我在ThreeJS中有一个3d模型。将3d对象投影到2d需要哪些技术?例如,我想将3d模型投影到地面上。这是我正在寻找的图片:
这算不算投影呢?如何做到这一点?
发布于 2015-10-31 02:53:49
是的,这是一个平面上的投影,在三个js中进行投影的简单方法是将几何点投影到一个平面上。
使用bufferGeometry的示例(法线几何体可能会以其他方式迭代点或其他..)
//create someplane to project to
var plane = new THREE.Plane().setFromCoplanarPoints(pointA,pointB,pointC)
//create some geometry to flatten..
var geometry = new THREE.BufferGeometry();
fillGeometry(geometry);
var positionAttr = geometry.getAttribute("position");
for(var i = 0; i < positionAttr.array.length; i+=3)
{
var point = new THREE.Vector3(positionAttr.array[i],positionAttr.array[i+1],positionAttr.array[i+2]);
var projectedPoint = plane.projectPoint();
positionAttr.array[i] = projectedPoint.x;
positionAttr.array[i+1] = projectedPoint.y;
positionAttr.array[i+2] = projectedPoint.z;
}
positionAttr.needsUpdate = true;
上面的代码会将几何体展平到由3个点给出的平面上,你可以处理一些东西的数组,或者使用场景中的几何体作为煎饼。
https://stackoverflow.com/questions/33406663
复制相似问题