@configura/babylon-view 1.3.0-alpha.3 → 1.3.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.
Files changed (125) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +1 -1
  3. package/dist/animation/AnimatableObject.d.ts +8 -8
  4. package/dist/animation/AnimatableObject.js +3 -3
  5. package/dist/animation/animator/Animator.d.ts +33 -33
  6. package/dist/animation/animator/Animator.js +58 -58
  7. package/dist/animation/animator/AnimatorEasing.d.ts +16 -16
  8. package/dist/animation/animator/AnimatorEasing.js +31 -31
  9. package/dist/animation/animator/AnimatorEasingMatrix.d.ts +14 -14
  10. package/dist/animation/animator/AnimatorEasingMatrix.js +16 -16
  11. package/dist/animation/animator/AnimatorHighlight.d.ts +16 -16
  12. package/dist/animation/animator/AnimatorHighlight.js +32 -32
  13. package/dist/animation/animator/AnimatorPointToPoint.d.ts +8 -8
  14. package/dist/animation/animator/AnimatorPointToPoint.js +14 -14
  15. package/dist/animation/animator/AnimatorQueue.d.ts +13 -13
  16. package/dist/animation/animator/AnimatorQueue.js +57 -57
  17. package/dist/animation/animator/AnimatorScale.d.ts +8 -8
  18. package/dist/animation/animator/AnimatorScale.js +13 -13
  19. package/dist/animation/animator/AnimatorSpin.d.ts +10 -10
  20. package/dist/animation/animator/AnimatorSpin.js +13 -13
  21. package/dist/animation/animator/EasingFunctions.d.ts +35 -35
  22. package/dist/animation/animator/EasingFunctions.js +137 -137
  23. package/dist/animation/coordinator/Coordinator.d.ts +28 -28
  24. package/dist/animation/coordinator/Coordinator.js +47 -47
  25. package/dist/animation/coordinator/CoordinatorDropAndSpin.d.ts +22 -22
  26. package/dist/animation/coordinator/CoordinatorDropAndSpin.js +133 -133
  27. package/dist/animation/coordinator/CoordinatorIdentity.d.ts +11 -11
  28. package/dist/animation/coordinator/CoordinatorIdentity.js +12 -12
  29. package/dist/animation/coordinator/CoordinatorNodeQueues.d.ts +18 -18
  30. package/dist/animation/coordinator/CoordinatorNodeQueues.js +50 -50
  31. package/dist/animation/coordinator/CoordinatorPulse.d.ts +21 -21
  32. package/dist/animation/coordinator/CoordinatorPulse.js +47 -47
  33. package/dist/animation/coordinator/CoordinatorPulseBounce.d.ts +14 -14
  34. package/dist/animation/coordinator/CoordinatorPulseBounce.js +40 -40
  35. package/dist/animation/coordinator/CoordinatorPulseHighlight.d.ts +13 -13
  36. package/dist/animation/coordinator/CoordinatorPulseHighlight.js +34 -34
  37. package/dist/animation/coordinator/CoordinatorPulseInflate.d.ts +14 -14
  38. package/dist/animation/coordinator/CoordinatorPulseInflate.js +30 -30
  39. package/dist/camera/CameraCreator.d.ts +5 -5
  40. package/dist/camera/CameraCreator.js +4 -4
  41. package/dist/camera/CfgArcRotateCameraPointersInput.d.ts +26 -10
  42. package/dist/camera/CfgArcRotateCameraPointersInput.js +264 -262
  43. package/dist/camera/CfgOrbitalCamera.d.ts +68 -68
  44. package/dist/camera/CfgOrbitalCamera.js +250 -250
  45. package/dist/camera/CfgOrbitalCameraControlProps.d.ts +6 -6
  46. package/dist/camera/CfgOrbitalCameraControlProps.js +3 -3
  47. package/dist/camera/GradingApplier.d.ts +3 -3
  48. package/dist/camera/GradingApplier.js +48 -48
  49. package/dist/engine/EngineCreator.d.ts +3 -3
  50. package/dist/engine/EngineCreator.js +10 -10
  51. package/dist/geometry/CfgGeometry.d.ts +29 -12
  52. package/dist/geometry/CfgGeometry.js +146 -117
  53. package/dist/geometry/CfgMesh.d.ts +10 -7
  54. package/dist/geometry/CfgMesh.js +38 -8
  55. package/dist/geometry/geoSplitter.d.ts +8 -8
  56. package/dist/geometry/geoSplitter.js +192 -192
  57. package/dist/geometry/stretch/CfgMorphTarget.d.ts +16 -0
  58. package/dist/geometry/stretch/CfgMorphTarget.js +65 -0
  59. package/dist/geometry/stretch/CfgStretchData.d.ts +115 -0
  60. package/dist/geometry/stretch/CfgStretchData.js +340 -0
  61. package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +17 -0
  62. package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -0
  63. package/dist/index.d.ts +13 -13
  64. package/dist/index.js +13 -13
  65. package/dist/light/CfgDirectionalLight.d.ts +8 -8
  66. package/dist/light/CfgDirectionalLight.js +18 -18
  67. package/dist/light/CfgHemisphericLight.d.ts +7 -7
  68. package/dist/light/CfgHemisphericLight.js +17 -17
  69. package/dist/light/CfgPointLight.d.ts +8 -8
  70. package/dist/light/CfgPointLight.js +18 -18
  71. package/dist/light/DefaultLightRig.d.ts +19 -19
  72. package/dist/light/DefaultLightRig.js +77 -77
  73. package/dist/light/LightRigCreator.d.ts +9 -9
  74. package/dist/light/LightRigCreator.js +3 -3
  75. package/dist/material/CfgMaterial.d.ts +68 -53
  76. package/dist/material/CfgMaterial.js +482 -454
  77. package/dist/material/DummyMaterialCreator.d.ts +4 -4
  78. package/dist/material/DummyMaterialCreator.js +15 -15
  79. package/dist/material/material.d.ts +18 -18
  80. package/dist/material/material.js +128 -128
  81. package/dist/material/texture.d.ts +14 -14
  82. package/dist/material/texture.js +306 -304
  83. package/dist/nodes/CfgContentRootNode.d.ts +19 -19
  84. package/dist/nodes/CfgContentRootNode.js +75 -75
  85. package/dist/nodes/CfgDeferredMeshNode.d.ts +55 -48
  86. package/dist/nodes/CfgDeferredMeshNode.js +377 -347
  87. package/dist/nodes/CfgProductNode.d.ts +126 -61
  88. package/dist/nodes/CfgProductNode.js +578 -486
  89. package/dist/nodes/CfgSymNode.d.ts +50 -42
  90. package/dist/nodes/CfgSymNode.js +249 -216
  91. package/dist/nodes/CfgSymRootNode.d.ts +45 -33
  92. package/dist/nodes/CfgSymRootNode.js +220 -175
  93. package/dist/nodes/CfgTransformNode.d.ts +33 -29
  94. package/dist/nodes/CfgTransformNode.js +83 -81
  95. package/dist/scene/SceneCreator.d.ts +6 -6
  96. package/dist/scene/SceneCreator.js +22 -22
  97. package/dist/utilities/CfgBoundingBox.d.ts +21 -16
  98. package/dist/utilities/CfgBoundingBox.js +81 -64
  99. package/dist/utilities/anchor/anchor.d.ts +52 -0
  100. package/dist/utilities/anchor/anchor.js +136 -0
  101. package/dist/utilities/anchor/anchorMap.d.ts +21 -0
  102. package/dist/utilities/anchor/anchorMap.js +111 -0
  103. package/dist/utilities/utilities3D.d.ts +70 -26
  104. package/dist/utilities/utilities3D.js +265 -187
  105. package/dist/utilities/utilitiesColor.d.ts +18 -18
  106. package/dist/utilities/utilitiesColor.js +48 -48
  107. package/dist/utilities/utilitiesImage.d.ts +6 -6
  108. package/dist/utilities/utilitiesImage.js +107 -107
  109. package/dist/utilities/utilitiesSymRootIdentifier.d.ts +7 -5
  110. package/dist/utilities/utilitiesSymRootIdentifier.js +26 -20
  111. package/dist/view/BaseView.d.ts +78 -70
  112. package/dist/view/BaseView.js +297 -291
  113. package/dist/view/BaseViewConfiguration.d.ts +32 -32
  114. package/dist/view/BaseViewConfiguration.js +8 -8
  115. package/dist/view/RenderEnv.d.ts +43 -38
  116. package/dist/view/RenderEnv.js +7 -7
  117. package/dist/view/SingleProductDefaultCameraView.d.ts +33 -33
  118. package/dist/view/SingleProductDefaultCameraView.js +141 -141
  119. package/dist/view/SingleProductDefaultCameraViewConfiguration.d.ts +46 -46
  120. package/dist/view/SingleProductDefaultCameraViewConfiguration.js +11 -11
  121. package/dist/view/SingleProductView.d.ts +49 -42
  122. package/dist/view/SingleProductView.js +206 -205
  123. package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
  124. package/dist/view/SingleProductViewConfiguration.js +19 -19
  125. package/package.json +5 -5
@@ -1,81 +1,83 @@
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
+ /**
41
+ * Recursively calculates the world matrix based on originalMatrix on nodes which inherits
42
+ * CfgTransformNode.
43
+ */
44
+ get worldOriginalMatrix() {
45
+ const o = this.originalMatrix;
46
+ const p = this.parent;
47
+ if (p && p instanceof CfgTransformNode) {
48
+ return o.multiply(p.worldOriginalMatrix);
49
+ }
50
+ return o;
51
+ }
52
+ remove(dispose, ...objects) {
53
+ for (const obj of objects) {
54
+ if (dispose) {
55
+ obj.dispose();
56
+ }
57
+ else {
58
+ obj.parent = null;
59
+ }
60
+ }
61
+ return this;
62
+ }
63
+ /**
64
+ * Adds the property to the instance so it shows up in the Babylon.js Inspector.
65
+ *
66
+ * TODO Babylon: Currently they show up as editable, even though they are used to display
67
+ * read-only information. Metadata seems to be more correct, but is not (yet?) included by the
68
+ * Inspector.
69
+ */
70
+ addInspectableCustomProperty(property) {
71
+ if (this.inspectableCustomProperties === undefined) {
72
+ this.inspectableCustomProperties = [];
73
+ }
74
+ this.inspectableCustomProperties.push(property);
75
+ }
76
+ addInspectorProperties() {
77
+ this.addInspectableCustomProperty({
78
+ label: "Cfg Class",
79
+ propertyName: "cfgClassName",
80
+ type: InspectableType.String,
81
+ });
82
+ }
83
+ }
@@ -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
+ }
@@ -1,17 +1,22 @@
1
- import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- export declare class CfgBoundingBox {
3
- minimum: Vector3;
4
- maximum: Vector3;
5
- constructor(minimum?: Vector3, maximum?: Vector3);
6
- private _isEmpty;
7
- reConstruct(minimum: Vector3, maximum: Vector3): CfgBoundingBox;
8
- copyFrom(otherBoundingBox: CfgBoundingBox): CfgBoundingBox;
9
- clone(): CfgBoundingBox;
10
- get center(): Vector3;
11
- translate(vec: Vector3): CfgBoundingBox;
12
- expand(otherBoundingBox: CfgBoundingBox): CfgBoundingBox;
13
- applyMatrix(matrix: Matrix): CfgBoundingBox;
14
- get spaceDiagonal(): number;
15
- get isEmpty(): boolean;
16
- }
1
+ import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ export declare class CfgBoundingBox {
3
+ minimum: Vector3;
4
+ maximum: Vector3;
5
+ constructor(minimum?: Vector3, maximum?: Vector3);
6
+ /**
7
+ * Means that the bounding box should be seen as "undefined", which is not the same as "zero"
8
+ */
9
+ private _isEmpty;
10
+ reConstruct(minimum: Vector3, maximum: Vector3): CfgBoundingBox;
11
+ copyFrom(otherBoundingBox: CfgBoundingBox): CfgBoundingBox;
12
+ clone(): CfgBoundingBox;
13
+ get center(): Vector3;
14
+ translate(vec: Vector3): CfgBoundingBox;
15
+ expand(otherBoundingBox: CfgBoundingBox): CfgBoundingBox;
16
+ expandWithPoint(point: Vector3): CfgBoundingBox;
17
+ applyMatrix(matrix: Matrix): CfgBoundingBox;
18
+ get spaceDiagonal(): number;
19
+ get isEmpty(): boolean;
20
+ get corners(): Vector3[];
21
+ }
17
22
  //# sourceMappingURL=CfgBoundingBox.d.ts.map
@@ -1,64 +1,81 @@
1
- import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- export class CfgBoundingBox {
3
- constructor(minimum, maximum) {
4
- /// Means that the bounding box should be seen as "undefined", which is not the same as "zero".
5
- this._isEmpty = true;
6
- this.minimum = (minimum === null || minimum === void 0 ? void 0 : minimum.clone()) || Vector3.Zero();
7
- this.maximum = (maximum === null || maximum === void 0 ? void 0 : maximum.clone()) || Vector3.Zero();
8
- this._isEmpty = minimum === undefined && maximum === undefined;
9
- }
10
- reConstruct(minimum, maximum) {
11
- this.minimum.copyFrom(minimum);
12
- this.maximum.copyFrom(maximum);
13
- this._isEmpty = false;
14
- return this;
15
- }
16
- copyFrom(otherBoundingBox) {
17
- this.reConstruct(otherBoundingBox.minimum, otherBoundingBox.maximum);
18
- this._isEmpty = otherBoundingBox.isEmpty;
19
- return this;
20
- }
21
- clone() {
22
- return new CfgBoundingBox(this.minimum, this.maximum);
23
- }
24
- get center() {
25
- return Vector3.Center(this.minimum, this.maximum);
26
- }
27
- translate(vec) {
28
- this.minimum.addInPlace(vec);
29
- this.maximum.addInPlace(vec);
30
- return this;
31
- }
32
- expand(otherBoundingBox) {
33
- if (otherBoundingBox.isEmpty) {
34
- return this;
35
- }
36
- if (this.isEmpty) {
37
- this.reConstruct(otherBoundingBox.minimum, otherBoundingBox.maximum);
38
- return this;
39
- }
40
- this.reConstruct(this.minimum.minimizeInPlace(otherBoundingBox.minimum), this.maximum.maximizeInPlace(otherBoundingBox.maximum));
41
- return this;
42
- }
43
- applyMatrix(matrix) {
44
- if (this.isEmpty) {
45
- return this;
46
- }
47
- // Transform can be rotation, in which case we might need to re-minimize/maximize
48
- const transformedMin = Vector3.TransformCoordinates(this.minimum, matrix);
49
- const transformedMax = Vector3.TransformCoordinates(this.maximum, matrix);
50
- this.reConstruct(transformedMin.clone().minimizeInPlace(transformedMax), transformedMax.maximizeInPlace(transformedMin));
51
- return this;
52
- }
53
- get spaceDiagonal() {
54
- if (this.isEmpty) {
55
- return 0;
56
- }
57
- const minimum = this.minimum.asArray();
58
- const maximum = this.maximum.asArray();
59
- return Math.sqrt(minimum.reduce((a, c, i) => a + Math.pow(maximum[i] - c, 2)));
60
- }
61
- get isEmpty() {
62
- return this._isEmpty;
63
- }
64
- }
1
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ export class CfgBoundingBox {
3
+ constructor(minimum, maximum) {
4
+ /**
5
+ * Means that the bounding box should be seen as "undefined", which is not the same as "zero"
6
+ */
7
+ this._isEmpty = true;
8
+ this.minimum = (minimum === null || minimum === void 0 ? void 0 : minimum.clone()) || Vector3.Zero();
9
+ this.maximum = (maximum === null || maximum === void 0 ? void 0 : maximum.clone()) || Vector3.Zero();
10
+ this._isEmpty = minimum === undefined && maximum === undefined;
11
+ }
12
+ reConstruct(minimum, maximum) {
13
+ this.minimum.copyFrom(minimum);
14
+ this.maximum.copyFrom(maximum);
15
+ this._isEmpty = false;
16
+ return this;
17
+ }
18
+ copyFrom(otherBoundingBox) {
19
+ this.reConstruct(otherBoundingBox.minimum, otherBoundingBox.maximum);
20
+ this._isEmpty = otherBoundingBox.isEmpty;
21
+ return this;
22
+ }
23
+ clone() {
24
+ return new CfgBoundingBox(this.minimum, this.maximum);
25
+ }
26
+ get center() {
27
+ return Vector3.Center(this.minimum, this.maximum);
28
+ }
29
+ translate(vec) {
30
+ this.minimum.addInPlace(vec);
31
+ this.maximum.addInPlace(vec);
32
+ return this;
33
+ }
34
+ expand(otherBoundingBox) {
35
+ if (otherBoundingBox.isEmpty) {
36
+ return this;
37
+ }
38
+ if (this.isEmpty) {
39
+ this.reConstruct(otherBoundingBox.minimum, otherBoundingBox.maximum);
40
+ return this;
41
+ }
42
+ this.reConstruct(this.minimum.minimizeInPlace(otherBoundingBox.minimum), this.maximum.maximizeInPlace(otherBoundingBox.maximum));
43
+ return this;
44
+ }
45
+ expandWithPoint(point) {
46
+ if (this.isEmpty) {
47
+ this.reConstruct(point, point);
48
+ return this;
49
+ }
50
+ this.reConstruct(this.minimum.minimizeInPlace(point), this.maximum.maximizeInPlace(point));
51
+ return this;
52
+ }
53
+ applyMatrix(matrix) {
54
+ if (this.isEmpty) {
55
+ return this;
56
+ }
57
+ // Transform can be rotation, in which case we might need to re-minimize/maximize
58
+ const transformedMin = Vector3.TransformCoordinates(this.minimum, matrix);
59
+ const transformedMax = Vector3.TransformCoordinates(this.maximum, matrix);
60
+ this.reConstruct(transformedMin.clone().minimizeInPlace(transformedMax), transformedMax.maximizeInPlace(transformedMin));
61
+ return this;
62
+ }
63
+ get spaceDiagonal() {
64
+ if (this.isEmpty) {
65
+ return 0;
66
+ }
67
+ const minimum = this.minimum.asArray();
68
+ const maximum = this.maximum.asArray();
69
+ return Math.sqrt(minimum.reduce((a, c, i) => a + Math.pow(maximum[i] - c, 2)));
70
+ }
71
+ get isEmpty() {
72
+ return this._isEmpty;
73
+ }
74
+ get corners() {
75
+ const corners = [];
76
+ for (let a = 0; a < 8; a++) {
77
+ corners.push(new Vector3(((a & 1) === 0 ? this.minimum : this.maximum).x, ((a & 2) === 0 ? this.minimum : this.maximum).y, ((a & 4) === 0 ? this.minimum : this.maximum).z));
78
+ }
79
+ return corners;
80
+ }
81
+ }
@@ -0,0 +1,52 @@
1
+ import { Matrix, Vector3 } from "@babylonjs/core";
2
+ import { MeasureParam } from "@configura/web-api";
3
+ import { CfgMeasureDefinition, CfgMeasurePriority } from "@configura/web-api/dist/CfgMeasure";
4
+ import { CfgProductNode } from "../../nodes/CfgProductNode.js";
5
+ import { CfgSymRootNode } from "../../nodes/CfgSymRootNode.js";
6
+ export declare type CfgAnchorTargetNode = CfgSymRootNode;
7
+ export declare type CfgAnchorableNode = CfgSymRootNode | CfgProductNode;
8
+ export declare function nodeEqualsMeasurePriorityNodeReference(node: CfgAnchorTargetNode, ref: CfgMeasurePriority): boolean;
9
+ /**
10
+ * The measureParamCode points to Measures inside Models. A Model can be used multiple times in a Product.
11
+ * More than one Model can use the same measureParamCode. Therefore what Measure an AnchorRef points to
12
+ * can be ambiguous. To help resolve the ambiguities, an anchorRef can have measurePriorities that
13
+ * governs which target it prefers to be anchored to.
14
+ *
15
+ * This method sorts the targets so that the highest priority (lowest index) one is first.
16
+ * Sorting is done in place on the original array.
17
+ */
18
+ export declare const getAnchorTargetPriorityComparer: (measureDefinitions: CfgMeasureDefinition[]) => (measureParamCode: string, l: CfgAnchorTargetNode, r: CfgAnchorTargetNode) => number;
19
+ /**
20
+ * It might be possible in the future to anchor to other things than Measures (which are primarily)
21
+ * used for stretch, but for now we can only support anchoring to the ends of a Measure.
22
+ * toSp means anchor to start point, else end point.
23
+ * The MeasureParam class is used in several different contexts. To make the intent inside Stage
24
+ * clear CfgAnchorRef exists, which including only what is relevant for when used for anchoring.
25
+ */
26
+ export declare class CfgAnchorRef {
27
+ readonly measureParamCode: string;
28
+ readonly toSp: boolean;
29
+ static make(m: MeasureParam | undefined): CfgAnchorRef | undefined;
30
+ private constructor();
31
+ equal(other: CfgAnchorRef): boolean;
32
+ }
33
+ /** Gets the coordinates of the anchor point relative the anchor target. */
34
+ export declare function getRawAnchorPoint(anchorTarget: CfgAnchorTargetNode | undefined, anchorRef: CfgAnchorRef | undefined): Vector3 | undefined;
35
+ /**
36
+ * Calculate a matrix which is the translation that makes a point move as if it was a child of
37
+ * anchorTarget and then moved to the end of the anchorPoint.
38
+ *
39
+ * It is assumed that all anchoring happens on symRoot/additionalProduct-level and therefore all anchorees are
40
+ * siblings to the anchorers.
41
+ *
42
+ * Application of anchoring happens from anchor tree root and out, so that originalMatrix of
43
+ * anchorTarget will already have any anchoring and stretch applied.
44
+ *
45
+ * @param ignoreTargetTransformation If true, ignore anchorTarget's originalMatrix. This is a
46
+ * workaround for that CET (as of this writing) somewhat unexpectedly mostly does not apply the
47
+ * transformation when anchoring Additional Products. We have noticed some cases when it actually
48
+ * apply the transform as you would expect. When the bug is solved this should be removed.
49
+ */
50
+ export declare function getStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgAnchorTargetNode | undefined, ignoreTargetTransformation: boolean): Matrix | undefined;
51
+ export declare function updatedStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgAnchorTargetNode | undefined, currentStretchedAnchorPointMatrix: Matrix | undefined, ignoreTargetTransformation: boolean): Matrix | undefined;
52
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1,136 @@
1
+ import { Matrix, Vector3 } from "@babylonjs/core";
2
+ import { toStretchedPoint } from "../../geometry/stretch/CfgStretchData.js";
3
+ import { identifierIsUri } from "../utilitiesSymRootIdentifier.js";
4
+ /*
5
+ * MeasurePriorityNodeReferences only uses the url of a Model as identifier. Therefore it
6
+ * can not differentiate between the same Model/CfgSymRootNode used multiple time in the same
7
+ * Product. Future development in Catalogues might make this change.
8
+ */
9
+ export function nodeEqualsMeasurePriorityNodeReference(node, ref) {
10
+ const nodeIdentifier = node._identifier;
11
+ // The identifier is made from URL when the node was made from an URL
12
+ if (!identifierIsUri(nodeIdentifier)) {
13
+ return false;
14
+ }
15
+ // The last segment of the URL is the Windows-style formatted relative file path to the model
16
+ const pathFromIdentifier = decodeURIComponent(nodeIdentifier.substr(nodeIdentifier.lastIndexOf("/") + 1));
17
+ return pathFromIdentifier === ref.modelLocalFilePath;
18
+ }
19
+ /**
20
+ * The measureParamCode points to Measures inside Models. A Model can be used multiple times in a Product.
21
+ * More than one Model can use the same measureParamCode. Therefore what Measure an AnchorRef points to
22
+ * can be ambiguous. To help resolve the ambiguities, an anchorRef can have measurePriorities that
23
+ * governs which target it prefers to be anchored to.
24
+ *
25
+ * This method sorts the targets so that the highest priority (lowest index) one is first.
26
+ * Sorting is done in place on the original array.
27
+ */
28
+ export const getAnchorTargetPriorityComparer = (measureDefinitions) => (measureParamCode, l, r) => {
29
+ const measureDefinition = measureDefinitions.find((m) => m.measureParamCode === measureParamCode);
30
+ if (measureDefinition === undefined) {
31
+ return 0;
32
+ }
33
+ const measurePriorities = measureDefinition.measurePriorities;
34
+ const lP = measurePriorities.find((m) => nodeEqualsMeasurePriorityNodeReference(l, m));
35
+ const rP = measurePriorities.find((m) => nodeEqualsMeasurePriorityNodeReference(r, m));
36
+ const lIndex = lP === undefined ? Number.POSITIVE_INFINITY : lP.index;
37
+ const rIndex = rP === undefined ? Number.POSITIVE_INFINITY : rP.index;
38
+ const prioDiff = lIndex - rIndex;
39
+ if (prioDiff !== 0) {
40
+ return prioDiff;
41
+ }
42
+ return l._identifier.localeCompare(r._identifier);
43
+ };
44
+ /**
45
+ * It might be possible in the future to anchor to other things than Measures (which are primarily)
46
+ * used for stretch, but for now we can only support anchoring to the ends of a Measure.
47
+ * toSp means anchor to start point, else end point.
48
+ * The MeasureParam class is used in several different contexts. To make the intent inside Stage
49
+ * clear CfgAnchorRef exists, which including only what is relevant for when used for anchoring.
50
+ */
51
+ export class CfgAnchorRef {
52
+ constructor(measureParamCode, toSp) {
53
+ this.measureParamCode = measureParamCode;
54
+ this.toSp = toSp;
55
+ }
56
+ static make(m) {
57
+ if (m === undefined) {
58
+ return undefined;
59
+ }
60
+ const { anchorPoint, code } = m;
61
+ if (anchorPoint === undefined) {
62
+ console.error("No anchorPoint for measureParam intended to be used as anchorRef");
63
+ return undefined;
64
+ }
65
+ const isSp = anchorPoint === "sp";
66
+ const isEp = anchorPoint === "ep";
67
+ if (!isSp && !isEp) {
68
+ console.error("AnchorPoint is neither sp nor ep");
69
+ return undefined;
70
+ }
71
+ return new CfgAnchorRef(code, isSp);
72
+ }
73
+ equal(other) {
74
+ return this.measureParamCode === other.measureParamCode && this.toSp === other.toSp;
75
+ }
76
+ }
77
+ /** Gets the coordinates of the anchor point relative the anchor target. */
78
+ export function getRawAnchorPoint(anchorTarget, anchorRef) {
79
+ if (anchorTarget === undefined) {
80
+ return undefined;
81
+ }
82
+ if (anchorRef === undefined) {
83
+ throw new Error("AnchorTo not set even though we got an anchorTarget");
84
+ }
85
+ const { measureParamCode, toSp } = anchorRef;
86
+ const { stretchDatas } = anchorTarget;
87
+ const targetStretchData = stretchDatas.find((stretchData) => measureParamCode === stretchData.measureParam);
88
+ if (targetStretchData === undefined) {
89
+ throw new Error("No target stretch data for measureParamCode found");
90
+ }
91
+ return toSp ? targetStretchData.sp : targetStretchData.ep;
92
+ }
93
+ /**
94
+ * Calculate a matrix which is the translation that makes a point move as if it was a child of
95
+ * anchorTarget and then moved to the end of the anchorPoint.
96
+ *
97
+ * It is assumed that all anchoring happens on symRoot/additionalProduct-level and therefore all anchorees are
98
+ * siblings to the anchorers.
99
+ *
100
+ * Application of anchoring happens from anchor tree root and out, so that originalMatrix of
101
+ * anchorTarget will already have any anchoring and stretch applied.
102
+ *
103
+ * @param ignoreTargetTransformation If true, ignore anchorTarget's originalMatrix. This is a
104
+ * workaround for that CET (as of this writing) somewhat unexpectedly mostly does not apply the
105
+ * transformation when anchoring Additional Products. We have noticed some cases when it actually
106
+ * apply the transform as you would expect. When the bug is solved this should be removed.
107
+ */
108
+ export function getStretchedAnchorPointMatrix(anchorRef, anchorTarget, ignoreTargetTransformation) {
109
+ const rawAnchorPoint = getRawAnchorPoint(anchorTarget, anchorRef);
110
+ if (rawAnchorPoint === undefined || anchorTarget === undefined) {
111
+ return undefined;
112
+ }
113
+ // Apply current stretch to the anchor point
114
+ const stretchedAnchorPoint = toStretchedPoint(rawAnchorPoint, anchorTarget.stretchDatas, anchorTarget.cfgProductNode.product.configuration._internal
115
+ .stretchReferenceLengthsByMeasureParamCode);
116
+ // Sometimes, apply the anchorTarget matrix, as if the point was a child to the anchorTarget.
117
+ const anchorTargetMatrixApplied = ignoreTargetTransformation
118
+ ? stretchedAnchorPoint
119
+ : Vector3.TransformCoordinates(stretchedAnchorPoint, anchorTarget.originalMatrix);
120
+ // We use translation as when we anchor things we do not change their orientation,
121
+ // we only move them to snap to this point
122
+ return Matrix.Identity().setTranslation(anchorTargetMatrixApplied);
123
+ }
124
+ export function updatedStretchedAnchorPointMatrix(anchorRef, anchorTarget, currentStretchedAnchorPointMatrix, ignoreTargetTransformation) {
125
+ const stretchedAnchorPointMatrix = getStretchedAnchorPointMatrix(anchorRef, anchorTarget, ignoreTargetTransformation);
126
+ if (currentStretchedAnchorPointMatrix === undefined &&
127
+ stretchedAnchorPointMatrix === undefined) {
128
+ return undefined;
129
+ }
130
+ if (currentStretchedAnchorPointMatrix !== undefined &&
131
+ stretchedAnchorPointMatrix !== undefined &&
132
+ stretchedAnchorPointMatrix.equals(currentStretchedAnchorPointMatrix)) {
133
+ return undefined;
134
+ }
135
+ return stretchedAnchorPointMatrix;
136
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Returns a map from child to parent guaranteed to be loop free.
3
+ * The anchor children (keys in the map) will all have a "anchorRef" and there is what
4
+ * measureParam they are linked on is found.
5
+ * Sorted so that parents are always before their children
6
+ * This function is a bit of a "best effort". These things are not well defined in CET - you
7
+ * can anchor A on B and B on A at the same time for example. You can also anchor B to A
8
+ * while there exists multiple A:s. The code below is a naive implementation as in it will
9
+ * not make the solution which allows the most things to be linked. But that is fine as you
10
+ * should never create a catalogue with strange anchoring anyhow.
11
+ */
12
+ export declare function makeAnchoredToAnchorMap<A extends {
13
+ anchorRef: {
14
+ measureParamCode: string;
15
+ } | undefined;
16
+ }, T extends {
17
+ stretchDatas: {
18
+ measureParam: string;
19
+ }[];
20
+ }>(nodes: (A | T)[], targetCandidateComparer: (measureParamCode: string, l: T, r: T) => number): Map<A, T>;
21
+ //# sourceMappingURL=anchorMap.d.ts.map