@combeenation/3d-viewer 6.1.0-beta1 → 6.1.0-rc1
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/dist/lib-cjs/api/classes/variant.js +0 -8
- package/dist/lib-cjs/api/classes/variant.js.map +1 -1
- package/dist/lib-cjs/api/manager/textureLoadManager.d.ts +1 -1
- package/dist/lib-cjs/api/manager/textureLoadManager.js +8 -8
- package/dist/lib-cjs/api/manager/textureLoadManager.js.map +1 -1
- package/dist/lib-cjs/api/util/babylonHelper.d.ts +10 -6
- package/dist/lib-cjs/api/util/babylonHelper.js +7 -7
- package/dist/lib-cjs/api/util/babylonHelper.js.map +1 -1
- package/dist/lib-cjs/buildinfo.json +1 -1
- package/dist/lib-cjs/commonjs.tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/api/classes/variant.ts +0 -8
- package/src/api/manager/textureLoadManager.ts +9 -9
- package/src/api/util/babylonHelper.ts +12 -7
package/package.json
CHANGED
|
@@ -752,20 +752,12 @@ export class Variant extends Parameterizable {
|
|
|
752
752
|
const elIsHiddenViaParams = elVisibleParamValueParsed === false;
|
|
753
753
|
if (paramShowsVariant && elIsHiddenViaParams) continue;
|
|
754
754
|
|
|
755
|
-
// To discuss: Is this a viable solution or is it too hacky to apply the elements material param, when the param
|
|
756
|
-
// at hand is actually the visible param?
|
|
757
755
|
// Fixes https://combeenation.youtrack.cloud/issue/CB-7809
|
|
758
756
|
// Apply element material before showing the element to prevent loading of the elements "original" material which
|
|
759
757
|
// is never shown when "overwritten" by elements material param.
|
|
760
758
|
const elMaterialParamPath = DottedPath.create([element.name, Parameter.MATERIAL]).toString();
|
|
761
759
|
const elMaterialParamValue = this.inheritedParameters[elMaterialParamPath];
|
|
762
760
|
if (paramShowsVariant && elMaterialParamValue) {
|
|
763
|
-
// To discuss: Should we rather use `this.commitParametersToElements` here?
|
|
764
|
-
// I'm not really sure about the actual differences, both seem to do the job 🤷♂️
|
|
765
|
-
// To discuss: Should we actively `await` this (as is) or should we also push the resulting promise into the
|
|
766
|
-
// `promises` array as dome some lines below?
|
|
767
|
-
// I wasn't sure whether not awaiting this could result in "not guaranteed application order" of
|
|
768
|
-
// new visibility & material param value...
|
|
769
761
|
await element.commitParameter(Parameter.MATERIAL, elMaterialParamValue);
|
|
770
762
|
}
|
|
771
763
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Event } from '../classes/event';
|
|
2
2
|
import { EventBroadcaster } from '../classes/eventBroadcaster';
|
|
3
|
-
import {
|
|
3
|
+
import { isTextureWithOnLoadObservable } from '../util/babylonHelper';
|
|
4
4
|
import { sleep } from '../util/resourceHelper';
|
|
5
5
|
import { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';
|
|
6
6
|
import { Scene as BabylonScene } from '@babylonjs/core/scene';
|
|
@@ -20,7 +20,7 @@ export class TextureLoadManager extends EventBroadcaster {
|
|
|
20
20
|
// x ms if all awaited textures are in "ready state" or not.
|
|
21
21
|
// This is basically just an additional safety net in addition to our `onLoadObservable`s and was added to prevent
|
|
22
22
|
// situations where a {@link Event.TEXTURE_LOADING_START} event is fired without an accompanying
|
|
23
|
-
// {@link Event.
|
|
23
|
+
// {@link Event.TEXTURE_LOADING_END} as that is a situation which can lead to load masks being endlessly shown in a
|
|
24
24
|
// cfgr.
|
|
25
25
|
// In theory this shouldn't be necessary, but we've already discovered some quirks and inconsistent behavior around
|
|
26
26
|
// the texture load observables etc. and I felt more save with this safety net in place.
|
|
@@ -29,7 +29,7 @@ export class TextureLoadManager extends EventBroadcaster {
|
|
|
29
29
|
|
|
30
30
|
private constructor(public scene: BabylonScene) {
|
|
31
31
|
super();
|
|
32
|
-
this.scene.onNewTextureAddedObservable.add(this.onTextureAdded
|
|
32
|
+
this.scene.onNewTextureAddedObservable.add(texture => this.onTextureAdded(texture));
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
public static create(scene: BabylonScene): TextureLoadManager {
|
|
@@ -40,7 +40,7 @@ export class TextureLoadManager extends EventBroadcaster {
|
|
|
40
40
|
private startReadyStatePollingIfNeeded() {
|
|
41
41
|
if (!this._readyStatePollingId) {
|
|
42
42
|
this._readyStatePollingId = window.setInterval(
|
|
43
|
-
this.checkLoadingTexturesState
|
|
43
|
+
() => this.checkLoadingTexturesState(),
|
|
44
44
|
this._readyStatePollingIntervalMs
|
|
45
45
|
);
|
|
46
46
|
}
|
|
@@ -55,7 +55,7 @@ export class TextureLoadManager extends EventBroadcaster {
|
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Checks the "ready state" of all textures inside the `this._loadingTextures` map, removes the ready ones and fires
|
|
58
|
-
* the {@link Event.TEXTURE_LOADING_END} event if no more textures are loading (i.e. "
|
|
58
|
+
* the {@link Event.TEXTURE_LOADING_END} event if no more textures are loading (i.e. "all ready").
|
|
59
59
|
*/
|
|
60
60
|
private checkLoadingTexturesState() {
|
|
61
61
|
const allTexturesReadyBefore = !this._loadingTextures.size;
|
|
@@ -75,21 +75,21 @@ export class TextureLoadManager extends EventBroadcaster {
|
|
|
75
75
|
|
|
76
76
|
private async onTextureAdded(texture: BaseTexture) {
|
|
77
77
|
// Workaround:
|
|
78
|
-
// The texture object is not fully created when the added observable is called. E.g. the function
|
|
78
|
+
// The texture object is not fully created when the "added observable" is called. E.g. the function
|
|
79
79
|
// `onLoadObservable` is not there at that point.
|
|
80
80
|
// More details: https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/4
|
|
81
81
|
await sleep(0);
|
|
82
82
|
|
|
83
83
|
// Some textures are already in "ready state" after the sleep -> We don't care for them anymore as well as for
|
|
84
84
|
// textures which don't come with an `onLoadObservable` (i.e. not of class {@link Texture}).
|
|
85
|
-
if (texture.isReady() || !
|
|
85
|
+
if (texture.isReady() || !isTextureWithOnLoadObservable(texture)) return;
|
|
86
86
|
|
|
87
|
-
const noCurrentLoadingTextures = this._loadingTextures.size
|
|
87
|
+
const noCurrentLoadingTextures = !this._loadingTextures.size;
|
|
88
88
|
if (noCurrentLoadingTextures) {
|
|
89
89
|
this.broadcastEvent(Event.TEXTURE_LOADING_START);
|
|
90
90
|
this.startReadyStatePollingIfNeeded();
|
|
91
91
|
}
|
|
92
92
|
this._loadingTextures.set(texture.uniqueId, texture);
|
|
93
|
-
texture.onLoadObservable.addOnce(
|
|
93
|
+
texture.onLoadObservable.addOnce(texture => this.checkLoadingTexturesState());
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -18,6 +18,7 @@ import { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';
|
|
|
18
18
|
import { InstancedMesh } from '@babylonjs/core/Meshes/instancedMesh';
|
|
19
19
|
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
|
20
20
|
import { TransformNode } from '@babylonjs/core/Meshes/transformNode';
|
|
21
|
+
import { Observable } from '@babylonjs/core/Misc/observable';
|
|
21
22
|
import { Tools } from '@babylonjs/core/Misc/tools';
|
|
22
23
|
import { Node } from '@babylonjs/core/node';
|
|
23
24
|
import { Scene } from '@babylonjs/core/scene';
|
|
@@ -614,20 +615,24 @@ const getClientRectFromMesh = function (mesh: AbstractMesh, scene: Scene, canvas
|
|
|
614
615
|
} as ClientRect;
|
|
615
616
|
};
|
|
616
617
|
|
|
618
|
+
type BaseTextureWithOnLoadObservable = BaseTexture & {
|
|
619
|
+
onLoadObservable: Observable<BaseTexture>;
|
|
620
|
+
};
|
|
621
|
+
|
|
617
622
|
/**
|
|
618
|
-
* This type guard
|
|
619
|
-
*
|
|
623
|
+
* This type guard checks whether the given `BaseTextures` is any of its subtypes which comes with an
|
|
624
|
+
* `onLoadObservable`.
|
|
620
625
|
*
|
|
621
|
-
*
|
|
622
|
-
* https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/
|
|
626
|
+
* !!! Timing of when this function is called is important !!!
|
|
627
|
+
* See the following for more details: https://forum.babylonjs.com/t/basetexture-whenallready-returns-too-early/34501/6
|
|
623
628
|
*/
|
|
624
|
-
const
|
|
625
|
-
return !!(texture as
|
|
629
|
+
const isTextureWithOnLoadObservable = function (texture: BaseTexture): texture is BaseTextureWithOnLoadObservable {
|
|
630
|
+
return !!(texture as BaseTextureWithOnLoadObservable).onLoadObservable;
|
|
626
631
|
};
|
|
627
632
|
|
|
628
633
|
export {
|
|
629
634
|
getRootNode,
|
|
630
|
-
|
|
635
|
+
isTextureWithOnLoadObservable,
|
|
631
636
|
mapToDottedNodes,
|
|
632
637
|
getDottedPathForNode,
|
|
633
638
|
cloneTransformNode,
|