@needle-tools/three 0.145.2 → 0.146.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +3559 -6924
- package/build/three.js +3559 -6924
- package/build/three.min.js +1 -2
- package/build/three.module.js +732 -339
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +94 -28
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLCubeUVMaps.js +1 -1
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
|
|
35
35
|
this.manager = new ResourceManager();
|
|
36
36
|
this.mesh = mesh;
|
|
37
|
+
|
|
37
38
|
/*
|
|
38
39
|
* I don't know why but 1/60 unitStep easily breaks models
|
|
39
40
|
* so I set it 1/65 so far.
|
|
40
41
|
* Don't set too small unitStep because
|
|
41
42
|
* the smaller unitStep can make the performance worse.
|
|
42
43
|
*/
|
|
43
|
-
|
|
44
44
|
this.unitStep = params.unitStep !== undefined ? params.unitStep : 1 / 65;
|
|
45
45
|
this.maxStepNum = params.maxStepNum !== undefined ? params.maxStepNum : 3;
|
|
46
46
|
this.gravity = new THREE.Vector3( 0, - 9.8 * 10, 0 );
|
|
@@ -49,22 +49,22 @@
|
|
|
49
49
|
|
|
50
50
|
this.bodies = [];
|
|
51
51
|
this.constraints = [];
|
|
52
|
-
|
|
53
52
|
this._init( mesh, rigidBodyParams, constraintParams );
|
|
54
53
|
|
|
55
54
|
}
|
|
55
|
+
|
|
56
56
|
/**
|
|
57
57
|
* Advances Physics calculation and updates bones.
|
|
58
58
|
*
|
|
59
59
|
* @param {Number} delta - time in second
|
|
60
60
|
* @return {MMDPhysics}
|
|
61
61
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
62
|
update( delta ) {
|
|
65
63
|
|
|
66
64
|
const manager = this.manager;
|
|
67
|
-
const mesh = this.mesh;
|
|
65
|
+
const mesh = this.mesh;
|
|
66
|
+
|
|
67
|
+
// rigid bodies and constrains are for
|
|
68
68
|
// mesh's world scale (1, 1, 1).
|
|
69
69
|
// Convert to (1, 1, 1) if it isn't.
|
|
70
70
|
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
const quaternion = manager.allocThreeQuaternion();
|
|
74
74
|
const scale = manager.allocThreeVector3();
|
|
75
75
|
mesh.matrixWorld.decompose( position, quaternion, scale );
|
|
76
|
-
|
|
77
76
|
if ( scale.x !== 1 || scale.y !== 1 || scale.z !== 1 ) {
|
|
78
77
|
|
|
79
78
|
isNonDefaultScale = true;
|
|
@@ -81,7 +80,6 @@
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
let parent;
|
|
84
|
-
|
|
85
83
|
if ( isNonDefaultScale ) {
|
|
86
84
|
|
|
87
85
|
parent = mesh.parent;
|
|
@@ -90,15 +88,15 @@
|
|
|
90
88
|
mesh.scale.set( 1, 1, 1 );
|
|
91
89
|
mesh.updateMatrixWorld( true );
|
|
92
90
|
|
|
93
|
-
}
|
|
91
|
+
}
|
|
94
92
|
|
|
93
|
+
// calculate physics and update bones
|
|
95
94
|
|
|
96
95
|
this._updateRigidBodies();
|
|
97
|
-
|
|
98
96
|
this._stepSimulation( delta );
|
|
97
|
+
this._updateBones();
|
|
99
98
|
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
// restore mesh if converted above
|
|
102
100
|
|
|
103
101
|
if ( isNonDefaultScale ) {
|
|
104
102
|
|
|
@@ -113,13 +111,12 @@
|
|
|
113
111
|
return this;
|
|
114
112
|
|
|
115
113
|
}
|
|
114
|
+
|
|
116
115
|
/**
|
|
117
116
|
* Resets rigid bodies transorm to current bone's.
|
|
118
117
|
*
|
|
119
118
|
* @return {MMDPhysics}
|
|
120
119
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
120
|
reset() {
|
|
124
121
|
|
|
125
122
|
for ( let i = 0, il = this.bodies.length; i < il; i ++ ) {
|
|
@@ -131,14 +128,13 @@
|
|
|
131
128
|
return this;
|
|
132
129
|
|
|
133
130
|
}
|
|
131
|
+
|
|
134
132
|
/**
|
|
135
133
|
* Warm ups Rigid bodies. Calculates cycles steps.
|
|
136
134
|
*
|
|
137
135
|
* @param {Integer} cycles
|
|
138
136
|
* @return {MMDPhysics}
|
|
139
137
|
*/
|
|
140
|
-
|
|
141
|
-
|
|
142
138
|
warmup( cycles ) {
|
|
143
139
|
|
|
144
140
|
for ( let i = 0; i < cycles; i ++ ) {
|
|
@@ -150,14 +146,13 @@
|
|
|
150
146
|
return this;
|
|
151
147
|
|
|
152
148
|
}
|
|
149
|
+
|
|
153
150
|
/**
|
|
154
151
|
* Sets gravity.
|
|
155
152
|
*
|
|
156
153
|
* @param {Vector3} gravity
|
|
157
154
|
* @return {MMDPhysicsHelper}
|
|
158
155
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
156
|
setGravity( gravity ) {
|
|
162
157
|
|
|
163
158
|
this.world.setGravity( new Ammo.btVector3( gravity.x, gravity.y, gravity.z ) );
|
|
@@ -165,23 +160,25 @@
|
|
|
165
160
|
return this;
|
|
166
161
|
|
|
167
162
|
}
|
|
163
|
+
|
|
168
164
|
/**
|
|
169
165
|
* Creates MMDPhysicsHelper
|
|
170
166
|
*
|
|
171
167
|
* @return {MMDPhysicsHelper}
|
|
172
168
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
169
|
createHelper() {
|
|
176
170
|
|
|
177
171
|
return new MMDPhysicsHelper( this.mesh, this );
|
|
178
172
|
|
|
179
|
-
}
|
|
173
|
+
}
|
|
180
174
|
|
|
175
|
+
// private methods
|
|
181
176
|
|
|
182
177
|
_init( mesh, rigidBodyParams, constraintParams ) {
|
|
183
178
|
|
|
184
|
-
const manager = this.manager;
|
|
179
|
+
const manager = this.manager;
|
|
180
|
+
|
|
181
|
+
// rigid body/constraint parameters are for
|
|
185
182
|
// mesh's default world transform as position(0, 0, 0),
|
|
186
183
|
// quaternion(0, 0, 0, 1) and scale(0, 0, 0)
|
|
187
184
|
|
|
@@ -197,7 +194,6 @@
|
|
|
197
194
|
mesh.quaternion.set( 0, 0, 0, 1 );
|
|
198
195
|
mesh.scale.set( 1, 1, 1 );
|
|
199
196
|
mesh.updateMatrixWorld( true );
|
|
200
|
-
|
|
201
197
|
if ( this.world === null ) {
|
|
202
198
|
|
|
203
199
|
this.world = this._createWorld();
|
|
@@ -206,9 +202,7 @@
|
|
|
206
202
|
}
|
|
207
203
|
|
|
208
204
|
this._initRigidBodies( rigidBodyParams );
|
|
209
|
-
|
|
210
205
|
this._initConstraints( constraintParams );
|
|
211
|
-
|
|
212
206
|
if ( parent !== null ) mesh.parent = parent;
|
|
213
207
|
mesh.position.copy( currentPosition );
|
|
214
208
|
mesh.quaternion.copy( currentQuaternion );
|
|
@@ -220,7 +214,6 @@
|
|
|
220
214
|
manager.freeThreeVector3( currentScale );
|
|
221
215
|
|
|
222
216
|
}
|
|
223
|
-
|
|
224
217
|
_createWorld() {
|
|
225
218
|
|
|
226
219
|
const config = new Ammo.btDefaultCollisionConfiguration();
|
|
@@ -231,7 +224,6 @@
|
|
|
231
224
|
return world;
|
|
232
225
|
|
|
233
226
|
}
|
|
234
|
-
|
|
235
227
|
_initRigidBodies( rigidBodies ) {
|
|
236
228
|
|
|
237
229
|
for ( let i = 0, il = rigidBodies.length; i < il; i ++ ) {
|
|
@@ -241,7 +233,6 @@
|
|
|
241
233
|
}
|
|
242
234
|
|
|
243
235
|
}
|
|
244
|
-
|
|
245
236
|
_initConstraints( constraints ) {
|
|
246
237
|
|
|
247
238
|
for ( let i = 0, il = constraints.length; i < il; i ++ ) {
|
|
@@ -254,13 +245,11 @@
|
|
|
254
245
|
}
|
|
255
246
|
|
|
256
247
|
}
|
|
257
|
-
|
|
258
248
|
_stepSimulation( delta ) {
|
|
259
249
|
|
|
260
250
|
const unitStep = this.unitStep;
|
|
261
251
|
let stepTime = delta;
|
|
262
252
|
let maxStepNum = ( delta / unitStep | 0 ) + 1;
|
|
263
|
-
|
|
264
253
|
if ( stepTime < unitStep ) {
|
|
265
254
|
|
|
266
255
|
stepTime = unitStep;
|
|
@@ -277,7 +266,6 @@
|
|
|
277
266
|
this.world.stepSimulation( stepTime, maxStepNum, unitStep );
|
|
278
267
|
|
|
279
268
|
}
|
|
280
|
-
|
|
281
269
|
_updateRigidBodies() {
|
|
282
270
|
|
|
283
271
|
for ( let i = 0, il = this.bodies.length; i < il; i ++ ) {
|
|
@@ -287,7 +275,6 @@
|
|
|
287
275
|
}
|
|
288
276
|
|
|
289
277
|
}
|
|
290
|
-
|
|
291
278
|
_updateBones() {
|
|
292
279
|
|
|
293
280
|
for ( let i = 0, il = this.bodies.length; i < il; i ++ ) {
|
|
@@ -299,6 +286,7 @@
|
|
|
299
286
|
}
|
|
300
287
|
|
|
301
288
|
}
|
|
289
|
+
|
|
302
290
|
/**
|
|
303
291
|
* This manager's responsibilies are
|
|
304
292
|
*
|
|
@@ -308,8 +296,6 @@
|
|
|
308
296
|
*
|
|
309
297
|
* 2. provide simple Ammo object operations.
|
|
310
298
|
*/
|
|
311
|
-
|
|
312
|
-
|
|
313
299
|
class ResourceManager {
|
|
314
300
|
|
|
315
301
|
constructor() {
|
|
@@ -318,104 +304,89 @@
|
|
|
318
304
|
this.threeVector3s = [];
|
|
319
305
|
this.threeMatrix4s = [];
|
|
320
306
|
this.threeQuaternions = [];
|
|
321
|
-
this.threeEulers = [];
|
|
307
|
+
this.threeEulers = [];
|
|
322
308
|
|
|
309
|
+
// for Ammo.js
|
|
323
310
|
this.transforms = [];
|
|
324
311
|
this.quaternions = [];
|
|
325
312
|
this.vector3s = [];
|
|
326
313
|
|
|
327
314
|
}
|
|
328
|
-
|
|
329
315
|
allocThreeVector3() {
|
|
330
316
|
|
|
331
317
|
return this.threeVector3s.length > 0 ? this.threeVector3s.pop() : new THREE.Vector3();
|
|
332
318
|
|
|
333
319
|
}
|
|
334
|
-
|
|
335
320
|
freeThreeVector3( v ) {
|
|
336
321
|
|
|
337
322
|
this.threeVector3s.push( v );
|
|
338
323
|
|
|
339
324
|
}
|
|
340
|
-
|
|
341
325
|
allocThreeMatrix4() {
|
|
342
326
|
|
|
343
327
|
return this.threeMatrix4s.length > 0 ? this.threeMatrix4s.pop() : new THREE.Matrix4();
|
|
344
328
|
|
|
345
329
|
}
|
|
346
|
-
|
|
347
330
|
freeThreeMatrix4( m ) {
|
|
348
331
|
|
|
349
332
|
this.threeMatrix4s.push( m );
|
|
350
333
|
|
|
351
334
|
}
|
|
352
|
-
|
|
353
335
|
allocThreeQuaternion() {
|
|
354
336
|
|
|
355
337
|
return this.threeQuaternions.length > 0 ? this.threeQuaternions.pop() : new THREE.Quaternion();
|
|
356
338
|
|
|
357
339
|
}
|
|
358
|
-
|
|
359
340
|
freeThreeQuaternion( q ) {
|
|
360
341
|
|
|
361
342
|
this.threeQuaternions.push( q );
|
|
362
343
|
|
|
363
344
|
}
|
|
364
|
-
|
|
365
345
|
allocThreeEuler() {
|
|
366
346
|
|
|
367
347
|
return this.threeEulers.length > 0 ? this.threeEulers.pop() : new THREE.Euler();
|
|
368
348
|
|
|
369
349
|
}
|
|
370
|
-
|
|
371
350
|
freeThreeEuler( e ) {
|
|
372
351
|
|
|
373
352
|
this.threeEulers.push( e );
|
|
374
353
|
|
|
375
354
|
}
|
|
376
|
-
|
|
377
355
|
allocTransform() {
|
|
378
356
|
|
|
379
357
|
return this.transforms.length > 0 ? this.transforms.pop() : new Ammo.btTransform();
|
|
380
358
|
|
|
381
359
|
}
|
|
382
|
-
|
|
383
360
|
freeTransform( t ) {
|
|
384
361
|
|
|
385
362
|
this.transforms.push( t );
|
|
386
363
|
|
|
387
364
|
}
|
|
388
|
-
|
|
389
365
|
allocQuaternion() {
|
|
390
366
|
|
|
391
367
|
return this.quaternions.length > 0 ? this.quaternions.pop() : new Ammo.btQuaternion();
|
|
392
368
|
|
|
393
369
|
}
|
|
394
|
-
|
|
395
370
|
freeQuaternion( q ) {
|
|
396
371
|
|
|
397
372
|
this.quaternions.push( q );
|
|
398
373
|
|
|
399
374
|
}
|
|
400
|
-
|
|
401
375
|
allocVector3() {
|
|
402
376
|
|
|
403
377
|
return this.vector3s.length > 0 ? this.vector3s.pop() : new Ammo.btVector3();
|
|
404
378
|
|
|
405
379
|
}
|
|
406
|
-
|
|
407
380
|
freeVector3( v ) {
|
|
408
381
|
|
|
409
382
|
this.vector3s.push( v );
|
|
410
383
|
|
|
411
384
|
}
|
|
412
|
-
|
|
413
385
|
setIdentity( t ) {
|
|
414
386
|
|
|
415
387
|
t.setIdentity();
|
|
416
388
|
|
|
417
389
|
}
|
|
418
|
-
|
|
419
390
|
getBasis( t ) {
|
|
420
391
|
|
|
421
392
|
var q = this.allocQuaternion();
|
|
@@ -423,7 +394,6 @@
|
|
|
423
394
|
return q;
|
|
424
395
|
|
|
425
396
|
}
|
|
426
|
-
|
|
427
397
|
getBasisAsMatrix3( t ) {
|
|
428
398
|
|
|
429
399
|
var q = this.getBasis( t );
|
|
@@ -432,32 +402,27 @@
|
|
|
432
402
|
return m;
|
|
433
403
|
|
|
434
404
|
}
|
|
435
|
-
|
|
436
405
|
getOrigin( t ) {
|
|
437
406
|
|
|
438
407
|
return t.getOrigin();
|
|
439
408
|
|
|
440
409
|
}
|
|
441
|
-
|
|
442
410
|
setOrigin( t, v ) {
|
|
443
411
|
|
|
444
412
|
t.getOrigin().setValue( v.x(), v.y(), v.z() );
|
|
445
413
|
|
|
446
414
|
}
|
|
447
|
-
|
|
448
415
|
copyOrigin( t1, t2 ) {
|
|
449
416
|
|
|
450
417
|
var o = t2.getOrigin();
|
|
451
418
|
this.setOrigin( t1, o );
|
|
452
419
|
|
|
453
420
|
}
|
|
454
|
-
|
|
455
421
|
setBasis( t, q ) {
|
|
456
422
|
|
|
457
423
|
t.setRotation( q );
|
|
458
424
|
|
|
459
425
|
}
|
|
460
|
-
|
|
461
426
|
setBasisFromMatrix3( t, m ) {
|
|
462
427
|
|
|
463
428
|
var q = this.matrix3ToQuaternion( m );
|
|
@@ -465,19 +430,16 @@
|
|
|
465
430
|
this.freeQuaternion( q );
|
|
466
431
|
|
|
467
432
|
}
|
|
468
|
-
|
|
469
433
|
setOriginFromArray3( t, a ) {
|
|
470
434
|
|
|
471
435
|
t.getOrigin().setValue( a[ 0 ], a[ 1 ], a[ 2 ] );
|
|
472
436
|
|
|
473
437
|
}
|
|
474
|
-
|
|
475
438
|
setOriginFromThreeVector3( t, v ) {
|
|
476
439
|
|
|
477
440
|
t.getOrigin().setValue( v.x, v.y, v.z );
|
|
478
441
|
|
|
479
442
|
}
|
|
480
|
-
|
|
481
443
|
setBasisFromArray3( t, a ) {
|
|
482
444
|
|
|
483
445
|
var thQ = this.allocThreeQuaternion();
|
|
@@ -488,7 +450,6 @@
|
|
|
488
450
|
this.freeThreeQuaternion( thQ );
|
|
489
451
|
|
|
490
452
|
}
|
|
491
|
-
|
|
492
453
|
setBasisFromThreeQuaternion( t, a ) {
|
|
493
454
|
|
|
494
455
|
var q = this.allocQuaternion();
|
|
@@ -500,7 +461,6 @@
|
|
|
500
461
|
this.freeQuaternion( q );
|
|
501
462
|
|
|
502
463
|
}
|
|
503
|
-
|
|
504
464
|
multiplyTransforms( t1, t2 ) {
|
|
505
465
|
|
|
506
466
|
var t = this.allocTransform();
|
|
@@ -519,7 +479,6 @@
|
|
|
519
479
|
return t;
|
|
520
480
|
|
|
521
481
|
}
|
|
522
|
-
|
|
523
482
|
inverseTransform( t ) {
|
|
524
483
|
|
|
525
484
|
var t2 = this.allocTransform();
|
|
@@ -535,7 +494,6 @@
|
|
|
535
494
|
return t2;
|
|
536
495
|
|
|
537
496
|
}
|
|
538
|
-
|
|
539
497
|
multiplyMatrices3( m1, m2 ) {
|
|
540
498
|
|
|
541
499
|
var m3 = [];
|
|
@@ -563,7 +521,6 @@
|
|
|
563
521
|
return m3;
|
|
564
522
|
|
|
565
523
|
}
|
|
566
|
-
|
|
567
524
|
addVector3( v1, v2 ) {
|
|
568
525
|
|
|
569
526
|
var v = this.allocVector3();
|
|
@@ -571,13 +528,11 @@
|
|
|
571
528
|
return v;
|
|
572
529
|
|
|
573
530
|
}
|
|
574
|
-
|
|
575
531
|
dotVectors3( v1, v2 ) {
|
|
576
532
|
|
|
577
533
|
return v1.x() * v2.x() + v1.y() * v2.y() + v1.z() * v2.z();
|
|
578
534
|
|
|
579
535
|
}
|
|
580
|
-
|
|
581
536
|
rowOfMatrix3( m, i ) {
|
|
582
537
|
|
|
583
538
|
var v = this.allocVector3();
|
|
@@ -585,7 +540,6 @@
|
|
|
585
540
|
return v;
|
|
586
541
|
|
|
587
542
|
}
|
|
588
|
-
|
|
589
543
|
columnOfMatrix3( m, i ) {
|
|
590
544
|
|
|
591
545
|
var v = this.allocVector3();
|
|
@@ -593,7 +547,6 @@
|
|
|
593
547
|
return v;
|
|
594
548
|
|
|
595
549
|
}
|
|
596
|
-
|
|
597
550
|
negativeVector3( v ) {
|
|
598
551
|
|
|
599
552
|
var v2 = this.allocVector3();
|
|
@@ -601,7 +554,6 @@
|
|
|
601
554
|
return v2;
|
|
602
555
|
|
|
603
556
|
}
|
|
604
|
-
|
|
605
557
|
multiplyMatrix3ByVector3( m, v ) {
|
|
606
558
|
|
|
607
559
|
var v4 = this.allocVector3();
|
|
@@ -618,7 +570,6 @@
|
|
|
618
570
|
return v4;
|
|
619
571
|
|
|
620
572
|
}
|
|
621
|
-
|
|
622
573
|
transposeMatrix3( m ) {
|
|
623
574
|
|
|
624
575
|
var m2 = [];
|
|
@@ -634,7 +585,6 @@
|
|
|
634
585
|
return m2;
|
|
635
586
|
|
|
636
587
|
}
|
|
637
|
-
|
|
638
588
|
quaternionToMatrix3( q ) {
|
|
639
589
|
|
|
640
590
|
var m = [];
|
|
@@ -663,12 +613,10 @@
|
|
|
663
613
|
return m;
|
|
664
614
|
|
|
665
615
|
}
|
|
666
|
-
|
|
667
616
|
matrix3ToQuaternion( m ) {
|
|
668
617
|
|
|
669
618
|
var t = m[ 0 ] + m[ 4 ] + m[ 8 ];
|
|
670
619
|
var s, x, y, z, w;
|
|
671
|
-
|
|
672
620
|
if ( t > 0 ) {
|
|
673
621
|
|
|
674
622
|
s = Math.sqrt( t + 1.0 ) * 2;
|
|
@@ -713,14 +661,13 @@
|
|
|
713
661
|
}
|
|
714
662
|
|
|
715
663
|
}
|
|
664
|
+
|
|
716
665
|
/**
|
|
717
666
|
* @param {THREE.SkinnedMesh} mesh
|
|
718
667
|
* @param {Ammo.btDiscreteDynamicsWorld} world
|
|
719
668
|
* @param {Object} params
|
|
720
669
|
* @param {ResourceManager} manager
|
|
721
670
|
*/
|
|
722
|
-
|
|
723
|
-
|
|
724
671
|
class RigidBody {
|
|
725
672
|
|
|
726
673
|
constructor( mesh, world, params, manager ) {
|
|
@@ -733,31 +680,27 @@
|
|
|
733
680
|
this.bone = null;
|
|
734
681
|
this.boneOffsetForm = null;
|
|
735
682
|
this.boneOffsetFormInverse = null;
|
|
736
|
-
|
|
737
683
|
this._init();
|
|
738
684
|
|
|
739
685
|
}
|
|
686
|
+
|
|
740
687
|
/**
|
|
741
688
|
* Resets rigid body transform to the current bone's.
|
|
742
689
|
*
|
|
743
690
|
* @return {RigidBody}
|
|
744
691
|
*/
|
|
745
|
-
|
|
746
|
-
|
|
747
692
|
reset() {
|
|
748
693
|
|
|
749
694
|
this._setTransformFromBone();
|
|
750
|
-
|
|
751
695
|
return this;
|
|
752
696
|
|
|
753
697
|
}
|
|
698
|
+
|
|
754
699
|
/**
|
|
755
700
|
* Updates rigid body's transform from the current bone.
|
|
756
701
|
*
|
|
757
702
|
* @return {RidigBody}
|
|
758
703
|
*/
|
|
759
|
-
|
|
760
|
-
|
|
761
704
|
updateFromBone() {
|
|
762
705
|
|
|
763
706
|
if ( this.params.boneIndex !== - 1 && this.params.type === 0 ) {
|
|
@@ -769,13 +712,12 @@
|
|
|
769
712
|
return this;
|
|
770
713
|
|
|
771
714
|
}
|
|
715
|
+
|
|
772
716
|
/**
|
|
773
717
|
* Updates bone from the current ridid body's transform.
|
|
774
718
|
*
|
|
775
719
|
* @return {RidigBody}
|
|
776
720
|
*/
|
|
777
|
-
|
|
778
|
-
|
|
779
721
|
updateBone() {
|
|
780
722
|
|
|
781
723
|
if ( this.params.type === 0 || this.params.boneIndex === - 1 ) {
|
|
@@ -785,7 +727,6 @@
|
|
|
785
727
|
}
|
|
786
728
|
|
|
787
729
|
this._updateBoneRotation();
|
|
788
|
-
|
|
789
730
|
if ( this.params.type === 1 ) {
|
|
790
731
|
|
|
791
732
|
this._updateBonePosition();
|
|
@@ -793,7 +734,6 @@
|
|
|
793
734
|
}
|
|
794
735
|
|
|
795
736
|
this.bone.updateMatrixWorld( true );
|
|
796
|
-
|
|
797
737
|
if ( this.params.type === 2 ) {
|
|
798
738
|
|
|
799
739
|
this._setPositionFromBone();
|
|
@@ -802,8 +742,9 @@
|
|
|
802
742
|
|
|
803
743
|
return this;
|
|
804
744
|
|
|
805
|
-
}
|
|
745
|
+
}
|
|
806
746
|
|
|
747
|
+
// private methods
|
|
807
748
|
|
|
808
749
|
_init() {
|
|
809
750
|
|
|
@@ -813,13 +754,10 @@
|
|
|
813
754
|
|
|
814
755
|
case 0:
|
|
815
756
|
return new Ammo.btSphereShape( p.width );
|
|
816
|
-
|
|
817
757
|
case 1:
|
|
818
758
|
return new Ammo.btBoxShape( new Ammo.btVector3( p.width, p.height, p.depth ) );
|
|
819
|
-
|
|
820
759
|
case 2:
|
|
821
760
|
return new Ammo.btCapsuleShape( p.width, p.height );
|
|
822
|
-
|
|
823
761
|
default:
|
|
824
762
|
throw new Error( 'unknown shape type ' + p.shapeType );
|
|
825
763
|
|
|
@@ -835,7 +773,6 @@
|
|
|
835
773
|
const weight = params.type === 0 ? 0 : params.weight;
|
|
836
774
|
const localInertia = manager.allocVector3();
|
|
837
775
|
localInertia.setValue( 0, 0, 0 );
|
|
838
|
-
|
|
839
776
|
if ( weight !== 0 ) {
|
|
840
777
|
|
|
841
778
|
shape.calculateLocalInertia( weight, localInertia );
|
|
@@ -856,16 +793,15 @@
|
|
|
856
793
|
info.set_m_friction( params.friction );
|
|
857
794
|
info.set_m_restitution( params.restitution );
|
|
858
795
|
const body = new Ammo.btRigidBody( info );
|
|
859
|
-
|
|
860
796
|
if ( params.type === 0 ) {
|
|
861
797
|
|
|
862
798
|
body.setCollisionFlags( body.getCollisionFlags() | 2 );
|
|
799
|
+
|
|
863
800
|
/*
|
|
864
801
|
* It'd be better to comment out this line though in general I should call this method
|
|
865
802
|
* because I'm not sure why but physics will be more like MMD's
|
|
866
803
|
* if I comment out.
|
|
867
804
|
*/
|
|
868
|
-
|
|
869
805
|
body.setActivationState( 4 );
|
|
870
806
|
|
|
871
807
|
}
|
|
@@ -883,7 +819,6 @@
|
|
|
883
819
|
manager.freeThreeVector3( vector );
|
|
884
820
|
|
|
885
821
|
}
|
|
886
|
-
|
|
887
822
|
_getBoneTransform() {
|
|
888
823
|
|
|
889
824
|
const manager = this.manager;
|
|
@@ -902,7 +837,6 @@
|
|
|
902
837
|
return form;
|
|
903
838
|
|
|
904
839
|
}
|
|
905
|
-
|
|
906
840
|
_getWorldTransformForBone() {
|
|
907
841
|
|
|
908
842
|
const manager = this.manager;
|
|
@@ -910,45 +844,38 @@
|
|
|
910
844
|
return manager.multiplyTransforms( tr, this.boneOffsetFormInverse );
|
|
911
845
|
|
|
912
846
|
}
|
|
913
|
-
|
|
914
847
|
_setTransformFromBone() {
|
|
915
848
|
|
|
916
849
|
const manager = this.manager;
|
|
850
|
+
const form = this._getBoneTransform();
|
|
917
851
|
|
|
918
|
-
|
|
852
|
+
// TODO: check the most appropriate way to set
|
|
919
853
|
//this.body.setWorldTransform( form );
|
|
920
|
-
|
|
921
|
-
|
|
922
854
|
this.body.setCenterOfMassTransform( form );
|
|
923
855
|
this.body.getMotionState().setWorldTransform( form );
|
|
924
856
|
manager.freeTransform( form );
|
|
925
857
|
|
|
926
858
|
}
|
|
927
|
-
|
|
928
859
|
_setPositionFromBone() {
|
|
929
860
|
|
|
930
861
|
const manager = this.manager;
|
|
931
|
-
|
|
932
862
|
const form = this._getBoneTransform();
|
|
933
|
-
|
|
934
863
|
const tr = manager.allocTransform();
|
|
935
864
|
this.body.getMotionState().getWorldTransform( tr );
|
|
936
|
-
manager.copyOrigin( tr, form );
|
|
937
|
-
//this.body.setWorldTransform( tr );
|
|
865
|
+
manager.copyOrigin( tr, form );
|
|
938
866
|
|
|
867
|
+
// TODO: check the most appropriate way to set
|
|
868
|
+
//this.body.setWorldTransform( tr );
|
|
939
869
|
this.body.setCenterOfMassTransform( tr );
|
|
940
870
|
this.body.getMotionState().setWorldTransform( tr );
|
|
941
871
|
manager.freeTransform( tr );
|
|
942
872
|
manager.freeTransform( form );
|
|
943
873
|
|
|
944
874
|
}
|
|
945
|
-
|
|
946
875
|
_updateBoneRotation() {
|
|
947
876
|
|
|
948
877
|
const manager = this.manager;
|
|
949
|
-
|
|
950
878
|
const tr = this._getWorldTransformForBone();
|
|
951
|
-
|
|
952
879
|
const q = manager.getBasis( tr );
|
|
953
880
|
const thQ = manager.allocThreeQuaternion();
|
|
954
881
|
const thQ2 = manager.allocThreeQuaternion();
|
|
@@ -956,12 +883,15 @@
|
|
|
956
883
|
thQ.set( q.x(), q.y(), q.z(), q.w() );
|
|
957
884
|
thQ2.setFromRotationMatrix( this.bone.matrixWorld );
|
|
958
885
|
thQ2.conjugate();
|
|
959
|
-
thQ2.multiply( thQ );
|
|
886
|
+
thQ2.multiply( thQ );
|
|
887
|
+
|
|
888
|
+
//this.bone.quaternion.multiply( thQ2 );
|
|
960
889
|
|
|
961
|
-
thQ3.setFromRotationMatrix( this.bone.matrix );
|
|
890
|
+
thQ3.setFromRotationMatrix( this.bone.matrix );
|
|
891
|
+
|
|
892
|
+
// Renormalizing quaternion here because repeatedly transforming
|
|
962
893
|
// quaternion continuously accumulates floating point error and
|
|
963
894
|
// can end up being overflow. See #15335
|
|
964
|
-
|
|
965
895
|
this.bone.quaternion.copy( thQ2.multiply( thQ3 ).normalize() );
|
|
966
896
|
manager.freeThreeQuaternion( thQ );
|
|
967
897
|
manager.freeThreeQuaternion( thQ2 );
|
|
@@ -970,17 +900,13 @@
|
|
|
970
900
|
manager.freeTransform( tr );
|
|
971
901
|
|
|
972
902
|
}
|
|
973
|
-
|
|
974
903
|
_updateBonePosition() {
|
|
975
904
|
|
|
976
905
|
const manager = this.manager;
|
|
977
|
-
|
|
978
906
|
const tr = this._getWorldTransformForBone();
|
|
979
|
-
|
|
980
907
|
const thV = manager.allocThreeVector3();
|
|
981
908
|
const o = manager.getOrigin( tr );
|
|
982
909
|
thV.set( o.x(), o.y(), o.z() );
|
|
983
|
-
|
|
984
910
|
if ( this.bone.parent ) {
|
|
985
911
|
|
|
986
912
|
this.bone.parent.worldToLocal( thV );
|
|
@@ -993,8 +919,9 @@
|
|
|
993
919
|
|
|
994
920
|
}
|
|
995
921
|
|
|
996
|
-
}
|
|
922
|
+
}
|
|
997
923
|
|
|
924
|
+
//
|
|
998
925
|
|
|
999
926
|
class Constraint {
|
|
1000
927
|
|
|
@@ -1015,11 +942,11 @@
|
|
|
1015
942
|
this.params = params;
|
|
1016
943
|
this.manager = manager;
|
|
1017
944
|
this.constraint = null;
|
|
1018
|
-
|
|
1019
945
|
this._init();
|
|
1020
946
|
|
|
1021
|
-
}
|
|
947
|
+
}
|
|
1022
948
|
|
|
949
|
+
// private method
|
|
1023
950
|
|
|
1024
951
|
_init() {
|
|
1025
952
|
|
|
@@ -1052,7 +979,6 @@
|
|
|
1052
979
|
constraint.setLinearUpperLimit( lul );
|
|
1053
980
|
constraint.setAngularLowerLimit( all );
|
|
1054
981
|
constraint.setAngularUpperLimit( aul );
|
|
1055
|
-
|
|
1056
982
|
for ( let i = 0; i < 3; i ++ ) {
|
|
1057
983
|
|
|
1058
984
|
if ( params.springPosition[ i ] !== 0 ) {
|
|
@@ -1074,14 +1000,13 @@
|
|
|
1074
1000
|
}
|
|
1075
1001
|
|
|
1076
1002
|
}
|
|
1003
|
+
|
|
1077
1004
|
/*
|
|
1078
1005
|
* Currently(10/31/2016) official ammo.js doesn't support
|
|
1079
1006
|
* btGeneric6DofSpringConstraint.setParam method.
|
|
1080
1007
|
* You need custom ammo.js (add the method into idl) if you wanna use.
|
|
1081
1008
|
* By setting this parameter, physics will be more like MMD's
|
|
1082
1009
|
*/
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
1010
|
if ( constraint.setParam !== undefined ) {
|
|
1086
1011
|
|
|
1087
1012
|
for ( let i = 0; i < 6; i ++ ) {
|
|
@@ -1108,17 +1033,14 @@
|
|
|
1108
1033
|
|
|
1109
1034
|
}
|
|
1110
1035
|
|
|
1111
|
-
}
|
|
1036
|
+
}
|
|
1112
1037
|
|
|
1038
|
+
//
|
|
1113
1039
|
|
|
1114
1040
|
const _position = new THREE.Vector3();
|
|
1115
|
-
|
|
1116
1041
|
const _quaternion = new THREE.Quaternion();
|
|
1117
|
-
|
|
1118
1042
|
const _scale = new THREE.Vector3();
|
|
1119
|
-
|
|
1120
1043
|
const _matrixWorldInv = new THREE.Matrix4();
|
|
1121
|
-
|
|
1122
1044
|
class MMDPhysicsHelper extends THREE.Object3D {
|
|
1123
1045
|
|
|
1124
1046
|
/**
|
|
@@ -1159,25 +1081,42 @@
|
|
|
1159
1081
|
opacity: 0.25,
|
|
1160
1082
|
transparent: true
|
|
1161
1083
|
} ) );
|
|
1162
|
-
|
|
1163
1084
|
this._init();
|
|
1164
1085
|
|
|
1165
1086
|
}
|
|
1087
|
+
|
|
1166
1088
|
/**
|
|
1167
|
-
*
|
|
1089
|
+
* Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
|
|
1168
1090
|
*/
|
|
1091
|
+
dispose() {
|
|
1092
|
+
|
|
1093
|
+
const materials = this.materials;
|
|
1094
|
+
const children = this.children;
|
|
1095
|
+
for ( let i = 0; i < materials.length; i ++ ) {
|
|
1169
1096
|
|
|
1097
|
+
materials[ i ].dispose();
|
|
1170
1098
|
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
for ( let i = 0; i < children.length; i ++ ) {
|
|
1102
|
+
|
|
1103
|
+
const child = children[ i ];
|
|
1104
|
+
if ( child.isMesh ) child.geometry.dispose();
|
|
1105
|
+
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* Updates Rigid Bodies visualization.
|
|
1112
|
+
*/
|
|
1171
1113
|
updateMatrixWorld( force ) {
|
|
1172
1114
|
|
|
1173
1115
|
var mesh = this.root;
|
|
1174
|
-
|
|
1175
1116
|
if ( this.visible ) {
|
|
1176
1117
|
|
|
1177
1118
|
var bodies = this.physics.bodies;
|
|
1178
|
-
|
|
1179
1119
|
_matrixWorldInv.copy( mesh.matrixWorld ).decompose( _position, _quaternion, _scale ).compose( _position, _quaternion, _scale.set( 1, 1, 1 ) ).invert();
|
|
1180
|
-
|
|
1181
1120
|
for ( var i = 0, il = bodies.length; i < il; i ++ ) {
|
|
1182
1121
|
|
|
1183
1122
|
var body = bodies[ i ].body;
|
|
@@ -1195,26 +1134,23 @@
|
|
|
1195
1134
|
this.matrix.copy( mesh.matrixWorld ).decompose( _position, _quaternion, _scale ).compose( _position, _quaternion, _scale.set( 1, 1, 1 ) );
|
|
1196
1135
|
super.updateMatrixWorld( force );
|
|
1197
1136
|
|
|
1198
|
-
}
|
|
1137
|
+
}
|
|
1199
1138
|
|
|
1139
|
+
// private method
|
|
1200
1140
|
|
|
1201
1141
|
_init() {
|
|
1202
1142
|
|
|
1203
1143
|
var bodies = this.physics.bodies;
|
|
1204
|
-
|
|
1205
1144
|
function createGeometry( param ) {
|
|
1206
1145
|
|
|
1207
1146
|
switch ( param.shapeType ) {
|
|
1208
1147
|
|
|
1209
1148
|
case 0:
|
|
1210
1149
|
return new THREE.SphereGeometry( param.width, 16, 8 );
|
|
1211
|
-
|
|
1212
1150
|
case 1:
|
|
1213
1151
|
return new THREE.BoxGeometry( param.width * 2, param.height * 2, param.depth * 2, 8, 8, 8 );
|
|
1214
|
-
|
|
1215
1152
|
case 2:
|
|
1216
1153
|
return new THREE.CapsuleGeometry( param.width, param.height, 8, 16 );
|
|
1217
|
-
|
|
1218
1154
|
default:
|
|
1219
1155
|
return null;
|
|
1220
1156
|
|