@onerjs/core 8.34.3 → 8.34.5
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/Animations/animationGroup.js +1 -0
- package/Animations/animationGroup.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +6 -10
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Limits/geospatialLimits.d.ts +4 -22
- package/Cameras/Limits/geospatialLimits.js +4 -36
- package/Cameras/Limits/geospatialLimits.js.map +1 -1
- package/Cameras/geospatialCamera.d.ts +15 -4
- package/Cameras/geospatialCamera.js +72 -16
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +1 -3
- package/Cameras/geospatialCameraMovement.js +13 -49
- package/Cameras/geospatialCameraMovement.js.map +1 -1
- package/Collisions/collisionCoordinator.d.ts +2 -2
- package/Collisions/collisionCoordinator.js +1 -0
- package/Collisions/collisionCoordinator.js.map +1 -1
- package/Engines/Extensions/engine.debugging.d.ts +3 -5
- package/Engines/Extensions/engine.debugging.js +3 -4
- package/Engines/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.js +15 -65
- package/Engines/WebGPU/Extensions/engine.debugging.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +9 -9
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.d.ts +2 -0
- package/Engines/abstractEngine.js +4 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +0 -2
- package/Engines/thinWebGPUEngine.js +0 -8
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +1 -3
- package/Engines/webgpuEngine.js +4 -10
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Passes/renderPass.js +4 -9
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +3 -0
- package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +2 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +31 -7
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +2 -2
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +9 -0
- package/FrameGraph/frameGraphContext.js +13 -2
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphObjectList.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +9 -8
- package/FrameGraph/frameGraphRenderContext.js +23 -20
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +2 -0
- package/FrameGraph/frameGraphTask.js +14 -4
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +4 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +8 -3
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/lightingVolume.js +11 -6
- package/Lights/lightingVolume.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js +3 -0
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -0
- package/Materials/Node/nodeMaterial.js +4 -0
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +6 -0
- package/Materials/Node/nodeMaterialBuildStateSharedData.js +4 -0
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js +1 -1
- package/Materials/Textures/Loaders/iesTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +7 -2
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js +1 -5
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.d.ts +6 -4
- package/Materials/Textures/internalTexture.js +6 -4
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js +2 -2
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/textureSampler.d.ts +3 -3
- package/Materials/Textures/textureSampler.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +4 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Misc/minMaxReducer.js +2 -2
- package/Misc/minMaxReducer.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js +3 -0
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js.map +1 -1
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleModuloBlock.d.ts +37 -0
- package/Particles/Node/Blocks/particleModuloBlock.js +98 -0
- package/Particles/Node/Blocks/particleModuloBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +22 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +83 -9
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +94 -66
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/thinParticleSystem.js +1 -0
- package/Particles/thinParticleSystem.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js +4 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.js.map +1 -1
- package/Probes/reflectionProbe.js +9 -2
- package/Probes/reflectionProbe.js.map +1 -1
- package/Rendering/depthRenderer.js +7 -2
- package/Rendering/depthRenderer.js.map +1 -1
- package/Shaders/particles.vertex.js +8 -1
- package/Shaders/particles.vertex.js.map +1 -1
- package/ShadersWGSL/particles.vertex.js +6 -0
- package/ShadersWGSL/particles.vertex.js.map +1 -1
- package/package.json +1 -1
package/Misc/minMaxReducer.js
CHANGED
|
@@ -117,11 +117,11 @@ export class MinMaxReducer {
|
|
|
117
117
|
}
|
|
118
118
|
this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(() => {
|
|
119
119
|
const engine = this._camera.getScene().getEngine();
|
|
120
|
-
engine._debugPushGroup
|
|
120
|
+
engine._debugPushGroup(`min max reduction`);
|
|
121
121
|
this._reductionSteps[0].activate(this._camera);
|
|
122
122
|
this._postProcessManager.directRender(this._reductionSteps, this._reductionSteps[0].inputTexture, this._forceFullscreenViewport, 0, 0, true, this._reductionSteps.length - 1);
|
|
123
123
|
engine.unBindFramebuffer(this._reductionSteps[this._reductionSteps.length - 1].inputTexture, false);
|
|
124
|
-
engine._debugPopGroup
|
|
124
|
+
engine._debugPopGroup();
|
|
125
125
|
});
|
|
126
126
|
this._activated = true;
|
|
127
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"minMaxReducer.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/minMaxReducer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGjD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAGzE,OAAO,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MA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SAAgB,CAAC;QACrD,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,kBAA0B,GAAG,SAAS,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEO,qBAAqB;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"./observable\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { PostProcessManager } from \"../PostProcesses/postProcessManager\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { ThinMinMaxReducer, ThinMinMaxReducerPostProcess } from \"./thinMinMaxReducer\";\r\n\r\nimport \"../Shaders/minmaxRedux.fragment\";\r\nimport \"../ShadersWGSL/minmaxRedux.fragment\";\r\n\r\n/**\r\n * This class computes a min/max reduction from a texture: it means it computes the minimum\r\n * and maximum values from all values of the texture.\r\n * It is performed on the GPU for better performances, thanks to a succession of post processes.\r\n * The source values are read from the red channel of the texture.\r\n */\r\nexport class MinMaxReducer {\r\n /**\r\n * Observable triggered when the computation has been performed\r\n */\r\n public get onAfterReductionPerformed() {\r\n return this._thinMinMaxReducer.onAfterReductionPerformed;\r\n }\r\n\r\n protected readonly _camera: Camera;\r\n protected readonly _thinMinMaxReducer: ThinMinMaxReducer;\r\n protected _sourceTexture: Nullable<RenderTargetTexture>;\r\n protected readonly _reductionSteps: Array<PostProcess>;\r\n protected readonly _postProcessManager: PostProcessManager;\r\n protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>> = null;\r\n protected _forceFullscreenViewport = true;\r\n protected readonly _onContextRestoredObserver: Observer<AbstractEngine>;\r\n\r\n /**\r\n * Creates a min/max reducer\r\n * @param camera The camera to use for the post processes\r\n */\r\n constructor(camera: Camera) {\r\n this._camera = camera;\r\n this._postProcessManager = new PostProcessManager(camera.getScene());\r\n this._thinMinMaxReducer = new ThinMinMaxReducer(camera.getScene());\r\n this._reductionSteps = [];\r\n\r\n this._onContextRestoredObserver = camera.getEngine().onContextRestoredObservable.add(() => {\r\n this._postProcessManager._rebuild();\r\n });\r\n }\r\n\r\n /**\r\n * Gets the texture used to read the values from.\r\n */\r\n public get sourceTexture(): Nullable<RenderTargetTexture> {\r\n return this._sourceTexture;\r\n }\r\n\r\n /**\r\n * Sets the source texture to read the values from.\r\n * One must indicate if the texture is a depth texture or not through the depthRedux parameter\r\n * because in such textures '1' value must not be taken into account to compute the maximum\r\n * as this value is used to clear the texture.\r\n * Note that the computation is not activated by calling this function, you must call activate() for that!\r\n * @param sourceTexture The texture to read the values from. The values should be in the red channel.\r\n * @param depthRedux Indicates if the texture is a depth texture or not\r\n * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)\r\n * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)\r\n */\r\n public setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type: number = Constants.TEXTURETYPE_HALF_FLOAT, forceFullscreenViewport = true): void {\r\n if (sourceTexture === this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._thinMinMaxReducer.depthRedux = depthRedux;\r\n\r\n this.deactivate();\r\n\r\n this._sourceTexture = sourceTexture;\r\n this._forceFullscreenViewport = forceFullscreenViewport;\r\n\r\n if (this._thinMinMaxReducer.setTextureDimensions(sourceTexture.getRenderWidth(), sourceTexture.getRenderHeight())) {\r\n this._disposePostProcesses();\r\n\r\n const reductionSteps = this._thinMinMaxReducer.reductionSteps;\r\n\r\n for (let i = 0; i < reductionSteps.length; ++i) {\r\n const reductionStep = reductionSteps[i];\r\n\r\n const postProcess = new PostProcess(reductionStep.name, ThinMinMaxReducerPostProcess.FragmentUrl, {\r\n effectWrapper: reductionStep,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n engine: this._camera.getScene().getEngine(),\r\n textureType: type,\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n size: { width: reductionStep.textureWidth, height: reductionStep.textureHeight },\r\n });\r\n\r\n this._reductionSteps.push(postProcess);\r\n\r\n postProcess.autoClear = false;\r\n postProcess.forceFullscreenViewport = forceFullscreenViewport;\r\n\r\n if (i === 0) {\r\n postProcess.externalTextureSamplerBinding = true;\r\n postProcess.onApplyObservable.add((effect: Effect) => {\r\n effect.setTexture(\"textureSampler\", this._sourceTexture);\r\n });\r\n }\r\n\r\n if (i === reductionSteps.length - 1) {\r\n this._reductionSteps[i - 1].onAfterRenderObservable.add(() => {\r\n this._thinMinMaxReducer.readMinMax(postProcess.inputTexture.texture!);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Defines the refresh rate of the computation.\r\n * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...\r\n */\r\n public get refreshRate(): number {\r\n return this._sourceTexture ? this._sourceTexture.refreshRate : -1;\r\n }\r\n\r\n public set refreshRate(value: number) {\r\n if (this._sourceTexture) {\r\n this._sourceTexture.refreshRate = value;\r\n }\r\n }\r\n\r\n protected _activated = false;\r\n\r\n /**\r\n * Gets the activation status of the reducer\r\n */\r\n public get activated(): boolean {\r\n return this._activated;\r\n }\r\n\r\n /**\r\n * Activates the reduction computation.\r\n * When activated, the observers registered in onAfterReductionPerformed are\r\n * called after the computation is performed\r\n */\r\n public activate(): void {\r\n if (this._onAfterUnbindObserver || !this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(() => {\r\n const engine = this._camera.getScene().getEngine();\r\n engine._debugPushGroup?.(`min max reduction`, 1);\r\n this._reductionSteps![0].activate(this._camera);\r\n this._postProcessManager.directRender(\r\n this._reductionSteps!,\r\n this._reductionSteps![0].inputTexture,\r\n this._forceFullscreenViewport,\r\n 0,\r\n 0,\r\n true,\r\n this._reductionSteps.length - 1\r\n );\r\n engine.unBindFramebuffer(this._reductionSteps![this._reductionSteps.length - 1].inputTexture, false);\r\n engine._debugPopGroup?.(1);\r\n });\r\n\r\n this._activated = true;\r\n }\r\n\r\n /**\r\n * Deactivates the reduction computation.\r\n */\r\n public deactivate(): void {\r\n if (!this._onAfterUnbindObserver || !this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);\r\n this._onAfterUnbindObserver = null;\r\n this._activated = false;\r\n }\r\n\r\n /**\r\n * Disposes the min/max reducer\r\n * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.\r\n */\r\n public dispose(disposeAll = true): void {\r\n if (!disposeAll) {\r\n return;\r\n }\r\n\r\n this.onAfterReductionPerformed.clear();\r\n\r\n this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n (this._onContextRestoredObserver as any) = undefined;\r\n\r\n this._disposePostProcesses();\r\n\r\n this._postProcessManager.dispose();\r\n (this._postProcessManager as any) = undefined as any;\r\n this._thinMinMaxReducer.dispose();\r\n (this._thinMinMaxReducer as any) = undefined;\r\n this._sourceTexture = null;\r\n }\r\n\r\n private _disposePostProcesses() {\r\n for (let i = 0; i < this._reductionSteps.length; ++i) {\r\n this._reductionSteps[i].dispose();\r\n }\r\n this._reductionSteps.length = 0;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"minMaxReducer.js","sourceRoot":"","sources":["../../../../dev/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M,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC5F,IAAI,CAAC,0BAAkC,GAAG,SAAS,CAAC;QAErD,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAE7B,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,mBAA2B,GAAG,SAAgB,CAAC;QACrD,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,CAAC,kBAA0B,GAAG,SAAS,CAAC;QAC7C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAEO,qBAAqB;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport type { RenderTargetTexture } from \"../Materials/Textures/renderTargetTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport type { Observer } from \"./observable\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { PostProcessManager } from \"../PostProcesses/postProcessManager\";\r\n\r\nimport type { AbstractEngine } from \"../Engines/abstractEngine\";\r\nimport { ThinMinMaxReducer, ThinMinMaxReducerPostProcess } from \"./thinMinMaxReducer\";\r\n\r\nimport \"../Shaders/minmaxRedux.fragment\";\r\nimport \"../ShadersWGSL/minmaxRedux.fragment\";\r\n\r\n/**\r\n * This class computes a min/max reduction from a texture: it means it computes the minimum\r\n * and maximum values from all values of the texture.\r\n * It is performed on the GPU for better performances, thanks to a succession of post processes.\r\n * The source values are read from the red channel of the texture.\r\n */\r\nexport class MinMaxReducer {\r\n /**\r\n * Observable triggered when the computation has been performed\r\n */\r\n public get onAfterReductionPerformed() {\r\n return this._thinMinMaxReducer.onAfterReductionPerformed;\r\n }\r\n\r\n protected readonly _camera: Camera;\r\n protected readonly _thinMinMaxReducer: ThinMinMaxReducer;\r\n protected _sourceTexture: Nullable<RenderTargetTexture>;\r\n protected readonly _reductionSteps: Array<PostProcess>;\r\n protected readonly _postProcessManager: PostProcessManager;\r\n protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>> = null;\r\n protected _forceFullscreenViewport = true;\r\n protected readonly _onContextRestoredObserver: Observer<AbstractEngine>;\r\n\r\n /**\r\n * Creates a min/max reducer\r\n * @param camera The camera to use for the post processes\r\n */\r\n constructor(camera: Camera) {\r\n this._camera = camera;\r\n this._postProcessManager = new PostProcessManager(camera.getScene());\r\n this._thinMinMaxReducer = new ThinMinMaxReducer(camera.getScene());\r\n this._reductionSteps = [];\r\n\r\n this._onContextRestoredObserver = camera.getEngine().onContextRestoredObservable.add(() => {\r\n this._postProcessManager._rebuild();\r\n });\r\n }\r\n\r\n /**\r\n * Gets the texture used to read the values from.\r\n */\r\n public get sourceTexture(): Nullable<RenderTargetTexture> {\r\n return this._sourceTexture;\r\n }\r\n\r\n /**\r\n * Sets the source texture to read the values from.\r\n * One must indicate if the texture is a depth texture or not through the depthRedux parameter\r\n * because in such textures '1' value must not be taken into account to compute the maximum\r\n * as this value is used to clear the texture.\r\n * Note that the computation is not activated by calling this function, you must call activate() for that!\r\n * @param sourceTexture The texture to read the values from. The values should be in the red channel.\r\n * @param depthRedux Indicates if the texture is a depth texture or not\r\n * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)\r\n * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)\r\n */\r\n public setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type: number = Constants.TEXTURETYPE_HALF_FLOAT, forceFullscreenViewport = true): void {\r\n if (sourceTexture === this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._thinMinMaxReducer.depthRedux = depthRedux;\r\n\r\n this.deactivate();\r\n\r\n this._sourceTexture = sourceTexture;\r\n this._forceFullscreenViewport = forceFullscreenViewport;\r\n\r\n if (this._thinMinMaxReducer.setTextureDimensions(sourceTexture.getRenderWidth(), sourceTexture.getRenderHeight())) {\r\n this._disposePostProcesses();\r\n\r\n const reductionSteps = this._thinMinMaxReducer.reductionSteps;\r\n\r\n for (let i = 0; i < reductionSteps.length; ++i) {\r\n const reductionStep = reductionSteps[i];\r\n\r\n const postProcess = new PostProcess(reductionStep.name, ThinMinMaxReducerPostProcess.FragmentUrl, {\r\n effectWrapper: reductionStep,\r\n samplingMode: Constants.TEXTURE_NEAREST_NEAREST,\r\n engine: this._camera.getScene().getEngine(),\r\n textureType: type,\r\n textureFormat: Constants.TEXTUREFORMAT_RG,\r\n size: { width: reductionStep.textureWidth, height: reductionStep.textureHeight },\r\n });\r\n\r\n this._reductionSteps.push(postProcess);\r\n\r\n postProcess.autoClear = false;\r\n postProcess.forceFullscreenViewport = forceFullscreenViewport;\r\n\r\n if (i === 0) {\r\n postProcess.externalTextureSamplerBinding = true;\r\n postProcess.onApplyObservable.add((effect: Effect) => {\r\n effect.setTexture(\"textureSampler\", this._sourceTexture);\r\n });\r\n }\r\n\r\n if (i === reductionSteps.length - 1) {\r\n this._reductionSteps[i - 1].onAfterRenderObservable.add(() => {\r\n this._thinMinMaxReducer.readMinMax(postProcess.inputTexture.texture!);\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Defines the refresh rate of the computation.\r\n * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...\r\n */\r\n public get refreshRate(): number {\r\n return this._sourceTexture ? this._sourceTexture.refreshRate : -1;\r\n }\r\n\r\n public set refreshRate(value: number) {\r\n if (this._sourceTexture) {\r\n this._sourceTexture.refreshRate = value;\r\n }\r\n }\r\n\r\n protected _activated = false;\r\n\r\n /**\r\n * Gets the activation status of the reducer\r\n */\r\n public get activated(): boolean {\r\n return this._activated;\r\n }\r\n\r\n /**\r\n * Activates the reduction computation.\r\n * When activated, the observers registered in onAfterReductionPerformed are\r\n * called after the computation is performed\r\n */\r\n public activate(): void {\r\n if (this._onAfterUnbindObserver || !this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._onAfterUnbindObserver = this._sourceTexture.onAfterUnbindObservable.add(() => {\r\n const engine = this._camera.getScene().getEngine();\r\n engine._debugPushGroup(`min max reduction`);\r\n this._reductionSteps![0].activate(this._camera);\r\n this._postProcessManager.directRender(\r\n this._reductionSteps!,\r\n this._reductionSteps![0].inputTexture,\r\n this._forceFullscreenViewport,\r\n 0,\r\n 0,\r\n true,\r\n this._reductionSteps.length - 1\r\n );\r\n engine.unBindFramebuffer(this._reductionSteps![this._reductionSteps.length - 1].inputTexture, false);\r\n engine._debugPopGroup();\r\n });\r\n\r\n this._activated = true;\r\n }\r\n\r\n /**\r\n * Deactivates the reduction computation.\r\n */\r\n public deactivate(): void {\r\n if (!this._onAfterUnbindObserver || !this._sourceTexture) {\r\n return;\r\n }\r\n\r\n this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);\r\n this._onAfterUnbindObserver = null;\r\n this._activated = false;\r\n }\r\n\r\n /**\r\n * Disposes the min/max reducer\r\n * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.\r\n */\r\n public dispose(disposeAll = true): void {\r\n if (!disposeAll) {\r\n return;\r\n }\r\n\r\n this.onAfterReductionPerformed.clear();\r\n\r\n this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver);\r\n (this._onContextRestoredObserver as any) = undefined;\r\n\r\n this._disposePostProcesses();\r\n\r\n this._postProcessManager.dispose();\r\n (this._postProcessManager as any) = undefined as any;\r\n this._thinMinMaxReducer.dispose();\r\n (this._thinMinMaxReducer as any) = undefined;\r\n this._sourceTexture = null;\r\n }\r\n\r\n private _disposePostProcesses() {\r\n for (let i = 0; i < this._reductionSteps.length; ++i) {\r\n this._reductionSteps[i].dispose();\r\n }\r\n this._reductionSteps.length = 0;\r\n }\r\n}\r\n"]}
|
|
@@ -68,6 +68,7 @@ export class SetupSpriteSheetBlock extends NodeParticleBlock {
|
|
|
68
68
|
system.spriteCellHeight = this.height;
|
|
69
69
|
system.startSpriteCellID = this.start;
|
|
70
70
|
system.endSpriteCellID = this.end;
|
|
71
|
+
system.spriteCellLoop = this.loop;
|
|
71
72
|
system.spriteRandomStartCell = this.randomStartCell;
|
|
72
73
|
this.output._storedValue = system;
|
|
73
74
|
}
|
|
@@ -77,6 +78,7 @@ export class SetupSpriteSheetBlock extends NodeParticleBlock {
|
|
|
77
78
|
serializationObject.height = this.height;
|
|
78
79
|
serializationObject.start = this.start;
|
|
79
80
|
serializationObject.end = this.end;
|
|
81
|
+
serializationObject.loop = this.loop;
|
|
80
82
|
serializationObject.randomStartCell = this.randomStartCell;
|
|
81
83
|
return serializationObject;
|
|
82
84
|
}
|
|
@@ -86,6 +88,7 @@ export class SetupSpriteSheetBlock extends NodeParticleBlock {
|
|
|
86
88
|
this.height = serializationObject.height;
|
|
87
89
|
this.start = serializationObject.start;
|
|
88
90
|
this.end = serializationObject.end;
|
|
91
|
+
this.loop = serializationObject.loop;
|
|
89
92
|
this.randomStartCell = serializationObject.randomStartCell;
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupSpriteSheetBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAA0B,gDAAsC;AAC/F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAA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AI,CAAC,MAAM,CAAC;QACtC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,KAAK,CAAC;QACtC,MAAM,CAAC,eAAe,GAAG,IAAI,CAAC,GAAG,CAAC;QAClC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,eAAe,CAAC;QAEpD,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;IACtC,CAAC;IAEe,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvC,mBAAmB,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACzC,mBAAmB,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvC,mBAAmB,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACnC,mBAAmB,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAE3D,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC;QACzC,IAAI,CAAC,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC;QACvC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC;QACnC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;IAC/D,CAAC;CACJ;
|
|
1
|
+
{"version":3,"file":"setupSpriteSheetBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAA0B,gDAAsC;AAC/F,OAAO,EAAE,aAAa,EAAE,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QACrC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;IAC/D,CAAC;CACJ;AA1GU;IADN,sBAAsB,CAAC,OAAO,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;oDACjH;AAMV;IADN,sBAAsB,CAAC,KAAK,sCAA8B,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;kDACjH;AAMR;IADN,sBAAsB,CAAC,OAAO,wCAAgC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;oDAClH;AAMX;IADN,sBAAsB,CAAC,QAAQ,wCAAgC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;qDAClH;AAMZ;IADN,sBAAsB,CAAC,MAAM,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;mDACzG;AAMb;IADN,sBAAsB,CAAC,mBAAmB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC3G;AA8EnC,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { editableInPropertyPage, PropertyTypeForEdition } from \"core/Decorators/nodeDecorator\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../../nodeParticleBuildState\";\r\nimport type { ParticleSystem } from \"core/Particles\";\r\n/**\r\n * Block used as configure the sprite sheet for particles\r\n */\r\nexport class SetupSpriteSheetBlock extends NodeParticleBlock {\r\n /**\r\n * Gets or sets the start cell of the sprite sheet\r\n */\r\n @editableInPropertyPage(\"Start\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 0 })\r\n public start = 0;\r\n\r\n /**\r\n * Gets or sets the end cell of the sprite sheet\r\n */\r\n @editableInPropertyPage(\"End\", PropertyTypeForEdition.Int, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 0 })\r\n public end = 8;\r\n\r\n /**\r\n * Gets or sets the width of the sprite sheet\r\n */\r\n @editableInPropertyPage(\"Width\", PropertyTypeForEdition.Float, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 0 })\r\n public width = 64;\r\n\r\n /**\r\n * Gets or sets the height of the sprite sheet\r\n */\r\n @editableInPropertyPage(\"Height\", PropertyTypeForEdition.Float, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true }, min: 0 })\r\n public height = 64;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the sprite sheet should loop\r\n */\r\n @editableInPropertyPage(\"Loop\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public loop = false;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if the sprite sheet should start at a random cell\r\n */\r\n @editableInPropertyPage(\"Random start cell\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public randomStartCell = false;\r\n\r\n /**\r\n * Creates a new SetupSpriteSheetBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"particle\", NodeParticleBlockConnectionPointTypes.Particle);\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.Particle);\r\n\r\n this._outputs[0]._typeConnectionSource = this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"SetupSpriteSheetBlock\";\r\n }\r\n\r\n /**\r\n * Gets the particle component\r\n */\r\n public get particle(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n super._build(state);\r\n\r\n const system = this.particle.getConnectedValue(state) as ParticleSystem;\r\n\r\n system._isAnimationSheetEnabled = true;\r\n system.spriteCellWidth = this.width;\r\n system.spriteCellHeight = this.height;\r\n system.startSpriteCellID = this.start;\r\n system.endSpriteCellID = this.end;\r\n system.spriteCellLoop = this.loop;\r\n system.spriteRandomStartCell = this.randomStartCell;\r\n\r\n this.output._storedValue = system;\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.width = this.width;\r\n serializationObject.height = this.height;\r\n serializationObject.start = this.start;\r\n serializationObject.end = this.end;\r\n serializationObject.loop = this.loop;\r\n serializationObject.randomStartCell = this.randomStartCell;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.width = serializationObject.width;\r\n this.height = serializationObject.height;\r\n this.start = serializationObject.start;\r\n this.end = serializationObject.end;\r\n this.loop = serializationObject.loop;\r\n this.randomStartCell = serializationObject.randomStartCell;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.SetupSpriteSheetBlock\", SetupSpriteSheetBlock);\r\n"]}
|
|
@@ -35,4 +35,5 @@ export * from "./Triggers/particleTriggerBlock.js";
|
|
|
35
35
|
export * from "./particleLocalVariableBlock.js";
|
|
36
36
|
export * from "./particleVectorLengthBlock.js";
|
|
37
37
|
export * from "./particleFresnelBlock.js";
|
|
38
|
+
export * from "./particleModuloBlock.js";
|
|
38
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./systemBlock\";\r\nexport * from \"./particleFloatToIntBlock\";\r\nexport * from \"./particleInputBlock\";\r\nexport * from \"./particleSourceTextureBlock\";\r\nexport * from \"./particleMathBlock\";\r\nexport * from \"./particleLerpBlock\";\r\nexport * from \"./Update/updateDirectionBlock\";\r\nexport * from \"./Update/updatePositionBlock\";\r\nexport * from \"./Update/updateColorBlock\";\r\nexport * from \"./Update/updateScaleBlock\";\r\nexport * from \"./Update/updateSizeBlock\";\r\nexport * from \"./Update/updateAngleBlock\";\r\nexport * from \"./Update/updateAgeBlock\";\r\nexport * from \"./Update/basicPositionUpdateBlock\";\r\nexport * from \"./Update/basicSpriteUpdateBlock\";\r\nexport * from \"./Update/basicColorUpdateBlock\";\r\nexport * from \"./Update/updateSpriteCellIndexBlock\";\r\nexport * from \"./Update/updateFlowMapBlock\";\r\nexport * from \"./Update/updateNoiseBlock\";\r\nexport * from \"./Update/updateAttractorBlock\";\r\nexport * from \"./Update/alignAngleBlock\";\r\nexport * from \"./Emitters/index\";\r\nexport * from \"./particleGradientValueBlock\";\r\nexport * from \"./particleGradientBlock\";\r\nexport * from \"./particleConverterBlock\";\r\nexport * from \"./particleTrigonometryBlock\";\r\nexport * from \"./particleRandomBlock\";\r\nexport * from \"./particleDebugBlock\";\r\nexport * from \"./particleElbowBlock\";\r\nexport * from \"./Teleport/particleTeleportInBlock\";\r\nexport * from \"./Teleport/particleTeleportOutBlock\";\r\nexport * from \"./Conditions/particleConditionBlock\";\r\nexport * from \"./Triggers/particleTriggerBlock\";\r\nexport * from \"./particleLocalVariableBlock\";\r\nexport * from \"./particleVectorLengthBlock\";\r\nexport * from \"./particleFresnelBlock\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mCAAmC,CAAC;AAClD,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qCAAqC,CAAC;AACpD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oCAAoC,CAAC;AACnD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./systemBlock\";\r\nexport * from \"./particleFloatToIntBlock\";\r\nexport * from \"./particleInputBlock\";\r\nexport * from \"./particleSourceTextureBlock\";\r\nexport * from \"./particleMathBlock\";\r\nexport * from \"./particleLerpBlock\";\r\nexport * from \"./Update/updateDirectionBlock\";\r\nexport * from \"./Update/updatePositionBlock\";\r\nexport * from \"./Update/updateColorBlock\";\r\nexport * from \"./Update/updateScaleBlock\";\r\nexport * from \"./Update/updateSizeBlock\";\r\nexport * from \"./Update/updateAngleBlock\";\r\nexport * from \"./Update/updateAgeBlock\";\r\nexport * from \"./Update/basicPositionUpdateBlock\";\r\nexport * from \"./Update/basicSpriteUpdateBlock\";\r\nexport * from \"./Update/basicColorUpdateBlock\";\r\nexport * from \"./Update/updateSpriteCellIndexBlock\";\r\nexport * from \"./Update/updateFlowMapBlock\";\r\nexport * from \"./Update/updateNoiseBlock\";\r\nexport * from \"./Update/updateAttractorBlock\";\r\nexport * from \"./Update/alignAngleBlock\";\r\nexport * from \"./Emitters/index\";\r\nexport * from \"./particleGradientValueBlock\";\r\nexport * from \"./particleGradientBlock\";\r\nexport * from \"./particleConverterBlock\";\r\nexport * from \"./particleTrigonometryBlock\";\r\nexport * from \"./particleRandomBlock\";\r\nexport * from \"./particleDebugBlock\";\r\nexport * from \"./particleElbowBlock\";\r\nexport * from \"./Teleport/particleTeleportInBlock\";\r\nexport * from \"./Teleport/particleTeleportOutBlock\";\r\nexport * from \"./Conditions/particleConditionBlock\";\r\nexport * from \"./Triggers/particleTriggerBlock\";\r\nexport * from \"./particleLocalVariableBlock\";\r\nexport * from \"./particleVectorLengthBlock\";\r\nexport * from \"./particleFresnelBlock\";\r\nexport * from \"./particleModuloBlock\";\r\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
2
|
+
import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnectionPoint.js";
|
|
3
|
+
import type { NodeParticleBuildState } from "../nodeParticleBuildState.js";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to apply the modulo operator
|
|
6
|
+
*/
|
|
7
|
+
export declare class ParticleModuloBlock extends NodeParticleBlock {
|
|
8
|
+
private readonly _connectionObservers;
|
|
9
|
+
/**
|
|
10
|
+
* Create a new ParticleModuloBlock
|
|
11
|
+
* @param name defines the block name
|
|
12
|
+
*/
|
|
13
|
+
constructor(name: string);
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current class name
|
|
16
|
+
* @returns the class name
|
|
17
|
+
*/
|
|
18
|
+
getClassName(): string;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the left input component
|
|
21
|
+
*/
|
|
22
|
+
get left(): NodeParticleConnectionPoint;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the right input component
|
|
25
|
+
*/
|
|
26
|
+
get right(): NodeParticleConnectionPoint;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the geometry output component
|
|
29
|
+
*/
|
|
30
|
+
get output(): NodeParticleConnectionPoint;
|
|
31
|
+
_build(state: NodeParticleBuildState): void;
|
|
32
|
+
private _updateInputOutputTypes;
|
|
33
|
+
/**
|
|
34
|
+
* Release resources
|
|
35
|
+
*/
|
|
36
|
+
dispose(): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
2
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
3
|
+
import { NodeParticleBlockConnectionPointTypes } from "../Enums/nodeParticleBlockConnectionPointTypes.js";
|
|
4
|
+
/**
|
|
5
|
+
* Block used to apply the modulo operator
|
|
6
|
+
*/
|
|
7
|
+
export class ParticleModuloBlock extends NodeParticleBlock {
|
|
8
|
+
/**
|
|
9
|
+
* Create a new ParticleModuloBlock
|
|
10
|
+
* @param name defines the block name
|
|
11
|
+
*/
|
|
12
|
+
constructor(name) {
|
|
13
|
+
super(name);
|
|
14
|
+
this.registerInput("left", NodeParticleBlockConnectionPointTypes.AutoDetect);
|
|
15
|
+
this.registerInput("right", NodeParticleBlockConnectionPointTypes.AutoDetect);
|
|
16
|
+
this.registerOutput("output", NodeParticleBlockConnectionPointTypes.BasedOnInput);
|
|
17
|
+
this.output._typeConnectionSource = this.left;
|
|
18
|
+
this.left.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Int);
|
|
19
|
+
this.left.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);
|
|
20
|
+
this.right.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Int);
|
|
21
|
+
this.right.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);
|
|
22
|
+
this._linkConnectionTypes(0, 1);
|
|
23
|
+
this._connectionObservers = [
|
|
24
|
+
this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),
|
|
25
|
+
this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),
|
|
26
|
+
this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),
|
|
27
|
+
this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets the current class name
|
|
32
|
+
* @returns the class name
|
|
33
|
+
*/
|
|
34
|
+
getClassName() {
|
|
35
|
+
return "ParticleModuloBlock";
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets the left input component
|
|
39
|
+
*/
|
|
40
|
+
get left() {
|
|
41
|
+
return this._inputs[0];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Gets the right input component
|
|
45
|
+
*/
|
|
46
|
+
get right() {
|
|
47
|
+
return this._inputs[1];
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the geometry output component
|
|
51
|
+
*/
|
|
52
|
+
get output() {
|
|
53
|
+
return this._outputs[0];
|
|
54
|
+
}
|
|
55
|
+
_build(state) {
|
|
56
|
+
const left = this.left;
|
|
57
|
+
const right = this.right;
|
|
58
|
+
if (!left.isConnected || !right.isConnected) {
|
|
59
|
+
this.output._storedFunction = null;
|
|
60
|
+
this.output._storedValue = null;
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const func = (state) => {
|
|
64
|
+
return left.getConnectedValue(state) % right.getConnectedValue(state);
|
|
65
|
+
};
|
|
66
|
+
this.output._storedFunction = (state) => {
|
|
67
|
+
if (left.type === NodeParticleBlockConnectionPointTypes.Int) {
|
|
68
|
+
return func(state) | 0;
|
|
69
|
+
}
|
|
70
|
+
return func(state);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
_updateInputOutputTypes() {
|
|
74
|
+
// First update the output type with the initial assumption that we'll base it on the left input.
|
|
75
|
+
this.output._typeConnectionSource = this.left;
|
|
76
|
+
if (this.left.isConnected && this.right.isConnected) {
|
|
77
|
+
if (this.right.type === NodeParticleBlockConnectionPointTypes.Float) {
|
|
78
|
+
this.output._typeConnectionSource = this.right;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else if (this.left.isConnected !== this.right.isConnected) {
|
|
82
|
+
// Only one input is connected, so we need to determine the output type based on the connected input.
|
|
83
|
+
this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Release resources
|
|
88
|
+
*/
|
|
89
|
+
dispose() {
|
|
90
|
+
super.dispose();
|
|
91
|
+
for (const observer of this._connectionObservers) {
|
|
92
|
+
observer.remove();
|
|
93
|
+
}
|
|
94
|
+
this._connectionObservers.length = 0;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
RegisterClass("BABYLON.ParticleModuloBlock", ParticleModuloBlock);
|
|
98
|
+
//# sourceMappingURL=particleModuloBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"particleModuloBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleModuloBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;A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,uBAAuB;QAC3B,iGAAiG;QACjG,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9C,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAClD,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,qCAAqC,CAAC,KAAK,EAAE,CAAC;gBAClE,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC;YACnD,CAAC;QACL,CAAC;aAAM,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC1D,qGAAqG;YACrG,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QACvF,CAAC;IACL,CAAC;IAED;;OAEG;IACa,OAAO;QACnB,KAAK,CAAC,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtB,CAAC;QACD,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,CAAC;IACzC,CAAC;CACJ;AAED,aAAa,CAAC,6BAA6B,EAAE,mBAAmB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\n\r\n/**\r\n * Block used to apply the modulo operator\r\n */\r\nexport class ParticleModuloBlock extends NodeParticleBlock {\r\n private readonly _connectionObservers: Observer<NodeParticleConnectionPoint>[];\r\n\r\n /**\r\n * Create a new ParticleModuloBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"left\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n this.registerInput(\"right\", NodeParticleBlockConnectionPointTypes.AutoDetect);\r\n\r\n this.registerOutput(\"output\", NodeParticleBlockConnectionPointTypes.BasedOnInput);\r\n\r\n this.output._typeConnectionSource = this.left;\r\n\r\n this.left.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Int);\r\n this.left.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);\r\n this.right.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Int);\r\n this.right.acceptedConnectionPointTypes.push(NodeParticleBlockConnectionPointTypes.Float);\r\n\r\n this._linkConnectionTypes(0, 1);\r\n\r\n this._connectionObservers = [\r\n this.left.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.left.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onConnectionObservable.add(() => this._updateInputOutputTypes()),\r\n this.right.onDisconnectionObservable.add(() => this._updateInputOutputTypes()),\r\n ];\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleModuloBlock\";\r\n }\r\n\r\n /**\r\n * Gets the left input component\r\n */\r\n public get left(): NodeParticleConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the right input component\r\n */\r\n public get right(): NodeParticleConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the geometry output component\r\n */\r\n public get output(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n public override _build(state: NodeParticleBuildState) {\r\n const left = this.left;\r\n const right = this.right;\r\n\r\n if (!left.isConnected || !right.isConnected) {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = null;\r\n return;\r\n }\r\n\r\n const func: (state: NodeParticleBuildState) => any = (state) => {\r\n return left.getConnectedValue(state) % right.getConnectedValue(state);\r\n };\r\n\r\n this.output._storedFunction = (state) => {\r\n if (left.type === NodeParticleBlockConnectionPointTypes.Int) {\r\n return func(state) | 0;\r\n }\r\n return func(state);\r\n };\r\n }\r\n\r\n private _updateInputOutputTypes() {\r\n // First update the output type with the initial assumption that we'll base it on the left input.\r\n this.output._typeConnectionSource = this.left;\r\n\r\n if (this.left.isConnected && this.right.isConnected) {\r\n if (this.right.type === NodeParticleBlockConnectionPointTypes.Float) {\r\n this.output._typeConnectionSource = this.right;\r\n }\r\n } else if (this.left.isConnected !== this.right.isConnected) {\r\n // Only one input is connected, so we need to determine the output type based on the connected input.\r\n this.output._typeConnectionSource = this.left.isConnected ? this.left : this.right;\r\n }\r\n }\r\n\r\n /**\r\n * Release resources\r\n */\r\n public override dispose() {\r\n super.dispose();\r\n for (const observer of this._connectionObservers) {\r\n observer.remove();\r\n }\r\n this._connectionObservers.length = 0;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleModuloBlock\", ParticleModuloBlock);\r\n"]}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
2
1
|
import type { NodeParticleConnectionPoint } from "../nodeParticleBlockConnectionPoint.js";
|
|
3
2
|
import type { NodeParticleBuildState } from "../nodeParticleBuildState.js";
|
|
4
3
|
import type { Nullable } from "../../../types.js";
|
|
5
4
|
import type { BaseTexture } from "../../../Materials/Textures/baseTexture.js";
|
|
5
|
+
import { NodeParticleBlock } from "../nodeParticleBlock.js";
|
|
6
6
|
/**
|
|
7
7
|
* Interface used to define texture data
|
|
8
8
|
*/
|
|
9
9
|
export interface INodeParticleTextureData {
|
|
10
|
+
/** Width of the texture in pixels */
|
|
10
11
|
width: number;
|
|
12
|
+
/** Height of the texture in pixels */
|
|
11
13
|
height: number;
|
|
14
|
+
/** RGBA pixel data */
|
|
12
15
|
data: Uint8ClampedArray;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
@@ -19,6 +22,7 @@ export declare class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
19
22
|
private _textureDataUrl;
|
|
20
23
|
private _sourceTexture;
|
|
21
24
|
private _cachedData;
|
|
25
|
+
private _clonedTextures;
|
|
22
26
|
/**
|
|
23
27
|
* Indicates if the texture data should be serialized as a base64 string.
|
|
24
28
|
*/
|
|
@@ -63,7 +67,24 @@ export declare class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
63
67
|
* @param state defines the current build state
|
|
64
68
|
*/
|
|
65
69
|
_build(state: NodeParticleBuildState): void;
|
|
70
|
+
/**
|
|
71
|
+
* Serializes this block
|
|
72
|
+
* @returns the serialization object
|
|
73
|
+
*/
|
|
66
74
|
serialize(): any;
|
|
75
|
+
/**
|
|
76
|
+
* Deserializes this block from a serialization object
|
|
77
|
+
* @param serializationObject the serialization object
|
|
78
|
+
*/
|
|
67
79
|
_deserialize(serializationObject: any): void;
|
|
80
|
+
/**
|
|
81
|
+
* Disposes the block and its associated resources
|
|
82
|
+
*/
|
|
68
83
|
dispose(): void;
|
|
84
|
+
/**
|
|
85
|
+
* Copies texture properties from source to target texture
|
|
86
|
+
* @param source - The source texture to copy properties from
|
|
87
|
+
* @param target - The target texture to copy properties to
|
|
88
|
+
*/
|
|
89
|
+
private _copyTextureProperties;
|
|
69
90
|
}
|
|
@@ -61,6 +61,7 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
61
61
|
this._textureDataUrl = "";
|
|
62
62
|
this._sourceTexture = null;
|
|
63
63
|
this._cachedData = null;
|
|
64
|
+
this._clonedTextures = [];
|
|
64
65
|
/**
|
|
65
66
|
* Indicates if the texture data should be serialized as a base64 string.
|
|
66
67
|
*/
|
|
@@ -94,7 +95,6 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
94
95
|
const texture = this.texture._storedValue || this._sourceTexture;
|
|
95
96
|
return await new Promise((resolve, reject) => {
|
|
96
97
|
if (!texture.isReady()) {
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
98
98
|
texture.onLoadObservable.addOnce(async () => {
|
|
99
99
|
try {
|
|
100
100
|
this._cachedData = await this.extractTextureContentAsync();
|
|
@@ -147,7 +147,37 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
147
147
|
*/
|
|
148
148
|
_build(state) {
|
|
149
149
|
if (this._sourceTexture) {
|
|
150
|
-
|
|
150
|
+
// The same NodeParticleSystemSet can be built into multiple scenes/engines
|
|
151
|
+
// (original system scene, editor preview scene).
|
|
152
|
+
// Textures are engine-specific, so we need to handle cross-engine cases.
|
|
153
|
+
const sourceScene = this._sourceTexture.getScene?.();
|
|
154
|
+
const sourceEngine = sourceScene?.getEngine?.();
|
|
155
|
+
const targetEngine = state.scene.getEngine();
|
|
156
|
+
if (sourceEngine && sourceEngine !== targetEngine) {
|
|
157
|
+
// Cross-engine: recreate texture from URL if available, preserving invertY
|
|
158
|
+
const url = this._sourceTexture.url || this._url;
|
|
159
|
+
if (url) {
|
|
160
|
+
const invertY = this._sourceTexture.invertY ?? true;
|
|
161
|
+
const tex = new Texture(url, state.scene, undefined, invertY);
|
|
162
|
+
this._copyTextureProperties(this._sourceTexture, tex);
|
|
163
|
+
this._clonedTextures.push(tex);
|
|
164
|
+
this.texture._storedValue = tex;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
// No URL available - use the source texture directly as fallback
|
|
168
|
+
// This may not render correctly but avoids breaking completely
|
|
169
|
+
this.texture._storedValue = this._sourceTexture;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
// Same engine: clone works correctly and preserves all properties
|
|
173
|
+
const cloned = this._sourceTexture.clone();
|
|
174
|
+
if (cloned) {
|
|
175
|
+
this._clonedTextures.push(cloned);
|
|
176
|
+
this.texture._storedValue = cloned;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
this.texture._storedValue = this._sourceTexture;
|
|
180
|
+
}
|
|
151
181
|
return;
|
|
152
182
|
}
|
|
153
183
|
if (!this._textureDataUrl && !this._url) {
|
|
@@ -155,11 +185,19 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
155
185
|
return;
|
|
156
186
|
}
|
|
157
187
|
if (this._textureDataUrl) {
|
|
158
|
-
|
|
188
|
+
const tex = new Texture(this._textureDataUrl, state.scene);
|
|
189
|
+
this._clonedTextures.push(tex);
|
|
190
|
+
this.texture._storedValue = tex;
|
|
159
191
|
return;
|
|
160
192
|
}
|
|
161
|
-
|
|
193
|
+
const tex = new Texture(this._url, state.scene);
|
|
194
|
+
this._clonedTextures.push(tex);
|
|
195
|
+
this.texture._storedValue = tex;
|
|
162
196
|
}
|
|
197
|
+
/**
|
|
198
|
+
* Serializes this block
|
|
199
|
+
* @returns the serialization object
|
|
200
|
+
*/
|
|
163
201
|
serialize() {
|
|
164
202
|
const serializationObject = super.serialize();
|
|
165
203
|
serializationObject.url = this.url;
|
|
@@ -169,6 +207,10 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
169
207
|
}
|
|
170
208
|
return serializationObject;
|
|
171
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Deserializes this block from a serialization object
|
|
212
|
+
* @param serializationObject the serialization object
|
|
213
|
+
*/
|
|
172
214
|
_deserialize(serializationObject) {
|
|
173
215
|
super._deserialize(serializationObject);
|
|
174
216
|
this.url = serializationObject.url;
|
|
@@ -177,15 +219,47 @@ export class ParticleTextureSourceBlock extends NodeParticleBlock {
|
|
|
177
219
|
this.textureDataUrl = serializationObject.textureDataUrl;
|
|
178
220
|
}
|
|
179
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Disposes the block and its associated resources
|
|
224
|
+
*/
|
|
180
225
|
dispose() {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
this.texture._storedValue = null;
|
|
185
|
-
}
|
|
226
|
+
// Dispose all cloned textures we created
|
|
227
|
+
for (const tex of this._clonedTextures) {
|
|
228
|
+
tex.dispose();
|
|
186
229
|
}
|
|
230
|
+
this._clonedTextures = [];
|
|
231
|
+
this.texture._storedValue = null;
|
|
232
|
+
// Never dispose _sourceTexture - it's owned by the caller
|
|
187
233
|
super.dispose();
|
|
188
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* Copies texture properties from source to target texture
|
|
237
|
+
* @param source - The source texture to copy properties from
|
|
238
|
+
* @param target - The target texture to copy properties to
|
|
239
|
+
*/
|
|
240
|
+
_copyTextureProperties(source, target) {
|
|
241
|
+
// BaseTexture properties
|
|
242
|
+
target.hasAlpha = source.hasAlpha;
|
|
243
|
+
target.level = source.level;
|
|
244
|
+
target.coordinatesIndex = source.coordinatesIndex;
|
|
245
|
+
target.coordinatesMode = source.coordinatesMode;
|
|
246
|
+
target.wrapU = source.wrapU;
|
|
247
|
+
target.wrapV = source.wrapV;
|
|
248
|
+
target.wrapR = source.wrapR;
|
|
249
|
+
target.anisotropicFilteringLevel = source.anisotropicFilteringLevel;
|
|
250
|
+
// Texture-specific properties (if both are Texture instances)
|
|
251
|
+
const sourceTexture = source;
|
|
252
|
+
const targetTexture = target;
|
|
253
|
+
if (sourceTexture.uOffset !== undefined && targetTexture.uOffset !== undefined) {
|
|
254
|
+
targetTexture.uOffset = sourceTexture.uOffset;
|
|
255
|
+
targetTexture.vOffset = sourceTexture.vOffset;
|
|
256
|
+
targetTexture.uScale = sourceTexture.uScale;
|
|
257
|
+
targetTexture.vScale = sourceTexture.vScale;
|
|
258
|
+
targetTexture.uAng = sourceTexture.uAng;
|
|
259
|
+
targetTexture.vAng = sourceTexture.vAng;
|
|
260
|
+
targetTexture.wAng = sourceTexture.wAng;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
189
263
|
}
|
|
190
264
|
RegisterClass("BABYLON.ParticleTextureSourceBlock", ParticleTextureSourceBlock);
|
|
191
265
|
//# sourceMappingURL=particleSourceTextureBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"particleSourceTextureBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleSourceTextureBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+CAAwC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,sCAA+B;AAatD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;IAW7D;;OAEG;IACH,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAW,GAAG,CAAC,KAAa;QACxB,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;YACtB,OAAO;QACX,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,IAAW,cAAc,CAAC,KAAa;QACnC,IAAI,IAAI,CAAC,eAAe,KAAK,KAAK,EAAE,CAAC;YACjC,OAAO;QACX,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;IAC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,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,GAAG,GAAG,mBAAmB,CAAC,GAAG,CAAC;QACnC,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QAEvE,IAAI,mBAAmB,CAAC,cAAc,EAAE,CAAC;YACrC,IAAI,CAAC,cAAc,GAAG,mBAAmB,CAAC,cAAc,CAAC;QAC7D,CAAC;IACL,CAAC;IAEe,OAAO;QACnB,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;YACvB,IAAI,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;gBAC5B,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;gBACpC,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;YACrC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ;AAED,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\nimport type { BaseTexture } from \"../../../Materials/Textures/baseTexture\";\r\nimport type { ProceduralTexture } from \"../../../Materials\";\r\n\r\n/**\r\n * Interface used to define texture data\r\n */\r\nexport interface INodeParticleTextureData {\r\n width: number;\r\n height: number;\r\n data: Uint8ClampedArray;\r\n}\r\n\r\n/**\r\n * Block used to provide a texture for particles in a particle system\r\n */\r\nexport class ParticleTextureSourceBlock extends NodeParticleBlock {\r\n private _url: string = \"\";\r\n private _textureDataUrl: string = \"\";\r\n private _sourceTexture: Nullable<BaseTexture> = null;\r\n private _cachedData: Nullable<INodeParticleTextureData> = null;\r\n\r\n /**\r\n * Indicates if the texture data should be serialized as a base64 string.\r\n */\r\n public serializedCachedData: boolean = false;\r\n\r\n /**\r\n * Gets or sets the URL of the texture to be used by this block.\r\n */\r\n public get url(): string {\r\n return this._url;\r\n }\r\n\r\n public set url(value: string) {\r\n if (this._url === value) {\r\n return;\r\n }\r\n this._cachedData = null;\r\n this._url = value;\r\n this._textureDataUrl = \"\";\r\n this._sourceTexture = null;\r\n }\r\n\r\n /**\r\n * Gets or sets the data URL of the texture to be used by this block.\r\n * This is a base64 encoded string representing the texture data.\r\n */\r\n public get textureDataUrl(): string {\r\n return this._textureDataUrl;\r\n }\r\n\r\n public set textureDataUrl(value: string) {\r\n if (this._textureDataUrl === value) {\r\n return;\r\n }\r\n\r\n this._cachedData = null;\r\n this._textureDataUrl = value;\r\n this._url = \"\";\r\n this._sourceTexture = null;\r\n }\r\n\r\n /**\r\n * Directly sets the texture to be used by this block.\r\n * This value will not be serialized.\r\n */\r\n public set sourceTexture(value: Nullable<BaseTexture>) {\r\n if (this._sourceTexture === value) {\r\n return;\r\n }\r\n this._cachedData = null;\r\n this._sourceTexture = value;\r\n this._url = (value as Texture).url || \"\";\r\n this._textureDataUrl = \"\";\r\n }\r\n\r\n /**\r\n * Create a new ParticleTextureSourceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"texture\", NodeParticleBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleTextureSourceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture output component\r\n */\r\n public get texture(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the texture content as a promise\r\n * @returns a promise that resolves to the texture content, including width, height, and pixel data\r\n */\r\n async extractTextureContentAsync() {\r\n if (!this.texture._storedValue && !this._sourceTexture) {\r\n return null;\r\n }\r\n\r\n if (this._cachedData) {\r\n return this._cachedData;\r\n }\r\n\r\n const texture = this.texture._storedValue || this._sourceTexture;\r\n return await new Promise<\r\n Nullable<{\r\n width: number;\r\n height: number;\r\n data: Uint8ClampedArray;\r\n }>\r\n >((resolve, reject) => {\r\n if (!texture.isReady()) {\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n texture.onLoadObservable.addOnce(async () => {\r\n try {\r\n this._cachedData = await this.extractTextureContentAsync();\r\n resolve(this._cachedData);\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(e);\r\n }\r\n });\r\n return;\r\n }\r\n const size = texture.getSize();\r\n if (texture.getContent) {\r\n const proceduralTexture = texture as ProceduralTexture;\r\n proceduralTexture\r\n .getContent()\r\n // eslint-disable-next-line github/no-then\r\n ?.then((data) => {\r\n this._cachedData = {\r\n width: size.width,\r\n height: size.height,\r\n data: data as Uint8ClampedArray,\r\n };\r\n resolve(this._cachedData);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n } else {\r\n TextureTools.GetTextureDataAsync(texture, size.width, size.height)\r\n // eslint-disable-next-line github/no-then\r\n .then((data) => {\r\n this._cachedData = {\r\n width: size.width,\r\n height: size.height,\r\n data: new Uint8ClampedArray(data),\r\n };\r\n texture.dispose();\r\n resolve(this._cachedData);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the current build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n if (this._sourceTexture) {\r\n this.texture._storedValue = this._sourceTexture;\r\n return;\r\n }\r\n\r\n if (!this._textureDataUrl && !this._url) {\r\n this.texture._storedValue = null;\r\n return;\r\n }\r\n\r\n if (this._textureDataUrl) {\r\n this.texture._storedValue = new Texture(this._textureDataUrl, state.scene);\r\n return;\r\n }\r\n\r\n this.texture._storedValue = new Texture(this._url, state.scene);\r\n }\r\n\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.url = this.url;\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n serializationObject.textureDataUrl = this.textureDataUrl;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.url = serializationObject.url;\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n\r\n if (serializationObject.textureDataUrl) {\r\n this.textureDataUrl = serializationObject.textureDataUrl;\r\n }\r\n }\r\n\r\n public override dispose(): void {\r\n if (!this._sourceTexture) {\r\n if (this.texture._storedValue) {\r\n this.texture._storedValue.dispose();\r\n this.texture._storedValue = null;\r\n }\r\n }\r\n super.dispose();\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleTextureSourceBlock\", ParticleTextureSourceBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"particleSourceTextureBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Particles/Node/Blocks/particleSourceTextureBlock.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,OAAO,EAAE,+CAAwC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,gDAAgD,CAAC;AACvG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,sCAA+B;AActD;;GAEG;AACH,MAAM,OAAO,0BAA2B,SAAQ,iBAAiB;IAY7D;;OAEG;IACH,IAAW,GAAG;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,IAAW,GAAG,CA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ACxC,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YACxC,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;QAC5C,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,oCAAoC,EAAE,0BAA0B,CAAC,CAAC","sourcesContent":["import type { NodeParticleConnectionPoint } from \"../nodeParticleBlockConnectionPoint\";\r\nimport type { NodeParticleBuildState } from \"../nodeParticleBuildState\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { BaseTexture } from \"../../../Materials/Textures/baseTexture\";\r\nimport type { ProceduralTexture } from \"../../../Materials\";\r\n\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeParticleBlockConnectionPointTypes } from \"../Enums/nodeParticleBlockConnectionPointTypes\";\r\nimport { NodeParticleBlock } from \"../nodeParticleBlock\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\n\r\n/**\r\n * Interface used to define texture data\r\n */\r\nexport interface INodeParticleTextureData {\r\n /** Width of the texture in pixels */\r\n width: number;\r\n /** Height of the texture in pixels */\r\n height: number;\r\n /** RGBA pixel data */\r\n data: Uint8ClampedArray;\r\n}\r\n\r\n/**\r\n * Block used to provide a texture for particles in a particle system\r\n */\r\nexport class ParticleTextureSourceBlock extends NodeParticleBlock {\r\n private _url: string = \"\";\r\n private _textureDataUrl: string = \"\";\r\n private _sourceTexture: Nullable<BaseTexture> = null;\r\n private _cachedData: Nullable<INodeParticleTextureData> = null;\r\n private _clonedTextures: BaseTexture[] = [];\r\n\r\n /**\r\n * Indicates if the texture data should be serialized as a base64 string.\r\n */\r\n public serializedCachedData: boolean = false;\r\n\r\n /**\r\n * Gets or sets the URL of the texture to be used by this block.\r\n */\r\n public get url(): string {\r\n return this._url;\r\n }\r\n\r\n public set url(value: string) {\r\n if (this._url === value) {\r\n return;\r\n }\r\n this._cachedData = null;\r\n this._url = value;\r\n this._textureDataUrl = \"\";\r\n this._sourceTexture = null;\r\n }\r\n\r\n /**\r\n * Gets or sets the data URL of the texture to be used by this block.\r\n * This is a base64 encoded string representing the texture data.\r\n */\r\n public get textureDataUrl(): string {\r\n return this._textureDataUrl;\r\n }\r\n\r\n public set textureDataUrl(value: string) {\r\n if (this._textureDataUrl === value) {\r\n return;\r\n }\r\n\r\n this._cachedData = null;\r\n this._textureDataUrl = value;\r\n this._url = \"\";\r\n this._sourceTexture = null;\r\n }\r\n\r\n /**\r\n * Directly sets the texture to be used by this block.\r\n * This value will not be serialized.\r\n */\r\n public set sourceTexture(value: Nullable<BaseTexture>) {\r\n if (this._sourceTexture === value) {\r\n return;\r\n }\r\n this._cachedData = null;\r\n this._sourceTexture = value;\r\n this._url = (value as Texture).url || \"\";\r\n this._textureDataUrl = \"\";\r\n }\r\n\r\n /**\r\n * Create a new ParticleTextureSourceBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"texture\", NodeParticleBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"ParticleTextureSourceBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture output component\r\n */\r\n public get texture(): NodeParticleConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the texture content as a promise\r\n * @returns a promise that resolves to the texture content, including width, height, and pixel data\r\n */\r\n async extractTextureContentAsync() {\r\n if (!this.texture._storedValue && !this._sourceTexture) {\r\n return null;\r\n }\r\n\r\n if (this._cachedData) {\r\n return this._cachedData;\r\n }\r\n\r\n const texture = this.texture._storedValue || this._sourceTexture;\r\n return await new Promise<\r\n Nullable<{\r\n width: number;\r\n height: number;\r\n data: Uint8ClampedArray;\r\n }>\r\n >((resolve, reject) => {\r\n if (!texture.isReady()) {\r\n texture.onLoadObservable.addOnce(async () => {\r\n try {\r\n this._cachedData = await this.extractTextureContentAsync();\r\n resolve(this._cachedData);\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(e);\r\n }\r\n });\r\n return;\r\n }\r\n const size = texture.getSize();\r\n if (texture.getContent) {\r\n const proceduralTexture = texture as ProceduralTexture;\r\n proceduralTexture\r\n .getContent()\r\n // eslint-disable-next-line github/no-then\r\n ?.then((data) => {\r\n this._cachedData = {\r\n width: size.width,\r\n height: size.height,\r\n data: data as Uint8ClampedArray,\r\n };\r\n resolve(this._cachedData);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n } else {\r\n TextureTools.GetTextureDataAsync(texture, size.width, size.height)\r\n // eslint-disable-next-line github/no-then\r\n .then((data) => {\r\n this._cachedData = {\r\n width: size.width,\r\n height: size.height,\r\n data: new Uint8ClampedArray(data),\r\n };\r\n texture.dispose();\r\n resolve(this._cachedData);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Builds the block\r\n * @param state defines the current build state\r\n */\r\n public override _build(state: NodeParticleBuildState) {\r\n if (this._sourceTexture) {\r\n // The same NodeParticleSystemSet can be built into multiple scenes/engines\r\n // (original system scene, editor preview scene).\r\n // Textures are engine-specific, so we need to handle cross-engine cases.\r\n const sourceScene = this._sourceTexture.getScene?.();\r\n const sourceEngine = sourceScene?.getEngine?.();\r\n const targetEngine = state.scene.getEngine();\r\n\r\n if (sourceEngine && sourceEngine !== targetEngine) {\r\n // Cross-engine: recreate texture from URL if available, preserving invertY\r\n const url = (this._sourceTexture as Texture).url || this._url;\r\n if (url) {\r\n const invertY = (this._sourceTexture as Texture).invertY ?? true;\r\n const tex = new Texture(url, state.scene, undefined, invertY);\r\n this._copyTextureProperties(this._sourceTexture, tex);\r\n this._clonedTextures.push(tex);\r\n this.texture._storedValue = tex;\r\n return;\r\n }\r\n // No URL available - use the source texture directly as fallback\r\n // This may not render correctly but avoids breaking completely\r\n this.texture._storedValue = this._sourceTexture;\r\n return;\r\n }\r\n\r\n // Same engine: clone works correctly and preserves all properties\r\n const cloned = this._sourceTexture.clone();\r\n if (cloned) {\r\n this._clonedTextures.push(cloned);\r\n this.texture._storedValue = cloned;\r\n } else {\r\n this.texture._storedValue = this._sourceTexture;\r\n }\r\n return;\r\n }\r\n\r\n if (!this._textureDataUrl && !this._url) {\r\n this.texture._storedValue = null;\r\n return;\r\n }\r\n\r\n if (this._textureDataUrl) {\r\n const tex = new Texture(this._textureDataUrl, state.scene);\r\n this._clonedTextures.push(tex);\r\n this.texture._storedValue = tex;\r\n return;\r\n }\r\n\r\n const tex = new Texture(this._url, state.scene);\r\n this._clonedTextures.push(tex);\r\n this.texture._storedValue = tex;\r\n }\r\n\r\n /**\r\n * Serializes this block\r\n * @returns the serialization object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.url = this.url;\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n\r\n if (this.serializedCachedData) {\r\n serializationObject.textureDataUrl = this.textureDataUrl;\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Deserializes this block from a serialization object\r\n * @param serializationObject the serialization object\r\n */\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.url = serializationObject.url;\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n\r\n if (serializationObject.textureDataUrl) {\r\n this.textureDataUrl = serializationObject.textureDataUrl;\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the block and its associated resources\r\n */\r\n public override dispose(): void {\r\n // Dispose all cloned textures we created\r\n for (const tex of this._clonedTextures) {\r\n tex.dispose();\r\n }\r\n this._clonedTextures = [];\r\n this.texture._storedValue = null;\r\n // Never dispose _sourceTexture - it's owned by the caller\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Copies texture properties from source to target texture\r\n * @param source - The source texture to copy properties from\r\n * @param target - The target texture to copy properties to\r\n */\r\n private _copyTextureProperties(source: BaseTexture, target: BaseTexture): void {\r\n // BaseTexture properties\r\n target.hasAlpha = source.hasAlpha;\r\n target.level = source.level;\r\n target.coordinatesIndex = source.coordinatesIndex;\r\n target.coordinatesMode = source.coordinatesMode;\r\n target.wrapU = source.wrapU;\r\n target.wrapV = source.wrapV;\r\n target.wrapR = source.wrapR;\r\n target.anisotropicFilteringLevel = source.anisotropicFilteringLevel;\r\n\r\n // Texture-specific properties (if both are Texture instances)\r\n const sourceTexture = source as Texture;\r\n const targetTexture = target as Texture;\r\n if (sourceTexture.uOffset !== undefined && targetTexture.uOffset !== undefined) {\r\n targetTexture.uOffset = sourceTexture.uOffset;\r\n targetTexture.vOffset = sourceTexture.vOffset;\r\n targetTexture.uScale = sourceTexture.uScale;\r\n targetTexture.vScale = sourceTexture.vScale;\r\n targetTexture.uAng = sourceTexture.uAng;\r\n targetTexture.vAng = sourceTexture.vAng;\r\n targetTexture.wAng = sourceTexture.wAng;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.ParticleTextureSourceBlock\", ParticleTextureSourceBlock);\r\n"]}
|