@antv/g-webgpu 1.1.3 → 1.1.6
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/WebGLContextService.d.ts +2 -3
- package/dist/WebGLContextService.d.ts.map +1 -1
- package/dist/index.esm.js +193 -82
- package/dist/index.js +193 -82
- package/dist/index.umd.js +7646 -6520
- package/dist/index.umd.min.js +5 -5
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -33,11 +33,54 @@ var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
|
|
|
33
33
|
var DeviceRenderer__namespace = /*#__PURE__*/_interopNamespace(DeviceRenderer);
|
|
34
34
|
var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespace(WebGPUDevice);
|
|
35
35
|
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
function _classCallCheck(instance, Constructor) {
|
|
37
|
+
if (!(instance instanceof Constructor)) {
|
|
38
|
+
throw new TypeError("Cannot call a class as a function");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _defineProperties(target, props) {
|
|
43
|
+
for (var i = 0; i < props.length; i++) {
|
|
44
|
+
var descriptor = props[i];
|
|
45
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
46
|
+
descriptor.configurable = true;
|
|
47
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
48
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
53
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
54
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
55
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
56
|
+
writable: false
|
|
57
|
+
});
|
|
58
|
+
return Constructor;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function _inherits(subClass, superClass) {
|
|
62
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
63
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
64
|
+
}
|
|
39
65
|
|
|
40
|
-
|
|
66
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
67
|
+
constructor: {
|
|
68
|
+
value: subClass,
|
|
69
|
+
writable: true,
|
|
70
|
+
configurable: true
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
Object.defineProperty(subClass, "prototype", {
|
|
74
|
+
writable: false
|
|
75
|
+
});
|
|
76
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function _getPrototypeOf(o) {
|
|
80
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
81
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
82
|
+
};
|
|
83
|
+
return _getPrototypeOf(o);
|
|
41
84
|
}
|
|
42
85
|
|
|
43
86
|
function _setPrototypeOf(o, p) {
|
|
@@ -49,6 +92,56 @@ function _setPrototypeOf(o, p) {
|
|
|
49
92
|
return _setPrototypeOf(o, p);
|
|
50
93
|
}
|
|
51
94
|
|
|
95
|
+
function _isNativeReflectConstruct() {
|
|
96
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
97
|
+
if (Reflect.construct.sham) return false;
|
|
98
|
+
if (typeof Proxy === "function") return true;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
102
|
+
return true;
|
|
103
|
+
} catch (e) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function _assertThisInitialized(self) {
|
|
109
|
+
if (self === void 0) {
|
|
110
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return self;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function _possibleConstructorReturn(self, call) {
|
|
117
|
+
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
118
|
+
return call;
|
|
119
|
+
} else if (call !== void 0) {
|
|
120
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return _assertThisInitialized(self);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function _createSuper(Derived) {
|
|
127
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
128
|
+
|
|
129
|
+
return function _createSuperInternal() {
|
|
130
|
+
var Super = _getPrototypeOf(Derived),
|
|
131
|
+
result;
|
|
132
|
+
|
|
133
|
+
if (hasNativeReflectConstruct) {
|
|
134
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
135
|
+
|
|
136
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
137
|
+
} else {
|
|
138
|
+
result = Super.apply(this, arguments);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return _possibleConstructorReturn(this, result);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
52
145
|
/******************************************************************************
|
|
53
146
|
Copyright (c) Microsoft Corporation.
|
|
54
147
|
|
|
@@ -77,6 +170,8 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
77
170
|
|
|
78
171
|
var WebGLContextService = /*#__PURE__*/function () {
|
|
79
172
|
function WebGLContextService() {
|
|
173
|
+
_classCallCheck(this, WebGLContextService);
|
|
174
|
+
|
|
80
175
|
this.$container = void 0;
|
|
81
176
|
this.$canvas = void 0;
|
|
82
177
|
this.dpr = void 0;
|
|
@@ -84,88 +179,96 @@ var WebGLContextService = /*#__PURE__*/function () {
|
|
|
84
179
|
this.canvasConfig = void 0;
|
|
85
180
|
}
|
|
86
181
|
|
|
87
|
-
|
|
182
|
+
_createClass(WebGLContextService, [{
|
|
183
|
+
key: "init",
|
|
184
|
+
value: function init() {
|
|
185
|
+
var _this$canvasConfig = this.canvasConfig,
|
|
186
|
+
container = _this$canvasConfig.container,
|
|
187
|
+
canvas = _this$canvasConfig.canvas,
|
|
188
|
+
devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
88
189
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
container = _this$canvasConfig.container,
|
|
92
|
-
canvas = _this$canvasConfig.canvas,
|
|
93
|
-
devicePixelRatio = _this$canvasConfig.devicePixelRatio;
|
|
190
|
+
if (canvas) {
|
|
191
|
+
this.$canvas = canvas;
|
|
94
192
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (container && canvas.parentElement !== container) {
|
|
99
|
-
container.appendChild(canvas);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
this.$container = canvas.parentElement;
|
|
103
|
-
this.canvasConfig.container = this.$container;
|
|
104
|
-
} else if (container) {
|
|
105
|
-
// create container
|
|
106
|
-
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
107
|
-
|
|
108
|
-
if (this.$container) {
|
|
109
|
-
// create canvas
|
|
110
|
-
var $canvas = document.createElement('canvas');
|
|
111
|
-
this.$container.appendChild($canvas);
|
|
112
|
-
|
|
113
|
-
if (!this.$container.style.position) {
|
|
114
|
-
this.$container.style.position = 'relative';
|
|
193
|
+
if (container && canvas.parentElement !== container) {
|
|
194
|
+
container.appendChild(canvas);
|
|
115
195
|
}
|
|
116
196
|
|
|
117
|
-
this.$
|
|
118
|
-
|
|
119
|
-
|
|
197
|
+
this.$container = canvas.parentElement;
|
|
198
|
+
this.canvasConfig.container = this.$container;
|
|
199
|
+
} else if (container) {
|
|
200
|
+
// create container
|
|
201
|
+
this.$container = g.isString(container) ? document.getElementById(container) : container;
|
|
120
202
|
|
|
203
|
+
if (this.$container) {
|
|
204
|
+
// create canvas
|
|
205
|
+
var $canvas = document.createElement('canvas');
|
|
206
|
+
this.$container.appendChild($canvas);
|
|
121
207
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
};
|
|
208
|
+
if (!this.$container.style.position) {
|
|
209
|
+
this.$container.style.position = 'relative';
|
|
210
|
+
}
|
|
126
211
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
212
|
+
this.$canvas = $canvas;
|
|
213
|
+
}
|
|
214
|
+
} // use user-defined dpr first
|
|
130
215
|
|
|
131
|
-
_proto.getContext = function getContext() {
|
|
132
|
-
return this.context;
|
|
133
|
-
};
|
|
134
216
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
217
|
+
var dpr = devicePixelRatio || g.isBrowser && window.devicePixelRatio || 1;
|
|
218
|
+
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
|
|
219
|
+
this.dpr = dpr;
|
|
138
220
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
221
|
+
}, {
|
|
222
|
+
key: "getDomElement",
|
|
223
|
+
value: function getDomElement() {
|
|
224
|
+
return this.$canvas;
|
|
225
|
+
}
|
|
226
|
+
}, {
|
|
227
|
+
key: "getContext",
|
|
228
|
+
value: function getContext() {
|
|
229
|
+
return this.context;
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "getBoundingClientRect",
|
|
233
|
+
value: function getBoundingClientRect() {
|
|
234
|
+
if (this.$canvas.getBoundingClientRect) {
|
|
235
|
+
return this.$canvas.getBoundingClientRect();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}, {
|
|
239
|
+
key: "destroy",
|
|
240
|
+
value: function destroy() {
|
|
144
241
|
// @ts-ignore
|
|
145
|
-
this.$container
|
|
242
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
243
|
+
// @ts-ignore
|
|
244
|
+
this.$container.removeChild(this.$canvas);
|
|
245
|
+
}
|
|
146
246
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
247
|
+
}, {
|
|
248
|
+
key: "resize",
|
|
249
|
+
value: function resize(width, height) {
|
|
250
|
+
if (this.$canvas) {
|
|
251
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
152
252
|
|
|
153
|
-
|
|
154
|
-
|
|
253
|
+
this.$canvas.width = dpr * width;
|
|
254
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
155
255
|
|
|
156
|
-
|
|
256
|
+
g.setDOMSize(this.$canvas, width, height);
|
|
257
|
+
}
|
|
157
258
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
_proto.applyCursorStyle = function applyCursorStyle(cursor) {
|
|
165
|
-
if (this.$container && this.$container.style) {
|
|
166
|
-
this.$container.style.cursor = cursor;
|
|
259
|
+
}, {
|
|
260
|
+
key: "getDPR",
|
|
261
|
+
value: function getDPR() {
|
|
262
|
+
return this.dpr;
|
|
167
263
|
}
|
|
168
|
-
}
|
|
264
|
+
}, {
|
|
265
|
+
key: "applyCursorStyle",
|
|
266
|
+
value: function applyCursorStyle(cursor) {
|
|
267
|
+
if (this.$container && this.$container.style) {
|
|
268
|
+
this.$container.style.cursor = cursor;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}]);
|
|
169
272
|
|
|
170
273
|
return WebGLContextService;
|
|
171
274
|
}();
|
|
@@ -184,29 +287,37 @@ var containerModule = manaSyringe.Module(function (register) {
|
|
|
184
287
|
});
|
|
185
288
|
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
186
289
|
function ContextRegisterPlugin() {
|
|
290
|
+
_classCallCheck(this, ContextRegisterPlugin);
|
|
291
|
+
|
|
187
292
|
this.name = 'webgpu-context-register';
|
|
188
293
|
}
|
|
189
294
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
container
|
|
198
|
-
|
|
295
|
+
_createClass(ContextRegisterPlugin, [{
|
|
296
|
+
key: "init",
|
|
297
|
+
value: function init(container) {
|
|
298
|
+
container.load(containerModule, true);
|
|
299
|
+
}
|
|
300
|
+
}, {
|
|
301
|
+
key: "destroy",
|
|
302
|
+
value: function destroy(container) {
|
|
303
|
+
container.unload(containerModule);
|
|
304
|
+
}
|
|
305
|
+
}]);
|
|
199
306
|
|
|
200
307
|
return ContextRegisterPlugin;
|
|
201
308
|
}();
|
|
202
309
|
|
|
203
310
|
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
204
|
-
|
|
311
|
+
_inherits(Renderer, _AbstractRenderer);
|
|
312
|
+
|
|
313
|
+
var _super = _createSuper(Renderer);
|
|
205
314
|
|
|
206
315
|
function Renderer(config) {
|
|
207
316
|
var _this;
|
|
208
317
|
|
|
209
|
-
|
|
318
|
+
_classCallCheck(this, Renderer);
|
|
319
|
+
|
|
320
|
+
_this = _super.call(this, config);
|
|
210
321
|
|
|
211
322
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
212
323
|
|
|
@@ -221,7 +332,7 @@ var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
|
221
332
|
return _this;
|
|
222
333
|
}
|
|
223
334
|
|
|
224
|
-
return Renderer;
|
|
335
|
+
return _createClass(Renderer);
|
|
225
336
|
}(g.AbstractRenderer);
|
|
226
337
|
|
|
227
338
|
exports.DomInteraction = DomInteraction__namespace;
|