@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 +1 @@
1
- {"version":3,"file":"plane-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/plane-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAG5C,oBAAY,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,MAAA;CACZ,CAAC;AAKF,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,GAAE,kBAAuB;CAW3C"}
1
+ {"version":3,"file":"plane-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/plane-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,gCAA6B;AAG9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAKF,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,GAAE,kBAAuB;CAY3C"}
@@ -1,129 +1,102 @@
1
- import { uid } from '@luma.gl/api';
2
- import Geometry from '../geometry/geometry';
3
- import { unpackIndexedGeometry } from '../geometry/geometry-utils';
1
+ import { uid } from '@luma.gl/core';
2
+ import { Geometry } from "../geometry/geometry.js";
3
+ import { unpackIndexedGeometry } from "../geometry/geometry-utils.js";
4
+ // Primitives inspired by TDL http://code.google.com/p/webglsamples/,
5
+ // copyright 2011 Google Inc. new BSD License
6
+ // (http://www.opensource.org/licenses/bsd-license.php).
4
7
  export class PlaneGeometry extends Geometry {
5
- constructor(props = {}) {
6
- const {
7
- id = uid('plane-geometry')
8
- } = props;
9
- const {
10
- indices,
11
- attributes
12
- } = tesselatePlane(props);
13
- super({ ...props,
14
- id,
15
- indices,
16
- attributes: { ...attributes,
17
- ...props.attributes
18
- }
19
- });
20
- }
21
-
8
+ constructor(props = {}) {
9
+ const { id = uid('plane-geometry') } = props;
10
+ const { indices, attributes } = tesselatePlane(props);
11
+ super({
12
+ ...props,
13
+ id,
14
+ topology: 'triangle-list',
15
+ indices,
16
+ attributes: { ...attributes, ...props.attributes }
17
+ });
18
+ }
22
19
  }
23
-
20
+ /* eslint-disable complexity, max-statements */
24
21
  function tesselatePlane(props) {
25
- const {
26
- type = 'x,y',
27
- offset = 0,
28
- flipCull = false,
29
- unpack = false
30
- } = props;
31
- const coords = type.split(',');
32
- let c1len = props["".concat(coords[0], "len")] || 1;
33
- const c2len = props["".concat(coords[1], "len")] || 1;
34
- const subdivisions1 = props["n".concat(coords[0])] || 1;
35
- const subdivisions2 = props["n".concat(coords[1])] || 1;
36
- const numVertices = (subdivisions1 + 1) * (subdivisions2 + 1);
37
- const positions = new Float32Array(numVertices * 3);
38
- const normals = new Float32Array(numVertices * 3);
39
- const texCoords = new Float32Array(numVertices * 2);
40
-
41
- if (flipCull) {
42
- c1len = -c1len;
43
- }
44
-
45
- let i2 = 0;
46
- let i3 = 0;
47
-
48
- for (let z = 0; z <= subdivisions2; z++) {
49
- for (let x = 0; x <= subdivisions1; x++) {
50
- const u = x / subdivisions1;
51
- const v = z / subdivisions2;
52
- texCoords[i2 + 0] = flipCull ? 1 - u : u;
53
- texCoords[i2 + 1] = v;
54
-
55
- switch (type) {
56
- case 'x,y':
57
- positions[i3 + 0] = c1len * u - c1len * 0.5;
58
- positions[i3 + 1] = c2len * v - c2len * 0.5;
59
- positions[i3 + 2] = offset;
60
- normals[i3 + 0] = 0;
61
- normals[i3 + 1] = 0;
62
- normals[i3 + 2] = flipCull ? 1 : -1;
63
- break;
64
-
65
- case 'x,z':
66
- positions[i3 + 0] = c1len * u - c1len * 0.5;
67
- positions[i3 + 1] = offset;
68
- positions[i3 + 2] = c2len * v - c2len * 0.5;
69
- normals[i3 + 0] = 0;
70
- normals[i3 + 1] = flipCull ? 1 : -1;
71
- normals[i3 + 2] = 0;
72
- break;
73
-
74
- case 'y,z':
75
- positions[i3 + 0] = offset;
76
- positions[i3 + 1] = c1len * u - c1len * 0.5;
77
- positions[i3 + 2] = c2len * v - c2len * 0.5;
78
- normals[i3 + 0] = flipCull ? 1 : -1;
79
- normals[i3 + 1] = 0;
80
- normals[i3 + 2] = 0;
81
- break;
82
-
83
- default:
84
- throw new Error('PlaneGeometry: unknown type');
85
- }
86
-
87
- i2 += 2;
88
- i3 += 3;
22
+ const { type = 'x,y', offset = 0, flipCull = false, unpack = false } = props;
23
+ const coords = type.split(',');
24
+ // width, height
25
+ let c1len = props[`${coords[0]}len`] || 1;
26
+ const c2len = props[`${coords[1]}len`] || 1;
27
+ // subdivisionsWidth, subdivisionsDepth
28
+ const subdivisions1 = props[`n${coords[0]}`] || 1;
29
+ const subdivisions2 = props[`n${coords[1]}`] || 1;
30
+ const numVertices = (subdivisions1 + 1) * (subdivisions2 + 1);
31
+ const positions = new Float32Array(numVertices * 3);
32
+ const normals = new Float32Array(numVertices * 3);
33
+ const texCoords = new Float32Array(numVertices * 2);
34
+ if (flipCull) {
35
+ c1len = -c1len;
89
36
  }
90
- }
91
-
92
- const numVertsAcross = subdivisions1 + 1;
93
- const indices = new Uint16Array(subdivisions1 * subdivisions2 * 6);
94
-
95
- for (let z = 0; z < subdivisions2; z++) {
96
- for (let x = 0; x < subdivisions1; x++) {
97
- const index = (z * subdivisions1 + x) * 6;
98
- indices[index + 0] = (z + 0) * numVertsAcross + x;
99
- indices[index + 1] = (z + 1) * numVertsAcross + x;
100
- indices[index + 2] = (z + 0) * numVertsAcross + x + 1;
101
- indices[index + 3] = (z + 1) * numVertsAcross + x;
102
- indices[index + 4] = (z + 1) * numVertsAcross + x + 1;
103
- indices[index + 5] = (z + 0) * numVertsAcross + x + 1;
37
+ let i2 = 0;
38
+ let i3 = 0;
39
+ for (let z = 0; z <= subdivisions2; z++) {
40
+ for (let x = 0; x <= subdivisions1; x++) {
41
+ const u = x / subdivisions1;
42
+ const v = z / subdivisions2;
43
+ texCoords[i2 + 0] = flipCull ? 1 - u : u;
44
+ texCoords[i2 + 1] = v;
45
+ switch (type) {
46
+ case 'x,y':
47
+ positions[i3 + 0] = c1len * u - c1len * 0.5;
48
+ positions[i3 + 1] = c2len * v - c2len * 0.5;
49
+ positions[i3 + 2] = offset;
50
+ normals[i3 + 0] = 0;
51
+ normals[i3 + 1] = 0;
52
+ normals[i3 + 2] = flipCull ? 1 : -1;
53
+ break;
54
+ case 'x,z':
55
+ positions[i3 + 0] = c1len * u - c1len * 0.5;
56
+ positions[i3 + 1] = offset;
57
+ positions[i3 + 2] = c2len * v - c2len * 0.5;
58
+ normals[i3 + 0] = 0;
59
+ normals[i3 + 1] = flipCull ? 1 : -1;
60
+ normals[i3 + 2] = 0;
61
+ break;
62
+ case 'y,z':
63
+ positions[i3 + 0] = offset;
64
+ positions[i3 + 1] = c1len * u - c1len * 0.5;
65
+ positions[i3 + 2] = c2len * v - c2len * 0.5;
66
+ normals[i3 + 0] = flipCull ? 1 : -1;
67
+ normals[i3 + 1] = 0;
68
+ normals[i3 + 2] = 0;
69
+ break;
70
+ default:
71
+ throw new Error('PlaneGeometry: unknown type');
72
+ }
73
+ i2 += 2;
74
+ i3 += 3;
75
+ }
104
76
  }
105
- }
106
-
107
- const geometry = {
108
- indices: {
109
- size: 1,
110
- value: indices
111
- },
112
- attributes: {
113
- POSITION: {
114
- size: 3,
115
- value: positions
116
- },
117
- NORMAL: {
118
- size: 3,
119
- value: normals
120
- },
121
- TEXCOORD_0: {
122
- size: 2,
123
- value: texCoords
124
- }
77
+ const numVertsAcross = subdivisions1 + 1;
78
+ const indices = new Uint16Array(subdivisions1 * subdivisions2 * 6);
79
+ for (let z = 0; z < subdivisions2; z++) {
80
+ for (let x = 0; x < subdivisions1; x++) {
81
+ const index = (z * subdivisions1 + x) * 6;
82
+ // Make triangle 1 of quad.
83
+ indices[index + 0] = (z + 0) * numVertsAcross + x;
84
+ indices[index + 1] = (z + 1) * numVertsAcross + x;
85
+ indices[index + 2] = (z + 0) * numVertsAcross + x + 1;
86
+ // Make triangle 2 of quad.
87
+ indices[index + 3] = (z + 1) * numVertsAcross + x;
88
+ indices[index + 4] = (z + 1) * numVertsAcross + x + 1;
89
+ indices[index + 5] = (z + 0) * numVertsAcross + x + 1;
90
+ }
125
91
  }
126
- };
127
- return unpack ? unpackIndexedGeometry(geometry) : geometry;
92
+ const geometry = {
93
+ indices: { size: 1, value: indices },
94
+ attributes: {
95
+ POSITION: { size: 3, value: positions },
96
+ NORMAL: { size: 3, value: normals },
97
+ TEXCOORD_0: { size: 2, value: texCoords }
98
+ }
99
+ };
100
+ // Optionally, unpack indexed geometry
101
+ return unpack ? unpackIndexedGeometry(geometry) : geometry;
128
102
  }
129
- //# sourceMappingURL=plane-geometry.js.map
@@ -1,5 +1,5 @@
1
- import Geometry from '../geometry/geometry';
2
- export declare type SphereGeometryProps = {
1
+ import { Geometry } from "../geometry/geometry.js";
2
+ export type SphereGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
5
5
  nlat?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/sphere-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C,oBAAY,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,MAAA;CACZ,CAAC;AAKF,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,KAAK,GAAE,mBAAwB;CAU5C"}
1
+ {"version":3,"file":"sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/sphere-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,gCAA6B;AAE9C,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAKF,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,KAAK,GAAE,mBAAwB;CAW5C"}
@@ -1,107 +1,84 @@
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
+ // Primitives inspired by TDL http://code.google.com/p/webglsamples/,
4
+ // copyright 2011 Google Inc. new BSD License
5
+ // (http://www.opensource.org/licenses/bsd-license.php).
3
6
  export class SphereGeometry extends Geometry {
4
- constructor(props = {}) {
5
- const {
6
- id = uid('sphere-geometry')
7
- } = props;
8
- const {
9
- indices,
10
- attributes
11
- } = tesselateSphere(props);
12
- super({ ...props,
13
- id,
14
- indices,
15
- attributes: { ...attributes,
16
- ...props.attributes
17
- }
18
- });
19
- }
20
-
7
+ constructor(props = {}) {
8
+ const { id = uid('sphere-geometry') } = props;
9
+ const { indices, attributes } = tesselateSphere(props);
10
+ super({
11
+ ...props,
12
+ id,
13
+ topology: 'triangle-list',
14
+ indices,
15
+ attributes: { ...attributes, ...props.attributes }
16
+ });
17
+ }
21
18
  }
22
-
19
+ /* eslint-disable max-statements, complexity */
23
20
  function tesselateSphere(props) {
24
- const {
25
- nlat = 10,
26
- nlong = 10
27
- } = props;
28
- const startLat = 0;
29
- const endLat = Math.PI;
30
- const latRange = endLat - startLat;
31
- const startLong = 0;
32
- const endLong = 2 * Math.PI;
33
- const longRange = endLong - startLong;
34
- const numVertices = (nlat + 1) * (nlong + 1);
35
-
36
- const radius = (n1, n2, n3, u, v) => props.radius || 1;
37
-
38
- const positions = new Float32Array(numVertices * 3);
39
- const normals = new Float32Array(numVertices * 3);
40
- const texCoords = new Float32Array(numVertices * 2);
41
- const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;
42
- const indices = new IndexType(nlat * nlong * 6);
43
-
44
- for (let y = 0; y <= nlat; y++) {
45
- for (let x = 0; x <= nlong; x++) {
46
- const u = x / nlong;
47
- const v = y / nlat;
48
- const index = x + y * (nlong + 1);
49
- const i2 = index * 2;
50
- const i3 = index * 3;
51
- const theta = longRange * u;
52
- const phi = latRange * v;
53
- const sinTheta = Math.sin(theta);
54
- const cosTheta = Math.cos(theta);
55
- const sinPhi = Math.sin(phi);
56
- const cosPhi = Math.cos(phi);
57
- const ux = cosTheta * sinPhi;
58
- const uy = cosPhi;
59
- const uz = sinTheta * sinPhi;
60
- const r = radius(ux, uy, uz, u, v);
61
- positions[i3 + 0] = r * ux;
62
- positions[i3 + 1] = r * uy;
63
- positions[i3 + 2] = r * uz;
64
- normals[i3 + 0] = ux;
65
- normals[i3 + 1] = uy;
66
- normals[i3 + 2] = uz;
67
- texCoords[i2 + 0] = u;
68
- texCoords[i2 + 1] = 1 - v;
69
- }
70
- }
71
-
72
- const numVertsAround = nlong + 1;
73
-
74
- for (let x = 0; x < nlong; x++) {
75
- for (let y = 0; y < nlat; y++) {
76
- const index = (x * nlat + y) * 6;
77
- indices[index + 0] = y * numVertsAround + x;
78
- indices[index + 1] = y * numVertsAround + x + 1;
79
- indices[index + 2] = (y + 1) * numVertsAround + x;
80
- indices[index + 3] = (y + 1) * numVertsAround + x;
81
- indices[index + 4] = y * numVertsAround + x + 1;
82
- indices[index + 5] = (y + 1) * numVertsAround + x + 1;
21
+ const { nlat = 10, nlong = 10 } = props;
22
+ const startLat = 0;
23
+ const endLat = Math.PI;
24
+ const latRange = endLat - startLat;
25
+ const startLong = 0;
26
+ const endLong = 2 * Math.PI;
27
+ const longRange = endLong - startLong;
28
+ const numVertices = (nlat + 1) * (nlong + 1);
29
+ const radius = (n1, n2, n3, u, v) => props.radius || 1;
30
+ const positions = new Float32Array(numVertices * 3);
31
+ const normals = new Float32Array(numVertices * 3);
32
+ const texCoords = new Float32Array(numVertices * 2);
33
+ const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;
34
+ const indices = new IndexType(nlat * nlong * 6);
35
+ // Create positions, normals and texCoords
36
+ for (let y = 0; y <= nlat; y++) {
37
+ for (let x = 0; x <= nlong; x++) {
38
+ const u = x / nlong;
39
+ const v = y / nlat;
40
+ const index = x + y * (nlong + 1);
41
+ const i2 = index * 2;
42
+ const i3 = index * 3;
43
+ const theta = longRange * u;
44
+ const phi = latRange * v;
45
+ const sinTheta = Math.sin(theta);
46
+ const cosTheta = Math.cos(theta);
47
+ const sinPhi = Math.sin(phi);
48
+ const cosPhi = Math.cos(phi);
49
+ const ux = cosTheta * sinPhi;
50
+ const uy = cosPhi;
51
+ const uz = sinTheta * sinPhi;
52
+ const r = radius(ux, uy, uz, u, v);
53
+ positions[i3 + 0] = r * ux;
54
+ positions[i3 + 1] = r * uy;
55
+ positions[i3 + 2] = r * uz;
56
+ normals[i3 + 0] = ux;
57
+ normals[i3 + 1] = uy;
58
+ normals[i3 + 2] = uz;
59
+ texCoords[i2 + 0] = u;
60
+ texCoords[i2 + 1] = 1 - v;
61
+ }
83
62
  }
84
- }
85
-
86
- return {
87
- indices: {
88
- size: 1,
89
- value: indices
90
- },
91
- attributes: {
92
- POSITION: {
93
- size: 3,
94
- value: positions
95
- },
96
- NORMAL: {
97
- size: 3,
98
- value: normals
99
- },
100
- TEXCOORD_0: {
101
- size: 2,
102
- value: texCoords
103
- }
63
+ // Create indices
64
+ const numVertsAround = nlong + 1;
65
+ for (let x = 0; x < nlong; x++) {
66
+ for (let y = 0; y < nlat; y++) {
67
+ const index = (x * nlat + y) * 6;
68
+ indices[index + 0] = y * numVertsAround + x;
69
+ indices[index + 1] = y * numVertsAround + x + 1;
70
+ indices[index + 2] = (y + 1) * numVertsAround + x;
71
+ indices[index + 3] = (y + 1) * numVertsAround + x;
72
+ indices[index + 4] = y * numVertsAround + x + 1;
73
+ indices[index + 5] = (y + 1) * numVertsAround + x + 1;
74
+ }
104
75
  }
105
- };
76
+ return {
77
+ indices: { size: 1, value: indices },
78
+ attributes: {
79
+ POSITION: { size: 3, value: positions },
80
+ NORMAL: { size: 3, value: normals },
81
+ TEXCOORD_0: { size: 2, value: texCoords }
82
+ }
83
+ };
106
84
  }
107
- //# sourceMappingURL=sphere-geometry.js.map
@@ -1,6 +1,5 @@
1
- import Geometry from '../geometry/geometry';
2
- import { GeometryTable } from '../geometry/geometry-table';
3
- export declare type TruncatedConeGeometryProps = {
1
+ import { Geometry } from "../geometry/geometry.js";
2
+ export type TruncatedConeGeometryProps = {
4
3
  topRadius?: number;
5
4
  bottomRadius?: number;
6
5
  topCap?: boolean;
@@ -15,7 +14,6 @@ export declare type TruncatedConeGeometryProps = {
15
14
  * copyright 2011 Google Inc. new BSD License
16
15
  * (http://www.opensource.org/licenses/bsd-license.php).
17
16
  */
18
- export declare function makeTruncatedConeGeometry(props?: TruncatedConeGeometryProps): GeometryTable;
19
17
  export declare class TruncatedConeGeometry extends Geometry {
20
18
  constructor(props?: TruncatedConeGeometryProps & {
21
19
  id?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"truncated-cone-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AAQzD,oBAAY,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAChC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,CAAC,EAAE,0BAA0B,GAAG,aAAa,CAO3F;AAED,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,KAAK,GAAE,0BAA0B,GAAG;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,MAAA;KAAM;CAchF"}
1
+ {"version":3,"file":"truncated-cone-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/truncated-cone-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,gCAA6B;AAQ9C,MAAM,MAAM,0BAA0B,GAAG;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;CAChC,CAAC;AAEF;;;;GAIG;AACH,qBAAa,qBAAsB,SAAQ,QAAQ;gBACrC,KAAK,GAAE,0BAA0B,GAAG;QAAC,EAAE,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,GAAG,CAAA;KAAM;CAgBrF"}