@onerjs/core 8.36.8 → 8.37.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 (99) hide show
  1. package/Audio/analyser.js.map +1 -1
  2. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -1
  3. package/Buffers/buffer.align.js +3 -3
  4. package/Buffers/buffer.align.js.map +1 -1
  5. package/Buffers/bufferUtils.d.ts +7 -0
  6. package/Buffers/bufferUtils.js +31 -13
  7. package/Buffers/bufferUtils.js.map +1 -1
  8. package/Engines/Extensions/engine.dynamicBuffer.js +3 -3
  9. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  10. package/Engines/Native/nativeDataStream.d.ts +1 -1
  11. package/Engines/Native/nativeDataStream.js.map +1 -1
  12. package/Engines/Native/nativeInterfaces.d.ts +4 -4
  13. package/Engines/Native/nativeInterfaces.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +13 -1
  15. package/Engines/WebGPU/Extensions/engine.rawTexture.js +26 -8
  16. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  17. package/Engines/WebGPU/webgpuTextureManager.d.ts +2 -1
  18. package/Engines/WebGPU/webgpuTextureManager.js +19 -6
  19. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  20. package/Engines/abstractEngine.d.ts +4 -2
  21. package/Engines/abstractEngine.functions.d.ts +1 -1
  22. package/Engines/abstractEngine.functions.js +8 -8
  23. package/Engines/abstractEngine.functions.js.map +1 -1
  24. package/Engines/abstractEngine.js +6 -4
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/engine.d.ts +12 -0
  27. package/Engines/thinNativeEngine.js +1 -1
  28. package/Engines/thinNativeEngine.js.map +1 -1
  29. package/Engines/thinWebGPUEngine.js +3 -0
  30. package/Engines/thinWebGPUEngine.js.map +1 -1
  31. package/Engines/webgpuEngine.js +18 -18
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  34. package/Materials/Background/backgroundMaterial.d.ts +16 -8
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +14 -1
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/Blocks/Input/inputBlock.js +14 -0
  38. package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
  39. package/Materials/Node/Blocks/debugBlock.d.ts +2 -0
  40. package/Materials/Node/Blocks/debugBlock.js +6 -2
  41. package/Materials/Node/Blocks/debugBlock.js.map +1 -1
  42. package/Materials/Node/Enums/nodeMaterialSystemValues.d.ts +3 -1
  43. package/Materials/Node/Enums/nodeMaterialSystemValues.js +2 -0
  44. package/Materials/Node/Enums/nodeMaterialSystemValues.js.map +1 -1
  45. package/Materials/Node/nodeMaterial.d.ts +16 -8
  46. package/Materials/Node/nodeMaterialBlock.js +2 -2
  47. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  48. package/Materials/PBR/openpbrMaterial.d.ts +16 -8
  49. package/Materials/PBR/pbrBaseMaterial.d.ts +16 -8
  50. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.d.ts +1 -1
  51. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.js.map +1 -1
  52. package/Materials/Textures/Loaders/EXR/exrLoader.core.d.ts +1 -1
  53. package/Materials/Textures/Loaders/EXR/exrLoader.core.js.map +1 -1
  54. package/Materials/Textures/internalTexture.d.ts +6 -0
  55. package/Materials/Textures/internalTexture.js +24 -2
  56. package/Materials/Textures/internalTexture.js.map +1 -1
  57. package/Materials/Textures/rawTexture.d.ts +8 -1
  58. package/Materials/Textures/rawTexture.js +12 -3
  59. package/Materials/Textures/rawTexture.js.map +1 -1
  60. package/Materials/Textures/rawTexture2DArray.d.ts +8 -1
  61. package/Materials/Textures/rawTexture2DArray.js +14 -3
  62. package/Materials/Textures/rawTexture2DArray.js.map +1 -1
  63. package/Materials/imageProcessing.d.ts +47 -8
  64. package/Materials/standardMaterial.d.ts +16 -8
  65. package/Meshes/Builders/shapeBuilder.d.ts +4 -0
  66. package/Meshes/Builders/shapeBuilder.js +12 -9
  67. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  68. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +68 -4
  69. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +349 -30
  70. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  71. package/Meshes/geometry.js +15 -2
  72. package/Meshes/geometry.js.map +1 -1
  73. package/Meshes/mesh.js +23 -21
  74. package/Meshes/mesh.js.map +1 -1
  75. package/Misc/dds.js.map +1 -1
  76. package/Misc/environmentTextureTools.js +3 -1
  77. package/Misc/environmentTextureTools.js.map +1 -1
  78. package/Misc/fileTools.js +9 -1
  79. package/Misc/fileTools.js.map +1 -1
  80. package/Misc/sceneSerializer.d.ts +18 -0
  81. package/Misc/sceneSerializer.js +9 -0
  82. package/Misc/sceneSerializer.js.map +1 -1
  83. package/Particles/Node/nodeParticleSystemSet.helper.js +2 -2
  84. package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
  85. package/Physics/v1/physicsImpostor.d.ts +2 -2
  86. package/Physics/v1/physicsImpostor.js.map +1 -1
  87. package/Shaders/ShadersInclude/gaussianSplatting.js +16 -3
  88. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  89. package/Shaders/gaussianSplatting.vertex.js +17 -4
  90. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  91. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +11 -1
  92. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  93. package/ShadersWGSL/gaussianSplatting.vertex.js +17 -4
  94. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  95. package/XR/native/nativeXRFrame.d.ts +1 -1
  96. package/XR/native/nativeXRFrame.js.map +1 -1
  97. package/package.json +1 -1
  98. package/types.d.ts +1 -1
  99. package/types.js.map +1 -1
@@ -140,6 +140,12 @@ export class InternalTexture extends TextureSampler {
140
140
  */
141
141
  this.generateMipMaps = false;
142
142
  this._useMipMaps = null;
143
+ /**
144
+ * Gets the number of mip levels for this texture.
145
+ * Note: This property has the correct value only if the texture was created through
146
+ * `createRawTexture` or `createRawTexture2DArray`.
147
+ */
148
+ this.mipLevelCount = 1;
143
149
  /**
144
150
  * Gets the number of samples used by the texture (WebGL2+ only)
145
151
  */
@@ -332,8 +338,16 @@ export class InternalTexture extends TextureSampler {
332
338
  }, null, this._buffer, undefined, this.format, this._extension, undefined, undefined, undefined, this._useSRGBBuffer);
333
339
  return;
334
340
  case 3 /* InternalTextureSource.Raw */:
335
- proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, this._creationFlags, this._useSRGBBuffer);
341
+ proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, this._creationFlags, this._useSRGBBuffer, this.mipLevelCount);
336
342
  proxy._swapAndDie(this, false);
343
+ if (this._bufferViewArray) {
344
+ for (let mipLevel = 0; mipLevel < this._bufferViewArray.length; mipLevel++) {
345
+ const mipData = this._bufferViewArray[mipLevel];
346
+ if (mipData) {
347
+ this._engine.updateRawTexture(this, mipData, this.format, this.invertY, this._compression, this.type, this._useSRGBBuffer, mipLevel);
348
+ }
349
+ }
350
+ }
337
351
  this.isReady = true;
338
352
  break;
339
353
  case 10 /* InternalTextureSource.Raw3D */:
@@ -342,8 +356,16 @@ export class InternalTexture extends TextureSampler {
342
356
  this.isReady = true;
343
357
  break;
344
358
  case 11 /* InternalTextureSource.Raw2DArray */:
345
- proxy = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type);
359
+ proxy = this._engine.createRawTexture2DArray(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression, this.type, this._creationFlags, this.mipLevelCount);
346
360
  proxy._swapAndDie(this, false);
361
+ if (this._bufferViewArray) {
362
+ for (let mipLevel = 0; mipLevel < this._bufferViewArray.length; mipLevel++) {
363
+ const mipData = this._bufferViewArray[mipLevel];
364
+ if (mipData) {
365
+ this._engine.updateRawTexture2DArray(this, mipData, this.format, this.invertY, this._compression, this.type, mipLevel);
366
+ }
367
+ }
368
+ }
347
369
  this.isReady = true;
348
370
  break;
349
371
  case 4 /* InternalTextureSource.Dynamic */:
@@ -1 +1 @@
1
- {"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/internalTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAkB,qBA6DjB;AA7DD,WAAkB,qBAAqB;IACnC;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,+DAAG,CAAA;IACH;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,iFAAY,CAAA;IACZ;;OAEG;IACH,2FAAiB,CAAA;IACjB;;OAEG;IACH,iEAAI,CAAA;IACJ;;OAEG;IACH,uEAAO,CAAA;IACP;;OAEG;IACH,uFAAe,CAAA;IACf;;OAEG;IACH,oEAAK,CAAA;IACL;;OAEG;IACH,8EAAU,CAAA;IACV;;OAEG;IACH,kFAAY,CAAA;IACZ;;OAEG;IACH,gFAAW,CAAA;IACX;;OAEG;IACH,oEAAK,CAAA;AACT,CAAC,EA7DiB,qBAAqB,KAArB,qBAAqB,QA6DtC;AAED;;;GAGG;AACH,MAAM,OAAO,eAAgB,SAAQ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ACtC,CAAC;IACL,CAAC;;AAtUD,gBAAgB;AACF,wBAAQ,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { ImageSource, Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { IHardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport const enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @internal */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n\r\n protected override _useMipMaps: Nullable<boolean> = null;\r\n /**\r\n * Indicates to use the mip maps (if available on the texture).\r\n * Thanks to this flag, you can instruct the sampler to not sample the mipmaps even if they exist (and if the sampling mode is set to a value that normally samples the mipmaps!)\r\n * If useMipMaps is null, the value of generateMipMaps is returned by the getter (for backward compatibility)\r\n */\r\n public override get useMipMaps() {\r\n return this._useMipMaps === null ? this.generateMipMaps : this._useMipMaps;\r\n }\r\n public override set useMipMaps(value: Nullable<boolean>) {\r\n this._useMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @internal */\r\n public _invertVScale = false;\r\n /** @internal */\r\n public _associatedChannel = -1;\r\n /** @internal */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @internal */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @internal */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @internal */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @internal */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @internal */\r\n public _size: number = 0;\r\n /** @internal */\r\n public _extension: string = \"\";\r\n /** @internal */\r\n public _files: Nullable<string[]> = null;\r\n /** @internal */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @internal */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @internal */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @internal */\r\n public _isDisabled: boolean = false;\r\n /** @internal */\r\n public _compression: Nullable<string> = null;\r\n /** @internal */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @internal */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @internal */\r\n public _sphericalPolynomialComputed = false;\r\n /** @internal */\r\n public _lodGenerationScale: number = 0;\r\n /** @internal */\r\n public _lodGenerationOffset: number = 0;\r\n /** @internal */\r\n public _useSRGBBuffer: boolean = false;\r\n /** @internal */\r\n public _creationFlags: number = 0;\r\n /** @internal */\r\n public _originalFormat?: number;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @internal */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @internal */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @internal */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @internal */\r\n public _hardwareTexture: Nullable<IHardwareTextureWrapper> = null;\r\n\r\n /** @internal */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @internal */\r\n public _references: number = 1;\r\n\r\n /** @internal */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n /** @internal */\r\n public _premulAlpha = false;\r\n\r\n /** @internal */\r\n public _dynamicTextureSource: Nullable<ImageSource> = null;\r\n\r\n /** @internal */\r\n public _autoMSAAManagement = false;\r\n\r\n private _engine: AbstractEngine;\r\n private _uniqueId: number;\r\n\r\n /** @internal */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /** @internal */\r\n public _setUniqueId(id: number) {\r\n this._uniqueId = id;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): AbstractEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: AbstractEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n // Do not use Proxy here as it could be fully synchronous\r\n // and proxy would be undefined.\r\n (temp) => {\r\n temp._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n this._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n if (this._dynamicTextureSource) {\r\n this._engine.updateDynamicTexture(this, this._dynamicTextureSource, this.invertY, this._premulAlpha, this.format, true);\r\n }\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer,\r\n ArrayBuffer.isView(this._buffer) ? this._buffer : null\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray,\r\n this.width,\r\n this._originalFormat ?? this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n\r\n case InternalTextureSource.DepthStencil:\r\n case InternalTextureSource.Depth: {\r\n // Will be handled at the RenderTargetWrapper level\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.is2DArray, this.isCube, this.is3D, this.width, this.height, this.depth);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n if (this._references === 0) {\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n this._dynamicTextureSource = null;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"internalTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/internalTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAInD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAMlD;;GAEG;AACH,MAAM,CAAN,IAAkB,qBA6Dj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K,KAAK,CAAC,CAAC,EAAE,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;YACzB,IAAI,CAAC,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAC7B,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC;QACtC,CAAC;IACL,CAAC;;AA3VD,gBAAgB;AACF,wBAAQ,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import { Observable } from \"../../Misc/observable\";\r\nimport type { ImageSource, Nullable, int } from \"../../types\";\r\nimport type { ICanvas, ICanvasRenderingContext } from \"../../Engines/ICanvas\";\r\nimport type { IHardwareTextureWrapper } from \"./hardwareTextureWrapper\";\r\nimport { TextureSampler } from \"./textureSampler\";\r\n\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport type { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport type { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * Defines the source of the internal texture\r\n */\r\nexport const enum InternalTextureSource {\r\n /**\r\n * The source of the texture data is unknown\r\n */\r\n Unknown,\r\n /**\r\n * Texture data comes from an URL\r\n */\r\n Url,\r\n /**\r\n * Texture data is only used for temporary storage\r\n */\r\n Temp,\r\n /**\r\n * Texture data comes from raw data (ArrayBuffer)\r\n */\r\n Raw,\r\n /**\r\n * Texture content is dynamic (video or dynamic texture)\r\n */\r\n Dynamic,\r\n /**\r\n * Texture content is generated by rendering to it\r\n */\r\n RenderTarget,\r\n /**\r\n * Texture content is part of a multi render target process\r\n */\r\n MultiRenderTarget,\r\n /**\r\n * Texture data comes from a cube data file\r\n */\r\n Cube,\r\n /**\r\n * Texture data comes from a raw cube data\r\n */\r\n CubeRaw,\r\n /**\r\n * Texture data come from a prefiltered cube data file\r\n */\r\n CubePrefiltered,\r\n /**\r\n * Texture content is raw 3D data\r\n */\r\n Raw3D,\r\n /**\r\n * Texture content is raw 2D array data\r\n */\r\n Raw2DArray,\r\n /**\r\n * Texture content is a depth/stencil texture\r\n */\r\n DepthStencil,\r\n /**\r\n * Texture data comes from a raw cube data encoded with RGBD\r\n */\r\n CubeRawRGBD,\r\n /**\r\n * Texture content is a depth texture\r\n */\r\n Depth,\r\n}\r\n\r\n/**\r\n * Class used to store data associated with WebGL texture data for the engine\r\n * This class should not be used directly\r\n */\r\nexport class InternalTexture extends TextureSampler {\r\n /**\r\n * Defines if the texture is ready\r\n */\r\n public isReady: boolean = false;\r\n /**\r\n * Defines if the texture is a cube texture\r\n */\r\n public isCube: boolean = false;\r\n /**\r\n * Defines if the texture contains 3D data\r\n */\r\n public is3D: boolean = false;\r\n /**\r\n * Defines if the texture contains 2D array data\r\n */\r\n public is2DArray: boolean = false;\r\n /**\r\n * Defines if the texture contains multiview data\r\n */\r\n public isMultiview: boolean = false;\r\n /**\r\n * Gets the URL used to load this texture\r\n */\r\n public url: string = \"\";\r\n /** @internal */\r\n public _originalUrl: string; // not empty only if different from url\r\n /**\r\n * Gets a boolean indicating if the texture needs mipmaps generation\r\n */\r\n public generateMipMaps: boolean = false;\r\n\r\n protected override _useMipMaps: Nullable<boolean> = null;\r\n /**\r\n * Indicates to use the mip maps (if available on the texture).\r\n * Thanks to this flag, you can instruct the sampler to not sample the mipmaps even if they exist (and if the sampling mode is set to a value that normally samples the mipmaps!)\r\n * If useMipMaps is null, the value of generateMipMaps is returned by the getter (for backward compatibility)\r\n */\r\n public override get useMipMaps() {\r\n return this._useMipMaps === null ? this.generateMipMaps : this._useMipMaps;\r\n }\r\n public override set useMipMaps(value: Nullable<boolean>) {\r\n this._useMipMaps = value;\r\n }\r\n /**\r\n * Gets the number of mip levels for this texture.\r\n * Note: This property has the correct value only if the texture was created through\r\n * `createRawTexture` or `createRawTexture2DArray`.\r\n */\r\n public mipLevelCount: number = 1;\r\n /**\r\n * Gets the number of samples used by the texture (WebGL2+ only)\r\n */\r\n public samples: number = 0;\r\n /**\r\n * Gets the type of the texture (int, float...)\r\n */\r\n public type: number = -1;\r\n /**\r\n * Gets the format of the texture (RGB, RGBA...)\r\n */\r\n public format: number = -1;\r\n /**\r\n * Observable called when the texture is loaded\r\n */\r\n public onLoadedObservable = new Observable<InternalTexture>();\r\n /**\r\n * Observable called when the texture load is raising an error\r\n */\r\n public onErrorObservable = new Observable<Partial<{ message: string; exception: any }>>();\r\n /**\r\n * If this callback is defined it will be called instead of the default _rebuild function\r\n */\r\n public onRebuildCallback: Nullable<\r\n (internalTexture: InternalTexture) => {\r\n proxy: Nullable<InternalTexture | Promise<InternalTexture>>;\r\n isReady: boolean;\r\n isAsync: boolean;\r\n }\r\n > = null;\r\n /**\r\n * Gets the width of the texture\r\n */\r\n public width: number = 0;\r\n /**\r\n * Gets the height of the texture\r\n */\r\n public height: number = 0;\r\n /**\r\n * Gets the depth of the texture\r\n */\r\n public depth: number = 0;\r\n /**\r\n * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseWidth: number = 0;\r\n /**\r\n * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseHeight: number = 0;\r\n /**\r\n * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)\r\n */\r\n public baseDepth: number = 0;\r\n /**\r\n * Gets a boolean indicating if the texture is inverted on Y axis\r\n */\r\n public invertY: boolean = false;\r\n\r\n // Private\r\n /** @internal */\r\n public _invertVScale = false;\r\n /** @internal */\r\n public _associatedChannel = -1;\r\n /** @internal */\r\n public _source = InternalTextureSource.Unknown;\r\n /** @internal */\r\n public _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap> = null;\r\n /** @internal */\r\n public _bufferView: Nullable<ArrayBufferView> = null;\r\n /** @internal */\r\n public _bufferViewArray: Nullable<ArrayBufferView[]> = null;\r\n /** @internal */\r\n public _bufferViewArrayArray: Nullable<ArrayBufferView[][]> = null;\r\n /** @internal */\r\n public _size: number = 0;\r\n /** @internal */\r\n public _extension: string = \"\";\r\n /** @internal */\r\n public _files: Nullable<string[]> = null;\r\n /** @internal */\r\n public _workingCanvas: Nullable<ICanvas> = null;\r\n /** @internal */\r\n public _workingContext: Nullable<ICanvasRenderingContext> = null;\r\n /** @internal */\r\n public _cachedCoordinatesMode: Nullable<number> = null;\r\n /** @internal */\r\n public _isDisabled: boolean = false;\r\n /** @internal */\r\n public _compression: Nullable<string> = null;\r\n /** @internal */\r\n public _sphericalPolynomial: Nullable<SphericalPolynomial> = null;\r\n /** @internal */\r\n public _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>> = null;\r\n /** @internal */\r\n public _sphericalPolynomialComputed = false;\r\n /** @internal */\r\n public _lodGenerationScale: number = 0;\r\n /** @internal */\r\n public _lodGenerationOffset: number = 0;\r\n /** @internal */\r\n public _useSRGBBuffer: boolean = false;\r\n /** @internal */\r\n public _creationFlags: number = 0;\r\n /** @internal */\r\n public _originalFormat?: number;\r\n\r\n // The following three fields helps sharing generated fixed LODs for texture filtering\r\n // In environment not supporting the textureLOD extension like EDGE. They are for internal use only.\r\n // They are at the level of the gl texture to benefit from the cache.\r\n /** @internal */\r\n public _lodTextureHigh: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureMid: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _lodTextureLow: Nullable<BaseTexture> = null;\r\n /** @internal */\r\n public _isRGBD: boolean = false;\r\n\r\n /** @internal */\r\n public _linearSpecularLOD: boolean = false;\r\n /** @internal */\r\n public _irradianceTexture: Nullable<BaseTexture> = null;\r\n\r\n /** @internal */\r\n public _hardwareTexture: Nullable<IHardwareTextureWrapper> = null;\r\n\r\n /** @internal */\r\n public _maxLodLevel: Nullable<number> = null;\r\n\r\n /** @internal */\r\n public _references: number = 1;\r\n\r\n /** @internal */\r\n public _gammaSpace: Nullable<boolean> = null;\r\n\r\n /** @internal */\r\n public _premulAlpha = false;\r\n\r\n /** @internal */\r\n public _dynamicTextureSource: Nullable<ImageSource> = null;\r\n\r\n /** @internal */\r\n public _autoMSAAManagement = false;\r\n\r\n private _engine: AbstractEngine;\r\n private _uniqueId: number;\r\n\r\n /** @internal */\r\n public static _Counter = 0;\r\n\r\n /** Gets the unique id of the internal texture */\r\n public get uniqueId() {\r\n return this._uniqueId;\r\n }\r\n\r\n /** @internal */\r\n public _setUniqueId(id: number) {\r\n this._uniqueId = id;\r\n }\r\n\r\n /**\r\n * Gets the Engine the texture belongs to.\r\n * @returns The babylon engine\r\n */\r\n public getEngine(): AbstractEngine {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Gets the data source type of the texture\r\n */\r\n public get source(): InternalTextureSource {\r\n return this._source;\r\n }\r\n\r\n /**\r\n * Creates a new InternalTexture\r\n * @param engine defines the engine to use\r\n * @param source defines the type of data that will be used\r\n * @param delayAllocation if the texture allocation should be delayed (default: false)\r\n */\r\n constructor(engine: AbstractEngine, source: InternalTextureSource, delayAllocation = false) {\r\n super();\r\n\r\n this._engine = engine;\r\n this._source = source;\r\n this._uniqueId = InternalTexture._Counter++;\r\n\r\n if (!delayAllocation) {\r\n this._hardwareTexture = engine._createHardwareTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Increments the number of references (ie. the number of Texture that point to it)\r\n */\r\n public incrementReferences(): void {\r\n this._references++;\r\n }\r\n\r\n /**\r\n * Change the size of the texture (not the size of the content)\r\n * @param width defines the new width\r\n * @param height defines the new height\r\n * @param depth defines the new depth (1 by default)\r\n */\r\n public updateSize(width: int, height: int, depth: int = 1): void {\r\n this._engine.updateTextureDimensions(this, width, height, depth);\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.depth = depth;\r\n\r\n this.baseWidth = width;\r\n this.baseHeight = height;\r\n this.baseDepth = depth;\r\n\r\n this._size = width * height * depth;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n this.isReady = false;\r\n this._cachedCoordinatesMode = null;\r\n this._cachedWrapU = null;\r\n this._cachedWrapV = null;\r\n this._cachedWrapR = null;\r\n this._cachedAnisotropicFilteringLevel = null;\r\n if (this.onRebuildCallback) {\r\n const data = this.onRebuildCallback(this);\r\n const swapAndSetIsReady = (proxyInternalTexture: InternalTexture) => {\r\n proxyInternalTexture._swapAndDie(this, false);\r\n this.isReady = data.isReady;\r\n };\r\n if (data.isAsync) {\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises, github/no-then\r\n (data.proxy as Promise<InternalTexture>).then(swapAndSetIsReady);\r\n } else {\r\n swapAndSetIsReady(data.proxy as InternalTexture);\r\n }\r\n return;\r\n }\r\n\r\n let proxy: InternalTexture;\r\n switch (this.source) {\r\n case InternalTextureSource.Temp:\r\n break;\r\n\r\n case InternalTextureSource.Url:\r\n proxy = this._engine.createTexture(\r\n this._originalUrl ?? this.url,\r\n !this.generateMipMaps,\r\n this.invertY,\r\n null,\r\n this.samplingMode,\r\n // Do not use Proxy here as it could be fully synchronous\r\n // and proxy would be undefined.\r\n (temp) => {\r\n temp._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this._buffer,\r\n undefined,\r\n this.format,\r\n this._extension,\r\n undefined,\r\n undefined,\r\n undefined,\r\n this._useSRGBBuffer\r\n );\r\n return;\r\n\r\n case InternalTextureSource.Raw:\r\n proxy = this._engine.createRawTexture(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n this._creationFlags,\r\n this._useSRGBBuffer,\r\n this.mipLevelCount\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n if (this._bufferViewArray) {\r\n for (let mipLevel = 0; mipLevel < this._bufferViewArray.length; mipLevel++) {\r\n const mipData = this._bufferViewArray[mipLevel];\r\n if (mipData) {\r\n this._engine.updateRawTexture(this, mipData, this.format, this.invertY, this._compression, this.type, this._useSRGBBuffer, mipLevel);\r\n }\r\n }\r\n }\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw3D:\r\n proxy = this._engine.createRawTexture3D(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Raw2DArray:\r\n proxy = this._engine.createRawTexture2DArray(\r\n this._bufferView,\r\n this.baseWidth,\r\n this.baseHeight,\r\n this.baseDepth,\r\n this.format,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression,\r\n this.type,\r\n this._creationFlags,\r\n this.mipLevelCount\r\n );\r\n proxy._swapAndDie(this, false);\r\n\r\n if (this._bufferViewArray) {\r\n for (let mipLevel = 0; mipLevel < this._bufferViewArray.length; mipLevel++) {\r\n const mipData = this._bufferViewArray[mipLevel];\r\n if (mipData) {\r\n this._engine.updateRawTexture2DArray(this, mipData, this.format, this.invertY, this._compression, this.type, mipLevel);\r\n }\r\n }\r\n }\r\n\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.Dynamic:\r\n proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);\r\n proxy._swapAndDie(this, false);\r\n if (this._dynamicTextureSource) {\r\n this._engine.updateDynamicTexture(this, this._dynamicTextureSource, this.invertY, this._premulAlpha, this.format, true);\r\n }\r\n\r\n // The engine will make sure to update content so no need to flag it as isReady = true\r\n break;\r\n\r\n case InternalTextureSource.Cube:\r\n proxy = this._engine.createCubeTexture(\r\n this.url,\r\n null,\r\n this._files,\r\n !this.generateMipMaps,\r\n () => {\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension,\r\n false,\r\n 0,\r\n 0,\r\n null,\r\n undefined,\r\n this._useSRGBBuffer,\r\n ArrayBuffer.isView(this._buffer) ? this._buffer : null\r\n );\r\n return;\r\n\r\n case InternalTextureSource.CubeRaw:\r\n proxy = this._engine.createRawCubeTexture(\r\n this._bufferViewArray,\r\n this.width,\r\n this._originalFormat ?? this.format,\r\n this.type,\r\n this.generateMipMaps,\r\n this.invertY,\r\n this.samplingMode,\r\n this._compression\r\n );\r\n proxy._swapAndDie(this, false);\r\n this.isReady = true;\r\n break;\r\n\r\n case InternalTextureSource.CubeRawRGBD:\r\n // This case is being handeled by the environment texture tools and is not a part of the rebuild process.\r\n // To use CubeRawRGBD use updateRGBDAsync on the cube texture.\r\n return;\r\n\r\n case InternalTextureSource.CubePrefiltered:\r\n proxy = this._engine.createPrefilteredCubeTexture(\r\n this.url,\r\n null,\r\n this._lodGenerationScale,\r\n this._lodGenerationOffset,\r\n (proxy) => {\r\n if (proxy) {\r\n proxy._swapAndDie(this, false);\r\n }\r\n this.isReady = true;\r\n },\r\n null,\r\n this.format,\r\n this._extension\r\n );\r\n proxy._sphericalPolynomial = this._sphericalPolynomial;\r\n return;\r\n\r\n case InternalTextureSource.DepthStencil:\r\n case InternalTextureSource.Depth: {\r\n // Will be handled at the RenderTargetWrapper level\r\n break;\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture, swapAll = true): void {\r\n // TODO what about refcount on target?\r\n\r\n this._hardwareTexture?.setUsage(target._source, this.generateMipMaps, this.is2DArray, this.isCube, this.is3D, this.width, this.height, this.depth);\r\n\r\n target._hardwareTexture = this._hardwareTexture;\r\n if (swapAll) {\r\n target._isRGBD = this._isRGBD;\r\n }\r\n\r\n if (this._lodTextureHigh) {\r\n if (target._lodTextureHigh) {\r\n target._lodTextureHigh.dispose();\r\n }\r\n target._lodTextureHigh = this._lodTextureHigh;\r\n }\r\n\r\n if (this._lodTextureMid) {\r\n if (target._lodTextureMid) {\r\n target._lodTextureMid.dispose();\r\n }\r\n target._lodTextureMid = this._lodTextureMid;\r\n }\r\n\r\n if (this._lodTextureLow) {\r\n if (target._lodTextureLow) {\r\n target._lodTextureLow.dispose();\r\n }\r\n target._lodTextureLow = this._lodTextureLow;\r\n }\r\n\r\n if (this._irradianceTexture) {\r\n if (target._irradianceTexture) {\r\n target._irradianceTexture.dispose();\r\n }\r\n target._irradianceTexture = this._irradianceTexture;\r\n }\r\n\r\n const cache = this._engine.getLoadedTexturesCache();\r\n let index = cache.indexOf(this);\r\n if (index !== -1) {\r\n cache.splice(index, 1);\r\n }\r\n\r\n index = cache.indexOf(target);\r\n if (index === -1) {\r\n cache.push(target);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the current allocated resources\r\n */\r\n public dispose(): void {\r\n this._references--;\r\n if (this._references === 0) {\r\n this.onLoadedObservable.clear();\r\n this.onErrorObservable.clear();\r\n this._engine._releaseTexture(this);\r\n this._hardwareTexture = null;\r\n this._dynamicTextureSource = null;\r\n }\r\n }\r\n}\r\n"]}
@@ -30,17 +30,24 @@ export declare class RawTexture extends Texture {
30
30
  * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
31
31
  * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
32
32
  * @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.
33
+ * @param mipLevelCount defines the number of mip levels to allocate for the texture
33
34
  */
34
35
  constructor(data: Nullable<ArrayBufferView>, width: number, height: number,
35
36
  /**
36
37
  * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
37
38
  */
38
- format: number, sceneOrEngine: Nullable<Scene | AbstractEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number, useSRGBBuffer?: boolean, waitDataToBeReady?: boolean);
39
+ format: number, sceneOrEngine: Nullable<Scene | AbstractEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number, creationFlags?: number, useSRGBBuffer?: boolean, waitDataToBeReady?: boolean, mipLevelCount?: number);
39
40
  /**
40
41
  * Updates the texture underlying data.
41
42
  * @param data Define the new data of the texture
42
43
  */
43
44
  update(data: ArrayBufferView): void;
45
+ /**
46
+ * Updates a specific mip level of the texture.
47
+ * @param data The new data for the mip level
48
+ * @param mipLevel The mip level to update (0 is the base level)
49
+ */
50
+ updateMipLevel(data: ArrayBufferView, mipLevel: number): void;
44
51
  /**
45
52
  * Clones the texture.
46
53
  * @returns the cloned texture
@@ -23,12 +23,13 @@ export class RawTexture extends Texture {
23
23
  * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
24
24
  * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
25
25
  * @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.
26
+ * @param mipLevelCount defines the number of mip levels to allocate for the texture
26
27
  */
27
28
  constructor(data, width, height,
28
29
  /**
29
30
  * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
30
31
  */
31
- format, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags, useSRGBBuffer, waitDataToBeReady) {
32
+ format, sceneOrEngine, generateMipMaps = true, invertY = false, samplingMode = 3, type = 0, creationFlags, useSRGBBuffer, waitDataToBeReady, mipLevelCount) {
32
33
  super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);
33
34
  this.format = format;
34
35
  if (!this._engine) {
@@ -40,7 +41,7 @@ export class RawTexture extends Texture {
40
41
  if (!this._engine._caps.textureHalfFloatLinearFiltering && type === 2) {
41
42
  samplingMode = 1;
42
43
  }
43
- this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0, useSRGBBuffer ?? false);
44
+ this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0, useSRGBBuffer ?? false, mipLevelCount);
44
45
  this.wrapU = Texture.CLAMP_ADDRESSMODE;
45
46
  this.wrapV = Texture.CLAMP_ADDRESSMODE;
46
47
  this._waitingForData = !!waitDataToBeReady && !data;
@@ -50,7 +51,15 @@ export class RawTexture extends Texture {
50
51
  * @param data Define the new data of the texture
51
52
  */
52
53
  update(data) {
53
- this._getEngine().updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, this._texture._useSRGBBuffer);
54
+ this.updateMipLevel(data, 0);
55
+ }
56
+ /**
57
+ * Updates a specific mip level of the texture.
58
+ * @param data The new data for the mip level
59
+ * @param mipLevel The mip level to update (0 is the base level)
60
+ */
61
+ updateMipLevel(data, mipLevel) {
62
+ this._getEngine().updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, this._texture._useSRGBBuffer, mipLevel);
54
63
  this._waitingForData = false;
55
64
  }
56
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rawTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/rawTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAMpD;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,OAAO;IAEnC;;;;;;;;;;;;;;;;;OAiBG;IACH,YACI,IAA+B,EAC/B,KAAa,EACb,MAAc;IACd;;OAEG;IACI,MAAc,EACrB,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,SAAS,CAAC,8BAA8B,EAC/D,OAAe,SAAS,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AAC;IACvI,CAAC;IAED;;;;;;;;;;;OAWG;IACH,gEAAgE;IACzD,MAAM,CAAC,qBAAqB,CAC/B,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC/K,CAAC;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n */\r\nexport class RawTexture extends Texture {\r\n private _waitingForData: boolean;\r\n /**\r\n * Instantiates a new RawTexture.\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n * @param data define the array of data to use to create the texture (null to create an empty texture)\r\n * @param width define the width of the texture\r\n * @param height define the height of the texture\r\n * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps define whether mip maps should be generated or not\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n /**\r\n * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n */\r\n public format: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean,\r\n waitDataToBeReady?: boolean\r\n ) {\r\n super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);\r\n\r\n if (!this._engine) {\r\n return;\r\n }\r\n\r\n if (!this._engine._caps.textureFloatLinearFiltering && type === Constants.TEXTURETYPE_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n if (!this._engine._caps.textureHalfFloatLinearFiltering && type === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n this._texture = this._engine.createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type, creationFlags ?? 0, useSRGBBuffer ?? false);\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._waitingForData = !!waitDataToBeReady && !data;\r\n }\r\n\r\n /**\r\n * Updates the texture underlying data.\r\n * @param data Define the new data of the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n this._getEngine()!.updateRawTexture(this._texture, data, this._texture!.format, this._texture!.invertY, null, this._texture!.type, this._texture!._useSRGBBuffer);\r\n this._waitingForData = false;\r\n }\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): Texture {\r\n if (!this._texture) {\r\n return super.clone();\r\n }\r\n\r\n const rawTexture = new RawTexture(\r\n null,\r\n this.getSize().width,\r\n this.getSize().height,\r\n this.format,\r\n this.getScene(),\r\n this._texture.generateMipMaps,\r\n this._invertY,\r\n this.samplingMode,\r\n this._texture.type,\r\n this._texture._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n\r\n rawTexture._texture = this._texture;\r\n this._texture.incrementReferences();\r\n\r\n return rawTexture;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return super.isReady() && !this._waitingForData;\r\n }\r\n\r\n /**\r\n * Creates a luminance texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance texture\r\n */\r\n public static CreateLuminanceTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a luminance alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance alpha texture\r\n */\r\n public static CreateLuminanceAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates an alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the alpha texture\r\n */\r\n public static CreateAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a RGB texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGB alpha texture\r\n */\r\n public static CreateRGBTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGB, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @param waitDataToBeReady if set to true this will force texture to wait for data to be set before it is considered ready.\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false,\r\n waitDataToBeReady: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n creationFlags,\r\n useSRGBBuffer,\r\n waitDataToBeReady\r\n );\r\n }\r\n\r\n /**\r\n * Creates a RGBA storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBAStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n useSRGBBuffer\r\n );\r\n }\r\n\r\n /**\r\n * Creates a R texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a R storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static CreateRStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, Constants.TEXTURE_CREATIONFLAG_STORAGE);\r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C,8BAA8B,EAC/D,OAAe,SAAS,CAAC,yBAAyB,EAClD,gBAAyB,KAAK;QAE9B,OAAO,IAAI,UAAU,CACjB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,SAAS,CAAC,kBAAkB,EAC5B,aAAa,EACb,eAAe,EACf,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,SAAS,CAAC,4BAA4B,EACtC,aAAa,CAChB,CAAC;IACN,CAAC;IAED;;;;;;;;;;;OAWG;IACI,MAAM,CAAC,cAAc,CACxB,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IACvI,CAAC;IAED;;;;;;;;;;;OAWG;IACH,gEAAgE;IACzD,MAAM,CAAC,qBAAqB,CAC/B,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,aAA+C,EAC/C,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,OAAe,SAAS,CAAC,iBAAiB;QAE1C,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,4BAA4B,CAAC,CAAC;IAC/K,CAAC;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n */\r\nexport class RawTexture extends Texture {\r\n private _waitingForData: boolean;\r\n /**\r\n * Instantiates a new RawTexture.\r\n * Raw texture can help creating a texture directly from an array of data.\r\n * This can be super useful if you either get the data from an uncompressed source or\r\n * if you wish to create your texture pixel by pixel.\r\n * @param data define the array of data to use to create the texture (null to create an empty texture)\r\n * @param width define the width of the texture\r\n * @param height define the height of the texture\r\n * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps define whether mip maps should be generated or not\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @param waitDataToBeReady If set to true Rawtexture will wait data to be set in order to be flaged as ready.\r\n * @param mipLevelCount defines the number of mip levels to allocate for the texture\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n /**\r\n * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)\r\n */\r\n public format: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags?: number,\r\n useSRGBBuffer?: boolean,\r\n waitDataToBeReady?: boolean,\r\n mipLevelCount?: number\r\n ) {\r\n super(null, sceneOrEngine, !generateMipMaps, invertY, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, creationFlags);\r\n\r\n if (!this._engine) {\r\n return;\r\n }\r\n\r\n if (!this._engine._caps.textureFloatLinearFiltering && type === Constants.TEXTURETYPE_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n if (!this._engine._caps.textureHalfFloatLinearFiltering && type === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n }\r\n\r\n this._texture = this._engine.createRawTexture(\r\n data,\r\n width,\r\n height,\r\n format,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n null,\r\n type,\r\n creationFlags ?? 0,\r\n useSRGBBuffer ?? false,\r\n mipLevelCount\r\n );\r\n\r\n this.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n this.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n this._waitingForData = !!waitDataToBeReady && !data;\r\n }\r\n\r\n /**\r\n * Updates the texture underlying data.\r\n * @param data Define the new data of the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n this.updateMipLevel(data, 0);\r\n }\r\n\r\n /**\r\n * Updates a specific mip level of the texture.\r\n * @param data The new data for the mip level\r\n * @param mipLevel The mip level to update (0 is the base level)\r\n */\r\n public updateMipLevel(data: ArrayBufferView, mipLevel: number): void {\r\n this._getEngine()!.updateRawTexture(this._texture, data, this._texture!.format, this._texture!.invertY, null, this._texture!.type, this._texture!._useSRGBBuffer, mipLevel);\r\n this._waitingForData = false;\r\n }\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): Texture {\r\n if (!this._texture) {\r\n return super.clone();\r\n }\r\n\r\n const rawTexture = new RawTexture(\r\n null,\r\n this.getSize().width,\r\n this.getSize().height,\r\n this.format,\r\n this.getScene(),\r\n this._texture.generateMipMaps,\r\n this._invertY,\r\n this.samplingMode,\r\n this._texture.type,\r\n this._texture._creationFlags,\r\n this._useSRGBBuffer\r\n );\r\n\r\n rawTexture._texture = this._texture;\r\n this._texture.incrementReferences();\r\n\r\n return rawTexture;\r\n }\r\n\r\n public override isReady(): boolean {\r\n return super.isReady() && !this._waitingForData;\r\n }\r\n\r\n /**\r\n * Creates a luminance texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance texture\r\n */\r\n public static CreateLuminanceTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a luminance alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the luminance alpha texture\r\n */\r\n public static CreateLuminanceAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_LUMINANCE_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates an alpha texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @returns the alpha texture\r\n */\r\n public static CreateAlphaTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_ALPHA, sceneOrEngine, generateMipMaps, invertY, samplingMode);\r\n }\r\n\r\n /**\r\n * Creates a RGB texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGB alpha texture\r\n */\r\n public static CreateRGBTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_RGB, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, creationFlags, useSRGBBuffer);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @param waitDataToBeReady if set to true this will force texture to wait for data to be set before it is considered ready.\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false,\r\n waitDataToBeReady: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n creationFlags,\r\n useSRGBBuffer,\r\n waitDataToBeReady\r\n );\r\n }\r\n\r\n /**\r\n * Creates a RGBA storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBAStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n useSRGBBuffer: boolean = false\r\n ): RawTexture {\r\n return new RawTexture(\r\n data,\r\n width,\r\n height,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n sceneOrEngine,\r\n generateMipMaps,\r\n invertY,\r\n samplingMode,\r\n type,\r\n Constants.TEXTURE_CREATIONFLAG_STORAGE,\r\n useSRGBBuffer\r\n );\r\n }\r\n\r\n /**\r\n * Creates a R texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n public static CreateRTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n\r\n /**\r\n * Creates a R storage texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param sceneOrEngine defines the scene or engine the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the R texture\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public static CreateRStorageTexture(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n sceneOrEngine: Nullable<Scene | AbstractEngine>,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_FLOAT\r\n ): RawTexture {\r\n return new RawTexture(data, width, height, Constants.TEXTUREFORMAT_R, sceneOrEngine, generateMipMaps, invertY, samplingMode, type, Constants.TEXTURE_CREATIONFLAG_STORAGE);\r\n }\r\n}\r\n"]}
@@ -25,15 +25,22 @@ export declare class RawTexture2DArray extends Texture {
25
25
  * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
26
26
  * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
27
27
  * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
28
+ * @param mipLevelCount defines the number of mip levels to allocate for the texture
28
29
  */
29
30
  constructor(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number,
30
31
  /** Gets or sets the texture format to use */
31
- format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number, creationFlags?: number);
32
+ format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number, creationFlags?: number, mipLevelCount?: number);
32
33
  /**
33
34
  * Update the texture with new data
34
35
  * @param data defines the data to store in the texture
35
36
  */
36
37
  update(data: ArrayBufferView): void;
38
+ /**
39
+ * Updates a specific mip level of the texture.
40
+ * @param data The new data for the mip level
41
+ * @param mipLevel The mip level to update (0 is the base level)
42
+ */
43
+ updateMipLevel(data: ArrayBufferView, mipLevel: number): void;
37
44
  /**
38
45
  * Creates a RGBA texture from some data.
39
46
  * @param data Define the texture data
@@ -23,13 +23,16 @@ export class RawTexture2DArray extends Texture {
23
23
  * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
24
24
  * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
25
25
  * @param creationFlags specific flags to use when creating the texture (1 for storage textures, for eg)
26
+ * @param mipLevelCount defines the number of mip levels to allocate for the texture
26
27
  */
27
28
  constructor(data, width, height, depth,
28
29
  /** Gets or sets the texture format to use */
29
- format, scene, generateMipMaps = true, invertY = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, textureType = 0, creationFlags) {
30
+ format, scene, generateMipMaps = true, invertY = false, samplingMode = Texture.TRILINEAR_SAMPLINGMODE, textureType = 0, creationFlags, mipLevelCount) {
30
31
  super(null, scene, !generateMipMaps, invertY);
31
32
  this.format = format;
32
- this._texture = scene.getEngine().createRawTexture2DArray(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, null, textureType, creationFlags);
33
+ this._texture = scene
34
+ .getEngine()
35
+ .createRawTexture2DArray(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, null, textureType, creationFlags ?? 0, mipLevelCount);
33
36
  this._depth = depth;
34
37
  this.is2DArray = true;
35
38
  }
@@ -38,10 +41,18 @@ export class RawTexture2DArray extends Texture {
38
41
  * @param data defines the data to store in the texture
39
42
  */
40
43
  update(data) {
44
+ this.updateMipLevel(data, 0);
45
+ }
46
+ /**
47
+ * Updates a specific mip level of the texture.
48
+ * @param data The new data for the mip level
49
+ * @param mipLevel The mip level to update (0 is the base level)
50
+ */
51
+ updateMipLevel(data, mipLevel) {
41
52
  if (!this._texture) {
42
53
  return;
43
54
  }
44
- this._getEngine().updateRawTexture2DArray(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);
55
+ this._getEngine().updateRawTexture2DArray(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, mipLevel);
45
56
  }
46
57
  /**
47
58
  * Creates a RGBA texture from some data.
@@ -1 +1 @@
1
- {"version":3,"file":"rawTexture2DArray.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/rawTexture2DArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO;IAG1C;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,YACI,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,KAAa;IACb,6CAA6C;IACtC,MAAc,EACrB,KAAY,EACZ,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,WAAW,GAAG,SAAS,CAAC,yBAAyB,EACjD,aAAsB;QAEtB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QARvC,WAAM,GAAN,MAAM,CAAQ;QAUrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC,uBAAuB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,CAAC,CAAC;QAExK,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAqB;QAC/B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,OAAO;QACX,CAAC;QACD,IAAI,CAAC,UAAU,EAAG,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC3I,CAAC;IAED;;;;;;;;;;;;OAYG;IACI,MAAM,CAAC,iBAAiB,CAC3B,IAAqB,EACrB,KAAa,EACb,MAAc,EACd,KAAa,EACb,KAAY,EACZ,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,SAAS,CAAC,8BAA8B,EAC/D,OAAe,SAAS,CAAC,yBAAyB;QAElD,OAAO,IAAI,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,kBAAkB,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;IAChJ,CAAC;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Class used to store 2D array textures containing user data\r\n */\r\nexport class RawTexture2DArray extends Texture {\r\n private _depth: number;\r\n\r\n /**\r\n * Gets the number of layers of the texture\r\n */\r\n public get depth() {\r\n return this._depth;\r\n }\r\n\r\n /**\r\n * Create a new RawTexture2DArray\r\n * @param data defines the data of the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param format defines the texture format to use\r\n * @param scene defines the hosting scene\r\n * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)\r\n * @param invertY defines if texture must be stored with Y axis inverted\r\n * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n /** Gets or sets the texture format to use */\r\n public format: number,\r\n scene: Scene,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags?: number\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY);\r\n\r\n this._texture = scene.getEngine().createRawTexture2DArray(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, null, textureType, creationFlags);\r\n\r\n this._depth = depth;\r\n this.is2DArray = true;\r\n }\r\n\r\n /**\r\n * Update the texture with new data\r\n * @param data defines the data to store in the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n if (!this._texture) {\r\n return;\r\n }\r\n this._getEngine()!.updateRawTexture2DArray(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param scene defines the scene the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: ArrayBufferView,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n scene: Scene,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n ): RawTexture2DArray {\r\n return new RawTexture2DArray(data, width, height, depth, Constants.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"rawTexture2DArray.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/rawTexture2DArray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,OAAO;IAG1C;;OAEG;IACH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACH,YACI,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,KAAa;IACb,6CAA6C;IACtC,MAAc,EACrB,KAAY,EACZ,kBAA2B,IAAI,EAC/B,UAAmB,KAAK,EACxB,eAAuB,OAAO,CAAC,sBAAsB,EACrD,WAAW,GAAG,SAAS,CAAC,yBAAyB,EACjD,aAAsB,EACtB,aAAsB;QAEtB,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,eAAe,EAAE,OAAO,C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I,CAAC,CAAC;IAChJ,CAAC;CACJ","sourcesContent":["import { Texture } from \"./texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { Nullable } from \"../../types\";\r\n\r\nimport type { Scene } from \"../../scene\";\r\n\r\n/**\r\n * Class used to store 2D array textures containing user data\r\n */\r\nexport class RawTexture2DArray extends Texture {\r\n private _depth: number;\r\n\r\n /**\r\n * Gets the number of layers of the texture\r\n */\r\n public get depth() {\r\n return this._depth;\r\n }\r\n\r\n /**\r\n * Create a new RawTexture2DArray\r\n * @param data defines the data of the texture\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param format defines the texture format to use\r\n * @param scene defines the hosting scene\r\n * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)\r\n * @param invertY defines if texture must be stored with Y axis inverted\r\n * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)\r\n * @param mipLevelCount defines the number of mip levels to allocate for the texture\r\n */\r\n constructor(\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n /** Gets or sets the texture format to use */\r\n public format: number,\r\n scene: Scene,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Texture.TRILINEAR_SAMPLINGMODE,\r\n textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags?: number,\r\n mipLevelCount?: number\r\n ) {\r\n super(null, scene, !generateMipMaps, invertY);\r\n\r\n this._texture = scene\r\n .getEngine()\r\n .createRawTexture2DArray(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, null, textureType, creationFlags ?? 0, mipLevelCount);\r\n\r\n this._depth = depth;\r\n this.is2DArray = true;\r\n }\r\n\r\n /**\r\n * Update the texture with new data\r\n * @param data defines the data to store in the texture\r\n */\r\n public update(data: ArrayBufferView): void {\r\n this.updateMipLevel(data, 0);\r\n }\r\n\r\n /**\r\n * Updates a specific mip level of the texture.\r\n * @param data The new data for the mip level\r\n * @param mipLevel The mip level to update (0 is the base level)\r\n */\r\n public updateMipLevel(data: ArrayBufferView, mipLevel: number): void {\r\n if (!this._texture) {\r\n return;\r\n }\r\n this._getEngine()!.updateRawTexture2DArray(this._texture, data, this._texture.format, this._texture.invertY, null, this._texture.type, mipLevel);\r\n }\r\n\r\n /**\r\n * Creates a RGBA texture from some data.\r\n * @param data Define the texture data\r\n * @param width Define the width of the texture\r\n * @param height Define the height of the texture\r\n * @param depth defines the number of layers of the texture\r\n * @param scene defines the scene the texture will belong to\r\n * @param generateMipMaps Define whether or not to create mip maps for the texture\r\n * @param invertY define if the data should be flipped on Y when uploaded to the GPU\r\n * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)\r\n * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)\r\n * @returns the RGBA texture\r\n */\r\n public static CreateRGBATexture(\r\n data: ArrayBufferView,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n scene: Scene,\r\n generateMipMaps: boolean = true,\r\n invertY: boolean = false,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n ): RawTexture2DArray {\r\n return new RawTexture2DArray(data, width, height, depth, Constants.TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);\r\n }\r\n}\r\n"]}
@@ -17,7 +17,13 @@ export declare function ImageProcessingMixin<Tbase extends ImageProcessingMixinC
17
17
  /**
18
18
  * Gets the image processing configuration used either in this material.
19
19
  */
20
- imageProcessingConfiguration: ImageProcessingConfiguration;
20
+ get imageProcessingConfiguration(): ImageProcessingConfiguration;
21
+ /**
22
+ * Sets the Default image processing configuration used either in the this material.
23
+ *
24
+ * If sets to null, the scene one is in use.
25
+ */
26
+ set imageProcessingConfiguration(value: ImageProcessingConfiguration);
21
27
  /**
22
28
  * Keep track of the image processing observer to allow dispose and replace.
23
29
  */
@@ -30,36 +36,69 @@ export declare function ImageProcessingMixin<Tbase extends ImageProcessingMixinC
30
36
  /**
31
37
  * Gets whether the color curves effect is enabled.
32
38
  */
33
- cameraColorCurvesEnabled: boolean;
39
+ get cameraColorCurvesEnabled(): boolean;
40
+ /**
41
+ * Sets whether the color curves effect is enabled.
42
+ */
43
+ set cameraColorCurvesEnabled(value: boolean);
44
+ /**
45
+ * Gets whether the color grading effect is enabled.
46
+ */
47
+ get cameraColorGradingEnabled(): boolean;
34
48
  /**
35
49
  * Gets whether the color grading effect is enabled.
36
50
  */
37
- cameraColorGradingEnabled: boolean;
51
+ set cameraColorGradingEnabled(value: boolean);
38
52
  /**
39
53
  * Gets whether tonemapping is enabled or not.
40
54
  */
41
- cameraToneMappingEnabled: boolean;
55
+ get cameraToneMappingEnabled(): boolean;
56
+ /**
57
+ * Sets whether tonemapping is enabled or not
58
+ */
59
+ set cameraToneMappingEnabled(value: boolean);
42
60
  /**
43
61
  * The camera exposure used on this material.
44
62
  * This property is here and not in the camera to allow controlling exposure without full screen post process.
45
63
  * This corresponds to a photographic exposure.
46
64
  */
47
- cameraExposure: number;
65
+ get cameraExposure(): number;
66
+ /**
67
+ * The camera exposure used on this material.
68
+ * This property is here and not in the camera to allow controlling exposure without full screen post process.
69
+ * This corresponds to a photographic exposure.
70
+ */
71
+ set cameraExposure(value: number);
48
72
  /**
49
73
  * Gets The camera contrast used on this material.
50
74
  */
51
- cameraContrast: number;
75
+ get cameraContrast(): number;
76
+ /**
77
+ * Sets The camera contrast used on this material.
78
+ */
79
+ set cameraContrast(value: number);
52
80
  /**
53
81
  * Gets the Color Grading 2D Lookup Texture.
54
82
  */
55
- cameraColorGradingTexture: Nullable<BaseTexture>;
83
+ get cameraColorGradingTexture(): Nullable<BaseTexture>;
84
+ /**
85
+ * Sets the Color Grading 2D Lookup Texture.
86
+ */
87
+ set cameraColorGradingTexture(value: Nullable<BaseTexture>);
56
88
  /**
57
89
  * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
58
90
  * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
59
91
  * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
60
92
  * corresponding to low luminance, medium luminance, and high luminance areas respectively.
61
93
  */
62
- cameraColorCurves: Nullable<ColorCurves>;
94
+ get cameraColorCurves(): Nullable<ColorCurves>;
95
+ /**
96
+ * The color grading curves provide additional color adjustment that is applied after any color grading transform (3D LUT).
97
+ * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
98
+ * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
99
+ * corresponding to low luminance, medium luminance, and high luminance areas respectively.
100
+ */
101
+ set cameraColorCurves(value: Nullable<ColorCurves>);
63
102
  };
64
103
  } & Tbase;
65
104
  export {};
@@ -219,16 +219,24 @@ export declare class StandardMaterialDefines extends StandardMaterialDefines_bas
219
219
  declare const StandardMaterialBase_base: {
220
220
  new (...args: any[]): {
221
221
  _imageProcessingConfiguration: ImageProcessingConfiguration;
222
- imageProcessingConfiguration: ImageProcessingConfiguration;
222
+ get imageProcessingConfiguration(): ImageProcessingConfiguration;
223
+ set imageProcessingConfiguration(value: ImageProcessingConfiguration);
223
224
  _imageProcessingObserver: Nullable<import("../index.js").Observer<ImageProcessingConfiguration>>;
224
225
  _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
225
- cameraColorCurvesEnabled: boolean;
226
- cameraColorGradingEnabled: boolean;
227
- cameraToneMappingEnabled: boolean;
228
- cameraExposure: number;
229
- cameraContrast: number;
230
- cameraColorGradingTexture: Nullable<BaseTexture>;
231
- cameraColorCurves: Nullable<import("./colorCurves.js").ColorCurves>;
226
+ get cameraColorCurvesEnabled(): boolean;
227
+ set cameraColorCurvesEnabled(value: boolean);
228
+ get cameraColorGradingEnabled(): boolean;
229
+ set cameraColorGradingEnabled(value: boolean);
230
+ get cameraToneMappingEnabled(): boolean;
231
+ set cameraToneMappingEnabled(value: boolean);
232
+ get cameraExposure(): number;
233
+ set cameraExposure(value: number);
234
+ get cameraContrast(): number;
235
+ set cameraContrast(value: number);
236
+ get cameraColorGradingTexture(): Nullable<BaseTexture>;
237
+ set cameraColorGradingTexture(value: Nullable<BaseTexture>);
238
+ get cameraColorCurves(): Nullable<import("./colorCurves.js").ColorCurves>;
239
+ set cameraColorCurves(value: Nullable<import("./colorCurves.js").ColorCurves>);
232
240
  };
233
241
  } & typeof PushMaterial;
234
242
  declare class StandardMaterialBase extends StandardMaterialBase_base {