@luma.gl/engine 8.6.0-alpha.4 → 9.0.0-alpha.4

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 (129) hide show
  1. package/dist/animation/key-frames.d.ts +1 -0
  2. package/dist/animation/key-frames.d.ts.map +1 -1
  3. package/dist/animation/key-frames.js.map +1 -1
  4. package/dist/animation/timeline.d.ts +1 -1
  5. package/dist/animation/timeline.d.ts.map +1 -1
  6. package/dist/animation/timeline.js.map +1 -1
  7. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  8. package/dist/geometries/cone-geometry.js +1 -1
  9. package/dist/geometries/cone-geometry.js.map +1 -1
  10. package/dist/geometries/cube-geometry.d.ts +4 -0
  11. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  12. package/dist/geometries/cube-geometry.js +30 -7
  13. package/dist/geometries/cube-geometry.js.map +1 -1
  14. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  15. package/dist/geometries/cylinder-geometry.js +1 -1
  16. package/dist/geometries/cylinder-geometry.js.map +1 -1
  17. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  18. package/dist/geometries/ico-sphere-geometry.js +1 -1
  19. package/dist/geometries/ico-sphere-geometry.js.map +1 -1
  20. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  21. package/dist/geometries/plane-geometry.js +1 -1
  22. package/dist/geometries/plane-geometry.js.map +1 -1
  23. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  24. package/dist/geometries/sphere-geometry.js +1 -1
  25. package/dist/geometries/sphere-geometry.js.map +1 -1
  26. package/dist/geometries/truncated-cone-geometry.d.ts +15 -3
  27. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  28. package/dist/geometries/truncated-cone-geometry.js +29 -15
  29. package/dist/geometries/truncated-cone-geometry.js.map +1 -1
  30. package/dist/geometry/geometry-table.d.ts +15 -0
  31. package/dist/geometry/geometry-table.d.ts.map +1 -0
  32. package/dist/geometry/geometry-table.js +2 -0
  33. package/dist/{transform/transform-types.js.map → geometry/geometry-table.js.map} +1 -1
  34. package/dist/geometry/geometry-utils.js.map +1 -1
  35. package/dist/geometry/geometry.d.ts +34 -7
  36. package/dist/geometry/geometry.d.ts.map +1 -1
  37. package/dist/geometry/geometry.js +33 -11
  38. package/dist/geometry/geometry.js.map +1 -1
  39. package/dist/geometry/primitive-utils.d.ts +1 -0
  40. package/dist/geometry/primitive-utils.d.ts.map +1 -0
  41. package/dist/geometry/primitive-utils.js +2 -0
  42. package/dist/geometry/primitive-utils.js.map +1 -0
  43. package/dist/index.d.ts +3 -5
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1 -4
  46. package/dist/index.js.map +1 -1
  47. package/dist/lib/animation-loop.d.ts +14 -73
  48. package/dist/lib/animation-loop.d.ts.map +1 -1
  49. package/dist/lib/animation-loop.js +39 -160
  50. package/dist/lib/animation-loop.js.map +1 -1
  51. package/dist/lib/animation-props.d.ts +24 -0
  52. package/dist/lib/animation-props.d.ts.map +1 -0
  53. package/dist/lib/animation-props.js +2 -0
  54. package/dist/lib/animation-props.js.map +1 -0
  55. package/dist/lib/clip-space.d.ts +1 -0
  56. package/dist/lib/clip-space.d.ts.map +1 -0
  57. package/dist/lib/clip-space.js +2 -0
  58. package/dist/lib/clip-space.js.map +1 -0
  59. package/dist/lib/model-utils.d.ts +4 -3
  60. package/dist/lib/model-utils.d.ts.map +1 -1
  61. package/dist/lib/model-utils.js +24 -70
  62. package/dist/lib/model-utils.js.map +1 -1
  63. package/dist/lib/model.d.ts +34 -104
  64. package/dist/lib/model.d.ts.map +1 -1
  65. package/dist/lib/model.js +108 -505
  66. package/dist/lib/model.js.map +1 -1
  67. package/dist/lib/pipeline-factory.d.ts +55 -0
  68. package/dist/lib/pipeline-factory.d.ts.map +1 -0
  69. package/dist/lib/pipeline-factory.js +191 -0
  70. package/dist/lib/pipeline-factory.js.map +1 -0
  71. package/dist/lib/render-loop.d.ts +4 -17
  72. package/dist/lib/render-loop.d.ts.map +1 -1
  73. package/dist/lib/render-loop.js +14 -21
  74. package/dist/lib/render-loop.js.map +1 -1
  75. package/package.json +5 -5
  76. package/src/animation/key-frames.ts +1 -0
  77. package/src/animation/timeline.ts +1 -1
  78. package/src/geometries/cone-geometry.ts +1 -1
  79. package/src/geometries/cube-geometry.ts +159 -8
  80. package/src/geometries/cylinder-geometry.ts +1 -1
  81. package/src/geometries/ico-sphere-geometry.ts +1 -1
  82. package/src/geometries/plane-geometry.ts +1 -1
  83. package/src/geometries/sphere-geometry.ts +2 -2
  84. package/src/geometries/truncated-cone-geometry.ts +30 -12
  85. package/src/geometry/geometry-table.ts +16 -0
  86. package/src/geometry/geometry-utils.ts +1 -1
  87. package/src/geometry/geometry.ts +58 -13
  88. package/src/geometry/primitive-utils.ts +30 -0
  89. package/src/index.ts +7 -8
  90. package/src/lib/animation-loop.ts +85 -274
  91. package/src/lib/animation-props.ts +31 -0
  92. package/src/{utils → lib}/clip-space.ts +5 -2
  93. package/src/lib/model-utils.ts +60 -32
  94. package/src/lib/model.ts +126 -642
  95. package/src/lib/pipeline-factory.ts +225 -0
  96. package/src/lib/render-loop.ts +21 -19
  97. package/dist/lib/program-manager.d.ts +0 -39
  98. package/dist/lib/program-manager.d.ts.map +0 -1
  99. package/dist/lib/program-manager.js +0 -175
  100. package/dist/lib/program-manager.js.map +0 -1
  101. package/dist/transform/buffer-transform.d.ts +0 -36
  102. package/dist/transform/buffer-transform.d.ts.map +0 -1
  103. package/dist/transform/buffer-transform.js +0 -255
  104. package/dist/transform/buffer-transform.js.map +0 -1
  105. package/dist/transform/texture-transform.d.ts +0 -57
  106. package/dist/transform/texture-transform.d.ts.map +0 -1
  107. package/dist/transform/texture-transform.js +0 -412
  108. package/dist/transform/texture-transform.js.map +0 -1
  109. package/dist/transform/transform-shader-utils.d.ts +0 -26
  110. package/dist/transform/transform-shader-utils.d.ts.map +0 -1
  111. package/dist/transform/transform-shader-utils.js +0 -149
  112. package/dist/transform/transform-shader-utils.js.map +0 -1
  113. package/dist/transform/transform-types.d.ts +0 -44
  114. package/dist/transform/transform-types.d.ts.map +0 -1
  115. package/dist/transform/transform-types.js +0 -2
  116. package/dist/transform/transform.d.ts +0 -47
  117. package/dist/transform/transform.d.ts.map +0 -1
  118. package/dist/transform/transform.js +0 -198
  119. package/dist/transform/transform.js.map +0 -1
  120. package/dist/utils/clip-space.d.ts +0 -5
  121. package/dist/utils/clip-space.d.ts.map +0 -1
  122. package/dist/utils/clip-space.js +0 -34
  123. package/dist/utils/clip-space.js.map +0 -1
  124. package/src/lib/program-manager.ts +0 -187
  125. package/src/transform/buffer-transform.ts +0 -214
  126. package/src/transform/texture-transform.ts +0 -344
  127. package/src/transform/transform-shader-utils.ts +0 -169
  128. package/src/transform/transform-types.ts +0 -42
  129. package/src/transform/transform.ts +0 -189
@@ -1,19 +1,25 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import Geometry from '../geometry/geometry';
2
- import {uid} from '@luma.gl/webgl';
3
+ // import type {GeometryType} from '../geometry/geometry-type';
3
4
 
4
5
  export type CubeGeometryProps = {
5
6
  id?: string;
6
- attributes?
7
+ indices?: boolean;
8
+ attributes?;
7
9
  };
8
10
 
9
11
  export class CubeGeometry extends Geometry {
10
12
  constructor(props: CubeGeometryProps = {}) {
11
- const {id = uid('cube-geometry')} = props;
12
- super({
13
+ const {id = uid('cube-geometry'), indices = true} = props;
14
+ super(indices ? {
13
15
  ...props,
14
16
  id,
15
- indices: {size: 1, value: new Uint16Array(CUBE_INDICES)},
17
+ indices: {size: 1, value: CUBE_INDICES},
16
18
  attributes: {...ATTRIBUTES, ...props.attributes}
19
+ } : {
20
+ ...props,
21
+ id,
22
+ attributes: {...NON_INDEXED_ATTRIBUTES, ...props.attributes}
17
23
  });
18
24
  }
19
25
  }
@@ -67,8 +73,153 @@ const CUBE_TEX_COORDS = new Float32Array([
67
73
  0, 0, 1, 0, 1, 1, 0, 1
68
74
  ]);
69
75
 
76
+ // float4 position
77
+ // prettier-ignore
78
+ export const CUBE_NON_INDEXED_POSITIONS = new Float32Array([
79
+ 1, -1, 1, 1,
80
+ -1, -1, 1, 1,
81
+ -1, -1, -1, 1,
82
+ 1, -1, -1, 1,
83
+ 1, -1, 1, 1,
84
+ -1, -1, -1, 1,
85
+
86
+ 1, 1, 1, 1,
87
+ 1, -1, 1, 1,
88
+ 1, -1, -1, 1,
89
+ 1, 1, -1, 1,
90
+ 1, 1, 1, 1,
91
+ 1, -1, -1, 1,
92
+
93
+ -1, 1, 1, 1,
94
+ 1, 1, 1, 1,
95
+ 1, 1, -1, 1,
96
+ -1, 1, -1, 1,
97
+ -1, 1, 1, 1,
98
+ 1, 1, -1, 1,
99
+
100
+ -1, -1, 1, 1,
101
+ -1, 1, 1, 1,
102
+ -1, 1, -1, 1,
103
+ -1, -1, -1, 1,
104
+ -1, -1, 1, 1,
105
+ -1, 1, -1, 1,
106
+
107
+ 1, 1, 1, 1,
108
+ -1, 1, 1, 1,
109
+ -1, -1, 1, 1,
110
+ -1, -1, 1, 1,
111
+ 1, -1, 1, 1,
112
+ 1, 1, 1, 1,
113
+
114
+ 1, -1, -1, 1,
115
+ -1, -1, -1, 1,
116
+ -1, 1, -1, 1,
117
+ 1, 1, -1, 1,
118
+ 1, -1, -1, 1,
119
+ -1, 1, -1, 1,
120
+ ]);
121
+
122
+ // float2 uv,
123
+ // prettier-ignore
124
+ export const CUBE_NON_INDEXED_TEX_COORDS = new Float32Array([
125
+ 1, 1,
126
+ 0, 1,
127
+ 0, 0,
128
+ 1, 0,
129
+ 1, 1,
130
+ 0, 0,
131
+
132
+ 1, 1,
133
+ 0, 1,
134
+ 0, 0,
135
+ 1, 0,
136
+ 1, 1,
137
+ 0, 0,
138
+
139
+ 1, 1,
140
+ 0, 1,
141
+ 0, 0,
142
+ 1, 0,
143
+ 1, 1,
144
+ 0, 0,
145
+
146
+ 1, 1,
147
+ 0, 1,
148
+ 0, 0,
149
+ 1, 0,
150
+ 1, 1,
151
+ 0, 0,
152
+
153
+ 1, 1,
154
+ 0, 1,
155
+ 0, 0,
156
+ 0, 0,
157
+ 1, 0,
158
+ 1, 1,
159
+
160
+ 1, 1,
161
+ 0, 1,
162
+ 0, 0,
163
+ 1, 0,
164
+ 1, 1,
165
+ 0, 0,
166
+ ]);
167
+
168
+ // float4 color
169
+ // prettier-ignore
170
+ export const CUBE_NON_INDEXED_COLORS = new Float32Array([
171
+ 1, 0, 1, 1,
172
+ 0, 0, 1, 1,
173
+ 0, 0, 0, 1,
174
+ 1, 0, 0, 1,
175
+ 1, 0, 1, 1,
176
+ 0, 0, 0, 1,
177
+
178
+ 1, 1, 1, 1,
179
+ 1, 0, 1, 1,
180
+ 1, 0, 0, 1,
181
+ 1, 1, 0, 1,
182
+ 1, 1, 1, 1,
183
+ 1, 0, 0, 1,
184
+
185
+ 0, 1, 1, 1,
186
+ 1, 1, 1, 1,
187
+ 1, 1, 0, 1,
188
+ 0, 1, 0, 1,
189
+ 0, 1, 1, 1,
190
+ 1, 1, 0, 1,
191
+
192
+ 0, 0, 1, 1,
193
+ 0, 1, 1, 1,
194
+ 0, 1, 0, 1,
195
+ 0, 0, 0, 1,
196
+ 0, 0, 1, 1,
197
+ 0, 1, 0, 1,
198
+
199
+ 1, 1, 1, 1,
200
+ 0, 1, 1, 1,
201
+ 0, 0, 1, 1,
202
+ 0, 0, 1, 1,
203
+ 1, 0, 1, 1,
204
+ 1, 1, 1, 1,
205
+
206
+ 1, 0, 0, 1,
207
+ 0, 0, 0, 1,
208
+ 0, 1, 0, 1,
209
+ 1, 1, 0, 1,
210
+ 1, 0, 0, 1,
211
+ 0, 1, 0, 1,
212
+ ]);
213
+
70
214
  const ATTRIBUTES = {
71
- POSITION: {size: 3, value: new Float32Array(CUBE_POSITIONS)},
72
- NORMAL: {size: 3, value: new Float32Array(CUBE_NORMALS)},
73
- TEXCOORD_0: {size: 2, value: new Float32Array(CUBE_TEX_COORDS)}
215
+ POSITION: {size: 3, value: CUBE_POSITIONS},
216
+ NORMAL: {size: 3, value: CUBE_NORMALS},
217
+ TEXCOORD_0: {size: 2, value: CUBE_TEX_COORDS}
218
+ };
219
+
220
+ const NON_INDEXED_ATTRIBUTES = {
221
+ POSITION: {size: 4, value: CUBE_NON_INDEXED_POSITIONS},
222
+ // NORMAL: {size: 3, value: CUBE_NON_INDEXED_NORMALS},
223
+ TEXCOORD_0: {size: 2, value: CUBE_NON_INDEXED_TEX_COORDS},
224
+ COLOR_0: {size: 3, value: CUBE_NON_INDEXED_COLORS}
74
225
  };
@@ -1,5 +1,5 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import {TruncatedConeGeometry} from './truncated-cone-geometry';
2
- import {uid} from '@luma.gl/webgl';
3
3
 
4
4
  export type CylinderGeometryProps = {
5
5
  id?: string;
@@ -1,6 +1,6 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import {Vector3} from '@math.gl/core';
2
3
  import Geometry from '../geometry/geometry';
3
- import {uid} from '@luma.gl/webgl';
4
4
 
5
5
  /* eslint-disable comma-spacing, max-statements, complexity */
6
6
 
@@ -1,6 +1,6 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import Geometry from '../geometry/geometry';
2
3
  import {unpackIndexedGeometry} from '../geometry/geometry-utils';
3
- import {uid} from '@luma.gl/webgl';
4
4
 
5
5
  export type PlaneGeometryProps = {
6
6
  id?: string;
@@ -1,5 +1,5 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import Geometry from '../geometry/geometry';
2
- import {uid} from '@luma.gl/webgl';
3
3
 
4
4
  export type SphereGeometryProps = {
5
5
  id?: string;
@@ -37,7 +37,7 @@ function tesselateSphere(props: SphereGeometryProps) {
37
37
  const longRange = endLong - startLong;
38
38
  const numVertices = (nlat + 1) * (nlong + 1);
39
39
 
40
- const radius = (n1, n2, n3, u, v) => props.radius || 1;
40
+ const radius = (n1: number, n2: number, n3: number, u: number, v: number) => props.radius || 1;
41
41
 
42
42
  const positions = new Float32Array(numVertices * 3);
43
43
  const normals = new Float32Array(numVertices * 3);
@@ -1,5 +1,6 @@
1
+ import {uid} from '@luma.gl/api';
1
2
  import Geometry from '../geometry/geometry';
2
- import {uid} from '@luma.gl/webgl';
3
+ import {GeometryTable} from '../geometry/geometry-table';
3
4
 
4
5
  const INDEX_OFFSETS = {
5
6
  x: [2, 0, 1],
@@ -8,32 +9,49 @@ const INDEX_OFFSETS = {
8
9
  };
9
10
 
10
11
  export type TruncatedConeGeometryProps = {
11
- id?: string;
12
12
  topRadius?: number;
13
13
  bottomRadius?: number;
14
14
  topCap?: boolean;
15
15
  bottomCap?: boolean;
16
- attributes?
16
+ height?: number;
17
+ nradial?: number;
18
+ nvertical?: number;
19
+ verticalAxis?: 'x' | 'y' | 'z';
17
20
  };
18
21
 
19
- // Primitives inspired by TDL http://code.google.com/p/webglsamples/,
20
- // copyright 2011 Google Inc. new BSD License
21
- // (http://www.opensource.org/licenses/bsd-license.php).
22
+ /**
23
+ * Primitives inspired by TDL http://code.google.com/p/webglsamples/,
24
+ * copyright 2011 Google Inc. new BSD License
25
+ * (http://www.opensource.org/licenses/bsd-license.php).
26
+ */
27
+ export function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): GeometryTable {
28
+ const {indices, attributes} = tesselateTruncatedCone(props);
29
+ return {
30
+ length: indices.length,
31
+ indices,
32
+ attributes
33
+ };
34
+ }
35
+
22
36
  export class TruncatedConeGeometry extends Geometry {
23
- constructor(props: TruncatedConeGeometryProps = {}) {
37
+ constructor(props: TruncatedConeGeometryProps & {id?: string; attributes?} = {}) {
24
38
  const {id = uid('truncated-code-geometry')} = props;
25
39
  const {indices, attributes} = tesselateTruncatedCone(props);
26
40
  super({
27
41
  ...props,
28
42
  id,
29
43
  indices,
30
- attributes: {...attributes, ...props.attributes}
44
+ attributes: {
45
+ POSITION: {size: 3, value: attributes.POSITION},
46
+ NORMAL: {size: 3, value: attributes.NORMAL},
47
+ TEXCOORD_0: {size: 2, value: attributes.TEXCOORD_0},
48
+ ...props.attributes}
31
49
  });
32
50
  }
33
51
  }
34
52
 
35
53
  /* eslint-disable max-statements, complexity */
36
- function tesselateTruncatedCone(props) {
54
+ function tesselateTruncatedCone(props: TruncatedConeGeometryProps = {}) {
37
55
  const {
38
56
  bottomRadius = 0,
39
57
  topRadius = 0,
@@ -123,9 +141,9 @@ function tesselateTruncatedCone(props) {
123
141
  return {
124
142
  indices,
125
143
  attributes: {
126
- POSITION: {size: 3, value: positions},
127
- NORMAL: {size: 3, value: normals},
128
- TEXCOORD_0: {size: 2, value: texCoords}
144
+ POSITION: positions,
145
+ NORMAL: normals,
146
+ TEXCOORD_0: texCoords
129
147
  }
130
148
  };
131
149
  }
@@ -0,0 +1,16 @@
1
+ // luma.gl, MIT license
2
+ import type {TypedArray, VertexFormat} from '@luma.gl/api';
3
+
4
+ /** Holds one geometry */
5
+ export type GeometryTable = {
6
+ length: number;
7
+ schema?: Record<string, VertexFormat>;
8
+ attributes: {
9
+ POSITION: TypedArray,
10
+ NORMAL: TypedArray,
11
+ TEXCOORD_0: TypedArray,
12
+ [key: string]: TypedArray,
13
+ };
14
+ indices?: Uint16Array | Uint32Array;
15
+ topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
16
+ }
@@ -1,4 +1,4 @@
1
- import type Geometry from './geometry';
1
+ // import type Geometry from './geometry';
2
2
 
3
3
  export function unpackIndexedGeometry(geometry) {
4
4
  const {indices, attributes} = geometry;
@@ -1,9 +1,10 @@
1
1
  // luma.gl, MIT license
2
+ import type {TypedArray} from '@luma.gl/api';
3
+ import {uid, assert} from '@luma.gl/api';
2
4
  import GL from '@luma.gl/constants';
3
- import {uid, assert} from '@luma.gl/webgl';
4
5
 
5
6
  /**
6
- * Rendering primitives - "opology" specifies how to extract primitives from vertices.
7
+ * Rendering primitives - "topology" specifies how to extract primitives from vertices.
7
8
  */
8
9
  export type Topology =
9
10
  GL.POINTS | // draw single points.
@@ -17,10 +18,21 @@ export type Topology =
17
18
 
18
19
  export type GeometryProps = {
19
20
  id?: string;
20
- drawMode?: Topology,
21
21
  attributes?: {},
22
22
  indices?;
23
- vertexCount?: number
23
+ vertexCount?: number;
24
+ /** Determines how vertices are read from the 'vertex' attributes */
25
+ topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
26
+ /** @deprecated */
27
+ drawMode?: Topology;
28
+ };
29
+
30
+ type GeometryAttributes = {
31
+ POSITION: {size: number, value: TypedArray, [key: string]: any},
32
+ NORMAL: {size: number, value: TypedArray, [key: string]: any},
33
+ TEXCOORD_0: {size: number, value: TypedArray, [key: string]: any},
34
+ COLOR_0?: {size: number, value: TypedArray, [key: string]: any},
35
+ indices?: {size?: number, value: Uint32Array | Uint16Array};
24
36
  };
25
37
 
26
38
  export default class Geometry {
@@ -36,12 +48,21 @@ export default class Geometry {
36
48
  };
37
49
 
38
50
  readonly id: string;
51
+ userData: Record<string, any> = {};
52
+
53
+ /** Determines how vertices are read from the 'vertex' attributes */
54
+ topology?: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
55
+ /** @deprecated */
39
56
  readonly drawMode: Topology = GL.TRIANGLES;
40
57
 
41
- vertexCount: number;
42
- attributes = {};
43
- indices;
44
- userData: Record<string, any> = {};
58
+ readonly vertexCount: number;
59
+ readonly attributes: {
60
+ POSITION: {size: number, value: TypedArray, [key: string]: any},
61
+ NORMAL: {size: number, value: TypedArray, [key: string]: any},
62
+ TEXCOORD_0: {size: number, value: TypedArray, [key: string]: any},
63
+ COLOR_0?: {size: number, value: TypedArray, [key: string]: any},
64
+ };
65
+ readonly indices?: Uint16Array | Uint32Array;
45
66
 
46
67
  constructor(props: GeometryProps = {}) {
47
68
  const {
@@ -54,6 +75,7 @@ export default class Geometry {
54
75
 
55
76
  this.id = id;
56
77
  this.drawMode = drawMode;
78
+ this.topology = props.topology || convertToTopology(drawMode);
57
79
 
58
80
  this._setAttributes(attributes, indices);
59
81
 
@@ -69,9 +91,9 @@ export default class Geometry {
69
91
  }
70
92
 
71
93
  // Return an object with all attributes plus indices added as a field.
72
- getAttributes() {
73
- return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;
74
- }
94
+ // getAttributes(): GeometryAttributes {
95
+ // return this.indices ? {indices: this.indices, ...this.attributes} : this.attributes;
96
+ // }
75
97
 
76
98
  // PRIVATE
77
99
 
@@ -86,9 +108,13 @@ export default class Geometry {
86
108
  // target: WebGL buffer type (string or constant)
87
109
  _setAttributes(attributes, indices): this {
88
110
  if (indices) {
111
+ // @ts-expect-error
89
112
  this.indices = ArrayBuffer.isView(indices) ? {value: indices, size: 1} : indices;
90
113
  }
91
114
 
115
+ // @ts-expect-error
116
+ this.attributes = {};
117
+
92
118
  for (const attributeName in attributes) {
93
119
  let attribute = attributes[attributeName];
94
120
 
@@ -107,14 +133,18 @@ export default class Geometry {
107
133
  // Move indices to separate field
108
134
  if (attributeName === 'indices') {
109
135
  assert(!this.indices);
110
- this.indices = attribute;
136
+ // @ts-expect-error
137
+ this.indices = attribute;
111
138
  } else {
112
139
  this.attributes[attributeName] = attribute;
113
140
  }
114
141
  }
115
142
 
116
- if (this.indices && this.indices.isIndexed !== undefined) {
143
+ // @ts-expect-error
144
+ if (this.indices && this.indices.isIndexed !== undefined) {
145
+ // @ts-expect-error
117
146
  this.indices = Object.assign({}, this.indices);
147
+ // @ts-expect-error
118
148
  delete this.indices.isIndexed;
119
149
  }
120
150
 
@@ -138,3 +168,18 @@ export default class Geometry {
138
168
  return vertexCount;
139
169
  }
140
170
  }
171
+
172
+ function convertToTopology(drawMode: GL): 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip' {
173
+ switch (drawMode) {
174
+ case GL.POINTS: return 'point-list'; // draw single points.
175
+ case GL.LINES: return 'line-list'; // draw lines. Each vertex connects to the one after it.
176
+ case GL.LINE_STRIP: return 'line-strip'; // draw a connected group of line segments from the first vertex to the last
177
+ case GL.TRIANGLES: return 'triangle-list'; // draw triangles. Each set of three vertices creates a separate triangle.
178
+ case GL.TRIANGLE_STRIP: return 'triangle-strip'; // draw a connected group of triangles.
179
+
180
+ case GL.TRIANGLE_FAN: // draw a connected group of triangles.
181
+ case GL.LINE_LOOP: // draw lines. Each set of two vertices is treated as a separate line segment.
182
+ default:
183
+ throw new Error(String(drawMode));
184
+ }
185
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ import type {GeometryTable} from './geometry-table';
3
+
4
+ export function unpackIndexedGeometry(geometry: GeometryTable): GeometryTable {
5
+ const {indices, attributes} = geometry;
6
+ if (!indices) {
7
+ return geometry;
8
+ }
9
+
10
+ const vertexCount = indices.length;
11
+ const unpackedAttributes = {};
12
+
13
+ for (const [name, values] of Object.entries(attributes)) {
14
+ const size = {POSITION: 3, NORMAL: 3, TEX_COORD0: 2}[name];
15
+ const unpackedValues = new values.constructor(length * size);
16
+ for (let x = 0; x < vertexCount; ++x) {
17
+ const index = indices[x];
18
+ for (let i = 0; i < size; i++) {
19
+ unpackedValues[x * size + i] = values[index * size + i];
20
+ }
21
+ }
22
+ unpackedAttributes[name] = unpackedValues;
23
+ }
24
+
25
+ return {
26
+ length,
27
+ attributes: unpackedAttributes
28
+ };
29
+ }
30
+ */
package/src/index.ts CHANGED
@@ -1,12 +1,13 @@
1
- // CORE
2
- export type {AnimationLoopProps, AnimationProps} from './lib/animation-loop';
3
- export {default as AnimationLoop} from './lib/animation-loop';
1
+ // luma.gl Engine API
2
+ export type {AnimationProps} from './lib/animation-props';
4
3
  export {RenderLoop} from './lib/render-loop';
5
-
6
4
  export type {ModelProps} from './lib/model';
7
5
  export {default as Model} from './lib/model';
8
- export {default as ProgramManager} from './lib/program-manager';
9
- export {default as Transform} from './transform/transform';
6
+ export type {AnimationLoopProps} from './lib/animation-loop';
7
+ export {default as AnimationLoop} from './lib/animation-loop';
8
+
9
+ // Utils
10
+ // export {default as ClipSpace} from './lib/clip-space';
10
11
 
11
12
  // Geometries
12
13
  export {default as Geometry} from './geometry/geometry';
@@ -31,5 +32,3 @@ export {TruncatedConeGeometry} from './geometries/truncated-cone-geometry';
31
32
  export {Timeline} from './animation/timeline';
32
33
  export {KeyFrames} from './animation/key-frames';
33
34
 
34
- // Utils
35
- export {default as ClipSpace} from './utils/clip-space';