@onerjs/core 8.31.0 → 8.31.1

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 (92) hide show
  1. package/Animations/animationGroup.js +1 -4
  2. package/Animations/animationGroup.js.map +1 -1
  3. package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
  4. package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
  5. package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
  6. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
  7. package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
  8. package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +7 -20
  9. package/Cameras/Inputs/geospatialCameraPointersInput.js +27 -75
  10. package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
  11. package/Cameras/Limits/geospatialLimits.d.ts +60 -0
  12. package/Cameras/Limits/geospatialLimits.js +89 -0
  13. package/Cameras/Limits/geospatialLimits.js.map +1 -0
  14. package/Cameras/cameraMovement.js +1 -1
  15. package/Cameras/cameraMovement.js.map +1 -1
  16. package/Cameras/geospatialCamera.d.ts +53 -49
  17. package/Cameras/geospatialCamera.js +172 -192
  18. package/Cameras/geospatialCamera.js.map +1 -1
  19. package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
  20. package/Cameras/geospatialCameraInputsManager.js +9 -0
  21. package/Cameras/geospatialCameraInputsManager.js.map +1 -1
  22. package/Cameras/geospatialCameraMovement.d.ts +66 -0
  23. package/Cameras/geospatialCameraMovement.js +199 -0
  24. package/Cameras/geospatialCameraMovement.js.map +1 -0
  25. package/Engines/Native/nativeInterfaces.d.ts +14 -6
  26. package/Engines/Native/nativeInterfaces.js +6 -1
  27. package/Engines/Native/nativeInterfaces.js.map +1 -1
  28. package/Engines/nativeEngine.js +2 -2
  29. package/Engines/nativeEngine.js.map +1 -1
  30. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
  31. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
  32. package/FlowGraph/flowGraphMath.d.ts +25 -0
  33. package/FlowGraph/flowGraphMath.js +40 -0
  34. package/FlowGraph/flowGraphMath.js.map +1 -0
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
  38. package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
  39. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
  40. package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
  41. package/Materials/shaderMaterial.js +4 -2
  42. package/Materials/shaderMaterial.js.map +1 -1
  43. package/Maths/math.vector.functions.d.ts +5 -24
  44. package/Maths/math.vector.functions.js +32 -35
  45. package/Maths/math.vector.functions.js.map +1 -1
  46. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
  47. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
  48. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  49. package/Meshes/csg2.js +1 -1
  50. package/Meshes/csg2.js.map +1 -1
  51. package/Meshes/thinInstanceMesh.js +15 -0
  52. package/Meshes/thinInstanceMesh.js.map +1 -1
  53. package/Misc/fileTools.js.map +1 -1
  54. package/Misc/tools.d.ts +3 -0
  55. package/Misc/tools.js +43 -4
  56. package/Misc/tools.js.map +1 -1
  57. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +2 -2
  58. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  59. package/Particles/Node/nodeParticleBuildState.js +4 -4
  60. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  61. package/Particles/Node/nodeParticleSystemSet.helper.js +147 -144
  62. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  63. package/Particles/particle.d.ts +4 -0
  64. package/Particles/particle.js +2 -0
  65. package/Particles/particle.js.map +1 -1
  66. package/Particles/thinParticleSystem.d.ts +0 -4
  67. package/Particles/thinParticleSystem.function.d.ts +1 -1
  68. package/Particles/thinParticleSystem.function.js +9 -6
  69. package/Particles/thinParticleSystem.function.js.map +1 -1
  70. package/Particles/thinParticleSystem.js +1 -3
  71. package/Particles/thinParticleSystem.js.map +1 -1
  72. package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
  73. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  74. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  75. package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  76. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
  77. package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  78. package/Shaders/gaussianSplatting.vertex.js +3 -3
  79. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  80. package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
  81. package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
  82. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
  83. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  84. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
  85. package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
  86. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
  87. package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
  88. package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
  89. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  90. package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
  91. package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
  92. package/package.json +1 -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,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,IAAI,CAAC;QAE1D;;WAEG;QACI,kBAAa,GAAW,CAAC,CAAC;QACjC;;WAEG;QACI,sBAAiB,GAAW,CAAC,CAAC;IA0KzC,CAAC;IApKG;;OAEG;IACI,UAAU;QACb,IAAI,YAAY,GAAG,EAAE,CAAC;QAEtB,KAAK,MAAM,iBAAiB,IAAI,IAAI,CAAC,6BAA6B,EAAE,CAAC;YACjE,YAAY,IAAI,SAAS,iBAAiB,CAAC,IAAI,eAC3C,iBAAiB,CAAC,UAAU,CAAC,IACjC,IAAI,iBAAiB,CAAC,UAAU,CAAC,YAAY,EAAE,2CAA2C,CAAC;QAC/F,CAAC;QAED,IAAI,YAAY,EAAE,CAAC;YACf,4CAA4C;YAC5C,MAAM,6CAA6C,GAAG,YAAY,CAAC;QACvE,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAmC,EAAE,UAAiD;QACxF,MAAM,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAElD,IAAI,MAAM,CAAC,IAA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I,CAAC,aAAa,CAAC,OAAQ,CAAC,gBAAgB,CAAC;IACvE,CAAC;IAED;;;;OAIG;IACI,cAAc,CAAC,MAAiC;QACnD,IAAI,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,yBAAyB,CAAC,IAAI;gBAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;YAC3C,KAAK,yBAAyB,CAAC,KAAK;gBAChC,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,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.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"]}
1
+ {"version":3,"file":"nodeParticleBuildState.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleBu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AAC,eAAe,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YAC/C,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,yBAAyB,CAAC,IAAI;gBAC/B,OAAO,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;YAC3C,KAAK,yBAAyB,CAAC,KAAK;gBAChC,OAAO,IAAI,CAAC,aAAa,CAAC,kBAAkB,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.particleContext._directionScale, this.particleContext._scaledDirection);\r\n return this.particleContext._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.particleContext._directionScale, this.particleContext._scaledDirection);\r\n this.particleContext._localPosition!.addInPlace(this.particleContext._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"]}
@@ -42,19 +42,16 @@ export async function ConvertToNodeParticleSystemSetAsync(name, particleSystemsL
42
42
  return nodeParticleSystemSet;
43
43
  }
44
44
  async function _ExtractDatafromParticleSystemAsync(newSet, oldSystem, context) {
45
- // CreateParticle block
46
- const createParticleBlock = _CreateParticleBlockGroup(oldSystem, context);
45
+ // CreateParticle block group
46
+ const createParticleOutput = _CreateParticleBlockGroup(oldSystem, context);
47
47
  // Emitter Shape block
48
- const shapeBlock = _EmitterShapeBlock(oldSystem);
49
- createParticleBlock.particle.connectTo(shapeBlock.particle);
50
- // Update the particle position
51
- const positionUpdatedParticle = _UpdateParticleBlockGroup(shapeBlock.output, oldSystem, context);
52
- // Color update
53
- const colorUpdateBlock = _CreateColorUpdateBlock(oldSystem, createParticleBlock);
54
- positionUpdatedParticle.connectTo(colorUpdateBlock.particle);
48
+ const shapeOutput = _EmitterShapeBlock(oldSystem);
49
+ createParticleOutput.particle.connectTo(shapeOutput.particle);
50
+ // UpdateParticle block group
51
+ const updateParticleOutput = _UpdateParticleBlockGroup(shapeOutput.output, oldSystem, context);
55
52
  // System block
56
53
  const newSystem = _SystemBlockGroup(oldSystem, context);
57
- colorUpdateBlock.output.connectTo(newSystem.particle);
54
+ updateParticleOutput.connectTo(newSystem.particle);
58
55
  // Register
59
56
  newSet.systemBlocks.push(newSystem);
60
57
  }
@@ -89,27 +86,16 @@ function _SystemBlockGroup(oldSystem, context) {
89
86
  }
90
87
  // ------------- CREATE PARTICLE FUNCTIONS -------------
91
88
  // 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
89
+ // Lifetime, Emit Power, Size, Scale/StartSize, Angle, Velocity, VelocityLimit, Color, Drag, Noise, ColorDead, Ramp, Sheet
93
90
  function _CreateParticleBlockGroup(oldSystem, context) {
94
- // Create particle
91
+ // Create particle block
95
92
  const createParticleBlock = new CreateParticleBlock("Create Particle");
96
- // Lifetime
97
93
  _CreateParticleLifetimeBlockGroup(oldSystem, context).connectTo(createParticleBlock.lifeTime);
98
- // Emit power (Speed)
99
- const randomEmitPowerBlock = new ParticleRandomBlock("Random Emit Power");
100
- _CreateAndConnectInput("Min Emit Power", oldSystem.minEmitPower, randomEmitPowerBlock.min);
101
- _CreateAndConnectInput("Max Emit Power", oldSystem.maxEmitPower, randomEmitPowerBlock.max);
102
- randomEmitPowerBlock.output.connectTo(createParticleBlock.emitPower);
103
- // Size
94
+ _CreateParticleEmitPowerBlockGroup(oldSystem).connectTo(createParticleBlock.emitPower);
104
95
  _CreateParticleSizeBlockGroup(oldSystem, context).connectTo(createParticleBlock.size);
105
- // Scale/Start Size
106
96
  _CreateParticleScaleBlockGroup(oldSystem, context).connectTo(createParticleBlock.scale);
107
- // Angle (rotation)
108
- const randomRotationBlock = new ParticleRandomBlock("Random Rotation");
109
- _CreateAndConnectInput("Min Rotation", oldSystem.minInitialRotation, randomRotationBlock.min);
110
- _CreateAndConnectInput("Max Rotation", oldSystem.maxInitialRotation, randomRotationBlock.max);
111
- randomRotationBlock.output.connectTo(createParticleBlock.angle);
112
- // Color is handled when we do the color update block to manage gradients
97
+ _CreateParticleAngleBlockGroup(oldSystem).connectTo(createParticleBlock.angle);
98
+ _CreateParticleColorBlockGroup(oldSystem, context).connectTo(createParticleBlock.color);
113
99
  // Dead color
114
100
  _CreateAndConnectInput("Dead Color", oldSystem.colorDead, createParticleBlock.colorDead);
115
101
  return createParticleBlock;
@@ -133,16 +119,27 @@ function _CreateParticleLifetimeBlockGroup(oldSystem, context) {
133
119
  return randomLifetimeBlock.output;
134
120
  }
135
121
  }
122
+ /**
123
+ * Creates the group of blocks that represent the particle emit power
124
+ * @param oldSystem The old particle system to convert
125
+ * @returns The output of the group of blocks that represent the particle emit power
126
+ */
127
+ function _CreateParticleEmitPowerBlockGroup(oldSystem) {
128
+ const randomEmitPowerBlock = new ParticleRandomBlock("Random Emit Power");
129
+ _CreateAndConnectInput("Min Emit Power", oldSystem.minEmitPower, randomEmitPowerBlock.min);
130
+ _CreateAndConnectInput("Max Emit Power", oldSystem.maxEmitPower, randomEmitPowerBlock.max);
131
+ return randomEmitPowerBlock.output;
132
+ }
136
133
  /**
137
134
  * Creates the group of blocks that represent the particle size
138
135
  * @param oldSystem The old particle system to convert
139
136
  * @param context The context of the current conversion
140
- * @returns The output of the group of blocks that represent the particle lifetime
137
+ * @returns The output of the group of blocks that represent the particle size
141
138
  */
142
139
  function _CreateParticleSizeBlockGroup(oldSystem, context) {
143
140
  if (oldSystem._sizeGradients && oldSystem._sizeGradients.length > 0) {
144
- const sizeGradientBlockGroupOutput = _CreateParticleSizeGradientBlockGroup(oldSystem._sizeGradients, context);
145
- return sizeGradientBlockGroupOutput;
141
+ context.sizeGradientValue0Output = _CreateParticleInitialValueFromGradient(oldSystem._sizeGradients);
142
+ return context.sizeGradientValue0Output;
146
143
  }
147
144
  else {
148
145
  const randomSizeBlock = new ParticleRandomBlock("Random size");
@@ -151,6 +148,12 @@ function _CreateParticleSizeBlockGroup(oldSystem, context) {
151
148
  return randomSizeBlock.output;
152
149
  }
153
150
  }
151
+ /**
152
+ * Creates the group of blocks that represent the particle scale
153
+ * @param oldSystem The old particle system to convert
154
+ * @param context The context of the current conversion
155
+ * @returns The output of the group of blocks that represent the particle scale
156
+ */
154
157
  function _CreateParticleScaleBlockGroup(oldSystem, context) {
155
158
  // Create the random scale
156
159
  const randomScaleBlock = new ParticleRandomBlock("Random Scale");
@@ -171,27 +174,54 @@ function _CreateParticleScaleBlockGroup(oldSystem, context) {
171
174
  return randomScaleBlock.output;
172
175
  }
173
176
  }
174
- function _CreateParticleSizeGradientBlockGroup(sizeGradients, context) {
175
- if (sizeGradients.length === 0) {
176
- throw new Error("No size gradients provided.");
177
+ /**
178
+ * Creates the group of blocks that represent the particle angle (rotation)
179
+ * @param oldSystem The old particle system to convert
180
+ * @returns The output of the group of blocks that represent the particle angle (rotation)
181
+ */
182
+ function _CreateParticleAngleBlockGroup(oldSystem) {
183
+ const randomRotationBlock = new ParticleRandomBlock("Random Rotation");
184
+ _CreateAndConnectInput("Min Rotation", oldSystem.minInitialRotation, randomRotationBlock.min);
185
+ _CreateAndConnectInput("Max Rotation", oldSystem.maxInitialRotation, randomRotationBlock.max);
186
+ return randomRotationBlock.output;
187
+ }
188
+ /**
189
+ * Creates the group of blocks that represent the particle color
190
+ * @param oldSystem The old particle system to convert
191
+ * @param context The context of the current conversion
192
+ * @returns The output of the group of blocks that represent the particle color
193
+ */
194
+ function _CreateParticleColorBlockGroup(oldSystem, context) {
195
+ if (oldSystem._colorGradients && oldSystem._colorGradients.length > 0) {
196
+ context.colorGradientValue0Output = _CreateParticleInitialValueFromGradient(oldSystem._colorGradients);
197
+ return context.colorGradientValue0Output;
198
+ }
199
+ else {
200
+ const randomColorBlock = new ParticleRandomBlock("Random color");
201
+ _CreateAndConnectInput("Color 1", oldSystem.color1, randomColorBlock.min);
202
+ _CreateAndConnectInput("Color 2", oldSystem.color2, randomColorBlock.max);
203
+ return randomColorBlock.output;
177
204
  }
178
- const initialParticleSize = _CreateSizeFromGradientStep(sizeGradients[0], 0);
179
- context.sizeGradientValue0Output = initialParticleSize;
180
- return initialParticleSize;
181
205
  }
182
- function _CreateSizeFromGradientStep(gradientStep, index) {
183
- if (gradientStep.factor2 !== undefined) {
206
+ function _CreateParticleInitialValueFromGradient(gradients) {
207
+ if (gradients.length === 0) {
208
+ throw new Error("No gradients provided.");
209
+ }
210
+ const gradientStep = gradients[0];
211
+ const value1 = gradientStep.factor1 ?? gradientStep.color1;
212
+ const value2 = gradientStep.factor2 ?? gradientStep.color2;
213
+ if (value2 !== undefined) {
184
214
  // Create a random between value1 and value2
185
- const randomBlock = new ParticleRandomBlock("Random Value " + index);
215
+ const randomBlock = new ParticleRandomBlock("Random Value 0");
186
216
  randomBlock.lockMode = ParticleRandomBlockLocks.OncePerParticle;
187
- _CreateAndConnectInput("Value 1", gradientStep.factor1, randomBlock.min);
188
- _CreateAndConnectInput("Value 2", gradientStep.factor2, randomBlock.max);
217
+ _CreateAndConnectInput("Value 1", value1, randomBlock.min);
218
+ _CreateAndConnectInput("Value 2", value2, randomBlock.max);
189
219
  return randomBlock.output;
190
220
  }
191
221
  else {
192
222
  // Single value
193
223
  const sizeBlock = new ParticleInputBlock("Value");
194
- sizeBlock.value = gradientStep.factor1;
224
+ sizeBlock.value = value1;
195
225
  return sizeBlock.output;
196
226
  }
197
227
  }
@@ -332,36 +362,80 @@ function _EmitterShapeBlock(oldSystem) {
332
362
  * @returns The output connection point after all updates have been applied
333
363
  */
334
364
  function _UpdateParticleBlockGroup(inputParticle, oldSystem, context) {
335
- let outputUpdate = inputParticle;
336
- if (oldSystem.minAngularSpeed !== 0 || oldSystem.maxAngularSpeed !== 0) {
337
- outputUpdate = _UpdateParticleAngularSpeedBlockGroup(outputUpdate, oldSystem.minAngularSpeed, oldSystem.maxAngularSpeed);
338
- }
339
- outputUpdate = _UpdateParticlePositionBlockGroup(outputUpdate, oldSystem.isLocal);
365
+ let updateBlockGroupOutput = inputParticle;
366
+ updateBlockGroupOutput = _UpdateParticleColorBlockGroup(updateBlockGroupOutput, oldSystem._colorGradients, context);
367
+ updateBlockGroupOutput = _UpdateParticleAngleBlockGroup(updateBlockGroupOutput, oldSystem, context);
368
+ updateBlockGroupOutput = _UpdateParticlePositionBlockGroup(updateBlockGroupOutput, oldSystem.isLocal);
340
369
  if (oldSystem._sizeGradients && oldSystem._sizeGradients.length > 0) {
341
- outputUpdate = _UpdateParticleSizeGradientBlockGroup(outputUpdate, oldSystem._sizeGradients, context);
370
+ updateBlockGroupOutput = _UpdateParticleSizeGradientBlockGroup(updateBlockGroupOutput, oldSystem._sizeGradients, context);
342
371
  }
343
372
  if (oldSystem.gravity.equalsToFloats(0, 0, 0) === false) {
344
- outputUpdate = _UpdateParticleGravityBlockGroup(outputUpdate, oldSystem.gravity);
373
+ updateBlockGroupOutput = _UpdateParticleGravityBlockGroup(updateBlockGroupOutput, oldSystem.gravity);
374
+ }
375
+ return updateBlockGroupOutput;
376
+ }
377
+ function _UpdateParticleColorBlockGroup(inputParticle, colorGradients, context) {
378
+ let colorCalculation = undefined;
379
+ if (colorGradients && colorGradients.length > 0) {
380
+ if (context.colorGradientValue0Output === undefined) {
381
+ throw new Error("Initial color gradient values not found in context.");
382
+ }
383
+ context.ageToLifeTimeRatioBlockGroupOutput = _CreateAgeToLifeTimeRatioBlockGroup(context);
384
+ colorCalculation = _CreateGradientBlockGroup(context.ageToLifeTimeRatioBlockGroupOutput, colorGradients, ParticleRandomBlockLocks.OncePerParticle, "Color", [
385
+ context.colorGradientValue0Output,
386
+ ]);
387
+ }
388
+ else {
389
+ colorCalculation = _CreateBasicColorUpdate();
390
+ }
391
+ // Create the color update block clamping alpha >= 0
392
+ const colorUpdateBlock = new UpdateColorBlock("Color update");
393
+ inputParticle.connectTo(colorUpdateBlock.particle);
394
+ _ClampUpdateColorAlpha(colorCalculation).connectTo(colorUpdateBlock.color);
395
+ return colorUpdateBlock.output;
396
+ }
397
+ function _UpdateParticleAngleBlockGroup(inputParticle, oldSystem, context) {
398
+ // We will try to use gradients if they exist
399
+ // If not, we will try to use min/max angular speed
400
+ let angularSpeedCalculation = null;
401
+ if (oldSystem._angularSpeedGradients && oldSystem._angularSpeedGradients.length > 0) {
402
+ angularSpeedCalculation = _UpdateParticleAngularSpeedGradientBlockGroup(oldSystem._angularSpeedGradients, context);
403
+ }
404
+ else if (oldSystem.minAngularSpeed !== 0 || oldSystem.maxAngularSpeed !== 0) {
405
+ angularSpeedCalculation = _UpdateParticleAngularSpeedBlockGroup(oldSystem.minAngularSpeed, oldSystem.maxAngularSpeed);
406
+ }
407
+ // If we have an angular speed calculation, then update the angle
408
+ if (angularSpeedCalculation) {
409
+ // Create the angular speed delta
410
+ const angleSpeedDeltaOutput = _CreateDeltaModifiedInput("Angular Speed", angularSpeedCalculation);
411
+ // Add it to the angle
412
+ const addAngle = new ParticleMathBlock("Add Angular Speed to Angle");
413
+ addAngle.operation = ParticleMathBlockOperations.Add;
414
+ _CreateAndConnectContextualSource("Angle", NodeParticleContextualSources.Angle, addAngle.left);
415
+ angleSpeedDeltaOutput.connectTo(addAngle.right);
416
+ // Update the particle angle
417
+ const updateAngle = new UpdateAngleBlock("Angle Update with Angular Speed");
418
+ inputParticle.connectTo(updateAngle.particle);
419
+ addAngle.output.connectTo(updateAngle.angle);
420
+ return updateAngle.output;
421
+ }
422
+ else {
423
+ return inputParticle;
345
424
  }
346
- return outputUpdate;
347
425
  }
348
- function _UpdateParticleAngularSpeedBlockGroup(inputParticle, minAngularSpeed, maxAngularSpeed) {
426
+ function _UpdateParticleAngularSpeedGradientBlockGroup(angularSpeedGradients, context) {
427
+ context.ageToLifeTimeRatioBlockGroupOutput = _CreateAgeToLifeTimeRatioBlockGroup(context);
428
+ // Generate the gradient
429
+ const angularSpeedValueOutput = _CreateGradientBlockGroup(context.ageToLifeTimeRatioBlockGroupOutput, angularSpeedGradients, ParticleRandomBlockLocks.OncePerParticle, "Angular Speed");
430
+ return angularSpeedValueOutput;
431
+ }
432
+ function _UpdateParticleAngularSpeedBlockGroup(minAngularSpeed, maxAngularSpeed) {
349
433
  // Random value between for the angular speed of the particle
350
434
  const randomAngularSpeedBlock = new ParticleRandomBlock("Random Angular Speed");
435
+ randomAngularSpeedBlock.lockMode = ParticleRandomBlockLocks.OncePerParticle;
351
436
  _CreateAndConnectInput("Min Angular Speed", minAngularSpeed, randomAngularSpeedBlock.min);
352
437
  _CreateAndConnectInput("Max Angular Speed", maxAngularSpeed, randomAngularSpeedBlock.max);
353
- // Create the angular speed delta
354
- const angleSpeedDeltaOutput = _CreateDeltaModifiedInput("Angular Speed", randomAngularSpeedBlock.output);
355
- // Add it to the angle
356
- const addAngle = new ParticleMathBlock("Add Angular Speed to Angle");
357
- addAngle.operation = ParticleMathBlockOperations.Add;
358
- _CreateAndConnectContextualSource("Angle", NodeParticleContextualSources.Angle, addAngle.left);
359
- angleSpeedDeltaOutput.connectTo(addAngle.right);
360
- // Update the particle angle
361
- const updateAngle = new UpdateAngleBlock("Angle Update with Angular Speed");
362
- inputParticle.connectTo(updateAngle.particle);
363
- addAngle.output.connectTo(updateAngle.angle);
364
- return updateAngle.output;
438
+ return randomAngularSpeedBlock.output;
365
439
  }
366
440
  function _UpdateParticlePositionBlockGroup(inputParticle, isLocal) {
367
441
  // Update the particle position
@@ -409,90 +483,17 @@ function _UpdateParticleGravityBlockGroup(inputParticle, gravity) {
409
483
  addDirectionBlock.output.connectTo(updateDirection.direction);
410
484
  return updateDirection.output;
411
485
  }
412
- function _CreateColorUpdateBlock(oldSystem, createParticleBlock) {
413
- if (!oldSystem) {
414
- throw new Error("Invalid particle system");
415
- }
416
- // Calculate the color
417
- const colorGradients = oldSystem.getColorGradients();
418
- let colorBlock = null;
419
- if (colorGradients && colorGradients.length > 0) {
420
- colorBlock = _CreateGradientColorUpdate(oldSystem, colorGradients, createParticleBlock);
421
- }
422
- else {
423
- colorBlock = _CreateBasicColorUpdate(oldSystem, createParticleBlock);
424
- }
425
- // Clamp alpha >= 0
426
- const clampedColor = _ClampUpdateColorAlpha(colorBlock);
427
- // Create the color update block
428
- const colorUpdateBlock = new UpdateColorBlock("Color update");
429
- clampedColor.colorOut.connectTo(colorUpdateBlock.color);
430
- return colorUpdateBlock;
431
- }
432
- function _CreateGradientColorUpdate(oldSystem, gradient, createParticleBlock) {
433
- const colorGradientBlock = new ParticleGradientBlock("Color Gradient");
434
- _CreateAndConnectContextualSource("gradient", NodeParticleContextualSources.Age, colorGradientBlock.gradient);
435
- let tempColor = null;
436
- let colorStart = null;
437
- let colorEnd = null;
438
- for (let i = 0; i < gradient.length; i++) {
439
- const gradientStep = gradient[i];
440
- const gradientValueBlock = new ParticleGradientValueBlock("Color Gradient Value " + i);
441
- gradientValueBlock.reference = gradientStep.gradient;
442
- if (gradientStep.color2) {
443
- // Create a random between color1 and color2
444
- const randomColorBlock = new ParticleRandomBlock("Random Color for Gradient " + i);
445
- randomColorBlock.lockMode = ParticleRandomBlockLocks.PerSystem;
446
- _CreateAndConnectInput("Color 1", gradientStep.color1, randomColorBlock.min);
447
- _CreateAndConnectInput("Color 2", gradientStep.color2, randomColorBlock.max);
448
- randomColorBlock.output.connectTo(gradientValueBlock.value);
449
- tempColor = randomColorBlock;
450
- }
451
- else {
452
- // Single color
453
- const input = new ParticleInputBlock("Color " + i);
454
- input.value = gradientStep.color1;
455
- input.output.connectTo(gradientValueBlock.value);
456
- tempColor = input;
457
- }
458
- if (gradientStep.gradient === 0) {
459
- colorStart = tempColor;
460
- }
461
- else if (gradientStep.gradient === 1) {
462
- colorEnd = tempColor;
463
- }
464
- gradientValueBlock.output.connectTo(colorGradientBlock.inputs[i + 1]);
465
- }
466
- _UpdateCreateParticleColor(oldSystem, colorStart, colorEnd, createParticleBlock);
467
- return colorGradientBlock;
468
- }
469
- function _CreateBasicColorUpdate(oldSystem, createParticleBlock) {
486
+ function _CreateBasicColorUpdate() {
470
487
  const addColorBlock = new ParticleMathBlock("Add Color");
471
488
  addColorBlock.operation = ParticleMathBlockOperations.Add;
472
489
  _CreateAndConnectContextualSource("Color", NodeParticleContextualSources.Color, addColorBlock.left);
473
490
  _CreateAndConnectContextualSource("Scaled Color Step", NodeParticleContextualSources.ScaledColorStep, addColorBlock.right);
474
- _UpdateCreateParticleColor(oldSystem, null, null, createParticleBlock);
475
- return addColorBlock;
476
- }
477
- function _UpdateCreateParticleColor(oldSystem, colorStart, colorEnd, createParticleBlock) {
478
- if (colorStart === null) {
479
- colorStart = new ParticleInputBlock("Color Start");
480
- colorStart.value = oldSystem.color1;
481
- }
482
- if (colorEnd === null) {
483
- colorEnd = new ParticleInputBlock("Color End");
484
- colorEnd.value = oldSystem.color2;
485
- }
486
- const randomColorBlock = new ParticleRandomBlock("Random color");
487
- randomColorBlock.lockMode = ParticleRandomBlockLocks.PerParticle;
488
- colorStart.output.connectTo(randomColorBlock.min);
489
- colorEnd.output.connectTo(randomColorBlock.max);
490
- randomColorBlock.output.connectTo(createParticleBlock.color);
491
+ return addColorBlock.output;
491
492
  }
492
- function _ClampUpdateColorAlpha(colorBlock) {
493
+ function _ClampUpdateColorAlpha(colorCalculationOutput) {
493
494
  // Decompose color to clamp alpha
494
495
  const decomposeColorBlock = new ParticleConverterBlock("Decompose Color");
495
- colorBlock.outputs[0].connectTo(decomposeColorBlock.colorIn);
496
+ colorCalculationOutput.connectTo(decomposeColorBlock.colorIn);
496
497
  // Clamp alpha to be >= 0
497
498
  const maxAlphaBlock = new ParticleMathBlock("Alpha >= 0");
498
499
  maxAlphaBlock.operation = ParticleMathBlockOperations.Max;
@@ -502,7 +503,7 @@ function _ClampUpdateColorAlpha(colorBlock) {
502
503
  const composeColorBlock = new ParticleConverterBlock("Compose Color");
503
504
  decomposeColorBlock.xyzOut.connectTo(composeColorBlock.xyzIn);
504
505
  maxAlphaBlock.output.connectTo(composeColorBlock.wIn);
505
- return composeColorBlock;
506
+ return composeColorBlock.colorOut;
506
507
  }
507
508
  // ------------- UTILITY FUNCTIONS -------------
508
509
  function _CreateDeltaModifiedInput(name, value) {
@@ -639,17 +640,19 @@ function _CreateGradientBlockGroup(gradientSelector, gradientValues, randomLockM
639
640
  function _CreateGradientValueBlockGroup(gradientStep, randomLockMode, prefix, index) {
640
641
  const gradientValueBlock = new ParticleGradientValueBlock(prefix + " Gradient Value " + index);
641
642
  gradientValueBlock.reference = gradientStep.gradient;
642
- if (gradientStep.factor2 !== undefined) {
643
+ const value1 = gradientStep.factor1 ?? gradientStep.color1;
644
+ const value2 = gradientStep.factor2 ?? gradientStep.color2;
645
+ if (value2 !== undefined) {
643
646
  // Create a random between value1 and value2
644
647
  const randomBlock = new ParticleRandomBlock("Random Value " + index);
645
648
  randomBlock.lockMode = randomLockMode;
646
- _CreateAndConnectInput("Value 1", gradientStep.factor1, randomBlock.min);
647
- _CreateAndConnectInput("Value 2", gradientStep.factor2, randomBlock.max);
649
+ _CreateAndConnectInput("Value 1", value1, randomBlock.min);
650
+ _CreateAndConnectInput("Value 2", value2, randomBlock.max);
648
651
  randomBlock.output.connectTo(gradientValueBlock.value);
649
652
  }
650
653
  else {
651
654
  // Single value
652
- _CreateAndConnectInput("Value", gradientStep.factor1, gradientValueBlock.value);
655
+ _CreateAndConnectInput("Value", value1, gradientValueBlock.value);
653
656
  }
654
657
  return gradientValueBlock.output;
655
658
  }