@luma.gl/webgl 9.1.0-beta.11 → 9.1.0-beta.12
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/webgl-adapter.d.ts +2 -1
- package/dist/adapter/webgl-adapter.d.ts.map +1 -1
- package/dist/adapter/webgl-adapter.js +8 -2
- package/dist/adapter/webgl-adapter.js.map +1 -1
- package/dist/adapter/webgl-device.d.ts.map +1 -1
- package/dist/adapter/webgl-device.js +14 -9
- package/dist/adapter/webgl-device.js.map +1 -1
- package/dist/dist.dev.js +11 -4
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +11 -4
- package/dist/index.cjs.map +2 -2
- package/package.json +3 -3
- package/src/adapter/webgl-adapter.ts +10 -3
- package/src/adapter/webgl-device.ts +21 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.1.0-beta.
|
|
3
|
+
"version": "9.1.0-beta.12",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl core API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"@luma.gl/core": "^9.1.0-alpha.1"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@luma.gl/constants": "9.1.0-beta.
|
|
46
|
+
"@luma.gl/constants": "9.1.0-beta.12",
|
|
47
47
|
"@math.gl/types": "^4.1.0",
|
|
48
48
|
"@probe.gl/env": "^4.0.8"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "7559423456495eeac8828002f48ddbe3d8ceeff0"
|
|
51
51
|
}
|
|
@@ -36,7 +36,8 @@ export class WebGLAdapter extends Adapter {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Get a device instance from a GL context
|
|
39
|
-
* Creates
|
|
39
|
+
* Creates a WebGLCanvasContext against the contexts canvas
|
|
40
|
+
* @note autoResize will be disabled, assuming that whoever created the external context will be handling resizes.
|
|
40
41
|
* @param gl
|
|
41
42
|
* @returns
|
|
42
43
|
*/
|
|
@@ -52,7 +53,13 @@ export class WebGLAdapter extends Adapter {
|
|
|
52
53
|
if (!isWebGL(gl)) {
|
|
53
54
|
throw new Error('Invalid WebGL2RenderingContext');
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
|
|
57
|
+
// We create a new device using the provided WebGL context and its canvas
|
|
58
|
+
// Assume that whoever created the external context will be handling resizes.
|
|
59
|
+
return new WebGLDevice({
|
|
60
|
+
_handle: gl,
|
|
61
|
+
createCanvasContext: {canvas: gl.canvas, autoResize: false}
|
|
62
|
+
});
|
|
56
63
|
}
|
|
57
64
|
|
|
58
65
|
async create(props: DeviceProps = {}): Promise<WebGLDevice> {
|
|
@@ -94,7 +101,7 @@ ${device.info.vendor}, ${device.info.renderer} for canvas: ${device.canvasContex
|
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
/** Check if supplied parameter is a WebGL2RenderingContext */
|
|
97
|
-
function isWebGL(gl: any):
|
|
104
|
+
function isWebGL(gl: any): gl is WebGL2RenderingContext {
|
|
98
105
|
if (typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext) {
|
|
99
106
|
return true;
|
|
100
107
|
}
|
|
@@ -140,19 +140,24 @@ export class WebGLDevice extends Device {
|
|
|
140
140
|
webglContextAttributes.powerPreference = props.powerPreference;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
143
|
+
// Check if we should attach to an externally created context or create a new context
|
|
144
|
+
const externalGLContext = this.props._handle as WebGL2RenderingContext | null;
|
|
145
|
+
|
|
146
|
+
const gl =
|
|
147
|
+
externalGLContext ||
|
|
148
|
+
createBrowserContext(
|
|
149
|
+
this.canvasContext.canvas,
|
|
150
|
+
{
|
|
151
|
+
onContextLost: (event: Event) =>
|
|
152
|
+
this._resolveContextLost?.({
|
|
153
|
+
reason: 'destroyed',
|
|
154
|
+
message: 'Entered sleep mode, or too many apps or browser tabs are using the GPU.'
|
|
155
|
+
}),
|
|
156
|
+
// eslint-disable-next-line no-console
|
|
157
|
+
onContextRestored: (event: Event) => console.log('WebGL context restored')
|
|
158
|
+
},
|
|
159
|
+
webglContextAttributes
|
|
160
|
+
);
|
|
156
161
|
|
|
157
162
|
if (!gl) {
|
|
158
163
|
throw new Error('WebGL context creation failed');
|
|
@@ -188,7 +193,9 @@ export class WebGLDevice extends Device {
|
|
|
188
193
|
this.features.initializeFeatures();
|
|
189
194
|
}
|
|
190
195
|
|
|
191
|
-
|
|
196
|
+
if (canvasContextProps.autoResize !== false) {
|
|
197
|
+
this.canvasContext.resize();
|
|
198
|
+
}
|
|
192
199
|
|
|
193
200
|
// Install context state tracking
|
|
194
201
|
const glState = new WebGLStateTracker(this.gl, {
|