@antv/g-webgpu 1.7.68 → 1.7.69

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.umd.js CHANGED
@@ -11278,6 +11278,7 @@
11278
11278
  _this = _Instanced.call.apply(_Instanced, [this].concat(args)) || this;
11279
11279
  _this.glyphManager = new GlyphManager();
11280
11280
  _this.packedBufferObjectMap = new WeakMap();
11281
+ _this.tmpMat4 = create();
11281
11282
  return _this;
11282
11283
  }
11283
11284
  var _proto = TextMesh.prototype;
@@ -11485,24 +11486,94 @@
11485
11486
  for (var i = 0; i < end - start; i += bytes) {
11486
11487
  sliced[i + bytes - 1] = renderOrder * RENDER_ORDER_SCALE;
11487
11488
  }
11488
- this.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / byteStride, new Uint8Array(sliced.buffer));
11489
- if (this.material) {
11490
- this.material.programDirty = true;
11491
- this.material.geometryDirty = true;
11492
- }
11489
+ this.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / bytes, new Uint8Array(sliced.buffer));
11493
11490
  };
11494
11491
  _proto.updateAttribute = function updateAttribute(objects, startIndex, name, value) {
11495
- if (name === 'text' || name === 'fontFamily' || name === 'fontSize' || name === 'fontWeight' || name === 'fontStyle' || name === 'fontVariant' || name === 'textBaseline' || name === 'letterSpacing' || name === 'wordWrapWidth' || name === 'lineHeight' || name === 'wordWrap' || name === 'textAlign' || name === 'modelMatrix' || name === 'visibility' || name === 'dx' || name === 'dy') {
11492
+ var _this3 = this;
11493
+ if (name === 'text' || name === 'fontFamily' || name === 'fontSize' || name === 'fontWeight' || name === 'fontStyle' || name === 'fontVariant' || name === 'textBaseline' || name === 'letterSpacing' || name === 'wordWrapWidth' || name === 'lineHeight' || name === 'wordWrap' || name === 'textAlign' || name === 'visibility' || name === 'dx' || name === 'dy') {
11496
11494
  this.material.programDirty = true;
11497
11495
  this.material.geometryDirty = true;
11498
11496
  // need re-upload SDF texture
11499
11497
  this.material.textureDirty = true;
11500
- } else if (name === 'fill' || name === 'fillOpacity' || name === 'stroke' || name === 'strokeOpacity' || name === 'opacity' || name === 'lineWidth' || name === 'pointerEvents') {
11501
- this.material.geometryDirty = true;
11498
+ } else if (name === 'modelMatrix' || name === 'fill' || name === 'fillOpacity' || name === 'stroke' || name === 'strokeOpacity' || name === 'opacity' || name === 'lineWidth' || name === 'pointerEvents') {
11499
+ var vertice = this.geometry.vertices[TextVertexAttributeBufferIndex.INSTANCED];
11500
+ var byteStride = this.geometry.inputLayoutDescriptor.vertexBufferDescriptors[TextVertexAttributeBufferIndex.INSTANCED].byteStride;
11501
+ var bytes = byteStride / 4;
11502
+ objects.forEach(function (object) {
11503
+ var _object$renderable3D;
11504
+ var _object$parsedStyle4 = object.parsedStyle,
11505
+ fill = _object$parsedStyle4.fill,
11506
+ stroke = _object$parsedStyle4.stroke,
11507
+ opacity = _object$parsedStyle4.opacity,
11508
+ fillOpacity = _object$parsedStyle4.fillOpacity,
11509
+ strokeOpacity = _object$parsedStyle4.strokeOpacity,
11510
+ lineWidth = _object$parsedStyle4.lineWidth,
11511
+ visibility = _object$parsedStyle4.visibility,
11512
+ isBillboard = _object$parsedStyle4.isBillboard,
11513
+ sizeAttenuation = _object$parsedStyle4.sizeAttenuation;
11514
+ var fillColor = [0, 0, 0, 0];
11515
+ if (gLite.isCSSRGB(fill)) {
11516
+ fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
11517
+ }
11518
+ var strokeColor = [0, 0, 0, 0];
11519
+ if (gLite.isCSSRGB(stroke)) {
11520
+ strokeColor = [Number(stroke.r) / 255, Number(stroke.g) / 255, Number(stroke.b) / 255, Number(stroke.alpha)];
11521
+ }
11522
+ var encodedPickingColor = object.isInteractive() && (
11523
+ // @ts-ignore
11524
+ (_object$renderable3D = object.renderable3D) === null || _object$renderable3D === void 0 ? void 0 : _object$renderable3D.encodedPickingColor) || [0, 0, 0];
11525
+ var modelMatrix = name === 'modelMatrix' ? copy(_this3.tmpMat4, object.getWorldTransform()) : null;
11526
+ var _this3$packedBufferOb = _this3.packedBufferObjectMap.get(object),
11527
+ start = _this3$packedBufferOb[0],
11528
+ end = _this3$packedBufferOb[1];
11529
+ var sliced = vertice.slice(start, end);
11530
+ for (var i = 0; i < end - start; i += bytes) {
11531
+ if (name === 'modelMatrix') {
11532
+ sliced[i + 0] = modelMatrix[0];
11533
+ sliced[i + 1] = modelMatrix[1];
11534
+ sliced[i + 2] = modelMatrix[2];
11535
+ sliced[i + 3] = modelMatrix[3];
11536
+ sliced[i + 4] = modelMatrix[4];
11537
+ sliced[i + 5] = modelMatrix[5];
11538
+ sliced[i + 6] = modelMatrix[6];
11539
+ sliced[i + 7] = modelMatrix[7];
11540
+ sliced[i + 8] = modelMatrix[8];
11541
+ sliced[i + 9] = modelMatrix[9];
11542
+ sliced[i + 10] = modelMatrix[10];
11543
+ sliced[i + 11] = modelMatrix[11];
11544
+ sliced[i + 12] = modelMatrix[12];
11545
+ sliced[i + 13] = modelMatrix[13];
11546
+ sliced[i + 14] = modelMatrix[14];
11547
+ sliced[i + 15] = modelMatrix[15];
11548
+ } else if (name === 'fill') {
11549
+ sliced[i + 16] = fillColor[0];
11550
+ sliced[i + 17] = fillColor[1];
11551
+ sliced[i + 18] = fillColor[2];
11552
+ sliced[i + 19] = fillColor[3];
11553
+ } else if (name === 'stroke') {
11554
+ sliced[i + 20] = strokeColor[0];
11555
+ sliced[i + 21] = strokeColor[1];
11556
+ sliced[i + 22] = strokeColor[2];
11557
+ sliced[i + 23] = strokeColor[3];
11558
+ }
11559
+ sliced[i + 24] = opacity;
11560
+ sliced[i + 25] = fillOpacity;
11561
+ sliced[i + 26] = strokeOpacity;
11562
+ sliced[i + 27] = lineWidth;
11563
+ sliced[i + 28] = visibility === 'visible' ? 1 : 0;
11564
+ sliced[i + 29] = isBillboard ? 1 : 0;
11565
+ sliced[i + 30] = sizeAttenuation ? 1 : 0;
11566
+ sliced[i + 31] = 0;
11567
+ sliced[i + 32] = encodedPickingColor[0];
11568
+ sliced[i + 33] = encodedPickingColor[1];
11569
+ sliced[i + 34] = encodedPickingColor[2];
11570
+ }
11571
+ _this3.geometry.updateVertexBuffer(TextVertexAttributeBufferIndex.INSTANCED, VertexAttributeLocation.MODEL_MATRIX0, start / bytes, new Uint8Array(sliced.buffer));
11572
+ });
11502
11573
  }
11503
11574
  };
11504
11575
  _proto.buildTextBuffers = function buildTextBuffers(_ref) {
11505
- var _object$renderable3D;
11576
+ var _object$renderable3D2;
11506
11577
  var object = _ref.object,
11507
11578
  lines = _ref.lines,
11508
11579
  fontStack = _ref.fontStack,
@@ -11512,17 +11583,17 @@
11512
11583
  offsetY = _ref.offsetY,
11513
11584
  glyphAtlas = _ref.glyphAtlas,
11514
11585
  indicesOffset = _ref.indicesOffset;
11515
- var _object$parsedStyle4 = object.parsedStyle,
11516
- textAlign = _object$parsedStyle4.textAlign,
11517
- fill = _object$parsedStyle4.fill,
11518
- stroke = _object$parsedStyle4.stroke,
11519
- opacity = _object$parsedStyle4.opacity,
11520
- fillOpacity = _object$parsedStyle4.fillOpacity,
11521
- strokeOpacity = _object$parsedStyle4.strokeOpacity,
11522
- lineWidth = _object$parsedStyle4.lineWidth,
11523
- visibility = _object$parsedStyle4.visibility,
11524
- isBillboard = _object$parsedStyle4.isBillboard,
11525
- sizeAttenuation = _object$parsedStyle4.sizeAttenuation;
11586
+ var _object$parsedStyle5 = object.parsedStyle,
11587
+ textAlign = _object$parsedStyle5.textAlign,
11588
+ fill = _object$parsedStyle5.fill,
11589
+ stroke = _object$parsedStyle5.stroke,
11590
+ opacity = _object$parsedStyle5.opacity,
11591
+ fillOpacity = _object$parsedStyle5.fillOpacity,
11592
+ strokeOpacity = _object$parsedStyle5.strokeOpacity,
11593
+ lineWidth = _object$parsedStyle5.lineWidth,
11594
+ visibility = _object$parsedStyle5.visibility,
11595
+ isBillboard = _object$parsedStyle5.isBillboard,
11596
+ sizeAttenuation = _object$parsedStyle5.sizeAttenuation;
11526
11597
  var fillColor = [0, 0, 0, 0];
11527
11598
  if (gLite.isCSSRGB(fill)) {
11528
11599
  fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
@@ -11533,8 +11604,8 @@
11533
11604
  }
11534
11605
  var encodedPickingColor = object.isInteractive() && (
11535
11606
  // @ts-ignore
11536
- (_object$renderable3D = object.renderable3D) === null || _object$renderable3D === void 0 ? void 0 : _object$renderable3D.encodedPickingColor) || [0, 0, 0];
11537
- var modelMatrix = copy(create(), object.getWorldTransform());
11607
+ (_object$renderable3D2 = object.renderable3D) === null || _object$renderable3D2 === void 0 ? void 0 : _object$renderable3D2.encodedPickingColor) || [0, 0, 0];
11608
+ var modelMatrix = copy(this.tmpMat4, object.getWorldTransform());
11538
11609
  var charPackedBuffer = [];
11539
11610
  var charUVOffsetBuffer = [];
11540
11611
  var indexBuffer = [];