@babylonjs/core 8.43.0 → 8.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -10
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -2
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js +8 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
- package/Engines/WebGPU/webgpuHardwareTexture.js +27 -21
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.d.ts +5 -4
- package/Engines/WebGPU/webgpuTextureManager.js +20 -30
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +1 -0
- package/Engines/thinEngine.js +9 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/thinWebGPUEngine.js +2 -3
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +28 -13
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +2 -2
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +4 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js +19 -0
- package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
- package/FrameGraph/Passes/renderPass.d.ts +16 -0
- package/FrameGraph/Passes/renderPass.js +12 -0
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -2
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +3 -2
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.js +4 -15
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.d.ts +2 -2
- package/FrameGraph/frameGraphTask.js +6 -6
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/frameGraphTaskMultiRenderTarget.d.ts +15 -0
- package/FrameGraph/frameGraphTaskMultiRenderTarget.js +25 -0
- package/FrameGraph/frameGraphTaskMultiRenderTarget.js.map +1 -0
- package/FrameGraph/frameGraphTextureManager.js +13 -2
- package/FrameGraph/frameGraphTextureManager.js.map +1 -1
- package/FrameGraph/frameGraphTypes.d.ts +9 -1
- package/FrameGraph/frameGraphTypes.js.map +1 -1
- package/Materials/Textures/dynamicTexture.d.ts +2 -2
- package/Materials/Textures/dynamicTexture.js +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/textureCreationOptions.d.ts +2 -0
- package/Materials/Textures/textureCreationOptions.js +0 -1
- package/Materials/Textures/textureCreationOptions.js.map +1 -1
- package/Materials/index.d.ts +1 -0
- package/Materials/index.js +1 -0
- package/Materials/index.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +1 -0
- package/Materials/shaderMaterial.js +22 -7
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/vertexPullingHelper.functions.d.ts +32 -0
- package/Materials/vertexPullingHelper.functions.js +60 -0
- package/Materials/vertexPullingHelper.functions.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +4 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/abstractMesh.js +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geometry.js +1 -0
- package/Meshes/geometry.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 +47 -20
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +2 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +7 -5
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
- package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLighting.js +4 -4
- package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js +4 -2
- package/Shaders/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +4 -12
- package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/Shaders/picking.vertex.js +2 -2
- package/Shaders/picking.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +6 -4
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +4 -4
- package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +4 -2
- package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +8 -14
- package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +2 -0
- package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -8
- package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
- package/ShadersWGSL/picking.vertex.js +2 -2
- package/ShadersWGSL/picking.vertex.js.map +1 -1
- package/package.json +1 -1
|
@@ -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,MAAM,yBAAyB,CAAC;AAI5D;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAqCxD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAzChB;;WAEG;QAEI,UAAK,GAAG,CAAC,CAAC;QAEjB;;WAEG;QAEI,QAAG,GAAG,CAAC,CAAC;QAEf;;WAEG;QAEI,UAAK,GAAG,EAAE,CAAC;QAElB;;WAEG;QAEI,WAAM,GAAG,EAAE,CAAC;QAEnB;;WAEG;QAEI,SAAI,GAAG,KAAK,CAAC;QAEpB;;WAEG;QAEI,oBAAe,GAAG,KAAK,CAAC;QAS3B,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,QAAQ,CAAC,CAAC;QAE9E,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,qBAAqB,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,uBAAuB,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,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AU,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;AAGvG;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,iBAAiB;IAGtD;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAEZ,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAC7E,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,qCAAqC,CAAC,UAAU,CAAC,CAAC;QAE9E,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,qCAAqC,CAAC,YAAY,CAAC,CAAC;QAElF,IAAI,CAAC,MAAM,CAAC,qBAAqB,GAAG,IAAI,CAAC,IAAI,CAAC;QAE9C,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,GAAG,CAAC,CAAC;QACvF,IAAI,CAAC,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QACzF,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,GAAG,CAAC,CAAC;QACxF,IAAI,CAAC,KAAK,CAAC,4BAA4B,CAAC,IAAI,CAAC,qCAAqC,CAAC,KAAK,CAAC,CAAC;QAE1F,IAAI,CA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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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GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACpE,CAAC;IAEe,SAAS;QACrB,MAAM,mBAAmB,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QAE9C,mBAAmB,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACnC,mBAAmB,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,CAAC;QAErE,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC5B,mBAAmB,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC7D,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,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/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MAAM,aAAa,GAAG,MAAiB,CAAC;QACxC,MAAM,aAAa,GAAG,MAAiB,CAAC;QACxC,IAAI,aAAa,CAAC,OAAO,KAAK,SAAS,IAAI,aAAa,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;YAC7E,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;YAC9C,aAAa,CAAC,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;YAC9C,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YAC5C,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;YAC5C,aAAa,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YACxC,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"]}
|