three-stdlib 2.24.2 → 2.25.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 (540) hide show
  1. package/controls/OrbitControls.d.ts +2 -0
  2. package/index.cjs +116401 -611
  3. package/index.js +116037 -263
  4. package/package.json +17 -4
  5. package/_polyfill/CapsuleGeometry.cjs +0 -22
  6. package/_polyfill/CapsuleGeometry.js +0 -22
  7. package/_polyfill/CompressedArrayTexture.cjs +0 -12
  8. package/_polyfill/CompressedArrayTexture.js +0 -12
  9. package/_polyfill/Data3DTexture.cjs +0 -17
  10. package/_polyfill/Data3DTexture.js +0 -17
  11. package/animation/AnimationClipCreator.cjs +0 -56
  12. package/animation/AnimationClipCreator.js +0 -56
  13. package/animation/CCDIKSolver.cjs +0 -269
  14. package/animation/CCDIKSolver.js +0 -269
  15. package/animation/MMDAnimationHelper.cjs +0 -688
  16. package/animation/MMDAnimationHelper.js +0 -688
  17. package/animation/MMDPhysics.cjs +0 -830
  18. package/animation/MMDPhysics.js +0 -830
  19. package/cameras/CinematicCamera.cjs +0 -131
  20. package/cameras/CinematicCamera.js +0 -131
  21. package/controls/ArcballControls.cjs +0 -2033
  22. package/controls/ArcballControls.js +0 -2033
  23. package/controls/DeviceOrientationControls.cjs +0 -85
  24. package/controls/DeviceOrientationControls.js +0 -85
  25. package/controls/DragControls.cjs +0 -182
  26. package/controls/DragControls.js +0 -182
  27. package/controls/FirstPersonControls.cjs +0 -229
  28. package/controls/FirstPersonControls.js +0 -229
  29. package/controls/FlyControls.cjs +0 -248
  30. package/controls/FlyControls.js +0 -248
  31. package/controls/OrbitControls.cjs +0 -787
  32. package/controls/OrbitControls.js +0 -787
  33. package/controls/PointerLockControls.cjs +0 -103
  34. package/controls/PointerLockControls.js +0 -103
  35. package/controls/TrackballControls.cjs +0 -502
  36. package/controls/TrackballControls.js +0 -502
  37. package/controls/TransformControls.cjs +0 -1089
  38. package/controls/TransformControls.js +0 -1089
  39. package/controls/experimental/CameraControls.cjs +0 -736
  40. package/controls/experimental/CameraControls.js +0 -736
  41. package/csm/CSM.cjs +0 -244
  42. package/csm/CSM.js +0 -244
  43. package/csm/CSMFrustum.cjs +0 -75
  44. package/csm/CSMFrustum.js +0 -75
  45. package/csm/CSMHelper.cjs +0 -114
  46. package/csm/CSMHelper.js +0 -114
  47. package/csm/CSMShader.cjs +0 -261
  48. package/csm/CSMShader.js +0 -261
  49. package/curves/CurveExtras.cjs +0 -214
  50. package/curves/CurveExtras.js +0 -214
  51. package/curves/NURBSCurve.cjs +0 -35
  52. package/curves/NURBSCurve.js +0 -35
  53. package/curves/NURBSSurface.cjs +0 -28
  54. package/curves/NURBSSurface.js +0 -28
  55. package/curves/NURBSUtils.cjs +0 -226
  56. package/curves/NURBSUtils.js +0 -226
  57. package/deprecated/Geometry.cjs +0 -971
  58. package/deprecated/Geometry.js +0 -971
  59. package/effects/AnaglyphEffect.cjs +0 -102
  60. package/effects/AnaglyphEffect.js +0 -102
  61. package/effects/AsciiEffect.cjs +0 -155
  62. package/effects/AsciiEffect.js +0 -155
  63. package/effects/OutlineEffect.cjs +0 -275
  64. package/effects/OutlineEffect.js +0 -275
  65. package/effects/ParallaxBarrierEffect.cjs +0 -65
  66. package/effects/ParallaxBarrierEffect.js +0 -65
  67. package/effects/PeppersGhostEffect.cjs +0 -88
  68. package/effects/PeppersGhostEffect.js +0 -88
  69. package/effects/StereoEffect.cjs +0 -35
  70. package/effects/StereoEffect.js +0 -35
  71. package/environments/RoomEnvironment.cjs +0 -95
  72. package/environments/RoomEnvironment.js +0 -78
  73. package/exporters/ColladaExporter.cjs +0 -331
  74. package/exporters/ColladaExporter.js +0 -331
  75. package/exporters/DRACOExporter.cjs +0 -141
  76. package/exporters/DRACOExporter.js +0 -141
  77. package/exporters/GLTFExporter.cjs +0 -1909
  78. package/exporters/GLTFExporter.js +0 -1909
  79. package/exporters/MMDExporter.cjs +0 -131
  80. package/exporters/MMDExporter.js +0 -131
  81. package/exporters/OBJExporter.cjs +0 -181
  82. package/exporters/OBJExporter.js +0 -181
  83. package/exporters/PLYExporter.cjs +0 -280
  84. package/exporters/PLYExporter.js +0 -280
  85. package/exporters/STLExporter.cjs +0 -146
  86. package/exporters/STLExporter.js +0 -146
  87. package/exporters/USDZExporter.cjs +0 -340
  88. package/exporters/USDZExporter.js +0 -340
  89. package/geometries/BoxLineGeometry.cjs +0 -45
  90. package/geometries/BoxLineGeometry.js +0 -45
  91. package/geometries/ConvexGeometry.cjs +0 -26
  92. package/geometries/ConvexGeometry.js +0 -26
  93. package/geometries/DecalGeometry.cjs +0 -184
  94. package/geometries/DecalGeometry.js +0 -184
  95. package/geometries/LightningStrike.cjs +0 -553
  96. package/geometries/LightningStrike.js +0 -553
  97. package/geometries/ParametricGeometries.cjs +0 -130
  98. package/geometries/ParametricGeometries.js +0 -130
  99. package/geometries/ParametricGeometry.cjs +0 -63
  100. package/geometries/ParametricGeometry.js +0 -63
  101. package/geometries/RoundedBoxGeometry.cjs +0 -91
  102. package/geometries/RoundedBoxGeometry.js +0 -91
  103. package/geometries/TeapotGeometry.cjs +0 -1563
  104. package/geometries/TeapotGeometry.js +0 -1563
  105. package/geometries/TextGeometry.cjs +0 -27
  106. package/geometries/TextGeometry.js +0 -27
  107. package/helpers/LightProbeHelper.cjs +0 -73
  108. package/helpers/LightProbeHelper.js +0 -73
  109. package/helpers/PositionalAudioHelper.cjs +0 -68
  110. package/helpers/PositionalAudioHelper.js +0 -68
  111. package/helpers/RectAreaLightHelper.cjs +0 -44
  112. package/helpers/RectAreaLightHelper.js +0 -44
  113. package/helpers/VertexNormalsHelper.cjs +0 -47
  114. package/helpers/VertexNormalsHelper.js +0 -47
  115. package/helpers/VertexTangentsHelper.cjs +0 -43
  116. package/helpers/VertexTangentsHelper.js +0 -43
  117. package/interactive/HTMLMesh.cjs +0 -325
  118. package/interactive/HTMLMesh.js +0 -325
  119. package/interactive/InteractiveGroup.cjs +0 -68
  120. package/interactive/InteractiveGroup.js +0 -68
  121. package/interactive/SelectionBox.cjs +0 -134
  122. package/interactive/SelectionBox.js +0 -134
  123. package/interactive/SelectionHelper.cjs +0 -51
  124. package/interactive/SelectionHelper.js +0 -51
  125. package/libs/MeshoptDecoder.cjs +0 -221
  126. package/libs/MeshoptDecoder.js +0 -221
  127. package/libs/MotionControllers.cjs +0 -325
  128. package/libs/MotionControllers.js +0 -325
  129. package/lights/LightProbeGenerator.cjs +0 -145
  130. package/lights/LightProbeGenerator.js +0 -145
  131. package/lights/RectAreaLightUniformsLib.cjs +0 -32846
  132. package/lights/RectAreaLightUniformsLib.js +0 -32846
  133. package/lines/Line2.cjs +0 -13
  134. package/lines/Line2.js +0 -13
  135. package/lines/LineGeometry.cjs +0 -44
  136. package/lines/LineGeometry.js +0 -44
  137. package/lines/LineMaterial.cjs +0 -547
  138. package/lines/LineMaterial.js +0 -547
  139. package/lines/LineSegments2.cjs +0 -203
  140. package/lines/LineSegments2.js +0 -203
  141. package/lines/LineSegmentsGeometry.cjs +0 -124
  142. package/lines/LineSegmentsGeometry.js +0 -124
  143. package/lines/Wireframe.cjs +0 -32
  144. package/lines/Wireframe.js +0 -32
  145. package/lines/WireframeGeometry2.cjs +0 -13
  146. package/lines/WireframeGeometry2.js +0 -13
  147. package/loaders/3DMLoader.cjs +0 -803
  148. package/loaders/3DMLoader.js +0 -803
  149. package/loaders/3MFLoader.cjs +0 -854
  150. package/loaders/3MFLoader.js +0 -854
  151. package/loaders/AMFLoader.cjs +0 -284
  152. package/loaders/AMFLoader.js +0 -284
  153. package/loaders/AssimpLoader.cjs +0 -1434
  154. package/loaders/AssimpLoader.js +0 -1434
  155. package/loaders/BVHLoader.cjs +0 -207
  156. package/loaders/BVHLoader.js +0 -207
  157. package/loaders/BasisTextureLoader.cjs +0 -489
  158. package/loaders/BasisTextureLoader.js +0 -489
  159. package/loaders/ColladaLoader.cjs +0 -2405
  160. package/loaders/ColladaLoader.js +0 -2405
  161. package/loaders/DDSLoader.cjs +0 -148
  162. package/loaders/DDSLoader.js +0 -148
  163. package/loaders/DRACOLoader.cjs +0 -341
  164. package/loaders/DRACOLoader.js +0 -341
  165. package/loaders/EXRLoader.cjs +0 -1356
  166. package/loaders/EXRLoader.js +0 -1356
  167. package/loaders/FBXLoader.cjs +0 -2457
  168. package/loaders/FBXLoader.js +0 -2457
  169. package/loaders/FontLoader.cjs +0 -123
  170. package/loaders/FontLoader.js +0 -123
  171. package/loaders/GCodeLoader.cjs +0 -141
  172. package/loaders/GCodeLoader.js +0 -141
  173. package/loaders/GLTFLoader.cjs +0 -2504
  174. package/loaders/GLTFLoader.js +0 -2504
  175. package/loaders/HDRCubeTextureLoader.cjs +0 -75
  176. package/loaders/HDRCubeTextureLoader.js +0 -75
  177. package/loaders/KMZLoader.cjs +0 -75
  178. package/loaders/KMZLoader.js +0 -75
  179. package/loaders/KTX2Loader.cjs +0 -480
  180. package/loaders/KTX2Loader.js +0 -480
  181. package/loaders/KTXLoader.cjs +0 -93
  182. package/loaders/KTXLoader.js +0 -93
  183. package/loaders/LDrawLoader.cjs +0 -1424
  184. package/loaders/LDrawLoader.js +0 -1424
  185. package/loaders/LUT3dlLoader.cjs +0 -103
  186. package/loaders/LUT3dlLoader.js +0 -103
  187. package/loaders/LUTCubeLoader.cjs +0 -107
  188. package/loaders/LUTCubeLoader.js +0 -107
  189. package/loaders/LWOLoader.cjs +0 -645
  190. package/loaders/LWOLoader.js +0 -645
  191. package/loaders/LottieLoader.cjs +0 -47
  192. package/loaders/LottieLoader.js +0 -47
  193. package/loaders/MD2Loader.cjs +0 -359
  194. package/loaders/MD2Loader.js +0 -359
  195. package/loaders/MDDLoader.cjs +0 -58
  196. package/loaders/MDDLoader.js +0 -58
  197. package/loaders/MMDLoader.cjs +0 -1121
  198. package/loaders/MMDLoader.js +0 -1121
  199. package/loaders/MTLLoader.cjs +0 -304
  200. package/loaders/MTLLoader.js +0 -304
  201. package/loaders/NRRDLoader.cjs +0 -401
  202. package/loaders/NRRDLoader.js +0 -401
  203. package/loaders/OBJLoader.cjs +0 -487
  204. package/loaders/OBJLoader.js +0 -487
  205. package/loaders/PCDLoader.cjs +0 -248
  206. package/loaders/PCDLoader.js +0 -248
  207. package/loaders/PDBLoader.cjs +0 -247
  208. package/loaders/PDBLoader.js +0 -247
  209. package/loaders/PLYLoader.cjs +0 -317
  210. package/loaders/PLYLoader.js +0 -317
  211. package/loaders/PRWMLoader.cjs +0 -160
  212. package/loaders/PRWMLoader.js +0 -160
  213. package/loaders/PVRLoader.cjs +0 -131
  214. package/loaders/PVRLoader.js +0 -131
  215. package/loaders/RGBELoader.cjs +0 -252
  216. package/loaders/RGBELoader.js +0 -252
  217. package/loaders/RGBMLoader.cjs +0 -1004
  218. package/loaders/RGBMLoader.js +0 -1004
  219. package/loaders/STLLoader.cjs +0 -190
  220. package/loaders/STLLoader.js +0 -190
  221. package/loaders/SVGLoader.cjs +0 -1712
  222. package/loaders/SVGLoader.js +0 -1712
  223. package/loaders/TDSLoader.cjs +0 -650
  224. package/loaders/TDSLoader.js +0 -650
  225. package/loaders/TGALoader.cjs +0 -285
  226. package/loaders/TGALoader.js +0 -285
  227. package/loaders/TTFLoader.cjs +0 -131
  228. package/loaders/TTFLoader.js +0 -131
  229. package/loaders/TiltLoader.cjs +0 -375
  230. package/loaders/TiltLoader.js +0 -375
  231. package/loaders/VOXLoader.cjs +0 -432
  232. package/loaders/VOXLoader.js +0 -432
  233. package/loaders/VRMLLoader.cjs +0 -2105
  234. package/loaders/VRMLLoader.js +0 -2105
  235. package/loaders/VRMLoader.cjs +0 -38
  236. package/loaders/VRMLoader.js +0 -38
  237. package/loaders/VTKLoader.cjs +0 -648
  238. package/loaders/VTKLoader.js +0 -648
  239. package/loaders/XLoader.cjs +0 -1258
  240. package/loaders/XLoader.js +0 -1258
  241. package/loaders/XYZLoader.cjs +0 -60
  242. package/loaders/XYZLoader.js +0 -60
  243. package/loaders/lwo/IFFParser.cjs +0 -743
  244. package/loaders/lwo/IFFParser.js +0 -743
  245. package/loaders/lwo/LWO2Parser.cjs +0 -312
  246. package/loaders/lwo/LWO2Parser.js +0 -312
  247. package/loaders/lwo/LWO3Parser.cjs +0 -282
  248. package/loaders/lwo/LWO3Parser.js +0 -282
  249. package/math/Capsule.cjs +0 -98
  250. package/math/Capsule.js +0 -98
  251. package/math/ColorConverter.cjs +0 -42
  252. package/math/ColorConverter.js +0 -42
  253. package/math/ConvexHull.cjs +0 -596
  254. package/math/ConvexHull.js +0 -596
  255. package/math/ImprovedNoise.cjs +0 -304
  256. package/math/ImprovedNoise.js +0 -304
  257. package/math/Lut.cjs +0 -137
  258. package/math/Lut.js +0 -137
  259. package/math/MeshSurfaceSampler.cjs +0 -103
  260. package/math/MeshSurfaceSampler.js +0 -103
  261. package/math/OBB.cjs +0 -242
  262. package/math/OBB.js +0 -242
  263. package/math/Octree.cjs +0 -273
  264. package/math/Octree.js +0 -273
  265. package/math/SimplexNoise.cjs +0 -440
  266. package/math/SimplexNoise.js +0 -440
  267. package/misc/ConvexObjectBreaker.cjs +0 -292
  268. package/misc/ConvexObjectBreaker.js +0 -292
  269. package/misc/GPUComputationRenderer.cjs +0 -205
  270. package/misc/GPUComputationRenderer.js +0 -205
  271. package/misc/Gyroscope.cjs +0 -33
  272. package/misc/Gyroscope.js +0 -33
  273. package/misc/MD2Character.cjs +0 -167
  274. package/misc/MD2Character.js +0 -167
  275. package/misc/MD2CharacterComplex.cjs +0 -332
  276. package/misc/MD2CharacterComplex.js +0 -332
  277. package/misc/MorphAnimMesh.cjs +0 -40
  278. package/misc/MorphAnimMesh.js +0 -40
  279. package/misc/MorphBlendMesh.cjs +0 -179
  280. package/misc/MorphBlendMesh.js +0 -179
  281. package/misc/ProgressiveLightmap.cjs +0 -186
  282. package/misc/ProgressiveLightmap.js +0 -186
  283. package/misc/RollerCoaster.cjs +0 -353
  284. package/misc/RollerCoaster.js +0 -353
  285. package/misc/Timer.cjs +0 -101
  286. package/misc/Timer.js +0 -101
  287. package/misc/TubePainter.cjs +0 -123
  288. package/misc/TubePainter.js +0 -123
  289. package/misc/Volume.cjs +0 -305
  290. package/misc/Volume.js +0 -305
  291. package/misc/VolumeSlice.cjs +0 -114
  292. package/misc/VolumeSlice.js +0 -114
  293. package/misc/WebGL.cjs +0 -74
  294. package/misc/WebGL.js +0 -74
  295. package/modifiers/CurveModifier.cjs +0 -232
  296. package/modifiers/CurveModifier.js +0 -232
  297. package/modifiers/EdgeSplitModifier.cjs +0 -167
  298. package/modifiers/EdgeSplitModifier.js +0 -168
  299. package/modifiers/SimplifyModifier.cjs +0 -301
  300. package/modifiers/SimplifyModifier.js +0 -301
  301. package/modifiers/TessellateModifier.cjs +0 -214
  302. package/modifiers/TessellateModifier.js +0 -214
  303. package/objects/GroundProjectedEnv.cjs +0 -134
  304. package/objects/GroundProjectedEnv.js +0 -134
  305. package/objects/Lensflare.cjs +0 -291
  306. package/objects/Lensflare.js +0 -291
  307. package/objects/LightningStorm.cjs +0 -110
  308. package/objects/LightningStorm.js +0 -110
  309. package/objects/MarchingCubes.cjs +0 -4809
  310. package/objects/MarchingCubes.js +0 -4809
  311. package/objects/Reflector.cjs +0 -202
  312. package/objects/Reflector.js +0 -202
  313. package/objects/ReflectorForSSRPass.cjs +0 -260
  314. package/objects/ReflectorForSSRPass.js +0 -260
  315. package/objects/ReflectorRTT.cjs +0 -10
  316. package/objects/ReflectorRTT.js +0 -10
  317. package/objects/Refractor.cjs +0 -215
  318. package/objects/Refractor.js +0 -215
  319. package/objects/ShadowMesh.cjs +0 -45
  320. package/objects/ShadowMesh.js +0 -45
  321. package/objects/Sky.cjs +0 -200
  322. package/objects/Sky.js +0 -200
  323. package/objects/Water.cjs +0 -242
  324. package/objects/Water.js +0 -242
  325. package/objects/Water2.cjs +0 -256
  326. package/objects/Water2.js +0 -256
  327. package/physics/AmmoPhysics.cjs +0 -166
  328. package/physics/AmmoPhysics.js +0 -166
  329. package/postprocessing/AdaptiveToneMappingPass.cjs +0 -218
  330. package/postprocessing/AdaptiveToneMappingPass.js +0 -218
  331. package/postprocessing/AfterimagePass.cjs +0 -68
  332. package/postprocessing/AfterimagePass.js +0 -68
  333. package/postprocessing/BloomPass.cjs +0 -109
  334. package/postprocessing/BloomPass.js +0 -109
  335. package/postprocessing/BokehPass.cjs +0 -90
  336. package/postprocessing/BokehPass.js +0 -90
  337. package/postprocessing/ClearPass.cjs +0 -36
  338. package/postprocessing/ClearPass.js +0 -36
  339. package/postprocessing/CubeTexturePass.cjs +0 -53
  340. package/postprocessing/CubeTexturePass.js +0 -53
  341. package/postprocessing/DotScreenPass.cjs +0 -49
  342. package/postprocessing/DotScreenPass.js +0 -49
  343. package/postprocessing/EffectComposer.cjs +0 -157
  344. package/postprocessing/EffectComposer.js +0 -157
  345. package/postprocessing/FilmPass.cjs +0 -51
  346. package/postprocessing/FilmPass.js +0 -51
  347. package/postprocessing/GlitchPass.cjs +0 -84
  348. package/postprocessing/GlitchPass.js +0 -84
  349. package/postprocessing/HalftonePass.cjs +0 -53
  350. package/postprocessing/HalftonePass.js +0 -53
  351. package/postprocessing/LUTPass.cjs +0 -142
  352. package/postprocessing/LUTPass.js +0 -142
  353. package/postprocessing/MaskPass.cjs +0 -69
  354. package/postprocessing/MaskPass.js +0 -69
  355. package/postprocessing/OutlinePass.cjs +0 -479
  356. package/postprocessing/OutlinePass.js +0 -479
  357. package/postprocessing/Pass.cjs +0 -48
  358. package/postprocessing/Pass.js +0 -48
  359. package/postprocessing/RenderPass.cjs +0 -59
  360. package/postprocessing/RenderPass.js +0 -59
  361. package/postprocessing/RenderPixelatedPass.cjs +0 -199
  362. package/postprocessing/RenderPixelatedPass.js +0 -199
  363. package/postprocessing/SAOPass.cjs +0 -288
  364. package/postprocessing/SAOPass.js +0 -288
  365. package/postprocessing/SMAAPass.cjs +0 -112
  366. package/postprocessing/SMAAPass.js +0 -112
  367. package/postprocessing/SSAARenderPass.cjs +0 -189
  368. package/postprocessing/SSAARenderPass.js +0 -189
  369. package/postprocessing/SSAOPass.cjs +0 -272
  370. package/postprocessing/SSAOPass.js +0 -272
  371. package/postprocessing/SSRPass.cjs +0 -411
  372. package/postprocessing/SSRPass.js +0 -411
  373. package/postprocessing/SavePass.cjs +0 -38
  374. package/postprocessing/SavePass.js +0 -38
  375. package/postprocessing/ShaderPass.cjs +0 -49
  376. package/postprocessing/ShaderPass.js +0 -49
  377. package/postprocessing/TAARenderPass.cjs +0 -174
  378. package/postprocessing/TAARenderPass.js +0 -174
  379. package/postprocessing/TexturePass.cjs +0 -42
  380. package/postprocessing/TexturePass.js +0 -42
  381. package/postprocessing/UnrealBloomPass.cjs +0 -277
  382. package/postprocessing/UnrealBloomPass.js +0 -277
  383. package/postprocessing/WaterPass.cjs +0 -72
  384. package/postprocessing/WaterPass.js +0 -72
  385. package/renderers/CSS2DRenderer.cjs +0 -122
  386. package/renderers/CSS2DRenderer.js +0 -122
  387. package/renderers/CSS3DRenderer.cjs +0 -167
  388. package/renderers/CSS3DRenderer.js +0 -167
  389. package/renderers/Projector.cjs +0 -499
  390. package/renderers/Projector.js +0 -499
  391. package/renderers/SVGRenderer.cjs +0 -311
  392. package/renderers/SVGRenderer.js +0 -311
  393. package/shaders/ACESFilmicToneMappingShader.cjs +0 -55
  394. package/shaders/ACESFilmicToneMappingShader.js +0 -55
  395. package/shaders/AfterimageShader.cjs +0 -32
  396. package/shaders/AfterimageShader.js +0 -32
  397. package/shaders/BasicShader.cjs +0 -12
  398. package/shaders/BasicShader.js +0 -12
  399. package/shaders/BleachBypassShader.cjs +0 -35
  400. package/shaders/BleachBypassShader.js +0 -35
  401. package/shaders/BlendShader.cjs +0 -30
  402. package/shaders/BlendShader.js +0 -30
  403. package/shaders/BokehShader.cjs +0 -109
  404. package/shaders/BokehShader.js +0 -109
  405. package/shaders/BokehShader2.cjs +0 -269
  406. package/shaders/BokehShader2.js +0 -269
  407. package/shaders/BrightnessContrastShader.cjs +0 -32
  408. package/shaders/BrightnessContrastShader.js +0 -32
  409. package/shaders/ColorCorrectionShader.cjs +0 -30
  410. package/shaders/ColorCorrectionShader.js +0 -30
  411. package/shaders/ColorifyShader.cjs +0 -28
  412. package/shaders/ColorifyShader.js +0 -28
  413. package/shaders/ConvolutionShader.cjs +0 -55
  414. package/shaders/ConvolutionShader.js +0 -55
  415. package/shaders/CopyShader.cjs +0 -25
  416. package/shaders/CopyShader.js +0 -25
  417. package/shaders/DOFMipMapShader.cjs +0 -32
  418. package/shaders/DOFMipMapShader.js +0 -32
  419. package/shaders/DepthLimitedBlurShader.cjs +0 -114
  420. package/shaders/DepthLimitedBlurShader.js +0 -114
  421. package/shaders/DigitalGlitch.cjs +0 -85
  422. package/shaders/DigitalGlitch.js +0 -85
  423. package/shaders/DotScreenShader.cjs +0 -39
  424. package/shaders/DotScreenShader.js +0 -39
  425. package/shaders/FXAAShader.cjs +0 -1098
  426. package/shaders/FXAAShader.js +0 -1098
  427. package/shaders/FilmShader.cjs +0 -53
  428. package/shaders/FilmShader.js +0 -53
  429. package/shaders/FocusShader.cjs +0 -55
  430. package/shaders/FocusShader.js +0 -55
  431. package/shaders/FreiChenShader.cjs +0 -64
  432. package/shaders/FreiChenShader.js +0 -64
  433. package/shaders/FresnelShader.cjs +0 -47
  434. package/shaders/FresnelShader.js +0 -47
  435. package/shaders/GammaCorrectionShader.cjs +0 -23
  436. package/shaders/GammaCorrectionShader.js +0 -23
  437. package/shaders/GodRaysShader.cjs +0 -183
  438. package/shaders/GodRaysShader.js +0 -183
  439. package/shaders/HalftoneShader.cjs +0 -228
  440. package/shaders/HalftoneShader.js +0 -228
  441. package/shaders/HorizontalBlurShader.cjs +0 -49
  442. package/shaders/HorizontalBlurShader.js +0 -49
  443. package/shaders/HorizontalTiltShiftShader.cjs +0 -37
  444. package/shaders/HorizontalTiltShiftShader.js +0 -37
  445. package/shaders/HueSaturationShader.cjs +0 -43
  446. package/shaders/HueSaturationShader.js +0 -43
  447. package/shaders/KaleidoShader.cjs +0 -34
  448. package/shaders/KaleidoShader.js +0 -34
  449. package/shaders/LuminosityHighPassShader.cjs +0 -37
  450. package/shaders/LuminosityHighPassShader.js +0 -37
  451. package/shaders/LuminosityShader.cjs +0 -25
  452. package/shaders/LuminosityShader.js +0 -25
  453. package/shaders/MirrorShader.cjs +0 -35
  454. package/shaders/MirrorShader.js +0 -35
  455. package/shaders/NormalMapShader.cjs +0 -31
  456. package/shaders/NormalMapShader.js +0 -31
  457. package/shaders/ParallaxShader.cjs +0 -133
  458. package/shaders/ParallaxShader.js +0 -133
  459. package/shaders/PixelShader.cjs +0 -28
  460. package/shaders/PixelShader.js +0 -28
  461. package/shaders/RGBShiftShader.cjs +0 -30
  462. package/shaders/RGBShiftShader.js +0 -30
  463. package/shaders/SAOShader.cjs +0 -144
  464. package/shaders/SAOShader.js +0 -144
  465. package/shaders/SMAAShader.cjs +0 -358
  466. package/shaders/SMAAShader.js +0 -358
  467. package/shaders/SSAOShader.cjs +0 -182
  468. package/shaders/SSAOShader.js +0 -182
  469. package/shaders/SSRShader.cjs +0 -342
  470. package/shaders/SSRShader.js +0 -342
  471. package/shaders/SepiaShader.cjs +0 -29
  472. package/shaders/SepiaShader.js +0 -29
  473. package/shaders/SobelOperatorShader.cjs +0 -54
  474. package/shaders/SobelOperatorShader.js +0 -54
  475. package/shaders/SubsurfaceScatteringShader.cjs +0 -98
  476. package/shaders/SubsurfaceScatteringShader.js +0 -98
  477. package/shaders/TechnicolorShader.cjs +0 -24
  478. package/shaders/TechnicolorShader.js +0 -24
  479. package/shaders/ToneMapShader.cjs +0 -51
  480. package/shaders/ToneMapShader.js +0 -51
  481. package/shaders/ToonShader.cjs +0 -188
  482. package/shaders/ToonShader.js +0 -188
  483. package/shaders/TriangleBlurShader.cjs +0 -37
  484. package/shaders/TriangleBlurShader.js +0 -37
  485. package/shaders/UnpackDepthRGBAShader.cjs +0 -26
  486. package/shaders/UnpackDepthRGBAShader.js +0 -26
  487. package/shaders/VerticalBlurShader.cjs +0 -50
  488. package/shaders/VerticalBlurShader.js +0 -50
  489. package/shaders/VerticalTiltShiftShader.cjs +0 -37
  490. package/shaders/VerticalTiltShiftShader.js +0 -37
  491. package/shaders/VignetteShader.cjs +0 -38
  492. package/shaders/VignetteShader.js +0 -38
  493. package/shaders/VolumeShader.cjs +0 -225
  494. package/shaders/VolumeShader.js +0 -225
  495. package/shaders/WaterRefractionShader.cjs +0 -59
  496. package/shaders/WaterRefractionShader.js +0 -59
  497. package/shaders/types.cjs +0 -1
  498. package/shaders/types.js +0 -1
  499. package/textures/FlakesTexture.cjs +0 -30
  500. package/textures/FlakesTexture.js +0 -30
  501. package/types/helpers.cjs +0 -4
  502. package/types/helpers.js +0 -4
  503. package/utils/BufferGeometryUtils.cjs +0 -636
  504. package/utils/BufferGeometryUtils.js +0 -636
  505. package/utils/GeometryCompressionUtils.cjs +0 -573
  506. package/utils/GeometryCompressionUtils.js +0 -573
  507. package/utils/GeometryUtils.cjs +0 -109
  508. package/utils/GeometryUtils.js +0 -109
  509. package/utils/RoughnessMipmapper.cjs +0 -223
  510. package/utils/RoughnessMipmapper.js +0 -223
  511. package/utils/SceneUtils.cjs +0 -36
  512. package/utils/SceneUtils.js +0 -36
  513. package/utils/ShadowMapViewer.cjs +0 -111
  514. package/utils/ShadowMapViewer.js +0 -111
  515. package/utils/SkeletonUtils.cjs +0 -211
  516. package/utils/SkeletonUtils.js +0 -211
  517. package/utils/UVsDebug.cjs +0 -80
  518. package/utils/UVsDebug.js +0 -80
  519. package/utils/WorkerPool.cjs +0 -62
  520. package/utils/WorkerPool.js +0 -62
  521. package/webxr/ARButton.cjs +0 -119
  522. package/webxr/ARButton.js +0 -119
  523. package/webxr/OculusHandModel.cjs +0 -82
  524. package/webxr/OculusHandModel.js +0 -82
  525. package/webxr/OculusHandPointerModel.cjs +0 -241
  526. package/webxr/OculusHandPointerModel.js +0 -224
  527. package/webxr/Text2D.cjs +0 -48
  528. package/webxr/Text2D.js +0 -31
  529. package/webxr/VRButton.cjs +0 -111
  530. package/webxr/VRButton.js +0 -111
  531. package/webxr/XRControllerModelFactory.cjs +0 -174
  532. package/webxr/XRControllerModelFactory.js +0 -174
  533. package/webxr/XREstimatedLight.cjs +0 -126
  534. package/webxr/XREstimatedLight.js +0 -126
  535. package/webxr/XRHandMeshModel.cjs +0 -82
  536. package/webxr/XRHandMeshModel.js +0 -82
  537. package/webxr/XRHandModelFactory.cjs +0 -61
  538. package/webxr/XRHandModelFactory.js +0 -61
  539. package/webxr/XRHandPrimitiveModel.cjs +0 -68
  540. package/webxr/XRHandPrimitiveModel.js +0 -68
@@ -1,1121 +0,0 @@
1
- import { Loader, FileLoader, LoaderUtils, SkinnedMesh, Skeleton, Bone, Vector3, Float32BufferAttribute, BufferGeometry, Uint16BufferAttribute, TextureLoader, Color, CustomBlending, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, DoubleSide, FrontSide, MultiplyOperation, AddOperation, MeshToonMaterial, NearestFilter, RepeatWrapping, AnimationClip, VectorKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, Quaternion, Euler, Interpolant } from "three";
2
- import { TGALoader } from "./TGALoader.js";
3
- import { Parser } from "mmd-parser";
4
- class MMDLoader extends Loader {
5
- constructor(manager) {
6
- super(manager);
7
- this.loader = new FileLoader(this.manager);
8
- this.parser = null;
9
- this.meshBuilder = new MeshBuilder(this.manager);
10
- this.animationBuilder = new AnimationBuilder();
11
- }
12
- /**
13
- * @param {string} animationPath
14
- * @return {MMDLoader}
15
- */
16
- setAnimationPath(animationPath) {
17
- this.animationPath = animationPath;
18
- return this;
19
- }
20
- // Load MMD assets as Three.js Object
21
- /**
22
- * Loads Model file (.pmd or .pmx) as a SkinnedMesh.
23
- *
24
- * @param {string} url - url to Model(.pmd or .pmx) file
25
- * @param {function} onLoad
26
- * @param {function} onProgress
27
- * @param {function} onError
28
- */
29
- load(url, onLoad, onProgress, onError) {
30
- const builder = this.meshBuilder.setCrossOrigin(this.crossOrigin);
31
- let resourcePath;
32
- if (this.resourcePath !== "") {
33
- resourcePath = this.resourcePath;
34
- } else if (this.path !== "") {
35
- resourcePath = this.path;
36
- } else {
37
- resourcePath = LoaderUtils.extractUrlBase(url);
38
- }
39
- const modelExtension = this._extractExtension(url).toLowerCase();
40
- if (modelExtension !== "pmd" && modelExtension !== "pmx") {
41
- if (onError)
42
- onError(new Error("THREE.MMDLoader: Unknown model file extension ." + modelExtension + "."));
43
- return;
44
- }
45
- this[modelExtension === "pmd" ? "loadPMD" : "loadPMX"](
46
- url,
47
- function(data) {
48
- onLoad(builder.build(data, resourcePath, onProgress, onError));
49
- },
50
- onProgress,
51
- onError
52
- );
53
- }
54
- /**
55
- * Loads Motion file(s) (.vmd) as a AnimationClip.
56
- * If two or more files are specified, they'll be merged.
57
- *
58
- * @param {string|Array<string>} url - url(s) to animation(.vmd) file(s)
59
- * @param {SkinnedMesh|THREE.Camera} object - tracks will be fitting to this object
60
- * @param {function} onLoad
61
- * @param {function} onProgress
62
- * @param {function} onError
63
- */
64
- loadAnimation(url, object, onLoad, onProgress, onError) {
65
- const builder = this.animationBuilder;
66
- this.loadVMD(
67
- url,
68
- function(vmd) {
69
- onLoad(object.isCamera ? builder.buildCameraAnimation(vmd) : builder.build(vmd, object));
70
- },
71
- onProgress,
72
- onError
73
- );
74
- }
75
- /**
76
- * Loads mode file and motion file(s) as an object containing
77
- * a SkinnedMesh and a AnimationClip.
78
- * Tracks of AnimationClip are fitting to the model.
79
- *
80
- * @param {string} modelUrl - url to Model(.pmd or .pmx) file
81
- * @param {string|Array{string}} vmdUrl - url(s) to animation(.vmd) file
82
- * @param {function} onLoad
83
- * @param {function} onProgress
84
- * @param {function} onError
85
- */
86
- loadWithAnimation(modelUrl, vmdUrl, onLoad, onProgress, onError) {
87
- const scope = this;
88
- this.load(
89
- modelUrl,
90
- function(mesh) {
91
- scope.loadAnimation(
92
- vmdUrl,
93
- mesh,
94
- function(animation) {
95
- onLoad({
96
- mesh,
97
- animation
98
- });
99
- },
100
- onProgress,
101
- onError
102
- );
103
- },
104
- onProgress,
105
- onError
106
- );
107
- }
108
- // Load MMD assets as Object data parsed by MMDParser
109
- /**
110
- * Loads .pmd file as an Object.
111
- *
112
- * @param {string} url - url to .pmd file
113
- * @param {function} onLoad
114
- * @param {function} onProgress
115
- * @param {function} onError
116
- */
117
- loadPMD(url, onLoad, onProgress, onError) {
118
- const parser = this._getParser();
119
- this.loader.setMimeType(void 0).setPath(this.path).setResponseType("arraybuffer").setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials).load(
120
- url,
121
- function(buffer) {
122
- onLoad(parser.parsePmd(buffer, true));
123
- },
124
- onProgress,
125
- onError
126
- );
127
- }
128
- /**
129
- * Loads .pmx file as an Object.
130
- *
131
- * @param {string} url - url to .pmx file
132
- * @param {function} onLoad
133
- * @param {function} onProgress
134
- * @param {function} onError
135
- */
136
- loadPMX(url, onLoad, onProgress, onError) {
137
- const parser = this._getParser();
138
- this.loader.setMimeType(void 0).setPath(this.path).setResponseType("arraybuffer").setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials).load(
139
- url,
140
- function(buffer) {
141
- onLoad(parser.parsePmx(buffer, true));
142
- },
143
- onProgress,
144
- onError
145
- );
146
- }
147
- /**
148
- * Loads .vmd file as an Object. If two or more files are specified
149
- * they'll be merged.
150
- *
151
- * @param {string|Array<string>} url - url(s) to .vmd file(s)
152
- * @param {function} onLoad
153
- * @param {function} onProgress
154
- * @param {function} onError
155
- */
156
- loadVMD(url, onLoad, onProgress, onError) {
157
- const urls = Array.isArray(url) ? url : [url];
158
- const vmds = [];
159
- const vmdNum = urls.length;
160
- const parser = this._getParser();
161
- this.loader.setMimeType(void 0).setPath(this.animationPath).setResponseType("arraybuffer").setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials);
162
- for (let i = 0, il = urls.length; i < il; i++) {
163
- this.loader.load(
164
- urls[i],
165
- function(buffer) {
166
- vmds.push(parser.parseVmd(buffer, true));
167
- if (vmds.length === vmdNum)
168
- onLoad(parser.mergeVmds(vmds));
169
- },
170
- onProgress,
171
- onError
172
- );
173
- }
174
- }
175
- /**
176
- * Loads .vpd file as an Object.
177
- *
178
- * @param {string} url - url to .vpd file
179
- * @param {boolean} isUnicode
180
- * @param {function} onLoad
181
- * @param {function} onProgress
182
- * @param {function} onError
183
- */
184
- loadVPD(url, isUnicode, onLoad, onProgress, onError) {
185
- const parser = this._getParser();
186
- this.loader.setMimeType(isUnicode ? void 0 : "text/plain; charset=shift_jis").setPath(this.animationPath).setResponseType("text").setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials).load(
187
- url,
188
- function(text) {
189
- onLoad(parser.parseVpd(text, true));
190
- },
191
- onProgress,
192
- onError
193
- );
194
- }
195
- // private methods
196
- _extractExtension(url) {
197
- const index = url.lastIndexOf(".");
198
- return index < 0 ? "" : url.slice(index + 1);
199
- }
200
- _getParser() {
201
- if (this.parser === null) {
202
- this.parser = new Parser();
203
- }
204
- return this.parser;
205
- }
206
- }
207
- const DEFAULT_TOON_TEXTURES = [
208
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=",
209
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/bWiiMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh8aBHZBl14e8wAAAABJRU5ErkJggg==",
210
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOUlEQVRYR+3WMREAMAwDsYY/yoDI7MLwIiP40+RJklfcCCBAgAABAgTqArfb/QMCCBAgQIAAgbbAB3z/e0F3js2cAAAAAElFTkSuQmCC",
211
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/B5ilMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh81dWyx0gFwKAAAAABJRU5ErkJggg==",
212
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOklEQVRYR+3WoREAMAwDsWb/UQtCy9wxTOQJ/oQ8SXKKGwEECBAgQIBAXeDt7f4BAQQIECBAgEBb4AOz8Hzx7WLY4wAAAABJRU5ErkJggg==",
213
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYR+1XwW7CMAy1+f9fZOMysSEOEweEOPRNdm3HbdOyIhAcklPrOs/PLy9RygBALxzcCDQFmgJNgaZAU6Ap0BR4PwX8gsRMVLssMRH5HcpzJEaWL7EVg9F1IHRlyqQohgVr4FGUlUcMJSjcUlDw0zvjeun70cLWmneoyf7NgBTQSniBTQQSuJAZsOnnaczjIMb5hCiuHKxokCrJfVnrctyZL0PkJAJe1HMil4nxeyi3Ypfn1kX51jpPvo/JeCNC4PhVdHdJw2XjBR8brF8PEIhNVn12AgP7uHsTBguBn53MUZCqv7Lp07Pn5k1Ro+uWmUNn7D+M57rtk7aG0Vo73xyF/fbFf0bPJjDXngnGocDTdFhygZjwUQrMNrDcmZlQT50VJ/g/UwNyHpu778+yW+/ksOz/BFo54P4AsUXMfRq7XWsAAAAASUVORK5CYII=",
214
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAACMElEQVRYR+2Xv4pTQRTGf2dubhLdICiii2KnYKHVolhauKWPoGAnNr6BD6CvIVaihYuI2i1ia0BY0MZGRHQXjZj/mSPnnskfNWiWZUlzJ5k7M2cm833nO5Mziej2DWWJRUoCpQKlAntSQCqgw39/iUWAGmh37jrRnVsKlgpiqmkoGVABA7E57fvY+pJDdgKqF6HzFCSADkDq+F6AHABtQ+UMVE5D7zXod7fFNhTEckTbj5XQgHzNN+5tQvc5NG7C6BNkp6D3EmpXHDR+dQAjFLchW3VS9rlw3JBh+B7ys5Cf9z0GW1C/7P32AyBAOAz1q4jGliIH3YPuBnSfQX4OGreTIgEYQb/pBDtPnEQ4CivXYPAWBk13oHrB54yA9QuSn2H4AcKRpEILDt0BUzj+RLR1V5EqjD66NPRBVpLcQwjHoHYJOhsQv6U4mnzmrIXJCFr4LDwm/xBUoboG9XX4cc9VKdYoSA2yk5NQLJaKDUjTBoveG3Z2TElTxwjNK4M3LEZgUdDdruvcXzKBpStgp2NPiWi3ks9ZXxIoFVi+AvHLdc9TqtjL3/aYjpPlrzOcEnK62Szhimdd7xX232zFDTgtxezOu3WNMRLjiKgjtOhHVMd1loynVHvOgjuIIJMaELEqhJAV/RCSLbWTcfPFakFgFlALTRRvx+ok6Hlp/Q+v3fmx90bMyUzaEAhmM3KvHlXTL5DxnbGf/1M8RNNACLL5MNtPxP/mypJAqcDSFfgFhpYqWUzhTEAAAAAASUVORK5CYII=",
215
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=",
216
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=",
217
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=",
218
- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII="
219
- ];
220
- class MeshBuilder {
221
- constructor(manager) {
222
- this.crossOrigin = "anonymous";
223
- this.geometryBuilder = new GeometryBuilder();
224
- this.materialBuilder = new MaterialBuilder(manager);
225
- }
226
- /**
227
- * @param {string} crossOrigin
228
- * @return {MeshBuilder}
229
- */
230
- setCrossOrigin(crossOrigin) {
231
- this.crossOrigin = crossOrigin;
232
- return this;
233
- }
234
- /**
235
- * @param {Object} data - parsed PMD/PMX data
236
- * @param {string} resourcePath
237
- * @param {function} onProgress
238
- * @param {function} onError
239
- * @return {SkinnedMesh}
240
- */
241
- build(data, resourcePath, onProgress, onError) {
242
- const geometry = this.geometryBuilder.build(data);
243
- const material = this.materialBuilder.setCrossOrigin(this.crossOrigin).setResourcePath(resourcePath).build(data, geometry, onProgress, onError);
244
- const mesh = new SkinnedMesh(geometry, material);
245
- const skeleton = new Skeleton(initBones(mesh));
246
- mesh.bind(skeleton);
247
- return mesh;
248
- }
249
- }
250
- function initBones(mesh) {
251
- const geometry = mesh.geometry;
252
- const bones = [];
253
- if (geometry && geometry.bones !== void 0) {
254
- for (let i = 0, il = geometry.bones.length; i < il; i++) {
255
- const gbone = geometry.bones[i];
256
- const bone = new Bone();
257
- bones.push(bone);
258
- bone.name = gbone.name;
259
- bone.position.fromArray(gbone.pos);
260
- bone.quaternion.fromArray(gbone.rotq);
261
- if (gbone.scl !== void 0)
262
- bone.scale.fromArray(gbone.scl);
263
- }
264
- for (let i = 0, il = geometry.bones.length; i < il; i++) {
265
- const gbone = geometry.bones[i];
266
- if (gbone.parent !== -1 && gbone.parent !== null && bones[gbone.parent] !== void 0) {
267
- bones[gbone.parent].add(bones[i]);
268
- } else {
269
- mesh.add(bones[i]);
270
- }
271
- }
272
- }
273
- mesh.updateMatrixWorld(true);
274
- return bones;
275
- }
276
- class GeometryBuilder {
277
- /**
278
- * @param {Object} data - parsed PMD/PMX data
279
- * @return {BufferGeometry}
280
- */
281
- build(data) {
282
- const positions = [];
283
- const uvs = [];
284
- const normals = [];
285
- const indices = [];
286
- const groups = [];
287
- const bones = [];
288
- const skinIndices = [];
289
- const skinWeights = [];
290
- const morphTargets = [];
291
- const morphPositions = [];
292
- const iks = [];
293
- const grants = [];
294
- const rigidBodies = [];
295
- const constraints = [];
296
- let offset = 0;
297
- const boneTypeTable = {};
298
- for (let i = 0; i < data.metadata.vertexCount; i++) {
299
- const v = data.vertices[i];
300
- for (let j = 0, jl = v.position.length; j < jl; j++) {
301
- positions.push(v.position[j]);
302
- }
303
- for (let j = 0, jl = v.normal.length; j < jl; j++) {
304
- normals.push(v.normal[j]);
305
- }
306
- for (let j = 0, jl = v.uv.length; j < jl; j++) {
307
- uvs.push(v.uv[j]);
308
- }
309
- for (let j = 0; j < 4; j++) {
310
- skinIndices.push(v.skinIndices.length - 1 >= j ? v.skinIndices[j] : 0);
311
- }
312
- for (let j = 0; j < 4; j++) {
313
- skinWeights.push(v.skinWeights.length - 1 >= j ? v.skinWeights[j] : 0);
314
- }
315
- }
316
- for (let i = 0; i < data.metadata.faceCount; i++) {
317
- const face = data.faces[i];
318
- for (let j = 0, jl = face.indices.length; j < jl; j++) {
319
- indices.push(face.indices[j]);
320
- }
321
- }
322
- for (let i = 0; i < data.metadata.materialCount; i++) {
323
- const material = data.materials[i];
324
- groups.push({
325
- offset: offset * 3,
326
- count: material.faceCount * 3
327
- });
328
- offset += material.faceCount;
329
- }
330
- for (let i = 0; i < data.metadata.rigidBodyCount; i++) {
331
- const body = data.rigidBodies[i];
332
- let value = boneTypeTable[body.boneIndex];
333
- value = value === void 0 ? body.type : Math.max(body.type, value);
334
- boneTypeTable[body.boneIndex] = value;
335
- }
336
- for (let i = 0; i < data.metadata.boneCount; i++) {
337
- const boneData = data.bones[i];
338
- const bone = {
339
- index: i,
340
- transformationClass: boneData.transformationClass,
341
- parent: boneData.parentIndex,
342
- name: boneData.name,
343
- pos: boneData.position.slice(0, 3),
344
- rotq: [0, 0, 0, 1],
345
- scl: [1, 1, 1],
346
- rigidBodyType: boneTypeTable[i] !== void 0 ? boneTypeTable[i] : -1
347
- };
348
- if (bone.parent !== -1) {
349
- bone.pos[0] -= data.bones[bone.parent].position[0];
350
- bone.pos[1] -= data.bones[bone.parent].position[1];
351
- bone.pos[2] -= data.bones[bone.parent].position[2];
352
- }
353
- bones.push(bone);
354
- }
355
- if (data.metadata.format === "pmd") {
356
- for (let i = 0; i < data.metadata.ikCount; i++) {
357
- const ik = data.iks[i];
358
- const param = {
359
- target: ik.target,
360
- effector: ik.effector,
361
- iteration: ik.iteration,
362
- maxAngle: ik.maxAngle * 4,
363
- links: []
364
- };
365
- for (let j = 0, jl = ik.links.length; j < jl; j++) {
366
- const link = {};
367
- link.index = ik.links[j].index;
368
- link.enabled = true;
369
- if (data.bones[link.index].name.indexOf("ひざ") >= 0) {
370
- link.limitation = new Vector3(1, 0, 0);
371
- }
372
- param.links.push(link);
373
- }
374
- iks.push(param);
375
- }
376
- } else {
377
- for (let i = 0; i < data.metadata.boneCount; i++) {
378
- const ik = data.bones[i].ik;
379
- if (ik === void 0)
380
- continue;
381
- const param = {
382
- target: i,
383
- effector: ik.effector,
384
- iteration: ik.iteration,
385
- maxAngle: ik.maxAngle,
386
- links: []
387
- };
388
- for (let j = 0, jl = ik.links.length; j < jl; j++) {
389
- const link = {};
390
- link.index = ik.links[j].index;
391
- link.enabled = true;
392
- if (ik.links[j].angleLimitation === 1) {
393
- const rotationMin = ik.links[j].lowerLimitationAngle;
394
- const rotationMax = ik.links[j].upperLimitationAngle;
395
- const tmp1 = -rotationMax[0];
396
- const tmp2 = -rotationMax[1];
397
- rotationMax[0] = -rotationMin[0];
398
- rotationMax[1] = -rotationMin[1];
399
- rotationMin[0] = tmp1;
400
- rotationMin[1] = tmp2;
401
- link.rotationMin = new Vector3().fromArray(rotationMin);
402
- link.rotationMax = new Vector3().fromArray(rotationMax);
403
- }
404
- param.links.push(link);
405
- }
406
- iks.push(param);
407
- bones[i].ik = param;
408
- }
409
- }
410
- if (data.metadata.format === "pmx") {
411
- let traverse = function(entry) {
412
- if (entry.param) {
413
- grants.push(entry.param);
414
- bones[entry.param.index].grant = entry.param;
415
- }
416
- entry.visited = true;
417
- for (let i = 0, il = entry.children.length; i < il; i++) {
418
- const child = entry.children[i];
419
- if (!child.visited)
420
- traverse(child);
421
- }
422
- };
423
- const grantEntryMap = {};
424
- for (let i = 0; i < data.metadata.boneCount; i++) {
425
- const boneData = data.bones[i];
426
- const grant = boneData.grant;
427
- if (grant === void 0)
428
- continue;
429
- const param = {
430
- index: i,
431
- parentIndex: grant.parentIndex,
432
- ratio: grant.ratio,
433
- isLocal: grant.isLocal,
434
- affectRotation: grant.affectRotation,
435
- affectPosition: grant.affectPosition,
436
- transformationClass: boneData.transformationClass
437
- };
438
- grantEntryMap[i] = { parent: null, children: [], param, visited: false };
439
- }
440
- const rootEntry = { parent: null, children: [], param: null, visited: false };
441
- for (const boneIndex in grantEntryMap) {
442
- const grantEntry = grantEntryMap[boneIndex];
443
- const parentGrantEntry = grantEntryMap[grantEntry.parentIndex] || rootEntry;
444
- grantEntry.parent = parentGrantEntry;
445
- parentGrantEntry.children.push(grantEntry);
446
- }
447
- traverse(rootEntry);
448
- }
449
- function updateAttributes(attribute, morph, ratio) {
450
- for (let i = 0; i < morph.elementCount; i++) {
451
- const element = morph.elements[i];
452
- let index;
453
- if (data.metadata.format === "pmd") {
454
- index = data.morphs[0].elements[element.index].index;
455
- } else {
456
- index = element.index;
457
- }
458
- attribute.array[index * 3 + 0] += element.position[0] * ratio;
459
- attribute.array[index * 3 + 1] += element.position[1] * ratio;
460
- attribute.array[index * 3 + 2] += element.position[2] * ratio;
461
- }
462
- }
463
- for (let i = 0; i < data.metadata.morphCount; i++) {
464
- const morph = data.morphs[i];
465
- const params = { name: morph.name };
466
- const attribute = new Float32BufferAttribute(data.metadata.vertexCount * 3, 3);
467
- attribute.name = morph.name;
468
- for (let j = 0; j < data.metadata.vertexCount * 3; j++) {
469
- attribute.array[j] = positions[j];
470
- }
471
- if (data.metadata.format === "pmd") {
472
- if (i !== 0) {
473
- updateAttributes(attribute, morph, 1);
474
- }
475
- } else {
476
- if (morph.type === 0) {
477
- for (let j = 0; j < morph.elementCount; j++) {
478
- const morph2 = data.morphs[morph.elements[j].index];
479
- const ratio = morph.elements[j].ratio;
480
- if (morph2.type === 1) {
481
- updateAttributes(attribute, morph2, ratio);
482
- } else {
483
- }
484
- }
485
- } else if (morph.type === 1) {
486
- updateAttributes(attribute, morph, 1);
487
- } else if (morph.type === 2) {
488
- } else if (morph.type === 3) {
489
- } else if (morph.type === 4) {
490
- } else if (morph.type === 5) {
491
- } else if (morph.type === 6) {
492
- } else if (morph.type === 7) {
493
- } else if (morph.type === 8) {
494
- }
495
- }
496
- morphTargets.push(params);
497
- morphPositions.push(attribute);
498
- }
499
- for (let i = 0; i < data.metadata.rigidBodyCount; i++) {
500
- const rigidBody = data.rigidBodies[i];
501
- const params = {};
502
- for (const key in rigidBody) {
503
- params[key] = rigidBody[key];
504
- }
505
- if (data.metadata.format === "pmx") {
506
- if (params.boneIndex !== -1) {
507
- const bone = data.bones[params.boneIndex];
508
- params.position[0] -= bone.position[0];
509
- params.position[1] -= bone.position[1];
510
- params.position[2] -= bone.position[2];
511
- }
512
- }
513
- rigidBodies.push(params);
514
- }
515
- for (let i = 0; i < data.metadata.constraintCount; i++) {
516
- const constraint = data.constraints[i];
517
- const params = {};
518
- for (const key in constraint) {
519
- params[key] = constraint[key];
520
- }
521
- const bodyA = rigidBodies[params.rigidBodyIndex1];
522
- const bodyB = rigidBodies[params.rigidBodyIndex2];
523
- if (bodyA.type !== 0 && bodyB.type === 2) {
524
- if (bodyA.boneIndex !== -1 && bodyB.boneIndex !== -1 && data.bones[bodyB.boneIndex].parentIndex === bodyA.boneIndex) {
525
- bodyB.type = 1;
526
- }
527
- }
528
- constraints.push(params);
529
- }
530
- const geometry = new BufferGeometry();
531
- geometry.setAttribute("position", new Float32BufferAttribute(positions, 3));
532
- geometry.setAttribute("normal", new Float32BufferAttribute(normals, 3));
533
- geometry.setAttribute("uv", new Float32BufferAttribute(uvs, 2));
534
- geometry.setAttribute("skinIndex", new Uint16BufferAttribute(skinIndices, 4));
535
- geometry.setAttribute("skinWeight", new Float32BufferAttribute(skinWeights, 4));
536
- geometry.setIndex(indices);
537
- for (let i = 0, il = groups.length; i < il; i++) {
538
- geometry.addGroup(groups[i].offset, groups[i].count, i);
539
- }
540
- geometry.bones = bones;
541
- geometry.morphTargets = morphTargets;
542
- geometry.morphAttributes.position = morphPositions;
543
- geometry.morphTargetsRelative = false;
544
- geometry.userData.MMD = {
545
- bones,
546
- iks,
547
- grants,
548
- rigidBodies,
549
- constraints,
550
- format: data.metadata.format
551
- };
552
- geometry.computeBoundingSphere();
553
- return geometry;
554
- }
555
- }
556
- class MaterialBuilder {
557
- constructor(manager) {
558
- this.manager = manager;
559
- this.textureLoader = new TextureLoader(this.manager);
560
- this.tgaLoader = null;
561
- this.crossOrigin = "anonymous";
562
- this.resourcePath = void 0;
563
- }
564
- /**
565
- * @param {string} crossOrigin
566
- * @return {MaterialBuilder}
567
- */
568
- setCrossOrigin(crossOrigin) {
569
- this.crossOrigin = crossOrigin;
570
- return this;
571
- }
572
- /**
573
- * @param {string} resourcePath
574
- * @return {MaterialBuilder}
575
- */
576
- setResourcePath(resourcePath) {
577
- this.resourcePath = resourcePath;
578
- return this;
579
- }
580
- /**
581
- * @param {Object} data - parsed PMD/PMX data
582
- * @param {BufferGeometry} geometry - some properties are dependend on geometry
583
- * @param {function} onProgress
584
- * @param {function} onError
585
- * @return {Array<MeshToonMaterial>}
586
- */
587
- build(data, geometry) {
588
- const materials = [];
589
- const textures = {};
590
- this.textureLoader.setCrossOrigin(this.crossOrigin);
591
- for (let i = 0; i < data.metadata.materialCount; i++) {
592
- const material = data.materials[i];
593
- const params = { userData: {} };
594
- if (material.name !== void 0)
595
- params.name = material.name;
596
- params.color = new Color().fromArray(material.diffuse);
597
- params.opacity = material.diffuse[3];
598
- params.emissive = new Color().fromArray(material.ambient);
599
- params.transparent = params.opacity !== 1;
600
- params.skinning = geometry.bones.length > 0 ? true : false;
601
- params.morphTargets = geometry.morphTargets.length > 0 ? true : false;
602
- params.fog = true;
603
- params.blending = CustomBlending;
604
- params.blendSrc = SrcAlphaFactor;
605
- params.blendDst = OneMinusSrcAlphaFactor;
606
- params.blendSrcAlpha = SrcAlphaFactor;
607
- params.blendDstAlpha = DstAlphaFactor;
608
- if (data.metadata.format === "pmx" && (material.flag & 1) === 1) {
609
- params.side = DoubleSide;
610
- } else {
611
- params.side = params.opacity === 1 ? FrontSide : DoubleSide;
612
- }
613
- if (data.metadata.format === "pmd") {
614
- if (material.fileName) {
615
- const fileName = material.fileName;
616
- const fileNames = fileName.split("*");
617
- params.map = this._loadTexture(fileNames[0], textures);
618
- if (fileNames.length > 1) {
619
- const extension = fileNames[1].slice(-4).toLowerCase();
620
- params.envMap = this._loadTexture(fileNames[1], textures);
621
- params.combine = extension === ".sph" ? MultiplyOperation : AddOperation;
622
- }
623
- }
624
- const toonFileName = material.toonIndex === -1 ? "toon00.bmp" : data.toonTextures[material.toonIndex].fileName;
625
- params.gradientMap = this._loadTexture(toonFileName, textures, {
626
- isToonTexture: true,
627
- isDefaultToonTexture: this._isDefaultToonTexture(toonFileName)
628
- });
629
- params.userData.outlineParameters = {
630
- thickness: material.edgeFlag === 1 ? 3e-3 : 0,
631
- color: [0, 0, 0],
632
- alpha: 1,
633
- visible: material.edgeFlag === 1
634
- };
635
- } else {
636
- if (material.textureIndex !== -1) {
637
- params.map = this._loadTexture(data.textures[material.textureIndex], textures);
638
- }
639
- if (material.envTextureIndex !== -1 && (material.envFlag === 1 || material.envFlag == 2)) {
640
- params.envMap = this._loadTexture(data.textures[material.envTextureIndex], textures);
641
- params.combine = material.envFlag === 1 ? MultiplyOperation : AddOperation;
642
- }
643
- let toonFileName, isDefaultToon;
644
- if (material.toonIndex === -1 || material.toonFlag !== 0) {
645
- toonFileName = "toon" + ("0" + (material.toonIndex + 1)).slice(-2) + ".bmp";
646
- isDefaultToon = true;
647
- } else {
648
- toonFileName = data.textures[material.toonIndex];
649
- isDefaultToon = false;
650
- }
651
- params.gradientMap = this._loadTexture(toonFileName, textures, {
652
- isToonTexture: true,
653
- isDefaultToonTexture: isDefaultToon
654
- });
655
- params.userData.outlineParameters = {
656
- thickness: material.edgeSize / 300,
657
- // TODO: better calculation?
658
- color: material.edgeColor.slice(0, 3),
659
- alpha: material.edgeColor[3],
660
- visible: (material.flag & 16) !== 0 && material.edgeSize > 0
661
- };
662
- }
663
- if (params.map !== void 0) {
664
- if (!params.transparent) {
665
- this._checkImageTransparency(params.map, geometry, i);
666
- }
667
- params.emissive.multiplyScalar(0.2);
668
- }
669
- materials.push(new MeshToonMaterial(params));
670
- }
671
- if (data.metadata.format === "pmx") {
672
- let checkAlphaMorph = function(elements, materials2) {
673
- for (let i = 0, il = elements.length; i < il; i++) {
674
- const element = elements[i];
675
- if (element.index === -1)
676
- continue;
677
- const material = materials2[element.index];
678
- if (material.opacity !== element.diffuse[3]) {
679
- material.transparent = true;
680
- }
681
- }
682
- };
683
- for (let i = 0, il = data.morphs.length; i < il; i++) {
684
- const morph = data.morphs[i];
685
- const elements = morph.elements;
686
- if (morph.type === 0) {
687
- for (let j = 0, jl = elements.length; j < jl; j++) {
688
- const morph2 = data.morphs[elements[j].index];
689
- if (morph2.type !== 8)
690
- continue;
691
- checkAlphaMorph(morph2.elements, materials);
692
- }
693
- } else if (morph.type === 8) {
694
- checkAlphaMorph(elements, materials);
695
- }
696
- }
697
- }
698
- return materials;
699
- }
700
- // private methods
701
- _getTGALoader() {
702
- if (this.tgaLoader === null) {
703
- if (TGALoader === void 0) {
704
- throw new Error("THREE.MMDLoader: Import TGALoader");
705
- }
706
- this.tgaLoader = new TGALoader(this.manager);
707
- }
708
- return this.tgaLoader;
709
- }
710
- _isDefaultToonTexture(name) {
711
- if (name.length !== 10)
712
- return false;
713
- return /toon(10|0[0-9])\.bmp/.test(name);
714
- }
715
- _loadTexture(filePath, textures, params, onProgress, onError) {
716
- params = params || {};
717
- const scope = this;
718
- let fullPath;
719
- if (params.isDefaultToonTexture === true) {
720
- let index;
721
- try {
722
- index = parseInt(filePath.match(/toon([0-9]{2})\.bmp$/)[1]);
723
- } catch (e) {
724
- console.warn(
725
- "THREE.MMDLoader: " + filePath + " seems like a not right default texture path. Using toon00.bmp instead."
726
- );
727
- index = 0;
728
- }
729
- fullPath = DEFAULT_TOON_TEXTURES[index];
730
- } else {
731
- fullPath = this.resourcePath + filePath;
732
- }
733
- if (textures[fullPath] !== void 0)
734
- return textures[fullPath];
735
- let loader = this.manager.getHandler(fullPath);
736
- if (loader === null) {
737
- loader = filePath.slice(-4).toLowerCase() === ".tga" ? this._getTGALoader() : this.textureLoader;
738
- }
739
- const texture = loader.load(
740
- fullPath,
741
- function(t) {
742
- if (params.isToonTexture === true) {
743
- t.image = scope._getRotatedImage(t.image);
744
- t.magFilter = NearestFilter;
745
- t.minFilter = NearestFilter;
746
- }
747
- t.flipY = false;
748
- t.wrapS = RepeatWrapping;
749
- t.wrapT = RepeatWrapping;
750
- for (let i = 0; i < texture.readyCallbacks.length; i++) {
751
- texture.readyCallbacks[i](texture);
752
- }
753
- delete texture.readyCallbacks;
754
- },
755
- onProgress,
756
- onError
757
- );
758
- texture.readyCallbacks = [];
759
- textures[fullPath] = texture;
760
- return texture;
761
- }
762
- _getRotatedImage(image) {
763
- const canvas = document.createElement("canvas");
764
- const context = canvas.getContext("2d");
765
- const width = image.width;
766
- const height = image.height;
767
- canvas.width = width;
768
- canvas.height = height;
769
- context.clearRect(0, 0, width, height);
770
- context.translate(width / 2, height / 2);
771
- context.rotate(0.5 * Math.PI);
772
- context.translate(-width / 2, -height / 2);
773
- context.drawImage(image, 0, 0);
774
- return context.getImageData(0, 0, width, height);
775
- }
776
- // Check if the partial image area used by the texture is transparent.
777
- _checkImageTransparency(map, geometry, groupIndex) {
778
- map.readyCallbacks.push(function(texture) {
779
- function createImageData(image) {
780
- const canvas = document.createElement("canvas");
781
- canvas.width = image.width;
782
- canvas.height = image.height;
783
- const context = canvas.getContext("2d");
784
- context.drawImage(image, 0, 0);
785
- return context.getImageData(0, 0, canvas.width, canvas.height);
786
- }
787
- function detectImageTransparency(image, uvs, indices) {
788
- const width = image.width;
789
- const height = image.height;
790
- const data = image.data;
791
- const threshold = 253;
792
- if (data.length / (width * height) !== 4)
793
- return false;
794
- for (let i = 0; i < indices.length; i += 3) {
795
- const centerUV = { x: 0, y: 0 };
796
- for (let j = 0; j < 3; j++) {
797
- const index = indices[i * 3 + j];
798
- const uv = { x: uvs[index * 2 + 0], y: uvs[index * 2 + 1] };
799
- if (getAlphaByUv(image, uv) < threshold)
800
- return true;
801
- centerUV.x += uv.x;
802
- centerUV.y += uv.y;
803
- }
804
- centerUV.x /= 3;
805
- centerUV.y /= 3;
806
- if (getAlphaByUv(image, centerUV) < threshold)
807
- return true;
808
- }
809
- return false;
810
- }
811
- function getAlphaByUv(image, uv) {
812
- const width = image.width;
813
- const height = image.height;
814
- let x = Math.round(uv.x * width) % width;
815
- let y = Math.round(uv.y * height) % height;
816
- if (x < 0)
817
- x += width;
818
- if (y < 0)
819
- y += height;
820
- const index = y * width + x;
821
- return image.data[index * 4 + 3];
822
- }
823
- const imageData = texture.image.data !== void 0 ? texture.image : createImageData(texture.image);
824
- const group = geometry.groups[groupIndex];
825
- if (detectImageTransparency(
826
- imageData,
827
- geometry.attributes.uv.array,
828
- geometry.index.array.slice(group.start, group.start + group.count)
829
- )) {
830
- map.transparent = true;
831
- }
832
- });
833
- }
834
- }
835
- class AnimationBuilder {
836
- /**
837
- * @param {Object} vmd - parsed VMD data
838
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
839
- * @return {AnimationClip}
840
- */
841
- build(vmd, mesh) {
842
- const tracks = this.buildSkeletalAnimation(vmd, mesh).tracks;
843
- const tracks2 = this.buildMorphAnimation(vmd, mesh).tracks;
844
- for (let i = 0, il = tracks2.length; i < il; i++) {
845
- tracks.push(tracks2[i]);
846
- }
847
- return new AnimationClip("", -1, tracks);
848
- }
849
- /**
850
- * @param {Object} vmd - parsed VMD data
851
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
852
- * @return {AnimationClip}
853
- */
854
- buildSkeletalAnimation(vmd, mesh) {
855
- function pushInterpolation(array, interpolation, index) {
856
- array.push(interpolation[index + 0] / 127);
857
- array.push(interpolation[index + 8] / 127);
858
- array.push(interpolation[index + 4] / 127);
859
- array.push(interpolation[index + 12] / 127);
860
- }
861
- const tracks = [];
862
- const motions = {};
863
- const bones = mesh.skeleton.bones;
864
- const boneNameDictionary = {};
865
- for (let i = 0, il = bones.length; i < il; i++) {
866
- boneNameDictionary[bones[i].name] = true;
867
- }
868
- for (let i = 0; i < vmd.metadata.motionCount; i++) {
869
- const motion = vmd.motions[i];
870
- const boneName = motion.boneName;
871
- if (boneNameDictionary[boneName] === void 0)
872
- continue;
873
- motions[boneName] = motions[boneName] || [];
874
- motions[boneName].push(motion);
875
- }
876
- for (const key in motions) {
877
- const array = motions[key];
878
- array.sort(function(a, b) {
879
- return a.frameNum - b.frameNum;
880
- });
881
- const times = [];
882
- const positions = [];
883
- const rotations = [];
884
- const pInterpolations = [];
885
- const rInterpolations = [];
886
- const basePosition = mesh.skeleton.getBoneByName(key).position.toArray();
887
- for (let i = 0, il = array.length; i < il; i++) {
888
- const time = array[i].frameNum / 30;
889
- const position = array[i].position;
890
- const rotation = array[i].rotation;
891
- const interpolation = array[i].interpolation;
892
- times.push(time);
893
- for (let j = 0; j < 3; j++)
894
- positions.push(basePosition[j] + position[j]);
895
- for (let j = 0; j < 4; j++)
896
- rotations.push(rotation[j]);
897
- for (let j = 0; j < 3; j++)
898
- pushInterpolation(pInterpolations, interpolation, j);
899
- pushInterpolation(rInterpolations, interpolation, 3);
900
- }
901
- const targetName = ".bones[" + key + "]";
902
- tracks.push(this._createTrack(targetName + ".position", VectorKeyframeTrack, times, positions, pInterpolations));
903
- tracks.push(
904
- this._createTrack(targetName + ".quaternion", QuaternionKeyframeTrack, times, rotations, rInterpolations)
905
- );
906
- }
907
- return new AnimationClip("", -1, tracks);
908
- }
909
- /**
910
- * @param {Object} vmd - parsed VMD data
911
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
912
- * @return {AnimationClip}
913
- */
914
- buildMorphAnimation(vmd, mesh) {
915
- const tracks = [];
916
- const morphs = {};
917
- const morphTargetDictionary = mesh.morphTargetDictionary;
918
- for (let i = 0; i < vmd.metadata.morphCount; i++) {
919
- const morph = vmd.morphs[i];
920
- const morphName = morph.morphName;
921
- if (morphTargetDictionary[morphName] === void 0)
922
- continue;
923
- morphs[morphName] = morphs[morphName] || [];
924
- morphs[morphName].push(morph);
925
- }
926
- for (const key in morphs) {
927
- const array = morphs[key];
928
- array.sort(function(a, b) {
929
- return a.frameNum - b.frameNum;
930
- });
931
- const times = [];
932
- const values = [];
933
- for (let i = 0, il = array.length; i < il; i++) {
934
- times.push(array[i].frameNum / 30);
935
- values.push(array[i].weight);
936
- }
937
- tracks.push(new NumberKeyframeTrack(".morphTargetInfluences[" + morphTargetDictionary[key] + "]", times, values));
938
- }
939
- return new AnimationClip("", -1, tracks);
940
- }
941
- /**
942
- * @param {Object} vmd - parsed VMD data
943
- * @return {AnimationClip}
944
- */
945
- buildCameraAnimation(vmd) {
946
- function pushVector3(array, vec) {
947
- array.push(vec.x);
948
- array.push(vec.y);
949
- array.push(vec.z);
950
- }
951
- function pushQuaternion(array, q) {
952
- array.push(q.x);
953
- array.push(q.y);
954
- array.push(q.z);
955
- array.push(q.w);
956
- }
957
- function pushInterpolation(array, interpolation, index) {
958
- array.push(interpolation[index * 4 + 0] / 127);
959
- array.push(interpolation[index * 4 + 1] / 127);
960
- array.push(interpolation[index * 4 + 2] / 127);
961
- array.push(interpolation[index * 4 + 3] / 127);
962
- }
963
- const cameras = vmd.cameras === void 0 ? [] : vmd.cameras.slice();
964
- cameras.sort(function(a, b) {
965
- return a.frameNum - b.frameNum;
966
- });
967
- const times = [];
968
- const centers = [];
969
- const quaternions = [];
970
- const positions = [];
971
- const fovs = [];
972
- const cInterpolations = [];
973
- const qInterpolations = [];
974
- const pInterpolations = [];
975
- const fInterpolations = [];
976
- const quaternion = new Quaternion();
977
- const euler = new Euler();
978
- const position = new Vector3();
979
- const center = new Vector3();
980
- for (let i = 0, il = cameras.length; i < il; i++) {
981
- const motion = cameras[i];
982
- const time = motion.frameNum / 30;
983
- const pos = motion.position;
984
- const rot = motion.rotation;
985
- const distance = motion.distance;
986
- const fov = motion.fov;
987
- const interpolation = motion.interpolation;
988
- times.push(time);
989
- position.set(0, 0, -distance);
990
- center.set(pos[0], pos[1], pos[2]);
991
- euler.set(-rot[0], -rot[1], -rot[2]);
992
- quaternion.setFromEuler(euler);
993
- position.add(center);
994
- position.applyQuaternion(quaternion);
995
- pushVector3(centers, center);
996
- pushQuaternion(quaternions, quaternion);
997
- pushVector3(positions, position);
998
- fovs.push(fov);
999
- for (let j = 0; j < 3; j++) {
1000
- pushInterpolation(cInterpolations, interpolation, j);
1001
- }
1002
- pushInterpolation(qInterpolations, interpolation, 3);
1003
- for (let j = 0; j < 3; j++) {
1004
- pushInterpolation(pInterpolations, interpolation, 4);
1005
- }
1006
- pushInterpolation(fInterpolations, interpolation, 5);
1007
- }
1008
- const tracks = [];
1009
- tracks.push(this._createTrack("target.position", VectorKeyframeTrack, times, centers, cInterpolations));
1010
- tracks.push(this._createTrack(".quaternion", QuaternionKeyframeTrack, times, quaternions, qInterpolations));
1011
- tracks.push(this._createTrack(".position", VectorKeyframeTrack, times, positions, pInterpolations));
1012
- tracks.push(this._createTrack(".fov", NumberKeyframeTrack, times, fovs, fInterpolations));
1013
- return new AnimationClip("", -1, tracks);
1014
- }
1015
- // private method
1016
- _createTrack(node, typedKeyframeTrack, times, values, interpolations) {
1017
- if (times.length > 2) {
1018
- times = times.slice();
1019
- values = values.slice();
1020
- interpolations = interpolations.slice();
1021
- const stride = values.length / times.length;
1022
- const interpolateStride = interpolations.length / times.length;
1023
- let index = 1;
1024
- for (let aheadIndex = 2, endIndex = times.length; aheadIndex < endIndex; aheadIndex++) {
1025
- for (let i = 0; i < stride; i++) {
1026
- if (values[index * stride + i] !== values[(index - 1) * stride + i] || values[index * stride + i] !== values[aheadIndex * stride + i]) {
1027
- index++;
1028
- break;
1029
- }
1030
- }
1031
- if (aheadIndex > index) {
1032
- times[index] = times[aheadIndex];
1033
- for (let i = 0; i < stride; i++) {
1034
- values[index * stride + i] = values[aheadIndex * stride + i];
1035
- }
1036
- for (let i = 0; i < interpolateStride; i++) {
1037
- interpolations[index * interpolateStride + i] = interpolations[aheadIndex * interpolateStride + i];
1038
- }
1039
- }
1040
- }
1041
- times.length = index + 1;
1042
- values.length = (index + 1) * stride;
1043
- interpolations.length = (index + 1) * interpolateStride;
1044
- }
1045
- const track = new typedKeyframeTrack(node, times, values);
1046
- track.createInterpolant = function InterpolantFactoryMethodCubicBezier(result) {
1047
- return new CubicBezierInterpolation(
1048
- this.times,
1049
- this.values,
1050
- this.getValueSize(),
1051
- result,
1052
- new Float32Array(interpolations)
1053
- );
1054
- };
1055
- return track;
1056
- }
1057
- }
1058
- class CubicBezierInterpolation extends Interpolant {
1059
- constructor(parameterPositions, sampleValues, sampleSize, resultBuffer, params) {
1060
- super(parameterPositions, sampleValues, sampleSize, resultBuffer);
1061
- this.interpolationParams = params;
1062
- }
1063
- interpolate_(i1, t0, t, t1) {
1064
- const result = this.resultBuffer;
1065
- const values = this.sampleValues;
1066
- const stride = this.valueSize;
1067
- const params = this.interpolationParams;
1068
- const offset1 = i1 * stride;
1069
- const offset0 = offset1 - stride;
1070
- const weight1 = t1 - t0 < 1 / 30 * 1.5 ? 0 : (t - t0) / (t1 - t0);
1071
- if (stride === 4) {
1072
- const x1 = params[i1 * 4 + 0];
1073
- const x2 = params[i1 * 4 + 1];
1074
- const y1 = params[i1 * 4 + 2];
1075
- const y2 = params[i1 * 4 + 3];
1076
- const ratio = this._calculate(x1, x2, y1, y2, weight1);
1077
- Quaternion.slerpFlat(result, 0, values, offset0, values, offset1, ratio);
1078
- } else if (stride === 3) {
1079
- for (let i = 0; i !== stride; ++i) {
1080
- const x1 = params[i1 * 12 + i * 4 + 0];
1081
- const x2 = params[i1 * 12 + i * 4 + 1];
1082
- const y1 = params[i1 * 12 + i * 4 + 2];
1083
- const y2 = params[i1 * 12 + i * 4 + 3];
1084
- const ratio = this._calculate(x1, x2, y1, y2, weight1);
1085
- result[i] = values[offset0 + i] * (1 - ratio) + values[offset1 + i] * ratio;
1086
- }
1087
- } else {
1088
- const x1 = params[i1 * 4 + 0];
1089
- const x2 = params[i1 * 4 + 1];
1090
- const y1 = params[i1 * 4 + 2];
1091
- const y2 = params[i1 * 4 + 3];
1092
- const ratio = this._calculate(x1, x2, y1, y2, weight1);
1093
- result[0] = values[offset0] * (1 - ratio) + values[offset1] * ratio;
1094
- }
1095
- return result;
1096
- }
1097
- _calculate(x1, x2, y1, y2, x) {
1098
- let c = 0.5;
1099
- let t = c;
1100
- let s = 1 - t;
1101
- const loop = 15;
1102
- const eps = 1e-5;
1103
- const math = Math;
1104
- let sst3, stt3, ttt;
1105
- for (let i = 0; i < loop; i++) {
1106
- sst3 = 3 * s * s * t;
1107
- stt3 = 3 * s * t * t;
1108
- ttt = t * t * t;
1109
- const ft = sst3 * x1 + stt3 * x2 + ttt - x;
1110
- if (math.abs(ft) < eps)
1111
- break;
1112
- c /= 2;
1113
- t += ft < 0 ? c : -c;
1114
- s = 1 - t;
1115
- }
1116
- return sst3 * y1 + stt3 * y2 + ttt;
1117
- }
1118
- }
1119
- export {
1120
- MMDLoader
1121
- };