@antv/g-webgpu 1.7.54 → 1.7.56

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
@@ -6084,13 +6084,11 @@
6084
6084
  this.renderTargetDebugNames = [];
6085
6085
  };
6086
6086
  var RenderGraph = /*#__PURE__*/function () {
6087
- // For scope callbacks.
6088
-
6089
- //#region Resource Creation & Caching
6090
-
6091
6087
  function RenderGraph(device) {
6092
6088
  this.device = void 0;
6089
+ // For scope callbacks.
6093
6090
  this.currentPass = null;
6091
+ //#region Resource Creation & Caching
6094
6092
  this.renderTargetDeadPool = [];
6095
6093
  this.singleSampledTextureDeadPool = [];
6096
6094
  //#endregion
@@ -6742,16 +6740,13 @@
6742
6740
  RenderInstFlags[RenderInstFlags["InheritedFlags"] = 3] = "InheritedFlags";
6743
6741
  })(RenderInstFlags || (RenderInstFlags = {}));
6744
6742
  var RenderInst = /*#__PURE__*/function () {
6745
- // Debugging pointer for whomever wants it...
6746
-
6747
- // Pipeline building.
6748
-
6749
- // Bindings building.
6750
-
6751
6743
  function RenderInst() {
6752
6744
  this.sortKey = 0;
6745
+ // Debugging pointer for whomever wants it...
6753
6746
  this.debug = null;
6747
+ // Pipeline building.
6754
6748
  this.renderPipelineDescriptor = void 0;
6749
+ // Bindings building.
6755
6750
  this.uniformBuffer = void 0;
6756
6751
  this.uniforms = [];
6757
6752
  this.bindingDescriptors = nArray(1, function () {
@@ -8240,22 +8235,6 @@
8240
8235
  */
8241
8236
  var BufferGeometry = /*#__PURE__*/function (_EventEmitter) {
8242
8237
  _inheritsLoose$1(BufferGeometry, _EventEmitter);
8243
- /**
8244
- * 绘制模式
8245
- */
8246
-
8247
- /**
8248
- * 存放 Attribute Buffer 列表
8249
- */
8250
-
8251
- /**
8252
- * 存放 Index Buffer
8253
- */
8254
-
8255
- /**
8256
- * 索引数组
8257
- */
8258
-
8259
8238
  function BufferGeometry(device, props) {
8260
8239
  var _this;
8261
8240
  if (props === void 0) {
@@ -8264,10 +8243,22 @@
8264
8243
  _this = _EventEmitter.call(this) || this;
8265
8244
  _this.device = void 0;
8266
8245
  _this.props = void 0;
8246
+ /**
8247
+ * 绘制模式
8248
+ */
8267
8249
  _this.drawMode = PrimitiveTopology.Triangles;
8250
+ /**
8251
+ * 存放 Attribute Buffer 列表
8252
+ */
8268
8253
  _this.vertexBuffers = [];
8269
8254
  _this.vertices = [];
8255
+ /**
8256
+ * 存放 Index Buffer
8257
+ */
8270
8258
  _this.indexBuffer = void 0;
8259
+ /**
8260
+ * 索引数组
8261
+ */
8271
8262
  _this.indices = void 0;
8272
8263
  _this.inputLayoutDescriptor = {
8273
8264
  vertexBufferDescriptors: [],
@@ -8826,20 +8817,18 @@
8826
8817
  * Instanced mesh
8827
8818
  */
8828
8819
  var Instanced = /*#__PURE__*/function () {
8829
- /**
8830
- * unique ID
8831
- */
8832
-
8833
- /**
8834
- * index in renderer.meshes
8835
- */
8836
-
8837
8820
  function Instanced(renderHelper, texturePool, lightPool) {
8838
8821
  this.renderHelper = void 0;
8839
8822
  this.texturePool = void 0;
8840
8823
  this.lightPool = void 0;
8824
+ /**
8825
+ * unique ID
8826
+ */
8841
8827
  this.id = counter$1++;
8842
8828
  this.renderer = void 0;
8829
+ /**
8830
+ * index in renderer.meshes
8831
+ */
8843
8832
  this.index = -1;
8844
8833
  this.context = void 0;
8845
8834
  /**
@@ -10051,7 +10040,7 @@
10051
10040
  packed.push(x1 - defX + startOffsetX, y1 - defY + startOffsetY, z1, x2 - defX + endOffsetX, y2 - defY + endOffsetY, z2);
10052
10041
  });
10053
10042
  this.geometry.updateVertexBuffer(InstancedLineVertexAttributeBufferIndex.POINT, InstancedLineVertexAttributeLocation.POINTA, startIndex, new Uint8Array(new Float32Array(packed).buffer));
10054
- } else if (name === 'lineDashOffset' || name === 'lineDash') {
10043
+ } else if (name === 'lineDashOffset' || name === 'lineDash' || name === 'isBillboard') {
10055
10044
  var _packed = [];
10056
10045
  objects.forEach(function (object) {
10057
10046
  var totalLength = object.getTotalLength();
@@ -11464,7 +11453,7 @@
11464
11453
  }(Instanced);
11465
11454
  var frag$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\n\nin vec4 v_PickingResult;\nin vec4 v_Color;\nin vec4 v_StrokeColor;\nin vec4 v_StylePacked1;\nin vec4 v_StylePacked2;\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\nvoid main() {\n vec4 u_Color = v_Color;\nvec4 u_StrokeColor = v_StrokeColor;\nfloat u_Opacity = v_StylePacked1.x;\nfloat u_FillOpacity = v_StylePacked1.y;\nfloat u_StrokeOpacity = v_StylePacked1.z;\nfloat u_StrokeWidth = v_StylePacked1.w;\nfloat u_Visible = v_StylePacked2.x;\nvec3 u_PickingColor = v_PickingResult.xyz;\n\nif (u_Visible < 0.5) {\n discard;\n}\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n if (u_IsPicking > 0.5) {\n if (u_PickingColor.x == 0.0 && u_PickingColor.y == 0.0 && u_PickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(u_PickingColor, 1.0);\n } else {\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity;\n }\n}"; // eslint-disable-line
11466
11455
 
11467
- var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec2 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size;\n\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}"; // eslint-disable-line
11456
+ var vert$3 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(location = MODEL_MATRIX0) in vec4 a_ModelMatrix0;\nlayout(location = MODEL_MATRIX1) in vec4 a_ModelMatrix1;\nlayout(location = MODEL_MATRIX2) in vec4 a_ModelMatrix2;\nlayout(location = MODEL_MATRIX3) in vec4 a_ModelMatrix3;\nlayout(location = COLOR) in vec4 a_Color;\nlayout(location = STROKE_COLOR) in vec4 a_StrokeColor;\nlayout(location = PACKED_STYLE1) in vec4 a_StylePacked1;\nlayout(location = PACKED_STYLE2) in vec4 a_StylePacked2;\nlayout(location = PICKING_COLOR) in vec4 a_PickingColor;\n\nout vec4 v_PickingResult;\nout vec4 v_Color;\nout vec4 v_StrokeColor;\nout vec4 v_StylePacked1;\nout vec4 v_StylePacked2;\n\n#define COLOR_SCALE 1. / 255.\nvoid setPickingColor(vec3 pickingColor) {\n v_PickingResult.rgb = pickingColor * COLOR_SCALE;\n}\nvec4 project(vec4 pos, mat4 pm, mat4 vm, mat4 mm) {\n return pm * vm * mm * pos;\n}\n\nlayout(location = POSITION) in vec4 a_Size;\n\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nbool isPerspectiveMatrix(mat4 m) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\n\nvoid main() {\n mat4 u_ModelMatrix = mat4(a_ModelMatrix0, a_ModelMatrix1, a_ModelMatrix2, a_ModelMatrix3);\nvec4 u_StrokeColor = a_StrokeColor;\nfloat u_Opacity = a_StylePacked1.x;\nfloat u_FillOpacity = a_StylePacked1.y;\nfloat u_StrokeOpacity = a_StylePacked1.z;\nfloat u_StrokeWidth = a_StylePacked1.w;\nfloat u_ZIndex = a_PickingColor.w;\nvec2 u_Anchor = a_StylePacked2.yz;\nfloat u_IncreasedLineWidthForHitTesting = a_StylePacked2.w;\n\nsetPickingColor(a_PickingColor.xyz);\n\nv_Color = a_Color;\nv_StrokeColor = a_StrokeColor;\nv_StylePacked1 = a_StylePacked1;\nv_StylePacked2 = a_StylePacked2;\n\n#ifdef CLIPSPACE_NEAR_ZERO\n gl_Position.z = gl_Position.z * 0.5 + 0.5;\n#endif\n\n vec2 offset = (a_Uv - u_Anchor.xy) * a_Size.xy;\n\n bool isPerspective = isPerspectiveMatrix(u_ProjectionMatrix);\n\n float isBillboard = a_Size.w;\n if (isBillboard < 0.5) {\n gl_Position = project(vec4(offset, u_ZIndex, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n } else {\n gl_Position = project(vec4(offset, a_Size.z, 1.0), u_ProjectionMatrix, u_ViewMatrix, u_ModelMatrix);\n }\n\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n}"; // eslint-disable-line
11468
11457
 
11469
11458
  var ImageMesh = /*#__PURE__*/function (_Instanced) {
11470
11459
  _inheritsLoose$1(ImageMesh, _Instanced);
@@ -11504,8 +11493,10 @@
11504
11493
  var offset = i * 4;
11505
11494
  var _image$parsedStyle = image.parsedStyle,
11506
11495
  width = _image$parsedStyle.width,
11507
- height = _image$parsedStyle.height;
11508
- instanced.push(width, height);
11496
+ height = _image$parsedStyle.height,
11497
+ z = _image$parsedStyle.z,
11498
+ isBillboard = _image$parsedStyle.isBillboard;
11499
+ instanced.push(width, height, z, isBillboard ? 1 : 0);
11509
11500
  interleaved.push(0, 0, 1, 0, 1, 1, 0, 1);
11510
11501
  indices.push(0 + offset, 2 + offset, 1 + offset, 0 + offset, 3 + offset, 2 + offset);
11511
11502
  });
@@ -11513,10 +11504,10 @@
11513
11504
  this.geometry.vertexCount = 6;
11514
11505
  this.geometry.setVertexBuffer({
11515
11506
  bufferIndex: VertexAttributeBufferIndex.POSITION,
11516
- byteStride: 4 * 2,
11507
+ byteStride: 4 * 4,
11517
11508
  frequency: VertexBufferFrequency.PerInstance,
11518
11509
  attributes: [{
11519
- format: Format.F32_RG,
11510
+ format: Format.F32_RGBA,
11520
11511
  bufferByteOffset: 4 * 0,
11521
11512
  location: VertexAttributeLocation.POSITION
11522
11513
  }],
@@ -11537,14 +11528,16 @@
11537
11528
  _proto.updateAttribute = function updateAttribute(objects, startIndex, name, value) {
11538
11529
  _Instanced.prototype.updateAttribute.call(this, objects, startIndex, name, value);
11539
11530
  this.updateBatchedAttribute(objects, startIndex, name, value);
11540
- if (name === 'width' || name === 'height') {
11531
+ if (name === 'width' || name === 'height' || name === 'z' || name === 'isBillboard') {
11541
11532
  var packed = [];
11542
11533
  objects.forEach(function (object) {
11543
11534
  var image = object;
11544
11535
  var _image$parsedStyle2 = image.parsedStyle,
11545
11536
  width = _image$parsedStyle2.width,
11546
- height = _image$parsedStyle2.height;
11547
- packed.push(width, height);
11537
+ height = _image$parsedStyle2.height,
11538
+ z = _image$parsedStyle2.z,
11539
+ isBillboard = _image$parsedStyle2.isBillboard;
11540
+ packed.push(width, height, z, isBillboard ? 1 : 0);
11548
11541
  });
11549
11542
  this.geometry.updateVertexBuffer(VertexAttributeBufferIndex.POSITION, VertexAttributeLocation.POSITION, startIndex, new Uint8Array(new Float32Array(packed).buffer));
11550
11543
  } else if (name === 'img') {
@@ -14209,8 +14202,7 @@
14209
14202
  var _this = this;
14210
14203
  var camera = context.camera,
14211
14204
  renderingContext = context.renderingContext,
14212
- renderingService = context.renderingService,
14213
- displayObjectPool = context.displayObjectPool;
14205
+ renderingService = context.renderingService;
14214
14206
  this.context = context;
14215
14207
  var canvas = renderingContext.root.ownerDocument.defaultView;
14216
14208
  var setTransform = function setTransform(object, $el) {
@@ -14234,6 +14226,7 @@
14234
14226
  _this.updateAttribute(name, object);
14235
14227
  });
14236
14228
  setTransform(object, $el);
14229
+ gLite.runtime.nativeHTMLMap.set($el, object);
14237
14230
  }
14238
14231
  };
14239
14232
  var handleUnmounted = function handleUnmounted(e) {
@@ -14242,6 +14235,7 @@
14242
14235
  var $el = _this.getOrCreateEl(object);
14243
14236
  if ($el) {
14244
14237
  $el.remove();
14238
+ gLite.runtime.nativeHTMLMap.delete($el);
14245
14239
  }
14246
14240
  // const existedId = this.getId(object);
14247
14241
  // const $existedElement: HTMLElement | null = this.$camera.querySelector('#' + existedId);
@@ -14278,16 +14272,12 @@
14278
14272
  return _regeneratorRuntime$3().wrap(function _callee$(_context) {
14279
14273
  while (1) switch (_context.prev = _context.next) {
14280
14274
  case 0:
14281
- if (displayObjectPool.getHTMLs().length) {
14282
- // append camera
14283
- _this.$camera = _this.createCamera(camera);
14284
- }
14285
14275
  canvas.addEventListener(gLite.CanvasEvent.RESIZE, handleCanvasResize);
14286
14276
  canvas.addEventListener(gLite.ElementEvent.MOUNTED, handleMounted);
14287
14277
  canvas.addEventListener(gLite.ElementEvent.UNMOUNTED, handleUnmounted);
14288
14278
  canvas.addEventListener(gLite.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
14289
14279
  canvas.addEventListener(gLite.ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
14290
- case 6:
14280
+ case 5:
14291
14281
  case "end":
14292
14282
  return _context.stop();
14293
14283
  }
@@ -16175,10 +16165,6 @@
16175
16165
  }
16176
16166
  var Buffer_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
16177
16167
  _inheritsLoose$5(Buffer_WebGPU, _ResourceBase_WebGPU);
16178
- /**
16179
- * @see https://www.w3.org/TR/webgpu/#gpubuffer
16180
- */
16181
-
16182
16168
  function Buffer_WebGPU(_ref) {
16183
16169
  var _this;
16184
16170
  var id = _ref.id,
@@ -16189,6 +16175,9 @@
16189
16175
  device: device
16190
16176
  }) || this;
16191
16177
  _this.type = ResourceType.Buffer;
16178
+ /**
16179
+ * @see https://www.w3.org/TR/webgpu/#gpubuffer
16180
+ */
16192
16181
  _this.gpuBuffer = void 0;
16193
16182
  _this.size = void 0;
16194
16183
  _this.view = void 0;
@@ -17032,8 +17021,6 @@
17032
17021
  }(ResourceBase_WebGPU);
17033
17022
  var Sampler_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
17034
17023
  _inheritsLoose$5(Sampler_WebGPU, _ResourceBase_WebGPU);
17035
- // @see https://www.w3.org/TR/webgpu/#gpusampler
17036
-
17037
17024
  function Sampler_WebGPU(_ref) {
17038
17025
  var _descriptor$maxAnisot, _descriptor$wrapQ;
17039
17026
  var _this;
@@ -17045,6 +17032,7 @@
17045
17032
  device: device
17046
17033
  }) || this;
17047
17034
  _this.type = ResourceType.Sampler;
17035
+ // @see https://www.w3.org/TR/webgpu/#gpusampler
17048
17036
  _this.gpuSampler = void 0;
17049
17037
  var lodMinClamp = descriptor.minLOD;
17050
17038
  var lodMaxClamp = descriptor.mipFilter === MipFilterMode.NoMip ? descriptor.minLOD : descriptor.maxLOD;
@@ -17114,9 +17102,6 @@
17114
17102
  return Texture_WebGPU;
17115
17103
  }(ResourceBase_WebGPU);
17116
17104
  var Device_WebGPU = /*#__PURE__*/function () {
17117
- // private fullscreenAlphaClear: FullscreenAlphaClear;
17118
- // VendorInfo
17119
-
17120
17105
  function Device_WebGPU(adapter, device, canvas, canvasContext, glsl_compile) {
17121
17106
  this.swapChainWidth = 0;
17122
17107
  this.swapChainHeight = 0;
@@ -17132,6 +17117,8 @@
17132
17117
  this.fallbackTextureCube = void 0;
17133
17118
  this.fallbackSampler = void 0;
17134
17119
  this.featureTextureCompressionBC = false;
17120
+ // private fullscreenAlphaClear: FullscreenAlphaClear;
17121
+ // VendorInfo
17135
17122
  this.platformString = 'WebGPU';
17136
17123
  this.glslVersion = "#version 440";
17137
17124
  this.explicitBindingLocations = true;