@antv/g-webgpu 1.7.30 → 1.7.31
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.esm.js +83 -173
- package/dist/index.js +83 -173
- package/dist/index.umd.js +1965 -4105
- package/dist/index.umd.min.js +1 -13
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -36,20 +36,19 @@ var HTMLRenderer__namespace = /*#__PURE__*/_interopNamespace(HTMLRenderer);
|
|
|
36
36
|
var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespace(WebGPUDevice);
|
|
37
37
|
|
|
38
38
|
function _regeneratorRuntime() {
|
|
39
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
40
|
-
|
|
41
39
|
_regeneratorRuntime = function () {
|
|
42
40
|
return exports;
|
|
43
41
|
};
|
|
44
|
-
|
|
45
42
|
var exports = {},
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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";
|
|
53
52
|
function define(obj, key, value) {
|
|
54
53
|
return Object.defineProperty(obj, key, {
|
|
55
54
|
value: value,
|
|
@@ -58,7 +57,6 @@ function _regeneratorRuntime() {
|
|
|
58
57
|
writable: !0
|
|
59
58
|
}), obj[key];
|
|
60
59
|
}
|
|
61
|
-
|
|
62
60
|
try {
|
|
63
61
|
define({}, "");
|
|
64
62
|
} catch (err) {
|
|
@@ -66,54 +64,14 @@ function _regeneratorRuntime() {
|
|
|
66
64
|
return obj[key] = value;
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
|
-
|
|
70
67
|
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
71
68
|
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
return generator
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
78
|
-
|
|
79
|
-
if ("completed" === state) {
|
|
80
|
-
if ("throw" === method) throw arg;
|
|
81
|
-
return doneResult();
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
for (context.method = method, context.arg = arg;;) {
|
|
85
|
-
var delegate = context.delegate;
|
|
86
|
-
|
|
87
|
-
if (delegate) {
|
|
88
|
-
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
89
|
-
|
|
90
|
-
if (delegateResult) {
|
|
91
|
-
if (delegateResult === ContinueSentinel) continue;
|
|
92
|
-
return delegateResult;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
97
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
98
|
-
context.dispatchException(context.arg);
|
|
99
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
100
|
-
state = "executing";
|
|
101
|
-
var record = tryCatch(innerFn, self, context);
|
|
102
|
-
|
|
103
|
-
if ("normal" === record.type) {
|
|
104
|
-
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
105
|
-
return {
|
|
106
|
-
value: record.arg,
|
|
107
|
-
done: context.done
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
}(innerFn, self, context), 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;
|
|
115
74
|
}
|
|
116
|
-
|
|
117
75
|
function tryCatch(fn, obj, arg) {
|
|
118
76
|
try {
|
|
119
77
|
return {
|
|
@@ -127,25 +85,19 @@ function _regeneratorRuntime() {
|
|
|
127
85
|
};
|
|
128
86
|
}
|
|
129
87
|
}
|
|
130
|
-
|
|
131
88
|
exports.wrap = wrap;
|
|
132
89
|
var ContinueSentinel = {};
|
|
133
|
-
|
|
134
90
|
function Generator() {}
|
|
135
|
-
|
|
136
91
|
function GeneratorFunction() {}
|
|
137
|
-
|
|
138
92
|
function GeneratorFunctionPrototype() {}
|
|
139
|
-
|
|
140
93
|
var IteratorPrototype = {};
|
|
141
94
|
define(IteratorPrototype, iteratorSymbol, function () {
|
|
142
95
|
return this;
|
|
143
96
|
});
|
|
144
97
|
var getProto = Object.getPrototypeOf,
|
|
145
|
-
|
|
98
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
146
99
|
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
147
100
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
148
|
-
|
|
149
101
|
function defineIteratorMethods(prototype) {
|
|
150
102
|
["next", "throw", "return"].forEach(function (method) {
|
|
151
103
|
define(prototype, method, function (arg) {
|
|
@@ -153,14 +105,12 @@ function _regeneratorRuntime() {
|
|
|
153
105
|
});
|
|
154
106
|
});
|
|
155
107
|
}
|
|
156
|
-
|
|
157
108
|
function AsyncIterator(generator, PromiseImpl) {
|
|
158
109
|
function invoke(method, arg, resolve, reject) {
|
|
159
110
|
var record = tryCatch(generator[method], generator, arg);
|
|
160
|
-
|
|
161
111
|
if ("throw" !== record.type) {
|
|
162
112
|
var result = record.arg,
|
|
163
|
-
|
|
113
|
+
value = result.value;
|
|
164
114
|
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
165
115
|
invoke("next", value, resolve, reject);
|
|
166
116
|
}, function (err) {
|
|
@@ -171,90 +121,114 @@ function _regeneratorRuntime() {
|
|
|
171
121
|
return invoke("throw", error, resolve, reject);
|
|
172
122
|
});
|
|
173
123
|
}
|
|
174
|
-
|
|
175
124
|
reject(record.arg);
|
|
176
125
|
}
|
|
177
|
-
|
|
178
126
|
var previousPromise;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
127
|
+
defineProperty(this, "_invoke", {
|
|
128
|
+
value: function (method, arg) {
|
|
129
|
+
function callInvokeWithMethodAndArg() {
|
|
130
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
131
|
+
invoke(method, arg, resolve, reject);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function makeInvokeMethod(innerFn, self, context) {
|
|
139
|
+
var state = "suspendedStart";
|
|
140
|
+
return function (method, arg) {
|
|
141
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
142
|
+
if ("completed" === state) {
|
|
143
|
+
if ("throw" === method) throw arg;
|
|
144
|
+
return doneResult();
|
|
145
|
+
}
|
|
146
|
+
for (context.method = method, context.arg = arg;;) {
|
|
147
|
+
var delegate = context.delegate;
|
|
148
|
+
if (delegate) {
|
|
149
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
150
|
+
if (delegateResult) {
|
|
151
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
152
|
+
return delegateResult;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
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);
|
|
185
169
|
}
|
|
186
|
-
|
|
187
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
188
170
|
};
|
|
189
171
|
}
|
|
190
|
-
|
|
191
172
|
function maybeInvokeDelegate(delegate, context) {
|
|
192
173
|
var method = delegate.iterator[context.method];
|
|
193
|
-
|
|
194
174
|
if (undefined === method) {
|
|
195
175
|
if (context.delegate = null, "throw" === context.method) {
|
|
196
176
|
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
197
177
|
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
198
178
|
}
|
|
199
|
-
|
|
200
179
|
return ContinueSentinel;
|
|
201
180
|
}
|
|
202
|
-
|
|
203
181
|
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
204
182
|
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
205
183
|
var info = record.arg;
|
|
206
184
|
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);
|
|
207
185
|
}
|
|
208
|
-
|
|
209
186
|
function pushTryEntry(locs) {
|
|
210
187
|
var entry = {
|
|
211
188
|
tryLoc: locs[0]
|
|
212
189
|
};
|
|
213
190
|
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
214
191
|
}
|
|
215
|
-
|
|
216
192
|
function resetTryEntry(entry) {
|
|
217
193
|
var record = entry.completion || {};
|
|
218
194
|
record.type = "normal", delete record.arg, entry.completion = record;
|
|
219
195
|
}
|
|
220
|
-
|
|
221
196
|
function Context(tryLocsList) {
|
|
222
197
|
this.tryEntries = [{
|
|
223
198
|
tryLoc: "root"
|
|
224
199
|
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
225
200
|
}
|
|
226
|
-
|
|
227
201
|
function values(iterable) {
|
|
228
202
|
if (iterable) {
|
|
229
203
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
230
204
|
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
231
205
|
if ("function" == typeof iterable.next) return iterable;
|
|
232
|
-
|
|
233
206
|
if (!isNaN(iterable.length)) {
|
|
234
207
|
var i = -1,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
240
|
-
|
|
208
|
+
next = function next() {
|
|
209
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
210
|
+
return next.value = undefined, next.done = !0, next;
|
|
211
|
+
};
|
|
241
212
|
return next.next = next;
|
|
242
213
|
}
|
|
243
214
|
}
|
|
244
|
-
|
|
245
215
|
return {
|
|
246
216
|
next: doneResult
|
|
247
217
|
};
|
|
248
218
|
}
|
|
249
|
-
|
|
250
219
|
function doneResult() {
|
|
251
220
|
return {
|
|
252
221
|
value: undefined,
|
|
253
222
|
done: !0
|
|
254
223
|
};
|
|
255
224
|
}
|
|
256
|
-
|
|
257
|
-
|
|
225
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
|
226
|
+
value: GeneratorFunctionPrototype,
|
|
227
|
+
configurable: !0
|
|
228
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
|
229
|
+
value: GeneratorFunction,
|
|
230
|
+
configurable: !0
|
|
231
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
258
232
|
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
259
233
|
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
260
234
|
}, exports.mark = function (genFun) {
|
|
@@ -275,17 +249,15 @@ function _regeneratorRuntime() {
|
|
|
275
249
|
return this;
|
|
276
250
|
}), define(Gp, "toString", function () {
|
|
277
251
|
return "[object Generator]";
|
|
278
|
-
}), exports.keys = function (
|
|
279
|
-
var
|
|
280
|
-
|
|
252
|
+
}), exports.keys = function (val) {
|
|
253
|
+
var object = Object(val),
|
|
254
|
+
keys = [];
|
|
281
255
|
for (var key in object) keys.push(key);
|
|
282
|
-
|
|
283
256
|
return keys.reverse(), function next() {
|
|
284
257
|
for (; keys.length;) {
|
|
285
258
|
var key = keys.pop();
|
|
286
259
|
if (key in object) return next.value = key, next.done = !1, next;
|
|
287
260
|
}
|
|
288
|
-
|
|
289
261
|
return next.done = !0, next;
|
|
290
262
|
};
|
|
291
263
|
}, exports.values = values, Context.prototype = {
|
|
@@ -302,20 +274,16 @@ function _regeneratorRuntime() {
|
|
|
302
274
|
dispatchException: function (exception) {
|
|
303
275
|
if (this.done) throw exception;
|
|
304
276
|
var context = this;
|
|
305
|
-
|
|
306
277
|
function handle(loc, caught) {
|
|
307
278
|
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
308
279
|
}
|
|
309
|
-
|
|
310
280
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
311
281
|
var entry = this.tryEntries[i],
|
|
312
|
-
|
|
282
|
+
record = entry.completion;
|
|
313
283
|
if ("root" === entry.tryLoc) return handle("end");
|
|
314
|
-
|
|
315
284
|
if (entry.tryLoc <= this.prev) {
|
|
316
285
|
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
317
|
-
|
|
318
|
-
|
|
286
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
319
287
|
if (hasCatch && hasFinally) {
|
|
320
288
|
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
321
289
|
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
@@ -331,13 +299,11 @@ function _regeneratorRuntime() {
|
|
|
331
299
|
abrupt: function (type, arg) {
|
|
332
300
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
333
301
|
var entry = this.tryEntries[i];
|
|
334
|
-
|
|
335
302
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
336
303
|
var finallyEntry = entry;
|
|
337
304
|
break;
|
|
338
305
|
}
|
|
339
306
|
}
|
|
340
|
-
|
|
341
307
|
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
342
308
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
343
309
|
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
@@ -355,19 +321,15 @@ function _regeneratorRuntime() {
|
|
|
355
321
|
catch: function (tryLoc) {
|
|
356
322
|
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
357
323
|
var entry = this.tryEntries[i];
|
|
358
|
-
|
|
359
324
|
if (entry.tryLoc === tryLoc) {
|
|
360
325
|
var record = entry.completion;
|
|
361
|
-
|
|
362
326
|
if ("throw" === record.type) {
|
|
363
327
|
var thrown = record.arg;
|
|
364
328
|
resetTryEntry(entry);
|
|
365
329
|
}
|
|
366
|
-
|
|
367
330
|
return thrown;
|
|
368
331
|
}
|
|
369
332
|
}
|
|
370
|
-
|
|
371
333
|
throw new Error("illegal catch attempt");
|
|
372
334
|
},
|
|
373
335
|
delegateYield: function (iterable, resultName, nextLoc) {
|
|
@@ -379,7 +341,6 @@ function _regeneratorRuntime() {
|
|
|
379
341
|
}
|
|
380
342
|
}, exports;
|
|
381
343
|
}
|
|
382
|
-
|
|
383
344
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
384
345
|
try {
|
|
385
346
|
var info = gen[key](arg);
|
|
@@ -388,41 +349,33 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
388
349
|
reject(error);
|
|
389
350
|
return;
|
|
390
351
|
}
|
|
391
|
-
|
|
392
352
|
if (info.done) {
|
|
393
353
|
resolve(value);
|
|
394
354
|
} else {
|
|
395
355
|
Promise.resolve(value).then(_next, _throw);
|
|
396
356
|
}
|
|
397
357
|
}
|
|
398
|
-
|
|
399
358
|
function _asyncToGenerator(fn) {
|
|
400
359
|
return function () {
|
|
401
360
|
var self = this,
|
|
402
|
-
|
|
361
|
+
args = arguments;
|
|
403
362
|
return new Promise(function (resolve, reject) {
|
|
404
363
|
var gen = fn.apply(self, args);
|
|
405
|
-
|
|
406
364
|
function _next(value) {
|
|
407
365
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
408
366
|
}
|
|
409
|
-
|
|
410
367
|
function _throw(err) {
|
|
411
368
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
412
369
|
}
|
|
413
|
-
|
|
414
370
|
_next(undefined);
|
|
415
371
|
});
|
|
416
372
|
};
|
|
417
373
|
}
|
|
418
|
-
|
|
419
374
|
function _inheritsLoose(subClass, superClass) {
|
|
420
375
|
subClass.prototype = Object.create(superClass.prototype);
|
|
421
376
|
subClass.prototype.constructor = subClass;
|
|
422
|
-
|
|
423
377
|
_setPrototypeOf(subClass, superClass);
|
|
424
378
|
}
|
|
425
|
-
|
|
426
379
|
function _setPrototypeOf(o, p) {
|
|
427
380
|
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
428
381
|
o.__proto__ = p;
|
|
@@ -438,51 +391,40 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
438
391
|
this.dpr = void 0;
|
|
439
392
|
this.canvasConfig = void 0;
|
|
440
393
|
this.deviceRendererPlugin = void 0;
|
|
441
|
-
this.canvasConfig = context.config;
|
|
442
|
-
|
|
394
|
+
this.canvasConfig = context.config;
|
|
395
|
+
// @ts-ignore
|
|
443
396
|
this.deviceRendererPlugin = context.deviceRendererPlugin;
|
|
444
397
|
}
|
|
445
|
-
|
|
446
398
|
var _proto = WebGPUContextService.prototype;
|
|
447
|
-
|
|
448
399
|
_proto.init = /*#__PURE__*/function () {
|
|
449
400
|
var _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
450
401
|
var _this$canvasConfig, container, canvas, $canvas;
|
|
451
|
-
|
|
452
402
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
453
403
|
while (1) {
|
|
454
404
|
switch (_context.prev = _context.next) {
|
|
455
405
|
case 0:
|
|
456
406
|
_this$canvasConfig = this.canvasConfig, container = _this$canvasConfig.container, canvas = _this$canvasConfig.canvas;
|
|
457
|
-
|
|
458
407
|
if (canvas) {
|
|
459
408
|
this.$canvas = canvas;
|
|
460
|
-
|
|
461
409
|
if (container && canvas.parentElement !== container) {
|
|
462
410
|
container.appendChild(canvas);
|
|
463
411
|
}
|
|
464
|
-
|
|
465
412
|
this.$container = canvas.parentElement;
|
|
466
413
|
this.canvasConfig.container = this.$container;
|
|
467
414
|
} else if (container) {
|
|
468
415
|
// create container
|
|
469
416
|
this.$container = util.isString(container) ? document.getElementById(container) : container;
|
|
470
|
-
|
|
471
417
|
if (this.$container) {
|
|
472
418
|
// create canvas
|
|
473
419
|
$canvas = document.createElement('canvas');
|
|
474
420
|
this.$container.appendChild($canvas);
|
|
475
|
-
|
|
476
421
|
if (!this.$container.style.position) {
|
|
477
422
|
this.$container.style.position = 'relative';
|
|
478
423
|
}
|
|
479
|
-
|
|
480
424
|
this.$canvas = $canvas;
|
|
481
425
|
}
|
|
482
426
|
}
|
|
483
|
-
|
|
484
427
|
this.resize(this.canvasConfig.width, this.canvasConfig.height);
|
|
485
|
-
|
|
486
428
|
case 3:
|
|
487
429
|
case "end":
|
|
488
430
|
return _context.stop();
|
|
@@ -490,29 +432,23 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
490
432
|
}
|
|
491
433
|
}, _callee, this);
|
|
492
434
|
}));
|
|
493
|
-
|
|
494
435
|
function init() {
|
|
495
436
|
return _init.apply(this, arguments);
|
|
496
437
|
}
|
|
497
|
-
|
|
498
438
|
return init;
|
|
499
439
|
}();
|
|
500
|
-
|
|
501
440
|
_proto.getDomElement = function getDomElement() {
|
|
502
441
|
return this.$canvas;
|
|
503
442
|
};
|
|
504
|
-
|
|
505
443
|
_proto.getContext = function getContext() {
|
|
506
444
|
// @ts-ignore
|
|
507
445
|
return this.deviceRendererPlugin.getDevice().canvasContext;
|
|
508
446
|
};
|
|
509
|
-
|
|
510
447
|
_proto.getBoundingClientRect = function getBoundingClientRect() {
|
|
511
448
|
if (this.$canvas.getBoundingClientRect) {
|
|
512
449
|
return this.$canvas.getBoundingClientRect();
|
|
513
450
|
}
|
|
514
451
|
};
|
|
515
|
-
|
|
516
452
|
_proto.destroy = function destroy() {
|
|
517
453
|
// @ts-ignore
|
|
518
454
|
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
@@ -520,35 +456,29 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
520
456
|
this.$container.removeChild(this.$canvas);
|
|
521
457
|
}
|
|
522
458
|
};
|
|
523
|
-
|
|
524
459
|
_proto.resize = function resize(width, height) {
|
|
525
460
|
// use user-defined dpr first
|
|
526
461
|
var devicePixelRatio = this.canvasConfig.devicePixelRatio;
|
|
527
462
|
var dpr = devicePixelRatio || gLite.isBrowser && window.devicePixelRatio || 1;
|
|
528
463
|
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
529
464
|
this.dpr = dpr;
|
|
530
|
-
|
|
531
465
|
if (this.$canvas) {
|
|
532
|
-
var _dpr = this.getDPR();
|
|
533
|
-
|
|
534
|
-
|
|
466
|
+
var _dpr = this.getDPR();
|
|
467
|
+
// set canvas width & height
|
|
535
468
|
this.$canvas.width = _dpr * width;
|
|
536
|
-
this.$canvas.height = _dpr * height;
|
|
537
|
-
|
|
469
|
+
this.$canvas.height = _dpr * height;
|
|
470
|
+
// set CSS style width & height
|
|
538
471
|
gLite.setDOMSize(this.$canvas, width, height);
|
|
539
472
|
}
|
|
540
473
|
};
|
|
541
|
-
|
|
542
474
|
_proto.getDPR = function getDPR() {
|
|
543
475
|
return this.dpr;
|
|
544
476
|
};
|
|
545
|
-
|
|
546
477
|
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
547
478
|
if (this.$container && this.$container.style) {
|
|
548
479
|
this.$container.style.cursor = cursor;
|
|
549
480
|
}
|
|
550
481
|
};
|
|
551
|
-
|
|
552
482
|
_proto.toDataURL = /*#__PURE__*/function () {
|
|
553
483
|
var _toDataURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(options) {
|
|
554
484
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -556,7 +486,6 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
556
486
|
switch (_context2.prev = _context2.next) {
|
|
557
487
|
case 0:
|
|
558
488
|
return _context2.abrupt("return", '');
|
|
559
|
-
|
|
560
489
|
case 1:
|
|
561
490
|
case "end":
|
|
562
491
|
return _context2.stop();
|
|
@@ -564,69 +493,50 @@ var WebGPUContextService = /*#__PURE__*/function () {
|
|
|
564
493
|
}
|
|
565
494
|
}, _callee2);
|
|
566
495
|
}));
|
|
567
|
-
|
|
568
496
|
function toDataURL(_x) {
|
|
569
497
|
return _toDataURL.apply(this, arguments);
|
|
570
498
|
}
|
|
571
|
-
|
|
572
499
|
return toDataURL;
|
|
573
500
|
}();
|
|
574
|
-
|
|
575
501
|
return WebGPUContextService;
|
|
576
502
|
}();
|
|
577
503
|
|
|
578
504
|
var ContextRegisterPlugin = /*#__PURE__*/function (_AbstractRendererPlug) {
|
|
579
505
|
_inheritsLoose(ContextRegisterPlugin, _AbstractRendererPlug);
|
|
580
|
-
|
|
581
506
|
function ContextRegisterPlugin(rendererPlugin) {
|
|
582
507
|
var _this;
|
|
583
|
-
|
|
584
508
|
_this = _AbstractRendererPlug.call(this) || this;
|
|
585
509
|
_this.rendererPlugin = void 0;
|
|
586
510
|
_this.name = 'webgpu-context-register';
|
|
587
511
|
_this.rendererPlugin = rendererPlugin;
|
|
588
512
|
return _this;
|
|
589
513
|
}
|
|
590
|
-
|
|
591
514
|
var _proto = ContextRegisterPlugin.prototype;
|
|
592
|
-
|
|
593
515
|
_proto.init = function init() {
|
|
594
|
-
this.context.ContextService = WebGPUContextService;
|
|
595
|
-
|
|
516
|
+
this.context.ContextService = WebGPUContextService;
|
|
517
|
+
// @ts-ignore
|
|
596
518
|
this.context.deviceRendererPlugin = this.rendererPlugin;
|
|
597
519
|
};
|
|
598
|
-
|
|
599
520
|
_proto.destroy = function destroy() {
|
|
600
521
|
delete this.context.ContextService;
|
|
601
522
|
};
|
|
602
|
-
|
|
603
523
|
return ContextRegisterPlugin;
|
|
604
524
|
}(gLite.AbstractRendererPlugin);
|
|
605
525
|
|
|
606
526
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
607
527
|
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
608
|
-
|
|
609
528
|
function Renderer(config) {
|
|
610
529
|
var _this;
|
|
611
|
-
|
|
612
530
|
_this = _AbstractRenderer.call(this, config) || this;
|
|
613
531
|
var deviceRendererPlugin = new DeviceRenderer.Plugin();
|
|
614
|
-
|
|
615
532
|
_this.registerPlugin(new ContextRegisterPlugin(deviceRendererPlugin));
|
|
616
|
-
|
|
617
533
|
_this.registerPlugin(new ImageLoader.Plugin());
|
|
618
|
-
|
|
619
534
|
_this.registerPlugin(new WebGPUDevice.Plugin());
|
|
620
|
-
|
|
621
535
|
_this.registerPlugin(deviceRendererPlugin);
|
|
622
|
-
|
|
623
536
|
_this.registerPlugin(new DomInteraction.Plugin());
|
|
624
|
-
|
|
625
537
|
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
626
|
-
|
|
627
538
|
return _this;
|
|
628
539
|
}
|
|
629
|
-
|
|
630
540
|
return Renderer;
|
|
631
541
|
}(gLite.AbstractRenderer);
|
|
632
542
|
|