@configura/babylon-view 3.1.0 → 3.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nodes/CfgProductNode.js +16 -2
- package/dist/nodes/CfgSymRootNode.d.ts +5 -2
- package/dist/nodes/CfgSymRootNode.js +18 -9
- package/dist/utilities/anchor/anchor.d.ts +1 -1
- package/dist/utilities/anchor/anchor.js +10 -1
- package/dist/utilities/utilitiesSymRootIdentifier.d.ts +1 -1
- package/dist/utilities/utilitiesSymRootIdentifier.js +7 -3
- package/package.json +5 -5
|
@@ -215,8 +215,22 @@ export class CfgProductNode extends CfgTransformNode {
|
|
|
215
215
|
// Make a map of who is anchored to who
|
|
216
216
|
const anchoredToAnchors = makeAnchoredToAnchorMap(anchorableChildren, getAnchorTargetPriorityComparer(this.product._internal.measureDefinitions));
|
|
217
217
|
this._anchoredToAnchors = anchoredToAnchors;
|
|
218
|
+
const anchorRefKey = (ref) => `${ref.stretchSymNodeId}:${ref.toSp}`;
|
|
219
|
+
const inheritedAnchorMap = new Map();
|
|
218
220
|
for (const child of anchorableChildren) {
|
|
219
|
-
|
|
221
|
+
const anchorTarget = anchoredToAnchors.get(child);
|
|
222
|
+
if (anchorTarget && child.anchorRef) {
|
|
223
|
+
child.setAnchorTarget(anchorTarget);
|
|
224
|
+
inheritedAnchorMap.set(anchorRefKey(child.anchorRef), anchorTarget);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
for (const child of anchorableChildren) {
|
|
228
|
+
if (isSymRootNode(child) && child.parentAnchorRef) {
|
|
229
|
+
const parentAnchorTarget = inheritedAnchorMap.get(anchorRefKey(child.parentAnchorRef));
|
|
230
|
+
if (parentAnchorTarget) {
|
|
231
|
+
child.setParentAnchorTarget(parentAnchorTarget);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
220
234
|
}
|
|
221
235
|
this.refreshStretch();
|
|
222
236
|
for (const symRoot of addedSymRoots) {
|
|
@@ -592,7 +606,7 @@ export class CfgProductNode extends CfgTransformNode {
|
|
|
592
606
|
alert("You must provide an URL to a CmSym-file");
|
|
593
607
|
return;
|
|
594
608
|
}
|
|
595
|
-
const symRootNode = CfgSymRootNode.makeCfgSymRootFromUrl(this.logger, true, this._renderEnvironment, this, url, undefined, undefined);
|
|
609
|
+
const symRootNode = CfgSymRootNode.makeCfgSymRootFromUrl(this.logger, true, this._renderEnvironment, this, url, undefined, undefined, undefined);
|
|
596
610
|
this._applyDebugSymRoots([symRootNode]);
|
|
597
611
|
}
|
|
598
612
|
}
|
|
@@ -14,15 +14,17 @@ export declare class CfgSymRootNode extends CfgSymNode {
|
|
|
14
14
|
private _isForDebug;
|
|
15
15
|
_identifier: string;
|
|
16
16
|
readonly anchorRef: CfgAnchorRef | undefined;
|
|
17
|
+
readonly parentAnchorRef: CfgAnchorRef | undefined;
|
|
17
18
|
static makeCfgSymRootFromRootNodeSource(logger: Logger, isForDebug: boolean, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, rootNodeSource: RootNodeSource): Promise<CfgSymRootNode | undefined>;
|
|
18
|
-
static makeCfgSymRootFromUrl(logger: Logger, isForDebug: boolean, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, symUrl: string, transform: ModelTransform | undefined, anchorRef: CfgAnchorRef | undefined): Promise<CfgSymRootNode | undefined>;
|
|
19
|
+
static makeCfgSymRootFromUrl(logger: Logger, isForDebug: boolean, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, symUrl: string, transform: ModelTransform | undefined, anchorRef: CfgAnchorRef | undefined, parentAnchorRef: CfgAnchorRef | undefined): Promise<CfgSymRootNode | undefined>;
|
|
19
20
|
static makeCfgSymRootFromFile(logger: Logger, isForDebug: boolean, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, file: File): Promise<CfgSymRootNode | undefined>;
|
|
20
21
|
get cfgClassName(): string;
|
|
21
|
-
static makeCfgSymRootFromSymNode(logger: Logger, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, isForDebug: boolean, identifier: string, transform: ModelTransform | undefined, anchorRef: CfgAnchorRef | undefined, symNode: SymNode): Promise<CfgSymRootNode | undefined>;
|
|
22
|
+
static makeCfgSymRootFromSymNode(logger: Logger, renderEnvironment: RenderEnv, cfgProductNodeParent: CfgProductNode, isForDebug: boolean, identifier: string, transform: ModelTransform | undefined, anchorRef: CfgAnchorRef | undefined, parentAnchorRef: CfgAnchorRef | undefined, symNode: SymNode): Promise<CfgSymRootNode | undefined>;
|
|
22
23
|
private _destroyed;
|
|
23
24
|
private _originalMatrixWithModelTransform;
|
|
24
25
|
private _stretchDatas;
|
|
25
26
|
private _anchorTarget;
|
|
27
|
+
private _parentAnchorTarget;
|
|
26
28
|
private _stretchedAnchorPointMatrix;
|
|
27
29
|
private constructor();
|
|
28
30
|
get isForDebug(): boolean;
|
|
@@ -39,6 +41,7 @@ export declare class CfgSymRootNode extends CfgSymNode {
|
|
|
39
41
|
get stretchDatas(): CfgStretchData[];
|
|
40
42
|
get accumulatedStretchDatas(): CfgStretchData[];
|
|
41
43
|
setAnchorTarget(anchorTarget: CfgAnchorTargetNode | undefined): void;
|
|
44
|
+
setParentAnchorTarget(parentAnchorTarget: CfgAnchorTargetNode | undefined): void;
|
|
42
45
|
refreshStretch(): void;
|
|
43
46
|
protected addInspectorProperties(): void;
|
|
44
47
|
private get _inspectorIsForDebug();
|
|
@@ -50,11 +50,12 @@ function getBestMatchingDetailLevel(logger, symNode, allowedLevels) {
|
|
|
50
50
|
return detailLevel || DetailLevel.undefined;
|
|
51
51
|
}
|
|
52
52
|
export class CfgSymRootNode extends CfgSymNode {
|
|
53
|
-
constructor(renderEnvironment, cfgProductNodeParent, _isForDebug, detailLevel, symNode, _identifier, modelTransform, anchorRef) {
|
|
53
|
+
constructor(renderEnvironment, cfgProductNodeParent, _isForDebug, detailLevel, symNode, _identifier, modelTransform, anchorRef, parentAnchorRef) {
|
|
54
54
|
super(renderEnvironment, cfgProductNodeParent, undefined, detailLevel, symNode);
|
|
55
55
|
this._isForDebug = _isForDebug;
|
|
56
56
|
this._identifier = _identifier;
|
|
57
57
|
this.anchorRef = anchorRef;
|
|
58
|
+
this.parentAnchorRef = parentAnchorRef;
|
|
58
59
|
this._destroyed = false;
|
|
59
60
|
this.name = "(SymRoot) " + symNode.id;
|
|
60
61
|
this.modelTransform = modelTransform;
|
|
@@ -63,11 +64,11 @@ export class CfgSymRootNode extends CfgSymNode {
|
|
|
63
64
|
static makeCfgSymRootFromRootNodeSource(logger, isForDebug, renderEnvironment, cfgProductNodeParent, rootNodeSource) {
|
|
64
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
66
|
return isModel(rootNodeSource)
|
|
66
|
-
? this.makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, cfgProductNodeParent, rootNodeSource.uri, rootNodeSource.t, CfgAnchorRef.make(rootNodeSource.anchor))
|
|
67
|
+
? this.makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, cfgProductNodeParent, rootNodeSource.uri, rootNodeSource.t, CfgAnchorRef.make(rootNodeSource.anchor), CfgAnchorRef.make(rootNodeSource.parentAnchor))
|
|
67
68
|
: this.makeCfgSymRootFromFile(logger, isForDebug, renderEnvironment, cfgProductNodeParent, rootNodeSource);
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
|
-
static makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, cfgProductNodeParent, symUrl, transform, anchorRef) {
|
|
71
|
+
static makeCfgSymRootFromUrl(logger, isForDebug, renderEnvironment, cfgProductNodeParent, symUrl, transform, anchorRef, parentAnchorRef) {
|
|
71
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
72
73
|
if (!/.cmsym$/i.test(symUrl)) {
|
|
73
74
|
renderEnvironment.notifyError(logger.errorAsObject("Unsupported model URL (not cmsym format): ", symUrl));
|
|
@@ -75,7 +76,7 @@ export class CfgSymRootNode extends CfgSymNode {
|
|
|
75
76
|
}
|
|
76
77
|
try {
|
|
77
78
|
const symNode = yield loadCachedSymNode(logger, symUrl, renderEnvironment);
|
|
78
|
-
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, makeIdentifier("uri", symUrl), transform, anchorRef, symNode);
|
|
79
|
+
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, makeIdentifier("uri", symUrl), transform, anchorRef, parentAnchorRef, symNode);
|
|
79
80
|
}
|
|
80
81
|
catch (e) {
|
|
81
82
|
logger.errorFromCaught(e);
|
|
@@ -88,20 +89,20 @@ export class CfgSymRootNode extends CfgSymNode {
|
|
|
88
89
|
const arrayBuffer = yield readFileToArrayBuffer(file);
|
|
89
90
|
const dexObj = renderEnvironment.dexManager.arrayBufferToDexObj(logger, "", arrayBuffer.buffer);
|
|
90
91
|
const symNode = makeSymFromDex(logger, dexObj);
|
|
91
|
-
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, makeIdentifier("file", file.name), undefined, undefined, symNode);
|
|
92
|
+
return this.makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, makeIdentifier("file", file.name), undefined, undefined, undefined, symNode);
|
|
92
93
|
});
|
|
93
94
|
}
|
|
94
95
|
get cfgClassName() {
|
|
95
96
|
return "CfgSymRootNode";
|
|
96
97
|
}
|
|
97
|
-
static makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, identifier, transform, anchorRef, symNode) {
|
|
98
|
+
static makeCfgSymRootFromSymNode(logger, renderEnvironment, cfgProductNodeParent, isForDebug, identifier, transform, anchorRef, parentAnchorRef, symNode) {
|
|
98
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
100
|
if (symNode === undefined) {
|
|
100
101
|
logger.warn("No symNode");
|
|
101
102
|
return;
|
|
102
103
|
}
|
|
103
104
|
const detailLevel = getBestMatchingDetailLevel(logger, symNode, renderEnvironment.allowedDetailLevels);
|
|
104
|
-
const node = new this(renderEnvironment, cfgProductNodeParent, isForDebug, detailLevel, symNode, identifier, transform, anchorRef);
|
|
105
|
+
const node = new this(renderEnvironment, cfgProductNodeParent, isForDebug, detailLevel, symNode, identifier, transform, anchorRef, parentAnchorRef);
|
|
105
106
|
yield this.initCfgSymNode(node);
|
|
106
107
|
return node;
|
|
107
108
|
});
|
|
@@ -110,7 +111,7 @@ export class CfgSymRootNode extends CfgSymNode {
|
|
|
110
111
|
return this._isForDebug;
|
|
111
112
|
}
|
|
112
113
|
isSameIdentifierTransformAndAnchor(rootNodeSource) {
|
|
113
|
-
return isSameIdentifierTransformAndAnchor(this._identifier, this.modelTransform, this.anchorRef, makeIdentifierFromRootNodeSource(rootNodeSource), isModel(rootNodeSource) ? rootNodeSource.t : undefined, isModel(rootNodeSource) ? CfgAnchorRef.make(rootNodeSource.anchor) : undefined);
|
|
114
|
+
return isSameIdentifierTransformAndAnchor(this._identifier, this.modelTransform, this.anchorRef, this.parentAnchorRef, makeIdentifierFromRootNodeSource(rootNodeSource), isModel(rootNodeSource) ? rootNodeSource.t : undefined, isModel(rootNodeSource) ? CfgAnchorRef.make(rootNodeSource.anchor) : undefined, isModel(rootNodeSource) ? CfgAnchorRef.make(rootNodeSource.parentAnchor) : undefined);
|
|
114
115
|
}
|
|
115
116
|
destroy() {
|
|
116
117
|
this._destroyed = true;
|
|
@@ -211,9 +212,17 @@ export class CfgSymRootNode extends CfgSymNode {
|
|
|
211
212
|
setAnchorTarget(anchorTarget) {
|
|
212
213
|
this._anchorTarget = anchorTarget;
|
|
213
214
|
}
|
|
215
|
+
setParentAnchorTarget(parentAnchorTarget) {
|
|
216
|
+
this._parentAnchorTarget = parentAnchorTarget;
|
|
217
|
+
}
|
|
214
218
|
refreshStretch() {
|
|
215
219
|
super.refreshStretch();
|
|
216
|
-
|
|
220
|
+
// Apply transformation relative to the parent anchor if it exists; otherwise, use this node's own anchor.
|
|
221
|
+
// Note: If both parent and own anchors exist, this may cause unexpected transformation results.
|
|
222
|
+
const [anchorRef, anchorTarget] = this.parentAnchorRef
|
|
223
|
+
? [this.parentAnchorRef, this._parentAnchorTarget]
|
|
224
|
+
: [this.anchorRef, this._anchorTarget];
|
|
225
|
+
const updated = updatedStretchedAnchorPointMatrix(anchorRef, anchorTarget, this._stretchedAnchorPointMatrix);
|
|
217
226
|
if (updated === undefined) {
|
|
218
227
|
return;
|
|
219
228
|
}
|
|
@@ -46,6 +46,6 @@ export declare function getRawAnchorPoint(anchorTarget: CfgAnchorTargetNode | un
|
|
|
46
46
|
* Application of anchoring happens from anchor tree root and out, so that originalMatrix of
|
|
47
47
|
* anchorTarget will already have any anchoring and stretch applied.
|
|
48
48
|
*/
|
|
49
|
-
export declare function getStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget:
|
|
49
|
+
export declare function getStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgSymRootNode | undefined): Matrix | undefined;
|
|
50
50
|
export declare function updatedStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgAnchorTargetNode | undefined, currentStretchedAnchorPointMatrix: Matrix | undefined): Matrix | undefined;
|
|
51
51
|
//# sourceMappingURL=anchor.d.ts.map
|
|
@@ -104,6 +104,14 @@ export function getRawAnchorPoint(anchorTarget, anchorRef) {
|
|
|
104
104
|
* Application of anchoring happens from anchor tree root and out, so that originalMatrix of
|
|
105
105
|
* anchorTarget will already have any anchoring and stretch applied.
|
|
106
106
|
*/
|
|
107
|
+
/// Calculate a matrix which is the translation that makes this
|
|
108
|
+
/// move as if it was a child of anchorTarget and then moved to
|
|
109
|
+
/// the end of the anchorPoint.
|
|
110
|
+
/// It is assumed that all anchoring happens on symRoot-level
|
|
111
|
+
/// and therefore all anchorees are siblings to the anchorers.
|
|
112
|
+
/// Application of anchoring happens from anchor tree root and
|
|
113
|
+
/// out, so that originalMatrix of anchorTarget will already have
|
|
114
|
+
/// any anchoring and stretch applied.
|
|
107
115
|
export function getStretchedAnchorPointMatrix(anchorRef, anchorTarget) {
|
|
108
116
|
const rawAnchorPoint = getRawAnchorPoint(anchorTarget, anchorRef);
|
|
109
117
|
if (rawAnchorPoint === undefined || anchorTarget === undefined) {
|
|
@@ -112,7 +120,8 @@ export function getStretchedAnchorPointMatrix(anchorRef, anchorTarget) {
|
|
|
112
120
|
// Apply current stretch to the anchor point
|
|
113
121
|
const stretchedAnchorPoint = toStretchedPoint(rawAnchorPoint, anchorTarget.stretchDatas, anchorTarget.cfgProductNode.product.configuration._internal
|
|
114
122
|
.stretchReferenceLengthsByMeasureParamCode);
|
|
115
|
-
//
|
|
123
|
+
// Apply the anchorTarget matrix. Move the point as if it was
|
|
124
|
+
// a child to the anchorTarget.
|
|
116
125
|
const anchorTargetMatrixApplied = Vector3.TransformCoordinates(stretchedAnchorPoint, anchorTarget.originalMatrix);
|
|
117
126
|
// We use translation as when we anchor things we do not change their orientation,
|
|
118
127
|
// we only move them to snap to this point
|
|
@@ -3,6 +3,6 @@ import { CfgAnchorRef } from "./anchor/anchor.js";
|
|
|
3
3
|
export declare function makeIdentifier(type: "uri" | "file", v: string): string;
|
|
4
4
|
export declare function identifierIsUri(identifier: string): boolean;
|
|
5
5
|
export declare function makeIdentifierFromRootNodeSource(source: RootNodeSource): string;
|
|
6
|
-
export declare function isSameIdentifierTransformAndAnchor(identifier1: string, transform1: ModelTransform | undefined, anchor1: CfgAnchorRef | undefined, identifier2: string, transform2: ModelTransform | undefined, anchor2: CfgAnchorRef | undefined): boolean;
|
|
6
|
+
export declare function isSameIdentifierTransformAndAnchor(identifier1: string, transform1: ModelTransform | undefined, anchor1: CfgAnchorRef | undefined, parentAnchor1: CfgAnchorRef | undefined, identifier2: string, transform2: ModelTransform | undefined, anchor2: CfgAnchorRef | undefined, parentAnchor2: CfgAnchorRef | undefined): boolean;
|
|
7
7
|
export declare function isSameRootNodeSource(source1: RootNodeSource, source2: RootNodeSource): boolean;
|
|
8
8
|
//# sourceMappingURL=utilitiesSymRootIdentifier.d.ts.map
|
|
@@ -12,15 +12,19 @@ export function makeIdentifierFromRootNodeSource(source) {
|
|
|
12
12
|
? makeIdentifier("uri", source.uri)
|
|
13
13
|
: makeIdentifier("file", source.name);
|
|
14
14
|
}
|
|
15
|
-
export function isSameIdentifierTransformAndAnchor(identifier1, transform1, anchor1, identifier2, transform2, anchor2) {
|
|
15
|
+
export function isSameIdentifierTransformAndAnchor(identifier1, transform1, anchor1, parentAnchor1, identifier2, transform2, anchor2, parentAnchor2) {
|
|
16
16
|
return (identifier1 === identifier2 &&
|
|
17
17
|
((transform1 === undefined && transform2 === undefined) ||
|
|
18
18
|
(transform1 !== undefined &&
|
|
19
19
|
transform2 !== undefined &&
|
|
20
20
|
modelTransformsEqual(transform1, transform2))) &&
|
|
21
21
|
((anchor1 === undefined && anchor2 === undefined) ||
|
|
22
|
-
(anchor1 !== undefined && anchor2 !== undefined && anchor1.equal(anchor2)))
|
|
22
|
+
(anchor1 !== undefined && anchor2 !== undefined && anchor1.equal(anchor2))) &&
|
|
23
|
+
((parentAnchor1 === undefined && parentAnchor2 === undefined) ||
|
|
24
|
+
(parentAnchor1 !== undefined &&
|
|
25
|
+
parentAnchor2 !== undefined &&
|
|
26
|
+
parentAnchor1.equal(parentAnchor2))));
|
|
23
27
|
}
|
|
24
28
|
export function isSameRootNodeSource(source1, source2) {
|
|
25
|
-
return isSameIdentifierTransformAndAnchor(makeIdentifierFromRootNodeSource(source1), isModel(source1) ? source1.t : undefined, isModel(source1) ? CfgAnchorRef.make(source1.anchor) : undefined, makeIdentifierFromRootNodeSource(source2), isModel(source2) ? source2.t : undefined, isModel(source2) ? CfgAnchorRef.make(source2.anchor) : undefined);
|
|
29
|
+
return isSameIdentifierTransformAndAnchor(makeIdentifierFromRootNodeSource(source1), isModel(source1) ? source1.t : undefined, isModel(source1) ? CfgAnchorRef.make(source1.anchor) : undefined, isModel(source1) ? CfgAnchorRef.make(source1.parentAnchor) : undefined, makeIdentifierFromRootNodeSource(source2), isModel(source2) ? source2.t : undefined, isModel(source2) ? CfgAnchorRef.make(source2.anchor) : undefined, isModel(source2) ? CfgAnchorRef.make(source2.parentAnchor) : undefined);
|
|
26
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configura/babylon-view",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0-alpha.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -22,13 +22,13 @@
|
|
|
22
22
|
"@babylonjs/loaders": "5.52.0",
|
|
23
23
|
"@babylonjs/materials": "5.52.0",
|
|
24
24
|
"@babylonjs/serializers": "5.52.0",
|
|
25
|
-
"@configura/web-core": "3.
|
|
26
|
-
"@configura/web-utilities": "3.
|
|
25
|
+
"@configura/web-core": "3.2.0-alpha.0",
|
|
26
|
+
"@configura/web-utilities": "3.2.0-alpha.0",
|
|
27
27
|
"babylonjs-gltf2interface": "5.22.0",
|
|
28
28
|
"exifr": "^7.1.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@configura/web-api": "3.
|
|
31
|
+
"@configura/web-api": "3.2.0-alpha.0",
|
|
32
32
|
"@types/react": "17.0.9",
|
|
33
33
|
"@types/react-dom": "17.0.6",
|
|
34
34
|
"del-cli": "^3.0.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "7a79fdef61d85c6ac8a1f84be9070c12ea37ffe2"
|
|
41
41
|
}
|