@luma.gl/webgl 9.0.0-alpha.25 → 9.0.0-alpha.26
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-canvas-context.d.ts.map +1 -1
- package/dist/adapter/webgl-canvas-context.js +1 -0
- package/dist/adapter/webgl-canvas-context.js.map +1 -1
- package/dist/classic/copy-and-blit.d.ts +17 -0
- package/dist/classic/copy-and-blit.d.ts.map +1 -1
- package/dist/classic/copy-and-blit.js +67 -1
- package/dist/classic/copy-and-blit.js.map +1 -1
- package/dist/dist.dev.js +655 -570
- package/dist/index.cjs +648 -554
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist.min.js +22 -22
- package/package.json +5 -5
- package/src/adapter/webgl-canvas-context.ts +2 -1
- package/src/classic/copy-and-blit.ts +120 -0
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/webgl",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.26",
|
|
4
4
|
"description": "WebGL2 adapter for the luma.gl API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@babel/runtime": "^7.0.0",
|
|
47
|
-
"@luma.gl/api": "9.0.0-alpha.
|
|
48
|
-
"@luma.gl/constants": "9.0.0-alpha.
|
|
47
|
+
"@luma.gl/api": "9.0.0-alpha.26",
|
|
48
|
+
"@luma.gl/constants": "9.0.0-alpha.26",
|
|
49
49
|
"@probe.gl/env": "^4.0.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@luma.gl/test-utils": "9.0.0-alpha.
|
|
52
|
+
"@luma.gl/test-utils": "9.0.0-alpha.26"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "e255f78c1c0a4555808c6e9282bcecb6accd147b"
|
|
55
55
|
}
|
|
@@ -52,6 +52,7 @@ export class WebGLCanvasContext extends CanvasContext {
|
|
|
52
52
|
resize(options?: {width?: number; height?: number; useDevicePixels?: boolean | number}): void {
|
|
53
53
|
// Resize browser context .
|
|
54
54
|
if (this.canvas) {
|
|
55
|
+
const devicePixelRatio = this.getDevicePixelRatio(options?.useDevicePixels);
|
|
55
56
|
this.setDevicePixelRatio(devicePixelRatio, options);
|
|
56
57
|
return;
|
|
57
58
|
}
|
|
@@ -64,7 +65,7 @@ export class WebGLCanvasContext extends CanvasContext {
|
|
|
64
65
|
}
|
|
65
66
|
|
|
66
67
|
commit() {
|
|
67
|
-
// gl.commit was ultimately removed from standard??
|
|
68
|
+
// gl.commit was ultimately removed from the WebGL standard??
|
|
68
69
|
// if (this.offScreen && this.gl.commit) {
|
|
69
70
|
// // @ts-expect-error gl.commit is not officially part of WebGLRenderingContext
|
|
70
71
|
// this.gl.commit();
|
|
@@ -80,6 +80,7 @@ export function readPixelsToArray(
|
|
|
80
80
|
/**
|
|
81
81
|
* Copies data from a Framebuffer or a Texture object into a Buffer object.
|
|
82
82
|
* NOTE: doesn't wait for copy to be complete, it programs GPU to perform a DMA transffer.
|
|
83
|
+
* @deprecated Use CommandEncoder
|
|
83
84
|
* @param source
|
|
84
85
|
* @param options
|
|
85
86
|
*/
|
|
@@ -141,6 +142,125 @@ export function readPixelsToBuffer(
|
|
|
141
142
|
return target;
|
|
142
143
|
}
|
|
143
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Copy a rectangle from a Framebuffer or Texture object into a texture (at an offset)
|
|
147
|
+
* @deprecated Use CommandEncoder
|
|
148
|
+
*/
|
|
149
|
+
// eslint-disable-next-line complexity, max-statements
|
|
150
|
+
export function copyToTexture(
|
|
151
|
+
source: Framebuffer | Texture,
|
|
152
|
+
target: Texture | GL,
|
|
153
|
+
options?: {
|
|
154
|
+
sourceX?: number;
|
|
155
|
+
sourceY?: number;
|
|
156
|
+
|
|
157
|
+
targetX?: number;
|
|
158
|
+
targetY?: number;
|
|
159
|
+
targetZ?: number;
|
|
160
|
+
targetMipmaplevel?: number;
|
|
161
|
+
targetInternalFormat?: number;
|
|
162
|
+
|
|
163
|
+
width?: number; // defaults to target width
|
|
164
|
+
height?: number; // defaults to target height
|
|
165
|
+
}
|
|
166
|
+
): Texture {
|
|
167
|
+
const {
|
|
168
|
+
sourceX = 0,
|
|
169
|
+
sourceY = 0,
|
|
170
|
+
// attachment = GL.COLOR_ATTACHMENT0, // TODO - support gl.readBuffer
|
|
171
|
+
targetMipmaplevel = 0,
|
|
172
|
+
targetInternalFormat = GL.RGBA
|
|
173
|
+
} = options || {};
|
|
174
|
+
let {
|
|
175
|
+
targetX,
|
|
176
|
+
targetY,
|
|
177
|
+
targetZ,
|
|
178
|
+
width, // defaults to target width
|
|
179
|
+
height // defaults to target height
|
|
180
|
+
} = options || {};
|
|
181
|
+
|
|
182
|
+
const {framebuffer, deleteFramebuffer} = getFramebuffer(source);
|
|
183
|
+
assert(framebuffer);
|
|
184
|
+
const webglFramebuffer = framebuffer as WEBGLFramebuffer;
|
|
185
|
+
const {device, handle} = webglFramebuffer;
|
|
186
|
+
const isSubCopy =
|
|
187
|
+
typeof targetX !== 'undefined' ||
|
|
188
|
+
typeof targetY !== 'undefined' ||
|
|
189
|
+
typeof targetZ !== 'undefined';
|
|
190
|
+
targetX = targetX || 0;
|
|
191
|
+
targetY = targetY || 0;
|
|
192
|
+
targetZ = targetZ || 0;
|
|
193
|
+
const prevHandle = device.gl.bindFramebuffer(GL.FRAMEBUFFER, handle);
|
|
194
|
+
// TODO - support gl.readBuffer (WebGL2 only)
|
|
195
|
+
// const prevBuffer = gl.readBuffer(attachment);
|
|
196
|
+
assert(target);
|
|
197
|
+
let texture = null;
|
|
198
|
+
let textureTarget: GL;
|
|
199
|
+
if (target instanceof Texture) {
|
|
200
|
+
texture = target;
|
|
201
|
+
width = Number.isFinite(width) ? width : texture.width;
|
|
202
|
+
height = Number.isFinite(height) ? height : texture.height;
|
|
203
|
+
texture.bind(0);
|
|
204
|
+
textureTarget = texture.target;
|
|
205
|
+
} else {
|
|
206
|
+
textureTarget = target;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (!isSubCopy) {
|
|
210
|
+
device.gl.copyTexImage2D(
|
|
211
|
+
textureTarget,
|
|
212
|
+
targetMipmaplevel,
|
|
213
|
+
targetInternalFormat,
|
|
214
|
+
sourceX,
|
|
215
|
+
sourceY,
|
|
216
|
+
width,
|
|
217
|
+
height,
|
|
218
|
+
0 /* border must be 0 */
|
|
219
|
+
);
|
|
220
|
+
} else {
|
|
221
|
+
switch (textureTarget) {
|
|
222
|
+
case GL.TEXTURE_2D:
|
|
223
|
+
case GL.TEXTURE_CUBE_MAP:
|
|
224
|
+
device.gl.copyTexSubImage2D(
|
|
225
|
+
textureTarget,
|
|
226
|
+
targetMipmaplevel,
|
|
227
|
+
targetX,
|
|
228
|
+
targetY,
|
|
229
|
+
sourceX,
|
|
230
|
+
sourceY,
|
|
231
|
+
width,
|
|
232
|
+
height
|
|
233
|
+
);
|
|
234
|
+
break;
|
|
235
|
+
case GL.TEXTURE_2D_ARRAY:
|
|
236
|
+
case GL.TEXTURE_3D:
|
|
237
|
+
device.assertWebGL2();
|
|
238
|
+
device.gl2.copyTexSubImage3D(
|
|
239
|
+
textureTarget,
|
|
240
|
+
targetMipmaplevel,
|
|
241
|
+
targetX,
|
|
242
|
+
targetY,
|
|
243
|
+
targetZ,
|
|
244
|
+
sourceX,
|
|
245
|
+
sourceY,
|
|
246
|
+
width,
|
|
247
|
+
height
|
|
248
|
+
);
|
|
249
|
+
break;
|
|
250
|
+
default:
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (texture) {
|
|
254
|
+
texture.unbind();
|
|
255
|
+
}
|
|
256
|
+
// @ts-expect-error
|
|
257
|
+
gl.bindFramebuffer(GL.FRAMEBUFFER, prevHandle || null);
|
|
258
|
+
if (deleteFramebuffer) {
|
|
259
|
+
framebuffer.destroy();
|
|
260
|
+
}
|
|
261
|
+
return texture;
|
|
262
|
+
}
|
|
263
|
+
|
|
144
264
|
function getFramebuffer(source: Texture | Framebuffer): {
|
|
145
265
|
framebuffer: Framebuffer;
|
|
146
266
|
deleteFramebuffer: boolean;
|
package/src/index.ts
CHANGED
|
@@ -81,4 +81,4 @@ export {TEXTURE_FORMATS as _TEXTURE_FORMATS} from './adapter/converters/texture-
|
|
|
81
81
|
|
|
82
82
|
// DEPRECATED EXPORTS
|
|
83
83
|
export {clear} from './classic/clear';
|
|
84
|
-
export {readPixelsToBuffer, readPixelsToArray} from './classic/copy-and-blit';
|
|
84
|
+
export {readPixelsToBuffer, readPixelsToArray, copyToTexture} from './classic/copy-and-blit';
|