@onerjs/core 8.30.9 → 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 (47) 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/cameraMovement.d.ts +150 -0
  14. package/Cameras/cameraMovement.js +190 -0
  15. package/Cameras/cameraMovement.js.map +1 -0
  16. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
  17. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
  18. package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
  19. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
  20. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +1 -1
  21. package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
  22. package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
  23. package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
  24. package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
  25. package/Particles/Node/Blocks/index.d.ts +1 -0
  26. package/Particles/Node/Blocks/index.js +1 -0
  27. package/Particles/Node/Blocks/index.js.map +1 -1
  28. package/Particles/Node/Blocks/particleInputBlock.js +1 -0
  29. package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
  30. package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
  31. package/Particles/Node/Blocks/particleRandomBlock.js +32 -14
  32. package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
  33. package/Particles/Node/Blocks/systemBlock.d.ts +8 -0
  34. package/Particles/Node/Blocks/systemBlock.js +8 -0
  35. package/Particles/Node/Blocks/systemBlock.js.map +1 -1
  36. package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
  37. package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
  38. package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
  39. package/Particles/Node/nodeParticleBuildState.js +2 -0
  40. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  41. package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
  42. package/Particles/Node/nodeParticleSystemSet.helper.js +162 -47
  43. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  44. package/Particles/thinParticleSystem.d.ts +3 -3
  45. package/Particles/thinParticleSystem.js +3 -3
  46. package/Particles/thinParticleSystem.js.map +1 -1
  47. 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,8DAA8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AC,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,IAAI,CAAC;QAE1D;;WAEG;QACI,kBAAa,GAAW,CAAC,CAAC;QACjC;;WAEG;QACI,sBAAiB,GAAW,CAAC,CAAC;IA0KzC,CAAC;IApKG;;OAEG;I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eParticleConnectionPoint } 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>>;
@@ -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) {
@@ -44,27 +43,27 @@ export async function ConvertToNodeParticleSystemSetAsync(name, particleSystemsL
44
43
  }
45
44
  async function _ExtractDatafromParticleSystemAsync(newSet, oldSystem, context) {
46
45
  // CreateParticle block
47
- const createParticleBlock = _CreateCreateParticleBlockGroup(oldSystem, context);
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, context);
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, context) {
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
- const targetStopDurationOutput = _CreateTargetStopDurationInputBlock(oldSystem, context);
67
- targetStopDurationOutput.connectTo(newSystem.targetStopDuration);
66
+ _CreateTargetStopDurationInputBlock(oldSystem, context).connectTo(newSystem.targetStopDuration);
68
67
  newSystem.emitRate = oldSystem.emitRate;
69
68
  newSystem.manualEmitCount = oldSystem.manualEmitCount;
70
69
  newSystem.blendMode = oldSystem.blendMode;
@@ -88,47 +87,43 @@ function _CreateSystemBlock(oldSystem, context) {
88
87
  textureBlock.texture.connectTo(newSystem.texture);
89
88
  return newSystem;
90
89
  }
91
- // Create Particle Block Group functions
92
- function _CreateCreateParticleBlockGroup(oldSystem, context) {
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) {
93
94
  // Create particle
94
95
  const createParticleBlock = new CreateParticleBlock("Create Particle");
95
96
  // Lifetime
96
97
  _CreateParticleLifetimeBlockGroup(oldSystem, context).connectTo(createParticleBlock.lifeTime);
97
- // Size
98
- const randomSizeBlock = new ParticleRandomBlock("Random size");
99
- _CreateAndConnectInput("Min size", oldSystem.minSize, randomSizeBlock.min);
100
- _CreateAndConnectInput("Max size", oldSystem.maxSize, randomSizeBlock.max);
101
- randomSizeBlock.output.connectTo(createParticleBlock.size);
102
- // Scale
103
- const randomScaleBlock = new ParticleRandomBlock("Random Scale");
104
- _CreateAndConnectInput("Min Scale", new Vector2(oldSystem.minScaleX, oldSystem.minScaleY), randomScaleBlock.min);
105
- _CreateAndConnectInput("Max Scale", new Vector2(oldSystem.maxScaleX, oldSystem.maxScaleY), randomScaleBlock.max);
106
- randomScaleBlock.output.connectTo(createParticleBlock.scale);
107
- // Color is handled when we do the color update block to manage gradients
108
- // Dead color
109
- _CreateAndConnectInput("Dead Color", oldSystem.colorDead, createParticleBlock.colorDead);
110
98
  // Emit power (Speed)
111
99
  const randomEmitPowerBlock = new ParticleRandomBlock("Random Emit Power");
112
100
  _CreateAndConnectInput("Min Emit Power", oldSystem.minEmitPower, randomEmitPowerBlock.min);
113
101
  _CreateAndConnectInput("Max Emit Power", oldSystem.maxEmitPower, randomEmitPowerBlock.max);
114
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);
115
107
  // Angle (rotation)
116
108
  const randomRotationBlock = new ParticleRandomBlock("Random Rotation");
117
109
  _CreateAndConnectInput("Min Rotation", oldSystem.minInitialRotation, randomRotationBlock.min);
118
110
  _CreateAndConnectInput("Max Rotation", oldSystem.maxInitialRotation, randomRotationBlock.max);
119
111
  randomRotationBlock.output.connectTo(createParticleBlock.angle);
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);
120
115
  return createParticleBlock;
121
116
  }
122
117
  /**
123
118
  * Creates the group of blocks that represent the particle lifetime
124
- * @param oldSystem The old particle system to migrate
125
- * @param context The system migration context
119
+ * @param oldSystem The old particle system to convert
120
+ * @param context The context of the current conversion
126
121
  * @returns The output of the group of blocks that represent the particle lifetime
127
122
  */
128
123
  function _CreateParticleLifetimeBlockGroup(oldSystem, context) {
129
124
  if (oldSystem.targetStopDuration && oldSystem._lifeTimeGradients && oldSystem._lifeTimeGradients.length > 0) {
130
125
  context.timeToStopTimeRatioBlockGroupOutput = _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context);
131
- const gradientBlockGroupOutput = _CreateGradientBlockGroup(context.timeToStopTimeRatioBlockGroupOutput, oldSystem._lifeTimeGradients);
126
+ const gradientBlockGroupOutput = _CreateGradientBlockGroup(context.timeToStopTimeRatioBlockGroupOutput, oldSystem._lifeTimeGradients, ParticleRandomBlockLocks.PerParticle, "Lifetime");
132
127
  return gradientBlockGroupOutput;
133
128
  }
134
129
  else {
@@ -138,7 +133,70 @@ function _CreateParticleLifetimeBlockGroup(oldSystem, context) {
138
133
  return randomLifetimeBlock.output;
139
134
  }
140
135
  }
141
- function _CreateEmitterShapeBlock(oldSystem) {
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) {
142
200
  const emitter = oldSystem.particleEmitterType;
143
201
  if (!emitter) {
144
202
  throw new Error("Particle system has no emitter type.");
@@ -263,18 +321,31 @@ function _CreateEmitterShapeBlock(oldSystem) {
263
321
  }
264
322
  return shapeBlock;
265
323
  }
266
- 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) {
267
335
  let outputUpdate = inputParticle;
268
336
  if (oldSystem.minAngularSpeed !== 0 || oldSystem.maxAngularSpeed !== 0) {
269
- 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);
270
342
  }
271
- outputUpdate = _CreatePositionUpdate(outputUpdate, oldSystem.isLocal);
272
343
  if (oldSystem.gravity.equalsToFloats(0, 0, 0) === false) {
273
- outputUpdate = _CreateGravityUpdate(outputUpdate, oldSystem.gravity);
344
+ outputUpdate = _UpdateParticleGravityBlockGroup(outputUpdate, oldSystem.gravity);
274
345
  }
275
346
  return outputUpdate;
276
347
  }
277
- function _CreateAngularSpeedUpdate(inputParticle, minAngularSpeed, maxAngularSpeed) {
348
+ function _UpdateParticleAngularSpeedBlockGroup(inputParticle, minAngularSpeed, maxAngularSpeed) {
278
349
  // Random value between for the angular speed of the particle
279
350
  const randomAngularSpeedBlock = new ParticleRandomBlock("Random Angular Speed");
280
351
  _CreateAndConnectInput("Min Angular Speed", minAngularSpeed, randomAngularSpeedBlock.min);
@@ -292,7 +363,7 @@ function _CreateAngularSpeedUpdate(inputParticle, minAngularSpeed, maxAngularSpe
292
363
  addAngle.output.connectTo(updateAngle.angle);
293
364
  return updateAngle.output;
294
365
  }
295
- function _CreatePositionUpdate(inputParticle, isLocal) {
366
+ function _UpdateParticlePositionBlockGroup(inputParticle, isLocal) {
296
367
  // Update the particle position
297
368
  const updatePosition = new UpdatePositionBlock("Position Update");
298
369
  inputParticle.connectTo(updatePosition.particle);
@@ -309,7 +380,22 @@ function _CreatePositionUpdate(inputParticle, isLocal) {
309
380
  }
310
381
  return updatePosition.output;
311
382
  }
312
- 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) {
313
399
  // Create the gravity delta
314
400
  const gravityDeltaOutput = _CreateDeltaModifiedInput("Gravity", gravity);
315
401
  // Add it to the direction
@@ -418,6 +504,7 @@ function _ClampUpdateColorAlpha(colorBlock) {
418
504
  maxAlphaBlock.output.connectTo(composeColorBlock.wIn);
419
505
  return composeColorBlock;
420
506
  }
507
+ // ------------- UTILITY FUNCTIONS -------------
421
508
  function _CreateDeltaModifiedInput(name, value) {
422
509
  const multiplyBlock = new ParticleMathBlock("Multiply by Delta");
423
510
  multiplyBlock.operation = ParticleMathBlockOperations.Multiply;
@@ -448,8 +535,8 @@ function _CreateAndConnectSystemSource(systemBlockName, systemSource, targetToCo
448
535
  /**
449
536
  * Creates the target stop duration input block, as it can be shared in multiple places
450
537
  * This block is stored in the context so the same block is shared in the graph
451
- * @param oldSystem The old particle system to migrate
452
- * @param context The system migration context
538
+ * @param oldSystem The old particle system to convert
539
+ * @param context The context of the current conversion
453
540
  * @returns
454
541
  */
455
542
  function _CreateTargetStopDurationInputBlock(oldSystem, context) {
@@ -468,8 +555,8 @@ function _CreateTargetStopDurationInputBlock(oldSystem, context) {
468
555
  * Create a group of blocks that calculates the ratio between the actual frame and the target stop duration, clamped between 0 and 1.
469
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.
470
557
  * This block group is stored in the context so the same group is shared in the graph
471
- * @param oldSystem The old particle system to migrate
472
- * @param context The system migration context
558
+ * @param oldSystem The old particle system to convert
559
+ * @param context The context of the current conversion
473
560
  * @returns The ratio block output connection point
474
561
  */
475
562
  function _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context) {
@@ -497,19 +584,45 @@ function _CreateTimeToStopTimeRatioBlockGroup(oldSystem, context) {
497
584
  context.timeToStopTimeRatioBlockGroupOutput = clampMax.output;
498
585
  return context.timeToStopTimeRatioBlockGroupOutput;
499
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
+ }
500
601
  /**
501
602
  * Creates the blocks that represent a gradient
502
603
  * @param gradientSelector The value that determines which gradient to use
503
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
504
608
  * @returns The output connection point of the gradient block
505
609
  */
506
- function _CreateGradientBlockGroup(gradientSelector, gradientValues) {
610
+ function _CreateGradientBlockGroup(gradientSelector, gradientValues, randomLockMode, prefix, initialValues = []) {
507
611
  // Create the gradient block and connect the value that controls the gradient selection
508
- const gradientBlock = new ParticleGradientBlock("Gradient Block");
612
+ const gradientBlock = new ParticleGradientBlock(prefix + " Gradient Block");
509
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
+ }
510
623
  // Create the gradient values
511
- for (let i = 0; i < gradientValues.length; i++) {
512
- const gradientValueBlockGroupOutput = _CreateGradientValueBlockGroup(gradientValues[i], i);
624
+ for (let i = 0 + initialValues.length; i < gradientValues.length; i++) {
625
+ const gradientValueBlockGroupOutput = _CreateGradientValueBlockGroup(gradientValues[i], randomLockMode, prefix, i);
513
626
  gradientValueBlockGroupOutput.connectTo(gradientBlock.inputs[i + 1]);
514
627
  }
515
628
  return gradientBlock.output;
@@ -518,16 +631,18 @@ function _CreateGradientBlockGroup(gradientSelector, gradientValues) {
518
631
  * Creates the blocks that represent a gradient value
519
632
  * This can be either a single value or a random between two values
520
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
521
636
  * @param index The index of the gradient step
522
637
  * @returns The output connection point of the gradient value block
523
638
  */
524
- function _CreateGradientValueBlockGroup(gradientStep, index) {
525
- const gradientValueBlock = new ParticleGradientValueBlock("Gradient Value " + index);
639
+ function _CreateGradientValueBlockGroup(gradientStep, randomLockMode, prefix, index) {
640
+ const gradientValueBlock = new ParticleGradientValueBlock(prefix + " Gradient Value " + index);
526
641
  gradientValueBlock.reference = gradientStep.gradient;
527
642
  if (gradientStep.factor2 !== undefined) {
528
643
  // Create a random between value1 and value2
529
- const randomBlock = new ParticleRandomBlock("Random Gradient Value " + index);
530
- randomBlock.lockMode = ParticleRandomBlockLocks.PerParticle;
644
+ const randomBlock = new ParticleRandomBlock("Random Value " + index);
645
+ randomBlock.lockMode = randomLockMode;
531
646
  _CreateAndConnectInput("Value 1", gradientStep.factor1, randomBlock.min);
532
647
  _CreateAndConnectInput("Value 2", gradientStep.factor2, randomBlock.max);
533
648
  randomBlock.output.connectTo(gradientValueBlock.value);