@babylonjs/core 8.12.0 → 8.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/BakedVertexAnimation/vertexAnimationBaker.d.ts +10 -2
  2. package/BakedVertexAnimation/vertexAnimationBaker.js +51 -2
  3. package/BakedVertexAnimation/vertexAnimationBaker.js.map +1 -1
  4. package/Cameras/camera.d.ts +6 -0
  5. package/Cameras/camera.js +8 -0
  6. package/Cameras/camera.js.map +1 -1
  7. package/Engines/abstractEngine.js +2 -2
  8. package/Engines/abstractEngine.js.map +1 -1
  9. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.d.ts +1 -1
  10. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js +27 -18
  11. package/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js.map +1 -1
  12. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.d.ts +55 -3
  13. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +83 -2
  14. package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
  15. package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
  16. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  17. package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
  18. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  19. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
  20. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +1 -0
  21. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +23 -2
  22. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  23. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +5 -5
  24. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  25. package/FlowGraph/Blocks/flowGraphBlockFactory.js +10 -0
  26. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  27. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +5 -0
  28. package/FlowGraph/Blocks/flowGraphBlockNames.js +5 -0
  29. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  30. package/FlowGraph/flowGraphRichTypes.js +10 -8
  31. package/FlowGraph/flowGraphRichTypes.js.map +1 -1
  32. package/FlowGraph/utils.d.ts +3 -3
  33. package/FlowGraph/utils.js +5 -4
  34. package/FlowGraph/utils.js.map +1 -1
  35. package/Instrumentation/engineInstrumentation.d.ts +2 -2
  36. package/Instrumentation/engineInstrumentation.js +5 -0
  37. package/Instrumentation/engineInstrumentation.js.map +1 -1
  38. package/Instrumentation/sceneInstrumentation.d.ts +1 -0
  39. package/Instrumentation/sceneInstrumentation.js +5 -0
  40. package/Instrumentation/sceneInstrumentation.js.map +1 -1
  41. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.d.ts +2 -5
  42. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +8 -71
  43. package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
  44. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +2 -0
  45. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +7 -8
  46. package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
  47. package/Materials/Node/Blocks/Fragment/index.d.ts +1 -0
  48. package/Materials/Node/Blocks/Fragment/index.js +1 -0
  49. package/Materials/Node/Blocks/Fragment/index.js.map +1 -1
  50. package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.d.ts +29 -0
  51. package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js +100 -0
  52. package/Materials/Node/Blocks/Fragment/smartFilterFragmentOutputBlock.js.map +1 -0
  53. package/Materials/Node/nodeMaterial.js +1 -1
  54. package/Materials/Node/nodeMaterial.js.map +1 -1
  55. package/Materials/Node/nodeMaterialBuildState.d.ts +0 -2
  56. package/Materials/Node/nodeMaterialBuildState.js +0 -2
  57. package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
  58. package/Materials/Node/nodeMaterialDefault.js +2 -1
  59. package/Materials/Node/nodeMaterialDefault.js.map +1 -1
  60. package/Maths/math.vector.d.ts +14 -0
  61. package/Maths/math.vector.functions.d.ts +25 -1
  62. package/Maths/math.vector.functions.js +35 -0
  63. package/Maths/math.vector.functions.js.map +1 -1
  64. package/Maths/math.vector.js +28 -0
  65. package/Maths/math.vector.js.map +1 -1
  66. package/Meshes/csg2.js +1 -1
  67. package/Meshes/csg2.js.map +1 -1
  68. package/Meshes/linesMesh.d.ts +2 -1
  69. package/Meshes/linesMesh.js +5 -0
  70. package/Meshes/linesMesh.js.map +1 -1
  71. package/Misc/environmentTextureTools.d.ts +4 -1
  72. package/Misc/environmentTextureTools.js +9 -2
  73. package/Misc/environmentTextureTools.js.map +1 -1
  74. package/Misc/observable.d.ts +1 -1
  75. package/Misc/observable.js.map +1 -1
  76. package/Morph/morphTargetManager.d.ts +5 -0
  77. package/Morph/morphTargetManager.js +8 -0
  78. package/Morph/morphTargetManager.js.map +1 -1
  79. package/Particles/IParticleSystem.d.ts +4 -0
  80. package/Particles/IParticleSystem.js.map +1 -1
  81. package/Particles/Node/nodeParticleSystemSet.d.ts +2 -1
  82. package/Particles/Node/nodeParticleSystemSet.js +2 -1
  83. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  84. package/Particles/baseParticleSystem.d.ts +4 -0
  85. package/Particles/baseParticleSystem.js +6 -0
  86. package/Particles/baseParticleSystem.js.map +1 -1
  87. package/Particles/particleSystem.js.map +1 -1
  88. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"environmentTextureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/environmentTextureTools.ts"],"names":[],"mappings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CAC/B,CAAC;IACN,0CAA0C;IAC1C,MAAM,YAAY,GAAG,yBAAyB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;IACxF,eAAe,CAAC,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,EAAE;QACrD,OAAO;YACH,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SAChB,CAAC;IACN,CAAC,CAAC;IACF,eAAe,CAAC,OAAO,6CAAoC,CAAC;IAC5D,eAAe,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAC7C,eAAe,CAAC,mBAAmB,GAAG,QAAQ,CAAC;IAC/C,eAAe,CAAC,oBAAoB,GAAG,SAAS,CAAC;IACjD,eAAe,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;IAE3D,0CAA0C;IAC1C,OAAO,yBAAyB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAC9D,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,OAAO,eAAe,CAAC;IAC3B,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC;;;;OAIG;IACH,UAAU;IAEV;;;;;;;OAOG;IACH,qBAAqB;IAErB;;;;;OAKG;IACH,uCAAuC;IAEvC;;;;;OAKG;IACH,yCAAyC;IAEzC;;;;;;OAMG;IACH,oBAAoB;IAEpB;;;;;;OAMG;IACH,yBAAyB;IAEzB;;;;;;OAMG;IACH,2BAA2B;IAE3B;;;;OAIG;IACH,kBAAkB;CACrB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { Tools } from \"./tools\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { ILog2 } from \"../Maths/math.scalar.functions\";\r\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { RGBDTextureTools } from \"./rgbdTextureTools\";\r\nimport { DumpDataAsync } from \"../Misc/dumpTools\";\r\nimport { ShaderLanguage } from \"core/Materials\";\r\n\r\nimport type { RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { Engine, WebGPUEngine } from \"core/Engines\";\r\n\r\nimport \"../Materials/Textures/baseTexture.polynomial\";\r\n\r\nconst DefaultEnvironmentTextureImageType = \"image/png\";\r\nconst CurrentVersion = 2;\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport type EnvironmentTextureInfo = EnvironmentTextureInfoV1 | EnvironmentTextureInfoV2;\r\n\r\n/**\r\n * v1 of EnvironmentTextureInfo\r\n */\r\ninterface EnvironmentTextureInfoV1 {\r\n /**\r\n * Version of the environment map\r\n */\r\n version: 1;\r\n\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n\r\n /**\r\n * Irradiance information stored in the file.\r\n */\r\n irradiance: Nullable<EnvironmentTextureIrradianceInfoV1>;\r\n\r\n /**\r\n * Specular information stored in the file.\r\n */\r\n specular: EnvironmentTextureSpecularInfoV1;\r\n}\r\n\r\n/**\r\n * v2 of EnvironmentTextureInfo\r\n */\r\ninterface EnvironmentTextureInfoV2 {\r\n /**\r\n * Version of the environment map\r\n */\r\n version: 2;\r\n\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n\r\n /**\r\n * Irradiance information stored in the file.\r\n */\r\n irradiance: Nullable<EnvironmentTextureIrradianceInfoV1>;\r\n\r\n /**\r\n * Specular information stored in the file.\r\n */\r\n specular: EnvironmentTextureSpecularInfoV1;\r\n\r\n /**\r\n * The mime type used to encode the image data.\r\n */\r\n imageType: string;\r\n\r\n /**\r\n * Defines where the specular Payload is located. It is a runtime value only not stored in the file.\r\n */\r\n binaryDataPosition?: number;\r\n}\r\n\r\n/**\r\n * Defines One Image in the file. It requires only the position in the file\r\n * as well as the length.\r\n */\r\ninterface BufferImageData {\r\n /**\r\n * Length of the image data.\r\n */\r\n length: number;\r\n /**\r\n * Position of the data from the null terminator delimiting the end of the JSON.\r\n */\r\n position: number;\r\n}\r\n\r\n/**\r\n * Defines the diffuse data enclosed in the file.\r\n * This corresponds to the version 1 of the data.\r\n */\r\nexport interface EnvironmentTextureIrradianceTextureInfoV1 {\r\n /**\r\n * Size of the texture faces.\r\n */\r\n size: number;\r\n /**\r\n * This contains all the images data needed to reconstruct the cubemap.\r\n */\r\n faces: Array<BufferImageData>;\r\n\r\n /**\r\n * The dominant direction of light in the environment texture.\r\n */\r\n dominantDirection?: Array<number>;\r\n}\r\n\r\n/**\r\n * Defines the specular data enclosed in the file.\r\n * This corresponds to the version 1 of the data.\r\n */\r\nexport interface EnvironmentTextureSpecularInfoV1 {\r\n /**\r\n * This contains all the images data needed to reconstruct the cubemap.\r\n */\r\n mipmaps: Array<BufferImageData>;\r\n\r\n /**\r\n * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.\r\n */\r\n lodGenerationScale: number;\r\n}\r\n\r\n/**\r\n * Defines the required storage to save the environment irradiance information.\r\n */\r\ninterface EnvironmentTextureIrradianceInfoV1 {\r\n x: Array<number>;\r\n y: Array<number>;\r\n z: Array<number>;\r\n\r\n xx: Array<number>;\r\n yy: Array<number>;\r\n zz: Array<number>;\r\n\r\n yz: Array<number>;\r\n zx: Array<number>;\r\n xy: Array<number>;\r\n\r\n irradianceTexture?: EnvironmentTextureIrradianceTextureInfoV1 | undefined;\r\n}\r\n\r\n/**\r\n * Options for creating environment textures\r\n */\r\nexport interface CreateEnvTextureOptions {\r\n /**\r\n * The mime type of encoded images.\r\n */\r\n imageType?: string;\r\n\r\n /**\r\n * the image quality of encoded WebP images.\r\n */\r\n imageQuality?: number;\r\n\r\n /**\r\n * Disables the generation of irradiance texture even if present on the source.\r\n */\r\n disableIrradianceTexture?: boolean;\r\n}\r\n\r\n/**\r\n * Magic number identifying the env file.\r\n */\r\nconst MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n/**\r\n * Gets the environment info from an env file.\r\n * @param data The array buffer containing the .env bytes.\r\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\r\n */\r\nexport function GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfoV2> {\r\n const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < MagicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== MagicBytes[i]) {\r\n Logger.Error(\"Not a babylon environment map\");\r\n return null;\r\n }\r\n }\r\n\r\n // Read json manifest - collect characters up to null terminator\r\n let manifestString = \"\";\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n manifestString += String.fromCharCode(charCode);\r\n }\r\n\r\n let manifest: EnvironmentTextureInfo = JSON.parse(manifestString);\r\n manifest = normalizeEnvInfo(manifest);\r\n // Extend the header with the position of the payload.\r\n manifest.binaryDataPosition = pos;\r\n\r\n if (manifest.specular) {\r\n // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.\r\n manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;\r\n }\r\n\r\n return manifest;\r\n}\r\n\r\n/**\r\n * Normalizes any supported version of the environment file info to the latest version\r\n * @param info environment file info on any supported version\r\n * @returns environment file info in the latest supported version\r\n * @private\r\n */\r\nexport function normalizeEnvInfo(info: EnvironmentTextureInfo): EnvironmentTextureInfoV2 {\r\n if (info.version > CurrentVersion) {\r\n throw new Error(`Unsupported babylon environment map version \"${info.version}\". Latest supported version is \"${CurrentVersion}\".`);\r\n }\r\n\r\n if (info.version === 2) {\r\n return info;\r\n }\r\n\r\n // Migrate a v1 info to v2\r\n info = { ...info, version: 2, imageType: DefaultEnvironmentTextureImageType };\r\n\r\n return info;\r\n}\r\n\r\n/**\r\n * Creates an environment texture from a loaded cube texture.\r\n * @param texture defines the cube texture to convert in env file\r\n * @param options options for the conversion process\r\n * @returns a promise containing the environment data if successful.\r\n */\r\nexport async function CreateEnvTextureAsync(texture: BaseTexture, options: CreateEnvTextureOptions = {}): Promise<ArrayBuffer> {\r\n const internalTexture = texture.getInternalTexture();\r\n if (!internalTexture) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"The cube texture is invalid.\");\r\n }\r\n\r\n const engine = internalTexture.getEngine();\r\n\r\n if (\r\n texture.textureType !== Constants.TEXTURETYPE_HALF_FLOAT &&\r\n texture.textureType !== Constants.TEXTURETYPE_FLOAT &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_BYTE &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_BYTE &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_INTEGER &&\r\n texture.textureType !== -1\r\n ) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"The cube texture should allow HDR (Full Float or Half Float).\");\r\n }\r\n\r\n let textureType = Constants.TEXTURETYPE_FLOAT;\r\n if (!engine.getCaps().textureFloatRender) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n if (!engine.getCaps().textureHalfFloatRender) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"Env texture can only be created when the browser supports half float or full float rendering.\");\r\n }\r\n }\r\n\r\n // sphericalPolynomial is lazy loaded so simply accessing it should trigger the computation.\r\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\r\n texture.sphericalPolynomial;\r\n\r\n // Lets keep track of the polynomial promise so we can wait for it to be ready before generating the pixels.\r\n const sphericalPolynomialPromise = texture.getInternalTexture()?._sphericalPolynomialPromise;\r\n\r\n const cubeWidth = internalTexture.width;\r\n const hostingScene = new Scene(engine);\r\n const specularTextures: { [key: number]: ArrayBuffer } = {};\r\n const diffuseTextures: { [key: number]: ArrayBuffer } = {};\r\n\r\n // As we are going to readPixels the faces of the cube, make sure the drawing/update commands for the cube texture are fully sent to the GPU in case it is drawn for the first time in this very frame!\r\n engine.flushFramebuffer();\r\n\r\n const imageType = options.imageType ?? DefaultEnvironmentTextureImageType;\r\n\r\n // Read and collect all mipmaps data from the cube.\r\n const mipmapsCount = ILog2(internalTexture.width);\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n const faceWidth = Math.pow(2, mipmapsCount - i);\r\n\r\n // All faces of the cube.\r\n for (let face = 0; face < 6; face++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n specularTextures[i * 6 + face] = await _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, faceWidth, imageType, options.imageQuality);\r\n }\r\n }\r\n\r\n // Read and collect all irradiance data from the cube.\r\n const irradianceTexture = options.disableIrradianceTexture ? null : texture.irradianceTexture;\r\n if (irradianceTexture) {\r\n const faceWidth = irradianceTexture.getSize().width;\r\n\r\n // All faces of the cube.\r\n for (let face = 0; face < 6; face++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n diffuseTextures[face] = await _GetTextureEncodedDataAsync(hostingScene, irradianceTexture, textureType, face, 0, faceWidth, imageType, options.imageQuality);\r\n }\r\n }\r\n\r\n // We can delete the hosting scene keeping track of all the creation objects\r\n hostingScene.dispose();\r\n\r\n // Ensure completion of the polynomial creation promise.\r\n if (sphericalPolynomialPromise) {\r\n await sphericalPolynomialPromise;\r\n }\r\n\r\n // Creates the json header for the env texture\r\n const info: EnvironmentTextureInfo = {\r\n version: CurrentVersion,\r\n width: cubeWidth,\r\n imageType,\r\n irradiance: CreateEnvTextureIrradiance(texture),\r\n specular: {\r\n mipmaps: [],\r\n lodGenerationScale: texture.lodGenerationScale,\r\n },\r\n };\r\n\r\n // Sets the specular image data information\r\n let position = 0;\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n const byteLength = specularTextures[i * 6 + face].byteLength;\r\n info.specular.mipmaps.push({\r\n length: byteLength,\r\n position: position,\r\n });\r\n position += byteLength;\r\n }\r\n }\r\n\r\n // Sets the irradiance image data information\r\n if (irradianceTexture) {\r\n info.irradiance = info.irradiance || {\r\n x: [0, 0, 0],\r\n xx: [0, 0, 0],\r\n y: [0, 0, 0],\r\n yy: [0, 0, 0],\r\n z: [0, 0, 0],\r\n zz: [0, 0, 0],\r\n yz: [0, 0, 0],\r\n zx: [0, 0, 0],\r\n xy: [0, 0, 0],\r\n };\r\n info.irradiance.irradianceTexture = {\r\n size: irradianceTexture.getSize().width,\r\n faces: [],\r\n dominantDirection: irradianceTexture._dominantDirection?.asArray(),\r\n };\r\n\r\n for (let face = 0; face < 6; face++) {\r\n const byteLength = diffuseTextures[face].byteLength;\r\n info.irradiance.irradianceTexture.faces.push({\r\n length: byteLength,\r\n position: position,\r\n });\r\n position += byteLength;\r\n }\r\n }\r\n\r\n // Encode the JSON as an array buffer\r\n const infoString = JSON.stringify(info);\r\n const infoBuffer = new ArrayBuffer(infoString.length + 1);\r\n const infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.\r\n for (let i = 0, strLen = infoString.length; i < strLen; i++) {\r\n infoView[i] = infoString.charCodeAt(i);\r\n }\r\n // Ends up with a null terminator for easier parsing\r\n infoView[infoString.length] = 0x00;\r\n\r\n // Computes the final required size and creates the storage\r\n const totalSize = MagicBytes.length + position + infoBuffer.byteLength;\r\n const finalBuffer = new ArrayBuffer(totalSize);\r\n const finalBufferView = new Uint8Array(finalBuffer);\r\n const dataView = new DataView(finalBuffer);\r\n\r\n // Copy the magic bytes identifying the file in\r\n let pos = 0;\r\n for (let i = 0; i < MagicBytes.length; i++) {\r\n dataView.setUint8(pos++, MagicBytes[i]);\r\n }\r\n\r\n // Add the json info\r\n finalBufferView.set(new Uint8Array(infoBuffer), pos);\r\n pos += infoBuffer.byteLength;\r\n\r\n // Finally inserts the radiance texture data\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n const dataBuffer = specularTextures[i * 6 + face];\r\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\r\n pos += dataBuffer.byteLength;\r\n }\r\n }\r\n\r\n // Finally inserts the irradiance texture data\r\n if (irradianceTexture) {\r\n for (let face = 0; face < 6; face++) {\r\n const dataBuffer = diffuseTextures[face];\r\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\r\n pos += dataBuffer.byteLength;\r\n }\r\n }\r\n\r\n // Voila\r\n return finalBuffer;\r\n}\r\n\r\n/**\r\n * Get the texture encoded data from the current texture\r\n * @internal\r\n */\r\nasync function _GetTextureEncodedDataAsync(\r\n hostingScene: Scene,\r\n texture: BaseTexture,\r\n textureType: number,\r\n face: number,\r\n i: number,\r\n size: number,\r\n imageType: string,\r\n imageQuality?: number\r\n) {\r\n let faceData = await texture.readPixels(face, i, undefined, false);\r\n if (faceData && faceData.byteLength === (faceData as Uint8Array).length) {\r\n const faceDataFloat = new Float32Array(faceData.byteLength * 4);\r\n for (let i = 0; i < faceData.byteLength; i++) {\r\n faceDataFloat[i] = (faceData as Uint8Array)[i] / 255;\r\n // Gamma to linear\r\n faceDataFloat[i] = Math.pow(faceDataFloat[i], 2.2);\r\n }\r\n faceData = faceDataFloat;\r\n } else if (faceData && texture.gammaSpace) {\r\n const floatData = faceData as Float32Array;\r\n for (let i = 0; i < floatData.length; i++) {\r\n // Gamma to linear\r\n floatData[i] = Math.pow(floatData[i], 2.2);\r\n }\r\n }\r\n\r\n const engine = hostingScene.getEngine();\r\n const tempTexture = engine.createRawTexture(faceData, size, size, Constants.TEXTUREFORMAT_RGBA, false, true, Constants.TEXTURE_NEAREST_SAMPLINGMODE, null, textureType);\r\n\r\n await RGBDTextureTools.EncodeTextureToRGBD(tempTexture, hostingScene, textureType);\r\n\r\n const rgbdEncodedData = await engine._readTexturePixels(tempTexture, size, size);\r\n\r\n const imageEncodedData = await DumpDataAsync(size, size, rgbdEncodedData, imageType, undefined, false, true, imageQuality);\r\n\r\n tempTexture.dispose();\r\n\r\n return imageEncodedData as ArrayBuffer;\r\n}\r\n\r\n/**\r\n * Creates a JSON representation of the spherical data.\r\n * @param texture defines the texture containing the polynomials\r\n * @returns the JSON representation of the spherical info\r\n */\r\nfunction CreateEnvTextureIrradiance(texture: BaseTexture): Nullable<EnvironmentTextureIrradianceInfoV1> {\r\n const polynmials = texture.sphericalPolynomial;\r\n if (polynmials == null) {\r\n return null;\r\n }\r\n\r\n return {\r\n x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],\r\n y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],\r\n z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],\r\n\r\n xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],\r\n yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],\r\n zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],\r\n\r\n yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],\r\n zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],\r\n xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z],\r\n };\r\n}\r\n\r\n/**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\nexport function CreateRadianceImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const specularInfo = info.specular;\r\n\r\n // Double checks the enclosed info\r\n let mipmapsCount = Math.log2(info.width);\r\n mipmapsCount = Math.round(mipmapsCount) + 1;\r\n if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {\r\n throw new Error(`Unsupported specular mipmaps number \"${specularInfo.mipmaps.length}\"`);\r\n }\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(mipmapsCount);\r\n for (let i = 0; i < mipmapsCount; i++) {\r\n imageData[i] = new Array<ArrayBufferView>(6);\r\n for (let face = 0; face < 6; face++) {\r\n const imageInfo = specularInfo.mipmaps[i * 6 + face];\r\n imageData[i][face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition! + imageInfo.position, imageInfo.length);\r\n }\r\n }\r\n\r\n return imageData;\r\n}\r\n\r\n/**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\nexport function CreateIrradianceImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<ArrayBufferView> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const imageData = new Array<ArrayBufferView>(6);\r\n\r\n const irradianceTexture = info.irradiance?.irradianceTexture;\r\n if (irradianceTexture) {\r\n if (irradianceTexture.faces.length !== 6) {\r\n throw new Error(`Incorrect irradiance texture faces number \"${irradianceTexture.faces.length}\"`);\r\n }\r\n\r\n for (let face = 0; face < 6; face++) {\r\n const imageInfo = irradianceTexture.faces[face];\r\n imageData[face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition! + imageInfo.position, imageInfo.length);\r\n }\r\n }\r\n\r\n return imageData;\r\n}\r\n\r\n/**\r\n * Uploads the texture info contained in the env file to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param data defines the data to load\r\n * @param info defines the texture info retrieved through the GetEnvInfo method\r\n * @returns a promise\r\n */\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\nexport function UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void[]> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const specularInfo = info.specular;\r\n if (!specularInfo) {\r\n // Nothing else parsed so far\r\n return Promise.resolve([]);\r\n }\r\n\r\n texture._lodGenerationScale = specularInfo.lodGenerationScale;\r\n\r\n const promises: Promise<void>[] = [];\r\n\r\n const radianceImageData = CreateRadianceImageDataArrayBufferViews(data, info);\r\n promises.push(UploadRadianceLevelsAsync(texture, radianceImageData, info.imageType));\r\n\r\n const irradianceTexture = info.irradiance?.irradianceTexture;\r\n if (irradianceTexture) {\r\n const irradianceImageData = CreateIrradianceImageDataArrayBufferViews(data, info);\r\n promises.push(UploadIrradianceLevelsAsync(texture, irradianceImageData, irradianceTexture.size, info.imageType));\r\n }\r\n\r\n return Promise.all(promises);\r\n}\r\n\r\nasync function _OnImageReadyAsync(\r\n image: HTMLImageElement | ImageBitmap,\r\n engine: Engine | WebGPUEngine,\r\n expandTexture: boolean,\r\n rgbdPostProcess: Nullable<PostProcess>,\r\n url: string,\r\n face: number,\r\n i: number,\r\n generateNonLODTextures: boolean,\r\n lodTextures: Nullable<{ [lod: number]: BaseTexture }>,\r\n cubeRtt: Nullable<RenderTargetWrapper>,\r\n texture: InternalTexture\r\n): Promise<void> {\r\n return await new Promise((resolve, reject) => {\r\n if (expandTexture) {\r\n const tempTexture = engine.createTexture(\r\n null,\r\n true,\r\n true,\r\n null,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n null,\r\n (message) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(message);\r\n },\r\n image\r\n );\r\n\r\n rgbdPostProcess?.onEffectCreatedObservable.addOnce((effect) => {\r\n effect.executeWhenCompiled(() => {\r\n // Uncompress the data to a RTT\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", tempTexture);\r\n effect.setFloat2(\"scale\", 1, engine._features.needsInvertingBitmap && image instanceof ImageBitmap ? -1 : 1);\r\n };\r\n\r\n if (!engine.scenes.length) {\r\n return;\r\n }\r\n\r\n engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n tempTexture.dispose();\r\n URL.revokeObjectURL(url);\r\n resolve();\r\n });\r\n });\r\n } else {\r\n engine._uploadImageToTexture(texture, image, face, i);\r\n\r\n // Upload the face to the non lod texture support\r\n if (generateNonLODTextures) {\r\n const lodTexture = lodTextures![i];\r\n if (lodTexture) {\r\n engine._uploadImageToTexture(lodTexture._texture!, image, face, 0);\r\n }\r\n }\r\n resolve();\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\nexport async function UploadRadianceLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][], imageType: string = DefaultEnvironmentTextureImageType): Promise<void> {\r\n const engine = texture.getEngine() as Engine;\r\n texture.format = Constants.TEXTUREFORMAT_RGBA;\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n texture.generateMipMaps = true;\r\n texture._cachedAnisotropicFilteringLevel = null;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, texture);\r\n\r\n await _UploadLevelsAsync(texture, imageData, true, imageType);\r\n\r\n // Flag internal texture as ready in case they are in use.\r\n texture.isReady = true;\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param mainTexture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param size defines the size of the texture faces\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\nexport async function UploadIrradianceLevelsAsync(\r\n mainTexture: InternalTexture,\r\n imageData: ArrayBufferView[],\r\n size: number,\r\n imageType: string = DefaultEnvironmentTextureImageType\r\n): Promise<void> {\r\n // Gets everything ready.\r\n const engine = mainTexture.getEngine() as Engine;\r\n const texture = new InternalTexture(engine, InternalTextureSource.RenderTarget);\r\n const baseTexture = new BaseTexture(engine, texture);\r\n mainTexture._irradianceTexture = baseTexture;\r\n\r\n texture.isCube = true;\r\n texture.format = Constants.TEXTUREFORMAT_RGBA;\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n texture.generateMipMaps = true;\r\n texture._cachedAnisotropicFilteringLevel = null;\r\n texture.generateMipMaps = true;\r\n texture.width = size;\r\n texture.height = size;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, texture);\r\n\r\n await _UploadLevelsAsync(texture, [imageData], false, imageType);\r\n\r\n engine.generateMipMapsForCubemap(texture);\r\n\r\n // Flag internal texture as ready in case they are in use.\r\n texture.isReady = true;\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param canGenerateNonLODTextures defines whether or not to generate non lod textures\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\nasync function _UploadLevelsAsync(\r\n texture: InternalTexture,\r\n imageData: ArrayBufferView[][],\r\n canGenerateNonLODTextures: boolean,\r\n imageType: string = DefaultEnvironmentTextureImageType\r\n) {\r\n if (!Tools.IsExponentOfTwo(texture.width)) {\r\n throw new Error(\"Texture size must be a power of two\");\r\n }\r\n\r\n const mipmapsCount = ILog2(texture.width) + 1;\r\n\r\n // Gets everything ready.\r\n const engine = texture.getEngine() as Engine;\r\n let expandTexture = false;\r\n let generateNonLODTextures = false;\r\n let rgbdPostProcess: Nullable<PostProcess> = null;\r\n let cubeRtt: Nullable<RenderTargetWrapper> = null;\r\n let lodTextures: Nullable<{ [lod: number]: BaseTexture }> = null;\r\n const caps = engine.getCaps();\r\n\r\n if (!caps.textureLOD) {\r\n expandTexture = false;\r\n generateNonLODTextures = canGenerateNonLODTextures;\r\n } else if (!engine._features.supportRenderAndCopyToLodForFloatTextures) {\r\n expandTexture = false;\r\n }\r\n // If half float available we can uncompress the texture\r\n else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n texture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n texture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n // Expand the texture if possible\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n if (expandTexture) {\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n await import(\"../ShadersWGSL/rgbdDecode.fragment\");\r\n } else {\r\n await import(\"../Shaders/rgbdDecode.fragment\");\r\n }\r\n\r\n // Simply run through the decode PP\r\n rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n texture.type,\r\n undefined,\r\n null,\r\n false,\r\n undefined,\r\n shaderLanguage\r\n );\r\n\r\n texture._isRGBD = false;\r\n texture.invertY = false;\r\n cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n generateStencilBuffer: false,\r\n samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: texture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n } else {\r\n texture._isRGBD = true;\r\n texture.invertY = true;\r\n\r\n // In case of missing support, applies the same patch than DDS files.\r\n if (generateNonLODTextures) {\r\n const mipSlices = 3;\r\n lodTextures = {};\r\n const scale = texture._lodGenerationScale;\r\n const offset = texture._lodGenerationOffset;\r\n\r\n for (let i = 0; i < mipSlices; i++) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n\r\n const minLODIndex = offset; // roughness = 0\r\n const maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)\r\n\r\n const lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;\r\n const mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));\r\n\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const glTextureFromLod = new InternalTexture(engine, InternalTextureSource.Temp);\r\n glTextureFromLod.isCube = true;\r\n glTextureFromLod.invertY = true;\r\n glTextureFromLod.generateMipMaps = false;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_LINEAR_LINEAR, glTextureFromLod);\r\n\r\n // Wrap in a base texture for easy binding.\r\n const lodTexture = new BaseTexture(null);\r\n lodTexture._isCube = true;\r\n lodTexture._texture = glTextureFromLod;\r\n lodTextures[mipmapIndex] = lodTexture;\r\n\r\n switch (i) {\r\n case 0:\r\n texture._lodTextureLow = lodTexture;\r\n break;\r\n case 1:\r\n texture._lodTextureMid = lodTexture;\r\n break;\r\n case 2:\r\n texture._lodTextureHigh = lodTexture;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n const promises: Promise<void>[] = [];\r\n // All mipmaps up to provided number of images\r\n for (let i = 0; i < imageData.length; i++) {\r\n // All faces\r\n for (let face = 0; face < 6; face++) {\r\n // Constructs an image element from image data\r\n const bytes = imageData[i][face];\r\n const blob = new Blob([bytes], { type: imageType });\r\n const url = URL.createObjectURL(blob);\r\n let promise: Promise<void>;\r\n\r\n if (engine._features.forceBitmapOverHTMLImageElement) {\r\n // eslint-disable-next-line github/no-then\r\n promise = engine.createImageBitmap(blob, { premultiplyAlpha: \"none\" }).then(async (img) => {\r\n return await _OnImageReadyAsync(img, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture);\r\n });\r\n } else {\r\n const image = new Image();\r\n image.src = url;\r\n\r\n // Enqueue promise to upload to the texture.\r\n promise = new Promise<void>((resolve, reject) => {\r\n image.onload = () => {\r\n _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture)\r\n // eslint-disable-next-line github/no-then\r\n .then(() => resolve())\r\n // eslint-disable-next-line github/no-then\r\n .catch((reason) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(reason);\r\n });\r\n };\r\n image.onerror = (error) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(error);\r\n };\r\n });\r\n }\r\n promises.push(promise);\r\n }\r\n }\r\n\r\n await Promise.all(promises);\r\n\r\n // Fill remaining mipmaps with black textures.\r\n if (imageData.length < mipmapsCount) {\r\n let data: ArrayBufferView;\r\n const size = Math.pow(2, mipmapsCount - 1 - imageData.length);\r\n const dataLength = size * size * 4;\r\n switch (texture.type) {\r\n case Constants.TEXTURETYPE_UNSIGNED_BYTE: {\r\n data = new Uint8Array(dataLength);\r\n break;\r\n }\r\n case Constants.TEXTURETYPE_HALF_FLOAT: {\r\n data = new Uint16Array(dataLength);\r\n break;\r\n }\r\n case Constants.TEXTURETYPE_FLOAT: {\r\n data = new Float32Array(dataLength);\r\n break;\r\n }\r\n }\r\n for (let i = imageData.length; i < mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n engine._uploadArrayBufferViewToTexture(cubeRtt?.texture || texture, data!, face, i);\r\n }\r\n }\r\n }\r\n\r\n // Release temp RTT.\r\n if (cubeRtt) {\r\n const irradiance = texture._irradianceTexture;\r\n texture._irradianceTexture = null;\r\n engine._releaseTexture(texture);\r\n cubeRtt._swapAndDie(texture);\r\n texture._irradianceTexture = irradiance;\r\n }\r\n // Release temp Post Process.\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n // Flag internal texture as ready in case they are in use.\r\n if (generateNonLODTextures) {\r\n if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {\r\n texture._lodTextureHigh._texture.isReady = true;\r\n }\r\n if (texture._lodTextureMid && texture._lodTextureMid._texture) {\r\n texture._lodTextureMid._texture.isReady = true;\r\n }\r\n if (texture._lodTextureLow && texture._lodTextureLow._texture) {\r\n texture._lodTextureLow._texture.isReady = true;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Uploads spherical polynomials information to the texture.\r\n * @param texture defines the texture we are trying to upload the information to\r\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\r\n */\r\nexport function UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void {\r\n info = normalizeEnvInfo(info);\r\n\r\n const irradianceInfo = info.irradiance as EnvironmentTextureIrradianceInfoV1;\r\n if (!irradianceInfo) {\r\n return;\r\n }\r\n\r\n const sp = new SphericalPolynomial();\r\n Vector3.FromArrayToRef(irradianceInfo.x, 0, sp.x);\r\n Vector3.FromArrayToRef(irradianceInfo.y, 0, sp.y);\r\n Vector3.FromArrayToRef(irradianceInfo.z, 0, sp.z);\r\n Vector3.FromArrayToRef(irradianceInfo.xx, 0, sp.xx);\r\n Vector3.FromArrayToRef(irradianceInfo.yy, 0, sp.yy);\r\n Vector3.FromArrayToRef(irradianceInfo.zz, 0, sp.zz);\r\n Vector3.FromArrayToRef(irradianceInfo.yz, 0, sp.yz);\r\n Vector3.FromArrayToRef(irradianceInfo.zx, 0, sp.zx);\r\n Vector3.FromArrayToRef(irradianceInfo.xy, 0, sp.xy);\r\n texture._sphericalPolynomial = sp;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\nexport function _UpdateRGBDAsync(\r\n internalTexture: InternalTexture,\r\n data: ArrayBufferView[][],\r\n sphericalPolynomial: Nullable<SphericalPolynomial>,\r\n lodScale: number,\r\n lodOffset: number\r\n): Promise<InternalTexture> {\r\n const proxy = internalTexture\r\n .getEngine()\r\n .createRawCubeTexture(\r\n null,\r\n internalTexture.width,\r\n internalTexture.format,\r\n internalTexture.type,\r\n internalTexture.generateMipMaps,\r\n internalTexture.invertY,\r\n internalTexture.samplingMode,\r\n internalTexture._compression\r\n );\r\n // eslint-disable-next-line github/no-then\r\n const proxyPromise = UploadRadianceLevelsAsync(proxy, data).then(() => internalTexture);\r\n internalTexture.onRebuildCallback = (_internalTexture) => {\r\n return {\r\n proxy: proxyPromise,\r\n isReady: true,\r\n isAsync: true,\r\n };\r\n };\r\n internalTexture._source = InternalTextureSource.CubeRawRGBD;\r\n internalTexture._bufferViewArrayArray = data;\r\n internalTexture._lodGenerationScale = lodScale;\r\n internalTexture._lodGenerationOffset = lodOffset;\r\n internalTexture._sphericalPolynomial = sphericalPolynomial;\r\n\r\n // eslint-disable-next-line github/no-then\r\n return UploadRadianceLevelsAsync(internalTexture, data).then(() => {\r\n internalTexture.isReady = true;\r\n return internalTexture;\r\n });\r\n}\r\n\r\n/**\r\n * Sets of helpers addressing the serialization and deserialization of environment texture\r\n * stored in a BabylonJS env file.\r\n * Those files are usually stored as .env files.\r\n */\r\nexport const EnvironmentTextureTools = {\r\n /**\r\n * Gets the environment info from an env file.\r\n * @param data The array buffer containing the .env bytes.\r\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\r\n */\r\n GetEnvInfo,\r\n\r\n /**\r\n * Creates an environment texture from a loaded cube texture.\r\n * @param texture defines the cube texture to convert in env file\r\n * @param options options for the conversion process\r\n * @param options.imageType the mime type for the encoded images, with support for \"image/png\" (default) and \"image/webp\"\r\n * @param options.imageQuality the image quality of encoded WebP images.\r\n * @returns a promise containing the environment data if successful.\r\n */\r\n CreateEnvTextureAsync,\r\n\r\n /**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\n CreateRadianceImageDataArrayBufferViews,\r\n\r\n /**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\n CreateIrradianceImageDataArrayBufferViews,\r\n\r\n /**\r\n * Uploads the texture info contained in the env file to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param data defines the data to load\r\n * @param info defines the texture info retrieved through the GetEnvInfo method\r\n * @returns a promise\r\n */\r\n UploadEnvLevelsAsync,\r\n\r\n /**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\n UploadRadianceLevelsAsync,\r\n\r\n /**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\n UploadIrradianceLevelsAsync,\r\n\r\n /**\r\n * Uploads spherical polynomials information to the texture.\r\n * @param texture defines the texture we are trying to upload the information to\r\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\r\n */\r\n UploadEnvSpherical,\r\n};\r\n"]}
1
+ {"version":3,"file":"environmentTextureTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/environmentTextureTools.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAyB,MAAM,uCAAuC,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,E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C,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,CAAC;IACxF,eAAe,CAAC,iBAAiB,GAAG,CAAC,gBAAgB,EAAE,EAAE;QACrD,OAAO;YACH,KAAK,EAAE,YAAY;YACnB,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SAChB,CAAC;IACN,CAAC,CAAC;IACF,eAAe,CAAC,OAAO,6CAAoC,CAAC;IAC5D,eAAe,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAC7C,eAAe,CAAC,mBAAmB,GAAG,QAAQ,CAAC;IAC/C,eAAe,CAAC,oBAAoB,GAAG,SAAS,CAAC;IACjD,eAAe,CAAC,oBAAoB,GAAG,mBAAmB,CAAC;IAE3D,0CAA0C;IAC1C,OAAO,yBAAyB,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QAC9D,eAAe,CAAC,OAAO,GAAG,IAAI,CAAC;QAC/B,OAAO,eAAe,CAAC;IAC3B,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACnC;;;;OAIG;IACH,UAAU;IAEV;;;;;;;OAOG;IACH,qBAAqB;IAErB;;;;;OAKG;IACH,uCAAuC;IAEvC;;;;;OAKG;IACH,yCAAyC;IAEzC;;;;;;OAMG;IACH,oBAAoB;IAEpB;;;;;;OAMG;IACH,yBAAyB;IAEzB;;;;;;;OAOG;IACH,2BAA2B;IAE3B;;;;OAIG;IACH,kBAAkB;CACrB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"../types\";\r\nimport { Tools } from \"./tools\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { ILog2 } from \"../Maths/math.scalar.functions\";\r\nimport { SphericalPolynomial } from \"../Maths/sphericalPolynomial\";\r\nimport { InternalTexture, InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Constants } from \"../Engines/constants\";\r\nimport { Scene } from \"../scene\";\r\nimport { PostProcess } from \"../PostProcesses/postProcess\";\r\nimport { Logger } from \"../Misc/logger\";\r\nimport { RGBDTextureTools } from \"./rgbdTextureTools\";\r\nimport { DumpDataAsync } from \"../Misc/dumpTools\";\r\nimport { ShaderLanguage } from \"core/Materials\";\r\n\r\nimport type { RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { Engine, WebGPUEngine } from \"core/Engines\";\r\n\r\nimport \"../Materials/Textures/baseTexture.polynomial\";\r\n\r\nconst DefaultEnvironmentTextureImageType = \"image/png\";\r\nconst CurrentVersion = 2;\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport type EnvironmentTextureInfo = EnvironmentTextureInfoV1 | EnvironmentTextureInfoV2;\r\n\r\n/**\r\n * v1 of EnvironmentTextureInfo\r\n */\r\ninterface EnvironmentTextureInfoV1 {\r\n /**\r\n * Version of the environment map\r\n */\r\n version: 1;\r\n\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n\r\n /**\r\n * Irradiance information stored in the file.\r\n */\r\n irradiance: Nullable<EnvironmentTextureIrradianceInfoV1>;\r\n\r\n /**\r\n * Specular information stored in the file.\r\n */\r\n specular: EnvironmentTextureSpecularInfoV1;\r\n}\r\n\r\n/**\r\n * v2 of EnvironmentTextureInfo\r\n */\r\ninterface EnvironmentTextureInfoV2 {\r\n /**\r\n * Version of the environment map\r\n */\r\n version: 2;\r\n\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n\r\n /**\r\n * Irradiance information stored in the file.\r\n */\r\n irradiance: Nullable<EnvironmentTextureIrradianceInfoV1>;\r\n\r\n /**\r\n * Specular information stored in the file.\r\n */\r\n specular: EnvironmentTextureSpecularInfoV1;\r\n\r\n /**\r\n * The mime type used to encode the image data.\r\n */\r\n imageType: string;\r\n\r\n /**\r\n * Defines where the specular Payload is located. It is a runtime value only not stored in the file.\r\n */\r\n binaryDataPosition?: number;\r\n}\r\n\r\n/**\r\n * Defines One Image in the file. It requires only the position in the file\r\n * as well as the length.\r\n */\r\ninterface BufferImageData {\r\n /**\r\n * Length of the image data.\r\n */\r\n length: number;\r\n /**\r\n * Position of the data from the null terminator delimiting the end of the JSON.\r\n */\r\n position: number;\r\n}\r\n\r\n/**\r\n * Defines the diffuse data enclosed in the file.\r\n * This corresponds to the version 1 of the data.\r\n */\r\nexport interface EnvironmentTextureIrradianceTextureInfoV1 {\r\n /**\r\n * Size of the texture faces.\r\n */\r\n size: number;\r\n /**\r\n * This contains all the images data needed to reconstruct the cubemap.\r\n */\r\n faces: Array<BufferImageData>;\r\n\r\n /**\r\n * The dominant direction of light in the environment texture.\r\n */\r\n dominantDirection?: Array<number>;\r\n}\r\n\r\n/**\r\n * Defines the specular data enclosed in the file.\r\n * This corresponds to the version 1 of the data.\r\n */\r\nexport interface EnvironmentTextureSpecularInfoV1 {\r\n /**\r\n * This contains all the images data needed to reconstruct the cubemap.\r\n */\r\n mipmaps: Array<BufferImageData>;\r\n\r\n /**\r\n * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.\r\n */\r\n lodGenerationScale: number;\r\n}\r\n\r\n/**\r\n * Defines the required storage to save the environment irradiance information.\r\n */\r\ninterface EnvironmentTextureIrradianceInfoV1 {\r\n x: Array<number>;\r\n y: Array<number>;\r\n z: Array<number>;\r\n\r\n xx: Array<number>;\r\n yy: Array<number>;\r\n zz: Array<number>;\r\n\r\n yz: Array<number>;\r\n zx: Array<number>;\r\n xy: Array<number>;\r\n\r\n irradianceTexture?: EnvironmentTextureIrradianceTextureInfoV1 | undefined;\r\n}\r\n\r\n/**\r\n * Options for creating environment textures\r\n */\r\nexport interface CreateEnvTextureOptions {\r\n /**\r\n * The mime type of encoded images.\r\n */\r\n imageType?: string;\r\n\r\n /**\r\n * the image quality of encoded WebP images.\r\n */\r\n imageQuality?: number;\r\n\r\n /**\r\n * Disables the generation of irradiance texture even if present on the source.\r\n */\r\n disableIrradianceTexture?: boolean;\r\n}\r\n\r\n/**\r\n * Magic number identifying the env file.\r\n */\r\nconst MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];\r\n\r\n/**\r\n * Gets the environment info from an env file.\r\n * @param data The array buffer containing the .env bytes.\r\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\r\n */\r\nexport function GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfoV2> {\r\n const dataView = new DataView(data.buffer, data.byteOffset, data.byteLength);\r\n let pos = 0;\r\n\r\n for (let i = 0; i < MagicBytes.length; i++) {\r\n if (dataView.getUint8(pos++) !== MagicBytes[i]) {\r\n Logger.Error(\"Not a babylon environment map\");\r\n return null;\r\n }\r\n }\r\n\r\n // Read json manifest - collect characters up to null terminator\r\n let manifestString = \"\";\r\n let charCode = 0x00;\r\n while ((charCode = dataView.getUint8(pos++))) {\r\n manifestString += String.fromCharCode(charCode);\r\n }\r\n\r\n let manifest: EnvironmentTextureInfo = JSON.parse(manifestString);\r\n manifest = normalizeEnvInfo(manifest);\r\n // Extend the header with the position of the payload.\r\n manifest.binaryDataPosition = pos;\r\n\r\n if (manifest.specular) {\r\n // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.\r\n manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;\r\n }\r\n\r\n return manifest;\r\n}\r\n\r\n/**\r\n * Normalizes any supported version of the environment file info to the latest version\r\n * @param info environment file info on any supported version\r\n * @returns environment file info in the latest supported version\r\n * @private\r\n */\r\nexport function normalizeEnvInfo(info: EnvironmentTextureInfo): EnvironmentTextureInfoV2 {\r\n if (info.version > CurrentVersion) {\r\n throw new Error(`Unsupported babylon environment map version \"${info.version}\". Latest supported version is \"${CurrentVersion}\".`);\r\n }\r\n\r\n if (info.version === 2) {\r\n return info;\r\n }\r\n\r\n // Migrate a v1 info to v2\r\n info = { ...info, version: 2, imageType: DefaultEnvironmentTextureImageType };\r\n\r\n return info;\r\n}\r\n\r\n/**\r\n * Creates an environment texture from a loaded cube texture.\r\n * @param texture defines the cube texture to convert in env file\r\n * @param options options for the conversion process\r\n * @returns a promise containing the environment data if successful.\r\n */\r\nexport async function CreateEnvTextureAsync(texture: BaseTexture, options: CreateEnvTextureOptions = {}): Promise<ArrayBuffer> {\r\n const internalTexture = texture.getInternalTexture();\r\n if (!internalTexture) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"The cube texture is invalid.\");\r\n }\r\n\r\n const engine = internalTexture.getEngine();\r\n\r\n if (\r\n texture.textureType !== Constants.TEXTURETYPE_HALF_FLOAT &&\r\n texture.textureType !== Constants.TEXTURETYPE_FLOAT &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_BYTE &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_BYTE &&\r\n texture.textureType !== Constants.TEXTURETYPE_UNSIGNED_INTEGER &&\r\n texture.textureType !== -1\r\n ) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"The cube texture should allow HDR (Full Float or Half Float).\");\r\n }\r\n\r\n let textureType = Constants.TEXTURETYPE_FLOAT;\r\n if (!engine.getCaps().textureFloatRender) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n if (!engine.getCaps().textureHalfFloatRender) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n return await Promise.reject(\"Env texture can only be created when the browser supports half float or full float rendering.\");\r\n }\r\n }\r\n\r\n // sphericalPolynomial is lazy loaded so simply accessing it should trigger the computation.\r\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\r\n texture.sphericalPolynomial;\r\n\r\n // Lets keep track of the polynomial promise so we can wait for it to be ready before generating the pixels.\r\n const sphericalPolynomialPromise = texture.getInternalTexture()?._sphericalPolynomialPromise;\r\n\r\n const cubeWidth = internalTexture.width;\r\n const hostingScene = new Scene(engine);\r\n const specularTextures: { [key: number]: ArrayBuffer } = {};\r\n const diffuseTextures: { [key: number]: ArrayBuffer } = {};\r\n\r\n // As we are going to readPixels the faces of the cube, make sure the drawing/update commands for the cube texture are fully sent to the GPU in case it is drawn for the first time in this very frame!\r\n engine.flushFramebuffer();\r\n\r\n const imageType = options.imageType ?? DefaultEnvironmentTextureImageType;\r\n\r\n // Read and collect all mipmaps data from the cube.\r\n const mipmapsCount = ILog2(internalTexture.width);\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n const faceWidth = Math.pow(2, mipmapsCount - i);\r\n\r\n // All faces of the cube.\r\n for (let face = 0; face < 6; face++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n specularTextures[i * 6 + face] = await _GetTextureEncodedDataAsync(hostingScene, texture, textureType, face, i, faceWidth, imageType, options.imageQuality);\r\n }\r\n }\r\n\r\n // Read and collect all irradiance data from the cube.\r\n const irradianceTexture = options.disableIrradianceTexture ? null : texture.irradianceTexture;\r\n if (irradianceTexture) {\r\n const faceWidth = irradianceTexture.getSize().width;\r\n\r\n // All faces of the cube.\r\n for (let face = 0; face < 6; face++) {\r\n // eslint-disable-next-line no-await-in-loop\r\n diffuseTextures[face] = await _GetTextureEncodedDataAsync(hostingScene, irradianceTexture, textureType, face, 0, faceWidth, imageType, options.imageQuality);\r\n }\r\n }\r\n\r\n // We can delete the hosting scene keeping track of all the creation objects\r\n hostingScene.dispose();\r\n\r\n // Ensure completion of the polynomial creation promise.\r\n if (sphericalPolynomialPromise) {\r\n await sphericalPolynomialPromise;\r\n }\r\n\r\n // Creates the json header for the env texture\r\n const info: EnvironmentTextureInfo = {\r\n version: CurrentVersion,\r\n width: cubeWidth,\r\n imageType,\r\n irradiance: CreateEnvTextureIrradiance(texture),\r\n specular: {\r\n mipmaps: [],\r\n lodGenerationScale: texture.lodGenerationScale,\r\n },\r\n };\r\n\r\n // Sets the specular image data information\r\n let position = 0;\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n const byteLength = specularTextures[i * 6 + face].byteLength;\r\n info.specular.mipmaps.push({\r\n length: byteLength,\r\n position: position,\r\n });\r\n position += byteLength;\r\n }\r\n }\r\n\r\n // Sets the irradiance image data information\r\n if (irradianceTexture) {\r\n info.irradiance = info.irradiance || {\r\n x: [0, 0, 0],\r\n xx: [0, 0, 0],\r\n y: [0, 0, 0],\r\n yy: [0, 0, 0],\r\n z: [0, 0, 0],\r\n zz: [0, 0, 0],\r\n yz: [0, 0, 0],\r\n zx: [0, 0, 0],\r\n xy: [0, 0, 0],\r\n };\r\n info.irradiance.irradianceTexture = {\r\n size: irradianceTexture.getSize().width,\r\n faces: [],\r\n dominantDirection: irradianceTexture._dominantDirection?.asArray(),\r\n };\r\n\r\n for (let face = 0; face < 6; face++) {\r\n const byteLength = diffuseTextures[face].byteLength;\r\n info.irradiance.irradianceTexture.faces.push({\r\n length: byteLength,\r\n position: position,\r\n });\r\n position += byteLength;\r\n }\r\n }\r\n\r\n // Encode the JSON as an array buffer\r\n const infoString = JSON.stringify(info);\r\n const infoBuffer = new ArrayBuffer(infoString.length + 1);\r\n const infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.\r\n for (let i = 0, strLen = infoString.length; i < strLen; i++) {\r\n infoView[i] = infoString.charCodeAt(i);\r\n }\r\n // Ends up with a null terminator for easier parsing\r\n infoView[infoString.length] = 0x00;\r\n\r\n // Computes the final required size and creates the storage\r\n const totalSize = MagicBytes.length + position + infoBuffer.byteLength;\r\n const finalBuffer = new ArrayBuffer(totalSize);\r\n const finalBufferView = new Uint8Array(finalBuffer);\r\n const dataView = new DataView(finalBuffer);\r\n\r\n // Copy the magic bytes identifying the file in\r\n let pos = 0;\r\n for (let i = 0; i < MagicBytes.length; i++) {\r\n dataView.setUint8(pos++, MagicBytes[i]);\r\n }\r\n\r\n // Add the json info\r\n finalBufferView.set(new Uint8Array(infoBuffer), pos);\r\n pos += infoBuffer.byteLength;\r\n\r\n // Finally inserts the radiance texture data\r\n for (let i = 0; i <= mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n const dataBuffer = specularTextures[i * 6 + face];\r\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\r\n pos += dataBuffer.byteLength;\r\n }\r\n }\r\n\r\n // Finally inserts the irradiance texture data\r\n if (irradianceTexture) {\r\n for (let face = 0; face < 6; face++) {\r\n const dataBuffer = diffuseTextures[face];\r\n finalBufferView.set(new Uint8Array(dataBuffer), pos);\r\n pos += dataBuffer.byteLength;\r\n }\r\n }\r\n\r\n // Voila\r\n return finalBuffer;\r\n}\r\n\r\n/**\r\n * Get the texture encoded data from the current texture\r\n * @internal\r\n */\r\nasync function _GetTextureEncodedDataAsync(\r\n hostingScene: Scene,\r\n texture: BaseTexture,\r\n textureType: number,\r\n face: number,\r\n i: number,\r\n size: number,\r\n imageType: string,\r\n imageQuality?: number\r\n) {\r\n let faceData = await texture.readPixels(face, i, undefined, false);\r\n if (faceData && faceData.byteLength === (faceData as Uint8Array).length) {\r\n const faceDataFloat = new Float32Array(faceData.byteLength * 4);\r\n for (let i = 0; i < faceData.byteLength; i++) {\r\n faceDataFloat[i] = (faceData as Uint8Array)[i] / 255;\r\n // Gamma to linear\r\n faceDataFloat[i] = Math.pow(faceDataFloat[i], 2.2);\r\n }\r\n faceData = faceDataFloat;\r\n } else if (faceData && texture.gammaSpace) {\r\n const floatData = faceData as Float32Array;\r\n for (let i = 0; i < floatData.length; i++) {\r\n // Gamma to linear\r\n floatData[i] = Math.pow(floatData[i], 2.2);\r\n }\r\n }\r\n\r\n const engine = hostingScene.getEngine();\r\n const tempTexture = engine.createRawTexture(faceData, size, size, Constants.TEXTUREFORMAT_RGBA, false, true, Constants.TEXTURE_NEAREST_SAMPLINGMODE, null, textureType);\r\n\r\n await RGBDTextureTools.EncodeTextureToRGBD(tempTexture, hostingScene, textureType);\r\n\r\n const rgbdEncodedData = await engine._readTexturePixels(tempTexture, size, size);\r\n\r\n const imageEncodedData = await DumpDataAsync(size, size, rgbdEncodedData, imageType, undefined, false, true, imageQuality);\r\n\r\n tempTexture.dispose();\r\n\r\n return imageEncodedData as ArrayBuffer;\r\n}\r\n\r\n/**\r\n * Creates a JSON representation of the spherical data.\r\n * @param texture defines the texture containing the polynomials\r\n * @returns the JSON representation of the spherical info\r\n */\r\nfunction CreateEnvTextureIrradiance(texture: BaseTexture): Nullable<EnvironmentTextureIrradianceInfoV1> {\r\n const polynmials = texture.sphericalPolynomial;\r\n if (polynmials == null) {\r\n return null;\r\n }\r\n\r\n return {\r\n x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],\r\n y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],\r\n z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],\r\n\r\n xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],\r\n yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],\r\n zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],\r\n\r\n yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],\r\n zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],\r\n xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z],\r\n };\r\n}\r\n\r\n/**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\nexport function CreateRadianceImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const specularInfo = info.specular;\r\n\r\n // Double checks the enclosed info\r\n let mipmapsCount = Math.log2(info.width);\r\n mipmapsCount = Math.round(mipmapsCount) + 1;\r\n if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {\r\n throw new Error(`Unsupported specular mipmaps number \"${specularInfo.mipmaps.length}\"`);\r\n }\r\n\r\n const imageData = new Array<Array<ArrayBufferView>>(mipmapsCount);\r\n for (let i = 0; i < mipmapsCount; i++) {\r\n imageData[i] = new Array<ArrayBufferView>(6);\r\n for (let face = 0; face < 6; face++) {\r\n const imageInfo = specularInfo.mipmaps[i * 6 + face];\r\n imageData[i][face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition! + imageInfo.position, imageInfo.length);\r\n }\r\n }\r\n\r\n return imageData;\r\n}\r\n\r\n/**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\nexport function CreateIrradianceImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<ArrayBufferView> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const imageData = new Array<ArrayBufferView>(6);\r\n\r\n const irradianceTexture = info.irradiance?.irradianceTexture;\r\n if (irradianceTexture) {\r\n if (irradianceTexture.faces.length !== 6) {\r\n throw new Error(`Incorrect irradiance texture faces number \"${irradianceTexture.faces.length}\"`);\r\n }\r\n\r\n for (let face = 0; face < 6; face++) {\r\n const imageInfo = irradianceTexture.faces[face];\r\n imageData[face] = new Uint8Array(data.buffer, data.byteOffset + info.binaryDataPosition! + imageInfo.position, imageInfo.length);\r\n }\r\n }\r\n\r\n return imageData;\r\n}\r\n\r\n/**\r\n * Uploads the texture info contained in the env file to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param data defines the data to load\r\n * @param info defines the texture info retrieved through the GetEnvInfo method\r\n * @returns a promise\r\n */\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\nexport function UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void[]> {\r\n info = normalizeEnvInfo(info);\r\n\r\n const specularInfo = info.specular;\r\n if (!specularInfo) {\r\n // Nothing else parsed so far\r\n return Promise.resolve([]);\r\n }\r\n\r\n texture._lodGenerationScale = specularInfo.lodGenerationScale;\r\n\r\n const promises: Promise<void>[] = [];\r\n\r\n const radianceImageData = CreateRadianceImageDataArrayBufferViews(data, info);\r\n promises.push(UploadRadianceLevelsAsync(texture, radianceImageData, info.imageType));\r\n\r\n const irradianceTexture = info.irradiance?.irradianceTexture;\r\n if (irradianceTexture) {\r\n const irradianceImageData = CreateIrradianceImageDataArrayBufferViews(data, info);\r\n let dominantDirection = null;\r\n if (info.irradiance?.irradianceTexture?.dominantDirection) {\r\n dominantDirection = Vector3.FromArray(info.irradiance.irradianceTexture.dominantDirection);\r\n }\r\n promises.push(UploadIrradianceLevelsAsync(texture, irradianceImageData, irradianceTexture.size, info.imageType, dominantDirection));\r\n }\r\n\r\n return Promise.all(promises);\r\n}\r\n\r\nasync function _OnImageReadyAsync(\r\n image: HTMLImageElement | ImageBitmap,\r\n engine: Engine | WebGPUEngine,\r\n expandTexture: boolean,\r\n rgbdPostProcess: Nullable<PostProcess>,\r\n url: string,\r\n face: number,\r\n i: number,\r\n generateNonLODTextures: boolean,\r\n lodTextures: Nullable<{ [lod: number]: BaseTexture }>,\r\n cubeRtt: Nullable<RenderTargetWrapper>,\r\n texture: InternalTexture\r\n): Promise<void> {\r\n return await new Promise((resolve, reject) => {\r\n if (expandTexture) {\r\n const tempTexture = engine.createTexture(\r\n null,\r\n true,\r\n true,\r\n null,\r\n Constants.TEXTURE_NEAREST_SAMPLINGMODE,\r\n null,\r\n (message) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(message);\r\n },\r\n image\r\n );\r\n\r\n rgbdPostProcess?.onEffectCreatedObservable.addOnce((effect) => {\r\n effect.executeWhenCompiled(() => {\r\n // Uncompress the data to a RTT\r\n rgbdPostProcess.externalTextureSamplerBinding = true;\r\n rgbdPostProcess.onApply = (effect) => {\r\n effect._bindTexture(\"textureSampler\", tempTexture);\r\n effect.setFloat2(\"scale\", 1, engine._features.needsInvertingBitmap && image instanceof ImageBitmap ? -1 : 1);\r\n };\r\n\r\n if (!engine.scenes.length) {\r\n return;\r\n }\r\n\r\n engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);\r\n\r\n // Cleanup\r\n engine.restoreDefaultFramebuffer();\r\n tempTexture.dispose();\r\n URL.revokeObjectURL(url);\r\n resolve();\r\n });\r\n });\r\n } else {\r\n engine._uploadImageToTexture(texture, image, face, i);\r\n\r\n // Upload the face to the non lod texture support\r\n if (generateNonLODTextures) {\r\n const lodTexture = lodTextures![i];\r\n if (lodTexture) {\r\n engine._uploadImageToTexture(lodTexture._texture!, image, face, 0);\r\n }\r\n }\r\n resolve();\r\n }\r\n });\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\nexport async function UploadRadianceLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][], imageType: string = DefaultEnvironmentTextureImageType): Promise<void> {\r\n const engine = texture.getEngine() as Engine;\r\n texture.format = Constants.TEXTUREFORMAT_RGBA;\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n texture.generateMipMaps = true;\r\n texture._cachedAnisotropicFilteringLevel = null;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, texture);\r\n\r\n await _UploadLevelsAsync(texture, imageData, true, imageType);\r\n\r\n // Flag internal texture as ready in case they are in use.\r\n texture.isReady = true;\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param mainTexture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param size defines the size of the texture faces\r\n * @param imageType the mime type of the image data\r\n * @param dominantDirection the dominant direction of light in the environment texture, if available\r\n * @returns a promise\r\n */\r\nexport async function UploadIrradianceLevelsAsync(\r\n mainTexture: InternalTexture,\r\n imageData: ArrayBufferView[],\r\n size: number,\r\n imageType: string = DefaultEnvironmentTextureImageType,\r\n dominantDirection: Nullable<Vector3> = null\r\n): Promise<void> {\r\n // Gets everything ready.\r\n const engine = mainTexture.getEngine() as Engine;\r\n const texture = new InternalTexture(engine, InternalTextureSource.RenderTarget);\r\n const baseTexture = new BaseTexture(engine, texture);\r\n mainTexture._irradianceTexture = baseTexture;\r\n baseTexture._dominantDirection = dominantDirection;\r\n texture.isCube = true;\r\n texture.format = Constants.TEXTUREFORMAT_RGBA;\r\n texture.type = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n texture.generateMipMaps = true;\r\n texture._cachedAnisotropicFilteringLevel = null;\r\n texture.generateMipMaps = true;\r\n texture.width = size;\r\n texture.height = size;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_TRILINEAR_SAMPLINGMODE, texture);\r\n\r\n await _UploadLevelsAsync(texture, [imageData], false, imageType);\r\n\r\n engine.generateMipMapsForCubemap(texture);\r\n\r\n // Flag internal texture as ready in case they are in use.\r\n texture.isReady = true;\r\n}\r\n\r\n/**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param canGenerateNonLODTextures defines whether or not to generate non lod textures\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\nasync function _UploadLevelsAsync(\r\n texture: InternalTexture,\r\n imageData: ArrayBufferView[][],\r\n canGenerateNonLODTextures: boolean,\r\n imageType: string = DefaultEnvironmentTextureImageType\r\n) {\r\n if (!Tools.IsExponentOfTwo(texture.width)) {\r\n throw new Error(\"Texture size must be a power of two\");\r\n }\r\n\r\n const mipmapsCount = ILog2(texture.width) + 1;\r\n\r\n // Gets everything ready.\r\n const engine = texture.getEngine() as Engine;\r\n let expandTexture = false;\r\n let generateNonLODTextures = false;\r\n let rgbdPostProcess: Nullable<PostProcess> = null;\r\n let cubeRtt: Nullable<RenderTargetWrapper> = null;\r\n let lodTextures: Nullable<{ [lod: number]: BaseTexture }> = null;\r\n const caps = engine.getCaps();\r\n\r\n if (!caps.textureLOD) {\r\n expandTexture = false;\r\n generateNonLODTextures = canGenerateNonLODTextures;\r\n } else if (!engine._features.supportRenderAndCopyToLodForFloatTextures) {\r\n expandTexture = false;\r\n }\r\n // If half float available we can uncompress the texture\r\n else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {\r\n expandTexture = true;\r\n texture.type = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n // If full float available we can uncompress the texture\r\n else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {\r\n expandTexture = true;\r\n texture.type = Constants.TEXTURETYPE_FLOAT;\r\n }\r\n\r\n // Expand the texture if possible\r\n let shaderLanguage = ShaderLanguage.GLSL;\r\n if (expandTexture) {\r\n if (engine.isWebGPU) {\r\n shaderLanguage = ShaderLanguage.WGSL;\r\n await import(\"../ShadersWGSL/rgbdDecode.fragment\");\r\n } else {\r\n await import(\"../Shaders/rgbdDecode.fragment\");\r\n }\r\n\r\n // Simply run through the decode PP\r\n rgbdPostProcess = new PostProcess(\r\n \"rgbdDecode\",\r\n \"rgbdDecode\",\r\n null,\r\n null,\r\n 1,\r\n null,\r\n Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n engine,\r\n false,\r\n undefined,\r\n texture.type,\r\n undefined,\r\n null,\r\n false,\r\n undefined,\r\n shaderLanguage\r\n );\r\n\r\n texture._isRGBD = false;\r\n texture.invertY = false;\r\n cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {\r\n generateDepthBuffer: false,\r\n generateMipMaps: true,\r\n generateStencilBuffer: false,\r\n samplingMode: Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n type: texture.type,\r\n format: Constants.TEXTUREFORMAT_RGBA,\r\n });\r\n } else {\r\n texture._isRGBD = true;\r\n texture.invertY = true;\r\n\r\n // In case of missing support, applies the same patch than DDS files.\r\n if (generateNonLODTextures) {\r\n const mipSlices = 3;\r\n lodTextures = {};\r\n const scale = texture._lodGenerationScale;\r\n const offset = texture._lodGenerationOffset;\r\n\r\n for (let i = 0; i < mipSlices; i++) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n\r\n const minLODIndex = offset; // roughness = 0\r\n const maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)\r\n\r\n const lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;\r\n const mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));\r\n\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const glTextureFromLod = new InternalTexture(engine, InternalTextureSource.Temp);\r\n glTextureFromLod.isCube = true;\r\n glTextureFromLod.invertY = true;\r\n glTextureFromLod.generateMipMaps = false;\r\n engine.updateTextureSamplingMode(Constants.TEXTURE_LINEAR_LINEAR, glTextureFromLod);\r\n\r\n // Wrap in a base texture for easy binding.\r\n const lodTexture = new BaseTexture(null);\r\n lodTexture._isCube = true;\r\n lodTexture._texture = glTextureFromLod;\r\n lodTextures[mipmapIndex] = lodTexture;\r\n\r\n switch (i) {\r\n case 0:\r\n texture._lodTextureLow = lodTexture;\r\n break;\r\n case 1:\r\n texture._lodTextureMid = lodTexture;\r\n break;\r\n case 2:\r\n texture._lodTextureHigh = lodTexture;\r\n break;\r\n }\r\n }\r\n }\r\n }\r\n\r\n const promises: Promise<void>[] = [];\r\n // All mipmaps up to provided number of images\r\n for (let i = 0; i < imageData.length; i++) {\r\n // All faces\r\n for (let face = 0; face < 6; face++) {\r\n // Constructs an image element from image data\r\n const bytes = imageData[i][face];\r\n const blob = new Blob([bytes], { type: imageType });\r\n const url = URL.createObjectURL(blob);\r\n let promise: Promise<void>;\r\n\r\n if (engine._features.forceBitmapOverHTMLImageElement) {\r\n // eslint-disable-next-line github/no-then\r\n promise = engine.createImageBitmap(blob, { premultiplyAlpha: \"none\" }).then(async (img) => {\r\n return await _OnImageReadyAsync(img, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture);\r\n });\r\n } else {\r\n const image = new Image();\r\n image.src = url;\r\n\r\n // Enqueue promise to upload to the texture.\r\n promise = new Promise<void>((resolve, reject) => {\r\n image.onload = () => {\r\n _OnImageReadyAsync(image, engine, expandTexture, rgbdPostProcess, url, face, i, generateNonLODTextures, lodTextures, cubeRtt, texture)\r\n // eslint-disable-next-line github/no-then\r\n .then(() => resolve())\r\n // eslint-disable-next-line github/no-then\r\n .catch((reason) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(reason);\r\n });\r\n };\r\n image.onerror = (error) => {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(error);\r\n };\r\n });\r\n }\r\n promises.push(promise);\r\n }\r\n }\r\n\r\n await Promise.all(promises);\r\n\r\n // Fill remaining mipmaps with black textures.\r\n if (imageData.length < mipmapsCount) {\r\n let data: ArrayBufferView;\r\n const size = Math.pow(2, mipmapsCount - 1 - imageData.length);\r\n const dataLength = size * size * 4;\r\n switch (texture.type) {\r\n case Constants.TEXTURETYPE_UNSIGNED_BYTE: {\r\n data = new Uint8Array(dataLength);\r\n break;\r\n }\r\n case Constants.TEXTURETYPE_HALF_FLOAT: {\r\n data = new Uint16Array(dataLength);\r\n break;\r\n }\r\n case Constants.TEXTURETYPE_FLOAT: {\r\n data = new Float32Array(dataLength);\r\n break;\r\n }\r\n }\r\n for (let i = imageData.length; i < mipmapsCount; i++) {\r\n for (let face = 0; face < 6; face++) {\r\n engine._uploadArrayBufferViewToTexture(cubeRtt?.texture || texture, data!, face, i);\r\n }\r\n }\r\n }\r\n\r\n // Release temp RTT.\r\n if (cubeRtt) {\r\n const irradiance = texture._irradianceTexture;\r\n texture._irradianceTexture = null;\r\n engine._releaseTexture(texture);\r\n cubeRtt._swapAndDie(texture);\r\n texture._irradianceTexture = irradiance;\r\n }\r\n // Release temp Post Process.\r\n if (rgbdPostProcess) {\r\n rgbdPostProcess.dispose();\r\n }\r\n // Flag internal texture as ready in case they are in use.\r\n if (generateNonLODTextures) {\r\n if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {\r\n texture._lodTextureHigh._texture.isReady = true;\r\n }\r\n if (texture._lodTextureMid && texture._lodTextureMid._texture) {\r\n texture._lodTextureMid._texture.isReady = true;\r\n }\r\n if (texture._lodTextureLow && texture._lodTextureLow._texture) {\r\n texture._lodTextureLow._texture.isReady = true;\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Uploads spherical polynomials information to the texture.\r\n * @param texture defines the texture we are trying to upload the information to\r\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\r\n */\r\nexport function UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void {\r\n info = normalizeEnvInfo(info);\r\n\r\n const irradianceInfo = info.irradiance as EnvironmentTextureIrradianceInfoV1;\r\n if (!irradianceInfo) {\r\n return;\r\n }\r\n\r\n const sp = new SphericalPolynomial();\r\n Vector3.FromArrayToRef(irradianceInfo.x, 0, sp.x);\r\n Vector3.FromArrayToRef(irradianceInfo.y, 0, sp.y);\r\n Vector3.FromArrayToRef(irradianceInfo.z, 0, sp.z);\r\n Vector3.FromArrayToRef(irradianceInfo.xx, 0, sp.xx);\r\n Vector3.FromArrayToRef(irradianceInfo.yy, 0, sp.yy);\r\n Vector3.FromArrayToRef(irradianceInfo.zz, 0, sp.zz);\r\n Vector3.FromArrayToRef(irradianceInfo.yz, 0, sp.yz);\r\n Vector3.FromArrayToRef(irradianceInfo.zx, 0, sp.zx);\r\n Vector3.FromArrayToRef(irradianceInfo.xy, 0, sp.xy);\r\n texture._sphericalPolynomial = sp;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/promise-function-async, no-restricted-syntax\r\nexport function _UpdateRGBDAsync(\r\n internalTexture: InternalTexture,\r\n data: ArrayBufferView[][],\r\n sphericalPolynomial: Nullable<SphericalPolynomial>,\r\n lodScale: number,\r\n lodOffset: number\r\n): Promise<InternalTexture> {\r\n const proxy = internalTexture\r\n .getEngine()\r\n .createRawCubeTexture(\r\n null,\r\n internalTexture.width,\r\n internalTexture.format,\r\n internalTexture.type,\r\n internalTexture.generateMipMaps,\r\n internalTexture.invertY,\r\n internalTexture.samplingMode,\r\n internalTexture._compression\r\n );\r\n // eslint-disable-next-line github/no-then\r\n const proxyPromise = UploadRadianceLevelsAsync(proxy, data).then(() => internalTexture);\r\n internalTexture.onRebuildCallback = (_internalTexture) => {\r\n return {\r\n proxy: proxyPromise,\r\n isReady: true,\r\n isAsync: true,\r\n };\r\n };\r\n internalTexture._source = InternalTextureSource.CubeRawRGBD;\r\n internalTexture._bufferViewArrayArray = data;\r\n internalTexture._lodGenerationScale = lodScale;\r\n internalTexture._lodGenerationOffset = lodOffset;\r\n internalTexture._sphericalPolynomial = sphericalPolynomial;\r\n\r\n // eslint-disable-next-line github/no-then\r\n return UploadRadianceLevelsAsync(internalTexture, data).then(() => {\r\n internalTexture.isReady = true;\r\n return internalTexture;\r\n });\r\n}\r\n\r\n/**\r\n * Sets of helpers addressing the serialization and deserialization of environment texture\r\n * stored in a BabylonJS env file.\r\n * Those files are usually stored as .env files.\r\n */\r\nexport const EnvironmentTextureTools = {\r\n /**\r\n * Gets the environment info from an env file.\r\n * @param data The array buffer containing the .env bytes.\r\n * @returns the environment file info (the json header) if successfully parsed, normalized to the latest supported version.\r\n */\r\n GetEnvInfo,\r\n\r\n /**\r\n * Creates an environment texture from a loaded cube texture.\r\n * @param texture defines the cube texture to convert in env file\r\n * @param options options for the conversion process\r\n * @param options.imageType the mime type for the encoded images, with support for \"image/png\" (default) and \"image/webp\"\r\n * @param options.imageQuality the image quality of encoded WebP images.\r\n * @returns a promise containing the environment data if successful.\r\n */\r\n CreateEnvTextureAsync,\r\n\r\n /**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\n CreateRadianceImageDataArrayBufferViews,\r\n\r\n /**\r\n * Creates the ArrayBufferViews used for initializing environment texture image data.\r\n * @param data the image data\r\n * @param info parameters that determine what views will be created for accessing the underlying buffer\r\n * @returns the views described by info providing access to the underlying buffer\r\n */\r\n CreateIrradianceImageDataArrayBufferViews,\r\n\r\n /**\r\n * Uploads the texture info contained in the env file to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param data defines the data to load\r\n * @param info defines the texture info retrieved through the GetEnvInfo method\r\n * @returns a promise\r\n */\r\n UploadEnvLevelsAsync,\r\n\r\n /**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @returns a promise\r\n */\r\n UploadRadianceLevelsAsync,\r\n\r\n /**\r\n * Uploads the levels of image data to the GPU.\r\n * @param texture defines the internal texture to upload to\r\n * @param imageData defines the array buffer views of image data [mipmap][face]\r\n * @param imageType the mime type of the image data\r\n * @param dominantDirection the dominant direction of light in the environment texture, if available\r\n * @returns a promise\r\n */\r\n UploadIrradianceLevelsAsync,\r\n\r\n /**\r\n * Uploads spherical polynomials information to the texture.\r\n * @param texture defines the texture we are trying to upload the information to\r\n * @param info defines the environment texture info retrieved through the GetEnvInfo method\r\n */\r\n UploadEnvSpherical,\r\n};\r\n"]}
@@ -113,7 +113,7 @@ export declare class Observer<T> implements IObserver {
113
113
  /**
114
114
  * An interface that defines the reader side of an Observable (receive notifications).
115
115
  */
116
- export interface IReadonlyObservable<T> {
116
+ export interface IReadonlyObservable<T = unknown> {
117
117
  /**
118
118
  * Create a new Observer with the specified callback
119
119
  * @param callback the callback that will be executed for that Observer
@@ -1 +1 @@
1
- {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/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AEnC,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE7C,OAAO,MAAM,CAAC;IAClB,CAAC;IAED;;;;QAII;IACG,eAAe,CAAC,OAAe,CAAC,CAAC;QACpC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAChC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\ndeclare const WeakRef: any;\r\n\r\nconst IsWeakRefSupported = typeof WeakRef !== \"undefined\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an observer registered to a given IObservable object.\r\n */\r\nexport interface IObserver {\r\n /**\r\n * Remove the observer from its observable\r\n * @param defer if true, the removal will be deferred to avoid callback skipping (default: false)\r\n */\r\n remove(defer?: boolean): void;\r\n}\r\n\r\n/**\r\n * Represent an observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> implements IObserver {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<(defer?: boolean) => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [null] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n * @param defer if true, the removal will be deferred to avoid callback skipping (default: false)\r\n */\r\n public remove(defer = false) {\r\n if (this._remove) {\r\n this._remove(defer);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * An interface that defines the reader side of an Observable (receive notifications).\r\n */\r\nexport interface IReadonlyObservable<T> {\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: unknown, unregisterOnFirstCall?: boolean): IObserver;\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n addOnce(callback: (eventData: T, eventState: EventState) => void): IObserver;\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> implements IReadonlyObservable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n // eslint-disable-next-line github/no-then\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n\r\n // attach the remove function to the observer\r\n const observableWeakRef = IsWeakRefSupported ? new WeakRef(this) : { deref: () => this };\r\n observer._remove = (defer = false) => {\r\n const observable = observableWeakRef.deref();\r\n if (observable) {\r\n defer ? observable.remove(observer) : observable._remove(observer);\r\n }\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/observable.ts"],"names":[],"mappings":"AAIA,MAAM,kBAAkB,GAAG,OAAO,OAAO,KAAK,WAAW,CAAC;AAE1D;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;;;;;OAMG;IACH,YAAY,IAAY,EAAE,iBAAiB,GAAG,KAAK,EAAE,MAAY,EAAE,aAAmB;QAClF,IAAI,CA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,EAAE,CAAC;YAChC,IAAI,GAAG,CAAC,IAAI,GAAG,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;gBACvC,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../types\";\r\n\r\ndeclare const WeakRef: any;\r\n\r\nconst IsWeakRefSupported = typeof WeakRef !== \"undefined\";\r\n\r\n/**\r\n * A class serves as a medium between the observable and its observers\r\n */\r\nexport class EventState {\r\n /**\r\n * Create a new EventState\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n */\r\n constructor(mask: number, skipNextObservers = false, target?: any, currentTarget?: any) {\r\n this.initialize(mask, skipNextObservers, target, currentTarget);\r\n }\r\n\r\n /**\r\n * Initialize the current event state\r\n * @param mask defines the mask associated with this state\r\n * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @returns the current event state\r\n */\r\n public initialize(mask: number, skipNextObservers = false, target?: any, currentTarget?: any): EventState {\r\n this.mask = mask;\r\n this.skipNextObservers = skipNextObservers;\r\n this.target = target;\r\n this.currentTarget = currentTarget;\r\n return this;\r\n }\r\n\r\n /**\r\n * An Observer can set this property to true to prevent subsequent observers of being notified\r\n */\r\n public skipNextObservers: boolean;\r\n\r\n /**\r\n * Get the mask value that were used to trigger the event corresponding to this EventState object\r\n */\r\n public mask: number;\r\n\r\n /**\r\n * The object that originally notified the event\r\n */\r\n public target?: any;\r\n\r\n /**\r\n * The current object in the bubbling phase\r\n */\r\n public currentTarget?: any;\r\n\r\n /**\r\n * This will be populated with the return value of the last function that was executed.\r\n * If it is the first function in the callback chain it will be the event data.\r\n */\r\n public lastReturnValue?: any;\r\n\r\n /**\r\n * User defined information that will be sent to observers\r\n */\r\n public userInfo?: any;\r\n}\r\n\r\n/**\r\n * Represent an observer registered to a given IObservable object.\r\n */\r\nexport interface IObserver {\r\n /**\r\n * Remove the observer from its observable\r\n * @param defer if true, the removal will be deferred to avoid callback skipping (default: false)\r\n */\r\n remove(defer?: boolean): void;\r\n}\r\n\r\n/**\r\n * Represent an observer registered to a given Observable object.\r\n */\r\nexport class Observer<T> implements IObserver {\r\n /** @internal */\r\n public _willBeUnregistered = false;\r\n /**\r\n * Gets or sets a property defining that the observer as to be unregistered after the next notification\r\n */\r\n public unregisterOnNextCall = false;\r\n\r\n /**\r\n * this function can be used to remove the observer from the observable.\r\n * It will be set by the observable that the observer belongs to.\r\n * @internal\r\n */\r\n public _remove: Nullable<(defer?: boolean) => void> = null;\r\n\r\n /**\r\n * Creates a new observer\r\n * @param callback defines the callback to call when the observer is notified\r\n * @param mask defines the mask of the observer (used to filter notifications)\r\n * @param scope defines the current scope used to restore the JS context\r\n */\r\n constructor(\r\n /**\r\n * Defines the callback to call when the observer is notified\r\n */\r\n public callback: (eventData: T, eventState: EventState) => void,\r\n /**\r\n * Defines the mask of the observer (used to filter notifications)\r\n */\r\n public mask: number,\r\n /**\r\n * [null] Defines the current scope used to restore the JS context\r\n */\r\n public scope: any = null\r\n ) {}\r\n\r\n /**\r\n * Remove the observer from its observable\r\n * This can be used instead of using the observable's remove function.\r\n * @param defer if true, the removal will be deferred to avoid callback skipping (default: false)\r\n */\r\n public remove(defer = false) {\r\n if (this._remove) {\r\n this._remove(defer);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * An interface that defines the reader side of an Observable (receive notifications).\r\n */\r\nexport interface IReadonlyObservable<T = unknown> {\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: unknown, unregisterOnFirstCall?: boolean): IObserver;\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n addOnce(callback: (eventData: T, eventState: EventState) => void): IObserver;\r\n}\r\n\r\n/**\r\n * The Observable class is a simple implementation of the Observable pattern.\r\n *\r\n * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.\r\n * This enable a more fine grained execution without having to rely on multiple different Observable objects.\r\n * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).\r\n * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.\r\n */\r\nexport class Observable<T> implements IReadonlyObservable<T> {\r\n private _observers = new Array<Observer<T>>();\r\n private _numObserversMarkedAsDeleted = 0;\r\n private _hasNotified = false;\r\n private _lastNotifiedValue?: T;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _eventState: EventState;\r\n\r\n private _onObserverAdded: Nullable<(observer: Observer<T>) => void>;\r\n\r\n /**\r\n * Create an observable from a Promise.\r\n * @param promise a promise to observe for fulfillment.\r\n * @param onErrorObservable an observable to notify if a promise was rejected.\r\n * @returns the new Observable\r\n */\r\n public static FromPromise<T, E = Error>(promise: Promise<T>, onErrorObservable?: Observable<E>): Observable<T> {\r\n const observable = new Observable<T>();\r\n\r\n promise\r\n // eslint-disable-next-line github/no-then\r\n .then((ret: T) => {\r\n observable.notifyObservers(ret);\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((err) => {\r\n if (onErrorObservable) {\r\n onErrorObservable.notifyObservers(err as E);\r\n } else {\r\n throw err;\r\n }\r\n });\r\n\r\n return observable;\r\n }\r\n\r\n /**\r\n * Gets the list of observers\r\n * Note that observers that were recently deleted may still be present in the list because they are only really deleted on the next javascript tick!\r\n */\r\n public get observers(): Array<Observer<T>> {\r\n return this._observers;\r\n }\r\n\r\n /**\r\n * Creates a new observable\r\n * @param onObserverAdded defines a callback to call when a new observer is added\r\n * @param notifyIfTriggered If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n */\r\n constructor(\r\n onObserverAdded?: (observer: Observer<T>) => void,\r\n /**\r\n * [false] If set to true the observable will notify when an observer was added if the observable was already triggered.\r\n * This is helpful to single-state observables like the scene onReady or the dispose observable.\r\n */\r\n public notifyIfTriggered = false\r\n ) {\r\n this._eventState = new EventState(0);\r\n\r\n if (onObserverAdded) {\r\n this._onObserverAdded = onObserverAdded;\r\n }\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback\r\n * @param callback the callback that will be executed for that Observer\r\n * @param mask the mask used to filter observers\r\n * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.\r\n * @param scope optional scope for the callback to be called from\r\n * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification\r\n * @returns the new observer created for the callback\r\n */\r\n public add(callback?: null, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): null;\r\n public add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Observer<T>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null,\r\n mask?: number,\r\n insertFirst?: boolean,\r\n scope?: any,\r\n unregisterOnFirstCall?: boolean\r\n ): Nullable<Observer<T>>;\r\n public add(\r\n callback?: ((eventData: T, eventState: EventState) => void) | null,\r\n mask: number = -1,\r\n insertFirst = false,\r\n scope: any = null,\r\n unregisterOnFirstCall = false\r\n ): Nullable<Observer<T>> {\r\n if (!callback) {\r\n return null;\r\n }\r\n\r\n const observer = new Observer(callback, mask, scope);\r\n observer.unregisterOnNextCall = unregisterOnFirstCall;\r\n\r\n if (insertFirst) {\r\n this._observers.unshift(observer);\r\n } else {\r\n this._observers.push(observer);\r\n }\r\n\r\n if (this._onObserverAdded) {\r\n this._onObserverAdded(observer);\r\n }\r\n\r\n // If the observable was already triggered and the observable is set to notify if triggered, notify the new observer\r\n if (this._hasNotified && this.notifyIfTriggered) {\r\n if (this._lastNotifiedValue !== undefined) {\r\n this.notifyObserver(observer, this._lastNotifiedValue);\r\n }\r\n }\r\n\r\n // attach the remove function to the observer\r\n const observableWeakRef = IsWeakRefSupported ? new WeakRef(this) : { deref: () => this };\r\n observer._remove = (defer = false) => {\r\n const observable = observableWeakRef.deref();\r\n if (observable) {\r\n defer ? observable.remove(observer) : observable._remove(observer);\r\n }\r\n };\r\n\r\n return observer;\r\n }\r\n\r\n /**\r\n * Create a new Observer with the specified callback and unregisters after the next notification\r\n * @param callback the callback that will be executed for that Observer\r\n * @returns the new observer created for the callback\r\n */\r\n public addOnce(callback?: null): null;\r\n public addOnce(callback: (eventData: T, eventState: EventState) => void): Observer<T>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null): Nullable<Observer<T>>;\r\n public addOnce(callback?: ((eventData: T, eventState: EventState) => void) | null): Nullable<Observer<T>> {\r\n return this.add(callback, undefined, undefined, undefined, true);\r\n }\r\n\r\n /**\r\n * Remove an Observer from the Observable object\r\n * @param observer the instance of the Observer to remove\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public remove(observer: Nullable<Observer<T>>): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n observer._remove = null;\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Remove a callback from the Observable object\r\n * @param callback the callback to remove\r\n * @param scope optional scope. If used only the callbacks with this scope will be removed\r\n * @returns false if it doesn't belong to this Observable\r\n */\r\n public removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean {\r\n for (let index = 0; index < this._observers.length; index++) {\r\n const observer = this._observers[index];\r\n if (observer._willBeUnregistered) {\r\n continue;\r\n }\r\n if (observer.callback === callback && (!scope || scope === observer.scope)) {\r\n this._deferUnregister(observer);\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _deferUnregister(observer: Observer<T>): void {\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n this._numObserversMarkedAsDeleted++;\r\n observer.unregisterOnNextCall = false;\r\n observer._willBeUnregistered = true;\r\n setTimeout(() => {\r\n this._remove(observer);\r\n }, 0);\r\n }\r\n\r\n // This should only be called when not iterating over _observers to avoid callback skipping.\r\n // Removes an observer from the _observer Array.\r\n private _remove(observer: Nullable<Observer<T>>, updateCounter = true): boolean {\r\n if (!observer) {\r\n return false;\r\n }\r\n\r\n const index = this._observers.indexOf(observer);\r\n\r\n if (index !== -1) {\r\n if (updateCounter) {\r\n this._numObserversMarkedAsDeleted--;\r\n }\r\n this._observers.splice(index, 1);\r\n return true;\r\n }\r\n\r\n return false;\r\n }\r\n\r\n /**\r\n * Moves the observable to the top of the observer list making it get called first when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverTopPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.unshift(observer);\r\n }\r\n\r\n /**\r\n * Moves the observable to the bottom of the observer list making it get called last when notified\r\n * @param observer the observer to move\r\n */\r\n public makeObserverBottomPriority(observer: Observer<T>) {\r\n this._remove(observer, false);\r\n this._observers.push(observer);\r\n }\r\n\r\n /**\r\n * Notify all Observers by calling their respective callback with the given data\r\n * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute\r\n * @param eventData defines the data to send to all observers\r\n * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)\r\n * @param target defines the original target of the state\r\n * @param currentTarget defines the current target of the state\r\n * @param userInfo defines any user info to send to observers\r\n * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)\r\n */\r\n public notifyObservers(eventData: T, mask: number = -1, target?: any, currentTarget?: any, userInfo?: any): boolean {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (!this._observers.length) {\r\n return true;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.target = target;\r\n state.currentTarget = currentTarget;\r\n state.skipNextObservers = false;\r\n state.lastReturnValue = eventData;\r\n state.userInfo = userInfo;\r\n\r\n for (const obs of this._observers) {\r\n if (obs._willBeUnregistered) {\r\n continue;\r\n }\r\n\r\n if (obs.mask & mask) {\r\n if (obs.unregisterOnNextCall) {\r\n this._deferUnregister(obs);\r\n }\r\n\r\n if (obs.scope) {\r\n state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);\r\n } else {\r\n state.lastReturnValue = obs.callback(eventData, state);\r\n }\r\n }\r\n if (state.skipNextObservers) {\r\n return false;\r\n }\r\n }\r\n return true;\r\n }\r\n\r\n /**\r\n * Notify a specific observer\r\n * @param observer defines the observer to notify\r\n * @param eventData defines the data to be sent to each callback\r\n * @param mask is used to filter observers defaults to -1\r\n */\r\n public notifyObserver(observer: Observer<T>, eventData: T, mask: number = -1): void {\r\n // this prevents potential memory leaks - if an object is disposed but the observable doesn't get cleared.\r\n if (this.notifyIfTriggered) {\r\n this._hasNotified = true;\r\n this._lastNotifiedValue = eventData;\r\n }\r\n if (observer._willBeUnregistered) {\r\n return;\r\n }\r\n\r\n const state = this._eventState;\r\n state.mask = mask;\r\n state.skipNextObservers = false;\r\n\r\n if (observer.unregisterOnNextCall) {\r\n this._deferUnregister(observer);\r\n }\r\n\r\n observer.callback(eventData, state);\r\n }\r\n\r\n /**\r\n * Gets a boolean indicating if the observable has at least one observer\r\n * @returns true is the Observable has at least one Observer registered\r\n */\r\n public hasObservers(): boolean {\r\n return this._observers.length - this._numObserversMarkedAsDeleted > 0;\r\n }\r\n\r\n /**\r\n * Clear the list of observers\r\n */\r\n public clear(): void {\r\n while (this._observers.length) {\r\n const o = this._observers.pop();\r\n if (o) {\r\n o._remove = null;\r\n }\r\n }\r\n this._onObserverAdded = null;\r\n this._numObserversMarkedAsDeleted = 0;\r\n this.cleanLastNotifiedState();\r\n }\r\n\r\n /**\r\n * Clean the last notified state - both the internal last value and the has-notified flag\r\n */\r\n public cleanLastNotifiedState(): void {\r\n this._hasNotified = false;\r\n this._lastNotifiedValue = undefined;\r\n }\r\n\r\n /**\r\n * Clone the current observable\r\n * @returns a new observable\r\n */\r\n public clone(): Observable<T> {\r\n const result = new Observable<T>();\r\n\r\n result._observers = this._observers.slice(0);\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Does this observable handles observer registered with a given mask\r\n * @param mask defines the mask to be tested\r\n * @returns whether or not one observer registered with the given mask is handled\r\n **/\r\n public hasSpecificMask(mask: number = -1): boolean {\r\n for (const obs of this._observers) {\r\n if (obs.mask & mask || obs.mask === mask) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n }\r\n}\r\n"]}
@@ -13,6 +13,10 @@ export declare class MorphTargetManager implements IDisposable {
13
13
  static EnableTextureStorage: boolean;
14
14
  /** Maximum number of active morph targets supported in the "vertex attribute" mode (i.e., not the "texture" mode) */
15
15
  static MaxActiveMorphTargetsInVertexAttributeMode: number;
16
+ /**
17
+ * When used in texture mode, if greather than 0, this will override the the morph manager numMaxInfluencers value.
18
+ */
19
+ static ConstantTargetCountForTextureMode: number;
16
20
  private _targets;
17
21
  private _targetInfluenceChangedObservers;
18
22
  private _targetDataLayoutChangedObservers;
@@ -90,6 +94,7 @@ export declare class MorphTargetManager implements IDisposable {
90
94
  * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.
91
95
  * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.
92
96
  * Note that this property has no effect if "useTextureToStoreTargets" is false.
97
+ * Note as well that if MorphTargetManager.ConstantTargetCountForTextureMode is greater than 0, this property will be ignored and the constant value will be used instead.
93
98
  */
94
99
  get numMaxInfluencers(): number;
95
100
  set numMaxInfluencers(value: number);
@@ -107,8 +107,12 @@ export class MorphTargetManager {
107
107
  * If you assign a non-zero value to this property, you need to ensure that this value is greater than the maximum number of (active) influencers you'll need for this morph manager.
108
108
  * Otherwise, the number of active influencers will be truncated at the value you set for this property, which can lead to unexpected results.
109
109
  * Note that this property has no effect if "useTextureToStoreTargets" is false.
110
+ * Note as well that if MorphTargetManager.ConstantTargetCountForTextureMode is greater than 0, this property will be ignored and the constant value will be used instead.
110
111
  */
111
112
  get numMaxInfluencers() {
113
+ if (MorphTargetManager.ConstantTargetCountForTextureMode > 0 && this.isUsingTextureForTargets) {
114
+ return MorphTargetManager.ConstantTargetCountForTextureMode;
115
+ }
112
116
  return this._numMaxInfluencers;
113
117
  }
114
118
  set numMaxInfluencers(value) {
@@ -552,4 +556,8 @@ export class MorphTargetManager {
552
556
  MorphTargetManager.EnableTextureStorage = true;
553
557
  /** Maximum number of active morph targets supported in the "vertex attribute" mode (i.e., not the "texture" mode) */
554
558
  MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode = 8;
559
+ /**
560
+ * When used in texture mode, if greather than 0, this will override the the morph manager numMaxInfluencers value.
561
+ */
562
+ MorphTargetManager.ConstantTargetCountForTextureMode = 0;
555
563
  //# sourceMappingURL=morphTargetManager.js.map