@needle-tools/three 0.145.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +84 -0
- package/build/three.cjs +36042 -0
- package/build/three.js +36048 -0
- package/build/three.min.js +6 -0
- package/build/three.module.js +49769 -0
- package/examples/fonts/LICENSE +13 -0
- package/examples/fonts/README.md +11 -0
- package/examples/fonts/droid/NOTICE +190 -0
- package/examples/fonts/droid/README.txt +18 -0
- package/examples/fonts/droid/droid_sans_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_sans_regular.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_bold.typeface.json +1 -0
- package/examples/fonts/droid/droid_serif_regular.typeface.json +1 -0
- package/examples/fonts/gentilis_bold.typeface.json +1 -0
- package/examples/fonts/gentilis_regular.typeface.json +1 -0
- package/examples/fonts/helvetiker_bold.typeface.json +1 -0
- package/examples/fonts/helvetiker_regular.typeface.json +1 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff +0 -0
- package/examples/fonts/open-sans/open-sans-v15-cyrillic-ext_greek_greek-ext_cyrillic_latin_latin-ext_vietnamese-regular.woff2 +0 -0
- package/examples/fonts/open-sans/open-sans.css +9 -0
- package/examples/fonts/optimer_bold.typeface.json +1 -0
- package/examples/fonts/optimer_regular.typeface.json +1 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.eot +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.svg +3966 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.ttf +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff +0 -0
- package/examples/fonts/tabler-icons/fonts/tabler-icons.woff2 +0 -0
- package/examples/fonts/tabler-icons/tabler-icons.min.css +4 -0
- package/examples/fonts/ttf/README.md +9 -0
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/js/animation/AnimationClipCreator.js +97 -0
- package/examples/js/animation/CCDIKSolver.js +433 -0
- package/examples/js/animation/MMDAnimationHelper.js +1117 -0
- package/examples/js/animation/MMDPhysics.js +1238 -0
- package/examples/js/cameras/CinematicCamera.js +157 -0
- package/examples/js/controls/ArcballControls.js +3037 -0
- package/examples/js/controls/DragControls.js +230 -0
- package/examples/js/controls/FirstPersonControls.js +334 -0
- package/examples/js/controls/FlyControls.js +347 -0
- package/examples/js/controls/OrbitControls.js +1075 -0
- package/examples/js/controls/PointerLockControls.js +153 -0
- package/examples/js/controls/TrackballControls.js +782 -0
- package/examples/js/controls/TransformControls.js +1386 -0
- package/examples/js/csm/CSM.js +382 -0
- package/examples/js/csm/CSMFrustum.js +133 -0
- package/examples/js/csm/CSMHelper.js +145 -0
- package/examples/js/csm/CSMShader.js +257 -0
- package/examples/js/curves/CurveExtras.js +348 -0
- package/examples/js/curves/NURBSCurve.js +75 -0
- package/examples/js/curves/NURBSSurface.js +54 -0
- package/examples/js/curves/NURBSUtils.js +476 -0
- package/examples/js/effects/AnaglyphEffect.js +100 -0
- package/examples/js/effects/AsciiEffect.js +259 -0
- package/examples/js/effects/OutlineEffect.js +454 -0
- package/examples/js/effects/ParallaxBarrierEffect.js +75 -0
- package/examples/js/effects/PeppersGhostEffect.js +166 -0
- package/examples/js/effects/StereoEffect.js +50 -0
- package/examples/js/environments/DebugEnvironment.js +53 -0
- package/examples/js/environments/RoomEnvironment.js +122 -0
- package/examples/js/exporters/ColladaExporter.js +504 -0
- package/examples/js/exporters/DRACOExporter.js +212 -0
- package/examples/js/exporters/EXRExporter.js +458 -0
- package/examples/js/exporters/GLTFExporter.js +2543 -0
- package/examples/js/exporters/MMDExporter.js +194 -0
- package/examples/js/exporters/OBJExporter.js +251 -0
- package/examples/js/exporters/PLYExporter.js +422 -0
- package/examples/js/exporters/STLExporter.js +190 -0
- package/examples/js/exporters/USDZExporter.js +523 -0
- package/examples/js/geometries/BoxLineGeometry.js +60 -0
- package/examples/js/geometries/ConvexGeometry.js +48 -0
- package/examples/js/geometries/DecalGeometry.js +291 -0
- package/examples/js/geometries/LightningStrike.js +874 -0
- package/examples/js/geometries/ParametricGeometries.js +215 -0
- package/examples/js/geometries/ParametricGeometry.js +108 -0
- package/examples/js/geometries/RoundedBoxGeometry.js +140 -0
- package/examples/js/geometries/TeapotGeometry.js +331 -0
- package/examples/js/geometries/TextGeometry.js +51 -0
- package/examples/js/helpers/LightProbeHelper.js +49 -0
- package/examples/js/helpers/OctreeHelper.js +74 -0
- package/examples/js/helpers/PositionalAudioHelper.js +89 -0
- package/examples/js/helpers/RectAreaLightHelper.js +74 -0
- package/examples/js/helpers/VertexNormalsHelper.js +72 -0
- package/examples/js/helpers/VertexTangentsHelper.js +62 -0
- package/examples/js/helpers/ViewHelper.js +266 -0
- package/examples/js/interactive/HTMLMesh.js +508 -0
- package/examples/js/interactive/InteractiveGroup.js +101 -0
- package/examples/js/interactive/SelectionBox.js +262 -0
- package/examples/js/interactive/SelectionHelper.js +91 -0
- package/examples/js/libs/ammo.wasm.js +822 -0
- package/examples/js/libs/ammo.wasm.wasm +0 -0
- package/examples/js/libs/basis/README.md +46 -0
- package/examples/js/libs/basis/basis_transcoder.js +21 -0
- package/examples/js/libs/basis/basis_transcoder.wasm +0 -0
- package/examples/js/libs/chevrotain.min.js +3 -0
- package/examples/js/libs/draco/README.md +32 -0
- package/examples/js/libs/draco/draco_decoder.js +52 -0
- package/examples/js/libs/draco/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/draco_encoder.js +33 -0
- package/examples/js/libs/draco/draco_wasm_wrapper.js +104 -0
- package/examples/js/libs/draco/gltf/draco_decoder.js +48 -0
- package/examples/js/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/examples/js/libs/draco/gltf/draco_encoder.js +33 -0
- package/examples/js/libs/draco/gltf/draco_wasm_wrapper.js +104 -0
- package/examples/js/libs/fflate.min.js +7 -0
- package/examples/js/libs/ktx-parse.umd.js +1 -0
- package/examples/js/libs/lottie_canvas.js +12751 -0
- package/examples/js/libs/meshopt_decoder.js +188 -0
- package/examples/js/libs/opentype.min.js +1 -0
- package/examples/js/libs/stats.min.js +5 -0
- package/examples/js/lights/LightProbeGenerator.js +228 -0
- package/examples/js/lights/RectAreaLightUniformsLib.js +56 -0
- package/examples/js/lines/Line2.js +19 -0
- package/examples/js/lines/LineGeometry.js +71 -0
- package/examples/js/lines/LineMaterial.js +642 -0
- package/examples/js/lines/LineSegments2.js +362 -0
- package/examples/js/lines/LineSegmentsGeometry.js +219 -0
- package/examples/js/lines/Wireframe.js +52 -0
- package/examples/js/lines/WireframeGeometry2.js +18 -0
- package/examples/js/loaders/3DMLoader.js +1370 -0
- package/examples/js/loaders/3MFLoader.js +1340 -0
- package/examples/js/loaders/AMFLoader.js +529 -0
- package/examples/js/loaders/BVHLoader.js +394 -0
- package/examples/js/loaders/BasisTextureLoader.js +736 -0
- package/examples/js/loaders/ColladaLoader.js +3821 -0
- package/examples/js/loaders/DDSLoader.js +245 -0
- package/examples/js/loaders/DRACOLoader.js +548 -0
- package/examples/js/loaders/EXRLoader.js +2136 -0
- package/examples/js/loaders/FBXLoader.js +3835 -0
- package/examples/js/loaders/FontLoader.js +169 -0
- package/examples/js/loaders/GCodeLoader.js +256 -0
- package/examples/js/loaders/GLTFLoader.js +4159 -0
- package/examples/js/loaders/HDRCubeTextureLoader.js +93 -0
- package/examples/js/loaders/KMZLoader.js +125 -0
- package/examples/js/loaders/KTXLoader.js +177 -0
- package/examples/js/loaders/LDrawLoader.js +2374 -0
- package/examples/js/loaders/LUT3dlLoader.js +139 -0
- package/examples/js/loaders/LUTCubeLoader.js +140 -0
- package/examples/js/loaders/LWOLoader.js +966 -0
- package/examples/js/loaders/LogLuvLoader.js +765 -0
- package/examples/js/loaders/LottieLoader.js +62 -0
- package/examples/js/loaders/MD2Loader.js +249 -0
- package/examples/js/loaders/MDDLoader.js +95 -0
- package/examples/js/loaders/MMDLoader.js +1924 -0
- package/examples/js/loaders/MTLLoader.js +501 -0
- package/examples/js/loaders/NRRDLoader.js +649 -0
- package/examples/js/loaders/OBJLoader.js +804 -0
- package/examples/js/loaders/PCDLoader.js +408 -0
- package/examples/js/loaders/PDBLoader.js +313 -0
- package/examples/js/loaders/PLYLoader.js +562 -0
- package/examples/js/loaders/PRWMLoader.js +260 -0
- package/examples/js/loaders/PVRLoader.js +227 -0
- package/examples/js/loaders/RGBELoader.js +467 -0
- package/examples/js/loaders/RGBMLoader.js +1415 -0
- package/examples/js/loaders/STLLoader.js +371 -0
- package/examples/js/loaders/SVGLoader.js +2655 -0
- package/examples/js/loaders/TDSLoader.js +1029 -0
- package/examples/js/loaders/TGALoader.js +486 -0
- package/examples/js/loaders/TIFFLoader.js +31 -0
- package/examples/js/loaders/TTFLoader.js +211 -0
- package/examples/js/loaders/TiltLoader.js +460 -0
- package/examples/js/loaders/VOXLoader.js +248 -0
- package/examples/js/loaders/VRMLLoader.js +3237 -0
- package/examples/js/loaders/VTKLoader.js +1095 -0
- package/examples/js/loaders/XYZLoader.js +91 -0
- package/examples/js/loaders/lwo/IFFParser.js +1148 -0
- package/examples/js/loaders/lwo/LWO2Parser.js +448 -0
- package/examples/js/loaders/lwo/LWO3Parser.js +402 -0
- package/examples/js/materials/MeshGouraudMaterial.js +385 -0
- package/examples/js/math/Capsule.js +120 -0
- package/examples/js/math/ColorConverter.js +33 -0
- package/examples/js/math/ConvexHull.js +1110 -0
- package/examples/js/math/ImprovedNoise.js +66 -0
- package/examples/js/math/Lut.js +171 -0
- package/examples/js/math/MeshSurfaceSampler.js +193 -0
- package/examples/js/math/OBB.js +341 -0
- package/examples/js/math/Octree.js +465 -0
- package/examples/js/math/SimplexNoise.js +459 -0
- package/examples/js/misc/ConvexObjectBreaker.js +485 -0
- package/examples/js/misc/GPUComputationRenderer.js +397 -0
- package/examples/js/misc/Gyroscope.js +60 -0
- package/examples/js/misc/MD2Character.js +244 -0
- package/examples/js/misc/MD2CharacterComplex.js +494 -0
- package/examples/js/misc/MorphAnimMesh.js +69 -0
- package/examples/js/misc/MorphBlendMesh.js +292 -0
- package/examples/js/misc/ProgressiveLightMap.js +331 -0
- package/examples/js/misc/RollerCoaster.js +437 -0
- package/examples/js/misc/TubePainter.js +161 -0
- package/examples/js/misc/Volume.js +466 -0
- package/examples/js/misc/VolumeSlice.js +224 -0
- package/examples/js/modifiers/CurveModifier.js +311 -0
- package/examples/js/modifiers/EdgeSplitModifier.js +258 -0
- package/examples/js/modifiers/SimplifyModifier.js +468 -0
- package/examples/js/modifiers/TessellateModifier.js +283 -0
- package/examples/js/objects/GroundProjectedEnv.js +193 -0
- package/examples/js/objects/Lensflare.js +347 -0
- package/examples/js/objects/LightningStorm.js +209 -0
- package/examples/js/objects/MarchingCubes.js +738 -0
- package/examples/js/objects/Reflector.js +214 -0
- package/examples/js/objects/ReflectorForSSRPass.js +319 -0
- package/examples/js/objects/Refractor.js +261 -0
- package/examples/js/objects/ShadowMesh.js +60 -0
- package/examples/js/objects/Sky.js +223 -0
- package/examples/js/objects/Water.js +287 -0
- package/examples/js/objects/Water2.js +306 -0
- package/examples/js/physics/AmmoPhysics.js +256 -0
- package/examples/js/physics/OimoPhysics.js +215 -0
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +342 -0
- package/examples/js/postprocessing/AfterimagePass.js +70 -0
- package/examples/js/postprocessing/BloomPass.js +114 -0
- package/examples/js/postprocessing/BokehPass.js +103 -0
- package/examples/js/postprocessing/ClearPass.js +44 -0
- package/examples/js/postprocessing/CubeTexturePass.js +57 -0
- package/examples/js/postprocessing/DotScreenPass.js +49 -0
- package/examples/js/postprocessing/EffectComposer.js +279 -0
- package/examples/js/postprocessing/FilmPass.js +50 -0
- package/examples/js/postprocessing/GlitchPass.js +105 -0
- package/examples/js/postprocessing/HalftonePass.js +75 -0
- package/examples/js/postprocessing/LUTPass.js +184 -0
- package/examples/js/postprocessing/MaskPass.js +92 -0
- package/examples/js/postprocessing/OutlinePass.js +589 -0
- package/examples/js/postprocessing/Pass.js +75 -0
- package/examples/js/postprocessing/RenderPass.js +74 -0
- package/examples/js/postprocessing/SAOPass.js +366 -0
- package/examples/js/postprocessing/SMAAPass.js +153 -0
- package/examples/js/postprocessing/SSAARenderPass.js +156 -0
- package/examples/js/postprocessing/SSAOPass.js +351 -0
- package/examples/js/postprocessing/SSRPass.js +550 -0
- package/examples/js/postprocessing/SavePass.js +51 -0
- package/examples/js/postprocessing/ShaderPass.js +63 -0
- package/examples/js/postprocessing/TAARenderPass.js +128 -0
- package/examples/js/postprocessing/TexturePass.js +46 -0
- package/examples/js/postprocessing/UnrealBloomPass.js +357 -0
- package/examples/js/renderers/CSS2DRenderer.js +197 -0
- package/examples/js/renderers/CSS3DRenderer.js +258 -0
- package/examples/js/renderers/Projector.js +874 -0
- package/examples/js/renderers/SVGRenderer.js +537 -0
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +92 -0
- package/examples/js/shaders/AfterimageShader.js +63 -0
- package/examples/js/shaders/BasicShader.js +30 -0
- package/examples/js/shaders/BleachBypassShader.js +65 -0
- package/examples/js/shaders/BlendShader.js +57 -0
- package/examples/js/shaders/BokehShader.js +159 -0
- package/examples/js/shaders/BokehShader2.js +428 -0
- package/examples/js/shaders/BrightnessContrastShader.js +61 -0
- package/examples/js/shaders/ColorCorrectionShader.js +56 -0
- package/examples/js/shaders/ColorifyShader.js +51 -0
- package/examples/js/shaders/ConvolutionShader.js +97 -0
- package/examples/js/shaders/CopyShader.js +48 -0
- package/examples/js/shaders/DOFMipMapShader.js +63 -0
- package/examples/js/shaders/DepthLimitedBlurShader.js +180 -0
- package/examples/js/shaders/DigitalGlitch.js +130 -0
- package/examples/js/shaders/DotScreenShader.js +76 -0
- package/examples/js/shaders/FXAAShader.js +286 -0
- package/examples/js/shaders/FilmShader.js +113 -0
- package/examples/js/shaders/FocusShader.js +98 -0
- package/examples/js/shaders/FreiChenShader.js +97 -0
- package/examples/js/shaders/GammaCorrectionShader.js +44 -0
- package/examples/js/shaders/GodRaysShader.js +297 -0
- package/examples/js/shaders/HalftoneShader.js +339 -0
- package/examples/js/shaders/HorizontalBlurShader.js +62 -0
- package/examples/js/shaders/HorizontalTiltShiftShader.js +68 -0
- package/examples/js/shaders/HueSaturationShader.js +72 -0
- package/examples/js/shaders/KaleidoShader.js +63 -0
- package/examples/js/shaders/LuminosityHighPassShader.js +71 -0
- package/examples/js/shaders/LuminosityShader.js +49 -0
- package/examples/js/shaders/MMDToonShader.js +100 -0
- package/examples/js/shaders/MirrorShader.js +59 -0
- package/examples/js/shaders/NormalMapShader.js +59 -0
- package/examples/js/shaders/PixelShader.js +51 -0
- package/examples/js/shaders/RGBShiftShader.js +59 -0
- package/examples/js/shaders/SAOShader.js +213 -0
- package/examples/js/shaders/SMAAShader.js +466 -0
- package/examples/js/shaders/SSAOShader.js +299 -0
- package/examples/js/shaders/SSRShader.js +393 -0
- package/examples/js/shaders/SepiaShader.js +55 -0
- package/examples/js/shaders/SobelOperatorShader.js +92 -0
- package/examples/js/shaders/SubsurfaceScatteringShader.js +49 -0
- package/examples/js/shaders/TechnicolorShader.js +46 -0
- package/examples/js/shaders/ToneMapShader.js +87 -0
- package/examples/js/shaders/ToonShader.js +351 -0
- package/examples/js/shaders/TriangleBlurShader.js +74 -0
- package/examples/js/shaders/UnpackDepthRGBAShader.js +50 -0
- package/examples/js/shaders/VerticalBlurShader.js +62 -0
- package/examples/js/shaders/VerticalTiltShiftShader.js +68 -0
- package/examples/js/shaders/VignetteShader.js +56 -0
- package/examples/js/shaders/VolumeShader.js +300 -0
- package/examples/js/shaders/WaterRefractionShader.js +88 -0
- package/examples/js/textures/FlakesTexture.js +41 -0
- package/examples/js/utils/BufferGeometryUtils.js +1094 -0
- package/examples/js/utils/CameraUtils.js +86 -0
- package/examples/js/utils/GPUStatsPanel.js +134 -0
- package/examples/js/utils/GeometryCompressionUtils.js +574 -0
- package/examples/js/utils/GeometryUtils.js +173 -0
- package/examples/js/utils/LDrawUtils.js +182 -0
- package/examples/js/utils/PackedPhongMaterial.js +107 -0
- package/examples/js/utils/SceneUtils.js +103 -0
- package/examples/js/utils/ShadowMapViewer.js +180 -0
- package/examples/js/utils/SkeletonUtils.js +507 -0
- package/examples/js/utils/UVsDebug.js +135 -0
- package/examples/js/utils/WorkerPool.js +115 -0
- package/examples/jsm/animation/AnimationClipCreator.js +114 -0
- package/examples/jsm/animation/CCDIKSolver.js +482 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +1207 -0
- package/examples/jsm/animation/MMDPhysics.js +1406 -0
- package/examples/jsm/cameras/CinematicCamera.js +209 -0
- package/examples/jsm/capabilities/WebGL.js +91 -0
- package/examples/jsm/capabilities/WebGPU.js +39 -0
- package/examples/jsm/controls/ArcballControls.js +3216 -0
- package/examples/jsm/controls/DragControls.js +220 -0
- package/examples/jsm/controls/FirstPersonControls.js +325 -0
- package/examples/jsm/controls/FlyControls.js +284 -0
- package/examples/jsm/controls/OrbitControls.js +1249 -0
- package/examples/jsm/controls/PointerLockControls.js +157 -0
- package/examples/jsm/controls/TrackballControls.js +814 -0
- package/examples/jsm/controls/TransformControls.js +1558 -0
- package/examples/jsm/csm/CSM.js +378 -0
- package/examples/jsm/csm/CSMFrustum.js +152 -0
- package/examples/jsm/csm/CSMHelper.js +193 -0
- package/examples/jsm/csm/CSMShader.js +251 -0
- package/examples/jsm/curves/CurveExtras.js +422 -0
- package/examples/jsm/curves/NURBSCurve.js +80 -0
- package/examples/jsm/curves/NURBSSurface.js +52 -0
- package/examples/jsm/curves/NURBSUtils.js +487 -0
- package/examples/jsm/effects/AnaglyphEffect.js +168 -0
- package/examples/jsm/effects/AsciiEffect.js +266 -0
- package/examples/jsm/effects/OutlineEffect.js +553 -0
- package/examples/jsm/effects/ParallaxBarrierEffect.js +116 -0
- package/examples/jsm/effects/PeppersGhostEffect.js +153 -0
- package/examples/jsm/effects/StereoEffect.js +55 -0
- package/examples/jsm/environments/DebugEnvironment.js +52 -0
- package/examples/jsm/environments/RoomEnvironment.js +144 -0
- package/examples/jsm/exporters/ColladaExporter.js +713 -0
- package/examples/jsm/exporters/DRACOExporter.js +225 -0
- package/examples/jsm/exporters/EXRExporter.js +507 -0
- package/examples/jsm/exporters/GLTFExporter.js +2870 -0
- package/examples/jsm/exporters/KTX2Exporter.js +281 -0
- package/examples/jsm/exporters/MMDExporter.js +217 -0
- package/examples/jsm/exporters/OBJExporter.js +284 -0
- package/examples/jsm/exporters/PLYExporter.js +521 -0
- package/examples/jsm/exporters/STLExporter.js +195 -0
- package/examples/jsm/exporters/USDZExporter.js +1112 -0
- package/examples/jsm/geometries/BoxLineGeometry.js +69 -0
- package/examples/jsm/geometries/ConvexGeometry.js +59 -0
- package/examples/jsm/geometries/DecalGeometry.js +356 -0
- package/examples/jsm/geometries/LightningStrike.js +1017 -0
- package/examples/jsm/geometries/ParametricGeometries.js +254 -0
- package/examples/jsm/geometries/ParametricGeometry.js +129 -0
- package/examples/jsm/geometries/RoundedBoxGeometry.js +155 -0
- package/examples/jsm/geometries/TeapotGeometry.js +704 -0
- package/examples/jsm/geometries/TextGeometry.js +57 -0
- package/examples/jsm/helpers/LightProbeHelper.js +130 -0
- package/examples/jsm/helpers/OctreeHelper.js +72 -0
- package/examples/jsm/helpers/PositionalAudioHelper.js +109 -0
- package/examples/jsm/helpers/RectAreaLightHelper.js +85 -0
- package/examples/jsm/helpers/VertexNormalsHelper.js +96 -0
- package/examples/jsm/helpers/VertexTangentsHelper.js +88 -0
- package/examples/jsm/helpers/ViewHelper.js +319 -0
- package/examples/jsm/interactive/HTMLMesh.js +550 -0
- package/examples/jsm/interactive/InteractiveGroup.js +116 -0
- package/examples/jsm/interactive/SelectionBox.js +227 -0
- package/examples/jsm/interactive/SelectionHelper.js +97 -0
- package/examples/jsm/libs/OimoPhysics/OimoPhysics.js +37071 -0
- package/examples/jsm/libs/OimoPhysics/index.js +43 -0
- package/examples/jsm/libs/chevrotain.module.min.js +141 -0
- package/examples/jsm/libs/ecsy.module.js +1792 -0
- package/examples/jsm/libs/fflate.module.js +2474 -0
- package/examples/jsm/libs/flow.module.js +4552 -0
- package/examples/jsm/libs/ktx-parse.module.js +1 -0
- package/examples/jsm/libs/lil-gui.module.min.js +8 -0
- package/examples/jsm/libs/meshopt_decoder.module.js +178 -0
- package/examples/jsm/libs/mikktspace.module.js +128 -0
- package/examples/jsm/libs/mmdparser.module.js +11530 -0
- package/examples/jsm/libs/motion-controllers.module.js +397 -0
- package/examples/jsm/libs/opentype.module.js +14568 -0
- package/examples/jsm/libs/potpack.module.js +125 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +21 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +16 -0
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/libs/stats.module.js +167 -0
- package/examples/jsm/libs/tween.module.min.js +3 -0
- package/examples/jsm/libs/utif.module.js +1579 -0
- package/examples/jsm/libs/zstddec.module.js +1 -0
- package/examples/jsm/lights/LightProbeGenerator.js +250 -0
- package/examples/jsm/lights/RectAreaLightUniformsLib.js +79 -0
- package/examples/jsm/lines/Line2.js +19 -0
- package/examples/jsm/lines/LineGeometry.js +79 -0
- package/examples/jsm/lines/LineMaterial.js +702 -0
- package/examples/jsm/lines/LineSegments2.js +355 -0
- package/examples/jsm/lines/LineSegmentsGeometry.js +241 -0
- package/examples/jsm/lines/Wireframe.js +56 -0
- package/examples/jsm/lines/WireframeGeometry2.js +24 -0
- package/examples/jsm/loaders/3DMLoader.js +1495 -0
- package/examples/jsm/loaders/3MFLoader.js +1473 -0
- package/examples/jsm/loaders/AMFLoader.js +518 -0
- package/examples/jsm/loaders/BVHLoader.js +437 -0
- package/examples/jsm/loaders/BasisTextureLoader.js +790 -0
- package/examples/jsm/loaders/ColladaLoader.js +4092 -0
- package/examples/jsm/loaders/DDSLoader.js +274 -0
- package/examples/jsm/loaders/DRACOLoader.js +561 -0
- package/examples/jsm/loaders/EXRLoader.js +2310 -0
- package/examples/jsm/loaders/FBXLoader.js +4137 -0
- package/examples/jsm/loaders/FontLoader.js +183 -0
- package/examples/jsm/loaders/GCodeLoader.js +262 -0
- package/examples/jsm/loaders/GLTFLoader.js +5221 -0
- package/examples/jsm/loaders/HDRCubeTextureLoader.js +115 -0
- package/examples/jsm/loaders/IFCLoader.js +2431 -0
- package/examples/jsm/loaders/KMZLoader.js +130 -0
- package/examples/jsm/loaders/KTX2Loader.js +753 -0
- package/examples/jsm/loaders/KTXLoader.js +176 -0
- package/examples/jsm/loaders/LDrawLoader.js +2464 -0
- package/examples/jsm/loaders/LUT3dlLoader.js +151 -0
- package/examples/jsm/loaders/LUTCubeLoader.js +153 -0
- package/examples/jsm/loaders/LWOLoader.js +1069 -0
- package/examples/jsm/loaders/LogLuvLoader.js +606 -0
- package/examples/jsm/loaders/LottieLoader.js +73 -0
- package/examples/jsm/loaders/MD2Loader.js +399 -0
- package/examples/jsm/loaders/MDDLoader.js +102 -0
- package/examples/jsm/loaders/MMDLoader.js +2242 -0
- package/examples/jsm/loaders/MTLLoader.js +567 -0
- package/examples/jsm/loaders/NRRDLoader.js +671 -0
- package/examples/jsm/loaders/OBJLoader.js +905 -0
- package/examples/jsm/loaders/PCDLoader.js +453 -0
- package/examples/jsm/loaders/PDBLoader.js +227 -0
- package/examples/jsm/loaders/PLYLoader.js +564 -0
- package/examples/jsm/loaders/PRWMLoader.js +299 -0
- package/examples/jsm/loaders/PVRLoader.js +251 -0
- package/examples/jsm/loaders/RGBELoader.js +468 -0
- package/examples/jsm/loaders/RGBMLoader.js +1065 -0
- package/examples/jsm/loaders/STLLoader.js +399 -0
- package/examples/jsm/loaders/SVGLoader.js +2950 -0
- package/examples/jsm/loaders/TDSLoader.js +1124 -0
- package/examples/jsm/loaders/TGALoader.js +517 -0
- package/examples/jsm/loaders/TIFFLoader.js +36 -0
- package/examples/jsm/loaders/TTFLoader.js +221 -0
- package/examples/jsm/loaders/TiltLoader.js +514 -0
- package/examples/jsm/loaders/USDZLoader.js +618 -0
- package/examples/jsm/loaders/VOXLoader.js +305 -0
- package/examples/jsm/loaders/VRMLLoader.js +3493 -0
- package/examples/jsm/loaders/VTKLoader.js +1154 -0
- package/examples/jsm/loaders/XYZLoader.js +100 -0
- package/examples/jsm/loaders/ifc/web-ifc-api.js +47504 -0
- package/examples/jsm/loaders/ifc/web-ifc.wasm +0 -0
- package/examples/jsm/loaders/lwo/IFFParser.js +1218 -0
- package/examples/jsm/loaders/lwo/LWO2Parser.js +414 -0
- package/examples/jsm/loaders/lwo/LWO3Parser.js +373 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +423 -0
- package/examples/jsm/math/Capsule.js +137 -0
- package/examples/jsm/math/ColorConverter.js +36 -0
- package/examples/jsm/math/ConvexHull.js +1271 -0
- package/examples/jsm/math/ImprovedNoise.js +71 -0
- package/examples/jsm/math/Lut.js +203 -0
- package/examples/jsm/math/MeshSurfaceSampler.js +211 -0
- package/examples/jsm/math/OBB.js +423 -0
- package/examples/jsm/math/Octree.js +462 -0
- package/examples/jsm/math/SimplexNoise.js +444 -0
- package/examples/jsm/misc/ConvexObjectBreaker.js +525 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +454 -0
- package/examples/jsm/misc/Gyroscope.js +66 -0
- package/examples/jsm/misc/MD2Character.js +276 -0
- package/examples/jsm/misc/MD2CharacterComplex.js +576 -0
- package/examples/jsm/misc/MorphAnimMesh.js +75 -0
- package/examples/jsm/misc/MorphBlendMesh.js +322 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +321 -0
- package/examples/jsm/misc/RollerCoaster.js +560 -0
- package/examples/jsm/misc/TubePainter.js +205 -0
- package/examples/jsm/misc/Volume.js +460 -0
- package/examples/jsm/misc/VolumeSlice.js +227 -0
- package/examples/jsm/modifiers/CurveModifier.js +325 -0
- package/examples/jsm/modifiers/EdgeSplitModifier.js +279 -0
- package/examples/jsm/modifiers/SimplifyModifier.js +525 -0
- package/examples/jsm/modifiers/TessellateModifier.js +307 -0
- package/examples/jsm/node-editor/NodeEditor.js +857 -0
- package/examples/jsm/node-editor/accessors/MatcapUVEditor.js +14 -0
- package/examples/jsm/node-editor/accessors/NormalEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/PositionEditor.js +30 -0
- package/examples/jsm/node-editor/accessors/UVEditor.js +25 -0
- package/examples/jsm/node-editor/core/BaseNode.js +96 -0
- package/examples/jsm/node-editor/core/DataFile.js +59 -0
- package/examples/jsm/node-editor/core/FileEditor.js +20 -0
- package/examples/jsm/node-editor/core/FileURLEditor.js +29 -0
- package/examples/jsm/node-editor/display/BlendEditor.js +44 -0
- package/examples/jsm/node-editor/display/NormalMapEditor.js +49 -0
- package/examples/jsm/node-editor/examples/animate-uv.json +1 -0
- package/examples/jsm/node-editor/examples/fake-top-light.json +1 -0
- package/examples/jsm/node-editor/examples/matcap.json +1 -0
- package/examples/jsm/node-editor/examples/oscillator-color.json +1 -0
- package/examples/jsm/node-editor/examples/rim.json +1 -0
- package/examples/jsm/node-editor/inputs/ColorEditor.js +96 -0
- package/examples/jsm/node-editor/inputs/FloatEditor.js +23 -0
- package/examples/jsm/node-editor/inputs/SliderEditor.js +67 -0
- package/examples/jsm/node-editor/inputs/TextureEditor.js +155 -0
- package/examples/jsm/node-editor/inputs/Vector2Editor.js +28 -0
- package/examples/jsm/node-editor/inputs/Vector3Editor.js +30 -0
- package/examples/jsm/node-editor/inputs/Vector4Editor.js +37 -0
- package/examples/jsm/node-editor/materials/BasicMaterialEditor.js +84 -0
- package/examples/jsm/node-editor/materials/PointsMaterialEditor.js +102 -0
- package/examples/jsm/node-editor/materials/StandardMaterialEditor.js +118 -0
- package/examples/jsm/node-editor/math/AngleEditor.js +40 -0
- package/examples/jsm/node-editor/math/DotEditor.js +35 -0
- package/examples/jsm/node-editor/math/InvertEditor.js +39 -0
- package/examples/jsm/node-editor/math/LimiterEditor.js +62 -0
- package/examples/jsm/node-editor/math/NormalizeEditor.js +28 -0
- package/examples/jsm/node-editor/math/OperatorEditor.js +63 -0
- package/examples/jsm/node-editor/math/PowerEditor.js +44 -0
- package/examples/jsm/node-editor/math/TrigonometryEditor.js +45 -0
- package/examples/jsm/node-editor/procedural/CheckerEditor.js +27 -0
- package/examples/jsm/node-editor/scene/MeshEditor.js +102 -0
- package/examples/jsm/node-editor/scene/Object3DEditor.js +160 -0
- package/examples/jsm/node-editor/scene/PointsEditor.js +99 -0
- package/examples/jsm/node-editor/utils/JoinEditor.js +58 -0
- package/examples/jsm/node-editor/utils/OscillatorEditor.js +43 -0
- package/examples/jsm/node-editor/utils/PreviewEditor.js +170 -0
- package/examples/jsm/node-editor/utils/SplitEditor.js +39 -0
- package/examples/jsm/node-editor/utils/TimerEditor.js +58 -0
- package/examples/jsm/nodes/Nodes.js +346 -0
- package/examples/jsm/nodes/accessors/BitangentNode.js +62 -0
- package/examples/jsm/nodes/accessors/BufferNode.js +24 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +67 -0
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +107 -0
- package/examples/jsm/nodes/accessors/InstanceNode.js +58 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +152 -0
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +23 -0
- package/examples/jsm/nodes/accessors/ModelNode.js +21 -0
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +30 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +79 -0
- package/examples/jsm/nodes/accessors/Object3DNode.js +122 -0
- package/examples/jsm/nodes/accessors/PointUVNode.js +21 -0
- package/examples/jsm/nodes/accessors/PositionNode.js +83 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +65 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +31 -0
- package/examples/jsm/nodes/accessors/SkinningNode.js +109 -0
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +21 -0
- package/examples/jsm/nodes/accessors/TangentNode.js +95 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +100 -0
- package/examples/jsm/nodes/accessors/UVNode.js +41 -0
- package/examples/jsm/nodes/accessors/UserDataNode.js +23 -0
- package/examples/jsm/nodes/core/ArrayUniformNode.js +23 -0
- package/examples/jsm/nodes/core/AttributeNode.js +94 -0
- package/examples/jsm/nodes/core/BypassNode.js +38 -0
- package/examples/jsm/nodes/core/CodeNode.js +50 -0
- package/examples/jsm/nodes/core/ConstNode.js +29 -0
- package/examples/jsm/nodes/core/ContextNode.js +52 -0
- package/examples/jsm/nodes/core/ExpressionNode.js +32 -0
- package/examples/jsm/nodes/core/FunctionCallNode.js +82 -0
- package/examples/jsm/nodes/core/FunctionNode.js +105 -0
- package/examples/jsm/nodes/core/InputNode.js +62 -0
- package/examples/jsm/nodes/core/InstanceIndexNode.js +21 -0
- package/examples/jsm/nodes/core/Node.js +354 -0
- package/examples/jsm/nodes/core/NodeAttribute.js +14 -0
- package/examples/jsm/nodes/core/NodeBuilder.js +815 -0
- package/examples/jsm/nodes/core/NodeCode.js +15 -0
- package/examples/jsm/nodes/core/NodeFrame.js +59 -0
- package/examples/jsm/nodes/core/NodeFunction.js +22 -0
- package/examples/jsm/nodes/core/NodeFunctionInput.js +17 -0
- package/examples/jsm/nodes/core/NodeKeywords.js +80 -0
- package/examples/jsm/nodes/core/NodeParser.js +11 -0
- package/examples/jsm/nodes/core/NodeUniform.js +28 -0
- package/examples/jsm/nodes/core/NodeUtils.js +125 -0
- package/examples/jsm/nodes/core/NodeVar.js +14 -0
- package/examples/jsm/nodes/core/NodeVarying.js +14 -0
- package/examples/jsm/nodes/core/PropertyNode.js +36 -0
- package/examples/jsm/nodes/core/TempNode.js +50 -0
- package/examples/jsm/nodes/core/UniformNode.js +46 -0
- package/examples/jsm/nodes/core/VarNode.js +97 -0
- package/examples/jsm/nodes/core/VaryingNode.js +54 -0
- package/examples/jsm/nodes/core/constants.js +21 -0
- package/examples/jsm/nodes/display/BlendModeNode.js +85 -0
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +84 -0
- package/examples/jsm/nodes/display/ColorSpaceNode.js +95 -0
- package/examples/jsm/nodes/display/FrontFacingNode.js +21 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +93 -0
- package/examples/jsm/nodes/display/ToneMappingNode.js +51 -0
- package/examples/jsm/nodes/fog/FogNode.js +31 -0
- package/examples/jsm/nodes/fog/FogRangeNode.js +27 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +33 -0
- package/examples/jsm/nodes/functions/BSDF/BRDF_Lambert.js +9 -0
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +27 -0
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +18 -0
- package/examples/jsm/nodes/functions/BSDF/F_Schlick.js +18 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +18 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +94 -0
- package/examples/jsm/nodes/functions/light/getDistanceAttenuation.js +22 -0
- package/examples/jsm/nodes/functions/material/getGeometryRoughness.js +12 -0
- package/examples/jsm/nodes/functions/material/getRoughness.js +18 -0
- package/examples/jsm/nodes/geometry/RangeNode.js +109 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +65 -0
- package/examples/jsm/nodes/lighting/AONode.js +25 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +37 -0
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +66 -0
- package/examples/jsm/nodes/lighting/HemisphereLightNode.js +50 -0
- package/examples/jsm/nodes/lighting/LightingContextNode.js +75 -0
- package/examples/jsm/nodes/lighting/LightingNode.js +19 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +120 -0
- package/examples/jsm/nodes/lighting/PunctualLightNode.js +68 -0
- package/examples/jsm/nodes/loaders/NodeLoader.js +107 -0
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +73 -0
- package/examples/jsm/nodes/loaders/NodeObjectLoader.js +70 -0
- package/examples/jsm/nodes/materials/LineBasicNodeMaterial.js +46 -0
- package/examples/jsm/nodes/materials/Materials.js +53 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +48 -0
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +70 -0
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +168 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +229 -0
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +106 -0
- package/examples/jsm/nodes/materialx/DISCLAIMER.md +199 -0
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +55 -0
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +56 -0
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +617 -0
- package/examples/jsm/nodes/math/CondNode.js +60 -0
- package/examples/jsm/nodes/math/MathNode.js +243 -0
- package/examples/jsm/nodes/math/OperatorNode.js +214 -0
- package/examples/jsm/nodes/parsers/GLSLNodeFunction.js +152 -0
- package/examples/jsm/nodes/parsers/GLSLNodeParser.js +14 -0
- package/examples/jsm/nodes/parsers/WGSLNodeFunction.js +104 -0
- package/examples/jsm/nodes/parsers/WGSLNodeParser.js +14 -0
- package/examples/jsm/nodes/procedural/CheckerNode.js +34 -0
- package/examples/jsm/nodes/shadernode/ShaderNode.js +264 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +299 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +131 -0
- package/examples/jsm/nodes/utils/ArrayElementNode.js +31 -0
- package/examples/jsm/nodes/utils/ConvertNode.js +47 -0
- package/examples/jsm/nodes/utils/JoinNode.js +42 -0
- package/examples/jsm/nodes/utils/MatcapUVNode.js +25 -0
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +33 -0
- package/examples/jsm/nodes/utils/OscNode.js +74 -0
- package/examples/jsm/nodes/utils/RemapNode.js +34 -0
- package/examples/jsm/nodes/utils/RotateUVNode.js +32 -0
- package/examples/jsm/nodes/utils/SplitNode.js +102 -0
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +58 -0
- package/examples/jsm/nodes/utils/TimerNode.js +84 -0
- package/examples/jsm/objects/GroundProjectedEnv.js +186 -0
- package/examples/jsm/objects/Lensflare.js +378 -0
- package/examples/jsm/objects/LightningStorm.js +245 -0
- package/examples/jsm/objects/MarchingCubes.js +1172 -0
- package/examples/jsm/objects/Reflector.js +269 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +349 -0
- package/examples/jsm/objects/Refractor.js +332 -0
- package/examples/jsm/objects/ShadowMesh.js +80 -0
- package/examples/jsm/objects/Sky.js +219 -0
- package/examples/jsm/objects/Water.js +329 -0
- package/examples/jsm/objects/Water2.js +358 -0
- package/examples/jsm/offscreen/jank.js +45 -0
- package/examples/jsm/offscreen/offscreen.js +8 -0
- package/examples/jsm/offscreen/scene.js +86 -0
- package/examples/jsm/physics/AmmoPhysics.js +286 -0
- package/examples/jsm/physics/OimoPhysics.js +231 -0
- package/examples/jsm/postprocessing/AdaptiveToneMappingPass.js +369 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +90 -0
- package/examples/jsm/postprocessing/BloomPass.js +150 -0
- package/examples/jsm/postprocessing/BokehPass.js +131 -0
- package/examples/jsm/postprocessing/ClearPass.js +46 -0
- package/examples/jsm/postprocessing/CubeTexturePass.js +78 -0
- package/examples/jsm/postprocessing/DotScreenPass.js +58 -0
- package/examples/jsm/postprocessing/EffectComposer.js +310 -0
- package/examples/jsm/postprocessing/FilmPass.js +59 -0
- package/examples/jsm/postprocessing/GlitchPass.js +118 -0
- package/examples/jsm/postprocessing/HalftonePass.js +77 -0
- package/examples/jsm/postprocessing/LUTPass.js +173 -0
- package/examples/jsm/postprocessing/MaskPass.js +101 -0
- package/examples/jsm/postprocessing/OutlinePass.js +646 -0
- package/examples/jsm/postprocessing/Pass.js +80 -0
- package/examples/jsm/postprocessing/RenderPass.js +81 -0
- package/examples/jsm/postprocessing/SAOPass.js +413 -0
- package/examples/jsm/postprocessing/SMAAPass.js +188 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +224 -0
- package/examples/jsm/postprocessing/SSAOPass.js +450 -0
- package/examples/jsm/postprocessing/SSRPass.js +645 -0
- package/examples/jsm/postprocessing/SavePass.js +62 -0
- package/examples/jsm/postprocessing/ShaderPass.js +68 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +167 -0
- package/examples/jsm/postprocessing/TexturePass.js +60 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +403 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +210 -0
- package/examples/jsm/renderers/CSS3DRenderer.js +313 -0
- package/examples/jsm/renderers/Projector.js +918 -0
- package/examples/jsm/renderers/SVGRenderer.js +553 -0
- package/examples/jsm/renderers/webgl/nodes/SlotNode.js +26 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +733 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodes.js +49 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +129 -0
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +144 -0
- package/examples/jsm/renderers/webgpu/WebGPUBinding.js +22 -0
- package/examples/jsm/renderers/webgpu/WebGPUBindings.js +255 -0
- package/examples/jsm/renderers/webgpu/WebGPUBuffer.js +43 -0
- package/examples/jsm/renderers/webgpu/WebGPUBufferUtils.js +33 -0
- package/examples/jsm/renderers/webgpu/WebGPUComputePipelines.js +78 -0
- package/examples/jsm/renderers/webgpu/WebGPUGeometries.js +82 -0
- package/examples/jsm/renderers/webgpu/WebGPUInfo.js +74 -0
- package/examples/jsm/renderers/webgpu/WebGPUObjects.js +36 -0
- package/examples/jsm/renderers/webgpu/WebGPUProgrammableStage.js +22 -0
- package/examples/jsm/renderers/webgpu/WebGPUProperties.js +38 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderLists.js +199 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderPipeline.js +735 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderPipelines.js +296 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderStates.js +66 -0
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +969 -0
- package/examples/jsm/renderers/webgpu/WebGPUSampledTexture.js +73 -0
- package/examples/jsm/renderers/webgpu/WebGPUSampler.js +29 -0
- package/examples/jsm/renderers/webgpu/WebGPUStorageBuffer.js +20 -0
- package/examples/jsm/renderers/webgpu/WebGPUTextureRenderer.js +40 -0
- package/examples/jsm/renderers/webgpu/WebGPUTextureUtils.js +183 -0
- package/examples/jsm/renderers/webgpu/WebGPUTextures.js +794 -0
- package/examples/jsm/renderers/webgpu/WebGPUUniform.js +136 -0
- package/examples/jsm/renderers/webgpu/WebGPUUniformBuffer.js +18 -0
- package/examples/jsm/renderers/webgpu/WebGPUUniformsGroup.js +299 -0
- package/examples/jsm/renderers/webgpu/WebGPUUtils.js +81 -0
- package/examples/jsm/renderers/webgpu/constants.js +261 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +801 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampledTexture.js +39 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeSampler.js +21 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeUniform.js +135 -0
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodes.js +83 -0
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +87 -0
- package/examples/jsm/shaders/AfterimageShader.js +56 -0
- package/examples/jsm/shaders/BasicShader.js +27 -0
- package/examples/jsm/shaders/BleachBypassShader.js +60 -0
- package/examples/jsm/shaders/BlendShader.js +48 -0
- package/examples/jsm/shaders/BokehShader.js +143 -0
- package/examples/jsm/shaders/BokehShader2.js +390 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +54 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +50 -0
- package/examples/jsm/shaders/ColorifyShader.js +49 -0
- package/examples/jsm/shaders/ConvolutionShader.js +101 -0
- package/examples/jsm/shaders/CopyShader.js +43 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +54 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +166 -0
- package/examples/jsm/shaders/DigitalGlitch.js +101 -0
- package/examples/jsm/shaders/DotScreenShader.js +68 -0
- package/examples/jsm/shaders/FXAAShader.js +286 -0
- package/examples/jsm/shaders/FilmShader.js +100 -0
- package/examples/jsm/shaders/FocusShader.js +87 -0
- package/examples/jsm/shaders/FreiChenShader.js +94 -0
- package/examples/jsm/shaders/GammaCorrectionShader.js +41 -0
- package/examples/jsm/shaders/GodRaysShader.js +313 -0
- package/examples/jsm/shaders/HalftoneShader.js +310 -0
- package/examples/jsm/shaders/HorizontalBlurShader.js +57 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +61 -0
- package/examples/jsm/shaders/HueSaturationShader.js +65 -0
- package/examples/jsm/shaders/KaleidoShader.js +56 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +64 -0
- package/examples/jsm/shaders/LuminosityShader.js +46 -0
- package/examples/jsm/shaders/MMDToonShader.js +123 -0
- package/examples/jsm/shaders/MirrorShader.js +54 -0
- package/examples/jsm/shaders/NormalMapShader.js +53 -0
- package/examples/jsm/shaders/PixelShader.js +44 -0
- package/examples/jsm/shaders/RGBShiftShader.js +52 -0
- package/examples/jsm/shaders/SAOShader.js +188 -0
- package/examples/jsm/shaders/SMAAShader.js +460 -0
- package/examples/jsm/shaders/SSAOShader.js +288 -0
- package/examples/jsm/shaders/SSRShader.js +364 -0
- package/examples/jsm/shaders/SepiaShader.js +50 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +90 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +88 -0
- package/examples/jsm/shaders/TechnicolorShader.js +43 -0
- package/examples/jsm/shaders/ToneMapShader.js +73 -0
- package/examples/jsm/shaders/ToonShader.js +318 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +72 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +45 -0
- package/examples/jsm/shaders/VerticalBlurShader.js +57 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +61 -0
- package/examples/jsm/shaders/VignetteShader.js +49 -0
- package/examples/jsm/shaders/VolumeShader.js +289 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +90 -0
- package/examples/jsm/textures/FlakesTexture.js +40 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +1222 -0
- package/examples/jsm/utils/CameraUtils.js +73 -0
- package/examples/jsm/utils/GPUStatsPanel.js +128 -0
- package/examples/jsm/utils/GeometryCompressionUtils.js +639 -0
- package/examples/jsm/utils/GeometryUtils.js +221 -0
- package/examples/jsm/utils/LDrawUtils.js +202 -0
- package/examples/jsm/utils/PackedPhongMaterial.js +251 -0
- package/examples/jsm/utils/SceneUtils.js +125 -0
- package/examples/jsm/utils/ShadowMapViewer.js +210 -0
- package/examples/jsm/utils/SkeletonUtils.js +596 -0
- package/examples/jsm/utils/UVsDebug.js +165 -0
- package/examples/jsm/utils/WorkerPool.js +102 -0
- package/examples/jsm/webxr/ARButton.js +208 -0
- package/examples/jsm/webxr/OculusHandModel.js +108 -0
- package/examples/jsm/webxr/OculusHandPointerModel.js +394 -0
- package/examples/jsm/webxr/Text2D.js +38 -0
- package/examples/jsm/webxr/VRButton.js +201 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +310 -0
- package/examples/jsm/webxr/XREstimatedLight.js +223 -0
- package/examples/jsm/webxr/XRHandMeshModel.js +108 -0
- package/examples/jsm/webxr/XRHandModelFactory.js +105 -0
- package/examples/jsm/webxr/XRHandPrimitiveModel.js +103 -0
- package/package.json +179 -0
- package/src/Three.Legacy.js +320 -0
- package/src/Three.js +180 -0
- package/src/animation/AnimationAction.js +700 -0
- package/src/animation/AnimationClip.js +473 -0
- package/src/animation/AnimationMixer.js +770 -0
- package/src/animation/AnimationObjectGroup.js +387 -0
- package/src/animation/AnimationUtils.js +361 -0
- package/src/animation/KeyframeTrack.js +462 -0
- package/src/animation/PropertyBinding.js +719 -0
- package/src/animation/PropertyMixer.js +318 -0
- package/src/animation/tracks/BooleanKeyframeTrack.js +19 -0
- package/src/animation/tracks/ColorKeyframeTrack.js +15 -0
- package/src/animation/tracks/NumberKeyframeTrack.js +12 -0
- package/src/animation/tracks/QuaternionKeyframeTrack.js +23 -0
- package/src/animation/tracks/StringKeyframeTrack.js +15 -0
- package/src/animation/tracks/VectorKeyframeTrack.js +12 -0
- package/src/audio/Audio.js +391 -0
- package/src/audio/AudioAnalyser.js +40 -0
- package/src/audio/AudioContext.js +25 -0
- package/src/audio/AudioListener.js +137 -0
- package/src/audio/PositionalAudio.js +138 -0
- package/src/cameras/ArrayCamera.js +17 -0
- package/src/cameras/Camera.js +68 -0
- package/src/cameras/CubeCamera.js +107 -0
- package/src/cameras/OrthographicCamera.js +136 -0
- package/src/cameras/PerspectiveCamera.js +233 -0
- package/src/cameras/StereoCamera.js +100 -0
- package/src/constants.js +181 -0
- package/src/core/BufferAttribute.js +493 -0
- package/src/core/BufferGeometry.js +1092 -0
- package/src/core/Clock.js +74 -0
- package/src/core/EventDispatcher.js +87 -0
- package/src/core/GLBufferAttribute.js +58 -0
- package/src/core/InstancedBufferAttribute.js +39 -0
- package/src/core/InstancedBufferGeometry.js +46 -0
- package/src/core/InstancedInterleavedBuffer.js +48 -0
- package/src/core/InterleavedBuffer.js +145 -0
- package/src/core/InterleavedBufferAttribute.js +331 -0
- package/src/core/Layers.js +60 -0
- package/src/core/Object3D.js +944 -0
- package/src/core/Raycaster.js +110 -0
- package/src/core/Uniform.js +17 -0
- package/src/core/UniformsGroup.js +92 -0
- package/src/extras/DataUtils.js +170 -0
- package/src/extras/Earcut.js +789 -0
- package/src/extras/ImageUtils.js +129 -0
- package/src/extras/PMREMGenerator.js +900 -0
- package/src/extras/ShapeUtils.js +92 -0
- package/src/extras/core/Curve.js +416 -0
- package/src/extras/core/CurvePath.js +252 -0
- package/src/extras/core/Interpolations.js +79 -0
- package/src/extras/core/Path.js +196 -0
- package/src/extras/core/Shape.js +102 -0
- package/src/extras/core/ShapePath.js +291 -0
- package/src/extras/curves/ArcCurve.js +17 -0
- package/src/extras/curves/CatmullRomCurve3.js +255 -0
- package/src/extras/curves/CubicBezierCurve.js +78 -0
- package/src/extras/curves/CubicBezierCurve3.js +79 -0
- package/src/extras/curves/Curves.js +10 -0
- package/src/extras/curves/EllipseCurve.js +156 -0
- package/src/extras/curves/LineCurve.js +90 -0
- package/src/extras/curves/LineCurve3.js +75 -0
- package/src/extras/curves/QuadraticBezierCurve.js +74 -0
- package/src/extras/curves/QuadraticBezierCurve3.js +75 -0
- package/src/extras/curves/SplineCurve.js +97 -0
- package/src/geometries/BoxGeometry.js +170 -0
- package/src/geometries/CapsuleGeometry.js +33 -0
- package/src/geometries/CircleGeometry.js +91 -0
- package/src/geometries/ConeGeometry.js +31 -0
- package/src/geometries/CylinderGeometry.js +276 -0
- package/src/geometries/DodecahedronGeometry.js +66 -0
- package/src/geometries/EdgesGeometry.js +142 -0
- package/src/geometries/ExtrudeGeometry.js +804 -0
- package/src/geometries/Geometries.js +21 -0
- package/src/geometries/IcosahedronGeometry.js +42 -0
- package/src/geometries/LatheGeometry.js +179 -0
- package/src/geometries/OctahedronGeometry.js +37 -0
- package/src/geometries/PlaneGeometry.js +88 -0
- package/src/geometries/PolyhedronGeometry.js +309 -0
- package/src/geometries/RingGeometry.js +118 -0
- package/src/geometries/ShapeGeometry.js +185 -0
- package/src/geometries/SphereGeometry.js +127 -0
- package/src/geometries/TetrahedronGeometry.js +34 -0
- package/src/geometries/TorusGeometry.js +110 -0
- package/src/geometries/TorusKnotGeometry.js +157 -0
- package/src/geometries/TubeGeometry.js +193 -0
- package/src/geometries/WireframeGeometry.js +137 -0
- package/src/helpers/ArrowHelper.js +114 -0
- package/src/helpers/AxesHelper.js +68 -0
- package/src/helpers/Box3Helper.js +56 -0
- package/src/helpers/BoxHelper.js +113 -0
- package/src/helpers/CameraHelper.js +269 -0
- package/src/helpers/DirectionalLightHelper.js +89 -0
- package/src/helpers/GridHelper.js +56 -0
- package/src/helpers/HemisphereLightHelper.js +85 -0
- package/src/helpers/PlaneHelper.js +63 -0
- package/src/helpers/PointLightHelper.js +91 -0
- package/src/helpers/PolarGridHelper.js +96 -0
- package/src/helpers/SkeletonHelper.js +128 -0
- package/src/helpers/SpotLightHelper.js +92 -0
- package/src/lights/AmbientLight.js +17 -0
- package/src/lights/AmbientLightProbe.js +21 -0
- package/src/lights/DirectionalLight.js +43 -0
- package/src/lights/DirectionalLightShadow.js +16 -0
- package/src/lights/HemisphereLight.js +34 -0
- package/src/lights/HemisphereLightProbe.js +30 -0
- package/src/lights/Light.js +58 -0
- package/src/lights/LightProbe.js +47 -0
- package/src/lights/LightShadow.js +147 -0
- package/src/lights/PointLight.js +57 -0
- package/src/lights/PointLightShadow.js +96 -0
- package/src/lights/RectAreaLight.js +56 -0
- package/src/lights/SpotLight.js +71 -0
- package/src/lights/SpotLightShadow.js +50 -0
- package/src/loaders/AnimationLoader.js +66 -0
- package/src/loaders/AudioLoader.js +60 -0
- package/src/loaders/BufferGeometryLoader.js +224 -0
- package/src/loaders/Cache.js +42 -0
- package/src/loaders/CompressedTextureLoader.js +134 -0
- package/src/loaders/CubeTextureLoader.js +56 -0
- package/src/loaders/DataTextureLoader.js +114 -0
- package/src/loaders/FileLoader.js +281 -0
- package/src/loaders/ImageBitmapLoader.js +99 -0
- package/src/loaders/ImageLoader.js +91 -0
- package/src/loaders/Loader.js +70 -0
- package/src/loaders/LoaderUtils.js +75 -0
- package/src/loaders/LoadingManager.js +142 -0
- package/src/loaders/MaterialLoader.js +355 -0
- package/src/loaders/ObjectLoader.js +1081 -0
- package/src/loaders/TextureLoader.js +41 -0
- package/src/materials/LineBasicMaterial.js +45 -0
- package/src/materials/LineDashedMaterial.js +35 -0
- package/src/materials/Material.js +493 -0
- package/src/materials/Materials.js +39 -0
- package/src/materials/MeshBasicMaterial.js +81 -0
- package/src/materials/MeshDepthMaterial.js +54 -0
- package/src/materials/MeshDistanceMaterial.js +52 -0
- package/src/materials/MeshLambertMaterial.js +116 -0
- package/src/materials/MeshMatcapMaterial.js +81 -0
- package/src/materials/MeshNormalMaterial.js +61 -0
- package/src/materials/MeshPhongMaterial.js +120 -0
- package/src/materials/MeshPhysicalMaterial.js +198 -0
- package/src/materials/MeshStandardMaterial.js +124 -0
- package/src/materials/MeshToonMaterial.js +102 -0
- package/src/materials/PointsMaterial.js +50 -0
- package/src/materials/RawShaderMaterial.js +17 -0
- package/src/materials/ShaderMaterial.js +182 -0
- package/src/materials/ShadowMaterial.js +37 -0
- package/src/materials/SpriteMaterial.js +54 -0
- package/src/math/Box2.js +203 -0
- package/src/math/Box3.js +532 -0
- package/src/math/Color.js +605 -0
- package/src/math/ColorManagement.js +74 -0
- package/src/math/Cylindrical.js +61 -0
- package/src/math/Euler.js +324 -0
- package/src/math/Frustum.js +162 -0
- package/src/math/Interpolant.js +241 -0
- package/src/math/Line3.js +115 -0
- package/src/math/MathUtils.js +321 -0
- package/src/math/Matrix3.js +333 -0
- package/src/math/Matrix4.js +860 -0
- package/src/math/Plane.js +205 -0
- package/src/math/Quaternion.js +678 -0
- package/src/math/Ray.js +496 -0
- package/src/math/Sphere.js +250 -0
- package/src/math/Spherical.js +86 -0
- package/src/math/SphericalHarmonics3.js +243 -0
- package/src/math/Triangle.js +299 -0
- package/src/math/Vector2.js +464 -0
- package/src/math/Vector3.js +715 -0
- package/src/math/Vector4.js +644 -0
- package/src/math/interpolants/CubicInterpolant.js +151 -0
- package/src/math/interpolants/DiscreteInterpolant.js +26 -0
- package/src/math/interpolants/LinearInterpolant.js +38 -0
- package/src/math/interpolants/QuaternionLinearInterpolant.js +39 -0
- package/src/objects/Bone.js +17 -0
- package/src/objects/Group.js +17 -0
- package/src/objects/InstancedMesh.js +126 -0
- package/src/objects/LOD.js +195 -0
- package/src/objects/Line.js +222 -0
- package/src/objects/LineLoop.js +17 -0
- package/src/objects/LineSegments.js +55 -0
- package/src/objects/Mesh.js +397 -0
- package/src/objects/Points.js +166 -0
- package/src/objects/Skeleton.js +281 -0
- package/src/objects/SkinnedMesh.js +151 -0
- package/src/objects/Sprite.js +181 -0
- package/src/renderers/WebGL1Renderer.js +7 -0
- package/src/renderers/WebGL3DRenderTarget.js +22 -0
- package/src/renderers/WebGLArrayRenderTarget.js +22 -0
- package/src/renderers/WebGLCubeRenderTarget.js +146 -0
- package/src/renderers/WebGLMultipleRenderTargets.js +82 -0
- package/src/renderers/WebGLRenderTarget.js +110 -0
- package/src/renderers/WebGLRenderer.js +2280 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/alphatest_pars_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +18 -0
- package/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js +304 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +42 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js +18 -0
- package/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js +33 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +23 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +118 -0
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +191 -0
- package/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +36 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js +3 -0
- package/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js +11 -0
- package/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +66 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js +21 -0
- package/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js +22 -0
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +46 -0
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +37 -0
- package/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_fragment.glsl.js +121 -0
- package/src/renderers/shaders/ShaderChunk/iridescence_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +199 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +13 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +32 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_fragment.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +30 -0
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +223 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +34 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +120 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +264 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js +4 -0
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +28 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js +9 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js +16 -0
- package/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js +22 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +24 -0
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +27 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +38 -0
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +36 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +46 -0
- package/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js +41 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_pars_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js +43 -0
- package/src/renderers/shaders/ShaderChunk/output_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +54 -0
- package/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +13 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js +12 -0
- package/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +321 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js +68 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +63 -0
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +66 -0
- package/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +33 -0
- package/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js +20 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js +14 -0
- package/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +77 -0
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +36 -0
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +116 -0
- package/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js +10 -0
- package/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js +17 -0
- package/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js +7 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk.js +265 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +35 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +38 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +92 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +73 -0
- package/src/renderers/shaders/ShaderLib/equirect.glsl.js +35 -0
- package/src/renderers/shaders/ShaderLib/linedashed.glsl.js +70 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +115 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +123 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +107 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +82 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +125 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +216 -0
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +117 -0
- package/src/renderers/shaders/ShaderLib/points.glsl.js +71 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +49 -0
- package/src/renderers/shaders/ShaderLib/sprite.glsl.js +79 -0
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +53 -0
- package/src/renderers/shaders/ShaderLib.js +331 -0
- package/src/renderers/shaders/UniformsLib.js +218 -0
- package/src/renderers/shaders/UniformsUtils.js +80 -0
- package/src/renderers/webgl/WebGLAnimation.js +53 -0
- package/src/renderers/webgl/WebGLAttributes.js +193 -0
- package/src/renderers/webgl/WebGLBackground.js +228 -0
- package/src/renderers/webgl/WebGLBindingStates.js +623 -0
- package/src/renderers/webgl/WebGLBufferRenderer.js +61 -0
- package/src/renderers/webgl/WebGLCapabilities.js +121 -0
- package/src/renderers/webgl/WebGLClipping.js +167 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +99 -0
- package/src/renderers/webgl/WebGLCubeUVMaps.js +130 -0
- package/src/renderers/webgl/WebGLExtensions.js +96 -0
- package/src/renderers/webgl/WebGLGeometries.js +195 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +71 -0
- package/src/renderers/webgl/WebGLInfo.js +72 -0
- package/src/renderers/webgl/WebGLLights.js +574 -0
- package/src/renderers/webgl/WebGLMaterials.js +677 -0
- package/src/renderers/webgl/WebGLMorphtargets.js +300 -0
- package/src/renderers/webgl/WebGLObjects.js +72 -0
- package/src/renderers/webgl/WebGLProgram.js +901 -0
- package/src/renderers/webgl/WebGLPrograms.js +542 -0
- package/src/renderers/webgl/WebGLProperties.js +48 -0
- package/src/renderers/webgl/WebGLRenderLists.js +238 -0
- package/src/renderers/webgl/WebGLRenderStates.js +107 -0
- package/src/renderers/webgl/WebGLShader.js +12 -0
- package/src/renderers/webgl/WebGLShaderCache.js +124 -0
- package/src/renderers/webgl/WebGLShadowMap.js +374 -0
- package/src/renderers/webgl/WebGLState.js +1263 -0
- package/src/renderers/webgl/WebGLTextures.js +1944 -0
- package/src/renderers/webgl/WebGLUniforms.js +1050 -0
- package/src/renderers/webgl/WebGLUniformsGroups.js +372 -0
- package/src/renderers/webgl/WebGLUtils.js +266 -0
- package/src/renderers/webxr/WebXRController.js +307 -0
- package/src/renderers/webxr/WebXRManager.js +731 -0
- package/src/scenes/Fog.js +37 -0
- package/src/scenes/FogExp2.js +34 -0
- package/src/scenes/Scene.js +71 -0
- package/src/textures/CanvasTexture.js +17 -0
- package/src/textures/CompressedTexture.js +28 -0
- package/src/textures/CubeTexture.js +33 -0
- package/src/textures/Data3DTexture.js +35 -0
- package/src/textures/DataArrayTexture.js +27 -0
- package/src/textures/DataTexture.js +22 -0
- package/src/textures/DepthTexture.js +36 -0
- package/src/textures/FramebufferTexture.js +25 -0
- package/src/textures/Source.js +123 -0
- package/src/textures/Texture.js +308 -0
- package/src/textures/VideoTexture.js +55 -0
- package/src/utils.js +71 -0
|
@@ -0,0 +1,3216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GridHelper,
|
|
3
|
+
EllipseCurve,
|
|
4
|
+
BufferGeometry,
|
|
5
|
+
Line,
|
|
6
|
+
LineBasicMaterial,
|
|
7
|
+
Raycaster,
|
|
8
|
+
Group,
|
|
9
|
+
Box3,
|
|
10
|
+
Sphere,
|
|
11
|
+
Quaternion,
|
|
12
|
+
Vector2,
|
|
13
|
+
Vector3,
|
|
14
|
+
Matrix4,
|
|
15
|
+
MathUtils,
|
|
16
|
+
EventDispatcher
|
|
17
|
+
} from 'three';
|
|
18
|
+
|
|
19
|
+
//trackball state
|
|
20
|
+
const STATE = {
|
|
21
|
+
|
|
22
|
+
IDLE: Symbol(),
|
|
23
|
+
ROTATE: Symbol(),
|
|
24
|
+
PAN: Symbol(),
|
|
25
|
+
SCALE: Symbol(),
|
|
26
|
+
FOV: Symbol(),
|
|
27
|
+
FOCUS: Symbol(),
|
|
28
|
+
ZROTATE: Symbol(),
|
|
29
|
+
TOUCH_MULTI: Symbol(),
|
|
30
|
+
ANIMATION_FOCUS: Symbol(),
|
|
31
|
+
ANIMATION_ROTATE: Symbol()
|
|
32
|
+
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const INPUT = {
|
|
36
|
+
|
|
37
|
+
NONE: Symbol(),
|
|
38
|
+
ONE_FINGER: Symbol(),
|
|
39
|
+
ONE_FINGER_SWITCHED: Symbol(),
|
|
40
|
+
TWO_FINGER: Symbol(),
|
|
41
|
+
MULT_FINGER: Symbol(),
|
|
42
|
+
CURSOR: Symbol()
|
|
43
|
+
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
//cursor center coordinates
|
|
47
|
+
const _center = {
|
|
48
|
+
|
|
49
|
+
x: 0,
|
|
50
|
+
y: 0
|
|
51
|
+
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
//transformation matrices for gizmos and camera
|
|
55
|
+
const _transformation = {
|
|
56
|
+
|
|
57
|
+
camera: new Matrix4(),
|
|
58
|
+
gizmos: new Matrix4()
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//events
|
|
63
|
+
const _changeEvent = { type: 'change' };
|
|
64
|
+
const _startEvent = { type: 'start' };
|
|
65
|
+
const _endEvent = { type: 'end' };
|
|
66
|
+
|
|
67
|
+
const _raycaster = new Raycaster();
|
|
68
|
+
const _offset = new Vector3();
|
|
69
|
+
|
|
70
|
+
const _gizmoMatrixStateTemp = new Matrix4();
|
|
71
|
+
const _cameraMatrixStateTemp = new Matrix4();
|
|
72
|
+
const _scalePointTemp = new Vector3();
|
|
73
|
+
/**
|
|
74
|
+
*
|
|
75
|
+
* @param {Camera} camera Virtual camera used in the scene
|
|
76
|
+
* @param {HTMLElement} domElement Renderer's dom element
|
|
77
|
+
* @param {Scene} scene The scene to be rendered
|
|
78
|
+
*/
|
|
79
|
+
class ArcballControls extends EventDispatcher {
|
|
80
|
+
|
|
81
|
+
constructor( camera, domElement, scene = null ) {
|
|
82
|
+
|
|
83
|
+
super();
|
|
84
|
+
this.camera = null;
|
|
85
|
+
this.domElement = domElement;
|
|
86
|
+
this.scene = scene;
|
|
87
|
+
this.target = new Vector3();
|
|
88
|
+
this._currentTarget = new Vector3();
|
|
89
|
+
this.radiusFactor = 0.67;
|
|
90
|
+
|
|
91
|
+
this.mouseActions = [];
|
|
92
|
+
this._mouseOp = null;
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
//global vectors and matrices that are used in some operations to avoid creating new objects every time (e.g. every time cursor moves)
|
|
96
|
+
this._v2_1 = new Vector2();
|
|
97
|
+
this._v3_1 = new Vector3();
|
|
98
|
+
this._v3_2 = new Vector3();
|
|
99
|
+
|
|
100
|
+
this._m4_1 = new Matrix4();
|
|
101
|
+
this._m4_2 = new Matrix4();
|
|
102
|
+
|
|
103
|
+
this._quat = new Quaternion();
|
|
104
|
+
|
|
105
|
+
//transformation matrices
|
|
106
|
+
this._translationMatrix = new Matrix4(); //matrix for translation operation
|
|
107
|
+
this._rotationMatrix = new Matrix4(); //matrix for rotation operation
|
|
108
|
+
this._scaleMatrix = new Matrix4(); //matrix for scaling operation
|
|
109
|
+
|
|
110
|
+
this._rotationAxis = new Vector3(); //axis for rotate operation
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
//camera state
|
|
114
|
+
this._cameraMatrixState = new Matrix4();
|
|
115
|
+
this._cameraProjectionState = new Matrix4();
|
|
116
|
+
|
|
117
|
+
this._fovState = 1;
|
|
118
|
+
this._upState = new Vector3();
|
|
119
|
+
this._zoomState = 1;
|
|
120
|
+
this._nearPos = 0;
|
|
121
|
+
this._farPos = 0;
|
|
122
|
+
|
|
123
|
+
this._gizmoMatrixState = new Matrix4();
|
|
124
|
+
|
|
125
|
+
//initial values
|
|
126
|
+
this._up0 = new Vector3();
|
|
127
|
+
this._zoom0 = 1;
|
|
128
|
+
this._fov0 = 0;
|
|
129
|
+
this._initialNear = 0;
|
|
130
|
+
this._nearPos0 = 0;
|
|
131
|
+
this._initialFar = 0;
|
|
132
|
+
this._farPos0 = 0;
|
|
133
|
+
this._cameraMatrixState0 = new Matrix4();
|
|
134
|
+
this._gizmoMatrixState0 = new Matrix4();
|
|
135
|
+
|
|
136
|
+
//pointers array
|
|
137
|
+
this._button = - 1;
|
|
138
|
+
this._touchStart = [];
|
|
139
|
+
this._touchCurrent = [];
|
|
140
|
+
this._input = INPUT.NONE;
|
|
141
|
+
|
|
142
|
+
//two fingers touch interaction
|
|
143
|
+
this._switchSensibility = 32; //minimum movement to be performed to fire single pan start after the second finger has been released
|
|
144
|
+
this._startFingerDistance = 0; //distance between two fingers
|
|
145
|
+
this._currentFingerDistance = 0;
|
|
146
|
+
this._startFingerRotation = 0; //amount of rotation performed with two fingers
|
|
147
|
+
this._currentFingerRotation = 0;
|
|
148
|
+
|
|
149
|
+
//double tap
|
|
150
|
+
this._devPxRatio = 0;
|
|
151
|
+
this._downValid = true;
|
|
152
|
+
this._nclicks = 0;
|
|
153
|
+
this._downEvents = [];
|
|
154
|
+
this._downStart = 0; //pointerDown time
|
|
155
|
+
this._clickStart = 0; //first click time
|
|
156
|
+
this._maxDownTime = 250;
|
|
157
|
+
this._maxInterval = 300;
|
|
158
|
+
this._posThreshold = 24;
|
|
159
|
+
this._movementThreshold = 24;
|
|
160
|
+
|
|
161
|
+
//cursor positions
|
|
162
|
+
this._currentCursorPosition = new Vector3();
|
|
163
|
+
this._startCursorPosition = new Vector3();
|
|
164
|
+
|
|
165
|
+
//grid
|
|
166
|
+
this._grid = null; //grid to be visualized during pan operation
|
|
167
|
+
this._gridPosition = new Vector3();
|
|
168
|
+
|
|
169
|
+
//gizmos
|
|
170
|
+
this._gizmos = new Group();
|
|
171
|
+
this._curvePts = 128;
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
//animations
|
|
175
|
+
this._timeStart = - 1; //initial time
|
|
176
|
+
this._animationId = - 1;
|
|
177
|
+
|
|
178
|
+
//focus animation
|
|
179
|
+
this.focusAnimationTime = 500; //duration of focus animation in ms
|
|
180
|
+
|
|
181
|
+
//rotate animation
|
|
182
|
+
this._timePrev = 0; //time at which previous rotate operation has been detected
|
|
183
|
+
this._timeCurrent = 0; //time at which current rotate operation has been detected
|
|
184
|
+
this._anglePrev = 0; //angle of previous rotation
|
|
185
|
+
this._angleCurrent = 0; //angle of current rotation
|
|
186
|
+
this._cursorPosPrev = new Vector3(); //cursor position when previous rotate operation has been detected
|
|
187
|
+
this._cursorPosCurr = new Vector3();//cursor position when current rotate operation has been detected
|
|
188
|
+
this._wPrev = 0; //angular velocity of the previous rotate operation
|
|
189
|
+
this._wCurr = 0; //angular velocity of the current rotate operation
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
//parameters
|
|
193
|
+
this.adjustNearFar = false;
|
|
194
|
+
this.scaleFactor = 1.1; //zoom/distance multiplier
|
|
195
|
+
this.dampingFactor = 25;
|
|
196
|
+
this.wMax = 20; //maximum angular velocity allowed
|
|
197
|
+
this.enableAnimations = true; //if animations should be performed
|
|
198
|
+
this.enableGrid = false; //if grid should be showed during pan operation
|
|
199
|
+
this.cursorZoom = false; //if wheel zoom should be cursor centered
|
|
200
|
+
this.minFov = 5;
|
|
201
|
+
this.maxFov = 90;
|
|
202
|
+
|
|
203
|
+
this.enabled = true;
|
|
204
|
+
this.enablePan = true;
|
|
205
|
+
this.enableRotate = true;
|
|
206
|
+
this.enableZoom = true;
|
|
207
|
+
this.enableGizmos = true;
|
|
208
|
+
|
|
209
|
+
this.minDistance = 0;
|
|
210
|
+
this.maxDistance = Infinity;
|
|
211
|
+
this.minZoom = 0;
|
|
212
|
+
this.maxZoom = Infinity;
|
|
213
|
+
|
|
214
|
+
//trackball parameters
|
|
215
|
+
this._tbRadius = 1;
|
|
216
|
+
|
|
217
|
+
//FSA
|
|
218
|
+
this._state = STATE.IDLE;
|
|
219
|
+
|
|
220
|
+
this.setCamera( camera );
|
|
221
|
+
|
|
222
|
+
if ( this.scene != null ) {
|
|
223
|
+
|
|
224
|
+
this.scene.add( this._gizmos );
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
this.domElement.style.touchAction = 'none';
|
|
229
|
+
this._devPxRatio = window.devicePixelRatio;
|
|
230
|
+
|
|
231
|
+
this.initializeMouseActions();
|
|
232
|
+
|
|
233
|
+
this.domElement.addEventListener( 'contextmenu', this.onContextMenu );
|
|
234
|
+
this.domElement.addEventListener( 'wheel', this.onWheel );
|
|
235
|
+
this.domElement.addEventListener( 'pointerdown', this.onPointerDown );
|
|
236
|
+
this.domElement.addEventListener( 'pointercancel', this.onPointerCancel );
|
|
237
|
+
|
|
238
|
+
window.addEventListener( 'resize', this.onWindowResize );
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//listeners
|
|
243
|
+
|
|
244
|
+
onWindowResize = () => {
|
|
245
|
+
|
|
246
|
+
const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
|
|
247
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
248
|
+
|
|
249
|
+
const newRadius = this._tbRadius / scale;
|
|
250
|
+
const curve = new EllipseCurve( 0, 0, newRadius, newRadius );
|
|
251
|
+
const points = curve.getPoints( this._curvePts );
|
|
252
|
+
const curveGeometry = new BufferGeometry().setFromPoints( points );
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
for ( const gizmo in this._gizmos.children ) {
|
|
256
|
+
|
|
257
|
+
this._gizmos.children[ gizmo ].geometry = curveGeometry;
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
this.dispatchEvent( _changeEvent );
|
|
262
|
+
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
onContextMenu = ( event ) => {
|
|
266
|
+
|
|
267
|
+
if ( ! this.enabled ) {
|
|
268
|
+
|
|
269
|
+
return;
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
274
|
+
|
|
275
|
+
if ( this.mouseActions[ i ].mouse == 2 ) {
|
|
276
|
+
|
|
277
|
+
//prevent only if button 2 is actually used
|
|
278
|
+
event.preventDefault();
|
|
279
|
+
break;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
onPointerCancel = () => {
|
|
288
|
+
|
|
289
|
+
this._touchStart.splice( 0, this._touchStart.length );
|
|
290
|
+
this._touchCurrent.splice( 0, this._touchCurrent.length );
|
|
291
|
+
this._input = INPUT.NONE;
|
|
292
|
+
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
onPointerDown = ( event ) => {
|
|
296
|
+
|
|
297
|
+
if ( event.button == 0 && event.isPrimary ) {
|
|
298
|
+
|
|
299
|
+
this._downValid = true;
|
|
300
|
+
this._downEvents.push( event );
|
|
301
|
+
this._downStart = performance.now();
|
|
302
|
+
|
|
303
|
+
} else {
|
|
304
|
+
|
|
305
|
+
this._downValid = false;
|
|
306
|
+
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
|
|
310
|
+
|
|
311
|
+
this._touchStart.push( event );
|
|
312
|
+
this._touchCurrent.push( event );
|
|
313
|
+
|
|
314
|
+
switch ( this._input ) {
|
|
315
|
+
|
|
316
|
+
case INPUT.NONE:
|
|
317
|
+
|
|
318
|
+
//singleStart
|
|
319
|
+
this._input = INPUT.ONE_FINGER;
|
|
320
|
+
this.onSinglePanStart( event, 'ROTATE' );
|
|
321
|
+
|
|
322
|
+
window.addEventListener( 'pointermove', this.onPointerMove );
|
|
323
|
+
window.addEventListener( 'pointerup', this.onPointerUp );
|
|
324
|
+
|
|
325
|
+
break;
|
|
326
|
+
|
|
327
|
+
case INPUT.ONE_FINGER:
|
|
328
|
+
case INPUT.ONE_FINGER_SWITCHED:
|
|
329
|
+
|
|
330
|
+
//doubleStart
|
|
331
|
+
this._input = INPUT.TWO_FINGER;
|
|
332
|
+
|
|
333
|
+
this.onRotateStart();
|
|
334
|
+
this.onPinchStart();
|
|
335
|
+
this.onDoublePanStart();
|
|
336
|
+
|
|
337
|
+
break;
|
|
338
|
+
|
|
339
|
+
case INPUT.TWO_FINGER:
|
|
340
|
+
|
|
341
|
+
//multipleStart
|
|
342
|
+
this._input = INPUT.MULT_FINGER;
|
|
343
|
+
this.onTriplePanStart( event );
|
|
344
|
+
break;
|
|
345
|
+
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
} else if ( event.pointerType != 'touch' && this._input == INPUT.NONE ) {
|
|
349
|
+
|
|
350
|
+
let modifier = null;
|
|
351
|
+
|
|
352
|
+
if ( event.ctrlKey || event.metaKey ) {
|
|
353
|
+
|
|
354
|
+
modifier = 'CTRL';
|
|
355
|
+
|
|
356
|
+
} else if ( event.shiftKey ) {
|
|
357
|
+
|
|
358
|
+
modifier = 'SHIFT';
|
|
359
|
+
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
this._mouseOp = this.getOpFromAction( event.button, modifier );
|
|
363
|
+
if ( this._mouseOp != null ) {
|
|
364
|
+
|
|
365
|
+
window.addEventListener( 'pointermove', this.onPointerMove );
|
|
366
|
+
window.addEventListener( 'pointerup', this.onPointerUp );
|
|
367
|
+
|
|
368
|
+
//singleStart
|
|
369
|
+
this._input = INPUT.CURSOR;
|
|
370
|
+
this._button = event.button;
|
|
371
|
+
this.onSinglePanStart( event, this._mouseOp );
|
|
372
|
+
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
onPointerMove = ( event ) => {
|
|
380
|
+
|
|
381
|
+
if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
|
|
382
|
+
|
|
383
|
+
switch ( this._input ) {
|
|
384
|
+
|
|
385
|
+
case INPUT.ONE_FINGER:
|
|
386
|
+
|
|
387
|
+
//singleMove
|
|
388
|
+
this.updateTouchEvent( event );
|
|
389
|
+
|
|
390
|
+
this.onSinglePanMove( event, STATE.ROTATE );
|
|
391
|
+
break;
|
|
392
|
+
|
|
393
|
+
case INPUT.ONE_FINGER_SWITCHED:
|
|
394
|
+
|
|
395
|
+
const movement = this.calculatePointersDistance( this._touchCurrent[ 0 ], event ) * this._devPxRatio;
|
|
396
|
+
|
|
397
|
+
if ( movement >= this._switchSensibility ) {
|
|
398
|
+
|
|
399
|
+
//singleMove
|
|
400
|
+
this._input = INPUT.ONE_FINGER;
|
|
401
|
+
this.updateTouchEvent( event );
|
|
402
|
+
|
|
403
|
+
this.onSinglePanStart( event, 'ROTATE' );
|
|
404
|
+
break;
|
|
405
|
+
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
break;
|
|
409
|
+
|
|
410
|
+
case INPUT.TWO_FINGER:
|
|
411
|
+
|
|
412
|
+
//rotate/pan/pinchMove
|
|
413
|
+
this.updateTouchEvent( event );
|
|
414
|
+
|
|
415
|
+
this.onRotateMove();
|
|
416
|
+
this.onPinchMove();
|
|
417
|
+
this.onDoublePanMove();
|
|
418
|
+
|
|
419
|
+
break;
|
|
420
|
+
|
|
421
|
+
case INPUT.MULT_FINGER:
|
|
422
|
+
|
|
423
|
+
//multMove
|
|
424
|
+
this.updateTouchEvent( event );
|
|
425
|
+
|
|
426
|
+
this.onTriplePanMove( event );
|
|
427
|
+
break;
|
|
428
|
+
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
} else if ( event.pointerType != 'touch' && this._input == INPUT.CURSOR ) {
|
|
432
|
+
|
|
433
|
+
let modifier = null;
|
|
434
|
+
|
|
435
|
+
if ( event.ctrlKey || event.metaKey ) {
|
|
436
|
+
|
|
437
|
+
modifier = 'CTRL';
|
|
438
|
+
|
|
439
|
+
} else if ( event.shiftKey ) {
|
|
440
|
+
|
|
441
|
+
modifier = 'SHIFT';
|
|
442
|
+
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const mouseOpState = this.getOpStateFromAction( this._button, modifier );
|
|
446
|
+
|
|
447
|
+
if ( mouseOpState != null ) {
|
|
448
|
+
|
|
449
|
+
this.onSinglePanMove( event, mouseOpState );
|
|
450
|
+
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
//checkDistance
|
|
456
|
+
if ( this._downValid ) {
|
|
457
|
+
|
|
458
|
+
const movement = this.calculatePointersDistance( this._downEvents[ this._downEvents.length - 1 ], event ) * this._devPxRatio;
|
|
459
|
+
if ( movement > this._movementThreshold ) {
|
|
460
|
+
|
|
461
|
+
this._downValid = false;
|
|
462
|
+
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
onPointerUp = ( event ) => {
|
|
470
|
+
|
|
471
|
+
if ( event.pointerType == 'touch' && this._input != INPUT.CURSOR ) {
|
|
472
|
+
|
|
473
|
+
const nTouch = this._touchCurrent.length;
|
|
474
|
+
|
|
475
|
+
for ( let i = 0; i < nTouch; i ++ ) {
|
|
476
|
+
|
|
477
|
+
if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
|
|
478
|
+
|
|
479
|
+
this._touchCurrent.splice( i, 1 );
|
|
480
|
+
this._touchStart.splice( i, 1 );
|
|
481
|
+
break;
|
|
482
|
+
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
switch ( this._input ) {
|
|
488
|
+
|
|
489
|
+
case INPUT.ONE_FINGER:
|
|
490
|
+
case INPUT.ONE_FINGER_SWITCHED:
|
|
491
|
+
|
|
492
|
+
//singleEnd
|
|
493
|
+
window.removeEventListener( 'pointermove', this.onPointerMove );
|
|
494
|
+
window.removeEventListener( 'pointerup', this.onPointerUp );
|
|
495
|
+
|
|
496
|
+
this._input = INPUT.NONE;
|
|
497
|
+
this.onSinglePanEnd();
|
|
498
|
+
|
|
499
|
+
break;
|
|
500
|
+
|
|
501
|
+
case INPUT.TWO_FINGER:
|
|
502
|
+
|
|
503
|
+
//doubleEnd
|
|
504
|
+
this.onDoublePanEnd( event );
|
|
505
|
+
this.onPinchEnd( event );
|
|
506
|
+
this.onRotateEnd( event );
|
|
507
|
+
|
|
508
|
+
//switching to singleStart
|
|
509
|
+
this._input = INPUT.ONE_FINGER_SWITCHED;
|
|
510
|
+
|
|
511
|
+
break;
|
|
512
|
+
|
|
513
|
+
case INPUT.MULT_FINGER:
|
|
514
|
+
|
|
515
|
+
if ( this._touchCurrent.length == 0 ) {
|
|
516
|
+
|
|
517
|
+
window.removeEventListener( 'pointermove', this.onPointerMove );
|
|
518
|
+
window.removeEventListener( 'pointerup', this.onPointerUp );
|
|
519
|
+
|
|
520
|
+
//multCancel
|
|
521
|
+
this._input = INPUT.NONE;
|
|
522
|
+
this.onTriplePanEnd();
|
|
523
|
+
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
break;
|
|
527
|
+
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
} else if ( event.pointerType != 'touch' && this._input == INPUT.CURSOR ) {
|
|
531
|
+
|
|
532
|
+
window.removeEventListener( 'pointermove', this.onPointerMove );
|
|
533
|
+
window.removeEventListener( 'pointerup', this.onPointerUp );
|
|
534
|
+
|
|
535
|
+
this._input = INPUT.NONE;
|
|
536
|
+
this.onSinglePanEnd();
|
|
537
|
+
this._button = - 1;
|
|
538
|
+
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if ( event.isPrimary ) {
|
|
542
|
+
|
|
543
|
+
if ( this._downValid ) {
|
|
544
|
+
|
|
545
|
+
const downTime = event.timeStamp - this._downEvents[ this._downEvents.length - 1 ].timeStamp;
|
|
546
|
+
|
|
547
|
+
if ( downTime <= this._maxDownTime ) {
|
|
548
|
+
|
|
549
|
+
if ( this._nclicks == 0 ) {
|
|
550
|
+
|
|
551
|
+
//first valid click detected
|
|
552
|
+
this._nclicks = 1;
|
|
553
|
+
this._clickStart = performance.now();
|
|
554
|
+
|
|
555
|
+
} else {
|
|
556
|
+
|
|
557
|
+
const clickInterval = event.timeStamp - this._clickStart;
|
|
558
|
+
const movement = this.calculatePointersDistance( this._downEvents[ 1 ], this._downEvents[ 0 ] ) * this._devPxRatio;
|
|
559
|
+
|
|
560
|
+
if ( clickInterval <= this._maxInterval && movement <= this._posThreshold ) {
|
|
561
|
+
|
|
562
|
+
//second valid click detected
|
|
563
|
+
//fire double tap and reset values
|
|
564
|
+
this._nclicks = 0;
|
|
565
|
+
this._downEvents.splice( 0, this._downEvents.length );
|
|
566
|
+
this.onDoubleTap( event );
|
|
567
|
+
|
|
568
|
+
} else {
|
|
569
|
+
|
|
570
|
+
//new 'first click'
|
|
571
|
+
this._nclicks = 1;
|
|
572
|
+
this._downEvents.shift();
|
|
573
|
+
this._clickStart = performance.now();
|
|
574
|
+
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
} else {
|
|
580
|
+
|
|
581
|
+
this._downValid = false;
|
|
582
|
+
this._nclicks = 0;
|
|
583
|
+
this._downEvents.splice( 0, this._downEvents.length );
|
|
584
|
+
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
} else {
|
|
588
|
+
|
|
589
|
+
this._nclicks = 0;
|
|
590
|
+
this._downEvents.splice( 0, this._downEvents.length );
|
|
591
|
+
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
onWheel = ( event ) => {
|
|
599
|
+
|
|
600
|
+
if ( this.enabled && this.enableZoom ) {
|
|
601
|
+
|
|
602
|
+
let modifier = null;
|
|
603
|
+
|
|
604
|
+
if ( event.ctrlKey || event.metaKey ) {
|
|
605
|
+
|
|
606
|
+
modifier = 'CTRL';
|
|
607
|
+
|
|
608
|
+
} else if ( event.shiftKey ) {
|
|
609
|
+
|
|
610
|
+
modifier = 'SHIFT';
|
|
611
|
+
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
const mouseOp = this.getOpFromAction( 'WHEEL', modifier );
|
|
615
|
+
|
|
616
|
+
if ( mouseOp != null ) {
|
|
617
|
+
|
|
618
|
+
event.preventDefault();
|
|
619
|
+
this.dispatchEvent( _startEvent );
|
|
620
|
+
|
|
621
|
+
const notchDeltaY = 125; //distance of one notch of mouse wheel
|
|
622
|
+
let sgn = event.deltaY / notchDeltaY;
|
|
623
|
+
|
|
624
|
+
let size = 1;
|
|
625
|
+
|
|
626
|
+
if ( sgn > 0 ) {
|
|
627
|
+
|
|
628
|
+
size = 1 / this.scaleFactor;
|
|
629
|
+
|
|
630
|
+
} else if ( sgn < 0 ) {
|
|
631
|
+
|
|
632
|
+
size = this.scaleFactor;
|
|
633
|
+
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
switch ( mouseOp ) {
|
|
637
|
+
|
|
638
|
+
case 'ZOOM':
|
|
639
|
+
|
|
640
|
+
this.updateTbState( STATE.SCALE, true );
|
|
641
|
+
|
|
642
|
+
if ( sgn > 0 ) {
|
|
643
|
+
|
|
644
|
+
size = 1 / ( Math.pow( this.scaleFactor, sgn ) );
|
|
645
|
+
|
|
646
|
+
} else if ( sgn < 0 ) {
|
|
647
|
+
|
|
648
|
+
size = Math.pow( this.scaleFactor, - sgn );
|
|
649
|
+
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if ( this.cursorZoom && this.enablePan ) {
|
|
653
|
+
|
|
654
|
+
let scalePoint;
|
|
655
|
+
|
|
656
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
657
|
+
|
|
658
|
+
scalePoint = this.unprojectOnTbPlane( this.camera, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._gizmos.position );
|
|
659
|
+
|
|
660
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
661
|
+
|
|
662
|
+
scalePoint = this.unprojectOnTbPlane( this.camera, event.clientX, event.clientY, this.domElement ).applyQuaternion( this.camera.quaternion ).add( this._gizmos.position );
|
|
663
|
+
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
this.applyTransformMatrix( this.scale( size, scalePoint ) );
|
|
667
|
+
|
|
668
|
+
} else {
|
|
669
|
+
|
|
670
|
+
this.applyTransformMatrix( this.scale( size, this._gizmos.position ) );
|
|
671
|
+
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
if ( this._grid != null ) {
|
|
675
|
+
|
|
676
|
+
this.disposeGrid();
|
|
677
|
+
this.drawGrid();
|
|
678
|
+
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
this.updateTbState( STATE.IDLE, false );
|
|
682
|
+
|
|
683
|
+
this.dispatchEvent( _changeEvent );
|
|
684
|
+
this.dispatchEvent( _endEvent );
|
|
685
|
+
|
|
686
|
+
break;
|
|
687
|
+
|
|
688
|
+
case 'FOV':
|
|
689
|
+
|
|
690
|
+
if ( this.camera.isPerspectiveCamera ) {
|
|
691
|
+
|
|
692
|
+
this.updateTbState( STATE.FOV, true );
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
//Vertigo effect
|
|
696
|
+
|
|
697
|
+
// fov / 2
|
|
698
|
+
// |\
|
|
699
|
+
// | \
|
|
700
|
+
// | \
|
|
701
|
+
// x | \
|
|
702
|
+
// | \
|
|
703
|
+
// | \
|
|
704
|
+
// | _ _ _\
|
|
705
|
+
// y
|
|
706
|
+
|
|
707
|
+
//check for iOs shift shortcut
|
|
708
|
+
if ( event.deltaX != 0 ) {
|
|
709
|
+
|
|
710
|
+
sgn = event.deltaX / notchDeltaY;
|
|
711
|
+
|
|
712
|
+
size = 1;
|
|
713
|
+
|
|
714
|
+
if ( sgn > 0 ) {
|
|
715
|
+
|
|
716
|
+
size = 1 / ( Math.pow( this.scaleFactor, sgn ) );
|
|
717
|
+
|
|
718
|
+
} else if ( sgn < 0 ) {
|
|
719
|
+
|
|
720
|
+
size = Math.pow( this.scaleFactor, - sgn );
|
|
721
|
+
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
|
|
727
|
+
const x = this._v3_1.distanceTo( this._gizmos.position );
|
|
728
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
|
729
|
+
|
|
730
|
+
//check min and max distance
|
|
731
|
+
xNew = MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
|
|
732
|
+
|
|
733
|
+
const y = x * Math.tan( MathUtils.DEG2RAD * this.camera.fov * 0.5 );
|
|
734
|
+
|
|
735
|
+
//calculate new fov
|
|
736
|
+
let newFov = MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
|
|
737
|
+
|
|
738
|
+
//check min and max fov
|
|
739
|
+
if ( newFov > this.maxFov ) {
|
|
740
|
+
|
|
741
|
+
newFov = this.maxFov;
|
|
742
|
+
|
|
743
|
+
} else if ( newFov < this.minFov ) {
|
|
744
|
+
|
|
745
|
+
newFov = this.minFov;
|
|
746
|
+
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
const newDistance = y / Math.tan( MathUtils.DEG2RAD * ( newFov / 2 ) );
|
|
750
|
+
size = x / newDistance;
|
|
751
|
+
|
|
752
|
+
this.setFov( newFov );
|
|
753
|
+
this.applyTransformMatrix( this.scale( size, this._gizmos.position, false ) );
|
|
754
|
+
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
if ( this._grid != null ) {
|
|
758
|
+
|
|
759
|
+
this.disposeGrid();
|
|
760
|
+
this.drawGrid();
|
|
761
|
+
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
this.updateTbState( STATE.IDLE, false );
|
|
765
|
+
|
|
766
|
+
this.dispatchEvent( _changeEvent );
|
|
767
|
+
this.dispatchEvent( _endEvent );
|
|
768
|
+
|
|
769
|
+
break;
|
|
770
|
+
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
onSinglePanStart = ( event, operation ) => {
|
|
780
|
+
|
|
781
|
+
if ( this.enabled ) {
|
|
782
|
+
|
|
783
|
+
this.dispatchEvent( _startEvent );
|
|
784
|
+
|
|
785
|
+
this.setCenter( event.clientX, event.clientY );
|
|
786
|
+
|
|
787
|
+
switch ( operation ) {
|
|
788
|
+
|
|
789
|
+
case 'PAN':
|
|
790
|
+
|
|
791
|
+
if ( ! this.enablePan ) {
|
|
792
|
+
|
|
793
|
+
return;
|
|
794
|
+
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
if ( this._animationId != - 1 ) {
|
|
798
|
+
|
|
799
|
+
cancelAnimationFrame( this._animationId );
|
|
800
|
+
this._animationId = - 1;
|
|
801
|
+
this._timeStart = - 1;
|
|
802
|
+
|
|
803
|
+
this.activateGizmos( false );
|
|
804
|
+
this.dispatchEvent( _changeEvent );
|
|
805
|
+
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
this.updateTbState( STATE.PAN, true );
|
|
809
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
|
|
810
|
+
if ( this.enableGrid ) {
|
|
811
|
+
|
|
812
|
+
this.drawGrid();
|
|
813
|
+
this.dispatchEvent( _changeEvent );
|
|
814
|
+
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
break;
|
|
818
|
+
|
|
819
|
+
case 'ROTATE':
|
|
820
|
+
|
|
821
|
+
if ( ! this.enableRotate ) {
|
|
822
|
+
|
|
823
|
+
return;
|
|
824
|
+
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
if ( this._animationId != - 1 ) {
|
|
828
|
+
|
|
829
|
+
cancelAnimationFrame( this._animationId );
|
|
830
|
+
this._animationId = - 1;
|
|
831
|
+
this._timeStart = - 1;
|
|
832
|
+
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
this.updateTbState( STATE.ROTATE, true );
|
|
836
|
+
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
837
|
+
this.activateGizmos( true );
|
|
838
|
+
if ( this.enableAnimations ) {
|
|
839
|
+
|
|
840
|
+
this._timePrev = this._timeCurrent = performance.now();
|
|
841
|
+
this._angleCurrent = this._anglePrev = 0;
|
|
842
|
+
this._cursorPosPrev.copy( this._startCursorPosition );
|
|
843
|
+
this._cursorPosCurr.copy( this._cursorPosPrev );
|
|
844
|
+
this._wCurr = 0;
|
|
845
|
+
this._wPrev = this._wCurr;
|
|
846
|
+
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
this.dispatchEvent( _changeEvent );
|
|
850
|
+
break;
|
|
851
|
+
|
|
852
|
+
case 'FOV':
|
|
853
|
+
|
|
854
|
+
if ( ! this.camera.isPerspectiveCamera || ! this.enableZoom ) {
|
|
855
|
+
|
|
856
|
+
return;
|
|
857
|
+
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
if ( this._animationId != - 1 ) {
|
|
861
|
+
|
|
862
|
+
cancelAnimationFrame( this._animationId );
|
|
863
|
+
this._animationId = - 1;
|
|
864
|
+
this._timeStart = - 1;
|
|
865
|
+
|
|
866
|
+
this.activateGizmos( false );
|
|
867
|
+
this.dispatchEvent( _changeEvent );
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
this.updateTbState( STATE.FOV, true );
|
|
872
|
+
this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
873
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
874
|
+
break;
|
|
875
|
+
|
|
876
|
+
case 'ZOOM':
|
|
877
|
+
|
|
878
|
+
if ( ! this.enableZoom ) {
|
|
879
|
+
|
|
880
|
+
return;
|
|
881
|
+
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
if ( this._animationId != - 1 ) {
|
|
885
|
+
|
|
886
|
+
cancelAnimationFrame( this._animationId );
|
|
887
|
+
this._animationId = - 1;
|
|
888
|
+
this._timeStart = - 1;
|
|
889
|
+
|
|
890
|
+
this.activateGizmos( false );
|
|
891
|
+
this.dispatchEvent( _changeEvent );
|
|
892
|
+
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
this.updateTbState( STATE.SCALE, true );
|
|
896
|
+
this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
897
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
898
|
+
break;
|
|
899
|
+
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
};
|
|
905
|
+
|
|
906
|
+
onSinglePanMove = ( event, opState ) => {
|
|
907
|
+
|
|
908
|
+
if ( this.enabled ) {
|
|
909
|
+
|
|
910
|
+
const restart = opState != this._state;
|
|
911
|
+
this.setCenter( event.clientX, event.clientY );
|
|
912
|
+
|
|
913
|
+
switch ( opState ) {
|
|
914
|
+
|
|
915
|
+
case STATE.PAN:
|
|
916
|
+
|
|
917
|
+
if ( this.enablePan ) {
|
|
918
|
+
|
|
919
|
+
if ( restart ) {
|
|
920
|
+
|
|
921
|
+
//switch to pan operation
|
|
922
|
+
|
|
923
|
+
this.dispatchEvent( _endEvent );
|
|
924
|
+
this.dispatchEvent( _startEvent );
|
|
925
|
+
|
|
926
|
+
this.updateTbState( opState, true );
|
|
927
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
|
|
928
|
+
if ( this.enableGrid ) {
|
|
929
|
+
|
|
930
|
+
this.drawGrid();
|
|
931
|
+
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
this.activateGizmos( false );
|
|
935
|
+
|
|
936
|
+
} else {
|
|
937
|
+
|
|
938
|
+
//continue with pan operation
|
|
939
|
+
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ) );
|
|
940
|
+
this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition ) );
|
|
941
|
+
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
break;
|
|
947
|
+
|
|
948
|
+
case STATE.ROTATE:
|
|
949
|
+
|
|
950
|
+
if ( this.enableRotate ) {
|
|
951
|
+
|
|
952
|
+
if ( restart ) {
|
|
953
|
+
|
|
954
|
+
//switch to rotate operation
|
|
955
|
+
|
|
956
|
+
this.dispatchEvent( _endEvent );
|
|
957
|
+
this.dispatchEvent( _startEvent );
|
|
958
|
+
|
|
959
|
+
this.updateTbState( opState, true );
|
|
960
|
+
this._startCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
961
|
+
|
|
962
|
+
if ( this.enableGrid ) {
|
|
963
|
+
|
|
964
|
+
this.disposeGrid();
|
|
965
|
+
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
this.activateGizmos( true );
|
|
969
|
+
|
|
970
|
+
} else {
|
|
971
|
+
|
|
972
|
+
//continue with rotate operation
|
|
973
|
+
this._currentCursorPosition.copy( this.unprojectOnTbSurface( this.camera, _center.x, _center.y, this.domElement, this._tbRadius ) );
|
|
974
|
+
|
|
975
|
+
const distance = this._startCursorPosition.distanceTo( this._currentCursorPosition );
|
|
976
|
+
const angle = this._startCursorPosition.angleTo( this._currentCursorPosition );
|
|
977
|
+
const amount = Math.max( distance / this._tbRadius, angle ); //effective rotation angle
|
|
978
|
+
|
|
979
|
+
this.applyTransformMatrix( this.rotate( this.calculateRotationAxis( this._startCursorPosition, this._currentCursorPosition ), amount ) );
|
|
980
|
+
|
|
981
|
+
if ( this.enableAnimations ) {
|
|
982
|
+
|
|
983
|
+
this._timePrev = this._timeCurrent;
|
|
984
|
+
this._timeCurrent = performance.now();
|
|
985
|
+
this._anglePrev = this._angleCurrent;
|
|
986
|
+
this._angleCurrent = amount;
|
|
987
|
+
this._cursorPosPrev.copy( this._cursorPosCurr );
|
|
988
|
+
this._cursorPosCurr.copy( this._currentCursorPosition );
|
|
989
|
+
this._wPrev = this._wCurr;
|
|
990
|
+
this._wCurr = this.calculateAngularSpeed( this._anglePrev, this._angleCurrent, this._timePrev, this._timeCurrent );
|
|
991
|
+
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
break;
|
|
999
|
+
|
|
1000
|
+
case STATE.SCALE:
|
|
1001
|
+
|
|
1002
|
+
if ( this.enableZoom ) {
|
|
1003
|
+
|
|
1004
|
+
if ( restart ) {
|
|
1005
|
+
|
|
1006
|
+
//switch to zoom operation
|
|
1007
|
+
|
|
1008
|
+
this.dispatchEvent( _endEvent );
|
|
1009
|
+
this.dispatchEvent( _startEvent );
|
|
1010
|
+
|
|
1011
|
+
this.updateTbState( opState, true );
|
|
1012
|
+
this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1013
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
1014
|
+
|
|
1015
|
+
if ( this.enableGrid ) {
|
|
1016
|
+
|
|
1017
|
+
this.disposeGrid();
|
|
1018
|
+
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
this.activateGizmos( false );
|
|
1022
|
+
|
|
1023
|
+
} else {
|
|
1024
|
+
|
|
1025
|
+
//continue with zoom operation
|
|
1026
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
|
1027
|
+
this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1028
|
+
|
|
1029
|
+
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
|
1030
|
+
|
|
1031
|
+
let size = 1;
|
|
1032
|
+
|
|
1033
|
+
if ( movement < 0 ) {
|
|
1034
|
+
|
|
1035
|
+
size = 1 / ( Math.pow( this.scaleFactor, - movement * screenNotches ) );
|
|
1036
|
+
|
|
1037
|
+
} else if ( movement > 0 ) {
|
|
1038
|
+
|
|
1039
|
+
size = Math.pow( this.scaleFactor, movement * screenNotches );
|
|
1040
|
+
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
this._v3_1.setFromMatrixPosition( this._gizmoMatrixState );
|
|
1044
|
+
|
|
1045
|
+
this.applyTransformMatrix( this.scale( size, this._v3_1 ) );
|
|
1046
|
+
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
break;
|
|
1052
|
+
|
|
1053
|
+
case STATE.FOV:
|
|
1054
|
+
|
|
1055
|
+
if ( this.enableZoom && this.camera.isPerspectiveCamera ) {
|
|
1056
|
+
|
|
1057
|
+
if ( restart ) {
|
|
1058
|
+
|
|
1059
|
+
//switch to fov operation
|
|
1060
|
+
|
|
1061
|
+
this.dispatchEvent( _endEvent );
|
|
1062
|
+
this.dispatchEvent( _startEvent );
|
|
1063
|
+
|
|
1064
|
+
this.updateTbState( opState, true );
|
|
1065
|
+
this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1066
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
1067
|
+
|
|
1068
|
+
if ( this.enableGrid ) {
|
|
1069
|
+
|
|
1070
|
+
this.disposeGrid();
|
|
1071
|
+
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
this.activateGizmos( false );
|
|
1075
|
+
|
|
1076
|
+
} else {
|
|
1077
|
+
|
|
1078
|
+
//continue with fov operation
|
|
1079
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
|
1080
|
+
this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1081
|
+
|
|
1082
|
+
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
|
1083
|
+
|
|
1084
|
+
let size = 1;
|
|
1085
|
+
|
|
1086
|
+
if ( movement < 0 ) {
|
|
1087
|
+
|
|
1088
|
+
size = 1 / ( Math.pow( this.scaleFactor, - movement * screenNotches ) );
|
|
1089
|
+
|
|
1090
|
+
} else if ( movement > 0 ) {
|
|
1091
|
+
|
|
1092
|
+
size = Math.pow( this.scaleFactor, movement * screenNotches );
|
|
1093
|
+
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
|
|
1097
|
+
const x = this._v3_1.distanceTo( this._gizmos.position );
|
|
1098
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
|
1099
|
+
|
|
1100
|
+
//check min and max distance
|
|
1101
|
+
xNew = MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
|
|
1102
|
+
|
|
1103
|
+
const y = x * Math.tan( MathUtils.DEG2RAD * this._fovState * 0.5 );
|
|
1104
|
+
|
|
1105
|
+
//calculate new fov
|
|
1106
|
+
let newFov = MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
|
|
1107
|
+
|
|
1108
|
+
//check min and max fov
|
|
1109
|
+
newFov = MathUtils.clamp( newFov, this.minFov, this.maxFov );
|
|
1110
|
+
|
|
1111
|
+
const newDistance = y / Math.tan( MathUtils.DEG2RAD * ( newFov / 2 ) );
|
|
1112
|
+
size = x / newDistance;
|
|
1113
|
+
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
1114
|
+
|
|
1115
|
+
this.setFov( newFov );
|
|
1116
|
+
this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
|
|
1117
|
+
|
|
1118
|
+
//adjusting distance
|
|
1119
|
+
_offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
|
|
1120
|
+
this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
1121
|
+
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
break;
|
|
1127
|
+
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
this.dispatchEvent( _changeEvent );
|
|
1131
|
+
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
onSinglePanEnd = () => {
|
|
1137
|
+
|
|
1138
|
+
if ( this._state == STATE.ROTATE ) {
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
if ( ! this.enableRotate ) {
|
|
1142
|
+
|
|
1143
|
+
return;
|
|
1144
|
+
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
if ( this.enableAnimations ) {
|
|
1148
|
+
|
|
1149
|
+
//perform rotation animation
|
|
1150
|
+
const deltaTime = ( performance.now() - this._timeCurrent );
|
|
1151
|
+
if ( deltaTime < 120 ) {
|
|
1152
|
+
|
|
1153
|
+
const w = Math.abs( ( this._wPrev + this._wCurr ) / 2 );
|
|
1154
|
+
|
|
1155
|
+
const self = this;
|
|
1156
|
+
this._animationId = window.requestAnimationFrame( function ( t ) {
|
|
1157
|
+
|
|
1158
|
+
self.updateTbState( STATE.ANIMATION_ROTATE, true );
|
|
1159
|
+
const rotationAxis = self.calculateRotationAxis( self._cursorPosPrev, self._cursorPosCurr );
|
|
1160
|
+
|
|
1161
|
+
self.onRotationAnim( t, rotationAxis, Math.min( w, self.wMax ) );
|
|
1162
|
+
|
|
1163
|
+
} );
|
|
1164
|
+
|
|
1165
|
+
} else {
|
|
1166
|
+
|
|
1167
|
+
//cursor has been standing still for over 120 ms since last movement
|
|
1168
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1169
|
+
this.activateGizmos( false );
|
|
1170
|
+
this.dispatchEvent( _changeEvent );
|
|
1171
|
+
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
} else {
|
|
1175
|
+
|
|
1176
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1177
|
+
this.activateGizmos( false );
|
|
1178
|
+
this.dispatchEvent( _changeEvent );
|
|
1179
|
+
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
} else if ( this._state == STATE.PAN || this._state == STATE.IDLE ) {
|
|
1183
|
+
|
|
1184
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1185
|
+
|
|
1186
|
+
if ( this.enableGrid ) {
|
|
1187
|
+
|
|
1188
|
+
this.disposeGrid();
|
|
1189
|
+
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
this.activateGizmos( false );
|
|
1193
|
+
this.dispatchEvent( _changeEvent );
|
|
1194
|
+
|
|
1195
|
+
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
this.dispatchEvent( _endEvent );
|
|
1199
|
+
|
|
1200
|
+
};
|
|
1201
|
+
|
|
1202
|
+
onDoubleTap = ( event ) => {
|
|
1203
|
+
|
|
1204
|
+
if ( this.enabled && this.enablePan && this.scene != null ) {
|
|
1205
|
+
|
|
1206
|
+
this.dispatchEvent( _startEvent );
|
|
1207
|
+
|
|
1208
|
+
this.setCenter( event.clientX, event.clientY );
|
|
1209
|
+
const hitP = this.unprojectOnObj( this.getCursorNDC( _center.x, _center.y, this.domElement ), this.camera );
|
|
1210
|
+
|
|
1211
|
+
if ( hitP != null && this.enableAnimations ) {
|
|
1212
|
+
|
|
1213
|
+
const self = this;
|
|
1214
|
+
if ( this._animationId != - 1 ) {
|
|
1215
|
+
|
|
1216
|
+
window.cancelAnimationFrame( this._animationId );
|
|
1217
|
+
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
this._timeStart = - 1;
|
|
1221
|
+
this._animationId = window.requestAnimationFrame( function ( t ) {
|
|
1222
|
+
|
|
1223
|
+
self.updateTbState( STATE.ANIMATION_FOCUS, true );
|
|
1224
|
+
self.onFocusAnim( t, hitP, self._cameraMatrixState, self._gizmoMatrixState );
|
|
1225
|
+
|
|
1226
|
+
} );
|
|
1227
|
+
|
|
1228
|
+
} else if ( hitP != null && ! this.enableAnimations ) {
|
|
1229
|
+
|
|
1230
|
+
this.updateTbState( STATE.FOCUS, true );
|
|
1231
|
+
this.focus( hitP, this.scaleFactor );
|
|
1232
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1233
|
+
this.dispatchEvent( _changeEvent );
|
|
1234
|
+
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1239
|
+
this.dispatchEvent( _endEvent );
|
|
1240
|
+
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
onDoublePanStart = () => {
|
|
1244
|
+
|
|
1245
|
+
if ( this.enabled && this.enablePan ) {
|
|
1246
|
+
|
|
1247
|
+
this.dispatchEvent( _startEvent );
|
|
1248
|
+
|
|
1249
|
+
this.updateTbState( STATE.PAN, true );
|
|
1250
|
+
|
|
1251
|
+
this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
|
|
1252
|
+
this._startCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
|
|
1253
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
1254
|
+
|
|
1255
|
+
this.activateGizmos( false );
|
|
1256
|
+
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
};
|
|
1260
|
+
|
|
1261
|
+
onDoublePanMove = () => {
|
|
1262
|
+
|
|
1263
|
+
if ( this.enabled && this.enablePan ) {
|
|
1264
|
+
|
|
1265
|
+
this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
|
|
1266
|
+
|
|
1267
|
+
if ( this._state != STATE.PAN ) {
|
|
1268
|
+
|
|
1269
|
+
this.updateTbState( STATE.PAN, true );
|
|
1270
|
+
this._startCursorPosition.copy( this._currentCursorPosition );
|
|
1271
|
+
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
this._currentCursorPosition.copy( this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement, true ) );
|
|
1275
|
+
this.applyTransformMatrix( this.pan( this._startCursorPosition, this._currentCursorPosition, true ) );
|
|
1276
|
+
this.dispatchEvent( _changeEvent );
|
|
1277
|
+
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
onDoublePanEnd = () => {
|
|
1283
|
+
|
|
1284
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1285
|
+
this.dispatchEvent( _endEvent );
|
|
1286
|
+
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
|
|
1290
|
+
onRotateStart = () => {
|
|
1291
|
+
|
|
1292
|
+
if ( this.enabled && this.enableRotate ) {
|
|
1293
|
+
|
|
1294
|
+
this.dispatchEvent( _startEvent );
|
|
1295
|
+
|
|
1296
|
+
this.updateTbState( STATE.ZROTATE, true );
|
|
1297
|
+
|
|
1298
|
+
//this._startFingerRotation = event.rotation;
|
|
1299
|
+
|
|
1300
|
+
this._startFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
|
|
1301
|
+
this._currentFingerRotation = this._startFingerRotation;
|
|
1302
|
+
|
|
1303
|
+
this.camera.getWorldDirection( this._rotationAxis ); //rotation axis
|
|
1304
|
+
|
|
1305
|
+
if ( ! this.enablePan && ! this.enableZoom ) {
|
|
1306
|
+
|
|
1307
|
+
this.activateGizmos( true );
|
|
1308
|
+
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
};
|
|
1314
|
+
|
|
1315
|
+
onRotateMove = () => {
|
|
1316
|
+
|
|
1317
|
+
if ( this.enabled && this.enableRotate ) {
|
|
1318
|
+
|
|
1319
|
+
this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
|
|
1320
|
+
let rotationPoint;
|
|
1321
|
+
|
|
1322
|
+
if ( this._state != STATE.ZROTATE ) {
|
|
1323
|
+
|
|
1324
|
+
this.updateTbState( STATE.ZROTATE, true );
|
|
1325
|
+
this._startFingerRotation = this._currentFingerRotation;
|
|
1326
|
+
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
//this._currentFingerRotation = event.rotation;
|
|
1330
|
+
this._currentFingerRotation = this.getAngle( this._touchCurrent[ 1 ], this._touchCurrent[ 0 ] ) + this.getAngle( this._touchStart[ 1 ], this._touchStart[ 0 ] );
|
|
1331
|
+
|
|
1332
|
+
if ( ! this.enablePan ) {
|
|
1333
|
+
|
|
1334
|
+
rotationPoint = new Vector3().setFromMatrixPosition( this._gizmoMatrixState );
|
|
1335
|
+
|
|
1336
|
+
} else {
|
|
1337
|
+
|
|
1338
|
+
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
1339
|
+
rotationPoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement ).applyQuaternion( this.camera.quaternion ).multiplyScalar( 1 / this.camera.zoom ).add( this._v3_2 );
|
|
1340
|
+
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
const amount = MathUtils.DEG2RAD * ( this._startFingerRotation - this._currentFingerRotation );
|
|
1344
|
+
|
|
1345
|
+
this.applyTransformMatrix( this.zRotate( rotationPoint, amount ) );
|
|
1346
|
+
this.dispatchEvent( _changeEvent );
|
|
1347
|
+
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
};
|
|
1351
|
+
|
|
1352
|
+
onRotateEnd = () => {
|
|
1353
|
+
|
|
1354
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1355
|
+
this.activateGizmos( false );
|
|
1356
|
+
this.dispatchEvent( _endEvent );
|
|
1357
|
+
|
|
1358
|
+
};
|
|
1359
|
+
|
|
1360
|
+
onPinchStart = () => {
|
|
1361
|
+
|
|
1362
|
+
if ( this.enabled && this.enableZoom ) {
|
|
1363
|
+
|
|
1364
|
+
this.dispatchEvent( _startEvent );
|
|
1365
|
+
this.updateTbState( STATE.SCALE, true );
|
|
1366
|
+
|
|
1367
|
+
this._startFingerDistance = this.calculatePointersDistance( this._touchCurrent[ 0 ], this._touchCurrent[ 1 ] );
|
|
1368
|
+
this._currentFingerDistance = this._startFingerDistance;
|
|
1369
|
+
|
|
1370
|
+
this.activateGizmos( false );
|
|
1371
|
+
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
};
|
|
1375
|
+
|
|
1376
|
+
onPinchMove = () => {
|
|
1377
|
+
|
|
1378
|
+
if ( this.enabled && this.enableZoom ) {
|
|
1379
|
+
|
|
1380
|
+
this.setCenter( ( this._touchCurrent[ 0 ].clientX + this._touchCurrent[ 1 ].clientX ) / 2, ( this._touchCurrent[ 0 ].clientY + this._touchCurrent[ 1 ].clientY ) / 2 );
|
|
1381
|
+
const minDistance = 12; //minimum distance between fingers (in css pixels)
|
|
1382
|
+
|
|
1383
|
+
if ( this._state != STATE.SCALE ) {
|
|
1384
|
+
|
|
1385
|
+
this._startFingerDistance = this._currentFingerDistance;
|
|
1386
|
+
this.updateTbState( STATE.SCALE, true );
|
|
1387
|
+
|
|
1388
|
+
}
|
|
1389
|
+
|
|
1390
|
+
this._currentFingerDistance = Math.max( this.calculatePointersDistance( this._touchCurrent[ 0 ], this._touchCurrent[ 1 ] ), minDistance * this._devPxRatio );
|
|
1391
|
+
const amount = this._currentFingerDistance / this._startFingerDistance;
|
|
1392
|
+
|
|
1393
|
+
let scalePoint;
|
|
1394
|
+
|
|
1395
|
+
if ( ! this.enablePan ) {
|
|
1396
|
+
|
|
1397
|
+
scalePoint = this._gizmos.position;
|
|
1398
|
+
|
|
1399
|
+
} else {
|
|
1400
|
+
|
|
1401
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
1402
|
+
|
|
1403
|
+
scalePoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement )
|
|
1404
|
+
.applyQuaternion( this.camera.quaternion )
|
|
1405
|
+
.multiplyScalar( 1 / this.camera.zoom )
|
|
1406
|
+
.add( this._gizmos.position );
|
|
1407
|
+
|
|
1408
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
1409
|
+
|
|
1410
|
+
scalePoint = this.unprojectOnTbPlane( this.camera, _center.x, _center.y, this.domElement )
|
|
1411
|
+
.applyQuaternion( this.camera.quaternion )
|
|
1412
|
+
.add( this._gizmos.position );
|
|
1413
|
+
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
this.applyTransformMatrix( this.scale( amount, scalePoint ) );
|
|
1419
|
+
this.dispatchEvent( _changeEvent );
|
|
1420
|
+
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
onPinchEnd = () => {
|
|
1426
|
+
|
|
1427
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1428
|
+
this.dispatchEvent( _endEvent );
|
|
1429
|
+
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
onTriplePanStart = () => {
|
|
1433
|
+
|
|
1434
|
+
if ( this.enabled && this.enableZoom ) {
|
|
1435
|
+
|
|
1436
|
+
this.dispatchEvent( _startEvent );
|
|
1437
|
+
|
|
1438
|
+
this.updateTbState( STATE.SCALE, true );
|
|
1439
|
+
|
|
1440
|
+
//const center = event.center;
|
|
1441
|
+
let clientX = 0;
|
|
1442
|
+
let clientY = 0;
|
|
1443
|
+
const nFingers = this._touchCurrent.length;
|
|
1444
|
+
|
|
1445
|
+
for ( let i = 0; i < nFingers; i ++ ) {
|
|
1446
|
+
|
|
1447
|
+
clientX += this._touchCurrent[ i ].clientX;
|
|
1448
|
+
clientY += this._touchCurrent[ i ].clientY;
|
|
1449
|
+
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1452
|
+
this.setCenter( clientX / nFingers, clientY / nFingers );
|
|
1453
|
+
|
|
1454
|
+
this._startCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1455
|
+
this._currentCursorPosition.copy( this._startCursorPosition );
|
|
1456
|
+
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
};
|
|
1460
|
+
|
|
1461
|
+
onTriplePanMove = () => {
|
|
1462
|
+
|
|
1463
|
+
if ( this.enabled && this.enableZoom ) {
|
|
1464
|
+
|
|
1465
|
+
// fov / 2
|
|
1466
|
+
// |\
|
|
1467
|
+
// | \
|
|
1468
|
+
// | \
|
|
1469
|
+
// x | \
|
|
1470
|
+
// | \
|
|
1471
|
+
// | \
|
|
1472
|
+
// | _ _ _\
|
|
1473
|
+
// y
|
|
1474
|
+
|
|
1475
|
+
//const center = event.center;
|
|
1476
|
+
let clientX = 0;
|
|
1477
|
+
let clientY = 0;
|
|
1478
|
+
const nFingers = this._touchCurrent.length;
|
|
1479
|
+
|
|
1480
|
+
for ( let i = 0; i < nFingers; i ++ ) {
|
|
1481
|
+
|
|
1482
|
+
clientX += this._touchCurrent[ i ].clientX;
|
|
1483
|
+
clientY += this._touchCurrent[ i ].clientY;
|
|
1484
|
+
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
this.setCenter( clientX / nFingers, clientY / nFingers );
|
|
1488
|
+
|
|
1489
|
+
const screenNotches = 8; //how many wheel notches corresponds to a full screen pan
|
|
1490
|
+
this._currentCursorPosition.setY( this.getCursorNDC( _center.x, _center.y, this.domElement ).y * 0.5 );
|
|
1491
|
+
|
|
1492
|
+
const movement = this._currentCursorPosition.y - this._startCursorPosition.y;
|
|
1493
|
+
|
|
1494
|
+
let size = 1;
|
|
1495
|
+
|
|
1496
|
+
if ( movement < 0 ) {
|
|
1497
|
+
|
|
1498
|
+
size = 1 / ( Math.pow( this.scaleFactor, - movement * screenNotches ) );
|
|
1499
|
+
|
|
1500
|
+
} else if ( movement > 0 ) {
|
|
1501
|
+
|
|
1502
|
+
size = Math.pow( this.scaleFactor, movement * screenNotches );
|
|
1503
|
+
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
|
|
1507
|
+
const x = this._v3_1.distanceTo( this._gizmos.position );
|
|
1508
|
+
let xNew = x / size; //distance between camera and gizmos if scale(size, scalepoint) would be performed
|
|
1509
|
+
|
|
1510
|
+
//check min and max distance
|
|
1511
|
+
xNew = MathUtils.clamp( xNew, this.minDistance, this.maxDistance );
|
|
1512
|
+
|
|
1513
|
+
const y = x * Math.tan( MathUtils.DEG2RAD * this._fovState * 0.5 );
|
|
1514
|
+
|
|
1515
|
+
//calculate new fov
|
|
1516
|
+
let newFov = MathUtils.RAD2DEG * ( Math.atan( y / xNew ) * 2 );
|
|
1517
|
+
|
|
1518
|
+
//check min and max fov
|
|
1519
|
+
newFov = MathUtils.clamp( newFov, this.minFov, this.maxFov );
|
|
1520
|
+
|
|
1521
|
+
const newDistance = y / Math.tan( MathUtils.DEG2RAD * ( newFov / 2 ) );
|
|
1522
|
+
size = x / newDistance;
|
|
1523
|
+
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
1524
|
+
|
|
1525
|
+
this.setFov( newFov );
|
|
1526
|
+
this.applyTransformMatrix( this.scale( size, this._v3_2, false ) );
|
|
1527
|
+
|
|
1528
|
+
//adjusting distance
|
|
1529
|
+
_offset.copy( this._gizmos.position ).sub( this.camera.position ).normalize().multiplyScalar( newDistance / x );
|
|
1530
|
+
this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
1531
|
+
|
|
1532
|
+
this.dispatchEvent( _changeEvent );
|
|
1533
|
+
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
onTriplePanEnd = () => {
|
|
1539
|
+
|
|
1540
|
+
this.updateTbState( STATE.IDLE, false );
|
|
1541
|
+
this.dispatchEvent( _endEvent );
|
|
1542
|
+
//this.dispatchEvent( _changeEvent );
|
|
1543
|
+
|
|
1544
|
+
};
|
|
1545
|
+
|
|
1546
|
+
/**
|
|
1547
|
+
* Set _center's x/y coordinates
|
|
1548
|
+
* @param {Number} clientX
|
|
1549
|
+
* @param {Number} clientY
|
|
1550
|
+
*/
|
|
1551
|
+
setCenter = ( clientX, clientY ) => {
|
|
1552
|
+
|
|
1553
|
+
_center.x = clientX;
|
|
1554
|
+
_center.y = clientY;
|
|
1555
|
+
|
|
1556
|
+
};
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* Set default mouse actions
|
|
1560
|
+
*/
|
|
1561
|
+
initializeMouseActions = () => {
|
|
1562
|
+
|
|
1563
|
+
this.setMouseAction( 'PAN', 0, 'CTRL' );
|
|
1564
|
+
this.setMouseAction( 'PAN', 2 );
|
|
1565
|
+
|
|
1566
|
+
this.setMouseAction( 'ROTATE', 0 );
|
|
1567
|
+
|
|
1568
|
+
this.setMouseAction( 'ZOOM', 'WHEEL' );
|
|
1569
|
+
this.setMouseAction( 'ZOOM', 1 );
|
|
1570
|
+
|
|
1571
|
+
this.setMouseAction( 'FOV', 'WHEEL', 'SHIFT' );
|
|
1572
|
+
this.setMouseAction( 'FOV', 1, 'SHIFT' );
|
|
1573
|
+
|
|
1574
|
+
|
|
1575
|
+
};
|
|
1576
|
+
|
|
1577
|
+
/**
|
|
1578
|
+
* Compare two mouse actions
|
|
1579
|
+
* @param {Object} action1
|
|
1580
|
+
* @param {Object} action2
|
|
1581
|
+
* @returns {Boolean} True if action1 and action 2 are the same mouse action, false otherwise
|
|
1582
|
+
*/
|
|
1583
|
+
compareMouseAction = ( action1, action2 ) => {
|
|
1584
|
+
|
|
1585
|
+
if ( action1.operation == action2.operation ) {
|
|
1586
|
+
|
|
1587
|
+
if ( action1.mouse == action2.mouse && action1.key == action2.key ) {
|
|
1588
|
+
|
|
1589
|
+
return true;
|
|
1590
|
+
|
|
1591
|
+
} else {
|
|
1592
|
+
|
|
1593
|
+
return false;
|
|
1594
|
+
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
} else {
|
|
1598
|
+
|
|
1599
|
+
return false;
|
|
1600
|
+
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1605
|
+
/**
|
|
1606
|
+
* Set a new mouse action by specifying the operation to be performed and a mouse/key combination. In case of conflict, replaces the existing one
|
|
1607
|
+
* @param {String} operation The operation to be performed ('PAN', 'ROTATE', 'ZOOM', 'FOV)
|
|
1608
|
+
* @param {*} mouse A mouse button (0, 1, 2) or 'WHEEL' for wheel notches
|
|
1609
|
+
* @param {*} key The keyboard modifier ('CTRL', 'SHIFT') or null if key is not needed
|
|
1610
|
+
* @returns {Boolean} True if the mouse action has been successfully added, false otherwise
|
|
1611
|
+
*/
|
|
1612
|
+
setMouseAction = ( operation, mouse, key = null ) => {
|
|
1613
|
+
|
|
1614
|
+
const operationInput = [ 'PAN', 'ROTATE', 'ZOOM', 'FOV' ];
|
|
1615
|
+
const mouseInput = [ 0, 1, 2, 'WHEEL' ];
|
|
1616
|
+
const keyInput = [ 'CTRL', 'SHIFT', null ];
|
|
1617
|
+
let state;
|
|
1618
|
+
|
|
1619
|
+
if ( ! operationInput.includes( operation ) || ! mouseInput.includes( mouse ) || ! keyInput.includes( key ) ) {
|
|
1620
|
+
|
|
1621
|
+
//invalid parameters
|
|
1622
|
+
return false;
|
|
1623
|
+
|
|
1624
|
+
}
|
|
1625
|
+
|
|
1626
|
+
if ( mouse == 'WHEEL' ) {
|
|
1627
|
+
|
|
1628
|
+
if ( operation != 'ZOOM' && operation != 'FOV' ) {
|
|
1629
|
+
|
|
1630
|
+
//cannot associate 2D operation to 1D input
|
|
1631
|
+
return false;
|
|
1632
|
+
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
switch ( operation ) {
|
|
1638
|
+
|
|
1639
|
+
case 'PAN':
|
|
1640
|
+
|
|
1641
|
+
state = STATE.PAN;
|
|
1642
|
+
break;
|
|
1643
|
+
|
|
1644
|
+
case 'ROTATE':
|
|
1645
|
+
|
|
1646
|
+
state = STATE.ROTATE;
|
|
1647
|
+
break;
|
|
1648
|
+
|
|
1649
|
+
case 'ZOOM':
|
|
1650
|
+
|
|
1651
|
+
state = STATE.SCALE;
|
|
1652
|
+
break;
|
|
1653
|
+
|
|
1654
|
+
case 'FOV':
|
|
1655
|
+
|
|
1656
|
+
state = STATE.FOV;
|
|
1657
|
+
break;
|
|
1658
|
+
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
const action = {
|
|
1662
|
+
|
|
1663
|
+
operation: operation,
|
|
1664
|
+
mouse: mouse,
|
|
1665
|
+
key: key,
|
|
1666
|
+
state: state
|
|
1667
|
+
|
|
1668
|
+
};
|
|
1669
|
+
|
|
1670
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1671
|
+
|
|
1672
|
+
if ( this.mouseActions[ i ].mouse == action.mouse && this.mouseActions[ i ].key == action.key ) {
|
|
1673
|
+
|
|
1674
|
+
this.mouseActions.splice( i, 1, action );
|
|
1675
|
+
return true;
|
|
1676
|
+
|
|
1677
|
+
}
|
|
1678
|
+
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
this.mouseActions.push( action );
|
|
1682
|
+
return true;
|
|
1683
|
+
|
|
1684
|
+
};
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* Remove a mouse action by specifying its mouse/key combination
|
|
1688
|
+
* @param {*} mouse A mouse button (0, 1, 2) or 'WHEEL' for wheel notches
|
|
1689
|
+
* @param {*} key The keyboard modifier ('CTRL', 'SHIFT') or null if key is not needed
|
|
1690
|
+
* @returns {Boolean} True if the operation has been succesfully removed, false otherwise
|
|
1691
|
+
*/
|
|
1692
|
+
unsetMouseAction = ( mouse, key = null ) => {
|
|
1693
|
+
|
|
1694
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1695
|
+
|
|
1696
|
+
if ( this.mouseActions[ i ].mouse == mouse && this.mouseActions[ i ].key == key ) {
|
|
1697
|
+
|
|
1698
|
+
this.mouseActions.splice( i, 1 );
|
|
1699
|
+
return true;
|
|
1700
|
+
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return false;
|
|
1706
|
+
|
|
1707
|
+
};
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* Return the operation associated to a mouse/keyboard combination
|
|
1711
|
+
* @param {*} mouse A mouse button (0, 1, 2) or 'WHEEL' for wheel notches
|
|
1712
|
+
* @param {*} key The keyboard modifier ('CTRL', 'SHIFT') or null if key is not needed
|
|
1713
|
+
* @returns The operation if it has been found, null otherwise
|
|
1714
|
+
*/
|
|
1715
|
+
getOpFromAction = ( mouse, key ) => {
|
|
1716
|
+
|
|
1717
|
+
let action;
|
|
1718
|
+
|
|
1719
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1720
|
+
|
|
1721
|
+
action = this.mouseActions[ i ];
|
|
1722
|
+
if ( action.mouse == mouse && action.key == key ) {
|
|
1723
|
+
|
|
1724
|
+
return action.operation;
|
|
1725
|
+
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
if ( key != null ) {
|
|
1731
|
+
|
|
1732
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1733
|
+
|
|
1734
|
+
action = this.mouseActions[ i ];
|
|
1735
|
+
if ( action.mouse == mouse && action.key == null ) {
|
|
1736
|
+
|
|
1737
|
+
return action.operation;
|
|
1738
|
+
|
|
1739
|
+
}
|
|
1740
|
+
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
return null;
|
|
1746
|
+
|
|
1747
|
+
};
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Get the operation associated to mouse and key combination and returns the corresponding FSA state
|
|
1751
|
+
* @param {Number} mouse Mouse button
|
|
1752
|
+
* @param {String} key Keyboard modifier
|
|
1753
|
+
* @returns The FSA state obtained from the operation associated to mouse/keyboard combination
|
|
1754
|
+
*/
|
|
1755
|
+
getOpStateFromAction = ( mouse, key ) => {
|
|
1756
|
+
|
|
1757
|
+
let action;
|
|
1758
|
+
|
|
1759
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1760
|
+
|
|
1761
|
+
action = this.mouseActions[ i ];
|
|
1762
|
+
if ( action.mouse == mouse && action.key == key ) {
|
|
1763
|
+
|
|
1764
|
+
return action.state;
|
|
1765
|
+
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
if ( key != null ) {
|
|
1771
|
+
|
|
1772
|
+
for ( let i = 0; i < this.mouseActions.length; i ++ ) {
|
|
1773
|
+
|
|
1774
|
+
action = this.mouseActions[ i ];
|
|
1775
|
+
if ( action.mouse == mouse && action.key == null ) {
|
|
1776
|
+
|
|
1777
|
+
return action.state;
|
|
1778
|
+
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
return null;
|
|
1786
|
+
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* Calculate the angle between two pointers
|
|
1791
|
+
* @param {PointerEvent} p1
|
|
1792
|
+
* @param {PointerEvent} p2
|
|
1793
|
+
* @returns {Number} The angle between two pointers in degrees
|
|
1794
|
+
*/
|
|
1795
|
+
getAngle = ( p1, p2 ) => {
|
|
1796
|
+
|
|
1797
|
+
return Math.atan2( p2.clientY - p1.clientY, p2.clientX - p1.clientX ) * 180 / Math.PI;
|
|
1798
|
+
|
|
1799
|
+
};
|
|
1800
|
+
|
|
1801
|
+
/**
|
|
1802
|
+
* Update a PointerEvent inside current pointerevents array
|
|
1803
|
+
* @param {PointerEvent} event
|
|
1804
|
+
*/
|
|
1805
|
+
updateTouchEvent = ( event ) => {
|
|
1806
|
+
|
|
1807
|
+
for ( let i = 0; i < this._touchCurrent.length; i ++ ) {
|
|
1808
|
+
|
|
1809
|
+
if ( this._touchCurrent[ i ].pointerId == event.pointerId ) {
|
|
1810
|
+
|
|
1811
|
+
this._touchCurrent.splice( i, 1, event );
|
|
1812
|
+
break;
|
|
1813
|
+
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* Apply a transformation matrix, to the camera and gizmos
|
|
1822
|
+
* @param {Object} transformation Object containing matrices to apply to camera and gizmos
|
|
1823
|
+
*/
|
|
1824
|
+
applyTransformMatrix( transformation ) {
|
|
1825
|
+
|
|
1826
|
+
if ( transformation.camera != null ) {
|
|
1827
|
+
|
|
1828
|
+
this._m4_1.copy( this._cameraMatrixState ).premultiply( transformation.camera );
|
|
1829
|
+
this._m4_1.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
|
|
1830
|
+
this.camera.updateMatrix();
|
|
1831
|
+
|
|
1832
|
+
//update camera up vector
|
|
1833
|
+
if ( this._state == STATE.ROTATE || this._state == STATE.ZROTATE || this._state == STATE.ANIMATION_ROTATE ) {
|
|
1834
|
+
|
|
1835
|
+
this.camera.up.copy( this._upState ).applyQuaternion( this.camera.quaternion );
|
|
1836
|
+
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
if ( transformation.gizmos != null ) {
|
|
1842
|
+
|
|
1843
|
+
this._m4_1.copy( this._gizmoMatrixState ).premultiply( transformation.gizmos );
|
|
1844
|
+
this._m4_1.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
1845
|
+
this._gizmos.updateMatrix();
|
|
1846
|
+
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1849
|
+
if ( this._state == STATE.SCALE || this._state == STATE.FOCUS || this._state == STATE.ANIMATION_FOCUS ) {
|
|
1850
|
+
|
|
1851
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
1852
|
+
|
|
1853
|
+
if ( this.adjustNearFar ) {
|
|
1854
|
+
|
|
1855
|
+
const cameraDistance = this.camera.position.distanceTo( this._gizmos.position );
|
|
1856
|
+
|
|
1857
|
+
const bb = new Box3();
|
|
1858
|
+
bb.setFromObject( this._gizmos );
|
|
1859
|
+
const sphere = new Sphere();
|
|
1860
|
+
bb.getBoundingSphere( sphere );
|
|
1861
|
+
|
|
1862
|
+
const adjustedNearPosition = Math.max( this._nearPos0, sphere.radius + sphere.center.length() );
|
|
1863
|
+
const regularNearPosition = cameraDistance - this._initialNear;
|
|
1864
|
+
|
|
1865
|
+
const minNearPos = Math.min( adjustedNearPosition, regularNearPosition );
|
|
1866
|
+
this.camera.near = cameraDistance - minNearPos;
|
|
1867
|
+
|
|
1868
|
+
|
|
1869
|
+
const adjustedFarPosition = Math.min( this._farPos0, - sphere.radius + sphere.center.length() );
|
|
1870
|
+
const regularFarPosition = cameraDistance - this._initialFar;
|
|
1871
|
+
|
|
1872
|
+
const minFarPos = Math.min( adjustedFarPosition, regularFarPosition );
|
|
1873
|
+
this.camera.far = cameraDistance - minFarPos;
|
|
1874
|
+
|
|
1875
|
+
this.camera.updateProjectionMatrix();
|
|
1876
|
+
|
|
1877
|
+
} else {
|
|
1878
|
+
|
|
1879
|
+
let update = false;
|
|
1880
|
+
|
|
1881
|
+
if ( this.camera.near != this._initialNear ) {
|
|
1882
|
+
|
|
1883
|
+
this.camera.near = this._initialNear;
|
|
1884
|
+
update = true;
|
|
1885
|
+
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
if ( this.camera.far != this._initialFar ) {
|
|
1889
|
+
|
|
1890
|
+
this.camera.far = this._initialFar;
|
|
1891
|
+
update = true;
|
|
1892
|
+
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
if ( update ) {
|
|
1896
|
+
|
|
1897
|
+
this.camera.updateProjectionMatrix();
|
|
1898
|
+
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
}
|
|
1904
|
+
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
/**
|
|
1908
|
+
* Calculate the angular speed
|
|
1909
|
+
* @param {Number} p0 Position at t0
|
|
1910
|
+
* @param {Number} p1 Position at t1
|
|
1911
|
+
* @param {Number} t0 Initial time in milliseconds
|
|
1912
|
+
* @param {Number} t1 Ending time in milliseconds
|
|
1913
|
+
*/
|
|
1914
|
+
calculateAngularSpeed = ( p0, p1, t0, t1 ) => {
|
|
1915
|
+
|
|
1916
|
+
const s = p1 - p0;
|
|
1917
|
+
const t = ( t1 - t0 ) / 1000;
|
|
1918
|
+
if ( t == 0 ) {
|
|
1919
|
+
|
|
1920
|
+
return 0;
|
|
1921
|
+
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
return s / t;
|
|
1925
|
+
|
|
1926
|
+
};
|
|
1927
|
+
|
|
1928
|
+
/**
|
|
1929
|
+
* Calculate the distance between two pointers
|
|
1930
|
+
* @param {PointerEvent} p0 The first pointer
|
|
1931
|
+
* @param {PointerEvent} p1 The second pointer
|
|
1932
|
+
* @returns {number} The distance between the two pointers
|
|
1933
|
+
*/
|
|
1934
|
+
calculatePointersDistance = ( p0, p1 ) => {
|
|
1935
|
+
|
|
1936
|
+
return Math.sqrt( Math.pow( p1.clientX - p0.clientX, 2 ) + Math.pow( p1.clientY - p0.clientY, 2 ) );
|
|
1937
|
+
|
|
1938
|
+
};
|
|
1939
|
+
|
|
1940
|
+
/**
|
|
1941
|
+
* Calculate the rotation axis as the vector perpendicular between two vectors
|
|
1942
|
+
* @param {Vector3} vec1 The first vector
|
|
1943
|
+
* @param {Vector3} vec2 The second vector
|
|
1944
|
+
* @returns {Vector3} The normalized rotation axis
|
|
1945
|
+
*/
|
|
1946
|
+
calculateRotationAxis = ( vec1, vec2 ) => {
|
|
1947
|
+
|
|
1948
|
+
this._rotationMatrix.extractRotation( this._cameraMatrixState );
|
|
1949
|
+
this._quat.setFromRotationMatrix( this._rotationMatrix );
|
|
1950
|
+
|
|
1951
|
+
this._rotationAxis.crossVectors( vec1, vec2 ).applyQuaternion( this._quat );
|
|
1952
|
+
return this._rotationAxis.normalize().clone();
|
|
1953
|
+
|
|
1954
|
+
};
|
|
1955
|
+
|
|
1956
|
+
/**
|
|
1957
|
+
* Calculate the trackball radius so that gizmo's diamater will be 2/3 of the minimum side of the camera frustum
|
|
1958
|
+
* @param {Camera} camera
|
|
1959
|
+
* @returns {Number} The trackball radius
|
|
1960
|
+
*/
|
|
1961
|
+
calculateTbRadius = ( camera ) => {
|
|
1962
|
+
|
|
1963
|
+
const distance = camera.position.distanceTo( this._gizmos.position );
|
|
1964
|
+
|
|
1965
|
+
if ( camera.type == 'PerspectiveCamera' ) {
|
|
1966
|
+
|
|
1967
|
+
const halfFovV = MathUtils.DEG2RAD * camera.fov * 0.5; //vertical fov/2 in radians
|
|
1968
|
+
const halfFovH = Math.atan( ( camera.aspect ) * Math.tan( halfFovV ) ); //horizontal fov/2 in radians
|
|
1969
|
+
return Math.tan( Math.min( halfFovV, halfFovH ) ) * distance * this.radiusFactor;
|
|
1970
|
+
|
|
1971
|
+
} else if ( camera.type == 'OrthographicCamera' ) {
|
|
1972
|
+
|
|
1973
|
+
return Math.min( camera.top, camera.right ) * this.radiusFactor;
|
|
1974
|
+
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1979
|
+
/**
|
|
1980
|
+
* Focus operation consist of positioning the point of interest in front of the camera and a slightly zoom in
|
|
1981
|
+
* @param {Vector3} point The point of interest
|
|
1982
|
+
* @param {Number} size Scale factor
|
|
1983
|
+
* @param {Number} amount Amount of operation to be completed (used for focus animations, default is complete full operation)
|
|
1984
|
+
*/
|
|
1985
|
+
focus = ( point, size, amount = 1 ) => {
|
|
1986
|
+
|
|
1987
|
+
//move center of camera (along with gizmos) towards point of interest
|
|
1988
|
+
_offset.copy( point ).sub( this._gizmos.position ).multiplyScalar( amount );
|
|
1989
|
+
this._translationMatrix.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
1990
|
+
|
|
1991
|
+
_gizmoMatrixStateTemp.copy( this._gizmoMatrixState );
|
|
1992
|
+
this._gizmoMatrixState.premultiply( this._translationMatrix );
|
|
1993
|
+
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
1994
|
+
|
|
1995
|
+
_cameraMatrixStateTemp.copy( this._cameraMatrixState );
|
|
1996
|
+
this._cameraMatrixState.premultiply( this._translationMatrix );
|
|
1997
|
+
this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
|
|
1998
|
+
|
|
1999
|
+
//apply zoom
|
|
2000
|
+
if ( this.enableZoom ) {
|
|
2001
|
+
|
|
2002
|
+
this.applyTransformMatrix( this.scale( size, this._gizmos.position ) );
|
|
2003
|
+
|
|
2004
|
+
}
|
|
2005
|
+
|
|
2006
|
+
this._gizmoMatrixState.copy( _gizmoMatrixStateTemp );
|
|
2007
|
+
this._cameraMatrixState.copy( _cameraMatrixStateTemp );
|
|
2008
|
+
|
|
2009
|
+
};
|
|
2010
|
+
|
|
2011
|
+
/**
|
|
2012
|
+
* Draw a grid and add it to the scene
|
|
2013
|
+
*/
|
|
2014
|
+
drawGrid = () => {
|
|
2015
|
+
|
|
2016
|
+
if ( this.scene != null ) {
|
|
2017
|
+
|
|
2018
|
+
const color = 0x888888;
|
|
2019
|
+
const multiplier = 3;
|
|
2020
|
+
let size, divisions, maxLength, tick;
|
|
2021
|
+
|
|
2022
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
2023
|
+
|
|
2024
|
+
const width = this.camera.right - this.camera.left;
|
|
2025
|
+
const height = this.camera.bottom - this.camera.top;
|
|
2026
|
+
|
|
2027
|
+
maxLength = Math.max( width, height );
|
|
2028
|
+
tick = maxLength / 20;
|
|
2029
|
+
|
|
2030
|
+
size = maxLength / this.camera.zoom * multiplier;
|
|
2031
|
+
divisions = size / tick * this.camera.zoom;
|
|
2032
|
+
|
|
2033
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
2034
|
+
|
|
2035
|
+
const distance = this.camera.position.distanceTo( this._gizmos.position );
|
|
2036
|
+
const halfFovV = MathUtils.DEG2RAD * this.camera.fov * 0.5;
|
|
2037
|
+
const halfFovH = Math.atan( ( this.camera.aspect ) * Math.tan( halfFovV ) );
|
|
2038
|
+
|
|
2039
|
+
maxLength = Math.tan( Math.max( halfFovV, halfFovH ) ) * distance * 2;
|
|
2040
|
+
tick = maxLength / 20;
|
|
2041
|
+
|
|
2042
|
+
size = maxLength * multiplier;
|
|
2043
|
+
divisions = size / tick;
|
|
2044
|
+
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
if ( this._grid == null ) {
|
|
2048
|
+
|
|
2049
|
+
this._grid = new GridHelper( size, divisions, color, color );
|
|
2050
|
+
this._grid.position.copy( this._gizmos.position );
|
|
2051
|
+
this._gridPosition.copy( this._grid.position );
|
|
2052
|
+
this._grid.quaternion.copy( this.camera.quaternion );
|
|
2053
|
+
this._grid.rotateX( Math.PI * 0.5 );
|
|
2054
|
+
|
|
2055
|
+
this.scene.add( this._grid );
|
|
2056
|
+
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Remove all listeners, stop animations and clean scene
|
|
2065
|
+
*/
|
|
2066
|
+
dispose = () => {
|
|
2067
|
+
|
|
2068
|
+
if ( this._animationId != - 1 ) {
|
|
2069
|
+
|
|
2070
|
+
window.cancelAnimationFrame( this._animationId );
|
|
2071
|
+
|
|
2072
|
+
}
|
|
2073
|
+
|
|
2074
|
+
this.domElement.removeEventListener( 'pointerdown', this.onPointerDown );
|
|
2075
|
+
this.domElement.removeEventListener( 'pointercancel', this.onPointerCancel );
|
|
2076
|
+
this.domElement.removeEventListener( 'wheel', this.onWheel );
|
|
2077
|
+
this.domElement.removeEventListener( 'contextmenu', this.onContextMenu );
|
|
2078
|
+
|
|
2079
|
+
window.removeEventListener( 'pointermove', this.onPointerMove );
|
|
2080
|
+
window.removeEventListener( 'pointerup', this.onPointerUp );
|
|
2081
|
+
|
|
2082
|
+
window.removeEventListener( 'resize', this.onWindowResize );
|
|
2083
|
+
|
|
2084
|
+
if ( this.scene !== null ) this.scene.remove( this._gizmos );
|
|
2085
|
+
this.disposeGrid();
|
|
2086
|
+
|
|
2087
|
+
};
|
|
2088
|
+
|
|
2089
|
+
/**
|
|
2090
|
+
* remove the grid from the scene
|
|
2091
|
+
*/
|
|
2092
|
+
disposeGrid = () => {
|
|
2093
|
+
|
|
2094
|
+
if ( this._grid != null && this.scene != null ) {
|
|
2095
|
+
|
|
2096
|
+
this.scene.remove( this._grid );
|
|
2097
|
+
this._grid = null;
|
|
2098
|
+
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2103
|
+
/**
|
|
2104
|
+
* Compute the easing out cubic function for ease out effect in animation
|
|
2105
|
+
* @param {Number} t The absolute progress of the animation in the bound of 0 (beginning of the) and 1 (ending of animation)
|
|
2106
|
+
* @returns {Number} Result of easing out cubic at time t
|
|
2107
|
+
*/
|
|
2108
|
+
easeOutCubic = ( t ) => {
|
|
2109
|
+
|
|
2110
|
+
return 1 - Math.pow( 1 - t, 3 );
|
|
2111
|
+
|
|
2112
|
+
};
|
|
2113
|
+
|
|
2114
|
+
/**
|
|
2115
|
+
* Make rotation gizmos more or less visible
|
|
2116
|
+
* @param {Boolean} isActive If true, make gizmos more visible
|
|
2117
|
+
*/
|
|
2118
|
+
activateGizmos = ( isActive ) => {
|
|
2119
|
+
|
|
2120
|
+
const gizmoX = this._gizmos.children[ 0 ];
|
|
2121
|
+
const gizmoY = this._gizmos.children[ 1 ];
|
|
2122
|
+
const gizmoZ = this._gizmos.children[ 2 ];
|
|
2123
|
+
|
|
2124
|
+
if ( isActive ) {
|
|
2125
|
+
|
|
2126
|
+
gizmoX.material.setValues( { opacity: 1 } );
|
|
2127
|
+
gizmoY.material.setValues( { opacity: 1 } );
|
|
2128
|
+
gizmoZ.material.setValues( { opacity: 1 } );
|
|
2129
|
+
|
|
2130
|
+
} else {
|
|
2131
|
+
|
|
2132
|
+
gizmoX.material.setValues( { opacity: 0.6 } );
|
|
2133
|
+
gizmoY.material.setValues( { opacity: 0.6 } );
|
|
2134
|
+
gizmoZ.material.setValues( { opacity: 0.6 } );
|
|
2135
|
+
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
};
|
|
2139
|
+
|
|
2140
|
+
/**
|
|
2141
|
+
* Calculate the cursor position in NDC
|
|
2142
|
+
* @param {number} x Cursor horizontal coordinate within the canvas
|
|
2143
|
+
* @param {number} y Cursor vertical coordinate within the canvas
|
|
2144
|
+
* @param {HTMLElement} canvas The canvas where the renderer draws its output
|
|
2145
|
+
* @returns {Vector2} Cursor normalized position inside the canvas
|
|
2146
|
+
*/
|
|
2147
|
+
getCursorNDC = ( cursorX, cursorY, canvas ) => {
|
|
2148
|
+
|
|
2149
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
2150
|
+
this._v2_1.setX( ( ( cursorX - canvasRect.left ) / canvasRect.width ) * 2 - 1 );
|
|
2151
|
+
this._v2_1.setY( ( ( canvasRect.bottom - cursorY ) / canvasRect.height ) * 2 - 1 );
|
|
2152
|
+
return this._v2_1.clone();
|
|
2153
|
+
|
|
2154
|
+
};
|
|
2155
|
+
|
|
2156
|
+
/**
|
|
2157
|
+
* Calculate the cursor position inside the canvas x/y coordinates with the origin being in the center of the canvas
|
|
2158
|
+
* @param {Number} x Cursor horizontal coordinate within the canvas
|
|
2159
|
+
* @param {Number} y Cursor vertical coordinate within the canvas
|
|
2160
|
+
* @param {HTMLElement} canvas The canvas where the renderer draws its output
|
|
2161
|
+
* @returns {Vector2} Cursor position inside the canvas
|
|
2162
|
+
*/
|
|
2163
|
+
getCursorPosition = ( cursorX, cursorY, canvas ) => {
|
|
2164
|
+
|
|
2165
|
+
this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
|
|
2166
|
+
this._v2_1.x *= ( this.camera.right - this.camera.left ) * 0.5;
|
|
2167
|
+
this._v2_1.y *= ( this.camera.top - this.camera.bottom ) * 0.5;
|
|
2168
|
+
return this._v2_1.clone();
|
|
2169
|
+
|
|
2170
|
+
};
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* Set the camera to be controlled
|
|
2174
|
+
* @param {Camera} camera The virtual camera to be controlled
|
|
2175
|
+
*/
|
|
2176
|
+
setCamera = ( camera ) => {
|
|
2177
|
+
|
|
2178
|
+
camera.lookAt( this.target );
|
|
2179
|
+
camera.updateMatrix();
|
|
2180
|
+
|
|
2181
|
+
//setting state
|
|
2182
|
+
if ( camera.type == 'PerspectiveCamera' ) {
|
|
2183
|
+
|
|
2184
|
+
this._fov0 = camera.fov;
|
|
2185
|
+
this._fovState = camera.fov;
|
|
2186
|
+
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
this._cameraMatrixState0.copy( camera.matrix );
|
|
2190
|
+
this._cameraMatrixState.copy( this._cameraMatrixState0 );
|
|
2191
|
+
this._cameraProjectionState.copy( camera.projectionMatrix );
|
|
2192
|
+
this._zoom0 = camera.zoom;
|
|
2193
|
+
this._zoomState = this._zoom0;
|
|
2194
|
+
|
|
2195
|
+
this._initialNear = camera.near;
|
|
2196
|
+
this._nearPos0 = camera.position.distanceTo( this.target ) - camera.near;
|
|
2197
|
+
this._nearPos = this._initialNear;
|
|
2198
|
+
|
|
2199
|
+
this._initialFar = camera.far;
|
|
2200
|
+
this._farPos0 = camera.position.distanceTo( this.target ) - camera.far;
|
|
2201
|
+
this._farPos = this._initialFar;
|
|
2202
|
+
|
|
2203
|
+
this._up0.copy( camera.up );
|
|
2204
|
+
this._upState.copy( camera.up );
|
|
2205
|
+
|
|
2206
|
+
this.camera = camera;
|
|
2207
|
+
this.camera.updateProjectionMatrix();
|
|
2208
|
+
|
|
2209
|
+
//making gizmos
|
|
2210
|
+
this._tbRadius = this.calculateTbRadius( camera );
|
|
2211
|
+
this.makeGizmos( this.target, this._tbRadius );
|
|
2212
|
+
|
|
2213
|
+
};
|
|
2214
|
+
|
|
2215
|
+
/**
|
|
2216
|
+
* Set gizmos visibility
|
|
2217
|
+
* @param {Boolean} value Value of gizmos visibility
|
|
2218
|
+
*/
|
|
2219
|
+
setGizmosVisible( value ) {
|
|
2220
|
+
|
|
2221
|
+
this._gizmos.visible = value;
|
|
2222
|
+
this.dispatchEvent( _changeEvent );
|
|
2223
|
+
|
|
2224
|
+
}
|
|
2225
|
+
|
|
2226
|
+
/**
|
|
2227
|
+
* Set gizmos radius factor and redraws gizmos
|
|
2228
|
+
* @param {Float} value Value of radius factor
|
|
2229
|
+
*/
|
|
2230
|
+
setTbRadius( value ) {
|
|
2231
|
+
|
|
2232
|
+
this.radiusFactor = value;
|
|
2233
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
2234
|
+
|
|
2235
|
+
const curve = new EllipseCurve( 0, 0, this._tbRadius, this._tbRadius );
|
|
2236
|
+
const points = curve.getPoints( this._curvePts );
|
|
2237
|
+
const curveGeometry = new BufferGeometry().setFromPoints( points );
|
|
2238
|
+
|
|
2239
|
+
|
|
2240
|
+
for ( const gizmo in this._gizmos.children ) {
|
|
2241
|
+
|
|
2242
|
+
this._gizmos.children[ gizmo ].geometry = curveGeometry;
|
|
2243
|
+
|
|
2244
|
+
}
|
|
2245
|
+
|
|
2246
|
+
this.dispatchEvent( _changeEvent );
|
|
2247
|
+
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* Creates the rotation gizmos matching trackball center and radius
|
|
2252
|
+
* @param {Vector3} tbCenter The trackball center
|
|
2253
|
+
* @param {number} tbRadius The trackball radius
|
|
2254
|
+
*/
|
|
2255
|
+
makeGizmos = ( tbCenter, tbRadius ) => {
|
|
2256
|
+
|
|
2257
|
+
const curve = new EllipseCurve( 0, 0, tbRadius, tbRadius );
|
|
2258
|
+
const points = curve.getPoints( this._curvePts );
|
|
2259
|
+
|
|
2260
|
+
//geometry
|
|
2261
|
+
const curveGeometry = new BufferGeometry().setFromPoints( points );
|
|
2262
|
+
|
|
2263
|
+
//material
|
|
2264
|
+
const curveMaterialX = new LineBasicMaterial( { color: 0xff8080, fog: false, transparent: true, opacity: 0.6 } );
|
|
2265
|
+
const curveMaterialY = new LineBasicMaterial( { color: 0x80ff80, fog: false, transparent: true, opacity: 0.6 } );
|
|
2266
|
+
const curveMaterialZ = new LineBasicMaterial( { color: 0x8080ff, fog: false, transparent: true, opacity: 0.6 } );
|
|
2267
|
+
|
|
2268
|
+
//line
|
|
2269
|
+
const gizmoX = new Line( curveGeometry, curveMaterialX );
|
|
2270
|
+
const gizmoY = new Line( curveGeometry, curveMaterialY );
|
|
2271
|
+
const gizmoZ = new Line( curveGeometry, curveMaterialZ );
|
|
2272
|
+
|
|
2273
|
+
const rotation = Math.PI * 0.5;
|
|
2274
|
+
gizmoX.rotation.x = rotation;
|
|
2275
|
+
gizmoY.rotation.y = rotation;
|
|
2276
|
+
|
|
2277
|
+
|
|
2278
|
+
//setting state
|
|
2279
|
+
this._gizmoMatrixState0.identity().setPosition( tbCenter );
|
|
2280
|
+
this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
|
|
2281
|
+
|
|
2282
|
+
if ( this.camera.zoom !== 1 ) {
|
|
2283
|
+
|
|
2284
|
+
//adapt gizmos size to camera zoom
|
|
2285
|
+
const size = 1 / this.camera.zoom;
|
|
2286
|
+
this._scaleMatrix.makeScale( size, size, size );
|
|
2287
|
+
this._translationMatrix.makeTranslation( - tbCenter.x, - tbCenter.y, - tbCenter.z );
|
|
2288
|
+
|
|
2289
|
+
this._gizmoMatrixState.premultiply( this._translationMatrix ).premultiply( this._scaleMatrix );
|
|
2290
|
+
this._translationMatrix.makeTranslation( tbCenter.x, tbCenter.y, tbCenter.z );
|
|
2291
|
+
this._gizmoMatrixState.premultiply( this._translationMatrix );
|
|
2292
|
+
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
2296
|
+
|
|
2297
|
+
//
|
|
2298
|
+
|
|
2299
|
+
this._gizmos.traverse( function ( object ) {
|
|
2300
|
+
|
|
2301
|
+
if ( object.isLine ) {
|
|
2302
|
+
|
|
2303
|
+
object.geometry.dispose();
|
|
2304
|
+
object.material.dispose();
|
|
2305
|
+
|
|
2306
|
+
}
|
|
2307
|
+
|
|
2308
|
+
} );
|
|
2309
|
+
|
|
2310
|
+
this._gizmos.clear();
|
|
2311
|
+
|
|
2312
|
+
//
|
|
2313
|
+
|
|
2314
|
+
this._gizmos.add( gizmoX );
|
|
2315
|
+
this._gizmos.add( gizmoY );
|
|
2316
|
+
this._gizmos.add( gizmoZ );
|
|
2317
|
+
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
/**
|
|
2321
|
+
* Perform animation for focus operation
|
|
2322
|
+
* @param {Number} time Instant in which this function is called as performance.now()
|
|
2323
|
+
* @param {Vector3} point Point of interest for focus operation
|
|
2324
|
+
* @param {Matrix4} cameraMatrix Camera matrix
|
|
2325
|
+
* @param {Matrix4} gizmoMatrix Gizmos matrix
|
|
2326
|
+
*/
|
|
2327
|
+
onFocusAnim = ( time, point, cameraMatrix, gizmoMatrix ) => {
|
|
2328
|
+
|
|
2329
|
+
if ( this._timeStart == - 1 ) {
|
|
2330
|
+
|
|
2331
|
+
//animation start
|
|
2332
|
+
this._timeStart = time;
|
|
2333
|
+
|
|
2334
|
+
}
|
|
2335
|
+
|
|
2336
|
+
if ( this._state == STATE.ANIMATION_FOCUS ) {
|
|
2337
|
+
|
|
2338
|
+
const deltaTime = time - this._timeStart;
|
|
2339
|
+
const animTime = deltaTime / this.focusAnimationTime;
|
|
2340
|
+
|
|
2341
|
+
this._gizmoMatrixState.copy( gizmoMatrix );
|
|
2342
|
+
|
|
2343
|
+
if ( animTime >= 1 ) {
|
|
2344
|
+
|
|
2345
|
+
//animation end
|
|
2346
|
+
|
|
2347
|
+
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
2348
|
+
|
|
2349
|
+
this.focus( point, this.scaleFactor );
|
|
2350
|
+
|
|
2351
|
+
this._timeStart = - 1;
|
|
2352
|
+
this.updateTbState( STATE.IDLE, false );
|
|
2353
|
+
this.activateGizmos( false );
|
|
2354
|
+
|
|
2355
|
+
this.dispatchEvent( _changeEvent );
|
|
2356
|
+
|
|
2357
|
+
} else {
|
|
2358
|
+
|
|
2359
|
+
const amount = this.easeOutCubic( animTime );
|
|
2360
|
+
const size = ( ( 1 - amount ) + ( this.scaleFactor * amount ) );
|
|
2361
|
+
|
|
2362
|
+
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
2363
|
+
this.focus( point, size, amount );
|
|
2364
|
+
|
|
2365
|
+
this.dispatchEvent( _changeEvent );
|
|
2366
|
+
const self = this;
|
|
2367
|
+
this._animationId = window.requestAnimationFrame( function ( t ) {
|
|
2368
|
+
|
|
2369
|
+
self.onFocusAnim( t, point, cameraMatrix, gizmoMatrix.clone() );
|
|
2370
|
+
|
|
2371
|
+
} );
|
|
2372
|
+
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
} else {
|
|
2376
|
+
|
|
2377
|
+
//interrupt animation
|
|
2378
|
+
|
|
2379
|
+
this._animationId = - 1;
|
|
2380
|
+
this._timeStart = - 1;
|
|
2381
|
+
|
|
2382
|
+
}
|
|
2383
|
+
|
|
2384
|
+
};
|
|
2385
|
+
|
|
2386
|
+
/**
|
|
2387
|
+
* Perform animation for rotation operation
|
|
2388
|
+
* @param {Number} time Instant in which this function is called as performance.now()
|
|
2389
|
+
* @param {Vector3} rotationAxis Rotation axis
|
|
2390
|
+
* @param {number} w0 Initial angular velocity
|
|
2391
|
+
*/
|
|
2392
|
+
onRotationAnim = ( time, rotationAxis, w0 ) => {
|
|
2393
|
+
|
|
2394
|
+
if ( this._timeStart == - 1 ) {
|
|
2395
|
+
|
|
2396
|
+
//animation start
|
|
2397
|
+
this._anglePrev = 0;
|
|
2398
|
+
this._angleCurrent = 0;
|
|
2399
|
+
this._timeStart = time;
|
|
2400
|
+
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
if ( this._state == STATE.ANIMATION_ROTATE ) {
|
|
2404
|
+
|
|
2405
|
+
//w = w0 + alpha * t
|
|
2406
|
+
const deltaTime = ( time - this._timeStart ) / 1000;
|
|
2407
|
+
const w = w0 + ( ( - this.dampingFactor ) * deltaTime );
|
|
2408
|
+
|
|
2409
|
+
if ( w > 0 ) {
|
|
2410
|
+
|
|
2411
|
+
//tetha = 0.5 * alpha * t^2 + w0 * t + tetha0
|
|
2412
|
+
this._angleCurrent = 0.5 * ( - this.dampingFactor ) * Math.pow( deltaTime, 2 ) + w0 * deltaTime + 0;
|
|
2413
|
+
this.applyTransformMatrix( this.rotate( rotationAxis, this._angleCurrent ) );
|
|
2414
|
+
this.dispatchEvent( _changeEvent );
|
|
2415
|
+
const self = this;
|
|
2416
|
+
this._animationId = window.requestAnimationFrame( function ( t ) {
|
|
2417
|
+
|
|
2418
|
+
self.onRotationAnim( t, rotationAxis, w0 );
|
|
2419
|
+
|
|
2420
|
+
} );
|
|
2421
|
+
|
|
2422
|
+
} else {
|
|
2423
|
+
|
|
2424
|
+
this._animationId = - 1;
|
|
2425
|
+
this._timeStart = - 1;
|
|
2426
|
+
|
|
2427
|
+
this.updateTbState( STATE.IDLE, false );
|
|
2428
|
+
this.activateGizmos( false );
|
|
2429
|
+
|
|
2430
|
+
this.dispatchEvent( _changeEvent );
|
|
2431
|
+
|
|
2432
|
+
}
|
|
2433
|
+
|
|
2434
|
+
} else {
|
|
2435
|
+
|
|
2436
|
+
//interrupt animation
|
|
2437
|
+
|
|
2438
|
+
this._animationId = - 1;
|
|
2439
|
+
this._timeStart = - 1;
|
|
2440
|
+
|
|
2441
|
+
if ( this._state != STATE.ROTATE ) {
|
|
2442
|
+
|
|
2443
|
+
this.activateGizmos( false );
|
|
2444
|
+
this.dispatchEvent( _changeEvent );
|
|
2445
|
+
|
|
2446
|
+
}
|
|
2447
|
+
|
|
2448
|
+
}
|
|
2449
|
+
|
|
2450
|
+
};
|
|
2451
|
+
|
|
2452
|
+
|
|
2453
|
+
/**
|
|
2454
|
+
* Perform pan operation moving camera between two points
|
|
2455
|
+
* @param {Vector3} p0 Initial point
|
|
2456
|
+
* @param {Vector3} p1 Ending point
|
|
2457
|
+
* @param {Boolean} adjust If movement should be adjusted considering camera distance (Perspective only)
|
|
2458
|
+
*/
|
|
2459
|
+
pan = ( p0, p1, adjust = false ) => {
|
|
2460
|
+
|
|
2461
|
+
const movement = p0.clone().sub( p1 );
|
|
2462
|
+
|
|
2463
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
2464
|
+
|
|
2465
|
+
//adjust movement amount
|
|
2466
|
+
movement.multiplyScalar( 1 / this.camera.zoom );
|
|
2467
|
+
|
|
2468
|
+
} else if ( this.camera.isPerspectiveCamera && adjust ) {
|
|
2469
|
+
|
|
2470
|
+
//adjust movement amount
|
|
2471
|
+
this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ); //camera's initial position
|
|
2472
|
+
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ); //gizmo's initial position
|
|
2473
|
+
const distanceFactor = this._v3_1.distanceTo( this._v3_2 ) / this.camera.position.distanceTo( this._gizmos.position );
|
|
2474
|
+
movement.multiplyScalar( 1 / distanceFactor );
|
|
2475
|
+
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
this._v3_1.set( movement.x, movement.y, 0 ).applyQuaternion( this.camera.quaternion );
|
|
2479
|
+
|
|
2480
|
+
this._m4_1.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z );
|
|
2481
|
+
|
|
2482
|
+
this.setTransformationMatrices( this._m4_1, this._m4_1 );
|
|
2483
|
+
return _transformation;
|
|
2484
|
+
|
|
2485
|
+
};
|
|
2486
|
+
|
|
2487
|
+
/**
|
|
2488
|
+
* Reset trackball
|
|
2489
|
+
*/
|
|
2490
|
+
reset = () => {
|
|
2491
|
+
|
|
2492
|
+
this.camera.zoom = this._zoom0;
|
|
2493
|
+
|
|
2494
|
+
if ( this.camera.isPerspectiveCamera ) {
|
|
2495
|
+
|
|
2496
|
+
this.camera.fov = this._fov0;
|
|
2497
|
+
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
this.camera.near = this._nearPos;
|
|
2501
|
+
this.camera.far = this._farPos;
|
|
2502
|
+
this._cameraMatrixState.copy( this._cameraMatrixState0 );
|
|
2503
|
+
this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
|
|
2504
|
+
this.camera.up.copy( this._up0 );
|
|
2505
|
+
|
|
2506
|
+
this.camera.updateMatrix();
|
|
2507
|
+
this.camera.updateProjectionMatrix();
|
|
2508
|
+
|
|
2509
|
+
this._gizmoMatrixState.copy( this._gizmoMatrixState0 );
|
|
2510
|
+
this._gizmoMatrixState0.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
2511
|
+
this._gizmos.updateMatrix();
|
|
2512
|
+
|
|
2513
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
2514
|
+
this.makeGizmos( this._gizmos.position, this._tbRadius );
|
|
2515
|
+
|
|
2516
|
+
this.camera.lookAt( this._gizmos.position );
|
|
2517
|
+
|
|
2518
|
+
this.updateTbState( STATE.IDLE, false );
|
|
2519
|
+
|
|
2520
|
+
this.dispatchEvent( _changeEvent );
|
|
2521
|
+
|
|
2522
|
+
};
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Rotate the camera around an axis passing by trackball's center
|
|
2526
|
+
* @param {Vector3} axis Rotation axis
|
|
2527
|
+
* @param {number} angle Angle in radians
|
|
2528
|
+
* @returns {Object} Object with 'camera' field containing transformation matrix resulting from the operation to be applied to the camera
|
|
2529
|
+
*/
|
|
2530
|
+
rotate = ( axis, angle ) => {
|
|
2531
|
+
|
|
2532
|
+
const point = this._gizmos.position; //rotation center
|
|
2533
|
+
this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
|
|
2534
|
+
this._rotationMatrix.makeRotationAxis( axis, - angle );
|
|
2535
|
+
|
|
2536
|
+
//rotate camera
|
|
2537
|
+
this._m4_1.makeTranslation( point.x, point.y, point.z );
|
|
2538
|
+
this._m4_1.multiply( this._rotationMatrix );
|
|
2539
|
+
this._m4_1.multiply( this._translationMatrix );
|
|
2540
|
+
|
|
2541
|
+
this.setTransformationMatrices( this._m4_1 );
|
|
2542
|
+
|
|
2543
|
+
return _transformation;
|
|
2544
|
+
|
|
2545
|
+
};
|
|
2546
|
+
|
|
2547
|
+
copyState = () => {
|
|
2548
|
+
|
|
2549
|
+
let state;
|
|
2550
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
2551
|
+
|
|
2552
|
+
state = JSON.stringify( { arcballState: {
|
|
2553
|
+
|
|
2554
|
+
cameraFar: this.camera.far,
|
|
2555
|
+
cameraMatrix: this.camera.matrix,
|
|
2556
|
+
cameraNear: this.camera.near,
|
|
2557
|
+
cameraUp: this.camera.up,
|
|
2558
|
+
cameraZoom: this.camera.zoom,
|
|
2559
|
+
gizmoMatrix: this._gizmos.matrix
|
|
2560
|
+
|
|
2561
|
+
} } );
|
|
2562
|
+
|
|
2563
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
2564
|
+
|
|
2565
|
+
state = JSON.stringify( { arcballState: {
|
|
2566
|
+
cameraFar: this.camera.far,
|
|
2567
|
+
cameraFov: this.camera.fov,
|
|
2568
|
+
cameraMatrix: this.camera.matrix,
|
|
2569
|
+
cameraNear: this.camera.near,
|
|
2570
|
+
cameraUp: this.camera.up,
|
|
2571
|
+
cameraZoom: this.camera.zoom,
|
|
2572
|
+
gizmoMatrix: this._gizmos.matrix
|
|
2573
|
+
|
|
2574
|
+
} } );
|
|
2575
|
+
|
|
2576
|
+
}
|
|
2577
|
+
|
|
2578
|
+
navigator.clipboard.writeText( state );
|
|
2579
|
+
|
|
2580
|
+
};
|
|
2581
|
+
|
|
2582
|
+
pasteState = () => {
|
|
2583
|
+
|
|
2584
|
+
const self = this;
|
|
2585
|
+
navigator.clipboard.readText().then( function resolved( value ) {
|
|
2586
|
+
|
|
2587
|
+
self.setStateFromJSON( value );
|
|
2588
|
+
|
|
2589
|
+
} );
|
|
2590
|
+
|
|
2591
|
+
};
|
|
2592
|
+
|
|
2593
|
+
/**
|
|
2594
|
+
* Save the current state of the control. This can later be recover with .reset
|
|
2595
|
+
*/
|
|
2596
|
+
saveState = () => {
|
|
2597
|
+
|
|
2598
|
+
this._cameraMatrixState0.copy( this.camera.matrix );
|
|
2599
|
+
this._gizmoMatrixState0.copy( this._gizmos.matrix );
|
|
2600
|
+
this._nearPos = this.camera.near;
|
|
2601
|
+
this._farPos = this.camera.far;
|
|
2602
|
+
this._zoom0 = this.camera.zoom;
|
|
2603
|
+
this._up0.copy( this.camera.up );
|
|
2604
|
+
|
|
2605
|
+
if ( this.camera.isPerspectiveCamera ) {
|
|
2606
|
+
|
|
2607
|
+
this._fov0 = this.camera.fov;
|
|
2608
|
+
|
|
2609
|
+
}
|
|
2610
|
+
|
|
2611
|
+
};
|
|
2612
|
+
|
|
2613
|
+
/**
|
|
2614
|
+
* Perform uniform scale operation around a given point
|
|
2615
|
+
* @param {Number} size Scale factor
|
|
2616
|
+
* @param {Vector3} point Point around which scale
|
|
2617
|
+
* @param {Boolean} scaleGizmos If gizmos should be scaled (Perspective only)
|
|
2618
|
+
* @returns {Object} Object with 'camera' and 'gizmo' fields containing transformation matrices resulting from the operation to be applied to the camera and gizmos
|
|
2619
|
+
*/
|
|
2620
|
+
scale = ( size, point, scaleGizmos = true ) => {
|
|
2621
|
+
|
|
2622
|
+
_scalePointTemp.copy( point );
|
|
2623
|
+
let sizeInverse = 1 / size;
|
|
2624
|
+
|
|
2625
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
2626
|
+
|
|
2627
|
+
//camera zoom
|
|
2628
|
+
this.camera.zoom = this._zoomState;
|
|
2629
|
+
this.camera.zoom *= size;
|
|
2630
|
+
|
|
2631
|
+
//check min and max zoom
|
|
2632
|
+
if ( this.camera.zoom > this.maxZoom ) {
|
|
2633
|
+
|
|
2634
|
+
this.camera.zoom = this.maxZoom;
|
|
2635
|
+
sizeInverse = this._zoomState / this.maxZoom;
|
|
2636
|
+
|
|
2637
|
+
} else if ( this.camera.zoom < this.minZoom ) {
|
|
2638
|
+
|
|
2639
|
+
this.camera.zoom = this.minZoom;
|
|
2640
|
+
sizeInverse = this._zoomState / this.minZoom;
|
|
2641
|
+
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
this.camera.updateProjectionMatrix();
|
|
2645
|
+
|
|
2646
|
+
this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ); //gizmos position
|
|
2647
|
+
|
|
2648
|
+
//scale gizmos so they appear in the same spot having the same dimension
|
|
2649
|
+
this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
|
|
2650
|
+
this._translationMatrix.makeTranslation( - this._v3_1.x, - this._v3_1.y, - this._v3_1.z );
|
|
2651
|
+
|
|
2652
|
+
this._m4_2.makeTranslation( this._v3_1.x, this._v3_1.y, this._v3_1.z ).multiply( this._scaleMatrix );
|
|
2653
|
+
this._m4_2.multiply( this._translationMatrix );
|
|
2654
|
+
|
|
2655
|
+
|
|
2656
|
+
//move camera and gizmos to obtain pinch effect
|
|
2657
|
+
_scalePointTemp.sub( this._v3_1 );
|
|
2658
|
+
|
|
2659
|
+
const amount = _scalePointTemp.clone().multiplyScalar( sizeInverse );
|
|
2660
|
+
_scalePointTemp.sub( amount );
|
|
2661
|
+
|
|
2662
|
+
this._m4_1.makeTranslation( _scalePointTemp.x, _scalePointTemp.y, _scalePointTemp.z );
|
|
2663
|
+
this._m4_2.premultiply( this._m4_1 );
|
|
2664
|
+
|
|
2665
|
+
this.setTransformationMatrices( this._m4_1, this._m4_2 );
|
|
2666
|
+
return _transformation;
|
|
2667
|
+
|
|
2668
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
2669
|
+
|
|
2670
|
+
this._v3_1.setFromMatrixPosition( this._cameraMatrixState );
|
|
2671
|
+
this._v3_2.setFromMatrixPosition( this._gizmoMatrixState );
|
|
2672
|
+
|
|
2673
|
+
//move camera
|
|
2674
|
+
let distance = this._v3_1.distanceTo( _scalePointTemp );
|
|
2675
|
+
let amount = distance - ( distance * sizeInverse );
|
|
2676
|
+
|
|
2677
|
+
//check min and max distance
|
|
2678
|
+
const newDistance = distance - amount;
|
|
2679
|
+
if ( newDistance < this.minDistance ) {
|
|
2680
|
+
|
|
2681
|
+
sizeInverse = this.minDistance / distance;
|
|
2682
|
+
amount = distance - ( distance * sizeInverse );
|
|
2683
|
+
|
|
2684
|
+
} else if ( newDistance > this.maxDistance ) {
|
|
2685
|
+
|
|
2686
|
+
sizeInverse = this.maxDistance / distance;
|
|
2687
|
+
amount = distance - ( distance * sizeInverse );
|
|
2688
|
+
|
|
2689
|
+
}
|
|
2690
|
+
|
|
2691
|
+
_offset.copy( _scalePointTemp ).sub( this._v3_1 ).normalize().multiplyScalar( amount );
|
|
2692
|
+
|
|
2693
|
+
this._m4_1.makeTranslation( _offset.x, _offset.y, _offset.z );
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
if ( scaleGizmos ) {
|
|
2697
|
+
|
|
2698
|
+
//scale gizmos so they appear in the same spot having the same dimension
|
|
2699
|
+
const pos = this._v3_2;
|
|
2700
|
+
|
|
2701
|
+
distance = pos.distanceTo( _scalePointTemp );
|
|
2702
|
+
amount = distance - ( distance * sizeInverse );
|
|
2703
|
+
_offset.copy( _scalePointTemp ).sub( this._v3_2 ).normalize().multiplyScalar( amount );
|
|
2704
|
+
|
|
2705
|
+
this._translationMatrix.makeTranslation( pos.x, pos.y, pos.z );
|
|
2706
|
+
this._scaleMatrix.makeScale( sizeInverse, sizeInverse, sizeInverse );
|
|
2707
|
+
|
|
2708
|
+
this._m4_2.makeTranslation( _offset.x, _offset.y, _offset.z ).multiply( this._translationMatrix );
|
|
2709
|
+
this._m4_2.multiply( this._scaleMatrix );
|
|
2710
|
+
|
|
2711
|
+
this._translationMatrix.makeTranslation( - pos.x, - pos.y, - pos.z );
|
|
2712
|
+
|
|
2713
|
+
this._m4_2.multiply( this._translationMatrix );
|
|
2714
|
+
this.setTransformationMatrices( this._m4_1, this._m4_2 );
|
|
2715
|
+
|
|
2716
|
+
|
|
2717
|
+
} else {
|
|
2718
|
+
|
|
2719
|
+
this.setTransformationMatrices( this._m4_1 );
|
|
2720
|
+
|
|
2721
|
+
}
|
|
2722
|
+
|
|
2723
|
+
return _transformation;
|
|
2724
|
+
|
|
2725
|
+
}
|
|
2726
|
+
|
|
2727
|
+
};
|
|
2728
|
+
|
|
2729
|
+
/**
|
|
2730
|
+
* Set camera fov
|
|
2731
|
+
* @param {Number} value fov to be setted
|
|
2732
|
+
*/
|
|
2733
|
+
setFov = ( value ) => {
|
|
2734
|
+
|
|
2735
|
+
if ( this.camera.isPerspectiveCamera ) {
|
|
2736
|
+
|
|
2737
|
+
this.camera.fov = MathUtils.clamp( value, this.minFov, this.maxFov );
|
|
2738
|
+
this.camera.updateProjectionMatrix();
|
|
2739
|
+
|
|
2740
|
+
}
|
|
2741
|
+
|
|
2742
|
+
};
|
|
2743
|
+
|
|
2744
|
+
/**
|
|
2745
|
+
* Set values in transformation object
|
|
2746
|
+
* @param {Matrix4} camera Transformation to be applied to the camera
|
|
2747
|
+
* @param {Matrix4} gizmos Transformation to be applied to gizmos
|
|
2748
|
+
*/
|
|
2749
|
+
setTransformationMatrices( camera = null, gizmos = null ) {
|
|
2750
|
+
|
|
2751
|
+
if ( camera != null ) {
|
|
2752
|
+
|
|
2753
|
+
if ( _transformation.camera != null ) {
|
|
2754
|
+
|
|
2755
|
+
_transformation.camera.copy( camera );
|
|
2756
|
+
|
|
2757
|
+
} else {
|
|
2758
|
+
|
|
2759
|
+
_transformation.camera = camera.clone();
|
|
2760
|
+
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
} else {
|
|
2764
|
+
|
|
2765
|
+
_transformation.camera = null;
|
|
2766
|
+
|
|
2767
|
+
}
|
|
2768
|
+
|
|
2769
|
+
if ( gizmos != null ) {
|
|
2770
|
+
|
|
2771
|
+
if ( _transformation.gizmos != null ) {
|
|
2772
|
+
|
|
2773
|
+
_transformation.gizmos.copy( gizmos );
|
|
2774
|
+
|
|
2775
|
+
} else {
|
|
2776
|
+
|
|
2777
|
+
_transformation.gizmos = gizmos.clone();
|
|
2778
|
+
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
} else {
|
|
2782
|
+
|
|
2783
|
+
_transformation.gizmos = null;
|
|
2784
|
+
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2789
|
+
/**
|
|
2790
|
+
* Rotate camera around its direction axis passing by a given point by a given angle
|
|
2791
|
+
* @param {Vector3} point The point where the rotation axis is passing trough
|
|
2792
|
+
* @param {Number} angle Angle in radians
|
|
2793
|
+
* @returns The computed transormation matix
|
|
2794
|
+
*/
|
|
2795
|
+
zRotate = ( point, angle ) => {
|
|
2796
|
+
|
|
2797
|
+
this._rotationMatrix.makeRotationAxis( this._rotationAxis, angle );
|
|
2798
|
+
this._translationMatrix.makeTranslation( - point.x, - point.y, - point.z );
|
|
2799
|
+
|
|
2800
|
+
this._m4_1.makeTranslation( point.x, point.y, point.z );
|
|
2801
|
+
this._m4_1.multiply( this._rotationMatrix );
|
|
2802
|
+
this._m4_1.multiply( this._translationMatrix );
|
|
2803
|
+
|
|
2804
|
+
this._v3_1.setFromMatrixPosition( this._gizmoMatrixState ).sub( point ); //vector from rotation center to gizmos position
|
|
2805
|
+
this._v3_2.copy( this._v3_1 ).applyAxisAngle( this._rotationAxis, angle ); //apply rotation
|
|
2806
|
+
this._v3_2.sub( this._v3_1 );
|
|
2807
|
+
|
|
2808
|
+
this._m4_2.makeTranslation( this._v3_2.x, this._v3_2.y, this._v3_2.z );
|
|
2809
|
+
|
|
2810
|
+
this.setTransformationMatrices( this._m4_1, this._m4_2 );
|
|
2811
|
+
return _transformation;
|
|
2812
|
+
|
|
2813
|
+
};
|
|
2814
|
+
|
|
2815
|
+
|
|
2816
|
+
getRaycaster() {
|
|
2817
|
+
|
|
2818
|
+
return _raycaster;
|
|
2819
|
+
|
|
2820
|
+
}
|
|
2821
|
+
|
|
2822
|
+
|
|
2823
|
+
/**
|
|
2824
|
+
* Unproject the cursor on the 3D object surface
|
|
2825
|
+
* @param {Vector2} cursor Cursor coordinates in NDC
|
|
2826
|
+
* @param {Camera} camera Virtual camera
|
|
2827
|
+
* @returns {Vector3} The point of intersection with the model, if exist, null otherwise
|
|
2828
|
+
*/
|
|
2829
|
+
unprojectOnObj = ( cursor, camera ) => {
|
|
2830
|
+
|
|
2831
|
+
const raycaster = this.getRaycaster();
|
|
2832
|
+
raycaster.near = camera.near;
|
|
2833
|
+
raycaster.far = camera.far;
|
|
2834
|
+
raycaster.setFromCamera( cursor, camera );
|
|
2835
|
+
|
|
2836
|
+
const intersect = raycaster.intersectObjects( this.scene.children, true );
|
|
2837
|
+
|
|
2838
|
+
for ( let i = 0; i < intersect.length; i ++ ) {
|
|
2839
|
+
|
|
2840
|
+
if ( intersect[ i ].object.uuid != this._gizmos.uuid && intersect[ i ].face != null ) {
|
|
2841
|
+
|
|
2842
|
+
return intersect[ i ].point.clone();
|
|
2843
|
+
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
}
|
|
2847
|
+
|
|
2848
|
+
return null;
|
|
2849
|
+
|
|
2850
|
+
};
|
|
2851
|
+
|
|
2852
|
+
/**
|
|
2853
|
+
* Unproject the cursor on the trackball surface
|
|
2854
|
+
* @param {Camera} camera The virtual camera
|
|
2855
|
+
* @param {Number} cursorX Cursor horizontal coordinate on screen
|
|
2856
|
+
* @param {Number} cursorY Cursor vertical coordinate on screen
|
|
2857
|
+
* @param {HTMLElement} canvas The canvas where the renderer draws its output
|
|
2858
|
+
* @param {number} tbRadius The trackball radius
|
|
2859
|
+
* @returns {Vector3} The unprojected point on the trackball surface
|
|
2860
|
+
*/
|
|
2861
|
+
unprojectOnTbSurface = ( camera, cursorX, cursorY, canvas, tbRadius ) => {
|
|
2862
|
+
|
|
2863
|
+
if ( camera.type == 'OrthographicCamera' ) {
|
|
2864
|
+
|
|
2865
|
+
this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
|
|
2866
|
+
this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
|
|
2867
|
+
|
|
2868
|
+
const x2 = Math.pow( this._v2_1.x, 2 );
|
|
2869
|
+
const y2 = Math.pow( this._v2_1.y, 2 );
|
|
2870
|
+
const r2 = Math.pow( this._tbRadius, 2 );
|
|
2871
|
+
|
|
2872
|
+
if ( x2 + y2 <= r2 * 0.5 ) {
|
|
2873
|
+
|
|
2874
|
+
//intersection with sphere
|
|
2875
|
+
this._v3_1.setZ( Math.sqrt( r2 - ( x2 + y2 ) ) );
|
|
2876
|
+
|
|
2877
|
+
} else {
|
|
2878
|
+
|
|
2879
|
+
//intersection with hyperboloid
|
|
2880
|
+
this._v3_1.setZ( ( r2 * 0.5 ) / ( Math.sqrt( x2 + y2 ) ) );
|
|
2881
|
+
|
|
2882
|
+
}
|
|
2883
|
+
|
|
2884
|
+
return this._v3_1;
|
|
2885
|
+
|
|
2886
|
+
} else if ( camera.type == 'PerspectiveCamera' ) {
|
|
2887
|
+
|
|
2888
|
+
//unproject cursor on the near plane
|
|
2889
|
+
this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
|
|
2890
|
+
|
|
2891
|
+
this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
|
|
2892
|
+
this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
|
|
2893
|
+
|
|
2894
|
+
const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
|
|
2895
|
+
const cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
|
|
2896
|
+
const radius2 = Math.pow( tbRadius, 2 );
|
|
2897
|
+
|
|
2898
|
+
// camera
|
|
2899
|
+
// |\
|
|
2900
|
+
// | \
|
|
2901
|
+
// | \
|
|
2902
|
+
// h | \
|
|
2903
|
+
// | \
|
|
2904
|
+
// | \
|
|
2905
|
+
// _ _ | _ _ _\ _ _ near plane
|
|
2906
|
+
// l
|
|
2907
|
+
|
|
2908
|
+
const h = this._v3_1.z;
|
|
2909
|
+
const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
|
|
2910
|
+
|
|
2911
|
+
if ( l == 0 ) {
|
|
2912
|
+
|
|
2913
|
+
//ray aligned with camera
|
|
2914
|
+
rayDir.set( this._v3_1.x, this._v3_1.y, tbRadius );
|
|
2915
|
+
return rayDir;
|
|
2916
|
+
|
|
2917
|
+
}
|
|
2918
|
+
|
|
2919
|
+
const m = h / l;
|
|
2920
|
+
const q = cameraGizmoDistance;
|
|
2921
|
+
|
|
2922
|
+
/*
|
|
2923
|
+
* calculate intersection point between unprojected ray and trackball surface
|
|
2924
|
+
*|y = m * x + q
|
|
2925
|
+
*|x^2 + y^2 = r^2
|
|
2926
|
+
*
|
|
2927
|
+
* (m^2 + 1) * x^2 + (2 * m * q) * x + q^2 - r^2 = 0
|
|
2928
|
+
*/
|
|
2929
|
+
let a = Math.pow( m, 2 ) + 1;
|
|
2930
|
+
let b = 2 * m * q;
|
|
2931
|
+
let c = Math.pow( q, 2 ) - radius2;
|
|
2932
|
+
let delta = Math.pow( b, 2 ) - ( 4 * a * c );
|
|
2933
|
+
|
|
2934
|
+
if ( delta >= 0 ) {
|
|
2935
|
+
|
|
2936
|
+
//intersection with sphere
|
|
2937
|
+
this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
|
|
2938
|
+
this._v2_1.setY( m * this._v2_1.x + q );
|
|
2939
|
+
|
|
2940
|
+
const angle = MathUtils.RAD2DEG * this._v2_1.angle();
|
|
2941
|
+
|
|
2942
|
+
if ( angle >= 45 ) {
|
|
2943
|
+
|
|
2944
|
+
//if angle between intersection point and X' axis is >= 45°, return that point
|
|
2945
|
+
//otherwise, calculate intersection point with hyperboloid
|
|
2946
|
+
|
|
2947
|
+
const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( ( cameraGizmoDistance - this._v2_1.y ), 2 ) );
|
|
2948
|
+
rayDir.multiplyScalar( rayLength );
|
|
2949
|
+
rayDir.z += cameraGizmoDistance;
|
|
2950
|
+
return rayDir;
|
|
2951
|
+
|
|
2952
|
+
}
|
|
2953
|
+
|
|
2954
|
+
}
|
|
2955
|
+
|
|
2956
|
+
//intersection with hyperboloid
|
|
2957
|
+
/*
|
|
2958
|
+
*|y = m * x + q
|
|
2959
|
+
*|y = (1 / x) * (r^2 / 2)
|
|
2960
|
+
*
|
|
2961
|
+
* m * x^2 + q * x - r^2 / 2 = 0
|
|
2962
|
+
*/
|
|
2963
|
+
|
|
2964
|
+
a = m;
|
|
2965
|
+
b = q;
|
|
2966
|
+
c = - radius2 * 0.5;
|
|
2967
|
+
delta = Math.pow( b, 2 ) - ( 4 * a * c );
|
|
2968
|
+
this._v2_1.setX( ( - b - Math.sqrt( delta ) ) / ( 2 * a ) );
|
|
2969
|
+
this._v2_1.setY( m * this._v2_1.x + q );
|
|
2970
|
+
|
|
2971
|
+
const rayLength = Math.sqrt( Math.pow( this._v2_1.x, 2 ) + Math.pow( ( cameraGizmoDistance - this._v2_1.y ), 2 ) );
|
|
2972
|
+
|
|
2973
|
+
rayDir.multiplyScalar( rayLength );
|
|
2974
|
+
rayDir.z += cameraGizmoDistance;
|
|
2975
|
+
return rayDir;
|
|
2976
|
+
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
};
|
|
2980
|
+
|
|
2981
|
+
|
|
2982
|
+
/**
|
|
2983
|
+
* Unproject the cursor on the plane passing through the center of the trackball orthogonal to the camera
|
|
2984
|
+
* @param {Camera} camera The virtual camera
|
|
2985
|
+
* @param {Number} cursorX Cursor horizontal coordinate on screen
|
|
2986
|
+
* @param {Number} cursorY Cursor vertical coordinate on screen
|
|
2987
|
+
* @param {HTMLElement} canvas The canvas where the renderer draws its output
|
|
2988
|
+
* @param {Boolean} initialDistance If initial distance between camera and gizmos should be used for calculations instead of current (Perspective only)
|
|
2989
|
+
* @returns {Vector3} The unprojected point on the trackball plane
|
|
2990
|
+
*/
|
|
2991
|
+
unprojectOnTbPlane = ( camera, cursorX, cursorY, canvas, initialDistance = false ) => {
|
|
2992
|
+
|
|
2993
|
+
if ( camera.type == 'OrthographicCamera' ) {
|
|
2994
|
+
|
|
2995
|
+
this._v2_1.copy( this.getCursorPosition( cursorX, cursorY, canvas ) );
|
|
2996
|
+
this._v3_1.set( this._v2_1.x, this._v2_1.y, 0 );
|
|
2997
|
+
|
|
2998
|
+
return this._v3_1.clone();
|
|
2999
|
+
|
|
3000
|
+
} else if ( camera.type == 'PerspectiveCamera' ) {
|
|
3001
|
+
|
|
3002
|
+
this._v2_1.copy( this.getCursorNDC( cursorX, cursorY, canvas ) );
|
|
3003
|
+
|
|
3004
|
+
//unproject cursor on the near plane
|
|
3005
|
+
this._v3_1.set( this._v2_1.x, this._v2_1.y, - 1 );
|
|
3006
|
+
this._v3_1.applyMatrix4( camera.projectionMatrixInverse );
|
|
3007
|
+
|
|
3008
|
+
const rayDir = this._v3_1.clone().normalize(); //unprojected ray direction
|
|
3009
|
+
|
|
3010
|
+
// camera
|
|
3011
|
+
// |\
|
|
3012
|
+
// | \
|
|
3013
|
+
// | \
|
|
3014
|
+
// h | \
|
|
3015
|
+
// | \
|
|
3016
|
+
// | \
|
|
3017
|
+
// _ _ | _ _ _\ _ _ near plane
|
|
3018
|
+
// l
|
|
3019
|
+
|
|
3020
|
+
const h = this._v3_1.z;
|
|
3021
|
+
const l = Math.sqrt( Math.pow( this._v3_1.x, 2 ) + Math.pow( this._v3_1.y, 2 ) );
|
|
3022
|
+
let cameraGizmoDistance;
|
|
3023
|
+
|
|
3024
|
+
if ( initialDistance ) {
|
|
3025
|
+
|
|
3026
|
+
cameraGizmoDistance = this._v3_1.setFromMatrixPosition( this._cameraMatrixState0 ).distanceTo( this._v3_2.setFromMatrixPosition( this._gizmoMatrixState0 ) );
|
|
3027
|
+
|
|
3028
|
+
} else {
|
|
3029
|
+
|
|
3030
|
+
cameraGizmoDistance = camera.position.distanceTo( this._gizmos.position );
|
|
3031
|
+
|
|
3032
|
+
}
|
|
3033
|
+
|
|
3034
|
+
/*
|
|
3035
|
+
* calculate intersection point between unprojected ray and the plane
|
|
3036
|
+
*|y = mx + q
|
|
3037
|
+
*|y = 0
|
|
3038
|
+
*
|
|
3039
|
+
* x = -q/m
|
|
3040
|
+
*/
|
|
3041
|
+
if ( l == 0 ) {
|
|
3042
|
+
|
|
3043
|
+
//ray aligned with camera
|
|
3044
|
+
rayDir.set( 0, 0, 0 );
|
|
3045
|
+
return rayDir;
|
|
3046
|
+
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
const m = h / l;
|
|
3050
|
+
const q = cameraGizmoDistance;
|
|
3051
|
+
const x = - q / m;
|
|
3052
|
+
|
|
3053
|
+
const rayLength = Math.sqrt( Math.pow( q, 2 ) + Math.pow( x, 2 ) );
|
|
3054
|
+
rayDir.multiplyScalar( rayLength );
|
|
3055
|
+
rayDir.z = 0;
|
|
3056
|
+
return rayDir;
|
|
3057
|
+
|
|
3058
|
+
}
|
|
3059
|
+
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3062
|
+
/**
|
|
3063
|
+
* Update camera and gizmos state
|
|
3064
|
+
*/
|
|
3065
|
+
updateMatrixState = () => {
|
|
3066
|
+
|
|
3067
|
+
//update camera and gizmos state
|
|
3068
|
+
this._cameraMatrixState.copy( this.camera.matrix );
|
|
3069
|
+
this._gizmoMatrixState.copy( this._gizmos.matrix );
|
|
3070
|
+
|
|
3071
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
3072
|
+
|
|
3073
|
+
this._cameraProjectionState.copy( this.camera.projectionMatrix );
|
|
3074
|
+
this.camera.updateProjectionMatrix();
|
|
3075
|
+
this._zoomState = this.camera.zoom;
|
|
3076
|
+
|
|
3077
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
3078
|
+
|
|
3079
|
+
this._fovState = this.camera.fov;
|
|
3080
|
+
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
};
|
|
3084
|
+
|
|
3085
|
+
/**
|
|
3086
|
+
* Update the trackball FSA
|
|
3087
|
+
* @param {STATE} newState New state of the FSA
|
|
3088
|
+
* @param {Boolean} updateMatrices If matriices state should be updated
|
|
3089
|
+
*/
|
|
3090
|
+
updateTbState = ( newState, updateMatrices ) => {
|
|
3091
|
+
|
|
3092
|
+
this._state = newState;
|
|
3093
|
+
if ( updateMatrices ) {
|
|
3094
|
+
|
|
3095
|
+
this.updateMatrixState();
|
|
3096
|
+
|
|
3097
|
+
}
|
|
3098
|
+
|
|
3099
|
+
};
|
|
3100
|
+
|
|
3101
|
+
update = () => {
|
|
3102
|
+
|
|
3103
|
+
const EPS = 0.000001;
|
|
3104
|
+
|
|
3105
|
+
if ( this.target.equals( this._currentTarget ) === false ) {
|
|
3106
|
+
|
|
3107
|
+
this._gizmos.position.copy( this.target ); //for correct radius calculation
|
|
3108
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
3109
|
+
this.makeGizmos( this.target, this._tbRadius );
|
|
3110
|
+
this._currentTarget.copy( this.target );
|
|
3111
|
+
|
|
3112
|
+
}
|
|
3113
|
+
|
|
3114
|
+
//check min/max parameters
|
|
3115
|
+
if ( this.camera.isOrthographicCamera ) {
|
|
3116
|
+
|
|
3117
|
+
//check zoom
|
|
3118
|
+
if ( this.camera.zoom > this.maxZoom || this.camera.zoom < this.minZoom ) {
|
|
3119
|
+
|
|
3120
|
+
const newZoom = MathUtils.clamp( this.camera.zoom, this.minZoom, this.maxZoom );
|
|
3121
|
+
this.applyTransformMatrix( this.scale( newZoom / this.camera.zoom, this._gizmos.position, true ) );
|
|
3122
|
+
|
|
3123
|
+
}
|
|
3124
|
+
|
|
3125
|
+
} else if ( this.camera.isPerspectiveCamera ) {
|
|
3126
|
+
|
|
3127
|
+
//check distance
|
|
3128
|
+
const distance = this.camera.position.distanceTo( this._gizmos.position );
|
|
3129
|
+
|
|
3130
|
+
if ( distance > this.maxDistance + EPS || distance < this.minDistance - EPS ) {
|
|
3131
|
+
|
|
3132
|
+
const newDistance = MathUtils.clamp( distance, this.minDistance, this.maxDistance );
|
|
3133
|
+
this.applyTransformMatrix( this.scale( newDistance / distance, this._gizmos.position ) );
|
|
3134
|
+
this.updateMatrixState();
|
|
3135
|
+
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
//check fov
|
|
3139
|
+
if ( this.camera.fov < this.minFov || this.camera.fov > this.maxFov ) {
|
|
3140
|
+
|
|
3141
|
+
this.camera.fov = MathUtils.clamp( this.camera.fov, this.minFov, this.maxFov );
|
|
3142
|
+
this.camera.updateProjectionMatrix();
|
|
3143
|
+
|
|
3144
|
+
}
|
|
3145
|
+
|
|
3146
|
+
const oldRadius = this._tbRadius;
|
|
3147
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
3148
|
+
|
|
3149
|
+
if ( oldRadius < this._tbRadius - EPS || oldRadius > this._tbRadius + EPS ) {
|
|
3150
|
+
|
|
3151
|
+
const scale = ( this._gizmos.scale.x + this._gizmos.scale.y + this._gizmos.scale.z ) / 3;
|
|
3152
|
+
const newRadius = this._tbRadius / scale;
|
|
3153
|
+
const curve = new EllipseCurve( 0, 0, newRadius, newRadius );
|
|
3154
|
+
const points = curve.getPoints( this._curvePts );
|
|
3155
|
+
const curveGeometry = new BufferGeometry().setFromPoints( points );
|
|
3156
|
+
|
|
3157
|
+
for ( const gizmo in this._gizmos.children ) {
|
|
3158
|
+
|
|
3159
|
+
this._gizmos.children[ gizmo ].geometry = curveGeometry;
|
|
3160
|
+
|
|
3161
|
+
}
|
|
3162
|
+
|
|
3163
|
+
}
|
|
3164
|
+
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
this.camera.lookAt( this._gizmos.position );
|
|
3168
|
+
|
|
3169
|
+
};
|
|
3170
|
+
|
|
3171
|
+
setStateFromJSON = ( json ) => {
|
|
3172
|
+
|
|
3173
|
+
const state = JSON.parse( json );
|
|
3174
|
+
|
|
3175
|
+
if ( state.arcballState != undefined ) {
|
|
3176
|
+
|
|
3177
|
+
this._cameraMatrixState.fromArray( state.arcballState.cameraMatrix.elements );
|
|
3178
|
+
this._cameraMatrixState.decompose( this.camera.position, this.camera.quaternion, this.camera.scale );
|
|
3179
|
+
|
|
3180
|
+
this.camera.up.copy( state.arcballState.cameraUp );
|
|
3181
|
+
this.camera.near = state.arcballState.cameraNear;
|
|
3182
|
+
this.camera.far = state.arcballState.cameraFar;
|
|
3183
|
+
|
|
3184
|
+
this.camera.zoom = state.arcballState.cameraZoom;
|
|
3185
|
+
|
|
3186
|
+
if ( this.camera.isPerspectiveCamera ) {
|
|
3187
|
+
|
|
3188
|
+
this.camera.fov = state.arcballState.cameraFov;
|
|
3189
|
+
|
|
3190
|
+
}
|
|
3191
|
+
|
|
3192
|
+
this._gizmoMatrixState.fromArray( state.arcballState.gizmoMatrix.elements );
|
|
3193
|
+
this._gizmoMatrixState.decompose( this._gizmos.position, this._gizmos.quaternion, this._gizmos.scale );
|
|
3194
|
+
|
|
3195
|
+
this.camera.updateMatrix();
|
|
3196
|
+
this.camera.updateProjectionMatrix();
|
|
3197
|
+
|
|
3198
|
+
this._gizmos.updateMatrix();
|
|
3199
|
+
|
|
3200
|
+
this._tbRadius = this.calculateTbRadius( this.camera );
|
|
3201
|
+
const gizmoTmp = new Matrix4().copy( this._gizmoMatrixState0 );
|
|
3202
|
+
this.makeGizmos( this._gizmos.position, this._tbRadius );
|
|
3203
|
+
this._gizmoMatrixState0.copy( gizmoTmp );
|
|
3204
|
+
|
|
3205
|
+
this.camera.lookAt( this._gizmos.position );
|
|
3206
|
+
this.updateTbState( STATE.IDLE, false );
|
|
3207
|
+
|
|
3208
|
+
this.dispatchEvent( _changeEvent );
|
|
3209
|
+
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
}
|
|
3215
|
+
|
|
3216
|
+
export { ArcballControls };
|