@babylonjs/core 6.28.0 → 6.29.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 (123) hide show
  1. package/Animations/animatable.js +1 -1
  2. package/Animations/animatable.js.map +1 -1
  3. package/Animations/animation.js +1 -1
  4. package/Animations/animation.js.map +1 -1
  5. package/Animations/animationKey.d.ts +5 -0
  6. package/Animations/animationKey.js.map +1 -1
  7. package/Behaviors/Meshes/fadeInOutBehavior.js +2 -1
  8. package/Behaviors/Meshes/fadeInOutBehavior.js.map +1 -1
  9. package/Cameras/arcRotateCamera.js +37 -13
  10. package/Cameras/arcRotateCamera.js.map +1 -1
  11. package/Cameras/camera.d.ts +21 -0
  12. package/Cameras/camera.js +35 -0
  13. package/Cameras/camera.js.map +1 -1
  14. package/Cameras/targetCamera.js +51 -30
  15. package/Cameras/targetCamera.js.map +1 -1
  16. package/Debug/debugLayer.d.ts +4 -0
  17. package/Debug/debugLayer.js +12 -1
  18. package/Debug/debugLayer.js.map +1 -1
  19. package/Engines/constants.d.ts +2 -0
  20. package/Engines/constants.js +2 -0
  21. package/Engines/constants.js.map +1 -1
  22. package/Engines/thinEngine.js +2 -2
  23. package/Engines/thinEngine.js.map +1 -1
  24. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +2 -2
  25. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  26. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +1 -1
  27. package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
  28. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +21 -9
  29. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +7 -8
  30. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  31. package/FlowGraph/flowGraph.d.ts +2 -8
  32. package/FlowGraph/flowGraph.js +2 -9
  33. package/FlowGraph/flowGraph.js.map +1 -1
  34. package/FlowGraph/flowGraphBlock.d.ts +1 -0
  35. package/FlowGraph/flowGraphBlock.js +3 -0
  36. package/FlowGraph/flowGraphBlock.js.map +1 -1
  37. package/FlowGraph/flowGraphContext.d.ts +20 -2
  38. package/FlowGraph/flowGraphContext.js +37 -33
  39. package/FlowGraph/flowGraphContext.js.map +1 -1
  40. package/FlowGraph/flowGraphContextLogger.d.ts +9 -0
  41. package/FlowGraph/flowGraphContextLogger.js +14 -0
  42. package/FlowGraph/flowGraphContextLogger.js.map +1 -0
  43. package/FlowGraph/flowGraphCoordinator.d.ts +14 -5
  44. package/FlowGraph/flowGraphCoordinator.js +27 -3
  45. package/FlowGraph/flowGraphCoordinator.js.map +1 -1
  46. package/FlowGraph/flowGraphDataConnection.js +1 -0
  47. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  48. package/FlowGraph/flowGraphEventBlock.js +1 -0
  49. package/FlowGraph/flowGraphEventBlock.js.map +1 -1
  50. package/FlowGraph/flowGraphSignalConnection.js +1 -0
  51. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  52. package/FlowGraph/index.d.ts +1 -1
  53. package/FlowGraph/index.js +1 -1
  54. package/FlowGraph/index.js.map +1 -1
  55. package/FlowGraph/serialization.d.ts +16 -0
  56. package/FlowGraph/serialization.js +79 -0
  57. package/FlowGraph/serialization.js.map +1 -0
  58. package/Materials/Textures/baseTexture.d.ts +2 -1
  59. package/Materials/Textures/baseTexture.js +12 -1
  60. package/Materials/Textures/baseTexture.js.map +1 -1
  61. package/Materials/Textures/renderTargetTexture.d.ts +2 -0
  62. package/Materials/Textures/renderTargetTexture.js +5 -2
  63. package/Materials/Textures/renderTargetTexture.js.map +1 -1
  64. package/Materials/Textures/texture.d.ts +2 -0
  65. package/Materials/Textures/texture.js +8 -3
  66. package/Materials/Textures/texture.js.map +1 -1
  67. package/Materials/materialPluginManager.js +1 -1
  68. package/Materials/materialPluginManager.js.map +1 -1
  69. package/Maths/math.vector.js +41 -26
  70. package/Maths/math.vector.js.map +1 -1
  71. package/Meshes/Builders/textBuilder.js +0 -1
  72. package/Meshes/Builders/textBuilder.js.map +1 -1
  73. package/Meshes/GreasedLine/greasedLineMesh.js +1 -1
  74. package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
  75. package/Meshes/GreasedLine/greasedLineRibbonMesh.js +2 -2
  76. package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
  77. package/Meshes/Node/Blocks/Sources/boxBlock.js +2 -1
  78. package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
  79. package/Meshes/Node/Blocks/Sources/capsuleBlock.js +2 -1
  80. package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
  81. package/Meshes/Node/Blocks/Sources/cylinderBlock.js +2 -1
  82. package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
  83. package/Meshes/Node/Blocks/Sources/discBlock.js +2 -1
  84. package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
  85. package/Meshes/Node/Blocks/Sources/gridBlock.js +2 -1
  86. package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
  87. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js +2 -1
  88. package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
  89. package/Meshes/Node/Blocks/Sources/planeBlock.js +2 -1
  90. package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
  91. package/Meshes/Node/Blocks/Sources/sphereBlock.js +2 -1
  92. package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
  93. package/Meshes/Node/Blocks/Sources/torusBlock.js +2 -1
  94. package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
  95. package/Meshes/abstractMesh.js +13 -9
  96. package/Meshes/abstractMesh.js.map +1 -1
  97. package/Meshes/csg.d.ts +8 -8
  98. package/Meshes/csg.js +12 -12
  99. package/Meshes/csg.js.map +1 -1
  100. package/Misc/deepCopier.d.ts +3 -1
  101. package/Misc/deepCopier.js +7 -5
  102. package/Misc/deepCopier.js.map +1 -1
  103. package/Misc/observable.d.ts +6 -2
  104. package/Misc/observable.js +0 -14
  105. package/Misc/observable.js.map +1 -1
  106. package/Misc/precisionDate.js +2 -4
  107. package/Misc/precisionDate.js.map +1 -1
  108. package/Rendering/renderingManager.d.ts +4 -0
  109. package/Rendering/renderingManager.js +18 -13
  110. package/Rendering/renderingManager.js.map +1 -1
  111. package/package.json +1 -1
  112. package/scene.d.ts +6 -0
  113. package/scene.js +11 -1
  114. package/scene.js.map +1 -1
  115. package/FlowGraph/flowGraphCustomEvent.d.ts +0 -5
  116. package/FlowGraph/flowGraphCustomEvent.js +0 -2
  117. package/FlowGraph/flowGraphCustomEvent.js.map +0 -1
  118. package/FlowGraph/flowGraphEventCoordinator.d.ts +0 -23
  119. package/FlowGraph/flowGraphEventCoordinator.js +0 -37
  120. package/FlowGraph/flowGraphEventCoordinator.js.map +0 -1
  121. package/FlowGraph/flowGraphVariableDefinitions.d.ts +0 -32
  122. package/FlowGraph/flowGraphVariableDefinitions.js +0 -51
  123. package/FlowGraph/flowGraphVariableDefinitions.js.map +0 -1
package/Meshes/csg.d.ts CHANGED
@@ -78,7 +78,7 @@ declare class Vertex {
78
78
  /**
79
79
  * Represents a plane in 3D space.
80
80
  */
81
- declare class Plane {
81
+ declare class CSGPlane {
82
82
  normal: Vector3;
83
83
  w: number;
84
84
  /**
@@ -98,12 +98,12 @@ declare class Plane {
98
98
  * @param b Point b
99
99
  * @param c Point c
100
100
  */
101
- static FromPoints(a: Vector3, b: Vector3, c: Vector3): Nullable<Plane>;
101
+ static FromPoints(a: Vector3, b: Vector3, c: Vector3): Nullable<CSGPlane>;
102
102
  /**
103
103
  * Clone, or make a deep copy of the plane
104
104
  * @returns a new Plane
105
105
  */
106
- clone(): Plane;
106
+ clone(): CSGPlane;
107
107
  /**
108
108
  * Flip the face of the plane
109
109
  */
@@ -120,7 +120,7 @@ declare class Plane {
120
120
  * @param front Will contain the polygons in front of the plane
121
121
  * @param back Will contain the polygons begind the plane
122
122
  */
123
- splitPolygon(polygon: Polygon, coplanarFront: Polygon[], coplanarBack: Polygon[], front: Polygon[], back: Polygon[]): void;
123
+ splitPolygon(polygon: CSGPolygon, coplanarFront: CSGPolygon[], coplanarBack: CSGPolygon[], front: CSGPolygon[], back: CSGPolygon[]): void;
124
124
  }
125
125
  /**
126
126
  * Represents a convex polygon. The vertices used to initialize a polygon must
@@ -130,7 +130,7 @@ declare class Plane {
130
130
  * polygons that are clones of each other or were split from the same polygon.
131
131
  * This can be used to define per-polygon properties (such as surface color)
132
132
  */
133
- declare class Polygon {
133
+ declare class CSGPolygon {
134
134
  /**
135
135
  * Vertices of the polygon
136
136
  */
@@ -142,7 +142,7 @@ declare class Polygon {
142
142
  /**
143
143
  * A plane formed from the vertices of the polygon
144
144
  */
145
- plane: Plane;
145
+ plane: CSGPlane;
146
146
  /**
147
147
  * Initializes the polygon
148
148
  * @param vertices The vertices of the polygon
@@ -152,7 +152,7 @@ declare class Polygon {
152
152
  /**
153
153
  * Clones, or makes a deep copy, or the polygon
154
154
  */
155
- clone(): Polygon;
155
+ clone(): CSGPolygon;
156
156
  /**
157
157
  * Flips the faces of the polygon
158
158
  */
@@ -262,7 +262,7 @@ export declare class CSG {
262
262
  * Coordinates here are in world space
263
263
  * @returns the final vertex data
264
264
  */
265
- toVertexData(onBeforePolygonProcessing?: Nullable<(polygon: Polygon) => void>, onAfterPolygonProcessing?: Nullable<() => void>): VertexData;
265
+ toVertexData(onBeforePolygonProcessing?: Nullable<(polygon: CSGPolygon) => void>, onAfterPolygonProcessing?: Nullable<() => void>): VertexData;
266
266
  /**
267
267
  * Build Raw mesh from CSG
268
268
  * Coordinates here are in world space
package/Meshes/csg.js CHANGED
@@ -78,7 +78,7 @@ class Vertex {
78
78
  /**
79
79
  * Represents a plane in 3D space.
80
80
  */
81
- class Plane {
81
+ class CSGPlane {
82
82
  /**
83
83
  * Initializes the plane
84
84
  * @param normal The normal for the plane
@@ -101,14 +101,14 @@ class Plane {
101
101
  return null;
102
102
  }
103
103
  const n = Vector3.Normalize(Vector3.Cross(v0, v1));
104
- return new Plane(n, Vector3.Dot(n, a));
104
+ return new CSGPlane(n, Vector3.Dot(n, a));
105
105
  }
106
106
  /**
107
107
  * Clone, or make a deep copy of the plane
108
108
  * @returns a new Plane
109
109
  */
110
110
  clone() {
111
- return new Plane(this.normal.clone(), this.w);
111
+ return new CSGPlane(this.normal.clone(), this.w);
112
112
  }
113
113
  /**
114
114
  * Flip the face of the plane
@@ -142,7 +142,7 @@ class Plane {
142
142
  let t;
143
143
  for (i = 0; i < polygon.vertices.length; i++) {
144
144
  t = Vector3.Dot(this.normal, polygon.vertices[i].pos) - this.w;
145
- const type = t < -Plane.EPSILON ? BACK : t > Plane.EPSILON ? FRONT : COPLANAR;
145
+ const type = t < -CSGPlane.EPSILON ? BACK : t > CSGPlane.EPSILON ? FRONT : COPLANAR;
146
146
  polygonType |= type;
147
147
  types.push(type);
148
148
  }
@@ -178,13 +178,13 @@ class Plane {
178
178
  }
179
179
  let poly;
180
180
  if (f.length >= 3) {
181
- poly = new Polygon(f, polygon.shared);
181
+ poly = new CSGPolygon(f, polygon.shared);
182
182
  if (poly.plane) {
183
183
  front.push(poly);
184
184
  }
185
185
  }
186
186
  if (b.length >= 3) {
187
- poly = new Polygon(b, polygon.shared);
187
+ poly = new CSGPolygon(b, polygon.shared);
188
188
  if (poly.plane) {
189
189
  back.push(poly);
190
190
  }
@@ -198,7 +198,7 @@ class Plane {
198
198
  * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
199
199
  * point is on the plane
200
200
  */
201
- Plane.EPSILON = 1e-5;
201
+ CSGPlane.EPSILON = 1e-5;
202
202
  /**
203
203
  * Represents a convex polygon. The vertices used to initialize a polygon must
204
204
  * be coplanar and form a convex loop.
@@ -207,7 +207,7 @@ Plane.EPSILON = 1e-5;
207
207
  * polygons that are clones of each other or were split from the same polygon.
208
208
  * This can be used to define per-polygon properties (such as surface color)
209
209
  */
210
- class Polygon {
210
+ class CSGPolygon {
211
211
  /**
212
212
  * Initializes the polygon
213
213
  * @param vertices The vertices of the polygon
@@ -216,14 +216,14 @@ class Polygon {
216
216
  constructor(vertices, shared) {
217
217
  this.vertices = vertices;
218
218
  this.shared = shared;
219
- this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
219
+ this.plane = CSGPlane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
220
220
  }
221
221
  /**
222
222
  * Clones, or makes a deep copy, or the polygon
223
223
  */
224
224
  clone() {
225
225
  const vertices = this.vertices.map((v) => v.clone());
226
- return new Polygon(vertices, this.shared);
226
+ return new CSGPolygon(vertices, this.shared);
227
227
  }
228
228
  /**
229
229
  * Flips the faces of the polygon
@@ -408,7 +408,7 @@ export class CSG {
408
408
  vertex = new Vertex(position, normal, uv, vertColor);
409
409
  vertices.push(vertex);
410
410
  }
411
- polygon = new Polygon(vertices, { subMeshId: 0, meshId: currentCSGMeshId, materialIndex: 0 });
411
+ polygon = new CSGPolygon(vertices, { subMeshId: 0, meshId: currentCSGMeshId, materialIndex: 0 });
412
412
  // To handle the case of degenerated triangle
413
413
  // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
414
414
  if (polygon.plane) {
@@ -471,7 +471,7 @@ export class CSG {
471
471
  vertex = new Vertex(position, normal, uv, vertColor);
472
472
  vertices.push(vertex);
473
473
  }
474
- polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
474
+ polygon = new CSGPolygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
475
475
  // To handle the case of degenerated triangle
476
476
  // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
477
477
  if (polygon.plane) {
package/Meshes/csg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,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,KAAa,EAAE,aAAuB;QACnG,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QAEhE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;SAC7D;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Quaternion, Matrix, Vector3, Vector2 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { SubMesh } from \"../Meshes/subMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\n/**\r\n * Unique ID when we import meshes from Babylon to CSG\r\n */\r\nlet currentCSGMeshId = 0;\r\n\r\n/**\r\n * Represents a vertex of a polygon. Use your own vertex class instead of this\r\n * one to provide additional features like texture coordinates and vertex\r\n * colors. Custom vertex classes need to provide a `pos` property and `clone()`,\r\n * `flip()`, and `interpolate()` methods that behave analogous to the ones\r\n * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience\r\n * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`\r\n * is not used anywhere else.\r\n * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes\r\n */\r\nclass Vertex {\r\n /**\r\n * Initializes the vertex\r\n * @param pos The position of the vertex\r\n * @param normal The normal of the vertex\r\n * @param uv The texture coordinate of the vertex\r\n * @param vertColor The RGBA color of the vertex\r\n */\r\n constructor(\r\n /**\r\n * The position of the vertex\r\n */\r\n public pos: Vector3,\r\n /**\r\n * The normal of the vertex\r\n */\r\n public normal: Vector3,\r\n /**\r\n * The texture coordinate of the vertex\r\n */\r\n public uv?: Vector2,\r\n /**\r\n * The texture coordinate of the vertex\r\n */\r\n public vertColor?: Color4\r\n ) {}\r\n\r\n /**\r\n * Make a clone, or deep copy, of the vertex\r\n * @returns A new Vertex\r\n */\r\n public clone(): Vertex {\r\n return new Vertex(this.pos.clone(), this.normal.clone(), this.uv?.clone(), this.vertColor?.clone());\r\n }\r\n\r\n /**\r\n * Invert all orientation-specific data (e.g. vertex normal). Called when the\r\n * orientation of a polygon is flipped.\r\n */\r\n public flip(): void {\r\n this.normal = this.normal.scale(-1);\r\n }\r\n\r\n /**\r\n * Create a new vertex between this vertex and `other` by linearly\r\n * interpolating all properties using a parameter of `t`. Subclasses should\r\n * override this to interpolate additional properties.\r\n * @param other the vertex to interpolate against\r\n * @param t The factor used to linearly interpolate between the vertices\r\n */\r\n public interpolate(other: Vertex, t: number): Vertex {\r\n return new Vertex(\r\n Vector3.Lerp(this.pos, other.pos, t),\r\n Vector3.Lerp(this.normal, other.normal, t),\r\n this.uv && other.uv ? Vector2.Lerp(this.uv, other.uv, t) : undefined,\r\n this.vertColor && other.vertColor ? Color4.Lerp(this.vertColor, other.vertColor, t) : undefined\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Represents a plane in 3D space.\r\n */\r\nclass Plane {\r\n /**\r\n * Initializes the plane\r\n * @param normal The normal for the plane\r\n * @param w\r\n */\r\n constructor(\r\n public normal: Vector3,\r\n public w: number\r\n ) {}\r\n\r\n /**\r\n * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a\r\n * point is on the plane\r\n */\r\n static EPSILON = 1e-5;\r\n\r\n /**\r\n * Construct a plane from three points\r\n * @param a Point a\r\n * @param b Point b\r\n * @param c Point c\r\n */\r\n public static FromPoints(a: Vector3, b: Vector3, c: Vector3): Nullable<Plane> {\r\n const v0 = c.subtract(a);\r\n const v1 = b.subtract(a);\r\n\r\n if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {\r\n return null;\r\n }\r\n\r\n const n = Vector3.Normalize(Vector3.Cross(v0, v1));\r\n return new Plane(n, Vector3.Dot(n, a));\r\n }\r\n\r\n /**\r\n * Clone, or make a deep copy of the plane\r\n * @returns a new Plane\r\n */\r\n public clone(): Plane {\r\n return new Plane(this.normal.clone(), this.w);\r\n }\r\n\r\n /**\r\n * Flip the face of the plane\r\n */\r\n public flip() {\r\n this.normal.scaleInPlace(-1);\r\n this.w = -this.w;\r\n }\r\n\r\n /**\r\n * Split `polygon` by this plane if needed, then put the polygon or polygon\r\n * fragments in the appropriate lists. Coplanar polygons go into either\r\n `* coplanarFront` or `coplanarBack` depending on their orientation with\r\n * respect to this plane. Polygons in front or in back of this plane go into\r\n * either `front` or `back`\r\n * @param polygon The polygon to be split\r\n * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane\r\n * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane\r\n * @param front Will contain the polygons in front of the plane\r\n * @param back Will contain the polygons begind the plane\r\n */\r\n public splitPolygon(polygon: Polygon, coplanarFront: Polygon[], coplanarBack: Polygon[], front: Polygon[], back: Polygon[]): void {\r\n const COPLANAR = 0;\r\n const FRONT = 1;\r\n const BACK = 2;\r\n const SPANNING = 3;\r\n\r\n // Classify each point as well as the entire polygon into one of the above\r\n // four classes.\r\n let polygonType = 0;\r\n const types = [];\r\n let i: number;\r\n let t: number;\r\n for (i = 0; i < polygon.vertices.length; i++) {\r\n t = Vector3.Dot(this.normal, polygon.vertices[i].pos) - this.w;\r\n const type = t < -Plane.EPSILON ? BACK : t > Plane.EPSILON ? FRONT : COPLANAR;\r\n polygonType |= type;\r\n types.push(type);\r\n }\r\n\r\n // Put the polygon in the correct list, splitting it when necessary\r\n switch (polygonType) {\r\n case COPLANAR:\r\n (Vector3.Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);\r\n break;\r\n case FRONT:\r\n front.push(polygon);\r\n break;\r\n case BACK:\r\n back.push(polygon);\r\n break;\r\n case SPANNING: {\r\n const f = [],\r\n b = [];\r\n for (i = 0; i < polygon.vertices.length; i++) {\r\n const j = (i + 1) % polygon.vertices.length;\r\n const ti = types[i],\r\n tj = types[j];\r\n const vi = polygon.vertices[i],\r\n vj = polygon.vertices[j];\r\n if (ti !== BACK) {\r\n f.push(vi);\r\n }\r\n if (ti !== FRONT) {\r\n b.push(ti !== BACK ? vi.clone() : vi);\r\n }\r\n if ((ti | tj) === SPANNING) {\r\n t = (this.w - Vector3.Dot(this.normal, vi.pos)) / Vector3.Dot(this.normal, vj.pos.subtract(vi.pos));\r\n const v = vi.interpolate(vj, t);\r\n f.push(v);\r\n b.push(v.clone());\r\n }\r\n }\r\n let poly: Polygon;\r\n if (f.length >= 3) {\r\n poly = new Polygon(f, polygon.shared);\r\n if (poly.plane) {\r\n front.push(poly);\r\n }\r\n }\r\n\r\n if (b.length >= 3) {\r\n poly = new Polygon(b, polygon.shared);\r\n\r\n if (poly.plane) {\r\n back.push(poly);\r\n }\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Represents a convex polygon. The vertices used to initialize a polygon must\r\n * be coplanar and form a convex loop.\r\n *\r\n * Each convex polygon has a `shared` property, which is shared between all\r\n * polygons that are clones of each other or were split from the same polygon.\r\n * This can be used to define per-polygon properties (such as surface color)\r\n */\r\nclass Polygon {\r\n /**\r\n * Vertices of the polygon\r\n */\r\n public vertices: Vertex[];\r\n /**\r\n * Properties that are shared across all polygons\r\n */\r\n public shared: any;\r\n /**\r\n * A plane formed from the vertices of the polygon\r\n */\r\n public plane: Plane;\r\n\r\n /**\r\n * Initializes the polygon\r\n * @param vertices The vertices of the polygon\r\n * @param shared The properties shared across all polygons\r\n */\r\n constructor(vertices: Vertex[], shared: any) {\r\n this.vertices = vertices;\r\n this.shared = shared;\r\n this.plane = <Plane>Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, or the polygon\r\n */\r\n public clone(): Polygon {\r\n const vertices = this.vertices.map((v) => v.clone());\r\n return new Polygon(vertices, this.shared);\r\n }\r\n\r\n /**\r\n * Flips the faces of the polygon\r\n */\r\n public flip() {\r\n this.vertices.reverse().map((v) => {\r\n v.flip();\r\n });\r\n this.plane.flip();\r\n }\r\n}\r\n\r\n/**\r\n * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons\r\n * by picking a polygon to split along. That polygon (and all other coplanar\r\n * polygons) are added directly to that node and the other polygons are added to\r\n * the front and/or back subtrees. This is not a leafy BSP tree since there is\r\n * no distinction between internal and leaf nodes\r\n */\r\nclass Node {\r\n private _plane: Nullable<Plane> = null;\r\n private _front: Nullable<Node> = null;\r\n private _back: Nullable<Node> = null;\r\n private _polygons = new Array<Polygon>();\r\n\r\n /**\r\n * Initializes the node\r\n * @param polygons A collection of polygons held in the node\r\n */\r\n constructor(polygons?: Array<Polygon>) {\r\n if (polygons) {\r\n this.build(polygons);\r\n }\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, of the node\r\n * @returns The cloned node\r\n */\r\n public clone(): Node {\r\n const node = new Node();\r\n node._plane = this._plane && this._plane.clone();\r\n node._front = this._front && this._front.clone();\r\n node._back = this._back && this._back.clone();\r\n node._polygons = this._polygons.map((p) => p.clone());\r\n return node;\r\n }\r\n\r\n /**\r\n * Convert solid space to empty space and empty space to solid space\r\n */\r\n public invert(): void {\r\n for (let i = 0; i < this._polygons.length; i++) {\r\n this._polygons[i].flip();\r\n }\r\n if (this._plane) {\r\n this._plane.flip();\r\n }\r\n if (this._front) {\r\n this._front.invert();\r\n }\r\n if (this._back) {\r\n this._back.invert();\r\n }\r\n const temp = this._front;\r\n this._front = this._back;\r\n this._back = temp;\r\n }\r\n\r\n /**\r\n * Recursively remove all polygons in `polygons` that are inside this BSP\r\n * tree.\r\n * @param polygons Polygons to remove from the BSP\r\n * @returns Polygons clipped from the BSP\r\n */\r\n clipPolygons(polygons: Polygon[]): Polygon[] {\r\n if (!this._plane) {\r\n return polygons.slice();\r\n }\r\n let front = new Array<Polygon>(),\r\n back = new Array<Polygon>();\r\n for (let i = 0; i < polygons.length; i++) {\r\n this._plane.splitPolygon(polygons[i], front, back, front, back);\r\n }\r\n if (this._front) {\r\n front = this._front.clipPolygons(front);\r\n }\r\n if (this._back) {\r\n back = this._back.clipPolygons(back);\r\n } else {\r\n back = [];\r\n }\r\n return front.concat(back);\r\n }\r\n\r\n /**\r\n * Remove all polygons in this BSP tree that are inside the other BSP tree\r\n * `bsp`.\r\n * @param bsp BSP containing polygons to remove from this BSP\r\n */\r\n clipTo(bsp: Node): void {\r\n this._polygons = bsp.clipPolygons(this._polygons);\r\n if (this._front) {\r\n this._front.clipTo(bsp);\r\n }\r\n if (this._back) {\r\n this._back.clipTo(bsp);\r\n }\r\n }\r\n\r\n /**\r\n * Return a list of all polygons in this BSP tree\r\n * @returns List of all polygons in this BSP tree\r\n */\r\n allPolygons(): Polygon[] {\r\n let polygons = this._polygons.slice();\r\n if (this._front) {\r\n polygons = polygons.concat(this._front.allPolygons());\r\n }\r\n if (this._back) {\r\n polygons = polygons.concat(this._back.allPolygons());\r\n }\r\n return polygons;\r\n }\r\n\r\n /**\r\n * Build a BSP tree out of `polygons`. When called on an existing tree, the\r\n * new polygons are filtered down to the bottom of the tree and become new\r\n * nodes there. Each set of polygons is partitioned using the first polygon\r\n * (no heuristic is used to pick a good split)\r\n * @param polygons Polygons used to construct the BSP tree\r\n */\r\n build(polygons: Polygon[]): void {\r\n if (!polygons.length) {\r\n return;\r\n }\r\n if (!this._plane) {\r\n this._plane = polygons[0].plane.clone();\r\n }\r\n const front = new Array<Polygon>(),\r\n back = new Array<Polygon>();\r\n for (let i = 0; i < polygons.length; i++) {\r\n this._plane.splitPolygon(polygons[i], this._polygons, this._polygons, front, back);\r\n }\r\n if (front.length) {\r\n if (!this._front) {\r\n this._front = new Node();\r\n }\r\n this._front.build(front);\r\n }\r\n if (back.length) {\r\n if (!this._back) {\r\n this._back = new Node();\r\n }\r\n this._back.build(back);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Class for building Constructive Solid Geometry\r\n */\r\nexport class CSG {\r\n private _polygons = new Array<Polygon>();\r\n /**\r\n * The world matrix\r\n */\r\n public matrix: Matrix;\r\n /**\r\n * Stores the position\r\n */\r\n public position: Vector3;\r\n /**\r\n * Stores the rotation\r\n */\r\n public rotation: Vector3;\r\n /**\r\n * Stores the rotation quaternion\r\n */\r\n public rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * Stores the scaling vector\r\n */\r\n public scaling: Vector3;\r\n\r\n /**\r\n * Convert a VertexData to CSG\r\n * @param mesh defines the VertexData to convert to CSG\r\n * @returns the new CSG\r\n */\r\n public static FromVertexData(data: VertexData): CSG {\r\n let vertex: Vertex, polygon: Polygon, vertices: Vertex[];\r\n const polygons = new Array<Polygon>();\r\n\r\n const indices = data.indices;\r\n const positions = data.positions;\r\n const normals = data.normals;\r\n const uvs = data.uvs;\r\n const vertColors = data.colors;\r\n\r\n if (!indices || !positions) {\r\n throw \"BABYLON.CSG: VertexData must at least contain positions and indices\";\r\n }\r\n\r\n for (let i = 0; i < indices.length; i += 3) {\r\n vertices = [];\r\n for (let j = 0; j < 3; j++) {\r\n const indexIndices = i + j;\r\n const offset = indices[indexIndices];\r\n\r\n const normal = normals ? Vector3.FromArray(normals, offset * 3) : Vector3.Zero();\r\n const uv = uvs ? Vector2.FromArray(uvs, offset * 2) : undefined;\r\n const vertColor = vertColors ? Color4.FromArray(vertColors, offset * 4) : undefined;\r\n\r\n const position = Vector3.FromArray(positions, offset * 3);\r\n\r\n vertex = new Vertex(position, normal, uv, vertColor);\r\n vertices.push(vertex);\r\n }\r\n\r\n polygon = new Polygon(vertices, { subMeshId: 0, meshId: currentCSGMeshId, materialIndex: 0 });\r\n\r\n // To handle the case of degenerated triangle\r\n // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated\r\n if (polygon.plane) {\r\n polygons.push(polygon);\r\n }\r\n }\r\n\r\n const csg = CSG._FromPolygons(polygons);\r\n csg.matrix = Matrix.Identity();\r\n csg.position = Vector3.Zero();\r\n csg.rotation = Vector3.Zero();\r\n csg.scaling = Vector3.One();\r\n csg.rotationQuaternion = Quaternion.Identity();\r\n currentCSGMeshId++;\r\n\r\n return csg;\r\n }\r\n\r\n /**\r\n * Convert the Mesh to CSG\r\n * @param mesh The Mesh to convert to CSG\r\n * @param absolute If true, the final (local) matrix transformation is set to the identity and not to that of `mesh`. It can help when dealing with right-handed meshes (default: false)\r\n * @returns A new CSG from the Mesh\r\n */\r\n public static FromMesh(mesh: Mesh, absolute = false): CSG {\r\n let vertex: Vertex,\r\n normal: Vector3,\r\n uv: Vector2 | undefined = undefined,\r\n position: Vector3,\r\n vertColor: Color4 | undefined = undefined,\r\n polygon: Polygon,\r\n vertices: Vertex[];\r\n const polygons = new Array<Polygon>();\r\n let matrix: Matrix,\r\n meshPosition: Vector3,\r\n meshRotation: Vector3,\r\n meshRotationQuaternion: Nullable<Quaternion> = null,\r\n meshScaling: Vector3;\r\n\r\n let invertWinding = false;\r\n if (mesh instanceof Mesh) {\r\n mesh.computeWorldMatrix(true);\r\n matrix = mesh.getWorldMatrix();\r\n meshPosition = mesh.position.clone();\r\n meshRotation = mesh.rotation.clone();\r\n if (mesh.rotationQuaternion) {\r\n meshRotationQuaternion = mesh.rotationQuaternion.clone();\r\n }\r\n meshScaling = mesh.scaling.clone();\r\n if (mesh.material && absolute) {\r\n invertWinding = mesh.material.sideOrientation === Constants.MATERIAL_ClockWiseSideOrientation;\r\n }\r\n } else {\r\n throw \"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh\";\r\n }\r\n\r\n const indices = <IndicesArray>mesh.getIndices(),\r\n positions = <FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind),\r\n normals = <FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind),\r\n uvs = <FloatArray>mesh.getVerticesData(VertexBuffer.UVKind),\r\n vertColors = <FloatArray>mesh.getVerticesData(VertexBuffer.ColorKind);\r\n\r\n const subMeshes = mesh.subMeshes;\r\n\r\n for (let sm = 0, sml = subMeshes.length; sm < sml; sm++) {\r\n for (let i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {\r\n vertices = [];\r\n for (let j = 0; j < 3; j++) {\r\n const indexIndices = j === 0 ? i + j : invertWinding ? i + 3 - j : i + j;\r\n const sourceNormal = new Vector3(normals[indices[indexIndices] * 3], normals[indices[indexIndices] * 3 + 1], normals[indices[indexIndices] * 3 + 2]);\r\n if (uvs) {\r\n uv = new Vector2(uvs[indices[indexIndices] * 2], uvs[indices[indexIndices] * 2 + 1]);\r\n }\r\n if (vertColors) {\r\n vertColor = new Color4(\r\n vertColors[indices[indexIndices] * 4],\r\n vertColors[indices[indexIndices] * 4 + 1],\r\n vertColors[indices[indexIndices] * 4 + 2],\r\n vertColors[indices[indexIndices] * 4 + 3]\r\n );\r\n }\r\n const sourcePosition = new Vector3(positions[indices[indexIndices] * 3], positions[indices[indexIndices] * 3 + 1], positions[indices[indexIndices] * 3 + 2]);\r\n position = Vector3.TransformCoordinates(sourcePosition, matrix);\r\n normal = Vector3.TransformNormal(sourceNormal, matrix);\r\n\r\n vertex = new Vertex(position, normal, uv, vertColor);\r\n vertices.push(vertex);\r\n }\r\n\r\n polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });\r\n\r\n // To handle the case of degenerated triangle\r\n // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated\r\n if (polygon.plane) {\r\n polygons.push(polygon);\r\n }\r\n }\r\n }\r\n\r\n const csg = CSG._FromPolygons(polygons);\r\n csg.matrix = absolute ? Matrix.Identity() : matrix;\r\n csg.position = absolute ? Vector3.Zero() : meshPosition;\r\n csg.rotation = absolute ? Vector3.Zero() : meshRotation;\r\n csg.scaling = absolute ? Vector3.One() : meshScaling;\r\n csg.rotationQuaternion = absolute && meshRotationQuaternion ? Quaternion.Identity() : meshRotationQuaternion;\r\n currentCSGMeshId++;\r\n\r\n return csg;\r\n }\r\n\r\n /**\r\n * Construct a CSG solid from a list of `CSG.Polygon` instances.\r\n * @param polygons Polygons used to construct a CSG solid\r\n */\r\n private static _FromPolygons(polygons: Polygon[]): CSG {\r\n const csg = new CSG();\r\n csg._polygons = polygons;\r\n return csg;\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, of the CSG\r\n * @returns A new CSG\r\n */\r\n public clone(): CSG {\r\n const csg = new CSG();\r\n csg._polygons = this._polygons.map((p) => p.clone());\r\n csg.copyTransformAttributes(this);\r\n return csg;\r\n }\r\n\r\n /**\r\n * Unions this CSG with another CSG\r\n * @param csg The CSG to union against this CSG\r\n * @returns The unioned CSG\r\n */\r\n public union(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Unions this CSG with another CSG in place\r\n * @param csg The CSG to union against this CSG\r\n */\r\n public unionInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Subtracts this CSG with another CSG\r\n * @param csg The CSG to subtract against this CSG\r\n * @returns A new CSG\r\n */\r\n public subtract(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n a.invert();\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Subtracts this CSG with another CSG in place\r\n * @param csg The CSG to subtract against this CSG\r\n */\r\n public subtractInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n a.invert();\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Intersect this CSG with another CSG\r\n * @param csg The CSG to intersect against this CSG\r\n * @returns A new CSG\r\n */\r\n public intersect(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n a.build(b.allPolygons());\r\n a.invert();\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Intersects this CSG with another CSG in place\r\n * @param csg The CSG to intersect against this CSG\r\n */\r\n public intersectInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n a.build(b.allPolygons());\r\n a.invert();\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Return a new CSG solid with solid and empty space switched. This solid is\r\n * not modified.\r\n * @returns A new CSG solid with solid and empty space switched\r\n */\r\n public inverse(): CSG {\r\n const csg = this.clone();\r\n csg.inverseInPlace();\r\n return csg;\r\n }\r\n\r\n /**\r\n * Inverses the CSG in place\r\n */\r\n public inverseInPlace(): void {\r\n this._polygons.map((p) => {\r\n p.flip();\r\n });\r\n }\r\n\r\n /**\r\n * This is used to keep meshes transformations so they can be restored\r\n * when we build back a Babylon Mesh\r\n * NB : All CSG operations are performed in world coordinates\r\n * @param csg The CSG to copy the transform attributes from\r\n * @returns This CSG\r\n */\r\n public copyTransformAttributes(csg: CSG): CSG {\r\n this.matrix = csg.matrix;\r\n this.position = csg.position;\r\n this.rotation = csg.rotation;\r\n this.scaling = csg.scaling;\r\n this.rotationQuaternion = csg.rotationQuaternion;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Build vertex data from CSG\r\n * Coordinates here are in world space\r\n * @returns the final vertex data\r\n */\r\n public toVertexData(onBeforePolygonProcessing: Nullable<(polygon: Polygon) => void> = null, onAfterPolygonProcessing: Nullable<() => void> = null): VertexData {\r\n const matrix = this.matrix.clone();\r\n matrix.invert();\r\n\r\n const polygons = this._polygons;\r\n const vertices = [];\r\n const indices = [];\r\n const normals = [];\r\n let uvs: Nullable<number[]> = null;\r\n let vertColors: Nullable<number[]> = null;\r\n const vertex = Vector3.Zero();\r\n const normal = Vector3.Zero();\r\n const uv = Vector2.Zero();\r\n const vertColor = new Color4(0, 0, 0, 0);\r\n const polygonIndices = [0, 0, 0];\r\n const vertice_dict = {};\r\n let vertex_idx;\r\n\r\n for (let i = 0, il = polygons.length; i < il; i++) {\r\n const polygon = polygons[i];\r\n\r\n if (onBeforePolygonProcessing) {\r\n onBeforePolygonProcessing(polygon);\r\n }\r\n\r\n for (let j = 2, jl = polygon.vertices.length; j < jl; j++) {\r\n polygonIndices[0] = 0;\r\n polygonIndices[1] = j - 1;\r\n polygonIndices[2] = j;\r\n\r\n for (let k = 0; k < 3; k++) {\r\n vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);\r\n normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);\r\n if (polygon.vertices[polygonIndices[k]].uv) {\r\n if (!uvs) {\r\n uvs = [];\r\n }\r\n uv.copyFrom(polygon.vertices[polygonIndices[k]].uv!);\r\n }\r\n\r\n if (polygon.vertices[polygonIndices[k]].vertColor) {\r\n if (!vertColors) {\r\n vertColors = [];\r\n }\r\n vertColor.copyFrom(polygon.vertices[polygonIndices[k]].vertColor!);\r\n }\r\n const localVertex = Vector3.TransformCoordinates(vertex, matrix);\r\n const localNormal = Vector3.TransformNormal(normal, matrix);\r\n\r\n vertex_idx = (<any>vertice_dict)[localVertex.x + \",\" + localVertex.y + \",\" + localVertex.z];\r\n\r\n let areUvsDifferent = false;\r\n\r\n if (uvs && !(uvs[vertex_idx * 2] === uv.x || uvs[vertex_idx * 2 + 1] === uv.y)) {\r\n areUvsDifferent = true;\r\n }\r\n\r\n let areColorsDifferent = false;\r\n\r\n if (\r\n vertColors &&\r\n !(\r\n vertColors[vertex_idx * 4] === vertColor.r ||\r\n vertColors[vertex_idx * 4 + 1] === vertColor.g ||\r\n vertColors[vertex_idx * 4 + 2] === vertColor.b ||\r\n vertColors[vertex_idx * 4 + 3] === vertColor.a\r\n )\r\n ) {\r\n areColorsDifferent = true;\r\n }\r\n\r\n // Check if 2 points can be merged\r\n if (\r\n !(\r\n typeof vertex_idx !== \"undefined\" &&\r\n normals[vertex_idx * 3] === localNormal.x &&\r\n normals[vertex_idx * 3 + 1] === localNormal.y &&\r\n normals[vertex_idx * 3 + 2] === localNormal.z\r\n ) ||\r\n areUvsDifferent ||\r\n areColorsDifferent\r\n ) {\r\n vertices.push(localVertex.x, localVertex.y, localVertex.z);\r\n if (uvs) {\r\n uvs.push(uv.x, uv.y);\r\n }\r\n normals.push(normal.x, normal.y, normal.z);\r\n if (vertColors) {\r\n vertColors.push(vertColor.r, vertColor.g, vertColor.b, vertColor.a);\r\n }\r\n vertex_idx = (<any>vertice_dict)[localVertex.x + \",\" + localVertex.y + \",\" + localVertex.z] = vertices.length / 3 - 1;\r\n }\r\n\r\n indices.push(vertex_idx);\r\n\r\n if (onAfterPolygonProcessing) {\r\n onAfterPolygonProcessing();\r\n }\r\n }\r\n }\r\n }\r\n\r\n const result = new VertexData();\r\n result.positions = vertices;\r\n result.normals = normals;\r\n if (uvs) {\r\n result.uvs = uvs;\r\n }\r\n if (vertColors) {\r\n result.colors = vertColors;\r\n }\r\n result.indices = indices;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Build Raw mesh from CSG\r\n * Coordinates here are in world space\r\n * @param name The name of the mesh geometry\r\n * @param scene The Scene\r\n * @param keepSubMeshes Specifies if the submeshes should be kept\r\n * @returns A new Mesh\r\n */\r\n public buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh {\r\n const mesh = new Mesh(name, scene);\r\n const polygons = this._polygons;\r\n let currentIndex = 0;\r\n const subMeshDict = {};\r\n let subMeshObj: {\r\n materialIndex: number;\r\n indexStart: number;\r\n indexEnd: number;\r\n };\r\n\r\n if (keepSubMeshes) {\r\n // Sort Polygons, since subMeshes are indices range\r\n polygons.sort((a, b) => {\r\n if (a.shared.meshId === b.shared.meshId) {\r\n return a.shared.subMeshId - b.shared.subMeshId;\r\n } else {\r\n return a.shared.meshId - b.shared.meshId;\r\n }\r\n });\r\n }\r\n\r\n const vertexData = this.toVertexData(\r\n (polygon) => {\r\n // Building SubMeshes\r\n if (!(<any>subMeshDict)[polygon.shared.meshId]) {\r\n (<any>subMeshDict)[polygon.shared.meshId] = {};\r\n }\r\n if (!(<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId]) {\r\n (<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId] = {\r\n indexStart: +Infinity,\r\n indexEnd: -Infinity,\r\n materialIndex: polygon.shared.materialIndex,\r\n };\r\n }\r\n subMeshObj = (<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId];\r\n },\r\n () => {\r\n subMeshObj.indexStart = Math.min(currentIndex, subMeshObj.indexStart);\r\n subMeshObj.indexEnd = Math.max(currentIndex, subMeshObj.indexEnd);\r\n currentIndex++;\r\n }\r\n );\r\n\r\n vertexData.applyToMesh(mesh);\r\n\r\n if (keepSubMeshes) {\r\n // We offset the materialIndex by the previous number of materials in the CSG mixed meshes\r\n let materialIndexOffset = 0,\r\n materialMaxIndex;\r\n\r\n mesh.subMeshes = new Array<SubMesh>();\r\n\r\n for (const m in subMeshDict) {\r\n materialMaxIndex = -1;\r\n for (const sm in (<any>subMeshDict)[m]) {\r\n subMeshObj = (<any>subMeshDict)[m][sm];\r\n SubMesh.CreateFromIndices(\r\n subMeshObj.materialIndex + materialIndexOffset,\r\n subMeshObj.indexStart,\r\n subMeshObj.indexEnd - subMeshObj.indexStart + 1,\r\n <AbstractMesh>mesh\r\n );\r\n materialMaxIndex = Math.max(subMeshObj.materialIndex, materialMaxIndex);\r\n }\r\n materialIndexOffset += ++materialMaxIndex;\r\n }\r\n }\r\n\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Build Mesh from CSG taking material and transforms into account\r\n * @param name The name of the Mesh\r\n * @param material The material of the Mesh\r\n * @param scene The Scene\r\n * @param keepSubMeshes Specifies if submeshes should be kept\r\n * @returns The new Mesh\r\n */\r\n public toMesh(name: string, material: Nullable<Material> = null, scene?: Scene, keepSubMeshes?: boolean): Mesh {\r\n const mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);\r\n\r\n mesh.material = material;\r\n\r\n mesh.position.copyFrom(this.position);\r\n mesh.rotation.copyFrom(this.rotation);\r\n if (this.rotationQuaternion) {\r\n mesh.rotationQuaternion = this.rotationQuaternion.clone();\r\n }\r\n mesh.scaling.copyFrom(this.scaling);\r\n mesh.computeWorldMatrix(true);\r\n\r\n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ACI,MAAM,CAAC,IAAY,EAAE,WAA+B,IAAI,EAAE,KAAa,EAAE,aAAuB;QACnG,MAAM,IAAI,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;QAEhE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,IAAI,CAAC,kBAAkB,EAAE;YACzB,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;SAC7D;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAE9B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Nullable, FloatArray, IndicesArray } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Quaternion, Matrix, Vector3, Vector2 } from \"../Maths/math.vector\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { SubMesh } from \"../Meshes/subMesh\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { Material } from \"../Materials/material\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { VertexData } from \"./mesh.vertexData\";\r\n/**\r\n * Unique ID when we import meshes from Babylon to CSG\r\n */\r\nlet currentCSGMeshId = 0;\r\n\r\n/**\r\n * Represents a vertex of a polygon. Use your own vertex class instead of this\r\n * one to provide additional features like texture coordinates and vertex\r\n * colors. Custom vertex classes need to provide a `pos` property and `clone()`,\r\n * `flip()`, and `interpolate()` methods that behave analogous to the ones\r\n * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience\r\n * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`\r\n * is not used anywhere else.\r\n * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes\r\n */\r\nclass Vertex {\r\n /**\r\n * Initializes the vertex\r\n * @param pos The position of the vertex\r\n * @param normal The normal of the vertex\r\n * @param uv The texture coordinate of the vertex\r\n * @param vertColor The RGBA color of the vertex\r\n */\r\n constructor(\r\n /**\r\n * The position of the vertex\r\n */\r\n public pos: Vector3,\r\n /**\r\n * The normal of the vertex\r\n */\r\n public normal: Vector3,\r\n /**\r\n * The texture coordinate of the vertex\r\n */\r\n public uv?: Vector2,\r\n /**\r\n * The texture coordinate of the vertex\r\n */\r\n public vertColor?: Color4\r\n ) {}\r\n\r\n /**\r\n * Make a clone, or deep copy, of the vertex\r\n * @returns A new Vertex\r\n */\r\n public clone(): Vertex {\r\n return new Vertex(this.pos.clone(), this.normal.clone(), this.uv?.clone(), this.vertColor?.clone());\r\n }\r\n\r\n /**\r\n * Invert all orientation-specific data (e.g. vertex normal). Called when the\r\n * orientation of a polygon is flipped.\r\n */\r\n public flip(): void {\r\n this.normal = this.normal.scale(-1);\r\n }\r\n\r\n /**\r\n * Create a new vertex between this vertex and `other` by linearly\r\n * interpolating all properties using a parameter of `t`. Subclasses should\r\n * override this to interpolate additional properties.\r\n * @param other the vertex to interpolate against\r\n * @param t The factor used to linearly interpolate between the vertices\r\n */\r\n public interpolate(other: Vertex, t: number): Vertex {\r\n return new Vertex(\r\n Vector3.Lerp(this.pos, other.pos, t),\r\n Vector3.Lerp(this.normal, other.normal, t),\r\n this.uv && other.uv ? Vector2.Lerp(this.uv, other.uv, t) : undefined,\r\n this.vertColor && other.vertColor ? Color4.Lerp(this.vertColor, other.vertColor, t) : undefined\r\n );\r\n }\r\n}\r\n\r\n/**\r\n * Represents a plane in 3D space.\r\n */\r\nclass CSGPlane {\r\n /**\r\n * Initializes the plane\r\n * @param normal The normal for the plane\r\n * @param w\r\n */\r\n constructor(\r\n public normal: Vector3,\r\n public w: number\r\n ) {}\r\n\r\n /**\r\n * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a\r\n * point is on the plane\r\n */\r\n static EPSILON = 1e-5;\r\n\r\n /**\r\n * Construct a plane from three points\r\n * @param a Point a\r\n * @param b Point b\r\n * @param c Point c\r\n */\r\n public static FromPoints(a: Vector3, b: Vector3, c: Vector3): Nullable<CSGPlane> {\r\n const v0 = c.subtract(a);\r\n const v1 = b.subtract(a);\r\n\r\n if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {\r\n return null;\r\n }\r\n\r\n const n = Vector3.Normalize(Vector3.Cross(v0, v1));\r\n return new CSGPlane(n, Vector3.Dot(n, a));\r\n }\r\n\r\n /**\r\n * Clone, or make a deep copy of the plane\r\n * @returns a new Plane\r\n */\r\n public clone(): CSGPlane {\r\n return new CSGPlane(this.normal.clone(), this.w);\r\n }\r\n\r\n /**\r\n * Flip the face of the plane\r\n */\r\n public flip() {\r\n this.normal.scaleInPlace(-1);\r\n this.w = -this.w;\r\n }\r\n\r\n /**\r\n * Split `polygon` by this plane if needed, then put the polygon or polygon\r\n * fragments in the appropriate lists. Coplanar polygons go into either\r\n `* coplanarFront` or `coplanarBack` depending on their orientation with\r\n * respect to this plane. Polygons in front or in back of this plane go into\r\n * either `front` or `back`\r\n * @param polygon The polygon to be split\r\n * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane\r\n * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane\r\n * @param front Will contain the polygons in front of the plane\r\n * @param back Will contain the polygons begind the plane\r\n */\r\n public splitPolygon(polygon: CSGPolygon, coplanarFront: CSGPolygon[], coplanarBack: CSGPolygon[], front: CSGPolygon[], back: CSGPolygon[]): void {\r\n const COPLANAR = 0;\r\n const FRONT = 1;\r\n const BACK = 2;\r\n const SPANNING = 3;\r\n\r\n // Classify each point as well as the entire polygon into one of the above\r\n // four classes.\r\n let polygonType = 0;\r\n const types = [];\r\n let i: number;\r\n let t: number;\r\n for (i = 0; i < polygon.vertices.length; i++) {\r\n t = Vector3.Dot(this.normal, polygon.vertices[i].pos) - this.w;\r\n const type = t < -CSGPlane.EPSILON ? BACK : t > CSGPlane.EPSILON ? FRONT : COPLANAR;\r\n polygonType |= type;\r\n types.push(type);\r\n }\r\n\r\n // Put the polygon in the correct list, splitting it when necessary\r\n switch (polygonType) {\r\n case COPLANAR:\r\n (Vector3.Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);\r\n break;\r\n case FRONT:\r\n front.push(polygon);\r\n break;\r\n case BACK:\r\n back.push(polygon);\r\n break;\r\n case SPANNING: {\r\n const f = [],\r\n b = [];\r\n for (i = 0; i < polygon.vertices.length; i++) {\r\n const j = (i + 1) % polygon.vertices.length;\r\n const ti = types[i],\r\n tj = types[j];\r\n const vi = polygon.vertices[i],\r\n vj = polygon.vertices[j];\r\n if (ti !== BACK) {\r\n f.push(vi);\r\n }\r\n if (ti !== FRONT) {\r\n b.push(ti !== BACK ? vi.clone() : vi);\r\n }\r\n if ((ti | tj) === SPANNING) {\r\n t = (this.w - Vector3.Dot(this.normal, vi.pos)) / Vector3.Dot(this.normal, vj.pos.subtract(vi.pos));\r\n const v = vi.interpolate(vj, t);\r\n f.push(v);\r\n b.push(v.clone());\r\n }\r\n }\r\n let poly: CSGPolygon;\r\n if (f.length >= 3) {\r\n poly = new CSGPolygon(f, polygon.shared);\r\n if (poly.plane) {\r\n front.push(poly);\r\n }\r\n }\r\n\r\n if (b.length >= 3) {\r\n poly = new CSGPolygon(b, polygon.shared);\r\n\r\n if (poly.plane) {\r\n back.push(poly);\r\n }\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Represents a convex polygon. The vertices used to initialize a polygon must\r\n * be coplanar and form a convex loop.\r\n *\r\n * Each convex polygon has a `shared` property, which is shared between all\r\n * polygons that are clones of each other or were split from the same polygon.\r\n * This can be used to define per-polygon properties (such as surface color)\r\n */\r\nclass CSGPolygon {\r\n /**\r\n * Vertices of the polygon\r\n */\r\n public vertices: Vertex[];\r\n /**\r\n * Properties that are shared across all polygons\r\n */\r\n public shared: any;\r\n /**\r\n * A plane formed from the vertices of the polygon\r\n */\r\n public plane: CSGPlane;\r\n\r\n /**\r\n * Initializes the polygon\r\n * @param vertices The vertices of the polygon\r\n * @param shared The properties shared across all polygons\r\n */\r\n constructor(vertices: Vertex[], shared: any) {\r\n this.vertices = vertices;\r\n this.shared = shared;\r\n this.plane = <CSGPlane>CSGPlane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, or the polygon\r\n */\r\n public clone(): CSGPolygon {\r\n const vertices = this.vertices.map((v) => v.clone());\r\n return new CSGPolygon(vertices, this.shared);\r\n }\r\n\r\n /**\r\n * Flips the faces of the polygon\r\n */\r\n public flip() {\r\n this.vertices.reverse().map((v) => {\r\n v.flip();\r\n });\r\n this.plane.flip();\r\n }\r\n}\r\n\r\n/**\r\n * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons\r\n * by picking a polygon to split along. That polygon (and all other coplanar\r\n * polygons) are added directly to that node and the other polygons are added to\r\n * the front and/or back subtrees. This is not a leafy BSP tree since there is\r\n * no distinction between internal and leaf nodes\r\n */\r\nclass Node {\r\n private _plane: Nullable<CSGPlane> = null;\r\n private _front: Nullable<Node> = null;\r\n private _back: Nullable<Node> = null;\r\n private _polygons = new Array<CSGPolygon>();\r\n\r\n /**\r\n * Initializes the node\r\n * @param polygons A collection of polygons held in the node\r\n */\r\n constructor(polygons?: Array<CSGPolygon>) {\r\n if (polygons) {\r\n this.build(polygons);\r\n }\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, of the node\r\n * @returns The cloned node\r\n */\r\n public clone(): Node {\r\n const node = new Node();\r\n node._plane = this._plane && this._plane.clone();\r\n node._front = this._front && this._front.clone();\r\n node._back = this._back && this._back.clone();\r\n node._polygons = this._polygons.map((p) => p.clone());\r\n return node;\r\n }\r\n\r\n /**\r\n * Convert solid space to empty space and empty space to solid space\r\n */\r\n public invert(): void {\r\n for (let i = 0; i < this._polygons.length; i++) {\r\n this._polygons[i].flip();\r\n }\r\n if (this._plane) {\r\n this._plane.flip();\r\n }\r\n if (this._front) {\r\n this._front.invert();\r\n }\r\n if (this._back) {\r\n this._back.invert();\r\n }\r\n const temp = this._front;\r\n this._front = this._back;\r\n this._back = temp;\r\n }\r\n\r\n /**\r\n * Recursively remove all polygons in `polygons` that are inside this BSP\r\n * tree.\r\n * @param polygons Polygons to remove from the BSP\r\n * @returns Polygons clipped from the BSP\r\n */\r\n clipPolygons(polygons: CSGPolygon[]): CSGPolygon[] {\r\n if (!this._plane) {\r\n return polygons.slice();\r\n }\r\n let front = new Array<CSGPolygon>(),\r\n back = new Array<CSGPolygon>();\r\n for (let i = 0; i < polygons.length; i++) {\r\n this._plane.splitPolygon(polygons[i], front, back, front, back);\r\n }\r\n if (this._front) {\r\n front = this._front.clipPolygons(front);\r\n }\r\n if (this._back) {\r\n back = this._back.clipPolygons(back);\r\n } else {\r\n back = [];\r\n }\r\n return front.concat(back);\r\n }\r\n\r\n /**\r\n * Remove all polygons in this BSP tree that are inside the other BSP tree\r\n * `bsp`.\r\n * @param bsp BSP containing polygons to remove from this BSP\r\n */\r\n clipTo(bsp: Node): void {\r\n this._polygons = bsp.clipPolygons(this._polygons);\r\n if (this._front) {\r\n this._front.clipTo(bsp);\r\n }\r\n if (this._back) {\r\n this._back.clipTo(bsp);\r\n }\r\n }\r\n\r\n /**\r\n * Return a list of all polygons in this BSP tree\r\n * @returns List of all polygons in this BSP tree\r\n */\r\n allPolygons(): CSGPolygon[] {\r\n let polygons = this._polygons.slice();\r\n if (this._front) {\r\n polygons = polygons.concat(this._front.allPolygons());\r\n }\r\n if (this._back) {\r\n polygons = polygons.concat(this._back.allPolygons());\r\n }\r\n return polygons;\r\n }\r\n\r\n /**\r\n * Build a BSP tree out of `polygons`. When called on an existing tree, the\r\n * new polygons are filtered down to the bottom of the tree and become new\r\n * nodes there. Each set of polygons is partitioned using the first polygon\r\n * (no heuristic is used to pick a good split)\r\n * @param polygons Polygons used to construct the BSP tree\r\n */\r\n build(polygons: CSGPolygon[]): void {\r\n if (!polygons.length) {\r\n return;\r\n }\r\n if (!this._plane) {\r\n this._plane = polygons[0].plane.clone();\r\n }\r\n const front = new Array<CSGPolygon>(),\r\n back = new Array<CSGPolygon>();\r\n for (let i = 0; i < polygons.length; i++) {\r\n this._plane.splitPolygon(polygons[i], this._polygons, this._polygons, front, back);\r\n }\r\n if (front.length) {\r\n if (!this._front) {\r\n this._front = new Node();\r\n }\r\n this._front.build(front);\r\n }\r\n if (back.length) {\r\n if (!this._back) {\r\n this._back = new Node();\r\n }\r\n this._back.build(back);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Class for building Constructive Solid Geometry\r\n */\r\nexport class CSG {\r\n private _polygons = new Array<CSGPolygon>();\r\n /**\r\n * The world matrix\r\n */\r\n public matrix: Matrix;\r\n /**\r\n * Stores the position\r\n */\r\n public position: Vector3;\r\n /**\r\n * Stores the rotation\r\n */\r\n public rotation: Vector3;\r\n /**\r\n * Stores the rotation quaternion\r\n */\r\n public rotationQuaternion: Nullable<Quaternion>;\r\n /**\r\n * Stores the scaling vector\r\n */\r\n public scaling: Vector3;\r\n\r\n /**\r\n * Convert a VertexData to CSG\r\n * @param mesh defines the VertexData to convert to CSG\r\n * @returns the new CSG\r\n */\r\n public static FromVertexData(data: VertexData): CSG {\r\n let vertex: Vertex, polygon: CSGPolygon, vertices: Vertex[];\r\n const polygons = new Array<CSGPolygon>();\r\n\r\n const indices = data.indices;\r\n const positions = data.positions;\r\n const normals = data.normals;\r\n const uvs = data.uvs;\r\n const vertColors = data.colors;\r\n\r\n if (!indices || !positions) {\r\n throw \"BABYLON.CSG: VertexData must at least contain positions and indices\";\r\n }\r\n\r\n for (let i = 0; i < indices.length; i += 3) {\r\n vertices = [];\r\n for (let j = 0; j < 3; j++) {\r\n const indexIndices = i + j;\r\n const offset = indices[indexIndices];\r\n\r\n const normal = normals ? Vector3.FromArray(normals, offset * 3) : Vector3.Zero();\r\n const uv = uvs ? Vector2.FromArray(uvs, offset * 2) : undefined;\r\n const vertColor = vertColors ? Color4.FromArray(vertColors, offset * 4) : undefined;\r\n\r\n const position = Vector3.FromArray(positions, offset * 3);\r\n\r\n vertex = new Vertex(position, normal, uv, vertColor);\r\n vertices.push(vertex);\r\n }\r\n\r\n polygon = new CSGPolygon(vertices, { subMeshId: 0, meshId: currentCSGMeshId, materialIndex: 0 });\r\n\r\n // To handle the case of degenerated triangle\r\n // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated\r\n if (polygon.plane) {\r\n polygons.push(polygon);\r\n }\r\n }\r\n\r\n const csg = CSG._FromPolygons(polygons);\r\n csg.matrix = Matrix.Identity();\r\n csg.position = Vector3.Zero();\r\n csg.rotation = Vector3.Zero();\r\n csg.scaling = Vector3.One();\r\n csg.rotationQuaternion = Quaternion.Identity();\r\n currentCSGMeshId++;\r\n\r\n return csg;\r\n }\r\n\r\n /**\r\n * Convert the Mesh to CSG\r\n * @param mesh The Mesh to convert to CSG\r\n * @param absolute If true, the final (local) matrix transformation is set to the identity and not to that of `mesh`. It can help when dealing with right-handed meshes (default: false)\r\n * @returns A new CSG from the Mesh\r\n */\r\n public static FromMesh(mesh: Mesh, absolute = false): CSG {\r\n let vertex: Vertex,\r\n normal: Vector3,\r\n uv: Vector2 | undefined = undefined,\r\n position: Vector3,\r\n vertColor: Color4 | undefined = undefined,\r\n polygon: CSGPolygon,\r\n vertices: Vertex[];\r\n const polygons = new Array<CSGPolygon>();\r\n let matrix: Matrix,\r\n meshPosition: Vector3,\r\n meshRotation: Vector3,\r\n meshRotationQuaternion: Nullable<Quaternion> = null,\r\n meshScaling: Vector3;\r\n\r\n let invertWinding = false;\r\n if (mesh instanceof Mesh) {\r\n mesh.computeWorldMatrix(true);\r\n matrix = mesh.getWorldMatrix();\r\n meshPosition = mesh.position.clone();\r\n meshRotation = mesh.rotation.clone();\r\n if (mesh.rotationQuaternion) {\r\n meshRotationQuaternion = mesh.rotationQuaternion.clone();\r\n }\r\n meshScaling = mesh.scaling.clone();\r\n if (mesh.material && absolute) {\r\n invertWinding = mesh.material.sideOrientation === Constants.MATERIAL_ClockWiseSideOrientation;\r\n }\r\n } else {\r\n throw \"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh\";\r\n }\r\n\r\n const indices = <IndicesArray>mesh.getIndices(),\r\n positions = <FloatArray>mesh.getVerticesData(VertexBuffer.PositionKind),\r\n normals = <FloatArray>mesh.getVerticesData(VertexBuffer.NormalKind),\r\n uvs = <FloatArray>mesh.getVerticesData(VertexBuffer.UVKind),\r\n vertColors = <FloatArray>mesh.getVerticesData(VertexBuffer.ColorKind);\r\n\r\n const subMeshes = mesh.subMeshes;\r\n\r\n for (let sm = 0, sml = subMeshes.length; sm < sml; sm++) {\r\n for (let i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {\r\n vertices = [];\r\n for (let j = 0; j < 3; j++) {\r\n const indexIndices = j === 0 ? i + j : invertWinding ? i + 3 - j : i + j;\r\n const sourceNormal = new Vector3(normals[indices[indexIndices] * 3], normals[indices[indexIndices] * 3 + 1], normals[indices[indexIndices] * 3 + 2]);\r\n if (uvs) {\r\n uv = new Vector2(uvs[indices[indexIndices] * 2], uvs[indices[indexIndices] * 2 + 1]);\r\n }\r\n if (vertColors) {\r\n vertColor = new Color4(\r\n vertColors[indices[indexIndices] * 4],\r\n vertColors[indices[indexIndices] * 4 + 1],\r\n vertColors[indices[indexIndices] * 4 + 2],\r\n vertColors[indices[indexIndices] * 4 + 3]\r\n );\r\n }\r\n const sourcePosition = new Vector3(positions[indices[indexIndices] * 3], positions[indices[indexIndices] * 3 + 1], positions[indices[indexIndices] * 3 + 2]);\r\n position = Vector3.TransformCoordinates(sourcePosition, matrix);\r\n normal = Vector3.TransformNormal(sourceNormal, matrix);\r\n\r\n vertex = new Vertex(position, normal, uv, vertColor);\r\n vertices.push(vertex);\r\n }\r\n\r\n polygon = new CSGPolygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });\r\n\r\n // To handle the case of degenerated triangle\r\n // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated\r\n if (polygon.plane) {\r\n polygons.push(polygon);\r\n }\r\n }\r\n }\r\n\r\n const csg = CSG._FromPolygons(polygons);\r\n csg.matrix = absolute ? Matrix.Identity() : matrix;\r\n csg.position = absolute ? Vector3.Zero() : meshPosition;\r\n csg.rotation = absolute ? Vector3.Zero() : meshRotation;\r\n csg.scaling = absolute ? Vector3.One() : meshScaling;\r\n csg.rotationQuaternion = absolute && meshRotationQuaternion ? Quaternion.Identity() : meshRotationQuaternion;\r\n currentCSGMeshId++;\r\n\r\n return csg;\r\n }\r\n\r\n /**\r\n * Construct a CSG solid from a list of `CSG.Polygon` instances.\r\n * @param polygons Polygons used to construct a CSG solid\r\n */\r\n private static _FromPolygons(polygons: CSGPolygon[]): CSG {\r\n const csg = new CSG();\r\n csg._polygons = polygons;\r\n return csg;\r\n }\r\n\r\n /**\r\n * Clones, or makes a deep copy, of the CSG\r\n * @returns A new CSG\r\n */\r\n public clone(): CSG {\r\n const csg = new CSG();\r\n csg._polygons = this._polygons.map((p) => p.clone());\r\n csg.copyTransformAttributes(this);\r\n return csg;\r\n }\r\n\r\n /**\r\n * Unions this CSG with another CSG\r\n * @param csg The CSG to union against this CSG\r\n * @returns The unioned CSG\r\n */\r\n public union(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Unions this CSG with another CSG in place\r\n * @param csg The CSG to union against this CSG\r\n */\r\n public unionInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Subtracts this CSG with another CSG\r\n * @param csg The CSG to subtract against this CSG\r\n * @returns A new CSG\r\n */\r\n public subtract(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n a.invert();\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Subtracts this CSG with another CSG in place\r\n * @param csg The CSG to subtract against this CSG\r\n */\r\n public subtractInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n b.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.build(b.allPolygons());\r\n a.invert();\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Intersect this CSG with another CSG\r\n * @param csg The CSG to intersect against this CSG\r\n * @returns A new CSG\r\n */\r\n public intersect(csg: CSG): CSG {\r\n const a = new Node(this.clone()._polygons);\r\n const b = new Node(csg.clone()._polygons);\r\n a.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n a.build(b.allPolygons());\r\n a.invert();\r\n return CSG._FromPolygons(a.allPolygons()).copyTransformAttributes(this);\r\n }\r\n\r\n /**\r\n * Intersects this CSG with another CSG in place\r\n * @param csg The CSG to intersect against this CSG\r\n */\r\n public intersectInPlace(csg: CSG): void {\r\n const a = new Node(this._polygons);\r\n const b = new Node(csg._polygons);\r\n\r\n a.invert();\r\n b.clipTo(a);\r\n b.invert();\r\n a.clipTo(b);\r\n b.clipTo(a);\r\n a.build(b.allPolygons());\r\n a.invert();\r\n\r\n this._polygons = a.allPolygons();\r\n }\r\n\r\n /**\r\n * Return a new CSG solid with solid and empty space switched. This solid is\r\n * not modified.\r\n * @returns A new CSG solid with solid and empty space switched\r\n */\r\n public inverse(): CSG {\r\n const csg = this.clone();\r\n csg.inverseInPlace();\r\n return csg;\r\n }\r\n\r\n /**\r\n * Inverses the CSG in place\r\n */\r\n public inverseInPlace(): void {\r\n this._polygons.map((p) => {\r\n p.flip();\r\n });\r\n }\r\n\r\n /**\r\n * This is used to keep meshes transformations so they can be restored\r\n * when we build back a Babylon Mesh\r\n * NB : All CSG operations are performed in world coordinates\r\n * @param csg The CSG to copy the transform attributes from\r\n * @returns This CSG\r\n */\r\n public copyTransformAttributes(csg: CSG): CSG {\r\n this.matrix = csg.matrix;\r\n this.position = csg.position;\r\n this.rotation = csg.rotation;\r\n this.scaling = csg.scaling;\r\n this.rotationQuaternion = csg.rotationQuaternion;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Build vertex data from CSG\r\n * Coordinates here are in world space\r\n * @returns the final vertex data\r\n */\r\n public toVertexData(onBeforePolygonProcessing: Nullable<(polygon: CSGPolygon) => void> = null, onAfterPolygonProcessing: Nullable<() => void> = null): VertexData {\r\n const matrix = this.matrix.clone();\r\n matrix.invert();\r\n\r\n const polygons = this._polygons;\r\n const vertices = [];\r\n const indices = [];\r\n const normals = [];\r\n let uvs: Nullable<number[]> = null;\r\n let vertColors: Nullable<number[]> = null;\r\n const vertex = Vector3.Zero();\r\n const normal = Vector3.Zero();\r\n const uv = Vector2.Zero();\r\n const vertColor = new Color4(0, 0, 0, 0);\r\n const polygonIndices = [0, 0, 0];\r\n const vertice_dict = {};\r\n let vertex_idx;\r\n\r\n for (let i = 0, il = polygons.length; i < il; i++) {\r\n const polygon = polygons[i];\r\n\r\n if (onBeforePolygonProcessing) {\r\n onBeforePolygonProcessing(polygon);\r\n }\r\n\r\n for (let j = 2, jl = polygon.vertices.length; j < jl; j++) {\r\n polygonIndices[0] = 0;\r\n polygonIndices[1] = j - 1;\r\n polygonIndices[2] = j;\r\n\r\n for (let k = 0; k < 3; k++) {\r\n vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);\r\n normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);\r\n if (polygon.vertices[polygonIndices[k]].uv) {\r\n if (!uvs) {\r\n uvs = [];\r\n }\r\n uv.copyFrom(polygon.vertices[polygonIndices[k]].uv!);\r\n }\r\n\r\n if (polygon.vertices[polygonIndices[k]].vertColor) {\r\n if (!vertColors) {\r\n vertColors = [];\r\n }\r\n vertColor.copyFrom(polygon.vertices[polygonIndices[k]].vertColor!);\r\n }\r\n const localVertex = Vector3.TransformCoordinates(vertex, matrix);\r\n const localNormal = Vector3.TransformNormal(normal, matrix);\r\n\r\n vertex_idx = (<any>vertice_dict)[localVertex.x + \",\" + localVertex.y + \",\" + localVertex.z];\r\n\r\n let areUvsDifferent = false;\r\n\r\n if (uvs && !(uvs[vertex_idx * 2] === uv.x || uvs[vertex_idx * 2 + 1] === uv.y)) {\r\n areUvsDifferent = true;\r\n }\r\n\r\n let areColorsDifferent = false;\r\n\r\n if (\r\n vertColors &&\r\n !(\r\n vertColors[vertex_idx * 4] === vertColor.r ||\r\n vertColors[vertex_idx * 4 + 1] === vertColor.g ||\r\n vertColors[vertex_idx * 4 + 2] === vertColor.b ||\r\n vertColors[vertex_idx * 4 + 3] === vertColor.a\r\n )\r\n ) {\r\n areColorsDifferent = true;\r\n }\r\n\r\n // Check if 2 points can be merged\r\n if (\r\n !(\r\n typeof vertex_idx !== \"undefined\" &&\r\n normals[vertex_idx * 3] === localNormal.x &&\r\n normals[vertex_idx * 3 + 1] === localNormal.y &&\r\n normals[vertex_idx * 3 + 2] === localNormal.z\r\n ) ||\r\n areUvsDifferent ||\r\n areColorsDifferent\r\n ) {\r\n vertices.push(localVertex.x, localVertex.y, localVertex.z);\r\n if (uvs) {\r\n uvs.push(uv.x, uv.y);\r\n }\r\n normals.push(normal.x, normal.y, normal.z);\r\n if (vertColors) {\r\n vertColors.push(vertColor.r, vertColor.g, vertColor.b, vertColor.a);\r\n }\r\n vertex_idx = (<any>vertice_dict)[localVertex.x + \",\" + localVertex.y + \",\" + localVertex.z] = vertices.length / 3 - 1;\r\n }\r\n\r\n indices.push(vertex_idx);\r\n\r\n if (onAfterPolygonProcessing) {\r\n onAfterPolygonProcessing();\r\n }\r\n }\r\n }\r\n }\r\n\r\n const result = new VertexData();\r\n result.positions = vertices;\r\n result.normals = normals;\r\n if (uvs) {\r\n result.uvs = uvs;\r\n }\r\n if (vertColors) {\r\n result.colors = vertColors;\r\n }\r\n result.indices = indices;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Build Raw mesh from CSG\r\n * Coordinates here are in world space\r\n * @param name The name of the mesh geometry\r\n * @param scene The Scene\r\n * @param keepSubMeshes Specifies if the submeshes should be kept\r\n * @returns A new Mesh\r\n */\r\n public buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh {\r\n const mesh = new Mesh(name, scene);\r\n const polygons = this._polygons;\r\n let currentIndex = 0;\r\n const subMeshDict = {};\r\n let subMeshObj: {\r\n materialIndex: number;\r\n indexStart: number;\r\n indexEnd: number;\r\n };\r\n\r\n if (keepSubMeshes) {\r\n // Sort Polygons, since subMeshes are indices range\r\n polygons.sort((a, b) => {\r\n if (a.shared.meshId === b.shared.meshId) {\r\n return a.shared.subMeshId - b.shared.subMeshId;\r\n } else {\r\n return a.shared.meshId - b.shared.meshId;\r\n }\r\n });\r\n }\r\n\r\n const vertexData = this.toVertexData(\r\n (polygon) => {\r\n // Building SubMeshes\r\n if (!(<any>subMeshDict)[polygon.shared.meshId]) {\r\n (<any>subMeshDict)[polygon.shared.meshId] = {};\r\n }\r\n if (!(<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId]) {\r\n (<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId] = {\r\n indexStart: +Infinity,\r\n indexEnd: -Infinity,\r\n materialIndex: polygon.shared.materialIndex,\r\n };\r\n }\r\n subMeshObj = (<any>subMeshDict)[polygon.shared.meshId][polygon.shared.subMeshId];\r\n },\r\n () => {\r\n subMeshObj.indexStart = Math.min(currentIndex, subMeshObj.indexStart);\r\n subMeshObj.indexEnd = Math.max(currentIndex, subMeshObj.indexEnd);\r\n currentIndex++;\r\n }\r\n );\r\n\r\n vertexData.applyToMesh(mesh);\r\n\r\n if (keepSubMeshes) {\r\n // We offset the materialIndex by the previous number of materials in the CSG mixed meshes\r\n let materialIndexOffset = 0,\r\n materialMaxIndex;\r\n\r\n mesh.subMeshes = new Array<SubMesh>();\r\n\r\n for (const m in subMeshDict) {\r\n materialMaxIndex = -1;\r\n for (const sm in (<any>subMeshDict)[m]) {\r\n subMeshObj = (<any>subMeshDict)[m][sm];\r\n SubMesh.CreateFromIndices(\r\n subMeshObj.materialIndex + materialIndexOffset,\r\n subMeshObj.indexStart,\r\n subMeshObj.indexEnd - subMeshObj.indexStart + 1,\r\n <AbstractMesh>mesh\r\n );\r\n materialMaxIndex = Math.max(subMeshObj.materialIndex, materialMaxIndex);\r\n }\r\n materialIndexOffset += ++materialMaxIndex;\r\n }\r\n }\r\n\r\n return mesh;\r\n }\r\n\r\n /**\r\n * Build Mesh from CSG taking material and transforms into account\r\n * @param name The name of the Mesh\r\n * @param material The material of the Mesh\r\n * @param scene The Scene\r\n * @param keepSubMeshes Specifies if submeshes should be kept\r\n * @returns The new Mesh\r\n */\r\n public toMesh(name: string, material: Nullable<Material> = null, scene?: Scene, keepSubMeshes?: boolean): Mesh {\r\n const mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);\r\n\r\n mesh.material = material;\r\n\r\n mesh.position.copyFrom(this.position);\r\n mesh.rotation.copyFrom(this.rotation);\r\n if (this.rotationQuaternion) {\r\n mesh.rotationQuaternion = this.rotationQuaternion.clone();\r\n }\r\n mesh.scaling.copyFrom(this.scaling);\r\n mesh.computeWorldMatrix(true);\r\n\r\n return mesh;\r\n }\r\n}\r\n"]}
@@ -8,6 +8,8 @@ export declare class DeepCopier {
8
8
  * @param destination defines the target object
9
9
  * @param doNotCopyList defines a list of properties to avoid
10
10
  * @param mustCopyList defines a list of properties to copy (even if they start with _)
11
+ * @param shallowCopyValues defines wether properties referencing objects (none cloneable) must be shallow copied (false by default)
12
+ * @remarks shallowCopyValues will not instantite the copied values which makes it only usable for "JSON objects"
11
13
  */
12
- static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
14
+ static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[], shallowCopyValues?: boolean): void;
13
15
  }
@@ -1,5 +1,5 @@
1
1
  import { Logger } from "./logger.js";
2
- const CloneValue = (source, destinationObject) => {
2
+ const CloneValue = (source, destinationObject, shallowCopyValues) => {
3
3
  if (!source) {
4
4
  return null;
5
5
  }
@@ -15,7 +15,7 @@ const CloneValue = (source, destinationObject) => {
15
15
  else if (Array.isArray(source)) {
16
16
  return source.slice();
17
17
  }
18
- else if (typeof source === "object") {
18
+ else if (shallowCopyValues && typeof source === "object") {
19
19
  return Object.assign({}, source);
20
20
  }
21
21
  return null;
@@ -41,8 +41,10 @@ export class DeepCopier {
41
41
  * @param destination defines the target object
42
42
  * @param doNotCopyList defines a list of properties to avoid
43
43
  * @param mustCopyList defines a list of properties to copy (even if they start with _)
44
+ * @param shallowCopyValues defines wether properties referencing objects (none cloneable) must be shallow copied (false by default)
45
+ * @remarks shallowCopyValues will not instantite the copied values which makes it only usable for "JSON objects"
44
46
  */
45
- static DeepCopy(source, destination, doNotCopyList, mustCopyList) {
47
+ static DeepCopy(source, destination, doNotCopyList, mustCopyList, shallowCopyValues = false) {
46
48
  const properties = GetAllPropertyNames(source);
47
49
  for (const prop of properties) {
48
50
  if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
@@ -69,7 +71,7 @@ export class DeepCopier {
69
71
  if (sourceValue.length > 0) {
70
72
  if (typeof sourceValue[0] == "object") {
71
73
  for (let index = 0; index < sourceValue.length; index++) {
72
- const clonedValue = CloneValue(sourceValue[index], destination);
74
+ const clonedValue = CloneValue(sourceValue[index], destination, shallowCopyValues);
73
75
  if (destination[prop].indexOf(clonedValue) === -1) {
74
76
  // Test if auto inject was not done
75
77
  destination[prop].push(clonedValue);
@@ -82,7 +84,7 @@ export class DeepCopier {
82
84
  }
83
85
  }
84
86
  else {
85
- destination[prop] = CloneValue(sourceValue, destination);
87
+ destination[prop] = CloneValue(sourceValue, destination, shallowCopyValues);
86
88
  }
87
89
  }
88
90
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"deepCopier.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/deepCopier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,CAAC,MAAW,EAAE,iBAAsB,EAAE,EAAE;IACvD,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IAED,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,EAAE,KAAK,MAAM,EAAE;QACzD,OAAO,IAAI,CAAC;KACf;IAED,IAAI,MAAM,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,EAAE,KAAK,aAAa,CAAC,EAAE;QACzG,OAAO,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;KAC1C;SAAM,IAAI,MAAM,CAAC,KAAK,EAAE;QACrB,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;KACzB;SAAM,IAAI,KAAK,C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C,OAAO,CAAC,CAAC;aAC1B;SACJ;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"./logger\";\r\n\r\nconst CloneValue = (source: any, destinationObject: any) => {\r\n if (!source) {\r\n return null;\r\n }\r\n\r\n if (source.getClassName && source.getClassName() === \"Mesh\") {\r\n return null;\r\n }\r\n\r\n if (source.getClassName && (source.getClassName() === \"SubMesh\" || source.getClassName() === \"PhysicsBody\")) {\r\n return source.clone(destinationObject);\r\n } else if (source.clone) {\r\n return source.clone();\r\n } else if (Array.isArray(source)) {\r\n return source.slice();\r\n } else if (typeof source === \"object\") {\r\n return { ...source };\r\n }\r\n return null;\r\n};\r\n\r\nfunction GetAllPropertyNames(obj: any): string[] {\r\n const props: string[] = [];\r\n\r\n do {\r\n Object.getOwnPropertyNames(obj).forEach(function (prop) {\r\n if (props.indexOf(prop) === -1) {\r\n props.push(prop);\r\n }\r\n });\r\n } while ((obj = Object.getPrototypeOf(obj)));\r\n\r\n return props;\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for deep copy.\r\n */\r\nexport class DeepCopier {\r\n /**\r\n * Tries to copy an object by duplicating every property\r\n * @param source defines the source object\r\n * @param destination defines the target object\r\n * @param doNotCopyList defines a list of properties to avoid\r\n * @param mustCopyList defines a list of properties to copy (even if they start with _)\r\n */\r\n public static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void {\r\n const properties = GetAllPropertyNames(source);\r\n for (const prop of properties) {\r\n if (prop[0] === \"_\" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {\r\n continue;\r\n }\r\n\r\n if (prop.endsWith(\"Observable\")) {\r\n continue;\r\n }\r\n\r\n if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {\r\n continue;\r\n }\r\n\r\n const sourceValue = source[prop];\r\n const typeOfSourceValue = typeof sourceValue;\r\n\r\n if (typeOfSourceValue === \"function\") {\r\n continue;\r\n }\r\n\r\n try {\r\n if (typeOfSourceValue === \"object\") {\r\n if (sourceValue instanceof Uint8Array) {\r\n destination[prop] = Uint8Array.from(sourceValue);\r\n } else if (sourceValue instanceof Array) {\r\n destination[prop] = [];\r\n\r\n if (sourceValue.length > 0) {\r\n if (typeof sourceValue[0] == \"object\") {\r\n for (let index = 0; index < sourceValue.length; index++) {\r\n const clonedValue = CloneValue(sourceValue[index], destination);\r\n\r\n if (destination[prop].indexOf(clonedValue) === -1) {\r\n // Test if auto inject was not done\r\n destination[prop].push(clonedValue);\r\n }\r\n }\r\n } else {\r\n destination[prop] = sourceValue.slice(0);\r\n }\r\n }\r\n } else {\r\n destination[prop] = CloneValue(sourceValue, destination);\r\n }\r\n } else {\r\n destination[prop] = sourceValue;\r\n }\r\n } catch (e) {\r\n // Log a warning (it could be because of a read-only property)\r\n Logger.Warn(e.message);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"deepCopier.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/deepCopier.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,UAAU,GAAG,CAAC,MAAW,EAAE,iBAAsB,EAAE,iBAA0B,EAAE,EAAE;IACnF,IAAI,CAAC,MAAM,EAAE;QACT,OAAO,IAAI,CAAC;KACf;IAED,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,EAAE,KAAK,MAAM,EAAE;QACzD,OAAO,IAAI,CAAC;KACf;IAED,IAAI,MAAM,CAAC,YAAY,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,KAAK,SAAS,IAAI,MAAM,CAAC,YAAY,EAAE,KAAK,aAAa,CAAC,EAAE;QACzG,OAAO,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;KAC1C;SAAM,IAAI,MAAM,CAAC,KAAK,EAAE;QACrB,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;KACzB;SAAM,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE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AC9D,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;aAC1B;SACJ;IACL,CAAC;CACJ","sourcesContent":["import { Logger } from \"./logger\";\r\n\r\nconst CloneValue = (source: any, destinationObject: any, shallowCopyValues: boolean) => {\r\n if (!source) {\r\n return null;\r\n }\r\n\r\n if (source.getClassName && source.getClassName() === \"Mesh\") {\r\n return null;\r\n }\r\n\r\n if (source.getClassName && (source.getClassName() === \"SubMesh\" || source.getClassName() === \"PhysicsBody\")) {\r\n return source.clone(destinationObject);\r\n } else if (source.clone) {\r\n return source.clone();\r\n } else if (Array.isArray(source)) {\r\n return source.slice();\r\n } else if (shallowCopyValues && typeof source === \"object\") {\r\n return { ...source };\r\n }\r\n return null;\r\n};\r\n\r\nfunction GetAllPropertyNames(obj: any): string[] {\r\n const props: string[] = [];\r\n\r\n do {\r\n Object.getOwnPropertyNames(obj).forEach(function (prop) {\r\n if (props.indexOf(prop) === -1) {\r\n props.push(prop);\r\n }\r\n });\r\n } while ((obj = Object.getPrototypeOf(obj)));\r\n\r\n return props;\r\n}\r\n\r\n/**\r\n * Class containing a set of static utilities functions for deep copy.\r\n */\r\nexport class DeepCopier {\r\n /**\r\n * Tries to copy an object by duplicating every property\r\n * @param source defines the source object\r\n * @param destination defines the target object\r\n * @param doNotCopyList defines a list of properties to avoid\r\n * @param mustCopyList defines a list of properties to copy (even if they start with _)\r\n * @param shallowCopyValues defines wether properties referencing objects (none cloneable) must be shallow copied (false by default)\r\n * @remarks shallowCopyValues will not instantite the copied values which makes it only usable for \"JSON objects\"\r\n */\r\n public static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[], shallowCopyValues = false): void {\r\n const properties = GetAllPropertyNames(source);\r\n for (const prop of properties) {\r\n if (prop[0] === \"_\" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {\r\n continue;\r\n }\r\n\r\n if (prop.endsWith(\"Observable\")) {\r\n continue;\r\n }\r\n\r\n if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {\r\n continue;\r\n }\r\n\r\n const sourceValue = source[prop];\r\n const typeOfSourceValue = typeof sourceValue;\r\n\r\n if (typeOfSourceValue === \"function\") {\r\n continue;\r\n }\r\n\r\n try {\r\n if (typeOfSourceValue === \"object\") {\r\n if (sourceValue instanceof Uint8Array) {\r\n destination[prop] = Uint8Array.from(sourceValue);\r\n } else if (sourceValue instanceof Array) {\r\n destination[prop] = [];\r\n\r\n if (sourceValue.length > 0) {\r\n if (typeof sourceValue[0] == \"object\") {\r\n for (let index = 0; index < sourceValue.length; index++) {\r\n const clonedValue = CloneValue(sourceValue[index], destination, shallowCopyValues);\r\n\r\n if (destination[prop].indexOf(clonedValue) === -1) {\r\n // Test if auto inject was not done\r\n destination[prop].push(clonedValue);\r\n }\r\n }\r\n } else {\r\n destination[prop] = sourceValue.slice(0);\r\n }\r\n }\r\n } else {\r\n destination[prop] = CloneValue(sourceValue, destination, shallowCopyValues);\r\n }\r\n } else {\r\n destination[prop] = sourceValue;\r\n }\r\n } catch (e) {\r\n // Log a warning (it could be because of a read-only property)\r\n Logger.Warn(e.message);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -154,13 +154,17 @@ export declare class Observable<T> {
154
154
  * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
155
155
  * @returns the new observer created for the callback
156
156
  */
157
- add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
157
+ add(callback?: null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;
158
+ add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;
159
+ add(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
158
160
  /**
159
161
  * Create a new Observer with the specified callback and unregisters after the next notification
160
162
  * @param callback the callback that will be executed for that Observer
161
163
  * @returns the new observer created for the callback
162
164
  */
163
- addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
165
+ addOnce(callback?: null | undefined): null;
166
+ addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;
167
+ addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null | undefined): Nullable<Observer<T>>;
164
168
  /**
165
169
  * Remove an Observer from the Observable object
166
170
  * @param observer the instance of the Observer to remove
@@ -135,15 +135,6 @@ export class Observable {
135
135
  this._onObserverAdded = onObserverAdded;
136
136
  }
137
137
  }
138
- /**
139
- * Create a new Observer with the specified callback
140
- * @param callback the callback that will be executed for that Observer
141
- * @param mask the mask used to filter observers
142
- * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
143
- * @param scope optional scope for the callback to be called from
144
- * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
145
- * @returns the new observer created for the callback
146
- */
147
138
  add(callback, mask = -1, insertFirst = false, scope = null, unregisterOnFirstCall = false) {
148
139
  if (!callback) {
149
140
  return null;
@@ -171,11 +162,6 @@ export class Observable {
171
162
  };
172
163
  return observer;
173
164
  }
174
- /**
175
- * Create a new Observer with the specified callback and unregisters after the next notification
176
- * @param callback the callback that will be executed for that Observer
177
- * @returns the new observer created for the callback
178
- */
179
165
  addOnce(callback) {
180
166
  return this.add(callback, undefined, undefined, undefined, true);
181
167
  }