@configura/web-core 2.1.0-alpha.2 → 2.1.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/.eslintrc.json +5 -5
- package/LICENSE +201 -201
- package/README.md +1 -1
- package/dist/cm/basic/Color.d.ts +16 -16
- package/dist/cm/basic/Color.js +18 -18
- package/dist/cm/basic/ColorF.d.ts +9 -9
- package/dist/cm/basic/ColorF.js +10 -10
- package/dist/cm/basic/boolean.d.ts +2 -2
- package/dist/cm/basic/boolean.js +11 -11
- package/dist/cm/basic/number.d.ts +3 -3
- package/dist/cm/basic/number.js +18 -18
- package/dist/cm/basic/string.d.ts +2 -2
- package/dist/cm/basic/string.js +11 -11
- package/dist/cm/core3D/ATriMeshF.d.ts +96 -96
- package/dist/cm/core3D/ATriMeshF.js +197 -197
- package/dist/cm/core3D/GMaterial3D.d.ts +62 -62
- package/dist/cm/core3D/GMaterial3D.js +112 -112
- package/dist/cm/core3D/GMaterialClassic.d.ts +55 -55
- package/dist/cm/core3D/GMaterialClassic.js +171 -171
- package/dist/cm/core3D/GMaterialPBR.d.ts +73 -73
- package/dist/cm/core3D/GMaterialPBR.js +314 -314
- package/dist/cm/core3D/MultiGMaterial3D.d.ts +8 -8
- package/dist/cm/core3D/MultiGMaterial3D.js +17 -17
- package/dist/cm/core3D/uvmapper/UVMapEnv.d.ts +19 -19
- package/dist/cm/core3D/uvmapper/UVMapEnv.js +47 -47
- package/dist/cm/core3D/uvmapper/UVMapper.d.ts +41 -41
- package/dist/cm/core3D/uvmapper/UVMapper.js +94 -94
- package/dist/cm/core3D/uvmapper/UVMapperBox.d.ts +4 -4
- package/dist/cm/core3D/uvmapper/UVMapperBox.js +181 -181
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.d.ts +9 -9
- package/dist/cm/core3D/uvmapper/UVMapperCylinder.js +96 -96
- package/dist/cm/core3D/uvmapper/UVMapperPlane.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/UVMapperPlane.js +84 -84
- package/dist/cm/core3D/uvmapper/UVTransformer.d.ts +5 -5
- package/dist/cm/core3D/uvmapper/UVTransformer.js +5 -5
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.d.ts +3 -3
- package/dist/cm/core3D/uvmapper/instantiateUVMapper.js +4 -4
- package/dist/cm/format/cmsym/InvalidationEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/InvalidationEnv.js +13 -13
- package/dist/cm/format/cmsym/SymImportEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/SymImportEnv.js +9 -9
- package/dist/cm/format/cmsym/SymInv.d.ts +8 -8
- package/dist/cm/format/cmsym/SymInv.js +17 -17
- package/dist/cm/format/cmsym/SymNode.d.ts +94 -94
- package/dist/cm/format/cmsym/SymNode.js +652 -652
- package/dist/cm/format/cmsym/components/SymBox.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymBox.js +39 -39
- package/dist/cm/format/cmsym/components/SymComponent.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymComponent.js +56 -56
- package/dist/cm/format/cmsym/components/SymConnector.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymConnector.js +10 -10
- package/dist/cm/format/cmsym/components/SymDexObj.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymDexObj.js +10 -10
- package/dist/cm/format/cmsym/components/SymGFX.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymGFX.js +20 -20
- package/dist/cm/format/cmsym/components/SymGMaterial.d.ts +19 -19
- package/dist/cm/format/cmsym/components/SymGMaterial.js +88 -88
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.d.ts +17 -17
- package/dist/cm/format/cmsym/components/SymGMaterialSelector.js +22 -22
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymGetMeshEnv.js +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.d.ts +9 -9
- package/dist/cm/format/cmsym/components/SymLODGroup.js +13 -13
- package/dist/cm/format/cmsym/components/SymLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymLines2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymLines2D.js +7 -7
- package/dist/cm/format/cmsym/components/SymMeasure.d.ts +33 -33
- package/dist/cm/format/cmsym/components/SymMeasure.js +149 -149
- package/dist/cm/format/cmsym/components/SymMesh.d.ts +29 -29
- package/dist/cm/format/cmsym/components/SymMesh.js +130 -130
- package/dist/cm/format/cmsym/components/SymMeshLight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymMeshLight.js +10 -10
- package/dist/cm/format/cmsym/components/SymMultiSelector.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymMultiSelector.js +48 -48
- package/dist/cm/format/cmsym/components/SymParams.d.ts +16 -16
- package/dist/cm/format/cmsym/components/SymParams.js +58 -58
- package/dist/cm/format/cmsym/components/SymPlane.d.ts +15 -15
- package/dist/cm/format/cmsym/components/SymPlane.js +30 -30
- package/dist/cm/format/cmsym/components/SymPlaneDivider.d.ts +4 -4
- package/dist/cm/format/cmsym/components/SymPlaneDivider.js +7 -7
- package/dist/cm/format/cmsym/components/SymPrimitive2D.d.ts +3 -3
- package/dist/cm/format/cmsym/components/SymPrimitive2D.js +3 -3
- package/dist/cm/format/cmsym/components/SymProgs.d.ts +32 -32
- package/dist/cm/format/cmsym/components/SymProgs.js +120 -120
- package/dist/cm/format/cmsym/components/SymProps.d.ts +54 -54
- package/dist/cm/format/cmsym/components/SymProps.js +171 -171
- package/dist/cm/format/cmsym/components/SymRep.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymRep.js +28 -28
- package/dist/cm/format/cmsym/components/SymReps.d.ts +36 -36
- package/dist/cm/format/cmsym/components/SymReps.js +230 -230
- package/dist/cm/format/cmsym/components/SymShape.d.ts +10 -10
- package/dist/cm/format/cmsym/components/SymShape.js +17 -17
- package/dist/cm/format/cmsym/components/SymSphere.d.ts +18 -18
- package/dist/cm/format/cmsym/components/SymSphere.js +33 -33
- package/dist/cm/format/cmsym/components/SymSpotlight.d.ts +8 -8
- package/dist/cm/format/cmsym/components/SymSpotlight.js +10 -10
- package/dist/cm/format/cmsym/components/SymTags.d.ts +11 -11
- package/dist/cm/format/cmsym/components/SymTags.js +20 -20
- package/dist/cm/format/cmsym/components/SymText2D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText2D.js +8 -8
- package/dist/cm/format/cmsym/components/SymText3D.d.ts +5 -5
- package/dist/cm/format/cmsym/components/SymText3D.js +8 -8
- package/dist/cm/format/cmsym/components/SymTransform.d.ts +23 -23
- package/dist/cm/format/cmsym/components/SymTransform.js +101 -101
- package/dist/cm/format/cmsym/components/SymUVMapper.d.ts +13 -13
- package/dist/cm/format/cmsym/components/SymUVMapper.js +50 -50
- package/dist/cm/format/cmsym/components/instantiate.d.ts +2 -2
- package/dist/cm/format/cmsym/components/instantiate.js +121 -121
- package/dist/cm/format/cmsym/components/legacy.d.ts +7 -7
- package/dist/cm/format/cmsym/components/legacy.js +27 -27
- package/dist/cm/format/cmsym/components/mesh.d.ts +8 -8
- package/dist/cm/format/cmsym/components/mesh.js +28 -28
- package/dist/cm/format/cmsym/invalidation.d.ts +4 -4
- package/dist/cm/format/cmsym/invalidation.js +72 -72
- package/dist/cm/format/dex/DexIRef.d.ts +9 -9
- package/dist/cm/format/dex/DexIRef.js +18 -18
- package/dist/cm/format/dex/DexInt.d.ts +11 -11
- package/dist/cm/format/dex/DexInt.js +18 -18
- package/dist/cm/format/dex/DexInternalizedXRef.d.ts +19 -19
- package/dist/cm/format/dex/DexInternalizedXRef.js +65 -65
- package/dist/cm/format/dex/DexLoader.d.ts +8 -8
- package/dist/cm/format/dex/DexLoader.js +12 -12
- package/dist/cm/format/dex/DexManager.d.ts +20 -20
- package/dist/cm/format/dex/DexManager.js +78 -78
- package/dist/cm/format/dex/DexObj.d.ts +15 -15
- package/dist/cm/format/dex/DexObj.js +86 -86
- package/dist/cm/format/dex/DexReader.d.ts +90 -90
- package/dist/cm/format/dex/DexReader.js +532 -532
- package/dist/cm/format/dex/DexRef.d.ts +6 -6
- package/dist/cm/format/dex/DexRef.js +8 -8
- package/dist/cm/format/dex/DexReplacedXRefs.d.ts +9 -9
- package/dist/cm/format/dex/DexReplacedXRefs.js +22 -22
- package/dist/cm/format/dex/DexURL.d.ts +4 -4
- package/dist/cm/format/dex/DexURL.js +5 -5
- package/dist/cm/format/dex/DexVersion.d.ts +15 -15
- package/dist/cm/format/dex/DexVersion.js +53 -53
- package/dist/cm/format/dex/DexXRef.d.ts +18 -18
- package/dist/cm/format/dex/DexXRef.js +51 -51
- package/dist/cm/format/dex/DexXRefTargetFilter.d.ts +4 -4
- package/dist/cm/format/dex/DexXRefTargetFilter.js +5 -5
- package/dist/cm/geometry/Angle.d.ts +9 -9
- package/dist/cm/geometry/Angle.js +18 -18
- package/dist/cm/geometry/AngleF.d.ts +5 -5
- package/dist/cm/geometry/AngleF.js +8 -8
- package/dist/cm/geometry/Box.d.ts +7 -7
- package/dist/cm/geometry/Box.js +9 -9
- package/dist/cm/geometry/DetailMask.d.ts +37 -37
- package/dist/cm/geometry/DetailMask.js +114 -114
- package/dist/cm/geometry/LayerExpr.d.ts +2 -2
- package/dist/cm/geometry/LayerExpr.js +2 -2
- package/dist/cm/geometry/Matrix22.d.ts +7 -7
- package/dist/cm/geometry/Matrix22.js +9 -9
- package/dist/cm/geometry/Matrix33.d.ts +42 -42
- package/dist/cm/geometry/Matrix33.js +124 -124
- package/dist/cm/geometry/Orientation.d.ts +7 -7
- package/dist/cm/geometry/Orientation.js +7 -7
- package/dist/cm/geometry/Plane.d.ts +8 -8
- package/dist/cm/geometry/Plane.js +14 -14
- package/dist/cm/geometry/Point.d.ts +21 -21
- package/dist/cm/geometry/Point.js +65 -65
- package/dist/cm/geometry/Point2D.d.ts +9 -9
- package/dist/cm/geometry/Point2D.js +23 -23
- package/dist/cm/geometry/PointF.d.ts +11 -11
- package/dist/cm/geometry/PointF.js +27 -27
- package/dist/cm/geometry/Transform.d.ts +11 -11
- package/dist/cm/geometry/Transform.js +61 -61
- package/dist/cm/geometry/Transform2D.d.ts +7 -7
- package/dist/cm/geometry/Transform2D.js +6 -6
- package/dist/cm/io/Semver.d.ts +18 -18
- package/dist/cm/io/Semver.js +61 -61
- package/dist/index.js +1 -1
- package/package.json +4 -4
|
@@ -1,652 +1,652 @@
|
|
|
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 { v4 } from "uuid";
|
|
11
|
-
import { Semver } from "../../io/Semver.js";
|
|
12
|
-
import { DexObj } from "../dex/DexObj.js";
|
|
13
|
-
import { DexVersion } from "../dex/DexVersion.js";
|
|
14
|
-
import { instantiate } from "./components/instantiate.js";
|
|
15
|
-
import { loadLegacyComponent } from "./components/legacy.js";
|
|
16
|
-
import { findMeshNodes } from "./components/mesh.js";
|
|
17
|
-
import { SymBox } from "./components/SymBox.js";
|
|
18
|
-
import { SymComponent } from "./components/SymComponent.js";
|
|
19
|
-
import { SymDexObj } from "./components/SymDexObj.js";
|
|
20
|
-
import { SymGMaterial } from "./components/SymGMaterial.js";
|
|
21
|
-
import { SymGMaterialSelector } from "./components/SymGMaterialSelector.js";
|
|
22
|
-
import { SymMeasure } from "./components/SymMeasure.js";
|
|
23
|
-
import { SymMesh } from "./components/SymMesh.js";
|
|
24
|
-
import { SymPlane } from "./components/SymPlane.js";
|
|
25
|
-
import { SymProps, SYM_FEATURES_KEY, SYM_GEOMETRY_KEY, SYM_LOCAL_BOUND_KEY, SYM_NODE_KEY, SYM_STRUCTURAL_KEY, } from "./components/SymProps.js";
|
|
26
|
-
import { SymReps } from "./components/SymReps.js";
|
|
27
|
-
import { SymSphere } from "./components/SymSphere.js";
|
|
28
|
-
import { SymTags } from "./components/SymTags.js";
|
|
29
|
-
import { SymTransform } from "./components/SymTransform.js";
|
|
30
|
-
import { SymUVMapper } from "./components/SymUVMapper.js";
|
|
31
|
-
import { appendInvalidation, invalidate } from "./invalidation.js";
|
|
32
|
-
import { SymImportEnv } from "./SymImportEnv.js";
|
|
33
|
-
export const VERBOSE_SYM_LOGGING = false;
|
|
34
|
-
export class SymNode {
|
|
35
|
-
constructor(id) {
|
|
36
|
-
this.id = id;
|
|
37
|
-
this.components = new Map();
|
|
38
|
-
this._isStretch = new Map();
|
|
39
|
-
if (VERBOSE_SYM_LOGGING) {
|
|
40
|
-
console.log("SymNode: " + id);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
setId(logger, newId) {
|
|
44
|
-
if (this.id === newId) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
if (this._parents !== undefined) {
|
|
48
|
-
for (const parent of this._parents) {
|
|
49
|
-
const children = parent.children(logger, true, true);
|
|
50
|
-
if (children.has(newId)) {
|
|
51
|
-
throw logger.errorAsObject("cannot have children with the same id, for any parent");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
for (const parent of this._parents) {
|
|
55
|
-
parent.breakDexConnection();
|
|
56
|
-
// children already loaded for all parents
|
|
57
|
-
const children = parent.children(logger, true, false);
|
|
58
|
-
if (children.size === 0) {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
children.delete(this.id);
|
|
62
|
-
children.set(newId, this);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
this.id = newId;
|
|
66
|
-
}
|
|
67
|
-
children(logger, safe = false, load = true) {
|
|
68
|
-
if (load) {
|
|
69
|
-
this.ensureChildrenLoaded(logger);
|
|
70
|
-
}
|
|
71
|
-
if (this._children === undefined && safe) {
|
|
72
|
-
this._children = new Map();
|
|
73
|
-
}
|
|
74
|
-
return this._children;
|
|
75
|
-
}
|
|
76
|
-
ensureChildrenLoaded(logger) {
|
|
77
|
-
const component = this.childrenProvider();
|
|
78
|
-
if (component instanceof SymComponent) {
|
|
79
|
-
component.loadChildren();
|
|
80
|
-
}
|
|
81
|
-
else if (this.dexObj() !== undefined &&
|
|
82
|
-
(this._children === undefined || this._children.size < this.dexChildrenCount())) {
|
|
83
|
-
this.loadDexChildren(logger);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
dexChildrenCount() {
|
|
87
|
-
const obj = this.dexObj();
|
|
88
|
-
if (obj === undefined) {
|
|
89
|
-
return 0;
|
|
90
|
-
}
|
|
91
|
-
const dexChildren = obj.get("children");
|
|
92
|
-
if (dexChildren instanceof DexObj && dexChildren.props !== undefined) {
|
|
93
|
-
return dexChildren.props.size;
|
|
94
|
-
}
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
loadDexChildren(logger) {
|
|
98
|
-
const obj = this.dexObj();
|
|
99
|
-
if (obj === undefined) {
|
|
100
|
-
throw logger.errorAsObject("this.dexObj() is undefined");
|
|
101
|
-
}
|
|
102
|
-
if (this.featureProvider("children") !== undefined) {
|
|
103
|
-
throw logger.errorAsObject("this.featureProvider('children') must be undefined");
|
|
104
|
-
}
|
|
105
|
-
const dexChildren = obj.get("children");
|
|
106
|
-
if (dexChildren instanceof DexObj && dexChildren.props !== undefined) {
|
|
107
|
-
const env = this.importEnv();
|
|
108
|
-
if (env === undefined) {
|
|
109
|
-
throw logger.errorAsObject("env must not be undefined");
|
|
110
|
-
}
|
|
111
|
-
for (const key of dexChildren.props.keys()) {
|
|
112
|
-
this.loadChild(logger, dexChildren, key, env);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
addChild(logger, child, invalidate = true) {
|
|
117
|
-
if (child === this) {
|
|
118
|
-
throw logger.errorAsObject("Trying to add node as a child of itself.");
|
|
119
|
-
}
|
|
120
|
-
if (invalidate && this.hasComponent("xRef")) {
|
|
121
|
-
throw logger.errorAsObject("Trying to add a child to an xRef node");
|
|
122
|
-
}
|
|
123
|
-
if (invalidate) {
|
|
124
|
-
this.breakDexConnection();
|
|
125
|
-
}
|
|
126
|
-
const children = this.children(logger, true, invalidate);
|
|
127
|
-
if (children.has(child.id)) {
|
|
128
|
-
child.setId(logger, v4());
|
|
129
|
-
}
|
|
130
|
-
children.set(child.id, child);
|
|
131
|
-
child.addParent(this, false);
|
|
132
|
-
if (invalidate) {
|
|
133
|
-
child.invalidateParent(this, false);
|
|
134
|
-
}
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
loadChild(logger, dexChildren, id, env) {
|
|
138
|
-
if (this._children !== undefined) {
|
|
139
|
-
const child = this._children.get(id);
|
|
140
|
-
if (child !== undefined) {
|
|
141
|
-
return child;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
const dexChild = dexChildren.get(id);
|
|
145
|
-
if (dexChild instanceof DexObj) {
|
|
146
|
-
if (this._children === undefined) {
|
|
147
|
-
this._children = new Map();
|
|
148
|
-
}
|
|
149
|
-
const child = toSymNode(logger, dexChild, this, env, false);
|
|
150
|
-
return child;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
// Parent
|
|
154
|
-
addParent(parent, safe = true) {
|
|
155
|
-
if (parent !== undefined) {
|
|
156
|
-
if (this._parents === undefined) {
|
|
157
|
-
this._parents = [];
|
|
158
|
-
}
|
|
159
|
-
if (safe && this._parents.indexOf(parent) === -1) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
this._parents.push(parent);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
invalidateParent(parent, removed) {
|
|
166
|
-
const invalidation = [];
|
|
167
|
-
appendInvalidation(invalidation, this, removed);
|
|
168
|
-
invalidate(parent, invalidation, true);
|
|
169
|
-
}
|
|
170
|
-
invalidate(removed) {
|
|
171
|
-
const invalidation = [];
|
|
172
|
-
appendInvalidation(invalidation, this, removed);
|
|
173
|
-
invalidate(this, invalidation, true);
|
|
174
|
-
}
|
|
175
|
-
// Env
|
|
176
|
-
importEnv(ascend = true) {
|
|
177
|
-
const obj = this.symDexObj();
|
|
178
|
-
if (obj instanceof SymDexObj) {
|
|
179
|
-
return obj.importEnv;
|
|
180
|
-
}
|
|
181
|
-
if (!ascend || this._parents === undefined || this._parents.length === 0) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
const env = this._parents[0].importEnv(ascend);
|
|
185
|
-
if (env instanceof SymImportEnv) {
|
|
186
|
-
this.setImportEnv(env);
|
|
187
|
-
}
|
|
188
|
-
return env;
|
|
189
|
-
}
|
|
190
|
-
setImportEnv(env) {
|
|
191
|
-
const obj = this.symDexObj();
|
|
192
|
-
if (obj instanceof Error) {
|
|
193
|
-
return obj;
|
|
194
|
-
}
|
|
195
|
-
else if (obj instanceof SymDexObj) {
|
|
196
|
-
obj.importEnv = env;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// Props
|
|
200
|
-
set(key, value) {
|
|
201
|
-
return this.symProps(true).set(key, value);
|
|
202
|
-
}
|
|
203
|
-
get(key) {
|
|
204
|
-
return this.symProps(true).get(key);
|
|
205
|
-
}
|
|
206
|
-
has(key) {
|
|
207
|
-
return this.symProps(true).has(key);
|
|
208
|
-
}
|
|
209
|
-
fillPropsAfterLoad() {
|
|
210
|
-
const symProps = this.symProps(false);
|
|
211
|
-
if (symProps instanceof Error || symProps === undefined) {
|
|
212
|
-
return symProps;
|
|
213
|
-
}
|
|
214
|
-
const requiredKeys = [
|
|
215
|
-
SYM_GEOMETRY_KEY,
|
|
216
|
-
SYM_STRUCTURAL_KEY,
|
|
217
|
-
SYM_NODE_KEY,
|
|
218
|
-
SYM_LOCAL_BOUND_KEY,
|
|
219
|
-
];
|
|
220
|
-
for (const key of requiredKeys) {
|
|
221
|
-
if (!symProps.has(key)) {
|
|
222
|
-
symProps.set(key, undefined);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
hasDexComponent(key) {
|
|
227
|
-
const obj = this.dexObj();
|
|
228
|
-
if (obj instanceof Error) {
|
|
229
|
-
return obj;
|
|
230
|
-
}
|
|
231
|
-
else if (obj === undefined) {
|
|
232
|
-
return false;
|
|
233
|
-
}
|
|
234
|
-
return obj.has(key);
|
|
235
|
-
}
|
|
236
|
-
breakDexConnection(loadChildren = true, descend = true) {
|
|
237
|
-
const obj = this.dexObj();
|
|
238
|
-
if (obj === undefined) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
const env = this.importEnv();
|
|
242
|
-
if (env === undefined) {
|
|
243
|
-
throw Error("[breakDexConnection] could not get env!");
|
|
244
|
-
}
|
|
245
|
-
this._breakDexConnection(env, loadChildren, descend);
|
|
246
|
-
}
|
|
247
|
-
_breakDexConnection(env, loadChildren, descend) {
|
|
248
|
-
// console.warn(`SymNode._breakDexConnection ${env} ${descend}`);
|
|
249
|
-
}
|
|
250
|
-
dexObj() {
|
|
251
|
-
const obj = this.symDexObj();
|
|
252
|
-
return obj && obj.dexObj;
|
|
253
|
-
}
|
|
254
|
-
symDexObj() {
|
|
255
|
-
const component = this.getComponent("symDexObj");
|
|
256
|
-
if (component instanceof SymDexObj) {
|
|
257
|
-
return component;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
symGMaterial(safe) {
|
|
261
|
-
const component = this.getComponent("symGMaterial");
|
|
262
|
-
if (component instanceof SymGMaterial) {
|
|
263
|
-
return component;
|
|
264
|
-
}
|
|
265
|
-
else if (safe) {
|
|
266
|
-
const component = new SymGMaterial();
|
|
267
|
-
this.addComponent(component);
|
|
268
|
-
return component;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
symGMaterialSelector(safe) {
|
|
272
|
-
const component = this.getComponent("symGMaterialSelector");
|
|
273
|
-
if (component instanceof SymGMaterialSelector) {
|
|
274
|
-
return component;
|
|
275
|
-
}
|
|
276
|
-
else if (safe) {
|
|
277
|
-
const component = new SymGMaterialSelector();
|
|
278
|
-
this.addComponent(component);
|
|
279
|
-
return component;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
symMesh(safe) {
|
|
283
|
-
const component = this.getComponent("symMesh");
|
|
284
|
-
if (component instanceof SymMesh) {
|
|
285
|
-
return component;
|
|
286
|
-
}
|
|
287
|
-
else if (safe) {
|
|
288
|
-
const component = new SymMesh();
|
|
289
|
-
this.addComponent(component);
|
|
290
|
-
return component;
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
symSphere(safe) {
|
|
294
|
-
const component = this.getComponent("symSphere");
|
|
295
|
-
if (component instanceof SymSphere) {
|
|
296
|
-
return component;
|
|
297
|
-
}
|
|
298
|
-
else if (safe) {
|
|
299
|
-
const component = new SymSphere();
|
|
300
|
-
this.addComponent(component);
|
|
301
|
-
return component;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
symBox(safe) {
|
|
305
|
-
const component = this.getComponent("symBox");
|
|
306
|
-
if (component instanceof SymBox) {
|
|
307
|
-
return component;
|
|
308
|
-
}
|
|
309
|
-
else if (safe) {
|
|
310
|
-
const component = new SymBox();
|
|
311
|
-
this.addComponent(component);
|
|
312
|
-
return component;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
symPlane(safe) {
|
|
316
|
-
const component = this.getComponent("symPlane");
|
|
317
|
-
if (component instanceof SymPlane) {
|
|
318
|
-
return component;
|
|
319
|
-
}
|
|
320
|
-
else if (safe) {
|
|
321
|
-
const component = new SymPlane();
|
|
322
|
-
this.addComponent(component);
|
|
323
|
-
return component;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
symProps(safe) {
|
|
327
|
-
const component = this.getComponent("symProps");
|
|
328
|
-
if (component instanceof SymProps) {
|
|
329
|
-
return component;
|
|
330
|
-
}
|
|
331
|
-
else if (safe) {
|
|
332
|
-
const component = new SymProps();
|
|
333
|
-
this.addComponent(component);
|
|
334
|
-
return component;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
symReps(safe) {
|
|
338
|
-
const component = this.getComponent("symReps");
|
|
339
|
-
if (component instanceof SymReps) {
|
|
340
|
-
return component;
|
|
341
|
-
}
|
|
342
|
-
else if (safe) {
|
|
343
|
-
const component = new SymReps();
|
|
344
|
-
this.addComponent(component);
|
|
345
|
-
return component;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
symTags(safe) {
|
|
349
|
-
const component = this.getComponent("symTags");
|
|
350
|
-
if (component instanceof SymTags) {
|
|
351
|
-
return component;
|
|
352
|
-
}
|
|
353
|
-
else if (safe) {
|
|
354
|
-
const component = new SymTags();
|
|
355
|
-
this.addComponent(component);
|
|
356
|
-
return component;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
symTransform(safe) {
|
|
360
|
-
const component = this.getComponent("symTransform");
|
|
361
|
-
if (component instanceof SymTransform) {
|
|
362
|
-
return component;
|
|
363
|
-
}
|
|
364
|
-
else if (safe) {
|
|
365
|
-
const component = new SymTransform();
|
|
366
|
-
this.addComponent(component);
|
|
367
|
-
return component;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
symUVMapper(safe) {
|
|
371
|
-
const component = this.getComponent("symUVMapper");
|
|
372
|
-
if (component instanceof SymUVMapper) {
|
|
373
|
-
return component;
|
|
374
|
-
}
|
|
375
|
-
else if (safe) {
|
|
376
|
-
const component = new SymUVMapper();
|
|
377
|
-
this.addComponent(component);
|
|
378
|
-
return component;
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
getMeasure() {
|
|
382
|
-
const component = this.components.get("symMeasure");
|
|
383
|
-
if (component instanceof SymMeasure) {
|
|
384
|
-
return component;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
isStretch(logger, detailLevel) {
|
|
388
|
-
let isStretch = this._isStretch.get(detailLevel);
|
|
389
|
-
if (isStretch === undefined) {
|
|
390
|
-
isStretch = symNodeIsStretch(logger, this, detailLevel);
|
|
391
|
-
this._isStretch.set(detailLevel, isStretch);
|
|
392
|
-
}
|
|
393
|
-
return isStretch;
|
|
394
|
-
}
|
|
395
|
-
// Components
|
|
396
|
-
getComponent(key) {
|
|
397
|
-
return this.components.get(key);
|
|
398
|
-
}
|
|
399
|
-
addComponent(component, invalidate = true) {
|
|
400
|
-
if (invalidate && component.breaksDex() && this.hasDexComponent(component.id)) {
|
|
401
|
-
this.breakDexConnection(false);
|
|
402
|
-
}
|
|
403
|
-
if (component.node && component.node !== this) {
|
|
404
|
-
throw Error("[SymNode.addComponent] component already has node.");
|
|
405
|
-
// component = component.copy();
|
|
406
|
-
}
|
|
407
|
-
if (this._children !== undefined) {
|
|
408
|
-
const features = component.features();
|
|
409
|
-
if (features !== undefined && features.has("children")) {
|
|
410
|
-
throw Error("[SymNode.addComponent] node already has children");
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
component.addComponent(this, invalidate);
|
|
414
|
-
this.components.set(component.id, component);
|
|
415
|
-
component.componentAdded(invalidate);
|
|
416
|
-
}
|
|
417
|
-
hasComponent(key) {
|
|
418
|
-
return this.components.has(key);
|
|
419
|
-
}
|
|
420
|
-
removeComponent(key, invalidate = true) {
|
|
421
|
-
throw Error(`SymNode.removeComponent ${key} ${invalidate}`);
|
|
422
|
-
}
|
|
423
|
-
loadComponents(logger, force = false) {
|
|
424
|
-
const obj = this.dexObj();
|
|
425
|
-
if (obj === undefined || obj.props === undefined) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
const env = this.importEnv();
|
|
429
|
-
let breakDex = false;
|
|
430
|
-
for (const key of obj.props.keys()) {
|
|
431
|
-
const prop = obj.get(key);
|
|
432
|
-
if (prop instanceof DexObj) {
|
|
433
|
-
const breaks = this.loadComponent(logger, key, prop, env, force);
|
|
434
|
-
if (breaks) {
|
|
435
|
-
breakDex = true;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
this.prepareAfterLoad();
|
|
440
|
-
if (breakDex) {
|
|
441
|
-
this.breakDexConnection();
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
loadComponent(logger, key, obj, env, force = false) {
|
|
445
|
-
if (env === undefined) {
|
|
446
|
-
env = this.importEnv();
|
|
447
|
-
}
|
|
448
|
-
if (env === undefined) {
|
|
449
|
-
throw logger.errorAsObject("[loadComponentObj] could not get env!");
|
|
450
|
-
}
|
|
451
|
-
else if (key === "children") {
|
|
452
|
-
return false;
|
|
453
|
-
}
|
|
454
|
-
else if (loadLegacyComponent(logger, this, key, obj, env, force)) {
|
|
455
|
-
return true;
|
|
456
|
-
}
|
|
457
|
-
const type = obj.type;
|
|
458
|
-
if (type === undefined) {
|
|
459
|
-
throw logger.errorAsObject("[loadComponentObj] obj has no type!");
|
|
460
|
-
}
|
|
461
|
-
const component = instantiate(type);
|
|
462
|
-
if (component instanceof SymComponent) {
|
|
463
|
-
this.addComponent(component, false);
|
|
464
|
-
component.load(logger, obj, env, force);
|
|
465
|
-
}
|
|
466
|
-
return false;
|
|
467
|
-
}
|
|
468
|
-
prepareAfterLoad() {
|
|
469
|
-
this.buildFeatures();
|
|
470
|
-
this.fillPropsAfterLoad();
|
|
471
|
-
}
|
|
472
|
-
features(create = false) {
|
|
473
|
-
const features = this.get(SYM_FEATURES_KEY);
|
|
474
|
-
if (features instanceof Map) {
|
|
475
|
-
return features;
|
|
476
|
-
}
|
|
477
|
-
else if (create) {
|
|
478
|
-
const features = new Map();
|
|
479
|
-
this.set(SYM_FEATURES_KEY, features);
|
|
480
|
-
return features;
|
|
481
|
-
}
|
|
482
|
-
throw Error("no features");
|
|
483
|
-
}
|
|
484
|
-
featureProviderKey(feature) {
|
|
485
|
-
return this.features().get(feature);
|
|
486
|
-
}
|
|
487
|
-
featureProvider(feature) {
|
|
488
|
-
const key = this.featureProviderKey(feature);
|
|
489
|
-
if (key === undefined) {
|
|
490
|
-
return;
|
|
491
|
-
}
|
|
492
|
-
return this.getComponent(key);
|
|
493
|
-
}
|
|
494
|
-
buildFeatures() {
|
|
495
|
-
const features = new Map();
|
|
496
|
-
for (const component of this.components.values()) {
|
|
497
|
-
const cFeatures = component.features();
|
|
498
|
-
if (cFeatures === undefined) {
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
for (const feature of cFeatures) {
|
|
502
|
-
features.set(feature, component.id);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
this.set(SYM_FEATURES_KEY, features);
|
|
506
|
-
return features;
|
|
507
|
-
}
|
|
508
|
-
addFeaturesFrom(component) {
|
|
509
|
-
const features = component.features();
|
|
510
|
-
if (features === undefined || features.size === 0) {
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
const nodeFeatures = this.features(true);
|
|
514
|
-
for (const feature of features) {
|
|
515
|
-
const key = this.featureProviderKey(feature);
|
|
516
|
-
if (key !== undefined) {
|
|
517
|
-
this.removeComponent(key, false);
|
|
518
|
-
}
|
|
519
|
-
nodeFeatures.set(feature, component.id);
|
|
520
|
-
}
|
|
521
|
-
if (features.has("mesh")) {
|
|
522
|
-
console.warn("mesh cache should be invalidated!" + component);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
525
|
-
childrenProvider() {
|
|
526
|
-
return this.featureProvider("children");
|
|
527
|
-
}
|
|
528
|
-
meshProvider() {
|
|
529
|
-
return this.featureProvider("mesh");
|
|
530
|
-
}
|
|
531
|
-
get3DTmp(logger, detail) {
|
|
532
|
-
return findMeshNodes(logger, this, detail, [], []);
|
|
533
|
-
}
|
|
534
|
-
toString() {
|
|
535
|
-
return `SymNode("${this.id}")`;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
export function toSymNode(logger, obj, parent, env, putImportEnv = false) {
|
|
539
|
-
if (env !== undefined) {
|
|
540
|
-
const node = env.sharedNodeMap.get(obj);
|
|
541
|
-
if (node instanceof SymNode) {
|
|
542
|
-
if (parent) {
|
|
543
|
-
parent.addChild(logger, node, false);
|
|
544
|
-
}
|
|
545
|
-
return node;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
switch (obj.type) {
|
|
549
|
-
case "node":
|
|
550
|
-
return toSymBasicNode(logger, obj, parent, env, putImportEnv);
|
|
551
|
-
case "xRefNode":
|
|
552
|
-
return toSymXRefNode(obj, parent, env, putImportEnv);
|
|
553
|
-
case "symFile":
|
|
554
|
-
return toSymFileRoot(logger, obj, parent);
|
|
555
|
-
}
|
|
556
|
-
throw logger.errorAsObject("[toSymNode] Unknown obj.type:", obj.type);
|
|
557
|
-
}
|
|
558
|
-
function toSymBasicNode(logger, obj, parent, env, putImportEnv = false) {
|
|
559
|
-
if (env === undefined) {
|
|
560
|
-
throw logger.errorAsObject("[toSymBasicNode] no env");
|
|
561
|
-
}
|
|
562
|
-
if (obj.id === undefined) {
|
|
563
|
-
throw logger.errorAsObject("[toSymBasicNode] obj.id is undefined");
|
|
564
|
-
}
|
|
565
|
-
const node = new SymNode(obj.id);
|
|
566
|
-
node.addComponent(new SymDexObj(obj, env.fileVersion, env), false);
|
|
567
|
-
env.sharedNodeMap.set(obj, node);
|
|
568
|
-
if (parent !== undefined) {
|
|
569
|
-
parent.addChild(logger, node, false);
|
|
570
|
-
}
|
|
571
|
-
node.loadComponents(logger);
|
|
572
|
-
return node;
|
|
573
|
-
}
|
|
574
|
-
function toSymXRefNode(_obj, _parent, _env, _putImportEnv = false) {
|
|
575
|
-
throw Error("[toSymXRefNode]");
|
|
576
|
-
}
|
|
577
|
-
function toSymFileRoot(logger, obj, parent) {
|
|
578
|
-
const version = obj.get("version");
|
|
579
|
-
const semver = loadVersion(version);
|
|
580
|
-
// Enable to get CmSym version statistics in the Exerciser
|
|
581
|
-
// logger.info("CmSym version " + semver.toDisplayString());
|
|
582
|
-
const env = new SymImportEnv(semver);
|
|
583
|
-
const sym = obj.get("sym");
|
|
584
|
-
if (!(sym instanceof DexObj)) {
|
|
585
|
-
throw Error(`sym: ${sym} is not a DexObj`);
|
|
586
|
-
}
|
|
587
|
-
return toSymNode(logger, sym, parent, env, true);
|
|
588
|
-
}
|
|
589
|
-
function loadVersion(obj) {
|
|
590
|
-
if (obj instanceof DexObj) {
|
|
591
|
-
return Semver.fromDex(obj);
|
|
592
|
-
}
|
|
593
|
-
if (obj instanceof DexVersion) {
|
|
594
|
-
return obj.toSemver();
|
|
595
|
-
}
|
|
596
|
-
throw Error(`obj: ${obj} can't load version`);
|
|
597
|
-
}
|
|
598
|
-
export function loadSymFile(logger, url, manager, abortSignal) {
|
|
599
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
600
|
-
const root = yield manager.load(logger, url, abortSignal);
|
|
601
|
-
return makeSymFromDex(logger, root);
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
export function makeSymFromDex(logger, root) {
|
|
605
|
-
const node = toSymNode(logger, root);
|
|
606
|
-
if (!(node instanceof SymNode)) {
|
|
607
|
-
throw Error(`node: ${node} is not a SymNode`);
|
|
608
|
-
}
|
|
609
|
-
node.ensureChildrenLoaded(logger);
|
|
610
|
-
return node;
|
|
611
|
-
}
|
|
612
|
-
function symNodeIsStretch(logger, symNode, detailLevel) {
|
|
613
|
-
const symMeasure = symNode.getMeasure();
|
|
614
|
-
if (symMeasure === undefined) {
|
|
615
|
-
return false;
|
|
616
|
-
}
|
|
617
|
-
const children = symNode.children(logger, true, true);
|
|
618
|
-
let nodeName;
|
|
619
|
-
for (const [name, node] of children) {
|
|
620
|
-
if (name.startsWith("3D") || name.startsWith("2D")) {
|
|
621
|
-
const symReps = node.symReps(true);
|
|
622
|
-
const details = symReps._details;
|
|
623
|
-
if (details === undefined) {
|
|
624
|
-
continue;
|
|
625
|
-
}
|
|
626
|
-
const detailMask = details.values().next().value;
|
|
627
|
-
if (detailMask.includes(detailLevel)) {
|
|
628
|
-
nodeName = name;
|
|
629
|
-
break;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
}
|
|
633
|
-
if (nodeName === undefined) {
|
|
634
|
-
logger.warn(`No 3D/2D SymNode which covers the detailLevel ${detailLevel} found`);
|
|
635
|
-
return false;
|
|
636
|
-
}
|
|
637
|
-
const node = children.get(nodeName);
|
|
638
|
-
if (node === undefined) {
|
|
639
|
-
return false;
|
|
640
|
-
}
|
|
641
|
-
const progsNode = node.components.get("symProgs");
|
|
642
|
-
if (progsNode === undefined) {
|
|
643
|
-
return false;
|
|
644
|
-
}
|
|
645
|
-
const symProgs = progsNode;
|
|
646
|
-
for (const prog of symProgs.progs) {
|
|
647
|
-
if (prog.isStretch) {
|
|
648
|
-
return true;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
return false;
|
|
652
|
-
}
|
|
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 { v4 } from "uuid";
|
|
11
|
+
import { Semver } from "../../io/Semver.js";
|
|
12
|
+
import { DexObj } from "../dex/DexObj.js";
|
|
13
|
+
import { DexVersion } from "../dex/DexVersion.js";
|
|
14
|
+
import { instantiate } from "./components/instantiate.js";
|
|
15
|
+
import { loadLegacyComponent } from "./components/legacy.js";
|
|
16
|
+
import { findMeshNodes } from "./components/mesh.js";
|
|
17
|
+
import { SymBox } from "./components/SymBox.js";
|
|
18
|
+
import { SymComponent } from "./components/SymComponent.js";
|
|
19
|
+
import { SymDexObj } from "./components/SymDexObj.js";
|
|
20
|
+
import { SymGMaterial } from "./components/SymGMaterial.js";
|
|
21
|
+
import { SymGMaterialSelector } from "./components/SymGMaterialSelector.js";
|
|
22
|
+
import { SymMeasure } from "./components/SymMeasure.js";
|
|
23
|
+
import { SymMesh } from "./components/SymMesh.js";
|
|
24
|
+
import { SymPlane } from "./components/SymPlane.js";
|
|
25
|
+
import { SymProps, SYM_FEATURES_KEY, SYM_GEOMETRY_KEY, SYM_LOCAL_BOUND_KEY, SYM_NODE_KEY, SYM_STRUCTURAL_KEY, } from "./components/SymProps.js";
|
|
26
|
+
import { SymReps } from "./components/SymReps.js";
|
|
27
|
+
import { SymSphere } from "./components/SymSphere.js";
|
|
28
|
+
import { SymTags } from "./components/SymTags.js";
|
|
29
|
+
import { SymTransform } from "./components/SymTransform.js";
|
|
30
|
+
import { SymUVMapper } from "./components/SymUVMapper.js";
|
|
31
|
+
import { appendInvalidation, invalidate } from "./invalidation.js";
|
|
32
|
+
import { SymImportEnv } from "./SymImportEnv.js";
|
|
33
|
+
export const VERBOSE_SYM_LOGGING = false;
|
|
34
|
+
export class SymNode {
|
|
35
|
+
constructor(id) {
|
|
36
|
+
this.id = id;
|
|
37
|
+
this.components = new Map();
|
|
38
|
+
this._isStretch = new Map();
|
|
39
|
+
if (VERBOSE_SYM_LOGGING) {
|
|
40
|
+
console.log("SymNode: " + id);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
setId(logger, newId) {
|
|
44
|
+
if (this.id === newId) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (this._parents !== undefined) {
|
|
48
|
+
for (const parent of this._parents) {
|
|
49
|
+
const children = parent.children(logger, true, true);
|
|
50
|
+
if (children.has(newId)) {
|
|
51
|
+
throw logger.errorAsObject("cannot have children with the same id, for any parent");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
for (const parent of this._parents) {
|
|
55
|
+
parent.breakDexConnection();
|
|
56
|
+
// children already loaded for all parents
|
|
57
|
+
const children = parent.children(logger, true, false);
|
|
58
|
+
if (children.size === 0) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
children.delete(this.id);
|
|
62
|
+
children.set(newId, this);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
this.id = newId;
|
|
66
|
+
}
|
|
67
|
+
children(logger, safe = false, load = true) {
|
|
68
|
+
if (load) {
|
|
69
|
+
this.ensureChildrenLoaded(logger);
|
|
70
|
+
}
|
|
71
|
+
if (this._children === undefined && safe) {
|
|
72
|
+
this._children = new Map();
|
|
73
|
+
}
|
|
74
|
+
return this._children;
|
|
75
|
+
}
|
|
76
|
+
ensureChildrenLoaded(logger) {
|
|
77
|
+
const component = this.childrenProvider();
|
|
78
|
+
if (component instanceof SymComponent) {
|
|
79
|
+
component.loadChildren();
|
|
80
|
+
}
|
|
81
|
+
else if (this.dexObj() !== undefined &&
|
|
82
|
+
(this._children === undefined || this._children.size < this.dexChildrenCount())) {
|
|
83
|
+
this.loadDexChildren(logger);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
dexChildrenCount() {
|
|
87
|
+
const obj = this.dexObj();
|
|
88
|
+
if (obj === undefined) {
|
|
89
|
+
return 0;
|
|
90
|
+
}
|
|
91
|
+
const dexChildren = obj.get("children");
|
|
92
|
+
if (dexChildren instanceof DexObj && dexChildren.props !== undefined) {
|
|
93
|
+
return dexChildren.props.size;
|
|
94
|
+
}
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
loadDexChildren(logger) {
|
|
98
|
+
const obj = this.dexObj();
|
|
99
|
+
if (obj === undefined) {
|
|
100
|
+
throw logger.errorAsObject("this.dexObj() is undefined");
|
|
101
|
+
}
|
|
102
|
+
if (this.featureProvider("children") !== undefined) {
|
|
103
|
+
throw logger.errorAsObject("this.featureProvider('children') must be undefined");
|
|
104
|
+
}
|
|
105
|
+
const dexChildren = obj.get("children");
|
|
106
|
+
if (dexChildren instanceof DexObj && dexChildren.props !== undefined) {
|
|
107
|
+
const env = this.importEnv();
|
|
108
|
+
if (env === undefined) {
|
|
109
|
+
throw logger.errorAsObject("env must not be undefined");
|
|
110
|
+
}
|
|
111
|
+
for (const key of dexChildren.props.keys()) {
|
|
112
|
+
this.loadChild(logger, dexChildren, key, env);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
addChild(logger, child, invalidate = true) {
|
|
117
|
+
if (child === this) {
|
|
118
|
+
throw logger.errorAsObject("Trying to add node as a child of itself.");
|
|
119
|
+
}
|
|
120
|
+
if (invalidate && this.hasComponent("xRef")) {
|
|
121
|
+
throw logger.errorAsObject("Trying to add a child to an xRef node");
|
|
122
|
+
}
|
|
123
|
+
if (invalidate) {
|
|
124
|
+
this.breakDexConnection();
|
|
125
|
+
}
|
|
126
|
+
const children = this.children(logger, true, invalidate);
|
|
127
|
+
if (children.has(child.id)) {
|
|
128
|
+
child.setId(logger, v4());
|
|
129
|
+
}
|
|
130
|
+
children.set(child.id, child);
|
|
131
|
+
child.addParent(this, false);
|
|
132
|
+
if (invalidate) {
|
|
133
|
+
child.invalidateParent(this, false);
|
|
134
|
+
}
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
loadChild(logger, dexChildren, id, env) {
|
|
138
|
+
if (this._children !== undefined) {
|
|
139
|
+
const child = this._children.get(id);
|
|
140
|
+
if (child !== undefined) {
|
|
141
|
+
return child;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const dexChild = dexChildren.get(id);
|
|
145
|
+
if (dexChild instanceof DexObj) {
|
|
146
|
+
if (this._children === undefined) {
|
|
147
|
+
this._children = new Map();
|
|
148
|
+
}
|
|
149
|
+
const child = toSymNode(logger, dexChild, this, env, false);
|
|
150
|
+
return child;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Parent
|
|
154
|
+
addParent(parent, safe = true) {
|
|
155
|
+
if (parent !== undefined) {
|
|
156
|
+
if (this._parents === undefined) {
|
|
157
|
+
this._parents = [];
|
|
158
|
+
}
|
|
159
|
+
if (safe && this._parents.indexOf(parent) === -1) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
this._parents.push(parent);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
invalidateParent(parent, removed) {
|
|
166
|
+
const invalidation = [];
|
|
167
|
+
appendInvalidation(invalidation, this, removed);
|
|
168
|
+
invalidate(parent, invalidation, true);
|
|
169
|
+
}
|
|
170
|
+
invalidate(removed) {
|
|
171
|
+
const invalidation = [];
|
|
172
|
+
appendInvalidation(invalidation, this, removed);
|
|
173
|
+
invalidate(this, invalidation, true);
|
|
174
|
+
}
|
|
175
|
+
// Env
|
|
176
|
+
importEnv(ascend = true) {
|
|
177
|
+
const obj = this.symDexObj();
|
|
178
|
+
if (obj instanceof SymDexObj) {
|
|
179
|
+
return obj.importEnv;
|
|
180
|
+
}
|
|
181
|
+
if (!ascend || this._parents === undefined || this._parents.length === 0) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
const env = this._parents[0].importEnv(ascend);
|
|
185
|
+
if (env instanceof SymImportEnv) {
|
|
186
|
+
this.setImportEnv(env);
|
|
187
|
+
}
|
|
188
|
+
return env;
|
|
189
|
+
}
|
|
190
|
+
setImportEnv(env) {
|
|
191
|
+
const obj = this.symDexObj();
|
|
192
|
+
if (obj instanceof Error) {
|
|
193
|
+
return obj;
|
|
194
|
+
}
|
|
195
|
+
else if (obj instanceof SymDexObj) {
|
|
196
|
+
obj.importEnv = env;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
// Props
|
|
200
|
+
set(key, value) {
|
|
201
|
+
return this.symProps(true).set(key, value);
|
|
202
|
+
}
|
|
203
|
+
get(key) {
|
|
204
|
+
return this.symProps(true).get(key);
|
|
205
|
+
}
|
|
206
|
+
has(key) {
|
|
207
|
+
return this.symProps(true).has(key);
|
|
208
|
+
}
|
|
209
|
+
fillPropsAfterLoad() {
|
|
210
|
+
const symProps = this.symProps(false);
|
|
211
|
+
if (symProps instanceof Error || symProps === undefined) {
|
|
212
|
+
return symProps;
|
|
213
|
+
}
|
|
214
|
+
const requiredKeys = [
|
|
215
|
+
SYM_GEOMETRY_KEY,
|
|
216
|
+
SYM_STRUCTURAL_KEY,
|
|
217
|
+
SYM_NODE_KEY,
|
|
218
|
+
SYM_LOCAL_BOUND_KEY,
|
|
219
|
+
];
|
|
220
|
+
for (const key of requiredKeys) {
|
|
221
|
+
if (!symProps.has(key)) {
|
|
222
|
+
symProps.set(key, undefined);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
hasDexComponent(key) {
|
|
227
|
+
const obj = this.dexObj();
|
|
228
|
+
if (obj instanceof Error) {
|
|
229
|
+
return obj;
|
|
230
|
+
}
|
|
231
|
+
else if (obj === undefined) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return obj.has(key);
|
|
235
|
+
}
|
|
236
|
+
breakDexConnection(loadChildren = true, descend = true) {
|
|
237
|
+
const obj = this.dexObj();
|
|
238
|
+
if (obj === undefined) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const env = this.importEnv();
|
|
242
|
+
if (env === undefined) {
|
|
243
|
+
throw Error("[breakDexConnection] could not get env!");
|
|
244
|
+
}
|
|
245
|
+
this._breakDexConnection(env, loadChildren, descend);
|
|
246
|
+
}
|
|
247
|
+
_breakDexConnection(env, loadChildren, descend) {
|
|
248
|
+
// console.warn(`SymNode._breakDexConnection ${env} ${descend}`);
|
|
249
|
+
}
|
|
250
|
+
dexObj() {
|
|
251
|
+
const obj = this.symDexObj();
|
|
252
|
+
return obj && obj.dexObj;
|
|
253
|
+
}
|
|
254
|
+
symDexObj() {
|
|
255
|
+
const component = this.getComponent("symDexObj");
|
|
256
|
+
if (component instanceof SymDexObj) {
|
|
257
|
+
return component;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
symGMaterial(safe) {
|
|
261
|
+
const component = this.getComponent("symGMaterial");
|
|
262
|
+
if (component instanceof SymGMaterial) {
|
|
263
|
+
return component;
|
|
264
|
+
}
|
|
265
|
+
else if (safe) {
|
|
266
|
+
const component = new SymGMaterial();
|
|
267
|
+
this.addComponent(component);
|
|
268
|
+
return component;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
symGMaterialSelector(safe) {
|
|
272
|
+
const component = this.getComponent("symGMaterialSelector");
|
|
273
|
+
if (component instanceof SymGMaterialSelector) {
|
|
274
|
+
return component;
|
|
275
|
+
}
|
|
276
|
+
else if (safe) {
|
|
277
|
+
const component = new SymGMaterialSelector();
|
|
278
|
+
this.addComponent(component);
|
|
279
|
+
return component;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
symMesh(safe) {
|
|
283
|
+
const component = this.getComponent("symMesh");
|
|
284
|
+
if (component instanceof SymMesh) {
|
|
285
|
+
return component;
|
|
286
|
+
}
|
|
287
|
+
else if (safe) {
|
|
288
|
+
const component = new SymMesh();
|
|
289
|
+
this.addComponent(component);
|
|
290
|
+
return component;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
symSphere(safe) {
|
|
294
|
+
const component = this.getComponent("symSphere");
|
|
295
|
+
if (component instanceof SymSphere) {
|
|
296
|
+
return component;
|
|
297
|
+
}
|
|
298
|
+
else if (safe) {
|
|
299
|
+
const component = new SymSphere();
|
|
300
|
+
this.addComponent(component);
|
|
301
|
+
return component;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
symBox(safe) {
|
|
305
|
+
const component = this.getComponent("symBox");
|
|
306
|
+
if (component instanceof SymBox) {
|
|
307
|
+
return component;
|
|
308
|
+
}
|
|
309
|
+
else if (safe) {
|
|
310
|
+
const component = new SymBox();
|
|
311
|
+
this.addComponent(component);
|
|
312
|
+
return component;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
symPlane(safe) {
|
|
316
|
+
const component = this.getComponent("symPlane");
|
|
317
|
+
if (component instanceof SymPlane) {
|
|
318
|
+
return component;
|
|
319
|
+
}
|
|
320
|
+
else if (safe) {
|
|
321
|
+
const component = new SymPlane();
|
|
322
|
+
this.addComponent(component);
|
|
323
|
+
return component;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
symProps(safe) {
|
|
327
|
+
const component = this.getComponent("symProps");
|
|
328
|
+
if (component instanceof SymProps) {
|
|
329
|
+
return component;
|
|
330
|
+
}
|
|
331
|
+
else if (safe) {
|
|
332
|
+
const component = new SymProps();
|
|
333
|
+
this.addComponent(component);
|
|
334
|
+
return component;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
symReps(safe) {
|
|
338
|
+
const component = this.getComponent("symReps");
|
|
339
|
+
if (component instanceof SymReps) {
|
|
340
|
+
return component;
|
|
341
|
+
}
|
|
342
|
+
else if (safe) {
|
|
343
|
+
const component = new SymReps();
|
|
344
|
+
this.addComponent(component);
|
|
345
|
+
return component;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
symTags(safe) {
|
|
349
|
+
const component = this.getComponent("symTags");
|
|
350
|
+
if (component instanceof SymTags) {
|
|
351
|
+
return component;
|
|
352
|
+
}
|
|
353
|
+
else if (safe) {
|
|
354
|
+
const component = new SymTags();
|
|
355
|
+
this.addComponent(component);
|
|
356
|
+
return component;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
symTransform(safe) {
|
|
360
|
+
const component = this.getComponent("symTransform");
|
|
361
|
+
if (component instanceof SymTransform) {
|
|
362
|
+
return component;
|
|
363
|
+
}
|
|
364
|
+
else if (safe) {
|
|
365
|
+
const component = new SymTransform();
|
|
366
|
+
this.addComponent(component);
|
|
367
|
+
return component;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
symUVMapper(safe) {
|
|
371
|
+
const component = this.getComponent("symUVMapper");
|
|
372
|
+
if (component instanceof SymUVMapper) {
|
|
373
|
+
return component;
|
|
374
|
+
}
|
|
375
|
+
else if (safe) {
|
|
376
|
+
const component = new SymUVMapper();
|
|
377
|
+
this.addComponent(component);
|
|
378
|
+
return component;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
getMeasure() {
|
|
382
|
+
const component = this.components.get("symMeasure");
|
|
383
|
+
if (component instanceof SymMeasure) {
|
|
384
|
+
return component;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
isStretch(logger, detailLevel) {
|
|
388
|
+
let isStretch = this._isStretch.get(detailLevel);
|
|
389
|
+
if (isStretch === undefined) {
|
|
390
|
+
isStretch = symNodeIsStretch(logger, this, detailLevel);
|
|
391
|
+
this._isStretch.set(detailLevel, isStretch);
|
|
392
|
+
}
|
|
393
|
+
return isStretch;
|
|
394
|
+
}
|
|
395
|
+
// Components
|
|
396
|
+
getComponent(key) {
|
|
397
|
+
return this.components.get(key);
|
|
398
|
+
}
|
|
399
|
+
addComponent(component, invalidate = true) {
|
|
400
|
+
if (invalidate && component.breaksDex() && this.hasDexComponent(component.id)) {
|
|
401
|
+
this.breakDexConnection(false);
|
|
402
|
+
}
|
|
403
|
+
if (component.node && component.node !== this) {
|
|
404
|
+
throw Error("[SymNode.addComponent] component already has node.");
|
|
405
|
+
// component = component.copy();
|
|
406
|
+
}
|
|
407
|
+
if (this._children !== undefined) {
|
|
408
|
+
const features = component.features();
|
|
409
|
+
if (features !== undefined && features.has("children")) {
|
|
410
|
+
throw Error("[SymNode.addComponent] node already has children");
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
component.addComponent(this, invalidate);
|
|
414
|
+
this.components.set(component.id, component);
|
|
415
|
+
component.componentAdded(invalidate);
|
|
416
|
+
}
|
|
417
|
+
hasComponent(key) {
|
|
418
|
+
return this.components.has(key);
|
|
419
|
+
}
|
|
420
|
+
removeComponent(key, invalidate = true) {
|
|
421
|
+
throw Error(`SymNode.removeComponent ${key} ${invalidate}`);
|
|
422
|
+
}
|
|
423
|
+
loadComponents(logger, force = false) {
|
|
424
|
+
const obj = this.dexObj();
|
|
425
|
+
if (obj === undefined || obj.props === undefined) {
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
const env = this.importEnv();
|
|
429
|
+
let breakDex = false;
|
|
430
|
+
for (const key of obj.props.keys()) {
|
|
431
|
+
const prop = obj.get(key);
|
|
432
|
+
if (prop instanceof DexObj) {
|
|
433
|
+
const breaks = this.loadComponent(logger, key, prop, env, force);
|
|
434
|
+
if (breaks) {
|
|
435
|
+
breakDex = true;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
this.prepareAfterLoad();
|
|
440
|
+
if (breakDex) {
|
|
441
|
+
this.breakDexConnection();
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
loadComponent(logger, key, obj, env, force = false) {
|
|
445
|
+
if (env === undefined) {
|
|
446
|
+
env = this.importEnv();
|
|
447
|
+
}
|
|
448
|
+
if (env === undefined) {
|
|
449
|
+
throw logger.errorAsObject("[loadComponentObj] could not get env!");
|
|
450
|
+
}
|
|
451
|
+
else if (key === "children") {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
else if (loadLegacyComponent(logger, this, key, obj, env, force)) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
const type = obj.type;
|
|
458
|
+
if (type === undefined) {
|
|
459
|
+
throw logger.errorAsObject("[loadComponentObj] obj has no type!");
|
|
460
|
+
}
|
|
461
|
+
const component = instantiate(type);
|
|
462
|
+
if (component instanceof SymComponent) {
|
|
463
|
+
this.addComponent(component, false);
|
|
464
|
+
component.load(logger, obj, env, force);
|
|
465
|
+
}
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
prepareAfterLoad() {
|
|
469
|
+
this.buildFeatures();
|
|
470
|
+
this.fillPropsAfterLoad();
|
|
471
|
+
}
|
|
472
|
+
features(create = false) {
|
|
473
|
+
const features = this.get(SYM_FEATURES_KEY);
|
|
474
|
+
if (features instanceof Map) {
|
|
475
|
+
return features;
|
|
476
|
+
}
|
|
477
|
+
else if (create) {
|
|
478
|
+
const features = new Map();
|
|
479
|
+
this.set(SYM_FEATURES_KEY, features);
|
|
480
|
+
return features;
|
|
481
|
+
}
|
|
482
|
+
throw Error("no features");
|
|
483
|
+
}
|
|
484
|
+
featureProviderKey(feature) {
|
|
485
|
+
return this.features().get(feature);
|
|
486
|
+
}
|
|
487
|
+
featureProvider(feature) {
|
|
488
|
+
const key = this.featureProviderKey(feature);
|
|
489
|
+
if (key === undefined) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
return this.getComponent(key);
|
|
493
|
+
}
|
|
494
|
+
buildFeatures() {
|
|
495
|
+
const features = new Map();
|
|
496
|
+
for (const component of this.components.values()) {
|
|
497
|
+
const cFeatures = component.features();
|
|
498
|
+
if (cFeatures === undefined) {
|
|
499
|
+
continue;
|
|
500
|
+
}
|
|
501
|
+
for (const feature of cFeatures) {
|
|
502
|
+
features.set(feature, component.id);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
this.set(SYM_FEATURES_KEY, features);
|
|
506
|
+
return features;
|
|
507
|
+
}
|
|
508
|
+
addFeaturesFrom(component) {
|
|
509
|
+
const features = component.features();
|
|
510
|
+
if (features === undefined || features.size === 0) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const nodeFeatures = this.features(true);
|
|
514
|
+
for (const feature of features) {
|
|
515
|
+
const key = this.featureProviderKey(feature);
|
|
516
|
+
if (key !== undefined) {
|
|
517
|
+
this.removeComponent(key, false);
|
|
518
|
+
}
|
|
519
|
+
nodeFeatures.set(feature, component.id);
|
|
520
|
+
}
|
|
521
|
+
if (features.has("mesh")) {
|
|
522
|
+
console.warn("mesh cache should be invalidated!" + component);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
childrenProvider() {
|
|
526
|
+
return this.featureProvider("children");
|
|
527
|
+
}
|
|
528
|
+
meshProvider() {
|
|
529
|
+
return this.featureProvider("mesh");
|
|
530
|
+
}
|
|
531
|
+
get3DTmp(logger, detail) {
|
|
532
|
+
return findMeshNodes(logger, this, detail, [], []);
|
|
533
|
+
}
|
|
534
|
+
toString() {
|
|
535
|
+
return `SymNode("${this.id}")`;
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
export function toSymNode(logger, obj, parent, env, putImportEnv = false) {
|
|
539
|
+
if (env !== undefined) {
|
|
540
|
+
const node = env.sharedNodeMap.get(obj);
|
|
541
|
+
if (node instanceof SymNode) {
|
|
542
|
+
if (parent) {
|
|
543
|
+
parent.addChild(logger, node, false);
|
|
544
|
+
}
|
|
545
|
+
return node;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
switch (obj.type) {
|
|
549
|
+
case "node":
|
|
550
|
+
return toSymBasicNode(logger, obj, parent, env, putImportEnv);
|
|
551
|
+
case "xRefNode":
|
|
552
|
+
return toSymXRefNode(obj, parent, env, putImportEnv);
|
|
553
|
+
case "symFile":
|
|
554
|
+
return toSymFileRoot(logger, obj, parent);
|
|
555
|
+
}
|
|
556
|
+
throw logger.errorAsObject("[toSymNode] Unknown obj.type:", obj.type);
|
|
557
|
+
}
|
|
558
|
+
function toSymBasicNode(logger, obj, parent, env, putImportEnv = false) {
|
|
559
|
+
if (env === undefined) {
|
|
560
|
+
throw logger.errorAsObject("[toSymBasicNode] no env");
|
|
561
|
+
}
|
|
562
|
+
if (obj.id === undefined) {
|
|
563
|
+
throw logger.errorAsObject("[toSymBasicNode] obj.id is undefined");
|
|
564
|
+
}
|
|
565
|
+
const node = new SymNode(obj.id);
|
|
566
|
+
node.addComponent(new SymDexObj(obj, env.fileVersion, env), false);
|
|
567
|
+
env.sharedNodeMap.set(obj, node);
|
|
568
|
+
if (parent !== undefined) {
|
|
569
|
+
parent.addChild(logger, node, false);
|
|
570
|
+
}
|
|
571
|
+
node.loadComponents(logger);
|
|
572
|
+
return node;
|
|
573
|
+
}
|
|
574
|
+
function toSymXRefNode(_obj, _parent, _env, _putImportEnv = false) {
|
|
575
|
+
throw Error("[toSymXRefNode]");
|
|
576
|
+
}
|
|
577
|
+
function toSymFileRoot(logger, obj, parent) {
|
|
578
|
+
const version = obj.get("version");
|
|
579
|
+
const semver = loadVersion(version);
|
|
580
|
+
// Enable to get CmSym version statistics in the Exerciser
|
|
581
|
+
// logger.info("CmSym version " + semver.toDisplayString());
|
|
582
|
+
const env = new SymImportEnv(semver);
|
|
583
|
+
const sym = obj.get("sym");
|
|
584
|
+
if (!(sym instanceof DexObj)) {
|
|
585
|
+
throw Error(`sym: ${sym} is not a DexObj`);
|
|
586
|
+
}
|
|
587
|
+
return toSymNode(logger, sym, parent, env, true);
|
|
588
|
+
}
|
|
589
|
+
function loadVersion(obj) {
|
|
590
|
+
if (obj instanceof DexObj) {
|
|
591
|
+
return Semver.fromDex(obj);
|
|
592
|
+
}
|
|
593
|
+
if (obj instanceof DexVersion) {
|
|
594
|
+
return obj.toSemver();
|
|
595
|
+
}
|
|
596
|
+
throw Error(`obj: ${obj} can't load version`);
|
|
597
|
+
}
|
|
598
|
+
export function loadSymFile(logger, url, manager, abortSignal) {
|
|
599
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
600
|
+
const root = yield manager.load(logger, url, abortSignal);
|
|
601
|
+
return makeSymFromDex(logger, root);
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
export function makeSymFromDex(logger, root) {
|
|
605
|
+
const node = toSymNode(logger, root);
|
|
606
|
+
if (!(node instanceof SymNode)) {
|
|
607
|
+
throw Error(`node: ${node} is not a SymNode`);
|
|
608
|
+
}
|
|
609
|
+
node.ensureChildrenLoaded(logger);
|
|
610
|
+
return node;
|
|
611
|
+
}
|
|
612
|
+
function symNodeIsStretch(logger, symNode, detailLevel) {
|
|
613
|
+
const symMeasure = symNode.getMeasure();
|
|
614
|
+
if (symMeasure === undefined) {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
const children = symNode.children(logger, true, true);
|
|
618
|
+
let nodeName;
|
|
619
|
+
for (const [name, node] of children) {
|
|
620
|
+
if (name.startsWith("3D") || name.startsWith("2D")) {
|
|
621
|
+
const symReps = node.symReps(true);
|
|
622
|
+
const details = symReps._details;
|
|
623
|
+
if (details === undefined) {
|
|
624
|
+
continue;
|
|
625
|
+
}
|
|
626
|
+
const detailMask = details.values().next().value;
|
|
627
|
+
if (detailMask.includes(detailLevel)) {
|
|
628
|
+
nodeName = name;
|
|
629
|
+
break;
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
if (nodeName === undefined) {
|
|
634
|
+
logger.warn(`No 3D/2D SymNode which covers the detailLevel ${detailLevel} found`);
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
const node = children.get(nodeName);
|
|
638
|
+
if (node === undefined) {
|
|
639
|
+
return false;
|
|
640
|
+
}
|
|
641
|
+
const progsNode = node.components.get("symProgs");
|
|
642
|
+
if (progsNode === undefined) {
|
|
643
|
+
return false;
|
|
644
|
+
}
|
|
645
|
+
const symProgs = progsNode;
|
|
646
|
+
for (const prog of symProgs.progs) {
|
|
647
|
+
if (prog.isStretch) {
|
|
648
|
+
return true;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return false;
|
|
652
|
+
}
|