@antv/l7-renderer 2.25.6 → 2.25.7
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/package.json +4 -4
- package/es/device/DeviceAttribute.d.ts +0 -13
- package/es/device/DeviceAttribute.js +0 -30
- package/es/device/DeviceBuffer.d.ts +0 -18
- package/es/device/DeviceBuffer.js +0 -51
- package/es/device/DeviceCache.d.ts +0 -14
- package/es/device/DeviceCache.js +0 -198
- package/es/device/DeviceElements.d.ts +0 -13
- package/es/device/DeviceElements.js +0 -42
- package/es/device/DeviceFramebuffer.d.ts +0 -24
- package/es/device/DeviceFramebuffer.js +0 -81
- package/es/device/DeviceModel.d.ts +0 -61
- package/es/device/DeviceModel.js +0 -488
- package/es/device/DeviceTexture2D.d.ts +0 -23
- package/es/device/DeviceTexture2D.js +0 -132
- package/es/device/constants.d.ts +0 -35
- package/es/device/constants.js +0 -117
- package/es/device/index.d.ts +0 -68
- package/es/device/index.js +0 -311
- package/es/device/utils/HashMap.d.ts +0 -24
- package/es/device/utils/HashMap.js +0 -86
- package/es/device/utils/pipeline.d.ts +0 -1
- package/es/device/utils/pipeline.js +0 -6
- package/es/device/utils/typedarray.d.ts +0 -7
- package/es/device/utils/typedarray.js +0 -33
- package/es/device/utils/webgl.d.ts +0 -1
- package/es/device/utils/webgl.js +0 -10
- package/es/index.d.ts +0 -3
- package/es/index.js +0 -7
- 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/device/DeviceAttribute.d.ts +0 -13
- package/lib/device/DeviceAttribute.js +0 -50
- package/lib/device/DeviceBuffer.d.ts +0 -18
- package/lib/device/DeviceBuffer.js +0 -71
- package/lib/device/DeviceCache.d.ts +0 -14
- package/lib/device/DeviceCache.js +0 -214
- package/lib/device/DeviceElements.d.ts +0 -13
- package/lib/device/DeviceElements.js +0 -62
- package/lib/device/DeviceFramebuffer.d.ts +0 -24
- package/lib/device/DeviceFramebuffer.js +0 -101
- package/lib/device/DeviceModel.d.ts +0 -61
- package/lib/device/DeviceModel.js +0 -495
- package/lib/device/DeviceTexture2D.d.ts +0 -23
- package/lib/device/DeviceTexture2D.js +0 -151
- package/lib/device/constants.d.ts +0 -35
- package/lib/device/constants.js +0 -141
- package/lib/device/index.d.ts +0 -68
- package/lib/device/index.js +0 -332
- package/lib/device/utils/HashMap.d.ts +0 -24
- package/lib/device/utils/HashMap.js +0 -113
- package/lib/device/utils/pipeline.d.ts +0 -1
- package/lib/device/utils/pipeline.js +0 -30
- package/lib/device/utils/typedarray.d.ts +0 -7
- package/lib/device/utils/typedarray.js +0 -58
- package/lib/device/utils/webgl.d.ts +0 -1
- package/lib/device/utils/webgl.js +0 -34
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -42
- 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
|
@@ -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
|
-
}
|
package/es/regl/ReglTexture2D.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
// src/regl/ReglTexture2D.ts
|
|
2
|
-
import { gl } from "@antv/l7-core";
|
|
3
|
-
import {
|
|
4
|
-
colorSpaceMap,
|
|
5
|
-
dataTypeMap,
|
|
6
|
-
filterMap,
|
|
7
|
-
formatMap,
|
|
8
|
-
mipmapMap,
|
|
9
|
-
wrapModeMap
|
|
10
|
-
} from "./constants";
|
|
11
|
-
var ReglTexture2D = class {
|
|
12
|
-
constructor(reGl, options) {
|
|
13
|
-
this.isDestroy = false;
|
|
14
|
-
const {
|
|
15
|
-
data,
|
|
16
|
-
type = gl.UNSIGNED_BYTE,
|
|
17
|
-
width,
|
|
18
|
-
height,
|
|
19
|
-
flipY = false,
|
|
20
|
-
format = gl.RGBA,
|
|
21
|
-
mipmap = false,
|
|
22
|
-
wrapS = gl.CLAMP_TO_EDGE,
|
|
23
|
-
wrapT = gl.CLAMP_TO_EDGE,
|
|
24
|
-
aniso = 0,
|
|
25
|
-
alignment = 1,
|
|
26
|
-
premultiplyAlpha = false,
|
|
27
|
-
mag = gl.NEAREST,
|
|
28
|
-
min = gl.NEAREST,
|
|
29
|
-
colorSpace = gl.BROWSER_DEFAULT_WEBGL,
|
|
30
|
-
x = 0,
|
|
31
|
-
y = 0,
|
|
32
|
-
copy = false
|
|
33
|
-
} = options;
|
|
34
|
-
this.width = width;
|
|
35
|
-
this.height = height;
|
|
36
|
-
const textureOptions = {
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
39
|
-
// @ts-ignore
|
|
40
|
-
type: dataTypeMap[type],
|
|
41
|
-
format: formatMap[format],
|
|
42
|
-
wrapS: wrapModeMap[wrapS],
|
|
43
|
-
wrapT: wrapModeMap[wrapT],
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
mag: filterMap[mag],
|
|
46
|
-
min: filterMap[min],
|
|
47
|
-
alignment,
|
|
48
|
-
flipY,
|
|
49
|
-
colorSpace: colorSpaceMap[colorSpace],
|
|
50
|
-
premultiplyAlpha,
|
|
51
|
-
aniso,
|
|
52
|
-
// copy pixels from current bind framebuffer
|
|
53
|
-
x,
|
|
54
|
-
y,
|
|
55
|
-
copy
|
|
56
|
-
};
|
|
57
|
-
if (data) {
|
|
58
|
-
textureOptions.data = data;
|
|
59
|
-
}
|
|
60
|
-
if (typeof mipmap === "number") {
|
|
61
|
-
textureOptions.mipmap = mipmapMap[mipmap];
|
|
62
|
-
} else if (typeof mipmap === "boolean") {
|
|
63
|
-
textureOptions.mipmap = mipmap;
|
|
64
|
-
}
|
|
65
|
-
this.texture = reGl.texture(textureOptions);
|
|
66
|
-
}
|
|
67
|
-
get() {
|
|
68
|
-
return this.texture;
|
|
69
|
-
}
|
|
70
|
-
update(props = {}) {
|
|
71
|
-
this.texture(props);
|
|
72
|
-
}
|
|
73
|
-
bind() {
|
|
74
|
-
this.texture._texture.bind();
|
|
75
|
-
}
|
|
76
|
-
resize({ width, height }) {
|
|
77
|
-
this.texture.resize(width, height);
|
|
78
|
-
this.width = width;
|
|
79
|
-
this.height = height;
|
|
80
|
-
}
|
|
81
|
-
getSize() {
|
|
82
|
-
return [this.width, this.height];
|
|
83
|
-
}
|
|
84
|
-
destroy() {
|
|
85
|
-
var _a;
|
|
86
|
-
if (!this.isDestroy) {
|
|
87
|
-
(_a = this.texture) == null ? void 0 : _a.destroy();
|
|
88
|
-
}
|
|
89
|
-
this.isDestroy = true;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
export {
|
|
93
|
-
ReglTexture2D as default
|
|
94
|
-
};
|