@antv/g-webgpu 1.7.31 → 1.7.33
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.umd.js +175 -31
- package/dist/index.umd.min.js +1 -1
- package/package.json +9 -8
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
|
5
5
|
import * as HTMLRenderer from '@antv/g-plugin-html-renderer';
|
|
6
6
|
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
7
7
|
export { DomInteraction, DeviceRenderer, WebGPUDevice, HTMLRenderer };
|
|
8
|
-
|
|
8
|
+
type WebGPURendererConfig = RendererConfig;
|
|
9
9
|
export declare class Renderer extends AbstractRenderer {
|
|
10
10
|
constructor(config?: Partial<WebGPURendererConfig>);
|
|
11
11
|
}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAEtE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAE7D,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAG7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,CAAC;AAEtE,KAAK,oBAAoB,GAAG,cAAc,CAAC;AAE3C,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;CAWnD"}
|
package/dist/index.umd.js
CHANGED
|
@@ -698,31 +698,32 @@
|
|
|
698
698
|
// delegate iterator, or by modifying context.method and context.arg,
|
|
699
699
|
// setting context.delegate to null, and returning the ContinueSentinel.
|
|
700
700
|
function maybeInvokeDelegate(delegate, context) {
|
|
701
|
-
var
|
|
701
|
+
var methodName = context.method;
|
|
702
|
+
var method = delegate.iterator[methodName];
|
|
702
703
|
if (method === undefined$1) {
|
|
703
704
|
// A .throw or .return when the delegate iterator has no .throw
|
|
704
|
-
// method always
|
|
705
|
+
// method, or a missing .next mehtod, always terminate the
|
|
706
|
+
// yield* loop.
|
|
705
707
|
context.delegate = null;
|
|
706
708
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
maybeInvokeDelegate(delegate, context);
|
|
709
|
+
// Note: ["return"] must be used for ES3 parsing compatibility.
|
|
710
|
+
if (methodName === "throw" && delegate.iterator["return"]) {
|
|
711
|
+
// If the delegate iterator has a return method, give it a
|
|
712
|
+
// chance to clean up.
|
|
713
|
+
context.method = "return";
|
|
714
|
+
context.arg = undefined$1;
|
|
715
|
+
maybeInvokeDelegate(delegate, context);
|
|
715
716
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
717
|
+
if (context.method === "throw") {
|
|
718
|
+
// If maybeInvokeDelegate(context) changed context.method from
|
|
719
|
+
// "return" to "throw", let that override the TypeError below.
|
|
720
|
+
return ContinueSentinel;
|
|
721
721
|
}
|
|
722
|
-
|
|
722
|
+
}
|
|
723
|
+
if (methodName !== "return") {
|
|
723
724
|
context.method = "throw";
|
|
724
725
|
context.arg = new TypeError(
|
|
725
|
-
"The iterator does not provide a '
|
|
726
|
+
"The iterator does not provide a '" + methodName + "' method");
|
|
726
727
|
}
|
|
727
728
|
|
|
728
729
|
return ContinueSentinel;
|
|
@@ -3981,10 +3982,10 @@
|
|
|
3981
3982
|
}
|
|
3982
3983
|
function getFormatSamplerKind(fmt) {
|
|
3983
3984
|
var flags = getFormatFlags(fmt);
|
|
3984
|
-
if (
|
|
3985
|
+
if (flags & FormatFlags.Depth) {
|
|
3985
3986
|
return SamplerFormatKind.Depth;
|
|
3986
3987
|
}
|
|
3987
|
-
if (
|
|
3988
|
+
if (flags & FormatFlags.Normalized) {
|
|
3988
3989
|
return SamplerFormatKind.Float;
|
|
3989
3990
|
}
|
|
3990
3991
|
var typeFlags = getFormatTypeFlags(fmt);
|
|
@@ -6226,10 +6227,7 @@
|
|
|
6226
6227
|
};
|
|
6227
6228
|
return SingleSampledTexture;
|
|
6228
6229
|
}();
|
|
6229
|
-
var _Symbol$species;
|
|
6230
|
-
_Symbol$species = Symbol.species;
|
|
6231
6230
|
var GraphImpl = function GraphImpl() {
|
|
6232
|
-
this[_Symbol$species] = void 0;
|
|
6233
6231
|
this.renderTargetDescriptions = [];
|
|
6234
6232
|
this.resolveTextureRenderTargetIDs = [];
|
|
6235
6233
|
this.passes = [];
|
|
@@ -7288,7 +7286,7 @@
|
|
|
7288
7286
|
var gfxPipeline = cache.createRenderPipeline(this.renderPipelineDescriptor);
|
|
7289
7287
|
var pipelineReady = device.pipelineQueryReady(gfxPipeline);
|
|
7290
7288
|
if (!pipelineReady) {
|
|
7291
|
-
if (
|
|
7289
|
+
if (this.flags & RenderInstFlags.AllowSkippingIfPipelineNotReady) {
|
|
7292
7290
|
return false;
|
|
7293
7291
|
}
|
|
7294
7292
|
device.pipelineForceReady(gfxPipeline);
|
|
@@ -11965,8 +11963,9 @@
|
|
|
11965
11963
|
if (!this.textMetricsCache[fontStack][char]) {
|
|
11966
11964
|
// 使用 mapbox/tiny-sdf 中的 context
|
|
11967
11965
|
// @see https://stackoverflow.com/questions/46126565/how-to-get-font-glyphs-metrics-details-in-javascript
|
|
11966
|
+
this.textMetricsCache[fontStack][char] =
|
|
11968
11967
|
// @ts-ignore
|
|
11969
|
-
|
|
11968
|
+
sdfGenerator.ctx.measureText(char).width;
|
|
11970
11969
|
}
|
|
11971
11970
|
// use sdf 2.x @see https://github.com/mapbox/tiny-sdf
|
|
11972
11971
|
var _sdfGenerator$draw = sdfGenerator.draw(char),
|
|
@@ -12911,7 +12910,8 @@
|
|
|
12911
12910
|
};
|
|
12912
12911
|
_proto.getOrCreatePattern = function getOrCreatePattern(pattern, instance, callback) {
|
|
12913
12912
|
var image = pattern.image,
|
|
12914
|
-
repetition = pattern.repetition
|
|
12913
|
+
repetition = pattern.repetition,
|
|
12914
|
+
transform = pattern.transform;
|
|
12915
12915
|
var _instance$getGeometry2 = instance.getGeometryBounds(),
|
|
12916
12916
|
halfExtents = _instance$getGeometry2.halfExtents;
|
|
12917
12917
|
var width = halfExtents[0] * 2 || 1;
|
|
@@ -12930,6 +12930,18 @@
|
|
|
12930
12930
|
src = image;
|
|
12931
12931
|
}
|
|
12932
12932
|
var canvasPattern = src && context.createPattern(src, repetition);
|
|
12933
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
|
|
12934
|
+
if (transform) {
|
|
12935
|
+
var mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
|
|
12936
|
+
canvasPattern.setTransform({
|
|
12937
|
+
a: mat[0],
|
|
12938
|
+
b: mat[1],
|
|
12939
|
+
c: mat[4],
|
|
12940
|
+
d: mat[5],
|
|
12941
|
+
e: mat[12],
|
|
12942
|
+
f: mat[13]
|
|
12943
|
+
});
|
|
12944
|
+
}
|
|
12933
12945
|
context.fillStyle = canvasPattern;
|
|
12934
12946
|
context.fillRect(0, 0, width, height);
|
|
12935
12947
|
};
|
|
@@ -14857,6 +14869,111 @@
|
|
|
14857
14869
|
};
|
|
14858
14870
|
return _setPrototypeOf$4(o, p);
|
|
14859
14871
|
}
|
|
14872
|
+
|
|
14873
|
+
/**
|
|
14874
|
+
* Common utilities
|
|
14875
|
+
* @module glMatrix
|
|
14876
|
+
*/
|
|
14877
|
+
var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
14878
|
+
if (!Math.hypot) Math.hypot = function () {
|
|
14879
|
+
var y = 0,
|
|
14880
|
+
i = arguments.length;
|
|
14881
|
+
while (i--) {
|
|
14882
|
+
y += arguments[i] * arguments[i];
|
|
14883
|
+
}
|
|
14884
|
+
return Math.sqrt(y);
|
|
14885
|
+
};
|
|
14886
|
+
|
|
14887
|
+
/**
|
|
14888
|
+
* 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
|
|
14889
|
+
* @module mat4
|
|
14890
|
+
*/
|
|
14891
|
+
|
|
14892
|
+
/**
|
|
14893
|
+
* Creates a new identity mat4
|
|
14894
|
+
*
|
|
14895
|
+
* @returns {mat4} a new 4x4 matrix
|
|
14896
|
+
*/
|
|
14897
|
+
|
|
14898
|
+
function create$3() {
|
|
14899
|
+
var out = new ARRAY_TYPE$1(16);
|
|
14900
|
+
if (ARRAY_TYPE$1 != Float32Array) {
|
|
14901
|
+
out[1] = 0;
|
|
14902
|
+
out[2] = 0;
|
|
14903
|
+
out[3] = 0;
|
|
14904
|
+
out[4] = 0;
|
|
14905
|
+
out[6] = 0;
|
|
14906
|
+
out[7] = 0;
|
|
14907
|
+
out[8] = 0;
|
|
14908
|
+
out[9] = 0;
|
|
14909
|
+
out[11] = 0;
|
|
14910
|
+
out[12] = 0;
|
|
14911
|
+
out[13] = 0;
|
|
14912
|
+
out[14] = 0;
|
|
14913
|
+
}
|
|
14914
|
+
out[0] = 1;
|
|
14915
|
+
out[5] = 1;
|
|
14916
|
+
out[10] = 1;
|
|
14917
|
+
out[15] = 1;
|
|
14918
|
+
return out;
|
|
14919
|
+
}
|
|
14920
|
+
/**
|
|
14921
|
+
* Set a mat4 to the identity matrix
|
|
14922
|
+
*
|
|
14923
|
+
* @param {mat4} out the receiving matrix
|
|
14924
|
+
* @returns {mat4} out
|
|
14925
|
+
*/
|
|
14926
|
+
|
|
14927
|
+
function identity$1(out) {
|
|
14928
|
+
out[0] = 1;
|
|
14929
|
+
out[1] = 0;
|
|
14930
|
+
out[2] = 0;
|
|
14931
|
+
out[3] = 0;
|
|
14932
|
+
out[4] = 0;
|
|
14933
|
+
out[5] = 1;
|
|
14934
|
+
out[6] = 0;
|
|
14935
|
+
out[7] = 0;
|
|
14936
|
+
out[8] = 0;
|
|
14937
|
+
out[9] = 0;
|
|
14938
|
+
out[10] = 1;
|
|
14939
|
+
out[11] = 0;
|
|
14940
|
+
out[12] = 0;
|
|
14941
|
+
out[13] = 0;
|
|
14942
|
+
out[14] = 0;
|
|
14943
|
+
out[15] = 1;
|
|
14944
|
+
return out;
|
|
14945
|
+
}
|
|
14946
|
+
/**
|
|
14947
|
+
* Scales the mat4 by the dimensions in the given vec3 not using vectorization
|
|
14948
|
+
*
|
|
14949
|
+
* @param {mat4} out the receiving matrix
|
|
14950
|
+
* @param {ReadonlyMat4} a the matrix to scale
|
|
14951
|
+
* @param {ReadonlyVec3} v the vec3 to scale the matrix by
|
|
14952
|
+
* @returns {mat4} out
|
|
14953
|
+
**/
|
|
14954
|
+
|
|
14955
|
+
function scale(out, a, v) {
|
|
14956
|
+
var x = v[0],
|
|
14957
|
+
y = v[1],
|
|
14958
|
+
z = v[2];
|
|
14959
|
+
out[0] = a[0] * x;
|
|
14960
|
+
out[1] = a[1] * x;
|
|
14961
|
+
out[2] = a[2] * x;
|
|
14962
|
+
out[3] = a[3] * x;
|
|
14963
|
+
out[4] = a[4] * y;
|
|
14964
|
+
out[5] = a[5] * y;
|
|
14965
|
+
out[6] = a[6] * y;
|
|
14966
|
+
out[7] = a[7] * y;
|
|
14967
|
+
out[8] = a[8] * z;
|
|
14968
|
+
out[9] = a[9] * z;
|
|
14969
|
+
out[10] = a[10] * z;
|
|
14970
|
+
out[11] = a[11] * z;
|
|
14971
|
+
out[12] = a[12];
|
|
14972
|
+
out[13] = a[13];
|
|
14973
|
+
out[14] = a[14];
|
|
14974
|
+
out[15] = a[15];
|
|
14975
|
+
return out;
|
|
14976
|
+
}
|
|
14860
14977
|
var ImagePool = /*#__PURE__*/function () {
|
|
14861
14978
|
function ImagePool(canvasConfig) {
|
|
14862
14979
|
this.canvasConfig = void 0;
|
|
@@ -14907,22 +15024,47 @@
|
|
|
14907
15024
|
}
|
|
14908
15025
|
});
|
|
14909
15026
|
};
|
|
14910
|
-
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
|
|
15027
|
+
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, $offscreenCanvas, dpr, callback) {
|
|
14911
15028
|
var patternKey = this.generatePatternKey(pattern);
|
|
14912
15029
|
if (patternKey && this.patternCache[patternKey]) {
|
|
14913
15030
|
return this.patternCache[patternKey];
|
|
14914
15031
|
}
|
|
14915
15032
|
var image = pattern.image,
|
|
14916
|
-
repetition = pattern.repetition
|
|
15033
|
+
repetition = pattern.repetition,
|
|
15034
|
+
transform = pattern.transform;
|
|
14917
15035
|
var src;
|
|
15036
|
+
var needScaleWithDPR = false;
|
|
14918
15037
|
// Image URL
|
|
14919
15038
|
if (isString(image)) {
|
|
14920
15039
|
src = this.getImageSync(image, callback);
|
|
15040
|
+
} else if ($offscreenCanvas) {
|
|
15041
|
+
src = $offscreenCanvas;
|
|
15042
|
+
needScaleWithDPR = true;
|
|
14921
15043
|
} else {
|
|
14922
15044
|
src = image;
|
|
14923
15045
|
}
|
|
14924
15046
|
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
14925
15047
|
var canvasPattern = src && context.createPattern(src, repetition);
|
|
15048
|
+
if (canvasPattern) {
|
|
15049
|
+
var mat;
|
|
15050
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasPattern/setTransform
|
|
15051
|
+
if (transform) {
|
|
15052
|
+
mat = gLite.parsedTransformToMat4(gLite.parseTransform(transform));
|
|
15053
|
+
} else {
|
|
15054
|
+
mat = identity$1(create$3());
|
|
15055
|
+
}
|
|
15056
|
+
if (needScaleWithDPR) {
|
|
15057
|
+
scale(mat, mat, [1 / dpr, 1 / dpr, 1]);
|
|
15058
|
+
}
|
|
15059
|
+
canvasPattern.setTransform({
|
|
15060
|
+
a: mat[0],
|
|
15061
|
+
b: mat[1],
|
|
15062
|
+
c: mat[4],
|
|
15063
|
+
d: mat[5],
|
|
15064
|
+
e: mat[12],
|
|
15065
|
+
f: mat[13]
|
|
15066
|
+
});
|
|
15067
|
+
}
|
|
14926
15068
|
if (patternKey && canvasPattern) {
|
|
14927
15069
|
this.patternCache[patternKey] = canvasPattern;
|
|
14928
15070
|
}
|
|
@@ -14992,6 +15134,8 @@
|
|
|
14992
15134
|
// only generate cache for Image
|
|
14993
15135
|
if (isString(image)) {
|
|
14994
15136
|
return "pattern-" + image + "-" + repetition;
|
|
15137
|
+
} else if (image instanceof gLite.Rect) {
|
|
15138
|
+
return "pattern-" + image.entity + "-" + repetition;
|
|
14995
15139
|
}
|
|
14996
15140
|
};
|
|
14997
15141
|
return ImagePool;
|
|
@@ -15709,8 +15853,8 @@
|
|
|
15709
15853
|
})(GPUMapMode || (GPUMapMode = {}));
|
|
15710
15854
|
function translateTextureUsage(usage) {
|
|
15711
15855
|
var gpuUsage = 0;
|
|
15712
|
-
if (
|
|
15713
|
-
if (
|
|
15856
|
+
if (usage & TextureUsage.Sampled) gpuUsage |= GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_DST;
|
|
15857
|
+
if (usage & TextureUsage.RenderTarget) gpuUsage |= GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST;
|
|
15714
15858
|
return gpuUsage;
|
|
15715
15859
|
}
|
|
15716
15860
|
function translateTextureFormat(format) {
|
|
@@ -17563,7 +17707,7 @@
|
|
|
17563
17707
|
while (1) {
|
|
17564
17708
|
switch (_context.prev = _context.next) {
|
|
17565
17709
|
case 0:
|
|
17566
|
-
if (!(navigator.gpu === undefined)) {
|
|
17710
|
+
if (!(globalThis.navigator.gpu === undefined)) {
|
|
17567
17711
|
_context.next = 2;
|
|
17568
17712
|
break;
|
|
17569
17713
|
}
|
|
@@ -17572,7 +17716,7 @@
|
|
|
17572
17716
|
adapter = null;
|
|
17573
17717
|
_context.prev = 3;
|
|
17574
17718
|
_context.next = 6;
|
|
17575
|
-
return navigator.gpu.requestAdapter();
|
|
17719
|
+
return globalThis.navigator.gpu.requestAdapter();
|
|
17576
17720
|
case 6:
|
|
17577
17721
|
adapter = _context.sent;
|
|
17578
17722
|
_context.next = 12;
|