@antv/l7-renderer 2.9.37-alpha.1 → 2.9.37-alpha.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,225 +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(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
- var __decorateClass = (decorators, target, key, kind) => {
22
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
23
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
24
- if (decorator = decorators[i])
25
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
26
- if (kind && result)
27
- __defProp(target, key, result);
28
- return result;
29
- };
30
-
31
- // src/regl/index.ts
32
- var regl_exports = {};
33
- __export(regl_exports, {
34
- default: () => ReglRendererService
35
- });
36
- module.exports = __toCommonJS(regl_exports);
37
- var import_l7_utils = require("@antv/l7-utils");
38
- var import_inversify = require("inversify");
39
- var import_l7regl = __toESM(require("l7regl"));
40
- var import_reflect_metadata = require("reflect-metadata");
41
- var import_ReglAttribute = __toESM(require("./ReglAttribute"));
42
- var import_ReglBuffer = __toESM(require("./ReglBuffer"));
43
- var import_ReglElements = __toESM(require("./ReglElements"));
44
- var import_ReglFramebuffer = __toESM(require("./ReglFramebuffer"));
45
- var import_ReglModel = __toESM(require("./ReglModel"));
46
- var import_ReglTexture2D = __toESM(require("./ReglTexture2D"));
47
- var ReglRendererService = class {
48
- constructor() {
49
- this.createModel = (options) => new import_ReglModel.default(this.gl, options);
50
- this.createAttribute = (options) => new import_ReglAttribute.default(this.gl, options);
51
- this.createBuffer = (options) => new import_ReglBuffer.default(this.gl, options);
52
- this.createElements = (options) => new import_ReglElements.default(this.gl, options);
53
- this.createTexture2D = (options) => new import_ReglTexture2D.default(this.gl, options);
54
- this.createFramebuffer = (options) => new import_ReglFramebuffer.default(this.gl, options);
55
- this.useFramebuffer = (framebuffer, drawCommands) => {
56
- this.gl({
57
- framebuffer: framebuffer ? framebuffer.get() : null
58
- })(drawCommands);
59
- };
60
- this.clear = (options) => {
61
- var _a;
62
- const { color, depth, stencil, framebuffer = null } = options;
63
- const reglClearOptions = {
64
- color,
65
- depth,
66
- stencil
67
- };
68
- reglClearOptions.framebuffer = framebuffer === null ? framebuffer : framebuffer.get();
69
- (_a = this.gl) == null ? void 0 : _a.clear(reglClearOptions);
70
- };
71
- this.viewport = ({
72
- x,
73
- y,
74
- width,
75
- height
76
- }) => {
77
- this.gl._gl.viewport(x, y, width, height);
78
- this.width = width;
79
- this.height = height;
80
- this.gl._refresh();
81
- };
82
- this.readPixels = (options) => {
83
- const { framebuffer, x, y, width, height } = options;
84
- const readPixelsOptions = {
85
- x,
86
- y,
87
- width,
88
- height
89
- };
90
- if (framebuffer) {
91
- readPixelsOptions.framebuffer = framebuffer.get();
92
- }
93
- return this.gl.read(readPixelsOptions);
94
- };
95
- this.getViewportSize = () => {
96
- return {
97
- width: this.gl._gl.drawingBufferWidth,
98
- height: this.gl._gl.drawingBufferHeight
99
- };
100
- };
101
- this.getContainer = () => {
102
- var _a;
103
- if (import_l7_utils.isMini) {
104
- return this.canvas;
105
- } else {
106
- return (_a = this.canvas) == null ? void 0 : _a.parentElement;
107
- }
108
- };
109
- this.getCanvas = () => {
110
- return this.canvas;
111
- };
112
- this.getGLContext = () => {
113
- return this.gl._gl;
114
- };
115
- this.destroy = () => {
116
- var _a, _b, _c;
117
- this.canvas = null;
118
- (_c = (_b = (_a = this.gl) == null ? void 0 : _a._gl) == null ? void 0 : _b.getExtension("WEBGL_lose_context")) == null ? void 0 : _c.loseContext();
119
- this.gl.destroy();
120
- this.gl = null;
121
- };
122
- }
123
- async init(canvas, cfg, gl) {
124
- this.canvas = canvas;
125
- if (gl) {
126
- this.gl = gl;
127
- } else {
128
- this.gl = await new Promise((resolve, reject) => {
129
- (0, import_l7regl.default)({
130
- canvas: this.canvas,
131
- attributes: {
132
- alpha: true,
133
- antialias: cfg.antialias,
134
- premultipliedAlpha: true,
135
- preserveDrawingBuffer: cfg.preserveDrawingBuffer,
136
- stencil: cfg.stencil
137
- },
138
- extensions: [
139
- "OES_element_index_uint",
140
- "OES_standard_derivatives",
141
- "ANGLE_instanced_arrays"
142
- ],
143
- optionalExtensions: [
144
- "oes_texture_float_linear",
145
- "OES_texture_float",
146
- "EXT_texture_filter_anisotropic",
147
- "EXT_blend_minmax",
148
- "WEBGL_depth_texture"
149
- ],
150
- profile: true,
151
- onDone: (err, r) => {
152
- if (err || !r) {
153
- reject(err);
154
- }
155
- resolve(r);
156
- }
157
- });
158
- });
159
- }
160
- this.extensionObject = {
161
- OES_texture_float: this.testExtension("OES_texture_float")
162
- };
163
- }
164
- getPointSizeRange() {
165
- return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
166
- }
167
- testExtension(name) {
168
- return !!this.getGLContext().getExtension(name);
169
- }
170
- setState() {
171
- this.gl({
172
- cull: {
173
- enable: false,
174
- face: "back"
175
- },
176
- viewport: {
177
- x: 0,
178
- y: 0,
179
- height: this.width,
180
- width: this.height
181
- },
182
- blend: {
183
- enable: true,
184
- equation: "add"
185
- },
186
- framebuffer: null
187
- });
188
- this.gl._refresh();
189
- }
190
- setBaseState() {
191
- this.gl({
192
- cull: {
193
- enable: false,
194
- face: "back"
195
- },
196
- viewport: {
197
- x: 0,
198
- y: 0,
199
- height: this.width,
200
- width: this.height
201
- },
202
- blend: {
203
- enable: false,
204
- equation: "add"
205
- },
206
- framebuffer: null
207
- });
208
- this.gl._refresh();
209
- }
210
- setCustomLayerDefaults() {
211
- const gl = this.getGLContext();
212
- gl.disable(gl.CULL_FACE);
213
- }
214
- setDirty(flag) {
215
- this.isDirty = flag;
216
- }
217
- getDirty() {
218
- return this.isDirty;
219
- }
220
- };
221
- ReglRendererService = __decorateClass([
222
- (0, import_inversify.injectable)()
223
- ], ReglRendererService);
224
- // Annotate the CommonJS export names for ESM import in node:
225
- 0 && (module.exports = {});