Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Web vtk和three.js同步_Web_Three.js_Vtk - Fatal编程技术网

Web vtk和three.js同步

Web vtk和three.js同步,web,three.js,vtk,Web,Three.js,Vtk,我正在开发一个web应用程序,它允许您从服务器向客户端发送制作的图片​​用VTK。但是你怎么知道互联网的速度取决于速度,嗯,文件系统。为了加快工作速度,我决定添加到客户端webGL。现在问题出现在数据同步上。在VTK中,摄像机围绕对象旋转,经过多次尝试后,我无法在客户端执行此操作,摄像机工作良好(随着摄像机坐标的变化),但能够正确地旋转对象。在这方面,有些问题: 1.你对照相机有什么想法吗? 2.或者很容易在vtk中更改旋转 更新: 我制作了一个摄像头,它与vtk同步,但我知道我的viewUp向

我正在开发一个web应用程序,它允许您从服务器向客户端发送制作的图片​​用VTK。但是你怎么知道互联网的速度取决于速度,嗯,文件系统。为了加快工作速度,我决定添加到客户端webGL。现在问题出现在数据同步上。在VTK中,摄像机围绕对象旋转,经过多次尝试后,我无法在客户端执行此操作,摄像机工作良好(随着摄像机坐标的变化),但能够正确地旋转对象。在这方面,有些问题: 1.你对照相机有什么想法吗? 2.或者很容易在vtk中更改旋转

更新: 我制作了一个摄像头,它与vtk同步,但我知道我的viewUp向量有问题,在客户端上,当phi上升超过90后,它变成了(0,-1,0),当我设置viewUp(0,-1,0)时,没有任何变化

Javascript: 更新2: 现在我在旋转方面也有一些问题。模型只是在旋转时改变了大小

解决方法:将模型移动到中心
完全解决了)VTK对你有什么好处?对我来说是一种文件格式。@mrdoob如果你将鼠标悬停在标签上,它会给你一个简短的提示。这个问题有点不清楚。你能给你的问题和图片添加更多的结构吗?主要的问题是如何同步客户端和服务器上的旋转过程。在它当前的形式中,我们捕捉到客户端上的鼠标移动,将请求发送到包含dx和dy的服务器,然后返回渲染图像。由于我最初没有参与这个项目,我对VTK不是很熟悉。但至少我意识到,在VTK对象中,旋转是通过在球坐标系中旋转相机来实现的。所以我问,我如何同步旋转,因为我无法编写与VTK中相同的相机
    renderer.domElement.addEventListener('mousemove', function(e) {
            e.preventDefault();

            if ( paused ) {
                return;
            }

            if ( !moving ) {
                lastLeft = e.clientX;
                lastTop = e.clientY;
                moving = true;
            }

            // horizontal
            theta = - ( ( event.clientX - lastLeft ) * 360 /window.innerWidth ) + onMouseDownTheta;
            phi = ( ( event.clientY - lastTop ) * 360 /window.innerHeight ) + onMouseDownPhi;



            //phi = Math.min( 90, Math.max( -90, phi ) );
            var cosPhi = Math.cos( phi * Math.PI / 180 );
            var sinPhi = Math.sin( phi * Math.PI / 180 );
            var sinTheta = Math.sin( theta * Math.PI / 180 );
            var cosTheta = Math.cos( theta * Math.PI / 180 );


            //trace('data_move');trace(radious);trace(theta);trace(phi);trace(camera.up);   

            camera.position.x = radious * cosTheta * cosPhi;
            camera.position.y = radious * sinPhi;
            camera.position.z = radious * sinTheta * cosPhi;

            var u;
            if (phi<0)  phi=2*180+phi;
            if (phi>2*180)  phi=phi-2*180;

            if ((phi>180/2)&&(phi<3*180/2))
                u=-1;
            else
                u=1;

            camera.up = new THREE.Vector3(0, u, 0);
            camera.lookAt(new THREE.Vector3(FocalPoint[0],FocalPoint[1],FocalPoint[2]))
            trace('data_move');trace(FocalPoint);trace(camera.up);  

            camera.updateMatrix();

        });
        renderer.domElement.addEventListener('mousedown', function(e) {
            paused = false;
            lastLeft = e.clientX;
            lastTop = e.clientY;
            onMouseDownTheta = theta;
            onMouseDownPhi = phi;

        });
        renderer.domElement.addEventListener('mouseup', function(e) {
            moving = paused = true;
            counter = 0
            trace('data_move');trace(camera.position);trace(camera.up); 
            comm.makeRequest("vtk", {
                mode: curVtkConf.mode,
                command: "set_camera",
                up: {'x': camera.up.x,'y': camera.up.y,'z': camera.up.z},
                position: {'x': camera.position.x,'y': camera.position.y,'z': camera.position.z},
            });
        });
 def set_camera(self, position, up):
    '''
    Поворот в жестко заданную позицию.
    '''
    self.move_to_origin()
    bounds = self.src_actor.GetBounds()
    camera = self.renderer.GetActiveCamera()
    x, y, z = camera.GetPosition()
    edge = None
    camera.SetPosition(position['x'], position['y'], position['z'])
    camera.SetViewUp(up['x'], up['y'], up['z'])
    self.world_coords_to_pixel_ratio = self._get_world_coords_to_pixel_ratio()
    camera.OrthogonalizeViewUp()
    camera.SetRoll(0)
    self.renderer.ResetCameraClippingRange()
    self.renderer.ResetCamera()