@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,142 +1,108 @@
1
- import { uid } from '@luma.gl/api';
2
- import Geometry from '../geometry/geometry';
1
+ import { uid } from '@luma.gl/core';
2
+ import { Geometry } from "../geometry/geometry.js";
3
3
  const INDEX_OFFSETS = {
4
- x: [2, 0, 1],
5
- y: [0, 1, 2],
6
- z: [1, 2, 0]
4
+ x: [2, 0, 1],
5
+ y: [0, 1, 2],
6
+ z: [1, 2, 0]
7
7
  };
8
- export function makeTruncatedConeGeometry(props) {
9
- const {
10
- indices,
11
- attributes
12
- } = tesselateTruncatedCone(props);
13
- return {
14
- length: indices.length,
15
- indices,
16
- attributes
17
- };
18
- }
8
+ /**
9
+ * Primitives inspired by TDL http://code.google.com/p/webglsamples/,
10
+ * copyright 2011 Google Inc. new BSD License
11
+ * (http://www.opensource.org/licenses/bsd-license.php).
12
+ */
19
13
  export class TruncatedConeGeometry extends Geometry {
20
- constructor(props = {}) {
21
- const {
22
- id = uid('truncated-code-geometry')
23
- } = props;
24
- const {
25
- indices,
26
- attributes
27
- } = tesselateTruncatedCone(props);
28
- super({ ...props,
29
- id,
30
- indices,
31
- attributes: {
32
- POSITION: {
33
- size: 3,
34
- value: attributes.POSITION
35
- },
36
- NORMAL: {
37
- size: 3,
38
- value: attributes.NORMAL
39
- },
40
- TEXCOORD_0: {
41
- size: 2,
42
- value: attributes.TEXCOORD_0
43
- },
44
- ...props.attributes
45
- }
46
- });
47
- }
48
-
14
+ constructor(props = {}) {
15
+ const { id = uid('truncated-code-geometry') } = props;
16
+ const { indices, attributes } = tesselateTruncatedCone(props);
17
+ super({
18
+ ...props,
19
+ id,
20
+ topology: 'triangle-list',
21
+ indices,
22
+ attributes: {
23
+ POSITION: { size: 3, value: attributes.POSITION },
24
+ NORMAL: { size: 3, value: attributes.NORMAL },
25
+ TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 },
26
+ ...props.attributes
27
+ }
28
+ });
29
+ }
49
30
  }
50
-
31
+ /* eslint-disable max-statements, complexity */
51
32
  function tesselateTruncatedCone(props = {}) {
52
- const {
53
- bottomRadius = 0,
54
- topRadius = 0,
55
- height = 1,
56
- nradial = 10,
57
- nvertical = 10,
58
- verticalAxis = 'y',
59
- topCap = false,
60
- bottomCap = false
61
- } = props;
62
- const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
63
- const numVertices = (nradial + 1) * (nvertical + 1 + extra);
64
- const slant = Math.atan2(bottomRadius - topRadius, height);
65
- const msin = Math.sin;
66
- const mcos = Math.cos;
67
- const mpi = Math.PI;
68
- const cosSlant = mcos(slant);
69
- const sinSlant = msin(slant);
70
- const start = topCap ? -2 : 0;
71
- const end = nvertical + (bottomCap ? 2 : 0);
72
- const vertsAroundEdge = nradial + 1;
73
- const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
74
- const indexOffset = INDEX_OFFSETS[verticalAxis];
75
- const positions = new Float32Array(numVertices * 3);
76
- const normals = new Float32Array(numVertices * 3);
77
- const texCoords = new Float32Array(numVertices * 2);
78
- let i3 = 0;
79
- let i2 = 0;
80
-
81
- for (let i = start; i <= end; i++) {
82
- let v = i / nvertical;
83
- let y = height * v;
84
- let ringRadius;
85
-
86
- if (i < 0) {
87
- y = 0;
88
- v = 1;
89
- ringRadius = bottomRadius;
90
- } else if (i > nvertical) {
91
- y = height;
92
- v = 1;
93
- ringRadius = topRadius;
94
- } else {
95
- ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
96
- }
97
-
98
- if (i === -2 || i === nvertical + 2) {
99
- ringRadius = 0;
100
- v = 0;
101
- }
102
-
103
- y -= height / 2;
104
-
105
- for (let j = 0; j < vertsAroundEdge; j++) {
106
- const sin = msin(j * mpi * 2 / nradial);
107
- const cos = mcos(j * mpi * 2 / nradial);
108
- positions[i3 + indexOffset[0]] = sin * ringRadius;
109
- positions[i3 + indexOffset[1]] = y;
110
- positions[i3 + indexOffset[2]] = cos * ringRadius;
111
- normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
112
- normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
113
- normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
114
- texCoords[i2 + 0] = j / nradial;
115
- texCoords[i2 + 1] = v;
116
- i2 += 2;
117
- i3 += 3;
118
- }
119
- }
120
-
121
- for (let i = 0; i < nvertical + extra; i++) {
122
- for (let j = 0; j < nradial; j++) {
123
- const index = (i * nradial + j) * 6;
124
- indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
125
- indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
126
- indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
127
- indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
128
- indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
129
- indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
33
+ const { bottomRadius = 0, topRadius = 0, height = 1, nradial = 10, nvertical = 10, verticalAxis = 'y', topCap = false, bottomCap = false } = props;
34
+ const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
35
+ const numVertices = (nradial + 1) * (nvertical + 1 + extra);
36
+ const slant = Math.atan2(bottomRadius - topRadius, height);
37
+ const msin = Math.sin;
38
+ const mcos = Math.cos;
39
+ const mpi = Math.PI;
40
+ const cosSlant = mcos(slant);
41
+ const sinSlant = msin(slant);
42
+ const start = topCap ? -2 : 0;
43
+ const end = nvertical + (bottomCap ? 2 : 0);
44
+ const vertsAroundEdge = nradial + 1;
45
+ const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
46
+ const indexOffset = INDEX_OFFSETS[verticalAxis];
47
+ const positions = new Float32Array(numVertices * 3);
48
+ const normals = new Float32Array(numVertices * 3);
49
+ const texCoords = new Float32Array(numVertices * 2);
50
+ let i3 = 0;
51
+ let i2 = 0;
52
+ for (let i = start; i <= end; i++) {
53
+ let v = i / nvertical;
54
+ let y = height * v;
55
+ let ringRadius;
56
+ if (i < 0) {
57
+ y = 0;
58
+ v = 1;
59
+ ringRadius = bottomRadius;
60
+ }
61
+ else if (i > nvertical) {
62
+ y = height;
63
+ v = 1;
64
+ ringRadius = topRadius;
65
+ }
66
+ else {
67
+ ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
68
+ }
69
+ if (i === -2 || i === nvertical + 2) {
70
+ ringRadius = 0;
71
+ v = 0;
72
+ }
73
+ y -= height / 2;
74
+ for (let j = 0; j < vertsAroundEdge; j++) {
75
+ const sin = msin((j * mpi * 2) / nradial);
76
+ const cos = mcos((j * mpi * 2) / nradial);
77
+ positions[i3 + indexOffset[0]] = sin * ringRadius;
78
+ positions[i3 + indexOffset[1]] = y;
79
+ positions[i3 + indexOffset[2]] = cos * ringRadius;
80
+ normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
81
+ normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
82
+ normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
83
+ texCoords[i2 + 0] = j / nradial;
84
+ texCoords[i2 + 1] = v;
85
+ i2 += 2;
86
+ i3 += 3;
87
+ }
130
88
  }
131
- }
132
-
133
- return {
134
- indices,
135
- attributes: {
136
- POSITION: positions,
137
- NORMAL: normals,
138
- TEXCOORD_0: texCoords
89
+ for (let i = 0; i < nvertical + extra; i++) {
90
+ for (let j = 0; j < nradial; j++) {
91
+ const index = (i * nradial + j) * 6;
92
+ indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
93
+ indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
94
+ indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
95
+ indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
96
+ indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
97
+ indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
98
+ }
139
99
  }
140
- };
100
+ return {
101
+ indices,
102
+ attributes: {
103
+ POSITION: positions,
104
+ NORMAL: normals,
105
+ TEXCOORD_0: texCoords
106
+ }
107
+ };
141
108
  }
142
- //# sourceMappingURL=truncated-cone-geometry.js.map
@@ -1,6 +1,6 @@
1
- import type { TypedArray, VertexFormat } from '@luma.gl/api';
1
+ import type { TypedArray, VertexFormat } from '@luma.gl/core';
2
2
  /** Holds one geometry */
3
- export declare type GeometryTable = {
3
+ export type GeometryTable = {
4
4
  length: number;
5
5
  schema?: Record<string, VertexFormat>;
6
6
  attributes: {
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,yBAAyB;AACzB,oBAAY,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,UAAU,EAAE;QACV,QAAQ,EAAE,UAAU,CAAC;QACrB,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,UAAU,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;CAC3F,CAAA"}
1
+ {"version":3,"file":"geometry-table.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-table.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5D,yBAAyB;AACzB,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACtC,UAAU,EAAE;QACV,QAAQ,EAAE,UAAU,CAAC;QACrB,MAAM,EAAE,UAAU,CAAC;QACnB,UAAU,EAAE,UAAU,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;KAC3B,CAAC;IACF,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACpC,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;CAC3F,CAAC"}
@@ -1,2 +1,4 @@
1
+ // luma.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export {};
2
- //# sourceMappingURL=geometry-table.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,QAAQ,KAAA,OA4B7C"}
1
+ {"version":3,"file":"geometry-utils.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry-utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,OA4BlD"}
@@ -1,46 +1,40 @@
1
+ // import type {Geometry} from './geometry';
1
2
  export function unpackIndexedGeometry(geometry) {
2
- const {
3
- indices,
4
- attributes
5
- } = geometry;
6
-
7
- if (!indices) {
8
- return geometry;
9
- }
10
-
11
- const vertexCount = indices.value.length;
12
- const unpackedAttributes = {};
13
-
14
- for (const attributeName in attributes) {
15
- const attribute = attributes[attributeName];
16
- const {
17
- constant,
18
- value,
19
- size
20
- } = attribute;
21
-
22
- if (constant || !size) {
23
- continue;
3
+ const { indices, attributes } = geometry;
4
+ if (!indices) {
5
+ return geometry;
24
6
  }
25
-
26
- const unpackedValue = new value.constructor(vertexCount * size);
27
-
28
- for (let x = 0; x < vertexCount; ++x) {
29
- const index = indices.value[x];
30
-
31
- for (let i = 0; i < size; i++) {
32
- unpackedValue[x * size + i] = value[index * size + i];
33
- }
7
+ const vertexCount = indices.value.length;
8
+ const unpackedAttributes = {};
9
+ for (const attributeName in attributes) {
10
+ const attribute = attributes[attributeName];
11
+ const { constant, value, size } = attribute;
12
+ if (constant || !size) {
13
+ continue; // eslint-disable-line
14
+ }
15
+ const unpackedValue = new value.constructor(vertexCount * size);
16
+ for (let x = 0; x < vertexCount; ++x) {
17
+ const index = indices.value[x];
18
+ for (let i = 0; i < size; i++) {
19
+ unpackedValue[x * size + i] = value[index * size + i];
20
+ }
21
+ }
22
+ unpackedAttributes[attributeName] = { size, value: unpackedValue };
34
23
  }
35
-
36
- unpackedAttributes[attributeName] = {
37
- size,
38
- value: unpackedValue
24
+ return {
25
+ attributes: Object.assign({}, attributes, unpackedAttributes)
39
26
  };
40
- }
41
-
42
- return {
43
- attributes: Object.assign({}, attributes, unpackedAttributes)
44
- };
45
27
  }
46
- //# sourceMappingURL=geometry-utils.js.map
28
+ // export function calculateVertexNormals(positions: Float32Array): Uint8Array {
29
+ // let normals = new Uint8Array(positions.length / 3);
30
+ // for (let i = 0; i < positions.length; i++) {
31
+ // const vec1 = new Vector3(positions.subarray(i * 3, i + 0, i + 3));
32
+ // const vec2 = new Vector3(positions.subarray(i + 3, i + 6));
33
+ // const vec3 = new Vector3(positions.subarray(i + 6, i + 9));
34
+ // const normal = new Vector3(vec1).cross(vec2).normalize();
35
+ // normals.set(normal[0], i + 4);
36
+ // normals.set(normal[1], i + 4 + 1);
37
+ // normals.set(normal[2], i + 2);
38
+ // }
39
+ // const normal = new Vector3(vec1).cross(vec2).normalize();
40
+ // }
@@ -1,62 +1,62 @@
1
- import type { PrimitiveTopology, TypedArray } from '@luma.gl/api';
2
- import GL from '@luma.gl/constants';
3
- /**
4
- * Rendering primitives - "topology" specifies how to extract primitives from vertices.
5
- * @deprecated - use string constants instead
6
- */
7
- export declare type GLTopology = GL.POINTS | // draw single points.
8
- GL.LINES | // draw lines. Each vertex connects to the one after it.
9
- GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.
10
- GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last
11
- GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.
12
- GL.TRIANGLE_STRIP | // draw a connected group of triangles.
13
- GL.TRIANGLE_FAN;
14
- export declare type GeometryAttribute = {
15
- size?: number;
16
- value: TypedArray;
17
- [key: string]: any;
18
- };
19
- export declare type GeometryProps = {
1
+ import type { PrimitiveTopology, TypedArray } from '@luma.gl/core';
2
+ export type GeometryProps = {
20
3
  id?: string;
4
+ /** Determines how vertices are read from the 'vertex' attributes */
5
+ topology: 'point-list' | 'line-list' | 'line-strip' | 'line-loop-webgl' | 'triangle-list' | 'triangle-strip' | 'triangle-fan-webgl';
6
+ /** Auto calculated from attributes if not provided */
7
+ vertexCount?: number;
21
8
  attributes?: Record<string, GeometryAttribute | TypedArray>;
22
9
  indices?: GeometryAttribute | TypedArray;
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?: GLTopology;
28
10
  };
29
- export default class Geometry {
30
- /** @deprecated */
31
- static DRAW_MODE: {
32
- POINTS: GL;
33
- LINES: GL;
34
- LINE_LOOP: GL;
35
- LINE_STRIP: GL;
36
- TRIANGLES: GL;
37
- TRIANGLE_STRIP: GL;
38
- TRIANGLE_FAN: GL;
11
+ export type GeometryAttributes = {
12
+ POSITION: GeometryAttribute;
13
+ NORMAL: GeometryAttribute;
14
+ TEXCOORD_0: GeometryAttribute;
15
+ COLOR_0?: GeometryAttribute;
16
+ indices?: GeometryAttribute & {
17
+ size: 1;
18
+ value: Uint32Array | Uint16Array;
39
19
  };
20
+ };
21
+ export type GeometryAttribute = {
22
+ size?: number;
23
+ value: TypedArray;
24
+ [key: string]: any;
25
+ };
26
+ export declare class Geometry {
40
27
  readonly id: string;
41
- userData: Record<string, unknown>;
42
28
  /** Determines how vertices are read from the 'vertex' attributes */
43
- topology?: PrimitiveTopology;
44
- /** @deprecated */
45
- readonly drawMode: GLTopology;
29
+ readonly topology?: PrimitiveTopology;
46
30
  readonly vertexCount: number;
31
+ readonly indices?: GeometryAttribute;
47
32
  readonly attributes: {
48
33
  POSITION: GeometryAttribute;
49
34
  NORMAL: GeometryAttribute;
50
35
  TEXCOORD_0: GeometryAttribute;
51
36
  COLOR_0?: GeometryAttribute;
37
+ [key: string]: GeometryAttribute | undefined;
52
38
  };
53
- readonly indices?: Uint16Array | Uint32Array;
54
- constructor(props?: GeometryProps);
55
- /** @deprecated Use string topology constants instead */
56
- get mode(): GLTopology;
39
+ userData: Record<string, unknown>;
40
+ constructor(props: GeometryProps);
57
41
  getVertexCount(): number;
42
+ /**
43
+ * Return an object with all attributes plus indices added as a field.
44
+ * TODO Geometry types are a mess
45
+ */
46
+ getAttributes(): GeometryAttributes;
58
47
  _print(attributeName: string): string;
48
+ /**
49
+ * GeometryAttribute
50
+ * value: typed array
51
+ * type: indices, vertices, uvs
52
+ * size: elements per vertex
53
+ * target: WebGL buffer type (string or constant)
54
+ *
55
+ * @param attributes
56
+ * @param indices
57
+ * @returns
58
+ */
59
59
  _setAttributes(attributes: Record<string, GeometryAttribute>, indices: any): this;
60
- _calculateVertexCount(attributes: any, indices: any): number;
60
+ _calculateVertexCount(attributes: GeometryAttributes, indices: GeometryAttribute): number;
61
61
  }
62
62
  //# sourceMappingURL=geometry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"geometry.d.ts","sourceRoot":"","sources":["../../src/geometry/geometry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,cAAc,CAAC;AAEhE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEpC;;;GAGG;AACH,oBAAY,UAAU,GACpB,EAAE,CAAC,MAAM,GAAI,sBAAsB;AACnC,EAAE,CAAC,KAAK,GAAI,wDAAwD;AACpE,EAAE,CAAC,SAAS,GAAI,8EAA8E;AAC9F,E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