【问题标题】:Map a canvas Texture to a plane将画布纹理映射到平面
【发布时间】:2017-01-20 05:09:58
【问题描述】:

我有一个画布,我想将其映射到 3D 空间中的平面。出于某种原因,我看到的只是一个绿色矩形。

我在 webgl 渲染器旁边有画布,我知道画布是在创建纹理之前绘制的。

this.geom = new THREE.Geometry();//, side:THREE.DoubleSide
    this.tex = new THREE.Texture(canvas2d);
    //this.tex.needsUpdate = false;
    //color: 0x0033ff,
    this.material = new THREE.MeshBasicMaterial( { map:this.tex, side:THREE.DoubleSide } );
    for(var i = 0; i < this.array.length;i++) {
        this.geom.vertices.push(new THREE.Vector3(this.array[i].x, 0, this.array[i].y));
        this.geom.vertices.push(new THREE.Vector3(this.array[i].x, this.h3d , this.array[i].y));
    }
    for(var i = 0; i < this.geom.vertices.length-3; i++) {
        this.geom.faces.push(new THREE.Face3(i+0,i+2,i+1));
        this.geom.faces.push(new THREE.Face3(i+2,i+3,i+1));
    }
    this.material.map.needsUpdate = true;
    var cube = new THREE.Mesh( this.geom, this.material );
    scene.add( cube );

【问题讨论】:

    标签: javascript html three.js html5-canvas


    【解决方案1】:

    除非我弄错了,否则您不会提供任何纹理映射。例如,this.geom.faceVertexUvs。这可能是问题的原因。

    【讨论】:

      猜你喜欢
      • 2011-12-08
      • 1970-01-01
      • 2015-08-10
      • 2021-08-20
      • 1970-01-01
      • 2020-08-27
      • 2013-07-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多