@luma.gl/engine 9.0.0-beta.1 → 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 (154) hide show
  1. package/dist/animation/key-frames.js +54 -54
  2. package/dist/animation/timeline.d.ts.map +1 -1
  3. package/dist/animation/timeline.js +95 -100
  4. package/dist/animation-loop/animation-loop-template.d.ts +1 -1
  5. package/dist/animation-loop/animation-loop-template.d.ts.map +1 -1
  6. package/dist/animation-loop/animation-loop-template.js +19 -5
  7. package/dist/animation-loop/animation-loop.d.ts +2 -2
  8. package/dist/animation-loop/animation-loop.d.ts.map +1 -1
  9. package/dist/animation-loop/animation-loop.js +433 -356
  10. package/dist/animation-loop/animation-props.d.ts +2 -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 +2 -2
  14. package/dist/animation-loop/make-animation-loop.d.ts.map +1 -1
  15. package/dist/animation-loop/make-animation-loop.js +28 -24
  16. package/dist/computation.d.ts +95 -0
  17. package/dist/computation.d.ts.map +1 -0
  18. package/dist/computation.js +248 -0
  19. package/dist/debug/copy-texture-to-image.d.ts.map +1 -1
  20. package/dist/debug/copy-texture-to-image.js +39 -42
  21. package/dist/debug/debug-framebuffer.d.ts.map +1 -1
  22. package/dist/debug/debug-framebuffer.js +43 -40
  23. package/dist/debug/debug-shader-layout.js +24 -25
  24. package/dist/debug/pixel-data-utils.d.ts.map +1 -1
  25. package/dist/debug/pixel-data-utils.js +34 -36
  26. package/dist/dist.dev.js +2538 -3027
  27. package/dist/dist.min.js +102 -0
  28. package/dist/geometries/cone-geometry.d.ts +1 -1
  29. package/dist/geometries/cone-geometry.d.ts.map +1 -1
  30. package/dist/geometries/cone-geometry.js +11 -17
  31. package/dist/geometries/cube-geometry.d.ts +1 -1
  32. package/dist/geometries/cube-geometry.d.ts.map +1 -1
  33. package/dist/geometries/cube-geometry.js +190 -61
  34. package/dist/geometries/cylinder-geometry.d.ts +1 -1
  35. package/dist/geometries/cylinder-geometry.d.ts.map +1 -1
  36. package/dist/geometries/cylinder-geometry.js +9 -14
  37. package/dist/geometries/ico-sphere-geometry.d.ts +1 -1
  38. package/dist/geometries/ico-sphere-geometry.d.ts.map +1 -1
  39. package/dist/geometries/ico-sphere-geometry.js +141 -160
  40. package/dist/geometries/plane-geometry.d.ts +1 -1
  41. package/dist/geometries/plane-geometry.d.ts.map +1 -1
  42. package/dist/geometries/plane-geometry.js +92 -110
  43. package/dist/geometries/sphere-geometry.d.ts +1 -1
  44. package/dist/geometries/sphere-geometry.d.ts.map +1 -1
  45. package/dist/geometries/sphere-geometry.js +76 -95
  46. package/dist/geometries/truncated-cone-geometry.d.ts +1 -1
  47. package/dist/geometries/truncated-cone-geometry.d.ts.map +1 -1
  48. package/dist/geometries/truncated-cone-geometry.js +99 -117
  49. package/dist/geometry/geometry-table.d.ts.map +1 -1
  50. package/dist/geometry/geometry-table.js +3 -1
  51. package/dist/geometry/geometry-utils.js +35 -32
  52. package/dist/geometry/geometry.d.ts.map +1 -1
  53. package/dist/geometry/geometry.js +80 -71
  54. package/dist/geometry/gpu-geometry.d.ts +1 -1
  55. package/dist/geometry/gpu-geometry.d.ts.map +1 -1
  56. package/dist/geometry/gpu-geometry.js +79 -99
  57. package/dist/geometry/gpu-table.js +41 -1
  58. package/dist/index.cjs +725 -409
  59. package/dist/index.cjs.map +7 -0
  60. package/dist/index.d.ts +43 -40
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.js +6 -1
  63. package/dist/lib/clip-space.d.ts +2 -2
  64. package/dist/lib/clip-space.d.ts.map +1 -1
  65. package/dist/lib/clip-space.js +28 -34
  66. package/dist/lib/pipeline-factory.d.ts +13 -14
  67. package/dist/lib/pipeline-factory.d.ts.map +1 -1
  68. package/dist/lib/pipeline-factory.js +86 -85
  69. package/dist/lib/shader-factory.d.ts +17 -0
  70. package/dist/lib/shader-factory.d.ts.map +1 -0
  71. package/dist/lib/shader-factory.js +46 -0
  72. package/dist/model/model.d.ts +59 -46
  73. package/dist/model/model.d.ts.map +1 -1
  74. package/dist/model/model.js +635 -411
  75. package/dist/scenegraph/group-node.d.ts +1 -1
  76. package/dist/scenegraph/group-node.d.ts.map +1 -1
  77. package/dist/scenegraph/group-node.js +73 -83
  78. package/dist/scenegraph/model-node.d.ts +3 -3
  79. package/dist/scenegraph/model-node.d.ts.map +1 -1
  80. package/dist/scenegraph/model-node.js +31 -24
  81. package/dist/scenegraph/scenegraph-node.d.ts.map +1 -1
  82. package/dist/scenegraph/scenegraph-node.js +136 -124
  83. package/dist/shader-inputs.d.ts.map +1 -1
  84. package/dist/shader-inputs.js +99 -58
  85. package/dist/transform/buffer-transform.d.ts +1 -1
  86. package/dist/transform/buffer-transform.d.ts.map +1 -1
  87. package/dist/transform/buffer-transform.js +65 -57
  88. package/dist/transform/texture-transform.d.ts +1 -1
  89. package/dist/transform/texture-transform.d.ts.map +1 -1
  90. package/dist/transform/texture-transform.js +109 -114
  91. package/dist.min.js +3 -271
  92. package/package.json +10 -9
  93. package/src/animation/timeline.ts +20 -20
  94. package/src/animation-loop/animation-loop-template.ts +10 -8
  95. package/src/animation-loop/animation-loop.ts +20 -10
  96. package/src/animation-loop/animation-props.ts +1 -1
  97. package/src/animation-loop/make-animation-loop.ts +17 -8
  98. package/src/computation.ts +346 -0
  99. package/src/debug/copy-texture-to-image.ts +9 -11
  100. package/src/debug/debug-framebuffer.ts +16 -3
  101. package/src/debug/debug-shader-layout.ts +1 -1
  102. package/src/debug/pixel-data-utils.ts +3 -6
  103. package/src/geometries/cube-geometry.ts +17 -13
  104. package/src/geometries/ico-sphere-geometry.ts +1 -1
  105. package/src/geometries/plane-geometry.ts +1 -1
  106. package/src/geometries/sphere-geometry.ts +1 -1
  107. package/src/geometries/truncated-cone-geometry.ts +2 -1
  108. package/src/geometry/geometry-table.ts +9 -6
  109. package/src/geometry/geometry-utils.ts +16 -0
  110. package/src/geometry/geometry.ts +9 -6
  111. package/src/geometry/gpu-geometry.ts +18 -11
  112. package/src/index.ts +4 -1
  113. package/src/lib/clip-space.ts +16 -19
  114. package/src/lib/pipeline-factory.ts +71 -64
  115. package/src/lib/shader-factory.ts +57 -0
  116. package/src/model/model.ts +255 -146
  117. package/src/scenegraph/group-node.ts +14 -10
  118. package/src/scenegraph/model-node.ts +2 -2
  119. package/src/scenegraph/scenegraph-node.ts +2 -2
  120. package/src/shader-inputs.ts +19 -12
  121. package/src/transform/buffer-transform.ts +16 -8
  122. package/src/transform/texture-transform.ts +14 -15
  123. package/dist/animation/key-frames.js.map +0 -1
  124. package/dist/animation/timeline.js.map +0 -1
  125. package/dist/animation-loop/animation-loop-template.js.map +0 -1
  126. package/dist/animation-loop/animation-loop.js.map +0 -1
  127. package/dist/animation-loop/animation-props.js.map +0 -1
  128. package/dist/animation-loop/make-animation-loop.js.map +0 -1
  129. package/dist/debug/copy-texture-to-image.js.map +0 -1
  130. package/dist/debug/debug-framebuffer.js.map +0 -1
  131. package/dist/debug/debug-shader-layout.js.map +0 -1
  132. package/dist/debug/pixel-data-utils.js.map +0 -1
  133. package/dist/geometries/cone-geometry.js.map +0 -1
  134. package/dist/geometries/cube-geometry.js.map +0 -1
  135. package/dist/geometries/cylinder-geometry.js.map +0 -1
  136. package/dist/geometries/ico-sphere-geometry.js.map +0 -1
  137. package/dist/geometries/plane-geometry.js.map +0 -1
  138. package/dist/geometries/sphere-geometry.js.map +0 -1
  139. package/dist/geometries/truncated-cone-geometry.js.map +0 -1
  140. package/dist/geometry/geometry-table.js.map +0 -1
  141. package/dist/geometry/geometry-utils.js.map +0 -1
  142. package/dist/geometry/geometry.js.map +0 -1
  143. package/dist/geometry/gpu-geometry.js.map +0 -1
  144. package/dist/geometry/gpu-table.js.map +0 -1
  145. package/dist/index.js.map +0 -1
  146. package/dist/lib/clip-space.js.map +0 -1
  147. package/dist/lib/pipeline-factory.js.map +0 -1
  148. package/dist/model/model.js.map +0 -1
  149. package/dist/scenegraph/group-node.js.map +0 -1
  150. package/dist/scenegraph/model-node.js.map +0 -1
  151. package/dist/scenegraph/scenegraph-node.js.map +0 -1
  152. package/dist/shader-inputs.js.map +0 -1
  153. package/dist/transform/buffer-transform.js.map +0 -1
  154. package/dist/transform/texture-transform.js.map +0 -1
@@ -1,69 +1,198 @@
1
1
  import { uid } from '@luma.gl/core';
2
2
  import { Geometry } from "../geometry/geometry.js";
3
3
  export class CubeGeometry extends Geometry {
4
- constructor() {
5
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
- const {
7
- id = uid('cube-geometry'),
8
- indices = true
9
- } = props;
10
- super(indices ? {
11
- ...props,
12
- id,
13
- topology: 'triangle-list',
14
- indices: {
15
- size: 1,
16
- value: CUBE_INDICES
17
- },
18
- attributes: {
19
- ...ATTRIBUTES,
20
- ...props.attributes
21
- }
22
- } : {
23
- ...props,
24
- id,
25
- topology: 'triangle-list',
26
- indices: undefined,
27
- attributes: {
28
- ...NON_INDEXED_ATTRIBUTES,
29
- ...props.attributes
30
- }
31
- });
32
- }
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
+ }
33
22
  }
34
- 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]);
35
- 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]);
36
- 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]);
37
- 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]);
38
- 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]);
39
- 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]);
40
- 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
+ ]);
41
188
  const ATTRIBUTES = {
42
- POSITION: {
43
- size: 3,
44
- value: CUBE_POSITIONS
45
- },
46
- NORMAL: {
47
- size: 3,
48
- value: CUBE_NORMALS
49
- },
50
- TEXCOORD_0: {
51
- size: 2,
52
- value: CUBE_TEX_COORDS
53
- }
189
+ POSITION: { size: 3, value: CUBE_POSITIONS },
190
+ NORMAL: { size: 3, value: CUBE_NORMALS },
191
+ TEXCOORD_0: { size: 2, value: CUBE_TEX_COORDS }
54
192
  };
55
193
  const NON_INDEXED_ATTRIBUTES = {
56
- POSITION: {
57
- size: 3,
58
- value: CUBE_NON_INDEXED_POSITIONS
59
- },
60
- TEXCOORD_0: {
61
- size: 2,
62
- value: CUBE_NON_INDEXED_TEX_COORDS
63
- },
64
- COLOR_0: {
65
- size: 3,
66
- value: CUBE_NON_INDEXED_COLORS
67
- }
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 }
68
198
  };
69
- //# sourceMappingURL=cube-geometry.js.map
@@ -1,4 +1,4 @@
1
- import { TruncatedConeGeometry } from './truncated-cone-geometry';
1
+ import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
2
2
  export type CylinderGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
@@ -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,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
+ {"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,18 +1,13 @@
1
1
  import { uid } from '@luma.gl/core';
2
2
  import { TruncatedConeGeometry } from "./truncated-cone-geometry.js";
3
3
  export class CylinderGeometry extends TruncatedConeGeometry {
4
- constructor() {
5
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
6
- const {
7
- id = uid('cylinder-geometry'),
8
- radius = 1
9
- } = props;
10
- super({
11
- ...props,
12
- id,
13
- bottomRadius: radius,
14
- topRadius: radius
15
- });
16
- }
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
+ }
17
13
  }
18
- //# sourceMappingURL=cylinder-geometry.js.map
@@ -1,4 +1,4 @@
1
- import { Geometry } from '../geometry/geometry';
1
+ import { Geometry } from "../geometry/geometry.js";
2
2
  export type IcoSphereGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"ico-sphere-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/ico-sphere-geometry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;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,CAAA;CACjB,CAAC;AAEF,qBAAa,iBAAkB,SAAQ,QAAQ;gBACjC,KAAK,GAAE,sBAA2B;CAW/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,171 +1,152 @@
1
1
  import { uid } from '@luma.gl/core';
2
2
  import { Vector3 } from '@math.gl/core';
3
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() {
8
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
9
- const {
10
- id = uid('ico-sphere-geometry')
11
- } = props;
12
- const {
13
- indices,
14
- attributes
15
- } = tesselateIcosaHedron(props);
16
- super({
17
- ...props,
18
- id,
19
- topology: 'triangle-list',
20
- indices,
21
- attributes: {
22
- ...attributes,
23
- ...props.attributes
24
- }
25
- });
26
- }
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
+ }
27
19
  }
28
20
  function tesselateIcosaHedron(props) {
29
- const {
30
- iterations = 0
31
- } = props;
32
- const PI = Math.PI;
33
- const PI2 = PI * 2;
34
- const positions = [...ICO_POSITIONS];
35
- let indices = [...ICO_INDICES];
36
- positions.push();
37
- indices.push();
38
- const getMiddlePoint = (() => {
39
- const pointMemo = {};
40
- return (i1, i2) => {
41
- i1 *= 3;
42
- i2 *= 3;
43
- const mini = i1 < i2 ? i1 : i2;
44
- const maxi = i1 > i2 ? i1 : i2;
45
- const key = `${mini}|${maxi}`;
46
- if (key in pointMemo) {
47
- return pointMemo[key];
48
- }
49
- const x1 = positions[i1];
50
- const y1 = positions[i1 + 1];
51
- const z1 = positions[i1 + 2];
52
- const x2 = positions[i2];
53
- const y2 = positions[i2 + 1];
54
- const z2 = positions[i2 + 2];
55
- let xm = (x1 + x2) / 2;
56
- let ym = (y1 + y2) / 2;
57
- let zm = (z1 + z2) / 2;
58
- const len = Math.sqrt(xm * xm + ym * ym + zm * zm);
59
- xm /= len;
60
- ym /= len;
61
- zm /= len;
62
- positions.push(xm, ym, zm);
63
- return pointMemo[key] = positions.length / 3 - 1;
64
- };
65
- })();
66
- for (let i = 0; i < iterations; i++) {
67
- const indices2 = [];
68
- for (let j = 0; j < indices.length; j += 3) {
69
- const a = getMiddlePoint(indices[j + 0], indices[j + 1]);
70
- const b = getMiddlePoint(indices[j + 1], indices[j + 2]);
71
- const c = getMiddlePoint(indices[j + 2], indices[j + 0]);
72
- 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;
73
65
  }
74
- indices = indices2;
75
- }
76
- const normals = new Array(positions.length);
77
- const texCoords = new Array(positions.length / 3 * 2);
78
- const l = indices.length;
79
- for (let i = l - 3; i >= 0; i -= 3) {
80
- const i1 = indices[i + 0];
81
- const i2 = indices[i + 1];
82
- const i3 = indices[i + 2];
83
- const in1 = i1 * 3;
84
- const in2 = i2 * 3;
85
- const in3 = i3 * 3;
86
- const iu1 = i1 * 2;
87
- const iu2 = i2 * 2;
88
- const iu3 = i3 * 2;
89
- const x1 = positions[in1 + 0];
90
- const y1 = positions[in1 + 1];
91
- const z1 = positions[in1 + 2];
92
- const theta1 = Math.acos(z1 / Math.sqrt(x1 * x1 + y1 * y1 + z1 * z1));
93
- const phi1 = Math.atan2(y1, x1) + PI;
94
- const v1 = theta1 / PI;
95
- const u1 = 1 - phi1 / PI2;
96
- const x2 = positions[in2 + 0];
97
- const y2 = positions[in2 + 1];
98
- const z2 = positions[in2 + 2];
99
- const theta2 = Math.acos(z2 / Math.sqrt(x2 * x2 + y2 * y2 + z2 * z2));
100
- const phi2 = Math.atan2(y2, x2) + PI;
101
- const v2 = theta2 / PI;
102
- const u2 = 1 - phi2 / PI2;
103
- const x3 = positions[in3 + 0];
104
- const y3 = positions[in3 + 1];
105
- const z3 = positions[in3 + 2];
106
- const theta3 = Math.acos(z3 / Math.sqrt(x3 * x3 + y3 * y3 + z3 * z3));
107
- const phi3 = Math.atan2(y3, x3) + PI;
108
- const v3 = theta3 / PI;
109
- const u3 = 1 - phi3 / PI2;
110
- const vec1 = [x3 - x2, y3 - y2, z3 - z2];
111
- const vec2 = [x1 - x2, y1 - y2, z1 - z2];
112
- const normal = new Vector3(vec1).cross(vec2).normalize();
113
- let newIndex;
114
- if ((u1 === 0 || u2 === 0 || u3 === 0) && (u1 === 0 || u1 > 0.5) && (u2 === 0 || u2 > 0.5) && (u3 === 0 || u3 > 0.5)) {
115
- positions.push(positions[in1 + 0], positions[in1 + 1], positions[in1 + 2]);
116
- newIndex = positions.length / 3 - 1;
117
- indices.push(newIndex);
118
- texCoords[newIndex * 2 + 0] = 1;
119
- texCoords[newIndex * 2 + 1] = v1;
120
- normals[newIndex * 3 + 0] = normal.x;
121
- normals[newIndex * 3 + 1] = normal.y;
122
- normals[newIndex * 3 + 2] = normal.z;
123
- positions.push(positions[in2 + 0], positions[in2 + 1], positions[in2 + 2]);
124
- newIndex = positions.length / 3 - 1;
125
- indices.push(newIndex);
126
- texCoords[newIndex * 2 + 0] = 1;
127
- texCoords[newIndex * 2 + 1] = v2;
128
- normals[newIndex * 3 + 0] = normal.x;
129
- normals[newIndex * 3 + 1] = normal.y;
130
- normals[newIndex * 3 + 2] = normal.z;
131
- positions.push(positions[in3 + 0], positions[in3 + 1], positions[in3 + 2]);
132
- newIndex = positions.length / 3 - 1;
133
- indices.push(newIndex);
134
- texCoords[newIndex * 2 + 0] = 1;
135
- texCoords[newIndex * 2 + 1] = v3;
136
- normals[newIndex * 3 + 0] = normal.x;
137
- normals[newIndex * 3 + 1] = normal.y;
138
- 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;
139
143
  }
140
- normals[in1 + 0] = normals[in2 + 0] = normals[in3 + 0] = normal.x;
141
- normals[in1 + 1] = normals[in2 + 1] = normals[in3 + 1] = normal.y;
142
- normals[in1 + 2] = normals[in2 + 2] = normals[in3 + 2] = normal.z;
143
- texCoords[iu1 + 0] = u1;
144
- texCoords[iu1 + 1] = v1;
145
- texCoords[iu2 + 0] = u2;
146
- texCoords[iu2 + 1] = v2;
147
- texCoords[iu3 + 0] = u3;
148
- texCoords[iu3 + 1] = v3;
149
- }
150
- return {
151
- indices: {
152
- size: 1,
153
- value: new Uint16Array(indices)
154
- },
155
- attributes: {
156
- POSITION: {
157
- size: 3,
158
- value: new Float32Array(positions)
159
- },
160
- NORMAL: {
161
- size: 3,
162
- value: new Float32Array(normals)
163
- },
164
- TEXCOORD_0: {
165
- size: 2,
166
- value: new Float32Array(texCoords)
167
- }
168
- }
169
- };
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
+ };
170
152
  }
171
- //# sourceMappingURL=ico-sphere-geometry.js.map
@@ -1,4 +1,4 @@
1
- import { Geometry } from '../geometry/geometry';
1
+ import { Geometry } from "../geometry/geometry.js";
2
2
  export type PlaneGeometryProps = {
3
3
  id?: string;
4
4
  radius?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"plane-geometry.d.ts","sourceRoot":"","sources":["../../src/geometries/plane-geometry.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAG9C,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,GAAG,CAAA;CACjB,CAAC;AAKF,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,KAAK,GAAE,kBAAuB;CAY3C"}
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"}