@vibecook/ice 0.11.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 (381) 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-VGVDJZSP.js → chunk-DYK6KNLG.js} +13206 -7387
  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 +33 -12
  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-2TNVB2ON.js +0 -1163
  324. package/dist/chunk-2TNVB2ON.js.map +0 -1
  325. package/dist/chunk-OR5FNVUE.js.map +0 -1
  326. package/dist/chunk-Q665T4L7.js +0 -681
  327. package/dist/chunk-Q665T4L7.js.map +0 -1
  328. package/dist/chunk-VGVDJZSP.js.map +0 -1
  329. package/dist/ground.js +0 -1108
  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 -101
  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-contract.d.ts +0 -28
  348. package/dist/types/packages/ground/src/passes/grid-magnet-pass.d.ts +0 -2
  349. package/dist/types/packages/ground/src/passes/grid-magnet.d.ts +0 -31
  350. package/dist/types/packages/ground/src/passes/grid.d.ts +0 -10
  351. package/dist/types/packages/ground/src/passes/guides-collect.d.ts +0 -14
  352. package/dist/types/packages/ground/src/passes/guides.d.ts +0 -3
  353. package/dist/types/packages/ground/src/passes/magnet-collect.d.ts +0 -63
  354. package/dist/types/packages/ground/src/passes/soup-collect.d.ts +0 -35
  355. package/dist/types/packages/ground/src/passes/soup-mesh.d.ts +0 -8
  356. package/dist/types/packages/ground/src/passes/wires-collect.d.ts +0 -35
  357. package/dist/types/packages/ground/src/passes/wires.d.ts +0 -10
  358. package/dist/types/packages/ground/src/poles.d.ts +0 -47
  359. package/dist/types/packages/ground/src/renderer.d.ts +0 -15
  360. package/dist/types/packages/ice/src/ground.d.ts +0 -1
  361. package/dist/types/packages/ice/src/r3f.d.ts +0 -1
  362. package/dist/types/packages/kernel/src/eviction.d.ts +0 -23
  363. package/dist/types/packages/kernel/src/zoom-bands.d.ts +0 -19
  364. package/dist/types/packages/r3f/src/bridge.d.ts +0 -129
  365. package/dist/types/packages/r3f/src/composite-material.d.ts +0 -26
  366. package/dist/types/packages/r3f/src/compositor-pass.d.ts +0 -105
  367. package/dist/types/packages/r3f/src/dev-write-trap.d.ts +0 -30
  368. package/dist/types/packages/r3f/src/gl-root.d.ts +0 -96
  369. package/dist/types/packages/r3f/src/gl-router.d.ts +0 -70
  370. package/dist/types/packages/r3f/src/index.d.ts +0 -17
  371. package/dist/types/packages/r3f/src/island-state.d.ts +0 -112
  372. package/dist/types/packages/r3f/src/island.d.ts +0 -13
  373. package/dist/types/packages/r3f/src/pool.d.ts +0 -56
  374. package/dist/types/packages/r3f/src/preview-capture.d.ts +0 -19
  375. package/dist/types/packages/r3f/src/resource-registry.d.ts +0 -30
  376. package/dist/types/packages/r3f/src/self-sustain.d.ts +0 -39
  377. package/dist/types/packages/r3f/src/use-island-frame.d.ts +0 -39
  378. package/dist/types/packages/react/src/infinite-canvas.d.ts +0 -140
  379. package/dist/types/packages/react/src/preview-snapshots.d.ts +0 -17
  380. package/dist/types/packages/react/src/widget-preview.d.ts +0 -14
  381. package/dist/types/packages/react/src/widget-root.d.ts +0 -33
package/dist/ground.js DELETED
@@ -1,1108 +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-VGVDJZSP.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-contract.ts
145
- function mergeGridConfig(base, next) {
146
- const merged = { ...base, ...next };
147
- if (next.magnet !== void 0) merged.magnet = { ...base.magnet, ...next.magnet };
148
- return merged;
149
- }
150
- function resolveInitialGridConfig(initial) {
151
- return mergeGridConfig(DEFAULT_GRID_CONFIG, initial);
152
- }
153
-
154
- // ../ground/src/passes/grid-magnet.ts
155
- import {
156
- Fn,
157
- If,
158
- Loop,
159
- abs,
160
- clamp,
161
- float,
162
- instanceIndex,
163
- int,
164
- length,
165
- max,
166
- min,
167
- mix,
168
- mod,
169
- positionGeometry,
170
- select,
171
- sign,
172
- smoothstep,
173
- sqrt,
174
- storage,
175
- uniform,
176
- varying,
177
- vec2,
178
- vec4,
179
- Continue,
180
- Discard
181
- } from "three/tsl";
182
- import {
183
- BufferAttribute,
184
- Group,
185
- InstancedBufferGeometry,
186
- Mesh,
187
- MeshBasicNodeMaterial,
188
- StorageBufferAttribute,
189
- Vector2,
190
- Vector3
191
- } from "three/webgpu";
192
-
193
- // ../ground/src/passes/soup-collect.ts
194
- var SoupBuilder = class {
195
- pos = [];
196
- col = [];
197
- vert(x, y, c) {
198
- this.pos.push(x, y, 0);
199
- this.col.push(c[0], c[1], c[2], c[3]);
200
- }
201
- /** Axis-aligned rect (two triangles). */
202
- rect(x, y, w, h, c) {
203
- this.vert(x, y, c);
204
- this.vert(x + w, y, c);
205
- this.vert(x + w, y + h, c);
206
- this.vert(x, y, c);
207
- this.vert(x + w, y + h, c);
208
- this.vert(x, y + h, c);
209
- }
210
- /** Stroke segment (a→b) of `width`, flat caps — a quad across the segment normal. */
211
- segment(ax, ay, bx, by, width, c) {
212
- const dx = bx - ax;
213
- const dy = by - ay;
214
- const len = Math.hypot(dx, dy);
215
- if (len < 1e-6) return;
216
- const nx = -dy / len * (width / 2);
217
- const ny = dx / len * (width / 2);
218
- this.vert(ax + nx, ay + ny, c);
219
- this.vert(bx + nx, by + ny, c);
220
- this.vert(bx - nx, by - ny, c);
221
- this.vert(ax + nx, ay + ny, c);
222
- this.vert(bx - nx, by - ny, c);
223
- this.vert(ax - nx, ay - ny, c);
224
- }
225
- /** Stroke a polyline (interleaved xy) as per-segment quads (smooth-curve joins). */
226
- polyline(points, width, c) {
227
- const n = Math.floor(points.length / 2);
228
- for (let i = 1; i < n; i++) {
229
- this.segment(
230
- points[(i - 1) * 2],
231
- points[(i - 1) * 2 + 1],
232
- points[i * 2],
233
- points[i * 2 + 1],
234
- width,
235
- c
236
- );
237
- }
238
- }
239
- /** Filled disc as a triangle fan (MSAA smooths the rim; 16 segs ≈ round at ≤8 px). */
240
- disc(cx, cy, r, c, segments = 16) {
241
- for (let i = 0; i < segments; i++) {
242
- const a0 = i / segments * Math.PI * 2;
243
- const a1 = (i + 1) / segments * Math.PI * 2;
244
- this.vert(cx, cy, c);
245
- this.vert(cx + Math.cos(a0) * r, cy + Math.sin(a0) * r, c);
246
- this.vert(cx + Math.cos(a1) * r, cy + Math.sin(a1) * r, c);
247
- }
248
- }
249
- build() {
250
- return {
251
- positions: new Float32Array(this.pos),
252
- colors: new Float32Array(this.col),
253
- vertexCount: this.pos.length / 3
254
- };
255
- }
256
- };
257
- function parseCssColor(css) {
258
- const rgba = /^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(css);
259
- if (rgba !== null) {
260
- return [
261
- Number(rgba[1]) / 255,
262
- Number(rgba[2]) / 255,
263
- Number(rgba[3]) / 255,
264
- rgba[4] === void 0 ? 1 : Number(rgba[4])
265
- ];
266
- }
267
- const hex = /^#([0-9a-f]{6})$/i.exec(css);
268
- if (hex !== null) {
269
- const v = Number.parseInt(hex[1], 16);
270
- return [(v >> 16 & 255) / 255, (v >> 8 & 255) / 255, (v & 255) / 255, 1];
271
- }
272
- return [0.5, 0.5, 0.5, 1];
273
- }
274
-
275
- // ../ground/src/passes/wires-collect.ts
276
- var wireQ = defineQuery([Wire]);
277
- var geometryQ = defineQuery([Position, Size]);
278
- var measuredQ = defineQuery([MeasuredSize]);
279
- var selectedQ = defineQuery([Selected]);
280
- var portQ = defineQuery([Port, PortAnchor]);
281
- var routedConnectQ = defineQuery([RoutedConnect]);
282
- var connectDragQ = defineQuery([RoutedConnect, Drag]);
283
- var activeQ = defineQuery([Active]);
284
- function outOfScope(world, e) {
285
- return world.hasTag(e, Culled) && !world.hasTag(e, Active);
286
- }
287
- var TESSELLATION_TOLERANCE_PX = 0.25;
288
- var DASH_PX = 6;
289
- var GAP_PX = 4;
290
- function readWidgetRect(world, e) {
291
- const p = world.get(e, Position);
292
- if (p === void 0) return void 0;
293
- const measured = world.get(e, MeasuredSize);
294
- const s = measured !== void 0 && measured.w > 0 ? measured : world.get(e, Size);
295
- if (s === void 0) return void 0;
296
- return { x: p.x, y: p.y, width: s.w, height: s.h };
297
- }
298
- var slotCache = /* @__PURE__ */ new Map();
299
- function slotOf(wt, portId) {
300
- let slots = slotCache.get(wt.type);
301
- if (slots === void 0) {
302
- slots = portSlots(wt.ports);
303
- slotCache.set(wt.type, slots);
304
- }
305
- return slots.get(portId);
306
- }
307
- function endpointAnchor(world, widget, portId) {
308
- if (widget === void 0) return void 0;
309
- const rect = readWidgetRect(world, widget);
310
- if (rect === void 0) return void 0;
311
- const type = world.get(widget, PrefabId)?.id;
312
- if (typeof type !== "string") return void 0;
313
- const wt = widgets.get(type);
314
- if (wt === void 0) return void 0;
315
- const slot = slotOf(wt, portId);
316
- if (slot === void 0) return void 0;
317
- return { anchor: rect, slot };
318
- }
319
- function cubicToScreen(c, cam) {
320
- const p0 = worldToScreen(c.x0, c.y0, cam);
321
- const p1 = worldToScreen(c.x1, c.y1, cam);
322
- const p2 = worldToScreen(c.x2, c.y2, cam);
323
- const p3 = worldToScreen(c.x3, c.y3, cam);
324
- 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 };
325
- }
326
- function pointAtLength(t, d) {
327
- const arc = t.arcLength;
328
- const n = arc.length;
329
- let lo = 0;
330
- let hi = n - 1;
331
- while (lo < hi) {
332
- const mid = lo + hi >> 1;
333
- if (arc[mid] < d) lo = mid + 1;
334
- else hi = mid;
335
- }
336
- const i = Math.max(1, lo);
337
- const a = arc[i - 1];
338
- const b = arc[i];
339
- const f = b > a ? (d - a) / (b - a) : 0;
340
- const x0 = t.points[(i - 1) * 2];
341
- const y0 = t.points[(i - 1) * 2 + 1];
342
- const x1 = t.points[i * 2];
343
- const y1 = t.points[i * 2 + 1];
344
- return { x: x0 + (x1 - x0) * f, y: y0 + (y1 - y0) * f };
345
- }
346
- function dashedStroke(soup, t, width, c) {
347
- const total = t.arcLength[t.arcLength.length - 1];
348
- for (let d = 0; d < total; d += DASH_PX + GAP_PX) {
349
- const a = pointAtLength(t, d);
350
- const b = pointAtLength(t, Math.min(d + DASH_PX, total));
351
- soup.segment(a.x, a.y, b.x, b.y, width, c);
352
- }
353
- }
354
- function collectWires(world, frame, config = DEFAULT_WIRES_CONFIG, preview) {
355
- const soup = new SoupBuilder();
356
- const cam = frame.camera;
357
- const wireColor = parseCssColor(config.wireColor);
358
- const selectedColor = parseCssColor(config.selectedColor);
359
- world.query(wireQ).each((batch) => {
360
- for (const r of batch) {
361
- const wire = batch.entity(r);
362
- const ports = world.get(wire, WirePorts);
363
- if (ports === void 0) continue;
364
- const fromWidget = world.getRelation(wire, WireFrom);
365
- const toWidget = world.getRelation(wire, WireTo);
366
- if (fromWidget !== void 0 && outOfScope(world, fromWidget)) continue;
367
- if (toWidget !== void 0 && outOfScope(world, toWidget)) continue;
368
- const from = endpointAnchor(world, fromWidget, ports.from ?? "");
369
- const to = endpointAnchor(world, toWidget, ports.to ?? "");
370
- if (from === void 0 || to === void 0) continue;
371
- const cubic = wireCubic(
372
- portAnchor(from.anchor, from.slot),
373
- from.slot.side,
374
- portAnchor(to.anchor, to.slot),
375
- to.slot.side
376
- );
377
- const selected = world.hasTag(wire, Selected);
378
- const t = tessellateCubic(cubicToScreen(cubic, cam), TESSELLATION_TOLERANCE_PX);
379
- soup.polyline(t.points, selected ? config.selectedWidth : config.wireWidth, selected ? selectedColor : wireColor);
380
- }
381
- });
382
- if (preview?.active === true) {
383
- const stub = Math.max(24, Math.abs(preview.tx - preview.sx) * 0.5);
384
- const cubic = {
385
- x0: preview.sx,
386
- y0: preview.sy,
387
- x1: preview.sx + stub,
388
- y1: preview.sy,
389
- x2: preview.tx - stub,
390
- y2: preview.ty,
391
- x3: preview.tx,
392
- y3: preview.ty
393
- };
394
- const t = tessellateCubic(cubicToScreen(cubic, cam), TESSELLATION_TOLERANCE_PX);
395
- if (preview.compatible) soup.polyline(t.points, config.wireWidth, selectedColor);
396
- else dashedStroke(soup, t, config.wireWidth, wireColor);
397
- }
398
- const connecting = world.firstOf(routedConnectQ) !== void 0;
399
- const dotColor = parseCssColor(connecting ? config.portActiveColor : config.portColor);
400
- world.query(portQ).each((batch) => {
401
- const ax = batch.col(PortAnchor).x;
402
- const ay = batch.col(PortAnchor).y;
403
- for (const r of batch) {
404
- const s = worldToScreen(ax[r], ay[r], cam);
405
- soup.disc(s.x, s.y, config.portRadius, dotColor);
406
- }
407
- });
408
- return soup.build();
409
- }
410
-
411
- // ../ground/src/passes/magnet-collect.ts
412
- var MAGNET_SOURCE_FLOATS = 8;
413
- var MAX_MAGNET_SOURCES = 256;
414
- var MAX_MAGNET_INSTANCES = 22e4;
415
- function resolveMagnet(cfg) {
416
- return { ...DEFAULT_GRID_MAGNET_CONFIG, ...cfg.magnet };
417
- }
418
- function fadeOpacity(cssSpacing, fadeIn, fadeOut) {
419
- const rise = (cssSpacing - fadeIn[0]) / Math.max(fadeIn[1] - fadeIn[0], 1e-4);
420
- const fall = 1 - (cssSpacing - fadeOut[0]) / Math.max(fadeOut[1] - fadeOut[0], 1e-4);
421
- return Math.min(Math.max(Math.min(rise, fall), 0), 1);
422
- }
423
- function magnetFieldScale(zoom, fadeZoom) {
424
- if (fadeZoom <= 0) return 1;
425
- const t = (zoom - 0.7 * fadeZoom) / (0.3 * fadeZoom);
426
- return Math.min(Math.max(t, 0), 1);
427
- }
428
- function collectMagnetLevels(frame, cfg) {
429
- const { camera } = frame;
430
- const out = [];
431
- const opacities = cfg.spacings.map((s) => fadeOpacity(s * camera.zoom, cfg.fadeIn, cfg.fadeOut));
432
- for (let i = 0; i < cfg.spacings.length; i++) {
433
- const spacing = cfg.spacings[i];
434
- const opacity = opacities[i];
435
- const weight = cfg.levelWeight[0] + i * cfg.levelWeight[1];
436
- const alpha = opacity * weight * cfg.dotAlpha;
437
- if (opacity < 0.01 || alpha <= 0) {
438
- out.push({ i0: 0, j0: 0, cols: 0, rows: 0, count: 0, alpha: 0, skipModulo: 0 });
439
- continue;
440
- }
441
- const worldW = frame.width / camera.zoom;
442
- const worldH = frame.height / camera.zoom;
443
- const i0 = Math.floor(camera.x / spacing) - 1;
444
- const j0 = Math.floor(camera.y / spacing) - 1;
445
- const i1 = Math.ceil((camera.x + worldW) / spacing) + 1;
446
- const j1 = Math.ceil((camera.y + worldH) / spacing) + 1;
447
- const cols = Math.max(1, i1 - i0);
448
- const rows = Math.max(1, j1 - j0);
449
- const count = cols * rows;
450
- if (count > MAX_MAGNET_INSTANCES) {
451
- out.push({ i0: 0, j0: 0, cols: 0, rows: 0, count: 0, alpha: 0, skipModulo: 0 });
452
- continue;
453
- }
454
- let skipModulo = 0;
455
- const next = cfg.spacings[i + 1];
456
- if (next !== void 0 && opacities[i + 1] >= 0.01) {
457
- const ratio = next / spacing;
458
- if (Number.isInteger(ratio) && ratio > 1) skipModulo = ratio;
459
- }
460
- out.push({ i0, j0, cols, rows, count, alpha, skipModulo });
461
- }
462
- return out;
463
- }
464
- function collectMagnetSources(world, frame, magnet, fieldScale, poles, readSpatial, out) {
465
- if (fieldScale <= 0) return 0;
466
- const { camera } = frame;
467
- const cap = Math.min(magnet.maxSources, MAX_MAGNET_SOURCES, Math.floor(out.length / MAGNET_SOURCE_FLOATS));
468
- let n = 0;
469
- for (const pole of poles) {
470
- if (n >= cap) break;
471
- if (!(pole.strength > 0)) continue;
472
- const s = pole.space === "screen" ? pole : worldToScreen(pole.x, pole.y, camera);
473
- const o = n * MAGNET_SOURCE_FLOATS;
474
- out[o + 0] = s.x;
475
- out[o + 1] = s.y;
476
- out[o + 2] = 0;
477
- out[o + 3] = 0;
478
- out[o + 4] = 0;
479
- out[o + 5] = pole.strength * fieldScale;
480
- out[o + 6] = 0;
481
- out[o + 7] = 0;
482
- n++;
483
- }
484
- if (!magnet.widgets || readSpatial === void 0 || magnet.widgetStrength <= 0 || n >= cap) {
485
- return n;
486
- }
487
- const haloCss = 5 * magnet.reach * Math.sqrt(Math.max(magnet.widgetStrength * fieldScale, 1e-4));
488
- const pad = haloCss / camera.zoom;
489
- const hits = readSpatial({
490
- minX: camera.x - pad,
491
- minY: camera.y - pad,
492
- maxX: camera.x + frame.width / camera.zoom + pad,
493
- maxY: camera.y + frame.height / camera.zoom + pad
494
- });
495
- const viewCx = frame.width / 2;
496
- const viewCy = frame.height / 2;
497
- const candidates = [];
498
- for (const hit of hits) {
499
- const rect = readWidgetRect(world, hit.id);
500
- if (rect === void 0 || rect.width <= 0 || rect.height <= 0) continue;
501
- const hx = rect.width / 2 * camera.zoom;
502
- const hy = rect.height / 2 * camera.zoom;
503
- const center = worldToScreen(rect.x + rect.width / 2, rect.y + rect.height / 2, camera);
504
- candidates.push({
505
- cx: center.x,
506
- cy: center.y,
507
- hx,
508
- hy,
509
- r: Math.min(magnet.widgetRadius * camera.zoom, hx, hy),
510
- area: hx * hy,
511
- centerDist: (center.x - viewCx) ** 2 + (center.y - viewCy) ** 2
512
- });
513
- }
514
- const budget = cap - n;
515
- if (candidates.length > budget) {
516
- candidates.sort((a, b) => b.area - a.area || a.centerDist - b.centerDist);
517
- candidates.length = budget;
518
- }
519
- const strength = magnet.widgetStrength * fieldScale;
520
- for (const c of candidates) {
521
- const o = n * MAGNET_SOURCE_FLOATS;
522
- out[o + 0] = c.cx;
523
- out[o + 1] = c.cy;
524
- out[o + 2] = c.hx;
525
- out[o + 3] = c.hy;
526
- out[o + 4] = c.r;
527
- out[o + 5] = strength;
528
- out[o + 6] = 0;
529
- out[o + 7] = 0;
530
- n++;
531
- }
532
- return n;
533
- }
534
-
535
- // ../ground/src/passes/grid-magnet.ts
536
- var CORNERS = new Float32Array([-1, -1, 0, 1, -1, 0, 1, 1, 0, -1, -1, 0, 1, 1, 0, -1, 1, 0]);
537
- var LEVELS = 3;
538
- function createMagnetGrid() {
539
- const sourceArray = new Float32Array(MAX_MAGNET_SOURCES * MAGNET_SOURCE_FLOATS);
540
- const sourceAttr = new StorageBufferAttribute(sourceArray, 4);
541
- const sourceBuf = storage(sourceAttr, "vec4", MAX_MAGNET_SOURCES * 2).setPBO(true).toReadOnly();
542
- const uCam = uniform(new Vector2(0, 0));
543
- const uZoom = uniform(1);
544
- const uView = uniform(new Vector2(1, 1));
545
- const uDotMode = uniform(0);
546
- const uHalfLen = uniform(5);
547
- const uHalfWidth = uniform(0.55);
548
- const uRestRadius = uniform(0.75);
549
- const uK = uniform(0);
550
- const uPad = uniform(0);
551
- const uPolarity = uniform(1);
552
- const uAlwaysAlign = uniform(0);
553
- const uCount = uniform(0, "int");
554
- const uColor = uniform(new Vector3(0.75, 0.77, 0.8));
555
- const EPS = float(25);
556
- const REST = vec2(0, 1);
557
- const sdRoundBox = Fn(([p, b, r]) => {
558
- const q = abs(p).sub(b).add(vec2(r, r));
559
- return length(max(q, vec2(0, 0))).add(min(max(q.x, q.y), 0)).sub(r);
560
- });
561
- const roundBoxNormal = Fn(([p, b, r]) => {
562
- const s = sign(p);
563
- const q = abs(p);
564
- const inner = max(b.sub(vec2(r, r)), vec2(0, 0));
565
- const d = q.sub(inner);
566
- const n = vec2(0, 0).toVar();
567
- If(d.x.greaterThan(0).and(d.y.greaterThan(0)), () => {
568
- const len = length(d);
569
- If(len.greaterThan(1e-4), () => {
570
- n.assign(s.mul(d.div(len)));
571
- }).Else(() => {
572
- n.assign(vec2(s.x, 0));
573
- });
574
- }).ElseIf(d.x.greaterThan(d.y), () => {
575
- n.assign(vec2(s.x, 0));
576
- }).Else(() => {
577
- n.assign(vec2(0, s.y));
578
- });
579
- return n;
580
- });
581
- const safeNormalize = Fn(([v, fallback]) => {
582
- const n = length(v);
583
- return select(n.greaterThan(1e-4), v.div(max(n, 1e-4)), fallback);
584
- });
585
- const group = new Group();
586
- const geometries = [];
587
- const materials = [];
588
- const meshes = [];
589
- const levelUniforms = Array.from({ length: LEVELS }, () => ({
590
- origin: uniform(new Vector2(0, 0)),
591
- dims: uniform(new Vector2(1, 1)),
592
- spacing: uniform(20),
593
- alpha: uniform(0),
594
- skipMod: uniform(0)
595
- }));
596
- for (let level = 0; level < LEVELS; level++) {
597
- const lu = levelUniforms[level];
598
- const vUv = varying(vec2(0, 0), `vMagnetUv${level}`);
599
- const vAlpha = varying(float(0), `vMagnetAlpha${level}`);
600
- const vertexNode = Fn(() => {
601
- const iid = float(instanceIndex);
602
- const cols = lu.dims.x;
603
- const col = mod(iid, cols).floor().toVar();
604
- const row = iid.div(cols).floor().toVar();
605
- const world = lu.origin.add(vec2(col, row)).mul(lu.spacing);
606
- const screen = world.sub(uCam).mul(uZoom).toVar();
607
- const field = vec2(0, 0).toVar();
608
- const minD = float(1e9).toVar();
609
- Loop({ start: int(0), end: uCount, type: "int", condition: "<" }, ({ i }) => {
610
- const a = sourceBuf.element(i.mul(2));
611
- const b = sourceBuf.element(i.mul(2).add(1));
612
- const center = a.xy;
613
- const half = a.zw;
614
- const rad = b.x;
615
- const strength = b.y;
616
- const rel = screen.sub(center);
617
- const reach = uPad.mul(sqrt(max(strength, 1e-4)));
618
- If(
619
- abs(rel.x).greaterThan(half.x.add(reach)).or(abs(rel.y).greaterThan(half.y.add(reach))),
620
- () => {
621
- Continue();
622
- }
623
- );
624
- const d = sdRoundBox(rel, half, rad);
625
- minD.assign(min(minD, d));
626
- const dist = max(d, 0);
627
- const r2 = dist.mul(dist).add(EPS);
628
- const outward = roundBoxNormal(rel, half, rad);
629
- field.subAssign(outward.mul(uK.mul(strength).mul(uPolarity).div(r2)));
630
- });
631
- const fieldDir = safeNormalize(field, REST);
632
- const mag = length(field);
633
- const influence = select(uDotMode.greaterThan(0.5), mag.div(mag.add(1)), clamp(mag, 0, 1));
634
- const corner = positionGeometry.xy;
635
- const dotRadius = mix(uRestRadius, uHalfLen.mul(1.05), influence);
636
- const dotLocal = vec2(corner.x, corner.y.negate()).mul(dotRadius);
637
- const dir = select(
638
- uAlwaysAlign.greaterThan(0.5),
639
- fieldDir,
640
- safeNormalize(mix(REST, fieldDir, influence), REST)
641
- );
642
- const nrm = vec2(dir.y.negate(), dir.x);
643
- const nLen = mix(uHalfLen.mul(0.55), uHalfLen.mul(1.35), influence);
644
- const nWid = mix(uHalfWidth.mul(0.85), uHalfWidth.mul(1.15), influence);
645
- const needleLocal = nrm.mul(corner.x).mul(nWid).add(dir.mul(corner.y).mul(nLen));
646
- const local = select(uDotMode.greaterThan(0.5), dotLocal, needleLocal);
647
- const pos = screen.add(local);
648
- const restAlpha = select(uDotMode.greaterThan(0.5), float(0.72), float(0.35));
649
- const fieldAlpha = mix(restAlpha, float(1), influence);
650
- const alpha = clamp(lu.alpha.mul(fieldAlpha), 0, 1).toVar();
651
- If(minD.lessThan(-0.5), () => {
652
- alpha.assign(0);
653
- });
654
- const absI = lu.origin.x.add(col);
655
- const absJ = lu.origin.y.add(row);
656
- If(
657
- lu.skipMod.greaterThan(0.5).and(mod(absI, lu.skipMod).lessThan(0.5)).and(mod(absJ, lu.skipMod).lessThan(0.5)),
658
- () => {
659
- alpha.assign(0);
660
- }
661
- );
662
- vUv.assign(corner);
663
- vAlpha.assign(alpha);
664
- const ndc = vec2(
665
- pos.x.div(uView.x).mul(2).sub(1),
666
- float(1).sub(pos.y.div(uView.y).mul(2))
667
- );
668
- return vec4(ndc, 0, 1);
669
- })();
670
- const fragmentNode = Fn(() => {
671
- const dotEdge = float(1).sub(smoothstep(0.62, 1, length(vUv)));
672
- const ax = float(1).sub(smoothstep(0.55, 1, abs(vUv.x)));
673
- const ay = float(1).sub(smoothstep(0.82, 1, abs(vUv.y)));
674
- const edge = select(uDotMode.greaterThan(0.5), dotEdge, ax.mul(ay));
675
- const a = vAlpha.mul(edge);
676
- Discard(a.lessThan(0.01));
677
- return vec4(uColor, a);
678
- })();
679
- const material = new MeshBasicNodeMaterial();
680
- material.vertexNode = vertexNode;
681
- material.fragmentNode = fragmentNode;
682
- material.transparent = true;
683
- material.depthTest = false;
684
- material.depthWrite = false;
685
- const geometry = new InstancedBufferGeometry();
686
- geometry.setAttribute("position", new BufferAttribute(CORNERS, 3));
687
- geometry.instanceCount = 0;
688
- const mesh = new Mesh(geometry, material);
689
- mesh.frustumCulled = false;
690
- mesh.renderOrder = 0;
691
- mesh.visible = false;
692
- geometries.push(geometry);
693
- materials.push(material);
694
- meshes.push(mesh);
695
- group.add(mesh);
696
- }
697
- return {
698
- group,
699
- update(frame, cfg, magnet, levels, sources, sourceCount) {
700
- uCam.value.set(frame.camera.x, frame.camera.y);
701
- uZoom.value = frame.camera.zoom;
702
- uView.value.set(Math.max(1, frame.width), Math.max(1, frame.height));
703
- uDotMode.value = magnet.glyph === "dot" ? 1 : 0;
704
- uHalfLen.value = magnet.needleLength;
705
- uHalfWidth.value = magnet.needleWidth;
706
- uRestRadius.value = cfg.dotRadius[0];
707
- const k = 0.5 * magnet.reach * magnet.reach;
708
- uK.value = k;
709
- uPad.value = Math.sqrt(Math.max(k, 1) / 0.02);
710
- uPolarity.value = magnet.polarity;
711
- uAlwaysAlign.value = magnet.alwaysAlign ? 1 : 0;
712
- uCount.value = sourceCount;
713
- uColor.value.set(...cfg.dotColor);
714
- if (sourceCount > 0) {
715
- sourceArray.set(sources.subarray(0, sourceCount * MAGNET_SOURCE_FLOATS));
716
- sourceAttr.needsUpdate = true;
717
- }
718
- for (let level = 0; level < LEVELS; level++) {
719
- const win = levels[level];
720
- const lu = levelUniforms[level];
721
- const geometry = geometries[level];
722
- const mesh = meshes[level];
723
- if (win === void 0 || win.count <= 0) {
724
- geometry.instanceCount = 0;
725
- mesh.visible = false;
726
- continue;
727
- }
728
- lu.origin.value.set(win.i0, win.j0);
729
- lu.dims.value.set(win.cols, win.rows);
730
- lu.spacing.value = cfg.spacings[level];
731
- lu.alpha.value = win.alpha;
732
- lu.skipMod.value = win.skipModulo;
733
- geometry.instanceCount = win.count;
734
- mesh.visible = true;
735
- }
736
- },
737
- dispose() {
738
- for (const g of geometries) g.dispose();
739
- for (const m of materials) m.dispose();
740
- }
741
- };
742
- }
743
-
744
- // ../ground/src/passes/grid-magnet-pass.ts
745
- var createGridPass = (initial = {}, deps = {}) => {
746
- let cfg = resolveInitialGridConfig(initial);
747
- const renderer = createMagnetGrid();
748
- const poles = deps.poles ?? [];
749
- const sourceScratch = new Float32Array(MAX_MAGNET_SOURCES * MAGNET_SOURCE_FLOATS);
750
- const poleScratch = [];
751
- return {
752
- name: "grid",
753
- object: renderer.group,
754
- arm(world, wake) {
755
- const wakeIfWidgets = () => {
756
- const magnet = resolveMagnet(cfg);
757
- if (magnet.widgets && deps.readSpatial !== void 0) wake();
758
- };
759
- const unsubs = [world.reactive.observeResource(SpatialVersion, wakeIfWidgets)];
760
- for (const source of poles) unsubs.push(source.subscribe(world, wake));
761
- return unsubs;
762
- },
763
- collect(world, frame) {
764
- const magnet = resolveMagnet(cfg);
765
- const fieldScale = magnetFieldScale(frame.camera.zoom, magnet.fadeZoom);
766
- poleScratch.length = 0;
767
- if (fieldScale > 0) {
768
- for (const source of poles) poleScratch.push(...source.read(world));
769
- }
770
- const sourceCount = collectMagnetSources(
771
- world,
772
- frame,
773
- magnet,
774
- fieldScale,
775
- poleScratch,
776
- deps.readSpatial,
777
- sourceScratch
778
- );
779
- const levels = collectMagnetLevels(frame, cfg);
780
- renderer.update(frame, cfg, magnet, levels, sourceScratch, sourceCount);
781
- },
782
- configure(next) {
783
- cfg = mergeGridConfig(cfg, next);
784
- },
785
- dispose() {
786
- renderer.dispose();
787
- }
788
- };
789
- };
790
-
791
- // ../ground/src/passes/guides-collect.ts
792
- var guideQ = defineQuery([GuideLine]);
793
- var barQ = defineQuery([SpacingBar]);
794
- function collectGuides(world, frame, config = DEFAULT_SNAP_GUIDES_CONFIG) {
795
- const soup = new SoupBuilder();
796
- const cam = frame.camera;
797
- const lw = config.lineWidth;
798
- const guideColor = [config.color[0], config.color[1], config.color[2], config.guideAlpha];
799
- const barColor = [config.color[0], config.color[1], config.color[2], config.spacingAlpha];
800
- world.query(guideQ).each((b) => {
801
- for (const r of b) {
802
- const g = world.read(b.entity(r), GuideLine);
803
- const fullSpan = g.from === g.to;
804
- if (g.axis === "x") {
805
- const sx = worldToScreen(g.at, 0, cam).x;
806
- if (frame.width > 0 && (sx < -1 || sx > frame.width + 1)) continue;
807
- const y0 = fullSpan ? 0 : worldToScreen(0, g.from, cam).y;
808
- const y1 = fullSpan ? frame.height : worldToScreen(0, g.to, cam).y;
809
- soup.rect(sx - lw / 2, Math.min(y0, y1), lw, Math.abs(y1 - y0), guideColor);
810
- } else {
811
- const sy = worldToScreen(0, g.at, cam).y;
812
- if (frame.height > 0 && (sy < -1 || sy > frame.height + 1)) continue;
813
- const x0 = fullSpan ? 0 : worldToScreen(g.from, 0, cam).x;
814
- const x1 = fullSpan ? frame.width : worldToScreen(g.to, 0, cam).x;
815
- soup.rect(Math.min(x0, x1), sy - lw / 2, Math.abs(x1 - x0), lw, guideColor);
816
- }
817
- }
818
- });
819
- world.query(barQ).each((b) => {
820
- for (const r of b) {
821
- const s = world.read(b.entity(r), SpacingBar);
822
- const t = config.tickPx;
823
- if (s.axis === "x") {
824
- const a = worldToScreen(s.from, s.perp, cam);
825
- const bp = worldToScreen(s.to, s.perp, cam);
826
- if (frame.width > 0 && (Math.max(a.x, bp.x) < 0 || Math.min(a.x, bp.x) > frame.width)) continue;
827
- soup.rect(Math.min(a.x, bp.x), a.y - lw / 2, Math.abs(bp.x - a.x), lw, barColor);
828
- soup.rect(a.x - lw / 2, a.y - t, lw, t * 2, barColor);
829
- soup.rect(bp.x - lw / 2, bp.y - t, lw, t * 2, barColor);
830
- } else {
831
- const a = worldToScreen(s.perp, s.from, cam);
832
- const bp = worldToScreen(s.perp, s.to, cam);
833
- if (frame.height > 0 && (Math.max(a.y, bp.y) < 0 || Math.min(a.y, bp.y) > frame.height)) continue;
834
- soup.rect(a.x - lw / 2, Math.min(a.y, bp.y), lw, Math.abs(bp.y - a.y), barColor);
835
- soup.rect(a.x - t, a.y - lw / 2, t * 2, lw, barColor);
836
- soup.rect(bp.x - t, bp.y - lw / 2, t * 2, lw, barColor);
837
- }
838
- }
839
- });
840
- return soup.build();
841
- }
842
-
843
- // ../ground/src/passes/soup-mesh.ts
844
- import { attribute } from "three/tsl";
845
- import { BufferAttribute as BufferAttribute2, BufferGeometry, DoubleSide, Mesh as Mesh2, MeshBasicNodeMaterial as MeshBasicNodeMaterial2 } from "three/webgpu";
846
- function createSoupMesh(renderOrder) {
847
- const material = new MeshBasicNodeMaterial2();
848
- material.fragmentNode = attribute("color", "vec4");
849
- material.transparent = true;
850
- material.depthTest = false;
851
- material.depthWrite = false;
852
- material.side = DoubleSide;
853
- let geometry = new BufferGeometry();
854
- let capacity = 0;
855
- const mesh = new Mesh2(geometry, material);
856
- mesh.frustumCulled = false;
857
- mesh.renderOrder = renderOrder;
858
- mesh.visible = false;
859
- return {
860
- mesh,
861
- update(soup) {
862
- if (soup.vertexCount === 0) {
863
- mesh.visible = false;
864
- geometry.setDrawRange(0, 0);
865
- return;
866
- }
867
- if (soup.vertexCount > capacity) {
868
- capacity = Math.max(soup.vertexCount, capacity * 2, 256);
869
- const old = geometry;
870
- geometry = new BufferGeometry();
871
- const pos = new Float32Array(capacity * 3);
872
- const col = new Float32Array(capacity * 4);
873
- pos.set(soup.positions);
874
- col.set(soup.colors);
875
- geometry.setAttribute("position", new BufferAttribute2(pos, 3));
876
- geometry.setAttribute("color", new BufferAttribute2(col, 4));
877
- mesh.geometry = geometry;
878
- old.dispose();
879
- } else {
880
- const pos = geometry.getAttribute("position");
881
- const col = geometry.getAttribute("color");
882
- pos.array.set(soup.positions);
883
- col.array.set(soup.colors);
884
- pos.needsUpdate = true;
885
- col.needsUpdate = true;
886
- }
887
- geometry.setDrawRange(0, soup.vertexCount);
888
- mesh.visible = true;
889
- },
890
- dispose() {
891
- geometry.dispose();
892
- material.dispose();
893
- }
894
- };
895
- }
896
-
897
- // ../ground/src/passes/guides.ts
898
- function createGuidesPass(initial = {}) {
899
- const config = { ...DEFAULT_SNAP_GUIDES_CONFIG, ...initial };
900
- const soup = createSoupMesh(2);
901
- return {
902
- name: "snap-guides",
903
- object: soup.mesh,
904
- arm(world, wake) {
905
- return [
906
- world.reactive.observeQuery(guideQ, wake, { cols: [GuideLine] }),
907
- world.reactive.observeQuery(barQ, wake, { cols: [SpacingBar] })
908
- ];
909
- },
910
- collect(world, frame) {
911
- soup.update(collectGuides(world, frame, config));
912
- },
913
- dispose() {
914
- soup.dispose();
915
- }
916
- };
917
- }
918
-
919
- // ../ground/src/passes/wires.ts
920
- function createWiresPass(initial = {}, readPreview) {
921
- const config = { ...DEFAULT_WIRES_CONFIG, ...initial };
922
- const soup = createSoupMesh(1);
923
- return {
924
- name: "wires",
925
- object: soup.mesh,
926
- arm(world, wake) {
927
- return [
928
- world.reactive.observeQuery(wireQ, wake, { cols: [] }),
929
- world.reactive.observeQuery(geometryQ, wake, { cols: [Position, Size] }),
930
- // MeasuredSize rides its own observer (readRect prefers it over Size):
931
- // in geometryQ's cols it would REQUIRE the rider and drop plain widgets.
932
- world.reactive.observeQuery(measuredQ, wake, { cols: [MeasuredSize] }),
933
- world.reactive.observeQuery(selectedQ, wake, { cols: [] }),
934
- // Nav churn: Active membership flips gate the scope filter (a wire
935
- // whose endpoints left the current frame must disappear this frame).
936
- world.reactive.observeQuery(activeQ, wake, { cols: [] }),
937
- world.reactive.observeQuery(portQ, wake, { cols: [PortAnchor] }),
938
- world.reactive.observeQuery(routedConnectQ, wake, { cols: [] }),
939
- world.reactive.observeQuery(connectDragQ, wake, { cols: [Drag] })
940
- ];
941
- },
942
- collect(world, frame) {
943
- soup.update(collectWires(world, frame, config, readPreview?.()));
944
- },
945
- dispose() {
946
- soup.dispose();
947
- }
948
- };
949
- }
950
-
951
- // ../ground/src/renderer.ts
952
- import { WebGPURenderer } from "three/webgpu";
953
- function createGroundRenderer(doc, opts = {}) {
954
- const canvas = doc.createElement("canvas");
955
- let renderer = null;
956
- let isReady = false;
957
- let isFailed = false;
958
- const readyCbs = [];
959
- const gpu = globalThis.navigator?.gpu;
960
- if (gpu == null || opts.forceWebGL === true) {
961
- let gl2 = null;
962
- try {
963
- gl2 = doc.createElement("canvas").getContext("webgl2");
964
- } catch {
965
- gl2 = null;
966
- }
967
- if (gl2 === null) isFailed = true;
968
- }
969
- if (!isFailed) {
970
- try {
971
- renderer = new WebGPURenderer({
972
- canvas,
973
- alpha: true,
974
- // transparent clear — the page background shows through P0
975
- antialias: true,
976
- ...opts.forceWebGL === true ? { forceWebGL: true } : {}
977
- });
978
- renderer.init().then(() => {
979
- isReady = true;
980
- for (const cb of readyCbs.splice(0)) cb();
981
- }).catch(() => {
982
- isFailed = true;
983
- });
984
- } catch {
985
- isFailed = true;
986
- }
987
- }
988
- let lastW = 0;
989
- let lastH = 0;
990
- let lastDpr = 0;
991
- return {
992
- canvas,
993
- ready: () => isReady,
994
- failed: () => isFailed,
995
- onReady(cb) {
996
- if (isReady) cb();
997
- else readyCbs.push(cb);
998
- },
999
- setSize(cssW, cssH, dpr) {
1000
- if (renderer === null || cssW === lastW && cssH === lastH && dpr === lastDpr) return;
1001
- lastW = cssW;
1002
- lastH = cssH;
1003
- lastDpr = dpr;
1004
- try {
1005
- renderer.setPixelRatio(dpr);
1006
- renderer.setSize(Math.max(1, cssW), Math.max(1, cssH), false);
1007
- } catch {
1008
- isFailed = true;
1009
- }
1010
- },
1011
- render(scene, camera) {
1012
- if (renderer === null || !isReady || isFailed) return;
1013
- try {
1014
- renderer.render(scene, camera);
1015
- } catch {
1016
- isFailed = true;
1017
- }
1018
- },
1019
- dispose() {
1020
- try {
1021
- renderer?.dispose();
1022
- } catch {
1023
- }
1024
- renderer = null;
1025
- }
1026
- };
1027
- }
1028
-
1029
- // ../ground/src/poles.ts
1030
- var localPointerQ = defineQuery([Pointer, PointerWorld, LocalPointer]);
1031
- function localPointerPoles(opts = {}) {
1032
- const strength = opts.strength ?? 1;
1033
- return {
1034
- read(world) {
1035
- const out = [];
1036
- world.query(localPointerQ).each((b) => {
1037
- for (const r of b) {
1038
- const p = world.read(b.entity(r), PointerWorld);
1039
- out.push({ x: p.x, y: p.y, strength, space: "world" });
1040
- }
1041
- });
1042
- return out;
1043
- },
1044
- subscribe(world, wake) {
1045
- return world.reactive.observeQuery(localPointerQ, wake, { cols: [PointerWorld] });
1046
- }
1047
- };
1048
- }
1049
- var cursorVisualQ = defineQuery([Position, CursorVisual]);
1050
- function cursorVisualPoles(opts = {}) {
1051
- const strength = opts.strength ?? 1;
1052
- return {
1053
- read(world) {
1054
- const out = [];
1055
- world.query(cursorVisualQ).each((b) => {
1056
- for (const r of b) {
1057
- const p = world.read(b.entity(r), Position);
1058
- out.push({ x: p.x, y: p.y, strength, space: "world" });
1059
- }
1060
- });
1061
- return out;
1062
- },
1063
- subscribe(world, wake) {
1064
- return world.reactive.observeQuery(cursorVisualQ, wake, { cols: [Position] });
1065
- }
1066
- };
1067
- }
1068
-
1069
- // ../ground/src/index.ts
1070
- function ground(opts = {}) {
1071
- return (ctx) => {
1072
- const doc = ctx.host.container.ownerDocument;
1073
- const renderer = opts.rendererOverride ?? createGroundRenderer(doc, { forceWebGL: opts.forceWebGL === true });
1074
- const poles = opts.poles === void 0 ? [] : Array.isArray(opts.poles) ? opts.poles : [opts.poles];
1075
- const grid = createGridPass(opts.grid ?? {}, { poles, ...ctx.readSpatial !== void 0 ? { readSpatial: ctx.readSpatial } : {} });
1076
- const wires = createWiresPass(opts.wires ?? {}, ctx.readWirePreview);
1077
- const guides = createGuidesPass(opts.guides ?? {});
1078
- const passes = [grid, wires, guides, ...opts.passes ?? []];
1079
- const layer = createLayer(ctx.host, ctx.world, renderer, passes);
1080
- return {
1081
- reflector: layer.reflector,
1082
- configureGrid(cfg) {
1083
- grid.configure(cfg);
1084
- layer.invalidateAll();
1085
- },
1086
- dispose: layer.dispose
1087
- };
1088
- };
1089
- }
1090
- export {
1091
- DEFAULT_GRID_CONFIG,
1092
- DEFAULT_GRID_MAGNET_CONFIG,
1093
- DEFAULT_SNAP_GUIDES_CONFIG,
1094
- DEFAULT_WIRES_CONFIG,
1095
- MAX_MAGNET_SOURCES,
1096
- SoupBuilder,
1097
- collectGuides,
1098
- collectMagnetLevels,
1099
- collectMagnetSources,
1100
- collectWires,
1101
- cursorVisualPoles,
1102
- ground,
1103
- localPointerPoles,
1104
- magnetFieldScale,
1105
- parseCssColor,
1106
- resolveMagnet
1107
- };
1108
- //# sourceMappingURL=ground.js.map