@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.
Files changed (51) hide show
  1. package/es/device/DeviceAttribute.js +26 -32
  2. package/es/device/DeviceBuffer.js +31 -49
  3. package/es/device/DeviceCache.js +136 -170
  4. package/es/device/DeviceElements.js +32 -38
  5. package/es/device/DeviceFramebuffer.js +76 -104
  6. package/es/device/DeviceModel.js +358 -384
  7. package/es/device/DeviceTexture2D.js +103 -122
  8. package/es/device/constants.js +117 -34
  9. package/es/device/index.js +254 -381
  10. package/es/device/utils/HashMap.js +71 -138
  11. package/es/device/utils/pipeline.js +6 -1
  12. package/es/device/utils/typedarray.js +23 -24
  13. package/es/device/utils/webgl.js +7 -6
  14. package/es/index.js +5 -4
  15. package/es/regl/ReglAttribute.js +17 -33
  16. package/es/regl/ReglBuffer.js +25 -40
  17. package/es/regl/ReglElements.js +21 -36
  18. package/es/regl/ReglFramebuffer.js +24 -44
  19. package/es/regl/ReglModel.js +266 -306
  20. package/es/regl/ReglRenderbuffer.js +19 -36
  21. package/es/regl/ReglTexture2D.js +72 -103
  22. package/es/regl/constants.js +133 -21
  23. package/es/regl/index.js +205 -289
  24. package/lib/device/DeviceAttribute.d.ts +13 -0
  25. package/lib/device/DeviceBuffer.d.ts +18 -0
  26. package/lib/device/DeviceCache.d.ts +14 -0
  27. package/lib/device/DeviceElements.d.ts +13 -0
  28. package/lib/device/DeviceFramebuffer.d.ts +24 -0
  29. package/lib/device/DeviceModel.d.ts +53 -0
  30. package/lib/device/DeviceModel.js +22 -15
  31. package/lib/device/DeviceTexture2D.d.ts +23 -0
  32. package/lib/device/constants.d.ts +35 -0
  33. package/lib/device/index.d.ts +68 -0
  34. package/lib/device/index.js +58 -36
  35. package/lib/device/utils/HashMap.d.ts +24 -0
  36. package/lib/device/utils/pipeline.d.ts +1 -0
  37. package/lib/device/utils/typedarray.d.ts +7 -0
  38. package/lib/device/utils/webgl.d.ts +1 -0
  39. package/lib/index.d.ts +6 -0
  40. package/lib/regl/ReglAttribute.d.ts +16 -0
  41. package/lib/regl/ReglBuffer.d.ts +17 -0
  42. package/lib/regl/ReglElements.d.ts +14 -0
  43. package/lib/regl/ReglFramebuffer.d.ts +16 -0
  44. package/lib/regl/ReglModel.d.ts +46 -0
  45. package/lib/regl/ReglModel.js +21 -11
  46. package/lib/regl/ReglRenderbuffer.d.ts +16 -0
  47. package/lib/regl/ReglTexture2D.d.ts +22 -0
  48. package/lib/regl/constants.d.ts +43 -0
  49. package/lib/regl/index.d.ts +56 -0
  50. package/lib/regl/index.js +70 -48
  51. 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 = async (framebuffer, drawCommands) => {
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 = async (options) => {
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
- async init(canvas, cfg, gl) {
127
- this.canvas = canvas;
128
- if (gl) {
129
- this.gl = gl;
130
- } else {
131
- this.gl = await new Promise((resolve, reject) => {
132
- (0, import_regl.default)({
133
- canvas: this.canvas,
134
- attributes: {
135
- alpha: true,
136
- // use TAA instead of MSAA
137
- // @see https://www.khronos.org/registry/webgl/specs/1.0/#5.2.1
138
- antialias: cfg.antialias,
139
- premultipliedAlpha: true,
140
- preserveDrawingBuffer: cfg.preserveDrawingBuffer,
141
- stencil: cfg.stencil
142
- },
143
- // TODO: use extensions
144
- extensions: [
145
- "OES_element_index_uint",
146
- "OES_standard_derivatives",
147
- // wireframe
148
- "ANGLE_instanced_arrays"
149
- // VSM shadow map
150
- ],
151
- optionalExtensions: [
152
- "oes_texture_float_linear",
153
- "OES_texture_float",
154
- "EXT_texture_filter_anisotropic",
155
- "EXT_blend_minmax",
156
- "WEBGL_depth_texture",
157
- "WEBGL_lose_context"
158
- ],
159
- profile: true,
160
- onDone: (err, r) => {
161
- if (err || !r) {
162
- reject(err);
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
- resolve(r);
165
- }
187
+ });
166
188
  });
167
- });
168
- }
169
- this.extensionObject = {
170
- OES_texture_float: this.testExtension("OES_texture_float")
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.1",
3
+ "version": "2.21.3",
4
4
  "description": "",
5
- "license": "ISC",
6
- "author": "xiaoiver",
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
- "build": "father build",
18
- "build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
19
- "build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
20
- "clean": "rimraf dist; rimraf es; rimraf lib;",
21
- "sync": "tnpm sync",
22
- "test": "umi-test --passWithNoTests",
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.1",
29
- "@antv/l7-utils": "2.21.1",
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.1",
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": "1e0d2e5920f479f77095a2c5eddda8a8d7ac9e0f"
36
+ "gitHead": "522dec125e1d49bfe3b7325239bb6c9103311b2d"
41
37
  }