@onerjs/core 8.27.2 → 8.27.4
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/Cameras/arcRotateCamera.js +7 -5
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/targetCamera.d.ts +12 -0
- package/Cameras/targetCamera.js +19 -5
- package/Cameras/targetCamera.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +7 -5
- package/Decorators/nodeDecorator.js +7 -5
- package/Decorators/nodeDecorator.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/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +3 -3
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +22 -22
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.d.ts +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js +8 -8
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +3 -3
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js +7 -7
- package/FrameGraph/Tasks/Rendering/taaObjectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +4 -0
- package/FrameGraph/frameGraph.js +8 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +10 -3
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTextureManager.d.ts +32 -2
- package/FrameGraph/frameGraphTextureManager.js +139 -9
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +4 -4
- package/Materials/Node/Blocks/conditionalBlock.js +1 -1
- package/Materials/Node/Blocks/curveBlock.js +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js +1 -1
- package/Materials/Node/Blocks/waveBlock.js +1 -1
- package/Materials/PBR/openPbrMaterial.d.ts +2 -0
- package/Materials/PBR/openPbrMaterial.js +3 -1
- package/Materials/PBR/openPbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.js +3 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/texture.js +13 -3
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +11 -6
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +3 -3
- package/Materials/materialHelper.functions.js +3 -3
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -0
- package/Materials/standardMaterial.js +3 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +17 -0
- package/Maths/math.vector.functions.js +27 -0
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/Node/Blocks/Set/aggregatorBlock.js +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryEaseBlock.js +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +1 -1
- package/Meshes/Node/Blocks/mappingBlock.js +1 -1
- package/Meshes/Node/Blocks/mathBlock.js +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +1 -1
- package/Meshes/abstractMesh.d.ts +4 -0
- package/Meshes/abstractMesh.js +7 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/screenshotTools.d.ts +63 -1
- package/Misc/screenshotTools.js +207 -4
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/textureTools.d.ts +6 -0
- package/Misc/textureTools.js +6 -1
- package/Misc/textureTools.js.map +1 -1
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +1 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleFresnelBlock.d.ts +34 -0
- package/Particles/Node/Blocks/particleFresnelBlock.js +74 -0
- package/Particles/Node/Blocks/particleFresnelBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js +2 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.d.ts +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.js +1 -1
- package/Particles/Node/Blocks/particleLerpBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleLocalVariableBlock.js +1 -1
- package/Particles/Node/Blocks/particleMathBlock.js +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.js +1 -1
- package/Particles/Node/Blocks/particleTrigonometryBlock.js +1 -1
- package/Particles/Node/Blocks/systemBlock.js +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/Enums/nodeParticleSystemSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleSystemSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleSystemSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +1 -1
- package/Particles/Node/nodeParticleBuildState.js +4 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/gpuParticleSystem.js +1 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +1 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +1 -1
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +2 -2
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +2 -2
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/node.js +4 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
|
@@ -92,6 +92,7 @@ export class CylinderShapeBlock extends NodeParticleBlock {
|
|
|
92
92
|
else {
|
|
93
93
|
particle.direction.copyFrom(this._tempVector);
|
|
94
94
|
}
|
|
95
|
+
particle._initialDirection = particle.direction.clone();
|
|
95
96
|
};
|
|
96
97
|
system._positionCreation.process = (particle) => {
|
|
97
98
|
state.particleContext = particle;
|
|
@@ -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,EA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AAM,GAAG,CAAC,CAAC,CAAC;YAClD,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;YAE1C,MAAM,kBAAkB,GAAG,WAAW,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,KAAK,CAAC,sBAAsB,EAAE,CAAC;gBAC/B,OAAO,CAAC,mCAAmC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;iBAAM,CAAC;gBACJ,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;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.isEmitterTransformNode) {\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFrom(this._tempVector);\r\n }\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n particle.position.addInPlace(state.emitterPosition!);\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":"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,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,CAA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AI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAChH,CAAC;iBAAM,CAAC;gBACJ,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;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.isEmitterTransformNode) {\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(this._tempVector.x, this._tempVector.y, this._tempVector.z, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFrom(this._tempVector);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(xPos, yPos, zPos);\r\n particle.position.addInPlace(state.emitterPosition!);\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"]}
|
|
@@ -143,6 +143,7 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
143
143
|
else {
|
|
144
144
|
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
145
145
|
}
|
|
146
|
+
particle._initialDirection = particle.direction.clone();
|
|
146
147
|
};
|
|
147
148
|
system._positionCreation.process = (particle) => {
|
|
148
149
|
if (!this._indices || !this._positions) {
|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AAa,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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFrom(this._storedNormal);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\r\n }\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\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":";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;AAG/D;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,iBAAiB;IAiCjD;;OAEG;IACH,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,IAAW,IAAI,CAAC,KAAqB;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QA/CR,sBAAiB,GAAyB,IAAI,CAAC;QAC/C,aAAQ,GAA2B,IAAI,CAAC;QACxC,eAAU,GAAyB,IAAI,CAAC;QACxC,aAAQ,GAAyB,IAAI,CAAC;QACtC,YAAO,GAAyB,IAAI,CAAC;QACrC,kBAAa,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;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AC;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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalToRef(this._storedNormal, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFrom(this._storedNormal);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randomVertex.x, randomVertex.y, randomVertex.z, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(randomVertex.x, randomVertex.y, randomVertex.z);\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"]}
|
|
@@ -69,6 +69,7 @@ export class PointShapeBlock extends NodeParticleBlock {
|
|
|
69
69
|
else {
|
|
70
70
|
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
71
71
|
}
|
|
72
|
+
particle._initialDirection = particle.direction.clone();
|
|
72
73
|
};
|
|
73
74
|
system._positionCreation.process = (particle) => {
|
|
74
75
|
state.systemContext = system;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/pointShapeBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAE1G,OAAO,EAAE,OAAO,EAAE,yCAA+B;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,mDAAyC;AAG/D;;GAEG;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,CAAC;QACL,CAAC,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;CACJ;AAED,aAAa,CAAC,yBAAyB,EAAE,eAAe,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Block used to provide a flow of particles emitted from a 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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(0, 0, 0, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFrom(state.emitterPosition!);\r\n }\r\n };\r\n\r\n this.output._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.PointShapeBlock\", PointShapeBlock);\r\n"]}
|
|
@@ -80,6 +80,7 @@ export class SphereShapeBlock extends NodeParticleBlock {
|
|
|
80
80
|
else {
|
|
81
81
|
particle.direction.copyFromFloats(randX, randY, randZ);
|
|
82
82
|
}
|
|
83
|
+
particle._initialDirection = particle.direction.clone();
|
|
83
84
|
};
|
|
84
85
|
system._positionCreation.process = (particle) => {
|
|
85
86
|
state.particleContext = particle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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C,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC3D,MAAM,KAAK,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC3C,MAAM,KAAK,GAAG,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAE3D,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC;gBAC/B,OAAO,CAAC,mCAAmC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,kBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnH,CAAC;iBAAM,CAAC;gBACJ,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;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 (state.isEmitterTransformNode) {\r\n Vector3.TransformNormalFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.direction);\r\n } else {\r\n particle.direction.copyFromFloats(randX, randY, randZ);\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 (state.isEmitterTransformNode) {\r\n Vector3.TransformCoordinatesFromFloatsToRef(randX, randY, randZ, state.emitterWorldMatrix!, particle.position);\r\n } else {\r\n particle.position.copyFromFloats(randX, randY, randZ);\r\n particle.position.addInPlace(state.emitterPosition!);\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"]}
|
|
@@ -31,4 +31,5 @@ export * from "./Conditions/particleConditionBlock.js";
|
|
|
31
31
|
export * from "./Triggers/particleTriggerBlock.js";
|
|
32
32
|
export * from "./particleLocalVariableBlock.js";
|
|
33
33
|
export * from "./particleVectorLengthBlock.js";
|
|
34
|
+
export * from "./particleFresnelBlock.js";
|
|
34
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./systemBlock\";\r\nexport * from \"./particleInputBlock\";\r\nexport * from \"./particleSourceTextureBlock\";\r\nexport * from \"./particleMathBlock\";\r\nexport * from \"./particleLerpBlock\";\r\nexport * from \"./Update/updateDirectionBlock\";\r\nexport * from \"./Update/updatePositionBlock\";\r\nexport * from \"./Update/updateColorBlock\";\r\nexport * from \"./Update/updateScaleBlock\";\r\nexport * from \"./Update/updateAngleBlock\";\r\nexport * from \"./Update/updateAgeBlock\";\r\nexport * from \"./Update/basicPositionUpdateBlock\";\r\nexport * from \"./Update/basicSpriteUpdateBlock\";\r\nexport * from \"./Update/basicColorUpdateBlock\";\r\nexport * from \"./Update/updateSpriteCellIndexBlock\";\r\nexport * from \"./Update/updateFlowMapBlock\";\r\nexport * from \"./Update/updateAttractorBlock\";\r\nexport * from \"./Update/alignAngleBlock\";\r\nexport * from \"./Emitters/index\";\r\nexport * from \"./particleGradientValueBlock\";\r\nexport * from \"./particleGradientBlock\";\r\nexport * from \"./particleConverterBlock\";\r\nexport * from \"./particleTrigonometryBlock\";\r\nexport * from \"./particleRandomBlock\";\r\nexport * from \"./particleDebugBlock\";\r\nexport * from \"./particleElbowBlock\";\r\nexport * from \"./Teleport/particleTeleportInBlock\";\r\nexport * from \"./Teleport/particleTeleportOutBlock\";\r\nexport * from \"./Conditions/particleConditionBlock\";\r\nexport * from \"./Triggers/particleTriggerBlock\";\r\nexport * from \"./particleLocalVariableBlock\";\r\nexport * from \"./particleVectorLengthBlock\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./systemBlock\";\r\nexport * from \"./particleInputBlock\";\r\nexport * from \"./particleSourceTextureBlock\";\r\nexport * from \"./particleMathBlock\";\r\nexport * from \"./particleLerpBlock\";\r\nexport * from \"./Update/updateDirectionBlock\";\r\nexport * from \"./Update/updatePositionBlock\";\r\nexport * from \"./Update/updateColorBlock\";\r\nexport * from \"./Update/updateScaleBlock\";\r\nexport * from \"./Update/updateAngleBlock\";\r\nexport * from \"./Update/updateAgeBlock\";\r\nexport * from \"./Update/basicPositionUpdateBlock\";\r\nexport * from \"./Update/basicSpriteUpdateBlock\";\r\nexport * from \"./Update/basicColorUpdateBlock\";\r\nexport * from \"./Update/updateSpriteCellIndexBlock\";\r\nexport * from \"./Update/updateFlowMapBlock\";\r\nexport * from \"./Update/updateAttractorBlock\";\r\nexport * from \"./Update/alignAngleBlock\";\r\nexport * from \"./Emitters/index\";\r\nexport * from \"./particleGradientValueBlock\";\r\nexport * from \"./particleGradientBlock\";\r\nexport * from \"./particleConverterBlock\";\r\nexport * from \"./particleTrigonometryBlock\";\r\nexport * from \"./particleRandomBlock\";\r\nexport * from \"./particleDebugBlock\";\r\nexport * from \"./particleElbowBlock\";\r\nexport * from \"./Teleport/particleTeleportInBlock\";\r\nexport * from \"./Teleport/particleTeleportOutBlock\";\r\nexport * from \"./Conditions/particleConditionBlock\";\r\nexport * from \"./Triggers/particleTriggerBlock\";\r\nexport * from \"./particleLocalVariableBlock\";\r\nexport * from \"./particleVectorLengthBlock\";\r\nexport * from \"./particleFresnelBlock\";\r\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
2
|
+
import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnectionPoint.js";
|
|
3
|
+
/**
|
|
4
|
+
* Block used to compute the fresnel term
|
|
5
|
+
*/
|
|
6
|
+
export declare class ParticleFresnelBlock extends NodeParticleBlock {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new ParticleFresnelBlock
|
|
9
|
+
* @param name defines the block name
|
|
10
|
+
*/
|
|
11
|
+
constructor(name: string);
|
|
12
|
+
/**
|
|
13
|
+
* Gets the current class name
|
|
14
|
+
* @returns the class name
|
|
15
|
+
*/
|
|
16
|
+
getClassName(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the view input component
|
|
19
|
+
*/
|
|
20
|
+
get view(): NodeParticleConnectionPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the normal input component
|
|
23
|
+
*/
|
|
24
|
+
get normal(): NodeParticleConnectionPoint;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the gradient operand input component
|
|
27
|
+
*/
|
|
28
|
+
get gradient(): NodeParticleConnectionPoint;
|
|
29
|
+
/**
|
|
30
|
+
* Gets the output component
|
|
31
|
+
*/
|
|
32
|
+
get output(): NodeParticleConnectionPoint;
|
|
33
|
+
_build(): void;
|
|
34
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
2
|
+
import { Vector3 } from "../../../Maths/math.vector.js";
|
|
3
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
4
|
+
import { NodeParticleBlockConnectionPointTypes } from "../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Block used to compute the fresnel term
|
|
7
|
+
*/
|
|
8
|
+
export class ParticleFresnelBlock extends NodeParticleBlock {
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new ParticleFresnelBlock
|
|
11
|
+
* @param name defines the block name
|
|
12
|
+
*/
|
|
13
|
+
constructor(name) {
|
|
14
|
+
super(name);
|
|
15
|
+
this.registerInput("view", NodeParticleBlockConnectionPointTypes.Vector3);
|
|
16
|
+
this.registerInput("normal", NodeParticleBlockConnectionPointTypes.Vector3);
|
|
17
|
+
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.Float);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets the current class name
|
|
21
|
+
* @returns the class name
|
|
22
|
+
*/
|
|
23
|
+
getClassName() {
|
|
24
|
+
return "ParticleFresnelBlock";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Gets the view input component
|
|
28
|
+
*/
|
|
29
|
+
get view() {
|
|
30
|
+
return this._inputs[0];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Gets the normal input component
|
|
34
|
+
*/
|
|
35
|
+
get normal() {
|
|
36
|
+
return this._inputs[1];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Gets the gradient operand input component
|
|
40
|
+
*/
|
|
41
|
+
get gradient() {
|
|
42
|
+
return this._inputs[2];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Gets the output component
|
|
46
|
+
*/
|
|
47
|
+
get output() {
|
|
48
|
+
return this._outputs[0];
|
|
49
|
+
}
|
|
50
|
+
_build() {
|
|
51
|
+
if (!this.view.isConnected || !this.normal.isConnected) {
|
|
52
|
+
this.output._storedFunction = null;
|
|
53
|
+
this.output._storedValue = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this.output._storedFunction = (state) => {
|
|
57
|
+
const view = this.view.getConnectedValue(state);
|
|
58
|
+
const normal = this.normal.getConnectedValue(state);
|
|
59
|
+
const f0 = 0.04; // base reflectance at normal incidence (e.g. 0.04 for dielectrics)
|
|
60
|
+
const nLen = normal.length();
|
|
61
|
+
const vLen = view.length();
|
|
62
|
+
// Guard against zero-length inputs
|
|
63
|
+
if (nLen < 1e-8 || vLen < 1e-8) {
|
|
64
|
+
return f0;
|
|
65
|
+
}
|
|
66
|
+
const cosTheta = Math.min(Math.max(Vector3.Dot(normal, view) / (nLen * vLen), 0.0), 1.0);
|
|
67
|
+
// Schlick approximation
|
|
68
|
+
const oneMinusCos = 1.0 - cosTheta;
|
|
69
|
+
return f0 + (1.0 - f0) * Math.pow(oneMinusCos, 5.0);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
RegisterClass("BABYLON.ParticleFresnelBlock", ParticleFresnelBlock);
|
|
74
|
+
//# sourceMappingURL=particleFresnelBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"particleFresnelBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleFresnelBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,sCAA+B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IACvD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,qCAAqC,CAAC,OAAO,CAAC,CAAC;QAC5E,IAAI,CAAC,cAAc,CAAC,QAAQ,EA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AC;YACd,CAAC;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;YAEzF,wBAAwB;YACxB,MAAM,WAAW,GAAG,GAAG,GAAG,QAAQ,CAAC;YACnC,OAAO,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QACxD,CAAC,CAAC;IACN,CAAC;CACJ;AAED,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\n\r\n/**\r\n * Block used to compute the fresnel term\r\n */\r\nexport class ParticleFresnelBlock extends NodeParticleBlock {\r\n /**\r\n * Creates a new ParticleFresnelBlock\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(\"view\", NodeParticleBlockConnectionPointTypes.Vector3);\r\n this.registerInput(\"normal\", NodeParticleBlockConnectionPointTypes.Vector3);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Float);\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 \"ParticleFresnelBlock\";\r\n }\r\n\r\n /**\r\n * Gets the view input component\r\n */\r\n public get view(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the normal input component\r\n */\r\n public get normal(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the gradient operand input component\r\n */\r\n public get gradient(): 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 public override _build() {\r\n if (!this.view.isConnected || !this.normal.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n this.output._storedFunction = (state) => {\r\n const view = this.view.getConnectedValue(state);\r\n const normal = this.normal.getConnectedValue(state);\r\n const f0 = 0.04; // base reflectance at normal incidence (e.g. 0.04 for dielectrics)\r\n\r\n const nLen = normal.length();\r\n const vLen = view.length();\r\n\r\n // Guard against zero-length inputs\r\n if (nLen < 1e-8 || vLen < 1e-8) {\r\n return f0;\r\n }\r\n\r\n const cosTheta = Math.min(Math.max(Vector3.Dot(normal, view) / (nLen * vLen), 0.0), 1.0);\r\n\r\n // Schlick approximation\r\n const oneMinusCos = 1.0 - cosTheta;\r\n return f0 + (1.0 - f0) * Math.pow(oneMinusCos, 5.0);\r\n };\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleFresnelBlock\", ParticleFresnelBlock);\r\n"]}
|
|
@@ -61,6 +61,7 @@ export class ParticleInputBlock extends NodeParticleBlock {
|
|
|
61
61
|
this._type = NodeParticleBlockConnectionPointTypes.Float;
|
|
62
62
|
break;
|
|
63
63
|
case NodeParticleSystemSources.Emitter:
|
|
64
|
+
case NodeParticleSystemSources.CameraPosition:
|
|
64
65
|
this._type = NodeParticleBlockConnectionPointTypes.Vector3;
|
|
65
66
|
break;
|
|
66
67
|
}
|
|
@@ -92,6 +93,7 @@ export class ParticleInputBlock extends NodeParticleBlock {
|
|
|
92
93
|
case NodeParticleContextualSources.Position:
|
|
93
94
|
case NodeParticleContextualSources.Direction:
|
|
94
95
|
case NodeParticleContextualSources.ScaledDirection:
|
|
96
|
+
case NodeParticleContextualSources.InitialDirection:
|
|
95
97
|
this._type = NodeParticleBlockConnectionPointTypes.Vector3;
|
|
96
98
|
break;
|
|
97
99
|
case NodeParticleContextualSources.Color:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particleInputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleInputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAsBrD;;OAEG;IACH,IAAW,IAAI;QACX,IAAI,IAAI,CAAC,KAAK,KAAK,qCAAqC,CAAC,UAAU,EAAE,CAAC;YAClE,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;oBACrB,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAC,KAAK,CAAC;oBACzD,OAAO,IAAI,CAAC,KAAK,CAAC;gBACtB,CAAC;gBAED,QAAQ,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,EAAE,CAAC;oBAChC,KAAK,SAAS;wBACV,IAAI,CAAC,KAAK,GAAG,qCAAqC,CAAC,OAAO,CAAC;wBA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AG,GAAG,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,GAAG,IAAI,CAAC,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,IAAI,EAAE,CAAC;QACnE,IAAI,mBAAmB,CAAC,kBAAkB,KAAK,SAAS,EAAE,CAAC;YACvD,IAAI,CAAC,kBAAkB,GAAG,mBAAmB,CAAC,kBAAkB,CAAC;QACrE,CAAC;QAED,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QAED,IAAI,mBAAmB,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC7C,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,KAAK,CAAC;QAClD,CAAC;aAAM,CAAC;YACJ,MAAM,SAAS,GAAG,QAAQ,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,SAAS,EAAE,CAAC;gBACZ,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,SAAS,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;YACvE,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { Observable } from \"../../../Misc/observable\";\r\nimport { GetClass, RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Matrix, Vector2, Vector3 } from \"../../../Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { NodeParticleContextualSources } from \"../Enums/nodeParticleContextualSources\";\r\nimport { NodeParticleSystemSources } from \"../Enums/nodeParticleSystemSources\";\r\n\r\n/**\r\n * Block used to expose an input value\r\n */\r\nexport class ParticleInputBlock extends NodeParticleBlock {\r\n private _storedValue: any;\r\n private _valueCallback: () => any;\r\n private _type: NodeParticleBlockConnectionPointTypes = NodeParticleBlockConnectionPointTypes.Undefined;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public min: number = 0;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public max: number = 0;\r\n\r\n /** Gets or sets the group to use to display this block in the Inspector */\r\n public groupInInspector = \"\";\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this input is displayed in the Inspector\r\n */\r\n public displayInInspector = true;\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<ParticleInputBlock>();\r\n\r\n /**\r\n * Gets or sets the connection point type (default is float)\r\n */\r\n public get type(): NodeParticleBlockConnectionPointTypes {\r\n if (this._type === NodeParticleBlockConnectionPointTypes.AutoDetect) {\r\n if (this.value != null) {\r\n if (!isNaN(this.value)) {\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n return this._type;\r\n }\r\n\r\n switch (this.value.getClassName()) {\r\n case \"Vector2\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector2;\r\n return this._type;\r\n case \"Vector3\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n return this._type;\r\n case \"Color4\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Color4;\r\n return this._type;\r\n case \"Matrix\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Matrix;\r\n return this._type;\r\n }\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n /** @internal */\r\n private _systemSource: NodeParticleSystemSources = NodeParticleSystemSources.None;\r\n\r\n /**\r\n * Gets a boolean indicating that the current connection point is a system source\r\n */\r\n public get isSystemSource(): boolean {\r\n return this._contextualSource === NodeParticleContextualSources.None && this._systemSource !== NodeParticleSystemSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the system source used by this input block\r\n */\r\n public get systemSource(): NodeParticleSystemSources {\r\n return this._systemSource;\r\n }\r\n\r\n public set systemSource(value: NodeParticleSystemSources) {\r\n this._systemSource = value;\r\n\r\n if (value !== NodeParticleSystemSources.None) {\r\n this._contextualSource = NodeParticleContextualSources.None;\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n\r\n switch (value) {\r\n case NodeParticleSystemSources.Time:\r\n case NodeParticleSystemSources.Delta:\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n break;\r\n case NodeParticleSystemSources.Emitter:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n }\r\n\r\n private _contextualSource = NodeParticleContextualSources.None;\r\n /**\r\n * Gets a boolean indicating that the current connection point is a contextual value\r\n */\r\n public get isContextual(): boolean {\r\n return this._contextualSource !== NodeParticleContextualSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the current contextual value\r\n */\r\n public get contextualValue(): NodeParticleContextualSources {\r\n return this._contextualSource;\r\n }\r\n\r\n public set contextualValue(value: NodeParticleContextualSources) {\r\n this._contextualSource = value;\r\n\r\n if (value !== NodeParticleContextualSources.None) {\r\n this._systemSource = NodeParticleSystemSources.None;\r\n\r\n switch (value) {\r\n case NodeParticleContextualSources.Scale:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector2;\r\n break;\r\n case NodeParticleContextualSources.Position:\r\n case NodeParticleContextualSources.Direction:\r\n case NodeParticleContextualSources.ScaledDirection:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n break;\r\n case NodeParticleContextualSources.Color:\r\n case NodeParticleContextualSources.InitialColor:\r\n case NodeParticleContextualSources.ColorDead:\r\n this._type = NodeParticleBlockConnectionPointTypes.Color4;\r\n break;\r\n case NodeParticleContextualSources.Age:\r\n case NodeParticleContextualSources.Lifetime:\r\n case NodeParticleContextualSources.Angle:\r\n case NodeParticleContextualSources.AgeGradient:\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n break;\r\n case NodeParticleContextualSources.SpriteCellEnd:\r\n case NodeParticleContextualSources.SpriteCellStart:\r\n case NodeParticleContextualSources.SpriteCellIndex:\r\n this._type = NodeParticleBlockConnectionPointTypes.Int;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new InputBlock\r\n * @param name defines the block name\r\n * @param type defines the type of the input (can be set to NodeParticleBlockConnectionPointTypes.AutoDetect)\r\n */\r\n public constructor(name: string, type: NodeParticleBlockConnectionPointTypes = NodeParticleBlockConnectionPointTypes.AutoDetect) {\r\n super(name);\r\n\r\n this._type = type;\r\n this._isInput = true;\r\n this._storedValue = null;\r\n\r\n this.setDefaultValue();\r\n\r\n this.registerOutput(\"output\", type);\r\n }\r\n\r\n /**\r\n * Gets or sets the value of that point.\r\n * Please note that this value will be ignored if valueCallback is defined\r\n */\r\n public get value(): any {\r\n return this._storedValue;\r\n }\r\n\r\n public set value(value: any) {\r\n if (this.type === NodeParticleBlockConnectionPointTypes.Float) {\r\n if (this.min !== this.max) {\r\n value = Math.max(this.min, value);\r\n value = Math.min(this.max, value);\r\n }\r\n }\r\n\r\n this._storedValue = value;\r\n\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets a callback used to get the value of that point.\r\n * Please note that setting this value will force the connection point to ignore the value property\r\n */\r\n public get valueCallback(): () => any {\r\n return this._valueCallback;\r\n }\r\n\r\n public set valueCallback(value: () => any) {\r\n this._valueCallback = value;\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 \"ParticleInputBlock\";\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 * Set the input block to its default value (based on its type)\r\n */\r\n public setDefaultValue() {\r\n switch (this.type) {\r\n case NodeParticleBlockConnectionPointTypes.Int:\r\n case NodeParticleBlockConnectionPointTypes.Float:\r\n this.value = 0;\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Vector2:\r\n this.value = Vector2.Zero();\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Vector3:\r\n this.value = Vector3.Zero();\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Color4:\r\n this.value = new Color4(1, 1, 1, 1);\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Matrix:\r\n this.value = Matrix.Identity();\r\n break;\r\n }\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n super._build(state);\r\n\r\n if (this.isSystemSource) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getSystemValue(this._systemSource);\r\n };\r\n } else if (this.isContextual) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getContextualValue(this._contextualSource);\r\n };\r\n } else {\r\n this.output._storedValue = this.value;\r\n // As a function to let the user dynamically change the value at runtime\r\n this.output._storedFunction = () => {\r\n return this.value;\r\n };\r\n }\r\n }\r\n\r\n public override dispose() {\r\n this.onValueChangedObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.type = this.type;\r\n serializationObject.contextualValue = this.contextualValue;\r\n serializationObject.systemSource = this.systemSource;\r\n serializationObject.min = this.min;\r\n serializationObject.max = this.max;\r\n serializationObject.groupInInspector = this.groupInInspector;\r\n serializationObject.displayInInspector = this.displayInInspector;\r\n\r\n if (this._storedValue !== null && !this.isContextual && !this.isSystemSource) {\r\n if (this._storedValue.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this._storedValue.getClassName();\r\n serializationObject.value = this._storedValue.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this._storedValue;\r\n }\r\n }\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._type = serializationObject.type;\r\n this.contextualValue = serializationObject.contextualValue;\r\n this.systemSource = serializationObject.systemSource || NodeParticleSystemSources.None;\r\n\r\n this.min = serializationObject.min || 0;\r\n this.max = serializationObject.max || 0;\r\n this.groupInInspector = serializationObject.groupInInspector || \"\";\r\n if (serializationObject.displayInInspector !== undefined) {\r\n this.displayInInspector = serializationObject.displayInInspector;\r\n }\r\n\r\n if (!serializationObject.valueType) {\r\n return;\r\n }\r\n\r\n if (serializationObject.valueType === \"number\") {\r\n this._storedValue = serializationObject.value;\r\n } else {\r\n const valueType = GetClass(serializationObject.valueType);\r\n\r\n if (valueType) {\r\n this._storedValue = valueType.FromArray(serializationObject.value);\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleInputBlock\", ParticleInputBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"particleInputBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleInputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AAGvG,OAAO,EAAE,MAAM,EAAE,qCAA8B;AAC/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,wCAAwC,CAAC;AACvF,OAAO,EAAE,yBAAyB,EAAE,MAAM,oCAAoC,CAAC;AAE/E;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,iBAAiB;IAsBrD;;OAEG;IACH,IAAW,IAAI;QACX,IA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C;YACvE,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,4BAA4B,EAAE,kBAAkB,CAAC,CAAC","sourcesContent":["import { Observable } from \"../../../Misc/observable\";\r\nimport { GetClass, RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { Matrix, Vector2, Vector3 } from \"../../../Maths/math.vector\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { NodeParticleContextualSources } from \"../Enums/nodeParticleContextualSources\";\r\nimport { NodeParticleSystemSources } from \"../Enums/nodeParticleSystemSources\";\r\n\r\n/**\r\n * Block used to expose an input value\r\n */\r\nexport class ParticleInputBlock extends NodeParticleBlock {\r\n private _storedValue: any;\r\n private _valueCallback: () => any;\r\n private _type: NodeParticleBlockConnectionPointTypes = NodeParticleBlockConnectionPointTypes.Undefined;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public min: number = 0;\r\n\r\n /** Gets or set a value used to limit the range of float values */\r\n public max: number = 0;\r\n\r\n /** Gets or sets the group to use to display this block in the Inspector */\r\n public groupInInspector = \"\";\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this input is displayed in the Inspector\r\n */\r\n public displayInInspector = true;\r\n\r\n /** Gets an observable raised when the value is changed */\r\n public onValueChangedObservable = new Observable<ParticleInputBlock>();\r\n\r\n /**\r\n * Gets or sets the connection point type (default is float)\r\n */\r\n public get type(): NodeParticleBlockConnectionPointTypes {\r\n if (this._type === NodeParticleBlockConnectionPointTypes.AutoDetect) {\r\n if (this.value != null) {\r\n if (!isNaN(this.value)) {\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n return this._type;\r\n }\r\n\r\n switch (this.value.getClassName()) {\r\n case \"Vector2\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector2;\r\n return this._type;\r\n case \"Vector3\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n return this._type;\r\n case \"Color4\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Color4;\r\n return this._type;\r\n case \"Matrix\":\r\n this._type = NodeParticleBlockConnectionPointTypes.Matrix;\r\n return this._type;\r\n }\r\n }\r\n }\r\n\r\n return this._type;\r\n }\r\n\r\n /** @internal */\r\n private _systemSource: NodeParticleSystemSources = NodeParticleSystemSources.None;\r\n\r\n /**\r\n * Gets a boolean indicating that the current connection point is a system source\r\n */\r\n public get isSystemSource(): boolean {\r\n return this._contextualSource === NodeParticleContextualSources.None && this._systemSource !== NodeParticleSystemSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the system source used by this input block\r\n */\r\n public get systemSource(): NodeParticleSystemSources {\r\n return this._systemSource;\r\n }\r\n\r\n public set systemSource(value: NodeParticleSystemSources) {\r\n this._systemSource = value;\r\n\r\n if (value !== NodeParticleSystemSources.None) {\r\n this._contextualSource = NodeParticleContextualSources.None;\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n\r\n switch (value) {\r\n case NodeParticleSystemSources.Time:\r\n case NodeParticleSystemSources.Delta:\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n break;\r\n case NodeParticleSystemSources.Emitter:\r\n case NodeParticleSystemSources.CameraPosition:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n }\r\n\r\n private _contextualSource = NodeParticleContextualSources.None;\r\n /**\r\n * Gets a boolean indicating that the current connection point is a contextual value\r\n */\r\n public get isContextual(): boolean {\r\n return this._contextualSource !== NodeParticleContextualSources.None;\r\n }\r\n\r\n /**\r\n * Gets or sets the current contextual value\r\n */\r\n public get contextualValue(): NodeParticleContextualSources {\r\n return this._contextualSource;\r\n }\r\n\r\n public set contextualValue(value: NodeParticleContextualSources) {\r\n this._contextualSource = value;\r\n\r\n if (value !== NodeParticleContextualSources.None) {\r\n this._systemSource = NodeParticleSystemSources.None;\r\n\r\n switch (value) {\r\n case NodeParticleContextualSources.Scale:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector2;\r\n break;\r\n case NodeParticleContextualSources.Position:\r\n case NodeParticleContextualSources.Direction:\r\n case NodeParticleContextualSources.ScaledDirection:\r\n case NodeParticleContextualSources.InitialDirection:\r\n this._type = NodeParticleBlockConnectionPointTypes.Vector3;\r\n break;\r\n case NodeParticleContextualSources.Color:\r\n case NodeParticleContextualSources.InitialColor:\r\n case NodeParticleContextualSources.ColorDead:\r\n this._type = NodeParticleBlockConnectionPointTypes.Color4;\r\n break;\r\n case NodeParticleContextualSources.Age:\r\n case NodeParticleContextualSources.Lifetime:\r\n case NodeParticleContextualSources.Angle:\r\n case NodeParticleContextualSources.AgeGradient:\r\n this._type = NodeParticleBlockConnectionPointTypes.Float;\r\n break;\r\n case NodeParticleContextualSources.SpriteCellEnd:\r\n case NodeParticleContextualSources.SpriteCellStart:\r\n case NodeParticleContextualSources.SpriteCellIndex:\r\n this._type = NodeParticleBlockConnectionPointTypes.Int;\r\n break;\r\n }\r\n\r\n if (this.output) {\r\n this.output.type = this._type;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a new InputBlock\r\n * @param name defines the block name\r\n * @param type defines the type of the input (can be set to NodeParticleBlockConnectionPointTypes.AutoDetect)\r\n */\r\n public constructor(name: string, type: NodeParticleBlockConnectionPointTypes = NodeParticleBlockConnectionPointTypes.AutoDetect) {\r\n super(name);\r\n\r\n this._type = type;\r\n this._isInput = true;\r\n this._storedValue = null;\r\n\r\n this.setDefaultValue();\r\n\r\n this.registerOutput(\"output\", type);\r\n }\r\n\r\n /**\r\n * Gets or sets the value of that point.\r\n * Please note that this value will be ignored if valueCallback is defined\r\n */\r\n public get value(): any {\r\n return this._storedValue;\r\n }\r\n\r\n public set value(value: any) {\r\n if (this.type === NodeParticleBlockConnectionPointTypes.Float) {\r\n if (this.min !== this.max) {\r\n value = Math.max(this.min, value);\r\n value = Math.min(this.max, value);\r\n }\r\n }\r\n\r\n this._storedValue = value;\r\n\r\n this.onValueChangedObservable.notifyObservers(this);\r\n }\r\n\r\n /**\r\n * Gets or sets a callback used to get the value of that point.\r\n * Please note that setting this value will force the connection point to ignore the value property\r\n */\r\n public get valueCallback(): () => any {\r\n return this._valueCallback;\r\n }\r\n\r\n public set valueCallback(value: () => any) {\r\n this._valueCallback = value;\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 \"ParticleInputBlock\";\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 * Set the input block to its default value (based on its type)\r\n */\r\n public setDefaultValue() {\r\n switch (this.type) {\r\n case NodeParticleBlockConnectionPointTypes.Int:\r\n case NodeParticleBlockConnectionPointTypes.Float:\r\n this.value = 0;\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Vector2:\r\n this.value = Vector2.Zero();\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Vector3:\r\n this.value = Vector3.Zero();\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Color4:\r\n this.value = new Color4(1, 1, 1, 1);\r\n break;\r\n case NodeParticleBlockConnectionPointTypes.Matrix:\r\n this.value = Matrix.Identity();\r\n break;\r\n }\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n super._build(state);\r\n\r\n if (this.isSystemSource) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getSystemValue(this._systemSource);\r\n };\r\n } else if (this.isContextual) {\r\n this.output._storedValue = null;\r\n this.output._storedFunction = (state) => {\r\n return state.getContextualValue(this._contextualSource);\r\n };\r\n } else {\r\n this.output._storedValue = this.value;\r\n // As a function to let the user dynamically change the value at runtime\r\n this.output._storedFunction = () => {\r\n return this.value;\r\n };\r\n }\r\n }\r\n\r\n public override dispose() {\r\n this.onValueChangedObservable.clear();\r\n\r\n super.dispose();\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.type = this.type;\r\n serializationObject.contextualValue = this.contextualValue;\r\n serializationObject.systemSource = this.systemSource;\r\n serializationObject.min = this.min;\r\n serializationObject.max = this.max;\r\n serializationObject.groupInInspector = this.groupInInspector;\r\n serializationObject.displayInInspector = this.displayInInspector;\r\n\r\n if (this._storedValue !== null && !this.isContextual && !this.isSystemSource) {\r\n if (this._storedValue.asArray) {\r\n serializationObject.valueType = \"BABYLON.\" + this._storedValue.getClassName();\r\n serializationObject.value = this._storedValue.asArray();\r\n } else {\r\n serializationObject.valueType = \"number\";\r\n serializationObject.value = this._storedValue;\r\n }\r\n }\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._type = serializationObject.type;\r\n this.contextualValue = serializationObject.contextualValue;\r\n this.systemSource = serializationObject.systemSource || NodeParticleSystemSources.None;\r\n\r\n this.min = serializationObject.min || 0;\r\n this.max = serializationObject.max || 0;\r\n this.groupInInspector = serializationObject.groupInInspector || \"\";\r\n if (serializationObject.displayInInspector !== undefined) {\r\n this.displayInInspector = serializationObject.displayInInspector;\r\n }\r\n\r\n if (!serializationObject.valueType) {\r\n return;\r\n }\r\n\r\n if (serializationObject.valueType === \"number\") {\r\n this._storedValue = serializationObject.value;\r\n } else {\r\n const valueType = GetClass(serializationObject.valueType);\r\n\r\n if (valueType) {\r\n this._storedValue = valueType.FromArray(serializationObject.value);\r\n }\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleInputBlock\", ParticleInputBlock);\r\n"]}
|
|
@@ -5,7 +5,7 @@ import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnection
|
|
|
5
5
|
*/
|
|
6
6
|
export declare class ParticleLerpBlock extends NodeParticleBlock {
|
|
7
7
|
/**
|
|
8
|
-
* Creates a new
|
|
8
|
+
* Creates a new ParticleLerpBlock
|
|
9
9
|
* @param name defines the block name
|
|
10
10
|
*/
|
|
11
11
|
constructor(name: string);
|
|
@@ -8,7 +8,7 @@ import { Color4 } from "../../../Maths/math.color.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export class ParticleLerpBlock extends NodeParticleBlock {
|
|
10
10
|
/**
|
|
11
|
-
* Creates a new
|
|
11
|
+
* Creates a new ParticleLerpBlock
|
|
12
12
|
* @param name defines the block name
|
|
13
13
|
*/
|
|
14
14
|
constructor(name) {
|