super-three 0.147.0 → 0.152.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (757) hide show
  1. package/LICENSE +1 -1
  2. package/build/three.cjs +36408 -21117
  3. package/build/three.js +37007 -21715
  4. package/build/three.min.js +3 -2
  5. package/build/three.module.js +6387 -5510
  6. package/build/three.module.min.js +6 -0
  7. package/examples/jsm/animation/AnimationClipCreator.js +5 -3
  8. package/examples/jsm/capabilities/WebGPU.js +2 -4
  9. package/examples/jsm/controls/ArcballControls.js +1828 -1821
  10. package/examples/jsm/controls/MapControls.js +28 -0
  11. package/examples/jsm/controls/OrbitControls.js +20 -45
  12. package/examples/jsm/controls/PointerLockControls.js +70 -65
  13. package/examples/jsm/controls/TrackballControls.js +18 -4
  14. package/examples/jsm/controls/TransformControls.js +0 -1
  15. package/examples/jsm/csm/CSM.js +11 -3
  16. package/examples/jsm/csm/CSMShader.js +7 -6
  17. package/examples/jsm/effects/AsciiEffect.js +3 -6
  18. package/examples/jsm/effects/OutlineEffect.js +1 -15
  19. package/examples/jsm/exporters/ColladaExporter.js +26 -14
  20. package/examples/jsm/exporters/DRACOExporter.js +53 -11
  21. package/examples/jsm/exporters/EXRExporter.js +3 -9
  22. package/examples/jsm/exporters/GLTFExporter.js +524 -111
  23. package/examples/jsm/exporters/KTX2Exporter.js +34 -23
  24. package/examples/jsm/exporters/MMDExporter.js +1 -1
  25. package/examples/jsm/exporters/PLYExporter.js +8 -1
  26. package/examples/jsm/exporters/STLExporter.js +8 -4
  27. package/examples/jsm/exporters/USDZExporter.js +22 -3
  28. package/examples/jsm/geometries/ConvexGeometry.js +0 -6
  29. package/examples/jsm/geometries/ParametricGeometry.js +10 -0
  30. package/examples/jsm/helpers/OctreeHelper.js +1 -0
  31. package/examples/jsm/helpers/ViewHelper.js +70 -56
  32. package/examples/jsm/interactive/HTMLMesh.js +16 -3
  33. package/examples/jsm/interactive/InteractiveGroup.js +1 -1
  34. package/examples/{js → jsm}/libs/basis/README.md +4 -4
  35. package/examples/jsm/libs/draco/draco_decoder.js +34 -0
  36. package/examples/jsm/libs/draco/draco_decoder.wasm +0 -0
  37. package/examples/jsm/libs/draco/draco_wasm_wrapper.js +117 -0
  38. package/examples/jsm/libs/draco/gltf/draco_decoder.js +33 -0
  39. package/examples/jsm/libs/draco/gltf/draco_decoder.wasm +0 -0
  40. package/examples/jsm/libs/draco/gltf/draco_wasm_wrapper.js +116 -0
  41. package/examples/jsm/libs/lil-gui.module.min.js +2 -2
  42. package/examples/jsm/libs/tween.module.js +803 -0
  43. package/examples/jsm/lights/IESSpotLight.js +25 -0
  44. package/examples/jsm/lights/LightProbeGenerator.js +11 -9
  45. package/examples/jsm/lines/LineSegments2.js +12 -10
  46. package/examples/jsm/loaders/3DMLoader.js +8 -5
  47. package/examples/jsm/loaders/3MFLoader.js +12 -11
  48. package/examples/jsm/loaders/AMFLoader.js +2 -3
  49. package/examples/jsm/loaders/BVHLoader.js +2 -2
  50. package/examples/jsm/loaders/ColladaLoader.js +15 -16
  51. package/examples/jsm/loaders/DRACOLoader.js +67 -18
  52. package/examples/jsm/loaders/EXRLoader.js +23 -24
  53. package/examples/jsm/loaders/FBXLoader.js +32 -50
  54. package/examples/jsm/loaders/GCodeLoader.js +1 -2
  55. package/examples/jsm/loaders/GLTFLoader.js +249 -215
  56. package/examples/jsm/loaders/HDRCubeTextureLoader.js +4 -4
  57. package/examples/jsm/loaders/IESLoader.js +337 -0
  58. package/examples/jsm/loaders/KMZLoader.js +4 -4
  59. package/examples/jsm/loaders/KTX2Loader.js +41 -24
  60. package/examples/jsm/loaders/LDrawLoader.js +20 -18
  61. package/examples/jsm/loaders/LWOLoader.js +12 -29
  62. package/examples/jsm/loaders/LottieLoader.js +3 -1
  63. package/examples/jsm/loaders/MMDLoader.js +17 -13
  64. package/examples/jsm/loaders/MTLLoader.js +2 -2
  65. package/examples/jsm/loaders/MaterialXLoader.js +9 -3
  66. package/examples/jsm/loaders/NRRDLoader.js +33 -5
  67. package/examples/jsm/loaders/OBJLoader.js +1 -1
  68. package/examples/jsm/loaders/PCDLoader.js +1 -2
  69. package/examples/jsm/loaders/PLYLoader.js +238 -105
  70. package/examples/jsm/loaders/RGBELoader.js +3 -3
  71. package/examples/jsm/loaders/STLLoader.js +1 -2
  72. package/examples/jsm/loaders/SVGLoader.js +36 -27
  73. package/examples/jsm/loaders/TTFLoader.js +1 -8
  74. package/examples/jsm/loaders/TiltLoader.js +13 -7
  75. package/examples/jsm/loaders/USDZLoader.js +5 -5
  76. package/examples/jsm/loaders/VOXLoader.js +8 -2
  77. package/examples/jsm/loaders/VRMLLoader.js +5 -13
  78. package/examples/jsm/loaders/VTKLoader.js +7 -6
  79. package/examples/jsm/loaders/lwo/IFFParser.js +19 -19
  80. package/examples/jsm/materials/MeshGouraudMaterial.js +0 -3
  81. package/examples/jsm/math/MeshSurfaceSampler.js +0 -6
  82. package/examples/jsm/misc/ConvexObjectBreaker.js +2 -8
  83. package/examples/jsm/misc/GPUComputationRenderer.js +5 -5
  84. package/examples/jsm/misc/MD2Character.js +2 -2
  85. package/examples/jsm/misc/MD2CharacterComplex.js +2 -2
  86. package/examples/jsm/misc/ProgressiveLightMap.js +12 -10
  87. package/examples/jsm/misc/RollerCoaster.js +7 -1
  88. package/examples/jsm/misc/Volume.js +20 -5
  89. package/examples/jsm/modifiers/CurveModifier.js +1 -0
  90. package/examples/jsm/modifiers/TessellateModifier.js +19 -19
  91. package/examples/jsm/nodes/Nodes.js +143 -335
  92. package/examples/jsm/nodes/accessors/BitangentNode.js +43 -16
  93. package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
  94. package/examples/jsm/nodes/accessors/CameraNode.js +12 -2
  95. package/examples/jsm/nodes/accessors/CubeTextureNode.js +27 -33
  96. package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +58 -0
  97. package/examples/jsm/nodes/accessors/InstanceNode.js +17 -21
  98. package/examples/jsm/nodes/accessors/MaterialNode.js +155 -38
  99. package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +16 -0
  100. package/examples/jsm/nodes/accessors/ModelNode.js +11 -0
  101. package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -8
  102. package/examples/jsm/nodes/accessors/NormalNode.js +35 -19
  103. package/examples/jsm/nodes/accessors/Object3DNode.js +32 -12
  104. package/examples/jsm/nodes/accessors/PointUVNode.js +6 -1
  105. package/examples/jsm/nodes/accessors/PositionNode.js +38 -23
  106. package/examples/jsm/nodes/accessors/ReferenceNode.js +21 -14
  107. package/examples/jsm/nodes/accessors/ReflectVectorNode.js +11 -7
  108. package/examples/jsm/nodes/accessors/SkinningNode.js +43 -40
  109. package/examples/jsm/nodes/accessors/StorageBufferNode.js +6 -0
  110. package/examples/jsm/nodes/accessors/TangentNode.js +28 -20
  111. package/examples/jsm/nodes/accessors/TextureNode.js +80 -12
  112. package/examples/jsm/nodes/accessors/UVNode.js +6 -0
  113. package/examples/jsm/nodes/accessors/UserDataNode.js +6 -0
  114. package/examples/jsm/nodes/{core → code}/CodeNode.js +27 -2
  115. package/examples/jsm/nodes/code/ExpressionNode.js +37 -0
  116. package/examples/jsm/nodes/{core → code}/FunctionCallNode.js +15 -1
  117. package/examples/jsm/nodes/{core → code}/FunctionNode.js +8 -7
  118. package/examples/jsm/nodes/code/ScriptableNode.js +488 -0
  119. package/examples/jsm/nodes/code/ScriptableValueNode.js +167 -0
  120. package/examples/jsm/nodes/core/ArrayUniformNode.js +3 -0
  121. package/examples/jsm/nodes/core/AttributeNode.js +16 -8
  122. package/examples/jsm/nodes/core/BypassNode.js +9 -2
  123. package/examples/jsm/nodes/core/CacheNode.js +46 -0
  124. package/examples/jsm/nodes/core/ConstNode.js +3 -0
  125. package/examples/jsm/nodes/core/ContextNode.js +8 -1
  126. package/examples/jsm/nodes/core/InputNode.js +26 -5
  127. package/examples/jsm/nodes/core/InstanceIndexNode.js +6 -1
  128. package/examples/jsm/nodes/core/LightingModel.js +16 -0
  129. package/examples/jsm/nodes/core/Node.js +128 -34
  130. package/examples/jsm/nodes/core/NodeBuilder.js +209 -118
  131. package/examples/jsm/nodes/core/NodeCache.js +26 -0
  132. package/examples/jsm/nodes/core/NodeFrame.js +56 -5
  133. package/examples/jsm/nodes/core/NodeUtils.js +105 -28
  134. package/examples/jsm/nodes/core/PropertyNode.js +19 -2
  135. package/examples/jsm/nodes/core/StackNode.js +92 -0
  136. package/examples/jsm/nodes/core/TempNode.js +11 -3
  137. package/examples/jsm/nodes/core/UniformNode.js +15 -0
  138. package/examples/jsm/nodes/core/VarNode.js +21 -29
  139. package/examples/jsm/nodes/core/VaryingNode.js +15 -2
  140. package/examples/jsm/nodes/core/constants.js +6 -0
  141. package/examples/jsm/nodes/display/BlendModeNode.js +25 -11
  142. package/examples/jsm/nodes/display/ColorAdjustmentNode.js +30 -14
  143. package/examples/jsm/nodes/display/ColorSpaceNode.js +39 -27
  144. package/examples/jsm/nodes/display/FrontFacingNode.js +7 -1
  145. package/examples/jsm/nodes/display/NormalMapNode.js +31 -18
  146. package/examples/jsm/nodes/display/PosterizeNode.js +10 -3
  147. package/examples/jsm/nodes/display/ToneMappingNode.js +92 -11
  148. package/examples/jsm/nodes/display/ViewportNode.js +27 -18
  149. package/examples/jsm/nodes/display/ViewportSharedTextureNode.js +30 -0
  150. package/examples/jsm/nodes/display/ViewportTextureNode.js +61 -0
  151. package/examples/jsm/nodes/fog/FogExp2Node.js +35 -0
  152. package/examples/jsm/nodes/fog/FogNode.js +12 -6
  153. package/examples/jsm/nodes/fog/FogRangeNode.js +12 -5
  154. package/examples/jsm/nodes/functions/BSDF/BRDF_BlinnPhong.js +30 -0
  155. package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +10 -13
  156. package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
  157. package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -6
  158. package/examples/jsm/nodes/functions/BSDF/D_GGX.js +4 -4
  159. package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +3 -3
  160. package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +7 -5
  161. package/examples/jsm/nodes/functions/PhongLightingModel.js +28 -0
  162. package/examples/jsm/nodes/functions/PhysicalLightingModel.js +33 -36
  163. package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +4 -3
  164. package/examples/jsm/nodes/functions/material/getRoughness.js +4 -4
  165. package/examples/jsm/nodes/geometry/RangeNode.js +32 -19
  166. package/examples/jsm/nodes/gpgpu/ComputeNode.js +9 -2
  167. package/examples/jsm/nodes/lighting/AONode.js +5 -3
  168. package/examples/jsm/nodes/lighting/AmbientLightNode.js +27 -0
  169. package/examples/jsm/nodes/lighting/AnalyticLightNode.js +112 -6
  170. package/examples/jsm/nodes/lighting/DirectionalLightNode.js +43 -0
  171. package/examples/jsm/nodes/lighting/EnvironmentNode.js +104 -34
  172. package/examples/jsm/nodes/lighting/HemisphereLightNode.js +15 -10
  173. package/examples/jsm/nodes/lighting/IESSpotLightNode.js +39 -0
  174. package/examples/jsm/nodes/lighting/LightNode.js +57 -0
  175. package/examples/jsm/nodes/lighting/LightUtils.js +17 -0
  176. package/examples/jsm/nodes/lighting/LightingContextNode.js +30 -8
  177. package/examples/jsm/nodes/lighting/LightingNode.js +3 -1
  178. package/examples/jsm/nodes/lighting/LightsNode.js +18 -10
  179. package/examples/jsm/nodes/lighting/PointLightNode.js +71 -0
  180. package/examples/jsm/nodes/lighting/SpotLightNode.js +92 -0
  181. package/examples/jsm/nodes/loaders/NodeLoader.js +5 -4
  182. package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +4 -20
  183. package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +6 -9
  184. package/examples/jsm/nodes/materials/Materials.js +11 -55
  185. package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +5 -11
  186. package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +48 -0
  187. package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +74 -0
  188. package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +6 -6
  189. package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +21 -96
  190. package/examples/jsm/nodes/materials/NodeMaterial.js +244 -61
  191. package/examples/jsm/nodes/materials/PointsNodeMaterial.js +7 -1
  192. package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +29 -25
  193. package/examples/jsm/nodes/materialx/MaterialXNodes.js +31 -22
  194. package/examples/jsm/nodes/materialx/lib/mx_hsv.js +1 -1
  195. package/examples/jsm/nodes/materialx/lib/mx_noise.js +2 -1
  196. package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +2 -1
  197. package/examples/jsm/nodes/math/CondNode.js +43 -17
  198. package/examples/jsm/nodes/math/MathNode.js +178 -73
  199. package/examples/jsm/nodes/math/OperatorNode.js +52 -2
  200. package/examples/jsm/nodes/procedural/CheckerNode.js +14 -6
  201. package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -42
  202. package/examples/jsm/nodes/utils/ArrayElementNode.js +4 -2
  203. package/examples/jsm/nodes/utils/ConvertNode.js +19 -1
  204. package/examples/jsm/nodes/utils/DiscardNode.js +26 -0
  205. package/examples/jsm/nodes/utils/EquirectUVNode.js +11 -4
  206. package/examples/jsm/nodes/utils/JoinNode.js +4 -1
  207. package/examples/jsm/nodes/utils/MatcapUVNode.js +11 -4
  208. package/examples/jsm/nodes/utils/MaxMipLevelNode.js +18 -5
  209. package/examples/jsm/nodes/utils/OscNode.js +21 -14
  210. package/examples/jsm/nodes/utils/PackingNode.js +55 -0
  211. package/examples/jsm/nodes/utils/RemapNode.js +13 -5
  212. package/examples/jsm/nodes/utils/RotateUVNode.js +18 -7
  213. package/examples/jsm/nodes/utils/SpecularMIPLevelNode.js +37 -0
  214. package/examples/jsm/nodes/utils/SplitNode.js +7 -5
  215. package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +15 -30
  216. package/examples/jsm/nodes/utils/TimerNode.js +16 -6
  217. package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +21 -10
  218. package/examples/jsm/objects/GroundProjectedSkybox.js +172 -0
  219. package/examples/jsm/objects/Reflector.js +4 -4
  220. package/examples/jsm/objects/Refractor.js +4 -4
  221. package/examples/jsm/objects/ShadowMesh.js +3 -3
  222. package/examples/jsm/physics/AmmoPhysics.js +27 -28
  223. package/examples/jsm/physics/{OimoPhysics.js → RapierPhysics.js} +59 -51
  224. package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +0 -8
  225. package/examples/jsm/postprocessing/AfterimagePass.js +0 -2
  226. package/examples/jsm/postprocessing/BloomPass.js +0 -2
  227. package/examples/jsm/postprocessing/BokehPass.js +0 -6
  228. package/examples/jsm/postprocessing/DotScreenPass.js +0 -2
  229. package/examples/jsm/postprocessing/EffectComposer.js +3 -94
  230. package/examples/jsm/postprocessing/FilmPass.js +0 -2
  231. package/examples/jsm/postprocessing/GlitchPass.js +0 -2
  232. package/examples/jsm/postprocessing/HalftonePass.js +0 -6
  233. package/examples/jsm/postprocessing/OutlinePass.js +0 -1
  234. package/examples/jsm/postprocessing/Pass.js +2 -0
  235. package/examples/jsm/postprocessing/SAOPass.js +0 -24
  236. package/examples/jsm/postprocessing/SMAAPass.js +0 -6
  237. package/examples/jsm/postprocessing/SSAARenderPass.js +13 -5
  238. package/examples/jsm/postprocessing/SSAOPass.js +0 -12
  239. package/examples/jsm/postprocessing/SSRPass.js +0 -6
  240. package/examples/jsm/postprocessing/SavePass.js +0 -2
  241. package/examples/jsm/postprocessing/TexturePass.js +0 -2
  242. package/examples/jsm/postprocessing/UnrealBloomPass.js +0 -8
  243. package/examples/jsm/renderers/CSS2DRenderer.js +6 -1
  244. package/examples/jsm/renderers/CSS3DRenderer.js +27 -5
  245. package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +35 -31
  246. package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +2 -2
  247. package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +14 -4
  248. package/examples/jsm/renderers/webgpu/WebGPUBackground.js +72 -55
  249. package/examples/jsm/renderers/webgpu/WebGPUBindings.js +34 -19
  250. package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +1 -1
  251. package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +158 -26
  252. package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +1 -1
  253. package/examples/jsm/renderers/webgpu/WebGPUProperties.js +6 -0
  254. package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +30 -14
  255. package/examples/jsm/renderers/webgpu/WebGPURenderObject.js +40 -0
  256. package/examples/jsm/renderers/webgpu/WebGPURenderObjects.js +50 -0
  257. package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +49 -111
  258. package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +40 -62
  259. package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +14 -26
  260. package/examples/jsm/renderers/webgpu/WebGPURenderTarget.js +15 -0
  261. package/examples/jsm/renderers/webgpu/WebGPURenderer.js +244 -100
  262. package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +3 -1
  263. package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +2 -4
  264. package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +2 -0
  265. package/examples/jsm/renderers/webgpu/WebGPUTextures.js +366 -110
  266. package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +1 -1
  267. package/examples/jsm/renderers/webgpu/WebGPUUtils.js +13 -6
  268. package/examples/jsm/renderers/webgpu/WebGPUWeakMap.js +83 -0
  269. package/examples/jsm/renderers/webgpu/constants.js +68 -6
  270. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +74 -57
  271. package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +241 -22
  272. package/examples/jsm/shaders/MMDToonShader.js +15 -4
  273. package/examples/jsm/shaders/RGBShiftShader.js +2 -2
  274. package/examples/jsm/shaders/VelocityShader.js +1 -1
  275. package/examples/jsm/utils/BufferGeometryUtils.js +37 -35
  276. package/examples/jsm/utils/LDrawUtils.js +4 -4
  277. package/examples/jsm/utils/PackedPhongMaterial.js +5 -78
  278. package/examples/jsm/utils/SceneUtils.js +8 -4
  279. package/examples/jsm/utils/SkeletonUtils.js +27 -210
  280. package/examples/jsm/webxr/VRButton.js +1 -2
  281. package/examples/jsm/webxr/XRButton.js +198 -0
  282. package/package.json +33 -87
  283. package/src/Three.Legacy.js +19 -110
  284. package/src/Three.js +4 -3
  285. package/src/animation/AnimationUtils.js +13 -1
  286. package/src/animation/PropertyBinding.js +2 -2
  287. package/src/audio/Audio.js +7 -2
  288. package/src/constants.js +10 -2
  289. package/src/core/BufferAttribute.js +147 -8
  290. package/src/core/BufferGeometry.js +3 -9
  291. package/src/core/GLBufferAttribute.js +2 -0
  292. package/src/core/InterleavedBufferAttribute.js +1 -1
  293. package/src/core/Object3D.js +36 -7
  294. package/src/extras/DataUtils.js +7 -1
  295. package/src/extras/ImageUtils.js +2 -2
  296. package/src/extras/PMREMGenerator.js +5 -5
  297. package/src/extras/curves/LineCurve.js +6 -4
  298. package/src/extras/curves/LineCurve3.js +13 -0
  299. package/src/geometries/BoxGeometry.js +10 -0
  300. package/src/geometries/CircleGeometry.js +11 -1
  301. package/src/geometries/ConeGeometry.js +1 -1
  302. package/src/geometries/CylinderGeometry.js +11 -1
  303. package/src/geometries/EdgesGeometry.js +10 -0
  304. package/src/geometries/ExtrudeGeometry.js +11 -1
  305. package/src/geometries/LatheGeometry.js +10 -0
  306. package/src/geometries/PlaneGeometry.js +10 -0
  307. package/src/geometries/PolyhedronGeometry.js +10 -0
  308. package/src/geometries/RingGeometry.js +11 -1
  309. package/src/geometries/ShapeGeometry.js +10 -0
  310. package/src/geometries/SphereGeometry.js +12 -2
  311. package/src/geometries/TorusGeometry.js +11 -1
  312. package/src/geometries/TorusKnotGeometry.js +10 -0
  313. package/src/geometries/TubeGeometry.js +10 -0
  314. package/src/geometries/WireframeGeometry.js +10 -0
  315. package/src/helpers/Box3Helper.js +1 -2
  316. package/src/lights/DirectionalLight.js +1 -1
  317. package/src/lights/HemisphereLight.js +1 -1
  318. package/src/lights/SpotLight.js +1 -1
  319. package/src/loaders/AudioLoader.js +14 -8
  320. package/src/loaders/DataTextureLoader.js +5 -1
  321. package/src/loaders/MaterialLoader.js +4 -0
  322. package/src/loaders/ObjectLoader.js +9 -2
  323. package/src/materials/LineBasicMaterial.js +4 -0
  324. package/src/materials/Material.js +6 -3
  325. package/src/materials/MeshDistanceMaterial.js +0 -9
  326. package/src/materials/ShaderMaterial.js +6 -1
  327. package/src/math/Box2.js +3 -2
  328. package/src/math/Box3.js +49 -64
  329. package/src/math/Color.js +72 -55
  330. package/src/math/ColorManagement.js +75 -16
  331. package/src/math/Euler.js +2 -11
  332. package/src/math/Frustum.js +13 -3
  333. package/src/math/MathUtils.js +27 -1
  334. package/src/math/Plane.js +2 -2
  335. package/src/math/Quaternion.js +6 -0
  336. package/src/math/Ray.js +7 -7
  337. package/src/math/Triangle.js +37 -7
  338. package/src/math/Vector2.js +16 -0
  339. package/src/math/Vector3.js +10 -0
  340. package/src/math/interpolants/CubicInterpolant.js +1 -2
  341. package/src/objects/InstancedMesh.js +79 -1
  342. package/src/objects/Mesh.js +101 -73
  343. package/src/objects/SkinnedMesh.js +95 -8
  344. package/src/objects/Sprite.js +1 -1
  345. package/src/renderers/WebGLCubeRenderTarget.js +12 -3
  346. package/src/renderers/WebGLMultipleRenderTargets.js +4 -2
  347. package/src/renderers/WebGLRenderTarget.js +14 -2
  348. package/src/renderers/WebGLRenderer.js +1340 -1258
  349. package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +1 -1
  350. package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +1 -1
  351. package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +0 -271
  352. package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +5 -5
  353. package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +2 -10
  354. package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +5 -5
  355. package/src/renderers/shaders/ShaderChunk/common.glsl.js +32 -0
  356. package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +1 -1
  357. package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +1 -1
  358. package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +1 -1
  359. package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +1 -1
  360. package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +3 -3
  361. package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +1 -1
  362. package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +11 -11
  363. package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +13 -13
  364. package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +256 -10
  365. package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +1 -11
  366. package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +9 -1
  367. package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +10 -2
  368. package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +1 -1
  369. package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +32 -10
  370. package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +5 -13
  371. package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +7 -7
  372. package/src/renderers/shaders/ShaderChunk/packing.glsl.js +11 -5
  373. package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +1 -1
  374. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +4 -11
  375. package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +2 -2
  376. package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +39 -34
  377. package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +1 -1
  378. package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +2 -2
  379. package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +91 -11
  380. package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +108 -1
  381. package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +128 -6
  382. package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +111 -1
  383. package/src/renderers/shaders/ShaderChunk.js +0 -6
  384. package/src/renderers/shaders/ShaderLib/background.glsl.js +0 -8
  385. package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +5 -0
  386. package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +1 -4
  387. package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -3
  388. package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +3 -3
  389. package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -3
  390. package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +8 -12
  391. package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -3
  392. package/src/renderers/shaders/ShaderLib/points.glsl.js +13 -0
  393. package/src/renderers/shaders/ShaderLib/shadow.glsl.js +5 -0
  394. package/src/renderers/shaders/ShaderLib.js +15 -4
  395. package/src/renderers/shaders/UniformsLib.js +25 -15
  396. package/src/renderers/shaders/UniformsUtils.js +12 -3
  397. package/src/renderers/webgl/WebGLBackground.js +23 -12
  398. package/src/renderers/webgl/WebGLCapabilities.js +1 -2
  399. package/src/renderers/webgl/WebGLClipping.js +7 -3
  400. package/src/renderers/webgl/WebGLLights.js +2 -2
  401. package/src/renderers/webgl/WebGLMaterials.js +105 -234
  402. package/src/renderers/webgl/WebGLMorphtargets.js +1 -1
  403. package/src/renderers/webgl/WebGLProgram.js +111 -48
  404. package/src/renderers/webgl/WebGLPrograms.js +200 -129
  405. package/src/renderers/webgl/WebGLRenderStates.js +2 -2
  406. package/src/renderers/webgl/WebGLShadowMap.js +40 -27
  407. package/src/renderers/webgl/WebGLState.js +23 -9
  408. package/src/renderers/webgl/WebGLTextures.js +21 -19
  409. package/src/renderers/webgl/WebGLUniformsGroups.js +74 -33
  410. package/src/renderers/webgl/WebGLUtils.js +41 -29
  411. package/src/renderers/webxr/WebXRController.js +3 -0
  412. package/src/renderers/webxr/WebXRManager.js +70 -48
  413. package/src/scenes/Scene.js +4 -6
  414. package/src/textures/CompressedTexture.js +2 -2
  415. package/src/textures/CubeTexture.js +2 -2
  416. package/src/textures/DataTexture.js +2 -2
  417. package/src/textures/Texture.js +41 -12
  418. package/src/utils.js +13 -1
  419. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
  420. package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
  421. package/examples/fonts/open-sans/open-sans.css +0 -9
  422. package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
  423. package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +0 -3966
  424. package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
  425. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
  426. package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
  427. package/examples/fonts/tabler-icons/tabler-icons.min.css +0 -4
  428. package/examples/js/animation/AnimationClipCreator.js +0 -89
  429. package/examples/js/animation/CCDIKSolver.js +0 -416
  430. package/examples/js/animation/MMDAnimationHelper.js +0 -1046
  431. package/examples/js/animation/MMDPhysics.js +0 -1174
  432. package/examples/js/cameras/CinematicCamera.js +0 -168
  433. package/examples/js/controls/ArcballControls.js +0 -2770
  434. package/examples/js/controls/DragControls.js +0 -205
  435. package/examples/js/controls/FirstPersonControls.js +0 -312
  436. package/examples/js/controls/FlyControls.js +0 -321
  437. package/examples/js/controls/OrbitControls.js +0 -1101
  438. package/examples/js/controls/PointerLockControls.js +0 -144
  439. package/examples/js/controls/TrackballControls.js +0 -729
  440. package/examples/js/controls/TransformControls.js +0 -1301
  441. package/examples/js/csm/CSM.js +0 -347
  442. package/examples/js/csm/CSMFrustum.js +0 -127
  443. package/examples/js/csm/CSMHelper.js +0 -165
  444. package/examples/js/csm/CSMShader.js +0 -253
  445. package/examples/js/curves/CurveExtras.js +0 -348
  446. package/examples/js/curves/NURBSCurve.js +0 -63
  447. package/examples/js/curves/NURBSSurface.js +0 -48
  448. package/examples/js/curves/NURBSUtils.js +0 -439
  449. package/examples/js/effects/AnaglyphEffect.js +0 -86
  450. package/examples/js/effects/AsciiEffect.js +0 -260
  451. package/examples/js/effects/OutlineEffect.js +0 -450
  452. package/examples/js/effects/ParallaxBarrierEffect.js +0 -62
  453. package/examples/js/effects/PeppersGhostEffect.js +0 -139
  454. package/examples/js/effects/StereoEffect.js +0 -46
  455. package/examples/js/environments/DebugEnvironment.js +0 -53
  456. package/examples/js/environments/RoomEnvironment.js +0 -124
  457. package/examples/js/exporters/ColladaExporter.js +0 -487
  458. package/examples/js/exporters/DRACOExporter.js +0 -212
  459. package/examples/js/exporters/EXRExporter.js +0 -455
  460. package/examples/js/exporters/GLTFExporter.js +0 -2367
  461. package/examples/js/exporters/MMDExporter.js +0 -187
  462. package/examples/js/exporters/OBJExporter.js +0 -260
  463. package/examples/js/exporters/PLYExporter.js +0 -427
  464. package/examples/js/exporters/STLExporter.js +0 -188
  465. package/examples/js/exporters/USDZExporter.js +0 -608
  466. package/examples/js/geometries/BoxLineGeometry.js +0 -59
  467. package/examples/js/geometries/ConvexGeometry.js +0 -53
  468. package/examples/js/geometries/DecalGeometry.js +0 -324
  469. package/examples/js/geometries/LightningStrike.js +0 -861
  470. package/examples/js/geometries/ParametricGeometries.js +0 -216
  471. package/examples/js/geometries/ParametricGeometry.js +0 -121
  472. package/examples/js/geometries/RoundedBoxGeometry.js +0 -142
  473. package/examples/js/geometries/TeapotGeometry.js +0 -335
  474. package/examples/js/geometries/TextGeometry.js +0 -53
  475. package/examples/js/helpers/LightProbeHelper.js +0 -48
  476. package/examples/js/helpers/OctreeHelper.js +0 -76
  477. package/examples/js/helpers/PositionalAudioHelper.js +0 -91
  478. package/examples/js/helpers/RectAreaLightHelper.js +0 -73
  479. package/examples/js/helpers/VertexNormalsHelper.js +0 -74
  480. package/examples/js/helpers/VertexTangentsHelper.js +0 -68
  481. package/examples/js/helpers/ViewHelper.js +0 -281
  482. package/examples/js/interactive/HTMLMesh.js +0 -497
  483. package/examples/js/interactive/InteractiveGroup.js +0 -95
  484. package/examples/js/interactive/SelectionBox.js +0 -195
  485. package/examples/js/interactive/SelectionHelper.js +0 -83
  486. package/examples/js/libs/chevrotain.min.js +0 -3
  487. package/examples/js/libs/draco/draco_decoder.js +0 -52
  488. package/examples/js/libs/draco/draco_decoder.wasm +0 -0
  489. package/examples/js/libs/draco/draco_wasm_wrapper.js +0 -104
  490. package/examples/js/libs/draco/gltf/draco_decoder.js +0 -48
  491. package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
  492. package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +0 -104
  493. package/examples/js/libs/fflate.min.js +0 -7
  494. package/examples/js/libs/ktx-parse.umd.js +0 -1
  495. package/examples/js/libs/meshopt_decoder.js +0 -188
  496. package/examples/js/libs/opentype.min.js +0 -1
  497. package/examples/js/libs/stats.min.js +0 -5
  498. package/examples/js/lights/LightProbeGenerator.js +0 -221
  499. package/examples/js/lights/RectAreaLightUniformsLib.js +0 -60
  500. package/examples/js/lines/Line2.js +0 -19
  501. package/examples/js/lines/LineGeometry.js +0 -69
  502. package/examples/js/lines/LineMaterial.js +0 -635
  503. package/examples/js/lines/LineSegments2.js +0 -313
  504. package/examples/js/lines/LineSegmentsGeometry.js +0 -198
  505. package/examples/js/lines/Wireframe.js +0 -47
  506. package/examples/js/lines/WireframeGeometry2.js +0 -20
  507. package/examples/js/loaders/3DMLoader.js +0 -1273
  508. package/examples/js/loaders/3MFLoader.js +0 -1306
  509. package/examples/js/loaders/AMFLoader.js +0 -504
  510. package/examples/js/loaders/BVHLoader.js +0 -395
  511. package/examples/js/loaders/BasisTextureLoader.js +0 -706
  512. package/examples/js/loaders/ColladaLoader.js +0 -3690
  513. package/examples/js/loaders/DDSLoader.js +0 -244
  514. package/examples/js/loaders/DRACOLoader.js +0 -511
  515. package/examples/js/loaders/EXRLoader.js +0 -2039
  516. package/examples/js/loaders/FBXLoader.js +0 -3681
  517. package/examples/js/loaders/FontLoader.js +0 -160
  518. package/examples/js/loaders/GCodeLoader.js +0 -255
  519. package/examples/js/loaders/GLTFLoader.js +0 -3862
  520. package/examples/js/loaders/HDRCubeTextureLoader.js +0 -87
  521. package/examples/js/loaders/KMZLoader.js +0 -121
  522. package/examples/js/loaders/KTXLoader.js +0 -159
  523. package/examples/js/loaders/LDrawLoader.js +0 -2263
  524. package/examples/js/loaders/LUT3dlLoader.js +0 -135
  525. package/examples/js/loaders/LUTCubeLoader.js +0 -132
  526. package/examples/js/loaders/LWOLoader.js +0 -901
  527. package/examples/js/loaders/LogLuvLoader.js +0 -715
  528. package/examples/js/loaders/LottieLoader.js +0 -62
  529. package/examples/js/loaders/MD2Loader.js +0 -248
  530. package/examples/js/loaders/MDDLoader.js +0 -91
  531. package/examples/js/loaders/MMDLoader.js +0 -1915
  532. package/examples/js/loaders/MTLLoader.js +0 -472
  533. package/examples/js/loaders/NRRDLoader.js +0 -609
  534. package/examples/js/loaders/OBJLoader.js +0 -789
  535. package/examples/js/loaders/PCDLoader.js +0 -413
  536. package/examples/js/loaders/PDBLoader.js +0 -317
  537. package/examples/js/loaders/PLYLoader.js +0 -576
  538. package/examples/js/loaders/PRWMLoader.js +0 -249
  539. package/examples/js/loaders/PVRLoader.js +0 -218
  540. package/examples/js/loaders/RGBELoader.js +0 -442
  541. package/examples/js/loaders/RGBMLoader.js +0 -1354
  542. package/examples/js/loaders/STLLoader.js +0 -364
  543. package/examples/js/loaders/SVGLoader.js +0 -2783
  544. package/examples/js/loaders/TDSLoader.js +0 -992
  545. package/examples/js/loaders/TGALoader.js +0 -484
  546. package/examples/js/loaders/TIFFLoader.js +0 -30
  547. package/examples/js/loaders/TTFLoader.js +0 -203
  548. package/examples/js/loaders/TiltLoader.js +0 -459
  549. package/examples/js/loaders/VOXLoader.js +0 -240
  550. package/examples/js/loaders/VRMLLoader.js +0 -3140
  551. package/examples/js/loaders/VTKLoader.js +0 -1078
  552. package/examples/js/loaders/XYZLoader.js +0 -89
  553. package/examples/js/loaders/lwo/IFFParser.js +0 -1067
  554. package/examples/js/loaders/lwo/LWO2Parser.js +0 -397
  555. package/examples/js/loaders/lwo/LWO3Parser.js +0 -360
  556. package/examples/js/materials/MeshGouraudMaterial.js +0 -387
  557. package/examples/js/math/Capsule.js +0 -103
  558. package/examples/js/math/ColorConverter.js +0 -33
  559. package/examples/js/math/ConvexHull.js +0 -1154
  560. package/examples/js/math/ImprovedNoise.js +0 -66
  561. package/examples/js/math/Lut.js +0 -164
  562. package/examples/js/math/MeshSurfaceSampler.js +0 -171
  563. package/examples/js/math/OBB.js +0 -382
  564. package/examples/js/math/Octree.js +0 -410
  565. package/examples/js/math/SimplexNoise.js +0 -445
  566. package/examples/js/misc/ConvexObjectBreaker.js +0 -474
  567. package/examples/js/misc/GPUComputationRenderer.js +0 -393
  568. package/examples/js/misc/Gyroscope.js +0 -56
  569. package/examples/js/misc/MD2Character.js +0 -235
  570. package/examples/js/misc/MD2CharacterComplex.js +0 -513
  571. package/examples/js/misc/MorphAnimMesh.js +0 -63
  572. package/examples/js/misc/MorphBlendMesh.js +0 -265
  573. package/examples/js/misc/ProgressiveLightMap.js +0 -335
  574. package/examples/js/misc/RollerCoaster.js +0 -430
  575. package/examples/js/misc/TubePainter.js +0 -167
  576. package/examples/js/misc/Volume.js +0 -437
  577. package/examples/js/misc/VolumeSlice.js +0 -214
  578. package/examples/js/modifiers/CurveModifier.js +0 -309
  579. package/examples/js/modifiers/EdgeSplitModifier.js +0 -228
  580. package/examples/js/modifiers/SimplifyModifier.js +0 -465
  581. package/examples/js/modifiers/TessellateModifier.js +0 -276
  582. package/examples/js/objects/GroundProjectedEnv.js +0 -181
  583. package/examples/js/objects/Lensflare.js +0 -356
  584. package/examples/js/objects/LightningStorm.js +0 -206
  585. package/examples/js/objects/MarchingCubes.js +0 -759
  586. package/examples/js/objects/Reflector.js +0 -216
  587. package/examples/js/objects/ReflectorForSSRPass.js +0 -315
  588. package/examples/js/objects/Refractor.js +0 -283
  589. package/examples/js/objects/ShadowMesh.js +0 -59
  590. package/examples/js/objects/Sky.js +0 -218
  591. package/examples/js/objects/Water.js +0 -292
  592. package/examples/js/objects/Water2.js +0 -307
  593. package/examples/js/physics/AmmoPhysics.js +0 -259
  594. package/examples/js/physics/OimoPhysics.js +0 -217
  595. package/examples/js/postprocessing/AdaptiveToneMappingPass.js +0 -335
  596. package/examples/js/postprocessing/AfterimagePass.js +0 -77
  597. package/examples/js/postprocessing/BloomPass.js +0 -135
  598. package/examples/js/postprocessing/BokehPass.js +0 -120
  599. package/examples/js/postprocessing/ClearPass.js +0 -39
  600. package/examples/js/postprocessing/CubeTexturePass.js +0 -60
  601. package/examples/js/postprocessing/DotScreenPass.js +0 -51
  602. package/examples/js/postprocessing/EffectComposer.js +0 -272
  603. package/examples/js/postprocessing/FilmPass.js +0 -52
  604. package/examples/js/postprocessing/GlitchPass.js +0 -104
  605. package/examples/js/postprocessing/HalftonePass.js +0 -75
  606. package/examples/js/postprocessing/LUTPass.js +0 -171
  607. package/examples/js/postprocessing/MaskPass.js +0 -95
  608. package/examples/js/postprocessing/OutlinePass.js +0 -598
  609. package/examples/js/postprocessing/Pass.js +0 -72
  610. package/examples/js/postprocessing/RenderPass.js +0 -70
  611. package/examples/js/postprocessing/RenderPixelatedPass.js +0 -215
  612. package/examples/js/postprocessing/SAOPass.js +0 -374
  613. package/examples/js/postprocessing/SMAAPass.js +0 -170
  614. package/examples/js/postprocessing/SSAARenderPass.js +0 -156
  615. package/examples/js/postprocessing/SSAOPass.js +0 -365
  616. package/examples/js/postprocessing/SSRPass.js +0 -567
  617. package/examples/js/postprocessing/SavePass.js +0 -59
  618. package/examples/js/postprocessing/ShaderPass.js +0 -64
  619. package/examples/js/postprocessing/TAARenderPass.js +0 -130
  620. package/examples/js/postprocessing/TexturePass.js +0 -49
  621. package/examples/js/postprocessing/UnrealBloomPass.js +0 -375
  622. package/examples/js/renderers/CSS2DRenderer.js +0 -178
  623. package/examples/js/renderers/CSS3DRenderer.js +0 -237
  624. package/examples/js/renderers/Projector.js +0 -818
  625. package/examples/js/renderers/SVGRenderer.js +0 -491
  626. package/examples/js/shaders/ACESFilmicToneMappingShader.js +0 -89
  627. package/examples/js/shaders/AfterimageShader.js +0 -60
  628. package/examples/js/shaders/BasicShader.js +0 -27
  629. package/examples/js/shaders/BleachBypassShader.js +0 -62
  630. package/examples/js/shaders/BlendShader.js +0 -54
  631. package/examples/js/shaders/BokehShader.js +0 -156
  632. package/examples/js/shaders/BokehShader2.js +0 -419
  633. package/examples/js/shaders/BrightnessContrastShader.js +0 -58
  634. package/examples/js/shaders/ColorCorrectionShader.js +0 -52
  635. package/examples/js/shaders/ColorifyShader.js +0 -47
  636. package/examples/js/shaders/ConvolutionShader.js +0 -92
  637. package/examples/js/shaders/CopyShader.js +0 -45
  638. package/examples/js/shaders/DOFMipMapShader.js +0 -60
  639. package/examples/js/shaders/DepthLimitedBlurShader.js +0 -173
  640. package/examples/js/shaders/DigitalGlitch.js +0 -127
  641. package/examples/js/shaders/DotScreenShader.js +0 -72
  642. package/examples/js/shaders/FXAAShader.js +0 -284
  643. package/examples/js/shaders/FilmShader.js +0 -110
  644. package/examples/js/shaders/FocusShader.js +0 -95
  645. package/examples/js/shaders/FreiChenShader.js +0 -93
  646. package/examples/js/shaders/GammaCorrectionShader.js +0 -41
  647. package/examples/js/shaders/GodRaysShader.js +0 -284
  648. package/examples/js/shaders/HalftoneShader.js +0 -336
  649. package/examples/js/shaders/HorizontalBlurShader.js +0 -59
  650. package/examples/js/shaders/HorizontalTiltShiftShader.js +0 -65
  651. package/examples/js/shaders/HueSaturationShader.js +0 -69
  652. package/examples/js/shaders/KaleidoShader.js +0 -60
  653. package/examples/js/shaders/LuminosityHighPassShader.js +0 -67
  654. package/examples/js/shaders/LuminosityShader.js +0 -46
  655. package/examples/js/shaders/MMDToonShader.js +0 -94
  656. package/examples/js/shaders/MirrorShader.js +0 -56
  657. package/examples/js/shaders/NormalMapShader.js +0 -55
  658. package/examples/js/shaders/RGBShiftShader.js +0 -56
  659. package/examples/js/shaders/SAOShader.js +0 -209
  660. package/examples/js/shaders/SMAAShader.js +0 -454
  661. package/examples/js/shaders/SSAOShader.js +0 -295
  662. package/examples/js/shaders/SSRShader.js +0 -381
  663. package/examples/js/shaders/SepiaShader.js +0 -52
  664. package/examples/js/shaders/SobelOperatorShader.js +0 -88
  665. package/examples/js/shaders/SubsurfaceScatteringShader.js +0 -49
  666. package/examples/js/shaders/TechnicolorShader.js +0 -43
  667. package/examples/js/shaders/ToneMapShader.js +0 -84
  668. package/examples/js/shaders/ToonShader.js +0 -335
  669. package/examples/js/shaders/TriangleBlurShader.js +0 -70
  670. package/examples/js/shaders/UnpackDepthRGBAShader.js +0 -47
  671. package/examples/js/shaders/VelocityShader.js +0 -126
  672. package/examples/js/shaders/VerticalBlurShader.js +0 -59
  673. package/examples/js/shaders/VerticalTiltShiftShader.js +0 -65
  674. package/examples/js/shaders/VignetteShader.js +0 -53
  675. package/examples/js/shaders/VolumeShader.js +0 -296
  676. package/examples/js/shaders/WaterRefractionShader.js +0 -84
  677. package/examples/js/textures/FlakesTexture.js +0 -40
  678. package/examples/js/utils/BufferGeometryUtils.js +0 -1160
  679. package/examples/js/utils/CameraUtils.js +0 -71
  680. package/examples/js/utils/GPUStatsPanel.js +0 -125
  681. package/examples/js/utils/GeometryCompressionUtils.js +0 -549
  682. package/examples/js/utils/GeometryUtils.js +0 -168
  683. package/examples/js/utils/LDrawUtils.js +0 -179
  684. package/examples/js/utils/PackedPhongMaterial.js +0 -109
  685. package/examples/js/utils/SceneUtils.js +0 -214
  686. package/examples/js/utils/ShadowMapViewer.js +0 -183
  687. package/examples/js/utils/SkeletonUtils.js +0 -493
  688. package/examples/js/utils/UVsDebug.js +0 -143
  689. package/examples/js/utils/WorkerPool.js +0 -105
  690. package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +0 -37071
  691. package/examples/jsm/libs/OimoPhysics/index.js +0 -43
  692. package/examples/jsm/libs/flow.module.js +0 -4552
  693. package/examples/jsm/libs/tween.module.min.js +0 -3
  694. package/examples/jsm/loaders/BasisTextureLoader.js +0 -790
  695. package/examples/jsm/loaders/IFCLoader.js +0 -2431
  696. package/examples/jsm/loaders/ifc/web-ifc-api.js +0 -47504
  697. package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
  698. package/examples/jsm/node-editor/NodeEditor.js +0 -857
  699. package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +0 -14
  700. package/examples/jsm/node-editor/accessors/NormalEditor.js +0 -30
  701. package/examples/jsm/node-editor/accessors/PositionEditor.js +0 -30
  702. package/examples/jsm/node-editor/accessors/UVEditor.js +0 -25
  703. package/examples/jsm/node-editor/core/BaseNode.js +0 -96
  704. package/examples/jsm/node-editor/core/DataFile.js +0 -59
  705. package/examples/jsm/node-editor/core/FileEditor.js +0 -20
  706. package/examples/jsm/node-editor/core/FileURLEditor.js +0 -29
  707. package/examples/jsm/node-editor/display/BlendEditor.js +0 -44
  708. package/examples/jsm/node-editor/display/NormalMapEditor.js +0 -49
  709. package/examples/jsm/node-editor/examples/animate-uv.json +0 -1
  710. package/examples/jsm/node-editor/examples/fake-top-light.json +0 -1
  711. package/examples/jsm/node-editor/examples/matcap.json +0 -1
  712. package/examples/jsm/node-editor/examples/oscillator-color.json +0 -1
  713. package/examples/jsm/node-editor/examples/rim.json +0 -1
  714. package/examples/jsm/node-editor/inputs/ColorEditor.js +0 -96
  715. package/examples/jsm/node-editor/inputs/FloatEditor.js +0 -23
  716. package/examples/jsm/node-editor/inputs/SliderEditor.js +0 -67
  717. package/examples/jsm/node-editor/inputs/TextureEditor.js +0 -155
  718. package/examples/jsm/node-editor/inputs/Vector2Editor.js +0 -28
  719. package/examples/jsm/node-editor/inputs/Vector3Editor.js +0 -30
  720. package/examples/jsm/node-editor/inputs/Vector4Editor.js +0 -37
  721. package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +0 -84
  722. package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +0 -102
  723. package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +0 -118
  724. package/examples/jsm/node-editor/math/AngleEditor.js +0 -40
  725. package/examples/jsm/node-editor/math/DotEditor.js +0 -35
  726. package/examples/jsm/node-editor/math/InvertEditor.js +0 -39
  727. package/examples/jsm/node-editor/math/LimiterEditor.js +0 -62
  728. package/examples/jsm/node-editor/math/NormalizeEditor.js +0 -28
  729. package/examples/jsm/node-editor/math/OperatorEditor.js +0 -63
  730. package/examples/jsm/node-editor/math/PowerEditor.js +0 -44
  731. package/examples/jsm/node-editor/math/TrigonometryEditor.js +0 -45
  732. package/examples/jsm/node-editor/procedural/CheckerEditor.js +0 -27
  733. package/examples/jsm/node-editor/scene/MeshEditor.js +0 -102
  734. package/examples/jsm/node-editor/scene/Object3DEditor.js +0 -160
  735. package/examples/jsm/node-editor/scene/PointsEditor.js +0 -99
  736. package/examples/jsm/node-editor/utils/JoinEditor.js +0 -58
  737. package/examples/jsm/node-editor/utils/OscillatorEditor.js +0 -43
  738. package/examples/jsm/node-editor/utils/PreviewEditor.js +0 -170
  739. package/examples/jsm/node-editor/utils/SplitEditor.js +0 -39
  740. package/examples/jsm/node-editor/utils/TimerEditor.js +0 -58
  741. package/examples/jsm/nodes/core/ExpressionNode.js +0 -32
  742. package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +0 -22
  743. package/examples/jsm/nodes/lighting/PunctualLightNode.js +0 -68
  744. package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +0 -301
  745. package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +0 -149
  746. package/examples/jsm/objects/GroundProjectedEnv.js +0 -186
  747. package/examples/jsm/renderers/webgpu/WebGPUObjects.js +0 -36
  748. package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +0 -7
  749. package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +0 -10
  750. package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +0 -7
  751. /package/examples/{js → jsm}/libs/ammo.wasm.js +0 -0
  752. /package/examples/{js → jsm}/libs/ammo.wasm.wasm +0 -0
  753. /package/examples/{js → jsm}/libs/basis/basis_transcoder.js +0 -0
  754. /package/examples/{js → jsm}/libs/basis/basis_transcoder.wasm +0 -0
  755. /package/examples/{js → jsm}/libs/draco/README.md +0 -0
  756. /package/examples/{js → jsm}/libs/draco/draco_encoder.js +0 -0
  757. /package/examples/{js → jsm}/libs/draco/gltf/draco_encoder.js +0 -0
@@ -1,1915 +0,0 @@
1
- ( function () {
2
-
3
- /**
4
- * Dependencies
5
- * - mmd-parser https://github.com/takahirox/mmd-parser
6
- * - THREE.TGALoader
7
- * - OutlineEffect
8
- *
9
- * MMDLoader creates Three.js Objects from MMD resources as
10
- * PMD, PMX, VMD, and VPD files.
11
- *
12
- * PMD/PMX is a model data format, VMD is a motion data format
13
- * VPD is a posing data format used in MMD(Miku Miku Dance).
14
- *
15
- * MMD official site
16
- * - https://sites.google.com/view/evpvp/
17
- *
18
- * PMD, VMD format (in Japanese)
19
- * - http://blog.goo.ne.jp/torisu_tetosuki/e/209ad341d3ece2b1b4df24abf619d6e4
20
- *
21
- * PMX format
22
- * - https://gist.github.com/felixjones/f8a06bd48f9da9a4539f
23
- *
24
- * TODO
25
- * - light motion in vmd support.
26
- * - SDEF support.
27
- * - uv/material/bone morphing support.
28
- * - more precise grant skinning support.
29
- * - shadow support.
30
- */
31
-
32
- /**
33
- * @param {THREE.LoadingManager} manager
34
- */
35
- class MMDLoader extends THREE.Loader {
36
-
37
- constructor( manager ) {
38
-
39
- super( manager );
40
- this.loader = new THREE.FileLoader( this.manager );
41
- this.parser = null; // lazy generation
42
- this.meshBuilder = new MeshBuilder( this.manager );
43
- this.animationBuilder = new AnimationBuilder();
44
-
45
- }
46
-
47
- /**
48
- * @param {string} animationPath
49
- * @return {MMDLoader}
50
- */
51
- setAnimationPath( animationPath ) {
52
-
53
- this.animationPath = animationPath;
54
- return this;
55
-
56
- }
57
-
58
- // Load MMD assets as Three.js Object
59
-
60
- /**
61
- * Loads Model file (.pmd or .pmx) as a THREE.SkinnedMesh.
62
- *
63
- * @param {string} url - url to Model(.pmd or .pmx) file
64
- * @param {function} onLoad
65
- * @param {function} onProgress
66
- * @param {function} onError
67
- */
68
- load( url, onLoad, onProgress, onError ) {
69
-
70
- const builder = this.meshBuilder.setCrossOrigin( this.crossOrigin );
71
-
72
- // resource path
73
-
74
- let resourcePath;
75
- if ( this.resourcePath !== '' ) {
76
-
77
- resourcePath = this.resourcePath;
78
-
79
- } else if ( this.path !== '' ) {
80
-
81
- resourcePath = this.path;
82
-
83
- } else {
84
-
85
- resourcePath = THREE.LoaderUtils.extractUrlBase( url );
86
-
87
- }
88
-
89
- const modelExtension = this._extractExtension( url ).toLowerCase();
90
-
91
- // Should I detect by seeing header?
92
- if ( modelExtension !== 'pmd' && modelExtension !== 'pmx' ) {
93
-
94
- if ( onError ) onError( new Error( 'THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.' ) );
95
- return;
96
-
97
- }
98
-
99
- this[ modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX' ]( url, function ( data ) {
100
-
101
- onLoad( builder.build( data, resourcePath, onProgress, onError ) );
102
-
103
- }, onProgress, onError );
104
-
105
- }
106
-
107
- /**
108
- * Loads Motion file(s) (.vmd) as a THREE.AnimationClip.
109
- * If two or more files are specified, they'll be merged.
110
- *
111
- * @param {string|Array<string>} url - url(s) to animation(.vmd) file(s)
112
- * @param {SkinnedMesh|THREE.Camera} object - tracks will be fitting to this object
113
- * @param {function} onLoad
114
- * @param {function} onProgress
115
- * @param {function} onError
116
- */
117
- loadAnimation( url, object, onLoad, onProgress, onError ) {
118
-
119
- const builder = this.animationBuilder;
120
- this.loadVMD( url, function ( vmd ) {
121
-
122
- onLoad( object.isCamera ? builder.buildCameraAnimation( vmd ) : builder.build( vmd, object ) );
123
-
124
- }, onProgress, onError );
125
-
126
- }
127
-
128
- /**
129
- * Loads mode file and motion file(s) as an object containing
130
- * a THREE.SkinnedMesh and a THREE.AnimationClip.
131
- * Tracks of THREE.AnimationClip are fitting to the model.
132
- *
133
- * @param {string} modelUrl - url to Model(.pmd or .pmx) file
134
- * @param {string|Array{string}} vmdUrl - url(s) to animation(.vmd) file
135
- * @param {function} onLoad
136
- * @param {function} onProgress
137
- * @param {function} onError
138
- */
139
- loadWithAnimation( modelUrl, vmdUrl, onLoad, onProgress, onError ) {
140
-
141
- const scope = this;
142
- this.load( modelUrl, function ( mesh ) {
143
-
144
- scope.loadAnimation( vmdUrl, mesh, function ( animation ) {
145
-
146
- onLoad( {
147
- mesh: mesh,
148
- animation: animation
149
- } );
150
-
151
- }, onProgress, onError );
152
-
153
- }, onProgress, onError );
154
-
155
- }
156
-
157
- // Load MMD assets as Object data parsed by MMDParser
158
-
159
- /**
160
- * Loads .pmd file as an Object.
161
- *
162
- * @param {string} url - url to .pmd file
163
- * @param {function} onLoad
164
- * @param {function} onProgress
165
- * @param {function} onError
166
- */
167
- loadPMD( url, onLoad, onProgress, onError ) {
168
-
169
- const parser = this._getParser();
170
- this.loader.setMimeType( undefined ).setPath( this.path ).setResponseType( 'arraybuffer' ).setRequestHeader( this.requestHeader ).setWithCredentials( this.withCredentials ).load( url, function ( buffer ) {
171
-
172
- onLoad( parser.parsePmd( buffer, true ) );
173
-
174
- }, onProgress, onError );
175
-
176
- }
177
-
178
- /**
179
- * Loads .pmx file as an Object.
180
- *
181
- * @param {string} url - url to .pmx file
182
- * @param {function} onLoad
183
- * @param {function} onProgress
184
- * @param {function} onError
185
- */
186
- loadPMX( url, onLoad, onProgress, onError ) {
187
-
188
- const parser = this._getParser();
189
- this.loader.setMimeType( undefined ).setPath( this.path ).setResponseType( 'arraybuffer' ).setRequestHeader( this.requestHeader ).setWithCredentials( this.withCredentials ).load( url, function ( buffer ) {
190
-
191
- onLoad( parser.parsePmx( buffer, true ) );
192
-
193
- }, onProgress, onError );
194
-
195
- }
196
-
197
- /**
198
- * Loads .vmd file as an Object. If two or more files are specified
199
- * they'll be merged.
200
- *
201
- * @param {string|Array<string>} url - url(s) to .vmd file(s)
202
- * @param {function} onLoad
203
- * @param {function} onProgress
204
- * @param {function} onError
205
- */
206
- loadVMD( url, onLoad, onProgress, onError ) {
207
-
208
- const urls = Array.isArray( url ) ? url : [ url ];
209
- const vmds = [];
210
- const vmdNum = urls.length;
211
- const parser = this._getParser();
212
- this.loader.setMimeType( undefined ).setPath( this.animationPath ).setResponseType( 'arraybuffer' ).setRequestHeader( this.requestHeader ).setWithCredentials( this.withCredentials );
213
- for ( let i = 0, il = urls.length; i < il; i ++ ) {
214
-
215
- this.loader.load( urls[ i ], function ( buffer ) {
216
-
217
- vmds.push( parser.parseVmd( buffer, true ) );
218
- if ( vmds.length === vmdNum ) onLoad( parser.mergeVmds( vmds ) );
219
-
220
- }, onProgress, onError );
221
-
222
- }
223
-
224
- }
225
-
226
- /**
227
- * Loads .vpd file as an Object.
228
- *
229
- * @param {string} url - url to .vpd file
230
- * @param {boolean} isUnicode
231
- * @param {function} onLoad
232
- * @param {function} onProgress
233
- * @param {function} onError
234
- */
235
- loadVPD( url, isUnicode, onLoad, onProgress, onError ) {
236
-
237
- const parser = this._getParser();
238
- this.loader.setMimeType( isUnicode ? undefined : 'text/plain; charset=shift_jis' ).setPath( this.animationPath ).setResponseType( 'text' ).setRequestHeader( this.requestHeader ).setWithCredentials( this.withCredentials ).load( url, function ( text ) {
239
-
240
- onLoad( parser.parseVpd( text, true ) );
241
-
242
- }, onProgress, onError );
243
-
244
- }
245
-
246
- // private methods
247
-
248
- _extractExtension( url ) {
249
-
250
- const index = url.lastIndexOf( '.' );
251
- return index < 0 ? '' : url.slice( index + 1 );
252
-
253
- }
254
- _getParser() {
255
-
256
- if ( this.parser === null ) {
257
-
258
- if ( typeof MMDParser === 'undefined' ) {
259
-
260
- throw new Error( 'THREE.MMDLoader: Import MMDParser https://github.com/takahirox/mmd-parser' );
261
-
262
- }
263
-
264
- this.parser = new MMDParser.Parser(); // eslint-disable-line no-undef
265
-
266
- }
267
-
268
- return this.parser;
269
-
270
- }
271
-
272
- }
273
-
274
- // Utilities
275
-
276
- /*
277
- * base64 encoded defalut toon textures toon00.bmp - toon10.bmp.
278
- * We don't need to request external toon image files.
279
- */
280
- const DEFAULT_TOON_TEXTURES = [ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/bWiiMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh8aBHZBl14e8wAAAABJRU5ErkJggg==', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOUlEQVRYR+3WMREAMAwDsYY/yoDI7MLwIiP40+RJklfcCCBAgAABAgTqArfb/QMCCBAgQIAAgbbAB3z/e0F3js2cAAAAAElFTkSuQmCC', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAN0lEQVRYR+3WQREAMBACsZ5/B5ilMvgEBTt5cW37hjsBBAgQIECAwFwgyfYPCCBAgAABAgTWAh81dWyx0gFwKAAAAABJRU5ErkJggg==', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAOklEQVRYR+3WoREAMAwDsWb/UQtCy9wxTOQJ/oQ8SXKKGwEECBAgQIBAXeDt7f4BAQQIECBAgEBb4AOz8Hzx7WLY4wAAAABJRU5ErkJggg==', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAABPUlEQVRYR+1XwW7CMAy1+f9fZOMysSEOEweEOPRNdm3HbdOyIhAcklPrOs/PLy9RygBALxzcCDQFmgJNgaZAU6Ap0BR4PwX8gsRMVLssMRH5HcpzJEaWL7EVg9F1IHRlyqQohgVr4FGUlUcMJSjcUlDw0zvjeun70cLWmneoyf7NgBTQSniBTQQSuJAZsOnnaczjIMb5hCiuHKxokCrJfVnrctyZL0PkJAJe1HMil4nxeyi3Ypfn1kX51jpPvo/JeCNC4PhVdHdJw2XjBR8brF8PEIhNVn12AgP7uHsTBguBn53MUZCqv7Lp07Pn5k1Ro+uWmUNn7D+M57rtk7aG0Vo73xyF/fbFf0bPJjDXngnGocDTdFhygZjwUQrMNrDcmZlQT50VJ/g/UwNyHpu778+yW+/ksOz/BFo54P4AsUXMfRq7XWsAAAAASUVORK5CYII=', '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=', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=' ];
281
- const NON_ALPHA_CHANNEL_FORMATS = [ THREE.RGB_S3TC_DXT1_Format, THREE.RGB_PVRTC_4BPPV1_Format, THREE.RGB_PVRTC_2BPPV1_Format, THREE.RGB_ETC1_Format, THREE.RGB_ETC2_Format ];
282
-
283
- // Builders. They build Three.js object from Object data parsed by MMDParser.
284
-
285
- /**
286
- * @param {THREE.LoadingManager} manager
287
- */
288
- class MeshBuilder {
289
-
290
- constructor( manager ) {
291
-
292
- this.crossOrigin = 'anonymous';
293
- this.geometryBuilder = new GeometryBuilder();
294
- this.materialBuilder = new MaterialBuilder( manager );
295
-
296
- }
297
-
298
- /**
299
- * @param {string} crossOrigin
300
- * @return {MeshBuilder}
301
- */
302
- setCrossOrigin( crossOrigin ) {
303
-
304
- this.crossOrigin = crossOrigin;
305
- return this;
306
-
307
- }
308
-
309
- /**
310
- * @param {Object} data - parsed PMD/PMX data
311
- * @param {string} resourcePath
312
- * @param {function} onProgress
313
- * @param {function} onError
314
- * @return {SkinnedMesh}
315
- */
316
- build( data, resourcePath, onProgress, onError ) {
317
-
318
- const geometry = this.geometryBuilder.build( data );
319
- const material = this.materialBuilder.setCrossOrigin( this.crossOrigin ).setResourcePath( resourcePath ).build( data, geometry, onProgress, onError );
320
- const mesh = new THREE.SkinnedMesh( geometry, material );
321
- const skeleton = new THREE.Skeleton( initBones( mesh ) );
322
- mesh.bind( skeleton );
323
-
324
- // console.log( mesh ); // for console debug
325
-
326
- return mesh;
327
-
328
- }
329
-
330
- }
331
-
332
- // TODO: Try to remove this function
333
-
334
- function initBones( mesh ) {
335
-
336
- const geometry = mesh.geometry;
337
- const bones = [];
338
- if ( geometry && geometry.bones !== undefined ) {
339
-
340
- // first, create array of 'Bone' objects from geometry data
341
-
342
- for ( let i = 0, il = geometry.bones.length; i < il; i ++ ) {
343
-
344
- const gbone = geometry.bones[ i ];
345
-
346
- // create new 'Bone' object
347
-
348
- const bone = new THREE.Bone();
349
- bones.push( bone );
350
-
351
- // apply values
352
-
353
- bone.name = gbone.name;
354
- bone.position.fromArray( gbone.pos );
355
- bone.quaternion.fromArray( gbone.rotq );
356
- if ( gbone.scl !== undefined ) bone.scale.fromArray( gbone.scl );
357
-
358
- }
359
-
360
- // second, create bone hierarchy
361
-
362
- for ( let i = 0, il = geometry.bones.length; i < il; i ++ ) {
363
-
364
- const gbone = geometry.bones[ i ];
365
- if ( gbone.parent !== - 1 && gbone.parent !== null && bones[ gbone.parent ] !== undefined ) {
366
-
367
- // subsequent bones in the hierarchy
368
-
369
- bones[ gbone.parent ].add( bones[ i ] );
370
-
371
- } else {
372
-
373
- // topmost bone, immediate child of the skinned mesh
374
-
375
- mesh.add( bones[ i ] );
376
-
377
- }
378
-
379
- }
380
-
381
- }
382
-
383
- // now the bones are part of the scene graph and children of the skinned mesh.
384
- // let's update the corresponding matrices
385
-
386
- mesh.updateMatrixWorld( true );
387
- return bones;
388
-
389
- }
390
-
391
- //
392
-
393
- class GeometryBuilder {
394
-
395
- /**
396
- * @param {Object} data - parsed PMD/PMX data
397
- * @return {BufferGeometry}
398
- */
399
- build( data ) {
400
-
401
- // for geometry
402
- const positions = [];
403
- const uvs = [];
404
- const normals = [];
405
- const indices = [];
406
- const groups = [];
407
- const bones = [];
408
- const skinIndices = [];
409
- const skinWeights = [];
410
- const morphTargets = [];
411
- const morphPositions = [];
412
- const iks = [];
413
- const grants = [];
414
- const rigidBodies = [];
415
- const constraints = [];
416
-
417
- // for work
418
- let offset = 0;
419
- const boneTypeTable = {};
420
-
421
- // positions, normals, uvs, skinIndices, skinWeights
422
-
423
- for ( let i = 0; i < data.metadata.vertexCount; i ++ ) {
424
-
425
- const v = data.vertices[ i ];
426
- for ( let j = 0, jl = v.position.length; j < jl; j ++ ) {
427
-
428
- positions.push( v.position[ j ] );
429
-
430
- }
431
-
432
- for ( let j = 0, jl = v.normal.length; j < jl; j ++ ) {
433
-
434
- normals.push( v.normal[ j ] );
435
-
436
- }
437
-
438
- for ( let j = 0, jl = v.uv.length; j < jl; j ++ ) {
439
-
440
- uvs.push( v.uv[ j ] );
441
-
442
- }
443
-
444
- for ( let j = 0; j < 4; j ++ ) {
445
-
446
- skinIndices.push( v.skinIndices.length - 1 >= j ? v.skinIndices[ j ] : 0.0 );
447
-
448
- }
449
-
450
- for ( let j = 0; j < 4; j ++ ) {
451
-
452
- skinWeights.push( v.skinWeights.length - 1 >= j ? v.skinWeights[ j ] : 0.0 );
453
-
454
- }
455
-
456
- }
457
-
458
- // indices
459
-
460
- for ( let i = 0; i < data.metadata.faceCount; i ++ ) {
461
-
462
- const face = data.faces[ i ];
463
- for ( let j = 0, jl = face.indices.length; j < jl; j ++ ) {
464
-
465
- indices.push( face.indices[ j ] );
466
-
467
- }
468
-
469
- }
470
-
471
- // groups
472
-
473
- for ( let i = 0; i < data.metadata.materialCount; i ++ ) {
474
-
475
- const material = data.materials[ i ];
476
- groups.push( {
477
- offset: offset * 3,
478
- count: material.faceCount * 3
479
- } );
480
- offset += material.faceCount;
481
-
482
- }
483
-
484
- // bones
485
-
486
- for ( let i = 0; i < data.metadata.rigidBodyCount; i ++ ) {
487
-
488
- const body = data.rigidBodies[ i ];
489
- let value = boneTypeTable[ body.boneIndex ];
490
-
491
- // keeps greater number if already value is set without any special reasons
492
- value = value === undefined ? body.type : Math.max( body.type, value );
493
- boneTypeTable[ body.boneIndex ] = value;
494
-
495
- }
496
-
497
- for ( let i = 0; i < data.metadata.boneCount; i ++ ) {
498
-
499
- const boneData = data.bones[ i ];
500
- const bone = {
501
- index: i,
502
- transformationClass: boneData.transformationClass,
503
- parent: boneData.parentIndex,
504
- name: boneData.name,
505
- pos: boneData.position.slice( 0, 3 ),
506
- rotq: [ 0, 0, 0, 1 ],
507
- scl: [ 1, 1, 1 ],
508
- rigidBodyType: boneTypeTable[ i ] !== undefined ? boneTypeTable[ i ] : - 1
509
- };
510
- if ( bone.parent !== - 1 ) {
511
-
512
- bone.pos[ 0 ] -= data.bones[ bone.parent ].position[ 0 ];
513
- bone.pos[ 1 ] -= data.bones[ bone.parent ].position[ 1 ];
514
- bone.pos[ 2 ] -= data.bones[ bone.parent ].position[ 2 ];
515
-
516
- }
517
-
518
- bones.push( bone );
519
-
520
- }
521
-
522
- // iks
523
-
524
- // TODO: remove duplicated codes between PMD and PMX
525
- if ( data.metadata.format === 'pmd' ) {
526
-
527
- for ( let i = 0; i < data.metadata.ikCount; i ++ ) {
528
-
529
- const ik = data.iks[ i ];
530
- const param = {
531
- target: ik.target,
532
- effector: ik.effector,
533
- iteration: ik.iteration,
534
- maxAngle: ik.maxAngle * 4,
535
- links: []
536
- };
537
- for ( let j = 0, jl = ik.links.length; j < jl; j ++ ) {
538
-
539
- const link = {};
540
- link.index = ik.links[ j ].index;
541
- link.enabled = true;
542
- if ( data.bones[ link.index ].name.indexOf( 'ひざ' ) >= 0 ) {
543
-
544
- link.limitation = new THREE.Vector3( 1.0, 0.0, 0.0 );
545
-
546
- }
547
-
548
- param.links.push( link );
549
-
550
- }
551
-
552
- iks.push( param );
553
-
554
- }
555
-
556
- } else {
557
-
558
- for ( let i = 0; i < data.metadata.boneCount; i ++ ) {
559
-
560
- const ik = data.bones[ i ].ik;
561
- if ( ik === undefined ) continue;
562
- const param = {
563
- target: i,
564
- effector: ik.effector,
565
- iteration: ik.iteration,
566
- maxAngle: ik.maxAngle,
567
- links: []
568
- };
569
- for ( let j = 0, jl = ik.links.length; j < jl; j ++ ) {
570
-
571
- const link = {};
572
- link.index = ik.links[ j ].index;
573
- link.enabled = true;
574
- if ( ik.links[ j ].angleLimitation === 1 ) {
575
-
576
- // Revert if rotationMin/Max doesn't work well
577
- // link.limitation = new THREE.Vector3( 1.0, 0.0, 0.0 );
578
-
579
- const rotationMin = ik.links[ j ].lowerLimitationAngle;
580
- const rotationMax = ik.links[ j ].upperLimitationAngle;
581
-
582
- // Convert Left to Right coordinate by myself because
583
- // MMDParser doesn't convert. It's a MMDParser's bug
584
-
585
- const tmp1 = - rotationMax[ 0 ];
586
- const tmp2 = - rotationMax[ 1 ];
587
- rotationMax[ 0 ] = - rotationMin[ 0 ];
588
- rotationMax[ 1 ] = - rotationMin[ 1 ];
589
- rotationMin[ 0 ] = tmp1;
590
- rotationMin[ 1 ] = tmp2;
591
- link.rotationMin = new THREE.Vector3().fromArray( rotationMin );
592
- link.rotationMax = new THREE.Vector3().fromArray( rotationMax );
593
-
594
- }
595
-
596
- param.links.push( link );
597
-
598
- }
599
-
600
- iks.push( param );
601
-
602
- // Save the reference even from bone data for efficiently
603
- // simulating PMX animation system
604
- bones[ i ].ik = param;
605
-
606
- }
607
-
608
- }
609
-
610
- // grants
611
-
612
- if ( data.metadata.format === 'pmx' ) {
613
-
614
- // bone index -> grant entry map
615
- const grantEntryMap = {};
616
- for ( let i = 0; i < data.metadata.boneCount; i ++ ) {
617
-
618
- const boneData = data.bones[ i ];
619
- const grant = boneData.grant;
620
- if ( grant === undefined ) continue;
621
- const param = {
622
- index: i,
623
- parentIndex: grant.parentIndex,
624
- ratio: grant.ratio,
625
- isLocal: grant.isLocal,
626
- affectRotation: grant.affectRotation,
627
- affectPosition: grant.affectPosition,
628
- transformationClass: boneData.transformationClass
629
- };
630
- grantEntryMap[ i ] = {
631
- parent: null,
632
- children: [],
633
- param: param,
634
- visited: false
635
- };
636
-
637
- }
638
-
639
- const rootEntry = {
640
- parent: null,
641
- children: [],
642
- param: null,
643
- visited: false
644
- };
645
-
646
- // Build a tree representing grant hierarchy
647
-
648
- for ( const boneIndex in grantEntryMap ) {
649
-
650
- const grantEntry = grantEntryMap[ boneIndex ];
651
- const parentGrantEntry = grantEntryMap[ grantEntry.parentIndex ] || rootEntry;
652
- grantEntry.parent = parentGrantEntry;
653
- parentGrantEntry.children.push( grantEntry );
654
-
655
- }
656
-
657
- // Sort grant parameters from parents to children because
658
- // grant uses parent's transform that parent's grant is already applied
659
- // so grant should be applied in order from parents to children
660
-
661
- function traverse( entry ) {
662
-
663
- if ( entry.param ) {
664
-
665
- grants.push( entry.param );
666
-
667
- // Save the reference even from bone data for efficiently
668
- // simulating PMX animation system
669
- bones[ entry.param.index ].grant = entry.param;
670
-
671
- }
672
-
673
- entry.visited = true;
674
- for ( let i = 0, il = entry.children.length; i < il; i ++ ) {
675
-
676
- const child = entry.children[ i ];
677
-
678
- // Cut off a loop if exists. (Is a grant loop invalid?)
679
- if ( ! child.visited ) traverse( child );
680
-
681
- }
682
-
683
- }
684
-
685
- traverse( rootEntry );
686
-
687
- }
688
-
689
- // morph
690
-
691
- function updateAttributes( attribute, morph, ratio ) {
692
-
693
- for ( let i = 0; i < morph.elementCount; i ++ ) {
694
-
695
- const element = morph.elements[ i ];
696
- let index;
697
- if ( data.metadata.format === 'pmd' ) {
698
-
699
- index = data.morphs[ 0 ].elements[ element.index ].index;
700
-
701
- } else {
702
-
703
- index = element.index;
704
-
705
- }
706
-
707
- attribute.array[ index * 3 + 0 ] += element.position[ 0 ] * ratio;
708
- attribute.array[ index * 3 + 1 ] += element.position[ 1 ] * ratio;
709
- attribute.array[ index * 3 + 2 ] += element.position[ 2 ] * ratio;
710
-
711
- }
712
-
713
- }
714
-
715
- for ( let i = 0; i < data.metadata.morphCount; i ++ ) {
716
-
717
- const morph = data.morphs[ i ];
718
- const params = {
719
- name: morph.name
720
- };
721
- const attribute = new THREE.Float32BufferAttribute( data.metadata.vertexCount * 3, 3 );
722
- attribute.name = morph.name;
723
- for ( let j = 0; j < data.metadata.vertexCount * 3; j ++ ) {
724
-
725
- attribute.array[ j ] = positions[ j ];
726
-
727
- }
728
-
729
- if ( data.metadata.format === 'pmd' ) {
730
-
731
- if ( i !== 0 ) {
732
-
733
- updateAttributes( attribute, morph, 1.0 );
734
-
735
- }
736
-
737
- } else {
738
-
739
- if ( morph.type === 0 ) {
740
-
741
- // group
742
-
743
- for ( let j = 0; j < morph.elementCount; j ++ ) {
744
-
745
- const morph2 = data.morphs[ morph.elements[ j ].index ];
746
- const ratio = morph.elements[ j ].ratio;
747
- if ( morph2.type === 1 ) {
748
-
749
- updateAttributes( attribute, morph2, ratio );
750
-
751
- } else {
752
-
753
- // TODO: implement
754
- }
755
-
756
- }
757
-
758
- } else if ( morph.type === 1 ) {
759
-
760
- // vertex
761
-
762
- updateAttributes( attribute, morph, 1.0 );
763
-
764
- } else if ( morph.type === 2 ) { // bone
765
-
766
- // TODO: implement
767
- } else if ( morph.type === 3 ) { // uv
768
-
769
- // TODO: implement
770
- } else if ( morph.type === 4 ) { // additional uv1
771
-
772
- // TODO: implement
773
- } else if ( morph.type === 5 ) { // additional uv2
774
-
775
- // TODO: implement
776
- } else if ( morph.type === 6 ) { // additional uv3
777
-
778
- // TODO: implement
779
- } else if ( morph.type === 7 ) { // additional uv4
780
-
781
- // TODO: implement
782
- } else if ( morph.type === 8 ) { // material
783
-
784
- // TODO: implement
785
- }
786
-
787
- }
788
-
789
- morphTargets.push( params );
790
- morphPositions.push( attribute );
791
-
792
- }
793
-
794
- // rigid bodies from rigidBodies field.
795
-
796
- for ( let i = 0; i < data.metadata.rigidBodyCount; i ++ ) {
797
-
798
- const rigidBody = data.rigidBodies[ i ];
799
- const params = {};
800
- for ( const key in rigidBody ) {
801
-
802
- params[ key ] = rigidBody[ key ];
803
-
804
- }
805
-
806
- /*
807
- * RigidBody position parameter in PMX seems global position
808
- * while the one in PMD seems offset from corresponding bone.
809
- * So unify being offset.
810
- */
811
- if ( data.metadata.format === 'pmx' ) {
812
-
813
- if ( params.boneIndex !== - 1 ) {
814
-
815
- const bone = data.bones[ params.boneIndex ];
816
- params.position[ 0 ] -= bone.position[ 0 ];
817
- params.position[ 1 ] -= bone.position[ 1 ];
818
- params.position[ 2 ] -= bone.position[ 2 ];
819
-
820
- }
821
-
822
- }
823
-
824
- rigidBodies.push( params );
825
-
826
- }
827
-
828
- // constraints from constraints field.
829
-
830
- for ( let i = 0; i < data.metadata.constraintCount; i ++ ) {
831
-
832
- const constraint = data.constraints[ i ];
833
- const params = {};
834
- for ( const key in constraint ) {
835
-
836
- params[ key ] = constraint[ key ];
837
-
838
- }
839
-
840
- const bodyA = rigidBodies[ params.rigidBodyIndex1 ];
841
- const bodyB = rigidBodies[ params.rigidBodyIndex2 ];
842
-
843
- // Refer to http://www20.atpages.jp/katwat/wp/?p=4135
844
- if ( bodyA.type !== 0 && bodyB.type === 2 ) {
845
-
846
- if ( bodyA.boneIndex !== - 1 && bodyB.boneIndex !== - 1 && data.bones[ bodyB.boneIndex ].parentIndex === bodyA.boneIndex ) {
847
-
848
- bodyB.type = 1;
849
-
850
- }
851
-
852
- }
853
-
854
- constraints.push( params );
855
-
856
- }
857
-
858
- // build THREE.BufferGeometry.
859
-
860
- const geometry = new THREE.BufferGeometry();
861
- geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( positions, 3 ) );
862
- geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
863
- geometry.setAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) );
864
- geometry.setAttribute( 'skinIndex', new THREE.Uint16BufferAttribute( skinIndices, 4 ) );
865
- geometry.setAttribute( 'skinWeight', new THREE.Float32BufferAttribute( skinWeights, 4 ) );
866
- geometry.setIndex( indices );
867
- for ( let i = 0, il = groups.length; i < il; i ++ ) {
868
-
869
- geometry.addGroup( groups[ i ].offset, groups[ i ].count, i );
870
-
871
- }
872
-
873
- geometry.bones = bones;
874
- geometry.morphTargets = morphTargets;
875
- geometry.morphAttributes.position = morphPositions;
876
- geometry.morphTargetsRelative = false;
877
- geometry.userData.MMD = {
878
- bones: bones,
879
- iks: iks,
880
- grants: grants,
881
- rigidBodies: rigidBodies,
882
- constraints: constraints,
883
- format: data.metadata.format
884
- };
885
- geometry.computeBoundingSphere();
886
- return geometry;
887
-
888
- }
889
-
890
- }
891
-
892
- //
893
-
894
- /**
895
- * @param {THREE.LoadingManager} manager
896
- */
897
- class MaterialBuilder {
898
-
899
- constructor( manager ) {
900
-
901
- this.manager = manager;
902
- this.textureLoader = new THREE.TextureLoader( this.manager );
903
- this.tgaLoader = null; // lazy generation
904
-
905
- this.crossOrigin = 'anonymous';
906
- this.resourcePath = undefined;
907
-
908
- }
909
-
910
- /**
911
- * @param {string} crossOrigin
912
- * @return {MaterialBuilder}
913
- */
914
- setCrossOrigin( crossOrigin ) {
915
-
916
- this.crossOrigin = crossOrigin;
917
- return this;
918
-
919
- }
920
-
921
- /**
922
- * @param {string} resourcePath
923
- * @return {MaterialBuilder}
924
- */
925
- setResourcePath( resourcePath ) {
926
-
927
- this.resourcePath = resourcePath;
928
- return this;
929
-
930
- }
931
-
932
- /**
933
- * @param {Object} data - parsed PMD/PMX data
934
- * @param {BufferGeometry} geometry - some properties are dependend on geometry
935
- * @param {function} onProgress
936
- * @param {function} onError
937
- * @return {Array<MMDToonMaterial>}
938
- */
939
- build( data, geometry /*, onProgress, onError */ ) {
940
-
941
- const materials = [];
942
- const textures = {};
943
- this.textureLoader.setCrossOrigin( this.crossOrigin );
944
-
945
- // materials
946
-
947
- for ( let i = 0; i < data.metadata.materialCount; i ++ ) {
948
-
949
- const material = data.materials[ i ];
950
- const params = {
951
- userData: {
952
- MMD: {}
953
- }
954
- };
955
- if ( material.name !== undefined ) params.name = material.name;
956
-
957
- /*
958
- * THREE.Color
959
- *
960
- * MMD MMDToonMaterial
961
- * ambient - emissive * a
962
- * (a = 1.0 without map texture or 0.2 with map texture)
963
- *
964
- * MMDToonMaterial doesn't have ambient. Set it to emissive instead.
965
- * It'll be too bright if material has map texture so using coef 0.2.
966
- */
967
- params.diffuse = new THREE.Color().fromArray( material.diffuse );
968
- params.opacity = material.diffuse[ 3 ];
969
- params.specular = new THREE.Color().fromArray( material.specular );
970
- params.shininess = material.shininess;
971
- params.emissive = new THREE.Color().fromArray( material.ambient );
972
- params.transparent = params.opacity !== 1.0;
973
-
974
- //
975
-
976
- params.fog = true;
977
-
978
- // blend
979
-
980
- params.blending = THREE.CustomBlending;
981
- params.blendSrc = THREE.SrcAlphaFactor;
982
- params.blendDst = THREE.OneMinusSrcAlphaFactor;
983
- params.blendSrcAlpha = THREE.SrcAlphaFactor;
984
- params.blendDstAlpha = THREE.DstAlphaFactor;
985
-
986
- // side
987
-
988
- if ( data.metadata.format === 'pmx' && ( material.flag & 0x1 ) === 1 ) {
989
-
990
- params.side = THREE.DoubleSide;
991
-
992
- } else {
993
-
994
- params.side = params.opacity === 1.0 ? THREE.FrontSide : THREE.DoubleSide;
995
-
996
- }
997
-
998
- if ( data.metadata.format === 'pmd' ) {
999
-
1000
- // map, envMap
1001
-
1002
- if ( material.fileName ) {
1003
-
1004
- const fileName = material.fileName;
1005
- const fileNames = fileName.split( '*' );
1006
-
1007
- // fileNames[ 0 ]: mapFileName
1008
- // fileNames[ 1 ]: envMapFileName( optional )
1009
-
1010
- params.map = this._loadTexture( fileNames[ 0 ], textures );
1011
- if ( fileNames.length > 1 ) {
1012
-
1013
- const extension = fileNames[ 1 ].slice( - 4 ).toLowerCase();
1014
- params.envMap = this._loadTexture( fileNames[ 1 ], textures );
1015
- params.combine = extension === '.sph' ? THREE.MultiplyOperation : THREE.AddOperation;
1016
-
1017
- }
1018
-
1019
- }
1020
-
1021
- // gradientMap
1022
-
1023
- const toonFileName = material.toonIndex === - 1 ? 'toon00.bmp' : data.toonTextures[ material.toonIndex ].fileName;
1024
- params.gradientMap = this._loadTexture( toonFileName, textures, {
1025
- isToonTexture: true,
1026
- isDefaultToonTexture: this._isDefaultToonTexture( toonFileName )
1027
- } );
1028
-
1029
- // parameters for OutlineEffect
1030
-
1031
- params.userData.outlineParameters = {
1032
- thickness: material.edgeFlag === 1 ? 0.003 : 0.0,
1033
- color: [ 0, 0, 0 ],
1034
- alpha: 1.0,
1035
- visible: material.edgeFlag === 1
1036
- };
1037
-
1038
- } else {
1039
-
1040
- // map
1041
-
1042
- if ( material.textureIndex !== - 1 ) {
1043
-
1044
- params.map = this._loadTexture( data.textures[ material.textureIndex ], textures );
1045
-
1046
- // Since PMX spec don't have standard to list map files except color map and env map,
1047
- // we need to save file name for further mapping, like matching normal map file names after model loaded.
1048
- // ref: https://gist.github.com/felixjones/f8a06bd48f9da9a4539f#texture
1049
- params.userData.MMD.mapFileName = data.textures[ material.textureIndex ];
1050
-
1051
- }
1052
-
1053
- // envMap TODO: support m.envFlag === 3
1054
-
1055
- if ( material.envTextureIndex !== - 1 && ( material.envFlag === 1 || material.envFlag == 2 ) ) {
1056
-
1057
- params.matcap = this._loadTexture( data.textures[ material.envTextureIndex ], textures );
1058
-
1059
- // Same as color map above, keep file name in userData for further usage.
1060
- params.userData.MMD.matcapFileName = data.textures[ material.envTextureIndex ];
1061
- params.matcapCombine = material.envFlag === 1 ? THREE.MultiplyOperation : THREE.AddOperation;
1062
-
1063
- }
1064
-
1065
- // gradientMap
1066
-
1067
- let toonFileName, isDefaultToon;
1068
- if ( material.toonIndex === - 1 || material.toonFlag !== 0 ) {
1069
-
1070
- toonFileName = 'toon' + ( '0' + ( material.toonIndex + 1 ) ).slice( - 2 ) + '.bmp';
1071
- isDefaultToon = true;
1072
-
1073
- } else {
1074
-
1075
- toonFileName = data.textures[ material.toonIndex ];
1076
- isDefaultToon = false;
1077
-
1078
- }
1079
-
1080
- params.gradientMap = this._loadTexture( toonFileName, textures, {
1081
- isToonTexture: true,
1082
- isDefaultToonTexture: isDefaultToon
1083
- } );
1084
-
1085
- // parameters for OutlineEffect
1086
- params.userData.outlineParameters = {
1087
- thickness: material.edgeSize / 300,
1088
- // TODO: better calculation?
1089
- color: material.edgeColor.slice( 0, 3 ),
1090
- alpha: material.edgeColor[ 3 ],
1091
- visible: ( material.flag & 0x10 ) !== 0 && material.edgeSize > 0.0
1092
- };
1093
-
1094
- }
1095
-
1096
- if ( params.map !== undefined ) {
1097
-
1098
- if ( ! params.transparent ) {
1099
-
1100
- this._checkImageTransparency( params.map, geometry, i );
1101
-
1102
- }
1103
-
1104
- params.emissive.multiplyScalar( 0.2 );
1105
-
1106
- }
1107
-
1108
- materials.push( new MMDToonMaterial( params ) );
1109
-
1110
- }
1111
-
1112
- if ( data.metadata.format === 'pmx' ) {
1113
-
1114
- // set transparent true if alpha morph is defined.
1115
-
1116
- function checkAlphaMorph( elements, materials ) {
1117
-
1118
- for ( let i = 0, il = elements.length; i < il; i ++ ) {
1119
-
1120
- const element = elements[ i ];
1121
- if ( element.index === - 1 ) continue;
1122
- const material = materials[ element.index ];
1123
- if ( material.opacity !== element.diffuse[ 3 ] ) {
1124
-
1125
- material.transparent = true;
1126
-
1127
- }
1128
-
1129
- }
1130
-
1131
- }
1132
-
1133
- for ( let i = 0, il = data.morphs.length; i < il; i ++ ) {
1134
-
1135
- const morph = data.morphs[ i ];
1136
- const elements = morph.elements;
1137
- if ( morph.type === 0 ) {
1138
-
1139
- for ( let j = 0, jl = elements.length; j < jl; j ++ ) {
1140
-
1141
- const morph2 = data.morphs[ elements[ j ].index ];
1142
- if ( morph2.type !== 8 ) continue;
1143
- checkAlphaMorph( morph2.elements, materials );
1144
-
1145
- }
1146
-
1147
- } else if ( morph.type === 8 ) {
1148
-
1149
- checkAlphaMorph( elements, materials );
1150
-
1151
- }
1152
-
1153
- }
1154
-
1155
- }
1156
-
1157
- return materials;
1158
-
1159
- }
1160
-
1161
- // private methods
1162
-
1163
- _getTGALoader() {
1164
-
1165
- if ( this.tgaLoader === null ) {
1166
-
1167
- if ( THREE.TGALoader === undefined ) {
1168
-
1169
- throw new Error( 'THREE.MMDLoader: Import THREE.TGALoader' );
1170
-
1171
- }
1172
-
1173
- this.tgaLoader = new THREE.TGALoader( this.manager );
1174
-
1175
- }
1176
-
1177
- return this.tgaLoader;
1178
-
1179
- }
1180
- _isDefaultToonTexture( name ) {
1181
-
1182
- if ( name.length !== 10 ) return false;
1183
- return /toon(10|0[0-9])\.bmp/.test( name );
1184
-
1185
- }
1186
- _loadTexture( filePath, textures, params, onProgress, onError ) {
1187
-
1188
- params = params || {};
1189
- const scope = this;
1190
- let fullPath;
1191
- if ( params.isDefaultToonTexture === true ) {
1192
-
1193
- let index;
1194
- try {
1195
-
1196
- index = parseInt( filePath.match( /toon([0-9]{2})\.bmp$/ )[ 1 ] );
1197
-
1198
- } catch ( e ) {
1199
-
1200
- console.warn( 'THREE.MMDLoader: ' + filePath + ' seems like a ' + 'not right default texture path. Using toon00.bmp instead.' );
1201
- index = 0;
1202
-
1203
- }
1204
-
1205
- fullPath = DEFAULT_TOON_TEXTURES[ index ];
1206
-
1207
- } else {
1208
-
1209
- fullPath = this.resourcePath + filePath;
1210
-
1211
- }
1212
-
1213
- if ( textures[ fullPath ] !== undefined ) return textures[ fullPath ];
1214
- let loader = this.manager.getHandler( fullPath );
1215
- if ( loader === null ) {
1216
-
1217
- loader = filePath.slice( - 4 ).toLowerCase() === '.tga' ? this._getTGALoader() : this.textureLoader;
1218
-
1219
- }
1220
-
1221
- const texture = loader.load( fullPath, function ( t ) {
1222
-
1223
- // MMD toon texture is Axis-Y oriented
1224
- // but Three.js gradient map is Axis-X oriented.
1225
- // So here replaces the toon texture image with the rotated one.
1226
- if ( params.isToonTexture === true ) {
1227
-
1228
- t.image = scope._getRotatedImage( t.image );
1229
- t.magFilter = THREE.NearestFilter;
1230
- t.minFilter = THREE.NearestFilter;
1231
-
1232
- }
1233
-
1234
- t.flipY = false;
1235
- t.wrapS = THREE.RepeatWrapping;
1236
- t.wrapT = THREE.RepeatWrapping;
1237
- for ( let i = 0; i < texture.readyCallbacks.length; i ++ ) {
1238
-
1239
- texture.readyCallbacks[ i ]( texture );
1240
-
1241
- }
1242
-
1243
- delete texture.readyCallbacks;
1244
-
1245
- }, onProgress, onError );
1246
- texture.readyCallbacks = [];
1247
- textures[ fullPath ] = texture;
1248
- return texture;
1249
-
1250
- }
1251
- _getRotatedImage( image ) {
1252
-
1253
- const canvas = document.createElement( 'canvas' );
1254
- const context = canvas.getContext( '2d' );
1255
- const width = image.width;
1256
- const height = image.height;
1257
- canvas.width = width;
1258
- canvas.height = height;
1259
- context.clearRect( 0, 0, width, height );
1260
- context.translate( width / 2.0, height / 2.0 );
1261
- context.rotate( 0.5 * Math.PI ); // 90.0 * Math.PI / 180.0
1262
- context.translate( - width / 2.0, - height / 2.0 );
1263
- context.drawImage( image, 0, 0 );
1264
- return context.getImageData( 0, 0, width, height );
1265
-
1266
- }
1267
-
1268
- // Check if the partial image area used by the texture is transparent.
1269
- _checkImageTransparency( map, geometry, groupIndex ) {
1270
-
1271
- map.readyCallbacks.push( function ( texture ) {
1272
-
1273
- // Is there any efficient ways?
1274
- function createImageData( image ) {
1275
-
1276
- const canvas = document.createElement( 'canvas' );
1277
- canvas.width = image.width;
1278
- canvas.height = image.height;
1279
- const context = canvas.getContext( '2d' );
1280
- context.drawImage( image, 0, 0 );
1281
- return context.getImageData( 0, 0, canvas.width, canvas.height );
1282
-
1283
- }
1284
-
1285
- function detectImageTransparency( image, uvs, indices ) {
1286
-
1287
- const width = image.width;
1288
- const height = image.height;
1289
- const data = image.data;
1290
- const threshold = 253;
1291
- if ( data.length / ( width * height ) !== 4 ) return false;
1292
- for ( let i = 0; i < indices.length; i += 3 ) {
1293
-
1294
- const centerUV = {
1295
- x: 0.0,
1296
- y: 0.0
1297
- };
1298
- for ( let j = 0; j < 3; j ++ ) {
1299
-
1300
- const index = indices[ i * 3 + j ];
1301
- const uv = {
1302
- x: uvs[ index * 2 + 0 ],
1303
- y: uvs[ index * 2 + 1 ]
1304
- };
1305
- if ( getAlphaByUv( image, uv ) < threshold ) return true;
1306
- centerUV.x += uv.x;
1307
- centerUV.y += uv.y;
1308
-
1309
- }
1310
-
1311
- centerUV.x /= 3;
1312
- centerUV.y /= 3;
1313
- if ( getAlphaByUv( image, centerUV ) < threshold ) return true;
1314
-
1315
- }
1316
-
1317
- return false;
1318
-
1319
- }
1320
-
1321
- /*
1322
- * This method expects
1323
- * texture.flipY = false
1324
- * texture.wrapS = THREE.RepeatWrapping
1325
- * texture.wrapT = THREE.RepeatWrapping
1326
- * TODO: more precise
1327
- */
1328
- function getAlphaByUv( image, uv ) {
1329
-
1330
- const width = image.width;
1331
- const height = image.height;
1332
- let x = Math.round( uv.x * width ) % width;
1333
- let y = Math.round( uv.y * height ) % height;
1334
- if ( x < 0 ) x += width;
1335
- if ( y < 0 ) y += height;
1336
- const index = y * width + x;
1337
- return image.data[ index * 4 + 3 ];
1338
-
1339
- }
1340
-
1341
- if ( texture.isCompressedTexture === true ) {
1342
-
1343
- if ( NON_ALPHA_CHANNEL_FORMATS.includes( texture.format ) ) {
1344
-
1345
- map.transparent = false;
1346
-
1347
- } else {
1348
-
1349
- // any other way to check transparency of CompressedTexture?
1350
- map.transparent = true;
1351
-
1352
- }
1353
-
1354
- return;
1355
-
1356
- }
1357
-
1358
- const imageData = texture.image.data !== undefined ? texture.image : createImageData( texture.image );
1359
- const group = geometry.groups[ groupIndex ];
1360
- if ( detectImageTransparency( imageData, geometry.attributes.uv.array, geometry.index.array.slice( group.start, group.start + group.count ) ) ) {
1361
-
1362
- map.transparent = true;
1363
-
1364
- }
1365
-
1366
- } );
1367
-
1368
- }
1369
-
1370
- }
1371
-
1372
- //
1373
-
1374
- class AnimationBuilder {
1375
-
1376
- /**
1377
- * @param {Object} vmd - parsed VMD data
1378
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
1379
- * @return {AnimationClip}
1380
- */
1381
- build( vmd, mesh ) {
1382
-
1383
- // combine skeletal and morph animations
1384
-
1385
- const tracks = this.buildSkeletalAnimation( vmd, mesh ).tracks;
1386
- const tracks2 = this.buildMorphAnimation( vmd, mesh ).tracks;
1387
- for ( let i = 0, il = tracks2.length; i < il; i ++ ) {
1388
-
1389
- tracks.push( tracks2[ i ] );
1390
-
1391
- }
1392
-
1393
- return new THREE.AnimationClip( '', - 1, tracks );
1394
-
1395
- }
1396
-
1397
- /**
1398
- * @param {Object} vmd - parsed VMD data
1399
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
1400
- * @return {AnimationClip}
1401
- */
1402
- buildSkeletalAnimation( vmd, mesh ) {
1403
-
1404
- function pushInterpolation( array, interpolation, index ) {
1405
-
1406
- array.push( interpolation[ index + 0 ] / 127 ); // x1
1407
- array.push( interpolation[ index + 8 ] / 127 ); // x2
1408
- array.push( interpolation[ index + 4 ] / 127 ); // y1
1409
- array.push( interpolation[ index + 12 ] / 127 ); // y2
1410
-
1411
- }
1412
-
1413
- const tracks = [];
1414
- const motions = {};
1415
- const bones = mesh.skeleton.bones;
1416
- const boneNameDictionary = {};
1417
- for ( let i = 0, il = bones.length; i < il; i ++ ) {
1418
-
1419
- boneNameDictionary[ bones[ i ].name ] = true;
1420
-
1421
- }
1422
-
1423
- for ( let i = 0; i < vmd.metadata.motionCount; i ++ ) {
1424
-
1425
- const motion = vmd.motions[ i ];
1426
- const boneName = motion.boneName;
1427
- if ( boneNameDictionary[ boneName ] === undefined ) continue;
1428
- motions[ boneName ] = motions[ boneName ] || [];
1429
- motions[ boneName ].push( motion );
1430
-
1431
- }
1432
-
1433
- for ( const key in motions ) {
1434
-
1435
- const array = motions[ key ];
1436
- array.sort( function ( a, b ) {
1437
-
1438
- return a.frameNum - b.frameNum;
1439
-
1440
- } );
1441
- const times = [];
1442
- const positions = [];
1443
- const rotations = [];
1444
- const pInterpolations = [];
1445
- const rInterpolations = [];
1446
- const basePosition = mesh.skeleton.getBoneByName( key ).position.toArray();
1447
- for ( let i = 0, il = array.length; i < il; i ++ ) {
1448
-
1449
- const time = array[ i ].frameNum / 30;
1450
- const position = array[ i ].position;
1451
- const rotation = array[ i ].rotation;
1452
- const interpolation = array[ i ].interpolation;
1453
- times.push( time );
1454
- for ( let j = 0; j < 3; j ++ ) positions.push( basePosition[ j ] + position[ j ] );
1455
- for ( let j = 0; j < 4; j ++ ) rotations.push( rotation[ j ] );
1456
- for ( let j = 0; j < 3; j ++ ) pushInterpolation( pInterpolations, interpolation, j );
1457
- pushInterpolation( rInterpolations, interpolation, 3 );
1458
-
1459
- }
1460
-
1461
- const targetName = '.bones[' + key + ']';
1462
- tracks.push( this._createTrack( targetName + '.position', THREE.VectorKeyframeTrack, times, positions, pInterpolations ) );
1463
- tracks.push( this._createTrack( targetName + '.quaternion', THREE.QuaternionKeyframeTrack, times, rotations, rInterpolations ) );
1464
-
1465
- }
1466
-
1467
- return new THREE.AnimationClip( '', - 1, tracks );
1468
-
1469
- }
1470
-
1471
- /**
1472
- * @param {Object} vmd - parsed VMD data
1473
- * @param {SkinnedMesh} mesh - tracks will be fitting to mesh
1474
- * @return {AnimationClip}
1475
- */
1476
- buildMorphAnimation( vmd, mesh ) {
1477
-
1478
- const tracks = [];
1479
- const morphs = {};
1480
- const morphTargetDictionary = mesh.morphTargetDictionary;
1481
- for ( let i = 0; i < vmd.metadata.morphCount; i ++ ) {
1482
-
1483
- const morph = vmd.morphs[ i ];
1484
- const morphName = morph.morphName;
1485
- if ( morphTargetDictionary[ morphName ] === undefined ) continue;
1486
- morphs[ morphName ] = morphs[ morphName ] || [];
1487
- morphs[ morphName ].push( morph );
1488
-
1489
- }
1490
-
1491
- for ( const key in morphs ) {
1492
-
1493
- const array = morphs[ key ];
1494
- array.sort( function ( a, b ) {
1495
-
1496
- return a.frameNum - b.frameNum;
1497
-
1498
- } );
1499
- const times = [];
1500
- const values = [];
1501
- for ( let i = 0, il = array.length; i < il; i ++ ) {
1502
-
1503
- times.push( array[ i ].frameNum / 30 );
1504
- values.push( array[ i ].weight );
1505
-
1506
- }
1507
-
1508
- tracks.push( new THREE.NumberKeyframeTrack( '.morphTargetInfluences[' + morphTargetDictionary[ key ] + ']', times, values ) );
1509
-
1510
- }
1511
-
1512
- return new THREE.AnimationClip( '', - 1, tracks );
1513
-
1514
- }
1515
-
1516
- /**
1517
- * @param {Object} vmd - parsed VMD data
1518
- * @return {AnimationClip}
1519
- */
1520
- buildCameraAnimation( vmd ) {
1521
-
1522
- function pushVector3( array, vec ) {
1523
-
1524
- array.push( vec.x );
1525
- array.push( vec.y );
1526
- array.push( vec.z );
1527
-
1528
- }
1529
-
1530
- function pushQuaternion( array, q ) {
1531
-
1532
- array.push( q.x );
1533
- array.push( q.y );
1534
- array.push( q.z );
1535
- array.push( q.w );
1536
-
1537
- }
1538
-
1539
- function pushInterpolation( array, interpolation, index ) {
1540
-
1541
- array.push( interpolation[ index * 4 + 0 ] / 127 ); // x1
1542
- array.push( interpolation[ index * 4 + 1 ] / 127 ); // x2
1543
- array.push( interpolation[ index * 4 + 2 ] / 127 ); // y1
1544
- array.push( interpolation[ index * 4 + 3 ] / 127 ); // y2
1545
-
1546
- }
1547
-
1548
- const cameras = vmd.cameras === undefined ? [] : vmd.cameras.slice();
1549
- cameras.sort( function ( a, b ) {
1550
-
1551
- return a.frameNum - b.frameNum;
1552
-
1553
- } );
1554
- const times = [];
1555
- const centers = [];
1556
- const quaternions = [];
1557
- const positions = [];
1558
- const fovs = [];
1559
- const cInterpolations = [];
1560
- const qInterpolations = [];
1561
- const pInterpolations = [];
1562
- const fInterpolations = [];
1563
- const quaternion = new THREE.Quaternion();
1564
- const euler = new THREE.Euler();
1565
- const position = new THREE.Vector3();
1566
- const center = new THREE.Vector3();
1567
- for ( let i = 0, il = cameras.length; i < il; i ++ ) {
1568
-
1569
- const motion = cameras[ i ];
1570
- const time = motion.frameNum / 30;
1571
- const pos = motion.position;
1572
- const rot = motion.rotation;
1573
- const distance = motion.distance;
1574
- const fov = motion.fov;
1575
- const interpolation = motion.interpolation;
1576
- times.push( time );
1577
- position.set( 0, 0, - distance );
1578
- center.set( pos[ 0 ], pos[ 1 ], pos[ 2 ] );
1579
- euler.set( - rot[ 0 ], - rot[ 1 ], - rot[ 2 ] );
1580
- quaternion.setFromEuler( euler );
1581
- position.add( center );
1582
- position.applyQuaternion( quaternion );
1583
- pushVector3( centers, center );
1584
- pushQuaternion( quaternions, quaternion );
1585
- pushVector3( positions, position );
1586
- fovs.push( fov );
1587
- for ( let j = 0; j < 3; j ++ ) {
1588
-
1589
- pushInterpolation( cInterpolations, interpolation, j );
1590
-
1591
- }
1592
-
1593
- pushInterpolation( qInterpolations, interpolation, 3 );
1594
-
1595
- // use the same parameter for x, y, z axis.
1596
- for ( let j = 0; j < 3; j ++ ) {
1597
-
1598
- pushInterpolation( pInterpolations, interpolation, 4 );
1599
-
1600
- }
1601
-
1602
- pushInterpolation( fInterpolations, interpolation, 5 );
1603
-
1604
- }
1605
-
1606
- const tracks = [];
1607
-
1608
- // I expect an object whose name 'target' exists under THREE.Camera
1609
- tracks.push( this._createTrack( 'target.position', THREE.VectorKeyframeTrack, times, centers, cInterpolations ) );
1610
- tracks.push( this._createTrack( '.quaternion', THREE.QuaternionKeyframeTrack, times, quaternions, qInterpolations ) );
1611
- tracks.push( this._createTrack( '.position', THREE.VectorKeyframeTrack, times, positions, pInterpolations ) );
1612
- tracks.push( this._createTrack( '.fov', THREE.NumberKeyframeTrack, times, fovs, fInterpolations ) );
1613
- return new THREE.AnimationClip( '', - 1, tracks );
1614
-
1615
- }
1616
-
1617
- // private method
1618
-
1619
- _createTrack( node, typedKeyframeTrack, times, values, interpolations ) {
1620
-
1621
- /*
1622
- * optimizes here not to let KeyframeTrackPrototype optimize
1623
- * because KeyframeTrackPrototype optimizes times and values but
1624
- * doesn't optimize interpolations.
1625
- */
1626
- if ( times.length > 2 ) {
1627
-
1628
- times = times.slice();
1629
- values = values.slice();
1630
- interpolations = interpolations.slice();
1631
- const stride = values.length / times.length;
1632
- const interpolateStride = interpolations.length / times.length;
1633
- let index = 1;
1634
- for ( let aheadIndex = 2, endIndex = times.length; aheadIndex < endIndex; aheadIndex ++ ) {
1635
-
1636
- for ( let i = 0; i < stride; i ++ ) {
1637
-
1638
- if ( values[ index * stride + i ] !== values[ ( index - 1 ) * stride + i ] || values[ index * stride + i ] !== values[ aheadIndex * stride + i ] ) {
1639
-
1640
- index ++;
1641
- break;
1642
-
1643
- }
1644
-
1645
- }
1646
-
1647
- if ( aheadIndex > index ) {
1648
-
1649
- times[ index ] = times[ aheadIndex ];
1650
- for ( let i = 0; i < stride; i ++ ) {
1651
-
1652
- values[ index * stride + i ] = values[ aheadIndex * stride + i ];
1653
-
1654
- }
1655
-
1656
- for ( let i = 0; i < interpolateStride; i ++ ) {
1657
-
1658
- interpolations[ index * interpolateStride + i ] = interpolations[ aheadIndex * interpolateStride + i ];
1659
-
1660
- }
1661
-
1662
- }
1663
-
1664
- }
1665
-
1666
- times.length = index + 1;
1667
- values.length = ( index + 1 ) * stride;
1668
- interpolations.length = ( index + 1 ) * interpolateStride;
1669
-
1670
- }
1671
-
1672
- const track = new typedKeyframeTrack( node, times, values );
1673
- track.createInterpolant = function InterpolantFactoryMethodCubicBezier( result ) {
1674
-
1675
- return new CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, new Float32Array( interpolations ) );
1676
-
1677
- };
1678
-
1679
- return track;
1680
-
1681
- }
1682
-
1683
- }
1684
-
1685
- // interpolation
1686
-
1687
- class CubicBezierInterpolation extends THREE.Interpolant {
1688
-
1689
- constructor( parameterPositions, sampleValues, sampleSize, resultBuffer, params ) {
1690
-
1691
- super( parameterPositions, sampleValues, sampleSize, resultBuffer );
1692
- this.interpolationParams = params;
1693
-
1694
- }
1695
- interpolate_( i1, t0, t, t1 ) {
1696
-
1697
- const result = this.resultBuffer;
1698
- const values = this.sampleValues;
1699
- const stride = this.valueSize;
1700
- const params = this.interpolationParams;
1701
- const offset1 = i1 * stride;
1702
- const offset0 = offset1 - stride;
1703
-
1704
- // No interpolation if next key frame is in one frame in 30fps.
1705
- // This is from MMD animation spec.
1706
- // '1.5' is for precision loss. times are Float32 in Three.js Animation system.
1707
- const weight1 = t1 - t0 < 1 / 30 * 1.5 ? 0.0 : ( t - t0 ) / ( t1 - t0 );
1708
- if ( stride === 4 ) {
1709
-
1710
- // THREE.Quaternion
1711
-
1712
- const x1 = params[ i1 * 4 + 0 ];
1713
- const x2 = params[ i1 * 4 + 1 ];
1714
- const y1 = params[ i1 * 4 + 2 ];
1715
- const y2 = params[ i1 * 4 + 3 ];
1716
- const ratio = this._calculate( x1, x2, y1, y2, weight1 );
1717
- THREE.Quaternion.slerpFlat( result, 0, values, offset0, values, offset1, ratio );
1718
-
1719
- } else if ( stride === 3 ) {
1720
-
1721
- // THREE.Vector3
1722
-
1723
- for ( let i = 0; i !== stride; ++ i ) {
1724
-
1725
- const x1 = params[ i1 * 12 + i * 4 + 0 ];
1726
- const x2 = params[ i1 * 12 + i * 4 + 1 ];
1727
- const y1 = params[ i1 * 12 + i * 4 + 2 ];
1728
- const y2 = params[ i1 * 12 + i * 4 + 3 ];
1729
- const ratio = this._calculate( x1, x2, y1, y2, weight1 );
1730
- result[ i ] = values[ offset0 + i ] * ( 1 - ratio ) + values[ offset1 + i ] * ratio;
1731
-
1732
- }
1733
-
1734
- } else {
1735
-
1736
- // Number
1737
-
1738
- const x1 = params[ i1 * 4 + 0 ];
1739
- const x2 = params[ i1 * 4 + 1 ];
1740
- const y1 = params[ i1 * 4 + 2 ];
1741
- const y2 = params[ i1 * 4 + 3 ];
1742
- const ratio = this._calculate( x1, x2, y1, y2, weight1 );
1743
- result[ 0 ] = values[ offset0 ] * ( 1 - ratio ) + values[ offset1 ] * ratio;
1744
-
1745
- }
1746
-
1747
- return result;
1748
-
1749
- }
1750
- _calculate( x1, x2, y1, y2, x ) {
1751
-
1752
- /*
1753
- * Cubic Bezier curves
1754
- * https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves
1755
- *
1756
- * B(t) = ( 1 - t ) ^ 3 * P0
1757
- * + 3 * ( 1 - t ) ^ 2 * t * P1
1758
- * + 3 * ( 1 - t ) * t^2 * P2
1759
- * + t ^ 3 * P3
1760
- * ( 0 <= t <= 1 )
1761
- *
1762
- * MMD uses Cubic Bezier curves for bone and camera animation interpolation.
1763
- * http://d.hatena.ne.jp/edvakf/20111016/1318716097
1764
- *
1765
- * x = ( 1 - t ) ^ 3 * x0
1766
- * + 3 * ( 1 - t ) ^ 2 * t * x1
1767
- * + 3 * ( 1 - t ) * t^2 * x2
1768
- * + t ^ 3 * x3
1769
- * y = ( 1 - t ) ^ 3 * y0
1770
- * + 3 * ( 1 - t ) ^ 2 * t * y1
1771
- * + 3 * ( 1 - t ) * t^2 * y2
1772
- * + t ^ 3 * y3
1773
- * ( x0 = 0, y0 = 0 )
1774
- * ( x3 = 1, y3 = 1 )
1775
- * ( 0 <= t, x1, x2, y1, y2 <= 1 )
1776
- *
1777
- * Here solves this equation with Bisection method,
1778
- * https://en.wikipedia.org/wiki/Bisection_method
1779
- * gets t, and then calculate y.
1780
- *
1781
- * f(t) = 3 * ( 1 - t ) ^ 2 * t * x1
1782
- * + 3 * ( 1 - t ) * t^2 * x2
1783
- * + t ^ 3 - x = 0
1784
- *
1785
- * (Another option: Newton's method
1786
- * https://en.wikipedia.org/wiki/Newton%27s_method)
1787
- */
1788
-
1789
- let c = 0.5;
1790
- let t = c;
1791
- let s = 1.0 - t;
1792
- const loop = 15;
1793
- const eps = 1e-5;
1794
- const math = Math;
1795
- let sst3, stt3, ttt;
1796
- for ( let i = 0; i < loop; i ++ ) {
1797
-
1798
- sst3 = 3.0 * s * s * t;
1799
- stt3 = 3.0 * s * t * t;
1800
- ttt = t * t * t;
1801
- const ft = sst3 * x1 + stt3 * x2 + ttt - x;
1802
- if ( math.abs( ft ) < eps ) break;
1803
- c /= 2.0;
1804
- t += ft < 0 ? c : - c;
1805
- s = 1.0 - t;
1806
-
1807
- }
1808
-
1809
- return sst3 * y1 + stt3 * y2 + ttt;
1810
-
1811
- }
1812
-
1813
- }
1814
- class MMDToonMaterial extends THREE.ShaderMaterial {
1815
-
1816
- constructor( parameters ) {
1817
-
1818
- super();
1819
- this.isMMDToonMaterial = true;
1820
- this._matcapCombine = THREE.AddOperation;
1821
- this.emissiveIntensity = 1.0;
1822
- this.normalMapType = THREE.TangentSpaceNormalMap;
1823
- this.combine = THREE.MultiplyOperation;
1824
- this.wireframeLinecap = 'round';
1825
- this.wireframeLinejoin = 'round';
1826
- this.flatShading = false;
1827
- this.lights = true;
1828
- this.vertexShader = THREE.MMDToonShader.vertexShader;
1829
- this.fragmentShader = THREE.MMDToonShader.fragmentShader;
1830
- this.defines = Object.assign( {}, THREE.MMDToonShader.defines );
1831
- Object.defineProperty( this, 'matcapCombine', {
1832
- get: function () {
1833
-
1834
- return this._matcapCombine;
1835
-
1836
- },
1837
- set: function ( value ) {
1838
-
1839
- this._matcapCombine = value;
1840
- switch ( value ) {
1841
-
1842
- case THREE.MultiplyOperation:
1843
- this.defines.MATCAP_BLENDING_MULTIPLY = true;
1844
- delete this.defines.MATCAP_BLENDING_ADD;
1845
- break;
1846
- default:
1847
- case THREE.AddOperation:
1848
- this.defines.MATCAP_BLENDING_ADD = true;
1849
- delete this.defines.MATCAP_BLENDING_MULTIPLY;
1850
- break;
1851
-
1852
- }
1853
-
1854
- }
1855
- } );
1856
- this.uniforms = THREE.UniformsUtils.clone( THREE.MMDToonShader.uniforms );
1857
-
1858
- // merged from MeshToon/Phong/MatcapMaterial
1859
- const exposePropertyNames = [ 'specular', 'opacity', 'diffuse', 'map', 'matcap', 'gradientMap', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalScale', 'displacemantBias', 'displacemantMap', 'displacemantScale', 'specularMap', 'alphaMap', 'envMap', 'reflectivity', 'refractionRatio' ];
1860
- for ( const propertyName of exposePropertyNames ) {
1861
-
1862
- Object.defineProperty( this, propertyName, {
1863
- get: function () {
1864
-
1865
- return this.uniforms[ propertyName ].value;
1866
-
1867
- },
1868
- set: function ( value ) {
1869
-
1870
- this.uniforms[ propertyName ].value = value;
1871
-
1872
- }
1873
- } );
1874
-
1875
- }
1876
-
1877
- // Special path for shininess to handle zero shininess properly
1878
- this._shininess = 30;
1879
- Object.defineProperty( this, 'shininess', {
1880
- get: function () {
1881
-
1882
- return this._shininess;
1883
-
1884
- },
1885
- set: function ( value ) {
1886
-
1887
- this._shininess = value;
1888
- this.uniforms.shininess.value = Math.max( this._shininess, 1e-4 ); // To prevent pow( 0.0, 0.0 )
1889
-
1890
- }
1891
- } );
1892
-
1893
- Object.defineProperty( this, 'color', Object.getOwnPropertyDescriptor( this, 'diffuse' ) );
1894
- this.setValues( parameters );
1895
-
1896
- }
1897
- copy( source ) {
1898
-
1899
- super.copy( source );
1900
- this.matcapCombine = source.matcapCombine;
1901
- this.emissiveIntensity = source.emissiveIntensity;
1902
- this.normalMapType = source.normalMapType;
1903
- this.combine = source.combine;
1904
- this.wireframeLinecap = source.wireframeLinecap;
1905
- this.wireframeLinejoin = source.wireframeLinejoin;
1906
- this.flatShading = source.flatShading;
1907
- return this;
1908
-
1909
- }
1910
-
1911
- }
1912
-
1913
- THREE.MMDLoader = MMDLoader;
1914
-
1915
- } )();