@babylonjs/viewer 7.12.0 → 7.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/interfaces.js CHANGED
@@ -1,2 +1,7 @@
1
- export {};
1
+ export var CameraBehavior;
2
+ (function (CameraBehavior) {
3
+ CameraBehavior[CameraBehavior["AUTOROTATION"] = 0] = "AUTOROTATION";
4
+ CameraBehavior[CameraBehavior["BOUNCING"] = 1] = "BOUNCING";
5
+ CameraBehavior[CameraBehavior["FRAMING"] = 2] = "FRAMING";
6
+ })(CameraBehavior || (CameraBehavior = {}));
2
7
  //# sourceMappingURL=interfaces.js.map
package/interfaces.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../tools/viewer/src/interfaces.ts"],"names":[],"mappings":"","sourcesContent":["export const enum CameraBehavior {\r\n AUTOROTATION,\r\n BOUNCING,\r\n FRAMING,\r\n}\r\n"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../tools/viewer/src/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mEAAY,CAAA;IACZ,2DAAQ,CAAA;IACR,yDAAO,CAAA;AACX,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B","sourcesContent":["export const enum CameraBehavior {\r\n AUTOROTATION,\r\n BOUNCING,\r\n FRAMING,\r\n}\r\n"]}
package/labs/texture.js CHANGED
@@ -1,7 +1,58 @@
1
1
  import { CubeTexture } from "@babylonjs/core/Materials/Textures/cubeTexture.js";
2
- import { InternalTexture, InternalTextureSource } from "@babylonjs/core/Materials/Textures/internalTexture.js";
2
+ import { InternalTexture } from "@babylonjs/core/Materials/Textures/internalTexture.js";
3
3
  import { Scalar } from "@babylonjs/core/Maths/math.scalar.js";
4
4
  import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
5
+ /**
6
+ * WebGL Pixel Formats
7
+ */
8
+ export var PixelFormat;
9
+ (function (PixelFormat) {
10
+ PixelFormat[PixelFormat["DEPTH_COMPONENT"] = 6402] = "DEPTH_COMPONENT";
11
+ PixelFormat[PixelFormat["ALPHA"] = 6406] = "ALPHA";
12
+ PixelFormat[PixelFormat["RGB"] = 6407] = "RGB";
13
+ PixelFormat[PixelFormat["RGBA"] = 6408] = "RGBA";
14
+ PixelFormat[PixelFormat["LUMINANCE"] = 6409] = "LUMINANCE";
15
+ PixelFormat[PixelFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA";
16
+ })(PixelFormat || (PixelFormat = {}));
17
+ /**
18
+ * WebGL Pixel Types
19
+ */
20
+ export var PixelType;
21
+ (function (PixelType) {
22
+ PixelType[PixelType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE";
23
+ PixelType[PixelType["UNSIGNED_SHORT_4_4_4_4"] = 32819] = "UNSIGNED_SHORT_4_4_4_4";
24
+ PixelType[PixelType["UNSIGNED_SHORT_5_5_5_1"] = 32820] = "UNSIGNED_SHORT_5_5_5_1";
25
+ PixelType[PixelType["UNSIGNED_SHORT_5_6_5"] = 33635] = "UNSIGNED_SHORT_5_6_5";
26
+ })(PixelType || (PixelType = {}));
27
+ /**
28
+ * WebGL Texture Magnification Filter
29
+ */
30
+ export var TextureMagFilter;
31
+ (function (TextureMagFilter) {
32
+ TextureMagFilter[TextureMagFilter["NEAREST"] = 9728] = "NEAREST";
33
+ TextureMagFilter[TextureMagFilter["LINEAR"] = 9729] = "LINEAR";
34
+ })(TextureMagFilter || (TextureMagFilter = {}));
35
+ /**
36
+ * WebGL Texture Minification Filter
37
+ */
38
+ export var TextureMinFilter;
39
+ (function (TextureMinFilter) {
40
+ TextureMinFilter[TextureMinFilter["NEAREST"] = 9728] = "NEAREST";
41
+ TextureMinFilter[TextureMinFilter["LINEAR"] = 9729] = "LINEAR";
42
+ TextureMinFilter[TextureMinFilter["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST";
43
+ TextureMinFilter[TextureMinFilter["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST";
44
+ TextureMinFilter[TextureMinFilter["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR";
45
+ TextureMinFilter[TextureMinFilter["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR";
46
+ })(TextureMinFilter || (TextureMinFilter = {}));
47
+ /**
48
+ * WebGL Texture Wrap Modes
49
+ */
50
+ export var TextureWrapMode;
51
+ (function (TextureWrapMode) {
52
+ TextureWrapMode[TextureWrapMode["REPEAT"] = 10497] = "REPEAT";
53
+ TextureWrapMode[TextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE";
54
+ TextureWrapMode[TextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT";
55
+ })(TextureWrapMode || (TextureWrapMode = {}));
5
56
  /**
6
57
  * A minimal WebGL cubemap descriptor
7
58
  */
@@ -89,7 +140,7 @@ export var TextureUtils = /** @class */ (function () {
89
140
  babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale;
90
141
  }
91
142
  babylonTexture.gammaSpace = false;
92
- var internalTexture_1 = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);
143
+ var internalTexture_1 = new InternalTexture(scene.getEngine(), 8 /* InternalTextureSource.CubeRaw */);
93
144
  var glTexture_1 = (_a = internalTexture_1._hardwareTexture) === null || _a === void 0 ? void 0 : _a.underlyingResource;
94
145
  //babylon properties
95
146
  internalTexture_1.isCube = true;
@@ -1 +1 @@
1
- {"version":3,"file":"texture.js","sourceRoot":"","sources":["../../../../tools/viewer/src/labs/texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,8DAAgD;AACjG,OAAO,EAAE,MAAM,EAAE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;KACnB,CAAC;IAEF,gFAAgF;IAChF;;OAEG;IACW,gCAAmB,GAAG,GAAG,CAAC;IACxC;;OAEG;IACW,iCAAoB,GAAG,GAAG,CAAC;IAC7C,mBAAC;CAAA,AAtSD,IAsSC","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CubeTexture } from \"core/Materials/Textures/cubeTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"core/Materials/Textures/internalTexture\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * WebGL Pixel Formats\r\n */\r\nexport const enum PixelFormat {\r\n DEPTH_COMPONENT = 0x1902,\r\n ALPHA = 0x1906,\r\n RGB = 0x1907,\r\n RGBA = 0x1908,\r\n LUMINANCE = 0x1909,\r\n LUMINANCE_ALPHA = 0x190a,\r\n}\r\n\r\n/**\r\n * WebGL Pixel Types\r\n */\r\nexport const enum PixelType {\r\n UNSIGNED_BYTE = 0x1401,\r\n UNSIGNED_SHORT_4_4_4_4 = 0x8033,\r\n UNSIGNED_SHORT_5_5_5_1 = 0x8034,\r\n UNSIGNED_SHORT_5_6_5 = 0x8363,\r\n}\r\n\r\n/**\r\n * WebGL Texture Magnification Filter\r\n */\r\nexport const enum TextureMagFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n}\r\n\r\n/**\r\n * WebGL Texture Minification Filter\r\n */\r\nexport const enum TextureMinFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n NEAREST_MIPMAP_NEAREST = 0x2700,\r\n LINEAR_MIPMAP_NEAREST = 0x2701,\r\n NEAREST_MIPMAP_LINEAR = 0x2702,\r\n LINEAR_MIPMAP_LINEAR = 0x2703,\r\n}\r\n\r\n/**\r\n * WebGL Texture Wrap Modes\r\n */\r\nexport const enum TextureWrapMode {\r\n REPEAT = 0x2901,\r\n CLAMP_TO_EDGE = 0x812f,\r\n MIRRORED_REPEAT = 0x8370,\r\n}\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport interface TextureData {\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n /**\r\n * Height of image\r\n */\r\n height: number;\r\n /**\r\n * Format of pixels in data\r\n */\r\n format: PixelFormat;\r\n /**\r\n * Row byte alignment of pixels in data\r\n */\r\n alignment: number;\r\n /**\r\n * Pixel data\r\n */\r\n data: ArrayBufferView;\r\n}\r\n\r\n/**\r\n * Wraps sampling parameters for a WebGL texture\r\n */\r\nexport interface SamplingParameters {\r\n /**\r\n * Magnification mode when upsampling from a WebGL texture\r\n */\r\n magFilter?: TextureMagFilter;\r\n /**\r\n * Minification mode when upsampling from a WebGL texture\r\n */\r\n minFilter?: TextureMinFilter;\r\n /**\r\n * X axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapS?: TextureWrapMode;\r\n /**\r\n * Y axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapT?: TextureWrapMode;\r\n /**\r\n * Anisotropic filtering samples\r\n */\r\n maxAnisotropy?: number;\r\n}\r\n\r\n/**\r\n * Represents a valid WebGL texture source for use in texImage2D\r\n */\r\nexport type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;\r\n\r\n/**\r\n * A generic set of texture mipmaps (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps<T> = Array<T>;\r\n\r\n/**\r\n * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]\r\n */\r\nexport type Faces<T> = Array<T>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps2D = Mipmaps<TextureSource>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type MipmapsCube = Mipmaps<Faces<TextureSource>>;\r\n\r\n/**\r\n * A minimal WebGL cubemap descriptor\r\n */\r\nexport class TextureCube {\r\n /**\r\n * Returns the width of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Width(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].width : 0;\r\n }\r\n\r\n /**\r\n * Returns the height of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Height(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].height : 0;\r\n }\r\n\r\n /**\r\n * constructor\r\n * @param internalFormat WebGL pixel format for the texture on the GPU\r\n * @param type WebGL pixel type of the supplied data and texture on the GPU\r\n * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object\r\n */\r\n constructor(\r\n public internalFormat: PixelFormat,\r\n public type: PixelType,\r\n public source: MipmapsCube = []\r\n ) {}\r\n}\r\n\r\n/**\r\n * A static class providing methods to aid working with Bablyon textures.\r\n */\r\nexport class TextureUtils {\r\n /**\r\n * A prefix used when storing a babylon texture object reference on a Spectre texture object\r\n */\r\n public static BabylonTextureKeyPrefix = \"__babylonTexture_\";\r\n\r\n /**\r\n * Controls anisotropic filtering for deserialized textures.\r\n */\r\n public static MaxAnisotropy = 4;\r\n\r\n /**\r\n * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.\r\n * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.\r\n * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.\r\n * @param scene A Babylon Scene instance\r\n * @param textureCube A Spectre TextureCube object\r\n * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)\r\n * @param environment Specifies that the texture will be used as an environment\r\n * @param singleLod Specifies that the texture will be a singleLod (for environment)\r\n * @returns Babylon cube texture\r\n */\r\n public static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment = false, singleLod = false): CubeTexture {\r\n if (!textureCube) {\r\n throw new Error(\"no texture cube provided\");\r\n }\r\n\r\n let parameters: SamplingParameters;\r\n if (environment) {\r\n parameters = singleLod ? TextureUtils._EnvironmentSingleMipSampling : TextureUtils._EnvironmentSampling;\r\n } else {\r\n parameters = {\r\n magFilter: TextureMagFilter.NEAREST,\r\n minFilter: TextureMinFilter.NEAREST,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n };\r\n }\r\n\r\n const key = TextureUtils.BabylonTextureKeyPrefix + parameters.magFilter + \"\" + parameters.minFilter + \"\" + parameters.wrapS + \"\" + parameters.wrapT;\r\n\r\n let babylonTexture: CubeTexture = (<any>textureCube)[key];\r\n\r\n if (!babylonTexture) {\r\n //initialize babylon texture\r\n babylonTexture = new CubeTexture(\"\", scene);\r\n if (environment) {\r\n babylonTexture.lodGenerationOffset = TextureUtils.EnvironmentLODOffset;\r\n babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale;\r\n }\r\n\r\n babylonTexture.gammaSpace = false;\r\n\r\n const internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n //babylon properties\r\n internalTexture.isCube = true;\r\n internalTexture.generateMipMaps = false;\r\n\r\n babylonTexture._texture = internalTexture;\r\n\r\n TextureUtils.ApplySamplingParameters(babylonTexture, parameters);\r\n\r\n const maxMipLevel = automaticMipmaps ? 0 : textureCube.source.length - 1;\r\n let texturesUploaded = 0;\r\n\r\n const textureComplete = function () {\r\n return texturesUploaded === (maxMipLevel + 1) * 6;\r\n };\r\n\r\n const uploadFace = function (i: number, level: number, face: TextureSource) {\r\n if (!glTexture) {\r\n return;\r\n }\r\n\r\n if (i === 0 && level === 0) {\r\n internalTexture.width = face.width;\r\n internalTexture.height = face.height;\r\n }\r\n\r\n const gl = (<any>scene.getEngine())._gl;\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, glTexture);\r\n (scene.getEngine() as Engine)._unpackFlipY(false);\r\n if (face instanceof HTMLElement || face instanceof ImageData) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureCube.internalFormat, textureCube.type, <any>face);\r\n } else {\r\n const textureData = <TextureData>face;\r\n gl.texImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n level,\r\n textureCube.internalFormat,\r\n textureData.width,\r\n textureData.height,\r\n 0,\r\n textureData.format,\r\n textureCube.type,\r\n textureData.data\r\n );\r\n }\r\n\r\n texturesUploaded++;\r\n\r\n if (textureComplete()) {\r\n //generate mipmaps\r\n if (automaticMipmaps) {\r\n const w = face.width;\r\n const h = face.height;\r\n const isPot = (w !== 0 && w & (w - 1)) === 0 && (h !== 0 && h & (h - 1)) === 0;\r\n if (isPot) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n }\r\n\r\n // Upload Separate lods in case there is no support for texture lod.\r\n if (environment && !scene.getEngine().getCaps().textureLOD && !singleLod) {\r\n const mipSlices = 3;\r\n for (let i = 0; i < mipSlices; i++) {\r\n const lodKey = TextureUtils.BabylonTextureKeyPrefix + \"lod\" + i;\r\n let lod: CubeTexture = (<any>textureCube)[lodKey];\r\n\r\n //initialize lod texture if it doesn't already exist\r\n if (lod == null && textureCube.Width) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n const kMinimumVariance = 0.0005;\r\n const alphaG = roughness * roughness + kMinimumVariance;\r\n const microsurfaceAverageSlopeTexels = alphaG * textureCube.Width;\r\n\r\n const environmentSpecularLOD = TextureUtils.EnvironmentLODScale * Scalar.Log2(microsurfaceAverageSlopeTexels) + TextureUtils.EnvironmentLODOffset;\r\n\r\n const maxLODIndex = textureCube.source.length - 1;\r\n const mipmapIndex = Math.min(Math.max(Math.round(environmentSpecularLOD), 0), maxLODIndex);\r\n\r\n lod = TextureUtils.GetBabylonCubeTexture(\r\n scene,\r\n new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, [textureCube.source[mipmapIndex]]),\r\n false,\r\n true,\r\n true\r\n );\r\n\r\n if (i === 0) {\r\n internalTexture._lodTextureLow = lod;\r\n } else if (i === 1) {\r\n internalTexture._lodTextureMid = lod;\r\n } else {\r\n internalTexture._lodTextureHigh = lod;\r\n }\r\n\r\n (<any>textureCube)[lodKey] = lod;\r\n }\r\n }\r\n }\r\n\r\n internalTexture.isReady = true;\r\n }\r\n\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);\r\n scene.getEngine().resetTextureCache();\r\n };\r\n\r\n for (let i = 0; i <= maxMipLevel; i++) {\r\n const faces = textureCube.source[i];\r\n for (let j = 0; j < faces.length; j++) {\r\n const face = faces[j];\r\n if (face instanceof HTMLImageElement && !face.complete) {\r\n face.addEventListener(\r\n \"load\",\r\n () => {\r\n uploadFace(j, i, face);\r\n },\r\n false\r\n );\r\n } else {\r\n uploadFace(j, i, face);\r\n }\r\n }\r\n }\r\n\r\n scene.getEngine().resetTextureCache();\r\n\r\n babylonTexture.isReady = () => {\r\n return textureComplete();\r\n };\r\n\r\n (<any>textureCube)[key] = babylonTexture;\r\n }\r\n\r\n return babylonTexture;\r\n }\r\n\r\n /**\r\n * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields\r\n * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)\r\n * @param parameters Spectre SamplingParameters to apply\r\n */\r\n public static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters) {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n return;\r\n }\r\n const gl = (<any>scene.getEngine())._gl;\r\n\r\n const target = babylonTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n\r\n const internalTexture = babylonTexture._texture;\r\n if (!internalTexture) {\r\n return;\r\n }\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n gl.bindTexture(target, glTexture);\r\n\r\n if (parameters.magFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, parameters.magFilter);\r\n }\r\n if (parameters.minFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, parameters.minFilter);\r\n }\r\n if (parameters.wrapS != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, parameters.wrapS);\r\n }\r\n if (parameters.wrapT != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, parameters.wrapT);\r\n }\r\n\r\n //set babylon wrap modes from sampling parameter\r\n switch (parameters.wrapS) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapU = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n switch (parameters.wrapT) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapV = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n if (parameters.maxAnisotropy != null && parameters.maxAnisotropy > 1) {\r\n const anisotropicExt = gl.getExtension(\"EXT_texture_filter_anisotropic\");\r\n if (anisotropicExt) {\r\n const maxAnisotropicSamples = gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\r\n const maxAnisotropy = Math.min(parameters.maxAnisotropy, maxAnisotropicSamples);\r\n gl.texParameterf(target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);\r\n babylonTexture.anisotropicFilteringLevel = maxAnisotropy;\r\n }\r\n }\r\n\r\n gl.bindTexture(target, null);\r\n scene.getEngine().resetTextureCache();\r\n }\r\n\r\n private static _EnvironmentSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR_MIPMAP_LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n private static _EnvironmentSingleMipSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n //from \"/Internal/Lighting.EnvironmentFilterScale\" in Engine/*/Configuration.cpp\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only).\r\n */\r\n public static EnvironmentLODScale = 0.8;\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only)..\r\n */\r\n public static EnvironmentLODOffset = 1.0;\r\n}\r\n"]}
1
+ {"version":3,"file":"texture.js","sourceRoot":"","sources":["../../../../tools/viewer/src/labs/texture.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,0DAA4C;AAClE,OAAO,EAAE,eAAe,EAAyB,8DAAgD;AACjG,OAAO,EAAE,MAAM,EAAE,6CAA+B;AAEhD,OAAO,EAAE,OAAO,EAAE,sDAAwC;AAG1D;;GAEG;AACH,MAAM,CAAN,IAAkB,WAOjB;AAPD,WAAkB,WAAW;IACz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ACzE,IAAI,cAAc,EAAE;gBAChB,IAAM,qBAAqB,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,8BAA8B,CAAC,CAAC;gBAC7F,IAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;gBAChF,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,cAAc,CAAC,0BAA0B,EAAE,aAAa,CAAC,CAAC;gBACnF,cAAc,CAAC,yBAAyB,GAAG,aAAa,CAAC;aAC5D;SACJ;QAED,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAC7B,KAAK,CAAC,SAAS,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAC1C,CAAC;IA1QD;;OAEG;IACW,oCAAuB,GAAG,mBAAmB,CAAC;IAE5D;;OAEG;IACW,0BAAa,GAAG,CAAC,CAAC;IAoQjB,iCAAoB,GAAuB;QACtD,SAAS,oCAAyB;QAClC,SAAS,kDAAuC;QAChD,KAAK,2CAA+B;QACpC,KAAK,2CAA+B;QACpC,aAAa,EAAE,CAAC;KACnB,CAAC;IAEa,0CAA6B,GAAuB;QAC/D,SAAS,oCAAyB;QAClC,SAAS,oCAAyB;QAClC,KAAK,2CAA+B;QACpC,KAAK,2CAA+B;QACpC,aAAa,EAAE,CAAC;KACnB,CAAC;IAEF,gFAAgF;IAChF;;OAEG;IACW,gCAAmB,GAAG,GAAG,CAAC;IACxC;;OAEG;IACW,iCAAoB,GAAG,GAAG,CAAC;IAC7C,mBAAC;CAAA,AAtSD,IAsSC","sourcesContent":["import type { Scene } from \"core/scene\";\r\nimport { CubeTexture } from \"core/Materials/Textures/cubeTexture\";\r\nimport { InternalTexture, InternalTextureSource } from \"core/Materials/Textures/internalTexture\";\r\nimport { Scalar } from \"core/Maths/math.scalar\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport { Texture } from \"core/Materials/Textures/texture\";\r\nimport type { Engine } from \"core/Engines/engine\";\r\n\r\n/**\r\n * WebGL Pixel Formats\r\n */\r\nexport const enum PixelFormat {\r\n DEPTH_COMPONENT = 0x1902,\r\n ALPHA = 0x1906,\r\n RGB = 0x1907,\r\n RGBA = 0x1908,\r\n LUMINANCE = 0x1909,\r\n LUMINANCE_ALPHA = 0x190a,\r\n}\r\n\r\n/**\r\n * WebGL Pixel Types\r\n */\r\nexport const enum PixelType {\r\n UNSIGNED_BYTE = 0x1401,\r\n UNSIGNED_SHORT_4_4_4_4 = 0x8033,\r\n UNSIGNED_SHORT_5_5_5_1 = 0x8034,\r\n UNSIGNED_SHORT_5_6_5 = 0x8363,\r\n}\r\n\r\n/**\r\n * WebGL Texture Magnification Filter\r\n */\r\nexport const enum TextureMagFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n}\r\n\r\n/**\r\n * WebGL Texture Minification Filter\r\n */\r\nexport const enum TextureMinFilter {\r\n NEAREST = 0x2600,\r\n LINEAR = 0x2601,\r\n NEAREST_MIPMAP_NEAREST = 0x2700,\r\n LINEAR_MIPMAP_NEAREST = 0x2701,\r\n NEAREST_MIPMAP_LINEAR = 0x2702,\r\n LINEAR_MIPMAP_LINEAR = 0x2703,\r\n}\r\n\r\n/**\r\n * WebGL Texture Wrap Modes\r\n */\r\nexport const enum TextureWrapMode {\r\n REPEAT = 0x2901,\r\n CLAMP_TO_EDGE = 0x812f,\r\n MIRRORED_REPEAT = 0x8370,\r\n}\r\n\r\n/**\r\n * Raw texture data and descriptor sufficient for WebGL texture upload\r\n */\r\nexport interface TextureData {\r\n /**\r\n * Width of image\r\n */\r\n width: number;\r\n /**\r\n * Height of image\r\n */\r\n height: number;\r\n /**\r\n * Format of pixels in data\r\n */\r\n format: PixelFormat;\r\n /**\r\n * Row byte alignment of pixels in data\r\n */\r\n alignment: number;\r\n /**\r\n * Pixel data\r\n */\r\n data: ArrayBufferView;\r\n}\r\n\r\n/**\r\n * Wraps sampling parameters for a WebGL texture\r\n */\r\nexport interface SamplingParameters {\r\n /**\r\n * Magnification mode when upsampling from a WebGL texture\r\n */\r\n magFilter?: TextureMagFilter;\r\n /**\r\n * Minification mode when upsampling from a WebGL texture\r\n */\r\n minFilter?: TextureMinFilter;\r\n /**\r\n * X axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapS?: TextureWrapMode;\r\n /**\r\n * Y axis wrapping mode when sampling out of a WebGL texture bounds\r\n */\r\n wrapT?: TextureWrapMode;\r\n /**\r\n * Anisotropic filtering samples\r\n */\r\n maxAnisotropy?: number;\r\n}\r\n\r\n/**\r\n * Represents a valid WebGL texture source for use in texImage2D\r\n */\r\nexport type TextureSource = TextureData | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement;\r\n\r\n/**\r\n * A generic set of texture mipmaps (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps<T> = Array<T>;\r\n\r\n/**\r\n * A set of 6 cubemap arranged in the order [+x, -x, +y, -y, +z, -z]\r\n */\r\nexport type Faces<T> = Array<T>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for 2D textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type Mipmaps2D = Mipmaps<TextureSource>;\r\n\r\n/**\r\n * A set of texture mipmaps specifically for cubemap textures in WebGL (where index 0 has the largest dimension)\r\n */\r\nexport type MipmapsCube = Mipmaps<Faces<TextureSource>>;\r\n\r\n/**\r\n * A minimal WebGL cubemap descriptor\r\n */\r\nexport class TextureCube {\r\n /**\r\n * Returns the width of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Width(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].width : 0;\r\n }\r\n\r\n /**\r\n * Returns the height of a face of the texture or 0 if not available\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public get Height(): number {\r\n return this.source && this.source[0] && this.source[0][0] ? this.source[0][0].height : 0;\r\n }\r\n\r\n /**\r\n * constructor\r\n * @param internalFormat WebGL pixel format for the texture on the GPU\r\n * @param type WebGL pixel type of the supplied data and texture on the GPU\r\n * @param source An array containing mipmap levels of faces, where each mipmap level is an array of faces and each face is a TextureSource object\r\n */\r\n constructor(\r\n public internalFormat: PixelFormat,\r\n public type: PixelType,\r\n public source: MipmapsCube = []\r\n ) {}\r\n}\r\n\r\n/**\r\n * A static class providing methods to aid working with Bablyon textures.\r\n */\r\nexport class TextureUtils {\r\n /**\r\n * A prefix used when storing a babylon texture object reference on a Spectre texture object\r\n */\r\n public static BabylonTextureKeyPrefix = \"__babylonTexture_\";\r\n\r\n /**\r\n * Controls anisotropic filtering for deserialized textures.\r\n */\r\n public static MaxAnisotropy = 4;\r\n\r\n /**\r\n * Returns a BabylonCubeTexture instance from a Spectre texture cube, subject to sampling parameters.\r\n * If such a texture has already been requested in the past, this texture will be returned, otherwise a new one will be created.\r\n * The advantage of this is to enable working with texture objects without the need to initialize on the GPU until desired.\r\n * @param scene A Babylon Scene instance\r\n * @param textureCube A Spectre TextureCube object\r\n * @param automaticMipmaps Pass true to enable automatic mipmap generation where possible (requires power of images)\r\n * @param environment Specifies that the texture will be used as an environment\r\n * @param singleLod Specifies that the texture will be a singleLod (for environment)\r\n * @returns Babylon cube texture\r\n */\r\n public static GetBabylonCubeTexture(scene: Scene, textureCube: TextureCube, automaticMipmaps: boolean, environment = false, singleLod = false): CubeTexture {\r\n if (!textureCube) {\r\n throw new Error(\"no texture cube provided\");\r\n }\r\n\r\n let parameters: SamplingParameters;\r\n if (environment) {\r\n parameters = singleLod ? TextureUtils._EnvironmentSingleMipSampling : TextureUtils._EnvironmentSampling;\r\n } else {\r\n parameters = {\r\n magFilter: TextureMagFilter.NEAREST,\r\n minFilter: TextureMinFilter.NEAREST,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n };\r\n }\r\n\r\n const key = TextureUtils.BabylonTextureKeyPrefix + parameters.magFilter + \"\" + parameters.minFilter + \"\" + parameters.wrapS + \"\" + parameters.wrapT;\r\n\r\n let babylonTexture: CubeTexture = (<any>textureCube)[key];\r\n\r\n if (!babylonTexture) {\r\n //initialize babylon texture\r\n babylonTexture = new CubeTexture(\"\", scene);\r\n if (environment) {\r\n babylonTexture.lodGenerationOffset = TextureUtils.EnvironmentLODOffset;\r\n babylonTexture.lodGenerationScale = TextureUtils.EnvironmentLODScale;\r\n }\r\n\r\n babylonTexture.gammaSpace = false;\r\n\r\n const internalTexture = new InternalTexture(scene.getEngine(), InternalTextureSource.CubeRaw);\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n //babylon properties\r\n internalTexture.isCube = true;\r\n internalTexture.generateMipMaps = false;\r\n\r\n babylonTexture._texture = internalTexture;\r\n\r\n TextureUtils.ApplySamplingParameters(babylonTexture, parameters);\r\n\r\n const maxMipLevel = automaticMipmaps ? 0 : textureCube.source.length - 1;\r\n let texturesUploaded = 0;\r\n\r\n const textureComplete = function () {\r\n return texturesUploaded === (maxMipLevel + 1) * 6;\r\n };\r\n\r\n const uploadFace = function (i: number, level: number, face: TextureSource) {\r\n if (!glTexture) {\r\n return;\r\n }\r\n\r\n if (i === 0 && level === 0) {\r\n internalTexture.width = face.width;\r\n internalTexture.height = face.height;\r\n }\r\n\r\n const gl = (<any>scene.getEngine())._gl;\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, glTexture);\r\n (scene.getEngine() as Engine)._unpackFlipY(false);\r\n if (face instanceof HTMLElement || face instanceof ImageData) {\r\n gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, level, textureCube.internalFormat, textureCube.internalFormat, textureCube.type, <any>face);\r\n } else {\r\n const textureData = <TextureData>face;\r\n gl.texImage2D(\r\n gl.TEXTURE_CUBE_MAP_POSITIVE_X + i,\r\n level,\r\n textureCube.internalFormat,\r\n textureData.width,\r\n textureData.height,\r\n 0,\r\n textureData.format,\r\n textureCube.type,\r\n textureData.data\r\n );\r\n }\r\n\r\n texturesUploaded++;\r\n\r\n if (textureComplete()) {\r\n //generate mipmaps\r\n if (automaticMipmaps) {\r\n const w = face.width;\r\n const h = face.height;\r\n const isPot = (w !== 0 && w & (w - 1)) === 0 && (h !== 0 && h & (h - 1)) === 0;\r\n if (isPot) {\r\n gl.generateMipmap(gl.TEXTURE_CUBE_MAP);\r\n }\r\n }\r\n\r\n // Upload Separate lods in case there is no support for texture lod.\r\n if (environment && !scene.getEngine().getCaps().textureLOD && !singleLod) {\r\n const mipSlices = 3;\r\n for (let i = 0; i < mipSlices; i++) {\r\n const lodKey = TextureUtils.BabylonTextureKeyPrefix + \"lod\" + i;\r\n let lod: CubeTexture = (<any>textureCube)[lodKey];\r\n\r\n //initialize lod texture if it doesn't already exist\r\n if (lod == null && textureCube.Width) {\r\n //compute LOD from even spacing in smoothness (matching shader calculation)\r\n const smoothness = i / (mipSlices - 1);\r\n const roughness = 1 - smoothness;\r\n const kMinimumVariance = 0.0005;\r\n const alphaG = roughness * roughness + kMinimumVariance;\r\n const microsurfaceAverageSlopeTexels = alphaG * textureCube.Width;\r\n\r\n const environmentSpecularLOD = TextureUtils.EnvironmentLODScale * Scalar.Log2(microsurfaceAverageSlopeTexels) + TextureUtils.EnvironmentLODOffset;\r\n\r\n const maxLODIndex = textureCube.source.length - 1;\r\n const mipmapIndex = Math.min(Math.max(Math.round(environmentSpecularLOD), 0), maxLODIndex);\r\n\r\n lod = TextureUtils.GetBabylonCubeTexture(\r\n scene,\r\n new TextureCube(PixelFormat.RGBA, PixelType.UNSIGNED_BYTE, [textureCube.source[mipmapIndex]]),\r\n false,\r\n true,\r\n true\r\n );\r\n\r\n if (i === 0) {\r\n internalTexture._lodTextureLow = lod;\r\n } else if (i === 1) {\r\n internalTexture._lodTextureMid = lod;\r\n } else {\r\n internalTexture._lodTextureHigh = lod;\r\n }\r\n\r\n (<any>textureCube)[lodKey] = lod;\r\n }\r\n }\r\n }\r\n\r\n internalTexture.isReady = true;\r\n }\r\n\r\n gl.bindTexture(gl.TEXTURE_CUBE_MAP, null);\r\n scene.getEngine().resetTextureCache();\r\n };\r\n\r\n for (let i = 0; i <= maxMipLevel; i++) {\r\n const faces = textureCube.source[i];\r\n for (let j = 0; j < faces.length; j++) {\r\n const face = faces[j];\r\n if (face instanceof HTMLImageElement && !face.complete) {\r\n face.addEventListener(\r\n \"load\",\r\n () => {\r\n uploadFace(j, i, face);\r\n },\r\n false\r\n );\r\n } else {\r\n uploadFace(j, i, face);\r\n }\r\n }\r\n }\r\n\r\n scene.getEngine().resetTextureCache();\r\n\r\n babylonTexture.isReady = () => {\r\n return textureComplete();\r\n };\r\n\r\n (<any>textureCube)[key] = babylonTexture;\r\n }\r\n\r\n return babylonTexture;\r\n }\r\n\r\n /**\r\n * Applies Spectre SamplingParameters to a Babylon texture by directly setting texture parameters on the internal WebGLTexture as well as setting Babylon fields\r\n * @param babylonTexture Babylon texture to apply texture to (requires the Babylon texture has an initialize _texture field)\r\n * @param parameters Spectre SamplingParameters to apply\r\n */\r\n public static ApplySamplingParameters(babylonTexture: BaseTexture, parameters: SamplingParameters) {\r\n const scene = babylonTexture.getScene();\r\n if (!scene) {\r\n return;\r\n }\r\n const gl = (<any>scene.getEngine())._gl;\r\n\r\n const target = babylonTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;\r\n\r\n const internalTexture = babylonTexture._texture;\r\n if (!internalTexture) {\r\n return;\r\n }\r\n const glTexture = internalTexture._hardwareTexture?.underlyingResource;\r\n gl.bindTexture(target, glTexture);\r\n\r\n if (parameters.magFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, parameters.magFilter);\r\n }\r\n if (parameters.minFilter != null) {\r\n gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, parameters.minFilter);\r\n }\r\n if (parameters.wrapS != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_S, parameters.wrapS);\r\n }\r\n if (parameters.wrapT != null) {\r\n gl.texParameteri(target, gl.TEXTURE_WRAP_T, parameters.wrapT);\r\n }\r\n\r\n //set babylon wrap modes from sampling parameter\r\n switch (parameters.wrapS) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapU = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapU = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapU = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n switch (parameters.wrapT) {\r\n case TextureWrapMode.REPEAT:\r\n babylonTexture.wrapV = Texture.WRAP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.CLAMP_TO_EDGE:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n break;\r\n case TextureWrapMode.MIRRORED_REPEAT:\r\n babylonTexture.wrapV = Texture.MIRROR_ADDRESSMODE;\r\n break;\r\n default:\r\n babylonTexture.wrapV = Texture.CLAMP_ADDRESSMODE;\r\n }\r\n\r\n if (parameters.maxAnisotropy != null && parameters.maxAnisotropy > 1) {\r\n const anisotropicExt = gl.getExtension(\"EXT_texture_filter_anisotropic\");\r\n if (anisotropicExt) {\r\n const maxAnisotropicSamples = gl.getParameter(anisotropicExt.MAX_TEXTURE_MAX_ANISOTROPY_EXT);\r\n const maxAnisotropy = Math.min(parameters.maxAnisotropy, maxAnisotropicSamples);\r\n gl.texParameterf(target, anisotropicExt.TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);\r\n babylonTexture.anisotropicFilteringLevel = maxAnisotropy;\r\n }\r\n }\r\n\r\n gl.bindTexture(target, null);\r\n scene.getEngine().resetTextureCache();\r\n }\r\n\r\n private static _EnvironmentSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR_MIPMAP_LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n private static _EnvironmentSingleMipSampling: SamplingParameters = {\r\n magFilter: TextureMagFilter.LINEAR,\r\n minFilter: TextureMinFilter.LINEAR,\r\n wrapS: TextureWrapMode.CLAMP_TO_EDGE,\r\n wrapT: TextureWrapMode.CLAMP_TO_EDGE,\r\n maxAnisotropy: 1,\r\n };\r\n\r\n //from \"/Internal/Lighting.EnvironmentFilterScale\" in Engine/*/Configuration.cpp\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only).\r\n */\r\n public static EnvironmentLODScale = 0.8;\r\n /**\r\n * Environment preprocessing dedicated value (Internal Use or Advanced only)..\r\n */\r\n public static EnvironmentLODOffset = 1.0;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/viewer",
3
- "version": "7.12.0",
3
+ "version": "7.13.0",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -18,10 +18,10 @@
18
18
  "postcompile": "build-tools -c add-js-to-es6"
19
19
  },
20
20
  "dependencies": {
21
- "@babylonjs/core": "^7.12.0",
22
- "@babylonjs/loaders": "^7.12.0",
23
- "babylonjs-gltf2interface": "^7.12.0",
24
- "babylonjs-viewer-assets": "^7.12.0",
21
+ "@babylonjs/core": "^7.13.0",
22
+ "@babylonjs/loaders": "^7.13.0",
23
+ "babylonjs-gltf2interface": "^7.13.0",
24
+ "babylonjs-viewer-assets": "^7.13.0",
25
25
  "deepmerge": "~4.2.2",
26
26
  "handlebars": "~4.7.7",
27
27
  "pepjs": "~0.5.3",