@antv/l7-renderer 2.17.12 → 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,237 +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_l7_utils = require("@antv/l7-utils");
45
- var import_inversify = require("inversify");
46
- var import_l7regl = __toESM(require("l7regl"));
47
- var import_reflect_metadata = require("reflect-metadata");
48
- var import_ReglAttribute = __toESM(require("./ReglAttribute"));
49
- var import_ReglBuffer = __toESM(require("./ReglBuffer"));
50
- var import_ReglElements = __toESM(require("./ReglElements"));
51
- var import_ReglFramebuffer = __toESM(require("./ReglFramebuffer"));
52
- var import_ReglModel = __toESM(require("./ReglModel"));
53
- var import_ReglTexture2D = __toESM(require("./ReglTexture2D"));
54
- var ReglRendererService = class {
55
- constructor() {
56
- this.createModel = (options) => new import_ReglModel.default(this.gl, options);
57
- this.createAttribute = (options) => new import_ReglAttribute.default(this.gl, options);
58
- this.createBuffer = (options) => new import_ReglBuffer.default(this.gl, options);
59
- this.createElements = (options) => new import_ReglElements.default(this.gl, options);
60
- this.createTexture2D = (options) => new import_ReglTexture2D.default(this.gl, options);
61
- this.createFramebuffer = (options) => new import_ReglFramebuffer.default(this.gl, options);
62
- this.useFramebuffer = (framebuffer, drawCommands) => {
63
- this.gl({
64
- framebuffer: framebuffer ? framebuffer.get() : null
65
- })(drawCommands);
66
- };
67
- this.clear = (options) => {
68
- var _a;
69
- const { color, depth, stencil, framebuffer = null } = options;
70
- const reglClearOptions = {
71
- color,
72
- depth,
73
- stencil
74
- };
75
- reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
76
- (_a = this.gl) == null ? void 0 : _a.clear(reglClearOptions);
77
- };
78
- this.viewport = ({
79
- x,
80
- y,
81
- width,
82
- height
83
- }) => {
84
- this.gl._gl.viewport(x, y, width, height);
85
- this.width = width;
86
- this.height = height;
87
- this.gl._refresh();
88
- };
89
- this.readPixels = (options) => {
90
- const { framebuffer, x, y, width, height } = options;
91
- const readPixelsOptions = {
92
- x,
93
- y,
94
- width,
95
- height
96
- };
97
- if (framebuffer) {
98
- readPixelsOptions.framebuffer = framebuffer.get();
99
- }
100
- return this.gl.read(readPixelsOptions);
101
- };
102
- this.getViewportSize = () => {
103
- return {
104
- width: this.gl._gl.drawingBufferWidth,
105
- height: this.gl._gl.drawingBufferHeight
106
- };
107
- };
108
- this.getContainer = () => {
109
- var _a;
110
- if (import_l7_utils.isMini) {
111
- return this.canvas;
112
- } else {
113
- return (_a = this.canvas) == null ? void 0 : _a.parentElement;
114
- }
115
- };
116
- this.getCanvas = () => {
117
- return this.canvas;
118
- };
119
- this.getGLContext = () => {
120
- return this.gl._gl;
121
- };
122
- this.destroy = () => {
123
- var _a, _b, _c;
124
- this.canvas = null;
125
- (_c = (_b = (_a = this.gl) == null ? void 0 : _a._gl) == null ? void 0 : _b.getExtension("WEBGL_lose_context")) == null ? void 0 : _c.loseContext();
126
- this.gl.destroy();
127
- this.gl = null;
128
- };
129
- }
130
- async init(canvas, cfg, gl) {
131
- this.canvas = canvas;
132
- if (gl) {
133
- this.gl = gl;
134
- } else {
135
- this.gl = await new Promise((resolve, reject) => {
136
- (0, import_l7regl.default)({
137
- canvas: this.canvas,
138
- attributes: {
139
- alpha: true,
140
- // use TAA instead of MSAA
141
- // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
142
- antialias: cfg.antialias,
143
- premultipliedAlpha: true,
144
- preserveDrawingBuffer: cfg.preserveDrawingBuffer,
145
- stencil: cfg.stencil
146
- },
147
- // TODO: use extensions
148
- extensions: [
149
- "OES_element_index_uint",
150
- "OES_standard_derivatives",
151
- // wireframe
152
- "ANGLE_instanced_arrays"
153
- // VSM shadow map
154
- ],
155
- optionalExtensions: [
156
- "oes_texture_float_linear",
157
- "OES_texture_float",
158
- "EXT_texture_filter_anisotropic",
159
- "EXT_blend_minmax",
160
- "WEBGL_depth_texture",
161
- "WEBGL_lose_context"
162
- ],
163
- profile: true,
164
- onDone: (err, r) => {
165
- if (err || !r) {
166
- reject(err);
167
- }
168
- resolve(r);
169
- }
170
- });
171
- });
172
- }
173
- this.extensionObject = {
174
- OES_texture_float: this.testExtension("OES_texture_float")
175
- };
176
- }
177
- getPointSizeRange() {
178
- return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
179
- }
180
- testExtension(name) {
181
- return !!this.getGLContext().getExtension(name);
182
- }
183
- // TODO: 临时方法
184
- setState() {
185
- this.gl({
186
- cull: {
187
- enable: false,
188
- face: "back"
189
- },
190
- viewport: {
191
- x: 0,
192
- y: 0,
193
- height: this.width,
194
- width: this.height
195
- },
196
- blend: {
197
- enable: true,
198
- equation: "add"
199
- },
200
- framebuffer: null
201
- });
202
- this.gl._refresh();
203
- }
204
- setBaseState() {
205
- this.gl({
206
- cull: {
207
- enable: false,
208
- face: "back"
209
- },
210
- viewport: {
211
- x: 0,
212
- y: 0,
213
- height: this.width,
214
- width: this.height
215
- },
216
- blend: {
217
- enable: false,
218
- equation: "add"
219
- },
220
- framebuffer: null
221
- });
222
- this.gl._refresh();
223
- }
224
- setCustomLayerDefaults() {
225
- const gl = this.getGLContext();
226
- gl.disable(gl.CULL_FACE);
227
- }
228
- setDirty(flag) {
229
- this.isDirty = flag;
230
- }
231
- getDirty() {
232
- return this.isDirty;
233
- }
234
- };
235
- ReglRendererService = __decorateClass([
236
- (0, import_inversify.injectable)()
237
- ], ReglRendererService);