@configura/babylon-view 1.2.1 → 1.3.0-alpha.3
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/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/animation/AnimatableObject.d.ts +8 -8
- package/dist/animation/AnimatableObject.js +3 -3
- package/dist/animation/animator/Animator.d.ts +33 -33
- package/dist/animation/animator/Animator.js +58 -58
- package/dist/animation/animator/AnimatorEasing.d.ts +16 -16
- package/dist/animation/animator/AnimatorEasing.js +31 -31
- package/dist/animation/animator/AnimatorEasingMatrix.d.ts +14 -14
- package/dist/animation/animator/AnimatorEasingMatrix.js +16 -16
- package/dist/animation/animator/AnimatorHighlight.d.ts +16 -16
- package/dist/animation/animator/AnimatorHighlight.js +32 -32
- package/dist/animation/animator/AnimatorPointToPoint.d.ts +8 -8
- package/dist/animation/animator/AnimatorPointToPoint.js +14 -14
- package/dist/animation/animator/AnimatorQueue.d.ts +13 -13
- package/dist/animation/animator/AnimatorQueue.js +57 -57
- package/dist/animation/animator/AnimatorScale.d.ts +8 -8
- package/dist/animation/animator/AnimatorScale.js +13 -13
- package/dist/animation/animator/AnimatorSpin.d.ts +10 -10
- package/dist/animation/animator/AnimatorSpin.js +13 -13
- package/dist/animation/animator/EasingFunctions.d.ts +35 -35
- package/dist/animation/animator/EasingFunctions.js +137 -137
- package/dist/animation/coordinator/Coordinator.d.ts +28 -28
- package/dist/animation/coordinator/Coordinator.js +47 -47
- package/dist/animation/coordinator/CoordinatorDropAndSpin.d.ts +22 -22
- package/dist/animation/coordinator/CoordinatorDropAndSpin.js +133 -133
- package/dist/animation/coordinator/CoordinatorIdentity.d.ts +11 -11
- package/dist/animation/coordinator/CoordinatorIdentity.js +12 -12
- package/dist/animation/coordinator/CoordinatorNodeQueues.d.ts +18 -18
- package/dist/animation/coordinator/CoordinatorNodeQueues.js +50 -50
- package/dist/animation/coordinator/CoordinatorPulse.d.ts +21 -21
- package/dist/animation/coordinator/CoordinatorPulse.js +47 -47
- package/dist/animation/coordinator/CoordinatorPulseBounce.d.ts +14 -14
- package/dist/animation/coordinator/CoordinatorPulseBounce.js +40 -40
- package/dist/animation/coordinator/CoordinatorPulseHighlight.d.ts +13 -13
- package/dist/animation/coordinator/CoordinatorPulseHighlight.js +34 -34
- package/dist/animation/coordinator/CoordinatorPulseInflate.d.ts +14 -14
- package/dist/animation/coordinator/CoordinatorPulseInflate.js +30 -30
- package/dist/camera/CameraCreator.d.ts +5 -5
- package/dist/camera/CameraCreator.js +4 -4
- package/dist/camera/CfgArcRotateCameraPointersInput.d.ts +10 -10
- package/dist/camera/CfgArcRotateCameraPointersInput.js +262 -262
- package/dist/camera/CfgOrbitalCamera.d.ts +68 -64
- package/dist/camera/CfgOrbitalCamera.js +250 -233
- package/dist/camera/CfgOrbitalCameraControlProps.d.ts +6 -6
- package/dist/camera/CfgOrbitalCameraControlProps.js +3 -3
- package/dist/camera/GradingApplier.d.ts +3 -3
- package/dist/camera/GradingApplier.js +48 -48
- package/dist/engine/EngineCreator.d.ts +3 -3
- package/dist/engine/EngineCreator.js +10 -10
- package/dist/geometry/CfgGeometry.d.ts +12 -12
- package/dist/geometry/CfgGeometry.js +117 -117
- package/dist/geometry/CfgMesh.d.ts +7 -7
- package/dist/geometry/CfgMesh.js +8 -8
- package/dist/geometry/geoSplitter.d.ts +8 -8
- package/dist/geometry/geoSplitter.js +192 -192
- package/dist/index.d.ts +13 -13
- package/dist/index.js +13 -13
- package/dist/light/CfgDirectionalLight.d.ts +8 -8
- package/dist/light/CfgDirectionalLight.js +18 -18
- package/dist/light/CfgHemisphericLight.d.ts +7 -7
- package/dist/light/CfgHemisphericLight.js +17 -17
- package/dist/light/CfgPointLight.d.ts +8 -8
- package/dist/light/CfgPointLight.js +18 -18
- package/dist/light/DefaultLightRig.d.ts +19 -19
- package/dist/light/DefaultLightRig.js +77 -77
- package/dist/light/LightRigCreator.d.ts +9 -9
- package/dist/light/LightRigCreator.js +3 -3
- package/dist/material/CfgMaterial.d.ts +53 -53
- package/dist/material/CfgMaterial.js +454 -454
- package/dist/material/DummyMaterialCreator.d.ts +4 -4
- package/dist/material/DummyMaterialCreator.js +15 -15
- package/dist/material/material.d.ts +18 -18
- package/dist/material/material.js +128 -128
- package/dist/material/texture.d.ts +14 -14
- package/dist/material/texture.js +304 -304
- package/dist/nodes/CfgContentRootNode.d.ts +19 -19
- package/dist/nodes/CfgContentRootNode.js +75 -75
- package/dist/nodes/CfgDeferredMeshNode.d.ts +48 -48
- package/dist/nodes/CfgDeferredMeshNode.js +347 -347
- package/dist/nodes/CfgProductNode.d.ts +61 -61
- package/dist/nodes/CfgProductNode.js +486 -486
- package/dist/nodes/CfgSymNode.d.ts +42 -42
- package/dist/nodes/CfgSymNode.js +216 -216
- package/dist/nodes/CfgSymRootNode.d.ts +33 -33
- package/dist/nodes/CfgSymRootNode.js +175 -175
- package/dist/nodes/CfgTransformNode.d.ts +29 -29
- package/dist/nodes/CfgTransformNode.js +81 -81
- package/dist/scene/SceneCreator.d.ts +6 -6
- package/dist/scene/SceneCreator.js +22 -22
- package/dist/utilities/CfgBoundingBox.d.ts +16 -16
- package/dist/utilities/CfgBoundingBox.js +64 -64
- package/dist/utilities/utilities3D.d.ts +26 -26
- package/dist/utilities/utilities3D.js +187 -187
- package/dist/utilities/utilitiesColor.d.ts +18 -18
- package/dist/utilities/utilitiesColor.js +48 -48
- package/dist/utilities/utilitiesImage.d.ts +6 -6
- package/dist/utilities/utilitiesImage.js +107 -107
- package/dist/utilities/utilitiesSymRootIdentifier.d.ts +5 -5
- package/dist/utilities/utilitiesSymRootIdentifier.js +20 -20
- package/dist/view/BaseView.d.ts +70 -70
- package/dist/view/BaseView.js +291 -291
- package/dist/view/BaseViewConfiguration.d.ts +32 -32
- package/dist/view/BaseViewConfiguration.js +8 -8
- package/dist/view/RenderEnv.d.ts +38 -38
- package/dist/view/RenderEnv.js +7 -7
- package/dist/view/SingleProductDefaultCameraView.d.ts +33 -33
- package/dist/view/SingleProductDefaultCameraView.js +141 -140
- package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +46 -44
- package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
- package/dist/view/SingleProductView.d.ts +42 -42
- package/dist/view/SingleProductView.js +205 -205
- package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
- package/dist/view/SingleProductViewConfiguration.js +19 -19
- package/package.json +5 -5
|
@@ -1,175 +1,175 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
|
11
|
-
import { InspectableType } from "@babylonjs/core/Misc/iInspectable.js";
|
|
12
|
-
import { isModel, } from "@configura/web-api";
|
|
13
|
-
import { SymGfxMode } from "@configura/web-core/dist/cm/format/cmsym/components/SymComponent.js";
|
|
14
|
-
import { loadSymFile, makeSymFromDex, } from "@configura/web-core/dist/cm/format/cmsym/SymNode.js";
|
|
15
|
-
import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
|
|
16
|
-
import { readFileToArrayBuffer } from "@configura/web-utilities";
|
|
17
|
-
import { modelTransformToSymTransform, symTransformToMatrix } from "../utilities/utilities3D.js";
|
|
18
|
-
import { isSameIdentifierAndTransform, makeIdentifier, makeIdentifierFromRootNodeSource, } from "../utilities/utilitiesSymRootIdentifier.js";
|
|
19
|
-
import { CfgSymNode } from "./CfgSymNode.js";
|
|
20
|
-
export function isSymRootNode(value) {
|
|
21
|
-
return value instanceof CfgSymRootNode;
|
|
22
|
-
}
|
|
23
|
-
function loadCachedSymNode(logger, url, renderEnvironment) {
|
|
24
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return renderEnvironment.symNodeCache.get(url, () => {
|
|
26
|
-
return loadSymFile(logger, url, renderEnvironment.dexManager);
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
function getBestMatchingDetailLevel(logger, symNode, allowedLevels) {
|
|
31
|
-
const symReps = symNode.symReps();
|
|
32
|
-
if (symReps === undefined) {
|
|
33
|
-
logger.warn("node has no SymReps", symNode);
|
|
34
|
-
return DetailLevel.undefined;
|
|
35
|
-
}
|
|
36
|
-
const detailMask = symReps.detailMask(SymGfxMode.x3D);
|
|
37
|
-
if (detailMask === undefined) {
|
|
38
|
-
logger.warn("symReps has no DetailMask", symReps);
|
|
39
|
-
return DetailLevel.undefined;
|
|
40
|
-
}
|
|
41
|
-
const detailLevel = detailMask.getBestMatch(allowedLevels);
|
|
42
|
-
if (detailLevel === undefined) {
|
|
43
|
-
logger.warn("No matching DetailLevel found", `available:${Array.from(detailMask.detailSet().values())}`, `allowed:${allowedLevels}`);
|
|
44
|
-
return DetailLevel.undefined;
|
|
45
|
-
}
|
|
46
|
-
return detailLevel || DetailLevel.undefined;
|
|
47
|
-
}
|
|
48
|
-
export class CfgSymRootNode extends CfgSymNode {
|
|
49
|
-
constructor(renderEnvironment, _isForDebug, detailLevel, symNode, _identifier, modelTransform) {
|
|
50
|
-
super(renderEnvironment, detailLevel, symNode);
|
|
51
|
-
this._isForDebug = _isForDebug;
|
|
52
|
-
this._identifier = _identifier;
|
|
53
|
-
this._destroyed = false;
|
|
54
|
-
this.name = "(SymRoot) " + symNode.id;
|
|
55
|
-
this.modelTransform = modelTransform;
|
|
56
|
-
this.initTransform();
|
|
57
|
-
}
|
|
58
|
-
static makeCfgSymRootFromRootNodeSource(logger, isForDebug, renderEnvironment, rootNodeSource) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
return isModel(rootNodeSource)
|
|
61
|
-
? CfgSymRootNode.makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, rootNodeSource.uri, rootNodeSource.t)
|
|
62
|
-
: CfgSymRootNode.makeCfgSymRootFromFile(logger, isForDebug, renderEnvironment, rootNodeSource);
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
static makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, symUrl, transform) {
|
|
66
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
-
if (!/.cmsym$/i.test(symUrl)) {
|
|
68
|
-
renderEnvironment.notifyError(logger.errorAsObject("Unsupported model URL (not cmsym format): ", symUrl));
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
try {
|
|
72
|
-
const symNode = yield loadCachedSymNode(logger, symUrl, renderEnvironment);
|
|
73
|
-
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, makeIdentifier("uri", symUrl), transform, symNode);
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
logger.errorFromCaught(e);
|
|
77
|
-
renderEnvironment.notifyError("Failed to load model-file. Please reload or change selection.");
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
static makeCfgSymRootFromFile(logger, isForDebug, renderEnvironment, file) {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
const arrayBuffer = yield readFileToArrayBuffer(file);
|
|
84
|
-
const dexObj = renderEnvironment.dexManager.arrayBufferToDexObj(logger, "", arrayBuffer.buffer);
|
|
85
|
-
const symNode = makeSymFromDex(logger, dexObj);
|
|
86
|
-
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, makeIdentifier("file", file.name), undefined, symNode);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
get cfgClassName() {
|
|
90
|
-
return "CfgSymRootNode";
|
|
91
|
-
}
|
|
92
|
-
static makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, identifier, transform, symNode) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
if (symNode === undefined) {
|
|
95
|
-
logger.warn("No symNode");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const detailLevel = getBestMatchingDetailLevel(logger, symNode, renderEnvironment.allowedDetailLevels);
|
|
99
|
-
const node = new CfgSymRootNode(renderEnvironment, isForDebug, detailLevel, symNode, identifier, transform);
|
|
100
|
-
yield CfgSymNode.initCfgSymNode(node);
|
|
101
|
-
return node;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
get isForDebug() {
|
|
105
|
-
return this._isForDebug;
|
|
106
|
-
}
|
|
107
|
-
isSameIdentifierAndTransform(rootNodeSource) {
|
|
108
|
-
return isSameIdentifierAndTransform(this._identifier, this.modelTransform, makeIdentifierFromRootNodeSource(rootNodeSource), isModel(rootNodeSource) ? rootNodeSource.t : undefined);
|
|
109
|
-
}
|
|
110
|
-
destroy() {
|
|
111
|
-
this._destroyed = true;
|
|
112
|
-
}
|
|
113
|
-
isDestroyed() {
|
|
114
|
-
return this._destroyed;
|
|
115
|
-
}
|
|
116
|
-
applyGeo() {
|
|
117
|
-
if (this._destroyed) {
|
|
118
|
-
throw Error("Apply geo on destroyed node");
|
|
119
|
-
}
|
|
120
|
-
return super.applyGeo();
|
|
121
|
-
}
|
|
122
|
-
setMaterialsAndLoad(areasToMaterials, animatorCoordinator) {
|
|
123
|
-
const _super = Object.create(null, {
|
|
124
|
-
setMaterialsAndLoad: { get: () => super.setMaterialsAndLoad }
|
|
125
|
-
});
|
|
126
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
-
if (this._destroyed) {
|
|
128
|
-
throw Error("setMaterials on destroyed node");
|
|
129
|
-
}
|
|
130
|
-
yield _super.setMaterialsAndLoad.call(this, areasToMaterials, animatorCoordinator);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
applyMaterial() {
|
|
134
|
-
if (this._destroyed) {
|
|
135
|
-
throw Error("applyMaterial on destroyed node");
|
|
136
|
-
}
|
|
137
|
-
super.applyMaterial();
|
|
138
|
-
}
|
|
139
|
-
get modelTransform() {
|
|
140
|
-
return this._modelTransform;
|
|
141
|
-
}
|
|
142
|
-
set modelTransform(value) {
|
|
143
|
-
this._modelTransform = value;
|
|
144
|
-
this._originalMatrixWithModelTransform = undefined;
|
|
145
|
-
}
|
|
146
|
-
get originalMatrix() {
|
|
147
|
-
if (this._originalMatrixWithModelTransform === undefined) {
|
|
148
|
-
const originalMatrix = super.originalMatrix;
|
|
149
|
-
let modelMatrix = Matrix.Identity();
|
|
150
|
-
const modelTransform = this.modelTransform;
|
|
151
|
-
if (modelTransform !== undefined) {
|
|
152
|
-
const modelSymTransform = modelTransformToSymTransform(modelTransform);
|
|
153
|
-
modelMatrix = symTransformToMatrix(modelSymTransform.transform());
|
|
154
|
-
}
|
|
155
|
-
this._originalMatrixWithModelTransform = originalMatrix.multiply(modelMatrix);
|
|
156
|
-
}
|
|
157
|
-
return this._originalMatrixWithModelTransform;
|
|
158
|
-
}
|
|
159
|
-
addInspectorProperties() {
|
|
160
|
-
super.addInspectorProperties();
|
|
161
|
-
this.addInspectableCustomProperty({
|
|
162
|
-
label: "Is for Debug",
|
|
163
|
-
propertyName: "_inspectorIsForDebug",
|
|
164
|
-
type: InspectableType.String,
|
|
165
|
-
});
|
|
166
|
-
this.addInspectableCustomProperty({
|
|
167
|
-
label: "SymUrl",
|
|
168
|
-
propertyName: "_symUrl",
|
|
169
|
-
type: InspectableType.String,
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
get _inspectorIsForDebug() {
|
|
173
|
-
return this._isForDebug ? "Yes" : "No";
|
|
174
|
-
}
|
|
175
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
|
11
|
+
import { InspectableType } from "@babylonjs/core/Misc/iInspectable.js";
|
|
12
|
+
import { isModel, } from "@configura/web-api";
|
|
13
|
+
import { SymGfxMode } from "@configura/web-core/dist/cm/format/cmsym/components/SymComponent.js";
|
|
14
|
+
import { loadSymFile, makeSymFromDex, } from "@configura/web-core/dist/cm/format/cmsym/SymNode.js";
|
|
15
|
+
import { DetailLevel } from "@configura/web-core/dist/cm/geometry/DetailMask.js";
|
|
16
|
+
import { readFileToArrayBuffer } from "@configura/web-utilities";
|
|
17
|
+
import { modelTransformToSymTransform, symTransformToMatrix } from "../utilities/utilities3D.js";
|
|
18
|
+
import { isSameIdentifierAndTransform, makeIdentifier, makeIdentifierFromRootNodeSource, } from "../utilities/utilitiesSymRootIdentifier.js";
|
|
19
|
+
import { CfgSymNode } from "./CfgSymNode.js";
|
|
20
|
+
export function isSymRootNode(value) {
|
|
21
|
+
return value instanceof CfgSymRootNode;
|
|
22
|
+
}
|
|
23
|
+
function loadCachedSymNode(logger, url, renderEnvironment) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return renderEnvironment.symNodeCache.get(url, () => {
|
|
26
|
+
return loadSymFile(logger, url, renderEnvironment.dexManager);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function getBestMatchingDetailLevel(logger, symNode, allowedLevels) {
|
|
31
|
+
const symReps = symNode.symReps();
|
|
32
|
+
if (symReps === undefined) {
|
|
33
|
+
logger.warn("node has no SymReps", symNode);
|
|
34
|
+
return DetailLevel.undefined;
|
|
35
|
+
}
|
|
36
|
+
const detailMask = symReps.detailMask(SymGfxMode.x3D);
|
|
37
|
+
if (detailMask === undefined) {
|
|
38
|
+
logger.warn("symReps has no DetailMask", symReps);
|
|
39
|
+
return DetailLevel.undefined;
|
|
40
|
+
}
|
|
41
|
+
const detailLevel = detailMask.getBestMatch(allowedLevels);
|
|
42
|
+
if (detailLevel === undefined) {
|
|
43
|
+
logger.warn("No matching DetailLevel found", `available:${Array.from(detailMask.detailSet().values())}`, `allowed:${allowedLevels}`);
|
|
44
|
+
return DetailLevel.undefined;
|
|
45
|
+
}
|
|
46
|
+
return detailLevel || DetailLevel.undefined;
|
|
47
|
+
}
|
|
48
|
+
export class CfgSymRootNode extends CfgSymNode {
|
|
49
|
+
constructor(renderEnvironment, _isForDebug, detailLevel, symNode, _identifier, modelTransform) {
|
|
50
|
+
super(renderEnvironment, detailLevel, symNode);
|
|
51
|
+
this._isForDebug = _isForDebug;
|
|
52
|
+
this._identifier = _identifier;
|
|
53
|
+
this._destroyed = false;
|
|
54
|
+
this.name = "(SymRoot) " + symNode.id;
|
|
55
|
+
this.modelTransform = modelTransform;
|
|
56
|
+
this.initTransform();
|
|
57
|
+
}
|
|
58
|
+
static makeCfgSymRootFromRootNodeSource(logger, isForDebug, renderEnvironment, rootNodeSource) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
return isModel(rootNodeSource)
|
|
61
|
+
? CfgSymRootNode.makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, rootNodeSource.uri, rootNodeSource.t)
|
|
62
|
+
: CfgSymRootNode.makeCfgSymRootFromFile(logger, isForDebug, renderEnvironment, rootNodeSource);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
static makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, symUrl, transform) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (!/.cmsym$/i.test(symUrl)) {
|
|
68
|
+
renderEnvironment.notifyError(logger.errorAsObject("Unsupported model URL (not cmsym format): ", symUrl));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
const symNode = yield loadCachedSymNode(logger, symUrl, renderEnvironment);
|
|
73
|
+
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, makeIdentifier("uri", symUrl), transform, symNode);
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
logger.errorFromCaught(e);
|
|
77
|
+
renderEnvironment.notifyError("Failed to load model-file. Please reload or change selection.");
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
static makeCfgSymRootFromFile(logger, isForDebug, renderEnvironment, file) {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
const arrayBuffer = yield readFileToArrayBuffer(file);
|
|
84
|
+
const dexObj = renderEnvironment.dexManager.arrayBufferToDexObj(logger, "", arrayBuffer.buffer);
|
|
85
|
+
const symNode = makeSymFromDex(logger, dexObj);
|
|
86
|
+
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, makeIdentifier("file", file.name), undefined, symNode);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
get cfgClassName() {
|
|
90
|
+
return "CfgSymRootNode";
|
|
91
|
+
}
|
|
92
|
+
static makeCfgSymRootFromSymNode(logger, renderEnvironment, isForDebug, identifier, transform, symNode) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
if (symNode === undefined) {
|
|
95
|
+
logger.warn("No symNode");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const detailLevel = getBestMatchingDetailLevel(logger, symNode, renderEnvironment.allowedDetailLevels);
|
|
99
|
+
const node = new CfgSymRootNode(renderEnvironment, isForDebug, detailLevel, symNode, identifier, transform);
|
|
100
|
+
yield CfgSymNode.initCfgSymNode(node);
|
|
101
|
+
return node;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
get isForDebug() {
|
|
105
|
+
return this._isForDebug;
|
|
106
|
+
}
|
|
107
|
+
isSameIdentifierAndTransform(rootNodeSource) {
|
|
108
|
+
return isSameIdentifierAndTransform(this._identifier, this.modelTransform, makeIdentifierFromRootNodeSource(rootNodeSource), isModel(rootNodeSource) ? rootNodeSource.t : undefined);
|
|
109
|
+
}
|
|
110
|
+
destroy() {
|
|
111
|
+
this._destroyed = true;
|
|
112
|
+
}
|
|
113
|
+
isDestroyed() {
|
|
114
|
+
return this._destroyed;
|
|
115
|
+
}
|
|
116
|
+
applyGeo() {
|
|
117
|
+
if (this._destroyed) {
|
|
118
|
+
throw Error("Apply geo on destroyed node");
|
|
119
|
+
}
|
|
120
|
+
return super.applyGeo();
|
|
121
|
+
}
|
|
122
|
+
setMaterialsAndLoad(areasToMaterials, animatorCoordinator) {
|
|
123
|
+
const _super = Object.create(null, {
|
|
124
|
+
setMaterialsAndLoad: { get: () => super.setMaterialsAndLoad }
|
|
125
|
+
});
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
if (this._destroyed) {
|
|
128
|
+
throw Error("setMaterials on destroyed node");
|
|
129
|
+
}
|
|
130
|
+
yield _super.setMaterialsAndLoad.call(this, areasToMaterials, animatorCoordinator);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
applyMaterial() {
|
|
134
|
+
if (this._destroyed) {
|
|
135
|
+
throw Error("applyMaterial on destroyed node");
|
|
136
|
+
}
|
|
137
|
+
super.applyMaterial();
|
|
138
|
+
}
|
|
139
|
+
get modelTransform() {
|
|
140
|
+
return this._modelTransform;
|
|
141
|
+
}
|
|
142
|
+
set modelTransform(value) {
|
|
143
|
+
this._modelTransform = value;
|
|
144
|
+
this._originalMatrixWithModelTransform = undefined;
|
|
145
|
+
}
|
|
146
|
+
get originalMatrix() {
|
|
147
|
+
if (this._originalMatrixWithModelTransform === undefined) {
|
|
148
|
+
const originalMatrix = super.originalMatrix;
|
|
149
|
+
let modelMatrix = Matrix.Identity();
|
|
150
|
+
const modelTransform = this.modelTransform;
|
|
151
|
+
if (modelTransform !== undefined) {
|
|
152
|
+
const modelSymTransform = modelTransformToSymTransform(modelTransform);
|
|
153
|
+
modelMatrix = symTransformToMatrix(modelSymTransform.transform());
|
|
154
|
+
}
|
|
155
|
+
this._originalMatrixWithModelTransform = originalMatrix.multiply(modelMatrix);
|
|
156
|
+
}
|
|
157
|
+
return this._originalMatrixWithModelTransform;
|
|
158
|
+
}
|
|
159
|
+
addInspectorProperties() {
|
|
160
|
+
super.addInspectorProperties();
|
|
161
|
+
this.addInspectableCustomProperty({
|
|
162
|
+
label: "Is for Debug",
|
|
163
|
+
propertyName: "_inspectorIsForDebug",
|
|
164
|
+
type: InspectableType.String,
|
|
165
|
+
});
|
|
166
|
+
this.addInspectableCustomProperty({
|
|
167
|
+
label: "SymUrl",
|
|
168
|
+
propertyName: "_symUrl",
|
|
169
|
+
type: InspectableType.String,
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
get _inspectorIsForDebug() {
|
|
173
|
+
return this._isForDebug ? "Yes" : "No";
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
|
2
|
-
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
3
|
-
import { IInspectable } from "@babylonjs/core/Misc/iInspectable.js";
|
|
4
|
-
import { Node } from "@babylonjs/core/node.js";
|
|
5
|
-
import { RenderEnv } from "../view/RenderEnv.js";
|
|
6
|
-
export declare abstract class CfgTransformNode extends TransformNode {
|
|
7
|
-
protected _renderEnvironment: RenderEnv;
|
|
8
|
-
constructor(_renderEnvironment: RenderEnv, name: string);
|
|
9
|
-
/**
|
|
10
|
-
* Provides a class name to show in the Babylon.js Inspector.
|
|
11
|
-
* Override in subclasses.
|
|
12
|
-
*/
|
|
13
|
-
get cfgClassName(): string;
|
|
14
|
-
protected getChildrenForAnimation(): CfgTransformNode[];
|
|
15
|
-
clear(dispose: boolean): void;
|
|
16
|
-
add(...objects: Node[]): void;
|
|
17
|
-
abstract get originalMatrix(): Matrix;
|
|
18
|
-
get worldOriginalMatrix(): Matrix;
|
|
19
|
-
remove(dispose: boolean, ...objects: Node[]): this;
|
|
20
|
-
/**
|
|
21
|
-
* Adds the property to the instance so it shows up in the Babylon.js Inspector.
|
|
22
|
-
*
|
|
23
|
-
* TODO Babylon: Currently they show up as editable, even though they are used to display
|
|
24
|
-
* read-only information. Metadata seems to be more correct, but is not (yet?) included by the
|
|
25
|
-
* Inspector.
|
|
26
|
-
*/
|
|
27
|
-
protected addInspectableCustomProperty(property: IInspectable): void;
|
|
28
|
-
protected addInspectorProperties(): void;
|
|
29
|
-
}
|
|
1
|
+
import { Matrix } from "@babylonjs/core/Maths/math.vector.js";
|
|
2
|
+
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
3
|
+
import { IInspectable } from "@babylonjs/core/Misc/iInspectable.js";
|
|
4
|
+
import { Node } from "@babylonjs/core/node.js";
|
|
5
|
+
import { RenderEnv } from "../view/RenderEnv.js";
|
|
6
|
+
export declare abstract class CfgTransformNode extends TransformNode {
|
|
7
|
+
protected _renderEnvironment: RenderEnv;
|
|
8
|
+
constructor(_renderEnvironment: RenderEnv, name: string);
|
|
9
|
+
/**
|
|
10
|
+
* Provides a class name to show in the Babylon.js Inspector.
|
|
11
|
+
* Override in subclasses.
|
|
12
|
+
*/
|
|
13
|
+
get cfgClassName(): string;
|
|
14
|
+
protected getChildrenForAnimation(): CfgTransformNode[];
|
|
15
|
+
clear(dispose: boolean): void;
|
|
16
|
+
add(...objects: Node[]): void;
|
|
17
|
+
abstract get originalMatrix(): Matrix;
|
|
18
|
+
get worldOriginalMatrix(): Matrix;
|
|
19
|
+
remove(dispose: boolean, ...objects: Node[]): this;
|
|
20
|
+
/**
|
|
21
|
+
* Adds the property to the instance so it shows up in the Babylon.js Inspector.
|
|
22
|
+
*
|
|
23
|
+
* TODO Babylon: Currently they show up as editable, even though they are used to display
|
|
24
|
+
* read-only information. Metadata seems to be more correct, but is not (yet?) included by the
|
|
25
|
+
* Inspector.
|
|
26
|
+
*/
|
|
27
|
+
protected addInspectableCustomProperty(property: IInspectable): void;
|
|
28
|
+
protected addInspectorProperties(): void;
|
|
29
|
+
}
|
|
30
30
|
//# sourceMappingURL=CfgTransformNode.d.ts.map
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
2
|
-
import { InspectableType } from "@babylonjs/core/Misc/iInspectable.js";
|
|
3
|
-
export class CfgTransformNode extends TransformNode {
|
|
4
|
-
constructor(_renderEnvironment, name) {
|
|
5
|
-
super(name, _renderEnvironment.scene);
|
|
6
|
-
this._renderEnvironment = _renderEnvironment;
|
|
7
|
-
this.addInspectorProperties();
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Provides a class name to show in the Babylon.js Inspector.
|
|
11
|
-
* Override in subclasses.
|
|
12
|
-
*/
|
|
13
|
-
get cfgClassName() {
|
|
14
|
-
return "CfgTransformNode";
|
|
15
|
-
}
|
|
16
|
-
getChildrenForAnimation() {
|
|
17
|
-
const result = [];
|
|
18
|
-
for (const c of this.getChildren()) {
|
|
19
|
-
if (c instanceof CfgTransformNode) {
|
|
20
|
-
result.push(c);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return result;
|
|
24
|
-
}
|
|
25
|
-
clear(dispose) {
|
|
26
|
-
const children = this.getChildren();
|
|
27
|
-
if (children.length > 0) {
|
|
28
|
-
this.remove(dispose, ...children.slice());
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
add(...objects) {
|
|
32
|
-
for (const obj of objects) {
|
|
33
|
-
if (obj === this) {
|
|
34
|
-
console.error("CfgTransformNode.add: object can't be added as a child of itself.", obj);
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
obj.parent = this;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
/// Recursively calculates the world matrix based on originalMatrix on
|
|
41
|
-
/// nodes which inherits CfgTransformNode.
|
|
42
|
-
get worldOriginalMatrix() {
|
|
43
|
-
const o = this.originalMatrix;
|
|
44
|
-
const p = this.parent;
|
|
45
|
-
if (p && p instanceof CfgTransformNode) {
|
|
46
|
-
return o.multiply(p.worldOriginalMatrix);
|
|
47
|
-
}
|
|
48
|
-
return o;
|
|
49
|
-
}
|
|
50
|
-
remove(dispose, ...objects) {
|
|
51
|
-
for (const obj of objects) {
|
|
52
|
-
if (dispose) {
|
|
53
|
-
obj.dispose();
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
obj.parent = null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Adds the property to the instance so it shows up in the Babylon.js Inspector.
|
|
63
|
-
*
|
|
64
|
-
* TODO Babylon: Currently they show up as editable, even though they are used to display
|
|
65
|
-
* read-only information. Metadata seems to be more correct, but is not (yet?) included by the
|
|
66
|
-
* Inspector.
|
|
67
|
-
*/
|
|
68
|
-
addInspectableCustomProperty(property) {
|
|
69
|
-
if (this.inspectableCustomProperties === undefined) {
|
|
70
|
-
this.inspectableCustomProperties = [];
|
|
71
|
-
}
|
|
72
|
-
this.inspectableCustomProperties.push(property);
|
|
73
|
-
}
|
|
74
|
-
addInspectorProperties() {
|
|
75
|
-
this.addInspectableCustomProperty({
|
|
76
|
-
label: "Cfg Class",
|
|
77
|
-
propertyName: "cfgClassName",
|
|
78
|
-
type: InspectableType.String,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
1
|
+
import { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
|
2
|
+
import { InspectableType } from "@babylonjs/core/Misc/iInspectable.js";
|
|
3
|
+
export class CfgTransformNode extends TransformNode {
|
|
4
|
+
constructor(_renderEnvironment, name) {
|
|
5
|
+
super(name, _renderEnvironment.scene);
|
|
6
|
+
this._renderEnvironment = _renderEnvironment;
|
|
7
|
+
this.addInspectorProperties();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Provides a class name to show in the Babylon.js Inspector.
|
|
11
|
+
* Override in subclasses.
|
|
12
|
+
*/
|
|
13
|
+
get cfgClassName() {
|
|
14
|
+
return "CfgTransformNode";
|
|
15
|
+
}
|
|
16
|
+
getChildrenForAnimation() {
|
|
17
|
+
const result = [];
|
|
18
|
+
for (const c of this.getChildren()) {
|
|
19
|
+
if (c instanceof CfgTransformNode) {
|
|
20
|
+
result.push(c);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
clear(dispose) {
|
|
26
|
+
const children = this.getChildren();
|
|
27
|
+
if (children.length > 0) {
|
|
28
|
+
this.remove(dispose, ...children.slice());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
add(...objects) {
|
|
32
|
+
for (const obj of objects) {
|
|
33
|
+
if (obj === this) {
|
|
34
|
+
console.error("CfgTransformNode.add: object can't be added as a child of itself.", obj);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
obj.parent = this;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/// Recursively calculates the world matrix based on originalMatrix on
|
|
41
|
+
/// nodes which inherits CfgTransformNode.
|
|
42
|
+
get worldOriginalMatrix() {
|
|
43
|
+
const o = this.originalMatrix;
|
|
44
|
+
const p = this.parent;
|
|
45
|
+
if (p && p instanceof CfgTransformNode) {
|
|
46
|
+
return o.multiply(p.worldOriginalMatrix);
|
|
47
|
+
}
|
|
48
|
+
return o;
|
|
49
|
+
}
|
|
50
|
+
remove(dispose, ...objects) {
|
|
51
|
+
for (const obj of objects) {
|
|
52
|
+
if (dispose) {
|
|
53
|
+
obj.dispose();
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
obj.parent = null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Adds the property to the instance so it shows up in the Babylon.js Inspector.
|
|
63
|
+
*
|
|
64
|
+
* TODO Babylon: Currently they show up as editable, even though they are used to display
|
|
65
|
+
* read-only information. Metadata seems to be more correct, but is not (yet?) included by the
|
|
66
|
+
* Inspector.
|
|
67
|
+
*/
|
|
68
|
+
addInspectableCustomProperty(property) {
|
|
69
|
+
if (this.inspectableCustomProperties === undefined) {
|
|
70
|
+
this.inspectableCustomProperties = [];
|
|
71
|
+
}
|
|
72
|
+
this.inspectableCustomProperties.push(property);
|
|
73
|
+
}
|
|
74
|
+
addInspectorProperties() {
|
|
75
|
+
this.addInspectableCustomProperty({
|
|
76
|
+
label: "Cfg Class",
|
|
77
|
+
propertyName: "cfgClassName",
|
|
78
|
+
type: InspectableType.String,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
-
import "@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js";
|
|
3
|
-
import "@babylonjs/core/Misc/dds.js";
|
|
4
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
|
5
|
-
export declare type SceneCreator = (engine: Engine) => Scene;
|
|
6
|
-
export declare function getDefaultScene(engine: Engine, envUrl?: string): Scene;
|
|
1
|
+
import { Engine } from "@babylonjs/core/Engines/engine.js";
|
|
2
|
+
import "@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js";
|
|
3
|
+
import "@babylonjs/core/Misc/dds.js";
|
|
4
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
5
|
+
export declare type SceneCreator = (engine: Engine) => Scene;
|
|
6
|
+
export declare function getDefaultScene(engine: Engine, envUrl?: string): Scene;
|
|
7
7
|
//# sourceMappingURL=SceneCreator.d.ts.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture.js";
|
|
2
|
-
import "@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js"; // Needed for environment map
|
|
3
|
-
import { Color4 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
|
-
import "@babylonjs/core/Misc/dds.js"; // Needed for environment map
|
|
5
|
-
import { Scene } from "@babylonjs/core/scene.js";
|
|
6
|
-
const DEFAULT_ENV_URL = "https://catalogueapi-demo.configura.com/envmap/default.env";
|
|
7
|
-
export function getDefaultScene(engine, envUrl) {
|
|
8
|
-
var scene = new Scene(engine);
|
|
9
|
-
// If the alpha component of the clearColor is set to 0, then the color components MUST also be
|
|
10
|
-
// set to 0. Otherwise the color components will sneak into transparent objects in the scene.
|
|
11
|
-
//
|
|
12
|
-
// This is because WebGL uses premultiplied alpha colors by default. In premultiplied alpha the
|
|
13
|
-
// color components have already been multiplied by the alpha value, and "X * 0" is always
|
|
14
|
-
// zero, no matter what X is. A color like "1, 0, 0, 0" is thus not an valid premultiplied
|
|
15
|
-
// color and the results is per the WebGL specs undefined.
|
|
16
|
-
scene.clearColor = new Color4(0, 0, 0, 0).toLinearSpace();
|
|
17
|
-
var hdrTexture = CubeTexture.CreateFromPrefilteredData(envUrl || DEFAULT_ENV_URL, scene);
|
|
18
|
-
hdrTexture.gammaSpace = false;
|
|
19
|
-
scene.environmentTexture = hdrTexture;
|
|
20
|
-
scene.environmentIntensity = 0.55;
|
|
21
|
-
return scene;
|
|
22
|
-
}
|
|
1
|
+
import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture.js";
|
|
2
|
+
import "@babylonjs/core/Materials/Textures/Loaders/envTextureLoader.js"; // Needed for environment map
|
|
3
|
+
import { Color4 } from "@babylonjs/core/Maths/math.color.js";
|
|
4
|
+
import "@babylonjs/core/Misc/dds.js"; // Needed for environment map
|
|
5
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
|
6
|
+
const DEFAULT_ENV_URL = "https://catalogueapi-demo.configura.com/envmap/default.env";
|
|
7
|
+
export function getDefaultScene(engine, envUrl) {
|
|
8
|
+
var scene = new Scene(engine);
|
|
9
|
+
// If the alpha component of the clearColor is set to 0, then the color components MUST also be
|
|
10
|
+
// set to 0. Otherwise the color components will sneak into transparent objects in the scene.
|
|
11
|
+
//
|
|
12
|
+
// This is because WebGL uses premultiplied alpha colors by default. In premultiplied alpha the
|
|
13
|
+
// color components have already been multiplied by the alpha value, and "X * 0" is always
|
|
14
|
+
// zero, no matter what X is. A color like "1, 0, 0, 0" is thus not an valid premultiplied
|
|
15
|
+
// color and the results is per the WebGL specs undefined.
|
|
16
|
+
scene.clearColor = new Color4(0, 0, 0, 0).toLinearSpace();
|
|
17
|
+
var hdrTexture = CubeTexture.CreateFromPrefilteredData(envUrl || DEFAULT_ENV_URL, scene);
|
|
18
|
+
hdrTexture.gammaSpace = false;
|
|
19
|
+
scene.environmentTexture = hdrTexture;
|
|
20
|
+
scene.environmentIntensity = 0.55;
|
|
21
|
+
return scene;
|
|
22
|
+
}
|