@antv/l7-renderer 2.18.2 → 2.18.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.
@@ -0,0 +1,170 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/regl/constants.ts
20
+ var constants_exports = {};
21
+ __export(constants_exports, {
22
+ blendEquationMap: () => blendEquationMap,
23
+ blendFuncMap: () => blendFuncMap,
24
+ colorSpaceMap: () => colorSpaceMap,
25
+ cullFaceMap: () => cullFaceMap,
26
+ dataTypeMap: () => dataTypeMap,
27
+ depthFuncMap: () => depthFuncMap,
28
+ filterMap: () => filterMap,
29
+ formatMap: () => formatMap,
30
+ mipmapMap: () => mipmapMap,
31
+ primitiveMap: () => primitiveMap,
32
+ stencilFuncMap: () => stencilFuncMap,
33
+ stencilOpMap: () => stencilOpMap,
34
+ usageMap: () => usageMap,
35
+ wrapModeMap: () => wrapModeMap
36
+ });
37
+ module.exports = __toCommonJS(constants_exports);
38
+ var import_l7_core = require("@antv/l7-core");
39
+ var primitiveMap = {
40
+ [import_l7_core.gl.POINTS]: "points",
41
+ [import_l7_core.gl.LINES]: "lines",
42
+ [import_l7_core.gl.LINE_LOOP]: "line loop",
43
+ [import_l7_core.gl.LINE_STRIP]: "line strip",
44
+ [import_l7_core.gl.TRIANGLES]: "triangles",
45
+ [import_l7_core.gl.TRIANGLE_FAN]: "triangle fan",
46
+ [import_l7_core.gl.TRIANGLE_STRIP]: "triangle strip"
47
+ };
48
+ var usageMap = {
49
+ [import_l7_core.gl.STATIC_DRAW]: "static",
50
+ [import_l7_core.gl.DYNAMIC_DRAW]: "dynamic",
51
+ [import_l7_core.gl.STREAM_DRAW]: "stream"
52
+ };
53
+ var dataTypeMap = {
54
+ [import_l7_core.gl.BYTE]: "int8",
55
+ [import_l7_core.gl.UNSIGNED_INT]: "int16",
56
+ [import_l7_core.gl.INT]: "int32",
57
+ [import_l7_core.gl.UNSIGNED_BYTE]: "uint8",
58
+ [import_l7_core.gl.UNSIGNED_SHORT]: "uint16",
59
+ [import_l7_core.gl.UNSIGNED_INT]: "uint32",
60
+ [import_l7_core.gl.FLOAT]: "float"
61
+ };
62
+ var formatMap = {
63
+ [import_l7_core.gl.ALPHA]: "alpha",
64
+ [import_l7_core.gl.LUMINANCE]: "luminance",
65
+ [import_l7_core.gl.LUMINANCE_ALPHA]: "luminance alpha",
66
+ [import_l7_core.gl.RGB]: "rgb",
67
+ [import_l7_core.gl.RGBA]: "rgba",
68
+ [import_l7_core.gl.RGBA4]: "rgba4",
69
+ [import_l7_core.gl.RGB5_A1]: "rgb5 a1",
70
+ [import_l7_core.gl.RGB565]: "rgb565",
71
+ [import_l7_core.gl.DEPTH_COMPONENT]: "depth",
72
+ [import_l7_core.gl.DEPTH_STENCIL]: "depth stencil"
73
+ };
74
+ var mipmapMap = {
75
+ [import_l7_core.gl.DONT_CARE]: "dont care",
76
+ [import_l7_core.gl.NICEST]: "nice",
77
+ [import_l7_core.gl.FASTEST]: "fast"
78
+ };
79
+ var filterMap = {
80
+ [import_l7_core.gl.NEAREST]: "nearest",
81
+ [import_l7_core.gl.LINEAR]: "linear",
82
+ [import_l7_core.gl.LINEAR_MIPMAP_LINEAR]: "mipmap",
83
+ [import_l7_core.gl.NEAREST_MIPMAP_LINEAR]: "nearest mipmap linear",
84
+ [import_l7_core.gl.LINEAR_MIPMAP_NEAREST]: "linear mipmap nearest",
85
+ [import_l7_core.gl.NEAREST_MIPMAP_NEAREST]: "nearest mipmap nearest"
86
+ };
87
+ var wrapModeMap = {
88
+ [import_l7_core.gl.REPEAT]: "repeat",
89
+ [import_l7_core.gl.CLAMP_TO_EDGE]: "clamp",
90
+ [import_l7_core.gl.MIRRORED_REPEAT]: "mirror"
91
+ };
92
+ var colorSpaceMap = {
93
+ [import_l7_core.gl.NONE]: "none",
94
+ [import_l7_core.gl.BROWSER_DEFAULT_WEBGL]: "browser"
95
+ };
96
+ var depthFuncMap = {
97
+ [import_l7_core.gl.NEVER]: "never",
98
+ [import_l7_core.gl.ALWAYS]: "always",
99
+ [import_l7_core.gl.LESS]: "less",
100
+ [import_l7_core.gl.LEQUAL]: "lequal",
101
+ [import_l7_core.gl.GREATER]: "greater",
102
+ [import_l7_core.gl.GEQUAL]: "gequal",
103
+ [import_l7_core.gl.EQUAL]: "equal",
104
+ [import_l7_core.gl.NOTEQUAL]: "notequal"
105
+ };
106
+ var blendEquationMap = {
107
+ [import_l7_core.gl.FUNC_ADD]: "add",
108
+ [import_l7_core.gl.MIN_EXT]: "min",
109
+ [import_l7_core.gl.MAX_EXT]: "max",
110
+ [import_l7_core.gl.FUNC_SUBTRACT]: "subtract",
111
+ [import_l7_core.gl.FUNC_REVERSE_SUBTRACT]: "reverse subtract"
112
+ };
113
+ var blendFuncMap = {
114
+ [import_l7_core.gl.ZERO]: "zero",
115
+ [import_l7_core.gl.ONE]: "one",
116
+ [import_l7_core.gl.SRC_COLOR]: "src color",
117
+ [import_l7_core.gl.ONE_MINUS_SRC_COLOR]: "one minus src color",
118
+ [import_l7_core.gl.SRC_ALPHA]: "src alpha",
119
+ [import_l7_core.gl.ONE_MINUS_SRC_ALPHA]: "one minus src alpha",
120
+ [import_l7_core.gl.DST_COLOR]: "dst color",
121
+ [import_l7_core.gl.ONE_MINUS_DST_COLOR]: "one minus dst color",
122
+ [import_l7_core.gl.DST_ALPHA]: "dst alpha",
123
+ [import_l7_core.gl.ONE_MINUS_DST_ALPHA]: "one minus dst alpha",
124
+ [import_l7_core.gl.CONSTANT_COLOR]: "constant color",
125
+ [import_l7_core.gl.ONE_MINUS_CONSTANT_COLOR]: "one minus constant color",
126
+ [import_l7_core.gl.CONSTANT_ALPHA]: "constant alpha",
127
+ [import_l7_core.gl.ONE_MINUS_CONSTANT_ALPHA]: "one minus constant alpha",
128
+ [import_l7_core.gl.SRC_ALPHA_SATURATE]: "src alpha saturate"
129
+ };
130
+ var stencilFuncMap = {
131
+ [import_l7_core.gl.NEVER]: "never",
132
+ [import_l7_core.gl.ALWAYS]: "always",
133
+ [import_l7_core.gl.LESS]: "less",
134
+ [import_l7_core.gl.LEQUAL]: "lequal",
135
+ [import_l7_core.gl.GREATER]: "greater",
136
+ [import_l7_core.gl.GEQUAL]: "gequal",
137
+ [import_l7_core.gl.EQUAL]: "equal",
138
+ [import_l7_core.gl.NOTEQUAL]: "notequal"
139
+ };
140
+ var stencilOpMap = {
141
+ [import_l7_core.gl.ZERO]: "zero",
142
+ [import_l7_core.gl.KEEP]: "keep",
143
+ [import_l7_core.gl.REPLACE]: "replace",
144
+ [import_l7_core.gl.INVERT]: "invert",
145
+ [import_l7_core.gl.INCR]: "increment",
146
+ [import_l7_core.gl.DECR]: "decrement",
147
+ [import_l7_core.gl.INCR_WRAP]: "increment wrap",
148
+ [import_l7_core.gl.DECR_WRAP]: "decrement wrap"
149
+ };
150
+ var cullFaceMap = {
151
+ [import_l7_core.gl.FRONT]: "front",
152
+ [import_l7_core.gl.BACK]: "back"
153
+ };
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
156
+ blendEquationMap,
157
+ blendFuncMap,
158
+ colorSpaceMap,
159
+ cullFaceMap,
160
+ dataTypeMap,
161
+ depthFuncMap,
162
+ filterMap,
163
+ formatMap,
164
+ mipmapMap,
165
+ primitiveMap,
166
+ stencilFuncMap,
167
+ stencilOpMap,
168
+ usageMap,
169
+ wrapModeMap
170
+ });
@@ -0,0 +1,232 @@
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-renderer",
3
- "version": "2.18.2",
3
+ "version": "2.18.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -25,18 +25,18 @@
25
25
  "author": "xiaoiver",
26
26
  "license": "ISC",
27
27
  "devDependencies": {
28
- "@antv/l7-test-utils": "^2.18.2",
28
+ "@antv/l7-test-utils": "2.18.3",
29
29
  "gl": "^5.0.3"
30
30
  },
31
31
  "dependencies": {
32
- "@antv/l7-core": "^2.18.2",
33
- "@antv/l7-utils": "^2.18.2",
32
+ "@antv/l7-core": "2.18.3",
33
+ "@antv/l7-utils": "2.18.3",
34
34
  "@babel/runtime": "^7.7.7",
35
35
  "inversify": "^5.0.1",
36
36
  "reflect-metadata": "^0.1.13",
37
37
  "regl": "^1.7.0"
38
38
  },
39
- "gitHead": "89de0cd3f4d2e6e71132577a2ae4e571e2acf0b8",
39
+ "gitHead": "882d6eaa2d503b4e50ad6d94b123f8f892c0f84c",
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  }