@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,107 +1,83 @@
1
1
  import { uid } from '@luma.gl/api';
2
- import Geometry from '../geometry/geometry';
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
+ indices,
14
+ attributes: { ...attributes, ...props.attributes }
15
+ });
16
+ }
21
17
  }
22
-
18
+ /* eslint-disable max-statements, complexity */
23
19
  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;
20
+ const { nlat = 10, nlong = 10 } = props;
21
+ const startLat = 0;
22
+ const endLat = Math.PI;
23
+ const latRange = endLat - startLat;
24
+ const startLong = 0;
25
+ const endLong = 2 * Math.PI;
26
+ const longRange = endLong - startLong;
27
+ const numVertices = (nlat + 1) * (nlong + 1);
28
+ const radius = (n1, n2, n3, u, v) => props.radius || 1;
29
+ const positions = new Float32Array(numVertices * 3);
30
+ const normals = new Float32Array(numVertices * 3);
31
+ const texCoords = new Float32Array(numVertices * 2);
32
+ const IndexType = numVertices > 0xffff ? Uint32Array : Uint16Array;
33
+ const indices = new IndexType(nlat * nlong * 6);
34
+ // Create positions, normals and texCoords
35
+ for (let y = 0; y <= nlat; y++) {
36
+ for (let x = 0; x <= nlong; x++) {
37
+ const u = x / nlong;
38
+ const v = y / nlat;
39
+ const index = x + y * (nlong + 1);
40
+ const i2 = index * 2;
41
+ const i3 = index * 3;
42
+ const theta = longRange * u;
43
+ const phi = latRange * v;
44
+ const sinTheta = Math.sin(theta);
45
+ const cosTheta = Math.cos(theta);
46
+ const sinPhi = Math.sin(phi);
47
+ const cosPhi = Math.cos(phi);
48
+ const ux = cosTheta * sinPhi;
49
+ const uy = cosPhi;
50
+ const uz = sinTheta * sinPhi;
51
+ const r = radius(ux, uy, uz, u, v);
52
+ positions[i3 + 0] = r * ux;
53
+ positions[i3 + 1] = r * uy;
54
+ positions[i3 + 2] = r * uz;
55
+ normals[i3 + 0] = ux;
56
+ normals[i3 + 1] = uy;
57
+ normals[i3 + 2] = uz;
58
+ texCoords[i2 + 0] = u;
59
+ texCoords[i2 + 1] = 1 - v;
60
+ }
83
61
  }
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
- }
62
+ // Create indices
63
+ const numVertsAround = nlong + 1;
64
+ for (let x = 0; x < nlong; x++) {
65
+ for (let y = 0; y < nlat; y++) {
66
+ const index = (x * nlat + y) * 6;
67
+ indices[index + 0] = y * numVertsAround + x;
68
+ indices[index + 1] = y * numVertsAround + x + 1;
69
+ indices[index + 2] = (y + 1) * numVertsAround + x;
70
+ indices[index + 3] = (y + 1) * numVertsAround + x;
71
+ indices[index + 4] = y * numVertsAround + x + 1;
72
+ indices[index + 5] = (y + 1) * numVertsAround + x + 1;
73
+ }
104
74
  }
105
- };
75
+ return {
76
+ indices: { size: 1, value: indices },
77
+ attributes: {
78
+ POSITION: { size: 3, value: positions },
79
+ NORMAL: { size: 3, value: normals },
80
+ TEXCOORD_0: { size: 2, value: texCoords }
81
+ }
82
+ };
106
83
  }
107
- //# sourceMappingURL=sphere-geometry.js.map
@@ -1,6 +1,6 @@
1
1
  import Geometry from '../geometry/geometry';
2
2
  import { GeometryTable } from '../geometry/geometry-table';
3
- export declare type TruncatedConeGeometryProps = {
3
+ export type TruncatedConeGeometryProps = {
4
4
  topRadius?: number;
5
5
  bottomRadius?: number;
6
6
  topCap?: boolean;
@@ -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,EAAE,GAAG,CAAA;KAAM;CAcrF"}
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,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,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,EAAE,GAAG,CAAA;KAAM;CAcrF"}
@@ -1,142 +1,115 @@
1
1
  import { uid } from '@luma.gl/api';
2
- import Geometry from '../geometry/geometry';
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
+ /**
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
+ */
8
13
  export function makeTruncatedConeGeometry(props) {
9
- const {
10
- indices,
11
- attributes
12
- } = tesselateTruncatedCone(props);
13
- return {
14
- length: indices.length,
15
- indices,
16
- attributes
17
- };
14
+ const { indices, attributes } = tesselateTruncatedCone(props);
15
+ return {
16
+ length: indices.length,
17
+ indices,
18
+ attributes
19
+ };
18
20
  }
19
21
  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
-
22
+ constructor(props = {}) {
23
+ const { id = uid('truncated-code-geometry') } = props;
24
+ const { indices, attributes } = tesselateTruncatedCone(props);
25
+ super({
26
+ ...props,
27
+ id,
28
+ indices,
29
+ attributes: {
30
+ POSITION: { size: 3, value: attributes.POSITION },
31
+ NORMAL: { size: 3, value: attributes.NORMAL },
32
+ TEXCOORD_0: { size: 2, value: attributes.TEXCOORD_0 },
33
+ ...props.attributes
34
+ }
35
+ });
36
+ }
49
37
  }
50
-
38
+ /* eslint-disable max-statements, complexity */
51
39
  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;
40
+ const { bottomRadius = 0, topRadius = 0, height = 1, nradial = 10, nvertical = 10, verticalAxis = 'y', topCap = false, bottomCap = false } = props;
41
+ const extra = (topCap ? 2 : 0) + (bottomCap ? 2 : 0);
42
+ const numVertices = (nradial + 1) * (nvertical + 1 + extra);
43
+ const slant = Math.atan2(bottomRadius - topRadius, height);
44
+ const msin = Math.sin;
45
+ const mcos = Math.cos;
46
+ const mpi = Math.PI;
47
+ const cosSlant = mcos(slant);
48
+ const sinSlant = msin(slant);
49
+ const start = topCap ? -2 : 0;
50
+ const end = nvertical + (bottomCap ? 2 : 0);
51
+ const vertsAroundEdge = nradial + 1;
52
+ const indices = new Uint16Array(nradial * (nvertical + extra) * 6);
53
+ const indexOffset = INDEX_OFFSETS[verticalAxis];
54
+ const positions = new Float32Array(numVertices * 3);
55
+ const normals = new Float32Array(numVertices * 3);
56
+ const texCoords = new Float32Array(numVertices * 2);
57
+ let i3 = 0;
58
+ let i2 = 0;
59
+ for (let i = start; i <= end; i++) {
60
+ let v = i / nvertical;
61
+ let y = height * v;
62
+ let ringRadius;
63
+ if (i < 0) {
64
+ y = 0;
65
+ v = 1;
66
+ ringRadius = bottomRadius;
67
+ }
68
+ else if (i > nvertical) {
69
+ y = height;
70
+ v = 1;
71
+ ringRadius = topRadius;
72
+ }
73
+ else {
74
+ ringRadius = bottomRadius + (topRadius - bottomRadius) * (i / nvertical);
75
+ }
76
+ if (i === -2 || i === nvertical + 2) {
77
+ ringRadius = 0;
78
+ v = 0;
79
+ }
80
+ y -= height / 2;
81
+ for (let j = 0; j < vertsAroundEdge; j++) {
82
+ const sin = msin((j * mpi * 2) / nradial);
83
+ const cos = mcos((j * mpi * 2) / nradial);
84
+ positions[i3 + indexOffset[0]] = sin * ringRadius;
85
+ positions[i3 + indexOffset[1]] = y;
86
+ positions[i3 + indexOffset[2]] = cos * ringRadius;
87
+ normals[i3 + indexOffset[0]] = i < 0 || i > nvertical ? 0 : sin * cosSlant;
88
+ normals[i3 + indexOffset[1]] = i < 0 ? -1 : i > nvertical ? 1 : sinSlant;
89
+ normals[i3 + indexOffset[2]] = i < 0 || i > nvertical ? 0 : cos * cosSlant;
90
+ texCoords[i2 + 0] = j / nradial;
91
+ texCoords[i2 + 1] = v;
92
+ i2 += 2;
93
+ i3 += 3;
94
+ }
130
95
  }
131
- }
132
-
133
- return {
134
- indices,
135
- attributes: {
136
- POSITION: positions,
137
- NORMAL: normals,
138
- TEXCOORD_0: texCoords
96
+ for (let i = 0; i < nvertical + extra; i++) {
97
+ for (let j = 0; j < nradial; j++) {
98
+ const index = (i * nradial + j) * 6;
99
+ indices[index + 0] = vertsAroundEdge * (i + 0) + 0 + j;
100
+ indices[index + 1] = vertsAroundEdge * (i + 0) + 1 + j;
101
+ indices[index + 2] = vertsAroundEdge * (i + 1) + 1 + j;
102
+ indices[index + 3] = vertsAroundEdge * (i + 0) + 0 + j;
103
+ indices[index + 4] = vertsAroundEdge * (i + 1) + 1 + j;
104
+ indices[index + 5] = vertsAroundEdge * (i + 1) + 0 + j;
105
+ }
139
106
  }
140
- };
107
+ return {
108
+ indices,
109
+ attributes: {
110
+ POSITION: positions,
111
+ NORMAL: normals,
112
+ TEXCOORD_0: texCoords
113
+ }
114
+ };
141
115
  }
142
- //# sourceMappingURL=truncated-cone-geometry.js.map
@@ -1,6 +1,6 @@
1
1
  import type { TypedArray, VertexFormat } from '@luma.gl/api';
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":"AACA,OAAO,KAAK,EAAC,UAAU,EAAE,YAAY,EAAC,MAAM,cAAc,CAAC;AAE3D,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,CAAA"}
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=geometry-table.js.map
@@ -1,46 +1,27 @@
1
+ // import type Geometry from './geometry.js';
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
@@ -4,19 +4,19 @@ import GL from '@luma.gl/constants';
4
4
  * Rendering primitives - "topology" specifies how to extract primitives from vertices.
5
5
  * @deprecated - use string constants instead
6
6
  */
7
- export declare type GLTopology = GL.POINTS | // draw single points.
7
+ export type GLTopology = GL.POINTS | // draw single points.
8
8
  GL.LINES | // draw lines. Each vertex connects to the one after it.
9
9
  GL.LINE_LOOP | // draw lines. Each set of two vertices is treated as a separate line segment.
10
10
  GL.LINE_STRIP | // draw a connected group of line segments from the first vertex to the last
11
11
  GL.TRIANGLES | // draw triangles. Each set of three vertices creates a separate triangle.
12
12
  GL.TRIANGLE_STRIP | // draw a connected group of triangles.
13
13
  GL.TRIANGLE_FAN;
14
- export declare type GeometryAttribute = {
14
+ export type GeometryAttribute = {
15
15
  size?: number;
16
16
  value: TypedArray;
17
17
  [key: string]: any;
18
18
  };
19
- export declare type GeometryProps = {
19
+ export type GeometryProps = {
20
20
  id?: string;
21
21
  attributes?: Record<string, GeometryAttribute | TypedArray>;
22
22
  indices?: GeometryAttribute | TypedArray;
@@ -26,7 +26,7 @@ export declare type GeometryProps = {
26
26
  /** @deprecated */
27
27
  drawMode?: GLTopology;
28
28
  };
29
- declare type GeometryAttributes = {
29
+ type GeometryAttributes = {
30
30
  POSITION: GeometryAttribute;
31
31
  NORMAL: GeometryAttribute;
32
32
  TEXCOORD_0: GeometryAttribute;
@@ -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,EAAE,CAAC,UAAU,GAAI,4EAA4E;AAC7F,EAAE,CAAC,SAAS,GAAI,0EAA0E;AAC1F,EAAE,CAAC,cAAc,GAAI,uCAAuC;AAC5D,EAAE,CAAC,YAAY,CACd;AAEH,oBAAY,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,UAAU,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,oBAAY,aAAa,GAAG;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,UAAU,CAAC,CAAC;IAC5D,OAAO,CAAC,EAAE,iBAAiB,GAAG,UAAU,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,QAAQ,CAAC,EAAE,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,GAAG,gBAAgB,CAAC;IAC1F,kBAAkB;IAClB,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB,CAAC;AAEF,aAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,M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