@onerjs/core 8.30.6 → 8.30.8

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 (104) hide show
  1. package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
  2. package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
  3. package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
  4. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
  5. package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
  6. package/AudioV2/audioParameter.d.ts +5 -1
  7. package/AudioV2/audioParameter.js +4 -0
  8. package/AudioV2/audioParameter.js.map +1 -1
  9. package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
  10. package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
  11. package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
  12. package/Debug/debugLayer.d.ts +1 -1
  13. package/Debug/debugLayer.js.map +1 -1
  14. package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
  15. package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
  16. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
  17. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  18. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
  19. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +1 -1
  20. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
  21. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
  22. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
  23. package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
  24. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
  25. package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
  26. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +3 -0
  27. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +13 -0
  28. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  30. package/FrameGraph/Node/Blocks/index.js +1 -0
  31. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  32. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
  33. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
  34. package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
  35. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
  36. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
  37. package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
  38. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
  39. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
  40. package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
  41. package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +4 -0
  42. package/FrameGraph/Tasks/Texture/copyToTextureTask.js +7 -1
  43. package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
  44. package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
  45. package/FrameGraph/frameGraphRenderContext.js +22 -3
  46. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  47. package/Materials/PBR/openpbrMaterial.js +2 -1
  48. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  49. package/Meshes/Node/Blocks/randomBlock.js +11 -11
  50. package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
  51. package/Misc/copyTextureToTexture.d.ts +8 -1
  52. package/Misc/copyTextureToTexture.js +16 -2
  53. package/Misc/copyTextureToTexture.js.map +1 -1
  54. package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
  55. package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
  56. package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
  57. package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
  58. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
  59. package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
  60. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
  61. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
  62. package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
  63. package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
  64. package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
  65. package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
  66. package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
  67. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
  68. package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
  69. package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
  70. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
  71. package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
  72. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +10 -1
  73. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +45 -13
  74. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  75. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  76. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  77. package/Particles/Node/Blocks/particleRandomBlock.js +10 -10
  78. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  79. package/Particles/Node/Blocks/systemBlock.d.ts +4 -0
  80. package/Particles/Node/Blocks/systemBlock.js +9 -0
  81. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  82. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  83. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  84. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  85. package/Particles/Node/nodeParticleBuildState.js +5 -0
  86. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  87. package/Particles/Node/nodeParticleSystemSet.helper.js +40 -12
  88. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  89. package/Particles/Node/nodeParticleSystemSet.js +1 -1
  90. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  91. package/Particles/thinParticleSystem.function.d.ts +2 -2
  92. package/Particles/thinParticleSystem.function.js +2 -2
  93. package/Particles/thinParticleSystem.function.js.map +1 -1
  94. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
  95. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  96. package/Rendering/prePassRenderer.js +4 -1
  97. package/Rendering/prePassRenderer.js.map +1 -1
  98. package/Shaders/copyTextureToTexture.fragment.js +2 -2
  99. package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
  100. package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
  101. package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
  102. package/XR/webXRSessionManager.js +4 -0
  103. package/XR/webXRSessionManager.js.map +1 -1
  104. package/package.json +1 -1
@@ -93,32 +93,32 @@ export class RandomBlock extends NodeGeometryBlock {
93
93
  case NodeGeometryBlockConnectionPointTypes.Int:
94
94
  case NodeGeometryBlockConnectionPointTypes.Float: {
95
95
  func = (state) => {
96
- const min = this.min.getConnectedValue(state) || 0;
97
- const max = this.max.getConnectedValue(state) || 0;
96
+ const min = this.min.getConnectedValue(state) ?? 0;
97
+ const max = this.max.getConnectedValue(state) ?? 0;
98
98
  return min + Math.random() * (max - min);
99
99
  };
100
100
  break;
101
101
  }
102
102
  case NodeGeometryBlockConnectionPointTypes.Vector2: {
103
103
  func = (state) => {
104
- const min = this.min.getConnectedValue(state) || Vector2.Zero();
105
- const max = this.max.getConnectedValue(state) || Vector2.Zero();
104
+ const min = this.min.getConnectedValue(state) ?? Vector2.Zero();
105
+ const max = this.max.getConnectedValue(state) ?? Vector2.Zero();
106
106
  return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));
107
107
  };
108
108
  break;
109
109
  }
110
110
  case NodeGeometryBlockConnectionPointTypes.Vector3: {
111
111
  func = (state) => {
112
- const min = this.min.getConnectedValue(state) || Vector3.Zero();
113
- const max = this.max.getConnectedValue(state) || Vector3.Zero();
112
+ const min = this.min.getConnectedValue(state) ?? Vector3.Zero();
113
+ const max = this.max.getConnectedValue(state) ?? Vector3.Zero();
114
114
  return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));
115
115
  };
116
116
  break;
117
117
  }
118
118
  case NodeGeometryBlockConnectionPointTypes.Vector4: {
119
119
  func = (state) => {
120
- const min = this.min.getConnectedValue(state) || Vector4.Zero();
121
- const max = this.max.getConnectedValue(state) || Vector4.Zero();
120
+ const min = this.min.getConnectedValue(state) ?? Vector4.Zero();
121
+ const max = this.max.getConnectedValue(state) ?? Vector4.Zero();
122
122
  return new Vector4(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z), min.w + Math.random() * (max.w - min.w));
123
123
  };
124
124
  break;
@@ -132,13 +132,13 @@ export class RandomBlock extends NodeGeometryBlock {
132
132
  let lockId = 0;
133
133
  switch (this.lockMode) {
134
134
  case RandomBlockLocks.InstanceID:
135
- lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) || 0;
135
+ lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) ?? 0;
136
136
  break;
137
137
  case RandomBlockLocks.LoopID:
138
- lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) || 0;
138
+ lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) ?? 0;
139
139
  break;
140
140
  case RandomBlockLocks.Once:
141
- lockId = state.buildId || 0;
141
+ lockId = state.buildId ?? 0;
142
142
  break;
143
143
  }
144
144
  if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {
@@ -1 +1 @@
1
- {"version":3,"file":"randomBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/randomBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAA0B,sBAAsB,EAAE,6CAAsC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IACxB,WAAW;IACX,uDAAI,CAAA;IACJ,aAAa;IACb,gEAAgE;IAChE,2DAAM,CAAA;IACN,iBAAiB;IACjB,gEAAgE;IAChE,mEAAU,CAAA;IACV,WAAW;IACX,uDAAI,CAAA;AACR,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B;AAED;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAiB9C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QArBR,mBAAc,GAAG,CAAC,CAAC,CAAC;QAC5B;;WAEG;QAWI,aAAQ,GAAG,gBAA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AAC,QAAQ,CAAC;QAE7C,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;IACjD,CAAC;CACJ;AAlKU;IAVN,sBAAsB,CAAC,UAAU,uCAA+B,UAAU,EAAE;QACzE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;YAC/C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE;YACnD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,CAAC,UAAU,EAAE;YAC3D,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;SAClD;KACJ,CAAC;6CACsC;AAoK5C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { GeometryInputBlock } from \"./geometryInputBlock\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Locks supported by the random block\r\n */\r\nexport enum RandomBlockLocks {\r\n /** None */\r\n None,\r\n /** LoopID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n LoopID,\r\n /** InstanceID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n InstanceID,\r\n /** Once */\r\n Once,\r\n}\r\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\r\n private _currentLockId = -1;\r\n /**\r\n * Gets or sets a value indicating if that block will lock its value for a specific duration\r\n */\r\n @editableInPropertyPage(\"LockMode\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"None\", value: RandomBlockLocks.None },\r\n { label: \"LoopID\", value: RandomBlockLocks.LoopID },\r\n { label: \"InstanceID\", value: RandomBlockLocks.InstanceID },\r\n { label: \"Once\", value: RandomBlockLocks.Once },\r\n ],\r\n })\r\n public lockMode = RandomBlockLocks.None;\r\n\r\n /**\r\n * Create a new RandomBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"min\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"max\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RandomBlock\";\r\n }\r\n\r\n /**\r\n * Gets the min input component\r\n */\r\n public get min(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the max input component\r\n */\r\n public get max(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.min.isConnected) {\r\n const minInput = new GeometryInputBlock(\"Min\");\r\n minInput.value = 0;\r\n minInput.output.connectTo(this.min);\r\n }\r\n\r\n if (!this.max.isConnected) {\r\n const maxInput = new GeometryInputBlock(\"Max\");\r\n maxInput.value = 1;\r\n maxInput.output.connectTo(this.max);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n this._currentLockId = -1;\r\n\r\n switch (this.min.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || 0;\r\n const max = this.max.getConnectedValue(state) || 0;\r\n return min + Math.random() * (max - min);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector2.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector2.Zero();\r\n return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector3.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector3.Zero();\r\n return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) || Vector4.Zero();\r\n const max = this.max.getConnectedValue(state) || Vector4.Zero();\r\n return new Vector4(\r\n min.x + Math.random() * (max.x - min.x),\r\n min.y + Math.random() * (max.y - min.y),\r\n min.z + Math.random() * (max.z - min.z),\r\n min.w + Math.random() * (max.w - min.w)\r\n );\r\n };\r\n break;\r\n }\r\n }\r\n\r\n if (this.lockMode === RandomBlockLocks.None || !func) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = (state) => {\r\n let lockId = 0;\r\n\r\n switch (this.lockMode) {\r\n case RandomBlockLocks.InstanceID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) || 0;\r\n break;\r\n case RandomBlockLocks.LoopID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) || 0;\r\n break;\r\n case RandomBlockLocks.Once:\r\n lockId = state.buildId || 0;\r\n break;\r\n }\r\n\r\n if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {\r\n this._currentLockId = lockId;\r\n this.output._storedValue = func(state);\r\n }\r\n return this.output._storedValue;\r\n };\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockMode = BABYLON.RandomBlockLocks.${RandomBlockLocks[this.lockMode]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.lockMode = this.lockMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.lockMode = serializationObject.lockMode;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
1
+ {"version":3,"file":"randomBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/randomBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAA0B,sBAAsB,EAAE,6CAAsC;AAC/F,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AAEvF;;GAEG;AACH,MAAM,CAAN,IAAY,gBAWX;AAXD,WAAY,gBAAgB;IACxB,WAAW;IACX,uDAAI,CAAA;IACJ,aAAa;IACb,gEAAgE;IAChE,2DAAM,CAAA;IACN,iBAAiB;IACjB,gEAAgE;IAChE,mEAAU,CAAA;IACV,WAAW;IACX,uDAAI,CAAA;AACR,CAAC,EAXW,gBAAgB,KAAhB,gBAAgB,QAW3B;AAED;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,iBAAiB;IAiB9C;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QArBR,mBAAc,GAAG,CAAC,CAAC,CAAC;QAC5B;;WAEG;QAWI,aAAQ,GAAG,gBAAgB,CAAC,IAAI,CAAC;QASpC,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC5E,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE5E,IAAI,CAAC,cAAc,CAAC,QAAQ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ACJ;AAlKU;IAVN,sBAAsB,CAAC,UAAU,uCAA+B,UAAU,EAAE;QACzE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE;QAC5B,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE;YACL,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;YAC/C,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,CAAC,MAAM,EAAE;YACnD,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,CAAC,UAAU,EAAE;YAC3D,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE;SAClD;KACJ,CAAC;6CACsC;AAoK5C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport { GeometryInputBlock } from \"./geometryInputBlock\";\r\nimport { Vector2, Vector3, Vector4 } from \"../../../Maths/math.vector\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeGeometryContextualSources } from \"../Enums/nodeGeometryContextualSources\";\r\n\r\n/**\r\n * Locks supported by the random block\r\n */\r\nexport enum RandomBlockLocks {\r\n /** None */\r\n None,\r\n /** LoopID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n LoopID,\r\n /** InstanceID */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n InstanceID,\r\n /** Once */\r\n Once,\r\n}\r\n\r\n/**\r\n * Block used to get a random number\r\n */\r\nexport class RandomBlock extends NodeGeometryBlock {\r\n private _currentLockId = -1;\r\n /**\r\n * Gets or sets a value indicating if that block will lock its value for a specific duration\r\n */\r\n @editableInPropertyPage(\"LockMode\", PropertyTypeForEdition.List, \"ADVANCED\", {\r\n notifiers: { rebuild: true },\r\n embedded: true,\r\n options: [\r\n { label: \"None\", value: RandomBlockLocks.None },\r\n { label: \"LoopID\", value: RandomBlockLocks.LoopID },\r\n { label: \"InstanceID\", value: RandomBlockLocks.InstanceID },\r\n { label: \"Once\", value: RandomBlockLocks.Once },\r\n ],\r\n })\r\n public lockMode = RandomBlockLocks.None;\r\n\r\n /**\r\n * Create a new RandomBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"min\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"max\", NodeGeometryBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[0].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Matrix);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this._inputs[1].excludedConnectionPointTypes.push(NodeGeometryBlockConnectionPointTypes.Texture);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n this._linkConnectionTypes(0, 1);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"RandomBlock\";\r\n }\r\n\r\n /**\r\n * Gets the min input component\r\n */\r\n public get min(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the max input component\r\n */\r\n public get max(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override autoConfigure() {\r\n if (!this.min.isConnected) {\r\n const minInput = new GeometryInputBlock(\"Min\");\r\n minInput.value = 0;\r\n minInput.output.connectTo(this.min);\r\n }\r\n\r\n if (!this.max.isConnected) {\r\n const maxInput = new GeometryInputBlock(\"Max\");\r\n maxInput.value = 1;\r\n maxInput.output.connectTo(this.max);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n let func: Nullable<(state: NodeGeometryBuildState) => any> = null;\r\n this._currentLockId = -1;\r\n\r\n switch (this.min.type) {\r\n case NodeGeometryBlockConnectionPointTypes.Int:\r\n case NodeGeometryBlockConnectionPointTypes.Float: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? 0;\r\n const max = this.max.getConnectedValue(state) ?? 0;\r\n return min + Math.random() * (max - min);\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector2: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector2.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector2.Zero();\r\n return new Vector2(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector3: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector3.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector3.Zero();\r\n return new Vector3(min.x + Math.random() * (max.x - min.x), min.y + Math.random() * (max.y - min.y), min.z + Math.random() * (max.z - min.z));\r\n };\r\n break;\r\n }\r\n case NodeGeometryBlockConnectionPointTypes.Vector4: {\r\n func = (state) => {\r\n const min = this.min.getConnectedValue(state) ?? Vector4.Zero();\r\n const max = this.max.getConnectedValue(state) ?? Vector4.Zero();\r\n return new Vector4(\r\n min.x + Math.random() * (max.x - min.x),\r\n min.y + Math.random() * (max.y - min.y),\r\n min.z + Math.random() * (max.z - min.z),\r\n min.w + Math.random() * (max.w - min.w)\r\n );\r\n };\r\n break;\r\n }\r\n }\r\n\r\n if (this.lockMode === RandomBlockLocks.None || !func) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = (state) => {\r\n let lockId = 0;\r\n\r\n switch (this.lockMode) {\r\n case RandomBlockLocks.InstanceID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.InstanceID, true) ?? 0;\r\n break;\r\n case RandomBlockLocks.LoopID:\r\n lockId = state.getContextualValue(NodeGeometryContextualSources.LoopID, true) ?? 0;\r\n break;\r\n case RandomBlockLocks.Once:\r\n lockId = state.buildId ?? 0;\r\n break;\r\n }\r\n\r\n if (this._currentLockId !== lockId || this.lockMode === RandomBlockLocks.None) {\r\n this._currentLockId = lockId;\r\n this.output._storedValue = func(state);\r\n }\r\n return this.output._storedValue;\r\n };\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.lockMode = BABYLON.RandomBlockLocks.${RandomBlockLocks[this.lockMode]};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.lockMode = this.lockMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.lockMode = serializationObject.lockMode;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.RandomBlock\", RandomBlock);\r\n"]}
@@ -23,6 +23,7 @@ export declare class CopyTextureToTexture {
23
23
  private _effectWrapper;
24
24
  private _source;
25
25
  private _conversion;
26
+ private _lodLevel;
26
27
  /** Shader language used */
27
28
  protected _shaderLanguage: ShaderLanguage;
28
29
  /**
@@ -38,6 +39,11 @@ export declare class CopyTextureToTexture {
38
39
  */
39
40
  get source(): InternalTexture | ThinTexture;
40
41
  set source(texture: InternalTexture | ThinTexture);
42
+ /**
43
+ * Gets or sets the LOD level to copy from the source texture
44
+ */
45
+ get lodLevel(): number;
46
+ set lodLevel(level: number);
41
47
  private _textureIsInternal;
42
48
  /**
43
49
  * Constructs a new instance of the class
@@ -58,9 +64,10 @@ export declare class CopyTextureToTexture {
58
64
  * @param source The source texture
59
65
  * @param destination The destination texture. If null, copy the source to the currently bound framebuffer
60
66
  * @param conversion The conversion mode that should be applied when copying
67
+ * @param lod The LOD level to copy from the source texture
61
68
  * @returns
62
69
  */
63
- copy(source: InternalTexture | ThinTexture, destination?: Nullable<RenderTargetWrapper | IRenderTargetTexture>, conversion?: ConversionMode): boolean;
70
+ copy(source: InternalTexture | ThinTexture, destination?: Nullable<RenderTargetWrapper | IRenderTargetTexture>, conversion?: ConversionMode, lod?: number): boolean;
64
71
  /**
65
72
  * Releases all the resources used by the class
66
73
  */
@@ -34,6 +34,15 @@ export class CopyTextureToTexture {
34
34
  set source(texture) {
35
35
  this._source = texture;
36
36
  }
37
+ /**
38
+ * Gets or sets the LOD level to copy from the source texture
39
+ */
40
+ get lodLevel() {
41
+ return this._lodLevel;
42
+ }
43
+ set lodLevel(level) {
44
+ this._lodLevel = level;
45
+ }
37
46
  _textureIsInternal(texture) {
38
47
  return texture.getInternalTexture === undefined;
39
48
  }
@@ -49,6 +58,8 @@ export class CopyTextureToTexture {
49
58
  this._shadersLoaded = false;
50
59
  this._engine = engine;
51
60
  this._isDepthTexture = isDepthTexture;
61
+ this._lodLevel = 0;
62
+ this._conversion = 0 /* ConversionMode.None */;
52
63
  this._renderer = new EffectRenderer(engine);
53
64
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
54
65
  this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);
@@ -75,7 +86,7 @@ export class CopyTextureToTexture {
75
86
  name: "CopyTextureToTexture",
76
87
  fragmentShader: "copyTextureToTexture",
77
88
  useShaderStore: true,
78
- uniformNames: ["conversion"],
89
+ uniformNames: ["conversion", "lodLevel"],
79
90
  samplerNames: ["textureSampler"],
80
91
  defines,
81
92
  shaderLanguage: this._shaderLanguage,
@@ -98,6 +109,7 @@ export class CopyTextureToTexture {
98
109
  this._effectWrapper.effect.setTexture("textureSampler", this._source);
99
110
  }
100
111
  this._effectWrapper.effect.setFloat("conversion", this._conversion);
112
+ this._effectWrapper.effect.setFloat("lodLevel", this._lodLevel);
101
113
  });
102
114
  }
103
115
  /**
@@ -112,14 +124,16 @@ export class CopyTextureToTexture {
112
124
  * @param source The source texture
113
125
  * @param destination The destination texture. If null, copy the source to the currently bound framebuffer
114
126
  * @param conversion The conversion mode that should be applied when copying
127
+ * @param lod The LOD level to copy from the source texture
115
128
  * @returns
116
129
  */
117
- copy(source, destination = null, conversion = 0 /* ConversionMode.None */) {
130
+ copy(source, destination = null, conversion = 0 /* ConversionMode.None */, lod = 0) {
118
131
  if (!this.isReady()) {
119
132
  return false;
120
133
  }
121
134
  this._source = source;
122
135
  this._conversion = conversion;
136
+ this._lodLevel = lod;
123
137
  const engineDepthFunc = this._engine.getDepthFunction();
124
138
  const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates
125
139
  this._renderer.render(this._effectWrapper, destination);
@@ -1 +1 @@
1
- {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAA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exture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAY7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe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gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n private _lodLevel: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n /**\r\n * Gets or sets the LOD level to copy from the source texture\r\n */\r\n public get lodLevel(): number {\r\n return this._lodLevel;\r\n }\r\n\r\n public set lodLevel(level: number) {\r\n this._lodLevel = level;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n this._lodLevel = 0;\r\n this._conversion = ConversionMode.None;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\", \"lodLevel\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n this._effectWrapper.effect.setFloat(\"lodLevel\", this._lodLevel);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @param lod The LOD level to copy from the source texture\r\n * @returns\r\n */\r\n public copy(\r\n source: InternalTexture | ThinTexture,\r\n destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null,\r\n conversion = ConversionMode.None,\r\n lod = 0\r\n ): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n this._lodLevel = lod;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
@@ -124,8 +124,10 @@ export declare class SphereDirectedParticleEmitter extends SphereParticleEmitter
124
124
  * Called by the particle System when the direction is computed for the created particle.
125
125
  * @param worldMatrix is the world matrix of the particle system
126
126
  * @param directionToUpdate is the direction vector to update with the result
127
+ * @param particle is the particle we are computed the position for
128
+ * @param isLocal defines if the direction should be set in local space
127
129
  */
128
- startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void;
130
+ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
129
131
  /**
130
132
  * Clones the current emitter and returns a copy of it
131
133
  * @returns the new emitter
@@ -163,11 +163,17 @@ export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
163
163
  * Called by the particle System when the direction is computed for the created particle.
164
164
  * @param worldMatrix is the world matrix of the particle system
165
165
  * @param directionToUpdate is the direction vector to update with the result
166
+ * @param particle is the particle we are computed the position for
167
+ * @param isLocal defines if the direction should be set in local space
166
168
  */
167
- startDirectionFunction(worldMatrix, directionToUpdate) {
169
+ startDirectionFunction(worldMatrix, directionToUpdate, particle, isLocal) {
168
170
  const randX = RandomRange(this.direction1.x, this.direction2.x);
169
171
  const randY = RandomRange(this.direction1.y, this.direction2.y);
170
172
  const randZ = RandomRange(this.direction1.z, this.direction2.z);
173
+ if (isLocal) {
174
+ directionToUpdate.copyFromFloats(randX, randY, randZ);
175
+ return;
176
+ }
171
177
  Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
172
178
  }
173
179
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAA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\"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"sphereParticleEmitter.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/EmitterTypes/sphereParticleEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAGhE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAC9B;;;;;OAKG;IACH;IACI;;OAEG;IACI,SAAS,CAAC;IACjB;;OAEG;IACI,cAAc,CAAC;IACtB;;OAEG;IACI,sBAAsB,CAAC;QARvB,WAAM,GAAN,MAAM,CAAI;QAIV,gBAAW,GAAX,WAAW,CAAI;QAIf,wBAAmB,GAAnB,mBAAmB,CAAI;IAC/B,CAAC;IAEJ;;;;;;OAMG;IACI,sBAAsB,CAAC,WAAmB,EAAE,iBAA0B,EAAE,QAAkB,EAAE,OAAgB;QAC/G,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC;QACvF,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB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AAsD,CAAC;IAClE,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,+BAA+B,CAAC;IAC3C,CAAC;IAED;;;OAGG;IACa,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3D,mBAAmB,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACa,KAAK,CAAC,mBAAwB;QAC1C,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC7D,CAAC;CACJ","sourcesContent":["import type { Matrix } from \"../../Maths/math.vector\";\r\nimport { Vector3 } from \"../../Maths/math.vector\";\r\nimport { RandomRange } from \"../../Maths/math.scalar.functions\";\r\nimport type { Particle } from \"../../Particles/particle\";\r\nimport type { IParticleEmitterType } from \"./IParticleEmitterType\";\r\nimport { DeepCopier } from \"../../Misc/deepCopier\";\r\nimport type { UniformBufferEffectCommonAccessor } from \"../../Materials/uniformBufferEffectCommonAccessor\";\r\nimport type { UniformBuffer } from \"../../Materials/uniformBuffer\";\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles alongside the sphere radius. The emission direction might be randomized.\r\n */\r\nexport class SphereParticleEmitter implements IParticleEmitterType {\r\n /**\r\n * Creates a new instance SphereParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param directionRandomizer defines how much to randomize the particle direction [0-1]\r\n */\r\n constructor(\r\n /**\r\n * [1] The radius of the emission sphere.\r\n */\r\n public radius = 1,\r\n /**\r\n * [1] The range of emission [0-1] 0 Surface only, 1 Entire Radius.\r\n */\r\n public radiusRange = 1,\r\n /**\r\n * [0] How much to randomize the particle direction [0-1].\r\n */\r\n public directionRandomizer = 0\r\n ) {}\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the direction for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();\r\n const randX = RandomRange(0, this.directionRandomizer);\r\n const randY = RandomRange(0, this.directionRandomizer);\r\n const randZ = RandomRange(0, this.directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFrom(direction);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the position is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param positionToUpdate is the position vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the position should be set in local space\r\n */\r\n public startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randRadius = this.radius - RandomRange(0, this.radius * this.radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (isLocal) {\r\n positionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public clone(): SphereParticleEmitter {\r\n const newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setFloat(\"directionRandomizer\", this.directionRandomizer);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"directionRandomizer\", 1);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public getClassName(): string {\r\n return \"SphereParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public serialize(): any {\r\n const serializationObject: any = {};\r\n serializationObject.type = this.getClassName();\r\n serializationObject.radius = this.radius;\r\n serializationObject.radiusRange = this.radiusRange;\r\n serializationObject.directionRandomizer = this.directionRandomizer;\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public parse(serializationObject: any): void {\r\n this.radius = serializationObject.radius;\r\n this.radiusRange = serializationObject.radiusRange;\r\n this.directionRandomizer = serializationObject.directionRandomizer;\r\n }\r\n}\r\n\r\n/**\r\n * Particle emitter emitting particles from the inside of a sphere.\r\n * It emits the particles randomly between two vectors.\r\n */\r\nexport class SphereDirectedParticleEmitter extends SphereParticleEmitter {\r\n /**\r\n * Creates a new instance SphereDirectedParticleEmitter\r\n * @param radius the radius of the emission sphere (1 by default)\r\n * @param direction1 the min limit of the emission direction (up vector by default)\r\n * @param direction2 the max limit of the emission direction (up vector by default)\r\n */\r\n constructor(\r\n radius = 1,\r\n /**\r\n * [Up vector] The min limit of the emission direction.\r\n */\r\n public direction1 = new Vector3(0, 1, 0),\r\n /**\r\n * [Up vector] The max limit of the emission direction.\r\n */\r\n public direction2 = new Vector3(0, 1, 0)\r\n ) {\r\n super(radius);\r\n }\r\n\r\n /**\r\n * Called by the particle System when the direction is computed for the created particle.\r\n * @param worldMatrix is the world matrix of the particle system\r\n * @param directionToUpdate is the direction vector to update with the result\r\n * @param particle is the particle we are computed the position for\r\n * @param isLocal defines if the direction should be set in local space\r\n */\r\n public override startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void {\r\n const randX = RandomRange(this.direction1.x, this.direction2.x);\r\n const randY = RandomRange(this.direction1.y, this.direction2.y);\r\n const randZ = RandomRange(this.direction1.z, this.direction2.z);\r\n\r\n if (isLocal) {\r\n directionToUpdate.copyFromFloats(randX, randY, randZ);\r\n return;\r\n }\r\n\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);\r\n }\r\n\r\n /**\r\n * Clones the current emitter and returns a copy of it\r\n * @returns the new emitter\r\n */\r\n public override clone(): SphereDirectedParticleEmitter {\r\n const newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);\r\n\r\n DeepCopier.DeepCopy(this, newOne);\r\n\r\n return newOne;\r\n }\r\n\r\n /**\r\n * Called by the GPUParticleSystem to setup the update shader\r\n * @param uboOrEffect defines the update shader\r\n */\r\n public override applyToShader(uboOrEffect: UniformBufferEffectCommonAccessor): void {\r\n uboOrEffect.setFloat(\"radius\", this.radius);\r\n uboOrEffect.setFloat(\"radiusRange\", this.radiusRange);\r\n uboOrEffect.setVector3(\"direction1\", this.direction1);\r\n uboOrEffect.setVector3(\"direction2\", this.direction2);\r\n }\r\n\r\n /**\r\n * Creates the structure of the ubo for this particle emitter\r\n * @param ubo ubo to create the structure for\r\n */\r\n public override buildUniformLayout(ubo: UniformBuffer): void {\r\n ubo.addUniform(\"radius\", 1);\r\n ubo.addUniform(\"radiusRange\", 1);\r\n ubo.addUniform(\"direction1\", 3);\r\n ubo.addUniform(\"direction2\", 3);\r\n }\r\n\r\n /**\r\n * Returns a string to use to update the GPU particles update shader\r\n * @returns a string containing the defines string\r\n */\r\n public override getEffectDefines(): string {\r\n return \"#define SPHEREEMITTER\\n#define DIRECTEDSPHEREEMITTER\";\r\n }\r\n\r\n /**\r\n * Returns the string \"SphereDirectedParticleEmitter\"\r\n * @returns a string containing the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SphereDirectedParticleEmitter\";\r\n }\r\n\r\n /**\r\n * Serializes the particle system to a JSON object.\r\n * @returns the JSON object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.direction1 = this.direction1.asArray();\r\n serializationObject.direction2 = this.direction2.asArray();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Parse properties from a JSON object\r\n * @param serializationObject defines the JSON object\r\n */\r\n public override parse(serializationObject: any): void {\r\n super.parse(serializationObject);\r\n this.direction1.copyFrom(serializationObject.direction1);\r\n this.direction2.copyFrom(serializationObject.direction2);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
2
2
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
3
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
4
3
  import type { IShapeBlock } from "./IShapeBlock.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  /**
6
6
  * Block used to provide a flow of particles emitted from a box shape.
7
7
  */
@@ -3,6 +3,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
3
3
  import { Vector3 } from "../../../../Maths/math.vector.js";
4
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
6
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
6
7
  /**
7
8
  * Block used to provide a flow of particles emitted from a box shape.
8
9
  */
@@ -95,11 +96,11 @@ export class BoxShapeBlock extends NodeParticleBlock {
95
96
  const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);
96
97
  if (system.isLocal) {
97
98
  particle.position.copyFromFloats(randX, randY, randZ);
98
- particle.position.addInPlace(state.emitterPosition);
99
99
  }
100
100
  else {
101
101
  Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
102
102
  }
103
+ _CreateLocalPositionData(particle);
103
104
  };
104
105
  this.output._storedValue = system;
105
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH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../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
1
+ {"version":3,"file":"boxShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/boxShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,iBAAiB;IAChD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC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,CAAC,CAAC,CAAC;YACtD,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,uBAAuB,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a box shape.\r\n */\r\nexport class BoxShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new BoxShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"minEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(-0.5, -0.5, -0.5));\r\n this.registerInput(\"maxEmitBox\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0.5, 0.5, 0.5));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"BoxShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle input component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the minEmitBox input component\r\n */\r\n public get minEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the maxEmitBox input component\r\n */\r\n public get maxEmitBox(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const minEmitBox = this.minEmitBox.getConnectedValue(state) as Vector3;\r\n const maxEmitBox = this.maxEmitBox.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(minEmitBox.x, maxEmitBox.x);\r\n const randY = RandomRange(minEmitBox.y, maxEmitBox.y);\r\n const randZ = RandomRange(minEmitBox.z, maxEmitBox.z);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.BoxShapeBlock\", BoxShapeBlock);\r\n"]}
@@ -1,9 +1,10 @@
1
- import { NodeParticleBlock } from "../../nodeParticleBlock.js";
2
1
  import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
3
2
  import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
4
3
  import type { IShapeBlock } from "./IShapeBlock.js";
4
+ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  /**
6
6
  * Block used to provide a flow of particles emitted from a cylinder shape.
7
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
7
8
  */
8
9
  export declare class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {
9
10
  private _tempVector;
@@ -37,6 +38,14 @@ export declare class CylinderShapeBlock extends NodeParticleBlock implements ISh
37
38
  * Gets the directionRandomizer input component
38
39
  */
39
40
  get directionRandomizer(): NodeParticleConnectionPoint;
41
+ /**
42
+ * Gets the direction1 input component
43
+ */
44
+ get direction1(): NodeParticleConnectionPoint;
45
+ /**
46
+ * Gets the direction2 input component
47
+ */
48
+ get direction2(): NodeParticleConnectionPoint;
40
49
  /**
41
50
  * Gets the output component
42
51
  */
@@ -3,8 +3,10 @@ import { RegisterClass } from "../../../../Misc/typeStore.js";
3
3
  import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
4
4
  import { NodeParticleBlock } from "../../nodeParticleBlock.js";
5
5
  import { Vector3 } from "../../../../Maths/math.vector.js";
6
+ import { _CreateLocalPositionData } from "./emitters.functions.js";
6
7
  /**
7
8
  * Block used to provide a flow of particles emitted from a cylinder shape.
9
+ * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
8
10
  */
9
11
  export class CylinderShapeBlock extends NodeParticleBlock {
10
12
  /**
@@ -19,6 +21,8 @@ export class CylinderShapeBlock extends NodeParticleBlock {
19
21
  this.registerInput("height", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);
20
22
  this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);
21
23
  this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);
24
+ this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
25
+ this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
22
26
  this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
23
27
  }
24
28
  /**
@@ -58,6 +62,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
58
62
  get directionRandomizer() {
59
63
  return this._inputs[4];
60
64
  }
65
+ /**
66
+ * Gets the direction1 input component
67
+ */
68
+ get direction1() {
69
+ return this._inputs[5];
70
+ }
71
+ /**
72
+ * Gets the direction2 input component
73
+ */
74
+ get direction2() {
75
+ return this._inputs[6];
76
+ }
61
77
  /**
62
78
  * Gets the output component
63
79
  */
@@ -73,24 +89,40 @@ export class CylinderShapeBlock extends NodeParticleBlock {
73
89
  system._directionCreation.process = (particle) => {
74
90
  state.particleContext = particle;
75
91
  state.systemContext = system;
76
- const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
77
- particle.position.subtractToRef(state.emitterPosition, this._tempVector);
78
- this._tempVector.normalize();
79
- if (state.emitterInverseWorldMatrix) {
80
- Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);
81
- }
82
- const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);
83
- let angle = Math.atan2(this._tempVector.x, this._tempVector.z);
84
- angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;
85
- this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface
86
- this._tempVector.x = Math.sin(angle);
87
- this._tempVector.z = Math.cos(angle);
88
- this._tempVector.normalize();
89
- if (system.isLocal) {
90
- particle.direction.copyFrom(this._tempVector);
92
+ // We always use directionRandomizer unless both directions are connected
93
+ if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
94
+ const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
95
+ particle.position.subtractToRef(state.emitterPosition, this._tempVector);
96
+ this._tempVector.normalize();
97
+ if (state.emitterInverseWorldMatrix) {
98
+ Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);
99
+ }
100
+ const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);
101
+ let angle = Math.atan2(this._tempVector.x, this._tempVector.z);
102
+ angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;
103
+ this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface
104
+ this._tempVector.x = Math.sin(angle);
105
+ this._tempVector.z = Math.cos(angle);
106
+ this._tempVector.normalize();
107
+ if (system.isLocal) {
108
+ particle.direction.copyFrom(this._tempVector);
109
+ }
110
+ else {
111
+ Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix, particle.direction);
112
+ }
91
113
  }
92
114
  else {
93
- Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix, particle.direction);
115
+ const direction1 = this.direction1.getConnectedValue(state);
116
+ const direction2 = this.direction2.getConnectedValue(state);
117
+ const randX = RandomRange(direction1.x, direction2.x);
118
+ const randY = RandomRange(direction1.y, direction2.y);
119
+ const randZ = RandomRange(direction1.z, direction2.z);
120
+ if (system.isLocal) {
121
+ particle.direction.copyFromFloats(randX, randY, randZ);
122
+ }
123
+ else {
124
+ Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
125
+ }
94
126
  }
95
127
  particle._initialDirection = particle.direction.clone();
96
128
  };
@@ -102,17 +134,18 @@ export class CylinderShapeBlock extends NodeParticleBlock {
102
134
  const radius = this.radius.getConnectedValue(state);
103
135
  const yPos = RandomRange(-height / 2, height / 2);
104
136
  const angle = RandomRange(0, 2 * Math.PI);
137
+ // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
105
138
  const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);
106
139
  const positionRadius = Math.sqrt(radiusDistribution) * radius;
107
140
  const xPos = positionRadius * Math.cos(angle);
108
141
  const zPos = positionRadius * Math.sin(angle);
109
142
  if (system.isLocal) {
110
143
  particle.position.copyFromFloats(xPos, yPos, zPos);
111
- particle.position.addInPlace(state.emitterPosition);
112
144
  }
113
145
  else {
114
146
  Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix, particle.position);
115
147
  }
148
+ _CreateLocalPositionData(particle);
116
149
  };
117
150
  this.output._storedValue = system;
118
151
  }