【问题标题】:ThreeJS - How to convert 3d object to 2d representationThreeJS - 如何将 3d 对象转换为 2d 表示
【发布时间】:2015-10-29 05:36:39
【问题描述】:

我在 ThreeJS 中有一个 3d 模型。将 3d 对象投影到 2d 调用了哪些技术?例如,我想将 3d 模型投影到地面。这是我正在寻找的图像:

这还叫投影吗?这是怎么做到的?

【问题讨论】:

    标签: 3d three.js projection


    【解决方案1】:

    是的,它是在平面上的投影,在三个 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 个点给出的平面上,您可以处理数组或将场景中的几何图形用作煎饼。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-30
      • 1970-01-01
      • 1970-01-01
      • 2014-07-11
      • 2013-03-28
      • 2017-09-04
      • 1970-01-01
      相关资源
      最近更新 更多