@onerjs/core 8.30.8 → 8.31.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 (137) hide show
  1. package/Behaviors/Cameras/interpolatingBehavior.d.ts +52 -0
  2. package/Behaviors/Cameras/interpolatingBehavior.js +105 -0
  3. package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
  4. package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
  5. package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
  6. package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
  7. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +10 -2
  8. package/Cameras/Inputs/geospatialCameraPointersInput.js +20 -2
  9. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  10. package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
  11. package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
  12. package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
  13. package/Cameras/camera.js +1 -0
  14. package/Cameras/camera.js.map +1 -1
  15. package/Cameras/cameraMovement.d.ts +150 -0
  16. package/Cameras/cameraMovement.js +190 -0
  17. package/Cameras/cameraMovement.js.map +1 -0
  18. package/Cameras/targetCamera.js +0 -4
  19. package/Cameras/targetCamera.js.map +1 -1
  20. package/Culling/ray.core.js +1 -1
  21. package/Culling/ray.core.js.map +1 -1
  22. package/Decorators/nodeDecorator.d.ts +9 -7
  23. package/Decorators/nodeDecorator.js +9 -7
  24. package/Decorators/nodeDecorator.js.map +1 -1
  25. package/Engines/WebGPU/webgpuTextureManager.js +2 -2
  26. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  27. package/Engines/abstractEngine.js +2 -2
  28. package/Engines/abstractEngine.js.map +1 -1
  29. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
  30. package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
  31. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
  32. package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
  33. package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
  34. package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
  35. package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
  36. package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
  37. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
  38. package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
  39. package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
  40. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
  41. package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
  42. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
  43. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
  44. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
  45. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
  46. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  47. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  48. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
  49. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  50. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
  51. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  52. package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
  53. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
  54. package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
  55. package/FrameGraph/Node/nodeRenderGraph.js +2 -1
  56. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  57. package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
  58. package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
  59. package/FrameGraph/Passes/objectListPass.js.map +1 -0
  60. package/FrameGraph/Passes/renderPass.d.ts +6 -2
  61. package/FrameGraph/Passes/renderPass.js +14 -2
  62. package/FrameGraph/Passes/renderPass.js.map +1 -1
  63. package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
  64. package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
  65. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
  66. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
  67. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  68. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
  69. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
  70. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  71. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
  72. package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
  73. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  74. package/FrameGraph/frameGraph.d.ts +10 -4
  75. package/FrameGraph/frameGraph.js +22 -9
  76. package/FrameGraph/frameGraph.js.map +1 -1
  77. package/FrameGraph/frameGraphTask.js +3 -3
  78. package/FrameGraph/frameGraphTask.js.map +1 -1
  79. package/FrameGraph/index.d.ts +1 -1
  80. package/FrameGraph/index.js +1 -1
  81. package/FrameGraph/index.js.map +1 -1
  82. package/Materials/floatingOriginMatrixOverrides.js +19 -0
  83. package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
  84. package/Materials/shaderMaterial.d.ts +9 -0
  85. package/Materials/shaderMaterial.js +35 -0
  86. package/Materials/shaderMaterial.js.map +1 -1
  87. package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
  88. package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
  89. package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
  90. package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
  91. package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
  92. package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
  93. package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
  94. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
  95. package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
  96. package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
  97. package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
  98. package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
  99. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +6 -0
  100. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +22 -1
  101. package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
  102. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
  103. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
  104. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
  105. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
  106. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +1 -1
  107. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  108. package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
  109. package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
  110. package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
  111. package/Particles/Node/Blocks/index.d.ts +1 -0
  112. package/Particles/Node/Blocks/index.js +1 -0
  113. package/Particles/Node/Blocks/index.js.map +1 -1
  114. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  115. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  116. package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
  117. package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
  118. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  119. package/Particles/Node/Blocks/systemBlock.d.ts +12 -4
  120. package/Particles/Node/Blocks/systemBlock.js +16 -12
  121. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  122. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  123. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  124. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  125. package/Particles/Node/nodeParticleBuildState.js +2 -0
  126. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  127. package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
  128. package/Particles/Node/nodeParticleSystemSet.helper.js +293 -44
  129. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  130. package/Particles/thinParticleSystem.d.ts +3 -3
  131. package/Particles/thinParticleSystem.js +4 -4
  132. package/Particles/thinParticleSystem.js.map +1 -1
  133. package/package.json +1 -1
  134. package/scene.d.ts +1 -3
  135. package/scene.js +8 -7
  136. package/scene.js.map +1 -1
  137. package/FrameGraph/Passes/cullPass.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"nodeParticleBuildState.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleBuildState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAGtF,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mCAA+B;AAE1D,OAAO,EAAE,MAA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CAAC;YACjD,KAAK,yBAAyB,CAAC,OAAO;gBAClC,OAAO,IAAI,CAAC,eAAe,CAAC;YAChC,KAAK,yBAAyB,CAAC,cAAc;gBACzC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,cAAc,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { NodeParticleConnectionPoint } from \"./nodeParticleBlockConnectionPoint\";\r\nimport { NodeParticleContextualSources } from \"./Enums/nodeParticleContextualSources\";\r\nimport type { Particle } from \"../particle\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"./Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { ThinParticleSystem } from \"../thinParticleSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { NodeParticleSystemSources } from \"./Enums/nodeParticleSystemSources\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\n/**\r\n * Class used to store node based geometry build state\r\n */\r\nexport class NodeParticleBuildState {\r\n /**\r\n * Gets the capactity of the particle system to build\r\n */\r\n public capacity: number;\r\n\r\n /**\r\n * Gets the scene where the particle system is built\r\n */\r\n public scene: Scene;\r\n\r\n /** Gets or sets the build identifier */\r\n public buildId: number;\r\n\r\n /** Gets or sets the list of non connected mandatory inputs */\r\n public notConnectedNonOptionalInputs: NodeParticleConnectionPoint[] = [];\r\n\r\n /** Gets or sets a boolean indicating that verbose mode is on */\r\n public verbose: boolean;\r\n\r\n /**\r\n * Gets or sets the particle context for contextual data\r\n */\r\n public particleContext: Nullable<Particle> = null;\r\n\r\n /**\r\n * Gets or sets the system context for contextual data\r\n */\r\n public systemContext: Nullable<ThinParticleSystem> = null;\r\n\r\n /**\r\n * Gets or sets the index of the gradient to use\r\n */\r\n public gradientIndex: number = 0;\r\n /**\r\n * Gets or sets next gradient in line\r\n */\r\n public nextGradientIndex: number = 0;\r\n /**\r\n * Gets or sets the next gradient value\r\n */\r\n public nextGradientValue: any;\r\n\r\n /**\r\n * Emits errors if any\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n for (const notConnectedInput of this.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Build of Node Particle System Set failed:\\n\" + errorMessage;\r\n }\r\n }\r\n\r\n /**\r\n * Adapt a value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @returns the adapted value\r\n */\r\n adapt(source: NodeParticleConnectionPoint, targetType: NodeParticleBlockConnectionPointTypes) {\r\n const value = source.getConnectedValue(this) || 0;\r\n\r\n if (source.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeParticleBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeParticleBlockConnectionPointTypes.Color4:\r\n return new Color4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual source\r\n * @param source Source of the contextual value\r\n * @returns the value associated with the source\r\n */\r\n public getContextualValue(source: NodeParticleContextualSources) {\r\n if (!this.particleContext || !this.systemContext) {\r\n return null;\r\n }\r\n\r\n switch (source) {\r\n case NodeParticleContextualSources.Position:\r\n return this.particleContext.position;\r\n case NodeParticleContextualSources.Direction:\r\n return this.particleContext.direction;\r\n case NodeParticleContextualSources.ScaledDirection:\r\n this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);\r\n return this.systemContext._scaledDirection;\r\n case NodeParticleContextualSources.Color:\r\n return this.particleContext.color;\r\n case NodeParticleContextualSources.InitialColor:\r\n return this.particleContext.initialColor;\r\n case NodeParticleContextualSources.ColorDead:\r\n return this.particleContext.colorDead;\r\n case NodeParticleContextualSources.Age:\r\n return this.particleContext.age;\r\n case NodeParticleContextualSources.Lifetime:\r\n return this.particleContext.lifeTime;\r\n case NodeParticleContextualSources.Angle:\r\n return this.particleContext.angle;\r\n case NodeParticleContextualSources.Scale:\r\n return this.particleContext.scale;\r\n case NodeParticleContextualSources.AgeGradient:\r\n return this.particleContext.age / this.particleContext.lifeTime;\r\n case NodeParticleContextualSources.SpriteCellEnd:\r\n return this.systemContext.endSpriteCellID;\r\n case NodeParticleContextualSources.SpriteCellIndex:\r\n return this.particleContext.cellIndex;\r\n case NodeParticleContextualSources.SpriteCellStart:\r\n return this.systemContext.startSpriteCellID;\r\n case NodeParticleContextualSources.InitialDirection:\r\n return this.particleContext._initialDirection;\r\n case NodeParticleContextualSources.ColorStep:\r\n return this.particleContext.colorStep;\r\n case NodeParticleContextualSources.ScaledColorStep:\r\n this.particleContext.colorStep.scaleToRef(this.systemContext._scaledUpdateSpeed, this.systemContext._scaledColorStep);\r\n return this.systemContext._scaledColorStep;\r\n case NodeParticleContextualSources.LocalPositionUpdated:\r\n this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);\r\n this.particleContext._localPosition!.addInPlace(this.systemContext._scaledDirection);\r\n Vector3.TransformCoordinatesToRef(this.particleContext._localPosition!, this.systemContext._emitterWorldMatrix, this.particleContext.position);\r\n return this.particleContext.position;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the emitter world matrix\r\n */\r\n public get emitterWorldMatrix() {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n return this.systemContext._emitterWorldMatrix;\r\n }\r\n\r\n /**\r\n * Gets the emitter inverse world matrix\r\n */\r\n public get emitterInverseWorldMatrix() {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n return this.systemContext._emitterInverseWorldMatrix;\r\n }\r\n\r\n /**\r\n * Gets the emitter position\r\n */\r\n public get emitterPosition(): Nullable<Vector3> {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n\r\n if (!this.systemContext.emitter) {\r\n return null;\r\n }\r\n\r\n if (this.systemContext.emitter instanceof Vector3) {\r\n return this.systemContext.emitter;\r\n }\r\n\r\n return (<AbstractMesh>this.systemContext.emitter).absolutePosition;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a system source\r\n * @param source Source of the system value\r\n * @returns the value associated with the source\r\n */\r\n public getSystemValue(source: NodeParticleSystemSources) {\r\n if (!this.particleContext || !this.systemContext) {\r\n return null;\r\n }\r\n\r\n switch (source) {\r\n case NodeParticleSystemSources.Time:\r\n return this.systemContext._actualFrame;\r\n case NodeParticleSystemSources.Delta:\r\n return this.systemContext._scaledUpdateSpeed;\r\n case NodeParticleSystemSources.Emitter:\r\n return this.emitterPosition;\r\n case NodeParticleSystemSources.CameraPosition:\r\n return this.scene.activeCamera?.globalPosition || Vector3.Zero();\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"nodeParticleBuildState.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleBuildState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AAGtF,OAAO,EAAE,qCAAqC,EAAE,MAAM,+CAA+C,CAAC;AACtG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,mCAA+B;AAE1D,OAAO,EAAE,MAAM,EAAE,kCAA8B;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAG9E;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QAcI,8DAA8D;QACvD,kCAA6B,GAAkC,EAAE,CAAC;QAKzE;;WAEG;QACI,oBAAe,GAAuB,IAAI,CAAC;QAElD;;WAEG;QACI,kBAAa,GAAiC,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IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACzE,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport type { NodeParticleConnectionPoint } from \"./nodeParticleBlockConnectionPoint\";\r\nimport { NodeParticleContextualSources } from \"./Enums/nodeParticleContextualSources\";\r\nimport type { Particle } from \"../particle\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"./Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { ThinParticleSystem } from \"../thinParticleSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { NodeParticleSystemSources } from \"./Enums/nodeParticleSystemSources\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\n\r\n/**\r\n * Class used to store node based geometry build state\r\n */\r\nexport class NodeParticleBuildState {\r\n /**\r\n * Gets the capactity of the particle system to build\r\n */\r\n public capacity: number;\r\n\r\n /**\r\n * Gets the scene where the particle system is built\r\n */\r\n public scene: Scene;\r\n\r\n /** Gets or sets the build identifier */\r\n public buildId: number;\r\n\r\n /** Gets or sets the list of non connected mandatory inputs */\r\n public notConnectedNonOptionalInputs: NodeParticleConnectionPoint[] = [];\r\n\r\n /** Gets or sets a boolean indicating that verbose mode is on */\r\n public verbose: boolean;\r\n\r\n /**\r\n * Gets or sets the particle context for contextual data\r\n */\r\n public particleContext: Nullable<Particle> = null;\r\n\r\n /**\r\n * Gets or sets the system context for contextual data\r\n */\r\n public systemContext: Nullable<ThinParticleSystem> = null;\r\n\r\n /**\r\n * Gets or sets the index of the gradient to use\r\n */\r\n public gradientIndex: number = 0;\r\n /**\r\n * Gets or sets next gradient in line\r\n */\r\n public nextGradientIndex: number = 0;\r\n /**\r\n * Gets or sets the next gradient value\r\n */\r\n public nextGradientValue: any;\r\n\r\n /**\r\n * Emits errors if any\r\n */\r\n public emitErrors() {\r\n let errorMessage = \"\";\r\n\r\n for (const notConnectedInput of this.notConnectedNonOptionalInputs) {\r\n errorMessage += `input ${notConnectedInput.name} from block ${\r\n notConnectedInput.ownerBlock.name\r\n }[${notConnectedInput.ownerBlock.getClassName()}] is not connected and is not optional.\\n`;\r\n }\r\n\r\n if (errorMessage) {\r\n // eslint-disable-next-line no-throw-literal\r\n throw \"Build of Node Particle System Set failed:\\n\" + errorMessage;\r\n }\r\n }\r\n\r\n /**\r\n * Adapt a value to a target type\r\n * @param source defines the value to adapt\r\n * @param targetType defines the target type\r\n * @returns the adapted value\r\n */\r\n adapt(source: NodeParticleConnectionPoint, targetType: NodeParticleBlockConnectionPointTypes) {\r\n const value = source.getConnectedValue(this) || 0;\r\n\r\n if (source.type === targetType) {\r\n return value;\r\n }\r\n\r\n switch (targetType) {\r\n case NodeParticleBlockConnectionPointTypes.Vector2:\r\n return new Vector2(value, value);\r\n case NodeParticleBlockConnectionPointTypes.Vector3:\r\n return new Vector3(value, value, value);\r\n case NodeParticleBlockConnectionPointTypes.Color4:\r\n return new Color4(value, value, value, value);\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a contextual source\r\n * @param source Source of the contextual value\r\n * @returns the value associated with the source\r\n */\r\n public getContextualValue(source: NodeParticleContextualSources) {\r\n if (!this.particleContext || !this.systemContext) {\r\n return null;\r\n }\r\n\r\n switch (source) {\r\n case NodeParticleContextualSources.Position:\r\n return this.particleContext.position;\r\n case NodeParticleContextualSources.Direction:\r\n return this.particleContext.direction;\r\n case NodeParticleContextualSources.ScaledDirection:\r\n this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);\r\n return this.systemContext._scaledDirection;\r\n case NodeParticleContextualSources.Color:\r\n return this.particleContext.color;\r\n case NodeParticleContextualSources.InitialColor:\r\n return this.particleContext.initialColor;\r\n case NodeParticleContextualSources.ColorDead:\r\n return this.particleContext.colorDead;\r\n case NodeParticleContextualSources.Age:\r\n return this.particleContext.age;\r\n case NodeParticleContextualSources.Lifetime:\r\n return this.particleContext.lifeTime;\r\n case NodeParticleContextualSources.Angle:\r\n return this.particleContext.angle;\r\n case NodeParticleContextualSources.Scale:\r\n return this.particleContext.scale;\r\n case NodeParticleContextualSources.Size:\r\n return this.particleContext.size;\r\n case NodeParticleContextualSources.AgeGradient:\r\n return this.particleContext.age / this.particleContext.lifeTime;\r\n case NodeParticleContextualSources.SpriteCellEnd:\r\n return this.systemContext.endSpriteCellID;\r\n case NodeParticleContextualSources.SpriteCellIndex:\r\n return this.particleContext.cellIndex;\r\n case NodeParticleContextualSources.SpriteCellStart:\r\n return this.systemContext.startSpriteCellID;\r\n case NodeParticleContextualSources.InitialDirection:\r\n return this.particleContext._initialDirection;\r\n case NodeParticleContextualSources.ColorStep:\r\n return this.particleContext.colorStep;\r\n case NodeParticleContextualSources.ScaledColorStep:\r\n this.particleContext.colorStep.scaleToRef(this.systemContext._scaledUpdateSpeed, this.systemContext._scaledColorStep);\r\n return this.systemContext._scaledColorStep;\r\n case NodeParticleContextualSources.LocalPositionUpdated:\r\n this.particleContext.direction.scaleToRef(this.systemContext._directionScale, this.systemContext._scaledDirection);\r\n this.particleContext._localPosition!.addInPlace(this.systemContext._scaledDirection);\r\n Vector3.TransformCoordinatesToRef(this.particleContext._localPosition!, this.systemContext._emitterWorldMatrix, this.particleContext.position);\r\n return this.particleContext.position;\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the emitter world matrix\r\n */\r\n public get emitterWorldMatrix() {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n return this.systemContext._emitterWorldMatrix;\r\n }\r\n\r\n /**\r\n * Gets the emitter inverse world matrix\r\n */\r\n public get emitterInverseWorldMatrix() {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n return this.systemContext._emitterInverseWorldMatrix;\r\n }\r\n\r\n /**\r\n * Gets the emitter position\r\n */\r\n public get emitterPosition(): Nullable<Vector3> {\r\n if (!this.systemContext) {\r\n return null;\r\n }\r\n\r\n if (!this.systemContext.emitter) {\r\n return null;\r\n }\r\n\r\n if (this.systemContext.emitter instanceof Vector3) {\r\n return this.systemContext.emitter;\r\n }\r\n\r\n return (<AbstractMesh>this.systemContext.emitter).absolutePosition;\r\n }\r\n\r\n /**\r\n * Gets the value associated with a system source\r\n * @param source Source of the system value\r\n * @returns the value associated with the source\r\n */\r\n public getSystemValue(source: NodeParticleSystemSources) {\r\n if (!this.particleContext || !this.systemContext) {\r\n return null;\r\n }\r\n\r\n switch (source) {\r\n case NodeParticleSystemSources.Time:\r\n return this.systemContext._actualFrame;\r\n case NodeParticleSystemSources.Delta:\r\n return this.systemContext._scaledUpdateSpeed;\r\n case NodeParticleSystemSources.Emitter:\r\n return this.emitterPosition;\r\n case NodeParticleSystemSources.CameraPosition:\r\n return this.scene.activeCamera?.globalPosition || Vector3.Zero();\r\n }\r\n\r\n return null;\r\n }\r\n}\r\n"]}
@@ -6,7 +6,5 @@ import { NodeParticleSystemSet } from "./nodeParticleSystemSet.js";
6
6
  * @param name The name of the node particle system set.
7
7
  * @param particleSystemsList The particle systems to convert.
8
8
  * @returns The converted node particle system set or null if conversion failed.
9
- * #0K3AQ2#3672
10
- * #7J0NXA#4
11
9
  */
12
10
  export declare function ConvertToNodeParticleSystemSetAsync(name: string, particleSystemsList: ParticleSystem[]): Promise<Nullable<NodeParticleSystemSet>>;
@@ -1,5 +1,4 @@
1
1
  import { Vector2, Vector3 } from "../../Maths/math.vector.js";
2
- import { NodeParticleBlockConnectionPointTypes } from "./Enums/nodeParticleBlockConnectionPointTypes.js";
3
2
  import { NodeParticleSystemSet } from "./nodeParticleSystemSet.js";
4
3
  import { NodeParticleContextualSources } from "./Enums/nodeParticleContextualSources.js";
5
4
  import { NodeParticleSystemSources } from "./Enums/nodeParticleSystemSources.js";
@@ -15,6 +14,7 @@ import { CreateParticleBlock } from "./Blocks/Emitters/createParticleBlock.js";
15
14
  import { BoxShapeBlock } from "./Blocks/Emitters/boxShapeBlock.js";
16
15
  import { ConeShapeBlock } from "./Blocks/Emitters/coneShapeBlock.js";
17
16
  import { CylinderShapeBlock } from "./Blocks/Emitters/cylinderShapeBlock.js";
17
+ import { CustomShapeBlock } from "./Blocks/Emitters/customShapeBlock.js";
18
18
  import { MeshShapeBlock } from "./Blocks/Emitters/meshShapeBlock.js";
19
19
  import { PointShapeBlock } from "./Blocks/Emitters/pointShapeBlock.js";
20
20
  import { SphereShapeBlock } from "./Blocks/Emitters/sphereShapeBlock.js";
@@ -22,13 +22,12 @@ import { UpdateAngleBlock } from "./Blocks/Update/updateAngleBlock.js";
22
22
  import { UpdateColorBlock } from "./Blocks/Update/updateColorBlock.js";
23
23
  import { UpdateDirectionBlock } from "./Blocks/Update/updateDirectionBlock.js";
24
24
  import { UpdatePositionBlock } from "./Blocks/Update/updatePositionBlock.js";
25
+ import { UpdateSizeBlock } from "./Blocks/Update/updateSizeBlock.js";
25
26
  /**
26
27
  * Converts a ParticleSystem to a NodeParticleSystemSet.
27
28
  * @param name The name of the node particle system set.
28
29
  * @param particleSystemsList The particle systems to convert.
29
30
  * @returns The converted node particle system set or null if conversion failed.
30
- * #0K3AQ2#3672
31
- * #7J0NXA#4
32
31
  */
33
32
  export async function ConvertToNodeParticleSystemSetAsync(name, particleSystemsList) {
34
33
  if (!particleSystemsList || !particleSystemsList.length) {
@@ -37,39 +36,39 @@ export async function ConvertToNodeParticleSystemSetAsync(name, particleSystemsL
37
36
  const nodeParticleSystemSet = new NodeParticleSystemSet(name);
38
37
  const promises = [];
39
38
  for (const particleSystem of particleSystemsList) {
40
- promises.push(_ExtractDatafromParticleSystemAsync(nodeParticleSystemSet, particleSystem));
39
+ promises.push(_ExtractDatafromParticleSystemAsync(nodeParticleSystemSet, particleSystem, {}));
41
40
  }
42
41
  await Promise.all(promises);
43
42
  return nodeParticleSystemSet;
44
43
  }
45
- async function _ExtractDatafromParticleSystemAsync(newSet, oldSystem) {
44
+ async function _ExtractDatafromParticleSystemAsync(newSet, oldSystem, context) {
46
45
  // CreateParticle block
47
- const createParticleBlock = _CreateCreateParticleBlock(oldSystem);
46
+ const createParticleBlock = _CreateParticleBlockGroup(oldSystem, context);
48
47
  // Emitter Shape block
49
- const shapeBlock = _CreateEmitterShapeBlock(oldSystem);
48
+ const shapeBlock = _EmitterShapeBlock(oldSystem);
50
49
  createParticleBlock.particle.connectTo(shapeBlock.particle);
51
50
  // Update the particle position
52
- const positionUpdatedParticle = _CreateUpdateSystem(shapeBlock.output, oldSystem);
51
+ const positionUpdatedParticle = _UpdateParticleBlockGroup(shapeBlock.output, oldSystem, context);
53
52
  // Color update
54
53
  const colorUpdateBlock = _CreateColorUpdateBlock(oldSystem, createParticleBlock);
55
54
  positionUpdatedParticle.connectTo(colorUpdateBlock.particle);
56
55
  // System block
57
- const newSystem = _CreateSystemBlock(oldSystem);
56
+ const newSystem = _SystemBlockGroup(oldSystem, context);
58
57
  colorUpdateBlock.output.connectTo(newSystem.particle);
59
58
  // Register
60
59
  newSet.systemBlocks.push(newSystem);
61
60
  }
62
- function _CreateSystemBlock(oldSystem) {
61
+ // ------------- SYSTEM FUNCTIONS -------------
62
+ function _SystemBlockGroup(oldSystem, context) {
63
63
  const newSystem = new SystemBlock(oldSystem.name);
64
64
  _CreateAndConnectInput("Translation pivot", oldSystem.translationPivot, newSystem.translationPivot);
65
65
  _CreateAndConnectInput("Texture mask", oldSystem.textureMask, newSystem.textureMask);
66
+ _CreateTargetStopDurationInputBlock(oldSystem, context).connectTo(newSystem.targetStopDuration);
66
67
  newSystem.emitRate = oldSystem.emitRate;
67
68
  newSystem.manualEmitCount = oldSystem.manualEmitCount;
68
69
  newSystem.blendMode = oldSystem.blendMode;
69
70
  newSystem.capacity = oldSystem.getCapacity();
70
- newSystem.targetStopDuration = oldSystem.targetStopDuration;
71
71
  newSystem.startDelay = oldSystem.startDelay;
72
- newSystem.targetStopDuration = oldSystem.targetStopDuration;
73
72
  newSystem.updateSpeed = oldSystem.updateSpeed;
74
73
  newSystem.preWarmCycles = oldSystem.preWarmCycles;
75
74
  newSystem.preWarmStepOffset = oldSystem.preWarmStepOffset;
@@ -88,40 +87,116 @@ function _CreateSystemBlock(oldSystem) {
88
87
  textureBlock.texture.connectTo(newSystem.texture);
89
88
  return newSystem;
90
89
  }
91
- function _CreateCreateParticleBlock(oldSystem) {
90
+ // ------------- CREATE PARTICLE FUNCTIONS -------------
91
+ // The creation of the different properties follows the order they are added to the CreationQueue in ThinParticleSystem:
92
+ // Lifetime, Position, Direction, Emit, Size, Scale/StartSize, Angle, Velocity, VelocityLimit, Color, Drag, Noise, ColorDead, Ramp, Sheet
93
+ function _CreateParticleBlockGroup(oldSystem, context) {
92
94
  // Create particle
93
95
  const createParticleBlock = new CreateParticleBlock("Create Particle");
94
- // Size
95
- const randomSizeBlock = new ParticleRandomBlock("Random size");
96
- _CreateAndConnectInput("Min size", oldSystem.minSize, randomSizeBlock.min);
97
- _CreateAndConnectInput("Max size", oldSystem.maxSize, randomSizeBlock.max);
98
- randomSizeBlock.output.connectTo(createParticleBlock.size);
99
- // Scale
100
- const randomScaleBlock = new ParticleRandomBlock("Random Scale");
101
- _CreateAndConnectInput("Min Scale", new Vector2(oldSystem.minScaleX, oldSystem.minScaleY), randomScaleBlock.min);
102
- _CreateAndConnectInput("Max Scale", new Vector2(oldSystem.maxScaleX, oldSystem.maxScaleY), randomScaleBlock.max);
103
- randomScaleBlock.output.connectTo(createParticleBlock.scale);
104
- // Color is handled when we do the color update block to manage gradients
105
- // Dead color
106
- _CreateAndConnectInput("Dead Color", oldSystem.colorDead, createParticleBlock.colorDead);
96
+ // Lifetime
97
+ _CreateParticleLifetimeBlockGroup(oldSystem, context).connectTo(createParticleBlock.lifeTime);
107
98
  // Emit power (Speed)
108
99
  const randomEmitPowerBlock = new ParticleRandomBlock("Random Emit Power");
109
100
  _CreateAndConnectInput("Min Emit Power", oldSystem.minEmitPower, randomEmitPowerBlock.min);
110
101
  _CreateAndConnectInput("Max Emit Power", oldSystem.maxEmitPower, randomEmitPowerBlock.max);
111
102
  randomEmitPowerBlock.output.connectTo(createParticleBlock.emitPower);
103
+ // Size
104
+ _CreateParticleSizeBlockGroup(oldSystem, context).connectTo(createParticleBlock.size);
105
+ // Scale/Start Size
106
+ _CreateParticleScaleBlockGroup(oldSystem, context).connectTo(createParticleBlock.scale);
112
107
  // Angle (rotation)
113
108
  const randomRotationBlock = new ParticleRandomBlock("Random Rotation");
114
109
  _CreateAndConnectInput("Min Rotation", oldSystem.minInitialRotation, randomRotationBlock.min);
115
110
  _CreateAndConnectInput("Max Rotation", oldSystem.maxInitialRotation, randomRotationBlock.max);
116
111
  randomRotationBlock.output.connectTo(createParticleBlock.angle);
117
- // Lifetime
118
- const randomLifetimeBlock = new ParticleRandomBlock("Random Lifetime");
119
- _CreateAndConnectInput("Min Lifetime", oldSystem.minLifeTime, randomLifetimeBlock.min);
120
- _CreateAndConnectInput("Max Lifetime", oldSystem.maxLifeTime, randomLifetimeBlock.max);
121
- randomLifetimeBlock.output.connectTo(createParticleBlock.lifeTime);
112
+ // Color is handled when we do the color update block to manage gradients
113
+ // Dead color
114
+ _CreateAndConnectInput("Dead Color", oldSystem.colorDead, createParticleBlock.colorDead);
122
115
  return createParticleBlock;
123
116
  }
124
- function _CreateEmitterShapeBlock(oldSystem) {
117
+ /**
118
+ * Creates the group of blocks that represent the particle lifetime
119
+ * @param oldSystem The old particle system to convert
120
+ * @param context The context of the current conversion
121
+ * @returns The output of the group of blocks that represent the particle lifetime
122
+ */
123
+ function _CreateParticleLifetimeBlockGroup(oldSystem, context) {
124
+ if (oldSystem.targetStopDuration && oldSystem._lifeTimeGradients && oldSystem._lifeTimeGradients.length > 0) {
125
+ context.timeToStopTimeRatioBlockGroupOutput = _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context);
126
+ const gradientBlockGroupOutput = _CreateGradientBlockGroup(context.timeToStopTimeRatioBlockGroupOutput, oldSystem._lifeTimeGradients, ParticleRandomBlockLocks.PerParticle, "Lifetime");
127
+ return gradientBlockGroupOutput;
128
+ }
129
+ else {
130
+ const randomLifetimeBlock = new ParticleRandomBlock("Random Lifetime");
131
+ _CreateAndConnectInput("Min Lifetime", oldSystem.minLifeTime, randomLifetimeBlock.min);
132
+ _CreateAndConnectInput("Max Lifetime", oldSystem.maxLifeTime, randomLifetimeBlock.max);
133
+ return randomLifetimeBlock.output;
134
+ }
135
+ }
136
+ /**
137
+ * Creates the group of blocks that represent the particle size
138
+ * @param oldSystem The old particle system to convert
139
+ * @param context The context of the current conversion
140
+ * @returns The output of the group of blocks that represent the particle lifetime
141
+ */
142
+ function _CreateParticleSizeBlockGroup(oldSystem, context) {
143
+ if (oldSystem._sizeGradients && oldSystem._sizeGradients.length > 0) {
144
+ const sizeGradientBlockGroupOutput = _CreateParticleSizeGradientBlockGroup(oldSystem._sizeGradients, context);
145
+ return sizeGradientBlockGroupOutput;
146
+ }
147
+ else {
148
+ const randomSizeBlock = new ParticleRandomBlock("Random size");
149
+ _CreateAndConnectInput("Min size", oldSystem.minSize, randomSizeBlock.min);
150
+ _CreateAndConnectInput("Max size", oldSystem.maxSize, randomSizeBlock.max);
151
+ return randomSizeBlock.output;
152
+ }
153
+ }
154
+ function _CreateParticleScaleBlockGroup(oldSystem, context) {
155
+ // Create the random scale
156
+ const randomScaleBlock = new ParticleRandomBlock("Random Scale");
157
+ _CreateAndConnectInput("Min Scale", new Vector2(oldSystem.minScaleX, oldSystem.minScaleY), randomScaleBlock.min);
158
+ _CreateAndConnectInput("Max Scale", new Vector2(oldSystem.maxScaleX, oldSystem.maxScaleY), randomScaleBlock.max);
159
+ if (oldSystem.targetStopDuration && oldSystem._startSizeGradients && oldSystem._startSizeGradients.length > 0) {
160
+ // Create the start size gradient
161
+ context.timeToStopTimeRatioBlockGroupOutput = _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context);
162
+ const gradientBlockGroupOutput = _CreateGradientBlockGroup(context.timeToStopTimeRatioBlockGroupOutput, oldSystem._startSizeGradients, ParticleRandomBlockLocks.PerParticle, "Start Size");
163
+ // Multiply the initial random scale by the start size gradient
164
+ const multiplyScaleBlock = new ParticleMathBlock("Multiply Scale by Start Size Gradient");
165
+ multiplyScaleBlock.operation = ParticleMathBlockOperations.Multiply;
166
+ randomScaleBlock.output.connectTo(multiplyScaleBlock.left);
167
+ gradientBlockGroupOutput.connectTo(multiplyScaleBlock.right);
168
+ return multiplyScaleBlock.output;
169
+ }
170
+ else {
171
+ return randomScaleBlock.output;
172
+ }
173
+ }
174
+ function _CreateParticleSizeGradientBlockGroup(sizeGradients, context) {
175
+ if (sizeGradients.length === 0) {
176
+ throw new Error("No size gradients provided.");
177
+ }
178
+ const initialParticleSize = _CreateSizeFromGradientStep(sizeGradients[0], 0);
179
+ context.sizeGradientValue0Output = initialParticleSize;
180
+ return initialParticleSize;
181
+ }
182
+ function _CreateSizeFromGradientStep(gradientStep, index) {
183
+ if (gradientStep.factor2 !== undefined) {
184
+ // Create a random between value1 and value2
185
+ const randomBlock = new ParticleRandomBlock("Random Value " + index);
186
+ randomBlock.lockMode = ParticleRandomBlockLocks.OncePerParticle;
187
+ _CreateAndConnectInput("Value 1", gradientStep.factor1, randomBlock.min);
188
+ _CreateAndConnectInput("Value 2", gradientStep.factor2, randomBlock.max);
189
+ return randomBlock.output;
190
+ }
191
+ else {
192
+ // Single value
193
+ const sizeBlock = new ParticleInputBlock("Value");
194
+ sizeBlock.value = gradientStep.factor1;
195
+ return sizeBlock.output;
196
+ }
197
+ }
198
+ // ------------- EMITTER SHAPE FUNCTIONS -------------
199
+ function _EmitterShapeBlock(oldSystem) {
125
200
  const emitter = oldSystem.particleEmitterType;
126
201
  if (!emitter) {
127
202
  throw new Error("Particle system has no emitter type.");
@@ -142,17 +217,35 @@ function _CreateEmitterShapeBlock(oldSystem) {
142
217
  const source = emitter;
143
218
  shapeBlock = new ConeShapeBlock("Cone Shape");
144
219
  const target = shapeBlock;
220
+ target.emitFromSpawnPointOnly = source.emitFromSpawnPointOnly;
145
221
  _CreateAndConnectInput("Radius", source.radius, target.radius);
146
222
  _CreateAndConnectInput("Angle", source.angle, target.angle);
147
223
  _CreateAndConnectInput("Radius Range", source.radiusRange, target.radiusRange);
148
224
  _CreateAndConnectInput("Height Range", source.heightRange, target.heightRange);
149
- _CreateAndConnectInput("Emit From Spawn Point Only", source.emitFromSpawnPointOnly ? 1 : 0, target.emitFromSpawnPointOnly, NodeParticleBlockConnectionPointTypes.Int);
150
225
  _CreateAndConnectInput("Direction Randomizer", source.directionRandomizer, target.directionRandomizer);
151
226
  break;
152
227
  }
228
+ case "ConeDirectedParticleEmitter": {
229
+ const source = emitter;
230
+ shapeBlock = new ConeShapeBlock("Cone Shape");
231
+ const target = shapeBlock;
232
+ target.emitFromSpawnPointOnly = source.emitFromSpawnPointOnly;
233
+ _CreateAndConnectInput("Radius", source.radius, target.radius);
234
+ _CreateAndConnectInput("Angle", source.angle, target.angle);
235
+ _CreateAndConnectInput("Radius Range", source.radiusRange, target.radiusRange);
236
+ _CreateAndConnectInput("Height Range", source.heightRange, target.heightRange);
237
+ _CreateAndConnectInput("Direction 1", source.direction1, target.direction1);
238
+ _CreateAndConnectInput("Direction 2", source.direction2, target.direction2);
239
+ break;
240
+ }
153
241
  case "CustomParticleEmitter": {
154
- // Custom emitter is not supported in nodes yet
155
- throw new Error("CustomParticleEmitter is not supported in Node Particle System.");
242
+ const source = emitter;
243
+ shapeBlock = new CustomShapeBlock("Custom Shape");
244
+ const target = shapeBlock;
245
+ target.particlePositionGenerator = source.particlePositionGenerator;
246
+ target.particleDestinationGenerator = source.particleDestinationGenerator;
247
+ target.particleDirectionGenerator = source.particleDirectionGenerator;
248
+ break;
156
249
  }
157
250
  case "CylinderParticleEmitter": {
158
251
  const source = emitter;
@@ -176,8 +269,14 @@ function _CreateEmitterShapeBlock(oldSystem) {
176
269
  break;
177
270
  }
178
271
  case "HemisphericParticleEmitter": {
179
- // Hemispheric emitter is not supported in nodes yet
180
- throw new Error("HemisphericParticleEmitter is not supported in Node Particle System.");
272
+ const source = emitter;
273
+ shapeBlock = new SphereShapeBlock("Sphere Shape");
274
+ const target = shapeBlock;
275
+ target.isHemispheric = true;
276
+ _CreateAndConnectInput("Radius", source.radius, target.radius);
277
+ _CreateAndConnectInput("Radius Range", source.radiusRange, target.radiusRange);
278
+ _CreateAndConnectInput("Direction Randomizer", source.directionRandomizer, target.directionRandomizer);
279
+ break;
181
280
  }
182
281
  case "MeshParticleEmitter": {
183
282
  const source = emitter;
@@ -222,18 +321,31 @@ function _CreateEmitterShapeBlock(oldSystem) {
222
321
  }
223
322
  return shapeBlock;
224
323
  }
225
- function _CreateUpdateSystem(inputParticle, oldSystem) {
324
+ // ------------- UPDATE PARTICLE FUNCTIONS -------------
325
+ /**
326
+ * Creates the group of blocks that represent the particle system update
327
+ * The creation of the different properties follows the order they are added to the ProcessQueue in ThinParticleSystem:
328
+ * Color, AngularSpeedGradients, AngularSpeed, VelocityGradients, Direction, LimitVelocityGradients, DragGradients, Position, Noise, SizeGradients, Gravity, RemapGradients
329
+ * @param inputParticle The particle input connection point
330
+ * @param oldSystem The old particle system to convert
331
+ * @param context The runtime conversion context
332
+ * @returns The output connection point after all updates have been applied
333
+ */
334
+ function _UpdateParticleBlockGroup(inputParticle, oldSystem, context) {
226
335
  let outputUpdate = inputParticle;
227
336
  if (oldSystem.minAngularSpeed !== 0 || oldSystem.maxAngularSpeed !== 0) {
228
- outputUpdate = _CreateAngularSpeedUpdate(outputUpdate, oldSystem.minAngularSpeed, oldSystem.maxAngularSpeed);
337
+ outputUpdate = _UpdateParticleAngularSpeedBlockGroup(outputUpdate, oldSystem.minAngularSpeed, oldSystem.maxAngularSpeed);
338
+ }
339
+ outputUpdate = _UpdateParticlePositionBlockGroup(outputUpdate, oldSystem.isLocal);
340
+ if (oldSystem._sizeGradients && oldSystem._sizeGradients.length > 0) {
341
+ outputUpdate = _UpdateParticleSizeGradientBlockGroup(outputUpdate, oldSystem._sizeGradients, context);
229
342
  }
230
- outputUpdate = _CreatePositionUpdate(outputUpdate, oldSystem.isLocal);
231
343
  if (oldSystem.gravity.equalsToFloats(0, 0, 0) === false) {
232
- outputUpdate = _CreateGravityUpdate(outputUpdate, oldSystem.gravity);
344
+ outputUpdate = _UpdateParticleGravityBlockGroup(outputUpdate, oldSystem.gravity);
233
345
  }
234
346
  return outputUpdate;
235
347
  }
236
- function _CreateAngularSpeedUpdate(inputParticle, minAngularSpeed, maxAngularSpeed) {
348
+ function _UpdateParticleAngularSpeedBlockGroup(inputParticle, minAngularSpeed, maxAngularSpeed) {
237
349
  // Random value between for the angular speed of the particle
238
350
  const randomAngularSpeedBlock = new ParticleRandomBlock("Random Angular Speed");
239
351
  _CreateAndConnectInput("Min Angular Speed", minAngularSpeed, randomAngularSpeedBlock.min);
@@ -251,7 +363,7 @@ function _CreateAngularSpeedUpdate(inputParticle, minAngularSpeed, maxAngularSpe
251
363
  addAngle.output.connectTo(updateAngle.angle);
252
364
  return updateAngle.output;
253
365
  }
254
- function _CreatePositionUpdate(inputParticle, isLocal) {
366
+ function _UpdateParticlePositionBlockGroup(inputParticle, isLocal) {
255
367
  // Update the particle position
256
368
  const updatePosition = new UpdatePositionBlock("Position Update");
257
369
  inputParticle.connectTo(updatePosition.particle);
@@ -268,7 +380,22 @@ function _CreatePositionUpdate(inputParticle, isLocal) {
268
380
  }
269
381
  return updatePosition.output;
270
382
  }
271
- function _CreateGravityUpdate(inputParticle, gravity) {
383
+ function _UpdateParticleSizeGradientBlockGroup(inputParticle, sizeGradients, context) {
384
+ if (context.sizeGradientValue0Output === undefined) {
385
+ throw new Error("Initial size gradient values not found in context.");
386
+ }
387
+ context.ageToLifeTimeRatioBlockGroupOutput = _CreateAgeToLifeTimeRatioBlockGroup(context);
388
+ // Generate the gradient
389
+ const sizeValueOutput = _CreateGradientBlockGroup(context.ageToLifeTimeRatioBlockGroupOutput, sizeGradients, ParticleRandomBlockLocks.OncePerParticle, "Size", [
390
+ context.sizeGradientValue0Output,
391
+ ]);
392
+ // Create the update size
393
+ const updateSizeBlock = new UpdateSizeBlock("Size Update");
394
+ inputParticle.connectTo(updateSizeBlock.particle);
395
+ sizeValueOutput.connectTo(updateSizeBlock.size);
396
+ return updateSizeBlock.output;
397
+ }
398
+ function _UpdateParticleGravityBlockGroup(inputParticle, gravity) {
272
399
  // Create the gravity delta
273
400
  const gravityDeltaOutput = _CreateDeltaModifiedInput("Gravity", gravity);
274
401
  // Add it to the direction
@@ -377,6 +504,7 @@ function _ClampUpdateColorAlpha(colorBlock) {
377
504
  maxAlphaBlock.output.connectTo(composeColorBlock.wIn);
378
505
  return composeColorBlock;
379
506
  }
507
+ // ------------- UTILITY FUNCTIONS -------------
380
508
  function _CreateDeltaModifiedInput(name, value) {
381
509
  const multiplyBlock = new ParticleMathBlock("Multiply by Delta");
382
510
  multiplyBlock.operation = ParticleMathBlockOperations.Multiply;
@@ -404,4 +532,125 @@ function _CreateAndConnectSystemSource(systemBlockName, systemSource, targetToCo
404
532
  input.systemSource = systemSource;
405
533
  input.output.connectTo(targetToConnectTo);
406
534
  }
535
+ /**
536
+ * Creates the target stop duration input block, as it can be shared in multiple places
537
+ * This block is stored in the context so the same block is shared in the graph
538
+ * @param oldSystem The old particle system to convert
539
+ * @param context The context of the current conversion
540
+ * @returns
541
+ */
542
+ function _CreateTargetStopDurationInputBlock(oldSystem, context) {
543
+ // If we have already created the target stop duration input block, return it
544
+ if (context.targetStopDurationBlockOutput) {
545
+ return context.targetStopDurationBlockOutput;
546
+ }
547
+ // Create the target stop duration input block if not already created
548
+ const targetStopDurationInputBlock = new ParticleInputBlock("Target Stop Duration");
549
+ targetStopDurationInputBlock.value = oldSystem.targetStopDuration;
550
+ // Save the output in our context to avoid regenerating it again
551
+ context.targetStopDurationBlockOutput = targetStopDurationInputBlock.output;
552
+ return context.targetStopDurationBlockOutput;
553
+ }
554
+ /**
555
+ * Create a group of blocks that calculates the ratio between the actual frame and the target stop duration, clamped between 0 and 1.
556
+ * This is used to simulate the behavior of the old particle system where several particle gradient values are affected by the target stop duration.
557
+ * This block group is stored in the context so the same group is shared in the graph
558
+ * @param oldSystem The old particle system to convert
559
+ * @param context The context of the current conversion
560
+ * @returns The ratio block output connection point
561
+ */
562
+ function _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context) {
563
+ // If we have already generated this group, return it
564
+ if (context.timeToStopTimeRatioBlockGroupOutput) {
565
+ return context.timeToStopTimeRatioBlockGroupOutput;
566
+ }
567
+ context.targetStopDurationBlockOutput = _CreateTargetStopDurationInputBlock(oldSystem, context);
568
+ // Find the ratio between the actual frame and the target stop duration
569
+ const ratio = new ParticleMathBlock("Frame/Stop Ratio");
570
+ ratio.operation = ParticleMathBlockOperations.Divide;
571
+ _CreateAndConnectSystemSource("Actual Frame", NodeParticleSystemSources.Time, ratio.left);
572
+ context.targetStopDurationBlockOutput.connectTo(ratio.right);
573
+ // Make sure values is >=0
574
+ const clampMin = new ParticleMathBlock("Clamp Min 0");
575
+ clampMin.operation = ParticleMathBlockOperations.Max;
576
+ _CreateAndConnectInput("Zero", 0, clampMin.left);
577
+ ratio.output.connectTo(clampMin.right);
578
+ // Make sure values is <=1
579
+ const clampMax = new ParticleMathBlock("Clamp Max 1");
580
+ clampMax.operation = ParticleMathBlockOperations.Min;
581
+ _CreateAndConnectInput("One", 1, clampMax.left);
582
+ clampMin.output.connectTo(clampMax.right);
583
+ // Save the group output in our context to avoid regenerating it again
584
+ context.timeToStopTimeRatioBlockGroupOutput = clampMax.output;
585
+ return context.timeToStopTimeRatioBlockGroupOutput;
586
+ }
587
+ function _CreateAgeToLifeTimeRatioBlockGroup(context) {
588
+ // If we have already generated this group, return it
589
+ if (context.ageToLifeTimeRatioBlockGroupOutput) {
590
+ return context.ageToLifeTimeRatioBlockGroupOutput;
591
+ }
592
+ // Find the ratio between the age and the lifetime
593
+ const ratio = new ParticleMathBlock("Age/LifeTime Ratio");
594
+ ratio.operation = ParticleMathBlockOperations.Divide;
595
+ _CreateAndConnectContextualSource("Age", NodeParticleContextualSources.Age, ratio.left);
596
+ _CreateAndConnectContextualSource("LifeTime", NodeParticleContextualSources.Lifetime, ratio.right);
597
+ // Save the group output in our context to avoid regenerating it again
598
+ context.ageToLifeTimeRatioBlockGroupOutput = ratio.output;
599
+ return ratio.output;
600
+ }
601
+ /**
602
+ * Creates the blocks that represent a gradient
603
+ * @param gradientSelector The value that determines which gradient to use
604
+ * @param gradientValues The list of gradient values
605
+ * @param randomLockMode The type of random to use for the gradient values
606
+ * @param prefix The prefix to use for naming the blocks
607
+ * @param initialValues Optional initial values to connect to the gradient inputs that were calculated during other steps of the conversion
608
+ * @returns The output connection point of the gradient block
609
+ */
610
+ function _CreateGradientBlockGroup(gradientSelector, gradientValues, randomLockMode, prefix, initialValues = []) {
611
+ // Create the gradient block and connect the value that controls the gradient selection
612
+ const gradientBlock = new ParticleGradientBlock(prefix + " Gradient Block");
613
+ gradientSelector.connectTo(gradientBlock.gradient);
614
+ // If initial values are provided, we use them instead of the values in the gradientValues array
615
+ // These means this values were already transformed into blocks on a previous step of the conversion and we must reuse them
616
+ for (let i = 0; i < initialValues.length; i++) {
617
+ const reference = i < gradientValues.length ? gradientValues[i].gradient : 1;
618
+ const gradientValueBlock = new ParticleGradientValueBlock(prefix + " Gradient Value " + i);
619
+ gradientValueBlock.reference = reference;
620
+ initialValues[i].connectTo(gradientValueBlock.value);
621
+ gradientValueBlock.output.connectTo(gradientBlock.inputs[i + 1]);
622
+ }
623
+ // Create the gradient values
624
+ for (let i = 0 + initialValues.length; i < gradientValues.length; i++) {
625
+ const gradientValueBlockGroupOutput = _CreateGradientValueBlockGroup(gradientValues[i], randomLockMode, prefix, i);
626
+ gradientValueBlockGroupOutput.connectTo(gradientBlock.inputs[i + 1]);
627
+ }
628
+ return gradientBlock.output;
629
+ }
630
+ /**
631
+ * Creates the blocks that represent a gradient value
632
+ * This can be either a single value or a random between two values
633
+ * @param gradientStep The gradient step data
634
+ * @param randomLockMode The lock mode to use for random values
635
+ * @param prefix The prefix to use for naming the blocks
636
+ * @param index The index of the gradient step
637
+ * @returns The output connection point of the gradient value block
638
+ */
639
+ function _CreateGradientValueBlockGroup(gradientStep, randomLockMode, prefix, index) {
640
+ const gradientValueBlock = new ParticleGradientValueBlock(prefix + " Gradient Value " + index);
641
+ gradientValueBlock.reference = gradientStep.gradient;
642
+ if (gradientStep.factor2 !== undefined) {
643
+ // Create a random between value1 and value2
644
+ const randomBlock = new ParticleRandomBlock("Random Value " + index);
645
+ randomBlock.lockMode = randomLockMode;
646
+ _CreateAndConnectInput("Value 1", gradientStep.factor1, randomBlock.min);
647
+ _CreateAndConnectInput("Value 2", gradientStep.factor2, randomBlock.max);
648
+ randomBlock.output.connectTo(gradientValueBlock.value);
649
+ }
650
+ else {
651
+ // Single value
652
+ _CreateAndConnectInput("Value", gradientStep.factor1, gradientValueBlock.value);
653
+ }
654
+ return gradientValueBlock.output;
655
+ }
407
656
  //# sourceMappingURL=nodeParticleSystemSet.helper.js.map