@antv/l7-renderer 2.28.14 → 2.29.1
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/index.d.ts +1 -2
- package/es/index.js +1 -3
- package/lib/index.d.ts +1 -2
- package/lib/index.js +2 -5
- package/package.json +8 -6
- package/es/regl/ReglAttribute.d.ts +0 -16
- package/es/regl/ReglAttribute.js +0 -29
- package/es/regl/ReglBuffer.d.ts +0 -17
- package/es/regl/ReglBuffer.js +0 -33
- package/es/regl/ReglElements.d.ts +0 -14
- package/es/regl/ReglElements.js +0 -27
- package/es/regl/ReglFramebuffer.d.ts +0 -16
- package/es/regl/ReglFramebuffer.js +0 -31
- package/es/regl/ReglModel.d.ts +0 -46
- package/es/regl/ReglModel.js +0 -302
- package/es/regl/ReglRenderbuffer.d.ts +0 -16
- package/es/regl/ReglRenderbuffer.js +0 -24
- package/es/regl/ReglTexture2D.d.ts +0 -22
- package/es/regl/ReglTexture2D.js +0 -94
- package/es/regl/constants.d.ts +0 -43
- package/es/regl/constants.js +0 -133
- package/es/regl/index.d.ts +0 -56
- package/es/regl/index.js +0 -227
- package/lib/regl/ReglAttribute.d.ts +0 -16
- package/lib/regl/ReglAttribute.js +0 -49
- package/lib/regl/ReglBuffer.d.ts +0 -17
- package/lib/regl/ReglBuffer.js +0 -53
- package/lib/regl/ReglElements.d.ts +0 -14
- package/lib/regl/ReglElements.js +0 -47
- package/lib/regl/ReglFramebuffer.d.ts +0 -16
- package/lib/regl/ReglFramebuffer.js +0 -51
- package/lib/regl/ReglModel.d.ts +0 -46
- package/lib/regl/ReglModel.js +0 -311
- package/lib/regl/ReglRenderbuffer.d.ts +0 -16
- package/lib/regl/ReglRenderbuffer.js +0 -44
- package/lib/regl/ReglTexture2D.d.ts +0 -22
- package/lib/regl/ReglTexture2D.js +0 -107
- package/lib/regl/constants.d.ts +0 -43
- package/lib/regl/constants.js +0 -170
- package/lib/regl/index.d.ts +0 -56
- package/lib/regl/index.js +0 -256
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -29,14 +29,11 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/index.ts
|
|
30
30
|
var src_exports = {};
|
|
31
31
|
__export(src_exports, {
|
|
32
|
-
DeviceRendererService: () => import_device.default
|
|
33
|
-
ReglRendererService: () => import_regl.default
|
|
32
|
+
DeviceRendererService: () => import_device.default
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(src_exports);
|
|
36
35
|
var import_device = __toESM(require("./device"));
|
|
37
|
-
var import_regl = __toESM(require("./regl"));
|
|
38
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
39
37
|
0 && (module.exports = {
|
|
40
|
-
DeviceRendererService
|
|
41
|
-
ReglRendererService
|
|
38
|
+
DeviceRendererService
|
|
42
39
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.29.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
@@ -15,18 +15,20 @@
|
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@antv/g-device-api": "^1.6.4",
|
|
17
17
|
"@babel/runtime": "^7.7.7",
|
|
18
|
-
"
|
|
19
|
-
"@antv/l7-
|
|
20
|
-
"@antv/l7-utils": "2.28.14"
|
|
18
|
+
"@antv/l7-core": "2.29.1",
|
|
19
|
+
"@antv/l7-utils": "2.29.1"
|
|
21
20
|
},
|
|
22
21
|
"devDependencies": {
|
|
23
|
-
"@antv/l7-test-utils": "^2.
|
|
22
|
+
"@antv/l7-test-utils": "^2.29.1"
|
|
24
23
|
},
|
|
25
24
|
"publishConfig": {
|
|
26
25
|
"access": "public",
|
|
27
26
|
"registry": "https://registry.npmjs.org"
|
|
28
27
|
},
|
|
29
|
-
"repository":
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git@github.com:antvis/L7.git"
|
|
31
|
+
},
|
|
30
32
|
"scripts": {
|
|
31
33
|
"dev": "father dev",
|
|
32
34
|
"build": "npm run clean && father build",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IAttribute, IAttributeInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
|
|
5
|
-
*/
|
|
6
|
-
export default class ReglAttribute implements IAttribute {
|
|
7
|
-
private attribute;
|
|
8
|
-
private buffer;
|
|
9
|
-
constructor(gl: regl.Regl, options: IAttributeInitializationOptions);
|
|
10
|
-
get(): regl.Attribute;
|
|
11
|
-
updateBuffer(options: {
|
|
12
|
-
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
13
|
-
offset: number;
|
|
14
|
-
}): void;
|
|
15
|
-
destroy(): void;
|
|
16
|
-
}
|
package/es/regl/ReglAttribute.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglAttribute.ts
|
|
2
|
-
var ReglAttribute = class {
|
|
3
|
-
constructor(gl, options) {
|
|
4
|
-
const { buffer, offset, stride, normalized, size, divisor } = options;
|
|
5
|
-
this.buffer = buffer;
|
|
6
|
-
this.attribute = {
|
|
7
|
-
buffer: buffer.get(),
|
|
8
|
-
offset: offset || 0,
|
|
9
|
-
stride: stride || 0,
|
|
10
|
-
normalized: normalized || false,
|
|
11
|
-
divisor: divisor || 0
|
|
12
|
-
};
|
|
13
|
-
if (size) {
|
|
14
|
-
this.attribute.size = size;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
get() {
|
|
18
|
-
return this.attribute;
|
|
19
|
-
}
|
|
20
|
-
updateBuffer(options) {
|
|
21
|
-
this.buffer.subData(options);
|
|
22
|
-
}
|
|
23
|
-
destroy() {
|
|
24
|
-
this.buffer.destroy();
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export {
|
|
28
|
-
ReglAttribute as default
|
|
29
|
-
};
|
package/es/regl/ReglBuffer.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { IBuffer, IBufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* adaptor for regl.Buffer
|
|
5
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
6
|
-
*/
|
|
7
|
-
export default class ReglBuffer implements IBuffer {
|
|
8
|
-
private buffer;
|
|
9
|
-
private isDestroyed;
|
|
10
|
-
constructor(reGl: regl.Regl, options: IBufferInitializationOptions);
|
|
11
|
-
get(): regl.Buffer;
|
|
12
|
-
destroy(): void;
|
|
13
|
-
subData({ data, offset, }: {
|
|
14
|
-
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
15
|
-
offset: number;
|
|
16
|
-
}): void;
|
|
17
|
-
}
|
package/es/regl/ReglBuffer.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglBuffer.ts
|
|
2
|
-
import { gl } from "@antv/l7-core";
|
|
3
|
-
import { dataTypeMap, usageMap } from "./constants";
|
|
4
|
-
var ReglBuffer = class {
|
|
5
|
-
constructor(reGl, options) {
|
|
6
|
-
this.isDestroyed = false;
|
|
7
|
-
const { data, usage, type } = options;
|
|
8
|
-
this.buffer = reGl.buffer({
|
|
9
|
-
data,
|
|
10
|
-
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
11
|
-
type: dataTypeMap[type || gl.UNSIGNED_BYTE]
|
|
12
|
-
// length: 0,
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
get() {
|
|
16
|
-
return this.buffer;
|
|
17
|
-
}
|
|
18
|
-
destroy() {
|
|
19
|
-
if (!this.isDestroyed) {
|
|
20
|
-
this.buffer.destroy();
|
|
21
|
-
}
|
|
22
|
-
this.isDestroyed = true;
|
|
23
|
-
}
|
|
24
|
-
subData({
|
|
25
|
-
data,
|
|
26
|
-
offset
|
|
27
|
-
}) {
|
|
28
|
-
this.buffer.subdata(data, offset);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
ReglBuffer as default
|
|
33
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { IElements, IElementsInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
|
|
5
|
-
*/
|
|
6
|
-
export default class ReglElements implements IElements {
|
|
7
|
-
private elements;
|
|
8
|
-
constructor(reGl: regl.Regl, options: IElementsInitializationOptions);
|
|
9
|
-
get(): regl.Elements;
|
|
10
|
-
subData({ data, }: {
|
|
11
|
-
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
12
|
-
}): void;
|
|
13
|
-
destroy(): void;
|
|
14
|
-
}
|
package/es/regl/ReglElements.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglElements.ts
|
|
2
|
-
import { gl } from "@antv/l7-core";
|
|
3
|
-
import { dataTypeMap, usageMap } from "./constants";
|
|
4
|
-
var ReglElements = class {
|
|
5
|
-
constructor(reGl, options) {
|
|
6
|
-
const { data, usage, type, count } = options;
|
|
7
|
-
this.elements = reGl.elements({
|
|
8
|
-
data,
|
|
9
|
-
usage: usageMap[usage || gl.STATIC_DRAW],
|
|
10
|
-
type: dataTypeMap[type || gl.UNSIGNED_BYTE],
|
|
11
|
-
count
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
get() {
|
|
15
|
-
return this.elements;
|
|
16
|
-
}
|
|
17
|
-
subData({
|
|
18
|
-
data
|
|
19
|
-
}) {
|
|
20
|
-
this.elements.subdata(data);
|
|
21
|
-
}
|
|
22
|
-
destroy() {
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
export {
|
|
26
|
-
ReglElements as default
|
|
27
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IFramebuffer, IFramebufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* adaptor for regl.Framebuffer
|
|
5
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
|
|
6
|
-
*/
|
|
7
|
-
export default class ReglFramebuffer implements IFramebuffer {
|
|
8
|
-
private framebuffer;
|
|
9
|
-
constructor(reGl: regl.Regl, options: IFramebufferInitializationOptions);
|
|
10
|
-
get(): regl.Framebuffer;
|
|
11
|
-
destroy(): void;
|
|
12
|
-
resize({ width, height }: {
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
}): void;
|
|
16
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglFramebuffer.ts
|
|
2
|
-
var ReglFramebuffer = class {
|
|
3
|
-
constructor(reGl, options) {
|
|
4
|
-
const { width, height, color, colors } = options;
|
|
5
|
-
const framebufferOptions = {
|
|
6
|
-
width,
|
|
7
|
-
height
|
|
8
|
-
};
|
|
9
|
-
if (Array.isArray(colors)) {
|
|
10
|
-
framebufferOptions.colors = colors.map(
|
|
11
|
-
(c) => c.get()
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
if (color && typeof color !== "boolean") {
|
|
15
|
-
framebufferOptions.color = color.get();
|
|
16
|
-
}
|
|
17
|
-
this.framebuffer = reGl.framebuffer(framebufferOptions);
|
|
18
|
-
}
|
|
19
|
-
get() {
|
|
20
|
-
return this.framebuffer;
|
|
21
|
-
}
|
|
22
|
-
destroy() {
|
|
23
|
-
this.framebuffer.destroy();
|
|
24
|
-
}
|
|
25
|
-
resize({ width, height }) {
|
|
26
|
-
this.framebuffer.resize(width, height);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
ReglFramebuffer as default
|
|
31
|
-
};
|
package/es/regl/ReglModel.d.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { IAttribute, IElements, IModel, IModelDrawOptions, IModelInitializationOptions, IUniform } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* adaptor for regl.DrawCommand
|
|
5
|
-
*/
|
|
6
|
-
export default class ReglModel implements IModel {
|
|
7
|
-
private reGl;
|
|
8
|
-
private destroyed;
|
|
9
|
-
private drawCommand;
|
|
10
|
-
private drawParams;
|
|
11
|
-
private options;
|
|
12
|
-
private uniforms;
|
|
13
|
-
constructor(reGl: regl.Regl, options: IModelInitializationOptions);
|
|
14
|
-
updateAttributesAndElements(attributes: {
|
|
15
|
-
[key: string]: IAttribute;
|
|
16
|
-
}, elements: IElements): void;
|
|
17
|
-
updateAttributes(attributes: {
|
|
18
|
-
[key: string]: IAttribute;
|
|
19
|
-
}): void;
|
|
20
|
-
addUniforms(uniforms: {
|
|
21
|
-
[key: string]: IUniform;
|
|
22
|
-
}): void;
|
|
23
|
-
draw(options: IModelDrawOptions, pick?: boolean): void;
|
|
24
|
-
destroy(): void;
|
|
25
|
-
/**
|
|
26
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
27
|
-
*/
|
|
28
|
-
private initDepthDrawParams;
|
|
29
|
-
private getBlendDrawParams;
|
|
30
|
-
/**
|
|
31
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
32
|
-
*/
|
|
33
|
-
private getStencilDrawParams;
|
|
34
|
-
private getColorMaskDrawParams;
|
|
35
|
-
/**
|
|
36
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
37
|
-
*/
|
|
38
|
-
private initCullDrawParams;
|
|
39
|
-
/**
|
|
40
|
-
* 考虑结构体命名, eg:
|
|
41
|
-
* a: { b: 1 } -> 'a.b'
|
|
42
|
-
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
43
|
-
*/
|
|
44
|
-
private extractUniforms;
|
|
45
|
-
private extractUniformsRecursively;
|
|
46
|
-
}
|
package/es/regl/ReglModel.js
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defProps = Object.defineProperties;
|
|
3
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
-
|
|
21
|
-
// src/regl/ReglModel.ts
|
|
22
|
-
import { ClipSpaceNearZ, preprocessShader_GLSL, ViewportOrigin } from "@antv/g-device-api";
|
|
23
|
-
import { gl, removeDuplicateUniforms } from "@antv/l7-core";
|
|
24
|
-
import { lodashUtil } from "@antv/l7-utils";
|
|
25
|
-
import {
|
|
26
|
-
blendEquationMap,
|
|
27
|
-
blendFuncMap,
|
|
28
|
-
cullFaceMap,
|
|
29
|
-
depthFuncMap,
|
|
30
|
-
primitiveMap,
|
|
31
|
-
stencilFuncMap,
|
|
32
|
-
stencilOpMap
|
|
33
|
-
} from "./constants";
|
|
34
|
-
var { isPlainObject, isTypedArray } = lodashUtil;
|
|
35
|
-
var ReglModel = class {
|
|
36
|
-
constructor(reGl, options) {
|
|
37
|
-
this.destroyed = false;
|
|
38
|
-
this.uniforms = {};
|
|
39
|
-
this.reGl = reGl;
|
|
40
|
-
const { vs, fs, attributes, uniforms, primitive, count, elements, depth, cull, instances } = options;
|
|
41
|
-
const vendorInfo = {
|
|
42
|
-
platformString: "WebGL1",
|
|
43
|
-
glslVersion: "#version 100",
|
|
44
|
-
explicitBindingLocations: false,
|
|
45
|
-
separateSamplerTextures: false,
|
|
46
|
-
viewportOrigin: ViewportOrigin.LOWER_LEFT,
|
|
47
|
-
clipSpaceNearZ: ClipSpaceNearZ.NEGATIVE_ONE,
|
|
48
|
-
supportMRT: false
|
|
49
|
-
};
|
|
50
|
-
const reglUniforms = {};
|
|
51
|
-
this.options = options;
|
|
52
|
-
if (uniforms) {
|
|
53
|
-
this.uniforms = this.extractUniforms(uniforms);
|
|
54
|
-
Object.keys(uniforms).forEach((uniformName) => {
|
|
55
|
-
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
const reglAttributes = {};
|
|
59
|
-
Object.keys(attributes).forEach((name) => {
|
|
60
|
-
reglAttributes[name] = attributes[name].get();
|
|
61
|
-
});
|
|
62
|
-
const frag = removeDuplicateUniforms(
|
|
63
|
-
preprocessShader_GLSL(vendorInfo, "frag", fs, null, false)
|
|
64
|
-
);
|
|
65
|
-
const vert = removeDuplicateUniforms(
|
|
66
|
-
preprocessShader_GLSL(vendorInfo, "vert", vs, null, false)
|
|
67
|
-
);
|
|
68
|
-
const drawParams = {
|
|
69
|
-
attributes: reglAttributes,
|
|
70
|
-
frag,
|
|
71
|
-
uniforms: reglUniforms,
|
|
72
|
-
vert,
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
colorMask: reGl.prop("colorMask"),
|
|
75
|
-
lineWidth: 1,
|
|
76
|
-
blend: {
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
enable: reGl.prop("blend.enable"),
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
func: reGl.prop("blend.func"),
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
equation: reGl.prop("blend.equation"),
|
|
83
|
-
// @ts-ignore
|
|
84
|
-
color: reGl.prop("blend.color")
|
|
85
|
-
},
|
|
86
|
-
stencil: {
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
enable: reGl.prop("stencil.enable"),
|
|
89
|
-
// @ts-ignore
|
|
90
|
-
mask: reGl.prop("stencil.mask"),
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
func: reGl.prop("stencil.func"),
|
|
93
|
-
// @ts-ignore
|
|
94
|
-
opFront: reGl.prop("stencil.opFront"),
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
opBack: reGl.prop("stencil.opBack")
|
|
97
|
-
},
|
|
98
|
-
primitive: primitiveMap[primitive === void 0 ? gl.TRIANGLES : primitive]
|
|
99
|
-
};
|
|
100
|
-
if (instances) {
|
|
101
|
-
drawParams.instances = instances;
|
|
102
|
-
}
|
|
103
|
-
if (count) {
|
|
104
|
-
drawParams.count = count;
|
|
105
|
-
} else if (elements) {
|
|
106
|
-
drawParams.elements = elements.get();
|
|
107
|
-
}
|
|
108
|
-
this.initDepthDrawParams({ depth }, drawParams);
|
|
109
|
-
this.initCullDrawParams({ cull }, drawParams);
|
|
110
|
-
this.drawCommand = reGl(drawParams);
|
|
111
|
-
this.drawParams = drawParams;
|
|
112
|
-
}
|
|
113
|
-
updateAttributesAndElements(attributes, elements) {
|
|
114
|
-
const reglAttributes = {};
|
|
115
|
-
Object.keys(attributes).forEach((name) => {
|
|
116
|
-
reglAttributes[name] = attributes[name].get();
|
|
117
|
-
});
|
|
118
|
-
this.drawParams.attributes = reglAttributes;
|
|
119
|
-
this.drawParams.elements = elements.get();
|
|
120
|
-
this.drawCommand = this.reGl(this.drawParams);
|
|
121
|
-
}
|
|
122
|
-
updateAttributes(attributes) {
|
|
123
|
-
const reglAttributes = {};
|
|
124
|
-
Object.keys(attributes).forEach((name) => {
|
|
125
|
-
reglAttributes[name] = attributes[name].get();
|
|
126
|
-
});
|
|
127
|
-
this.drawParams.attributes = reglAttributes;
|
|
128
|
-
this.drawCommand = this.reGl(this.drawParams);
|
|
129
|
-
}
|
|
130
|
-
addUniforms(uniforms) {
|
|
131
|
-
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
132
|
-
}
|
|
133
|
-
draw(options, pick) {
|
|
134
|
-
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
const uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
138
|
-
const reglDrawProps = {};
|
|
139
|
-
Object.keys(uniforms).forEach((uniformName) => {
|
|
140
|
-
const type = typeof uniforms[uniformName];
|
|
141
|
-
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
142
|
-
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
143
|
-
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
144
|
-
} else {
|
|
145
|
-
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
reglDrawProps.blend = pick ? this.getBlendDrawParams({
|
|
149
|
-
blend: { enable: false }
|
|
150
|
-
}) : this.getBlendDrawParams(options);
|
|
151
|
-
reglDrawProps.stencil = this.getStencilDrawParams(options);
|
|
152
|
-
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
|
|
153
|
-
this.drawCommand(reglDrawProps);
|
|
154
|
-
}
|
|
155
|
-
destroy() {
|
|
156
|
-
var _a, _b;
|
|
157
|
-
(_b = (_a = this.drawParams) == null ? void 0 : _a.elements) == null ? void 0 : _b.destroy();
|
|
158
|
-
if (this.options.attributes) {
|
|
159
|
-
Object.values(this.options.attributes).forEach((attr) => {
|
|
160
|
-
attr == null ? void 0 : attr.destroy();
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
this.destroyed = true;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
167
|
-
*/
|
|
168
|
-
initDepthDrawParams({ depth }, drawParams) {
|
|
169
|
-
if (depth) {
|
|
170
|
-
drawParams.depth = {
|
|
171
|
-
enable: depth.enable === void 0 ? true : !!depth.enable,
|
|
172
|
-
mask: depth.mask === void 0 ? true : !!depth.mask,
|
|
173
|
-
func: depthFuncMap[depth.func || gl.LESS],
|
|
174
|
-
range: depth.range || [0, 1]
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
getBlendDrawParams({ blend }) {
|
|
179
|
-
const { enable, func, equation, color = [0, 0, 0, 0] } = blend || {};
|
|
180
|
-
return {
|
|
181
|
-
enable: !!enable,
|
|
182
|
-
func: {
|
|
183
|
-
srcRGB: blendFuncMap[func && func.srcRGB || gl.SRC_ALPHA],
|
|
184
|
-
srcAlpha: blendFuncMap[func && func.srcAlpha || gl.SRC_ALPHA],
|
|
185
|
-
dstRGB: blendFuncMap[func && func.dstRGB || gl.ONE_MINUS_SRC_ALPHA],
|
|
186
|
-
dstAlpha: blendFuncMap[func && func.dstAlpha || gl.ONE_MINUS_SRC_ALPHA]
|
|
187
|
-
},
|
|
188
|
-
equation: {
|
|
189
|
-
rgb: blendEquationMap[equation && equation.rgb || gl.FUNC_ADD],
|
|
190
|
-
alpha: blendEquationMap[equation && equation.alpha || gl.FUNC_ADD]
|
|
191
|
-
},
|
|
192
|
-
color
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
197
|
-
*/
|
|
198
|
-
getStencilDrawParams({ stencil }) {
|
|
199
|
-
const {
|
|
200
|
-
enable,
|
|
201
|
-
mask = -1,
|
|
202
|
-
func = {
|
|
203
|
-
cmp: gl.ALWAYS,
|
|
204
|
-
ref: 0,
|
|
205
|
-
mask: -1
|
|
206
|
-
},
|
|
207
|
-
opFront = {
|
|
208
|
-
fail: gl.KEEP,
|
|
209
|
-
zfail: gl.KEEP,
|
|
210
|
-
zpass: gl.KEEP
|
|
211
|
-
},
|
|
212
|
-
opBack = {
|
|
213
|
-
fail: gl.KEEP,
|
|
214
|
-
zfail: gl.KEEP,
|
|
215
|
-
zpass: gl.KEEP
|
|
216
|
-
}
|
|
217
|
-
} = stencil || {};
|
|
218
|
-
return {
|
|
219
|
-
enable: !!enable,
|
|
220
|
-
mask,
|
|
221
|
-
func: __spreadProps(__spreadValues({}, func), {
|
|
222
|
-
cmp: stencilFuncMap[func.cmp]
|
|
223
|
-
}),
|
|
224
|
-
opFront: {
|
|
225
|
-
fail: stencilOpMap[opFront.fail],
|
|
226
|
-
zfail: stencilOpMap[opFront.zfail],
|
|
227
|
-
zpass: stencilOpMap[opFront.zpass]
|
|
228
|
-
},
|
|
229
|
-
opBack: {
|
|
230
|
-
fail: stencilOpMap[opBack.fail],
|
|
231
|
-
zfail: stencilOpMap[opBack.zfail],
|
|
232
|
-
zpass: stencilOpMap[opBack.zpass]
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
getColorMaskDrawParams({ stencil }, pick) {
|
|
237
|
-
const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
|
|
238
|
-
return colorMask;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
242
|
-
*/
|
|
243
|
-
initCullDrawParams({ cull }, drawParams) {
|
|
244
|
-
if (cull) {
|
|
245
|
-
const { enable, face = gl.BACK } = cull;
|
|
246
|
-
drawParams.cull = {
|
|
247
|
-
enable: !!enable,
|
|
248
|
-
face: cullFaceMap[face]
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
/**
|
|
253
|
-
* 考虑结构体命名, eg:
|
|
254
|
-
* a: { b: 1 } -> 'a.b'
|
|
255
|
-
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
256
|
-
*/
|
|
257
|
-
extractUniforms(uniforms) {
|
|
258
|
-
const extractedUniforms = {};
|
|
259
|
-
Object.keys(uniforms).forEach((uniformName) => {
|
|
260
|
-
this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, "");
|
|
261
|
-
});
|
|
262
|
-
return extractedUniforms;
|
|
263
|
-
}
|
|
264
|
-
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
265
|
-
if (uniformValue === null || typeof uniformValue === "number" || // u_A: 1
|
|
266
|
-
typeof uniformValue === "boolean" || // u_A: false
|
|
267
|
-
Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3]
|
|
268
|
-
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
269
|
-
// @ts-ignore
|
|
270
|
-
uniformValue === "" || "resize" in uniformValue) {
|
|
271
|
-
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
if (isPlainObject(uniformValue)) {
|
|
275
|
-
Object.keys(uniformValue).forEach((childName) => {
|
|
276
|
-
this.extractUniformsRecursively(
|
|
277
|
-
childName,
|
|
278
|
-
// @ts-ignore
|
|
279
|
-
uniformValue[childName],
|
|
280
|
-
uniforms,
|
|
281
|
-
`${prefix && prefix + "."}${uniformName}`
|
|
282
|
-
);
|
|
283
|
-
});
|
|
284
|
-
}
|
|
285
|
-
if (Array.isArray(uniformValue)) {
|
|
286
|
-
uniformValue.forEach((child, idx) => {
|
|
287
|
-
Object.keys(child).forEach((childName) => {
|
|
288
|
-
this.extractUniformsRecursively(
|
|
289
|
-
childName,
|
|
290
|
-
// @ts-ignore
|
|
291
|
-
child[childName],
|
|
292
|
-
uniforms,
|
|
293
|
-
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
294
|
-
);
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
export {
|
|
301
|
-
ReglModel as default
|
|
302
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { IRenderbuffer, IRenderbufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* adaptor for regl.Renderbuffer
|
|
5
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
|
|
6
|
-
*/
|
|
7
|
-
export default class ReglRenderbuffer implements IRenderbuffer {
|
|
8
|
-
private renderbuffer;
|
|
9
|
-
constructor(reGl: regl.Regl, options: IRenderbufferInitializationOptions);
|
|
10
|
-
get(): regl.Renderbuffer;
|
|
11
|
-
destroy(): void;
|
|
12
|
-
resize({ width, height }: {
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
}): void;
|
|
16
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglRenderbuffer.ts
|
|
2
|
-
import { formatMap } from "./constants";
|
|
3
|
-
var ReglRenderbuffer = class {
|
|
4
|
-
constructor(reGl, options) {
|
|
5
|
-
const { width, height, format } = options;
|
|
6
|
-
this.renderbuffer = reGl.renderbuffer({
|
|
7
|
-
width,
|
|
8
|
-
height,
|
|
9
|
-
format: formatMap[format]
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
get() {
|
|
13
|
-
return this.renderbuffer;
|
|
14
|
-
}
|
|
15
|
-
destroy() {
|
|
16
|
-
this.renderbuffer.destroy();
|
|
17
|
-
}
|
|
18
|
-
resize({ width, height }) {
|
|
19
|
-
this.renderbuffer.resize(width, height);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export {
|
|
23
|
-
ReglRenderbuffer as default
|
|
24
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import type regl from 'regl';
|
|
3
|
-
/**
|
|
4
|
-
* adaptor for regl.Buffer
|
|
5
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
6
|
-
*/
|
|
7
|
-
export default class ReglTexture2D implements ITexture2D {
|
|
8
|
-
private texture;
|
|
9
|
-
private width;
|
|
10
|
-
private height;
|
|
11
|
-
private isDestroy;
|
|
12
|
-
constructor(reGl: regl.Regl, options: ITexture2DInitializationOptions);
|
|
13
|
-
get(): regl.Texture2D;
|
|
14
|
-
update(props?: regl.Texture2DOptions): void;
|
|
15
|
-
bind(): void;
|
|
16
|
-
resize({ width, height }: {
|
|
17
|
-
width: number;
|
|
18
|
-
height: number;
|
|
19
|
-
}): void;
|
|
20
|
-
getSize(): [number, number];
|
|
21
|
-
destroy(): void;
|
|
22
|
-
}
|