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,1183 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
if (typeof define === "function" && define.amd) {
|
3
|
+
define(["exports", "three"], factory);
|
4
|
+
} else if (typeof exports !== "undefined") {
|
5
|
+
factory(exports, require("three"));
|
6
|
+
} else {
|
7
|
+
var mod = {
|
8
|
+
exports: {}
|
9
|
+
};
|
10
|
+
factory(mod.exports, global.three);
|
11
|
+
global.MMDPhysics = mod.exports;
|
12
|
+
}
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _three) {
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
Object.defineProperty(_exports, "__esModule", {
|
17
|
+
value: true
|
18
|
+
});
|
19
|
+
_exports.MMDPhysics = 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 _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); }
|
26
|
+
|
27
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
28
|
+
|
29
|
+
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); }; }
|
30
|
+
|
31
|
+
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); }
|
32
|
+
|
33
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
34
|
+
|
35
|
+
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; } }
|
36
|
+
|
37
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
38
|
+
|
39
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
40
|
+
|
41
|
+
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); } }
|
42
|
+
|
43
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Dependencies
|
47
|
+
* - Ammo.js https://github.com/kripken/ammo.js
|
48
|
+
*
|
49
|
+
* MMDPhysics calculates physics with Ammo(Bullet based JavaScript Physics engine)
|
50
|
+
* for MMD model loaded by MMDLoader.
|
51
|
+
*
|
52
|
+
* TODO
|
53
|
+
* - Physics in Worker
|
54
|
+
*/
|
55
|
+
|
56
|
+
/* global Ammo */
|
57
|
+
var MMDPhysics = /*#__PURE__*/function () {
|
58
|
+
/**
|
59
|
+
* @param {THREE.SkinnedMesh} mesh
|
60
|
+
* @param {Array<Object>} rigidBodyParams
|
61
|
+
* @param {Array<Object>} (optional) constraintParams
|
62
|
+
* @param {Object} params - (optional)
|
63
|
+
* @param {Number} params.unitStep - Default is 1 / 65.
|
64
|
+
* @param {Integer} params.maxStepNum - Default is 3.
|
65
|
+
* @param {Vector3} params.gravity - Default is ( 0, - 9.8 * 10, 0 )
|
66
|
+
*/
|
67
|
+
function MMDPhysics(mesh, rigidBodyParams) {
|
68
|
+
var constraintParams = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
69
|
+
var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
70
|
+
|
71
|
+
_classCallCheck(this, MMDPhysics);
|
72
|
+
|
73
|
+
if (typeof Ammo === 'undefined') {
|
74
|
+
throw new Error('THREE.MMDPhysics: Import ammo.js https://github.com/kripken/ammo.js');
|
75
|
+
}
|
76
|
+
|
77
|
+
this.manager = new ResourceManager();
|
78
|
+
this.mesh = mesh;
|
79
|
+
/*
|
80
|
+
* I don't know why but 1/60 unitStep easily breaks models
|
81
|
+
* so I set it 1/65 so far.
|
82
|
+
* Don't set too small unitStep because
|
83
|
+
* the smaller unitStep can make the performance worse.
|
84
|
+
*/
|
85
|
+
|
86
|
+
this.unitStep = params.unitStep !== undefined ? params.unitStep : 1 / 65;
|
87
|
+
this.maxStepNum = params.maxStepNum !== undefined ? params.maxStepNum : 3;
|
88
|
+
this.gravity = new _three.Vector3(0, -9.8 * 10, 0);
|
89
|
+
if (params.gravity !== undefined) this.gravity.copy(params.gravity);
|
90
|
+
this.world = params.world !== undefined ? params.world : null; // experimental
|
91
|
+
|
92
|
+
this.bodies = [];
|
93
|
+
this.constraints = [];
|
94
|
+
|
95
|
+
this._init(mesh, rigidBodyParams, constraintParams);
|
96
|
+
}
|
97
|
+
/**
|
98
|
+
* Advances Physics calculation and updates bones.
|
99
|
+
*
|
100
|
+
* @param {Number} delta - time in second
|
101
|
+
* @return {MMDPhysics}
|
102
|
+
*/
|
103
|
+
|
104
|
+
|
105
|
+
_createClass(MMDPhysics, [{
|
106
|
+
key: "update",
|
107
|
+
value: function update(delta) {
|
108
|
+
var manager = this.manager;
|
109
|
+
var mesh = this.mesh; // rigid bodies and constrains are for
|
110
|
+
// mesh's world scale (1, 1, 1).
|
111
|
+
// Convert to (1, 1, 1) if it isn't.
|
112
|
+
|
113
|
+
var isNonDefaultScale = false;
|
114
|
+
var position = manager.allocThreeVector3();
|
115
|
+
var quaternion = manager.allocThreeQuaternion();
|
116
|
+
var scale = manager.allocThreeVector3();
|
117
|
+
mesh.matrixWorld.decompose(position, quaternion, scale);
|
118
|
+
|
119
|
+
if (scale.x !== 1 || scale.y !== 1 || scale.z !== 1) {
|
120
|
+
isNonDefaultScale = true;
|
121
|
+
}
|
122
|
+
|
123
|
+
var parent;
|
124
|
+
|
125
|
+
if (isNonDefaultScale) {
|
126
|
+
parent = mesh.parent;
|
127
|
+
if (parent !== null) mesh.parent = null;
|
128
|
+
scale.copy(this.mesh.scale);
|
129
|
+
mesh.scale.set(1, 1, 1);
|
130
|
+
mesh.updateMatrixWorld(true);
|
131
|
+
} // calculate physics and update bones
|
132
|
+
|
133
|
+
|
134
|
+
this._updateRigidBodies();
|
135
|
+
|
136
|
+
this._stepSimulation(delta);
|
137
|
+
|
138
|
+
this._updateBones(); // restore mesh if converted above
|
139
|
+
|
140
|
+
|
141
|
+
if (isNonDefaultScale) {
|
142
|
+
if (parent !== null) mesh.parent = parent;
|
143
|
+
mesh.scale.copy(scale);
|
144
|
+
}
|
145
|
+
|
146
|
+
manager.freeThreeVector3(scale);
|
147
|
+
manager.freeThreeQuaternion(quaternion);
|
148
|
+
manager.freeThreeVector3(position);
|
149
|
+
return this;
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* Resets rigid bodies transorm to current bone's.
|
153
|
+
*
|
154
|
+
* @return {MMDPhysics}
|
155
|
+
*/
|
156
|
+
|
157
|
+
}, {
|
158
|
+
key: "reset",
|
159
|
+
value: function reset() {
|
160
|
+
for (var i = 0, il = this.bodies.length; i < il; i++) {
|
161
|
+
this.bodies[i].reset();
|
162
|
+
}
|
163
|
+
|
164
|
+
return this;
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Warm ups Rigid bodies. Calculates cycles steps.
|
168
|
+
*
|
169
|
+
* @param {Integer} cycles
|
170
|
+
* @return {MMDPhysics}
|
171
|
+
*/
|
172
|
+
|
173
|
+
}, {
|
174
|
+
key: "warmup",
|
175
|
+
value: function warmup(cycles) {
|
176
|
+
for (var i = 0; i < cycles; i++) {
|
177
|
+
this.update(1 / 60);
|
178
|
+
}
|
179
|
+
|
180
|
+
return this;
|
181
|
+
}
|
182
|
+
/**
|
183
|
+
* Sets gravity.
|
184
|
+
*
|
185
|
+
* @param {Vector3} gravity
|
186
|
+
* @return {MMDPhysicsHelper}
|
187
|
+
*/
|
188
|
+
|
189
|
+
}, {
|
190
|
+
key: "setGravity",
|
191
|
+
value: function setGravity(gravity) {
|
192
|
+
this.world.setGravity(new Ammo.btVector3(gravity.x, gravity.y, gravity.z));
|
193
|
+
this.gravity.copy(gravity);
|
194
|
+
return this;
|
195
|
+
}
|
196
|
+
/**
|
197
|
+
* Creates MMDPhysicsHelper
|
198
|
+
*
|
199
|
+
* @return {MMDPhysicsHelper}
|
200
|
+
*/
|
201
|
+
|
202
|
+
}, {
|
203
|
+
key: "createHelper",
|
204
|
+
value: function createHelper() {
|
205
|
+
return new MMDPhysicsHelper(this.mesh, this);
|
206
|
+
} // private methods
|
207
|
+
|
208
|
+
}, {
|
209
|
+
key: "_init",
|
210
|
+
value: function _init(mesh, rigidBodyParams, constraintParams) {
|
211
|
+
var manager = this.manager; // rigid body/constraint parameters are for
|
212
|
+
// mesh's default world transform as position(0, 0, 0),
|
213
|
+
// quaternion(0, 0, 0, 1) and scale(0, 0, 0)
|
214
|
+
|
215
|
+
var parent = mesh.parent;
|
216
|
+
if (parent !== null) parent = null;
|
217
|
+
var currentPosition = manager.allocThreeVector3();
|
218
|
+
var currentQuaternion = manager.allocThreeQuaternion();
|
219
|
+
var currentScale = manager.allocThreeVector3();
|
220
|
+
currentPosition.copy(mesh.position);
|
221
|
+
currentQuaternion.copy(mesh.quaternion);
|
222
|
+
currentScale.copy(mesh.scale);
|
223
|
+
mesh.position.set(0, 0, 0);
|
224
|
+
mesh.quaternion.set(0, 0, 0, 1);
|
225
|
+
mesh.scale.set(1, 1, 1);
|
226
|
+
mesh.updateMatrixWorld(true);
|
227
|
+
|
228
|
+
if (this.world === null) {
|
229
|
+
this.world = this._createWorld();
|
230
|
+
this.setGravity(this.gravity);
|
231
|
+
}
|
232
|
+
|
233
|
+
this._initRigidBodies(rigidBodyParams);
|
234
|
+
|
235
|
+
this._initConstraints(constraintParams);
|
236
|
+
|
237
|
+
if (parent !== null) mesh.parent = parent;
|
238
|
+
mesh.position.copy(currentPosition);
|
239
|
+
mesh.quaternion.copy(currentQuaternion);
|
240
|
+
mesh.scale.copy(currentScale);
|
241
|
+
mesh.updateMatrixWorld(true);
|
242
|
+
this.reset();
|
243
|
+
manager.freeThreeVector3(currentPosition);
|
244
|
+
manager.freeThreeQuaternion(currentQuaternion);
|
245
|
+
manager.freeThreeVector3(currentScale);
|
246
|
+
}
|
247
|
+
}, {
|
248
|
+
key: "_createWorld",
|
249
|
+
value: function _createWorld() {
|
250
|
+
var config = new Ammo.btDefaultCollisionConfiguration();
|
251
|
+
var dispatcher = new Ammo.btCollisionDispatcher(config);
|
252
|
+
var cache = new Ammo.btDbvtBroadphase();
|
253
|
+
var solver = new Ammo.btSequentialImpulseConstraintSolver();
|
254
|
+
var world = new Ammo.btDiscreteDynamicsWorld(dispatcher, cache, solver, config);
|
255
|
+
return world;
|
256
|
+
}
|
257
|
+
}, {
|
258
|
+
key: "_initRigidBodies",
|
259
|
+
value: function _initRigidBodies(rigidBodies) {
|
260
|
+
for (var i = 0, il = rigidBodies.length; i < il; i++) {
|
261
|
+
this.bodies.push(new RigidBody(this.mesh, this.world, rigidBodies[i], this.manager));
|
262
|
+
}
|
263
|
+
}
|
264
|
+
}, {
|
265
|
+
key: "_initConstraints",
|
266
|
+
value: function _initConstraints(constraints) {
|
267
|
+
for (var i = 0, il = constraints.length; i < il; i++) {
|
268
|
+
var params = constraints[i];
|
269
|
+
var bodyA = this.bodies[params.rigidBodyIndex1];
|
270
|
+
var bodyB = this.bodies[params.rigidBodyIndex2];
|
271
|
+
this.constraints.push(new Constraint(this.mesh, this.world, bodyA, bodyB, params, this.manager));
|
272
|
+
}
|
273
|
+
}
|
274
|
+
}, {
|
275
|
+
key: "_stepSimulation",
|
276
|
+
value: function _stepSimulation(delta) {
|
277
|
+
var unitStep = this.unitStep;
|
278
|
+
var stepTime = delta;
|
279
|
+
var maxStepNum = (delta / unitStep | 0) + 1;
|
280
|
+
|
281
|
+
if (stepTime < unitStep) {
|
282
|
+
stepTime = unitStep;
|
283
|
+
maxStepNum = 1;
|
284
|
+
}
|
285
|
+
|
286
|
+
if (maxStepNum > this.maxStepNum) {
|
287
|
+
maxStepNum = this.maxStepNum;
|
288
|
+
}
|
289
|
+
|
290
|
+
this.world.stepSimulation(stepTime, maxStepNum, unitStep);
|
291
|
+
}
|
292
|
+
}, {
|
293
|
+
key: "_updateRigidBodies",
|
294
|
+
value: function _updateRigidBodies() {
|
295
|
+
for (var i = 0, il = this.bodies.length; i < il; i++) {
|
296
|
+
this.bodies[i].updateFromBone();
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}, {
|
300
|
+
key: "_updateBones",
|
301
|
+
value: function _updateBones() {
|
302
|
+
for (var i = 0, il = this.bodies.length; i < il; i++) {
|
303
|
+
this.bodies[i].updateBone();
|
304
|
+
}
|
305
|
+
}
|
306
|
+
}]);
|
307
|
+
|
308
|
+
return MMDPhysics;
|
309
|
+
}();
|
310
|
+
/**
|
311
|
+
* This manager's responsibilies are
|
312
|
+
*
|
313
|
+
* 1. manage Ammo.js and Three.js object resources and
|
314
|
+
* improve the performance and the memory consumption by
|
315
|
+
* reusing objects.
|
316
|
+
*
|
317
|
+
* 2. provide simple Ammo object operations.
|
318
|
+
*/
|
319
|
+
|
320
|
+
|
321
|
+
_exports.MMDPhysics = MMDPhysics;
|
322
|
+
|
323
|
+
var ResourceManager = /*#__PURE__*/function () {
|
324
|
+
function ResourceManager() {
|
325
|
+
_classCallCheck(this, ResourceManager);
|
326
|
+
|
327
|
+
// for Three.js
|
328
|
+
this.threeVector3s = [];
|
329
|
+
this.threeMatrix4s = [];
|
330
|
+
this.threeQuaternions = [];
|
331
|
+
this.threeEulers = []; // for Ammo.js
|
332
|
+
|
333
|
+
this.transforms = [];
|
334
|
+
this.quaternions = [];
|
335
|
+
this.vector3s = [];
|
336
|
+
}
|
337
|
+
|
338
|
+
_createClass(ResourceManager, [{
|
339
|
+
key: "allocThreeVector3",
|
340
|
+
value: function allocThreeVector3() {
|
341
|
+
return this.threeVector3s.length > 0 ? this.threeVector3s.pop() : new _three.Vector3();
|
342
|
+
}
|
343
|
+
}, {
|
344
|
+
key: "freeThreeVector3",
|
345
|
+
value: function freeThreeVector3(v) {
|
346
|
+
this.threeVector3s.push(v);
|
347
|
+
}
|
348
|
+
}, {
|
349
|
+
key: "allocThreeMatrix4",
|
350
|
+
value: function allocThreeMatrix4() {
|
351
|
+
return this.threeMatrix4s.length > 0 ? this.threeMatrix4s.pop() : new _three.Matrix4();
|
352
|
+
}
|
353
|
+
}, {
|
354
|
+
key: "freeThreeMatrix4",
|
355
|
+
value: function freeThreeMatrix4(m) {
|
356
|
+
this.threeMatrix4s.push(m);
|
357
|
+
}
|
358
|
+
}, {
|
359
|
+
key: "allocThreeQuaternion",
|
360
|
+
value: function allocThreeQuaternion() {
|
361
|
+
return this.threeQuaternions.length > 0 ? this.threeQuaternions.pop() : new _three.Quaternion();
|
362
|
+
}
|
363
|
+
}, {
|
364
|
+
key: "freeThreeQuaternion",
|
365
|
+
value: function freeThreeQuaternion(q) {
|
366
|
+
this.threeQuaternions.push(q);
|
367
|
+
}
|
368
|
+
}, {
|
369
|
+
key: "allocThreeEuler",
|
370
|
+
value: function allocThreeEuler() {
|
371
|
+
return this.threeEulers.length > 0 ? this.threeEulers.pop() : new _three.Euler();
|
372
|
+
}
|
373
|
+
}, {
|
374
|
+
key: "freeThreeEuler",
|
375
|
+
value: function freeThreeEuler(e) {
|
376
|
+
this.threeEulers.push(e);
|
377
|
+
}
|
378
|
+
}, {
|
379
|
+
key: "allocTransform",
|
380
|
+
value: function allocTransform() {
|
381
|
+
return this.transforms.length > 0 ? this.transforms.pop() : new Ammo.btTransform();
|
382
|
+
}
|
383
|
+
}, {
|
384
|
+
key: "freeTransform",
|
385
|
+
value: function freeTransform(t) {
|
386
|
+
this.transforms.push(t);
|
387
|
+
}
|
388
|
+
}, {
|
389
|
+
key: "allocQuaternion",
|
390
|
+
value: function allocQuaternion() {
|
391
|
+
return this.quaternions.length > 0 ? this.quaternions.pop() : new Ammo.btQuaternion();
|
392
|
+
}
|
393
|
+
}, {
|
394
|
+
key: "freeQuaternion",
|
395
|
+
value: function freeQuaternion(q) {
|
396
|
+
this.quaternions.push(q);
|
397
|
+
}
|
398
|
+
}, {
|
399
|
+
key: "allocVector3",
|
400
|
+
value: function allocVector3() {
|
401
|
+
return this.vector3s.length > 0 ? this.vector3s.pop() : new Ammo.btVector3();
|
402
|
+
}
|
403
|
+
}, {
|
404
|
+
key: "freeVector3",
|
405
|
+
value: function freeVector3(v) {
|
406
|
+
this.vector3s.push(v);
|
407
|
+
}
|
408
|
+
}, {
|
409
|
+
key: "setIdentity",
|
410
|
+
value: function setIdentity(t) {
|
411
|
+
t.setIdentity();
|
412
|
+
}
|
413
|
+
}, {
|
414
|
+
key: "getBasis",
|
415
|
+
value: function getBasis(t) {
|
416
|
+
var q = this.allocQuaternion();
|
417
|
+
t.getBasis().getRotation(q);
|
418
|
+
return q;
|
419
|
+
}
|
420
|
+
}, {
|
421
|
+
key: "getBasisAsMatrix3",
|
422
|
+
value: function getBasisAsMatrix3(t) {
|
423
|
+
var q = this.getBasis(t);
|
424
|
+
var m = this.quaternionToMatrix3(q);
|
425
|
+
this.freeQuaternion(q);
|
426
|
+
return m;
|
427
|
+
}
|
428
|
+
}, {
|
429
|
+
key: "getOrigin",
|
430
|
+
value: function getOrigin(t) {
|
431
|
+
return t.getOrigin();
|
432
|
+
}
|
433
|
+
}, {
|
434
|
+
key: "setOrigin",
|
435
|
+
value: function setOrigin(t, v) {
|
436
|
+
t.getOrigin().setValue(v.x(), v.y(), v.z());
|
437
|
+
}
|
438
|
+
}, {
|
439
|
+
key: "copyOrigin",
|
440
|
+
value: function copyOrigin(t1, t2) {
|
441
|
+
var o = t2.getOrigin();
|
442
|
+
this.setOrigin(t1, o);
|
443
|
+
}
|
444
|
+
}, {
|
445
|
+
key: "setBasis",
|
446
|
+
value: function setBasis(t, q) {
|
447
|
+
t.setRotation(q);
|
448
|
+
}
|
449
|
+
}, {
|
450
|
+
key: "setBasisFromMatrix3",
|
451
|
+
value: function setBasisFromMatrix3(t, m) {
|
452
|
+
var q = this.matrix3ToQuaternion(m);
|
453
|
+
this.setBasis(t, q);
|
454
|
+
this.freeQuaternion(q);
|
455
|
+
}
|
456
|
+
}, {
|
457
|
+
key: "setOriginFromArray3",
|
458
|
+
value: function setOriginFromArray3(t, a) {
|
459
|
+
t.getOrigin().setValue(a[0], a[1], a[2]);
|
460
|
+
}
|
461
|
+
}, {
|
462
|
+
key: "setOriginFromThreeVector3",
|
463
|
+
value: function setOriginFromThreeVector3(t, v) {
|
464
|
+
t.getOrigin().setValue(v.x, v.y, v.z);
|
465
|
+
}
|
466
|
+
}, {
|
467
|
+
key: "setBasisFromArray3",
|
468
|
+
value: function setBasisFromArray3(t, a) {
|
469
|
+
var thQ = this.allocThreeQuaternion();
|
470
|
+
var thE = this.allocThreeEuler();
|
471
|
+
thE.set(a[0], a[1], a[2]);
|
472
|
+
this.setBasisFromThreeQuaternion(t, thQ.setFromEuler(thE));
|
473
|
+
this.freeThreeEuler(thE);
|
474
|
+
this.freeThreeQuaternion(thQ);
|
475
|
+
}
|
476
|
+
}, {
|
477
|
+
key: "setBasisFromThreeQuaternion",
|
478
|
+
value: function setBasisFromThreeQuaternion(t, a) {
|
479
|
+
var q = this.allocQuaternion();
|
480
|
+
q.setX(a.x);
|
481
|
+
q.setY(a.y);
|
482
|
+
q.setZ(a.z);
|
483
|
+
q.setW(a.w);
|
484
|
+
this.setBasis(t, q);
|
485
|
+
this.freeQuaternion(q);
|
486
|
+
}
|
487
|
+
}, {
|
488
|
+
key: "multiplyTransforms",
|
489
|
+
value: function multiplyTransforms(t1, t2) {
|
490
|
+
var t = this.allocTransform();
|
491
|
+
this.setIdentity(t);
|
492
|
+
var m1 = this.getBasisAsMatrix3(t1);
|
493
|
+
var m2 = this.getBasisAsMatrix3(t2);
|
494
|
+
var o1 = this.getOrigin(t1);
|
495
|
+
var o2 = this.getOrigin(t2);
|
496
|
+
var v1 = this.multiplyMatrix3ByVector3(m1, o2);
|
497
|
+
var v2 = this.addVector3(v1, o1);
|
498
|
+
this.setOrigin(t, v2);
|
499
|
+
var m3 = this.multiplyMatrices3(m1, m2);
|
500
|
+
this.setBasisFromMatrix3(t, m3);
|
501
|
+
this.freeVector3(v1);
|
502
|
+
this.freeVector3(v2);
|
503
|
+
return t;
|
504
|
+
}
|
505
|
+
}, {
|
506
|
+
key: "inverseTransform",
|
507
|
+
value: function inverseTransform(t) {
|
508
|
+
var t2 = this.allocTransform();
|
509
|
+
var m1 = this.getBasisAsMatrix3(t);
|
510
|
+
var o = this.getOrigin(t);
|
511
|
+
var m2 = this.transposeMatrix3(m1);
|
512
|
+
var v1 = this.negativeVector3(o);
|
513
|
+
var v2 = this.multiplyMatrix3ByVector3(m2, v1);
|
514
|
+
this.setOrigin(t2, v2);
|
515
|
+
this.setBasisFromMatrix3(t2, m2);
|
516
|
+
this.freeVector3(v1);
|
517
|
+
this.freeVector3(v2);
|
518
|
+
return t2;
|
519
|
+
}
|
520
|
+
}, {
|
521
|
+
key: "multiplyMatrices3",
|
522
|
+
value: function multiplyMatrices3(m1, m2) {
|
523
|
+
var m3 = [];
|
524
|
+
var v10 = this.rowOfMatrix3(m1, 0);
|
525
|
+
var v11 = this.rowOfMatrix3(m1, 1);
|
526
|
+
var v12 = this.rowOfMatrix3(m1, 2);
|
527
|
+
var v20 = this.columnOfMatrix3(m2, 0);
|
528
|
+
var v21 = this.columnOfMatrix3(m2, 1);
|
529
|
+
var v22 = this.columnOfMatrix3(m2, 2);
|
530
|
+
m3[0] = this.dotVectors3(v10, v20);
|
531
|
+
m3[1] = this.dotVectors3(v10, v21);
|
532
|
+
m3[2] = this.dotVectors3(v10, v22);
|
533
|
+
m3[3] = this.dotVectors3(v11, v20);
|
534
|
+
m3[4] = this.dotVectors3(v11, v21);
|
535
|
+
m3[5] = this.dotVectors3(v11, v22);
|
536
|
+
m3[6] = this.dotVectors3(v12, v20);
|
537
|
+
m3[7] = this.dotVectors3(v12, v21);
|
538
|
+
m3[8] = this.dotVectors3(v12, v22);
|
539
|
+
this.freeVector3(v10);
|
540
|
+
this.freeVector3(v11);
|
541
|
+
this.freeVector3(v12);
|
542
|
+
this.freeVector3(v20);
|
543
|
+
this.freeVector3(v21);
|
544
|
+
this.freeVector3(v22);
|
545
|
+
return m3;
|
546
|
+
}
|
547
|
+
}, {
|
548
|
+
key: "addVector3",
|
549
|
+
value: function addVector3(v1, v2) {
|
550
|
+
var v = this.allocVector3();
|
551
|
+
v.setValue(v1.x() + v2.x(), v1.y() + v2.y(), v1.z() + v2.z());
|
552
|
+
return v;
|
553
|
+
}
|
554
|
+
}, {
|
555
|
+
key: "dotVectors3",
|
556
|
+
value: function dotVectors3(v1, v2) {
|
557
|
+
return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
|
558
|
+
}
|
559
|
+
}, {
|
560
|
+
key: "rowOfMatrix3",
|
561
|
+
value: function rowOfMatrix3(m, i) {
|
562
|
+
var v = this.allocVector3();
|
563
|
+
v.setValue(m[i * 3 + 0], m[i * 3 + 1], m[i * 3 + 2]);
|
564
|
+
return v;
|
565
|
+
}
|
566
|
+
}, {
|
567
|
+
key: "columnOfMatrix3",
|
568
|
+
value: function columnOfMatrix3(m, i) {
|
569
|
+
var v = this.allocVector3();
|
570
|
+
v.setValue(m[i + 0], m[i + 3], m[i + 6]);
|
571
|
+
return v;
|
572
|
+
}
|
573
|
+
}, {
|
574
|
+
key: "negativeVector3",
|
575
|
+
value: function negativeVector3(v) {
|
576
|
+
var v2 = this.allocVector3();
|
577
|
+
v2.setValue(-v.x(), -v.y(), -v.z());
|
578
|
+
return v2;
|
579
|
+
}
|
580
|
+
}, {
|
581
|
+
key: "multiplyMatrix3ByVector3",
|
582
|
+
value: function multiplyMatrix3ByVector3(m, v) {
|
583
|
+
var v4 = this.allocVector3();
|
584
|
+
var v0 = this.rowOfMatrix3(m, 0);
|
585
|
+
var v1 = this.rowOfMatrix3(m, 1);
|
586
|
+
var v2 = this.rowOfMatrix3(m, 2);
|
587
|
+
var x = this.dotVectors3(v0, v);
|
588
|
+
var y = this.dotVectors3(v1, v);
|
589
|
+
var z = this.dotVectors3(v2, v);
|
590
|
+
v4.setValue(x, y, z);
|
591
|
+
this.freeVector3(v0);
|
592
|
+
this.freeVector3(v1);
|
593
|
+
this.freeVector3(v2);
|
594
|
+
return v4;
|
595
|
+
}
|
596
|
+
}, {
|
597
|
+
key: "transposeMatrix3",
|
598
|
+
value: function transposeMatrix3(m) {
|
599
|
+
var m2 = [];
|
600
|
+
m2[0] = m[0];
|
601
|
+
m2[1] = m[3];
|
602
|
+
m2[2] = m[6];
|
603
|
+
m2[3] = m[1];
|
604
|
+
m2[4] = m[4];
|
605
|
+
m2[5] = m[7];
|
606
|
+
m2[6] = m[2];
|
607
|
+
m2[7] = m[5];
|
608
|
+
m2[8] = m[8];
|
609
|
+
return m2;
|
610
|
+
}
|
611
|
+
}, {
|
612
|
+
key: "quaternionToMatrix3",
|
613
|
+
value: function quaternionToMatrix3(q) {
|
614
|
+
var m = [];
|
615
|
+
var x = q.x();
|
616
|
+
var y = q.y();
|
617
|
+
var z = q.z();
|
618
|
+
var w = q.w();
|
619
|
+
var xx = x * x;
|
620
|
+
var yy = y * y;
|
621
|
+
var zz = z * z;
|
622
|
+
var xy = x * y;
|
623
|
+
var yz = y * z;
|
624
|
+
var zx = z * x;
|
625
|
+
var xw = x * w;
|
626
|
+
var yw = y * w;
|
627
|
+
var zw = z * w;
|
628
|
+
m[0] = 1 - 2 * (yy + zz);
|
629
|
+
m[1] = 2 * (xy - zw);
|
630
|
+
m[2] = 2 * (zx + yw);
|
631
|
+
m[3] = 2 * (xy + zw);
|
632
|
+
m[4] = 1 - 2 * (zz + xx);
|
633
|
+
m[5] = 2 * (yz - xw);
|
634
|
+
m[6] = 2 * (zx - yw);
|
635
|
+
m[7] = 2 * (yz + xw);
|
636
|
+
m[8] = 1 - 2 * (xx + yy);
|
637
|
+
return m;
|
638
|
+
}
|
639
|
+
}, {
|
640
|
+
key: "matrix3ToQuaternion",
|
641
|
+
value: function matrix3ToQuaternion(m) {
|
642
|
+
var t = m[0] + m[4] + m[8];
|
643
|
+
var s, x, y, z, w;
|
644
|
+
|
645
|
+
if (t > 0) {
|
646
|
+
s = Math.sqrt(t + 1.0) * 2;
|
647
|
+
w = 0.25 * s;
|
648
|
+
x = (m[7] - m[5]) / s;
|
649
|
+
y = (m[2] - m[6]) / s;
|
650
|
+
z = (m[3] - m[1]) / s;
|
651
|
+
} else if (m[0] > m[4] && m[0] > m[8]) {
|
652
|
+
s = Math.sqrt(1.0 + m[0] - m[4] - m[8]) * 2;
|
653
|
+
w = (m[7] - m[5]) / s;
|
654
|
+
x = 0.25 * s;
|
655
|
+
y = (m[1] + m[3]) / s;
|
656
|
+
z = (m[2] + m[6]) / s;
|
657
|
+
} else if (m[4] > m[8]) {
|
658
|
+
s = Math.sqrt(1.0 + m[4] - m[0] - m[8]) * 2;
|
659
|
+
w = (m[2] - m[6]) / s;
|
660
|
+
x = (m[1] + m[3]) / s;
|
661
|
+
y = 0.25 * s;
|
662
|
+
z = (m[5] + m[7]) / s;
|
663
|
+
} else {
|
664
|
+
s = Math.sqrt(1.0 + m[8] - m[0] - m[4]) * 2;
|
665
|
+
w = (m[3] - m[1]) / s;
|
666
|
+
x = (m[2] + m[6]) / s;
|
667
|
+
y = (m[5] + m[7]) / s;
|
668
|
+
z = 0.25 * s;
|
669
|
+
}
|
670
|
+
|
671
|
+
var q = this.allocQuaternion();
|
672
|
+
q.setX(x);
|
673
|
+
q.setY(y);
|
674
|
+
q.setZ(z);
|
675
|
+
q.setW(w);
|
676
|
+
return q;
|
677
|
+
}
|
678
|
+
}]);
|
679
|
+
|
680
|
+
return ResourceManager;
|
681
|
+
}();
|
682
|
+
/**
|
683
|
+
* @param {THREE.SkinnedMesh} mesh
|
684
|
+
* @param {Ammo.btDiscreteDynamicsWorld} world
|
685
|
+
* @param {Object} params
|
686
|
+
* @param {ResourceManager} manager
|
687
|
+
*/
|
688
|
+
|
689
|
+
|
690
|
+
var RigidBody = /*#__PURE__*/function () {
|
691
|
+
function RigidBody(mesh, world, params, manager) {
|
692
|
+
_classCallCheck(this, RigidBody);
|
693
|
+
|
694
|
+
this.mesh = mesh;
|
695
|
+
this.world = world;
|
696
|
+
this.params = params;
|
697
|
+
this.manager = manager;
|
698
|
+
this.body = null;
|
699
|
+
this.bone = null;
|
700
|
+
this.boneOffsetForm = null;
|
701
|
+
this.boneOffsetFormInverse = null;
|
702
|
+
|
703
|
+
this._init();
|
704
|
+
}
|
705
|
+
/**
|
706
|
+
* Resets rigid body transform to the current bone's.
|
707
|
+
*
|
708
|
+
* @return {RigidBody}
|
709
|
+
*/
|
710
|
+
|
711
|
+
|
712
|
+
_createClass(RigidBody, [{
|
713
|
+
key: "reset",
|
714
|
+
value: function reset() {
|
715
|
+
this._setTransformFromBone();
|
716
|
+
|
717
|
+
return this;
|
718
|
+
}
|
719
|
+
/**
|
720
|
+
* Updates rigid body's transform from the current bone.
|
721
|
+
*
|
722
|
+
* @return {RidigBody}
|
723
|
+
*/
|
724
|
+
|
725
|
+
}, {
|
726
|
+
key: "updateFromBone",
|
727
|
+
value: function updateFromBone() {
|
728
|
+
if (this.params.boneIndex !== -1 && this.params.type === 0) {
|
729
|
+
this._setTransformFromBone();
|
730
|
+
}
|
731
|
+
|
732
|
+
return this;
|
733
|
+
}
|
734
|
+
/**
|
735
|
+
* Updates bone from the current ridid body's transform.
|
736
|
+
*
|
737
|
+
* @return {RidigBody}
|
738
|
+
*/
|
739
|
+
|
740
|
+
}, {
|
741
|
+
key: "updateBone",
|
742
|
+
value: function updateBone() {
|
743
|
+
if (this.params.type === 0 || this.params.boneIndex === -1) {
|
744
|
+
return this;
|
745
|
+
}
|
746
|
+
|
747
|
+
this._updateBoneRotation();
|
748
|
+
|
749
|
+
if (this.params.type === 1) {
|
750
|
+
this._updateBonePosition();
|
751
|
+
}
|
752
|
+
|
753
|
+
this.bone.updateMatrixWorld(true);
|
754
|
+
|
755
|
+
if (this.params.type === 2) {
|
756
|
+
this._setPositionFromBone();
|
757
|
+
}
|
758
|
+
|
759
|
+
return this;
|
760
|
+
} // private methods
|
761
|
+
|
762
|
+
}, {
|
763
|
+
key: "_init",
|
764
|
+
value: function _init() {
|
765
|
+
function generateShape(p) {
|
766
|
+
switch (p.shapeType) {
|
767
|
+
case 0:
|
768
|
+
return new Ammo.btSphereShape(p.width);
|
769
|
+
|
770
|
+
case 1:
|
771
|
+
return new Ammo.btBoxShape(new Ammo.btVector3(p.width, p.height, p.depth));
|
772
|
+
|
773
|
+
case 2:
|
774
|
+
return new Ammo.btCapsuleShape(p.width, p.height);
|
775
|
+
|
776
|
+
default:
|
777
|
+
throw 'unknown shape type ' + p.shapeType;
|
778
|
+
}
|
779
|
+
}
|
780
|
+
|
781
|
+
var manager = this.manager;
|
782
|
+
var params = this.params;
|
783
|
+
var bones = this.mesh.skeleton.bones;
|
784
|
+
var bone = params.boneIndex === -1 ? new _three.Bone() : bones[params.boneIndex];
|
785
|
+
var shape = generateShape(params);
|
786
|
+
var weight = params.type === 0 ? 0 : params.weight;
|
787
|
+
var localInertia = manager.allocVector3();
|
788
|
+
localInertia.setValue(0, 0, 0);
|
789
|
+
|
790
|
+
if (weight !== 0) {
|
791
|
+
shape.calculateLocalInertia(weight, localInertia);
|
792
|
+
}
|
793
|
+
|
794
|
+
var boneOffsetForm = manager.allocTransform();
|
795
|
+
manager.setIdentity(boneOffsetForm);
|
796
|
+
manager.setOriginFromArray3(boneOffsetForm, params.position);
|
797
|
+
manager.setBasisFromArray3(boneOffsetForm, params.rotation);
|
798
|
+
var vector = manager.allocThreeVector3();
|
799
|
+
var boneForm = manager.allocTransform();
|
800
|
+
manager.setIdentity(boneForm);
|
801
|
+
manager.setOriginFromThreeVector3(boneForm, bone.getWorldPosition(vector));
|
802
|
+
var form = manager.multiplyTransforms(boneForm, boneOffsetForm);
|
803
|
+
var state = new Ammo.btDefaultMotionState(form);
|
804
|
+
var info = new Ammo.btRigidBodyConstructionInfo(weight, state, shape, localInertia);
|
805
|
+
info.set_m_friction(params.friction);
|
806
|
+
info.set_m_restitution(params.restitution);
|
807
|
+
var body = new Ammo.btRigidBody(info);
|
808
|
+
|
809
|
+
if (params.type === 0) {
|
810
|
+
body.setCollisionFlags(body.getCollisionFlags() | 2);
|
811
|
+
/*
|
812
|
+
* It'd be better to comment out this line though in general I should call this method
|
813
|
+
* because I'm not sure why but physics will be more like MMD's
|
814
|
+
* if I comment out.
|
815
|
+
*/
|
816
|
+
|
817
|
+
body.setActivationState(4);
|
818
|
+
}
|
819
|
+
|
820
|
+
body.setDamping(params.positionDamping, params.rotationDamping);
|
821
|
+
body.setSleepingThresholds(0, 0);
|
822
|
+
this.world.addRigidBody(body, 1 << params.groupIndex, params.groupTarget);
|
823
|
+
this.body = body;
|
824
|
+
this.bone = bone;
|
825
|
+
this.boneOffsetForm = boneOffsetForm;
|
826
|
+
this.boneOffsetFormInverse = manager.inverseTransform(boneOffsetForm);
|
827
|
+
manager.freeVector3(localInertia);
|
828
|
+
manager.freeTransform(form);
|
829
|
+
manager.freeTransform(boneForm);
|
830
|
+
manager.freeThreeVector3(vector);
|
831
|
+
}
|
832
|
+
}, {
|
833
|
+
key: "_getBoneTransform",
|
834
|
+
value: function _getBoneTransform() {
|
835
|
+
var manager = this.manager;
|
836
|
+
var p = manager.allocThreeVector3();
|
837
|
+
var q = manager.allocThreeQuaternion();
|
838
|
+
var s = manager.allocThreeVector3();
|
839
|
+
this.bone.matrixWorld.decompose(p, q, s);
|
840
|
+
var tr = manager.allocTransform();
|
841
|
+
manager.setOriginFromThreeVector3(tr, p);
|
842
|
+
manager.setBasisFromThreeQuaternion(tr, q);
|
843
|
+
var form = manager.multiplyTransforms(tr, this.boneOffsetForm);
|
844
|
+
manager.freeTransform(tr);
|
845
|
+
manager.freeThreeVector3(s);
|
846
|
+
manager.freeThreeQuaternion(q);
|
847
|
+
manager.freeThreeVector3(p);
|
848
|
+
return form;
|
849
|
+
}
|
850
|
+
}, {
|
851
|
+
key: "_getWorldTransformForBone",
|
852
|
+
value: function _getWorldTransformForBone() {
|
853
|
+
var manager = this.manager;
|
854
|
+
var tr = this.body.getCenterOfMassTransform();
|
855
|
+
return manager.multiplyTransforms(tr, this.boneOffsetFormInverse);
|
856
|
+
}
|
857
|
+
}, {
|
858
|
+
key: "_setTransformFromBone",
|
859
|
+
value: function _setTransformFromBone() {
|
860
|
+
var manager = this.manager;
|
861
|
+
|
862
|
+
var form = this._getBoneTransform(); // TODO: check the most appropriate way to set
|
863
|
+
//this.body.setWorldTransform( form );
|
864
|
+
|
865
|
+
|
866
|
+
this.body.setCenterOfMassTransform(form);
|
867
|
+
this.body.getMotionState().setWorldTransform(form);
|
868
|
+
manager.freeTransform(form);
|
869
|
+
}
|
870
|
+
}, {
|
871
|
+
key: "_setPositionFromBone",
|
872
|
+
value: function _setPositionFromBone() {
|
873
|
+
var manager = this.manager;
|
874
|
+
|
875
|
+
var form = this._getBoneTransform();
|
876
|
+
|
877
|
+
var tr = manager.allocTransform();
|
878
|
+
this.body.getMotionState().getWorldTransform(tr);
|
879
|
+
manager.copyOrigin(tr, form); // TODO: check the most appropriate way to set
|
880
|
+
//this.body.setWorldTransform( tr );
|
881
|
+
|
882
|
+
this.body.setCenterOfMassTransform(tr);
|
883
|
+
this.body.getMotionState().setWorldTransform(tr);
|
884
|
+
manager.freeTransform(tr);
|
885
|
+
manager.freeTransform(form);
|
886
|
+
}
|
887
|
+
}, {
|
888
|
+
key: "_updateBoneRotation",
|
889
|
+
value: function _updateBoneRotation() {
|
890
|
+
var manager = this.manager;
|
891
|
+
|
892
|
+
var tr = this._getWorldTransformForBone();
|
893
|
+
|
894
|
+
var q = manager.getBasis(tr);
|
895
|
+
var thQ = manager.allocThreeQuaternion();
|
896
|
+
var thQ2 = manager.allocThreeQuaternion();
|
897
|
+
var thQ3 = manager.allocThreeQuaternion();
|
898
|
+
thQ.set(q.x(), q.y(), q.z(), q.w());
|
899
|
+
thQ2.setFromRotationMatrix(this.bone.matrixWorld);
|
900
|
+
thQ2.conjugate();
|
901
|
+
thQ2.multiply(thQ); //this.bone.quaternion.multiply( thQ2 );
|
902
|
+
|
903
|
+
thQ3.setFromRotationMatrix(this.bone.matrix); // Renormalizing quaternion here because repeatedly transforming
|
904
|
+
// quaternion continuously accumulates floating point error and
|
905
|
+
// can end up being overflow. See #15335
|
906
|
+
|
907
|
+
this.bone.quaternion.copy(thQ2.multiply(thQ3).normalize());
|
908
|
+
manager.freeThreeQuaternion(thQ);
|
909
|
+
manager.freeThreeQuaternion(thQ2);
|
910
|
+
manager.freeThreeQuaternion(thQ3);
|
911
|
+
manager.freeQuaternion(q);
|
912
|
+
manager.freeTransform(tr);
|
913
|
+
}
|
914
|
+
}, {
|
915
|
+
key: "_updateBonePosition",
|
916
|
+
value: function _updateBonePosition() {
|
917
|
+
var manager = this.manager;
|
918
|
+
|
919
|
+
var tr = this._getWorldTransformForBone();
|
920
|
+
|
921
|
+
var thV = manager.allocThreeVector3();
|
922
|
+
var o = manager.getOrigin(tr);
|
923
|
+
thV.set(o.x(), o.y(), o.z());
|
924
|
+
|
925
|
+
if (this.bone.parent) {
|
926
|
+
this.bone.parent.worldToLocal(thV);
|
927
|
+
}
|
928
|
+
|
929
|
+
this.bone.position.copy(thV);
|
930
|
+
manager.freeThreeVector3(thV);
|
931
|
+
manager.freeTransform(tr);
|
932
|
+
}
|
933
|
+
}]);
|
934
|
+
|
935
|
+
return RigidBody;
|
936
|
+
}(); //
|
937
|
+
|
938
|
+
|
939
|
+
var Constraint = /*#__PURE__*/function () {
|
940
|
+
/**
|
941
|
+
* @param {THREE.SkinnedMesh} mesh
|
942
|
+
* @param {Ammo.btDiscreteDynamicsWorld} world
|
943
|
+
* @param {RigidBody} bodyA
|
944
|
+
* @param {RigidBody} bodyB
|
945
|
+
* @param {Object} params
|
946
|
+
* @param {ResourceManager} manager
|
947
|
+
*/
|
948
|
+
function Constraint(mesh, world, bodyA, bodyB, params, manager) {
|
949
|
+
_classCallCheck(this, Constraint);
|
950
|
+
|
951
|
+
this.mesh = mesh;
|
952
|
+
this.world = world;
|
953
|
+
this.bodyA = bodyA;
|
954
|
+
this.bodyB = bodyB;
|
955
|
+
this.params = params;
|
956
|
+
this.manager = manager;
|
957
|
+
this.constraint = null;
|
958
|
+
|
959
|
+
this._init();
|
960
|
+
} // private method
|
961
|
+
|
962
|
+
|
963
|
+
_createClass(Constraint, [{
|
964
|
+
key: "_init",
|
965
|
+
value: function _init() {
|
966
|
+
var manager = this.manager;
|
967
|
+
var params = this.params;
|
968
|
+
var bodyA = this.bodyA;
|
969
|
+
var bodyB = this.bodyB;
|
970
|
+
var form = manager.allocTransform();
|
971
|
+
manager.setIdentity(form);
|
972
|
+
manager.setOriginFromArray3(form, params.position);
|
973
|
+
manager.setBasisFromArray3(form, params.rotation);
|
974
|
+
var formA = manager.allocTransform();
|
975
|
+
var formB = manager.allocTransform();
|
976
|
+
bodyA.body.getMotionState().getWorldTransform(formA);
|
977
|
+
bodyB.body.getMotionState().getWorldTransform(formB);
|
978
|
+
var formInverseA = manager.inverseTransform(formA);
|
979
|
+
var formInverseB = manager.inverseTransform(formB);
|
980
|
+
var formA2 = manager.multiplyTransforms(formInverseA, form);
|
981
|
+
var formB2 = manager.multiplyTransforms(formInverseB, form);
|
982
|
+
var constraint = new Ammo.btGeneric6DofSpringConstraint(bodyA.body, bodyB.body, formA2, formB2, true);
|
983
|
+
var lll = manager.allocVector3();
|
984
|
+
var lul = manager.allocVector3();
|
985
|
+
var all = manager.allocVector3();
|
986
|
+
var aul = manager.allocVector3();
|
987
|
+
lll.setValue(params.translationLimitation1[0], params.translationLimitation1[1], params.translationLimitation1[2]);
|
988
|
+
lul.setValue(params.translationLimitation2[0], params.translationLimitation2[1], params.translationLimitation2[2]);
|
989
|
+
all.setValue(params.rotationLimitation1[0], params.rotationLimitation1[1], params.rotationLimitation1[2]);
|
990
|
+
aul.setValue(params.rotationLimitation2[0], params.rotationLimitation2[1], params.rotationLimitation2[2]);
|
991
|
+
constraint.setLinearLowerLimit(lll);
|
992
|
+
constraint.setLinearUpperLimit(lul);
|
993
|
+
constraint.setAngularLowerLimit(all);
|
994
|
+
constraint.setAngularUpperLimit(aul);
|
995
|
+
|
996
|
+
for (var i = 0; i < 3; i++) {
|
997
|
+
if (params.springPosition[i] !== 0) {
|
998
|
+
constraint.enableSpring(i, true);
|
999
|
+
constraint.setStiffness(i, params.springPosition[i]);
|
1000
|
+
}
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
for (var _i = 0; _i < 3; _i++) {
|
1004
|
+
if (params.springRotation[_i] !== 0) {
|
1005
|
+
constraint.enableSpring(_i + 3, true);
|
1006
|
+
constraint.setStiffness(_i + 3, params.springRotation[_i]);
|
1007
|
+
}
|
1008
|
+
}
|
1009
|
+
/*
|
1010
|
+
* Currently(10/31/2016) official ammo.js doesn't support
|
1011
|
+
* btGeneric6DofSpringConstraint.setParam method.
|
1012
|
+
* You need custom ammo.js (add the method into idl) if you wanna use.
|
1013
|
+
* By setting this parameter, physics will be more like MMD's
|
1014
|
+
*/
|
1015
|
+
|
1016
|
+
|
1017
|
+
if (constraint.setParam !== undefined) {
|
1018
|
+
for (var _i2 = 0; _i2 < 6; _i2++) {
|
1019
|
+
// this parameter is from http://www20.atpages.jp/katwat/three.js_r58/examples/mytest37/mmd.three.js
|
1020
|
+
constraint.setParam(2, 0.475, _i2);
|
1021
|
+
}
|
1022
|
+
}
|
1023
|
+
|
1024
|
+
this.world.addConstraint(constraint, true);
|
1025
|
+
this.constraint = constraint;
|
1026
|
+
manager.freeTransform(form);
|
1027
|
+
manager.freeTransform(formA);
|
1028
|
+
manager.freeTransform(formB);
|
1029
|
+
manager.freeTransform(formInverseA);
|
1030
|
+
manager.freeTransform(formInverseB);
|
1031
|
+
manager.freeTransform(formA2);
|
1032
|
+
manager.freeTransform(formB2);
|
1033
|
+
manager.freeVector3(lll);
|
1034
|
+
manager.freeVector3(lul);
|
1035
|
+
manager.freeVector3(all);
|
1036
|
+
manager.freeVector3(aul);
|
1037
|
+
}
|
1038
|
+
}]);
|
1039
|
+
|
1040
|
+
return Constraint;
|
1041
|
+
}(); //
|
1042
|
+
|
1043
|
+
|
1044
|
+
var _position = new _three.Vector3();
|
1045
|
+
|
1046
|
+
var _quaternion = new _three.Quaternion();
|
1047
|
+
|
1048
|
+
var _scale = new _three.Vector3();
|
1049
|
+
|
1050
|
+
var _matrixWorldInv = new _three.Matrix4();
|
1051
|
+
|
1052
|
+
var MMDPhysicsHelper = /*#__PURE__*/function (_Object3D) {
|
1053
|
+
_inherits(MMDPhysicsHelper, _Object3D);
|
1054
|
+
|
1055
|
+
var _super = _createSuper(MMDPhysicsHelper);
|
1056
|
+
|
1057
|
+
/**
|
1058
|
+
* Visualize Rigid bodies
|
1059
|
+
*
|
1060
|
+
* @param {THREE.SkinnedMesh} mesh
|
1061
|
+
* @param {Physics} physics
|
1062
|
+
*/
|
1063
|
+
function MMDPhysicsHelper(mesh, physics) {
|
1064
|
+
var _this;
|
1065
|
+
|
1066
|
+
_classCallCheck(this, MMDPhysicsHelper);
|
1067
|
+
|
1068
|
+
_this = _super.call(this);
|
1069
|
+
_this.root = mesh;
|
1070
|
+
_this.physics = physics;
|
1071
|
+
|
1072
|
+
_this.matrix.copy(mesh.matrixWorld);
|
1073
|
+
|
1074
|
+
_this.matrixAutoUpdate = false;
|
1075
|
+
_this.materials = [];
|
1076
|
+
|
1077
|
+
_this.materials.push(new _three.MeshBasicMaterial({
|
1078
|
+
color: new _three.Color(0xff8888),
|
1079
|
+
wireframe: true,
|
1080
|
+
depthTest: false,
|
1081
|
+
depthWrite: false,
|
1082
|
+
opacity: 0.25,
|
1083
|
+
transparent: true
|
1084
|
+
}));
|
1085
|
+
|
1086
|
+
_this.materials.push(new _three.MeshBasicMaterial({
|
1087
|
+
color: new _three.Color(0x88ff88),
|
1088
|
+
wireframe: true,
|
1089
|
+
depthTest: false,
|
1090
|
+
depthWrite: false,
|
1091
|
+
opacity: 0.25,
|
1092
|
+
transparent: true
|
1093
|
+
}));
|
1094
|
+
|
1095
|
+
_this.materials.push(new _three.MeshBasicMaterial({
|
1096
|
+
color: new _three.Color(0x8888ff),
|
1097
|
+
wireframe: true,
|
1098
|
+
depthTest: false,
|
1099
|
+
depthWrite: false,
|
1100
|
+
opacity: 0.25,
|
1101
|
+
transparent: true
|
1102
|
+
}));
|
1103
|
+
|
1104
|
+
_this._init();
|
1105
|
+
|
1106
|
+
return _this;
|
1107
|
+
}
|
1108
|
+
/**
|
1109
|
+
* Updates Rigid Bodies visualization.
|
1110
|
+
*/
|
1111
|
+
|
1112
|
+
|
1113
|
+
_createClass(MMDPhysicsHelper, [{
|
1114
|
+
key: "updateMatrixWorld",
|
1115
|
+
value: function updateMatrixWorld(force) {
|
1116
|
+
var mesh = this.root;
|
1117
|
+
|
1118
|
+
if (this.visible) {
|
1119
|
+
var bodies = this.physics.bodies;
|
1120
|
+
|
1121
|
+
_matrixWorldInv.copy(mesh.matrixWorld).decompose(_position, _quaternion, _scale).compose(_position, _quaternion, _scale.set(1, 1, 1)).invert();
|
1122
|
+
|
1123
|
+
for (var i = 0, il = bodies.length; i < il; i++) {
|
1124
|
+
var body = bodies[i].body;
|
1125
|
+
var child = this.children[i];
|
1126
|
+
var tr = body.getCenterOfMassTransform();
|
1127
|
+
var origin = tr.getOrigin();
|
1128
|
+
var rotation = tr.getRotation();
|
1129
|
+
child.position.set(origin.x(), origin.y(), origin.z()).applyMatrix4(_matrixWorldInv);
|
1130
|
+
child.quaternion.setFromRotationMatrix(_matrixWorldInv).multiply(_quaternion.set(rotation.x(), rotation.y(), rotation.z(), rotation.w()));
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
this.matrix.copy(mesh.matrixWorld).decompose(_position, _quaternion, _scale).compose(_position, _quaternion, _scale.set(1, 1, 1));
|
1135
|
+
|
1136
|
+
_get(_getPrototypeOf(MMDPhysicsHelper.prototype), "updateMatrixWorld", this).call(this, force);
|
1137
|
+
} // private method
|
1138
|
+
|
1139
|
+
}, {
|
1140
|
+
key: "_init",
|
1141
|
+
value: function _init() {
|
1142
|
+
var bodies = this.physics.bodies;
|
1143
|
+
|
1144
|
+
function createGeometry(param) {
|
1145
|
+
switch (param.shapeType) {
|
1146
|
+
case 0:
|
1147
|
+
return new _three.SphereGeometry(param.width, 16, 8);
|
1148
|
+
|
1149
|
+
case 1:
|
1150
|
+
return new _three.BoxGeometry(param.width * 2, param.height * 2, param.depth * 2, 8, 8, 8);
|
1151
|
+
|
1152
|
+
case 2:
|
1153
|
+
return new createCapsuleGeometry(param.width, param.height, 16, 8);
|
1154
|
+
|
1155
|
+
default:
|
1156
|
+
return null;
|
1157
|
+
}
|
1158
|
+
} // copy from http://www20.atpages.jp/katwat/three.js_r58/examples/mytest37/mytest37.js?ver=20160815
|
1159
|
+
|
1160
|
+
|
1161
|
+
function createCapsuleGeometry(radius, cylinderHeight, segmentsRadius, segmentsHeight) {
|
1162
|
+
var geometry = new _three.CylinderGeometry(radius, radius, cylinderHeight, segmentsRadius, segmentsHeight, true);
|
1163
|
+
var upperSphere = new _three.Mesh(new _three.SphereGeometry(radius, segmentsRadius, segmentsHeight, 0, Math.PI * 2, 0, Math.PI / 2));
|
1164
|
+
var lowerSphere = new _three.Mesh(new _three.SphereGeometry(radius, segmentsRadius, segmentsHeight, 0, Math.PI * 2, Math.PI / 2, Math.PI / 2));
|
1165
|
+
upperSphere.position.set(0, cylinderHeight / 2, 0);
|
1166
|
+
lowerSphere.position.set(0, -cylinderHeight / 2, 0);
|
1167
|
+
upperSphere.updateMatrix();
|
1168
|
+
lowerSphere.updateMatrix();
|
1169
|
+
geometry.merge(upperSphere.geometry, upperSphere.matrix);
|
1170
|
+
geometry.merge(lowerSphere.geometry, lowerSphere.matrix);
|
1171
|
+
return geometry;
|
1172
|
+
}
|
1173
|
+
|
1174
|
+
for (var i = 0, il = bodies.length; i < il; i++) {
|
1175
|
+
var param = bodies[i].params;
|
1176
|
+
this.add(new _three.Mesh(createGeometry(param), this.materials[param.type]));
|
1177
|
+
}
|
1178
|
+
}
|
1179
|
+
}]);
|
1180
|
+
|
1181
|
+
return MMDPhysicsHelper;
|
1182
|
+
}(_three.Object3D);
|
1183
|
+
});
|