【发布时间】: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