@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,63 +1,198 @@
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
  export class CubeGeometry extends Geometry {
4
- constructor(props = {}) {
5
- const {
6
- id = uid('cube-geometry'),
7
- indices = true
8
- } = props;
9
- super(indices ? { ...props,
10
- id,
11
- indices: {
12
- size: 1,
13
- value: CUBE_INDICES
14
- },
15
- attributes: { ...ATTRIBUTES,
16
- ...props.attributes
17
- }
18
- } : { ...props,
19
- id,
20
- indices: undefined,
21
- attributes: { ...NON_INDEXED_ATTRIBUTES,
22
- ...props.attributes
23
- }
24
- });
25
- }
26
-
4
+ constructor(props = {}) {
5
+ const { id = uid('cube-geometry'), indices = true } = props;
6
+ super(indices
7
+ ? {
8
+ ...props,
9
+ id,
10
+ topology: 'triangle-list',
11
+ indices: { size: 1, value: CUBE_INDICES },
12
+ attributes: { ...ATTRIBUTES, ...props.attributes }
13
+ }
14
+ : {
15
+ ...props,
16
+ id,
17
+ topology: 'triangle-list',
18
+ indices: undefined,
19
+ attributes: { ...NON_INDEXED_ATTRIBUTES, ...props.attributes }
20
+ });
21
+ }
27
22
  }
28
- const CUBE_INDICES = new Uint16Array([0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13, 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23]);
29
- const CUBE_POSITIONS = new Float32Array([-1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1]);
30
- const CUBE_NORMALS = new Float32Array([0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0]);
31
- const CUBE_TEX_COORDS = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1]);
32
- export const CUBE_NON_INDEXED_POSITIONS = new Float32Array([1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, 1, 1, -1, -1, 1, 1, -1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, 1, 1, -1, 1, -1, 1, -1, -1, -1, 1, -1, -1, 1, 1, -1, 1, -1, 1, 1, 1, 1, 1, -1, 1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, -1, -1, 1, -1, -1, -1, 1, -1, 1, -1, 1, 1, 1, -1, 1, 1, -1, -1, 1, -1, 1, -1, 1]);
33
- export const CUBE_NON_INDEXED_TEX_COORDS = new Float32Array([1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0]);
34
- export const CUBE_NON_INDEXED_COLORS = new Float32Array([1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1]);
23
+ // prettier-ignore
24
+ const CUBE_INDICES = new Uint16Array([
25
+ 0, 1, 2, 0, 2, 3, 4, 5, 6, 4, 6, 7, 8, 9, 10, 8, 10, 11, 12, 13,
26
+ 14, 12, 14, 15, 16, 17, 18, 16, 18, 19, 20, 21, 22, 20, 22, 23
27
+ ]);
28
+ // prettier-ignore
29
+ const CUBE_POSITIONS = new Float32Array([
30
+ -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1, 1,
31
+ -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1, -1,
32
+ -1, 1, -1, -1, 1, 1, 1, 1, 1, 1, 1, -1,
33
+ -1, -1, -1, 1, -1, -1, 1, -1, 1, -1, -1, 1,
34
+ 1, -1, -1, 1, 1, -1, 1, 1, 1, 1, -1, 1,
35
+ -1, -1, -1, -1, -1, 1, -1, 1, 1, -1, 1, -1
36
+ ]);
37
+ // TODO - could be Uint8
38
+ // prettier-ignore
39
+ const CUBE_NORMALS = new Float32Array([
40
+ // Front face
41
+ 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1,
42
+ // Back face
43
+ 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1,
44
+ // Top face
45
+ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0,
46
+ // Bottom face
47
+ 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0,
48
+ // Right face
49
+ 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0,
50
+ // Left face
51
+ -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0
52
+ ]);
53
+ // prettier-ignore
54
+ const CUBE_TEX_COORDS = new Float32Array([
55
+ // Front face
56
+ 0, 0, 1, 0, 1, 1, 0, 1,
57
+ // Back face
58
+ 1, 0, 1, 1, 0, 1, 0, 0,
59
+ // Top face
60
+ 0, 1, 0, 0, 1, 0, 1, 1,
61
+ // Bottom face
62
+ 1, 1, 0, 1, 0, 0, 1, 0,
63
+ // Right face
64
+ 1, 0, 1, 1, 0, 1, 0, 0,
65
+ // Left face
66
+ 0, 0, 1, 0, 1, 1, 0, 1
67
+ ]);
68
+ // float4 position
69
+ // prettier-ignore
70
+ export const CUBE_NON_INDEXED_POSITIONS = new Float32Array([
71
+ 1, -1, 1,
72
+ -1, -1, 1,
73
+ -1, -1, -1,
74
+ 1, -1, -1,
75
+ 1, -1, 1,
76
+ -1, -1, -1,
77
+ 1, 1, 1,
78
+ 1, -1, 1,
79
+ 1, -1, -1,
80
+ 1, 1, -1,
81
+ 1, 1, 1,
82
+ 1, -1, -1,
83
+ -1, 1, 1,
84
+ 1, 1, 1,
85
+ 1, 1, -1,
86
+ -1, 1, -1,
87
+ -1, 1, 1,
88
+ 1, 1, -1,
89
+ -1, -1, 1,
90
+ -1, 1, 1,
91
+ -1, 1, -1,
92
+ -1, -1, -1,
93
+ -1, -1, 1,
94
+ -1, 1, -1,
95
+ 1, 1, 1,
96
+ -1, 1, 1,
97
+ -1, -1, 1,
98
+ -1, -1, 1,
99
+ 1, -1, 1,
100
+ 1, 1, 1,
101
+ 1, -1, -1,
102
+ -1, -1, -1,
103
+ -1, 1, -1,
104
+ 1, 1, -1,
105
+ 1, -1, -1,
106
+ -1, 1, -1,
107
+ ]);
108
+ // float2 uv,
109
+ // prettier-ignore
110
+ export const CUBE_NON_INDEXED_TEX_COORDS = new Float32Array([
111
+ 1, 1,
112
+ 0, 1,
113
+ 0, 0,
114
+ 1, 0,
115
+ 1, 1,
116
+ 0, 0,
117
+ 1, 1,
118
+ 0, 1,
119
+ 0, 0,
120
+ 1, 0,
121
+ 1, 1,
122
+ 0, 0,
123
+ 1, 1,
124
+ 0, 1,
125
+ 0, 0,
126
+ 1, 0,
127
+ 1, 1,
128
+ 0, 0,
129
+ 1, 1,
130
+ 0, 1,
131
+ 0, 0,
132
+ 1, 0,
133
+ 1, 1,
134
+ 0, 0,
135
+ 1, 1,
136
+ 0, 1,
137
+ 0, 0,
138
+ 0, 0,
139
+ 1, 0,
140
+ 1, 1,
141
+ 1, 1,
142
+ 0, 1,
143
+ 0, 0,
144
+ 1, 0,
145
+ 1, 1,
146
+ 0, 0,
147
+ ]);
148
+ // float4 color
149
+ // prettier-ignore
150
+ export const CUBE_NON_INDEXED_COLORS = new Float32Array([
151
+ 1, 0, 1, 1,
152
+ 0, 0, 1, 1,
153
+ 0, 0, 0, 1,
154
+ 1, 0, 0, 1,
155
+ 1, 0, 1, 1,
156
+ 0, 0, 0, 1,
157
+ 1, 1, 1, 1,
158
+ 1, 0, 1, 1,
159
+ 1, 0, 0, 1,
160
+ 1, 1, 0, 1,
161
+ 1, 1, 1, 1,
162
+ 1, 0, 0, 1,
163
+ 0, 1, 1, 1,
164
+ 1, 1, 1, 1,
165
+ 1, 1, 0, 1,
166
+ 0, 1, 0, 1,
167
+ 0, 1, 1, 1,
168
+ 1, 1, 0, 1,
169
+ 0, 0, 1, 1,
170
+ 0, 1, 1, 1,
171
+ 0, 1, 0, 1,
172
+ 0, 0, 0, 1,
173
+ 0, 0, 1, 1,
174
+ 0, 1, 0, 1,
175
+ 1, 1, 1, 1,
176
+ 0, 1, 1, 1,
177
+ 0, 0, 1, 1,
178
+ 0, 0, 1, 1,
179
+ 1, 0, 1, 1,
180
+ 1, 1, 1, 1,
181
+ 1, 0, 0, 1,
182
+ 0, 0, 0, 1,
183
+ 0, 1, 0, 1,
184
+ 1, 1, 0, 1,
185
+ 1, 0, 0, 1,
186
+ 0, 1, 0, 1,
187
+ ]);
35
188
  const ATTRIBUTES = {
36
- POSITION: {
37
- size: 3,
38
- value: CUBE_POSITIONS
39
- },
40
- NORMAL: {
41
- size: 3,
42
- value: CUBE_NORMALS
43
- },
44
- TEXCOORD_0: {
45
- size: 2,
46
- value: CUBE_TEX_COORDS
47
- }
189
+ POSITION: { size: 3, value: CUBE_POSITIONS },
190
+ NORMAL: { size: 3, value: CUBE_NORMALS },
191
+ TEXCOORD_0: { size: 2, value: CUBE_TEX_COORDS }
48
192
  };
49
193
  const NON_INDEXED_ATTRIBUTES = {
50
- POSITION: {
51
- size: 4,
52
- value: CUBE_NON_INDEXED_POSITIONS
53
- },
54
- TEXCOORD_0: {
55
- size: 2,
56
- value: CUBE_NON_INDEXED_TEX_COORDS
57
- },
58
- COLOR_0: {
59
- size: 3,
60
- value: CUBE_NON_INDEXED_COLORS
61
- }
194
+ POSITION: { size: 3, value: CUBE_NON_INDEXED_POSITIONS },
195
+ // NORMAL: {size: 3, value: CUBE_NON_INDEXED_NORMALS},
196
+ TEXCOORD_0: { size: 2, value: CUBE_NON_INDEXED_TEX_COORDS },
197
+ COLOR_0: { size: 3, value: CUBE_NON_INDEXED_COLORS }
62
198
  };
63
- //# sourceMappingURL=cube-geometry.js.map
@@ -1,5 +1,5 @@
1
- import { TruncatedConeGeometry } from './truncated-cone-geometry';
2
- export declare type CylinderGeometryProps = {
1
+ import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
2
+ export type CylinderGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
5
5
  attributes?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"cylinder-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/cylinder-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAEhE,oBAAY,qBAAqB,GAAG;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,MAAA;CACZ,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,qBAAqB;gBAC7C,KAAK,GAAE,qBAA0B;CAS9C"}
1
+ {"version":3,"file":"cylinder-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/cylinder-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,qCAAkC;AAEhE,MAAM,MAAM,qBAAqB,GAAG;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,qBAAa,gBAAiB,SAAQ,qBAAqB;gBAC7C,KAAK,GAAE,qBAA0B;CAS9C"}
@@ -1,17 +1,13 @@
1
- import { uid } from '@luma.gl/api';
2
- import { TruncatedConeGeometry } from './truncated-cone-geometry';
1
+ import { uid } from '@luma.gl/core';
2
+ import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
3
3
  export class CylinderGeometry extends TruncatedConeGeometry {
4
- constructor(props = {}) {
5
- const {
6
- id = uid('cylinder-geometry'),
7
- radius = 1
8
- } = props;
9
- super({ ...props,
10
- id,
11
- bottomRadius: radius,
12
- topRadius: radius
13
- });
14
- }
15
-
4
+ constructor(props = {}) {
5
+ const { id = uid('cylinder-geometry'), radius = 1 } = props;
6
+ super({
7
+ ...props,
8
+ id,
9
+ bottomRadius: radius,
10
+ topRadius: radius
11
+ });
12
+ }
16
13
  }
17
- //# sourceMappingURL=cylinder-geometry.js.map
@@ -1,5 +1,5 @@
1
- import Geometry from '../geometry/geometry';
2
- export declare type IcoSphereGeometryProps = {
1
+ import { Geometry } from "../geometry/geometry.js";
2
+ export type IcoSphereGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
5
5
  iterations?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ico-sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/ico-sphere-geometry.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAO5C,oBAAY,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,MAAA;CACZ,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,GAAE,sBAA2B;CAU/C"}
1
+ {"version":3,"file":"ico-sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/ico-sphere-geometry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,gCAA6B;AAO9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,GAAE,sBAA2B;CAW/C"}
@@ -1,180 +1,152 @@
1
- import { uid } from '@luma.gl/api';
1
+ import { uid } from '@luma.gl/core';
2
2
  import { Vector3 } from '@math.gl/core';
3
- import Geometry from '../geometry/geometry';
3
+ import { Geometry } from "../geometry/geometry.js";
4
+ /* eslint-disable comma-spacing, max-statements, complexity */
4
5
  const ICO_POSITIONS = [-1, 0, 0, 0, 1, 0, 0, 0, -1, 0, 0, 1, 0, -1, 0, 1, 0, 0];
5
6
  const ICO_INDICES = [3, 4, 5, 3, 5, 1, 3, 1, 0, 3, 0, 4, 4, 0, 2, 4, 2, 5, 2, 0, 1, 5, 2, 1];
6
7
  export class IcoSphereGeometry extends Geometry {
7
- constructor(props = {}) {
8
- const {
9
- id = uid('ico-sphere-geometry')
10
- } = props;
11
- const {
12
- indices,
13
- attributes
14
- } = tesselateIcosaHedron(props);
15
- super({ ...props,
16
- id,
17
- indices,
18
- attributes: { ...attributes,
19
- ...props.attributes
20
- }
21
- });
22
- }
23
-
8
+ constructor(props = {}) {
9
+ const { id = uid('ico-sphere-geometry') } = props;
10
+ const { indices, attributes } = tesselateIcosaHedron(props);
11
+ super({
12
+ ...props,
13
+ id,
14
+ topology: 'triangle-list',
15
+ indices,
16
+ attributes: { ...attributes, ...props.attributes }
17
+ });
18
+ }
24
19
  }
25
-
26
20
  function tesselateIcosaHedron(props) {
27
- const {
28
- iterations = 0
29
- } = props;
30
- const PI = Math.PI;
31
- const PI2 = PI * 2;
32
- const positions = [...ICO_POSITIONS];
33
- let indices = [...ICO_INDICES];
34
- positions.push();
35
- indices.push();
36
-
37
- const getMiddlePoint = (() => {
38
- const pointMemo = {};
39
- return (i1, i2) => {
40
- i1 *= 3;
41
- i2 *= 3;
42
- const mini = i1 < i2 ? i1 : i2;
43
- const maxi = i1 > i2 ? i1 : i2;
44
- const key = "".concat(mini, "|").concat(maxi);
45
-
46
- if (key in pointMemo) {
47
- return pointMemo[key];
48
- }
49
-
50
- const x1 = positions[i1];
51
- const y1 = positions[i1 + 1];
52
- const z1 = positions[i1 + 2];
53
- const x2 = positions[i2];
54
- const y2 = positions[i2 + 1];
55
- const z2 = positions[i2 + 2];
56
- let xm = (x1 + x2) / 2;
57
- let ym = (y1 + y2) / 2;
58
- let zm = (z1 + z2) / 2;
59
- const len = Math.sqrt(xm * xm + ym * ym + zm * zm);
60
- xm /= len;
61
- ym /= len;
62
- zm /= len;
63
- positions.push(xm, ym, zm);
64
- return pointMemo[key] = positions.length / 3 - 1;
65
- };
66
- })();
67
-
68
- for (let i = 0; i < iterations; i++) {
69
- const indices2 = [];
70
-
71
- for (let j = 0; j < indices.length; j += 3) {
72
- const a = getMiddlePoint(indices[j + 0], indices[j + 1]);
73
- const b = getMiddlePoint(indices[j + 1], indices[j + 2]);
74
- const c = getMiddlePoint(indices[j + 2], indices[j + 0]);
75
- indices2.push(c, indices[j + 0], a, a, indices[j + 1], b, b, indices[j + 2], c, a, b, c);
21
+ const { iterations = 0 } = props;
22
+ const PI = Math.PI;
23
+ const PI2 = PI * 2;
24
+ const positions = [...ICO_POSITIONS];
25
+ let indices = [...ICO_INDICES];
26
+ positions.push();
27
+ indices.push();
28
+ const getMiddlePoint = (() => {
29
+ const pointMemo = {};
30
+ return (i1, i2) => {
31
+ i1 *= 3;
32
+ i2 *= 3;
33
+ const mini = i1 < i2 ? i1 : i2;
34
+ const maxi = i1 > i2 ? i1 : i2;
35
+ const key = `${mini}|${maxi}`;
36
+ if (key in pointMemo) {
37
+ return pointMemo[key];
38
+ }
39
+ const x1 = positions[i1];
40
+ const y1 = positions[i1 + 1];
41
+ const z1 = positions[i1 + 2];
42
+ const x2 = positions[i2];
43
+ const y2 = positions[i2 + 1];
44
+ const z2 = positions[i2 + 2];
45
+ let xm = (x1 + x2) / 2;
46
+ let ym = (y1 + y2) / 2;
47
+ let zm = (z1 + z2) / 2;
48
+ const len = Math.sqrt(xm * xm + ym * ym + zm * zm);
49
+ xm /= len;
50
+ ym /= len;
51
+ zm /= len;
52
+ positions.push(xm, ym, zm);
53
+ return (pointMemo[key] = positions.length / 3 - 1);
54
+ };
55
+ })();
56
+ for (let i = 0; i < iterations; i++) {
57
+ const indices2 = [];
58
+ for (let j = 0; j < indices.length; j += 3) {
59
+ const a = getMiddlePoint(indices[j + 0], indices[j + 1]);
60
+ const b = getMiddlePoint(indices[j + 1], indices[j + 2]);
61
+ const c = getMiddlePoint(indices[j + 2], indices[j + 0]);
62
+ indices2.push(c, indices[j + 0], a, a, indices[j + 1], b, b, indices[j + 2], c, a, b, c);
63
+ }
64
+ indices = indices2;
76
65
  }
77
-
78
- indices = indices2;
79
- }
80
-
81
- const normals = new Array(positions.length);
82
- const texCoords = new Array(positions.length / 3 * 2);
83
- const l = indices.length;
84
-
85
- for (let i = l - 3; i >= 0; i -= 3) {
86
- const i1 = indices[i + 0];
87
- const i2 = indices[i + 1];
88
- const i3 = indices[i + 2];
89
- const in1 = i1 * 3;
90
- const in2 = i2 * 3;
91
- const in3 = i3 * 3;
92
- const iu1 = i1 * 2;
93
- const iu2 = i2 * 2;
94
- const iu3 = i3 * 2;
95
- const x1 = positions[in1 + 0];
96
- const y1 = positions[in1 + 1];
97
- const z1 = positions[in1 + 2];
98
- const theta1 = Math.acos(z1 / Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1));
99
- const phi1 = Math.atan2(y1, x1) + PI;
100
- const v1 = theta1 / PI;
101
- const u1 = 1 - phi1 / PI2;
102
- const x2 = positions[in2 + 0];
103
- const y2 = positions[in2 + 1];
104
- const z2 = positions[in2 + 2];
105
- const theta2 = Math.acos(z2 / Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2));
106
- const phi2 = Math.atan2(y2, x2) + PI;
107
- const v2 = theta2 / PI;
108
- const u2 = 1 - phi2 / PI2;
109
- const x3 = positions[in3 + 0];
110
- const y3 = positions[in3 + 1];
111
- const z3 = positions[in3 + 2];
112
- const theta3 = Math.acos(z3 / Math.sqrt(x3 * x3 + y3 * y3 + z3 * z3));
113
- const phi3 = Math.atan2(y3, x3) + PI;
114
- const v3 = theta3 / PI;
115
- const u3 = 1 - phi3 / PI2;
116
- const vec1 = [x3 - x2, y3 - y2, z3 - z2];
117
- const vec2 = [x1 - x2, y1 - y2, z1 - z2];
118
- const normal = new Vector3(vec1).cross(vec2).normalize();
119
- let newIndex;
120
-
121
- if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
122
- positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
123
- newIndex = positions.length / 3 - 1;
124
- indices.push(newIndex);
125
- texCoords[newIndex * 2 + 0] = 1;
126
- texCoords[newIndex * 2 + 1] = v1;
127
- normals[newIndex * 3 + 0] = normal.x;
128
- normals[newIndex * 3 + 1] = normal.y;
129
- normals[newIndex * 3 + 2] = normal.z;
130
- positions.push(positions[in2 + 0], positions[in2 + 1], positions[in2 + 2]);
131
- newIndex = positions.length / 3 - 1;
132
- indices.push(newIndex);
133
- texCoords[newIndex * 2 + 0] = 1;
134
- texCoords[newIndex * 2 + 1] = v2;
135
- normals[newIndex * 3 + 0] = normal.x;
136
- normals[newIndex * 3 + 1] = normal.y;
137
- normals[newIndex * 3 + 2] = normal.z;
138
- positions.push(positions[in3 + 0], positions[in3 + 1], positions[in3 + 2]);
139
- newIndex = positions.length / 3 - 1;
140
- indices.push(newIndex);
141
- texCoords[newIndex * 2 + 0] = 1;
142
- texCoords[newIndex * 2 + 1] = v3;
143
- normals[newIndex * 3 + 0] = normal.x;
144
- normals[newIndex * 3 + 1] = normal.y;
145
- normals[newIndex * 3 + 2] = normal.z;
66
+ // Calculate texCoords and normals
67
+ const normals = new Array(positions.length);
68
+ const texCoords = new Array((positions.length / 3) * 2);
69
+ const l = indices.length;
70
+ for (let i = l - 3; i >= 0; i -= 3) {
71
+ const i1 = indices[i + 0];
72
+ const i2 = indices[i + 1];
73
+ const i3 = indices[i + 2];
74
+ const in1 = i1 * 3;
75
+ const in2 = i2 * 3;
76
+ const in3 = i3 * 3;
77
+ const iu1 = i1 * 2;
78
+ const iu2 = i2 * 2;
79
+ const iu3 = i3 * 2;
80
+ const x1 = positions[in1 + 0];
81
+ const y1 = positions[in1 + 1];
82
+ const z1 = positions[in1 + 2];
83
+ const theta1 = Math.acos(z1 / Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1));
84
+ const phi1 = Math.atan2(y1, x1) + PI;
85
+ const v1 = theta1 / PI;
86
+ const u1 = 1 - phi1 / PI2;
87
+ const x2 = positions[in2 + 0];
88
+ const y2 = positions[in2 + 1];
89
+ const z2 = positions[in2 + 2];
90
+ const theta2 = Math.acos(z2 / Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2));
91
+ const phi2 = Math.atan2(y2, x2) + PI;
92
+ const v2 = theta2 / PI;
93
+ const u2 = 1 - phi2 / PI2;
94
+ const x3 = positions[in3 + 0];
95
+ const y3 = positions[in3 + 1];
96
+ const z3 = positions[in3 + 2];
97
+ const theta3 = Math.acos(z3 / Math.sqrt(x3 * x3 + y3 * y3 + z3 * z3));
98
+ const phi3 = Math.atan2(y3, x3) + PI;
99
+ const v3 = theta3 / PI;
100
+ const u3 = 1 - phi3 / PI2;
101
+ const vec1 = [x3 - x2, y3 - y2, z3 - z2];
102
+ const vec2 = [x1 - x2, y1 - y2, z1 - z2];
103
+ const normal = new Vector3(vec1).cross(vec2).normalize();
104
+ let newIndex;
105
+ if ((u1 === 0 || u2 === 0 || u3 === 0) &&
106
+ (u1 === 0 || u1 > 0.5) &&
107
+ (u2 === 0 || u2 > 0.5) &&
108
+ (u3 === 0 || u3 > 0.5)) {
109
+ positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
110
+ newIndex = positions.length / 3 - 1;
111
+ indices.push(newIndex);
112
+ texCoords[newIndex * 2 + 0] = 1;
113
+ texCoords[newIndex * 2 + 1] = v1;
114
+ normals[newIndex * 3 + 0] = normal.x;
115
+ normals[newIndex * 3 + 1] = normal.y;
116
+ normals[newIndex * 3 + 2] = normal.z;
117
+ positions.push(positions[in2 + 0], positions[in2 + 1], positions[in2 + 2]);
118
+ newIndex = positions.length / 3 - 1;
119
+ indices.push(newIndex);
120
+ texCoords[newIndex * 2 + 0] = 1;
121
+ texCoords[newIndex * 2 + 1] = v2;
122
+ normals[newIndex * 3 + 0] = normal.x;
123
+ normals[newIndex * 3 + 1] = normal.y;
124
+ normals[newIndex * 3 + 2] = normal.z;
125
+ positions.push(positions[in3 + 0], positions[in3 + 1], positions[in3 + 2]);
126
+ newIndex = positions.length / 3 - 1;
127
+ indices.push(newIndex);
128
+ texCoords[newIndex * 2 + 0] = 1;
129
+ texCoords[newIndex * 2 + 1] = v3;
130
+ normals[newIndex * 3 + 0] = normal.x;
131
+ normals[newIndex * 3 + 1] = normal.y;
132
+ normals[newIndex * 3 + 2] = normal.z;
133
+ }
134
+ normals[in1 + 0] = normals[in2 + 0] = normals[in3 + 0] = normal.x;
135
+ normals[in1 + 1] = normals[in2 + 1] = normals[in3 + 1] = normal.y;
136
+ normals[in1 + 2] = normals[in2 + 2] = normals[in3 + 2] = normal.z;
137
+ texCoords[iu1 + 0] = u1;
138
+ texCoords[iu1 + 1] = v1;
139
+ texCoords[iu2 + 0] = u2;
140
+ texCoords[iu2 + 1] = v2;
141
+ texCoords[iu3 + 0] = u3;
142
+ texCoords[iu3 + 1] = v3;
146
143
  }
147
-
148
- normals[in1 + 0] = normals[in2 + 0] = normals[in3 + 0] = normal.x;
149
- normals[in1 + 1] = normals[in2 + 1] = normals[in3 + 1] = normal.y;
150
- normals[in1 + 2] = normals[in2 + 2] = normals[in3 + 2] = normal.z;
151
- texCoords[iu1 + 0] = u1;
152
- texCoords[iu1 + 1] = v1;
153
- texCoords[iu2 + 0] = u2;
154
- texCoords[iu2 + 1] = v2;
155
- texCoords[iu3 + 0] = u3;
156
- texCoords[iu3 + 1] = v3;
157
- }
158
-
159
- return {
160
- indices: {
161
- size: 1,
162
- value: new Uint16Array(indices)
163
- },
164
- attributes: {
165
- POSITION: {
166
- size: 3,
167
- value: new Float32Array(positions)
168
- },
169
- NORMAL: {
170
- size: 3,
171
- value: new Float32Array(normals)
172
- },
173
- TEXCOORD_0: {
174
- size: 2,
175
- value: new Float32Array(texCoords)
176
- }
177
- }
178
- };
144
+ return {
145
+ indices: { size: 1, value: new Uint16Array(indices) },
146
+ attributes: {
147
+ POSITION: { size: 3, value: new Float32Array(positions) },
148
+ NORMAL: { size: 3, value: new Float32Array(normals) },
149
+ TEXCOORD_0: { size: 2, value: new Float32Array(texCoords) }
150
+ }
151
+ };
179
152
  }
180
- //# sourceMappingURL=ico-sphere-geometry.js.map
@@ -1,5 +1,5 @@
1
- import Geometry from '../geometry/geometry';
2
- export declare type PlaneGeometryProps = {
1
+ import { Geometry } from "../geometry/geometry.js";
2
+ export type PlaneGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
5
5
  attributes?: any;