@onerjs/core 8.30.7 → 8.30.9
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.
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/targetCamera.js +0 -4
- package/Cameras/targetCamera.js.map +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +19 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +35 -0
- package/Materials/shaderMaterial.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
- package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +4 -4
- package/Particles/Node/Blocks/systemBlock.js +8 -12
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +5 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +188 -27
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.function.d.ts +2 -2
- package/Particles/thinParticleSystem.function.js +2 -2
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -3
- package/scene.js +8 -7
- package/scene.js.map +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cylinderShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/cylinderShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAGjD;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAErD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QANR,gBAAW,GAAG,O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AW,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC;YACjF,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;YAC9D,MAAM,IAAI,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAE9C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cylinder shape.\r\n */\r\nexport class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _tempVector = Vector3.Zero();\r\n /**\r\n * Create a new CylinderShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"height\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"CylinderShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the height input component\r\n */\r\n public get height(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state);\r\n particle.position.subtractToRef(state.emitterPosition!, this._tempVector);\r\n\r\n this._tempVector.normalize();\r\n\r\n if (state.emitterInverseWorldMatrix) {\r\n Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);\r\n }\r\n\r\n const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._tempVector);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const height = this.height.getConnectedValue(state);\r\n const radiusRange = this.radiusRange.getConnectedValue(state);\r\n const radius = this.radius.getConnectedValue(state);\r\n const yPos = RandomRange(-height / 2, height / 2);\r\n const angle = RandomRange(0, 2 * Math.PI);\r\n\r\n const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CylinderShapeBlock\", CylinderShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"cylinderShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/cylinderShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;GAGG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAErD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QANR,gBAAW,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAQjC,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QACnF,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACtF,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,qCAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,aAAa,CAAC,qBAAqB,EAAE,qCAAqC,CAAC,KAAK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AE,IAAI,EAAE,IAAI,CAAC,CAAC;YACvD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a cylinder shape.\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\nexport class CylinderShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _tempVector = Vector3.Zero();\r\n /**\r\n * Create a new CylinderShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"height\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"CylinderShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the height input component\r\n */\r\n public get height(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[6];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n particle.position.subtractToRef(state.emitterPosition!, this._tempVector);\r\n this._tempVector.normalize();\r\n\r\n if (state.emitterInverseWorldMatrix) {\r\n Vector3.TransformNormalToRef(this._tempVector, state.emitterInverseWorldMatrix, this._tempVector);\r\n }\r\n\r\n const randY = RandomRange(-directionRandomizer / 2, directionRandomizer / 2);\r\n\r\n let angle = Math.atan2(this._tempVector.x, this._tempVector.z);\r\n angle += RandomRange(-Math.PI / 2, Math.PI / 2) * directionRandomizer;\r\n\r\n this._tempVector.y = randY; // set direction y to rand y to mirror normal of cylinder surface\r\n this._tempVector.x = Math.sin(angle);\r\n this._tempVector.z = Math.cos(angle);\r\n this._tempVector.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._tempVector);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const height = this.height.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n\r\n const yPos = RandomRange(-height / 2, height / 2);\r\n const angle = RandomRange(0, 2 * Math.PI);\r\n\r\n // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html\r\n const radiusDistribution = RandomRange((1 - radiusRange) * (1 - radiusRange), 1);\r\n const positionRadius = Math.sqrt(radiusDistribution) * radius;\r\n const xPos = positionRadius * Math.cos(angle);\r\n const zPos = positionRadius * Math.sin(angle);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CylinderShapeBlock\", CylinderShapeBlock);\r\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the local position data for the particle
|
|
3
|
+
* @param particle The particle to update
|
|
4
|
+
*/
|
|
5
|
+
export function _CreateLocalPositionData(particle) {
|
|
6
|
+
if (!particle._localPosition) {
|
|
7
|
+
particle._localPosition = particle.position.clone();
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
particle._localPosition.copyFrom(particle.position);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=emitters.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emitters.functions.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/emitters.functions.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAAkB;IACvD,IAAI,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC;QAC3B,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxD,CAAC;SAAM,CAAC;QACJ,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACxD,CAAC;AACL,CAAC","sourcesContent":["import type { Particle } from \"core/Particles/particle\";\r\n\r\n/**\r\n * Creates the local position data for the particle\r\n * @param particle The particle to update\r\n */\r\nexport function _CreateLocalPositionData(particle: Particle): void {\r\n if (!particle._localPosition) {\r\n particle._localPosition = particle.position.clone();\r\n } else {\r\n particle._localPosition.copyFrom(particle.position);\r\n }\r\n}\r\n"]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Mesh } from "../../../../Meshes/mesh.js";
|
|
2
1
|
import type { Nullable } from "../../../../types.js";
|
|
3
|
-
import {
|
|
2
|
+
import type { Mesh } from "../../../../Meshes/mesh.js";
|
|
4
3
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
5
4
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
6
5
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
6
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
7
7
|
/**
|
|
8
8
|
* Defines a block used to generate particle shape from mesh geometry data
|
|
9
9
|
*/
|
|
@@ -6,6 +6,7 @@ import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
|
6
6
|
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
7
7
|
import { TmpVectors, Vector3, Vector4 } from "../../../../Maths/math.vector.js";
|
|
8
8
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
9
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
9
10
|
/**
|
|
10
11
|
* Defines a block used to generate particle shape from mesh geometry data
|
|
11
12
|
*/
|
|
@@ -38,7 +39,7 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
38
39
|
/**
|
|
39
40
|
* Gets or sets a boolean indicating if the mesh normals should be used for particle direction
|
|
40
41
|
*/
|
|
41
|
-
this.useMeshNormalsForDirection =
|
|
42
|
+
this.useMeshNormalsForDirection = true;
|
|
42
43
|
/**
|
|
43
44
|
* Gets or sets a boolean indicating if the mesh colors should be used for particle color
|
|
44
45
|
*/
|
|
@@ -146,6 +147,8 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
146
147
|
particle._initialDirection = particle.direction.clone();
|
|
147
148
|
};
|
|
148
149
|
system._positionCreation.process = (particle) => {
|
|
150
|
+
state.particleContext = particle;
|
|
151
|
+
state.systemContext = system;
|
|
149
152
|
if (!this._indices || !this._positions) {
|
|
150
153
|
return;
|
|
151
154
|
}
|
|
@@ -175,6 +178,7 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
175
178
|
else {
|
|
176
179
|
Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix, particle.position);
|
|
177
180
|
}
|
|
181
|
+
_CreateLocalPositionData(particle);
|
|
178
182
|
if (this.useMeshNormalsForDirection && this._normals) {
|
|
179
183
|
Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);
|
|
180
184
|
Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/meshShapeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAEhE,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAI1G,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACtE,OAAO,EAAE,WAAW,EAAE,mDAAyC;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CAAC,CAAC,mBAAmB,CAAC,0BAA0B,CAAC;QACnF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACvD,CAAC;CACJ;AA5PU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC1G;AAM7B;IADN,sBAAsB,CAAC,2BAA2B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kEACxG;AAMnC;IADN,sBAAsB,CAAC,4BAA4B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC/G;AAM7B;IADN,sBAAsB,CAAC,aAAa,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kDAC1G;AA4O9B,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { FloatArray, IndicesArray, Nullable } from \"../../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { TmpVectors, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Defines a block used to generate particle shape from mesh geometry data\r\n */\r\nexport class MeshShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n private _indices: Nullable<IndicesArray> = null;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _storedNormal = Vector3.Zero();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh normals should be used for particle direction\r\n */\r\n @editableInPropertyPage(\"Use normals for direction\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshNormalsForDirection = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh colors should be used for particle color\r\n */\r\n @editableInPropertyPage(\"Use vertex color for color\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshColorForColor = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the coordinates should be in world space (local space by default)\r\n */\r\n @editableInPropertyPage(\"World space\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public worldSpace = false;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"MeshShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Remove stored data\r\n */\r\n public cleanData() {\r\n this._mesh = null;\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n if (!this._mesh && !this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n if (this._mesh) {\r\n this._cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n }\r\n\r\n if (!this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n this._indices = this._cachedVertexData.indices;\r\n this._positions = this._cachedVertexData.positions;\r\n this._normals = this._cachedVertexData.normals;\r\n this._colors = this._cachedVertexData.colors;\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n system._colorCreation.process = () => {};\r\n }\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._storedNormal);\r\n } else {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n return;\r\n }\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n if (!this._indices || !this._positions) {\r\n return;\r\n }\r\n\r\n const randomFaceIndex = 3 * ((Math.random() * (this._indices.length / 3)) | 0);\r\n const bu = Math.random();\r\n const bv = Math.random() * (1.0 - bu);\r\n const bw = 1.0 - bu - bv;\r\n\r\n const faceIndexA = this._indices[randomFaceIndex];\r\n const faceIndexB = this._indices[randomFaceIndex + 1];\r\n const faceIndexC = this._indices[randomFaceIndex + 2];\r\n const vertexA = TmpVectors.Vector3[0];\r\n const vertexB = TmpVectors.Vector3[1];\r\n const vertexC = TmpVectors.Vector3[2];\r\n const randomVertex = TmpVectors.Vector3[3];\r\n\r\n Vector3.FromArrayToRef(this._positions, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._positions, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._positions, faceIndexC * 3, vertexC);\r\n\r\n randomVertex.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n randomVertex.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n randomVertex.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n\r\n if (this.worldSpace && this.mesh) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, this.mesh.getWorldMatrix(), randomVertex);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._normals, faceIndexC * 3, vertexC);\r\n\r\n this._storedNormal.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n this._storedNormal.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n this._storedNormal.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n }\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n Vector4.FromArrayToRef(this._colors, faceIndexA * 4, TmpVectors.Vector4[0]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexB * 4, TmpVectors.Vector4[1]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexC * 4, TmpVectors.Vector4[2]);\r\n\r\n particle.color.copyFromFloats(\r\n bu * TmpVectors.Vector4[0].x + bv * TmpVectors.Vector4[1].x + bw * TmpVectors.Vector4[2].x,\r\n bu * TmpVectors.Vector4[0].y + bv * TmpVectors.Vector4[1].y + bw * TmpVectors.Vector4[2].y,\r\n bu * TmpVectors.Vector4[0].z + bv * TmpVectors.Vector4[1].z + bw * TmpVectors.Vector4[2].z,\r\n bu * TmpVectors.Vector4[0].w + bv * TmpVectors.Vector4[1].w + bw * TmpVectors.Vector4[2].w\r\n );\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\r\n }\r\n }\r\n\r\n serializationObject.useMeshNormalsForDirection = this.useMeshNormalsForDirection;\r\n serializationObject.useMeshColorForColor = this.useMeshColorForColor;\r\n serializationObject.worldSpace = this.worldSpace;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n this.useMeshNormalsForDirection = !!serializationObject.useMeshNormalsForDirection;\r\n this.useMeshColorForColor = !!serializationObject.useMeshColorForColor;\r\n this.worldSpace = !!serializationObject.worldSpace;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshShapeBlock\", MeshShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"meshShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/meshShapeBlock.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAC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EAAE,CAAC;kDAC1G;AAiP9B,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import type { FloatArray, IndicesArray, Nullable } from \"core/types\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport type { NodeParticleBuildState } from \"core/Particles/Node/nodeParticleBuildState\";\r\nimport type { NodeParticleConnectionPoint } from \"core/Particles/Node/nodeParticleBlockConnectionPoint\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeParticleBlock } from \"core/Particles/Node/nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { TmpVectors, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Defines a block used to generate particle shape from mesh geometry data\r\n */\r\nexport class MeshShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n private _indices: Nullable<IndicesArray> = null;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _storedNormal = Vector3.Zero();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh normals should be used for particle direction\r\n */\r\n @editableInPropertyPage(\"Use normals for direction\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshNormalsForDirection = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh colors should be used for particle color\r\n */\r\n @editableInPropertyPage(\"Use vertex color for color\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshColorForColor = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the coordinates should be in world space (local space by default)\r\n */\r\n @editableInPropertyPage(\"World space\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public worldSpace = false;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"MeshShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Remove stored data\r\n */\r\n public cleanData() {\r\n this._mesh = null;\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n if (!this._mesh && !this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n if (this._mesh) {\r\n this._cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n }\r\n\r\n if (!this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n this._indices = this._cachedVertexData.indices;\r\n this._positions = this._cachedVertexData.positions;\r\n this._normals = this._cachedVertexData.normals;\r\n this._colors = this._cachedVertexData.colors;\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n system._colorCreation.process = () => {};\r\n }\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n if (system.isLocal) {\r\n particle.direction.copyFrom(this._storedNormal);\r\n } else {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n return;\r\n }\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (!this._indices || !this._positions) {\r\n return;\r\n }\r\n\r\n const randomFaceIndex = 3 * ((Math.random() * (this._indices.length / 3)) | 0);\r\n const bu = Math.random();\r\n const bv = Math.random() * (1.0 - bu);\r\n const bw = 1.0 - bu - bv;\r\n\r\n const faceIndexA = this._indices[randomFaceIndex];\r\n const faceIndexB = this._indices[randomFaceIndex + 1];\r\n const faceIndexC = this._indices[randomFaceIndex + 2];\r\n const vertexA = TmpVectors.Vector3[0];\r\n const vertexB = TmpVectors.Vector3[1];\r\n const vertexC = TmpVectors.Vector3[2];\r\n const randomVertex = TmpVectors.Vector3[3];\r\n\r\n Vector3.FromArrayToRef(this._positions, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._positions, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._positions, faceIndexC * 3, vertexC);\r\n\r\n randomVertex.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n randomVertex.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n randomVertex.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n\r\n if (this.worldSpace && this.mesh) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, this.mesh.getWorldMatrix(), randomVertex);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n Vector3.FromArrayToRef(this._normals, faceIndexA * 3, vertexA);\r\n Vector3.FromArrayToRef(this._normals, faceIndexB * 3, vertexB);\r\n Vector3.FromArrayToRef(this._normals, faceIndexC * 3, vertexC);\r\n\r\n this._storedNormal.x = bu * vertexA.x + bv * vertexB.x + bw * vertexC.x;\r\n this._storedNormal.y = bu * vertexA.y + bv * vertexB.y + bw * vertexC.y;\r\n this._storedNormal.z = bu * vertexA.z + bv * vertexB.z + bw * vertexC.z;\r\n }\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n Vector4.FromArrayToRef(this._colors, faceIndexA * 4, TmpVectors.Vector4[0]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexB * 4, TmpVectors.Vector4[1]);\r\n Vector4.FromArrayToRef(this._colors, faceIndexC * 4, TmpVectors.Vector4[2]);\r\n\r\n particle.color.copyFromFloats(\r\n bu * TmpVectors.Vector4[0].x + bv * TmpVectors.Vector4[1].x + bw * TmpVectors.Vector4[2].x,\r\n bu * TmpVectors.Vector4[0].y + bv * TmpVectors.Vector4[1].y + bw * TmpVectors.Vector4[2].y,\r\n bu * TmpVectors.Vector4[0].z + bv * TmpVectors.Vector4[1].z + bw * TmpVectors.Vector4[2].z,\r\n bu * TmpVectors.Vector4[0].w + bv * TmpVectors.Vector4[1].w + bw * TmpVectors.Vector4[2].w\r\n );\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n if (this._mesh) {\r\n serializationObject.cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true).serialize();\r\n } else if (this._cachedVertexData) {\r\n serializationObject.cachedVertexData = this._cachedVertexData.serialize();\r\n }\r\n }\r\n\r\n serializationObject.useMeshNormalsForDirection = this.useMeshNormalsForDirection;\r\n serializationObject.useMeshColorForColor = this.useMeshColorForColor;\r\n serializationObject.worldSpace = this.worldSpace;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n if (serializationObject.cachedVertexData) {\r\n this._cachedVertexData = VertexData.Parse(serializationObject.cachedVertexData);\r\n }\r\n\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n this.useMeshNormalsForDirection = !!serializationObject.useMeshNormalsForDirection;\r\n this.useMeshColorForColor = !!serializationObject.useMeshColorForColor;\r\n this.worldSpace = !!serializationObject.worldSpace;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.MeshShapeBlock\", MeshShapeBlock);\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
2
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
-
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
3
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
4
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
/**
|
|
6
6
|
* Block used to provide a flow of particles emitted from a point.
|
|
7
7
|
*/
|
|
@@ -3,6 +3,7 @@ import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleB
|
|
|
3
3
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
4
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
6
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
6
7
|
/**
|
|
7
8
|
* Block used to provide a flow of particles emitted from a point.
|
|
8
9
|
*/
|
|
@@ -74,11 +75,12 @@ export class PointShapeBlock extends NodeParticleBlock {
|
|
|
74
75
|
system._positionCreation.process = (particle) => {
|
|
75
76
|
state.systemContext = system;
|
|
76
77
|
if (system.isLocal) {
|
|
77
|
-
particle.position.
|
|
78
|
+
particle.position.copyFromFloats(0, 0, 0);
|
|
78
79
|
}
|
|
79
80
|
else {
|
|
80
81
|
Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, state.emitterWorldMatrix, particle.position);
|
|
81
82
|
}
|
|
83
|
+
_CreateLocalPositionData(particle);
|
|
82
84
|
};
|
|
83
85
|
this.output._storedValue = system;
|
|
84
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/pointShapeBlock.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pointShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/pointShapeBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,iBAAiB;IAClD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QAC9G,IAAI,CAAC,aAAa,CAAC,YAAY,EAAE,qCAAqC,CAAC,OAAO,EAAE,IAAI,EA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D,MAAM,KAAK,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;YAEtD,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,8BAA8B,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC/G,CAAC;YAED,QAAQ,CAAC,iBAAiB,GAAG,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QAC5D,CAAC,CAAC;QAEF,MAAM,CAAC,iBAAiB,CAAC,OAAO,GAAG,CAAC,QAAkB,EAAE,EAAE;YACtD,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;YAC7B,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACvG,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a point.\r\n */\r\nexport class PointShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new PointShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"PointShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.systemContext = system;\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(0, 0, 0);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PointShapeBlock\", PointShapeBlock);\r\n"]}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
2
2
|
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
3
|
-
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
3
|
import type { IShapeBlock } from "./IShapeBlock.js";
|
|
4
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
5
5
|
/**
|
|
6
6
|
* Block used to provide a flow of particles emitted from a sphere shape.
|
|
7
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
7
8
|
*/
|
|
8
9
|
export declare class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {
|
|
10
|
+
/**
|
|
11
|
+
* Gets or sets a boolean indicating whether to emit in a hemispheric mode (top half of the sphere) or not
|
|
12
|
+
*/
|
|
13
|
+
isHemispheric: boolean;
|
|
9
14
|
/**
|
|
10
15
|
* Create a new SphereShapeBlock
|
|
11
16
|
* @param name defines the block name
|
|
@@ -32,6 +37,14 @@ export declare class SphereShapeBlock extends NodeParticleBlock implements IShap
|
|
|
32
37
|
* Gets the directionRandomizer input component
|
|
33
38
|
*/
|
|
34
39
|
get directionRandomizer(): NodeParticleConnectionPoint;
|
|
40
|
+
/**
|
|
41
|
+
* Gets the direction1 input component
|
|
42
|
+
*/
|
|
43
|
+
get direction1(): NodeParticleConnectionPoint;
|
|
44
|
+
/**
|
|
45
|
+
* Gets the direction2 input component
|
|
46
|
+
*/
|
|
47
|
+
get direction2(): NodeParticleConnectionPoint;
|
|
35
48
|
/**
|
|
36
49
|
* Gets the output component
|
|
37
50
|
*/
|
|
@@ -41,4 +54,6 @@ export declare class SphereShapeBlock extends NodeParticleBlock implements IShap
|
|
|
41
54
|
* @param state defines the build state
|
|
42
55
|
*/
|
|
43
56
|
_build(state: NodeParticleBuildState): void;
|
|
57
|
+
serialize(): any;
|
|
58
|
+
_deserialize(serializationObject: any): void;
|
|
44
59
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { __decorate } from "../../../../tslib.es6.js";
|
|
1
2
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
2
3
|
import { NodeParticleBlockConnectionPointTypes } from "../../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
3
4
|
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
4
5
|
import { Vector3 } from "../../../../Maths/math.vector.js";
|
|
5
6
|
import { RandomRange } from "../../../../Maths/math.scalar.functions.js";
|
|
7
|
+
import { _CreateLocalPositionData } from "./emitters.functions.js";
|
|
8
|
+
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
6
9
|
/**
|
|
7
10
|
* Block used to provide a flow of particles emitted from a sphere shape.
|
|
11
|
+
* DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.
|
|
8
12
|
*/
|
|
9
13
|
export class SphereShapeBlock extends NodeParticleBlock {
|
|
10
14
|
/**
|
|
@@ -13,10 +17,16 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
13
17
|
*/
|
|
14
18
|
constructor(name) {
|
|
15
19
|
super(name);
|
|
20
|
+
/**
|
|
21
|
+
* Gets or sets a boolean indicating whether to emit in a hemispheric mode (top half of the sphere) or not
|
|
22
|
+
*/
|
|
23
|
+
this.isHemispheric = false;
|
|
16
24
|
this.registerInput("particle", NodeParticleBlockConnectionPointTypes.Particle);
|
|
17
25
|
this.registerInput("radius", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
18
26
|
this.registerInput("radiusRange", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);
|
|
19
27
|
this.registerInput("directionRandomizer", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);
|
|
28
|
+
this.registerInput("direction1", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
29
|
+
this.registerInput("direction2", NodeParticleBlockConnectionPointTypes.Vector3, true);
|
|
20
30
|
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Particle);
|
|
21
31
|
}
|
|
22
32
|
/**
|
|
@@ -50,6 +60,18 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
50
60
|
get directionRandomizer() {
|
|
51
61
|
return this._inputs[3];
|
|
52
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the direction1 input component
|
|
65
|
+
*/
|
|
66
|
+
get direction1() {
|
|
67
|
+
return this._inputs[4];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Gets the direction2 input component
|
|
71
|
+
*/
|
|
72
|
+
get direction2() {
|
|
73
|
+
return this._inputs[5];
|
|
74
|
+
}
|
|
53
75
|
/**
|
|
54
76
|
* Gets the output component
|
|
55
77
|
*/
|
|
@@ -65,20 +87,36 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
65
87
|
system._directionCreation.process = (particle) => {
|
|
66
88
|
state.particleContext = particle;
|
|
67
89
|
state.systemContext = system;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
// We always use directionRandomizer unless both directions are connected
|
|
91
|
+
if (this.direction1.isConnected === false || this.direction2.isConnected === false) {
|
|
92
|
+
const directionRandomizer = this.directionRandomizer.getConnectedValue(state);
|
|
93
|
+
const direction = particle.position.subtract(state.emitterPosition).normalize();
|
|
94
|
+
const randX = RandomRange(0, directionRandomizer);
|
|
95
|
+
const randY = RandomRange(0, directionRandomizer);
|
|
96
|
+
const randZ = RandomRange(0, directionRandomizer);
|
|
97
|
+
direction.x += randX;
|
|
98
|
+
direction.y += randY;
|
|
99
|
+
direction.z += randZ;
|
|
100
|
+
direction.normalize();
|
|
101
|
+
if (system.isLocal) {
|
|
102
|
+
particle.direction.copyFromFloats(direction.x, direction.y, direction.z);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix, particle.direction);
|
|
106
|
+
}
|
|
79
107
|
}
|
|
80
108
|
else {
|
|
81
|
-
|
|
109
|
+
const direction1 = this.direction1.getConnectedValue(state);
|
|
110
|
+
const direction2 = this.direction2.getConnectedValue(state);
|
|
111
|
+
const randX = RandomRange(direction1.x, direction2.x);
|
|
112
|
+
const randY = RandomRange(direction1.y, direction2.y);
|
|
113
|
+
const randZ = RandomRange(direction1.z, direction2.z);
|
|
114
|
+
if (system.isLocal) {
|
|
115
|
+
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.direction);
|
|
119
|
+
}
|
|
82
120
|
}
|
|
83
121
|
particle._initialDirection = particle.direction.clone();
|
|
84
122
|
};
|
|
@@ -92,18 +130,33 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
92
130
|
const phi = RandomRange(0, 2 * Math.PI);
|
|
93
131
|
const theta = Math.acos(2 * v - 1);
|
|
94
132
|
const randX = randRadius * Math.cos(phi) * Math.sin(theta);
|
|
95
|
-
|
|
133
|
+
let randY = randRadius * Math.cos(theta);
|
|
96
134
|
const randZ = randRadius * Math.sin(phi) * Math.sin(theta);
|
|
135
|
+
if (this.isHemispheric) {
|
|
136
|
+
randY = Math.abs(randY);
|
|
137
|
+
}
|
|
97
138
|
if (system.isLocal) {
|
|
98
139
|
particle.position.copyFromFloats(randX, randY, randZ);
|
|
99
|
-
particle.position.addInPlace(state.emitterPosition);
|
|
100
140
|
}
|
|
101
141
|
else {
|
|
102
142
|
Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix, particle.position);
|
|
103
143
|
}
|
|
144
|
+
_CreateLocalPositionData(particle);
|
|
104
145
|
};
|
|
105
146
|
this.output._storedValue = system;
|
|
106
147
|
}
|
|
148
|
+
serialize() {
|
|
149
|
+
const serializationObject = super.serialize();
|
|
150
|
+
serializationObject.isHemispheric = this.isHemispheric;
|
|
151
|
+
return serializationObject;
|
|
152
|
+
}
|
|
153
|
+
_deserialize(serializationObject) {
|
|
154
|
+
super._deserialize(serializationObject);
|
|
155
|
+
this.isHemispheric = serializationObject.isHemispheric;
|
|
156
|
+
}
|
|
107
157
|
}
|
|
158
|
+
__decorate([
|
|
159
|
+
editableInPropertyPage("Is hemispheric", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
|
|
160
|
+
], SphereShapeBlock.prototype, "isHemispheric", void 0);
|
|
108
161
|
RegisterClass("BABYLON.SphereShapeBlock", SphereShapeBlock);
|
|
109
162
|
//# sourceMappingURL=sphereShapeBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1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GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAE3D,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;gBACtD,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,eAAgB,CAAC,CAAC;YACzD,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a sphere shape.\r\n */\r\nexport class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Create a new SphereShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SphereShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state);\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const radius = this.radius.getConnectedValue(state);\r\n const radiusRange = this.radiusRange.getConnectedValue(state);\r\n\r\n const randRadius = radius - RandomRange(0, radius * radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n const randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SphereShapeBlock\", SphereShapeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"sphereShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/sphereShapeBlock.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAA0B,gDAAsC;AAE/F;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,iBAAiB;IAOnD;;;OAGG;IACH,YAAmB,IAAY;QAC3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K,EAAE,KAAK,CAAC,CAAC;YAC1D,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;YAED,wBAAwB,CAAC,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;IAEe,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QAEvD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC;IAC3D,CAAC;CACJ;AAtKU;IADN,sBAAsB,CAAC,gBAAgB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;uDAC1G;AAwKjC,aAAa,CAAC,0BAA0B,EAAE,gBAAgB,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport { _CreateLocalPositionData } from \"./emitters.functions\";\r\nimport { editableInPropertyPage, PropertyTypeForEdition } from \"core/Decorators/nodeDecorator\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a sphere shape.\r\n * DirectionRandomizer will be used for the particles initial direction unless both direction1 and direction2 are connected.\r\n */\r\nexport class SphereShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n /**\r\n * Gets or sets a boolean indicating whether to emit in a hemispheric mode (top half of the sphere) or not\r\n */\r\n @editableInPropertyPage(\"Is hemispheric\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public isHemispheric = false;\r\n\r\n /**\r\n * Create a new SphereShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"radius\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"radiusRange\", NodeParticleBlockConnectionPointTypes.Float, true, 1, 0, 1);\r\n this.registerInput(\"directionRandomizer\", NodeParticleBlockConnectionPointTypes.Float, true, 0, 0, 1);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SphereShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the radius input component\r\n */\r\n public get radius(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the radiusRange input component\r\n */\r\n public get radiusRange(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the directionRandomizer input component\r\n */\r\n public get directionRandomizer(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n // We always use directionRandomizer unless both directions are connected\r\n if (this.direction1.isConnected === false || this.direction2.isConnected === false) {\r\n const directionRandomizer = this.directionRandomizer.getConnectedValue(state) as number;\r\n\r\n const direction = particle.position.subtract(state.emitterPosition!).normalize();\r\n const randX = RandomRange(0, directionRandomizer);\r\n const randY = RandomRange(0, directionRandomizer);\r\n const randZ = RandomRange(0, directionRandomizer);\r\n direction.x += randX;\r\n direction.y += randY;\r\n direction.z += randZ;\r\n direction.normalize();\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(direction.x, direction.y, direction.z);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n } else {\r\n const direction1 = this.direction1.getConnectedValue(state) as Vector3;\r\n const direction2 = this.direction2.getConnectedValue(state) as Vector3;\r\n\r\n const randX = RandomRange(direction1.x, direction2.x);\r\n const randY = RandomRange(direction1.y, direction2.y);\r\n const randZ = RandomRange(direction1.z, direction2.z);\r\n\r\n if (system.isLocal) {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n }\r\n }\r\n\r\n particle._initialDirection = particle.direction.clone();\r\n };\r\n\r\n system._positionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n const radius = this.radius.getConnectedValue(state) as number;\r\n const radiusRange = this.radiusRange.getConnectedValue(state) as number;\r\n\r\n const randRadius = radius - RandomRange(0, radius * radiusRange);\r\n const v = RandomRange(0, 1.0);\r\n const phi = RandomRange(0, 2 * Math.PI);\r\n const theta = Math.acos(2 * v - 1);\r\n const randX = randRadius * Math.cos(phi) * Math.sin(theta);\r\n let randY = randRadius * Math.cos(theta);\r\n const randZ = randRadius * Math.sin(phi) * Math.sin(theta);\r\n\r\n if (this.isHemispheric) {\r\n randY = Math.abs(randY);\r\n }\r\n\r\n if (system.isLocal) {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n } else {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n }\r\n\r\n _CreateLocalPositionData(particle);\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.isHemispheric = this.isHemispheric;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.isHemispheric = serializationObject.isHemispheric;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SphereShapeBlock\", SphereShapeBlock);\r\n"]}
|
|
@@ -94,6 +94,7 @@ export class ParticleInputBlock extends NodeParticleBlock {
|
|
|
94
94
|
case NodeParticleContextualSources.Direction:
|
|
95
95
|
case NodeParticleContextualSources.ScaledDirection:
|
|
96
96
|
case NodeParticleContextualSources.InitialDirection:
|
|
97
|
+
case NodeParticleContextualSources.LocalPositionUpdated:
|
|
97
98
|
this._type = NodeParticleBlockConnectionPointTypes.Vector3;
|
|
98
99
|
break;
|
|
99
100
|
case NodeParticleContextualSources.Color:
|