opal-js_wrap-three 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +4 -4
- data/lib/opal/js_wrap/three/version.rb +1 -1
- data/lib-opal/js_wrap/three/WebGL.js +102 -0
- data/lib-opal/js_wrap/three/animation/AnimationClipCreator.js +116 -0
- data/lib-opal/js_wrap/three/animation/CCDIKSolver.js +436 -0
- data/lib-opal/js_wrap/three/animation/MMDAnimationHelper.js +941 -0
- data/lib-opal/js_wrap/three/animation/MMDPhysics.js +1183 -0
- data/lib-opal/js_wrap/three/cameras/CinematicCamera.js +204 -0
- data/lib-opal/js_wrap/three/controls/ArcballControls.js +2649 -0
- data/lib-opal/js_wrap/three/controls/DragControls.js +234 -0
- data/lib-opal/js_wrap/three/controls/FirstPersonControls.js +301 -0
- data/lib-opal/js_wrap/three/controls/FlyControls.js +357 -0
- data/lib-opal/js_wrap/three/controls/OrbitControls.js +908 -0
- data/lib-opal/js_wrap/three/controls/PointerLockControls.js +173 -0
- data/lib-opal/js_wrap/three/controls/TrackballControls.js +666 -0
- data/lib-opal/js_wrap/three/controls/TransformControls.js +1210 -0
- data/lib-opal/js_wrap/three/controls/experimental/CameraControls.js +860 -0
- data/lib-opal/js_wrap/three/csm/CSM.js +346 -0
- data/lib-opal/js_wrap/three/csm/CSMFrustum.js +123 -0
- data/lib-opal/js_wrap/three/csm/CSMHelper.js +197 -0
- data/lib-opal/js_wrap/three/csm/CSMShader.js +29 -0
- data/lib-opal/js_wrap/three/curves/CurveExtras.js +544 -0
- data/lib-opal/js_wrap/three/curves/NURBSCurve.js +122 -0
- data/lib-opal/js_wrap/three/curves/NURBSSurface.js +78 -0
- data/lib-opal/js_wrap/three/curves/NURBSUtils.js +413 -0
- data/lib-opal/js_wrap/three/deprecated/Geometry.js +1373 -0
- data/lib-opal/js_wrap/three/effects/AnaglyphEffect.js +113 -0
- data/lib-opal/js_wrap/three/effects/AsciiEffect.js +267 -0
- data/lib-opal/js_wrap/three/effects/OutlineEffect.js +400 -0
- data/lib-opal/js_wrap/three/effects/ParallaxBarrierEffect.js +90 -0
- data/lib-opal/js_wrap/three/effects/PeppersGhostEffect.js +160 -0
- data/lib-opal/js_wrap/three/effects/StereoEffect.js +63 -0
- data/lib-opal/js_wrap/three/environments/DebugEnvironment.js +107 -0
- data/lib-opal/js_wrap/three/environments/RoomEnvironment.js +166 -0
- data/lib-opal/js_wrap/three/exporters/ColladaExporter.js +442 -0
- data/lib-opal/js_wrap/three/exporters/DRACOExporter.js +205 -0
- data/lib-opal/js_wrap/three/exporters/GLTFExporter.js +2042 -0
- data/lib-opal/js_wrap/three/exporters/MMDExporter.js +189 -0
- data/lib-opal/js_wrap/three/exporters/OBJExporter.js +241 -0
- data/lib-opal/js_wrap/three/exporters/PLYExporter.js +370 -0
- data/lib-opal/js_wrap/three/exporters/STLExporter.js +186 -0
- data/lib-opal/js_wrap/three/exporters/USDZExporter.js +402 -0
- data/lib-opal/js_wrap/three/geometries/BoxLineGeometry.js +106 -0
- data/lib-opal/js_wrap/three/geometries/ConvexGeometry.js +88 -0
- data/lib-opal/js_wrap/three/geometries/DecalGeometry.js +302 -0
- data/lib-opal/js_wrap/three/geometries/LightningStrike.js +817 -0
- data/lib-opal/js_wrap/three/geometries/ParametricGeometries.js +280 -0
- data/lib-opal/js_wrap/three/geometries/ParametricGeometry.js +146 -0
- data/lib-opal/js_wrap/three/geometries/RoundedBoxGeometry.js +183 -0
- data/lib-opal/js_wrap/three/geometries/TeapotGeometry.js +352 -0
- data/lib-opal/js_wrap/three/geometries/TextGeometry.js +76 -0
- data/lib-opal/js_wrap/three/helpers/LightProbeHelper.js +95 -0
- data/lib-opal/js_wrap/three/helpers/PositionalAudioHelper.js +138 -0
- data/lib-opal/js_wrap/three/helpers/RectAreaLightHelper.js +115 -0
- data/lib-opal/js_wrap/three/helpers/VertexNormalsHelper.js +131 -0
- data/lib-opal/js_wrap/three/helpers/VertexTangentsHelper.js +118 -0
- data/lib-opal/js_wrap/three/interactive/HTMLMesh.js +307 -0
- data/lib-opal/js_wrap/three/interactive/InteractiveGroup.js +138 -0
- data/lib-opal/js_wrap/three/interactive/SelectionBox.js +264 -0
- data/lib-opal/js_wrap/three/interactive/SelectionHelper.js +88 -0
- data/lib-opal/js_wrap/three/libs/OimoPhysics/OimoPhysics.js +46059 -0
- data/lib-opal/js_wrap/three/libs/OimoPhysics/index.js +92 -0
- data/lib-opal/js_wrap/three/libs/chevrotain.module.min.js +6947 -0
- data/lib-opal/js_wrap/three/libs/ecsy.module.js +1999 -0
- data/lib-opal/js_wrap/three/libs/fflate.module.js +3002 -0
- data/lib-opal/js_wrap/three/libs/flow.module.js +3033 -0
- data/lib-opal/js_wrap/three/libs/ktx-parse.module.js +392 -0
- data/lib-opal/js_wrap/three/libs/lil-gui.module.min.js +821 -0
- data/lib-opal/js_wrap/three/libs/meshopt_decoder.module.js +136 -0
- data/lib-opal/js_wrap/three/libs/mmdparser.module.js +11022 -0
- data/lib-opal/js_wrap/three/libs/motion-controllers.module.js +589 -0
- data/lib-opal/js_wrap/three/libs/opentype.module.min.js +6132 -0
- data/lib-opal/js_wrap/three/libs/potpack.module.js +171 -0
- data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.js +6781 -0
- data/lib-opal/js_wrap/three/libs/rhino3dm/rhino3dm.module.js +6783 -0
- data/lib-opal/js_wrap/three/libs/stats.module.js +139 -0
- data/lib-opal/js_wrap/three/libs/tween.module.min.js +349 -0
- data/lib-opal/js_wrap/three/lights/LightProbeGenerator.js +233 -0
- data/lib-opal/js_wrap/three/lights/RectAreaLightUniformsLib.js +75 -0
- data/lib-opal/js_wrap/three/lines/Line2.js +66 -0
- data/lib-opal/js_wrap/three/lines/LineGeometry.js +122 -0
- data/lib-opal/js_wrap/three/lines/LineMaterial.js +227 -0
- data/lib-opal/js_wrap/three/lines/LineSegments2.js +312 -0
- data/lib-opal/js_wrap/three/lines/LineSegmentsGeometry.js +238 -0
- data/lib-opal/js_wrap/three/lines/Wireframe.js +98 -0
- data/lib-opal/js_wrap/three/lines/WireframeGeometry2.js +65 -0
- data/lib-opal/js_wrap/three/loaders/3DMLoader.js +1230 -0
- data/lib-opal/js_wrap/three/loaders/3MFLoader.js +1123 -0
- data/lib-opal/js_wrap/three/loaders/AMFLoader.js +445 -0
- data/lib-opal/js_wrap/three/loaders/BVHLoader.js +365 -0
- data/lib-opal/js_wrap/three/loaders/BasisTextureLoader.js +692 -0
- data/lib-opal/js_wrap/three/loaders/ColladaLoader.js +3046 -0
- data/lib-opal/js_wrap/three/loaders/DDSLoader.js +264 -0
- data/lib-opal/js_wrap/three/loaders/DRACOLoader.js +531 -0
- data/lib-opal/js_wrap/three/loaders/EXRLoader.js +1834 -0
- data/lib-opal/js_wrap/three/loaders/FBXLoader.js +3125 -0
- data/lib-opal/js_wrap/three/loaders/FontLoader.js +201 -0
- data/lib-opal/js_wrap/three/loaders/GCodeLoader.js +248 -0
- data/lib-opal/js_wrap/three/loaders/GLTFLoader.js +3334 -0
- data/lib-opal/js_wrap/three/loaders/HDRCubeTextureLoader.js +144 -0
- data/lib-opal/js_wrap/three/loaders/IFCLoader.js +2395 -0
- data/lib-opal/js_wrap/three/loaders/KMZLoader.js +142 -0
- data/lib-opal/js_wrap/three/loaders/KTX2Loader.js +535 -0
- data/lib-opal/js_wrap/three/loaders/KTXLoader.js +202 -0
- data/lib-opal/js_wrap/three/loaders/LDrawLoader.js +1737 -0
- data/lib-opal/js_wrap/three/loaders/LUT3dlLoader.js +163 -0
- data/lib-opal/js_wrap/three/loaders/LUTCubeLoader.js +171 -0
- data/lib-opal/js_wrap/three/loaders/LWOLoader.js +831 -0
- data/lib-opal/js_wrap/three/loaders/LogLuvLoader.js +713 -0
- data/lib-opal/js_wrap/three/loaders/LottieLoader.js +103 -0
- data/lib-opal/js_wrap/three/loaders/MD2Loader.js +258 -0
- data/lib-opal/js_wrap/three/loaders/MDDLoader.js +116 -0
- data/lib-opal/js_wrap/three/loaders/MMDLoader.js +1687 -0
- data/lib-opal/js_wrap/three/loaders/MTLLoader.js +465 -0
- data/lib-opal/js_wrap/three/loaders/NRRDLoader.js +554 -0
- data/lib-opal/js_wrap/three/loaders/NodeMaterialLoader.js +248 -0
- data/lib-opal/js_wrap/three/loaders/OBJLoader.js +673 -0
- data/lib-opal/js_wrap/three/loaders/PCDLoader.js +322 -0
- data/lib-opal/js_wrap/three/loaders/PDBLoader.js +318 -0
- data/lib-opal/js_wrap/three/loaders/PLYLoader.js +489 -0
- data/lib-opal/js_wrap/three/loaders/PRWMLoader.js +247 -0
- data/lib-opal/js_wrap/three/loaders/PVRLoader.js +240 -0
- data/lib-opal/js_wrap/three/loaders/RGBELoader.js +462 -0
- data/lib-opal/js_wrap/three/loaders/RGBMLoader.js +1169 -0
- data/lib-opal/js_wrap/three/loaders/STLLoader.js +345 -0
- data/lib-opal/js_wrap/three/loaders/SVGLoader.js +2162 -0
- data/lib-opal/js_wrap/three/loaders/TDSLoader.js +982 -0
- data/lib-opal/js_wrap/three/loaders/TGALoader.js +444 -0
- data/lib-opal/js_wrap/three/loaders/TTFLoader.js +210 -0
- data/lib-opal/js_wrap/three/loaders/TiltLoader.js +391 -0
- data/lib-opal/js_wrap/three/loaders/VOXLoader.js +272 -0
- data/lib-opal/js_wrap/three/loaders/VRMLLoader.js +2685 -0
- data/lib-opal/js_wrap/three/loaders/VRMLoader.js +103 -0
- data/lib-opal/js_wrap/three/loaders/VTKLoader.js +894 -0
- data/lib-opal/js_wrap/three/loaders/XYZLoader.js +136 -0
- data/lib-opal/js_wrap/three/loaders/ifc/web-ifc-api.js +60504 -0
- data/lib-opal/js_wrap/three/loaders/lwo/IFFParser.js +931 -0
- data/lib-opal/js_wrap/three/loaders/lwo/LWO2Parser.js +450 -0
- data/lib-opal/js_wrap/three/loaders/lwo/LWO3Parser.js +406 -0
- data/lib-opal/js_wrap/three/math/Capsule.js +133 -0
- data/lib-opal/js_wrap/three/math/ColorConverter.js +104 -0
- data/lib-opal/js_wrap/three/math/ConvexHull.js +924 -0
- data/lib-opal/js_wrap/three/math/ImprovedNoise.js +86 -0
- data/lib-opal/js_wrap/three/math/Lut.js +170 -0
- data/lib-opal/js_wrap/three/math/MeshSurfaceSampler.js +187 -0
- data/lib-opal/js_wrap/three/math/OBB.js +345 -0
- data/lib-opal/js_wrap/three/math/Octree.js +409 -0
- data/lib-opal/js_wrap/three/math/SimplexNoise.js +425 -0
- data/lib-opal/js_wrap/three/misc/ConvexObjectBreaker.js +447 -0
- data/lib-opal/js_wrap/three/misc/GPUComputationRenderer.js +322 -0
- data/lib-opal/js_wrap/three/misc/Gyroscope.js +94 -0
- data/lib-opal/js_wrap/three/misc/MD2Character.js +225 -0
- data/lib-opal/js_wrap/three/misc/MD2CharacterComplex.js +424 -0
- data/lib-opal/js_wrap/three/misc/MorphAnimMesh.js +109 -0
- data/lib-opal/js_wrap/three/misc/MorphBlendMesh.js +283 -0
- data/lib-opal/js_wrap/three/misc/ProgressiveLightMap.js +324 -0
- data/lib-opal/js_wrap/three/misc/RollerCoaster.js +489 -0
- data/lib-opal/js_wrap/three/misc/TubePainter.js +158 -0
- data/lib-opal/js_wrap/three/misc/Volume.js +427 -0
- data/lib-opal/js_wrap/three/misc/VolumeSlice.js +210 -0
- data/lib-opal/js_wrap/three/modifiers/CurveModifier.js +291 -0
- data/lib-opal/js_wrap/three/modifiers/EdgeSplitModifier.js +308 -0
- data/lib-opal/js_wrap/three/modifiers/SimplifyModifier.js +435 -0
- data/lib-opal/js_wrap/three/modifiers/TessellateModifier.js +264 -0
- data/lib-opal/js_wrap/three/node-editor/NodeEditor.js +402 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/NormalEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/PositionEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/accessors/UVEditor.js +71 -0
- data/lib-opal/js_wrap/three/node-editor/display/BlendEditor.js +78 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/ColorEditor.js +111 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/FloatEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/SliderEditor.js +97 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector2Editor.js +73 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector3Editor.js +75 -0
- data/lib-opal/js_wrap/three/node-editor/inputs/Vector4Editor.js +77 -0
- data/lib-opal/js_wrap/three/node-editor/materials/StandardMaterialEditor.js +121 -0
- data/lib-opal/js_wrap/three/node-editor/math/DotEditor.js +76 -0
- data/lib-opal/js_wrap/three/node-editor/math/InvertEditor.js +80 -0
- data/lib-opal/js_wrap/three/node-editor/math/LimiterEditor.js +85 -0
- data/lib-opal/js_wrap/three/node-editor/math/NormalizeEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/math/OperatorEditor.js +91 -0
- data/lib-opal/js_wrap/three/node-editor/math/PowerEditor.js +73 -0
- data/lib-opal/js_wrap/three/node-editor/math/TrigonometryEditor.js +83 -0
- data/lib-opal/js_wrap/three/node-editor/procedural/CheckerEditor.js +69 -0
- data/lib-opal/js_wrap/three/node-editor/utils/OscillatorEditor.js +87 -0
- data/lib-opal/js_wrap/three/node-editor/utils/TimerEditor.js +89 -0
- data/lib-opal/js_wrap/three/nodes/Nodes.js +481 -0
- data/lib-opal/js_wrap/three/nodes/accessors/CameraNode.js +222 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ColorsNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/accessors/LightNode.js +100 -0
- data/lib-opal/js_wrap/three/nodes/accessors/NormalNode.js +152 -0
- data/lib-opal/js_wrap/three/nodes/accessors/PositionNode.js +163 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ReflectNode.js +161 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ResolutionNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/accessors/ScreenUVNode.js +101 -0
- data/lib-opal/js_wrap/three/nodes/accessors/UVNode.js +105 -0
- data/lib-opal/js_wrap/three/nodes/core/AttributeNode.js +106 -0
- data/lib-opal/js_wrap/three/nodes/core/ConstNode.js +149 -0
- data/lib-opal/js_wrap/three/nodes/core/ExpressionNode.js +57 -0
- data/lib-opal/js_wrap/three/nodes/core/FunctionCallNode.js +138 -0
- data/lib-opal/js_wrap/three/nodes/core/FunctionNode.js +259 -0
- data/lib-opal/js_wrap/three/nodes/core/InputNode.js +124 -0
- data/lib-opal/js_wrap/three/nodes/core/Node.js +193 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeBuilder.js +782 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeFrame.js +69 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeLib.js +56 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeUniform.js +53 -0
- data/lib-opal/js_wrap/three/nodes/core/NodeUtils.js +60 -0
- data/lib-opal/js_wrap/three/nodes/core/StructNode.js +131 -0
- data/lib-opal/js_wrap/three/nodes/core/TempNode.js +160 -0
- data/lib-opal/js_wrap/three/nodes/core/VarNode.js +105 -0
- data/lib-opal/js_wrap/three/nodes/effects/BlurNode.js +160 -0
- data/lib-opal/js_wrap/three/nodes/effects/ColorAdjustmentNode.js +139 -0
- data/lib-opal/js_wrap/three/nodes/effects/LuminanceNode.js +106 -0
- data/lib-opal/js_wrap/three/nodes/inputs/BoolNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ColorNode.js +99 -0
- data/lib-opal/js_wrap/three/nodes/inputs/CubeTextureNode.js +136 -0
- data/lib-opal/js_wrap/three/nodes/inputs/FloatNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/IntNode.js +95 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Matrix3Node.js +102 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Matrix4Node.js +102 -0
- data/lib-opal/js_wrap/three/nodes/inputs/PropertyNode.js +85 -0
- data/lib-opal/js_wrap/three/nodes/inputs/RTTNode.js +164 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ReflectorNode.js +111 -0
- data/lib-opal/js_wrap/three/nodes/inputs/ScreenNode.js +69 -0
- data/lib-opal/js_wrap/three/nodes/inputs/TextureNode.js +140 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector2Node.js +98 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector3Node.js +99 -0
- data/lib-opal/js_wrap/three/nodes/inputs/Vector4Node.js +100 -0
- data/lib-opal/js_wrap/three/nodes/materials/BasicNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/MeshStandardNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/NodeMaterial.js +202 -0
- data/lib-opal/js_wrap/three/nodes/materials/PhongNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/SpriteNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/StandardNodeMaterial.js +63 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/BasicNode.js +146 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/MeshStandardNode.js +133 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/PhongNode.js +273 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/RawNode.js +101 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/SpriteNode.js +176 -0
- data/lib-opal/js_wrap/three/nodes/materials/nodes/StandardNode.js +397 -0
- data/lib-opal/js_wrap/three/nodes/math/CondNode.js +151 -0
- data/lib-opal/js_wrap/three/nodes/math/MathNode.js +266 -0
- data/lib-opal/js_wrap/three/nodes/math/OperatorNode.js +120 -0
- data/lib-opal/js_wrap/three/nodes/misc/BumpMapNode.js +139 -0
- data/lib-opal/js_wrap/three/nodes/misc/NormalMapNode.js +122 -0
- data/lib-opal/js_wrap/three/nodes/misc/TextureCubeNode.js +107 -0
- data/lib-opal/js_wrap/three/nodes/misc/TextureCubeUVNode.js +191 -0
- data/lib-opal/js_wrap/three/nodes/postprocessing/NodePass.js +117 -0
- data/lib-opal/js_wrap/three/nodes/postprocessing/NodePostProcessing.js +128 -0
- data/lib-opal/js_wrap/three/nodes/procedural/CheckerNode.js +104 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Fractal3DNode.js +121 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Noise2DNode.js +115 -0
- data/lib-opal/js_wrap/three/nodes/procedural/Noise3DNode.js +112 -0
- data/lib-opal/js_wrap/three/nodes/utils/BypassNode.js +115 -0
- data/lib-opal/js_wrap/three/nodes/utils/ColorSpaceNode.js +214 -0
- data/lib-opal/js_wrap/three/nodes/utils/JoinNode.js +138 -0
- data/lib-opal/js_wrap/three/nodes/utils/MaxMIPLevelNode.js +88 -0
- data/lib-opal/js_wrap/three/nodes/utils/RemapNode.js +117 -0
- data/lib-opal/js_wrap/three/nodes/utils/SpecularMIPLevelNode.js +121 -0
- data/lib-opal/js_wrap/three/nodes/utils/SubSlotNode.js +112 -0
- data/lib-opal/js_wrap/three/nodes/utils/SwitchNode.js +129 -0
- data/lib-opal/js_wrap/three/nodes/utils/TimerNode.js +126 -0
- data/lib-opal/js_wrap/three/nodes/utils/UVTransformNode.js +104 -0
- data/lib-opal/js_wrap/three/nodes/utils/VelocityNode.js +181 -0
- data/lib-opal/js_wrap/three/objects/Lensflare.js +285 -0
- data/lib-opal/js_wrap/three/objects/LightningStorm.js +238 -0
- data/lib-opal/js_wrap/three/objects/MarchingCubes.js +667 -0
- data/lib-opal/js_wrap/three/objects/Reflector.js +205 -0
- data/lib-opal/js_wrap/three/objects/ReflectorForSSRPass.js +288 -0
- data/lib-opal/js_wrap/three/objects/ReflectorRTT.js +63 -0
- data/lib-opal/js_wrap/three/objects/Refractor.js +243 -0
- data/lib-opal/js_wrap/three/objects/ShadowMesh.js +100 -0
- data/lib-opal/js_wrap/three/objects/Sky.js +107 -0
- data/lib-opal/js_wrap/three/objects/Water.js +246 -0
- data/lib-opal/js_wrap/three/objects/Water2.js +238 -0
- data/lib-opal/js_wrap/three/offscreen/jank.js +51 -0
- data/lib-opal/js_wrap/three/offscreen/offscreen.js +24 -0
- data/lib-opal/js_wrap/three/offscreen/scene.js +99 -0
- data/lib-opal/js_wrap/three/physics/AmmoPhysics.js +266 -0
- data/lib-opal/js_wrap/three/physics/OimoPhysics.js +214 -0
- data/lib-opal/js_wrap/three/postprocessing/AdaptiveToneMappingPass.js +307 -0
- data/lib-opal/js_wrap/three/postprocessing/AfterimagePass.js +116 -0
- data/lib-opal/js_wrap/three/postprocessing/BloomPass.js +132 -0
- data/lib-opal/js_wrap/three/postprocessing/BokehPass.js +143 -0
- data/lib-opal/js_wrap/three/postprocessing/ClearPass.js +85 -0
- data/lib-opal/js_wrap/three/postprocessing/CubeTexturePass.js +104 -0
- data/lib-opal/js_wrap/three/postprocessing/DotScreenPass.js +90 -0
- data/lib-opal/js_wrap/three/postprocessing/EffectComposer.js +272 -0
- data/lib-opal/js_wrap/three/postprocessing/FilmPass.js +91 -0
- data/lib-opal/js_wrap/three/postprocessing/GlitchPass.js +140 -0
- data/lib-opal/js_wrap/three/postprocessing/HalftonePass.js +108 -0
- data/lib-opal/js_wrap/three/postprocessing/LUTPass.js +132 -0
- data/lib-opal/js_wrap/three/postprocessing/MaskPass.js +142 -0
- data/lib-opal/js_wrap/three/postprocessing/OutlinePass.js +480 -0
- data/lib-opal/js_wrap/three/postprocessing/Pass.js +101 -0
- data/lib-opal/js_wrap/three/postprocessing/RenderPass.js +109 -0
- data/lib-opal/js_wrap/three/postprocessing/SAOPass.js +384 -0
- data/lib-opal/js_wrap/three/postprocessing/SMAAPass.js +199 -0
- data/lib-opal/js_wrap/three/postprocessing/SSAARenderPass.js +186 -0
- data/lib-opal/js_wrap/three/postprocessing/SSAOPass.js +388 -0
- data/lib-opal/js_wrap/three/postprocessing/SSRPass.js +537 -0
- data/lib-opal/js_wrap/three/postprocessing/SSRrPass.js +481 -0
- data/lib-opal/js_wrap/three/postprocessing/SavePass.js +96 -0
- data/lib-opal/js_wrap/three/postprocessing/ShaderPass.js +98 -0
- data/lib-opal/js_wrap/three/postprocessing/TAARenderPass.js +159 -0
- data/lib-opal/js_wrap/three/postprocessing/TexturePass.js +91 -0
- data/lib-opal/js_wrap/three/postprocessing/UnrealBloomPass.js +335 -0
- data/lib-opal/js_wrap/three/renderers/CSS2DRenderer.js +213 -0
- data/lib-opal/js_wrap/three/renderers/CSS3DRenderer.js +277 -0
- data/lib-opal/js_wrap/three/renderers/Projector.js +733 -0
- data/lib-opal/js_wrap/three/renderers/SVGRenderer.js +470 -0
- data/lib-opal/js_wrap/three/renderers/nodes/Nodes.js +531 -0
- data/lib-opal/js_wrap/three/renderers/nodes/ShaderNode.js +386 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/CameraNode.js +114 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialNode.js +140 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/MaterialReferenceNode.js +79 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelNode.js +62 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ModelViewProjectionNode.js +80 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/NormalNode.js +113 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/Object3DNode.js +136 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/PointUVNode.js +70 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/PositionNode.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/ReferenceNode.js +124 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/SkinningNode.js +129 -0
- data/lib-opal/js_wrap/three/renderers/nodes/accessors/UVNode.js +77 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ArrayInputNode.js +74 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/AttributeNode.js +97 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/BypassNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/CodeNode.js +131 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ContextNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/ExpressionNode.js +81 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionCallNode.js +123 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/FunctionNode.js +126 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/InputNode.js +103 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/Node.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeAttribute.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeBuilder.js +650 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeCode.js +42 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFrame.js +70 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunction.js +55 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeFunctionInput.js +44 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeKeywords.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeParser.js +46 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeUniform.js +55 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVar.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/NodeVary.js +37 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/PropertyNode.js +90 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/TempNode.js +89 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/VarNode.js +101 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/VaryNode.js +101 -0
- data/lib-opal/js_wrap/three/renderers/nodes/core/constants.js +42 -0
- data/lib-opal/js_wrap/three/renderers/nodes/display/ColorSpaceNode.js +165 -0
- data/lib-opal/js_wrap/three/renderers/nodes/display/NormalMapNode.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/functions/BSDFs.js +133 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/BufferNode.js +78 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/ColorNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/FloatNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/IntNode.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix3Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Matrix4Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/TextureNode.js +120 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector2Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector3Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/inputs/Vector4Node.js +67 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightContextNode.js +103 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightNode.js +115 -0
- data/lib-opal/js_wrap/three/renderers/nodes/lights/LightsNode.js +117 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/LineBasicNodeMaterial.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/Materials.js +49 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshBasicNodeMaterial.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/MeshStandardNodeMaterial.js +96 -0
- data/lib-opal/js_wrap/three/renderers/nodes/materials/PointsNodeMaterial.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/CondNode.js +98 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/MathNode.js +255 -0
- data/lib-opal/js_wrap/three/renderers/nodes/math/OperatorNode.js +163 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeFunction.js +158 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/GLSLNodeParser.js +68 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeFunction.js +126 -0
- data/lib-opal/js_wrap/three/renderers/nodes/parsers/WGSLNodeParser.js +68 -0
- data/lib-opal/js_wrap/three/renderers/nodes/procedural/CheckerNode.js +84 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/ArrayElementNode.js +79 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/ConvertNode.js +82 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/JoinNode.js +88 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/OscNode.js +105 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/SplitNode.js +96 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/SpriteSheetUVNode.js +98 -0
- data/lib-opal/js_wrap/three/renderers/nodes/utils/TimerNode.js +93 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/SlotNode.js +72 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodeBuilder.js +463 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLNodes.js +62 -0
- data/lib-opal/js_wrap/three/renderers/webgl/nodes/WebGLPhysicalContextNode.js +95 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPU.js +62 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUAttributes.js +118 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBackground.js +109 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBinding.js +52 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBindings.js +254 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUBufferUtils.js +39 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUComputePipelines.js +82 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUGeometries.js +84 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUInfo.js +86 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUObjects.js +64 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProgrammableStage.js +46 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUProperties.js +63 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderLists.js +180 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipeline.js +662 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderPipelines.js +275 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPURenderer.js +883 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampledTexture.js +139 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUSampler.js +76 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUStorageBuffer.js +69 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureRenderer.js +64 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextureUtils.js +125 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUTextures.js +681 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniform.js +237 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformBuffer.js +90 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/WebGPUUniformsGroup.js +294 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/constants.js +263 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeBuilder.js +619 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +67 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeSampler.js +71 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniform.js +229 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodeUniformsGroup.js +68 -0
- data/lib-opal/js_wrap/three/renderers/webgpu/nodes/WebGPUNodes.js +106 -0
- data/lib-opal/js_wrap/three/shaders/ACESFilmicToneMappingShader.js +45 -0
- data/lib-opal/js_wrap/three/shaders/AfterimageShader.js +46 -0
- data/lib-opal/js_wrap/three/shaders/BasicShader.js +34 -0
- data/lib-opal/js_wrap/three/shaders/BleachBypassShader.js +43 -0
- data/lib-opal/js_wrap/three/shaders/BlendShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/BokehShader.js +65 -0
- data/lib-opal/js_wrap/three/shaders/BokehShader2.js +125 -0
- data/lib-opal/js_wrap/three/shaders/BrightnessContrastShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/ColorCorrectionShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/ColorifyShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/ConvolutionShader.js +75 -0
- data/lib-opal/js_wrap/three/shaders/CopyShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/DOFMipMapShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/DepthLimitedBlurShader.js +95 -0
- data/lib-opal/js_wrap/three/shaders/DigitalGlitch.js +79 -0
- data/lib-opal/js_wrap/three/shaders/DotScreenShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/FXAAShader.js +78 -0
- data/lib-opal/js_wrap/three/shaders/FilmShader.js +69 -0
- data/lib-opal/js_wrap/three/shaders/FocusShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/FreiChenShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/GammaCorrectionShader.js +39 -0
- data/lib-opal/js_wrap/three/shaders/GodRaysShader.js +140 -0
- data/lib-opal/js_wrap/three/shaders/HalftoneShader.js +77 -0
- data/lib-opal/js_wrap/three/shaders/HorizontalBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/HorizontalTiltShiftShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/HueSaturationShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/KaleidoShader.js +50 -0
- data/lib-opal/js_wrap/three/shaders/LuminosityHighPassShader.js +52 -0
- data/lib-opal/js_wrap/three/shaders/LuminosityShader.js +39 -0
- data/lib-opal/js_wrap/three/shaders/MMDToonShader.js +48 -0
- data/lib-opal/js_wrap/three/shaders/MirrorShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/NormalMapShader.js +48 -0
- data/lib-opal/js_wrap/three/shaders/PixelShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/RGBShiftShader.js +50 -0
- data/lib-opal/js_wrap/three/shaders/SAOShader.js +85 -0
- data/lib-opal/js_wrap/three/shaders/SMAAShader.js +95 -0
- data/lib-opal/js_wrap/three/shaders/SSAOShader.js +113 -0
- data/lib-opal/js_wrap/three/shaders/SSRShader.js +126 -0
- data/lib-opal/js_wrap/three/shaders/SSRrShader.js +106 -0
- data/lib-opal/js_wrap/three/shaders/SepiaShader.js +43 -0
- data/lib-opal/js_wrap/three/shaders/SobelOperatorShader.js +44 -0
- data/lib-opal/js_wrap/three/shaders/SubsurfaceScatteringShader.js +64 -0
- data/lib-opal/js_wrap/three/shaders/TechnicolorShader.js +41 -0
- data/lib-opal/js_wrap/three/shaders/ToneMapShader.js +53 -0
- data/lib-opal/js_wrap/three/shaders/ToonShader.js +148 -0
- data/lib-opal/js_wrap/three/shaders/TriangleBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/UnpackDepthRGBAShader.js +42 -0
- data/lib-opal/js_wrap/three/shaders/VerticalBlurShader.js +47 -0
- data/lib-opal/js_wrap/three/shaders/VerticalTiltShiftShader.js +49 -0
- data/lib-opal/js_wrap/three/shaders/VignetteShader.js +46 -0
- data/lib-opal/js_wrap/three/shaders/VolumeShader.js +55 -0
- data/lib-opal/js_wrap/three/shaders/WaterRefractionShader.js +46 -0
- data/lib-opal/js_wrap/three/textures/FlakesTexture.js +61 -0
- data/lib-opal/js_wrap/three/utils/BufferGeometryUtils.js +683 -0
- data/lib-opal/js_wrap/three/utils/CameraUtils.js +97 -0
- data/lib-opal/js_wrap/three/utils/GPUStatsPanel.js +154 -0
- data/lib-opal/js_wrap/three/utils/GeometryCompressionUtils.js +468 -0
- data/lib-opal/js_wrap/three/utils/GeometryUtils.js +192 -0
- data/lib-opal/js_wrap/three/utils/PackedPhongMaterial.js +77 -0
- data/lib-opal/js_wrap/three/utils/RoughnessMipmapper.js +169 -0
- data/lib-opal/js_wrap/three/utils/SceneUtils.js +62 -0
- data/lib-opal/js_wrap/three/utils/ShadowMapViewer.js +182 -0
- data/lib-opal/js_wrap/three/utils/SkeletonUtils.js +400 -0
- data/lib-opal/js_wrap/three/utils/UVsDebug.js +132 -0
- data/lib-opal/js_wrap/three/utils/WorkerPool.js +130 -0
- data/lib-opal/js_wrap/three/webxr/ARButton.js +203 -0
- data/lib-opal/js_wrap/three/webxr/OculusHandModel.js +131 -0
- data/lib-opal/js_wrap/three/webxr/OculusHandPointerModel.js +328 -0
- data/lib-opal/js_wrap/three/webxr/Text2D.js +54 -0
- data/lib-opal/js_wrap/three/webxr/VRButton.js +181 -0
- data/lib-opal/js_wrap/three/webxr/XRControllerModelFactory.js +266 -0
- data/lib-opal/js_wrap/three/webxr/XREstimatedLight.js +221 -0
- data/lib-opal/js_wrap/three/webxr/XRHandMeshModel.js +93 -0
- data/lib-opal/js_wrap/three/webxr/XRHandModelFactory.js +127 -0
- data/lib-opal/js_wrap/three/webxr/XRHandPrimitiveModel.js +85 -0
- data/opal-js_wrap-three.gemspec +4 -4
- metadata +502 -5
@@ -0,0 +1,1687 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "three", "../shaders/MMDToonShader.js", "../loaders/TGALoader.js", "../libs/mmdparser.module.js"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("three"), require("../shaders/MMDToonShader.js"), require("../loaders/TGALoader.js"), require("../libs/mmdparser.module.js"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.three, global.MMDToonShader, global.TGALoader, global.mmdparserModule);
|
11
|
+
global.MMDLoader = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three, _MMDToonShader, _TGALoader, _mmdparserModule) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(_exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
_exports.MMDLoader = void 0;
|
20
|
+
|
21
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
22
|
+
|
23
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
24
|
+
|
25
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
26
|
+
|
27
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
28
|
+
|
29
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
30
|
+
|
31
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } Object.defineProperty(subClass, "prototype", { value: Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }), writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
32
|
+
|
33
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
34
|
+
|
35
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
36
|
+
|
37
|
+
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
38
|
+
|
39
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
40
|
+
|
41
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
42
|
+
|
43
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Dependencies
|
47
|
+
* - mmd-parser https://github.com/takahirox/mmd-parser
|
48
|
+
* - TGALoader
|
49
|
+
* - OutlineEffect
|
50
|
+
*
|
51
|
+
* MMDLoader creates Three.js Objects from MMD resources as
|
52
|
+
* PMD, PMX, VMD, and VPD files.
|
53
|
+
*
|
54
|
+
* PMD/PMX is a model data format, VMD is a motion data format
|
55
|
+
* VPD is a posing data format used in MMD(Miku Miku Dance).
|
56
|
+
*
|
57
|
+
* MMD official site
|
58
|
+
* - https://sites.google.com/view/evpvp/
|
59
|
+
*
|
60
|
+
* PMD, VMD format (in Japanese)
|
61
|
+
* - http://blog.goo.ne.jp/torisu_tetosuki/e/209ad341d3ece2b1b4df24abf619d6e4
|
62
|
+
*
|
63
|
+
* PMX format
|
64
|
+
* - https://gist.github.com/felixjones/f8a06bd48f9da9a4539f
|
65
|
+
*
|
66
|
+
* TODO
|
67
|
+
* - light motion in vmd support.
|
68
|
+
* - SDEF support.
|
69
|
+
* - uv/material/bone morphing support.
|
70
|
+
* - more precise grant skinning support.
|
71
|
+
* - shadow support.
|
72
|
+
*/
|
73
|
+
|
74
|
+
/**
|
75
|
+
* @param {THREE.LoadingManager} manager
|
76
|
+
*/
|
77
|
+
var MMDLoader = /*#__PURE__*/function (_Loader) {
|
78
|
+
_inherits(MMDLoader, _Loader);
|
79
|
+
|
80
|
+
var _super = _createSuper(MMDLoader);
|
81
|
+
|
82
|
+
function MMDLoader(manager) {
|
83
|
+
var _this;
|
84
|
+
|
85
|
+
_classCallCheck(this, MMDLoader);
|
86
|
+
|
87
|
+
_this = _super.call(this, manager);
|
88
|
+
_this.loader = new _three.FileLoader(_this.manager);
|
89
|
+
_this.parser = null; // lazy generation
|
90
|
+
|
91
|
+
_this.meshBuilder = new MeshBuilder(_this.manager);
|
92
|
+
_this.animationBuilder = new AnimationBuilder();
|
93
|
+
return _this;
|
94
|
+
}
|
95
|
+
/**
|
96
|
+
* @param {string} animationPath
|
97
|
+
* @return {MMDLoader}
|
98
|
+
*/
|
99
|
+
|
100
|
+
|
101
|
+
_createClass(MMDLoader, [{
|
102
|
+
key: "setAnimationPath",
|
103
|
+
value: function setAnimationPath(animationPath) {
|
104
|
+
this.animationPath = animationPath;
|
105
|
+
return this;
|
106
|
+
} // Load MMD assets as Three.js Object
|
107
|
+
|
108
|
+
/**
|
109
|
+
* Loads Model file (.pmd or .pmx) as a SkinnedMesh.
|
110
|
+
*
|
111
|
+
* @param {string} url - url to Model(.pmd or .pmx) file
|
112
|
+
* @param {function} onLoad
|
113
|
+
* @param {function} onProgress
|
114
|
+
* @param {function} onError
|
115
|
+
*/
|
116
|
+
|
117
|
+
}, {
|
118
|
+
key: "load",
|
119
|
+
value: function load(url, onLoad, onProgress, onError) {
|
120
|
+
var builder = this.meshBuilder.setCrossOrigin(this.crossOrigin); // resource path
|
121
|
+
|
122
|
+
var resourcePath;
|
123
|
+
|
124
|
+
if (this.resourcePath !== '') {
|
125
|
+
resourcePath = this.resourcePath;
|
126
|
+
} else if (this.path !== '') {
|
127
|
+
resourcePath = this.path;
|
128
|
+
} else {
|
129
|
+
resourcePath = _three.LoaderUtils.extractUrlBase(url);
|
130
|
+
}
|
131
|
+
|
132
|
+
var modelExtension = this._extractExtension(url).toLowerCase(); // Should I detect by seeing header?
|
133
|
+
|
134
|
+
|
135
|
+
if (modelExtension !== 'pmd' && modelExtension !== 'pmx') {
|
136
|
+
if (onError) onError(new Error('THREE.MMDLoader: Unknown model file extension .' + modelExtension + '.'));
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
|
140
|
+
this[modelExtension === 'pmd' ? 'loadPMD' : 'loadPMX'](url, function (data) {
|
141
|
+
onLoad(builder.build(data, resourcePath, onProgress, onError));
|
142
|
+
}, onProgress, onError);
|
143
|
+
}
|
144
|
+
/**
|
145
|
+
* Loads Motion file(s) (.vmd) as a AnimationClip.
|
146
|
+
* If two or more files are specified, they'll be merged.
|
147
|
+
*
|
148
|
+
* @param {string|Array<string>} url - url(s) to animation(.vmd) file(s)
|
149
|
+
* @param {SkinnedMesh|THREE.Camera} object - tracks will be fitting to this object
|
150
|
+
* @param {function} onLoad
|
151
|
+
* @param {function} onProgress
|
152
|
+
* @param {function} onError
|
153
|
+
*/
|
154
|
+
|
155
|
+
}, {
|
156
|
+
key: "loadAnimation",
|
157
|
+
value: function loadAnimation(url, object, onLoad, onProgress, onError) {
|
158
|
+
var builder = this.animationBuilder;
|
159
|
+
this.loadVMD(url, function (vmd) {
|
160
|
+
onLoad(object.isCamera ? builder.buildCameraAnimation(vmd) : builder.build(vmd, object));
|
161
|
+
}, onProgress, onError);
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* Loads mode file and motion file(s) as an object containing
|
165
|
+
* a SkinnedMesh and a AnimationClip.
|
166
|
+
* Tracks of AnimationClip are fitting to the model.
|
167
|
+
*
|
168
|
+
* @param {string} modelUrl - url to Model(.pmd or .pmx) file
|
169
|
+
* @param {string|Array{string}} vmdUrl - url(s) to animation(.vmd) file
|
170
|
+
* @param {function} onLoad
|
171
|
+
* @param {function} onProgress
|
172
|
+
* @param {function} onError
|
173
|
+
*/
|
174
|
+
|
175
|
+
}, {
|
176
|
+
key: "loadWithAnimation",
|
177
|
+
value: function loadWithAnimation(modelUrl, vmdUrl, onLoad, onProgress, onError) {
|
178
|
+
var scope = this;
|
179
|
+
this.load(modelUrl, function (mesh) {
|
180
|
+
scope.loadAnimation(vmdUrl, mesh, function (animation) {
|
181
|
+
onLoad({
|
182
|
+
mesh: mesh,
|
183
|
+
animation: animation
|
184
|
+
});
|
185
|
+
}, onProgress, onError);
|
186
|
+
}, onProgress, onError);
|
187
|
+
} // Load MMD assets as Object data parsed by MMDParser
|
188
|
+
|
189
|
+
/**
|
190
|
+
* Loads .pmd file as an Object.
|
191
|
+
*
|
192
|
+
* @param {string} url - url to .pmd file
|
193
|
+
* @param {function} onLoad
|
194
|
+
* @param {function} onProgress
|
195
|
+
* @param {function} onError
|
196
|
+
*/
|
197
|
+
|
198
|
+
}, {
|
199
|
+
key: "loadPMD",
|
200
|
+
value: function loadPMD(url, onLoad, onProgress, onError) {
|
201
|
+
var parser = this._getParser();
|
202
|
+
|
203
|
+
this.loader.setMimeType(undefined).setPath(this.path).setResponseType('arraybuffer').setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials).load(url, function (buffer) {
|
204
|
+
onLoad(parser.parsePmd(buffer, true));
|
205
|
+
}, onProgress, onError);
|
206
|
+
}
|
207
|
+
/**
|
208
|
+
* Loads .pmx file as an Object.
|
209
|
+
*
|
210
|
+
* @param {string} url - url to .pmx file
|
211
|
+
* @param {function} onLoad
|
212
|
+
* @param {function} onProgress
|
213
|
+
* @param {function} onError
|
214
|
+
*/
|
215
|
+
|
216
|
+
}, {
|
217
|
+
key: "loadPMX",
|
218
|
+
value: function loadPMX(url, onLoad, onProgress, onError) {
|
219
|
+
var parser = this._getParser();
|
220
|
+
|
221
|
+
this.loader.setMimeType(undefined).setPath(this.path).setResponseType('arraybuffer').setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials).load(url, function (buffer) {
|
222
|
+
onLoad(parser.parsePmx(buffer, true));
|
223
|
+
}, onProgress, onError);
|
224
|
+
}
|
225
|
+
/**
|
226
|
+
* Loads .vmd file as an Object. If two or more files are specified
|
227
|
+
* they'll be merged.
|
228
|
+
*
|
229
|
+
* @param {string|Array<string>} url - url(s) to .vmd file(s)
|
230
|
+
* @param {function} onLoad
|
231
|
+
* @param {function} onProgress
|
232
|
+
* @param {function} onError
|
233
|
+
*/
|
234
|
+
|
235
|
+
}, {
|
236
|
+
key: "loadVMD",
|
237
|
+
value: function loadVMD(url, onLoad, onProgress, onError) {
|
238
|
+
var urls = Array.isArray(url) ? url : [url];
|
239
|
+
var vmds = [];
|
240
|
+
var vmdNum = urls.length;
|
241
|
+
|
242
|
+
var parser = this._getParser();
|
243
|
+
|
244
|
+
this.loader.setMimeType(undefined).setPath(this.animationPath).setResponseType('arraybuffer').setRequestHeader(this.requestHeader).setWithCredentials(this.withCredentials);
|
245
|
+
|
246
|
+
for (var i = 0, il = urls.length; i < il; i++) {
|
247
|
+
this.loader.load(urls[i], function (buffer) {
|
248
|
+
vmds.push(parser.parseVmd(buffer, true));
|
249
|
+
if (vmds.length === vmdNum) onLoad(parser.mergeVmds(vmds));
|
250
|
+
}, onProgress, onError);
|
251
|
+
}
|
252
|
+
}
|
253
|
+
/**
|
254
|
+
* Loads .vpd file as an Object.
|
255
|
+
*
|
256
|
+
* @param {string} url - url to .vpd file
|
257
|
+
* @param {boolean} isUnicode
|
258
|
+
* @param {function} onLoad
|
259
|
+
* @param {function} onProgress
|
260
|
+
* @param {function} onError
|
261
|
+
*/
|
262
|
+
|
263
|
+
}, {
|
264
|
+
key: "loadVPD",
|
265
|
+
value: function loadVPD(url, isUnicode, onLoad, onProgress, onError) {
|
266
|
+
var parser = this._getParser();
|
267
|
+
|
268
|
+
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) {
|
269
|
+
onLoad(parser.parseVpd(text, true));
|
270
|
+
}, onProgress, onError);
|
271
|
+
} // private methods
|
272
|
+
|
273
|
+
}, {
|
274
|
+
key: "_extractExtension",
|
275
|
+
value: function _extractExtension(url) {
|
276
|
+
var index = url.lastIndexOf('.');
|
277
|
+
return index < 0 ? '' : url.slice(index + 1);
|
278
|
+
}
|
279
|
+
}, {
|
280
|
+
key: "_getParser",
|
281
|
+
value: function _getParser() {
|
282
|
+
if (this.parser === null) {
|
283
|
+
if (typeof _mmdparserModule.MMDParser === 'undefined') {
|
284
|
+
throw new Error('THREE.MMDLoader: Import MMDParser https://github.com/takahirox/mmd-parser');
|
285
|
+
}
|
286
|
+
|
287
|
+
this.parser = new _mmdparserModule.MMDParser.Parser(); // eslint-disable-line no-undef
|
288
|
+
}
|
289
|
+
|
290
|
+
return this.parser;
|
291
|
+
}
|
292
|
+
}]);
|
293
|
+
|
294
|
+
return MMDLoader;
|
295
|
+
}(_three.Loader); // Utilities
|
296
|
+
|
297
|
+
/*
|
298
|
+
* base64 encoded defalut toon textures toon00.bmp - toon10.bmp.
|
299
|
+
* We don't need to request external toon image files.
|
300
|
+
* This idea is from http://www20.atpages.jp/katwat/three.js_r58/examples/mytest37/mmd.three.js
|
301
|
+
*/
|
302
|
+
|
303
|
+
|
304
|
+
_exports.MMDLoader = MMDLoader;
|
305
|
+
var 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='];
|
306
|
+
var 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]; // Builders. They build Three.js object from Object data parsed by MMDParser.
|
307
|
+
|
308
|
+
/**
|
309
|
+
* @param {THREE.LoadingManager} manager
|
310
|
+
*/
|
311
|
+
|
312
|
+
var MeshBuilder = /*#__PURE__*/function () {
|
313
|
+
function MeshBuilder(manager) {
|
314
|
+
_classCallCheck(this, MeshBuilder);
|
315
|
+
|
316
|
+
this.crossOrigin = 'anonymous';
|
317
|
+
this.geometryBuilder = new GeometryBuilder();
|
318
|
+
this.materialBuilder = new MaterialBuilder(manager);
|
319
|
+
}
|
320
|
+
/**
|
321
|
+
* @param {string} crossOrigin
|
322
|
+
* @return {MeshBuilder}
|
323
|
+
*/
|
324
|
+
|
325
|
+
|
326
|
+
_createClass(MeshBuilder, [{
|
327
|
+
key: "setCrossOrigin",
|
328
|
+
value: function setCrossOrigin(crossOrigin) {
|
329
|
+
this.crossOrigin = crossOrigin;
|
330
|
+
return this;
|
331
|
+
}
|
332
|
+
/**
|
333
|
+
* @param {Object} data - parsed PMD/PMX data
|
334
|
+
* @param {string} resourcePath
|
335
|
+
* @param {function} onProgress
|
336
|
+
* @param {function} onError
|
337
|
+
* @return {SkinnedMesh}
|
338
|
+
*/
|
339
|
+
|
340
|
+
}, {
|
341
|
+
key: "build",
|
342
|
+
value: function build(data, resourcePath, onProgress, onError) {
|
343
|
+
var geometry = this.geometryBuilder.build(data);
|
344
|
+
var material = this.materialBuilder.setCrossOrigin(this.crossOrigin).setResourcePath(resourcePath).build(data, geometry, onProgress, onError);
|
345
|
+
var mesh = new _three.SkinnedMesh(geometry, material);
|
346
|
+
var skeleton = new _three.Skeleton(initBones(mesh));
|
347
|
+
mesh.bind(skeleton); // console.log( mesh ); // for console debug
|
348
|
+
|
349
|
+
return mesh;
|
350
|
+
}
|
351
|
+
}]);
|
352
|
+
|
353
|
+
return MeshBuilder;
|
354
|
+
}(); // TODO: Try to remove this function
|
355
|
+
|
356
|
+
|
357
|
+
function initBones(mesh) {
|
358
|
+
var geometry = mesh.geometry;
|
359
|
+
var bones = [];
|
360
|
+
|
361
|
+
if (geometry && geometry.bones !== undefined) {
|
362
|
+
// first, create array of 'Bone' objects from geometry data
|
363
|
+
for (var i = 0, il = geometry.bones.length; i < il; i++) {
|
364
|
+
var gbone = geometry.bones[i]; // create new 'Bone' object
|
365
|
+
|
366
|
+
var bone = new _three.Bone();
|
367
|
+
bones.push(bone); // apply values
|
368
|
+
|
369
|
+
bone.name = gbone.name;
|
370
|
+
bone.position.fromArray(gbone.pos);
|
371
|
+
bone.quaternion.fromArray(gbone.rotq);
|
372
|
+
if (gbone.scl !== undefined) bone.scale.fromArray(gbone.scl);
|
373
|
+
} // second, create bone hierarchy
|
374
|
+
|
375
|
+
|
376
|
+
for (var _i = 0, _il = geometry.bones.length; _i < _il; _i++) {
|
377
|
+
var _gbone = geometry.bones[_i];
|
378
|
+
|
379
|
+
if (_gbone.parent !== -1 && _gbone.parent !== null && bones[_gbone.parent] !== undefined) {
|
380
|
+
// subsequent bones in the hierarchy
|
381
|
+
bones[_gbone.parent].add(bones[_i]);
|
382
|
+
} else {
|
383
|
+
// topmost bone, immediate child of the skinned mesh
|
384
|
+
mesh.add(bones[_i]);
|
385
|
+
}
|
386
|
+
}
|
387
|
+
} // now the bones are part of the scene graph and children of the skinned mesh.
|
388
|
+
// let's update the corresponding matrices
|
389
|
+
|
390
|
+
|
391
|
+
mesh.updateMatrixWorld(true);
|
392
|
+
return bones;
|
393
|
+
} //
|
394
|
+
|
395
|
+
|
396
|
+
var GeometryBuilder = /*#__PURE__*/function () {
|
397
|
+
function GeometryBuilder() {
|
398
|
+
_classCallCheck(this, GeometryBuilder);
|
399
|
+
}
|
400
|
+
|
401
|
+
_createClass(GeometryBuilder, [{
|
402
|
+
key: "build",
|
403
|
+
value:
|
404
|
+
/**
|
405
|
+
* @param {Object} data - parsed PMD/PMX data
|
406
|
+
* @return {BufferGeometry}
|
407
|
+
*/
|
408
|
+
function build(data) {
|
409
|
+
// for geometry
|
410
|
+
var positions = [];
|
411
|
+
var uvs = [];
|
412
|
+
var normals = [];
|
413
|
+
var indices = [];
|
414
|
+
var groups = [];
|
415
|
+
var bones = [];
|
416
|
+
var skinIndices = [];
|
417
|
+
var skinWeights = [];
|
418
|
+
var morphTargets = [];
|
419
|
+
var morphPositions = [];
|
420
|
+
var iks = [];
|
421
|
+
var grants = [];
|
422
|
+
var rigidBodies = [];
|
423
|
+
var constraints = []; // for work
|
424
|
+
|
425
|
+
var offset = 0;
|
426
|
+
var boneTypeTable = {}; // positions, normals, uvs, skinIndices, skinWeights
|
427
|
+
|
428
|
+
for (var i = 0; i < data.metadata.vertexCount; i++) {
|
429
|
+
var v = data.vertices[i];
|
430
|
+
|
431
|
+
for (var j = 0, jl = v.position.length; j < jl; j++) {
|
432
|
+
positions.push(v.position[j]);
|
433
|
+
}
|
434
|
+
|
435
|
+
for (var _j = 0, _jl = v.normal.length; _j < _jl; _j++) {
|
436
|
+
normals.push(v.normal[_j]);
|
437
|
+
}
|
438
|
+
|
439
|
+
for (var _j2 = 0, _jl2 = v.uv.length; _j2 < _jl2; _j2++) {
|
440
|
+
uvs.push(v.uv[_j2]);
|
441
|
+
}
|
442
|
+
|
443
|
+
for (var _j3 = 0; _j3 < 4; _j3++) {
|
444
|
+
skinIndices.push(v.skinIndices.length - 1 >= _j3 ? v.skinIndices[_j3] : 0.0);
|
445
|
+
}
|
446
|
+
|
447
|
+
for (var _j4 = 0; _j4 < 4; _j4++) {
|
448
|
+
skinWeights.push(v.skinWeights.length - 1 >= _j4 ? v.skinWeights[_j4] : 0.0);
|
449
|
+
}
|
450
|
+
} // indices
|
451
|
+
|
452
|
+
|
453
|
+
for (var _i2 = 0; _i2 < data.metadata.faceCount; _i2++) {
|
454
|
+
var face = data.faces[_i2];
|
455
|
+
|
456
|
+
for (var _j5 = 0, _jl3 = face.indices.length; _j5 < _jl3; _j5++) {
|
457
|
+
indices.push(face.indices[_j5]);
|
458
|
+
}
|
459
|
+
} // groups
|
460
|
+
|
461
|
+
|
462
|
+
for (var _i3 = 0; _i3 < data.metadata.materialCount; _i3++) {
|
463
|
+
var material = data.materials[_i3];
|
464
|
+
groups.push({
|
465
|
+
offset: offset * 3,
|
466
|
+
count: material.faceCount * 3
|
467
|
+
});
|
468
|
+
offset += material.faceCount;
|
469
|
+
} // bones
|
470
|
+
|
471
|
+
|
472
|
+
for (var _i4 = 0; _i4 < data.metadata.rigidBodyCount; _i4++) {
|
473
|
+
var body = data.rigidBodies[_i4];
|
474
|
+
var value = boneTypeTable[body.boneIndex]; // keeps greater number if already value is set without any special reasons
|
475
|
+
|
476
|
+
value = value === undefined ? body.type : Math.max(body.type, value);
|
477
|
+
boneTypeTable[body.boneIndex] = value;
|
478
|
+
}
|
479
|
+
|
480
|
+
for (var _i5 = 0; _i5 < data.metadata.boneCount; _i5++) {
|
481
|
+
var boneData = data.bones[_i5];
|
482
|
+
var bone = {
|
483
|
+
index: _i5,
|
484
|
+
transformationClass: boneData.transformationClass,
|
485
|
+
parent: boneData.parentIndex,
|
486
|
+
name: boneData.name,
|
487
|
+
pos: boneData.position.slice(0, 3),
|
488
|
+
rotq: [0, 0, 0, 1],
|
489
|
+
scl: [1, 1, 1],
|
490
|
+
rigidBodyType: boneTypeTable[_i5] !== undefined ? boneTypeTable[_i5] : -1
|
491
|
+
};
|
492
|
+
|
493
|
+
if (bone.parent !== -1) {
|
494
|
+
bone.pos[0] -= data.bones[bone.parent].position[0];
|
495
|
+
bone.pos[1] -= data.bones[bone.parent].position[1];
|
496
|
+
bone.pos[2] -= data.bones[bone.parent].position[2];
|
497
|
+
}
|
498
|
+
|
499
|
+
bones.push(bone);
|
500
|
+
} // iks
|
501
|
+
// TODO: remove duplicated codes between PMD and PMX
|
502
|
+
|
503
|
+
|
504
|
+
if (data.metadata.format === 'pmd') {
|
505
|
+
for (var _i6 = 0; _i6 < data.metadata.ikCount; _i6++) {
|
506
|
+
var ik = data.iks[_i6];
|
507
|
+
var param = {
|
508
|
+
target: ik.target,
|
509
|
+
effector: ik.effector,
|
510
|
+
iteration: ik.iteration,
|
511
|
+
maxAngle: ik.maxAngle * 4,
|
512
|
+
links: []
|
513
|
+
};
|
514
|
+
|
515
|
+
for (var _j6 = 0, _jl4 = ik.links.length; _j6 < _jl4; _j6++) {
|
516
|
+
var link = {};
|
517
|
+
link.index = ik.links[_j6].index;
|
518
|
+
link.enabled = true;
|
519
|
+
|
520
|
+
if (data.bones[link.index].name.indexOf('ひざ') >= 0) {
|
521
|
+
link.limitation = new _three.Vector3(1.0, 0.0, 0.0);
|
522
|
+
}
|
523
|
+
|
524
|
+
param.links.push(link);
|
525
|
+
}
|
526
|
+
|
527
|
+
iks.push(param);
|
528
|
+
}
|
529
|
+
} else {
|
530
|
+
for (var _i7 = 0; _i7 < data.metadata.boneCount; _i7++) {
|
531
|
+
var _ik = data.bones[_i7].ik;
|
532
|
+
if (_ik === undefined) continue;
|
533
|
+
var _param = {
|
534
|
+
target: _i7,
|
535
|
+
effector: _ik.effector,
|
536
|
+
iteration: _ik.iteration,
|
537
|
+
maxAngle: _ik.maxAngle,
|
538
|
+
links: []
|
539
|
+
};
|
540
|
+
|
541
|
+
for (var _j7 = 0, _jl5 = _ik.links.length; _j7 < _jl5; _j7++) {
|
542
|
+
var _link = {};
|
543
|
+
_link.index = _ik.links[_j7].index;
|
544
|
+
_link.enabled = true;
|
545
|
+
|
546
|
+
if (_ik.links[_j7].angleLimitation === 1) {
|
547
|
+
// Revert if rotationMin/Max doesn't work well
|
548
|
+
// link.limitation = new Vector3( 1.0, 0.0, 0.0 );
|
549
|
+
var rotationMin = _ik.links[_j7].lowerLimitationAngle;
|
550
|
+
var rotationMax = _ik.links[_j7].upperLimitationAngle; // Convert Left to Right coordinate by myself because
|
551
|
+
// MMDParser doesn't convert. It's a MMDParser's bug
|
552
|
+
|
553
|
+
var tmp1 = -rotationMax[0];
|
554
|
+
var tmp2 = -rotationMax[1];
|
555
|
+
rotationMax[0] = -rotationMin[0];
|
556
|
+
rotationMax[1] = -rotationMin[1];
|
557
|
+
rotationMin[0] = tmp1;
|
558
|
+
rotationMin[1] = tmp2;
|
559
|
+
_link.rotationMin = new _three.Vector3().fromArray(rotationMin);
|
560
|
+
_link.rotationMax = new _three.Vector3().fromArray(rotationMax);
|
561
|
+
}
|
562
|
+
|
563
|
+
_param.links.push(_link);
|
564
|
+
}
|
565
|
+
|
566
|
+
iks.push(_param); // Save the reference even from bone data for efficiently
|
567
|
+
// simulating PMX animation system
|
568
|
+
|
569
|
+
bones[_i7].ik = _param;
|
570
|
+
}
|
571
|
+
} // grants
|
572
|
+
|
573
|
+
|
574
|
+
if (data.metadata.format === 'pmx') {
|
575
|
+
// Sort grant parameters from parents to children because
|
576
|
+
// grant uses parent's transform that parent's grant is already applied
|
577
|
+
// so grant should be applied in order from parents to children
|
578
|
+
var traverse = function traverse(entry) {
|
579
|
+
if (entry.param) {
|
580
|
+
grants.push(entry.param); // Save the reference even from bone data for efficiently
|
581
|
+
// simulating PMX animation system
|
582
|
+
|
583
|
+
bones[entry.param.index].grant = entry.param;
|
584
|
+
}
|
585
|
+
|
586
|
+
entry.visited = true;
|
587
|
+
|
588
|
+
for (var _i9 = 0, il = entry.children.length; _i9 < il; _i9++) {
|
589
|
+
var child = entry.children[_i9]; // Cut off a loop if exists. (Is a grant loop invalid?)
|
590
|
+
|
591
|
+
if (!child.visited) traverse(child);
|
592
|
+
}
|
593
|
+
};
|
594
|
+
|
595
|
+
// bone index -> grant entry map
|
596
|
+
var grantEntryMap = {};
|
597
|
+
|
598
|
+
for (var _i8 = 0; _i8 < data.metadata.boneCount; _i8++) {
|
599
|
+
var _boneData = data.bones[_i8];
|
600
|
+
var grant = _boneData.grant;
|
601
|
+
if (grant === undefined) continue;
|
602
|
+
var _param2 = {
|
603
|
+
index: _i8,
|
604
|
+
parentIndex: grant.parentIndex,
|
605
|
+
ratio: grant.ratio,
|
606
|
+
isLocal: grant.isLocal,
|
607
|
+
affectRotation: grant.affectRotation,
|
608
|
+
affectPosition: grant.affectPosition,
|
609
|
+
transformationClass: _boneData.transformationClass
|
610
|
+
};
|
611
|
+
grantEntryMap[_i8] = {
|
612
|
+
parent: null,
|
613
|
+
children: [],
|
614
|
+
param: _param2,
|
615
|
+
visited: false
|
616
|
+
};
|
617
|
+
}
|
618
|
+
|
619
|
+
var rootEntry = {
|
620
|
+
parent: null,
|
621
|
+
children: [],
|
622
|
+
param: null,
|
623
|
+
visited: false
|
624
|
+
}; // Build a tree representing grant hierarchy
|
625
|
+
|
626
|
+
for (var boneIndex in grantEntryMap) {
|
627
|
+
var grantEntry = grantEntryMap[boneIndex];
|
628
|
+
var parentGrantEntry = grantEntryMap[grantEntry.parentIndex] || rootEntry;
|
629
|
+
grantEntry.parent = parentGrantEntry;
|
630
|
+
parentGrantEntry.children.push(grantEntry);
|
631
|
+
}
|
632
|
+
|
633
|
+
traverse(rootEntry);
|
634
|
+
} // morph
|
635
|
+
|
636
|
+
|
637
|
+
function updateAttributes(attribute, morph, ratio) {
|
638
|
+
for (var _i10 = 0; _i10 < morph.elementCount; _i10++) {
|
639
|
+
var element = morph.elements[_i10];
|
640
|
+
var index = void 0;
|
641
|
+
|
642
|
+
if (data.metadata.format === 'pmd') {
|
643
|
+
index = data.morphs[0].elements[element.index].index;
|
644
|
+
} else {
|
645
|
+
index = element.index;
|
646
|
+
}
|
647
|
+
|
648
|
+
attribute.array[index * 3 + 0] += element.position[0] * ratio;
|
649
|
+
attribute.array[index * 3 + 1] += element.position[1] * ratio;
|
650
|
+
attribute.array[index * 3 + 2] += element.position[2] * ratio;
|
651
|
+
}
|
652
|
+
}
|
653
|
+
|
654
|
+
for (var _i11 = 0; _i11 < data.metadata.morphCount; _i11++) {
|
655
|
+
var morph = data.morphs[_i11];
|
656
|
+
var params = {
|
657
|
+
name: morph.name
|
658
|
+
};
|
659
|
+
var attribute = new _three.Float32BufferAttribute(data.metadata.vertexCount * 3, 3);
|
660
|
+
attribute.name = morph.name;
|
661
|
+
|
662
|
+
for (var _j8 = 0; _j8 < data.metadata.vertexCount * 3; _j8++) {
|
663
|
+
attribute.array[_j8] = positions[_j8];
|
664
|
+
}
|
665
|
+
|
666
|
+
if (data.metadata.format === 'pmd') {
|
667
|
+
if (_i11 !== 0) {
|
668
|
+
updateAttributes(attribute, morph, 1.0);
|
669
|
+
}
|
670
|
+
} else {
|
671
|
+
if (morph.type === 0) {
|
672
|
+
// group
|
673
|
+
for (var _j9 = 0; _j9 < morph.elementCount; _j9++) {
|
674
|
+
var morph2 = data.morphs[morph.elements[_j9].index];
|
675
|
+
var ratio = morph.elements[_j9].ratio;
|
676
|
+
|
677
|
+
if (morph2.type === 1) {
|
678
|
+
updateAttributes(attribute, morph2, ratio);
|
679
|
+
} else {// TODO: implement
|
680
|
+
}
|
681
|
+
}
|
682
|
+
} else if (morph.type === 1) {
|
683
|
+
// vertex
|
684
|
+
updateAttributes(attribute, morph, 1.0);
|
685
|
+
} else if (morph.type === 2) {// bone
|
686
|
+
// TODO: implement
|
687
|
+
} else if (morph.type === 3) {// uv
|
688
|
+
// TODO: implement
|
689
|
+
} else if (morph.type === 4) {// additional uv1
|
690
|
+
// TODO: implement
|
691
|
+
} else if (morph.type === 5) {// additional uv2
|
692
|
+
// TODO: implement
|
693
|
+
} else if (morph.type === 6) {// additional uv3
|
694
|
+
// TODO: implement
|
695
|
+
} else if (morph.type === 7) {// additional uv4
|
696
|
+
// TODO: implement
|
697
|
+
} else if (morph.type === 8) {// material
|
698
|
+
// TODO: implement
|
699
|
+
}
|
700
|
+
}
|
701
|
+
|
702
|
+
morphTargets.push(params);
|
703
|
+
morphPositions.push(attribute);
|
704
|
+
} // rigid bodies from rigidBodies field.
|
705
|
+
|
706
|
+
|
707
|
+
for (var _i12 = 0; _i12 < data.metadata.rigidBodyCount; _i12++) {
|
708
|
+
var rigidBody = data.rigidBodies[_i12];
|
709
|
+
var _params = {};
|
710
|
+
|
711
|
+
for (var key in rigidBody) {
|
712
|
+
_params[key] = rigidBody[key];
|
713
|
+
}
|
714
|
+
/*
|
715
|
+
* RigidBody position parameter in PMX seems global position
|
716
|
+
* while the one in PMD seems offset from corresponding bone.
|
717
|
+
* So unify being offset.
|
718
|
+
*/
|
719
|
+
|
720
|
+
|
721
|
+
if (data.metadata.format === 'pmx') {
|
722
|
+
if (_params.boneIndex !== -1) {
|
723
|
+
var _bone = data.bones[_params.boneIndex];
|
724
|
+
_params.position[0] -= _bone.position[0];
|
725
|
+
_params.position[1] -= _bone.position[1];
|
726
|
+
_params.position[2] -= _bone.position[2];
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
rigidBodies.push(_params);
|
731
|
+
} // constraints from constraints field.
|
732
|
+
|
733
|
+
|
734
|
+
for (var _i13 = 0; _i13 < data.metadata.constraintCount; _i13++) {
|
735
|
+
var constraint = data.constraints[_i13];
|
736
|
+
var _params2 = {};
|
737
|
+
|
738
|
+
for (var _key in constraint) {
|
739
|
+
_params2[_key] = constraint[_key];
|
740
|
+
}
|
741
|
+
|
742
|
+
var bodyA = rigidBodies[_params2.rigidBodyIndex1];
|
743
|
+
var bodyB = rigidBodies[_params2.rigidBodyIndex2]; // Refer to http://www20.atpages.jp/katwat/wp/?p=4135
|
744
|
+
|
745
|
+
if (bodyA.type !== 0 && bodyB.type === 2) {
|
746
|
+
if (bodyA.boneIndex !== -1 && bodyB.boneIndex !== -1 && data.bones[bodyB.boneIndex].parentIndex === bodyA.boneIndex) {
|
747
|
+
bodyB.type = 1;
|
748
|
+
}
|
749
|
+
}
|
750
|
+
|
751
|
+
constraints.push(_params2);
|
752
|
+
} // build BufferGeometry.
|
753
|
+
|
754
|
+
|
755
|
+
var geometry = new _three.BufferGeometry();
|
756
|
+
geometry.setAttribute('position', new _three.Float32BufferAttribute(positions, 3));
|
757
|
+
geometry.setAttribute('normal', new _three.Float32BufferAttribute(normals, 3));
|
758
|
+
geometry.setAttribute('uv', new _three.Float32BufferAttribute(uvs, 2));
|
759
|
+
geometry.setAttribute('skinIndex', new _three.Uint16BufferAttribute(skinIndices, 4));
|
760
|
+
geometry.setAttribute('skinWeight', new _three.Float32BufferAttribute(skinWeights, 4));
|
761
|
+
geometry.setIndex(indices);
|
762
|
+
|
763
|
+
for (var _i14 = 0, il = groups.length; _i14 < il; _i14++) {
|
764
|
+
geometry.addGroup(groups[_i14].offset, groups[_i14].count, _i14);
|
765
|
+
}
|
766
|
+
|
767
|
+
geometry.bones = bones;
|
768
|
+
geometry.morphTargets = morphTargets;
|
769
|
+
geometry.morphAttributes.position = morphPositions;
|
770
|
+
geometry.morphTargetsRelative = false;
|
771
|
+
geometry.userData.MMD = {
|
772
|
+
bones: bones,
|
773
|
+
iks: iks,
|
774
|
+
grants: grants,
|
775
|
+
rigidBodies: rigidBodies,
|
776
|
+
constraints: constraints,
|
777
|
+
format: data.metadata.format
|
778
|
+
};
|
779
|
+
geometry.computeBoundingSphere();
|
780
|
+
return geometry;
|
781
|
+
}
|
782
|
+
}]);
|
783
|
+
|
784
|
+
return GeometryBuilder;
|
785
|
+
}(); //
|
786
|
+
|
787
|
+
/**
|
788
|
+
* @param {THREE.LoadingManager} manager
|
789
|
+
*/
|
790
|
+
|
791
|
+
|
792
|
+
var MaterialBuilder = /*#__PURE__*/function () {
|
793
|
+
function MaterialBuilder(manager) {
|
794
|
+
_classCallCheck(this, MaterialBuilder);
|
795
|
+
|
796
|
+
this.manager = manager;
|
797
|
+
this.textureLoader = new _three.TextureLoader(this.manager);
|
798
|
+
this.tgaLoader = null; // lazy generation
|
799
|
+
|
800
|
+
this.crossOrigin = 'anonymous';
|
801
|
+
this.resourcePath = undefined;
|
802
|
+
}
|
803
|
+
/**
|
804
|
+
* @param {string} crossOrigin
|
805
|
+
* @return {MaterialBuilder}
|
806
|
+
*/
|
807
|
+
|
808
|
+
|
809
|
+
_createClass(MaterialBuilder, [{
|
810
|
+
key: "setCrossOrigin",
|
811
|
+
value: function setCrossOrigin(crossOrigin) {
|
812
|
+
this.crossOrigin = crossOrigin;
|
813
|
+
return this;
|
814
|
+
}
|
815
|
+
/**
|
816
|
+
* @param {string} resourcePath
|
817
|
+
* @return {MaterialBuilder}
|
818
|
+
*/
|
819
|
+
|
820
|
+
}, {
|
821
|
+
key: "setResourcePath",
|
822
|
+
value: function setResourcePath(resourcePath) {
|
823
|
+
this.resourcePath = resourcePath;
|
824
|
+
return this;
|
825
|
+
}
|
826
|
+
/**
|
827
|
+
* @param {Object} data - parsed PMD/PMX data
|
828
|
+
* @param {BufferGeometry} geometry - some properties are dependend on geometry
|
829
|
+
* @param {function} onProgress
|
830
|
+
* @param {function} onError
|
831
|
+
* @return {Array<MMDToonMaterial>}
|
832
|
+
*/
|
833
|
+
|
834
|
+
}, {
|
835
|
+
key: "build",
|
836
|
+
value: function build(data, geometry
|
837
|
+
/*, onProgress, onError */
|
838
|
+
) {
|
839
|
+
var materials = [];
|
840
|
+
var textures = {};
|
841
|
+
this.textureLoader.setCrossOrigin(this.crossOrigin); // materials
|
842
|
+
|
843
|
+
for (var i = 0; i < data.metadata.materialCount; i++) {
|
844
|
+
var material = data.materials[i];
|
845
|
+
var params = {
|
846
|
+
userData: {
|
847
|
+
MMD: {}
|
848
|
+
}
|
849
|
+
};
|
850
|
+
if (material.name !== undefined) params.name = material.name;
|
851
|
+
/*
|
852
|
+
* Color
|
853
|
+
*
|
854
|
+
* MMD MMDToonMaterial
|
855
|
+
* ambient - emissive * a
|
856
|
+
* (a = 1.0 without map texture or 0.2 with map texture)
|
857
|
+
*
|
858
|
+
* MMDToonMaterial doesn't have ambient. Set it to emissive instead.
|
859
|
+
* It'll be too bright if material has map texture so using coef 0.2.
|
860
|
+
*/
|
861
|
+
|
862
|
+
params.diffuse = new _three.Color().fromArray(material.diffuse);
|
863
|
+
params.opacity = material.diffuse[3];
|
864
|
+
params.specular = new _three.Color().fromArray(material.specular);
|
865
|
+
params.shininess = material.shininess;
|
866
|
+
params.emissive = new _three.Color().fromArray(material.ambient);
|
867
|
+
params.transparent = params.opacity !== 1.0; //
|
868
|
+
|
869
|
+
params.fog = true; // blend
|
870
|
+
|
871
|
+
params.blending = _three.CustomBlending;
|
872
|
+
params.blendSrc = _three.SrcAlphaFactor;
|
873
|
+
params.blendDst = _three.OneMinusSrcAlphaFactor;
|
874
|
+
params.blendSrcAlpha = _three.SrcAlphaFactor;
|
875
|
+
params.blendDstAlpha = _three.DstAlphaFactor; // side
|
876
|
+
|
877
|
+
if (data.metadata.format === 'pmx' && (material.flag & 0x1) === 1) {
|
878
|
+
params.side = _three.DoubleSide;
|
879
|
+
} else {
|
880
|
+
params.side = params.opacity === 1.0 ? _three.FrontSide : _three.DoubleSide;
|
881
|
+
}
|
882
|
+
|
883
|
+
if (data.metadata.format === 'pmd') {
|
884
|
+
// map, envMap
|
885
|
+
if (material.fileName) {
|
886
|
+
var fileName = material.fileName;
|
887
|
+
var fileNames = fileName.split('*'); // fileNames[ 0 ]: mapFileName
|
888
|
+
// fileNames[ 1 ]: envMapFileName( optional )
|
889
|
+
|
890
|
+
params.map = this._loadTexture(fileNames[0], textures);
|
891
|
+
|
892
|
+
if (fileNames.length > 1) {
|
893
|
+
var extension = fileNames[1].slice(-4).toLowerCase();
|
894
|
+
params.envMap = this._loadTexture(fileNames[1], textures);
|
895
|
+
params.combine = extension === '.sph' ? _three.MultiplyOperation : _three.AddOperation;
|
896
|
+
}
|
897
|
+
} // gradientMap
|
898
|
+
|
899
|
+
|
900
|
+
var toonFileName = material.toonIndex === -1 ? 'toon00.bmp' : data.toonTextures[material.toonIndex].fileName;
|
901
|
+
params.gradientMap = this._loadTexture(toonFileName, textures, {
|
902
|
+
isToonTexture: true,
|
903
|
+
isDefaultToonTexture: this._isDefaultToonTexture(toonFileName)
|
904
|
+
}); // parameters for OutlineEffect
|
905
|
+
|
906
|
+
params.userData.outlineParameters = {
|
907
|
+
thickness: material.edgeFlag === 1 ? 0.003 : 0.0,
|
908
|
+
color: [0, 0, 0],
|
909
|
+
alpha: 1.0,
|
910
|
+
visible: material.edgeFlag === 1
|
911
|
+
};
|
912
|
+
} else {
|
913
|
+
// map
|
914
|
+
if (material.textureIndex !== -1) {
|
915
|
+
params.map = this._loadTexture(data.textures[material.textureIndex], textures); // Since PMX spec don't have standard to list map files except color map and env map,
|
916
|
+
// we need to save file name for further mapping, like matching normal map file names after model loaded.
|
917
|
+
// ref: https://gist.github.com/felixjones/f8a06bd48f9da9a4539f#texture
|
918
|
+
|
919
|
+
params.userData.MMD.mapFileName = data.textures[material.textureIndex];
|
920
|
+
} // envMap TODO: support m.envFlag === 3
|
921
|
+
|
922
|
+
|
923
|
+
if (material.envTextureIndex !== -1 && (material.envFlag === 1 || material.envFlag == 2)) {
|
924
|
+
params.matcap = this._loadTexture(data.textures[material.envTextureIndex], textures); // Same as color map above, keep file name in userData for further usage.
|
925
|
+
|
926
|
+
params.userData.MMD.matcapFileName = data.textures[material.envTextureIndex];
|
927
|
+
params.matcapCombine = material.envFlag === 1 ? _three.MultiplyOperation : _three.AddOperation;
|
928
|
+
} // gradientMap
|
929
|
+
|
930
|
+
|
931
|
+
var _toonFileName = void 0,
|
932
|
+
isDefaultToon = void 0;
|
933
|
+
|
934
|
+
if (material.toonIndex === -1 || material.toonFlag !== 0) {
|
935
|
+
_toonFileName = 'toon' + ('0' + (material.toonIndex + 1)).slice(-2) + '.bmp';
|
936
|
+
isDefaultToon = true;
|
937
|
+
} else {
|
938
|
+
_toonFileName = data.textures[material.toonIndex];
|
939
|
+
isDefaultToon = false;
|
940
|
+
}
|
941
|
+
|
942
|
+
params.gradientMap = this._loadTexture(_toonFileName, textures, {
|
943
|
+
isToonTexture: true,
|
944
|
+
isDefaultToonTexture: isDefaultToon
|
945
|
+
}); // parameters for OutlineEffect
|
946
|
+
|
947
|
+
params.userData.outlineParameters = {
|
948
|
+
thickness: material.edgeSize / 300,
|
949
|
+
// TODO: better calculation?
|
950
|
+
color: material.edgeColor.slice(0, 3),
|
951
|
+
alpha: material.edgeColor[3],
|
952
|
+
visible: (material.flag & 0x10) !== 0 && material.edgeSize > 0.0
|
953
|
+
};
|
954
|
+
}
|
955
|
+
|
956
|
+
if (params.map !== undefined) {
|
957
|
+
if (!params.transparent) {
|
958
|
+
this._checkImageTransparency(params.map, geometry, i);
|
959
|
+
}
|
960
|
+
|
961
|
+
params.emissive.multiplyScalar(0.2);
|
962
|
+
}
|
963
|
+
|
964
|
+
materials.push(new MMDToonMaterial(params));
|
965
|
+
}
|
966
|
+
|
967
|
+
if (data.metadata.format === 'pmx') {
|
968
|
+
// set transparent true if alpha morph is defined.
|
969
|
+
var checkAlphaMorph = function checkAlphaMorph(elements, materials) {
|
970
|
+
for (var _i15 = 0, il = elements.length; _i15 < il; _i15++) {
|
971
|
+
var element = elements[_i15];
|
972
|
+
if (element.index === -1) continue;
|
973
|
+
var _material = materials[element.index];
|
974
|
+
|
975
|
+
if (_material.opacity !== element.diffuse[3]) {
|
976
|
+
_material.transparent = true;
|
977
|
+
}
|
978
|
+
}
|
979
|
+
};
|
980
|
+
|
981
|
+
for (var _i16 = 0, il = data.morphs.length; _i16 < il; _i16++) {
|
982
|
+
var morph = data.morphs[_i16];
|
983
|
+
var elements = morph.elements;
|
984
|
+
|
985
|
+
if (morph.type === 0) {
|
986
|
+
for (var j = 0, jl = elements.length; j < jl; j++) {
|
987
|
+
var morph2 = data.morphs[elements[j].index];
|
988
|
+
if (morph2.type !== 8) continue;
|
989
|
+
checkAlphaMorph(morph2.elements, materials);
|
990
|
+
}
|
991
|
+
} else if (morph.type === 8) {
|
992
|
+
checkAlphaMorph(elements, materials);
|
993
|
+
}
|
994
|
+
}
|
995
|
+
}
|
996
|
+
|
997
|
+
return materials;
|
998
|
+
} // private methods
|
999
|
+
|
1000
|
+
}, {
|
1001
|
+
key: "_getTGALoader",
|
1002
|
+
value: function _getTGALoader() {
|
1003
|
+
if (this.tgaLoader === null) {
|
1004
|
+
if (_TGALoader.TGALoader === undefined) {
|
1005
|
+
throw new Error('THREE.MMDLoader: Import TGALoader');
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
this.tgaLoader = new _TGALoader.TGALoader(this.manager);
|
1009
|
+
}
|
1010
|
+
|
1011
|
+
return this.tgaLoader;
|
1012
|
+
}
|
1013
|
+
}, {
|
1014
|
+
key: "_isDefaultToonTexture",
|
1015
|
+
value: function _isDefaultToonTexture(name) {
|
1016
|
+
if (name.length !== 10) return false;
|
1017
|
+
return /toon(10|0[0-9])\.bmp/.test(name);
|
1018
|
+
}
|
1019
|
+
}, {
|
1020
|
+
key: "_loadTexture",
|
1021
|
+
value: function _loadTexture(filePath, textures, params, onProgress, onError) {
|
1022
|
+
params = params || {};
|
1023
|
+
var scope = this;
|
1024
|
+
var fullPath;
|
1025
|
+
|
1026
|
+
if (params.isDefaultToonTexture === true) {
|
1027
|
+
var index;
|
1028
|
+
|
1029
|
+
try {
|
1030
|
+
index = parseInt(filePath.match(/toon([0-9]{2})\.bmp$/)[1]);
|
1031
|
+
} catch (e) {
|
1032
|
+
console.warn('THREE.MMDLoader: ' + filePath + ' seems like a ' + 'not right default texture path. Using toon00.bmp instead.');
|
1033
|
+
index = 0;
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
fullPath = DEFAULT_TOON_TEXTURES[index];
|
1037
|
+
} else {
|
1038
|
+
fullPath = this.resourcePath + filePath;
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
if (textures[fullPath] !== undefined) return textures[fullPath];
|
1042
|
+
var loader = this.manager.getHandler(fullPath);
|
1043
|
+
|
1044
|
+
if (loader === null) {
|
1045
|
+
loader = filePath.slice(-4).toLowerCase() === '.tga' ? this._getTGALoader() : this.textureLoader;
|
1046
|
+
}
|
1047
|
+
|
1048
|
+
var texture = loader.load(fullPath, function (t) {
|
1049
|
+
// MMD toon texture is Axis-Y oriented
|
1050
|
+
// but Three.js gradient map is Axis-X oriented.
|
1051
|
+
// So here replaces the toon texture image with the rotated one.
|
1052
|
+
if (params.isToonTexture === true) {
|
1053
|
+
t.image = scope._getRotatedImage(t.image);
|
1054
|
+
t.magFilter = _three.NearestFilter;
|
1055
|
+
t.minFilter = _three.NearestFilter;
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
t.flipY = false;
|
1059
|
+
t.wrapS = _three.RepeatWrapping;
|
1060
|
+
t.wrapT = _three.RepeatWrapping;
|
1061
|
+
|
1062
|
+
for (var i = 0; i < texture.readyCallbacks.length; i++) {
|
1063
|
+
texture.readyCallbacks[i](texture);
|
1064
|
+
}
|
1065
|
+
|
1066
|
+
delete texture.readyCallbacks;
|
1067
|
+
}, onProgress, onError);
|
1068
|
+
texture.readyCallbacks = [];
|
1069
|
+
textures[fullPath] = texture;
|
1070
|
+
return texture;
|
1071
|
+
}
|
1072
|
+
}, {
|
1073
|
+
key: "_getRotatedImage",
|
1074
|
+
value: function _getRotatedImage(image) {
|
1075
|
+
var canvas = document.createElement('canvas');
|
1076
|
+
var context = canvas.getContext('2d');
|
1077
|
+
var width = image.width;
|
1078
|
+
var height = image.height;
|
1079
|
+
canvas.width = width;
|
1080
|
+
canvas.height = height;
|
1081
|
+
context.clearRect(0, 0, width, height);
|
1082
|
+
context.translate(width / 2.0, height / 2.0);
|
1083
|
+
context.rotate(0.5 * Math.PI); // 90.0 * Math.PI / 180.0
|
1084
|
+
|
1085
|
+
context.translate(-width / 2.0, -height / 2.0);
|
1086
|
+
context.drawImage(image, 0, 0);
|
1087
|
+
return context.getImageData(0, 0, width, height);
|
1088
|
+
} // Check if the partial image area used by the texture is transparent.
|
1089
|
+
|
1090
|
+
}, {
|
1091
|
+
key: "_checkImageTransparency",
|
1092
|
+
value: function _checkImageTransparency(map, geometry, groupIndex) {
|
1093
|
+
map.readyCallbacks.push(function (texture) {
|
1094
|
+
// Is there any efficient ways?
|
1095
|
+
function createImageData(image) {
|
1096
|
+
var canvas = document.createElement('canvas');
|
1097
|
+
canvas.width = image.width;
|
1098
|
+
canvas.height = image.height;
|
1099
|
+
var context = canvas.getContext('2d');
|
1100
|
+
context.drawImage(image, 0, 0);
|
1101
|
+
return context.getImageData(0, 0, canvas.width, canvas.height);
|
1102
|
+
}
|
1103
|
+
|
1104
|
+
function detectImageTransparency(image, uvs, indices) {
|
1105
|
+
var width = image.width;
|
1106
|
+
var height = image.height;
|
1107
|
+
var data = image.data;
|
1108
|
+
var threshold = 253;
|
1109
|
+
if (data.length / (width * height) !== 4) return false;
|
1110
|
+
|
1111
|
+
for (var i = 0; i < indices.length; i += 3) {
|
1112
|
+
var centerUV = {
|
1113
|
+
x: 0.0,
|
1114
|
+
y: 0.0
|
1115
|
+
};
|
1116
|
+
|
1117
|
+
for (var j = 0; j < 3; j++) {
|
1118
|
+
var index = indices[i * 3 + j];
|
1119
|
+
var uv = {
|
1120
|
+
x: uvs[index * 2 + 0],
|
1121
|
+
y: uvs[index * 2 + 1]
|
1122
|
+
};
|
1123
|
+
if (getAlphaByUv(image, uv) < threshold) return true;
|
1124
|
+
centerUV.x += uv.x;
|
1125
|
+
centerUV.y += uv.y;
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
centerUV.x /= 3;
|
1129
|
+
centerUV.y /= 3;
|
1130
|
+
if (getAlphaByUv(image, centerUV) < threshold) return true;
|
1131
|
+
}
|
1132
|
+
|
1133
|
+
return false;
|
1134
|
+
}
|
1135
|
+
/*
|
1136
|
+
* This method expects
|
1137
|
+
* texture.flipY = false
|
1138
|
+
* texture.wrapS = RepeatWrapping
|
1139
|
+
* texture.wrapT = RepeatWrapping
|
1140
|
+
* TODO: more precise
|
1141
|
+
*/
|
1142
|
+
|
1143
|
+
|
1144
|
+
function getAlphaByUv(image, uv) {
|
1145
|
+
var width = image.width;
|
1146
|
+
var height = image.height;
|
1147
|
+
var x = Math.round(uv.x * width) % width;
|
1148
|
+
var y = Math.round(uv.y * height) % height;
|
1149
|
+
if (x < 0) x += width;
|
1150
|
+
if (y < 0) y += height;
|
1151
|
+
var index = y * width + x;
|
1152
|
+
return image.data[index * 4 + 3];
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
if (texture.isCompressedTexture === true) {
|
1156
|
+
if (NON_ALPHA_CHANNEL_FORMATS.includes(texture.format)) {
|
1157
|
+
map.transparent = false;
|
1158
|
+
} else {
|
1159
|
+
// any other way to check transparency of CompressedTexture?
|
1160
|
+
map.transparent = true;
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
return;
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
var imageData = texture.image.data !== undefined ? texture.image : createImageData(texture.image);
|
1167
|
+
var group = geometry.groups[groupIndex];
|
1168
|
+
|
1169
|
+
if (detectImageTransparency(imageData, geometry.attributes.uv.array, geometry.index.array.slice(group.start, group.start + group.count))) {
|
1170
|
+
map.transparent = true;
|
1171
|
+
}
|
1172
|
+
});
|
1173
|
+
}
|
1174
|
+
}]);
|
1175
|
+
|
1176
|
+
return MaterialBuilder;
|
1177
|
+
}(); //
|
1178
|
+
|
1179
|
+
|
1180
|
+
var AnimationBuilder = /*#__PURE__*/function () {
|
1181
|
+
function AnimationBuilder() {
|
1182
|
+
_classCallCheck(this, AnimationBuilder);
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
_createClass(AnimationBuilder, [{
|
1186
|
+
key: "build",
|
1187
|
+
value:
|
1188
|
+
/**
|
1189
|
+
* @param {Object} vmd - parsed VMD data
|
1190
|
+
* @param {SkinnedMesh} mesh - tracks will be fitting to mesh
|
1191
|
+
* @return {AnimationClip}
|
1192
|
+
*/
|
1193
|
+
function build(vmd, mesh) {
|
1194
|
+
// combine skeletal and morph animations
|
1195
|
+
var tracks = this.buildSkeletalAnimation(vmd, mesh).tracks;
|
1196
|
+
var tracks2 = this.buildMorphAnimation(vmd, mesh).tracks;
|
1197
|
+
|
1198
|
+
for (var i = 0, il = tracks2.length; i < il; i++) {
|
1199
|
+
tracks.push(tracks2[i]);
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
return new _three.AnimationClip('', -1, tracks);
|
1203
|
+
}
|
1204
|
+
/**
|
1205
|
+
* @param {Object} vmd - parsed VMD data
|
1206
|
+
* @param {SkinnedMesh} mesh - tracks will be fitting to mesh
|
1207
|
+
* @return {AnimationClip}
|
1208
|
+
*/
|
1209
|
+
|
1210
|
+
}, {
|
1211
|
+
key: "buildSkeletalAnimation",
|
1212
|
+
value: function buildSkeletalAnimation(vmd, mesh) {
|
1213
|
+
function pushInterpolation(array, interpolation, index) {
|
1214
|
+
array.push(interpolation[index + 0] / 127); // x1
|
1215
|
+
|
1216
|
+
array.push(interpolation[index + 8] / 127); // x2
|
1217
|
+
|
1218
|
+
array.push(interpolation[index + 4] / 127); // y1
|
1219
|
+
|
1220
|
+
array.push(interpolation[index + 12] / 127); // y2
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
var tracks = [];
|
1224
|
+
var motions = {};
|
1225
|
+
var bones = mesh.skeleton.bones;
|
1226
|
+
var boneNameDictionary = {};
|
1227
|
+
|
1228
|
+
for (var i = 0, il = bones.length; i < il; i++) {
|
1229
|
+
boneNameDictionary[bones[i].name] = true;
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
for (var _i17 = 0; _i17 < vmd.metadata.motionCount; _i17++) {
|
1233
|
+
var motion = vmd.motions[_i17];
|
1234
|
+
var boneName = motion.boneName;
|
1235
|
+
if (boneNameDictionary[boneName] === undefined) continue;
|
1236
|
+
motions[boneName] = motions[boneName] || [];
|
1237
|
+
motions[boneName].push(motion);
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
for (var key in motions) {
|
1241
|
+
var array = motions[key];
|
1242
|
+
array.sort(function (a, b) {
|
1243
|
+
return a.frameNum - b.frameNum;
|
1244
|
+
});
|
1245
|
+
var times = [];
|
1246
|
+
var positions = [];
|
1247
|
+
var rotations = [];
|
1248
|
+
var pInterpolations = [];
|
1249
|
+
var rInterpolations = [];
|
1250
|
+
var basePosition = mesh.skeleton.getBoneByName(key).position.toArray();
|
1251
|
+
|
1252
|
+
for (var _i18 = 0, _il2 = array.length; _i18 < _il2; _i18++) {
|
1253
|
+
var time = array[_i18].frameNum / 30;
|
1254
|
+
var position = array[_i18].position;
|
1255
|
+
var rotation = array[_i18].rotation;
|
1256
|
+
var interpolation = array[_i18].interpolation;
|
1257
|
+
times.push(time);
|
1258
|
+
|
1259
|
+
for (var j = 0; j < 3; j++) {
|
1260
|
+
positions.push(basePosition[j] + position[j]);
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
for (var _j10 = 0; _j10 < 4; _j10++) {
|
1264
|
+
rotations.push(rotation[_j10]);
|
1265
|
+
}
|
1266
|
+
|
1267
|
+
for (var _j11 = 0; _j11 < 3; _j11++) {
|
1268
|
+
pushInterpolation(pInterpolations, interpolation, _j11);
|
1269
|
+
}
|
1270
|
+
|
1271
|
+
pushInterpolation(rInterpolations, interpolation, 3);
|
1272
|
+
}
|
1273
|
+
|
1274
|
+
var targetName = '.bones[' + key + ']';
|
1275
|
+
tracks.push(this._createTrack(targetName + '.position', _three.VectorKeyframeTrack, times, positions, pInterpolations));
|
1276
|
+
tracks.push(this._createTrack(targetName + '.quaternion', _three.QuaternionKeyframeTrack, times, rotations, rInterpolations));
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
return new _three.AnimationClip('', -1, tracks);
|
1280
|
+
}
|
1281
|
+
/**
|
1282
|
+
* @param {Object} vmd - parsed VMD data
|
1283
|
+
* @param {SkinnedMesh} mesh - tracks will be fitting to mesh
|
1284
|
+
* @return {AnimationClip}
|
1285
|
+
*/
|
1286
|
+
|
1287
|
+
}, {
|
1288
|
+
key: "buildMorphAnimation",
|
1289
|
+
value: function buildMorphAnimation(vmd, mesh) {
|
1290
|
+
var tracks = [];
|
1291
|
+
var morphs = {};
|
1292
|
+
var morphTargetDictionary = mesh.morphTargetDictionary;
|
1293
|
+
|
1294
|
+
for (var i = 0; i < vmd.metadata.morphCount; i++) {
|
1295
|
+
var morph = vmd.morphs[i];
|
1296
|
+
var morphName = morph.morphName;
|
1297
|
+
if (morphTargetDictionary[morphName] === undefined) continue;
|
1298
|
+
morphs[morphName] = morphs[morphName] || [];
|
1299
|
+
morphs[morphName].push(morph);
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
for (var key in morphs) {
|
1303
|
+
var array = morphs[key];
|
1304
|
+
array.sort(function (a, b) {
|
1305
|
+
return a.frameNum - b.frameNum;
|
1306
|
+
});
|
1307
|
+
var times = [];
|
1308
|
+
var values = [];
|
1309
|
+
|
1310
|
+
for (var _i19 = 0, il = array.length; _i19 < il; _i19++) {
|
1311
|
+
times.push(array[_i19].frameNum / 30);
|
1312
|
+
values.push(array[_i19].weight);
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
tracks.push(new _three.NumberKeyframeTrack('.morphTargetInfluences[' + morphTargetDictionary[key] + ']', times, values));
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
return new _three.AnimationClip('', -1, tracks);
|
1319
|
+
}
|
1320
|
+
/**
|
1321
|
+
* @param {Object} vmd - parsed VMD data
|
1322
|
+
* @return {AnimationClip}
|
1323
|
+
*/
|
1324
|
+
|
1325
|
+
}, {
|
1326
|
+
key: "buildCameraAnimation",
|
1327
|
+
value: function buildCameraAnimation(vmd) {
|
1328
|
+
function pushVector3(array, vec) {
|
1329
|
+
array.push(vec.x);
|
1330
|
+
array.push(vec.y);
|
1331
|
+
array.push(vec.z);
|
1332
|
+
}
|
1333
|
+
|
1334
|
+
function pushQuaternion(array, q) {
|
1335
|
+
array.push(q.x);
|
1336
|
+
array.push(q.y);
|
1337
|
+
array.push(q.z);
|
1338
|
+
array.push(q.w);
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
function pushInterpolation(array, interpolation, index) {
|
1342
|
+
array.push(interpolation[index * 4 + 0] / 127); // x1
|
1343
|
+
|
1344
|
+
array.push(interpolation[index * 4 + 1] / 127); // x2
|
1345
|
+
|
1346
|
+
array.push(interpolation[index * 4 + 2] / 127); // y1
|
1347
|
+
|
1348
|
+
array.push(interpolation[index * 4 + 3] / 127); // y2
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
var cameras = vmd.cameras === undefined ? [] : vmd.cameras.slice();
|
1352
|
+
cameras.sort(function (a, b) {
|
1353
|
+
return a.frameNum - b.frameNum;
|
1354
|
+
});
|
1355
|
+
var times = [];
|
1356
|
+
var centers = [];
|
1357
|
+
var quaternions = [];
|
1358
|
+
var positions = [];
|
1359
|
+
var fovs = [];
|
1360
|
+
var cInterpolations = [];
|
1361
|
+
var qInterpolations = [];
|
1362
|
+
var pInterpolations = [];
|
1363
|
+
var fInterpolations = [];
|
1364
|
+
var quaternion = new _three.Quaternion();
|
1365
|
+
var euler = new _three.Euler();
|
1366
|
+
var position = new _three.Vector3();
|
1367
|
+
var center = new _three.Vector3();
|
1368
|
+
|
1369
|
+
for (var i = 0, il = cameras.length; i < il; i++) {
|
1370
|
+
var motion = cameras[i];
|
1371
|
+
var time = motion.frameNum / 30;
|
1372
|
+
var pos = motion.position;
|
1373
|
+
var rot = motion.rotation;
|
1374
|
+
var distance = motion.distance;
|
1375
|
+
var fov = motion.fov;
|
1376
|
+
var interpolation = motion.interpolation;
|
1377
|
+
times.push(time);
|
1378
|
+
position.set(0, 0, -distance);
|
1379
|
+
center.set(pos[0], pos[1], pos[2]);
|
1380
|
+
euler.set(-rot[0], -rot[1], -rot[2]);
|
1381
|
+
quaternion.setFromEuler(euler);
|
1382
|
+
position.add(center);
|
1383
|
+
position.applyQuaternion(quaternion);
|
1384
|
+
pushVector3(centers, center);
|
1385
|
+
pushQuaternion(quaternions, quaternion);
|
1386
|
+
pushVector3(positions, position);
|
1387
|
+
fovs.push(fov);
|
1388
|
+
|
1389
|
+
for (var j = 0; j < 3; j++) {
|
1390
|
+
pushInterpolation(cInterpolations, interpolation, j);
|
1391
|
+
}
|
1392
|
+
|
1393
|
+
pushInterpolation(qInterpolations, interpolation, 3); // use the same parameter for x, y, z axis.
|
1394
|
+
|
1395
|
+
for (var _j12 = 0; _j12 < 3; _j12++) {
|
1396
|
+
pushInterpolation(pInterpolations, interpolation, 4);
|
1397
|
+
}
|
1398
|
+
|
1399
|
+
pushInterpolation(fInterpolations, interpolation, 5);
|
1400
|
+
}
|
1401
|
+
|
1402
|
+
var tracks = []; // I expect an object whose name 'target' exists under THREE.Camera
|
1403
|
+
|
1404
|
+
tracks.push(this._createTrack('target.position', _three.VectorKeyframeTrack, times, centers, cInterpolations));
|
1405
|
+
tracks.push(this._createTrack('.quaternion', _three.QuaternionKeyframeTrack, times, quaternions, qInterpolations));
|
1406
|
+
tracks.push(this._createTrack('.position', _three.VectorKeyframeTrack, times, positions, pInterpolations));
|
1407
|
+
tracks.push(this._createTrack('.fov', _three.NumberKeyframeTrack, times, fovs, fInterpolations));
|
1408
|
+
return new _three.AnimationClip('', -1, tracks);
|
1409
|
+
} // private method
|
1410
|
+
|
1411
|
+
}, {
|
1412
|
+
key: "_createTrack",
|
1413
|
+
value: function _createTrack(node, typedKeyframeTrack, times, values, interpolations) {
|
1414
|
+
/*
|
1415
|
+
* optimizes here not to let KeyframeTrackPrototype optimize
|
1416
|
+
* because KeyframeTrackPrototype optimizes times and values but
|
1417
|
+
* doesn't optimize interpolations.
|
1418
|
+
*/
|
1419
|
+
if (times.length > 2) {
|
1420
|
+
times = times.slice();
|
1421
|
+
values = values.slice();
|
1422
|
+
interpolations = interpolations.slice();
|
1423
|
+
var stride = values.length / times.length;
|
1424
|
+
var interpolateStride = interpolations.length / times.length;
|
1425
|
+
var index = 1;
|
1426
|
+
|
1427
|
+
for (var aheadIndex = 2, endIndex = times.length; aheadIndex < endIndex; aheadIndex++) {
|
1428
|
+
for (var i = 0; i < stride; i++) {
|
1429
|
+
if (values[index * stride + i] !== values[(index - 1) * stride + i] || values[index * stride + i] !== values[aheadIndex * stride + i]) {
|
1430
|
+
index++;
|
1431
|
+
break;
|
1432
|
+
}
|
1433
|
+
}
|
1434
|
+
|
1435
|
+
if (aheadIndex > index) {
|
1436
|
+
times[index] = times[aheadIndex];
|
1437
|
+
|
1438
|
+
for (var _i20 = 0; _i20 < stride; _i20++) {
|
1439
|
+
values[index * stride + _i20] = values[aheadIndex * stride + _i20];
|
1440
|
+
}
|
1441
|
+
|
1442
|
+
for (var _i21 = 0; _i21 < interpolateStride; _i21++) {
|
1443
|
+
interpolations[index * interpolateStride + _i21] = interpolations[aheadIndex * interpolateStride + _i21];
|
1444
|
+
}
|
1445
|
+
}
|
1446
|
+
}
|
1447
|
+
|
1448
|
+
times.length = index + 1;
|
1449
|
+
values.length = (index + 1) * stride;
|
1450
|
+
interpolations.length = (index + 1) * interpolateStride;
|
1451
|
+
}
|
1452
|
+
|
1453
|
+
var track = new typedKeyframeTrack(node, times, values);
|
1454
|
+
|
1455
|
+
track.createInterpolant = function InterpolantFactoryMethodCubicBezier(result) {
|
1456
|
+
return new CubicBezierInterpolation(this.times, this.values, this.getValueSize(), result, new Float32Array(interpolations));
|
1457
|
+
};
|
1458
|
+
|
1459
|
+
return track;
|
1460
|
+
}
|
1461
|
+
}]);
|
1462
|
+
|
1463
|
+
return AnimationBuilder;
|
1464
|
+
}(); // interpolation
|
1465
|
+
|
1466
|
+
|
1467
|
+
var CubicBezierInterpolation = /*#__PURE__*/function (_Interpolant) {
|
1468
|
+
_inherits(CubicBezierInterpolation, _Interpolant);
|
1469
|
+
|
1470
|
+
var _super2 = _createSuper(CubicBezierInterpolation);
|
1471
|
+
|
1472
|
+
function CubicBezierInterpolation(parameterPositions, sampleValues, sampleSize, resultBuffer, params) {
|
1473
|
+
var _this2;
|
1474
|
+
|
1475
|
+
_classCallCheck(this, CubicBezierInterpolation);
|
1476
|
+
|
1477
|
+
_this2 = _super2.call(this, parameterPositions, sampleValues, sampleSize, resultBuffer);
|
1478
|
+
_this2.interpolationParams = params;
|
1479
|
+
return _this2;
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
_createClass(CubicBezierInterpolation, [{
|
1483
|
+
key: "interpolate_",
|
1484
|
+
value: function interpolate_(i1, t0, t, t1) {
|
1485
|
+
var result = this.resultBuffer;
|
1486
|
+
var values = this.sampleValues;
|
1487
|
+
var stride = this.valueSize;
|
1488
|
+
var params = this.interpolationParams;
|
1489
|
+
var offset1 = i1 * stride;
|
1490
|
+
var offset0 = offset1 - stride; // No interpolation if next key frame is in one frame in 30fps.
|
1491
|
+
// This is from MMD animation spec.
|
1492
|
+
// '1.5' is for precision loss. times are Float32 in Three.js Animation system.
|
1493
|
+
|
1494
|
+
var weight1 = t1 - t0 < 1 / 30 * 1.5 ? 0.0 : (t - t0) / (t1 - t0);
|
1495
|
+
|
1496
|
+
if (stride === 4) {
|
1497
|
+
// Quaternion
|
1498
|
+
var x1 = params[i1 * 4 + 0];
|
1499
|
+
var x2 = params[i1 * 4 + 1];
|
1500
|
+
var y1 = params[i1 * 4 + 2];
|
1501
|
+
var y2 = params[i1 * 4 + 3];
|
1502
|
+
|
1503
|
+
var ratio = this._calculate(x1, x2, y1, y2, weight1);
|
1504
|
+
|
1505
|
+
_three.Quaternion.slerpFlat(result, 0, values, offset0, values, offset1, ratio);
|
1506
|
+
} else if (stride === 3) {
|
1507
|
+
// Vector3
|
1508
|
+
for (var i = 0; i !== stride; ++i) {
|
1509
|
+
var _x = params[i1 * 12 + i * 4 + 0];
|
1510
|
+
var _x2 = params[i1 * 12 + i * 4 + 1];
|
1511
|
+
var _y = params[i1 * 12 + i * 4 + 2];
|
1512
|
+
var _y2 = params[i1 * 12 + i * 4 + 3];
|
1513
|
+
|
1514
|
+
var _ratio = this._calculate(_x, _x2, _y, _y2, weight1);
|
1515
|
+
|
1516
|
+
result[i] = values[offset0 + i] * (1 - _ratio) + values[offset1 + i] * _ratio;
|
1517
|
+
}
|
1518
|
+
} else {
|
1519
|
+
// Number
|
1520
|
+
var _x3 = params[i1 * 4 + 0];
|
1521
|
+
var _x4 = params[i1 * 4 + 1];
|
1522
|
+
var _y3 = params[i1 * 4 + 2];
|
1523
|
+
var _y4 = params[i1 * 4 + 3];
|
1524
|
+
|
1525
|
+
var _ratio2 = this._calculate(_x3, _x4, _y3, _y4, weight1);
|
1526
|
+
|
1527
|
+
result[0] = values[offset0] * (1 - _ratio2) + values[offset1] * _ratio2;
|
1528
|
+
}
|
1529
|
+
|
1530
|
+
return result;
|
1531
|
+
}
|
1532
|
+
}, {
|
1533
|
+
key: "_calculate",
|
1534
|
+
value: function _calculate(x1, x2, y1, y2, x) {
|
1535
|
+
/*
|
1536
|
+
* Cubic Bezier curves
|
1537
|
+
* https://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves
|
1538
|
+
*
|
1539
|
+
* B(t) = ( 1 - t ) ^ 3 * P0
|
1540
|
+
* + 3 * ( 1 - t ) ^ 2 * t * P1
|
1541
|
+
* + 3 * ( 1 - t ) * t^2 * P2
|
1542
|
+
* + t ^ 3 * P3
|
1543
|
+
* ( 0 <= t <= 1 )
|
1544
|
+
*
|
1545
|
+
* MMD uses Cubic Bezier curves for bone and camera animation interpolation.
|
1546
|
+
* http://d.hatena.ne.jp/edvakf/20111016/1318716097
|
1547
|
+
*
|
1548
|
+
* x = ( 1 - t ) ^ 3 * x0
|
1549
|
+
* + 3 * ( 1 - t ) ^ 2 * t * x1
|
1550
|
+
* + 3 * ( 1 - t ) * t^2 * x2
|
1551
|
+
* + t ^ 3 * x3
|
1552
|
+
* y = ( 1 - t ) ^ 3 * y0
|
1553
|
+
* + 3 * ( 1 - t ) ^ 2 * t * y1
|
1554
|
+
* + 3 * ( 1 - t ) * t^2 * y2
|
1555
|
+
* + t ^ 3 * y3
|
1556
|
+
* ( x0 = 0, y0 = 0 )
|
1557
|
+
* ( x3 = 1, y3 = 1 )
|
1558
|
+
* ( 0 <= t, x1, x2, y1, y2 <= 1 )
|
1559
|
+
*
|
1560
|
+
* Here solves this equation with Bisection method,
|
1561
|
+
* https://en.wikipedia.org/wiki/Bisection_method
|
1562
|
+
* gets t, and then calculate y.
|
1563
|
+
*
|
1564
|
+
* f(t) = 3 * ( 1 - t ) ^ 2 * t * x1
|
1565
|
+
* + 3 * ( 1 - t ) * t^2 * x2
|
1566
|
+
* + t ^ 3 - x = 0
|
1567
|
+
*
|
1568
|
+
* (Another option: Newton's method
|
1569
|
+
* https://en.wikipedia.org/wiki/Newton%27s_method)
|
1570
|
+
*/
|
1571
|
+
var c = 0.5;
|
1572
|
+
var t = c;
|
1573
|
+
var s = 1.0 - t;
|
1574
|
+
var loop = 15;
|
1575
|
+
var eps = 1e-5;
|
1576
|
+
var math = Math;
|
1577
|
+
var sst3, stt3, ttt;
|
1578
|
+
|
1579
|
+
for (var i = 0; i < loop; i++) {
|
1580
|
+
sst3 = 3.0 * s * s * t;
|
1581
|
+
stt3 = 3.0 * s * t * t;
|
1582
|
+
ttt = t * t * t;
|
1583
|
+
var ft = sst3 * x1 + stt3 * x2 + ttt - x;
|
1584
|
+
if (math.abs(ft) < eps) break;
|
1585
|
+
c /= 2.0;
|
1586
|
+
t += ft < 0 ? c : -c;
|
1587
|
+
s = 1.0 - t;
|
1588
|
+
}
|
1589
|
+
|
1590
|
+
return sst3 * y1 + stt3 * y2 + ttt;
|
1591
|
+
}
|
1592
|
+
}]);
|
1593
|
+
|
1594
|
+
return CubicBezierInterpolation;
|
1595
|
+
}(_three.Interpolant);
|
1596
|
+
|
1597
|
+
var MMDToonMaterial = /*#__PURE__*/function (_ShaderMaterial) {
|
1598
|
+
_inherits(MMDToonMaterial, _ShaderMaterial);
|
1599
|
+
|
1600
|
+
var _super3 = _createSuper(MMDToonMaterial);
|
1601
|
+
|
1602
|
+
function MMDToonMaterial(parameters) {
|
1603
|
+
var _this3;
|
1604
|
+
|
1605
|
+
_classCallCheck(this, MMDToonMaterial);
|
1606
|
+
|
1607
|
+
_this3 = _super3.call(this);
|
1608
|
+
_this3._matcapCombine = _three.AddOperation;
|
1609
|
+
_this3.emissiveIntensity = 1.0;
|
1610
|
+
_this3.normalMapType = _three.TangentSpaceNormalMap;
|
1611
|
+
_this3.combine = _three.MultiplyOperation;
|
1612
|
+
_this3.wireframeLinecap = 'round';
|
1613
|
+
_this3.wireframeLinejoin = 'round';
|
1614
|
+
_this3.flatShading = false;
|
1615
|
+
_this3.lights = true;
|
1616
|
+
_this3.vertexShader = _MMDToonShader.MMDToonShader.vertexShader;
|
1617
|
+
_this3.fragmentShader = _MMDToonShader.MMDToonShader.fragmentShader;
|
1618
|
+
_this3.defines = Object.assign({}, _MMDToonShader.MMDToonShader.defines);
|
1619
|
+
Object.defineProperty(_assertThisInitialized(_this3), 'matcapCombine', {
|
1620
|
+
get: function get() {
|
1621
|
+
return this._matcapCombine;
|
1622
|
+
},
|
1623
|
+
set: function set(value) {
|
1624
|
+
this._matcapCombine = value;
|
1625
|
+
|
1626
|
+
switch (value) {
|
1627
|
+
case _three.MultiplyOperation:
|
1628
|
+
this.defines.MATCAP_BLENDING_MULTIPLY = true;
|
1629
|
+
delete this.defines.MATCAP_BLENDING_ADD;
|
1630
|
+
break;
|
1631
|
+
|
1632
|
+
default:
|
1633
|
+
case _three.AddOperation:
|
1634
|
+
this.defines.MATCAP_BLENDING_ADD = true;
|
1635
|
+
delete this.defines.MATCAP_BLENDING_MULTIPLY;
|
1636
|
+
break;
|
1637
|
+
}
|
1638
|
+
}
|
1639
|
+
});
|
1640
|
+
_this3.uniforms = _three.UniformsUtils.clone(_MMDToonShader.MMDToonShader.uniforms); // merged from MeshToon/Phong/MatcapMaterial
|
1641
|
+
|
1642
|
+
var exposePropertyNames = ['specular', 'shininess', 'opacity', 'diffuse', 'map', 'matcap', 'gradientMap', 'lightMap', 'lightMapIntensity', 'aoMap', 'aoMapIntensity', 'emissive', 'emissiveMap', 'bumpMap', 'bumpScale', 'normalMap', 'normalScale', 'displacemantBias', 'displacemantMap', 'displacemantScale', 'specularMap', 'alphaMap', 'envMap', 'reflectivity', 'refractionRatio'];
|
1643
|
+
|
1644
|
+
var _loop = function _loop() {
|
1645
|
+
var propertyName = _exposePropertyNames[_i22];
|
1646
|
+
Object.defineProperty(_assertThisInitialized(_this3), propertyName, {
|
1647
|
+
get: function get() {
|
1648
|
+
return this.uniforms[propertyName].value;
|
1649
|
+
},
|
1650
|
+
set: function set(value) {
|
1651
|
+
this.uniforms[propertyName].value = value;
|
1652
|
+
}
|
1653
|
+
});
|
1654
|
+
};
|
1655
|
+
|
1656
|
+
for (var _i22 = 0, _exposePropertyNames = exposePropertyNames; _i22 < _exposePropertyNames.length; _i22++) {
|
1657
|
+
_loop();
|
1658
|
+
}
|
1659
|
+
|
1660
|
+
Object.defineProperty(_assertThisInitialized(_this3), 'color', Object.getOwnPropertyDescriptor(_assertThisInitialized(_this3), 'diffuse'));
|
1661
|
+
|
1662
|
+
_this3.setValues(parameters);
|
1663
|
+
|
1664
|
+
return _this3;
|
1665
|
+
}
|
1666
|
+
|
1667
|
+
_createClass(MMDToonMaterial, [{
|
1668
|
+
key: "copy",
|
1669
|
+
value: function copy(source) {
|
1670
|
+
_get(_getPrototypeOf(MMDToonMaterial.prototype), "copy", this).call(this, source);
|
1671
|
+
|
1672
|
+
this.matcapCombine = source.matcapCombine;
|
1673
|
+
this.emissiveIntensity = source.emissiveIntensity;
|
1674
|
+
this.normalMapType = source.normalMapType;
|
1675
|
+
this.combine = source.combine;
|
1676
|
+
this.wireframeLinecap = source.wireframeLinecap;
|
1677
|
+
this.wireframeLinejoin = source.wireframeLinejoin;
|
1678
|
+
this.flatShading = source.flatShading;
|
1679
|
+
return this;
|
1680
|
+
}
|
1681
|
+
}]);
|
1682
|
+
|
1683
|
+
return MMDToonMaterial;
|
1684
|
+
}(_three.ShaderMaterial);
|
1685
|
+
|
1686
|
+
MMDToonMaterial.prototype.isMMDToonMaterial = true;
|
1687
|
+
});
|