@babylonjs/core 7.9.0 → 7.10.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 (98) hide show
  1. package/Behaviors/Cameras/framingBehavior.d.ts +1 -1
  2. package/Behaviors/Cameras/framingBehavior.js +1 -1
  3. package/Behaviors/Cameras/framingBehavior.js.map +1 -1
  4. package/Behaviors/Meshes/baseSixDofDragBehavior.d.ts +5 -5
  5. package/Behaviors/Meshes/baseSixDofDragBehavior.js +4 -4
  6. package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
  7. package/Collisions/gpuPicker.d.ts +38 -0
  8. package/Collisions/gpuPicker.js +256 -0
  9. package/Collisions/gpuPicker.js.map +1 -0
  10. package/Collisions/index.d.ts +1 -0
  11. package/Collisions/index.js +1 -0
  12. package/Collisions/index.js.map +1 -1
  13. package/Debug/physicsViewer.d.ts +4 -2
  14. package/Debug/physicsViewer.js +16 -4
  15. package/Debug/physicsViewer.js.map +1 -1
  16. package/Engines/Extensions/engine.views.d.ts +1 -0
  17. package/Engines/Extensions/engine.views.js +3 -0
  18. package/Engines/Extensions/engine.views.js.map +1 -0
  19. package/Engines/abstractEngine.js +2 -2
  20. package/Engines/abstractEngine.js.map +1 -1
  21. package/Engines/thinEngine.js +8 -7
  22. package/Engines/thinEngine.js.map +1 -1
  23. package/Gizmos/boundingBoxGizmo.d.ts +6 -5
  24. package/Gizmos/boundingBoxGizmo.js +5 -5
  25. package/Gizmos/boundingBoxGizmo.js.map +1 -1
  26. package/Gizmos/lightGizmo.js +1 -2
  27. package/Gizmos/lightGizmo.js.map +1 -1
  28. package/Helpers/environmentHelper.js +2 -0
  29. package/Helpers/environmentHelper.js.map +1 -1
  30. package/Materials/Node/nodeMaterial.d.ts +2 -2
  31. package/Materials/Node/nodeMaterial.js +4 -4
  32. package/Materials/Node/nodeMaterial.js.map +1 -1
  33. package/Materials/material.d.ts +1 -1
  34. package/Materials/material.js.map +1 -1
  35. package/Materials/pushMaterial.d.ts +1 -1
  36. package/Materials/pushMaterial.js.map +1 -1
  37. package/Materials/shaderMaterial.d.ts +6 -1
  38. package/Materials/shaderMaterial.js +8 -1
  39. package/Materials/shaderMaterial.js.map +1 -1
  40. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +0 -2
  41. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  42. package/Meshes/Node/Blocks/mergeGeometryBlock.js +15 -11
  43. package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
  44. package/Meshes/abstractMesh.d.ts +6 -16
  45. package/Meshes/abstractMesh.js +5 -21
  46. package/Meshes/abstractMesh.js.map +1 -1
  47. package/Meshes/mesh.vertexData.js +19 -1
  48. package/Meshes/mesh.vertexData.js.map +1 -1
  49. package/Meshes/transformNode.d.ts +14 -0
  50. package/Meshes/transformNode.js +20 -0
  51. package/Meshes/transformNode.js.map +1 -1
  52. package/Particles/EmitterTypes/coneParticleEmitter.d.ts +60 -0
  53. package/Particles/EmitterTypes/coneParticleEmitter.js +88 -0
  54. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  55. package/Particles/IParticleSystem.d.ts +2 -1
  56. package/Particles/IParticleSystem.js.map +1 -1
  57. package/Particles/baseParticleSystem.d.ts +2 -1
  58. package/Particles/baseParticleSystem.js +3 -0
  59. package/Particles/baseParticleSystem.js.map +1 -1
  60. package/Particles/gpuParticleSystem.d.ts +2 -1
  61. package/Particles/gpuParticleSystem.js +6 -1
  62. package/Particles/gpuParticleSystem.js.map +1 -1
  63. package/Particles/particleSystem.d.ts +2 -1
  64. package/Particles/particleSystem.functions.d.ts +2 -1
  65. package/Particles/particleSystem.functions.js +4 -1
  66. package/Particles/particleSystem.functions.js.map +1 -1
  67. package/Particles/particleSystem.js +10 -2
  68. package/Particles/particleSystem.js.map +1 -1
  69. package/Physics/v2/IPhysicsEnginePlugin.d.ts +3 -0
  70. package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -1
  71. package/Physics/v2/Plugins/havokPlugin.d.ts +14 -0
  72. package/Physics/v2/Plugins/havokPlugin.js +42 -18
  73. package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
  74. package/Physics/v2/physicsEngine.d.ts +14 -0
  75. package/Physics/v2/physicsEngine.js +20 -0
  76. package/Physics/v2/physicsEngine.js.map +1 -1
  77. package/Rendering/edgesRenderer.js +2 -1
  78. package/Rendering/edgesRenderer.js.map +1 -1
  79. package/Shaders/ShadersInclude/lineUboDeclaration.d.ts +7 -0
  80. package/Shaders/ShadersInclude/lineUboDeclaration.js +14 -0
  81. package/Shaders/ShadersInclude/lineUboDeclaration.js.map +1 -0
  82. package/Shaders/ShadersInclude/lineVertexDeclaration.d.ts +5 -0
  83. package/Shaders/ShadersInclude/lineVertexDeclaration.js +11 -0
  84. package/Shaders/ShadersInclude/lineVertexDeclaration.js.map +1 -0
  85. package/Shaders/gpuUpdateParticles.vertex.js +12 -2
  86. package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
  87. package/Shaders/line.vertex.d.ts +2 -0
  88. package/Shaders/line.vertex.js +5 -2
  89. package/Shaders/line.vertex.js.map +1 -1
  90. package/ShadersWGSL/gpuUpdateParticles.compute.js +11 -1
  91. package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
  92. package/XR/features/WebXRControllerMovement.d.ts +14 -1
  93. package/XR/features/WebXRControllerMovement.js +21 -3
  94. package/XR/features/WebXRControllerMovement.js.map +1 -1
  95. package/XR/webXRInputSource.d.ts +1 -1
  96. package/XR/webXRInputSource.js +3 -3
  97. package/XR/webXRInputSource.js.map +1 -1
  98. package/package.json +1 -1
@@ -74,6 +74,20 @@ export declare class PhysicsEngine implements IPhysicsEngine {
74
74
  * @returns the name of the plugin
75
75
  */
76
76
  getPhysicsPluginName(): string;
77
+ /**
78
+ * Set the maximum allowed linear and angular velocities
79
+ * @param maxLinearVelocity maximum allowed linear velocity
80
+ * @param maxAngularVelocity maximum allowed angular velocity
81
+ */
82
+ setVelocityLimits(maxLinearVelocity: number, maxAngularVelocity: number): void;
83
+ /**
84
+ * @returns maximum allowed linear velocity
85
+ */
86
+ getMaxLinearVelocity(): number;
87
+ /**
88
+ * @returns maximum allowed angular velocity
89
+ */
90
+ getMaxAngularVelocity(): number;
77
91
  /**
78
92
  * Adding a new impostor for the impostor tracking.
79
93
  * This will be done by the impostor itself.
@@ -90,6 +90,26 @@ export class PhysicsEngine {
90
90
  getPhysicsPluginName() {
91
91
  return this._physicsPlugin.name;
92
92
  }
93
+ /**
94
+ * Set the maximum allowed linear and angular velocities
95
+ * @param maxLinearVelocity maximum allowed linear velocity
96
+ * @param maxAngularVelocity maximum allowed angular velocity
97
+ */
98
+ setVelocityLimits(maxLinearVelocity, maxAngularVelocity) {
99
+ this._physicsPlugin.setVelocityLimits(maxLinearVelocity, maxAngularVelocity);
100
+ }
101
+ /**
102
+ * @returns maximum allowed linear velocity
103
+ */
104
+ getMaxLinearVelocity() {
105
+ return this._physicsPlugin.getMaxLinearVelocity();
106
+ }
107
+ /**
108
+ * @returns maximum allowed angular velocity
109
+ */
110
+ getMaxAngularVelocity() {
111
+ return this._physicsPlugin.getMaxAngularVelocity();
112
+ }
93
113
  /**
94
114
  * Adding a new impostor for the impostor tracking.
95
115
  * This will be done by the impostor itself.
@@ -1 +1 @@
1
- {"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,aAAa;IAUtB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD,uDAAuD;IACvD;;;OAGG;IACI,M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type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport type { IRaycastQuery } from \"../physicsRaycastResult\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n // eslint-disable-next-line jsdoc/require-returns-check\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(\r\n gravity: Nullable<Vector3>,\r\n private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()\r\n ) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * Unit is seconds.\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param physicsBody The body to add\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n * @param physicsBody The body to remove from the simulation\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * @returns an array of bodies added to this engine\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n * @param query raycast query object\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void {\r\n this._physicsPlugin.raycast(from, to, result, query);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param query raycast query object\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3, query?: IRaycastQuery): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result, query);\r\n return result;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"physicsEngine.js","sourceRoot":"","sources":["../../../../../dev/core/src/Physics/v2/physicsEngine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAIlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;GAGG;AACH,MAAM,OAAO,aAAa;IAUtB;;;OAGG;IACI,gBAAgB;QACnB,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,EAAE,CAAC;IAClD,CAAC;IACD,uDAAuD;IACvD;;;OAGG;IACI,M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C,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CAAC,IAAa,EAAE,EAAW,EAAE,KAAqB;QAC5D,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC1C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../types\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport type { IPhysicsEngine } from \"../IPhysicsEngine\";\r\nimport type { IPhysicsEnginePluginV2 } from \"./IPhysicsEnginePlugin\";\r\nimport type { IRaycastQuery } from \"../physicsRaycastResult\";\r\nimport { PhysicsRaycastResult } from \"../physicsRaycastResult\";\r\nimport { _WarnImport } from \"../../Misc/devTools\";\r\nimport type { PhysicsBody } from \"./physicsBody\";\r\n\r\n/**\r\n * Class used to control physics engine\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine\r\n */\r\nexport class PhysicsEngine implements IPhysicsEngine {\r\n /** @internal */\r\n private _physicsBodies: Array<PhysicsBody> = [];\r\n private _subTimeStep: number = 0;\r\n\r\n /**\r\n * Gets the gravity vector used by the simulation\r\n */\r\n public gravity: Vector3;\r\n\r\n /**\r\n *\r\n * @returns physics plugin version\r\n */\r\n public getPluginVersion(): number {\r\n return this._physicsPlugin.getPluginVersion();\r\n }\r\n // eslint-disable-next-line jsdoc/require-returns-check\r\n /**\r\n * Factory used to create the default physics plugin.\r\n * @returns The default physics plugin\r\n */\r\n public static DefaultPluginFactory(): IPhysicsEnginePluginV2 {\r\n throw _WarnImport(\"\");\r\n }\r\n\r\n /**\r\n * Creates a new Physics Engine\r\n * @param gravity defines the gravity vector used by the simulation\r\n * @param _physicsPlugin defines the plugin to use (CannonJS by default)\r\n */\r\n constructor(\r\n gravity: Nullable<Vector3>,\r\n private _physicsPlugin: IPhysicsEnginePluginV2 = PhysicsEngine.DefaultPluginFactory()\r\n ) {\r\n gravity = gravity || new Vector3(0, -9.807, 0);\r\n this.setGravity(gravity);\r\n this.setTimeStep();\r\n }\r\n\r\n /**\r\n * Sets the gravity vector used by the simulation\r\n * @param gravity defines the gravity vector to use\r\n */\r\n public setGravity(gravity: Vector3): void {\r\n this.gravity = gravity;\r\n this._physicsPlugin.setGravity(this.gravity);\r\n }\r\n\r\n /**\r\n * Set the time step of the physics engine.\r\n * Default is 1/60.\r\n * To slow it down, enter 1/600 for example.\r\n * To speed it up, 1/30\r\n * Unit is seconds.\r\n * @param newTimeStep defines the new timestep to apply to this world.\r\n */\r\n public setTimeStep(newTimeStep: number = 1 / 60) {\r\n this._physicsPlugin.setTimeStep(newTimeStep);\r\n }\r\n\r\n /**\r\n * Get the time step of the physics engine.\r\n * @returns the current time step\r\n */\r\n public getTimeStep(): number {\r\n return this._physicsPlugin.getTimeStep();\r\n }\r\n\r\n /**\r\n * Set the sub time step of the physics engine.\r\n * Default is 0 meaning there is no sub steps\r\n * To increase physics resolution precision, set a small value (like 1 ms)\r\n * @param subTimeStep defines the new sub timestep used for physics resolution.\r\n */\r\n public setSubTimeStep(subTimeStep: number = 0) {\r\n this._subTimeStep = subTimeStep;\r\n }\r\n\r\n /**\r\n * Get the sub time step of the physics engine.\r\n * @returns the current sub time step\r\n */\r\n public getSubTimeStep() {\r\n return this._subTimeStep;\r\n }\r\n\r\n /**\r\n * Release all resources\r\n */\r\n public dispose(): void {\r\n this._physicsPlugin.dispose();\r\n }\r\n\r\n /**\r\n * Gets the name of the current physics plugin\r\n * @returns the name of the plugin\r\n */\r\n public getPhysicsPluginName(): string {\r\n return this._physicsPlugin.name;\r\n }\r\n\r\n /**\r\n * Set the maximum allowed linear and angular velocities\r\n * @param maxLinearVelocity maximum allowed linear velocity\r\n * @param maxAngularVelocity maximum allowed angular velocity\r\n */\r\n setVelocityLimits(maxLinearVelocity: number, maxAngularVelocity: number): void {\r\n this._physicsPlugin.setVelocityLimits(maxLinearVelocity, maxAngularVelocity);\r\n }\r\n\r\n /**\r\n * @returns maximum allowed linear velocity\r\n */\r\n getMaxLinearVelocity(): number {\r\n return this._physicsPlugin.getMaxLinearVelocity();\r\n }\r\n\r\n /**\r\n * @returns maximum allowed angular velocity\r\n */\r\n getMaxAngularVelocity(): number {\r\n return this._physicsPlugin.getMaxAngularVelocity();\r\n }\r\n\r\n /**\r\n * Adding a new impostor for the impostor tracking.\r\n * This will be done by the impostor itself.\r\n * @param impostor the impostor to add\r\n */\r\n\r\n /**\r\n * Called by the scene. No need to call it.\r\n * @param delta defines the timespan between frames\r\n */\r\n public _step(delta: number) {\r\n if (delta > 0.1) {\r\n delta = 0.1;\r\n } else if (delta <= 0) {\r\n delta = 1.0 / 60.0;\r\n }\r\n\r\n this._physicsPlugin.executeStep(delta, this._physicsBodies);\r\n }\r\n\r\n /**\r\n * Add a body as an active component of this engine\r\n * @param physicsBody The body to add\r\n */\r\n public addBody(physicsBody: PhysicsBody): void {\r\n this._physicsBodies.push(physicsBody);\r\n }\r\n /**\r\n * Removes a particular body from this engine\r\n * @param physicsBody The body to remove from the simulation\r\n */\r\n public removeBody(physicsBody: PhysicsBody): void {\r\n const index = this._physicsBodies.indexOf(physicsBody);\r\n if (index > -1) {\r\n /*const removed =*/ this._physicsBodies.splice(index, 1);\r\n }\r\n }\r\n /**\r\n * @returns an array of bodies added to this engine\r\n */\r\n public getBodies(): Array<PhysicsBody> {\r\n return this._physicsBodies;\r\n }\r\n\r\n /**\r\n * Gets the current plugin used to run the simulation\r\n * @returns current plugin\r\n */\r\n public getPhysicsPlugin(): IPhysicsEnginePluginV2 {\r\n return this._physicsPlugin;\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param result resulting PhysicsRaycastResult\r\n * @param query raycast query object\r\n */\r\n public raycastToRef(from: Vector3, to: Vector3, result: PhysicsRaycastResult, query?: IRaycastQuery): void {\r\n this._physicsPlugin.raycast(from, to, result, query);\r\n }\r\n\r\n /**\r\n * Does a raycast in the physics world\r\n * @param from when should the ray start?\r\n * @param to when should the ray end?\r\n * @param query raycast query object\r\n * @returns PhysicsRaycastResult\r\n */\r\n public raycast(from: Vector3, to: Vector3, query?: IRaycastQuery): PhysicsRaycastResult {\r\n const result = new PhysicsRaycastResult();\r\n this._physicsPlugin.raycast(from, to, result, query);\r\n return result;\r\n }\r\n}\r\n"]}
@@ -78,6 +78,7 @@ export class EdgesRenderer {
78
78
  const shader = new ShaderMaterial("lineShader", scene, "line", {
79
79
  attributes: ["position", "normal"],
80
80
  uniforms: ["world", "viewProjection", "color", "width", "aspectRatio"],
81
+ uniformBuffers: ["Scene", "Mesh"],
81
82
  }, false);
82
83
  shader.disableDepthWrite = true;
83
84
  shader.backFaceCulling = false;
@@ -677,7 +678,7 @@ export class EdgesRenderer {
677
678
  this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
678
679
  }
679
680
  this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
680
- this._lineShader.bind(this._source.getWorldMatrix());
681
+ this._lineShader.bind(this._source.getWorldMatrix(), this._source);
681
682
  // Draw order
682
683
  engine.drawElementsType(Material.TriangleFillMode, 0, this._indicesCount, instanceCount);
683
684
  this._lineShader.unbind();
@@ -1 +1 @@
1
- {"version":3,"file":"edgesRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/edgesRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAI3D,OAAO,EAA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AAC,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAC5H,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAEhI,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAExD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { LinesMesh, InstancedLinesMesh } from \"../Meshes/linesMesh\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Node } from \"../node\";\r\n\r\nimport \"../Shaders/line.fragment\";\r\nimport \"../Shaders/line.vertex\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal */\r\n _edgeRenderLineShader: Nullable<ShaderMaterial>;\r\n }\r\n}\r\n\r\ndeclare module \"../Meshes/abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Gets the edgesRenderer associated with the mesh\r\n */\r\n edgesRenderer: Nullable<EdgesRenderer>;\r\n }\r\n}\r\nAbstractMesh.prototype.disableEdgesRendering = function (): AbstractMesh {\r\n if (this._edgesRenderer) {\r\n this._edgesRenderer.dispose();\r\n this._edgesRenderer = null;\r\n }\r\n return this;\r\n};\r\n\r\nAbstractMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false, options?: IEdgesRendererOptions): AbstractMesh {\r\n this.disableEdgesRendering();\r\n this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices, true, options);\r\n return this;\r\n};\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"edgesRenderer\", {\r\n get: function (this: AbstractMesh) {\r\n return this._edgesRenderer;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\ndeclare module \"../Meshes/linesMesh\" {\r\n export interface LinesMesh {\r\n /**\r\n * Enables the edge rendering mode on the mesh.\r\n * This mode makes the mesh edges visible\r\n * @param epsilon defines the maximal distance between two angles to detect a face\r\n * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces\r\n * @returns the currentAbstractMesh\r\n * @see https://www.babylonjs-playground.com/#19O9TU#0\r\n */\r\n enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;\r\n }\r\n}\r\nLinesMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false): AbstractMesh {\r\n this.disableEdgesRendering();\r\n this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);\r\n return this;\r\n};\r\n\r\ndeclare module \"../Meshes/linesMesh\" {\r\n export interface InstancedLinesMesh {\r\n /**\r\n * Enables the edge rendering mode on the mesh.\r\n * This mode makes the mesh edges visible\r\n * @param epsilon defines the maximal distance between two angles to detect a face\r\n * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces\r\n * @returns the current InstancedLinesMesh\r\n * @see https://www.babylonjs-playground.com/#19O9TU#0\r\n */\r\n enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nInstancedLinesMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false): InstancedLinesMesh {\r\n LinesMesh.prototype.enableEdgesRendering.apply(this, arguments);\r\n return this;\r\n};\r\n\r\n/**\r\n * FaceAdjacencies Helper class to generate edges\r\n */\r\nclass FaceAdjacencies {\r\n public edges: number[] = [];\r\n public p0: Vector3;\r\n public p1: Vector3;\r\n public p2: Vector3;\r\n public edgesConnectedCount = 0;\r\n}\r\n\r\n/**\r\n * Defines the minimum contract an Edges renderer should follow.\r\n */\r\nexport interface IEdgesRenderer extends IDisposable {\r\n /**\r\n * Gets or sets a boolean indicating if the edgesRenderer is active\r\n */\r\n isEnabled: boolean;\r\n\r\n /**\r\n * Renders the edges of the attached mesh,\r\n */\r\n render(): void;\r\n\r\n /**\r\n * Checks whether or not the edges renderer is ready to render.\r\n * @returns true if ready, otherwise false.\r\n */\r\n isReady(): boolean;\r\n\r\n /**\r\n * List of instances to render in case the source mesh has instances\r\n */\r\n customInstances: SmartArray<Matrix>;\r\n}\r\n\r\n/**\r\n * Defines the additional options of the edges renderer\r\n */\r\nexport interface IEdgesRendererOptions {\r\n /**\r\n * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used\r\n * If not defined, the default value is true\r\n */\r\n useAlternateEdgeFinder?: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the vertex merger fast processing must be used.\r\n * If not defined, the default value is true.\r\n * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n useFastVertexMerger?: boolean;\r\n\r\n /**\r\n * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.\r\n * The default value is 1e-6\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n epsilonVertexMerge?: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit\r\n * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n applyTessellation?: boolean;\r\n\r\n /**\r\n * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned\r\n * The default value is 1e-6\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n epsilonVertexAligned?: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that degenerated triangles should not be processed.\r\n * Degenerated triangles are triangles that have 2 or 3 vertices with the same coordinates\r\n */\r\n removeDegeneratedTriangles?: boolean;\r\n}\r\n\r\n/**\r\n * This class is used to generate edges of the mesh that could then easily be rendered in a scene.\r\n */\r\nexport class EdgesRenderer implements IEdgesRenderer {\r\n /**\r\n * Define the size of the edges with an orthographic camera\r\n */\r\n public edgesWidthScalerForOrthographic = 1000.0;\r\n\r\n /**\r\n * Define the size of the edges with a perspective camera\r\n */\r\n public edgesWidthScalerForPerspective = 50.0;\r\n\r\n protected _source: AbstractMesh;\r\n protected _linesPositions = new Array<number>();\r\n protected _linesNormals = new Array<number>();\r\n protected _linesIndices = new Array<number>();\r\n protected _epsilon: number;\r\n protected _indicesCount: number;\r\n protected _drawWrapper?: DrawWrapper;\r\n\r\n protected _lineShader: ShaderMaterial;\r\n protected _ib: DataBuffer;\r\n protected _buffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n protected _buffersForInstances: { [key: string]: Nullable<VertexBuffer> } = {};\r\n protected _checkVerticesInsteadOfIndices = false;\r\n protected _options: Nullable<IEdgesRendererOptions>;\r\n\r\n private _meshRebuildObserver: Nullable<Observer<AbstractMesh>>;\r\n private _meshDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /** Gets or sets a boolean indicating if the edgesRenderer is active */\r\n public isEnabled = true;\r\n\r\n /** Gets the vertices generated by the edge renderer */\r\n public get linesPositions(): Immutable<Array<number>> {\r\n return this._linesPositions;\r\n }\r\n\r\n /** Gets the normals generated by the edge renderer */\r\n public get linesNormals(): Immutable<Array<number>> {\r\n return this._linesNormals;\r\n }\r\n\r\n /** Gets the indices generated by the edge renderer */\r\n public get linesIndices(): Immutable<Array<number>> {\r\n return this._linesIndices;\r\n }\r\n\r\n /**\r\n * Gets or sets the shader used to draw the lines\r\n */\r\n public get lineShader(): ShaderMaterial {\r\n return this._lineShader;\r\n }\r\n\r\n public set lineShader(shader: ShaderMaterial) {\r\n this._lineShader = shader;\r\n }\r\n\r\n /**\r\n * List of instances to render in case the source mesh has instances\r\n */\r\n public customInstances = new SmartArray<Matrix>(32);\r\n\r\n private static _GetShader(scene: Scene): ShaderMaterial {\r\n if (!scene._edgeRenderLineShader) {\r\n const shader = new ShaderMaterial(\r\n \"lineShader\",\r\n scene,\r\n \"line\",\r\n {\r\n attributes: [\"position\", \"normal\"],\r\n uniforms: [\"world\", \"viewProjection\", \"color\", \"width\", \"aspectRatio\"],\r\n },\r\n false\r\n );\r\n\r\n shader.disableDepthWrite = true;\r\n shader.backFaceCulling = false;\r\n shader.checkReadyOnEveryCall = scene.getEngine().isWebGPU;\r\n\r\n scene._edgeRenderLineShader = shader;\r\n }\r\n\r\n return scene._edgeRenderLineShader;\r\n }\r\n\r\n /**\r\n * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.\r\n * Beware when you use this class with complex objects as the adjacencies computation can be really long\r\n * @param source Mesh used to create edges\r\n * @param epsilon sum of angles in adjacency to check for edge\r\n * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true\r\n * @param generateEdgesLines - should generate Lines or only prepare resources.\r\n * @param options The options to apply when generating the edges\r\n */\r\n constructor(source: AbstractMesh, epsilon = 0.95, checkVerticesInsteadOfIndices = false, generateEdgesLines = true, options?: IEdgesRendererOptions) {\r\n this._source = source;\r\n this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;\r\n this._options = options ?? null;\r\n\r\n this._epsilon = epsilon;\r\n if (this._source.getScene().getEngine().isWebGPU) {\r\n this._drawWrapper = new DrawWrapper(source.getEngine());\r\n }\r\n\r\n this._prepareRessources();\r\n if (generateEdgesLines) {\r\n if (options?.useAlternateEdgeFinder ?? true) {\r\n this._generateEdgesLinesAlternate();\r\n } else {\r\n this._generateEdgesLines();\r\n }\r\n }\r\n\r\n this._meshRebuildObserver = this._source.onRebuildObservable.add(() => {\r\n this._rebuild();\r\n });\r\n\r\n this._meshDisposeObserver = this._source.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n protected _prepareRessources(): void {\r\n if (this._lineShader) {\r\n return;\r\n }\r\n\r\n this._lineShader = EdgesRenderer._GetShader(this._source.getScene());\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n let buffer = this._buffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer._rebuild();\r\n }\r\n\r\n buffer = this._buffers[VertexBuffer.NormalKind];\r\n if (buffer) {\r\n buffer._rebuild();\r\n }\r\n\r\n const scene = this._source.getScene();\r\n const engine = scene.getEngine();\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n }\r\n\r\n /**\r\n * Releases the required resources for the edges renderer\r\n */\r\n public dispose(): void {\r\n this._source.onRebuildObservable.remove(this._meshRebuildObserver);\r\n this._source.onDisposeObservable.remove(this._meshDisposeObserver);\r\n\r\n let buffer = this._buffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._buffers[VertexBuffer.PositionKind] = null;\r\n }\r\n buffer = this._buffers[VertexBuffer.NormalKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._buffers[VertexBuffer.NormalKind] = null;\r\n }\r\n\r\n if (this._ib) {\r\n this._source.getScene().getEngine()._releaseBuffer(this._ib);\r\n }\r\n this._lineShader.dispose();\r\n\r\n this._drawWrapper?.dispose();\r\n }\r\n\r\n protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number {\r\n if ((pa === p0 && pb === p1) || (pa === p1 && pb === p0)) {\r\n return 0;\r\n }\r\n\r\n if ((pa === p1 && pb === p2) || (pa === p2 && pb === p1)) {\r\n return 1;\r\n }\r\n\r\n if ((pa === p2 && pb === p0) || (pa === p0 && pb === p2)) {\r\n return 2;\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number {\r\n const eps = 1e-10;\r\n if ((pa.equalsWithEpsilon(p0, eps) && pb.equalsWithEpsilon(p1, eps)) || (pa.equalsWithEpsilon(p1, eps) && pb.equalsWithEpsilon(p0, eps))) {\r\n return 0;\r\n }\r\n\r\n if ((pa.equalsWithEpsilon(p1, eps) && pb.equalsWithEpsilon(p2, eps)) || (pa.equalsWithEpsilon(p2, eps) && pb.equalsWithEpsilon(p1, eps))) {\r\n return 1;\r\n }\r\n\r\n if ((pa.equalsWithEpsilon(p2, eps) && pb.equalsWithEpsilon(p0, eps)) || (pa.equalsWithEpsilon(p0, eps) && pb.equalsWithEpsilon(p2, eps))) {\r\n return 2;\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n /**\r\n * Checks if the pair of p0 and p1 is en edge\r\n * @param faceIndex\r\n * @param edge\r\n * @param faceNormals\r\n * @param p0\r\n * @param p1\r\n * @private\r\n */\r\n protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void {\r\n let needToCreateLine;\r\n\r\n if (edge === undefined) {\r\n needToCreateLine = true;\r\n } else {\r\n const dotProduct = Vector3.Dot(faceNormals[faceIndex], faceNormals[edge]);\r\n\r\n needToCreateLine = dotProduct < this._epsilon;\r\n }\r\n\r\n if (needToCreateLine) {\r\n this.createLine(p0, p1, this._linesPositions.length / 3);\r\n }\r\n }\r\n\r\n /**\r\n * push line into the position, normal and index buffer\r\n * @param p0\r\n * @param p1\r\n * @param offset\r\n * @protected\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected createLine(p0: Vector3, p1: Vector3, offset: number) {\r\n // Positions\r\n this._linesPositions.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p1.x, p1.y, p1.z);\r\n\r\n // Normals\r\n this._linesNormals.push(p1.x, p1.y, p1.z, -1, p1.x, p1.y, p1.z, 1, p0.x, p0.y, p0.z, -1, p0.x, p0.y, p0.z, 1);\r\n\r\n // Indices\r\n this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);\r\n }\r\n\r\n /**\r\n * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm\r\n * @param edgePoints\r\n * @param indexTriangle\r\n * @param indices\r\n * @param remapVertexIndices\r\n */\r\n private _tessellateTriangle(edgePoints: Array<Array<[number, number]>>, indexTriangle: number, indices: Array<number>, remapVertexIndices: Array<number>): void {\r\n const makePointList = (edgePoints: Array<[number, number]>, pointIndices: Array<number>, firstIndex: number) => {\r\n if (firstIndex >= 0) {\r\n pointIndices.push(firstIndex);\r\n }\r\n\r\n for (let i = 0; i < edgePoints.length; ++i) {\r\n pointIndices.push(edgePoints[i][0]);\r\n }\r\n };\r\n\r\n let startEdge = 0;\r\n\r\n if (edgePoints[1].length >= edgePoints[0].length && edgePoints[1].length >= edgePoints[2].length) {\r\n startEdge = 1;\r\n } else if (edgePoints[2].length >= edgePoints[0].length && edgePoints[2].length >= edgePoints[1].length) {\r\n startEdge = 2;\r\n }\r\n\r\n for (let e = 0; e < 3; ++e) {\r\n if (e === startEdge) {\r\n edgePoints[e].sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0));\r\n } else {\r\n edgePoints[e].sort((a, b) => (a[1] > b[1] ? -1 : a[1] < b[1] ? 1 : 0));\r\n }\r\n }\r\n\r\n const mainPointIndices: Array<number> = [],\r\n otherPointIndices: Array<number> = [];\r\n\r\n makePointList(edgePoints[startEdge], mainPointIndices, -1);\r\n\r\n const numMainPoints = mainPointIndices.length;\r\n\r\n for (let i = startEdge + 2; i >= startEdge + 1; --i) {\r\n makePointList(edgePoints[i % 3], otherPointIndices, i !== startEdge + 2 ? remapVertexIndices[indices[indexTriangle + ((i + 1) % 3)]] : -1);\r\n }\r\n\r\n const numOtherPoints = otherPointIndices.length;\r\n\r\n const idxMain = 0;\r\n const idxOther = 0;\r\n\r\n indices.push(remapVertexIndices[indices[indexTriangle + startEdge]], mainPointIndices[0], otherPointIndices[0]);\r\n indices.push(remapVertexIndices[indices[indexTriangle + ((startEdge + 1) % 3)]], otherPointIndices[numOtherPoints - 1], mainPointIndices[numMainPoints - 1]);\r\n\r\n const bucketIsMain = numMainPoints <= numOtherPoints;\r\n\r\n const bucketStep = bucketIsMain ? numMainPoints : numOtherPoints;\r\n const bucketLimit = bucketIsMain ? numOtherPoints : numMainPoints;\r\n const bucketIdxLimit = bucketIsMain ? numMainPoints - 1 : numOtherPoints - 1;\r\n const winding = bucketIsMain ? 0 : 1;\r\n\r\n let numTris = numMainPoints + numOtherPoints - 2;\r\n\r\n let bucketIdx = bucketIsMain ? idxMain : idxOther;\r\n let nbucketIdx = bucketIsMain ? idxOther : idxMain;\r\n const bucketPoints = bucketIsMain ? mainPointIndices : otherPointIndices;\r\n const nbucketPoints = bucketIsMain ? otherPointIndices : mainPointIndices;\r\n\r\n let bucket = 0;\r\n\r\n while (numTris-- > 0) {\r\n if (winding) {\r\n indices.push(bucketPoints[bucketIdx], nbucketPoints[nbucketIdx]);\r\n } else {\r\n indices.push(nbucketPoints[nbucketIdx], bucketPoints[bucketIdx]);\r\n }\r\n\r\n bucket += bucketStep;\r\n\r\n let lastIdx;\r\n\r\n if (bucket >= bucketLimit && bucketIdx < bucketIdxLimit) {\r\n lastIdx = bucketPoints[++bucketIdx];\r\n bucket -= bucketLimit;\r\n } else {\r\n lastIdx = nbucketPoints[++nbucketIdx];\r\n }\r\n\r\n indices.push(lastIdx);\r\n }\r\n\r\n indices[indexTriangle + 0] = indices[indices.length - 3];\r\n indices[indexTriangle + 1] = indices[indices.length - 2];\r\n indices[indexTriangle + 2] = indices[indices.length - 1];\r\n\r\n indices.length = indices.length - 3;\r\n }\r\n\r\n private _generateEdgesLinesAlternate(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n let indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n if (!Array.isArray(indices)) {\r\n indices = Array.from(indices);\r\n }\r\n\r\n /**\r\n * Find all vertices that are at the same location (with an epsilon) and remapp them on the same vertex\r\n */\r\n const useFastVertexMerger = this._options?.useFastVertexMerger ?? true;\r\n const epsVertexMerge = useFastVertexMerger ? Math.round(-Math.log(this._options?.epsilonVertexMerge ?? 1e-6) / Math.log(10)) : this._options?.epsilonVertexMerge ?? 1e-6;\r\n const remapVertexIndices: Array<number> = [];\r\n const uniquePositions: Array<number> = []; // list of unique index of vertices - needed for tessellation\r\n\r\n if (useFastVertexMerger) {\r\n const mapVertices: { [key: string]: number } = {};\r\n for (let v1 = 0; v1 < positions.length; v1 += 3) {\r\n const x1 = positions[v1 + 0],\r\n y1 = positions[v1 + 1],\r\n z1 = positions[v1 + 2];\r\n\r\n const key = x1.toFixed(epsVertexMerge) + \"|\" + y1.toFixed(epsVertexMerge) + \"|\" + z1.toFixed(epsVertexMerge);\r\n\r\n if (mapVertices[key] !== undefined) {\r\n remapVertexIndices.push(mapVertices[key]);\r\n } else {\r\n const idx = v1 / 3;\r\n mapVertices[key] = idx;\r\n remapVertexIndices.push(idx);\r\n uniquePositions.push(idx);\r\n }\r\n }\r\n } else {\r\n for (let v1 = 0; v1 < positions.length; v1 += 3) {\r\n const x1 = positions[v1 + 0],\r\n y1 = positions[v1 + 1],\r\n z1 = positions[v1 + 2];\r\n let found = false;\r\n for (let v2 = 0; v2 < v1 && !found; v2 += 3) {\r\n const x2 = positions[v2 + 0],\r\n y2 = positions[v2 + 1],\r\n z2 = positions[v2 + 2];\r\n\r\n if (Math.abs(x1 - x2) < epsVertexMerge && Math.abs(y1 - y2) < epsVertexMerge && Math.abs(z1 - z2) < epsVertexMerge) {\r\n remapVertexIndices.push(v2 / 3);\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n remapVertexIndices.push(v1 / 3);\r\n uniquePositions.push(v1 / 3);\r\n }\r\n }\r\n }\r\n\r\n if (this._options?.applyTessellation) {\r\n /**\r\n * Tessellate triangles if necessary:\r\n *\r\n * A\r\n * +\r\n * |\\\r\n * | \\\r\n * | \\\r\n * E + \\\r\n * /| \\\r\n * / | \\\r\n * / | \\\r\n * +---+-------+ B\r\n * D C\r\n *\r\n * For the edges to be rendered correctly, the ABC triangle has to be split into ABE and BCE, else AC is considered to be an edge, whereas only AE should be.\r\n *\r\n * The tessellation process looks for the vertices like E that are in-between two other vertices making of an edge and create new triangles as necessary\r\n */\r\n\r\n // First step: collect the triangles to tessellate\r\n const epsVertexAligned = this._options?.epsilonVertexAligned ?? 1e-6;\r\n const mustTesselate: Array<{ index: number; edgesPoints: Array<Array<[number, number]>> }> = []; // liste of triangles that must be tessellated\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n // loop over all triangles\r\n let triangleToTessellate: { index: number; edgesPoints: Array<Array<[number, number]>> } | undefined;\r\n\r\n for (let i = 0; i < 3; ++i) {\r\n // loop over the 3 edges of the triangle\r\n const p0Index = remapVertexIndices[indices[index + i]];\r\n const p1Index = remapVertexIndices[indices[index + ((i + 1) % 3)]];\r\n const p2Index = remapVertexIndices[indices[index + ((i + 2) % 3)]];\r\n\r\n if (p0Index === p1Index) {\r\n continue;\r\n } // degenerated triangle - don't process\r\n\r\n const p0x = positions[p0Index * 3 + 0],\r\n p0y = positions[p0Index * 3 + 1],\r\n p0z = positions[p0Index * 3 + 2];\r\n const p1x = positions[p1Index * 3 + 0],\r\n p1y = positions[p1Index * 3 + 1],\r\n p1z = positions[p1Index * 3 + 2];\r\n\r\n const p0p1 = Math.sqrt((p1x - p0x) * (p1x - p0x) + (p1y - p0y) * (p1y - p0y) + (p1z - p0z) * (p1z - p0z));\r\n\r\n for (let v = 0; v < uniquePositions.length - 1; v++) {\r\n // loop over all (unique) vertices and look for the ones that would be in-between p0 and p1\r\n const vIndex = uniquePositions[v];\r\n\r\n if (vIndex === p0Index || vIndex === p1Index || vIndex === p2Index) {\r\n continue;\r\n } // don't handle the vertex if it is a vertex of the current triangle\r\n\r\n const x = positions[vIndex * 3 + 0],\r\n y = positions[vIndex * 3 + 1],\r\n z = positions[vIndex * 3 + 2];\r\n\r\n const p0p = Math.sqrt((x - p0x) * (x - p0x) + (y - p0y) * (y - p0y) + (z - p0z) * (z - p0z));\r\n const pp1 = Math.sqrt((x - p1x) * (x - p1x) + (y - p1y) * (y - p1y) + (z - p1z) * (z - p1z));\r\n\r\n if (Math.abs(p0p + pp1 - p0p1) < epsVertexAligned) {\r\n // vertices are aligned and p in-between p0 and p1 if distance(p0, p) + distance (p, p1) ~ distance(p0, p1)\r\n if (!triangleToTessellate) {\r\n triangleToTessellate = {\r\n index: index,\r\n edgesPoints: [[], [], []],\r\n };\r\n mustTesselate.push(triangleToTessellate);\r\n }\r\n triangleToTessellate.edgesPoints[i].push([vIndex, p0p]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Second step: tesselate the triangles\r\n for (let t = 0; t < mustTesselate.length; ++t) {\r\n const triangle = mustTesselate[t];\r\n\r\n this._tessellateTriangle(triangle.edgesPoints, triangle.index, indices, remapVertexIndices);\r\n }\r\n\r\n mustTesselate.length = 0;\r\n }\r\n\r\n /**\r\n * Collect the edges to render\r\n */\r\n const edges: { [key: string]: { normal: Vector3; done: boolean; index: number; i: number } } = {};\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n let faceNormal;\r\n for (let i = 0; i < 3; ++i) {\r\n let p0Index = remapVertexIndices[indices[index + i]];\r\n let p1Index = remapVertexIndices[indices[index + ((i + 1) % 3)]];\r\n const p2Index = remapVertexIndices[indices[index + ((i + 2) % 3)]];\r\n\r\n if (p0Index === p1Index || ((p0Index === p2Index || p1Index === p2Index) && this._options?.removeDegeneratedTriangles)) {\r\n continue;\r\n }\r\n\r\n TmpVectors.Vector3[0].copyFromFloats(positions[p0Index * 3 + 0], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n TmpVectors.Vector3[1].copyFromFloats(positions[p1Index * 3 + 0], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n TmpVectors.Vector3[2].copyFromFloats(positions[p2Index * 3 + 0], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);\r\n\r\n if (!faceNormal) {\r\n TmpVectors.Vector3[1].subtractToRef(TmpVectors.Vector3[0], TmpVectors.Vector3[3]);\r\n TmpVectors.Vector3[2].subtractToRef(TmpVectors.Vector3[1], TmpVectors.Vector3[4]);\r\n faceNormal = Vector3.Cross(TmpVectors.Vector3[3], TmpVectors.Vector3[4]);\r\n faceNormal.normalize();\r\n }\r\n\r\n if (p0Index > p1Index) {\r\n const tmp = p0Index;\r\n p0Index = p1Index;\r\n p1Index = tmp;\r\n }\r\n\r\n const key = p0Index + \"_\" + p1Index;\r\n const ei = edges[key];\r\n\r\n if (ei) {\r\n if (!ei.done) {\r\n const dotProduct = Vector3.Dot(faceNormal, ei.normal);\r\n\r\n if (dotProduct < this._epsilon) {\r\n this.createLine(TmpVectors.Vector3[0], TmpVectors.Vector3[1], this._linesPositions.length / 3);\r\n }\r\n\r\n ei.done = true;\r\n }\r\n } else {\r\n edges[key] = { normal: faceNormal, done: false, index: index, i: i };\r\n }\r\n }\r\n }\r\n\r\n for (const key in edges) {\r\n const ei = edges[key];\r\n if (!ei.done) {\r\n // Orphaned edge - we must display it\r\n const p0Index = remapVertexIndices[indices[ei.index + ei.i]];\r\n const p1Index = remapVertexIndices[indices[ei.index + ((ei.i + 1) % 3)]];\r\n\r\n TmpVectors.Vector3[0].copyFromFloats(positions[p0Index * 3 + 0], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n TmpVectors.Vector3[1].copyFromFloats(positions[p1Index * 3 + 0], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n\r\n this.createLine(TmpVectors.Vector3[0], TmpVectors.Vector3[1], this._linesPositions.length / 3);\r\n }\r\n }\r\n\r\n /**\r\n * Merge into a single mesh\r\n */\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._buffersForInstances[VertexBuffer.PositionKind] = this._buffers[VertexBuffer.PositionKind];\r\n this._buffersForInstances[VertexBuffer.NormalKind] = this._buffers[VertexBuffer.NormalKind];\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n\r\n /**\r\n * Generates lines edges from adjacencjes\r\n * @private\r\n */\r\n _generateEdgesLines(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n // First let's find adjacencies\r\n const adjacencies: FaceAdjacencies[] = [];\r\n const faceNormals: Vector3[] = [];\r\n let index: number;\r\n let faceAdjacencies: FaceAdjacencies;\r\n\r\n // Prepare faces\r\n for (index = 0; index < indices.length; index += 3) {\r\n faceAdjacencies = new FaceAdjacencies();\r\n const p0Index = indices[index];\r\n const p1Index = indices[index + 1];\r\n const p2Index = indices[index + 2];\r\n\r\n faceAdjacencies.p0 = new Vector3(positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n faceAdjacencies.p1 = new Vector3(positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n faceAdjacencies.p2 = new Vector3(positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);\r\n const faceNormal = Vector3.Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));\r\n\r\n faceNormal.normalize();\r\n\r\n faceNormals.push(faceNormal);\r\n adjacencies.push(faceAdjacencies);\r\n }\r\n\r\n // Scan\r\n for (index = 0; index < adjacencies.length; index++) {\r\n faceAdjacencies = adjacencies[index];\r\n\r\n for (let otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {\r\n const otherFaceAdjacencies = adjacencies[otherIndex];\r\n\r\n if (faceAdjacencies.edgesConnectedCount === 3) {\r\n // Full\r\n break;\r\n }\r\n\r\n if (otherFaceAdjacencies.edgesConnectedCount === 3) {\r\n // Full\r\n continue;\r\n }\r\n\r\n const otherP0 = indices[otherIndex * 3];\r\n const otherP1 = indices[otherIndex * 3 + 1];\r\n const otherP2 = indices[otherIndex * 3 + 2];\r\n\r\n for (let edgeIndex = 0; edgeIndex < 3; edgeIndex++) {\r\n let otherEdgeIndex: number = 0;\r\n\r\n if (faceAdjacencies.edges[edgeIndex] !== undefined) {\r\n continue;\r\n }\r\n\r\n switch (edgeIndex) {\r\n case 0:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p0,\r\n faceAdjacencies.p1,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n case 1:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p1,\r\n faceAdjacencies.p2,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n case 2:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p2,\r\n faceAdjacencies.p0,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n }\r\n\r\n if (otherEdgeIndex === -1) {\r\n continue;\r\n }\r\n\r\n faceAdjacencies.edges[edgeIndex] = otherIndex;\r\n otherFaceAdjacencies.edges[otherEdgeIndex] = index;\r\n\r\n faceAdjacencies.edgesConnectedCount++;\r\n otherFaceAdjacencies.edgesConnectedCount++;\r\n\r\n if (faceAdjacencies.edgesConnectedCount === 3) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Create lines\r\n for (index = 0; index < adjacencies.length; index++) {\r\n // We need a line when a face has no adjacency on a specific edge or if all the adjacencies has an angle greater than epsilon\r\n const current = adjacencies[index];\r\n\r\n this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);\r\n this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);\r\n this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);\r\n }\r\n\r\n // Merge into a single mesh\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._buffersForInstances[VertexBuffer.PositionKind] = this._buffers[VertexBuffer.PositionKind];\r\n this._buffersForInstances[VertexBuffer.NormalKind] = this._buffers[VertexBuffer.NormalKind];\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n\r\n /**\r\n * Checks whether or not the edges renderer is ready to render.\r\n * @returns true if ready, otherwise false.\r\n */\r\n public isReady(): boolean {\r\n return this._lineShader.isReady(this._source, (this._source.hasInstances && this.customInstances.length > 0) || this._source.hasThinInstances);\r\n }\r\n\r\n /**\r\n * Renders the edges of the attached mesh,\r\n */\r\n public render(): void {\r\n const scene = this._source.getScene();\r\n\r\n const currentDrawWrapper = this._lineShader._getDrawWrapper();\r\n if (this._drawWrapper) {\r\n this._lineShader._setDrawWrapper(this._drawWrapper);\r\n }\r\n\r\n if (!this.isReady() || !scene.activeCamera) {\r\n this._lineShader._setDrawWrapper(currentDrawWrapper);\r\n return;\r\n }\r\n\r\n const hasInstances = this._source.hasInstances && this.customInstances.length > 0;\r\n const useBuffersWithInstances = hasInstances || this._source.hasThinInstances;\r\n\r\n let instanceCount = 0;\r\n\r\n if (useBuffersWithInstances) {\r\n this._buffersForInstances[\"world0\"] = (this._source as Mesh).getVertexBuffer(\"world0\");\r\n this._buffersForInstances[\"world1\"] = (this._source as Mesh).getVertexBuffer(\"world1\");\r\n this._buffersForInstances[\"world2\"] = (this._source as Mesh).getVertexBuffer(\"world2\");\r\n this._buffersForInstances[\"world3\"] = (this._source as Mesh).getVertexBuffer(\"world3\");\r\n\r\n if (hasInstances) {\r\n const instanceStorage = (this._source as Mesh)._instanceDataStorage;\r\n\r\n instanceCount = this.customInstances.length;\r\n\r\n if (!instanceStorage.instancesData) {\r\n if (!this._source.getScene()._activeMeshesFrozen) {\r\n this.customInstances.reset();\r\n }\r\n return;\r\n }\r\n\r\n if (!instanceStorage.isFrozen) {\r\n let offset = 0;\r\n\r\n for (let i = 0; i < instanceCount; ++i) {\r\n this.customInstances.data[i].copyToArray(instanceStorage.instancesData, offset);\r\n offset += 16;\r\n }\r\n\r\n instanceStorage.instancesBuffer!.updateDirectly(instanceStorage.instancesData, 0, instanceCount);\r\n }\r\n } else {\r\n instanceCount = (this._source as Mesh).thinInstanceCount;\r\n }\r\n }\r\n\r\n const engine = scene.getEngine();\r\n this._lineShader._preBind();\r\n\r\n if (this._source.edgesColor.a !== 1) {\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n } else {\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n }\r\n\r\n // VBOs\r\n engine.bindBuffers(useBuffersWithInstances ? this._buffersForInstances : this._buffers, this._ib, <Effect>this._lineShader.getEffect());\r\n\r\n scene.resetCachedMaterial();\r\n this._lineShader.setColor4(\"color\", this._source.edgesColor);\r\n\r\n if (scene.activeCamera.mode === Camera.ORTHOGRAPHIC_CAMERA) {\r\n this._lineShader.setFloat(\"width\", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);\r\n } else {\r\n this._lineShader.setFloat(\"width\", this._source.edgesWidth / this.edgesWidthScalerForPerspective);\r\n }\r\n\r\n this._lineShader.setFloat(\"aspectRatio\", engine.getAspectRatio(scene.activeCamera));\r\n this._lineShader.bind(this._source.getWorldMatrix());\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, this._indicesCount, instanceCount);\r\n this._lineShader.unbind();\r\n\r\n if (useBuffersWithInstances) {\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n if (!this._source.getScene()._activeMeshesFrozen) {\r\n this.customInstances.reset();\r\n }\r\n\r\n this._lineShader._setDrawWrapper(currentDrawWrapper);\r\n }\r\n}\r\n\r\n/**\r\n * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation\r\n */\r\nexport class LineEdgesRenderer extends EdgesRenderer {\r\n /**\r\n * This constructor turns off auto generating edges line in Edges Renderer to make it here.\r\n * @param source LineMesh used to generate edges\r\n * @param epsilon not important (specified angle for edge detection)\r\n * @param checkVerticesInsteadOfIndices not important for LineMesh\r\n */\r\n constructor(source: AbstractMesh, epsilon = 0.95, checkVerticesInsteadOfIndices = false) {\r\n super(source, epsilon, checkVerticesInsteadOfIndices, false);\r\n this._generateEdgesLines();\r\n }\r\n\r\n /**\r\n * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.\r\n */\r\n override _generateEdgesLines(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n const p0 = TmpVectors.Vector3[0];\r\n const p1 = TmpVectors.Vector3[1];\r\n const len = indices.length - 1;\r\n for (let i = 0, offset = 0; i < len; i += 2, offset += 4) {\r\n Vector3.FromArrayToRef(positions, 3 * indices[i], p0);\r\n Vector3.FromArrayToRef(positions, 3 * indices[i + 1], p1);\r\n this.createLine(p0, p1, offset);\r\n }\r\n\r\n // Merge into a single mesh\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"edgesRenderer.js","sourceRoot":"","sources":["../../../../dev/core/src/Rendering/edgesRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEp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AAC;SACnC;QAED,2BAA2B;QAC3B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,CAAC;QAEnD,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,YAAY,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,EAAE,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;QAC5H,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,IAAI,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,YAAY,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;QAEhI,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAExD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport { VertexBuffer } from \"../Buffers/buffer\";\r\nimport { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Mesh } from \"../Meshes/mesh\";\r\nimport { LinesMesh, InstancedLinesMesh } from \"../Meshes/linesMesh\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3, TmpVectors } from \"../Maths/math.vector\";\r\nimport type { IDisposable, Scene } from \"../scene\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { Material } from \"../Materials/material\";\r\nimport { ShaderMaterial } from \"../Materials/shaderMaterial\";\r\nimport { Camera } from \"../Cameras/camera\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Node } from \"../node\";\r\n\r\nimport \"../Shaders/line.fragment\";\r\nimport \"../Shaders/line.vertex\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\nimport { SmartArray } from \"../Misc/smartArray\";\r\nimport { DrawWrapper } from \"../Materials/drawWrapper\";\r\n\r\ndeclare module \"../scene\" {\r\n export interface Scene {\r\n /** @internal */\r\n _edgeRenderLineShader: Nullable<ShaderMaterial>;\r\n }\r\n}\r\n\r\ndeclare module \"../Meshes/abstractMesh\" {\r\n export interface AbstractMesh {\r\n /**\r\n * Gets the edgesRenderer associated with the mesh\r\n */\r\n edgesRenderer: Nullable<EdgesRenderer>;\r\n }\r\n}\r\nAbstractMesh.prototype.disableEdgesRendering = function (): AbstractMesh {\r\n if (this._edgesRenderer) {\r\n this._edgesRenderer.dispose();\r\n this._edgesRenderer = null;\r\n }\r\n return this;\r\n};\r\n\r\nAbstractMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false, options?: IEdgesRendererOptions): AbstractMesh {\r\n this.disableEdgesRendering();\r\n this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices, true, options);\r\n return this;\r\n};\r\n\r\nObject.defineProperty(AbstractMesh.prototype, \"edgesRenderer\", {\r\n get: function (this: AbstractMesh) {\r\n return this._edgesRenderer;\r\n },\r\n enumerable: true,\r\n configurable: true,\r\n});\r\n\r\ndeclare module \"../Meshes/linesMesh\" {\r\n export interface LinesMesh {\r\n /**\r\n * Enables the edge rendering mode on the mesh.\r\n * This mode makes the mesh edges visible\r\n * @param epsilon defines the maximal distance between two angles to detect a face\r\n * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces\r\n * @returns the currentAbstractMesh\r\n * @see https://www.babylonjs-playground.com/#19O9TU#0\r\n */\r\n enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;\r\n }\r\n}\r\nLinesMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false): AbstractMesh {\r\n this.disableEdgesRendering();\r\n this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);\r\n return this;\r\n};\r\n\r\ndeclare module \"../Meshes/linesMesh\" {\r\n export interface InstancedLinesMesh {\r\n /**\r\n * Enables the edge rendering mode on the mesh.\r\n * This mode makes the mesh edges visible\r\n * @param epsilon defines the maximal distance between two angles to detect a face\r\n * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces\r\n * @returns the current InstancedLinesMesh\r\n * @see https://www.babylonjs-playground.com/#19O9TU#0\r\n */\r\n enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;\r\n }\r\n}\r\n\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nInstancedLinesMesh.prototype.enableEdgesRendering = function (epsilon = 0.95, checkVerticesInsteadOfIndices = false): InstancedLinesMesh {\r\n LinesMesh.prototype.enableEdgesRendering.apply(this, arguments);\r\n return this;\r\n};\r\n\r\n/**\r\n * FaceAdjacencies Helper class to generate edges\r\n */\r\nclass FaceAdjacencies {\r\n public edges: number[] = [];\r\n public p0: Vector3;\r\n public p1: Vector3;\r\n public p2: Vector3;\r\n public edgesConnectedCount = 0;\r\n}\r\n\r\n/**\r\n * Defines the minimum contract an Edges renderer should follow.\r\n */\r\nexport interface IEdgesRenderer extends IDisposable {\r\n /**\r\n * Gets or sets a boolean indicating if the edgesRenderer is active\r\n */\r\n isEnabled: boolean;\r\n\r\n /**\r\n * Renders the edges of the attached mesh,\r\n */\r\n render(): void;\r\n\r\n /**\r\n * Checks whether or not the edges renderer is ready to render.\r\n * @returns true if ready, otherwise false.\r\n */\r\n isReady(): boolean;\r\n\r\n /**\r\n * List of instances to render in case the source mesh has instances\r\n */\r\n customInstances: SmartArray<Matrix>;\r\n}\r\n\r\n/**\r\n * Defines the additional options of the edges renderer\r\n */\r\nexport interface IEdgesRendererOptions {\r\n /**\r\n * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used\r\n * If not defined, the default value is true\r\n */\r\n useAlternateEdgeFinder?: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the vertex merger fast processing must be used.\r\n * If not defined, the default value is true.\r\n * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n useFastVertexMerger?: boolean;\r\n\r\n /**\r\n * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit within which vertices are considered to be equal.\r\n * The default value is 1e-6\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n epsilonVertexMerge?: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit\r\n * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n applyTessellation?: boolean;\r\n\r\n /**\r\n * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned\r\n * The default value is 1e-6\r\n * This option is used only if useAlternateEdgeFinder = true\r\n */\r\n epsilonVertexAligned?: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that degenerated triangles should not be processed.\r\n * Degenerated triangles are triangles that have 2 or 3 vertices with the same coordinates\r\n */\r\n removeDegeneratedTriangles?: boolean;\r\n}\r\n\r\n/**\r\n * This class is used to generate edges of the mesh that could then easily be rendered in a scene.\r\n */\r\nexport class EdgesRenderer implements IEdgesRenderer {\r\n /**\r\n * Define the size of the edges with an orthographic camera\r\n */\r\n public edgesWidthScalerForOrthographic = 1000.0;\r\n\r\n /**\r\n * Define the size of the edges with a perspective camera\r\n */\r\n public edgesWidthScalerForPerspective = 50.0;\r\n\r\n protected _source: AbstractMesh;\r\n protected _linesPositions = new Array<number>();\r\n protected _linesNormals = new Array<number>();\r\n protected _linesIndices = new Array<number>();\r\n protected _epsilon: number;\r\n protected _indicesCount: number;\r\n protected _drawWrapper?: DrawWrapper;\r\n\r\n protected _lineShader: ShaderMaterial;\r\n protected _ib: DataBuffer;\r\n protected _buffers: { [key: string]: Nullable<VertexBuffer> } = {};\r\n protected _buffersForInstances: { [key: string]: Nullable<VertexBuffer> } = {};\r\n protected _checkVerticesInsteadOfIndices = false;\r\n protected _options: Nullable<IEdgesRendererOptions>;\r\n\r\n private _meshRebuildObserver: Nullable<Observer<AbstractMesh>>;\r\n private _meshDisposeObserver: Nullable<Observer<Node>>;\r\n\r\n /** Gets or sets a boolean indicating if the edgesRenderer is active */\r\n public isEnabled = true;\r\n\r\n /** Gets the vertices generated by the edge renderer */\r\n public get linesPositions(): Immutable<Array<number>> {\r\n return this._linesPositions;\r\n }\r\n\r\n /** Gets the normals generated by the edge renderer */\r\n public get linesNormals(): Immutable<Array<number>> {\r\n return this._linesNormals;\r\n }\r\n\r\n /** Gets the indices generated by the edge renderer */\r\n public get linesIndices(): Immutable<Array<number>> {\r\n return this._linesIndices;\r\n }\r\n\r\n /**\r\n * Gets or sets the shader used to draw the lines\r\n */\r\n public get lineShader(): ShaderMaterial {\r\n return this._lineShader;\r\n }\r\n\r\n public set lineShader(shader: ShaderMaterial) {\r\n this._lineShader = shader;\r\n }\r\n\r\n /**\r\n * List of instances to render in case the source mesh has instances\r\n */\r\n public customInstances = new SmartArray<Matrix>(32);\r\n\r\n private static _GetShader(scene: Scene): ShaderMaterial {\r\n if (!scene._edgeRenderLineShader) {\r\n const shader = new ShaderMaterial(\r\n \"lineShader\",\r\n scene,\r\n \"line\",\r\n {\r\n attributes: [\"position\", \"normal\"],\r\n uniforms: [\"world\", \"viewProjection\", \"color\", \"width\", \"aspectRatio\"],\r\n uniformBuffers: [\"Scene\", \"Mesh\"],\r\n },\r\n false\r\n );\r\n\r\n shader.disableDepthWrite = true;\r\n shader.backFaceCulling = false;\r\n shader.checkReadyOnEveryCall = scene.getEngine().isWebGPU;\r\n\r\n scene._edgeRenderLineShader = shader;\r\n }\r\n\r\n return scene._edgeRenderLineShader;\r\n }\r\n\r\n /**\r\n * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.\r\n * Beware when you use this class with complex objects as the adjacencies computation can be really long\r\n * @param source Mesh used to create edges\r\n * @param epsilon sum of angles in adjacency to check for edge\r\n * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true\r\n * @param generateEdgesLines - should generate Lines or only prepare resources.\r\n * @param options The options to apply when generating the edges\r\n */\r\n constructor(source: AbstractMesh, epsilon = 0.95, checkVerticesInsteadOfIndices = false, generateEdgesLines = true, options?: IEdgesRendererOptions) {\r\n this._source = source;\r\n this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;\r\n this._options = options ?? null;\r\n\r\n this._epsilon = epsilon;\r\n if (this._source.getScene().getEngine().isWebGPU) {\r\n this._drawWrapper = new DrawWrapper(source.getEngine());\r\n }\r\n\r\n this._prepareRessources();\r\n if (generateEdgesLines) {\r\n if (options?.useAlternateEdgeFinder ?? true) {\r\n this._generateEdgesLinesAlternate();\r\n } else {\r\n this._generateEdgesLines();\r\n }\r\n }\r\n\r\n this._meshRebuildObserver = this._source.onRebuildObservable.add(() => {\r\n this._rebuild();\r\n });\r\n\r\n this._meshDisposeObserver = this._source.onDisposeObservable.add(() => {\r\n this.dispose();\r\n });\r\n }\r\n\r\n protected _prepareRessources(): void {\r\n if (this._lineShader) {\r\n return;\r\n }\r\n\r\n this._lineShader = EdgesRenderer._GetShader(this._source.getScene());\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n let buffer = this._buffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer._rebuild();\r\n }\r\n\r\n buffer = this._buffers[VertexBuffer.NormalKind];\r\n if (buffer) {\r\n buffer._rebuild();\r\n }\r\n\r\n const scene = this._source.getScene();\r\n const engine = scene.getEngine();\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n }\r\n\r\n /**\r\n * Releases the required resources for the edges renderer\r\n */\r\n public dispose(): void {\r\n this._source.onRebuildObservable.remove(this._meshRebuildObserver);\r\n this._source.onDisposeObservable.remove(this._meshDisposeObserver);\r\n\r\n let buffer = this._buffers[VertexBuffer.PositionKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._buffers[VertexBuffer.PositionKind] = null;\r\n }\r\n buffer = this._buffers[VertexBuffer.NormalKind];\r\n if (buffer) {\r\n buffer.dispose();\r\n this._buffers[VertexBuffer.NormalKind] = null;\r\n }\r\n\r\n if (this._ib) {\r\n this._source.getScene().getEngine()._releaseBuffer(this._ib);\r\n }\r\n this._lineShader.dispose();\r\n\r\n this._drawWrapper?.dispose();\r\n }\r\n\r\n protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number {\r\n if ((pa === p0 && pb === p1) || (pa === p1 && pb === p0)) {\r\n return 0;\r\n }\r\n\r\n if ((pa === p1 && pb === p2) || (pa === p2 && pb === p1)) {\r\n return 1;\r\n }\r\n\r\n if ((pa === p2 && pb === p0) || (pa === p0 && pb === p2)) {\r\n return 2;\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number {\r\n const eps = 1e-10;\r\n if ((pa.equalsWithEpsilon(p0, eps) && pb.equalsWithEpsilon(p1, eps)) || (pa.equalsWithEpsilon(p1, eps) && pb.equalsWithEpsilon(p0, eps))) {\r\n return 0;\r\n }\r\n\r\n if ((pa.equalsWithEpsilon(p1, eps) && pb.equalsWithEpsilon(p2, eps)) || (pa.equalsWithEpsilon(p2, eps) && pb.equalsWithEpsilon(p1, eps))) {\r\n return 1;\r\n }\r\n\r\n if ((pa.equalsWithEpsilon(p2, eps) && pb.equalsWithEpsilon(p0, eps)) || (pa.equalsWithEpsilon(p0, eps) && pb.equalsWithEpsilon(p2, eps))) {\r\n return 2;\r\n }\r\n\r\n return -1;\r\n }\r\n\r\n /**\r\n * Checks if the pair of p0 and p1 is en edge\r\n * @param faceIndex\r\n * @param edge\r\n * @param faceNormals\r\n * @param p0\r\n * @param p1\r\n * @private\r\n */\r\n protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void {\r\n let needToCreateLine;\r\n\r\n if (edge === undefined) {\r\n needToCreateLine = true;\r\n } else {\r\n const dotProduct = Vector3.Dot(faceNormals[faceIndex], faceNormals[edge]);\r\n\r\n needToCreateLine = dotProduct < this._epsilon;\r\n }\r\n\r\n if (needToCreateLine) {\r\n this.createLine(p0, p1, this._linesPositions.length / 3);\r\n }\r\n }\r\n\r\n /**\r\n * push line into the position, normal and index buffer\r\n * @param p0\r\n * @param p1\r\n * @param offset\r\n * @protected\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n protected createLine(p0: Vector3, p1: Vector3, offset: number) {\r\n // Positions\r\n this._linesPositions.push(p0.x, p0.y, p0.z, p0.x, p0.y, p0.z, p1.x, p1.y, p1.z, p1.x, p1.y, p1.z);\r\n\r\n // Normals\r\n this._linesNormals.push(p1.x, p1.y, p1.z, -1, p1.x, p1.y, p1.z, 1, p0.x, p0.y, p0.z, -1, p0.x, p0.y, p0.z, 1);\r\n\r\n // Indices\r\n this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);\r\n }\r\n\r\n /**\r\n * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm\r\n * @param edgePoints\r\n * @param indexTriangle\r\n * @param indices\r\n * @param remapVertexIndices\r\n */\r\n private _tessellateTriangle(edgePoints: Array<Array<[number, number]>>, indexTriangle: number, indices: Array<number>, remapVertexIndices: Array<number>): void {\r\n const makePointList = (edgePoints: Array<[number, number]>, pointIndices: Array<number>, firstIndex: number) => {\r\n if (firstIndex >= 0) {\r\n pointIndices.push(firstIndex);\r\n }\r\n\r\n for (let i = 0; i < edgePoints.length; ++i) {\r\n pointIndices.push(edgePoints[i][0]);\r\n }\r\n };\r\n\r\n let startEdge = 0;\r\n\r\n if (edgePoints[1].length >= edgePoints[0].length && edgePoints[1].length >= edgePoints[2].length) {\r\n startEdge = 1;\r\n } else if (edgePoints[2].length >= edgePoints[0].length && edgePoints[2].length >= edgePoints[1].length) {\r\n startEdge = 2;\r\n }\r\n\r\n for (let e = 0; e < 3; ++e) {\r\n if (e === startEdge) {\r\n edgePoints[e].sort((a, b) => (a[1] < b[1] ? -1 : a[1] > b[1] ? 1 : 0));\r\n } else {\r\n edgePoints[e].sort((a, b) => (a[1] > b[1] ? -1 : a[1] < b[1] ? 1 : 0));\r\n }\r\n }\r\n\r\n const mainPointIndices: Array<number> = [],\r\n otherPointIndices: Array<number> = [];\r\n\r\n makePointList(edgePoints[startEdge], mainPointIndices, -1);\r\n\r\n const numMainPoints = mainPointIndices.length;\r\n\r\n for (let i = startEdge + 2; i >= startEdge + 1; --i) {\r\n makePointList(edgePoints[i % 3], otherPointIndices, i !== startEdge + 2 ? remapVertexIndices[indices[indexTriangle + ((i + 1) % 3)]] : -1);\r\n }\r\n\r\n const numOtherPoints = otherPointIndices.length;\r\n\r\n const idxMain = 0;\r\n const idxOther = 0;\r\n\r\n indices.push(remapVertexIndices[indices[indexTriangle + startEdge]], mainPointIndices[0], otherPointIndices[0]);\r\n indices.push(remapVertexIndices[indices[indexTriangle + ((startEdge + 1) % 3)]], otherPointIndices[numOtherPoints - 1], mainPointIndices[numMainPoints - 1]);\r\n\r\n const bucketIsMain = numMainPoints <= numOtherPoints;\r\n\r\n const bucketStep = bucketIsMain ? numMainPoints : numOtherPoints;\r\n const bucketLimit = bucketIsMain ? numOtherPoints : numMainPoints;\r\n const bucketIdxLimit = bucketIsMain ? numMainPoints - 1 : numOtherPoints - 1;\r\n const winding = bucketIsMain ? 0 : 1;\r\n\r\n let numTris = numMainPoints + numOtherPoints - 2;\r\n\r\n let bucketIdx = bucketIsMain ? idxMain : idxOther;\r\n let nbucketIdx = bucketIsMain ? idxOther : idxMain;\r\n const bucketPoints = bucketIsMain ? mainPointIndices : otherPointIndices;\r\n const nbucketPoints = bucketIsMain ? otherPointIndices : mainPointIndices;\r\n\r\n let bucket = 0;\r\n\r\n while (numTris-- > 0) {\r\n if (winding) {\r\n indices.push(bucketPoints[bucketIdx], nbucketPoints[nbucketIdx]);\r\n } else {\r\n indices.push(nbucketPoints[nbucketIdx], bucketPoints[bucketIdx]);\r\n }\r\n\r\n bucket += bucketStep;\r\n\r\n let lastIdx;\r\n\r\n if (bucket >= bucketLimit && bucketIdx < bucketIdxLimit) {\r\n lastIdx = bucketPoints[++bucketIdx];\r\n bucket -= bucketLimit;\r\n } else {\r\n lastIdx = nbucketPoints[++nbucketIdx];\r\n }\r\n\r\n indices.push(lastIdx);\r\n }\r\n\r\n indices[indexTriangle + 0] = indices[indices.length - 3];\r\n indices[indexTriangle + 1] = indices[indices.length - 2];\r\n indices[indexTriangle + 2] = indices[indices.length - 1];\r\n\r\n indices.length = indices.length - 3;\r\n }\r\n\r\n private _generateEdgesLinesAlternate(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n let indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n if (!Array.isArray(indices)) {\r\n indices = Array.from(indices);\r\n }\r\n\r\n /**\r\n * Find all vertices that are at the same location (with an epsilon) and remapp them on the same vertex\r\n */\r\n const useFastVertexMerger = this._options?.useFastVertexMerger ?? true;\r\n const epsVertexMerge = useFastVertexMerger ? Math.round(-Math.log(this._options?.epsilonVertexMerge ?? 1e-6) / Math.log(10)) : this._options?.epsilonVertexMerge ?? 1e-6;\r\n const remapVertexIndices: Array<number> = [];\r\n const uniquePositions: Array<number> = []; // list of unique index of vertices - needed for tessellation\r\n\r\n if (useFastVertexMerger) {\r\n const mapVertices: { [key: string]: number } = {};\r\n for (let v1 = 0; v1 < positions.length; v1 += 3) {\r\n const x1 = positions[v1 + 0],\r\n y1 = positions[v1 + 1],\r\n z1 = positions[v1 + 2];\r\n\r\n const key = x1.toFixed(epsVertexMerge) + \"|\" + y1.toFixed(epsVertexMerge) + \"|\" + z1.toFixed(epsVertexMerge);\r\n\r\n if (mapVertices[key] !== undefined) {\r\n remapVertexIndices.push(mapVertices[key]);\r\n } else {\r\n const idx = v1 / 3;\r\n mapVertices[key] = idx;\r\n remapVertexIndices.push(idx);\r\n uniquePositions.push(idx);\r\n }\r\n }\r\n } else {\r\n for (let v1 = 0; v1 < positions.length; v1 += 3) {\r\n const x1 = positions[v1 + 0],\r\n y1 = positions[v1 + 1],\r\n z1 = positions[v1 + 2];\r\n let found = false;\r\n for (let v2 = 0; v2 < v1 && !found; v2 += 3) {\r\n const x2 = positions[v2 + 0],\r\n y2 = positions[v2 + 1],\r\n z2 = positions[v2 + 2];\r\n\r\n if (Math.abs(x1 - x2) < epsVertexMerge && Math.abs(y1 - y2) < epsVertexMerge && Math.abs(z1 - z2) < epsVertexMerge) {\r\n remapVertexIndices.push(v2 / 3);\r\n found = true;\r\n break;\r\n }\r\n }\r\n\r\n if (!found) {\r\n remapVertexIndices.push(v1 / 3);\r\n uniquePositions.push(v1 / 3);\r\n }\r\n }\r\n }\r\n\r\n if (this._options?.applyTessellation) {\r\n /**\r\n * Tessellate triangles if necessary:\r\n *\r\n * A\r\n * +\r\n * |\\\r\n * | \\\r\n * | \\\r\n * E + \\\r\n * /| \\\r\n * / | \\\r\n * / | \\\r\n * +---+-------+ B\r\n * D C\r\n *\r\n * For the edges to be rendered correctly, the ABC triangle has to be split into ABE and BCE, else AC is considered to be an edge, whereas only AE should be.\r\n *\r\n * The tessellation process looks for the vertices like E that are in-between two other vertices making of an edge and create new triangles as necessary\r\n */\r\n\r\n // First step: collect the triangles to tessellate\r\n const epsVertexAligned = this._options?.epsilonVertexAligned ?? 1e-6;\r\n const mustTesselate: Array<{ index: number; edgesPoints: Array<Array<[number, number]>> }> = []; // liste of triangles that must be tessellated\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n // loop over all triangles\r\n let triangleToTessellate: { index: number; edgesPoints: Array<Array<[number, number]>> } | undefined;\r\n\r\n for (let i = 0; i < 3; ++i) {\r\n // loop over the 3 edges of the triangle\r\n const p0Index = remapVertexIndices[indices[index + i]];\r\n const p1Index = remapVertexIndices[indices[index + ((i + 1) % 3)]];\r\n const p2Index = remapVertexIndices[indices[index + ((i + 2) % 3)]];\r\n\r\n if (p0Index === p1Index) {\r\n continue;\r\n } // degenerated triangle - don't process\r\n\r\n const p0x = positions[p0Index * 3 + 0],\r\n p0y = positions[p0Index * 3 + 1],\r\n p0z = positions[p0Index * 3 + 2];\r\n const p1x = positions[p1Index * 3 + 0],\r\n p1y = positions[p1Index * 3 + 1],\r\n p1z = positions[p1Index * 3 + 2];\r\n\r\n const p0p1 = Math.sqrt((p1x - p0x) * (p1x - p0x) + (p1y - p0y) * (p1y - p0y) + (p1z - p0z) * (p1z - p0z));\r\n\r\n for (let v = 0; v < uniquePositions.length - 1; v++) {\r\n // loop over all (unique) vertices and look for the ones that would be in-between p0 and p1\r\n const vIndex = uniquePositions[v];\r\n\r\n if (vIndex === p0Index || vIndex === p1Index || vIndex === p2Index) {\r\n continue;\r\n } // don't handle the vertex if it is a vertex of the current triangle\r\n\r\n const x = positions[vIndex * 3 + 0],\r\n y = positions[vIndex * 3 + 1],\r\n z = positions[vIndex * 3 + 2];\r\n\r\n const p0p = Math.sqrt((x - p0x) * (x - p0x) + (y - p0y) * (y - p0y) + (z - p0z) * (z - p0z));\r\n const pp1 = Math.sqrt((x - p1x) * (x - p1x) + (y - p1y) * (y - p1y) + (z - p1z) * (z - p1z));\r\n\r\n if (Math.abs(p0p + pp1 - p0p1) < epsVertexAligned) {\r\n // vertices are aligned and p in-between p0 and p1 if distance(p0, p) + distance (p, p1) ~ distance(p0, p1)\r\n if (!triangleToTessellate) {\r\n triangleToTessellate = {\r\n index: index,\r\n edgesPoints: [[], [], []],\r\n };\r\n mustTesselate.push(triangleToTessellate);\r\n }\r\n triangleToTessellate.edgesPoints[i].push([vIndex, p0p]);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Second step: tesselate the triangles\r\n for (let t = 0; t < mustTesselate.length; ++t) {\r\n const triangle = mustTesselate[t];\r\n\r\n this._tessellateTriangle(triangle.edgesPoints, triangle.index, indices, remapVertexIndices);\r\n }\r\n\r\n mustTesselate.length = 0;\r\n }\r\n\r\n /**\r\n * Collect the edges to render\r\n */\r\n const edges: { [key: string]: { normal: Vector3; done: boolean; index: number; i: number } } = {};\r\n\r\n for (let index = 0; index < indices.length; index += 3) {\r\n let faceNormal;\r\n for (let i = 0; i < 3; ++i) {\r\n let p0Index = remapVertexIndices[indices[index + i]];\r\n let p1Index = remapVertexIndices[indices[index + ((i + 1) % 3)]];\r\n const p2Index = remapVertexIndices[indices[index + ((i + 2) % 3)]];\r\n\r\n if (p0Index === p1Index || ((p0Index === p2Index || p1Index === p2Index) && this._options?.removeDegeneratedTriangles)) {\r\n continue;\r\n }\r\n\r\n TmpVectors.Vector3[0].copyFromFloats(positions[p0Index * 3 + 0], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n TmpVectors.Vector3[1].copyFromFloats(positions[p1Index * 3 + 0], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n TmpVectors.Vector3[2].copyFromFloats(positions[p2Index * 3 + 0], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);\r\n\r\n if (!faceNormal) {\r\n TmpVectors.Vector3[1].subtractToRef(TmpVectors.Vector3[0], TmpVectors.Vector3[3]);\r\n TmpVectors.Vector3[2].subtractToRef(TmpVectors.Vector3[1], TmpVectors.Vector3[4]);\r\n faceNormal = Vector3.Cross(TmpVectors.Vector3[3], TmpVectors.Vector3[4]);\r\n faceNormal.normalize();\r\n }\r\n\r\n if (p0Index > p1Index) {\r\n const tmp = p0Index;\r\n p0Index = p1Index;\r\n p1Index = tmp;\r\n }\r\n\r\n const key = p0Index + \"_\" + p1Index;\r\n const ei = edges[key];\r\n\r\n if (ei) {\r\n if (!ei.done) {\r\n const dotProduct = Vector3.Dot(faceNormal, ei.normal);\r\n\r\n if (dotProduct < this._epsilon) {\r\n this.createLine(TmpVectors.Vector3[0], TmpVectors.Vector3[1], this._linesPositions.length / 3);\r\n }\r\n\r\n ei.done = true;\r\n }\r\n } else {\r\n edges[key] = { normal: faceNormal, done: false, index: index, i: i };\r\n }\r\n }\r\n }\r\n\r\n for (const key in edges) {\r\n const ei = edges[key];\r\n if (!ei.done) {\r\n // Orphaned edge - we must display it\r\n const p0Index = remapVertexIndices[indices[ei.index + ei.i]];\r\n const p1Index = remapVertexIndices[indices[ei.index + ((ei.i + 1) % 3)]];\r\n\r\n TmpVectors.Vector3[0].copyFromFloats(positions[p0Index * 3 + 0], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n TmpVectors.Vector3[1].copyFromFloats(positions[p1Index * 3 + 0], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n\r\n this.createLine(TmpVectors.Vector3[0], TmpVectors.Vector3[1], this._linesPositions.length / 3);\r\n }\r\n }\r\n\r\n /**\r\n * Merge into a single mesh\r\n */\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._buffersForInstances[VertexBuffer.PositionKind] = this._buffers[VertexBuffer.PositionKind];\r\n this._buffersForInstances[VertexBuffer.NormalKind] = this._buffers[VertexBuffer.NormalKind];\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n\r\n /**\r\n * Generates lines edges from adjacencjes\r\n * @private\r\n */\r\n _generateEdgesLines(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n // First let's find adjacencies\r\n const adjacencies: FaceAdjacencies[] = [];\r\n const faceNormals: Vector3[] = [];\r\n let index: number;\r\n let faceAdjacencies: FaceAdjacencies;\r\n\r\n // Prepare faces\r\n for (index = 0; index < indices.length; index += 3) {\r\n faceAdjacencies = new FaceAdjacencies();\r\n const p0Index = indices[index];\r\n const p1Index = indices[index + 1];\r\n const p2Index = indices[index + 2];\r\n\r\n faceAdjacencies.p0 = new Vector3(positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);\r\n faceAdjacencies.p1 = new Vector3(positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);\r\n faceAdjacencies.p2 = new Vector3(positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);\r\n const faceNormal = Vector3.Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));\r\n\r\n faceNormal.normalize();\r\n\r\n faceNormals.push(faceNormal);\r\n adjacencies.push(faceAdjacencies);\r\n }\r\n\r\n // Scan\r\n for (index = 0; index < adjacencies.length; index++) {\r\n faceAdjacencies = adjacencies[index];\r\n\r\n for (let otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {\r\n const otherFaceAdjacencies = adjacencies[otherIndex];\r\n\r\n if (faceAdjacencies.edgesConnectedCount === 3) {\r\n // Full\r\n break;\r\n }\r\n\r\n if (otherFaceAdjacencies.edgesConnectedCount === 3) {\r\n // Full\r\n continue;\r\n }\r\n\r\n const otherP0 = indices[otherIndex * 3];\r\n const otherP1 = indices[otherIndex * 3 + 1];\r\n const otherP2 = indices[otherIndex * 3 + 2];\r\n\r\n for (let edgeIndex = 0; edgeIndex < 3; edgeIndex++) {\r\n let otherEdgeIndex: number = 0;\r\n\r\n if (faceAdjacencies.edges[edgeIndex] !== undefined) {\r\n continue;\r\n }\r\n\r\n switch (edgeIndex) {\r\n case 0:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p0,\r\n faceAdjacencies.p1,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n case 1:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p1,\r\n faceAdjacencies.p2,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n case 2:\r\n if (this._checkVerticesInsteadOfIndices) {\r\n otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(\r\n faceAdjacencies.p2,\r\n faceAdjacencies.p0,\r\n otherFaceAdjacencies.p0,\r\n otherFaceAdjacencies.p1,\r\n otherFaceAdjacencies.p2\r\n );\r\n } else {\r\n otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);\r\n }\r\n break;\r\n }\r\n\r\n if (otherEdgeIndex === -1) {\r\n continue;\r\n }\r\n\r\n faceAdjacencies.edges[edgeIndex] = otherIndex;\r\n otherFaceAdjacencies.edges[otherEdgeIndex] = index;\r\n\r\n faceAdjacencies.edgesConnectedCount++;\r\n otherFaceAdjacencies.edgesConnectedCount++;\r\n\r\n if (faceAdjacencies.edgesConnectedCount === 3) {\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Create lines\r\n for (index = 0; index < adjacencies.length; index++) {\r\n // We need a line when a face has no adjacency on a specific edge or if all the adjacencies has an angle greater than epsilon\r\n const current = adjacencies[index];\r\n\r\n this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);\r\n this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);\r\n this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);\r\n }\r\n\r\n // Merge into a single mesh\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._buffersForInstances[VertexBuffer.PositionKind] = this._buffers[VertexBuffer.PositionKind];\r\n this._buffersForInstances[VertexBuffer.NormalKind] = this._buffers[VertexBuffer.NormalKind];\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n\r\n /**\r\n * Checks whether or not the edges renderer is ready to render.\r\n * @returns true if ready, otherwise false.\r\n */\r\n public isReady(): boolean {\r\n return this._lineShader.isReady(this._source, (this._source.hasInstances && this.customInstances.length > 0) || this._source.hasThinInstances);\r\n }\r\n\r\n /**\r\n * Renders the edges of the attached mesh,\r\n */\r\n public render(): void {\r\n const scene = this._source.getScene();\r\n\r\n const currentDrawWrapper = this._lineShader._getDrawWrapper();\r\n if (this._drawWrapper) {\r\n this._lineShader._setDrawWrapper(this._drawWrapper);\r\n }\r\n\r\n if (!this.isReady() || !scene.activeCamera) {\r\n this._lineShader._setDrawWrapper(currentDrawWrapper);\r\n return;\r\n }\r\n\r\n const hasInstances = this._source.hasInstances && this.customInstances.length > 0;\r\n const useBuffersWithInstances = hasInstances || this._source.hasThinInstances;\r\n\r\n let instanceCount = 0;\r\n\r\n if (useBuffersWithInstances) {\r\n this._buffersForInstances[\"world0\"] = (this._source as Mesh).getVertexBuffer(\"world0\");\r\n this._buffersForInstances[\"world1\"] = (this._source as Mesh).getVertexBuffer(\"world1\");\r\n this._buffersForInstances[\"world2\"] = (this._source as Mesh).getVertexBuffer(\"world2\");\r\n this._buffersForInstances[\"world3\"] = (this._source as Mesh).getVertexBuffer(\"world3\");\r\n\r\n if (hasInstances) {\r\n const instanceStorage = (this._source as Mesh)._instanceDataStorage;\r\n\r\n instanceCount = this.customInstances.length;\r\n\r\n if (!instanceStorage.instancesData) {\r\n if (!this._source.getScene()._activeMeshesFrozen) {\r\n this.customInstances.reset();\r\n }\r\n return;\r\n }\r\n\r\n if (!instanceStorage.isFrozen) {\r\n let offset = 0;\r\n\r\n for (let i = 0; i < instanceCount; ++i) {\r\n this.customInstances.data[i].copyToArray(instanceStorage.instancesData, offset);\r\n offset += 16;\r\n }\r\n\r\n instanceStorage.instancesBuffer!.updateDirectly(instanceStorage.instancesData, 0, instanceCount);\r\n }\r\n } else {\r\n instanceCount = (this._source as Mesh).thinInstanceCount;\r\n }\r\n }\r\n\r\n const engine = scene.getEngine();\r\n this._lineShader._preBind();\r\n\r\n if (this._source.edgesColor.a !== 1) {\r\n engine.setAlphaMode(Constants.ALPHA_COMBINE);\r\n } else {\r\n engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n }\r\n\r\n // VBOs\r\n engine.bindBuffers(useBuffersWithInstances ? this._buffersForInstances : this._buffers, this._ib, <Effect>this._lineShader.getEffect());\r\n\r\n scene.resetCachedMaterial();\r\n this._lineShader.setColor4(\"color\", this._source.edgesColor);\r\n\r\n if (scene.activeCamera.mode === Camera.ORTHOGRAPHIC_CAMERA) {\r\n this._lineShader.setFloat(\"width\", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);\r\n } else {\r\n this._lineShader.setFloat(\"width\", this._source.edgesWidth / this.edgesWidthScalerForPerspective);\r\n }\r\n\r\n this._lineShader.setFloat(\"aspectRatio\", engine.getAspectRatio(scene.activeCamera));\r\n this._lineShader.bind(this._source.getWorldMatrix(), this._source);\r\n\r\n // Draw order\r\n engine.drawElementsType(Material.TriangleFillMode, 0, this._indicesCount, instanceCount);\r\n this._lineShader.unbind();\r\n\r\n if (useBuffersWithInstances) {\r\n engine.unbindInstanceAttributes();\r\n }\r\n\r\n if (!this._source.getScene()._activeMeshesFrozen) {\r\n this.customInstances.reset();\r\n }\r\n\r\n this._lineShader._setDrawWrapper(currentDrawWrapper);\r\n }\r\n}\r\n\r\n/**\r\n * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation\r\n */\r\nexport class LineEdgesRenderer extends EdgesRenderer {\r\n /**\r\n * This constructor turns off auto generating edges line in Edges Renderer to make it here.\r\n * @param source LineMesh used to generate edges\r\n * @param epsilon not important (specified angle for edge detection)\r\n * @param checkVerticesInsteadOfIndices not important for LineMesh\r\n */\r\n constructor(source: AbstractMesh, epsilon = 0.95, checkVerticesInsteadOfIndices = false) {\r\n super(source, epsilon, checkVerticesInsteadOfIndices, false);\r\n this._generateEdgesLines();\r\n }\r\n\r\n /**\r\n * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.\r\n */\r\n override _generateEdgesLines(): void {\r\n const positions = this._source.getVerticesData(VertexBuffer.PositionKind);\r\n const indices = this._source.getIndices();\r\n\r\n if (!indices || !positions) {\r\n return;\r\n }\r\n\r\n const p0 = TmpVectors.Vector3[0];\r\n const p1 = TmpVectors.Vector3[1];\r\n const len = indices.length - 1;\r\n for (let i = 0, offset = 0; i < len; i += 2, offset += 4) {\r\n Vector3.FromArrayToRef(positions, 3 * indices[i], p0);\r\n Vector3.FromArrayToRef(positions, 3 * indices[i + 1], p1);\r\n this.createLine(p0, p1, offset);\r\n }\r\n\r\n // Merge into a single mesh\r\n const engine = this._source.getScene().getEngine();\r\n\r\n this._buffers[VertexBuffer.PositionKind] = new VertexBuffer(engine, this._linesPositions, VertexBuffer.PositionKind, false);\r\n this._buffers[VertexBuffer.NormalKind] = new VertexBuffer(engine, this._linesNormals, VertexBuffer.NormalKind, false, false, 4);\r\n\r\n this._ib = engine.createIndexBuffer(this._linesIndices);\r\n\r\n this._indicesCount = this._linesIndices.length;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,7 @@
1
+ import "./sceneUboDeclaration";
2
+ import "./meshUboDeclaration";
3
+ /** @internal */
4
+ export declare const lineUboDeclaration: {
5
+ name: string;
6
+ shader: string;
7
+ };
@@ -0,0 +1,14 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ import "./sceneUboDeclaration.js";
4
+ import "./meshUboDeclaration.js";
5
+ const name = "lineUboDeclaration";
6
+ const shader = `layout(std140,column_major) uniform;
7
+ #include<sceneUboDeclaration>
8
+ #include<meshUboDeclaration>
9
+ `;
10
+ // Sideeffect
11
+ ShaderStore.IncludesShadersStore[name] = shader;
12
+ /** @internal */
13
+ export const lineUboDeclaration = { name, shader };
14
+ //# sourceMappingURL=lineUboDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineUboDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/lineUboDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,uBAAuB,CAAC;AAC/B,OAAO,sBAAsB,CAAC;AAE9B,MAAM,IAAI,GAAG,oBAAoB,CAAC;AAClC,MAAM,MAAM,GAAG;;;CAGd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\nimport \"./sceneUboDeclaration\";\nimport \"./meshUboDeclaration\";\n\nconst name = \"lineUboDeclaration\";\nconst shader = `layout(std140,column_major) uniform;\n#include<sceneUboDeclaration>\n#include<meshUboDeclaration>\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const lineUboDeclaration = { name, shader };\n"]}
@@ -0,0 +1,5 @@
1
+ /** @internal */
2
+ export declare const lineVertexDeclaration: {
3
+ name: string;
4
+ shader: string;
5
+ };
@@ -0,0 +1,11 @@
1
+ // Do not edit.
2
+ import { ShaderStore } from "../../Engines/shaderStore.js";
3
+ const name = "lineVertexDeclaration";
4
+ const shader = `uniform mat4 viewProjection;
5
+ #define ADDITIONAL_VERTEX_DECLARATION
6
+ `;
7
+ // Sideeffect
8
+ ShaderStore.IncludesShadersStore[name] = shader;
9
+ /** @internal */
10
+ export const lineVertexDeclaration = { name, shader };
11
+ //# sourceMappingURL=lineVertexDeclaration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lineVertexDeclaration.js","sourceRoot":"","sources":["../../../../../dev/core/src/Shaders/ShadersInclude/lineVertexDeclaration.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,IAAI,GAAG,uBAAuB,CAAC;AACrC,MAAM,MAAM,GAAG;;CAEd,CAAC;AACF,aAAa;AACb,WAAW,CAAC,oBAAoB,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;AAChD,gBAAgB;AAChB,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC","sourcesContent":["// Do not edit.\nimport { ShaderStore } from \"../../Engines/shaderStore\";\n\nconst name = \"lineVertexDeclaration\";\nconst shader = `uniform mat4 viewProjection;\n#define ADDITIONAL_VERTEX_DECLARATION\n`;\n// Sideeffect\nShaderStore.IncludesShadersStore[name] = shader;\n/** @internal */\nexport const lineVertexDeclaration = { name, shader };\n"]}
@@ -38,7 +38,12 @@ uniform float directionRandomizer;
38
38
  #endif
39
39
  #endif
40
40
  #ifdef CONEEMITTER
41
- uniform vec2 radius;uniform float coneAngle;uniform vec2 height;uniform float directionRandomizer;
41
+ uniform vec2 radius;uniform float coneAngle;uniform vec2 height;
42
+ #ifdef DIRECTEDCONEEMITTER
43
+ uniform vec3 direction1;uniform vec3 direction2;
44
+ #else
45
+ uniform float directionRandomizer;
46
+ #endif
42
47
  #endif
43
48
  in vec3 position;
44
49
  #ifdef CUSTOMEMITTER
@@ -159,7 +164,12 @@ float h=0.0001;
159
164
  float h=randoms2.y*height.y;h=1.-h*h;
160
165
  #endif
161
166
  float lRadius=radius.x-radius.x*randoms2.z*radius.y;lRadius=lRadius*h;float randX=lRadius*sin(s);float randZ=lRadius*cos(s);float randY=h *height.x;newPosition=vec3(randX,randY,randZ);
162
- if (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {vec3 randoms3=getRandomVec3(seed.z);newDirection=normalize(newPosition+directionRandomizer*randoms3); }
167
+ vec3 randoms3=getRandomVec3(seed.z);
168
+ #ifdef DIRECTEDCONEEMITTER
169
+ newDirection=direction1+(direction2-direction1)*randoms3;
170
+ #else
171
+ if (abs(cos(coneAngle))==1.0) {newDirection=vec3(0.,1.0,0.);} else {newDirection=normalize(newPosition+directionRandomizer*randoms3); }
172
+ #endif
163
173
  #elif defined(CUSTOMEMITTER)
164
174
  newPosition=initialPosition;outInitialPosition=initialPosition;
165
175
  #else