@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
@@ -0,0 +1,111 @@
1
+ // Tests do not work if we have Babylon-imports in the same file, so this has to be a separate file
2
+ /**
3
+ * Returns a map from child to parent guaranteed to be loop free.
4
+ * The anchor children (keys in the map) will all have a "anchorRef" and there is what
5
+ * measureParam they are linked on is found.
6
+ * Sorted so that parents are always before their children
7
+ * This function is a bit of a "best effort". These things are not well defined in CET - you
8
+ * can anchor A on B and B on A at the same time for example. You can also anchor B to A
9
+ * while there exists multiple A:s. The code below is a naive implementation as in it will
10
+ * not make the solution which allows the most things to be linked. But that is fine as you
11
+ * should never create a catalogue with strange anchoring anyhow.
12
+ */
13
+ export function makeAnchoredToAnchorMap(nodes, targetCandidateComparer) {
14
+ function isAnchoree(n) {
15
+ return "anchorRef" in n;
16
+ }
17
+ function isTarget(n) {
18
+ return "stretchDatas" in n;
19
+ }
20
+ const anchoredToAnchorMap = new Map();
21
+ // Step 1: build a legal tree
22
+ for (const node of nodes) {
23
+ if (!isAnchoree(node)) {
24
+ continue;
25
+ }
26
+ const anchorRef = node.anchorRef;
27
+ if (anchorRef === undefined) {
28
+ continue;
29
+ }
30
+ const measureParam = anchorRef.measureParamCode;
31
+ const targetCandidates = nodes
32
+ .filter((n) => {
33
+ // Ignore self
34
+ if (node === n) {
35
+ return false;
36
+ }
37
+ if (!isTarget(n)) {
38
+ return false;
39
+ }
40
+ // Can we anchor to this node?
41
+ return n.stretchDatas.some((stretchData) => measureParam === stretchData.measureParam);
42
+ })
43
+ .map((t, i) => ({ t, i }))
44
+ .sort((l, r) => {
45
+ // As sort is not stable in JS-versions older than EcmaScript 2019 we add the
46
+ // array original index to have as a fallback when there is a draw
47
+ const comp = targetCandidateComparer(anchorRef.measureParamCode, l.t, r.t);
48
+ if (comp === 0) {
49
+ return l.i - r.i;
50
+ }
51
+ return comp;
52
+ })
53
+ .map((tt) => tt.t);
54
+ let okay = true;
55
+ for (const otherNode of targetCandidates) {
56
+ okay = true;
57
+ // Loop control, the candidate can not be a child, then we would get a loop
58
+ let loopCandidate = otherNode;
59
+ while (loopCandidate !== undefined) {
60
+ if (!isAnchoree(loopCandidate)) {
61
+ break;
62
+ }
63
+ loopCandidate = anchoredToAnchorMap.get(loopCandidate);
64
+ if (loopCandidate === node) {
65
+ okay = false;
66
+ break;
67
+ }
68
+ }
69
+ if (okay) {
70
+ anchoredToAnchorMap.set(node, otherNode);
71
+ break;
72
+ }
73
+ }
74
+ if (!okay) {
75
+ console.warn("No SymRootNode to anchor to found.");
76
+ }
77
+ }
78
+ // From anchored to anchor
79
+ const unplaced = Array.from(anchoredToAnchorMap);
80
+ // Step 2: Build a sorted map so that parents are before their children
81
+ const result = [];
82
+ while (true) {
83
+ const candidate = unplaced.pop();
84
+ if (candidate === undefined) {
85
+ //done
86
+ break;
87
+ }
88
+ const parent = candidate[1];
89
+ const indexInResult = result.findIndex((otherAnchoredToAnchor) => parent === otherAnchoredToAnchor[0]);
90
+ if (indexInResult === -1) {
91
+ // Candidates parent is not in the result, see if it in those waiting
92
+ const indexInUnplaced = unplaced.findIndex((item) => item[0] === parent);
93
+ if (indexInUnplaced === -1) {
94
+ // The parent was not part of the original nodes, so we just add this node.
95
+ result.push(candidate);
96
+ }
97
+ else {
98
+ const toMoveUp = unplaced.splice(indexInUnplaced, 1)[0];
99
+ // Put back to candidate
100
+ unplaced.push(candidate);
101
+ // Move up the parent
102
+ unplaced.push(toMoveUp);
103
+ }
104
+ }
105
+ else {
106
+ // Parent is in result
107
+ result.splice(indexInResult + 1, 0, candidate);
108
+ }
109
+ }
110
+ return new Map(result);
111
+ }
@@ -1,27 +1,71 @@
1
- import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
- import { Transform as ModelTransform } from "@configura/web-api";
3
- import { ATriMeshF } from "@configura/web-core/dist/cm/core3D/ATriMeshF.js";
4
- import { SymTransform } from "@configura/web-core/dist/cm/format/cmsym/components/SymTransform.js";
5
- import { Point } from "@configura/web-core/dist/cm/geometry/Point.js";
6
- import { Transform as GeoTransform } from "@configura/web-core/dist/cm/geometry/Transform.js";
7
- import { CfgBoundingBox } from "./CfgBoundingBox.js";
8
- export declare function vector3Equals(left: Vector3, right: Vector3): boolean;
9
- declare type Axis = "x" | "y" | "z";
10
- export declare const getBoundingBoxChangeForAxis: (bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, forMax: boolean, axis: Axis) => number;
11
- export declare const boundingBoxChangeIsSignificantForAxis: (bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, forMax: boolean, axis: Axis, acceptableDifferenceShrink: number, acceptableDifferenceGrow: number) => boolean;
12
- export declare function boundingBoxesAreSignificantlyDifferent(bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, acceptableDifferenceShrink: number, acceptableDifferenceGrow: number): boolean;
13
- export declare function unifyBoundingRect(boundingRect: ClientRect | DOMRect): {
14
- x: number;
15
- y: number;
16
- width: number;
17
- height: number;
18
- };
19
- export declare function symTransformToMatrix(symTransform: GeoTransform): Matrix;
20
- export declare function modelTransformsEqual(left: ModelTransform, right: ModelTransform): boolean;
21
- export declare function modelTransformToSymTransform(modelTransform: ModelTransform): SymTransform;
22
- export declare function cloneName(name: string): string;
23
- export declare function measureLongestDistanceToCorner(bb: CfgBoundingBox, measureComponents: number[]): number;
24
- export declare function aTriMeshSphere(radius?: number, center?: Point, segments?: number): ATriMeshF;
25
- export declare function aTriMeshBox(p0?: Point, p1?: Point): ATriMeshF;
26
- export {};
1
+ import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ import { Transform as ModelTransform } from "@configura/web-api";
3
+ import { ATriMeshF } from "@configura/web-core/dist/cm/core3D/ATriMeshF.js";
4
+ import { SymTransform } from "@configura/web-core/dist/cm/format/cmsym/components/SymTransform.js";
5
+ import { Point } from "@configura/web-core/dist/cm/geometry/Point.js";
6
+ import { Transform as GeoTransform } from "@configura/web-core/dist/cm/geometry/Transform.js";
7
+ import { CfgBoundingBox } from "./CfgBoundingBox.js";
8
+ export declare function vector3Equals(left: Vector3, right: Vector3): boolean;
9
+ export declare function cmPointToVector3(point: Point): Vector3;
10
+ declare type Axis = "x" | "y" | "z";
11
+ /**
12
+ * Calculates the change in one component for min or max when moving from one bounding box to
13
+ * another. Negative result is shrink, positive is grow. forMax is accounted for.
14
+ */
15
+ export declare const getBoundingBoxChangeForAxis: (bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, forMax: boolean, axis: Axis) => number;
16
+ /**
17
+ * Given an old bounding box and a new tells if the size difference in one component is significant.
18
+ */
19
+ export declare const boundingBoxChangeIsSignificantForAxis: (bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, forMax: boolean, axis: Axis, acceptableDifferenceShrink: number, acceptableDifferenceGrow: number) => boolean;
20
+ /**
21
+ * Returns true if either:
22
+ * - One bounding box was empty and the other not.
23
+ * - There is a size change in any of the six primary directions which is larger than
24
+ * acceptableDifferenceShrink or acceptableDifferenceGrow depending if the change from bbOld to
25
+ * bbNew in that direction is shrink or grow.
26
+ */
27
+ export declare function boundingBoxesAreSignificantlyDifferent(bbOld: CfgBoundingBox, bbNew: CfgBoundingBox, acceptableDifferenceShrink: number, acceptableDifferenceGrow: number): boolean;
28
+ export declare function unifyBoundingRect(boundingRect: ClientRect | DOMRect): {
29
+ x: number;
30
+ y: number;
31
+ width: number;
32
+ height: number;
33
+ };
34
+ export declare function symTransformToMatrix(symTransform: GeoTransform): Matrix;
35
+ export declare function modelTransformsEqual(left: ModelTransform, right: ModelTransform): boolean;
36
+ export declare function modelTransformToSymTransform(modelTransform: ModelTransform): SymTransform;
37
+ export declare function cloneName(name: string): string;
38
+ export declare function measureLongestDistanceToCorner(bb: CfgBoundingBox, measureComponents: number[]): number;
39
+ /**
40
+ * Creates an ATriMeshF instance containing a mesh of a sphere of the given radius (default 1)
41
+ * centered on the given position (default <0,0,0>). The "resolution" of the mesh is set by the
42
+ * segments value (default 32).
43
+ *
44
+ * UV coordinates are generated by wrapping the texture around the sphere like a world map.
45
+ */
46
+ export declare function aTriMeshSphere(radius?: number, center?: Point, segments?: number): ATriMeshF;
47
+ /**
48
+ * Creates an ATriMeshF instance containing a mesh of a box between the two points.
49
+ * Default value of p0 is <0,0,0> and p1 is <1,1,1>.
50
+ *
51
+ * UV coordinates are generated, repeating the texture on each side.
52
+ */
53
+ export declare function aTriMeshBox(p0?: Point, p1?: Point): ATriMeshF;
54
+ /**
55
+ * Creates an ATriMeshF instance containing a mesh representing an infinite plane with the given
56
+ * normal, offset by the given distance along the normal.
57
+ *
58
+ * Due to automatic bounding box calculations, the infinite plane is represented by a circular disc
59
+ * with the given radius centered on a point offset from the origin along the normal vector.
60
+ *
61
+ * The number of triangles in the disc is controlled by the refine parameter. The minimum number of
62
+ * triangles is 4, each refine step doubles the triangle count.
63
+ *
64
+ * Default normal: 1, 0, 0
65
+ * Default offset: 0
66
+ * Default radius: 1
67
+ * Default refinement: 4 (64 triangles)
68
+ */
69
+ export declare function aTriMeshPlane(normal?: Point, offset?: number, radius?: number, refine?: number): ATriMeshF;
70
+ export {};
27
71
  //# sourceMappingURL=utilities3D.d.ts.map