10,606
社区成员
发帖
与我相关
我的任务
分享
/** 加入模型 */
function createModel() {
// model
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
}
};
var onError = function () { };
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
//加载模型
new THREE.OBJLoader()
.setPath( 'models/obj/bentley_motors/' )
.load('qc10.obj', function ( object ) {//加载模型
object.position.y =-180;
object.position.x =-350;
object.position.z =200;
object.scale.x = 0.04;
object.scale.y = 0.04;
object.scale.z = 0.04;
left_front_wheel = new THREE.Object3D;
left_front_wheel.position.y =-180;
left_front_wheel.position.x =-350;
left_front_wheel.position.z =200;
left_front_wheel.scale.x = 0.04;
left_front_wheel.scale.y = 0.04;
left_front_wheel.scale.z = 0.04;
var left_front_1,left_front_2 ;
object.traverse(function(child) {
if(child instanceof THREE.Mesh) {
if(child.name=="left_front_wheel"){
left_front_2= child;
}
console.log("元素——"+child.name)
console.log(child)
}
})
left_front_wheel.add(left_front_2);
//left_front_wheel.children[0].geometry.center()
scene.add( left_front_wheel );
ready=true;
return object;
}, onProgress, onError );
}
//轮子自转 动画
function updateWheel(){
left_front_wheel.rotation.x-=speed;
}