使用正交轨迹球控件消失几何图形

时间:2017-05-27 18:55:19

标签: three.js

我正在使用OrthographicTrackballControls和正交相机。我正在使用STLLoader将几何体加载到场景中。几何图形加载正常,但是当我开始缩放/旋转/平移时,几何图形将随机从场景中消失。这是OrthographicTrackball控件的已知问题吗?使用透视摄像头和轨迹球控件时,我似乎没有这个问题...

我的代码:

camera = new THREE.OrthographicCamera(window.innerWidth/-zoomDefault, window.innerWidth/zoomDefault, window.innerHeight/zoomDefault, window.innerHeight/-zoomDefault, -200, 500);

renderer = new THREE.WebGLRenderer({alpha: true});

var loader = new THREE.STLLoader();
loader.load('file.php?model_id='+modelId+'', function ( geometry ) {

    var material = new THREE.MeshPhongMaterial( { color: 0xff5533, specular: 0x111111, shininess: 100 } );
    var mesh = new THREE.Mesh( geometry, material );

    mesh.position.set( 0, 0, 0 );
    mesh.rotation.set( 0, - Math.PI / 2, 0 );
    mesh.scale.set( 0.5, 0.5, 0.5 );

    // center the rotational pivot point on center of geometry
    mesh.translation = THREE.GeometryUtils.center(geometry);

    mesh.castShadow = true;
    mesh.receiveShadow = true;

    scene.add( mesh );

} );

controls = new THREE.OrthographicTrackballControls(camera, renderer.domElement);
controls.zoomSpeed = 0.1;
controls.dynamicDampingFactor = 0.5;

0 个答案:

没有答案