@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,117 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { Format, TextureUsage } from '@antv/g-device-api';
|
|
1
|
+
// src/device/DeviceFramebuffer.ts
|
|
2
|
+
import { Format, TextureUsage } from "@antv/g-device-api";
|
|
4
3
|
import { isTexture2D } from "./DeviceTexture2D";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Contains 2 render targets: color and depth.
|
|
8
|
-
*/
|
|
9
|
-
var DeviceFramebuffer = /*#__PURE__*/function () {
|
|
10
|
-
function DeviceFramebuffer(device, options) {
|
|
11
|
-
_classCallCheck(this, DeviceFramebuffer);
|
|
4
|
+
var DeviceFramebuffer = class {
|
|
5
|
+
constructor(device, options) {
|
|
12
6
|
this.device = device;
|
|
13
7
|
this.options = options;
|
|
14
8
|
this.createColorRenderTarget();
|
|
15
9
|
this.createDepthRenderTarget();
|
|
16
10
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
height = _this$options.height,
|
|
24
|
-
color = _this$options.color;
|
|
25
|
-
if (color) {
|
|
26
|
-
if (isTexture2D(color)) {
|
|
27
|
-
if (resize) {
|
|
28
|
-
color.resize({
|
|
29
|
-
width: width,
|
|
30
|
-
height: height
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
this.colorTexture = color.get();
|
|
34
|
-
this.colorRenderTarget = this.device.createRenderTargetFromTexture(this.colorTexture);
|
|
35
|
-
this.width = color['width'];
|
|
36
|
-
this.height = color['height'];
|
|
37
|
-
} else if (width && height) {
|
|
38
|
-
this.colorTexture = this.device.createTexture({
|
|
39
|
-
format: Format.U8_RGBA_RT,
|
|
40
|
-
usage: TextureUsage.RENDER_TARGET,
|
|
41
|
-
width: width,
|
|
42
|
-
height: height
|
|
43
|
-
});
|
|
44
|
-
this.colorRenderTarget = this.device.createRenderTargetFromTexture(this.colorTexture);
|
|
45
|
-
this.width = width;
|
|
46
|
-
this.height = height;
|
|
11
|
+
createColorRenderTarget(resize = false) {
|
|
12
|
+
const { width, height, color } = this.options;
|
|
13
|
+
if (color) {
|
|
14
|
+
if (isTexture2D(color)) {
|
|
15
|
+
if (resize) {
|
|
16
|
+
color.resize({ width, height });
|
|
47
17
|
}
|
|
18
|
+
this.colorTexture = color.get();
|
|
19
|
+
this.colorRenderTarget = this.device.createRenderTargetFromTexture(
|
|
20
|
+
this.colorTexture
|
|
21
|
+
);
|
|
22
|
+
this.width = color["width"];
|
|
23
|
+
this.height = color["height"];
|
|
24
|
+
} else if (width && height) {
|
|
25
|
+
this.colorTexture = this.device.createTexture({
|
|
26
|
+
format: Format.U8_RGBA_RT,
|
|
27
|
+
usage: TextureUsage.RENDER_TARGET,
|
|
28
|
+
width,
|
|
29
|
+
height
|
|
30
|
+
});
|
|
31
|
+
this.colorRenderTarget = this.device.createRenderTargetFromTexture(
|
|
32
|
+
this.colorTexture
|
|
33
|
+
);
|
|
34
|
+
this.width = width;
|
|
35
|
+
this.height = height;
|
|
48
36
|
}
|
|
49
37
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
depth = _this$options2.depth;
|
|
58
|
-
// TODO: avoid creating depth texture if not needed
|
|
59
|
-
if (depth) {
|
|
60
|
-
if (isTexture2D(depth)) {
|
|
61
|
-
if (resize) {
|
|
62
|
-
depth.resize({
|
|
63
|
-
width: width,
|
|
64
|
-
height: height
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
this.depthTexture = depth.get();
|
|
68
|
-
this.depthRenderTarget = this.device.createRenderTargetFromTexture(this.depthTexture);
|
|
69
|
-
this.width = depth['width'];
|
|
70
|
-
this.height = depth['height'];
|
|
71
|
-
} else if (width && height) {
|
|
72
|
-
this.depthTexture = this.device.createTexture({
|
|
73
|
-
format: Format.D24_S8,
|
|
74
|
-
usage: TextureUsage.RENDER_TARGET,
|
|
75
|
-
width: width,
|
|
76
|
-
height: height
|
|
77
|
-
});
|
|
78
|
-
this.depthRenderTarget = this.device.createRenderTargetFromTexture(this.depthTexture);
|
|
79
|
-
this.width = width;
|
|
80
|
-
this.height = height;
|
|
38
|
+
}
|
|
39
|
+
createDepthRenderTarget(resize = false) {
|
|
40
|
+
const { width, height, depth } = this.options;
|
|
41
|
+
if (depth) {
|
|
42
|
+
if (isTexture2D(depth)) {
|
|
43
|
+
if (resize) {
|
|
44
|
+
depth.resize({ width, height });
|
|
81
45
|
}
|
|
46
|
+
this.depthTexture = depth.get();
|
|
47
|
+
this.depthRenderTarget = this.device.createRenderTargetFromTexture(
|
|
48
|
+
this.depthTexture
|
|
49
|
+
);
|
|
50
|
+
this.width = depth["width"];
|
|
51
|
+
this.height = depth["height"];
|
|
52
|
+
} else if (width && height) {
|
|
53
|
+
this.depthTexture = this.device.createTexture({
|
|
54
|
+
format: Format.D24_S8,
|
|
55
|
+
usage: TextureUsage.RENDER_TARGET,
|
|
56
|
+
width,
|
|
57
|
+
height
|
|
58
|
+
});
|
|
59
|
+
this.depthRenderTarget = this.device.createRenderTargetFromTexture(
|
|
60
|
+
this.depthTexture
|
|
61
|
+
);
|
|
62
|
+
this.width = width;
|
|
63
|
+
this.height = height;
|
|
82
64
|
}
|
|
83
65
|
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
this.destroy();
|
|
103
|
-
// Prevent double free texture.
|
|
104
|
-
// @ts-ignore
|
|
105
|
-
this.colorTexture.destroyed = true;
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
this.depthTexture.destroyed = true;
|
|
108
|
-
this.options.width = width;
|
|
109
|
-
this.options.height = height;
|
|
110
|
-
this.createColorRenderTarget(true);
|
|
111
|
-
this.createDepthRenderTarget(true);
|
|
112
|
-
}
|
|
66
|
+
}
|
|
67
|
+
get() {
|
|
68
|
+
return this.colorRenderTarget;
|
|
69
|
+
}
|
|
70
|
+
destroy() {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
(_a = this.colorRenderTarget) == null ? void 0 : _a.destroy();
|
|
73
|
+
(_b = this.depthRenderTarget) == null ? void 0 : _b.destroy();
|
|
74
|
+
}
|
|
75
|
+
resize({ width, height }) {
|
|
76
|
+
if (this.width !== width || this.height !== height) {
|
|
77
|
+
this.destroy();
|
|
78
|
+
this.colorTexture.destroyed = true;
|
|
79
|
+
this.depthTexture.destroyed = true;
|
|
80
|
+
this.options.width = width;
|
|
81
|
+
this.options.height = height;
|
|
82
|
+
this.createColorRenderTarget(true);
|
|
83
|
+
this.createDepthRenderTarget(true);
|
|
113
84
|
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
DeviceFramebuffer as default
|
|
89
|
+
};
|