@vibecook/ice 0.10.0 → 0.14.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 (380) hide show
  1. package/README.md +79 -50
  2. package/dist/chunk-BA7XJC27.js +2429 -0
  3. package/dist/chunk-BA7XJC27.js.map +1 -0
  4. package/dist/chunk-BKV4ZEU3.js +1 -0
  5. package/dist/chunk-BKV4ZEU3.js.map +1 -0
  6. package/dist/{chunk-5FQS7V2C.js → chunk-DYK6KNLG.js} +13303 -7485
  7. package/dist/chunk-DYK6KNLG.js.map +1 -0
  8. package/dist/chunk-ENIFIUEP.js +155 -0
  9. package/dist/chunk-ENIFIUEP.js.map +1 -0
  10. package/dist/chunk-IBWWLA6D.js +634 -0
  11. package/dist/chunk-IBWWLA6D.js.map +1 -0
  12. package/dist/{chunk-OR5FNVUE.js → chunk-JS6PG6YD.js} +398 -167
  13. package/dist/chunk-JS6PG6YD.js.map +1 -0
  14. package/dist/chunk-QXOCF56A.js +148 -0
  15. package/dist/chunk-QXOCF56A.js.map +1 -0
  16. package/dist/chunk-ZPUPBULB.js +7399 -0
  17. package/dist/chunk-ZPUPBULB.js.map +1 -0
  18. package/dist/desk-engine.js +36 -0
  19. package/dist/desk-engine.js.map +1 -0
  20. package/dist/desk-kit.js +244 -0
  21. package/dist/desk-kit.js.map +1 -0
  22. package/dist/desk-objects.js +12728 -0
  23. package/dist/desk-objects.js.map +1 -0
  24. package/dist/desk.js +469 -0
  25. package/dist/desk.js.map +1 -0
  26. package/dist/devtools.js +233 -189
  27. package/dist/devtools.js.map +1 -1
  28. package/dist/dom.js +7 -19
  29. package/dist/index.js +232 -20
  30. package/dist/kernel.js +53 -25
  31. package/dist/react.js +1045 -38
  32. package/dist/react.js.map +1 -1
  33. package/dist/types/packages/core/src/behavior/define-behavior.d.ts +11 -0
  34. package/dist/types/packages/core/src/behavior/runtime.d.ts +4 -0
  35. package/dist/types/packages/core/src/canvas/define-canvas-type.d.ts +86 -0
  36. package/dist/types/packages/core/src/canvas/define-container.d.ts +17 -0
  37. package/dist/types/packages/core/src/canvas/diagnostics.d.ts +27 -0
  38. package/dist/types/packages/core/src/canvas/engine-catalog.d.ts +70 -0
  39. package/dist/types/packages/core/src/canvas/extensions.d.ts +125 -0
  40. package/dist/types/packages/core/src/canvas/frame-behavior-host.d.ts +16 -0
  41. package/dist/types/packages/core/src/canvas/frame-preview.d.ts +79 -0
  42. package/dist/types/packages/core/src/canvas/frame-projection.d.ts +38 -0
  43. package/dist/types/packages/core/src/canvas/frame-view.d.ts +36 -0
  44. package/dist/types/packages/core/src/canvas/migrate.d.ts +14 -0
  45. package/dist/types/packages/core/src/canvas/placement.d.ts +30 -0
  46. package/dist/types/packages/core/src/canvas/presentation-transition.d.ts +100 -0
  47. package/dist/types/packages/core/src/canvas/runtime-extension-host.d.ts +16 -0
  48. package/dist/types/packages/core/src/canvas/session.d.ts +47 -0
  49. package/dist/types/packages/core/src/catalog/camera-derived.d.ts +16 -27
  50. package/dist/types/packages/core/src/catalog/desk.d.ts +326 -0
  51. package/dist/types/packages/core/src/catalog/gesture.d.ts +51 -0
  52. package/dist/types/packages/core/src/catalog/graph.d.ts +2 -2
  53. package/dist/types/packages/core/src/catalog/index.d.ts +2 -0
  54. package/dist/types/packages/core/src/catalog/pointer.d.ts +42 -0
  55. package/dist/types/packages/core/src/catalog/selection-presence.d.ts +7 -0
  56. package/dist/types/packages/core/src/catalog/settings-resources.d.ts +28 -2
  57. package/dist/types/packages/core/src/catalog/surface.d.ts +1 -0
  58. package/dist/types/packages/core/src/doc/doc-commit-sink.d.ts +18 -2
  59. package/dist/types/packages/core/src/doc/doc-kit.d.ts +21 -2
  60. package/dist/types/packages/core/src/doc/envelope.d.ts +5 -2
  61. package/dist/types/packages/core/src/doc/schema-migrate.d.ts +1 -1
  62. package/dist/types/packages/core/src/doc/version-gate.d.ts +21 -3
  63. package/dist/types/packages/core/src/engine/commit-sink.d.ts +10 -1
  64. package/dist/types/packages/core/src/engine/engine.d.ts +6 -0
  65. package/dist/types/packages/core/src/engine/frame-control.d.ts +74 -0
  66. package/dist/types/packages/core/src/engine/guests.d.ts +4 -1
  67. package/dist/types/packages/core/src/engine/world-doors.d.ts +12 -0
  68. package/dist/types/packages/core/src/facade/create-canvas-engine.d.ts +146 -13
  69. package/dist/types/packages/core/src/index.d.ts +34 -13
  70. package/dist/types/packages/core/src/input/queue.d.ts +3 -1
  71. package/dist/types/packages/core/src/interaction/install.d.ts +30 -0
  72. package/dist/types/packages/core/src/interaction/wakes.d.ts +24 -0
  73. package/dist/types/packages/core/src/nav/nav-geometry.d.ts +100 -0
  74. package/dist/types/packages/core/src/nav/nested-canvas.d.ts +47 -4
  75. package/dist/types/packages/core/src/ops/cascade.d.ts +2 -1
  76. package/dist/types/packages/core/src/ops/claims.d.ts +6 -0
  77. package/dist/types/packages/core/src/ops/insert.d.ts +4 -0
  78. package/dist/types/packages/core/src/ops/point-pick.d.ts +4 -1
  79. package/dist/types/packages/core/src/ops/sibling-order.d.ts +14 -4
  80. package/dist/types/packages/core/src/ops/tray.d.ts +48 -0
  81. package/dist/types/packages/core/src/presence/presence-kit.d.ts +5 -0
  82. package/dist/types/packages/core/src/schema/meta.d.ts +10 -0
  83. package/dist/types/packages/core/src/schema/prefab.d.ts +8 -0
  84. package/dist/types/packages/core/src/settings/defaults.d.ts +25 -6
  85. package/dist/types/packages/core/src/surface/gpu-device.d.ts +55 -0
  86. package/dist/types/packages/core/src/systems/camera-sim.d.ts +29 -0
  87. package/dist/types/packages/core/src/systems/chrome.d.ts +15 -23
  88. package/dist/types/packages/core/src/systems/drag-mods.d.ts +34 -0
  89. package/dist/types/packages/core/src/systems/held.d.ts +71 -0
  90. package/dist/types/packages/core/src/systems/insert-ghost.d.ts +2 -0
  91. package/dist/types/packages/core/src/systems/l0-input.d.ts +14 -0
  92. package/dist/types/packages/core/src/systems/l1-pick.d.ts +37 -1
  93. package/dist/types/packages/core/src/systems/l2-arbitrate.d.ts +18 -4
  94. package/dist/types/packages/core/src/systems/l3-behave.d.ts +4 -1
  95. package/dist/types/packages/core/src/systems/l3-claim.d.ts +7 -0
  96. package/dist/types/packages/core/src/systems/l3-connect.d.ts +1 -1
  97. package/dist/types/packages/core/src/systems/l3-drop.d.ts +30 -1
  98. package/dist/types/packages/core/src/systems/l3-marquee.d.ts +2 -1
  99. package/dist/types/packages/core/src/systems/l3-ports.d.ts +1 -1
  100. package/dist/types/packages/core/src/systems/l4-cursor.d.ts +5 -0
  101. package/dist/types/packages/core/src/systems/nav-flight.d.ts +85 -3
  102. package/dist/types/packages/core/src/systems/nav-tap.d.ts +44 -0
  103. package/dist/types/packages/core/src/systems/press-wheel.d.ts +11 -0
  104. package/dist/types/packages/core/src/systems/tray.d.ts +108 -0
  105. package/dist/types/packages/core/src/systems/zoom-through.d.ts +30 -0
  106. package/dist/types/packages/core/src/tools/define-tool.d.ts +10 -0
  107. package/dist/types/packages/core/src/widget/define-widget.d.ts +166 -63
  108. package/dist/types/packages/core/src/widget/equip.d.ts +14 -2
  109. package/dist/types/packages/core/src/widget/held-tools.d.ts +83 -0
  110. package/dist/types/packages/core/src/widget/menu-actions.d.ts +44 -0
  111. package/dist/types/packages/core/src/widget/mount-store.d.ts +21 -46
  112. package/dist/types/packages/core/src/widget/spawn.d.ts +1 -1
  113. package/dist/types/packages/desk/src/assets/blue-noise.gen.d.ts +10 -0
  114. package/dist/types/packages/desk/src/card/card.d.ts +103 -0
  115. package/dist/types/packages/desk/src/compose/ambient.d.ts +59 -0
  116. package/dist/types/packages/desk/src/compose/builder.d.ts +285 -0
  117. package/dist/types/packages/desk/src/compose/children.d.ts +3 -0
  118. package/dist/types/packages/desk/src/compose/index.d.ts +14 -0
  119. package/dist/types/packages/desk/src/compose/marks.d.ts +126 -0
  120. package/dist/types/packages/desk/src/compose/pick.d.ts +5 -0
  121. package/dist/types/packages/desk/src/compose/reflector.d.ts +111 -0
  122. package/dist/types/packages/desk/src/compose/tap.d.ts +5 -0
  123. package/dist/types/packages/desk/src/docs.d.ts +23 -0
  124. package/dist/types/packages/desk/src/engine/budget.d.ts +38 -0
  125. package/dist/types/packages/desk/src/engine/device.d.ts +54 -0
  126. package/dist/types/packages/desk/src/engine/index.d.ts +5 -0
  127. package/dist/types/packages/desk/src/engine/pipeline.d.ts +36 -0
  128. package/dist/types/packages/desk/src/engine/rasters.d.ts +66 -0
  129. package/dist/types/packages/desk/src/engine/records.d.ts +56 -0
  130. package/dist/types/packages/desk/src/engine/shader.d.ts +22 -0
  131. package/dist/types/packages/desk/src/engine/struct.d.ts +39 -0
  132. package/dist/types/packages/desk/src/engine/target.d.ts +26 -0
  133. package/dist/types/packages/desk/src/gpu-ablation.d.ts +61 -0
  134. package/dist/types/packages/desk/src/gpu-memory.d.ts +54 -0
  135. package/dist/types/packages/desk/src/gpu-profiler.d.ts +141 -0
  136. package/dist/types/packages/desk/src/gpu-wrap.d.ts +8 -0
  137. package/dist/types/packages/desk/src/ground.d.ts +388 -0
  138. package/dist/types/packages/desk/src/hold/focus.d.ts +53 -0
  139. package/dist/types/packages/desk/src/hold/pose.d.ts +132 -0
  140. package/dist/types/packages/desk/src/hold/shaders.d.ts +9 -0
  141. package/dist/types/packages/desk/src/host/editor.d.ts +18 -0
  142. package/dist/types/packages/desk/src/host/index.d.ts +9 -0
  143. package/dist/types/packages/desk/src/host/ink.d.ts +18 -0
  144. package/dist/types/packages/desk/src/host/layer.d.ts +430 -0
  145. package/dist/types/packages/desk/src/host/picture.d.ts +2 -0
  146. package/dist/types/packages/desk/src/host/surface.d.ts +5 -0
  147. package/dist/types/packages/desk/src/index.d.ts +13 -0
  148. package/dist/types/packages/desk/src/kind.d.ts +187 -0
  149. package/dist/types/packages/desk/src/kinds/world.d.ts +429 -0
  150. package/dist/types/packages/desk/src/kit/arrays.d.ts +88 -0
  151. package/dist/types/packages/desk/src/kit/blobs.d.ts +40 -0
  152. package/dist/types/packages/desk/src/kit/book.d.ts +2 -0
  153. package/dist/types/packages/desk/src/kit/editor.d.ts +103 -0
  154. package/dist/types/packages/desk/src/kit/eye.d.ts +37 -0
  155. package/dist/types/packages/desk/src/kit/hold.d.ts +1 -0
  156. package/dist/types/packages/desk/src/kit/index.d.ts +26 -0
  157. package/dist/types/packages/desk/src/kit/inside.d.ts +116 -0
  158. package/dist/types/packages/desk/src/kit/layer.d.ts +159 -0
  159. package/dist/types/packages/desk/src/kit/light.d.ts +3 -0
  160. package/dist/types/packages/desk/src/kit/mesh.d.ts +29 -0
  161. package/dist/types/packages/desk/src/kit/mips.d.ts +2 -0
  162. package/dist/types/packages/desk/src/kit/nav.d.ts +2 -0
  163. package/dist/types/packages/desk/src/kit/paper-tex.d.ts +5 -0
  164. package/dist/types/packages/desk/src/kit/physics.d.ts +44 -0
  165. package/dist/types/packages/desk/src/kit/place.d.ts +44 -0
  166. package/dist/types/packages/desk/src/kit/print.d.ts +30 -0
  167. package/dist/types/packages/desk/src/kit/raster.d.ts +34 -0
  168. package/dist/types/packages/desk/src/kit/sdf.d.ts +1 -0
  169. package/dist/types/packages/desk/src/kit/seeds.d.ts +11 -0
  170. package/dist/types/packages/desk/src/kit/services.d.ts +34 -0
  171. package/dist/types/packages/desk/src/kit/springs.d.ts +12 -0
  172. package/dist/types/packages/desk/src/kit/strokes.d.ts +93 -0
  173. package/dist/types/packages/desk/src/kit/text.d.ts +142 -0
  174. package/dist/types/packages/desk/src/kit/uniform.d.ts +8 -0
  175. package/dist/types/packages/desk/src/kit/view.d.ts +39 -0
  176. package/dist/types/packages/desk/src/kit/wgsl.d.ts +15 -0
  177. package/dist/types/packages/desk/src/lattice/line.d.ts +15 -0
  178. package/dist/types/packages/desk/src/lattice/lod.d.ts +52 -0
  179. package/dist/types/packages/desk/src/lattice/ruler.d.ts +88 -0
  180. package/dist/types/packages/desk/src/marks/assemble.d.ts +65 -0
  181. package/dist/types/packages/desk/src/marks/ease.d.ts +4 -0
  182. package/dist/types/packages/desk/src/marks/laser.d.ts +41 -0
  183. package/dist/types/packages/desk/src/marks/layout.d.ts +167 -0
  184. package/dist/types/packages/desk/src/marks/pass.d.ts +59 -0
  185. package/dist/types/packages/desk/src/marks/shaders.d.ts +12 -0
  186. package/dist/types/packages/desk/src/mat/grid.d.ts +50 -0
  187. package/dist/types/packages/desk/src/mat/lamp.d.ts +14 -0
  188. package/dist/types/packages/desk/src/mat/layout.d.ts +144 -0
  189. package/dist/types/packages/desk/src/mat/mat-pass.d.ts +83 -0
  190. package/dist/types/packages/desk/src/mat/night.d.ts +95 -0
  191. package/dist/types/packages/desk/src/mat/projector.d.ts +39 -0
  192. package/dist/types/packages/desk/src/mat/shaders.d.ts +17 -0
  193. package/dist/types/packages/desk/src/mat/tilt.d.ts +14 -0
  194. package/dist/types/packages/desk/src/nav/flight.d.ts +186 -0
  195. package/dist/types/packages/desk/src/nav/portal.d.ts +95 -0
  196. package/dist/types/packages/desk/src/object.d.ts +46 -0
  197. package/dist/types/packages/desk/src/pass-instrument.d.ts +89 -0
  198. package/dist/types/packages/desk/src/shaders.d.ts +12 -0
  199. package/dist/types/packages/desk/src/shaders.gen.d.ts +16 -0
  200. package/dist/types/packages/desk/src/submit-instrument.d.ts +36 -0
  201. package/dist/types/packages/desk/src/theme.d.ts +475 -0
  202. package/dist/types/packages/desk/src/tray/carry.d.ts +99 -0
  203. package/dist/types/packages/desk/src/tray/drawer.d.ts +113 -0
  204. package/dist/types/packages/desk/src/tray/flux.d.ts +46 -0
  205. package/dist/types/packages/desk/src/tray/index.d.ts +4 -0
  206. package/dist/types/packages/desk/src/tray/lattice.d.ts +71 -0
  207. package/dist/types/packages/desk/src/tray/layout.d.ts +7 -0
  208. package/dist/types/packages/desk/src/tray/look.d.ts +29 -0
  209. package/dist/types/packages/desk/src/tray/pass.d.ts +96 -0
  210. package/dist/types/packages/desk/src/tray/shaders.d.ts +10 -0
  211. package/dist/types/packages/desk/src/tray/specimens.d.ts +199 -0
  212. package/dist/types/packages/devtools/src/attach.d.ts +22 -8
  213. package/dist/types/packages/devtools/src/dock.d.ts +18 -14
  214. package/dist/types/packages/devtools/src/gpu-panel.d.ts +105 -0
  215. package/dist/types/packages/devtools/src/index.d.ts +5 -4
  216. package/dist/types/packages/dom/src/desk-host.d.ts +91 -0
  217. package/dist/types/packages/dom/src/host.d.ts +13 -14
  218. package/dist/types/packages/dom/src/index.d.ts +12 -10
  219. package/dist/types/packages/dom/src/loop.d.ts +18 -1
  220. package/dist/types/packages/dom/src/pointer-adapter.d.ts +5 -29
  221. package/dist/types/packages/dom/src/widget-focus.d.ts +17 -13
  222. package/dist/types/packages/ice/src/desk-engine.d.ts +2 -0
  223. package/dist/types/packages/ice/src/desk-kit.d.ts +6 -0
  224. package/dist/types/packages/ice/src/desk-objects.d.ts +5 -0
  225. package/dist/types/packages/ice/src/desk.d.ts +5 -0
  226. package/dist/types/packages/kernel/src/atlas-pack.d.ts +157 -0
  227. package/dist/types/packages/kernel/src/bezier.d.ts +0 -15
  228. package/dist/types/packages/kernel/src/coords.d.ts +0 -39
  229. package/dist/types/packages/kernel/src/index.d.ts +2 -2
  230. package/dist/types/packages/kernel/src/nav-flight.d.ts +6 -0
  231. package/dist/types/packages/kernel/src/tray.d.ts +155 -0
  232. package/dist/types/packages/objects/src/board/board-pass.d.ts +180 -0
  233. package/dist/types/packages/objects/src/board/board-pen.d.ts +36 -0
  234. package/dist/types/packages/objects/src/board/board.d.ts +104 -0
  235. package/dist/types/packages/objects/src/board/data.d.ts +31 -0
  236. package/dist/types/packages/objects/src/board/history.d.ts +33 -0
  237. package/dist/types/packages/objects/src/board/kind.d.ts +208 -0
  238. package/dist/types/packages/objects/src/board/layout.d.ts +102 -0
  239. package/dist/types/packages/objects/src/board/object.d.ts +7 -0
  240. package/dist/types/packages/objects/src/board/pen.d.ts +71 -0
  241. package/dist/types/packages/objects/src/board/shaders.d.ts +36 -0
  242. package/dist/types/packages/objects/src/board/stroke.d.ts +99 -0
  243. package/dist/types/packages/objects/src/board/theme.d.ts +150 -0
  244. package/dist/types/packages/objects/src/calendar/data.d.ts +97 -0
  245. package/dist/types/packages/objects/src/calendar/events.d.ts +58 -0
  246. package/dist/types/packages/objects/src/calendar/hand.d.ts +53 -0
  247. package/dist/types/packages/objects/src/calendar/host/input.d.ts +67 -0
  248. package/dist/types/packages/objects/src/calendar/host/print.d.ts +9 -0
  249. package/dist/types/packages/objects/src/calendar/kind.d.ts +297 -0
  250. package/dist/types/packages/objects/src/calendar/law.d.ts +151 -0
  251. package/dist/types/packages/objects/src/calendar/layout.d.ts +47 -0
  252. package/dist/types/packages/objects/src/calendar/month.d.ts +75 -0
  253. package/dist/types/packages/objects/src/calendar/object.d.ts +45 -0
  254. package/dist/types/packages/objects/src/calendar/pad.d.ts +42 -0
  255. package/dist/types/packages/objects/src/calendar/pass.d.ts +229 -0
  256. package/dist/types/packages/objects/src/calendar/print.d.ts +87 -0
  257. package/dist/types/packages/objects/src/calendar/printing.d.ts +80 -0
  258. package/dist/types/packages/objects/src/calendar/roll.d.ts +45 -0
  259. package/dist/types/packages/objects/src/calendar/shaders.d.ts +12 -0
  260. package/dist/types/packages/objects/src/calendar/sheet.d.ts +43 -0
  261. package/dist/types/packages/objects/src/calendar/tiles.d.ts +67 -0
  262. package/dist/types/packages/objects/src/calendar/turn.d.ts +73 -0
  263. package/dist/types/packages/objects/src/calendar/writing.d.ts +42 -0
  264. package/dist/types/packages/objects/src/index.d.ts +22 -0
  265. package/dist/types/packages/objects/src/kinds.d.ts +24 -0
  266. package/dist/types/packages/objects/src/minimat/inside.d.ts +17 -0
  267. package/dist/types/packages/objects/src/minimat/kind.d.ts +51 -0
  268. package/dist/types/packages/objects/src/minimat/layout.d.ts +83 -0
  269. package/dist/types/packages/objects/src/minimat/minimat.d.ts +179 -0
  270. package/dist/types/packages/objects/src/minimat/object.d.ts +8 -0
  271. package/dist/types/packages/objects/src/minimat/pass.d.ts +61 -0
  272. package/dist/types/packages/objects/src/minimat/shaders.d.ts +10 -0
  273. package/dist/types/packages/objects/src/minimat/theme.d.ts +98 -0
  274. package/dist/types/packages/objects/src/notebook/ink.d.ts +70 -0
  275. package/dist/types/packages/objects/src/notebook/kind.d.ts +236 -0
  276. package/dist/types/packages/objects/src/notebook/law.d.ts +129 -0
  277. package/dist/types/packages/objects/src/notebook/layout.d.ts +46 -0
  278. package/dist/types/packages/objects/src/notebook/leaf.d.ts +44 -0
  279. package/dist/types/packages/objects/src/notebook/mesh.d.ts +20 -0
  280. package/dist/types/packages/objects/src/notebook/motion.d.ts +107 -0
  281. package/dist/types/packages/objects/src/notebook/object.d.ts +8 -0
  282. package/dist/types/packages/objects/src/notebook/pages.d.ts +56 -0
  283. package/dist/types/packages/objects/src/notebook/pass.d.ts +197 -0
  284. package/dist/types/packages/objects/src/notebook/pick.d.ts +30 -0
  285. package/dist/types/packages/objects/src/notebook/raster.d.ts +28 -0
  286. package/dist/types/packages/objects/src/notebook/shaders.d.ts +11 -0
  287. package/dist/types/packages/objects/src/notebook/shape.d.ts +155 -0
  288. package/dist/types/packages/objects/src/notebook/theme.d.ts +76 -0
  289. package/dist/types/packages/objects/src/palette.d.ts +577 -0
  290. package/dist/types/packages/objects/src/paper/host/body.d.ts +30 -0
  291. package/dist/types/packages/objects/src/paper/kind.d.ts +81 -0
  292. package/dist/types/packages/objects/src/paper/layout.d.ts +73 -0
  293. package/dist/types/packages/objects/src/paper/object.d.ts +31 -0
  294. package/dist/types/packages/objects/src/paper/pages.d.ts +43 -0
  295. package/dist/types/packages/objects/src/paper/paper-pass.d.ts +86 -0
  296. package/dist/types/packages/objects/src/paper/paper.d.ts +117 -0
  297. package/dist/types/packages/objects/src/paper/shaders.d.ts +18 -0
  298. package/dist/types/packages/objects/src/paper/theme.d.ts +58 -0
  299. package/dist/types/packages/objects/src/paper/typing.d.ts +51 -0
  300. package/dist/types/packages/objects/src/paper/writing.d.ts +161 -0
  301. package/dist/types/packages/objects/src/photo/carry.d.ts +33 -0
  302. package/dist/types/packages/objects/src/photo/kind.d.ts +136 -0
  303. package/dist/types/packages/objects/src/photo/layout.d.ts +39 -0
  304. package/dist/types/packages/objects/src/photo/object.d.ts +5 -0
  305. package/dist/types/packages/objects/src/photo/photo-pass.d.ts +104 -0
  306. package/dist/types/packages/objects/src/photo/photo.d.ts +262 -0
  307. package/dist/types/packages/objects/src/photo/pictures.d.ts +152 -0
  308. package/dist/types/packages/objects/src/photo/sample.d.ts +9 -0
  309. package/dist/types/packages/objects/src/photo/shaders.d.ts +18 -0
  310. package/dist/types/packages/objects/src/preset.d.ts +44 -0
  311. package/dist/types/packages/objects/src/shaders.d.ts +3 -0
  312. package/dist/types/packages/objects/src/shaders.gen.d.ts +21 -0
  313. package/dist/types/packages/react/src/canvas-hooks.d.ts +12 -0
  314. package/dist/types/packages/react/src/desk.d.ts +56 -0
  315. package/dist/types/packages/react/src/engine-context.d.ts +2 -2
  316. package/dist/types/packages/react/src/frame-preview-boundary.d.ts +19 -0
  317. package/dist/types/packages/react/src/hooks.d.ts +9 -14
  318. package/dist/types/packages/react/src/index.d.ts +16 -9
  319. package/dist/types/packages/react/src/keymap.d.ts +21 -2
  320. package/dist/types/packages/react/src/selection-menu.d.ts +171 -0
  321. package/dist/types/packages/react/src/tray-bar.d.ts +124 -0
  322. package/package.json +64 -31
  323. package/dist/chunk-5FQS7V2C.js.map +0 -1
  324. package/dist/chunk-JWRHAM7L.js +0 -1163
  325. package/dist/chunk-JWRHAM7L.js.map +0 -1
  326. package/dist/chunk-MFTMPJUF.js +0 -681
  327. package/dist/chunk-MFTMPJUF.js.map +0 -1
  328. package/dist/chunk-OR5FNVUE.js.map +0 -1
  329. package/dist/ground.js +0 -1213
  330. package/dist/ground.js.map +0 -1
  331. package/dist/r3f.js +0 -1644
  332. package/dist/r3f.js.map +0 -1
  333. package/dist/types/packages/core/src/input/measure-queue.d.ts +0 -30
  334. package/dist/types/packages/core/src/settings/ground-config.d.ts +0 -103
  335. package/dist/types/packages/core/src/systems/measure-ingest.d.ts +0 -26
  336. package/dist/types/packages/devtools/src/gl-panel.d.ts +0 -69
  337. package/dist/types/packages/dom/src/measure-adapter.d.ts +0 -31
  338. package/dist/types/packages/dom/src/measure-wiring.d.ts +0 -49
  339. package/dist/types/packages/dom/src/planes.d.ts +0 -33
  340. package/dist/types/packages/dom/src/reflectors/chrome.d.ts +0 -33
  341. package/dist/types/packages/dom/src/reflectors/dom-widgets.d.ts +0 -59
  342. package/dist/types/packages/dom/src/reflectors/graybox.d.ts +0 -31
  343. package/dist/types/packages/dom/src/reflectors/plane-transform.d.ts +0 -38
  344. package/dist/types/packages/ground/src/index.d.ts +0 -69
  345. package/dist/types/packages/ground/src/layer.d.ts +0 -40
  346. package/dist/types/packages/ground/src/pass.d.ts +0 -41
  347. package/dist/types/packages/ground/src/passes/grid-classic.d.ts +0 -30
  348. package/dist/types/packages/ground/src/passes/grid-magnet.d.ts +0 -31
  349. package/dist/types/packages/ground/src/passes/grid.d.ts +0 -28
  350. package/dist/types/packages/ground/src/passes/guides-collect.d.ts +0 -14
  351. package/dist/types/packages/ground/src/passes/guides.d.ts +0 -3
  352. package/dist/types/packages/ground/src/passes/magnet-collect.d.ts +0 -63
  353. package/dist/types/packages/ground/src/passes/soup-collect.d.ts +0 -35
  354. package/dist/types/packages/ground/src/passes/soup-mesh.d.ts +0 -8
  355. package/dist/types/packages/ground/src/passes/wires-collect.d.ts +0 -35
  356. package/dist/types/packages/ground/src/passes/wires.d.ts +0 -10
  357. package/dist/types/packages/ground/src/poles.d.ts +0 -47
  358. package/dist/types/packages/ground/src/renderer.d.ts +0 -15
  359. package/dist/types/packages/ice/src/ground.d.ts +0 -1
  360. package/dist/types/packages/ice/src/r3f.d.ts +0 -1
  361. package/dist/types/packages/kernel/src/eviction.d.ts +0 -23
  362. package/dist/types/packages/kernel/src/zoom-bands.d.ts +0 -19
  363. package/dist/types/packages/r3f/src/bridge.d.ts +0 -129
  364. package/dist/types/packages/r3f/src/composite-material.d.ts +0 -26
  365. package/dist/types/packages/r3f/src/compositor-pass.d.ts +0 -105
  366. package/dist/types/packages/r3f/src/dev-write-trap.d.ts +0 -30
  367. package/dist/types/packages/r3f/src/gl-root.d.ts +0 -96
  368. package/dist/types/packages/r3f/src/gl-router.d.ts +0 -70
  369. package/dist/types/packages/r3f/src/index.d.ts +0 -17
  370. package/dist/types/packages/r3f/src/island-state.d.ts +0 -112
  371. package/dist/types/packages/r3f/src/island.d.ts +0 -13
  372. package/dist/types/packages/r3f/src/pool.d.ts +0 -56
  373. package/dist/types/packages/r3f/src/preview-capture.d.ts +0 -19
  374. package/dist/types/packages/r3f/src/resource-registry.d.ts +0 -30
  375. package/dist/types/packages/r3f/src/self-sustain.d.ts +0 -39
  376. package/dist/types/packages/r3f/src/use-island-frame.d.ts +0 -39
  377. package/dist/types/packages/react/src/infinite-canvas.d.ts +0 -140
  378. package/dist/types/packages/react/src/preview-snapshots.d.ts +0 -17
  379. package/dist/types/packages/react/src/widget-preview.d.ts +0 -14
  380. package/dist/types/packages/react/src/widget-root.d.ts +0 -33
package/dist/ground.js DELETED
@@ -1,1213 +0,0 @@
1
- import {
2
- Active,
3
- Camera,
4
- Culled,
5
- CursorVisual,
6
- DEFAULT_GRID_CONFIG,
7
- DEFAULT_GRID_MAGNET_CONFIG,
8
- DEFAULT_SNAP_GUIDES_CONFIG,
9
- DEFAULT_WIRES_CONFIG,
10
- Drag,
11
- GuideLine,
12
- LocalPointer,
13
- MeasuredSize,
14
- Pointer,
15
- PointerWorld,
16
- Port,
17
- PortAnchor,
18
- Position,
19
- PrefabId,
20
- RoutedConnect,
21
- Selected,
22
- Size,
23
- SpacingBar,
24
- SpatialVersion,
25
- Wire,
26
- WireFrom,
27
- WirePorts,
28
- WireTo,
29
- defineQuery,
30
- portSlots,
31
- widgets
32
- } from "./chunk-5FQS7V2C.js";
33
- import {
34
- portAnchor,
35
- tessellateCubic,
36
- wireCubic,
37
- worldToScreen
38
- } from "./chunk-OR5FNVUE.js";
39
-
40
- // ../ground/src/layer.ts
41
- import { OrthographicCamera, Scene } from "three/webgpu";
42
- function createLayer(host, world, renderer, passes) {
43
- const doc = host.container.ownerDocument;
44
- const canvas = renderer.canvas;
45
- canvas.style.position = "absolute";
46
- canvas.style.left = "0";
47
- canvas.style.top = "0";
48
- canvas.style.width = "100%";
49
- canvas.style.height = "100%";
50
- canvas.style.display = "block";
51
- canvas.style.pointerEvents = "none";
52
- host.container.insertBefore(canvas, host.contentPlane);
53
- const scene = new Scene();
54
- const camera = new OrthographicCamera(0, 1, 0, 1, -1e3, 1e3);
55
- for (const pass of passes) scene.add(pass.object);
56
- const dirty = /* @__PURE__ */ new Map();
57
- for (const pass of passes) dirty.set(pass, true);
58
- let anyDirty = true;
59
- const wakeAll = () => {
60
- for (const pass of passes) dirty.set(pass, true);
61
- anyDirty = true;
62
- };
63
- const unsubs = [
64
- // Camera moves re-map every pass's screen-space geometry (2D-canvas parity).
65
- world.reactive.observeResource(Camera, wakeAll)
66
- ];
67
- for (const pass of passes) {
68
- unsubs.push(
69
- ...pass.arm(world, () => {
70
- dirty.set(pass, true);
71
- anyDirty = true;
72
- })
73
- );
74
- }
75
- renderer.onReady(wakeAll);
76
- let cssW = 0;
77
- let cssH = 0;
78
- let dpr = 1;
79
- const applySize = (w, h) => {
80
- dpr = doc.defaultView?.devicePixelRatio ?? 1;
81
- cssW = w;
82
- cssH = h;
83
- renderer.setSize(w, h, dpr);
84
- camera.left = 0;
85
- camera.right = Math.max(1, w);
86
- camera.top = 0;
87
- camera.bottom = Math.max(1, h);
88
- camera.updateProjectionMatrix();
89
- wakeAll();
90
- };
91
- const initialRect = host.container.getBoundingClientRect();
92
- applySize(initialRect.width, initialRect.height);
93
- let ro = null;
94
- try {
95
- ro = new ResizeObserver((entries) => {
96
- const entry = entries[0];
97
- if (entry === void 0) return;
98
- applySize(entry.contentRect.width, entry.contentRect.height);
99
- });
100
- ro.observe(host.container);
101
- } catch {
102
- ro = null;
103
- }
104
- let redraws = 0;
105
- const reflector = {
106
- name: "ground",
107
- // Self-gated on the dirty union (wires/chrome precedent) — the every-frame
108
- // cost is one boolean check.
109
- always: true,
110
- flush(w) {
111
- if (!anyDirty || renderer.failed()) return;
112
- if (!renderer.ready()) return;
113
- const cam = w.getResource(Camera);
114
- if (cam === void 0) return;
115
- anyDirty = false;
116
- const frame = { width: cssW, height: cssH, dpr, camera: cam };
117
- for (const pass of passes) {
118
- if (dirty.get(pass) === true) {
119
- dirty.set(pass, false);
120
- pass.collect(w, frame);
121
- }
122
- }
123
- redraws++;
124
- renderer.render(scene, camera);
125
- },
126
- available: () => renderer.ready() && !renderer.failed(),
127
- redraws: () => redraws
128
- };
129
- return {
130
- reflector,
131
- invalidateAll: wakeAll,
132
- dispose() {
133
- for (const u of unsubs) u();
134
- unsubs.length = 0;
135
- ro?.disconnect();
136
- ro = null;
137
- for (const pass of passes) pass.dispose();
138
- renderer.dispose();
139
- canvas.remove();
140
- }
141
- };
142
- }
143
-
144
- // ../ground/src/passes/grid.ts
145
- import { Group as Group2 } from "three/webgpu";
146
-
147
- // ../ground/src/passes/grid-classic.ts
148
- import {
149
- clamp,
150
- float,
151
- fract,
152
- length,
153
- max,
154
- min,
155
- mix,
156
- positionGeometry,
157
- screenCoordinate,
158
- smoothstep,
159
- uniform,
160
- vec4
161
- } from "three/tsl";
162
- import {
163
- BufferAttribute,
164
- BufferGeometry,
165
- Mesh,
166
- MeshBasicNodeMaterial,
167
- Vector2,
168
- Vector3
169
- } from "three/webgpu";
170
- var FULLSCREEN_TRIANGLE = new Float32Array([-1, -1, 0, 3, -1, 0, -1, 3, 0]);
171
- function createClassicGrid(cfg) {
172
- const uCamera = uniform(new Vector2(0, 0));
173
- const uZoom = uniform(1);
174
- const uDpr = uniform(1);
175
- const uSpacings = uniform(new Vector3(...cfg.spacings));
176
- const uDotColor = uniform(new Vector3(...cfg.dotColor));
177
- const uDotAlpha = uniform(cfg.dotAlpha);
178
- const uFadeIn = uniform(new Vector2(...cfg.fadeIn));
179
- const uFadeOut = uniform(new Vector2(...cfg.fadeOut));
180
- const uDotRadius = uniform(new Vector2(...cfg.dotRadius));
181
- const uLevelWeight = uniform(new Vector2(...cfg.levelWeight));
182
- const effZoom = uZoom.mul(uDpr);
183
- const worldPos = screenCoordinate.xy.div(effZoom).add(uCamera);
184
- let total = float(0);
185
- for (let i = 0; i < 3; i++) {
186
- const spacing = i === 0 ? uSpacings.x : i === 1 ? uSpacings.y : uSpacings.z;
187
- const cssSpacing = spacing.mul(uZoom);
188
- const rise = cssSpacing.sub(uFadeIn.x).div(uFadeIn.y.sub(uFadeIn.x));
189
- const fall = float(1).sub(cssSpacing.sub(uFadeOut.x).div(uFadeOut.y.sub(uFadeOut.x)));
190
- const opacity = clamp(min(rise, fall), 0, 1);
191
- const f = fract(worldPos.div(spacing).add(0.5)).sub(0.5);
192
- const dist = length(f).mul(spacing).mul(effZoom);
193
- const t = clamp(cssSpacing.sub(uFadeIn.x).div(40), 0, 1);
194
- const radius = mix(uDotRadius.x, uDotRadius.y, t).mul(uDpr);
195
- const dot = smoothstep(radius.sub(0.5), radius.add(0.5), dist).oneMinus();
196
- const weight = uLevelWeight.x.add(float(i).mul(uLevelWeight.y));
197
- total = max(total, dot.mul(opacity).mul(weight));
198
- }
199
- const material = new MeshBasicNodeMaterial();
200
- material.vertexNode = vec4(positionGeometry.xy, 0, 1);
201
- material.fragmentNode = vec4(uDotColor, clamp(total.mul(uDotAlpha), 0, 1));
202
- material.transparent = true;
203
- material.depthTest = false;
204
- material.depthWrite = false;
205
- const geometry = new BufferGeometry();
206
- geometry.setAttribute("position", new BufferAttribute(FULLSCREEN_TRIANGLE, 3));
207
- const mesh = new Mesh(geometry, material);
208
- mesh.frustumCulled = false;
209
- mesh.renderOrder = 0;
210
- return {
211
- mesh,
212
- setCamera(frame) {
213
- uCamera.value.set(frame.camera.x, frame.camera.y);
214
- uZoom.value = frame.camera.zoom;
215
- uDpr.value = frame.dpr;
216
- },
217
- configure(next) {
218
- uSpacings.value.set(...next.spacings);
219
- uDotColor.value.set(...next.dotColor);
220
- uDotAlpha.value = next.dotAlpha;
221
- uFadeIn.value.set(...next.fadeIn);
222
- uFadeOut.value.set(...next.fadeOut);
223
- uDotRadius.value.set(...next.dotRadius);
224
- uLevelWeight.value.set(...next.levelWeight);
225
- },
226
- dispose() {
227
- geometry.dispose();
228
- material.dispose();
229
- }
230
- };
231
- }
232
-
233
- // ../ground/src/passes/grid-magnet.ts
234
- import {
235
- Fn,
236
- If,
237
- Loop,
238
- abs,
239
- clamp as clamp2,
240
- float as float2,
241
- instanceIndex,
242
- int,
243
- length as length2,
244
- max as max2,
245
- min as min2,
246
- mix as mix2,
247
- mod,
248
- positionGeometry as positionGeometry2,
249
- select,
250
- sign,
251
- smoothstep as smoothstep2,
252
- sqrt,
253
- storage,
254
- uniform as uniform2,
255
- varying,
256
- vec2,
257
- vec4 as vec42,
258
- Continue,
259
- Discard
260
- } from "three/tsl";
261
- import {
262
- BufferAttribute as BufferAttribute2,
263
- Group,
264
- InstancedBufferGeometry,
265
- Mesh as Mesh2,
266
- MeshBasicNodeMaterial as MeshBasicNodeMaterial2,
267
- StorageBufferAttribute,
268
- Vector2 as Vector22,
269
- Vector3 as Vector32
270
- } from "three/webgpu";
271
-
272
- // ../ground/src/passes/soup-collect.ts
273
- var SoupBuilder = class {
274
- pos = [];
275
- col = [];
276
- vert(x, y, c) {
277
- this.pos.push(x, y, 0);
278
- this.col.push(c[0], c[1], c[2], c[3]);
279
- }
280
- /** Axis-aligned rect (two triangles). */
281
- rect(x, y, w, h, c) {
282
- this.vert(x, y, c);
283
- this.vert(x + w, y, c);
284
- this.vert(x + w, y + h, c);
285
- this.vert(x, y, c);
286
- this.vert(x + w, y + h, c);
287
- this.vert(x, y + h, c);
288
- }
289
- /** Stroke segment (a→b) of `width`, flat caps — a quad across the segment normal. */
290
- segment(ax, ay, bx, by, width, c) {
291
- const dx = bx - ax;
292
- const dy = by - ay;
293
- const len = Math.hypot(dx, dy);
294
- if (len < 1e-6) return;
295
- const nx = -dy / len * (width / 2);
296
- const ny = dx / len * (width / 2);
297
- this.vert(ax + nx, ay + ny, c);
298
- this.vert(bx + nx, by + ny, c);
299
- this.vert(bx - nx, by - ny, c);
300
- this.vert(ax + nx, ay + ny, c);
301
- this.vert(bx - nx, by - ny, c);
302
- this.vert(ax - nx, ay - ny, c);
303
- }
304
- /** Stroke a polyline (interleaved xy) as per-segment quads (smooth-curve joins). */
305
- polyline(points, width, c) {
306
- const n = Math.floor(points.length / 2);
307
- for (let i = 1; i < n; i++) {
308
- this.segment(
309
- points[(i - 1) * 2],
310
- points[(i - 1) * 2 + 1],
311
- points[i * 2],
312
- points[i * 2 + 1],
313
- width,
314
- c
315
- );
316
- }
317
- }
318
- /** Filled disc as a triangle fan (MSAA smooths the rim; 16 segs ≈ round at ≤8 px). */
319
- disc(cx, cy, r, c, segments = 16) {
320
- for (let i = 0; i < segments; i++) {
321
- const a0 = i / segments * Math.PI * 2;
322
- const a1 = (i + 1) / segments * Math.PI * 2;
323
- this.vert(cx, cy, c);
324
- this.vert(cx + Math.cos(a0) * r, cy + Math.sin(a0) * r, c);
325
- this.vert(cx + Math.cos(a1) * r, cy + Math.sin(a1) * r, c);
326
- }
327
- }
328
- build() {
329
- return {
330
- positions: new Float32Array(this.pos),
331
- colors: new Float32Array(this.col),
332
- vertexCount: this.pos.length / 3
333
- };
334
- }
335
- };
336
- function parseCssColor(css) {
337
- const rgba = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(css);
338
- if (rgba !== null) {
339
- return [
340
- Number(rgba[1]) / 255,
341
- Number(rgba[2]) / 255,
342
- Number(rgba[3]) / 255,
343
- rgba[4] === void 0 ? 1 : Number(rgba[4])
344
- ];
345
- }
346
- const hex = /^#([0-9a-f]{6})$/i.exec(css);
347
- if (hex !== null) {
348
- const v = Number.parseInt(hex[1], 16);
349
- return [(v >> 16 & 255) / 255, (v >> 8 & 255) / 255, (v & 255) / 255, 1];
350
- }
351
- return [0.5, 0.5, 0.5, 1];
352
- }
353
-
354
- // ../ground/src/passes/wires-collect.ts
355
- var wireQ = defineQuery([Wire]);
356
- var geometryQ = defineQuery([Position, Size]);
357
- var measuredQ = defineQuery([MeasuredSize]);
358
- var selectedQ = defineQuery([Selected]);
359
- var portQ = defineQuery([Port, PortAnchor]);
360
- var routedConnectQ = defineQuery([RoutedConnect]);
361
- var connectDragQ = defineQuery([RoutedConnect, Drag]);
362
- var activeQ = defineQuery([Active]);
363
- function outOfScope(world, e) {
364
- return world.hasTag(e, Culled) && !world.hasTag(e, Active);
365
- }
366
- var TESSELLATION_TOLERANCE_PX = 0.25;
367
- var DASH_PX = 6;
368
- var GAP_PX = 4;
369
- function readWidgetRect(world, e) {
370
- const p = world.get(e, Position);
371
- if (p === void 0) return void 0;
372
- const measured = world.get(e, MeasuredSize);
373
- const s = measured !== void 0 && measured.w > 0 ? measured : world.get(e, Size);
374
- if (s === void 0) return void 0;
375
- return { x: p.x, y: p.y, width: s.w, height: s.h };
376
- }
377
- var slotCache = /* @__PURE__ */ new Map();
378
- function slotOf(wt, portId) {
379
- let slots = slotCache.get(wt.type);
380
- if (slots === void 0) {
381
- slots = portSlots(wt.ports);
382
- slotCache.set(wt.type, slots);
383
- }
384
- return slots.get(portId);
385
- }
386
- function endpointAnchor(world, widget, portId) {
387
- if (widget === void 0) return void 0;
388
- const rect = readWidgetRect(world, widget);
389
- if (rect === void 0) return void 0;
390
- const type = world.get(widget, PrefabId)?.id;
391
- if (typeof type !== "string") return void 0;
392
- const wt = widgets.get(type);
393
- if (wt === void 0) return void 0;
394
- const slot = slotOf(wt, portId);
395
- if (slot === void 0) return void 0;
396
- return { anchor: rect, slot };
397
- }
398
- function cubicToScreen(c, cam) {
399
- const p0 = worldToScreen(c.x0, c.y0, cam);
400
- const p1 = worldToScreen(c.x1, c.y1, cam);
401
- const p2 = worldToScreen(c.x2, c.y2, cam);
402
- const p3 = worldToScreen(c.x3, c.y3, cam);
403
- return { x0: p0.x, y0: p0.y, x1: p1.x, y1: p1.y, x2: p2.x, y2: p2.y, x3: p3.x, y3: p3.y };
404
- }
405
- function pointAtLength(t, d) {
406
- const arc = t.arcLength;
407
- const n = arc.length;
408
- let lo = 0;
409
- let hi = n - 1;
410
- while (lo < hi) {
411
- const mid = lo + hi >> 1;
412
- if (arc[mid] < d) lo = mid + 1;
413
- else hi = mid;
414
- }
415
- const i = Math.max(1, lo);
416
- const a = arc[i - 1];
417
- const b = arc[i];
418
- const f = b > a ? (d - a) / (b - a) : 0;
419
- const x0 = t.points[(i - 1) * 2];
420
- const y0 = t.points[(i - 1) * 2 + 1];
421
- const x1 = t.points[i * 2];
422
- const y1 = t.points[i * 2 + 1];
423
- return { x: x0 + (x1 - x0) * f, y: y0 + (y1 - y0) * f };
424
- }
425
- function dashedStroke(soup, t, width, c) {
426
- const total = t.arcLength[t.arcLength.length - 1];
427
- for (let d = 0; d < total; d += DASH_PX + GAP_PX) {
428
- const a = pointAtLength(t, d);
429
- const b = pointAtLength(t, Math.min(d + DASH_PX, total));
430
- soup.segment(a.x, a.y, b.x, b.y, width, c);
431
- }
432
- }
433
- function collectWires(world, frame, config = DEFAULT_WIRES_CONFIG, preview) {
434
- const soup = new SoupBuilder();
435
- const cam = frame.camera;
436
- const wireColor = parseCssColor(config.wireColor);
437
- const selectedColor = parseCssColor(config.selectedColor);
438
- world.query(wireQ).each((batch) => {
439
- for (const r of batch) {
440
- const wire = batch.entity(r);
441
- const ports = world.get(wire, WirePorts);
442
- if (ports === void 0) continue;
443
- const fromWidget = world.getRelation(wire, WireFrom);
444
- const toWidget = world.getRelation(wire, WireTo);
445
- if (fromWidget !== void 0 && outOfScope(world, fromWidget)) continue;
446
- if (toWidget !== void 0 && outOfScope(world, toWidget)) continue;
447
- const from = endpointAnchor(world, fromWidget, ports.from ?? "");
448
- const to = endpointAnchor(world, toWidget, ports.to ?? "");
449
- if (from === void 0 || to === void 0) continue;
450
- const cubic = wireCubic(
451
- portAnchor(from.anchor, from.slot),
452
- from.slot.side,
453
- portAnchor(to.anchor, to.slot),
454
- to.slot.side
455
- );
456
- const selected = world.hasTag(wire, Selected);
457
- const t = tessellateCubic(cubicToScreen(cubic, cam), TESSELLATION_TOLERANCE_PX);
458
- soup.polyline(t.points, selected ? config.selectedWidth : config.wireWidth, selected ? selectedColor : wireColor);
459
- }
460
- });
461
- if (preview?.active === true) {
462
- const stub = Math.max(24, Math.abs(preview.tx - preview.sx) * 0.5);
463
- const cubic = {
464
- x0: preview.sx,
465
- y0: preview.sy,
466
- x1: preview.sx + stub,
467
- y1: preview.sy,
468
- x2: preview.tx - stub,
469
- y2: preview.ty,
470
- x3: preview.tx,
471
- y3: preview.ty
472
- };
473
- const t = tessellateCubic(cubicToScreen(cubic, cam), TESSELLATION_TOLERANCE_PX);
474
- if (preview.compatible) soup.polyline(t.points, config.wireWidth, selectedColor);
475
- else dashedStroke(soup, t, config.wireWidth, wireColor);
476
- }
477
- const connecting = world.firstOf(routedConnectQ) !== void 0;
478
- const dotColor = parseCssColor(connecting ? config.portActiveColor : config.portColor);
479
- world.query(portQ).each((batch) => {
480
- const ax = batch.col(PortAnchor).x;
481
- const ay = batch.col(PortAnchor).y;
482
- for (const r of batch) {
483
- const s = worldToScreen(ax[r], ay[r], cam);
484
- soup.disc(s.x, s.y, config.portRadius, dotColor);
485
- }
486
- });
487
- return soup.build();
488
- }
489
-
490
- // ../ground/src/passes/magnet-collect.ts
491
- var MAGNET_SOURCE_FLOATS = 8;
492
- var MAX_MAGNET_SOURCES = 256;
493
- var MAX_MAGNET_INSTANCES = 22e4;
494
- function resolveMagnet(cfg) {
495
- return { ...DEFAULT_GRID_MAGNET_CONFIG, ...cfg.magnet };
496
- }
497
- function fadeOpacity(cssSpacing, fadeIn, fadeOut) {
498
- const rise = (cssSpacing - fadeIn[0]) / Math.max(fadeIn[1] - fadeIn[0], 1e-4);
499
- const fall = 1 - (cssSpacing - fadeOut[0]) / Math.max(fadeOut[1] - fadeOut[0], 1e-4);
500
- return Math.min(Math.max(Math.min(rise, fall), 0), 1);
501
- }
502
- function magnetFieldScale(zoom, fadeZoom) {
503
- if (fadeZoom <= 0) return 1;
504
- const t = (zoom - 0.7 * fadeZoom) / (0.3 * fadeZoom);
505
- return Math.min(Math.max(t, 0), 1);
506
- }
507
- function collectMagnetLevels(frame, cfg) {
508
- const { camera } = frame;
509
- const out = [];
510
- const opacities = cfg.spacings.map((s) => fadeOpacity(s * camera.zoom, cfg.fadeIn, cfg.fadeOut));
511
- for (let i = 0; i < cfg.spacings.length; i++) {
512
- const spacing = cfg.spacings[i];
513
- const opacity = opacities[i];
514
- const weight = cfg.levelWeight[0] + i * cfg.levelWeight[1];
515
- const alpha = opacity * weight * cfg.dotAlpha;
516
- if (opacity < 0.01 || alpha <= 0) {
517
- out.push({ i0: 0, j0: 0, cols: 0, rows: 0, count: 0, alpha: 0, skipModulo: 0 });
518
- continue;
519
- }
520
- const worldW = frame.width / camera.zoom;
521
- const worldH = frame.height / camera.zoom;
522
- const i0 = Math.floor(camera.x / spacing) - 1;
523
- const j0 = Math.floor(camera.y / spacing) - 1;
524
- const i1 = Math.ceil((camera.x + worldW) / spacing) + 1;
525
- const j1 = Math.ceil((camera.y + worldH) / spacing) + 1;
526
- const cols = Math.max(1, i1 - i0);
527
- const rows = Math.max(1, j1 - j0);
528
- const count = cols * rows;
529
- if (count > MAX_MAGNET_INSTANCES) {
530
- out.push({ i0: 0, j0: 0, cols: 0, rows: 0, count: 0, alpha: 0, skipModulo: 0 });
531
- continue;
532
- }
533
- let skipModulo = 0;
534
- const next = cfg.spacings[i + 1];
535
- if (next !== void 0 && opacities[i + 1] >= 0.01) {
536
- const ratio = next / spacing;
537
- if (Number.isInteger(ratio) && ratio > 1) skipModulo = ratio;
538
- }
539
- out.push({ i0, j0, cols, rows, count, alpha, skipModulo });
540
- }
541
- return out;
542
- }
543
- function collectMagnetSources(world, frame, magnet, fieldScale, poles, readSpatial, out) {
544
- if (fieldScale <= 0) return 0;
545
- const { camera } = frame;
546
- const cap = Math.min(magnet.maxSources, MAX_MAGNET_SOURCES, Math.floor(out.length / MAGNET_SOURCE_FLOATS));
547
- let n = 0;
548
- for (const pole of poles) {
549
- if (n >= cap) break;
550
- if (!(pole.strength > 0)) continue;
551
- const s = pole.space === "screen" ? pole : worldToScreen(pole.x, pole.y, camera);
552
- const o = n * MAGNET_SOURCE_FLOATS;
553
- out[o + 0] = s.x;
554
- out[o + 1] = s.y;
555
- out[o + 2] = 0;
556
- out[o + 3] = 0;
557
- out[o + 4] = 0;
558
- out[o + 5] = pole.strength * fieldScale;
559
- out[o + 6] = 0;
560
- out[o + 7] = 0;
561
- n++;
562
- }
563
- if (!magnet.widgets || readSpatial === void 0 || magnet.widgetStrength <= 0 || n >= cap) {
564
- return n;
565
- }
566
- const haloCss = 5 * magnet.reach * Math.sqrt(Math.max(magnet.widgetStrength * fieldScale, 1e-4));
567
- const pad = haloCss / camera.zoom;
568
- const hits = readSpatial({
569
- minX: camera.x - pad,
570
- minY: camera.y - pad,
571
- maxX: camera.x + frame.width / camera.zoom + pad,
572
- maxY: camera.y + frame.height / camera.zoom + pad
573
- });
574
- const viewCx = frame.width / 2;
575
- const viewCy = frame.height / 2;
576
- const candidates = [];
577
- for (const hit of hits) {
578
- const rect = readWidgetRect(world, hit.id);
579
- if (rect === void 0 || rect.width <= 0 || rect.height <= 0) continue;
580
- const hx = rect.width / 2 * camera.zoom;
581
- const hy = rect.height / 2 * camera.zoom;
582
- const center = worldToScreen(rect.x + rect.width / 2, rect.y + rect.height / 2, camera);
583
- candidates.push({
584
- cx: center.x,
585
- cy: center.y,
586
- hx,
587
- hy,
588
- r: Math.min(magnet.widgetRadius * camera.zoom, hx, hy),
589
- area: hx * hy,
590
- centerDist: (center.x - viewCx) ** 2 + (center.y - viewCy) ** 2
591
- });
592
- }
593
- const budget = cap - n;
594
- if (candidates.length > budget) {
595
- candidates.sort((a, b) => b.area - a.area || a.centerDist - b.centerDist);
596
- candidates.length = budget;
597
- }
598
- const strength = magnet.widgetStrength * fieldScale;
599
- for (const c of candidates) {
600
- const o = n * MAGNET_SOURCE_FLOATS;
601
- out[o + 0] = c.cx;
602
- out[o + 1] = c.cy;
603
- out[o + 2] = c.hx;
604
- out[o + 3] = c.hy;
605
- out[o + 4] = c.r;
606
- out[o + 5] = strength;
607
- out[o + 6] = 0;
608
- out[o + 7] = 0;
609
- n++;
610
- }
611
- return n;
612
- }
613
-
614
- // ../ground/src/passes/grid-magnet.ts
615
- var CORNERS = new Float32Array([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0]);
616
- var LEVELS = 3;
617
- function createMagnetGrid() {
618
- const sourceArray = new Float32Array(MAX_MAGNET_SOURCES * MAGNET_SOURCE_FLOATS);
619
- const sourceAttr = new StorageBufferAttribute(sourceArray, 4);
620
- const sourceBuf = storage(sourceAttr, "vec4", MAX_MAGNET_SOURCES * 2).setPBO(true).toReadOnly();
621
- const uCam = uniform2(new Vector22(0, 0));
622
- const uZoom = uniform2(1);
623
- const uView = uniform2(new Vector22(1, 1));
624
- const uDotMode = uniform2(0);
625
- const uHalfLen = uniform2(5);
626
- const uHalfWidth = uniform2(0.55);
627
- const uRestRadius = uniform2(0.75);
628
- const uK = uniform2(0);
629
- const uPad = uniform2(0);
630
- const uPolarity = uniform2(1);
631
- const uAlwaysAlign = uniform2(0);
632
- const uCount = uniform2(0, "int");
633
- const uColor = uniform2(new Vector32(0.75, 0.77, 0.8));
634
- const EPS = float2(25);
635
- const REST = vec2(0, 1);
636
- const sdRoundBox = Fn(([p, b, r]) => {
637
- const q = abs(p).sub(b).add(vec2(r, r));
638
- return length2(max2(q, vec2(0, 0))).add(min2(max2(q.x, q.y), 0)).sub(r);
639
- });
640
- const roundBoxNormal = Fn(([p, b, r]) => {
641
- const s = sign(p);
642
- const q = abs(p);
643
- const inner = max2(b.sub(vec2(r, r)), vec2(0, 0));
644
- const d = q.sub(inner);
645
- const n = vec2(0, 0).toVar();
646
- If(d.x.greaterThan(0).and(d.y.greaterThan(0)), () => {
647
- const len = length2(d);
648
- If(len.greaterThan(1e-4), () => {
649
- n.assign(s.mul(d.div(len)));
650
- }).Else(() => {
651
- n.assign(vec2(s.x, 0));
652
- });
653
- }).ElseIf(d.x.greaterThan(d.y), () => {
654
- n.assign(vec2(s.x, 0));
655
- }).Else(() => {
656
- n.assign(vec2(0, s.y));
657
- });
658
- return n;
659
- });
660
- const safeNormalize = Fn(([v, fallback]) => {
661
- const n = length2(v);
662
- return select(n.greaterThan(1e-4), v.div(max2(n, 1e-4)), fallback);
663
- });
664
- const group = new Group();
665
- const geometries = [];
666
- const materials = [];
667
- const meshes = [];
668
- const levelUniforms = Array.from({ length: LEVELS }, () => ({
669
- origin: uniform2(new Vector22(0, 0)),
670
- dims: uniform2(new Vector22(1, 1)),
671
- spacing: uniform2(20),
672
- alpha: uniform2(0),
673
- skipMod: uniform2(0)
674
- }));
675
- for (let level = 0; level < LEVELS; level++) {
676
- const lu = levelUniforms[level];
677
- const vUv = varying(vec2(0, 0), `vMagnetUv${level}`);
678
- const vAlpha = varying(float2(0), `vMagnetAlpha${level}`);
679
- const vertexNode = Fn(() => {
680
- const iid = float2(instanceIndex);
681
- const cols = lu.dims.x;
682
- const col = mod(iid, cols).floor();
683
- const row = iid.div(cols).floor();
684
- const world = lu.origin.add(vec2(col, row)).mul(lu.spacing);
685
- const screen = world.sub(uCam).mul(uZoom);
686
- const field = vec2(0, 0).toVar();
687
- const minD = float2(1e9).toVar();
688
- Loop({ start: int(0), end: uCount, type: "int", condition: "<" }, ({ i }) => {
689
- const a = sourceBuf.element(i.mul(2));
690
- const b = sourceBuf.element(i.mul(2).add(1));
691
- const center = a.xy;
692
- const half = a.zw;
693
- const rad = b.x;
694
- const strength = b.y;
695
- const rel = screen.sub(center);
696
- const reach = uPad.mul(sqrt(max2(strength, 1e-4)));
697
- If(
698
- abs(rel.x).greaterThan(half.x.add(reach)).or(abs(rel.y).greaterThan(half.y.add(reach))),
699
- () => {
700
- Continue();
701
- }
702
- );
703
- const d = sdRoundBox(rel, half, rad);
704
- minD.assign(min2(minD, d));
705
- const dist = max2(d, 0);
706
- const r2 = dist.mul(dist).add(EPS);
707
- const outward = roundBoxNormal(rel, half, rad);
708
- field.subAssign(outward.mul(uK.mul(strength).mul(uPolarity).div(r2)));
709
- });
710
- const fieldDir = safeNormalize(field, REST);
711
- const mag = length2(field);
712
- const influence = select(uDotMode.greaterThan(0.5), mag.div(mag.add(1)), clamp2(mag, 0, 1));
713
- const corner = positionGeometry2.xy;
714
- const dotRadius = mix2(uRestRadius, uHalfLen.mul(1.05), influence);
715
- const dotLocal = corner.mul(dotRadius);
716
- const dir = select(
717
- uAlwaysAlign.greaterThan(0.5),
718
- fieldDir,
719
- safeNormalize(mix2(REST, fieldDir, influence), REST)
720
- );
721
- const nrm = vec2(dir.y.negate(), dir.x);
722
- const nLen = mix2(uHalfLen.mul(0.55), uHalfLen.mul(1.35), influence);
723
- const nWid = mix2(uHalfWidth.mul(0.85), uHalfWidth.mul(1.15), influence);
724
- const needleLocal = nrm.mul(corner.x).mul(nWid).add(dir.mul(corner.y).mul(nLen));
725
- const local = select(uDotMode.greaterThan(0.5), dotLocal, needleLocal);
726
- const pos = screen.add(local);
727
- const restAlpha = select(uDotMode.greaterThan(0.5), float2(0.72), float2(0.35));
728
- const fieldAlpha = mix2(restAlpha, float2(1), influence);
729
- const alpha = clamp2(lu.alpha.mul(fieldAlpha), 0, 1).toVar();
730
- If(minD.lessThan(-0.5), () => {
731
- alpha.assign(0);
732
- });
733
- const absI = lu.origin.x.add(col);
734
- const absJ = lu.origin.y.add(row);
735
- If(
736
- lu.skipMod.greaterThan(0.5).and(mod(absI, lu.skipMod).lessThan(0.5)).and(mod(absJ, lu.skipMod).lessThan(0.5)),
737
- () => {
738
- alpha.assign(0);
739
- }
740
- );
741
- vUv.assign(corner);
742
- vAlpha.assign(alpha);
743
- const ndc = vec2(
744
- pos.x.div(uView.x).mul(2).sub(1),
745
- float2(1).sub(pos.y.div(uView.y).mul(2))
746
- );
747
- return vec42(ndc, 0, 1);
748
- })();
749
- const fragmentNode = Fn(() => {
750
- const dotEdge = float2(1).sub(smoothstep2(0.62, 1, length2(vUv)));
751
- const ax = float2(1).sub(smoothstep2(0.55, 1, abs(vUv.x)));
752
- const ay = float2(1).sub(smoothstep2(0.82, 1, abs(vUv.y)));
753
- const edge = select(uDotMode.greaterThan(0.5), dotEdge, ax.mul(ay));
754
- const a = vAlpha.mul(edge);
755
- Discard(a.lessThan(0.01));
756
- return vec42(uColor, a);
757
- })();
758
- const material = new MeshBasicNodeMaterial2();
759
- material.vertexNode = vertexNode;
760
- material.fragmentNode = fragmentNode;
761
- material.transparent = true;
762
- material.depthTest = false;
763
- material.depthWrite = false;
764
- const geometry = new InstancedBufferGeometry();
765
- geometry.setAttribute("position", new BufferAttribute2(CORNERS, 3));
766
- geometry.instanceCount = 0;
767
- const mesh = new Mesh2(geometry, material);
768
- mesh.frustumCulled = false;
769
- mesh.renderOrder = 0;
770
- mesh.visible = false;
771
- geometries.push(geometry);
772
- materials.push(material);
773
- meshes.push(mesh);
774
- group.add(mesh);
775
- }
776
- return {
777
- group,
778
- update(frame, cfg, magnet, levels, sources, sourceCount) {
779
- uCam.value.set(frame.camera.x, frame.camera.y);
780
- uZoom.value = frame.camera.zoom;
781
- uView.value.set(Math.max(1, frame.width), Math.max(1, frame.height));
782
- uDotMode.value = magnet.glyph === "dot" ? 1 : 0;
783
- uHalfLen.value = magnet.needleLength;
784
- uHalfWidth.value = magnet.needleWidth;
785
- uRestRadius.value = cfg.dotRadius[0];
786
- const k = 0.5 * magnet.reach * magnet.reach;
787
- uK.value = k;
788
- uPad.value = Math.sqrt(Math.max(k, 1) / 0.02);
789
- uPolarity.value = magnet.polarity;
790
- uAlwaysAlign.value = magnet.alwaysAlign ? 1 : 0;
791
- uCount.value = sourceCount;
792
- uColor.value.set(...cfg.dotColor);
793
- if (sourceCount > 0) {
794
- sourceArray.set(sources.subarray(0, sourceCount * MAGNET_SOURCE_FLOATS));
795
- sourceAttr.needsUpdate = true;
796
- }
797
- for (let level = 0; level < LEVELS; level++) {
798
- const win = levels[level];
799
- const lu = levelUniforms[level];
800
- const geometry = geometries[level];
801
- const mesh = meshes[level];
802
- if (win === void 0 || win.count <= 0) {
803
- geometry.instanceCount = 0;
804
- mesh.visible = false;
805
- continue;
806
- }
807
- lu.origin.value.set(win.i0, win.j0);
808
- lu.dims.value.set(win.cols, win.rows);
809
- lu.spacing.value = cfg.spacings[level];
810
- lu.alpha.value = win.alpha;
811
- lu.skipMod.value = win.skipModulo;
812
- geometry.instanceCount = win.count;
813
- mesh.visible = true;
814
- }
815
- },
816
- dispose() {
817
- for (const g of geometries) g.dispose();
818
- for (const m of materials) m.dispose();
819
- }
820
- };
821
- }
822
-
823
- // ../ground/src/passes/grid.ts
824
- function mergeGridConfig(base, next) {
825
- const merged = { ...base, ...next };
826
- if (next.magnet !== void 0) merged.magnet = { ...base.magnet, ...next.magnet };
827
- return merged;
828
- }
829
- function createGridPass(initial = {}, deps = {}) {
830
- let cfg = mergeGridConfig(DEFAULT_GRID_CONFIG, initial);
831
- const group = new Group2();
832
- const classic = createClassicGrid(cfg);
833
- group.add(classic.mesh);
834
- let magnet = null;
835
- const poles = deps.poles ?? [];
836
- const sourceScratch = new Float32Array(MAX_MAGNET_SOURCES * MAGNET_SOURCE_FLOATS);
837
- const poleScratch = [];
838
- return {
839
- name: "grid",
840
- object: group,
841
- arm(world, wake) {
842
- const wakeIfWidgets = () => {
843
- const m = resolveMagnet(cfg);
844
- if (m.enabled && m.widgets && deps.readSpatial !== void 0) wake();
845
- };
846
- const wakeIfEnabled = () => {
847
- if (resolveMagnet(cfg).enabled) wake();
848
- };
849
- const unsubs = [world.reactive.observeResource(SpatialVersion, wakeIfWidgets)];
850
- for (const source of poles) unsubs.push(source.subscribe(world, wakeIfEnabled));
851
- return unsubs;
852
- },
853
- collect(world, frame) {
854
- const m = resolveMagnet(cfg);
855
- if (!m.enabled) {
856
- classic.mesh.visible = true;
857
- if (magnet !== null) magnet.group.visible = false;
858
- classic.setCamera(frame);
859
- return;
860
- }
861
- if (magnet === null) {
862
- magnet = createMagnetGrid();
863
- group.add(magnet.group);
864
- }
865
- classic.mesh.visible = false;
866
- magnet.group.visible = true;
867
- const fieldScale = magnetFieldScale(frame.camera.zoom, m.fadeZoom);
868
- poleScratch.length = 0;
869
- if (fieldScale > 0) {
870
- for (const source of poles) poleScratch.push(...source.read(world));
871
- }
872
- const sourceCount = collectMagnetSources(
873
- world,
874
- frame,
875
- m,
876
- fieldScale,
877
- poleScratch,
878
- deps.readSpatial,
879
- sourceScratch
880
- );
881
- const levels = collectMagnetLevels(frame, cfg);
882
- magnet.update(frame, cfg, m, levels, sourceScratch, sourceCount);
883
- },
884
- configure(next) {
885
- cfg = mergeGridConfig(cfg, next);
886
- classic.configure(cfg);
887
- },
888
- dispose() {
889
- classic.dispose();
890
- magnet?.dispose();
891
- magnet = null;
892
- }
893
- };
894
- }
895
-
896
- // ../ground/src/passes/guides-collect.ts
897
- var guideQ = defineQuery([GuideLine]);
898
- var barQ = defineQuery([SpacingBar]);
899
- function collectGuides(world, frame, config = DEFAULT_SNAP_GUIDES_CONFIG) {
900
- const soup = new SoupBuilder();
901
- const cam = frame.camera;
902
- const lw = config.lineWidth;
903
- const guideColor = [config.color[0], config.color[1], config.color[2], config.guideAlpha];
904
- const barColor = [config.color[0], config.color[1], config.color[2], config.spacingAlpha];
905
- world.query(guideQ).each((b) => {
906
- for (const r of b) {
907
- const g = world.read(b.entity(r), GuideLine);
908
- const fullSpan = g.from === g.to;
909
- if (g.axis === "x") {
910
- const sx = worldToScreen(g.at, 0, cam).x;
911
- if (frame.width > 0 && (sx < -1 || sx > frame.width + 1)) continue;
912
- const y0 = fullSpan ? 0 : worldToScreen(0, g.from, cam).y;
913
- const y1 = fullSpan ? frame.height : worldToScreen(0, g.to, cam).y;
914
- soup.rect(sx - lw / 2, Math.min(y0, y1), lw, Math.abs(y1 - y0), guideColor);
915
- } else {
916
- const sy = worldToScreen(0, g.at, cam).y;
917
- if (frame.height > 0 && (sy < -1 || sy > frame.height + 1)) continue;
918
- const x0 = fullSpan ? 0 : worldToScreen(g.from, 0, cam).x;
919
- const x1 = fullSpan ? frame.width : worldToScreen(g.to, 0, cam).x;
920
- soup.rect(Math.min(x0, x1), sy - lw / 2, Math.abs(x1 - x0), lw, guideColor);
921
- }
922
- }
923
- });
924
- world.query(barQ).each((b) => {
925
- for (const r of b) {
926
- const s = world.read(b.entity(r), SpacingBar);
927
- const t = config.tickPx;
928
- if (s.axis === "x") {
929
- const a = worldToScreen(s.from, s.perp, cam);
930
- const bp = worldToScreen(s.to, s.perp, cam);
931
- if (frame.width > 0 && (Math.max(a.x, bp.x) < 0 || Math.min(a.x, bp.x) > frame.width)) continue;
932
- soup.rect(Math.min(a.x, bp.x), a.y - lw / 2, Math.abs(bp.x - a.x), lw, barColor);
933
- soup.rect(a.x - lw / 2, a.y - t, lw, t * 2, barColor);
934
- soup.rect(bp.x - lw / 2, bp.y - t, lw, t * 2, barColor);
935
- } else {
936
- const a = worldToScreen(s.perp, s.from, cam);
937
- const bp = worldToScreen(s.perp, s.to, cam);
938
- if (frame.height > 0 && (Math.max(a.y, bp.y) < 0 || Math.min(a.y, bp.y) > frame.height)) continue;
939
- soup.rect(a.x - lw / 2, Math.min(a.y, bp.y), lw, Math.abs(bp.y - a.y), barColor);
940
- soup.rect(a.x - t, a.y - lw / 2, t * 2, lw, barColor);
941
- soup.rect(bp.x - t, bp.y - lw / 2, t * 2, lw, barColor);
942
- }
943
- }
944
- });
945
- return soup.build();
946
- }
947
-
948
- // ../ground/src/passes/soup-mesh.ts
949
- import { attribute } from "three/tsl";
950
- import { BufferAttribute as BufferAttribute3, BufferGeometry as BufferGeometry2, DoubleSide, Mesh as Mesh3, MeshBasicNodeMaterial as MeshBasicNodeMaterial3 } from "three/webgpu";
951
- function createSoupMesh(renderOrder) {
952
- const material = new MeshBasicNodeMaterial3();
953
- material.fragmentNode = attribute("color", "vec4");
954
- material.transparent = true;
955
- material.depthTest = false;
956
- material.depthWrite = false;
957
- material.side = DoubleSide;
958
- let geometry = new BufferGeometry2();
959
- let capacity = 0;
960
- const mesh = new Mesh3(geometry, material);
961
- mesh.frustumCulled = false;
962
- mesh.renderOrder = renderOrder;
963
- mesh.visible = false;
964
- return {
965
- mesh,
966
- update(soup) {
967
- if (soup.vertexCount === 0) {
968
- mesh.visible = false;
969
- geometry.setDrawRange(0, 0);
970
- return;
971
- }
972
- if (soup.vertexCount > capacity) {
973
- capacity = Math.max(soup.vertexCount, capacity * 2, 256);
974
- const old = geometry;
975
- geometry = new BufferGeometry2();
976
- const pos = new Float32Array(capacity * 3);
977
- const col = new Float32Array(capacity * 4);
978
- pos.set(soup.positions);
979
- col.set(soup.colors);
980
- geometry.setAttribute("position", new BufferAttribute3(pos, 3));
981
- geometry.setAttribute("color", new BufferAttribute3(col, 4));
982
- mesh.geometry = geometry;
983
- old.dispose();
984
- } else {
985
- const pos = geometry.getAttribute("position");
986
- const col = geometry.getAttribute("color");
987
- pos.array.set(soup.positions);
988
- col.array.set(soup.colors);
989
- pos.needsUpdate = true;
990
- col.needsUpdate = true;
991
- }
992
- geometry.setDrawRange(0, soup.vertexCount);
993
- mesh.visible = true;
994
- },
995
- dispose() {
996
- geometry.dispose();
997
- material.dispose();
998
- }
999
- };
1000
- }
1001
-
1002
- // ../ground/src/passes/guides.ts
1003
- function createGuidesPass(initial = {}) {
1004
- const config = { ...DEFAULT_SNAP_GUIDES_CONFIG, ...initial };
1005
- const soup = createSoupMesh(2);
1006
- return {
1007
- name: "snap-guides",
1008
- object: soup.mesh,
1009
- arm(world, wake) {
1010
- return [
1011
- world.reactive.observeQuery(guideQ, wake, { cols: [GuideLine] }),
1012
- world.reactive.observeQuery(barQ, wake, { cols: [SpacingBar] })
1013
- ];
1014
- },
1015
- collect(world, frame) {
1016
- soup.update(collectGuides(world, frame, config));
1017
- },
1018
- dispose() {
1019
- soup.dispose();
1020
- }
1021
- };
1022
- }
1023
-
1024
- // ../ground/src/passes/wires.ts
1025
- function createWiresPass(initial = {}, readPreview) {
1026
- const config = { ...DEFAULT_WIRES_CONFIG, ...initial };
1027
- const soup = createSoupMesh(1);
1028
- return {
1029
- name: "wires",
1030
- object: soup.mesh,
1031
- arm(world, wake) {
1032
- return [
1033
- world.reactive.observeQuery(wireQ, wake, { cols: [] }),
1034
- world.reactive.observeQuery(geometryQ, wake, { cols: [Position, Size] }),
1035
- // MeasuredSize rides its own observer (readRect prefers it over Size):
1036
- // in geometryQ's cols it would REQUIRE the rider and drop plain widgets.
1037
- world.reactive.observeQuery(measuredQ, wake, { cols: [MeasuredSize] }),
1038
- world.reactive.observeQuery(selectedQ, wake, { cols: [] }),
1039
- // Nav churn: Active membership flips gate the scope filter (a wire
1040
- // whose endpoints left the current frame must disappear this frame).
1041
- world.reactive.observeQuery(activeQ, wake, { cols: [] }),
1042
- world.reactive.observeQuery(portQ, wake, { cols: [PortAnchor] }),
1043
- world.reactive.observeQuery(routedConnectQ, wake, { cols: [] }),
1044
- world.reactive.observeQuery(connectDragQ, wake, { cols: [Drag] })
1045
- ];
1046
- },
1047
- collect(world, frame) {
1048
- soup.update(collectWires(world, frame, config, readPreview?.()));
1049
- },
1050
- dispose() {
1051
- soup.dispose();
1052
- }
1053
- };
1054
- }
1055
-
1056
- // ../ground/src/renderer.ts
1057
- import { WebGPURenderer } from "three/webgpu";
1058
- function createGroundRenderer(doc, opts = {}) {
1059
- const canvas = doc.createElement("canvas");
1060
- let renderer = null;
1061
- let isReady = false;
1062
- let isFailed = false;
1063
- const readyCbs = [];
1064
- const gpu = globalThis.navigator?.gpu;
1065
- if (gpu == null || opts.forceWebGL === true) {
1066
- let gl2 = null;
1067
- try {
1068
- gl2 = doc.createElement("canvas").getContext("webgl2");
1069
- } catch {
1070
- gl2 = null;
1071
- }
1072
- if (gl2 === null) isFailed = true;
1073
- }
1074
- if (!isFailed) {
1075
- try {
1076
- renderer = new WebGPURenderer({
1077
- canvas,
1078
- alpha: true,
1079
- // transparent clear — the page background shows through P0
1080
- antialias: true,
1081
- ...opts.forceWebGL === true ? { forceWebGL: true } : {}
1082
- });
1083
- renderer.init().then(() => {
1084
- isReady = true;
1085
- for (const cb of readyCbs.splice(0)) cb();
1086
- }).catch(() => {
1087
- isFailed = true;
1088
- });
1089
- } catch {
1090
- isFailed = true;
1091
- }
1092
- }
1093
- let lastW = 0;
1094
- let lastH = 0;
1095
- let lastDpr = 0;
1096
- return {
1097
- canvas,
1098
- ready: () => isReady,
1099
- failed: () => isFailed,
1100
- onReady(cb) {
1101
- if (isReady) cb();
1102
- else readyCbs.push(cb);
1103
- },
1104
- setSize(cssW, cssH, dpr) {
1105
- if (renderer === null || cssW === lastW && cssH === lastH && dpr === lastDpr) return;
1106
- lastW = cssW;
1107
- lastH = cssH;
1108
- lastDpr = dpr;
1109
- try {
1110
- renderer.setPixelRatio(dpr);
1111
- renderer.setSize(Math.max(1, cssW), Math.max(1, cssH), false);
1112
- } catch {
1113
- isFailed = true;
1114
- }
1115
- },
1116
- render(scene, camera) {
1117
- if (renderer === null || !isReady || isFailed) return;
1118
- try {
1119
- renderer.render(scene, camera);
1120
- } catch {
1121
- isFailed = true;
1122
- }
1123
- },
1124
- dispose() {
1125
- try {
1126
- renderer?.dispose();
1127
- } catch {
1128
- }
1129
- renderer = null;
1130
- }
1131
- };
1132
- }
1133
-
1134
- // ../ground/src/poles.ts
1135
- var localPointerQ = defineQuery([Pointer, PointerWorld, LocalPointer]);
1136
- function localPointerPoles(opts = {}) {
1137
- const strength = opts.strength ?? 1;
1138
- return {
1139
- read(world) {
1140
- const out = [];
1141
- world.query(localPointerQ).each((b) => {
1142
- for (const r of b) {
1143
- const p = world.read(b.entity(r), PointerWorld);
1144
- out.push({ x: p.x, y: p.y, strength, space: "world" });
1145
- }
1146
- });
1147
- return out;
1148
- },
1149
- subscribe(world, wake) {
1150
- return world.reactive.observeQuery(localPointerQ, wake, { cols: [PointerWorld] });
1151
- }
1152
- };
1153
- }
1154
- var cursorVisualQ = defineQuery([Position, CursorVisual]);
1155
- function cursorVisualPoles(opts = {}) {
1156
- const strength = opts.strength ?? 1;
1157
- return {
1158
- read(world) {
1159
- const out = [];
1160
- world.query(cursorVisualQ).each((b) => {
1161
- for (const r of b) {
1162
- const p = world.read(b.entity(r), Position);
1163
- out.push({ x: p.x, y: p.y, strength, space: "world" });
1164
- }
1165
- });
1166
- return out;
1167
- },
1168
- subscribe(world, wake) {
1169
- return world.reactive.observeQuery(cursorVisualQ, wake, { cols: [Position] });
1170
- }
1171
- };
1172
- }
1173
-
1174
- // ../ground/src/index.ts
1175
- function ground(opts = {}) {
1176
- return (ctx) => {
1177
- const doc = ctx.host.container.ownerDocument;
1178
- const renderer = opts.rendererOverride ?? createGroundRenderer(doc, { forceWebGL: opts.forceWebGL === true });
1179
- const poles = opts.poles === void 0 ? [] : Array.isArray(opts.poles) ? opts.poles : [opts.poles];
1180
- const grid = createGridPass(opts.grid ?? {}, { poles, ...ctx.readSpatial !== void 0 ? { readSpatial: ctx.readSpatial } : {} });
1181
- const wires = createWiresPass(opts.wires ?? {}, ctx.readWirePreview);
1182
- const guides = createGuidesPass(opts.guides ?? {});
1183
- const passes = [grid, wires, guides, ...opts.passes ?? []];
1184
- const layer = createLayer(ctx.host, ctx.world, renderer, passes);
1185
- return {
1186
- reflector: layer.reflector,
1187
- configureGrid(cfg) {
1188
- grid.configure(cfg);
1189
- layer.invalidateAll();
1190
- },
1191
- dispose: layer.dispose
1192
- };
1193
- };
1194
- }
1195
- export {
1196
- DEFAULT_GRID_CONFIG,
1197
- DEFAULT_GRID_MAGNET_CONFIG,
1198
- DEFAULT_SNAP_GUIDES_CONFIG,
1199
- DEFAULT_WIRES_CONFIG,
1200
- MAX_MAGNET_SOURCES,
1201
- SoupBuilder,
1202
- collectGuides,
1203
- collectMagnetLevels,
1204
- collectMagnetSources,
1205
- collectWires,
1206
- cursorVisualPoles,
1207
- ground,
1208
- localPointerPoles,
1209
- magnetFieldScale,
1210
- parseCssColor,
1211
- resolveMagnet
1212
- };
1213
- //# sourceMappingURL=ground.js.map