@luma.gl/webgl 9.1.0-alpha.2 → 9.1.0-beta.1
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/dist/adapter/converters/device-parameters.d.ts +3 -3
- package/dist/adapter/converters/device-parameters.d.ts.map +1 -1
- package/dist/adapter/converters/device-parameters.js +19 -11
- package/dist/adapter/converters/device-parameters.js.map +1 -0
- package/dist/adapter/converters/sampler-parameters.js +7 -4
- package/dist/adapter/converters/sampler-parameters.js.map +1 -0
- package/dist/adapter/converters/shader-formats.js +1 -0
- package/dist/adapter/converters/shader-formats.js.map +1 -0
- package/dist/adapter/converters/vertex-formats.js +1 -0
- package/dist/adapter/converters/vertex-formats.js.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts +40 -0
- package/dist/adapter/converters/webgl-texture-table.d.ts.map +1 -0
- package/dist/adapter/converters/webgl-texture-table.js +304 -0
- package/dist/adapter/converters/webgl-texture-table.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-features.d.ts.map +1 -1
- package/dist/adapter/device-helpers/webgl-device-features.js +2 -3
- package/dist/adapter/device-helpers/webgl-device-features.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-info.js.map +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js +1 -0
- package/dist/adapter/device-helpers/webgl-device-limits.js.map +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js +1 -0
- package/dist/adapter/helpers/decode-webgl-types.js.map +1 -0
- package/dist/adapter/helpers/format-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/format-utils.js +7 -0
- package/dist/adapter/helpers/format-utils.js.map +1 -0
- package/dist/adapter/helpers/get-shader-layout.d.ts +1 -1
- package/dist/adapter/helpers/get-shader-layout.d.ts.map +1 -1
- package/dist/adapter/helpers/get-shader-layout.js +5 -4
- package/dist/adapter/helpers/get-shader-layout.js.map +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js +1 -0
- package/dist/adapter/helpers/parse-shader-compiler-log.js.map +1 -0
- package/dist/adapter/helpers/set-uniform.js +1 -0
- package/dist/adapter/helpers/set-uniform.js.map +1 -0
- package/dist/adapter/helpers/typed-array-utils.d.ts.map +1 -0
- package/dist/{classic → adapter/helpers}/typed-array-utils.js +1 -0
- package/dist/adapter/helpers/typed-array-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-texture-utils.d.ts +100 -29
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +231 -240
- package/dist/adapter/helpers/webgl-texture-utils.js.map +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js +1 -0
- package/dist/adapter/helpers/webgl-topology-utils.js.map +1 -0
- package/dist/adapter/resources/webgl-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-buffer.js +4 -1
- package/dist/adapter/resources/webgl-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-buffer.d.ts +59 -2
- package/dist/adapter/resources/webgl-command-buffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-buffer.js +89 -32
- package/dist/adapter/resources/webgl-command-buffer.js.map +1 -0
- package/dist/adapter/resources/webgl-command-encoder.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-command-encoder.js +4 -0
- package/dist/adapter/resources/webgl-command-encoder.js.map +1 -0
- package/dist/adapter/resources/webgl-external-texture.js +15 -0
- package/dist/adapter/resources/webgl-external-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-framebuffer.d.ts +33 -35
- package/dist/adapter/resources/webgl-framebuffer.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-framebuffer.js +71 -76
- package/dist/adapter/resources/webgl-framebuffer.js.map +1 -0
- package/dist/adapter/resources/webgl-query-set.js +1 -0
- package/dist/adapter/resources/webgl-query-set.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pass.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pass.js +49 -21
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +3 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +45 -23
- package/dist/adapter/resources/webgl-render-pipeline.js.map +1 -0
- package/dist/adapter/resources/webgl-sampler.js +1 -0
- package/dist/adapter/resources/webgl-sampler.js.map +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts +1 -0
- package/dist/adapter/resources/webgl-shader.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-shader.js +13 -6
- package/dist/adapter/resources/webgl-shader.js.map +1 -0
- package/dist/adapter/resources/webgl-texture-view.js +1 -0
- package/dist/adapter/resources/webgl-texture-view.js.map +1 -0
- package/dist/adapter/resources/webgl-texture.d.ts +33 -21
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +172 -242
- package/dist/adapter/resources/webgl-texture.js.map +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js +1 -0
- package/dist/adapter/resources/webgl-transform-feedback.js.map +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js +1 -0
- package/dist/adapter/resources/webgl-vertex-array.js.map +1 -0
- package/dist/adapter/webgl-adapter.d.ts +21 -0
- package/dist/adapter/webgl-adapter.d.ts.map +1 -0
- package/dist/adapter/webgl-adapter.js +86 -0
- package/dist/adapter/webgl-adapter.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +4 -6
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +13 -17
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +35 -46
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +100 -156
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/context/debug/spector-types.d.ts +1108 -0
- package/dist/context/debug/spector-types.d.ts.map +1 -0
- package/dist/context/debug/spector-types.js +698 -0
- package/dist/context/debug/spector-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts +12 -8
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +24 -17
- package/dist/context/debug/spector.js.map +1 -0
- package/dist/context/debug/webgl-developer-tools.d.ts +2 -3
- package/dist/context/debug/webgl-developer-tools.d.ts.map +1 -1
- package/dist/context/debug/webgl-developer-tools.js +7 -19
- package/dist/context/debug/webgl-developer-tools.js.map +1 -0
- package/dist/context/helpers/create-browser-context.d.ts +6 -22
- package/dist/context/helpers/create-browser-context.d.ts.map +1 -1
- package/dist/context/helpers/create-browser-context.js +41 -32
- package/dist/context/helpers/create-browser-context.js.map +1 -0
- package/dist/context/helpers/webgl-context-data.js +1 -0
- package/dist/context/helpers/webgl-context-data.js.map +1 -0
- package/dist/context/helpers/webgl-extensions.js +1 -0
- package/dist/context/helpers/webgl-extensions.js.map +1 -0
- package/dist/context/parameters/unified-parameter-api.js +1 -0
- package/dist/context/parameters/unified-parameter-api.js.map +1 -0
- package/dist/context/parameters/webgl-parameter-tables.d.ts +1 -1
- package/dist/context/parameters/webgl-parameter-tables.d.ts.map +1 -1
- package/dist/context/parameters/webgl-parameter-tables.js +3 -2
- package/dist/context/parameters/webgl-parameter-tables.js.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts +9 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.d.ts.map +1 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js +182 -0
- package/dist/context/polyfills/polyfill-webgl1-extensions.js.map +1 -0
- package/dist/context/state-tracker/deep-array-equal.js +1 -0
- package/dist/context/state-tracker/deep-array-equal.js.map +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts +43 -0
- package/dist/context/state-tracker/webgl-state-tracker.d.ts.map +1 -0
- package/dist/context/state-tracker/{track-context-state.js → webgl-state-tracker.js} +45 -74
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.d.ts.map +1 -1
- package/dist/context/state-tracker/with-parameters.js +6 -4
- package/dist/context/state-tracker/with-parameters.js.map +1 -0
- package/dist/deprecated/accessor.d.ts.map +1 -0
- package/dist/{classic → deprecated}/accessor.js +37 -1
- package/dist/deprecated/accessor.js.map +1 -0
- package/dist/dist.dev.js +2397 -2430
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +2273 -2298
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fill-array.d.ts +4 -4
- package/dist/utils/fill-array.d.ts.map +1 -1
- package/dist/utils/fill-array.js +1 -0
- package/dist/utils/fill-array.js.map +1 -0
- package/dist/utils/load-script.js +1 -0
- package/dist/utils/load-script.js.map +1 -0
- package/dist/utils/split-uniforms-and-bindings.d.ts +1 -1
- package/dist/utils/split-uniforms-and-bindings.d.ts.map +1 -1
- package/dist/utils/split-uniforms-and-bindings.js +1 -0
- package/dist/utils/split-uniforms-and-bindings.js.map +1 -0
- package/dist/utils/uid.d.ts +7 -0
- package/dist/utils/uid.d.ts.map +1 -0
- package/dist/utils/uid.js +15 -0
- package/dist/utils/uid.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +21 -15
- package/src/adapter/converters/sampler-parameters.ts +6 -4
- package/src/adapter/converters/webgl-texture-table.ts +404 -0
- package/src/adapter/device-helpers/webgl-device-features.ts +5 -3
- package/src/{classic → adapter/helpers}/format-utils.ts +6 -0
- package/src/adapter/helpers/get-shader-layout.ts +7 -4
- package/src/adapter/helpers/webgl-texture-utils.ts +410 -64
- package/src/adapter/resources/webgl-buffer.ts +3 -1
- package/src/adapter/resources/webgl-command-buffer.ts +125 -41
- package/src/adapter/resources/webgl-command-encoder.ts +6 -0
- package/src/adapter/resources/webgl-external-texture.ts +14 -0
- package/src/adapter/resources/webgl-framebuffer.ts +80 -86
- package/src/adapter/resources/webgl-render-pass.ts +72 -45
- package/src/adapter/resources/webgl-render-pipeline.ts +58 -27
- package/src/adapter/resources/webgl-shader.ts +15 -7
- package/src/adapter/resources/webgl-texture.ts +202 -274
- package/src/adapter/webgl-adapter.ts +105 -0
- package/src/adapter/webgl-canvas-context.ts +16 -19
- package/src/adapter/webgl-device.ts +144 -210
- package/src/context/debug/spector-types.ts +1154 -0
- package/src/context/debug/spector.ts +38 -29
- package/src/context/debug/webgl-developer-tools.ts +8 -31
- package/src/context/helpers/create-browser-context.ts +53 -63
- package/src/context/parameters/webgl-parameter-tables.ts +2 -2
- package/src/context/polyfills/polyfill-webgl1-extensions.ts +202 -0
- package/src/context/state-tracker/{track-context-state.ts → webgl-state-tracker.ts} +55 -94
- package/src/context/state-tracker/with-parameters.ts +5 -4
- package/src/{classic → deprecated}/accessor.ts +44 -3
- package/src/index.ts +7 -12
- package/src/utils/fill-array.ts +4 -4
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- package/src/utils/uid.ts +16 -0
- package/dist/adapter/converters/texture-formats.d.ts +0 -83
- package/dist/adapter/converters/texture-formats.d.ts.map +0 -1
- package/dist/adapter/converters/texture-formats.js +0 -518
- package/dist/classic/accessor.d.ts.map +0 -1
- package/dist/classic/clear.d.ts +0 -22
- package/dist/classic/clear.d.ts.map +0 -1
- package/dist/classic/clear.js +0 -86
- package/dist/classic/copy-and-blit.d.ts +0 -63
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -193
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/dist/context/state-tracker/track-context-state.d.ts +0 -22
- package/dist/context/state-tracker/track-context-state.d.ts.map +0 -1
- package/src/adapter/converters/texture-formats.ts +0 -665
- package/src/classic/clear.ts +0 -115
- package/src/classic/copy-and-blit.ts +0 -318
- /package/dist/{classic → adapter/helpers}/format-utils.d.ts +0 -0
- /package/dist/{classic → adapter/helpers}/typed-array-utils.d.ts +0 -0
- /package/dist/{classic → deprecated}/accessor.d.ts +0 -0
- /package/src/{classic → adapter/helpers}/typed-array-utils.ts +0 -0
|
@@ -2,14 +2,6 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
// @todo texture refactor
|
|
6
|
-
// - [ ] cube texture init params P1
|
|
7
|
-
// - [ ] 3d texture init params P1
|
|
8
|
-
// - [ ] GPU memory tracking
|
|
9
|
-
// - [ ] raw data inputs
|
|
10
|
-
// - [ ] video (external) textures
|
|
11
|
-
|
|
12
|
-
// import {TypedArray} from '@math.gl/types';
|
|
13
5
|
import type {
|
|
14
6
|
Device,
|
|
15
7
|
TextureProps,
|
|
@@ -17,10 +9,8 @@ import type {
|
|
|
17
9
|
Sampler,
|
|
18
10
|
SamplerProps,
|
|
19
11
|
SamplerParameters,
|
|
20
|
-
// TextureFormat,
|
|
21
12
|
TextureCubeFace,
|
|
22
13
|
ExternalImage,
|
|
23
|
-
TextureLevelData,
|
|
24
14
|
Texture1DData,
|
|
25
15
|
Texture2DData,
|
|
26
16
|
Texture3DData,
|
|
@@ -28,8 +18,6 @@ import type {
|
|
|
28
18
|
TextureArrayData,
|
|
29
19
|
TextureCubeArrayData
|
|
30
20
|
} from '@luma.gl/core';
|
|
31
|
-
// import {decodeTextureFormat} from '@luma.gl/core';
|
|
32
|
-
// import {Buffer, Texture, log} from '@luma.gl/core';
|
|
33
21
|
import {Texture, log} from '@luma.gl/core';
|
|
34
22
|
import {
|
|
35
23
|
GL,
|
|
@@ -38,62 +26,26 @@ import {
|
|
|
38
26
|
GLTexelDataFormat,
|
|
39
27
|
GLTextureTarget
|
|
40
28
|
} from '@luma.gl/constants';
|
|
41
|
-
|
|
42
|
-
import {withGLParameters} from '../../context/state-tracker/with-parameters';
|
|
43
|
-
// getTextureFormatBytesPerPixel
|
|
44
|
-
import {getTextureFormatWebGL} from '../converters/texture-formats';
|
|
29
|
+
import {getTextureFormatWebGL} from '../converters/webgl-texture-table';
|
|
45
30
|
import {convertSamplerParametersToWebGL} from '../converters/sampler-parameters';
|
|
46
31
|
import {WebGLDevice} from '../webgl-device';
|
|
47
|
-
// import {WEBGLBuffer} from './webgl-buffer';
|
|
48
32
|
import {WEBGLSampler} from './webgl-sampler';
|
|
49
33
|
import {WEBGLTextureView} from './webgl-texture-view';
|
|
50
34
|
|
|
51
|
-
// import type {WebGLSetTextureOptions, WebGLCopyTextureOptions} from '../helpers/webgl-texture-utils';
|
|
52
35
|
import {
|
|
53
36
|
initializeTextureStorage,
|
|
54
37
|
// clearMipLevel,
|
|
55
|
-
|
|
38
|
+
copyExternalImageToMipLevel,
|
|
56
39
|
copyCPUDataToMipLevel,
|
|
57
40
|
// copyGPUBufferToMipLevel,
|
|
58
41
|
getWebGLTextureTarget
|
|
59
42
|
} from '../helpers/webgl-texture-utils';
|
|
60
43
|
|
|
61
|
-
// PORTABLE HELPERS (Move to methods on Texture?)
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Normalize TextureData to an array of TextureLevelData / ExternalImages
|
|
65
|
-
* @param data
|
|
66
|
-
* @param options
|
|
67
|
-
* @returns array of TextureLevelData / ExternalImages
|
|
68
|
-
*/
|
|
69
|
-
function normalizeTextureData(
|
|
70
|
-
data: Texture2DData,
|
|
71
|
-
options: {width: number; height: number; depth: number}
|
|
72
|
-
): (TextureLevelData | ExternalImage)[] {
|
|
73
|
-
let lodArray: (TextureLevelData | ExternalImage)[];
|
|
74
|
-
if (ArrayBuffer.isView(data)) {
|
|
75
|
-
lodArray = [
|
|
76
|
-
{
|
|
77
|
-
// ts-expect-error does data really need to be Uint8ClampedArray?
|
|
78
|
-
data,
|
|
79
|
-
width: options.width,
|
|
80
|
-
height: options.height
|
|
81
|
-
// depth: options.depth
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
} else if (!Array.isArray(data)) {
|
|
85
|
-
lodArray = [data];
|
|
86
|
-
} else {
|
|
87
|
-
lodArray = data;
|
|
88
|
-
}
|
|
89
|
-
return lodArray;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
44
|
/**
|
|
93
45
|
* WebGL... the texture API from hell... hopefully made simpler
|
|
94
46
|
*/
|
|
95
47
|
export class WEBGLTexture extends Texture {
|
|
96
|
-
readonly MAX_ATTRIBUTES: number;
|
|
48
|
+
// readonly MAX_ATTRIBUTES: number;
|
|
97
49
|
readonly device: WebGLDevice;
|
|
98
50
|
readonly gl: WebGL2RenderingContext;
|
|
99
51
|
handle: WebGLTexture;
|
|
@@ -101,9 +53,14 @@ export class WEBGLTexture extends Texture {
|
|
|
101
53
|
sampler: WEBGLSampler = undefined; // TODO - currently unused in WebGL. Create dummy sampler?
|
|
102
54
|
view: WEBGLTextureView = undefined; // TODO - currently unused in WebGL. Create dummy view?
|
|
103
55
|
|
|
104
|
-
mipmaps: boolean
|
|
56
|
+
mipmaps: boolean;
|
|
57
|
+
|
|
58
|
+
// Texture type
|
|
59
|
+
/** Whether the internal format is compressed */
|
|
60
|
+
compressed: boolean;
|
|
105
61
|
|
|
106
62
|
/**
|
|
63
|
+
* The WebGL target corresponding to the texture type
|
|
107
64
|
* @note `target` cannot be modified by bind:
|
|
108
65
|
* textures are special because when you first bind them to a target,
|
|
109
66
|
* When you first bind a texture as a GL_TEXTURE_2D, you are saying that this texture is a 2D texture.
|
|
@@ -112,39 +69,23 @@ export class WEBGLTexture extends Texture {
|
|
|
112
69
|
* attempting to bind it as GL_TEXTURE_3D will give rise to a run-time error
|
|
113
70
|
*/
|
|
114
71
|
glTarget: GLTextureTarget;
|
|
115
|
-
|
|
116
|
-
// Texture type
|
|
117
|
-
|
|
118
72
|
/** The WebGL format - essentially channel structure */
|
|
119
73
|
glFormat: GLTexelDataFormat;
|
|
120
74
|
/** The WebGL data format - the type of each channel */
|
|
121
75
|
glType: GLPixelType;
|
|
122
76
|
/** The WebGL constant corresponding to the WebGPU style constant in format */
|
|
123
77
|
glInternalFormat: GL;
|
|
124
|
-
/** Whether the internal format is compressed */
|
|
125
|
-
compressed: boolean;
|
|
126
|
-
|
|
127
|
-
// data;
|
|
128
|
-
// inherited props
|
|
129
|
-
// dimension: ...
|
|
130
|
-
// format: GLTextureTarget;
|
|
131
|
-
// width: number = undefined;
|
|
132
|
-
// height: number = undefined;
|
|
133
|
-
// depth: number = undefined;
|
|
134
78
|
|
|
135
79
|
// state
|
|
136
|
-
/** Texture binding slot */
|
|
80
|
+
/** Texture binding slot - TODO - move to texture view? */
|
|
137
81
|
textureUnit: number = 0;
|
|
138
|
-
/** For automatically updating video */
|
|
139
|
-
_video: {
|
|
140
|
-
video: HTMLVideoElement;
|
|
141
|
-
parameters: any;
|
|
142
|
-
lastTime: number;
|
|
143
|
-
} | null = null;
|
|
144
82
|
|
|
145
83
|
constructor(device: Device, props: TextureProps) {
|
|
146
|
-
|
|
147
|
-
|
|
84
|
+
super(device, props);
|
|
85
|
+
|
|
86
|
+
// Texture base class strips out the data prop, so we need to add it back in
|
|
87
|
+
const propsWithData = {...this.props};
|
|
88
|
+
propsWithData.data = props.data;
|
|
148
89
|
|
|
149
90
|
this.device = device as WebGLDevice;
|
|
150
91
|
this.gl = this.device.gl;
|
|
@@ -153,46 +94,33 @@ export class WEBGLTexture extends Texture {
|
|
|
153
94
|
this.glTarget = getWebGLTextureTarget(this.props.dimension);
|
|
154
95
|
|
|
155
96
|
// The target format of this texture
|
|
156
|
-
const
|
|
157
|
-
this.glInternalFormat =
|
|
158
|
-
this.glFormat =
|
|
159
|
-
this.glType =
|
|
160
|
-
this.compressed =
|
|
161
|
-
|
|
162
|
-
if (
|
|
163
|
-
typeof HTMLVideoElement !== 'undefined' &&
|
|
164
|
-
props.data instanceof HTMLVideoElement &&
|
|
165
|
-
// @ts-expect-error
|
|
166
|
-
props.data.readyState < HTMLVideoElement.HAVE_METADATA
|
|
167
|
-
) {
|
|
168
|
-
const video = props.data;
|
|
169
|
-
this._video = null; // Declare member before the object is sealed
|
|
170
|
-
video.addEventListener('loadeddata', () => this.initialize(props));
|
|
171
|
-
}
|
|
97
|
+
const formatInfo = getTextureFormatWebGL(this.props.format);
|
|
98
|
+
this.glInternalFormat = formatInfo.internalFormat;
|
|
99
|
+
this.glFormat = formatInfo.format;
|
|
100
|
+
this.glType = formatInfo.type;
|
|
101
|
+
this.compressed = formatInfo.compressed;
|
|
102
|
+
this.mipmaps = Boolean(this.props.mipmaps);
|
|
172
103
|
|
|
173
|
-
|
|
174
|
-
// @ts-expect-error
|
|
175
|
-
this.initialize({...this.props, data: props.data});
|
|
104
|
+
this._initialize(propsWithData);
|
|
176
105
|
|
|
177
106
|
Object.seal(this);
|
|
178
107
|
}
|
|
179
108
|
|
|
180
|
-
/**
|
|
181
|
-
* Initialize texture with supplied props
|
|
182
|
-
*/
|
|
109
|
+
/** Initialize texture with supplied props */
|
|
183
110
|
// eslint-disable-next-line max-statements
|
|
184
|
-
|
|
111
|
+
_initialize(propsWithData: TextureProps): void {
|
|
185
112
|
this.handle = this.props.handle || this.gl.createTexture();
|
|
186
|
-
this.device.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
113
|
+
this.device._setWebGLDebugMetadata(this.handle, this, {
|
|
114
|
+
spector: {
|
|
115
|
+
...this.props,
|
|
116
|
+
data: propsWithData.data
|
|
117
|
+
}
|
|
118
|
+
});
|
|
191
119
|
|
|
192
|
-
let {width, height} =
|
|
120
|
+
let {width, height} = propsWithData;
|
|
193
121
|
|
|
194
122
|
if (!width || !height) {
|
|
195
|
-
const textureSize =
|
|
123
|
+
const textureSize = Texture.getTextureDataSize(propsWithData.data);
|
|
196
124
|
width = textureSize?.width || 1;
|
|
197
125
|
height = textureSize?.height || 1;
|
|
198
126
|
}
|
|
@@ -200,72 +128,34 @@ export class WEBGLTexture extends Texture {
|
|
|
200
128
|
// Store opts for accessors
|
|
201
129
|
this.width = width;
|
|
202
130
|
this.height = height;
|
|
203
|
-
this.depth =
|
|
131
|
+
this.depth = propsWithData.depth;
|
|
204
132
|
|
|
205
133
|
// Set texture sampler parameters
|
|
206
|
-
this.setSampler(
|
|
207
|
-
// @ts-ignore
|
|
134
|
+
this.setSampler(propsWithData.sampler);
|
|
135
|
+
// @ts-ignore TODO - fix types
|
|
208
136
|
this.view = new WEBGLTextureView(this.device, {...this.props, texture: this});
|
|
209
137
|
|
|
210
138
|
this.bind();
|
|
211
|
-
|
|
212
|
-
initializeTextureStorage(this.gl, this.mipLevels, this);
|
|
213
|
-
}
|
|
139
|
+
initializeTextureStorage(this.gl, this.mipLevels, this);
|
|
214
140
|
|
|
215
|
-
if (
|
|
141
|
+
if (propsWithData.data) {
|
|
216
142
|
// prettier-ignore
|
|
217
|
-
switch (
|
|
218
|
-
case '1d': this.setTexture1DData(
|
|
219
|
-
case '2d': this.setTexture2DData(
|
|
220
|
-
case '3d': this.setTexture3DData(
|
|
221
|
-
case 'cube': this.setTextureCubeData(
|
|
222
|
-
case '2d-array': this.setTextureArrayData(
|
|
223
|
-
case 'cube-array': this.setTextureCubeArrayData(
|
|
143
|
+
switch (propsWithData.dimension) {
|
|
144
|
+
case '1d': this.setTexture1DData(propsWithData.data); break;
|
|
145
|
+
case '2d': this.setTexture2DData(propsWithData.data); break;
|
|
146
|
+
case '3d': this.setTexture3DData(propsWithData.data); break;
|
|
147
|
+
case 'cube': this.setTextureCubeData(propsWithData.data); break;
|
|
148
|
+
case '2d-array': this.setTextureArrayData(propsWithData.data); break;
|
|
149
|
+
case 'cube-array': this.setTextureCubeArrayData(propsWithData.data); break;
|
|
224
150
|
// @ts-expect-error
|
|
225
|
-
default: throw new Error(
|
|
151
|
+
default: throw new Error(propsWithData.dimension);
|
|
226
152
|
}
|
|
227
153
|
}
|
|
228
154
|
|
|
229
|
-
this.mipmaps = Boolean(props.mipmaps);
|
|
230
|
-
|
|
231
155
|
if (this.mipmaps) {
|
|
232
156
|
this.generateMipmap();
|
|
233
157
|
}
|
|
234
|
-
|
|
235
|
-
// if (isVideo) {
|
|
236
|
-
// this._video = {
|
|
237
|
-
// video: data,
|
|
238
|
-
// // TODO - should we be using the sampler parameters here?
|
|
239
|
-
// parameters: {},
|
|
240
|
-
// // @ts-expect-error HTMLVideoElement.HAVE_CURRENT_DATA is not declared
|
|
241
|
-
// lastTime: data.readyState >= HTMLVideoElement.HAVE_CURRENT_DATA ? data.currentTime : -1
|
|
242
|
-
// };
|
|
243
|
-
// }
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/*
|
|
247
|
-
initializeCube(props?: TextureProps): void {
|
|
248
|
-
const {mipmaps = true} = props; // , parameters = {} as Record<GL, any>} = props;
|
|
249
|
-
|
|
250
|
-
// Store props for accessors
|
|
251
|
-
// this.props = props;
|
|
252
|
-
|
|
253
|
-
// @ts-expect-error
|
|
254
|
-
this.setCubeMapData(props).then(() => {
|
|
255
|
-
// TODO - should genMipmap() be called on the cubemap or on the faces?
|
|
256
|
-
// TODO - without generateMipmap() cube textures do not work at all!!! Why?
|
|
257
|
-
if (mipmaps) {
|
|
258
|
-
this.generateMipmap(props);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
this.setSampler(props.sampler);
|
|
262
|
-
|
|
263
|
-
// v8 compatibility?
|
|
264
|
-
// const {parameters = {} as Record<GL, any>} = props;
|
|
265
|
-
// this._setSamplerParameters(parameters);
|
|
266
|
-
});
|
|
267
158
|
}
|
|
268
|
-
*/
|
|
269
159
|
|
|
270
160
|
override destroy(): void {
|
|
271
161
|
if (this.handle) {
|
|
@@ -277,10 +167,6 @@ export class WEBGLTexture extends Texture {
|
|
|
277
167
|
}
|
|
278
168
|
}
|
|
279
169
|
|
|
280
|
-
override toString(): string {
|
|
281
|
-
return `Texture(${this.id},${this.width}x${this.height})`;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
170
|
createView(props: TextureViewProps): WEBGLTextureView {
|
|
285
171
|
return new WEBGLTextureView(this.device, {...props, texture: this});
|
|
286
172
|
}
|
|
@@ -299,50 +185,89 @@ export class WEBGLTexture extends Texture {
|
|
|
299
185
|
this._setSamplerParameters(parameters);
|
|
300
186
|
}
|
|
301
187
|
|
|
302
|
-
/** Update external texture (video frame or canvas) */
|
|
303
|
-
update(): void {
|
|
304
|
-
log.warn('Texture.update() not implemented');
|
|
305
|
-
// if (this._video) {
|
|
306
|
-
// const {video, parameters, lastTime} = this._video;
|
|
307
|
-
// // @ts-expect-error
|
|
308
|
-
// if (lastTime === video.currentTime || video.readyState < HTMLVideoElement.HAVE_CURRENT_DATA) {
|
|
309
|
-
// return;
|
|
310
|
-
// }
|
|
311
|
-
// this.setSubImageData({
|
|
312
|
-
// data: video,
|
|
313
|
-
// parameters
|
|
314
|
-
// });
|
|
315
|
-
// if (this.mipmaps) {
|
|
316
|
-
// this.generateMipmap();
|
|
317
|
-
// }
|
|
318
|
-
// this._video.lastTime = video.currentTime;
|
|
319
|
-
// }
|
|
320
|
-
}
|
|
321
|
-
|
|
322
188
|
// Call to regenerate mipmaps after modifying texture(s)
|
|
323
|
-
generateMipmap(
|
|
324
|
-
|
|
325
|
-
|
|
189
|
+
generateMipmap(options?: {force?: boolean}): void {
|
|
190
|
+
const isFilterableAndRenderable =
|
|
191
|
+
this.device.isTextureFormatRenderable(this.props.format) &&
|
|
192
|
+
this.device.isTextureFormatFilterable(this.props.format);
|
|
193
|
+
if (!isFilterableAndRenderable) {
|
|
194
|
+
log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)();
|
|
195
|
+
if (!options?.force) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
326
198
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
199
|
+
|
|
200
|
+
try {
|
|
201
|
+
this.gl.bindTexture(this.glTarget, this.handle);
|
|
330
202
|
this.gl.generateMipmap(this.glTarget);
|
|
331
|
-
})
|
|
332
|
-
|
|
203
|
+
} catch (error) {
|
|
204
|
+
log.warn(`Error generating mipmap for ${this}: ${(error as Error).message}`)();
|
|
205
|
+
} finally {
|
|
206
|
+
this.gl.bindTexture(this.glTarget, null);
|
|
207
|
+
}
|
|
333
208
|
}
|
|
334
209
|
|
|
335
210
|
// Image Data Setters
|
|
211
|
+
copyExternalImage(options: {
|
|
212
|
+
image: ExternalImage;
|
|
213
|
+
sourceX?: number;
|
|
214
|
+
sourceY?: number;
|
|
215
|
+
width?: number;
|
|
216
|
+
height?: number;
|
|
217
|
+
depth?: number;
|
|
218
|
+
mipLevel?: number;
|
|
219
|
+
x?: number;
|
|
220
|
+
y?: number;
|
|
221
|
+
z?: number;
|
|
222
|
+
aspect?: 'all' | 'stencil-only' | 'depth-only';
|
|
223
|
+
colorSpace?: 'srgb';
|
|
224
|
+
premultipliedAlpha?: boolean;
|
|
225
|
+
flipY?: boolean;
|
|
226
|
+
}): {width: number; height: number} {
|
|
227
|
+
const size = Texture.getExternalImageSize(options.image);
|
|
228
|
+
const opts = {...Texture.defaultCopyExternalImageOptions, ...size, ...options};
|
|
229
|
+
|
|
230
|
+
const {image, depth, mipLevel, x, y, z, flipY} = opts;
|
|
231
|
+
let {width, height} = opts;
|
|
232
|
+
const {dimension, glTarget, glFormat, glInternalFormat, glType} = this;
|
|
233
|
+
|
|
234
|
+
// WebGL will error if we try to copy outside the bounds of the texture
|
|
235
|
+
width = Math.min(width, this.width - x);
|
|
236
|
+
height = Math.min(height, this.height - y);
|
|
237
|
+
|
|
238
|
+
if (options.sourceX || options.sourceY) {
|
|
239
|
+
// requires copyTexSubImage2D from a framebuffer'
|
|
240
|
+
throw new Error('WebGL does not support sourceX/sourceY)');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
copyExternalImageToMipLevel(this.device.gl, this.handle, image, {
|
|
244
|
+
dimension,
|
|
245
|
+
mipLevel,
|
|
246
|
+
x,
|
|
247
|
+
y,
|
|
248
|
+
z,
|
|
249
|
+
width,
|
|
250
|
+
height,
|
|
251
|
+
depth,
|
|
252
|
+
glFormat,
|
|
253
|
+
glInternalFormat,
|
|
254
|
+
glType,
|
|
255
|
+
glTarget,
|
|
256
|
+
flipY
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
return {width: opts.width, height: opts.height};
|
|
260
|
+
}
|
|
336
261
|
|
|
337
262
|
setTexture1DData(data: Texture1DData): void {
|
|
338
263
|
throw new Error('setTexture1DData not supported in WebGL.');
|
|
339
264
|
}
|
|
340
265
|
|
|
341
266
|
/** Set a simple texture */
|
|
342
|
-
setTexture2DData(lodData: Texture2DData, depth = 0
|
|
267
|
+
setTexture2DData(lodData: Texture2DData, depth = 0): void {
|
|
343
268
|
this.bind();
|
|
344
269
|
|
|
345
|
-
const lodArray = normalizeTextureData(lodData, this);
|
|
270
|
+
const lodArray = Texture.normalizeTextureData(lodData, this);
|
|
346
271
|
|
|
347
272
|
// If the user provides multiple LODs, then automatic mipmap
|
|
348
273
|
// generation generateMipmap() should be disabled to avoid overwriting them.
|
|
@@ -367,7 +292,9 @@ export class WEBGLTexture extends Texture {
|
|
|
367
292
|
throw new Error(this.id);
|
|
368
293
|
}
|
|
369
294
|
if (ArrayBuffer.isView(data)) {
|
|
295
|
+
this.bind();
|
|
370
296
|
copyCPUDataToMipLevel(this.device.gl, data, this);
|
|
297
|
+
this.unbind();
|
|
371
298
|
}
|
|
372
299
|
}
|
|
373
300
|
|
|
@@ -381,9 +308,9 @@ export class WEBGLTexture extends Texture {
|
|
|
381
308
|
if (this.props.dimension !== 'cube') {
|
|
382
309
|
throw new Error(this.id);
|
|
383
310
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
311
|
+
for (const face of Texture.CubeFaces) {
|
|
312
|
+
this.setTextureCubeFaceData(data[face], face);
|
|
313
|
+
}
|
|
387
314
|
}
|
|
388
315
|
|
|
389
316
|
/**
|
|
@@ -414,27 +341,16 @@ export class WEBGLTexture extends Texture {
|
|
|
414
341
|
log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
415
342
|
}
|
|
416
343
|
|
|
417
|
-
|
|
418
|
-
// const glType = GL.UNSIGNED_BYTE;
|
|
419
|
-
// const {width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = this;
|
|
420
|
-
// const {width, height, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = this;
|
|
344
|
+
const faceDepth = Texture.CubeFaces.indexOf(face);
|
|
421
345
|
|
|
422
|
-
this.
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
// this.glInternalFormat,
|
|
431
|
-
// this.glInternalFormat,
|
|
432
|
-
// glType,
|
|
433
|
-
// imageData
|
|
434
|
-
// );
|
|
435
|
-
// }
|
|
436
|
-
// }
|
|
437
|
-
this.unbind();
|
|
346
|
+
this.setTexture2DData(lodData, faceDepth);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
// DEPRECATED METHODS
|
|
350
|
+
|
|
351
|
+
/** Update external texture (video frame or canvas) @deprecated Use ExternalTexture */
|
|
352
|
+
update(): void {
|
|
353
|
+
throw new Error('Texture.update() not implemented. Use ExternalTexture');
|
|
438
354
|
}
|
|
439
355
|
|
|
440
356
|
// INTERNAL METHODS
|
|
@@ -491,7 +407,7 @@ export class WEBGLTexture extends Texture {
|
|
|
491
407
|
* Sets sampler parameters on texture
|
|
492
408
|
*/
|
|
493
409
|
_setSamplerParameters(parameters: GLSamplerParameters): void {
|
|
494
|
-
log.log(1,
|
|
410
|
+
log.log(1, `${this.id} sampler parameters`, this.device.getGLKeys(parameters))();
|
|
495
411
|
|
|
496
412
|
this.gl.bindTexture(this.glTarget, this.handle);
|
|
497
413
|
for (const [pname, pvalue] of Object.entries(parameters)) {
|
|
@@ -529,86 +445,41 @@ export class WEBGLTexture extends Texture {
|
|
|
529
445
|
this.gl.bindTexture(this.glTarget, null);
|
|
530
446
|
}
|
|
531
447
|
|
|
532
|
-
// CLASSIC
|
|
533
|
-
|
|
534
|
-
/*
|
|
535
|
-
setCubeMapData(options: {
|
|
536
|
-
width: number;
|
|
537
|
-
height: number;
|
|
538
|
-
data: Record<GL, Texture2DData> | Record<TextureCubeFace, Texture2DData>;
|
|
539
|
-
format?: any;
|
|
540
|
-
type?: any;
|
|
541
|
-
/** @deprecated Use .data *
|
|
542
|
-
pixels: any;
|
|
543
|
-
}): void {
|
|
544
|
-
const {gl} = this;
|
|
545
|
-
|
|
546
|
-
const {width, height, pixels, data, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = options;
|
|
547
|
-
|
|
548
|
-
// pixel data (imageDataMap) is an Object from Face to Image or Promise.
|
|
549
|
-
// For example:
|
|
550
|
-
// {
|
|
551
|
-
// GL.TEXTURE_CUBE_MAP_POSITIVE_X : Image-or-Promise,
|
|
552
|
-
// GL.TEXTURE_CUBE_MAP_NEGATIVE_X : Image-or-Promise,
|
|
553
|
-
// ... }
|
|
554
|
-
// To provide multiple level-of-details (LODs) this can be Face to Array
|
|
555
|
-
// of Image or Promise, like this
|
|
556
|
-
// {
|
|
557
|
-
// GL.TEXTURE_CUBE_MAP_POSITIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],
|
|
558
|
-
// GL.TEXTURE_CUBE_MAP_NEGATIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],
|
|
559
|
-
// ... }
|
|
560
|
-
|
|
561
|
-
const imageDataMap = this._getImageDataMap(pixels || data);
|
|
562
|
-
|
|
563
|
-
const resolvedFaces = WEBGLTexture.FACES.map(face => {
|
|
564
|
-
const facePixels = imageDataMap[face];
|
|
565
|
-
return Array.isArray(facePixels) ? facePixels : [facePixels];
|
|
566
|
-
});
|
|
567
|
-
this.bind();
|
|
568
|
-
|
|
569
|
-
WEBGLTexture.FACES.forEach((face, index) => {
|
|
570
|
-
if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {
|
|
571
|
-
// If the user provides multiple LODs, then automatic mipmap
|
|
572
|
-
// generation generateMipmap() should be disabled to avoid overwritting them.
|
|
573
|
-
log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
574
|
-
}
|
|
575
|
-
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
576
|
-
// TODO: adjust width & height for LOD!
|
|
577
|
-
if (width && height) {
|
|
578
|
-
gl.texImage2D(face, lodLevel, format, width, height, 0 /* border*, format, type, image);
|
|
579
|
-
} else {
|
|
580
|
-
gl.texImage2D(face, lodLevel, format, format, type, image);
|
|
581
|
-
}
|
|
582
|
-
});
|
|
583
|
-
});
|
|
584
|
-
|
|
585
|
-
this.unbind();
|
|
586
|
-
}
|
|
587
|
-
*/
|
|
588
|
-
|
|
589
448
|
// INTERNAL SETTERS
|
|
590
449
|
|
|
591
450
|
/**
|
|
592
451
|
* Copy a region of data from a CPU memory buffer into this texture.
|
|
593
452
|
* @todo - GLUnpackParameters parameters
|
|
594
453
|
*/
|
|
595
|
-
protected _setMipLevel(
|
|
454
|
+
protected _setMipLevel(
|
|
455
|
+
depth: number,
|
|
456
|
+
mipLevel: number,
|
|
457
|
+
textureData: Texture2DData,
|
|
458
|
+
glTarget: GL = this.glTarget
|
|
459
|
+
) {
|
|
596
460
|
// if (!textureData) {
|
|
597
461
|
// clearMipLevel(this.device.gl, {...this, depth, level});
|
|
598
462
|
// return;
|
|
599
463
|
// }
|
|
600
464
|
|
|
601
465
|
if (Texture.isExternalImage(textureData)) {
|
|
602
|
-
|
|
466
|
+
copyExternalImageToMipLevel(this.device.gl, this.handle, textureData, {
|
|
467
|
+
...this,
|
|
468
|
+
depth,
|
|
469
|
+
mipLevel,
|
|
470
|
+
glTarget,
|
|
471
|
+
flipY: this.props.flipY
|
|
472
|
+
});
|
|
603
473
|
return;
|
|
604
474
|
}
|
|
605
475
|
|
|
606
476
|
// @ts-expect-error
|
|
607
|
-
if (
|
|
477
|
+
if (Texture.isTextureLevelData(textureData)) {
|
|
608
478
|
copyCPUDataToMipLevel(this.device.gl, textureData.data, {
|
|
609
479
|
...this,
|
|
610
480
|
depth,
|
|
611
|
-
|
|
481
|
+
mipLevel,
|
|
482
|
+
glTarget
|
|
612
483
|
});
|
|
613
484
|
return;
|
|
614
485
|
}
|
|
@@ -645,3 +516,60 @@ export class WEBGLTexture extends Texture {
|
|
|
645
516
|
return textureUnit;
|
|
646
517
|
}
|
|
647
518
|
}
|
|
519
|
+
|
|
520
|
+
// TODO - Remove when texture refactor is complete
|
|
521
|
+
|
|
522
|
+
/*
|
|
523
|
+
setCubeMapData(options: {
|
|
524
|
+
width: number;
|
|
525
|
+
height: number;
|
|
526
|
+
data: Record<GL, Texture2DData> | Record<TextureCubeFace, Texture2DData>;
|
|
527
|
+
format?: any;
|
|
528
|
+
type?: any;
|
|
529
|
+
/** @deprecated Use .data *
|
|
530
|
+
pixels: any;
|
|
531
|
+
}): void {
|
|
532
|
+
const {gl} = this;
|
|
533
|
+
|
|
534
|
+
const {width, height, pixels, data, format = GL.RGBA, type = GL.UNSIGNED_BYTE} = options;
|
|
535
|
+
|
|
536
|
+
// pixel data (imageDataMap) is an Object from Face to Image or Promise.
|
|
537
|
+
// For example:
|
|
538
|
+
// {
|
|
539
|
+
// GL.TEXTURE_CUBE_MAP_POSITIVE_X : Image-or-Promise,
|
|
540
|
+
// GL.TEXTURE_CUBE_MAP_NEGATIVE_X : Image-or-Promise,
|
|
541
|
+
// ... }
|
|
542
|
+
// To provide multiple level-of-details (LODs) this can be Face to Array
|
|
543
|
+
// of Image or Promise, like this
|
|
544
|
+
// {
|
|
545
|
+
// GL.TEXTURE_CUBE_MAP_POSITIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],
|
|
546
|
+
// GL.TEXTURE_CUBE_MAP_NEGATIVE_X : [Image-or-Promise-LOD-0, Image-or-Promise-LOD-1],
|
|
547
|
+
// ... }
|
|
548
|
+
|
|
549
|
+
const imageDataMap = this._getImageDataMap(pixels || data);
|
|
550
|
+
|
|
551
|
+
const resolvedFaces = WEBGLTexture.FACES.map(face => {
|
|
552
|
+
const facePixels = imageDataMap[face];
|
|
553
|
+
return Array.isArray(facePixels) ? facePixels : [facePixels];
|
|
554
|
+
});
|
|
555
|
+
this.bind();
|
|
556
|
+
|
|
557
|
+
WEBGLTexture.FACES.forEach((face, index) => {
|
|
558
|
+
if (resolvedFaces[index].length > 1 && this.props.mipmaps !== false) {
|
|
559
|
+
// If the user provides multiple LODs, then automatic mipmap
|
|
560
|
+
// generation generateMipmap() should be disabled to avoid overwritting them.
|
|
561
|
+
log.warn(`${this.id} has mipmap and multiple LODs.`)();
|
|
562
|
+
}
|
|
563
|
+
resolvedFaces[index].forEach((image, lodLevel) => {
|
|
564
|
+
// TODO: adjust width & height for LOD!
|
|
565
|
+
if (width && height) {
|
|
566
|
+
gl.texImage2D(face, lodLevel, format, width, height, 0 /* border*, format, type, image);
|
|
567
|
+
} else {
|
|
568
|
+
gl.texImage2D(face, lodLevel, format, format, type, image);
|
|
569
|
+
}
|
|
570
|
+
});
|
|
571
|
+
});
|
|
572
|
+
|
|
573
|
+
this.unbind();
|
|
574
|
+
}
|
|
575
|
+
*/
|