使用三个js拖拽一个obj文件 [英] Drag an obj file using three js
本文介绍了使用三个js拖拽一个obj文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用三个 js Draggable cubes 示例,它是 this.
I am using a Three js Draggable cubes example which is this.
我想用 obj 文件替换内部创建的立方体.这就是我正在做的事情.
I want to replace the internally created cubes with the obj files. Here is what I am doing.
我已经将obj模型(人脸)添加到objects[]中,所以我认为现在它是所有对象的一部分,应该与射线相交.
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.
我无法拖动 3D obj 模型,但我可以拖动其他立方体.Raycaster 不与 3d obj 模型相交吗?怎么把obj模型拖进去?
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?
推荐答案
尝试通过这个例子.
<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);
}
这篇关于使用三个js拖拽一个obj文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文