@antv/l7-renderer 2.25.7 → 2.25.10
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,214 @@
|
|
|
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/device/DeviceCache.ts
|
|
20
|
+
var DeviceCache_exports = {};
|
|
21
|
+
__export(DeviceCache_exports, {
|
|
22
|
+
RenderCache: () => RenderCache
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(DeviceCache_exports);
|
|
25
|
+
var import_g_device_api = require("@antv/g-device-api");
|
|
26
|
+
var import_HashMap = require("./utils/HashMap");
|
|
27
|
+
function blendStateHash(hash, a) {
|
|
28
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.blendMode);
|
|
29
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.blendSrcFactor);
|
|
30
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.blendDstFactor);
|
|
31
|
+
return hash;
|
|
32
|
+
}
|
|
33
|
+
function attachmentStateHash(hash, a) {
|
|
34
|
+
hash = blendStateHash(hash, a.rgbBlendState);
|
|
35
|
+
hash = blendStateHash(hash, a.alphaBlendState);
|
|
36
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.channelWriteMask);
|
|
37
|
+
return hash;
|
|
38
|
+
}
|
|
39
|
+
function colorHash(hash, a) {
|
|
40
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.r << 24 | a.g << 16 | a.b << 8 | a.a);
|
|
41
|
+
return hash;
|
|
42
|
+
}
|
|
43
|
+
function megaStateDescriptorHash(hash, a) {
|
|
44
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
45
|
+
for (let i = 0; i < a.attachmentsState.length; i++)
|
|
46
|
+
hash = attachmentStateHash(hash, a.attachmentsState[i]);
|
|
47
|
+
hash = colorHash(hash, a.blendConstant || import_g_device_api.TransparentBlack);
|
|
48
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.depthCompare);
|
|
49
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.depthWrite ? 1 : 0);
|
|
50
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_a = a.stencilFront) == null ? void 0 : _a.compare);
|
|
51
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_b = a.stencilFront) == null ? void 0 : _b.passOp);
|
|
52
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_c = a.stencilFront) == null ? void 0 : _c.failOp);
|
|
53
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_d = a.stencilFront) == null ? void 0 : _d.depthFailOp);
|
|
54
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_e = a.stencilBack) == null ? void 0 : _e.compare);
|
|
55
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_f = a.stencilBack) == null ? void 0 : _f.passOp);
|
|
56
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_g = a.stencilBack) == null ? void 0 : _g.failOp);
|
|
57
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, (_h = a.stencilBack) == null ? void 0 : _h.depthFailOp);
|
|
58
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.stencilWrite ? 1 : 0);
|
|
59
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.cullMode);
|
|
60
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.frontFace ? 1 : 0);
|
|
61
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.polygonOffset ? 1 : 0);
|
|
62
|
+
return hash;
|
|
63
|
+
}
|
|
64
|
+
function renderPipelineDescriptorHash(a) {
|
|
65
|
+
let hash = 0;
|
|
66
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.program.id);
|
|
67
|
+
if (a.inputLayout !== null)
|
|
68
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.inputLayout.id);
|
|
69
|
+
hash = megaStateDescriptorHash(hash, a.megaStateDescriptor);
|
|
70
|
+
for (let i = 0; i < a.colorAttachmentFormats.length; i++)
|
|
71
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.colorAttachmentFormats[i] || 0);
|
|
72
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, a.depthStencilAttachmentFormat || 0);
|
|
73
|
+
return (0, import_HashMap.hashCodeNumberFinish)(hash);
|
|
74
|
+
}
|
|
75
|
+
function bindingsDescriptorHash(a) {
|
|
76
|
+
let hash = 0;
|
|
77
|
+
if (a.samplerBindings) {
|
|
78
|
+
for (let i = 0; i < a.samplerBindings.length; i++) {
|
|
79
|
+
const binding = a.samplerBindings[i];
|
|
80
|
+
if (binding !== null && binding.texture !== null)
|
|
81
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.texture.id);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (a.uniformBufferBindings) {
|
|
85
|
+
for (let i = 0; i < a.uniformBufferBindings.length; i++) {
|
|
86
|
+
const binding = a.uniformBufferBindings[i];
|
|
87
|
+
if (binding !== null && binding.buffer !== null) {
|
|
88
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.buffer.id);
|
|
89
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.binding);
|
|
90
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.offset);
|
|
91
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.size);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (a.storageBufferBindings) {
|
|
96
|
+
for (let i = 0; i < a.storageBufferBindings.length; i++) {
|
|
97
|
+
const binding = a.storageBufferBindings[i];
|
|
98
|
+
if (binding !== null && binding.buffer !== null) {
|
|
99
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.buffer.id);
|
|
100
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.binding);
|
|
101
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.offset);
|
|
102
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.size);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (a.storageTextureBindings) {
|
|
107
|
+
for (let i = 0; i < a.storageTextureBindings.length; i++) {
|
|
108
|
+
const binding = a.storageTextureBindings[i];
|
|
109
|
+
if (binding !== null && binding.texture !== null) {
|
|
110
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.texture.id);
|
|
111
|
+
hash = (0, import_HashMap.hashCodeNumberUpdate)(hash, binding.binding);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return (0, import_HashMap.hashCodeNumberFinish)(hash);
|
|
116
|
+
}
|
|
117
|
+
function programDescriptorEquals(a, b) {
|
|
118
|
+
var _a, _b, _c, _d;
|
|
119
|
+
return ((_a = a.vertex) == null ? void 0 : _a.glsl) === ((_b = b.vertex) == null ? void 0 : _b.glsl) && ((_c = a.fragment) == null ? void 0 : _c.glsl) === ((_d = b.fragment) == null ? void 0 : _d.glsl);
|
|
120
|
+
}
|
|
121
|
+
function programDescriptorCopy(a) {
|
|
122
|
+
var _a, _b;
|
|
123
|
+
return {
|
|
124
|
+
vertex: {
|
|
125
|
+
glsl: (_a = a.vertex) == null ? void 0 : _a.glsl
|
|
126
|
+
},
|
|
127
|
+
fragment: {
|
|
128
|
+
glsl: (_b = a.fragment) == null ? void 0 : _b.glsl
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
var RenderCache = class {
|
|
133
|
+
constructor(device) {
|
|
134
|
+
this.device = device;
|
|
135
|
+
this.bindingsCache = new import_HashMap.HashMap(
|
|
136
|
+
import_g_device_api.bindingsDescriptorEquals,
|
|
137
|
+
bindingsDescriptorHash
|
|
138
|
+
);
|
|
139
|
+
this.renderPipelinesCache = new import_HashMap.HashMap(
|
|
140
|
+
import_g_device_api.renderPipelineDescriptorEquals,
|
|
141
|
+
renderPipelineDescriptorHash
|
|
142
|
+
);
|
|
143
|
+
this.inputLayoutsCache = new import_HashMap.HashMap(
|
|
144
|
+
import_g_device_api.inputLayoutDescriptorEquals,
|
|
145
|
+
import_HashMap.nullHashFunc
|
|
146
|
+
);
|
|
147
|
+
this.programCache = new import_HashMap.HashMap(
|
|
148
|
+
programDescriptorEquals,
|
|
149
|
+
import_HashMap.nullHashFunc
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
createBindings(descriptor) {
|
|
153
|
+
var _a;
|
|
154
|
+
let bindings = this.bindingsCache.get(descriptor);
|
|
155
|
+
if (bindings === null) {
|
|
156
|
+
const descriptorCopy = (0, import_g_device_api.bindingsDescriptorCopy)(descriptor);
|
|
157
|
+
descriptorCopy.uniformBufferBindings = (_a = descriptorCopy.uniformBufferBindings) == null ? void 0 : _a.filter(
|
|
158
|
+
({ size }) => size && size > 0
|
|
159
|
+
);
|
|
160
|
+
bindings = this.device.createBindings(descriptorCopy);
|
|
161
|
+
this.bindingsCache.add(descriptorCopy, bindings);
|
|
162
|
+
}
|
|
163
|
+
return bindings;
|
|
164
|
+
}
|
|
165
|
+
createRenderPipeline(descriptor) {
|
|
166
|
+
let renderPipeline = this.renderPipelinesCache.get(descriptor);
|
|
167
|
+
if (renderPipeline === null) {
|
|
168
|
+
const descriptorCopy = (0, import_g_device_api.renderPipelineDescriptorCopy)(descriptor);
|
|
169
|
+
descriptorCopy.colorAttachmentFormats = descriptorCopy.colorAttachmentFormats.filter(
|
|
170
|
+
(f) => f
|
|
171
|
+
);
|
|
172
|
+
renderPipeline = this.device.createRenderPipeline(descriptorCopy);
|
|
173
|
+
this.renderPipelinesCache.add(descriptorCopy, renderPipeline);
|
|
174
|
+
}
|
|
175
|
+
return renderPipeline;
|
|
176
|
+
}
|
|
177
|
+
createInputLayout(descriptor) {
|
|
178
|
+
descriptor.vertexBufferDescriptors = descriptor.vertexBufferDescriptors.filter((d) => !!d);
|
|
179
|
+
let inputLayout = this.inputLayoutsCache.get(descriptor);
|
|
180
|
+
if (inputLayout === null) {
|
|
181
|
+
const descriptorCopy = (0, import_g_device_api.inputLayoutDescriptorCopy)(descriptor);
|
|
182
|
+
inputLayout = this.device.createInputLayout(descriptorCopy);
|
|
183
|
+
this.inputLayoutsCache.add(descriptorCopy, inputLayout);
|
|
184
|
+
}
|
|
185
|
+
return inputLayout;
|
|
186
|
+
}
|
|
187
|
+
createProgram(descriptor) {
|
|
188
|
+
let program = this.programCache.get(descriptor);
|
|
189
|
+
if (program === null) {
|
|
190
|
+
const descriptorCopy = programDescriptorCopy(descriptor);
|
|
191
|
+
program = this.device.createProgram(descriptor);
|
|
192
|
+
this.programCache.add(descriptorCopy, program);
|
|
193
|
+
}
|
|
194
|
+
return program;
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
for (const bindings of this.bindingsCache.values())
|
|
198
|
+
bindings.destroy();
|
|
199
|
+
for (const renderPipeline of this.renderPipelinesCache.values())
|
|
200
|
+
renderPipeline.destroy();
|
|
201
|
+
for (const inputLayout of this.inputLayoutsCache.values())
|
|
202
|
+
inputLayout.destroy();
|
|
203
|
+
for (const program of this.programCache.values())
|
|
204
|
+
program.destroy();
|
|
205
|
+
this.bindingsCache.clear();
|
|
206
|
+
this.renderPipelinesCache.clear();
|
|
207
|
+
this.inputLayoutsCache.clear();
|
|
208
|
+
this.programCache.clear();
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
212
|
+
0 && (module.exports = {
|
|
213
|
+
RenderCache
|
|
214
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Buffer, Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IElements, IElementsInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
export default class DeviceElements implements IElements {
|
|
4
|
+
private indexBuffer;
|
|
5
|
+
private type;
|
|
6
|
+
private count;
|
|
7
|
+
constructor(device: Device, options: IElementsInitializationOptions);
|
|
8
|
+
get(): Buffer;
|
|
9
|
+
subData({ data, }: {
|
|
10
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
11
|
+
}): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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/device/DeviceElements.ts
|
|
20
|
+
var DeviceElements_exports = {};
|
|
21
|
+
__export(DeviceElements_exports, {
|
|
22
|
+
default: () => DeviceElements
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(DeviceElements_exports);
|
|
25
|
+
var import_g_device_api = require("@antv/g-device-api");
|
|
26
|
+
var import_l7_core = require("@antv/l7-core");
|
|
27
|
+
var import_constants = require("./constants");
|
|
28
|
+
var import_typedarray = require("./utils/typedarray");
|
|
29
|
+
var DeviceElements = class {
|
|
30
|
+
constructor(device, options) {
|
|
31
|
+
const { data, type, count = 0 } = options;
|
|
32
|
+
let typed;
|
|
33
|
+
if ((0, import_typedarray.isTypedArray)(data)) {
|
|
34
|
+
typed = data;
|
|
35
|
+
} else {
|
|
36
|
+
typed = new import_constants.typedArrayCtorMap[this.type || import_l7_core.gl.UNSIGNED_INT](data);
|
|
37
|
+
}
|
|
38
|
+
this.type = type;
|
|
39
|
+
this.count = count;
|
|
40
|
+
this.indexBuffer = device.createBuffer({
|
|
41
|
+
viewOrSize: typed,
|
|
42
|
+
usage: import_g_device_api.BufferUsage.INDEX
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
get() {
|
|
46
|
+
return this.indexBuffer;
|
|
47
|
+
}
|
|
48
|
+
subData({
|
|
49
|
+
data
|
|
50
|
+
}) {
|
|
51
|
+
let typed;
|
|
52
|
+
if ((0, import_typedarray.isTypedArray)(data)) {
|
|
53
|
+
typed = data;
|
|
54
|
+
} else {
|
|
55
|
+
typed = new import_constants.typedArrayCtorMap[this.type || import_l7_core.gl.UNSIGNED_INT](data);
|
|
56
|
+
}
|
|
57
|
+
this.indexBuffer.setSubData(0, new Uint8Array(typed.buffer));
|
|
58
|
+
}
|
|
59
|
+
destroy() {
|
|
60
|
+
this.indexBuffer.destroy();
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Device, RenderTarget, Texture } from '@antv/g-device-api';
|
|
2
|
+
import type { IFramebuffer, IFramebufferInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
/**
|
|
4
|
+
* Contains 2 render targets: color and depth.
|
|
5
|
+
*/
|
|
6
|
+
export default class DeviceFramebuffer implements IFramebuffer {
|
|
7
|
+
private device;
|
|
8
|
+
private options;
|
|
9
|
+
private colorRenderTarget;
|
|
10
|
+
colorTexture: Texture;
|
|
11
|
+
private depthRenderTarget;
|
|
12
|
+
private depthTexture;
|
|
13
|
+
private width;
|
|
14
|
+
private height;
|
|
15
|
+
constructor(device: Device, options: IFramebufferInitializationOptions);
|
|
16
|
+
private createColorRenderTarget;
|
|
17
|
+
private createDepthRenderTarget;
|
|
18
|
+
get(): RenderTarget;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
resize({ width, height }: {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
}): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
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/device/DeviceFramebuffer.ts
|
|
20
|
+
var DeviceFramebuffer_exports = {};
|
|
21
|
+
__export(DeviceFramebuffer_exports, {
|
|
22
|
+
default: () => DeviceFramebuffer
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(DeviceFramebuffer_exports);
|
|
25
|
+
var import_g_device_api = require("@antv/g-device-api");
|
|
26
|
+
var import_DeviceTexture2D = require("./DeviceTexture2D");
|
|
27
|
+
var DeviceFramebuffer = class {
|
|
28
|
+
constructor(device, options) {
|
|
29
|
+
this.device = device;
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.createColorRenderTarget();
|
|
32
|
+
this.createDepthRenderTarget();
|
|
33
|
+
}
|
|
34
|
+
createColorRenderTarget(resize = false) {
|
|
35
|
+
const { width, height, color } = this.options;
|
|
36
|
+
if (color) {
|
|
37
|
+
if ((0, import_DeviceTexture2D.isTexture2D)(color)) {
|
|
38
|
+
if (resize) {
|
|
39
|
+
color.resize({ width, height });
|
|
40
|
+
}
|
|
41
|
+
this.colorTexture = color.get();
|
|
42
|
+
this.colorRenderTarget = this.device.createRenderTargetFromTexture(this.colorTexture);
|
|
43
|
+
this.width = color["width"];
|
|
44
|
+
this.height = color["height"];
|
|
45
|
+
} else if (width && height) {
|
|
46
|
+
this.colorTexture = this.device.createTexture({
|
|
47
|
+
format: import_g_device_api.Format.U8_RGBA_RT,
|
|
48
|
+
usage: import_g_device_api.TextureUsage.RENDER_TARGET,
|
|
49
|
+
width,
|
|
50
|
+
height
|
|
51
|
+
});
|
|
52
|
+
this.colorRenderTarget = this.device.createRenderTargetFromTexture(this.colorTexture);
|
|
53
|
+
this.width = width;
|
|
54
|
+
this.height = height;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
createDepthRenderTarget(resize = false) {
|
|
59
|
+
const { width, height, depth } = this.options;
|
|
60
|
+
if (depth) {
|
|
61
|
+
if ((0, import_DeviceTexture2D.isTexture2D)(depth)) {
|
|
62
|
+
if (resize) {
|
|
63
|
+
depth.resize({ width, height });
|
|
64
|
+
}
|
|
65
|
+
this.depthTexture = depth.get();
|
|
66
|
+
this.depthRenderTarget = this.device.createRenderTargetFromTexture(this.depthTexture);
|
|
67
|
+
this.width = depth["width"];
|
|
68
|
+
this.height = depth["height"];
|
|
69
|
+
} else if (width && height) {
|
|
70
|
+
this.depthTexture = this.device.createTexture({
|
|
71
|
+
format: import_g_device_api.Format.D24_S8,
|
|
72
|
+
usage: import_g_device_api.TextureUsage.RENDER_TARGET,
|
|
73
|
+
width,
|
|
74
|
+
height
|
|
75
|
+
});
|
|
76
|
+
this.depthRenderTarget = this.device.createRenderTargetFromTexture(this.depthTexture);
|
|
77
|
+
this.width = width;
|
|
78
|
+
this.height = height;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
get() {
|
|
83
|
+
return this.colorRenderTarget;
|
|
84
|
+
}
|
|
85
|
+
destroy() {
|
|
86
|
+
var _a, _b;
|
|
87
|
+
(_a = this.colorRenderTarget) == null ? void 0 : _a.destroy();
|
|
88
|
+
(_b = this.depthRenderTarget) == null ? void 0 : _b.destroy();
|
|
89
|
+
}
|
|
90
|
+
resize({ width, height }) {
|
|
91
|
+
if (this.width !== width || this.height !== height) {
|
|
92
|
+
this.destroy();
|
|
93
|
+
this.colorTexture.destroyed = true;
|
|
94
|
+
this.depthTexture.destroyed = true;
|
|
95
|
+
this.options.width = width;
|
|
96
|
+
this.options.height = height;
|
|
97
|
+
this.createColorRenderTarget(true);
|
|
98
|
+
this.createDepthRenderTarget(true);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { Device } from '@antv/g-device-api';
|
|
2
|
+
import type { IModel, IModelDrawOptions, IModelInitializationOptions, IUniform } from '@antv/l7-core';
|
|
3
|
+
import type DeviceRendererService from '.';
|
|
4
|
+
export default class DeviceModel implements IModel {
|
|
5
|
+
private device;
|
|
6
|
+
private options;
|
|
7
|
+
private service;
|
|
8
|
+
private destroyed;
|
|
9
|
+
private uniforms;
|
|
10
|
+
private program;
|
|
11
|
+
private inputLayout;
|
|
12
|
+
private pipeline;
|
|
13
|
+
private indexBuffer;
|
|
14
|
+
private vertexBuffers;
|
|
15
|
+
private bindings;
|
|
16
|
+
private pipelineCache;
|
|
17
|
+
private currentPipelineKey;
|
|
18
|
+
constructor(device: Device, options: IModelInitializationOptions, service: DeviceRendererService);
|
|
19
|
+
/**
|
|
20
|
+
* 生成 Pipeline 缓存键,用于判断是否需要重新创建 Pipeline
|
|
21
|
+
* 包含所有影响 Pipeline 创建的参数
|
|
22
|
+
* 注意:当 blend/stencil 禁用时,使用简化的 key 以避免创建重复 Pipeline
|
|
23
|
+
*/
|
|
24
|
+
private getPipelineKey;
|
|
25
|
+
private createPipeline;
|
|
26
|
+
updateAttributesAndElements(): void;
|
|
27
|
+
/**
|
|
28
|
+
* No need to implement this method, you should update data on `Attribute` like this:
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* attribute.updateBuffer({
|
|
33
|
+
* data: [],
|
|
34
|
+
* offset: 0,
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
updateAttributes(): void;
|
|
39
|
+
addUniforms(uniforms: {
|
|
40
|
+
[key: string]: IUniform;
|
|
41
|
+
}): void;
|
|
42
|
+
draw(options: IModelDrawOptions, pick?: boolean): void;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
private initDepthDrawParams;
|
|
45
|
+
private getBlendDrawParams;
|
|
46
|
+
/**
|
|
47
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
48
|
+
*/
|
|
49
|
+
private getStencilDrawParams;
|
|
50
|
+
/**
|
|
51
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
52
|
+
*/
|
|
53
|
+
private initCullDrawParams;
|
|
54
|
+
/**
|
|
55
|
+
* 考虑结构体命名, eg:
|
|
56
|
+
* a: { b: 1 } -> 'a.b'
|
|
57
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
58
|
+
*/
|
|
59
|
+
private extractUniforms;
|
|
60
|
+
private extractUniformsRecursively;
|
|
61
|
+
}
|