@luma.gl/engine 9.0.0-alpha.9 → 9.0.0-beta.10

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 (187) hide show
  1. package/LICENSE +3 -1
  2. package/dist/animation/key-frames.d.ts +1 -1
  3. package/dist/animation/key-frames.d.ts.map +1 -1
  4. package/dist/animation/key-frames.js +51 -72
  5. package/dist/animation/timeline.d.ts +8 -8
  6. package/dist/animation/timeline.d.ts.map +1 -1
  7. package/dist/animation/timeline.js +95 -131
  8. package/dist/animation-loop/animation-loop-template.d.ts +23 -0
  9. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -0
  10. package/dist/animation-loop/animation-loop-template.js +21 -0
  11. package/dist/{lib → animation-loop}/animation-loop.d.ts +31 -23
  12. package/dist/animation-loop/animation-loop.d.ts.map +1 -0
  13. package/dist/animation-loop/animation-loop.js +442 -0
  14. package/dist/{lib → animation-loop}/animation-props.d.ts +4 -5
  15. package/dist/animation-loop/animation-props.d.ts.map +1 -0
  16. package/dist/animation-loop/animation-props.js +1 -0
  17. package/dist/animation-loop/make-animation-loop.d.ts +6 -0
  18. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -0
  19. package/dist/animation-loop/make-animation-loop.js +32 -0
  20. package/dist/computation.d.ts +95 -0
  21. package/dist/computation.d.ts.map +1 -0
  22. package/dist/computation.js +248 -0
  23. package/dist/debug/copy-texture-to-image.d.ts +26 -0
  24. package/dist/debug/copy-texture-to-image.d.ts.map +1 -0
  25. package/dist/debug/copy-texture-to-image.js +43 -0
  26. package/dist/debug/debug-framebuffer.d.ts +11 -0
  27. package/dist/debug/debug-framebuffer.d.ts.map +1 -0
  28. package/dist/debug/debug-framebuffer.js +46 -0
  29. package/dist/debug/debug-shader-layout.d.ts +9 -0
  30. package/dist/debug/debug-shader-layout.d.ts.map +1 -0
  31. package/dist/debug/debug-shader-layout.js +27 -0
  32. package/dist/debug/pixel-data-utils.d.ts +24 -0
  33. package/dist/debug/pixel-data-utils.d.ts.map +1 -0
  34. package/dist/debug/pixel-data-utils.js +39 -0
  35. package/dist/dist.dev.js +9592 -0
  36. package/dist/dist.min.js +102 -0
  37. package/dist/geometries/cone-geometry.d.ts +2 -2
  38. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  39. package/dist/geometries/cone-geometry.js +13 -18
  40. package/dist/geometries/cube-geometry.d.ts +2 -2
  41. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  42. package/dist/geometries/cube-geometry.js +192 -57
  43. package/dist/geometries/cylinder-geometry.d.ts +2 -2
  44. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  45. package/dist/geometries/cylinder-geometry.js +11 -15
  46. package/dist/geometries/ico-sphere-geometry.d.ts +2 -2
  47. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  48. package/dist/geometries/ico-sphere-geometry.js +143 -171
  49. package/dist/geometries/plane-geometry.d.ts +2 -2
  50. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  51. package/dist/geometries/plane-geometry.js +95 -122
  52. package/dist/geometries/sphere-geometry.d.ts +2 -2
  53. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  54. package/dist/geometries/sphere-geometry.js +78 -101
  55. package/dist/geometries/truncated-cone-geometry.d.ts +2 -4
  56. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  57. package/dist/geometries/truncated-cone-geometry.js +100 -134
  58. package/dist/geometry/geometry-table.d.ts +2 -2
  59. package/dist/geometry/geometry-table.d.ts.map +1 -1
  60. package/dist/geometry/geometry-table.js +3 -1
  61. package/dist/geometry/geometry-utils.d.ts.map +1 -1
  62. package/dist/geometry/geometry-utils.js +35 -41
  63. package/dist/geometry/geometry.d.ts +43 -43
  64. package/dist/geometry/geometry.d.ts.map +1 -1
  65. package/dist/geometry/geometry.js +82 -139
  66. package/dist/geometry/gpu-geometry.d.ts +37 -0
  67. package/dist/geometry/gpu-geometry.d.ts.map +1 -0
  68. package/dist/geometry/gpu-geometry.js +90 -0
  69. package/dist/geometry/gpu-table.d.ts +1 -0
  70. package/dist/geometry/gpu-table.d.ts.map +1 -0
  71. package/dist/geometry/gpu-table.js +42 -0
  72. package/dist/index.cjs +3444 -0
  73. package/dist/index.cjs.map +7 -0
  74. package/dist/index.d.ts +43 -24
  75. package/dist/index.d.ts.map +1 -1
  76. package/dist/index.js +29 -15
  77. package/dist/lib/clip-space.d.ts +8 -0
  78. package/dist/lib/clip-space.d.ts.map +1 -1
  79. package/dist/lib/clip-space.js +43 -2
  80. package/dist/lib/pipeline-factory.d.ts +17 -51
  81. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  82. package/dist/lib/pipeline-factory.js +84 -209
  83. package/dist/lib/shader-factory.d.ts +17 -0
  84. package/dist/lib/shader-factory.d.ts.map +1 -0
  85. package/dist/lib/shader-factory.js +46 -0
  86. package/dist/model/model.d.ts +219 -0
  87. package/dist/model/model.d.ts.map +1 -0
  88. package/dist/model/model.js +659 -0
  89. package/dist/scenegraph/group-node.d.ts +21 -0
  90. package/dist/scenegraph/group-node.d.ts.map +1 -0
  91. package/dist/scenegraph/group-node.js +84 -0
  92. package/dist/scenegraph/model-node.d.ts +18 -0
  93. package/dist/scenegraph/model-node.d.ts.map +1 -0
  94. package/dist/scenegraph/model-node.js +35 -0
  95. package/dist/scenegraph/scenegraph-node.d.ts +56 -0
  96. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -0
  97. package/dist/scenegraph/scenegraph-node.js +153 -0
  98. package/dist/shader-inputs.d.ts +63 -0
  99. package/dist/shader-inputs.d.ts.map +1 -0
  100. package/dist/shader-inputs.js +107 -0
  101. package/dist/transform/buffer-transform.d.ts +35 -0
  102. package/dist/transform/buffer-transform.d.ts.map +1 -0
  103. package/dist/transform/buffer-transform.js +70 -0
  104. package/dist/transform/texture-transform.d.ts +57 -0
  105. package/dist/transform/texture-transform.d.ts.map +1 -0
  106. package/dist/transform/texture-transform.js +117 -0
  107. package/dist.min.js +25 -0
  108. package/package.json +24 -14
  109. package/src/animation/timeline.ts +35 -34
  110. package/src/animation-loop/animation-loop-template.ts +25 -0
  111. package/src/{lib → animation-loop}/animation-loop.ts +114 -93
  112. package/src/{lib → animation-loop}/animation-props.ts +2 -2
  113. package/src/animation-loop/make-animation-loop.ts +53 -0
  114. package/src/computation.ts +346 -0
  115. package/src/debug/copy-texture-to-image.ts +70 -0
  116. package/src/debug/debug-framebuffer.ts +70 -0
  117. package/src/debug/debug-shader-layout.ts +38 -0
  118. package/src/debug/pixel-data-utils.ts +54 -0
  119. package/src/geometries/cone-geometry.ts +1 -1
  120. package/src/geometries/cube-geometry.ts +62 -56
  121. package/src/geometries/cylinder-geometry.ts +2 -2
  122. package/src/geometries/ico-sphere-geometry.ts +6 -5
  123. package/src/geometries/plane-geometry.ts +5 -4
  124. package/src/geometries/sphere-geometry.ts +4 -3
  125. package/src/geometries/truncated-cone-geometry.ts +6 -14
  126. package/src/geometry/geometry-table.ts +10 -7
  127. package/src/geometry/geometry-utils.ts +19 -3
  128. package/src/geometry/geometry.ts +68 -110
  129. package/src/geometry/gpu-geometry.ts +132 -0
  130. package/src/geometry/gpu-table.ts +41 -0
  131. package/src/index.ts +37 -10
  132. package/src/lib/clip-space.ts +32 -34
  133. package/src/lib/pipeline-factory.ts +83 -193
  134. package/src/lib/shader-factory.ts +57 -0
  135. package/src/model/model.ts +835 -0
  136. package/src/scenegraph/group-node.ts +107 -0
  137. package/src/scenegraph/model-node.ts +50 -0
  138. package/src/scenegraph/scenegraph-node.ts +204 -0
  139. package/src/shader-inputs.ts +157 -0
  140. package/src/transform/buffer-transform.ts +102 -0
  141. package/src/transform/texture-transform.ts +168 -0
  142. package/dist/animation/key-frames.js.map +0 -1
  143. package/dist/animation/timeline.js.map +0 -1
  144. package/dist/bundle.d.ts +0 -2
  145. package/dist/bundle.d.ts.map +0 -1
  146. package/dist/bundle.js +0 -5
  147. package/dist/bundle.js.map +0 -1
  148. package/dist/geometries/cone-geometry.js.map +0 -1
  149. package/dist/geometries/cube-geometry.js.map +0 -1
  150. package/dist/geometries/cylinder-geometry.js.map +0 -1
  151. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  152. package/dist/geometries/plane-geometry.js.map +0 -1
  153. package/dist/geometries/sphere-geometry.js.map +0 -1
  154. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  155. package/dist/geometry/geometry-table.js.map +0 -1
  156. package/dist/geometry/geometry-utils.js.map +0 -1
  157. package/dist/geometry/geometry.js.map +0 -1
  158. package/dist/geometry/primitive-utils.d.ts +0 -1
  159. package/dist/geometry/primitive-utils.d.ts.map +0 -1
  160. package/dist/geometry/primitive-utils.js +0 -2
  161. package/dist/geometry/primitive-utils.js.map +0 -1
  162. package/dist/index.js.map +0 -1
  163. package/dist/lib/animation-loop.d.ts.map +0 -1
  164. package/dist/lib/animation-loop.js +0 -480
  165. package/dist/lib/animation-loop.js.map +0 -1
  166. package/dist/lib/animation-props.d.ts.map +0 -1
  167. package/dist/lib/animation-props.js +0 -2
  168. package/dist/lib/animation-props.js.map +0 -1
  169. package/dist/lib/clip-space.js.map +0 -1
  170. package/dist/lib/model-utils.d.ts +0 -5
  171. package/dist/lib/model-utils.d.ts.map +0 -1
  172. package/dist/lib/model-utils.js +0 -45
  173. package/dist/lib/model-utils.js.map +0 -1
  174. package/dist/lib/model.d.ts +0 -41
  175. package/dist/lib/model.d.ts.map +0 -1
  176. package/dist/lib/model.js +0 -182
  177. package/dist/lib/model.js.map +0 -1
  178. package/dist/lib/pipeline-factory.js.map +0 -1
  179. package/dist/lib/render-loop.d.ts +0 -14
  180. package/dist/lib/render-loop.d.ts.map +0 -1
  181. package/dist/lib/render-loop.js +0 -49
  182. package/dist/lib/render-loop.js.map +0 -1
  183. package/src/bundle.ts +0 -4
  184. package/src/geometry/primitive-utils.ts +0 -30
  185. package/src/lib/model-utils.ts +0 -124
  186. package/src/lib/model.ts +0 -183
  187. package/src/lib/render-loop.ts +0 -58
@@ -1,145 +1,88 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { uid, assert } from '@luma.gl/api';
3
- import GL from '@luma.gl/constants';
4
- export default class Geometry {
5
- constructor(props = {}) {
6
- _defineProperty(this, "id", void 0);
7
-
8
- _defineProperty(this, "userData", {});
9
-
10
- _defineProperty(this, "topology", void 0);
11
-
12
- _defineProperty(this, "drawMode", GL.TRIANGLES);
13
-
14
- _defineProperty(this, "vertexCount", void 0);
15
-
16
- _defineProperty(this, "attributes", void 0);
17
-
18
- _defineProperty(this, "indices", void 0);
19
-
20
- const {
21
- id = uid('geometry'),
22
- drawMode = GL.TRIANGLES,
23
- attributes = {},
24
- indices = null,
25
- vertexCount = null
26
- } = props;
27
- this.id = id;
28
- this.drawMode = drawMode;
29
- this.topology = props.topology || convertToTopology(drawMode);
30
-
31
- if (indices) {
32
- this.indices = ArrayBuffer.isView(indices) ? {
33
- value: indices,
34
- size: 1
35
- } : indices;
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ import { uid, assert } from '@luma.gl/core';
5
+ export class Geometry {
6
+ id;
7
+ /** Determines how vertices are read from the 'vertex' attributes */
8
+ topology;
9
+ vertexCount;
10
+ indices;
11
+ attributes;
12
+ userData = {};
13
+ constructor(props) {
14
+ const { attributes = {}, indices = null, vertexCount = null } = props;
15
+ this.id = props.id || uid('geometry');
16
+ this.topology = props.topology;
17
+ if (indices) {
18
+ this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
19
+ }
20
+ // @ts-expect-error
21
+ this.attributes = {};
22
+ for (const [attributeName, attributeValue] of Object.entries(attributes)) {
23
+ // Wrap "unwrapped" arrays and try to autodetect their type
24
+ const attribute = ArrayBuffer.isView(attributeValue)
25
+ ? { value: attributeValue }
26
+ : attributeValue;
27
+ assert(ArrayBuffer.isView(attribute.value), `${this._print(attributeName)}: must be typed array or object with value as typed array`);
28
+ if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
29
+ attribute.size = 3;
30
+ }
31
+ // Move indices to separate field
32
+ if (attributeName === 'indices') {
33
+ assert(!this.indices);
34
+ this.indices = attribute;
35
+ }
36
+ else {
37
+ this.attributes[attributeName] = attribute;
38
+ }
39
+ }
40
+ if (this.indices && this.indices.isIndexed !== undefined) {
41
+ this.indices = Object.assign({}, this.indices);
42
+ delete this.indices.isIndexed;
43
+ }
44
+ this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
36
45
  }
37
-
38
- this.attributes = {};
39
-
40
- for (const [attributeName, attributeValue] of Object.entries(attributes)) {
41
- const attribute = ArrayBuffer.isView(attributeValue) ? {
42
- value: attributeValue
43
- } : attributeValue;
44
- assert(ArrayBuffer.isView(attribute.value), "".concat(this._print(attributeName), ": must be typed array or object with value as typed array"));
45
-
46
- if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
47
- attribute.size = 3;
48
- }
49
-
50
- if (attributeName === 'indices') {
51
- assert(!this.indices);
52
- this.indices = attribute;
53
- } else {
54
- this.attributes[attributeName] = attribute;
55
- }
46
+ getVertexCount() {
47
+ return this.vertexCount;
56
48
  }
57
-
58
- if (this.indices && this.indices.isIndexed !== undefined) {
59
- this.indices = Object.assign({}, this.indices);
60
- delete this.indices.isIndexed;
49
+ /**
50
+ * Return an object with all attributes plus indices added as a field.
51
+ * TODO Geometry types are a mess
52
+ */
53
+ getAttributes() {
54
+ return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
61
55
  }
62
-
63
- this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
64
- }
65
-
66
- get mode() {
67
- return this.drawMode;
68
- }
69
-
70
- getVertexCount() {
71
- return this.vertexCount;
72
- }
73
-
74
- _print(attributeName) {
75
- return "Geometry ".concat(this.id, " attribute ").concat(attributeName);
76
- }
77
-
78
- _setAttributes(attributes, indices) {
79
- return this;
80
- }
81
-
82
- _calculateVertexCount(attributes, indices) {
83
- if (indices) {
84
- return indices.value.length;
56
+ // PRIVATE
57
+ _print(attributeName) {
58
+ return `Geometry ${this.id} attribute ${attributeName}`;
85
59
  }
86
-
87
- let vertexCount = Infinity;
88
-
89
- for (const attributeName in attributes) {
90
- const attribute = attributes[attributeName];
91
- const {
92
- value,
93
- size,
94
- constant
95
- } = attribute;
96
-
97
- if (!constant && value && size >= 1) {
98
- vertexCount = Math.min(vertexCount, value.length / size);
99
- }
60
+ /**
61
+ * GeometryAttribute
62
+ * value: typed array
63
+ * type: indices, vertices, uvs
64
+ * size: elements per vertex
65
+ * target: WebGL buffer type (string or constant)
66
+ *
67
+ * @param attributes
68
+ * @param indices
69
+ * @returns
70
+ */
71
+ _setAttributes(attributes, indices) {
72
+ return this;
73
+ }
74
+ _calculateVertexCount(attributes, indices) {
75
+ if (indices) {
76
+ return indices.value.length;
77
+ }
78
+ let vertexCount = Infinity;
79
+ for (const attribute of Object.values(attributes)) {
80
+ const { value, size, constant } = attribute;
81
+ if (!constant && value && size >= 1) {
82
+ vertexCount = Math.min(vertexCount, value.length / size);
83
+ }
84
+ }
85
+ assert(Number.isFinite(vertexCount));
86
+ return vertexCount;
100
87
  }
101
-
102
- assert(Number.isFinite(vertexCount));
103
- return vertexCount;
104
- }
105
-
106
- }
107
-
108
- _defineProperty(Geometry, "DRAW_MODE", {
109
- POINTS: GL.POINTS,
110
- LINES: GL.LINES,
111
- LINE_LOOP: GL.LINE_LOOP,
112
- LINE_STRIP: GL.LINE_STRIP,
113
- TRIANGLES: GL.TRIANGLES,
114
- TRIANGLE_STRIP: GL.TRIANGLE_STRIP,
115
- TRIANGLE_FAN: GL.TRIANGLE_FAN
116
- });
117
-
118
- function convertToTopology(drawMode) {
119
- switch (drawMode) {
120
- case GL.POINTS:
121
- return 'point-list';
122
-
123
- case GL.LINES:
124
- return 'line-list';
125
-
126
- case GL.LINE_STRIP:
127
- return 'line-strip';
128
-
129
- case GL.TRIANGLES:
130
- return 'triangle-list';
131
-
132
- case GL.TRIANGLE_STRIP:
133
- return 'triangle-strip';
134
-
135
- case GL.TRIANGLE_FAN:
136
- return 'triangle-fan';
137
-
138
- case GL.LINE_LOOP:
139
- return 'line-loop';
140
-
141
- default:
142
- throw new Error(String(drawMode));
143
- }
144
88
  }
145
- //# sourceMappingURL=geometry.js.map
@@ -0,0 +1,37 @@
1
+ import type { PrimitiveTopology, BufferLayout } from '@luma.gl/core';
2
+ import { Device, Buffer } from '@luma.gl/core';
3
+ import type { Geometry } from "../geometry/geometry.js";
4
+ export type GPUGeometryProps = {
5
+ id?: string;
6
+ /** Determines how vertices are read from the 'vertex' attributes */
7
+ topology: 'point-list' | 'line-list' | 'line-strip' | 'line-loop-webgl' | 'triangle-list' | 'triangle-strip' | 'triangle-fan-webgl';
8
+ /** Auto calculated from attributes if not provided */
9
+ vertexCount: number;
10
+ bufferLayout: BufferLayout[];
11
+ indices?: Buffer | null;
12
+ attributes: Record<string, Buffer>;
13
+ };
14
+ export declare class GPUGeometry {
15
+ readonly id: string;
16
+ userData: Record<string, unknown>;
17
+ /** Determines how vertices are read from the 'vertex' attributes */
18
+ readonly topology?: PrimitiveTopology;
19
+ readonly bufferLayout: BufferLayout[];
20
+ readonly vertexCount: number;
21
+ readonly indices?: Buffer | null;
22
+ readonly attributes: Record<string, Buffer>;
23
+ constructor(props: GPUGeometryProps);
24
+ destroy(): void;
25
+ getVertexCount(): number;
26
+ getAttributes(): Record<string, Buffer>;
27
+ getIndexes(): Buffer | null;
28
+ _calculateVertexCount(positions: Buffer): number;
29
+ }
30
+ export declare function makeGPUGeometry(device: Device, geometry: Geometry | GPUGeometry): GPUGeometry;
31
+ export declare function getIndexBufferFromGeometry(device: Device, geometry: Geometry): Buffer | undefined;
32
+ export declare function getAttributeBuffersFromGeometry(device: Device, geometry: Geometry): {
33
+ attributes: Record<string, Buffer>;
34
+ bufferLayout: BufferLayout[];
35
+ vertexCount: number;
36
+ };
37
+ //# sourceMappingURL=gpu-geometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/gpu-geometry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AACnE,OAAO,EAAC,MAAM,EAAE,MAAM,EAA4C,MAAM,eAAe,CAAC;AACxF,OAAO,KAAK,EAAC,QAAQ,EAAC,gCAA6B;AAEnD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,QAAQ,EACJ,YAAY,GACZ,WAAW,GACX,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,gBAAgB,GAChB,oBAAoB,CAAC;IACzB,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,EAAE,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC,CAAC;AAEF,qBAAa,WAAW;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAEvC,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;IACtC,QAAQ,CAAC,YAAY,EAAE,YAAY,EAAE,CAAM;IAE3C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEhC,KAAK,EAAE,gBAAgB;IAenC,OAAO,IAAI,IAAI;IAOf,cAAc,IAAI,MAAM;IAIxB,aAAa,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAIvC,UAAU,IAAI,MAAM,GAAG,IAAI;IAI3B,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;CAKjD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,WAAW,GAAG,WAAW,CAc7F;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAMjG;AAED,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,YAAY,EAAE,YAAY,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAC,CA6BzF"}
@@ -0,0 +1,90 @@
1
+ import { Buffer, uid, assert, getVertexFormatFromAttribute } from '@luma.gl/core';
2
+ export class GPUGeometry {
3
+ id;
4
+ userData = {};
5
+ /** Determines how vertices are read from the 'vertex' attributes */
6
+ topology;
7
+ bufferLayout = [];
8
+ vertexCount;
9
+ indices;
10
+ attributes;
11
+ constructor(props) {
12
+ this.id = props.id || uid('geometry');
13
+ this.topology = props.topology;
14
+ this.indices = props.indices || null;
15
+ this.attributes = props.attributes;
16
+ this.vertexCount = props.vertexCount;
17
+ this.bufferLayout = props.bufferLayout || [];
18
+ if (this.indices) {
19
+ assert(this.indices.usage === Buffer.INDEX);
20
+ }
21
+ }
22
+ destroy() {
23
+ this.indices?.destroy();
24
+ for (const attribute of Object.values(this.attributes)) {
25
+ attribute.destroy();
26
+ }
27
+ }
28
+ getVertexCount() {
29
+ return this.vertexCount;
30
+ }
31
+ getAttributes() {
32
+ return this.attributes;
33
+ }
34
+ getIndexes() {
35
+ return this.indices;
36
+ }
37
+ _calculateVertexCount(positions) {
38
+ // Assume that positions is a fully packed float32x3 buffer
39
+ const vertexCount = positions.byteLength / 12;
40
+ return vertexCount;
41
+ }
42
+ }
43
+ export function makeGPUGeometry(device, geometry) {
44
+ if (geometry instanceof GPUGeometry) {
45
+ return geometry;
46
+ }
47
+ const indices = getIndexBufferFromGeometry(device, geometry);
48
+ const { attributes, bufferLayout } = getAttributeBuffersFromGeometry(device, geometry);
49
+ return new GPUGeometry({
50
+ topology: geometry.topology || 'triangle-list',
51
+ bufferLayout,
52
+ vertexCount: geometry.vertexCount,
53
+ indices,
54
+ attributes
55
+ });
56
+ }
57
+ export function getIndexBufferFromGeometry(device, geometry) {
58
+ if (!geometry.indices) {
59
+ return undefined;
60
+ }
61
+ const data = geometry.indices.value;
62
+ return device.createBuffer({ usage: Buffer.INDEX, data });
63
+ }
64
+ export function getAttributeBuffersFromGeometry(device, geometry) {
65
+ const bufferLayout = [];
66
+ const attributes = {};
67
+ for (const [attributeName, attribute] of Object.entries(geometry.attributes)) {
68
+ let name = attributeName;
69
+ // TODO Map some GLTF attribute names (is this still needed?)
70
+ switch (attributeName) {
71
+ case 'POSITION':
72
+ name = 'positions';
73
+ break;
74
+ case 'NORMAL':
75
+ name = 'normals';
76
+ break;
77
+ case 'TEXCOORD_0':
78
+ name = 'texCoords';
79
+ break;
80
+ case 'COLOR_0':
81
+ name = 'colors';
82
+ break;
83
+ }
84
+ attributes[name] = device.createBuffer({ data: attribute.value, id: `${attributeName}-buffer` });
85
+ const { value, size, normalized } = attribute;
86
+ bufferLayout.push({ name, format: getVertexFormatFromAttribute(value, size, normalized) });
87
+ }
88
+ const vertexCount = geometry._calculateVertexCount(geometry.attributes, geometry.indices);
89
+ return { attributes, bufferLayout, vertexCount };
90
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=gpu-table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpu-table.d.ts","sourceRoot":"","sources":["../../src/geometry/gpu-table.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*
3
+ export function getAttributeLayoutsFromGeometry(geometry: Geometry) {
4
+ const layouts: Record<string, {}> = {};
5
+ let indices = geometry.indices;
6
+
7
+ for (const [name, attribute] of Object.entries(geometry.attributes)) {
8
+ const remappedName = mapAttributeName(name);
9
+
10
+ if (attribute.constant) {
11
+ throw new Error('constant attributes not supported');
12
+ } else {
13
+ const typedArray = attribute.value;
14
+ // Create accessor by copying the attribute and removing `value``
15
+ const accessor = {...attribute};
16
+ delete accessor.value;
17
+ buffers[remappedName] = [device.createBuffer(typedArray), accessor];
18
+
19
+ inferAttributeAccessor(name, accessor);
20
+ }
21
+ }
22
+ }
23
+
24
+ export class Table {
25
+ length: number;
26
+ // columns: Record<string, TypedArray> = {};
27
+ }
28
+
29
+ export class GPUTable {
30
+ length: number;
31
+ columns: Record<string, Buffer> = {};
32
+ }
33
+
34
+ export function convertTableToGPUTable(table: Table) {
35
+ // for (const ) {}
36
+ }
37
+
38
+ export function renameTableColumns(table: Table, map: (name: string) => string) {
39
+ const newColumns = table.columns.reduce()
40
+ table.clone();
41
+ }
42
+ */