@onerjs/core 8.23.12 → 8.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -7,84 +7,141 @@ import { PointShapeBlock } from "./Blocks/Emitters/pointShapeBlock.js";
|
|
|
7
7
|
import { SphereShapeBlock } from "./Blocks/Emitters/sphereShapeBlock.js";
|
|
8
8
|
import { CylinderShapeBlock } from "./Blocks/Emitters/cylinderShapeBlock.js";
|
|
9
9
|
import { MeshShapeBlock } from "./Blocks/Emitters/meshShapeBlock.js";
|
|
10
|
+
import { ParticleTextureSourceBlock } from "./Blocks/particleSourceTextureBlock.js";
|
|
11
|
+
import { BasicPositionUpdateBlock } from "./Blocks/Update/basicPositionUpdateBlock.js";
|
|
12
|
+
import { BasicColorUpdateBlock } from "./Blocks/Update/basicColorUpdateBlock.js";
|
|
13
|
+
import { ParticleRandomBlock } from "./Blocks/particleRandomBlock.js";
|
|
10
14
|
function _CreateAndConnectInput(connectionPoint, name, defaultValue) {
|
|
11
15
|
const input = new ParticleInputBlock(name);
|
|
12
16
|
input.value = defaultValue;
|
|
13
17
|
input.output.connectTo(connectionPoint);
|
|
14
18
|
}
|
|
19
|
+
async function _ExtractDatafromParticleSystemAsync(particleSystem, target) {
|
|
20
|
+
// Main system
|
|
21
|
+
const system = new SystemBlock(particleSystem.name);
|
|
22
|
+
system.capacity = particleSystem.getCapacity();
|
|
23
|
+
system.emitRate = particleSystem.emitRate;
|
|
24
|
+
// Create particle
|
|
25
|
+
const createParticleBlock = new CreateParticleBlock("Create particle");
|
|
26
|
+
// Shape
|
|
27
|
+
let shapeBlock = null;
|
|
28
|
+
switch (particleSystem.particleEmitterType.getClassName()) {
|
|
29
|
+
case "BoxParticleEmitter": {
|
|
30
|
+
const source = particleSystem.particleEmitterType;
|
|
31
|
+
shapeBlock = new BoxShapeBlock("Box shape");
|
|
32
|
+
const target = shapeBlock;
|
|
33
|
+
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
34
|
+
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
35
|
+
_CreateAndConnectInput(target.minEmitBox, "Min Emit Box", source.minEmitBox);
|
|
36
|
+
_CreateAndConnectInput(target.maxEmitBox, "Max Emit Box", source.maxEmitBox);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "PointParticleEmitter": {
|
|
40
|
+
const source = particleSystem.particleEmitterType;
|
|
41
|
+
shapeBlock = new PointShapeBlock("Point shape");
|
|
42
|
+
const target = shapeBlock;
|
|
43
|
+
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
44
|
+
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case "SphereParticleEmitter": {
|
|
48
|
+
const source = particleSystem.particleEmitterType;
|
|
49
|
+
shapeBlock = new SphereShapeBlock("Sphere shape");
|
|
50
|
+
const target = shapeBlock;
|
|
51
|
+
_CreateAndConnectInput(target.radius, "Radius", source.radius);
|
|
52
|
+
_CreateAndConnectInput(target.radiusRange, "Radius Range", source.radiusRange);
|
|
53
|
+
_CreateAndConnectInput(target.directionRandomizer, "Direction Randomizer", source.directionRandomizer);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
case "CylinderParticleEmitter": {
|
|
57
|
+
const source = particleSystem.particleEmitterType;
|
|
58
|
+
shapeBlock = new CylinderShapeBlock("Cylinder shape");
|
|
59
|
+
const target = shapeBlock;
|
|
60
|
+
_CreateAndConnectInput(target.height, "Height", source.height);
|
|
61
|
+
_CreateAndConnectInput(target.radius, "Radius", source.radius);
|
|
62
|
+
_CreateAndConnectInput(target.radiusRange, "Radius Range", source.radiusRange);
|
|
63
|
+
_CreateAndConnectInput(target.directionRandomizer, "Direction Randomizer", source.directionRandomizer);
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
case "MeshParticleEmitter": {
|
|
67
|
+
const source = particleSystem.particleEmitterType;
|
|
68
|
+
shapeBlock = new MeshShapeBlock("Mesh shape");
|
|
69
|
+
const target = shapeBlock;
|
|
70
|
+
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
71
|
+
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
72
|
+
target.mesh = source.mesh;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!shapeBlock) {
|
|
77
|
+
throw new Error(`Unsupported particle emitter type: ${particleSystem.particleEmitterType.getClassName()}`);
|
|
78
|
+
}
|
|
79
|
+
createParticleBlock.particle.connectTo(shapeBlock.particle);
|
|
80
|
+
createParticleBlock.colorDead.value = particleSystem.colorDead;
|
|
81
|
+
// Color
|
|
82
|
+
const color0Block = new ParticleInputBlock("Color0");
|
|
83
|
+
color0Block.value = particleSystem.color1;
|
|
84
|
+
const color1Block = new ParticleInputBlock("Color1");
|
|
85
|
+
color1Block.value = particleSystem.color2;
|
|
86
|
+
const randomColorBlock = new ParticleRandomBlock("Random Color");
|
|
87
|
+
color0Block.output.connectTo(randomColorBlock.min);
|
|
88
|
+
color1Block.output.connectTo(randomColorBlock.max);
|
|
89
|
+
randomColorBlock.output.connectTo(createParticleBlock.color);
|
|
90
|
+
// Emit power
|
|
91
|
+
const minEmitPowerBlock = new ParticleInputBlock("Min Emit Power");
|
|
92
|
+
minEmitPowerBlock.value = particleSystem.minEmitPower;
|
|
93
|
+
const maxEmitPowerBlock = new ParticleInputBlock("Max Emit Power");
|
|
94
|
+
maxEmitPowerBlock.value = particleSystem.maxEmitPower;
|
|
95
|
+
const randomEmitPowerBlock = new ParticleRandomBlock("Random Emit Power");
|
|
96
|
+
minEmitPowerBlock.output.connectTo(randomEmitPowerBlock.min);
|
|
97
|
+
maxEmitPowerBlock.output.connectTo(randomEmitPowerBlock.max);
|
|
98
|
+
randomEmitPowerBlock.output.connectTo(createParticleBlock.emitPower);
|
|
99
|
+
// Lifetime
|
|
100
|
+
const minLifetimeBlock = new ParticleInputBlock("Min Lifetime");
|
|
101
|
+
minLifetimeBlock.value = particleSystem.minLifeTime;
|
|
102
|
+
const maxLifetimeBlock = new ParticleInputBlock("Max Lifetime");
|
|
103
|
+
maxLifetimeBlock.value = particleSystem.maxLifeTime;
|
|
104
|
+
const randomLifetimeBlock = new ParticleRandomBlock("Random Lifetime");
|
|
105
|
+
minLifetimeBlock.output.connectTo(randomLifetimeBlock.min);
|
|
106
|
+
maxLifetimeBlock.output.connectTo(randomLifetimeBlock.max);
|
|
107
|
+
randomLifetimeBlock.output.connectTo(createParticleBlock.lifeTime);
|
|
108
|
+
// Texture
|
|
109
|
+
const textureBlock = new ParticleTextureSourceBlock("Texture");
|
|
110
|
+
const url = particleSystem.particleTexture.url || "";
|
|
111
|
+
if (url) {
|
|
112
|
+
textureBlock.url = url;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
textureBlock.sourceTexture = particleSystem.particleTexture;
|
|
116
|
+
}
|
|
117
|
+
textureBlock.texture.connectTo(system.texture);
|
|
118
|
+
// Default position update
|
|
119
|
+
const basicPositionUpdateBlock = new BasicPositionUpdateBlock("Position update");
|
|
120
|
+
shapeBlock.output.connectTo(basicPositionUpdateBlock.particle);
|
|
121
|
+
// Default color update
|
|
122
|
+
const basicColorUpdateBlock = new BasicColorUpdateBlock("Color update");
|
|
123
|
+
basicPositionUpdateBlock.output.connectTo(basicColorUpdateBlock.particle);
|
|
124
|
+
basicColorUpdateBlock.output.connectTo(system.particle);
|
|
125
|
+
// Register
|
|
126
|
+
target.systemBlocks.push(system);
|
|
127
|
+
}
|
|
15
128
|
/**
|
|
16
129
|
* Converts a ParticleSystem to a NodeParticleSystemSet.
|
|
17
130
|
* @param name The name of the node particle system set.
|
|
18
131
|
* @param particleSystems The particle systems to convert.
|
|
19
132
|
* @returns The converted node particle system set or null if conversion failed.
|
|
133
|
+
* #0K3AQ2#3627
|
|
20
134
|
*/
|
|
21
|
-
export function
|
|
135
|
+
export async function ConvertToNodeParticleSystemSetAsync(name, particleSystems) {
|
|
22
136
|
if (!particleSystems || !particleSystems.length) {
|
|
23
137
|
return null;
|
|
24
138
|
}
|
|
25
139
|
const nodeParticleSystemSet = new NodeParticleSystemSet(name);
|
|
140
|
+
const promises = [];
|
|
26
141
|
for (const particleSystem of particleSystems) {
|
|
27
|
-
|
|
28
|
-
const system = new SystemBlock(particleSystem.name);
|
|
29
|
-
// Create particle
|
|
30
|
-
const createParticleBlock = new CreateParticleBlock("Create particle");
|
|
31
|
-
// Shape
|
|
32
|
-
let shapeBlock = null;
|
|
33
|
-
switch (particleSystem.particleEmitterType.getClassName()) {
|
|
34
|
-
case "BoxParticleEmitter": {
|
|
35
|
-
const source = particleSystem.particleEmitterType;
|
|
36
|
-
shapeBlock = new BoxShapeBlock("Box shape");
|
|
37
|
-
const target = shapeBlock;
|
|
38
|
-
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
39
|
-
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
40
|
-
_CreateAndConnectInput(target.minEmitBox, "Min Emit Box", source.minEmitBox);
|
|
41
|
-
_CreateAndConnectInput(target.maxEmitBox, "Max Emit Box", source.maxEmitBox);
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
case "PointParticleEmitter": {
|
|
45
|
-
const source = particleSystem.particleEmitterType;
|
|
46
|
-
shapeBlock = new PointShapeBlock("Point shape");
|
|
47
|
-
const target = shapeBlock;
|
|
48
|
-
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
49
|
-
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
case "SphereParticleEmitter": {
|
|
53
|
-
const source = particleSystem.particleEmitterType;
|
|
54
|
-
shapeBlock = new SphereShapeBlock("Sphere shape");
|
|
55
|
-
const target = shapeBlock;
|
|
56
|
-
_CreateAndConnectInput(target.radius, "Radius", source.radius);
|
|
57
|
-
_CreateAndConnectInput(target.radiusRange, "Radius Range", source.radiusRange);
|
|
58
|
-
_CreateAndConnectInput(target.directionRandomizer, "Direction Randomizer", source.directionRandomizer);
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
case "CylinderParticleEmitter": {
|
|
62
|
-
const source = particleSystem.particleEmitterType;
|
|
63
|
-
shapeBlock = new CylinderShapeBlock("Cylinder shape");
|
|
64
|
-
const target = shapeBlock;
|
|
65
|
-
_CreateAndConnectInput(target.height, "Height", source.height);
|
|
66
|
-
_CreateAndConnectInput(target.radius, "Radius", source.radius);
|
|
67
|
-
_CreateAndConnectInput(target.radiusRange, "Radius Range", source.radiusRange);
|
|
68
|
-
_CreateAndConnectInput(target.directionRandomizer, "Direction Randomizer", source.directionRandomizer);
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
case "MeshParticleEmitter": {
|
|
72
|
-
const source = particleSystem.particleEmitterType;
|
|
73
|
-
shapeBlock = new MeshShapeBlock("Mesh shape");
|
|
74
|
-
const target = shapeBlock;
|
|
75
|
-
_CreateAndConnectInput(target.direction1, "Direction 1", source.direction1);
|
|
76
|
-
_CreateAndConnectInput(target.direction2, "Direction 2", source.direction2);
|
|
77
|
-
target.mesh = source.mesh;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!shapeBlock) {
|
|
82
|
-
throw new Error(`Unsupported particle emitter type: ${particleSystem.particleEmitterType.getClassName()}`);
|
|
83
|
-
}
|
|
84
|
-
createParticleBlock.particle.connectTo(shapeBlock.particle);
|
|
85
|
-
shapeBlock.output.connectTo(system.particle);
|
|
86
|
-
nodeParticleSystemSet.systemBlocks.push(system);
|
|
142
|
+
promises.push(_ExtractDatafromParticleSystemAsync(particleSystem, nodeParticleSystemSet));
|
|
87
143
|
}
|
|
144
|
+
await Promise.all(promises);
|
|
88
145
|
return nodeParticleSystemSet;
|
|
89
146
|
}
|
|
90
147
|
//# sourceMappingURL=nodeParticleSystemSet.helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeParticleSystemSet.helper.js","sourceRoot":"","sources":["../../../../../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UAAU,CAAC,CAAC;gBAE5E,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAY,CAAC;gBAClC,MAAM;YACV,CAAC;QACL,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,sCAAsC,cAAc,CAAC,mBAAmB,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QAC/G,CAAC;QAED,mBAAmB,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC5D,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE7C,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;IAED,OAAO,qBAAqB,CAAC;AACjC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { ParticleSystem } from \"../particleSystem\";\r\nimport { NodeParticleSystemSet } from \"./nodeParticleSystemSet\";\r\nimport { SystemBlock } from \"./Blocks/systemBlock\";\r\nimport { CreateParticleBlock } from \"./Blocks/Emitters/createParticleBlock\";\r\nimport { BoxShapeBlock } from \"./Blocks/Emitters/boxShapeBlock\";\r\nimport type { IShapeBlock } from \"./Blocks/Emitters/IShapeBlock\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleConnectionPoint } from \"./nodeParticleBlockConnectionPoint\";\r\nimport type { BoxParticleEmitter } from \"../EmitterTypes/boxParticleEmitter\";\r\nimport type { PointParticleEmitter } from \"../EmitterTypes/pointParticleEmitter\";\r\nimport type { SphereParticleEmitter } from \"../EmitterTypes/sphereParticleEmitter\";\r\nimport type { CylinderParticleEmitter, MeshParticleEmitter } from \"../EmitterTypes\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { ParticleInputBlock } from \"./Blocks/particleInputBlock\";\r\nimport { PointShapeBlock } from \"./Blocks/Emitters/pointShapeBlock\";\r\nimport { SphereShapeBlock } from \"./Blocks/Emitters/sphereShapeBlock\";\r\nimport { CylinderShapeBlock } from \"./Blocks/Emitters/cylinderShapeBlock\";\r\nimport { MeshShapeBlock } from \"./Blocks/Emitters/meshShapeBlock\";\r\n\r\nfunction _CreateAndConnectInput(connectionPoint: NodeParticleConnectionPoint, name: string, defaultValue: Vector3 | number) {\r\n const input = new ParticleInputBlock(name);\r\n input.value = defaultValue;\r\n input.output.connectTo(connectionPoint);\r\n}\r\n\r\n/**\r\n * Converts a ParticleSystem to a NodeParticleSystemSet.\r\n * @param name The name of the node particle system set.\r\n * @param particleSystems The particle systems to convert.\r\n * @returns The converted node particle system set or null if conversion failed.\r\n */\r\nexport function ConvertToNodeParticleSystemSet(name: string, particleSystems: ParticleSystem[]): Nullable<NodeParticleSystemSet> {\r\n if (!particleSystems || !particleSystems.length) {\r\n return null;\r\n }\r\n\r\n const nodeParticleSystemSet = new NodeParticleSystemSet(name);\r\n\r\n for (const particleSystem of particleSystems) {\r\n // Main system\r\n const system = new SystemBlock(particleSystem.name);\r\n\r\n // Create particle\r\n const createParticleBlock = new CreateParticleBlock(\"Create particle\");\r\n\r\n // Shape\r\n let shapeBlock: Nullable<IShapeBlock> = null;\r\n switch (particleSystem.particleEmitterType.getClassName()) {\r\n case \"BoxParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as BoxParticleEmitter;\r\n shapeBlock = new BoxShapeBlock(\"Box shape\");\r\n\r\n const target = shapeBlock as BoxShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n _CreateAndConnectInput(target.minEmitBox, \"Min Emit Box\", source.minEmitBox);\r\n _CreateAndConnectInput(target.maxEmitBox, \"Max Emit Box\", source.maxEmitBox);\r\n break;\r\n }\r\n case \"PointParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as PointParticleEmitter;\r\n shapeBlock = new PointShapeBlock(\"Point shape\");\r\n\r\n const target = shapeBlock as PointShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n break;\r\n }\r\n case \"SphereParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as SphereParticleEmitter;\r\n shapeBlock = new SphereShapeBlock(\"Sphere shape\");\r\n\r\n const target = shapeBlock as SphereShapeBlock;\r\n _CreateAndConnectInput(target.radius, \"Radius\", source.radius);\r\n _CreateAndConnectInput(target.radiusRange, \"Radius Range\", source.radiusRange);\r\n _CreateAndConnectInput(target.directionRandomizer, \"Direction Randomizer\", source.directionRandomizer);\r\n break;\r\n }\r\n case \"CylinderParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as CylinderParticleEmitter;\r\n shapeBlock = new CylinderShapeBlock(\"Cylinder shape\");\r\n\r\n const target = shapeBlock as CylinderShapeBlock;\r\n _CreateAndConnectInput(target.height, \"Height\", source.height);\r\n _CreateAndConnectInput(target.radius, \"Radius\", source.radius);\r\n _CreateAndConnectInput(target.radiusRange, \"Radius Range\", source.radiusRange);\r\n _CreateAndConnectInput(target.directionRandomizer, \"Direction Randomizer\", source.directionRandomizer);\r\n break;\r\n }\r\n case \"MeshParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as MeshParticleEmitter;\r\n shapeBlock = new MeshShapeBlock(\"Mesh shape\");\r\n\r\n const target = shapeBlock as MeshShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n\r\n target.mesh = source.mesh as Mesh;\r\n break;\r\n }\r\n }\r\n\r\n if (!shapeBlock) {\r\n throw new Error(`Unsupported particle emitter type: ${particleSystem.particleEmitterType.getClassName()}`);\r\n }\r\n\r\n createParticleBlock.particle.connectTo(shapeBlock.particle);\r\n shapeBlock.output.connectTo(system.particle);\r\n\r\n nodeParticleSystemSet.systemBlocks.push(system);\r\n }\r\n\r\n return nodeParticleSystemSet;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"nodeParticleSystemSet.helper.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleSystemSet.helper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAShE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,SAAS,sBAAsB,CAAC,eAA4C,EAAE,IAAY,EAAE,YAA8B;IACtH,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC;IAC3B,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAC5C,CAAC;AAED,KAAK,UAAU,mCAAmC,CAAC,cAA8B,EAAE,MAA6B;IAC5G,cAAc;IACd,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,CAAC,QAA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;QACJ,YAAY,CAAC,aAAa,GAAG,cAAc,CAAC,eAAe,CAAC;IAChE,CAAC;IACD,YAAY,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAE/C,0BAA0B;IAC1B,MAAM,wBAAwB,GAAG,IAAI,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;IACjF,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAE/D,uBAAuB;IACvB,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,CAAC,cAAc,CAAC,CAAC;IACxE,wBAAwB,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAC1E,qBAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAExD,WAAW;IACX,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,IAAY,EAAE,eAAiC;IACrG,IAAI,CAAC,eAAe,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAoB,EAAE,CAAC;IAErC,KAAK,MAAM,cAAc,IAAI,eAAe,EAAE,CAAC;QAC3C,QAAQ,CAAC,IAAI,CAAC,mCAAmC,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC9F,CAAC;IAED,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,qBAAqB,CAAC;AACjC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { ParticleSystem } from \"../particleSystem\";\r\nimport { NodeParticleSystemSet } from \"./nodeParticleSystemSet\";\r\nimport { SystemBlock } from \"./Blocks/systemBlock\";\r\nimport { CreateParticleBlock } from \"./Blocks/Emitters/createParticleBlock\";\r\nimport { BoxShapeBlock } from \"./Blocks/Emitters/boxShapeBlock\";\r\nimport type { IShapeBlock } from \"./Blocks/Emitters/IShapeBlock\";\r\nimport type { Vector3 } from \"core/Maths/math.vector\";\r\nimport type { NodeParticleConnectionPoint } from \"./nodeParticleBlockConnectionPoint\";\r\nimport type { BoxParticleEmitter } from \"../EmitterTypes/boxParticleEmitter\";\r\nimport type { PointParticleEmitter } from \"../EmitterTypes/pointParticleEmitter\";\r\nimport type { SphereParticleEmitter } from \"../EmitterTypes/sphereParticleEmitter\";\r\nimport type { CylinderParticleEmitter, MeshParticleEmitter } from \"../EmitterTypes\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\nimport { ParticleInputBlock } from \"./Blocks/particleInputBlock\";\r\nimport { PointShapeBlock } from \"./Blocks/Emitters/pointShapeBlock\";\r\nimport { SphereShapeBlock } from \"./Blocks/Emitters/sphereShapeBlock\";\r\nimport { CylinderShapeBlock } from \"./Blocks/Emitters/cylinderShapeBlock\";\r\nimport { MeshShapeBlock } from \"./Blocks/Emitters/meshShapeBlock\";\r\nimport { ParticleTextureSourceBlock } from \"./Blocks/particleSourceTextureBlock\";\r\nimport type { Texture } from \"../../Materials/Textures/texture\";\r\nimport { BasicPositionUpdateBlock } from \"./Blocks/Update/basicPositionUpdateBlock\";\r\nimport { BasicColorUpdateBlock } from \"./Blocks/Update/basicColorUpdateBlock\";\r\nimport { ParticleRandomBlock } from \"./Blocks/particleRandomBlock\";\r\n\r\nfunction _CreateAndConnectInput(connectionPoint: NodeParticleConnectionPoint, name: string, defaultValue: Vector3 | number) {\r\n const input = new ParticleInputBlock(name);\r\n input.value = defaultValue;\r\n input.output.connectTo(connectionPoint);\r\n}\r\n\r\nasync function _ExtractDatafromParticleSystemAsync(particleSystem: ParticleSystem, target: NodeParticleSystemSet) {\r\n // Main system\r\n const system = new SystemBlock(particleSystem.name);\r\n system.capacity = particleSystem.getCapacity();\r\n system.emitRate = particleSystem.emitRate;\r\n\r\n // Create particle\r\n const createParticleBlock = new CreateParticleBlock(\"Create particle\");\r\n\r\n // Shape\r\n let shapeBlock: Nullable<IShapeBlock> = null;\r\n switch (particleSystem.particleEmitterType.getClassName()) {\r\n case \"BoxParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as BoxParticleEmitter;\r\n shapeBlock = new BoxShapeBlock(\"Box shape\");\r\n\r\n const target = shapeBlock as BoxShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n _CreateAndConnectInput(target.minEmitBox, \"Min Emit Box\", source.minEmitBox);\r\n _CreateAndConnectInput(target.maxEmitBox, \"Max Emit Box\", source.maxEmitBox);\r\n break;\r\n }\r\n case \"PointParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as PointParticleEmitter;\r\n shapeBlock = new PointShapeBlock(\"Point shape\");\r\n\r\n const target = shapeBlock as PointShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n break;\r\n }\r\n case \"SphereParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as SphereParticleEmitter;\r\n shapeBlock = new SphereShapeBlock(\"Sphere shape\");\r\n\r\n const target = shapeBlock as SphereShapeBlock;\r\n _CreateAndConnectInput(target.radius, \"Radius\", source.radius);\r\n _CreateAndConnectInput(target.radiusRange, \"Radius Range\", source.radiusRange);\r\n _CreateAndConnectInput(target.directionRandomizer, \"Direction Randomizer\", source.directionRandomizer);\r\n break;\r\n }\r\n case \"CylinderParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as CylinderParticleEmitter;\r\n shapeBlock = new CylinderShapeBlock(\"Cylinder shape\");\r\n\r\n const target = shapeBlock as CylinderShapeBlock;\r\n _CreateAndConnectInput(target.height, \"Height\", source.height);\r\n _CreateAndConnectInput(target.radius, \"Radius\", source.radius);\r\n _CreateAndConnectInput(target.radiusRange, \"Radius Range\", source.radiusRange);\r\n _CreateAndConnectInput(target.directionRandomizer, \"Direction Randomizer\", source.directionRandomizer);\r\n break;\r\n }\r\n case \"MeshParticleEmitter\": {\r\n const source = particleSystem.particleEmitterType as MeshParticleEmitter;\r\n shapeBlock = new MeshShapeBlock(\"Mesh shape\");\r\n\r\n const target = shapeBlock as MeshShapeBlock;\r\n _CreateAndConnectInput(target.direction1, \"Direction 1\", source.direction1);\r\n _CreateAndConnectInput(target.direction2, \"Direction 2\", source.direction2);\r\n\r\n target.mesh = source.mesh as Mesh;\r\n break;\r\n }\r\n }\r\n\r\n if (!shapeBlock) {\r\n throw new Error(`Unsupported particle emitter type: ${particleSystem.particleEmitterType.getClassName()}`);\r\n }\r\n\r\n createParticleBlock.particle.connectTo(shapeBlock.particle);\r\n createParticleBlock.colorDead.value = particleSystem.colorDead;\r\n\r\n // Color\r\n const color0Block = new ParticleInputBlock(\"Color0\");\r\n color0Block.value = particleSystem.color1;\r\n\r\n const color1Block = new ParticleInputBlock(\"Color1\");\r\n color1Block.value = particleSystem.color2;\r\n\r\n const randomColorBlock = new ParticleRandomBlock(\"Random Color\");\r\n color0Block.output.connectTo(randomColorBlock.min);\r\n color1Block.output.connectTo(randomColorBlock.max);\r\n\r\n randomColorBlock.output.connectTo(createParticleBlock.color);\r\n\r\n // Emit power\r\n const minEmitPowerBlock = new ParticleInputBlock(\"Min Emit Power\");\r\n minEmitPowerBlock.value = particleSystem.minEmitPower;\r\n\r\n const maxEmitPowerBlock = new ParticleInputBlock(\"Max Emit Power\");\r\n maxEmitPowerBlock.value = particleSystem.maxEmitPower;\r\n\r\n const randomEmitPowerBlock = new ParticleRandomBlock(\"Random Emit Power\");\r\n minEmitPowerBlock.output.connectTo(randomEmitPowerBlock.min);\r\n maxEmitPowerBlock.output.connectTo(randomEmitPowerBlock.max);\r\n\r\n randomEmitPowerBlock.output.connectTo(createParticleBlock.emitPower);\r\n\r\n // Lifetime\r\n const minLifetimeBlock = new ParticleInputBlock(\"Min Lifetime\");\r\n minLifetimeBlock.value = particleSystem.minLifeTime;\r\n\r\n const maxLifetimeBlock = new ParticleInputBlock(\"Max Lifetime\");\r\n maxLifetimeBlock.value = particleSystem.maxLifeTime;\r\n\r\n const randomLifetimeBlock = new ParticleRandomBlock(\"Random Lifetime\");\r\n minLifetimeBlock.output.connectTo(randomLifetimeBlock.min);\r\n maxLifetimeBlock.output.connectTo(randomLifetimeBlock.max);\r\n\r\n randomLifetimeBlock.output.connectTo(createParticleBlock.lifeTime);\r\n\r\n // Texture\r\n const textureBlock = new ParticleTextureSourceBlock(\"Texture\");\r\n const url = (particleSystem.particleTexture as Texture).url || \"\";\r\n if (url) {\r\n textureBlock.url = url;\r\n } else {\r\n textureBlock.sourceTexture = particleSystem.particleTexture;\r\n }\r\n textureBlock.texture.connectTo(system.texture);\r\n\r\n // Default position update\r\n const basicPositionUpdateBlock = new BasicPositionUpdateBlock(\"Position update\");\r\n shapeBlock.output.connectTo(basicPositionUpdateBlock.particle);\r\n\r\n // Default color update\r\n const basicColorUpdateBlock = new BasicColorUpdateBlock(\"Color update\");\r\n basicPositionUpdateBlock.output.connectTo(basicColorUpdateBlock.particle);\r\n basicColorUpdateBlock.output.connectTo(system.particle);\r\n\r\n // Register\r\n target.systemBlocks.push(system);\r\n}\r\n\r\n/**\r\n * Converts a ParticleSystem to a NodeParticleSystemSet.\r\n * @param name The name of the node particle system set.\r\n * @param particleSystems The particle systems to convert.\r\n * @returns The converted node particle system set or null if conversion failed.\r\n * #0K3AQ2#3627\r\n */\r\nexport async function ConvertToNodeParticleSystemSetAsync(name: string, particleSystems: ParticleSystem[]): Promise<Nullable<NodeParticleSystemSet>> {\r\n if (!particleSystems || !particleSystems.length) {\r\n return null;\r\n }\r\n\r\n const nodeParticleSystemSet = new NodeParticleSystemSet(name);\r\n const promises: Promise<void>[] = [];\r\n\r\n for (const particleSystem of particleSystems) {\r\n promises.push(_ExtractDatafromParticleSystemAsync(particleSystem, nodeParticleSystemSet));\r\n }\r\n\r\n await Promise.all(promises);\r\n return nodeParticleSystemSet;\r\n}\r\n"]}
|
|
@@ -201,6 +201,7 @@ export class NodeParticleSystemSet {
|
|
|
201
201
|
state.verbose = verbose;
|
|
202
202
|
const system = block.createSystem(state);
|
|
203
203
|
system._source = this;
|
|
204
|
+
system._blockReference = block._internalId;
|
|
204
205
|
// Errors
|
|
205
206
|
state.emitErrors();
|
|
206
207
|
output.systems.push(system);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeParticleSystemSet.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleSystemSet.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iCAA6B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,+CAA2C;AACzE,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAClD,OAAO,EAAE,QAAQ,EAAE,gCAA4B;AAC/C,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAClD,OAAO,EAAE,SAAS,EAAE,mCAA+B;AACnD,OAAO,EAAE,KAAK,EAAE,4BAAwB;AACxC,OAAO,EAAE,cAAc,EAAE,wCAAoC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,2BAA2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ialize } from \"core/Misc/decorators\";\r\nimport { ParticleSystemSet } from \"../particleSystemSet\";\r\nimport { SystemBlock } from \"./Blocks/systemBlock\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { NodeParticleBuildState } from \"./nodeParticleBuildState\";\r\nimport type { NodeParticleBlock } from \"./nodeParticleBlock\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { GetClass } from \"core/Misc/typeStore\";\r\nimport { WebRequest } from \"core/Misc/webRequest\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ParticleInputBlock } from \"./Blocks/particleInputBlock\";\r\nimport { ParticleTextureSourceBlock } from \"./Blocks/particleSourceTextureBlock\";\r\nimport { NodeParticleContextualSources } from \"./Enums/nodeParticleContextualSources\";\r\nimport { UpdatePositionBlock } from \"./Blocks/Update/updatePositionBlock\";\r\nimport { ParticleMathBlock, ParticleMathBlockOperations } from \"./Blocks/particleMathBlock\";\r\nimport type { ParticleTeleportOutBlock } from \"./Blocks/Teleport/particleTeleportOutBlock\";\r\nimport type { ParticleTeleportInBlock } from \"./Blocks/Teleport/particleTeleportInBlock\";\r\nimport { BoxShapeBlock } from \"./Blocks/Emitters/boxShapeBlock\";\r\nimport { CreateParticleBlock } from \"./Blocks/Emitters/createParticleBlock\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n// declare NODEPARTICLEEDITOR namespace for compilation issue\r\ndeclare let NODEPARTICLEEDITOR: any;\r\ndeclare let BABYLON: any;\r\n\r\n/**\r\n * Interface used to configure the node particle editor\r\n */\r\nexport interface INodeParticleEditorOptions {\r\n /** Define the URL to load node editor script from */\r\n editorURL?: string;\r\n /** Additional configuration for the NPE */\r\n nodeEditorConfig?: {\r\n backgroundColor?: Color4;\r\n };\r\n}\r\n\r\n/**\r\n * Defines a set of particle systems defined as a node graph.\r\n * NPE: #K6F1ZB#1\r\n * PG: #ZT509U#1\r\n */\r\nexport class NodeParticleSystemSet {\r\n private _systemBlocks: SystemBlock[] = [];\r\n private _buildId: number = 0;\r\n\r\n /** Define the Url to load node editor script */\r\n public static EditorURL = `${Tools._DefaultCdnUrl}/v${AbstractEngine.Version}/nodeParticleEditor/babylon.nodeParticleEditor.js`;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /**\r\n * Snippet ID if the material was created from the snippet server\r\n */\r\n public snippetId: string;\r\n\r\n /**\r\n * Gets an array of blocks that needs to be serialized even if they are not yet connected\r\n */\r\n public attachedBlocks: NodeParticleBlock[] = [];\r\n\r\n /**\r\n * Gets or sets data used by visual editor\r\n * @see https://npe.babylonjs.com\r\n */\r\n public editorData: any = null;\r\n\r\n /**\r\n * Observable raised when the particle set is built\r\n */\r\n public onBuildObservable = new Observable<NodeParticleSystemSet>();\r\n\r\n /**\r\n * The name of the set\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * A free comment about the set\r\n */\r\n @serialize(\"comment\")\r\n public comment: string;\r\n\r\n /**\r\n * Gets the system blocks\r\n */\r\n public get systemBlocks(): SystemBlock[] {\r\n return this._systemBlocks;\r\n }\r\n\r\n /**\r\n * Gets the list of input blocks attached to this material\r\n * @returns an array of InputBlocks\r\n */\r\n public get inputBlocks() {\r\n const blocks: ParticleInputBlock[] = [];\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput) {\r\n blocks.push(block as ParticleInputBlock);\r\n }\r\n }\r\n\r\n return blocks;\r\n }\r\n\r\n /**\r\n * Get a block by its name\r\n * @param name defines the name of the block to retrieve\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByName(name: string) {\r\n let result = null;\r\n for (const block of this.attachedBlocks) {\r\n if (block.name === name) {\r\n if (!result) {\r\n result = block;\r\n } else {\r\n Tools.Warn(\"More than one block was found with the name `\" + name + \"`\");\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Get a block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByPredicate(predicate: (block: NodeParticleBlock) => boolean) {\r\n for (const block of this.attachedBlocks) {\r\n if (predicate(block)) {\r\n return block;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Get an input block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required input block or null if not found\r\n */\r\n public getInputBlockByPredicate(predicate: (block: ParticleInputBlock) => boolean): Nullable<ParticleInputBlock> {\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput && predicate(block as ParticleInputBlock)) {\r\n return block as ParticleInputBlock;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n /**\r\n * Creates a new set\r\n * @param name defines the name of the set\r\n */\r\n public constructor(name: string) {\r\n this.name = name;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the geometry e.g. \"NodeParticleSystemSet\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeParticleSystemSet\";\r\n }\r\n\r\n private _initializeBlock(node: NodeParticleBlock, autoConfigure = true) {\r\n if (this.attachedBlocks.indexOf(node) === -1) {\r\n this.attachedBlocks.push(node);\r\n }\r\n\r\n for (const input of node.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== node) {\r\n this._initializeBlock(block, autoConfigure);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private BJSNODEPARTICLEEDITOR = this._getGlobalNodeParticleEditor();\r\n\r\n /** Get the editor from bundle or global\r\n * @returns the global NPE\r\n */\r\n private _getGlobalNodeParticleEditor(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof NODEPARTICLEEDITOR !== \"undefined\") {\r\n return NODEPARTICLEEDITOR;\r\n }\r\n\r\n // In case of module let's check the global emitted from the editor entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.NodeParticleEditor !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Creates the node editor window.\r\n * @param additionalConfig Define the configuration of the editor\r\n */\r\n private _createNodeParticleEditor(additionalConfig?: any) {\r\n const nodeEditorConfig: any = {\r\n nodeParticleSet: this,\r\n ...additionalConfig,\r\n };\r\n this.BJSNODEPARTICLEEDITOR.NodeParticleEditor.Show(nodeEditorConfig);\r\n }\r\n\r\n /**\r\n * Launch the node particle editor\r\n * @param config Define the configuration of the editor\r\n * @returns a promise fulfilled when the node editor is visible\r\n */\r\n public async editAsync(config?: INodeParticleEditorOptions): Promise<void> {\r\n return await new Promise((resolve) => {\r\n this.BJSNODEPARTICLEEDITOR = this.BJSNODEPARTICLEEDITOR || this._getGlobalNodeParticleEditor();\r\n if (typeof this.BJSNODEPARTICLEEDITOR == \"undefined\") {\r\n const editorUrl = config && config.editorURL ? config.editorURL : NodeParticleSystemSet.EditorURL;\r\n\r\n // Load editor and add it to the DOM\r\n Tools.LoadBabylonScript(editorUrl, () => {\r\n this.BJSNODEPARTICLEEDITOR = this.BJSNODEPARTICLEEDITOR || this._getGlobalNodeParticleEditor();\r\n this._createNodeParticleEditor(config?.nodeEditorConfig);\r\n resolve();\r\n });\r\n } else {\r\n // Otherwise creates the editor\r\n this._createNodeParticleEditor(config?.nodeEditorConfig);\r\n resolve();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Builds the particle system set from the defined blocks.\r\n * @param scene defines the hosting scene\r\n * @param verbose defines whether to log detailed information during the build process (false by default)\r\n * @returns a promise that resolves to the built particle system set\r\n */\r\n public async buildAsync(scene: Scene, verbose = false): Promise<ParticleSystemSet> {\r\n return await new Promise<ParticleSystemSet>((resolve) => {\r\n const output = new ParticleSystemSet();\r\n\r\n // Initialize all blocks\r\n for (const block of this._systemBlocks) {\r\n this._initializeBlock(block);\r\n }\r\n\r\n // Build the blocks\r\n for (const block of this.systemBlocks) {\r\n const state = new NodeParticleBuildState();\r\n state.buildId = this._buildId++;\r\n state.scene = scene;\r\n state.verbose = verbose;\r\n\r\n const system = block.createSystem(state);\r\n system._source = this;\r\n\r\n // Errors\r\n state.emitErrors();\r\n\r\n output.systems.push(system);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n\r\n resolve(output);\r\n });\r\n }\r\n\r\n /**\r\n * Clear the current geometry\r\n */\r\n public clear() {\r\n this.attachedBlocks.length = 0;\r\n this._systemBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * Clear the current set and restore it to a default state\r\n */\r\n public setToDefault() {\r\n this.clear();\r\n\r\n this.editorData = null;\r\n\r\n // Main system\r\n const system = new SystemBlock(\"Particle system\");\r\n\r\n // Update position\r\n const updatePositionBlock = new UpdatePositionBlock(\"Update position\");\r\n updatePositionBlock.output.connectTo(system.particle);\r\n\r\n // Contextual inputs\r\n const positionBlock = new ParticleInputBlock(\"Position\");\r\n positionBlock.contextualValue = NodeParticleContextualSources.Position;\r\n const directionBlock = new ParticleInputBlock(\"Scaled direction\");\r\n directionBlock.contextualValue = NodeParticleContextualSources.ScaledDirection;\r\n\r\n // Add\r\n const addBlock = new ParticleMathBlock(\"Add\");\r\n addBlock.operation = ParticleMathBlockOperations.Add;\r\n positionBlock.output.connectTo(addBlock.left);\r\n directionBlock.output.connectTo(addBlock.right);\r\n addBlock.output.connectTo(updatePositionBlock.position);\r\n\r\n // Create particle\r\n const createParticleBlock = new CreateParticleBlock(\"Create particle\");\r\n\r\n // Shape\r\n const emitterShape = new BoxShapeBlock(\"Box shape\");\r\n createParticleBlock.particle.connectTo(emitterShape.particle);\r\n emitterShape.output.connectTo(updatePositionBlock.particle);\r\n\r\n // Texture\r\n const textureBlock = new ParticleTextureSourceBlock(\"Texture\");\r\n textureBlock.texture.connectTo(system.texture);\r\n textureBlock.url = \"https://assets.babylonjs.com/textures/flare.png\";\r\n\r\n this._systemBlocks.push(system);\r\n }\r\n\r\n /**\r\n * Remove a block from the current system set\r\n * @param block defines the block to remove\r\n */\r\n public removeBlock(block: NodeParticleBlock) {\r\n const attachedBlockIndex = this.attachedBlocks.indexOf(block);\r\n if (attachedBlockIndex > -1) {\r\n this.attachedBlocks.splice(attachedBlockIndex, 1);\r\n }\r\n\r\n if (block.isSystem) {\r\n const index = this._systemBlocks.indexOf(block as SystemBlock);\r\n if (index > -1) {\r\n this._systemBlocks.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current graph and load a new one from a serialization object\r\n * @param source defines the JSON representation of the particle set\r\n * @param merge defines whether or not the source must be merged or replace the current content\r\n */\r\n public parseSerializedObject(source: any, merge = false) {\r\n if (!merge) {\r\n this.clear();\r\n }\r\n\r\n const map: { [key: number]: NodeParticleBlock } = {};\r\n\r\n // Create blocks\r\n for (const parsedBlock of source.blocks) {\r\n const blockType = GetClass(parsedBlock.customType);\r\n if (blockType) {\r\n const block: NodeParticleBlock = new blockType();\r\n block._deserialize(parsedBlock);\r\n map[parsedBlock.id] = block;\r\n\r\n this.attachedBlocks.push(block);\r\n\r\n if (block.isSystem) {\r\n this._systemBlocks.push(block as SystemBlock);\r\n }\r\n }\r\n }\r\n\r\n // Reconnect teleportation\r\n for (const block of this.attachedBlocks) {\r\n if (block.isTeleportOut) {\r\n const teleportOut = block as ParticleTeleportOutBlock;\r\n const id = teleportOut._tempEntryPointUniqueId;\r\n if (id) {\r\n const source = map[id] as ParticleTeleportInBlock;\r\n if (source) {\r\n source.attachToEndpoint(teleportOut);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Connections - Starts with input blocks only (except if in \"merge\" mode where we scan all blocks)\r\n for (let blockIndex = 0; blockIndex < source.blocks.length; blockIndex++) {\r\n const parsedBlock = source.blocks[blockIndex];\r\n const block = map[parsedBlock.id];\r\n\r\n if (!block) {\r\n continue;\r\n }\r\n\r\n if (block.inputs.length && parsedBlock.inputs.some((i: any) => i.targetConnectionName) && !merge) {\r\n continue;\r\n }\r\n this._restoreConnections(block, source, map);\r\n }\r\n\r\n // UI related info\r\n if (source.locations || (source.editorData && source.editorData.locations)) {\r\n const locations: {\r\n blockId: number;\r\n x: number;\r\n y: number;\r\n isCollapsed: boolean;\r\n }[] = source.locations || source.editorData.locations;\r\n\r\n for (const location of locations) {\r\n if (map[location.blockId]) {\r\n location.blockId = map[location.blockId].uniqueId;\r\n }\r\n }\r\n\r\n if (merge && this.editorData && this.editorData.locations) {\r\n locations.concat(this.editorData.locations);\r\n }\r\n\r\n if (source.locations) {\r\n this.editorData = {\r\n locations: locations,\r\n };\r\n } else {\r\n this.editorData = source.editorData;\r\n this.editorData.locations = locations;\r\n }\r\n\r\n const blockMap: number[] = [];\r\n\r\n for (const key in map) {\r\n blockMap[key] = map[key].uniqueId;\r\n }\r\n\r\n this.editorData.map = blockMap;\r\n }\r\n\r\n this.comment = source.comment;\r\n }\r\n\r\n private _restoreConnections(block: NodeParticleBlock, source: any, map: { [key: number]: NodeParticleBlock }) {\r\n for (const outputPoint of block.outputs) {\r\n for (const candidate of source.blocks) {\r\n const target = map[candidate.id];\r\n\r\n if (!target) {\r\n continue;\r\n }\r\n\r\n for (const input of candidate.inputs) {\r\n if (map[input.targetBlockId] === block && input.targetConnectionName === outputPoint.name) {\r\n const inputPoint = target.getInputByName(input.inputName);\r\n if (!inputPoint || inputPoint.isConnected) {\r\n continue;\r\n }\r\n\r\n outputPoint.connectTo(inputPoint, true);\r\n this._restoreConnections(target, source, map);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this geometry in a JSON representation\r\n * @param selectedBlocks defines the list of blocks to save (if null the whole geometry will be saved)\r\n * @returns the serialized particle system set object\r\n */\r\n public serialize(selectedBlocks?: NodeParticleBlock[]): any {\r\n const serializationObject = selectedBlocks ? {} : SerializationHelper.Serialize(this);\r\n serializationObject.editorData = JSON.parse(JSON.stringify(this.editorData)); // Copy\r\n\r\n let blocks: NodeParticleBlock[] = [];\r\n\r\n if (selectedBlocks) {\r\n blocks = selectedBlocks;\r\n } else {\r\n serializationObject.customType = \"BABYLON.NodeParticleSystemSet\";\r\n }\r\n\r\n // Blocks\r\n serializationObject.blocks = [];\r\n\r\n for (const block of blocks) {\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n\r\n if (!selectedBlocks) {\r\n for (const block of this.attachedBlocks) {\r\n if (blocks.indexOf(block) !== -1) {\r\n continue;\r\n }\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current particle system set.\r\n * @param name defines the name to use for the new particle system set\r\n * @returns the cloned particle system set\r\n */\r\n public clone(name: string): NodeParticleSystemSet {\r\n const serializationObject = this.serialize();\r\n\r\n const clone = SerializationHelper.Clone(() => new NodeParticleSystemSet(name), this);\r\n clone.name = name;\r\n clone.snippetId = this.snippetId;\r\n\r\n clone.parseSerializedObject(serializationObject);\r\n clone._buildId = this._buildId;\r\n\r\n return clone;\r\n }\r\n\r\n /**\r\n * Disposes the resources\r\n */\r\n public dispose(): void {\r\n for (const block of this.attachedBlocks) {\r\n block.dispose();\r\n }\r\n\r\n this.attachedBlocks.length = 0;\r\n this.onBuildObservable.clear();\r\n }\r\n\r\n /**\r\n * Creates a new node particle set set to default basic configuration\r\n * @param name defines the name of the particle set\r\n * @returns a new NodeParticleSystemSet\r\n */\r\n public static CreateDefault(name: string) {\r\n const nodeParticleSet = new NodeParticleSystemSet(name);\r\n\r\n nodeParticleSet.setToDefault();\r\n\r\n return nodeParticleSet;\r\n }\r\n\r\n /**\r\n * Creates a node particle set from parsed data\r\n * @param source defines the JSON representation of the particle set\r\n * @returns a new node particle set\r\n */\r\n public static Parse(source: any): NodeParticleSystemSet {\r\n const nodeParticleSet = SerializationHelper.Parse(() => new NodeParticleSystemSet(source.name), source, null);\r\n\r\n nodeParticleSet.parseSerializedObject(source);\r\n\r\n return nodeParticleSet;\r\n }\r\n\r\n /**\r\n * Creates a node particle set from a snippet saved by the node geometry editor\r\n * @param snippetId defines the snippet to load\r\n * @param nodeParticleSet defines a node particle set to update (instead of creating a new one)\r\n * @returns a promise that will resolve to the new node geometry\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public static ParseFromSnippetAsync(snippetId: string, nodeParticleSet?: NodeParticleSystemSet): Promise<NodeParticleSystemSet> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(NodeParticleSystemSet.CreateDefault(\"blank\"));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.nodeParticle);\r\n\r\n if (!nodeParticleSet) {\r\n nodeParticleSet = SerializationHelper.Parse(() => new NodeParticleSystemSet(snippetId), serializationObject, null);\r\n }\r\n\r\n nodeParticleSet.parseSerializedObject(serializationObject);\r\n nodeParticleSet.snippetId = snippetId;\r\n\r\n try {\r\n resolve(nodeParticleSet);\r\n } catch (err) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(err);\r\n }\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"nodeParticleSystemSet.js","sourceRoot":"","sources":["../../../../../dev/core/src/Particles/Node/nodeParticleSystemSet.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iCAA6B;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MA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AM,CAAC,GAAG,CAAC,CAAC;wBAChB,CAAC;oBACL,CAAC;yBAAM,CAAC;wBACJ,2EAA2E;wBAC3E,MAAM,CAAC,6BAA6B,GAAG,SAAS,CAAC,CAAC;oBACtD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,GAAG,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;YAC1E,OAAO,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACP,CAAC;;AAnjBD,gDAAgD;AAClC,+BAAS,GAAG,GAAG,KAAK,CAAC,cAAc,KAAK,cAAc,CAAC,OAAO,mDAAmD,AAAxG,CAAyG;AAEhI,sCAAsC;AACxB,gCAAU,GAAG,SAAS,CAAC,UAAU,AAAvB,CAAwB;AA2BzC;IADN,SAAS,EAAE;mDACQ;AAMb;IADN,SAAS,CAAC,SAAS,CAAC;sDACE","sourcesContent":["import { serialize } from \"core/Misc/decorators\";\r\nimport { ParticleSystemSet } from \"../particleSystemSet\";\r\nimport { SystemBlock } from \"./Blocks/systemBlock\";\r\nimport type { Scene } from \"core/scene\";\r\nimport { NodeParticleBuildState } from \"./nodeParticleBuildState\";\r\nimport type { NodeParticleBlock } from \"./nodeParticleBlock\";\r\nimport { SerializationHelper } from \"core/Misc/decorators.serialization\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { GetClass } from \"core/Misc/typeStore\";\r\nimport { WebRequest } from \"core/Misc/webRequest\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { ParticleInputBlock } from \"./Blocks/particleInputBlock\";\r\nimport { ParticleTextureSourceBlock } from \"./Blocks/particleSourceTextureBlock\";\r\nimport { NodeParticleContextualSources } from \"./Enums/nodeParticleContextualSources\";\r\nimport { UpdatePositionBlock } from \"./Blocks/Update/updatePositionBlock\";\r\nimport { ParticleMathBlock, ParticleMathBlockOperations } from \"./Blocks/particleMathBlock\";\r\nimport type { ParticleTeleportOutBlock } from \"./Blocks/Teleport/particleTeleportOutBlock\";\r\nimport type { ParticleTeleportInBlock } from \"./Blocks/Teleport/particleTeleportInBlock\";\r\nimport { BoxShapeBlock } from \"./Blocks/Emitters/boxShapeBlock\";\r\nimport { CreateParticleBlock } from \"./Blocks/Emitters/createParticleBlock\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\n// declare NODEPARTICLEEDITOR namespace for compilation issue\r\ndeclare let NODEPARTICLEEDITOR: any;\r\ndeclare let BABYLON: any;\r\n\r\n/**\r\n * Interface used to configure the node particle editor\r\n */\r\nexport interface INodeParticleEditorOptions {\r\n /** Define the URL to load node editor script from */\r\n editorURL?: string;\r\n /** Additional configuration for the NPE */\r\n nodeEditorConfig?: {\r\n backgroundColor?: Color4;\r\n };\r\n}\r\n\r\n/**\r\n * Defines a set of particle systems defined as a node graph.\r\n * NPE: #K6F1ZB#1\r\n * PG: #ZT509U#1\r\n */\r\nexport class NodeParticleSystemSet {\r\n private _systemBlocks: SystemBlock[] = [];\r\n private _buildId: number = 0;\r\n\r\n /** Define the Url to load node editor script */\r\n public static EditorURL = `${Tools._DefaultCdnUrl}/v${AbstractEngine.Version}/nodeParticleEditor/babylon.nodeParticleEditor.js`;\r\n\r\n /** Define the Url to load snippets */\r\n public static SnippetUrl = Constants.SnippetUrl;\r\n\r\n /**\r\n * Snippet ID if the material was created from the snippet server\r\n */\r\n public snippetId: string;\r\n\r\n /**\r\n * Gets an array of blocks that needs to be serialized even if they are not yet connected\r\n */\r\n public attachedBlocks: NodeParticleBlock[] = [];\r\n\r\n /**\r\n * Gets or sets data used by visual editor\r\n * @see https://npe.babylonjs.com\r\n */\r\n public editorData: any = null;\r\n\r\n /**\r\n * Observable raised when the particle set is built\r\n */\r\n public onBuildObservable = new Observable<NodeParticleSystemSet>();\r\n\r\n /**\r\n * The name of the set\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * A free comment about the set\r\n */\r\n @serialize(\"comment\")\r\n public comment: string;\r\n\r\n /**\r\n * Gets the system blocks\r\n */\r\n public get systemBlocks(): SystemBlock[] {\r\n return this._systemBlocks;\r\n }\r\n\r\n /**\r\n * Gets the list of input blocks attached to this material\r\n * @returns an array of InputBlocks\r\n */\r\n public get inputBlocks() {\r\n const blocks: ParticleInputBlock[] = [];\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput) {\r\n blocks.push(block as ParticleInputBlock);\r\n }\r\n }\r\n\r\n return blocks;\r\n }\r\n\r\n /**\r\n * Get a block by its name\r\n * @param name defines the name of the block to retrieve\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByName(name: string) {\r\n let result = null;\r\n for (const block of this.attachedBlocks) {\r\n if (block.name === name) {\r\n if (!result) {\r\n result = block;\r\n } else {\r\n Tools.Warn(\"More than one block was found with the name `\" + name + \"`\");\r\n return result;\r\n }\r\n }\r\n }\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Get a block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required block or null if not found\r\n */\r\n public getBlockByPredicate(predicate: (block: NodeParticleBlock) => boolean) {\r\n for (const block of this.attachedBlocks) {\r\n if (predicate(block)) {\r\n return block;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /**\r\n * Get an input block using a predicate\r\n * @param predicate defines the predicate used to find the good candidate\r\n * @returns the required input block or null if not found\r\n */\r\n public getInputBlockByPredicate(predicate: (block: ParticleInputBlock) => boolean): Nullable<ParticleInputBlock> {\r\n for (const block of this.attachedBlocks) {\r\n if (block.isInput && predicate(block as ParticleInputBlock)) {\r\n return block as ParticleInputBlock;\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n /**\r\n * Creates a new set\r\n * @param name defines the name of the set\r\n */\r\n public constructor(name: string) {\r\n this.name = name;\r\n }\r\n\r\n /**\r\n * Gets the current class name of the geometry e.g. \"NodeParticleSystemSet\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"NodeParticleSystemSet\";\r\n }\r\n\r\n private _initializeBlock(node: NodeParticleBlock, autoConfigure = true) {\r\n if (this.attachedBlocks.indexOf(node) === -1) {\r\n this.attachedBlocks.push(node);\r\n }\r\n\r\n for (const input of node.inputs) {\r\n const connectedPoint = input.connectedPoint;\r\n if (connectedPoint) {\r\n const block = connectedPoint.ownerBlock;\r\n if (block !== node) {\r\n this._initializeBlock(block, autoConfigure);\r\n }\r\n }\r\n }\r\n }\r\n\r\n private BJSNODEPARTICLEEDITOR = this._getGlobalNodeParticleEditor();\r\n\r\n /** Get the editor from bundle or global\r\n * @returns the global NPE\r\n */\r\n private _getGlobalNodeParticleEditor(): any {\r\n // UMD Global name detection from Webpack Bundle UMD Name.\r\n if (typeof NODEPARTICLEEDITOR !== \"undefined\") {\r\n return NODEPARTICLEEDITOR;\r\n }\r\n\r\n // In case of module let's check the global emitted from the editor entry point.\r\n if (typeof BABYLON !== \"undefined\" && typeof BABYLON.NodeParticleEditor !== \"undefined\") {\r\n return BABYLON;\r\n }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Creates the node editor window.\r\n * @param additionalConfig Define the configuration of the editor\r\n */\r\n private _createNodeParticleEditor(additionalConfig?: any) {\r\n const nodeEditorConfig: any = {\r\n nodeParticleSet: this,\r\n ...additionalConfig,\r\n };\r\n this.BJSNODEPARTICLEEDITOR.NodeParticleEditor.Show(nodeEditorConfig);\r\n }\r\n\r\n /**\r\n * Launch the node particle editor\r\n * @param config Define the configuration of the editor\r\n * @returns a promise fulfilled when the node editor is visible\r\n */\r\n public async editAsync(config?: INodeParticleEditorOptions): Promise<void> {\r\n return await new Promise((resolve) => {\r\n this.BJSNODEPARTICLEEDITOR = this.BJSNODEPARTICLEEDITOR || this._getGlobalNodeParticleEditor();\r\n if (typeof this.BJSNODEPARTICLEEDITOR == \"undefined\") {\r\n const editorUrl = config && config.editorURL ? config.editorURL : NodeParticleSystemSet.EditorURL;\r\n\r\n // Load editor and add it to the DOM\r\n Tools.LoadBabylonScript(editorUrl, () => {\r\n this.BJSNODEPARTICLEEDITOR = this.BJSNODEPARTICLEEDITOR || this._getGlobalNodeParticleEditor();\r\n this._createNodeParticleEditor(config?.nodeEditorConfig);\r\n resolve();\r\n });\r\n } else {\r\n // Otherwise creates the editor\r\n this._createNodeParticleEditor(config?.nodeEditorConfig);\r\n resolve();\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Builds the particle system set from the defined blocks.\r\n * @param scene defines the hosting scene\r\n * @param verbose defines whether to log detailed information during the build process (false by default)\r\n * @returns a promise that resolves to the built particle system set\r\n */\r\n public async buildAsync(scene: Scene, verbose = false): Promise<ParticleSystemSet> {\r\n return await new Promise<ParticleSystemSet>((resolve) => {\r\n const output = new ParticleSystemSet();\r\n\r\n // Initialize all blocks\r\n for (const block of this._systemBlocks) {\r\n this._initializeBlock(block);\r\n }\r\n\r\n // Build the blocks\r\n for (const block of this.systemBlocks) {\r\n const state = new NodeParticleBuildState();\r\n state.buildId = this._buildId++;\r\n state.scene = scene;\r\n state.verbose = verbose;\r\n\r\n const system = block.createSystem(state);\r\n system._source = this;\r\n system._blockReference = block._internalId;\r\n\r\n // Errors\r\n state.emitErrors();\r\n\r\n output.systems.push(system);\r\n }\r\n\r\n this.onBuildObservable.notifyObservers(this);\r\n\r\n resolve(output);\r\n });\r\n }\r\n\r\n /**\r\n * Clear the current geometry\r\n */\r\n public clear() {\r\n this.attachedBlocks.length = 0;\r\n this._systemBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * Clear the current set and restore it to a default state\r\n */\r\n public setToDefault() {\r\n this.clear();\r\n\r\n this.editorData = null;\r\n\r\n // Main system\r\n const system = new SystemBlock(\"Particle system\");\r\n\r\n // Update position\r\n const updatePositionBlock = new UpdatePositionBlock(\"Update position\");\r\n updatePositionBlock.output.connectTo(system.particle);\r\n\r\n // Contextual inputs\r\n const positionBlock = new ParticleInputBlock(\"Position\");\r\n positionBlock.contextualValue = NodeParticleContextualSources.Position;\r\n const directionBlock = new ParticleInputBlock(\"Scaled direction\");\r\n directionBlock.contextualValue = NodeParticleContextualSources.ScaledDirection;\r\n\r\n // Add\r\n const addBlock = new ParticleMathBlock(\"Add\");\r\n addBlock.operation = ParticleMathBlockOperations.Add;\r\n positionBlock.output.connectTo(addBlock.left);\r\n directionBlock.output.connectTo(addBlock.right);\r\n addBlock.output.connectTo(updatePositionBlock.position);\r\n\r\n // Create particle\r\n const createParticleBlock = new CreateParticleBlock(\"Create particle\");\r\n\r\n // Shape\r\n const emitterShape = new BoxShapeBlock(\"Box shape\");\r\n createParticleBlock.particle.connectTo(emitterShape.particle);\r\n emitterShape.output.connectTo(updatePositionBlock.particle);\r\n\r\n // Texture\r\n const textureBlock = new ParticleTextureSourceBlock(\"Texture\");\r\n textureBlock.texture.connectTo(system.texture);\r\n textureBlock.url = \"https://assets.babylonjs.com/textures/flare.png\";\r\n\r\n this._systemBlocks.push(system);\r\n }\r\n\r\n /**\r\n * Remove a block from the current system set\r\n * @param block defines the block to remove\r\n */\r\n public removeBlock(block: NodeParticleBlock) {\r\n const attachedBlockIndex = this.attachedBlocks.indexOf(block);\r\n if (attachedBlockIndex > -1) {\r\n this.attachedBlocks.splice(attachedBlockIndex, 1);\r\n }\r\n\r\n if (block.isSystem) {\r\n const index = this._systemBlocks.indexOf(block as SystemBlock);\r\n if (index > -1) {\r\n this._systemBlocks.splice(index, 1);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Clear the current graph and load a new one from a serialization object\r\n * @param source defines the JSON representation of the particle set\r\n * @param merge defines whether or not the source must be merged or replace the current content\r\n */\r\n public parseSerializedObject(source: any, merge = false) {\r\n if (!merge) {\r\n this.clear();\r\n }\r\n\r\n const map: { [key: number]: NodeParticleBlock } = {};\r\n\r\n // Create blocks\r\n for (const parsedBlock of source.blocks) {\r\n const blockType = GetClass(parsedBlock.customType);\r\n if (blockType) {\r\n const block: NodeParticleBlock = new blockType();\r\n block._deserialize(parsedBlock);\r\n map[parsedBlock.id] = block;\r\n\r\n this.attachedBlocks.push(block);\r\n\r\n if (block.isSystem) {\r\n this._systemBlocks.push(block as SystemBlock);\r\n }\r\n }\r\n }\r\n\r\n // Reconnect teleportation\r\n for (const block of this.attachedBlocks) {\r\n if (block.isTeleportOut) {\r\n const teleportOut = block as ParticleTeleportOutBlock;\r\n const id = teleportOut._tempEntryPointUniqueId;\r\n if (id) {\r\n const source = map[id] as ParticleTeleportInBlock;\r\n if (source) {\r\n source.attachToEndpoint(teleportOut);\r\n }\r\n }\r\n }\r\n }\r\n\r\n // Connections - Starts with input blocks only (except if in \"merge\" mode where we scan all blocks)\r\n for (let blockIndex = 0; blockIndex < source.blocks.length; blockIndex++) {\r\n const parsedBlock = source.blocks[blockIndex];\r\n const block = map[parsedBlock.id];\r\n\r\n if (!block) {\r\n continue;\r\n }\r\n\r\n if (block.inputs.length && parsedBlock.inputs.some((i: any) => i.targetConnectionName) && !merge) {\r\n continue;\r\n }\r\n this._restoreConnections(block, source, map);\r\n }\r\n\r\n // UI related info\r\n if (source.locations || (source.editorData && source.editorData.locations)) {\r\n const locations: {\r\n blockId: number;\r\n x: number;\r\n y: number;\r\n isCollapsed: boolean;\r\n }[] = source.locations || source.editorData.locations;\r\n\r\n for (const location of locations) {\r\n if (map[location.blockId]) {\r\n location.blockId = map[location.blockId].uniqueId;\r\n }\r\n }\r\n\r\n if (merge && this.editorData && this.editorData.locations) {\r\n locations.concat(this.editorData.locations);\r\n }\r\n\r\n if (source.locations) {\r\n this.editorData = {\r\n locations: locations,\r\n };\r\n } else {\r\n this.editorData = source.editorData;\r\n this.editorData.locations = locations;\r\n }\r\n\r\n const blockMap: number[] = [];\r\n\r\n for (const key in map) {\r\n blockMap[key] = map[key].uniqueId;\r\n }\r\n\r\n this.editorData.map = blockMap;\r\n }\r\n\r\n this.comment = source.comment;\r\n }\r\n\r\n private _restoreConnections(block: NodeParticleBlock, source: any, map: { [key: number]: NodeParticleBlock }) {\r\n for (const outputPoint of block.outputs) {\r\n for (const candidate of source.blocks) {\r\n const target = map[candidate.id];\r\n\r\n if (!target) {\r\n continue;\r\n }\r\n\r\n for (const input of candidate.inputs) {\r\n if (map[input.targetBlockId] === block && input.targetConnectionName === outputPoint.name) {\r\n const inputPoint = target.getInputByName(input.inputName);\r\n if (!inputPoint || inputPoint.isConnected) {\r\n continue;\r\n }\r\n\r\n outputPoint.connectTo(inputPoint, true);\r\n this._restoreConnections(target, source, map);\r\n continue;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Serializes this geometry in a JSON representation\r\n * @param selectedBlocks defines the list of blocks to save (if null the whole geometry will be saved)\r\n * @returns the serialized particle system set object\r\n */\r\n public serialize(selectedBlocks?: NodeParticleBlock[]): any {\r\n const serializationObject = selectedBlocks ? {} : SerializationHelper.Serialize(this);\r\n serializationObject.editorData = JSON.parse(JSON.stringify(this.editorData)); // Copy\r\n\r\n let blocks: NodeParticleBlock[] = [];\r\n\r\n if (selectedBlocks) {\r\n blocks = selectedBlocks;\r\n } else {\r\n serializationObject.customType = \"BABYLON.NodeParticleSystemSet\";\r\n }\r\n\r\n // Blocks\r\n serializationObject.blocks = [];\r\n\r\n for (const block of blocks) {\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n\r\n if (!selectedBlocks) {\r\n for (const block of this.attachedBlocks) {\r\n if (blocks.indexOf(block) !== -1) {\r\n continue;\r\n }\r\n serializationObject.blocks.push(block.serialize());\r\n }\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Makes a duplicate of the current particle system set.\r\n * @param name defines the name to use for the new particle system set\r\n * @returns the cloned particle system set\r\n */\r\n public clone(name: string): NodeParticleSystemSet {\r\n const serializationObject = this.serialize();\r\n\r\n const clone = SerializationHelper.Clone(() => new NodeParticleSystemSet(name), this);\r\n clone.name = name;\r\n clone.snippetId = this.snippetId;\r\n\r\n clone.parseSerializedObject(serializationObject);\r\n clone._buildId = this._buildId;\r\n\r\n return clone;\r\n }\r\n\r\n /**\r\n * Disposes the resources\r\n */\r\n public dispose(): void {\r\n for (const block of this.attachedBlocks) {\r\n block.dispose();\r\n }\r\n\r\n this.attachedBlocks.length = 0;\r\n this.onBuildObservable.clear();\r\n }\r\n\r\n /**\r\n * Creates a new node particle set set to default basic configuration\r\n * @param name defines the name of the particle set\r\n * @returns a new NodeParticleSystemSet\r\n */\r\n public static CreateDefault(name: string) {\r\n const nodeParticleSet = new NodeParticleSystemSet(name);\r\n\r\n nodeParticleSet.setToDefault();\r\n\r\n return nodeParticleSet;\r\n }\r\n\r\n /**\r\n * Creates a node particle set from parsed data\r\n * @param source defines the JSON representation of the particle set\r\n * @returns a new node particle set\r\n */\r\n public static Parse(source: any): NodeParticleSystemSet {\r\n const nodeParticleSet = SerializationHelper.Parse(() => new NodeParticleSystemSet(source.name), source, null);\r\n\r\n nodeParticleSet.parseSerializedObject(source);\r\n\r\n return nodeParticleSet;\r\n }\r\n\r\n /**\r\n * Creates a node particle set from a snippet saved by the node geometry editor\r\n * @param snippetId defines the snippet to load\r\n * @param nodeParticleSet defines a node particle set to update (instead of creating a new one)\r\n * @returns a promise that will resolve to the new node geometry\r\n */\r\n // eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\n public static ParseFromSnippetAsync(snippetId: string, nodeParticleSet?: NodeParticleSystemSet): Promise<NodeParticleSystemSet> {\r\n if (snippetId === \"_BLANK\") {\r\n return Promise.resolve(NodeParticleSystemSet.CreateDefault(\"blank\"));\r\n }\r\n\r\n return new Promise((resolve, reject) => {\r\n const request = new WebRequest();\r\n request.addEventListener(\"readystatechange\", () => {\r\n if (request.readyState == 4) {\r\n if (request.status == 200) {\r\n const snippet = JSON.parse(JSON.parse(request.responseText).jsonPayload);\r\n const serializationObject = JSON.parse(snippet.nodeParticle);\r\n\r\n if (!nodeParticleSet) {\r\n nodeParticleSet = SerializationHelper.Parse(() => new NodeParticleSystemSet(snippetId), serializationObject, null);\r\n }\r\n\r\n nodeParticleSet.parseSerializedObject(serializationObject);\r\n nodeParticleSet.snippetId = snippetId;\r\n\r\n try {\r\n resolve(nodeParticleSet);\r\n } catch (err) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(err);\r\n }\r\n } else {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(\"Unable to load the snippet \" + snippetId);\r\n }\r\n }\r\n });\r\n\r\n request.open(\"GET\", this.SnippetUrl + \"/\" + snippetId.replace(/#/g, \"/\"));\r\n request.send();\r\n });\r\n }\r\n}\r\n"]}
|
package/Particles/particle.d.ts
CHANGED
|
@@ -34,6 +34,14 @@ export declare class Particle {
|
|
|
34
34
|
* The color change of the particle per step.
|
|
35
35
|
*/
|
|
36
36
|
colorStep: Color4;
|
|
37
|
+
/**
|
|
38
|
+
* The creation color of the particle.
|
|
39
|
+
*/
|
|
40
|
+
initialColor: Color4;
|
|
41
|
+
/**
|
|
42
|
+
* The color used when the end of life of the particle.
|
|
43
|
+
*/
|
|
44
|
+
colorDead: Color4;
|
|
37
45
|
/**
|
|
38
46
|
* Defines how long will the life of the particle be.
|
|
39
47
|
*/
|
package/Particles/particle.js
CHANGED
|
@@ -32,6 +32,14 @@ export class Particle {
|
|
|
32
32
|
* The color change of the particle per step.
|
|
33
33
|
*/
|
|
34
34
|
this.colorStep = new Color4(0, 0, 0, 0);
|
|
35
|
+
/**
|
|
36
|
+
* The creation color of the particle.
|
|
37
|
+
*/
|
|
38
|
+
this.initialColor = new Color4(0, 0, 0, 0);
|
|
39
|
+
/**
|
|
40
|
+
* The color used when the end of life of the particle.
|
|
41
|
+
*/
|
|
42
|
+
this.colorDead = new Color4(0, 0, 0, 0);
|
|
35
43
|
/**
|
|
36
44
|
* Defines how long will the life of the particle be.
|
|
37
45
|
*/
|
|
@@ -194,6 +202,8 @@ export class Particle {
|
|
|
194
202
|
}
|
|
195
203
|
other.color.copyFrom(this.color);
|
|
196
204
|
other.colorStep.copyFrom(this.colorStep);
|
|
205
|
+
other.initialColor.copyFrom(this.initialColor);
|
|
206
|
+
other.colorDead.copyFrom(this.colorDead);
|
|
197
207
|
other.lifeTime = this.lifeTime;
|
|
198
208
|
other.age = this.age;
|
|
199
209
|
other._randomCellOffset = this._randomCellOffset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particle.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/particle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,QAAQ;IAoIjB;;;OAGG;IACH;IACI;;OAEG;IACI,cAAkC;QAAlC,mBAAc,GAAd,cAAc,CAAoB;QAtI7C;;WAEG;QACI,aAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAEjC;;WAEG;QACI,cAAS,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAElC;;WAEG;QACI,UAAK,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAEtC;;WAEG;QACI,cAAS,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAE1C;;WAEG;QACI,aAAQ,GAAG,GAAG,CAAC;QAEtB;;WAEG;QACI,QAAG,GAAG,CAAC,CAAC;QAEf;;WAEG;QACI,SAAI,GAAG,CAAC,CAAC;QAEhB;;WAEG;QACI,UAAK,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAEjC;;WAEG;QACI,UAAK,GA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C,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YAC7C,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;QACL,CAAC;QACD,IAAI,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAChC,IAAI,KAAK,CAAC,wBAAwB,EAAE,CAAC;gBACjC,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;gBACvE,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;gBACvE,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;YAC3E,CAAC;QACL,CAAC;IACL,CAAC;;AA3Tc,eAAM,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Vector2, Vector3, TmpVectors, Vector4 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { SubEmitter } from \"./subEmitter\";\r\nimport type { ColorGradient, FactorGradient } from \"../Misc/gradients\";\r\n\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { ThinParticleSystem } from \"./thinParticleSystem\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\n\r\n/**\r\n * A particle represents one of the element emitted by a particle system.\r\n * This is mainly define by its coordinates, direction, velocity and age.\r\n */\r\nexport class Particle {\r\n private static _Count = 0;\r\n /**\r\n * Unique ID of the particle\r\n */\r\n public id: number;\r\n /**\r\n * The world position of the particle in the scene.\r\n */\r\n public position = Vector3.Zero();\r\n\r\n /**\r\n * The world direction of the particle in the scene.\r\n */\r\n public direction = Vector3.Zero();\r\n\r\n /**\r\n * The color of the particle.\r\n */\r\n public color = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * The color change of the particle per step.\r\n */\r\n public colorStep = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * Defines how long will the life of the particle be.\r\n */\r\n public lifeTime = 1.0;\r\n\r\n /**\r\n * The current age of the particle.\r\n */\r\n public age = 0;\r\n\r\n /**\r\n * The current size of the particle.\r\n */\r\n public size = 0;\r\n\r\n /**\r\n * The current scale of the particle.\r\n */\r\n public scale = new Vector2(1, 1);\r\n\r\n /**\r\n * The current angle of the particle.\r\n */\r\n public angle = 0;\r\n\r\n /**\r\n * Defines how fast is the angle changing.\r\n */\r\n public angularSpeed = 0;\r\n\r\n /**\r\n * Defines the cell index used by the particle to be rendered from a sprite.\r\n */\r\n public cellIndex: number = 0;\r\n\r\n /**\r\n * The information required to support color remapping\r\n */\r\n public remapData: Vector4;\r\n\r\n /** @internal */\r\n public _randomCellOffset?: number;\r\n\r\n /** @internal */\r\n public _initialDirection: Nullable<Vector3>;\r\n\r\n /** @internal */\r\n public _attachedSubEmitters: Nullable<Array<SubEmitter>> = null;\r\n\r\n /** @internal */\r\n public _initialStartSpriteCellId: number;\r\n /** @internal */\r\n public _initialEndSpriteCellId: number;\r\n /** @internal */\r\n public _initialSpriteCellLoop: boolean;\r\n\r\n /** @internal */\r\n public _currentColorGradient: Nullable<ColorGradient>;\r\n /** @internal */\r\n public _currentColor1 = new Color4(0, 0, 0, 0);\r\n /** @internal */\r\n public _currentColor2 = new Color4(0, 0, 0, 0);\r\n\r\n /** @internal */\r\n public _currentSizeGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentSize1 = 0;\r\n /** @internal */\r\n public _currentSize2 = 0;\r\n\r\n /** @internal */\r\n public _currentAngularSpeedGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentAngularSpeed1 = 0;\r\n /** @internal */\r\n public _currentAngularSpeed2 = 0;\r\n\r\n /** @internal */\r\n public _currentVelocityGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentVelocity1 = 0;\r\n /** @internal */\r\n public _currentVelocity2 = 0;\r\n\r\n /** @internal */\r\n public _currentLimitVelocityGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentLimitVelocity1 = 0;\r\n /** @internal */\r\n public _currentLimitVelocity2 = 0;\r\n\r\n /** @internal */\r\n public _currentDragGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentDrag1 = 0;\r\n /** @internal */\r\n public _currentDrag2 = 0;\r\n\r\n /** @internal */\r\n public _randomNoiseCoordinates1: Vector3;\r\n /** @internal */\r\n public _randomNoiseCoordinates2: Vector3;\r\n\r\n /** @internal */\r\n public _localPosition?: Vector3;\r\n\r\n /**\r\n * Creates a new instance Particle\r\n * @param particleSystem the particle system the particle belongs to\r\n */\r\n constructor(\r\n /**\r\n * The particle system the particle belongs to.\r\n */\r\n public particleSystem: ThinParticleSystem\r\n ) {\r\n this.id = Particle._Count++;\r\n if (!this.particleSystem.isAnimationSheetEnabled) {\r\n return;\r\n }\r\n\r\n this._updateCellInfoFromSystem();\r\n }\r\n\r\n private _updateCellInfoFromSystem(): void {\r\n this.cellIndex = this.particleSystem.startSpriteCellID;\r\n }\r\n\r\n /**\r\n * Defines how the sprite cell index is updated for the particle\r\n */\r\n public updateCellIndex(): void {\r\n let offsetAge = this.age;\r\n let changeSpeed = this.particleSystem.spriteCellChangeSpeed;\r\n\r\n if (this.particleSystem.spriteRandomStartCell) {\r\n if (this._randomCellOffset === undefined) {\r\n this._randomCellOffset = Math.random() * this.lifeTime;\r\n }\r\n\r\n if (changeSpeed === 0) {\r\n // Special case when speed = 0 meaning we want to stay on initial cell\r\n changeSpeed = 1;\r\n offsetAge = this._randomCellOffset;\r\n } else {\r\n offsetAge += this._randomCellOffset;\r\n }\r\n }\r\n\r\n const dist = this._initialEndSpriteCellId - this._initialStartSpriteCellId + 1;\r\n let ratio: number;\r\n if (this._initialSpriteCellLoop) {\r\n ratio = Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);\r\n } else {\r\n ratio = Clamp((offsetAge * changeSpeed) / this.lifeTime);\r\n }\r\n this.cellIndex = (this._initialStartSpriteCellId + ratio * dist) | 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter) {\r\n if ((<AbstractMesh>subEmitter.particleSystem.emitter).position) {\r\n const emitterMesh = <AbstractMesh>subEmitter.particleSystem.emitter;\r\n emitterMesh.position.copyFrom(this.position);\r\n if (subEmitter.inheritDirection) {\r\n const temp = TmpVectors.Vector3[0];\r\n this.direction.normalizeToRef(temp);\r\n emitterMesh.setDirection(temp, 0, Math.PI / 2);\r\n }\r\n } else {\r\n const emitterPosition = <Vector3>subEmitter.particleSystem.emitter;\r\n emitterPosition.copyFrom(this.position);\r\n }\r\n // Set inheritedVelocityOffset to be used when new particles are created\r\n this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, TmpVectors.Vector3[0]);\r\n subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(TmpVectors.Vector3[0]);\r\n }\r\n\r\n /** @internal */\r\n public _inheritParticleInfoToSubEmitters() {\r\n if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {\r\n for (const subEmitter of this._attachedSubEmitters) {\r\n this._inheritParticleInfoToSubEmitter(subEmitter);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n this.age = 0;\r\n this.id = Particle._Count++;\r\n this._currentColorGradient = null;\r\n this._currentSizeGradient = null;\r\n this._currentAngularSpeedGradient = null;\r\n this._currentVelocityGradient = null;\r\n this._currentLimitVelocityGradient = null;\r\n this._currentDragGradient = null;\r\n this.cellIndex = this.particleSystem.startSpriteCellID;\r\n this._randomCellOffset = undefined;\r\n }\r\n\r\n /**\r\n * Copy the properties of particle to another one.\r\n * @param other the particle to copy the information to.\r\n */\r\n public copyTo(other: Particle) {\r\n other.position.copyFrom(this.position);\r\n if (this._initialDirection) {\r\n if (other._initialDirection) {\r\n other._initialDirection.copyFrom(this._initialDirection);\r\n } else {\r\n other._initialDirection = this._initialDirection.clone();\r\n }\r\n } else {\r\n other._initialDirection = null;\r\n }\r\n other.direction.copyFrom(this.direction);\r\n if (this._localPosition) {\r\n if (other._localPosition) {\r\n other._localPosition.copyFrom(this._localPosition);\r\n } else {\r\n other._localPosition = this._localPosition.clone();\r\n }\r\n }\r\n other.color.copyFrom(this.color);\r\n other.colorStep.copyFrom(this.colorStep);\r\n other.lifeTime = this.lifeTime;\r\n other.age = this.age;\r\n other._randomCellOffset = this._randomCellOffset;\r\n other.size = this.size;\r\n other.scale.copyFrom(this.scale);\r\n other.angle = this.angle;\r\n other.angularSpeed = this.angularSpeed;\r\n other.particleSystem = this.particleSystem;\r\n other.cellIndex = this.cellIndex;\r\n other.id = this.id;\r\n other._attachedSubEmitters = this._attachedSubEmitters;\r\n if (this._currentColorGradient) {\r\n other._currentColorGradient = this._currentColorGradient;\r\n other._currentColor1.copyFrom(this._currentColor1);\r\n other._currentColor2.copyFrom(this._currentColor2);\r\n }\r\n if (this._currentSizeGradient) {\r\n other._currentSizeGradient = this._currentSizeGradient;\r\n other._currentSize1 = this._currentSize1;\r\n other._currentSize2 = this._currentSize2;\r\n }\r\n if (this._currentAngularSpeedGradient) {\r\n other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;\r\n other._currentAngularSpeed1 = this._currentAngularSpeed1;\r\n other._currentAngularSpeed2 = this._currentAngularSpeed2;\r\n }\r\n if (this._currentVelocityGradient) {\r\n other._currentVelocityGradient = this._currentVelocityGradient;\r\n other._currentVelocity1 = this._currentVelocity1;\r\n other._currentVelocity2 = this._currentVelocity2;\r\n }\r\n if (this._currentLimitVelocityGradient) {\r\n other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;\r\n other._currentLimitVelocity1 = this._currentLimitVelocity1;\r\n other._currentLimitVelocity2 = this._currentLimitVelocity2;\r\n }\r\n if (this._currentDragGradient) {\r\n other._currentDragGradient = this._currentDragGradient;\r\n other._currentDrag1 = this._currentDrag1;\r\n other._currentDrag2 = this._currentDrag2;\r\n }\r\n if (this.particleSystem.isAnimationSheetEnabled) {\r\n other._initialStartSpriteCellId = this._initialStartSpriteCellId;\r\n other._initialEndSpriteCellId = this._initialEndSpriteCellId;\r\n other._initialSpriteCellLoop = this._initialSpriteCellLoop;\r\n }\r\n if (this.particleSystem.useRampGradients) {\r\n if (other.remapData && this.remapData) {\r\n other.remapData.copyFrom(this.remapData);\r\n } else {\r\n other.remapData = new Vector4(0, 0, 0, 0);\r\n }\r\n }\r\n if (this._randomNoiseCoordinates1) {\r\n if (other._randomNoiseCoordinates1) {\r\n other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);\r\n other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);\r\n } else {\r\n other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();\r\n other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"particle.js","sourceRoot":"","sources":["../../../../dev/core/src/Particles/particle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAM7C,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,QAAQ;IA8IjB;;;OAGG;IACH;IACI;;OAEG;IACI,cAAkC;QAAlC,mBAAc,GAAd,cAAc,CAAoB;QAhJ7C;;WAEG;QACI,aAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAEjC;;WAEG;QACI,cAAS,GAAG,OAAO,CAAC,IAAI,EAAE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IAAI,CAAC,wBAAwB,CAAC,CAAC;YAC3E,CAAC;iBAAM,CAAC;gBACJ,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;gBACvE,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,wBAAwB,CAAC,KAAK,EAAE,CAAC;YAC3E,CAAC;QACL,CAAC;IACL,CAAC;;AAvUc,eAAM,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Vector2, Vector3, TmpVectors, Vector4 } from \"../Maths/math.vector\";\r\nimport { Color4 } from \"../Maths/math.color\";\r\nimport type { SubEmitter } from \"./subEmitter\";\r\nimport type { ColorGradient, FactorGradient } from \"../Misc/gradients\";\r\n\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { ThinParticleSystem } from \"./thinParticleSystem\";\r\nimport { Clamp } from \"../Maths/math.scalar.functions\";\r\n\r\n/**\r\n * A particle represents one of the element emitted by a particle system.\r\n * This is mainly define by its coordinates, direction, velocity and age.\r\n */\r\nexport class Particle {\r\n private static _Count = 0;\r\n /**\r\n * Unique ID of the particle\r\n */\r\n public id: number;\r\n /**\r\n * The world position of the particle in the scene.\r\n */\r\n public position = Vector3.Zero();\r\n\r\n /**\r\n * The world direction of the particle in the scene.\r\n */\r\n public direction = Vector3.Zero();\r\n\r\n /**\r\n * The color of the particle.\r\n */\r\n public color = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * The color change of the particle per step.\r\n */\r\n public colorStep = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * The creation color of the particle.\r\n */\r\n public initialColor = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * The color used when the end of life of the particle.\r\n */\r\n public colorDead = new Color4(0, 0, 0, 0);\r\n\r\n /**\r\n * Defines how long will the life of the particle be.\r\n */\r\n public lifeTime = 1.0;\r\n\r\n /**\r\n * The current age of the particle.\r\n */\r\n public age = 0;\r\n\r\n /**\r\n * The current size of the particle.\r\n */\r\n public size = 0;\r\n\r\n /**\r\n * The current scale of the particle.\r\n */\r\n public scale = new Vector2(1, 1);\r\n\r\n /**\r\n * The current angle of the particle.\r\n */\r\n public angle = 0;\r\n\r\n /**\r\n * Defines how fast is the angle changing.\r\n */\r\n public angularSpeed = 0;\r\n\r\n /**\r\n * Defines the cell index used by the particle to be rendered from a sprite.\r\n */\r\n public cellIndex: number = 0;\r\n\r\n /**\r\n * The information required to support color remapping\r\n */\r\n public remapData: Vector4;\r\n\r\n /** @internal */\r\n public _randomCellOffset?: number;\r\n\r\n /** @internal */\r\n public _initialDirection: Nullable<Vector3>;\r\n\r\n /** @internal */\r\n public _attachedSubEmitters: Nullable<Array<SubEmitter>> = null;\r\n\r\n /** @internal */\r\n public _initialStartSpriteCellId: number;\r\n /** @internal */\r\n public _initialEndSpriteCellId: number;\r\n /** @internal */\r\n public _initialSpriteCellLoop: boolean;\r\n\r\n /** @internal */\r\n public _currentColorGradient: Nullable<ColorGradient>;\r\n /** @internal */\r\n public _currentColor1 = new Color4(0, 0, 0, 0);\r\n /** @internal */\r\n public _currentColor2 = new Color4(0, 0, 0, 0);\r\n\r\n /** @internal */\r\n public _currentSizeGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentSize1 = 0;\r\n /** @internal */\r\n public _currentSize2 = 0;\r\n\r\n /** @internal */\r\n public _currentAngularSpeedGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentAngularSpeed1 = 0;\r\n /** @internal */\r\n public _currentAngularSpeed2 = 0;\r\n\r\n /** @internal */\r\n public _currentVelocityGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentVelocity1 = 0;\r\n /** @internal */\r\n public _currentVelocity2 = 0;\r\n\r\n /** @internal */\r\n public _currentLimitVelocityGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentLimitVelocity1 = 0;\r\n /** @internal */\r\n public _currentLimitVelocity2 = 0;\r\n\r\n /** @internal */\r\n public _currentDragGradient: Nullable<FactorGradient>;\r\n /** @internal */\r\n public _currentDrag1 = 0;\r\n /** @internal */\r\n public _currentDrag2 = 0;\r\n\r\n /** @internal */\r\n public _randomNoiseCoordinates1: Vector3;\r\n /** @internal */\r\n public _randomNoiseCoordinates2: Vector3;\r\n\r\n /** @internal */\r\n public _localPosition?: Vector3;\r\n\r\n /**\r\n * Creates a new instance Particle\r\n * @param particleSystem the particle system the particle belongs to\r\n */\r\n constructor(\r\n /**\r\n * The particle system the particle belongs to.\r\n */\r\n public particleSystem: ThinParticleSystem\r\n ) {\r\n this.id = Particle._Count++;\r\n if (!this.particleSystem.isAnimationSheetEnabled) {\r\n return;\r\n }\r\n\r\n this._updateCellInfoFromSystem();\r\n }\r\n\r\n private _updateCellInfoFromSystem(): void {\r\n this.cellIndex = this.particleSystem.startSpriteCellID;\r\n }\r\n\r\n /**\r\n * Defines how the sprite cell index is updated for the particle\r\n */\r\n public updateCellIndex(): void {\r\n let offsetAge = this.age;\r\n let changeSpeed = this.particleSystem.spriteCellChangeSpeed;\r\n\r\n if (this.particleSystem.spriteRandomStartCell) {\r\n if (this._randomCellOffset === undefined) {\r\n this._randomCellOffset = Math.random() * this.lifeTime;\r\n }\r\n\r\n if (changeSpeed === 0) {\r\n // Special case when speed = 0 meaning we want to stay on initial cell\r\n changeSpeed = 1;\r\n offsetAge = this._randomCellOffset;\r\n } else {\r\n offsetAge += this._randomCellOffset;\r\n }\r\n }\r\n\r\n const dist = this._initialEndSpriteCellId - this._initialStartSpriteCellId + 1;\r\n let ratio: number;\r\n if (this._initialSpriteCellLoop) {\r\n ratio = Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);\r\n } else {\r\n ratio = Clamp((offsetAge * changeSpeed) / this.lifeTime);\r\n }\r\n this.cellIndex = (this._initialStartSpriteCellId + ratio * dist) | 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter) {\r\n if ((<AbstractMesh>subEmitter.particleSystem.emitter).position) {\r\n const emitterMesh = <AbstractMesh>subEmitter.particleSystem.emitter;\r\n emitterMesh.position.copyFrom(this.position);\r\n if (subEmitter.inheritDirection) {\r\n const temp = TmpVectors.Vector3[0];\r\n this.direction.normalizeToRef(temp);\r\n emitterMesh.setDirection(temp, 0, Math.PI / 2);\r\n }\r\n } else {\r\n const emitterPosition = <Vector3>subEmitter.particleSystem.emitter;\r\n emitterPosition.copyFrom(this.position);\r\n }\r\n // Set inheritedVelocityOffset to be used when new particles are created\r\n this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, TmpVectors.Vector3[0]);\r\n subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(TmpVectors.Vector3[0]);\r\n }\r\n\r\n /** @internal */\r\n public _inheritParticleInfoToSubEmitters() {\r\n if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {\r\n for (const subEmitter of this._attachedSubEmitters) {\r\n this._inheritParticleInfoToSubEmitter(subEmitter);\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public _reset() {\r\n this.age = 0;\r\n this.id = Particle._Count++;\r\n this._currentColorGradient = null;\r\n this._currentSizeGradient = null;\r\n this._currentAngularSpeedGradient = null;\r\n this._currentVelocityGradient = null;\r\n this._currentLimitVelocityGradient = null;\r\n this._currentDragGradient = null;\r\n this.cellIndex = this.particleSystem.startSpriteCellID;\r\n this._randomCellOffset = undefined;\r\n }\r\n\r\n /**\r\n * Copy the properties of particle to another one.\r\n * @param other the particle to copy the information to.\r\n */\r\n public copyTo(other: Particle) {\r\n other.position.copyFrom(this.position);\r\n if (this._initialDirection) {\r\n if (other._initialDirection) {\r\n other._initialDirection.copyFrom(this._initialDirection);\r\n } else {\r\n other._initialDirection = this._initialDirection.clone();\r\n }\r\n } else {\r\n other._initialDirection = null;\r\n }\r\n other.direction.copyFrom(this.direction);\r\n if (this._localPosition) {\r\n if (other._localPosition) {\r\n other._localPosition.copyFrom(this._localPosition);\r\n } else {\r\n other._localPosition = this._localPosition.clone();\r\n }\r\n }\r\n other.color.copyFrom(this.color);\r\n other.colorStep.copyFrom(this.colorStep);\r\n other.initialColor.copyFrom(this.initialColor);\r\n other.colorDead.copyFrom(this.colorDead);\r\n other.lifeTime = this.lifeTime;\r\n other.age = this.age;\r\n other._randomCellOffset = this._randomCellOffset;\r\n other.size = this.size;\r\n other.scale.copyFrom(this.scale);\r\n other.angle = this.angle;\r\n other.angularSpeed = this.angularSpeed;\r\n other.particleSystem = this.particleSystem;\r\n other.cellIndex = this.cellIndex;\r\n other.id = this.id;\r\n other._attachedSubEmitters = this._attachedSubEmitters;\r\n if (this._currentColorGradient) {\r\n other._currentColorGradient = this._currentColorGradient;\r\n other._currentColor1.copyFrom(this._currentColor1);\r\n other._currentColor2.copyFrom(this._currentColor2);\r\n }\r\n if (this._currentSizeGradient) {\r\n other._currentSizeGradient = this._currentSizeGradient;\r\n other._currentSize1 = this._currentSize1;\r\n other._currentSize2 = this._currentSize2;\r\n }\r\n if (this._currentAngularSpeedGradient) {\r\n other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;\r\n other._currentAngularSpeed1 = this._currentAngularSpeed1;\r\n other._currentAngularSpeed2 = this._currentAngularSpeed2;\r\n }\r\n if (this._currentVelocityGradient) {\r\n other._currentVelocityGradient = this._currentVelocityGradient;\r\n other._currentVelocity1 = this._currentVelocity1;\r\n other._currentVelocity2 = this._currentVelocity2;\r\n }\r\n if (this._currentLimitVelocityGradient) {\r\n other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;\r\n other._currentLimitVelocity1 = this._currentLimitVelocity1;\r\n other._currentLimitVelocity2 = this._currentLimitVelocity2;\r\n }\r\n if (this._currentDragGradient) {\r\n other._currentDragGradient = this._currentDragGradient;\r\n other._currentDrag1 = this._currentDrag1;\r\n other._currentDrag2 = this._currentDrag2;\r\n }\r\n if (this.particleSystem.isAnimationSheetEnabled) {\r\n other._initialStartSpriteCellId = this._initialStartSpriteCellId;\r\n other._initialEndSpriteCellId = this._initialEndSpriteCellId;\r\n other._initialSpriteCellLoop = this._initialSpriteCellLoop;\r\n }\r\n if (this.particleSystem.useRampGradients) {\r\n if (other.remapData && this.remapData) {\r\n other.remapData.copyFrom(this.remapData);\r\n } else {\r\n other.remapData = new Vector4(0, 0, 0, 0);\r\n }\r\n }\r\n if (this._randomNoiseCoordinates1) {\r\n if (other._randomNoiseCoordinates1) {\r\n other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);\r\n other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);\r\n } else {\r\n other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();\r\n other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -71,6 +71,8 @@ export declare class ParticleSystem extends ThinParticleSystem {
|
|
|
71
71
|
private _flowMapUpdate;
|
|
72
72
|
/** @internal */
|
|
73
73
|
_source: Nullable<NodeParticleSystemSet>;
|
|
74
|
+
/** @internal */
|
|
75
|
+
_blockReference: number;
|
|
74
76
|
/**
|
|
75
77
|
* Gets the NodeParticleSystemSet that this particle system belongs to.
|
|
76
78
|
*/
|
|
@@ -94,10 +96,6 @@ export declare class ParticleSystem extends ThinParticleSystem {
|
|
|
94
96
|
* Please note that this is a copy of the internal array. If you want to modify it, please use the addAttractor and removeAttractor methods.
|
|
95
97
|
*/
|
|
96
98
|
get attractors(): Attractor[];
|
|
97
|
-
/**
|
|
98
|
-
* Gets or sets an object used to store user defined information for the particle system
|
|
99
|
-
*/
|
|
100
|
-
metadata: any;
|
|
101
99
|
/**
|
|
102
100
|
* Add an attractor to the particle system. Attractors are used to change the direction of the particles in the system.
|
|
103
101
|
* @param attractor The attractor to add to the particle system
|