@babylonjs/core 5.35.0 → 5.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Audio/sound.d.ts +5 -0
- package/Audio/sound.js +7 -0
- package/Audio/sound.js.map +1 -1
- package/Debug/physicsViewer.d.ts +4 -3
- package/Debug/physicsViewer.js +2 -2
- package/Debug/physicsViewer.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +15 -15
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/Extensions/engine.renderTargetCube.d.ts +1 -1
- package/Engines/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +4 -0
- package/Engines/Extensions/engine.views.js +61 -42
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Native/nativeHardwareTexture.d.ts +14 -0
- package/Engines/Native/nativeHardwareTexture.js +24 -0
- package/Engines/Native/nativeHardwareTexture.js.map +1 -0
- package/Engines/Native/nativeInterfaces.d.ts +22 -15
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativePipelineContext.d.ts +252 -0
- package/Engines/Native/nativePipelineContext.js +502 -0
- package/Engines/Native/nativePipelineContext.js.map +1 -0
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +16 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +33 -0
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +3 -3
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTargetCube.js.map +1 -1
- package/Engines/engine.d.ts +1 -0
- package/Engines/engine.js +24 -18
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.d.ts +18 -17
- package/Engines/nativeEngine.js +100 -598
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.d.ts +1 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.d.ts +1 -1
- package/Engines/thinEngine.js +41 -38
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js +3 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Inputs/scene.inputManager.js +4 -4
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.js +3 -3
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +19 -1
- package/Materials/Node/nodeMaterial.js +30 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +2 -8
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +2 -1
- package/Materials/Textures/baseTexture.js +3 -2
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +2 -0
- package/Materials/Textures/internalTexture.js +4 -0
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js +0 -2
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +53 -3
- package/Materials/Textures/renderTargetTexture.js +25 -25
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.d.ts +2 -0
- package/Materials/Textures/texture.js +35 -7
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +4 -1
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/material.js +1 -1
- package/Materials/material.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +4 -4
- package/Meshes/abstractMesh.js +4 -4
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +2 -2
- package/Meshes/mesh.js +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +9 -2
- package/Misc/copyTextureToTexture.js +23 -1
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +15 -1
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +24 -2
- package/Particles/gpuParticleSystem.js +98 -43
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.d.ts +6 -1
- package/Particles/particleSystem.js +7 -2
- package/Particles/particleSystem.js.map +1 -1
- package/Physics/IPhysicsEngine.d.ts +8 -108
- package/Physics/IPhysicsEngine.js.map +1 -1
- package/Physics/Plugins/ammoJSPlugin.d.ts +1 -389
- package/Physics/Plugins/ammoJSPlugin.js +2 -1414
- package/Physics/Plugins/ammoJSPlugin.js.map +1 -1
- package/Physics/Plugins/cannonJSPlugin.d.ts +1 -75
- package/Physics/Plugins/cannonJSPlugin.js +2 -664
- package/Physics/Plugins/cannonJSPlugin.js.map +1 -1
- package/Physics/Plugins/oimoJSPlugin.d.ts +1 -59
- package/Physics/Plugins/oimoJSPlugin.js +2 -432
- package/Physics/Plugins/oimoJSPlugin.js.map +1 -1
- package/Physics/index.d.ts +3 -6
- package/Physics/index.js +3 -6
- package/Physics/index.js.map +1 -1
- package/Physics/physicsEngine.d.ts +1 -135
- package/Physics/physicsEngine.js +2 -221
- package/Physics/physicsEngine.js.map +1 -1
- package/Physics/physicsEngineComponent.d.ts +7 -42
- package/Physics/physicsEngineComponent.js +11 -71
- package/Physics/physicsEngineComponent.js.map +1 -1
- package/Physics/physicsHelper.d.ts +1 -411
- package/Physics/physicsHelper.js +2 -708
- package/Physics/physicsHelper.js.map +1 -1
- package/Physics/physicsImpostor.d.ts +1 -640
- package/Physics/physicsImpostor.js +2 -1004
- package/Physics/physicsImpostor.js.map +1 -1
- package/Physics/physicsJoint.d.ts +1 -275
- package/Physics/physicsJoint.js +2 -222
- package/Physics/physicsJoint.js.map +1 -1
- package/Physics/v1/IPhysicsEnginePlugin.d.ts +73 -0
- package/Physics/v1/IPhysicsEnginePlugin.js +2 -0
- package/Physics/v1/IPhysicsEnginePlugin.js.map +1 -0
- package/Physics/v1/Plugins/ammoJSPlugin.d.ts +401 -0
- package/Physics/v1/Plugins/ammoJSPlugin.js +1431 -0
- package/Physics/v1/Plugins/ammoJSPlugin.js.map +1 -0
- package/Physics/v1/Plugins/cannonJSPlugin.d.ts +87 -0
- package/Physics/v1/Plugins/cannonJSPlugin.js +683 -0
- package/Physics/v1/Plugins/cannonJSPlugin.js.map +1 -0
- package/Physics/{Plugins → v1/Plugins}/index.d.ts +0 -0
- package/Physics/{Plugins → v1/Plugins}/index.js +0 -0
- package/Physics/v1/Plugins/index.js.map +1 -0
- package/Physics/v1/Plugins/oimoJSPlugin.d.ts +71 -0
- package/Physics/v1/Plugins/oimoJSPlugin.js +450 -0
- package/Physics/v1/Plugins/oimoJSPlugin.js.map +1 -0
- package/Physics/v1/index.d.ts +7 -0
- package/Physics/v1/index.js +9 -0
- package/Physics/v1/index.js.map +1 -0
- package/Physics/v1/physicsEngine.d.ts +147 -0
- package/Physics/v1/physicsEngine.js +237 -0
- package/Physics/v1/physicsEngine.js.map +1 -0
- package/Physics/v1/physicsEngineComponent.d.ts +45 -0
- package/Physics/v1/physicsEngineComponent.js +70 -0
- package/Physics/v1/physicsEngineComponent.js.map +1 -0
- package/Physics/v1/physicsHelper.d.ts +411 -0
- package/Physics/v1/physicsHelper.js +709 -0
- package/Physics/v1/physicsHelper.js.map +1 -0
- package/Physics/v1/physicsImpostor.d.ts +636 -0
- package/Physics/v1/physicsImpostor.js +1001 -0
- package/Physics/v1/physicsImpostor.js.map +1 -0
- package/Physics/v1/physicsJoint.d.ts +275 -0
- package/Physics/v1/physicsJoint.js +223 -0
- package/Physics/v1/physicsJoint.js.map +1 -0
- package/Physics/v2/IPhysicsEnginePlugin.d.ts +170 -0
- package/Physics/v2/IPhysicsEnginePlugin.js +47 -0
- package/Physics/v2/IPhysicsEnginePlugin.js.map +1 -0
- package/Physics/v2/Plugins/index.d.ts +0 -0
- package/Physics/v2/Plugins/index.js +2 -0
- package/Physics/v2/Plugins/index.js.map +1 -0
- package/Physics/v2/index.d.ts +6 -0
- package/Physics/v2/index.js +8 -0
- package/Physics/v2/index.js.map +1 -0
- package/Physics/v2/physicsAggregate.d.ts +114 -0
- package/Physics/v2/physicsAggregate.js +46 -0
- package/Physics/v2/physicsAggregate.js.map +1 -0
- package/Physics/v2/physicsBody.d.ts +109 -0
- package/Physics/v2/physicsBody.js +158 -0
- package/Physics/v2/physicsBody.js.map +1 -0
- package/Physics/v2/physicsConstraint.d.ts +184 -0
- package/Physics/v2/physicsConstraint.js +257 -0
- package/Physics/v2/physicsConstraint.js.map +1 -0
- package/Physics/v2/physicsEngine.d.ts +103 -0
- package/Physics/v2/physicsEngine.js +146 -0
- package/Physics/v2/physicsEngine.js.map +1 -0
- package/Physics/v2/physicsEngineComponent.d.ts +31 -0
- package/Physics/v2/physicsEngineComponent.js +50 -0
- package/Physics/v2/physicsEngineComponent.js.map +1 -0
- package/Physics/v2/physicsMaterial.d.ts +45 -0
- package/Physics/v2/physicsMaterial.js +67 -0
- package/Physics/v2/physicsMaterial.js.map +1 -0
- package/Physics/v2/physicsShape.d.ts +182 -0
- package/Physics/v2/physicsShape.js +229 -0
- package/Physics/v2/physicsShape.js.map +1 -0
- package/PostProcesses/postProcess.d.ts +3 -1
- package/PostProcesses/postProcess.js +4 -1
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.d.ts +153 -0
- package/Rendering/fluidRenderer/fluidRenderer.js +410 -0
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.d.ts +13 -0
- package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js +31 -0
- package/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +81 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js +180 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.d.ts +63 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js +130 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +64 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +104 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.d.ts +234 -0
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +690 -0
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderingTextures.d.ts +56 -0
- package/Rendering/fluidRenderer/fluidRenderingTextures.js +261 -0
- package/Rendering/fluidRenderer/fluidRenderingTextures.js.map +1 -0
- package/Rendering/fluidRenderer/index.d.ts +5 -0
- package/Rendering/fluidRenderer/index.js +6 -0
- package/Rendering/fluidRenderer/index.js.map +1 -0
- package/Rendering/index.d.ts +1 -0
- package/Rendering/index.js +2 -0
- package/Rendering/index.js.map +1 -1
- package/Shaders/copyTextureToTexture.fragment.js +4 -1
- package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
- package/Shaders/fluidRenderingBilateralBlur.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingBilateralBlur.fragment.js +9 -0
- package/Shaders/fluidRenderingBilateralBlur.fragment.js.map +1 -0
- package/Shaders/fluidRenderingParticleDepth.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingParticleDepth.fragment.js +17 -0
- package/Shaders/fluidRenderingParticleDepth.fragment.js.map +1 -0
- package/Shaders/fluidRenderingParticleDepth.vertex.d.ts +5 -0
- package/Shaders/fluidRenderingParticleDepth.vertex.js +13 -0
- package/Shaders/fluidRenderingParticleDepth.vertex.js.map +1 -0
- package/Shaders/fluidRenderingParticleDiffuse.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingParticleDiffuse.fragment.js +9 -0
- package/Shaders/fluidRenderingParticleDiffuse.fragment.js.map +1 -0
- package/Shaders/fluidRenderingParticleDiffuse.vertex.d.ts +5 -0
- package/Shaders/fluidRenderingParticleDiffuse.vertex.js +4 -0
- package/Shaders/fluidRenderingParticleDiffuse.vertex.js.map +1 -0
- package/Shaders/fluidRenderingParticleThickness.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingParticleThickness.fragment.js +9 -0
- package/Shaders/fluidRenderingParticleThickness.fragment.js.map +1 -0
- package/Shaders/fluidRenderingParticleThickness.vertex.d.ts +5 -0
- package/Shaders/fluidRenderingParticleThickness.vertex.js +9 -0
- package/Shaders/fluidRenderingParticleThickness.vertex.js.map +1 -0
- package/Shaders/fluidRenderingRender.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingRender.fragment.js +46 -0
- package/Shaders/fluidRenderingRender.fragment.js.map +1 -0
- package/Shaders/fluidRenderingStandardBlur.fragment.d.ts +5 -0
- package/Shaders/fluidRenderingStandardBlur.fragment.js +9 -0
- package/Shaders/fluidRenderingStandardBlur.fragment.js.map +1 -0
- package/XR/features/WebXRControllerPhysics.d.ts +1 -1
- package/XR/features/WebXRControllerPhysics.js +1 -1
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRHandTracking.js +1 -1
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +6 -1
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +3 -0
- package/sceneComponent.js +3 -0
- package/sceneComponent.js.map +1 -1
- package/Physics/Plugins/index.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThinEngine } from "../Engines/thinEngine.js";
|
|
2
2
|
import type { InternalTexture } from "../Materials/Textures/internalTexture";
|
|
3
3
|
import type { IRenderTargetTexture, RenderTargetWrapper } from "../Engines/renderTargetWrapper";
|
|
4
4
|
import type { ThinTexture } from "../Materials/Textures/thinTexture";
|
|
@@ -15,6 +15,8 @@ export declare enum ConversionMode {
|
|
|
15
15
|
* Class used for fast copy from one texture to another
|
|
16
16
|
*/
|
|
17
17
|
export declare class CopyTextureToTexture {
|
|
18
|
+
private _engine;
|
|
19
|
+
private _isDepthTexture;
|
|
18
20
|
private _renderer;
|
|
19
21
|
private _effectWrapper;
|
|
20
22
|
private _source;
|
|
@@ -23,8 +25,9 @@ export declare class CopyTextureToTexture {
|
|
|
23
25
|
/**
|
|
24
26
|
* Constructs a new instance of the class
|
|
25
27
|
* @param engine The engine to use for the copy
|
|
28
|
+
* @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)
|
|
26
29
|
*/
|
|
27
|
-
constructor(engine:
|
|
30
|
+
constructor(engine: ThinEngine, isDepthTexture?: boolean);
|
|
28
31
|
/**
|
|
29
32
|
* Indicates if the effect is ready to be used for the copy
|
|
30
33
|
* @returns true if "copy" can be called without delay, else false
|
|
@@ -38,4 +41,8 @@ export declare class CopyTextureToTexture {
|
|
|
38
41
|
* @returns
|
|
39
42
|
*/
|
|
40
43
|
copy(source: InternalTexture | ThinTexture, destination: RenderTargetWrapper | IRenderTargetTexture, conversion?: ConversionMode): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Releases all the resources used by the class
|
|
46
|
+
*/
|
|
47
|
+
dispose(): void;
|
|
41
48
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EffectRenderer, EffectWrapper } from "../Materials/effectRenderer.js";
|
|
2
|
+
|
|
2
3
|
import "../Shaders/copyTextureToTexture.fragment.js";
|
|
3
4
|
/**
|
|
4
5
|
* Conversion modes available when copying a texture into another one
|
|
@@ -16,8 +17,11 @@ export class CopyTextureToTexture {
|
|
|
16
17
|
/**
|
|
17
18
|
* Constructs a new instance of the class
|
|
18
19
|
* @param engine The engine to use for the copy
|
|
20
|
+
* @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)
|
|
19
21
|
*/
|
|
20
|
-
constructor(engine) {
|
|
22
|
+
constructor(engine, isDepthTexture = false) {
|
|
23
|
+
this._engine = engine;
|
|
24
|
+
this._isDepthTexture = isDepthTexture;
|
|
21
25
|
this._renderer = new EffectRenderer(engine);
|
|
22
26
|
this._effectWrapper = new EffectWrapper({
|
|
23
27
|
engine: engine,
|
|
@@ -26,8 +30,15 @@ export class CopyTextureToTexture {
|
|
|
26
30
|
useShaderStore: true,
|
|
27
31
|
uniformNames: ["conversion"],
|
|
28
32
|
samplerNames: ["textureSampler"],
|
|
33
|
+
defines: isDepthTexture ? ["#define DEPTH_TEXTURE"] : [],
|
|
29
34
|
});
|
|
30
35
|
this._effectWrapper.onApplyObservable.add(() => {
|
|
36
|
+
if (isDepthTexture) {
|
|
37
|
+
engine.setState(false);
|
|
38
|
+
engine.setDepthBuffer(true);
|
|
39
|
+
engine.depthCullingState.depthMask = true;
|
|
40
|
+
engine.depthCullingState.depthFunc = 519;
|
|
41
|
+
}
|
|
31
42
|
if (this._textureIsInternal(this._source)) {
|
|
32
43
|
this._effectWrapper.effect._bindTexture("textureSampler", this._source);
|
|
33
44
|
}
|
|
@@ -60,8 +71,19 @@ export class CopyTextureToTexture {
|
|
|
60
71
|
}
|
|
61
72
|
this._source = source;
|
|
62
73
|
this._conversion = conversion;
|
|
74
|
+
const engineDepthFunc = this._engine.depthCullingState.depthFunc;
|
|
63
75
|
this._renderer.render(this._effectWrapper, destination);
|
|
76
|
+
if (this._isDepthTexture && engineDepthFunc) {
|
|
77
|
+
this._engine.depthCullingState.depthFunc = engineDepthFunc;
|
|
78
|
+
}
|
|
64
79
|
return true;
|
|
65
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Releases all the resources used by the class
|
|
83
|
+
*/
|
|
84
|
+
dispose() {
|
|
85
|
+
this._effectWrapper.dispose();
|
|
86
|
+
this._renderer.dispose();
|
|
87
|
+
}
|
|
66
88
|
}
|
|
67
89
|
//# sourceMappingURL=copyTextureToTexture.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../lts/core/generated/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAEnD,OAAO,0CAA0C,CAAC;AAElD;;GAEG;AACH,MAAM,CAAN,IAAY,cAIX;AAJD,WAAY,cAAc;IACtB,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJW,cAAc,KAAd,cAAc,QAIzB;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAY7B;;;;OAIG;IACH,YAAY,MAAkB,EAAE,cAAc,GAAG,KAAK;QAClD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5C,IAAI,CAAC,cAAc,GAAG,IAAI,aAAa,CAAC;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,cAAc,EAAE,sBAAsB;YACtC,cAAc,EAAE,IAAI;YACpB,YAAY,EAAE,CAAC,YAAY,CAAC;YAC5B,YAAY,EAAE,CAAC,gBAAgB,CAAC;YAChC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,EAAE;SAC3D,CAAC,CAAC;QAEH,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE;YAC3C,IAAI,cAAc,EAAE;gBAChB,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACvB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;gBAC5B,MAAM,CAAC,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC;gBAC1C,MAAM,CAAC,iBAAiB,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;aACzD;YAED,IAAI,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;gBACvC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;aAC3E;iBAAM;gBACH,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,CAAC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;aACzE;YACD,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACxE,CAAC,CAAC,CAAC;IACP,CAAC;IAxCO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAwCD;;;OAGG;IACI,OAAO;QACV,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;IAED;;;;;;OAMG;IACI,IAAI,CAAC,MAAqC,EAAE,WAAuD,EAAE,UAAU,GAAG,cAAc,CAAC,IAAI;QACxI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE;YACjB,OAAO,KAAK,CAAC;SAChB;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAE9B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,CAAC;QAEjE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAExD,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE;YACzC,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC,SAAS,GAAG,eAAe,CAAC;SAC9D;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC;QAC9B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { ThinEngine } from \"core/Engines/thinEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\nimport \"../Shaders/copyTextureToTexture.fragment\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: ThinEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n */\r\n constructor(engine: ThinEngine, isDepthTexture = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines: isDepthTexture ? [\"#define DEPTH_TEXTURE\"] : [],\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._effectWrapper.effect.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: RenderTargetWrapper | IRenderTargetTexture, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.depthCullingState.depthFunc;\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.depthCullingState.depthFunc = engineDepthFunc;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from "../types";
|
|
1
|
+
import type { Immutable, Nullable } from "../types";
|
|
2
2
|
import type { Vector2, Vector3, Matrix } from "../Maths/math.vector";
|
|
3
3
|
import type { Color3, Color4 } from "../Maths/math.color";
|
|
4
4
|
import type { BaseTexture } from "../Materials/Textures/baseTexture";
|
|
@@ -7,6 +7,8 @@ import type { Scene } from "../scene";
|
|
|
7
7
|
import type { ColorGradient, FactorGradient, Color3Gradient } from "../Misc/gradients";
|
|
8
8
|
import type { Effect } from "../Materials/effect";
|
|
9
9
|
import type { Observable } from "../Misc/observable";
|
|
10
|
+
import type { VertexBuffer } from "../Buffers/buffer";
|
|
11
|
+
import type { DataBuffer } from "../Buffers/dataBuffer";
|
|
10
12
|
declare type Animation = import("../Animations/animation").Animation;
|
|
11
13
|
declare type AbstractMesh = import("../Meshes/abstractMesh").AbstractMesh;
|
|
12
14
|
/**
|
|
@@ -235,6 +237,8 @@ export interface IParticleSystem {
|
|
|
235
237
|
snippetId: string;
|
|
236
238
|
/** Gets or sets a matrix to use to compute projection */
|
|
237
239
|
defaultProjectionMatrix: Matrix;
|
|
240
|
+
/** Indicates that the update of particles is done in the animate function (and not in render) */
|
|
241
|
+
updateInAnimate: boolean;
|
|
238
242
|
/** @internal */
|
|
239
243
|
_wasDispatched: boolean;
|
|
240
244
|
/**
|
|
@@ -354,6 +358,16 @@ export interface IParticleSystem {
|
|
|
354
358
|
* Gets the name of the particle vertex shader
|
|
355
359
|
*/
|
|
356
360
|
vertexShaderName: string;
|
|
361
|
+
/**
|
|
362
|
+
* Gets the vertex buffers used by the particle system
|
|
363
|
+
*/
|
|
364
|
+
vertexBuffers: Immutable<{
|
|
365
|
+
[key: string]: VertexBuffer;
|
|
366
|
+
}>;
|
|
367
|
+
/**
|
|
368
|
+
* Gets the index buffer used by the particle system (or null if no index buffer is used)
|
|
369
|
+
*/
|
|
370
|
+
indexBuffer: Nullable<DataBuffer>;
|
|
357
371
|
/**
|
|
358
372
|
* Adds a new color gradient
|
|
359
373
|
* @param gradient defines the gradient to use (between 0 and 1)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../lts/core/generated/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n ConeParticleEmitter,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\n\r\ndeclare type Animation = import(\"../Animations/animation\").Animation;\r\ndeclare type AbstractMesh = import(\"../Meshes/abstractMesh\").AbstractMesh;\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n */\r\n dispose(disposeTexture?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IParticleSystem.js","sourceRoot":"","sources":["../../../../lts/core/generated/Particles/IParticleSystem.ts"],"names":[],"mappings":"","sourcesContent":["import type { Immutable, Nullable } from \"../types\";\r\nimport type { Vector2, Vector3, Matrix } from \"../Maths/math.vector\";\r\nimport type { Color3, Color4 } from \"../Maths/math.color\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport type {\r\n BoxParticleEmitter,\r\n IParticleEmitterType,\r\n PointParticleEmitter,\r\n HemisphericParticleEmitter,\r\n SphereParticleEmitter,\r\n SphereDirectedParticleEmitter,\r\n CylinderParticleEmitter,\r\n ConeParticleEmitter,\r\n // eslint-disable-next-line import/no-internal-modules\r\n} from \"../Particles/EmitterTypes/index\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { ColorGradient, FactorGradient, Color3Gradient } from \"../Misc/gradients\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { Observable } from \"../Misc/observable\";\r\nimport type { VertexBuffer } from \"../Buffers/buffer\";\r\nimport type { DataBuffer } from \"../Buffers/dataBuffer\";\r\n\r\ndeclare type Animation = import(\"../Animations/animation\").Animation;\r\ndeclare type AbstractMesh = import(\"../Meshes/abstractMesh\").AbstractMesh;\r\n\r\n/**\r\n * Interface representing a particle system in Babylon.js.\r\n * This groups the common functionalities that needs to be implemented in order to create a particle system.\r\n * A particle system represents a way to manage particles from their emission to their animation and rendering.\r\n */\r\nexport interface IParticleSystem {\r\n /**\r\n * List of animations used by the particle system.\r\n */\r\n animations: Animation[];\r\n /**\r\n * The id of the Particle system.\r\n */\r\n id: string;\r\n /**\r\n * The name of the Particle system.\r\n */\r\n name: string;\r\n /**\r\n * The emitter represents the Mesh or position we are attaching the particle system to.\r\n */\r\n emitter: Nullable<AbstractMesh | Vector3>;\r\n /**\r\n * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction\r\n */\r\n isBillboardBased: boolean;\r\n /**\r\n * The rendering group used by the Particle system to chose when to render.\r\n */\r\n renderingGroupId: number;\r\n /**\r\n * The layer mask we are rendering the particles through.\r\n */\r\n layerMask: number;\r\n\r\n /**\r\n * The overall motion speed (0.01 is default update speed, faster updates = faster animation)\r\n */\r\n updateSpeed: number;\r\n\r\n /**\r\n * The amount of time the particle system is running (depends of the overall update speed).\r\n */\r\n targetStopDuration: number;\r\n\r\n /**\r\n * The texture used to render each particle. (this can be a spritesheet)\r\n */\r\n particleTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.\r\n */\r\n blendMode: number;\r\n\r\n /**\r\n * Minimum life time of emitting particles.\r\n */\r\n minLifeTime: number;\r\n /**\r\n * Maximum life time of emitting particles.\r\n */\r\n maxLifeTime: number;\r\n\r\n /**\r\n * Minimum Size of emitting particles.\r\n */\r\n minSize: number;\r\n /**\r\n * Maximum Size of emitting particles.\r\n */\r\n maxSize: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on X axis.\r\n */\r\n minScaleX: number;\r\n /**\r\n * Maximum scale of emitting particles on X axis.\r\n */\r\n maxScaleX: number;\r\n\r\n /**\r\n * Minimum scale of emitting particles on Y axis.\r\n */\r\n minScaleY: number;\r\n /**\r\n * Maximum scale of emitting particles on Y axis.\r\n */\r\n maxScaleY: number;\r\n\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color1: Color4;\r\n /**\r\n * Random color of each particle after it has been emitted, between color1 and color2 vectors.\r\n */\r\n color2: Color4;\r\n\r\n /**\r\n * Color the particle will have at the end of its lifetime.\r\n */\r\n colorDead: Color4;\r\n\r\n /**\r\n * The maximum number of particles to emit per frame until we reach the activeParticleCount value\r\n */\r\n emitRate: number;\r\n\r\n /**\r\n * You can use gravity if you want to give an orientation to your particles.\r\n */\r\n gravity: Vector3;\r\n\r\n /**\r\n * Minimum power of emitting particles.\r\n */\r\n minEmitPower: number;\r\n /**\r\n * Maximum power of emitting particles.\r\n */\r\n maxEmitPower: number;\r\n /**\r\n * Minimum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n minAngularSpeed: number;\r\n /**\r\n * Maximum angular speed of emitting particles (Z-axis rotation for each particle).\r\n */\r\n maxAngularSpeed: number;\r\n /**\r\n * Gets or sets the minimal initial rotation in radians.\r\n */\r\n minInitialRotation: number;\r\n /**\r\n * Gets or sets the maximal initial rotation in radians.\r\n */\r\n maxInitialRotation: number;\r\n /**\r\n * The particle emitter type defines the emitter used by the particle system.\r\n * It can be for example box, sphere, or cone...\r\n */\r\n particleEmitterType: Nullable<IParticleEmitterType>;\r\n /**\r\n * Defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n startDelay: number;\r\n /**\r\n * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0\r\n */\r\n preWarmCycles: number;\r\n /**\r\n * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)\r\n */\r\n preWarmStepOffset: number;\r\n\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)\r\n */\r\n spriteCellChangeSpeed: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display\r\n */\r\n startSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display\r\n */\r\n endSpriteCellID: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines whether the sprite animation is looping\r\n */\r\n spriteCellLoop: boolean;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use\r\n */\r\n spriteCellWidth: number;\r\n /**\r\n * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use\r\n */\r\n spriteCellHeight: number;\r\n /**\r\n * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID\r\n */\r\n spriteRandomStartCell: boolean;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture\r\n */\r\n isAnimationSheetEnabled: boolean;\r\n\r\n /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */\r\n translationPivot: Vector2;\r\n\r\n /**\r\n * Gets or sets a texture used to add random noise to particle positions\r\n */\r\n noiseTexture: Nullable<BaseTexture>;\r\n\r\n /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */\r\n noiseStrength: Vector3;\r\n\r\n /**\r\n * Gets or sets the billboard mode to use when isBillboardBased = true.\r\n * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED\r\n */\r\n billboardMode: number;\r\n\r\n /**\r\n * Gets or sets a boolean enabling the use of logarithmic depth buffers, which is good for wide depth buffers.\r\n */\r\n useLogarithmicDepth: boolean;\r\n\r\n /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */\r\n limitVelocityDamping: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called\r\n */\r\n beginAnimationOnStart: boolean;\r\n\r\n /**\r\n * Gets or sets the frame to start the animation from when beginAnimationOnStart is true\r\n */\r\n beginAnimationFrom: number;\r\n\r\n /**\r\n * Gets or sets the frame to end the animation on when beginAnimationOnStart is true\r\n */\r\n beginAnimationTo: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true\r\n */\r\n beginAnimationLoop: boolean;\r\n\r\n /**\r\n * Specifies whether the particle system will be disposed once it reaches the end of the animation.\r\n */\r\n disposeOnStop: boolean;\r\n\r\n /**\r\n * If you want to launch only a few particles at once, that can be done, as well.\r\n */\r\n manualEmitCount: number;\r\n\r\n /**\r\n * Specifies if the particles are updated in emitter local space or world space\r\n */\r\n isLocal: boolean;\r\n\r\n /** Snippet ID if the particle system was created from the snippet server */\r\n snippetId: string;\r\n\r\n /** Gets or sets a matrix to use to compute projection */\r\n defaultProjectionMatrix: Matrix;\r\n\r\n /** Indicates that the update of particles is done in the animate function (and not in render) */\r\n updateInAnimate: boolean;\r\n\r\n /** @internal */\r\n _wasDispatched: boolean;\r\n\r\n /**\r\n * Gets the maximum number of particles active at the same time.\r\n * @returns The max number of active particles.\r\n */\r\n getCapacity(): number;\r\n\r\n /**\r\n * Gets the number of particles active at the same time.\r\n * @returns The number of active particles.\r\n */\r\n getActiveCount(): number;\r\n\r\n /**\r\n * Gets if the system has been started. (Note: this will still be true after stop is called)\r\n * @returns True if it has been started, otherwise false.\r\n */\r\n isStarted(): boolean;\r\n\r\n /**\r\n * Animates the particle system for this frame.\r\n */\r\n animate(): void;\r\n /**\r\n * Renders the particle system in its current state.\r\n * @returns the current number of particles\r\n */\r\n render(): number;\r\n /**\r\n * Dispose the particle system and frees its associated resources.\r\n * @param disposeTexture defines if the particle texture must be disposed as well (true by default)\r\n */\r\n dispose(disposeTexture?: boolean): void;\r\n /**\r\n * An event triggered when the system is disposed\r\n */\r\n onDisposeObservable: Observable<IParticleSystem>;\r\n /**\r\n * An event triggered when the system is stopped\r\n */\r\n onStoppedObservable: Observable<IParticleSystem>;\r\n /**\r\n * Clones the particle system.\r\n * @param name The name of the cloned object\r\n * @param newEmitter The new emitter to use\r\n * @returns the cloned particle system\r\n */\r\n clone(name: string, newEmitter: any): Nullable<IParticleSystem>;\r\n /**\r\n * Serializes the particle system to a JSON object\r\n * @param serializeTexture defines if the texture must be serialized as well\r\n * @returns the JSON object\r\n */\r\n serialize(serializeTexture: boolean): any;\r\n /**\r\n * Rebuild the particle system\r\n */\r\n rebuild(): void;\r\n\r\n /** Force the system to rebuild all gradients that need to be resync */\r\n forceRefreshGradients(): void;\r\n\r\n /**\r\n * Starts the particle system and begins to emit\r\n * @param delay defines the delay in milliseconds before starting the system (0 by default)\r\n */\r\n start(delay?: number): void;\r\n\r\n /**\r\n * Stops the particle system.\r\n */\r\n stop(): void;\r\n\r\n /**\r\n * Remove all active particles\r\n */\r\n reset(): void;\r\n\r\n /**\r\n * Gets a boolean indicating that the system is stopping\r\n * @returns true if the system is currently stopping\r\n */\r\n isStopping(): boolean;\r\n\r\n /**\r\n * Is this system ready to be used/rendered\r\n * @returns true if the system is ready\r\n */\r\n isReady(): boolean;\r\n /**\r\n * Returns the string \"ParticleSystem\"\r\n * @returns a string containing the class name\r\n */\r\n getClassName(): string;\r\n /**\r\n * Gets the custom effect used to render the particles\r\n * @param blendMode Blend mode for which the effect should be retrieved\r\n * @returns The effect\r\n */\r\n getCustomEffect(blendMode: number): Nullable<Effect>;\r\n /**\r\n * Sets the custom effect used to render the particles\r\n * @param effect The effect to set\r\n * @param blendMode Blend mode for which the effect should be set\r\n */\r\n setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;\r\n\r\n /**\r\n * Fill the defines array according to the current settings of the particle system\r\n * @param defines Array to be updated\r\n * @param blendMode blend mode to take into account when updating the array\r\n */\r\n fillDefines(defines: Array<string>, blendMode: number): void;\r\n /**\r\n * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system\r\n * @param uniforms Uniforms array to fill\r\n * @param attributes Attributes array to fill\r\n * @param samplers Samplers array to fill\r\n */\r\n fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;\r\n /**\r\n * Observable that will be called just before the particles are drawn\r\n */\r\n onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;\r\n /**\r\n * Gets the name of the particle vertex shader\r\n */\r\n vertexShaderName: string;\r\n\r\n /**\r\n * Gets the vertex buffers used by the particle system\r\n */\r\n vertexBuffers: Immutable<{ [key: string]: VertexBuffer }>;\r\n /**\r\n * Gets the index buffer used by the particle system (or null if no index buffer is used)\r\n */\r\n indexBuffer: Nullable<DataBuffer>;\r\n\r\n /**\r\n * Adds a new color gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color1 defines the color to affect to the specified gradient\r\n * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from\r\n * @returns the current particle system\r\n */\r\n addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;\r\n /**\r\n * Remove a specific color gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeColorGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new size gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the size factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n /**\r\n * Gets the current list of size gradients.\r\n * You must use addSizeGradient and removeSizeGradient to update this list\r\n * @returns the list of size gradients\r\n */\r\n getSizeGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Gets the current list of angular speed gradients.\r\n * You must use addAngularSpeedGradient and removeAngularSpeedGradient to update this list\r\n * @returns the list of angular speed gradients\r\n */\r\n getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new angular speed gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the angular speed to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific angular speed gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeAngularSpeedGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of velocity gradients.\r\n * You must use addVelocityGradient and removeVelocityGradient to update this list\r\n * @returns the list of velocity gradients\r\n */\r\n getVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of limit velocity gradients.\r\n * You must use addLimitVelocityGradient and removeLimitVelocityGradient to update this list\r\n * @returns the list of limit velocity gradients\r\n */\r\n getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new limit velocity gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the limit velocity to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific limit velocity gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLimitVelocityGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Adds a new drag gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the drag to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific drag gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeDragGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of drag gradients.\r\n * You must use addDragGradient and removeDragGradient to update this list\r\n * @returns the list of drag gradients\r\n */\r\n getDragGradients(): Nullable<Array<FactorGradient>>;\r\n /**\r\n * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the emit rate to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific emit rate gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeEmitRateGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of emit rate gradients.\r\n * You must use addEmitRateGradient and removeEmitRateGradient to update this list\r\n * @returns the list of emit rate gradients\r\n */\r\n getEmitRateGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the start size to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific start size gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeStartSizeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of start size gradients.\r\n * You must use addStartSizeGradient and removeStartSizeGradient to update this list\r\n * @returns the list of start size gradients\r\n */\r\n getStartSizeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new life time gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param factor defines the life time factor to affect to the specified gradient\r\n * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from\r\n * @returns the current particle system\r\n */\r\n addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;\r\n /**\r\n * Remove a specific life time gradient\r\n * @param gradient defines the gradient to remove\r\n * @returns the current particle system\r\n */\r\n removeLifeTimeGradient(gradient: number): IParticleSystem;\r\n /**\r\n * Gets the current list of life time gradients.\r\n * You must use addLifeTimeGradient and removeLifeTimeGradient to update this list\r\n * @returns the list of life time gradients\r\n */\r\n getLifeTimeGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Gets the current list of color gradients.\r\n * You must use addColorGradient and removeColorGradient to update this list\r\n * @returns the list of color gradients\r\n */\r\n getColorGradients(): Nullable<Array<ColorGradient>>;\r\n\r\n /**\r\n * Adds a new ramp gradient used to remap particle colors\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param color defines the color to affect to the specified gradient\r\n * @returns the current particle system\r\n */\r\n addRampGradient(gradient: number, color: Color3): IParticleSystem;\r\n /**\r\n * Gets the current list of ramp gradients.\r\n * You must use addRampGradient and removeRampGradient to update this list\r\n * @returns the list of ramp gradients\r\n */\r\n getRampGradients(): Nullable<Array<Color3Gradient>>;\r\n\r\n /** Gets or sets a boolean indicating that ramp gradients must be used\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/particles/particle_system/ramps_and_blends\r\n */\r\n useRampGradients: boolean;\r\n\r\n /**\r\n * Adds a new color remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the color remap minimal range\r\n * @param max defines the color remap maximal range\r\n * @returns the current particle system\r\n */\r\n addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of color remap gradients.\r\n * You must use addColorRemapGradient and removeColorRemapGradient to update this list\r\n * @returns the list of color remap gradients\r\n */\r\n getColorRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Adds a new alpha remap gradient\r\n * @param gradient defines the gradient to use (between 0 and 1)\r\n * @param min defines the alpha remap minimal range\r\n * @param max defines the alpha remap maximal range\r\n * @returns the current particle system\r\n */\r\n addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;\r\n /**\r\n * Gets the current list of alpha remap gradients.\r\n * You must use addAlphaRemapGradient and removeAlphaRemapGradient to update this list\r\n * @returns the list of alpha remap gradients\r\n */\r\n getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;\r\n\r\n /**\r\n * Creates a Point Emitter for the particle system (emits directly from the emitter position)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @returns the emitter\r\n */\r\n createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;\r\n\r\n /**\r\n * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)\r\n * @param radius The radius of the hemisphere to emit from\r\n * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;\r\n\r\n /**\r\n * Creates a Sphere Emitter for the particle system (emits along the sphere radius)\r\n * @param radius The radius of the sphere to emit from\r\n * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius\r\n * @returns the emitter\r\n */\r\n createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the sphere to emit from\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere\r\n * @returns the emitter\r\n */\r\n createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)\r\n * @param radius The radius of the emission cylinder\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius\r\n * @param directionRandomizer How much to randomize the particle direction [0-1]\r\n * @returns the emitter\r\n */\r\n createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;\r\n\r\n /**\r\n * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)\r\n * @param radius The radius of the cylinder to emit from\r\n * @param height The height of the emission cylinder\r\n * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder\r\n * @returns the emitter\r\n */\r\n createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;\r\n\r\n /**\r\n * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)\r\n * @param radius The radius of the cone to emit from\r\n * @param angle The base angle of the cone\r\n * @returns the emitter\r\n */\r\n createConeEmitter(radius: number, angle: number): ConeParticleEmitter;\r\n\r\n /**\r\n * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)\r\n * @param direction1 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param direction2 Particles are emitted between the direction1 and direction2 from within the box\r\n * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox\r\n * @returns the emitter\r\n */\r\n createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;\r\n\r\n /**\r\n * Get hosting scene\r\n * @returns the scene\r\n */\r\n getScene(): Nullable<Scene>;\r\n}\r\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { Nullable } from "../types";
|
|
1
|
+
import type { Immutable, Nullable } from "../types";
|
|
2
2
|
import type { Color3Gradient, IValueGradient } from "../Misc/gradients";
|
|
3
3
|
import { Observable } from "../Misc/observable";
|
|
4
4
|
import { Matrix } from "../Maths/math.vector";
|
|
5
5
|
import { Color4 } from "../Maths/math.color";
|
|
6
|
+
import { VertexBuffer } from "../Buffers/buffer";
|
|
6
7
|
import type { IParticleSystem } from "./IParticleSystem";
|
|
7
8
|
import { BaseParticleSystem } from "./baseParticleSystem";
|
|
8
9
|
import type { IDisposable } from "../scene";
|
|
@@ -10,6 +11,7 @@ import type { Effect } from "../Materials/effect";
|
|
|
10
11
|
import { RawTexture } from "../Materials/Textures/rawTexture";
|
|
11
12
|
import type { IAnimatable } from "../Animations/animatable.interface";
|
|
12
13
|
import { ThinEngine } from "../Engines/thinEngine";
|
|
14
|
+
import type { DataBuffer } from "../Buffers/dataBuffer";
|
|
13
15
|
import { DrawWrapper } from "../Materials/drawWrapper";
|
|
14
16
|
declare type Scene = import("../scene").Scene;
|
|
15
17
|
import "../Shaders/gpuRenderParticles.fragment";
|
|
@@ -32,6 +34,7 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
32
34
|
private _buffer0;
|
|
33
35
|
private _buffer1;
|
|
34
36
|
private _spriteBuffer;
|
|
37
|
+
private _renderVertexBuffers;
|
|
35
38
|
private _targetIndex;
|
|
36
39
|
private _sourceBuffer;
|
|
37
40
|
private _targetBuffer;
|
|
@@ -44,6 +47,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
44
47
|
_randomTexture: RawTexture;
|
|
45
48
|
/** @internal */
|
|
46
49
|
_randomTexture2: RawTexture;
|
|
50
|
+
/** Indicates that the update of particles is done in the animate function (and not in render). Default: false */
|
|
51
|
+
updateInAnimate: boolean;
|
|
47
52
|
private _attributesStrideSize;
|
|
48
53
|
private _cachedUpdateDefines;
|
|
49
54
|
private _randomTextureSize;
|
|
@@ -84,6 +89,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
84
89
|
* Specifies if the particles are updated in emitter local space or world space.
|
|
85
90
|
*/
|
|
86
91
|
isLocal: boolean;
|
|
92
|
+
/** Indicates that the particle system is GPU based */
|
|
93
|
+
readonly isGPU = true;
|
|
87
94
|
/** Gets or sets a matrix to use to compute projection */
|
|
88
95
|
defaultProjectionMatrix: Matrix;
|
|
89
96
|
/**
|
|
@@ -152,6 +159,18 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
152
159
|
* Gets the name of the particle vertex shader
|
|
153
160
|
*/
|
|
154
161
|
get vertexShaderName(): string;
|
|
162
|
+
/**
|
|
163
|
+
* Gets the vertex buffers used by the particle system
|
|
164
|
+
* Should be called after render() has been called for the current frame so that the buffers returned are the ones that have been updated
|
|
165
|
+
* in the current frame (there's a ping-pong between two sets of buffers - for a given frame, one set is used as the source and the other as the destination)
|
|
166
|
+
*/
|
|
167
|
+
get vertexBuffers(): Immutable<{
|
|
168
|
+
[key: string]: VertexBuffer;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the index buffer used by the particle system (null for GPU particle systems)
|
|
172
|
+
*/
|
|
173
|
+
get indexBuffer(): Nullable<DataBuffer>;
|
|
155
174
|
/** @internal */
|
|
156
175
|
_colorGradientsTexture: RawTexture;
|
|
157
176
|
protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
|
|
@@ -380,6 +399,8 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
380
399
|
private _createDragGradientTexture;
|
|
381
400
|
private _createColorGradientTexture;
|
|
382
401
|
private _render;
|
|
402
|
+
/** @internal */
|
|
403
|
+
_update(emitterWM?: Matrix): void;
|
|
383
404
|
/**
|
|
384
405
|
* Renders the particle system in its current state
|
|
385
406
|
* @param preWarm defines if the system should only update the particles but not render them
|
|
@@ -401,9 +422,10 @@ export declare class GPUParticleSystem extends BaseParticleSystem implements IDi
|
|
|
401
422
|
* Clones the particle system.
|
|
402
423
|
* @param name The name of the cloned object
|
|
403
424
|
* @param newEmitter The new emitter to use
|
|
425
|
+
* @param cloneTexture Also clone the textures if true
|
|
404
426
|
* @returns the cloned particle system
|
|
405
427
|
*/
|
|
406
|
-
clone(name: string, newEmitter: any): GPUParticleSystem;
|
|
428
|
+
clone(name: string, newEmitter: any, cloneTexture?: boolean): GPUParticleSystem;
|
|
407
429
|
/**
|
|
408
430
|
* Serializes the particle system to a JSON object
|
|
409
431
|
* @param serializeTexture defines if the texture must be serialized as well
|
|
@@ -41,12 +41,15 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
41
41
|
*/
|
|
42
42
|
this.layerMask = 0x0fffffff;
|
|
43
43
|
this._accumulatedCount = 0;
|
|
44
|
+
this._renderVertexBuffers = [];
|
|
44
45
|
this._targetIndex = 0;
|
|
45
46
|
this._currentRenderId = -1;
|
|
46
47
|
this._currentRenderingCameraUniqueId = -1;
|
|
47
48
|
this._started = false;
|
|
48
49
|
this._stopped = false;
|
|
49
50
|
this._timeDelta = 0;
|
|
51
|
+
/** Indicates that the update of particles is done in the animate function (and not in render). Default: false */
|
|
52
|
+
this.updateInAnimate = false;
|
|
50
53
|
this._actualFrame = 0;
|
|
51
54
|
this._rawTextureWidth = 256;
|
|
52
55
|
/**
|
|
@@ -67,6 +70,8 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
67
70
|
* Specifies if the particles are updated in emitter local space or world space.
|
|
68
71
|
*/
|
|
69
72
|
this.isLocal = false;
|
|
73
|
+
/** Indicates that the particle system is GPU based */
|
|
74
|
+
this.isGPU = true;
|
|
70
75
|
/** @internal */
|
|
71
76
|
this._onBeforeDrawParticlesObservable = null;
|
|
72
77
|
if (!sceneOrEngine || sceneOrEngine.getClassName() === "Scene") {
|
|
@@ -308,6 +313,24 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
308
313
|
get vertexShaderName() {
|
|
309
314
|
return "gpuRenderParticles";
|
|
310
315
|
}
|
|
316
|
+
/**
|
|
317
|
+
* Gets the vertex buffers used by the particle system
|
|
318
|
+
* Should be called after render() has been called for the current frame so that the buffers returned are the ones that have been updated
|
|
319
|
+
* in the current frame (there's a ping-pong between two sets of buffers - for a given frame, one set is used as the source and the other as the destination)
|
|
320
|
+
*/
|
|
321
|
+
get vertexBuffers() {
|
|
322
|
+
// We return the other buffers than those corresponding to this._targetIndex because it is assumed vertexBuffers will be called in the current frame
|
|
323
|
+
// after render() has been called, meaning that the buffers have already been swapped and this._targetIndex points to the buffers that will be updated
|
|
324
|
+
// in the next frame (and which are the sources in this frame) and (this._targetIndex ^ 1) points to the buffers that have been updated this frame
|
|
325
|
+
// (and that will be the source buffers in the next frame)
|
|
326
|
+
return this._renderVertexBuffers[this._targetIndex ^ 1];
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Gets the index buffer used by the particle system (null for GPU particle systems)
|
|
330
|
+
*/
|
|
331
|
+
get indexBuffer() {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
311
334
|
_removeGradientAndTexture(gradient, gradients, texture) {
|
|
312
335
|
super._removeGradientAndTexture(gradient, gradients, texture);
|
|
313
336
|
this._releaseBuffers();
|
|
@@ -711,6 +734,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
711
734
|
}
|
|
712
735
|
renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
|
|
713
736
|
renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
|
|
737
|
+
this._renderVertexBuffers.push(renderVertexBuffers);
|
|
714
738
|
this._platform.createVertexBuffers(updateBuffer, renderVertexBuffers);
|
|
715
739
|
this.resetDrawCache();
|
|
716
740
|
}
|
|
@@ -871,6 +895,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
871
895
|
this._buffer1 = new Buffer(engine, bufferData2, false, this._attributesStrideSize);
|
|
872
896
|
this._spriteBuffer = new Buffer(engine, spriteData, false, 4);
|
|
873
897
|
// Update & Render vertex buffers
|
|
898
|
+
this._renderVertexBuffers = [];
|
|
874
899
|
this._createVertexBuffers(this._buffer0, this._buffer1, this._spriteBuffer);
|
|
875
900
|
this._createVertexBuffers(this._buffer1, this._buffer0, this._spriteBuffer);
|
|
876
901
|
// Links
|
|
@@ -1055,6 +1080,9 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1055
1080
|
this.stop();
|
|
1056
1081
|
}
|
|
1057
1082
|
}
|
|
1083
|
+
if (this.updateInAnimate) {
|
|
1084
|
+
this._update();
|
|
1085
|
+
}
|
|
1058
1086
|
}
|
|
1059
1087
|
_createFactorGradientTexture(factorGradients, textureName) {
|
|
1060
1088
|
const texture = this[textureName];
|
|
@@ -1174,6 +1202,62 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1174
1202
|
this._engine.setAlphaMode(0);
|
|
1175
1203
|
return this._currentActiveCount;
|
|
1176
1204
|
}
|
|
1205
|
+
/** @internal */
|
|
1206
|
+
_update(emitterWM) {
|
|
1207
|
+
if (!this.emitter) {
|
|
1208
|
+
return;
|
|
1209
|
+
}
|
|
1210
|
+
this._recreateUpdateEffect();
|
|
1211
|
+
if (this.emitter.position) {
|
|
1212
|
+
const emitterMesh = this.emitter;
|
|
1213
|
+
emitterWM = emitterMesh.getWorldMatrix();
|
|
1214
|
+
}
|
|
1215
|
+
else {
|
|
1216
|
+
const emitterPosition = this.emitter;
|
|
1217
|
+
emitterWM = TmpVectors.Matrix[0];
|
|
1218
|
+
Matrix.TranslationToRef(emitterPosition.x, emitterPosition.y, emitterPosition.z, emitterWM);
|
|
1219
|
+
}
|
|
1220
|
+
this._platform.preUpdateParticleBuffer();
|
|
1221
|
+
this._updateBuffer.setFloat("currentCount", this._currentActiveCount);
|
|
1222
|
+
this._updateBuffer.setFloat("timeDelta", this._timeDelta);
|
|
1223
|
+
this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1);
|
|
1224
|
+
this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize);
|
|
1225
|
+
this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
|
|
1226
|
+
this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
|
|
1227
|
+
if (!this._colorGradientsTexture) {
|
|
1228
|
+
this._updateBuffer.setDirectColor4("color1", this.color1);
|
|
1229
|
+
this._updateBuffer.setDirectColor4("color2", this.color2);
|
|
1230
|
+
}
|
|
1231
|
+
this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize);
|
|
1232
|
+
this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
|
|
1233
|
+
this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
|
|
1234
|
+
this._updateBuffer.setVector3("gravity", this.gravity);
|
|
1235
|
+
if (this._limitVelocityGradientsTexture) {
|
|
1236
|
+
this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping);
|
|
1237
|
+
}
|
|
1238
|
+
if (this.particleEmitterType) {
|
|
1239
|
+
this.particleEmitterType.applyToShader(this._updateBuffer);
|
|
1240
|
+
}
|
|
1241
|
+
if (this._isAnimationSheetEnabled) {
|
|
1242
|
+
this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0);
|
|
1243
|
+
}
|
|
1244
|
+
if (this.noiseTexture) {
|
|
1245
|
+
this._updateBuffer.setVector3("noiseStrength", this.noiseStrength);
|
|
1246
|
+
}
|
|
1247
|
+
if (!this.isLocal) {
|
|
1248
|
+
this._updateBuffer.setMatrix("emitterWM", emitterWM);
|
|
1249
|
+
}
|
|
1250
|
+
this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
|
|
1251
|
+
// Switch VAOs
|
|
1252
|
+
this._targetIndex++;
|
|
1253
|
+
if (this._targetIndex === 2) {
|
|
1254
|
+
this._targetIndex = 0;
|
|
1255
|
+
}
|
|
1256
|
+
// Switch buffers
|
|
1257
|
+
const tmpBuffer = this._sourceBuffer;
|
|
1258
|
+
this._sourceBuffer = this._targetBuffer;
|
|
1259
|
+
this._targetBuffer = tmpBuffer;
|
|
1260
|
+
}
|
|
1177
1261
|
/**
|
|
1178
1262
|
* Renders the particle system in its current state
|
|
1179
1263
|
* @param preWarm defines if the system should only update the particles but not render them
|
|
@@ -1190,7 +1274,6 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1190
1274
|
this._createVelocityGradientTexture();
|
|
1191
1275
|
this._createLimitVelocityGradientTexture();
|
|
1192
1276
|
this._createDragGradientTexture();
|
|
1193
|
-
this._recreateUpdateEffect();
|
|
1194
1277
|
if (!this.isReady()) {
|
|
1195
1278
|
return 0;
|
|
1196
1279
|
}
|
|
@@ -1230,40 +1313,13 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1230
1313
|
}
|
|
1231
1314
|
else {
|
|
1232
1315
|
const emitterPosition = this.emitter;
|
|
1233
|
-
emitterWM = Matrix
|
|
1316
|
+
emitterWM = TmpVectors.Matrix[0];
|
|
1317
|
+
Matrix.TranslationToRef(emitterPosition.x, emitterPosition.y, emitterPosition.z, emitterWM);
|
|
1234
1318
|
}
|
|
1235
1319
|
const engine = this._engine;
|
|
1236
|
-
this.
|
|
1237
|
-
|
|
1238
|
-
this._updateBuffer.setFloat("timeDelta", this._timeDelta);
|
|
1239
|
-
this._updateBuffer.setFloat("stopFactor", this._stopped ? 0 : 1);
|
|
1240
|
-
this._updateBuffer.setInt("randomTextureSize", this._randomTextureSize);
|
|
1241
|
-
this._updateBuffer.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
|
|
1242
|
-
this._updateBuffer.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
|
|
1243
|
-
if (!this._colorGradientsTexture) {
|
|
1244
|
-
this._updateBuffer.setDirectColor4("color1", this.color1);
|
|
1245
|
-
this._updateBuffer.setDirectColor4("color2", this.color2);
|
|
1320
|
+
if (!this.updateInAnimate) {
|
|
1321
|
+
this._update(emitterWM);
|
|
1246
1322
|
}
|
|
1247
|
-
this._updateBuffer.setFloat2("sizeRange", this.minSize, this.maxSize);
|
|
1248
|
-
this._updateBuffer.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
|
|
1249
|
-
this._updateBuffer.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
|
|
1250
|
-
this._updateBuffer.setVector3("gravity", this.gravity);
|
|
1251
|
-
if (this._limitVelocityGradientsTexture) {
|
|
1252
|
-
this._updateBuffer.setFloat("limitVelocityDamping", this.limitVelocityDamping);
|
|
1253
|
-
}
|
|
1254
|
-
if (this.particleEmitterType) {
|
|
1255
|
-
this.particleEmitterType.applyToShader(this._updateBuffer);
|
|
1256
|
-
}
|
|
1257
|
-
if (this._isAnimationSheetEnabled) {
|
|
1258
|
-
this._updateBuffer.setFloat4("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed, this.spriteCellLoop ? 1 : 0);
|
|
1259
|
-
}
|
|
1260
|
-
if (this.noiseTexture) {
|
|
1261
|
-
this._updateBuffer.setVector3("noiseStrength", this.noiseStrength);
|
|
1262
|
-
}
|
|
1263
|
-
if (!this.isLocal) {
|
|
1264
|
-
this._updateBuffer.setMatrix("emitterWM", emitterWM);
|
|
1265
|
-
}
|
|
1266
|
-
this._platform.updateParticleBuffer(this._targetIndex, this._targetBuffer, this._currentActiveCount);
|
|
1267
1323
|
let outparticles = 0;
|
|
1268
1324
|
if (!preWarm && !forceUpdateOnly) {
|
|
1269
1325
|
engine.setState(false);
|
|
@@ -1278,15 +1334,6 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1278
1334
|
}
|
|
1279
1335
|
this._engine.setAlphaMode(0);
|
|
1280
1336
|
}
|
|
1281
|
-
// Switch VAOs
|
|
1282
|
-
this._targetIndex++;
|
|
1283
|
-
if (this._targetIndex === 2) {
|
|
1284
|
-
this._targetIndex = 0;
|
|
1285
|
-
}
|
|
1286
|
-
// Switch buffers
|
|
1287
|
-
const tmpBuffer = this._sourceBuffer;
|
|
1288
|
-
this._sourceBuffer = this._targetBuffer;
|
|
1289
|
-
this._targetBuffer = tmpBuffer;
|
|
1290
1337
|
return outparticles;
|
|
1291
1338
|
}
|
|
1292
1339
|
/**
|
|
@@ -1328,6 +1375,13 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1328
1375
|
}
|
|
1329
1376
|
this._releaseBuffers();
|
|
1330
1377
|
this._platform.releaseVertexBuffers();
|
|
1378
|
+
for (let i = 0; i < this._renderVertexBuffers.length; ++i) {
|
|
1379
|
+
const rvb = this._renderVertexBuffers[i];
|
|
1380
|
+
for (const key in rvb) {
|
|
1381
|
+
rvb[key].dispose();
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
this._renderVertexBuffers = [];
|
|
1331
1385
|
if (this._colorGradientsTexture) {
|
|
1332
1386
|
this._colorGradientsTexture.dispose();
|
|
1333
1387
|
this._colorGradientsTexture = null;
|
|
@@ -1377,9 +1431,10 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1377
1431
|
* Clones the particle system.
|
|
1378
1432
|
* @param name The name of the cloned object
|
|
1379
1433
|
* @param newEmitter The new emitter to use
|
|
1434
|
+
* @param cloneTexture Also clone the textures if true
|
|
1380
1435
|
* @returns the cloned particle system
|
|
1381
1436
|
*/
|
|
1382
|
-
clone(name, newEmitter) {
|
|
1437
|
+
clone(name, newEmitter, cloneTexture = false) {
|
|
1383
1438
|
const custom = { ...this._customWrappers };
|
|
1384
1439
|
let program = null;
|
|
1385
1440
|
const engine = this._engine;
|
|
@@ -1390,7 +1445,7 @@ export class GPUParticleSystem extends BaseParticleSystem {
|
|
|
1390
1445
|
custom[0] = engine.createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines, undefined, undefined, undefined, this);
|
|
1391
1446
|
}
|
|
1392
1447
|
}
|
|
1393
|
-
const serialization = this.serialize();
|
|
1448
|
+
const serialization = this.serialize(cloneTexture);
|
|
1394
1449
|
const result = GPUParticleSystem.Parse(serialization, this._scene || this._engine, this._rootUrl);
|
|
1395
1450
|
result.name = name;
|
|
1396
1451
|
result.customShader = program;
|