@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.
Files changed (53) hide show
  1. package/es/device/DeviceAttribute.js +26 -32
  2. package/es/device/DeviceBuffer.js +31 -49
  3. package/es/device/DeviceCache.js +136 -170
  4. package/es/device/DeviceElements.js +32 -38
  5. package/es/device/DeviceFramebuffer.js +76 -104
  6. package/es/device/DeviceModel.js +358 -384
  7. package/es/device/DeviceTexture2D.js +103 -122
  8. package/es/device/constants.js +117 -34
  9. package/es/device/index.js +254 -381
  10. package/es/device/utils/HashMap.js +71 -138
  11. package/es/device/utils/pipeline.js +6 -1
  12. package/es/device/utils/typedarray.js +23 -24
  13. package/es/device/utils/webgl.js +7 -6
  14. package/es/index.js +5 -4
  15. package/es/regl/ReglAttribute.js +17 -33
  16. package/es/regl/ReglBuffer.js +25 -40
  17. package/es/regl/ReglElements.js +21 -36
  18. package/es/regl/ReglFramebuffer.js +24 -44
  19. package/es/regl/ReglModel.js +266 -306
  20. package/es/regl/ReglRenderbuffer.js +19 -36
  21. package/es/regl/ReglTexture2D.js +72 -103
  22. package/es/regl/constants.js +133 -21
  23. package/es/regl/index.js +205 -289
  24. package/lib/device/DeviceAttribute.d.ts +13 -0
  25. package/lib/device/DeviceBuffer.d.ts +18 -0
  26. package/lib/device/DeviceCache.d.ts +14 -0
  27. package/lib/device/DeviceElements.d.ts +13 -0
  28. package/lib/device/DeviceFramebuffer.d.ts +24 -0
  29. package/lib/device/DeviceModel.d.ts +53 -0
  30. package/lib/device/DeviceModel.js +22 -15
  31. package/lib/device/DeviceTexture2D.d.ts +23 -0
  32. package/lib/device/constants.d.ts +35 -0
  33. package/lib/device/index.d.ts +68 -0
  34. package/lib/device/index.js +58 -36
  35. package/lib/device/utils/HashMap.d.ts +24 -0
  36. package/lib/device/utils/pipeline.d.ts +1 -0
  37. package/lib/device/utils/typedarray.d.ts +7 -0
  38. package/lib/device/utils/webgl.d.ts +1 -0
  39. package/lib/index.d.ts +6 -0
  40. package/lib/regl/ReglAttribute.d.ts +16 -0
  41. package/lib/regl/ReglBuffer.d.ts +17 -0
  42. package/lib/regl/ReglElements.d.ts +14 -0
  43. package/lib/regl/ReglFramebuffer.d.ts +16 -0
  44. package/lib/regl/ReglModel.d.ts +46 -0
  45. package/lib/regl/ReglModel.js +21 -11
  46. package/lib/regl/ReglRenderbuffer.d.ts +16 -0
  47. package/lib/regl/ReglTexture2D.d.ts +22 -0
  48. package/lib/regl/constants.d.ts +43 -0
  49. package/lib/regl/index.d.ts +56 -0
  50. package/lib/regl/index.js +70 -48
  51. package/package.json +14 -18
  52. package/CHANGELOG.md +0 -350
  53. package/LICENSE.md +0 -21
@@ -1,117 +1,89 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
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
- _createClass(DeviceFramebuffer, [{
18
- key: "createColorRenderTarget",
19
- value: function createColorRenderTarget() {
20
- var resize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
21
- var _this$options = this.options,
22
- width = _this$options.width,
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
- key: "createDepthRenderTarget",
52
- value: function createDepthRenderTarget() {
53
- var resize = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
54
- var _this$options2 = this.options,
55
- width = _this$options2.width,
56
- height = _this$options2.height,
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
- key: "get",
86
- value: function get() {
87
- return this.colorRenderTarget;
88
- }
89
- }, {
90
- key: "destroy",
91
- value: function destroy() {
92
- var _this$colorRenderTarg, _this$depthRenderTarg;
93
- (_this$colorRenderTarg = this.colorRenderTarget) === null || _this$colorRenderTarg === void 0 || _this$colorRenderTarg.destroy();
94
- (_this$depthRenderTarg = this.depthRenderTarget) === null || _this$depthRenderTarg === void 0 || _this$depthRenderTarg.destroy();
95
- }
96
- }, {
97
- key: "resize",
98
- value: function resize(_ref) {
99
- var width = _ref.width,
100
- height = _ref.height;
101
- if (this.width !== width || this.height !== height) {
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
- return DeviceFramebuffer;
116
- }();
117
- export { DeviceFramebuffer as default };
85
+ }
86
+ };
87
+ export {
88
+ DeviceFramebuffer as default
89
+ };