@antv/l7-renderer 2.21.1 → 2.21.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/es/device/DeviceAttribute.js +26 -32
- package/es/device/DeviceBuffer.js +31 -49
- package/es/device/DeviceCache.js +136 -170
- package/es/device/DeviceElements.js +32 -38
- package/es/device/DeviceFramebuffer.js +76 -104
- package/es/device/DeviceModel.js +358 -384
- package/es/device/DeviceTexture2D.js +103 -122
- package/es/device/constants.js +117 -34
- package/es/device/index.js +254 -381
- package/es/device/utils/HashMap.js +71 -138
- package/es/device/utils/pipeline.js +6 -1
- package/es/device/utils/typedarray.js +23 -24
- package/es/device/utils/webgl.js +7 -6
- package/es/index.js +5 -4
- package/es/regl/ReglAttribute.js +17 -33
- package/es/regl/ReglBuffer.js +25 -40
- package/es/regl/ReglElements.js +21 -36
- package/es/regl/ReglFramebuffer.js +24 -44
- package/es/regl/ReglModel.js +266 -306
- package/es/regl/ReglRenderbuffer.js +19 -36
- package/es/regl/ReglTexture2D.js +72 -103
- package/es/regl/constants.js +133 -21
- package/es/regl/index.js +205 -289
- package/lib/device/DeviceAttribute.d.ts +13 -0
- package/lib/device/DeviceBuffer.d.ts +18 -0
- package/lib/device/DeviceCache.d.ts +14 -0
- package/lib/device/DeviceElements.d.ts +13 -0
- package/lib/device/DeviceFramebuffer.d.ts +24 -0
- package/lib/device/DeviceModel.d.ts +53 -0
- package/lib/device/DeviceModel.js +22 -15
- package/lib/device/DeviceTexture2D.d.ts +23 -0
- package/lib/device/constants.d.ts +35 -0
- package/lib/device/index.d.ts +68 -0
- package/lib/device/index.js +58 -36
- package/lib/device/utils/HashMap.d.ts +24 -0
- package/lib/device/utils/pipeline.d.ts +1 -0
- package/lib/device/utils/typedarray.d.ts +7 -0
- package/lib/device/utils/webgl.d.ts +1 -0
- package/lib/index.d.ts +6 -0
- package/lib/regl/ReglAttribute.d.ts +16 -0
- package/lib/regl/ReglBuffer.d.ts +17 -0
- package/lib/regl/ReglElements.d.ts +14 -0
- package/lib/regl/ReglFramebuffer.d.ts +16 -0
- package/lib/regl/ReglModel.d.ts +46 -0
- package/lib/regl/ReglModel.js +21 -11
- package/lib/regl/ReglRenderbuffer.d.ts +16 -0
- package/lib/regl/ReglTexture2D.d.ts +22 -0
- package/lib/regl/constants.d.ts +43 -0
- package/lib/regl/index.d.ts +56 -0
- package/lib/regl/index.js +70 -48
- package/package.json +14 -18
- package/CHANGELOG.md +0 -350
- package/LICENSE.md +0 -21
|
@@ -1,9 +1,26 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
7
24
|
var __export = (target, all) => {
|
|
8
25
|
for (var name in all)
|
|
9
26
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -196,16 +213,10 @@ var DeviceModel = class {
|
|
|
196
213
|
updateAttributes() {
|
|
197
214
|
}
|
|
198
215
|
addUniforms(uniforms) {
|
|
199
|
-
this.uniforms = {
|
|
200
|
-
...this.uniforms,
|
|
201
|
-
...this.extractUniforms(uniforms)
|
|
202
|
-
};
|
|
216
|
+
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
203
217
|
}
|
|
204
218
|
draw(options, pick) {
|
|
205
|
-
const mergedOptions = {
|
|
206
|
-
...this.options,
|
|
207
|
-
...options
|
|
208
|
-
};
|
|
219
|
+
const mergedOptions = __spreadValues(__spreadValues({}, this.options), options);
|
|
209
220
|
const {
|
|
210
221
|
count = 0,
|
|
211
222
|
instances,
|
|
@@ -214,10 +225,7 @@ var DeviceModel = class {
|
|
|
214
225
|
uniformBuffers,
|
|
215
226
|
textures
|
|
216
227
|
} = mergedOptions;
|
|
217
|
-
this.uniforms = {
|
|
218
|
-
...this.uniforms,
|
|
219
|
-
...this.extractUniforms(uniforms)
|
|
220
|
-
};
|
|
228
|
+
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
221
229
|
const { renderPass, currentFramebuffer, width, height, renderCache } = this.service;
|
|
222
230
|
this.pipeline = this.createPipeline(mergedOptions, pick);
|
|
223
231
|
const device = this.service["device"];
|
|
@@ -351,10 +359,9 @@ var DeviceModel = class {
|
|
|
351
359
|
return {
|
|
352
360
|
enable: !!enable,
|
|
353
361
|
mask,
|
|
354
|
-
func: {
|
|
355
|
-
...func,
|
|
362
|
+
func: __spreadProps(__spreadValues({}, func), {
|
|
356
363
|
cmp: import_constants.stencilFuncMap[func.cmp]
|
|
357
|
-
},
|
|
364
|
+
}),
|
|
358
365
|
opFront: {
|
|
359
366
|
fail: import_constants.stencilOpMap[opFront.fail],
|
|
360
367
|
zfail: import_constants.stencilOpMap[opFront.zfail],
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Device, Texture } from '@antv/g-device-api';
|
|
2
|
+
import type { ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
export declare function isTexture2D(t: any): t is ITexture2D;
|
|
4
|
+
export default class DeviceTexture2D implements ITexture2D {
|
|
5
|
+
private device;
|
|
6
|
+
private options;
|
|
7
|
+
private texture;
|
|
8
|
+
private sampler;
|
|
9
|
+
private width;
|
|
10
|
+
private height;
|
|
11
|
+
private isDestroy;
|
|
12
|
+
constructor(device: Device, options: ITexture2DInitializationOptions);
|
|
13
|
+
private createTexture;
|
|
14
|
+
get(): Texture;
|
|
15
|
+
update(props: any): void;
|
|
16
|
+
bind(): void;
|
|
17
|
+
resize({ width, height }: {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}): void;
|
|
21
|
+
getSize(): [number, number];
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AddressMode, BlendFactor, BlendMode, BufferFrequencyHint, CompareFunction, CullMode, Format, PrimitiveTopology, StencilOp } from '@antv/g-device-api';
|
|
2
|
+
import type { TypedArray } from './utils/typedarray';
|
|
3
|
+
export declare const typedArrayCtorMap: {
|
|
4
|
+
[key: string]: new (data: number[]) => TypedArray;
|
|
5
|
+
};
|
|
6
|
+
export declare const primitiveMap: {
|
|
7
|
+
[key: string]: PrimitiveTopology;
|
|
8
|
+
};
|
|
9
|
+
export declare const sizeFormatMap: {
|
|
10
|
+
[key: number]: Format;
|
|
11
|
+
};
|
|
12
|
+
export declare const hintMap: {
|
|
13
|
+
[key: string]: BufferFrequencyHint;
|
|
14
|
+
};
|
|
15
|
+
export declare const wrapModeMap: {
|
|
16
|
+
[key: string]: AddressMode;
|
|
17
|
+
};
|
|
18
|
+
export declare const depthFuncMap: {
|
|
19
|
+
[key: string]: CompareFunction;
|
|
20
|
+
};
|
|
21
|
+
export declare const cullFaceMap: {
|
|
22
|
+
[key: string]: CullMode;
|
|
23
|
+
};
|
|
24
|
+
export declare const blendEquationMap: {
|
|
25
|
+
[key: string]: BlendMode;
|
|
26
|
+
};
|
|
27
|
+
export declare const blendFuncMap: {
|
|
28
|
+
[key: string]: BlendFactor;
|
|
29
|
+
};
|
|
30
|
+
export declare const stencilOpMap: {
|
|
31
|
+
[key: string]: StencilOp;
|
|
32
|
+
};
|
|
33
|
+
export declare const stencilFuncMap: {
|
|
34
|
+
[key: string]: CompareFunction;
|
|
35
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { RenderPass, RenderTarget, SwapChain } from '@antv/g-device-api';
|
|
2
|
+
import type { IAttribute, IAttributeInitializationOptions, IBuffer, IBufferInitializationOptions, IClearOptions, IElements, IElementsInitializationOptions, IExtensions, IFramebuffer, IFramebufferInitializationOptions, IModel, IModelInitializationOptions, IReadPixelsOptions, IRenderConfig, IRendererService, ITexture2D, ITexture2DInitializationOptions } from '@antv/l7-core';
|
|
3
|
+
import { RenderCache } from './DeviceCache';
|
|
4
|
+
import DeviceFramebuffer from './DeviceFramebuffer';
|
|
5
|
+
/**
|
|
6
|
+
* Device API renderer
|
|
7
|
+
*/
|
|
8
|
+
export default class DeviceRendererService implements IRendererService {
|
|
9
|
+
uniformBuffers: IBuffer[];
|
|
10
|
+
extensionObject: IExtensions;
|
|
11
|
+
private device;
|
|
12
|
+
swapChain: SwapChain;
|
|
13
|
+
private $container;
|
|
14
|
+
private canvas;
|
|
15
|
+
width: number;
|
|
16
|
+
height: number;
|
|
17
|
+
private isDirty;
|
|
18
|
+
/**
|
|
19
|
+
* Current render pass.
|
|
20
|
+
*/
|
|
21
|
+
renderPass: RenderPass;
|
|
22
|
+
preRenderPass: RenderPass;
|
|
23
|
+
mainColorRT: RenderTarget;
|
|
24
|
+
mainDepthRT: RenderTarget;
|
|
25
|
+
renderCache: RenderCache;
|
|
26
|
+
/**
|
|
27
|
+
* Current FBO.
|
|
28
|
+
*/
|
|
29
|
+
currentFramebuffer: DeviceFramebuffer | null;
|
|
30
|
+
queryVerdorInfo: () => string;
|
|
31
|
+
private viewportOrigin;
|
|
32
|
+
init(canvas: HTMLCanvasElement, cfg: IRenderConfig): Promise<void>;
|
|
33
|
+
private createMainColorDepthRT;
|
|
34
|
+
beginFrame(): void;
|
|
35
|
+
endFrame(): void;
|
|
36
|
+
getPointSizeRange(): any;
|
|
37
|
+
testExtension(name: string): boolean;
|
|
38
|
+
createModel: (options: IModelInitializationOptions) => IModel;
|
|
39
|
+
createAttribute: (options: IAttributeInitializationOptions) => IAttribute;
|
|
40
|
+
createBuffer: (options: IBufferInitializationOptions) => IBuffer;
|
|
41
|
+
createElements: (options: IElementsInitializationOptions) => IElements;
|
|
42
|
+
createTexture2D: (options: ITexture2DInitializationOptions) => ITexture2D;
|
|
43
|
+
createFramebuffer: (options: IFramebufferInitializationOptions) => DeviceFramebuffer;
|
|
44
|
+
useFramebuffer: (framebuffer: IFramebuffer | null, drawCommands: () => void) => void;
|
|
45
|
+
useFramebufferAsync: (framebuffer: IFramebuffer | null, drawCommands: () => Promise<void>) => Promise<void>;
|
|
46
|
+
clear: (options: IClearOptions) => void;
|
|
47
|
+
viewport: ({ width, height, }: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}) => void;
|
|
53
|
+
readPixels: (options: IReadPixelsOptions) => Uint8Array;
|
|
54
|
+
readPixelsAsync: (options: IReadPixelsOptions) => Promise<Uint8Array>;
|
|
55
|
+
getViewportSize: () => {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
};
|
|
59
|
+
getContainer: () => HTMLElement | null;
|
|
60
|
+
getCanvas: () => HTMLCanvasElement;
|
|
61
|
+
getGLContext: () => WebGLRenderingContext;
|
|
62
|
+
setState(): void;
|
|
63
|
+
setBaseState(): void;
|
|
64
|
+
setCustomLayerDefaults(): void;
|
|
65
|
+
setDirty(flag: boolean): void;
|
|
66
|
+
getDirty(): boolean;
|
|
67
|
+
destroy: () => void;
|
|
68
|
+
}
|
package/lib/device/index.js
CHANGED
|
@@ -25,6 +25,26 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
mod
|
|
26
26
|
));
|
|
27
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __async = (__this, __arguments, generator) => {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
var fulfilled = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.next(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var rejected = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.throw(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
45
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
46
|
+
});
|
|
47
|
+
};
|
|
28
48
|
|
|
29
49
|
// src/device/index.ts
|
|
30
50
|
var device_exports = {};
|
|
@@ -62,15 +82,15 @@ var DeviceRendererService = class {
|
|
|
62
82
|
this.endFrame();
|
|
63
83
|
this.currentFramebuffer = null;
|
|
64
84
|
};
|
|
65
|
-
this.useFramebufferAsync =
|
|
85
|
+
this.useFramebufferAsync = (framebuffer, drawCommands) => __async(this, null, function* () {
|
|
66
86
|
this.currentFramebuffer = framebuffer;
|
|
67
87
|
this.preRenderPass = this.renderPass;
|
|
68
88
|
this.beginFrame();
|
|
69
|
-
|
|
89
|
+
yield drawCommands();
|
|
70
90
|
this.endFrame();
|
|
71
91
|
this.currentFramebuffer = null;
|
|
72
92
|
this.renderPass = this.preRenderPass;
|
|
73
|
-
};
|
|
93
|
+
});
|
|
74
94
|
this.clear = (options) => {
|
|
75
95
|
const { color, depth, stencil, framebuffer = null } = options;
|
|
76
96
|
if (framebuffer) {
|
|
@@ -126,11 +146,11 @@ var DeviceRendererService = class {
|
|
|
126
146
|
readback.destroy();
|
|
127
147
|
return result;
|
|
128
148
|
};
|
|
129
|
-
this.readPixelsAsync =
|
|
149
|
+
this.readPixelsAsync = (options) => __async(this, null, function* () {
|
|
130
150
|
const { framebuffer, x, y, width, height } = options;
|
|
131
151
|
const readback = this.device.createReadback();
|
|
132
152
|
const texture = framebuffer["colorTexture"];
|
|
133
|
-
const result =
|
|
153
|
+
const result = yield readback.readTexture(
|
|
134
154
|
texture,
|
|
135
155
|
x,
|
|
136
156
|
/**
|
|
@@ -151,7 +171,7 @@ var DeviceRendererService = class {
|
|
|
151
171
|
}
|
|
152
172
|
readback.destroy();
|
|
153
173
|
return result;
|
|
154
|
-
};
|
|
174
|
+
});
|
|
155
175
|
this.getViewportSize = () => {
|
|
156
176
|
return {
|
|
157
177
|
width: this.width,
|
|
@@ -178,37 +198,39 @@ var DeviceRendererService = class {
|
|
|
178
198
|
this.renderCache.destroy();
|
|
179
199
|
};
|
|
180
200
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
201
|
+
init(canvas, cfg) {
|
|
202
|
+
return __async(this, null, function* () {
|
|
203
|
+
const { enableWebGPU, shaderCompilerPath } = cfg;
|
|
204
|
+
this.canvas = canvas;
|
|
205
|
+
const deviceContribution = enableWebGPU ? new import_g_device_api.WebGPUDeviceContribution({
|
|
206
|
+
shaderCompilerPath
|
|
207
|
+
}) : new import_g_device_api.WebGLDeviceContribution({
|
|
208
|
+
// Use WebGL2 first and downgrade to WebGL1 if WebGL2 is not supported.
|
|
209
|
+
targets: ["webgl2", "webgl1"],
|
|
210
|
+
onContextLost(e) {
|
|
211
|
+
console.warn("context lost", e);
|
|
212
|
+
},
|
|
213
|
+
onContextCreationError(e) {
|
|
214
|
+
console.warn("context creation error", e);
|
|
215
|
+
},
|
|
216
|
+
onContextRestored(e) {
|
|
217
|
+
console.warn("context restored", e);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const swapChain = yield deviceContribution.createSwapChain(canvas);
|
|
221
|
+
swapChain.configureSwapChain(canvas.width, canvas.height);
|
|
222
|
+
this.device = swapChain.getDevice();
|
|
223
|
+
this.swapChain = swapChain;
|
|
224
|
+
this.renderCache = new import_DeviceCache.RenderCache(this.device);
|
|
225
|
+
this.currentFramebuffer = null;
|
|
226
|
+
this.viewportOrigin = this.device.queryVendorInfo().viewportOrigin;
|
|
227
|
+
const gl = this.device["gl"];
|
|
228
|
+
this.extensionObject = {
|
|
229
|
+
// @ts-ignore
|
|
230
|
+
OES_texture_float: !(0, import_webgl.isWebGL2)(gl) && this.device["OES_texture_float"]
|
|
231
|
+
};
|
|
232
|
+
this.createMainColorDepthRT(canvas.width, canvas.height);
|
|
198
233
|
});
|
|
199
|
-
const swapChain = await deviceContribution.createSwapChain(canvas);
|
|
200
|
-
swapChain.configureSwapChain(canvas.width, canvas.height);
|
|
201
|
-
this.device = swapChain.getDevice();
|
|
202
|
-
this.swapChain = swapChain;
|
|
203
|
-
this.renderCache = new import_DeviceCache.RenderCache(this.device);
|
|
204
|
-
this.currentFramebuffer = null;
|
|
205
|
-
this.viewportOrigin = this.device.queryVendorInfo().viewportOrigin;
|
|
206
|
-
const gl = this.device["gl"];
|
|
207
|
-
this.extensionObject = {
|
|
208
|
-
// @ts-ignore
|
|
209
|
-
OES_texture_float: !(0, import_webgl.isWebGL2)(gl) && this.device["OES_texture_float"]
|
|
210
|
-
};
|
|
211
|
-
this.createMainColorDepthRT(canvas.width, canvas.height);
|
|
212
234
|
}
|
|
213
235
|
createMainColorDepthRT(width, height) {
|
|
214
236
|
if (this.mainColorRT) {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare function hashCodeNumberUpdate(hash: number, v?: number): number;
|
|
2
|
+
export declare function hashCodeNumberFinish(hash: number): number;
|
|
3
|
+
export declare function nullHashFunc(): number;
|
|
4
|
+
export type EqualFunc<K> = (a: K, b: K) => boolean;
|
|
5
|
+
export type HashFunc<K> = (a: K) => number;
|
|
6
|
+
declare class HashBucket<K, V> {
|
|
7
|
+
keys: K[];
|
|
8
|
+
values: V[];
|
|
9
|
+
}
|
|
10
|
+
export declare class HashMap<K, V> {
|
|
11
|
+
private keyEqualFunc;
|
|
12
|
+
private keyHashFunc;
|
|
13
|
+
buckets: Map<number, HashBucket<K, V>>;
|
|
14
|
+
constructor(keyEqualFunc: EqualFunc<K>, keyHashFunc: HashFunc<K>);
|
|
15
|
+
private findBucketIndex;
|
|
16
|
+
private findBucket;
|
|
17
|
+
get(k: K): V | null;
|
|
18
|
+
add(k: K, v: V): void;
|
|
19
|
+
delete(k: K): void;
|
|
20
|
+
clear(): void;
|
|
21
|
+
size(): number;
|
|
22
|
+
values(): IterableIterator<V>;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pipelineEquals(): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
|
|
2
|
+
export declare function isTypedArray(x: any): x is TypedArray;
|
|
3
|
+
/**
|
|
4
|
+
* WebGPU does not support RGB texture, so we need to convert RGB to RGBA
|
|
5
|
+
* @see https://github.com/antvis/L7/pull/2262
|
|
6
|
+
*/
|
|
7
|
+
export declare function extend3ChannelsTo4(array: Float32Array, valueToInsert: number): Float32Array;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isWebGL2(gl: WebGL2RenderingContext | WebGLRenderingContext): gl is WebGL2RenderingContext;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IAttribute, IAttributeInitializationOptions } from '@antv/l7-core';
|
|
2
|
+
import type regl from 'regl';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#attributes
|
|
5
|
+
*/
|
|
6
|
+
export default class ReglAttribute implements IAttribute {
|
|
7
|
+
private attribute;
|
|
8
|
+
private buffer;
|
|
9
|
+
constructor(gl: regl.Regl, options: IAttributeInitializationOptions);
|
|
10
|
+
get(): regl.Attribute;
|
|
11
|
+
updateBuffer(options: {
|
|
12
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
13
|
+
offset: number;
|
|
14
|
+
}): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IBuffer, IBufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
+
import type regl from 'regl';
|
|
3
|
+
/**
|
|
4
|
+
* adaptor for regl.Buffer
|
|
5
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#buffers
|
|
6
|
+
*/
|
|
7
|
+
export default class ReglBuffer implements IBuffer {
|
|
8
|
+
private buffer;
|
|
9
|
+
private isDestroyed;
|
|
10
|
+
constructor(reGl: regl.Regl, options: IBufferInitializationOptions);
|
|
11
|
+
get(): regl.Buffer;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
subData({ data, offset, }: {
|
|
14
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
15
|
+
offset: number;
|
|
16
|
+
}): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IElements, IElementsInitializationOptions } from '@antv/l7-core';
|
|
2
|
+
import type regl from 'regl';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#elements
|
|
5
|
+
*/
|
|
6
|
+
export default class ReglElements implements IElements {
|
|
7
|
+
private elements;
|
|
8
|
+
constructor(reGl: regl.Regl, options: IElementsInitializationOptions);
|
|
9
|
+
get(): regl.Elements;
|
|
10
|
+
subData({ data, }: {
|
|
11
|
+
data: number[] | number[][] | Uint8Array | Uint16Array | Uint32Array;
|
|
12
|
+
}): void;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IFramebuffer, IFramebufferInitializationOptions } from '@antv/l7-core';
|
|
2
|
+
import type regl from 'regl';
|
|
3
|
+
/**
|
|
4
|
+
* adaptor for regl.Framebuffer
|
|
5
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#framebuffers
|
|
6
|
+
*/
|
|
7
|
+
export default class ReglFramebuffer implements IFramebuffer {
|
|
8
|
+
private framebuffer;
|
|
9
|
+
constructor(reGl: regl.Regl, options: IFramebufferInitializationOptions);
|
|
10
|
+
get(): regl.Framebuffer;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
resize({ width, height }: {
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { IAttribute, IElements, IModel, IModelDrawOptions, IModelInitializationOptions, IUniform } from '@antv/l7-core';
|
|
2
|
+
import type regl from 'regl';
|
|
3
|
+
/**
|
|
4
|
+
* adaptor for regl.DrawCommand
|
|
5
|
+
*/
|
|
6
|
+
export default class ReglModel implements IModel {
|
|
7
|
+
private reGl;
|
|
8
|
+
private destroyed;
|
|
9
|
+
private drawCommand;
|
|
10
|
+
private drawParams;
|
|
11
|
+
private options;
|
|
12
|
+
private uniforms;
|
|
13
|
+
constructor(reGl: regl.Regl, options: IModelInitializationOptions);
|
|
14
|
+
updateAttributesAndElements(attributes: {
|
|
15
|
+
[key: string]: IAttribute;
|
|
16
|
+
}, elements: IElements): void;
|
|
17
|
+
updateAttributes(attributes: {
|
|
18
|
+
[key: string]: IAttribute;
|
|
19
|
+
}): void;
|
|
20
|
+
addUniforms(uniforms: {
|
|
21
|
+
[key: string]: IUniform;
|
|
22
|
+
}): void;
|
|
23
|
+
draw(options: IModelDrawOptions, pick?: boolean): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
/**
|
|
26
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#depth-buffer
|
|
27
|
+
*/
|
|
28
|
+
private initDepthDrawParams;
|
|
29
|
+
private getBlendDrawParams;
|
|
30
|
+
/**
|
|
31
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#stencil
|
|
32
|
+
*/
|
|
33
|
+
private getStencilDrawParams;
|
|
34
|
+
private getColorMaskDrawParams;
|
|
35
|
+
/**
|
|
36
|
+
* @see https://github.com/regl-project/regl/blob/gh-pages/API.md#culling
|
|
37
|
+
*/
|
|
38
|
+
private initCullDrawParams;
|
|
39
|
+
/**
|
|
40
|
+
* 考虑结构体命名, eg:
|
|
41
|
+
* a: { b: 1 } -> 'a.b'
|
|
42
|
+
* a: [ { b: 1 } ] -> 'a[0].b'
|
|
43
|
+
*/
|
|
44
|
+
private extractUniforms;
|
|
45
|
+
private extractUniformsRecursively;
|
|
46
|
+
}
|
package/lib/regl/ReglModel.js
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
3
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
4
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));
|
|
5
22
|
var __export = (target, all) => {
|
|
6
23
|
for (var name in all)
|
|
7
24
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -134,19 +151,13 @@ var ReglModel = class {
|
|
|
134
151
|
this.drawCommand = this.reGl(this.drawParams);
|
|
135
152
|
}
|
|
136
153
|
addUniforms(uniforms) {
|
|
137
|
-
this.uniforms = {
|
|
138
|
-
...this.uniforms,
|
|
139
|
-
...this.extractUniforms(uniforms)
|
|
140
|
-
};
|
|
154
|
+
this.uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(uniforms));
|
|
141
155
|
}
|
|
142
156
|
draw(options, pick) {
|
|
143
157
|
if (this.drawParams.attributes && Object.keys(this.drawParams.attributes).length === 0) {
|
|
144
158
|
return;
|
|
145
159
|
}
|
|
146
|
-
const uniforms = {
|
|
147
|
-
...this.uniforms,
|
|
148
|
-
...this.extractUniforms(options.uniforms || {})
|
|
149
|
-
};
|
|
160
|
+
const uniforms = __spreadValues(__spreadValues({}, this.uniforms), this.extractUniforms(options.uniforms || {}));
|
|
150
161
|
const reglDrawProps = {};
|
|
151
162
|
Object.keys(uniforms).forEach((uniformName) => {
|
|
152
163
|
const type = typeof uniforms[uniformName];
|
|
@@ -234,10 +245,9 @@ var ReglModel = class {
|
|
|
234
245
|
return {
|
|
235
246
|
enable: !!enable,
|
|
236
247
|
mask,
|
|
237
|
-
func: {
|
|
238
|
-
...func,
|
|
248
|
+
func: __spreadProps(__spreadValues({}, func), {
|
|
239
249
|
cmp: import_constants.stencilFuncMap[func.cmp]
|
|
240
|
-
},
|
|
250
|
+
}),
|
|
241
251
|
opFront: {
|
|
242
252
|
fail: import_constants.stencilOpMap[opFront.fail],
|
|
243
253
|
zfail: import_constants.stencilOpMap[opFront.zfail],
|
|
@@ -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,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,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
|
+
};
|