@luma.gl/webgl 9.1.0-alpha.9 → 9.1.0-beta.11
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 +1 -0
- 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 -2
- 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 +96 -25
- package/dist/adapter/helpers/webgl-texture-utils.d.ts.map +1 -1
- package/dist/adapter/helpers/webgl-texture-utils.js +225 -236
- 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.js +1 -0
- 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 +68 -73
- 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 +30 -17
- package/dist/adapter/resources/webgl-render-pass.js.map +1 -0
- package/dist/adapter/resources/webgl-render-pipeline.d.ts +2 -4
- package/dist/adapter/resources/webgl-render-pipeline.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-render-pipeline.js +33 -18
- 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 +8 -5
- 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 +32 -20
- package/dist/adapter/resources/webgl-texture.d.ts.map +1 -1
- package/dist/adapter/resources/webgl-texture.js +158 -218
- 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.map +1 -1
- package/dist/adapter/webgl-adapter.js +5 -10
- package/dist/adapter/webgl-adapter.js.map +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts +1 -0
- package/dist/adapter/webgl-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +4 -0
- package/dist/adapter/webgl-canvas-context.js.map +1 -0
- package/dist/adapter/webgl-device.d.ts +11 -14
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +60 -39
- package/dist/adapter/webgl-device.js.map +1 -0
- package/dist/context/debug/spector-types.js +2 -1
- package/dist/context/debug/spector-types.js.map +1 -0
- package/dist/context/debug/spector.d.ts +5 -5
- package/dist/context/debug/spector.d.ts.map +1 -1
- package/dist/context/debug/spector.js +7 -6
- 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.js +1 -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.js +1 -0
- package/dist/context/state-tracker/webgl-state-tracker.js.map +1 -0
- package/dist/context/state-tracker/with-parameters.js +1 -0
- 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 +2217 -2366
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +2098 -2240
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- 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.js +1 -0
- package/dist/utils/uid.js.map +1 -0
- package/package.json +5 -5
- package/src/adapter/converters/device-parameters.ts +3 -3
- 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 -2
- 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 +400 -57
- 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 +77 -83
- package/src/adapter/resources/webgl-render-pass.ts +52 -41
- package/src/adapter/resources/webgl-render-pipeline.ts +44 -21
- package/src/adapter/resources/webgl-shader.ts +8 -6
- package/src/adapter/resources/webgl-texture.ts +183 -250
- package/src/adapter/webgl-adapter.ts +4 -12
- package/src/adapter/webgl-canvas-context.ts +4 -0
- package/src/adapter/webgl-device.ts +100 -72
- package/src/context/debug/spector-types.ts +1 -1
- package/src/context/debug/spector.ts +11 -11
- 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/{classic → deprecated}/accessor.ts +44 -3
- package/src/index.ts +2 -5
- package/src/utils/fill-array.ts +4 -4
- package/src/utils/split-uniforms-and-bindings.ts +3 -3
- 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 -511
- 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 -64
- package/dist/classic/copy-and-blit.d.ts.map +0 -1
- package/dist/classic/copy-and-blit.js +0 -194
- package/dist/classic/format-utils.d.ts.map +0 -1
- package/dist/classic/typed-array-utils.d.ts.map +0 -1
- package/src/adapter/converters/texture-formats.ts +0 -657
- package/src/classic/clear.ts +0 -115
- package/src/classic/copy-and-blit.ts +0 -323
- /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
|
@@ -3,28 +3,16 @@
|
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import type {TypedArray} from '@math.gl/types';
|
|
6
|
-
import type {DeviceProps, DeviceInfo, CanvasContextProps, TextureFormat} from '@luma.gl/core';
|
|
7
|
-
import type {Buffer, Texture, Framebuffer, VertexArray, VertexArrayProps} from '@luma.gl/core';
|
|
8
|
-
import {Device, CanvasContext, log} from '@luma.gl/core';
|
|
9
|
-
import type {GLExtensions} from '@luma.gl/constants';
|
|
10
|
-
import {WebGLStateTracker} from '../context/state-tracker/webgl-state-tracker';
|
|
11
|
-
import {createBrowserContext} from '../context/helpers/create-browser-context';
|
|
12
|
-
import {getDeviceInfo} from './device-helpers/webgl-device-info';
|
|
13
|
-
import {WebGLDeviceFeatures} from './device-helpers/webgl-device-features';
|
|
14
|
-
import {WebGLDeviceLimits} from './device-helpers/webgl-device-limits';
|
|
15
|
-
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
16
|
-
import type {Spector} from '../context/debug/spector-types';
|
|
17
|
-
import {initializeSpectorJS} from '../context/debug/spector';
|
|
18
|
-
import {makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
19
|
-
import {
|
|
20
|
-
isTextureFormatSupported,
|
|
21
|
-
isTextureFormatRenderable,
|
|
22
|
-
isTextureFormatFilterable
|
|
23
|
-
} from './converters/texture-formats';
|
|
24
|
-
import {uid} from '../utils/uid';
|
|
25
|
-
|
|
26
|
-
// WebGL classes
|
|
27
6
|
import type {
|
|
7
|
+
DeviceProps,
|
|
8
|
+
DeviceInfo,
|
|
9
|
+
DeviceTextureFormatCapabilities,
|
|
10
|
+
CanvasContextProps,
|
|
11
|
+
Buffer,
|
|
12
|
+
Texture,
|
|
13
|
+
Framebuffer,
|
|
14
|
+
VertexArray,
|
|
15
|
+
VertexArrayProps,
|
|
28
16
|
BufferProps,
|
|
29
17
|
ShaderProps,
|
|
30
18
|
// Sampler,
|
|
@@ -46,6 +34,19 @@ import type {
|
|
|
46
34
|
TransformFeedbackProps,
|
|
47
35
|
QuerySetProps
|
|
48
36
|
} from '@luma.gl/core';
|
|
37
|
+
import {Device, CanvasContext, log} from '@luma.gl/core';
|
|
38
|
+
import type {GLExtensions} from '@luma.gl/constants';
|
|
39
|
+
import {WebGLStateTracker} from '../context/state-tracker/webgl-state-tracker';
|
|
40
|
+
import {createBrowserContext} from '../context/helpers/create-browser-context';
|
|
41
|
+
import {getDeviceInfo} from './device-helpers/webgl-device-info';
|
|
42
|
+
import {WebGLDeviceFeatures} from './device-helpers/webgl-device-features';
|
|
43
|
+
import {WebGLDeviceLimits} from './device-helpers/webgl-device-limits';
|
|
44
|
+
import {WebGLCanvasContext} from './webgl-canvas-context';
|
|
45
|
+
import type {Spector} from '../context/debug/spector-types';
|
|
46
|
+
import {initializeSpectorJS} from '../context/debug/spector';
|
|
47
|
+
import {makeDebugContext} from '../context/debug/webgl-developer-tools';
|
|
48
|
+
import {getTextureFormatCapabilitiesWebGL} from './converters/webgl-texture-table';
|
|
49
|
+
import {uid} from '../utils/uid';
|
|
49
50
|
|
|
50
51
|
import {WEBGLBuffer} from './resources/webgl-buffer';
|
|
51
52
|
import {WEBGLShader} from './resources/webgl-shader';
|
|
@@ -59,14 +60,13 @@ import {WEBGLVertexArray} from './resources/webgl-vertex-array';
|
|
|
59
60
|
import {WEBGLTransformFeedback} from './resources/webgl-transform-feedback';
|
|
60
61
|
import {WEBGLQuerySet} from './resources/webgl-query-set';
|
|
61
62
|
|
|
62
|
-
import {readPixelsToArray, readPixelsToBuffer} from '
|
|
63
|
+
import {readPixelsToArray, readPixelsToBuffer} from './helpers/webgl-texture-utils';
|
|
63
64
|
import {
|
|
64
65
|
setGLParameters,
|
|
65
66
|
getGLParameters,
|
|
66
67
|
resetGLParameters
|
|
67
68
|
} from '../context/parameters/unified-parameter-api';
|
|
68
69
|
import {withGLParameters} from '../context/state-tracker/with-parameters';
|
|
69
|
-
import {clear} from '../classic/clear';
|
|
70
70
|
import {getWebGLExtension} from '../context/helpers/webgl-extensions';
|
|
71
71
|
|
|
72
72
|
/** WebGPU style Device API for a WebGL context */
|
|
@@ -111,35 +111,62 @@ export class WebGLDevice extends Device {
|
|
|
111
111
|
constructor(props: DeviceProps) {
|
|
112
112
|
super({...props, id: props.id || uid('webgl-device')});
|
|
113
113
|
|
|
114
|
+
// WebGL requires a canvas to be created before creating the context
|
|
115
|
+
if (!props.createCanvasContext) {
|
|
116
|
+
throw new Error('WebGLDevice requires props.createCanvasContext to be set');
|
|
117
|
+
}
|
|
118
|
+
const canvasContextProps = props.createCanvasContext === true ? {} : props.createCanvasContext;
|
|
119
|
+
|
|
114
120
|
// If attaching to an already attached context, return the attached device
|
|
115
121
|
// @ts-expect-error device is attached to context
|
|
116
|
-
|
|
122
|
+
let device: WebGLDevice | undefined = canvasContextProps.canvas?.gl?.device;
|
|
117
123
|
if (device) {
|
|
118
124
|
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
// Create and instrument context
|
|
122
|
-
|
|
123
|
-
this.canvasContext = new WebGLCanvasContext(this, {...props, canvas});
|
|
128
|
+
this.canvasContext = new WebGLCanvasContext(this, canvasContextProps);
|
|
124
129
|
|
|
125
130
|
this.lost = new Promise<{reason: 'destroyed'; message: string}>(resolve => {
|
|
126
131
|
this._resolveContextLost = resolve;
|
|
127
132
|
});
|
|
128
133
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
this.gl = this.handle;
|
|
134
|
+
const webglContextAttributes: WebGLContextAttributes = {...props.webgl};
|
|
135
|
+
// Copy props from CanvasContextProps
|
|
136
|
+
if (canvasContextProps.alphaMode === 'premultiplied') {
|
|
137
|
+
webglContextAttributes.premultipliedAlpha = true;
|
|
138
|
+
}
|
|
139
|
+
if (props.powerPreference !== undefined) {
|
|
140
|
+
webglContextAttributes.powerPreference = props.powerPreference;
|
|
141
|
+
}
|
|
138
142
|
|
|
139
|
-
|
|
143
|
+
const gl = createBrowserContext(
|
|
144
|
+
this.canvasContext.canvas,
|
|
145
|
+
{
|
|
146
|
+
onContextLost: (event: Event) =>
|
|
147
|
+
this._resolveContextLost?.({
|
|
148
|
+
reason: 'destroyed',
|
|
149
|
+
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
150
|
+
}),
|
|
151
|
+
// eslint-disable-next-line no-console
|
|
152
|
+
onContextRestored: (event: Event) => console.log('WebGL context restored')
|
|
153
|
+
},
|
|
154
|
+
webglContextAttributes
|
|
155
|
+
);
|
|
156
|
+
|
|
157
|
+
if (!gl) {
|
|
140
158
|
throw new Error('WebGL context creation failed');
|
|
141
159
|
}
|
|
142
160
|
|
|
161
|
+
// @ts-expect-error device is attached to context
|
|
162
|
+
device = gl.device;
|
|
163
|
+
if (device) {
|
|
164
|
+
throw new Error(`WebGL context already attached to device ${device.id}`);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
this.handle = gl;
|
|
168
|
+
this.gl = gl;
|
|
169
|
+
|
|
143
170
|
// Add spector debug instrumentation to context
|
|
144
171
|
// We need to trust spector integration to decide if spector should be initialized
|
|
145
172
|
// We also run spector instrumentation first, otherwise spector can clobber luma instrumentation.
|
|
@@ -152,8 +179,12 @@ export class WebGLDevice extends Device {
|
|
|
152
179
|
// initialize luma Device fields
|
|
153
180
|
this.info = getDeviceInfo(this.gl, this._extensions);
|
|
154
181
|
this.limits = new WebGLDeviceLimits(this.gl);
|
|
155
|
-
this.features = new WebGLDeviceFeatures(
|
|
156
|
-
|
|
182
|
+
this.features = new WebGLDeviceFeatures(
|
|
183
|
+
this.gl,
|
|
184
|
+
this._extensions,
|
|
185
|
+
this.props._disabledFeatures
|
|
186
|
+
);
|
|
187
|
+
if (this.props._initializeFeatures) {
|
|
157
188
|
this.features.initializeFeatures();
|
|
158
189
|
}
|
|
159
190
|
|
|
@@ -166,11 +197,14 @@ export class WebGLDevice extends Device {
|
|
|
166
197
|
glState.trackState(this.gl, {copyState: false});
|
|
167
198
|
|
|
168
199
|
// DEBUG contexts: Add luma debug instrumentation to the context, force log level to at least 1
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
200
|
+
const debugWebGL = props.debugWebGL || props.debug;
|
|
201
|
+
const traceWebGL = props.debugWebGL;
|
|
202
|
+
if (debugWebGL) {
|
|
203
|
+
this.gl = makeDebugContext(this.gl, {debugWebGL, traceWebGL});
|
|
173
204
|
log.warn('WebGL debug mode activated. Performance reduced.')();
|
|
205
|
+
if (props.debugWebGL) {
|
|
206
|
+
log.level = Math.max(log.level, 1);
|
|
207
|
+
}
|
|
174
208
|
}
|
|
175
209
|
}
|
|
176
210
|
|
|
@@ -184,18 +218,6 @@ export class WebGLDevice extends Device {
|
|
|
184
218
|
return this.gl.isContextLost();
|
|
185
219
|
}
|
|
186
220
|
|
|
187
|
-
isTextureFormatSupported(format: TextureFormat): boolean {
|
|
188
|
-
return isTextureFormatSupported(this.gl, format, this._extensions);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
isTextureFormatFilterable(format: TextureFormat): boolean {
|
|
192
|
-
return isTextureFormatFilterable(this.gl, format, this._extensions);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
isTextureFormatRenderable(format: TextureFormat): boolean {
|
|
196
|
-
return isTextureFormatRenderable(this.gl, format, this._extensions);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
221
|
// IMPLEMENTATION OF ABSTRACT DEVICE
|
|
200
222
|
|
|
201
223
|
createCanvasContext(props?: CanvasContextProps): CanvasContext {
|
|
@@ -203,12 +225,11 @@ export class WebGLDevice extends Device {
|
|
|
203
225
|
}
|
|
204
226
|
|
|
205
227
|
createBuffer(props: BufferProps | ArrayBuffer | ArrayBufferView): WEBGLBuffer {
|
|
206
|
-
const newProps = this.
|
|
228
|
+
const newProps = this._normalizeBufferProps(props);
|
|
207
229
|
return new WEBGLBuffer(this, newProps);
|
|
208
230
|
}
|
|
209
231
|
|
|
210
|
-
|
|
211
|
-
_createTexture(props: TextureProps): Texture {
|
|
232
|
+
createTexture(props: TextureProps): WEBGLTexture {
|
|
212
233
|
return new WEBGLTexture(this, props);
|
|
213
234
|
}
|
|
214
235
|
|
|
@@ -325,20 +346,17 @@ export class WebGLDevice extends Device {
|
|
|
325
346
|
return withGLParameters(this.gl, parameters, func);
|
|
326
347
|
}
|
|
327
348
|
|
|
328
|
-
override clearWebGL(options?: {
|
|
329
|
-
framebuffer?: Framebuffer;
|
|
330
|
-
color?: any;
|
|
331
|
-
depth?: any;
|
|
332
|
-
stencil?: any;
|
|
333
|
-
}): void {
|
|
334
|
-
clear(this, options);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
349
|
override resetWebGL(): void {
|
|
338
350
|
log.warn('WebGLDevice.resetWebGL is deprecated, use only for debugging')();
|
|
339
351
|
resetGLParameters(this.gl);
|
|
340
352
|
}
|
|
341
353
|
|
|
354
|
+
override _getDeviceSpecificTextureFormatCapabilities(
|
|
355
|
+
capabilities: DeviceTextureFormatCapabilities
|
|
356
|
+
): DeviceTextureFormatCapabilities {
|
|
357
|
+
return getTextureFormatCapabilitiesWebGL(this.gl, capabilities, this._extensions);
|
|
358
|
+
}
|
|
359
|
+
|
|
342
360
|
//
|
|
343
361
|
// WebGL-only API (not part of `Device` API)
|
|
344
362
|
//
|
|
@@ -390,18 +408,28 @@ export class WebGLDevice extends Device {
|
|
|
390
408
|
* Be aware that there are some duplicates especially for constants that are 0,
|
|
391
409
|
* so this isn't guaranteed to return the right key in all cases.
|
|
392
410
|
*/
|
|
393
|
-
getGLKey(value: unknown,
|
|
394
|
-
// @ts-ignore expect-error depends on settings
|
|
395
|
-
gl = gl || this.gl2 || this.gl;
|
|
411
|
+
getGLKey(value: unknown, options?: {emptyIfUnknown?: boolean}): string {
|
|
396
412
|
const number = Number(value);
|
|
397
|
-
for (const key in gl) {
|
|
413
|
+
for (const key in this.gl) {
|
|
398
414
|
// @ts-ignore expect-error depends on settings
|
|
399
|
-
if (gl[key] === number) {
|
|
415
|
+
if (this.gl[key] === number) {
|
|
400
416
|
return `GL.${key}`;
|
|
401
417
|
}
|
|
402
418
|
}
|
|
403
419
|
// No constant found. Stringify the value and return it.
|
|
404
|
-
return String(value);
|
|
420
|
+
return options?.emptyIfUnknown ? '' : String(value);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Returns a map with any GL.<KEY> constants mapped to strings, both for keys and values
|
|
425
|
+
*/
|
|
426
|
+
getGLKeys(glParameters: Record<number, unknown>): Record<string, string> {
|
|
427
|
+
const opts = {emptyIfUnknown: true};
|
|
428
|
+
return Object.entries(glParameters).reduce<Record<string, string>>((keys, [key, value]) => {
|
|
429
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
430
|
+
keys[`${key}:${this.getGLKey(key, opts)}`] = `${value}:${this.getGLKey(value, opts)}`;
|
|
431
|
+
return keys;
|
|
432
|
+
}, {});
|
|
405
433
|
}
|
|
406
434
|
|
|
407
435
|
/** Store constants */
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import {log} from '@luma.gl/core';
|
|
6
6
|
import {loadScript} from '../../utils/load-script';
|
|
7
7
|
|
|
8
|
-
import {Spector} from './spector-types';
|
|
8
|
+
import type {Spector} from './spector-types';
|
|
9
9
|
|
|
10
10
|
/** Spector debug initialization options */
|
|
11
11
|
type SpectorProps = {
|
|
12
|
-
/** Whether spector is enabled */
|
|
13
|
-
|
|
12
|
+
/** Whether spector.js is enabled */
|
|
13
|
+
debugSpectorJS?: boolean;
|
|
14
14
|
/** URL to load spector script from. Typically a CDN URL */
|
|
15
|
-
|
|
15
|
+
debugSpectorJSUrl?: string;
|
|
16
16
|
/** Canvas to monitor */
|
|
17
17
|
gl?: WebGL2RenderingContext;
|
|
18
18
|
};
|
|
@@ -29,19 +29,19 @@ declare global {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const DEFAULT_SPECTOR_PROPS: Required<SpectorProps> = {
|
|
32
|
-
|
|
32
|
+
debugSpectorJS: log.get('debug-spectorjs'),
|
|
33
33
|
// https://github.com/BabylonJS/Spector.js#basic-usage
|
|
34
34
|
// https://forum.babylonjs.com/t/spectorcdn-is-temporarily-off/48241
|
|
35
35
|
// spectorUrl: 'https://spectorcdn.babylonjs.com/spector.bundle.js';
|
|
36
|
-
|
|
36
|
+
debugSpectorJSUrl: 'https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js',
|
|
37
37
|
gl: undefined!
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
/** Loads spector from CDN if not already installed */
|
|
41
|
-
export async function loadSpectorJS(props: {
|
|
41
|
+
export async function loadSpectorJS(props: {debugSpectorJSUrl?: string}): Promise<void> {
|
|
42
42
|
if (!globalThis.SPECTOR) {
|
|
43
43
|
try {
|
|
44
|
-
await loadScript(props.
|
|
44
|
+
await loadScript(props.debugSpectorJSUrl || DEFAULT_SPECTOR_PROPS.debugSpectorJSUrl);
|
|
45
45
|
} catch (error) {
|
|
46
46
|
log.warn(String(error));
|
|
47
47
|
}
|
|
@@ -50,14 +50,14 @@ export async function loadSpectorJS(props: {spectorUrl?: string}): Promise<void>
|
|
|
50
50
|
|
|
51
51
|
export function initializeSpectorJS(props: SpectorProps): Spector | null {
|
|
52
52
|
props = {...DEFAULT_SPECTOR_PROPS, ...props};
|
|
53
|
-
if (!props.
|
|
53
|
+
if (!props.debugSpectorJS) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
if (!spector && globalThis.SPECTOR && !globalThis.luma?.spector) {
|
|
58
58
|
log.probe(LOG_LEVEL, 'SPECTOR found and initialized. Start with `luma.spector.displayUI()`')();
|
|
59
|
-
const {Spector} = globalThis.SPECTOR as any;
|
|
60
|
-
spector = new
|
|
59
|
+
const {Spector: SpectorJS} = globalThis.SPECTOR as any;
|
|
60
|
+
spector = new SpectorJS();
|
|
61
61
|
if (globalThis.luma) {
|
|
62
62
|
(globalThis.luma as any).spector = spector;
|
|
63
63
|
}
|
|
@@ -11,18 +11,10 @@ import {loadScript} from '../../utils/load-script';
|
|
|
11
11
|
const WEBGL_DEBUG_CDN_URL = 'https://unpkg.com/webgl-debug@2.0.1/index.js';
|
|
12
12
|
|
|
13
13
|
type DebugContextProps = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
break?: string[];
|
|
14
|
+
debugWebGL?: boolean;
|
|
15
|
+
traceWebGL?: boolean;
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
// const DEFAULT_DEBUG_CONTEXT_PROPS: Required<DebugContextProps> = {
|
|
20
|
-
// debug: true,
|
|
21
|
-
// throwOnError: false,
|
|
22
|
-
// break: [],
|
|
23
|
-
// webgl2: false,
|
|
24
|
-
// }
|
|
25
|
-
|
|
26
18
|
type ContextData = {
|
|
27
19
|
realContext?: WebGL2RenderingContext;
|
|
28
20
|
debugContext?: WebGL2RenderingContext;
|
|
@@ -60,7 +52,7 @@ export function makeDebugContext(
|
|
|
60
52
|
gl: WebGL2RenderingContext,
|
|
61
53
|
props: DebugContextProps = {}
|
|
62
54
|
): WebGL2RenderingContext {
|
|
63
|
-
return props.
|
|
55
|
+
return props.debugWebGL || props.traceWebGL ? getDebugContext(gl, props) : getRealContext(gl);
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
// Returns the real context from either of the real/debug contexts
|
|
@@ -136,9 +128,7 @@ function onGLError(props: DebugContextProps, err, functionName: string, args: an
|
|
|
136
128
|
const message = `${errorMessage} in gl.${functionName}(${functionArgs})`;
|
|
137
129
|
log.error(message)();
|
|
138
130
|
debugger; // eslint-disable-line
|
|
139
|
-
|
|
140
|
-
throw new Error(message);
|
|
141
|
-
}
|
|
131
|
+
// throw new Error(message);
|
|
142
132
|
}
|
|
143
133
|
|
|
144
134
|
// Don't generate function string until it is needed
|
|
@@ -150,29 +140,16 @@ function onValidateGLFunc(
|
|
|
150
140
|
let functionString: string = '';
|
|
151
141
|
if (log.level >= 1) {
|
|
152
142
|
functionString = getFunctionString(functionName, functionArgs);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
// If array of breakpoint strings supplied, check if any of them is contained in current GLEnum function
|
|
157
|
-
if (props.break && props.break.length > 0) {
|
|
158
|
-
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
159
|
-
const isBreakpoint = props.break.every(
|
|
160
|
-
(breakOn: string) => functionString.indexOf(breakOn) !== -1
|
|
161
|
-
);
|
|
162
|
-
if (isBreakpoint) {
|
|
163
|
-
debugger; // eslint-disable-line
|
|
143
|
+
if (props.traceWebGL) {
|
|
144
|
+
log.log(1, functionString)();
|
|
164
145
|
}
|
|
165
146
|
}
|
|
166
147
|
|
|
167
148
|
for (const arg of functionArgs) {
|
|
168
149
|
if (arg === undefined) {
|
|
169
150
|
functionString = functionString || getFunctionString(functionName, functionArgs);
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
log.error(`Undefined argument: ${functionString}`)();
|
|
174
|
-
debugger; // eslint-disable-line
|
|
175
|
-
}
|
|
151
|
+
debugger; // eslint-disable-line
|
|
152
|
+
// throw new Error(`Undefined argument: ${functionString}`);
|
|
176
153
|
}
|
|
177
154
|
}
|
|
178
155
|
}
|
|
@@ -5,37 +5,13 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* ContextProps
|
|
7
7
|
* @param onContextLost
|
|
8
|
-
* @param onContextRestored
|
|
9
|
-
*
|
|
10
|
-
* BROWSER CONTEXT PARAMETERS
|
|
11
|
-
* @param debug Instrument context (at the expense of performance).
|
|
12
|
-
* @param alpha Default render target has an alpha buffer.
|
|
13
|
-
* @param depth Default render target has a depth buffer of at least 16 bits.
|
|
14
|
-
* @param stencil Default render target has a stencil buffer of at least 8 bits.
|
|
15
|
-
* @param antialias Boolean that indicates whether or not to perform anti-aliasing.
|
|
16
|
-
* @param premultipliedAlpha Boolean that indicates that the page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
|
|
17
|
-
* @param preserveDrawingBuffer Default render target buffers will not be automatically cleared and will preserve their values until cleared or overwritten
|
|
18
|
-
* @param failIfMajorPerformanceCaveat Do not create if the system performance is low.
|
|
8
|
+
* @param onContextRestored *
|
|
19
9
|
*/
|
|
20
10
|
type ContextProps = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
antialias?: boolean; // indicates whether or not to perform anti-aliasing.
|
|
26
|
-
depth?: boolean; // indicates that the drawing buffer has a depth buffer of at least 16 bits.
|
|
27
|
-
failIfMajorPerformanceCaveat?: boolean; // indicates if a context will be created if the system performance is low or if no hardware GPU is available.
|
|
28
|
-
powerPreference?: 'default' | 'high-performance' | 'low-power';
|
|
29
|
-
premultipliedAlpha?: boolean; // page compositor will assume the drawing buffer contains colors with pre-multiplied alpha.
|
|
30
|
-
preserveDrawingBuffer?: boolean; // buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
34
|
-
powerPreference: 'high-performance', // After all, most apps are using WebGL for performance reasons
|
|
35
|
-
// eslint-disable-next-line no-console
|
|
36
|
-
onContextLost: () => console.error('WebGL context lost'),
|
|
37
|
-
// eslint-disable-next-line no-console
|
|
38
|
-
onContextRestored: () => console.info('WebGL context restored')
|
|
11
|
+
/** Called when a context is lost */
|
|
12
|
+
onContextLost: (event: Event) => void;
|
|
13
|
+
/** Called when a context is restored */
|
|
14
|
+
onContextRestored: (event: Event) => void;
|
|
39
15
|
};
|
|
40
16
|
|
|
41
17
|
/**
|
|
@@ -45,53 +21,67 @@ const DEFAULT_CONTEXT_PROPS: ContextProps = {
|
|
|
45
21
|
*/
|
|
46
22
|
export function createBrowserContext(
|
|
47
23
|
canvas: HTMLCanvasElement | OffscreenCanvas,
|
|
48
|
-
props: ContextProps
|
|
24
|
+
props: ContextProps,
|
|
25
|
+
webglContextAttributes: WebGLContextAttributes
|
|
49
26
|
): WebGL2RenderingContext {
|
|
50
|
-
props = {...DEFAULT_CONTEXT_PROPS, ...props};
|
|
51
|
-
|
|
52
27
|
// Try to extract any extra information about why context creation failed
|
|
53
|
-
let errorMessage =
|
|
54
|
-
const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);
|
|
55
|
-
canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
56
|
-
|
|
57
|
-
// Create the desired context
|
|
58
|
-
let gl: WebGL2RenderingContext | null = null;
|
|
28
|
+
let errorMessage = '';
|
|
29
|
+
// const onCreateError = error => (errorMessage = error.statusMessage || errorMessage);
|
|
59
30
|
|
|
60
|
-
//
|
|
31
|
+
// Avoid multiple listeners?
|
|
32
|
+
// canvas.removeEventListener('webglcontextcreationerror', onCreateError, false);
|
|
33
|
+
// canvas.addEventListener('webglcontextcreationerror', onCreateError, false);
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
35
|
+
const webglProps: WebGLContextAttributes = {
|
|
36
|
+
preserveDrawingBuffer: true,
|
|
37
|
+
// failIfMajorPerformanceCaveat: true,
|
|
38
|
+
...webglContextAttributes
|
|
39
|
+
};
|
|
64
40
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
// props.failIfMajorPerformanceCaveat = false;
|
|
41
|
+
// Create the desired context
|
|
42
|
+
let gl: WebGL2RenderingContext | null = null;
|
|
68
43
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
// Create a webgl2 context
|
|
45
|
+
gl ||= canvas.getContext('webgl2', webglProps);
|
|
46
|
+
if (webglProps.failIfMajorPerformanceCaveat) {
|
|
47
|
+
errorMessage ||=
|
|
48
|
+
'Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.';
|
|
49
|
+
}
|
|
72
50
|
|
|
73
|
-
//
|
|
74
|
-
|
|
51
|
+
// Creation failed with failIfMajorPerformanceCaveat - Try a Software GPU
|
|
52
|
+
if (!gl && !webglContextAttributes.failIfMajorPerformanceCaveat) {
|
|
53
|
+
webglProps.failIfMajorPerformanceCaveat = false;
|
|
54
|
+
gl = canvas.getContext('webgl2', webglProps);
|
|
55
|
+
// @ts-expect-error
|
|
56
|
+
gl.luma ||= {};
|
|
57
|
+
// @ts-expect-error
|
|
58
|
+
gl.luma.softwareRenderer = true;
|
|
59
|
+
}
|
|
75
60
|
|
|
76
61
|
if (!gl) {
|
|
77
|
-
|
|
62
|
+
gl = canvas.getContext('webgl', {}) as WebGL2RenderingContext;
|
|
63
|
+
if (gl) {
|
|
64
|
+
gl = null;
|
|
65
|
+
errorMessage ||= 'Your browser only supports WebGL1';
|
|
66
|
+
}
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);
|
|
84
|
-
}
|
|
85
|
-
if (props.onContextRestored) {
|
|
86
|
-
// Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
|
|
87
|
-
const {onContextRestored} = props;
|
|
88
|
-
canvas.addEventListener(
|
|
89
|
-
'webglcontextrestored',
|
|
90
|
-
(event: Event) => onContextRestored(event),
|
|
91
|
-
false
|
|
92
|
-
);
|
|
69
|
+
if (!gl) {
|
|
70
|
+
errorMessage ||= 'Your browser does not support WebGL';
|
|
71
|
+
throw new Error(`Failed to create WebGL context: ${errorMessage}`);
|
|
93
72
|
}
|
|
94
73
|
|
|
74
|
+
// Carefully extract and wrap callbacks to prevent addEventListener from rebinding them.
|
|
75
|
+
const {onContextLost, onContextRestored} = props;
|
|
76
|
+
canvas.addEventListener('webglcontextlost', (event: Event) => onContextLost(event), false);
|
|
77
|
+
canvas.addEventListener(
|
|
78
|
+
'webglcontextrestored',
|
|
79
|
+
(event: Event) => onContextRestored(event),
|
|
80
|
+
false
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// @ts-expect-error
|
|
84
|
+
gl.luma ||= {};
|
|
95
85
|
return gl;
|
|
96
86
|
}
|
|
97
87
|
|
|
@@ -412,9 +412,9 @@ export const GL_HOOKED_SETTERS = {
|
|
|
412
412
|
update({
|
|
413
413
|
[pname]: value
|
|
414
414
|
}),
|
|
415
|
-
hint: (update: UpdateFunc, pname: GL,
|
|
415
|
+
hint: (update: UpdateFunc, pname: GL, value: GL) =>
|
|
416
416
|
update({
|
|
417
|
-
[pname]:
|
|
417
|
+
[pname]: value
|
|
418
418
|
}),
|
|
419
419
|
|
|
420
420
|
// SPECIFIC SETTERS
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
// Copyright (c) vis.gl contributors
|
|
4
4
|
|
|
5
|
-
import {Buffer} from '@luma.gl/core';
|
|
6
|
-
import {GL} from '@luma.gl/constants';
|
|
7
|
-
import {
|
|
5
|
+
import {Buffer, log} from '@luma.gl/core';
|
|
6
|
+
import {GL, GLDataType, GLPixelType} from '@luma.gl/constants';
|
|
7
|
+
import {TypedArrayConstructor} from '@math.gl/types';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Attribute descriptor object
|
|
@@ -81,6 +81,7 @@ export class Accessor implements AccessorObject {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
constructor(...accessors: AccessorObject[]) {
|
|
84
|
+
log.warn('Accessor will be removed in next minor release');
|
|
84
85
|
accessors.forEach(accessor => this._assign(accessor)); // Merge in sequence
|
|
85
86
|
Object.freeze(this);
|
|
86
87
|
}
|
|
@@ -180,5 +181,45 @@ export class Accessor implements AccessorObject {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Converts GL constant to corresponding TYPED ARRAY
|
|
186
|
+
* Used to auto deduce gl parameter types
|
|
187
|
+
* @deprecated Use getTypedArrayFromDataType
|
|
188
|
+
* @param glType
|
|
189
|
+
* @param param1
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
// eslint-disable-next-line complexity
|
|
193
|
+
function getTypedArrayFromGLType(
|
|
194
|
+
glType: GLDataType | GLPixelType,
|
|
195
|
+
options?: {
|
|
196
|
+
clamped?: boolean;
|
|
197
|
+
}
|
|
198
|
+
): TypedArrayConstructor {
|
|
199
|
+
const {clamped = true} = options || {};
|
|
200
|
+
// Sorted in some order of likelihood to reduce amount of comparisons
|
|
201
|
+
switch (glType) {
|
|
202
|
+
case GL.FLOAT:
|
|
203
|
+
return Float32Array;
|
|
204
|
+
case GL.UNSIGNED_SHORT:
|
|
205
|
+
case GL.UNSIGNED_SHORT_5_6_5:
|
|
206
|
+
case GL.UNSIGNED_SHORT_4_4_4_4:
|
|
207
|
+
case GL.UNSIGNED_SHORT_5_5_5_1:
|
|
208
|
+
return Uint16Array;
|
|
209
|
+
case GL.UNSIGNED_INT:
|
|
210
|
+
return Uint32Array;
|
|
211
|
+
case GL.UNSIGNED_BYTE:
|
|
212
|
+
return clamped ? Uint8ClampedArray : Uint8Array;
|
|
213
|
+
case GL.BYTE:
|
|
214
|
+
return Int8Array;
|
|
215
|
+
case GL.SHORT:
|
|
216
|
+
return Int16Array;
|
|
217
|
+
case GL.INT:
|
|
218
|
+
return Int32Array;
|
|
219
|
+
default:
|
|
220
|
+
throw new Error('Failed to deduce typed array type from GL constant');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
183
224
|
// TEST EXPORTS
|
|
184
225
|
export {DEFAULT_ACCESSOR_VALUES};
|
package/src/index.ts
CHANGED
|
@@ -38,7 +38,7 @@ export {WEBGLVertexArray} from './adapter/resources/webgl-vertex-array';
|
|
|
38
38
|
export {WEBGLTransformFeedback} from './adapter/resources/webgl-transform-feedback';
|
|
39
39
|
|
|
40
40
|
// WebGL adapter classes
|
|
41
|
-
export {Accessor} from './
|
|
41
|
+
export {Accessor} from './deprecated/accessor';
|
|
42
42
|
export type {AccessorObject} from './types';
|
|
43
43
|
|
|
44
44
|
// Unified parameter API
|
|
@@ -46,12 +46,9 @@ export type {AccessorObject} from './types';
|
|
|
46
46
|
export {setDeviceParameters, withDeviceParameters} from './adapter/converters/device-parameters';
|
|
47
47
|
|
|
48
48
|
// HELPERS - EXPERIMENTAL
|
|
49
|
-
export {
|
|
49
|
+
export {getShaderLayoutFromGLSL} from './adapter/helpers/get-shader-layout';
|
|
50
50
|
export {WebGLStateTracker} from './context/state-tracker/webgl-state-tracker';
|
|
51
51
|
|
|
52
|
-
// TEST EXPORTS
|
|
53
|
-
export {TEXTURE_FORMATS as _TEXTURE_FORMATS} from './adapter/converters/texture-formats';
|
|
54
|
-
|
|
55
52
|
// DEPRECATED TEST EXPORTS
|
|
56
53
|
export {
|
|
57
54
|
resetGLParameters,
|