@zephyr3d/scene 0.9.2 → 0.9.4

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 (513) hide show
  1. package/dist/animation/animationset.js +135 -135
  2. package/dist/animation/animationset.js.map +1 -1
  3. package/dist/animation/ik/ik_chain_builder.js +68 -0
  4. package/dist/animation/ik/ik_chain_builder.js.map +1 -0
  5. package/dist/animation/ik/ik_pole_constraint.js +2 -7
  6. package/dist/animation/ik/ik_pole_constraint.js.map +1 -1
  7. package/dist/animation/joint_dynamics/controller.js +146 -146
  8. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  9. package/dist/animation/joint_dynamics/math.js +16 -0
  10. package/dist/animation/joint_dynamics/math.js.map +1 -0
  11. package/dist/animation/spring/spring_system.js +75 -75
  12. package/dist/animation/spring/spring_system.js.map +1 -1
  13. package/dist/animation/spring2/constraints.js.map +1 -1
  14. package/dist/animation/spring2/controller.js +64 -64
  15. package/dist/animation/spring2/controller.js.map +1 -1
  16. package/dist/animation/spring2/math.js.map +1 -1
  17. package/dist/animation/spring2/spring_system.js +8 -8
  18. package/dist/animation/spring2/spring_system.js.map +1 -1
  19. package/dist/app/engine.js +119 -71
  20. package/dist/app/engine.js.map +1 -1
  21. package/dist/asset/assetmanager.js +296 -244
  22. package/dist/asset/assetmanager.js.map +1 -1
  23. package/dist/asset/loaders/gltf/gltf_loader.js +1 -0
  24. package/dist/asset/loaders/gltf/gltf_loader.js.map +1 -1
  25. package/dist/camera/camera.js +184 -184
  26. package/dist/camera/camera.js.map +1 -1
  27. package/dist/index.d.ts +685 -38
  28. package/dist/index.js +11 -2
  29. package/dist/index.js.map +1 -1
  30. package/dist/material/material.js +290 -290
  31. package/dist/material/material.js.map +1 -1
  32. package/dist/material/msdf_text.js +180 -0
  33. package/dist/material/msdf_text.js.map +1 -0
  34. package/dist/material/msdf_text_sprite.js +64 -0
  35. package/dist/material/msdf_text_sprite.js.map +1 -0
  36. package/dist/material/pbrblueprint.js +123 -108
  37. package/dist/material/pbrblueprint.js.map +1 -1
  38. package/dist/material/shader/helper.js +6 -3
  39. package/dist/material/shader/helper.js.map +1 -1
  40. package/dist/material/sprite_sdf.js +106 -0
  41. package/dist/material/sprite_sdf.js.map +1 -0
  42. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +38 -0
  43. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +1 -0
  44. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +10 -0
  45. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +1 -0
  46. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +127 -0
  47. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +1 -0
  48. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +263 -0
  49. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +1 -0
  50. package/dist/posteffect/ssr.js +1 -0
  51. package/dist/posteffect/ssr.js.map +1 -1
  52. package/dist/render/abuffer_oit.js +1 -0
  53. package/dist/render/abuffer_oit.js.map +1 -1
  54. package/dist/render/cluster_light.js +3 -4
  55. package/dist/render/cluster_light.js.map +1 -1
  56. package/dist/render/cull_visitor.js +28 -0
  57. package/dist/render/cull_visitor.js.map +1 -1
  58. package/dist/render/drawable.js.map +1 -1
  59. package/dist/render/drawable_mixin.js +1 -0
  60. package/dist/render/drawable_mixin.js.map +1 -1
  61. package/dist/render/fbm_wavegenerator.js +1 -0
  62. package/dist/render/fbm_wavegenerator.js.map +1 -1
  63. package/dist/render/gerstner_wavegenerator.js +1 -0
  64. package/dist/render/gerstner_wavegenerator.js.map +1 -1
  65. package/dist/render/globalbindgroup_allocator.js +1 -0
  66. package/dist/render/globalbindgroup_allocator.js.map +1 -1
  67. package/dist/render/render_queue.js +1 -0
  68. package/dist/render/render_queue.js.map +1 -1
  69. package/dist/render/rendergraph/history_resource_manager.js +93 -93
  70. package/dist/render/rendergraph/history_resource_manager.js.map +1 -1
  71. package/dist/render/rendergraph/history_resources.js +3 -3
  72. package/dist/render/rendergraph/history_resources.js.map +1 -1
  73. package/dist/render/rendergraph/types.js +22 -22
  74. package/dist/render/rendergraph/types.js.map +1 -1
  75. package/dist/scene/basesprite.js +1 -5
  76. package/dist/scene/basesprite.js.map +1 -1
  77. package/dist/scene/batchgroup.js +29 -17
  78. package/dist/scene/batchgroup.js.map +1 -1
  79. package/dist/scene/environment.js +1 -0
  80. package/dist/scene/environment.js.map +1 -1
  81. package/dist/scene/mesh.js +8 -9
  82. package/dist/scene/mesh.js.map +1 -1
  83. package/dist/scene/meshdrawable.js +96 -0
  84. package/dist/scene/meshdrawable.js.map +1 -0
  85. package/dist/scene/msdftext.js +341 -0
  86. package/dist/scene/msdftext.js.map +1 -0
  87. package/dist/scene/msdftextsprite.js +349 -0
  88. package/dist/scene/msdftextsprite.js.map +1 -0
  89. package/dist/scene/particlesys.js +1 -0
  90. package/dist/scene/particlesys.js.map +1 -1
  91. package/dist/scene/scene.js +1 -0
  92. package/dist/scene/scene.js.map +1 -1
  93. package/dist/scene/scene_node.js +6 -0
  94. package/dist/scene/scene_node.js.map +1 -1
  95. package/dist/scene/sdftextsprite.js +322 -0
  96. package/dist/scene/sdftextsprite.js.map +1 -0
  97. package/dist/scene/terrain-cm/grass.js +1 -0
  98. package/dist/scene/terrain-cm/grass.js.map +1 -1
  99. package/dist/scene/terrain-cm/grassmaterial.js +1 -0
  100. package/dist/scene/terrain-cm/grassmaterial.js.map +1 -1
  101. package/dist/scene/terrain-cm/terrain-cm.js +1 -0
  102. package/dist/scene/terrain-cm/terrain-cm.js.map +1 -1
  103. package/dist/scene/textsprite.js +120 -0
  104. package/dist/scene/textsprite.js.map +1 -0
  105. package/dist/scene/water.js +1 -0
  106. package/dist/scene/water.js.map +1 -1
  107. package/dist/shadow/shader.js +1 -0
  108. package/dist/shadow/shader.js.map +1 -1
  109. package/dist/shapes/torus.js +90 -59
  110. package/dist/shapes/torus.js.map +1 -1
  111. package/dist/src/animation/animation.js +127 -0
  112. package/dist/src/animation/animation.js.map +1 -0
  113. package/dist/src/animation/animationset.js +255 -0
  114. package/dist/src/animation/animationset.js.map +1 -0
  115. package/dist/src/animation/animationtrack.js +34 -0
  116. package/dist/src/animation/animationtrack.js.map +1 -0
  117. package/dist/src/animation/eulerrotationtrack.js +52 -0
  118. package/dist/src/animation/eulerrotationtrack.js.map +1 -0
  119. package/dist/src/animation/morphtarget.js +93 -0
  120. package/dist/src/animation/morphtarget.js.map +1 -0
  121. package/dist/src/animation/morphtrack.js +70 -0
  122. package/dist/src/animation/morphtrack.js.map +1 -0
  123. package/dist/src/animation/proptrack.js +161 -0
  124. package/dist/src/animation/proptrack.js.map +1 -0
  125. package/dist/src/animation/rotationtrack.js +51 -0
  126. package/dist/src/animation/rotationtrack.js.map +1 -0
  127. package/dist/src/animation/scaletrack.js +50 -0
  128. package/dist/src/animation/scaletrack.js.map +1 -0
  129. package/dist/src/animation/skeleton.js +204 -0
  130. package/dist/src/animation/skeleton.js.map +1 -0
  131. package/dist/src/animation/translationtrack.js +50 -0
  132. package/dist/src/animation/translationtrack.js.map +1 -0
  133. package/dist/src/app/app.js +129 -0
  134. package/dist/src/app/app.js.map +1 -0
  135. package/dist/src/app/inputmgr.js +267 -0
  136. package/dist/src/app/inputmgr.js.map +1 -0
  137. package/dist/src/asset/assetmanager.js +404 -0
  138. package/dist/src/asset/assetmanager.js.map +1 -0
  139. package/dist/src/asset/builtin.js +337 -0
  140. package/dist/src/asset/builtin.js.map +1 -0
  141. package/dist/src/asset/loaders/dds/dds.js +470 -0
  142. package/dist/src/asset/loaders/dds/dds.js.map +1 -0
  143. package/dist/src/asset/loaders/dds/dds_loader.js +28 -0
  144. package/dist/src/asset/loaders/dds/dds_loader.js.map +1 -0
  145. package/dist/src/asset/loaders/gltf/gltf_loader.js +1265 -0
  146. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +1 -0
  147. package/dist/src/asset/loaders/gltf/helpers.js +327 -0
  148. package/dist/src/asset/loaders/gltf/helpers.js.map +1 -0
  149. package/dist/src/asset/loaders/hdr/hdr.js +180 -0
  150. package/dist/src/asset/loaders/hdr/hdr.js.map +1 -0
  151. package/dist/src/asset/loaders/image/tga_Loader.js +116 -0
  152. package/dist/src/asset/loaders/image/tga_Loader.js.map +1 -0
  153. package/dist/src/asset/loaders/image/webimage_loader.js +63 -0
  154. package/dist/src/asset/loaders/image/webimage_loader.js.map +1 -0
  155. package/dist/src/asset/loaders/loader.js +45 -0
  156. package/dist/src/asset/loaders/loader.js.map +1 -0
  157. package/dist/src/asset/model.js +414 -0
  158. package/dist/src/asset/model.js.map +1 -0
  159. package/dist/src/blitter/bilateralblur.js +221 -0
  160. package/dist/src/blitter/bilateralblur.js.map +1 -0
  161. package/dist/src/blitter/blitter.js +390 -0
  162. package/dist/src/blitter/blitter.js.map +1 -0
  163. package/dist/src/blitter/box.js +118 -0
  164. package/dist/src/blitter/box.js.map +1 -0
  165. package/dist/src/blitter/copy.js +22 -0
  166. package/dist/src/blitter/copy.js.map +1 -0
  167. package/dist/src/blitter/gaussianblur.js +228 -0
  168. package/dist/src/blitter/gaussianblur.js.map +1 -0
  169. package/dist/src/camera/base.js +92 -0
  170. package/dist/src/camera/base.js.map +1 -0
  171. package/dist/src/camera/camera.js +1005 -0
  172. package/dist/src/camera/camera.js.map +1 -0
  173. package/dist/src/camera/fps.js +238 -0
  174. package/dist/src/camera/fps.js.map +1 -0
  175. package/dist/src/camera/orbit.js +245 -0
  176. package/dist/src/camera/orbit.js.map +1 -0
  177. package/dist/src/camera/orthocamera.js +167 -0
  178. package/dist/src/camera/orthocamera.js.map +1 -0
  179. package/dist/src/camera/perspectivecamera.js +141 -0
  180. package/dist/src/camera/perspectivecamera.js.map +1 -0
  181. package/dist/src/index.js +120 -0
  182. package/dist/src/index.js.map +1 -0
  183. package/dist/src/material/blinn.js +81 -0
  184. package/dist/src/material/blinn.js.map +1 -0
  185. package/dist/src/material/grassmaterial.js +113 -0
  186. package/dist/src/material/grassmaterial.js.map +1 -0
  187. package/dist/src/material/lambert.js +92 -0
  188. package/dist/src/material/lambert.js.map +1 -0
  189. package/dist/src/material/material.js +301 -0
  190. package/dist/src/material/material.js.map +1 -0
  191. package/dist/src/material/meshmaterial.js +704 -0
  192. package/dist/src/material/meshmaterial.js.map +1 -0
  193. package/dist/src/material/mixins/albedocolor.js +76 -0
  194. package/dist/src/material/mixins/albedocolor.js.map +1 -0
  195. package/dist/src/material/mixins/foliage.js +47 -0
  196. package/dist/src/material/mixins/foliage.js.map +1 -0
  197. package/dist/src/material/mixins/lightmodel/blinnphong.js +112 -0
  198. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +1 -0
  199. package/dist/src/material/mixins/lightmodel/lambert.js +58 -0
  200. package/dist/src/material/mixins/lightmodel/lambert.js.map +1 -0
  201. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +178 -0
  202. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -0
  203. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +139 -0
  204. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +1 -0
  205. package/dist/src/material/mixins/lit.js +476 -0
  206. package/dist/src/material/mixins/lit.js.map +1 -0
  207. package/dist/src/material/mixins/pbr/common.js +918 -0
  208. package/dist/src/material/mixins/pbr/common.js.map +1 -0
  209. package/dist/src/material/mixins/texture.js +172 -0
  210. package/dist/src/material/mixins/texture.js.map +1 -0
  211. package/dist/src/material/mixins/vertexcolor.js +56 -0
  212. package/dist/src/material/mixins/vertexcolor.js.map +1 -0
  213. package/dist/src/material/particle.js +178 -0
  214. package/dist/src/material/particle.js.map +1 -0
  215. package/dist/src/material/pbrmr.js +97 -0
  216. package/dist/src/material/pbrmr.js.map +1 -0
  217. package/dist/src/material/pbrsg.js +97 -0
  218. package/dist/src/material/pbrsg.js.map +1 -0
  219. package/dist/src/material/shader/helper.js +1209 -0
  220. package/dist/src/material/shader/helper.js.map +1 -0
  221. package/dist/src/material/terrain-cm.js +606 -0
  222. package/dist/src/material/terrain-cm.js.map +1 -0
  223. package/dist/src/material/terrainmaterial.js +375 -0
  224. package/dist/src/material/terrainmaterial.js.map +1 -0
  225. package/dist/src/material/unlit.js +41 -0
  226. package/dist/src/material/unlit.js.map +1 -0
  227. package/dist/src/material/water.js +417 -0
  228. package/dist/src/material/water.js.map +1 -0
  229. package/dist/src/posteffect/bloom.js +361 -0
  230. package/dist/src/posteffect/bloom.js.map +1 -0
  231. package/dist/src/posteffect/compositor.js +226 -0
  232. package/dist/src/posteffect/compositor.js.map +1 -0
  233. package/dist/src/posteffect/fxaa.js +273 -0
  234. package/dist/src/posteffect/fxaa.js.map +1 -0
  235. package/dist/src/posteffect/grayscale.js +69 -0
  236. package/dist/src/posteffect/grayscale.js.map +1 -0
  237. package/dist/src/posteffect/motionblur.js +96 -0
  238. package/dist/src/posteffect/motionblur.js.map +1 -0
  239. package/dist/src/posteffect/posteffect.js +126 -0
  240. package/dist/src/posteffect/posteffect.js.map +1 -0
  241. package/dist/src/posteffect/sao.js +324 -0
  242. package/dist/src/posteffect/sao.js.map +1 -0
  243. package/dist/src/posteffect/ssr.js +489 -0
  244. package/dist/src/posteffect/ssr.js.map +1 -0
  245. package/dist/src/posteffect/taa.js +172 -0
  246. package/dist/src/posteffect/taa.js.map +1 -0
  247. package/dist/src/posteffect/tonemap.js +94 -0
  248. package/dist/src/posteffect/tonemap.js.map +1 -0
  249. package/dist/src/render/abuffer_oit.js +361 -0
  250. package/dist/src/render/abuffer_oit.js.map +1 -0
  251. package/dist/src/render/clipmap.js +851 -0
  252. package/dist/src/render/clipmap.js.map +1 -0
  253. package/dist/src/render/cluster_light.js +333 -0
  254. package/dist/src/render/cluster_light.js.map +1 -0
  255. package/dist/src/render/cull_visitor.js +187 -0
  256. package/dist/src/render/cull_visitor.js.map +1 -0
  257. package/dist/src/render/depthpass.js +68 -0
  258. package/dist/src/render/depthpass.js.map +1 -0
  259. package/dist/src/render/drawable_mixin.js +227 -0
  260. package/dist/src/render/drawable_mixin.js.map +1 -0
  261. package/dist/src/render/envlight.js +463 -0
  262. package/dist/src/render/envlight.js.map +1 -0
  263. package/dist/src/render/fbm_wavegenerator.js +251 -0
  264. package/dist/src/render/fbm_wavegenerator.js.map +1 -0
  265. package/dist/src/render/fft_wavegenerator.js +1006 -0
  266. package/dist/src/render/fft_wavegenerator.js.map +1 -0
  267. package/dist/src/render/fullscreenquad.js +38 -0
  268. package/dist/src/render/fullscreenquad.js.map +1 -0
  269. package/dist/src/render/gerstner_wavegenerator.js +314 -0
  270. package/dist/src/render/gerstner_wavegenerator.js.map +1 -0
  271. package/dist/src/render/globalbindgroup_allocator.js +60 -0
  272. package/dist/src/render/globalbindgroup_allocator.js.map +1 -0
  273. package/dist/src/render/hzb.js +273 -0
  274. package/dist/src/render/hzb.js.map +1 -0
  275. package/dist/src/render/lightpass.js +172 -0
  276. package/dist/src/render/lightpass.js.map +1 -0
  277. package/dist/src/render/objectcolorpass.js +51 -0
  278. package/dist/src/render/objectcolorpass.js.map +1 -0
  279. package/dist/src/render/primitive.js +364 -0
  280. package/dist/src/render/primitive.js.map +1 -0
  281. package/dist/src/render/render_queue.js +467 -0
  282. package/dist/src/render/render_queue.js.map +1 -0
  283. package/dist/src/render/renderbundle_wrapper.js +152 -0
  284. package/dist/src/render/renderbundle_wrapper.js.map +1 -0
  285. package/dist/src/render/renderer.js +455 -0
  286. package/dist/src/render/renderer.js.map +1 -0
  287. package/dist/src/render/renderpass.js +200 -0
  288. package/dist/src/render/renderpass.js.map +1 -0
  289. package/dist/src/render/shadowmap_pass.js +56 -0
  290. package/dist/src/render/shadowmap_pass.js.map +1 -0
  291. package/dist/src/render/sky.js +1103 -0
  292. package/dist/src/render/sky.js.map +1 -0
  293. package/dist/src/render/weightedblended_oit.js +168 -0
  294. package/dist/src/render/weightedblended_oit.js.map +1 -0
  295. package/dist/src/scene/batchgroup.js +162 -0
  296. package/dist/src/scene/batchgroup.js.map +1 -0
  297. package/dist/src/scene/environment.js +209 -0
  298. package/dist/src/scene/environment.js.map +1 -0
  299. package/dist/src/scene/graph_node.js +72 -0
  300. package/dist/src/scene/graph_node.js.map +1 -0
  301. package/dist/src/scene/light.js +416 -0
  302. package/dist/src/scene/light.js.map +1 -0
  303. package/dist/src/scene/mesh.js +341 -0
  304. package/dist/src/scene/mesh.js.map +1 -0
  305. package/dist/src/scene/octree.js +649 -0
  306. package/dist/src/scene/octree.js.map +1 -0
  307. package/dist/src/scene/particlesys.js +738 -0
  308. package/dist/src/scene/particlesys.js.map +1 -0
  309. package/dist/src/scene/raycast_visitor.js +103 -0
  310. package/dist/src/scene/raycast_visitor.js.map +1 -0
  311. package/dist/src/scene/scene.js +284 -0
  312. package/dist/src/scene/scene.js.map +1 -0
  313. package/dist/src/scene/scene_node.js +732 -0
  314. package/dist/src/scene/scene_node.js.map +1 -0
  315. package/dist/src/scene/terrain/grass.js +278 -0
  316. package/dist/src/scene/terrain/grass.js.map +1 -0
  317. package/dist/src/scene/terrain/heightfield.js +475 -0
  318. package/dist/src/scene/terrain/heightfield.js.map +1 -0
  319. package/dist/src/scene/terrain/patch.js +530 -0
  320. package/dist/src/scene/terrain/patch.js.map +1 -0
  321. package/dist/src/scene/terrain/quadtree.js +461 -0
  322. package/dist/src/scene/terrain/quadtree.js.map +1 -0
  323. package/dist/src/scene/terrain/terrain.js +246 -0
  324. package/dist/src/scene/terrain/terrain.js.map +1 -0
  325. package/dist/src/scene/terrain-cm/grass.js +594 -0
  326. package/dist/src/scene/terrain-cm/grass.js.map +1 -0
  327. package/dist/src/scene/terrain-cm/grassmaterial.js +159 -0
  328. package/dist/src/scene/terrain-cm/grassmaterial.js.map +1 -0
  329. package/dist/src/scene/terrain-cm/terrain-cm.js +538 -0
  330. package/dist/src/scene/terrain-cm/terrain-cm.js.map +1 -0
  331. package/dist/src/scene/water.js +374 -0
  332. package/dist/src/scene/water.js.map +1 -0
  333. package/dist/src/shaders/atmosphere.js +957 -0
  334. package/dist/src/shaders/atmosphere.js.map +1 -0
  335. package/dist/src/shaders/fog.js +112 -0
  336. package/dist/src/shaders/fog.js.map +1 -0
  337. package/dist/src/shaders/misc.js +266 -0
  338. package/dist/src/shaders/misc.js.map +1 -0
  339. package/dist/src/shaders/noise.js +222 -0
  340. package/dist/src/shaders/noise.js.map +1 -0
  341. package/dist/src/shaders/pbr.js +51 -0
  342. package/dist/src/shaders/pbr.js.map +1 -0
  343. package/dist/src/shaders/shadow.js +636 -0
  344. package/dist/src/shaders/shadow.js.map +1 -0
  345. package/dist/src/shaders/ssr.js +490 -0
  346. package/dist/src/shaders/ssr.js.map +1 -0
  347. package/dist/src/shaders/temporal.js +215 -0
  348. package/dist/src/shaders/temporal.js.map +1 -0
  349. package/dist/src/shaders/water.js +756 -0
  350. package/dist/src/shaders/water.js.map +1 -0
  351. package/dist/src/shadow/esm.js +237 -0
  352. package/dist/src/shadow/esm.js.map +1 -0
  353. package/dist/src/shadow/pcf_opt.js +181 -0
  354. package/dist/src/shadow/pcf_opt.js.map +1 -0
  355. package/dist/src/shadow/pcf_pd.js +189 -0
  356. package/dist/src/shadow/pcf_pd.js.map +1 -0
  357. package/dist/src/shadow/shader.js +37 -0
  358. package/dist/src/shadow/shader.js.map +1 -0
  359. package/dist/src/shadow/shadow_impl.js +15 -0
  360. package/dist/src/shadow/shadow_impl.js.map +1 -0
  361. package/dist/src/shadow/shadowmapper.js +790 -0
  362. package/dist/src/shadow/shadowmapper.js.map +1 -0
  363. package/dist/src/shadow/ssm.js +159 -0
  364. package/dist/src/shadow/ssm.js.map +1 -0
  365. package/dist/src/shadow/vsm.js +297 -0
  366. package/dist/src/shadow/vsm.js.map +1 -0
  367. package/dist/src/shapes/box.js +386 -0
  368. package/dist/src/shapes/box.js.map +1 -0
  369. package/dist/src/shapes/cylinder.js +125 -0
  370. package/dist/src/shapes/cylinder.js.map +1 -0
  371. package/dist/src/shapes/plane.js +88 -0
  372. package/dist/src/shapes/plane.js.map +1 -0
  373. package/dist/src/shapes/shape.js +87 -0
  374. package/dist/src/shapes/shape.js.map +1 -0
  375. package/dist/src/shapes/sphere.js +114 -0
  376. package/dist/src/shapes/sphere.js.map +1 -0
  377. package/dist/src/shapes/tetrahedron.js +188 -0
  378. package/dist/src/shapes/tetrahedron.js.map +1 -0
  379. package/dist/src/shapes/torus.js +111 -0
  380. package/dist/src/shapes/torus.js.map +1 -0
  381. package/dist/src/utility/aabbtree.js +400 -0
  382. package/dist/src/utility/aabbtree.js.map +1 -0
  383. package/dist/src/utility/bounding_volume.js +29 -0
  384. package/dist/src/utility/bounding_volume.js.map +1 -0
  385. package/dist/src/utility/debug.js +28 -0
  386. package/dist/src/utility/debug.js.map +1 -0
  387. package/dist/src/utility/draco/decoder.js +116 -0
  388. package/dist/src/utility/draco/decoder.js.map +1 -0
  389. package/dist/src/utility/misc.js +105 -0
  390. package/dist/src/utility/misc.js.map +1 -0
  391. package/dist/src/utility/panorama.js +163 -0
  392. package/dist/src/utility/panorama.js.map +1 -0
  393. package/dist/src/utility/pmrem.js +354 -0
  394. package/dist/src/utility/pmrem.js.map +1 -0
  395. package/dist/src/utility/rendermipmap.js +115 -0
  396. package/dist/src/utility/rendermipmap.js.map +1 -0
  397. package/dist/src/utility/serialization/json.js +402 -0
  398. package/dist/src/utility/serialization/json.js.map +1 -0
  399. package/dist/src/utility/serialization/manager.js +623 -0
  400. package/dist/src/utility/serialization/manager.js.map +1 -0
  401. package/dist/src/utility/serialization/scene/animation.js +248 -0
  402. package/dist/src/utility/serialization/scene/animation.js.map +1 -0
  403. package/dist/src/utility/serialization/scene/batch.js +59 -0
  404. package/dist/src/utility/serialization/scene/batch.js.map +1 -0
  405. package/dist/src/utility/serialization/scene/camera.js +790 -0
  406. package/dist/src/utility/serialization/scene/camera.js.map +1 -0
  407. package/dist/src/utility/serialization/scene/common.js +222 -0
  408. package/dist/src/utility/serialization/scene/common.js.map +1 -0
  409. package/dist/src/utility/serialization/scene/light.js +575 -0
  410. package/dist/src/utility/serialization/scene/light.js.map +1 -0
  411. package/dist/src/utility/serialization/scene/material.js +1111 -0
  412. package/dist/src/utility/serialization/scene/material.js.map +1 -0
  413. package/dist/src/utility/serialization/scene/mesh.js +148 -0
  414. package/dist/src/utility/serialization/scene/mesh.js.map +1 -0
  415. package/dist/src/utility/serialization/scene/misc.js +39 -0
  416. package/dist/src/utility/serialization/scene/misc.js.map +1 -0
  417. package/dist/src/utility/serialization/scene/node.js +451 -0
  418. package/dist/src/utility/serialization/scene/node.js.map +1 -0
  419. package/dist/src/utility/serialization/scene/particle.js +425 -0
  420. package/dist/src/utility/serialization/scene/particle.js.map +1 -0
  421. package/dist/src/utility/serialization/scene/primitive.js +692 -0
  422. package/dist/src/utility/serialization/scene/primitive.js.map +1 -0
  423. package/dist/src/utility/serialization/scene/scene.js +704 -0
  424. package/dist/src/utility/serialization/scene/scene.js.map +1 -0
  425. package/dist/src/utility/serialization/scene/terrain.js +488 -0
  426. package/dist/src/utility/serialization/scene/terrain.js.map +1 -0
  427. package/dist/src/utility/serialization/scene/water.js +465 -0
  428. package/dist/src/utility/serialization/scene/water.js.map +1 -0
  429. package/dist/src/utility/shprojector.js +297 -0
  430. package/dist/src/utility/shprojector.js.map +1 -0
  431. package/dist/src/utility/textures/ggxlut.js +213 -0
  432. package/dist/src/utility/textures/ggxlut.js.map +1 -0
  433. package/dist/src/utility/textures/gradientnoise.js +62 -0
  434. package/dist/src/utility/textures/gradientnoise.js.map +1 -0
  435. package/dist/src/utility/textures/randomnoise.js +41 -0
  436. package/dist/src/utility/textures/randomnoise.js.map +1 -0
  437. package/dist/src/values.js +162 -0
  438. package/dist/src/values.js.map +1 -0
  439. package/dist/text/font/font_asset.js +884 -0
  440. package/dist/text/font/font_asset.js.map +1 -0
  441. package/dist/text/font/sfnt_reader.js +43 -0
  442. package/dist/text/font/sfnt_reader.js.map +1 -0
  443. package/dist/text/msdf/generator.js +417 -0
  444. package/dist/text/msdf/generator.js.map +1 -0
  445. package/dist/text/msdf/shape.js +143 -0
  446. package/dist/text/msdf/shape.js.map +1 -0
  447. package/dist/text/runtime/msdf_glyph_atlas.js +146 -0
  448. package/dist/text/runtime/msdf_glyph_atlas.js.map +1 -0
  449. package/dist/text/runtime/msdf_text_atlas_manager.js +47 -0
  450. package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -0
  451. package/dist/text/runtime/text_layout.js +96 -0
  452. package/dist/text/runtime/text_layout.js.map +1 -0
  453. package/dist/utility/blueprint/material/common.js +7 -0
  454. package/dist/utility/blueprint/material/common.js.map +1 -0
  455. package/dist/utility/blueprint/material/inputs.js +1275 -1091
  456. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  457. package/dist/utility/blueprint/material/ir.js +505 -490
  458. package/dist/utility/blueprint/material/ir.js.map +1 -1
  459. package/dist/utility/blueprint/material/pbr.js +32 -0
  460. package/dist/utility/blueprint/material/pbr.js.map +1 -1
  461. package/dist/utility/serialization/blueprint/constants.js +255 -0
  462. package/dist/utility/serialization/blueprint/constants.js.map +1 -0
  463. package/dist/utility/serialization/blueprint/material/constants.js +203 -0
  464. package/dist/utility/serialization/blueprint/material/constants.js.map +1 -0
  465. package/dist/utility/serialization/blueprint/material/texture.js +165 -0
  466. package/dist/utility/serialization/blueprint/material/texture.js.map +1 -0
  467. package/dist/utility/serialization/manager.js +55 -11
  468. package/dist/utility/serialization/manager.js.map +1 -1
  469. package/dist/utility/serialization/scene/animation.js +2 -0
  470. package/dist/utility/serialization/scene/animation.js.map +1 -1
  471. package/dist/utility/serialization/scene/batch.js +2 -0
  472. package/dist/utility/serialization/scene/batch.js.map +1 -1
  473. package/dist/utility/serialization/scene/camera.js +2 -0
  474. package/dist/utility/serialization/scene/camera.js.map +1 -1
  475. package/dist/utility/serialization/scene/common.js.map +1 -1
  476. package/dist/utility/serialization/scene/light.js +2 -0
  477. package/dist/utility/serialization/scene/light.js.map +1 -1
  478. package/dist/utility/serialization/scene/material.js +1 -0
  479. package/dist/utility/serialization/scene/material.js.map +1 -1
  480. package/dist/utility/serialization/scene/mesh.js +2 -0
  481. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  482. package/dist/utility/serialization/scene/node.js +2 -0
  483. package/dist/utility/serialization/scene/node.js.map +1 -1
  484. package/dist/utility/serialization/scene/particle.js +2 -0
  485. package/dist/utility/serialization/scene/particle.js.map +1 -1
  486. package/dist/utility/serialization/scene/primitive.js +1 -0
  487. package/dist/utility/serialization/scene/primitive.js.map +1 -1
  488. package/dist/utility/serialization/scene/scene.js.map +1 -1
  489. package/dist/utility/serialization/scene/sprite.js +2 -0
  490. package/dist/utility/serialization/scene/sprite.js.map +1 -1
  491. package/dist/utility/serialization/scene/terrain.js +2 -0
  492. package/dist/utility/serialization/scene/terrain.js.map +1 -1
  493. package/dist/utility/serialization/scene/text.js +516 -0
  494. package/dist/utility/serialization/scene/text.js.map +1 -0
  495. package/dist/utility/serialization/scene/water.js +2 -0
  496. package/dist/utility/serialization/scene/water.js.map +1 -1
  497. package/dist/utility/serialization/types.js +4 -4
  498. package/dist/utility/serialization/types.js.map +1 -1
  499. package/dist/values.js +1 -5
  500. package/dist/values.js.map +1 -1
  501. package/package.json +3 -3
  502. package/dist/animation/joint_dynamics/vrm_spring_bone.js +0 -46
  503. package/dist/animation/joint_dynamics/vrm_spring_bone.js.map +0 -1
  504. package/dist/animation/spring/spring_bone.js +0 -240
  505. package/dist/animation/spring/spring_bone.js.map +0 -1
  506. package/dist/animation/spring/spring_bone_collider.js +0 -198
  507. package/dist/animation/spring/spring_bone_collider.js.map +0 -1
  508. package/dist/animation/spring/spring_bone_constraint.js +0 -170
  509. package/dist/animation/spring/spring_bone_constraint.js.map +0 -1
  510. package/dist/animation/spring/spring_bone_system.js +0 -328
  511. package/dist/animation/spring/spring_bone_system.js.map +0 -1
  512. package/dist/render/sky_motion_vector.js +0 -85
  513. package/dist/render/sky_motion_vector.js.map +0 -1
@@ -0,0 +1,884 @@
1
+ import { SFNTReader } from './sfnt_reader.js';
2
+
3
+ const ARG_1_AND_2_ARE_WORDS = 1 << 0;
4
+ const ARGS_ARE_XY_VALUES = 1 << 1;
5
+ const WE_HAVE_A_SCALE = 1 << 3;
6
+ const MORE_COMPONENTS = 1 << 5;
7
+ const WE_HAVE_AN_X_AND_Y_SCALE = 1 << 6;
8
+ const WE_HAVE_A_TWO_BY_TWO = 1 << 7;
9
+ const DEFAULT_MSDF_ATLAS_PAGE_SIZE = 1024;
10
+ const DEFAULT_MSDF_GLYPH_SIZE = 32;
11
+ /**
12
+ * Minimal runtime font asset for TrueType outlines.
13
+ *
14
+ * @public
15
+ */ class FontAsset {
16
+ _reader;
17
+ _tables;
18
+ _glyphOffsets;
19
+ _advanceWidths;
20
+ _leftSideBearings;
21
+ _glyphCache;
22
+ _cmapFormat4;
23
+ _cmapFormat12;
24
+ _kernPairs;
25
+ _gposPairs;
26
+ _metrics;
27
+ _numberOfHMetrics;
28
+ _msdfAtlasSettings;
29
+ constructor(buffer, options){
30
+ this._reader = new SFNTReader(buffer);
31
+ this._tables = parseTableDirectory(this._reader);
32
+ const head = this.requireTable('head');
33
+ const maxp = this.requireTable('maxp');
34
+ const hhea = this.requireTable('hhea');
35
+ const hmtx = this.requireTable('hmtx');
36
+ const loca = this.requireTable('loca');
37
+ this.requireTable('glyf');
38
+ this.requireTable('cmap');
39
+ this._numberOfHMetrics = this._reader.uint16(hhea.offset + 34);
40
+ this._metrics = {
41
+ unitsPerEm: this._reader.uint16(head.offset + 18),
42
+ ascent: this._reader.int16(hhea.offset + 4),
43
+ descent: this._reader.int16(hhea.offset + 6),
44
+ lineGap: this._reader.int16(hhea.offset + 8),
45
+ glyphCount: this._reader.uint16(maxp.offset + 4)
46
+ };
47
+ this._glyphOffsets = parseGlyphOffsets(this._reader, loca.offset, this._metrics.glyphCount, this._reader.int16(head.offset + 50));
48
+ const metrics = parseHorizontalMetrics(this._reader, hmtx.offset, this._metrics.glyphCount, this._numberOfHMetrics);
49
+ this._advanceWidths = metrics.advanceWidths;
50
+ this._leftSideBearings = metrics.leftSideBearings;
51
+ const cmap = parseBestCMap(this._reader, this.requireTable('cmap').offset);
52
+ this._cmapFormat4 = cmap.format4;
53
+ this._cmapFormat12 = cmap.format12;
54
+ this._kernPairs = parseKernPairs(this._reader, this.getTable('kern'));
55
+ this._gposPairs = parseGPOSPairs(this._reader, this.getTable('GPOS'));
56
+ this._glyphCache = new Map();
57
+ this._msdfAtlasSettings = Object.freeze({
58
+ pageSize: normalizeMSDFAtlasPageSize(options?.pageSize),
59
+ glyphSize: normalizeMSDFGlyphSize(options?.glyphSize)
60
+ });
61
+ }
62
+ static fromBuffer(buffer, options) {
63
+ return new FontAsset(buffer, options);
64
+ }
65
+ get metrics() {
66
+ return this._metrics;
67
+ }
68
+ get msdfAtlasSettings() {
69
+ return this._msdfAtlasSettings;
70
+ }
71
+ get msdfAtlasPageSize() {
72
+ return this._msdfAtlasSettings.pageSize;
73
+ }
74
+ get msdfGlyphSize() {
75
+ return this._msdfAtlasSettings.glyphSize;
76
+ }
77
+ getGlyphIndex(codePoint) {
78
+ if (this._cmapFormat12) {
79
+ const glyphIndex = lookupCMapFormat12(this._reader, this._cmapFormat12.offset, codePoint);
80
+ if (glyphIndex !== 0) {
81
+ return glyphIndex;
82
+ }
83
+ }
84
+ if (this._cmapFormat4 && codePoint <= 0xffff) {
85
+ return lookupCMapFormat4(this._reader, this._cmapFormat4.offset, codePoint);
86
+ }
87
+ return 0;
88
+ }
89
+ getKerning(leftGlyphIndex, rightGlyphIndex) {
90
+ const gpos = this.getPairAdjustment(leftGlyphIndex, rightGlyphIndex);
91
+ if (gpos) {
92
+ return gpos.firstXAdvance + gpos.secondXAdvance;
93
+ }
94
+ return this._kernPairs.get(leftGlyphIndex << 16 | rightGlyphIndex) ?? 0;
95
+ }
96
+ getPairAdjustment(leftGlyphIndex, rightGlyphIndex) {
97
+ return lookupGPOSPair(this._gposPairs, leftGlyphIndex, rightGlyphIndex);
98
+ }
99
+ getGlyph(glyphIndex) {
100
+ if (glyphIndex < 0 || glyphIndex >= this._metrics.glyphCount) {
101
+ return null;
102
+ }
103
+ if (this._glyphCache.has(glyphIndex)) {
104
+ return this._glyphCache.get(glyphIndex);
105
+ }
106
+ const glyph = this.loadGlyph(glyphIndex, 0);
107
+ this._glyphCache.set(glyphIndex, glyph);
108
+ return glyph;
109
+ }
110
+ getTable(tag) {
111
+ return this._tables.get(tag) ?? null;
112
+ }
113
+ requireTable(tag) {
114
+ const table = this.getTable(tag);
115
+ if (!table) {
116
+ throw new Error(`Font table not found: ${tag}`);
117
+ }
118
+ return table;
119
+ }
120
+ loadGlyph(glyphIndex, depth) {
121
+ if (depth > 16) {
122
+ throw new Error(`Composite glyph nesting too deep: ${glyphIndex}`);
123
+ }
124
+ const glyf = this.requireTable('glyf');
125
+ const offset = this._glyphOffsets[glyphIndex];
126
+ const nextOffset = this._glyphOffsets[glyphIndex + 1];
127
+ if (offset === nextOffset) {
128
+ return buildGlyphData(glyphIndex, this._advanceWidths, this._leftSideBearings, [], 0, 0, 0, 0);
129
+ }
130
+ const glyphOffset = glyf.offset + offset;
131
+ const header = parseGlyphHeader(this._reader, glyphOffset);
132
+ if (header.numberOfContours >= 0) {
133
+ const contours = parseSimpleGlyph(this._reader, glyphOffset, header.numberOfContours);
134
+ return buildGlyphData(glyphIndex, this._advanceWidths, this._leftSideBearings, contours, header.xMin, header.yMin, header.xMax, header.yMax);
135
+ }
136
+ const contours = parseCompositeGlyph(this._reader, glyphOffset, (childIndex)=>this.loadGlyph(childIndex, depth + 1));
137
+ const bounds = computeBounds(contours);
138
+ return buildGlyphData(glyphIndex, this._advanceWidths, this._leftSideBearings, contours, bounds.xMin, bounds.yMin, bounds.xMax, bounds.yMax);
139
+ }
140
+ }
141
+ function parseTableDirectory(reader) {
142
+ const numTables = reader.uint16(4);
143
+ const tables = new Map();
144
+ let offset = 12;
145
+ for(let i = 0; i < numTables; i++){
146
+ const tag = reader.tag(offset);
147
+ tables.set(tag, {
148
+ offset: reader.uint32(offset + 8),
149
+ length: reader.uint32(offset + 12)
150
+ });
151
+ offset += 16;
152
+ }
153
+ return tables;
154
+ }
155
+ function parseGlyphOffsets(reader, offset, glyphCount, indexToLocFormat) {
156
+ const result = new Uint32Array(glyphCount + 1);
157
+ if (indexToLocFormat === 0) {
158
+ for(let i = 0; i <= glyphCount; i++){
159
+ result[i] = reader.uint16(offset + i * 2) * 2;
160
+ }
161
+ } else {
162
+ for(let i = 0; i <= glyphCount; i++){
163
+ result[i] = reader.uint32(offset + i * 4);
164
+ }
165
+ }
166
+ return result;
167
+ }
168
+ function parseHorizontalMetrics(reader, offset, glyphCount, numberOfHMetrics) {
169
+ const advanceWidths = new Uint16Array(glyphCount);
170
+ const leftSideBearings = new Int16Array(glyphCount);
171
+ let cursor = offset;
172
+ let lastAdvanceWidth = 0;
173
+ for(let i = 0; i < glyphCount; i++){
174
+ if (i < numberOfHMetrics) {
175
+ lastAdvanceWidth = reader.uint16(cursor);
176
+ advanceWidths[i] = lastAdvanceWidth;
177
+ leftSideBearings[i] = reader.int16(cursor + 2);
178
+ cursor += 4;
179
+ } else {
180
+ advanceWidths[i] = lastAdvanceWidth;
181
+ leftSideBearings[i] = reader.int16(cursor);
182
+ cursor += 2;
183
+ }
184
+ }
185
+ return {
186
+ advanceWidths,
187
+ leftSideBearings
188
+ };
189
+ }
190
+ function parseBestCMap(reader, offset) {
191
+ const numTables = reader.uint16(offset + 2);
192
+ let format4 = null;
193
+ let format12 = null;
194
+ for(let i = 0; i < numTables; i++){
195
+ const recordOffset = offset + 4 + i * 8;
196
+ const platformId = reader.uint16(recordOffset);
197
+ const encodingId = reader.uint16(recordOffset + 2);
198
+ const subtableOffset = offset + reader.uint32(recordOffset + 4);
199
+ const format = reader.uint16(subtableOffset);
200
+ if (format === 12) {
201
+ if (!format12 || isPreferredCMap(platformId, encodingId, format12.platformId, format12.encodingId)) {
202
+ format12 = {
203
+ offset: subtableOffset,
204
+ platformId,
205
+ encodingId
206
+ };
207
+ }
208
+ } else if (format === 4) {
209
+ if (!format4 || isPreferredCMap(platformId, encodingId, format4.platformId, format4.encodingId)) {
210
+ format4 = {
211
+ offset: subtableOffset,
212
+ platformId,
213
+ encodingId
214
+ };
215
+ }
216
+ }
217
+ }
218
+ return {
219
+ format4,
220
+ format12
221
+ };
222
+ }
223
+ function isPreferredCMap(platformId, encodingId, currentPlatformId, currentEncodingId) {
224
+ const nextScore = getCMapScore(platformId, encodingId);
225
+ const currentScore = getCMapScore(currentPlatformId, currentEncodingId);
226
+ return nextScore > currentScore;
227
+ }
228
+ function getCMapScore(platformId, encodingId) {
229
+ if (platformId === 3 && encodingId === 10) {
230
+ return 5;
231
+ }
232
+ if (platformId === 0 && encodingId <= 6) {
233
+ return 4;
234
+ }
235
+ if (platformId === 3 && encodingId === 1) {
236
+ return 3;
237
+ }
238
+ if (platformId === 0) {
239
+ return 2;
240
+ }
241
+ return 1;
242
+ }
243
+ function lookupCMapFormat12(reader, offset, codePoint) {
244
+ const nGroups = reader.uint32(offset + 12);
245
+ let low = 0;
246
+ let high = nGroups - 1;
247
+ while(low <= high){
248
+ const mid = low + high >> 1;
249
+ const groupOffset = offset + 16 + mid * 12;
250
+ const startCharCode = reader.uint32(groupOffset);
251
+ const endCharCode = reader.uint32(groupOffset + 4);
252
+ if (codePoint < startCharCode) {
253
+ high = mid - 1;
254
+ } else if (codePoint > endCharCode) {
255
+ low = mid + 1;
256
+ } else {
257
+ return reader.uint32(groupOffset + 8) + (codePoint - startCharCode);
258
+ }
259
+ }
260
+ return 0;
261
+ }
262
+ function lookupCMapFormat4(reader, offset, codePoint) {
263
+ const segCount = reader.uint16(offset + 6) >> 1;
264
+ const endCodeOffset = offset + 14;
265
+ const startCodeOffset = endCodeOffset + segCount * 2 + 2;
266
+ const idDeltaOffset = startCodeOffset + segCount * 2;
267
+ const idRangeOffsetOffset = idDeltaOffset + segCount * 2;
268
+ for(let i = 0; i < segCount; i++){
269
+ const endCode = reader.uint16(endCodeOffset + i * 2);
270
+ if (codePoint > endCode) {
271
+ continue;
272
+ }
273
+ const startCode = reader.uint16(startCodeOffset + i * 2);
274
+ if (codePoint < startCode) {
275
+ return 0;
276
+ }
277
+ const idDelta = reader.int16(idDeltaOffset + i * 2);
278
+ const idRangeOffset = reader.uint16(idRangeOffsetOffset + i * 2);
279
+ if (idRangeOffset === 0) {
280
+ return codePoint + idDelta & 0xffff;
281
+ }
282
+ const glyphIndexAddress = idRangeOffsetOffset + i * 2 + idRangeOffset + (codePoint - startCode) * 2;
283
+ const glyphIndex = reader.uint16(glyphIndexAddress);
284
+ return glyphIndex === 0 ? 0 : glyphIndex + idDelta & 0xffff;
285
+ }
286
+ return 0;
287
+ }
288
+ function parseKernPairs(reader, table) {
289
+ const result = new Map();
290
+ if (!table || table.length < 4) {
291
+ return result;
292
+ }
293
+ const version = reader.uint16(table.offset);
294
+ if (version !== 0) {
295
+ return result;
296
+ }
297
+ const nTables = reader.uint16(table.offset + 2);
298
+ let cursor = table.offset + 4;
299
+ for(let i = 0; i < nTables; i++){
300
+ const length = reader.uint16(cursor + 2);
301
+ const coverage = reader.uint16(cursor + 4);
302
+ const format = coverage >> 8;
303
+ if (format === 0) {
304
+ const nPairs = reader.uint16(cursor + 6);
305
+ let pairOffset = cursor + 14;
306
+ for(let j = 0; j < nPairs; j++){
307
+ const left = reader.uint16(pairOffset);
308
+ const right = reader.uint16(pairOffset + 2);
309
+ const value = reader.int16(pairOffset + 4);
310
+ result.set(left << 16 | right, value);
311
+ pairOffset += 6;
312
+ }
313
+ }
314
+ cursor += length;
315
+ }
316
+ return result;
317
+ }
318
+ function parseGPOSPairs(reader, table) {
319
+ if (!table || table.length < 10) {
320
+ return [];
321
+ }
322
+ const majorVersion = reader.uint16(table.offset);
323
+ if (majorVersion !== 1) {
324
+ return [];
325
+ }
326
+ const featureListOffset = reader.uint16(table.offset + 6);
327
+ const lookupListOffset = reader.uint16(table.offset + 8);
328
+ if (!featureListOffset || !lookupListOffset) {
329
+ return [];
330
+ }
331
+ const featureLookupIndices = collectGPOSFeatureLookupIndices(reader, table.offset + featureListOffset);
332
+ if (featureLookupIndices.length === 0) {
333
+ return [];
334
+ }
335
+ return parseGPOSLookupSubtables(reader, table.offset + lookupListOffset, table.offset, featureLookupIndices);
336
+ }
337
+ function collectGPOSFeatureLookupIndices(reader, featureListOffset) {
338
+ const featureCount = reader.uint16(featureListOffset);
339
+ const featureTags = new Set([
340
+ 'kern'
341
+ ]);
342
+ const lookupIndices = new Set();
343
+ for(let i = 0; i < featureCount; i++){
344
+ const recordOffset = featureListOffset + 2 + i * 6;
345
+ const tag = reader.tag(recordOffset);
346
+ if (!featureTags.has(tag)) {
347
+ continue;
348
+ }
349
+ const featureOffset = featureListOffset + reader.uint16(recordOffset + 4);
350
+ const lookupIndexCount = reader.uint16(featureOffset + 2);
351
+ for(let j = 0; j < lookupIndexCount; j++){
352
+ lookupIndices.add(reader.uint16(featureOffset + 4 + j * 2));
353
+ }
354
+ }
355
+ return [
356
+ ...lookupIndices
357
+ ].sort((a, b)=>a - b);
358
+ }
359
+ function parseGPOSLookupSubtables(reader, lookupListOffset, gposOffset, lookupIndices) {
360
+ const lookupCount = reader.uint16(lookupListOffset);
361
+ const result = [];
362
+ for (const lookupIndex of lookupIndices){
363
+ if (lookupIndex >= lookupCount) {
364
+ continue;
365
+ }
366
+ const lookupOffset = lookupListOffset + reader.uint16(lookupListOffset + 2 + lookupIndex * 2);
367
+ const lookupType = reader.uint16(lookupOffset);
368
+ const subtableCount = reader.uint16(lookupOffset + 4);
369
+ for(let i = 0; i < subtableCount; i++){
370
+ const subtableOffset = lookupOffset + reader.uint16(lookupOffset + 6 + i * 2);
371
+ if (lookupType === 2) {
372
+ const parsed = parsePairPosSubtable(reader, subtableOffset);
373
+ if (parsed) {
374
+ result.push(parsed);
375
+ }
376
+ } else if (lookupType === 9) {
377
+ const extensionLookupType = reader.uint16(subtableOffset + 2);
378
+ const extensionOffset = reader.uint32(subtableOffset + 4);
379
+ if (extensionLookupType === 2) {
380
+ const parsed = parsePairPosSubtable(reader, subtableOffset + extensionOffset);
381
+ if (parsed) {
382
+ result.push(parsed);
383
+ }
384
+ }
385
+ }
386
+ }
387
+ }
388
+ return result;
389
+ }
390
+ function parsePairPosSubtable(reader, offset) {
391
+ const format = reader.uint16(offset);
392
+ if (format === 1) {
393
+ return parsePairPosFormat1(reader, offset);
394
+ }
395
+ if (format === 2) {
396
+ return parsePairPosFormat2(reader, offset);
397
+ }
398
+ return null;
399
+ }
400
+ function parsePairPosFormat1(reader, offset) {
401
+ const coverage = parseCoverageTable(reader, offset + reader.uint16(offset + 2));
402
+ const valueFormat1 = reader.uint16(offset + 4);
403
+ const valueFormat2 = reader.uint16(offset + 6);
404
+ const pairSetCount = reader.uint16(offset + 8);
405
+ const pairs = new Map();
406
+ for(let i = 0; i < pairSetCount; i++){
407
+ const firstGlyph = getCoverageGlyph(coverage, i);
408
+ if (firstGlyph < 0) {
409
+ continue;
410
+ }
411
+ const pairSetOffset = offset + reader.uint16(offset + 10 + i * 2);
412
+ const pairValueCount = reader.uint16(pairSetOffset);
413
+ let cursor = pairSetOffset + 2;
414
+ const secondMap = new Map();
415
+ for(let j = 0; j < pairValueCount; j++){
416
+ const secondGlyph = reader.uint16(cursor);
417
+ cursor += 2;
418
+ const value1 = readValueRecordX(reader, cursor, valueFormat1);
419
+ cursor += getValueRecordSize(valueFormat1);
420
+ const value2 = readValueRecordX(reader, cursor, valueFormat2);
421
+ cursor += getValueRecordSize(valueFormat2);
422
+ const adjustment = {
423
+ firstXPlacement: value1.xPlacement,
424
+ firstXAdvance: value1.xAdvance,
425
+ secondXPlacement: value2.xPlacement,
426
+ secondXAdvance: value2.xAdvance
427
+ };
428
+ if (adjustment.firstXPlacement !== 0 || adjustment.firstXAdvance !== 0 || adjustment.secondXPlacement !== 0 || adjustment.secondXAdvance !== 0) {
429
+ secondMap.set(secondGlyph, adjustment);
430
+ }
431
+ }
432
+ pairs.set(firstGlyph, secondMap);
433
+ }
434
+ return {
435
+ kind: 'format1',
436
+ coverage,
437
+ pairs
438
+ };
439
+ }
440
+ function parsePairPosFormat2(reader, offset) {
441
+ const coverage = parseCoverageTable(reader, offset + reader.uint16(offset + 2));
442
+ const valueFormat1 = reader.uint16(offset + 4);
443
+ const valueFormat2 = reader.uint16(offset + 6);
444
+ const classDef1 = parseClassDefTable(reader, offset + reader.uint16(offset + 8));
445
+ const classDef2 = parseClassDefTable(reader, offset + reader.uint16(offset + 10));
446
+ const class1Count = reader.uint16(offset + 12);
447
+ const class2Count = reader.uint16(offset + 14);
448
+ const values = new Array(class1Count * class2Count);
449
+ let cursor = offset + 16;
450
+ for(let c1 = 0; c1 < class1Count; c1++){
451
+ for(let c2 = 0; c2 < class2Count; c2++){
452
+ const value1 = readValueRecordX(reader, cursor, valueFormat1);
453
+ cursor += getValueRecordSize(valueFormat1);
454
+ const value2 = readValueRecordX(reader, cursor, valueFormat2);
455
+ cursor += getValueRecordSize(valueFormat2);
456
+ values[c1 * class2Count + c2] = {
457
+ firstXPlacement: value1.xPlacement,
458
+ firstXAdvance: value1.xAdvance,
459
+ secondXPlacement: value2.xPlacement,
460
+ secondXAdvance: value2.xAdvance
461
+ };
462
+ }
463
+ }
464
+ return {
465
+ kind: 'format2',
466
+ coverage,
467
+ classDef1,
468
+ classDef2,
469
+ class1Count,
470
+ class2Count,
471
+ values
472
+ };
473
+ }
474
+ function parseCoverageTable(reader, offset) {
475
+ const format = reader.uint16(offset);
476
+ if (format === 1) {
477
+ const glyphCount = reader.uint16(offset + 2);
478
+ const glyphs = new Uint16Array(glyphCount);
479
+ for(let i = 0; i < glyphCount; i++){
480
+ glyphs[i] = reader.uint16(offset + 4 + i * 2);
481
+ }
482
+ return {
483
+ format: 1,
484
+ glyphs
485
+ };
486
+ }
487
+ const rangeCount = reader.uint16(offset + 2);
488
+ const ranges = [];
489
+ for(let i = 0; i < rangeCount; i++){
490
+ const rangeOffset = offset + 4 + i * 6;
491
+ ranges.push({
492
+ start: reader.uint16(rangeOffset),
493
+ end: reader.uint16(rangeOffset + 2),
494
+ startIndex: reader.uint16(rangeOffset + 4)
495
+ });
496
+ }
497
+ return {
498
+ format: 2,
499
+ ranges
500
+ };
501
+ }
502
+ function getCoverageGlyph(coverage, index) {
503
+ if (coverage.format === 1) {
504
+ return coverage.glyphs[index] ?? -1;
505
+ }
506
+ for (const range of coverage.ranges){
507
+ const rangeLength = range.end - range.start + 1;
508
+ if (index >= range.startIndex && index < range.startIndex + rangeLength) {
509
+ return range.start + (index - range.startIndex);
510
+ }
511
+ }
512
+ return -1;
513
+ }
514
+ function coverageContains(coverage, glyphIndex) {
515
+ if (coverage.format === 1) {
516
+ return binarySearchU16(coverage.glyphs, glyphIndex) >= 0;
517
+ }
518
+ for (const range of coverage.ranges){
519
+ if (glyphIndex >= range.start && glyphIndex <= range.end) {
520
+ return true;
521
+ }
522
+ }
523
+ return false;
524
+ }
525
+ function parseClassDefTable(reader, offset) {
526
+ const format = reader.uint16(offset);
527
+ if (format === 1) {
528
+ const startGlyphId = reader.uint16(offset + 2);
529
+ const glyphCount = reader.uint16(offset + 4);
530
+ const classes = new Uint16Array(glyphCount);
531
+ for(let i = 0; i < glyphCount; i++){
532
+ classes[i] = reader.uint16(offset + 6 + i * 2);
533
+ }
534
+ return {
535
+ format: 1,
536
+ startGlyphId,
537
+ classes
538
+ };
539
+ }
540
+ const classRangeCount = reader.uint16(offset + 2);
541
+ const ranges = [];
542
+ for(let i = 0; i < classRangeCount; i++){
543
+ const rangeOffset = offset + 4 + i * 6;
544
+ ranges.push({
545
+ start: reader.uint16(rangeOffset),
546
+ end: reader.uint16(rangeOffset + 2),
547
+ classId: reader.uint16(rangeOffset + 4)
548
+ });
549
+ }
550
+ return {
551
+ format: 2,
552
+ ranges
553
+ };
554
+ }
555
+ function getGlyphClass(classDef, glyphIndex) {
556
+ if (classDef.format === 1) {
557
+ const index = glyphIndex - classDef.startGlyphId;
558
+ return index >= 0 && index < classDef.classes.length ? classDef.classes[index] : 0;
559
+ }
560
+ for (const range of classDef.ranges){
561
+ if (glyphIndex >= range.start && glyphIndex <= range.end) {
562
+ return range.classId;
563
+ }
564
+ }
565
+ return 0;
566
+ }
567
+ function readValueRecordX(reader, offset, valueFormat) {
568
+ let cursor = offset;
569
+ let xPlacement = 0;
570
+ let xAdvance = 0;
571
+ if (valueFormat & 0x0001) {
572
+ xPlacement = reader.int16(cursor);
573
+ cursor += 2;
574
+ }
575
+ if (valueFormat & 0x0002) {
576
+ cursor += 2;
577
+ }
578
+ if (valueFormat & 0x0004) {
579
+ xAdvance = reader.int16(cursor);
580
+ cursor += 2;
581
+ }
582
+ if (valueFormat & 0x0008) {
583
+ cursor += 2;
584
+ }
585
+ if (valueFormat & 0x0010) {
586
+ cursor += 2;
587
+ }
588
+ if (valueFormat & 0x0020) {
589
+ cursor += 2;
590
+ }
591
+ if (valueFormat & 0x0040) {
592
+ cursor += 2;
593
+ }
594
+ if (valueFormat & 0x0080) {
595
+ cursor += 2;
596
+ }
597
+ return {
598
+ xPlacement,
599
+ xAdvance
600
+ };
601
+ }
602
+ function getValueRecordSize(valueFormat) {
603
+ let size = 0;
604
+ for(let bit = 0; bit < 8; bit++){
605
+ if (valueFormat & 1 << bit) {
606
+ size += 2;
607
+ }
608
+ }
609
+ return size;
610
+ }
611
+ function lookupGPOSPair(subtables, leftGlyphIndex, rightGlyphIndex) {
612
+ let merged = null;
613
+ for (const subtable of subtables){
614
+ if (!coverageContains(subtable.coverage, leftGlyphIndex)) {
615
+ continue;
616
+ }
617
+ if (subtable.kind === 'format1') {
618
+ const secondMap = subtable.pairs.get(leftGlyphIndex);
619
+ if (secondMap) {
620
+ const adjustment = secondMap.get(rightGlyphIndex);
621
+ if (adjustment) {
622
+ merged = mergePairAdjustment(merged, adjustment);
623
+ }
624
+ }
625
+ } else {
626
+ const class1 = getGlyphClass(subtable.classDef1, leftGlyphIndex);
627
+ const class2 = getGlyphClass(subtable.classDef2, rightGlyphIndex);
628
+ if (class1 < subtable.class1Count && class2 < subtable.class2Count) {
629
+ const adjustment = subtable.values[class1 * subtable.class2Count + class2];
630
+ if (adjustment) {
631
+ merged = mergePairAdjustment(merged, adjustment);
632
+ }
633
+ }
634
+ }
635
+ }
636
+ return merged;
637
+ }
638
+ function binarySearchU16(values, target) {
639
+ let low = 0;
640
+ let high = values.length - 1;
641
+ while(low <= high){
642
+ const mid = low + high >> 1;
643
+ const value = values[mid];
644
+ if (value < target) {
645
+ low = mid + 1;
646
+ } else if (value > target) {
647
+ high = mid - 1;
648
+ } else {
649
+ return mid;
650
+ }
651
+ }
652
+ return -1;
653
+ }
654
+ function mergePairAdjustment(base, next) {
655
+ if (!base) {
656
+ return {
657
+ ...next
658
+ };
659
+ }
660
+ return {
661
+ firstXPlacement: base.firstXPlacement + next.firstXPlacement,
662
+ firstXAdvance: base.firstXAdvance + next.firstXAdvance,
663
+ secondXPlacement: base.secondXPlacement + next.secondXPlacement,
664
+ secondXAdvance: base.secondXAdvance + next.secondXAdvance
665
+ };
666
+ }
667
+ function parseGlyphHeader(reader, offset) {
668
+ return {
669
+ numberOfContours: reader.int16(offset),
670
+ xMin: reader.int16(offset + 2),
671
+ yMin: reader.int16(offset + 4),
672
+ xMax: reader.int16(offset + 6),
673
+ yMax: reader.int16(offset + 8)
674
+ };
675
+ }
676
+ function parseSimpleGlyph(reader, offset, numberOfContours) {
677
+ const endPts = [];
678
+ let cursor = offset + 10;
679
+ for(let i = 0; i < numberOfContours; i++){
680
+ endPts.push(reader.uint16(cursor));
681
+ cursor += 2;
682
+ }
683
+ const pointCount = endPts[numberOfContours - 1] + 1;
684
+ const instructionLength = reader.uint16(cursor);
685
+ cursor += 2 + instructionLength;
686
+ const flags = new Uint8Array(pointCount);
687
+ for(let i = 0; i < pointCount;){
688
+ const flag = reader.uint8(cursor++);
689
+ flags[i++] = flag;
690
+ if (flag & 0x08) {
691
+ const repeatCount = reader.uint8(cursor++);
692
+ for(let j = 0; j < repeatCount; j++){
693
+ flags[i++] = flag;
694
+ }
695
+ }
696
+ }
697
+ const xs = new Int16Array(pointCount);
698
+ const ys = new Int16Array(pointCount);
699
+ let currentX = 0;
700
+ for(let i = 0; i < pointCount; i++){
701
+ const flag = flags[i];
702
+ if (flag & 0x02) {
703
+ const dx = reader.uint8(cursor++);
704
+ currentX += flag & 0x10 ? dx : -dx;
705
+ } else if (!(flag & 0x10)) {
706
+ currentX += reader.int16(cursor);
707
+ cursor += 2;
708
+ }
709
+ xs[i] = currentX;
710
+ }
711
+ let currentY = 0;
712
+ for(let i = 0; i < pointCount; i++){
713
+ const flag = flags[i];
714
+ if (flag & 0x04) {
715
+ const dy = reader.uint8(cursor++);
716
+ currentY += flag & 0x20 ? dy : -dy;
717
+ } else if (!(flag & 0x20)) {
718
+ currentY += reader.int16(cursor);
719
+ cursor += 2;
720
+ }
721
+ ys[i] = currentY;
722
+ }
723
+ const points = [];
724
+ for(let i = 0; i < pointCount; i++){
725
+ points.push({
726
+ x: xs[i],
727
+ y: ys[i],
728
+ onCurve: !!(flags[i] & 0x01)
729
+ });
730
+ }
731
+ const contours = [];
732
+ let start = 0;
733
+ for (const end of endPts){
734
+ contours.push(expandImplicitPoints(points.slice(start, end + 1)));
735
+ start = end + 1;
736
+ }
737
+ return contours;
738
+ }
739
+ function parseCompositeGlyph(reader, offset, loadGlyph) {
740
+ let cursor = offset + 10;
741
+ const contours = [];
742
+ let flags = 0;
743
+ do {
744
+ flags = reader.uint16(cursor);
745
+ const glyphIndex = reader.uint16(cursor + 2);
746
+ cursor += 4;
747
+ const component = parseCompositeComponent(reader, cursor, flags, glyphIndex);
748
+ cursor = component.cursor;
749
+ const child = loadGlyph(component.data.glyphIndex);
750
+ if (child) {
751
+ for (const contour of child.contours){
752
+ contours.push(contour.map((point)=>({
753
+ x: point.x * component.data.xx + point.y * component.data.xy + component.data.dx,
754
+ y: point.x * component.data.yx + point.y * component.data.yy + component.data.dy,
755
+ onCurve: point.onCurve
756
+ })));
757
+ }
758
+ }
759
+ }while (flags & MORE_COMPONENTS)
760
+ return contours;
761
+ }
762
+ function parseCompositeComponent(reader, offset, flags, glyphIndex) {
763
+ let cursor = offset;
764
+ let arg1 = 0;
765
+ let arg2 = 0;
766
+ if (flags & ARG_1_AND_2_ARE_WORDS) {
767
+ arg1 = reader.int16(cursor);
768
+ arg2 = reader.int16(cursor + 2);
769
+ cursor += 4;
770
+ } else {
771
+ arg1 = reader.int8(cursor);
772
+ arg2 = reader.int8(cursor + 1);
773
+ cursor += 2;
774
+ }
775
+ let dx = 0;
776
+ let dy = 0;
777
+ if (flags & ARGS_ARE_XY_VALUES) {
778
+ dx = arg1;
779
+ dy = arg2;
780
+ }
781
+ let xx = 1;
782
+ let xy = 0;
783
+ let yx = 0;
784
+ let yy = 1;
785
+ if (flags & WE_HAVE_A_SCALE) {
786
+ const scale = readF2Dot14(reader, cursor);
787
+ cursor += 2;
788
+ xx = scale;
789
+ yy = scale;
790
+ } else if (flags & WE_HAVE_AN_X_AND_Y_SCALE) {
791
+ xx = readF2Dot14(reader, cursor);
792
+ yy = readF2Dot14(reader, cursor + 2);
793
+ cursor += 4;
794
+ } else if (flags & WE_HAVE_A_TWO_BY_TWO) {
795
+ xx = readF2Dot14(reader, cursor);
796
+ xy = readF2Dot14(reader, cursor + 2);
797
+ yx = readF2Dot14(reader, cursor + 4);
798
+ yy = readF2Dot14(reader, cursor + 6);
799
+ cursor += 8;
800
+ }
801
+ return {
802
+ data: {
803
+ glyphIndex,
804
+ dx,
805
+ dy,
806
+ xx,
807
+ xy,
808
+ yx,
809
+ yy
810
+ },
811
+ cursor
812
+ };
813
+ }
814
+ function readF2Dot14(reader, offset) {
815
+ return reader.int16(offset) / 16384;
816
+ }
817
+ function expandImplicitPoints(points) {
818
+ if (points.length === 0) {
819
+ return points;
820
+ }
821
+ const result = [];
822
+ for(let i = 0; i < points.length; i++){
823
+ const current = points[i];
824
+ const next = points[(i + 1) % points.length];
825
+ result.push(current);
826
+ if (!current.onCurve && !next.onCurve) {
827
+ result.push({
828
+ x: (current.x + next.x) * 0.5,
829
+ y: (current.y + next.y) * 0.5,
830
+ onCurve: true
831
+ });
832
+ }
833
+ }
834
+ return result;
835
+ }
836
+ function computeBounds(contours) {
837
+ if (contours.length === 0) {
838
+ return {
839
+ xMin: 0,
840
+ yMin: 0,
841
+ xMax: 0,
842
+ yMax: 0
843
+ };
844
+ }
845
+ let xMin = Number.POSITIVE_INFINITY;
846
+ let yMin = Number.POSITIVE_INFINITY;
847
+ let xMax = Number.NEGATIVE_INFINITY;
848
+ let yMax = Number.NEGATIVE_INFINITY;
849
+ for (const contour of contours){
850
+ for (const point of contour){
851
+ xMin = Math.min(xMin, point.x);
852
+ yMin = Math.min(yMin, point.y);
853
+ xMax = Math.max(xMax, point.x);
854
+ yMax = Math.max(yMax, point.y);
855
+ }
856
+ }
857
+ return {
858
+ xMin,
859
+ yMin,
860
+ xMax,
861
+ yMax
862
+ };
863
+ }
864
+ function buildGlyphData(glyphIndex, advanceWidths, leftSideBearings, contours, xMin, yMin, xMax, yMax) {
865
+ return {
866
+ glyphIndex,
867
+ advanceWidth: advanceWidths[glyphIndex] ?? 0,
868
+ leftSideBearing: leftSideBearings[glyphIndex] ?? 0,
869
+ xMin,
870
+ yMin,
871
+ xMax,
872
+ yMax,
873
+ contours
874
+ };
875
+ }
876
+ function normalizeMSDFAtlasPageSize(value) {
877
+ return Math.max(32, Math.round(Number.isFinite(value) ? value : DEFAULT_MSDF_ATLAS_PAGE_SIZE));
878
+ }
879
+ function normalizeMSDFGlyphSize(value) {
880
+ return Math.max(8, Math.round(Number.isFinite(value) ? value : DEFAULT_MSDF_GLYPH_SIZE));
881
+ }
882
+
883
+ export { FontAsset };
884
+ //# sourceMappingURL=font_asset.js.map