@bloomengine/engine 0.3.1

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 (562) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/native/android/Cargo.lock +1848 -0
  4. package/native/android/Cargo.toml +20 -0
  5. package/native/android/src/lib.rs +1747 -0
  6. package/native/ios/Cargo.lock +1688 -0
  7. package/native/ios/Cargo.toml +19 -0
  8. package/native/ios/src/lib.rs +2258 -0
  9. package/native/linux/Cargo.lock +1719 -0
  10. package/native/linux/Cargo.toml +22 -0
  11. package/native/linux/src/lib.rs +2236 -0
  12. package/native/macos/Cargo.lock +3310 -0
  13. package/native/macos/Cargo.toml +29 -0
  14. package/native/macos/src/lib.rs +3444 -0
  15. package/native/shared/Cargo.lock +1898 -0
  16. package/native/shared/Cargo.toml +42 -0
  17. package/native/shared/assets/default_font.ttf +0 -0
  18. package/native/shared/build.rs +77 -0
  19. package/native/shared/shaders/common/fog.wgsl +16 -0
  20. package/native/shared/shaders/common/imposter.wgsl +112 -0
  21. package/native/shared/shaders/common/pbr.wgsl +186 -0
  22. package/native/shared/shaders/common/shadows.wgsl +77 -0
  23. package/native/shared/shaders/common/sky.wgsl +8 -0
  24. package/native/shared/shaders/common/tonemap.wgsl +25 -0
  25. package/native/shared/shaders/impulse_field.wgsl +53 -0
  26. package/native/shared/shaders/material_abi.wgsl +360 -0
  27. package/native/shared/shaders/materials/test_minimal.wgsl +42 -0
  28. package/native/shared/src/audio.rs +363 -0
  29. package/native/shared/src/custom_shaders.rs +104 -0
  30. package/native/shared/src/drs.rs +211 -0
  31. package/native/shared/src/engine.rs +186 -0
  32. package/native/shared/src/frame_callbacks.rs +88 -0
  33. package/native/shared/src/geometry.rs +236 -0
  34. package/native/shared/src/handles.rs +76 -0
  35. package/native/shared/src/input.rs +273 -0
  36. package/native/shared/src/jolt_sys.rs +822 -0
  37. package/native/shared/src/lib.rs +43 -0
  38. package/native/shared/src/models.rs +1941 -0
  39. package/native/shared/src/physics_jolt.rs +1528 -0
  40. package/native/shared/src/picking.rs +298 -0
  41. package/native/shared/src/postfx.rs +339 -0
  42. package/native/shared/src/profiler.rs +416 -0
  43. package/native/shared/src/renderer/atmosphere_lut.rs +573 -0
  44. package/native/shared/src/renderer/brdf_lut.rs +154 -0
  45. package/native/shared/src/renderer/formats.rs +778 -0
  46. package/native/shared/src/renderer/graph.rs +465 -0
  47. package/native/shared/src/renderer/hot_reload.rs +390 -0
  48. package/native/shared/src/renderer/impulse_field.rs +455 -0
  49. package/native/shared/src/renderer/material_pipeline.rs +604 -0
  50. package/native/shared/src/renderer/material_system.rs +2106 -0
  51. package/native/shared/src/renderer/mod.rs +13923 -0
  52. package/native/shared/src/renderer/planar_reflection.rs +458 -0
  53. package/native/shared/src/renderer/post_pass.rs +249 -0
  54. package/native/shared/src/renderer/shader_include.rs +205 -0
  55. package/native/shared/src/renderer/shader_library.rs +134 -0
  56. package/native/shared/src/renderer/shaders.rs +5855 -0
  57. package/native/shared/src/renderer/transient.rs +576 -0
  58. package/native/shared/src/renderer/types.rs +259 -0
  59. package/native/shared/src/renderer/util.rs +151 -0
  60. package/native/shared/src/scene.rs +1066 -0
  61. package/native/shared/src/sdf_cache.rs +274 -0
  62. package/native/shared/src/shadows.rs +551 -0
  63. package/native/shared/src/staging.rs +90 -0
  64. package/native/shared/src/string_header.rs +35 -0
  65. package/native/shared/src/text_renderer.rs +456 -0
  66. package/native/shared/src/textures.rs +154 -0
  67. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.cpp +242 -0
  68. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeBuilder.h +121 -0
  69. package/native/third_party/JoltPhysics/Jolt/AABBTree/AABBTreeToBuffer.h +296 -0
  70. package/native/third_party/JoltPhysics/Jolt/AABBTree/NodeCodec/NodeCodecQuadTreeHalfFloat.h +323 -0
  71. package/native/third_party/JoltPhysics/Jolt/AABBTree/TriangleCodec/TriangleCodecIndexed8BitPackSOA4Flags.h +555 -0
  72. package/native/third_party/JoltPhysics/Jolt/ConfigurationString.h +112 -0
  73. package/native/third_party/JoltPhysics/Jolt/Core/ARMNeon.h +94 -0
  74. package/native/third_party/JoltPhysics/Jolt/Core/Array.h +713 -0
  75. package/native/third_party/JoltPhysics/Jolt/Core/Atomics.h +44 -0
  76. package/native/third_party/JoltPhysics/Jolt/Core/BinaryHeap.h +96 -0
  77. package/native/third_party/JoltPhysics/Jolt/Core/ByteBuffer.h +74 -0
  78. package/native/third_party/JoltPhysics/Jolt/Core/Color.cpp +38 -0
  79. package/native/third_party/JoltPhysics/Jolt/Core/Color.h +98 -0
  80. package/native/third_party/JoltPhysics/Jolt/Core/Core.h +652 -0
  81. package/native/third_party/JoltPhysics/Jolt/Core/FPControlWord.h +143 -0
  82. package/native/third_party/JoltPhysics/Jolt/Core/FPException.h +96 -0
  83. package/native/third_party/JoltPhysics/Jolt/Core/FPFlushDenormals.h +43 -0
  84. package/native/third_party/JoltPhysics/Jolt/Core/Factory.cpp +92 -0
  85. package/native/third_party/JoltPhysics/Jolt/Core/Factory.h +54 -0
  86. package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.h +122 -0
  87. package/native/third_party/JoltPhysics/Jolt/Core/FixedSizeFreeList.inl +215 -0
  88. package/native/third_party/JoltPhysics/Jolt/Core/HashCombine.h +234 -0
  89. package/native/third_party/JoltPhysics/Jolt/Core/HashTable.h +876 -0
  90. package/native/third_party/JoltPhysics/Jolt/Core/InsertionSort.h +58 -0
  91. package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.cpp +27 -0
  92. package/native/third_party/JoltPhysics/Jolt/Core/IssueReporting.h +38 -0
  93. package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.h +311 -0
  94. package/native/third_party/JoltPhysics/Jolt/Core/JobSystem.inl +56 -0
  95. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.cpp +65 -0
  96. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemSingleThreaded.h +62 -0
  97. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.cpp +364 -0
  98. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemThreadPool.h +101 -0
  99. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.cpp +230 -0
  100. package/native/third_party/JoltPhysics/Jolt/Core/JobSystemWithBarrier.h +85 -0
  101. package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.cpp +51 -0
  102. package/native/third_party/JoltPhysics/Jolt/Core/LinearCurve.h +67 -0
  103. package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.h +182 -0
  104. package/native/third_party/JoltPhysics/Jolt/Core/LockFreeHashMap.inl +351 -0
  105. package/native/third_party/JoltPhysics/Jolt/Core/Memory.cpp +85 -0
  106. package/native/third_party/JoltPhysics/Jolt/Core/Memory.h +85 -0
  107. package/native/third_party/JoltPhysics/Jolt/Core/Mutex.h +223 -0
  108. package/native/third_party/JoltPhysics/Jolt/Core/MutexArray.h +98 -0
  109. package/native/third_party/JoltPhysics/Jolt/Core/NonCopyable.h +18 -0
  110. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.cpp +677 -0
  111. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.h +301 -0
  112. package/native/third_party/JoltPhysics/Jolt/Core/Profiler.inl +90 -0
  113. package/native/third_party/JoltPhysics/Jolt/Core/QuickSort.h +137 -0
  114. package/native/third_party/JoltPhysics/Jolt/Core/RTTI.cpp +149 -0
  115. package/native/third_party/JoltPhysics/Jolt/Core/RTTI.h +436 -0
  116. package/native/third_party/JoltPhysics/Jolt/Core/Reference.h +244 -0
  117. package/native/third_party/JoltPhysics/Jolt/Core/Result.h +174 -0
  118. package/native/third_party/JoltPhysics/Jolt/Core/STLAlignedAllocator.h +72 -0
  119. package/native/third_party/JoltPhysics/Jolt/Core/STLAllocator.h +127 -0
  120. package/native/third_party/JoltPhysics/Jolt/Core/STLLocalAllocator.h +170 -0
  121. package/native/third_party/JoltPhysics/Jolt/Core/STLTempAllocator.h +80 -0
  122. package/native/third_party/JoltPhysics/Jolt/Core/ScopeExit.h +49 -0
  123. package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.cpp +135 -0
  124. package/native/third_party/JoltPhysics/Jolt/Core/Semaphore.h +68 -0
  125. package/native/third_party/JoltPhysics/Jolt/Core/StaticArray.h +329 -0
  126. package/native/third_party/JoltPhysics/Jolt/Core/StreamIn.h +120 -0
  127. package/native/third_party/JoltPhysics/Jolt/Core/StreamOut.h +97 -0
  128. package/native/third_party/JoltPhysics/Jolt/Core/StreamUtils.h +168 -0
  129. package/native/third_party/JoltPhysics/Jolt/Core/StreamWrapper.h +53 -0
  130. package/native/third_party/JoltPhysics/Jolt/Core/StridedPtr.h +63 -0
  131. package/native/third_party/JoltPhysics/Jolt/Core/StringTools.cpp +101 -0
  132. package/native/third_party/JoltPhysics/Jolt/Core/StringTools.h +38 -0
  133. package/native/third_party/JoltPhysics/Jolt/Core/TempAllocator.h +209 -0
  134. package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.cpp +37 -0
  135. package/native/third_party/JoltPhysics/Jolt/Core/TickCounter.h +58 -0
  136. package/native/third_party/JoltPhysics/Jolt/Core/UnorderedMap.h +80 -0
  137. package/native/third_party/JoltPhysics/Jolt/Core/UnorderedSet.h +32 -0
  138. package/native/third_party/JoltPhysics/Jolt/Geometry/AABox.h +313 -0
  139. package/native/third_party/JoltPhysics/Jolt/Geometry/AABox4.h +224 -0
  140. package/native/third_party/JoltPhysics/Jolt/Geometry/ClipPoly.h +200 -0
  141. package/native/third_party/JoltPhysics/Jolt/Geometry/ClosestPoint.h +498 -0
  142. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.cpp +1467 -0
  143. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder.h +276 -0
  144. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.cpp +335 -0
  145. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexHullBuilder2D.h +105 -0
  146. package/native/third_party/JoltPhysics/Jolt/Geometry/ConvexSupport.h +188 -0
  147. package/native/third_party/JoltPhysics/Jolt/Geometry/EPAConvexHullBuilder.h +845 -0
  148. package/native/third_party/JoltPhysics/Jolt/Geometry/EPAPenetrationDepth.h +557 -0
  149. package/native/third_party/JoltPhysics/Jolt/Geometry/Ellipse.h +77 -0
  150. package/native/third_party/JoltPhysics/Jolt/Geometry/GJKClosestPoint.h +945 -0
  151. package/native/third_party/JoltPhysics/Jolt/Geometry/IndexedTriangle.h +130 -0
  152. package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.cpp +222 -0
  153. package/native/third_party/JoltPhysics/Jolt/Geometry/Indexify.h +19 -0
  154. package/native/third_party/JoltPhysics/Jolt/Geometry/MortonCode.h +40 -0
  155. package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.cpp +178 -0
  156. package/native/third_party/JoltPhysics/Jolt/Geometry/OrientedBox.h +39 -0
  157. package/native/third_party/JoltPhysics/Jolt/Geometry/Plane.h +104 -0
  158. package/native/third_party/JoltPhysics/Jolt/Geometry/RayAABox.h +241 -0
  159. package/native/third_party/JoltPhysics/Jolt/Geometry/RayCapsule.h +37 -0
  160. package/native/third_party/JoltPhysics/Jolt/Geometry/RayCylinder.h +101 -0
  161. package/native/third_party/JoltPhysics/Jolt/Geometry/RaySphere.h +96 -0
  162. package/native/third_party/JoltPhysics/Jolt/Geometry/RayTriangle.h +158 -0
  163. package/native/third_party/JoltPhysics/Jolt/Geometry/Sphere.h +72 -0
  164. package/native/third_party/JoltPhysics/Jolt/Geometry/Triangle.h +34 -0
  165. package/native/third_party/JoltPhysics/Jolt/Jolt.cmake +703 -0
  166. package/native/third_party/JoltPhysics/Jolt/Jolt.h +16 -0
  167. package/native/third_party/JoltPhysics/Jolt/Jolt.natvis +116 -0
  168. package/native/third_party/JoltPhysics/Jolt/Math/BVec16.h +99 -0
  169. package/native/third_party/JoltPhysics/Jolt/Math/BVec16.inl +177 -0
  170. package/native/third_party/JoltPhysics/Jolt/Math/DMat44.h +158 -0
  171. package/native/third_party/JoltPhysics/Jolt/Math/DMat44.inl +310 -0
  172. package/native/third_party/JoltPhysics/Jolt/Math/DVec3.h +291 -0
  173. package/native/third_party/JoltPhysics/Jolt/Math/DVec3.inl +941 -0
  174. package/native/third_party/JoltPhysics/Jolt/Math/Double3.h +48 -0
  175. package/native/third_party/JoltPhysics/Jolt/Math/DynMatrix.h +31 -0
  176. package/native/third_party/JoltPhysics/Jolt/Math/EigenValueSymmetric.h +177 -0
  177. package/native/third_party/JoltPhysics/Jolt/Math/FindRoot.h +42 -0
  178. package/native/third_party/JoltPhysics/Jolt/Math/Float2.h +36 -0
  179. package/native/third_party/JoltPhysics/Jolt/Math/Float3.h +50 -0
  180. package/native/third_party/JoltPhysics/Jolt/Math/Float4.h +44 -0
  181. package/native/third_party/JoltPhysics/Jolt/Math/GaussianElimination.h +102 -0
  182. package/native/third_party/JoltPhysics/Jolt/Math/HalfFloat.h +208 -0
  183. package/native/third_party/JoltPhysics/Jolt/Math/Mat44.h +243 -0
  184. package/native/third_party/JoltPhysics/Jolt/Math/Mat44.inl +952 -0
  185. package/native/third_party/JoltPhysics/Jolt/Math/Math.h +208 -0
  186. package/native/third_party/JoltPhysics/Jolt/Math/MathTypes.h +32 -0
  187. package/native/third_party/JoltPhysics/Jolt/Math/Matrix.h +259 -0
  188. package/native/third_party/JoltPhysics/Jolt/Math/Quat.h +268 -0
  189. package/native/third_party/JoltPhysics/Jolt/Math/Quat.inl +406 -0
  190. package/native/third_party/JoltPhysics/Jolt/Math/Real.h +44 -0
  191. package/native/third_party/JoltPhysics/Jolt/Math/Swizzle.h +19 -0
  192. package/native/third_party/JoltPhysics/Jolt/Math/Trigonometry.h +79 -0
  193. package/native/third_party/JoltPhysics/Jolt/Math/UVec4.h +232 -0
  194. package/native/third_party/JoltPhysics/Jolt/Math/UVec4.inl +636 -0
  195. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.cpp +71 -0
  196. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.h +308 -0
  197. package/native/third_party/JoltPhysics/Jolt/Math/Vec3.inl +942 -0
  198. package/native/third_party/JoltPhysics/Jolt/Math/Vec4.h +320 -0
  199. package/native/third_party/JoltPhysics/Jolt/Math/Vec4.inl +1152 -0
  200. package/native/third_party/JoltPhysics/Jolt/Math/Vector.h +211 -0
  201. package/native/third_party/JoltPhysics/Jolt/ObjectStream/GetPrimitiveTypeOfType.h +54 -0
  202. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.cpp +38 -0
  203. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStream.h +337 -0
  204. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.cpp +252 -0
  205. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryIn.h +57 -0
  206. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.cpp +165 -0
  207. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamBinaryOut.h +57 -0
  208. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.cpp +635 -0
  209. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamIn.h +148 -0
  210. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.cpp +166 -0
  211. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamOut.h +101 -0
  212. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.cpp +418 -0
  213. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextIn.h +55 -0
  214. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.cpp +255 -0
  215. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTextOut.h +62 -0
  216. package/native/third_party/JoltPhysics/Jolt/ObjectStream/ObjectStreamTypes.h +26 -0
  217. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttribute.h +111 -0
  218. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeEnum.h +67 -0
  219. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableAttributeTyped.h +60 -0
  220. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.cpp +15 -0
  221. package/native/third_party/JoltPhysics/Jolt/ObjectStream/SerializableObject.h +170 -0
  222. package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.cpp +70 -0
  223. package/native/third_party/JoltPhysics/Jolt/ObjectStream/TypeDeclarations.h +45 -0
  224. package/native/third_party/JoltPhysics/Jolt/Physics/Body/AllowedDOFs.h +68 -0
  225. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.cpp +426 -0
  226. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.h +452 -0
  227. package/native/third_party/JoltPhysics/Jolt/Physics/Body/Body.inl +197 -0
  228. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyAccess.h +68 -0
  229. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyActivationListener.h +28 -0
  230. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.cpp +234 -0
  231. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyCreationSettings.h +124 -0
  232. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyFilter.h +130 -0
  233. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyID.h +101 -0
  234. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.cpp +1099 -0
  235. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyInterface.h +324 -0
  236. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLock.h +111 -0
  237. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockInterface.h +134 -0
  238. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyLockMulti.h +120 -0
  239. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.cpp +1220 -0
  240. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyManager.h +403 -0
  241. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyPair.h +36 -0
  242. package/native/third_party/JoltPhysics/Jolt/Physics/Body/BodyType.h +19 -0
  243. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.cpp +185 -0
  244. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MassProperties.h +58 -0
  245. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.cpp +92 -0
  246. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.h +308 -0
  247. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionProperties.inl +178 -0
  248. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionQuality.h +31 -0
  249. package/native/third_party/JoltPhysics/Jolt/Physics/Body/MotionType.h +17 -0
  250. package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.cpp +354 -0
  251. package/native/third_party/JoltPhysics/Jolt/Physics/Character/Character.h +159 -0
  252. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.cpp +59 -0
  253. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterBase.h +157 -0
  254. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterID.h +98 -0
  255. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.cpp +1933 -0
  256. package/native/third_party/JoltPhysics/Jolt/Physics/Character/CharacterVirtual.h +752 -0
  257. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/AABoxCast.h +20 -0
  258. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdgeMode.h +17 -0
  259. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ActiveEdges.h +114 -0
  260. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BackFaceMode.h +16 -0
  261. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.cpp +16 -0
  262. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhase.h +109 -0
  263. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.cpp +313 -0
  264. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseBruteForce.h +38 -0
  265. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayer.h +148 -0
  266. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceMask.h +92 -0
  267. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseLayerInterfaceTable.h +64 -0
  268. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.cpp +629 -0
  269. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuadTree.h +108 -0
  270. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/BroadPhaseQuery.h +56 -0
  271. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterMask.h +35 -0
  272. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/ObjectVsBroadPhaseLayerFilterTable.h +66 -0
  273. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.cpp +1768 -0
  274. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/BroadPhase/QuadTree.h +389 -0
  275. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.cpp +107 -0
  276. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastConvexVsTriangles.h +46 -0
  277. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastResult.h +37 -0
  278. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.cpp +223 -0
  279. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CastSphereVsTriangles.h +49 -0
  280. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollectFacesMode.h +16 -0
  281. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.cpp +155 -0
  282. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideConvexVsTriangles.h +56 -0
  283. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollidePointResult.h +25 -0
  284. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShape.h +106 -0
  285. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideShapeVsShapePerLeaf.h +94 -0
  286. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVertexIterator.h +110 -0
  287. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSoftBodyVerticesVsTriangles.h +102 -0
  288. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.cpp +121 -0
  289. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollideSphereVsTriangles.h +50 -0
  290. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollector.h +109 -0
  291. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionCollectorImpl.h +219 -0
  292. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.cpp +107 -0
  293. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionDispatch.h +97 -0
  294. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.cpp +35 -0
  295. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/CollisionGroup.h +97 -0
  296. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ContactListener.h +143 -0
  297. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.cpp +213 -0
  298. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/EstimateCollisionResponse.h +48 -0
  299. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.cpp +32 -0
  300. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilter.h +46 -0
  301. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.cpp +38 -0
  302. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/GroupFilterTable.h +130 -0
  303. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/InternalEdgeRemovingCollector.h +279 -0
  304. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.cpp +271 -0
  305. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ManifoldBetweenTwoFaces.h +44 -0
  306. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.cpp +448 -0
  307. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseQuery.h +77 -0
  308. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.cpp +62 -0
  309. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/NarrowPhaseStats.h +110 -0
  310. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayer.h +111 -0
  311. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterMask.h +52 -0
  312. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ObjectLayerPairFilterTable.h +78 -0
  313. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.cpp +35 -0
  314. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterial.h +57 -0
  315. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.cpp +38 -0
  316. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/PhysicsMaterialSimple.h +37 -0
  317. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/RayCast.h +87 -0
  318. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.cpp +318 -0
  319. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/BoxShape.h +115 -0
  320. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.cpp +438 -0
  321. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CapsuleShape.h +129 -0
  322. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.cpp +433 -0
  323. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShape.h +354 -0
  324. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CompoundShapeVisitors.h +461 -0
  325. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.cpp +1311 -0
  326. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexHullShape.h +202 -0
  327. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.cpp +566 -0
  328. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ConvexShape.h +150 -0
  329. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.cpp +418 -0
  330. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/CylinderShape.h +126 -0
  331. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.cpp +87 -0
  332. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/DecoratedShape.h +80 -0
  333. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.cpp +64 -0
  334. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/EmptyShape.h +75 -0
  335. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/GetTrianglesContext.h +248 -0
  336. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.cpp +2754 -0
  337. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/HeightFieldShape.h +380 -0
  338. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.cpp +1305 -0
  339. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MeshShape.h +228 -0
  340. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.cpp +596 -0
  341. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/MutableCompoundShape.h +176 -0
  342. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.cpp +217 -0
  343. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/OffsetCenterOfMassShape.h +140 -0
  344. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.cpp +541 -0
  345. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PlaneShape.h +147 -0
  346. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/PolyhedronSubmergedVolumeCalculator.h +319 -0
  347. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.cpp +333 -0
  348. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/RotatedTranslatedShape.h +161 -0
  349. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaleHelpers.h +83 -0
  350. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.cpp +238 -0
  351. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/ScaledShape.h +145 -0
  352. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.cpp +325 -0
  353. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/Shape.h +466 -0
  354. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.cpp +347 -0
  355. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SphereShape.h +125 -0
  356. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.cpp +674 -0
  357. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/StaticCompoundShape.h +139 -0
  358. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeID.h +138 -0
  359. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/SubShapeIDPair.h +65 -0
  360. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.cpp +453 -0
  361. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.gliffy +1 -0
  362. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCapsuleShape.h +135 -0
  363. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.cpp +691 -0
  364. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TaperedCylinderShape.h +132 -0
  365. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.cpp +430 -0
  366. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/Shape/TriangleShape.h +143 -0
  367. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeCast.h +173 -0
  368. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/ShapeFilter.h +73 -0
  369. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilter.h +40 -0
  370. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SimShapeFilterWrapper.h +58 -0
  371. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/SortReverseAndStore.h +48 -0
  372. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.cpp +180 -0
  373. package/native/third_party/JoltPhysics/Jolt/Physics/Collision/TransformedShape.h +194 -0
  374. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/CalculateSolverSteps.h +70 -0
  375. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.cpp +246 -0
  376. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConeConstraint.h +133 -0
  377. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.cpp +73 -0
  378. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/Constraint.h +243 -0
  379. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.cpp +289 -0
  380. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintManager.h +100 -0
  381. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AngleConstraintPart.h +257 -0
  382. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/AxisConstraintPart.h +682 -0
  383. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/DualAxisConstraintPart.h +276 -0
  384. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/GearConstraintPart.h +195 -0
  385. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/HingeRotationConstraintPart.h +222 -0
  386. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/IndependentAxisConstraintPart.h +246 -0
  387. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/PointConstraintPart.h +239 -0
  388. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RackAndPinionConstraintPart.h +196 -0
  389. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationEulerConstraintPart.h +283 -0
  390. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/RotationQuatConstraintPart.h +246 -0
  391. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SpringPart.h +169 -0
  392. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ConstraintPart/SwingTwistConstraintPart.h +597 -0
  393. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.cpp +1804 -0
  394. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/ContactConstraintManager.h +524 -0
  395. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.cpp +266 -0
  396. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/DistanceConstraint.h +120 -0
  397. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.cpp +215 -0
  398. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/FixedConstraint.h +96 -0
  399. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.cpp +188 -0
  400. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/GearConstraint.h +116 -0
  401. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.cpp +443 -0
  402. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/HingeConstraint.h +205 -0
  403. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.cpp +43 -0
  404. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/MotorSettings.h +66 -0
  405. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.cpp +458 -0
  406. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraint.h +191 -0
  407. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.cpp +85 -0
  408. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPath.h +76 -0
  409. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.cpp +308 -0
  410. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PathConstraintPathHermite.h +54 -0
  411. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.cpp +157 -0
  412. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PointConstraint.h +94 -0
  413. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.cpp +253 -0
  414. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/PulleyConstraint.h +137 -0
  415. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.cpp +189 -0
  416. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/RackAndPinionConstraint.h +118 -0
  417. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.cpp +900 -0
  418. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SixDOFConstraint.h +289 -0
  419. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.cpp +501 -0
  420. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SliderConstraint.h +198 -0
  421. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.cpp +35 -0
  422. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SpringSettings.h +70 -0
  423. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.cpp +524 -0
  424. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/SwingTwistConstraint.h +197 -0
  425. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.cpp +56 -0
  426. package/native/third_party/JoltPhysics/Jolt/Physics/Constraints/TwoBodyConstraint.h +65 -0
  427. package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.cpp +17 -0
  428. package/native/third_party/JoltPhysics/Jolt/Physics/DeterminismLog.h +159 -0
  429. package/native/third_party/JoltPhysics/Jolt/Physics/EActivation.h +16 -0
  430. package/native/third_party/JoltPhysics/Jolt/Physics/EPhysicsUpdateError.h +37 -0
  431. package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.cpp +492 -0
  432. package/native/third_party/JoltPhysics/Jolt/Physics/IslandBuilder.h +144 -0
  433. package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.cpp +582 -0
  434. package/native/third_party/JoltPhysics/Jolt/Physics/LargeIslandSplitter.h +187 -0
  435. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsLock.h +169 -0
  436. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.cpp +261 -0
  437. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsScene.h +104 -0
  438. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSettings.h +125 -0
  439. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsStepListener.h +37 -0
  440. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.cpp +2915 -0
  441. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsSystem.h +391 -0
  442. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.cpp +25 -0
  443. package/native/third_party/JoltPhysics/Jolt/Physics/PhysicsUpdateContext.h +176 -0
  444. package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.cpp +744 -0
  445. package/native/third_party/JoltPhysics/Jolt/Physics/Ragdoll/Ragdoll.h +245 -0
  446. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyContactListener.h +55 -0
  447. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.cpp +128 -0
  448. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyCreationSettings.h +75 -0
  449. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyManifold.h +74 -0
  450. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.cpp +1501 -0
  451. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyMotionProperties.h +333 -0
  452. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.cpp +354 -0
  453. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyShape.h +73 -0
  454. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.cpp +1487 -0
  455. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodySharedSettings.h +390 -0
  456. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyUpdateContext.h +63 -0
  457. package/native/third_party/JoltPhysics/Jolt/Physics/SoftBody/SoftBodyVertex.h +36 -0
  458. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorder.h +136 -0
  459. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.cpp +90 -0
  460. package/native/third_party/JoltPhysics/Jolt/Physics/StateRecorderImpl.h +50 -0
  461. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.cpp +306 -0
  462. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/MotorcycleController.h +119 -0
  463. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.cpp +547 -0
  464. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/TrackedVehicleController.h +169 -0
  465. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.cpp +33 -0
  466. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleAntiRollBar.h +33 -0
  467. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.cpp +376 -0
  468. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleCollisionTester.h +146 -0
  469. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.cpp +703 -0
  470. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleConstraint.h +252 -0
  471. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.cpp +17 -0
  472. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleController.h +87 -0
  473. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.cpp +81 -0
  474. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleDifferential.h +39 -0
  475. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.cpp +122 -0
  476. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleEngine.h +93 -0
  477. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.cpp +52 -0
  478. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTrack.h +56 -0
  479. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.cpp +159 -0
  480. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/VehicleTransmission.h +87 -0
  481. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.cpp +93 -0
  482. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/Wheel.h +148 -0
  483. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.cpp +866 -0
  484. package/native/third_party/JoltPhysics/Jolt/Physics/Vehicle/WheeledVehicleController.h +205 -0
  485. package/native/third_party/JoltPhysics/Jolt/RegisterTypes.cpp +204 -0
  486. package/native/third_party/JoltPhysics/Jolt/RegisterTypes.h +29 -0
  487. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.cpp +1107 -0
  488. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRenderer.h +383 -0
  489. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.cpp +168 -0
  490. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererPlayback.h +48 -0
  491. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.cpp +158 -0
  492. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererRecorder.h +130 -0
  493. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.cpp +80 -0
  494. package/native/third_party/JoltPhysics/Jolt/Renderer/DebugRendererSimple.h +88 -0
  495. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.cpp +165 -0
  496. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletalAnimation.h +91 -0
  497. package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.cpp +82 -0
  498. package/native/third_party/JoltPhysics/Jolt/Skeleton/Skeleton.h +72 -0
  499. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.cpp +237 -0
  500. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonMapper.h +145 -0
  501. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.cpp +87 -0
  502. package/native/third_party/JoltPhysics/Jolt/Skeleton/SkeletonPose.h +82 -0
  503. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.cpp +73 -0
  504. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitter.h +84 -0
  505. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.cpp +139 -0
  506. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterBinning.h +52 -0
  507. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.cpp +43 -0
  508. package/native/third_party/JoltPhysics/Jolt/TriangleSplitter/TriangleSplitterMean.h +28 -0
  509. package/native/third_party/JoltPhysics/LICENSE +7 -0
  510. package/native/third_party/JoltPhysics/README.md +173 -0
  511. package/native/third_party/bloom_jolt/CMakeLists.txt +78 -0
  512. package/native/third_party/bloom_jolt/include/bloom_jolt.h +519 -0
  513. package/native/third_party/bloom_jolt/src/bloom_jolt.cpp +1780 -0
  514. package/native/tvos/Cargo.lock +1692 -0
  515. package/native/tvos/Cargo.toml +22 -0
  516. package/native/tvos/src/lib.rs +3179 -0
  517. package/native/watchos/Cargo.lock +16 -0
  518. package/native/watchos/Cargo.toml +19 -0
  519. package/native/watchos/shaders/bloom_postfx.metal +99 -0
  520. package/native/watchos/src/BloomWatchApp.swift +1236 -0
  521. package/native/watchos/src/BloomWatchAudio.swift +179 -0
  522. package/native/watchos/src/audio.rs +55 -0
  523. package/native/watchos/src/draw_list.rs +223 -0
  524. package/native/watchos/src/ffi_stubs.rs +454 -0
  525. package/native/watchos/src/lib.rs +1013 -0
  526. package/native/watchos/src/models.rs +746 -0
  527. package/native/watchos/src/postfx.rs +91 -0
  528. package/native/watchos/src/scene.rs +534 -0
  529. package/native/watchos/src/textures.rs +184 -0
  530. package/native/web/Cargo.lock +1656 -0
  531. package/native/web/Cargo.toml +38 -0
  532. package/native/web/bloom_glue.js +218 -0
  533. package/native/web/build.sh +101 -0
  534. package/native/web/index.html +390 -0
  535. package/native/web/jolt_bridge.js +1311 -0
  536. package/native/web/src/lib.rs +2739 -0
  537. package/native/windows/Cargo.lock +1813 -0
  538. package/native/windows/Cargo.toml +31 -0
  539. package/native/windows/src/lib.rs +1933 -0
  540. package/package.json +558 -0
  541. package/src/audio/index.ts +151 -0
  542. package/src/core/colors.ts +56 -0
  543. package/src/core/index.ts +903 -0
  544. package/src/core/keys.ts +63 -0
  545. package/src/core/types.ts +102 -0
  546. package/src/index.ts +158 -0
  547. package/src/math/index.ts +502 -0
  548. package/src/mobile/index.ts +294 -0
  549. package/src/models/index.ts +859 -0
  550. package/src/physics/index.ts +1072 -0
  551. package/src/scene/index.ts +570 -0
  552. package/src/shapes/index.ts +120 -0
  553. package/src/text/index.ts +48 -0
  554. package/src/textures/index.ts +173 -0
  555. package/src/world/index.ts +22 -0
  556. package/src/world/loader.ts +385 -0
  557. package/src/world/prefab.ts +205 -0
  558. package/src/world/saver.ts +61 -0
  559. package/src/world/terrain.ts +254 -0
  560. package/src/world/types.ts +136 -0
  561. package/src/world/validate.ts +202 -0
  562. package/src/world/version.ts +47 -0
@@ -0,0 +1,859 @@
1
+ import { spawn, parallelMap } from 'perry/thread';
2
+ import { Color, Model, Vec3, Mat4, BoundingBox } from '../core/types';
3
+
4
+ // FFI declarations
5
+ declare function bloom_load_model(path: number): number;
6
+ declare function bloom_draw_model(handle: number, x: number, y: number, z: number, scale: number, r: number, g: number, b: number, a: number): void;
7
+ declare function bloom_draw_model_rotated(handle: number, x: number, y: number, z: number, scale: number, rotY: number, colorPackedArgb: number): void;
8
+ declare function bloom_unload_model(handle: number): void;
9
+ declare function bloom_draw_cube(x: number, y: number, z: number, w: number, h: number, d: number, r: number, g: number, b: number, a: number): void;
10
+ declare function bloom_draw_cube_wires(x: number, y: number, z: number, w: number, h: number, d: number, r: number, g: number, b: number, a: number): void;
11
+ declare function bloom_draw_sphere(x: number, y: number, z: number, radius: number, r: number, g: number, b: number, a: number): void;
12
+ declare function bloom_draw_sphere_wires(x: number, y: number, z: number, radius: number, r: number, g: number, b: number, a: number): void;
13
+ declare function bloom_draw_cylinder(x: number, y: number, z: number, rt: number, rb: number, h: number, r: number, g: number, b: number, a: number): void;
14
+ declare function bloom_draw_cylinder_ex(x: number, y: number, z: number, rt: number, rb: number, h: number, slices: number, r: number, g: number, b: number, a: number): void;
15
+ declare function bloom_draw_plane(x: number, y: number, z: number, w: number, d: number, r: number, g: number, b: number, a: number): void;
16
+ declare function bloom_draw_grid(slices: number, spacing: number): void;
17
+ declare function bloom_draw_ray(ox: number, oy: number, oz: number, dx: number, dy: number, dz: number, r: number, g: number, b: number, a: number): void;
18
+ declare function bloom_gen_mesh_cube(w: number, h: number, d: number): number;
19
+ declare function bloom_gen_mesh_heightmap(imageHandle: number, sizeX: number, sizeY: number, sizeZ: number): number;
20
+ declare function bloom_load_shader(source: number): number;
21
+ declare function bloom_compile_material(source: number): number;
22
+ declare function bloom_compile_material_refractive(source: number): number;
23
+ declare function bloom_compile_material_transparent(source: number): number;
24
+ declare function bloom_compile_material_additive(source: number): number;
25
+ declare function bloom_compile_material_cutout(source: number): number;
26
+ declare function bloom_compile_material_instanced(source: number): number;
27
+ declare function bloom_create_instance_buffer(dataPtr: any, instanceCount: number): number;
28
+ declare function bloom_submit_material_draw_instanced(material: number, meshHandle: number, meshIdx: number, instanceBuffer: number, instanceCount: number): void;
29
+ declare function bloom_destroy_instance_buffer(handle: number): void;
30
+ declare function bloom_create_planar_reflection(planeY: number, normalX: number, normalY: number, normalZ: number, resolution: number): number;
31
+ declare function bloom_set_material_reflection_probe(material: number, probe: number): void;
32
+ declare function bloom_create_texture_array(dataPtr: any, dataLen: number, width: number, height: number, layerCount: number): number;
33
+ declare function bloom_create_texture_array_ex(dataPtr: any, dataLen: number, width: number, height: number, layerCount: number, format: number, mipLevels: number): number;
34
+ declare function bloom_set_material_texture_array(material: number, slot: number, array: number): void;
35
+ declare function bloom_set_material_shading_model(material: number, model: number): void;
36
+ declare function bloom_set_material_foliage(material: number, transR: number, transG: number, transB: number, transAmount: number, wrapFactor: number): void;
37
+ declare function bloom_compile_material_from_file(path: number, bucketKind: number): number;
38
+ declare function bloom_set_material_params(handle: number, paramsPtr: any, paramCount: number): void;
39
+ declare function bloom_draw_material(material: number, meshHandle: number, meshIdx: number, x: number, y: number, z: number, scale: number, r: number, g: number, b: number, a: number): void;
40
+ declare function bloom_load_model_animation(path: number): number;
41
+ declare function bloom_update_model_animation(handle: number, animIndex: number, time: number, scale: number, px: number, py: number, pz: number, rotY: number): void;
42
+ declare function bloom_create_mesh(vertexPtr: number, vertexCount: number, indexPtr: number, indexCount: number): number;
43
+ declare function bloom_set_ambient_light(r: number, g: number, b: number, intensity: number): void;
44
+ declare function bloom_set_directional_light(dx: number, dy: number, dz: number, r: number, g: number, b: number, intensity: number): void;
45
+ declare function bloom_set_procedural_sky(enabled: number, rayleighDensity: number, mieDensity: number, groundAlbedo: number): void;
46
+ declare function bloom_set_sun_direction(dx: number, dy: number, dz: number, intensity: number): void;
47
+ declare function bloom_gen_mesh_spline_ribbon(pointsPtr: number, pointCount: number, widthsPtr: number, widthCount: number): number;
48
+ declare function bloom_get_model_mesh_count(handle: number): number;
49
+ declare function bloom_get_model_material_count(handle: number): number;
50
+ declare function bloom_get_model_bounds_min_x(handle: number): number;
51
+ declare function bloom_get_model_bounds_min_y(handle: number): number;
52
+ declare function bloom_get_model_bounds_min_z(handle: number): number;
53
+ declare function bloom_get_model_bounds_max_x(handle: number): number;
54
+ declare function bloom_get_model_bounds_max_y(handle: number): number;
55
+ declare function bloom_get_model_bounds_max_z(handle: number): number;
56
+
57
+ function makeModel(handle: number): Model {
58
+ const mc = bloom_get_model_mesh_count(handle);
59
+ const matc = bloom_get_model_material_count(handle);
60
+ return { handle, meshCount: mc, materialCount: matc, transform: [1.0,0.0,0.0,0.0, 0.0,1.0,0.0,0.0, 0.0,0.0,1.0,0.0, 0.0,0.0,0.0,1.0] };
61
+ }
62
+
63
+ // OBJ parser (pure TypeScript)
64
+ function parseOBJ(text: string): { vertices: number[]; indices: number[] } | null {
65
+ const positions: number[][] = [];
66
+ const normals: number[][] = [];
67
+ const texcoords: number[][] = [];
68
+ const vertexMap = new Map<string, number>();
69
+ const vertices: number[] = [];
70
+ const indices: number[] = [];
71
+ let vertexCount = 0;
72
+
73
+ const lines = text.split('\n');
74
+ for (let i = 0; i < lines.length; i++) {
75
+ const line = lines[i].trim();
76
+ if (line.length === 0 || line[0] === '#') continue;
77
+
78
+ const parts = line.split(/\s+/);
79
+ const cmd = parts[0];
80
+
81
+ if (cmd === 'v' && parts.length >= 4) {
82
+ positions.push([parseFloat(parts[1]), parseFloat(parts[2]), parseFloat(parts[3])]);
83
+ } else if (cmd === 'vn' && parts.length >= 4) {
84
+ normals.push([parseFloat(parts[1]), parseFloat(parts[2]), parseFloat(parts[3])]);
85
+ } else if (cmd === 'vt' && parts.length >= 3) {
86
+ texcoords.push([parseFloat(parts[1]), parseFloat(parts[2])]);
87
+ } else if (cmd === 'f') {
88
+ // Triangulate face (fan from first vertex)
89
+ const faceIndices: number[] = [];
90
+ for (let j = 1; j < parts.length; j++) {
91
+ const key = parts[j];
92
+ if (vertexMap.has(key)) {
93
+ faceIndices.push(vertexMap.get(key)!);
94
+ } else {
95
+ const segs = key.split('/');
96
+ const pi = parseInt(segs[0]) - 1;
97
+ const ti = segs.length > 1 && segs[1] !== '' ? parseInt(segs[1]) - 1 : -1;
98
+ const ni = segs.length > 2 ? parseInt(segs[2]) - 1 : -1;
99
+
100
+ const pos = pi >= 0 && pi < positions.length ? positions[pi] : [0, 0, 0];
101
+ const norm = ni >= 0 && ni < normals.length ? normals[ni] : [0, 1, 0];
102
+ const uv = ti >= 0 && ti < texcoords.length ? texcoords[ti] : [0, 0];
103
+
104
+ // Format: x,y,z, nx,ny,nz, r,g,b,a, u,v (12 floats per vertex)
105
+ vertices.push(pos[0], pos[1], pos[2]);
106
+ vertices.push(norm[0], norm[1], norm[2]);
107
+ vertices.push(1, 1, 1, 1); // white color
108
+ vertices.push(uv[0], uv[1]);
109
+
110
+ const idx = vertexCount;
111
+ vertexCount++;
112
+ vertexMap.set(key, idx);
113
+ faceIndices.push(idx);
114
+ }
115
+ }
116
+
117
+ // Fan triangulation
118
+ for (let j = 2; j < faceIndices.length; j++) {
119
+ indices.push(faceIndices[0], faceIndices[j - 1], faceIndices[j]);
120
+ }
121
+ }
122
+ }
123
+
124
+ if (vertexCount === 0) return null;
125
+ return { vertices, indices };
126
+ }
127
+
128
+ declare function bloom_read_file(path: number): number;
129
+
130
+ export function loadModel(path: string): Model {
131
+ // Check for OBJ format
132
+ const pathLower = (path as string).toLowerCase();
133
+ if (pathLower.endsWith('.obj')) {
134
+ const text: string = bloom_read_file(path as any) as any;
135
+ if (text) {
136
+ const parsed = parseOBJ(text);
137
+ if (parsed) {
138
+ const handle = bloom_create_mesh(
139
+ parsed.vertices as any,
140
+ parsed.vertices.length / 12,
141
+ parsed.indices as any,
142
+ parsed.indices.length,
143
+ );
144
+ return makeModel(handle, 1, 1);
145
+ }
146
+ }
147
+ return makeModel(0);
148
+ }
149
+
150
+ const handle = bloom_load_model(path as any);
151
+ return makeModel(handle);
152
+ }
153
+
154
+ export function drawModel(model: Model, position: Vec3, scale: number, tint: Color): void {
155
+ bloom_draw_model(model.handle, position.x, position.y, position.z, scale, tint.r, tint.g, tint.b, tint.a);
156
+ }
157
+
158
+ /// Draw a model with a Y-axis rotation (radians). RGBA is packed into
159
+ /// a single f64 (ARGB byte order) to keep the FFI to 7 args, dodging
160
+ /// the Perry-ARM64 9th-arg quirk.
161
+ export function drawModelRotated(
162
+ model: Model, position: Vec3, scale: number, rotY: number, tint: Color,
163
+ ): void {
164
+ // Color components are 0..255 ints (matching drawModel above).
165
+ const a = (tint.a & 0xff) << 24;
166
+ const r = (tint.r & 0xff) << 16;
167
+ const g = (tint.g & 0xff) << 8;
168
+ const b = tint.b & 0xff;
169
+ // Use unsigned-shift-zero to keep the value positive when stored as f64.
170
+ const packed = (a | r | g | b) >>> 0;
171
+ bloom_draw_model_rotated(model.handle, position.x, position.y, position.z, scale, rotY, packed);
172
+ }
173
+
174
+ export function unloadModel(model: Model): void {
175
+ bloom_unload_model(model.handle);
176
+ }
177
+
178
+ /**
179
+ * Return the axis-aligned bounding box of a loaded model in its local
180
+ * coordinate space. Computed once at load time from mesh vertex positions.
181
+ *
182
+ * Used by editors to:
183
+ * - size move/rotate/scale gizmos to the selected entity
184
+ * - auto-frame the camera on the current selection
185
+ * - snap placed entities onto terrain by the lowest vertex
186
+ * - build precise ray-pick colliders
187
+ *
188
+ * Returns a zero-sized box at the origin if the model handle is invalid.
189
+ */
190
+ /**
191
+ * Q9: Generate a ribbon mesh along a Catmull-Rom spline.
192
+ * `points` is a flat array [x0,y0,z0, x1,y1,z1, ...] of control points.
193
+ * `widths` has one width per control point.
194
+ * Returns a Model whose mesh is a smooth triangle-strip ribbon.
195
+ */
196
+ export function genMeshSplineRibbon(points: number[], widths: number[]): Model {
197
+ const pointCount = points.length / 3;
198
+ const handle = bloom_gen_mesh_spline_ribbon(points as any, pointCount, widths as any, widths.length);
199
+ return makeModel(handle);
200
+ }
201
+
202
+ export function getModelBounds(model: Model): BoundingBox {
203
+ return {
204
+ min: {
205
+ x: bloom_get_model_bounds_min_x(model.handle),
206
+ y: bloom_get_model_bounds_min_y(model.handle),
207
+ z: bloom_get_model_bounds_min_z(model.handle),
208
+ },
209
+ max: {
210
+ x: bloom_get_model_bounds_max_x(model.handle),
211
+ y: bloom_get_model_bounds_max_y(model.handle),
212
+ z: bloom_get_model_bounds_max_z(model.handle),
213
+ },
214
+ };
215
+ }
216
+
217
+ export interface DrawCubeOpts {
218
+ rotationY?: number;
219
+ }
220
+
221
+ export function drawCube(position: Vec3, width: number, height: number, depth: number, color: Color, opts?: DrawCubeOpts): void {
222
+ // Note: rotationY is accepted for API compatibility but applied only when native support exists
223
+ bloom_draw_cube(position.x, position.y, position.z, width, height, depth, color.r, color.g, color.b, color.a);
224
+ }
225
+
226
+ export function drawCubeWires(position: Vec3, width: number, height: number, depth: number, color: Color): void {
227
+ bloom_draw_cube_wires(position.x, position.y, position.z, width, height, depth, color.r, color.g, color.b, color.a);
228
+ }
229
+
230
+ export function drawSphere(position: Vec3, radius: number, color: Color): void {
231
+ bloom_draw_sphere(position.x, position.y, position.z, radius, color.r, color.g, color.b, color.a);
232
+ }
233
+
234
+ export function drawSphereWires(position: Vec3, radius: number, color: Color): void {
235
+ bloom_draw_sphere_wires(position.x, position.y, position.z, radius, color.r, color.g, color.b, color.a);
236
+ }
237
+
238
+ export function drawCylinder(position: Vec3, radiusTop: number, radiusBottom: number, height: number, color: Color, slices?: number): void {
239
+ bloom_draw_cylinder(position.x, position.y, position.z, radiusTop, radiusBottom, height, color.r, color.g, color.b, color.a);
240
+ }
241
+
242
+ export function drawPlane(position: Vec3, width: number, depth: number, color: Color): void {
243
+ bloom_draw_plane(position.x, position.y, position.z, width, depth, color.r, color.g, color.b, color.a);
244
+ }
245
+
246
+ export function drawGrid(slices: number, spacing: number): void {
247
+ bloom_draw_grid(slices, spacing);
248
+ }
249
+
250
+ export function drawRay(origin: Vec3, direction: Vec3, color: Color): void {
251
+ bloom_draw_ray(origin.x, origin.y, origin.z, direction.x, direction.y, direction.z, color.r, color.g, color.b, color.a);
252
+ }
253
+
254
+ export function genMeshCube(width: number, height: number, depth: number): Model {
255
+ const handle = bloom_gen_mesh_cube(width, height, depth);
256
+ return makeModel(handle, 1, 1);
257
+ }
258
+
259
+ export function genMeshHeightmap(imageHandle: number, sizeX: number, sizeY: number, sizeZ: number): Model {
260
+ const handle = bloom_gen_mesh_heightmap(imageHandle, sizeX, sizeY, sizeZ);
261
+ return makeModel(handle, 1, 1);
262
+ }
263
+
264
+ export function loadShader(wgslSource: string): number {
265
+ return bloom_load_shader(wgslSource as any);
266
+ }
267
+
268
+ /// Phase 1c — compile a material against the shader ABI in
269
+ /// `native/shared/shaders/material_abi.wgsl`. Source may `#include`
270
+ /// the header and common helpers. Returns a handle (>0 on success, 0
271
+ /// on compile failure — errors log to stderr).
272
+ export function compileMaterial(wgslSource: string): number {
273
+ return bloom_compile_material(wgslSource as any);
274
+ }
275
+
276
+ /// Material profile — matches `FragmentProfile` in the engine's
277
+ /// material_pipeline. Opaque writes the full 4-MRT G-buffer;
278
+ /// Translucent writes a single HDR attachment with alpha blending.
279
+ export const PROFILE_OPAQUE = 0;
280
+ export const PROFILE_TRANSLUCENT = 1;
281
+
282
+ /// Material bucket — matches `Bucket` in the engine. Decides which
283
+ /// pass the draw lands in and what sort order applies. Refractive
284
+ /// also triggers a scene-colour snapshot before the pass runs.
285
+ export const BUCKET_OPAQUE = 0;
286
+ export const BUCKET_TRANSPARENT = 1;
287
+ export const BUCKET_REFRACTIVE = 2;
288
+ export const BUCKET_ADDITIVE = 3;
289
+ export const BUCKET_CUTOUT = 4;
290
+
291
+ /// Phase 4b — full-control material compile. Pass PROFILE_* and
292
+ /// BUCKET_* constants. `readsScene` enables the group-4 SceneInputs
293
+ /// binding; required for refraction / shoreline / depth-fade effects.
294
+ /// Phase 4b — compile a refractive material (profile=Translucent,
295
+ /// bucket=Refractive, reads_scene=true). The material's shader gets
296
+ /// the SceneInputs bind group at group 4 and can sample the
297
+ /// pre-translucent scene colour via `scene_color_tex`.
298
+ export function compileRefractiveMaterial(wgslSource: string): number {
299
+ return bloom_compile_material_refractive(wgslSource as any);
300
+ }
301
+
302
+ /// Compile a transparent material (profile=Translucent, bucket=
303
+ /// Transparent, reads_scene=false). Alpha-blended, sorted back-to-
304
+ /// front. No scene-colour sampling.
305
+ export function compileTransparentMaterial(wgslSource: string): number {
306
+ return bloom_compile_material_transparent(wgslSource as any);
307
+ }
308
+
309
+ /// Compile an additive material (profile=Translucent, bucket=
310
+ /// Additive, reads_scene=false). Order-independent — use for
311
+ /// particle flares, weapon glows, spell effects.
312
+ export function compileAdditiveMaterial(wgslSource: string): number {
313
+ return bloom_compile_material_additive(wgslSource as any);
314
+ }
315
+
316
+ /// Compile a material into the Cutout bucket: writes the full G-buffer
317
+ /// (so it casts/receives sun shadow + SSAO), but the fragment shader
318
+ /// is expected to call `discard` against `material.metal_rough.w`
319
+ /// (`MaterialFactors.alpha_cutoff`) to drop transparent texels. Use
320
+ /// for foliage cards, chain-link fences, leaf silhouettes. Rendered
321
+ /// double-sided (cull_mode=None) so foliage is visible from both
322
+ /// faces.
323
+ export function compileMaterialCutout(wgslSource: string): number {
324
+ return bloom_compile_material_cutout(wgslSource as any);
325
+ }
326
+
327
+ /// EN-001 — compile a material that draws via the instanced pipeline.
328
+ /// Per-instance data is uploaded once via `createInstanceBuffer` and
329
+ /// drawn via `drawMeshWithMaterialInstanced`. The game shader's
330
+ /// VertexInput must declare these locations IN ADDITION to the
331
+ /// standard 0..6 (see `material_abi.wgsl` for the canonical layout):
332
+ ///
333
+ /// @location(7) instance_pos: vec3<f32>
334
+ /// @location(8) instance_rot_y: f32
335
+ /// @location(9) instance_scale: f32
336
+ /// @location(10) instance_tint: vec4<f32>
337
+ ///
338
+ /// The pipeline lives in the Opaque bucket (cuts opaque profile +
339
+ /// no scene-color reads). For the shooter's grass/foliage workload
340
+ /// this is the right default; future work can extend to other buckets.
341
+ export function compileMaterialInstanced(wgslSource: string): number {
342
+ return bloom_compile_material_instanced(wgslSource as any);
343
+ }
344
+
345
+ /// EN-001 — upload a flat per-instance buffer to the GPU. `data` is
346
+ /// laid out as 9 floats per instance:
347
+ /// [pos.x, pos.y, pos.z, rot_y, scale, tint.r, tint.g, tint.b, tint.a]
348
+ /// × instanceCount. Returns a handle to use with
349
+ /// `drawMeshWithMaterialInstanced`. The buffer is persistent across
350
+ /// frames; call `destroyInstanceBuffer` when the data is no longer
351
+ /// needed.
352
+ ///
353
+ /// IMPORTANT: pass `instanceCount` derived from a literal-init array
354
+ /// length OR from a manually-tracked counter. Don't compute
355
+ /// `data.length / 9` if `data` was built via `.push()` — Perry's
356
+ /// `.length` reports the literal-init size, not the post-push count
357
+ /// (a Perry codegen bug — see `feedback_perry_array_push.md`).
358
+ export function createInstanceBuffer(data: number[], instanceCount: number): number {
359
+ return bloom_create_instance_buffer(data as any, instanceCount);
360
+ }
361
+
362
+ /// EN-001 — draw `mesh` (a single primitive at `meshIdx`)
363
+ /// `instanceCount` times using `material`'s instanced pipeline. The
364
+ /// instance buffer is bound at vertex slot 1 and the engine emits a
365
+ /// single draw_indexed call. Per-draw model/MVP are identity / current
366
+ /// camera VP — per-instance pos/rot_y/scale dominate from the buffer.
367
+ export function drawMeshWithMaterialInstanced(
368
+ material: number, mesh: Model, meshIdx: number,
369
+ instanceBuffer: number, instanceCount: number,
370
+ ): void {
371
+ bloom_submit_material_draw_instanced(
372
+ material, mesh.handle, meshIdx, instanceBuffer, instanceCount,
373
+ );
374
+ }
375
+
376
+ /// EN-001 — release the GPU memory backing an instance buffer
377
+ /// returned by `createInstanceBuffer`. Safe to call with handle 0
378
+ /// (no-op).
379
+ export function destroyInstanceBuffer(handle: number): void {
380
+ bloom_destroy_instance_buffer(handle);
381
+ }
382
+
383
+ /// EN-011 — create a planar reflection probe. Each frame, the engine
384
+ /// renders the world (minus excluded materials) from a mirror camera
385
+ /// across the given plane into an HDR RT, bound at `@group(2)
386
+ /// @binding(12)` on materials that opt in via
387
+ /// `setMaterialReflectionProbe`.
388
+ ///
389
+ /// Use for water surfaces where the static `env_tex` sky reflection
390
+ /// isn't enough — the planar reflection captures the actual scene
391
+ /// geometry (trees, bridges) reflected on the water plane, with
392
+ /// wave-normal wobble applied by the material's WGSL.
393
+ ///
394
+ /// Arguments:
395
+ /// - `planeY` — world-space Y offset of the reflective plane
396
+ /// - `normalX/Y/Z` — plane normal (typically (0,1,0) for water)
397
+ /// - `resolution` — square texture side in pixels; pass 0 to
398
+ /// default to half the swapchain width
399
+ ///
400
+ /// Returns a 1-based probe handle (0 on failure).
401
+ ///
402
+ /// V1 limits: one probe per plane, repainted every frame, hardcoded
403
+ /// exclude list (materials linked to a probe never appear in their
404
+ /// own reflection — the water plane doesn't show up in itself).
405
+ /// Future: cull-mode flip for correct front-face winding (V1 leaves
406
+ /// pipelines' compiled cull mode in place; the artifact is mostly
407
+ /// hidden for typical horizontal-water-from-above viewpoints).
408
+ ///
409
+ /// WGSL pattern in a water material:
410
+ /// ```wgsl
411
+ /// let screen_uv = clip_position.xy / vec2<f32>(frame.screen_resolution);
412
+ /// let perturb = wave_normal.xz * 0.05;
413
+ /// let refl = textureSample(planar_reflection_tex,
414
+ /// planar_reflection_samp,
415
+ /// screen_uv + perturb).rgb;
416
+ /// ```
417
+ export function createPlanarReflection(
418
+ planeY: number,
419
+ normalX: number, normalY: number, normalZ: number,
420
+ resolution: number,
421
+ ): number {
422
+ return bloom_create_planar_reflection(planeY, normalX, normalY, normalZ, resolution);
423
+ }
424
+
425
+ /// EN-011 — link `material` to a planar reflection probe (handle
426
+ /// returned by `createPlanarReflection`). The probe's RT is bound at
427
+ /// `@group(2) @binding(12)` on subsequent draws. Pass `probe = 0` to
428
+ /// unlink and revert to the default 1×1 black texture.
429
+ ///
430
+ /// Materials linked to any probe are automatically excluded from
431
+ /// every probe's render — the water surface doesn't reflect itself.
432
+ export function setMaterialReflectionProbe(material: number, probe: number): void {
433
+ bloom_set_material_reflection_probe(material, probe);
434
+ }
435
+
436
+ /// EN-014 — slot indices for `setMaterialTextureArray`.
437
+ export const TEXTURE_ARRAY_ALBEDO = 0;
438
+ export const TEXTURE_ARRAY_NORMAL = 1;
439
+ export const TEXTURE_ARRAY_MR = 2;
440
+
441
+ /// EN-014 — create a 2D texture array from a flat RGBA8 byte buffer.
442
+ /// All `layerCount` layers must share the same `width × height` (wgpu
443
+ /// requires uniform extent for D2Array). The buffer holds each layer
444
+ /// back-to-back: byte[0..(W·H·4)] = layer 0, byte[W·H·4..2·W·H·4] =
445
+ /// layer 1, and so on. Layer count is capped at 16 in V1.
446
+ ///
447
+ /// Returns a 1-based handle (0 on failure: zero count, zero extent,
448
+ /// or short buffer). Pair with `setMaterialTextureArray` to bind to
449
+ /// one of three slots (albedo / normal / MR) on a terrain material;
450
+ /// the WGSL fragment samples the array via:
451
+ /// ```wgsl
452
+ /// let albedo = textureSample(albedo_array, albedo_array_samp,
453
+ /// uv_world_xz, layer_idx);
454
+ /// ```
455
+ ///
456
+ /// IMPORTANT: pass `dataLen` and `layerCount` derived from manually-
457
+ /// tracked counters — NOT `bytes.length` if `bytes` was built via
458
+ /// `.push()` — Perry's `.length` reports the literal-init size, not
459
+ /// the post-push count. (See `feedback_perry_array_push.md`.)
460
+ export function createTextureArray(
461
+ bytes: number[], dataLen: number,
462
+ width: number, height: number, layerCount: number,
463
+ ): number {
464
+ return bloom_create_texture_array(bytes as any, dataLen, width, height, layerCount);
465
+ }
466
+
467
+ /// EN-014 V2 — texture-array pixel format codes for `createTextureArrayEx`.
468
+ /// `TEX_ARRAY_FORMAT_SRGB` (0) → Rgba8UnormSrgb (albedo / colour textures)
469
+ /// `TEX_ARRAY_FORMAT_LINEAR` (1) → Rgba8Unorm (normal / MR / data textures —
470
+ /// mandatory for normal maps so the GPU doesn't sRGB-decode the encoded
471
+ /// data and silently corrupt the channels).
472
+ export const TEX_ARRAY_FORMAT_SRGB: number = 0;
473
+ export const TEX_ARRAY_FORMAT_LINEAR: number = 1;
474
+
475
+ /// EN-014 V2 — create a texture array with explicit format + mip control.
476
+ ///
477
+ /// `format`:
478
+ /// `TEX_ARRAY_FORMAT_SRGB` (0) → Rgba8UnormSrgb (albedo / colour)
479
+ /// `TEX_ARRAY_FORMAT_LINEAR` (1) → Rgba8Unorm (normal / MR / data)
480
+ ///
481
+ /// `mipLevels`:
482
+ /// `1` → no mips (matches V1 `createTextureArray`; data is just mip 0)
483
+ /// `0` → auto-generate `floor(log2(max(w,h))) + 1` levels, filled by
484
+ /// point-downsample copies. V2.5 follow-up will upgrade to a
485
+ /// render-pass box filter for higher-quality minification.
486
+ /// `N` (N > 1) → not yet supported in V2; treated as auto-generate.
487
+ ///
488
+ /// Backwards compatible: `createTextureArray` (no Ex) stays available
489
+ /// and is equivalent to `createTextureArrayEx(.., TEX_ARRAY_FORMAT_SRGB, 1)`.
490
+ export function createTextureArrayEx(
491
+ bytes: number[], dataLen: number,
492
+ width: number, height: number, layerCount: number,
493
+ format: number, mipLevels: number,
494
+ ): number {
495
+ return bloom_create_texture_array_ex(bytes as any, dataLen, width, height, layerCount, format, mipLevels);
496
+ }
497
+
498
+ /// EN-014 — link a texture-array handle to a material at one of three
499
+ /// slots: `TEXTURE_ARRAY_ALBEDO` (binding 14), `TEXTURE_ARRAY_NORMAL`
500
+ /// (binding 15), `TEXTURE_ARRAY_MR` (binding 16). Pass `array = 0` to
501
+ /// revert the slot to the engine's 1×1×1 stub.
502
+ ///
503
+ /// Materials don't need to bind every slot — the stub is safe to
504
+ /// sample. A common pattern is to bind only `TEXTURE_ARRAY_ALBEDO`
505
+ /// for a non-PBR splat-mapped terrain.
506
+ export function setMaterialTextureArray(material: number, slot: number, array: number): void {
507
+ bloom_set_material_texture_array(material, slot, array);
508
+ }
509
+
510
+ /// EN-012 — shading-model selectors. Pass to `setMaterialShadingModel`.
511
+ export const SHADING_MODEL_DEFAULT_LIT = 0;
512
+ export const SHADING_MODEL_FOLIAGE = 1;
513
+ export const SHADING_MODEL_SUBSURFACE = 2; // V2 stub — currently behaves as default lit
514
+
515
+ /// EN-012 — switch a material's shading model. The game shader is
516
+ /// responsible for branching on `material.shading_model.x` and calling
517
+ /// either standard PBR or `shade_foliage` (wrap-lambert + transmission)
518
+ /// from `common/pbr.wgsl`. The engine just exposes the slot.
519
+ ///
520
+ /// V1 limitation: SSAO doesn't half-strength on backfaces — the
521
+ /// G-buffer doesn't carry an isFrontFace channel today. Documented as a
522
+ /// follow-up requirement on the EN-012 ticket.
523
+ export function setMaterialShadingModel(material: number, model: number): void {
524
+ bloom_set_material_shading_model(material, model);
525
+ }
526
+
527
+ /// EN-012 — set the foliage shading parameters for a material. Only
528
+ /// takes effect when `shading_model == SHADING_MODEL_FOLIAGE`.
529
+ ///
530
+ /// `transmissionR/G/B`: rgb tint for back-lit foliage (1,1,1 = neutral).
531
+ /// `transmissionAmount`: 0..1 — how much sun bleeds through the leaf.
532
+ /// `wrapFactor`: 0..1 — wrap-lambert intensity. 0 = standard lambert
533
+ /// (back face goes pure black), 1 = light wraps fully around to the
534
+ /// back face.
535
+ export function setMaterialFoliage(
536
+ material: number,
537
+ transmissionR: number, transmissionG: number, transmissionB: number,
538
+ transmissionAmount: number, wrapFactor: number,
539
+ ): void {
540
+ bloom_set_material_foliage(material, transmissionR, transmissionG, transmissionB, transmissionAmount, wrapFactor);
541
+ }
542
+
543
+ /**
544
+ * Phase 6 — file-backed material compile with hot reload. Reads the
545
+ * WGSL from disk, compiles it, and registers the path with the
546
+ * engine's hot-reload watcher. Editing the file while the game is
547
+ * running re-compiles the pipeline and replaces it in place — the
548
+ * material handle stays valid; existing draws automatically pick up
549
+ * the new shader on the next frame.
550
+ *
551
+ * Failures during reload (parse error, validation) keep the previous
552
+ * pipeline running; the error is logged but doesn't crash the game.
553
+ *
554
+ * `bucket` selects the same presets as the dedicated compile* APIs:
555
+ * 'opaque' | 'cutout' | 'transparent' | 'refractive' | 'additive'
556
+ */
557
+ export function compileMaterialFromFile(
558
+ path: string,
559
+ bucket: 'opaque' | 'cutout' | 'transparent' | 'refractive' | 'additive',
560
+ ): number {
561
+ const kind = bucket === 'opaque' ? 0
562
+ : bucket === 'transparent' ? 1
563
+ : bucket === 'refractive' ? 2
564
+ : bucket === 'additive' ? 3
565
+ : 4; // cutout
566
+ return bloom_compile_material_from_file(path as any, kind);
567
+ }
568
+
569
+ /**
570
+ * Phase 5 — material descriptor loader. Compiles a material from
571
+ * a typed descriptor in one call:
572
+ * - resolves `shader` via `compileMaterialFromFile` (gets hot
573
+ * reload)
574
+ * - applies `params` via `setMaterialParams` if provided
575
+ *
576
+ * Returns the material handle (0 on failure).
577
+ *
578
+ * Why a typed object instead of a JSON string: Perry's runtime
579
+ * `JSON.parse` mishandles array `.length`, so a JSON-string variant
580
+ * would force every game to roll its own parser. Games that DO
581
+ * want JSON-on-disk should preprocess at build time (see
582
+ * `shooter/tools/build-world.ts` for the pattern) and emit a TS
583
+ * module that calls `loadMaterial` with literal descriptors.
584
+ */
585
+ export interface MaterialDesc {
586
+ shader: string;
587
+ bucket: 'opaque' | 'cutout' | 'transparent' | 'refractive' | 'additive';
588
+ params?: number[];
589
+ }
590
+
591
+ export function loadMaterial(desc: MaterialDesc): number {
592
+ const handle = compileMaterialFromFile(desc.shader, desc.bucket);
593
+ if (handle > 0 && desc.params) {
594
+ // Bind to a local first — Perry currently mishandles `.length`
595
+ // on an object field passed directly into an FFI call (the FFI
596
+ // sees count = 0). Re-binding to a local lets `.length` evaluate
597
+ // before the FFI call is laid out.
598
+ const p = desc.params;
599
+ if (p.length > 0) {
600
+ bloom_set_material_params(handle, p as any, p.length);
601
+ }
602
+ }
603
+ return handle;
604
+ }
605
+
606
+ /// Draw a mesh with a material. `mesh` must be a Model created via
607
+ /// `createMesh` or `loadModel`. Transform is a position + uniform
608
+ /// scale; tint is an RGBA color multiplied into PerDraw.model_tint.
609
+ /// `meshIdx` selects which primitive of a multi-mesh GLB to draw —
610
+ /// default 0 for single-mesh models. Loop 0..mesh.meshCount when
611
+ /// rendering a multi-primitive GLB through a custom material.
612
+ export function drawMeshWithMaterial(
613
+ material: number, mesh: Model,
614
+ position: Vec3, scale: number, tint: Color,
615
+ meshIdx: number = 0,
616
+ ): void {
617
+ bloom_draw_material(
618
+ material, mesh.handle, meshIdx,
619
+ position.x, position.y, position.z, scale,
620
+ tint.r, tint.g, tint.b, tint.a,
621
+ );
622
+ }
623
+
624
+ /// Draw every primitive of a multi-mesh GLB with the same material.
625
+ /// Convenience wrapper around `drawMeshWithMaterial` that loops
626
+ /// 0..mesh.meshCount internally.
627
+ export function drawModelWithMaterial(
628
+ material: number, mesh: Model,
629
+ position: Vec3, scale: number, tint: Color,
630
+ ): void {
631
+ for (let i = 0; i < mesh.meshCount; i = i + 1) {
632
+ bloom_draw_material(
633
+ material, mesh.handle, i,
634
+ position.x, position.y, position.z, scale,
635
+ tint.r, tint.g, tint.b, tint.a,
636
+ );
637
+ }
638
+ }
639
+
640
+ export function loadModelAnimation(path: string): number {
641
+ return bloom_load_model_animation(path as any);
642
+ }
643
+
644
+ export function updateModelAnimation(handle: number, animIndex: number, time: number, scale: number, px: number, py: number, pz: number, rotY: number): void {
645
+ bloom_update_model_animation(handle, animIndex, time, scale, px, py, pz, rotY);
646
+ }
647
+
648
+ export function createMesh(vertices: number[], indices: number[]): Model {
649
+ // vertices: flat array of [x,y,z, nx,ny,nz, r,g,b,a, u,v] per vertex (12 floats each)
650
+ // NOTE: `vertices.length` and `indices.length` here only return the
651
+ // correct value for arrays built via literals or `new Array(N)` +
652
+ // index assignment. Arrays built via `.push()` reflect the LITERAL
653
+ // initialization size as `.length`, not the post-push size (a
654
+ // Perry codegen bug). For `.push`-built data, use createMeshExplicit
655
+ // and pass the counts manually.
656
+ const handle = bloom_create_mesh(vertices as any, vertices.length / 12, indices as any, indices.length);
657
+ return makeModel(handle, 1, 1);
658
+ }
659
+
660
+ /// Explicit-count variant of createMesh — pass `vertexCount` (number
661
+ /// of complete 12-float vertex records) and `indexCount` directly.
662
+ /// Use this when the underlying `number[]` arrays were built with
663
+ /// `.push()`, since Perry's `.length` doesn't reflect post-push size.
664
+ export function createMeshExplicit(
665
+ vertices: number[], vertexCount: number,
666
+ indices: number[], indexCount: number,
667
+ ): Model {
668
+ const handle = bloom_create_mesh(vertices as any, vertexCount, indices as any, indexCount);
669
+ return makeModel(handle, 1, 1);
670
+ }
671
+
672
+ export function setAmbientLight(color: Color, intensity: number): void {
673
+ bloom_set_ambient_light(color.r, color.g, color.b, intensity);
674
+ }
675
+
676
+ export function setDirectionalLight(direction: Vec3, color: Color, intensity: number): void {
677
+ bloom_set_directional_light(direction.x, direction.y, direction.z, color.r, color.g, color.b, intensity);
678
+ }
679
+
680
+ // EN-005 — Hillaire 2020 procedural sky.
681
+ //
682
+ // `setProceduralSky(true)` swaps the static HDR-panorama background
683
+ // for a physics-based atmosphere driven by Rayleigh + Mie scattering.
684
+ // `setSunDirection` then steers the sun: the sky-view LUT re-bakes
685
+ // on the next frame and the sun disk + transmittance update together.
686
+ //
687
+ // `setProceduralSky(false)` returns to the panorama path; the
688
+ // existing `loadEnvironment` / `setEnvironmentIntensity` flow is
689
+ // untouched.
690
+
691
+ export interface ProceduralSkyOptions {
692
+ /** Rayleigh density multiplier. 1.0 = Earth standard. Higher = bluer
693
+ * thicker air; lower = thinner. */
694
+ rayleighDensity?: number;
695
+ /** Mie density multiplier. Drives haze + sun-glow size. 1.0 = Earth
696
+ * standard, raise for hazy/dusty scenes. */
697
+ mieDensity?: number;
698
+ /** Ground albedo (0..1). Affects how much light bounces back up
699
+ * into the lower atmosphere. 0.1 = soil/grass, 0.9 = snow. */
700
+ groundAlbedo?: number;
701
+ }
702
+
703
+ export function setProceduralSky(enabled: boolean, opts?: ProceduralSkyOptions): void {
704
+ const rd = opts?.rayleighDensity ?? 1.0;
705
+ const md = opts?.mieDensity ?? 1.0;
706
+ const ga = opts?.groundAlbedo ?? 0.1;
707
+ bloom_set_procedural_sky(enabled ? 1 : 0, rd, md, ga);
708
+ }
709
+
710
+ export function setSunDirection(direction: Vec3, intensity: number = 1.0): void {
711
+ bloom_set_sun_direction(direction.x, direction.y, direction.z, intensity);
712
+ }
713
+
714
+ declare function bloom_set_joint_test(joint: number, angle: number): void;
715
+ export function setJointTest(joint: number, angle: number): void {
716
+ bloom_set_joint_test(joint, angle);
717
+ }
718
+
719
+ // Async / threaded loading
720
+
721
+ declare function bloom_stage_model(path: number): number;
722
+ declare function bloom_commit_model(handle: number): number;
723
+
724
+ export async function loadModelAsync(path: string): Promise<Model> {
725
+ const pathLower = (path as string).toLowerCase();
726
+ if (pathLower.endsWith('.obj')) {
727
+ const parsed = await spawn(() => {
728
+ const text: string = bloom_read_file(path as any) as any;
729
+ return text ? parseOBJ(text) : null;
730
+ });
731
+ if (parsed) {
732
+ const handle = bloom_create_mesh(
733
+ parsed.vertices as any,
734
+ parsed.vertices.length / 12,
735
+ parsed.indices as any,
736
+ parsed.indices.length,
737
+ );
738
+ return makeModel(handle, 1, 1);
739
+ }
740
+ return makeModel(0);
741
+ }
742
+ const stagingHandle = await spawn(() => bloom_stage_model(path as any));
743
+ const handle = bloom_commit_model(stagingHandle);
744
+ return makeModel(handle);
745
+ }
746
+
747
+ export function stageModels(paths: string[]): number[] {
748
+ return parallelMap(paths, (path: string) => bloom_stage_model(path as any));
749
+ }
750
+
751
+ export function commitModel(stagingHandle: number): Model {
752
+ const handle = bloom_commit_model(stagingHandle);
753
+ return makeModel(handle);
754
+ }
755
+
756
+ // ---------------------------------------------------------------------
757
+ // EN-015 V1 — Octahedral imposter / billboard helpers.
758
+ //
759
+ // V1 ships the runtime piece only: the WGSL helper library
760
+ // (`common/imposter.wgsl`) plus this TS-side LOD selector +
761
+ // `drawImposterAtlas` wrapper. Bake tooling is a follow-up — V1 expects
762
+ // games to bake atlases externally (Blender's ScreenSpace add-on,
763
+ // Unity Tree Creator, etc.) until the engine bake tool ships.
764
+ //
765
+ // The atlas convention is fixed at 8×8 octahedral views (64 cells
766
+ // total) packed into a single RGBA8 texture.
767
+ //
768
+ // Typical game-side imposter material WGSL (drop in your own .wgsl
769
+ // file and pass to compileMaterial):
770
+ //
771
+ // #include "material_abi.wgsl"
772
+ // #include "common/imposter.wgsl"
773
+ //
774
+ // struct VsOut {
775
+ // @builtin(position) clip_pos: vec4<f32>,
776
+ // @location(0) view_dir: vec3<f32>,
777
+ // @location(1) uv: vec2<f32>,
778
+ // };
779
+ //
780
+ // @vertex
781
+ // fn vs_main(@builtin(vertex_index) vid: u32) -> VsOut {
782
+ // // node.transform[3].xyz holds the per-instance world position;
783
+ // // node.scale_x is the imposter scale.
784
+ // let center = node.transform[3].xyz;
785
+ // let bb = billboard_quad(
786
+ // center, node.scale_x,
787
+ // view.camera_pos.xyz, vec3<f32>(0.0, 1.0, 0.0),
788
+ // vid,
789
+ // );
790
+ // var out: VsOut;
791
+ // out.clip_pos = view.view_proj * vec4<f32>(bb.world_pos, 1.0);
792
+ // out.view_dir = normalize(view.camera_pos.xyz - center);
793
+ // out.uv = bb.uv;
794
+ // return out;
795
+ // }
796
+ //
797
+ // @fragment
798
+ // fn fs_main(in: VsOut) -> @location(0) vec4<f32> {
799
+ // let atlas_uv = imposter_atlas_uv(in.view_dir, in.uv);
800
+ // return textureSample(material_albedo, material_sampler, atlas_uv);
801
+ // }
802
+ //
803
+ // Then at runtime:
804
+ //
805
+ // const useImposter = pickImposterLOD(
806
+ // camera.x, camera.y, camera.z,
807
+ // tree.x, tree.y, tree.z,
808
+ // 50.0,
809
+ // );
810
+ // if (useImposter) {
811
+ // drawImposterAtlas(impMaterial, impAtlasMesh, treePos, treeScale);
812
+ // } else {
813
+ // drawModel(treeModel, treePos, treeScale, WHITE);
814
+ // }
815
+ // ---------------------------------------------------------------------
816
+
817
+ /// EN-015 — pick LOD by distance. Returns true if the camera is far
818
+ /// enough that the imposter should be drawn in place of the full mesh.
819
+ ///
820
+ /// Typical `switchDistance` is 40–60 m for trees. To mitigate pop at
821
+ /// the LOD boundary, layer a small hysteresis band on top from the
822
+ /// caller (e.g. switch to imposter at 50 m, switch back to mesh at
823
+ /// 47 m); when TAA is enabled the residual flicker is mostly resolved
824
+ /// across frames.
825
+ export function pickImposterLOD(
826
+ cameraX: number, cameraY: number, cameraZ: number,
827
+ worldX: number, worldY: number, worldZ: number,
828
+ switchDistance: number,
829
+ ): boolean {
830
+ const dx = cameraX - worldX;
831
+ const dy = cameraY - worldY;
832
+ const dz = cameraZ - worldZ;
833
+ const distSq = dx * dx + dy * dy + dz * dz;
834
+ const threshSq = switchDistance * switchDistance;
835
+ return distSq > threshSq;
836
+ }
837
+
838
+ /// EN-015 — draw a billboard quad sampling an imposter atlas.
839
+ ///
840
+ /// V1 is a thin wrapper around `drawMeshWithMaterial`: the game
841
+ /// supplies its own quad mesh (any 4-vertex / 2-triangle plane the
842
+ /// imposter material's vertex shader will reposition via
843
+ /// `billboard_quad`). The atlas texture is bound through the standard
844
+ /// material albedo slot before this call (via the engine's material
845
+ /// param / texture binding APIs).
846
+ ///
847
+ /// Future revs may add a dedicated FFI that submits a hard-coded unit
848
+ /// quad so games don't need to author a quad mesh; for V1 we keep the
849
+ /// API surface tight and reuse the existing draw path.
850
+ export function drawImposterAtlas(
851
+ material: number, quadMesh: Model,
852
+ position: Vec3, scale: number,
853
+ ): void {
854
+ bloom_draw_material(
855
+ material, quadMesh.handle, 0,
856
+ position.x, position.y, position.z, scale,
857
+ 1.0, 1.0, 1.0, 1.0,
858
+ );
859
+ }