@holoscript/core 6.0.3 → 7.0.0

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 (244) hide show
  1. package/README.md +40 -40
  2. package/dist/codebase/index.d.ts +25 -0
  3. package/dist/compiler/index.d.ts +82 -0
  4. package/dist/constants.d.ts +4 -0
  5. package/dist/coordinators/index.d.ts +189 -0
  6. package/dist/entries/interop.d.ts +9 -0
  7. package/dist/entries/scripting.d.ts +7 -0
  8. package/dist/index.d.ts +520 -19
  9. package/dist/paper-0c-spike/index.d.ts +29 -0
  10. package/dist/reconstruction/index.d.ts +78 -0
  11. package/dist/self-improvement/index.d.ts +0 -48
  12. package/dist/storage/index.d.ts +24 -0
  13. package/dist/tools/index.d.ts +33 -0
  14. package/dist/traitDocs/traitDocs.d.ts +69 -0
  15. package/dist/traits/index.d.ts +61 -0
  16. package/package.json +102 -19
  17. package/dist/GLTFPipeline-3KLWWUQO.cjs +0 -34
  18. package/dist/GLTFPipeline-LYII2ZVQ.js +0 -13
  19. package/dist/HoloScriptPlusParser-BZR5DELQ.js +0 -692
  20. package/dist/HoloScriptPlusParser-SBMYDNXO.cjs +0 -697
  21. package/dist/USDZExporter-MHEHXZB4.cjs +0 -709
  22. package/dist/USDZExporter-YA55ZS35.js +0 -707
  23. package/dist/chunk-26TLYBFD.js +0 -309
  24. package/dist/chunk-27LWW5FU.cjs +0 -410
  25. package/dist/chunk-2UX5LRAP.cjs +0 -833
  26. package/dist/chunk-32TWR3HE.js +0 -70
  27. package/dist/chunk-3FXV5S25.cjs +0 -633
  28. package/dist/chunk-3FYZOR7S.cjs +0 -69
  29. package/dist/chunk-3KEU5QYY.cjs +0 -175
  30. package/dist/chunk-4FCZDTD5.js +0 -610
  31. package/dist/chunk-4KJ2R7VP.cjs +0 -507
  32. package/dist/chunk-4SMUJFHL.js +0 -1213
  33. package/dist/chunk-54FHG2MX.js +0 -655
  34. package/dist/chunk-56IF4NTA.js +0 -56
  35. package/dist/chunk-5GLCTO44.js +0 -161
  36. package/dist/chunk-5TOFIR6L.js +0 -407
  37. package/dist/chunk-65RFOWZI.js +0 -765
  38. package/dist/chunk-6OQBLABR.js +0 -5240
  39. package/dist/chunk-6WNCRE6F.js +0 -126
  40. package/dist/chunk-74YCHHTE.js +0 -1872
  41. package/dist/chunk-7H5UNJZD.cjs +0 -1973
  42. package/dist/chunk-7KPI4EKH.cjs +0 -701
  43. package/dist/chunk-7LCYLPW2.cjs +0 -663
  44. package/dist/chunk-7N3JIJMT.js +0 -1395
  45. package/dist/chunk-7X2IEJIE.cjs +0 -2526
  46. package/dist/chunk-A6GO3DPZ.cjs +0 -1002
  47. package/dist/chunk-AC4BSHFV.js +0 -765
  48. package/dist/chunk-AIUXRS74.cjs +0 -3681
  49. package/dist/chunk-ARNKA274.cjs +0 -130
  50. package/dist/chunk-AW7WAELW.js +0 -975
  51. package/dist/chunk-BKIGPPVM.js +0 -629
  52. package/dist/chunk-BO2OKHIY.js +0 -6055
  53. package/dist/chunk-BU5ZAFMC.js +0 -115
  54. package/dist/chunk-BY3B7ZYV.cjs +0 -457
  55. package/dist/chunk-C2QHVHZF.js +0 -4066
  56. package/dist/chunk-C7BNX4XJ.js +0 -1043
  57. package/dist/chunk-CLYEIWA5.cjs +0 -408
  58. package/dist/chunk-CMYAWUX3.js +0 -4455
  59. package/dist/chunk-CN4NOESF.cjs +0 -416
  60. package/dist/chunk-CNVM7J3M.js +0 -883
  61. package/dist/chunk-CO2VM2DK.js +0 -1965
  62. package/dist/chunk-CQDOF3G7.cjs +0 -1404
  63. package/dist/chunk-DH5G2JUA.cjs +0 -614
  64. package/dist/chunk-DIEDKX5B.cjs +0 -660
  65. package/dist/chunk-DN7UFU63.cjs +0 -172
  66. package/dist/chunk-DXVCEFZB.js +0 -2027
  67. package/dist/chunk-EGIZHYJP.cjs +0 -85
  68. package/dist/chunk-EJA7G2C4.cjs +0 -428
  69. package/dist/chunk-ELLQPFAF.js +0 -830
  70. package/dist/chunk-EMO7HAKJ.cjs +0 -1875
  71. package/dist/chunk-ENV7K6XA.js +0 -282
  72. package/dist/chunk-EPWRXL6S.js +0 -2522
  73. package/dist/chunk-EUFLX2PI.js +0 -56956
  74. package/dist/chunk-F5LVGHNT.js +0 -449
  75. package/dist/chunk-FEFHPUEM.cjs +0 -6122
  76. package/dist/chunk-FF3Q7ADR.js +0 -380
  77. package/dist/chunk-GC3YU46J.js +0 -762
  78. package/dist/chunk-H6WMMLQK.cjs +0 -4492
  79. package/dist/chunk-H7XMORZI.js +0 -2731
  80. package/dist/chunk-HAN4V3PF.cjs +0 -2037
  81. package/dist/chunk-HBZYCASG.js +0 -4208
  82. package/dist/chunk-HF4OFY25.cjs +0 -4097
  83. package/dist/chunk-HHS6FMOU.cjs +0 -3813
  84. package/dist/chunk-HJJLD366.js +0 -1169
  85. package/dist/chunk-HKCVM6OK.cjs +0 -2237
  86. package/dist/chunk-HUFNKFA6.js +0 -698
  87. package/dist/chunk-I3XGTIHM.cjs +0 -1505
  88. package/dist/chunk-I6XZ5DZF.cjs +0 -488
  89. package/dist/chunk-IHOUYQIA.js +0 -406
  90. package/dist/chunk-ILRBGFVD.cjs +0 -72
  91. package/dist/chunk-KDB6BUMB.js +0 -3666
  92. package/dist/chunk-KUJRR4FJ.js +0 -657
  93. package/dist/chunk-KYM4XRFG.js +0 -421
  94. package/dist/chunk-L3Z2HIWJ.cjs +0 -793
  95. package/dist/chunk-LBPEZQAF.js +0 -2232
  96. package/dist/chunk-LER4WXW5.cjs +0 -286
  97. package/dist/chunk-LK5IAVH6.cjs +0 -1173
  98. package/dist/chunk-M6FU6S22.js +0 -2911
  99. package/dist/chunk-MWEFR6YQ.js +0 -1857
  100. package/dist/chunk-N5FTS757.cjs +0 -415
  101. package/dist/chunk-NCUHGRTZ.js +0 -752
  102. package/dist/chunk-NKRKT6V2.js +0 -69
  103. package/dist/chunk-NLPSZT4C.js +0 -630
  104. package/dist/chunk-NRUB55IT.cjs +0 -771
  105. package/dist/chunk-NTMZSDXM.cjs +0 -633
  106. package/dist/chunk-ODGMVILH.js +0 -9662
  107. package/dist/chunk-PBA6NXCT.cjs +0 -1216
  108. package/dist/chunk-PHENW4MQ.js +0 -65
  109. package/dist/chunk-PJMOXFPR.cjs +0 -1861
  110. package/dist/chunk-PLMYCCA4.js +0 -504
  111. package/dist/chunk-PPULB4GG.cjs +0 -9728
  112. package/dist/chunk-PQLGZKMC.cjs +0 -755
  113. package/dist/chunk-Q56TT7IL.js +0 -483
  114. package/dist/chunk-QHVVVN47.cjs +0 -2033
  115. package/dist/chunk-QWKUKVRE.js +0 -2026
  116. package/dist/chunk-RE3OKSYF.cjs +0 -424
  117. package/dist/chunk-RT7LJRSF.cjs +0 -57378
  118. package/dist/chunk-SPDELRRV.cjs +0 -319
  119. package/dist/chunk-SUCBB66F.js +0 -229
  120. package/dist/chunk-TSWTWZ42.cjs +0 -4214
  121. package/dist/chunk-UITWA6DV.cjs +0 -2829
  122. package/dist/chunk-UQW6SLM5.js +0 -172
  123. package/dist/chunk-V2ILLPHK.cjs +0 -237
  124. package/dist/chunk-V42NTCFH.js +0 -3645
  125. package/dist/chunk-VJ3L7CHT.cjs +0 -169
  126. package/dist/chunk-VJVCD5T5.cjs +0 -769
  127. package/dist/chunk-VK5AXKO3.js +0 -746
  128. package/dist/chunk-VSXOIUCF.cjs +0 -473
  129. package/dist/chunk-VZNKJZTT.cjs +0 -749
  130. package/dist/chunk-W76ETJTI.js +0 -678
  131. package/dist/chunk-WFJIDI2N.cjs +0 -424
  132. package/dist/chunk-WN3YF33G.cjs +0 -118
  133. package/dist/chunk-WUXIRGZP.cjs +0 -2915
  134. package/dist/chunk-WYH4GVZ5.js +0 -1488
  135. package/dist/chunk-X4YVN7H3.cjs +0 -888
  136. package/dist/chunk-X67XRI2T.js +0 -410
  137. package/dist/chunk-XDXZM3ZP.cjs +0 -1046
  138. package/dist/chunk-XH7SE4HH.cjs +0 -72
  139. package/dist/chunk-XNMEH2BI.js +0 -126
  140. package/dist/chunk-XSF76QRU.js +0 -468
  141. package/dist/chunk-XSUZMPVQ.cjs +0 -682
  142. package/dist/chunk-XUILI4KB.cjs +0 -430
  143. package/dist/chunk-Y5MUAYTO.js +0 -167
  144. package/dist/chunk-Y7VK5TH3.cjs +0 -129
  145. package/dist/chunk-YCMQQQ5U.cjs +0 -5244
  146. package/dist/chunk-YYXH45E2.js +0 -426
  147. package/dist/chunk-ZGTGVSTZ.js +0 -422
  148. package/dist/chunk-ZL6VJ6SN.js +0 -421
  149. package/dist/cli/holoscript-runner.cjs +0 -2258
  150. package/dist/cli/holoscript-runner.js +0 -2233
  151. package/dist/codebase/index.cjs +0 -336
  152. package/dist/codebase/index.js +0 -331
  153. package/dist/compiler/agent-inference.cjs +0 -29
  154. package/dist/compiler/agent-inference.js +0 -6
  155. package/dist/compiler/android-xr.cjs +0 -20
  156. package/dist/compiler/android-xr.js +0 -10
  157. package/dist/compiler/android.cjs +0 -21
  158. package/dist/compiler/android.js +0 -11
  159. package/dist/compiler/ar.cjs +0 -21
  160. package/dist/compiler/ar.js +0 -9
  161. package/dist/compiler/babylon.cjs +0 -18
  162. package/dist/compiler/babylon.js +0 -12
  163. package/dist/compiler/coco.cjs +0 -27
  164. package/dist/compiler/coco.js +0 -4
  165. package/dist/compiler/domain-block-utils.cjs +0 -595
  166. package/dist/compiler/domain-block-utils.js +0 -9
  167. package/dist/compiler/dtdl.cjs +0 -25
  168. package/dist/compiler/dtdl.js +0 -9
  169. package/dist/compiler/gltf-pipeline.cjs +0 -39
  170. package/dist/compiler/gltf-pipeline.js +0 -4
  171. package/dist/compiler/godot.cjs +0 -16
  172. package/dist/compiler/godot.js +0 -10
  173. package/dist/compiler/incremental.cjs +0 -30
  174. package/dist/compiler/incremental.js +0 -5
  175. package/dist/compiler/index.cjs +0 -1522
  176. package/dist/compiler/index.js +0 -1321
  177. package/dist/compiler/ios.cjs +0 -21
  178. package/dist/compiler/ios.js +0 -11
  179. package/dist/compiler/multi-layer.cjs +0 -27
  180. package/dist/compiler/multi-layer.js +0 -12
  181. package/dist/compiler/nodetoy.cjs +0 -23
  182. package/dist/compiler/nodetoy.js +0 -4
  183. package/dist/compiler/openxr.cjs +0 -16
  184. package/dist/compiler/openxr.js +0 -10
  185. package/dist/compiler/playcanvas.cjs +0 -17
  186. package/dist/compiler/playcanvas.js +0 -11
  187. package/dist/compiler/r3f.cjs +0 -35
  188. package/dist/compiler/r3f.js +0 -13
  189. package/dist/compiler/remotion.cjs +0 -23
  190. package/dist/compiler/remotion.js +0 -4
  191. package/dist/compiler/reproducibility.cjs +0 -39
  192. package/dist/compiler/reproducibility.js +0 -4
  193. package/dist/compiler/sdf.cjs +0 -22
  194. package/dist/compiler/sdf.js +0 -10
  195. package/dist/compiler/semantic-scene.cjs +0 -31
  196. package/dist/compiler/semantic-scene.js +0 -4
  197. package/dist/compiler/state.cjs +0 -18
  198. package/dist/compiler/state.js +0 -8
  199. package/dist/compiler/trait-composition.cjs +0 -27
  200. package/dist/compiler/trait-composition.js +0 -6
  201. package/dist/compiler/unity.cjs +0 -16
  202. package/dist/compiler/unity.js +0 -10
  203. package/dist/compiler/unreal.cjs +0 -20
  204. package/dist/compiler/unreal.js +0 -10
  205. package/dist/compiler/urdf.cjs +0 -46
  206. package/dist/compiler/urdf.js +0 -10
  207. package/dist/compiler/usd-physics.cjs +0 -24
  208. package/dist/compiler/usd-physics.js +0 -7
  209. package/dist/compiler/visionos.cjs +0 -16
  210. package/dist/compiler/visionos.js +0 -10
  211. package/dist/compiler/vrchat.cjs +0 -20
  212. package/dist/compiler/vrchat.js +0 -10
  213. package/dist/compiler/vrr.cjs +0 -22
  214. package/dist/compiler/vrr.js +0 -10
  215. package/dist/compiler/wasm.cjs +0 -34
  216. package/dist/compiler/wasm.js +0 -10
  217. package/dist/compiler/webgpu.cjs +0 -16
  218. package/dist/compiler/webgpu.js +0 -10
  219. package/dist/debugger.cjs +0 -21
  220. package/dist/debugger.js +0 -8
  221. package/dist/entries/interop.cjs +0 -62
  222. package/dist/entries/interop.js +0 -5
  223. package/dist/entries/scripting.cjs +0 -67
  224. package/dist/entries/scripting.js +0 -10
  225. package/dist/index.cjs +0 -61703
  226. package/dist/index.js +0 -58652
  227. package/dist/math/vec3.cjs +0 -57
  228. package/dist/math/vec3.js +0 -4
  229. package/dist/parser.cjs +0 -26
  230. package/dist/parser.js +0 -9
  231. package/dist/playwright-7DTEQCBD.cjs +0 -98673
  232. package/dist/playwright-BIZXMLD2.js +0 -98660
  233. package/dist/post-quantum-JTTAAGO3.cjs +0 -6
  234. package/dist/post-quantum-RVPVDEPI.js +0 -4
  235. package/dist/runtime.cjs +0 -16
  236. package/dist/runtime.js +0 -7
  237. package/dist/storage/index.cjs +0 -37
  238. package/dist/storage/index.js +0 -4
  239. package/dist/traits/index.cjs +0 -14331
  240. package/dist/traits/index.js +0 -12126
  241. package/dist/type-checker.cjs +0 -18
  242. package/dist/type-checker.js +0 -5
  243. package/dist/wot/index.cjs +0 -29
  244. package/dist/wot/index.js +0 -4
@@ -1,1169 +0,0 @@
1
- import { vec3SubArray, vec3NormalizeInPlace, vec3CrossArray, vec3ScaleArray } from './chunk-56IF4NTA.js';
2
-
3
- // src/compiler/ProceduralGeometry.ts
4
- var LOD_PRESETS = {
5
- low: {
6
- hull: { resolution: 12, boundsPadding: 1.2 },
7
- spline: { radialSegments: 8, lengthSteps: 4 },
8
- membrane: { subdivisions: 3 }
9
- },
10
- medium: {
11
- hull: { resolution: 24, boundsPadding: 1.3 },
12
- spline: { radialSegments: 32, lengthSteps: 12 },
13
- membrane: { subdivisions: 8 }
14
- },
15
- high: {
16
- hull: { resolution: 48, boundsPadding: 1.4 },
17
- spline: { radialSegments: 64, lengthSteps: 24 },
18
- membrane: { subdivisions: 16 }
19
- }
20
- };
21
- function catmullRom(p0, p1, p2, p3, t) {
22
- const t2 = t * t;
23
- const t3 = t2 * t;
24
- const result = [];
25
- for (let i = 0; i < p0.length; i++) {
26
- result.push(
27
- 0.5 * (2 * p1[i] + (-p0[i] + p2[i]) * t + (2 * p0[i] - 5 * p1[i] + 4 * p2[i] - p3[i]) * t2 + (-p0[i] + 3 * p1[i] - 3 * p2[i] + p3[i]) * t3)
28
- );
29
- }
30
- return result;
31
- }
32
- function fallbackBox() {
33
- const s = 0.5;
34
- const positions = new Float32Array([
35
- // Front
36
- -s,
37
- -s,
38
- s,
39
- s,
40
- -s,
41
- s,
42
- s,
43
- s,
44
- s,
45
- -s,
46
- s,
47
- s,
48
- // Back
49
- s,
50
- -s,
51
- -s,
52
- -s,
53
- -s,
54
- -s,
55
- -s,
56
- s,
57
- -s,
58
- s,
59
- s,
60
- -s,
61
- // Top
62
- -s,
63
- s,
64
- s,
65
- s,
66
- s,
67
- s,
68
- s,
69
- s,
70
- -s,
71
- -s,
72
- s,
73
- -s,
74
- // Bottom
75
- -s,
76
- -s,
77
- -s,
78
- s,
79
- -s,
80
- -s,
81
- s,
82
- -s,
83
- s,
84
- -s,
85
- -s,
86
- s,
87
- // Right
88
- s,
89
- -s,
90
- s,
91
- s,
92
- -s,
93
- -s,
94
- s,
95
- s,
96
- -s,
97
- s,
98
- s,
99
- s,
100
- // Left
101
- -s,
102
- -s,
103
- -s,
104
- -s,
105
- -s,
106
- s,
107
- -s,
108
- s,
109
- s,
110
- -s,
111
- s,
112
- -s
113
- ]);
114
- const normals = new Float32Array([
115
- 0,
116
- 0,
117
- 1,
118
- 0,
119
- 0,
120
- 1,
121
- 0,
122
- 0,
123
- 1,
124
- 0,
125
- 0,
126
- 1,
127
- 0,
128
- 0,
129
- -1,
130
- 0,
131
- 0,
132
- -1,
133
- 0,
134
- 0,
135
- -1,
136
- 0,
137
- 0,
138
- -1,
139
- 0,
140
- 1,
141
- 0,
142
- 0,
143
- 1,
144
- 0,
145
- 0,
146
- 1,
147
- 0,
148
- 0,
149
- 1,
150
- 0,
151
- 0,
152
- -1,
153
- 0,
154
- 0,
155
- -1,
156
- 0,
157
- 0,
158
- -1,
159
- 0,
160
- 0,
161
- -1,
162
- 0,
163
- 1,
164
- 0,
165
- 0,
166
- 1,
167
- 0,
168
- 0,
169
- 1,
170
- 0,
171
- 0,
172
- 1,
173
- 0,
174
- 0,
175
- -1,
176
- 0,
177
- 0,
178
- -1,
179
- 0,
180
- 0,
181
- -1,
182
- 0,
183
- 0,
184
- -1,
185
- 0,
186
- 0
187
- ]);
188
- const uvs = new Float32Array([
189
- 0,
190
- 0,
191
- 1,
192
- 0,
193
- 1,
194
- 1,
195
- 0,
196
- 1,
197
- 0,
198
- 0,
199
- 1,
200
- 0,
201
- 1,
202
- 1,
203
- 0,
204
- 1,
205
- 0,
206
- 0,
207
- 1,
208
- 0,
209
- 1,
210
- 1,
211
- 0,
212
- 1,
213
- 0,
214
- 0,
215
- 1,
216
- 0,
217
- 1,
218
- 1,
219
- 0,
220
- 1,
221
- 0,
222
- 0,
223
- 1,
224
- 0,
225
- 1,
226
- 1,
227
- 0,
228
- 1,
229
- 0,
230
- 0,
231
- 1,
232
- 0,
233
- 1,
234
- 1,
235
- 0,
236
- 1
237
- ]);
238
- const indices = new Uint16Array([
239
- 0,
240
- 1,
241
- 2,
242
- 0,
243
- 2,
244
- 3,
245
- 4,
246
- 5,
247
- 6,
248
- 4,
249
- 6,
250
- 7,
251
- 8,
252
- 9,
253
- 10,
254
- 8,
255
- 10,
256
- 11,
257
- 12,
258
- 13,
259
- 14,
260
- 12,
261
- 14,
262
- 15,
263
- 16,
264
- 17,
265
- 18,
266
- 16,
267
- 18,
268
- 19,
269
- 20,
270
- 21,
271
- 22,
272
- 20,
273
- 22,
274
- 23
275
- ]);
276
- return { positions, normals, uvs, indices };
277
- }
278
- function generateSplineGeometry(points, radii, radialSegments = 32, lengthSteps = 12, lod) {
279
- if (lod) {
280
- const preset = LOD_PRESETS[lod].spline;
281
- radialSegments = preset.radialSegments;
282
- lengthSteps = preset.lengthSteps;
283
- }
284
- if (points.length < 2) return fallbackBox();
285
- const positions = [];
286
- const normals = [];
287
- const uvs = [];
288
- const indices = [];
289
- const pathPoints = [];
290
- const pathRadii = [];
291
- const numSegments = points.length - 1;
292
- for (let seg = 0; seg < numSegments; seg++) {
293
- const p0 = points[Math.max(0, seg - 1)];
294
- const p1 = points[seg];
295
- const p2 = points[Math.min(points.length - 1, seg + 1)];
296
- const p3 = points[Math.min(points.length - 1, seg + 2)];
297
- const r1 = radii[seg] ?? radii[radii.length - 1] ?? 0.1;
298
- const r2 = radii[seg + 1] ?? radii[radii.length - 1] ?? 0.1;
299
- const steps = seg === numSegments - 1 ? lengthSteps + 1 : lengthSteps;
300
- for (let i = 0; i < steps; i++) {
301
- const t = i / lengthSteps;
302
- pathPoints.push(catmullRom(p0, p1, p2, p3, t));
303
- pathRadii.push(r1 + (r2 - r1) * t);
304
- }
305
- }
306
- const totalRings = pathPoints.length;
307
- let prevNormal = [0, 0, 0];
308
- for (let ring = 0; ring < totalRings; ring++) {
309
- const p = pathPoints[ring];
310
- const radius = pathRadii[ring];
311
- const v = ring / (totalRings - 1);
312
- let tangent;
313
- if (ring === 0) {
314
- tangent = vec3SubArray(pathPoints[1], pathPoints[0]);
315
- } else if (ring === totalRings - 1) {
316
- tangent = vec3SubArray(pathPoints[totalRings - 1], pathPoints[totalRings - 2]);
317
- } else {
318
- tangent = vec3SubArray(pathPoints[ring + 1], pathPoints[ring - 1]);
319
- }
320
- vec3NormalizeInPlace(tangent);
321
- let normal;
322
- let binormal;
323
- if (ring === 0) {
324
- if (Math.abs(tangent[0]) < 0.9) {
325
- normal = vec3CrossArray(tangent, [1, 0, 0]);
326
- } else {
327
- normal = vec3CrossArray(tangent, [0, 1, 0]);
328
- }
329
- vec3NormalizeInPlace(normal);
330
- binormal = vec3CrossArray(tangent, normal);
331
- vec3NormalizeInPlace(binormal);
332
- } else {
333
- normal = vec3SubArray(
334
- prevNormal,
335
- vec3ScaleArray(
336
- tangent,
337
- prevNormal[0] * tangent[0] + prevNormal[1] * tangent[1] + prevNormal[2] * tangent[2]
338
- )
339
- );
340
- const nLen = vec3NormalizeInPlace(normal);
341
- if (nLen < 1e-6) normal = [...prevNormal];
342
- binormal = vec3CrossArray(tangent, normal);
343
- vec3NormalizeInPlace(binormal);
344
- }
345
- prevNormal = normal;
346
- for (let i = 0; i <= radialSegments; i++) {
347
- const u = i / radialSegments;
348
- const theta = u * Math.PI * 2;
349
- const cosT = Math.cos(theta);
350
- const sinT = Math.sin(theta);
351
- const nx = normal[0] * cosT + binormal[0] * sinT;
352
- const ny = normal[1] * cosT + binormal[1] * sinT;
353
- const nz = normal[2] * cosT + binormal[2] * sinT;
354
- positions.push(p[0] + nx * radius, p[1] + ny * radius, p[2] + nz * radius);
355
- normals.push(nx, ny, nz);
356
- uvs.push(u, v);
357
- }
358
- }
359
- const ringVerts = radialSegments + 1;
360
- for (let ring = 0; ring < totalRings - 1; ring++) {
361
- for (let i = 0; i < radialSegments; i++) {
362
- const a = ring * ringVerts + i;
363
- const b = a + ringVerts;
364
- indices.push(a, b, a + 1);
365
- indices.push(b, b + 1, a + 1);
366
- }
367
- }
368
- const startCenter = positions.length / 3;
369
- const sp = pathPoints[0];
370
- const startTangent = vec3SubArray(pathPoints[1], pathPoints[0]);
371
- vec3NormalizeInPlace(startTangent);
372
- positions.push(sp[0], sp[1], sp[2]);
373
- normals.push(-startTangent[0], -startTangent[1], -startTangent[2]);
374
- uvs.push(0.5, 0);
375
- for (let i = 0; i < radialSegments; i++) {
376
- indices.push(startCenter, i + 1, i);
377
- }
378
- const endCenter = positions.length / 3;
379
- const ep = pathPoints[totalRings - 1];
380
- const endTangent = vec3SubArray(pathPoints[totalRings - 1], pathPoints[totalRings - 2]);
381
- vec3NormalizeInPlace(endTangent);
382
- positions.push(ep[0], ep[1], ep[2]);
383
- normals.push(endTangent[0], endTangent[1], endTangent[2]);
384
- uvs.push(0.5, 1);
385
- const lastRingStart = (totalRings - 1) * ringVerts;
386
- for (let i = 0; i < radialSegments; i++) {
387
- indices.push(endCenter, lastRingStart + i, lastRingStart + i + 1);
388
- }
389
- const vertexCount = positions.length / 3;
390
- const IndexArrayType = vertexCount > 65535 ? Uint32Array : Uint16Array;
391
- return {
392
- positions: new Float32Array(positions),
393
- normals: new Float32Array(normals),
394
- uvs: new Float32Array(uvs),
395
- indices: new IndexArrayType(indices)
396
- };
397
- }
398
- var MC_EDGE_TABLE = [
399
- 0,
400
- 265,
401
- 515,
402
- 778,
403
- 1030,
404
- 1295,
405
- 1541,
406
- 1804,
407
- 2060,
408
- 2309,
409
- 2575,
410
- 2822,
411
- 3082,
412
- 3331,
413
- 3593,
414
- 3840,
415
- 400,
416
- 153,
417
- 915,
418
- 666,
419
- 1430,
420
- 1183,
421
- 1941,
422
- 1692,
423
- 2460,
424
- 2197,
425
- 2975,
426
- 2710,
427
- 3482,
428
- 3219,
429
- 3993,
430
- 3728,
431
- 560,
432
- 825,
433
- 51,
434
- 314,
435
- 1590,
436
- 1855,
437
- 1077,
438
- 1340,
439
- 2620,
440
- 2869,
441
- 2111,
442
- 2358,
443
- 3642,
444
- 3891,
445
- 3129,
446
- 3376,
447
- 928,
448
- 681,
449
- 419,
450
- 170,
451
- 1958,
452
- 1711,
453
- 1445,
454
- 1196,
455
- 2988,
456
- 2725,
457
- 2479,
458
- 2214,
459
- 4010,
460
- 3747,
461
- 3497,
462
- 3232,
463
- 1120,
464
- 1385,
465
- 1635,
466
- 1898,
467
- 102,
468
- 367,
469
- 613,
470
- 876,
471
- 3180,
472
- 3429,
473
- 3695,
474
- 3942,
475
- 2154,
476
- 2403,
477
- 2665,
478
- 2912,
479
- 1520,
480
- 1273,
481
- 2035,
482
- 1786,
483
- 502,
484
- 255,
485
- 1013,
486
- 764,
487
- 3580,
488
- 3317,
489
- 4095,
490
- 3830,
491
- 2554,
492
- 2291,
493
- 3065,
494
- 2800,
495
- 1616,
496
- 1881,
497
- 1107,
498
- 1370,
499
- 598,
500
- 863,
501
- 85,
502
- 348,
503
- 3676,
504
- 3925,
505
- 3167,
506
- 3414,
507
- 2650,
508
- 2899,
509
- 2137,
510
- 2384,
511
- 1984,
512
- 1737,
513
- 1475,
514
- 1226,
515
- 966,
516
- 719,
517
- 453,
518
- 204,
519
- 4044,
520
- 3781,
521
- 3535,
522
- 3270,
523
- 3018,
524
- 2755,
525
- 2505,
526
- 2240,
527
- 2240,
528
- 2505,
529
- 2755,
530
- 3018,
531
- 3270,
532
- 3535,
533
- 3781,
534
- 4044,
535
- 204,
536
- 453,
537
- 719,
538
- 966,
539
- 1226,
540
- 1475,
541
- 1737,
542
- 1984,
543
- 2384,
544
- 2137,
545
- 2899,
546
- 2650,
547
- 3414,
548
- 3167,
549
- 3925,
550
- 3676,
551
- 348,
552
- 85,
553
- 863,
554
- 598,
555
- 1370,
556
- 1107,
557
- 1881,
558
- 1616,
559
- 2800,
560
- 3065,
561
- 2291,
562
- 2554,
563
- 3830,
564
- 4095,
565
- 3317,
566
- 3580,
567
- 764,
568
- 1013,
569
- 255,
570
- 502,
571
- 1786,
572
- 2035,
573
- 1273,
574
- 1520,
575
- 2912,
576
- 2665,
577
- 2403,
578
- 2154,
579
- 3942,
580
- 3695,
581
- 3429,
582
- 3180,
583
- 876,
584
- 613,
585
- 367,
586
- 102,
587
- 1898,
588
- 1635,
589
- 1385,
590
- 1120,
591
- 3232,
592
- 3497,
593
- 3747,
594
- 4010,
595
- 2214,
596
- 2479,
597
- 2725,
598
- 2988,
599
- 1196,
600
- 1445,
601
- 1711,
602
- 1958,
603
- 170,
604
- 419,
605
- 681,
606
- 928,
607
- 3376,
608
- 3129,
609
- 3891,
610
- 3642,
611
- 2358,
612
- 2111,
613
- 2869,
614
- 2620,
615
- 1340,
616
- 1077,
617
- 1855,
618
- 1590,
619
- 314,
620
- 51,
621
- 825,
622
- 560,
623
- 3728,
624
- 3993,
625
- 3219,
626
- 3482,
627
- 2710,
628
- 2975,
629
- 2197,
630
- 2460,
631
- 1692,
632
- 1941,
633
- 1183,
634
- 1430,
635
- 666,
636
- 915,
637
- 153,
638
- 400,
639
- 3840,
640
- 3593,
641
- 3331,
642
- 3082,
643
- 2822,
644
- 2575,
645
- 2309,
646
- 2060,
647
- 1804,
648
- 1541,
649
- 1295,
650
- 1030,
651
- 778,
652
- 515,
653
- 265,
654
- 0
655
- ];
656
- var MC_TRI_TABLE = [
657
- [-1],
658
- [0, 8, 3, -1],
659
- [0, 1, 9, -1],
660
- [1, 8, 3, 9, 8, 1, -1],
661
- [1, 2, 10, -1],
662
- [0, 8, 3, 1, 2, 10, -1],
663
- [9, 2, 10, 0, 2, 9, -1],
664
- [2, 8, 3, 2, 10, 8, 10, 9, 8, -1],
665
- [3, 11, 2, -1],
666
- [0, 11, 2, 8, 11, 0, -1],
667
- [1, 9, 0, 2, 3, 11, -1],
668
- [1, 11, 2, 1, 9, 11, 9, 8, 11, -1],
669
- [3, 10, 1, 11, 10, 3, -1],
670
- [0, 10, 1, 0, 8, 10, 8, 11, 10, -1],
671
- [3, 9, 0, 3, 11, 9, 11, 10, 9, -1],
672
- [9, 8, 10, 10, 8, 11, -1],
673
- [4, 7, 8, -1],
674
- [4, 3, 0, 7, 3, 4, -1],
675
- [0, 1, 9, 8, 4, 7, -1],
676
- [4, 1, 9, 4, 7, 1, 7, 3, 1, -1],
677
- [1, 2, 10, 8, 4, 7, -1],
678
- [3, 4, 7, 3, 0, 4, 1, 2, 10, -1],
679
- [9, 2, 10, 9, 0, 2, 8, 4, 7, -1],
680
- [2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1],
681
- [8, 4, 7, 3, 11, 2, -1],
682
- [11, 4, 7, 11, 2, 4, 2, 0, 4, -1],
683
- [9, 0, 1, 8, 4, 7, 2, 3, 11, -1],
684
- [4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1],
685
- [3, 10, 1, 3, 11, 10, 7, 8, 4, -1],
686
- [1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1],
687
- [4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1],
688
- [4, 7, 11, 4, 11, 9, 9, 11, 10, -1],
689
- [9, 5, 4, -1],
690
- [9, 5, 4, 0, 8, 3, -1],
691
- [0, 5, 4, 1, 5, 0, -1],
692
- [8, 5, 4, 8, 3, 5, 3, 1, 5, -1],
693
- [1, 2, 10, 9, 5, 4, -1],
694
- [3, 0, 8, 1, 2, 10, 4, 9, 5, -1],
695
- [5, 2, 10, 5, 4, 2, 4, 0, 2, -1],
696
- [2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1],
697
- [9, 5, 4, 2, 3, 11, -1],
698
- [0, 11, 2, 0, 8, 11, 4, 9, 5, -1],
699
- [0, 5, 4, 0, 1, 5, 2, 3, 11, -1],
700
- [2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1],
701
- [10, 3, 11, 10, 1, 3, 9, 5, 4, -1],
702
- [4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1],
703
- [5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1],
704
- [5, 4, 8, 5, 8, 10, 10, 8, 11, -1],
705
- [9, 7, 8, 5, 7, 9, -1],
706
- [9, 3, 0, 9, 5, 3, 5, 7, 3, -1],
707
- [0, 7, 8, 0, 1, 7, 1, 5, 7, -1],
708
- [1, 5, 3, 3, 5, 7, -1],
709
- [9, 7, 8, 9, 5, 7, 10, 1, 2, -1],
710
- [10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1],
711
- [8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1],
712
- [2, 10, 5, 2, 5, 3, 3, 5, 7, -1],
713
- [7, 9, 5, 7, 8, 9, 3, 11, 2, -1],
714
- [9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1],
715
- [2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1],
716
- [11, 2, 1, 11, 1, 7, 7, 1, 5, -1],
717
- [9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1],
718
- [5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1],
719
- [11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1],
720
- [11, 10, 5, 7, 11, 5, -1],
721
- [10, 6, 5, -1],
722
- [0, 8, 3, 5, 10, 6, -1],
723
- [9, 0, 1, 5, 10, 6, -1],
724
- [1, 8, 3, 1, 9, 8, 5, 10, 6, -1],
725
- [1, 6, 5, 2, 6, 1, -1],
726
- [1, 6, 5, 1, 2, 6, 3, 0, 8, -1],
727
- [9, 6, 5, 9, 0, 6, 0, 2, 6, -1],
728
- [5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1],
729
- [2, 3, 11, 10, 6, 5, -1],
730
- [11, 0, 8, 11, 2, 0, 10, 6, 5, -1],
731
- [0, 1, 9, 2, 3, 11, 5, 10, 6, -1],
732
- [5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1],
733
- [6, 3, 11, 6, 5, 3, 5, 1, 3, -1],
734
- [0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1],
735
- [3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1],
736
- [6, 5, 9, 6, 9, 11, 11, 9, 8, -1],
737
- [5, 10, 6, 4, 7, 8, -1],
738
- [4, 3, 0, 4, 7, 3, 6, 5, 10, -1],
739
- [1, 9, 0, 5, 10, 6, 8, 4, 7, -1],
740
- [10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1],
741
- [6, 1, 2, 6, 5, 1, 4, 7, 8, -1],
742
- [1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1],
743
- [8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1],
744
- [7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1],
745
- [3, 11, 2, 7, 8, 4, 10, 6, 5, -1],
746
- [5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1],
747
- [0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1],
748
- [9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1],
749
- [8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1],
750
- [5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1],
751
- [0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1],
752
- [6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1],
753
- [10, 4, 9, 6, 4, 10, -1],
754
- [4, 10, 6, 4, 9, 10, 0, 8, 3, -1],
755
- [10, 0, 1, 10, 6, 0, 6, 4, 0, -1],
756
- [8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1],
757
- [1, 4, 9, 1, 2, 4, 2, 6, 4, -1],
758
- [3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1],
759
- [0, 2, 4, 4, 2, 6, -1],
760
- [8, 3, 2, 8, 2, 4, 4, 2, 6, -1],
761
- [10, 4, 9, 10, 6, 4, 11, 2, 3, -1],
762
- [0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1],
763
- [3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1],
764
- [6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1],
765
- [9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1],
766
- [8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1],
767
- [3, 11, 6, 3, 6, 0, 0, 6, 4, -1],
768
- [6, 4, 8, 11, 6, 8, -1],
769
- [7, 10, 6, 7, 8, 10, 8, 9, 10, -1],
770
- [0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1],
771
- [10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1],
772
- [10, 6, 7, 10, 7, 1, 1, 7, 3, -1],
773
- [1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1],
774
- [2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1],
775
- [7, 8, 0, 7, 0, 6, 6, 0, 2, -1],
776
- [7, 3, 2, 6, 7, 2, -1],
777
- [2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1],
778
- [2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1],
779
- [1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1],
780
- [11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1],
781
- [8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1],
782
- [0, 9, 1, 11, 6, 7, -1],
783
- [7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1],
784
- [7, 11, 6, -1],
785
- [7, 6, 11, -1],
786
- [3, 0, 8, 11, 7, 6, -1],
787
- [0, 1, 9, 11, 7, 6, -1],
788
- [8, 1, 9, 8, 3, 1, 11, 7, 6, -1],
789
- [10, 1, 2, 6, 11, 7, -1],
790
- [1, 2, 10, 3, 0, 8, 6, 11, 7, -1],
791
- [2, 9, 0, 2, 10, 9, 6, 11, 7, -1],
792
- [6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1],
793
- [7, 2, 3, 6, 2, 7, -1],
794
- [7, 0, 8, 7, 6, 0, 6, 2, 0, -1],
795
- [2, 7, 6, 2, 3, 7, 0, 1, 9, -1],
796
- [1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1],
797
- [10, 7, 6, 10, 1, 7, 1, 3, 7, -1],
798
- [10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1],
799
- [0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1],
800
- [7, 6, 10, 7, 10, 8, 8, 10, 9, -1],
801
- [6, 8, 4, 11, 8, 6, -1],
802
- [3, 6, 11, 3, 0, 6, 0, 4, 6, -1],
803
- [8, 6, 11, 8, 4, 6, 9, 0, 1, -1],
804
- [9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1],
805
- [6, 8, 4, 6, 11, 8, 2, 10, 1, -1],
806
- [1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1],
807
- [4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1],
808
- [10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1],
809
- [8, 2, 3, 8, 4, 2, 4, 6, 2, -1],
810
- [0, 4, 2, 4, 6, 2, -1],
811
- [1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1],
812
- [1, 9, 4, 1, 4, 2, 2, 4, 6, -1],
813
- [8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1],
814
- [10, 1, 0, 10, 0, 6, 6, 0, 4, -1],
815
- [4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1],
816
- [10, 9, 4, 6, 10, 4, -1],
817
- [4, 9, 5, 7, 6, 11, -1],
818
- [0, 8, 3, 4, 9, 5, 11, 7, 6, -1],
819
- [5, 0, 1, 5, 4, 0, 7, 6, 11, -1],
820
- [11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1],
821
- [9, 5, 4, 10, 1, 2, 7, 6, 11, -1],
822
- [6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1],
823
- [7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1],
824
- [3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1],
825
- [7, 2, 3, 7, 6, 2, 5, 4, 9, -1],
826
- [9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1],
827
- [3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1],
828
- [6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1],
829
- [9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1],
830
- [1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1],
831
- [4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1],
832
- [7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1],
833
- [6, 9, 5, 6, 11, 9, 11, 8, 9, -1],
834
- [3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1],
835
- [0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1],
836
- [6, 11, 3, 6, 3, 5, 5, 3, 1, -1],
837
- [1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1],
838
- [0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1],
839
- [11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1],
840
- [6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1],
841
- [5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1],
842
- [9, 5, 6, 9, 6, 0, 0, 6, 2, -1],
843
- [1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1],
844
- [1, 5, 6, 2, 1, 6, -1],
845
- [1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1],
846
- [10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1],
847
- [0, 3, 8, 5, 6, 10, -1],
848
- [10, 5, 6, -1],
849
- [11, 5, 10, 7, 5, 11, -1],
850
- [11, 5, 10, 11, 7, 5, 8, 3, 0, -1],
851
- [5, 11, 7, 5, 10, 11, 1, 9, 0, -1],
852
- [10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1],
853
- [11, 1, 2, 11, 7, 1, 7, 5, 1, -1],
854
- [0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1],
855
- [9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1],
856
- [7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1],
857
- [2, 5, 10, 2, 3, 5, 3, 7, 5, -1],
858
- [8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1],
859
- [9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1],
860
- [9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1],
861
- [1, 3, 5, 3, 7, 5, -1],
862
- [0, 8, 7, 0, 7, 1, 1, 7, 5, -1],
863
- [9, 0, 3, 9, 3, 5, 5, 3, 7, -1],
864
- [9, 8, 7, 5, 9, 7, -1],
865
- [5, 8, 4, 5, 10, 8, 10, 11, 8, -1],
866
- [5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1],
867
- [0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1],
868
- [10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1],
869
- [2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1],
870
- [0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1],
871
- [0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1],
872
- [9, 4, 5, 2, 11, 3, -1],
873
- [2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1],
874
- [5, 10, 2, 5, 2, 4, 4, 2, 0, -1],
875
- [3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1],
876
- [5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1],
877
- [8, 4, 5, 8, 5, 3, 3, 5, 1, -1],
878
- [0, 4, 5, 1, 0, 5, -1],
879
- [8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1],
880
- [9, 4, 5, -1],
881
- [4, 11, 7, 4, 9, 11, 9, 10, 11, -1],
882
- [0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1],
883
- [1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1],
884
- [3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1],
885
- [4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1],
886
- [9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1],
887
- [11, 7, 4, 11, 4, 2, 2, 4, 0, -1],
888
- [11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1],
889
- [2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1],
890
- [9, 10, 7, 9, 7, 4, 10, 2, 7, 0, 7, 8, 2, 8, 7, -1],
891
- [3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1],
892
- [1, 10, 2, 8, 7, 4, -1],
893
- [4, 9, 1, 4, 1, 7, 7, 1, 3, -1],
894
- [4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1],
895
- [4, 0, 3, 7, 4, 3, -1],
896
- [4, 8, 7, -1],
897
- [9, 10, 8, 10, 11, 8, -1],
898
- [3, 0, 9, 3, 9, 11, 11, 9, 10, -1],
899
- [0, 1, 10, 0, 10, 8, 8, 10, 11, -1],
900
- [3, 1, 10, 11, 3, 10, -1],
901
- [1, 2, 11, 1, 11, 9, 9, 11, 8, -1],
902
- [3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1],
903
- [0, 2, 11, 8, 0, 11, -1],
904
- [3, 2, 11, -1],
905
- [2, 3, 8, 2, 8, 10, 10, 8, 9, -1],
906
- [9, 10, 2, 0, 9, 2, -1],
907
- [2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1],
908
- [1, 10, 2, -1],
909
- [1, 3, 8, 9, 1, 8, -1],
910
- [0, 9, 1, -1],
911
- [0, 3, 8, -1],
912
- [-1]
913
- ];
914
- function generateHullGeometry(blobs, resolution = 24, threshold = 1, lod) {
915
- if (blobs.length === 0) return fallbackBox();
916
- const boundsPadding = lod ? LOD_PRESETS[lod].hull.boundsPadding : 1.3;
917
- if (lod) {
918
- const preset = LOD_PRESETS[lod].hull;
919
- resolution = preset.resolution;
920
- }
921
- let minX = Infinity, minY = Infinity, minZ = Infinity;
922
- let maxX = -Infinity, maxY = -Infinity, maxZ = -Infinity;
923
- for (const b of blobs) {
924
- minX = Math.min(minX, b.center[0] - b.radius[0] * boundsPadding);
925
- minY = Math.min(minY, b.center[1] - b.radius[1] * boundsPadding);
926
- minZ = Math.min(minZ, b.center[2] - b.radius[2] * boundsPadding);
927
- maxX = Math.max(maxX, b.center[0] + b.radius[0] * boundsPadding);
928
- maxY = Math.max(maxY, b.center[1] + b.radius[1] * boundsPadding);
929
- maxZ = Math.max(maxZ, b.center[2] + b.radius[2] * boundsPadding);
930
- }
931
- const positions = [];
932
- const normals = [];
933
- const uvs = [];
934
- const indices = [];
935
- function evalField(x, y, z) {
936
- let sum = 0;
937
- for (const b of blobs) {
938
- const dx2 = (x - b.center[0]) / b.radius[0];
939
- const dy2 = (y - b.center[1]) / b.radius[1];
940
- const dz2 = (z - b.center[2]) / b.radius[2];
941
- const d2 = dx2 * dx2 + dy2 * dy2 + dz2 * dz2;
942
- if (d2 > 1e-3) sum += 1 / d2;
943
- }
944
- return sum;
945
- }
946
- function evalGradient(x, y, z, eps = 0.01) {
947
- return [
948
- evalField(x + eps, y, z) - evalField(x - eps, y, z),
949
- evalField(x, y + eps, z) - evalField(x, y - eps, z),
950
- evalField(x, y, z + eps) - evalField(x, y, z - eps)
951
- ];
952
- }
953
- const nx = resolution, ny = resolution, nz = resolution;
954
- const dx = (maxX - minX) / nx;
955
- const dy = (maxY - minY) / ny;
956
- const dz = (maxZ - minZ) / nz;
957
- const field = new Float32Array((nx + 1) * (ny + 1) * (nz + 1));
958
- const idx3 = (ix, iy, iz) => ix + (nx + 1) * (iy + (ny + 1) * iz);
959
- for (let iz = 0; iz <= nz; iz++) {
960
- for (let iy = 0; iy <= ny; iy++) {
961
- for (let ix = 0; ix <= nx; ix++) {
962
- field[idx3(ix, iy, iz)] = evalField(minX + ix * dx, minY + iy * dy, minZ + iz * dz);
963
- }
964
- }
965
- }
966
- const vertexMap = /* @__PURE__ */ new Map();
967
- const gridStride = nx + 1;
968
- const gridSlice = gridStride * (ny + 1);
969
- function interpVertex(ix1, iy1, iz1, v1, ix2, iy2, iz2, v2) {
970
- const k1 = ix1 + iy1 * gridStride + iz1 * gridSlice;
971
- const k2 = ix2 + iy2 * gridStride + iz2 * gridSlice;
972
- const key = k1 < k2 ? `${k1}_${k2}` : `${k2}_${k1}`;
973
- if (vertexMap.has(key)) return vertexMap.get(key);
974
- const dv = v2 - v1;
975
- const t = Math.abs(dv) < 1e-10 ? 0.5 : Math.max(0, Math.min(1, (threshold - v1) / dv));
976
- const x = minX + (ix1 + t * (ix2 - ix1)) * dx;
977
- const y = minY + (iy1 + t * (iy2 - iy1)) * dy;
978
- const z = minZ + (iz1 + t * (iz2 - iz1)) * dz;
979
- const gradEps = Math.min(dx, dy, dz) * 0.5;
980
- const grad = evalGradient(x, y, z, gradEps);
981
- const n = [-grad[0], -grad[1], -grad[2]];
982
- vec3NormalizeInPlace(n);
983
- const vertIdx = positions.length / 3;
984
- positions.push(x, y, z);
985
- normals.push(n[0], n[1], n[2]);
986
- uvs.push(
987
- 0.5 + Math.atan2(n[2], n[0]) / (2 * Math.PI),
988
- 0.5 - Math.asin(Math.max(-1, Math.min(1, n[1]))) / Math.PI
989
- );
990
- vertexMap.set(key, vertIdx);
991
- return vertIdx;
992
- }
993
- const edgeVerts = [
994
- [0, 1],
995
- [1, 2],
996
- [2, 3],
997
- [3, 0],
998
- [4, 5],
999
- [5, 6],
1000
- [6, 7],
1001
- [7, 4],
1002
- [0, 4],
1003
- [1, 5],
1004
- [2, 6],
1005
- [3, 7]
1006
- ];
1007
- const cornerOffsets = [
1008
- [0, 0, 0],
1009
- [1, 0, 0],
1010
- [1, 1, 0],
1011
- [0, 1, 0],
1012
- [0, 0, 1],
1013
- [1, 0, 1],
1014
- [1, 1, 1],
1015
- [0, 1, 1]
1016
- ];
1017
- for (let iz = 0; iz < nz; iz++) {
1018
- for (let iy = 0; iy < ny; iy++) {
1019
- for (let ix = 0; ix < nx; ix++) {
1020
- const cornerVals = [];
1021
- const cornerCoords = [];
1022
- let cubeIndex = 0;
1023
- for (let c = 0; c < 8; c++) {
1024
- const cx = ix + cornerOffsets[c][0];
1025
- const cy = iy + cornerOffsets[c][1];
1026
- const cz = iz + cornerOffsets[c][2];
1027
- const val = field[idx3(cx, cy, cz)];
1028
- cornerVals.push(val);
1029
- cornerCoords.push([cx, cy, cz]);
1030
- if (val >= threshold) cubeIndex |= 1 << c;
1031
- }
1032
- const edges = MC_EDGE_TABLE[cubeIndex];
1033
- if (edges === 0 || edges === void 0) continue;
1034
- const edgeVertices = new Array(12).fill(-1);
1035
- for (let e = 0; e < 12; e++) {
1036
- if (edges & 1 << e) {
1037
- const [c1, c2] = edgeVerts[e];
1038
- edgeVertices[e] = interpVertex(
1039
- cornerCoords[c1][0],
1040
- cornerCoords[c1][1],
1041
- cornerCoords[c1][2],
1042
- cornerVals[c1],
1043
- cornerCoords[c2][0],
1044
- cornerCoords[c2][1],
1045
- cornerCoords[c2][2],
1046
- cornerVals[c2]
1047
- );
1048
- }
1049
- }
1050
- const triRow = MC_TRI_TABLE[cubeIndex];
1051
- if (triRow) {
1052
- for (let t = 0; t < triRow.length; t += 3) {
1053
- const e0 = triRow[t], e1 = triRow[t + 1], e2 = triRow[t + 2];
1054
- if (e0 === -1) break;
1055
- if (edgeVertices[e0] >= 0 && edgeVertices[e1] >= 0 && edgeVertices[e2] >= 0) {
1056
- indices.push(edgeVertices[e0], edgeVertices[e1], edgeVertices[e2]);
1057
- }
1058
- }
1059
- }
1060
- }
1061
- }
1062
- }
1063
- if (positions.length === 0) return fallbackBox();
1064
- const vertexCount = positions.length / 3;
1065
- const IndexArrayType = vertexCount > 65535 ? Uint32Array : Uint16Array;
1066
- return {
1067
- positions: new Float32Array(positions),
1068
- normals: new Float32Array(normals),
1069
- uvs: new Float32Array(uvs),
1070
- indices: new IndexArrayType(indices)
1071
- };
1072
- }
1073
- function generateMembraneGeometry(anchors, subdivisions = 8, bulge = 0.15, lod) {
1074
- if (lod) {
1075
- subdivisions = LOD_PRESETS[lod].membrane.subdivisions;
1076
- }
1077
- if (anchors.length < 3) return fallbackBox();
1078
- const positions = [];
1079
- const normals = [];
1080
- const uvs = [];
1081
- const indices = [];
1082
- const center = [0, 0, 0];
1083
- for (const a of anchors) {
1084
- center[0] += a[0];
1085
- center[1] += a[1];
1086
- center[2] += a[2];
1087
- }
1088
- center[0] /= anchors.length;
1089
- center[1] /= anchors.length;
1090
- center[2] /= anchors.length;
1091
- const memNormal = [0, 0, 0];
1092
- for (let i = 0; i < anchors.length; i++) {
1093
- const a = anchors[i];
1094
- const b = anchors[(i + 1) % anchors.length];
1095
- const ca = vec3SubArray(a, center);
1096
- const cb = vec3SubArray(b, center);
1097
- const cross = vec3CrossArray(ca, cb);
1098
- memNormal[0] += cross[0];
1099
- memNormal[1] += cross[1];
1100
- memNormal[2] += cross[2];
1101
- }
1102
- vec3NormalizeInPlace(memNormal);
1103
- const numAnchors = anchors.length;
1104
- const centerIdx = 0;
1105
- positions.push(
1106
- center[0] + memNormal[0] * bulge,
1107
- center[1] + memNormal[1] * bulge,
1108
- center[2] + memNormal[2] * bulge
1109
- );
1110
- normals.push(memNormal[0], memNormal[1], memNormal[2]);
1111
- uvs.push(0.5, 0.5);
1112
- for (let ring = 1; ring <= subdivisions; ring++) {
1113
- const t = ring / subdivisions;
1114
- const ringBulge = bulge * (1 - t * t);
1115
- for (let seg = 0; seg < numAnchors; seg++) {
1116
- const a0 = anchors[seg];
1117
- anchors[(seg + 1) % numAnchors];
1118
- const px = center[0] + (a0[0] - center[0]) * t;
1119
- const py = center[1] + (a0[1] - center[1]) * t;
1120
- const pz = center[2] + (a0[2] - center[2]) * t;
1121
- positions.push(
1122
- px + memNormal[0] * ringBulge,
1123
- py + memNormal[1] * ringBulge,
1124
- pz + memNormal[2] * ringBulge
1125
- );
1126
- const dx = px - center[0];
1127
- const dy = py - center[1];
1128
- const dz = pz - center[2];
1129
- const n = [
1130
- memNormal[0] + dx * bulge * 0.5,
1131
- memNormal[1] + dy * bulge * 0.5,
1132
- memNormal[2] + dz * bulge * 0.5
1133
- ];
1134
- vec3NormalizeInPlace(n);
1135
- normals.push(n[0], n[1], n[2]);
1136
- const angle = seg / numAnchors * Math.PI * 2;
1137
- uvs.push(0.5 + t * 0.5 * Math.cos(angle), 0.5 + t * 0.5 * Math.sin(angle));
1138
- }
1139
- }
1140
- for (let i = 0; i < numAnchors; i++) {
1141
- const next = (i + 1) % numAnchors;
1142
- indices.push(centerIdx, 1 + i, 1 + next);
1143
- }
1144
- for (let ring = 1; ring < subdivisions; ring++) {
1145
- const ringStart = 1 + (ring - 1) * numAnchors;
1146
- const nextRingStart = 1 + ring * numAnchors;
1147
- for (let i = 0; i < numAnchors; i++) {
1148
- const next = (i + 1) % numAnchors;
1149
- indices.push(ringStart + i, nextRingStart + i, nextRingStart + next);
1150
- indices.push(ringStart + i, nextRingStart + next, ringStart + next);
1151
- }
1152
- }
1153
- const triCount = indices.length;
1154
- for (let i = 0; i < triCount; i += 3) {
1155
- indices.push(indices[i], indices[i + 2], indices[i + 1]);
1156
- }
1157
- const vertexCount = positions.length / 3;
1158
- const IndexArrayType = vertexCount > 65535 ? Uint32Array : Uint16Array;
1159
- return {
1160
- positions: new Float32Array(positions),
1161
- normals: new Float32Array(normals),
1162
- uvs: new Float32Array(uvs),
1163
- indices: new IndexArrayType(indices)
1164
- };
1165
- }
1166
-
1167
- export { generateHullGeometry, generateMembraneGeometry, generateSplineGeometry };
1168
- //# sourceMappingURL=chunk-HJJLD366.js.map
1169
- //# sourceMappingURL=chunk-HJJLD366.js.map