Drag an obj file using three js

耗尽温柔 提交于 2019-12-23 04:13:08

问题


I am using a Three js Draggable cubes example which is this.

I want to replace the internally created cubes with the obj files. Here is what I am doing.

I have added the obj model(a human face) to the objects[], so I think now it is a part of all the objects and should be intersected by a ray.

I am not able to drag the 3D obj model but I am able to drag the other cubes. Does the Raycaster not intersect 3d obj Model? How can I drag the obj model in this?


回答1:


Try to make through this example.

<script src="js/controls/EventsControls.js"></script>

EventsControls = new EventsControls( camera, renderer.domElement );
EventsControls.projectionMap = checkerboard;
EventsControls.fixed.y = true;  

var loader = new THREE.OBJMTLLoader();

loader.load( 'models/objmtl/model.obj', 'models/objmtl/model.mtl',
    function ( GingerbreadMan ) {
        GingerbreadMan.position.set( 125, 35, 175 );
        GingerbreadMan.scale.set( 1/3, 1/3, 1/3 );
        scene.add( GingerbreadMan );

        EventsControls.attach( GingerbreadMan );
    }
);

//

function render() {
       EventsControls.update();
       controls.update();
       renderer.render(scene, camera);
}


来源:https://stackoverflow.com/questions/28115792/drag-an-obj-file-using-three-js

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