@onerjs/core 8.23.11 → 8.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/index.d.ts +1 -0
- package/Behaviors/Meshes/index.js +1 -0
- package/Behaviors/Meshes/index.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +6 -34
- package/Behaviors/Meshes/pointerDragBehavior.js +0 -12
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragEvents.d.ts +38 -0
- package/Behaviors/Meshes/pointerDragEvents.js +2 -0
- package/Behaviors/Meshes/pointerDragEvents.js.map +1 -0
- package/Buffers/storageBuffer.d.ts +6 -0
- package/Buffers/storageBuffer.js +8 -0
- package/Buffers/storageBuffer.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/Extensions/engine.multiRender.js +12 -7
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.multiview.js +5 -5
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +12 -7
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js +9 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +3 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +4 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/engineFactory.d.ts +4 -1
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.js +2 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +2 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +17 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +7 -0
- package/Engines/webgpuEngine.js +19 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +12 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +52 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +0 -3
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -2
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +4 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +7 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +11 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +6 -6
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +27 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +76 -8
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +2 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +0 -7
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.js +1 -1
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -2
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js +2 -2
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +7 -6
- package/Gizmos/positionGizmo.js +3 -9
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +7 -6
- package/Gizmos/rotationGizmo.js +3 -9
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +7 -6
- package/Gizmos/scaleGizmo.js +3 -9
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.d.ts +2 -0
- package/Instrumentation/sceneInstrumentation.js +58 -32
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +102 -0
- package/Lights/Clustered/clusteredLightContainer.js +487 -0
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.d.ts +34 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js +47 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js.map +1 -0
- package/Lights/Clustered/index.d.ts +6 -0
- package/Lights/Clustered/index.js +7 -0
- package/Lights/Clustered/index.js.map +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +10 -8
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Lights/light.d.ts +7 -1
- package/Lights/light.js +7 -1
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +4 -0
- package/Lights/lightConstants.js +4 -0
- package/Lights/lightConstants.js.map +1 -1
- package/Lights/spotLight.d.ts +6 -3
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +0 -5
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +3 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +5 -0
- package/Materials/Textures/renderTargetTexture.js +9 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +12 -4
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.js +4 -3
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +7 -4
- package/Materials/uniformBuffer.js +37 -15
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +1 -1
- package/Maths/math.vector.js +2 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +25 -0
- package/Meshes/abstractMesh.hotSpot.js +37 -25
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg2.js +6 -4
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +1 -0
- package/Meshes/instancedMesh.js +3 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.d.ts +5 -3
- package/Meshes/linesMesh.js +27 -8
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +0 -19
- package/Meshes/mesh.js +2 -26
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/dumpTools.d.ts +1 -1
- package/Misc/dumpTools.js +23 -14
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/fileTools.js +8 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +16 -7
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/lazy.d.ts +16 -0
- package/Misc/lazy.js +25 -0
- package/Misc/lazy.js.map +1 -0
- package/Misc/screenshotTools.js +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +6 -3
- package/Misc/snapshotRenderingHelper.js +37 -6
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -0
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +17 -3
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +0 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +31 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +67 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -0
- 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/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +2 -2
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +3 -3
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +3 -0
- package/Particles/Node/Blocks/systemBlock.js +3 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +3 -1
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +2 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +118 -61
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -0
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particle.d.ts +8 -0
- package/Particles/particle.js +10 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +2 -4
- package/Particles/particleSystem.js +2 -4
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +6 -0
- package/Particles/thinParticleSystem.function.d.ts +2 -0
- package/Particles/thinParticleSystem.function.js +3 -0
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +15 -5
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +33 -3
- package/Rendering/objectRenderer.js +164 -38
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +19 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/helperFunctions.js +6 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +33 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +5 -0
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +2 -0
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +20 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.d.ts +7 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +125 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +5 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +6 -0
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/lightProxy.fragment.d.ts +5 -0
- package/Shaders/lightProxy.fragment.js +13 -0
- package/Shaders/lightProxy.fragment.js.map +1 -0
- package/Shaders/lightProxy.vertex.d.ts +8 -0
- package/Shaders/lightProxy.vertex.js +19 -0
- package/Shaders/lightProxy.vertex.js.map +1 -0
- package/Shaders/pbr.fragment.d.ts +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +6 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js +24 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +33 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +6 -0
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +22 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +2 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +115 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +5 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +6 -0
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/lightProxy.fragment.d.ts +5 -0
- package/ShadersWGSL/lightProxy.fragment.js +13 -0
- package/ShadersWGSL/lightProxy.fragment.js.map +1 -0
- package/ShadersWGSL/lightProxy.vertex.d.ts +7 -0
- package/ShadersWGSL/lightProxy.vertex.js +19 -0
- package/ShadersWGSL/lightProxy.vertex.js.map +1 -0
- package/ShadersWGSL/pbr.vertex.js +6 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/Sprites/spriteManager.d.ts +5 -0
- package/Sprites/spriteManager.js +6 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +5 -2
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/alphaCullingState.d.ts +3 -1
- package/States/alphaCullingState.js +39 -37
- package/States/alphaCullingState.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +28 -1
- package/scene.js +198 -34
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +2 -0
- package/sceneComponent.js +2 -0
- package/sceneComponent.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshotRenderingHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/snapshotRenderingHelper.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,EAAE,yBAAyB,EAAE,iDAAgD;AAEpF,OAAO,EAAE,MAAM,EAAE,oBAAyB;AAiB1C;;GAEG;AACH,MAAM,OAAO,uBAAuB;IAmBhC;;;;;;OAMG;IACH,YAAY,KAAY,EAAE,OAAyC;QAnB3D,8BAAyB,GAAG,CAAC,CAAC;QAC9B,oCAA+B,uDAA+C;QAE9E,gBAAW,GAAG,KAAK,CAAC;QACpB,2BAAsB,GAAgC,IAAI,GAAG,EAAE,CAAC,CAAC,yEAAyE;QAC1I,4BAAuB,GAAgC,IAAI,GAAG,EAAE,CAAC,CAAC,gBAAgB;QAE1F;;WAEG;QACI,kBAAa,GAAG,KAAK,CAAC;QAUzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAEjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG;YACZ,4BAA4B,EAAE,EAAE;YAChC,GAAG,OAAO;SACb,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,sBAAsB,CAAC;QAEtE,IAAI,CAAC,SAAS,EAAE,CAAC;QAEjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC9D,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;YAE/B,4IAA4I;YAC5I,IAAI,IAAI,CAAC,6BAA6B,EAAE,CAAC;gBACrC,IAA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I,EAAE,CAAC;YACX,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YACzB,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACnG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;IAEO,IAAI,CAAC,QAAgB,EAAE,OAAe;QAC1C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,6BAA6B,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type {\r\n AbstractEngine,\r\n AbstractMesh,\r\n EffectLayer,\r\n Mesh,\r\n Nullable,\r\n Observer,\r\n Scene,\r\n WebGPUDrawContext,\r\n WebGPUShaderProcessor,\r\n WebGPUPipelineContext,\r\n GaussianSplattingMesh,\r\n} from \"core/index\";\r\n\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { BindMorphTargetParameters } from \"core/Materials/materialHelper.functions\";\r\nimport { ScenePerformancePriority } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\n/**\r\n * Options for the snapshot rendering helper\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface SnapshotRenderingHelpersOptions {\r\n /**\r\n * Maximum number of influences for morph target managers\r\n * In FAST snapshot mode, the number of influences must be fixed and cannot change from one frame to the next.\r\n * morphTargetsNumMaxInfluences is the maximum number of non-zero influences allowed in a morph target manager.\r\n * The final value defined for a morph target manager is: Math.min(morphTargetManager.numTargets, morphTargetsNumMaxInfluences)\r\n * Default: 20\r\n */\r\n morphTargetsNumMaxInfluences?: number;\r\n}\r\n\r\n/**\r\n * A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).\r\n */\r\nexport class SnapshotRenderingHelper {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _options: SnapshotRenderingHelpersOptions;\r\n private readonly _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onBeforeRenderObserverUpdateLayer: Nullable<Observer<Scene>>;\r\n private readonly _onResizeObserver: Nullable<Observer<AbstractEngine>>;\r\n private _disableRenderingRefCount = 0;\r\n private _currentPerformancePriorityMode = ScenePerformancePriority.BackwardCompatible;\r\n private _pendingCurrentPerformancePriorityMode?: ScenePerformancePriority;\r\n private _isEnabling = false;\r\n private _enableCancelFunctions: Map<() => void, () => void> = new Map(); // first function is the callback, second function is the cancel function\r\n private _disableCancelFunctions: Map<() => void, () => void> = new Map(); // same as above\r\n\r\n /**\r\n * Indicates if debug logs should be displayed\r\n */\r\n public showDebugLogs = false;\r\n\r\n /**\r\n * Creates a new snapshot rendering helper\r\n * Note that creating an instance of the helper will set the snapshot rendering mode to SNAPSHOTRENDERING_FAST but will not enable snapshot rendering (engine.snapshotRendering is not updated).\r\n * Note also that fixMeshes() is called as part of the construction\r\n * @param scene The scene to use the helper in\r\n * @param options The options for the helper\r\n */\r\n constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._options = {\r\n morphTargetsNumMaxInfluences: 20,\r\n ...options,\r\n };\r\n\r\n this._engine.snapshotRenderingMode = Constants.SNAPSHOTRENDERING_FAST;\r\n\r\n this.fixMeshes();\r\n\r\n this._onResizeObserver = this._engine.onResizeObservable.add(() => {\r\n this._log(\"onResize\", \"start\");\r\n\r\n // enableSnapshotRendering() will delay the actual enabling of snapshot rendering by at least a frame, so these two lines are not redundant!\r\n if (this._fastSnapshotRenderingEnabled) {\r\n this.disableSnapshotRendering();\r\n this.enableSnapshotRendering();\r\n }\r\n\r\n this._log(\"onResize\", \"end\");\r\n });\r\n\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n // Animate skeletons\r\n for (const skeleton of scene.skeletons) {\r\n skeleton.prepare(true);\r\n }\r\n\r\n for (const mesh of scene.meshes) {\r\n if (mesh.infiniteDistance) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.skeleton) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.getClassName() === \"GaussianSplattingMesh\") {\r\n (mesh as GaussianSplattingMesh)._postToWorker();\r\n }\r\n\r\n if (mesh.morphTargetManager && mesh.subMeshes) {\r\n // Make sure morph target animations work\r\n for (const subMesh of mesh.subMeshes) {\r\n const dw = subMesh._drawWrapper;\r\n const effect = dw.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n mesh.morphTargetManager._bind(effect);\r\n BindMorphTargetParameters(mesh, effect);\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets a value indicating if the helper is in a steady state (not in the process of enabling snapshot rendering).\r\n */\r\n public get isReady() {\r\n return !this._isEnabling;\r\n }\r\n\r\n /**\r\n * Enable snapshot rendering\r\n * Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public enableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (--this._disableRenderingRefCount > 0) {\r\n return;\r\n }\r\n\r\n this._log(\"enableSnapshotRendering\", \"called\");\r\n if (this._disableCancelFunctions.size > 0) {\r\n this._log(\"enableSnapshotRendering\", `cancelling ${this._disableCancelFunctions.size} \"disable\" callbacks`);\r\n }\r\n\r\n this._disableCancelFunctions.forEach((cancel) => cancel());\r\n this._disableCancelFunctions.clear();\r\n\r\n this._isEnabling = true;\r\n this._disableRenderingRefCount = 0;\r\n\r\n this._currentPerformancePriorityMode = this._pendingCurrentPerformancePriorityMode ?? this._scene.performancePriority;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._enableCancelFunctions.delete(callbackWhenSceneReady);\r\n\r\n // Make sure a full frame is rendered before enabling snapshot rendering, so use \"+2\" instead of \"+1\"\r\n const targetFrameId = this._engine.frameId + 2;\r\n\r\n this._log(\"enableSnapshotRendering\", `scene ready, add callbacks for frames ${targetFrameId} and ${targetFrameId + 1}`);\r\n\r\n this._executeAtFrame(targetFrameId, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #1, enable snapshot rendering at the engine level`);\r\n this._engine.snapshotRendering = true;\r\n });\r\n\r\n // Render one frame with snapshot rendering enabled to make sure everything is ready\r\n this._executeAtFrame(targetFrameId + 1, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #2, signals that snapshot rendering helper is ready`);\r\n this._isEnabling = false;\r\n });\r\n };\r\n\r\n this._enableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n\r\n /**\r\n * Disable snapshot rendering\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public disableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._log(\"disableSnapshotRendering\", \"called\");\r\n\r\n if (this._disableRenderingRefCount === 0) {\r\n if (this._enableCancelFunctions.size > 0) {\r\n this._log(\"disableSnapshotRendering\", `cancelling ${this._enableCancelFunctions.size} \"enable\" callbacks`);\r\n }\r\n\r\n this._enableCancelFunctions.forEach((cancel) => cancel());\r\n this._enableCancelFunctions.clear();\r\n\r\n this._isEnabling = false;\r\n\r\n // Snapshot rendering switches from enabled to disabled\r\n // We reset the performance priority mode to that which it was before enabling snapshot rendering, but first set it to “BackwardCompatible” to allow the system to regenerate resources that may have been optimized for snapshot rendering.\r\n // We'll then restore the original mode at the next frame.\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n if (this._currentPerformancePriorityMode !== ScenePerformancePriority.BackwardCompatible) {\r\n this._log(\r\n \"disableSnapshotRendering\",\r\n `makes sure that the scene is rendered once in BackwardCompatible mode (code: ${ScenePerformancePriority.BackwardCompatible}) before switching to mode ${this._currentPerformancePriorityMode}`\r\n );\r\n\r\n this._pendingCurrentPerformancePriorityMode = this._currentPerformancePriorityMode;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._log(\"disableSnapshotRendering\", `scene ready, add callback for frame ${this._engine.frameId + 2}`);\r\n\r\n this._executeAtFrame(\r\n this._engine.frameId + 2,\r\n () => {\r\n this._log(\"disableSnapshotRendering\", `switching to performance priority mode ${this._pendingCurrentPerformancePriorityMode}`);\r\n this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode!;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n },\r\n \"whenDisabled\"\r\n );\r\n };\r\n\r\n this._disableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n }\r\n\r\n this._engine.snapshotRendering = false;\r\n this._disableRenderingRefCount++;\r\n }\r\n\r\n /**\r\n * Fix meshes for snapshot rendering.\r\n * This method will make sure that some features are disabled or fixed to make sure snapshot rendering works correctly.\r\n * @param meshes List of meshes to fix. If not provided, all meshes in the scene will be fixed.\r\n */\r\n public fixMeshes(meshes?: AbstractMesh[]) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n meshes = meshes || this._scene.meshes;\r\n\r\n for (const mesh of meshes) {\r\n (mesh as Mesh).ignoreCameraMaxZ = false;\r\n if (mesh.morphTargetManager) {\r\n mesh.morphTargetManager.numMaxInfluencers = Math.min(mesh.morphTargetManager.numTargets, this._options.morphTargetsNumMaxInfluences!);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Call this method to update a mesh on the GPU after some properties have changed (position, rotation, scaling, visibility).\r\n * @param mesh The mesh to update. Can be a single mesh or an array of meshes to update.\r\n * @param updateInstancedMeshes If true, the method will also update instanced meshes. Default is true. If you know instanced meshes won't move (or you don't have instanced meshes), you can set this to false to save some CPU time.\r\n */\r\n public updateMesh(mesh: AbstractMesh | AbstractMesh[], updateInstancedMeshes = true) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(mesh)) {\r\n for (const m of mesh) {\r\n if (!updateInstancedMeshes || !this._updateInstancedMesh(m)) {\r\n m.transferToEffect(m.computeWorldMatrix());\r\n }\r\n }\r\n return;\r\n }\r\n\r\n if (!updateInstancedMeshes || !this._updateInstancedMesh(mesh)) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix());\r\n }\r\n }\r\n\r\n private _updateInstancedMesh(mesh: AbstractMesh) {\r\n if (mesh.hasInstances) {\r\n if (mesh.subMeshes) {\r\n const sourceMesh = mesh as Mesh;\r\n for (const subMesh of sourceMesh.subMeshes) {\r\n const batch = sourceMesh._getInstancesRenderList(subMesh._id);\r\n sourceMesh._updateInstancedBuffers(subMesh, batch, batch.parent.instancesBufferSize, this._engine);\r\n }\r\n }\r\n return true;\r\n } else if (mesh.isAnInstance) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Update the meshes used in an effect layer to ensure that snapshot rendering works correctly for these meshes in this layer.\r\n * @param effectLayer The effect layer\r\n * @param autoUpdate If true, the helper will automatically update the effect layer meshes with each frame. If false, you'll need to call this method manually when the camera or layer meshes move or rotate.\r\n */\r\n public updateMeshesForEffectLayer(effectLayer: EffectLayer, autoUpdate = true) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const renderPassId = effectLayer.mainTexture.renderPassId;\r\n\r\n if (autoUpdate) {\r\n this._onBeforeRenderObserverUpdateLayer = this._scene.onBeforeRenderObservable.add(() => {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n });\r\n } else {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the helper\r\n */\r\n public dispose() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer);\r\n this._engine.onResizeObservable.remove(this._onResizeObserver);\r\n }\r\n\r\n private get _fastSnapshotRenderingEnabled() {\r\n return this._engine.snapshotRendering && this._engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST;\r\n }\r\n\r\n private _updateMeshMatricesForRenderPassId(renderPassId: number) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n const sceneTransformationMatrix = this._scene.getTransformMatrix();\r\n\r\n for (let i = 0; i < this._scene.meshes.length; ++i) {\r\n const mesh = this._scene.meshes[i];\r\n if (!mesh.subMeshes) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < mesh.subMeshes.length; ++j) {\r\n const dw = mesh.subMeshes[j]._getDrawWrapper(renderPassId);\r\n const effect = dw?.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n effect.setMatrix(\"viewProjection\", sceneTransformationMatrix);\r\n effect.setMatrix(\"world\", mesh.computeWorldMatrix());\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _executeAtFrame(frameId: number, func: () => void, mode: \"whenEnabled\" | \"whenDisabled\" = \"whenEnabled\") {\r\n const callback = () => {\r\n if (this._engine.frameId >= frameId) {\r\n this._engine.onEndFrameObservable.remove(obs);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.delete(callback);\r\n } else {\r\n this._disableCancelFunctions.delete(callback);\r\n }\r\n func();\r\n }\r\n };\r\n\r\n const obs = this._engine.onEndFrameObservable.add(callback);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n } else {\r\n this._disableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n }\r\n }\r\n\r\n private _log(funcName: string, message: string) {\r\n if (this.showDebugLogs) {\r\n Logger.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${funcName} - ${message}`);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"snapshotRenderingHelper.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/snapshotRenderingHelper.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,SAAS,EAAE,gCAA+B;AACnD,OAAO,E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,MAAM,CAAC,GAAG,CAAC,CAAC;gBAC9C,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;oBACzB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBACjD,CAAC;qBAAM,CAAC;oBACJ,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;gBAClD,CAAC;gBACD,IAAI,EAAE,CAAC;YACX,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YACzB,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACnG,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;IAEO,IAAI,CAAC,QAAgB,EAAE,OAAe;QAC1C,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,OAAO,CAAC,OAAO,6BAA6B,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type {\r\n AbstractEngine,\r\n AbstractMesh,\r\n EffectLayer,\r\n Mesh,\r\n Nullable,\r\n Observer,\r\n Scene,\r\n WebGPUDrawContext,\r\n WebGPUShaderProcessor,\r\n WebGPUPipelineContext,\r\n GaussianSplattingMesh,\r\n DrawWrapper,\r\n Camera,\r\n SpriteManager,\r\n} from \"core/index\";\r\n\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { BindMorphTargetParameters } from \"core/Materials/materialHelper.functions\";\r\nimport { ScenePerformancePriority } from \"core/scene\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FrameGraphBaseLayerTask } from \"../FrameGraph/Tasks/Layers/baseLayerTask\";\r\nimport { FrameGraphUtils } from \"../FrameGraph/frameGraphUtils\";\r\n\r\n/**\r\n * Options for the snapshot rendering helper\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport interface SnapshotRenderingHelpersOptions {\r\n /**\r\n * Maximum number of influences for morph target managers\r\n * In FAST snapshot mode, the number of influences must be fixed and cannot change from one frame to the next.\r\n * morphTargetsNumMaxInfluences is the maximum number of non-zero influences allowed in a morph target manager.\r\n * The final value defined for a morph target manager is: Math.min(morphTargetManager.numTargets, morphTargetsNumMaxInfluences)\r\n * Default: 20\r\n */\r\n morphTargetsNumMaxInfluences?: number;\r\n}\r\n\r\n/**\r\n * A helper class to simplify work with FAST snapshot mode (WebGPU only - can be used in WebGL too, but won't do anything).\r\n */\r\nexport class SnapshotRenderingHelper {\r\n private readonly _engine: AbstractEngine;\r\n private readonly _scene: Scene;\r\n private readonly _options: SnapshotRenderingHelpersOptions;\r\n private readonly _onBeforeRenderObserver: Nullable<Observer<Scene>>;\r\n private _onBeforeRenderObserverUpdateLayer: Nullable<Observer<Scene>>;\r\n private readonly _onResizeObserver: Nullable<Observer<AbstractEngine>>;\r\n private _disableRenderingRefCount = 0;\r\n private _currentPerformancePriorityMode = ScenePerformancePriority.BackwardCompatible;\r\n private _pendingCurrentPerformancePriorityMode?: ScenePerformancePriority;\r\n private _isEnabling = false;\r\n private _enableCancelFunctions: Map<() => void, () => void> = new Map(); // first function is the callback, second function is the cancel function\r\n private _disableCancelFunctions: Map<() => void, () => void> = new Map(); // same as above\r\n\r\n /**\r\n * Indicates if debug logs should be displayed\r\n */\r\n public showDebugLogs = false;\r\n\r\n /**\r\n * Creates a new snapshot rendering helper\r\n * Note that creating an instance of the helper will set the snapshot rendering mode to SNAPSHOTRENDERING_FAST but will not enable snapshot rendering (engine.snapshotRendering is not updated).\r\n * Note also that fixMeshes() is called as part of the construction\r\n * @param scene The scene to use the helper in\r\n * @param options The options for the helper\r\n */\r\n constructor(scene: Scene, options?: SnapshotRenderingHelpersOptions) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._options = {\r\n morphTargetsNumMaxInfluences: 20,\r\n ...options,\r\n };\r\n\r\n this._engine.snapshotRenderingMode = Constants.SNAPSHOTRENDERING_FAST;\r\n\r\n this.fixMeshes();\r\n\r\n this._onResizeObserver = this._engine.onResizeObservable.add(() => {\r\n this._log(\"onResize\", \"start\");\r\n\r\n // enableSnapshotRendering() will delay the actual enabling of snapshot rendering by at least a frame, so these two lines are not redundant!\r\n if (this._fastSnapshotRenderingEnabled) {\r\n this.disableSnapshotRendering();\r\n this.enableSnapshotRendering();\r\n }\r\n\r\n this._log(\"onResize\", \"end\");\r\n });\r\n\r\n this._scene.onBeforeRenderObservable.add(() => {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n // Animates skeletons\r\n for (const skeleton of scene.skeletons) {\r\n skeleton.prepare(true);\r\n }\r\n\r\n // Handles meshes\r\n for (const mesh of scene.meshes) {\r\n if (mesh.infiniteDistance) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.skeleton) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix(true));\r\n }\r\n\r\n if (mesh.getClassName() === \"GaussianSplattingMesh\") {\r\n (mesh as GaussianSplattingMesh)._postToWorker();\r\n }\r\n\r\n if (mesh.morphTargetManager && mesh.subMeshes) {\r\n // Make sure morph target animations work\r\n for (const subMesh of mesh.subMeshes) {\r\n const dw = subMesh._drawWrapper;\r\n const effect = dw.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n mesh.morphTargetManager._bind(effect);\r\n BindMorphTargetParameters(mesh, effect);\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Handles sprite renderers\r\n let camera = scene.activeCamera;\r\n if (scene.frameGraph) {\r\n camera = FrameGraphUtils.FindMainCamera(scene.frameGraph) || camera;\r\n }\r\n if (scene.spriteManagers && camera) {\r\n for (const imanager of scene.spriteManagers) {\r\n const manager = imanager as SpriteManager;\r\n const renderer = manager.spriteRenderer;\r\n\r\n this._spriteRendererUpdateEffects(renderer._drawWrapperBase, renderer._drawWrapperDepth, camera);\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets a value indicating if the helper is in a steady state (not in the process of enabling snapshot rendering).\r\n */\r\n public get isReady() {\r\n return !this._isEnabling;\r\n }\r\n\r\n /**\r\n * Enable snapshot rendering\r\n * Use this method instead of engine.snapshotRendering=true, to make sure everything is ready before enabling snapshot rendering.\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public enableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n if (--this._disableRenderingRefCount > 0) {\r\n return;\r\n }\r\n\r\n this._log(\"enableSnapshotRendering\", \"called\");\r\n if (this._disableCancelFunctions.size > 0) {\r\n this._log(\"enableSnapshotRendering\", `cancelling ${this._disableCancelFunctions.size} \"disable\" callbacks`);\r\n }\r\n\r\n this._disableCancelFunctions.forEach((cancel) => cancel());\r\n this._disableCancelFunctions.clear();\r\n\r\n this._isEnabling = true;\r\n this._disableRenderingRefCount = 0;\r\n\r\n this._currentPerformancePriorityMode = this._pendingCurrentPerformancePriorityMode ?? this._scene.performancePriority;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._enableCancelFunctions.delete(callbackWhenSceneReady);\r\n\r\n // Make sure a full frame is rendered before enabling snapshot rendering, so use \"+2\" instead of \"+1\"\r\n const targetFrameId = this._engine.frameId + 2;\r\n\r\n this._log(\"enableSnapshotRendering\", `scene ready, add callbacks for frames ${targetFrameId} and ${targetFrameId + 1}`);\r\n\r\n this._executeAtFrame(targetFrameId, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #1, enable snapshot rendering at the engine level`);\r\n this._engine.snapshotRendering = true;\r\n });\r\n\r\n // Render one frame with snapshot rendering enabled to make sure everything is ready\r\n this._executeAtFrame(targetFrameId + 1, () => {\r\n this._log(\"enableSnapshotRendering\", `callback #2, signals that snapshot rendering helper is ready`);\r\n this._isEnabling = false;\r\n });\r\n };\r\n\r\n this._enableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n\r\n /**\r\n * Disable snapshot rendering\r\n * Note that this method is ref-counted and works in pair with disableSnapshotRendering(): you should call enableSnapshotRendering() as many times as you call disableSnapshotRendering().\r\n */\r\n public disableSnapshotRendering() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._log(\"disableSnapshotRendering\", \"called\");\r\n\r\n if (this._disableRenderingRefCount === 0) {\r\n if (this._enableCancelFunctions.size > 0) {\r\n this._log(\"disableSnapshotRendering\", `cancelling ${this._enableCancelFunctions.size} \"enable\" callbacks`);\r\n }\r\n\r\n this._enableCancelFunctions.forEach((cancel) => cancel());\r\n this._enableCancelFunctions.clear();\r\n\r\n this._isEnabling = false;\r\n\r\n // Snapshot rendering switches from enabled to disabled\r\n // We reset the performance priority mode to that which it was before enabling snapshot rendering, but first set it to “BackwardCompatible” to allow the system to regenerate resources that may have been optimized for snapshot rendering.\r\n // We'll then restore the original mode at the next frame.\r\n this._scene.performancePriority = ScenePerformancePriority.BackwardCompatible;\r\n if (this._currentPerformancePriorityMode !== ScenePerformancePriority.BackwardCompatible) {\r\n this._log(\r\n \"disableSnapshotRendering\",\r\n `makes sure that the scene is rendered once in BackwardCompatible mode (code: ${ScenePerformancePriority.BackwardCompatible}) before switching to mode ${this._currentPerformancePriorityMode}`\r\n );\r\n\r\n this._pendingCurrentPerformancePriorityMode = this._currentPerformancePriorityMode;\r\n\r\n const callbackWhenSceneReady = () => {\r\n this._log(\"disableSnapshotRendering\", `scene ready, add callback for frame ${this._engine.frameId + 2}`);\r\n\r\n this._executeAtFrame(\r\n this._engine.frameId + 2,\r\n () => {\r\n this._log(\"disableSnapshotRendering\", `switching to performance priority mode ${this._pendingCurrentPerformancePriorityMode}`);\r\n this._scene.performancePriority = this._pendingCurrentPerformancePriorityMode!;\r\n this._pendingCurrentPerformancePriorityMode = undefined;\r\n },\r\n \"whenDisabled\"\r\n );\r\n };\r\n\r\n this._disableCancelFunctions.set(callbackWhenSceneReady, () => this._scene.onReadyObservable.removeCallback(callbackWhenSceneReady));\r\n\r\n this._scene.executeWhenReady(callbackWhenSceneReady);\r\n }\r\n }\r\n\r\n this._engine.snapshotRendering = false;\r\n this._disableRenderingRefCount++;\r\n }\r\n\r\n /**\r\n * Fix meshes for snapshot rendering.\r\n * This method will make sure that some features are disabled or fixed to make sure snapshot rendering works correctly.\r\n * @param meshes List of meshes to fix. If not provided, all meshes in the scene will be fixed.\r\n */\r\n public fixMeshes(meshes?: AbstractMesh[]) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n meshes = meshes || this._scene.meshes;\r\n\r\n for (const mesh of meshes) {\r\n (mesh as Mesh).ignoreCameraMaxZ = false;\r\n if (mesh.morphTargetManager) {\r\n mesh.morphTargetManager.numMaxInfluencers = Math.min(mesh.morphTargetManager.numTargets, this._options.morphTargetsNumMaxInfluences!);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Call this method to update a mesh on the GPU after some properties have changed (position, rotation, scaling, visibility).\r\n * @param mesh The mesh to update. Can be a single mesh or an array of meshes to update.\r\n * @param updateInstancedMeshes If true, the method will also update instanced meshes. Default is true. If you know instanced meshes won't move (or you don't have instanced meshes), you can set this to false to save some CPU time.\r\n */\r\n public updateMesh(mesh: AbstractMesh | AbstractMesh[], updateInstancedMeshes = true) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(mesh)) {\r\n for (const m of mesh) {\r\n if (!updateInstancedMeshes || !this._updateInstancedMesh(m)) {\r\n m.transferToEffect(m.computeWorldMatrix());\r\n }\r\n }\r\n return;\r\n }\r\n\r\n if (!updateInstancedMeshes || !this._updateInstancedMesh(mesh)) {\r\n mesh.transferToEffect(mesh.computeWorldMatrix());\r\n }\r\n }\r\n\r\n private _updateInstancedMesh(mesh: AbstractMesh) {\r\n if (mesh.hasInstances) {\r\n if (mesh.subMeshes) {\r\n const sourceMesh = mesh as Mesh;\r\n for (const subMesh of sourceMesh.subMeshes) {\r\n const batch = sourceMesh._getInstancesRenderList(subMesh._id);\r\n sourceMesh._updateInstancedBuffers(subMesh, batch, batch.parent.instancesBufferSize, this._engine);\r\n }\r\n }\r\n return true;\r\n } else if (mesh.isAnInstance) {\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Update the meshes used in an effect layer to ensure that snapshot rendering works correctly for these meshes in this layer.\r\n * @param layer The effect layer or frame graph layer\r\n * @param autoUpdate If true, the helper will automatically update the meshes of the layer with each frame. If false, you'll need to call this method manually when the camera or layer meshes move or rotate.\r\n */\r\n public updateMeshesForEffectLayer(layer: EffectLayer | FrameGraphBaseLayerTask, autoUpdate = true) {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n const renderPassId = layer instanceof FrameGraphBaseLayerTask ? layer.objectRendererForLayer.objectRenderer.renderPassId : layer.mainTexture.renderPassId;\r\n\r\n if (autoUpdate) {\r\n this._onBeforeRenderObserverUpdateLayer = this._scene.onBeforeRenderObservable.add(() => {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n });\r\n } else {\r\n this._updateMeshMatricesForRenderPassId(renderPassId);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the helper\r\n */\r\n public dispose() {\r\n if (!this._engine.isWebGPU) {\r\n return;\r\n }\r\n\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);\r\n this._scene.onBeforeRenderObservable.remove(this._onBeforeRenderObserverUpdateLayer);\r\n this._engine.onResizeObservable.remove(this._onResizeObserver);\r\n }\r\n\r\n private get _fastSnapshotRenderingEnabled() {\r\n return this._engine.snapshotRendering && this._engine.snapshotRenderingMode === Constants.SNAPSHOTRENDERING_FAST;\r\n }\r\n\r\n private _updateMeshMatricesForRenderPassId(renderPassId: number) {\r\n if (!this._fastSnapshotRenderingEnabled) {\r\n return;\r\n }\r\n\r\n const sceneTransformationMatrix =\r\n this._scene.objectRenderers.find((renderer) => renderer.renderPassId === renderPassId)?.activeCamera?.getTransformationMatrix() ?? this._scene.getTransformMatrix();\r\n\r\n for (let i = 0; i < this._scene.meshes.length; ++i) {\r\n const mesh = this._scene.meshes[i];\r\n if (!mesh.subMeshes) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < mesh.subMeshes.length; ++j) {\r\n const dw = mesh.subMeshes[j]._getDrawWrapper(renderPassId);\r\n const effect = dw?.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n effect.setMatrix(\"viewProjection\", sceneTransformationMatrix);\r\n effect.setMatrix(\"world\", mesh.computeWorldMatrix());\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _spriteRendererDirectMatrixUpdate(dw: DrawWrapper, camera: Camera) {\r\n const effect = dw?.effect;\r\n if (effect) {\r\n const dataBuffer = (dw.drawContext as WebGPUDrawContext).buffers[\"LeftOver\" satisfies (typeof WebGPUShaderProcessor)[\"LeftOvertUBOName\"]];\r\n const ubLeftOver = (effect._pipelineContext as WebGPUPipelineContext)?.uniformBuffer;\r\n if (dataBuffer && ubLeftOver && ubLeftOver.setDataBuffer(dataBuffer)) {\r\n effect.setMatrix(\"view\", camera.getViewMatrix());\r\n effect.setMatrix(\"projection\", camera.getProjectionMatrix());\r\n ubLeftOver.update();\r\n }\r\n }\r\n }\r\n\r\n private _spriteRendererUpdateEffects(drawWrapperBase: DrawWrapper, drawWrapperDepth: DrawWrapper, camera: Camera) {\r\n this._spriteRendererDirectMatrixUpdate(drawWrapperBase, camera);\r\n this._spriteRendererDirectMatrixUpdate(drawWrapperDepth, camera);\r\n }\r\n\r\n private _executeAtFrame(frameId: number, func: () => void, mode: \"whenEnabled\" | \"whenDisabled\" = \"whenEnabled\") {\r\n const callback = () => {\r\n if (this._engine.frameId >= frameId) {\r\n this._engine.onEndFrameObservable.remove(obs);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.delete(callback);\r\n } else {\r\n this._disableCancelFunctions.delete(callback);\r\n }\r\n func();\r\n }\r\n };\r\n\r\n const obs = this._engine.onEndFrameObservable.add(callback);\r\n if (mode === \"whenEnabled\") {\r\n this._enableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n } else {\r\n this._disableCancelFunctions.set(callback, () => this._engine.onEndFrameObservable.remove(obs));\r\n }\r\n }\r\n\r\n private _log(funcName: string, message: string) {\r\n if (this.showDebugLogs) {\r\n Logger.Log(`[Frame: ${this._engine.frameId}] SnapshotRenderingHelper:${funcName} - ${message}`);\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -21,6 +21,10 @@ export interface IParticleSystem {
|
|
|
21
21
|
* Gets or sets the unique id of the particle system.
|
|
22
22
|
*/
|
|
23
23
|
uniqueId: number;
|
|
24
|
+
/**
|
|
25
|
+
* Particle system metadata.
|
|
26
|
+
*/
|
|
27
|
+
metadata: Nullable<any>;
|
|
24
28
|
/**
|
|
25
29
|
* List of animations used by the particle system.
|
|
26
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n CylinderDirectedParticleEmitter,\r\n ConeParticleEmitter,\r\n ConeDirectedParticleEmitter,\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * Gets or sets the unique id of the particle system.\r\n */\r\n uniqueId: number;\r\n\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle. It can be any of the ParticleSystem.BLENDMODE_* constants\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** Indicates that the update of particles is done in the animate function (and not in render) */\r\n updateInAnimate: boolean;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Returns true if the particle system was generated by a node particle system set\r\n */\r\n isNodeGenerated: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n * @param disposeAttachedSubEmitters defines if the attached sub-emitters must be disposed as well (false by default)\r\n * @param disposeEndSubEmitters defines if the end type sub-emitters must be disposed as well (false by default)\r\n */\r\n dispose(disposeTexture?: boolean, disposeAttachedSubEmitters?: boolean, disposeEndSubEmitters?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is started\r\n */\r\n onStartedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n * @param fillImageProcessing fills the image processing defines\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number, fillImageProcessing?: boolean): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Gets the vertex buffers used by the particle system\r\n */\r\n vertexBuffers: Immutable<{ [key: string]: VertexBuffer }>;\r\n /**\r\n * Gets the index buffer used by the particle system (or null if no index buffer is used)\r\n */\r\n indexBuffer: Nullable<DataBuffer>;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): CylinderDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n createDirectedConeEmitter(radius: number, angle: number, direction1: Vector3, direction2: Vector3): ConeDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n CylinderDirectedParticleEmitter,\r\n ConeParticleEmitter,\r\n ConeDirectedParticleEmitter,\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\n\r\nimport type { Animation } from \"../Animations/animation\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * Gets or sets the unique id of the particle system.\r\n */\r\n uniqueId: number;\r\n /**\r\n * Particle system metadata.\r\n */\r\n metadata: Nullable<any>;\r\n\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle. It can be any of the ParticleSystem.BLENDMODE_* constants\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** Indicates that the update of particles is done in the animate function (and not in render) */\r\n updateInAnimate: boolean;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Returns true if the particle system was generated by a node particle system set\r\n */\r\n isNodeGenerated: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n * @param disposeAttachedSubEmitters defines if the attached sub-emitters must be disposed as well (false by default)\r\n * @param disposeEndSubEmitters defines if the end type sub-emitters must be disposed as well (false by default)\r\n */\r\n dispose(disposeTexture?: boolean, disposeAttachedSubEmitters?: boolean, disposeEndSubEmitters?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is started\r\n */\r\n onStartedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n * @param fillImageProcessing fills the image processing defines\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number, fillImageProcessing?: boolean): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Gets the vertex buffers used by the particle system\r\n */\r\n vertexBuffers: Immutable<{ [key: string]: VertexBuffer }>;\r\n /**\r\n * Gets the index buffer used by the particle system (or null if no index buffer is used)\r\n */\r\n indexBuffer: Nullable<DataBuffer>;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): CylinderDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n createDirectedConeEmitter(radius: number, angle: number, direction1: Vector3, direction2: Vector3): ConeDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
|
|
@@ -27,6 +27,10 @@ export declare class CreateParticleBlock extends NodeParticleBlock {
|
|
|
27
27
|
* Gets the color input component
|
|
28
28
|
*/
|
|
29
29
|
get color(): NodeParticleConnectionPoint;
|
|
30
|
+
/**
|
|
31
|
+
* Gets the color dead input component
|
|
32
|
+
*/
|
|
33
|
+
get colorDead(): NodeParticleConnectionPoint;
|
|
30
34
|
/**
|
|
31
35
|
* Gets the scale input component
|
|
32
36
|
*/
|
|
@@ -5,6 +5,7 @@ import { Color4 } from "../../../../Maths/math.color.js";
|
|
|
5
5
|
import { Vector2 } from "../../../../Maths/math.vector.js";
|
|
6
6
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
7
7
|
import { PointParticleEmitter } from "../../../EmitterTypes/pointParticleEmitter.js";
|
|
8
|
+
const ColorDiff = new Color4();
|
|
8
9
|
/**
|
|
9
10
|
* @internal
|
|
10
11
|
*/
|
|
@@ -18,6 +19,7 @@ export class CreateParticleBlock extends NodeParticleBlock {
|
|
|
18
19
|
this.registerInput("emitPower", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
19
20
|
this.registerInput("lifeTime", NodeParticleBlockConnectionPointTypes.Float, true, 1);
|
|
20
21
|
this.registerInput("color", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(1, 1, 1, 1));
|
|
22
|
+
this.registerInput("colorDead", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(0, 0, 0, 0));
|
|
21
23
|
this.registerInput("scale", NodeParticleBlockConnectionPointTypes.Vector2, true, new Vector2(1, 1));
|
|
22
24
|
this.registerInput("angle", NodeParticleBlockConnectionPointTypes.Float, true, 0);
|
|
23
25
|
this.registerOutput("particle", NodeParticleBlockConnectionPointTypes.Particle);
|
|
@@ -47,17 +49,23 @@ export class CreateParticleBlock extends NodeParticleBlock {
|
|
|
47
49
|
get color() {
|
|
48
50
|
return this._inputs[2];
|
|
49
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the color dead input component
|
|
54
|
+
*/
|
|
55
|
+
get colorDead() {
|
|
56
|
+
return this._inputs[3];
|
|
57
|
+
}
|
|
50
58
|
/**
|
|
51
59
|
* Gets the scale input component
|
|
52
60
|
*/
|
|
53
61
|
get scale() {
|
|
54
|
-
return this._inputs[
|
|
62
|
+
return this._inputs[4];
|
|
55
63
|
}
|
|
56
64
|
/**
|
|
57
65
|
* Gets the angle input component
|
|
58
66
|
*/
|
|
59
67
|
get angle() {
|
|
60
|
-
return this._inputs[
|
|
68
|
+
return this._inputs[5];
|
|
61
69
|
}
|
|
62
70
|
/**
|
|
63
71
|
* Gets the particle output component
|
|
@@ -80,7 +88,13 @@ export class CreateParticleBlock extends NodeParticleBlock {
|
|
|
80
88
|
system._colorCreation.process = (particle) => {
|
|
81
89
|
state.particleContext = particle;
|
|
82
90
|
particle.color.copyFrom(this.color.getConnectedValue(state));
|
|
83
|
-
|
|
91
|
+
};
|
|
92
|
+
system._colorDeadCreation.process = (particle) => {
|
|
93
|
+
state.particleContext = particle;
|
|
94
|
+
particle.colorDead.copyFrom(this.colorDead.getConnectedValue(state));
|
|
95
|
+
particle.initialColor.copyFrom(particle.color);
|
|
96
|
+
particle.colorDead.subtractToRef(particle.initialColor, ColorDiff);
|
|
97
|
+
ColorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
|
|
84
98
|
};
|
|
85
99
|
system._sizeCreation.process = (particle) => {
|
|
86
100
|
state.particleContext = particle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createParticleBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/createParticleBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,cAAc,EAAE,mCAAsC;AAQ/D,OAAO,EAAE,MAAM,EAAE,wCAA8B;AAC/C,OAAO,EAAE,OAAO,EAAE,yCAA+B;AACjD,OAAO,EAAE,aAAa,EAAE,sCAA4B;AACpD,OAAO,EAAE,oBAAoB,EAAE,sDAAyD;AAExF;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IACtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,qCAA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CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport { ParticleSystem } from \"core/Particles/particleSystem\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport type { _IExecutionQueueItem } from \"core/Particles/Queue/executionQueue\";\r\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\r\nimport { _RemoveFromQueue } from \"core/Particles/Queue/executionQueue\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport type { ThinParticleSystem } from \"core/Particles/thinParticleSystem\";\r\nimport { Color4 } from \"core/Maths/math.color\";\r\nimport { Vector2 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"core/Misc/typeStore\";\r\nimport { PointParticleEmitter } from \"core/Particles/EmitterTypes/pointParticleEmitter\";\r\n\r\nconst ColorDiff = new Color4();\r\n\r\n/**\r\n * @internal\r\n */\r\nexport class CreateParticleBlock extends NodeParticleBlock {\r\n /**\r\n * Create a new CreateParticleBlock\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(\"emitPower\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"lifeTime\", NodeParticleBlockConnectionPointTypes.Float, true, 1);\r\n this.registerInput(\"color\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(1, 1, 1, 1));\r\n this.registerInput(\"colorDead\", NodeParticleBlockConnectionPointTypes.Color4, true, new Color4(0, 0, 0, 0));\r\n this.registerInput(\"scale\", NodeParticleBlockConnectionPointTypes.Vector2, true, new Vector2(1, 1));\r\n this.registerInput(\"angle\", NodeParticleBlockConnectionPointTypes.Float, true, 0);\r\n this.registerOutput(\"particle\", 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 \"CreateParticleBlock\";\r\n }\r\n\r\n /**\r\n * Gets the emitPower input component\r\n */\r\n public get emitPower(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the lifeTime input component\r\n */\r\n public get lifeTime(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the color input component\r\n */\r\n public get color(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the color dead input component\r\n */\r\n public get colorDead(): NodeParticleConnectionPoint {\r\n return this._inputs[3];\r\n }\r\n\r\n /**\r\n * Gets the scale input component\r\n */\r\n public get scale(): NodeParticleConnectionPoint {\r\n return this._inputs[4];\r\n }\r\n\r\n /**\r\n * Gets the angle input component\r\n */\r\n public get angle(): NodeParticleConnectionPoint {\r\n return this._inputs[5];\r\n }\r\n\r\n /**\r\n * Gets the particle output component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = new ParticleSystem(this.name, state.capacity, state.scene, null, false, undefined, true);\r\n system.particleEmitterType = new PointParticleEmitter();\r\n\r\n // Creation\r\n system._lifeTimeCreation.process = (particle: Particle, system: ThinParticleSystem) => {\r\n state.particleContext = particle;\r\n particle.lifeTime = this.lifeTime.getConnectedValue(state);\r\n system._emitPower = this.emitPower.getConnectedValue(state);\r\n };\r\n\r\n system._colorCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.color.copyFrom(this.color.getConnectedValue(state));\r\n };\r\n\r\n system._colorDeadCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.colorDead.copyFrom(this.colorDead.getConnectedValue(state));\r\n particle.initialColor.copyFrom(particle.color);\r\n particle.colorDead.subtractToRef(particle.initialColor, ColorDiff);\r\n ColorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);\r\n };\r\n\r\n system._sizeCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.size = 1;\r\n particle.scale.copyFrom(this.scale.getConnectedValue(state));\r\n };\r\n\r\n system._angleCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n particle.angle = this.angle.getConnectedValue(state);\r\n };\r\n\r\n this.particle._storedValue = system;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.CreateParticleBlock\", CreateParticleBlock);\r\n"]}
|
|
@@ -187,7 +187,6 @@ export class MeshShapeBlock extends NodeParticleBlock {
|
|
|
187
187
|
Vector4.FromArrayToRef(this._colors, faceIndexB * 4, TmpVectors.Vector4[1]);
|
|
188
188
|
Vector4.FromArrayToRef(this._colors, faceIndexC * 4, TmpVectors.Vector4[2]);
|
|
189
189
|
particle.color.copyFromFloats(bu * TmpVectors.Vector4[0].x + bv * TmpVectors.Vector4[1].x + bw * TmpVectors.Vector4[2].x, bu * TmpVectors.Vector4[0].y + bv * TmpVectors.Vector4[1].y + bw * TmpVectors.Vector4[2].y, bu * TmpVectors.Vector4[0].z + bv * TmpVectors.Vector4[1].z + bw * TmpVectors.Vector4[2].z, bu * TmpVectors.Vector4[0].w + bv * TmpVectors.Vector4[1].w + bw * TmpVectors.Vector4[2].w);
|
|
190
|
-
particle.colorStep.copyFrom(particle.color);
|
|
191
190
|
}
|
|
192
191
|
};
|
|
193
192
|
this.output._storedValue = system;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meshShapeBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/meshShapeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,oCA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mBAAmB,CAAC,CAAC;QAExC,IAAI,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;YACvC,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QACpF,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,0BAA0B,GAAG,CAAC,CAAC,mBAAmB,CAAC,0BAA0B,CAAC;QACnF,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QACvE,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,mBAAmB,CAAC,UAAU,CAAC;IACvD,CAAC;CACJ;AA5PU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC1G;AAM7B;IADN,sBAAsB,CAAC,2BAA2B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kEACxG;AAMnC;IADN,sBAAsB,CAAC,4BAA4B,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC/G;AAM7B;IADN,sBAAsB,CAAC,aAAa,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kDAC1G;AA4O9B,aAAa,CAAC,wBAAwB,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { Mesh } from \"../../../../Meshes/mesh\";\r\nimport { VertexData } from \"../../../../Meshes/mesh.vertexData\";\r\nimport type { FloatArray, IndicesArray, Nullable } from \"../../../../types\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { Particle } from \"core/Particles/particle\";\r\nimport { TmpVectors, Vector3, Vector4 } from \"core/Maths/math.vector\";\r\nimport { RandomRange } from \"core/Maths/math.scalar.functions\";\r\nimport type { IShapeBlock } from \"./IShapeBlock\";\r\n\r\n/**\r\n * Defines a block used to generate particle shape from mesh geometry data\r\n */\r\nexport class MeshShapeBlock extends NodeParticleBlock implements IShapeBlock {\r\n private _mesh: Nullable<Mesh>;\r\n private _cachedVertexData: Nullable<VertexData> = null;\r\n private _indices: Nullable<IndicesArray> = null;\r\n private _positions: Nullable<FloatArray> = null;\r\n private _normals: Nullable<FloatArray> = null;\r\n private _colors: Nullable<FloatArray> = null;\r\n private _storedNormal = Vector3.Zero();\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh normals should be used for particle direction\r\n */\r\n @editableInPropertyPage(\"Use normals for direction\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshNormalsForDirection = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the mesh colors should be used for particle color\r\n */\r\n @editableInPropertyPage(\"Use vertex color for color\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public useMeshColorForColor = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the coordinates should be in world space (local space by default)\r\n */\r\n @editableInPropertyPage(\"World space\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public worldSpace = false;\r\n\r\n /**\r\n * Gets or sets the mesh to use to get vertex data\r\n */\r\n public get mesh() {\r\n return this._mesh;\r\n }\r\n\r\n public set mesh(value: Nullable<Mesh>) {\r\n this._mesh = value;\r\n }\r\n\r\n /**\r\n * Create a new MeshShapeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerInput(\"direction1\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerInput(\"direction2\", NodeParticleBlockConnectionPointTypes.Vector3, true, new Vector3(0, 1.0, 0));\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"MeshShapeBlock\";\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the block is using cached data\r\n */\r\n public get isUsingCachedData() {\r\n return !this.mesh && !!this._cachedVertexData;\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the direction1 input component\r\n */\r\n public get direction1(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the direction2 input component\r\n */\r\n public get direction2(): NodeParticleConnectionPoint {\r\n return this._inputs[2];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Remove stored data\r\n */\r\n public cleanData() {\r\n this._mesh = null;\r\n this._cachedVertexData = null;\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n const system = this.particle.getConnectedValue(state);\r\n\r\n if (!this._mesh && !this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n if (this._mesh) {\r\n this._cachedVertexData = VertexData.ExtractFromMesh(this._mesh, false, true);\r\n }\r\n\r\n if (!this._cachedVertexData) {\r\n this.output._storedValue = system;\r\n return;\r\n }\r\n\r\n this._indices = this._cachedVertexData.indices;\r\n this._positions = this._cachedVertexData.positions;\r\n this._normals = this._cachedVertexData.normals;\r\n this._colors = this._cachedVertexData.colors;\r\n\r\n if (this.useMeshColorForColor && this._colors) {\r\n system._colorCreation.process = () => {};\r\n }\r\n\r\n system._directionCreation.process = (particle: Particle) => {\r\n state.particleContext = particle;\r\n state.systemContext = system;\r\n\r\n if (this.useMeshNormalsForDirection && this._normals) {\r\n if (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 particle.colorStep.copyFrom(particle.color);\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;QAEvC;;WAEG;QAEI,yBAAoB,GAAG,KAAK,CAAC;QAEpC;;WAEG;QAEI,+BAA0B,GAAG,KAAK,CAAC;QAE1C;;WAEG;QAEI,yBAAo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C,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kDAC1G;AA0O9B,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\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"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NodeParticleBlock } from "../../nodeParticleBlock.js";
|
|
2
|
+
import type { NodeParticleConnectionPoint } from "../../nodeParticleBlockConnectionPoint.js";
|
|
3
|
+
import type { NodeParticleBuildState } from "../../nodeParticleBuildState.js";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to provide the basic update functionality for particle colors.
|
|
6
|
+
*/
|
|
7
|
+
export declare class BasicColorUpdateBlock extends NodeParticleBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new UpdateScaleBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name: string);
|
|
13
|
+
/**
|
|
14
|
+
* Gets the particle component
|
|
15
|
+
*/
|
|
16
|
+
get particle(): NodeParticleConnectionPoint;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the output component
|
|
19
|
+
*/
|
|
20
|
+
get output(): NodeParticleConnectionPoint;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the current class name
|
|
23
|
+
* @returns the class name
|
|
24
|
+
*/
|
|
25
|
+
getClassName(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Builds the block
|
|
28
|
+
* @param state defines the current build state
|
|
29
|
+
*/
|
|
30
|
+
_build(state: NodeParticleBuildState): void;
|
|
31
|
+
}
|