@antv/l7-renderer 2.25.7 → 2.25.9
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.d.ts +13 -0
- package/es/device/DeviceAttribute.js +30 -0
- package/es/device/DeviceBuffer.d.ts +18 -0
- package/es/device/DeviceBuffer.js +51 -0
- package/es/device/DeviceCache.d.ts +14 -0
- package/es/device/DeviceCache.js +198 -0
- package/es/device/DeviceElements.d.ts +13 -0
- package/es/device/DeviceElements.js +42 -0
- package/es/device/DeviceFramebuffer.d.ts +24 -0
- package/es/device/DeviceFramebuffer.js +81 -0
- package/es/device/DeviceModel.d.ts +61 -0
- package/es/device/DeviceModel.js +488 -0
- package/es/device/DeviceTexture2D.d.ts +23 -0
- package/es/device/DeviceTexture2D.js +132 -0
- package/es/device/constants.d.ts +35 -0
- package/es/device/constants.js +117 -0
- package/es/device/index.d.ts +68 -0
- package/es/device/index.js +311 -0
- package/es/device/utils/HashMap.d.ts +24 -0
- package/es/device/utils/HashMap.js +86 -0
- package/es/device/utils/pipeline.d.ts +1 -0
- package/es/device/utils/pipeline.js +6 -0
- package/es/device/utils/typedarray.d.ts +7 -0
- package/es/device/utils/typedarray.js +33 -0
- package/es/device/utils/webgl.d.ts +1 -0
- package/es/device/utils/webgl.js +10 -0
- package/es/index.d.ts +3 -0
- package/es/index.js +7 -0
- package/es/regl/ReglAttribute.d.ts +16 -0
- package/es/regl/ReglAttribute.js +29 -0
- package/es/regl/ReglBuffer.d.ts +17 -0
- package/es/regl/ReglBuffer.js +33 -0
- package/es/regl/ReglElements.d.ts +14 -0
- package/es/regl/ReglElements.js +27 -0
- package/es/regl/ReglFramebuffer.d.ts +16 -0
- package/es/regl/ReglFramebuffer.js +31 -0
- package/es/regl/ReglModel.d.ts +46 -0
- package/es/regl/ReglModel.js +302 -0
- package/es/regl/ReglRenderbuffer.d.ts +16 -0
- package/es/regl/ReglRenderbuffer.js +24 -0
- package/es/regl/ReglTexture2D.d.ts +22 -0
- package/es/regl/ReglTexture2D.js +94 -0
- package/es/regl/constants.d.ts +43 -0
- package/es/regl/constants.js +133 -0
- package/es/regl/index.d.ts +56 -0
- package/es/regl/index.js +227 -0
- package/lib/device/DeviceAttribute.d.ts +13 -0
- package/lib/device/DeviceAttribute.js +50 -0
- package/lib/device/DeviceBuffer.d.ts +18 -0
- package/lib/device/DeviceBuffer.js +71 -0
- package/lib/device/DeviceCache.d.ts +14 -0
- package/lib/device/DeviceCache.js +214 -0
- package/lib/device/DeviceElements.d.ts +13 -0
- package/lib/device/DeviceElements.js +62 -0
- package/lib/device/DeviceFramebuffer.d.ts +24 -0
- package/lib/device/DeviceFramebuffer.js +101 -0
- package/lib/device/DeviceModel.d.ts +61 -0
- package/lib/device/DeviceModel.js +495 -0
- package/lib/device/DeviceTexture2D.d.ts +23 -0
- package/lib/device/DeviceTexture2D.js +151 -0
- package/lib/device/constants.d.ts +35 -0
- package/lib/device/constants.js +141 -0
- package/lib/device/index.d.ts +68 -0
- package/lib/device/index.js +332 -0
- package/lib/device/utils/HashMap.d.ts +24 -0
- package/lib/device/utils/HashMap.js +113 -0
- package/lib/device/utils/pipeline.d.ts +1 -0
- package/lib/device/utils/pipeline.js +30 -0
- package/lib/device/utils/typedarray.d.ts +7 -0
- package/lib/device/utils/typedarray.js +58 -0
- package/lib/device/utils/webgl.d.ts +1 -0
- package/lib/device/utils/webgl.js +34 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +42 -0
- package/lib/regl/ReglAttribute.d.ts +16 -0
- package/lib/regl/ReglAttribute.js +49 -0
- package/lib/regl/ReglBuffer.d.ts +17 -0
- package/lib/regl/ReglBuffer.js +53 -0
- package/lib/regl/ReglElements.d.ts +14 -0
- package/lib/regl/ReglElements.js +47 -0
- package/lib/regl/ReglFramebuffer.d.ts +16 -0
- package/lib/regl/ReglFramebuffer.js +51 -0
- package/lib/regl/ReglModel.d.ts +46 -0
- package/lib/regl/ReglModel.js +311 -0
- package/lib/regl/ReglRenderbuffer.d.ts +16 -0
- package/lib/regl/ReglRenderbuffer.js +44 -0
- package/lib/regl/ReglTexture2D.d.ts +22 -0
- package/lib/regl/ReglTexture2D.js +107 -0
- package/lib/regl/constants.d.ts +43 -0
- package/lib/regl/constants.js +170 -0
- package/lib/regl/index.d.ts +56 -0
- package/lib/regl/index.js +256 -0
- package/package.json +4 -4
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// src/regl/ReglModel.ts
|
|
37
|
+
var ReglModel_exports = {};
|
|
38
|
+
__export(ReglModel_exports, {
|
|
39
|
+
default: () => ReglModel
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(ReglModel_exports);
|
|
42
|
+
var import_g_device_api = require("@antv/g-device-api");
|
|
43
|
+
var import_l7_core = require("@antv/l7-core");
|
|
44
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
45
|
+
var import_constants = require("./constants");
|
|
46
|
+
var { isPlainObject, isTypedArray } = import_l7_utils.lodashUtil;
|
|
47
|
+
var ReglModel = class {
|
|
48
|
+
constructor(reGl, options) {
|
|
49
|
+
this.destroyed = false;
|
|
50
|
+
this.uniforms = {};
|
|
51
|
+
this.reGl = reGl;
|
|
52
|
+
const { vs, fs, attributes, uniforms, primitive, count, elements, depth, cull, instances } = options;
|
|
53
|
+
const vendorInfo = {
|
|
54
|
+
platformString: "WebGL1",
|
|
55
|
+
glslVersion: "#version 100",
|
|
56
|
+
explicitBindingLocations: false,
|
|
57
|
+
separateSamplerTextures: false,
|
|
58
|
+
viewportOrigin: import_g_device_api.ViewportOrigin.LOWER_LEFT,
|
|
59
|
+
clipSpaceNearZ: import_g_device_api.ClipSpaceNearZ.NEGATIVE_ONE,
|
|
60
|
+
supportMRT: false
|
|
61
|
+
};
|
|
62
|
+
const reglUniforms = {};
|
|
63
|
+
this.options = options;
|
|
64
|
+
if (uniforms) {
|
|
65
|
+
this.uniforms = this.extractUniforms(uniforms);
|
|
66
|
+
Object.keys(uniforms).forEach((uniformName) => {
|
|
67
|
+
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const reglAttributes = {};
|
|
71
|
+
Object.keys(attributes).forEach((name) => {
|
|
72
|
+
reglAttributes[name] = attributes[name].get();
|
|
73
|
+
});
|
|
74
|
+
const frag = (0, import_l7_core.removeDuplicateUniforms)(
|
|
75
|
+
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "frag", fs, null, false)
|
|
76
|
+
);
|
|
77
|
+
const vert = (0, import_l7_core.removeDuplicateUniforms)(
|
|
78
|
+
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "vert", vs, null, false)
|
|
79
|
+
);
|
|
80
|
+
const drawParams = {
|
|
81
|
+
attributes: reglAttributes,
|
|
82
|
+
frag,
|
|
83
|
+
uniforms: reglUniforms,
|
|
84
|
+
vert,
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
colorMask: reGl.prop("colorMask"),
|
|
87
|
+
lineWidth: 1,
|
|
88
|
+
blend: {
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
enable: reGl.prop("blend.enable"),
|
|
91
|
+
// @ts-ignore
|
|
92
|
+
func: reGl.prop("blend.func"),
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
equation: reGl.prop("blend.equation"),
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
color: reGl.prop("blend.color")
|
|
97
|
+
},
|
|
98
|
+
stencil: {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
enable: reGl.prop("stencil.enable"),
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
mask: reGl.prop("stencil.mask"),
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
func: reGl.prop("stencil.func"),
|
|
105
|
+
// @ts-ignore
|
|
106
|
+
opFront: reGl.prop("stencil.opFront"),
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
opBack: reGl.prop("stencil.opBack")
|
|
109
|
+
},
|
|
110
|
+
primitive: import_constants.primitiveMap[primitive === void 0 ? import_l7_core.gl.TRIANGLES : primitive]
|
|
111
|
+
};
|
|
112
|
+
if (instances) {
|
|
113
|
+
drawParams.instances = instances;
|
|
114
|
+
}
|
|
115
|
+
if (count) {
|
|
116
|
+
drawParams.count = count;
|
|
117
|
+
} else if (elements) {
|
|
118
|
+
drawParams.elements = elements.get();
|
|
119
|
+
}
|
|
120
|
+
this.initDepthDrawParams({ depth }, drawParams);
|
|
121
|
+
this.initCullDrawParams({ cull }, drawParams);
|
|
122
|
+
this.drawCommand = reGl(drawParams);
|
|
123
|
+
this.drawParams = drawParams;
|
|
124
|
+
}
|
|
125
|
+
updateAttributesAndElements(attributes, elements) {
|
|
126
|
+
const reglAttributes = {};
|
|
127
|
+
Object.keys(attributes).forEach((name) => {
|
|
128
|
+
reglAttributes[name] = attributes[name].get();
|
|
129
|
+
});
|
|
130
|
+
this.drawParams.attributes = reglAttributes;
|
|
131
|
+
this.drawParams.elements = elements.get();
|
|
132
|
+
this.drawCommand = this.reGl(this.drawParams);
|
|
133
|
+
}
|
|
134
|
+
updateAttributes(attributes) {
|
|
135
|
+
const reglAttributes = {};
|
|
136
|
+
Object.keys(attributes).forEach((name) => {
|
|
137
|
+
reglAttributes[name] = attributes[name].get();
|
|
138
|
+
});
|
|
139
|
+
this.drawParams.attributes = reglAttributes;
|
|
140
|
+
this.drawCommand = this.reGl(this.drawParams);
|
|
141
|
+
}
|
|
142
|
+
addUniforms(uniforms) {
|
|
143
|
+
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
144
|
+
}
|
|
145
|
+
draw(options, pick) {
|
|
146
|
+
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
const uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
150
|
+
const reglDrawProps = {};
|
|
151
|
+
Object.keys(uniforms).forEach((uniformName) => {
|
|
152
|
+
const type = typeof uniforms[uniformName];
|
|
153
|
+
if (type === "boolean" || type === "number" || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
154
|
+
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
155
|
+
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
156
|
+
} else {
|
|
157
|
+
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
reglDrawProps.blend = pick ? this.getBlendDrawParams({
|
|
161
|
+
blend: { enable: false }
|
|
162
|
+
}) : this.getBlendDrawParams(options);
|
|
163
|
+
reglDrawProps.stencil = this.getStencilDrawParams(options);
|
|
164
|
+
reglDrawProps.colorMask = this.getColorMaskDrawParams(options, pick);
|
|
165
|
+
this.drawCommand(reglDrawProps);
|
|
166
|
+
}
|
|
167
|
+
destroy() {
|
|
168
|
+
var _a, _b;
|
|
169
|
+
(_b = (_a = this.drawParams) == null ? void 0 : _a.elements) == null ? void 0 : _b.destroy();
|
|
170
|
+
if (this.options.attributes) {
|
|
171
|
+
Object.values(this.options.attributes).forEach((attr) => {
|
|
172
|
+
attr == null ? void 0 : attr.destroy();
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
this.destroyed = true;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
179
|
+
*/
|
|
180
|
+
initDepthDrawParams({ depth }, drawParams) {
|
|
181
|
+
if (depth) {
|
|
182
|
+
drawParams.depth = {
|
|
183
|
+
enable: depth.enable === void 0 ? true : !!depth.enable,
|
|
184
|
+
mask: depth.mask === void 0 ? true : !!depth.mask,
|
|
185
|
+
func: import_constants.depthFuncMap[depth.func || import_l7_core.gl.LESS],
|
|
186
|
+
range: depth.range || [0, 1]
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
getBlendDrawParams({ blend }) {
|
|
191
|
+
const { enable, func, equation, color = [0, 0, 0, 0] } = blend || {};
|
|
192
|
+
return {
|
|
193
|
+
enable: !!enable,
|
|
194
|
+
func: {
|
|
195
|
+
srcRGB: import_constants.blendFuncMap[func && func.srcRGB || import_l7_core.gl.SRC_ALPHA],
|
|
196
|
+
srcAlpha: import_constants.blendFuncMap[func && func.srcAlpha || import_l7_core.gl.SRC_ALPHA],
|
|
197
|
+
dstRGB: import_constants.blendFuncMap[func && func.dstRGB || import_l7_core.gl.ONE_MINUS_SRC_ALPHA],
|
|
198
|
+
dstAlpha: import_constants.blendFuncMap[func && func.dstAlpha || import_l7_core.gl.ONE_MINUS_SRC_ALPHA]
|
|
199
|
+
},
|
|
200
|
+
equation: {
|
|
201
|
+
rgb: import_constants.blendEquationMap[equation && equation.rgb || import_l7_core.gl.FUNC_ADD],
|
|
202
|
+
alpha: import_constants.blendEquationMap[equation && equation.alpha || import_l7_core.gl.FUNC_ADD]
|
|
203
|
+
},
|
|
204
|
+
color
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
209
|
+
*/
|
|
210
|
+
getStencilDrawParams({ stencil }) {
|
|
211
|
+
const {
|
|
212
|
+
enable,
|
|
213
|
+
mask = -1,
|
|
214
|
+
func = {
|
|
215
|
+
cmp: import_l7_core.gl.ALWAYS,
|
|
216
|
+
ref: 0,
|
|
217
|
+
mask: -1
|
|
218
|
+
},
|
|
219
|
+
opFront = {
|
|
220
|
+
fail: import_l7_core.gl.KEEP,
|
|
221
|
+
zfail: import_l7_core.gl.KEEP,
|
|
222
|
+
zpass: import_l7_core.gl.KEEP
|
|
223
|
+
},
|
|
224
|
+
opBack = {
|
|
225
|
+
fail: import_l7_core.gl.KEEP,
|
|
226
|
+
zfail: import_l7_core.gl.KEEP,
|
|
227
|
+
zpass: import_l7_core.gl.KEEP
|
|
228
|
+
}
|
|
229
|
+
} = stencil || {};
|
|
230
|
+
return {
|
|
231
|
+
enable: !!enable,
|
|
232
|
+
mask,
|
|
233
|
+
func: __spreadProps(__spreadValues({}, func), {
|
|
234
|
+
cmp: import_constants.stencilFuncMap[func.cmp]
|
|
235
|
+
}),
|
|
236
|
+
opFront: {
|
|
237
|
+
fail: import_constants.stencilOpMap[opFront.fail],
|
|
238
|
+
zfail: import_constants.stencilOpMap[opFront.zfail],
|
|
239
|
+
zpass: import_constants.stencilOpMap[opFront.zpass]
|
|
240
|
+
},
|
|
241
|
+
opBack: {
|
|
242
|
+
fail: import_constants.stencilOpMap[opBack.fail],
|
|
243
|
+
zfail: import_constants.stencilOpMap[opBack.zfail],
|
|
244
|
+
zpass: import_constants.stencilOpMap[opBack.zpass]
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
getColorMaskDrawParams({ stencil }, pick) {
|
|
249
|
+
const colorMask = (stencil == null ? void 0 : stencil.enable) && stencil.opFront && !pick ? [false, false, false, false] : [true, true, true, true];
|
|
250
|
+
return colorMask;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
254
|
+
*/
|
|
255
|
+
initCullDrawParams({ cull }, drawParams) {
|
|
256
|
+
if (cull) {
|
|
257
|
+
const { enable, face = import_l7_core.gl.BACK } = cull;
|
|
258
|
+
drawParams.cull = {
|
|
259
|
+
enable: !!enable,
|
|
260
|
+
face: import_constants.cullFaceMap[face]
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* 考虑结构体命名, eg:
|
|
266
|
+
* a: { b: 1 } -> 'a.b'
|
|
267
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
268
|
+
*/
|
|
269
|
+
extractUniforms(uniforms) {
|
|
270
|
+
const extractedUniforms = {};
|
|
271
|
+
Object.keys(uniforms).forEach((uniformName) => {
|
|
272
|
+
this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, "");
|
|
273
|
+
});
|
|
274
|
+
return extractedUniforms;
|
|
275
|
+
}
|
|
276
|
+
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
277
|
+
if (uniformValue === null || typeof uniformValue === "number" || // u_A: 1
|
|
278
|
+
typeof uniformValue === "boolean" || // u_A: false
|
|
279
|
+
Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || // u_A: [1, 2, 3]
|
|
280
|
+
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
281
|
+
// @ts-ignore
|
|
282
|
+
uniformValue === "" || "resize" in uniformValue) {
|
|
283
|
+
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
if (isPlainObject(uniformValue)) {
|
|
287
|
+
Object.keys(uniformValue).forEach((childName) => {
|
|
288
|
+
this.extractUniformsRecursively(
|
|
289
|
+
childName,
|
|
290
|
+
// @ts-ignore
|
|
291
|
+
uniformValue[childName],
|
|
292
|
+
uniforms,
|
|
293
|
+
`${prefix && prefix + "."}${uniformName}`
|
|
294
|
+
);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (Array.isArray(uniformValue)) {
|
|
298
|
+
uniformValue.forEach((child, idx) => {
|
|
299
|
+
Object.keys(child).forEach((childName) => {
|
|
300
|
+
this.extractUniformsRecursively(
|
|
301
|
+
childName,
|
|
302
|
+
// @ts-ignore
|
|
303
|
+
child[childName],
|
|
304
|
+
uniforms,
|
|
305
|
+
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
306
|
+
);
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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/ReglRenderbuffer.ts
|
|
20
|
+
var ReglRenderbuffer_exports = {};
|
|
21
|
+
__export(ReglRenderbuffer_exports, {
|
|
22
|
+
default: () => ReglRenderbuffer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ReglRenderbuffer_exports);
|
|
25
|
+
var import_constants = require("./constants");
|
|
26
|
+
var ReglRenderbuffer = class {
|
|
27
|
+
constructor(reGl, options) {
|
|
28
|
+
const { width, height, format } = options;
|
|
29
|
+
this.renderbuffer = reGl.renderbuffer({
|
|
30
|
+
width,
|
|
31
|
+
height,
|
|
32
|
+
format: import_constants.formatMap[format]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
get() {
|
|
36
|
+
return this.renderbuffer;
|
|
37
|
+
}
|
|
38
|
+
destroy() {
|
|
39
|
+
this.renderbuffer.destroy();
|
|
40
|
+
}
|
|
41
|
+
resize({ width, height }) {
|
|
42
|
+
this.renderbuffer.resize(width, height);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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/ReglTexture2D.ts
|
|
20
|
+
var ReglTexture2D_exports = {};
|
|
21
|
+
__export(ReglTexture2D_exports, {
|
|
22
|
+
default: () => ReglTexture2D
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(ReglTexture2D_exports);
|
|
25
|
+
var import_l7_core = require("@antv/l7-core");
|
|
26
|
+
var import_constants = require("./constants");
|
|
27
|
+
var ReglTexture2D = class {
|
|
28
|
+
constructor(reGl, options) {
|
|
29
|
+
this.isDestroy = false;
|
|
30
|
+
const {
|
|
31
|
+
data,
|
|
32
|
+
type = import_l7_core.gl.UNSIGNED_BYTE,
|
|
33
|
+
width,
|
|
34
|
+
height,
|
|
35
|
+
flipY = false,
|
|
36
|
+
format = import_l7_core.gl.RGBA,
|
|
37
|
+
mipmap = false,
|
|
38
|
+
wrapS = import_l7_core.gl.CLAMP_TO_EDGE,
|
|
39
|
+
wrapT = import_l7_core.gl.CLAMP_TO_EDGE,
|
|
40
|
+
aniso = 0,
|
|
41
|
+
alignment = 1,
|
|
42
|
+
premultiplyAlpha = false,
|
|
43
|
+
mag = import_l7_core.gl.NEAREST,
|
|
44
|
+
min = import_l7_core.gl.NEAREST,
|
|
45
|
+
colorSpace = import_l7_core.gl.BROWSER_DEFAULT_WEBGL,
|
|
46
|
+
x = 0,
|
|
47
|
+
y = 0,
|
|
48
|
+
copy = false
|
|
49
|
+
} = options;
|
|
50
|
+
this.width = width;
|
|
51
|
+
this.height = height;
|
|
52
|
+
const textureOptions = {
|
|
53
|
+
width,
|
|
54
|
+
height,
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
type: import_constants.dataTypeMap[type],
|
|
57
|
+
format: import_constants.formatMap[format],
|
|
58
|
+
wrapS: import_constants.wrapModeMap[wrapS],
|
|
59
|
+
wrapT: import_constants.wrapModeMap[wrapT],
|
|
60
|
+
// @ts-ignore
|
|
61
|
+
mag: import_constants.filterMap[mag],
|
|
62
|
+
min: import_constants.filterMap[min],
|
|
63
|
+
alignment,
|
|
64
|
+
flipY,
|
|
65
|
+
colorSpace: import_constants.colorSpaceMap[colorSpace],
|
|
66
|
+
premultiplyAlpha,
|
|
67
|
+
aniso,
|
|
68
|
+
// copy pixels from current bind framebuffer
|
|
69
|
+
x,
|
|
70
|
+
y,
|
|
71
|
+
copy
|
|
72
|
+
};
|
|
73
|
+
if (data) {
|
|
74
|
+
textureOptions.data = data;
|
|
75
|
+
}
|
|
76
|
+
if (typeof mipmap === "number") {
|
|
77
|
+
textureOptions.mipmap = import_constants.mipmapMap[mipmap];
|
|
78
|
+
} else if (typeof mipmap === "boolean") {
|
|
79
|
+
textureOptions.mipmap = mipmap;
|
|
80
|
+
}
|
|
81
|
+
this.texture = reGl.texture(textureOptions);
|
|
82
|
+
}
|
|
83
|
+
get() {
|
|
84
|
+
return this.texture;
|
|
85
|
+
}
|
|
86
|
+
update(props = {}) {
|
|
87
|
+
this.texture(props);
|
|
88
|
+
}
|
|
89
|
+
bind() {
|
|
90
|
+
this.texture._texture.bind();
|
|
91
|
+
}
|
|
92
|
+
resize({ width, height }) {
|
|
93
|
+
this.texture.resize(width, height);
|
|
94
|
+
this.width = width;
|
|
95
|
+
this.height = height;
|
|
96
|
+
}
|
|
97
|
+
getSize() {
|
|
98
|
+
return [this.width, this.height];
|
|
99
|
+
}
|
|
100
|
+
destroy() {
|
|
101
|
+
var _a;
|
|
102
|
+
if (!this.isDestroy) {
|
|
103
|
+
(_a = this.texture) == null ? void 0 : _a.destroy();
|
|
104
|
+
}
|
|
105
|
+
this.isDestroy = true;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type regl from 'regl';
|
|
2
|
+
export declare const primitiveMap: {
|
|
3
|
+
[key: string]: 'points' | 'lines' | 'line loop' | 'line strip' | 'triangles' | 'triangle strip' | 'triangle fan';
|
|
4
|
+
};
|
|
5
|
+
export declare const usageMap: {
|
|
6
|
+
[key: string]: 'static' | 'dynamic' | 'stream';
|
|
7
|
+
};
|
|
8
|
+
export declare const dataTypeMap: {
|
|
9
|
+
[key: string]: 'int8' | 'int16' | 'int32' | 'uint8' | 'uint16' | 'uint32' | 'float';
|
|
10
|
+
};
|
|
11
|
+
export declare const formatMap: {
|
|
12
|
+
[key: string]: 'alpha' | 'luminance' | 'luminance alpha' | 'rgb' | 'rgba' | 'rgba4' | 'rgb5 a1' | 'rgb565' | 'depth' | 'depth stencil';
|
|
13
|
+
};
|
|
14
|
+
export declare const mipmapMap: {
|
|
15
|
+
[key: string]: 'dont care' | 'nice' | 'fast';
|
|
16
|
+
};
|
|
17
|
+
export declare const filterMap: {
|
|
18
|
+
[key: string]: 'nearest' | 'linear' | 'mipmap' | 'nearest mipmap linear' | 'linear mipmap nearest' | 'nearest mipmap nearest';
|
|
19
|
+
};
|
|
20
|
+
export declare const wrapModeMap: {
|
|
21
|
+
[key: string]: 'repeat' | 'clamp' | 'mirror';
|
|
22
|
+
};
|
|
23
|
+
export declare const colorSpaceMap: {
|
|
24
|
+
[key: string]: 'none' | 'browser';
|
|
25
|
+
};
|
|
26
|
+
export declare const depthFuncMap: {
|
|
27
|
+
[key: string]: 'never' | 'always' | 'less' | 'lequal' | 'greater' | 'gequal' | 'equal' | 'notequal';
|
|
28
|
+
};
|
|
29
|
+
export declare const blendEquationMap: {
|
|
30
|
+
[key: string]: regl.BlendingEquation;
|
|
31
|
+
};
|
|
32
|
+
export declare const blendFuncMap: {
|
|
33
|
+
[key: string]: regl.BlendingFunction;
|
|
34
|
+
};
|
|
35
|
+
export declare const stencilFuncMap: {
|
|
36
|
+
[key: string]: regl.ComparisonOperatorType;
|
|
37
|
+
};
|
|
38
|
+
export declare const stencilOpMap: {
|
|
39
|
+
[key: string]: regl.StencilOperationType;
|
|
40
|
+
};
|
|
41
|
+
export declare const cullFaceMap: {
|
|
42
|
+
[key: string]: regl.FaceOrientationType;
|
|
43
|
+
};
|