@antv/l7-renderer 2.9.37-alpha.1 → 2.9.37-alpha.2
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 +5 -5
- package/es/index.d.ts +0 -5
- package/es/index.js +0 -5
- package/es/regl/ReglAttribute.d.ts +0 -16
- package/es/regl/ReglAttribute.js +0 -51
- package/es/regl/ReglBuffer.d.ts +0 -16
- package/es/regl/ReglBuffer.js +0 -47
- package/es/regl/ReglElements.d.ts +0 -14
- package/es/regl/ReglElements.js +0 -45
- package/es/regl/ReglFramebuffer.d.ts +0 -16
- package/es/regl/ReglFramebuffer.js +0 -57
- package/es/regl/ReglModel.d.ts +0 -49
- package/es/regl/ReglModel.js +0 -362
- package/es/regl/ReglRenderbuffer.d.ts +0 -16
- package/es/regl/ReglRenderbuffer.js +0 -45
- package/es/regl/ReglTexture2D.d.ts +0 -21
- package/es/regl/ReglTexture2D.js +0 -130
- package/es/regl/constants.d.ts +0 -43
- package/es/regl/constants.js +0 -23
- package/es/regl/index.d.ts +0 -51
- package/es/regl/index.js +0 -313
- package/lib/index.js +0 -32
- package/lib/regl/ReglAttribute.js +0 -51
- package/lib/regl/ReglBuffer.js +0 -50
- package/lib/regl/ReglElements.js +0 -49
- package/lib/regl/ReglFramebuffer.js +0 -51
- package/lib/regl/ReglModel.js +0 -269
- package/lib/regl/ReglRenderbuffer.js +0 -46
- package/lib/regl/ReglTexture2D.js +0 -103
- package/lib/regl/constants.js +0 -170
- package/lib/regl/index.js +0 -225
package/es/regl/ReglModel.js
DELETED
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
import { gl } from '@antv/l7-core';
|
|
7
|
-
import { cloneDeep, isPlainObject, isTypedArray } from 'lodash';
|
|
8
|
-
import { blendEquationMap, blendFuncMap, cullFaceMap, depthFuncMap, primitiveMap, stencilFuncMap, stencilOpMap } from "./constants";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* adaptor for regl.DrawCommand
|
|
12
|
-
*/
|
|
13
|
-
var ReglModel = /*#__PURE__*/function () {
|
|
14
|
-
function ReglModel(reGl, options) {
|
|
15
|
-
_classCallCheck(this, ReglModel);
|
|
16
|
-
|
|
17
|
-
_defineProperty(this, "destroyed", false);
|
|
18
|
-
|
|
19
|
-
_defineProperty(this, "uniforms", {});
|
|
20
|
-
|
|
21
|
-
this.reGl = reGl;
|
|
22
|
-
var _options$pick = options.pick,
|
|
23
|
-
pick = _options$pick === void 0 ? true : _options$pick,
|
|
24
|
-
vs = options.vs,
|
|
25
|
-
fs = options.fs,
|
|
26
|
-
attributes = options.attributes,
|
|
27
|
-
uniforms = options.uniforms,
|
|
28
|
-
primitive = options.primitive,
|
|
29
|
-
count = options.count,
|
|
30
|
-
elements = options.elements,
|
|
31
|
-
depth = options.depth,
|
|
32
|
-
blend = options.blend,
|
|
33
|
-
stencil = options.stencil,
|
|
34
|
-
cull = options.cull,
|
|
35
|
-
instances = options.instances;
|
|
36
|
-
var reglUniforms = {};
|
|
37
|
-
this.options = options;
|
|
38
|
-
|
|
39
|
-
if (uniforms) {
|
|
40
|
-
this.uniforms = this.extractUniforms(uniforms);
|
|
41
|
-
Object.keys(uniforms).forEach(function (uniformName) {
|
|
42
|
-
// use regl prop API
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
reglUniforms[uniformName] = reGl.prop(uniformName);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
var reglAttributes = {};
|
|
49
|
-
Object.keys(attributes).forEach(function (name) {
|
|
50
|
-
reglAttributes[name] = attributes[name].get();
|
|
51
|
-
});
|
|
52
|
-
var drawParams = {
|
|
53
|
-
attributes: reglAttributes,
|
|
54
|
-
frag: fs,
|
|
55
|
-
uniforms: reglUniforms,
|
|
56
|
-
vert: vs,
|
|
57
|
-
blend: {},
|
|
58
|
-
primitive: primitiveMap[primitive === undefined ? gl.TRIANGLES : primitive]
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
if (instances) {
|
|
62
|
-
drawParams.instances = instances;
|
|
63
|
-
} // Tip:
|
|
64
|
-
// elements 中可能包含 count,此时不应传入
|
|
65
|
-
// count 和 elements 相比、count 优先
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (count) {
|
|
69
|
-
drawParams.count = count;
|
|
70
|
-
} else if (elements) {
|
|
71
|
-
drawParams.elements = elements.get();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
this.initDepthDrawParams({
|
|
75
|
-
depth: depth
|
|
76
|
-
}, drawParams);
|
|
77
|
-
this.initBlendDrawParams({
|
|
78
|
-
blend: blend
|
|
79
|
-
}, drawParams);
|
|
80
|
-
this.initStencilDrawParams({
|
|
81
|
-
stencil: stencil
|
|
82
|
-
}, drawParams);
|
|
83
|
-
this.initCullDrawParams({
|
|
84
|
-
cull: cull
|
|
85
|
-
}, drawParams);
|
|
86
|
-
this.drawCommand = reGl(drawParams);
|
|
87
|
-
|
|
88
|
-
if (pick) {
|
|
89
|
-
var pickDrawParams = cloneDeep(drawParams);
|
|
90
|
-
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
91
|
-
enable: false
|
|
92
|
-
});
|
|
93
|
-
this.drawPickCommand = reGl(pickDrawParams);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.drawParams = drawParams;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
_createClass(ReglModel, [{
|
|
100
|
-
key: "updateAttributesAndElements",
|
|
101
|
-
value: function updateAttributesAndElements(attributes, elements) {
|
|
102
|
-
var reglAttributes = {};
|
|
103
|
-
Object.keys(attributes).forEach(function (name) {
|
|
104
|
-
reglAttributes[name] = attributes[name].get();
|
|
105
|
-
});
|
|
106
|
-
this.drawParams.attributes = reglAttributes;
|
|
107
|
-
this.drawParams.elements = elements.get();
|
|
108
|
-
this.drawCommand = this.reGl(this.drawParams);
|
|
109
|
-
|
|
110
|
-
if (this.options.pick) {
|
|
111
|
-
var pickDrawParams = cloneDeep(this.drawParams);
|
|
112
|
-
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
113
|
-
enable: false
|
|
114
|
-
});
|
|
115
|
-
this.drawPickCommand = this.reGl(pickDrawParams);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}, {
|
|
119
|
-
key: "updateAttributes",
|
|
120
|
-
value: function updateAttributes(attributes) {
|
|
121
|
-
var reglAttributes = {};
|
|
122
|
-
Object.keys(attributes).forEach(function (name) {
|
|
123
|
-
reglAttributes[name] = attributes[name].get();
|
|
124
|
-
});
|
|
125
|
-
this.drawParams.attributes = reglAttributes;
|
|
126
|
-
this.drawCommand = this.reGl(this.drawParams);
|
|
127
|
-
|
|
128
|
-
if (this.options.pick) {
|
|
129
|
-
var pickDrawParams = cloneDeep(this.drawParams);
|
|
130
|
-
pickDrawParams.blend = _objectSpread(_objectSpread({}, pickDrawParams.blend), {}, {
|
|
131
|
-
enable: false
|
|
132
|
-
});
|
|
133
|
-
this.drawPickCommand = this.reGl(pickDrawParams);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "addUniforms",
|
|
138
|
-
value: function addUniforms(uniforms) {
|
|
139
|
-
this.uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(uniforms));
|
|
140
|
-
}
|
|
141
|
-
}, {
|
|
142
|
-
key: "draw",
|
|
143
|
-
value: function draw(options, pick) {
|
|
144
|
-
// console.log('options', this.drawParams)
|
|
145
|
-
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
var uniforms = _objectSpread(_objectSpread({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
150
|
-
|
|
151
|
-
var reglDrawProps = {};
|
|
152
|
-
Object.keys(uniforms).forEach(function (uniformName) {
|
|
153
|
-
var type = _typeof(uniforms[uniformName]);
|
|
154
|
-
|
|
155
|
-
if (type === 'boolean' || type === 'number' || Array.isArray(uniforms[uniformName]) || // @ts-ignore
|
|
156
|
-
uniforms[uniformName].BYTES_PER_ELEMENT) {
|
|
157
|
-
reglDrawProps[uniformName] = uniforms[uniformName];
|
|
158
|
-
} else {
|
|
159
|
-
reglDrawProps[uniformName] = uniforms[uniformName].get();
|
|
160
|
-
}
|
|
161
|
-
}); // 在进行拾取操作的绘制中,不应该使用叠加模式 - picking 根据拾取的颜色作为判断的输入,而叠加模式会产生新的,在 id 序列中不存在的颜色
|
|
162
|
-
|
|
163
|
-
if (!pick) {
|
|
164
|
-
this.drawCommand(reglDrawProps);
|
|
165
|
-
} else {
|
|
166
|
-
this.drawPickCommand && this.drawPickCommand(reglDrawProps);
|
|
167
|
-
} // this.drawCommand(reglDrawProps);
|
|
168
|
-
// this.drawPickCommand(reglDrawProps);
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "destroy",
|
|
173
|
-
value: function destroy() {
|
|
174
|
-
var _this$drawParams, _this$drawParams$elem;
|
|
175
|
-
|
|
176
|
-
// @ts-ignore
|
|
177
|
-
(_this$drawParams = this.drawParams) === null || _this$drawParams === void 0 ? void 0 : (_this$drawParams$elem = _this$drawParams.elements) === null || _this$drawParams$elem === void 0 ? void 0 : _this$drawParams$elem.destroy();
|
|
178
|
-
|
|
179
|
-
if (this.options.attributes) {
|
|
180
|
-
Object.values(this.options.attributes).forEach(function (attr) {
|
|
181
|
-
// @ts-ignore
|
|
182
|
-
attr === null || attr === void 0 ? void 0 : attr.destroy();
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
this.destroyed = true;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
190
|
-
*/
|
|
191
|
-
|
|
192
|
-
}, {
|
|
193
|
-
key: "initDepthDrawParams",
|
|
194
|
-
value: function initDepthDrawParams(_ref, drawParams) {
|
|
195
|
-
var depth = _ref.depth;
|
|
196
|
-
|
|
197
|
-
if (depth) {
|
|
198
|
-
drawParams.depth = {
|
|
199
|
-
enable: depth.enable === undefined ? true : !!depth.enable,
|
|
200
|
-
mask: depth.mask === undefined ? true : !!depth.mask,
|
|
201
|
-
func: depthFuncMap[depth.func || gl.LESS],
|
|
202
|
-
range: depth.range || [0, 1]
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#blending
|
|
208
|
-
*/
|
|
209
|
-
|
|
210
|
-
}, {
|
|
211
|
-
key: "initBlendDrawParams",
|
|
212
|
-
value: function initBlendDrawParams(_ref2, drawParams) {
|
|
213
|
-
var blend = _ref2.blend;
|
|
214
|
-
|
|
215
|
-
if (blend) {
|
|
216
|
-
var enable = blend.enable,
|
|
217
|
-
func = blend.func,
|
|
218
|
-
equation = blend.equation,
|
|
219
|
-
_blend$color = blend.color,
|
|
220
|
-
color = _blend$color === void 0 ? [0, 0, 0, 0] : _blend$color; // @ts-ignore
|
|
221
|
-
|
|
222
|
-
drawParams.blend = {
|
|
223
|
-
enable: !!enable,
|
|
224
|
-
func: {
|
|
225
|
-
srcRGB: blendFuncMap[func && func.srcRGB || gl.SRC_ALPHA],
|
|
226
|
-
srcAlpha: blendFuncMap[func && func.srcAlpha || gl.SRC_ALPHA],
|
|
227
|
-
dstRGB: blendFuncMap[func && func.dstRGB || gl.ONE_MINUS_SRC_ALPHA],
|
|
228
|
-
dstAlpha: blendFuncMap[func && func.dstAlpha || gl.ONE_MINUS_SRC_ALPHA]
|
|
229
|
-
},
|
|
230
|
-
equation: {
|
|
231
|
-
rgb: blendEquationMap[equation && equation.rgb || gl.FUNC_ADD],
|
|
232
|
-
alpha: blendEquationMap[equation && equation.alpha || gl.FUNC_ADD]
|
|
233
|
-
},
|
|
234
|
-
color: color
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
|
-
}, {
|
|
243
|
-
key: "initStencilDrawParams",
|
|
244
|
-
value: function initStencilDrawParams(_ref3, drawParams) {
|
|
245
|
-
var stencil = _ref3.stencil;
|
|
246
|
-
|
|
247
|
-
if (stencil) {
|
|
248
|
-
var enable = stencil.enable,
|
|
249
|
-
_stencil$mask = stencil.mask,
|
|
250
|
-
mask = _stencil$mask === void 0 ? -1 : _stencil$mask,
|
|
251
|
-
_stencil$func = stencil.func,
|
|
252
|
-
func = _stencil$func === void 0 ? {
|
|
253
|
-
cmp: gl.ALWAYS,
|
|
254
|
-
ref: 0,
|
|
255
|
-
mask: -1
|
|
256
|
-
} : _stencil$func,
|
|
257
|
-
_stencil$opFront = stencil.opFront,
|
|
258
|
-
opFront = _stencil$opFront === void 0 ? {
|
|
259
|
-
fail: gl.KEEP,
|
|
260
|
-
zfail: gl.KEEP,
|
|
261
|
-
zpass: gl.KEEP
|
|
262
|
-
} : _stencil$opFront,
|
|
263
|
-
_stencil$opBack = stencil.opBack,
|
|
264
|
-
opBack = _stencil$opBack === void 0 ? {
|
|
265
|
-
fail: gl.KEEP,
|
|
266
|
-
zfail: gl.KEEP,
|
|
267
|
-
zpass: gl.KEEP
|
|
268
|
-
} : _stencil$opBack;
|
|
269
|
-
drawParams.stencil = {
|
|
270
|
-
enable: !!enable,
|
|
271
|
-
mask: mask,
|
|
272
|
-
func: _objectSpread(_objectSpread({}, func), {}, {
|
|
273
|
-
cmp: stencilFuncMap[func.cmp]
|
|
274
|
-
}),
|
|
275
|
-
opFront: {
|
|
276
|
-
fail: stencilOpMap[opFront.fail],
|
|
277
|
-
zfail: stencilOpMap[opFront.zfail],
|
|
278
|
-
zpass: stencilOpMap[opFront.zpass]
|
|
279
|
-
},
|
|
280
|
-
opBack: {
|
|
281
|
-
fail: stencilOpMap[opBack.fail],
|
|
282
|
-
zfail: stencilOpMap[opBack.zfail],
|
|
283
|
-
zpass: stencilOpMap[opBack.zpass]
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
290
|
-
*/
|
|
291
|
-
|
|
292
|
-
}, {
|
|
293
|
-
key: "initCullDrawParams",
|
|
294
|
-
value: function initCullDrawParams(_ref4, drawParams) {
|
|
295
|
-
var cull = _ref4.cull;
|
|
296
|
-
|
|
297
|
-
if (cull) {
|
|
298
|
-
var enable = cull.enable,
|
|
299
|
-
_cull$face = cull.face,
|
|
300
|
-
face = _cull$face === void 0 ? gl.BACK : _cull$face;
|
|
301
|
-
drawParams.cull = {
|
|
302
|
-
enable: !!enable,
|
|
303
|
-
face: cullFaceMap[face]
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
/**
|
|
308
|
-
* 考虑结构体命名, eg:
|
|
309
|
-
* a: { b: 1 } -> 'a.b'
|
|
310
|
-
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
311
|
-
*/
|
|
312
|
-
|
|
313
|
-
}, {
|
|
314
|
-
key: "extractUniforms",
|
|
315
|
-
value: function extractUniforms(uniforms) {
|
|
316
|
-
var _this = this;
|
|
317
|
-
|
|
318
|
-
var extractedUniforms = {};
|
|
319
|
-
Object.keys(uniforms).forEach(function (uniformName) {
|
|
320
|
-
_this.extractUniformsRecursively(uniformName, uniforms[uniformName], extractedUniforms, '');
|
|
321
|
-
});
|
|
322
|
-
return extractedUniforms;
|
|
323
|
-
}
|
|
324
|
-
}, {
|
|
325
|
-
key: "extractUniformsRecursively",
|
|
326
|
-
value: function extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
327
|
-
var _this2 = this;
|
|
328
|
-
|
|
329
|
-
if (uniformValue === null || typeof uniformValue === 'number' || // u_A: 1
|
|
330
|
-
typeof uniformValue === 'boolean' || // u_A: false
|
|
331
|
-
Array.isArray(uniformValue) && typeof uniformValue[0] === 'number' || // u_A: [1, 2, 3]
|
|
332
|
-
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
333
|
-
// @ts-ignore
|
|
334
|
-
uniformValue === '' || 'resize' in uniformValue) {
|
|
335
|
-
uniforms["".concat(prefix && prefix + '.').concat(uniformName)] = uniformValue;
|
|
336
|
-
return;
|
|
337
|
-
} // u_Struct.a.b.c
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (isPlainObject(uniformValue)) {
|
|
341
|
-
Object.keys(uniformValue).forEach(function (childName) {
|
|
342
|
-
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
343
|
-
uniformValue[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName));
|
|
344
|
-
});
|
|
345
|
-
} // u_Struct[0].a
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
if (Array.isArray(uniformValue)) {
|
|
349
|
-
uniformValue.forEach(function (child, idx) {
|
|
350
|
-
Object.keys(child).forEach(function (childName) {
|
|
351
|
-
_this2.extractUniformsRecursively(childName, // @ts-ignore
|
|
352
|
-
child[childName], uniforms, "".concat(prefix && prefix + '.').concat(uniformName, "[").concat(idx, "]"));
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
}]);
|
|
358
|
-
|
|
359
|
-
return ReglModel;
|
|
360
|
-
}();
|
|
361
|
-
|
|
362
|
-
export { ReglModel as default };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { IRenderbuffer, IRenderbufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import regl from 'l7regl';
|
|
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,45 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import { formatMap } from "./constants";
|
|
4
|
-
/**
|
|
5
|
-
* adaptor for regl.Renderbuffer
|
|
6
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#renderbuffers
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
var ReglRenderbuffer = /*#__PURE__*/function () {
|
|
10
|
-
function ReglRenderbuffer(reGl, options) {
|
|
11
|
-
_classCallCheck(this, ReglRenderbuffer);
|
|
12
|
-
|
|
13
|
-
var width = options.width,
|
|
14
|
-
height = options.height,
|
|
15
|
-
format = options.format;
|
|
16
|
-
this.renderbuffer = reGl.renderbuffer({
|
|
17
|
-
width: width,
|
|
18
|
-
height: height,
|
|
19
|
-
format: formatMap[format]
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
_createClass(ReglRenderbuffer, [{
|
|
24
|
-
key: "get",
|
|
25
|
-
value: function get() {
|
|
26
|
-
return this.renderbuffer;
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "destroy",
|
|
30
|
-
value: function destroy() {
|
|
31
|
-
this.renderbuffer.destroy();
|
|
32
|
-
}
|
|
33
|
-
}, {
|
|
34
|
-
key: "resize",
|
|
35
|
-
value: function resize(_ref) {
|
|
36
|
-
var width = _ref.width,
|
|
37
|
-
height = _ref.height;
|
|
38
|
-
this.renderbuffer.resize(width, height);
|
|
39
|
-
}
|
|
40
|
-
}]);
|
|
41
|
-
|
|
42
|
-
return ReglRenderbuffer;
|
|
43
|
-
}();
|
|
44
|
-
|
|
45
|
-
export { ReglRenderbuffer as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
|
|
2
|
-
import regl from 'l7regl';
|
|
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 isDistroy;
|
|
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
|
-
destroy(): void;
|
|
21
|
-
}
|
package/es/regl/ReglTexture2D.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
|
-
import { gl } from '@antv/l7-core';
|
|
5
|
-
import { colorSpaceMap, dataTypeMap, filterMap, formatMap, mipmapMap, wrapModeMap } from "./constants";
|
|
6
|
-
/**
|
|
7
|
-
* adaptor for regl.Buffer
|
|
8
|
-
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var ReglTexture2D = /*#__PURE__*/function () {
|
|
12
|
-
function ReglTexture2D(reGl, options) {
|
|
13
|
-
_classCallCheck(this, ReglTexture2D);
|
|
14
|
-
|
|
15
|
-
_defineProperty(this, "isDistroy", false);
|
|
16
|
-
|
|
17
|
-
var data = options.data,
|
|
18
|
-
_options$type = options.type,
|
|
19
|
-
type = _options$type === void 0 ? gl.UNSIGNED_BYTE : _options$type,
|
|
20
|
-
width = options.width,
|
|
21
|
-
height = options.height,
|
|
22
|
-
_options$flipY = options.flipY,
|
|
23
|
-
flipY = _options$flipY === void 0 ? false : _options$flipY,
|
|
24
|
-
_options$format = options.format,
|
|
25
|
-
format = _options$format === void 0 ? gl.RGBA : _options$format,
|
|
26
|
-
_options$mipmap = options.mipmap,
|
|
27
|
-
mipmap = _options$mipmap === void 0 ? false : _options$mipmap,
|
|
28
|
-
_options$wrapS = options.wrapS,
|
|
29
|
-
wrapS = _options$wrapS === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapS,
|
|
30
|
-
_options$wrapT = options.wrapT,
|
|
31
|
-
wrapT = _options$wrapT === void 0 ? gl.CLAMP_TO_EDGE : _options$wrapT,
|
|
32
|
-
_options$aniso = options.aniso,
|
|
33
|
-
aniso = _options$aniso === void 0 ? 0 : _options$aniso,
|
|
34
|
-
_options$alignment = options.alignment,
|
|
35
|
-
alignment = _options$alignment === void 0 ? 1 : _options$alignment,
|
|
36
|
-
_options$premultiplyA = options.premultiplyAlpha,
|
|
37
|
-
premultiplyAlpha = _options$premultiplyA === void 0 ? false : _options$premultiplyA,
|
|
38
|
-
_options$mag = options.mag,
|
|
39
|
-
mag = _options$mag === void 0 ? gl.NEAREST : _options$mag,
|
|
40
|
-
_options$min = options.min,
|
|
41
|
-
min = _options$min === void 0 ? gl.NEAREST : _options$min,
|
|
42
|
-
_options$colorSpace = options.colorSpace,
|
|
43
|
-
colorSpace = _options$colorSpace === void 0 ? gl.BROWSER_DEFAULT_WEBGL : _options$colorSpace,
|
|
44
|
-
_options$x = options.x,
|
|
45
|
-
x = _options$x === void 0 ? 0 : _options$x,
|
|
46
|
-
_options$y = options.y,
|
|
47
|
-
y = _options$y === void 0 ? 0 : _options$y,
|
|
48
|
-
_options$copy = options.copy,
|
|
49
|
-
copy = _options$copy === void 0 ? false : _options$copy;
|
|
50
|
-
this.width = width;
|
|
51
|
-
this.height = height;
|
|
52
|
-
var textureOptions = {
|
|
53
|
-
width: width,
|
|
54
|
-
height: height,
|
|
55
|
-
// @ts-ignore
|
|
56
|
-
type: dataTypeMap[type],
|
|
57
|
-
format: formatMap[format],
|
|
58
|
-
wrapS: wrapModeMap[wrapS],
|
|
59
|
-
wrapT: wrapModeMap[wrapT],
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
mag: filterMap[mag],
|
|
62
|
-
min: filterMap[min],
|
|
63
|
-
alignment: alignment,
|
|
64
|
-
flipY: flipY,
|
|
65
|
-
colorSpace: colorSpaceMap[colorSpace],
|
|
66
|
-
premultiplyAlpha: premultiplyAlpha,
|
|
67
|
-
aniso: aniso,
|
|
68
|
-
// copy pixels from current bind framebuffer
|
|
69
|
-
x: x,
|
|
70
|
-
y: y,
|
|
71
|
-
copy: copy
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
if (data) {
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
textureOptions.data = data;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (typeof mipmap === 'number') {
|
|
80
|
-
textureOptions.mipmap = mipmapMap[mipmap];
|
|
81
|
-
} else if (typeof mipmap === 'boolean') {
|
|
82
|
-
textureOptions.mipmap = mipmap;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
this.texture = reGl.texture(textureOptions);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
_createClass(ReglTexture2D, [{
|
|
89
|
-
key: "get",
|
|
90
|
-
value: function get() {
|
|
91
|
-
return this.texture;
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "update",
|
|
95
|
-
value: function update() {
|
|
96
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
97
|
-
this.texture(props);
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "bind",
|
|
101
|
-
value: function bind() {
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
this.texture._texture.bind();
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "resize",
|
|
107
|
-
value: function resize(_ref) {
|
|
108
|
-
var width = _ref.width,
|
|
109
|
-
height = _ref.height;
|
|
110
|
-
this.texture.resize(width, height);
|
|
111
|
-
this.width = width;
|
|
112
|
-
this.height = height;
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "destroy",
|
|
116
|
-
value: function destroy() {
|
|
117
|
-
if (!this.isDistroy) {
|
|
118
|
-
var _this$texture;
|
|
119
|
-
|
|
120
|
-
(_this$texture = this.texture) === null || _this$texture === void 0 ? void 0 : _this$texture.destroy();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
this.isDistroy = true;
|
|
124
|
-
}
|
|
125
|
-
}]);
|
|
126
|
-
|
|
127
|
-
return ReglTexture2D;
|
|
128
|
-
}();
|
|
129
|
-
|
|
130
|
-
export { ReglTexture2D as default };
|
package/es/regl/constants.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import regl from 'l7regl';
|
|
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
|
-
};
|
package/es/regl/constants.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
|
-
var _primitiveMap, _usageMap, _dataTypeMap, _formatMap, _mipmapMap, _filterMap, _wrapModeMap, _colorSpaceMap, _depthFuncMap, _blendEquationMap, _blendFuncMap, _stencilFuncMap, _stencilOpMap, _cullFaceMap;
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @desc 由于 regl 使用大量字符串而非 WebGL 常量,因此需要映射
|
|
7
|
-
*/
|
|
8
|
-
import { gl } from '@antv/l7-core';
|
|
9
|
-
// @see https://github.com/regl-project/regl/blob/gh-pages/lib/constants/primitives.json
|
|
10
|
-
export var primitiveMap = (_primitiveMap = {}, _defineProperty(_primitiveMap, gl.POINTS, 'points'), _defineProperty(_primitiveMap, gl.LINES, 'lines'), _defineProperty(_primitiveMap, gl.LINE_LOOP, 'line loop'), _defineProperty(_primitiveMap, gl.LINE_STRIP, 'line strip'), _defineProperty(_primitiveMap, gl.TRIANGLES, 'triangles'), _defineProperty(_primitiveMap, gl.TRIANGLE_FAN, 'triangle fan'), _defineProperty(_primitiveMap, gl.TRIANGLE_STRIP, 'triangle strip'), _primitiveMap);
|
|
11
|
-
export var usageMap = (_usageMap = {}, _defineProperty(_usageMap, gl.STATIC_DRAW, 'static'), _defineProperty(_usageMap, gl.DYNAMIC_DRAW, 'dynamic'), _defineProperty(_usageMap, gl.STREAM_DRAW, 'stream'), _usageMap);
|
|
12
|
-
export var dataTypeMap = (_dataTypeMap = {}, _defineProperty(_dataTypeMap, gl.BYTE, 'int8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'int16'), _defineProperty(_dataTypeMap, gl.INT, 'int32'), _defineProperty(_dataTypeMap, gl.UNSIGNED_BYTE, 'uint8'), _defineProperty(_dataTypeMap, gl.UNSIGNED_SHORT, 'uint16'), _defineProperty(_dataTypeMap, gl.UNSIGNED_INT, 'uint32'), _defineProperty(_dataTypeMap, gl.FLOAT, 'float'), _dataTypeMap);
|
|
13
|
-
export var formatMap = (_formatMap = {}, _defineProperty(_formatMap, gl.ALPHA, 'alpha'), _defineProperty(_formatMap, gl.LUMINANCE, 'luminance'), _defineProperty(_formatMap, gl.LUMINANCE_ALPHA, 'luminance alpha'), _defineProperty(_formatMap, gl.RGB, 'rgb'), _defineProperty(_formatMap, gl.RGBA, 'rgba'), _defineProperty(_formatMap, gl.RGBA4, 'rgba4'), _defineProperty(_formatMap, gl.RGB5_A1, 'rgb5 a1'), _defineProperty(_formatMap, gl.RGB565, 'rgb565'), _defineProperty(_formatMap, gl.DEPTH_COMPONENT, 'depth'), _defineProperty(_formatMap, gl.DEPTH_STENCIL, 'depth stencil'), _formatMap);
|
|
14
|
-
export var mipmapMap = (_mipmapMap = {}, _defineProperty(_mipmapMap, gl.DONT_CARE, 'dont care'), _defineProperty(_mipmapMap, gl.NICEST, 'nice'), _defineProperty(_mipmapMap, gl.FASTEST, 'fast'), _mipmapMap);
|
|
15
|
-
export var filterMap = (_filterMap = {}, _defineProperty(_filterMap, gl.NEAREST, 'nearest'), _defineProperty(_filterMap, gl.LINEAR, 'linear'), _defineProperty(_filterMap, gl.LINEAR_MIPMAP_LINEAR, 'mipmap'), _defineProperty(_filterMap, gl.NEAREST_MIPMAP_LINEAR, 'nearest mipmap linear'), _defineProperty(_filterMap, gl.LINEAR_MIPMAP_NEAREST, 'linear mipmap nearest'), _defineProperty(_filterMap, gl.NEAREST_MIPMAP_NEAREST, 'nearest mipmap nearest'), _filterMap);
|
|
16
|
-
export var wrapModeMap = (_wrapModeMap = {}, _defineProperty(_wrapModeMap, gl.REPEAT, 'repeat'), _defineProperty(_wrapModeMap, gl.CLAMP_TO_EDGE, 'clamp'), _defineProperty(_wrapModeMap, gl.MIRRORED_REPEAT, 'mirror'), _wrapModeMap);
|
|
17
|
-
export var colorSpaceMap = (_colorSpaceMap = {}, _defineProperty(_colorSpaceMap, gl.NONE, 'none'), _defineProperty(_colorSpaceMap, gl.BROWSER_DEFAULT_WEBGL, 'browser'), _colorSpaceMap);
|
|
18
|
-
export var depthFuncMap = (_depthFuncMap = {}, _defineProperty(_depthFuncMap, gl.NEVER, 'never'), _defineProperty(_depthFuncMap, gl.ALWAYS, 'always'), _defineProperty(_depthFuncMap, gl.LESS, 'less'), _defineProperty(_depthFuncMap, gl.LEQUAL, 'lequal'), _defineProperty(_depthFuncMap, gl.GREATER, 'greater'), _defineProperty(_depthFuncMap, gl.GEQUAL, 'gequal'), _defineProperty(_depthFuncMap, gl.EQUAL, 'equal'), _defineProperty(_depthFuncMap, gl.NOTEQUAL, 'notequal'), _depthFuncMap);
|
|
19
|
-
export var blendEquationMap = (_blendEquationMap = {}, _defineProperty(_blendEquationMap, gl.FUNC_ADD, 'add'), _defineProperty(_blendEquationMap, gl.MIN_EXT, 'min'), _defineProperty(_blendEquationMap, gl.MAX_EXT, 'max'), _defineProperty(_blendEquationMap, gl.FUNC_SUBTRACT, 'subtract'), _defineProperty(_blendEquationMap, gl.FUNC_REVERSE_SUBTRACT, 'reverse subtract'), _blendEquationMap);
|
|
20
|
-
export var blendFuncMap = (_blendFuncMap = {}, _defineProperty(_blendFuncMap, gl.ZERO, 'zero'), _defineProperty(_blendFuncMap, gl.ONE, 'one'), _defineProperty(_blendFuncMap, gl.SRC_COLOR, 'src color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_COLOR, 'one minus src color'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA, 'src alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_SRC_ALPHA, 'one minus src alpha'), _defineProperty(_blendFuncMap, gl.DST_COLOR, 'dst color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_COLOR, 'one minus dst color'), _defineProperty(_blendFuncMap, gl.DST_ALPHA, 'dst alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_DST_ALPHA, 'one minus dst alpha'), _defineProperty(_blendFuncMap, gl.CONSTANT_COLOR, 'constant color'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_COLOR, 'one minus constant color'), _defineProperty(_blendFuncMap, gl.CONSTANT_ALPHA, 'constant alpha'), _defineProperty(_blendFuncMap, gl.ONE_MINUS_CONSTANT_ALPHA, 'one minus constant alpha'), _defineProperty(_blendFuncMap, gl.SRC_ALPHA_SATURATE, 'src alpha saturate'), _blendFuncMap);
|
|
21
|
-
export var stencilFuncMap = (_stencilFuncMap = {}, _defineProperty(_stencilFuncMap, gl.NEVER, 'never'), _defineProperty(_stencilFuncMap, gl.ALWAYS, 'always'), _defineProperty(_stencilFuncMap, gl.LESS, 'less'), _defineProperty(_stencilFuncMap, gl.LEQUAL, 'lequal'), _defineProperty(_stencilFuncMap, gl.GREATER, 'greater'), _defineProperty(_stencilFuncMap, gl.GEQUAL, 'gequal'), _defineProperty(_stencilFuncMap, gl.EQUAL, 'equal'), _defineProperty(_stencilFuncMap, gl.NOTEQUAL, 'notequal'), _stencilFuncMap);
|
|
22
|
-
export var stencilOpMap = (_stencilOpMap = {}, _defineProperty(_stencilOpMap, gl.ZERO, 'zero'), _defineProperty(_stencilOpMap, gl.KEEP, 'keep'), _defineProperty(_stencilOpMap, gl.REPLACE, 'replace'), _defineProperty(_stencilOpMap, gl.INVERT, 'invert'), _defineProperty(_stencilOpMap, gl.INCR, 'increment'), _defineProperty(_stencilOpMap, gl.DECR, 'decrement'), _defineProperty(_stencilOpMap, gl.INCR_WRAP, 'increment wrap'), _defineProperty(_stencilOpMap, gl.DECR_WRAP, 'decrement wrap'), _stencilOpMap);
|
|
23
|
-
export var cullFaceMap = (_cullFaceMap = {}, _defineProperty(_cullFaceMap, gl.FRONT, 'front'), _defineProperty(_cullFaceMap, gl.BACK, 'back'), _cullFaceMap);
|