@luma.gl/webgl 9.0.3 → 9.0.4

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/index.cjs CHANGED
@@ -1619,9 +1619,9 @@ function setDeviceParameters(device, parameters) {
1619
1619
  const extensions = webglDevice.getExtension("WEBGL_polygon_mode");
1620
1620
  const ext = extensions.WEBGL_polygon_mode;
1621
1621
  if (parameters.polygonMode) {
1622
- const mode = map("polygonMode", parameters.provokingVertex, {
1622
+ const mode = map("polygonMode", parameters.polygonMode, {
1623
1623
  fill: 6914,
1624
- lint: 6913
1624
+ line: 6913
1625
1625
  });
1626
1626
  ext == null ? void 0 : ext.polygonModeWEBGL(1028, mode);
1627
1627
  ext == null ? void 0 : ext.polygonModeWEBGL(1029, mode);
@@ -1741,7 +1741,12 @@ function convertBlendFactorToFunction(parameter, value) {
1741
1741
  "src-alpha": 770,
1742
1742
  "one-minus-src-alpha": 771,
1743
1743
  "dst-alpha": 772,
1744
- "one-minus-dst-alpha": 773
1744
+ "one-minus-dst-alpha": 773,
1745
+ "src-alpha-saturated": 776,
1746
+ "constant-color": 32769,
1747
+ "one-minus-constant-color": 32770,
1748
+ "constant-alpha": 32771,
1749
+ "one-minus-constant-alpha": 32772
1745
1750
  });
1746
1751
  }
1747
1752
  function message(parameter, value) {
@@ -2618,7 +2623,7 @@ var WEBGLFramebuffer = class extends import_core10.Framebuffer {
2618
2623
  if (!isDefaultFramebuffer) {
2619
2624
  device.setSpectorMetadata(this.handle, { id: this.props.id, props: this.props });
2620
2625
  this.autoCreateAttachmentTextures();
2621
- this.gl.bindFramebuffer(36160, this.handle);
2626
+ const prevHandle = this.gl.bindFramebuffer(36160, this.handle);
2622
2627
  for (let i = 0; i < this.colorAttachments.length; ++i) {
2623
2628
  const attachment = this.colorAttachments[i];
2624
2629
  const attachmentPoint = 36064 + i;
@@ -2635,7 +2640,7 @@ var WEBGLFramebuffer = class extends import_core10.Framebuffer {
2635
2640
  throw new Error(`Framebuffer ${_getFrameBufferStatus(status)}`);
2636
2641
  }
2637
2642
  }
2638
- this.gl.bindFramebuffer(36160, null);
2643
+ this.gl.bindFramebuffer(36160, prevHandle);
2639
2644
  }
2640
2645
  }
2641
2646
  /** destroys any auto created resources etc. */
@@ -4255,6 +4260,7 @@ function _copyTextureToBuffer(device, options) {
4255
4260
  throw new Error("not implemented");
4256
4261
  }
4257
4262
  const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
4263
+ let prevHandle;
4258
4264
  try {
4259
4265
  const webglBuffer = destination;
4260
4266
  const sourceWidth = width || framebuffer.width;
@@ -4263,11 +4269,13 @@ function _copyTextureToBuffer(device, options) {
4263
4269
  const sourceFormat = sourceParams.dataFormat;
4264
4270
  const sourceType = sourceParams.type;
4265
4271
  device.gl.bindBuffer(35051, webglBuffer.handle);
4266
- device.gl.bindFramebuffer(36160, framebuffer.handle);
4272
+ prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);
4267
4273
  device.gl.readPixels(origin[0], origin[1], sourceWidth, sourceHeight, sourceFormat, sourceType, byteOffset);
4268
4274
  } finally {
4269
4275
  device.gl.bindBuffer(35051, null);
4270
- device.gl.bindFramebuffer(36160, null);
4276
+ if (prevHandle !== void 0) {
4277
+ device.gl.bindFramebuffer(36160, prevHandle);
4278
+ }
4271
4279
  if (destroyFramebuffer) {
4272
4280
  framebuffer.destroy();
4273
4281
  }
@@ -4277,12 +4285,14 @@ function _copyTextureToTexture(device, options) {
4277
4285
  const {
4278
4286
  /** Texture to copy to/from. */
4279
4287
  source,
4280
- /** Mip-map level of the texture to copy to/from. (Default 0) */
4281
- // mipLevel = 0,
4288
+ /** Mip-map level of the texture to copy to (Default 0) */
4289
+ destinationMipLevel = 0,
4282
4290
  /** Defines which aspects of the texture to copy to/from. */
4283
4291
  // aspect = 'all',
4284
- /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to/from. */
4292
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy from. */
4285
4293
  origin = [0, 0],
4294
+ /** Defines the origin of the copy - the minimum corner of the texture sub-region to copy to. */
4295
+ destinationOrigin = [0, 0],
4286
4296
  /** Texture to copy to/from. */
4287
4297
  destination
4288
4298
  /** Mip-map level of the texture to copy to/from. (Default 0) */
@@ -4294,15 +4304,13 @@ function _copyTextureToTexture(device, options) {
4294
4304
  } = options;
4295
4305
  let {
4296
4306
  width = options.destination.width,
4297
- height = options.destination.width
4307
+ height = options.destination.height
4298
4308
  // depthOrArrayLayers = 0
4299
4309
  } = options;
4300
- const destinationMipmaplevel = 0;
4301
- const destinationInternalFormat = 6408;
4302
4310
  const { framebuffer, destroyFramebuffer } = getFramebuffer(source);
4303
4311
  const [sourceX, sourceY] = origin;
4304
- const isSubCopy = false;
4305
- device.gl.bindFramebuffer(36160, framebuffer.handle);
4312
+ const [destinationX, destinationY, destinationZ] = destinationOrigin;
4313
+ const prevHandle = device.gl.bindFramebuffer(36160, framebuffer.handle);
4306
4314
  let texture = null;
4307
4315
  let textureTarget;
4308
4316
  if (destination instanceof WEBGLTexture) {
@@ -4310,31 +4318,28 @@ function _copyTextureToTexture(device, options) {
4310
4318
  width = Number.isFinite(width) ? width : texture.width;
4311
4319
  height = Number.isFinite(height) ? height : texture.height;
4312
4320
  texture.bind(0);
4313
- textureTarget = texture.destination;
4314
- } else {
4315
- throw new Error("whoops");
4316
- }
4317
- if (!isSubCopy) {
4318
- device.gl.copyTexImage2D(
4319
- textureTarget,
4320
- destinationMipmaplevel,
4321
- destinationInternalFormat,
4322
- sourceX,
4323
- sourceY,
4324
- width,
4325
- height,
4326
- 0
4327
- /* border must be 0 */
4328
- );
4321
+ textureTarget = texture.target;
4329
4322
  } else {
4323
+ throw new Error("invalid destination");
4324
+ }
4325
+ switch (textureTarget) {
4326
+ case 3553:
4327
+ case 34067:
4328
+ device.gl.copyTexSubImage2D(textureTarget, destinationMipLevel, destinationX, destinationY, sourceX, sourceY, width, height);
4329
+ break;
4330
+ case 35866:
4331
+ case 32879:
4332
+ device.gl.copyTexSubImage3D(textureTarget, destinationMipLevel, destinationX, destinationY, destinationZ, sourceX, sourceY, width, height);
4333
+ break;
4334
+ default:
4330
4335
  }
4331
4336
  if (texture) {
4332
4337
  texture.unbind();
4333
4338
  }
4339
+ device.gl.bindFramebuffer(36160, prevHandle);
4334
4340
  if (destroyFramebuffer) {
4335
4341
  framebuffer.destroy();
4336
4342
  }
4337
- return texture;
4338
4343
  }
4339
4344
  function getFramebuffer(source) {
4340
4345
  if (source instanceof import_core19.Texture) {