@iwsdk/core 0.1.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 (326) hide show
  1. package/LICENSE +21 -0
  2. package/dist/asset/asset-manager.d.ts +72 -0
  3. package/dist/asset/asset-manager.d.ts.map +1 -0
  4. package/dist/asset/asset-manager.js +138 -0
  5. package/dist/asset/asset-manager.js.map +1 -0
  6. package/dist/asset/cache-manager.d.ts +44 -0
  7. package/dist/asset/cache-manager.d.ts.map +1 -0
  8. package/dist/asset/cache-manager.js +80 -0
  9. package/dist/asset/cache-manager.js.map +1 -0
  10. package/dist/asset/index.d.ts +9 -0
  11. package/dist/asset/index.d.ts.map +1 -0
  12. package/dist/asset/loaders/audio-loader.d.ts +21 -0
  13. package/dist/asset/loaders/audio-loader.d.ts.map +1 -0
  14. package/dist/asset/loaders/audio-loader.js +57 -0
  15. package/dist/asset/loaders/audio-loader.js.map +1 -0
  16. package/dist/asset/loaders/gltf-loader.d.ts +33 -0
  17. package/dist/asset/loaders/gltf-loader.d.ts.map +1 -0
  18. package/dist/asset/loaders/gltf-loader.js +79 -0
  19. package/dist/asset/loaders/gltf-loader.js.map +1 -0
  20. package/dist/asset/loaders/hdr-texture-loader.d.ts +18 -0
  21. package/dist/asset/loaders/hdr-texture-loader.d.ts.map +1 -0
  22. package/dist/asset/loaders/hdr-texture-loader.js +65 -0
  23. package/dist/asset/loaders/hdr-texture-loader.js.map +1 -0
  24. package/dist/asset/loaders/texture-loader.d.ts +21 -0
  25. package/dist/asset/loaders/texture-loader.d.ts.map +1 -0
  26. package/dist/asset/loaders/texture-loader.js +57 -0
  27. package/dist/asset/loaders/texture-loader.js.map +1 -0
  28. package/dist/audio/audio-pool.d.ts +59 -0
  29. package/dist/audio/audio-pool.d.ts.map +1 -0
  30. package/dist/audio/audio-pool.js +105 -0
  31. package/dist/audio/audio-pool.js.map +1 -0
  32. package/dist/audio/audio-system.d.ts +326 -0
  33. package/dist/audio/audio-system.d.ts.map +1 -0
  34. package/dist/audio/audio-system.js +478 -0
  35. package/dist/audio/audio-system.js.map +1 -0
  36. package/dist/audio/audio-utils.d.ts +71 -0
  37. package/dist/audio/audio-utils.d.ts.map +1 -0
  38. package/dist/audio/audio-utils.js +145 -0
  39. package/dist/audio/audio-utils.js.map +1 -0
  40. package/dist/audio/audio.d.ts +178 -0
  41. package/dist/audio/audio.d.ts.map +1 -0
  42. package/dist/audio/audio.js +104 -0
  43. package/dist/audio/audio.js.map +1 -0
  44. package/dist/audio/index.d.ts +11 -0
  45. package/dist/audio/index.d.ts.map +1 -0
  46. package/dist/ecs/component-registry.d.ts +54 -0
  47. package/dist/ecs/component-registry.d.ts.map +1 -0
  48. package/dist/ecs/component-registry.js +86 -0
  49. package/dist/ecs/component-registry.js.map +1 -0
  50. package/dist/ecs/component.d.ts +12 -0
  51. package/dist/ecs/component.d.ts.map +1 -0
  52. package/dist/ecs/entity.d.ts +17 -0
  53. package/dist/ecs/entity.d.ts.map +1 -0
  54. package/dist/ecs/entity.js +13 -0
  55. package/dist/ecs/entity.js.map +1 -0
  56. package/dist/ecs/index.d.ts +12 -0
  57. package/dist/ecs/index.d.ts.map +1 -0
  58. package/dist/ecs/system.d.ts +70 -0
  59. package/dist/ecs/system.d.ts.map +1 -0
  60. package/dist/ecs/system.js +79 -0
  61. package/dist/ecs/system.js.map +1 -0
  62. package/dist/ecs/world.d.ts +101 -0
  63. package/dist/ecs/world.d.ts.map +1 -0
  64. package/dist/ecs/world.js +165 -0
  65. package/dist/ecs/world.js.map +1 -0
  66. package/dist/environment/dome-gradient.d.ts +39 -0
  67. package/dist/environment/dome-gradient.d.ts.map +1 -0
  68. package/dist/environment/dome-gradient.js +30 -0
  69. package/dist/environment/dome-gradient.js.map +1 -0
  70. package/dist/environment/dome-texture.d.ts +39 -0
  71. package/dist/environment/dome-texture.d.ts.map +1 -0
  72. package/dist/environment/dome-texture.js +30 -0
  73. package/dist/environment/dome-texture.js.map +1 -0
  74. package/dist/environment/environment-system.d.ts +82 -0
  75. package/dist/environment/environment-system.d.ts.map +1 -0
  76. package/dist/environment/environment-system.js +389 -0
  77. package/dist/environment/environment-system.js.map +1 -0
  78. package/dist/environment/gradient-environment.d.ts +37 -0
  79. package/dist/environment/gradient-environment.d.ts.map +1 -0
  80. package/dist/environment/gradient-environment.js +99 -0
  81. package/dist/environment/gradient-environment.js.map +1 -0
  82. package/dist/environment/ibl-gradient.d.ts +38 -0
  83. package/dist/environment/ibl-gradient.d.ts.map +1 -0
  84. package/dist/environment/ibl-gradient.js +29 -0
  85. package/dist/environment/ibl-gradient.js.map +1 -0
  86. package/dist/environment/ibl-texture.d.ts +36 -0
  87. package/dist/environment/ibl-texture.d.ts.map +1 -0
  88. package/dist/environment/ibl-texture.js +30 -0
  89. package/dist/environment/ibl-texture.js.map +1 -0
  90. package/dist/environment/index.d.ts +12 -0
  91. package/dist/environment/index.d.ts.map +1 -0
  92. package/dist/grab/distance-grabbable.d.ts +115 -0
  93. package/dist/grab/distance-grabbable.d.ts.map +1 -0
  94. package/dist/grab/distance-grabbable.js +102 -0
  95. package/dist/grab/distance-grabbable.js.map +1 -0
  96. package/dist/grab/grab-system.d.ts +320 -0
  97. package/dist/grab/grab-system.d.ts.map +1 -0
  98. package/dist/grab/grab-system.js +239 -0
  99. package/dist/grab/grab-system.js.map +1 -0
  100. package/dist/grab/handles.d.ts +43 -0
  101. package/dist/grab/handles.d.ts.map +1 -0
  102. package/dist/grab/handles.js +132 -0
  103. package/dist/grab/handles.js.map +1 -0
  104. package/dist/grab/index.d.ts +13 -0
  105. package/dist/grab/index.d.ts.map +1 -0
  106. package/dist/grab/index.js +23 -0
  107. package/dist/grab/index.js.map +1 -0
  108. package/dist/grab/one-hand-grabbable.d.ts +80 -0
  109. package/dist/grab/one-hand-grabbable.d.ts.map +1 -0
  110. package/dist/grab/one-hand-grabbable.js +80 -0
  111. package/dist/grab/one-hand-grabbable.js.map +1 -0
  112. package/dist/grab/pointer-events-patch.d.ts +16 -0
  113. package/dist/grab/pointer-events-patch.d.ts.map +1 -0
  114. package/dist/grab/pointer-events-patch.js +223 -0
  115. package/dist/grab/pointer-events-patch.js.map +1 -0
  116. package/dist/grab/two-hands-grabbable.d.ts +103 -0
  117. package/dist/grab/two-hands-grabbable.d.ts.map +1 -0
  118. package/dist/grab/two-hands-grabbable.js +100 -0
  119. package/dist/grab/two-hands-grabbable.js.map +1 -0
  120. package/dist/index.d.ts +27 -0
  121. package/dist/index.d.ts.map +1 -0
  122. package/dist/index.js +82 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/init/index.d.ts +9 -0
  125. package/dist/init/index.d.ts.map +1 -0
  126. package/dist/init/world-initializer.d.ts +76 -0
  127. package/dist/init/world-initializer.d.ts.map +1 -0
  128. package/dist/init/world-initializer.js +403 -0
  129. package/dist/init/world-initializer.js.map +1 -0
  130. package/dist/init/xr.d.ts +87 -0
  131. package/dist/init/xr.d.ts.map +1 -0
  132. package/dist/init/xr.js +193 -0
  133. package/dist/init/xr.js.map +1 -0
  134. package/dist/input/index.d.ts +9 -0
  135. package/dist/input/index.d.ts.map +1 -0
  136. package/dist/input/input-system.d.ts +52 -0
  137. package/dist/input/input-system.d.ts.map +1 -0
  138. package/dist/input/input-system.js +176 -0
  139. package/dist/input/input-system.js.map +1 -0
  140. package/dist/input/state-tags.d.ts +56 -0
  141. package/dist/input/state-tags.d.ts.map +1 -0
  142. package/dist/input/state-tags.js +63 -0
  143. package/dist/input/state-tags.js.map +1 -0
  144. package/dist/level/index.d.ts +12 -0
  145. package/dist/level/index.d.ts.map +1 -0
  146. package/dist/level/level-entity-creator.d.ts +27 -0
  147. package/dist/level/level-entity-creator.d.ts.map +1 -0
  148. package/dist/level/level-entity-creator.js +110 -0
  149. package/dist/level/level-entity-creator.js.map +1 -0
  150. package/dist/level/level-glxf-importer.d.ts +22 -0
  151. package/dist/level/level-glxf-importer.d.ts.map +1 -0
  152. package/dist/level/level-glxf-importer.js +40 -0
  153. package/dist/level/level-glxf-importer.js.map +1 -0
  154. package/dist/level/level-root.d.ts +18 -0
  155. package/dist/level/level-root.d.ts.map +1 -0
  156. package/dist/level/level-root.js +25 -0
  157. package/dist/level/level-root.js.map +1 -0
  158. package/dist/level/level-system.d.ts +54 -0
  159. package/dist/level/level-system.d.ts.map +1 -0
  160. package/dist/level/level-system.js +134 -0
  161. package/dist/level/level-system.js.map +1 -0
  162. package/dist/level/level-tag.d.ts +25 -0
  163. package/dist/level/level-tag.d.ts.map +1 -0
  164. package/dist/level/level-tag.js +28 -0
  165. package/dist/level/level-tag.js.map +1 -0
  166. package/dist/locomotion/geometries/beveled-cylinder.d.ts +12 -0
  167. package/dist/locomotion/geometries/beveled-cylinder.d.ts.map +1 -0
  168. package/dist/locomotion/geometries/beveled-cylinder.js +64 -0
  169. package/dist/locomotion/geometries/beveled-cylinder.js.map +1 -0
  170. package/dist/locomotion/index.d.ts +11 -0
  171. package/dist/locomotion/index.d.ts.map +1 -0
  172. package/dist/locomotion/locomotion.d.ts +239 -0
  173. package/dist/locomotion/locomotion.d.ts.map +1 -0
  174. package/dist/locomotion/locomotion.js +256 -0
  175. package/dist/locomotion/locomotion.js.map +1 -0
  176. package/dist/locomotion/materials/line.d.ts +24 -0
  177. package/dist/locomotion/materials/line.d.ts.map +1 -0
  178. package/dist/locomotion/materials/line.js +307 -0
  179. package/dist/locomotion/materials/line.js.map +1 -0
  180. package/dist/locomotion/slide.d.ts +76 -0
  181. package/dist/locomotion/slide.d.ts.map +1 -0
  182. package/dist/locomotion/slide.js +131 -0
  183. package/dist/locomotion/slide.js.map +1 -0
  184. package/dist/locomotion/teleport.d.ts +68 -0
  185. package/dist/locomotion/teleport.d.ts.map +1 -0
  186. package/dist/locomotion/teleport.js +150 -0
  187. package/dist/locomotion/teleport.js.map +1 -0
  188. package/dist/locomotion/turn.d.ts +77 -0
  189. package/dist/locomotion/turn.d.ts.map +1 -0
  190. package/dist/locomotion/turn.js +126 -0
  191. package/dist/locomotion/turn.js.map +1 -0
  192. package/dist/node_modules/.pnpm/@pmndrs_uikitml@0.0.10_@pmndrs_uikit@1.0.32_super-three@0.177.0_/node_modules/@pmndrs/uikitml/dist/index.js +13 -0
  193. package/dist/node_modules/.pnpm/@pmndrs_uikitml@0.0.10_@pmndrs_uikit@1.0.32_super-three@0.177.0_/node_modules/@pmndrs/uikitml/dist/index.js.map +1 -0
  194. package/dist/node_modules/.pnpm/@pmndrs_uikitml@0.0.10_@pmndrs_uikit@1.0.32_super-three@0.177.0_/node_modules/@pmndrs/uikitml/dist/interpreter/index.js +154 -0
  195. package/dist/node_modules/.pnpm/@pmndrs_uikitml@0.0.10_@pmndrs_uikit@1.0.32_super-three@0.177.0_/node_modules/@pmndrs/uikitml/dist/interpreter/index.js.map +1 -0
  196. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/error-codes.js +66 -0
  197. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/error-codes.js.map +1 -0
  198. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/foreign-content.js +162 -0
  199. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/foreign-content.js.map +1 -0
  200. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/html.js +519 -0
  201. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/html.js.map +1 -0
  202. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/token.js +15 -0
  203. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/token.js.map +1 -0
  204. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/unicode.js +32 -0
  205. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/common/unicode.js.map +1 -0
  206. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/formatting-element-list.js +10 -0
  207. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/formatting-element-list.js.map +1 -0
  208. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/index.js +41 -0
  209. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/index.js.map +1 -0
  210. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/open-element-stack.js +35 -0
  211. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/parser/open-element-stack.js.map +1 -0
  212. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/serializer/index.js +24 -0
  213. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/serializer/index.js.map +1 -0
  214. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/index.js +92 -0
  215. package/dist/node_modules/.pnpm/parse5@7.3.0/node_modules/parse5/dist/tokenizer/index.js.map +1 -0
  216. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/libs/fflate.module.js +382 -0
  217. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/libs/fflate.module.js.map +1 -0
  218. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/loaders/EXRLoader.js +2587 -0
  219. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/loaders/EXRLoader.js.map +1 -0
  220. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/loaders/RGBELoader.js +477 -0
  221. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/examples/jsm/loaders/RGBELoader.js.map +1 -0
  222. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/src/math/MathUtils.js +17 -0
  223. package/dist/node_modules/.pnpm/super-three@0.177.0/node_modules/super-three/src/math/MathUtils.js.map +1 -0
  224. package/dist/physics/index.d.ts +11 -0
  225. package/dist/physics/index.d.ts.map +1 -0
  226. package/dist/physics/physics-system.d.ts +314 -0
  227. package/dist/physics/physics-system.d.ts.map +1 -0
  228. package/dist/physics/physics-system.js +419 -0
  229. package/dist/physics/physics-system.js.map +1 -0
  230. package/dist/physics/physicsBody.d.ts +83 -0
  231. package/dist/physics/physicsBody.d.ts.map +1 -0
  232. package/dist/physics/physicsBody.js +60 -0
  233. package/dist/physics/physicsBody.js.map +1 -0
  234. package/dist/physics/physicsManipulation.d.ts +51 -0
  235. package/dist/physics/physicsManipulation.d.ts.map +1 -0
  236. package/dist/physics/physicsManipulation.js +46 -0
  237. package/dist/physics/physicsManipulation.js.map +1 -0
  238. package/dist/physics/physicsShape.d.ts +133 -0
  239. package/dist/physics/physicsShape.d.ts.map +1 -0
  240. package/dist/physics/physicsShape.js +97 -0
  241. package/dist/physics/physicsShape.js.map +1 -0
  242. package/dist/physics/utils.d.ts +21 -0
  243. package/dist/physics/utils.d.ts.map +1 -0
  244. package/dist/physics/utils.js +130 -0
  245. package/dist/physics/utils.js.map +1 -0
  246. package/dist/runtime/index.d.ts +8 -0
  247. package/dist/runtime/index.d.ts.map +1 -0
  248. package/dist/runtime/three.d.ts +8 -0
  249. package/dist/runtime/three.d.ts.map +1 -0
  250. package/dist/runtime/three.js +18 -0
  251. package/dist/runtime/three.js.map +1 -0
  252. package/dist/scene-understanding/anchor.d.ts +42 -0
  253. package/dist/scene-understanding/anchor.d.ts.map +1 -0
  254. package/dist/scene-understanding/anchor.js +45 -0
  255. package/dist/scene-understanding/anchor.js.map +1 -0
  256. package/dist/scene-understanding/index.d.ts +11 -0
  257. package/dist/scene-understanding/index.d.ts.map +1 -0
  258. package/dist/scene-understanding/mesh.d.ts +67 -0
  259. package/dist/scene-understanding/mesh.d.ts.map +1 -0
  260. package/dist/scene-understanding/mesh.js +55 -0
  261. package/dist/scene-understanding/mesh.js.map +1 -0
  262. package/dist/scene-understanding/plane.d.ts +39 -0
  263. package/dist/scene-understanding/plane.d.ts.map +1 -0
  264. package/dist/scene-understanding/plane.js +42 -0
  265. package/dist/scene-understanding/plane.js.map +1 -0
  266. package/dist/scene-understanding/scene-understanding-system.d.ts +180 -0
  267. package/dist/scene-understanding/scene-understanding-system.d.ts.map +1 -0
  268. package/dist/scene-understanding/scene-understanding-system.js +342 -0
  269. package/dist/scene-understanding/scene-understanding-system.js.map +1 -0
  270. package/dist/transform/index.d.ts +10 -0
  271. package/dist/transform/index.d.ts.map +1 -0
  272. package/dist/transform/synced-quaternion.d.ts +35 -0
  273. package/dist/transform/synced-quaternion.d.ts.map +1 -0
  274. package/dist/transform/synced-quaternion.js +128 -0
  275. package/dist/transform/synced-quaternion.js.map +1 -0
  276. package/dist/transform/synced-vector3.d.ts +34 -0
  277. package/dist/transform/synced-vector3.d.ts.map +1 -0
  278. package/dist/transform/synced-vector3.js +106 -0
  279. package/dist/transform/synced-vector3.js.map +1 -0
  280. package/dist/transform/transform.d.ts +100 -0
  281. package/dist/transform/transform.d.ts.map +1 -0
  282. package/dist/transform/transform.js +194 -0
  283. package/dist/transform/transform.js.map +1 -0
  284. package/dist/types/webxr-augmentations.d.ts +23 -0
  285. package/dist/types/webxr-augmentations.d.ts.map +1 -0
  286. package/dist/ui/document.d.ts +112 -0
  287. package/dist/ui/document.d.ts.map +1 -0
  288. package/dist/ui/document.js +298 -0
  289. package/dist/ui/document.js.map +1 -0
  290. package/dist/ui/follow.d.ts +197 -0
  291. package/dist/ui/follow.d.ts.map +1 -0
  292. package/dist/ui/follow.js +143 -0
  293. package/dist/ui/follow.js.map +1 -0
  294. package/dist/ui/index.d.ts +18 -0
  295. package/dist/ui/index.d.ts.map +1 -0
  296. package/dist/ui/screenspace.d.ts +219 -0
  297. package/dist/ui/screenspace.d.ts.map +1 -0
  298. package/dist/ui/screenspace.js +215 -0
  299. package/dist/ui/screenspace.js.map +1 -0
  300. package/dist/ui/ui.d.ts +209 -0
  301. package/dist/ui/ui.d.ts.map +1 -0
  302. package/dist/ui/ui.js +185 -0
  303. package/dist/ui/ui.js.map +1 -0
  304. package/dist/vendor/basis/README.md +46 -0
  305. package/dist/vendor/basis/basis_transcoder.js +19 -0
  306. package/dist/vendor/basis/basis_transcoder.wasm +0 -0
  307. package/dist/vendor/draco/README.md +32 -0
  308. package/dist/vendor/draco/draco_decoder.js +34 -0
  309. package/dist/vendor/draco/draco_decoder.wasm +0 -0
  310. package/dist/vendor/draco/draco_encoder.js +33 -0
  311. package/dist/vendor/draco/draco_wasm_wrapper.js +117 -0
  312. package/dist/vendor/draco/gltf/draco_decoder.js +33 -0
  313. package/dist/vendor/draco/gltf/draco_decoder.wasm +0 -0
  314. package/dist/vendor/draco/gltf/draco_encoder.js +33 -0
  315. package/dist/vendor/draco/gltf/draco_wasm_wrapper.js +116 -0
  316. package/dist/version.d.ts +2 -0
  317. package/dist/version.d.ts.map +1 -0
  318. package/dist/version.js +4 -0
  319. package/dist/version.js.map +1 -0
  320. package/dist/visibility/index.d.ts +8 -0
  321. package/dist/visibility/index.d.ts.map +1 -0
  322. package/dist/visibility/visibility.d.ts +37 -0
  323. package/dist/visibility/visibility.d.ts.map +1 -0
  324. package/dist/visibility/visibility.js +52 -0
  325. package/dist/visibility/visibility.js.map +1 -0
  326. package/package.json +46 -0
@@ -0,0 +1,46 @@
1
+ import '../index.js';
2
+ import { createComponent, Types } from 'elics';
3
+
4
+ /**
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ /**
11
+ * Component for applying one‑time physics manipulations to an entity.
12
+ *
13
+ * @remarks
14
+ * - This component is automatically removed after the manipulations are applied.
15
+ * - Force is applied as an impulse at the entity's center of mass.
16
+ * - Setting linear or angular velocity overrides the current velocity.
17
+ * - All manipulations are applied in a single frame, then the component is removed.
18
+ * - Requires the entity to have {@link PhysicsBody}.
19
+ *
20
+ * @example Apply an upward force to make an object jump
21
+ * ```ts
22
+ * entity.addComponent(PhysicsManipulation, {
23
+ * force: [0, 10, 0]
24
+ * })
25
+ * ```
26
+ *
27
+ * @example Set specific velocity for controlled movement
28
+ * ```ts
29
+ * entity.addComponent(PhysicsManipulation, {
30
+ * linearVelocity: [5, 0, 0],
31
+ * angularVelocity: [0, 2, 0]
32
+ * })
33
+ * ```
34
+ *
35
+ * @category Physics
36
+ * @see {@link PhysicsSystem}
37
+ * @see {@link PhysicsBody}
38
+ */
39
+ const PhysicsManipulation = createComponent('PhysicsManipulation', {
40
+ force: { type: Types.Vec3, default: [0.0, 0.0, 0.0] },
41
+ linearVelocity: { type: Types.Vec3, default: [0.0, 0.0, 0.0] },
42
+ angularVelocity: { type: Types.Vec3, default: [0.0, 0.0, 0.0] },
43
+ }, 'Component to apply physics manipulations to an entity.');
44
+
45
+ export { PhysicsManipulation };
46
+ //# sourceMappingURL=physicsManipulation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsManipulation.js","sources":["../../src/physics/physicsManipulation.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BG;AAEI,MAAM,mBAAmB,GAAG,eAAe,CAChD,qBAAqB,EACrB;AACE,IAAA,KAAK,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;AACrD,IAAA,cAAc,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;AAC9D,IAAA,eAAe,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;CAChE,EACD,wDAAwD;;;;"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Types } from '.././index.js';
8
+ /** Available physics shape types for {@link PhysicsShape}. @category Physics */
9
+ export declare const PhysicsShapeType: {
10
+ /** The sphere is described by just the radius in dimensions[0]. Efficient for round objects. */
11
+ readonly Sphere: "Sphere";
12
+ /** A box shape is described by the `dimensions` as [width, height, depth]. Good for rectangular objects. */
13
+ readonly Box: "Box";
14
+ /** A cylinder shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
15
+ readonly Cylinder: "Cylinder";
16
+ /** Capsules are similar to cylinders, but have two half-spheres on each end.
17
+ * A Capsules shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
18
+ readonly Capsules: "Capsules";
19
+ /** A convex is a shape that, if two points are part of the shape, then the segment between these two points is
20
+ * also part of the shape. The physics engine would creates a convex wrapper around the mesh. This is a great
21
+ * approximation for most objects since it's more accurate than primitives and much more efficient than TriMesh. */
22
+ readonly ConvexHull: "ConvexHull";
23
+ /** Uses exact mesh geometry in the physics engine. This will give the closest match to your render geometry but
24
+ * may cause expensive compute load when two complex mesh shapes collide with each other. Typically used for static objects. */
25
+ readonly TriMesh: "TriMesh";
26
+ /** Automatically detects the best shape from the entity's Three.js geometry. The shape type mapping is
27
+ * SphereGeometry -> PhysicsShapeType.Sphere,
28
+ * BoxGeometry | PlaneGeometry -> PhysicsShapeType.Box,
29
+ * CylinderGeometry -> PhysicsShapeType.Cylinder,
30
+ * default -> PhysicsShapeType.ConvexHull,
31
+ * When this type is selected, the dimensions field in PhysicsShape will be overridden by the size of the Three.js geometry.
32
+ */
33
+ readonly Auto: "Auto";
34
+ };
35
+ export declare const DEFAULT_DENSITY = 1;
36
+ export declare const DEFAULT_RESTITUTION = 0;
37
+ export declare const DEFAULT_FRICTION = 0.5;
38
+ /**
39
+ * Component for defining the collision shape and material properties of a physics entity.
40
+ *
41
+ * @remarks
42
+ * - Material properties (density, restitution, friction) affect physics behavior.
43
+ * - Higher density increases mass, affecting how the object responds to forces.
44
+ *
45
+ * @example Auto‑detect shape from geometry
46
+ * ```ts
47
+ * entity.addComponent(PhysicsShape, {
48
+ * shape: PhysicsShapeType.Auto
49
+ * })
50
+ * ```
51
+ *
52
+ * @example Create a bouncy sphere
53
+ * ```ts
54
+ * entity.addComponent(PhysicsShape, {
55
+ * shape: PhysicsShapeType.Sphere,
56
+ * dimensions: [0.5, 0, 0], // radius = 0.5
57
+ * restitution: 0.8, // bouncy
58
+ * friction: 0.1 // low friction
59
+ * })
60
+ * ```
61
+ *
62
+ * @example Create a heavy box
63
+ * ```ts
64
+ * entity.addComponent(PhysicsShape, {
65
+ * shape: PhysicsShapeType.Box,
66
+ * dimensions: [2, 1, 1], // 2x1x1 meters
67
+ * density: 5.0, // high density
68
+ * friction: 0.9 // high friction
69
+ * })
70
+ * ```
71
+ *
72
+ * @category Physics
73
+ * @see {@link PhysicsSystem}
74
+ * @see {@link PhysicsBody}
75
+ */
76
+ export declare const PhysicsShape: import("elics").Component<{
77
+ /** The type of the shape defined in the Physics engine. {@link PhysicsShapeType} */
78
+ shape: {
79
+ type: Types.Enum;
80
+ enum: {
81
+ /** The sphere is described by just the radius in dimensions[0]. Efficient for round objects. */
82
+ readonly Sphere: "Sphere";
83
+ /** A box shape is described by the `dimensions` as [width, height, depth]. Good for rectangular objects. */
84
+ readonly Box: "Box";
85
+ /** A cylinder shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
86
+ readonly Cylinder: "Cylinder";
87
+ /** Capsules are similar to cylinders, but have two half-spheres on each end.
88
+ * A Capsules shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
89
+ readonly Capsules: "Capsules";
90
+ /** A convex is a shape that, if two points are part of the shape, then the segment between these two points is
91
+ * also part of the shape. The physics engine would creates a convex wrapper around the mesh. This is a great
92
+ * approximation for most objects since it's more accurate than primitives and much more efficient than TriMesh. */
93
+ readonly ConvexHull: "ConvexHull";
94
+ /** Uses exact mesh geometry in the physics engine. This will give the closest match to your render geometry but
95
+ * may cause expensive compute load when two complex mesh shapes collide with each other. Typically used for static objects. */
96
+ readonly TriMesh: "TriMesh";
97
+ /** Automatically detects the best shape from the entity's Three.js geometry. The shape type mapping is
98
+ * SphereGeometry -> PhysicsShapeType.Sphere,
99
+ * BoxGeometry | PlaneGeometry -> PhysicsShapeType.Box,
100
+ * CylinderGeometry -> PhysicsShapeType.Cylinder,
101
+ * default -> PhysicsShapeType.ConvexHull,
102
+ * When this type is selected, the dimensions field in PhysicsShape will be overridden by the size of the Three.js geometry.
103
+ */
104
+ readonly Auto: "Auto";
105
+ };
106
+ default: "Auto";
107
+ };
108
+ /** The dimension of the physics shape. The definition of it is based on the selection of {@link PhysicsShapeType}. */
109
+ dimensions: {
110
+ type: Types.Vec3;
111
+ default: [number, number, number];
112
+ };
113
+ /** The density of the physics shape. It is used to calculate the mass. */
114
+ density: {
115
+ type: Types.Float32;
116
+ default: number;
117
+ };
118
+ /** Restitution controls bounciness (0 = no bounce, 1 = perfect bounce). */
119
+ restitution: {
120
+ type: Types.Float32;
121
+ default: number;
122
+ };
123
+ /** Friction to define the sliding behavior on surfaces. */
124
+ friction: {
125
+ type: Types.Float32;
126
+ default: number;
127
+ };
128
+ _engineShape: {
129
+ type: Types.Float64;
130
+ default: number;
131
+ };
132
+ }>;
133
+ //# sourceMappingURL=physicsShape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsShape.d.ts","sourceRoot":"","sources":["../../src/physics/physicsShape.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAmB,MAAM,eAAe,CAAC;AAEvD,gFAAgF;AAChF,eAAO,MAAM,gBAAgB;IAC3B,gGAAgG;;IAEhG,4GAA4G;;IAE5G,8FAA8F;;IAE9F;iGAC6F;;IAE7F;;uHAEmH;;IAEnH;mIAC+H;;IAE/H;;;;;;OAMG;;CAEK,CAAC;AAEX,eAAO,MAAM,eAAe,IAAM,CAAC;AACnC,eAAO,MAAM,mBAAmB,IAAM,CAAC;AACvC,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,YAAY;IAGrB,oFAAoF;;;;YAvEtF,gGAAgG;;YAEhG,4GAA4G;;YAE5G,8FAA8F;;YAE9F;yGAC6F;;YAE7F;;+HAEmH;;YAEnH;2IAC+H;;YAE/H;;;;;;eAMG;;;;;IAuDD,sHAAsH;;;;;IAEtH,0EAA0E;;;;;IAE1E,2EAA2E;;;;;IAE3E,2DAA2D;;;;;;;;;EAK9D,CAAC"}
@@ -0,0 +1,97 @@
1
+ import '../index.js';
2
+ import { createComponent, Types } from 'elics';
3
+
4
+ /**
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+ /** Available physics shape types for {@link PhysicsShape}. @category Physics */
11
+ const PhysicsShapeType = {
12
+ /** The sphere is described by just the radius in dimensions[0]. Efficient for round objects. */
13
+ Sphere: 'Sphere',
14
+ /** A box shape is described by the `dimensions` as [width, height, depth]. Good for rectangular objects. */
15
+ Box: 'Box',
16
+ /** A cylinder shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
17
+ Cylinder: 'Cylinder',
18
+ /** Capsules are similar to cylinders, but have two half-spheres on each end.
19
+ * A Capsules shape is defined by the radius in dimensions[0] and height in dimensions[1]. */
20
+ Capsules: 'Capsules',
21
+ /** A convex is a shape that, if two points are part of the shape, then the segment between these two points is
22
+ * also part of the shape. The physics engine would creates a convex wrapper around the mesh. This is a great
23
+ * approximation for most objects since it's more accurate than primitives and much more efficient than TriMesh. */
24
+ ConvexHull: 'ConvexHull',
25
+ /** Uses exact mesh geometry in the physics engine. This will give the closest match to your render geometry but
26
+ * may cause expensive compute load when two complex mesh shapes collide with each other. Typically used for static objects. */
27
+ TriMesh: 'TriMesh',
28
+ /** Automatically detects the best shape from the entity's Three.js geometry. The shape type mapping is
29
+ * SphereGeometry -> PhysicsShapeType.Sphere,
30
+ * BoxGeometry | PlaneGeometry -> PhysicsShapeType.Box,
31
+ * CylinderGeometry -> PhysicsShapeType.Cylinder,
32
+ * default -> PhysicsShapeType.ConvexHull,
33
+ * When this type is selected, the dimensions field in PhysicsShape will be overridden by the size of the Three.js geometry.
34
+ */
35
+ Auto: 'Auto',
36
+ };
37
+ const DEFAULT_DENSITY = 1.0;
38
+ const DEFAULT_RESTITUTION = 0.0;
39
+ const DEFAULT_FRICTION = 0.5;
40
+ /**
41
+ * Component for defining the collision shape and material properties of a physics entity.
42
+ *
43
+ * @remarks
44
+ * - Material properties (density, restitution, friction) affect physics behavior.
45
+ * - Higher density increases mass, affecting how the object responds to forces.
46
+ *
47
+ * @example Auto‑detect shape from geometry
48
+ * ```ts
49
+ * entity.addComponent(PhysicsShape, {
50
+ * shape: PhysicsShapeType.Auto
51
+ * })
52
+ * ```
53
+ *
54
+ * @example Create a bouncy sphere
55
+ * ```ts
56
+ * entity.addComponent(PhysicsShape, {
57
+ * shape: PhysicsShapeType.Sphere,
58
+ * dimensions: [0.5, 0, 0], // radius = 0.5
59
+ * restitution: 0.8, // bouncy
60
+ * friction: 0.1 // low friction
61
+ * })
62
+ * ```
63
+ *
64
+ * @example Create a heavy box
65
+ * ```ts
66
+ * entity.addComponent(PhysicsShape, {
67
+ * shape: PhysicsShapeType.Box,
68
+ * dimensions: [2, 1, 1], // 2x1x1 meters
69
+ * density: 5.0, // high density
70
+ * friction: 0.9 // high friction
71
+ * })
72
+ * ```
73
+ *
74
+ * @category Physics
75
+ * @see {@link PhysicsSystem}
76
+ * @see {@link PhysicsBody}
77
+ */
78
+ const PhysicsShape = createComponent('PhysicsShape', {
79
+ /** The type of the shape defined in the Physics engine. {@link PhysicsShapeType} */
80
+ shape: {
81
+ type: Types.Enum,
82
+ enum: PhysicsShapeType,
83
+ default: PhysicsShapeType.Auto,
84
+ },
85
+ /** The dimension of the physics shape. The definition of it is based on the selection of {@link PhysicsShapeType}. */
86
+ dimensions: { type: Types.Vec3, default: [0.0, 0.0, 0.0] },
87
+ /** The density of the physics shape. It is used to calculate the mass. */
88
+ density: { type: Types.Float32, default: 1.0 },
89
+ /** Restitution controls bounciness (0 = no bounce, 1 = perfect bounce). */
90
+ restitution: { type: Types.Float32, default: 0.0 },
91
+ /** Friction to define the sliding behavior on surfaces. */
92
+ friction: { type: Types.Float32, default: 0.5 },
93
+ _engineShape: { type: Types.Float64, default: 0 },
94
+ }, 'Component to define physics shape of an entity.');
95
+
96
+ export { DEFAULT_DENSITY, DEFAULT_FRICTION, DEFAULT_RESTITUTION, PhysicsShape, PhysicsShapeType };
97
+ //# sourceMappingURL=physicsShape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"physicsShape.js","sources":["../../src/physics/physicsShape.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;;;;;AAKG;AAIH;AACO,MAAM,gBAAgB,GAAG;;AAE9B,IAAA,MAAM,EAAE,QAAQ;;AAEhB,IAAA,GAAG,EAAE,KAAK;;AAEV,IAAA,QAAQ,EAAE,UAAU;AACpB;AAC6F;AAC7F,IAAA,QAAQ,EAAE,UAAU;AACpB;;AAEmH;AACnH,IAAA,UAAU,EAAE,YAAY;AACxB;AAC+H;AAC/H,IAAA,OAAO,EAAE,SAAS;AAClB;;;;;;AAMG;AACH,IAAA,IAAI,EAAE,MAAM;;AAGP,MAAM,eAAe,GAAG;AACxB,MAAM,mBAAmB,GAAG;AAC5B,MAAM,gBAAgB,GAAG;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCG;AACI,MAAM,YAAY,GAAG,eAAe,CACzC,cAAc,EACd;;AAEE,IAAA,KAAK,EAAE;QACL,IAAI,EAAE,KAAK,CAAC,IAAI;AAChB,QAAA,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,gBAAgB,CAAC,IAAI;AAC/B,KAAA;;AAED,IAAA,UAAU,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE;;IAE1D,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;;IAE9C,WAAW,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;;IAElD,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE;IAC/C,YAAY,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE;CAClD,EACD,iDAAiD;;;;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { BufferGeometry, Object3D } from '../runtime/index.js';
8
+ export interface ShapeDetectionResult {
9
+ shapeType: string;
10
+ dimensions: [number, number, number] | null;
11
+ }
12
+ /**
13
+ * Automatically detects the best physics shape type and calculates dimensions based on the entity's Three.js geometry
14
+ */
15
+ export declare function detectShapeFromGeometry(object3D: Object3D): ShapeDetectionResult;
16
+ /**
17
+ * Calculates bounding box dimensions from Object3D for fallback cases
18
+ */
19
+ export declare function calculateObject3DBounds(object3D: Object3D): [number, number, number];
20
+ export declare function generateMergedGeometry(object3D: Object3D): BufferGeometry;
21
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/physics/utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAOL,cAAc,EAEd,QAAQ,EAGT,MAAM,qBAAqB,CAAC;AAY7B,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;CAC7C;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,GACjB,oBAAoB,CAsEtB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,GACjB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CA+B1B;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAuBzE"}
@@ -0,0 +1,130 @@
1
+ import '../runtime/three.js';
2
+ import { PhysicsShapeType } from './physicsShape.js';
3
+ import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
4
+ import { Vector3, Quaternion, Matrix4, Mesh, SphereGeometry, BoxGeometry, PlaneGeometry, CylinderGeometry, BufferGeometry, Box3 } from 'three';
5
+
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ const tempVec1 = new Vector3();
13
+ const tempVec2 = new Vector3();
14
+ const tempQuat = new Quaternion();
15
+ const tempMatrix = new Matrix4();
16
+ const tempMatrix2 = new Matrix4();
17
+ const UNIT_SCALE = new Vector3(1, 1, 1);
18
+ /**
19
+ * Automatically detects the best physics shape type and calculates dimensions based on the entity's Three.js geometry
20
+ */
21
+ function detectShapeFromGeometry(object3D) {
22
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
23
+ const geometry = object3D instanceof Mesh
24
+ ? object3D.geometry
25
+ : generateMergedGeometry(object3D);
26
+ // Check for specific geometry types and calculate their dimensions
27
+ if (geometry instanceof SphereGeometry) {
28
+ const radius = (_a = geometry.parameters.radius) !== null && _a !== void 0 ? _a : 1;
29
+ return {
30
+ shapeType: PhysicsShapeType.Sphere,
31
+ dimensions: [radius, 0, 0], // Only radius is needed for sphere
32
+ };
33
+ }
34
+ if (geometry instanceof BoxGeometry) {
35
+ const width = (_b = geometry.parameters.width) !== null && _b !== void 0 ? _b : 1;
36
+ const height = (_c = geometry.parameters.height) !== null && _c !== void 0 ? _c : 1;
37
+ const depth = (_d = geometry.parameters.depth) !== null && _d !== void 0 ? _d : 1;
38
+ return {
39
+ shapeType: PhysicsShapeType.Box,
40
+ dimensions: [width, height, depth],
41
+ };
42
+ }
43
+ if (geometry instanceof PlaneGeometry) {
44
+ const width = (_e = geometry.parameters.width) !== null && _e !== void 0 ? _e : 1;
45
+ const height = (_f = geometry.parameters.height) !== null && _f !== void 0 ? _f : 1;
46
+ const thickness = 0.01; // Thin plane
47
+ return {
48
+ shapeType: PhysicsShapeType.Box,
49
+ dimensions: [width, height, thickness],
50
+ };
51
+ }
52
+ if (geometry instanceof CylinderGeometry) {
53
+ const radiusTop = (_g = geometry.parameters.radiusTop) !== null && _g !== void 0 ? _g : 1;
54
+ const radiusBottom = (_h = geometry.parameters.radiusBottom) !== null && _h !== void 0 ? _h : 1;
55
+ if (radiusTop !== radiusBottom) {
56
+ console.warn('PhysicsSystem: detected cylinder with different radiusTop and radiusBottom. Using average radius for the physics shape.');
57
+ }
58
+ const height = (_j = geometry.parameters.height) !== null && _j !== void 0 ? _j : 1;
59
+ const avgRadius = (radiusTop + radiusBottom) / 2;
60
+ return {
61
+ shapeType: PhysicsShapeType.Cylinder,
62
+ dimensions: [avgRadius, height, 0], // Approximate bounding dimensions
63
+ };
64
+ }
65
+ // For generic BufferGeometry, fall back to the default ConvexHull shape type for better perf
66
+ if (geometry instanceof BufferGeometry) {
67
+ console.log(`PhysicsSystem: BufferGeometry detected for object ${object3D}, using ConvexHull.`);
68
+ return {
69
+ shapeType: PhysicsShapeType.ConvexHull,
70
+ dimensions: null,
71
+ };
72
+ }
73
+ // Fallback for unknown geometry types
74
+ console.warn(`PhysicsSystem: Unknown geometry type for object ${object3D}, falling back to Box`);
75
+ return {
76
+ shapeType: PhysicsShapeType.Box,
77
+ dimensions: calculateObject3DBounds(object3D),
78
+ };
79
+ }
80
+ /**
81
+ * Calculates bounding box dimensions from Object3D for fallback cases
82
+ */
83
+ function calculateObject3DBounds(object3D) {
84
+ try {
85
+ // Create a bounding box for the object
86
+ const box = new Box3().setFromObject(object3D);
87
+ if (!box.isEmpty()) {
88
+ const size = new Vector3();
89
+ box.getSize(size);
90
+ // Convert to half-extents and ensure minimum size
91
+ const dimensions = [
92
+ Math.max(size.x, 0.01),
93
+ Math.max(size.y, 0.01),
94
+ Math.max(size.z, 0.01),
95
+ ];
96
+ console.log(`PhysicsSystem: Calculated Object3D bounds: [${dimensions.join(', ')}]`);
97
+ return dimensions;
98
+ }
99
+ else {
100
+ console.warn('PhysicsSystem: Object3D bounding box is empty, using default dimensions');
101
+ }
102
+ }
103
+ catch (error) {
104
+ console.warn('PhysicsSystem: Failed to calculate Object3D bounds:', error);
105
+ }
106
+ // Final fallback if bounding box calculation fails
107
+ return [1, 1, 1];
108
+ }
109
+ function generateMergedGeometry(object3D) {
110
+ object3D.updateMatrixWorld(true);
111
+ tempMatrix.copy(object3D.matrixWorld);
112
+ tempMatrix.decompose(tempVec1, tempQuat, tempVec2);
113
+ tempMatrix.compose(tempVec1, tempQuat, UNIT_SCALE);
114
+ const geometries = [];
115
+ object3D.traverse((child) => {
116
+ if (child.isMesh && child.geometry) {
117
+ const geometry = child.geometry.clone();
118
+ geometry.applyMatrix4(child.matrixWorld);
119
+ geometries.push(geometry);
120
+ }
121
+ });
122
+ const mergedGeometry = mergeGeometries(geometries);
123
+ tempMatrix2.copy(tempMatrix).invert();
124
+ mergedGeometry.applyMatrix4(tempMatrix2);
125
+ object3D.matrixWorld.copy(tempMatrix);
126
+ return mergedGeometry;
127
+ }
128
+
129
+ export { calculateObject3DBounds, detectShapeFromGeometry, generateMergedGeometry };
130
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../src/physics/utils.ts"],"sourcesContent":[null],"names":[],"mapp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yE,CAC1E;QACH;IACF;IAAE,OAAO,KAAK,EAAE;AACd,QAAA,OAAO,CAAC,IAAI,CAAC,qDAAqD,EAAE,KAAK,CAAC;IAC5E;;AAGA,IAAA,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAClB;AAEM,SAAU,sBAAsB,CAAC,QAAkB,EAAA;AACvD,IAAA,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC;AAEhC,IAAA,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;IAErC,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;IAClD,UAAU,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,CAAC;IAElD,MAAM,UAAU,GAAqB,EAAE;AACvC,IAAA,QAAQ,CAAC,QAAQ,CAAC,CAAC,KAAK,KAAI;QAC1B,IAAK,KAAc,CAAC,MAAM,IAAK,KAAc,CAAC,QAAQ,EAAE;YACtD,MAAM,QAAQ,GAAI,KAAc,CAAC,QAAQ,CAAC,KAAK,EAAE;AACjD,YAAA,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC;AACxC,YAAA,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC3B;AACF,IAAA,CAAC,CAAC;AACF,IAAA,MAAM,cAAc,GAAG,eAAe,CAAC,UAAU,CAAC;IAClD,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE;AACrC,IAAA,cAAc,CAAC,YAAY,CAAC,WAAW,CAAC;AAExC,IAAA,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC;AAErC,IAAA,OAAO,cAAc;AACvB;;;;"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export * from './three.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,YAAY,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export * from 'three';
8
+ //# sourceMappingURL=three.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"three.d.ts","sourceRoot":"","sources":["../../src/runtime/three.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH,cAAc,OAAO,CAAC"}
@@ -0,0 +1,18 @@
1
+ import * as THREE from 'three';
2
+ export * from 'three';
3
+ import { computeBoundsTree, disposeBoundsTree, acceleratedRaycast, computeBatchedBoundsTree, disposeBatchedBoundsTree } from 'three-mesh-bvh';
4
+
5
+ /**
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+ THREE.BufferGeometry.prototype.computeBoundsTree = computeBoundsTree;
12
+ THREE.BufferGeometry.prototype.disposeBoundsTree = disposeBoundsTree;
13
+ THREE.Mesh.prototype.raycast = acceleratedRaycast;
14
+ THREE.BatchedMesh.prototype.computeBoundsTree = computeBatchedBoundsTree;
15
+ THREE.BatchedMesh.prototype.disposeBoundsTree = disposeBatchedBoundsTree;
16
+ THREE.BatchedMesh.prototype.raycast = acceleratedRaycast;
17
+ // export * as Addons from 'three/examples/jsm/Addons.js';
18
+ //# sourceMappingURL=three.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"three.js","sources":["../../src/runtime/three.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAAA;;;;;AAKG;AAWH,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,iBAAiB,GAAG,iBAAiB;AACpE,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,iBAAiB,GAAG,iBAAiB;AACpE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,GAAG,kBAAkB;AAEjD,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,iBAAiB,GAAG,wBAAwB;AACxE,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,iBAAiB,GAAG,wBAAwB;AACxE,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,GAAG,kBAAkB;AAIxD"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { Types } from '../ecs/index.js';
8
+ /**
9
+ * Component for anchoring entities to stable real‑world positions in AR/VR.
10
+ *
11
+ * @remarks
12
+ * - Anchors provide persistent, stable positioning relative to the real world.
13
+ * - Entities with this component are automatically managed by {@link SceneUnderstandingSystem}.
14
+ * - The entity's `object3D` will be attached to a world‑anchored group for stable tracking.
15
+ * - Requires WebXR session with 'anchor' feature enabled.
16
+ * - Anchors persist across tracking loss and help maintain consistent positioning.
17
+ * - Once attached, the entity's transform is managed relative to the anchor's reference frame.
18
+ * - Internal `attached` property tracks whether the entity has been processed by the system.
19
+ *
20
+ * @example Create an anchored object
21
+ * ```ts
22
+ * const marker = world.createEntity()
23
+ * marker.addComponent(XRAnchor) // Will be anchored to current world position
24
+ * ```
25
+ *
26
+ * @example Place content at a specific anchor point
27
+ * ```ts
28
+ * const hologram = world.createTransformEntity(hologramMesh)
29
+ * hologram.addComponent(XRAnchor)
30
+ * // The SceneUnderstandingSystem will anchor this at the current reference position
31
+ * ```
32
+ *
33
+ * @category Scene Understanding
34
+ * @see {@link SceneUnderstandingSystem}
35
+ */
36
+ export declare const XRAnchor: import("elics").Component<{
37
+ attached: {
38
+ type: Types.Boolean;
39
+ default: false;
40
+ };
41
+ }>;
42
+ //# sourceMappingURL=anchor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.d.ts","sourceRoot":"","sources":["../../src/scene-understanding/anchor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAmB,MAAM,iBAAiB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,eAAO,MAAM,QAAQ;;;;;EAMpB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import '@preact/signals-core';
2
+ import '../ecs/world.js';
3
+ import { createComponent, Types } from 'elics';
4
+ import '../ecs/component-registry.js';
5
+
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ /**
13
+ * Component for anchoring entities to stable real‑world positions in AR/VR.
14
+ *
15
+ * @remarks
16
+ * - Anchors provide persistent, stable positioning relative to the real world.
17
+ * - Entities with this component are automatically managed by {@link SceneUnderstandingSystem}.
18
+ * - The entity's `object3D` will be attached to a world‑anchored group for stable tracking.
19
+ * - Requires WebXR session with 'anchor' feature enabled.
20
+ * - Anchors persist across tracking loss and help maintain consistent positioning.
21
+ * - Once attached, the entity's transform is managed relative to the anchor's reference frame.
22
+ * - Internal `attached` property tracks whether the entity has been processed by the system.
23
+ *
24
+ * @example Create an anchored object
25
+ * ```ts
26
+ * const marker = world.createEntity()
27
+ * marker.addComponent(XRAnchor) // Will be anchored to current world position
28
+ * ```
29
+ *
30
+ * @example Place content at a specific anchor point
31
+ * ```ts
32
+ * const hologram = world.createTransformEntity(hologramMesh)
33
+ * hologram.addComponent(XRAnchor)
34
+ * // The SceneUnderstandingSystem will anchor this at the current reference position
35
+ * ```
36
+ *
37
+ * @category Scene Understanding
38
+ * @see {@link SceneUnderstandingSystem}
39
+ */
40
+ const XRAnchor = createComponent('XRAnchor', {
41
+ attached: { type: Types.Boolean, default: false },
42
+ }, 'Component for anchoring objects in the scene');
43
+
44
+ export { XRAnchor };
45
+ //# sourceMappingURL=anchor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor.js","sources":["../../src/scene-understanding/anchor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;AAAA;;;;;AAKG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AAEI,MAAM,QAAQ,GAAG,eAAe,CACrC,UAAU,EACV;IACE,QAAQ,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;CAClD,EACD,8CAA8C;;;;"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ export * from './scene-understanding-system.js';
8
+ export * from './anchor.js';
9
+ export * from './plane.js';
10
+ export * from './mesh.js';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/scene-understanding/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAc,iCAAiC,CAAC;AAChD,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}