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