@luma.gl/engine 9.0.0-alpha.14 → 9.0.0-alpha.16

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 (172) hide show
  1. package/dist/animation/key-frames.d.ts +1 -1
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js +51 -72
  4. package/dist/animation/timeline.d.ts +4 -4
  5. package/dist/animation/timeline.d.ts.map +1 -1
  6. package/dist/animation/timeline.js +94 -131
  7. package/dist/animation-loop/animation-loop.d.ts +2 -3
  8. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  9. package/dist/animation-loop/animation-loop.js +414 -473
  10. package/dist/animation-loop/animation-props.d.ts +1 -2
  11. package/dist/animation-loop/animation-props.d.ts.map +1 -1
  12. package/dist/animation-loop/animation-props.js +0 -1
  13. package/dist/animation-loop/make-animation-loop.d.ts +1 -1
  14. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  15. package/dist/animation-loop/make-animation-loop.js +26 -31
  16. package/dist/animation-loop/render-loop.js +17 -7
  17. package/dist/bundle.js +2 -2
  18. package/dist/dist.min.js +31 -0
  19. package/dist/es5/animation/key-frames.js +84 -0
  20. package/dist/es5/animation/key-frames.js.map +1 -0
  21. package/dist/es5/animation/timeline.js +183 -0
  22. package/dist/es5/animation/timeline.js.map +1 -0
  23. package/dist/es5/animation-loop/animation-loop.js +534 -0
  24. package/dist/es5/animation-loop/animation-loop.js.map +1 -0
  25. package/dist/es5/animation-loop/animation-props.js +2 -0
  26. package/dist/es5/animation-loop/animation-props.js.map +1 -0
  27. package/dist/es5/animation-loop/make-animation-loop.js +53 -0
  28. package/dist/es5/animation-loop/make-animation-loop.js.map +1 -0
  29. package/dist/es5/animation-loop/render-loop.js +39 -0
  30. package/dist/es5/animation-loop/render-loop.js.map +1 -0
  31. package/dist/es5/bundle.js +6 -0
  32. package/dist/es5/bundle.js.map +1 -0
  33. package/dist/es5/geometries/cone-geometry.js +43 -0
  34. package/dist/es5/geometries/cone-geometry.js.map +1 -0
  35. package/dist/es5/geometries/cube-geometry.js +84 -0
  36. package/dist/es5/geometries/cube-geometry.js.map +1 -0
  37. package/dist/es5/geometries/cylinder-geometry.js +39 -0
  38. package/dist/es5/geometries/cylinder-geometry.js.map +1 -0
  39. package/dist/es5/geometries/ico-sphere-geometry.js +185 -0
  40. package/dist/es5/geometries/ico-sphere-geometry.js.map +1 -0
  41. package/dist/es5/geometries/plane-geometry.js +137 -0
  42. package/dist/es5/geometries/plane-geometry.js.map +1 -0
  43. package/dist/es5/geometries/sphere-geometry.js +120 -0
  44. package/dist/es5/geometries/sphere-geometry.js.map +1 -0
  45. package/dist/es5/geometries/truncated-cone-geometry.js +160 -0
  46. package/dist/es5/geometries/truncated-cone-geometry.js.map +1 -0
  47. package/dist/es5/geometry/geometry-table.js +2 -0
  48. package/dist/es5/geometry/geometry-table.js.map +1 -0
  49. package/dist/es5/geometry/geometry-utils.js +39 -0
  50. package/dist/es5/geometry/geometry-utils.js.map +1 -0
  51. package/dist/es5/geometry/geometry.js +150 -0
  52. package/dist/es5/geometry/geometry.js.map +1 -0
  53. package/dist/es5/geometry/primitive-utils.js +2 -0
  54. package/dist/es5/geometry/primitive-utils.js.map +1 -0
  55. package/dist/es5/index.js +112 -0
  56. package/dist/es5/index.js.map +1 -0
  57. package/dist/es5/lib/clip-space.js +2 -0
  58. package/dist/es5/lib/clip-space.js.map +1 -0
  59. package/dist/es5/lib/model-utils.js +52 -0
  60. package/dist/es5/lib/model-utils.js.map +1 -0
  61. package/dist/es5/lib/model.js +173 -0
  62. package/dist/es5/lib/model.js.map +1 -0
  63. package/dist/es5/lib/pipeline-factory.js +244 -0
  64. package/dist/es5/lib/pipeline-factory.js.map +1 -0
  65. package/dist/esm/animation/key-frames.js +57 -0
  66. package/dist/esm/animation/key-frames.js.map +1 -0
  67. package/dist/esm/animation/timeline.js +113 -0
  68. package/dist/esm/animation/timeline.js.map +1 -0
  69. package/dist/esm/animation-loop/animation-loop.js +367 -0
  70. package/dist/esm/animation-loop/animation-loop.js.map +1 -0
  71. package/dist/esm/animation-loop/animation-props.js +2 -0
  72. package/dist/esm/animation-loop/animation-props.js.map +1 -0
  73. package/dist/esm/animation-loop/make-animation-loop.js +28 -0
  74. package/dist/esm/animation-loop/make-animation-loop.js.map +1 -0
  75. package/dist/esm/animation-loop/render-loop.js +7 -0
  76. package/dist/esm/animation-loop/render-loop.js.map +1 -0
  77. package/dist/esm/bundle.js +4 -0
  78. package/dist/esm/bundle.js.map +1 -0
  79. package/dist/esm/geometries/cone-geometry.js +21 -0
  80. package/dist/esm/geometries/cone-geometry.js.map +1 -0
  81. package/dist/esm/geometries/cube-geometry.js +67 -0
  82. package/dist/esm/geometries/cube-geometry.js.map +1 -0
  83. package/dist/esm/geometries/cylinder-geometry.js +18 -0
  84. package/dist/esm/geometries/cylinder-geometry.js.map +1 -0
  85. package/dist/esm/geometries/ico-sphere-geometry.js +170 -0
  86. package/dist/esm/geometries/ico-sphere-geometry.js.map +1 -0
  87. package/dist/esm/geometries/plane-geometry.js +119 -0
  88. package/dist/esm/geometries/plane-geometry.js.map +1 -0
  89. package/dist/esm/geometries/sphere-geometry.js +102 -0
  90. package/dist/esm/geometries/sphere-geometry.js.map +1 -0
  91. package/dist/esm/geometries/truncated-cone-geometry.js +136 -0
  92. package/dist/esm/geometries/truncated-cone-geometry.js.map +1 -0
  93. package/dist/esm/geometry/geometry-table.js +2 -0
  94. package/dist/esm/geometry/geometry-table.js.map +1 -0
  95. package/dist/esm/geometry/geometry-utils.js +37 -0
  96. package/dist/esm/geometry/geometry-utils.js.map +1 -0
  97. package/dist/esm/geometry/geometry.js +119 -0
  98. package/dist/esm/geometry/geometry.js.map +1 -0
  99. package/dist/esm/geometry/primitive-utils.js +2 -0
  100. package/dist/esm/geometry/primitive-utils.js.map +1 -0
  101. package/dist/esm/index.js +16 -0
  102. package/dist/esm/index.js.map +1 -0
  103. package/dist/esm/lib/clip-space.js +2 -0
  104. package/dist/esm/lib/clip-space.js.map +1 -0
  105. package/dist/esm/lib/model-utils.js +40 -0
  106. package/dist/esm/lib/model-utils.js.map +1 -0
  107. package/dist/esm/lib/model.js +146 -0
  108. package/dist/esm/lib/model.js.map +1 -0
  109. package/dist/esm/lib/pipeline-factory.js +180 -0
  110. package/dist/esm/lib/pipeline-factory.js.map +1 -0
  111. package/dist/geometries/cone-geometry.d.ts +1 -1
  112. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  113. package/dist/geometries/cone-geometry.js +12 -17
  114. package/dist/geometries/cube-geometry.d.ts +1 -1
  115. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  116. package/dist/geometries/cube-geometry.js +187 -56
  117. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  118. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  119. package/dist/geometries/cylinder-geometry.js +10 -14
  120. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  121. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  122. package/dist/geometries/ico-sphere-geometry.js +141 -170
  123. package/dist/geometries/plane-geometry.d.ts +1 -1
  124. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  125. package/dist/geometries/plane-geometry.js +93 -121
  126. package/dist/geometries/sphere-geometry.d.ts +1 -1
  127. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  128. package/dist/geometries/sphere-geometry.js +76 -100
  129. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  130. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  131. package/dist/geometries/truncated-cone-geometry.js +104 -131
  132. package/dist/geometry/geometry-table.d.ts +1 -1
  133. package/dist/geometry/geometry-table.d.ts.map +1 -1
  134. package/dist/geometry/geometry-table.js +0 -1
  135. package/dist/geometry/geometry-utils.js +22 -41
  136. package/dist/geometry/geometry.d.ts +4 -4
  137. package/dist/geometry/geometry.d.ts.map +1 -1
  138. package/dist/geometry/geometry.js +96 -142
  139. package/dist/geometry/primitive-utils.js +30 -1
  140. package/dist/index.js +20 -16
  141. package/dist/lib/clip-space.js +50 -1
  142. package/dist/lib/model-utils.js +97 -29
  143. package/dist/lib/model.d.ts +1 -1
  144. package/dist/lib/model.d.ts.map +1 -1
  145. package/dist/lib/model.js +122 -166
  146. package/dist/lib/pipeline-factory.d.ts +3 -3
  147. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  148. package/dist/lib/pipeline-factory.js +136 -204
  149. package/package.json +12 -11
  150. package/dist/animation/key-frames.js.map +0 -1
  151. package/dist/animation/timeline.js.map +0 -1
  152. package/dist/animation-loop/animation-loop.js.map +0 -1
  153. package/dist/animation-loop/animation-props.js.map +0 -1
  154. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  155. package/dist/animation-loop/render-loop.js.map +0 -1
  156. package/dist/bundle.js.map +0 -1
  157. package/dist/geometries/cone-geometry.js.map +0 -1
  158. package/dist/geometries/cube-geometry.js.map +0 -1
  159. package/dist/geometries/cylinder-geometry.js.map +0 -1
  160. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  161. package/dist/geometries/plane-geometry.js.map +0 -1
  162. package/dist/geometries/sphere-geometry.js.map +0 -1
  163. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  164. package/dist/geometry/geometry-table.js.map +0 -1
  165. package/dist/geometry/geometry-utils.js.map +0 -1
  166. package/dist/geometry/geometry.js.map +0 -1
  167. package/dist/geometry/primitive-utils.js.map +0 -1
  168. package/dist/index.js.map +0 -1
  169. package/dist/lib/clip-space.js.map +0 -1
  170. package/dist/lib/model-utils.js.map +0 -1
  171. package/dist/lib/model.js.map +0 -1
  172. package/dist/lib/pipeline-factory.js.map +0 -1
@@ -1,152 +1,106 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import { uid, assert } from '@luma.gl/api';
3
2
  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;
3
+ class Geometry {
4
+ constructor(props = {}) {
5
+ this.userData = {};
6
+ /** @deprecated */
7
+ this.drawMode = GL.TRIANGLES;
8
+ const { id = uid('geometry'), drawMode = GL.TRIANGLES, attributes = {}, indices = null, vertexCount = null } = props;
9
+ this.id = id;
10
+ this.drawMode = drawMode;
11
+ this.topology = props.topology || convertToTopology(drawMode);
12
+ if (indices) {
13
+ // @ts-expect-error
14
+ this.indices = ArrayBuffer.isView(indices) ? { value: indices, size: 1 } : indices;
15
+ }
16
+ // @ts-expect-error
17
+ this.attributes = {};
18
+ for (const [attributeName, attributeValue] of Object.entries(attributes)) {
19
+ // Wrap "unwrapped" arrays and try to autodetect their type
20
+ const attribute = ArrayBuffer.isView(attributeValue) ? { value: attributeValue } : attributeValue;
21
+ assert(ArrayBuffer.isView(attribute.value), `${this._print(attributeName)}: must be typed array or object with value as typed array`);
22
+ if ((attributeName === 'POSITION' || attributeName === 'positions') && !attribute.size) {
23
+ attribute.size = 3;
24
+ }
25
+ // Move indices to separate field
26
+ if (attributeName === 'indices') {
27
+ assert(!this.indices);
28
+ // @ts-expect-error
29
+ this.indices = attribute;
30
+ }
31
+ else {
32
+ this.attributes[attributeName] = attribute;
33
+ }
34
+ }
35
+ // @ts-expect-error
36
+ if (this.indices && this.indices.isIndexed !== undefined) {
37
+ this.indices = Object.assign({}, this.indices);
38
+ // @ts-expect-error
39
+ delete this.indices.isIndexed;
40
+ }
41
+ this.vertexCount = vertexCount || this._calculateVertexCount(this.attributes, this.indices);
36
42
  }
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
- }
43
+ /** @deprecated Use string topology constants instead */
44
+ get mode() {
45
+ return this.drawMode;
56
46
  }
57
-
58
- if (this.indices && this.indices.isIndexed !== undefined) {
59
- this.indices = Object.assign({}, this.indices);
60
- delete this.indices.isIndexed;
47
+ getVertexCount() {
48
+ return this.vertexCount;
61
49
  }
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
- getAttributes() {
75
- return this.indices ? {
76
- indices: this.indices,
77
- ...this.attributes
78
- } : this.attributes;
79
- }
80
-
81
- _print(attributeName) {
82
- return "Geometry ".concat(this.id, " attribute ").concat(attributeName);
83
- }
84
-
85
- _setAttributes(attributes, indices) {
86
- return this;
87
- }
88
-
89
- _calculateVertexCount(attributes, indices) {
90
- if (indices) {
91
- return indices.value.length;
50
+ // Return an object with all attributes plus indices added as a field.
51
+ getAttributes() {
52
+ // @ts-expect-error Geometry types are a mess
53
+ return this.indices ? { indices: this.indices, ...this.attributes } : this.attributes;
92
54
  }
93
-
94
- let vertexCount = Infinity;
95
-
96
- for (const attributeName in attributes) {
97
- const attribute = attributes[attributeName];
98
- const {
99
- value,
100
- size,
101
- constant
102
- } = attribute;
103
-
104
- if (!constant && value && size >= 1) {
105
- vertexCount = Math.min(vertexCount, value.length / size);
106
- }
55
+ // PRIVATE
56
+ _print(attributeName) {
57
+ return `Geometry ${this.id} attribute ${attributeName}`;
58
+ }
59
+ // GeometryAttribute
60
+ // value: typed array
61
+ // type: indices, vertices, uvs
62
+ // size: elements per vertex
63
+ // target: WebGL buffer type (string or constant)
64
+ _setAttributes(attributes, indices) {
65
+ return this;
66
+ }
67
+ _calculateVertexCount(attributes, indices) {
68
+ if (indices) {
69
+ return indices.value.length;
70
+ }
71
+ let vertexCount = Infinity;
72
+ for (const attributeName in attributes) {
73
+ const attribute = attributes[attributeName];
74
+ const { value, size, constant } = attribute;
75
+ if (!constant && value && size >= 1) {
76
+ vertexCount = Math.min(vertexCount, value.length / size);
77
+ }
78
+ }
79
+ assert(Number.isFinite(vertexCount));
80
+ return vertexCount;
107
81
  }
108
-
109
- assert(Number.isFinite(vertexCount));
110
- return vertexCount;
111
- }
112
-
113
82
  }
114
-
115
- _defineProperty(Geometry, "DRAW_MODE", {
116
- POINTS: GL.POINTS,
117
- LINES: GL.LINES,
118
- LINE_LOOP: GL.LINE_LOOP,
119
- LINE_STRIP: GL.LINE_STRIP,
120
- TRIANGLES: GL.TRIANGLES,
121
- TRIANGLE_STRIP: GL.TRIANGLE_STRIP,
122
- TRIANGLE_FAN: GL.TRIANGLE_FAN
123
- });
124
-
83
+ /** @deprecated */
84
+ Geometry.DRAW_MODE = {
85
+ POINTS: GL.POINTS,
86
+ LINES: GL.LINES,
87
+ LINE_LOOP: GL.LINE_LOOP,
88
+ LINE_STRIP: GL.LINE_STRIP,
89
+ TRIANGLES: GL.TRIANGLES,
90
+ TRIANGLE_STRIP: GL.TRIANGLE_STRIP,
91
+ TRIANGLE_FAN: GL.TRIANGLE_FAN // draw a connected group of triangles.
92
+ };
93
+ export default Geometry;
125
94
  function convertToTopology(drawMode) {
126
- switch (drawMode) {
127
- case GL.POINTS:
128
- return 'point-list';
129
-
130
- case GL.LINES:
131
- return 'line-list';
132
-
133
- case GL.LINE_STRIP:
134
- return 'line-strip';
135
-
136
- case GL.TRIANGLES:
137
- return 'triangle-list';
138
-
139
- case GL.TRIANGLE_STRIP:
140
- return 'triangle-strip';
141
-
142
- case GL.TRIANGLE_FAN:
143
- return 'triangle-fan';
144
-
145
- case GL.LINE_LOOP:
146
- return 'line-loop';
147
-
148
- default:
149
- throw new Error(String(drawMode));
150
- }
95
+ switch (drawMode) {
96
+ case GL.POINTS: return 'point-list'; // draw single points.
97
+ case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.
98
+ case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last
99
+ case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.
100
+ case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.
101
+ case GL.TRIANGLE_FAN: return 'triangle-fan'; // draw a connected group of triangles.
102
+ case GL.LINE_LOOP: return 'line-loop'; // draw lines. Each set of two vertices is treated as a separate line segment.
103
+ default:
104
+ throw new Error(String(drawMode));
105
+ }
151
106
  }
152
- //# sourceMappingURL=geometry.js.map
@@ -1,2 +1,31 @@
1
+ "use strict";
2
+ /*
3
+ import type {GeometryTable} from './geometry-table.js';
1
4
 
2
- //# sourceMappingURL=primitive-utils.js.map
5
+ export function unpackIndexedGeometry(geometry: GeometryTable): GeometryTable {
6
+ const {indices, attributes} = geometry;
7
+ if (!indices) {
8
+ return geometry;
9
+ }
10
+
11
+ const vertexCount = indices.length;
12
+ const unpackedAttributes = {};
13
+
14
+ for (const [name, values] of Object.entries(attributes)) {
15
+ const size = {POSITION: 3, NORMAL: 3, TEX_COORD0: 2}[name];
16
+ const unpackedValues = new values.constructor(length * size);
17
+ for (let x = 0; x < vertexCount; ++x) {
18
+ const index = indices[x];
19
+ for (let i = 0; i < size; i++) {
20
+ unpackedValues[x * size + i] = values[index * size + i];
21
+ }
22
+ }
23
+ unpackedAttributes[name] = unpackedValues;
24
+ }
25
+
26
+ return {
27
+ length,
28
+ attributes: unpackedAttributes
29
+ };
30
+ }
31
+ */
package/dist/index.js CHANGED
@@ -1,16 +1,20 @@
1
- export { Timeline } from './animation/timeline';
2
- export { KeyFrames } from './animation/key-frames';
3
- export { AnimationLoopTemplate } from './animation-loop/render-loop';
4
- export { AnimationLoop } from './animation-loop/animation-loop';
5
- export { makeAnimationLoop } from './animation-loop/make-animation-loop';
6
- export { Model } from './lib/model';
7
- export { PipelineFactory } from './lib/pipeline-factory';
8
- export { default as Geometry } from './geometry/geometry';
9
- export { ConeGeometry } from './geometries/cone-geometry';
10
- export { CubeGeometry } from './geometries/cube-geometry';
11
- export { CylinderGeometry } from './geometries/cylinder-geometry';
12
- export { IcoSphereGeometry } from './geometries/ico-sphere-geometry';
13
- export { PlaneGeometry } from './geometries/plane-geometry';
14
- export { SphereGeometry } from './geometries/sphere-geometry';
15
- export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry';
16
- //# sourceMappingURL=index.js.map
1
+ // luma.gl Engine API
2
+ // Animation
3
+ export { Timeline } from './animation/timeline.js';
4
+ export { KeyFrames } from './animation/key-frames.js';
5
+ export { AnimationLoopTemplate } from './animation-loop/render-loop.js';
6
+ export { AnimationLoop } from './animation-loop/animation-loop.js';
7
+ export { makeAnimationLoop } from './animation-loop/make-animation-loop.js';
8
+ export { Model } from './lib/model.js';
9
+ export { PipelineFactory } from './lib/pipeline-factory.js';
10
+ // Utils
11
+ // export {default as ClipSpace} from './lib/clip-space.js';
12
+ // Geometries
13
+ export { default as Geometry } from './geometry/geometry.js';
14
+ export { ConeGeometry } from './geometries/cone-geometry.js';
15
+ export { CubeGeometry } from './geometries/cube-geometry.js';
16
+ export { CylinderGeometry } from './geometries/cylinder-geometry.js';
17
+ export { IcoSphereGeometry } from './geometries/ico-sphere-geometry.js';
18
+ export { PlaneGeometry } from './geometries/plane-geometry.js';
19
+ export { SphereGeometry } from './geometries/sphere-geometry.js';
20
+ export { TruncatedConeGeometry } from './geometries/truncated-cone-geometry.js';
@@ -1,2 +1,51 @@
1
+ "use strict";
2
+ // ClipSpace
3
+ /*
4
+ import GL from '@luma.gl/constants';
5
+ import Model, {ModelProps} from './model.js';
6
+ import Geometry from '../geometry/geometry.js';
1
7
 
2
- //# sourceMappingURL=clip-space.js.map
8
+ const CLIPSPACE_VERTEX_SHADER = glsl`\
9
+ attribute vec2 aClipSpacePosition;
10
+ attribute vec2 aTexCoord;
11
+ attribute vec2 aCoordinate;
12
+
13
+ varying vec2 position;
14
+ varying vec2 coordinate;
15
+ varying vec2 uv;
16
+
17
+ void main(void) {
18
+ gl_Position = vec4(aClipSpacePosition, 0., 1.);
19
+ position = aClipSpacePosition;
20
+ coordinate = aCoordinate;
21
+ uv = aTexCoord;
22
+ }
23
+ `;
24
+
25
+ /* eslint-disable indent, no-multi-spaces *
26
+ const POSITIONS = [-1, -1, 1, -1, -1, 1, 1, 1];
27
+
28
+
29
+ export default class ClipSpace extends Model {
30
+ constructor(gl: WebGLRenderingContext, opts?: ModelProps) {
31
+ const TEX_COORDS = POSITIONS.map((coord) => (coord === -1 ? 0 : coord));
32
+
33
+ super(
34
+ gl,
35
+ Object.assign({}, opts, {
36
+ vs: CLIPSPACE_VERTEX_SHADER,
37
+ geometry: new Geometry({
38
+ drawMode: GL.TRIANGLE_STRIP,
39
+ vertexCount: 4,
40
+ attributes: {
41
+ aClipSpacePosition: {size: 2, value: new Float32Array(POSITIONS)},
42
+ aTexCoord: {size: 2, value: new Float32Array(TEX_COORDS)},
43
+ aCoordinate: {size: 2, value: new Float32Array(TEX_COORDS)}
44
+ }
45
+ })
46
+ })
47
+ );
48
+ this.setVertexCount(4);
49
+ }
50
+ }
51
+ */
@@ -1,45 +1,113 @@
1
1
  import { Buffer, assert } from '@luma.gl/api';
2
+ // Support for mapping new geometries with glTF attribute names to "classic" luma.gl shader names
2
3
  const GLTF_TO_LUMA_ATTRIBUTE_MAP = {
3
- POSITION: 'positions',
4
- NORMAL: 'normals',
5
- COLOR_0: 'colors',
6
- TEXCOORD_0: 'texCoords',
7
- TEXCOORD_1: 'texCoords1',
8
- TEXCOORD_2: 'texCoords2'
4
+ POSITION: 'positions',
5
+ NORMAL: 'normals',
6
+ COLOR_0: 'colors',
7
+ TEXCOORD_0: 'texCoords',
8
+ TEXCOORD_1: 'texCoords1',
9
+ TEXCOORD_2: 'texCoords2'
9
10
  };
10
- export function getIndexBufferFromGeometry(device, geometry) {
11
- if (!geometry.indices) {
12
- return undefined;
13
- }
14
-
15
- const data = geometry.indices.value || geometry.indices;
16
- assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
17
- return device.createBuffer({
18
- usage: Buffer.INDEX,
19
- data
20
- });
21
- }
22
- export function getAttributeBuffersFromGeometry(device, geometry) {
23
- const buffers = {};
11
+ /*
12
+ export function getAttributeLayoutsFromGeometry(geometry: Geometry) {
13
+ const layouts: Record<string, {}> = {};
14
+ let indices = geometry.indices;
24
15
 
25
16
  for (const [name, attribute] of Object.entries(geometry.attributes)) {
26
17
  const remappedName = mapAttributeName(name);
27
18
 
28
- if (attribute !== null && attribute !== void 0 && attribute.constant) {
19
+ if (attribute.constant) {
29
20
  throw new Error('constant attributes not supported');
30
21
  } else {
31
- const typedArray = attribute === null || attribute === void 0 ? void 0 : attribute.value;
32
- buffers[remappedName] = device.createBuffer({
33
- data: typedArray,
34
- id: "".concat(remappedName, "-buffer")
35
- });
22
+ const typedArray = attribute.value;
23
+ // Create accessor by copying the attribute and removing `value``
24
+ const accessor = {...attribute};
25
+ delete accessor.value;
26
+ buffers[remappedName] = [device.createBuffer(typedArray), accessor];
27
+
28
+ inferAttributeAccessor(name, accessor);
36
29
  }
37
30
  }
31
+ }
32
+
33
+ export class Table {
34
+ length: number;
35
+ // columns: Record<string, TypedArray> = {};
36
+ }
38
37
 
39
- return buffers;
38
+ export class GPUTable {
39
+ length: number;
40
+ columns: Record<string, Buffer> = {};
40
41
  }
41
42
 
43
+ export function convertTableToGPUTable(table: Table) {
44
+ // for (const ) {}
45
+ }
46
+
47
+ export function renameTableColumns(table: Table, map: (name: string) => string) {
48
+ const newColumns = table.columns.reduce()
49
+ table.clone();
50
+ }
51
+ */
52
+ export function getIndexBufferFromGeometry(device, geometry) {
53
+ if (!geometry.indices) {
54
+ return undefined;
55
+ }
56
+ // @ts-expect-error
57
+ const data = geometry.indices.value || geometry.indices;
58
+ assert(data instanceof Uint16Array || data instanceof Uint32Array, 'attribute array for "indices" must be of integer type');
59
+ return device.createBuffer({ usage: Buffer.INDEX, data });
60
+ }
61
+ export function getAttributeBuffersFromGeometry(device, geometry) {
62
+ const buffers = {};
63
+ for (const [name, attribute] of Object.entries(geometry.attributes)) {
64
+ const remappedName = mapAttributeName(name);
65
+ if (attribute?.constant) {
66
+ throw new Error('constant attributes not supported');
67
+ }
68
+ else {
69
+ const typedArray = attribute?.value;
70
+ buffers[remappedName] = device.createBuffer({ data: typedArray, id: `${remappedName}-buffer` });
71
+ }
72
+ }
73
+ return buffers;
74
+ }
42
75
  function mapAttributeName(name) {
43
- return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
76
+ // @ts-ignore-error
77
+ return GLTF_TO_LUMA_ATTRIBUTE_MAP[name] || name;
78
+ }
79
+ /*
80
+ // Check for well known attribute names
81
+ // eslint-disable-next-line complexity
82
+ export function inferAttributeAccessor(attributeName, attribute) {
83
+ let category;
84
+ switch (attributeName) {
85
+ case 'texCoords':
86
+ case 'texCoord1':
87
+ case 'texCoord2':
88
+ case 'texCoord3':
89
+ category = 'uvs';
90
+ break;
91
+ case 'vertices':
92
+ case 'positions':
93
+ case 'normals':
94
+ case 'pickingColors':
95
+ category = 'vectors';
96
+ break;
97
+ default:
98
+ }
99
+
100
+ // Check for categorys
101
+ switch (category) {
102
+ case 'vectors':
103
+ attribute.size = attribute.size || 3;
104
+ break;
105
+ case 'uvs':
106
+ attribute.size = attribute.size || 2;
107
+ break;
108
+ default:
109
+ }
110
+
111
+ assert(Number.isFinite(attribute.size), `attribute ${attributeName} needs size`);
44
112
  }
45
- //# sourceMappingURL=model-utils.js.map
113
+ */
@@ -2,7 +2,7 @@ import type { Device, Buffer, RenderPipelineProps, RenderPass, Binding, Primitiv
2
2
  import { RenderPipeline } from '@luma.gl/api';
3
3
  import type { ShaderModule } from '@luma.gl/shadertools';
4
4
  import type Geometry from '../geometry/geometry';
5
- export declare type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
5
+ export type ModelProps = Omit<RenderPipelineProps, 'vs' | 'fs'> & {
6
6
  vs?: {
7
7
  glsl?: string;
8
8
  wgsl?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/lib/model.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,MAAM,EAAE,mBAAmB,EAAE,UAAU,EAAE,OAAO,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAIjD,oBAAY,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,IAAI,GAAG,IAAI,CAAC,GAAG;IAEhE,EAAE,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACpD,EAAE,CAAC,EAAE;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,GAAG,IAAI,CAAC;IACpD,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM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