@adobe/data 0.5.4 → 0.5.5

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 (346) hide show
  1. package/dist/ecs/database/create-database.d.ts +2 -2
  2. package/dist/ecs/database/database-schema/create-database-schema-test.d.ts +1 -0
  3. package/dist/ecs/database/database-schema/create-database-schema-test.js +42 -0
  4. package/dist/ecs/database/database-schema/create-database-schema-test.js.map +1 -0
  5. package/dist/ecs/database/database-schema/create-database-schema.d.ts +14 -0
  6. package/dist/ecs/database/database-schema/create-database-schema.js +32 -0
  7. package/dist/ecs/database/database-schema/create-database-schema.js.map +1 -0
  8. package/dist/ecs/database/database-schema/database-schema.d.ts +13 -0
  9. package/dist/{services/is-service.js → ecs/database/database-schema/database-schema.js} +2 -4
  10. package/dist/ecs/database/database-schema/database-schema.js.map +1 -0
  11. package/dist/ecs/database/database-schema/index.d.ts +2 -0
  12. package/dist/{services → ecs/database/database-schema}/index.js +2 -3
  13. package/dist/ecs/database/database-schema/index.js.map +1 -0
  14. package/dist/ecs/database/database.d.ts +3 -1
  15. package/dist/ecs/database/index.d.ts +1 -0
  16. package/dist/ecs/database/index.js +1 -0
  17. package/dist/ecs/database/index.js.map +1 -1
  18. package/dist/ecs/index.d.ts +2 -1
  19. package/dist/ecs/index.js +2 -1
  20. package/dist/ecs/index.js.map +1 -1
  21. package/dist/ecs/store/archetype-components.d.ts +3 -1
  22. package/dist/ecs/store/core/core.d.ts +1 -8
  23. package/dist/ecs/store/core/create-core.js +9 -4
  24. package/dist/ecs/store/core/create-core.js.map +1 -1
  25. package/dist/ecs/store/core/create-core.test.js +0 -109
  26. package/dist/ecs/store/core/create-core.test.js.map +1 -1
  27. package/dist/ecs/store/create-store.js +21 -0
  28. package/dist/ecs/store/create-store.js.map +1 -1
  29. package/dist/ecs/store/store-schema/create-store-schema-test.js +4 -7
  30. package/dist/ecs/store/store-schema/create-store-schema-test.js.map +1 -1
  31. package/dist/ecs/store/store-schema/create-store-schema.d.ts +2 -0
  32. package/dist/ecs/store/store-schema/create-store-schema.js +5 -0
  33. package/dist/ecs/store/store-schema/create-store-schema.js.map +1 -1
  34. package/dist/ecs/store/store-schema/index.d.ts +1 -1
  35. package/dist/ecs/store/store-schema/index.js +1 -1
  36. package/dist/ecs/store/store-schema/index.js.map +1 -1
  37. package/dist/ecs/store/store-schema/store-schema.d.ts +1 -1
  38. package/dist/ecs/world/create-world.d.ts +7 -0
  39. package/dist/ecs/world/create-world.js +108 -0
  40. package/dist/ecs/world/create-world.js.map +1 -0
  41. package/dist/ecs/world/create-world.test.d.ts +1 -0
  42. package/dist/ecs/world/create-world.test.js +499 -0
  43. package/dist/ecs/world/create-world.test.js.map +1 -0
  44. package/dist/ecs/world/index.d.ts +4 -0
  45. package/dist/ecs/world/index.js +26 -0
  46. package/dist/ecs/world/index.js.map +1 -0
  47. package/dist/ecs/world/system.d.ts +20 -0
  48. package/dist/ecs/world/system.js +2 -0
  49. package/dist/ecs/world/system.js.map +1 -0
  50. package/dist/ecs/world/world-schema/create-world-schema-test.d.ts +1 -0
  51. package/dist/ecs/world/world-schema/create-world-schema-test.js +55 -0
  52. package/dist/ecs/world/world-schema/create-world-schema-test.js.map +1 -0
  53. package/dist/ecs/world/world-schema/create-world-schema.d.ts +19 -0
  54. package/dist/ecs/world/world-schema/create-world-schema.js +33 -0
  55. package/dist/ecs/world/world-schema/create-world-schema.js.map +1 -0
  56. package/dist/ecs/world/world-schema/index.d.ts +2 -0
  57. package/dist/ecs/world/world-schema/index.js +24 -0
  58. package/dist/ecs/world/world-schema/index.js.map +1 -0
  59. package/dist/ecs/world/world-schema/world-schema.d.ts +18 -0
  60. package/dist/ecs/world/world-schema/world-schema.js +23 -0
  61. package/dist/ecs/world/world-schema/world-schema.js.map +1 -0
  62. package/dist/ecs/world/world.d.ts +9 -0
  63. package/dist/ecs/world/world.js +2 -0
  64. package/dist/ecs/world/world.js.map +1 -0
  65. package/dist/functions/serialization/serialization.test.js +78 -0
  66. package/dist/functions/serialization/serialization.test.js.map +1 -1
  67. package/dist/graphics/camera/camera.d.ts +62 -0
  68. package/dist/graphics/camera/camera.js +17 -0
  69. package/dist/graphics/camera/camera.js.map +1 -0
  70. package/dist/graphics/camera/index.d.ts +4 -0
  71. package/dist/graphics/camera/index.js +5 -0
  72. package/dist/graphics/camera/index.js.map +1 -0
  73. package/dist/graphics/camera/screen-to-world-ray.d.ts +12 -0
  74. package/dist/graphics/camera/screen-to-world-ray.js +49 -0
  75. package/dist/graphics/camera/screen-to-world-ray.js.map +1 -0
  76. package/dist/graphics/camera/screen-to-world-ray.test.d.ts +1 -0
  77. package/dist/graphics/camera/screen-to-world-ray.test.js +171 -0
  78. package/dist/graphics/camera/screen-to-world-ray.test.js.map +1 -0
  79. package/dist/graphics/camera/to-view-projection.d.ts +3 -0
  80. package/dist/graphics/camera/to-view-projection.js +8 -0
  81. package/dist/graphics/camera/to-view-projection.js.map +1 -0
  82. package/dist/graphics/camera/world-to-screen.d.ts +12 -0
  83. package/dist/graphics/camera/world-to-screen.js +38 -0
  84. package/dist/graphics/camera/world-to-screen.js.map +1 -0
  85. package/dist/graphics/camera/world-to-screen.test.d.ts +1 -0
  86. package/dist/graphics/camera/world-to-screen.test.js +124 -0
  87. package/dist/graphics/camera/world-to-screen.test.js.map +1 -0
  88. package/dist/graphics/create-struct-gpu-buffer.d.ts +7 -0
  89. package/dist/graphics/create-struct-gpu-buffer.js +17 -0
  90. package/dist/graphics/create-struct-gpu-buffer.js.map +1 -0
  91. package/dist/graphics/extract-wgsl-bindings.d.ts +5 -0
  92. package/dist/graphics/extract-wgsl-bindings.js +10 -0
  93. package/dist/graphics/extract-wgsl-bindings.js.map +1 -0
  94. package/dist/graphics/frame.d.ts +22 -0
  95. package/dist/graphics/frame.js +12 -0
  96. package/dist/graphics/frame.js.map +1 -0
  97. package/dist/graphics/get-web-gpu-device-and-context.d.ts +2 -0
  98. package/dist/graphics/get-web-gpu-device-and-context.js +21 -0
  99. package/dist/graphics/get-web-gpu-device-and-context.js.map +1 -0
  100. package/dist/graphics/graphics-context.d.ts +5 -0
  101. package/dist/graphics/graphics-context.js +2 -0
  102. package/dist/graphics/graphics-context.js.map +1 -0
  103. package/dist/graphics/index.d.ts +5 -0
  104. package/dist/graphics/index.js +5 -0
  105. package/dist/graphics/index.js.map +1 -0
  106. package/dist/graphics/to-gpu-buffer.d.ts +2 -0
  107. package/dist/graphics/to-gpu-buffer.js +14 -0
  108. package/dist/graphics/to-gpu-buffer.js.map +1 -0
  109. package/dist/internal/array/index.d.ts +1 -0
  110. package/dist/internal/array/index.js +23 -0
  111. package/dist/internal/array/index.js.map +1 -0
  112. package/dist/internal/array/topological-sort.d.ts +26 -0
  113. package/dist/internal/array/topological-sort.js +79 -0
  114. package/dist/internal/array/topological-sort.js.map +1 -0
  115. package/dist/internal/array/topological-sort.test.d.ts +1 -0
  116. package/dist/internal/array/topological-sort.test.js +100 -0
  117. package/dist/internal/array/topological-sort.test.js.map +1 -0
  118. package/dist/internal/function/debounce.d.ts +70 -0
  119. package/dist/internal/function/debounce.js +155 -0
  120. package/dist/internal/function/debounce.js.map +1 -0
  121. package/dist/internal/function/debounce.test.d.ts +1 -0
  122. package/dist/internal/function/debounce.test.js +306 -0
  123. package/dist/internal/function/debounce.test.js.map +1 -0
  124. package/dist/lit/elements/application-element.js.map +1 -1
  125. package/dist/lit/elements/application-host.d.ts +16 -0
  126. package/dist/lit/elements/application-host.js +59 -0
  127. package/dist/lit/elements/application-host.js.map +1 -0
  128. package/dist/lit/elements/index.d.ts +2 -0
  129. package/dist/lit/elements/index.js +2 -0
  130. package/dist/lit/elements/index.js.map +1 -1
  131. package/dist/lit/hooks/index.d.ts +3 -0
  132. package/dist/lit/hooks/index.js +3 -0
  133. package/dist/lit/hooks/index.js.map +1 -1
  134. package/dist/lit/hooks/use-drag-observe.d.ts +1 -1
  135. package/dist/lit/hooks/use-drag-observe.js +1 -1
  136. package/dist/lit/hooks/use-drag-observe.js.map +1 -1
  137. package/dist/lit/hooks/use-drag-transaction.d.ts +2 -3
  138. package/dist/lit/hooks/use-drag-transaction.js +3 -3
  139. package/dist/lit/hooks/use-drag-transaction.js.map +1 -1
  140. package/dist/math/aabb/aabb.d.ts +48 -0
  141. package/dist/math/aabb/aabb.js +86 -0
  142. package/dist/math/aabb/aabb.js.map +1 -0
  143. package/dist/math/aabb/line-intersection.test.d.ts +1 -0
  144. package/dist/math/aabb/line-intersection.test.js +210 -0
  145. package/dist/math/aabb/line-intersection.test.js.map +1 -0
  146. package/dist/math/constants.d.ts +4 -0
  147. package/dist/math/constants.js +26 -0
  148. package/dist/math/constants.js.map +1 -0
  149. package/dist/math/index.d.ts +18 -0
  150. package/dist/math/index.js +40 -0
  151. package/dist/math/index.js.map +1 -0
  152. package/dist/math/line2/intersects.test.d.ts +1 -0
  153. package/dist/math/line2/intersects.test.js +104 -0
  154. package/dist/math/line2/intersects.test.js.map +1 -0
  155. package/dist/math/line2/line2.d.ts +42 -0
  156. package/dist/math/line2/line2.js +78 -0
  157. package/dist/math/line2/line2.js.map +1 -0
  158. package/dist/math/line3/closest-point-on-line.test.d.ts +1 -0
  159. package/dist/math/line3/closest-point-on-line.test.js +107 -0
  160. package/dist/math/line3/closest-point-on-line.test.js.map +1 -0
  161. package/dist/math/line3/interpolate.test.d.ts +1 -0
  162. package/dist/math/line3/interpolate.test.js +66 -0
  163. package/dist/math/line3/interpolate.test.js.map +1 -0
  164. package/dist/math/line3/line3.d.ts +49 -0
  165. package/dist/math/line3/line3.js +77 -0
  166. package/dist/math/line3/line3.js.map +1 -0
  167. package/dist/math/line3/sub-line.test.d.ts +1 -0
  168. package/dist/math/line3/sub-line.test.js +70 -0
  169. package/dist/math/line3/sub-line.test.js.map +1 -0
  170. package/dist/math/mat4x4/mat4x4.d.ts +37 -0
  171. package/dist/math/mat4x4/mat4x4.js +246 -0
  172. package/dist/math/mat4x4/mat4x4.js.map +1 -0
  173. package/dist/math/picking/index.d.ts +1 -0
  174. package/dist/math/picking/index.js +23 -0
  175. package/dist/math/picking/index.js.map +1 -0
  176. package/dist/math/picking/pick-from-tables.d.ts +18 -0
  177. package/dist/math/picking/pick-from-tables.js +154 -0
  178. package/dist/math/picking/pick-from-tables.js.map +1 -0
  179. package/dist/math/picking/pick-result.d.ts +7 -0
  180. package/dist/{services/service.js → math/picking/pick-result.js} +1 -1
  181. package/dist/math/picking/pick-result.js.map +1 -0
  182. package/dist/math/quat/quat.d.ts +42 -0
  183. package/dist/math/quat/quat.js +220 -0
  184. package/dist/math/quat/quat.js.map +1 -0
  185. package/dist/math/vec2/vec2.d.ts +63 -0
  186. package/dist/math/vec2/vec2.js +114 -0
  187. package/dist/math/vec2/vec2.js.map +1 -0
  188. package/dist/math/vec3/vec3.d.ts +65 -0
  189. package/dist/math/vec3/vec3.js +154 -0
  190. package/dist/math/vec3/vec3.js.map +1 -0
  191. package/dist/math/vec4/vec4.d.ts +63 -0
  192. package/dist/math/vec4/vec4.js +154 -0
  193. package/dist/math/vec4/vec4.js.map +1 -0
  194. package/dist/observe/to-async-generator.js +4 -0
  195. package/dist/observe/to-async-generator.js.map +1 -1
  196. package/dist/observe/with-filter.d.ts +1 -1
  197. package/dist/observe/with-filter.js.map +1 -1
  198. package/dist/samples/index.d.ts +13 -0
  199. package/dist/samples/index.js +27 -0
  200. package/dist/samples/index.js.map +1 -0
  201. package/dist/samples/todo/elements/todo-list/todo-list-presentation.d.ts +25 -0
  202. package/dist/samples/todo/elements/todo-list/todo-list-presentation.js +12 -0
  203. package/dist/samples/todo/elements/todo-list/todo-list-presentation.js.map +1 -0
  204. package/dist/samples/todo/elements/todo-list/todo-list.css.d.ts +18 -0
  205. package/dist/samples/todo/elements/todo-list/todo-list.css.js +27 -0
  206. package/dist/samples/todo/elements/todo-list/todo-list.css.js.map +1 -0
  207. package/dist/samples/todo/elements/todo-list/todo-list.d.ts +12 -0
  208. package/dist/samples/todo/elements/todo-list/todo-list.js +60 -0
  209. package/dist/samples/todo/elements/todo-list/todo-list.js.map +1 -0
  210. package/dist/samples/todo/elements/todo-row/index.d.ts +18 -0
  211. package/dist/samples/todo/elements/todo-row/index.js +19 -0
  212. package/dist/samples/todo/elements/todo-row/index.js.map +1 -0
  213. package/dist/samples/todo/elements/todo-row/todo-row-presentation.d.ts +18 -0
  214. package/dist/samples/todo/elements/todo-row/todo-row-presentation.js +66 -0
  215. package/dist/samples/todo/elements/todo-row/todo-row-presentation.js.map +1 -0
  216. package/dist/samples/todo/elements/todo-row/todo-row.css.d.ts +1 -0
  217. package/dist/samples/todo/elements/todo-row/todo-row.css.js +65 -0
  218. package/dist/samples/todo/elements/todo-row/todo-row.css.js.map +1 -0
  219. package/dist/samples/todo/elements/todo-row/todo-row.d.ts +14 -0
  220. package/dist/samples/todo/elements/todo-row/todo-row.js +60 -0
  221. package/dist/samples/todo/elements/todo-row/todo-row.js.map +1 -0
  222. package/dist/samples/todo/elements/todo-toolbar/index.d.ts +18 -0
  223. package/dist/samples/todo/elements/todo-toolbar/index.js +19 -0
  224. package/dist/samples/todo/elements/todo-toolbar/index.js.map +1 -0
  225. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.d.ts +22 -0
  226. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.js +57 -0
  227. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar-presentation.js.map +1 -0
  228. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.d.ts +1 -0
  229. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.js +50 -0
  230. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.css.js.map +1 -0
  231. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.d.ts +11 -0
  232. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.js +77 -0
  233. package/dist/samples/todo/elements/todo-toolbar/todo-toolbar.js.map +1 -0
  234. package/dist/samples/todo/elements/todo-undo-redo/index.d.ts +18 -0
  235. package/dist/samples/todo/elements/todo-undo-redo/index.js +19 -0
  236. package/dist/samples/todo/elements/todo-undo-redo/index.js.map +1 -0
  237. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.d.ts +17 -0
  238. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.js +45 -0
  239. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo-presentation.js.map +1 -0
  240. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.d.ts +1 -0
  241. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.js +28 -0
  242. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.css.js.map +1 -0
  243. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.d.ts +11 -0
  244. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.js +52 -0
  245. package/dist/samples/todo/elements/todo-undo-redo/todo-undo-redo.js.map +1 -0
  246. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.d.ts +6 -0
  247. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.js +21 -0
  248. package/dist/samples/todo/services/dependent-state-service/create-dependent-state-service.js.map +1 -0
  249. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.d.ts +19 -0
  250. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.js +2 -0
  251. package/dist/samples/todo/services/dependent-state-service/dependent-state/all-todos.js.map +1 -0
  252. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.d.ts +19 -0
  253. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.js +2 -0
  254. package/dist/samples/todo/services/dependent-state-service/dependent-state/complete-todos.js.map +1 -0
  255. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.d.ts +19 -0
  256. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.js +2 -0
  257. package/dist/samples/todo/services/dependent-state-service/dependent-state/incomplete-todos.js.map +1 -0
  258. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.d.ts +20 -0
  259. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.js +21 -0
  260. package/dist/samples/todo/services/dependent-state-service/dependent-state/index.js.map +1 -0
  261. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.d.ts +19 -0
  262. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.js +2 -0
  263. package/dist/samples/todo/services/dependent-state-service/dependent-state-service.js.map +1 -0
  264. package/dist/samples/todo/services/main-service/create-main-service.d.ts +25 -0
  265. package/dist/samples/todo/services/main-service/create-main-service.js +39 -0
  266. package/dist/samples/todo/services/main-service/create-main-service.js.map +1 -0
  267. package/dist/samples/todo/services/main-service/todo-main-service.d.ts +35 -0
  268. package/dist/samples/todo/services/main-service/todo-main-service.js +2 -0
  269. package/dist/samples/todo/services/main-service/todo-main-service.js.map +1 -0
  270. package/dist/samples/todo/services/state-service/create-todo-database.d.ts +13 -0
  271. package/dist/samples/todo/services/state-service/create-todo-database.js +26 -0
  272. package/dist/samples/todo/services/state-service/create-todo-database.js.map +1 -0
  273. package/dist/samples/todo/services/state-service/create-todo-store.d.ts +13 -0
  274. package/dist/samples/todo/services/state-service/create-todo-store.js +41 -0
  275. package/dist/samples/todo/services/state-service/create-todo-store.js.map +1 -0
  276. package/dist/samples/todo/services/state-service/todo-state-service.d.ts +22 -0
  277. package/dist/samples/todo/services/state-service/todo-state-service.js +2 -0
  278. package/dist/samples/todo/services/state-service/todo-state-service.js.map +1 -0
  279. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.d.ts +2 -0
  280. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.js +26 -0
  281. package/dist/samples/todo/services/state-service/transactions/create-bulk-todos.js.map +1 -0
  282. package/dist/samples/todo/services/state-service/transactions/create-todo.d.ts +22 -0
  283. package/dist/samples/todo/services/state-service/transactions/create-todo.js +13 -0
  284. package/dist/samples/todo/services/state-service/transactions/create-todo.js.map +1 -0
  285. package/dist/samples/todo/services/state-service/transactions/create-todo.test.d.ts +1 -0
  286. package/dist/samples/todo/services/state-service/transactions/create-todo.test.js +32 -0
  287. package/dist/samples/todo/services/state-service/transactions/create-todo.test.js.map +1 -0
  288. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.d.ts +19 -0
  289. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.js +16 -0
  290. package/dist/samples/todo/services/state-service/transactions/delete-all-todos.js.map +1 -0
  291. package/dist/samples/todo/services/state-service/transactions/delete-todo.d.ts +3 -0
  292. package/dist/samples/todo/services/state-service/transactions/delete-todo.js +24 -0
  293. package/dist/samples/todo/services/state-service/transactions/delete-todo.js.map +1 -0
  294. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.d.ts +1 -0
  295. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.js +40 -0
  296. package/dist/samples/todo/services/state-service/transactions/delete-todo.test.js.map +1 -0
  297. package/dist/samples/todo/services/state-service/transactions/drag-todo.d.ts +7 -0
  298. package/dist/samples/todo/services/state-service/transactions/drag-todo.js +33 -0
  299. package/dist/samples/todo/services/state-service/transactions/drag-todo.js.map +1 -0
  300. package/dist/samples/todo/services/state-service/transactions/index.d.ts +23 -0
  301. package/dist/samples/todo/services/state-service/transactions/index.js +25 -0
  302. package/dist/samples/todo/services/state-service/transactions/index.js.map +1 -0
  303. package/dist/samples/todo/services/state-service/transactions/reorder-todos.d.ts +23 -0
  304. package/dist/samples/todo/services/state-service/transactions/reorder-todos.js +11 -0
  305. package/dist/samples/todo/services/state-service/transactions/reorder-todos.js.map +1 -0
  306. package/dist/samples/todo/services/state-service/transactions/toggle-complete.d.ts +20 -0
  307. package/dist/samples/todo/services/state-service/transactions/toggle-complete.js +11 -0
  308. package/dist/samples/todo/services/state-service/transactions/toggle-complete.js.map +1 -0
  309. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.d.ts +1 -0
  310. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.js +81 -0
  311. package/dist/samples/todo/services/state-service/transactions/toggle-complete.test.js.map +1 -0
  312. package/dist/samples/todo/todo-element.d.ts +21 -0
  313. package/dist/samples/todo/todo-element.js +4 -0
  314. package/dist/samples/todo/todo-element.js.map +1 -0
  315. package/dist/samples/todo/todo-host.d.ts +8 -0
  316. package/dist/samples/todo/todo-host.js +55 -0
  317. package/dist/samples/todo/todo-host.js.map +1 -0
  318. package/dist/samples/todo/todo-main-element.d.ts +27 -0
  319. package/dist/samples/todo/todo-main-element.js +63 -0
  320. package/dist/samples/todo/todo-main-element.js.map +1 -0
  321. package/dist/samples/todo/todo-sample.d.ts +3 -0
  322. package/dist/samples/todo/todo-sample.js +39 -0
  323. package/dist/samples/todo/todo-sample.js.map +1 -0
  324. package/dist/schema/schema.d.ts +7 -6
  325. package/dist/schema/schema.js.map +1 -1
  326. package/dist/tsconfig.tsbuildinfo +1 -1
  327. package/dist/typed-buffer/register-typed-buffer-codecs.js +39 -22
  328. package/dist/typed-buffer/register-typed-buffer-codecs.js.map +1 -1
  329. package/dist/typed-buffer/structs/get-struct-layout.js +3 -0
  330. package/dist/typed-buffer/structs/get-struct-layout.js.map +1 -1
  331. package/package.json +20 -3
  332. package/dist/service/to-frontend-service.d.ts +0 -12
  333. package/dist/service/to-frontend-service.js +0 -5
  334. package/dist/service/to-frontend-service.js.map +0 -1
  335. package/dist/services/add-observable-actions.d.ts +0 -29
  336. package/dist/services/add-observable-actions.js +0 -108
  337. package/dist/services/add-observable-actions.js.map +0 -1
  338. package/dist/services/index.d.ts +0 -4
  339. package/dist/services/index.js.map +0 -1
  340. package/dist/services/is-service.d.ts +0 -2
  341. package/dist/services/is-service.js.map +0 -1
  342. package/dist/services/progressive-result.d.ts +0 -96
  343. package/dist/services/progressive-result.js +0 -99
  344. package/dist/services/progressive-result.js.map +0 -1
  345. package/dist/services/service.d.ts +0 -4
  346. package/dist/services/service.js.map +0 -1
@@ -0,0 +1,154 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ import { Aabb } from "../index.js";
23
+ import { Line3 } from "../index.js";
24
+ import { Vec3 } from "../index.js";
25
+ /**
26
+ * Determines which face of a cube was hit based on the intersection point
27
+ * @param position World position of the intersection
28
+ * @param aabb Bounding box of the cube
29
+ * @returns Face index: 0=POS_Z, 1=POS_X, 2=NEG_Z, 3=NEG_X, 4=POS_Y, 5=NEG_Y
30
+ */
31
+ function determineFaceFromPosition(position, aabb) {
32
+ const aabbCenter = Aabb.center(aabb);
33
+ const localPos = [
34
+ position[0] - aabbCenter[0],
35
+ position[1] - aabbCenter[1],
36
+ position[2] - aabbCenter[2]
37
+ ];
38
+ // Find the face with the largest absolute coordinate (closest to cube surface)
39
+ const absX = Math.abs(localPos[0]);
40
+ const absY = Math.abs(localPos[1]);
41
+ const absZ = Math.abs(localPos[2]);
42
+ if (absX >= absY && absX >= absZ) {
43
+ // X-axis face (NEG_X or POS_X)
44
+ return localPos[0] > 0 ? 1 : 3; // 1=POS_X, 3=NEG_X
45
+ }
46
+ else if (absY >= absZ) {
47
+ // Y-axis face (NEG_Y or POS_Y)
48
+ return localPos[1] > 0 ? 4 : 5; // 4=POS_Y, 5=NEG_Y
49
+ }
50
+ else {
51
+ // Z-axis face (NEG_Z or POS_Z)
52
+ return localPos[2] > 0 ? 0 : 2; // 0=POS_Z, 2=NEG_Z
53
+ }
54
+ }
55
+ function getIntersectingEntities(options) {
56
+ const { tables, line, radius = 0, predicate } = options;
57
+ const rows = new Map();
58
+ for (const table of tables) {
59
+ for (let row = 0; row < table.rowCount; row++) {
60
+ const boundingBox = table.columns.boundingBox.get(row);
61
+ if (Aabb.lineIntersection(boundingBox, line, radius) !== -1 && (predicate?.(table, row) ?? true)) {
62
+ rows.set(table.columns.id.get(row), boundingBox);
63
+ }
64
+ }
65
+ }
66
+ return rows;
67
+ }
68
+ function getClosestEntityToPoint(rows, point) {
69
+ let closestRow = -1;
70
+ let closestDistanceSquared = Infinity;
71
+ let closestAabb = null;
72
+ for (const [row, aabb] of rows) {
73
+ const distSquared = Vec3.distanceSquared(point, Aabb.center(aabb));
74
+ if (distSquared < closestDistanceSquared) {
75
+ closestDistanceSquared = distSquared;
76
+ closestRow = row;
77
+ closestAabb = aabb;
78
+ }
79
+ }
80
+ if (closestRow !== -1 && closestAabb) {
81
+ // For direct intersection, use the intersection point if possible
82
+ // We'll use the intersection alpha from Aabb.lineIntersection
83
+ // If the line starts inside, alpha=0, so position is line.a
84
+ // Otherwise, Line3.interpolate at alpha
85
+ return {
86
+ entity: closestRow,
87
+ position: point,
88
+ face: determineFaceFromPosition(point, closestAabb),
89
+ };
90
+ }
91
+ return null;
92
+ }
93
+ function getClosestEntityToLine(rows, line) {
94
+ let closestEntity = null;
95
+ let closestDistanceSquared = Infinity;
96
+ let closestAlpha = Infinity;
97
+ let pickedPosition = null;
98
+ for (const [id, aabb] of rows) {
99
+ const aabbCenter = Aabb.center(aabb);
100
+ const alpha = Line3.closestPointOnLine(line, aabbCenter);
101
+ const closestPointOnLineSegment = Line3.interpolate(line, alpha);
102
+ const distSquared = Vec3.distanceSquared(aabbCenter, closestPointOnLineSegment);
103
+ if (distSquared < closestDistanceSquared ||
104
+ (distSquared === closestDistanceSquared && alpha < closestAlpha)) {
105
+ closestDistanceSquared = distSquared;
106
+ closestAlpha = alpha;
107
+ closestEntity = id;
108
+ pickedPosition = closestPointOnLineSegment;
109
+ }
110
+ }
111
+ if (closestEntity !== null && pickedPosition) {
112
+ return {
113
+ entity: closestEntity,
114
+ position: pickedPosition,
115
+ face: determineFaceFromPosition(pickedPosition, rows.get(closestEntity)),
116
+ };
117
+ }
118
+ return null;
119
+ }
120
+ /**
121
+ * Picks the closest intersecting row from a table.
122
+ * @returns The entity id and picked position, or null if no entity is found.
123
+ */
124
+ export function pickFromTables(options) {
125
+ const { tables, line, radius = 0, predicate } = options;
126
+ let rows = getIntersectingEntities({ tables, line, radius: 0, predicate });
127
+ if (rows.size > 0) {
128
+ // For direct intersection, find the alpha for the closest intersecting entity
129
+ let best = null;
130
+ for (const [id, aabb] of rows) {
131
+ const alpha = Aabb.lineIntersection(aabb, line, 0);
132
+ if (alpha !== -1 && (best === null || alpha < best.alpha)) {
133
+ best = { id, alpha };
134
+ }
135
+ }
136
+ if (best) {
137
+ return {
138
+ entity: best.id,
139
+ position: Line3.interpolate(line, best.alpha),
140
+ face: determineFaceFromPosition(Line3.interpolate(line, best.alpha), rows.get(best.id)),
141
+ };
142
+ }
143
+ // fallback (should not happen):
144
+ return getClosestEntityToPoint(rows, line.a);
145
+ }
146
+ else if (radius > 0) {
147
+ rows = getIntersectingEntities({ tables, line, radius, predicate });
148
+ if (rows.size > 0) {
149
+ return getClosestEntityToLine(rows, line);
150
+ }
151
+ }
152
+ return null;
153
+ }
154
+ //# sourceMappingURL=pick-from-tables.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick-from-tables.js","sourceRoot":"","sources":["../../../src/math/picking/pick-from-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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E,yBAAyB,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAE,CAAC;aAC3F,CAAC;QACN,CAAC;QACD,gCAAgC;QAChC,OAAO,uBAAuB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACpB,IAAI,GAAG,uBAAuB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QACpE,IAAI,IAAI,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAChB,OAAO,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC9C,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Entity } from "../../ecs/index.js";
2
+ import { Vec3 } from "../index.js";
3
+ export interface PickResult {
4
+ entity: Entity;
5
+ position: Vec3;
6
+ face: number;
7
+ }
@@ -20,4 +20,4 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.*/
22
22
  export {};
23
- //# sourceMappingURL=service.js.map
23
+ //# sourceMappingURL=pick-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick-result.js","sourceRoot":"","sources":["../../../src/math/picking/pick-result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW"}
@@ -0,0 +1,42 @@
1
+ import { FromSchema } from "../../schema/index.js";
2
+ import { Vec3, Mat4x4 } from "../index.js";
3
+ export declare const schema: {
4
+ readonly type: "array";
5
+ readonly items: {
6
+ readonly type: "number";
7
+ readonly precision: 1;
8
+ readonly default: number;
9
+ };
10
+ readonly minItems: 4;
11
+ readonly maxItems: 4;
12
+ readonly default: readonly [0, 0, 0, 1];
13
+ };
14
+ export type Type = FromSchema<typeof schema>;
15
+ type Quat = Type;
16
+ export declare const layout: import("../../typed-buffer/index.js").StructLayout;
17
+ export declare const add: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
18
+ export declare const subtract: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
19
+ export declare const scale: ([x, y, z, w]: Quat, s: number) => Quat;
20
+ export declare const negate: ([x, y, z, w]: Quat) => Quat;
21
+ export declare const conjugate: ([x, y, z, w]: Quat) => Quat;
22
+ export declare const multiply: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => Quat;
23
+ export declare const length: ([x, y, z, w]: Quat) => number;
24
+ export declare const lengthSquared: ([x, y, z, w]: Quat) => number;
25
+ export declare const normalize: (q: Quat) => Quat;
26
+ export declare const dot: ([x1, y1, z1, w1]: Quat, [x2, y2, z2, w2]: Quat) => number;
27
+ export declare const distance: (a: Quat, b: Quat) => number;
28
+ export declare const fromAxisAngle: (axis: Vec3, angle: number) => Quat;
29
+ export declare const toAxisAngle: ([x, y, z, w]: Quat) => {
30
+ axis: Vec3;
31
+ angle: number;
32
+ };
33
+ export declare const fromEuler: (x: number, y: number, z: number) => Quat;
34
+ export declare const toEuler: ([x, y, z, w]: Quat) => Vec3;
35
+ export declare const rotateVec3: ([x, y, z, w]: Quat, v: Vec3) => Vec3;
36
+ export declare const slerp: (q1: Quat, q2: Quat, t: number) => Quat;
37
+ export declare const lerp: (q1: Quat, q2: Quat, t: number) => Quat;
38
+ export declare const toMat4: ([x, y, z, w]: Quat) => Mat4x4;
39
+ export declare const identity: () => Quat;
40
+ export declare const inverse: (q: Quat) => Quat;
41
+ export declare const lookAt: (forward: Vec3, up: Vec3) => Quat;
42
+ export {};
@@ -0,0 +1,220 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ import { F32Schema } from "../../schema/index.js";
23
+ import { getStructLayout } from "../../typed-buffer/index.js";
24
+ import { Vec3 } from "../index.js";
25
+ export const schema = {
26
+ type: 'array',
27
+ items: F32Schema,
28
+ minItems: 4,
29
+ maxItems: 4,
30
+ default: [0, 0, 0, 1], // identity quaternion
31
+ };
32
+ export const layout = getStructLayout(schema);
33
+ // Basic Quaternion Operations
34
+ export const add = ([x1, y1, z1, w1], [x2, y2, z2, w2]) => [
35
+ x1 + x2,
36
+ y1 + y2,
37
+ z1 + z2,
38
+ w1 + w2
39
+ ];
40
+ export const subtract = ([x1, y1, z1, w1], [x2, y2, z2, w2]) => [
41
+ x1 - x2,
42
+ y1 - y2,
43
+ z1 - z2,
44
+ w1 - w2
45
+ ];
46
+ export const scale = ([x, y, z, w], s) => [x * s, y * s, z * s, w * s];
47
+ export const negate = ([x, y, z, w]) => [-x, -y, -z, -w];
48
+ export const conjugate = ([x, y, z, w]) => [-x, -y, -z, w];
49
+ export const multiply = ([x1, y1, z1, w1], [x2, y2, z2, w2]) => [
50
+ x1 * w2 + w1 * x2 + y1 * z2 - z1 * y2,
51
+ y1 * w2 + w1 * y2 + z1 * x2 - x1 * z2,
52
+ z1 * w2 + w1 * z2 + x1 * y2 - y1 * x2,
53
+ w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2
54
+ ];
55
+ // Geometric Functions
56
+ export const length = ([x, y, z, w]) => Math.sqrt(x * x + y * y + z * z + w * w);
57
+ export const lengthSquared = ([x, y, z, w]) => x * x + y * y + z * z + w * w;
58
+ export const normalize = (q) => {
59
+ const len = length(q);
60
+ return len === 0 ? [0, 0, 0, 1] : scale(q, 1 / len);
61
+ };
62
+ export const dot = ([x1, y1, z1, w1], [x2, y2, z2, w2]) => x1 * x2 + y1 * y2 + z1 * z2 + w1 * w2;
63
+ export const distance = (a, b) => length(subtract(b, a));
64
+ // Rotation Functions
65
+ export const fromAxisAngle = (axis, angle) => {
66
+ const halfAngle = angle * 0.5;
67
+ const s = Math.sin(halfAngle);
68
+ const c = Math.cos(halfAngle);
69
+ return [axis[0] * s, axis[1] * s, axis[2] * s, c];
70
+ };
71
+ export const toAxisAngle = ([x, y, z, w]) => {
72
+ const angle = 2 * Math.acos(Math.abs(w));
73
+ const s = Math.sin(angle * 0.5);
74
+ if (s === 0) {
75
+ return { axis: [0, 0, 1], angle: 0 };
76
+ }
77
+ return {
78
+ axis: [x / s, y / s, z / s],
79
+ angle: w < 0 ? -angle : angle
80
+ };
81
+ };
82
+ export const fromEuler = (x, y, z) => {
83
+ const cx = Math.cos(x * 0.5);
84
+ const sx = Math.sin(x * 0.5);
85
+ const cy = Math.cos(y * 0.5);
86
+ const sy = Math.sin(y * 0.5);
87
+ const cz = Math.cos(z * 0.5);
88
+ const sz = Math.sin(z * 0.5);
89
+ return [
90
+ sx * cy * cz - cx * sy * sz,
91
+ cx * sy * cz + sx * cy * sz,
92
+ cx * cy * sz - sx * sy * cz,
93
+ cx * cy * cz + sx * sy * sz
94
+ ];
95
+ };
96
+ export const toEuler = ([x, y, z, w]) => {
97
+ // Roll (x-axis rotation)
98
+ const sinr_cosp = 2 * (w * x + y * z);
99
+ const cosr_cosp = 1 - 2 * (x * x + y * y);
100
+ const roll = Math.atan2(sinr_cosp, cosr_cosp);
101
+ // Pitch (y-axis rotation)
102
+ const sinp = 2 * (w * y - z * x);
103
+ let pitch;
104
+ if (Math.abs(sinp) >= 1) {
105
+ pitch = Math.sign(sinp) * Math.PI / 2; // use 90 degrees if out of range
106
+ }
107
+ else {
108
+ pitch = Math.asin(sinp);
109
+ }
110
+ // Yaw (z-axis rotation)
111
+ const siny_cosp = 2 * (w * z + x * y);
112
+ const cosy_cosp = 1 - 2 * (y * y + z * z);
113
+ const yaw = Math.atan2(siny_cosp, cosy_cosp);
114
+ return [roll, pitch, yaw];
115
+ };
116
+ // Vector Rotation
117
+ export const rotateVec3 = ([x, y, z, w], v) => {
118
+ // q * v * q^-1
119
+ const qv = [x, y, z];
120
+ const uv = Vec3.cross(qv, v);
121
+ const uuv = Vec3.cross(qv, uv);
122
+ const scaleFactor = 2 * w;
123
+ return [
124
+ v[0] + scaleFactor * uv[0] + 2 * uuv[0],
125
+ v[1] + scaleFactor * uv[1] + 2 * uuv[1],
126
+ v[2] + scaleFactor * uv[2] + 2 * uuv[2]
127
+ ];
128
+ };
129
+ // Interpolation
130
+ export const slerp = (q1, q2, t) => {
131
+ const dotProduct = dot(q1, q2);
132
+ // If the dot product is negative, slerp won't take the shorter route
133
+ const q2Adjusted = dotProduct < 0 ? negate(q2) : q2;
134
+ const adjustedDot = Math.abs(dotProduct);
135
+ // If the inputs are too close for comfort, linearly interpolate
136
+ if (adjustedDot > 0.9995) {
137
+ return normalize(add(scale(q1, 1 - t), scale(q2Adjusted, t)));
138
+ }
139
+ const theta = Math.acos(adjustedDot);
140
+ const sinTheta = Math.sin(theta);
141
+ const factor1 = Math.sin((1 - t) * theta) / sinTheta;
142
+ const factor2 = Math.sin(t * theta) / sinTheta;
143
+ return normalize(add(scale(q1, factor1), scale(q2Adjusted, factor2)));
144
+ };
145
+ export const lerp = (q1, q2, t) => {
146
+ return normalize(add(scale(q1, 1 - t), scale(q2, t)));
147
+ };
148
+ // Matrix Conversion
149
+ export const toMat4 = ([x, y, z, w]) => {
150
+ const xx = x * x;
151
+ const yy = y * y;
152
+ const zz = z * z;
153
+ const xy = x * y;
154
+ const xz = x * z;
155
+ const yz = y * z;
156
+ const wx = w * x;
157
+ const wy = w * y;
158
+ const wz = w * z;
159
+ return [
160
+ 1 - 2 * (yy + zz), 2 * (xy - wz), 2 * (xz + wy), 0,
161
+ 2 * (xy + wz), 1 - 2 * (xx + zz), 2 * (yz - wx), 0,
162
+ 2 * (xz - wy), 2 * (yz + wx), 1 - 2 * (xx + yy), 0,
163
+ 0, 0, 0, 1
164
+ ];
165
+ };
166
+ // Utility Functions
167
+ export const identity = () => [0, 0, 0, 1];
168
+ export const inverse = (q) => {
169
+ const lenSq = lengthSquared(q);
170
+ if (lenSq === 0)
171
+ return [0, 0, 0, 1];
172
+ return scale(conjugate(q), 1 / lenSq);
173
+ };
174
+ export const lookAt = (forward, up) => {
175
+ // Normalize forward vector
176
+ const f = Vec3.normalize(forward);
177
+ // Calculate right vector
178
+ const r = Vec3.normalize(Vec3.cross(f, up));
179
+ // Recalculate up vector
180
+ const u = Vec3.cross(r, f);
181
+ // Convert to quaternion
182
+ const trace = r[0] + u[1] + f[2];
183
+ if (trace > 0) {
184
+ const s = Math.sqrt(trace + 1) * 2;
185
+ return [
186
+ (u[2] - f[1]) / s,
187
+ (f[0] - r[2]) / s,
188
+ (r[1] - u[0]) / s,
189
+ 0.25 * s
190
+ ];
191
+ }
192
+ else if (r[0] > u[1] && r[0] > f[2]) {
193
+ const s = Math.sqrt(1 + r[0] - u[1] - f[2]) * 2;
194
+ return [
195
+ 0.25 * s,
196
+ (u[0] + r[1]) / s,
197
+ (f[0] + r[2]) / s,
198
+ (u[2] - f[1]) / s
199
+ ];
200
+ }
201
+ else if (u[1] > f[2]) {
202
+ const s = Math.sqrt(1 + u[1] - r[0] - f[2]) * 2;
203
+ return [
204
+ (u[0] + r[1]) / s,
205
+ 0.25 * s,
206
+ (f[1] + u[2]) / s,
207
+ (f[0] - r[2]) / s
208
+ ];
209
+ }
210
+ else {
211
+ const s = Math.sqrt(1 + f[2] - r[0] - u[1]) * 2;
212
+ return [
213
+ (f[0] + r[2]) / s,
214
+ (f[1] + u[2]) / s,
215
+ 0.25 * s,
216
+ (r[1] - u[0]) / s
217
+ ];
218
+ }
219
+ };
220
+ //# sourceMappingURL=quat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quat.js","sourceRoot":"","sources":["../../../src/math/quat/quat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;WAoBW;AAEX,OAAO,EAAE,SAAS,EAAsB,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAU,MAAM,aAAa,CAAC;AAE3C,MAAM,CAAC,MAAM,MAAM,GAAG;IAClB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,SAAS;IAChB,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,sBAAsB;CACtB,CAAC;AAI5B,MAAM,CAAC,MAAM,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;AAE9C,8BAA8B;AAC9B,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAO,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAO,EAAQ,EAAE,CAAC;IACzE,EAAE,GAAG,EAAE;IACP,E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AAC;IACN,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,63 @@
1
+ import { FromSchema } from "../../schema/index.js";
2
+ export declare const schema: {
3
+ readonly type: "array";
4
+ readonly items: {
5
+ readonly type: "number";
6
+ readonly precision: 1;
7
+ readonly default: number;
8
+ };
9
+ readonly minItems: 2;
10
+ readonly maxItems: 2;
11
+ readonly default: readonly [0, 0];
12
+ };
13
+ export type Type = FromSchema<typeof schema>;
14
+ type Vec2 = Type;
15
+ export declare const layout: import("../../typed-buffer/index.js").StructLayout;
16
+ export declare const abs: ([x, y]: Vec2) => Vec2;
17
+ export declare const ceil: ([x, y]: Vec2) => Vec2;
18
+ export declare const floor: ([x, y]: Vec2) => Vec2;
19
+ export declare const round: ([x, y]: Vec2) => Vec2;
20
+ export declare const trunc: ([x, y]: Vec2) => Vec2;
21
+ export declare const min: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
22
+ export declare const max: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
23
+ export declare const clamp: (v: Vec2, minVec: Vec2, maxVec: Vec2) => Vec2;
24
+ export declare const mix: ([x1, y1]: Vec2, [x2, y2]: Vec2, t: number) => Vec2;
25
+ export declare const step: ([edge1, edge2]: Vec2, [x, y]: Vec2) => Vec2;
26
+ export declare const smoothstep: ([e0x, e0y]: Vec2, [e1x, e1y]: Vec2, [x, y]: Vec2) => Vec2;
27
+ export declare const length: ([x, y]: Vec2) => number;
28
+ export declare const distance: (a: Vec2, b: Vec2) => number;
29
+ export declare const dot: ([x1, y1]: Vec2, [x2, y2]: Vec2) => number;
30
+ export declare const normalize: (v: Vec2) => Vec2;
31
+ export declare const faceforward: (n: Vec2, i: Vec2, nref: Vec2) => Vec2;
32
+ export declare const reflect: (i: Vec2, n: Vec2) => Vec2;
33
+ export declare const refract: (i: Vec2, n: Vec2, eta: number) => Vec2;
34
+ export declare const sin: ([x, y]: Vec2) => Vec2;
35
+ export declare const cos: ([x, y]: Vec2) => Vec2;
36
+ export declare const tan: ([x, y]: Vec2) => Vec2;
37
+ export declare const asin: ([x, y]: Vec2) => Vec2;
38
+ export declare const acos: ([x, y]: Vec2) => Vec2;
39
+ export declare const atan: ([x, y]: Vec2) => Vec2;
40
+ export declare const sinh: ([x, y]: Vec2) => Vec2;
41
+ export declare const cosh: ([x, y]: Vec2) => Vec2;
42
+ export declare const tanh: ([x, y]: Vec2) => Vec2;
43
+ export declare const asinh: ([x, y]: Vec2) => Vec2;
44
+ export declare const acosh: ([x, y]: Vec2) => Vec2;
45
+ export declare const atanh: ([x, y]: Vec2) => Vec2;
46
+ export declare const sign: ([x, y]: Vec2) => Vec2;
47
+ export declare const fract: ([x, y]: Vec2) => Vec2;
48
+ export declare const mod: ([x, y]: Vec2, m: number) => Vec2;
49
+ export declare const modf: ([x, y]: Vec2) => {
50
+ fract: Vec2;
51
+ whole: Vec2;
52
+ };
53
+ export declare const pow: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
54
+ export declare const exp: ([x, y]: Vec2) => Vec2;
55
+ export declare const exp2: ([x, y]: Vec2) => Vec2;
56
+ export declare const log: ([x, y]: Vec2) => Vec2;
57
+ export declare const log2: ([x, y]: Vec2) => Vec2;
58
+ export declare const sqrt: ([x, y]: Vec2) => Vec2;
59
+ export declare const add: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
60
+ export declare const subtract: ([x1, y1]: Vec2, [x2, y2]: Vec2) => Vec2;
61
+ export declare const scale: ([x, y]: Vec2, s: number) => Vec2;
62
+ export declare const negate: ([x, y]: Vec2) => Vec2;
63
+ export {};
@@ -0,0 +1,114 @@
1
+ /*MIT License
2
+
3
+ © Copyright 2025 Adobe. All rights reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.*/
22
+ import { F32Schema } from "../../schema/index.js";
23
+ import { getStructLayout } from "../../typed-buffer/index.js";
24
+ export const schema = {
25
+ type: 'array',
26
+ items: F32Schema,
27
+ minItems: 2,
28
+ maxItems: 2,
29
+ default: [0, 0],
30
+ };
31
+ export const layout = getStructLayout(schema);
32
+ // Mathematical Operations
33
+ export const abs = ([x, y]) => [Math.abs(x), Math.abs(y)];
34
+ export const ceil = ([x, y]) => [Math.ceil(x), Math.ceil(y)];
35
+ export const floor = ([x, y]) => [Math.floor(x), Math.floor(y)];
36
+ export const round = ([x, y]) => [Math.round(x), Math.round(y)];
37
+ export const trunc = ([x, y]) => [Math.trunc(x), Math.trunc(y)];
38
+ export const min = ([x1, y1], [x2, y2]) => [Math.min(x1, x2), Math.min(y1, y2)];
39
+ export const max = ([x1, y1], [x2, y2]) => [Math.max(x1, x2), Math.max(y1, y2)];
40
+ export const clamp = (v, minVec, maxVec) => min(max(v, minVec), maxVec);
41
+ export const mix = ([x1, y1], [x2, y2], t) => [
42
+ x1 * (1 - t) + x2 * t,
43
+ y1 * (1 - t) + y2 * t
44
+ ];
45
+ export const step = ([edge1, edge2], [x, y]) => [
46
+ x < edge1 ? 0 : 1,
47
+ y < edge2 ? 0 : 1
48
+ ];
49
+ export const smoothstep = ([e0x, e0y], [e1x, e1y], [x, y]) => {
50
+ const tx = Math.max(0, Math.min(1, (x - e0x) / (e1x - e0x)));
51
+ const ty = Math.max(0, Math.min(1, (y - e0y) / (e1y - e0y)));
52
+ return [tx * tx * (3 - 2 * tx), ty * ty * (3 - 2 * ty)];
53
+ };
54
+ // Geometric Functions
55
+ export const length = ([x, y]) => Math.sqrt(x * x + y * y);
56
+ export const distance = (a, b) => length(subtract(b, a));
57
+ export const dot = ([x1, y1], [x2, y2]) => x1 * x2 + y1 * y2;
58
+ export const normalize = (v) => {
59
+ const len = length(v);
60
+ return len === 0 ? [0, 0] : scale(v, 1 / len);
61
+ };
62
+ export const faceforward = (n, i, nref) => dot(nref, i) < 0 ? n : negate(n);
63
+ export const reflect = (i, n) => {
64
+ const dot2 = dot(n, i) * 2;
65
+ return subtract(i, scale(n, dot2));
66
+ };
67
+ export const refract = (i, n, eta) => {
68
+ const dotProduct = dot(n, i);
69
+ const k = 1.0 - eta * eta * (1.0 - dotProduct * dotProduct);
70
+ if (k < 0.0) {
71
+ return [0, 0];
72
+ }
73
+ const scaleFactor = eta * dotProduct + Math.sqrt(k);
74
+ return subtract(scale(i, eta), scale(n, scaleFactor));
75
+ };
76
+ // Trigonometric Functions
77
+ export const sin = ([x, y]) => [Math.sin(x), Math.sin(y)];
78
+ export const cos = ([x, y]) => [Math.cos(x), Math.cos(y)];
79
+ export const tan = ([x, y]) => [Math.tan(x), Math.tan(y)];
80
+ export const asin = ([x, y]) => [Math.asin(x), Math.asin(y)];
81
+ export const acos = ([x, y]) => [Math.acos(x), Math.acos(y)];
82
+ export const atan = ([x, y]) => [Math.atan(x), Math.atan(y)];
83
+ export const sinh = ([x, y]) => [Math.sinh(x), Math.sinh(y)];
84
+ export const cosh = ([x, y]) => [Math.cosh(x), Math.cosh(y)];
85
+ export const tanh = ([x, y]) => [Math.tanh(x), Math.tanh(y)];
86
+ export const asinh = ([x, y]) => [Math.asinh(x), Math.asinh(y)];
87
+ export const acosh = ([x, y]) => [Math.acosh(x), Math.acosh(y)];
88
+ export const atanh = ([x, y]) => [Math.atanh(x), Math.atanh(y)];
89
+ // Common Functions
90
+ export const sign = ([x, y]) => [Math.sign(x), Math.sign(y)];
91
+ export const fract = ([x, y]) => [x - Math.floor(x), y - Math.floor(y)];
92
+ export const mod = ([x, y], m) => [
93
+ ((x % m) + m) % m,
94
+ ((y % m) + m) % m
95
+ ];
96
+ export const modf = ([x, y]) => ({
97
+ whole: [Math.trunc(x), Math.trunc(y)],
98
+ fract: [x - Math.trunc(x), y - Math.trunc(y)]
99
+ });
100
+ export const pow = ([x1, y1], [x2, y2]) => [
101
+ Math.pow(x1, x2),
102
+ Math.pow(y1, y2)
103
+ ];
104
+ export const exp = ([x, y]) => [Math.exp(x), Math.exp(y)];
105
+ export const exp2 = ([x, y]) => [Math.pow(2, x), Math.pow(2, y)];
106
+ export const log = ([x, y]) => [Math.log(x), Math.log(y)];
107
+ export const log2 = ([x, y]) => [Math.log2(x), Math.log2(y)];
108
+ export const sqrt = ([x, y]) => [Math.sqrt(x), Math.sqrt(y)];
109
+ // Helper functions needed by some of the above
110
+ export const add = ([x1, y1], [x2, y2]) => [x1 + x2, y1 + y2];
111
+ export const subtract = ([x1, y1], [x2, y2]) => [x1 - x2, y1 - y2];
112
+ export const scale = ([x, y], s) => [x * s, y * s];
113
+ export const negate = ([x, y]) => [-x, -y];
114
+ //# sourceMappingURL=vec2.js.map