@babylonjs/core 7.13.2 → 7.14.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.
@@ -11,6 +11,8 @@ import { SerializationHelper } from "../../Misc/decorators.serialization.js";
11
11
  import "../../Engines/AbstractEngine/abstractEngine.cubeTexture.js";
12
12
  import "../../Engines/Extensions/engine.cubeTexture.js";
13
13
  import "../../Engines/Extensions/engine.prefilteredCubeTexture.js";
14
+ // The default scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
15
+ const defaultLodScale = 0.8;
14
16
  /**
15
17
  * Class for creating a cube texture
16
18
  */
@@ -110,10 +112,8 @@ export class CubeTexture extends BaseTexture {
110
112
  * @param useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false)
111
113
  * @returns the cube texture
112
114
  */
113
- constructor(rootUrl, sceneOrEngine, extensionsOrOptions = null, noMipmap = false, files = null, onLoad = null, onError = null, format = 5, prefiltered = false, forcedExtension = null, createPolynomials = false, lodScale = 0.8, lodOffset = 0, loaderOptions, useSRGBBuffer) {
115
+ constructor(rootUrl, sceneOrEngine, extensionsOrOptions = null, noMipmap = false, files = null, onLoad = null, onError = null, format = 5, prefiltered = false, forcedExtension = null, createPolynomials = false, lodScale = defaultLodScale, lodOffset = 0, loaderOptions, useSRGBBuffer) {
114
116
  super(sceneOrEngine);
115
- this._lodScale = 0.8;
116
- this._lodOffset = 0;
117
117
  /**
118
118
  * Observable triggered once the texture has been loaded.
119
119
  */
@@ -149,7 +149,7 @@ export class CubeTexture extends BaseTexture {
149
149
  prefiltered = extensionsOrOptions.prefiltered ?? false;
150
150
  forcedExtension = extensionsOrOptions.forcedExtension ?? null;
151
151
  this._createPolynomials = extensionsOrOptions.createPolynomials ?? false;
152
- this._lodScale = extensionsOrOptions.lodScale ?? 0;
152
+ this._lodScale = extensionsOrOptions.lodScale ?? defaultLodScale;
153
153
  this._lodOffset = extensionsOrOptions.lodOffset ?? 0;
154
154
  this._loaderOptions = extensionsOrOptions.loaderOptions;
155
155
  this._useSRGBBuffer = extensionsOrOptions.useSRGBBuffer;
@@ -1 +1 @@
1
- {"version":3,"file":"cubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/cubeTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACtE,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,QAAQ,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,yDAAyD,CAAC;AACjE,OAAO,6CAA6C,CAAC;AACrD,OAAO,wDAAwD,CAAC;AAiDhE;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IA2BxC;;;;;OAKG;IACH,IAAW,eAAe,CAAC,KAAc;QACrC,IAAI,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;YAC9D,OAAO;SACV;QACD,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,KAAK,EAAE;YACP,KAAK,CAAC,uBAAuB,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;SACtE;IACL,CAAC;IACD;;;OA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DACJ;AAGvB;IADP,iBAAiB,CAAC,yBAAyB,CAAC;6DACW;AAka5D,OAAO,CAAC,kBAAkB,GAAG,WAAW,CAAC,KAAK,CAAC;AAC/C,6CAA6C;AAC7C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsMatrix, serializeAsVector3 } from \"../../Misc/decorators\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, TmpVectors, 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 { GetClass, RegisterClass } from \"../../Misc/typeStore\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { SerializationHelper } from \"../../Misc/decorators.serialization\";\r\n\r\nimport \"../../Engines/AbstractEngine/abstractEngine.cubeTexture\";\r\nimport \"../../Engines/Extensions/engine.cubeTexture\";\r\nimport \"../../Engines/Extensions/engine.prefilteredCubeTexture\";\r\n\r\n/**\r\n * Defines the available options when creating a cube texture\r\n */\r\nexport interface ICubeTextureCreationOptions {\r\n /** Defines the suffixes add to the picture name in case six images are in use like _px.jpg */\r\n extensions?: string[];\r\n\r\n /** noMipmap defines if mipmaps should be created or not */\r\n noMipmap?: boolean;\r\n\r\n /** files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz */\r\n files?: string[];\r\n\r\n /** buffer to load instead of loading the data from the url */\r\n buffer?: ArrayBufferView;\r\n\r\n /** onLoad defines a callback triggered at the end of the file load if no errors occurred */\r\n onLoad?: () => void;\r\n\r\n /** onError defines a callback triggered in case of error during load */\r\n onError?: (message?: string, exception?: any) => void;\r\n\r\n /** format defines the internal format to use for the texture once loaded */\r\n format?: number;\r\n\r\n /** prefiltered defines whether or not the texture is created from prefiltered data */\r\n prefiltered?: boolean;\r\n\r\n /** forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name */\r\n forcedExtension?: any;\r\n\r\n /** createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary */\r\n createPolynomials?: boolean;\r\n\r\n /** lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness */\r\n lodScale?: number;\r\n\r\n /** lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness */\r\n lodOffset?: number;\r\n\r\n /** loaderOptions options to be passed to the loader */\r\n loaderOptions?: any;\r\n\r\n /** useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false) */\r\n useSRGBBuffer?: boolean;\r\n}\r\n\r\n/**\r\n * Class for creating a cube texture\r\n */\r\nexport class CubeTexture extends BaseTexture {\r\n private _delayedOnLoad: Nullable<() => void>;\r\n private _delayedOnError: Nullable<(message?: string, exception?: any) => void>;\r\n private _lodScale: number = 0.8;\r\n private _lodOffset: number = 0;\r\n\r\n /**\r\n * Observable triggered once the texture has been loaded.\r\n */\r\n public onLoadObservable: Observable<CubeTexture> = new Observable<CubeTexture>();\r\n\r\n /**\r\n * The url of the texture\r\n */\r\n @serialize()\r\n public url: string;\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 * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode\r\n */\r\n @serializeAsVector3()\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 /**\r\n * Returns the bounding box size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode\r\n */\r\n @serializeAsVector3()\r\n public get boundingBoxSize(): Vector3 {\r\n return this._boundingBoxSize;\r\n }\r\n\r\n protected _rotationY: number = 0;\r\n\r\n /**\r\n * Sets texture matrix rotation angle around Y axis in radians.\r\n */\r\n @serialize(\"rotationY\")\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 * Are mip maps generated for this texture or not.\r\n */\r\n public override get noMipmap(): boolean {\r\n return this._noMipmap;\r\n }\r\n\r\n private _noMipmap: boolean;\r\n\r\n /** @internal */\r\n @serialize(\"files\")\r\n public _files: Nullable<string[]> = null;\r\n\r\n @serialize(\"forcedExtension\")\r\n protected _forcedExtension: Nullable<string> = null;\r\n\r\n /**\r\n * Gets the forced extension (if any)\r\n */\r\n public get forcedExtension(): Nullable<string> {\r\n return this._forcedExtension;\r\n }\r\n\r\n @serialize(\"extensions\")\r\n private _extensions: Nullable<string[]> = null;\r\n\r\n @serializeAsMatrix(\"textureMatrix\")\r\n private _textureMatrix: Matrix;\r\n\r\n @serializeAsMatrix(\"textureMatrixRefraction\")\r\n private _textureMatrixRefraction: Matrix = new Matrix();\r\n\r\n private _format: number;\r\n private _createPolynomials: boolean;\r\n private _loaderOptions: any;\r\n private _useSRGBBuffer?: boolean;\r\n private _buffer: Nullable<ArrayBufferView> = null;\r\n\r\n /**\r\n * Creates a cube texture from an array of image urls\r\n * @param files defines an array of image urls\r\n * @param scene defines the hosting scene\r\n * @param noMipmap specifies if mip maps are not used\r\n * @returns a cube texture\r\n */\r\n public static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture {\r\n let rootUrlKey = \"\";\r\n\r\n files.forEach((url) => (rootUrlKey += url));\r\n\r\n return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);\r\n }\r\n\r\n /**\r\n * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.\r\n * @param url defines the url of the prefiltered texture\r\n * @param scene defines the scene the texture is attached to\r\n * @param forcedExtension defines the extension of the file if different from the url\r\n * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary\r\n * @returns the prefiltered texture\r\n */\r\n public static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension: any = null, createPolynomials: boolean = true) {\r\n const oldValue = scene.useDelayedTextureLoading;\r\n scene.useDelayedTextureLoading = false;\r\n\r\n const result = new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);\r\n\r\n scene.useDelayedTextureLoading = oldValue;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well\r\n * as prefiltered data.\r\n * @param rootUrl defines the url of the texture or the root name of the six images\r\n * @param sceneOrEngine defines the scene or engine the texture is attached to\r\n * @param extensionsOrOptions defines the suffixes add to the picture name in case six images are in use like _px.jpg or set of all options to create the cube texture\r\n * @param noMipmap defines if mipmaps should be created or not\r\n * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz\r\n * @param onLoad defines a callback triggered at the end of the file load if no errors occurred\r\n * @param onError defines a callback triggered in case of error during load\r\n * @param format defines the internal format to use for the texture once loaded\r\n * @param prefiltered defines whether or not the texture is created from prefiltered data\r\n * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name\r\n * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @param loaderOptions options to be passed to the loader\r\n * @param useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false)\r\n * @returns the cube texture\r\n */\r\n constructor(\r\n rootUrl: string,\r\n sceneOrEngine: Scene | AbstractEngine,\r\n extensionsOrOptions: Nullable<string[] | ICubeTextureCreationOptions> = null,\r\n noMipmap: boolean = false,\r\n files: Nullable<string[]> = null,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n prefiltered = false,\r\n forcedExtension: any = null,\r\n createPolynomials: boolean = false,\r\n lodScale: number = 0.8,\r\n lodOffset: number = 0,\r\n loaderOptions?: any,\r\n useSRGBBuffer?: boolean\r\n ) {\r\n super(sceneOrEngine);\r\n\r\n this.name = rootUrl;\r\n this.url = rootUrl;\r\n this._noMipmap = noMipmap;\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n this._textureMatrix = Matrix.Identity();\r\n this.coordinatesMode = Texture.CUBIC_MODE;\r\n\r\n let extensions: Nullable<string[]> = null;\r\n let buffer: Nullable<ArrayBufferView> = null;\r\n\r\n if (extensionsOrOptions !== null && !Array.isArray(extensionsOrOptions)) {\r\n extensions = extensionsOrOptions.extensions ?? null;\r\n this._noMipmap = extensionsOrOptions.noMipmap ?? false;\r\n files = extensionsOrOptions.files ?? null;\r\n buffer = extensionsOrOptions.buffer ?? null;\r\n this._format = extensionsOrOptions.format ?? Constants.TEXTUREFORMAT_RGBA;\r\n prefiltered = extensionsOrOptions.prefiltered ?? false;\r\n forcedExtension = extensionsOrOptions.forcedExtension ?? null;\r\n this._createPolynomials = extensionsOrOptions.createPolynomials ?? false;\r\n this._lodScale = extensionsOrOptions.lodScale ?? 0;\r\n this._lodOffset = extensionsOrOptions.lodOffset ?? 0;\r\n this._loaderOptions = extensionsOrOptions.loaderOptions;\r\n this._useSRGBBuffer = extensionsOrOptions.useSRGBBuffer;\r\n onLoad = extensionsOrOptions.onLoad ?? null;\r\n onError = extensionsOrOptions.onError ?? null;\r\n } else {\r\n this._noMipmap = noMipmap;\r\n this._format = format;\r\n this._createPolynomials = createPolynomials;\r\n extensions = extensionsOrOptions;\r\n this._loaderOptions = loaderOptions;\r\n this._useSRGBBuffer = useSRGBBuffer;\r\n this._lodScale = lodScale;\r\n this._lodOffset = lodOffset;\r\n }\r\n\r\n if (!rootUrl && !files) {\r\n return;\r\n }\r\n\r\n this.updateURL(rootUrl, forcedExtension, onLoad, prefiltered, onError, extensions, this.getScene()?.useDelayedTextureLoading, files, buffer);\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 \"CubeTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"CubeTexture\";\r\n }\r\n\r\n /**\r\n * Update the url (and optional buffer) of this texture if url was null during construction.\r\n * @param url the url of the texture\r\n * @param forcedExtension defines the extension to use\r\n * @param onLoad callback called when the texture is loaded (defaults to null)\r\n * @param prefiltered Defines whether the updated texture is prefiltered or not\r\n * @param onError callback called if there was an error during the loading process (defaults to null)\r\n * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...\r\n * @param delayLoad defines if the texture should be loaded now (false by default)\r\n * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz\r\n * @param buffer the buffer to use instead of loading from the url\r\n */\r\n public updateURL(\r\n url: string,\r\n forcedExtension: Nullable<string> = null,\r\n onLoad: Nullable<() => void> = null,\r\n prefiltered: boolean = false,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n extensions: Nullable<string[]> = null,\r\n delayLoad = false,\r\n files: Nullable<string[]> = null,\r\n buffer: Nullable<ArrayBufferView> = null\r\n ): void {\r\n if (!this.name || this.name.startsWith(\"data:\")) {\r\n this.name = url;\r\n }\r\n this.url = url;\r\n\r\n if (forcedExtension) {\r\n this._forcedExtension = forcedExtension;\r\n }\r\n\r\n const lastDot = url.lastIndexOf(\".\");\r\n const extension = forcedExtension ? forcedExtension : lastDot > -1 ? url.substring(lastDot).toLowerCase() : \"\";\r\n const isDDS = extension.indexOf(\".dds\") === 0;\r\n const isEnv = extension.indexOf(\".env\") === 0;\r\n const isBasis = extension.indexOf(\".basis\") === 0;\r\n\r\n if (isEnv) {\r\n this.gammaSpace = false;\r\n this._prefiltered = false;\r\n this.anisotropicFilteringLevel = 1;\r\n } else {\r\n this._prefiltered = prefiltered;\r\n\r\n if (prefiltered) {\r\n this.gammaSpace = false;\r\n this.anisotropicFilteringLevel = 1;\r\n }\r\n }\r\n\r\n if (files) {\r\n this._files = files;\r\n } else {\r\n if (!isBasis && !isEnv && !isDDS && !extensions) {\r\n extensions = [\"_px.jpg\", \"_py.jpg\", \"_pz.jpg\", \"_nx.jpg\", \"_ny.jpg\", \"_nz.jpg\"];\r\n }\r\n\r\n this._files = this._files || [];\r\n this._files.length = 0;\r\n\r\n if (extensions) {\r\n for (let index = 0; index < extensions.length; index++) {\r\n this._files.push(url + extensions[index]);\r\n }\r\n this._extensions = extensions;\r\n }\r\n }\r\n\r\n this._buffer = buffer;\r\n\r\n if (delayLoad) {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n this._delayedOnLoad = onLoad;\r\n this._delayedOnError = onError;\r\n } else {\r\n this._loadTexture(onLoad, onError);\r\n }\r\n }\r\n\r\n /**\r\n * Delays loading of the cube texture\r\n * @param forcedExtension defines the extension to use\r\n */\r\n public override delayLoad(forcedExtension?: string): void {\r\n if (this.delayLoadState !== Constants.DELAYLOADSTATE_NOTLOADED) {\r\n return;\r\n }\r\n if (forcedExtension) {\r\n this._forcedExtension = forcedExtension;\r\n }\r\n\r\n this.delayLoadState = Constants.DELAYLOADSTATE_LOADED;\r\n this._loadTexture(this._delayedOnLoad, this._delayedOnError);\r\n }\r\n\r\n /**\r\n * Returns the reflection texture matrix\r\n * @returns the reflection texture matrix\r\n */\r\n public override getReflectionTextureMatrix(): Matrix {\r\n return this._textureMatrix;\r\n }\r\n\r\n /**\r\n * Sets the reflection texture matrix\r\n * @param value Reflection texture matrix\r\n */\r\n public setReflectionTextureMatrix(value: Matrix): void {\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 this._textureMatrix = value;\r\n\r\n if (!this.getScene()?.useRightHandedSystem) {\r\n return;\r\n }\r\n\r\n const scale = TmpVectors.Vector3[0];\r\n const quat = TmpVectors.Quaternion[0];\r\n const trans = TmpVectors.Vector3[1];\r\n\r\n this._textureMatrix.decompose(scale, quat, trans);\r\n\r\n quat.z *= -1; // these two operations correspond to negating the x and y euler angles\r\n quat.w *= -1;\r\n\r\n Matrix.ComposeToRef(scale, quat, trans, this._textureMatrixRefraction);\r\n }\r\n\r\n /**\r\n * Gets a suitable rotate/transform matrix when the texture is used for refraction.\r\n * There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.\r\n * @returns The refraction matrix\r\n */\r\n public override getRefractionTextureMatrix(): Matrix {\r\n return this.getScene()?.useRightHandedSystem ? this._textureMatrixRefraction : this._textureMatrix;\r\n }\r\n\r\n private _loadTexture(onLoad: Nullable<() => void> = null, onError: Nullable<(message?: string, exception?: any) => void> = null) {\r\n const scene = this.getScene();\r\n const oldTexture = this._texture;\r\n this._texture = this._getFromCache(this.url, this._noMipmap, undefined, undefined, this._useSRGBBuffer, this.isCube);\r\n\r\n const onLoadProcessing = () => {\r\n this.onLoadObservable.notifyObservers(this);\r\n if (oldTexture) {\r\n oldTexture.dispose();\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n const errorHandler = (message?: string, exception?: any) => {\r\n this._loadingError = true;\r\n this._errorObject = { message, exception };\r\n if (onError) {\r\n onError(message, exception);\r\n }\r\n Texture.OnTextureLoadErrorObservable.notifyObservers(this);\r\n };\r\n\r\n if (!this._texture) {\r\n if (this._prefiltered) {\r\n this._texture = this._getEngine()!.createPrefilteredCubeTexture(\r\n this.url,\r\n scene,\r\n this._lodScale,\r\n this._lodOffset,\r\n onLoad,\r\n errorHandler,\r\n this._format,\r\n this._forcedExtension,\r\n this._createPolynomials\r\n );\r\n } else {\r\n this._texture = this._getEngine()!.createCubeTexture(\r\n this.url,\r\n scene,\r\n this._files,\r\n this._noMipmap,\r\n onLoad,\r\n errorHandler,\r\n this._format,\r\n this._forcedExtension,\r\n false,\r\n this._lodScale,\r\n this._lodOffset,\r\n null,\r\n this._loaderOptions,\r\n !!this._useSRGBBuffer,\r\n this._buffer\r\n );\r\n }\r\n\r\n this._texture?.onLoadedObservable.add(() => this.onLoadObservable.notifyObservers(this));\r\n } else {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => onLoadProcessing());\r\n } else {\r\n this._texture.onLoadedObservable.add(() => onLoadProcessing());\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Parses text to create a cube texture\r\n * @param parsedTexture define the serialized text to read from\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root url of the cube texture\r\n * @returns a cube texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => {\r\n let prefiltered: boolean = false;\r\n if (parsedTexture.prefiltered) {\r\n prefiltered = parsedTexture.prefiltered;\r\n }\r\n return new CubeTexture(\r\n rootUrl + (parsedTexture.url ?? parsedTexture.name),\r\n scene,\r\n parsedTexture.extensions,\r\n false,\r\n parsedTexture.files || null,\r\n null,\r\n null,\r\n undefined,\r\n prefiltered,\r\n parsedTexture.forcedExtension\r\n );\r\n },\r\n parsedTexture,\r\n scene\r\n );\r\n\r\n // Local Cubemaps\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\r\n // Animations\r\n if (parsedTexture.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedTexture.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n texture.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n }\r\n\r\n return texture;\r\n }\r\n\r\n /**\r\n * Makes a clone, or deep copy, of the cube texture\r\n * @returns a new cube texture\r\n */\r\n public override clone(): CubeTexture {\r\n let uniqueId = 0;\r\n\r\n const newCubeTexture = SerializationHelper.Clone(() => {\r\n const cubeTexture = new CubeTexture(this.url, this.getScene() || this._getEngine()!, this._extensions, this._noMipmap, this._files);\r\n uniqueId = cubeTexture.uniqueId;\r\n\r\n return cubeTexture;\r\n }, this);\r\n\r\n newCubeTexture.uniqueId = uniqueId;\r\n\r\n return newCubeTexture;\r\n }\r\n}\r\n\r\nTexture._CubeTextureParser = CubeTexture.Parse;\r\n// Some exporters relies on Tools.Instantiate\r\nRegisterClass(\"BABYLON.CubeTexture\", CubeTexture);\r\n"]}
1
+ {"version":3,"file":"cubeTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/cubeTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AACn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AM,cAAc,GAAG,mBAAmB,CAAC,KAAK,CAAC,GAAG,EAAE;YAClD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,UAAU,EAAG,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;YACpI,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC;YAEhC,OAAO,WAAW,CAAC;QACvB,CAAC,EAAE,IAAI,CAAC,CAAC;QAET,cAAc,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEnC,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ;AApfU;IADN,SAAS,EAAE;wCACO;AAQZ;IADN,kBAAkB,EAAE;wDACuB;AAyB5C;IADC,kBAAkB,EAAE;kDAGpB;AAQD;IADC,SAAS,CAAC,WAAW,CAAC;4CAItB;AAmBM;IADN,SAAS,CAAC,OAAO,CAAC;2CACsB;AAG/B;IADT,SAAS,CAAC,iBAAiB,CAAC;qDACuB;AAU5C;IADP,SAAS,CAAC,YAAY,CAAC;gDACuB;AAGvC;IADP,iBAAiB,CAAC,eAAe,CAAC;mDACJ;AAGvB;IADP,iBAAiB,CAAC,yBAAyB,CAAC;6DACW;AAka5D,OAAO,CAAC,kBAAkB,GAAG,WAAW,CAAC,KAAK,CAAC;AAC/C,6CAA6C;AAC7C,aAAa,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsMatrix, serializeAsVector3 } from \"../../Misc/decorators\";\r\nimport { Tools } from \"../../Misc/tools\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix, TmpVectors, 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 { GetClass, RegisterClass } from \"../../Misc/typeStore\";\r\nimport type { AbstractEngine } from \"../../Engines/abstractEngine\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { SerializationHelper } from \"../../Misc/decorators.serialization\";\r\n\r\nimport \"../../Engines/AbstractEngine/abstractEngine.cubeTexture\";\r\nimport \"../../Engines/Extensions/engine.cubeTexture\";\r\nimport \"../../Engines/Extensions/engine.prefilteredCubeTexture\";\r\n\r\n/**\r\n * Defines the available options when creating a cube texture\r\n */\r\nexport interface ICubeTextureCreationOptions {\r\n /** Defines the suffixes add to the picture name in case six images are in use like _px.jpg */\r\n extensions?: string[];\r\n\r\n /** noMipmap defines if mipmaps should be created or not */\r\n noMipmap?: boolean;\r\n\r\n /** files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz */\r\n files?: string[];\r\n\r\n /** buffer to load instead of loading the data from the url */\r\n buffer?: ArrayBufferView;\r\n\r\n /** onLoad defines a callback triggered at the end of the file load if no errors occurred */\r\n onLoad?: () => void;\r\n\r\n /** onError defines a callback triggered in case of error during load */\r\n onError?: (message?: string, exception?: any) => void;\r\n\r\n /** format defines the internal format to use for the texture once loaded */\r\n format?: number;\r\n\r\n /** prefiltered defines whether or not the texture is created from prefiltered data */\r\n prefiltered?: boolean;\r\n\r\n /** forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name */\r\n forcedExtension?: any;\r\n\r\n /** createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary */\r\n createPolynomials?: boolean;\r\n\r\n /** lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness */\r\n lodScale?: number;\r\n\r\n /** lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness */\r\n lodOffset?: number;\r\n\r\n /** loaderOptions options to be passed to the loader */\r\n loaderOptions?: any;\r\n\r\n /** useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false) */\r\n useSRGBBuffer?: boolean;\r\n}\r\n\r\n// The default scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\nconst defaultLodScale = 0.8;\r\n\r\n/**\r\n * Class for creating a cube texture\r\n */\r\nexport class CubeTexture extends BaseTexture {\r\n private _delayedOnLoad: Nullable<() => void>;\r\n private _delayedOnError: Nullable<(message?: string, exception?: any) => void>;\r\n private _lodScale: number;\r\n private _lodOffset: number;\r\n\r\n /**\r\n * Observable triggered once the texture has been loaded.\r\n */\r\n public onLoadObservable: Observable<CubeTexture> = new Observable<CubeTexture>();\r\n\r\n /**\r\n * The url of the texture\r\n */\r\n @serialize()\r\n public url: string;\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 * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode\r\n */\r\n @serializeAsVector3()\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 /**\r\n * Returns the bounding box size\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/materials/using/reflectionTexture#using-local-cubemap-mode\r\n */\r\n @serializeAsVector3()\r\n public get boundingBoxSize(): Vector3 {\r\n return this._boundingBoxSize;\r\n }\r\n\r\n protected _rotationY: number = 0;\r\n\r\n /**\r\n * Sets texture matrix rotation angle around Y axis in radians.\r\n */\r\n @serialize(\"rotationY\")\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 * Are mip maps generated for this texture or not.\r\n */\r\n public override get noMipmap(): boolean {\r\n return this._noMipmap;\r\n }\r\n\r\n private _noMipmap: boolean;\r\n\r\n /** @internal */\r\n @serialize(\"files\")\r\n public _files: Nullable<string[]> = null;\r\n\r\n @serialize(\"forcedExtension\")\r\n protected _forcedExtension: Nullable<string> = null;\r\n\r\n /**\r\n * Gets the forced extension (if any)\r\n */\r\n public get forcedExtension(): Nullable<string> {\r\n return this._forcedExtension;\r\n }\r\n\r\n @serialize(\"extensions\")\r\n private _extensions: Nullable<string[]> = null;\r\n\r\n @serializeAsMatrix(\"textureMatrix\")\r\n private _textureMatrix: Matrix;\r\n\r\n @serializeAsMatrix(\"textureMatrixRefraction\")\r\n private _textureMatrixRefraction: Matrix = new Matrix();\r\n\r\n private _format: number;\r\n private _createPolynomials: boolean;\r\n private _loaderOptions: any;\r\n private _useSRGBBuffer?: boolean;\r\n private _buffer: Nullable<ArrayBufferView> = null;\r\n\r\n /**\r\n * Creates a cube texture from an array of image urls\r\n * @param files defines an array of image urls\r\n * @param scene defines the hosting scene\r\n * @param noMipmap specifies if mip maps are not used\r\n * @returns a cube texture\r\n */\r\n public static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture {\r\n let rootUrlKey = \"\";\r\n\r\n files.forEach((url) => (rootUrlKey += url));\r\n\r\n return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);\r\n }\r\n\r\n /**\r\n * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.\r\n * @param url defines the url of the prefiltered texture\r\n * @param scene defines the scene the texture is attached to\r\n * @param forcedExtension defines the extension of the file if different from the url\r\n * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary\r\n * @returns the prefiltered texture\r\n */\r\n public static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension: any = null, createPolynomials: boolean = true) {\r\n const oldValue = scene.useDelayedTextureLoading;\r\n scene.useDelayedTextureLoading = false;\r\n\r\n const result = new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);\r\n\r\n scene.useDelayedTextureLoading = oldValue;\r\n\r\n return result;\r\n }\r\n\r\n /**\r\n * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well\r\n * as prefiltered data.\r\n * @param rootUrl defines the url of the texture or the root name of the six images\r\n * @param sceneOrEngine defines the scene or engine the texture is attached to\r\n * @param extensionsOrOptions defines the suffixes add to the picture name in case six images are in use like _px.jpg or set of all options to create the cube texture\r\n * @param noMipmap defines if mipmaps should be created or not\r\n * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz\r\n * @param onLoad defines a callback triggered at the end of the file load if no errors occurred\r\n * @param onError defines a callback triggered in case of error during load\r\n * @param format defines the internal format to use for the texture once loaded\r\n * @param prefiltered defines whether or not the texture is created from prefiltered data\r\n * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name\r\n * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary\r\n * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness\r\n * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness\r\n * @param loaderOptions options to be passed to the loader\r\n * @param useSRGBBuffer Defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU) (default: false)\r\n * @returns the cube texture\r\n */\r\n constructor(\r\n rootUrl: string,\r\n sceneOrEngine: Scene | AbstractEngine,\r\n extensionsOrOptions: Nullable<string[] | ICubeTextureCreationOptions> = null,\r\n noMipmap: boolean = false,\r\n files: Nullable<string[]> = null,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n format: number = Constants.TEXTUREFORMAT_RGBA,\r\n prefiltered = false,\r\n forcedExtension: any = null,\r\n createPolynomials: boolean = false,\r\n lodScale: number = defaultLodScale,\r\n lodOffset: number = 0,\r\n loaderOptions?: any,\r\n useSRGBBuffer?: boolean\r\n ) {\r\n super(sceneOrEngine);\r\n\r\n this.name = rootUrl;\r\n this.url = rootUrl;\r\n this._noMipmap = noMipmap;\r\n this.hasAlpha = false;\r\n this.isCube = true;\r\n this._textureMatrix = Matrix.Identity();\r\n this.coordinatesMode = Texture.CUBIC_MODE;\r\n\r\n let extensions: Nullable<string[]> = null;\r\n let buffer: Nullable<ArrayBufferView> = null;\r\n\r\n if (extensionsOrOptions !== null && !Array.isArray(extensionsOrOptions)) {\r\n extensions = extensionsOrOptions.extensions ?? null;\r\n this._noMipmap = extensionsOrOptions.noMipmap ?? false;\r\n files = extensionsOrOptions.files ?? null;\r\n buffer = extensionsOrOptions.buffer ?? null;\r\n this._format = extensionsOrOptions.format ?? Constants.TEXTUREFORMAT_RGBA;\r\n prefiltered = extensionsOrOptions.prefiltered ?? false;\r\n forcedExtension = extensionsOrOptions.forcedExtension ?? null;\r\n this._createPolynomials = extensionsOrOptions.createPolynomials ?? false;\r\n this._lodScale = extensionsOrOptions.lodScale ?? defaultLodScale;\r\n this._lodOffset = extensionsOrOptions.lodOffset ?? 0;\r\n this._loaderOptions = extensionsOrOptions.loaderOptions;\r\n this._useSRGBBuffer = extensionsOrOptions.useSRGBBuffer;\r\n onLoad = extensionsOrOptions.onLoad ?? null;\r\n onError = extensionsOrOptions.onError ?? null;\r\n } else {\r\n this._noMipmap = noMipmap;\r\n this._format = format;\r\n this._createPolynomials = createPolynomials;\r\n extensions = extensionsOrOptions;\r\n this._loaderOptions = loaderOptions;\r\n this._useSRGBBuffer = useSRGBBuffer;\r\n this._lodScale = lodScale;\r\n this._lodOffset = lodOffset;\r\n }\r\n\r\n if (!rootUrl && !files) {\r\n return;\r\n }\r\n\r\n this.updateURL(rootUrl, forcedExtension, onLoad, prefiltered, onError, extensions, this.getScene()?.useDelayedTextureLoading, files, buffer);\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 \"CubeTexture\"\r\n */\r\n public override getClassName(): string {\r\n return \"CubeTexture\";\r\n }\r\n\r\n /**\r\n * Update the url (and optional buffer) of this texture if url was null during construction.\r\n * @param url the url of the texture\r\n * @param forcedExtension defines the extension to use\r\n * @param onLoad callback called when the texture is loaded (defaults to null)\r\n * @param prefiltered Defines whether the updated texture is prefiltered or not\r\n * @param onError callback called if there was an error during the loading process (defaults to null)\r\n * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...\r\n * @param delayLoad defines if the texture should be loaded now (false by default)\r\n * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz\r\n * @param buffer the buffer to use instead of loading from the url\r\n */\r\n public updateURL(\r\n url: string,\r\n forcedExtension: Nullable<string> = null,\r\n onLoad: Nullable<() => void> = null,\r\n prefiltered: boolean = false,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n extensions: Nullable<string[]> = null,\r\n delayLoad = false,\r\n files: Nullable<string[]> = null,\r\n buffer: Nullable<ArrayBufferView> = null\r\n ): void {\r\n if (!this.name || this.name.startsWith(\"data:\")) {\r\n this.name = url;\r\n }\r\n this.url = url;\r\n\r\n if (forcedExtension) {\r\n this._forcedExtension = forcedExtension;\r\n }\r\n\r\n const lastDot = url.lastIndexOf(\".\");\r\n const extension = forcedExtension ? forcedExtension : lastDot > -1 ? url.substring(lastDot).toLowerCase() : \"\";\r\n const isDDS = extension.indexOf(\".dds\") === 0;\r\n const isEnv = extension.indexOf(\".env\") === 0;\r\n const isBasis = extension.indexOf(\".basis\") === 0;\r\n\r\n if (isEnv) {\r\n this.gammaSpace = false;\r\n this._prefiltered = false;\r\n this.anisotropicFilteringLevel = 1;\r\n } else {\r\n this._prefiltered = prefiltered;\r\n\r\n if (prefiltered) {\r\n this.gammaSpace = false;\r\n this.anisotropicFilteringLevel = 1;\r\n }\r\n }\r\n\r\n if (files) {\r\n this._files = files;\r\n } else {\r\n if (!isBasis && !isEnv && !isDDS && !extensions) {\r\n extensions = [\"_px.jpg\", \"_py.jpg\", \"_pz.jpg\", \"_nx.jpg\", \"_ny.jpg\", \"_nz.jpg\"];\r\n }\r\n\r\n this._files = this._files || [];\r\n this._files.length = 0;\r\n\r\n if (extensions) {\r\n for (let index = 0; index < extensions.length; index++) {\r\n this._files.push(url + extensions[index]);\r\n }\r\n this._extensions = extensions;\r\n }\r\n }\r\n\r\n this._buffer = buffer;\r\n\r\n if (delayLoad) {\r\n this.delayLoadState = Constants.DELAYLOADSTATE_NOTLOADED;\r\n this._delayedOnLoad = onLoad;\r\n this._delayedOnError = onError;\r\n } else {\r\n this._loadTexture(onLoad, onError);\r\n }\r\n }\r\n\r\n /**\r\n * Delays loading of the cube texture\r\n * @param forcedExtension defines the extension to use\r\n */\r\n public override delayLoad(forcedExtension?: string): void {\r\n if (this.delayLoadState !== Constants.DELAYLOADSTATE_NOTLOADED) {\r\n return;\r\n }\r\n if (forcedExtension) {\r\n this._forcedExtension = forcedExtension;\r\n }\r\n\r\n this.delayLoadState = Constants.DELAYLOADSTATE_LOADED;\r\n this._loadTexture(this._delayedOnLoad, this._delayedOnError);\r\n }\r\n\r\n /**\r\n * Returns the reflection texture matrix\r\n * @returns the reflection texture matrix\r\n */\r\n public override getReflectionTextureMatrix(): Matrix {\r\n return this._textureMatrix;\r\n }\r\n\r\n /**\r\n * Sets the reflection texture matrix\r\n * @param value Reflection texture matrix\r\n */\r\n public setReflectionTextureMatrix(value: Matrix): void {\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 this._textureMatrix = value;\r\n\r\n if (!this.getScene()?.useRightHandedSystem) {\r\n return;\r\n }\r\n\r\n const scale = TmpVectors.Vector3[0];\r\n const quat = TmpVectors.Quaternion[0];\r\n const trans = TmpVectors.Vector3[1];\r\n\r\n this._textureMatrix.decompose(scale, quat, trans);\r\n\r\n quat.z *= -1; // these two operations correspond to negating the x and y euler angles\r\n quat.w *= -1;\r\n\r\n Matrix.ComposeToRef(scale, quat, trans, this._textureMatrixRefraction);\r\n }\r\n\r\n /**\r\n * Gets a suitable rotate/transform matrix when the texture is used for refraction.\r\n * There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.\r\n * @returns The refraction matrix\r\n */\r\n public override getRefractionTextureMatrix(): Matrix {\r\n return this.getScene()?.useRightHandedSystem ? this._textureMatrixRefraction : this._textureMatrix;\r\n }\r\n\r\n private _loadTexture(onLoad: Nullable<() => void> = null, onError: Nullable<(message?: string, exception?: any) => void> = null) {\r\n const scene = this.getScene();\r\n const oldTexture = this._texture;\r\n this._texture = this._getFromCache(this.url, this._noMipmap, undefined, undefined, this._useSRGBBuffer, this.isCube);\r\n\r\n const onLoadProcessing = () => {\r\n this.onLoadObservable.notifyObservers(this);\r\n if (oldTexture) {\r\n oldTexture.dispose();\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n const errorHandler = (message?: string, exception?: any) => {\r\n this._loadingError = true;\r\n this._errorObject = { message, exception };\r\n if (onError) {\r\n onError(message, exception);\r\n }\r\n Texture.OnTextureLoadErrorObservable.notifyObservers(this);\r\n };\r\n\r\n if (!this._texture) {\r\n if (this._prefiltered) {\r\n this._texture = this._getEngine()!.createPrefilteredCubeTexture(\r\n this.url,\r\n scene,\r\n this._lodScale,\r\n this._lodOffset,\r\n onLoad,\r\n errorHandler,\r\n this._format,\r\n this._forcedExtension,\r\n this._createPolynomials\r\n );\r\n } else {\r\n this._texture = this._getEngine()!.createCubeTexture(\r\n this.url,\r\n scene,\r\n this._files,\r\n this._noMipmap,\r\n onLoad,\r\n errorHandler,\r\n this._format,\r\n this._forcedExtension,\r\n false,\r\n this._lodScale,\r\n this._lodOffset,\r\n null,\r\n this._loaderOptions,\r\n !!this._useSRGBBuffer,\r\n this._buffer\r\n );\r\n }\r\n\r\n this._texture?.onLoadedObservable.add(() => this.onLoadObservable.notifyObservers(this));\r\n } else {\r\n if (this._texture.isReady) {\r\n Tools.SetImmediate(() => onLoadProcessing());\r\n } else {\r\n this._texture.onLoadedObservable.add(() => onLoadProcessing());\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Parses text to create a cube texture\r\n * @param parsedTexture define the serialized text to read from\r\n * @param scene defines the hosting scene\r\n * @param rootUrl defines the root url of the cube texture\r\n * @returns a cube texture\r\n */\r\n public static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture {\r\n const texture = SerializationHelper.Parse(\r\n () => {\r\n let prefiltered: boolean = false;\r\n if (parsedTexture.prefiltered) {\r\n prefiltered = parsedTexture.prefiltered;\r\n }\r\n return new CubeTexture(\r\n rootUrl + (parsedTexture.url ?? parsedTexture.name),\r\n scene,\r\n parsedTexture.extensions,\r\n false,\r\n parsedTexture.files || null,\r\n null,\r\n null,\r\n undefined,\r\n prefiltered,\r\n parsedTexture.forcedExtension\r\n );\r\n },\r\n parsedTexture,\r\n scene\r\n );\r\n\r\n // Local Cubemaps\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\r\n // Animations\r\n if (parsedTexture.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedTexture.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n texture.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n }\r\n\r\n return texture;\r\n }\r\n\r\n /**\r\n * Makes a clone, or deep copy, of the cube texture\r\n * @returns a new cube texture\r\n */\r\n public override clone(): CubeTexture {\r\n let uniqueId = 0;\r\n\r\n const newCubeTexture = SerializationHelper.Clone(() => {\r\n const cubeTexture = new CubeTexture(this.url, this.getScene() || this._getEngine()!, this._extensions, this._noMipmap, this._files);\r\n uniqueId = cubeTexture.uniqueId;\r\n\r\n return cubeTexture;\r\n }, this);\r\n\r\n newCubeTexture.uniqueId = uniqueId;\r\n\r\n return newCubeTexture;\r\n }\r\n}\r\n\r\nTexture._CubeTextureParser = CubeTexture.Parse;\r\n// Some exporters relies on Tools.Instantiate\r\nRegisterClass(\"BABYLON.CubeTexture\", CubeTexture);\r\n"]}
@@ -600,6 +600,15 @@ export declare class Vector2 implements Vector<Tuple<number, 2>, IVector2Like>,
600
600
  * @returns a new Vector2
601
601
  */
602
602
  static Lerp(start: DeepImmutable<IVector2Like>, end: DeepImmutable<IVector2Like>, amount: number): Vector2;
603
+ /**
604
+ * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
605
+ * @param start defines the start value
606
+ * @param end defines the end value
607
+ * @param amount max defines amount between both (between 0 and 1)
608
+ * @param result defines the Vector2 where to store the result
609
+ * @returns result input
610
+ */
611
+ static LerpToRef(start: DeepImmutable<IVector2Like>, end: DeepImmutable<IVector2Like>, amount: number, result: Vector2): Vector2;
603
612
  /**
604
613
  * Gets the dot product of the vector "left" and the vector "right"
605
614
  * Example Playground https://playground.babylonjs.com/#QYBWV4#90
@@ -759,9 +759,20 @@ export class Vector2 {
759
759
  * @returns a new Vector2
760
760
  */
761
761
  static Lerp(start, end, amount) {
762
- const x = start.x + (end.x - start.x) * amount;
763
- const y = start.y + (end.y - start.y) * amount;
764
- return new Vector2(x, y);
762
+ return Vector2.LerpToRef(start, end, amount, new Vector2());
763
+ }
764
+ /**
765
+ * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
766
+ * @param start defines the start value
767
+ * @param end defines the end value
768
+ * @param amount max defines amount between both (between 0 and 1)
769
+ * @param result defines the Vector2 where to store the result
770
+ * @returns result input
771
+ */
772
+ static LerpToRef(start, end, amount, result) {
773
+ result.x = start.x + (end.x - start.x) * amount;
774
+ result.y = start.y + (end.y - start.y) * amount;
775
+ return result;
765
776
  }
766
777
  /**
767
778
  * Gets the dot product of the vector "left" and the vector "right"