@antv/g-webgpu 1.1.2 → 1.1.3
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/{es → dist}/ContextRegisterPlugin.d.ts +8 -7
- package/dist/ContextRegisterPlugin.d.ts.map +1 -0
- package/{lib → dist}/WebGLContextService.d.ts +19 -18
- package/dist/WebGLContextService.d.ts.map +1 -0
- package/{lib → dist}/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +205 -0
- package/dist/index.js +230 -0
- package/dist/index.umd.js +18322 -0
- package/dist/index.umd.min.js +9 -16
- package/package.json +26 -31
- package/es/ContextRegisterPlugin.js +0 -28
- package/es/WebGLContextService.d.ts +0 -18
- package/es/WebGLContextService.js +0 -99
- package/es/index.d.ts +0 -10
- package/es/index.js +0 -34
- package/lib/ContextRegisterPlugin.d.ts +0 -7
- package/lib/ContextRegisterPlugin.js +0 -37
- package/lib/WebGLContextService.js +0 -107
- package/lib/index.js +0 -58
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { Syringe } from 'mana-syringe';
|
|
2
|
-
import type { RendererPlugin } from '@antv/g';
|
|
3
|
-
export declare class ContextRegisterPlugin implements RendererPlugin {
|
|
4
|
-
name: string;
|
|
5
|
-
init(container: Syringe.Container): void;
|
|
6
|
-
destroy(container: Syringe.Container): void;
|
|
7
|
-
}
|
|
1
|
+
import type { Syringe } from 'mana-syringe';
|
|
2
|
+
import type { RendererPlugin } from '@antv/g';
|
|
3
|
+
export declare class ContextRegisterPlugin implements RendererPlugin {
|
|
4
|
+
name: string;
|
|
5
|
+
init(container: Syringe.Container): void;
|
|
6
|
+
destroy(container: Syringe.Container): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ContextRegisterPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextRegisterPlugin.d.ts","sourceRoot":"","sources":["../src/ContextRegisterPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAU9C,qBAAa,qBAAsB,YAAW,cAAc;IAC1D,IAAI,SAA6B;IACjC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;IAGxC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,SAAS,GAAG,IAAI;CAG5C"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
/// <reference types="offscreencanvas" />
|
|
2
|
-
/// <reference types="@webgpu/types" />
|
|
3
|
-
import { ContextService } from '@antv/g';
|
|
4
|
-
export declare class WebGLContextService implements ContextService<WebGLRenderingContext> {
|
|
5
|
-
private $container;
|
|
6
|
-
private $canvas;
|
|
7
|
-
private dpr;
|
|
8
|
-
private context;
|
|
9
|
-
private canvasConfig;
|
|
10
|
-
init(): void;
|
|
11
|
-
getDomElement(): OffscreenCanvas | HTMLCanvasElement;
|
|
12
|
-
getContext(): WebGLRenderingContext;
|
|
13
|
-
getBoundingClientRect(): DOMRect;
|
|
14
|
-
destroy(): void;
|
|
15
|
-
resize(width: number, height: number): void;
|
|
16
|
-
getDPR(): number;
|
|
17
|
-
applyCursorStyle(cursor: string): void;
|
|
18
|
-
}
|
|
1
|
+
/// <reference types="offscreencanvas" />
|
|
2
|
+
/// <reference types="@webgpu/types" />
|
|
3
|
+
import { ContextService } from '@antv/g';
|
|
4
|
+
export declare class WebGLContextService implements ContextService<WebGLRenderingContext> {
|
|
5
|
+
private $container;
|
|
6
|
+
private $canvas;
|
|
7
|
+
private dpr;
|
|
8
|
+
private context;
|
|
9
|
+
private canvasConfig;
|
|
10
|
+
init(): void;
|
|
11
|
+
getDomElement(): OffscreenCanvas | HTMLCanvasElement;
|
|
12
|
+
getContext(): WebGLRenderingContext;
|
|
13
|
+
getBoundingClientRect(): DOMRect;
|
|
14
|
+
destroy(): void;
|
|
15
|
+
resize(width: number, height: number): void;
|
|
16
|
+
getDPR(): number;
|
|
17
|
+
applyCursorStyle(cursor: string): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=WebGLContextService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebGLContextService.d.ts","sourceRoot":"","sources":["../src/WebGLContextService.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAgB,cAAc,EAAmC,MAAM,SAAS,CAAC;AAGxF,qBACa,mBAAoB,YAAW,cAAc,CAAC,qBAAqB,CAAC;IAC/E,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,OAAO,CAA6C;IAC5D,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAA+B;IAG9C,OAAO,CAAC,YAAY,CAAe;IAEnC,IAAI;IAgCJ,aAAa;IAIb,UAAU;IAIV,qBAAqB;IAMrB,OAAO;IAQP,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAapC,MAAM;IAIN,gBAAgB,CAAC,MAAM,EAAE,MAAM;CAKhC"}
|
package/{lib → dist}/index.d.ts
RENAMED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { RendererConfig } from '@antv/g';
|
|
2
|
-
import { AbstractRenderer } from '@antv/g';
|
|
3
|
-
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
4
|
-
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
5
|
-
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
6
|
-
export { DomInteraction, DeviceRenderer, WebGPUDevice };
|
|
7
|
-
declare type WebGPURendererConfig = RendererConfig;
|
|
8
|
-
export declare class Renderer extends AbstractRenderer {
|
|
9
|
-
constructor(config?: Partial<WebGPURendererConfig>);
|
|
10
|
-
}
|
|
1
|
+
import type { RendererConfig } from '@antv/g';
|
|
2
|
+
import { AbstractRenderer } from '@antv/g';
|
|
3
|
+
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
4
|
+
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
5
|
+
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
6
|
+
export { DomInteraction, DeviceRenderer, WebGPUDevice };
|
|
7
|
+
declare type WebGPURendererConfig = RendererConfig;
|
|
8
|
+
export declare class Renderer extends AbstractRenderer {
|
|
9
|
+
constructor(config?: Partial<WebGPURendererConfig>);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,cAAc,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,YAAY,MAAM,8BAA8B,CAAC;AAI7D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC;AAExD,aAAK,oBAAoB,GAAG,cAAc,CAAC;AAE3C,qBAAa,QAAS,SAAQ,gBAAgB;gBAChC,MAAM,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC;CASnD"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { CanvasConfig, ContextService, isString, setDOMSize, isBrowser, AbstractRenderer } from '@antv/g';
|
|
2
|
+
import { Plugin as Plugin$2 } from '@antv/g-plugin-dom-interaction';
|
|
3
|
+
import * as DomInteraction from '@antv/g-plugin-dom-interaction';
|
|
4
|
+
export { DomInteraction };
|
|
5
|
+
import { Plugin as Plugin$1 } from '@antv/g-plugin-device-renderer';
|
|
6
|
+
import * as DeviceRenderer from '@antv/g-plugin-device-renderer';
|
|
7
|
+
export { DeviceRenderer };
|
|
8
|
+
import { Plugin } from '@antv/g-plugin-webgpu-device';
|
|
9
|
+
import * as WebGPUDevice from '@antv/g-plugin-webgpu-device';
|
|
10
|
+
export { WebGPUDevice };
|
|
11
|
+
import { Plugin as Plugin$3 } from '@antv/g-plugin-html-renderer';
|
|
12
|
+
import { inject, singleton, Module } from 'mana-syringe';
|
|
13
|
+
|
|
14
|
+
function _inheritsLoose(subClass, superClass) {
|
|
15
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
16
|
+
subClass.prototype.constructor = subClass;
|
|
17
|
+
|
|
18
|
+
_setPrototypeOf(subClass, superClass);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _setPrototypeOf(o, p) {
|
|
22
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
23
|
+
o.__proto__ = p;
|
|
24
|
+
return o;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return _setPrototypeOf(o, p);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/******************************************************************************
|
|
31
|
+
Copyright (c) Microsoft Corporation.
|
|
32
|
+
|
|
33
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
34
|
+
purpose with or without fee is hereby granted.
|
|
35
|
+
|
|
36
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
37
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
38
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
39
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
40
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
41
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
42
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
43
|
+
***************************************************************************** */
|
|
44
|
+
|
|
45
|
+
function __decorate(decorators, target, key, desc) {
|
|
46
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
47
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
48
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
49
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function __metadata(metadataKey, metadataValue) {
|
|
53
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
var WebGLContextService = /*#__PURE__*/function () {
|
|
57
|
+
function WebGLContextService() {
|
|
58
|
+
this.$container = void 0;
|
|
59
|
+
this.$canvas = void 0;
|
|
60
|
+
this.dpr = void 0;
|
|
61
|
+
this.context = void 0;
|
|
62
|
+
this.canvasConfig = void 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
var _proto = WebGLContextService.prototype;
|
|
66
|
+
|
|
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;
|
|
72
|
+
|
|
73
|
+
if (canvas) {
|
|
74
|
+
this.$canvas = canvas;
|
|
75
|
+
|
|
76
|
+
if (container && canvas.parentElement !== container) {
|
|
77
|
+
container.appendChild(canvas);
|
|
78
|
+
}
|
|
79
|
+
|
|
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;
|
|
85
|
+
|
|
86
|
+
if (this.$container) {
|
|
87
|
+
// create canvas
|
|
88
|
+
var $canvas = document.createElement('canvas');
|
|
89
|
+
this.$container.appendChild($canvas);
|
|
90
|
+
|
|
91
|
+
if (!this.$container.style.position) {
|
|
92
|
+
this.$container.style.position = 'relative';
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
this.$canvas = $canvas;
|
|
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();
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_proto.destroy = function destroy() {
|
|
120
|
+
// @ts-ignore
|
|
121
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
122
|
+
// @ts-ignore
|
|
123
|
+
this.$container.removeChild(this.$canvas);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
_proto.resize = function resize(width, height) {
|
|
128
|
+
if (this.$canvas) {
|
|
129
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
130
|
+
|
|
131
|
+
this.$canvas.width = dpr * width;
|
|
132
|
+
this.$canvas.height = dpr * height; // set CSS style width & height
|
|
133
|
+
|
|
134
|
+
setDOMSize(this.$canvas, width, height);
|
|
135
|
+
}
|
|
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;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
return WebGLContextService;
|
|
149
|
+
}();
|
|
150
|
+
|
|
151
|
+
__decorate([inject(CanvasConfig), __metadata("design:type", Object)], WebGLContextService.prototype, "canvasConfig", void 0);
|
|
152
|
+
|
|
153
|
+
WebGLContextService = __decorate([singleton({
|
|
154
|
+
token: ContextService
|
|
155
|
+
})], WebGLContextService);
|
|
156
|
+
|
|
157
|
+
var containerModule = Module(function (register) {
|
|
158
|
+
/**
|
|
159
|
+
* implements ContextService
|
|
160
|
+
*/
|
|
161
|
+
register(WebGLContextService);
|
|
162
|
+
});
|
|
163
|
+
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
164
|
+
function ContextRegisterPlugin() {
|
|
165
|
+
this.name = 'webgpu-context-register';
|
|
166
|
+
}
|
|
167
|
+
|
|
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
|
+
};
|
|
177
|
+
|
|
178
|
+
return ContextRegisterPlugin;
|
|
179
|
+
}();
|
|
180
|
+
|
|
181
|
+
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
182
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
183
|
+
|
|
184
|
+
function Renderer(config) {
|
|
185
|
+
var _this;
|
|
186
|
+
|
|
187
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
188
|
+
|
|
189
|
+
_this.registerPlugin(new ContextRegisterPlugin());
|
|
190
|
+
|
|
191
|
+
_this.registerPlugin(new Plugin());
|
|
192
|
+
|
|
193
|
+
_this.registerPlugin(new Plugin$1());
|
|
194
|
+
|
|
195
|
+
_this.registerPlugin(new Plugin$2());
|
|
196
|
+
|
|
197
|
+
_this.registerPlugin(new Plugin$3());
|
|
198
|
+
|
|
199
|
+
return _this;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return Renderer;
|
|
203
|
+
}(AbstractRenderer);
|
|
204
|
+
|
|
205
|
+
export { Renderer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var g = require('@antv/g');
|
|
6
|
+
var DomInteraction = require('@antv/g-plugin-dom-interaction');
|
|
7
|
+
var DeviceRenderer = require('@antv/g-plugin-device-renderer');
|
|
8
|
+
var WebGPUDevice = require('@antv/g-plugin-webgpu-device');
|
|
9
|
+
var HTMLRenderer = require('@antv/g-plugin-html-renderer');
|
|
10
|
+
var manaSyringe = require('mana-syringe');
|
|
11
|
+
|
|
12
|
+
function _interopNamespace(e) {
|
|
13
|
+
if (e && e.__esModule) return e;
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return e[k];
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
n['default'] = e;
|
|
29
|
+
return Object.freeze(n);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var DomInteraction__namespace = /*#__PURE__*/_interopNamespace(DomInteraction);
|
|
33
|
+
var DeviceRenderer__namespace = /*#__PURE__*/_interopNamespace(DeviceRenderer);
|
|
34
|
+
var WebGPUDevice__namespace = /*#__PURE__*/_interopNamespace(WebGPUDevice);
|
|
35
|
+
|
|
36
|
+
function _inheritsLoose(subClass, superClass) {
|
|
37
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
38
|
+
subClass.prototype.constructor = subClass;
|
|
39
|
+
|
|
40
|
+
_setPrototypeOf(subClass, superClass);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function _setPrototypeOf(o, p) {
|
|
44
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
45
|
+
o.__proto__ = p;
|
|
46
|
+
return o;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return _setPrototypeOf(o, p);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/******************************************************************************
|
|
53
|
+
Copyright (c) Microsoft Corporation.
|
|
54
|
+
|
|
55
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
56
|
+
purpose with or without fee is hereby granted.
|
|
57
|
+
|
|
58
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
59
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
60
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
61
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
62
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
63
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
64
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
65
|
+
***************************************************************************** */
|
|
66
|
+
|
|
67
|
+
function __decorate(decorators, target, key, desc) {
|
|
68
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
69
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
70
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
71
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function __metadata(metadataKey, metadataValue) {
|
|
75
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var WebGLContextService = /*#__PURE__*/function () {
|
|
79
|
+
function WebGLContextService() {
|
|
80
|
+
this.$container = void 0;
|
|
81
|
+
this.$canvas = void 0;
|
|
82
|
+
this.dpr = void 0;
|
|
83
|
+
this.context = void 0;
|
|
84
|
+
this.canvasConfig = void 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
var _proto = WebGLContextService.prototype;
|
|
88
|
+
|
|
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;
|
|
94
|
+
|
|
95
|
+
if (canvas) {
|
|
96
|
+
this.$canvas = canvas;
|
|
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';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.$canvas = $canvas;
|
|
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();
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
_proto.destroy = function destroy() {
|
|
142
|
+
// @ts-ignore
|
|
143
|
+
if (this.$container && this.$canvas && this.$canvas.parentNode) {
|
|
144
|
+
// @ts-ignore
|
|
145
|
+
this.$container.removeChild(this.$canvas);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
_proto.resize = function resize(width, height) {
|
|
150
|
+
if (this.$canvas) {
|
|
151
|
+
var dpr = this.getDPR(); // set canvas width & height
|
|
152
|
+
|
|
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);
|
|
157
|
+
}
|
|
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;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return WebGLContextService;
|
|
171
|
+
}();
|
|
172
|
+
|
|
173
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], WebGLContextService.prototype, "canvasConfig", void 0);
|
|
174
|
+
|
|
175
|
+
WebGLContextService = __decorate([manaSyringe.singleton({
|
|
176
|
+
token: g.ContextService
|
|
177
|
+
})], WebGLContextService);
|
|
178
|
+
|
|
179
|
+
var containerModule = manaSyringe.Module(function (register) {
|
|
180
|
+
/**
|
|
181
|
+
* implements ContextService
|
|
182
|
+
*/
|
|
183
|
+
register(WebGLContextService);
|
|
184
|
+
});
|
|
185
|
+
var ContextRegisterPlugin = /*#__PURE__*/function () {
|
|
186
|
+
function ContextRegisterPlugin() {
|
|
187
|
+
this.name = 'webgpu-context-register';
|
|
188
|
+
}
|
|
189
|
+
|
|
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
|
+
};
|
|
199
|
+
|
|
200
|
+
return ContextRegisterPlugin;
|
|
201
|
+
}();
|
|
202
|
+
|
|
203
|
+
var Renderer = /*#__PURE__*/function (_AbstractRenderer) {
|
|
204
|
+
_inheritsLoose(Renderer, _AbstractRenderer);
|
|
205
|
+
|
|
206
|
+
function Renderer(config) {
|
|
207
|
+
var _this;
|
|
208
|
+
|
|
209
|
+
_this = _AbstractRenderer.call(this, config) || this;
|
|
210
|
+
|
|
211
|
+
_this.registerPlugin(new ContextRegisterPlugin());
|
|
212
|
+
|
|
213
|
+
_this.registerPlugin(new WebGPUDevice.Plugin());
|
|
214
|
+
|
|
215
|
+
_this.registerPlugin(new DeviceRenderer.Plugin());
|
|
216
|
+
|
|
217
|
+
_this.registerPlugin(new DomInteraction.Plugin());
|
|
218
|
+
|
|
219
|
+
_this.registerPlugin(new HTMLRenderer.Plugin());
|
|
220
|
+
|
|
221
|
+
return _this;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return Renderer;
|
|
225
|
+
}(g.AbstractRenderer);
|
|
226
|
+
|
|
227
|
+
exports.DomInteraction = DomInteraction__namespace;
|
|
228
|
+
exports.DeviceRenderer = DeviceRenderer__namespace;
|
|
229
|
+
exports.WebGPUDevice = WebGPUDevice__namespace;
|
|
230
|
+
exports.Renderer = Renderer;
|