@antv/l7-renderer 2.20.5 → 2.20.6
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 +2 -2
- package/es/device/DeviceBuffer.d.ts +2 -2
- package/es/device/DeviceBuffer.js +5 -1
- package/es/device/DeviceElements.d.ts +2 -2
- package/es/device/DeviceFramebuffer.d.ts +12 -3
- package/es/device/DeviceFramebuffer.js +70 -30
- package/es/device/DeviceModel.d.ts +17 -4
- package/es/device/DeviceModel.js +64 -40
- package/es/device/DeviceTexture2D.d.ts +2 -2
- package/es/device/DeviceTexture2D.js +25 -22
- package/es/device/constants.d.ts +1 -1
- package/es/device/index.d.ts +20 -12
- package/es/device/index.js +73 -74
- package/es/regl/ReglAttribute.d.ts +2 -2
- package/es/regl/ReglBuffer.d.ts +2 -2
- package/es/regl/ReglElements.d.ts +2 -2
- package/es/regl/ReglFramebuffer.d.ts +2 -2
- package/es/regl/ReglModel.d.ts +2 -2
- package/es/regl/ReglModel.js +4 -2
- package/es/regl/ReglRenderbuffer.d.ts +2 -2
- package/es/regl/ReglTexture2D.d.ts +2 -2
- package/es/regl/constants.d.ts +1 -1
- package/es/regl/index.d.ts +1 -1
- package/lib/device/DeviceBuffer.js +4 -1
- package/lib/device/DeviceFramebuffer.js +61 -27
- package/lib/device/DeviceModel.js +59 -11
- package/lib/device/DeviceTexture2D.js +18 -17
- package/lib/device/index.js +60 -27
- package/lib/regl/ReglModel.js +8 -6
- package/package.json +9 -9
|
@@ -27,7 +27,7 @@ var import_g_device_api = require("@antv/g-device-api");
|
|
|
27
27
|
var import_l7_core = require("@antv/l7-core");
|
|
28
28
|
var import_constants = require("./constants");
|
|
29
29
|
function isTexture2D(t) {
|
|
30
|
-
return
|
|
30
|
+
return !!(t && t["texture"]);
|
|
31
31
|
}
|
|
32
32
|
var DeviceTexture2D = class {
|
|
33
33
|
constructor(device, options) {
|
|
@@ -41,12 +41,13 @@ var DeviceTexture2D = class {
|
|
|
41
41
|
format = import_l7_core.gl.RGBA,
|
|
42
42
|
wrapS = import_l7_core.gl.CLAMP_TO_EDGE,
|
|
43
43
|
wrapT = import_l7_core.gl.CLAMP_TO_EDGE,
|
|
44
|
-
|
|
45
|
-
alignment = 1
|
|
46
|
-
|
|
44
|
+
aniso = 0,
|
|
45
|
+
alignment = 1,
|
|
46
|
+
usage = import_l7_core.TextureUsage.SAMPLED,
|
|
47
|
+
mipmap = false,
|
|
47
48
|
// premultiplyAlpha = false,
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
mag = import_l7_core.gl.NEAREST,
|
|
50
|
+
min = import_l7_core.gl.NEAREST
|
|
50
51
|
// colorSpace = gl.BROWSER_DEFAULT_WEBGL,
|
|
51
52
|
// x = 0,
|
|
52
53
|
// y = 0,
|
|
@@ -57,10 +58,10 @@ var DeviceTexture2D = class {
|
|
|
57
58
|
let pixelFormat = import_g_device_api.Format.U8_RGBA_RT;
|
|
58
59
|
if (type === import_l7_core.gl.UNSIGNED_BYTE && format === import_l7_core.gl.RGBA) {
|
|
59
60
|
pixelFormat = import_g_device_api.Format.U8_RGBA_RT;
|
|
60
|
-
} else if (
|
|
61
|
-
pixelFormat = import_g_device_api.Format.F32_LUMINANCE;
|
|
62
|
-
} else if (format === import_l7_core.gl.LUMINANCE && type === import_l7_core.gl.UNSIGNED_BYTE) {
|
|
61
|
+
} else if (type === import_l7_core.gl.UNSIGNED_BYTE && format === import_l7_core.gl.LUMINANCE) {
|
|
63
62
|
pixelFormat = import_g_device_api.Format.U8_LUMINANCE;
|
|
63
|
+
} else if (type === import_l7_core.gl.FLOAT && format === import_l7_core.gl.RGB) {
|
|
64
|
+
pixelFormat = import_g_device_api.Format.F32_RGB;
|
|
64
65
|
} else {
|
|
65
66
|
throw new Error(`create texture error, type: ${type}, format: ${format}`);
|
|
66
67
|
}
|
|
@@ -68,11 +69,12 @@ var DeviceTexture2D = class {
|
|
|
68
69
|
format: pixelFormat,
|
|
69
70
|
width,
|
|
70
71
|
height,
|
|
71
|
-
usage: import_g_device_api.TextureUsage.SAMPLED,
|
|
72
|
+
usage: usage === import_l7_core.TextureUsage.SAMPLED ? import_g_device_api.TextureUsage.SAMPLED : import_g_device_api.TextureUsage.RENDER_TARGET,
|
|
72
73
|
pixelStore: {
|
|
73
74
|
unpackFlipY: flipY,
|
|
74
75
|
packAlignment: alignment
|
|
75
|
-
}
|
|
76
|
+
},
|
|
77
|
+
mipLevelCount: usage === import_l7_core.TextureUsage.RENDER_TARGET ? 1 : mipmap ? 1 : 0
|
|
76
78
|
});
|
|
77
79
|
if (data) {
|
|
78
80
|
this.texture.setImageData([data]);
|
|
@@ -80,13 +82,12 @@ var DeviceTexture2D = class {
|
|
|
80
82
|
this.sampler = device.createSampler({
|
|
81
83
|
addressModeU: import_constants.wrapModeMap[wrapS],
|
|
82
84
|
addressModeV: import_constants.wrapModeMap[wrapT],
|
|
83
|
-
minFilter: import_g_device_api.FilterMode.POINT,
|
|
84
|
-
|
|
85
|
-
magFilter: import_g_device_api.FilterMode.BILINEAR,
|
|
85
|
+
minFilter: min === import_l7_core.gl.NEAREST ? import_g_device_api.FilterMode.POINT : import_g_device_api.FilterMode.BILINEAR,
|
|
86
|
+
magFilter: mag === import_l7_core.gl.NEAREST ? import_g_device_api.FilterMode.POINT : import_g_device_api.FilterMode.BILINEAR,
|
|
86
87
|
mipmapFilter: import_g_device_api.MipmapFilterMode.NO_MIP,
|
|
87
|
-
lodMinClamp: 0,
|
|
88
|
-
lodMaxClamp: 0
|
|
89
|
-
|
|
88
|
+
// lodMinClamp: 0,
|
|
89
|
+
// lodMaxClamp: 0,
|
|
90
|
+
maxAnisotropy: aniso
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
93
|
get() {
|
package/lib/device/index.js
CHANGED
|
@@ -54,15 +54,24 @@ var import_webgl = require("./utils/webgl");
|
|
|
54
54
|
var DeviceRendererService = class {
|
|
55
55
|
constructor() {
|
|
56
56
|
this.uniformBuffers = [];
|
|
57
|
-
this.createModel = (options) => new import_DeviceModel.default(this.device, options);
|
|
57
|
+
this.createModel = (options) => new import_DeviceModel.default(this.device, options, this);
|
|
58
58
|
this.createAttribute = (options) => new import_DeviceAttribute.default(this.device, options);
|
|
59
59
|
this.createBuffer = (options) => new import_DeviceBuffer.default(this.device, options);
|
|
60
60
|
this.createElements = (options) => new import_DeviceElements.default(this.device, options);
|
|
61
61
|
this.createTexture2D = (options) => new import_DeviceTexture2D.default(this.device, options);
|
|
62
62
|
this.createFramebuffer = (options) => new import_DeviceFramebuffer.default(this.device, options);
|
|
63
|
-
this.useFramebuffer = () => {
|
|
63
|
+
this.useFramebuffer = (framebuffer, drawCommands) => {
|
|
64
|
+
this.currentFramebuffer = framebuffer;
|
|
65
|
+
this.beginFrame();
|
|
66
|
+
drawCommands();
|
|
67
|
+
this.endFrame();
|
|
68
|
+
this.currentFramebuffer = null;
|
|
64
69
|
};
|
|
65
|
-
this.clear = () => {
|
|
70
|
+
this.clear = (options) => {
|
|
71
|
+
const { color, depth, stencil, framebuffer = null } = options;
|
|
72
|
+
if (framebuffer) {
|
|
73
|
+
framebuffer.clearOptions = { color, depth, stencil };
|
|
74
|
+
}
|
|
66
75
|
};
|
|
67
76
|
this.viewport = ({
|
|
68
77
|
// x,
|
|
@@ -72,18 +81,24 @@ var DeviceRendererService = class {
|
|
|
72
81
|
}) => {
|
|
73
82
|
this.width = width;
|
|
74
83
|
this.height = height;
|
|
75
|
-
this.device.width = width;
|
|
76
|
-
this.device.height = height;
|
|
77
84
|
};
|
|
78
|
-
this.readPixels = () => {
|
|
79
|
-
|
|
85
|
+
this.readPixels = (options) => {
|
|
86
|
+
const { framebuffer, x, y, width, height } = options;
|
|
87
|
+
const readback = this.device.createReadback();
|
|
88
|
+
const texture = framebuffer["colorTexture"];
|
|
89
|
+
return readback.readTextureSync(
|
|
90
|
+
texture,
|
|
91
|
+
x,
|
|
92
|
+
y,
|
|
93
|
+
width,
|
|
94
|
+
height,
|
|
95
|
+
new Uint8Array(width * height * 4)
|
|
96
|
+
);
|
|
80
97
|
};
|
|
81
98
|
this.getViewportSize = () => {
|
|
82
99
|
return {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
height: this.device.height
|
|
100
|
+
width: this.width,
|
|
101
|
+
height: this.height
|
|
87
102
|
};
|
|
88
103
|
};
|
|
89
104
|
this.getContainer = () => {
|
|
@@ -127,18 +142,20 @@ var DeviceRendererService = class {
|
|
|
127
142
|
swapChain.configureSwapChain(canvas.width, canvas.height);
|
|
128
143
|
this.device = swapChain.getDevice();
|
|
129
144
|
this.swapChain = swapChain;
|
|
145
|
+
this.currentFramebuffer = null;
|
|
130
146
|
const gl = this.device["gl"];
|
|
131
147
|
this.extensionObject = {
|
|
132
148
|
// @ts-ignore
|
|
133
149
|
OES_texture_float: !(0, import_webgl.isWebGL2)(gl) && this.device["OES_texture_float"]
|
|
134
150
|
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
151
|
+
this.mainColorRT = this.device.createRenderTargetFromTexture(
|
|
152
|
+
this.device.createTexture({
|
|
153
|
+
format: import_g_device_api.Format.U8_RGBA_RT,
|
|
154
|
+
width: canvas.width,
|
|
155
|
+
height: canvas.height,
|
|
156
|
+
usage: import_g_device_api.TextureUsage.RENDER_TARGET
|
|
157
|
+
})
|
|
158
|
+
);
|
|
142
159
|
this.mainDepthRT = this.device.createRenderTargetFromTexture(
|
|
143
160
|
this.device.createTexture({
|
|
144
161
|
format: import_g_device_api.Format.D24_S8,
|
|
@@ -149,16 +166,32 @@ var DeviceRendererService = class {
|
|
|
149
166
|
);
|
|
150
167
|
}
|
|
151
168
|
beginFrame() {
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
169
|
+
const { currentFramebuffer, swapChain, mainColorRT, mainDepthRT } = this;
|
|
170
|
+
const onscreenTexture = swapChain.getOnscreenTexture();
|
|
171
|
+
const colorAttachment = currentFramebuffer ? currentFramebuffer["colorRenderTarget"] : mainColorRT;
|
|
172
|
+
const colorResolveTo = currentFramebuffer ? null : onscreenTexture;
|
|
173
|
+
const depthStencilAttachment = currentFramebuffer ? currentFramebuffer["depthRenderTarget"] : mainDepthRT;
|
|
174
|
+
const { color = [0, 0, 0, 0], depth = 1, stencil = 0 } = (
|
|
175
|
+
// @ts-ignore
|
|
176
|
+
(currentFramebuffer == null ? void 0 : currentFramebuffer.clearOptions) || {}
|
|
177
|
+
);
|
|
178
|
+
const colorClearColor = colorAttachment ? (0, import_g_device_api.colorNewFromRGBA)(
|
|
179
|
+
color[0] * 255,
|
|
180
|
+
color[1] * 255,
|
|
181
|
+
color[2] * 255,
|
|
182
|
+
color[3]
|
|
183
|
+
) : import_g_device_api.TransparentBlack;
|
|
184
|
+
const depthClearValue = depthStencilAttachment ? depth : void 0;
|
|
185
|
+
const stencilClearValue = depthStencilAttachment ? stencil : void 0;
|
|
186
|
+
const renderPass = this.device.createRenderPass({
|
|
187
|
+
colorAttachment: [colorAttachment],
|
|
188
|
+
colorResolveTo: [colorResolveTo],
|
|
189
|
+
colorClearColor: [colorClearColor],
|
|
190
|
+
depthStencilAttachment,
|
|
191
|
+
depthClearValue,
|
|
192
|
+
stencilClearValue
|
|
160
193
|
});
|
|
161
|
-
this.
|
|
194
|
+
this.renderPass = renderPass;
|
|
162
195
|
}
|
|
163
196
|
endFrame() {
|
|
164
197
|
this.device.submitPass(this.renderPass);
|
package/lib/regl/ReglModel.js
CHANGED
|
@@ -65,15 +65,17 @@ var ReglModel = class {
|
|
|
65
65
|
Object.keys(attributes).forEach((name) => {
|
|
66
66
|
reglAttributes[name] = attributes[name].get();
|
|
67
67
|
});
|
|
68
|
+
const frag = (0, import_l7_core.removeDuplicateUniforms)(
|
|
69
|
+
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "frag", fs, null, false)
|
|
70
|
+
);
|
|
71
|
+
const vert = (0, import_l7_core.removeDuplicateUniforms)(
|
|
72
|
+
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "vert", vs, null, false)
|
|
73
|
+
);
|
|
68
74
|
const drawParams = {
|
|
69
75
|
attributes: reglAttributes,
|
|
70
|
-
frag
|
|
71
|
-
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "frag", fs, null, false)
|
|
72
|
-
),
|
|
76
|
+
frag,
|
|
73
77
|
uniforms: reglUniforms,
|
|
74
|
-
vert
|
|
75
|
-
(0, import_g_device_api.preprocessShader_GLSL)(vendorInfo, "vert", vs, null, false)
|
|
76
|
-
),
|
|
78
|
+
vert,
|
|
77
79
|
// @ts-ignore
|
|
78
80
|
colorMask: reGl.prop("colorMask"),
|
|
79
81
|
lineWidth: 1,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-renderer",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "xiaoiver",
|
|
@@ -14,30 +14,30 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"tsc": "tsc --project tsconfig.build.json",
|
|
18
17
|
"build": "father build",
|
|
19
18
|
"build:cjs": "BABEL_ENV=cjs babel src --root-mode upward --out-dir lib --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
20
19
|
"build:esm": "BABEL_ENV=esm babel src --root-mode upward --out-dir es --source-maps --extensions .ts,.tsx --delete-dir-on-start --no-comments",
|
|
21
20
|
"clean": "rimraf dist; rimraf es; rimraf lib;",
|
|
22
21
|
"sync": "tnpm sync",
|
|
23
22
|
"test": "umi-test --passWithNoTests",
|
|
24
|
-
"test-live": "umi-test --watch"
|
|
23
|
+
"test-live": "umi-test --watch",
|
|
24
|
+
"tsc": "tsc --project tsconfig.build.json"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@antv/g-device-api": "^1.
|
|
28
|
-
"@antv/l7-core": "2.20.
|
|
29
|
-
"@antv/l7-utils": "2.20.
|
|
27
|
+
"@antv/g-device-api": "^1.4.5",
|
|
28
|
+
"@antv/l7-core": "2.20.6",
|
|
29
|
+
"@antv/l7-utils": "2.20.6",
|
|
30
30
|
"@babel/runtime": "^7.7.7",
|
|
31
31
|
"inversify": "^5.0.1",
|
|
32
|
-
"reflect-metadata": "^0.1
|
|
32
|
+
"reflect-metadata": "^0.2.1",
|
|
33
33
|
"regl": "1.6.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@antv/l7-test-utils": "2.20.
|
|
36
|
+
"@antv/l7-test-utils": "2.20.6",
|
|
37
37
|
"gl": "^6.0.2"
|
|
38
38
|
},
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "b5af1f23f8f5524cbbb2ea858399fefba63b0163"
|
|
43
43
|
}
|