@itwin/core-frontend 3.0.0-dev.172 → 3.0.0-dev.176
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/LICENSE.md +1 -1
- package/lib/cjs/IModelApp.js +1 -1
- package/lib/cjs/IModelApp.js.map +1 -1
- package/lib/cjs/SheetViewState.d.ts.map +1 -1
- package/lib/cjs/SheetViewState.js +1 -2
- package/lib/cjs/SheetViewState.js.map +1 -1
- package/lib/cjs/render/RenderSystem.d.ts.map +1 -1
- package/lib/cjs/render/RenderSystem.js +5 -6
- package/lib/cjs/render/RenderSystem.js.map +1 -1
- package/lib/cjs/render/RenderTexture.d.ts +2 -17
- package/lib/cjs/render/RenderTexture.d.ts.map +1 -1
- package/lib/cjs/render/RenderTexture.js +0 -17
- package/lib/cjs/render/RenderTexture.js.map +1 -1
- package/lib/cjs/render/primitives/Primitives.d.ts +1 -1
- package/lib/cjs/render/primitives/Primitives.d.ts.map +1 -1
- package/lib/cjs/render/primitives/Primitives.js.map +1 -1
- package/lib/cjs/render/webgl/BackgroundMapDrape.js +1 -1
- package/lib/cjs/render/webgl/BackgroundMapDrape.js.map +1 -1
- package/lib/cjs/render/webgl/PlanarClassifier.d.ts.map +1 -1
- package/lib/cjs/render/webgl/PlanarClassifier.js +2 -1
- package/lib/cjs/render/webgl/PlanarClassifier.js.map +1 -1
- package/lib/cjs/render/webgl/SolarShadowMap.d.ts.map +1 -1
- package/lib/cjs/render/webgl/SolarShadowMap.js +2 -2
- package/lib/cjs/render/webgl/SolarShadowMap.js.map +1 -1
- package/lib/cjs/render/webgl/System.d.ts.map +1 -1
- package/lib/cjs/render/webgl/System.js +15 -11
- package/lib/cjs/render/webgl/System.js.map +1 -1
- package/lib/cjs/render/webgl/Texture.d.ts +15 -11
- package/lib/cjs/render/webgl/Texture.d.ts.map +1 -1
- package/lib/cjs/render/webgl/Texture.js +27 -23
- package/lib/cjs/render/webgl/Texture.js.map +1 -1
- package/lib/cjs/tile/GltfReader.d.ts +29 -17
- package/lib/cjs/tile/GltfReader.d.ts.map +1 -1
- package/lib/cjs/tile/GltfReader.js +103 -80
- package/lib/cjs/tile/GltfReader.js.map +1 -1
- package/lib/cjs/tile/ImdlReader.d.ts +3 -1
- package/lib/cjs/tile/ImdlReader.d.ts.map +1 -1
- package/lib/cjs/tile/ImdlReader.js +1 -1
- package/lib/cjs/tile/ImdlReader.js.map +1 -1
- package/lib/esm/IModelApp.js +1 -1
- package/lib/esm/IModelApp.js.map +1 -1
- package/lib/esm/SheetViewState.d.ts.map +1 -1
- package/lib/esm/SheetViewState.js +1 -2
- package/lib/esm/SheetViewState.js.map +1 -1
- package/lib/esm/render/RenderSystem.d.ts.map +1 -1
- package/lib/esm/render/RenderSystem.js +6 -7
- package/lib/esm/render/RenderSystem.js.map +1 -1
- package/lib/esm/render/RenderTexture.d.ts +2 -17
- package/lib/esm/render/RenderTexture.d.ts.map +1 -1
- package/lib/esm/render/RenderTexture.js +1 -16
- package/lib/esm/render/RenderTexture.js.map +1 -1
- package/lib/esm/render/primitives/Primitives.d.ts +1 -1
- package/lib/esm/render/primitives/Primitives.d.ts.map +1 -1
- package/lib/esm/render/primitives/Primitives.js.map +1 -1
- package/lib/esm/render/webgl/BackgroundMapDrape.js +2 -2
- package/lib/esm/render/webgl/BackgroundMapDrape.js.map +1 -1
- package/lib/esm/render/webgl/PlanarClassifier.d.ts.map +1 -1
- package/lib/esm/render/webgl/PlanarClassifier.js +3 -2
- package/lib/esm/render/webgl/PlanarClassifier.js.map +1 -1
- package/lib/esm/render/webgl/SolarShadowMap.d.ts.map +1 -1
- package/lib/esm/render/webgl/SolarShadowMap.js +3 -3
- package/lib/esm/render/webgl/SolarShadowMap.js.map +1 -1
- package/lib/esm/render/webgl/System.d.ts.map +1 -1
- package/lib/esm/render/webgl/System.js +16 -12
- package/lib/esm/render/webgl/System.js.map +1 -1
- package/lib/esm/render/webgl/Texture.d.ts +15 -11
- package/lib/esm/render/webgl/Texture.d.ts.map +1 -1
- package/lib/esm/render/webgl/Texture.js +28 -24
- package/lib/esm/render/webgl/Texture.js.map +1 -1
- package/lib/esm/tile/GltfReader.d.ts +29 -17
- package/lib/esm/tile/GltfReader.d.ts.map +1 -1
- package/lib/esm/tile/GltfReader.js +105 -82
- package/lib/esm/tile/GltfReader.js.map +1 -1
- package/lib/esm/tile/ImdlReader.d.ts +3 -1
- package/lib/esm/tile/ImdlReader.d.ts.map +1 -1
- package/lib/esm/tile/ImdlReader.js +1 -1
- package/lib/esm/tile/ImdlReader.js.map +1 -1
- package/package.json +22 -22
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module WebGL
|
|
7
7
|
*/
|
|
8
8
|
import { assert, BeEvent, dispose } from "@itwin/core-bentley";
|
|
9
|
-
import { ImageBuffer, ImageBufferFormat, ImageSource,
|
|
9
|
+
import { ImageBuffer, ImageBufferFormat, ImageSource, isPowerOfTwo, nextHighestPowerOfTwo, RenderTexture, TextureTransparency, } from "@itwin/core-common";
|
|
10
10
|
import { getImageSourceMimeType, imageBufferToPngDataUrl, imageElementFromImageSource, openImageDataUrlInNewWindow } from "../../ImageUtil";
|
|
11
11
|
import { IModelApp } from "../../IModelApp";
|
|
12
12
|
import { GL } from "./GL";
|
|
@@ -101,6 +101,7 @@ export class Texture extends RenderTexture {
|
|
|
101
101
|
super(params.type);
|
|
102
102
|
this.ownership = params.ownership;
|
|
103
103
|
this.texture = params.handle;
|
|
104
|
+
this.transparency = params.handle.format === GL.Texture.Format.Rgba ? params.transparency : TextureTransparency.Opaque;
|
|
104
105
|
}
|
|
105
106
|
get bytesUsed() { return this.texture.bytesUsed; }
|
|
106
107
|
get hasOwner() { return undefined !== this.ownership; }
|
|
@@ -113,7 +114,7 @@ export class Texture extends RenderTexture {
|
|
|
113
114
|
dispose() {
|
|
114
115
|
dispose(this.texture);
|
|
115
116
|
}
|
|
116
|
-
get hasTranslucency() { return
|
|
117
|
+
get hasTranslucency() { return TextureTransparency.Opaque !== this.transparency; }
|
|
117
118
|
}
|
|
118
119
|
function getDataType(data) {
|
|
119
120
|
return data instanceof Float32Array ? GL.Texture.DataType.Float : GL.Texture.DataType.UnsignedByte;
|
|
@@ -137,14 +138,16 @@ class Texture2DCreateParams {
|
|
|
137
138
|
return new Texture2DCreateParams(width, height, format, getDataType(data), wrapMode, (tex, params) => loadTextureFromBytes(tex, params, data), undefined, undefined, undefined, bytes);
|
|
138
139
|
}
|
|
139
140
|
static createForImageBuffer(image, type) {
|
|
140
|
-
const props = this.getImageProperties(
|
|
141
|
+
const props = this.getImageProperties(type);
|
|
142
|
+
if (ImageBufferFormat.Rgb === image.format)
|
|
143
|
+
props.format = GL.Texture.Format.Rgb;
|
|
141
144
|
return new Texture2DCreateParams(image.width, image.height, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode, (tex, params) => loadTextureFromBytes(tex, params, image.data), props.useMipMaps, props.interpolate);
|
|
142
145
|
}
|
|
143
146
|
static createForAttachment(width, height, format, dataType) {
|
|
144
147
|
return new Texture2DCreateParams(width, height, format, dataType, GL.Texture.WrapMode.ClampToEdge, (tex, params) => loadTextureFromBytes(tex, params), undefined, undefined);
|
|
145
148
|
}
|
|
146
|
-
static createForImage(image,
|
|
147
|
-
const props = this.getImageProperties(
|
|
149
|
+
static createForImage(image, type) {
|
|
150
|
+
const props = this.getImageProperties(type);
|
|
148
151
|
let targetWidth = image.naturalWidth;
|
|
149
152
|
let targetHeight = image.naturalHeight;
|
|
150
153
|
const caps = System.instance.capabilities;
|
|
@@ -180,8 +183,8 @@ class Texture2DCreateParams {
|
|
|
180
183
|
}
|
|
181
184
|
return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode, (tex, params) => loadTexture2DImageData(tex, params, undefined, element), props.useMipMaps, props.interpolate, props.anisotropicFilter);
|
|
182
185
|
}
|
|
183
|
-
static createForImageBitmap(image,
|
|
184
|
-
const props = this.getImageProperties(
|
|
186
|
+
static createForImageBitmap(image, type) {
|
|
187
|
+
const props = this.getImageProperties(type);
|
|
185
188
|
let targetWidth = image.width;
|
|
186
189
|
let targetHeight = image.height;
|
|
187
190
|
const caps = System.instance.capabilities;
|
|
@@ -209,7 +212,7 @@ class Texture2DCreateParams {
|
|
|
209
212
|
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
210
213
|
return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode, (tex, params) => loadTexture2DImageData(tex, params, undefined, canvas), props.useMipMaps, props.interpolate, props.anisotropicFilter);
|
|
211
214
|
}
|
|
212
|
-
static getImageProperties(
|
|
215
|
+
static getImageProperties(type) {
|
|
213
216
|
const isSky = RenderTexture.Type.SkyBox === type;
|
|
214
217
|
const isTile = RenderTexture.Type.TileSection === type;
|
|
215
218
|
const isThematic = RenderTexture.Type.ThematicGradient === type;
|
|
@@ -218,8 +221,9 @@ class Texture2DCreateParams {
|
|
|
218
221
|
const wrapMode = RenderTexture.Type.Normal === type ? GL.Texture.WrapMode.Repeat : GL.Texture.WrapMode.ClampToEdge;
|
|
219
222
|
const useMipMaps = (!isSky && !isTile && !isFilteredTile && !isThematic) ? true : undefined;
|
|
220
223
|
const interpolate = isThematic ? undefined : true;
|
|
221
|
-
const format = isTranslucent ? GL.Texture.Format.Rgba : GL.Texture.Format.Rgb;
|
|
222
224
|
const anisotropicFilter = isFilteredTile ? maxAnisotropicFilterLevel : undefined;
|
|
225
|
+
// Always use RGBA. RGB is much slower and almost certainly does not actually save any GPU memory.
|
|
226
|
+
const format = GL.Texture.Format.Rgba;
|
|
223
227
|
return { format, wrapMode, useMipMaps, interpolate, anisotropicFilter };
|
|
224
228
|
}
|
|
225
229
|
}
|
|
@@ -280,19 +284,19 @@ export class TextureHandle {
|
|
|
280
284
|
return Texture2DHandle.createForImageBuffer(image, type);
|
|
281
285
|
}
|
|
282
286
|
/** Create a 2D texture from an HTMLImageElement. */
|
|
283
|
-
static createForImage(image,
|
|
284
|
-
return Texture2DHandle.createForImage(image,
|
|
287
|
+
static createForImage(image, type) {
|
|
288
|
+
return Texture2DHandle.createForImage(image, type);
|
|
285
289
|
}
|
|
286
290
|
/** Create a 2D texture from an ImageBitmap. */
|
|
287
|
-
static createForImageBitmap(image,
|
|
288
|
-
return Texture2DHandle.createForImageBitmap(image,
|
|
291
|
+
static createForImageBitmap(image, type) {
|
|
292
|
+
return Texture2DHandle.createForImageBitmap(image, type);
|
|
289
293
|
}
|
|
290
294
|
/** Create a cube map texture from six HTMLImageElement objects. */
|
|
291
295
|
static createForCubeImages(posX, negX, posY, negY, posZ, negZ) {
|
|
292
296
|
return TextureCubeHandle.createForCubeImages(posX, negX, posY, negY, posZ, negZ);
|
|
293
297
|
}
|
|
294
|
-
static createForElement(id, imodel, type, format) {
|
|
295
|
-
return Texture2DHandle.createForElement(id, imodel, type, format);
|
|
298
|
+
static createForElement(id, imodel, type, format, onLoaded) {
|
|
299
|
+
return Texture2DHandle.createForElement(id, imodel, type, format, onLoaded);
|
|
296
300
|
}
|
|
297
301
|
/** For debugging purposes, open a new window containing this texture as an image. */
|
|
298
302
|
showDebugImage() {
|
|
@@ -395,20 +399,20 @@ export class Texture2DHandle extends TextureHandle {
|
|
|
395
399
|
return this.create(Texture2DCreateParams.createForImageBuffer(image, type));
|
|
396
400
|
}
|
|
397
401
|
/** Create a 2D texture from an HTMLImageElement. */
|
|
398
|
-
static createForImage(image,
|
|
399
|
-
return this.create(Texture2DCreateParams.createForImage(image,
|
|
402
|
+
static createForImage(image, type) {
|
|
403
|
+
return this.create(Texture2DCreateParams.createForImage(image, type));
|
|
400
404
|
}
|
|
401
405
|
/** Create a 2D texture from an ImageBitmap. */
|
|
402
|
-
static createForImageBitmap(image,
|
|
403
|
-
return this.create(Texture2DCreateParams.createForImageBitmap(image,
|
|
406
|
+
static createForImageBitmap(image, type) {
|
|
407
|
+
return this.create(Texture2DCreateParams.createForImageBitmap(image, type));
|
|
404
408
|
}
|
|
405
|
-
static createForElement(id, imodel, type, format) {
|
|
409
|
+
static createForElement(id, imodel, type, format, onLoaded) {
|
|
406
410
|
// set a placeholder texture while we wait for the external texture to load
|
|
407
411
|
const handle = this.createForData(1, 1, this._placeHolderTextureData, undefined, undefined, GL.Texture.Format.Rgb);
|
|
408
412
|
if (undefined === handle)
|
|
409
413
|
return undefined;
|
|
410
414
|
// kick off loading the texture from the backend
|
|
411
|
-
ExternalTextureLoader.instance.loadTexture(handle, id, imodel, type, format);
|
|
415
|
+
ExternalTextureLoader.instance.loadTexture(handle, id, imodel, type, format, onLoaded);
|
|
412
416
|
return handle;
|
|
413
417
|
}
|
|
414
418
|
reload(params) {
|
|
@@ -463,7 +467,7 @@ export class ExternalTextureLoader {
|
|
|
463
467
|
if (!req.imodel.isClosed) {
|
|
464
468
|
IModelApp.tileAdmin.invalidateAllScenes();
|
|
465
469
|
if (undefined !== req.onLoaded)
|
|
466
|
-
req.onLoaded(req);
|
|
470
|
+
req.onLoaded(req, texData);
|
|
467
471
|
}
|
|
468
472
|
}
|
|
469
473
|
}
|
|
@@ -481,13 +485,13 @@ export class ExternalTextureLoader {
|
|
|
481
485
|
const blob = new Blob([imageSource.data], { type: getImageSourceMimeType(imageSource.format) });
|
|
482
486
|
const image = await createImageBitmap(blob, 0, 0, cnvReq.texData.width, cnvReq.texData.height);
|
|
483
487
|
if (!cnvReq.req.imodel.isClosed) {
|
|
484
|
-
cnvReq.req.handle.reload(Texture2DCreateParams.createForImageBitmap(image,
|
|
488
|
+
cnvReq.req.handle.reload(Texture2DCreateParams.createForImageBitmap(image, cnvReq.req.type));
|
|
485
489
|
}
|
|
486
490
|
}
|
|
487
491
|
else {
|
|
488
492
|
const image = await imageElementFromImageSource(imageSource);
|
|
489
493
|
if (!cnvReq.req.imodel.isClosed) {
|
|
490
|
-
cnvReq.req.handle.reload(Texture2DCreateParams.createForImage(image,
|
|
494
|
+
cnvReq.req.handle.reload(Texture2DCreateParams.createForImage(image, cnvReq.req.type));
|
|
491
495
|
}
|
|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SACtB;IACH,CAAC;IAEM,kBAAkB,CAAC,KAAa,EAAE,KAAe;QACtD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACrC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IAEM,cAAc,CAAC,KAAa,IAAY,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpG,kBAAkB,CAAC,KAAa;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,OAAO,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, BeEvent, dispose, Id64String } from \"@itwin/core-bentley\";\r\nimport { ImageBuffer, ImageBufferFormat, ImageSource, ImageSourceFormat, isPowerOfTwo, nextHighestPowerOfTwo, RenderTexture, TextureData } from \"@itwin/core-common\";\r\nimport { getImageSourceMimeType, imageBufferToPngDataUrl, imageElementFromImageSource, openImageDataUrlInNewWindow } from \"../../ImageUtil\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { GL } from \"./GL\";\r\nimport { UniformHandle } from \"./UniformHandle\";\r\nimport { OvrFlags, TextureUnit } from \"./RenderFlags\";\r\nimport { System } from \"./System\";\r\nimport { TextureOwnership } from \"../RenderTexture\";\r\n\r\ntype CanvasOrImage = HTMLCanvasElement | HTMLImageElement;\r\n\r\n/** @internal */\r\nexport type Texture2DData = Uint8Array | Float32Array;\r\n\r\nfunction computeBytesUsed(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType): number {\r\n const bytesPerComponent = GL.Texture.DataType.UnsignedByte === dataType ? 1 : 4;\r\n let componentsPerPixel = 1;\r\n switch (format) {\r\n case GL.Texture.Format.Rgb:\r\n componentsPerPixel = 3;\r\n break;\r\n case GL.Texture.Format.Rgba:\r\n componentsPerPixel = 4;\r\n break;\r\n }\r\n\r\n return width * height * componentsPerPixel * bytesPerComponent;\r\n}\r\n\r\n/** Associate texture data with a WebGLTexture from a canvas, image, OR a bitmap. */\r\nfunction loadTexture2DImageData(handle: TextureHandle, params: Texture2DCreateParams, bytes?: Texture2DData, element?: CanvasOrImage): void {\r\n handle.bytesUsed = undefined !== bytes ? bytes.byteLength : computeBytesUsed(params.width, params.height, params.format, params.dataType);\r\n\r\n const tex = handle.getHandle()!;\r\n const gl = System.instance.context;\r\n\r\n // Use tightly packed data\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Bind the texture object; make sure we do not interfere with other active textures\r\n System.instance.activateTexture2d(TextureUnit.Zero, tex);\r\n\r\n // Figure out the internal format. For all but WebGL2 float/half-float datatypes it is just same as format.\r\n // TODO: probably need to just support internal format types in Texture2DCreateParams.\r\n let internalFormat = params.format;\r\n if (System.instance.capabilities.isWebGL2) {\r\n const context2 = System.instance.context as WebGL2RenderingContext;\r\n if (GL.Texture.Format.Rgba === params.format) {\r\n if (GL.Texture.DataType.Float === params.dataType)\r\n internalFormat = context2.RGBA32F;\r\n else if (context2.HALF_FLOAT === params.dataType)\r\n internalFormat = context2.RGBA16F;\r\n } else if (GL.Texture.Format.DepthStencil === params.format)\r\n internalFormat = context2.DEPTH24_STENCIL8;\r\n }\r\n\r\n // send the texture data\r\n if (undefined !== element) {\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, params.format, params.dataType, element);\r\n } else {\r\n const pixelData = undefined !== bytes ? bytes : null;\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, params.width, params.height, 0, params.format, params.dataType, pixelData);\r\n }\r\n\r\n if (params.useMipMaps) {\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n } else {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, params.interpolate ? gl.LINEAR : gl.NEAREST);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, params.interpolate ? gl.LINEAR : gl.NEAREST);\r\n }\r\n if (params.anisotropicFilter) {\r\n System.instance.setMaxAnisotropy(params.anisotropicFilter);\r\n }\r\n\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, params.wrapMode);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, params.wrapMode);\r\n\r\n System.instance.bindTexture2d(TextureUnit.Zero, undefined);\r\n}\r\n\r\nfunction loadTextureFromBytes(handle: TextureHandle, params: Texture2DCreateParams, bytes?: Texture2DData): void { loadTexture2DImageData(handle, params, bytes); }\r\n\r\n/** Associate cube texture data with a WebGLTexture from an image. */\r\nfunction loadTextureCubeImageData(handle: TextureHandle, params: TextureCubeCreateParams, images: CanvasOrImage[]): void {\r\n handle.bytesUsed = computeBytesUsed(params.dim * 6, params.dim, params.format, params.dataType);\r\n\r\n const tex = handle.getHandle()!;\r\n const gl = System.instance.context;\r\n\r\n // Use tightly packed data\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Bind the texture object; make sure we do not interfere with other active textures\r\n System.instance.activateTextureCubeMap(TextureUnit.Zero, tex);\r\n\r\n const cubeTargets: number[] = [GL.Texture.Target.CubeMapPositiveX, GL.Texture.Target.CubeMapNegativeX, GL.Texture.Target.CubeMapPositiveY, GL.Texture.Target.CubeMapNegativeY, GL.Texture.Target.CubeMapPositiveZ, GL.Texture.Target.CubeMapNegativeZ];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n gl.texImage2D(cubeTargets[i], 0, params.format, params.format, params.dataType, images[i]);\r\n }\r\n\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_S, params.wrapMode);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_T, params.wrapMode);\r\n // gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_R, params.wrapMode); // Unavailable in GLES2\r\n\r\n System.instance.bindTextureCubeMap(TextureUnit.Zero, undefined);\r\n}\r\n\r\ntype TextureFlag = true | undefined;\r\ntype TextureAnisotropicFilter = number | undefined;\r\ntype Load2DImageData = (handle: TextureHandle, params: Texture2DCreateParams) => void;\r\ntype LoadCubeImageData = (handle: TextureHandle, params: TextureCubeCreateParams) => void;\r\n\r\ninterface TextureImageProperties {\r\n wrapMode: GL.Texture.WrapMode;\r\n useMipMaps: TextureFlag;\r\n interpolate: TextureFlag;\r\n format: GL.Texture.Format;\r\n anisotropicFilter: TextureAnisotropicFilter;\r\n}\r\n\r\n/** @internal */\r\nexport interface TextureParams {\r\n type: RenderTexture.Type;\r\n ownership?: TextureOwnership;\r\n // ###TODO transparency: TextureTransparency;\r\n handle: TextureHandle;\r\n}\r\n\r\n/** Wrapper class for a WebGL texture handle and parameters specific to an individual texture.\r\n * @internal\r\n */\r\nexport class Texture extends RenderTexture implements WebGLDisposable {\r\n public readonly texture: TextureHandle;\r\n public readonly ownership?: TextureOwnership;\r\n\r\n public get bytesUsed(): number { return this.texture.bytesUsed; }\r\n public get hasOwner(): boolean { return undefined !== this.ownership; }\r\n public get key(): string | undefined {\r\n return typeof this.ownership !== \"string\" && typeof this.ownership?.key === \"string\" ? this.ownership.key : undefined;\r\n }\r\n\r\n public constructor(params: TextureParams) {\r\n super(params.type);\r\n this.ownership = params.ownership;\r\n this.texture = params.handle;\r\n }\r\n\r\n public get isDisposed(): boolean { return this.texture.isDisposed; }\r\n\r\n /** Free this object in the WebGL wrapper. */\r\n public dispose() {\r\n dispose(this.texture);\r\n }\r\n\r\n public get hasTranslucency(): boolean { return GL.Texture.Format.Rgba === this.texture.format; }\r\n}\r\n\r\nfunction getDataType(data: Texture2DData): GL.Texture.DataType {\r\n return data instanceof Float32Array ? GL.Texture.DataType.Float : GL.Texture.DataType.UnsignedByte;\r\n}\r\n\r\n/** Parameters used internally to define how to create a texture for use with WebGL. */\r\nclass Texture2DCreateParams {\r\n private constructor(\r\n public width: number,\r\n public height: number,\r\n public format: GL.Texture.Format,\r\n public dataType: GL.Texture.DataType,\r\n public wrapMode: GL.Texture.WrapMode,\r\n public loadImageData: Load2DImageData,\r\n public useMipMaps?: TextureFlag,\r\n public interpolate?: TextureFlag,\r\n public anisotropicFilter?: TextureAnisotropicFilter,\r\n public dataBytes?: Uint8Array) { }\r\n\r\n public static createForData(width: number, height: number, data: Texture2DData, preserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n const bytes = (preserveData && data instanceof Uint8Array) ? data : undefined;\r\n return new Texture2DCreateParams(width, height, format, getDataType(data), wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params, data), undefined, undefined, undefined, bytes);\r\n }\r\n\r\n public static createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(ImageBufferFormat.Rgba === image.format, type);\r\n\r\n return new Texture2DCreateParams(image.width, image.height, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params, image.data), props.useMipMaps, props.interpolate);\r\n }\r\n\r\n public static createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return new Texture2DCreateParams(width, height, format, dataType, GL.Texture.WrapMode.ClampToEdge,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params), undefined, undefined);\r\n }\r\n\r\n public static createForImage(image: HTMLImageElement, hasAlpha: boolean, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(hasAlpha, type);\r\n\r\n let targetWidth = image.naturalWidth;\r\n let targetHeight = image.naturalHeight;\r\n\r\n const caps = System.instance.capabilities;\r\n if (RenderTexture.Type.Glyph === type) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n } else if (!caps.supportsNonPowerOf2Textures && (!isPowerOfTwo(targetWidth) || !isPowerOfTwo(targetHeight))) {\r\n if (GL.Texture.WrapMode.ClampToEdge === props.wrapMode) {\r\n // NPOT are supported but not mipmaps\r\n // Probably on poor hardware so I choose to disable mipmaps for lower memory usage over quality. If quality is required we need to resize the image to a pow of 2.\r\n // Above comment is not necessarily true - WebGL doesn't support NPOT mipmapping, only supporting base NPOT caps\r\n props.useMipMaps = undefined;\r\n } else if (GL.Texture.WrapMode.Repeat === props.wrapMode) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n }\r\n }\r\n\r\n // Cap texture dimensions to system WebGL capabilities\r\n const maxTexSize = System.instance.capabilities.maxTextureSize;\r\n targetWidth = Math.min(targetWidth, maxTexSize);\r\n targetHeight = Math.min(targetHeight, maxTexSize);\r\n\r\n let element: CanvasOrImage = image;\r\n if (targetWidth !== image.naturalWidth || targetHeight !== image.naturalHeight) {\r\n // Resize so dimensions are powers-of-two\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = targetWidth;\r\n canvas.height = targetHeight;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n context.drawImage(image, 0, 0, canvas.width, canvas.height);\r\n\r\n element = canvas;\r\n }\r\n\r\n return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTexture2DImageData(tex, params, undefined, element), props.useMipMaps, props.interpolate, props.anisotropicFilter);\r\n }\r\n\r\n public static createForImageBitmap(image: ImageBitmap, hasAlpha: boolean, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(hasAlpha, type);\r\n\r\n let targetWidth = image.width;\r\n let targetHeight = image.height;\r\n\r\n const caps = System.instance.capabilities;\r\n if (RenderTexture.Type.Glyph === type) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n } else if (!caps.supportsNonPowerOf2Textures && (!isPowerOfTwo(targetWidth) || !isPowerOfTwo(targetHeight))) {\r\n if (GL.Texture.WrapMode.ClampToEdge === props.wrapMode) {\r\n // NPOT are supported but not mipmaps\r\n // Probably on poor hardware so I choose to disable mipmaps for lower memory usage over quality. If quality is required we need to resize the image to a pow of 2.\r\n // Above comment is not necessarily true - WebGL doesn't support NPOT mipmapping, only supporting base NPOT caps\r\n props.useMipMaps = undefined;\r\n } else if (GL.Texture.WrapMode.Repeat === props.wrapMode) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n }\r\n }\r\n\r\n // Always draw to canvas for ImageBitmap\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = targetWidth;\r\n canvas.height = targetHeight;\r\n const context = canvas.getContext(\"2d\")!;\r\n context.drawImage(image, 0, 0, canvas.width, canvas.height);\r\n\r\n return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTexture2DImageData(tex, params, undefined, canvas), props.useMipMaps, props.interpolate, props.anisotropicFilter);\r\n }\r\n\r\n private static getImageProperties(isTranslucent: boolean, type: RenderTexture.Type): TextureImageProperties {\r\n const isSky = RenderTexture.Type.SkyBox === type;\r\n const isTile = RenderTexture.Type.TileSection === type;\r\n const isThematic = RenderTexture.Type.ThematicGradient === type;\r\n const isFilteredTile = RenderTexture.Type.FilteredTileSection === type;\r\n const maxAnisotropicFilterLevel = 16;\r\n\r\n const wrapMode = RenderTexture.Type.Normal === type ? GL.Texture.WrapMode.Repeat : GL.Texture.WrapMode.ClampToEdge;\r\n const useMipMaps: TextureFlag = (!isSky && !isTile && !isFilteredTile && !isThematic) ? true : undefined;\r\n const interpolate: TextureFlag = isThematic ? undefined : true;\r\n const format = isTranslucent ? GL.Texture.Format.Rgba : GL.Texture.Format.Rgb;\r\n const anisotropicFilter = isFilteredTile ? maxAnisotropicFilterLevel : undefined;\r\n\r\n return { format, wrapMode, useMipMaps, interpolate, anisotropicFilter };\r\n }\r\n\r\n public static readonly placeholderParams = new Texture2DCreateParams(1, 1, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte, GL.Texture.WrapMode.ClampToEdge,\r\n (_tex: TextureHandle, _params: Texture2DCreateParams) => undefined);\r\n}\r\n\r\nclass TextureCubeCreateParams {\r\n private constructor(\r\n public dim: number,\r\n public format: GL.Texture.Format,\r\n public dataType: GL.Texture.DataType,\r\n public wrapMode: GL.Texture.WrapMode,\r\n public loadImageData: LoadCubeImageData) { }\r\n\r\n public static createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement): TextureCubeCreateParams | undefined {\r\n const targetDim = posX.naturalWidth;\r\n\r\n if (posX.naturalHeight !== targetDim) // Cube texture dimensions must match (width must equal height)\r\n return undefined;\r\n\r\n const images: HTMLImageElement[] = [posX, negX, posY, negY, posZ, negZ];\r\n\r\n for (let i = 1; i < images.length; i++) { // Dimensions of all six sides must match each other\r\n if (images[i].naturalWidth !== targetDim || images[i].naturalHeight !== targetDim)\r\n return undefined;\r\n }\r\n\r\n return new TextureCubeCreateParams(targetDim, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte, GL.Texture.WrapMode.ClampToEdge,\r\n (tex: TextureHandle, params: TextureCubeCreateParams) => loadTextureCubeImageData(tex, params, images));\r\n }\r\n}\r\n\r\n/** Wraps a WebGLTextureHandle\r\n * @internal\r\n */\r\nexport abstract class TextureHandle implements WebGLDisposable {\r\n protected _glTexture?: WebGLTexture;\r\n protected _bytesUsed = 0;\r\n\r\n public abstract get width(): number;\r\n public abstract get height(): number;\r\n public abstract get format(): GL.Texture.Format;\r\n public abstract get dataType(): GL.Texture.DataType;\r\n public abstract get dataBytes(): Uint8Array | undefined;\r\n public get bytesUsed(): number { return this._bytesUsed; }\r\n public set bytesUsed(bytesUsed: number) {\r\n // assert(0 === this.bytesUsed);\r\n this._bytesUsed = bytesUsed;\r\n }\r\n\r\n /** Get the WebGLTexture for this TextureHandle. */\r\n public getHandle(): WebGLTexture | undefined { return this._glTexture; }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public abstract bind(_texUnit: TextureUnit): boolean;\r\n\r\n /** Bind this texture to a uniform sampler. */\r\n public abstract bindSampler(_uniform: UniformHandle, _unit: TextureUnit): void;\r\n\r\n public get isDisposed(): boolean { return this._glTexture === undefined; }\r\n\r\n public dispose() {\r\n if (!this.isDisposed) {\r\n System.instance.disposeTexture(this._glTexture!);\r\n this._glTexture = undefined;\r\n this.bytesUsed = 0;\r\n }\r\n }\r\n\r\n /** Create a 2D texture for use as a color attachment for rendering */\r\n public static createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return Texture2DHandle.createForAttachment(width, height, format, dataType);\r\n }\r\n\r\n /** Create a 2D texture to hold non-image data */\r\n public static createForData(width: number, height: number, data: Texture2DData, wantPreserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n return Texture2DHandle.createForData(width, height, data, wantPreserveData, wrapMode, format);\r\n }\r\n\r\n /** Create a 2D texture from a bitmap */\r\n public static createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImageBuffer(image, type);\r\n }\r\n\r\n /** Create a 2D texture from an HTMLImageElement. */\r\n public static createForImage(image: HTMLImageElement, hasAlpha: boolean, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImage(image, hasAlpha, type);\r\n }\r\n\r\n /** Create a 2D texture from an ImageBitmap. */\r\n public static createForImageBitmap(image: ImageBitmap, hasAlpha: boolean, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImageBitmap(image, hasAlpha, type);\r\n }\r\n\r\n /** Create a cube map texture from six HTMLImageElement objects. */\r\n public static createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement) {\r\n return TextureCubeHandle.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n }\r\n\r\n public static createForElement(id: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat) {\r\n return Texture2DHandle.createForElement(id, imodel, type, format);\r\n }\r\n\r\n protected constructor(glTexture: WebGLTexture) {\r\n this._glTexture = glTexture;\r\n }\r\n\r\n /** For debugging purposes, open a new window containing this texture as an image. */\r\n public showDebugImage(): void {\r\n const gl = System.instance.context;\r\n const fbo = gl.createFramebuffer();\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.getHandle()!, 0);\r\n if (gl.FRAMEBUFFER_COMPLETE === gl.checkFramebufferStatus(gl.FRAMEBUFFER)) {\r\n const w = this.width;\r\n const h = this.height;\r\n const pixels = new Uint8Array(w * h * 4);\r\n gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels);\r\n\r\n const buffer = ImageBuffer.create(pixels, ImageBufferFormat.Rgba, w)!;\r\n const url = imageBufferToPngDataUrl(buffer, false);\r\n openImageDataUrlInNewWindow(url!, \"Classifiers\");\r\n }\r\n\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n gl.deleteFramebuffer(fbo);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class Texture2DHandle extends TextureHandle {\r\n private _width: number;\r\n private _height: number;\r\n private _format: GL.Texture.Format;\r\n private _dataType: GL.Texture.DataType;\r\n private _dataBytes?: Uint8Array;\r\n\r\n public get width(): number { return this._width; }\r\n public get height(): number { return this._height; }\r\n public get format(): GL.Texture.Format { return this._format; }\r\n public get dataType(): GL.Texture.DataType { return this._dataType; }\r\n public get dataBytes(): Uint8Array | undefined { return this._dataBytes; }\r\n\r\n /** Bind specified texture handle to specified texture unit. */\r\n public static bindTexture(texUnit: TextureUnit, glTex: WebGLTexture | undefined) {\r\n assert(!(glTex instanceof TextureHandle));\r\n System.instance.bindTexture2d(texUnit, glTex);\r\n }\r\n\r\n /** Bind the specified texture to a uniform sampler2D */\r\n public static bindSampler(uniform: UniformHandle, tex: WebGLTexture, unit: TextureUnit): void {\r\n assert(!(tex instanceof TextureHandle));\r\n this.bindTexture(unit, tex);\r\n uniform.setUniform1i(unit - TextureUnit.Zero);\r\n }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public bind(texUnit: TextureUnit): boolean {\r\n if (undefined === this._glTexture)\r\n return false;\r\n Texture2DHandle.bindTexture(texUnit, this._glTexture);\r\n return true;\r\n }\r\n\r\n /** Bind this texture to a uniform sampler2D */\r\n public bindSampler(uniform: UniformHandle, unit: TextureUnit): void {\r\n if (undefined !== this._glTexture)\r\n Texture2DHandle.bindSampler(uniform, this._glTexture, unit);\r\n }\r\n\r\n /** Update the 2D texture contents. */\r\n public update(updater: Texture2DDataUpdater): boolean {\r\n if (0 === this.width || 0 === this.height || undefined === this._dataBytes || 0 === this._dataBytes.length) {\r\n assert(false);\r\n return false;\r\n }\r\n\r\n if (!updater.modified)\r\n return false;\r\n\r\n return this.replaceTextureData(this._dataBytes);\r\n }\r\n\r\n /** Replace the 2D texture contents. */\r\n public replaceTextureData(data: Texture2DData): boolean {\r\n assert((GL.Texture.DataType.Float === this._dataType) === (data instanceof Float32Array));\r\n\r\n const tex = this.getHandle()!;\r\n if (undefined === tex)\r\n return false;\r\n\r\n const gl = System.instance.context;\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Go through System to ensure we don't interfere with currently-bound textures!\r\n System.instance.activateTexture2d(TextureUnit.Zero, tex);\r\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, this._format, this._dataType, data);\r\n System.instance.bindTexture2d(TextureUnit.Zero, undefined);\r\n\r\n return true;\r\n }\r\n\r\n private static create(params: Texture2DCreateParams): Texture2DHandle | undefined {\r\n const glTex = System.instance.context.createTexture();\r\n return null !== glTex ? new Texture2DHandle(glTex, params) : undefined;\r\n }\r\n\r\n /** Create a texture for use as a color attachment for rendering */\r\n public static override createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return this.create(Texture2DCreateParams.createForAttachment(width, height, format, dataType));\r\n }\r\n\r\n /** Create a texture to hold non-image data */\r\n public static override createForData(width: number, height: number, data: Texture2DData, wantPreserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n return this.create(Texture2DCreateParams.createForData(width, height, data, wantPreserveData, wrapMode, format));\r\n }\r\n\r\n /** Create a texture from a bitmap */\r\n public static override createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n if (RenderTexture.Type.TileSection !== type && RenderTexture.Type.ThematicGradient !== type)\r\n assert(isPowerOfTwo(image.width) && isPowerOfTwo(image.height), \"###TODO: Resize image dimensions to powers-of-two if necessary\");\r\n\r\n return this.create(Texture2DCreateParams.createForImageBuffer(image, type));\r\n }\r\n\r\n /** Create a 2D texture from an HTMLImageElement. */\r\n public static override createForImage(image: HTMLImageElement, hasAlpha: boolean, type: RenderTexture.Type) {\r\n return this.create(Texture2DCreateParams.createForImage(image, hasAlpha, type));\r\n }\r\n\r\n /** Create a 2D texture from an ImageBitmap. */\r\n public static override createForImageBitmap(image: ImageBitmap, hasAlpha: boolean, type: RenderTexture.Type) {\r\n return this.create(Texture2DCreateParams.createForImageBitmap(image, hasAlpha, type));\r\n }\r\n\r\n private static _placeHolderTextureData = new Uint8Array([128, 128, 128]);\r\n\r\n public static override createForElement(id: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat) {\r\n // set a placeholder texture while we wait for the external texture to load\r\n const handle = this.createForData(1, 1, this._placeHolderTextureData, undefined, undefined, GL.Texture.Format.Rgb);\r\n\r\n if (undefined === handle)\r\n return undefined;\r\n\r\n // kick off loading the texture from the backend\r\n ExternalTextureLoader.instance.loadTexture(handle, id, imodel, type, format);\r\n\r\n return handle;\r\n }\r\n\r\n public reload(params: Texture2DCreateParams) {\r\n this._width = params.width;\r\n this._height = params.height;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n this._dataBytes = params.dataBytes;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n\r\n private constructor(glTexture: WebGLTexture, params: Texture2DCreateParams) {\r\n super(glTexture);\r\n this._width = params.width;\r\n this._height = params.height;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n this._dataBytes = params.dataBytes;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport interface ExternalTextureRequest {\r\n handle: Texture2DHandle;\r\n name: Id64String;\r\n imodel: IModelConnection;\r\n type: RenderTexture.Type;\r\n format: ImageSourceFormat;\r\n onLoaded?: (req: ExternalTextureRequest) => void;\r\n}\r\n\r\n/** @internal */\r\ninterface TextureConvertRequest {\r\n req: ExternalTextureRequest;\r\n texData: TextureData;\r\n}\r\n\r\n/** @internal */\r\nexport class ExternalTextureLoader { /* currently exported for tests only */\r\n public static readonly instance = new ExternalTextureLoader(2);\r\n public readonly onTexturesLoaded = new BeEvent<() => void>();\r\n private readonly _maxActiveRequests: number;\r\n private _activeRequests: Array<ExternalTextureRequest> = [];\r\n private _pendingRequests: Array<ExternalTextureRequest> = [];\r\n private _convertRequests: Array<TextureConvertRequest> = [];\r\n private _convertPending = false;\r\n\r\n public get numActiveRequests() { return this._activeRequests.length; }\r\n public get numPendingRequests() { return this._pendingRequests.length; }\r\n public get maxActiveRequests() { return this._maxActiveRequests; }\r\n\r\n private constructor(maxActiveRequests: number) {\r\n this._maxActiveRequests = maxActiveRequests;\r\n }\r\n\r\n private async _nextRequest(prevReq: ExternalTextureRequest) {\r\n this._activeRequests.splice(this._activeRequests.indexOf(prevReq), 1);\r\n if (this._activeRequests.length < this._maxActiveRequests && this._pendingRequests.length > 0) {\r\n const req = this._pendingRequests.shift()!;\r\n await this._activateRequest(req);\r\n }\r\n if (this._activeRequests.length < 1 && this._pendingRequests.length < 1)\r\n this.onTexturesLoaded.raiseEvent();\r\n }\r\n\r\n private async _activateRequest(req: ExternalTextureRequest) {\r\n if (req.imodel.isClosed)\r\n return;\r\n\r\n this._activeRequests.push(req);\r\n\r\n try {\r\n if (!req.imodel.isClosed) {\r\n const maxTextureSize = System.instance.capabilities.maxTexSizeAllow;\r\n const texData = await req.imodel.queryTextureData({ name: req.name, maxTextureSize });\r\n if (undefined !== texData) {\r\n const cnvReq = { req, texData };\r\n this._convertRequests.push(cnvReq);\r\n // _convertPending is used to prevent overlapping calls to _convertTexture (from overlapping calls to _activateRequest)\r\n // it has been put on the list, so if it doesn't get converted here it will get converted by the loop that is converting the current one\r\n do {\r\n if (!this._convertPending)\r\n await this._convertTexture();\r\n } while (!this._convertPending && this._convertRequests.length > 0);\r\n if (!req.imodel.isClosed) {\r\n IModelApp.tileAdmin.invalidateAllScenes();\r\n if (undefined !== req.onLoaded)\r\n req.onLoaded(req);\r\n }\r\n }\r\n }\r\n } catch (_e) { }\r\n\r\n return this._nextRequest(req);\r\n }\r\n\r\n private async _convertTexture(): Promise<void> {\r\n this._convertPending = true;\r\n try {\r\n const cnvReq = this._convertRequests.shift();\r\n if (undefined !== cnvReq) {\r\n const imageSource = new ImageSource(cnvReq.texData.bytes, cnvReq.texData.format);\r\n if (System.instance.capabilities.supportsCreateImageBitmap) {\r\n const blob = new Blob([imageSource.data], { type: getImageSourceMimeType(imageSource.format) });\r\n const image = await createImageBitmap(blob, 0, 0, cnvReq.texData.width, cnvReq.texData.height);\r\n if (!cnvReq.req.imodel.isClosed) {\r\n cnvReq.req.handle.reload(Texture2DCreateParams.createForImageBitmap(image, ImageSourceFormat.Png === cnvReq.req.format, cnvReq.req.type));\r\n }\r\n } else {\r\n const image = await imageElementFromImageSource(imageSource);\r\n if (!cnvReq.req.imodel.isClosed) {\r\n cnvReq.req.handle.reload(Texture2DCreateParams.createForImage(image, ImageSourceFormat.Png === cnvReq.req.format, cnvReq.req.type));\r\n }\r\n }\r\n }\r\n } catch (_e) { }\r\n this._convertPending = false;\r\n }\r\n\r\n private _requestExists(reqToCheck: ExternalTextureRequest) {\r\n for (const r of this._activeRequests)\r\n if (reqToCheck.name === r.name && reqToCheck.imodel === r.imodel)\r\n return true;\r\n\r\n for (const r of this._pendingRequests)\r\n if (reqToCheck.name === r.name && reqToCheck.imodel === r.imodel)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n public loadTexture(handle: Texture2DHandle, name: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat, onLoaded?: (req: ExternalTextureRequest) => void) {\r\n const req = { handle, name, imodel, type, format, onLoaded };\r\n if (this._requestExists(req))\r\n return;\r\n\r\n if (this._activeRequests.length + 1 > this._maxActiveRequests) {\r\n this._pendingRequests.push(req);\r\n } else\r\n this._activateRequest(req); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TextureCubeHandle extends TextureHandle {\r\n private _dim: number; // Cubemap texture height and width must match. This must be the same for each of the six faces.\r\n private _format: GL.Texture.Format; // Format must be the same for each of the six faces.\r\n private _dataType: GL.Texture.DataType; // Type must be the same for each of the six faces.\r\n\r\n public get width(): number { return this._dim; }\r\n public get height(): number { return this._dim; }\r\n public get format(): GL.Texture.Format { return this._format; }\r\n public get dataType(): GL.Texture.DataType { return this._dataType; }\r\n public get dataBytes(): Uint8Array | undefined { return undefined; }\r\n\r\n /** Bind specified cubemap texture handle to specified texture unit. */\r\n public static bindTexture(texUnit: TextureUnit, glTex: WebGLTexture | undefined) {\r\n assert(!(glTex instanceof TextureHandle));\r\n System.instance.bindTextureCubeMap(texUnit, glTex);\r\n }\r\n\r\n /** Bind the specified texture to a uniform sampler2D */\r\n public static bindSampler(uniform: UniformHandle, tex: WebGLTexture, unit: TextureUnit): void {\r\n assert(!(tex instanceof TextureHandle));\r\n this.bindTexture(unit, tex);\r\n uniform.setUniform1i(unit - TextureUnit.Zero);\r\n }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public bind(texUnit: TextureUnit): boolean {\r\n if (undefined === this._glTexture)\r\n return false;\r\n TextureCubeHandle.bindTexture(texUnit, this._glTexture);\r\n return true;\r\n }\r\n\r\n /** Bind this texture to a uniform sampler2D */\r\n public bindSampler(uniform: UniformHandle, unit: TextureUnit): void {\r\n if (undefined !== this._glTexture)\r\n TextureCubeHandle.bindSampler(uniform, this._glTexture, unit);\r\n }\r\n\r\n private static create(params: TextureCubeCreateParams): TextureHandle | undefined {\r\n const glTex = System.instance.context.createTexture();\r\n return null !== glTex ? new TextureCubeHandle(glTex, params) : undefined;\r\n }\r\n\r\n /** Create a cube map texture from six HTMLImageElement objects. */\r\n public static override createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement) {\r\n const params = TextureCubeCreateParams.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n return params !== undefined ? this.create(params) : undefined;\r\n }\r\n\r\n private constructor(glTexture: WebGLTexture, params: TextureCubeCreateParams) {\r\n super(glTexture);\r\n this._dim = params.dim;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class Texture2DDataUpdater {\r\n public data: Uint8Array;\r\n public modified: boolean = false;\r\n\r\n public constructor(data: Uint8Array) { this.data = data; }\r\n\r\n public setByteAtIndex(index: number, byte: number) {\r\n assert(index < this.data.length);\r\n if (byte !== this.data[index]) {\r\n this.data[index] = byte;\r\n this.modified = true;\r\n }\r\n }\r\n\r\n public setOvrFlagsAtIndex(index: number, value: OvrFlags) {\r\n assert(index < this.data.length - 1);\r\n assert(value < 0xffff);\r\n this.setByteAtIndex(index, value & 0xff);\r\n this.setByteAtIndex(index + 1, (value & 0xff00) >> 8);\r\n }\r\n\r\n public getByteAtIndex(index: number): number { assert(index < this.data.length); return this.data[index]; }\r\n public getOvrFlagsAtIndex(index: number): OvrFlags {\r\n const lo = this.getByteAtIndex(index);\r\n const hi = this.getByteAtIndex(index + 1);\r\n return lo | (hi << 8);\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Texture.js","sourceRoot":"","sources":["../../../../src/render/webgl/Texture.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,E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IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACxD,CAAC;IAEM,cAAc,CAAC,KAAa,IAAY,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACpG,kBAAkB,CAAC,KAAa;QACrC,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACtC,MAAM,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;QAC1C,OAAO,EAAE,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module WebGL\r\n */\r\n\r\nimport { assert, BeEvent, dispose, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n ImageBuffer, ImageBufferFormat, ImageSource, ImageSourceFormat, isPowerOfTwo, nextHighestPowerOfTwo, RenderTexture, TextureData, TextureTransparency,\r\n} from \"@itwin/core-common\";\r\nimport { getImageSourceMimeType, imageBufferToPngDataUrl, imageElementFromImageSource, openImageDataUrlInNewWindow } from \"../../ImageUtil\";\r\nimport { IModelConnection } from \"../../IModelConnection\";\r\nimport { IModelApp } from \"../../IModelApp\";\r\nimport { WebGLDisposable } from \"./Disposable\";\r\nimport { GL } from \"./GL\";\r\nimport { UniformHandle } from \"./UniformHandle\";\r\nimport { OvrFlags, TextureUnit } from \"./RenderFlags\";\r\nimport { System } from \"./System\";\r\nimport { TextureOwnership } from \"../RenderTexture\";\r\n\r\ntype CanvasOrImage = HTMLCanvasElement | HTMLImageElement;\r\n\r\n/** @internal */\r\nexport type Texture2DData = Uint8Array | Float32Array;\r\n\r\nfunction computeBytesUsed(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType): number {\r\n const bytesPerComponent = GL.Texture.DataType.UnsignedByte === dataType ? 1 : 4;\r\n let componentsPerPixel = 1;\r\n switch (format) {\r\n case GL.Texture.Format.Rgb:\r\n componentsPerPixel = 3;\r\n break;\r\n case GL.Texture.Format.Rgba:\r\n componentsPerPixel = 4;\r\n break;\r\n }\r\n\r\n return width * height * componentsPerPixel * bytesPerComponent;\r\n}\r\n\r\n/** Associate texture data with a WebGLTexture from a canvas, image, OR a bitmap. */\r\nfunction loadTexture2DImageData(handle: TextureHandle, params: Texture2DCreateParams, bytes?: Texture2DData, element?: CanvasOrImage): void {\r\n handle.bytesUsed = undefined !== bytes ? bytes.byteLength : computeBytesUsed(params.width, params.height, params.format, params.dataType);\r\n\r\n const tex = handle.getHandle()!;\r\n const gl = System.instance.context;\r\n\r\n // Use tightly packed data\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Bind the texture object; make sure we do not interfere with other active textures\r\n System.instance.activateTexture2d(TextureUnit.Zero, tex);\r\n\r\n // Figure out the internal format. For all but WebGL2 float/half-float datatypes it is just same as format.\r\n // TODO: probably need to just support internal format types in Texture2DCreateParams.\r\n let internalFormat = params.format;\r\n if (System.instance.capabilities.isWebGL2) {\r\n const context2 = System.instance.context as WebGL2RenderingContext;\r\n if (GL.Texture.Format.Rgba === params.format) {\r\n if (GL.Texture.DataType.Float === params.dataType)\r\n internalFormat = context2.RGBA32F;\r\n else if (context2.HALF_FLOAT === params.dataType)\r\n internalFormat = context2.RGBA16F;\r\n } else if (GL.Texture.Format.DepthStencil === params.format)\r\n internalFormat = context2.DEPTH24_STENCIL8;\r\n }\r\n\r\n // send the texture data\r\n if (undefined !== element) {\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, params.format, params.dataType, element);\r\n } else {\r\n const pixelData = undefined !== bytes ? bytes : null;\r\n gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, params.width, params.height, 0, params.format, params.dataType, pixelData);\r\n }\r\n\r\n if (params.useMipMaps) {\r\n gl.generateMipmap(gl.TEXTURE_2D);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n } else {\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, params.interpolate ? gl.LINEAR : gl.NEAREST);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, params.interpolate ? gl.LINEAR : gl.NEAREST);\r\n }\r\n if (params.anisotropicFilter) {\r\n System.instance.setMaxAnisotropy(params.anisotropicFilter);\r\n }\r\n\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, params.wrapMode);\r\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, params.wrapMode);\r\n\r\n System.instance.bindTexture2d(TextureUnit.Zero, undefined);\r\n}\r\n\r\nfunction loadTextureFromBytes(handle: TextureHandle, params: Texture2DCreateParams, bytes?: Texture2DData): void { loadTexture2DImageData(handle, params, bytes); }\r\n\r\n/** Associate cube texture data with a WebGLTexture from an image. */\r\nfunction loadTextureCubeImageData(handle: TextureHandle, params: TextureCubeCreateParams, images: CanvasOrImage[]): void {\r\n handle.bytesUsed = computeBytesUsed(params.dim * 6, params.dim, params.format, params.dataType);\r\n\r\n const tex = handle.getHandle()!;\r\n const gl = System.instance.context;\r\n\r\n // Use tightly packed data\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Bind the texture object; make sure we do not interfere with other active textures\r\n System.instance.activateTextureCubeMap(TextureUnit.Zero, tex);\r\n\r\n const cubeTargets: number[] = [GL.Texture.Target.CubeMapPositiveX, GL.Texture.Target.CubeMapNegativeX, GL.Texture.Target.CubeMapPositiveY, GL.Texture.Target.CubeMapNegativeY, GL.Texture.Target.CubeMapPositiveZ, GL.Texture.Target.CubeMapNegativeZ];\r\n\r\n for (let i = 0; i < 6; i++) {\r\n gl.texImage2D(cubeTargets[i], 0, params.format, params.format, params.dataType, images[i]);\r\n }\r\n\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_MAG_FILTER, gl.LINEAR);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_MIN_FILTER, gl.LINEAR);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_S, params.wrapMode);\r\n gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_T, params.wrapMode);\r\n // gl.texParameteri(GL.Texture.Target.CubeMap, gl.TEXTURE_WRAP_R, params.wrapMode); // Unavailable in GLES2\r\n\r\n System.instance.bindTextureCubeMap(TextureUnit.Zero, undefined);\r\n}\r\n\r\ntype TextureFlag = true | undefined;\r\ntype TextureAnisotropicFilter = number | undefined;\r\ntype Load2DImageData = (handle: TextureHandle, params: Texture2DCreateParams) => void;\r\ntype LoadCubeImageData = (handle: TextureHandle, params: TextureCubeCreateParams) => void;\r\n\r\ninterface TextureImageProperties {\r\n wrapMode: GL.Texture.WrapMode;\r\n useMipMaps: TextureFlag;\r\n interpolate: TextureFlag;\r\n format: GL.Texture.Format;\r\n anisotropicFilter: TextureAnisotropicFilter;\r\n}\r\n\r\n/** @internal */\r\nexport interface TextureParams {\r\n type: RenderTexture.Type;\r\n ownership?: TextureOwnership;\r\n transparency: TextureTransparency;\r\n handle: TextureHandle;\r\n}\r\n\r\n/** Wrapper class for a WebGL texture handle and parameters specific to an individual texture.\r\n * @internal\r\n */\r\nexport class Texture extends RenderTexture implements WebGLDisposable {\r\n public readonly texture: TextureHandle;\r\n public readonly ownership?: TextureOwnership;\r\n public transparency: TextureTransparency;\r\n\r\n public get bytesUsed(): number { return this.texture.bytesUsed; }\r\n public get hasOwner(): boolean { return undefined !== this.ownership; }\r\n public get key(): string | undefined {\r\n return typeof this.ownership !== \"string\" && typeof this.ownership?.key === \"string\" ? this.ownership.key : undefined;\r\n }\r\n\r\n public constructor(params: TextureParams) {\r\n super(params.type);\r\n this.ownership = params.ownership;\r\n this.texture = params.handle;\r\n this.transparency = params.handle.format === GL.Texture.Format.Rgba ? params.transparency : TextureTransparency.Opaque;\r\n }\r\n\r\n public get isDisposed(): boolean { return this.texture.isDisposed; }\r\n\r\n /** Free this object in the WebGL wrapper. */\r\n public dispose() {\r\n dispose(this.texture);\r\n }\r\n\r\n public get hasTranslucency(): boolean { return TextureTransparency.Opaque !== this.transparency; }\r\n}\r\n\r\nfunction getDataType(data: Texture2DData): GL.Texture.DataType {\r\n return data instanceof Float32Array ? GL.Texture.DataType.Float : GL.Texture.DataType.UnsignedByte;\r\n}\r\n\r\n/** Parameters used internally to define how to create a texture for use with WebGL. */\r\nclass Texture2DCreateParams {\r\n private constructor(\r\n public width: number,\r\n public height: number,\r\n public format: GL.Texture.Format,\r\n public dataType: GL.Texture.DataType,\r\n public wrapMode: GL.Texture.WrapMode,\r\n public loadImageData: Load2DImageData,\r\n public useMipMaps?: TextureFlag,\r\n public interpolate?: TextureFlag,\r\n public anisotropicFilter?: TextureAnisotropicFilter,\r\n public dataBytes?: Uint8Array) { }\r\n\r\n public static createForData(width: number, height: number, data: Texture2DData, preserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n const bytes = (preserveData && data instanceof Uint8Array) ? data : undefined;\r\n return new Texture2DCreateParams(width, height, format, getDataType(data), wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params, data), undefined, undefined, undefined, bytes);\r\n }\r\n\r\n public static createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(type);\r\n if (ImageBufferFormat.Rgb === image.format)\r\n props.format = GL.Texture.Format.Rgb;\r\n\r\n return new Texture2DCreateParams(image.width, image.height, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params, image.data), props.useMipMaps, props.interpolate);\r\n }\r\n\r\n public static createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return new Texture2DCreateParams(width, height, format, dataType, GL.Texture.WrapMode.ClampToEdge,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTextureFromBytes(tex, params), undefined, undefined);\r\n }\r\n\r\n public static createForImage(image: HTMLImageElement, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(type);\r\n\r\n let targetWidth = image.naturalWidth;\r\n let targetHeight = image.naturalHeight;\r\n\r\n const caps = System.instance.capabilities;\r\n if (RenderTexture.Type.Glyph === type) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n } else if (!caps.supportsNonPowerOf2Textures && (!isPowerOfTwo(targetWidth) || !isPowerOfTwo(targetHeight))) {\r\n if (GL.Texture.WrapMode.ClampToEdge === props.wrapMode) {\r\n // NPOT are supported but not mipmaps\r\n // Probably on poor hardware so I choose to disable mipmaps for lower memory usage over quality. If quality is required we need to resize the image to a pow of 2.\r\n // Above comment is not necessarily true - WebGL doesn't support NPOT mipmapping, only supporting base NPOT caps\r\n props.useMipMaps = undefined;\r\n } else if (GL.Texture.WrapMode.Repeat === props.wrapMode) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n }\r\n }\r\n\r\n // Cap texture dimensions to system WebGL capabilities\r\n const maxTexSize = System.instance.capabilities.maxTextureSize;\r\n targetWidth = Math.min(targetWidth, maxTexSize);\r\n targetHeight = Math.min(targetHeight, maxTexSize);\r\n\r\n let element: CanvasOrImage = image;\r\n if (targetWidth !== image.naturalWidth || targetHeight !== image.naturalHeight) {\r\n // Resize so dimensions are powers-of-two\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = targetWidth;\r\n canvas.height = targetHeight;\r\n\r\n const context = canvas.getContext(\"2d\")!;\r\n context.drawImage(image, 0, 0, canvas.width, canvas.height);\r\n\r\n element = canvas;\r\n }\r\n\r\n return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTexture2DImageData(tex, params, undefined, element), props.useMipMaps, props.interpolate, props.anisotropicFilter);\r\n }\r\n\r\n public static createForImageBitmap(image: ImageBitmap, type: RenderTexture.Type) {\r\n const props = this.getImageProperties(type);\r\n\r\n let targetWidth = image.width;\r\n let targetHeight = image.height;\r\n\r\n const caps = System.instance.capabilities;\r\n if (RenderTexture.Type.Glyph === type) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n } else if (!caps.supportsNonPowerOf2Textures && (!isPowerOfTwo(targetWidth) || !isPowerOfTwo(targetHeight))) {\r\n if (GL.Texture.WrapMode.ClampToEdge === props.wrapMode) {\r\n // NPOT are supported but not mipmaps\r\n // Probably on poor hardware so I choose to disable mipmaps for lower memory usage over quality. If quality is required we need to resize the image to a pow of 2.\r\n // Above comment is not necessarily true - WebGL doesn't support NPOT mipmapping, only supporting base NPOT caps\r\n props.useMipMaps = undefined;\r\n } else if (GL.Texture.WrapMode.Repeat === props.wrapMode) {\r\n targetWidth = nextHighestPowerOfTwo(targetWidth);\r\n targetHeight = nextHighestPowerOfTwo(targetHeight);\r\n }\r\n }\r\n\r\n // Always draw to canvas for ImageBitmap\r\n const canvas = document.createElement(\"canvas\");\r\n canvas.width = targetWidth;\r\n canvas.height = targetHeight;\r\n const context = canvas.getContext(\"2d\")!;\r\n context.drawImage(image, 0, 0, canvas.width, canvas.height);\r\n\r\n return new Texture2DCreateParams(targetWidth, targetHeight, props.format, GL.Texture.DataType.UnsignedByte, props.wrapMode,\r\n (tex: TextureHandle, params: Texture2DCreateParams) => loadTexture2DImageData(tex, params, undefined, canvas), props.useMipMaps, props.interpolate, props.anisotropicFilter);\r\n }\r\n\r\n private static getImageProperties(type: RenderTexture.Type): TextureImageProperties {\r\n const isSky = RenderTexture.Type.SkyBox === type;\r\n const isTile = RenderTexture.Type.TileSection === type;\r\n const isThematic = RenderTexture.Type.ThematicGradient === type;\r\n const isFilteredTile = RenderTexture.Type.FilteredTileSection === type;\r\n const maxAnisotropicFilterLevel = 16;\r\n\r\n const wrapMode = RenderTexture.Type.Normal === type ? GL.Texture.WrapMode.Repeat : GL.Texture.WrapMode.ClampToEdge;\r\n const useMipMaps: TextureFlag = (!isSky && !isTile && !isFilteredTile && !isThematic) ? true : undefined;\r\n const interpolate: TextureFlag = isThematic ? undefined : true;\r\n const anisotropicFilter = isFilteredTile ? maxAnisotropicFilterLevel : undefined;\r\n\r\n // Always use RGBA. RGB is much slower and almost certainly does not actually save any GPU memory.\r\n const format = GL.Texture.Format.Rgba;\r\n\r\n return { format, wrapMode, useMipMaps, interpolate, anisotropicFilter };\r\n }\r\n\r\n public static readonly placeholderParams = new Texture2DCreateParams(1, 1, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte, GL.Texture.WrapMode.ClampToEdge,\r\n (_tex: TextureHandle, _params: Texture2DCreateParams) => undefined);\r\n}\r\n\r\nclass TextureCubeCreateParams {\r\n private constructor(\r\n public dim: number,\r\n public format: GL.Texture.Format,\r\n public dataType: GL.Texture.DataType,\r\n public wrapMode: GL.Texture.WrapMode,\r\n public loadImageData: LoadCubeImageData) { }\r\n\r\n public static createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement): TextureCubeCreateParams | undefined {\r\n const targetDim = posX.naturalWidth;\r\n\r\n if (posX.naturalHeight !== targetDim) // Cube texture dimensions must match (width must equal height)\r\n return undefined;\r\n\r\n const images: HTMLImageElement[] = [posX, negX, posY, negY, posZ, negZ];\r\n\r\n for (let i = 1; i < images.length; i++) { // Dimensions of all six sides must match each other\r\n if (images[i].naturalWidth !== targetDim || images[i].naturalHeight !== targetDim)\r\n return undefined;\r\n }\r\n\r\n return new TextureCubeCreateParams(targetDim, GL.Texture.Format.Rgba, GL.Texture.DataType.UnsignedByte, GL.Texture.WrapMode.ClampToEdge,\r\n (tex: TextureHandle, params: TextureCubeCreateParams) => loadTextureCubeImageData(tex, params, images));\r\n }\r\n}\r\n\r\n/** Wraps a WebGLTextureHandle\r\n * @internal\r\n */\r\nexport abstract class TextureHandle implements WebGLDisposable {\r\n protected _glTexture?: WebGLTexture;\r\n protected _bytesUsed = 0;\r\n\r\n public abstract get width(): number;\r\n public abstract get height(): number;\r\n public abstract get format(): GL.Texture.Format;\r\n public abstract get dataType(): GL.Texture.DataType;\r\n public abstract get dataBytes(): Uint8Array | undefined;\r\n public get bytesUsed(): number { return this._bytesUsed; }\r\n public set bytesUsed(bytesUsed: number) {\r\n // assert(0 === this.bytesUsed);\r\n this._bytesUsed = bytesUsed;\r\n }\r\n\r\n /** Get the WebGLTexture for this TextureHandle. */\r\n public getHandle(): WebGLTexture | undefined { return this._glTexture; }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public abstract bind(_texUnit: TextureUnit): boolean;\r\n\r\n /** Bind this texture to a uniform sampler. */\r\n public abstract bindSampler(_uniform: UniformHandle, _unit: TextureUnit): void;\r\n\r\n public get isDisposed(): boolean { return this._glTexture === undefined; }\r\n\r\n public dispose() {\r\n if (!this.isDisposed) {\r\n System.instance.disposeTexture(this._glTexture!);\r\n this._glTexture = undefined;\r\n this.bytesUsed = 0;\r\n }\r\n }\r\n\r\n /** Create a 2D texture for use as a color attachment for rendering */\r\n public static createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return Texture2DHandle.createForAttachment(width, height, format, dataType);\r\n }\r\n\r\n /** Create a 2D texture to hold non-image data */\r\n public static createForData(width: number, height: number, data: Texture2DData, wantPreserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n return Texture2DHandle.createForData(width, height, data, wantPreserveData, wrapMode, format);\r\n }\r\n\r\n /** Create a 2D texture from a bitmap */\r\n public static createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImageBuffer(image, type);\r\n }\r\n\r\n /** Create a 2D texture from an HTMLImageElement. */\r\n public static createForImage(image: HTMLImageElement, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImage(image, type);\r\n }\r\n\r\n /** Create a 2D texture from an ImageBitmap. */\r\n public static createForImageBitmap(image: ImageBitmap, type: RenderTexture.Type) {\r\n return Texture2DHandle.createForImageBitmap(image, type);\r\n }\r\n\r\n /** Create a cube map texture from six HTMLImageElement objects. */\r\n public static createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement) {\r\n return TextureCubeHandle.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n }\r\n\r\n public static createForElement(id: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat, onLoaded: ExternalTextureLoadCallback) {\r\n return Texture2DHandle.createForElement(id, imodel, type, format, onLoaded);\r\n }\r\n\r\n protected constructor(glTexture: WebGLTexture) {\r\n this._glTexture = glTexture;\r\n }\r\n\r\n /** For debugging purposes, open a new window containing this texture as an image. */\r\n public showDebugImage(): void {\r\n const gl = System.instance.context;\r\n const fbo = gl.createFramebuffer();\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, fbo);\r\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, this.getHandle()!, 0);\r\n if (gl.FRAMEBUFFER_COMPLETE === gl.checkFramebufferStatus(gl.FRAMEBUFFER)) {\r\n const w = this.width;\r\n const h = this.height;\r\n const pixels = new Uint8Array(w * h * 4);\r\n gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, pixels);\r\n\r\n const buffer = ImageBuffer.create(pixels, ImageBufferFormat.Rgba, w)!;\r\n const url = imageBufferToPngDataUrl(buffer, false);\r\n openImageDataUrlInNewWindow(url!, \"Classifiers\");\r\n }\r\n\r\n gl.bindFramebuffer(gl.FRAMEBUFFER, null);\r\n gl.deleteFramebuffer(fbo);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class Texture2DHandle extends TextureHandle {\r\n private _width: number;\r\n private _height: number;\r\n private _format: GL.Texture.Format;\r\n private _dataType: GL.Texture.DataType;\r\n private _dataBytes?: Uint8Array;\r\n\r\n public get width(): number { return this._width; }\r\n public get height(): number { return this._height; }\r\n public get format(): GL.Texture.Format { return this._format; }\r\n public get dataType(): GL.Texture.DataType { return this._dataType; }\r\n public get dataBytes(): Uint8Array | undefined { return this._dataBytes; }\r\n\r\n /** Bind specified texture handle to specified texture unit. */\r\n public static bindTexture(texUnit: TextureUnit, glTex: WebGLTexture | undefined) {\r\n assert(!(glTex instanceof TextureHandle));\r\n System.instance.bindTexture2d(texUnit, glTex);\r\n }\r\n\r\n /** Bind the specified texture to a uniform sampler2D */\r\n public static bindSampler(uniform: UniformHandle, tex: WebGLTexture, unit: TextureUnit): void {\r\n assert(!(tex instanceof TextureHandle));\r\n this.bindTexture(unit, tex);\r\n uniform.setUniform1i(unit - TextureUnit.Zero);\r\n }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public bind(texUnit: TextureUnit): boolean {\r\n if (undefined === this._glTexture)\r\n return false;\r\n Texture2DHandle.bindTexture(texUnit, this._glTexture);\r\n return true;\r\n }\r\n\r\n /** Bind this texture to a uniform sampler2D */\r\n public bindSampler(uniform: UniformHandle, unit: TextureUnit): void {\r\n if (undefined !== this._glTexture)\r\n Texture2DHandle.bindSampler(uniform, this._glTexture, unit);\r\n }\r\n\r\n /** Update the 2D texture contents. */\r\n public update(updater: Texture2DDataUpdater): boolean {\r\n if (0 === this.width || 0 === this.height || undefined === this._dataBytes || 0 === this._dataBytes.length) {\r\n assert(false);\r\n return false;\r\n }\r\n\r\n if (!updater.modified)\r\n return false;\r\n\r\n return this.replaceTextureData(this._dataBytes);\r\n }\r\n\r\n /** Replace the 2D texture contents. */\r\n public replaceTextureData(data: Texture2DData): boolean {\r\n assert((GL.Texture.DataType.Float === this._dataType) === (data instanceof Float32Array));\r\n\r\n const tex = this.getHandle()!;\r\n if (undefined === tex)\r\n return false;\r\n\r\n const gl = System.instance.context;\r\n gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);\r\n\r\n // Go through System to ensure we don't interfere with currently-bound textures!\r\n System.instance.activateTexture2d(TextureUnit.Zero, tex);\r\n gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.height, this._format, this._dataType, data);\r\n System.instance.bindTexture2d(TextureUnit.Zero, undefined);\r\n\r\n return true;\r\n }\r\n\r\n private static create(params: Texture2DCreateParams): Texture2DHandle | undefined {\r\n const glTex = System.instance.context.createTexture();\r\n return null !== glTex ? new Texture2DHandle(glTex, params) : undefined;\r\n }\r\n\r\n /** Create a texture for use as a color attachment for rendering */\r\n public static override createForAttachment(width: number, height: number, format: GL.Texture.Format, dataType: GL.Texture.DataType) {\r\n return this.create(Texture2DCreateParams.createForAttachment(width, height, format, dataType));\r\n }\r\n\r\n /** Create a texture to hold non-image data */\r\n public static override createForData(width: number, height: number, data: Texture2DData, wantPreserveData = false, wrapMode = GL.Texture.WrapMode.ClampToEdge, format = GL.Texture.Format.Rgba) {\r\n return this.create(Texture2DCreateParams.createForData(width, height, data, wantPreserveData, wrapMode, format));\r\n }\r\n\r\n /** Create a texture from a bitmap */\r\n public static override createForImageBuffer(image: ImageBuffer, type: RenderTexture.Type) {\r\n if (RenderTexture.Type.TileSection !== type && RenderTexture.Type.ThematicGradient !== type)\r\n assert(isPowerOfTwo(image.width) && isPowerOfTwo(image.height), \"###TODO: Resize image dimensions to powers-of-two if necessary\");\r\n\r\n return this.create(Texture2DCreateParams.createForImageBuffer(image, type));\r\n }\r\n\r\n /** Create a 2D texture from an HTMLImageElement. */\r\n public static override createForImage(image: HTMLImageElement, type: RenderTexture.Type) {\r\n return this.create(Texture2DCreateParams.createForImage(image, type));\r\n }\r\n\r\n /** Create a 2D texture from an ImageBitmap. */\r\n public static override createForImageBitmap(image: ImageBitmap, type: RenderTexture.Type) {\r\n return this.create(Texture2DCreateParams.createForImageBitmap(image, type));\r\n }\r\n\r\n private static _placeHolderTextureData = new Uint8Array([128, 128, 128]);\r\n\r\n public static override createForElement(id: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat, onLoaded: ExternalTextureLoadCallback) {\r\n // set a placeholder texture while we wait for the external texture to load\r\n const handle = this.createForData(1, 1, this._placeHolderTextureData, undefined, undefined, GL.Texture.Format.Rgb);\r\n\r\n if (undefined === handle)\r\n return undefined;\r\n\r\n // kick off loading the texture from the backend\r\n ExternalTextureLoader.instance.loadTexture(handle, id, imodel, type, format, onLoaded);\r\n\r\n return handle;\r\n }\r\n\r\n public reload(params: Texture2DCreateParams) {\r\n this._width = params.width;\r\n this._height = params.height;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n this._dataBytes = params.dataBytes;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n\r\n private constructor(glTexture: WebGLTexture, params: Texture2DCreateParams) {\r\n super(glTexture);\r\n this._width = params.width;\r\n this._height = params.height;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n this._dataBytes = params.dataBytes;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport type ExternalTextureLoadCallback = (req: ExternalTextureRequest, data: TextureData) => void;\r\n\r\n/** @internal */\r\nexport interface ExternalTextureRequest {\r\n handle: Texture2DHandle;\r\n name: Id64String;\r\n imodel: IModelConnection;\r\n type: RenderTexture.Type;\r\n format: ImageSourceFormat;\r\n onLoaded?: ExternalTextureLoadCallback;\r\n}\r\n\r\n/** @internal */\r\ninterface TextureConvertRequest {\r\n req: ExternalTextureRequest;\r\n texData: TextureData;\r\n}\r\n\r\n/** @internal */\r\nexport class ExternalTextureLoader { /* currently exported for tests only */\r\n public static readonly instance = new ExternalTextureLoader(2);\r\n public readonly onTexturesLoaded = new BeEvent<() => void>();\r\n private readonly _maxActiveRequests: number;\r\n private _activeRequests: Array<ExternalTextureRequest> = [];\r\n private _pendingRequests: Array<ExternalTextureRequest> = [];\r\n private _convertRequests: Array<TextureConvertRequest> = [];\r\n private _convertPending = false;\r\n\r\n public get numActiveRequests() { return this._activeRequests.length; }\r\n public get numPendingRequests() { return this._pendingRequests.length; }\r\n public get maxActiveRequests() { return this._maxActiveRequests; }\r\n\r\n private constructor(maxActiveRequests: number) {\r\n this._maxActiveRequests = maxActiveRequests;\r\n }\r\n\r\n private async _nextRequest(prevReq: ExternalTextureRequest) {\r\n this._activeRequests.splice(this._activeRequests.indexOf(prevReq), 1);\r\n if (this._activeRequests.length < this._maxActiveRequests && this._pendingRequests.length > 0) {\r\n const req = this._pendingRequests.shift()!;\r\n await this._activateRequest(req);\r\n }\r\n if (this._activeRequests.length < 1 && this._pendingRequests.length < 1)\r\n this.onTexturesLoaded.raiseEvent();\r\n }\r\n\r\n private async _activateRequest(req: ExternalTextureRequest) {\r\n if (req.imodel.isClosed)\r\n return;\r\n\r\n this._activeRequests.push(req);\r\n\r\n try {\r\n if (!req.imodel.isClosed) {\r\n const maxTextureSize = System.instance.capabilities.maxTexSizeAllow;\r\n const texData = await req.imodel.queryTextureData({ name: req.name, maxTextureSize });\r\n if (undefined !== texData) {\r\n const cnvReq = { req, texData };\r\n this._convertRequests.push(cnvReq);\r\n // _convertPending is used to prevent overlapping calls to _convertTexture (from overlapping calls to _activateRequest)\r\n // it has been put on the list, so if it doesn't get converted here it will get converted by the loop that is converting the current one\r\n do {\r\n if (!this._convertPending)\r\n await this._convertTexture();\r\n } while (!this._convertPending && this._convertRequests.length > 0);\r\n if (!req.imodel.isClosed) {\r\n IModelApp.tileAdmin.invalidateAllScenes();\r\n if (undefined !== req.onLoaded)\r\n req.onLoaded(req, texData);\r\n }\r\n }\r\n }\r\n } catch (_e) { }\r\n\r\n return this._nextRequest(req);\r\n }\r\n\r\n private async _convertTexture(): Promise<void> {\r\n this._convertPending = true;\r\n try {\r\n const cnvReq = this._convertRequests.shift();\r\n if (undefined !== cnvReq) {\r\n const imageSource = new ImageSource(cnvReq.texData.bytes, cnvReq.texData.format);\r\n if (System.instance.capabilities.supportsCreateImageBitmap) {\r\n const blob = new Blob([imageSource.data], { type: getImageSourceMimeType(imageSource.format) });\r\n const image = await createImageBitmap(blob, 0, 0, cnvReq.texData.width, cnvReq.texData.height);\r\n if (!cnvReq.req.imodel.isClosed) {\r\n cnvReq.req.handle.reload(Texture2DCreateParams.createForImageBitmap(image, cnvReq.req.type));\r\n }\r\n } else {\r\n const image = await imageElementFromImageSource(imageSource);\r\n if (!cnvReq.req.imodel.isClosed) {\r\n cnvReq.req.handle.reload(Texture2DCreateParams.createForImage(image, cnvReq.req.type));\r\n }\r\n }\r\n }\r\n } catch (_e) { }\r\n this._convertPending = false;\r\n }\r\n\r\n private _requestExists(reqToCheck: ExternalTextureRequest) {\r\n for (const r of this._activeRequests)\r\n if (reqToCheck.name === r.name && reqToCheck.imodel === r.imodel)\r\n return true;\r\n\r\n for (const r of this._pendingRequests)\r\n if (reqToCheck.name === r.name && reqToCheck.imodel === r.imodel)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n public loadTexture(handle: Texture2DHandle, name: Id64String, imodel: IModelConnection, type: RenderTexture.Type, format: ImageSourceFormat, onLoaded?: ExternalTextureLoadCallback) {\r\n const req = { handle, name, imodel, type, format, onLoaded };\r\n if (this._requestExists(req))\r\n return;\r\n\r\n if (this._activeRequests.length + 1 > this._maxActiveRequests) {\r\n this._pendingRequests.push(req);\r\n } else\r\n this._activateRequest(req); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class TextureCubeHandle extends TextureHandle {\r\n private _dim: number; // Cubemap texture height and width must match. This must be the same for each of the six faces.\r\n private _format: GL.Texture.Format; // Format must be the same for each of the six faces.\r\n private _dataType: GL.Texture.DataType; // Type must be the same for each of the six faces.\r\n\r\n public get width(): number { return this._dim; }\r\n public get height(): number { return this._dim; }\r\n public get format(): GL.Texture.Format { return this._format; }\r\n public get dataType(): GL.Texture.DataType { return this._dataType; }\r\n public get dataBytes(): Uint8Array | undefined { return undefined; }\r\n\r\n /** Bind specified cubemap texture handle to specified texture unit. */\r\n public static bindTexture(texUnit: TextureUnit, glTex: WebGLTexture | undefined) {\r\n assert(!(glTex instanceof TextureHandle));\r\n System.instance.bindTextureCubeMap(texUnit, glTex);\r\n }\r\n\r\n /** Bind the specified texture to a uniform sampler2D */\r\n public static bindSampler(uniform: UniformHandle, tex: WebGLTexture, unit: TextureUnit): void {\r\n assert(!(tex instanceof TextureHandle));\r\n this.bindTexture(unit, tex);\r\n uniform.setUniform1i(unit - TextureUnit.Zero);\r\n }\r\n\r\n /** Bind texture handle (if available) associated with an instantiation of this class to specified texture unit. */\r\n public bind(texUnit: TextureUnit): boolean {\r\n if (undefined === this._glTexture)\r\n return false;\r\n TextureCubeHandle.bindTexture(texUnit, this._glTexture);\r\n return true;\r\n }\r\n\r\n /** Bind this texture to a uniform sampler2D */\r\n public bindSampler(uniform: UniformHandle, unit: TextureUnit): void {\r\n if (undefined !== this._glTexture)\r\n TextureCubeHandle.bindSampler(uniform, this._glTexture, unit);\r\n }\r\n\r\n private static create(params: TextureCubeCreateParams): TextureHandle | undefined {\r\n const glTex = System.instance.context.createTexture();\r\n return null !== glTex ? new TextureCubeHandle(glTex, params) : undefined;\r\n }\r\n\r\n /** Create a cube map texture from six HTMLImageElement objects. */\r\n public static override createForCubeImages(posX: HTMLImageElement, negX: HTMLImageElement, posY: HTMLImageElement, negY: HTMLImageElement, posZ: HTMLImageElement, negZ: HTMLImageElement) {\r\n const params = TextureCubeCreateParams.createForCubeImages(posX, negX, posY, negY, posZ, negZ);\r\n return params !== undefined ? this.create(params) : undefined;\r\n }\r\n\r\n private constructor(glTexture: WebGLTexture, params: TextureCubeCreateParams) {\r\n super(glTexture);\r\n this._dim = params.dim;\r\n this._format = params.format;\r\n this._dataType = params.dataType;\r\n\r\n params.loadImageData(this, params);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class Texture2DDataUpdater {\r\n public data: Uint8Array;\r\n public modified: boolean = false;\r\n\r\n public constructor(data: Uint8Array) { this.data = data; }\r\n\r\n public setByteAtIndex(index: number, byte: number) {\r\n assert(index < this.data.length);\r\n if (byte !== this.data[index]) {\r\n this.data[index] = byte;\r\n this.modified = true;\r\n }\r\n }\r\n\r\n public setOvrFlagsAtIndex(index: number, value: OvrFlags) {\r\n assert(index < this.data.length - 1);\r\n assert(value < 0xffff);\r\n this.setByteAtIndex(index, value & 0xff);\r\n this.setByteAtIndex(index + 1, (value & 0xff00) >> 8);\r\n }\r\n\r\n public getByteAtIndex(index: number): number { assert(index < this.data.length); return this.data[index]; }\r\n public getOvrFlagsAtIndex(index: number): OvrFlags {\r\n const lo = this.getByteAtIndex(index);\r\n const hi = this.getByteAtIndex(index + 1);\r\n return lo | (hi << 8);\r\n }\r\n}\r\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Id64String } from "@itwin/core-bentley";
|
|
5
5
|
import { Point3d, Range2d, Range3d, Transform, Vector3d } from "@itwin/core-geometry";
|
|
6
|
-
import { BatchType, ElementAlignedBox3d, FeatureTable, MeshPolylineList, QParams2d, QParams3d,
|
|
6
|
+
import { BatchType, ElementAlignedBox3d, FeatureTable, MeshPolylineList, QParams2d, QParams3d, TextureMapping, TileReadStatus } from "@itwin/core-common";
|
|
7
7
|
import { IModelConnection } from "../IModelConnection";
|
|
8
8
|
import { PickableGraphicOptions } from "../render/GraphicBuilder";
|
|
9
9
|
import { InstancedGraphicParams } from "../render/InstancedGraphicParams";
|
|
@@ -226,7 +226,10 @@ interface GltfImage extends GltfChildOfRootProperty {
|
|
|
226
226
|
interface GltfTextureInfo extends GltfProperty {
|
|
227
227
|
/** The Id of the [[GltfTexture]]. */
|
|
228
228
|
index: GltfId;
|
|
229
|
-
/** The set index of the texture's TEXCOORD attribute used for texture coordinate mapping.
|
|
229
|
+
/** The set index of the texture's TEXCOORD attribute used for texture coordinate mapping.
|
|
230
|
+
* For example, if `texCoord` is `2`, an attribute named `TEXCOORD_2` must exist containing the texture coordinates.
|
|
231
|
+
* Default: 0.
|
|
232
|
+
*/
|
|
230
233
|
texCoord?: number;
|
|
231
234
|
}
|
|
232
235
|
/** Describes a texture and its sampler. */
|
|
@@ -240,17 +243,25 @@ interface GltfTexture extends GltfChildOfRootProperty {
|
|
|
240
243
|
*/
|
|
241
244
|
source?: GltfId;
|
|
242
245
|
}
|
|
243
|
-
/** Describes the filtering and wrapping behavior to be applied to a [[GltfTexture]].
|
|
246
|
+
/** Describes the filtering and wrapping behavior to be applied to a [[GltfTexture]].
|
|
247
|
+
* @note The implementation currently does not support MirroredRepeat and does not support different wrapping for U and V;
|
|
248
|
+
* effectively, unless `wrapS` or `wrapT` is set to ClampToEdge, the sampler will use GltfWrapMode.Repeat.
|
|
249
|
+
*/
|
|
244
250
|
interface GltfSampler extends GltfChildOfRootProperty {
|
|
245
251
|
/** Magnification filter. */
|
|
246
252
|
magFilter?: GltfMagFilter;
|
|
247
253
|
/** Minification filter. */
|
|
248
254
|
minFilter?: GltfMinFilter;
|
|
249
|
-
/** S (U) wrapping mode. */
|
|
255
|
+
/** S (U) wrapping mode. Default: Repeat. */
|
|
250
256
|
wrapS?: GltfWrapMode;
|
|
251
|
-
/** T (V) wrapping mode. */
|
|
257
|
+
/** T (V) wrapping mode. Default: Repeat. */
|
|
252
258
|
wrapT?: GltfWrapMode;
|
|
253
259
|
}
|
|
260
|
+
/** GL states that can be enabled by a [[GltfTechnique]]. Only those queried by this implementation are enumerated. */
|
|
261
|
+
declare enum GltfTechniqueState {
|
|
262
|
+
/** Enables alpha blending. */
|
|
263
|
+
Blend = 3042
|
|
264
|
+
}
|
|
254
265
|
/** For glTF 1.0 only, describes shader programs and shader state associated with a [[Gltf1Material]], used to render meshes associated with the material.
|
|
255
266
|
* This implementation uses it strictly to identify techniques that require alpha blending.
|
|
256
267
|
*/
|
|
@@ -258,9 +269,9 @@ interface GltfTechnique extends GltfChildOfRootProperty {
|
|
|
258
269
|
/** GL render states to be applied by the technique. */
|
|
259
270
|
states?: {
|
|
260
271
|
/** An array of integers corresponding to boolean GL states that should be enabled using GL's `enable` function.
|
|
261
|
-
* For example, the value
|
|
272
|
+
* For example, the value [[GltfTechniqueState.Blend]] (3042) indicates that blending should be enabled.
|
|
262
273
|
*/
|
|
263
|
-
enable?:
|
|
274
|
+
enable?: GltfTechniqueState[];
|
|
264
275
|
};
|
|
265
276
|
}
|
|
266
277
|
interface Gltf1Material extends GltfChildOfRootProperty {
|
|
@@ -291,6 +302,10 @@ interface Gltf2Material extends GltfChildOfRootProperty {
|
|
|
291
302
|
alphaCutoff?: number;
|
|
292
303
|
doubleSided?: boolean;
|
|
293
304
|
extensions?: GltfExtensions & {
|
|
305
|
+
/** The [KHR_materials_unlit](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_unlit) extension
|
|
306
|
+
* indicates that the material should be displayed without lighting. The extension adds no additional properties; it is effectively a boolean flag.
|
|
307
|
+
*/
|
|
308
|
+
KHR_materials_unlit?: {};
|
|
294
309
|
/** The [KHR_techniques_webgl extension](https://github.com/KhronosGroup/glTF/blob/c1c12bd100e88ff468ccef1cb88cfbec56a69af2/extensions/2.0/Khronos/KHR_techniques_webgl/README.md)
|
|
295
310
|
* allows "techniques" to be associated with [[GltfMaterial]]s. Techniques can supply custom shader programs to render geometry; this was a core feature of glTF 1.0 (see [[GltfTechnique]]).
|
|
296
311
|
* Here, it is only used to extract uniform values.
|
|
@@ -467,7 +482,7 @@ export declare class GltfMeshData {
|
|
|
467
482
|
uvQParams?: QParams2d;
|
|
468
483
|
uvs?: Uint16Array;
|
|
469
484
|
uvRange?: Range2d;
|
|
470
|
-
indices?: Uint16Array | Uint32Array;
|
|
485
|
+
indices?: Uint8Array | Uint16Array | Uint32Array;
|
|
471
486
|
constructor(props: Mesh);
|
|
472
487
|
}
|
|
473
488
|
/** A function that returns true if deserialization of the data supplied by the reader should abort.
|
|
@@ -519,15 +534,14 @@ export declare abstract class GltfReader {
|
|
|
519
534
|
private readonly _canceled?;
|
|
520
535
|
protected readonly _sceneNodes: GltfId[];
|
|
521
536
|
protected _computedContentRange?: ElementAlignedBox3d;
|
|
537
|
+
private readonly _resolvedTextures;
|
|
522
538
|
protected get _nodes(): GltfDictionary<GltfNode>;
|
|
523
539
|
protected get _meshes(): GltfDictionary<GltfMesh>;
|
|
524
540
|
protected get _accessors(): GltfDictionary<GltfAccessor>;
|
|
525
541
|
protected get _bufferViews(): GltfDictionary<GltfBufferViewProps>;
|
|
526
542
|
protected get _materials(): GltfDictionary<GltfMaterial>;
|
|
527
543
|
protected get _samplers(): GltfDictionary<GltfSampler>;
|
|
528
|
-
protected get _textures(): GltfDictionary<GltfTexture
|
|
529
|
-
resolvedTexture?: RenderTexture;
|
|
530
|
-
}>;
|
|
544
|
+
protected get _textures(): GltfDictionary<GltfTexture>;
|
|
531
545
|
protected get _images(): GltfDictionary<GltfImage & {
|
|
532
546
|
resolvedImage?: HTMLImageElement;
|
|
533
547
|
}>;
|
|
@@ -571,7 +585,8 @@ export declare abstract class GltfReader {
|
|
|
571
585
|
}, accessorName: string, type: GltfDataType): GltfBufferData | undefined;
|
|
572
586
|
protected readFeatureIndices(_json: any): number[] | undefined;
|
|
573
587
|
private extractTextureId;
|
|
574
|
-
|
|
588
|
+
private isMaterialTransparent;
|
|
589
|
+
protected createDisplayParams(material: GltfMaterial, hasBakedLighting: boolean): DisplayParams | undefined;
|
|
575
590
|
protected readMeshPrimitive(primitive: GltfMeshPrimitive, featureTable?: FeatureTable, pseudoRtcBias?: Vector3d): GltfMeshData | undefined;
|
|
576
591
|
private deduplicateVertices;
|
|
577
592
|
/**
|
|
@@ -601,9 +616,8 @@ export declare abstract class GltfReader {
|
|
|
601
616
|
private resolveUrl;
|
|
602
617
|
private resolveBuffer;
|
|
603
618
|
private resolveImage;
|
|
604
|
-
private resolveTextures;
|
|
605
619
|
private resolveTexture;
|
|
606
|
-
protected findTextureMapping(
|
|
620
|
+
protected findTextureMapping(id: string, isTransparent: boolean): TextureMapping | undefined;
|
|
607
621
|
}
|
|
608
622
|
/** Arguments supplied to [[readGltfGraphics]] to produce a [[RenderGraphic]] from a [glTF](https://www.khronos.org/gltf/) asset.
|
|
609
623
|
* @public
|
|
@@ -649,9 +663,7 @@ export declare class GltfGraphicsReader extends GltfReader {
|
|
|
649
663
|
get nodes(): GltfDictionary<GltfNode>;
|
|
650
664
|
get scenes(): GltfDictionary<GltfScene>;
|
|
651
665
|
get sceneNodes(): GltfId[];
|
|
652
|
-
get textures(): GltfDictionary<GltfTexture
|
|
653
|
-
resolvedTexture?: RenderTexture;
|
|
654
|
-
}>;
|
|
666
|
+
get textures(): GltfDictionary<GltfTexture>;
|
|
655
667
|
}
|
|
656
668
|
export {};
|
|
657
669
|
//# sourceMappingURL=GltfReader.d.ts.map
|