@antv/g-webgpu 1.7.73 → 1.8.0-alpha.1
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/ContextRegisterPlugin.d.ts +9 -10
- package/dist/WebGPUContextService.d.ts +19 -20
- package/dist/index.d.ts +14 -15
- package/dist/index.esm.js +114 -479
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +132 -497
- package/dist/index.js.map +1 -0
- package/dist/index.umd.min.js +2 -1
- package/dist/index.umd.min.js.map +1 -0
- package/package.json +19 -14
- package/dist/ContextRegisterPlugin.d.ts.map +0 -1
- package/dist/WebGPUContextService.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.umd.js +0 -16413
- package/dist/pkg/glsl_wgsl_compiler.d.ts +0 -48
- package/dist/pkg/glsl_wgsl_compiler.js +0 -223
- package/dist/pkg/glsl_wgsl_compiler_bg.wasm +0 -0
- package/dist/pkg/package.json +0 -17
package/dist/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var tslib = require('tslib');
|
|
5
4
|
var gLite = require('@antv/g-lite');
|
|
6
5
|
var DeviceRenderer = require('@antv/g-plugin-device-renderer');
|
|
7
6
|
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
@@ -10,521 +9,157 @@ var ImageLoader = require('@antv/g-plugin-image-loader');
|
|
|
10
9
|
var WebGPUDevice = require('@antv/g-plugin-webgpu-device');
|
|
11
10
|
var util = require('@antv/util');
|
|
12
11
|
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
12
|
+
function _interopNamespaceDefault(e) {
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
25
23
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
n['default'] = e;
|
|
30
|
-
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
var DeviceRenderer__namespace = /*#__PURE__*/
|
|
34
|
-
var DomInteraction__namespace = /*#__PURE__*/
|
|
35
|
-
var HTMLRenderer__namespace = /*#__PURE__*/
|
|
36
|
-
var
|
|
29
|
+
var DeviceRenderer__namespace = /*#__PURE__*/_interopNamespaceDefault(DeviceRenderer);
|
|
30
|
+
var DomInteraction__namespace = /*#__PURE__*/_interopNamespaceDefault(DomInteraction);
|
|
31
|
+
var HTMLRenderer__namespace = /*#__PURE__*/_interopNamespaceDefault(HTMLRenderer);
|
|
32
|
+
var ImageLoader__namespace = /*#__PURE__*/_interopNamespaceDefault(ImageLoader);
|
|
33
|
+
var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespaceDefault(WebGPUDevice);
|
|
37
34
|
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Op = Object.prototype,
|
|
44
|
-
hasOwn = Op.hasOwnProperty,
|
|
45
|
-
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
|
46
|
-
obj[key] = desc.value;
|
|
47
|
-
},
|
|
48
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
49
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
50
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
51
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
52
|
-
function define(obj, key, value) {
|
|
53
|
-
return Object.defineProperty(obj, key, {
|
|
54
|
-
value: value,
|
|
55
|
-
enumerable: !0,
|
|
56
|
-
configurable: !0,
|
|
57
|
-
writable: !0
|
|
58
|
-
}), obj[key];
|
|
59
|
-
}
|
|
60
|
-
try {
|
|
61
|
-
define({}, "");
|
|
62
|
-
} catch (err) {
|
|
63
|
-
define = function (obj, key, value) {
|
|
64
|
-
return obj[key] = value;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
68
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
69
|
-
generator = Object.create(protoGenerator.prototype),
|
|
70
|
-
context = new Context(tryLocsList || []);
|
|
71
|
-
return defineProperty(generator, "_invoke", {
|
|
72
|
-
value: makeInvokeMethod(innerFn, self, context)
|
|
73
|
-
}), generator;
|
|
74
|
-
}
|
|
75
|
-
function tryCatch(fn, obj, arg) {
|
|
76
|
-
try {
|
|
77
|
-
return {
|
|
78
|
-
type: "normal",
|
|
79
|
-
arg: fn.call(obj, arg)
|
|
80
|
-
};
|
|
81
|
-
} catch (err) {
|
|
82
|
-
return {
|
|
83
|
-
type: "throw",
|
|
84
|
-
arg: err
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
exports.wrap = wrap;
|
|
89
|
-
var ContinueSentinel = {};
|
|
90
|
-
function Generator() {}
|
|
91
|
-
function GeneratorFunction() {}
|
|
92
|
-
function GeneratorFunctionPrototype() {}
|
|
93
|
-
var IteratorPrototype = {};
|
|
94
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
95
|
-
return this;
|
|
96
|
-
});
|
|
97
|
-
var getProto = Object.getPrototypeOf,
|
|
98
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
99
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
100
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
101
|
-
function defineIteratorMethods(prototype) {
|
|
102
|
-
["next", "throw", "return"].forEach(function (method) {
|
|
103
|
-
define(prototype, method, function (arg) {
|
|
104
|
-
return this._invoke(method, arg);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
109
|
-
function invoke(method, arg, resolve, reject) {
|
|
110
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
111
|
-
if ("throw" !== record.type) {
|
|
112
|
-
var result = record.arg,
|
|
113
|
-
value = result.value;
|
|
114
|
-
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
115
|
-
invoke("next", value, resolve, reject);
|
|
116
|
-
}, function (err) {
|
|
117
|
-
invoke("throw", err, resolve, reject);
|
|
118
|
-
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
119
|
-
result.value = unwrapped, resolve(result);
|
|
120
|
-
}, function (error) {
|
|
121
|
-
return invoke("throw", error, resolve, reject);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
reject(record.arg);
|
|
35
|
+
var WebGPUContextService = /** @class */ (function () {
|
|
36
|
+
function WebGPUContextService(context) {
|
|
37
|
+
this.canvasConfig = context.config;
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
125
40
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
41
|
+
WebGPUContextService.prototype.init = function () {
|
|
42
|
+
var _a = this.canvasConfig, container = _a.container, canvas = _a.canvas;
|
|
43
|
+
if (canvas) {
|
|
44
|
+
this.$canvas = canvas;
|
|
45
|
+
if (container &&
|
|
46
|
+
canvas.parentElement !== container) {
|
|
47
|
+
container.appendChild(canvas);
|
|
48
|
+
}
|
|
49
|
+
this.$container = canvas.parentElement;
|
|
50
|
+
this.canvasConfig.container = this.$container;
|
|
133
51
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (delegate) {
|
|
149
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
150
|
-
if (delegateResult) {
|
|
151
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
152
|
-
return delegateResult;
|
|
153
|
-
}
|
|
52
|
+
else if (container) {
|
|
53
|
+
// create container
|
|
54
|
+
this.$container = util.isString(container)
|
|
55
|
+
? document.getElementById(container)
|
|
56
|
+
: container;
|
|
57
|
+
if (this.$container) {
|
|
58
|
+
// create canvas
|
|
59
|
+
var $canvas = document.createElement('canvas');
|
|
60
|
+
this.$container.appendChild($canvas);
|
|
61
|
+
if (!this.$container.style.position) {
|
|
62
|
+
this.$container.style.position = 'relative';
|
|
63
|
+
}
|
|
64
|
+
this.$canvas = $canvas;
|
|
65
|
+
}
|
|
154
66
|
}
|
|
155
|
-
|
|
156
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
157
|
-
context.dispatchException(context.arg);
|
|
158
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
159
|
-
state = "executing";
|
|
160
|
-
var record = tryCatch(innerFn, self, context);
|
|
161
|
-
if ("normal" === record.type) {
|
|
162
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
163
|
-
return {
|
|
164
|
-
value: record.arg,
|
|
165
|
-
done: context.done
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
173
|
-
var methodName = context.method,
|
|
174
|
-
method = delegate.iterator[methodName];
|
|
175
|
-
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
|
176
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
177
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
178
|
-
var info = record.arg;
|
|
179
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
180
|
-
}
|
|
181
|
-
function pushTryEntry(locs) {
|
|
182
|
-
var entry = {
|
|
183
|
-
tryLoc: locs[0]
|
|
184
|
-
};
|
|
185
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
186
|
-
}
|
|
187
|
-
function resetTryEntry(entry) {
|
|
188
|
-
var record = entry.completion || {};
|
|
189
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
190
|
-
}
|
|
191
|
-
function Context(tryLocsList) {
|
|
192
|
-
this.tryEntries = [{
|
|
193
|
-
tryLoc: "root"
|
|
194
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
195
|
-
}
|
|
196
|
-
function values(iterable) {
|
|
197
|
-
if (iterable) {
|
|
198
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
199
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
200
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
201
|
-
if (!isNaN(iterable.length)) {
|
|
202
|
-
var i = -1,
|
|
203
|
-
next = function next() {
|
|
204
|
-
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
205
|
-
return next.value = undefined, next.done = !0, next;
|
|
206
|
-
};
|
|
207
|
-
return next.next = next;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return {
|
|
211
|
-
next: doneResult
|
|
67
|
+
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
212
68
|
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
return {
|
|
216
|
-
value: undefined,
|
|
217
|
-
done: !0
|
|
69
|
+
WebGPUContextService.prototype.getDomElement = function () {
|
|
70
|
+
return this.$canvas;
|
|
218
71
|
};
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
224
|
-
value: GeneratorFunction,
|
|
225
|
-
configurable: !0
|
|
226
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
227
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
228
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
229
|
-
}, exports.mark = function (genFun) {
|
|
230
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
231
|
-
}, exports.awrap = function (arg) {
|
|
232
|
-
return {
|
|
233
|
-
__await: arg
|
|
72
|
+
WebGPUContextService.prototype.getContext = function () {
|
|
73
|
+
return (
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
this.deviceRendererPlugin.getDevice().canvasContext);
|
|
234
76
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
240
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
241
|
-
return result.done ? result.value : iter.next();
|
|
242
|
-
});
|
|
243
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
244
|
-
return this;
|
|
245
|
-
}), define(Gp, "toString", function () {
|
|
246
|
-
return "[object Generator]";
|
|
247
|
-
}), exports.keys = function (val) {
|
|
248
|
-
var object = Object(val),
|
|
249
|
-
keys = [];
|
|
250
|
-
for (var key in object) keys.push(key);
|
|
251
|
-
return keys.reverse(), function next() {
|
|
252
|
-
for (; keys.length;) {
|
|
253
|
-
var key = keys.pop();
|
|
254
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
255
|
-
}
|
|
256
|
-
return next.done = !0, next;
|
|
77
|
+
WebGPUContextService.prototype.getBoundingClientRect = function () {
|
|
78
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
79
|
+
return this.$canvas.getBoundingClientRect();
|
|
80
|
+
}
|
|
257
81
|
};
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
stop: function () {
|
|
264
|
-
this.done = !0;
|
|
265
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
266
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
267
|
-
return this.rval;
|
|
268
|
-
},
|
|
269
|
-
dispatchException: function (exception) {
|
|
270
|
-
if (this.done) throw exception;
|
|
271
|
-
var context = this;
|
|
272
|
-
function handle(loc, caught) {
|
|
273
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
274
|
-
}
|
|
275
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
276
|
-
var entry = this.tryEntries[i],
|
|
277
|
-
record = entry.completion;
|
|
278
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
279
|
-
if (entry.tryLoc <= this.prev) {
|
|
280
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
281
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
282
|
-
if (hasCatch && hasFinally) {
|
|
283
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
284
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
285
|
-
} else if (hasCatch) {
|
|
286
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
287
|
-
} else {
|
|
288
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
289
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
290
|
-
}
|
|
82
|
+
WebGPUContextService.prototype.destroy = function () {
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
this.$container.removeChild(this.$canvas);
|
|
291
87
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
var
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
88
|
+
};
|
|
89
|
+
WebGPUContextService.prototype.resize = function (width, height) {
|
|
90
|
+
// use user-defined dpr first
|
|
91
|
+
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
92
|
+
var dpr = devicePixelRatio || (gLite.isBrowser && window.devicePixelRatio) || 1;
|
|
93
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
94
|
+
this.dpr = dpr;
|
|
95
|
+
if (this.$canvas) {
|
|
96
|
+
var dpr_1 = this.getDPR();
|
|
97
|
+
// set canvas width & height
|
|
98
|
+
this.$canvas.width = dpr_1 * width;
|
|
99
|
+
this.$canvas.height = dpr_1 * height;
|
|
100
|
+
// set CSS style width & height
|
|
101
|
+
gLite.setDOMSize(this.$canvas, width, height);
|
|
300
102
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
309
|
-
},
|
|
310
|
-
finish: function (finallyLoc) {
|
|
311
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
312
|
-
var entry = this.tryEntries[i];
|
|
313
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
314
|
-
}
|
|
315
|
-
},
|
|
316
|
-
catch: function (tryLoc) {
|
|
317
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
318
|
-
var entry = this.tryEntries[i];
|
|
319
|
-
if (entry.tryLoc === tryLoc) {
|
|
320
|
-
var record = entry.completion;
|
|
321
|
-
if ("throw" === record.type) {
|
|
322
|
-
var thrown = record.arg;
|
|
323
|
-
resetTryEntry(entry);
|
|
324
|
-
}
|
|
325
|
-
return thrown;
|
|
103
|
+
};
|
|
104
|
+
WebGPUContextService.prototype.getDPR = function () {
|
|
105
|
+
return this.dpr;
|
|
106
|
+
};
|
|
107
|
+
WebGPUContextService.prototype.applyCursorStyle = function (cursor) {
|
|
108
|
+
if (this.$container && this.$container.style) {
|
|
109
|
+
this.$container.style.cursor = cursor;
|
|
326
110
|
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}, exports;
|
|
338
|
-
}
|
|
339
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
340
|
-
try {
|
|
341
|
-
var info = gen[key](arg);
|
|
342
|
-
var value = info.value;
|
|
343
|
-
} catch (error) {
|
|
344
|
-
reject(error);
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
if (info.done) {
|
|
348
|
-
resolve(value);
|
|
349
|
-
} else {
|
|
350
|
-
Promise.resolve(value).then(_next, _throw);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
function _asyncToGenerator(fn) {
|
|
354
|
-
return function () {
|
|
355
|
-
var self = this,
|
|
356
|
-
args = arguments;
|
|
357
|
-
return new Promise(function (resolve, reject) {
|
|
358
|
-
var gen = fn.apply(self, args);
|
|
359
|
-
function _next(value) {
|
|
360
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
361
|
-
}
|
|
362
|
-
function _throw(err) {
|
|
363
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
364
|
-
}
|
|
365
|
-
_next(undefined);
|
|
366
|
-
});
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
function _inheritsLoose(subClass, superClass) {
|
|
370
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
371
|
-
subClass.prototype.constructor = subClass;
|
|
372
|
-
_setPrototypeOf(subClass, superClass);
|
|
373
|
-
}
|
|
374
|
-
function _setPrototypeOf(o, p) {
|
|
375
|
-
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
376
|
-
o.__proto__ = p;
|
|
377
|
-
return o;
|
|
378
|
-
};
|
|
379
|
-
return _setPrototypeOf(o, p);
|
|
380
|
-
}
|
|
111
|
+
};
|
|
112
|
+
WebGPUContextService.prototype.toDataURL = function (options) {
|
|
113
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
114
|
+
return tslib.__generator(this, function (_a) {
|
|
115
|
+
return [2 /*return*/, ''];
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return WebGPUContextService;
|
|
120
|
+
}());
|
|
381
121
|
|
|
382
|
-
var
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
this.canvasConfig = context.config;
|
|
390
|
-
// @ts-ignore
|
|
391
|
-
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
392
|
-
}
|
|
393
|
-
var _proto = WebGPUContextService.prototype;
|
|
394
|
-
_proto.init = function init() {
|
|
395
|
-
var _this$canvasConfig = this.canvasConfig,
|
|
396
|
-
container = _this$canvasConfig.container,
|
|
397
|
-
canvas = _this$canvasConfig.canvas;
|
|
398
|
-
if (canvas) {
|
|
399
|
-
this.$canvas = canvas;
|
|
400
|
-
if (container && canvas.parentElement !== container) {
|
|
401
|
-
container.appendChild(canvas);
|
|
402
|
-
}
|
|
403
|
-
this.$container = canvas.parentElement;
|
|
404
|
-
this.canvasConfig.container = this.$container;
|
|
405
|
-
} else if (container) {
|
|
406
|
-
// create container
|
|
407
|
-
this.$container = util.isString(container) ? document.getElementById(container) : container;
|
|
408
|
-
if (this.$container) {
|
|
409
|
-
// create canvas
|
|
410
|
-
var $canvas = document.createElement('canvas');
|
|
411
|
-
this.$container.appendChild($canvas);
|
|
412
|
-
if (!this.$container.style.position) {
|
|
413
|
-
this.$container.style.position = 'relative';
|
|
414
|
-
}
|
|
415
|
-
this.$canvas = $canvas;
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
419
|
-
};
|
|
420
|
-
_proto.getDomElement = function getDomElement() {
|
|
421
|
-
return this.$canvas;
|
|
422
|
-
};
|
|
423
|
-
_proto.getContext = function getContext() {
|
|
424
|
-
return (
|
|
425
|
-
// @ts-ignore
|
|
426
|
-
this.deviceRendererPlugin.getDevice().canvasContext
|
|
427
|
-
);
|
|
428
|
-
};
|
|
429
|
-
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
430
|
-
if (this.$canvas.getBoundingClientRect) {
|
|
431
|
-
return this.$canvas.getBoundingClientRect();
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
_proto.destroy = function destroy() {
|
|
435
|
-
// @ts-ignore
|
|
436
|
-
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
437
|
-
// @ts-ignore
|
|
438
|
-
this.$container.removeChild(this.$canvas);
|
|
122
|
+
var ContextRegisterPlugin = /** @class */ (function (_super) {
|
|
123
|
+
tslib.__extends(ContextRegisterPlugin, _super);
|
|
124
|
+
function ContextRegisterPlugin(rendererPlugin) {
|
|
125
|
+
var _this = _super.call(this) || this;
|
|
126
|
+
_this.rendererPlugin = rendererPlugin;
|
|
127
|
+
_this.name = 'webgpu-context-register';
|
|
128
|
+
return _this;
|
|
439
129
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
this.$canvas.width = _dpr * width;
|
|
451
|
-
this.$canvas.height = _dpr * height;
|
|
452
|
-
// set CSS style width & height
|
|
453
|
-
gLite.setDOMSize(this.$canvas, width, height);
|
|
454
|
-
}
|
|
455
|
-
};
|
|
456
|
-
_proto.getDPR = function getDPR() {
|
|
457
|
-
return this.dpr;
|
|
458
|
-
};
|
|
459
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
460
|
-
if (this.$container && this.$container.style) {
|
|
461
|
-
this.$container.style.cursor = cursor;
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
_proto.toDataURL = /*#__PURE__*/function () {
|
|
465
|
-
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
466
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
467
|
-
while (1) switch (_context.prev = _context.next) {
|
|
468
|
-
case 0:
|
|
469
|
-
return _context.abrupt("return", '');
|
|
470
|
-
case 1:
|
|
471
|
-
case "end":
|
|
472
|
-
return _context.stop();
|
|
473
|
-
}
|
|
474
|
-
}, _callee);
|
|
475
|
-
}));
|
|
476
|
-
function toDataURL(_x) {
|
|
477
|
-
return _toDataURL.apply(this, arguments);
|
|
478
|
-
}
|
|
479
|
-
return toDataURL;
|
|
480
|
-
}();
|
|
481
|
-
return WebGPUContextService;
|
|
482
|
-
}();
|
|
483
|
-
|
|
484
|
-
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
485
|
-
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
486
|
-
function ContextRegisterPlugin(rendererPlugin) {
|
|
487
|
-
var _this;
|
|
488
|
-
_this = _AbstractRendererPlug.call(this) || this;
|
|
489
|
-
_this.rendererPlugin = void 0;
|
|
490
|
-
_this.name = 'webgpu-context-register';
|
|
491
|
-
_this.rendererPlugin = rendererPlugin;
|
|
492
|
-
return _this;
|
|
493
|
-
}
|
|
494
|
-
var _proto = ContextRegisterPlugin.prototype;
|
|
495
|
-
_proto.init = function init() {
|
|
496
|
-
this.context.ContextService = WebGPUContextService;
|
|
497
|
-
// @ts-ignore
|
|
498
|
-
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
499
|
-
};
|
|
500
|
-
_proto.destroy = function destroy() {
|
|
501
|
-
delete this.context.ContextService;
|
|
502
|
-
};
|
|
503
|
-
return ContextRegisterPlugin;
|
|
504
|
-
}(gLite.AbstractRendererPlugin);
|
|
130
|
+
ContextRegisterPlugin.prototype.init = function () {
|
|
131
|
+
this.context.ContextService = WebGPUContextService;
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
134
|
+
};
|
|
135
|
+
ContextRegisterPlugin.prototype.destroy = function () {
|
|
136
|
+
delete this.context.ContextService;
|
|
137
|
+
};
|
|
138
|
+
return ContextRegisterPlugin;
|
|
139
|
+
}(gLite.AbstractRendererPlugin));
|
|
505
140
|
|
|
506
|
-
var Renderer =
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
}(gLite.AbstractRenderer);
|
|
141
|
+
var Renderer = /** @class */ (function (_super) {
|
|
142
|
+
tslib.__extends(Renderer, _super);
|
|
143
|
+
function Renderer(config) {
|
|
144
|
+
var _this = _super.call(this, config) || this;
|
|
145
|
+
var deviceRendererPlugin = new DeviceRenderer__namespace.Plugin();
|
|
146
|
+
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
147
|
+
_this.registerPlugin(new ImageLoader__namespace.Plugin());
|
|
148
|
+
_this.registerPlugin(new WebGPUDevice__namespace.Plugin({
|
|
149
|
+
shaderCompilerPath: config === null || config === void 0 ? void 0 : config.shaderCompilerPath,
|
|
150
|
+
onContextLost: config === null || config === void 0 ? void 0 : config.onContextLost,
|
|
151
|
+
}));
|
|
152
|
+
_this.registerPlugin(deviceRendererPlugin);
|
|
153
|
+
_this.registerPlugin(new DomInteraction__namespace.Plugin());
|
|
154
|
+
_this.registerPlugin(new HTMLRenderer__namespace.Plugin());
|
|
155
|
+
return _this;
|
|
156
|
+
}
|
|
157
|
+
return Renderer;
|
|
158
|
+
}(gLite.AbstractRenderer));
|
|
525
159
|
|
|
526
160
|
exports.DeviceRenderer = DeviceRenderer__namespace;
|
|
527
161
|
exports.DomInteraction = DomInteraction__namespace;
|
|
528
162
|
exports.HTMLRenderer = HTMLRenderer__namespace;
|
|
529
163
|
exports.WebGPUDevice = WebGPUDevice__namespace;
|
|
530
164
|
exports.Renderer = Renderer;
|
|
165
|
+
//# sourceMappingURL=index.js.map
|