@antv/l7-renderer 2.21.1 → 2.21.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/device/DeviceAttribute.js +26 -32
- package/es/device/DeviceBuffer.js +31 -49
- package/es/device/DeviceCache.js +136 -170
- package/es/device/DeviceElements.js +32 -38
- package/es/device/DeviceFramebuffer.js +76 -104
- package/es/device/DeviceModel.js +358 -384
- package/es/device/DeviceTexture2D.js +103 -122
- package/es/device/constants.js +117 -34
- package/es/device/index.js +254 -381
- package/es/device/utils/HashMap.js +71 -138
- package/es/device/utils/pipeline.js +6 -1
- package/es/device/utils/typedarray.js +23 -24
- package/es/device/utils/webgl.js +7 -6
- package/es/index.js +5 -4
- package/es/regl/ReglAttribute.js +17 -33
- package/es/regl/ReglBuffer.js +25 -40
- package/es/regl/ReglElements.js +21 -36
- package/es/regl/ReglFramebuffer.js +24 -44
- package/es/regl/ReglModel.js +266 -306
- package/es/regl/ReglRenderbuffer.js +19 -36
- package/es/regl/ReglTexture2D.js +72 -103
- package/es/regl/constants.js +133 -21
- package/es/regl/index.js +205 -289
- package/lib/device/DeviceAttribute.d.ts +13 -0
- package/lib/device/DeviceBuffer.d.ts +18 -0
- package/lib/device/DeviceCache.d.ts +14 -0
- package/lib/device/DeviceElements.d.ts +13 -0
- package/lib/device/DeviceFramebuffer.d.ts +24 -0
- package/lib/device/DeviceModel.d.ts +53 -0
- package/lib/device/DeviceModel.js +22 -15
- package/lib/device/DeviceTexture2D.d.ts +23 -0
- package/lib/device/constants.d.ts +35 -0
- package/lib/device/index.d.ts +68 -0
- package/lib/device/index.js +58 -36
- package/lib/device/utils/HashMap.d.ts +24 -0
- package/lib/device/utils/pipeline.d.ts +1 -0
- package/lib/device/utils/typedarray.d.ts +7 -0
- package/lib/device/utils/webgl.d.ts +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/regl/ReglAttribute.d.ts +16 -0
- package/lib/regl/ReglBuffer.d.ts +17 -0
- package/lib/regl/ReglElements.d.ts +14 -0
- package/lib/regl/ReglFramebuffer.d.ts +16 -0
- package/lib/regl/ReglModel.d.ts +46 -0
- package/lib/regl/ReglModel.js +21 -11
- package/lib/regl/ReglRenderbuffer.d.ts +16 -0
- package/lib/regl/ReglTexture2D.d.ts +22 -0
- package/lib/regl/constants.d.ts +43 -0
- package/lib/regl/index.d.ts +56 -0
- package/lib/regl/index.js +70 -48
- package/package.json +14 -18
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* render w/ regl
|
|
3
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md
|
|
4
|
+
*/
|
|
5
|
+
import type { IAttribute, IAttributeInitializationOptions, IBuffer, IBufferInitializationOptions, IClearOptions, IElements, IElementsInitializationOptions, IExtensions, IFramebuffer, IFramebufferInitializationOptions, IModel, IModelInitializationOptions, IReadPixelsOptions, IRenderConfig, IRendererService, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
|
|
6
|
+
import regl from 'regl';
|
|
7
|
+
import ReglFramebuffer from './ReglFramebuffer';
|
|
8
|
+
/**
|
|
9
|
+
* regl renderer
|
|
10
|
+
*/
|
|
11
|
+
export default class ReglRendererService implements IRendererService {
|
|
12
|
+
uniformBuffers: IBuffer[];
|
|
13
|
+
extensionObject: IExtensions;
|
|
14
|
+
private gl;
|
|
15
|
+
private $container;
|
|
16
|
+
private canvas;
|
|
17
|
+
private width;
|
|
18
|
+
private height;
|
|
19
|
+
private isDirty;
|
|
20
|
+
queryVerdorInfo: () => string;
|
|
21
|
+
init(canvas: HTMLCanvasElement, cfg: IRenderConfig, gl?: regl.Regl): Promise<void>;
|
|
22
|
+
getPointSizeRange(): any;
|
|
23
|
+
testExtension(name: string): boolean;
|
|
24
|
+
createModel: (options: IModelInitializationOptions) => IModel;
|
|
25
|
+
createAttribute: (options: IAttributeInitializationOptions) => IAttribute;
|
|
26
|
+
createBuffer: (options: IBufferInitializationOptions) => IBuffer;
|
|
27
|
+
createElements: (options: IElementsInitializationOptions) => IElements;
|
|
28
|
+
createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
|
|
29
|
+
createFramebuffer: (options: IFramebufferInitializationOptions) => ReglFramebuffer;
|
|
30
|
+
useFramebuffer: (framebuffer: IFramebuffer | null, drawCommands: () => void) => void;
|
|
31
|
+
useFramebufferAsync: (framebuffer: IFramebuffer | null, drawCommands: () => Promise<void>) => Promise<void>;
|
|
32
|
+
clear: (options: IClearOptions) => void;
|
|
33
|
+
viewport: ({ x, y, width, height, }: {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
width: number;
|
|
37
|
+
height: number;
|
|
38
|
+
}) => void;
|
|
39
|
+
readPixels: (options: IReadPixelsOptions) => Uint8Array;
|
|
40
|
+
readPixelsAsync: (options: IReadPixelsOptions) => Promise<Uint8Array>;
|
|
41
|
+
getViewportSize: () => {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
};
|
|
45
|
+
getContainer: () => HTMLElement | null;
|
|
46
|
+
getCanvas: () => HTMLCanvasElement;
|
|
47
|
+
getGLContext: () => WebGLRenderingContext;
|
|
48
|
+
setState(): void;
|
|
49
|
+
setBaseState(): void;
|
|
50
|
+
setCustomLayerDefaults(): void;
|
|
51
|
+
setDirty(flag: boolean): void;
|
|
52
|
+
getDirty(): boolean;
|
|
53
|
+
destroy: () => void;
|
|
54
|
+
beginFrame(): void;
|
|
55
|
+
endFrame(): void;
|
|
56
|
+
}
|
package/lib/regl/index.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
|
|
29
49
|
// src/regl/index.ts
|
|
30
50
|
var regl_exports = {};
|
|
@@ -56,11 +76,11 @@ var ReglRendererService = class {
|
|
|
56
76
|
framebuffer: framebuffer ? framebuffer.get() : null
|
|
57
77
|
})(drawCommands);
|
|
58
78
|
};
|
|
59
|
-
this.useFramebufferAsync =
|
|
79
|
+
this.useFramebufferAsync = (framebuffer, drawCommands) => __async(this, null, function* () {
|
|
60
80
|
this.gl({
|
|
61
81
|
framebuffer: framebuffer ? framebuffer.get() : null
|
|
62
82
|
})(drawCommands);
|
|
63
|
-
};
|
|
83
|
+
});
|
|
64
84
|
this.clear = (options) => {
|
|
65
85
|
var _a;
|
|
66
86
|
const { color, depth, stencil, framebuffer = null } = options;
|
|
@@ -96,9 +116,9 @@ var ReglRendererService = class {
|
|
|
96
116
|
}
|
|
97
117
|
return this.gl.read(readPixelsOptions);
|
|
98
118
|
};
|
|
99
|
-
this.readPixelsAsync =
|
|
119
|
+
this.readPixelsAsync = (options) => __async(this, null, function* () {
|
|
100
120
|
return this.readPixels(options);
|
|
101
|
-
};
|
|
121
|
+
});
|
|
102
122
|
this.getViewportSize = () => {
|
|
103
123
|
return {
|
|
104
124
|
width: this.gl._gl.drawingBufferWidth,
|
|
@@ -123,52 +143,54 @@ var ReglRendererService = class {
|
|
|
123
143
|
this.gl = null;
|
|
124
144
|
};
|
|
125
145
|
}
|
|
126
|
-
|
|
127
|
-
this
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
init(canvas, cfg, gl) {
|
|
147
|
+
return __async(this, null, function* () {
|
|
148
|
+
this.canvas = canvas;
|
|
149
|
+
if (gl) {
|
|
150
|
+
this.gl = gl;
|
|
151
|
+
} else {
|
|
152
|
+
this.gl = yield new Promise((resolve, reject) => {
|
|
153
|
+
(0, import_regl.default)({
|
|
154
|
+
canvas: this.canvas,
|
|
155
|
+
attributes: {
|
|
156
|
+
alpha: true,
|
|
157
|
+
// use TAA instead of MSAA
|
|
158
|
+
// @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
|
|
159
|
+
antialias: cfg.antialias,
|
|
160
|
+
premultipliedAlpha: true,
|
|
161
|
+
preserveDrawingBuffer: cfg.preserveDrawingBuffer,
|
|
162
|
+
stencil: cfg.stencil
|
|
163
|
+
},
|
|
164
|
+
// TODO: use extensions
|
|
165
|
+
extensions: [
|
|
166
|
+
"OES_element_index_uint",
|
|
167
|
+
"OES_standard_derivatives",
|
|
168
|
+
// wireframe
|
|
169
|
+
"ANGLE_instanced_arrays"
|
|
170
|
+
// VSM shadow map
|
|
171
|
+
],
|
|
172
|
+
optionalExtensions: [
|
|
173
|
+
"oes_texture_float_linear",
|
|
174
|
+
"OES_texture_float",
|
|
175
|
+
"EXT_texture_filter_anisotropic",
|
|
176
|
+
"EXT_blend_minmax",
|
|
177
|
+
"WEBGL_depth_texture",
|
|
178
|
+
"WEBGL_lose_context"
|
|
179
|
+
],
|
|
180
|
+
profile: true,
|
|
181
|
+
onDone: (err, r) => {
|
|
182
|
+
if (err || !r) {
|
|
183
|
+
reject(err);
|
|
184
|
+
}
|
|
185
|
+
resolve(r);
|
|
163
186
|
}
|
|
164
|
-
|
|
165
|
-
}
|
|
187
|
+
});
|
|
166
188
|
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
};
|
|
189
|
+
}
|
|
190
|
+
this.extensionObject = {
|
|
191
|
+
OES_texture_float: this.testExtension("OES_texture_float")
|
|
192
|
+
};
|
|
193
|
+
});
|
|
172
194
|
}
|
|
173
195
|
getPointSizeRange() {
|
|
174
196
|
return this.gl._gl.getParameter(this.gl._gl.ALIASED_POINT_SIZE_RANGE);
|
package/package.json
CHANGED
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.21.
|
|
3
|
+
"version": "2.21.3",
|
|
4
4
|
"description": "",
|
|
5
|
-
"license": "
|
|
6
|
-
"author": "
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "https://github.com/orgs/antvis/people",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"module": "es/index.js",
|
|
10
10
|
"types": "es/index.d.ts",
|
|
11
11
|
"files": [
|
|
12
12
|
"lib",
|
|
13
|
-
"es"
|
|
14
|
-
"README.md"
|
|
13
|
+
"es"
|
|
15
14
|
],
|
|
16
15
|
"scripts": {
|
|
17
|
-
"
|
|
18
|
-
"build
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"test-live": "umi-test --watch",
|
|
24
|
-
"tsc": "tsc --project tsconfig.build.json"
|
|
16
|
+
"dev": "father dev",
|
|
17
|
+
"build": "npm run clean && father build",
|
|
18
|
+
"check-deps": "father doctor",
|
|
19
|
+
"lint": "eslint src __tests__",
|
|
20
|
+
"clean": "rimraf dist es lib",
|
|
21
|
+
"sync": "tnpm sync"
|
|
25
22
|
},
|
|
26
23
|
"dependencies": {
|
|
27
24
|
"@antv/g-device-api": "^1.6.4",
|
|
28
|
-
"@antv/l7-core": "2.21.
|
|
29
|
-
"@antv/l7-utils": "2.21.
|
|
25
|
+
"@antv/l7-core": "^2.21.3",
|
|
26
|
+
"@antv/l7-utils": "^2.21.3",
|
|
30
27
|
"@babel/runtime": "^7.7.7",
|
|
31
28
|
"regl": "1.6.1"
|
|
32
29
|
},
|
|
33
30
|
"devDependencies": {
|
|
34
|
-
"@antv/l7-test-utils": "2.21.
|
|
35
|
-
"gl": "^6.0.2"
|
|
31
|
+
"@antv/l7-test-utils": "^2.21.3"
|
|
36
32
|
},
|
|
37
33
|
"publishConfig": {
|
|
38
34
|
"access": "public"
|
|
39
35
|
},
|
|
40
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "522dec125e1d49bfe3b7325239bb6c9103311b2d"
|
|
41
37
|
}
|