@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.
Files changed (129) hide show
  1. package/Engines/WebGPU/Extensions/engine.multiRender.js +5 -10
  2. package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
  3. package/Engines/WebGPU/Extensions/engine.renderTarget.js +4 -2
  4. package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
  5. package/Engines/WebGPU/webgpuDrawContext.d.ts +8 -0
  6. package/Engines/WebGPU/webgpuDrawContext.js +8 -0
  7. package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
  8. package/Engines/WebGPU/webgpuHardwareTexture.d.ts +4 -3
  9. package/Engines/WebGPU/webgpuHardwareTexture.js +27 -21
  10. package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
  11. package/Engines/WebGPU/webgpuTextureManager.d.ts +5 -4
  12. package/Engines/WebGPU/webgpuTextureManager.js +20 -30
  13. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  14. package/Engines/abstractEngine.js +2 -2
  15. package/Engines/abstractEngine.js.map +1 -1
  16. package/Engines/engine.d.ts +1 -0
  17. package/Engines/thinEngine.js +9 -1
  18. package/Engines/thinEngine.js.map +1 -1
  19. package/Engines/thinWebGPUEngine.js +2 -3
  20. package/Engines/thinWebGPUEngine.js.map +1 -1
  21. package/Engines/webgpuEngine.js +28 -13
  22. package/Engines/webgpuEngine.js.map +1 -1
  23. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +2 -2
  24. package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
  25. package/FrameGraph/Node/Blocks/Textures/clearBlock.d.ts +1 -1
  26. package/FrameGraph/Node/Blocks/Textures/clearBlock.js +2 -2
  27. package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
  28. package/FrameGraph/Node/Blocks/inputBlock.js +4 -0
  29. package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
  30. package/FrameGraph/Node/nodeRenderGraphBlock.d.ts +1 -0
  31. package/FrameGraph/Node/nodeRenderGraphBlock.js +19 -0
  32. package/FrameGraph/Node/nodeRenderGraphBlock.js.map +1 -1
  33. package/FrameGraph/Passes/renderPass.d.ts +16 -0
  34. package/FrameGraph/Passes/renderPass.js +12 -0
  35. package/FrameGraph/Passes/renderPass.js.map +1 -1
  36. package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +3 -3
  37. package/FrameGraph/Tasks/Rendering/objectRendererTask.js +3 -2
  38. package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
  39. package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +2 -2
  40. package/FrameGraph/Tasks/Texture/clearTextureTask.js +3 -2
  41. package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
  42. package/FrameGraph/frameGraphRenderContext.js +4 -15
  43. package/FrameGraph/frameGraphRenderContext.js.map +1 -1
  44. package/FrameGraph/frameGraphTask.d.ts +2 -2
  45. package/FrameGraph/frameGraphTask.js +6 -6
  46. package/FrameGraph/frameGraphTask.js.map +1 -1
  47. package/FrameGraph/frameGraphTaskMultiRenderTarget.d.ts +15 -0
  48. package/FrameGraph/frameGraphTaskMultiRenderTarget.js +25 -0
  49. package/FrameGraph/frameGraphTaskMultiRenderTarget.js.map +1 -0
  50. package/FrameGraph/frameGraphTextureManager.js +13 -2
  51. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  52. package/FrameGraph/frameGraphTypes.d.ts +9 -1
  53. package/FrameGraph/frameGraphTypes.js.map +1 -1
  54. package/Materials/Textures/dynamicTexture.d.ts +2 -2
  55. package/Materials/Textures/dynamicTexture.js +1 -1
  56. package/Materials/Textures/dynamicTexture.js.map +1 -1
  57. package/Materials/Textures/textureCreationOptions.d.ts +2 -0
  58. package/Materials/Textures/textureCreationOptions.js +0 -1
  59. package/Materials/Textures/textureCreationOptions.js.map +1 -1
  60. package/Materials/index.d.ts +1 -0
  61. package/Materials/index.js +1 -0
  62. package/Materials/index.js.map +1 -1
  63. package/Materials/shaderMaterial.d.ts +1 -0
  64. package/Materials/shaderMaterial.js +22 -7
  65. package/Materials/shaderMaterial.js.map +1 -1
  66. package/Materials/vertexPullingHelper.functions.d.ts +32 -0
  67. package/Materials/vertexPullingHelper.functions.js +60 -0
  68. package/Materials/vertexPullingHelper.functions.js.map +1 -0
  69. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +4 -0
  70. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  71. package/Meshes/abstractMesh.js +1 -1
  72. package/Meshes/abstractMesh.js.map +1 -1
  73. package/Meshes/geometry.js +1 -0
  74. package/Meshes/geometry.js.map +1 -1
  75. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js +3 -0
  76. package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js.map +1 -1
  77. package/Particles/Node/Blocks/index.d.ts +1 -0
  78. package/Particles/Node/Blocks/index.js +1 -0
  79. package/Particles/Node/Blocks/index.js.map +1 -1
  80. package/Particles/Node/Blocks/particleModuloBlock.d.ts +37 -0
  81. package/Particles/Node/Blocks/particleModuloBlock.js +98 -0
  82. package/Particles/Node/Blocks/particleModuloBlock.js.map +1 -0
  83. package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +22 -1
  84. package/Particles/Node/Blocks/particleSourceTextureBlock.js +83 -9
  85. package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
  86. package/Particles/Node/nodeParticleSystemSet.helper.js +47 -20
  87. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  88. package/Particles/solidParticleSystem.d.ts +2 -1
  89. package/Particles/solidParticleSystem.js.map +1 -1
  90. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +4 -0
  91. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  92. package/Shaders/ShadersInclude/lightFragment.js +7 -5
  93. package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
  94. package/Shaders/ShadersInclude/lightUboDeclaration.js +1 -1
  95. package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
  96. package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
  97. package/Shaders/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
  98. package/Shaders/ShadersInclude/lightVxUboDeclaration.js +1 -1
  99. package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
  100. package/Shaders/ShadersInclude/openpbrDirectLighting.js +4 -4
  101. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  102. package/Shaders/ShadersInclude/openpbrDirectLightingInit.js +4 -2
  103. package/Shaders/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  104. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js +4 -12
  105. package/Shaders/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  106. package/Shaders/picking.vertex.js +2 -2
  107. package/Shaders/picking.vertex.js.map +1 -1
  108. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +2 -2
  109. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  110. package/ShadersWGSL/ShadersInclude/lightFragment.js +6 -4
  111. package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
  112. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +1 -1
  113. package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
  114. package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js +1 -1
  115. package/ShadersWGSL/ShadersInclude/lightVxFragmentDeclaration.js.map +1 -1
  116. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +1 -1
  117. package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
  118. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +4 -4
  119. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  120. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js +4 -2
  121. package/ShadersWGSL/ShadersInclude/openpbrDirectLightingInit.js.map +1 -1
  122. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js +8 -14
  123. package/ShadersWGSL/ShadersInclude/shadowsFragmentFunctions.js.map +1 -1
  124. package/ShadersWGSL/iblVoxelGrid.vertex.d.ts +2 -0
  125. package/ShadersWGSL/iblVoxelGrid.vertex.js +78 -8
  126. package/ShadersWGSL/iblVoxelGrid.vertex.js.map +1 -1
  127. package/ShadersWGSL/picking.vertex.js +2 -2
  128. package/ShadersWGSL/picking.vertex.js.map +1 -1
  129. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dynamicTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/dynamicTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,gDAAgD,CAAC;AAcxD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,OAAO;IA6CvC,gBAAgB;IAChB,YACI,IAAY,EACZ,YAAkE,EAClE,cAAyD,EACzD,kBAA2B,KAAK,EAChC,eAAuB,SAAS,CAAC,8BAA8B,EAC/D,SAAiB,SAAS,CAAC,kBAAkB,EAC7C,OAAiB;QAEjB,MAAM,OAAO,GAAG,CAAC,cAAc,IAAK,cAAwB,CAAC,QAAQ,CAAC;QACtE,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAE,cAAwB,CAAC,CAAC,CAAE,cAAyC,EAAE,KAAK,CAAC;QACtG,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAE,cAAyC,CAAC;QAEzF,KAAK,CAAC,IAAI,EAAE,KAAK,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CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC5C,mBAAmB,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QAErD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEO,MAAM,CAAC,gBAAgB,CAAC,MAAqD;QACjF,OAAQ,MAA4B,CAAC,SAAS,KAAK,SAAS,CAAC;IACjE,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport type { ITextureCreationOptions } from \"../../Materials/Textures/texture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\n/**\r\n * Interface defining options used to create a dynamic texture\r\n */\r\nexport interface IDynamicTextureOptions extends ITextureCreationOptions {\r\n /** defines the width of the texture (default: 0) */\r\n width?: number;\r\n /** defines the height of the texture (default: 0) */\r\n height?: number;\r\n /** defines the hosting scene (default: null) */\r\n scene?: Nullable<Scene>;\r\n}\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _ownCanvas: boolean;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param canvasOrSize provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param options The options to be used when constructing the dynamic texture\r\n */\r\n constructor(name: string, canvasOrSize: ICanvas | { width: number; height: number } | number, options?: IDynamicTextureOptions);\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MinMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n constructor(\r\n name: string,\r\n options: ICanvas | { width: number; height: number } | number,\r\n scene?: Nullable<Scene>,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n const isScene = !sceneOrOptions || (sceneOrOptions as Scene)._isScene;\r\n const scene = isScene ? (sceneOrOptions as Scene) : (sceneOrOptions as IDynamicTextureOptions)?.scene;\r\n const noMipmap = isScene ? !generateMipMaps : (sceneOrOptions as IDynamicTextureOptions);\r\n\r\n super(null, scene, noMipmap, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if ((canvasOrSize as ICanvas).getContext) {\r\n this._canvas = canvasOrSize as ICanvas;\r\n this._ownCanvas = false;\r\n this._texture = engine.createDynamicTexture(this._canvas.width, this._canvas.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n this._ownCanvas = true;\r\n\r\n const optionsAsSize = canvasOrSize as ISize;\r\n if (optionsAsSize.width || optionsAsSize.width === 0) {\r\n this._texture = engine.createDynamicTexture(optionsAsSize.width, optionsAsSize.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(canvasOrSize as number, canvasOrSize as number, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public override get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public override scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n // When disposed, this._texture will be null.\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this bleands with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the dynamic texture.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n if (this._ownCanvas) {\r\n this._canvas?.remove?.();\r\n }\r\n (this._canvas as any) = null;\r\n (this._context as any) = null;\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public override serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"dynamicTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/dynamicTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAK3C,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAGpD,OAAO,gDAAgD,CAAC;AAcxD;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,OAAO;IA6CvC,gBAAgB;IAChB,YACI,IAAY,EACZ,YAAkE,EAClE,cAAyD,EACzD,kBAA2B,KAAK,EAChC,eAAuB,SAAS,CAAC,8BAA8B,EAC/D,SAAiB,SAAS,CAAC,kBAAkB,EAC7C,OAAiB;QAEjB,MAAM,OAAO,GAAG,CAAC,cAAc,IAAK,cAAwB,CAAC,QAAQ,CAAC;QACtE,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAE,cAAwB,CAAC,CAAC,CAAE,cAAyC,EAAE,KAAK,CAAC;QACtG,MAAM,QAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAE,cAAyC,CAAC;QAEzF,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;QAExG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,OAA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,OAAQ,MAA4B,CAAC,SAAS,KAAK,SAAS,CAAC;IACjE,CAAC;IAED,gBAAgB;IACA,QAAQ;QACpB,IAAI,CAAC,MAAM,EAAE,CAAC;IAClB,CAAC;CACJ","sourcesContent":["import { Logger } from \"../../Misc/logger\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport type { ISize } from \"../../Maths/math.size\";\r\nimport type { ITextureCreationOptions } from \"../../Materials/Textures/texture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\n\r\nimport \"../../Engines/Extensions/engine.dynamicTexture\";\r\n\r\n/**\r\n * Interface defining options used to create a dynamic texture\r\n */\r\nexport interface IDynamicTextureOptions extends ITextureCreationOptions {\r\n /** defines the width of the texture (default: 0) */\r\n width?: number;\r\n /** defines the height of the texture (default: 0) */\r\n height?: number;\r\n /** defines the hosting scene (default: null) */\r\n scene?: Nullable<Scene>;\r\n}\r\n\r\n/**\r\n * A class extending Texture allowing drawing on a texture\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/dynamicTexture\r\n */\r\nexport class DynamicTexture extends Texture {\r\n private _generateMipMaps: boolean;\r\n private _canvas: ICanvas;\r\n private _ownCanvas: boolean;\r\n private _context: ICanvasRenderingContext;\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param canvasOrSize provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param options The options to be used when constructing the dynamic texture\r\n */\r\n constructor(name: string, canvasOrSize: ICanvas | { width: number; height: number } | number, options?: IDynamicTextureOptions);\r\n\r\n /**\r\n * Creates a DynamicTexture\r\n * @param name defines the name of the texture\r\n * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height\r\n * @param scene defines the scene where you want the texture\r\n * @param generateMipMaps defines the use of MipMaps or not (default is false)\r\n * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)\r\n * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)\r\n * @param invertY defines if the texture needs to be inverted on the y axis during loading\r\n */\r\n constructor(\r\n name: string,\r\n options: ICanvas | { width: number; height: number } | number,\r\n scene?: Nullable<Scene>,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps?: boolean,\r\n samplingMode?: number,\r\n format?: number,\r\n invertY?: boolean\r\n );\r\n\r\n /** @internal */\r\n constructor(\r\n name: string,\r\n canvasOrSize: ICanvas | { width: number; height: number } | number,\r\n sceneOrOptions?: Nullable<Scene> | IDynamicTextureOptions,\r\n generateMipMaps: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n invertY?: boolean\r\n ) {\r\n const isScene = !sceneOrOptions || (sceneOrOptions as Scene)._isScene;\r\n const scene = isScene ? (sceneOrOptions as Scene) : (sceneOrOptions as IDynamicTextureOptions)?.scene;\r\n const noMipmap = isScene ? !generateMipMaps : (sceneOrOptions as IDynamicTextureOptions);\r\n\r\n super(null, scene, noMipmap, invertY, samplingMode, undefined, undefined, undefined, undefined, format);\r\n\r\n this.name = name;\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n\r\n this._generateMipMaps = generateMipMaps;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return;\r\n }\r\n\r\n if ((canvasOrSize as ICanvas).getContext) {\r\n this._canvas = canvasOrSize as ICanvas;\r\n this._ownCanvas = false;\r\n this._texture = engine.createDynamicTexture(this._canvas.width, this._canvas.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._canvas = engine.createCanvas(1, 1);\r\n this._ownCanvas = true;\r\n\r\n const optionsAsSize = canvasOrSize as ISize;\r\n if (optionsAsSize.width || optionsAsSize.width === 0) {\r\n this._texture = engine.createDynamicTexture(optionsAsSize.width, optionsAsSize.height, generateMipMaps, samplingMode);\r\n } else {\r\n this._texture = engine.createDynamicTexture(canvasOrSize as number, canvasOrSize as number, generateMipMaps, samplingMode);\r\n }\r\n }\r\n\r\n const textureSize = this.getSize();\r\n\r\n if (this._canvas.width !== textureSize.width) {\r\n this._canvas.width = textureSize.width;\r\n }\r\n if (this._canvas.height !== textureSize.height) {\r\n this._canvas.height = textureSize.height;\r\n }\r\n this._context = this._canvas.getContext(\"2d\");\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"DynamicTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"DynamicTexture\";\r\n }\r\n\r\n /**\r\n * Gets the current state of canRescale\r\n */\r\n public override get canRescale(): boolean {\r\n return true;\r\n }\r\n\r\n private _recreate(textureSize: ISize): void {\r\n this._canvas.width = textureSize.width;\r\n this._canvas.height = textureSize.height;\r\n\r\n this.releaseInternalTexture();\r\n\r\n this._texture = this._getEngine()!.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);\r\n }\r\n\r\n /**\r\n * Scales the texture\r\n * @param ratio the scale factor to apply to both width and height\r\n */\r\n public override scale(ratio: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width *= ratio;\r\n textureSize.height *= ratio;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Resizes the texture\r\n * @param width the new width\r\n * @param height the new height\r\n */\r\n public scaleTo(width: number, height: number): void {\r\n const textureSize = this.getSize();\r\n\r\n textureSize.width = width;\r\n textureSize.height = height;\r\n\r\n this._recreate(textureSize);\r\n }\r\n\r\n /**\r\n * Gets the context of the canvas used by the texture\r\n * @returns the canvas context of the dynamic texture\r\n */\r\n public getContext(): ICanvasRenderingContext {\r\n return this._context;\r\n }\r\n\r\n /**\r\n * Clears the texture\r\n * @param clearColor Defines the clear color to use\r\n */\r\n public clear(clearColor?: string): void {\r\n const size = this.getSize();\r\n if (clearColor) {\r\n this._context.fillStyle = clearColor;\r\n }\r\n this._context.clearRect(0, 0, size.width, size.height);\r\n }\r\n\r\n /**\r\n * Updates the texture\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param premulAlpha defines if alpha is stored as premultiplied (default is false)\r\n * @param allowGPUOptimization true to allow some specific GPU optimizations (subject to engine feature \"allowGPUOptimizationsForGUI\" being true)\r\n */\r\n public update(invertY?: boolean, premulAlpha = false, allowGPUOptimization = false): void {\r\n // When disposed, this._texture will be null.\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._getEngine()!.updateDynamicTexture(\r\n this._texture,\r\n this._canvas,\r\n invertY === undefined ? true : invertY,\r\n premulAlpha,\r\n this._format || undefined,\r\n undefined,\r\n allowGPUOptimization\r\n );\r\n }\r\n\r\n /**\r\n * Draws text onto the texture\r\n * @param text defines the text to be drawn\r\n * @param x defines the placement of the text from the left\r\n * @param y defines the placement of the text from the top when invertY is true and from the bottom when false\r\n * @param font defines the font to be used with font-style, font-size, font-name\r\n * @param color defines the color used for the text\r\n * @param fillColor defines the color for the canvas, use null to not overwrite canvas (this blends with the background to replace, use the clear function)\r\n * @param invertY defines the direction for the Y axis (default is true - y increases downwards)\r\n * @param update defines whether texture is immediately update (default is true)\r\n */\r\n public drawText(\r\n text: string,\r\n x: number | null | undefined,\r\n y: number | null | undefined,\r\n font: string,\r\n color: string | null,\r\n fillColor: string | null,\r\n invertY?: boolean,\r\n update = true\r\n ) {\r\n const size = this.getSize();\r\n if (fillColor) {\r\n this._context.fillStyle = fillColor;\r\n this._context.fillRect(0, 0, size.width, size.height);\r\n }\r\n\r\n this._context.font = font;\r\n if (x === null || x === undefined) {\r\n const textSize = this._context.measureText(text);\r\n x = (size.width - textSize.width) / 2;\r\n }\r\n if (y === null || y === undefined) {\r\n const fontSize = parseInt(font.replace(/\\D/g, \"\"));\r\n y = size.height / 2 + fontSize / 3.65;\r\n }\r\n\r\n this._context.fillStyle = color || \"\";\r\n this._context.fillText(text, x, y);\r\n\r\n if (update) {\r\n this.update(invertY);\r\n }\r\n }\r\n\r\n /**\r\n * Disposes the dynamic texture.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n\r\n if (this._ownCanvas) {\r\n this._canvas?.remove?.();\r\n }\r\n (this._canvas as any) = null;\r\n (this._context as any) = null;\r\n }\r\n\r\n /**\r\n * Clones the texture\r\n * @returns the clone of the texture.\r\n */\r\n public override clone(): DynamicTexture {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return this;\r\n }\r\n\r\n const textureSize = this.getSize();\r\n const newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);\r\n\r\n // Base texture\r\n newTexture.hasAlpha = this.hasAlpha;\r\n newTexture.level = this.level;\r\n\r\n // Dynamic Texture\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n\r\n return newTexture;\r\n }\r\n\r\n /**\r\n * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized\r\n * @returns a serialized dynamic texture object\r\n */\r\n public override serialize(): any {\r\n const scene = this.getScene();\r\n if (scene && !scene.isReady()) {\r\n Logger.Warn(\"The scene must be ready before serializing the dynamic texture\");\r\n }\r\n\r\n const serializationObject = super.serialize();\r\n if (DynamicTexture._IsCanvasElement(this._canvas)) {\r\n serializationObject.base64String = this._canvas.toDataURL();\r\n }\r\n\r\n serializationObject.invertY = this._invertY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n\r\n return serializationObject;\r\n }\r\n\r\n private static _IsCanvasElement(canvas: HTMLCanvasElement | OffscreenCanvas | ICanvas): canvas is HTMLCanvasElement {\r\n return (canvas as HTMLCanvasElement).toDataURL !== undefined;\r\n }\r\n\r\n /** @internal */\r\n public override _rebuild(): void {\r\n this.update();\r\n }\r\n}\r\n"]}
@@ -25,6 +25,8 @@ export interface InternalTextureCreationOptions {
25
25
  createMSAATexture?: boolean;
26
26
  /** Comparison function. Used only for depth textures (default: 0) */
27
27
  comparisonFunction?: number;
28
+ /** If the created texture is a cube texture */
29
+ isCube?: boolean;
28
30
  }
29
31
  /**
30
32
  * Define options used to create a render target texture
@@ -4,7 +4,6 @@
4
4
  * @returns True if the TextureSize is an object
5
5
  */
6
6
  export function textureSizeIsObject(size) {
7
- // eslint-disable-next-line jsdoc/require-jsdoc
8
7
  return size.width !== undefined;
9
8
  }
10
9
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"textureCreationOptions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/textureCreationOptions.ts"],"names":[],"mappings":"AAsEA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAiB;IACjD,+CAA+C;IAC/C,OAAQ,IAA0B,CAAC,KAAK,KAAK,SAAS,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAiB;IAC1D,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { InternalTexture } from \"./internalTexture\";\r\n\r\n/**\r\n * Define options used to create an internal texture\r\n */\r\nexport interface InternalTextureCreationOptions {\r\n /** Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead */\r\n createMipMaps?: boolean;\r\n /** Specifies if mipmaps must be generated */\r\n generateMipMaps?: boolean;\r\n /** Defines texture type (unsigned byte by default) */\r\n type?: number;\r\n /** Defines sampling mode (trilinear by default) */\r\n samplingMode?: number;\r\n /** Defines format (RGBA by default) */\r\n format?: number;\r\n /** Defines sample count (1 by default) */\r\n samples?: number;\r\n /** Texture creation flags */\r\n creationFlags?: number;\r\n /** Creates the RTT in sRGB space */\r\n useSRGBBuffer?: boolean;\r\n /** Label of the texture (used for debugging only) */\r\n label?: string;\r\n /** If the MSAA texture must be created right away (default: false) */\r\n createMSAATexture?: boolean;\r\n /** Comparison function. Used only for depth textures (default: 0) */\r\n comparisonFunction?: number;\r\n}\r\n\r\n/**\r\n * Define options used to create a render target texture\r\n */\r\nexport interface RenderTargetCreationOptions extends InternalTextureCreationOptions {\r\n /** Specifies whether or not a depth should be allocated in the texture (true by default) */\r\n generateDepthBuffer?: boolean;\r\n /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/\r\n generateStencilBuffer?: boolean;\r\n /** Specifies that no color target should be bound to the render target (useful if you only want to write to the depth buffer, for eg) */\r\n noColorAttachment?: boolean;\r\n /** Specifies the internal texture to use directly instead of creating one (ignores `noColorAttachment` flag when set) **/\r\n colorAttachment?: InternalTexture;\r\n}\r\n\r\n/**\r\n * Define options used to create a depth texture\r\n */\r\nexport interface DepthTextureCreationOptions {\r\n /** Specifies whether or not a stencil should be allocated in the texture. Not used if depthTextureFormat is supplied, in which case stencil creation will depend on this value. */\r\n generateStencil?: boolean;\r\n /** Specifies whether or not bilinear filtering is enable on the texture */\r\n bilinearFiltering?: boolean;\r\n /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */\r\n comparisonFunction?: number;\r\n /** Specifies if the created texture is a cube texture */\r\n isCube?: boolean;\r\n /** Specifies the sample count of the depth/stencil texture texture */\r\n samples?: number;\r\n /** Specifies the depth texture format to use */\r\n depthTextureFormat?: number;\r\n /** Label of the texture (used for debugging only) */\r\n label?: string;\r\n}\r\n\r\n/**\r\n * Type used to define a texture size (either with a number or with a rect width and height)\r\n */\r\nexport type TextureSize = number | { width: number; height: number; depth?: number; layers?: number };\r\n\r\n/**\r\n * Check if a TextureSize is an object\r\n * @param size The TextureSize to check\r\n * @returns True if the TextureSize is an object\r\n */\r\nexport function textureSizeIsObject(size: TextureSize): size is { width: number; height: number } {\r\n // eslint-disable-next-line jsdoc/require-jsdoc\r\n return (size as { width: number }).width !== undefined;\r\n}\r\n\r\n/**\r\n * Get the width/height dimensions from a TextureSize\r\n * @param size The TextureSize to get the dimensions from\r\n * @returns The width and height as an object\r\n */\r\nexport function getDimensionsFromTextureSize(size: TextureSize): { width: number; height: number } {\r\n if (textureSizeIsObject(size)) {\r\n return { width: size.width, height: size.height };\r\n }\r\n return { width: size, height: size };\r\n}\r\n"]}
1
+ {"version":3,"file":"textureCreationOptions.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/textureCreationOptions.ts"],"names":[],"mappings":"AAwEA;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAiB;IACjD,OAAQ,IAA0B,CAAC,KAAK,KAAK,SAAS,CAAC;AAC3D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAiB;IAC1D,IAAI,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;IACtD,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AACzC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { InternalTexture } from \"./internalTexture\";\r\n\r\n/**\r\n * Define options used to create an internal texture\r\n */\r\nexport interface InternalTextureCreationOptions {\r\n /** Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead */\r\n createMipMaps?: boolean;\r\n /** Specifies if mipmaps must be generated */\r\n generateMipMaps?: boolean;\r\n /** Defines texture type (unsigned byte by default) */\r\n type?: number;\r\n /** Defines sampling mode (trilinear by default) */\r\n samplingMode?: number;\r\n /** Defines format (RGBA by default) */\r\n format?: number;\r\n /** Defines sample count (1 by default) */\r\n samples?: number;\r\n /** Texture creation flags */\r\n creationFlags?: number;\r\n /** Creates the RTT in sRGB space */\r\n useSRGBBuffer?: boolean;\r\n /** Label of the texture (used for debugging only) */\r\n label?: string;\r\n /** If the MSAA texture must be created right away (default: false) */\r\n createMSAATexture?: boolean;\r\n /** Comparison function. Used only for depth textures (default: 0) */\r\n comparisonFunction?: number;\r\n /** If the created texture is a cube texture */\r\n isCube?: boolean;\r\n}\r\n\r\n/**\r\n * Define options used to create a render target texture\r\n */\r\nexport interface RenderTargetCreationOptions extends InternalTextureCreationOptions {\r\n /** Specifies whether or not a depth should be allocated in the texture (true by default) */\r\n generateDepthBuffer?: boolean;\r\n /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/\r\n generateStencilBuffer?: boolean;\r\n /** Specifies that no color target should be bound to the render target (useful if you only want to write to the depth buffer, for eg) */\r\n noColorAttachment?: boolean;\r\n /** Specifies the internal texture to use directly instead of creating one (ignores `noColorAttachment` flag when set) **/\r\n colorAttachment?: InternalTexture;\r\n}\r\n\r\n/**\r\n * Define options used to create a depth texture\r\n */\r\nexport interface DepthTextureCreationOptions {\r\n /** Specifies whether or not a stencil should be allocated in the texture. Not used if depthTextureFormat is supplied, in which case stencil creation will depend on this value. */\r\n generateStencil?: boolean;\r\n /** Specifies whether or not bilinear filtering is enable on the texture */\r\n bilinearFiltering?: boolean;\r\n /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */\r\n comparisonFunction?: number;\r\n /** Specifies if the created texture is a cube texture */\r\n isCube?: boolean;\r\n /** Specifies the sample count of the depth/stencil texture texture */\r\n samples?: number;\r\n /** Specifies the depth texture format to use */\r\n depthTextureFormat?: number;\r\n /** Label of the texture (used for debugging only) */\r\n label?: string;\r\n}\r\n\r\n/**\r\n * Type used to define a texture size (either with a number or with a rect width and height)\r\n */\r\nexport type TextureSize = number | { width: number; height: number; depth?: number; layers?: number };\r\n\r\n/**\r\n * Check if a TextureSize is an object\r\n * @param size The TextureSize to check\r\n * @returns True if the TextureSize is an object\r\n */\r\nexport function textureSizeIsObject(size: TextureSize): size is { width: number; height: number } {\r\n return (size as { width: number }).width !== undefined;\r\n}\r\n\r\n/**\r\n * Get the width/height dimensions from a TextureSize\r\n * @param size The TextureSize to get the dimensions from\r\n * @returns The width and height as an object\r\n */\r\nexport function getDimensionsFromTextureSize(size: TextureSize): { width: number; height: number } {\r\n if (textureSizeIsObject(size)) {\r\n return { width: size.width, height: size.height };\r\n }\r\n return { width: size, height: size };\r\n}\r\n"]}
@@ -42,6 +42,7 @@ export * from "./materialHelper.geometryrendering.js";
42
42
  export * from "./materialStencilState.js";
43
43
  export * from "./uv.defines.js";
44
44
  export * from "./floatingOriginMatrixOverrides.js";
45
+ export * from "./vertexPullingHelper.functions.js";
45
46
  import "./material.decalMap.js";
46
47
  export * from "../Shaders/default.fragment.js";
47
48
  export * from "../Shaders/default.vertex.js";
@@ -43,6 +43,7 @@ export * from "./materialHelper.geometryrendering.js";
43
43
  export * from "./materialStencilState.js";
44
44
  export * from "./uv.defines.js";
45
45
  export * from "./floatingOriginMatrixOverrides.js";
46
+ export * from "./vertexPullingHelper.functions.js";
46
47
  import "./material.decalMap.js";
47
48
  // async-loaded shaders
48
49
  // StandardMaterial
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC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-imports */\r\nexport * from \"./Background/index\";\r\nexport * from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nexport * from \"./floatingOriginMatrixOverrides\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AACzB,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yCAAyC,CAAC;AACxD,cAAc,yCAAyC,CAAC;AACxD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+CAA+C,CAAC;AAC9D,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,cAAc,CAAC;AAC7B,cAAc,iCAAiC,CAAC;AAChD,cAAc,iCAAiC,CAAC;AAChD,OAAO,qBAAqB,CAAC;AAE7B,uBAAuB;AAEvB,mBAAmB;AACnB,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAE9C,2BAA2B;AAC3B,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./Background/index\";\r\nexport * from \"./colorCurves\";\r\nexport * from \"./iEffectFallbacks\";\r\nexport * from \"./effectFallbacks\";\r\nexport * from \"./effect\";\r\nexport * from \"./fresnelParameters\";\r\nexport * from \"./imageProcessing\";\r\nexport * from \"./imageProcessingConfiguration\";\r\nexport * from \"./material\";\r\nexport * from \"./materialDefines\";\r\nexport * from \"./clipPlaneMaterialHelper\";\r\nexport * from \"./materialHelper\";\r\nexport * from \"./multiMaterial\";\r\nexport * from \"./Occlusion/index\";\r\nexport * from \"./PBR/index\";\r\nexport * from \"./pushMaterial\";\r\nexport * from \"./shaderLanguage\";\r\nexport * from \"./shaderMaterial\";\r\nexport * from \"./standardMaterial\";\r\nexport * from \"./Textures/index\";\r\nexport * from \"./uniformBuffer\";\r\nexport * from \"./materialFlags\";\r\nexport * from \"./Node/index\";\r\nexport * from \"./effectRenderer\";\r\nexport * from \"./shadowDepthWrapper\";\r\nexport * from \"./drawWrapper.functions\";\r\nexport * from \"./drawWrapper\";\r\nexport * from \"./materialPluginBase\";\r\nexport * from \"./materialPluginManager\";\r\nexport * from \"./materialPluginEvent\";\r\nexport * from \"./material.detailMapConfiguration\";\r\nexport * from \"./material.decalMapConfiguration\";\r\nexport * from \"./materialPluginFactoryExport\";\r\nexport * from \"./GreasedLine/greasedLinePluginMaterial\";\r\nexport * from \"./GreasedLine/greasedLineSimpleMaterial\";\r\nexport * from \"./GreasedLine/greasedLineMaterialInterfaces\";\r\nexport * from \"./GreasedLine/greasedLineMaterialDefaults\";\r\nexport * from \"./meshDebugPluginMaterial\";\r\nexport * from \"./GaussianSplatting/gaussianSplattingMaterial\";\r\nexport * from \"./materialHelper.functions\";\r\nexport * from \"./materialHelper.geometryrendering\";\r\nexport * from \"./materialStencilState\";\r\nexport * from \"./uv.defines\";\r\nexport * from \"./floatingOriginMatrixOverrides\";\r\nexport * from \"./vertexPullingHelper.functions\";\r\nimport \"./material.decalMap\";\r\n\r\n// async-loaded shaders\r\n\r\n// StandardMaterial\r\nexport * from \"../Shaders/default.fragment\";\r\nexport * from \"../Shaders/default.vertex\";\r\nexport * from \"../ShadersWGSL/default.fragment\";\r\nexport * from \"../ShadersWGSL/default.vertex\";\r\n\r\n// GreasedLineSimplMaterial\r\nexport * from \"../Shaders/greasedLine.fragment\";\r\nexport * from \"../Shaders/greasedLine.vertex\";\r\nexport * from \"../ShadersWGSL/greasedLine.fragment\";\r\nexport * from \"../ShadersWGSL/greasedLine.vertex\";\r\n"]}
@@ -111,6 +111,7 @@ export declare class ShaderMaterial extends PushMaterial {
111
111
  private _cachedWorldViewMatrix;
112
112
  private _cachedWorldViewProjectionMatrix;
113
113
  private _multiview;
114
+ private _vertexPullingMetadata;
114
115
  /**
115
116
  * @internal
116
117
  */
@@ -11,6 +11,7 @@ import { EngineStore } from "../Engines/engineStore.js";
11
11
 
12
12
  import { AddClipPlaneUniforms, BindClipPlane, PrepareStringDefinesForClipPlanes } from "./clipPlaneMaterialHelper.js";
13
13
  import { BindBonesParameters, BindFogParameters, BindLogDepth, BindMorphTargetParameters, BindSceneUniformBuffer, PrepareDefinesAndAttributesForMorphTargets, PushAttributesForInstances, } from "./materialHelper.functions.js";
14
+ import { PrepareVertexPullingUniforms, BindVertexPullingUniforms } from "./vertexPullingHelper.functions.js";
14
15
  const OnCreatedEffectParameters = { effect: null, subMesh: null };
15
16
  /**
16
17
  * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
@@ -63,6 +64,7 @@ export class ShaderMaterial extends PushMaterial {
63
64
  this._cachedWorldViewMatrix = new Matrix();
64
65
  this._cachedWorldViewProjectionMatrix = new Matrix();
65
66
  this._multiview = false;
67
+ this._vertexPullingMetadata = null;
66
68
  /**
67
69
  * @internal
68
70
  */
@@ -685,23 +687,33 @@ export class ShaderMaterial extends PushMaterial {
685
687
  uniforms.push("logarithmicDepthConstant");
686
688
  }
687
689
  }
688
- if (this.customShaderNameResolve) {
689
- uniforms = uniforms.slice();
690
- uniformBuffers = uniformBuffers.slice();
691
- samplers = samplers.slice();
692
- shaderName = this.customShaderNameResolve(this.name, uniforms, uniformBuffers, samplers, defines, attribs);
693
- }
694
690
  const renderingMesh = subMesh ? subMesh.getRenderingMesh() : mesh;
695
691
  if (renderingMesh && this.useVertexPulling) {
692
+ // Add vertex buffer metadata defines for proper stride/offset handling
693
+ const geometry = renderingMesh.geometry;
694
+ if (geometry) {
695
+ this._vertexPullingMetadata = PrepareVertexPullingUniforms(geometry);
696
+ if (this._vertexPullingMetadata) {
697
+ this._vertexPullingMetadata.forEach((_, attribute) => {
698
+ uniforms.push(`vp_${attribute}_info`);
699
+ });
700
+ }
701
+ }
696
702
  defines.push("#define USE_VERTEX_PULLING");
697
703
  const indexBuffer = renderingMesh.geometry?.getIndexBuffer();
698
- if (indexBuffer) {
704
+ if (indexBuffer && !renderingMesh.isUnIndexed) {
699
705
  defines.push("#define VERTEX_PULLING_USE_INDEX_BUFFER");
700
706
  if (indexBuffer.is32Bits) {
701
707
  defines.push("#define VERTEX_PULLING_INDEX_BUFFER_32BITS");
702
708
  }
703
709
  }
704
710
  }
711
+ if (this.customShaderNameResolve) {
712
+ uniforms = uniforms.slice();
713
+ uniformBuffers = uniformBuffers.slice();
714
+ samplers = samplers.slice();
715
+ shaderName = this.customShaderNameResolve(this.name, uniforms, uniformBuffers, samplers, defines, attribs);
716
+ }
705
717
  const drawWrapper = storeEffectOnSubMeshes ? subMesh._getDrawWrapper(undefined, true) : this._drawWrapper;
706
718
  const previousEffect = drawWrapper?.effect ?? null;
707
719
  const previousDefines = drawWrapper?.defines ?? null;
@@ -837,6 +849,9 @@ export class ShaderMaterial extends PushMaterial {
837
849
  BindBonesParameters(mesh, effect);
838
850
  // Clip plane
839
851
  BindClipPlane(effect, this, scene);
852
+ if (this._vertexPullingMetadata) {
853
+ BindVertexPullingUniforms(effect, this._vertexPullingMetadata);
854
+ }
840
855
  // Misc
841
856
  if (this._useLogarithmicDepth) {
842
857
  BindLogDepth(storeEffectOnSubMeshes ? subMesh.materialDefines : effect.defines, effect, scene);