@preference-sl/pref-viewer 2.10.0-beta.17 → 2.10.0-beta.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/gltf-storage.js +7 -1
- package/src/index.js +21 -18
package/package.json
CHANGED
package/src/gltf-storage.js
CHANGED
|
@@ -23,6 +23,12 @@ function _openEnsuringStore(dbName, storeName) {
|
|
|
23
23
|
}
|
|
24
24
|
open.onupgradeneeded = (ev) => {
|
|
25
25
|
const upgradeDb = ev.target.result;
|
|
26
|
+
|
|
27
|
+
// Eliminar la object store si ya existe
|
|
28
|
+
if (upgradeDb.objectStoreNames.contains(storeName)) {
|
|
29
|
+
upgradeDb.deleteObjectStore(storeName);
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
const store = upgradeDb.createObjectStore(storeName, { keyPath: 'id' });
|
|
27
33
|
store.createIndex('expirationTimeStamp', 'expirationTimeStamp', { unique: false });
|
|
28
34
|
};
|
|
@@ -218,4 +224,4 @@ export function deleteDatabase(dbName) {
|
|
|
218
224
|
};
|
|
219
225
|
// free to inspect PC.db in devtools
|
|
220
226
|
global.PrefConfigurator.storage = Object.freeze(storage);
|
|
221
|
-
})(globalThis);
|
|
227
|
+
})(globalThis);
|
package/src/index.js
CHANGED
|
@@ -299,7 +299,6 @@ class PrefViewer extends HTMLElement {
|
|
|
299
299
|
}
|
|
300
300
|
|
|
301
301
|
#setStatusOptionsLoaded() {
|
|
302
|
-
|
|
303
302
|
const toLoadDetail = {
|
|
304
303
|
inneWallMaterial: !!this.#data.options.materials.innerWall.changed,
|
|
305
304
|
outerWallMaterial: !!this.#data.options.materials.outerWall.changed,
|
|
@@ -310,7 +309,7 @@ class PrefViewer extends HTMLElement {
|
|
|
310
309
|
inneWallMaterial: !!this.#data.options.materials.innerWall.changed?.success,
|
|
311
310
|
outerWallMaterial: !!this.#data.options.materials.outerWall.changed?.success,
|
|
312
311
|
innerFloorMaterial: !!this.#data.options.materials.innerFloor.changed?.success,
|
|
313
|
-
|
|
312
|
+
outerFloorMaterial: !!this.#data.options.materials.outerFloor.changed?.success,
|
|
314
313
|
};
|
|
315
314
|
|
|
316
315
|
const detail = {
|
|
@@ -358,10 +357,13 @@ class PrefViewer extends HTMLElement {
|
|
|
358
357
|
if (success) {
|
|
359
358
|
container.timeStamp = container.changed.timeStamp;
|
|
360
359
|
container.size = container.changed.size;
|
|
361
|
-
|
|
360
|
+
container.changed.success = success;
|
|
361
|
+
} else if(container.changed) {
|
|
362
362
|
container.source = container.changed.source;
|
|
363
|
+
container.changed.success = success;
|
|
364
|
+
} else {
|
|
365
|
+
container.changed = { success: success };
|
|
363
366
|
}
|
|
364
|
-
container.changed.success = success;
|
|
365
367
|
}
|
|
366
368
|
|
|
367
369
|
#resetChangedFlags() {
|
|
@@ -455,6 +457,7 @@ class PrefViewer extends HTMLElement {
|
|
|
455
457
|
}
|
|
456
458
|
|
|
457
459
|
#createLights() {
|
|
460
|
+
|
|
458
461
|
// 1) Stronger ambient fill
|
|
459
462
|
this.#hemiLight = new HemisphericLight("hemiLight", new Vector3(-10, 10, -10), this.#scene);
|
|
460
463
|
this.#hemiLight.intensity = 0.6;
|
|
@@ -733,25 +736,13 @@ class PrefViewer extends HTMLElement {
|
|
|
733
736
|
}
|
|
734
737
|
|
|
735
738
|
async #loadContainers(loadModel = true, loadEnvironment = true, loadMaterials = true) {
|
|
739
|
+
this.#setStatusSceneLoading();
|
|
740
|
+
|
|
736
741
|
const promiseArray = [];
|
|
737
742
|
promiseArray.push(loadModel ? this.#loadAssetContainer(this.#data.containers.model) : false);
|
|
738
743
|
promiseArray.push(loadEnvironment ? this.#loadAssetContainer(this.#data.containers.environment) : false);
|
|
739
744
|
promiseArray.push(loadMaterials ? this.#loadAssetContainer(this.#data.containers.materials) : false);
|
|
740
745
|
|
|
741
|
-
const loadingDetail = {
|
|
742
|
-
model: !!this.#data.containers.model.changed,
|
|
743
|
-
environment: !!this.#data.containers.environment.changed,
|
|
744
|
-
materials: !!this.#data.containers.materials.changed,
|
|
745
|
-
options: {
|
|
746
|
-
camera: !!this.#data.options.camera.changed,
|
|
747
|
-
inneWallMaterial: !!this.#data.options.materials.innerWall.changed,
|
|
748
|
-
outerWallMaterial: !!this.#data.options.materials.outerWall.changed,
|
|
749
|
-
innerFloorMaterial: !!this.#data.options.materials.innerFloor.changed,
|
|
750
|
-
outerFloorMaterial: !!this.#data.options.materials.outerFloor.changed,
|
|
751
|
-
},
|
|
752
|
-
};
|
|
753
|
-
this.#setStatusSceneLoading(loadingDetail);
|
|
754
|
-
|
|
755
746
|
Promise.allSettled(promiseArray)
|
|
756
747
|
.then(async (values) => {
|
|
757
748
|
const modelContainer = values[0];
|
|
@@ -853,6 +844,7 @@ class PrefViewer extends HTMLElement {
|
|
|
853
844
|
if (!model) {
|
|
854
845
|
return false;
|
|
855
846
|
}
|
|
847
|
+
this.#data.containers.model.changed = { storage: this.#data.containers.model.storage || null };
|
|
856
848
|
this.#data.containers.model.storage = model.storage || null;
|
|
857
849
|
this.#data.containers.model.show = model.visible !== undefined ? model.visible : this.#data.containers.model.show;
|
|
858
850
|
this.initialized && this.#loadContainers(true, false, false);
|
|
@@ -863,11 +855,22 @@ class PrefViewer extends HTMLElement {
|
|
|
863
855
|
if (!scene) {
|
|
864
856
|
return false;
|
|
865
857
|
}
|
|
858
|
+
this.#data.containers.environment.changed = { storage: this.#data.containers.environment.storage || null };
|
|
866
859
|
this.#data.containers.environment.storage = scene.storage || null;
|
|
867
860
|
this.#data.containers.environment.show = scene.visible !== undefined ? scene.visible : this.#data.containers.environment.show;
|
|
868
861
|
this.initialized && this.#loadContainers(false, true, false);
|
|
869
862
|
}
|
|
870
863
|
|
|
864
|
+
loadMaterials(materials) {
|
|
865
|
+
materials = typeof materials === "string" ? JSON.parse(materials) : materials;
|
|
866
|
+
if (!materials) {
|
|
867
|
+
return false;
|
|
868
|
+
}
|
|
869
|
+
this.#data.containers.materials.changed = { storage: this.#data.containers.materials.storage || null };
|
|
870
|
+
this.#data.containers.materials.storage = materials.storage || null;
|
|
871
|
+
this.initialized && this.#loadContainers(false, false, true);
|
|
872
|
+
}
|
|
873
|
+
|
|
871
874
|
showModel() {
|
|
872
875
|
this.#data.containers.model.show = true;
|
|
873
876
|
this.#addContainer(this.#data.containers.model);
|