@configura/babylon-view 1.4.0 → 1.6.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.
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 -26
  42. package/dist/camera/CfgArcRotateCameraPointersInput.js +264 -264
  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 -29
  52. package/dist/geometry/CfgGeometry.js +146 -146
  53. package/dist/geometry/CfgMesh.d.ts +10 -10
  54. package/dist/geometry/CfgMesh.js +38 -38
  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 +15 -15
  58. package/dist/geometry/stretch/CfgMorphTarget.js +65 -65
  59. package/dist/geometry/stretch/CfgStretchData.d.ts +116 -114
  60. package/dist/geometry/stretch/CfgStretchData.js +346 -340
  61. package/dist/geometry/stretch/CfgStretchMorphGeometry.d.ts +16 -16
  62. package/dist/geometry/stretch/CfgStretchMorphGeometry.js +95 -95
  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 -68
  76. package/dist/material/CfgMaterial.js +482 -482
  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 -306
  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 -55
  86. package/dist/nodes/CfgDeferredMeshNode.js +377 -377
  87. package/dist/nodes/CfgProductNode.d.ts +126 -126
  88. package/dist/nodes/CfgProductNode.js +579 -578
  89. package/dist/nodes/CfgSymNode.d.ts +50 -50
  90. package/dist/nodes/CfgSymNode.js +249 -249
  91. package/dist/nodes/CfgSymRootNode.d.ts +45 -45
  92. package/dist/nodes/CfgSymRootNode.js +220 -220
  93. package/dist/nodes/CfgTransformNode.d.ts +33 -33
  94. package/dist/nodes/CfgTransformNode.js +83 -83
  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 -21
  98. package/dist/utilities/CfgBoundingBox.js +81 -81
  99. package/dist/utilities/anchor/anchor.d.ts +55 -51
  100. package/dist/utilities/anchor/anchor.js +140 -136
  101. package/dist/utilities/anchor/anchorMap.d.ts +20 -20
  102. package/dist/utilities/anchor/anchorMap.js +111 -111
  103. package/dist/utilities/utilities3D.d.ts +70 -70
  104. package/dist/utilities/utilities3D.js +265 -265
  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 -7
  110. package/dist/utilities/utilitiesSymRootIdentifier.js +26 -26
  111. package/dist/view/BaseView.d.ts +78 -78
  112. package/dist/view/BaseView.js +297 -297
  113. package/dist/view/BaseViewConfiguration.d.ts +32 -32
  114. package/dist/view/BaseViewConfiguration.js +10 -8
  115. package/dist/view/RenderEnv.d.ts +43 -43
  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 +42 -42
  122. package/dist/view/SingleProductView.js +206 -206
  123. package/dist/view/SingleProductViewConfiguration.d.ts +32 -32
  124. package/dist/view/SingleProductViewConfiguration.js +19 -19
  125. package/package.json +5 -5
@@ -1,83 +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
- /**
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
+ 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,22 +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
- /**
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
- }
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
+ }
22
22
  //# sourceMappingURL=CfgBoundingBox.d.ts.map
@@ -1,81 +1,81 @@
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
- }
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
+ }
@@ -1,52 +1,56 @@
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;
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 stretchSymNodeId: string;
28
+ readonly toSp: boolean;
29
+ static make(m: MeasureParam | undefined): CfgAnchorRef | undefined;
30
+ /**
31
+ * The name stretchSymNodeId might seem confusing. And it is. Turns out CET is implemented so
32
+ * that it bases its anchoring on symNode Id containing the stretch. Not the measureParamId.
33
+ */
34
+ private constructor();
35
+ equal(other: CfgAnchorRef): boolean;
36
+ }
37
+ /** Gets the coordinates of the anchor point relative the anchor target. */
38
+ export declare function getRawAnchorPoint(anchorTarget: CfgAnchorTargetNode | undefined, anchorRef: CfgAnchorRef | undefined): Vector3 | undefined;
39
+ /**
40
+ * Calculate a matrix which is the translation that makes a point move as if it was a child of
41
+ * anchorTarget and then moved to the end of the anchorPoint.
42
+ *
43
+ * It is assumed that all anchoring happens on symRoot/additionalProduct-level and therefore all anchorees are
44
+ * siblings to the anchorers.
45
+ *
46
+ * Application of anchoring happens from anchor tree root and out, so that originalMatrix of
47
+ * anchorTarget will already have any anchoring and stretch applied.
48
+ *
49
+ * @param ignoreTargetTransformation If true, ignore anchorTarget's originalMatrix. This is a
50
+ * workaround for that CET (as of this writing) somewhat unexpectedly mostly does not apply the
51
+ * transformation when anchoring Additional Products. We have noticed some cases when it actually
52
+ * apply the transform as you would expect. When the bug is solved this should be removed.
53
+ */
54
+ export declare function getStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgAnchorTargetNode | undefined, ignoreTargetTransformation: boolean): Matrix | undefined;
55
+ export declare function updatedStretchedAnchorPointMatrix(anchorRef: CfgAnchorRef | undefined, anchorTarget: CfgAnchorTargetNode | undefined, currentStretchedAnchorPointMatrix: Matrix | undefined, ignoreTargetTransformation: boolean): Matrix | undefined;
52
56
  //# sourceMappingURL=anchor.d.ts.map