@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
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
|
|
2
|
+
import { CopyTextureToTexture } from "../../Misc/copyTextureToTexture.js";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export class FluidRenderingDepthTextureCopy {
|
|
5
|
+
constructor(engine, width, height, samples = 1) {
|
|
6
|
+
this._engine = engine;
|
|
7
|
+
this._copyTextureToTexture = new CopyTextureToTexture(engine, true);
|
|
8
|
+
this._depthRTWrapper = this._engine.createRenderTargetTexture({ width, height }, {
|
|
9
|
+
generateMipMaps: false,
|
|
10
|
+
type: 0,
|
|
11
|
+
format: 6,
|
|
12
|
+
samplingMode: 1,
|
|
13
|
+
generateDepthBuffer: true,
|
|
14
|
+
generateStencilBuffer: false,
|
|
15
|
+
samples,
|
|
16
|
+
noColorAttachment: true,
|
|
17
|
+
});
|
|
18
|
+
this._depthRTWrapper.createDepthStencilTexture(0, false, false, 1);
|
|
19
|
+
}
|
|
20
|
+
get depthRTWrapper() {
|
|
21
|
+
return this._depthRTWrapper;
|
|
22
|
+
}
|
|
23
|
+
copy(source) {
|
|
24
|
+
return this._copyTextureToTexture.copy(source, this._depthRTWrapper);
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
this._depthRTWrapper.dispose();
|
|
28
|
+
this._copyTextureToTexture.dispose();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=fluidRenderingDepthTextureCopy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidRenderingDepthTextureCopy.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/fluidRenderer/fluidRenderingDepthTextureCopy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAInD,OAAO,EAAE,oBAAoB,EAAE,2CAAuC;AAEtE,gBAAgB;AAChB,MAAM,OAAO,8BAA8B;IASvC,YAAY,MAAc,EAAE,KAAa,EAAE,MAAc,EAAE,OAAO,GAAG,CAAC;QAClE,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,qBAAqB,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEpE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,CACzD,EAAE,KAAK,EAAE,MAAM,EAAE,EACjB;YACI,eAAe,EAAE,KAAK;YACtB,IAAI,EAAE,SAAS,CAAC,yBAAyB;YACzC,MAAM,EAAE,SAAS,CAAC,eAAe;YACjC,YAAY,EAAE,SAAS,CAAC,4BAA4B;YACpD,mBAAmB,EAAE,IAAI;YACzB,qBAAqB,EAAE,KAAK;YAC5B,OAAO;YACP,iBAAiB,EAAE,IAAI;SAC1B,CACJ,CAAC;QACF,IAAI,CAAC,eAAe,CAAC,yBAAyB,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IACvE,CAAC;IAtBD,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAsBM,IAAI,CAAC,MAAuB;QAC/B,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACzE,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACJ","sourcesContent":["import { Constants } from \"core/Engines/constants\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\nimport type { RenderTargetWrapper } from \"core/Engines/renderTargetWrapper\";\r\nimport type { InternalTexture } from \"core/Materials/Textures/internalTexture\";\r\nimport { CopyTextureToTexture } from \"core/Misc/copyTextureToTexture\";\r\n\r\n/** @internal */\r\nexport class FluidRenderingDepthTextureCopy {\r\n private _engine: Engine;\r\n private _depthRTWrapper: RenderTargetWrapper;\r\n private _copyTextureToTexture: CopyTextureToTexture;\r\n\r\n public get depthRTWrapper() {\r\n return this._depthRTWrapper;\r\n }\r\n\r\n constructor(engine: Engine, width: number, height: number, samples = 1) {\r\n this._engine = engine;\r\n this._copyTextureToTexture = new CopyTextureToTexture(engine, true);\r\n\r\n this._depthRTWrapper = this._engine.createRenderTargetTexture(\r\n { width, height },\r\n {\r\n generateMipMaps: false,\r\n type: Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n format: Constants.TEXTUREFORMAT_R,\r\n samplingMode: Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n generateDepthBuffer: true,\r\n generateStencilBuffer: false,\r\n samples,\r\n noColorAttachment: true,\r\n }\r\n );\r\n this._depthRTWrapper.createDepthStencilTexture(0, false, false, 1);\r\n }\r\n\r\n public copy(source: InternalTexture): boolean {\r\n return this._copyTextureToTexture.copy(source, this._depthRTWrapper);\r\n }\r\n\r\n public dispose() {\r\n this._depthRTWrapper.dispose();\r\n this._copyTextureToTexture.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { VertexBuffer } from "../../Buffers/buffer.js";
|
|
2
|
+
import type { DataBuffer } from "../../Buffers/dataBuffer.js";
|
|
3
|
+
import type { Engine } from "../../Engines/engine.js";
|
|
4
|
+
import { EffectWrapper } from "../../Materials/effectRenderer.js";
|
|
5
|
+
import { Observable } from "../../Misc/observable.js";
|
|
6
|
+
import type { Scene } from "../../scene.js";
|
|
7
|
+
import type { Nullable } from "../../types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Defines the base object used for fluid rendering.
|
|
10
|
+
* It is based on a list of vertices (particles)
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class FluidRenderingObject {
|
|
13
|
+
protected _scene: Scene;
|
|
14
|
+
protected _engine: Engine;
|
|
15
|
+
protected _effectsAreDirty: boolean;
|
|
16
|
+
protected _depthEffectWrapper: Nullable<EffectWrapper>;
|
|
17
|
+
protected _thicknessEffectWrapper: Nullable<EffectWrapper>;
|
|
18
|
+
/** Defines the priority of the object. Objects will be rendered in ascending order of priority */
|
|
19
|
+
priority: number;
|
|
20
|
+
protected _particleSize: number;
|
|
21
|
+
/** Observable triggered when the size of the particle is changed */
|
|
22
|
+
onParticleSizeChanged: Observable<FluidRenderingObject>;
|
|
23
|
+
/** Gets or sets the size of the particle */
|
|
24
|
+
get particleSize(): number;
|
|
25
|
+
set particleSize(size: number);
|
|
26
|
+
/** Defines the alpha value of a particle */
|
|
27
|
+
particleThicknessAlpha: number;
|
|
28
|
+
/** Indicates if the object uses instancing or not */
|
|
29
|
+
get useInstancing(): boolean;
|
|
30
|
+
private _useVelocity;
|
|
31
|
+
/** Indicates if velocity of particles should be used when rendering the object. The vertex buffer set must contain a "velocity" buffer for this to work! */
|
|
32
|
+
get useVelocity(): boolean;
|
|
33
|
+
set useVelocity(use: boolean);
|
|
34
|
+
private _hasVelocity;
|
|
35
|
+
/**
|
|
36
|
+
* Gets the vertex buffers
|
|
37
|
+
*/
|
|
38
|
+
abstract get vertexBuffers(): {
|
|
39
|
+
[key: string]: VertexBuffer;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Gets the index buffer (or null if the object is using instancing)
|
|
43
|
+
*/
|
|
44
|
+
get indexBuffer(): Nullable<DataBuffer>;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the name of the class
|
|
47
|
+
*/
|
|
48
|
+
getClassName(): string;
|
|
49
|
+
/**
|
|
50
|
+
* Instantiates a fluid rendering object
|
|
51
|
+
* @param scene The scene the object is part of
|
|
52
|
+
*/
|
|
53
|
+
constructor(scene: Scene);
|
|
54
|
+
protected _createEffects(): void;
|
|
55
|
+
/**
|
|
56
|
+
* Indicates if the object is ready to be rendered
|
|
57
|
+
* @returns True if everything is ready for the object to be rendered, otherwise false
|
|
58
|
+
*/
|
|
59
|
+
isReady(): boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the number of particles (vertices) of this object
|
|
62
|
+
* @returns The number of particles
|
|
63
|
+
*/
|
|
64
|
+
abstract get numParticles(): number;
|
|
65
|
+
/**
|
|
66
|
+
* Render the depth texture for this object
|
|
67
|
+
*/
|
|
68
|
+
renderDepthTexture(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Render the thickness texture for this object
|
|
71
|
+
*/
|
|
72
|
+
renderThicknessTexture(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Render the diffuse texture for this object
|
|
75
|
+
*/
|
|
76
|
+
renderDiffuseTexture(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Releases the ressources used by the class
|
|
79
|
+
*/
|
|
80
|
+
dispose(): void;
|
|
81
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
|
|
2
|
+
import { EffectWrapper } from "../../Materials/effectRenderer.js";
|
|
3
|
+
import { Observable } from "../../Misc/observable.js";
|
|
4
|
+
/**
|
|
5
|
+
* Defines the base object used for fluid rendering.
|
|
6
|
+
* It is based on a list of vertices (particles)
|
|
7
|
+
*/
|
|
8
|
+
export class FluidRenderingObject {
|
|
9
|
+
/**
|
|
10
|
+
* Instantiates a fluid rendering object
|
|
11
|
+
* @param scene The scene the object is part of
|
|
12
|
+
*/
|
|
13
|
+
constructor(scene) {
|
|
14
|
+
/** Defines the priority of the object. Objects will be rendered in ascending order of priority */
|
|
15
|
+
this.priority = 0;
|
|
16
|
+
this._particleSize = 0.1;
|
|
17
|
+
/** Observable triggered when the size of the particle is changed */
|
|
18
|
+
this.onParticleSizeChanged = new Observable();
|
|
19
|
+
/** Defines the alpha value of a particle */
|
|
20
|
+
this.particleThicknessAlpha = 0.05;
|
|
21
|
+
this._useVelocity = false;
|
|
22
|
+
this._scene = scene;
|
|
23
|
+
this._engine = scene.getEngine();
|
|
24
|
+
this._effectsAreDirty = true;
|
|
25
|
+
this._depthEffectWrapper = null;
|
|
26
|
+
this._thicknessEffectWrapper = null;
|
|
27
|
+
}
|
|
28
|
+
/** Gets or sets the size of the particle */
|
|
29
|
+
get particleSize() {
|
|
30
|
+
return this._particleSize;
|
|
31
|
+
}
|
|
32
|
+
set particleSize(size) {
|
|
33
|
+
if (size === this._particleSize) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this._particleSize = size;
|
|
37
|
+
this.onParticleSizeChanged.notifyObservers(this);
|
|
38
|
+
}
|
|
39
|
+
/** Indicates if the object uses instancing or not */
|
|
40
|
+
get useInstancing() {
|
|
41
|
+
return !this.indexBuffer;
|
|
42
|
+
}
|
|
43
|
+
/** Indicates if velocity of particles should be used when rendering the object. The vertex buffer set must contain a "velocity" buffer for this to work! */
|
|
44
|
+
get useVelocity() {
|
|
45
|
+
return this._useVelocity;
|
|
46
|
+
}
|
|
47
|
+
set useVelocity(use) {
|
|
48
|
+
if (this._useVelocity === use || !this._hasVelocity()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this._useVelocity = use;
|
|
52
|
+
this._effectsAreDirty = true;
|
|
53
|
+
}
|
|
54
|
+
_hasVelocity() {
|
|
55
|
+
var _a;
|
|
56
|
+
return !!((_a = this.vertexBuffers) === null || _a === void 0 ? void 0 : _a.velocity);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Gets the index buffer (or null if the object is using instancing)
|
|
60
|
+
*/
|
|
61
|
+
get indexBuffer() {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets the name of the class
|
|
66
|
+
*/
|
|
67
|
+
getClassName() {
|
|
68
|
+
return "FluidRenderingObject";
|
|
69
|
+
}
|
|
70
|
+
_createEffects() {
|
|
71
|
+
const uniformNames = ["view", "projection", "particleRadius", "size"];
|
|
72
|
+
const attributeNames = ["position", "offset"];
|
|
73
|
+
const defines = [];
|
|
74
|
+
this._effectsAreDirty = false;
|
|
75
|
+
if (this.useVelocity) {
|
|
76
|
+
attributeNames.push("velocity");
|
|
77
|
+
defines.push("#define FLUIDRENDERING_VELOCITY");
|
|
78
|
+
}
|
|
79
|
+
this._depthEffectWrapper = new EffectWrapper({
|
|
80
|
+
engine: this._engine,
|
|
81
|
+
useShaderStore: true,
|
|
82
|
+
vertexShader: "fluidRenderingParticleDepth",
|
|
83
|
+
fragmentShader: "fluidRenderingParticleDepth",
|
|
84
|
+
attributeNames,
|
|
85
|
+
uniformNames,
|
|
86
|
+
samplerNames: [],
|
|
87
|
+
defines,
|
|
88
|
+
});
|
|
89
|
+
uniformNames.push("particleAlpha");
|
|
90
|
+
this._thicknessEffectWrapper = new EffectWrapper({
|
|
91
|
+
engine: this._engine,
|
|
92
|
+
useShaderStore: true,
|
|
93
|
+
vertexShader: "fluidRenderingParticleThickness",
|
|
94
|
+
fragmentShader: "fluidRenderingParticleThickness",
|
|
95
|
+
attributeNames: ["position", "offset"],
|
|
96
|
+
uniformNames,
|
|
97
|
+
samplerNames: [],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Indicates if the object is ready to be rendered
|
|
102
|
+
* @returns True if everything is ready for the object to be rendered, otherwise false
|
|
103
|
+
*/
|
|
104
|
+
isReady() {
|
|
105
|
+
if (this._effectsAreDirty) {
|
|
106
|
+
this._createEffects();
|
|
107
|
+
}
|
|
108
|
+
if (!this._depthEffectWrapper || !this._thicknessEffectWrapper) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
const depthEffect = this._depthEffectWrapper._drawWrapper.effect;
|
|
112
|
+
const thicknessEffect = this._thicknessEffectWrapper._drawWrapper.effect;
|
|
113
|
+
return depthEffect.isReady() && thicknessEffect.isReady();
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Render the depth texture for this object
|
|
117
|
+
*/
|
|
118
|
+
renderDepthTexture() {
|
|
119
|
+
const numParticles = this.numParticles;
|
|
120
|
+
if (!this._depthEffectWrapper || numParticles === 0) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const depthDrawWrapper = this._depthEffectWrapper._drawWrapper;
|
|
124
|
+
const depthEffect = depthDrawWrapper.effect;
|
|
125
|
+
this._engine.enableEffect(depthDrawWrapper);
|
|
126
|
+
this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, depthEffect);
|
|
127
|
+
depthEffect.setMatrix("view", this._scene.getViewMatrix());
|
|
128
|
+
depthEffect.setMatrix("projection", this._scene.getProjectionMatrix());
|
|
129
|
+
depthEffect.setFloat2("size", this._particleSize, this._particleSize);
|
|
130
|
+
depthEffect.setFloat("particleRadius", this._particleSize / 2);
|
|
131
|
+
if (this.useInstancing) {
|
|
132
|
+
this._engine.drawArraysType(7, 0, 4, numParticles);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
this._engine.drawElementsType(0, 0, numParticles);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Render the thickness texture for this object
|
|
140
|
+
*/
|
|
141
|
+
renderThicknessTexture() {
|
|
142
|
+
const numParticles = this.numParticles;
|
|
143
|
+
if (!this._thicknessEffectWrapper || numParticles === 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const thicknessDrawWrapper = this._thicknessEffectWrapper._drawWrapper;
|
|
147
|
+
const thicknessEffect = thicknessDrawWrapper.effect;
|
|
148
|
+
this._engine.setAlphaMode(6);
|
|
149
|
+
this._engine.setDepthWrite(false);
|
|
150
|
+
this._engine.enableEffect(thicknessDrawWrapper);
|
|
151
|
+
this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, thicknessEffect);
|
|
152
|
+
thicknessEffect.setMatrix("view", this._scene.getViewMatrix());
|
|
153
|
+
thicknessEffect.setMatrix("projection", this._scene.getProjectionMatrix());
|
|
154
|
+
thicknessEffect.setFloat("particleAlpha", this.particleThicknessAlpha);
|
|
155
|
+
thicknessEffect.setFloat2("size", this._particleSize, this._particleSize);
|
|
156
|
+
if (this.useInstancing) {
|
|
157
|
+
this._engine.drawArraysType(7, 0, 4, numParticles);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
this._engine.drawElementsType(0, 0, numParticles);
|
|
161
|
+
}
|
|
162
|
+
this._engine.setDepthWrite(true);
|
|
163
|
+
this._engine.setAlphaMode(0);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Render the diffuse texture for this object
|
|
167
|
+
*/
|
|
168
|
+
renderDiffuseTexture() {
|
|
169
|
+
// do nothing by default
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Releases the ressources used by the class
|
|
173
|
+
*/
|
|
174
|
+
dispose() {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
(_a = this._depthEffectWrapper) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
177
|
+
(_b = this._thicknessEffectWrapper) === null || _b === void 0 ? void 0 : _b.dispose();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=fluidRenderingObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidRenderingObject.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/fluidRenderer/fluidRenderingObject.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,mCAA+B;AAEnD,OAAO,EAAE,aAAa,EAAE,0CAAsC;AAC9D,OAAO,EAAE,UAAU,EAAE,iCAA6B;AAIlD;;;GAGG;AACH,MAAM,OAAgB,oBAAoB;IA4EtC;;;OAGG;IACH,YAAY,KAAY;QAzExB,kGAAkG;QAC3F,aAAQ,GAAG,CAAC,CAAC;QAEV,kBAAa,GAAG,GAAG,CAAC;QAE9B,oEAAoE;QAC7D,0BAAqB,GAAG,IAAI,UAAU,EAAwB,CAAC;QAgBtE,4CAA4C;QACrC,2BAAsB,GAAG,IAAI,CAAC;QAO7B,iBAAY,GAAG,KAAK,CAAC;QA4CzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACjC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAChC,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC;IACxC,CAAC;IA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AAuB,0CAAE,OAAO,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { DataBuffer } from \"core/Buffers/dataBuffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\nimport { EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\n/**\r\n * Defines the base object used for fluid rendering.\r\n * It is based on a list of vertices (particles)\r\n */\r\nexport abstract class FluidRenderingObject {\r\n protected _scene: Scene;\r\n protected _engine: Engine;\r\n protected _effectsAreDirty: boolean;\r\n protected _depthEffectWrapper: Nullable<EffectWrapper>;\r\n protected _thicknessEffectWrapper: Nullable<EffectWrapper>;\r\n\r\n /** Defines the priority of the object. Objects will be rendered in ascending order of priority */\r\n public priority = 0;\r\n\r\n protected _particleSize = 0.1;\r\n\r\n /** Observable triggered when the size of the particle is changed */\r\n public onParticleSizeChanged = new Observable<FluidRenderingObject>();\r\n\r\n /** Gets or sets the size of the particle */\r\n public get particleSize() {\r\n return this._particleSize;\r\n }\r\n\r\n public set particleSize(size: number) {\r\n if (size === this._particleSize) {\r\n return;\r\n }\r\n\r\n this._particleSize = size;\r\n this.onParticleSizeChanged.notifyObservers(this);\r\n }\r\n\r\n /** Defines the alpha value of a particle */\r\n public particleThicknessAlpha = 0.05;\r\n\r\n /** Indicates if the object uses instancing or not */\r\n public get useInstancing() {\r\n return !this.indexBuffer;\r\n }\r\n\r\n private _useVelocity = false;\r\n\r\n /** Indicates if velocity of particles should be used when rendering the object. The vertex buffer set must contain a \"velocity\" buffer for this to work! */\r\n public get useVelocity() {\r\n return this._useVelocity;\r\n }\r\n\r\n public set useVelocity(use: boolean) {\r\n if (this._useVelocity === use || !this._hasVelocity()) {\r\n return;\r\n }\r\n\r\n this._useVelocity = use;\r\n this._effectsAreDirty = true;\r\n }\r\n\r\n private _hasVelocity() {\r\n return !!this.vertexBuffers?.velocity;\r\n }\r\n\r\n /**\r\n * Gets the vertex buffers\r\n */\r\n public abstract get vertexBuffers(): { [key: string]: VertexBuffer };\r\n\r\n /**\r\n * Gets the index buffer (or null if the object is using instancing)\r\n */\r\n public get indexBuffer(): Nullable<DataBuffer> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Gets the name of the class\r\n */\r\n public getClassName(): string {\r\n return \"FluidRenderingObject\";\r\n }\r\n\r\n /**\r\n * Instantiates a fluid rendering object\r\n * @param scene The scene the object is part of\r\n */\r\n constructor(scene: Scene) {\r\n this._scene = scene;\r\n this._engine = scene.getEngine();\r\n this._effectsAreDirty = true;\r\n this._depthEffectWrapper = null;\r\n this._thicknessEffectWrapper = null;\r\n }\r\n\r\n protected _createEffects(): void {\r\n const uniformNames = [\"view\", \"projection\", \"particleRadius\", \"size\"];\r\n const attributeNames = [\"position\", \"offset\"];\r\n const defines: string[] = [];\r\n\r\n this._effectsAreDirty = false;\r\n\r\n if (this.useVelocity) {\r\n attributeNames.push(\"velocity\");\r\n defines.push(\"#define FLUIDRENDERING_VELOCITY\");\r\n }\r\n\r\n this._depthEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n useShaderStore: true,\r\n vertexShader: \"fluidRenderingParticleDepth\",\r\n fragmentShader: \"fluidRenderingParticleDepth\",\r\n attributeNames,\r\n uniformNames,\r\n samplerNames: [],\r\n defines,\r\n });\r\n\r\n uniformNames.push(\"particleAlpha\");\r\n\r\n this._thicknessEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n useShaderStore: true,\r\n vertexShader: \"fluidRenderingParticleThickness\",\r\n fragmentShader: \"fluidRenderingParticleThickness\",\r\n attributeNames: [\"position\", \"offset\"],\r\n uniformNames,\r\n samplerNames: [],\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the object is ready to be rendered\r\n * @returns True if everything is ready for the object to be rendered, otherwise false\r\n */\r\n public isReady(): boolean {\r\n if (this._effectsAreDirty) {\r\n this._createEffects();\r\n }\r\n\r\n if (!this._depthEffectWrapper || !this._thicknessEffectWrapper) {\r\n return false;\r\n }\r\n\r\n const depthEffect = this._depthEffectWrapper._drawWrapper.effect!;\r\n const thicknessEffect = this._thicknessEffectWrapper._drawWrapper.effect!;\r\n\r\n return depthEffect.isReady() && thicknessEffect.isReady();\r\n }\r\n\r\n /**\r\n * Gets the number of particles (vertices) of this object\r\n * @returns The number of particles\r\n */\r\n public abstract get numParticles(): number;\r\n\r\n /**\r\n * Render the depth texture for this object\r\n */\r\n public renderDepthTexture(): void {\r\n const numParticles = this.numParticles;\r\n\r\n if (!this._depthEffectWrapper || numParticles === 0) {\r\n return;\r\n }\r\n\r\n const depthDrawWrapper = this._depthEffectWrapper._drawWrapper;\r\n const depthEffect = depthDrawWrapper.effect!;\r\n\r\n this._engine.enableEffect(depthDrawWrapper);\r\n this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, depthEffect);\r\n\r\n depthEffect.setMatrix(\"view\", this._scene.getViewMatrix());\r\n depthEffect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\r\n depthEffect.setFloat2(\"size\", this._particleSize, this._particleSize);\r\n depthEffect.setFloat(\"particleRadius\", this._particleSize / 2);\r\n\r\n if (this.useInstancing) {\r\n this._engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, numParticles);\r\n } else {\r\n this._engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, numParticles);\r\n }\r\n }\r\n\r\n /**\r\n * Render the thickness texture for this object\r\n */\r\n public renderThicknessTexture(): void {\r\n const numParticles = this.numParticles;\r\n\r\n if (!this._thicknessEffectWrapper || numParticles === 0) {\r\n return;\r\n }\r\n\r\n const thicknessDrawWrapper = this._thicknessEffectWrapper._drawWrapper;\r\n const thicknessEffect = thicknessDrawWrapper.effect!;\r\n\r\n this._engine.setAlphaMode(Constants.ALPHA_ONEONE);\r\n this._engine.setDepthWrite(false);\r\n\r\n this._engine.enableEffect(thicknessDrawWrapper);\r\n this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, thicknessEffect);\r\n\r\n thicknessEffect.setMatrix(\"view\", this._scene.getViewMatrix());\r\n thicknessEffect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\r\n thicknessEffect.setFloat(\"particleAlpha\", this.particleThicknessAlpha);\r\n thicknessEffect.setFloat2(\"size\", this._particleSize, this._particleSize);\r\n\r\n if (this.useInstancing) {\r\n this._engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, numParticles);\r\n } else {\r\n this._engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, numParticles);\r\n }\r\n\r\n this._engine.setDepthWrite(true);\r\n this._engine.setAlphaMode(Constants.ALPHA_DISABLE);\r\n }\r\n\r\n /**\r\n * Render the diffuse texture for this object\r\n */\r\n public renderDiffuseTexture(): void {\r\n // do nothing by default\r\n }\r\n\r\n /**\r\n * Releases the ressources used by the class\r\n */\r\n public dispose(): void {\r\n this._depthEffectWrapper?.dispose();\r\n this._thicknessEffectWrapper?.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { VertexBuffer } from "../../Buffers/buffer.js";
|
|
2
|
+
import type { Scene } from "../../scene.js";
|
|
3
|
+
import type { FloatArray } from "../../types.js";
|
|
4
|
+
import { FluidRenderingObject } from "./fluidRenderingObject";
|
|
5
|
+
/**
|
|
6
|
+
* Defines a rendering object based on a list of custom buffers
|
|
7
|
+
* The list must contain at least a "position" buffer!
|
|
8
|
+
*/
|
|
9
|
+
export declare class FluidRenderingObjectCustomParticles extends FluidRenderingObject {
|
|
10
|
+
private _numParticles;
|
|
11
|
+
private _diffuseEffectWrapper;
|
|
12
|
+
private _vertexBuffers;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the name of the class
|
|
15
|
+
*/
|
|
16
|
+
getClassName(): string;
|
|
17
|
+
/**
|
|
18
|
+
* Gets the vertex buffers
|
|
19
|
+
*/
|
|
20
|
+
get vertexBuffers(): {
|
|
21
|
+
[key: string]: VertexBuffer;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new instance of the class
|
|
25
|
+
* @param scene The scene the particles should be rendered into
|
|
26
|
+
* @param buffers The list of buffers (must contain at least one "position" buffer!). Note that you don't have to pass all (or any!) buffers at once in the constructor, you can use the addBuffers method to add more later.
|
|
27
|
+
* @param numParticles Number of vertices to take into account from the buffers
|
|
28
|
+
*/
|
|
29
|
+
constructor(scene: Scene, buffers: {
|
|
30
|
+
[key: string]: FloatArray;
|
|
31
|
+
}, numParticles: number);
|
|
32
|
+
/**
|
|
33
|
+
* Add some new buffers
|
|
34
|
+
* @param buffers List of buffers
|
|
35
|
+
*/
|
|
36
|
+
addBuffers(buffers: {
|
|
37
|
+
[key: string]: FloatArray;
|
|
38
|
+
}): void;
|
|
39
|
+
protected _createEffects(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Indicates if the object is ready to be rendered
|
|
42
|
+
* @returns True if everything is ready for the object to be rendered, otherwise false
|
|
43
|
+
*/
|
|
44
|
+
isReady(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Gets the number of particles in this object
|
|
47
|
+
* @returns The number of particles
|
|
48
|
+
*/
|
|
49
|
+
get numParticles(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Sets the number of particles in this object
|
|
52
|
+
* @param num The number of particles to take into account
|
|
53
|
+
*/
|
|
54
|
+
setNumParticles(num: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* Render the diffuse texture for this object
|
|
57
|
+
*/
|
|
58
|
+
renderDiffuseTexture(): void;
|
|
59
|
+
/**
|
|
60
|
+
* Releases the ressources used by the class
|
|
61
|
+
*/
|
|
62
|
+
dispose(): void;
|
|
63
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { VertexBuffer } from "../../Buffers/buffer.js";
|
|
2
|
+
|
|
3
|
+
import { EffectWrapper } from "../../Materials/effectRenderer.js";
|
|
4
|
+
import { FluidRenderingObject } from "./fluidRenderingObject.js";
|
|
5
|
+
/**
|
|
6
|
+
* Defines a rendering object based on a list of custom buffers
|
|
7
|
+
* The list must contain at least a "position" buffer!
|
|
8
|
+
*/
|
|
9
|
+
export class FluidRenderingObjectCustomParticles extends FluidRenderingObject {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new instance of the class
|
|
12
|
+
* @param scene The scene the particles should be rendered into
|
|
13
|
+
* @param buffers The list of buffers (must contain at least one "position" buffer!). Note that you don't have to pass all (or any!) buffers at once in the constructor, you can use the addBuffers method to add more later.
|
|
14
|
+
* @param numParticles Number of vertices to take into account from the buffers
|
|
15
|
+
*/
|
|
16
|
+
constructor(scene, buffers, numParticles) {
|
|
17
|
+
super(scene);
|
|
18
|
+
this._numParticles = numParticles;
|
|
19
|
+
this._diffuseEffectWrapper = null;
|
|
20
|
+
this._vertexBuffers = {};
|
|
21
|
+
this.addBuffers(buffers);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Gets the name of the class
|
|
25
|
+
*/
|
|
26
|
+
getClassName() {
|
|
27
|
+
return "FluidRenderingObjectCustomParticles";
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Gets the vertex buffers
|
|
31
|
+
*/
|
|
32
|
+
get vertexBuffers() {
|
|
33
|
+
return this._vertexBuffers;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Add some new buffers
|
|
37
|
+
* @param buffers List of buffers
|
|
38
|
+
*/
|
|
39
|
+
addBuffers(buffers) {
|
|
40
|
+
for (const name in buffers) {
|
|
41
|
+
let stride;
|
|
42
|
+
let instanced = true;
|
|
43
|
+
switch (name) {
|
|
44
|
+
case "velocity":
|
|
45
|
+
stride = 3;
|
|
46
|
+
break;
|
|
47
|
+
case "offset":
|
|
48
|
+
instanced = false;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
this._vertexBuffers[name] = new VertexBuffer(this._engine, buffers[name], name, true, false, stride, instanced);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
_createEffects() {
|
|
55
|
+
super._createEffects();
|
|
56
|
+
const uniformNames = ["view", "projection", "size"];
|
|
57
|
+
const attributeNames = ["position", "offset", "color"];
|
|
58
|
+
this._diffuseEffectWrapper = new EffectWrapper({
|
|
59
|
+
engine: this._engine,
|
|
60
|
+
useShaderStore: true,
|
|
61
|
+
vertexShader: "fluidRenderingParticleDiffuse",
|
|
62
|
+
fragmentShader: "fluidRenderingParticleDiffuse",
|
|
63
|
+
attributeNames,
|
|
64
|
+
uniformNames,
|
|
65
|
+
samplerNames: [],
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Indicates if the object is ready to be rendered
|
|
70
|
+
* @returns True if everything is ready for the object to be rendered, otherwise false
|
|
71
|
+
*/
|
|
72
|
+
isReady() {
|
|
73
|
+
var _a, _b;
|
|
74
|
+
if (!this._vertexBuffers["offset"]) {
|
|
75
|
+
this._vertexBuffers["offset"] = new VertexBuffer(this._engine, [0, 0, 1, 0, 0, 1, 1, 1], "offset", false, false, 2);
|
|
76
|
+
}
|
|
77
|
+
return super.isReady() && ((_b = (_a = this._diffuseEffectWrapper) === null || _a === void 0 ? void 0 : _a.effect.isReady()) !== null && _b !== void 0 ? _b : false);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Gets the number of particles in this object
|
|
81
|
+
* @returns The number of particles
|
|
82
|
+
*/
|
|
83
|
+
get numParticles() {
|
|
84
|
+
return this._numParticles;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Sets the number of particles in this object
|
|
88
|
+
* @param num The number of particles to take into account
|
|
89
|
+
*/
|
|
90
|
+
setNumParticles(num) {
|
|
91
|
+
this._numParticles = num;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Render the diffuse texture for this object
|
|
95
|
+
*/
|
|
96
|
+
renderDiffuseTexture() {
|
|
97
|
+
const numParticles = this.numParticles;
|
|
98
|
+
if (!this._diffuseEffectWrapper || numParticles === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const diffuseDrawWrapper = this._diffuseEffectWrapper._drawWrapper;
|
|
102
|
+
const diffuseEffect = diffuseDrawWrapper.effect;
|
|
103
|
+
this._engine.enableEffect(diffuseDrawWrapper);
|
|
104
|
+
this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, diffuseEffect);
|
|
105
|
+
diffuseEffect.setMatrix("view", this._scene.getViewMatrix());
|
|
106
|
+
diffuseEffect.setMatrix("projection", this._scene.getProjectionMatrix());
|
|
107
|
+
if (this._particleSize !== null) {
|
|
108
|
+
diffuseEffect.setFloat2("size", this._particleSize, this._particleSize);
|
|
109
|
+
}
|
|
110
|
+
if (this.useInstancing) {
|
|
111
|
+
this._engine.drawArraysType(7, 0, 4, numParticles);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this._engine.drawElementsType(0, 0, numParticles);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Releases the ressources used by the class
|
|
119
|
+
*/
|
|
120
|
+
dispose() {
|
|
121
|
+
var _a;
|
|
122
|
+
super.dispose();
|
|
123
|
+
(_a = this._diffuseEffectWrapper) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
124
|
+
for (const name in this._vertexBuffers) {
|
|
125
|
+
this._vertexBuffers[name].dispose();
|
|
126
|
+
}
|
|
127
|
+
this._vertexBuffers = {};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=fluidRenderingObjectCustomParticles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluidRenderingObjectCustomParticles.js","sourceRoot":"","sources":["../../../../../lts/core/generated/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gCAA4B;AACnD,OAAO,EAAE,SAA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AAO,CAAC;QAEjD,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QAC9C,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC;QAE9E,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;QAC7D,aAAa,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;QACzE,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;YAC7B,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;SAC3E;QAED,IAAI,IAAI,CAAC,aAAa,EAAE;YACpB,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,8BAA8B,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;SAC7F;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,SAAS,CAAC,yBAAyB,EAAE,CAAC,EAAE,YAAY,CAAC,CAAC;SACvF;IACL,CAAC;IAED;;OAEG;IACI,OAAO;;QACV,KAAK,CAAC,OAAO,EAAE,CAAC;QAEhB,MAAA,IAAI,CAAC,qBAAqB,0CAAE,OAAO,EAAE,CAAC;QAEtC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE;YACpC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;QAED,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { EffectWrapper } from \"core/Materials/effectRenderer\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { FloatArray, Nullable } from \"core/types\";\r\n\r\nimport { FluidRenderingObject } from \"./fluidRenderingObject\";\r\n\r\n/**\r\n * Defines a rendering object based on a list of custom buffers\r\n * The list must contain at least a \"position\" buffer!\r\n */\r\nexport class FluidRenderingObjectCustomParticles extends FluidRenderingObject {\r\n private _numParticles: number;\r\n private _diffuseEffectWrapper: Nullable<EffectWrapper>;\r\n private _vertexBuffers: { [key: string]: VertexBuffer };\r\n\r\n /**\r\n * Gets the name of the class\r\n */\r\n public getClassName(): string {\r\n return \"FluidRenderingObjectCustomParticles\";\r\n }\r\n\r\n /**\r\n * Gets the vertex buffers\r\n */\r\n public get vertexBuffers(): { [key: string]: VertexBuffer } {\r\n return this._vertexBuffers;\r\n }\r\n\r\n /**\r\n * Creates a new instance of the class\r\n * @param scene The scene the particles should be rendered into\r\n * @param buffers The list of buffers (must contain at least one \"position\" buffer!). Note that you don't have to pass all (or any!) buffers at once in the constructor, you can use the addBuffers method to add more later.\r\n * @param numParticles Number of vertices to take into account from the buffers\r\n */\r\n constructor(scene: Scene, buffers: { [key: string]: FloatArray }, numParticles: number) {\r\n super(scene);\r\n\r\n this._numParticles = numParticles;\r\n this._diffuseEffectWrapper = null;\r\n this._vertexBuffers = {};\r\n\r\n this.addBuffers(buffers);\r\n }\r\n\r\n /**\r\n * Add some new buffers\r\n * @param buffers List of buffers\r\n */\r\n public addBuffers(buffers: { [key: string]: FloatArray }) {\r\n for (const name in buffers) {\r\n let stride: number | undefined;\r\n let instanced = true;\r\n\r\n switch (name) {\r\n case \"velocity\":\r\n stride = 3;\r\n break;\r\n case \"offset\":\r\n instanced = false;\r\n break;\r\n }\r\n\r\n this._vertexBuffers[name] = new VertexBuffer(this._engine, buffers[name], name, true, false, stride, instanced);\r\n }\r\n }\r\n\r\n protected _createEffects(): void {\r\n super._createEffects();\r\n\r\n const uniformNames = [\"view\", \"projection\", \"size\"];\r\n const attributeNames = [\"position\", \"offset\", \"color\"];\r\n\r\n this._diffuseEffectWrapper = new EffectWrapper({\r\n engine: this._engine,\r\n useShaderStore: true,\r\n vertexShader: \"fluidRenderingParticleDiffuse\",\r\n fragmentShader: \"fluidRenderingParticleDiffuse\",\r\n attributeNames,\r\n uniformNames,\r\n samplerNames: [],\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the object is ready to be rendered\r\n * @returns True if everything is ready for the object to be rendered, otherwise false\r\n */\r\n public isReady(): boolean {\r\n if (!this._vertexBuffers[\"offset\"]) {\r\n this._vertexBuffers[\"offset\"] = new VertexBuffer(this._engine, [0, 0, 1, 0, 0, 1, 1, 1], \"offset\", false, false, 2);\r\n }\r\n\r\n return super.isReady() && (this._diffuseEffectWrapper?.effect!.isReady() ?? false);\r\n }\r\n\r\n /**\r\n * Gets the number of particles in this object\r\n * @returns The number of particles\r\n */\r\n public get numParticles(): number {\r\n return this._numParticles;\r\n }\r\n\r\n /**\r\n * Sets the number of particles in this object\r\n * @param num The number of particles to take into account\r\n */\r\n public setNumParticles(num: number) {\r\n this._numParticles = num;\r\n }\r\n\r\n /**\r\n * Render the diffuse texture for this object\r\n */\r\n public renderDiffuseTexture(): void {\r\n const numParticles = this.numParticles;\r\n\r\n if (!this._diffuseEffectWrapper || numParticles === 0) {\r\n return;\r\n }\r\n\r\n const diffuseDrawWrapper = this._diffuseEffectWrapper._drawWrapper;\r\n const diffuseEffect = diffuseDrawWrapper.effect!;\r\n\r\n this._engine.enableEffect(diffuseDrawWrapper);\r\n this._engine.bindBuffers(this.vertexBuffers, this.indexBuffer, diffuseEffect);\r\n\r\n diffuseEffect.setMatrix(\"view\", this._scene.getViewMatrix());\r\n diffuseEffect.setMatrix(\"projection\", this._scene.getProjectionMatrix());\r\n if (this._particleSize !== null) {\r\n diffuseEffect.setFloat2(\"size\", this._particleSize, this._particleSize);\r\n }\r\n\r\n if (this.useInstancing) {\r\n this._engine.drawArraysType(Constants.MATERIAL_TriangleStripDrawMode, 0, 4, numParticles);\r\n } else {\r\n this._engine.drawElementsType(Constants.MATERIAL_TriangleFillMode, 0, numParticles);\r\n }\r\n }\r\n\r\n /**\r\n * Releases the ressources used by the class\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n\r\n this._diffuseEffectWrapper?.dispose();\r\n\r\n for (const name in this._vertexBuffers) {\r\n this._vertexBuffers[name].dispose();\r\n }\r\n\r\n this._vertexBuffers = {};\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { VertexBuffer } from "../../Buffers/buffer.js";
|
|
2
|
+
import type { DataBuffer } from "../../Buffers/dataBuffer.js";
|
|
3
|
+
import type { IParticleSystem } from "../../Particles/IParticleSystem.js";
|
|
4
|
+
import type { Scene } from "../../scene.js";
|
|
5
|
+
import type { Nullable } from "../../types.js";
|
|
6
|
+
import { FluidRenderingObject } from "./fluidRenderingObject";
|
|
7
|
+
/**
|
|
8
|
+
* Defines a rendering object based on a particle system
|
|
9
|
+
*/
|
|
10
|
+
export declare class FluidRenderingObjectParticleSystem extends FluidRenderingObject {
|
|
11
|
+
private _particleSystem;
|
|
12
|
+
private _originalRender;
|
|
13
|
+
private _blendMode;
|
|
14
|
+
private _onBeforeDrawParticleObserver;
|
|
15
|
+
private _updateInAnimate;
|
|
16
|
+
/** Gets the particle system */
|
|
17
|
+
get particleSystem(): IParticleSystem;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the name of the class
|
|
20
|
+
*/
|
|
21
|
+
getClassName(): string;
|
|
22
|
+
private _useTrueRenderingForDiffuseTexture;
|
|
23
|
+
/**
|
|
24
|
+
* Gets or sets a boolean indicating that the diffuse texture should be generated based on the regular rendering of the particle system (default: true).
|
|
25
|
+
* Sometimes, generating the diffuse texture this way may be sub-optimal. In that case, you can disable this property, in which case the particle system will be
|
|
26
|
+
* rendered using a ALPHA_COMBINE mode instead of the one used by the particle system.
|
|
27
|
+
*/
|
|
28
|
+
get useTrueRenderingForDiffuseTexture(): boolean;
|
|
29
|
+
set useTrueRenderingForDiffuseTexture(use: boolean);
|
|
30
|
+
/**
|
|
31
|
+
* Gets the vertex buffers
|
|
32
|
+
*/
|
|
33
|
+
get vertexBuffers(): {
|
|
34
|
+
[key: string]: VertexBuffer;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Gets the index buffer (or null if the object is using instancing)
|
|
38
|
+
*/
|
|
39
|
+
get indexBuffer(): Nullable<DataBuffer>;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new instance of the class
|
|
42
|
+
* @param scene The scene the particle system is part of
|
|
43
|
+
* @param ps The particle system
|
|
44
|
+
*/
|
|
45
|
+
constructor(scene: Scene, ps: IParticleSystem);
|
|
46
|
+
/**
|
|
47
|
+
* Indicates if the object is ready to be rendered
|
|
48
|
+
* @returns True if everything is ready for the object to be rendered, otherwise false
|
|
49
|
+
*/
|
|
50
|
+
isReady(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Gets the number of particles in this particle system
|
|
53
|
+
* @returns The number of particles
|
|
54
|
+
*/
|
|
55
|
+
get numParticles(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Render the diffuse texture for this object
|
|
58
|
+
*/
|
|
59
|
+
renderDiffuseTexture(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Releases the ressources used by the class
|
|
62
|
+
*/
|
|
63
|
+
dispose(): void;
|
|
64
|
+
}
|