@babylonjs/core 7.13.1 → 7.13.3

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 (76) hide show
  1. package/Animations/animationGroupMask.d.ts +1 -1
  2. package/Animations/animationKey.d.ts +1 -1
  3. package/Behaviors/Meshes/handConstraintBehavior.d.ts +3 -3
  4. package/Cameras/Inputs/flyCameraMouseInput.d.ts +0 -1
  5. package/Cameras/Inputs/flyCameraMouseInput.js +0 -1
  6. package/Cameras/Inputs/flyCameraMouseInput.js.map +1 -1
  7. package/Cameras/arcRotateCamera.d.ts +5 -0
  8. package/Cameras/arcRotateCamera.js +45 -0
  9. package/Cameras/arcRotateCamera.js.map +1 -1
  10. package/Cameras/camera.d.ts +5 -0
  11. package/Cameras/camera.js +7 -0
  12. package/Cameras/camera.js.map +1 -1
  13. package/Collisions/gpuPicker.d.ts +1 -0
  14. package/Collisions/gpuPicker.js +1 -0
  15. package/Collisions/gpuPicker.js.map +1 -1
  16. package/Debug/debugLayer.d.ts +1 -1
  17. package/Decorators/nodeDecorator.d.ts +1 -1
  18. package/DeviceInput/InputDevices/deviceEnums.d.ts +5 -5
  19. package/Engines/Extensions/engine.computeShader.d.ts +1 -1
  20. package/Engines/WebGPU/webgpuConstants.d.ts +39 -39
  21. package/Engines/abstractEngine.js +2 -2
  22. package/Engines/abstractEngine.js.map +1 -1
  23. package/Events/deviceInputEvents.d.ts +1 -1
  24. package/FlowGraph/flowGraph.d.ts +1 -1
  25. package/FlowGraph/flowGraphConnection.d.ts +1 -1
  26. package/Gamepads/dualShockGamepad.d.ts +2 -2
  27. package/Gamepads/xboxGamepad.d.ts +2 -2
  28. package/Gizmos/gizmo.d.ts +2 -2
  29. package/Loading/sceneLoader.d.ts +1 -1
  30. package/Materials/GreasedLine/greasedLineMaterialInterfaces.d.ts +3 -3
  31. package/Materials/Node/Blocks/meshAttributeExistsBlock.d.ts +1 -1
  32. package/Materials/Node/Blocks/waveBlock.d.ts +1 -1
  33. package/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode.d.ts +1 -1
  34. package/Materials/Node/nodeMaterialBlockConnectionPoint.d.ts +2 -2
  35. package/Materials/Textures/internalTexture.d.ts +1 -1
  36. package/Materials/Textures/ktx2decoderTypes.d.ts +1 -1
  37. package/Materials/materialPluginEvent.d.ts +1 -1
  38. package/Materials/meshDebugPluginMaterial.d.ts +1 -1
  39. package/Materials/shaderLanguage.d.ts +1 -1
  40. package/Maths/math.axis.d.ts +2 -2
  41. package/Maths/math.path.d.ts +1 -1
  42. package/Maths/math.vector.d.ts +9 -0
  43. package/Maths/math.vector.js +14 -3
  44. package/Maths/math.vector.js.map +1 -1
  45. package/Meshes/Builders/greasedLineBuilder.d.ts +2 -2
  46. package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +3 -3
  47. package/Meshes/Node/nodeGeometryBlockConnectionPoint.d.ts +2 -2
  48. package/Meshes/csg.js +12 -0
  49. package/Meshes/csg.js.map +1 -1
  50. package/Meshes/meshSimplification.d.ts +1 -1
  51. package/Misc/assetsManager.d.ts +1 -1
  52. package/Misc/asyncLock.d.ts +24 -0
  53. package/Misc/asyncLock.js +32 -0
  54. package/Misc/asyncLock.js.map +1 -0
  55. package/Misc/copyTextureToTexture.d.ts +1 -1
  56. package/Misc/iInspectable.d.ts +1 -1
  57. package/Misc/index.d.ts +1 -0
  58. package/Misc/index.js +1 -0
  59. package/Misc/index.js.map +1 -1
  60. package/Misc/timer.d.ts +1 -1
  61. package/Misc/virtualJoystick.d.ts +1 -1
  62. package/Particles/gpuParticleSystem.js +1 -0
  63. package/Particles/gpuParticleSystem.js.map +1 -1
  64. package/Particles/pointsCloudSystem.d.ts +1 -1
  65. package/Particles/subEmitter.d.ts +1 -1
  66. package/Physics/physicsHelper.d.ts +2 -2
  67. package/Physics/v2/IPhysicsEnginePlugin.d.ts +8 -8
  68. package/Physics/v2/physicsMaterial.d.ts +1 -1
  69. package/PostProcesses/depthOfFieldEffect.d.ts +1 -1
  70. package/PostProcesses/tonemapPostProcess.d.ts +1 -1
  71. package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +1 -1
  72. package/XR/features/WebXRHandTracking.d.ts +2 -2
  73. package/XR/features/WebXRNearInteraction.d.ts +1 -1
  74. package/XR/webXRTypes.d.ts +2 -2
  75. package/package.json +1 -1
  76. package/scene.d.ts +1 -1
@@ -12,7 +12,7 @@ import type { GreasedLineMaterialOptions } from "../../Materials/GreasedLine/gre
12
12
  * How are the colors distributed along the color table
13
13
  * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#colors-and-colordistribution}
14
14
  */
15
- export declare const enum GreasedLineMeshColorDistribution {
15
+ export declare enum GreasedLineMeshColorDistribution {
16
16
  /**
17
17
  * Do no modify the color table
18
18
  */
@@ -42,7 +42,7 @@ export declare const enum GreasedLineMeshColorDistribution {
42
42
  * How are the widths distributed along the width table
43
43
  * {@link https://doc.babylonjs.com/features/featuresDeepDive/mesh/creation/param/greased_line#widths-and-widthdistribution}
44
44
  */
45
- export declare const enum GreasedLineMeshWidthDistribution {
45
+ export declare enum GreasedLineMeshWidthDistribution {
46
46
  /**
47
47
  * Do no modify the width table
48
48
  */
@@ -10,7 +10,7 @@ import type { FloatArray, IndicesArray } from "../../types";
10
10
  * In POINTS_MODE_POINTS every array of points will become the center (backbone) of the ribbon. The ribbon will be expanded by `width / 2` to `+direction` and `-direction` as well.
11
11
  * In POINTS_MODE_PATHS every array of points specifies an edge. These will be used to build one ribbon.
12
12
  */
13
- export declare const enum GreasedLineRibbonPointsMode {
13
+ export declare enum GreasedLineRibbonPointsMode {
14
14
  POINTS_MODE_POINTS = 0,
15
15
  POINTS_MODE_PATHS = 1
16
16
  }
@@ -19,7 +19,7 @@ export declare const enum GreasedLineRibbonPointsMode {
19
19
  * FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING single sided without back face culling. Sets backFaceCulling = false on the material so it affects all line ribbons added to the line ribbon instance.
20
20
  * FACES_MODE_DOUBLE_SIDED extra back faces are created. This doubles the amount of faces of the mesh.
21
21
  */
22
- export declare const enum GreasedLineRibbonFacesMode {
22
+ export declare enum GreasedLineRibbonFacesMode {
23
23
  FACES_MODE_SINGLE_SIDED = 0,
24
24
  FACES_MODE_SINGLE_SIDED_NO_BACKFACE_CULLING = 1,
25
25
  FACES_MODE_DOUBLE_SIDED = 2
@@ -32,7 +32,7 @@ export declare const enum GreasedLineRibbonFacesMode {
32
32
  * AUTO_DIRECTIONS_FACE_TO in this mode the direction (slope) will be calculated for each line segment according to the direction vector between each point of the line segments and a direction (face-to) vector specified in direction. The resulting line will face to the direction of this face-to vector.
33
33
  * AUTO_DIRECTIONS_NONE you have to set the direction (slope) manually. Recommended.
34
34
  */
35
- export declare const enum GreasedLineRibbonAutoDirectionMode {
35
+ export declare enum GreasedLineRibbonAutoDirectionMode {
36
36
  AUTO_DIRECTIONS_FROM_FIRST_SEGMENT = 0,
37
37
  AUTO_DIRECTIONS_FROM_ALL_SEGMENTS = 1,
38
38
  AUTO_DIRECTIONS_ENHANCED = 2,
@@ -6,7 +6,7 @@ import type { NodeGeometryBuildState } from "./nodeGeometryBuildState";
6
6
  /**
7
7
  * Enum used to define the compatibility state between two connection points
8
8
  */
9
- export declare const enum NodeGeometryConnectionPointCompatibilityStates {
9
+ export declare enum NodeGeometryConnectionPointCompatibilityStates {
10
10
  /** Points are compatibles */
11
11
  Compatible = 0,
12
12
  /** Points are incompatible because of their types */
@@ -17,7 +17,7 @@ export declare const enum NodeGeometryConnectionPointCompatibilityStates {
17
17
  /**
18
18
  * Defines the direction of a connection point
19
19
  */
20
- export declare const enum NodeGeometryConnectionPointDirection {
20
+ export declare enum NodeGeometryConnectionPointDirection {
21
21
  /** Input */
22
22
  Input = 0,
23
23
  /** Output */
package/Meshes/csg.js CHANGED
@@ -456,6 +456,18 @@ export class CSG {
456
456
  throw "BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";
457
457
  }
458
458
  const indices = mesh.getIndices(), positions = mesh.getVerticesData(VertexBuffer.PositionKind), normals = mesh.getVerticesData(VertexBuffer.NormalKind), uvs = mesh.getVerticesData(VertexBuffer.UVKind), vertColors = mesh.getVerticesData(VertexBuffer.ColorKind);
459
+ if (indices === null) {
460
+ // eslint-disable-next-line no-throw-literal
461
+ throw "BABYLON.CSG: Mesh has no indices";
462
+ }
463
+ if (positions === null) {
464
+ // eslint-disable-next-line no-throw-literal
465
+ throw "BABYLON.CSG: Mesh has no positions";
466
+ }
467
+ if (normals === null) {
468
+ // eslint-disable-next-line no-throw-literal
469
+ throw "BABYLON.CSG: Mesh has no normals";
470
+ }
459
471
  const subMeshes = mesh.subMeshes;
460
472
  for (let sm = 0, sml = subMeshes.length; sm < sml; sm++) {
461
473
  for (let i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
package/Meshes/csg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"csg.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C;;GAEG;AACH,IAAI,gBAAgB,GAAG,CAAC,CAAC;AAEzB;;;;;;;;;GASG;AACH,MAAM,MAAM;IACR;;;;;;OAMG;IACH;IACI;;OAEG;IACI,GAAY;IACnB;;OAEG;IACI,MAAe;IACtB;;OAEG;I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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 * @returns The new interpolated vertex\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 * @returns A new plane\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 * @returns A new CSGPolygon\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: CSGPolygon[] = [],\r\n back = [] as 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: CSGPolygon[] = [],\r\n back = [] as 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 data 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: 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 // eslint-disable-next-line no-throw-literal\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: 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 // eslint-disable-next-line no-throw-literal\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 * @returns A new 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 * @param onBeforePolygonProcessing called before each polygon is being processed\r\n * @param onAfterPolygonProcessing called after each polygon has been processed\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 = [] as 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"]}
1
+ {"version":3,"file":"csg.js","sourceRoot":"","sources":["../../../../dev/core/src/Meshes/csg.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEt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AC;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 } 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 * @returns The new interpolated vertex\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 * @returns A new plane\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 * @returns A new CSGPolygon\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: CSGPolygon[] = [],\r\n back = [] as 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: CSGPolygon[] = [],\r\n back = [] as 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 data 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: 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 // eslint-disable-next-line no-throw-literal\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: 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 // eslint-disable-next-line no-throw-literal\r\n throw \"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh\";\r\n }\r\n\r\n const indices = mesh.getIndices(),\r\n positions = mesh.getVerticesData(VertexBuffer.PositionKind),\r\n normals = mesh.getVerticesData(VertexBuffer.NormalKind),\r\n uvs = mesh.getVerticesData(VertexBuffer.UVKind),\r\n vertColors = mesh.getVerticesData(VertexBuffer.ColorKind);\r\n\r\n if (indices === null) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"BABYLON.CSG: Mesh has no indices\";\r\n }\r\n if (positions === null) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"BABYLON.CSG: Mesh has no positions\";\r\n }\r\n if (normals === null) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"BABYLON.CSG: Mesh has no normals\";\r\n }\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 * @returns A new 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 * @param onBeforePolygonProcessing called before each polygon is being processed\r\n * @param onAfterPolygonProcessing called after each polygon has been processed\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 = [] as 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"]}
@@ -117,7 +117,7 @@ export declare class SimplificationQueue {
117
117
  * At the moment only Quadratic Error Decimation is implemented
118
118
  * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/simplifyingMeshes
119
119
  */
120
- export declare const enum SimplificationType {
120
+ export declare enum SimplificationType {
121
121
  /** Quadratic error decimation */
122
122
  QUADRATIC = 0
123
123
  }
@@ -16,7 +16,7 @@ import type { Nullable } from "../types";
16
16
  /**
17
17
  * Defines the list of states available for a task inside a AssetsManager
18
18
  */
19
- export declare const enum AssetTaskState {
19
+ export declare enum AssetTaskState {
20
20
  /**
21
21
  * Initialization
22
22
  */
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Provides a simple way of creating the rough equivalent of an async critical section.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const myLock = new AsyncLock();
7
+ *
8
+ * private async MyFuncAsync(): Promise<void> {
9
+ * await myLock.lockAsync(async () => {
10
+ * await operation1Async();
11
+ * await operation2Async();
12
+ * });
13
+ * }
14
+ * ```
15
+ */
16
+ export declare class AsyncLock {
17
+ private _currentOperation;
18
+ /**
19
+ * Executes the func when the lock is acquired (e.g. when the previous operation finishes).
20
+ * @param func The function to execute.
21
+ * @returns A promise that resolves when the func finishes executing.
22
+ */
23
+ lockAsync<T>(func: () => T | Promise<T>): Promise<T>;
24
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Provides a simple way of creating the rough equivalent of an async critical section.
3
+ *
4
+ * @example
5
+ * ```typescript
6
+ * const myLock = new AsyncLock();
7
+ *
8
+ * private async MyFuncAsync(): Promise<void> {
9
+ * await myLock.lockAsync(async () => {
10
+ * await operation1Async();
11
+ * await operation2Async();
12
+ * });
13
+ * }
14
+ * ```
15
+ */
16
+ export class AsyncLock {
17
+ constructor() {
18
+ this._currentOperation = Promise.resolve();
19
+ }
20
+ /**
21
+ * Executes the func when the lock is acquired (e.g. when the previous operation finishes).
22
+ * @param func The function to execute.
23
+ * @returns A promise that resolves when the func finishes executing.
24
+ */
25
+ lockAsync(func) {
26
+ const newOperation = this._currentOperation.then(func);
27
+ // NOTE: It would be simpler to just hold a Promise<unknown>, but this class should not prevent an object held by the returned promise from being garbage collected.
28
+ this._currentOperation = new Promise((resolve) => newOperation.then(() => resolve(), resolve));
29
+ return newOperation;
30
+ }
31
+ }
32
+ //# sourceMappingURL=asyncLock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asyncLock.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/asyncLock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,SAAS;IAAtB;QACY,sBAAiB,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAC;IAajE,CAAC;IAXG;;;;OAIG;IACI,SAAS,CAAI,IAA0B;QAC1C,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvD,oKAAoK;QACpK,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QACrG,OAAO,YAAY,CAAC;IACxB,CAAC;CACJ","sourcesContent":["/**\r\n * Provides a simple way of creating the rough equivalent of an async critical section.\r\n *\r\n * @example\r\n * ```typescript\r\n * const myLock = new AsyncLock();\r\n *\r\n * private async MyFuncAsync(): Promise<void> {\r\n * await myLock.lockAsync(async () => {\r\n * await operation1Async();\r\n * await operation2Async();\r\n * });\r\n * }\r\n * ```\r\n */\r\nexport class AsyncLock {\r\n private _currentOperation: Promise<void> = Promise.resolve();\r\n\r\n /**\r\n * Executes the func when the lock is acquired (e.g. when the previous operation finishes).\r\n * @param func The function to execute.\r\n * @returns A promise that resolves when the func finishes executing.\r\n */\r\n public lockAsync<T>(func: () => T | Promise<T>): Promise<T> {\r\n const newOperation = this._currentOperation.then(func);\r\n // NOTE: It would be simpler to just hold a Promise<unknown>, but this class should not prevent an object held by the returned promise from being garbage collected.\r\n this._currentOperation = new Promise<void>((resolve) => newOperation.then(() => resolve(), resolve));\r\n return newOperation;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,7 @@ import "../Shaders/copyTextureToTexture.fragment";
6
6
  /**
7
7
  * Conversion modes available when copying a texture into another one
8
8
  */
9
- export declare const enum ConversionMode {
9
+ export declare enum ConversionMode {
10
10
  None = 0,
11
11
  ToLinearSpace = 1,
12
12
  ToGammaSpace = 2
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Enum that determines the text-wrapping mode to use.
3
3
  */
4
- export declare const enum InspectableType {
4
+ export declare enum InspectableType {
5
5
  /**
6
6
  * Checkbox for booleans
7
7
  */
package/Misc/index.d.ts CHANGED
@@ -65,3 +65,4 @@ export * from "./dumpTools";
65
65
  export * from "./greasedLineTools";
66
66
  export * from "./equirectangularCapture";
67
67
  export * from "./decorators.serialization";
68
+ export * from "./asyncLock";
package/Misc/index.js CHANGED
@@ -67,4 +67,5 @@ export * from "./dumpTools.js";
67
67
  export * from "./greasedLineTools.js";
68
68
  export * from "./equirectangularCapture.js";
69
69
  export * from "./decorators.serialization.js";
70
+ export * from "./asyncLock.js";
70
71
  //# sourceMappingURL=index.js.map
package/Misc/index.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AACzC,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,2BAA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AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,yCAAyC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC","sourcesContent":["/* eslint-disable import/no-internal-modules */\r\nexport * from \"./andOrNotEvaluator\";\r\nexport * from \"./assetsManager\";\r\nexport * from \"./basis\";\r\nexport * from \"./dds\";\r\nexport * from \"./decorators\";\r\nexport * from \"./deferred\";\r\nexport * from \"./environmentTextureTools\";\r\nexport * from \"./meshExploder\";\r\nexport * from \"./filesInput\";\r\nexport * from \"./HighDynamicRange/index\";\r\nexport * from \"./khronosTextureContainer\";\r\nexport * from \"./observable\";\r\nexport * from \"./observable.extensions\";\r\nexport * from \"./performanceMonitor\";\r\nexport * from \"./sceneOptimizer\";\r\nexport * from \"./sceneSerializer\";\r\nexport * from \"./smartArray\";\r\nexport * from \"./stringDictionary\";\r\nexport * from \"./tags\";\r\nexport * from \"./textureTools\";\r\nexport * from \"./tga\";\r\nexport * from \"./tools\";\r\nexport * from \"./videoRecorder\";\r\nexport * from \"./virtualJoystick\";\r\nexport * from \"./workerPool\";\r\nexport * from \"./logger\";\r\nexport * from \"./typeStore\";\r\nexport * from \"./filesInputStore\";\r\nexport * from \"./deepCopier\";\r\nexport * from \"./pivotTools\";\r\nexport * from \"./precisionDate\";\r\nexport * from \"./screenshotTools\";\r\nexport * from \"./webRequest\";\r\nexport * from \"./iInspectable\";\r\nexport * from \"./brdfTextureTools\";\r\nexport * from \"./rgbdTextureTools\";\r\nexport * from \"./gradients\";\r\nexport * from \"./perfCounter\";\r\nexport * from \"./fileRequest\";\r\nexport * from \"./customAnimationFrameRequester\";\r\nexport * from \"./retryStrategy\";\r\nexport * from \"./interfaces/screenshotSize\";\r\nexport * from \"./interfaces/iPerfViewer\";\r\nexport * from \"./fileTools\";\r\nexport * from \"./stringTools\";\r\nexport * from \"./dataReader\";\r\nexport * from \"./minMaxReducer\";\r\nexport * from \"./depthReducer\";\r\nexport * from \"./dataStorage\";\r\nexport * from \"./sceneRecorder\";\r\nexport * from \"./khronosTextureContainer2\";\r\nexport * from \"./trajectoryClassifier\";\r\nexport * from \"./timer\";\r\nexport * from \"./copyTools\";\r\nexport * from \"./reflector\";\r\nexport * from \"./domManagement\";\r\nexport * from \"./pressureObserverWrapper\";\r\nexport * from \"./PerformanceViewer/index\";\r\nexport * from \"./coroutine\";\r\nexport * from \"./guid\";\r\nexport * from \"./error\";\r\n// eslint-disable-next-line import/export\r\nexport * from \"./observableCoroutine\";\r\nexport * from \"./copyTextureToTexture\";\r\nexport * from \"./dumpTools\";\r\nexport * from \"./greasedLineTools\";\r\nexport * from \"./equirectangularCapture\";\r\nexport * from \"./decorators.serialization\";\r\nexport * from \"./asyncLock\";\r\n"]}
package/Misc/timer.d.ts CHANGED
@@ -70,7 +70,7 @@ export interface ITimerData<T> {
70
70
  /**
71
71
  * The current state of the timer
72
72
  */
73
- export declare const enum TimerState {
73
+ export declare enum TimerState {
74
74
  /**
75
75
  * Timer initialized, not yet started
76
76
  */
@@ -3,7 +3,7 @@ import { Vector3 } from "../Maths/math.vector";
3
3
  /**
4
4
  * Defines the potential axis of a Joystick
5
5
  */
6
- export declare const enum JoystickAxis {
6
+ export declare enum JoystickAxis {
7
7
  /** X axis */
8
8
  X = 0,
9
9
  /** Y axis */
@@ -262,6 +262,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
262
262
  if (this._stopped) {
263
263
  return;
264
264
  }
265
+ this.onStoppedObservable.notifyObservers(this);
265
266
  this._stopped = true;
266
267
  }
267
268
  /**