@antv/l7-renderer 2.25.6 → 2.25.7
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 +4 -4
- package/es/device/DeviceAttribute.d.ts +0 -13
- package/es/device/DeviceAttribute.js +0 -30
- package/es/device/DeviceBuffer.d.ts +0 -18
- package/es/device/DeviceBuffer.js +0 -51
- package/es/device/DeviceCache.d.ts +0 -14
- package/es/device/DeviceCache.js +0 -198
- package/es/device/DeviceElements.d.ts +0 -13
- package/es/device/DeviceElements.js +0 -42
- package/es/device/DeviceFramebuffer.d.ts +0 -24
- package/es/device/DeviceFramebuffer.js +0 -81
- package/es/device/DeviceModel.d.ts +0 -61
- package/es/device/DeviceModel.js +0 -488
- package/es/device/DeviceTexture2D.d.ts +0 -23
- package/es/device/DeviceTexture2D.js +0 -132
- package/es/device/constants.d.ts +0 -35
- package/es/device/constants.js +0 -117
- package/es/device/index.d.ts +0 -68
- package/es/device/index.js +0 -311
- package/es/device/utils/HashMap.d.ts +0 -24
- package/es/device/utils/HashMap.js +0 -86
- package/es/device/utils/pipeline.d.ts +0 -1
- package/es/device/utils/pipeline.js +0 -6
- package/es/device/utils/typedarray.d.ts +0 -7
- package/es/device/utils/typedarray.js +0 -33
- package/es/device/utils/webgl.d.ts +0 -1
- package/es/device/utils/webgl.js +0 -10
- package/es/index.d.ts +0 -3
- package/es/index.js +0 -7
- package/es/regl/ReglAttribute.d.ts +0 -16
- package/es/regl/ReglAttribute.js +0 -29
- package/es/regl/ReglBuffer.d.ts +0 -17
- package/es/regl/ReglBuffer.js +0 -33
- package/es/regl/ReglElements.d.ts +0 -14
- package/es/regl/ReglElements.js +0 -27
- package/es/regl/ReglFramebuffer.d.ts +0 -16
- package/es/regl/ReglFramebuffer.js +0 -31
- package/es/regl/ReglModel.d.ts +0 -46
- package/es/regl/ReglModel.js +0 -302
- package/es/regl/ReglRenderbuffer.d.ts +0 -16
- package/es/regl/ReglRenderbuffer.js +0 -24
- package/es/regl/ReglTexture2D.d.ts +0 -22
- package/es/regl/ReglTexture2D.js +0 -94
- package/es/regl/constants.d.ts +0 -43
- package/es/regl/constants.js +0 -133
- package/es/regl/index.d.ts +0 -56
- package/es/regl/index.js +0 -227
- package/lib/device/DeviceAttribute.d.ts +0 -13
- package/lib/device/DeviceAttribute.js +0 -50
- package/lib/device/DeviceBuffer.d.ts +0 -18
- package/lib/device/DeviceBuffer.js +0 -71
- package/lib/device/DeviceCache.d.ts +0 -14
- package/lib/device/DeviceCache.js +0 -214
- package/lib/device/DeviceElements.d.ts +0 -13
- package/lib/device/DeviceElements.js +0 -62
- package/lib/device/DeviceFramebuffer.d.ts +0 -24
- package/lib/device/DeviceFramebuffer.js +0 -101
- package/lib/device/DeviceModel.d.ts +0 -61
- package/lib/device/DeviceModel.js +0 -495
- package/lib/device/DeviceTexture2D.d.ts +0 -23
- package/lib/device/DeviceTexture2D.js +0 -151
- package/lib/device/constants.d.ts +0 -35
- package/lib/device/constants.js +0 -141
- package/lib/device/index.d.ts +0 -68
- package/lib/device/index.js +0 -332
- package/lib/device/utils/HashMap.d.ts +0 -24
- package/lib/device/utils/HashMap.js +0 -113
- package/lib/device/utils/pipeline.d.ts +0 -1
- package/lib/device/utils/pipeline.js +0 -30
- package/lib/device/utils/typedarray.d.ts +0 -7
- package/lib/device/utils/typedarray.js +0 -58
- package/lib/device/utils/webgl.d.ts +0 -1
- package/lib/device/utils/webgl.js +0 -34
- package/lib/index.d.ts +0 -3
- package/lib/index.js +0 -42
- package/lib/regl/ReglAttribute.d.ts +0 -16
- package/lib/regl/ReglAttribute.js +0 -49
- package/lib/regl/ReglBuffer.d.ts +0 -17
- package/lib/regl/ReglBuffer.js +0 -53
- package/lib/regl/ReglElements.d.ts +0 -14
- package/lib/regl/ReglElements.js +0 -47
- package/lib/regl/ReglFramebuffer.d.ts +0 -16
- package/lib/regl/ReglFramebuffer.js +0 -51
- package/lib/regl/ReglModel.d.ts +0 -46
- package/lib/regl/ReglModel.js +0 -311
- package/lib/regl/ReglRenderbuffer.d.ts +0 -16
- package/lib/regl/ReglRenderbuffer.js +0 -44
- package/lib/regl/ReglTexture2D.d.ts +0 -22
- package/lib/regl/ReglTexture2D.js +0 -107
- package/lib/regl/constants.d.ts +0 -43
- package/lib/regl/constants.js +0 -170
- package/lib/regl/index.d.ts +0 -56
- package/lib/regl/index.js +0 -256
package/es/device/constants.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
// src/device/constants.ts
|
|
2
|
-
import {
|
|
3
|
-
AddressMode,
|
|
4
|
-
BlendFactor,
|
|
5
|
-
BlendMode,
|
|
6
|
-
BufferFrequencyHint,
|
|
7
|
-
CompareFunction,
|
|
8
|
-
CullMode,
|
|
9
|
-
Format,
|
|
10
|
-
PrimitiveTopology,
|
|
11
|
-
StencilOp
|
|
12
|
-
} from "@antv/g-device-api";
|
|
13
|
-
import { gl } from "@antv/l7-core";
|
|
14
|
-
var typedArrayCtorMap = {
|
|
15
|
-
[gl.FLOAT]: Float32Array,
|
|
16
|
-
[gl.UNSIGNED_BYTE]: Uint8Array,
|
|
17
|
-
[gl.SHORT]: Int16Array,
|
|
18
|
-
[gl.UNSIGNED_SHORT]: Uint16Array,
|
|
19
|
-
[gl.INT]: Int32Array,
|
|
20
|
-
[gl.UNSIGNED_INT]: Uint32Array
|
|
21
|
-
};
|
|
22
|
-
var primitiveMap = {
|
|
23
|
-
[gl.POINTS]: PrimitiveTopology.POINTS,
|
|
24
|
-
[gl.LINES]: PrimitiveTopology.LINES,
|
|
25
|
-
[gl.LINE_LOOP]: PrimitiveTopology.LINES,
|
|
26
|
-
[gl.LINE_STRIP]: PrimitiveTopology.LINE_STRIP,
|
|
27
|
-
[gl.TRIANGLES]: PrimitiveTopology.TRIANGLES,
|
|
28
|
-
[gl.TRIANGLE_FAN]: PrimitiveTopology.TRIANGLES,
|
|
29
|
-
[gl.TRIANGLE_STRIP]: PrimitiveTopology.TRIANGLE_STRIP
|
|
30
|
-
};
|
|
31
|
-
var sizeFormatMap = {
|
|
32
|
-
[1]: Format.F32_R,
|
|
33
|
-
[2]: Format.F32_RG,
|
|
34
|
-
[3]: Format.F32_RGB,
|
|
35
|
-
[4]: Format.F32_RGBA
|
|
36
|
-
};
|
|
37
|
-
var hintMap = {
|
|
38
|
-
[gl.STATIC_DRAW]: BufferFrequencyHint.STATIC,
|
|
39
|
-
[gl.DYNAMIC_DRAW]: BufferFrequencyHint.DYNAMIC,
|
|
40
|
-
[gl.STREAM_DRAW]: BufferFrequencyHint.DYNAMIC
|
|
41
|
-
};
|
|
42
|
-
var wrapModeMap = {
|
|
43
|
-
[gl.REPEAT]: AddressMode.REPEAT,
|
|
44
|
-
[gl.CLAMP_TO_EDGE]: AddressMode.CLAMP_TO_EDGE,
|
|
45
|
-
[gl.MIRRORED_REPEAT]: AddressMode.MIRRORED_REPEAT
|
|
46
|
-
};
|
|
47
|
-
var depthFuncMap = {
|
|
48
|
-
[gl.NEVER]: CompareFunction.NEVER,
|
|
49
|
-
[gl.ALWAYS]: CompareFunction.ALWAYS,
|
|
50
|
-
[gl.LESS]: CompareFunction.LESS,
|
|
51
|
-
[gl.LEQUAL]: CompareFunction.LEQUAL,
|
|
52
|
-
[gl.GREATER]: CompareFunction.GREATER,
|
|
53
|
-
[gl.GEQUAL]: CompareFunction.GEQUAL,
|
|
54
|
-
[gl.EQUAL]: CompareFunction.EQUAL,
|
|
55
|
-
[gl.NOTEQUAL]: CompareFunction.NOTEQUAL
|
|
56
|
-
};
|
|
57
|
-
var cullFaceMap = {
|
|
58
|
-
[gl.FRONT]: CullMode.FRONT,
|
|
59
|
-
[gl.BACK]: CullMode.BACK
|
|
60
|
-
};
|
|
61
|
-
var blendEquationMap = {
|
|
62
|
-
[gl.FUNC_ADD]: BlendMode.ADD,
|
|
63
|
-
[gl.MIN_EXT]: BlendMode.MIN,
|
|
64
|
-
[gl.MAX_EXT]: BlendMode.MAX,
|
|
65
|
-
[gl.FUNC_SUBTRACT]: BlendMode.SUBSTRACT,
|
|
66
|
-
[gl.FUNC_REVERSE_SUBTRACT]: BlendMode.REVERSE_SUBSTRACT
|
|
67
|
-
};
|
|
68
|
-
var blendFuncMap = {
|
|
69
|
-
[gl.ZERO]: BlendFactor.ZERO,
|
|
70
|
-
[gl.ONE]: BlendFactor.ONE,
|
|
71
|
-
[gl.SRC_COLOR]: BlendFactor.SRC,
|
|
72
|
-
[gl.ONE_MINUS_SRC_COLOR]: BlendFactor.ONE_MINUS_SRC,
|
|
73
|
-
[gl.SRC_ALPHA]: BlendFactor.SRC_ALPHA,
|
|
74
|
-
[gl.ONE_MINUS_SRC_ALPHA]: BlendFactor.ONE_MINUS_SRC_ALPHA,
|
|
75
|
-
[gl.DST_COLOR]: BlendFactor.DST,
|
|
76
|
-
[gl.ONE_MINUS_DST_COLOR]: BlendFactor.ONE_MINUS_DST,
|
|
77
|
-
[gl.DST_ALPHA]: BlendFactor.DST_ALPHA,
|
|
78
|
-
[gl.ONE_MINUS_DST_ALPHA]: BlendFactor.ONE_MINUS_DST_ALPHA,
|
|
79
|
-
[gl.CONSTANT_COLOR]: BlendFactor.CONST,
|
|
80
|
-
[gl.ONE_MINUS_CONSTANT_COLOR]: BlendFactor.ONE_MINUS_CONSTANT,
|
|
81
|
-
[gl.CONSTANT_ALPHA]: BlendFactor.CONST,
|
|
82
|
-
[gl.ONE_MINUS_CONSTANT_ALPHA]: BlendFactor.ONE_MINUS_CONSTANT,
|
|
83
|
-
[gl.SRC_ALPHA_SATURATE]: BlendFactor.SRC_ALPHA_SATURATE
|
|
84
|
-
};
|
|
85
|
-
var stencilOpMap = {
|
|
86
|
-
[gl.REPLACE]: StencilOp.REPLACE,
|
|
87
|
-
[gl.KEEP]: StencilOp.KEEP,
|
|
88
|
-
[gl.ZERO]: StencilOp.ZERO,
|
|
89
|
-
[gl.INVERT]: StencilOp.INVERT,
|
|
90
|
-
[gl.INCR]: StencilOp.INCREMENT_CLAMP,
|
|
91
|
-
[gl.DECR]: StencilOp.DECREMENT_CLAMP,
|
|
92
|
-
[gl.INCR_WRAP]: StencilOp.INCREMENT_WRAP,
|
|
93
|
-
[gl.DECR_WRAP]: StencilOp.DECREMENT_WRAP
|
|
94
|
-
};
|
|
95
|
-
var stencilFuncMap = {
|
|
96
|
-
[gl.ALWAYS]: CompareFunction.ALWAYS,
|
|
97
|
-
[gl.EQUAL]: CompareFunction.EQUAL,
|
|
98
|
-
[gl.GEQUAL]: CompareFunction.GEQUAL,
|
|
99
|
-
[gl.GREATER]: CompareFunction.GREATER,
|
|
100
|
-
[gl.LEQUAL]: CompareFunction.LEQUAL,
|
|
101
|
-
[gl.LESS]: CompareFunction.LESS,
|
|
102
|
-
[gl.NEVER]: CompareFunction.NEVER,
|
|
103
|
-
[gl.NOTEQUAL]: CompareFunction.NOTEQUAL
|
|
104
|
-
};
|
|
105
|
-
export {
|
|
106
|
-
blendEquationMap,
|
|
107
|
-
blendFuncMap,
|
|
108
|
-
cullFaceMap,
|
|
109
|
-
depthFuncMap,
|
|
110
|
-
hintMap,
|
|
111
|
-
primitiveMap,
|
|
112
|
-
sizeFormatMap,
|
|
113
|
-
stencilFuncMap,
|
|
114
|
-
stencilOpMap,
|
|
115
|
-
typedArrayCtorMap,
|
|
116
|
-
wrapModeMap
|
|
117
|
-
};
|
package/es/device/index.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
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/es/device/index.js
DELETED
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
var __async = (__this, __arguments, generator) => {
|
|
2
|
-
return new Promise((resolve, reject) => {
|
|
3
|
-
var fulfilled = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
step(generator.next(value));
|
|
6
|
-
} catch (e) {
|
|
7
|
-
reject(e);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var rejected = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
step(generator.throw(value));
|
|
13
|
-
} catch (e) {
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
// src/device/index.ts
|
|
23
|
-
import {
|
|
24
|
-
Format,
|
|
25
|
-
TextureUsage,
|
|
26
|
-
TransparentBlack,
|
|
27
|
-
ViewportOrigin,
|
|
28
|
-
WebGLDeviceContribution,
|
|
29
|
-
WebGPUDeviceContribution,
|
|
30
|
-
colorNewFromRGBA
|
|
31
|
-
} from "@antv/g-device-api";
|
|
32
|
-
import { lodashUtil } from "@antv/l7-utils";
|
|
33
|
-
import DeviceAttribute from "./DeviceAttribute";
|
|
34
|
-
import DeviceBuffer from "./DeviceBuffer";
|
|
35
|
-
import { RenderCache } from "./DeviceCache";
|
|
36
|
-
import DeviceElements from "./DeviceElements";
|
|
37
|
-
import DeviceFramebuffer from "./DeviceFramebuffer";
|
|
38
|
-
import DeviceModel from "./DeviceModel";
|
|
39
|
-
import DeviceTexture2D from "./DeviceTexture2D";
|
|
40
|
-
import { isWebGL2 } from "./utils/webgl";
|
|
41
|
-
var { isUndefined } = lodashUtil;
|
|
42
|
-
var DeviceRendererService = class {
|
|
43
|
-
constructor() {
|
|
44
|
-
this.uniformBuffers = [];
|
|
45
|
-
this.queryVerdorInfo = () => {
|
|
46
|
-
return this.device.queryVendorInfo().platformString;
|
|
47
|
-
};
|
|
48
|
-
this.createModel = (options) => new DeviceModel(this.device, options, this);
|
|
49
|
-
this.createAttribute = (options) => new DeviceAttribute(this.device, options);
|
|
50
|
-
this.createBuffer = (options) => new DeviceBuffer(this.device, options);
|
|
51
|
-
this.createElements = (options) => new DeviceElements(this.device, options);
|
|
52
|
-
this.createTexture2D = (options) => new DeviceTexture2D(this.device, options);
|
|
53
|
-
this.createFramebuffer = (options) => new DeviceFramebuffer(this.device, options);
|
|
54
|
-
this.useFramebuffer = (framebuffer, drawCommands) => {
|
|
55
|
-
this.currentFramebuffer = framebuffer;
|
|
56
|
-
this.beginFrame();
|
|
57
|
-
drawCommands();
|
|
58
|
-
this.endFrame();
|
|
59
|
-
this.currentFramebuffer = null;
|
|
60
|
-
};
|
|
61
|
-
this.useFramebufferAsync = (framebuffer, drawCommands) => __async(this, null, function* () {
|
|
62
|
-
this.currentFramebuffer = framebuffer;
|
|
63
|
-
this.preRenderPass = this.renderPass;
|
|
64
|
-
this.beginFrame();
|
|
65
|
-
yield drawCommands();
|
|
66
|
-
this.endFrame();
|
|
67
|
-
this.currentFramebuffer = null;
|
|
68
|
-
this.renderPass = this.preRenderPass;
|
|
69
|
-
});
|
|
70
|
-
this.clear = (options) => {
|
|
71
|
-
const { color, depth, stencil, framebuffer = null } = options;
|
|
72
|
-
if (framebuffer) {
|
|
73
|
-
framebuffer.clearOptions = { color, depth, stencil };
|
|
74
|
-
} else {
|
|
75
|
-
const platformString = this.queryVerdorInfo();
|
|
76
|
-
if (platformString === "WebGL1") {
|
|
77
|
-
const gl = this.getGLContext();
|
|
78
|
-
if (!isUndefined(stencil)) {
|
|
79
|
-
gl.clearStencil(stencil);
|
|
80
|
-
gl.clear(gl.STENCIL_BUFFER_BIT);
|
|
81
|
-
} else if (!isUndefined(depth)) {
|
|
82
|
-
gl.clearDepth(depth);
|
|
83
|
-
gl.clear(gl.DEPTH_BUFFER_BIT);
|
|
84
|
-
}
|
|
85
|
-
} else if (platformString === "WebGL2") {
|
|
86
|
-
const gl = this.getGLContext();
|
|
87
|
-
if (!isUndefined(stencil)) {
|
|
88
|
-
gl.clearBufferiv(gl.STENCIL, 0, [stencil]);
|
|
89
|
-
} else if (!isUndefined(depth)) {
|
|
90
|
-
gl.clearBufferfv(gl.DEPTH, 0, [depth]);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
this.viewport = ({
|
|
96
|
-
// x,
|
|
97
|
-
// y,
|
|
98
|
-
width,
|
|
99
|
-
height
|
|
100
|
-
}) => {
|
|
101
|
-
this.swapChain.configureSwapChain(width, height);
|
|
102
|
-
this.createMainColorDepthRT(width, height);
|
|
103
|
-
this.width = width;
|
|
104
|
-
this.height = height;
|
|
105
|
-
};
|
|
106
|
-
this.readPixels = (options) => {
|
|
107
|
-
const { framebuffer, x, y, width, height } = options;
|
|
108
|
-
const readback = this.device.createReadback();
|
|
109
|
-
const texture = framebuffer["colorTexture"];
|
|
110
|
-
const result = readback.readTextureSync(
|
|
111
|
-
texture,
|
|
112
|
-
x,
|
|
113
|
-
/**
|
|
114
|
-
* Origin is at lower-left corner. Width / height is already multiplied by dpr.
|
|
115
|
-
* WebGPU needs flipY
|
|
116
|
-
*/
|
|
117
|
-
this.viewportOrigin === ViewportOrigin.LOWER_LEFT ? y : this.height - y,
|
|
118
|
-
width,
|
|
119
|
-
height,
|
|
120
|
-
new Uint8Array(width * height * 4)
|
|
121
|
-
);
|
|
122
|
-
if (this.viewportOrigin !== ViewportOrigin.LOWER_LEFT) {
|
|
123
|
-
for (let j = 0; j < result.length; j += 4) {
|
|
124
|
-
const t = result[j];
|
|
125
|
-
result[j] = result[j + 2];
|
|
126
|
-
result[j + 2] = t;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
readback.destroy();
|
|
130
|
-
return result;
|
|
131
|
-
};
|
|
132
|
-
this.readPixelsAsync = (options) => __async(this, null, function* () {
|
|
133
|
-
const { framebuffer, x, y, width, height } = options;
|
|
134
|
-
const readback = this.device.createReadback();
|
|
135
|
-
const texture = framebuffer["colorTexture"];
|
|
136
|
-
const result = yield readback.readTexture(
|
|
137
|
-
texture,
|
|
138
|
-
x,
|
|
139
|
-
/**
|
|
140
|
-
* Origin is at lower-left corner. Width / height is already multiplied by dpr.
|
|
141
|
-
* WebGPU needs flipY
|
|
142
|
-
*/
|
|
143
|
-
this.viewportOrigin === ViewportOrigin.LOWER_LEFT ? y : this.height - y,
|
|
144
|
-
width,
|
|
145
|
-
height,
|
|
146
|
-
new Uint8Array(width * height * 4)
|
|
147
|
-
);
|
|
148
|
-
if (this.viewportOrigin !== ViewportOrigin.LOWER_LEFT) {
|
|
149
|
-
for (let j = 0; j < result.length; j += 4) {
|
|
150
|
-
const t = result[j];
|
|
151
|
-
result[j] = result[j + 2];
|
|
152
|
-
result[j + 2] = t;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
readback.destroy();
|
|
156
|
-
return result;
|
|
157
|
-
});
|
|
158
|
-
this.getViewportSize = () => {
|
|
159
|
-
return {
|
|
160
|
-
width: this.width,
|
|
161
|
-
height: this.height
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
this.getContainer = () => {
|
|
165
|
-
var _a;
|
|
166
|
-
return (_a = this.canvas) == null ? void 0 : _a.parentElement;
|
|
167
|
-
};
|
|
168
|
-
this.getCanvas = () => {
|
|
169
|
-
return this.canvas;
|
|
170
|
-
};
|
|
171
|
-
this.getGLContext = () => {
|
|
172
|
-
return this.device["gl"];
|
|
173
|
-
};
|
|
174
|
-
this.destroy = () => {
|
|
175
|
-
var _a;
|
|
176
|
-
this.canvas = null;
|
|
177
|
-
(_a = this.uniformBuffers) == null ? void 0 : _a.forEach((buffer) => {
|
|
178
|
-
buffer.destroy();
|
|
179
|
-
});
|
|
180
|
-
this.device.destroy();
|
|
181
|
-
this.renderCache.destroy();
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
init(canvas, cfg) {
|
|
185
|
-
return __async(this, null, function* () {
|
|
186
|
-
const { enableWebGPU, shaderCompilerPath, antialias } = cfg;
|
|
187
|
-
this.canvas = canvas;
|
|
188
|
-
const deviceContribution = enableWebGPU ? new WebGPUDeviceContribution({
|
|
189
|
-
shaderCompilerPath
|
|
190
|
-
}) : new WebGLDeviceContribution({
|
|
191
|
-
// Use WebGL2 first and downgrade to WebGL1 if WebGL2 is not supported.
|
|
192
|
-
targets: ["webgl2", "webgl1"],
|
|
193
|
-
antialias,
|
|
194
|
-
onContextLost(e) {
|
|
195
|
-
console.warn("context lost", e);
|
|
196
|
-
},
|
|
197
|
-
onContextCreationError(e) {
|
|
198
|
-
console.warn("context creation error", e);
|
|
199
|
-
},
|
|
200
|
-
onContextRestored(e) {
|
|
201
|
-
console.warn("context restored", e);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
const swapChain = yield deviceContribution.createSwapChain(canvas);
|
|
205
|
-
swapChain.configureSwapChain(canvas.width, canvas.height);
|
|
206
|
-
this.device = swapChain.getDevice();
|
|
207
|
-
this.swapChain = swapChain;
|
|
208
|
-
this.renderCache = new RenderCache(this.device);
|
|
209
|
-
this.currentFramebuffer = null;
|
|
210
|
-
this.viewportOrigin = this.device.queryVendorInfo().viewportOrigin;
|
|
211
|
-
const gl = this.device["gl"];
|
|
212
|
-
this.extensionObject = {
|
|
213
|
-
// @ts-ignore
|
|
214
|
-
OES_texture_float: !isWebGL2(gl) && this.device["OES_texture_float"]
|
|
215
|
-
};
|
|
216
|
-
this.createMainColorDepthRT(canvas.width, canvas.height);
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
createMainColorDepthRT(width, height) {
|
|
220
|
-
if (this.mainColorRT) {
|
|
221
|
-
this.mainColorRT.destroy();
|
|
222
|
-
}
|
|
223
|
-
if (this.mainDepthRT) {
|
|
224
|
-
this.mainDepthRT.destroy();
|
|
225
|
-
}
|
|
226
|
-
this.mainColorRT = this.device.createRenderTargetFromTexture(
|
|
227
|
-
this.device.createTexture({
|
|
228
|
-
format: Format.U8_RGBA_RT,
|
|
229
|
-
width,
|
|
230
|
-
height,
|
|
231
|
-
usage: TextureUsage.RENDER_TARGET
|
|
232
|
-
})
|
|
233
|
-
);
|
|
234
|
-
this.mainDepthRT = this.device.createRenderTargetFromTexture(
|
|
235
|
-
this.device.createTexture({
|
|
236
|
-
format: Format.D24_S8,
|
|
237
|
-
width,
|
|
238
|
-
height,
|
|
239
|
-
usage: TextureUsage.RENDER_TARGET
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
beginFrame() {
|
|
244
|
-
this.device.beginFrame();
|
|
245
|
-
const { currentFramebuffer, swapChain, mainColorRT, mainDepthRT } = this;
|
|
246
|
-
const colorAttachment = currentFramebuffer ? currentFramebuffer["colorRenderTarget"] : mainColorRT;
|
|
247
|
-
const colorResolveTo = currentFramebuffer ? null : swapChain.getOnscreenTexture();
|
|
248
|
-
const depthStencilAttachment = currentFramebuffer ? currentFramebuffer["depthRenderTarget"] : mainDepthRT;
|
|
249
|
-
const { color = [0, 0, 0, 0], depth = 1, stencil = 0 } = (
|
|
250
|
-
// @ts-ignore
|
|
251
|
-
(currentFramebuffer == null ? void 0 : currentFramebuffer.clearOptions) || {}
|
|
252
|
-
);
|
|
253
|
-
const colorClearColor = colorAttachment ? colorNewFromRGBA(color[0] * 255, color[1] * 255, color[2] * 255, color[3]) : TransparentBlack;
|
|
254
|
-
const depthClearValue = depthStencilAttachment ? depth : void 0;
|
|
255
|
-
const stencilClearValue = depthStencilAttachment ? stencil : void 0;
|
|
256
|
-
const renderPass = this.device.createRenderPass({
|
|
257
|
-
colorAttachment: [colorAttachment],
|
|
258
|
-
colorResolveTo: [colorResolveTo],
|
|
259
|
-
colorClearColor: [colorClearColor],
|
|
260
|
-
// colorStore: [!!currentFramebuffer],
|
|
261
|
-
colorStore: [true],
|
|
262
|
-
depthStencilAttachment,
|
|
263
|
-
depthClearValue,
|
|
264
|
-
stencilClearValue
|
|
265
|
-
});
|
|
266
|
-
this.renderPass = renderPass;
|
|
267
|
-
}
|
|
268
|
-
endFrame() {
|
|
269
|
-
this.device.submitPass(this.renderPass);
|
|
270
|
-
this.device.endFrame();
|
|
271
|
-
}
|
|
272
|
-
getPointSizeRange() {
|
|
273
|
-
const gl = this.device["gl"];
|
|
274
|
-
return gl.getParameter(gl.ALIASED_POINT_SIZE_RANGE);
|
|
275
|
-
}
|
|
276
|
-
testExtension(name) {
|
|
277
|
-
return !!this.getGLContext().getExtension(name);
|
|
278
|
-
}
|
|
279
|
-
// TODO: 临时方法
|
|
280
|
-
setState() {
|
|
281
|
-
const gl = this.getGLContext();
|
|
282
|
-
if (gl) {
|
|
283
|
-
gl.disable(gl.CULL_FACE);
|
|
284
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
285
|
-
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
setBaseState() {
|
|
289
|
-
const gl = this.getGLContext();
|
|
290
|
-
if (gl) {
|
|
291
|
-
gl.disable(gl.CULL_FACE);
|
|
292
|
-
gl.blendEquation(gl.FUNC_ADD);
|
|
293
|
-
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
setCustomLayerDefaults() {
|
|
297
|
-
const gl = this.getGLContext();
|
|
298
|
-
if (gl) {
|
|
299
|
-
gl.disable(gl.CULL_FACE);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
setDirty(flag) {
|
|
303
|
-
this.isDirty = flag;
|
|
304
|
-
}
|
|
305
|
-
getDirty() {
|
|
306
|
-
return this.isDirty;
|
|
307
|
-
}
|
|
308
|
-
};
|
|
309
|
-
export {
|
|
310
|
-
DeviceRendererService as default
|
|
311
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
// src/device/utils/HashMap.ts
|
|
2
|
-
function hashCodeNumberUpdate(hash, v = 0) {
|
|
3
|
-
hash += v;
|
|
4
|
-
hash += hash << 10;
|
|
5
|
-
hash += hash >>> 6;
|
|
6
|
-
return hash >>> 0;
|
|
7
|
-
}
|
|
8
|
-
function hashCodeNumberFinish(hash) {
|
|
9
|
-
hash += hash << 3;
|
|
10
|
-
hash ^= hash >>> 11;
|
|
11
|
-
hash += hash << 15;
|
|
12
|
-
return hash >>> 0;
|
|
13
|
-
}
|
|
14
|
-
function nullHashFunc() {
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
var HashBucket = class {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.keys = [];
|
|
20
|
-
this.values = [];
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
var HashMap = class {
|
|
24
|
-
constructor(keyEqualFunc, keyHashFunc) {
|
|
25
|
-
this.keyEqualFunc = keyEqualFunc;
|
|
26
|
-
this.keyHashFunc = keyHashFunc;
|
|
27
|
-
this.buckets = /* @__PURE__ */ new Map();
|
|
28
|
-
}
|
|
29
|
-
findBucketIndex(bucket, k) {
|
|
30
|
-
for (let i = 0; i < bucket.keys.length; i++)
|
|
31
|
-
if (this.keyEqualFunc(k, bucket.keys[i]))
|
|
32
|
-
return i;
|
|
33
|
-
return -1;
|
|
34
|
-
}
|
|
35
|
-
findBucket(k) {
|
|
36
|
-
const bw = this.keyHashFunc(k);
|
|
37
|
-
return this.buckets.get(bw);
|
|
38
|
-
}
|
|
39
|
-
get(k) {
|
|
40
|
-
const bucket = this.findBucket(k);
|
|
41
|
-
if (bucket === void 0)
|
|
42
|
-
return null;
|
|
43
|
-
const bi = this.findBucketIndex(bucket, k);
|
|
44
|
-
if (bi < 0)
|
|
45
|
-
return null;
|
|
46
|
-
return bucket.values[bi];
|
|
47
|
-
}
|
|
48
|
-
add(k, v) {
|
|
49
|
-
const bw = this.keyHashFunc(k);
|
|
50
|
-
if (this.buckets.get(bw) === void 0)
|
|
51
|
-
this.buckets.set(bw, new HashBucket());
|
|
52
|
-
const bucket = this.buckets.get(bw);
|
|
53
|
-
bucket.keys.push(k);
|
|
54
|
-
bucket.values.push(v);
|
|
55
|
-
}
|
|
56
|
-
delete(k) {
|
|
57
|
-
const bucket = this.findBucket(k);
|
|
58
|
-
if (bucket === void 0)
|
|
59
|
-
return;
|
|
60
|
-
const bi = this.findBucketIndex(bucket, k);
|
|
61
|
-
if (bi === -1)
|
|
62
|
-
return;
|
|
63
|
-
bucket.keys.splice(bi, 1);
|
|
64
|
-
bucket.values.splice(bi, 1);
|
|
65
|
-
}
|
|
66
|
-
clear() {
|
|
67
|
-
this.buckets.clear();
|
|
68
|
-
}
|
|
69
|
-
size() {
|
|
70
|
-
let acc = 0;
|
|
71
|
-
for (const bucket of this.buckets.values())
|
|
72
|
-
acc += bucket.values.length;
|
|
73
|
-
return acc;
|
|
74
|
-
}
|
|
75
|
-
*values() {
|
|
76
|
-
for (const bucket of this.buckets.values())
|
|
77
|
-
for (let j = bucket.values.length - 1; j >= 0; j--)
|
|
78
|
-
yield bucket.values[j];
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
export {
|
|
82
|
-
HashMap,
|
|
83
|
-
hashCodeNumberFinish,
|
|
84
|
-
hashCodeNumberUpdate,
|
|
85
|
-
nullHashFunc
|
|
86
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pipelineEquals(): void;
|
|
@@ -1,7 +0,0 @@
|
|
|
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;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// src/device/utils/typedarray.ts
|
|
2
|
-
var dtypes = {
|
|
3
|
-
"[object Int8Array]": 5120,
|
|
4
|
-
"[object Int16Array]": 5122,
|
|
5
|
-
"[object Int32Array]": 5124,
|
|
6
|
-
"[object Uint8Array]": 5121,
|
|
7
|
-
"[object Uint8ClampedArray]": 5121,
|
|
8
|
-
"[object Uint16Array]": 5123,
|
|
9
|
-
"[object Uint32Array]": 5125,
|
|
10
|
-
"[object Float32Array]": 5126,
|
|
11
|
-
"[object Float64Array]": 5121,
|
|
12
|
-
"[object ArrayBuffer]": 5121
|
|
13
|
-
};
|
|
14
|
-
function isTypedArray(x) {
|
|
15
|
-
return Object.prototype.toString.call(x) in dtypes;
|
|
16
|
-
}
|
|
17
|
-
function extend3ChannelsTo4(array, valueToInsert) {
|
|
18
|
-
const originalLength = array.length;
|
|
19
|
-
const insertCount = Math.ceil(originalLength / 3);
|
|
20
|
-
const newLength = originalLength + insertCount;
|
|
21
|
-
const newArray = new Float32Array(newLength);
|
|
22
|
-
for (let i = 0; i < newLength; i += 4) {
|
|
23
|
-
newArray[i] = array[i / 4 * 3];
|
|
24
|
-
newArray[i + 1] = array[i / 4 * 3 + 1];
|
|
25
|
-
newArray[i + 2] = array[i / 4 * 3 + 2];
|
|
26
|
-
newArray[i + 3] = valueToInsert;
|
|
27
|
-
}
|
|
28
|
-
return newArray;
|
|
29
|
-
}
|
|
30
|
-
export {
|
|
31
|
-
extend3ChannelsTo4,
|
|
32
|
-
isTypedArray
|
|
33
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isWebGL2(gl: WebGL2RenderingContext | WebGLRenderingContext): gl is WebGL2RenderingContext;
|
package/es/device/utils/webgl.js
DELETED
package/es/index.d.ts
DELETED