@antv/l7-renderer 2.18.0 → 2.18.2

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/lib/regl/index.js DELETED
@@ -1,232 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var __decorateClass = (decorators, target, key, kind) => {
29
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
30
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
31
- if (decorator = decorators[i])
32
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
33
- if (kind && result)
34
- __defProp(target, key, result);
35
- return result;
36
- };
37
-
38
- // src/regl/index.ts
39
- var regl_exports = {};
40
- __export(regl_exports, {
41
- default: () => ReglRendererService
42
- });
43
- module.exports = __toCommonJS(regl_exports);
44
- var import_inversify = require("inversify");
45
- var import_reflect_metadata = require("reflect-metadata");
46
- var import_regl = __toESM(require("regl"));
47
- var import_ReglAttribute = __toESM(require("./ReglAttribute"));
48
- var import_ReglBuffer = __toESM(require("./ReglBuffer"));
49
- var import_ReglElements = __toESM(require("./ReglElements"));
50
- var import_ReglFramebuffer = __toESM(require("./ReglFramebuffer"));
51
- var import_ReglModel = __toESM(require("./ReglModel"));
52
- var import_ReglTexture2D = __toESM(require("./ReglTexture2D"));
53
- var ReglRendererService = class {
54
- constructor() {
55
- this.createModel = (options) => new import_ReglModel.default(this.gl, options);
56
- this.createAttribute = (options) => new import_ReglAttribute.default(this.gl, options);
57
- this.createBuffer = (options) => new import_ReglBuffer.default(this.gl, options);
58
- this.createElements = (options) => new import_ReglElements.default(this.gl, options);
59
- this.createTexture2D = (options) => new import_ReglTexture2D.default(this.gl, options);
60
- this.createFramebuffer = (options) => new import_ReglFramebuffer.default(this.gl, options);
61
- this.useFramebuffer = (framebuffer, drawCommands) => {
62
- this.gl({
63
- framebuffer: framebuffer ? framebuffer.get() : null
64
- })(drawCommands);
65
- };
66
- this.clear = (options) => {
67
- var _a;
68
- const { color, depth, stencil, framebuffer = null } = options;
69
- const reglClearOptions = {
70
- color,
71
- depth,
72
- stencil
73
- };
74
- reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
75
- (_a = this.gl) == null ? void 0 : _a.clear(reglClearOptions);
76
- };
77
- this.viewport = ({
78
- x,
79
- y,
80
- width,
81
- height
82
- }) => {
83
- this.gl._gl.viewport(x, y, width, height);
84
- this.width = width;
85
- this.height = height;
86
- this.gl._refresh();
87
- };
88
- this.readPixels = (options) => {
89
- const { framebuffer, x, y, width, height } = options;
90
- const readPixelsOptions = {
91
- x,
92
- y,
93
- width,
94
- height
95
- };
96
- if (framebuffer) {
97
- readPixelsOptions.framebuffer = framebuffer.get();
98
- }
99
- return this.gl.read(readPixelsOptions);
100
- };
101
- this.getViewportSize = () => {
102
- return {
103
- width: this.gl._gl.drawingBufferWidth,
104
- height: this.gl._gl.drawingBufferHeight
105
- };
106
- };
107
- this.getContainer = () => {
108
- var _a;
109
- return (_a = this.canvas) == null ? void 0 : _a.parentElement;
110
- };
111
- this.getCanvas = () => {
112
- return this.canvas;
113
- };
114
- this.getGLContext = () => {
115
- return this.gl._gl;
116
- };
117
- this.destroy = () => {
118
- var _a, _b, _c;
119
- this.canvas = null;
120
- (_c = (_b = (_a = this.gl) == null ? void 0 : _a._gl) == null ? void 0 : _b.getExtension("WEBGL_lose_context")) == null ? void 0 : _c.loseContext();
121
- this.gl.destroy();
122
- this.gl = null;
123
- };
124
- }
125
- async init(canvas, cfg, gl) {
126
- this.canvas = canvas;
127
- if (gl) {
128
- this.gl = gl;
129
- } else {
130
- this.gl = await new Promise((resolve, reject) => {
131
- (0, import_regl.default)({
132
- canvas: this.canvas,
133
- attributes: {
134
- alpha: true,
135
- // use TAA instead of MSAA
136
- // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
137
- antialias: cfg.antialias,
138
- premultipliedAlpha: true,
139
- preserveDrawingBuffer: cfg.preserveDrawingBuffer,
140
- stencil: cfg.stencil
141
- },
142
- // TODO: use extensions
143
- extensions: [
144
- "OES_element_index_uint",
145
- "OES_standard_derivatives",
146
- // wireframe
147
- "ANGLE_instanced_arrays"
148
- // VSM shadow map
149
- ],
150
- optionalExtensions: [
151
- "oes_texture_float_linear",
152
- "OES_texture_float",
153
- "EXT_texture_filter_anisotropic",
154
- "EXT_blend_minmax",
155
- "WEBGL_depth_texture",
156
- "WEBGL_lose_context"
157
- ],
158
- profile: true,
159
- onDone: (err, r) => {
160
- if (err || !r) {
161
- reject(err);
162
- }
163
- resolve(r);
164
- }
165
- });
166
- });
167
- }
168
- this.extensionObject = {
169
- OES_texture_float: this.testExtension("OES_texture_float")
170
- };
171
- }
172
- getPointSizeRange() {
173
- return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
174
- }
175
- testExtension(name) {
176
- return !!this.getGLContext().getExtension(name);
177
- }
178
- // TODO: 临时方法
179
- setState() {
180
- this.gl({
181
- cull: {
182
- enable: false,
183
- face: "back"
184
- },
185
- viewport: {
186
- x: 0,
187
- y: 0,
188
- height: this.width,
189
- width: this.height
190
- },
191
- blend: {
192
- enable: true,
193
- equation: "add"
194
- },
195
- framebuffer: null
196
- });
197
- this.gl._refresh();
198
- }
199
- setBaseState() {
200
- this.gl({
201
- cull: {
202
- enable: false,
203
- face: "back"
204
- },
205
- viewport: {
206
- x: 0,
207
- y: 0,
208
- height: this.width,
209
- width: this.height
210
- },
211
- blend: {
212
- enable: false,
213
- equation: "add"
214
- },
215
- framebuffer: null
216
- });
217
- this.gl._refresh();
218
- }
219
- setCustomLayerDefaults() {
220
- const gl = this.getGLContext();
221
- gl.disable(gl.CULL_FACE);
222
- }
223
- setDirty(flag) {
224
- this.isDirty = flag;
225
- }
226
- getDirty() {
227
- return this.isDirty;
228
- }
229
- };
230
- ReglRendererService = __decorateClass([
231
- (0, import_inversify.injectable)()
232
- ], ReglRendererService);