@needle-tools/three 0.145.4 → 0.146.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/three.cjs +32586 -35951
- package/build/three.js +32600 -35965
- package/build/three.min.js +6 -7
- package/build/three.module.js +1547 -1154
- package/examples/js/animation/AnimationClipCreator.js +0 -8
- package/examples/js/animation/CCDIKSolver.js +49 -66
- package/examples/js/animation/MMDAnimationHelper.js +66 -137
- package/examples/js/animation/MMDPhysics.js +70 -134
- package/examples/js/cameras/CinematicCamera.js +33 -22
- package/examples/js/controls/ArcballControls.js +138 -405
- package/examples/js/controls/DragControls.js +8 -33
- package/examples/js/controls/FirstPersonControls.js +32 -54
- package/examples/js/controls/FlyControls.js +29 -55
- package/examples/js/controls/OrbitControls.js +85 -95
- package/examples/js/controls/PointerLockControls.js +5 -14
- package/examples/js/controls/TrackballControls.js +33 -86
- package/examples/js/controls/TransformControls.js +84 -169
- package/examples/js/csm/CSM.js +4 -39
- package/examples/js/csm/CSMFrustum.js +3 -9
- package/examples/js/csm/CSMHelper.js +24 -4
- package/examples/js/csm/CSMShader.js +2 -6
- package/examples/js/curves/CurveExtras.js +27 -27
- package/examples/js/curves/NURBSCurve.js +4 -16
- package/examples/js/curves/NURBSSurface.js +3 -9
- package/examples/js/curves/NURBSUtils.js +8 -45
- package/examples/js/effects/AnaglyphEffect.js +4 -18
- package/examples/js/effects/AsciiEffect.js +32 -31
- package/examples/js/effects/OutlineEffect.js +26 -30
- package/examples/js/effects/ParallaxBarrierEffect.js +0 -13
- package/examples/js/effects/PeppersGhostEffect.js +12 -39
- package/examples/js/effects/StereoEffect.js +0 -4
- package/examples/js/environments/RoomEnvironment.js +12 -10
- package/examples/js/exporters/ColladaExporter.js +48 -65
- package/examples/js/exporters/DRACOExporter.js +22 -22
- package/examples/js/exporters/EXRExporter.js +15 -18
- package/examples/js/exporters/GLTFExporter.js +143 -261
- package/examples/js/exporters/MMDExporter.js +5 -12
- package/examples/js/exporters/OBJExporter.js +42 -33
- package/examples/js/exporters/PLYExporter.js +38 -33
- package/examples/js/exporters/STLExporter.js +5 -7
- package/examples/js/exporters/USDZExporter.js +110 -25
- package/examples/js/geometries/BoxLineGeometry.js +0 -1
- package/examples/js/geometries/ConvexGeometry.js +11 -6
- package/examples/js/geometries/DecalGeometry.js +53 -20
- package/examples/js/geometries/LightningStrike.js +54 -67
- package/examples/js/geometries/ParametricGeometries.js +8 -7
- package/examples/js/geometries/ParametricGeometry.js +25 -12
- package/examples/js/geometries/RoundedBoxGeometry.js +21 -19
- package/examples/js/geometries/TeapotGeometry.js +54 -50
- package/examples/js/geometries/TextGeometry.js +6 -4
- package/examples/js/helpers/LightProbeHelper.js +1 -2
- package/examples/js/helpers/OctreeHelper.js +22 -20
- package/examples/js/helpers/PositionalAudioHelper.js +8 -6
- package/examples/js/helpers/RectAreaLightHelper.js +6 -7
- package/examples/js/helpers/VertexNormalsHelper.js +15 -13
- package/examples/js/helpers/VertexTangentsHelper.js +15 -9
- package/examples/js/helpers/ViewHelper.js +31 -16
- package/examples/js/interactive/HTMLMesh.js +22 -33
- package/examples/js/interactive/InteractiveGroup.js +6 -12
- package/examples/js/interactive/SelectionBox.js +3 -70
- package/examples/js/interactive/SelectionHelper.js +0 -8
- package/examples/js/lights/LightProbeGenerator.js +32 -39
- package/examples/js/lights/RectAreaLightUniformsLib.js +5 -1
- package/examples/js/lines/LineGeometry.js +3 -5
- package/examples/js/lines/LineMaterial.js +4 -11
- package/examples/js/lines/LineSegments2.js +38 -89
- package/examples/js/lines/LineSegmentsGeometry.js +7 -28
- package/examples/js/lines/Wireframe.js +2 -7
- package/examples/js/lines/WireframeGeometry2.js +3 -1
- package/examples/js/loaders/3DMLoader.js +58 -155
- package/examples/js/loaders/3MFLoader.js +72 -106
- package/examples/js/loaders/AMFLoader.js +0 -25
- package/examples/js/loaders/BVHLoader.js +44 -43
- package/examples/js/loaders/BasisTextureLoader.js +16 -46
- package/examples/js/loaders/ColladaLoader.js +201 -359
- package/examples/js/loaders/DDSLoader.js +24 -25
- package/examples/js/loaders/DRACOLoader.js +29 -66
- package/examples/js/loaders/EXRLoader.js +67 -164
- package/examples/js/loaders/FBXLoader.js +286 -441
- package/examples/js/loaders/FontLoader.js +6 -15
- package/examples/js/loaders/GCodeLoader.js +15 -16
- package/examples/js/loaders/GLTFLoader.js +354 -405
- package/examples/js/loaders/HDRCubeTextureLoader.js +0 -6
- package/examples/js/loaders/KMZLoader.js +3 -7
- package/examples/js/loaders/KTXLoader.js +12 -30
- package/examples/js/loaders/LDrawLoader.js +178 -289
- package/examples/js/loaders/LUT3dlLoader.js +7 -11
- package/examples/js/loaders/LUTCubeLoader.js +0 -8
- package/examples/js/loaders/LWOLoader.js +59 -124
- package/examples/js/loaders/LogLuvLoader.js +27 -77
- package/examples/js/loaders/LottieLoader.js +4 -4
- package/examples/js/loaders/MD2Loader.js +26 -27
- package/examples/js/loaders/MDDLoader.js +6 -10
- package/examples/js/loaders/MMDLoader.js +180 -189
- package/examples/js/loaders/MTLLoader.js +18 -47
- package/examples/js/loaders/MaterialXLoader.js +392 -0
- package/examples/js/loaders/NRRDLoader.js +44 -84
- package/examples/js/loaders/OBJLoader.js +50 -65
- package/examples/js/loaders/PCDLoader.js +34 -29
- package/examples/js/loaders/PDBLoader.js +17 -13
- package/examples/js/loaders/PLYLoader.js +9 -39
- package/examples/js/loaders/PRWMLoader.js +11 -22
- package/examples/js/loaders/PVRLoader.js +7 -16
- package/examples/js/loaders/RGBELoader.js +36 -61
- package/examples/js/loaders/RGBMLoader.js +26 -87
- package/examples/js/loaders/STLLoader.js +20 -27
- package/examples/js/loaders/SVGLoader.js +361 -233
- package/examples/js/loaders/TDSLoader.js +81 -118
- package/examples/js/loaders/TGALoader.js +39 -41
- package/examples/js/loaders/TIFFLoader.js +0 -1
- package/examples/js/loaders/TTFLoader.js +0 -8
- package/examples/js/loaders/TiltLoader.js +14 -15
- package/examples/js/loaders/VOXLoader.js +8 -16
- package/examples/js/loaders/VRMLLoader.js +243 -340
- package/examples/js/loaders/VTKLoader.js +101 -118
- package/examples/js/loaders/XYZLoader.js +2 -4
- package/examples/js/loaders/lwo/IFFParser.js +55 -136
- package/examples/js/loaders/lwo/LWO2Parser.js +32 -83
- package/examples/js/loaders/lwo/LWO3Parser.js +31 -73
- package/examples/js/materials/MeshGouraudMaterial.js +15 -13
- package/examples/js/math/Capsule.js +0 -17
- package/examples/js/math/ColorConverter.js +3 -3
- package/examples/js/math/ConvexHull.js +183 -139
- package/examples/js/math/ImprovedNoise.js +1 -1
- package/examples/js/math/Lut.js +8 -15
- package/examples/js/math/MeshSurfaceSampler.js +6 -28
- package/examples/js/math/OBB.js +90 -49
- package/examples/js/math/Octree.js +2 -57
- package/examples/js/math/SimplexNoise.js +74 -88
- package/examples/js/misc/ConvexObjectBreaker.js +37 -48
- package/examples/js/misc/GPUComputationRenderer.js +14 -18
- package/examples/js/misc/Gyroscope.js +5 -9
- package/examples/js/misc/MD2Character.js +14 -23
- package/examples/js/misc/MD2CharacterComplex.js +73 -54
- package/examples/js/misc/MorphAnimMesh.js +0 -6
- package/examples/js/misc/MorphBlendMesh.js +3 -30
- package/examples/js/misc/ProgressiveLightMap.js +47 -43
- package/examples/js/misc/RollerCoaster.js +17 -24
- package/examples/js/misc/TubePainter.js +18 -12
- package/examples/js/misc/Volume.js +16 -45
- package/examples/js/misc/VolumeSlice.js +14 -24
- package/examples/js/modifiers/CurveModifier.js +19 -21
- package/examples/js/modifiers/EdgeSplitModifier.js +0 -30
- package/examples/js/modifiers/SimplifyModifier.js +56 -59
- package/examples/js/modifiers/TessellateModifier.js +2 -9
- package/examples/js/objects/GroundProjectedEnv.js +2 -14
- package/examples/js/objects/Lensflare.js +47 -38
- package/examples/js/objects/LightningStorm.js +10 -13
- package/examples/js/objects/MarchingCubes.js +80 -59
- package/examples/js/objects/Reflector.js +22 -20
- package/examples/js/objects/ReflectorForSSRPass.js +19 -23
- package/examples/js/objects/Refractor.js +52 -30
- package/examples/js/objects/ShadowMesh.js +1 -2
- package/examples/js/objects/Sky.js +2 -7
- package/examples/js/objects/Water.js +23 -18
- package/examples/js/objects/Water2.js +20 -19
- package/examples/js/physics/AmmoPhysics.js +23 -20
- package/examples/js/physics/OimoPhysics.js +19 -17
- package/examples/js/postprocessing/AdaptiveToneMappingPass.js +13 -20
- package/examples/js/postprocessing/AfterimagePass.js +19 -12
- package/examples/js/postprocessing/BloomPass.js +38 -17
- package/examples/js/postprocessing/BokehPass.js +29 -12
- package/examples/js/postprocessing/ClearPass.js +1 -6
- package/examples/js/postprocessing/CubeTexturePass.js +12 -9
- package/examples/js/postprocessing/DotScreenPass.js +7 -5
- package/examples/js/postprocessing/EffectComposer.js +25 -32
- package/examples/js/postprocessing/FilmPass.js +7 -5
- package/examples/js/postprocessing/GlitchPass.js +10 -11
- package/examples/js/postprocessing/HalftonePass.js +9 -9
- package/examples/js/postprocessing/LUTPass.js +2 -15
- package/examples/js/postprocessing/MaskPass.js +20 -17
- package/examples/js/postprocessing/OutlinePass.js +45 -36
- package/examples/js/postprocessing/Pass.js +11 -14
- package/examples/js/postprocessing/RenderPass.js +3 -7
- package/examples/js/postprocessing/SAOPass.js +40 -32
- package/examples/js/postprocessing/SMAAPass.js +34 -17
- package/examples/js/postprocessing/SSAARenderPass.js +14 -14
- package/examples/js/postprocessing/SSAOPass.js +56 -42
- package/examples/js/postprocessing/SSRPass.js +78 -61
- package/examples/js/postprocessing/SavePass.js +14 -6
- package/examples/js/postprocessing/ShaderPass.js +9 -8
- package/examples/js/postprocessing/TAARenderPass.js +11 -9
- package/examples/js/postprocessing/TexturePass.js +7 -4
- package/examples/js/postprocessing/UnrealBloomPass.js +43 -25
- package/examples/js/renderers/CSS2DRenderer.js +2 -21
- package/examples/js/renderers/CSS3DRenderer.js +3 -24
- package/examples/js/renderers/Projector.js +29 -85
- package/examples/js/renderers/SVGRenderer.js +4 -50
- package/examples/js/shaders/ACESFilmicToneMappingShader.js +3 -6
- package/examples/js/shaders/AfterimageShader.js +3 -6
- package/examples/js/shaders/BasicShader.js +3 -6
- package/examples/js/shaders/BleachBypassShader.js +3 -6
- package/examples/js/shaders/BlendShader.js +3 -6
- package/examples/js/shaders/BokehShader.js +3 -6
- package/examples/js/shaders/BokehShader2.js +4 -13
- package/examples/js/shaders/BrightnessContrastShader.js +3 -6
- package/examples/js/shaders/ColorCorrectionShader.js +2 -6
- package/examples/js/shaders/ColorifyShader.js +2 -6
- package/examples/js/shaders/ConvolutionShader.js +5 -10
- package/examples/js/shaders/CopyShader.js +3 -6
- package/examples/js/shaders/DOFMipMapShader.js +3 -6
- package/examples/js/shaders/DepthLimitedBlurShader.js +2 -9
- package/examples/js/shaders/DigitalGlitch.js +3 -6
- package/examples/js/shaders/DotScreenShader.js +2 -6
- package/examples/js/shaders/FXAAShader.js +1 -3
- package/examples/js/shaders/FilmShader.js +3 -6
- package/examples/js/shaders/FocusShader.js +3 -6
- package/examples/js/shaders/FreiChenShader.js +2 -6
- package/examples/js/shaders/GammaCorrectionShader.js +3 -6
- package/examples/js/shaders/GodRaysShader.js +11 -24
- package/examples/js/shaders/HalftoneShader.js +3 -6
- package/examples/js/shaders/HorizontalBlurShader.js +3 -6
- package/examples/js/shaders/HorizontalTiltShiftShader.js +3 -6
- package/examples/js/shaders/HueSaturationShader.js +3 -6
- package/examples/js/shaders/KaleidoShader.js +3 -6
- package/examples/js/shaders/LuminosityHighPassShader.js +2 -6
- package/examples/js/shaders/LuminosityShader.js +3 -6
- package/examples/js/shaders/MMDToonShader.js +2 -6
- package/examples/js/shaders/MirrorShader.js +3 -6
- package/examples/js/shaders/NormalMapShader.js +2 -6
- package/examples/js/shaders/RGBShiftShader.js +3 -6
- package/examples/js/shaders/SAOShader.js +2 -6
- package/examples/js/shaders/SMAAShader.js +6 -18
- package/examples/js/shaders/SSAOShader.js +2 -6
- package/examples/js/shaders/SSRShader.js +6 -18
- package/examples/js/shaders/SepiaShader.js +3 -6
- package/examples/js/shaders/SobelOperatorShader.js +2 -6
- package/examples/js/shaders/TechnicolorShader.js +3 -6
- package/examples/js/shaders/ToneMapShader.js +3 -6
- package/examples/js/shaders/ToonShader.js +8 -24
- package/examples/js/shaders/TriangleBlurShader.js +2 -6
- package/examples/js/shaders/UnpackDepthRGBAShader.js +3 -6
- package/examples/js/shaders/VelocityShader.js +126 -0
- package/examples/js/shaders/VerticalBlurShader.js +3 -6
- package/examples/js/shaders/VerticalTiltShiftShader.js +3 -6
- package/examples/js/shaders/VignetteShader.js +3 -6
- package/examples/js/shaders/VolumeShader.js +2 -6
- package/examples/js/shaders/WaterRefractionShader.js +2 -6
- package/examples/js/textures/FlakesTexture.js +0 -1
- package/examples/js/utils/BufferGeometryUtils.js +234 -168
- package/examples/js/utils/CameraUtils.js +5 -20
- package/examples/js/utils/GPUStatsPanel.js +3 -12
- package/examples/js/utils/GeometryCompressionUtils.js +19 -44
- package/examples/js/utils/GeometryUtils.js +13 -18
- package/examples/js/utils/LDrawUtils.js +8 -11
- package/examples/js/utils/PackedPhongMaterial.js +6 -4
- package/examples/js/utils/SceneUtils.js +117 -6
- package/examples/js/utils/ShadowMapViewer.js +17 -14
- package/examples/js/utils/SkeletonUtils.js +13 -27
- package/examples/js/utils/UVsDebug.js +20 -12
- package/examples/js/utils/WorkerPool.js +1 -11
- package/examples/jsm/animation/CCDIKSolver.js +1 -1
- package/examples/jsm/capabilities/WebGPU.js +3 -1
- package/examples/jsm/controls/OrbitControls.js +44 -4
- package/examples/jsm/exporters/GLTFExporter.js +17 -131
- package/examples/jsm/exporters/USDZExporter.js +75 -19
- package/examples/jsm/interactive/HTMLMesh.js +2 -0
- package/examples/jsm/libs/lottie_canvas.module.js +14844 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -2
- package/examples/jsm/loaders/ColladaLoader.js +28 -0
- package/examples/jsm/loaders/FBXLoader.js +16 -2
- package/examples/jsm/loaders/GLTFLoader.js +204 -377
- package/examples/jsm/loaders/KTX2Loader.js +68 -29
- package/examples/jsm/loaders/LDrawLoader.js +14 -13
- package/examples/jsm/loaders/LottieLoader.js +4 -2
- package/examples/jsm/loaders/MaterialXLoader.js +728 -0
- package/examples/jsm/loaders/PCDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +68 -16
- package/examples/jsm/loaders/SVGLoader.js +227 -14
- package/examples/jsm/loaders/USDZLoader.js +31 -16
- package/examples/jsm/nodes/Nodes.js +14 -2
- package/examples/jsm/nodes/accessors/Object3DNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReferenceNode.js +1 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +1 -1
- package/examples/jsm/nodes/core/Node.js +1 -1
- package/examples/jsm/nodes/core/NodeBuilder.js +36 -4
- package/examples/jsm/nodes/core/NodeFrame.js +2 -2
- package/examples/jsm/nodes/core/NodeVarying.js +7 -4
- package/examples/jsm/nodes/core/VaryingNode.js +6 -4
- package/examples/jsm/nodes/core/constants.js +13 -13
- package/examples/jsm/nodes/display/PosterizeNode.js +25 -0
- package/examples/jsm/nodes/display/ViewportNode.js +106 -0
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +1 -1
- package/examples/jsm/nodes/loaders/NodeMaterialLoader.js +3 -1
- package/examples/jsm/nodes/materials/Materials.js +9 -7
- package/examples/jsm/nodes/materials/NodeMaterial.js +9 -1
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +6 -2
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +18 -0
- package/examples/jsm/nodes/math/MathNode.js +5 -0
- package/examples/jsm/nodes/math/OperatorNode.js +6 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +26 -13
- package/examples/jsm/nodes/shadernode/ShaderNodeBaseElements.js +2 -0
- package/examples/jsm/nodes/shadernode/ShaderNodeElements.js +18 -0
- package/examples/jsm/nodes/utils/EquirectUVNode.js +27 -0
- package/examples/jsm/nodes/utils/JoinNode.js +8 -2
- package/examples/jsm/nodes/utils/MatcapUVNode.js +2 -4
- package/examples/jsm/nodes/utils/MaxMipLevelNode.js +1 -1
- package/examples/jsm/nodes/utils/SpriteSheetUVNode.js +8 -10
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +51 -0
- package/examples/jsm/postprocessing/AfterimagePass.js +17 -4
- package/examples/jsm/postprocessing/BloomPass.js +22 -3
- package/examples/jsm/postprocessing/BokehPass.js +18 -4
- package/examples/jsm/postprocessing/CubeTexturePass.js +12 -5
- package/examples/jsm/postprocessing/DotScreenPass.js +8 -0
- package/examples/jsm/postprocessing/EffectComposer.js +9 -0
- package/examples/jsm/postprocessing/FilmPass.js +8 -0
- package/examples/jsm/postprocessing/GlitchPass.js +13 -1
- package/examples/jsm/postprocessing/HalftonePass.js +8 -0
- package/examples/jsm/postprocessing/OutlinePass.js +10 -0
- package/examples/jsm/postprocessing/Pass.js +2 -0
- package/examples/jsm/postprocessing/RenderPixelatedPass.js +234 -0
- package/examples/jsm/postprocessing/SAOPass.js +20 -0
- package/examples/jsm/postprocessing/SMAAPass.js +16 -0
- package/examples/jsm/postprocessing/SSAARenderPass.js +4 -0
- package/examples/jsm/postprocessing/SavePass.js +17 -1
- package/examples/jsm/postprocessing/ShaderPass.js +8 -0
- package/examples/jsm/postprocessing/TAARenderPass.js +9 -0
- package/examples/jsm/postprocessing/TexturePass.js +8 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +16 -0
- package/examples/jsm/renderers/webgl/nodes/WebGLNodeBuilder.js +39 -16
- package/examples/jsm/renderers/webgpu/WebGPUAnimation.js +58 -0
- package/examples/jsm/renderers/webgpu/WebGPUAttributes.js +63 -5
- package/examples/jsm/renderers/webgpu/WebGPUBackground.js +36 -7
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +47 -12
- package/examples/jsm/renderers/webgpu/nodes/WebGPUNodeBuilder.js +35 -5
- package/examples/jsm/shaders/MMDToonShader.js +0 -2
- package/examples/jsm/shaders/VelocityShader.js +128 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +130 -6
- package/examples/jsm/utils/SceneUtils.js +129 -4
- package/examples/jsm/utils/TextureUtils.js +85 -0
- package/examples/jsm/webxr/OculusHandModel.js +1 -1
- package/examples/jsm/webxr/XRHandMeshModel.js +6 -3
- package/package.json +11 -12
- package/src/Three.js +1 -0
- package/src/audio/AudioContext.js +5 -5
- package/src/cameras/CubeCamera.js +14 -14
- package/src/constants.js +1 -1
- package/src/core/InstancedBufferGeometry.js +1 -7
- package/src/extras/Earcut.js +67 -67
- package/src/helpers/DirectionalLightHelper.js +5 -1
- package/src/helpers/HemisphereLightHelper.js +4 -1
- package/src/helpers/PointLightHelper.js +2 -1
- package/src/helpers/SpotLightHelper.js +4 -2
- package/src/lights/PointLight.js +2 -2
- package/src/lights/SpotLight.js +2 -2
- package/src/loaders/FileLoader.js +4 -1
- package/src/loaders/ObjectLoader.js +5 -1
- package/src/materials/Material.js +1 -1
- package/src/math/Color.js +5 -5
- package/src/math/Matrix3.js +53 -18
- package/src/math/Ray.js +2 -5
- package/src/math/Sphere.js +19 -26
- package/src/objects/InstancedMesh.js +7 -0
- package/src/objects/LOD.js +25 -6
- package/src/renderers/WebGL3DRenderTarget.js +1 -1
- package/src/renderers/WebGLArrayRenderTarget.js +1 -1
- package/src/renderers/WebGLCubeRenderTarget.js +1 -1
- package/src/renderers/WebGLMultipleRenderTargets.js +1 -1
- package/src/renderers/WebGLRenderTarget.js +1 -1
- package/src/renderers/WebGLRenderer.js +36 -62
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +0 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +0 -1
- package/src/renderers/shaders/ShaderChunk/lights_lambert_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js +0 -2
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk.js +3 -0
- package/src/renderers/shaders/ShaderLib/background.glsl.js +7 -2
- package/src/renderers/shaders/ShaderLib/backgroundCube.glsl.js +62 -0
- package/src/renderers/shaders/ShaderLib/cube.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +20 -6
- package/src/renderers/shaders/UniformsLib.js +1 -1
- package/src/renderers/shaders/UniformsUtils.js +15 -0
- package/src/renderers/webgl/WebGLAttributes.js +2 -0
- package/src/renderers/webgl/WebGLBackground.js +15 -7
- package/src/renderers/webgl/WebGLLights.js +0 -4
- package/src/renderers/webgl/WebGLMaterials.js +2 -1
- package/src/renderers/webgl/WebGLShadowMap.js +3 -1
- package/src/renderers/webgl/WebGLState.js +31 -1
- package/src/renderers/webgl/WebGLTextures.js +71 -18
- package/src/renderers/webgl/WebGLUniforms.js +116 -20
- package/src/renderers/webgl/WebGLUtils.js +1 -1
- package/src/renderers/webxr/WebXRController.js +46 -13
- package/src/renderers/webxr/WebXRManager.js +85 -3
- package/src/scenes/Scene.js +8 -0
- package/src/textures/CompressedArrayTexture.js +18 -0
- package/examples/js/libs/lottie_canvas.js +0 -12751
- package/examples/js/shaders/PixelShader.js +0 -51
- package/examples/jsm/shaders/PixelShader.js +0 -44
|
@@ -6,25 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
const Visible = 0;
|
|
8
8
|
const Deleted = 1;
|
|
9
|
-
|
|
10
9
|
const _v1 = new THREE.Vector3();
|
|
11
|
-
|
|
12
10
|
const _line3 = new THREE.Line3();
|
|
13
|
-
|
|
14
11
|
const _plane = new THREE.Plane();
|
|
15
|
-
|
|
16
12
|
const _closestPoint = new THREE.Vector3();
|
|
17
|
-
|
|
18
13
|
const _triangle = new THREE.Triangle();
|
|
19
|
-
|
|
20
14
|
class ConvexHull {
|
|
21
15
|
|
|
22
16
|
constructor() {
|
|
23
17
|
|
|
24
18
|
this.tolerance = - 1;
|
|
25
19
|
this.faces = []; // the generated faces of the convex hull
|
|
26
|
-
|
|
27
20
|
this.newFaces = []; // this array holds the faces that are generated within a single iteration
|
|
21
|
+
|
|
28
22
|
// the vertex lists work as follows:
|
|
29
23
|
//
|
|
30
24
|
// let 'a' and 'b' be 'Face' instances
|
|
@@ -35,7 +29,6 @@
|
|
|
35
29
|
// | |
|
|
36
30
|
// a.outside b.outside
|
|
37
31
|
//
|
|
38
|
-
|
|
39
32
|
this.assigned = new VertexList();
|
|
40
33
|
this.unassigned = new VertexList();
|
|
41
34
|
this.vertices = []; // vertices of the hull (internal representation of given geometry data)
|
|
@@ -45,10 +38,10 @@
|
|
|
45
38
|
setFromPoints( points ) {
|
|
46
39
|
|
|
47
40
|
// The algorithm needs at least four points.
|
|
41
|
+
|
|
48
42
|
if ( points.length >= 4 ) {
|
|
49
43
|
|
|
50
44
|
this.makeEmpty();
|
|
51
|
-
|
|
52
45
|
for ( let i = 0, l = points.length; i < l; i ++ ) {
|
|
53
46
|
|
|
54
47
|
this.vertices.push( new VertexNode( points[ i ] ) );
|
|
@@ -62,7 +55,6 @@
|
|
|
62
55
|
return this;
|
|
63
56
|
|
|
64
57
|
}
|
|
65
|
-
|
|
66
58
|
setFromObject( object ) {
|
|
67
59
|
|
|
68
60
|
const points = [];
|
|
@@ -70,11 +62,9 @@
|
|
|
70
62
|
object.traverse( function ( node ) {
|
|
71
63
|
|
|
72
64
|
const geometry = node.geometry;
|
|
73
|
-
|
|
74
65
|
if ( geometry !== undefined ) {
|
|
75
66
|
|
|
76
67
|
const attribute = geometry.attributes.position;
|
|
77
|
-
|
|
78
68
|
if ( attribute !== undefined ) {
|
|
79
69
|
|
|
80
70
|
for ( let i = 0, l = attribute.count; i < l; i ++ ) {
|
|
@@ -93,14 +83,14 @@
|
|
|
93
83
|
return this.setFromPoints( points );
|
|
94
84
|
|
|
95
85
|
}
|
|
96
|
-
|
|
97
86
|
containsPoint( point ) {
|
|
98
87
|
|
|
99
88
|
const faces = this.faces;
|
|
100
|
-
|
|
101
89
|
for ( let i = 0, l = faces.length; i < l; i ++ ) {
|
|
102
90
|
|
|
103
|
-
const face = faces[ i ];
|
|
91
|
+
const face = faces[ i ];
|
|
92
|
+
|
|
93
|
+
// compute signed distance and check on what half space the point lies
|
|
104
94
|
|
|
105
95
|
if ( face.distanceToPoint( point ) > this.tolerance ) return false;
|
|
106
96
|
|
|
@@ -109,37 +99,48 @@
|
|
|
109
99
|
return true;
|
|
110
100
|
|
|
111
101
|
}
|
|
112
|
-
|
|
113
102
|
intersectRay( ray, target ) {
|
|
114
103
|
|
|
115
104
|
// based on "Fast Ray-Convex Polyhedron Intersection" by Eric Haines, GRAPHICS GEMS II
|
|
105
|
+
|
|
116
106
|
const faces = this.faces;
|
|
117
107
|
let tNear = - Infinity;
|
|
118
108
|
let tFar = Infinity;
|
|
119
|
-
|
|
120
109
|
for ( let i = 0, l = faces.length; i < l; i ++ ) {
|
|
121
110
|
|
|
122
|
-
const face = faces[ i ];
|
|
111
|
+
const face = faces[ i ];
|
|
112
|
+
|
|
113
|
+
// interpret faces as planes for the further computation
|
|
123
114
|
|
|
124
115
|
const vN = face.distanceToPoint( ray.origin );
|
|
125
|
-
const vD = face.normal.dot( ray.direction );
|
|
116
|
+
const vD = face.normal.dot( ray.direction );
|
|
117
|
+
|
|
118
|
+
// if the origin is on the positive side of a plane (so the plane can "see" the origin) and
|
|
126
119
|
// the ray is turned away or parallel to the plane, there is no intersection
|
|
127
120
|
|
|
128
|
-
if ( vN > 0 && vD >= 0 ) return null;
|
|
121
|
+
if ( vN > 0 && vD >= 0 ) return null;
|
|
129
122
|
|
|
130
|
-
|
|
123
|
+
// compute the distance from the ray’s origin to the intersection with the plane
|
|
124
|
+
|
|
125
|
+
const t = vD !== 0 ? - vN / vD : 0;
|
|
126
|
+
|
|
127
|
+
// only proceed if the distance is positive. a negative distance means the intersection point
|
|
131
128
|
// lies "behind" the origin
|
|
132
129
|
|
|
133
|
-
if ( t <= 0 ) continue;
|
|
130
|
+
if ( t <= 0 ) continue;
|
|
131
|
+
|
|
132
|
+
// now categorized plane as front-facing or back-facing
|
|
134
133
|
|
|
135
134
|
if ( vD > 0 ) {
|
|
136
135
|
|
|
137
136
|
// plane faces away from the ray, so this plane is a back-face
|
|
137
|
+
|
|
138
138
|
tFar = Math.min( t, tFar );
|
|
139
139
|
|
|
140
140
|
} else {
|
|
141
141
|
|
|
142
142
|
// front-face
|
|
143
|
+
|
|
143
144
|
tNear = Math.max( t, tNear );
|
|
144
145
|
|
|
145
146
|
}
|
|
@@ -147,13 +148,16 @@
|
|
|
147
148
|
if ( tNear > tFar ) {
|
|
148
149
|
|
|
149
150
|
// if tNear ever is greater than tFar, the ray must miss the convex hull
|
|
151
|
+
|
|
150
152
|
return null;
|
|
151
153
|
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
}
|
|
155
|
-
// always try tNear first since its the closer intersection point
|
|
156
|
+
}
|
|
156
157
|
|
|
158
|
+
// evaluate intersection point
|
|
159
|
+
|
|
160
|
+
// always try tNear first since its the closer intersection point
|
|
157
161
|
|
|
158
162
|
if ( tNear !== - Infinity ) {
|
|
159
163
|
|
|
@@ -168,26 +172,24 @@
|
|
|
168
172
|
return target;
|
|
169
173
|
|
|
170
174
|
}
|
|
171
|
-
|
|
172
175
|
intersectsRay( ray ) {
|
|
173
176
|
|
|
174
177
|
return this.intersectRay( ray, _v1 ) !== null;
|
|
175
178
|
|
|
176
179
|
}
|
|
177
|
-
|
|
178
180
|
makeEmpty() {
|
|
179
181
|
|
|
180
182
|
this.faces = [];
|
|
181
183
|
this.vertices = [];
|
|
182
184
|
return this;
|
|
183
185
|
|
|
184
|
-
}
|
|
186
|
+
}
|
|
185
187
|
|
|
188
|
+
// Adds a vertex to the 'assigned' list of vertices and assigns it to the given face
|
|
186
189
|
|
|
187
190
|
addVertexToFace( vertex, face ) {
|
|
188
191
|
|
|
189
192
|
vertex.face = face;
|
|
190
|
-
|
|
191
193
|
if ( face.outside === null ) {
|
|
192
194
|
|
|
193
195
|
this.assigned.append( vertex );
|
|
@@ -201,22 +203,26 @@
|
|
|
201
203
|
face.outside = vertex;
|
|
202
204
|
return this;
|
|
203
205
|
|
|
204
|
-
}
|
|
206
|
+
}
|
|
205
207
|
|
|
208
|
+
// Removes a vertex from the 'assigned' list of vertices and from the given face
|
|
206
209
|
|
|
207
210
|
removeVertexFromFace( vertex, face ) {
|
|
208
211
|
|
|
209
212
|
if ( vertex === face.outside ) {
|
|
210
213
|
|
|
211
214
|
// fix face.outside link
|
|
215
|
+
|
|
212
216
|
if ( vertex.next !== null && vertex.next.face === face ) {
|
|
213
217
|
|
|
214
218
|
// face has at least 2 outside vertices, move the 'outside' reference
|
|
219
|
+
|
|
215
220
|
face.outside = vertex.next;
|
|
216
221
|
|
|
217
222
|
} else {
|
|
218
223
|
|
|
219
224
|
// vertex was the only outside vertex that face had
|
|
225
|
+
|
|
220
226
|
face.outside = null;
|
|
221
227
|
|
|
222
228
|
}
|
|
@@ -226,24 +232,27 @@
|
|
|
226
232
|
this.assigned.remove( vertex );
|
|
227
233
|
return this;
|
|
228
234
|
|
|
229
|
-
}
|
|
235
|
+
}
|
|
230
236
|
|
|
237
|
+
// Removes all the visible vertices that a given face is able to see which are stored in the 'assigned' vertext list
|
|
231
238
|
|
|
232
239
|
removeAllVerticesFromFace( face ) {
|
|
233
240
|
|
|
234
241
|
if ( face.outside !== null ) {
|
|
235
242
|
|
|
236
243
|
// reference to the first and last vertex of this face
|
|
244
|
+
|
|
237
245
|
const start = face.outside;
|
|
238
246
|
let end = face.outside;
|
|
239
|
-
|
|
240
247
|
while ( end.next !== null && end.next.face === face ) {
|
|
241
248
|
|
|
242
249
|
end = end.next;
|
|
243
250
|
|
|
244
251
|
}
|
|
245
252
|
|
|
246
|
-
this.assigned.removeSubList( start, end );
|
|
253
|
+
this.assigned.removeSubList( start, end );
|
|
254
|
+
|
|
255
|
+
// fix references
|
|
247
256
|
|
|
248
257
|
start.prev = end.next = null;
|
|
249
258
|
face.outside = null;
|
|
@@ -251,31 +260,35 @@
|
|
|
251
260
|
|
|
252
261
|
}
|
|
253
262
|
|
|
254
|
-
}
|
|
263
|
+
}
|
|
255
264
|
|
|
265
|
+
// Removes all the visible vertices that 'face' is able to see
|
|
256
266
|
|
|
257
267
|
deleteFaceVertices( face, absorbingFace ) {
|
|
258
268
|
|
|
259
269
|
const faceVertices = this.removeAllVerticesFromFace( face );
|
|
260
|
-
|
|
261
270
|
if ( faceVertices !== undefined ) {
|
|
262
271
|
|
|
263
272
|
if ( absorbingFace === undefined ) {
|
|
264
273
|
|
|
265
274
|
// mark the vertices to be reassigned to some other face
|
|
275
|
+
|
|
266
276
|
this.unassigned.appendChain( faceVertices );
|
|
267
277
|
|
|
268
278
|
} else {
|
|
269
279
|
|
|
270
280
|
// if there's an absorbing face try to assign as many vertices as possible to it
|
|
271
|
-
let vertex = faceVertices;
|
|
272
281
|
|
|
282
|
+
let vertex = faceVertices;
|
|
273
283
|
do {
|
|
274
284
|
|
|
275
285
|
// we need to buffer the subsequent vertex at this point because the 'vertex.next' reference
|
|
276
286
|
// will be changed by upcoming method calls
|
|
287
|
+
|
|
277
288
|
const nextVertex = vertex.next;
|
|
278
|
-
const distance = absorbingFace.distanceToPoint( vertex.point );
|
|
289
|
+
const distance = absorbingFace.distanceToPoint( vertex.point );
|
|
290
|
+
|
|
291
|
+
// check if 'vertex' is able to see 'absorbingFace'
|
|
279
292
|
|
|
280
293
|
if ( distance > this.tolerance ) {
|
|
281
294
|
|
|
@@ -285,8 +298,9 @@
|
|
|
285
298
|
|
|
286
299
|
this.unassigned.append( vertex );
|
|
287
300
|
|
|
288
|
-
}
|
|
301
|
+
}
|
|
289
302
|
|
|
303
|
+
// now assign next vertex
|
|
290
304
|
|
|
291
305
|
vertex = nextVertex;
|
|
292
306
|
|
|
@@ -298,30 +312,28 @@
|
|
|
298
312
|
|
|
299
313
|
return this;
|
|
300
314
|
|
|
301
|
-
}
|
|
315
|
+
}
|
|
302
316
|
|
|
317
|
+
// Reassigns as many vertices as possible from the unassigned list to the new faces
|
|
303
318
|
|
|
304
319
|
resolveUnassignedPoints( newFaces ) {
|
|
305
320
|
|
|
306
321
|
if ( this.unassigned.isEmpty() === false ) {
|
|
307
322
|
|
|
308
323
|
let vertex = this.unassigned.first();
|
|
309
|
-
|
|
310
324
|
do {
|
|
311
325
|
|
|
312
326
|
// buffer 'next' reference, see .deleteFaceVertices()
|
|
327
|
+
|
|
313
328
|
const nextVertex = vertex.next;
|
|
314
329
|
let maxDistance = this.tolerance;
|
|
315
330
|
let maxFace = null;
|
|
316
|
-
|
|
317
331
|
for ( let i = 0; i < newFaces.length; i ++ ) {
|
|
318
332
|
|
|
319
333
|
const face = newFaces[ i ];
|
|
320
|
-
|
|
321
334
|
if ( face.mark === Visible ) {
|
|
322
335
|
|
|
323
336
|
const distance = face.distanceToPoint( vertex.point );
|
|
324
|
-
|
|
325
337
|
if ( distance > maxDistance ) {
|
|
326
338
|
|
|
327
339
|
maxDistance = distance;
|
|
@@ -333,8 +345,9 @@
|
|
|
333
345
|
|
|
334
346
|
}
|
|
335
347
|
|
|
336
|
-
}
|
|
348
|
+
}
|
|
337
349
|
|
|
350
|
+
// 'maxFace' can be null e.g. if there are identical vertices
|
|
338
351
|
|
|
339
352
|
if ( maxFace !== null ) {
|
|
340
353
|
|
|
@@ -350,15 +363,18 @@
|
|
|
350
363
|
|
|
351
364
|
return this;
|
|
352
365
|
|
|
353
|
-
}
|
|
366
|
+
}
|
|
354
367
|
|
|
368
|
+
// Computes the extremes of a simplex which will be the initial hull
|
|
355
369
|
|
|
356
370
|
computeExtremes() {
|
|
357
371
|
|
|
358
372
|
const min = new THREE.Vector3();
|
|
359
373
|
const max = new THREE.Vector3();
|
|
360
374
|
const minVertices = [];
|
|
361
|
-
const maxVertices = [];
|
|
375
|
+
const maxVertices = [];
|
|
376
|
+
|
|
377
|
+
// initially assume that the first vertex is the min/max
|
|
362
378
|
|
|
363
379
|
for ( let i = 0; i < 3; i ++ ) {
|
|
364
380
|
|
|
@@ -367,12 +383,16 @@
|
|
|
367
383
|
}
|
|
368
384
|
|
|
369
385
|
min.copy( this.vertices[ 0 ].point );
|
|
370
|
-
max.copy( this.vertices[ 0 ].point );
|
|
386
|
+
max.copy( this.vertices[ 0 ].point );
|
|
387
|
+
|
|
388
|
+
// compute the min/max vertex on all six directions
|
|
371
389
|
|
|
372
390
|
for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
|
|
373
391
|
|
|
374
392
|
const vertex = this.vertices[ i ];
|
|
375
|
-
const point = vertex.point;
|
|
393
|
+
const point = vertex.point;
|
|
394
|
+
|
|
395
|
+
// update the min coordinates
|
|
376
396
|
|
|
377
397
|
for ( let j = 0; j < 3; j ++ ) {
|
|
378
398
|
|
|
@@ -383,8 +403,9 @@
|
|
|
383
403
|
|
|
384
404
|
}
|
|
385
405
|
|
|
386
|
-
}
|
|
406
|
+
}
|
|
387
407
|
|
|
408
|
+
// update the max coordinates
|
|
388
409
|
|
|
389
410
|
for ( let j = 0; j < 3; j ++ ) {
|
|
390
411
|
|
|
@@ -397,8 +418,9 @@
|
|
|
397
418
|
|
|
398
419
|
}
|
|
399
420
|
|
|
400
|
-
}
|
|
421
|
+
}
|
|
401
422
|
|
|
423
|
+
// use min/max vectors to compute an optimal epsilon
|
|
402
424
|
|
|
403
425
|
this.tolerance = 3 * Number.EPSILON * ( Math.max( Math.abs( min.x ), Math.abs( max.x ) ) + Math.max( Math.abs( min.y ), Math.abs( max.y ) ) + Math.max( Math.abs( min.z ), Math.abs( max.z ) ) );
|
|
404
426
|
return {
|
|
@@ -406,27 +428,28 @@
|
|
|
406
428
|
max: maxVertices
|
|
407
429
|
};
|
|
408
430
|
|
|
409
|
-
}
|
|
410
|
-
// that are candidates to form part of the hull
|
|
431
|
+
}
|
|
411
432
|
|
|
433
|
+
// Computes the initial simplex assigning to its faces all the points
|
|
434
|
+
// that are candidates to form part of the hull
|
|
412
435
|
|
|
413
436
|
computeInitialHull() {
|
|
414
437
|
|
|
415
438
|
const vertices = this.vertices;
|
|
416
439
|
const extremes = this.computeExtremes();
|
|
417
440
|
const min = extremes.min;
|
|
418
|
-
const max = extremes.max;
|
|
441
|
+
const max = extremes.max;
|
|
442
|
+
|
|
443
|
+
// 1. Find the two vertices 'v0' and 'v1' with the greatest 1d separation
|
|
419
444
|
// (max.x - min.x)
|
|
420
445
|
// (max.y - min.y)
|
|
421
446
|
// (max.z - min.z)
|
|
422
447
|
|
|
423
448
|
let maxDistance = 0;
|
|
424
449
|
let index = 0;
|
|
425
|
-
|
|
426
450
|
for ( let i = 0; i < 3; i ++ ) {
|
|
427
451
|
|
|
428
452
|
const distance = max[ i ].point.getComponent( i ) - min[ i ].point.getComponent( i );
|
|
429
|
-
|
|
430
453
|
if ( distance > maxDistance ) {
|
|
431
454
|
|
|
432
455
|
maxDistance = distance;
|
|
@@ -439,22 +462,19 @@
|
|
|
439
462
|
const v0 = min[ index ];
|
|
440
463
|
const v1 = max[ index ];
|
|
441
464
|
let v2;
|
|
442
|
-
let v3;
|
|
465
|
+
let v3;
|
|
443
466
|
|
|
444
|
-
|
|
467
|
+
// 2. The next vertex 'v2' is the one farthest to the line formed by 'v0' and 'v1'
|
|
445
468
|
|
|
469
|
+
maxDistance = 0;
|
|
446
470
|
_line3.set( v0.point, v1.point );
|
|
447
|
-
|
|
448
471
|
for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
|
|
449
472
|
|
|
450
473
|
const vertex = vertices[ i ];
|
|
451
|
-
|
|
452
474
|
if ( vertex !== v0 && vertex !== v1 ) {
|
|
453
475
|
|
|
454
476
|
_line3.closestPointToPoint( vertex.point, true, _closestPoint );
|
|
455
|
-
|
|
456
477
|
const distance = _closestPoint.distanceToSquared( vertex.point );
|
|
457
|
-
|
|
458
478
|
if ( distance > maxDistance ) {
|
|
459
479
|
|
|
460
480
|
maxDistance = distance;
|
|
@@ -464,21 +484,18 @@
|
|
|
464
484
|
|
|
465
485
|
}
|
|
466
486
|
|
|
467
|
-
}
|
|
487
|
+
}
|
|
468
488
|
|
|
489
|
+
// 3. The next vertex 'v3' is the one farthest to the plane 'v0', 'v1', 'v2'
|
|
469
490
|
|
|
470
491
|
maxDistance = - 1;
|
|
471
|
-
|
|
472
492
|
_plane.setFromCoplanarPoints( v0.point, v1.point, v2.point );
|
|
473
|
-
|
|
474
493
|
for ( let i = 0, l = this.vertices.length; i < l; i ++ ) {
|
|
475
494
|
|
|
476
495
|
const vertex = vertices[ i ];
|
|
477
|
-
|
|
478
496
|
if ( vertex !== v0 && vertex !== v1 && vertex !== v2 ) {
|
|
479
497
|
|
|
480
498
|
const distance = Math.abs( _plane.distanceToPoint( vertex.point ) );
|
|
481
|
-
|
|
482
499
|
if ( distance > maxDistance ) {
|
|
483
500
|
|
|
484
501
|
maxDistance = distance;
|
|
@@ -491,17 +508,23 @@
|
|
|
491
508
|
}
|
|
492
509
|
|
|
493
510
|
const faces = [];
|
|
494
|
-
|
|
495
511
|
if ( _plane.distanceToPoint( v3.point ) < 0 ) {
|
|
496
512
|
|
|
497
513
|
// the face is not able to see the point so 'plane.normal' is pointing outside the tetrahedron
|
|
498
|
-
|
|
514
|
+
|
|
515
|
+
faces.push( Face.create( v0, v1, v2 ), Face.create( v3, v1, v0 ), Face.create( v3, v2, v1 ), Face.create( v3, v0, v2 ) );
|
|
516
|
+
|
|
517
|
+
// set the twin edge
|
|
499
518
|
|
|
500
519
|
for ( let i = 0; i < 3; i ++ ) {
|
|
501
520
|
|
|
502
|
-
const j = ( i + 1 ) % 3;
|
|
521
|
+
const j = ( i + 1 ) % 3;
|
|
503
522
|
|
|
504
|
-
|
|
523
|
+
// join face[ i ] i > 0, with the first face
|
|
524
|
+
|
|
525
|
+
faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( j ) );
|
|
526
|
+
|
|
527
|
+
// join face[ i ] with face[ i + 1 ], 1 <= i <= 3
|
|
505
528
|
|
|
506
529
|
faces[ i + 1 ].getEdge( 1 ).setTwin( faces[ j + 1 ].getEdge( 0 ) );
|
|
507
530
|
|
|
@@ -510,41 +533,47 @@
|
|
|
510
533
|
} else {
|
|
511
534
|
|
|
512
535
|
// the face is able to see the point so 'plane.normal' is pointing inside the tetrahedron
|
|
513
|
-
|
|
536
|
+
|
|
537
|
+
faces.push( Face.create( v0, v2, v1 ), Face.create( v3, v0, v1 ), Face.create( v3, v1, v2 ), Face.create( v3, v2, v0 ) );
|
|
538
|
+
|
|
539
|
+
// set the twin edge
|
|
514
540
|
|
|
515
541
|
for ( let i = 0; i < 3; i ++ ) {
|
|
516
542
|
|
|
517
|
-
const j = ( i + 1 ) % 3;
|
|
543
|
+
const j = ( i + 1 ) % 3;
|
|
544
|
+
|
|
545
|
+
// join face[ i ] i > 0, with the first face
|
|
546
|
+
|
|
547
|
+
faces[ i + 1 ].getEdge( 2 ).setTwin( faces[ 0 ].getEdge( ( 3 - i ) % 3 ) );
|
|
518
548
|
|
|
519
|
-
|
|
549
|
+
// join face[ i ] with face[ i + 1 ]
|
|
520
550
|
|
|
521
551
|
faces[ i + 1 ].getEdge( 0 ).setTwin( faces[ j + 1 ].getEdge( 1 ) );
|
|
522
552
|
|
|
523
553
|
}
|
|
524
554
|
|
|
525
|
-
}
|
|
555
|
+
}
|
|
526
556
|
|
|
557
|
+
// the initial hull is the tetrahedron
|
|
527
558
|
|
|
528
559
|
for ( let i = 0; i < 4; i ++ ) {
|
|
529
560
|
|
|
530
561
|
this.faces.push( faces[ i ] );
|
|
531
562
|
|
|
532
|
-
}
|
|
563
|
+
}
|
|
533
564
|
|
|
565
|
+
// initial assignment of vertices to the faces of the tetrahedron
|
|
534
566
|
|
|
535
567
|
for ( let i = 0, l = vertices.length; i < l; i ++ ) {
|
|
536
568
|
|
|
537
569
|
const vertex = vertices[ i ];
|
|
538
|
-
|
|
539
570
|
if ( vertex !== v0 && vertex !== v1 && vertex !== v2 && vertex !== v3 ) {
|
|
540
571
|
|
|
541
572
|
maxDistance = this.tolerance;
|
|
542
573
|
let maxFace = null;
|
|
543
|
-
|
|
544
574
|
for ( let j = 0; j < 4; j ++ ) {
|
|
545
575
|
|
|
546
576
|
const distance = this.faces[ j ].distanceToPoint( vertex.point );
|
|
547
|
-
|
|
548
577
|
if ( distance > maxDistance ) {
|
|
549
578
|
|
|
550
579
|
maxDistance = distance;
|
|
@@ -566,17 +595,16 @@
|
|
|
566
595
|
|
|
567
596
|
return this;
|
|
568
597
|
|
|
569
|
-
}
|
|
598
|
+
}
|
|
570
599
|
|
|
600
|
+
// Removes inactive faces
|
|
571
601
|
|
|
572
602
|
reindexFaces() {
|
|
573
603
|
|
|
574
604
|
const activeFaces = [];
|
|
575
|
-
|
|
576
605
|
for ( let i = 0; i < this.faces.length; i ++ ) {
|
|
577
606
|
|
|
578
607
|
const face = this.faces[ i ];
|
|
579
|
-
|
|
580
608
|
if ( face.mark === Visible ) {
|
|
581
609
|
|
|
582
610
|
activeFaces.push( face );
|
|
@@ -588,24 +616,29 @@
|
|
|
588
616
|
this.faces = activeFaces;
|
|
589
617
|
return this;
|
|
590
618
|
|
|
591
|
-
}
|
|
619
|
+
}
|
|
592
620
|
|
|
621
|
+
// Finds the next vertex to create faces with the current hull
|
|
593
622
|
|
|
594
623
|
nextVertexToAdd() {
|
|
595
624
|
|
|
596
625
|
// if the 'assigned' list of vertices is empty, no vertices are left. return with 'undefined'
|
|
626
|
+
|
|
597
627
|
if ( this.assigned.isEmpty() === false ) {
|
|
598
628
|
|
|
599
629
|
let eyeVertex,
|
|
600
|
-
maxDistance = 0;
|
|
630
|
+
maxDistance = 0;
|
|
631
|
+
|
|
632
|
+
// grap the first available face and start with the first visible vertex of that face
|
|
601
633
|
|
|
602
634
|
const eyeFace = this.assigned.first().face;
|
|
603
|
-
let vertex = eyeFace.outside;
|
|
635
|
+
let vertex = eyeFace.outside;
|
|
636
|
+
|
|
637
|
+
// now calculate the farthest vertex that face can see
|
|
604
638
|
|
|
605
639
|
do {
|
|
606
640
|
|
|
607
641
|
const distance = eyeFace.distanceToPoint( vertex.point );
|
|
608
|
-
|
|
609
642
|
if ( distance > maxDistance ) {
|
|
610
643
|
|
|
611
644
|
maxDistance = distance;
|
|
@@ -621,18 +654,19 @@
|
|
|
621
654
|
|
|
622
655
|
}
|
|
623
656
|
|
|
624
|
-
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
// Computes a chain of half edges in CCW order called the 'horizon'.
|
|
625
660
|
// For an edge to be part of the horizon it must join a face that can see
|
|
626
661
|
// 'eyePoint' and a face that cannot see 'eyePoint'.
|
|
627
662
|
|
|
628
|
-
|
|
629
663
|
computeHorizon( eyePoint, crossEdge, face, horizon ) {
|
|
630
664
|
|
|
631
665
|
// moves face's vertices to the 'unassigned' vertex list
|
|
666
|
+
|
|
632
667
|
this.deleteFaceVertices( face );
|
|
633
668
|
face.mark = Deleted;
|
|
634
669
|
let edge;
|
|
635
|
-
|
|
636
670
|
if ( crossEdge === null ) {
|
|
637
671
|
|
|
638
672
|
edge = crossEdge = face.getEdge( 0 );
|
|
@@ -641,6 +675,7 @@
|
|
|
641
675
|
|
|
642
676
|
// start from the next edge since 'crossEdge' was already analyzed
|
|
643
677
|
// (actually 'crossEdge.twin' was the edge who called this method recursively)
|
|
678
|
+
|
|
644
679
|
edge = crossEdge.next;
|
|
645
680
|
|
|
646
681
|
}
|
|
@@ -649,17 +684,18 @@
|
|
|
649
684
|
|
|
650
685
|
const twinEdge = edge.twin;
|
|
651
686
|
const oppositeFace = twinEdge.face;
|
|
652
|
-
|
|
653
687
|
if ( oppositeFace.mark === Visible ) {
|
|
654
688
|
|
|
655
689
|
if ( oppositeFace.distanceToPoint( eyePoint ) > this.tolerance ) {
|
|
656
690
|
|
|
657
691
|
// the opposite face can see the vertex, so proceed with next edge
|
|
692
|
+
|
|
658
693
|
this.computeHorizon( eyePoint, twinEdge, oppositeFace, horizon );
|
|
659
694
|
|
|
660
695
|
} else {
|
|
661
696
|
|
|
662
697
|
// the opposite face can't see the vertex, so this edge is part of the horizon
|
|
698
|
+
|
|
663
699
|
horizon.push( edge );
|
|
664
700
|
|
|
665
701
|
}
|
|
@@ -672,34 +708,39 @@
|
|
|
672
708
|
|
|
673
709
|
return this;
|
|
674
710
|
|
|
675
|
-
}
|
|
711
|
+
}
|
|
676
712
|
|
|
713
|
+
// Creates a face with the vertices 'eyeVertex.point', 'horizonEdge.tail' and 'horizonEdge.head' in CCW order
|
|
677
714
|
|
|
678
715
|
addAdjoiningFace( eyeVertex, horizonEdge ) {
|
|
679
716
|
|
|
680
717
|
// all the half edges are created in ccw order thus the face is always pointing outside the hull
|
|
718
|
+
|
|
681
719
|
const face = Face.create( eyeVertex, horizonEdge.tail(), horizonEdge.head() );
|
|
682
|
-
this.faces.push( face );
|
|
720
|
+
this.faces.push( face );
|
|
721
|
+
|
|
722
|
+
// join face.getEdge( - 1 ) with the horizon's opposite edge face.getEdge( - 1 ) = face.getEdge( 2 )
|
|
683
723
|
|
|
684
724
|
face.getEdge( - 1 ).setTwin( horizonEdge.twin );
|
|
685
725
|
return face.getEdge( 0 ); // the half edge whose vertex is the eyeVertex
|
|
686
726
|
|
|
687
|
-
}
|
|
688
|
-
// horizon opposite face and the face on the left/right
|
|
727
|
+
}
|
|
689
728
|
|
|
729
|
+
// Adds 'horizon.length' faces to the hull, each face will be linked with the
|
|
730
|
+
// horizon opposite face and the face on the left/right
|
|
690
731
|
|
|
691
732
|
addNewFaces( eyeVertex, horizon ) {
|
|
692
733
|
|
|
693
734
|
this.newFaces = [];
|
|
694
735
|
let firstSideEdge = null;
|
|
695
736
|
let previousSideEdge = null;
|
|
696
|
-
|
|
697
737
|
for ( let i = 0; i < horizon.length; i ++ ) {
|
|
698
738
|
|
|
699
|
-
const horizonEdge = horizon[ i ];
|
|
739
|
+
const horizonEdge = horizon[ i ];
|
|
700
740
|
|
|
701
|
-
|
|
741
|
+
// returns the right side edge
|
|
702
742
|
|
|
743
|
+
const sideEdge = this.addAdjoiningFace( eyeVertex, horizonEdge );
|
|
703
744
|
if ( firstSideEdge === null ) {
|
|
704
745
|
|
|
705
746
|
firstSideEdge = sideEdge;
|
|
@@ -707,6 +748,7 @@
|
|
|
707
748
|
} else {
|
|
708
749
|
|
|
709
750
|
// joins face.getEdge( 1 ) with previousFace.getEdge( 0 )
|
|
751
|
+
|
|
710
752
|
sideEdge.next.setTwin( previousSideEdge );
|
|
711
753
|
|
|
712
754
|
}
|
|
@@ -714,29 +756,34 @@
|
|
|
714
756
|
this.newFaces.push( sideEdge.face );
|
|
715
757
|
previousSideEdge = sideEdge;
|
|
716
758
|
|
|
717
|
-
}
|
|
759
|
+
}
|
|
718
760
|
|
|
761
|
+
// perform final join of new faces
|
|
719
762
|
|
|
720
763
|
firstSideEdge.next.setTwin( previousSideEdge );
|
|
721
764
|
return this;
|
|
722
765
|
|
|
723
|
-
}
|
|
766
|
+
}
|
|
724
767
|
|
|
768
|
+
// Adds a vertex to the hull
|
|
725
769
|
|
|
726
770
|
addVertexToHull( eyeVertex ) {
|
|
727
771
|
|
|
728
772
|
const horizon = [];
|
|
729
|
-
this.unassigned.clear();
|
|
773
|
+
this.unassigned.clear();
|
|
774
|
+
|
|
775
|
+
// remove 'eyeVertex' from 'eyeVertex.face' so that it can't be added to the 'unassigned' vertex list
|
|
730
776
|
|
|
731
777
|
this.removeVertexFromFace( eyeVertex, eyeVertex.face );
|
|
732
778
|
this.computeHorizon( eyeVertex.point, null, eyeVertex.face, horizon );
|
|
733
|
-
this.addNewFaces( eyeVertex, horizon );
|
|
779
|
+
this.addNewFaces( eyeVertex, horizon );
|
|
780
|
+
|
|
781
|
+
// reassign 'unassigned' vertices to the new faces
|
|
734
782
|
|
|
735
783
|
this.resolveUnassignedPoints( this.newFaces );
|
|
736
784
|
return this;
|
|
737
785
|
|
|
738
786
|
}
|
|
739
|
-
|
|
740
787
|
cleanup() {
|
|
741
788
|
|
|
742
789
|
this.assigned.clear();
|
|
@@ -745,11 +792,12 @@
|
|
|
745
792
|
return this;
|
|
746
793
|
|
|
747
794
|
}
|
|
748
|
-
|
|
749
795
|
compute() {
|
|
750
796
|
|
|
751
797
|
let vertex;
|
|
752
|
-
this.computeInitialHull();
|
|
798
|
+
this.computeInitialHull();
|
|
799
|
+
|
|
800
|
+
// add all available vertices gradually to the hull
|
|
753
801
|
|
|
754
802
|
while ( ( vertex = this.nextVertexToAdd() ) !== undefined ) {
|
|
755
803
|
|
|
@@ -763,8 +811,9 @@
|
|
|
763
811
|
|
|
764
812
|
}
|
|
765
813
|
|
|
766
|
-
}
|
|
814
|
+
}
|
|
767
815
|
|
|
816
|
+
//
|
|
768
817
|
|
|
769
818
|
class Face {
|
|
770
819
|
|
|
@@ -774,34 +823,33 @@
|
|
|
774
823
|
this.midpoint = new THREE.Vector3();
|
|
775
824
|
this.area = 0;
|
|
776
825
|
this.constant = 0; // signed distance from face to the origin
|
|
777
|
-
|
|
778
826
|
this.outside = null; // reference to a vertex in a vertex list this face can see
|
|
779
|
-
|
|
780
827
|
this.mark = Visible;
|
|
781
828
|
this.edge = null;
|
|
782
829
|
|
|
783
830
|
}
|
|
784
|
-
|
|
785
831
|
static create( a, b, c ) {
|
|
786
832
|
|
|
787
833
|
const face = new Face();
|
|
788
834
|
const e0 = new HalfEdge( a, face );
|
|
789
835
|
const e1 = new HalfEdge( b, face );
|
|
790
|
-
const e2 = new HalfEdge( c, face );
|
|
836
|
+
const e2 = new HalfEdge( c, face );
|
|
837
|
+
|
|
838
|
+
// join edges
|
|
791
839
|
|
|
792
840
|
e0.next = e2.prev = e1;
|
|
793
841
|
e1.next = e0.prev = e2;
|
|
794
|
-
e2.next = e1.prev = e0;
|
|
842
|
+
e2.next = e1.prev = e0;
|
|
843
|
+
|
|
844
|
+
// main half edge reference
|
|
795
845
|
|
|
796
846
|
face.edge = e0;
|
|
797
847
|
return face.compute();
|
|
798
848
|
|
|
799
849
|
}
|
|
800
|
-
|
|
801
850
|
getEdge( i ) {
|
|
802
851
|
|
|
803
852
|
let edge = this.edge;
|
|
804
|
-
|
|
805
853
|
while ( i > 0 ) {
|
|
806
854
|
|
|
807
855
|
edge = edge.next;
|
|
@@ -819,33 +867,28 @@
|
|
|
819
867
|
return edge;
|
|
820
868
|
|
|
821
869
|
}
|
|
822
|
-
|
|
823
870
|
compute() {
|
|
824
871
|
|
|
825
872
|
const a = this.edge.tail();
|
|
826
873
|
const b = this.edge.head();
|
|
827
874
|
const c = this.edge.next.head();
|
|
828
|
-
|
|
829
875
|
_triangle.set( a.point, b.point, c.point );
|
|
830
|
-
|
|
831
876
|
_triangle.getNormal( this.normal );
|
|
832
|
-
|
|
833
877
|
_triangle.getMidpoint( this.midpoint );
|
|
834
|
-
|
|
835
878
|
this.area = _triangle.getArea();
|
|
836
879
|
this.constant = this.normal.dot( this.midpoint );
|
|
837
880
|
return this;
|
|
838
881
|
|
|
839
882
|
}
|
|
840
|
-
|
|
841
883
|
distanceToPoint( point ) {
|
|
842
884
|
|
|
843
885
|
return this.normal.dot( point ) - this.constant;
|
|
844
886
|
|
|
845
887
|
}
|
|
846
888
|
|
|
847
|
-
}
|
|
889
|
+
}
|
|
848
890
|
|
|
891
|
+
// Entity for a Doubly-Connected Edge List (DCEL).
|
|
849
892
|
|
|
850
893
|
class HalfEdge {
|
|
851
894
|
|
|
@@ -858,24 +901,20 @@
|
|
|
858
901
|
this.face = face;
|
|
859
902
|
|
|
860
903
|
}
|
|
861
|
-
|
|
862
904
|
head() {
|
|
863
905
|
|
|
864
906
|
return this.vertex;
|
|
865
907
|
|
|
866
908
|
}
|
|
867
|
-
|
|
868
909
|
tail() {
|
|
869
910
|
|
|
870
911
|
return this.prev ? this.prev.vertex : null;
|
|
871
912
|
|
|
872
913
|
}
|
|
873
|
-
|
|
874
914
|
length() {
|
|
875
915
|
|
|
876
916
|
const head = this.head();
|
|
877
917
|
const tail = this.tail();
|
|
878
|
-
|
|
879
918
|
if ( tail !== null ) {
|
|
880
919
|
|
|
881
920
|
return tail.point.distanceTo( head.point );
|
|
@@ -885,12 +924,10 @@
|
|
|
885
924
|
return - 1;
|
|
886
925
|
|
|
887
926
|
}
|
|
888
|
-
|
|
889
927
|
lengthSquared() {
|
|
890
928
|
|
|
891
929
|
const head = this.head();
|
|
892
930
|
const tail = this.tail();
|
|
893
|
-
|
|
894
931
|
if ( tail !== null ) {
|
|
895
932
|
|
|
896
933
|
return tail.point.distanceToSquared( head.point );
|
|
@@ -900,7 +937,6 @@
|
|
|
900
937
|
return - 1;
|
|
901
938
|
|
|
902
939
|
}
|
|
903
|
-
|
|
904
940
|
setTwin( edge ) {
|
|
905
941
|
|
|
906
942
|
this.twin = edge;
|
|
@@ -909,8 +945,9 @@
|
|
|
909
945
|
|
|
910
946
|
}
|
|
911
947
|
|
|
912
|
-
}
|
|
948
|
+
}
|
|
913
949
|
|
|
950
|
+
// A vertex as a double linked list node.
|
|
914
951
|
|
|
915
952
|
class VertexNode {
|
|
916
953
|
|
|
@@ -923,8 +960,9 @@
|
|
|
923
960
|
|
|
924
961
|
}
|
|
925
962
|
|
|
926
|
-
}
|
|
963
|
+
}
|
|
927
964
|
|
|
965
|
+
// A double linked list that contains vertex nodes.
|
|
928
966
|
|
|
929
967
|
class VertexList {
|
|
930
968
|
|
|
@@ -934,32 +972,29 @@
|
|
|
934
972
|
this.tail = null;
|
|
935
973
|
|
|
936
974
|
}
|
|
937
|
-
|
|
938
975
|
first() {
|
|
939
976
|
|
|
940
977
|
return this.head;
|
|
941
978
|
|
|
942
979
|
}
|
|
943
|
-
|
|
944
980
|
last() {
|
|
945
981
|
|
|
946
982
|
return this.tail;
|
|
947
983
|
|
|
948
984
|
}
|
|
949
|
-
|
|
950
985
|
clear() {
|
|
951
986
|
|
|
952
987
|
this.head = this.tail = null;
|
|
953
988
|
return this;
|
|
954
989
|
|
|
955
|
-
}
|
|
990
|
+
}
|
|
956
991
|
|
|
992
|
+
// Inserts a vertex before the target vertex
|
|
957
993
|
|
|
958
994
|
insertBefore( target, vertex ) {
|
|
959
995
|
|
|
960
996
|
vertex.prev = target.prev;
|
|
961
997
|
vertex.next = target;
|
|
962
|
-
|
|
963
998
|
if ( vertex.prev === null ) {
|
|
964
999
|
|
|
965
1000
|
this.head = vertex;
|
|
@@ -973,14 +1008,14 @@
|
|
|
973
1008
|
target.prev = vertex;
|
|
974
1009
|
return this;
|
|
975
1010
|
|
|
976
|
-
}
|
|
1011
|
+
}
|
|
977
1012
|
|
|
1013
|
+
// Inserts a vertex after the target vertex
|
|
978
1014
|
|
|
979
1015
|
insertAfter( target, vertex ) {
|
|
980
1016
|
|
|
981
1017
|
vertex.prev = target;
|
|
982
1018
|
vertex.next = target.next;
|
|
983
|
-
|
|
984
1019
|
if ( vertex.next === null ) {
|
|
985
1020
|
|
|
986
1021
|
this.tail = vertex;
|
|
@@ -994,8 +1029,9 @@
|
|
|
994
1029
|
target.next = vertex;
|
|
995
1030
|
return this;
|
|
996
1031
|
|
|
997
|
-
}
|
|
1032
|
+
}
|
|
998
1033
|
|
|
1034
|
+
// Appends a vertex to the end of the linked list
|
|
999
1035
|
|
|
1000
1036
|
append( vertex ) {
|
|
1001
1037
|
|
|
@@ -1015,8 +1051,9 @@
|
|
|
1015
1051
|
this.tail = vertex;
|
|
1016
1052
|
return this;
|
|
1017
1053
|
|
|
1018
|
-
}
|
|
1054
|
+
}
|
|
1019
1055
|
|
|
1056
|
+
// Appends a chain of vertices where 'vertex' is the head.
|
|
1020
1057
|
|
|
1021
1058
|
appendChain( vertex ) {
|
|
1022
1059
|
|
|
@@ -1030,7 +1067,9 @@
|
|
|
1030
1067
|
|
|
1031
1068
|
}
|
|
1032
1069
|
|
|
1033
|
-
vertex.prev = this.tail;
|
|
1070
|
+
vertex.prev = this.tail;
|
|
1071
|
+
|
|
1072
|
+
// ensure that the 'tail' reference points to the last vertex of the chain
|
|
1034
1073
|
|
|
1035
1074
|
while ( vertex.next !== null ) {
|
|
1036
1075
|
|
|
@@ -1041,8 +1080,9 @@
|
|
|
1041
1080
|
this.tail = vertex;
|
|
1042
1081
|
return this;
|
|
1043
1082
|
|
|
1044
|
-
}
|
|
1083
|
+
}
|
|
1045
1084
|
|
|
1085
|
+
// Removes a vertex from the linked list
|
|
1046
1086
|
|
|
1047
1087
|
remove( vertex ) {
|
|
1048
1088
|
|
|
@@ -1068,8 +1108,9 @@
|
|
|
1068
1108
|
|
|
1069
1109
|
return this;
|
|
1070
1110
|
|
|
1071
|
-
}
|
|
1111
|
+
}
|
|
1072
1112
|
|
|
1113
|
+
// Removes a list of vertices whose 'head' is 'a' and whose 'tail' is b
|
|
1073
1114
|
|
|
1074
1115
|
removeSubList( a, b ) {
|
|
1075
1116
|
|
|
@@ -1096,7 +1137,6 @@
|
|
|
1096
1137
|
return this;
|
|
1097
1138
|
|
|
1098
1139
|
}
|
|
1099
|
-
|
|
1100
1140
|
isEmpty() {
|
|
1101
1141
|
|
|
1102
1142
|
return this.head === null;
|
|
@@ -1106,5 +1146,9 @@
|
|
|
1106
1146
|
}
|
|
1107
1147
|
|
|
1108
1148
|
THREE.ConvexHull = ConvexHull;
|
|
1149
|
+
THREE.Face = Face;
|
|
1150
|
+
THREE.HalfEdge = HalfEdge;
|
|
1151
|
+
THREE.VertexList = VertexList;
|
|
1152
|
+
THREE.VertexNode = VertexNode;
|
|
1109
1153
|
|
|
1110
1154
|
} )();
|