three.js - rotate particular part of geometry

冷暖自知 提交于 2019-12-24 12:51:40

问题


I've created a tube geometry with following function.

function plotPath()
        {                                           
            var obj = getPath();
            var segments = 60;
            var closed = false;
            var debug = false;
            var radiusSegments = 12;
            var tube;
            var points = [];
            var x=0,y=0,z=0;            

            for(var i=0; i<obj.path.length; i++)
            {                               
                console.log(obj.path[i].point);
                points.push(obj.path[i].point);                                                                                 
            }

            extrudePath = new THREE.SplineCurve3(points);
            tube = new THREE.TubeGeometry(extrudePath, segments, 10, radiusSegments, closed, debug);                                

            tubeMesh = new THREE.Mesh(tube ,new THREE.MeshBasicMaterial({
                color: 0x000000, side: THREE.DoubleSide,
                opacity: 0.5, transparent: false, wireframe: true}));

            tubeMesh.add(new THREE.AxisHelper());
            var v = new THREE.Vector3(1,0,0).normalize();           
            tubeMesh.applyMatrix(matrix.makeRotationAxis(v, 0));
            tubeMesh.applyMatrix(matrix.makeTranslation(-500,0,0));

            if ( tube.debug ) tubeMesh.add( tube.debug );                                   
            scene.add(tubeMesh);
            objects.push(tubeMesh);                                         
        } 

Here extrudePath is built with points passed as argument to THREE.SplineCurve3(points). Points are stored in external javascript file as JSON format. In this tube geometry I can rotate/spin the initial part of it. When I zoom out and try to rotate/spin the middle or end part of tube, I can't. The rotation is weird.

How can I rotate/spin particular part of tube geometry ? Do I need to break it in some small parts to make rotation smooth ? Or is it possible to add THREE.AxisHelper at each point to make rotation/spin look easier ?

来源:https://stackoverflow.com/questions/12969119/three-js-rotate-particular-part-of-geometry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!