three.js: mesh1.position.set 不是函数
three.js: mesh1.position.set is not a function
我已经尝试了所有方法来设置我新创建的 mesh1
网格对象的位置。 mesh1.position
属性 是只读的,mesh1.setPosition
不存在,mesh1.position.set
也不存在。这是我当前的代码:
var plane1 = new THREE.PlaneGeometry(20, 20, 5, 5);
var mesh1 = utils_misc.mesher(plane1, intersection, 0xffffff, "", false, true, false);
mesher 函数的相关部分如下所示:
function mesher ( aGeometry, position, color, name, woodTexture, doubleSided, debug ) {
// ...
material = new THREE.MeshBasicMaterial( { map: texture, side: THREE.DoubleSide } );
mesh = new THREE.Mesh(aGeometry, material);
mesh.position.set = position;
mesh.name = name;
mesh.callback = function() { makeDOMelements.info.innerHTML = name; };
makeScene.scene.add( mesh );
}
我也试过这个:
mesh1.position.set(intersection.x, intersection.y, intersection.z);
帅哥是怎么摆位的?
这行不通:
mesh.position.set = position;
你需要做
mesh.position.copy( position );
但是
mesh1.position.set(intersection.x, intersection.y, intersection.z);
只要 mesh1
的类型是 Object3D
就应该有效
我已经尝试了所有方法来设置我新创建的 mesh1
网格对象的位置。 mesh1.position
属性 是只读的,mesh1.setPosition
不存在,mesh1.position.set
也不存在。这是我当前的代码:
var plane1 = new THREE.PlaneGeometry(20, 20, 5, 5);
var mesh1 = utils_misc.mesher(plane1, intersection, 0xffffff, "", false, true, false);
mesher 函数的相关部分如下所示:
function mesher ( aGeometry, position, color, name, woodTexture, doubleSided, debug ) {
// ...
material = new THREE.MeshBasicMaterial( { map: texture, side: THREE.DoubleSide } );
mesh = new THREE.Mesh(aGeometry, material);
mesh.position.set = position;
mesh.name = name;
mesh.callback = function() { makeDOMelements.info.innerHTML = name; };
makeScene.scene.add( mesh );
}
我也试过这个:
mesh1.position.set(intersection.x, intersection.y, intersection.z);
帅哥是怎么摆位的?
这行不通:
mesh.position.set = position;
你需要做
mesh.position.copy( position );
但是
mesh1.position.set(intersection.x, intersection.y, intersection.z);
只要 mesh1
的类型是 Object3D