@onerjs/core 8.50.9 → 8.51.2

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 (131) hide show
  1. package/Cameras/Inputs/freeCameraTouchInput.js +5 -3
  2. package/Cameras/Inputs/freeCameraTouchInput.js.map +1 -1
  3. package/Cameras/Inputs/freeCameraVirtualJoystickInput.js +11 -7
  4. package/Cameras/Inputs/freeCameraVirtualJoystickInput.js.map +1 -1
  5. package/Cameras/arcRotateCamera.js +2 -1
  6. package/Cameras/arcRotateCamera.js.map +1 -1
  7. package/Cameras/camera.js +1 -0
  8. package/Cameras/camera.js.map +1 -1
  9. package/Cameras/followCamera.js +1 -1
  10. package/Cameras/followCamera.js.map +1 -1
  11. package/Compute/computeEffect.js +2 -2
  12. package/Compute/computeEffect.js.map +1 -1
  13. package/Culling/ray.core.js +46 -2
  14. package/Culling/ray.core.js.map +1 -1
  15. package/Debug/debugLayer.js +1 -1
  16. package/Debug/debugLayer.js.map +1 -1
  17. package/Engines/abstractEngine.js +2 -2
  18. package/Engines/abstractEngine.js.map +1 -1
  19. package/FrameGraph/Node/nodeRenderGraph.js +11 -3
  20. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  21. package/Layers/layer.js +5 -1
  22. package/Layers/layer.js.map +1 -1
  23. package/LensFlares/lensFlareSystem.js +1 -0
  24. package/LensFlares/lensFlareSystem.js.map +1 -1
  25. package/Lights/Clustered/clusteredLightContainer.js +19 -1
  26. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  27. package/Lights/light.d.ts +5 -0
  28. package/Lights/light.js +18 -2
  29. package/Lights/light.js.map +1 -1
  30. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.d.ts +1 -0
  31. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js +6 -3
  32. package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.js.map +1 -1
  33. package/Materials/GaussianSplatting/gaussianSplattingMaterial.d.ts +2 -0
  34. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +10 -3
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  36. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.d.ts +2 -1
  37. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js +10 -4
  38. package/Materials/GaussianSplatting/gaussianSplattingSolidColorMaterialPlugin.js.map +1 -1
  39. package/Materials/Node/nodeMaterial.js +10 -2
  40. package/Materials/Node/nodeMaterial.js.map +1 -1
  41. package/Materials/PBR/openpbrMaterial.d.ts +31 -0
  42. package/Materials/PBR/openpbrMaterial.js +50 -2
  43. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  44. package/Materials/Textures/envCubeTexture.js +33 -15
  45. package/Materials/Textures/envCubeTexture.js.map +1 -1
  46. package/Materials/effect.functions.js +4 -4
  47. package/Materials/effect.functions.js.map +1 -1
  48. package/Materials/standardMaterial.js +4 -2
  49. package/Materials/standardMaterial.js.map +1 -1
  50. package/Meshes/Node/Blocks/bevelBlock.d.ts +52 -0
  51. package/Meshes/Node/Blocks/bevelBlock.js +1327 -0
  52. package/Meshes/Node/Blocks/bevelBlock.js.map +1 -0
  53. package/Meshes/Node/index.d.ts +1 -0
  54. package/Meshes/Node/index.js +1 -0
  55. package/Meshes/Node/index.js.map +1 -1
  56. package/Meshes/Node/nodeGeometry.js +10 -2
  57. package/Meshes/Node/nodeGeometry.js.map +1 -1
  58. package/Meshes/abstractMesh.js +1 -0
  59. package/Meshes/abstractMesh.js.map +1 -1
  60. package/Misc/snapshotRenderingHelper.d.ts +22 -1
  61. package/Misc/snapshotRenderingHelper.js +101 -0
  62. package/Misc/snapshotRenderingHelper.js.map +1 -1
  63. package/Misc/tools.js +1 -1
  64. package/Misc/tools.js.map +1 -1
  65. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +17 -10
  66. package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -1
  67. package/Particles/Node/Blocks/Update/updateNoiseBlock.js +14 -0
  68. package/Particles/Node/Blocks/Update/updateNoiseBlock.js.map +1 -1
  69. package/Particles/Node/Blocks/particleSourceTextureBlock.js +114 -12
  70. package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
  71. package/Particles/Node/nodeParticleBuildState.d.ts +11 -0
  72. package/Particles/Node/nodeParticleBuildState.js +15 -0
  73. package/Particles/Node/nodeParticleBuildState.js.map +1 -1
  74. package/Particles/Node/nodeParticleSystemSet.js +33 -24
  75. package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
  76. package/Particles/gpuParticleSystem.js +1 -0
  77. package/Particles/gpuParticleSystem.js.map +1 -1
  78. package/Particles/thinParticleSystem.d.ts +13 -0
  79. package/Particles/thinParticleSystem.js +42 -6
  80. package/Particles/thinParticleSystem.js.map +1 -1
  81. package/PostProcesses/postProcessManager.d.ts +2 -0
  82. package/PostProcesses/postProcessManager.js +14 -8
  83. package/PostProcesses/postProcessManager.js.map +1 -1
  84. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js +12 -9
  85. package/Rendering/IBLShadows/iblShadowsVoxelRenderer.js.map +1 -1
  86. package/Rendering/iblCdfGeneratorSceneComponent.d.ts +6 -0
  87. package/Rendering/iblCdfGeneratorSceneComponent.js +16 -0
  88. package/Rendering/iblCdfGeneratorSceneComponent.js.map +1 -1
  89. package/Rendering/prePassRenderer.d.ts +4 -1
  90. package/Rendering/prePassRenderer.js +31 -9
  91. package/Rendering/prePassRenderer.js.map +1 -1
  92. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  93. package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  94. package/Shaders/ShadersInclude/openpbrDirectLighting.js +2 -2
  95. package/Shaders/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  96. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js +8 -2
  97. package/Shaders/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  98. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js +4 -1
  99. package/Shaders/ShadersInclude/openpbrFragmentDeclaration.js.map +1 -1
  100. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  101. package/Shaders/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  102. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  103. package/Shaders/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  104. package/Shaders/ShadersInclude/pbrBRDFFunctions.js +2 -1
  105. package/Shaders/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  106. package/Shaders/openpbr.fragment.js +1 -1
  107. package/Shaders/openpbr.fragment.js.map +1 -1
  108. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +20 -7
  109. package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
  110. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js +2 -2
  111. package/ShadersWGSL/ShadersInclude/openpbrDirectLighting.js.map +1 -1
  112. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js +9 -3
  113. package/ShadersWGSL/ShadersInclude/openpbrEnvironmentLighting.js.map +1 -1
  114. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js +2 -0
  115. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragment.js.map +1 -1
  116. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js +1 -1
  117. package/ShadersWGSL/ShadersInclude/openpbrNormalMapFragmentMainFunctions.js.map +1 -1
  118. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js +1 -1
  119. package/ShadersWGSL/ShadersInclude/openpbrVolumeFunctions.js.map +1 -1
  120. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js +5 -4
  121. package/ShadersWGSL/ShadersInclude/pbrBRDFFunctions.js.map +1 -1
  122. package/ShadersWGSL/ShadersInclude/shadowsVertex.js +4 -0
  123. package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
  124. package/ShadersWGSL/openpbr.fragment.js +1 -1
  125. package/ShadersWGSL/openpbr.fragment.js.map +1 -1
  126. package/Sprites/spriteManager.js +1 -0
  127. package/Sprites/spriteManager.js.map +1 -1
  128. package/package.json +1 -1
  129. package/scene.d.ts +16 -0
  130. package/scene.js +13 -0
  131. package/scene.js.map +1 -1
@@ -214,26 +214,44 @@ export class EnvCubeTexture extends BaseTexture {
214
214
  };
215
215
  if (engine._features.allowTexturePrefiltering && (this._prefilterOnLoad || this._prefilterIrradianceOnLoad)) {
216
216
  const previousOnLoad = this._onLoad;
217
+ const previousOnError = this._onError;
217
218
  const hdrFiltering = new HDRFiltering(engine);
219
+ const prefilterPendingToken = {};
220
+ const scene = this.getScene();
221
+ scene?.addPendingData(prefilterPendingToken);
222
+ this._onError = () => {
223
+ // If the texture load itself fails, _onLoad never runs so the try/finally below
224
+ // never fires. Make sure the pending-data token is still cleared so the scene
225
+ // doesn't stay stuck in isLoading / executeWhenReady.
226
+ scene?.removePendingData(prefilterPendingToken);
227
+ if (previousOnError) {
228
+ previousOnError();
229
+ }
230
+ };
218
231
  this._onLoad = () => {
219
232
  void (async () => {
220
- let irradianceTexture = null;
221
- if (this._prefilterIrradianceOnLoad) {
222
- const hdrIrradianceFiltering = new HDRIrradianceFiltering(engine, { useCdf: this._prefilterUsingCdf });
223
- irradianceTexture = await hdrIrradianceFiltering.prefilter(this);
224
- }
225
- // Run irradiance prefiltering first because it samples the current source texture.
226
- // Radiance prefiltering mutates/swaps the source internal texture, so running both
227
- // concurrently can lead to stale/destroyed texture references on WebGPU.
228
- if (this._prefilterIrradianceOnLoad && irradianceTexture) {
229
- this.irradianceTexture = irradianceTexture;
230
- const scene = this.getScene();
231
- if (scene) {
232
- scene.markAllMaterialsAsDirty(1);
233
+ try {
234
+ let irradianceTexture = null;
235
+ if (this._prefilterIrradianceOnLoad) {
236
+ const hdrIrradianceFiltering = new HDRIrradianceFiltering(engine, { useCdf: this._prefilterUsingCdf });
237
+ irradianceTexture = await hdrIrradianceFiltering.prefilter(this);
238
+ }
239
+ // Run irradiance prefiltering first because it samples the current source texture.
240
+ // Radiance prefiltering mutates/swaps the source internal texture, so running both
241
+ // concurrently can lead to stale/destroyed texture references on WebGPU.
242
+ if (this._prefilterIrradianceOnLoad && irradianceTexture) {
243
+ this.irradianceTexture = irradianceTexture;
244
+ const innerScene = this.getScene();
245
+ if (innerScene) {
246
+ innerScene.markAllMaterialsAsDirty(1);
247
+ }
248
+ }
249
+ if (this._prefilterOnLoad) {
250
+ await hdrFiltering.prefilter(this);
233
251
  }
234
252
  }
235
- if (this._prefilterOnLoad) {
236
- await hdrFiltering.prefilter(this);
253
+ finally {
254
+ scene?.removePendingData(prefilterPendingToken);
237
255
  }
238
256
  if (previousOnLoad) {
239
257
  previousOnLoad();
@@ -1 +1 @@
1
- {"version":3,"file":"envCubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/envCubeTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,0DAA0D,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB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,GAAG,aAAa,CAAC,KAAK,CAAC;QACxC,CAAC;IACL,CAAC;;AA7cc,4BAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,AAAnD,CAAoD","sourcesContent":["import { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { Matrix, Vector3 } from \"../../Maths/math.vector\";\r\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { CubeMapToSphericalPolynomialTools } from \"../../Misc/HighDynamicRange/cubemapToSphericalPolynomial\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { ToGammaSpace } from \"../../Maths/math.constants\";\r\nimport { type AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport { HDRFiltering } from \"../../Materials/Textures/Filtering/hdrFiltering\";\r\nimport { HDRIrradianceFiltering } from \"../../Materials/Textures/Filtering/hdrIrradianceFiltering\";\r\nimport { ToHalfFloat } from \"../../Misc/textureTools\";\r\nimport \"../../Materials/Textures/baseTexture.polynomial\";\r\nimport { type CubeMapInfo } from \"../../Misc/HighDynamicRange/panoramaToCubemap\";\r\nimport { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * This represents an environment base texture which could for instance be from HDR or EXR files.\r\n */\r\nexport abstract class EnvCubeTexture extends BaseTexture {\r\n private static _FacesMapping = [\"right\", \"left\", \"up\", \"down\", \"front\", \"back\"];\r\n\r\n protected _generateHarmonics = true;\r\n protected _noMipmap: boolean;\r\n protected _size: number;\r\n\r\n private _prefilterOnLoad: boolean;\r\n private _prefilterIrradianceOnLoad: boolean;\r\n private _prefilterUsingCdf: boolean;\r\n private _textureMatrix: Matrix;\r\n private _supersample: boolean;\r\n private _onLoad: () => void;\r\n private _onError: Nullable<() => void> = null;\r\n\r\n /**\r\n * The texture URL.\r\n */\r\n public url: string;\r\n\r\n protected _isBlocking: boolean = true;\r\n /**\r\n * Sets whether or not the texture is blocking during loading.\r\n */\r\n public override set isBlocking(value: boolean) {\r\n this._isBlocking = value;\r\n }\r\n /**\r\n * Gets whether or not the texture is blocking during loading.\r\n */\r\n public override get isBlocking(): boolean {\r\n return this._isBlocking;\r\n }\r\n\r\n protected _rotationY: number = 0;\r\n /**\r\n * Sets texture matrix rotation angle around Y axis in radians.\r\n */\r\n public set rotationY(value: number) {\r\n this._rotationY = value;\r\n this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY));\r\n }\r\n /**\r\n * Gets texture matrix rotation angle around Y axis radians.\r\n */\r\n public get rotationY(): number {\r\n return this._rotationY;\r\n }\r\n\r\n /**\r\n * Gets or sets the center of the bounding box associated with the cube texture\r\n * It must define where the camera used to render the texture was set\r\n */\r\n public boundingBoxPosition = Vector3.Zero();\r\n\r\n private _boundingBoxSize: Vector3;\r\n\r\n /**\r\n * Gets or sets the size of the bounding box associated with the cube texture\r\n * When defined, the cubemap will switch to local mode\r\n * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity\r\n * @example https://www.babylonjs-playground.com/#RNASML\r\n */\r\n public set boundingBoxSize(value: Vector3) {\r\n if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {\r\n return;\r\n }\r\n this._boundingBoxSize = value;\r\n const scene = this.getScene();\r\n if (scene) {\r\n scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n }\r\n public get boundingBoxSize(): Vector3 {\r\n return this._boundingBoxSize;\r\n }\r\n\r\n /**\r\n * Observable triggered once the texture has been loaded.\r\n */\r\n public onLoadObservable: Observable<EnvCubeTexture> = new Observable<EnvCubeTexture>();\r\n\r\n /**\r\n * Instantiates an EnvCubeTexture from the following parameters.\r\n *\r\n * @param url The location of the raw data (Panorama stored in RGBE format)\r\n * @param sceneOrEngine The scene or engine the texture will be used in\r\n * @param size The cubemap desired size (the more it increases the longer the generation will be)\r\n * @param noMipmap Forces to not generate the mipmap if true\r\n * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process\r\n * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)\r\n * @param prefilterOnLoad Prefilters texture to allow use of this texture as a PBR reflection texture.\r\n * @param onLoad on success callback function\r\n * @param onError on error callback function\r\n * @param supersample Defines if texture must be supersampled (default: false)\r\n * @param prefilterIrradianceOnLoad Prefilters texture to allow use of this texture for irradiance lighting.\r\n * @param prefilterUsingCdf Defines if the prefiltering should be done using a CDF instead of the default approach.\r\n * @param sphericalPolynomialTargetSize Target face size for spherical polynomial computation. 0 = full resolution (default).\r\n */\r\n constructor(\r\n url: string,\r\n sceneOrEngine: Scene | AbstractEngine,\r\n size: number,\r\n noMipmap = false,\r\n generateHarmonics = true,\r\n gammaSpace = false,\r\n prefilterOnLoad = false,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n supersample = false,\r\n prefilterIrradianceOnLoad = false,\r\n prefilterUsingCdf = false,\r\n sphericalPolynomialTargetSize = 0\r\n ) {\r\n super(sceneOrEngine);\r\n\r\n if (!url) {\r\n return;\r\n }\r\n\r\n this._coordinatesMode = Texture.CUBIC_MODE;\r\n this.name = url;\r\n this.url = url;\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n this._textureMatrix = Matrix.Identity();\r\n this._prefilterOnLoad = prefilterOnLoad;\r\n this._prefilterIrradianceOnLoad = prefilterIrradianceOnLoad;\r\n this._prefilterUsingCdf = prefilterUsingCdf;\r\n this._onLoad = () => {\r\n this.onLoadObservable.notifyObservers(this);\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._onError = onError;\r\n this.gammaSpace = gammaSpace;\r\n\r\n this._noMipmap = noMipmap;\r\n this._size = size;\r\n // CDF is very sensitive to lost precision due to downsampling. This can result in\r\n // noticeable brightness differences with different resolutions. Enabling supersampling\r\n // mitigates this.\r\n this._supersample = supersample || prefilterUsingCdf;\r\n this._generateHarmonics = generateHarmonics;\r\n this._sphericalPolynomialTargetSize = sphericalPolynomialTargetSize;\r\n\r\n this.updateURL(url);\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"EnvCubeTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"EnvCubeTexture\";\r\n }\r\n\r\n /**\r\n * Convert the raw data from the server into cubemap faces\r\n * @param buffer The buffer containing the texture data\r\n * @param size The cubemap face size\r\n * @param supersample Defines if texture must be supersampled\r\n * @returns The cube map data\r\n */\r\n protected abstract _getCubeMapTextureDataAsync(buffer: ArrayBuffer, size: number, supersample: boolean): Promise<CubeMapInfo>;\r\n\r\n /**\r\n * Occurs when the file has been loaded.\r\n */\r\n private _loadTexture() {\r\n const engine = this._getEngine()!;\r\n const caps = engine.getCaps();\r\n\r\n let textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (caps.textureFloat && caps.textureFloatLinearFiltering) {\r\n textureType = Constants.TEXTURETYPE_FLOAT;\r\n } else if (caps.textureHalfFloat && caps.textureHalfFloatLinearFiltering) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n const callback = async (buffer: ArrayBuffer): Promise<ArrayBufferView<ArrayBufferLike>[]> => {\r\n this.lodGenerationOffset = 0.0;\r\n this.lodGenerationScale = 0.8;\r\n\r\n // Extract the raw linear data.\r\n const data = await this._getCubeMapTextureDataAsync(buffer, this._size, this._supersample);\r\n\r\n // Generate harmonics if needed.\r\n if (this._generateHarmonics) {\r\n const sphericalPolynomial = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(data, this._sphericalPolynomialTargetSize);\r\n this.sphericalPolynomial = sphericalPolynomial;\r\n }\r\n\r\n const results = [];\r\n\r\n let byteArray: Nullable<Uint8Array> = null;\r\n let shortArray: Nullable<Uint16Array> = null;\r\n\r\n // Push each faces.\r\n for (let j = 0; j < 6; j++) {\r\n // Create fallback array\r\n if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n shortArray = new Uint16Array(this._size * this._size * 3);\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_BYTE) {\r\n // 3 channels of 1 bytes per pixel in bytes.\r\n byteArray = new Uint8Array(this._size * this._size * 3);\r\n }\r\n\r\n const dataFace = <Float32Array>(<any>data)[EnvCubeTexture._FacesMapping[j]];\r\n\r\n // If special cases.\r\n if (this.gammaSpace || shortArray || byteArray) {\r\n for (let i = 0; i < this._size * this._size; i++) {\r\n // Put in gamma space if requested.\r\n if (this.gammaSpace) {\r\n dataFace[i * 3 + 0] = Math.pow(dataFace[i * 3 + 0], ToGammaSpace);\r\n dataFace[i * 3 + 1] = Math.pow(dataFace[i * 3 + 1], ToGammaSpace);\r\n dataFace[i * 3 + 2] = Math.pow(dataFace[i * 3 + 2], ToGammaSpace);\r\n }\r\n\r\n // Convert to half float texture for fallback.\r\n if (shortArray) {\r\n shortArray[i * 3 + 0] = ToHalfFloat(dataFace[i * 3 + 0]);\r\n shortArray[i * 3 + 1] = ToHalfFloat(dataFace[i * 3 + 1]);\r\n shortArray[i * 3 + 2] = ToHalfFloat(dataFace[i * 3 + 2]);\r\n }\r\n\r\n // Convert to int texture for fallback.\r\n if (byteArray) {\r\n let r = Math.max(dataFace[i * 3 + 0] * 255, 0);\r\n let g = Math.max(dataFace[i * 3 + 1] * 255, 0);\r\n let b = Math.max(dataFace[i * 3 + 2] * 255, 0);\r\n\r\n // May use luminance instead if the result is not accurate.\r\n const max = Math.max(Math.max(r, g), b);\r\n if (max > 255) {\r\n const scale = 255 / max;\r\n r *= scale;\r\n g *= scale;\r\n b *= scale;\r\n }\r\n\r\n byteArray[i * 3 + 0] = r;\r\n byteArray[i * 3 + 1] = g;\r\n byteArray[i * 3 + 2] = b;\r\n }\r\n }\r\n }\r\n\r\n if (shortArray) {\r\n results.push(shortArray);\r\n } else if (byteArray) {\r\n results.push(byteArray);\r\n } else {\r\n results.push(dataFace);\r\n }\r\n }\r\n\r\n return results;\r\n };\r\n\r\n if (engine._features.allowTexturePrefiltering && (this._prefilterOnLoad || this._prefilterIrradianceOnLoad)) {\r\n const previousOnLoad = this._onLoad;\r\n const hdrFiltering = new HDRFiltering(engine);\r\n this._onLoad = () => {\r\n void (async () => {\r\n let irradianceTexture: Nullable<BaseTexture> = null;\r\n if (this._prefilterIrradianceOnLoad) {\r\n const hdrIrradianceFiltering = new HDRIrradianceFiltering(engine, { useCdf: this._prefilterUsingCdf });\r\n irradianceTexture = await hdrIrradianceFiltering.prefilter(this);\r\n }\r\n\r\n // Run irradiance prefiltering first because it samples the current source texture.\r\n // Radiance prefiltering mutates/swaps the source internal texture, so running both\r\n // concurrently can lead to stale/destroyed texture references on WebGPU.\r\n if (this._prefilterIrradianceOnLoad && irradianceTexture) {\r\n this.irradianceTexture = irradianceTexture;\r\n const scene = this.getScene();\r\n if (scene) {\r\n scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n }\r\n\r\n if (this._prefilterOnLoad) {\r\n await hdrFiltering.prefilter(this);\r\n }\r\n\r\n if (previousOnLoad) {\r\n previousOnLoad();\r\n }\r\n })();\r\n };\r\n }\r\n\r\n this._texture = engine.createRawCubeTextureFromUrl(\r\n this.url,\r\n this.getScene(),\r\n this._size,\r\n Constants.TEXTUREFORMAT_RGB,\r\n textureType,\r\n this._noMipmap,\r\n callback,\r\n null,\r\n this._onLoad,\r\n this._onError\r\n );\r\n\r\n if (!this._generateHarmonics && !this._texture._sphericalPolynomial) {\r\n this._texture._sphericalPolynomial = new SphericalPolynomial();\r\n }\r\n }\r\n\r\n /**\r\n * Refresh envCubeTexture current url\r\n * @param url\r\n */\r\n public updateURL(url: string) {\r\n this._texture = this._getFromCache(url, this._noMipmap, undefined, undefined, undefined, this.isCube);\r\n\r\n if (!this._texture) {\r\n if (!this.getScene()?.useDelayedTextureLoading) {\r\n this._loadTexture();\r\n } else {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n }\r\n } else {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => this._onLoad());\r\n } else {\r\n this._texture.onLoadedObservable.add(this._onLoad);\r\n }\r\n }\r\n }\r\n\r\n // Methods\r\n public override delayLoad(): void {\r\n if (this.delayLoadState !== Constants.DELAYLOADSTATE_NOTLOADED) {\r\n return;\r\n }\r\n\r\n this.delayLoadState = Constants.DELAYLOADSTATE_LOADED;\r\n this._texture = this._getFromCache(this.url, this._noMipmap);\r\n\r\n if (!this._texture) {\r\n this._loadTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Get the texture reflection matrix used to rotate/transform the reflection.\r\n * @returns the reflection matrix\r\n */\r\n public override getReflectionTextureMatrix(): Matrix {\r\n return this._textureMatrix;\r\n }\r\n\r\n /**\r\n * Set the texture reflection matrix used to rotate/transform the reflection.\r\n * @param value Define the reflection matrix to set\r\n */\r\n public setReflectionTextureMatrix(value: Matrix): void {\r\n this._textureMatrix = value;\r\n\r\n if (value.updateFlag === this._textureMatrix.updateFlag) {\r\n return;\r\n }\r\n\r\n if (value.isIdentity() !== this._textureMatrix.isIdentity()) {\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => mat.getActiveTextures().indexOf(this) !== -1);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public override dispose(): void {\r\n this.onLoadObservable.clear();\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Serializes the texture to a JSON representation.\r\n * @returns the JSON representation\r\n */\r\n public override serialize(): any {\r\n if (!this.name) {\r\n return null;\r\n }\r\n\r\n const serializationObject: any = {};\r\n serializationObject.name = this.name;\r\n serializationObject.url = this.url;\r\n serializationObject.hasAlpha = this.hasAlpha;\r\n serializationObject.isCube = true;\r\n serializationObject.level = this.level;\r\n serializationObject.size = this._size;\r\n serializationObject.coordinatesMode = this.coordinatesMode;\r\n serializationObject.useInGammaSpace = this.gammaSpace;\r\n serializationObject.generateHarmonics = this._generateHarmonics;\r\n serializationObject.noMipmap = this._noMipmap;\r\n serializationObject.isBlocking = this._isBlocking;\r\n serializationObject.rotationY = this._rotationY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n serializationObject.wrapU = this.wrapU;\r\n serializationObject.wrapV = this.wrapV;\r\n serializationObject.wrapR = this.wrapR;\r\n serializationObject.supersample = this._supersample;\r\n serializationObject.prefilterIrradianceOnLoad = this._prefilterIrradianceOnLoad;\r\n serializationObject.prefilterOnLoad = this._prefilterOnLoad;\r\n serializationObject.prefilterUsingCdf = this._prefilterUsingCdf;\r\n serializationObject.metadata = this.metadata;\r\n\r\n return serializationObject;\r\n }\r\n\r\n protected abstract _instantiateClone(): this;\r\n\r\n /**\r\n * Clones the current texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): this {\r\n const newTexture = this._instantiateClone();\r\n\r\n // Base Texture\r\n newTexture.level = this.level;\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n newTexture.coordinatesIndex = this.coordinatesIndex;\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n\r\n protected static _Parse(parsedTexture: any, texture: EnvCubeTexture): void {\r\n texture.name = parsedTexture.name;\r\n texture.hasAlpha = parsedTexture.hasAlpha;\r\n texture.level = parsedTexture.level;\r\n texture.coordinatesMode = parsedTexture.coordinatesMode;\r\n texture.isBlocking = parsedTexture.isBlocking;\r\n texture.metadata = parsedTexture.metadata;\r\n if (parsedTexture.boundingBoxPosition) {\r\n texture.boundingBoxPosition = Vector3.FromArray(parsedTexture.boundingBoxPosition);\r\n }\r\n if (parsedTexture.boundingBoxSize) {\r\n texture.boundingBoxSize = Vector3.FromArray(parsedTexture.boundingBoxSize);\r\n }\r\n if (parsedTexture.rotationY) {\r\n texture.rotationY = parsedTexture.rotationY;\r\n }\r\n if (parsedTexture.samplingMode !== null && parsedTexture.samplingMode !== undefined) {\r\n texture.updateSamplingMode(parsedTexture.samplingMode);\r\n }\r\n if (parsedTexture.wrapU !== null && parsedTexture.wrapU !== undefined) {\r\n texture.wrapU = parsedTexture.wrapU;\r\n }\r\n if (parsedTexture.wrapV !== null && parsedTexture.wrapV !== undefined) {\r\n texture.wrapV = parsedTexture.wrapV;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"envCubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/envCubeTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,iCAAiC,EAAE,MAAM,0DAA0D,CAAC;AAC7G,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,iDAAiD,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAgB,cAAe,SAAQ,WAAW;IAqBpD;;OAEG;IACH,IAAoB,UAAU,CAAC,KAAc;QACzC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,CAAC;IACD;;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AC,CAAC;QAC3D,CAAC;QACD,IAAI,aAAa,CAAC,KAAK,KAAK,IAAI,IAAI,aAAa,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACpE,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;QACxC,CAAC;QACD,IAAI,aAAa,CAAC,KAAK,KAAK,IAAI,IAAI,aAAa,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACpE,OAAO,CAAC,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;QACxC,CAAC;IACL,CAAC;;AA9dc,4BAAa,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,AAAnD,CAAoD","sourcesContent":["import { type Nullable } from \"../../types\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { Matrix, Vector3 } from \"../../Maths/math.vector\";\r\nimport { BaseTexture } from \"../../Materials/Textures/baseTexture\";\r\nimport { Texture } from \"../../Materials/Textures/texture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { CubeMapToSphericalPolynomialTools } from \"../../Misc/HighDynamicRange/cubemapToSphericalPolynomial\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport { ToGammaSpace } from \"../../Maths/math.constants\";\r\nimport { type AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport { HDRFiltering } from \"../../Materials/Textures/Filtering/hdrFiltering\";\r\nimport { HDRIrradianceFiltering } from \"../../Materials/Textures/Filtering/hdrIrradianceFiltering\";\r\nimport { ToHalfFloat } from \"../../Misc/textureTools\";\r\nimport \"../../Materials/Textures/baseTexture.polynomial\";\r\nimport { type CubeMapInfo } from \"../../Misc/HighDynamicRange/panoramaToCubemap\";\r\nimport { SphericalPolynomial } from \"../../Maths/sphericalPolynomial\";\r\n\r\n/**\r\n * This represents an environment base texture which could for instance be from HDR or EXR files.\r\n */\r\nexport abstract class EnvCubeTexture extends BaseTexture {\r\n private static _FacesMapping = [\"right\", \"left\", \"up\", \"down\", \"front\", \"back\"];\r\n\r\n protected _generateHarmonics = true;\r\n protected _noMipmap: boolean;\r\n protected _size: number;\r\n\r\n private _prefilterOnLoad: boolean;\r\n private _prefilterIrradianceOnLoad: boolean;\r\n private _prefilterUsingCdf: boolean;\r\n private _textureMatrix: Matrix;\r\n private _supersample: boolean;\r\n private _onLoad: () => void;\r\n private _onError: Nullable<() => void> = null;\r\n\r\n /**\r\n * The texture URL.\r\n */\r\n public url: string;\r\n\r\n protected _isBlocking: boolean = true;\r\n /**\r\n * Sets whether or not the texture is blocking during loading.\r\n */\r\n public override set isBlocking(value: boolean) {\r\n this._isBlocking = value;\r\n }\r\n /**\r\n * Gets whether or not the texture is blocking during loading.\r\n */\r\n public override get isBlocking(): boolean {\r\n return this._isBlocking;\r\n }\r\n\r\n protected _rotationY: number = 0;\r\n /**\r\n * Sets texture matrix rotation angle around Y axis in radians.\r\n */\r\n public set rotationY(value: number) {\r\n this._rotationY = value;\r\n this.setReflectionTextureMatrix(Matrix.RotationY(this._rotationY));\r\n }\r\n /**\r\n * Gets texture matrix rotation angle around Y axis radians.\r\n */\r\n public get rotationY(): number {\r\n return this._rotationY;\r\n }\r\n\r\n /**\r\n * Gets or sets the center of the bounding box associated with the cube texture\r\n * It must define where the camera used to render the texture was set\r\n */\r\n public boundingBoxPosition = Vector3.Zero();\r\n\r\n private _boundingBoxSize: Vector3;\r\n\r\n /**\r\n * Gets or sets the size of the bounding box associated with the cube texture\r\n * When defined, the cubemap will switch to local mode\r\n * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity\r\n * @example https://www.babylonjs-playground.com/#RNASML\r\n */\r\n public set boundingBoxSize(value: Vector3) {\r\n if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {\r\n return;\r\n }\r\n this._boundingBoxSize = value;\r\n const scene = this.getScene();\r\n if (scene) {\r\n scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n }\r\n public get boundingBoxSize(): Vector3 {\r\n return this._boundingBoxSize;\r\n }\r\n\r\n /**\r\n * Observable triggered once the texture has been loaded.\r\n */\r\n public onLoadObservable: Observable<EnvCubeTexture> = new Observable<EnvCubeTexture>();\r\n\r\n /**\r\n * Instantiates an EnvCubeTexture from the following parameters.\r\n *\r\n * @param url The location of the raw data (Panorama stored in RGBE format)\r\n * @param sceneOrEngine The scene or engine the texture will be used in\r\n * @param size The cubemap desired size (the more it increases the longer the generation will be)\r\n * @param noMipmap Forces to not generate the mipmap if true\r\n * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process\r\n * @param gammaSpace Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)\r\n * @param prefilterOnLoad Prefilters texture to allow use of this texture as a PBR reflection texture.\r\n * @param onLoad on success callback function\r\n * @param onError on error callback function\r\n * @param supersample Defines if texture must be supersampled (default: false)\r\n * @param prefilterIrradianceOnLoad Prefilters texture to allow use of this texture for irradiance lighting.\r\n * @param prefilterUsingCdf Defines if the prefiltering should be done using a CDF instead of the default approach.\r\n * @param sphericalPolynomialTargetSize Target face size for spherical polynomial computation. 0 = full resolution (default).\r\n */\r\n constructor(\r\n url: string,\r\n sceneOrEngine: Scene | AbstractEngine,\r\n size: number,\r\n noMipmap = false,\r\n generateHarmonics = true,\r\n gammaSpace = false,\r\n prefilterOnLoad = false,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n supersample = false,\r\n prefilterIrradianceOnLoad = false,\r\n prefilterUsingCdf = false,\r\n sphericalPolynomialTargetSize = 0\r\n ) {\r\n super(sceneOrEngine);\r\n\r\n if (!url) {\r\n return;\r\n }\r\n\r\n this._coordinatesMode = Texture.CUBIC_MODE;\r\n this.name = url;\r\n this.url = url;\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n this._textureMatrix = Matrix.Identity();\r\n this._prefilterOnLoad = prefilterOnLoad;\r\n this._prefilterIrradianceOnLoad = prefilterIrradianceOnLoad;\r\n this._prefilterUsingCdf = prefilterUsingCdf;\r\n this._onLoad = () => {\r\n this.onLoadObservable.notifyObservers(this);\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._onError = onError;\r\n this.gammaSpace = gammaSpace;\r\n\r\n this._noMipmap = noMipmap;\r\n this._size = size;\r\n // CDF is very sensitive to lost precision due to downsampling. This can result in\r\n // noticeable brightness differences with different resolutions. Enabling supersampling\r\n // mitigates this.\r\n this._supersample = supersample || prefilterUsingCdf;\r\n this._generateHarmonics = generateHarmonics;\r\n this._sphericalPolynomialTargetSize = sphericalPolynomialTargetSize;\r\n\r\n this.updateURL(url);\r\n }\r\n\r\n /**\r\n * Get the current class name of the texture useful for serialization or dynamic coding.\r\n * @returns \"EnvCubeTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"EnvCubeTexture\";\r\n }\r\n\r\n /**\r\n * Convert the raw data from the server into cubemap faces\r\n * @param buffer The buffer containing the texture data\r\n * @param size The cubemap face size\r\n * @param supersample Defines if texture must be supersampled\r\n * @returns The cube map data\r\n */\r\n protected abstract _getCubeMapTextureDataAsync(buffer: ArrayBuffer, size: number, supersample: boolean): Promise<CubeMapInfo>;\r\n\r\n /**\r\n * Occurs when the file has been loaded.\r\n */\r\n private _loadTexture() {\r\n const engine = this._getEngine()!;\r\n const caps = engine.getCaps();\r\n\r\n let textureType = Constants.TEXTURETYPE_UNSIGNED_BYTE;\r\n if (caps.textureFloat && caps.textureFloatLinearFiltering) {\r\n textureType = Constants.TEXTURETYPE_FLOAT;\r\n } else if (caps.textureHalfFloat && caps.textureHalfFloatLinearFiltering) {\r\n textureType = Constants.TEXTURETYPE_HALF_FLOAT;\r\n }\r\n\r\n // eslint-disable-next-line no-restricted-syntax\r\n const callback = async (buffer: ArrayBuffer): Promise<ArrayBufferView<ArrayBufferLike>[]> => {\r\n this.lodGenerationOffset = 0.0;\r\n this.lodGenerationScale = 0.8;\r\n\r\n // Extract the raw linear data.\r\n const data = await this._getCubeMapTextureDataAsync(buffer, this._size, this._supersample);\r\n\r\n // Generate harmonics if needed.\r\n if (this._generateHarmonics) {\r\n const sphericalPolynomial = CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(data, this._sphericalPolynomialTargetSize);\r\n this.sphericalPolynomial = sphericalPolynomial;\r\n }\r\n\r\n const results = [];\r\n\r\n let byteArray: Nullable<Uint8Array> = null;\r\n let shortArray: Nullable<Uint16Array> = null;\r\n\r\n // Push each faces.\r\n for (let j = 0; j < 6; j++) {\r\n // Create fallback array\r\n if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n shortArray = new Uint16Array(this._size * this._size * 3);\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_BYTE) {\r\n // 3 channels of 1 bytes per pixel in bytes.\r\n byteArray = new Uint8Array(this._size * this._size * 3);\r\n }\r\n\r\n const dataFace = <Float32Array>(<any>data)[EnvCubeTexture._FacesMapping[j]];\r\n\r\n // If special cases.\r\n if (this.gammaSpace || shortArray || byteArray) {\r\n for (let i = 0; i < this._size * this._size; i++) {\r\n // Put in gamma space if requested.\r\n if (this.gammaSpace) {\r\n dataFace[i * 3 + 0] = Math.pow(dataFace[i * 3 + 0], ToGammaSpace);\r\n dataFace[i * 3 + 1] = Math.pow(dataFace[i * 3 + 1], ToGammaSpace);\r\n dataFace[i * 3 + 2] = Math.pow(dataFace[i * 3 + 2], ToGammaSpace);\r\n }\r\n\r\n // Convert to half float texture for fallback.\r\n if (shortArray) {\r\n shortArray[i * 3 + 0] = ToHalfFloat(dataFace[i * 3 + 0]);\r\n shortArray[i * 3 + 1] = ToHalfFloat(dataFace[i * 3 + 1]);\r\n shortArray[i * 3 + 2] = ToHalfFloat(dataFace[i * 3 + 2]);\r\n }\r\n\r\n // Convert to int texture for fallback.\r\n if (byteArray) {\r\n let r = Math.max(dataFace[i * 3 + 0] * 255, 0);\r\n let g = Math.max(dataFace[i * 3 + 1] * 255, 0);\r\n let b = Math.max(dataFace[i * 3 + 2] * 255, 0);\r\n\r\n // May use luminance instead if the result is not accurate.\r\n const max = Math.max(Math.max(r, g), b);\r\n if (max > 255) {\r\n const scale = 255 / max;\r\n r *= scale;\r\n g *= scale;\r\n b *= scale;\r\n }\r\n\r\n byteArray[i * 3 + 0] = r;\r\n byteArray[i * 3 + 1] = g;\r\n byteArray[i * 3 + 2] = b;\r\n }\r\n }\r\n }\r\n\r\n if (shortArray) {\r\n results.push(shortArray);\r\n } else if (byteArray) {\r\n results.push(byteArray);\r\n } else {\r\n results.push(dataFace);\r\n }\r\n }\r\n\r\n return results;\r\n };\r\n\r\n if (engine._features.allowTexturePrefiltering && (this._prefilterOnLoad || this._prefilterIrradianceOnLoad)) {\r\n const previousOnLoad = this._onLoad;\r\n const previousOnError = this._onError;\r\n const hdrFiltering = new HDRFiltering(engine);\r\n const prefilterPendingToken = {};\r\n const scene = this.getScene();\r\n scene?.addPendingData(prefilterPendingToken);\r\n this._onError = () => {\r\n // If the texture load itself fails, _onLoad never runs so the try/finally below\r\n // never fires. Make sure the pending-data token is still cleared so the scene\r\n // doesn't stay stuck in isLoading / executeWhenReady.\r\n scene?.removePendingData(prefilterPendingToken);\r\n if (previousOnError) {\r\n previousOnError();\r\n }\r\n };\r\n this._onLoad = () => {\r\n void (async () => {\r\n try {\r\n let irradianceTexture: Nullable<BaseTexture> = null;\r\n if (this._prefilterIrradianceOnLoad) {\r\n const hdrIrradianceFiltering = new HDRIrradianceFiltering(engine, { useCdf: this._prefilterUsingCdf });\r\n irradianceTexture = await hdrIrradianceFiltering.prefilter(this);\r\n }\r\n\r\n // Run irradiance prefiltering first because it samples the current source texture.\r\n // Radiance prefiltering mutates/swaps the source internal texture, so running both\r\n // concurrently can lead to stale/destroyed texture references on WebGPU.\r\n if (this._prefilterIrradianceOnLoad && irradianceTexture) {\r\n this.irradianceTexture = irradianceTexture;\r\n const innerScene = this.getScene();\r\n if (innerScene) {\r\n innerScene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n }\r\n\r\n if (this._prefilterOnLoad) {\r\n await hdrFiltering.prefilter(this);\r\n }\r\n } finally {\r\n scene?.removePendingData(prefilterPendingToken);\r\n }\r\n\r\n if (previousOnLoad) {\r\n previousOnLoad();\r\n }\r\n })();\r\n };\r\n }\r\n\r\n this._texture = engine.createRawCubeTextureFromUrl(\r\n this.url,\r\n this.getScene(),\r\n this._size,\r\n Constants.TEXTUREFORMAT_RGB,\r\n textureType,\r\n this._noMipmap,\r\n callback,\r\n null,\r\n this._onLoad,\r\n this._onError\r\n );\r\n\r\n if (!this._generateHarmonics && !this._texture._sphericalPolynomial) {\r\n this._texture._sphericalPolynomial = new SphericalPolynomial();\r\n }\r\n }\r\n\r\n /**\r\n * Refresh envCubeTexture current url\r\n * @param url\r\n */\r\n public updateURL(url: string) {\r\n this._texture = this._getFromCache(url, this._noMipmap, undefined, undefined, undefined, this.isCube);\r\n\r\n if (!this._texture) {\r\n if (!this.getScene()?.useDelayedTextureLoading) {\r\n this._loadTexture();\r\n } else {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n }\r\n } else {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => this._onLoad());\r\n } else {\r\n this._texture.onLoadedObservable.add(this._onLoad);\r\n }\r\n }\r\n }\r\n\r\n // Methods\r\n public override delayLoad(): void {\r\n if (this.delayLoadState !== Constants.DELAYLOADSTATE_NOTLOADED) {\r\n return;\r\n }\r\n\r\n this.delayLoadState = Constants.DELAYLOADSTATE_LOADED;\r\n this._texture = this._getFromCache(this.url, this._noMipmap);\r\n\r\n if (!this._texture) {\r\n this._loadTexture();\r\n }\r\n }\r\n\r\n /**\r\n * Get the texture reflection matrix used to rotate/transform the reflection.\r\n * @returns the reflection matrix\r\n */\r\n public override getReflectionTextureMatrix(): Matrix {\r\n return this._textureMatrix;\r\n }\r\n\r\n /**\r\n * Set the texture reflection matrix used to rotate/transform the reflection.\r\n * @param value Define the reflection matrix to set\r\n */\r\n public setReflectionTextureMatrix(value: Matrix): void {\r\n this._textureMatrix = value;\r\n\r\n if (value.updateFlag === this._textureMatrix.updateFlag) {\r\n return;\r\n }\r\n\r\n if (value.isIdentity() !== this._textureMatrix.isIdentity()) {\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => mat.getActiveTextures().indexOf(this) !== -1);\r\n }\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public override dispose(): void {\r\n this.onLoadObservable.clear();\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Serializes the texture to a JSON representation.\r\n * @returns the JSON representation\r\n */\r\n public override serialize(): any {\r\n if (!this.name) {\r\n return null;\r\n }\r\n\r\n const serializationObject: any = {};\r\n serializationObject.name = this.name;\r\n serializationObject.url = this.url;\r\n serializationObject.hasAlpha = this.hasAlpha;\r\n serializationObject.isCube = true;\r\n serializationObject.level = this.level;\r\n serializationObject.size = this._size;\r\n serializationObject.coordinatesMode = this.coordinatesMode;\r\n serializationObject.useInGammaSpace = this.gammaSpace;\r\n serializationObject.generateHarmonics = this._generateHarmonics;\r\n serializationObject.noMipmap = this._noMipmap;\r\n serializationObject.isBlocking = this._isBlocking;\r\n serializationObject.rotationY = this._rotationY;\r\n serializationObject.samplingMode = this.samplingMode;\r\n serializationObject.wrapU = this.wrapU;\r\n serializationObject.wrapV = this.wrapV;\r\n serializationObject.wrapR = this.wrapR;\r\n serializationObject.supersample = this._supersample;\r\n serializationObject.prefilterIrradianceOnLoad = this._prefilterIrradianceOnLoad;\r\n serializationObject.prefilterOnLoad = this._prefilterOnLoad;\r\n serializationObject.prefilterUsingCdf = this._prefilterUsingCdf;\r\n serializationObject.metadata = this.metadata;\r\n\r\n return serializationObject;\r\n }\r\n\r\n protected abstract _instantiateClone(): this;\r\n\r\n /**\r\n * Clones the current texture.\r\n * @returns the cloned texture\r\n */\r\n public override clone(): this {\r\n const newTexture = this._instantiateClone();\r\n\r\n // Base Texture\r\n newTexture.level = this.level;\r\n newTexture.wrapU = this.wrapU;\r\n newTexture.wrapV = this.wrapV;\r\n newTexture.coordinatesIndex = this.coordinatesIndex;\r\n newTexture.coordinatesMode = this.coordinatesMode;\r\n\r\n return newTexture;\r\n }\r\n\r\n protected static _Parse(parsedTexture: any, texture: EnvCubeTexture): void {\r\n texture.name = parsedTexture.name;\r\n texture.hasAlpha = parsedTexture.hasAlpha;\r\n texture.level = parsedTexture.level;\r\n texture.coordinatesMode = parsedTexture.coordinatesMode;\r\n texture.isBlocking = parsedTexture.isBlocking;\r\n texture.metadata = parsedTexture.metadata;\r\n if (parsedTexture.boundingBoxPosition) {\r\n texture.boundingBoxPosition = Vector3.FromArray(parsedTexture.boundingBoxPosition);\r\n }\r\n if (parsedTexture.boundingBoxSize) {\r\n texture.boundingBoxSize = Vector3.FromArray(parsedTexture.boundingBoxSize);\r\n }\r\n if (parsedTexture.rotationY) {\r\n texture.rotationY = parsedTexture.rotationY;\r\n }\r\n if (parsedTexture.samplingMode !== null && parsedTexture.samplingMode !== undefined) {\r\n texture.updateSamplingMode(parsedTexture.samplingMode);\r\n }\r\n if (parsedTexture.wrapU !== null && parsedTexture.wrapU !== undefined) {\r\n texture.wrapU = parsedTexture.wrapU;\r\n }\r\n if (parsedTexture.wrapV !== null && parsedTexture.wrapV !== undefined) {\r\n texture.wrapV = parsedTexture.wrapV;\r\n }\r\n }\r\n}\r\n"]}
@@ -40,10 +40,10 @@ export function _ProcessShaderCode(processorOptions, baseName, processFinalCode,
40
40
  if (typeof baseName === "string") {
41
41
  vertexSource = baseName;
42
42
  }
43
- else if (baseName.vertexSource) {
43
+ else if (typeof baseName.vertexSource === "string") {
44
44
  vertexSource = "source:" + baseName.vertexSource;
45
45
  }
46
- else if (baseName.vertexElement) {
46
+ else if (typeof baseName.vertexElement === "string") {
47
47
  vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;
48
48
  }
49
49
  else {
@@ -52,10 +52,10 @@ export function _ProcessShaderCode(processorOptions, baseName, processFinalCode,
52
52
  if (typeof baseName === "string") {
53
53
  fragmentSource = baseName;
54
54
  }
55
- else if (baseName.fragmentSource) {
55
+ else if (typeof baseName.fragmentSource === "string") {
56
56
  fragmentSource = "source:" + baseName.fragmentSource;
57
57
  }
58
- else if (baseName.fragmentElement) {
58
+ else if (typeof baseName.fragmentElement === "string") {
59
59
  fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;
60
60
  }
61
61
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,OAAO,EAAqB,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAIvD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,SAAS,EAAE,MAAM,uCAAuC,CAAC;AA+ElE;;;;;;GAMG;AACH,gEAAgE;AAChE,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,OAAqB;IACjE,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,OAAO,WAAW,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC7C,CAAC;AAED;;GAEG;AACH,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,QAA0B;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC5B,MAAM,OAAO,GAAI,QAAiC,CAAC,OAAO,CAAC;IAC3D,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;Q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AC1F,EAAE;IAClB,IAAI,CAAC;QACD,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC7E,IAAI,WAAW,EAAE,CAAC;YACd,gIAAgI;YAChI,WAAW,CAAC,4BAA4B,GAAG,OAAO,CAAC,0BAA0B,CAAC;QAClF,CAAC;QACD,MAAM,eAAe,GAAqB,OAAO,CAAC,uBAAuB,IAAI,qBAAqB,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QACpI,eAAe,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QACrC,IAAI,OAAO,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC;YAC9B,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;QAChE,CAAC;QAED,sEAAsE;QACtE,oGAAoG;QACpG,uBAAuB,CACnB,eAAe,EACf,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,CAAC,CAAC,OAAO,CAAC,WAAW,EACrB,EAAE,EACF,EAAE,EACF,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,yBAAyB,EACjC,EAAE,EACF,GAAG,EAAE;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { type _IProcessingOptions, type ShaderCustomProcessingFunction, type _IShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport { type WebGLContext, getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport { type AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { type Effect, type IShaderPath } from \"./effect\";\r\nimport { type IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport { type WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (baseName.vertexSource) {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (baseName.vertexElement) {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (baseName.fragmentSource) {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (baseName.fragmentElement) {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n // Important:\r\n // The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.\r\n // Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.\r\n // Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.\r\n // This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel\r\n // as long as we wait for both shaders to be loaded before starting the processing.\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n const [vertexCode, fragmentCode] = shaderCodes;\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n processorOptions.isFragment = true;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode: string, codeBeforeMigration: string) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n }\r\n shaderCodes[0] = vertexCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
1
+ {"version":3,"file":"effect.functions.js","sourceRoot":"","sources":["../../../../dev/core/src/Materials/effect.functions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAG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WAAW,EAAE,CAAC;YAC9B,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC;QAChE,CAAC;QAED,sEAAsE;QACtE,oGAAoG;QACpG,uBAAuB,CACnB,eAAe,EACf,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,QAAQ,EAChB,CAAC,CAAC,OAAO,CAAC,WAAW,EACrB,EAAE,EACF,EAAE,EACF,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,OAAO,EACf,OAAO,CAAC,yBAAyB,EACjC,EAAE,EACF,GAAG,EAAE;YACD,oCAAoC,CAAC,eAAe,EAAE,GAAG,EAAE;gBACvD,OAAO,CAAC,wBAAwB,EAAE,CAAC,eAAe,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;QACP,CAAC,CACJ,CAAC;QAEF,OAAO,eAAe,CAAC;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QACvC,MAAM,CAAC,CAAC;IACZ,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { type _IProcessingOptions, type ShaderCustomProcessingFunction, type _IShaderProcessingContext } from \"core/Engines/Processors/shaderProcessingOptions\";\r\nimport { GetDOMTextContent, IsWindowObjectExist } from \"core/Misc/domManagement\";\r\nimport { type Nullable } from \"core/types\";\r\nimport { ShaderLanguage } from \"./shaderLanguage\";\r\nimport { type WebGLContext, getStateObject } from \"core/Engines/thinEngine.functions\";\r\nimport { ShaderStore } from \"core/Engines/shaderStore\";\r\nimport { type AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport { type Effect, type IShaderPath } from \"./effect\";\r\nimport { type IPipelineContext } from \"core/Engines/IPipelineContext\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { Finalize, Initialize, Process } from \"core/Engines/Processors/shaderProcessor\";\r\nimport { _LoadFile } from \"core/Engines/abstractEngine.functions\";\r\nimport { type WebGLPipelineContext } from \"core/Engines/WebGL/webGLPipelineContext\";\r\n\r\n/**\r\n * Options to be used when creating a pipeline\r\n */\r\nexport interface IPipelineGenerationOptions {\r\n /**\r\n * The definition of the shader content.\r\n * Can be either a unified name, name per vertex and frament or the shader code content itself\r\n */\r\n shaderNameOrContent: string | IShaderPath;\r\n /**\r\n * Unique key to identify the pipeline.\r\n * Note that though not mandatory, it's recommended to provide a key to be able to use the automated pipeline loading system.\r\n */\r\n key?: string;\r\n /**\r\n * The list of defines to be used in the shader\r\n */\r\n defines?: string[];\r\n\r\n /**\r\n * If true, the global defines will be added to the defines array\r\n */\r\n addGlobalDefines?: boolean;\r\n /**\r\n * The shader language.\r\n * Defaults to the language suiting the platform name (GLSL for WEBGL2, WGSL for WEBGPU)\r\n */\r\n shaderLanguage?: ShaderLanguage;\r\n\r\n /**\r\n * The name of the platform to be used when processing the shader\r\n * defaults to WEBGL2\r\n */\r\n platformName?: string /* \"WEBGL2\" | \"WEBGL1\" | \"WEBGPU\" */;\r\n\r\n /**\r\n * extend the processing options when running code processing\r\n */\r\n extendedProcessingOptions?: Partial<_IProcessingOptions>;\r\n\r\n /**\r\n * extend the pipeline generation options\r\n */\r\n extendedCreatePipelineOptions?: Partial<ICreateAndPreparePipelineContextOptions>;\r\n\r\n /**\r\n * If true, generating a new pipeline will return when the pipeline is ready to be used\r\n */\r\n waitForIsReady?: boolean;\r\n\r\n /**\r\n * If true, the pipeline will be created synchronously, even if parallel shader compilation is available\r\n */\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\nexport interface ICreateAndPreparePipelineContextOptions {\r\n parallelShaderCompile?: { COMPLETION_STATUS_KHR: number };\r\n shaderProcessingContext: Nullable<_IShaderProcessingContext>;\r\n existingPipelineContext?: Nullable<IPipelineContext>;\r\n name?: string;\r\n rebuildRebind?: (vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void) => void;\r\n onRenderingStateCompiled?: (pipelineContext?: IPipelineContext) => void;\r\n context?: WebGL2RenderingContext | WebGLRenderingContext;\r\n // preparePipeline options\r\n createAsRaw?: boolean;\r\n vertex: string;\r\n fragment: string;\r\n defines: Nullable<string>;\r\n transformFeedbackVaryings: Nullable<string[]>;\r\n disableParallelCompilation?: boolean;\r\n}\r\n\r\n/**\r\n * Get a cached pipeline context\r\n * @param name the pipeline name\r\n * @param context the context to be used when creating the pipeline\r\n * @returns the cached pipeline context if it exists\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function getCachedPipeline(name: string, context: WebGLContext): IPipelineContext | undefined {\r\n const stateObject = getStateObject(context);\r\n return stateObject.cachedPipelines[name];\r\n}\r\n\r\n/**\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function resetCachedPipeline(pipeline: IPipelineContext): void {\r\n const name = pipeline._name;\r\n const context = (pipeline as WebGLPipelineContext).context;\r\n if (name && context) {\r\n const stateObject = getStateObject(context);\r\n const cachedPipeline = stateObject.cachedPipelines[name];\r\n cachedPipeline?.dispose();\r\n delete stateObject.cachedPipelines[name];\r\n }\r\n}\r\n\r\n/** @internal */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function _ProcessShaderCode(\r\n processorOptions: _IProcessingOptions,\r\n baseName: any,\r\n processFinalCode?: Nullable<ShaderCustomProcessingFunction>,\r\n onFinalCodeReady?: (vertexCode: string, fragmentCode: string) => void,\r\n shaderLanguage?: ShaderLanguage,\r\n engine?: AbstractEngine,\r\n effectContext?: Effect\r\n) {\r\n let vertexSource: string | HTMLElement | IShaderPath;\r\n let fragmentSource: string | HTMLElement | IShaderPath;\r\n\r\n // const baseName = this.name;\r\n const hostDocument = IsWindowObjectExist() ? engine?.getHostDocument() : null;\r\n\r\n if (typeof baseName === \"string\") {\r\n vertexSource = baseName;\r\n } else if (typeof baseName.vertexSource === \"string\") {\r\n vertexSource = \"source:\" + baseName.vertexSource;\r\n } else if (typeof baseName.vertexElement === \"string\") {\r\n vertexSource = hostDocument?.getElementById(baseName.vertexElement) || baseName.vertexElement;\r\n } else {\r\n vertexSource = baseName.vertex || baseName;\r\n }\r\n if (typeof baseName === \"string\") {\r\n fragmentSource = baseName;\r\n } else if (typeof baseName.fragmentSource === \"string\") {\r\n fragmentSource = \"source:\" + baseName.fragmentSource;\r\n } else if (typeof baseName.fragmentElement === \"string\") {\r\n fragmentSource = hostDocument?.getElementById(baseName.fragmentElement) || baseName.fragmentElement;\r\n } else {\r\n fragmentSource = baseName.fragment || baseName;\r\n }\r\n\r\n // Important:\r\n // The vertex shader must be compiled before the fragment shader, as processing the fragment shader may require information from the vertex shader.\r\n // Also, they should be processed in the same JS tick because the shader processor is a singleton and stores information about the current processing in its internal state.\r\n // Processing the vertex and fragment shaders in different ticks may cause issues as the internal state may be overridden by another shader being processed in between.\r\n // This means that the shaders must be processed in sequence and synchronously, but the loading of the shader code can be done in parallel\r\n // as long as we wait for both shaders to be loaded before starting the processing.\r\n const shaderCodes: [string | undefined, string | undefined] = [undefined, undefined];\r\n const shadersLoaded = () => {\r\n if (shaderCodes[0] && shaderCodes[1]) {\r\n const [vertexCode, fragmentCode] = shaderCodes;\r\n Initialize(processorOptions);\r\n Process(\r\n vertexCode,\r\n processorOptions,\r\n (migratedVertexCode, codeBeforeMigration) => {\r\n if (effectContext) {\r\n effectContext._vertexSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedVertexCode = processFinalCode(\"vertex\", migratedVertexCode);\r\n }\r\n processorOptions.isFragment = true;\r\n Process(\r\n fragmentCode,\r\n processorOptions,\r\n (migratedFragmentCode: string, codeBeforeMigration: string) => {\r\n if (effectContext) {\r\n effectContext._fragmentSourceCodeBeforeMigration = codeBeforeMigration;\r\n }\r\n if (processFinalCode) {\r\n migratedFragmentCode = processFinalCode(\"fragment\", migratedFragmentCode);\r\n }\r\n const finalShaders = Finalize(migratedVertexCode, migratedFragmentCode, processorOptions);\r\n processorOptions = null as any;\r\n const finalCode = UseFinalCode(finalShaders.vertexCode, finalShaders.fragmentCode, baseName, shaderLanguage);\r\n onFinalCodeReady?.(finalCode.vertexSourceCode, finalCode.fragmentSourceCode);\r\n },\r\n engine\r\n );\r\n },\r\n engine\r\n );\r\n }\r\n };\r\n LoadShader(\r\n vertexSource,\r\n \"Vertex\",\r\n \"\",\r\n (vertexCode) => {\r\n if (effectContext) {\r\n effectContext._rawVertexSourceCode = vertexCode;\r\n }\r\n shaderCodes[0] = vertexCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n LoadShader(\r\n fragmentSource,\r\n \"Fragment\",\r\n \"Pixel\",\r\n (fragmentCode) => {\r\n if (effectContext) {\r\n effectContext._rawFragmentSourceCode = fragmentCode;\r\n }\r\n shaderCodes[1] = fragmentCode;\r\n shadersLoaded();\r\n },\r\n shaderLanguage\r\n );\r\n}\r\n\r\nfunction LoadShader(shader: any, key: string, optionalKey: string, callback: (data: any) => void, shaderLanguage?: ShaderLanguage, _loadFileInjection?: typeof _LoadFile) {\r\n if (typeof HTMLElement !== \"undefined\") {\r\n // DOM element ?\r\n if (shader instanceof HTMLElement) {\r\n const shaderCode = GetDOMTextContent(shader);\r\n callback(shaderCode);\r\n return;\r\n }\r\n }\r\n\r\n // Direct source ?\r\n if (shader.substring(0, 7) === \"source:\") {\r\n callback(shader.substring(7));\r\n return;\r\n }\r\n\r\n // Base64 encoded ?\r\n if (shader.substring(0, 7) === \"base64:\") {\r\n const shaderBinary = window.atob(shader.substring(7));\r\n callback(shaderBinary);\r\n return;\r\n }\r\n\r\n const shaderStore = ShaderStore.GetShadersStore(shaderLanguage);\r\n\r\n // Is in local store ?\r\n if (shaderStore[shader + key + \"Shader\"]) {\r\n callback(shaderStore[shader + key + \"Shader\"]);\r\n return;\r\n }\r\n\r\n if (optionalKey && shaderStore[shader + optionalKey + \"Shader\"]) {\r\n callback(shaderStore[shader + optionalKey + \"Shader\"]);\r\n return;\r\n }\r\n\r\n let shaderUrl;\r\n\r\n if (shader[0] === \".\" || shader[0] === \"/\" || shader.indexOf(\"http\") > -1) {\r\n shaderUrl = shader;\r\n } else {\r\n shaderUrl = ShaderStore.GetShadersRepository(shaderLanguage) + shader;\r\n }\r\n _loadFileInjection = _loadFileInjection || _LoadFile;\r\n if (!_loadFileInjection) {\r\n // we got to this point and loadFile was not injected - throw an error\r\n throw new Error(\"loadFileInjection is not defined\");\r\n }\r\n // Vertex shader\r\n _loadFileInjection(shaderUrl + \".\" + key.toLowerCase() + \".fx\", callback);\r\n}\r\n\r\nfunction UseFinalCode(migratedVertexCode: string, migratedFragmentCode: string, baseName: any, shaderLanguage?: ShaderLanguage) {\r\n if (baseName) {\r\n const vertex = baseName.vertexElement || baseName.vertex || baseName.spectorName || baseName;\r\n const fragment = baseName.fragmentElement || baseName.fragment || baseName.spectorName || baseName;\r\n\r\n return {\r\n vertexSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME vertex:\" + vertex + \"\\n\" + migratedVertexCode,\r\n fragmentSourceCode: (shaderLanguage === ShaderLanguage.WGSL ? \"//\" : \"\") + \"#define SHADER_NAME fragment:\" + fragment + \"\\n\" + migratedFragmentCode,\r\n };\r\n } else {\r\n return {\r\n vertexSourceCode: migratedVertexCode,\r\n fragmentSourceCode: migratedFragmentCode,\r\n };\r\n }\r\n}\r\n\r\n/**\r\n * Creates and prepares a pipeline context\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const createAndPreparePipelineContext = (\r\n options: ICreateAndPreparePipelineContextOptions,\r\n createPipelineContext: typeof AbstractEngine.prototype.createPipelineContext,\r\n _preparePipelineContext: typeof AbstractEngine.prototype._preparePipelineContextAsync,\r\n _executeWhenRenderingStateIsCompiled: typeof AbstractEngine.prototype._executeWhenRenderingStateIsCompiled\r\n): IPipelineContext => {\r\n try {\r\n const stateObject = options.context ? getStateObject(options.context) : null;\r\n if (stateObject) {\r\n // will not remove the reference to parallelShaderPrecompile, but will prevent it from being used in the next shader compilation\r\n stateObject.disableParallelShaderCompile = options.disableParallelCompilation;\r\n }\r\n const pipelineContext: IPipelineContext = options.existingPipelineContext || createPipelineContext(options.shaderProcessingContext);\r\n pipelineContext._name = options.name;\r\n if (options.name && stateObject) {\r\n stateObject.cachedPipelines[options.name] = pipelineContext;\r\n }\r\n\r\n // Flagged as async as we may need to delay load some processing tools\r\n // This does not break anything as the execution is waiting for _executeWhenRenderingStateIsCompiled\r\n _preparePipelineContext(\r\n pipelineContext,\r\n options.vertex,\r\n options.fragment,\r\n !!options.createAsRaw,\r\n \"\",\r\n \"\",\r\n options.rebuildRebind,\r\n options.defines,\r\n options.transformFeedbackVaryings,\r\n \"\",\r\n () => {\r\n _executeWhenRenderingStateIsCompiled(pipelineContext, () => {\r\n options.onRenderingStateCompiled?.(pipelineContext);\r\n });\r\n }\r\n );\r\n\r\n return pipelineContext;\r\n } catch (e) {\r\n Logger.Error(\"Error compiling effect\");\r\n throw e;\r\n }\r\n};\r\n"]}
@@ -3,7 +3,7 @@ import { __decorate } from "../tslib.es6.js";
3
3
  import { serialize, serializeAsColor3, expandToProperty, serializeAsFresnelParameters, serializeAsTexture } from "../Misc/decorators.js";
4
4
  import { SmartArray } from "../Misc/smartArray.js";
5
5
  import { Scene } from "../scene.js";
6
- import { Color3 } from "../Maths/math.color.js";
6
+ import { Color3, TmpColors } from "../Maths/math.color.js";
7
7
  import { VertexBuffer } from "../Buffers/buffer.js";
8
8
  import { PrePassConfiguration } from "./prePassConfiguration.js";
9
9
  import { ImageProcessingDefinesMixin } from "./imageProcessingConfiguration.defines.js";
@@ -958,7 +958,9 @@ export class StandardMaterial extends StandardMaterialBase {
958
958
  ubo.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
959
959
  }
960
960
  if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
961
- ubo.updateColor4("opacityParts", new Color3(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias), this.opacityFresnelParameters.power);
961
+ const opacityParts = TmpColors.Color3[0];
962
+ opacityParts.set(this.opacityFresnelParameters.leftColor.toLuminance(), this.opacityFresnelParameters.rightColor.toLuminance(), this.opacityFresnelParameters.bias);
963
+ ubo.updateColor4("opacityParts", opacityParts, this.opacityFresnelParameters.power);
962
964
  }
963
965
  if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
964
966
  ubo.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);