@antv/l7-renderer 2.23.2 → 2.23.3-beta.0
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.
|
@@ -13,7 +13,15 @@ export default class DeviceModel implements IModel {
|
|
|
13
13
|
private indexBuffer;
|
|
14
14
|
private vertexBuffers;
|
|
15
15
|
private bindings;
|
|
16
|
+
private pipelineCache;
|
|
17
|
+
private currentPipelineKey;
|
|
16
18
|
constructor(device: Device, options: IModelInitializationOptions, service: DeviceRendererService);
|
|
19
|
+
/**
|
|
20
|
+
* 生成 Pipeline 缓存键,用于判断是否需要重新创建 Pipeline
|
|
21
|
+
* 包含所有影响 Pipeline 创建的参数
|
|
22
|
+
* 注意:当 blend/stencil 禁用时,使用简化的 key 以避免创建重复 Pipeline
|
|
23
|
+
*/
|
|
24
|
+
private getPipelineKey;
|
|
17
25
|
private createPipeline;
|
|
18
26
|
updateAttributesAndElements(): void;
|
|
19
27
|
/**
|
package/es/device/DeviceModel.js
CHANGED
|
@@ -54,6 +54,9 @@ var DeviceModel = class {
|
|
|
54
54
|
this.destroyed = false;
|
|
55
55
|
this.uniforms = {};
|
|
56
56
|
this.vertexBuffers = [];
|
|
57
|
+
// Pipeline cache to avoid recreating pipeline on every draw call
|
|
58
|
+
this.pipelineCache = /* @__PURE__ */ new Map();
|
|
59
|
+
this.currentPipelineKey = "";
|
|
57
60
|
const { vs, fs, attributes, uniforms, count, elements, diagnosticDerivativeUniformityEnabled } = options;
|
|
58
61
|
this.options = options;
|
|
59
62
|
const diagnosticDerivativeUniformityHeader = diagnosticDerivativeUniformityEnabled ? "" : this.service["viewportOrigin"] === ViewportOrigin.UPPER_LEFT ? "diagnostic(off,derivative_uniformity);" : "";
|
|
@@ -111,6 +114,61 @@ var DeviceModel = class {
|
|
|
111
114
|
});
|
|
112
115
|
this.inputLayout = inputLayout;
|
|
113
116
|
this.pipeline = this.createPipeline(options);
|
|
117
|
+
const initialKey = this.getPipelineKey(options);
|
|
118
|
+
this.pipelineCache.set(initialKey, this.pipeline);
|
|
119
|
+
this.currentPipelineKey = initialKey;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 生成 Pipeline 缓存键,用于判断是否需要重新创建 Pipeline
|
|
123
|
+
* 包含所有影响 Pipeline 创建的参数
|
|
124
|
+
* 注意:当 blend/stencil 禁用时,使用简化的 key 以避免创建重复 Pipeline
|
|
125
|
+
*/
|
|
126
|
+
getPipelineKey(options, pick) {
|
|
127
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
|
|
128
|
+
const { primitive = gl.TRIANGLES, depth, cull, blend, stencil } = options;
|
|
129
|
+
let stencilKey;
|
|
130
|
+
if (stencil == null ? void 0 : stencil.enable) {
|
|
131
|
+
stencilKey = [
|
|
132
|
+
1,
|
|
133
|
+
// enabled
|
|
134
|
+
(_a = stencil.mask) != null ? _a : 4294967295,
|
|
135
|
+
(_c = (_b = stencil.func) == null ? void 0 : _b.cmp) != null ? _c : gl.ALWAYS,
|
|
136
|
+
(_e = (_d = stencil.func) == null ? void 0 : _d.ref) != null ? _e : 0,
|
|
137
|
+
(_g = (_f = stencil.func) == null ? void 0 : _f.mask) != null ? _g : 4294967295,
|
|
138
|
+
(_i = (_h = stencil.opFront) == null ? void 0 : _h.fail) != null ? _i : gl.KEEP,
|
|
139
|
+
(_k = (_j = stencil.opFront) == null ? void 0 : _j.zfail) != null ? _k : gl.KEEP,
|
|
140
|
+
(_m = (_l = stencil.opFront) == null ? void 0 : _l.zpass) != null ? _m : gl.KEEP,
|
|
141
|
+
(_o = (_n = stencil.opBack) == null ? void 0 : _n.fail) != null ? _o : gl.KEEP,
|
|
142
|
+
(_q = (_p = stencil.opBack) == null ? void 0 : _p.zfail) != null ? _q : gl.KEEP,
|
|
143
|
+
(_s = (_r = stencil.opBack) == null ? void 0 : _r.zpass) != null ? _s : gl.KEEP
|
|
144
|
+
].join(",");
|
|
145
|
+
} else {
|
|
146
|
+
stencilKey = "0";
|
|
147
|
+
}
|
|
148
|
+
let blendKey;
|
|
149
|
+
if (blend == null ? void 0 : blend.enable) {
|
|
150
|
+
blendKey = [
|
|
151
|
+
1,
|
|
152
|
+
// enabled
|
|
153
|
+
(_u = (_t = blend.func) == null ? void 0 : _t.srcRGB) != null ? _u : gl.SRC_ALPHA,
|
|
154
|
+
(_w = (_v = blend.func) == null ? void 0 : _v.dstRGB) != null ? _w : gl.ONE_MINUS_SRC_ALPHA,
|
|
155
|
+
(_y = (_x = blend.func) == null ? void 0 : _x.srcAlpha) != null ? _y : gl.SRC_ALPHA,
|
|
156
|
+
(_A = (_z = blend.func) == null ? void 0 : _z.dstAlpha) != null ? _A : gl.ONE_MINUS_SRC_ALPHA,
|
|
157
|
+
(_C = (_B = blend.equation) == null ? void 0 : _B.rgb) != null ? _C : gl.FUNC_ADD,
|
|
158
|
+
(_E = (_D = blend.equation) == null ? void 0 : _D.alpha) != null ? _E : gl.FUNC_ADD
|
|
159
|
+
].join(",");
|
|
160
|
+
} else {
|
|
161
|
+
blendKey = "0";
|
|
162
|
+
}
|
|
163
|
+
const parts = [
|
|
164
|
+
`primitive:${primitive}`,
|
|
165
|
+
`pick:${!!pick}`,
|
|
166
|
+
`depth:${(_F = depth == null ? void 0 : depth.enable) != null ? _F : true}:${(_G = depth == null ? void 0 : depth.func) != null ? _G : gl.LESS}:${(_H = depth == null ? void 0 : depth.mask) != null ? _H : true}`,
|
|
167
|
+
`cull:${(_I = cull == null ? void 0 : cull.enable) != null ? _I : false}:${(_J = cull == null ? void 0 : cull.face) != null ? _J : gl.BACK}`,
|
|
168
|
+
`blend:${blendKey}`,
|
|
169
|
+
`stencil:${stencilKey}`
|
|
170
|
+
];
|
|
171
|
+
return parts.join("|");
|
|
114
172
|
}
|
|
115
173
|
createPipeline(options, pick) {
|
|
116
174
|
var _a;
|
|
@@ -213,20 +271,28 @@ var DeviceModel = class {
|
|
|
213
271
|
} = mergedOptions;
|
|
214
272
|
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
215
273
|
const { renderPass, currentFramebuffer, width, height } = this.service;
|
|
216
|
-
|
|
274
|
+
const pipelineKey = this.getPipelineKey(mergedOptions, pick);
|
|
275
|
+
let cachedPipeline = this.pipelineCache.get(pipelineKey);
|
|
276
|
+
if (!cachedPipeline) {
|
|
277
|
+
cachedPipeline = this.createPipeline(mergedOptions, pick);
|
|
278
|
+
this.pipelineCache.set(pipelineKey, cachedPipeline);
|
|
279
|
+
}
|
|
280
|
+
this.pipeline = cachedPipeline;
|
|
281
|
+
this.currentPipelineKey = pipelineKey;
|
|
217
282
|
const device = this.service["device"];
|
|
218
|
-
const tmpHeight = device
|
|
219
|
-
device
|
|
283
|
+
const tmpHeight = device.swapChainHeight;
|
|
284
|
+
device.swapChainHeight = (currentFramebuffer == null ? void 0 : currentFramebuffer["height"]) || height;
|
|
220
285
|
renderPass.setViewport(
|
|
221
286
|
0,
|
|
222
287
|
0,
|
|
223
288
|
(currentFramebuffer == null ? void 0 : currentFramebuffer["width"]) || width,
|
|
224
289
|
(currentFramebuffer == null ? void 0 : currentFramebuffer["height"]) || height
|
|
225
290
|
);
|
|
226
|
-
device
|
|
291
|
+
device.swapChainHeight = tmpHeight;
|
|
227
292
|
renderPass.setPipeline(this.pipeline);
|
|
228
|
-
|
|
229
|
-
|
|
293
|
+
const extendedPipeline = this.pipeline;
|
|
294
|
+
if (!isNil(extendedPipeline.stencilFuncReference)) {
|
|
295
|
+
renderPass.setStencilReference(extendedPipeline.stencilFuncReference);
|
|
230
296
|
}
|
|
231
297
|
renderPass.setVertexInput(
|
|
232
298
|
this.inputLayout,
|
|
@@ -262,7 +328,8 @@ var DeviceModel = class {
|
|
|
262
328
|
if (uniform instanceof DeviceTexture2D) {
|
|
263
329
|
this.uniforms[uniformName] = uniform.get();
|
|
264
330
|
} else if (uniform instanceof DeviceFramebuffer) {
|
|
265
|
-
|
|
331
|
+
const renderTarget = uniform.get();
|
|
332
|
+
this.uniforms[uniformName] = renderTarget.texture;
|
|
266
333
|
}
|
|
267
334
|
});
|
|
268
335
|
this.program.setUniformsLegacy(this.uniforms);
|
|
@@ -283,7 +350,8 @@ var DeviceModel = class {
|
|
|
283
350
|
(_a = this.vertexBuffers) == null ? void 0 : _a.forEach((buffer) => buffer.destroy());
|
|
284
351
|
(_b = this.indexBuffer) == null ? void 0 : _b.destroy();
|
|
285
352
|
(_c = this.bindings) == null ? void 0 : _c.destroy();
|
|
286
|
-
this.pipeline.destroy();
|
|
353
|
+
this.pipelineCache.forEach((pipeline) => pipeline.destroy());
|
|
354
|
+
this.pipelineCache.clear();
|
|
287
355
|
this.destroyed = true;
|
|
288
356
|
}
|
|
289
357
|
initDepthDrawParams({ depth }) {
|
|
@@ -381,21 +449,18 @@ var DeviceModel = class {
|
|
|
381
449
|
return extractedUniforms;
|
|
382
450
|
}
|
|
383
451
|
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
384
|
-
|
|
385
|
-
typeof uniformValue === "boolean" ||
|
|
386
|
-
|
|
387
|
-
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
388
|
-
// @ts-ignore
|
|
389
|
-
uniformValue === "" || "resize" in uniformValue) {
|
|
452
|
+
const isPrimitiveType = uniformValue === null || typeof uniformValue === "string" || // 包括空字符串
|
|
453
|
+
typeof uniformValue === "number" || typeof uniformValue === "boolean" || Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || isTypedArray(uniformValue);
|
|
454
|
+
if (isPrimitiveType || uniformValue !== null && typeof uniformValue === "object" && "resize" in uniformValue) {
|
|
390
455
|
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
391
456
|
return;
|
|
392
457
|
}
|
|
393
458
|
if (isPlainObject(uniformValue)) {
|
|
394
|
-
|
|
459
|
+
const obj = uniformValue;
|
|
460
|
+
Object.keys(obj).forEach((childName) => {
|
|
395
461
|
this.extractUniformsRecursively(
|
|
396
462
|
childName,
|
|
397
|
-
|
|
398
|
-
uniformValue[childName],
|
|
463
|
+
obj[childName],
|
|
399
464
|
uniforms,
|
|
400
465
|
`${prefix && prefix + "."}${uniformName}`
|
|
401
466
|
);
|
|
@@ -403,15 +468,17 @@ var DeviceModel = class {
|
|
|
403
468
|
}
|
|
404
469
|
if (Array.isArray(uniformValue)) {
|
|
405
470
|
uniformValue.forEach((child, idx) => {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
471
|
+
if (isPlainObject(child)) {
|
|
472
|
+
const childObj = child;
|
|
473
|
+
Object.keys(childObj).forEach((childName) => {
|
|
474
|
+
this.extractUniformsRecursively(
|
|
475
|
+
childName,
|
|
476
|
+
childObj[childName],
|
|
477
|
+
uniforms,
|
|
478
|
+
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
479
|
+
);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
415
482
|
});
|
|
416
483
|
}
|
|
417
484
|
}
|
|
@@ -13,7 +13,15 @@ export default class DeviceModel implements IModel {
|
|
|
13
13
|
private indexBuffer;
|
|
14
14
|
private vertexBuffers;
|
|
15
15
|
private bindings;
|
|
16
|
+
private pipelineCache;
|
|
17
|
+
private currentPipelineKey;
|
|
16
18
|
constructor(device: Device, options: IModelInitializationOptions, service: DeviceRendererService);
|
|
19
|
+
/**
|
|
20
|
+
* 生成 Pipeline 缓存键,用于判断是否需要重新创建 Pipeline
|
|
21
|
+
* 包含所有影响 Pipeline 创建的参数
|
|
22
|
+
* 注意:当 blend/stencil 禁用时,使用简化的 key 以避免创建重复 Pipeline
|
|
23
|
+
*/
|
|
24
|
+
private getPipelineKey;
|
|
17
25
|
private createPipeline;
|
|
18
26
|
updateAttributesAndElements(): void;
|
|
19
27
|
/**
|
|
@@ -64,6 +64,9 @@ var DeviceModel = class {
|
|
|
64
64
|
this.destroyed = false;
|
|
65
65
|
this.uniforms = {};
|
|
66
66
|
this.vertexBuffers = [];
|
|
67
|
+
// Pipeline cache to avoid recreating pipeline on every draw call
|
|
68
|
+
this.pipelineCache = /* @__PURE__ */ new Map();
|
|
69
|
+
this.currentPipelineKey = "";
|
|
67
70
|
const { vs, fs, attributes, uniforms, count, elements, diagnosticDerivativeUniformityEnabled } = options;
|
|
68
71
|
this.options = options;
|
|
69
72
|
const diagnosticDerivativeUniformityHeader = diagnosticDerivativeUniformityEnabled ? "" : this.service["viewportOrigin"] === import_g_device_api.ViewportOrigin.UPPER_LEFT ? "diagnostic(off,derivative_uniformity);" : "";
|
|
@@ -121,6 +124,61 @@ var DeviceModel = class {
|
|
|
121
124
|
});
|
|
122
125
|
this.inputLayout = inputLayout;
|
|
123
126
|
this.pipeline = this.createPipeline(options);
|
|
127
|
+
const initialKey = this.getPipelineKey(options);
|
|
128
|
+
this.pipelineCache.set(initialKey, this.pipeline);
|
|
129
|
+
this.currentPipelineKey = initialKey;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 生成 Pipeline 缓存键,用于判断是否需要重新创建 Pipeline
|
|
133
|
+
* 包含所有影响 Pipeline 创建的参数
|
|
134
|
+
* 注意:当 blend/stencil 禁用时,使用简化的 key 以避免创建重复 Pipeline
|
|
135
|
+
*/
|
|
136
|
+
getPipelineKey(options, pick) {
|
|
137
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
|
|
138
|
+
const { primitive = import_l7_core.gl.TRIANGLES, depth, cull, blend, stencil } = options;
|
|
139
|
+
let stencilKey;
|
|
140
|
+
if (stencil == null ? void 0 : stencil.enable) {
|
|
141
|
+
stencilKey = [
|
|
142
|
+
1,
|
|
143
|
+
// enabled
|
|
144
|
+
(_a = stencil.mask) != null ? _a : 4294967295,
|
|
145
|
+
(_c = (_b = stencil.func) == null ? void 0 : _b.cmp) != null ? _c : import_l7_core.gl.ALWAYS,
|
|
146
|
+
(_e = (_d = stencil.func) == null ? void 0 : _d.ref) != null ? _e : 0,
|
|
147
|
+
(_g = (_f = stencil.func) == null ? void 0 : _f.mask) != null ? _g : 4294967295,
|
|
148
|
+
(_i = (_h = stencil.opFront) == null ? void 0 : _h.fail) != null ? _i : import_l7_core.gl.KEEP,
|
|
149
|
+
(_k = (_j = stencil.opFront) == null ? void 0 : _j.zfail) != null ? _k : import_l7_core.gl.KEEP,
|
|
150
|
+
(_m = (_l = stencil.opFront) == null ? void 0 : _l.zpass) != null ? _m : import_l7_core.gl.KEEP,
|
|
151
|
+
(_o = (_n = stencil.opBack) == null ? void 0 : _n.fail) != null ? _o : import_l7_core.gl.KEEP,
|
|
152
|
+
(_q = (_p = stencil.opBack) == null ? void 0 : _p.zfail) != null ? _q : import_l7_core.gl.KEEP,
|
|
153
|
+
(_s = (_r = stencil.opBack) == null ? void 0 : _r.zpass) != null ? _s : import_l7_core.gl.KEEP
|
|
154
|
+
].join(",");
|
|
155
|
+
} else {
|
|
156
|
+
stencilKey = "0";
|
|
157
|
+
}
|
|
158
|
+
let blendKey;
|
|
159
|
+
if (blend == null ? void 0 : blend.enable) {
|
|
160
|
+
blendKey = [
|
|
161
|
+
1,
|
|
162
|
+
// enabled
|
|
163
|
+
(_u = (_t = blend.func) == null ? void 0 : _t.srcRGB) != null ? _u : import_l7_core.gl.SRC_ALPHA,
|
|
164
|
+
(_w = (_v = blend.func) == null ? void 0 : _v.dstRGB) != null ? _w : import_l7_core.gl.ONE_MINUS_SRC_ALPHA,
|
|
165
|
+
(_y = (_x = blend.func) == null ? void 0 : _x.srcAlpha) != null ? _y : import_l7_core.gl.SRC_ALPHA,
|
|
166
|
+
(_A = (_z = blend.func) == null ? void 0 : _z.dstAlpha) != null ? _A : import_l7_core.gl.ONE_MINUS_SRC_ALPHA,
|
|
167
|
+
(_C = (_B = blend.equation) == null ? void 0 : _B.rgb) != null ? _C : import_l7_core.gl.FUNC_ADD,
|
|
168
|
+
(_E = (_D = blend.equation) == null ? void 0 : _D.alpha) != null ? _E : import_l7_core.gl.FUNC_ADD
|
|
169
|
+
].join(",");
|
|
170
|
+
} else {
|
|
171
|
+
blendKey = "0";
|
|
172
|
+
}
|
|
173
|
+
const parts = [
|
|
174
|
+
`primitive:${primitive}`,
|
|
175
|
+
`pick:${!!pick}`,
|
|
176
|
+
`depth:${(_F = depth == null ? void 0 : depth.enable) != null ? _F : true}:${(_G = depth == null ? void 0 : depth.func) != null ? _G : import_l7_core.gl.LESS}:${(_H = depth == null ? void 0 : depth.mask) != null ? _H : true}`,
|
|
177
|
+
`cull:${(_I = cull == null ? void 0 : cull.enable) != null ? _I : false}:${(_J = cull == null ? void 0 : cull.face) != null ? _J : import_l7_core.gl.BACK}`,
|
|
178
|
+
`blend:${blendKey}`,
|
|
179
|
+
`stencil:${stencilKey}`
|
|
180
|
+
];
|
|
181
|
+
return parts.join("|");
|
|
124
182
|
}
|
|
125
183
|
createPipeline(options, pick) {
|
|
126
184
|
var _a;
|
|
@@ -223,20 +281,28 @@ var DeviceModel = class {
|
|
|
223
281
|
} = mergedOptions;
|
|
224
282
|
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
225
283
|
const { renderPass, currentFramebuffer, width, height } = this.service;
|
|
226
|
-
|
|
284
|
+
const pipelineKey = this.getPipelineKey(mergedOptions, pick);
|
|
285
|
+
let cachedPipeline = this.pipelineCache.get(pipelineKey);
|
|
286
|
+
if (!cachedPipeline) {
|
|
287
|
+
cachedPipeline = this.createPipeline(mergedOptions, pick);
|
|
288
|
+
this.pipelineCache.set(pipelineKey, cachedPipeline);
|
|
289
|
+
}
|
|
290
|
+
this.pipeline = cachedPipeline;
|
|
291
|
+
this.currentPipelineKey = pipelineKey;
|
|
227
292
|
const device = this.service["device"];
|
|
228
|
-
const tmpHeight = device
|
|
229
|
-
device
|
|
293
|
+
const tmpHeight = device.swapChainHeight;
|
|
294
|
+
device.swapChainHeight = (currentFramebuffer == null ? void 0 : currentFramebuffer["height"]) || height;
|
|
230
295
|
renderPass.setViewport(
|
|
231
296
|
0,
|
|
232
297
|
0,
|
|
233
298
|
(currentFramebuffer == null ? void 0 : currentFramebuffer["width"]) || width,
|
|
234
299
|
(currentFramebuffer == null ? void 0 : currentFramebuffer["height"]) || height
|
|
235
300
|
);
|
|
236
|
-
device
|
|
301
|
+
device.swapChainHeight = tmpHeight;
|
|
237
302
|
renderPass.setPipeline(this.pipeline);
|
|
238
|
-
|
|
239
|
-
|
|
303
|
+
const extendedPipeline = this.pipeline;
|
|
304
|
+
if (!isNil(extendedPipeline.stencilFuncReference)) {
|
|
305
|
+
renderPass.setStencilReference(extendedPipeline.stencilFuncReference);
|
|
240
306
|
}
|
|
241
307
|
renderPass.setVertexInput(
|
|
242
308
|
this.inputLayout,
|
|
@@ -272,7 +338,8 @@ var DeviceModel = class {
|
|
|
272
338
|
if (uniform instanceof import_DeviceTexture2D.default) {
|
|
273
339
|
this.uniforms[uniformName] = uniform.get();
|
|
274
340
|
} else if (uniform instanceof import_DeviceFramebuffer.default) {
|
|
275
|
-
|
|
341
|
+
const renderTarget = uniform.get();
|
|
342
|
+
this.uniforms[uniformName] = renderTarget.texture;
|
|
276
343
|
}
|
|
277
344
|
});
|
|
278
345
|
this.program.setUniformsLegacy(this.uniforms);
|
|
@@ -293,7 +360,8 @@ var DeviceModel = class {
|
|
|
293
360
|
(_a = this.vertexBuffers) == null ? void 0 : _a.forEach((buffer) => buffer.destroy());
|
|
294
361
|
(_b = this.indexBuffer) == null ? void 0 : _b.destroy();
|
|
295
362
|
(_c = this.bindings) == null ? void 0 : _c.destroy();
|
|
296
|
-
this.pipeline.destroy();
|
|
363
|
+
this.pipelineCache.forEach((pipeline) => pipeline.destroy());
|
|
364
|
+
this.pipelineCache.clear();
|
|
297
365
|
this.destroyed = true;
|
|
298
366
|
}
|
|
299
367
|
initDepthDrawParams({ depth }) {
|
|
@@ -391,21 +459,18 @@ var DeviceModel = class {
|
|
|
391
459
|
return extractedUniforms;
|
|
392
460
|
}
|
|
393
461
|
extractUniformsRecursively(uniformName, uniformValue, uniforms, prefix) {
|
|
394
|
-
|
|
395
|
-
typeof uniformValue === "boolean" ||
|
|
396
|
-
|
|
397
|
-
isTypedArray(uniformValue) || // u_A: Float32Array
|
|
398
|
-
// @ts-ignore
|
|
399
|
-
uniformValue === "" || "resize" in uniformValue) {
|
|
462
|
+
const isPrimitiveType = uniformValue === null || typeof uniformValue === "string" || // 包括空字符串
|
|
463
|
+
typeof uniformValue === "number" || typeof uniformValue === "boolean" || Array.isArray(uniformValue) && typeof uniformValue[0] === "number" || isTypedArray(uniformValue);
|
|
464
|
+
if (isPrimitiveType || uniformValue !== null && typeof uniformValue === "object" && "resize" in uniformValue) {
|
|
400
465
|
uniforms[`${prefix && prefix + "."}${uniformName}`] = uniformValue;
|
|
401
466
|
return;
|
|
402
467
|
}
|
|
403
468
|
if (isPlainObject(uniformValue)) {
|
|
404
|
-
|
|
469
|
+
const obj = uniformValue;
|
|
470
|
+
Object.keys(obj).forEach((childName) => {
|
|
405
471
|
this.extractUniformsRecursively(
|
|
406
472
|
childName,
|
|
407
|
-
|
|
408
|
-
uniformValue[childName],
|
|
473
|
+
obj[childName],
|
|
409
474
|
uniforms,
|
|
410
475
|
`${prefix && prefix + "."}${uniformName}`
|
|
411
476
|
);
|
|
@@ -413,15 +478,17 @@ var DeviceModel = class {
|
|
|
413
478
|
}
|
|
414
479
|
if (Array.isArray(uniformValue)) {
|
|
415
480
|
uniformValue.forEach((child, idx) => {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
481
|
+
if (isPlainObject(child)) {
|
|
482
|
+
const childObj = child;
|
|
483
|
+
Object.keys(childObj).forEach((childName) => {
|
|
484
|
+
this.extractUniformsRecursively(
|
|
485
|
+
childName,
|
|
486
|
+
childObj[childName],
|
|
487
|
+
uniforms,
|
|
488
|
+
`${prefix && prefix + "."}${uniformName}[${idx}]`
|
|
489
|
+
);
|
|
490
|
+
});
|
|
491
|
+
}
|
|
425
492
|
});
|
|
426
493
|
}
|
|
427
494
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.23.
|
|
3
|
+
"version": "2.23.3-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "https://github.com/orgs/antvis/people",
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
"@antv/g-device-api": "^1.6.4",
|
|
17
17
|
"@babel/runtime": "^7.7.7",
|
|
18
18
|
"regl": "1.6.1",
|
|
19
|
-
"@antv/l7-
|
|
20
|
-
"@antv/l7-
|
|
19
|
+
"@antv/l7-utils": "2.23.3-beta.0",
|
|
20
|
+
"@antv/l7-core": "2.23.3-beta.0"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@antv/l7-test-utils": "^2.23.
|
|
23
|
+
"@antv/l7-test-utils": "^2.23.3-beta.0"
|
|
24
24
|
},
|
|
25
25
|
"publishConfig": {
|
|
26
26
|
"access": "public",
|