问题
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