diff --git a/index.html b/index.html index 8249413e..8d22c09c 100644 --- a/index.html +++ b/index.html @@ -376,6 +376,8 @@

Animation

Model Credits

Copyright:
{{ assetCopyright }}
Generated by:
{{ assetGenerator }}
+

Environment Credits

+
Copyright:

{{ xmp ? "XMP" : "" }}

diff --git a/src/logic/uimodel.js b/src/logic/uimodel.js index bf26d62f..afe54358 100644 --- a/src/logic/uimodel.js +++ b/src/logic/uimodel.js @@ -29,7 +29,7 @@ class UIModel this.environmentRotation = app.environmentRotationChanged.pipe(); this.app.environments = environments; const selectedEnvironment = app.selectedEnvironmentChanged.pipe( - map(environmentName => this.app.environments[environmentName].hdr_path) + map(environmentName => this.app.environments[environmentName]) ); const initialEnvironment = "Cannon_Exterior"; this.app.selectedEnvironment = initialEnvironment; @@ -111,12 +111,40 @@ class UIModel ); this.model = merge(dropdownGltfChanged, dropdownFlavourChanged, inputObservables.droppedGltf); + this.hdr = merge(selectedEnvironment, this.addEnvironment, inputObservables.droppedHdr).pipe( - startWith(environments[initialEnvironment].hdr_path) + startWith(environments[initialEnvironment]) ); + this.hdr.subscribe(async hdr => { + if (hdr.license_path !== undefined) { + try { + const response = await fetch(hdr.license_path); + if (!response.ok) { + throw new Error("License file not found"); + } + let text = await response.text(); + const license = text.split("SPDX-License-Identifier: ")[1]; + console.log(license); + text = text.replace("SPDX-FileCopyrightText: ", ""); + text = text.replace(/SPDX-License-Identifier:(.)*/g, `, Source, License: `); + text += `${license}`; + text = "(c) " + text; + text = text.replaceAll("\n",""); + text = text.replaceAll(" ,", ","); + this.app.environmentLicense = text; + } catch (error) { + this.app.environmentLicense = "N/A"; + } + + } else { + this.app.environmentLicense = "N/A"; + } + }); + merge(this.addEnvironment, inputObservables.droppedHdr) - .subscribe(hdrPath => { + .subscribe(hdr => { + const hdrPath = hdr.hdr_path; this.app.environments[hdrPath.name] = { title: hdrPath.name, hdr_path: hdrPath, @@ -285,7 +313,8 @@ const getInputObservables = (inputElement, app) => { observables.droppedHdr = droppedFiles.pipe( map(files => files.find(([path]) => path.endsWith(".hdr"))), filter(file => file !== undefined), - pluck("1") + pluck("1"), + map(file => ({hdr_path: file})) ); const mouseMove = fromEvent(document, 'mousemove'); diff --git a/src/main.js b/src/main.js index 69259177..9cd9f57d 100644 --- a/src/main.js +++ b/src/main.js @@ -430,8 +430,8 @@ export default async () => { ); listenForRedraw(uiModel.activeAnimations); - uiModel.hdr.subscribe((hdrFile) => { - resourceLoader.loadEnvironment(hdrFile).then((environment) => { + uiModel.hdr.subscribe((hdr) => { + resourceLoader.loadEnvironment(hdr.hdr_path).then((environment) => { state.environment = environment; // We need to wait until the environment is loaded to redraw redraw = true; diff --git a/src/model_path_provider.js b/src/model_path_provider.js index 3d7e78c3..f0596851 100644 --- a/src/model_path_provider.js +++ b/src/model_path_provider.js @@ -68,7 +68,9 @@ export function fillEnvironmentWithPaths(environmentNames, environmentsBasePath) index: index, title: title, hdr_path: environmentsBasePath + name + ".hdr", - jpg_path: environmentsBasePath + name + ".jpg" + jpg_path: environmentsBasePath + name + ".jpg", + license_path: environmentsBasePath + name + ".hdr.license", + base_path: environmentsBasePath }; }); return environmentNames; diff --git a/src/ui/ui.js b/src/ui/ui.js index 33298f56..dcf8bbda 100644 --- a/src/ui/ui.js +++ b/src/ui/ui.js @@ -324,7 +324,7 @@ const appCreated = createApp({ }, onFileChange(e) { const file = e.target.files[0]; - this.addEnvironmentChanged.next(file); + this.addEnvironmentChanged.next({hdr_path: file}); }, toggleUI() {