@zephyr3d/scene 0.7.1 → 0.8.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 (441) hide show
  1. package/dist/animation/animation.js +0 -18
  2. package/dist/animation/animation.js.map +1 -1
  3. package/dist/animation/animationset.js +200 -3
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/ik/ccd_solver.js +371 -0
  6. package/dist/animation/ik/ccd_solver.js.map +1 -0
  7. package/dist/animation/ik/fabrik_solver.js +398 -0
  8. package/dist/animation/ik/fabrik_solver.js.map +1 -0
  9. package/dist/animation/ik/ik_angle_constraint.js +181 -0
  10. package/dist/animation/ik/ik_angle_constraint.js.map +1 -0
  11. package/dist/animation/ik/ik_chain.js +163 -0
  12. package/dist/animation/ik/ik_chain.js.map +1 -0
  13. package/dist/animation/ik/ik_constraint.js +25 -0
  14. package/dist/animation/ik/ik_constraint.js.map +1 -0
  15. package/dist/animation/ik/ik_pole_constraint.js +128 -0
  16. package/dist/animation/ik/ik_pole_constraint.js.map +1 -0
  17. package/dist/animation/ik/ik_solver.js +48 -0
  18. package/dist/animation/ik/ik_solver.js.map +1 -0
  19. package/dist/animation/ik/ik_track.js +96 -0
  20. package/dist/animation/ik/ik_track.js.map +1 -0
  21. package/dist/animation/ik/ik_utils.js +191 -0
  22. package/dist/animation/ik/ik_utils.js.map +1 -0
  23. package/dist/animation/ik/two_bone_ik_solver.js +331 -0
  24. package/dist/animation/ik/two_bone_ik_solver.js.map +1 -0
  25. package/dist/animation/ik_modifier.js +61 -0
  26. package/dist/animation/ik_modifier.js.map +1 -0
  27. package/dist/animation/ik_postprocessor.js +71 -0
  28. package/dist/animation/ik_postprocessor.js.map +1 -0
  29. package/dist/animation/manual_transform_processor.js +156 -0
  30. package/dist/animation/manual_transform_processor.js.map +1 -0
  31. package/dist/animation/skeleton.js +55 -51
  32. package/dist/animation/skeleton.js.map +1 -1
  33. package/dist/animation/skeleton_modifier.js +38 -0
  34. package/dist/animation/skeleton_modifier.js.map +1 -0
  35. package/dist/animation/skeleton_postprocessor.js +50 -0
  36. package/dist/animation/skeleton_postprocessor.js.map +1 -0
  37. package/dist/animation/spring/multi_chain_spring_system.js +503 -0
  38. package/dist/animation/spring/multi_chain_spring_system.js.map +1 -0
  39. package/dist/animation/spring/spring_bone.js +240 -0
  40. package/dist/animation/spring/spring_bone.js.map +1 -0
  41. package/dist/animation/spring/spring_bone_collider.js +198 -0
  42. package/dist/animation/spring/spring_bone_collider.js.map +1 -0
  43. package/dist/animation/spring/spring_bone_constraint.js +170 -0
  44. package/dist/animation/spring/spring_bone_constraint.js.map +1 -0
  45. package/dist/animation/spring/spring_bone_system.js +328 -0
  46. package/dist/animation/spring/spring_bone_system.js.map +1 -0
  47. package/dist/animation/spring/spring_chain.js +103 -0
  48. package/dist/animation/spring/spring_chain.js.map +1 -0
  49. package/dist/animation/spring/spring_collider.js +247 -0
  50. package/dist/animation/spring/spring_collider.js.map +1 -0
  51. package/dist/animation/spring/spring_constraint.js +21 -0
  52. package/dist/animation/spring/spring_constraint.js.map +1 -0
  53. package/dist/animation/spring/spring_particle.js +20 -0
  54. package/dist/animation/spring/spring_particle.js.map +1 -0
  55. package/dist/animation/spring/spring_system.js +526 -0
  56. package/dist/animation/spring/spring_system.js.map +1 -0
  57. package/dist/animation/spring_modifier.js +45 -0
  58. package/dist/animation/spring_modifier.js.map +1 -0
  59. package/dist/animation/spring_postprocessor.js +54 -0
  60. package/dist/animation/spring_postprocessor.js.map +1 -0
  61. package/dist/app/screen.js +1 -1
  62. package/dist/app/screen.js.map +1 -1
  63. package/dist/asset/model.js +10 -6
  64. package/dist/asset/model.js.map +1 -1
  65. package/dist/camera/perspectivecamera.js +3 -3
  66. package/dist/camera/perspectivecamera.js.map +1 -1
  67. package/dist/index.d.ts +1400 -4
  68. package/dist/index.js +16 -0
  69. package/dist/index.js.map +1 -1
  70. package/dist/material/mixins/lightmodel/blinnphong.js +66 -4
  71. package/dist/material/mixins/lightmodel/blinnphong.js.map +1 -1
  72. package/dist/material/mixins/pbr/common.js +20 -17
  73. package/dist/material/mixins/pbr/common.js.map +1 -1
  74. package/dist/material/shader/helper.js +5 -3
  75. package/dist/material/shader/helper.js.map +1 -1
  76. package/dist/render/gpu_picking.js +100 -0
  77. package/dist/render/gpu_picking.js.map +1 -0
  78. package/dist/render/rendergraph/device_pool_allocator.js +41 -0
  79. package/dist/render/rendergraph/device_pool_allocator.js.map +1 -0
  80. package/dist/render/rendergraph/executor.js +146 -0
  81. package/dist/render/rendergraph/executor.js.map +1 -0
  82. package/dist/render/rendergraph/forward_plus_builder.js +414 -0
  83. package/dist/render/rendergraph/forward_plus_builder.js.map +1 -0
  84. package/dist/render/rendergraph/rendergraph.js +306 -0
  85. package/dist/render/rendergraph/rendergraph.js.map +1 -0
  86. package/dist/render/rendergraph/types.js +57 -0
  87. package/dist/render/rendergraph/types.js.map +1 -0
  88. package/dist/render/sky_motion_vector.js +85 -0
  89. package/dist/render/sky_motion_vector.js.map +1 -0
  90. package/dist/scene/mesh.js +15 -23
  91. package/dist/scene/mesh.js.map +1 -1
  92. package/dist/utility/serialization/scene/animation.js +24 -23
  93. package/dist/utility/serialization/scene/animation.js.map +1 -1
  94. package/dist/utility/serialization/scene/material.js +62 -0
  95. package/dist/utility/serialization/scene/material.js.map +1 -1
  96. package/dist/utility/serialization/scene/node.js +1 -1
  97. package/package.json +3 -3
  98. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  99. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  100. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  101. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  102. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  103. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  104. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  105. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  106. package/dist/src/animation/animation.js +0 -127
  107. package/dist/src/animation/animation.js.map +0 -1
  108. package/dist/src/animation/animationset.js +0 -255
  109. package/dist/src/animation/animationset.js.map +0 -1
  110. package/dist/src/animation/animationtrack.js +0 -34
  111. package/dist/src/animation/animationtrack.js.map +0 -1
  112. package/dist/src/animation/eulerrotationtrack.js +0 -52
  113. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  114. package/dist/src/animation/morphtarget.js +0 -93
  115. package/dist/src/animation/morphtarget.js.map +0 -1
  116. package/dist/src/animation/morphtrack.js +0 -70
  117. package/dist/src/animation/morphtrack.js.map +0 -1
  118. package/dist/src/animation/proptrack.js +0 -161
  119. package/dist/src/animation/proptrack.js.map +0 -1
  120. package/dist/src/animation/rotationtrack.js +0 -51
  121. package/dist/src/animation/rotationtrack.js.map +0 -1
  122. package/dist/src/animation/scaletrack.js +0 -50
  123. package/dist/src/animation/scaletrack.js.map +0 -1
  124. package/dist/src/animation/skeleton.js +0 -204
  125. package/dist/src/animation/skeleton.js.map +0 -1
  126. package/dist/src/animation/translationtrack.js +0 -50
  127. package/dist/src/animation/translationtrack.js.map +0 -1
  128. package/dist/src/app/app.js +0 -129
  129. package/dist/src/app/app.js.map +0 -1
  130. package/dist/src/app/inputmgr.js +0 -267
  131. package/dist/src/app/inputmgr.js.map +0 -1
  132. package/dist/src/asset/assetmanager.js +0 -404
  133. package/dist/src/asset/assetmanager.js.map +0 -1
  134. package/dist/src/asset/builtin.js +0 -337
  135. package/dist/src/asset/builtin.js.map +0 -1
  136. package/dist/src/asset/loaders/dds/dds.js +0 -470
  137. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  138. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  139. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  140. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  141. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  142. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  143. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  144. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  145. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  146. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  147. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  148. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  149. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  150. package/dist/src/asset/loaders/loader.js +0 -45
  151. package/dist/src/asset/loaders/loader.js.map +0 -1
  152. package/dist/src/asset/model.js +0 -414
  153. package/dist/src/asset/model.js.map +0 -1
  154. package/dist/src/blitter/bilateralblur.js +0 -221
  155. package/dist/src/blitter/bilateralblur.js.map +0 -1
  156. package/dist/src/blitter/blitter.js +0 -390
  157. package/dist/src/blitter/blitter.js.map +0 -1
  158. package/dist/src/blitter/box.js +0 -118
  159. package/dist/src/blitter/box.js.map +0 -1
  160. package/dist/src/blitter/copy.js +0 -22
  161. package/dist/src/blitter/copy.js.map +0 -1
  162. package/dist/src/blitter/gaussianblur.js +0 -228
  163. package/dist/src/blitter/gaussianblur.js.map +0 -1
  164. package/dist/src/camera/base.js +0 -92
  165. package/dist/src/camera/base.js.map +0 -1
  166. package/dist/src/camera/camera.js +0 -1005
  167. package/dist/src/camera/camera.js.map +0 -1
  168. package/dist/src/camera/fps.js +0 -238
  169. package/dist/src/camera/fps.js.map +0 -1
  170. package/dist/src/camera/orbit.js +0 -245
  171. package/dist/src/camera/orbit.js.map +0 -1
  172. package/dist/src/camera/orthocamera.js +0 -167
  173. package/dist/src/camera/orthocamera.js.map +0 -1
  174. package/dist/src/camera/perspectivecamera.js +0 -141
  175. package/dist/src/camera/perspectivecamera.js.map +0 -1
  176. package/dist/src/index.js +0 -120
  177. package/dist/src/index.js.map +0 -1
  178. package/dist/src/material/blinn.js +0 -81
  179. package/dist/src/material/blinn.js.map +0 -1
  180. package/dist/src/material/grassmaterial.js +0 -113
  181. package/dist/src/material/grassmaterial.js.map +0 -1
  182. package/dist/src/material/lambert.js +0 -92
  183. package/dist/src/material/lambert.js.map +0 -1
  184. package/dist/src/material/material.js +0 -301
  185. package/dist/src/material/material.js.map +0 -1
  186. package/dist/src/material/meshmaterial.js +0 -704
  187. package/dist/src/material/meshmaterial.js.map +0 -1
  188. package/dist/src/material/mixins/albedocolor.js +0 -76
  189. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  190. package/dist/src/material/mixins/foliage.js +0 -47
  191. package/dist/src/material/mixins/foliage.js.map +0 -1
  192. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  193. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  194. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  195. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  196. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  197. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  198. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  199. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  200. package/dist/src/material/mixins/lit.js +0 -476
  201. package/dist/src/material/mixins/lit.js.map +0 -1
  202. package/dist/src/material/mixins/pbr/common.js +0 -918
  203. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  204. package/dist/src/material/mixins/texture.js +0 -172
  205. package/dist/src/material/mixins/texture.js.map +0 -1
  206. package/dist/src/material/mixins/vertexcolor.js +0 -56
  207. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  208. package/dist/src/material/particle.js +0 -178
  209. package/dist/src/material/particle.js.map +0 -1
  210. package/dist/src/material/pbrmr.js +0 -97
  211. package/dist/src/material/pbrmr.js.map +0 -1
  212. package/dist/src/material/pbrsg.js +0 -97
  213. package/dist/src/material/pbrsg.js.map +0 -1
  214. package/dist/src/material/shader/helper.js +0 -1209
  215. package/dist/src/material/shader/helper.js.map +0 -1
  216. package/dist/src/material/terrain-cm.js +0 -606
  217. package/dist/src/material/terrain-cm.js.map +0 -1
  218. package/dist/src/material/terrainmaterial.js +0 -375
  219. package/dist/src/material/terrainmaterial.js.map +0 -1
  220. package/dist/src/material/unlit.js +0 -41
  221. package/dist/src/material/unlit.js.map +0 -1
  222. package/dist/src/material/water.js +0 -417
  223. package/dist/src/material/water.js.map +0 -1
  224. package/dist/src/posteffect/bloom.js +0 -361
  225. package/dist/src/posteffect/bloom.js.map +0 -1
  226. package/dist/src/posteffect/compositor.js +0 -226
  227. package/dist/src/posteffect/compositor.js.map +0 -1
  228. package/dist/src/posteffect/fxaa.js +0 -273
  229. package/dist/src/posteffect/fxaa.js.map +0 -1
  230. package/dist/src/posteffect/grayscale.js +0 -69
  231. package/dist/src/posteffect/grayscale.js.map +0 -1
  232. package/dist/src/posteffect/motionblur.js +0 -96
  233. package/dist/src/posteffect/motionblur.js.map +0 -1
  234. package/dist/src/posteffect/posteffect.js +0 -126
  235. package/dist/src/posteffect/posteffect.js.map +0 -1
  236. package/dist/src/posteffect/sao.js +0 -324
  237. package/dist/src/posteffect/sao.js.map +0 -1
  238. package/dist/src/posteffect/ssr.js +0 -489
  239. package/dist/src/posteffect/ssr.js.map +0 -1
  240. package/dist/src/posteffect/taa.js +0 -172
  241. package/dist/src/posteffect/taa.js.map +0 -1
  242. package/dist/src/posteffect/tonemap.js +0 -94
  243. package/dist/src/posteffect/tonemap.js.map +0 -1
  244. package/dist/src/render/abuffer_oit.js +0 -361
  245. package/dist/src/render/abuffer_oit.js.map +0 -1
  246. package/dist/src/render/clipmap.js +0 -851
  247. package/dist/src/render/clipmap.js.map +0 -1
  248. package/dist/src/render/cluster_light.js +0 -333
  249. package/dist/src/render/cluster_light.js.map +0 -1
  250. package/dist/src/render/cull_visitor.js +0 -187
  251. package/dist/src/render/cull_visitor.js.map +0 -1
  252. package/dist/src/render/depthpass.js +0 -68
  253. package/dist/src/render/depthpass.js.map +0 -1
  254. package/dist/src/render/drawable_mixin.js +0 -227
  255. package/dist/src/render/drawable_mixin.js.map +0 -1
  256. package/dist/src/render/envlight.js +0 -463
  257. package/dist/src/render/envlight.js.map +0 -1
  258. package/dist/src/render/fbm_wavegenerator.js +0 -251
  259. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  260. package/dist/src/render/fft_wavegenerator.js +0 -1006
  261. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  262. package/dist/src/render/fullscreenquad.js +0 -38
  263. package/dist/src/render/fullscreenquad.js.map +0 -1
  264. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  265. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  266. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  267. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  268. package/dist/src/render/hzb.js +0 -273
  269. package/dist/src/render/hzb.js.map +0 -1
  270. package/dist/src/render/lightpass.js +0 -172
  271. package/dist/src/render/lightpass.js.map +0 -1
  272. package/dist/src/render/objectcolorpass.js +0 -51
  273. package/dist/src/render/objectcolorpass.js.map +0 -1
  274. package/dist/src/render/primitive.js +0 -364
  275. package/dist/src/render/primitive.js.map +0 -1
  276. package/dist/src/render/render_queue.js +0 -467
  277. package/dist/src/render/render_queue.js.map +0 -1
  278. package/dist/src/render/renderbundle_wrapper.js +0 -152
  279. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  280. package/dist/src/render/renderer.js +0 -455
  281. package/dist/src/render/renderer.js.map +0 -1
  282. package/dist/src/render/renderpass.js +0 -200
  283. package/dist/src/render/renderpass.js.map +0 -1
  284. package/dist/src/render/shadowmap_pass.js +0 -56
  285. package/dist/src/render/shadowmap_pass.js.map +0 -1
  286. package/dist/src/render/sky.js +0 -1103
  287. package/dist/src/render/sky.js.map +0 -1
  288. package/dist/src/render/weightedblended_oit.js +0 -168
  289. package/dist/src/render/weightedblended_oit.js.map +0 -1
  290. package/dist/src/scene/batchgroup.js +0 -162
  291. package/dist/src/scene/batchgroup.js.map +0 -1
  292. package/dist/src/scene/environment.js +0 -209
  293. package/dist/src/scene/environment.js.map +0 -1
  294. package/dist/src/scene/graph_node.js +0 -72
  295. package/dist/src/scene/graph_node.js.map +0 -1
  296. package/dist/src/scene/light.js +0 -416
  297. package/dist/src/scene/light.js.map +0 -1
  298. package/dist/src/scene/mesh.js +0 -341
  299. package/dist/src/scene/mesh.js.map +0 -1
  300. package/dist/src/scene/octree.js +0 -649
  301. package/dist/src/scene/octree.js.map +0 -1
  302. package/dist/src/scene/particlesys.js +0 -738
  303. package/dist/src/scene/particlesys.js.map +0 -1
  304. package/dist/src/scene/raycast_visitor.js +0 -103
  305. package/dist/src/scene/raycast_visitor.js.map +0 -1
  306. package/dist/src/scene/scene.js +0 -284
  307. package/dist/src/scene/scene.js.map +0 -1
  308. package/dist/src/scene/scene_node.js +0 -732
  309. package/dist/src/scene/scene_node.js.map +0 -1
  310. package/dist/src/scene/terrain/grass.js +0 -278
  311. package/dist/src/scene/terrain/grass.js.map +0 -1
  312. package/dist/src/scene/terrain/heightfield.js +0 -475
  313. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  314. package/dist/src/scene/terrain/patch.js +0 -530
  315. package/dist/src/scene/terrain/patch.js.map +0 -1
  316. package/dist/src/scene/terrain/quadtree.js +0 -461
  317. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  318. package/dist/src/scene/terrain/terrain.js +0 -246
  319. package/dist/src/scene/terrain/terrain.js.map +0 -1
  320. package/dist/src/scene/terrain-cm/grass.js +0 -594
  321. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  322. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  323. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  324. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  325. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  326. package/dist/src/scene/water.js +0 -374
  327. package/dist/src/scene/water.js.map +0 -1
  328. package/dist/src/shaders/atmosphere.js +0 -957
  329. package/dist/src/shaders/atmosphere.js.map +0 -1
  330. package/dist/src/shaders/fog.js +0 -112
  331. package/dist/src/shaders/fog.js.map +0 -1
  332. package/dist/src/shaders/misc.js +0 -266
  333. package/dist/src/shaders/misc.js.map +0 -1
  334. package/dist/src/shaders/noise.js +0 -222
  335. package/dist/src/shaders/noise.js.map +0 -1
  336. package/dist/src/shaders/pbr.js +0 -51
  337. package/dist/src/shaders/pbr.js.map +0 -1
  338. package/dist/src/shaders/shadow.js +0 -636
  339. package/dist/src/shaders/shadow.js.map +0 -1
  340. package/dist/src/shaders/ssr.js +0 -490
  341. package/dist/src/shaders/ssr.js.map +0 -1
  342. package/dist/src/shaders/temporal.js +0 -215
  343. package/dist/src/shaders/temporal.js.map +0 -1
  344. package/dist/src/shaders/water.js +0 -756
  345. package/dist/src/shaders/water.js.map +0 -1
  346. package/dist/src/shadow/esm.js +0 -237
  347. package/dist/src/shadow/esm.js.map +0 -1
  348. package/dist/src/shadow/pcf_opt.js +0 -181
  349. package/dist/src/shadow/pcf_opt.js.map +0 -1
  350. package/dist/src/shadow/pcf_pd.js +0 -189
  351. package/dist/src/shadow/pcf_pd.js.map +0 -1
  352. package/dist/src/shadow/shader.js +0 -37
  353. package/dist/src/shadow/shader.js.map +0 -1
  354. package/dist/src/shadow/shadow_impl.js +0 -15
  355. package/dist/src/shadow/shadow_impl.js.map +0 -1
  356. package/dist/src/shadow/shadowmapper.js +0 -790
  357. package/dist/src/shadow/shadowmapper.js.map +0 -1
  358. package/dist/src/shadow/ssm.js +0 -159
  359. package/dist/src/shadow/ssm.js.map +0 -1
  360. package/dist/src/shadow/vsm.js +0 -297
  361. package/dist/src/shadow/vsm.js.map +0 -1
  362. package/dist/src/shapes/box.js +0 -386
  363. package/dist/src/shapes/box.js.map +0 -1
  364. package/dist/src/shapes/cylinder.js +0 -125
  365. package/dist/src/shapes/cylinder.js.map +0 -1
  366. package/dist/src/shapes/plane.js +0 -88
  367. package/dist/src/shapes/plane.js.map +0 -1
  368. package/dist/src/shapes/shape.js +0 -87
  369. package/dist/src/shapes/shape.js.map +0 -1
  370. package/dist/src/shapes/sphere.js +0 -114
  371. package/dist/src/shapes/sphere.js.map +0 -1
  372. package/dist/src/shapes/tetrahedron.js +0 -188
  373. package/dist/src/shapes/tetrahedron.js.map +0 -1
  374. package/dist/src/shapes/torus.js +0 -111
  375. package/dist/src/shapes/torus.js.map +0 -1
  376. package/dist/src/utility/aabbtree.js +0 -400
  377. package/dist/src/utility/aabbtree.js.map +0 -1
  378. package/dist/src/utility/bounding_volume.js +0 -29
  379. package/dist/src/utility/bounding_volume.js.map +0 -1
  380. package/dist/src/utility/debug.js +0 -28
  381. package/dist/src/utility/debug.js.map +0 -1
  382. package/dist/src/utility/draco/decoder.js +0 -116
  383. package/dist/src/utility/draco/decoder.js.map +0 -1
  384. package/dist/src/utility/misc.js +0 -105
  385. package/dist/src/utility/misc.js.map +0 -1
  386. package/dist/src/utility/panorama.js +0 -163
  387. package/dist/src/utility/panorama.js.map +0 -1
  388. package/dist/src/utility/pmrem.js +0 -354
  389. package/dist/src/utility/pmrem.js.map +0 -1
  390. package/dist/src/utility/rendermipmap.js +0 -115
  391. package/dist/src/utility/rendermipmap.js.map +0 -1
  392. package/dist/src/utility/serialization/json.js +0 -402
  393. package/dist/src/utility/serialization/json.js.map +0 -1
  394. package/dist/src/utility/serialization/manager.js +0 -623
  395. package/dist/src/utility/serialization/manager.js.map +0 -1
  396. package/dist/src/utility/serialization/scene/animation.js +0 -248
  397. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  398. package/dist/src/utility/serialization/scene/batch.js +0 -59
  399. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  400. package/dist/src/utility/serialization/scene/camera.js +0 -790
  401. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  402. package/dist/src/utility/serialization/scene/common.js +0 -222
  403. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  404. package/dist/src/utility/serialization/scene/light.js +0 -575
  405. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  406. package/dist/src/utility/serialization/scene/material.js +0 -1111
  407. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  408. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  409. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  410. package/dist/src/utility/serialization/scene/misc.js +0 -39
  411. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  412. package/dist/src/utility/serialization/scene/node.js +0 -451
  413. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  414. package/dist/src/utility/serialization/scene/particle.js +0 -425
  415. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  416. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  417. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  418. package/dist/src/utility/serialization/scene/scene.js +0 -704
  419. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  420. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  421. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  422. package/dist/src/utility/serialization/scene/water.js +0 -465
  423. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  424. package/dist/src/utility/shprojector.js +0 -297
  425. package/dist/src/utility/shprojector.js.map +0 -1
  426. package/dist/src/utility/textures/ggxlut.js +0 -213
  427. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  428. package/dist/src/utility/textures/gradientnoise.js +0 -62
  429. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  430. package/dist/src/utility/textures/randomnoise.js +0 -41
  431. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  432. package/dist/src/values.js +0 -162
  433. package/dist/src/values.js.map +0 -1
  434. package/dist/utility/blueprint/material/common.js +0 -7
  435. package/dist/utility/blueprint/material/common.js.map +0 -1
  436. package/dist/utility/serialization/blueprint/constants.js +0 -255
  437. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  438. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  439. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  440. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  441. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
@@ -0,0 +1,371 @@
1
+ import { Vector3, Quaternion } from '@zephyr3d/base';
2
+ import { IKSolver } from './ik_solver.js';
3
+ import { IKUtils } from './ik_utils.js';
4
+
5
+ /**
6
+ * CCD (Cyclic Coordinate Descent) IK solver.
7
+ *
8
+ * @remarks
9
+ * CCD is an iterative IK algorithm that works by:
10
+ * 1. Starting from the joint closest to the end effector
11
+ * 2. Rotating each joint to point the end effector toward the target
12
+ * 3. Moving backward through the chain to the root
13
+ * 4. Repeating until convergence or max iterations
14
+ *
15
+ * CCD is generally faster than FABRIK and works well for chains of any length.
16
+ * It's particularly good for tentacles, tails, and other flexible chains.
17
+ *
18
+ * Supports multiple pole vectors to control the bending direction of different joints.
19
+ *
20
+ * @public
21
+ */ class CCDSolver extends IKSolver {
22
+ /** Map of joint index to pole vector configuration */ _poleVectors;
23
+ /** Twist constraints for each joint (indexed by joint index) */ _twistConstraints;
24
+ /**
25
+ * Create a CCD solver.
26
+ *
27
+ * @param chain - The IK chain to solve
28
+ * @param maxIterations - Maximum number of iterations (default: 10)
29
+ * @param tolerance - Convergence tolerance in world units (default: 0.001)
30
+ */ constructor(chain, maxIterations = 10, tolerance = 0.001){
31
+ super(chain, maxIterations, tolerance);
32
+ this._poleVectors = new Map();
33
+ this._twistConstraints = new Map();
34
+ // Set default twist constraints for all joints
35
+ for(let i = 0; i < chain.joints.length - 1; i++){
36
+ // Middle joints have more restrictive twist limits
37
+ const isMiddleJoint = i > 0 && i < chain.joints.length - 2;
38
+ this._twistConstraints.set(i, {
39
+ minTwist: isMiddleJoint ? -Math.PI * 0.2 : -Math.PI * 0.3,
40
+ maxTwist: isMiddleJoint ? Math.PI * 0.2 : Math.PI * 0.3,
41
+ smoothFactor: 0.3
42
+ });
43
+ }
44
+ }
45
+ /**
46
+ * Set twist constraint for a specific joint.
47
+ *
48
+ * @param jointIndex - Index of the joint
49
+ * @param minTwist - Minimum twist angle in radians
50
+ * @param maxTwist - Maximum twist angle in radians
51
+ * @param smoothFactor - Smoothing factor [0-1] (default: 0.3)
52
+ */ setTwistConstraint(jointIndex, minTwist, maxTwist, smoothFactor = 0.3) {
53
+ if (jointIndex < 0 || jointIndex >= this._chain.joints.length - 1) {
54
+ throw new Error(`Invalid joint index: ${jointIndex}`);
55
+ }
56
+ this._twistConstraints.set(jointIndex, {
57
+ minTwist,
58
+ maxTwist,
59
+ smoothFactor: Math.max(0, Math.min(1, smoothFactor))
60
+ });
61
+ }
62
+ /**
63
+ * Get twist constraint for a specific joint.
64
+ *
65
+ * @param jointIndex - Index of the joint
66
+ * @returns Twist constraint or undefined if not set
67
+ */ getTwistConstraint(jointIndex) {
68
+ return this._twistConstraints.get(jointIndex);
69
+ }
70
+ /**
71
+ * Remove twist constraint for a specific joint.
72
+ *
73
+ * @param jointIndex - Index of the joint
74
+ * @returns True if a constraint was removed
75
+ */ removeTwistConstraint(jointIndex) {
76
+ return this._twistConstraints.delete(jointIndex);
77
+ }
78
+ /**
79
+ * Clear all twist constraints.
80
+ */ clearTwistConstraints() {
81
+ this._twistConstraints.clear();
82
+ }
83
+ /**
84
+ * Set pole vector for a specific joint.
85
+ *
86
+ * @param jointIndex - Index of the joint to apply pole vector to
87
+ * @param poleVector - Pole vector position in world space
88
+ * @param weight - Weight of the pole vector constraint (0-1, default: 1)
89
+ */ setPoleVector(jointIndex, poleVector, weight = 1) {
90
+ if (jointIndex < 0 || jointIndex >= this._chain.joints.length) {
91
+ throw new Error(`Invalid joint index: ${jointIndex}`);
92
+ }
93
+ this._poleVectors.set(jointIndex, {
94
+ position: poleVector.clone(),
95
+ weight: Math.max(0, Math.min(1, weight))
96
+ });
97
+ }
98
+ /**
99
+ * Remove pole vector for a specific joint.
100
+ *
101
+ * @param jointIndex - Index of the joint to remove pole vector from
102
+ * @returns True if a pole vector was removed, false if none existed
103
+ */ removePoleVector(jointIndex) {
104
+ return this._poleVectors.delete(jointIndex);
105
+ }
106
+ /**
107
+ * Clear all pole vectors.
108
+ */ clearPoleVectors() {
109
+ this._poleVectors.clear();
110
+ }
111
+ /**
112
+ * Get pole vector configuration for a specific joint.
113
+ *
114
+ * @param jointIndex - Index of the joint
115
+ * @returns Pole vector configuration or undefined if not set
116
+ */ getPoleVector(jointIndex) {
117
+ const config = this._poleVectors.get(jointIndex);
118
+ if (config) {
119
+ return {
120
+ position: config.position.clone(),
121
+ weight: config.weight
122
+ };
123
+ }
124
+ return undefined;
125
+ }
126
+ /**
127
+ * Check if a joint has a pole vector.
128
+ *
129
+ * @param jointIndex - Index of the joint
130
+ * @returns True if the joint has a pole vector
131
+ */ hasPoleVector(jointIndex) {
132
+ return this._poleVectors.has(jointIndex);
133
+ }
134
+ /**
135
+ * Solve the IK chain to reach the target position using CCD algorithm.
136
+ *
137
+ * @param target - Target position for the end effector
138
+ * @returns True if converged within tolerance, false otherwise
139
+ */ solve(target) {
140
+ const joints = this._chain.joints;
141
+ // Update joint positions from scene nodes before solving
142
+ this._chain.updateFromNodes();
143
+ // Store original positions
144
+ this._chain.storeOriginalPositions();
145
+ let converged = false;
146
+ for(let iteration = 0; iteration < this._maxIterations; iteration++){
147
+ // Check convergence
148
+ const endEffector = joints[joints.length - 1];
149
+ const distToTarget = Vector3.distance(endEffector.position, target);
150
+ if (distToTarget < this._tolerance) {
151
+ converged = true;
152
+ break;
153
+ }
154
+ // Iterate backward through joints (from second-to-last to root)
155
+ // We skip the end effector itself since it doesn't have a child to rotate toward
156
+ for(let i = joints.length - 2; i >= 0; i--){
157
+ const joint = joints[i];
158
+ // Vector from current joint to end effector
159
+ const toEnd = Vector3.sub(endEffector.position, joint.position, new Vector3());
160
+ const toEndDist = toEnd.magnitude;
161
+ // Vector from current joint to target
162
+ const toTarget = Vector3.sub(target, joint.position, new Vector3());
163
+ const toTargetDist = toTarget.magnitude;
164
+ // Skip if either vector is too small
165
+ if (toEndDist < 0.000001 || toTargetDist < 0.000001) {
166
+ continue;
167
+ }
168
+ // Normalize vectors
169
+ const toEndDir = Vector3.scale(toEnd, 1 / toEndDist, new Vector3());
170
+ const toTargetDir = Vector3.scale(toTarget, 1 / toTargetDist, new Vector3());
171
+ // Calculate rotation needed to align end effector toward target
172
+ let rotation = new Quaternion();
173
+ IKUtils.fromToRotation(toEndDir, toTargetDir, rotation);
174
+ // Apply rotation to all joints from current to end effector
175
+ this._rotateJointsFromIndex(i, rotation, joint.position);
176
+ // Apply constraints after rotating this joint
177
+ this._applyConstraintsForJoint(i);
178
+ }
179
+ // Apply all pole vector constraints after each full iteration
180
+ // This is more stable than applying them during the CCD loop
181
+ this._applyAllPoleVectors();
182
+ }
183
+ return converged;
184
+ }
185
+ /**
186
+ * Rotate all joints from the given index to the end effector around a pivot point.
187
+ *
188
+ * @param startIndex - Index of the joint to start rotating from
189
+ * @param rotation - Rotation to apply
190
+ * @param pivot - Pivot point for rotation (position of the joint being adjusted)
191
+ */ _rotateJointsFromIndex(startIndex, rotation, pivot) {
192
+ const joints = this._chain.joints;
193
+ // Rotate all joints from startIndex+1 to end effector
194
+ for(let i = startIndex + 1; i < joints.length; i++){
195
+ const joint = joints[i];
196
+ // Translate to pivot
197
+ const offset = Vector3.sub(joint.position, pivot, new Vector3());
198
+ // Rotate around pivot
199
+ const rotated = rotation.transform(offset, new Vector3());
200
+ // Translate back
201
+ joint.position.set(Vector3.add(pivot, rotated, new Vector3()));
202
+ }
203
+ }
204
+ /**
205
+ * Apply all pole vector constraints.
206
+ *
207
+ * @remarks
208
+ * This method applies all configured pole vectors to their respective joints.
209
+ * Pole vectors are applied in reverse order (from end to root) to minimize
210
+ * interference between multiple pole vectors. This ensures that pole vectors
211
+ * closer to the end effector are not affected by pole vectors closer to the root.
212
+ */ _applyAllPoleVectors() {
213
+ if (this._poleVectors.size === 0) {
214
+ return;
215
+ }
216
+ // Apply pole vectors in reverse order (from end to root)
217
+ // This prevents earlier pole vectors from affecting later ones
218
+ const sortedIndices = Array.from(this._poleVectors.keys()).sort((a, b)=>b - a);
219
+ for (const jointIndex of sortedIndices){
220
+ const config = this._poleVectors.get(jointIndex);
221
+ if (config && config.weight > 0.001) {
222
+ this._applyPoleVectorTwist(jointIndex, config.position, config.weight);
223
+ }
224
+ }
225
+ }
226
+ /**
227
+ * Apply pole vector twist to a specific joint.
228
+ *
229
+ * @remarks
230
+ * This method is called after the base CCD rotation has been applied.
231
+ * It adds an additional twist rotation around the joint-to-end axis
232
+ * to make the next joint (child) bend toward the pole vector.
233
+ *
234
+ * @param jointIndex - Index of the pole joint
235
+ * @param poleVector - Pole vector position in world space
236
+ * @param weight - Weight of the pole vector constraint (0-1)
237
+ */ _applyPoleVectorTwist(jointIndex, poleVector, weight) {
238
+ const joints = this._chain.joints;
239
+ // We need at least 3 joints to apply pole vector (parent, pole joint, child)
240
+ if (jointIndex < 1 || jointIndex >= joints.length - 1) {
241
+ return;
242
+ }
243
+ const parentJoint = joints[jointIndex - 1];
244
+ const currentJoint = joints[jointIndex];
245
+ const childJoint = joints[jointIndex + 1];
246
+ const parentPos = parentJoint.position;
247
+ const currentPos = currentJoint.position;
248
+ const childPos = childJoint.position;
249
+ // Calculate the plane defined by parent, child, and pole vector
250
+ // Vector from parent to child (the "line" we're bending around)
251
+ const parentToChild = Vector3.sub(childPos, parentPos, new Vector3());
252
+ const lineLength = parentToChild.magnitude;
253
+ if (lineLength < 0.000001) {
254
+ return; // Parent and child are at same position
255
+ }
256
+ const lineDir = Vector3.scale(parentToChild, 1 / lineLength, new Vector3());
257
+ // Project current joint onto the parent-child line
258
+ const parentToCurrent = Vector3.sub(currentPos, parentPos, new Vector3());
259
+ const projectionLength = Vector3.dot(parentToCurrent, lineDir);
260
+ const projectionPoint = Vector3.scale(lineDir, projectionLength, new Vector3());
261
+ Vector3.add(parentPos, projectionPoint, projectionPoint);
262
+ // Vector from projection point to current joint (perpendicular to line)
263
+ const perpendicular = Vector3.sub(currentPos, projectionPoint, new Vector3());
264
+ const perpLength = perpendicular.magnitude;
265
+ if (perpLength < 0.000001) {
266
+ return; // Current joint is on the line
267
+ }
268
+ // Calculate desired direction toward pole vector
269
+ const parentToPole = Vector3.sub(poleVector, parentPos, new Vector3());
270
+ const poleProjectionLength = Vector3.dot(parentToPole, lineDir);
271
+ const poleProjectionPoint = Vector3.scale(lineDir, poleProjectionLength, new Vector3());
272
+ Vector3.add(parentPos, poleProjectionPoint, poleProjectionPoint);
273
+ // Direction from projection to pole (perpendicular to line)
274
+ const poleDirection = Vector3.sub(poleVector, poleProjectionPoint, new Vector3());
275
+ const poleDirLength = poleDirection.magnitude;
276
+ if (poleDirLength < 0.000001) {
277
+ return; // Pole is on the line
278
+ }
279
+ poleDirection.scaleBy(1 / poleDirLength);
280
+ // Calculate new position for current joint
281
+ // Keep the same distance from the line, but rotate toward pole direction
282
+ const desiredPerpendicular = Vector3.scale(poleDirection, perpLength, new Vector3());
283
+ const newPosition = Vector3.add(projectionPoint, desiredPerpendicular, new Vector3());
284
+ // Apply weight (blend between original and constrained position)
285
+ if (weight < 0.999) {
286
+ const blended = new Vector3();
287
+ blended.x = currentPos.x + (newPosition.x - currentPos.x) * weight;
288
+ blended.y = currentPos.y + (newPosition.y - currentPos.y) * weight;
289
+ blended.z = currentPos.z + (newPosition.z - currentPos.z) * weight;
290
+ currentJoint.position.set(blended);
291
+ } else {
292
+ currentJoint.position.set(newPosition);
293
+ }
294
+ }
295
+ /**
296
+ * Apply constraints for a specific joint.
297
+ *
298
+ * @param jointIndex - Index of the joint to apply constraints to
299
+ */ _applyConstraintsForJoint(jointIndex) {
300
+ const constraints = this._chain.constraints;
301
+ for (const constraint of constraints){
302
+ if (constraint.jointIndex === jointIndex) {
303
+ constraint.apply(this._chain.joints);
304
+ }
305
+ }
306
+ }
307
+ /**
308
+ * Apply the solved joint positions to scene nodes as rotations.
309
+ *
310
+ * @param weight - Blend weight (0 = original, 1 = full IK, default: 1)
311
+ */ applyToNodes(weight = 1) {
312
+ const joints = this._chain.joints;
313
+ // Apply rotation for all joints except the end effector
314
+ for(let i = 0; i < joints.length - 1; i++){
315
+ const joint = joints[i];
316
+ const nextJoint = joints[i + 1];
317
+ // Calculate direction from current joint to next joint in world space
318
+ const originalDir = Vector3.sub(nextJoint.originalPosition, joint.originalPosition, new Vector3());
319
+ const newDir = Vector3.sub(nextJoint.position, joint.position, new Vector3());
320
+ const originalDirNorm = Vector3.normalize(originalDir, new Vector3());
321
+ const newDirNorm = Vector3.normalize(newDir, new Vector3());
322
+ // Calculate basic rotation
323
+ const deltaRotation = new Quaternion();
324
+ IKUtils.fromToRotation(originalDirNorm, newDirNorm, deltaRotation);
325
+ // Calculate new world rotation
326
+ let worldRotation = Quaternion.multiply(deltaRotation, joint.originalRotation, new Quaternion());
327
+ // Apply swing-twist constraint to prevent over-rotation
328
+ const swing = new Quaternion();
329
+ const twist = new Quaternion();
330
+ worldRotation.decomposeSwingTwist(newDirNorm, swing, twist);
331
+ // Get twist angle
332
+ let twistAngle = twist.getTwistAngle(newDirNorm);
333
+ // Get twist constraint for this joint
334
+ const constraint = this._twistConstraints.get(i);
335
+ if (constraint) {
336
+ // Clamp and smooth twist
337
+ twistAngle = IKUtils.clampAndSmoothTwist(twistAngle, joint.previousTwist, constraint.minTwist, constraint.maxTwist, constraint.smoothFactor);
338
+ }
339
+ // Store for next frame
340
+ joint.previousTwist = twistAngle;
341
+ // Reconstruct rotation from clamped twist: Q = Twist * Swing
342
+ const clampedTwist = Quaternion.fromAxisAngle(newDirNorm, twistAngle);
343
+ worldRotation = Quaternion.multiply(clampedTwist, swing, worldRotation);
344
+ // Blend with original rotation based on weight
345
+ if (weight < 1) {
346
+ Quaternion.slerp(joint.originalRotation, worldRotation, weight, worldRotation);
347
+ }
348
+ // Store this frame's world rotation for next frame's twist continuity
349
+ if (!joint.previousIKRotation) {
350
+ joint.previousIKRotation = worldRotation.clone();
351
+ } else {
352
+ joint.previousIKRotation.set(worldRotation);
353
+ }
354
+ // Convert world rotation to local rotation (relative to parent)
355
+ if (joint.node.parent) {
356
+ const parentWorldRotation = new Quaternion();
357
+ joint.node.parent.worldMatrix.decompose(null, parentWorldRotation, null);
358
+ // localRotation = conjugate(parentWorldRotation) * worldRotation
359
+ const parentInvRotation = Quaternion.conjugate(parentWorldRotation, new Quaternion());
360
+ const localRotation = Quaternion.multiply(parentInvRotation, worldRotation, new Quaternion());
361
+ joint.node.rotation = localRotation;
362
+ } else {
363
+ // Root node has no parent, world rotation is local rotation
364
+ joint.node.rotation = worldRotation;
365
+ }
366
+ }
367
+ }
368
+ }
369
+
370
+ export { CCDSolver };
371
+ //# sourceMappingURL=ccd_solver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ccd_solver.js","sources":["../../../src/animation/ik/ccd_solver.ts"],"sourcesContent":["import { Vector3, Quaternion } from '@zephyr3d/base';\r\nimport { IKSolver } from './ik_solver';\r\nimport type { IKChain } from './ik_chain';\r\nimport { IKUtils } from './ik_utils';\r\nimport type { TwistConstraint } from './ik_constraint';\r\n\r\n/**\r\n * Pole vector configuration for a specific joint.\r\n */\r\ninterface PoleVectorConfig {\r\n /** Pole vector position in world space */\r\n position: Vector3;\r\n /** Weight of the pole vector constraint (0-1) */\r\n weight: number;\r\n}\r\n\r\n/**\r\n * CCD (Cyclic Coordinate Descent) IK solver.\r\n *\r\n * @remarks\r\n * CCD is an iterative IK algorithm that works by:\r\n * 1. Starting from the joint closest to the end effector\r\n * 2. Rotating each joint to point the end effector toward the target\r\n * 3. Moving backward through the chain to the root\r\n * 4. Repeating until convergence or max iterations\r\n *\r\n * CCD is generally faster than FABRIK and works well for chains of any length.\r\n * It's particularly good for tentacles, tails, and other flexible chains.\r\n *\r\n * Supports multiple pole vectors to control the bending direction of different joints.\r\n *\r\n * @public\r\n */\r\nexport class CCDSolver extends IKSolver {\r\n /** Map of joint index to pole vector configuration */\r\n private _poleVectors: Map<number, PoleVectorConfig>;\r\n /** Twist constraints for each joint (indexed by joint index) */\r\n private _twistConstraints: Map<number, TwistConstraint>;\r\n\r\n /**\r\n * Create a CCD solver.\r\n *\r\n * @param chain - The IK chain to solve\r\n * @param maxIterations - Maximum number of iterations (default: 10)\r\n * @param tolerance - Convergence tolerance in world units (default: 0.001)\r\n */\r\n constructor(chain: IKChain, maxIterations = 10, tolerance = 0.001) {\r\n super(chain, maxIterations, tolerance);\r\n this._poleVectors = new Map();\r\n this._twistConstraints = new Map();\r\n\r\n // Set default twist constraints for all joints\r\n for (let i = 0; i < chain.joints.length - 1; i++) {\r\n // Middle joints have more restrictive twist limits\r\n const isMiddleJoint = i > 0 && i < chain.joints.length - 2;\r\n this._twistConstraints.set(i, {\r\n minTwist: isMiddleJoint ? -Math.PI * 0.2 : -Math.PI * 0.3,\r\n maxTwist: isMiddleJoint ? Math.PI * 0.2 : Math.PI * 0.3,\r\n smoothFactor: 0.3\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Set twist constraint for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint\r\n * @param minTwist - Minimum twist angle in radians\r\n * @param maxTwist - Maximum twist angle in radians\r\n * @param smoothFactor - Smoothing factor [0-1] (default: 0.3)\r\n */\r\n setTwistConstraint(\r\n jointIndex: number,\r\n minTwist: number,\r\n maxTwist: number,\r\n smoothFactor: number = 0.3\r\n ): void {\r\n if (jointIndex < 0 || jointIndex >= this._chain.joints.length - 1) {\r\n throw new Error(`Invalid joint index: ${jointIndex}`);\r\n }\r\n\r\n this._twistConstraints.set(jointIndex, {\r\n minTwist,\r\n maxTwist,\r\n smoothFactor: Math.max(0, Math.min(1, smoothFactor))\r\n });\r\n }\r\n\r\n /**\r\n * Get twist constraint for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint\r\n * @returns Twist constraint or undefined if not set\r\n */\r\n getTwistConstraint(jointIndex: number): TwistConstraint | undefined {\r\n return this._twistConstraints.get(jointIndex);\r\n }\r\n\r\n /**\r\n * Remove twist constraint for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint\r\n * @returns True if a constraint was removed\r\n */\r\n removeTwistConstraint(jointIndex: number): boolean {\r\n return this._twistConstraints.delete(jointIndex);\r\n }\r\n\r\n /**\r\n * Clear all twist constraints.\r\n */\r\n clearTwistConstraints(): void {\r\n this._twistConstraints.clear();\r\n }\r\n\r\n /**\r\n * Set pole vector for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint to apply pole vector to\r\n * @param poleVector - Pole vector position in world space\r\n * @param weight - Weight of the pole vector constraint (0-1, default: 1)\r\n */\r\n setPoleVector(jointIndex: number, poleVector: Vector3, weight = 1): void {\r\n if (jointIndex < 0 || jointIndex >= this._chain.joints.length) {\r\n throw new Error(`Invalid joint index: ${jointIndex}`);\r\n }\r\n\r\n this._poleVectors.set(jointIndex, {\r\n position: poleVector.clone(),\r\n weight: Math.max(0, Math.min(1, weight))\r\n });\r\n }\r\n\r\n /**\r\n * Remove pole vector for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint to remove pole vector from\r\n * @returns True if a pole vector was removed, false if none existed\r\n */\r\n removePoleVector(jointIndex: number): boolean {\r\n return this._poleVectors.delete(jointIndex);\r\n }\r\n\r\n /**\r\n * Clear all pole vectors.\r\n */\r\n clearPoleVectors(): void {\r\n this._poleVectors.clear();\r\n }\r\n\r\n /**\r\n * Get pole vector configuration for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint\r\n * @returns Pole vector configuration or undefined if not set\r\n */\r\n getPoleVector(jointIndex: number): { position: Vector3; weight: number } | undefined {\r\n const config = this._poleVectors.get(jointIndex);\r\n if (config) {\r\n return {\r\n position: config.position.clone(),\r\n weight: config.weight\r\n };\r\n }\r\n return undefined;\r\n }\r\n\r\n /**\r\n * Check if a joint has a pole vector.\r\n *\r\n * @param jointIndex - Index of the joint\r\n * @returns True if the joint has a pole vector\r\n */\r\n hasPoleVector(jointIndex: number): boolean {\r\n return this._poleVectors.has(jointIndex);\r\n }\r\n\r\n /**\r\n * Solve the IK chain to reach the target position using CCD algorithm.\r\n *\r\n * @param target - Target position for the end effector\r\n * @returns True if converged within tolerance, false otherwise\r\n */\r\n solve(target: Vector3): boolean {\r\n const joints = this._chain.joints;\r\n\r\n // Update joint positions from scene nodes before solving\r\n this._chain.updateFromNodes();\r\n\r\n // Store original positions\r\n this._chain.storeOriginalPositions();\r\n\r\n let converged = false;\r\n\r\n for (let iteration = 0; iteration < this._maxIterations; iteration++) {\r\n // Check convergence\r\n const endEffector = joints[joints.length - 1];\r\n const distToTarget = Vector3.distance(endEffector.position, target);\r\n\r\n if (distToTarget < this._tolerance) {\r\n converged = true;\r\n break;\r\n }\r\n\r\n // Iterate backward through joints (from second-to-last to root)\r\n // We skip the end effector itself since it doesn't have a child to rotate toward\r\n for (let i = joints.length - 2; i >= 0; i--) {\r\n const joint = joints[i];\r\n\r\n // Vector from current joint to end effector\r\n const toEnd = Vector3.sub(endEffector.position, joint.position, new Vector3());\r\n const toEndDist = toEnd.magnitude;\r\n\r\n // Vector from current joint to target\r\n const toTarget = Vector3.sub(target, joint.position, new Vector3());\r\n const toTargetDist = toTarget.magnitude;\r\n\r\n // Skip if either vector is too small\r\n if (toEndDist < 0.000001 || toTargetDist < 0.000001) {\r\n continue;\r\n }\r\n\r\n // Normalize vectors\r\n const toEndDir = Vector3.scale(toEnd, 1 / toEndDist, new Vector3());\r\n const toTargetDir = Vector3.scale(toTarget, 1 / toTargetDist, new Vector3());\r\n\r\n // Calculate rotation needed to align end effector toward target\r\n let rotation = new Quaternion();\r\n IKUtils.fromToRotation(toEndDir, toTargetDir, rotation);\r\n\r\n // Apply rotation to all joints from current to end effector\r\n this._rotateJointsFromIndex(i, rotation, joint.position);\r\n\r\n // Apply constraints after rotating this joint\r\n this._applyConstraintsForJoint(i);\r\n }\r\n\r\n // Apply all pole vector constraints after each full iteration\r\n // This is more stable than applying them during the CCD loop\r\n this._applyAllPoleVectors();\r\n }\r\n\r\n return converged;\r\n }\r\n\r\n /**\r\n * Rotate all joints from the given index to the end effector around a pivot point.\r\n *\r\n * @param startIndex - Index of the joint to start rotating from\r\n * @param rotation - Rotation to apply\r\n * @param pivot - Pivot point for rotation (position of the joint being adjusted)\r\n */\r\n private _rotateJointsFromIndex(startIndex: number, rotation: Quaternion, pivot: Vector3): void {\r\n const joints = this._chain.joints;\r\n\r\n // Rotate all joints from startIndex+1 to end effector\r\n for (let i = startIndex + 1; i < joints.length; i++) {\r\n const joint = joints[i];\r\n\r\n // Translate to pivot\r\n const offset = Vector3.sub(joint.position, pivot, new Vector3());\r\n\r\n // Rotate around pivot\r\n const rotated = rotation.transform(offset, new Vector3());\r\n\r\n // Translate back\r\n joint.position.set(Vector3.add(pivot, rotated, new Vector3()));\r\n }\r\n }\r\n\r\n /**\r\n * Apply all pole vector constraints.\r\n *\r\n * @remarks\r\n * This method applies all configured pole vectors to their respective joints.\r\n * Pole vectors are applied in reverse order (from end to root) to minimize\r\n * interference between multiple pole vectors. This ensures that pole vectors\r\n * closer to the end effector are not affected by pole vectors closer to the root.\r\n */\r\n private _applyAllPoleVectors(): void {\r\n if (this._poleVectors.size === 0) {\r\n return;\r\n }\r\n\r\n // Apply pole vectors in reverse order (from end to root)\r\n // This prevents earlier pole vectors from affecting later ones\r\n const sortedIndices = Array.from(this._poleVectors.keys()).sort((a, b) => b - a);\r\n\r\n for (const jointIndex of sortedIndices) {\r\n const config = this._poleVectors.get(jointIndex);\r\n if (config && config.weight > 0.001) {\r\n this._applyPoleVectorTwist(jointIndex, config.position, config.weight);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Apply pole vector twist to a specific joint.\r\n *\r\n * @remarks\r\n * This method is called after the base CCD rotation has been applied.\r\n * It adds an additional twist rotation around the joint-to-end axis\r\n * to make the next joint (child) bend toward the pole vector.\r\n *\r\n * @param jointIndex - Index of the pole joint\r\n * @param poleVector - Pole vector position in world space\r\n * @param weight - Weight of the pole vector constraint (0-1)\r\n */\r\n private _applyPoleVectorTwist(jointIndex: number, poleVector: Vector3, weight: number): void {\r\n const joints = this._chain.joints;\r\n\r\n // We need at least 3 joints to apply pole vector (parent, pole joint, child)\r\n if (jointIndex < 1 || jointIndex >= joints.length - 1) {\r\n return;\r\n }\r\n\r\n const parentJoint = joints[jointIndex - 1];\r\n const currentJoint = joints[jointIndex];\r\n const childJoint = joints[jointIndex + 1];\r\n\r\n const parentPos = parentJoint.position;\r\n const currentPos = currentJoint.position;\r\n const childPos = childJoint.position;\r\n\r\n // Calculate the plane defined by parent, child, and pole vector\r\n // Vector from parent to child (the \"line\" we're bending around)\r\n const parentToChild = Vector3.sub(childPos, parentPos, new Vector3());\r\n const lineLength = parentToChild.magnitude;\r\n\r\n if (lineLength < 0.000001) {\r\n return; // Parent and child are at same position\r\n }\r\n\r\n const lineDir = Vector3.scale(parentToChild, 1 / lineLength, new Vector3());\r\n\r\n // Project current joint onto the parent-child line\r\n const parentToCurrent = Vector3.sub(currentPos, parentPos, new Vector3());\r\n const projectionLength = Vector3.dot(parentToCurrent, lineDir);\r\n const projectionPoint = Vector3.scale(lineDir, projectionLength, new Vector3());\r\n Vector3.add(parentPos, projectionPoint, projectionPoint);\r\n\r\n // Vector from projection point to current joint (perpendicular to line)\r\n const perpendicular = Vector3.sub(currentPos, projectionPoint, new Vector3());\r\n const perpLength = perpendicular.magnitude;\r\n\r\n if (perpLength < 0.000001) {\r\n return; // Current joint is on the line\r\n }\r\n\r\n // Calculate desired direction toward pole vector\r\n const parentToPole = Vector3.sub(poleVector, parentPos, new Vector3());\r\n const poleProjectionLength = Vector3.dot(parentToPole, lineDir);\r\n const poleProjectionPoint = Vector3.scale(lineDir, poleProjectionLength, new Vector3());\r\n Vector3.add(parentPos, poleProjectionPoint, poleProjectionPoint);\r\n\r\n // Direction from projection to pole (perpendicular to line)\r\n const poleDirection = Vector3.sub(poleVector, poleProjectionPoint, new Vector3());\r\n const poleDirLength = poleDirection.magnitude;\r\n\r\n if (poleDirLength < 0.000001) {\r\n return; // Pole is on the line\r\n }\r\n\r\n poleDirection.scaleBy(1 / poleDirLength);\r\n\r\n // Calculate new position for current joint\r\n // Keep the same distance from the line, but rotate toward pole direction\r\n const desiredPerpendicular = Vector3.scale(poleDirection, perpLength, new Vector3());\r\n const newPosition = Vector3.add(projectionPoint, desiredPerpendicular, new Vector3());\r\n\r\n // Apply weight (blend between original and constrained position)\r\n if (weight < 0.999) {\r\n const blended = new Vector3();\r\n blended.x = currentPos.x + (newPosition.x - currentPos.x) * weight;\r\n blended.y = currentPos.y + (newPosition.y - currentPos.y) * weight;\r\n blended.z = currentPos.z + (newPosition.z - currentPos.z) * weight;\r\n currentJoint.position.set(blended);\r\n } else {\r\n currentJoint.position.set(newPosition);\r\n }\r\n }\r\n\r\n /**\r\n * Apply constraints for a specific joint.\r\n *\r\n * @param jointIndex - Index of the joint to apply constraints to\r\n */\r\n private _applyConstraintsForJoint(jointIndex: number): void {\r\n const constraints = this._chain.constraints;\r\n for (const constraint of constraints) {\r\n if (constraint.jointIndex === jointIndex) {\r\n constraint.apply(this._chain.joints);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Apply the solved joint positions to scene nodes as rotations.\r\n *\r\n * @param weight - Blend weight (0 = original, 1 = full IK, default: 1)\r\n */\r\n applyToNodes(weight = 1): void {\r\n const joints = this._chain.joints;\r\n\r\n // Apply rotation for all joints except the end effector\r\n for (let i = 0; i < joints.length - 1; i++) {\r\n const joint = joints[i];\r\n const nextJoint = joints[i + 1];\r\n\r\n // Calculate direction from current joint to next joint in world space\r\n const originalDir = Vector3.sub(nextJoint.originalPosition, joint.originalPosition, new Vector3());\r\n const newDir = Vector3.sub(nextJoint.position, joint.position, new Vector3());\r\n\r\n const originalDirNorm = Vector3.normalize(originalDir, new Vector3());\r\n const newDirNorm = Vector3.normalize(newDir, new Vector3());\r\n\r\n // Calculate basic rotation\r\n const deltaRotation = new Quaternion();\r\n IKUtils.fromToRotation(originalDirNorm, newDirNorm, deltaRotation);\r\n\r\n // Calculate new world rotation\r\n let worldRotation = Quaternion.multiply(deltaRotation, joint.originalRotation, new Quaternion());\r\n\r\n // Apply swing-twist constraint to prevent over-rotation\r\n const swing = new Quaternion();\r\n const twist = new Quaternion();\r\n worldRotation.decomposeSwingTwist(newDirNorm, swing, twist);\r\n\r\n // Get twist angle\r\n let twistAngle = twist.getTwistAngle(newDirNorm);\r\n\r\n // Get twist constraint for this joint\r\n const constraint = this._twistConstraints.get(i);\r\n if (constraint) {\r\n // Clamp and smooth twist\r\n twistAngle = IKUtils.clampAndSmoothTwist(\r\n twistAngle,\r\n joint.previousTwist,\r\n constraint.minTwist,\r\n constraint.maxTwist,\r\n constraint.smoothFactor\r\n );\r\n }\r\n\r\n // Store for next frame\r\n joint.previousTwist = twistAngle;\r\n\r\n // Reconstruct rotation from clamped twist: Q = Twist * Swing\r\n const clampedTwist = Quaternion.fromAxisAngle(newDirNorm, twistAngle);\r\n worldRotation = Quaternion.multiply(clampedTwist, swing, worldRotation);\r\n\r\n // Blend with original rotation based on weight\r\n if (weight < 1) {\r\n Quaternion.slerp(joint.originalRotation, worldRotation, weight, worldRotation);\r\n }\r\n\r\n // Store this frame's world rotation for next frame's twist continuity\r\n if (!joint.previousIKRotation) {\r\n joint.previousIKRotation = worldRotation.clone();\r\n } else {\r\n joint.previousIKRotation.set(worldRotation);\r\n }\r\n\r\n // Convert world rotation to local rotation (relative to parent)\r\n if (joint.node.parent) {\r\n const parentWorldRotation = new Quaternion();\r\n joint.node.parent.worldMatrix.decompose(null, parentWorldRotation, null);\r\n\r\n // localRotation = conjugate(parentWorldRotation) * worldRotation\r\n const parentInvRotation = Quaternion.conjugate(parentWorldRotation, new Quaternion());\r\n const localRotation = Quaternion.multiply(parentInvRotation, worldRotation, new Quaternion());\r\n\r\n joint.node.rotation = localRotation;\r\n } else {\r\n // Root node has no parent, world rotation is local rotation\r\n joint.node.rotation = worldRotation;\r\n }\r\n }\r\n }\r\n}\r\n"],"names":["CCDSolver","IKSolver","chain","maxIterations","tolerance","_poleVectors","Map","_twistConstraints","i","joints","length","isMiddleJoint","set","minTwist","Math","PI","maxTwist","smoothFactor","setTwistConstraint","jointIndex","_chain","Error","max","min","getTwistConstraint","get","removeTwistConstraint","delete","clearTwistConstraints","clear","setPoleVector","poleVector","weight","position","clone","removePoleVector","clearPoleVectors","getPoleVector","config","undefined","hasPoleVector","has","solve","target","updateFromNodes","storeOriginalPositions","converged","iteration","_maxIterations","endEffector","distToTarget","Vector3","distance","_tolerance","joint","toEnd","sub","toEndDist","magnitude","toTarget","toTargetDist","toEndDir","scale","toTargetDir","rotation","Quaternion","IKUtils","fromToRotation","_rotateJointsFromIndex","_applyConstraintsForJoint","_applyAllPoleVectors","startIndex","pivot","offset","rotated","transform","add","size","sortedIndices","Array","from","keys","sort","a","b","_applyPoleVectorTwist","parentJoint","currentJoint","childJoint","parentPos","currentPos","childPos","parentToChild","lineLength","lineDir","parentToCurrent","projectionLength","dot","projectionPoint","perpendicular","perpLength","parentToPole","poleProjectionLength","poleProjectionPoint","poleDirection","poleDirLength","scaleBy","desiredPerpendicular","newPosition","blended","x","y","z","constraints","constraint","apply","applyToNodes","nextJoint","originalDir","originalPosition","newDir","originalDirNorm","normalize","newDirNorm","deltaRotation","worldRotation","multiply","originalRotation","swing","twist","decomposeSwingTwist","twistAngle","getTwistAngle","clampAndSmoothTwist","previousTwist","clampedTwist","fromAxisAngle","slerp","previousIKRotation","node","parent","parentWorldRotation","worldMatrix","decompose","parentInvRotation","conjugate","localRotation"],"mappings":";;;;AAgBA;;;;;;;;;;;;;;;;IAiBO,MAAMA,SAAkBC,SAAAA,QAAAA,CAAAA;2DAE7B,YAAoD;qEAEpD,iBAAwD;AAExD;;;;;;MAOA,WAAA,CAAYC,KAAc,EAAEC,aAAAA,GAAgB,EAAE,EAAEC,SAAAA,GAAY,KAAK,CAAE;QACjE,KAAK,CAACF,OAAOC,aAAeC,EAAAA,SAAAA,CAAAA;QAC5B,IAAI,CAACC,YAAY,GAAG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