我有一个png,我用作PlaneGeometry的纹理,但我想添加蓝色背景。 我正在使用画布渲染器,如果这是相关的。
这是我的代码,图片有效,但颜色没有:
var material2 = getTextureMaterial('img/ok.png');
var plane2 = new THREE.PlaneGeometry(100, 100);
meshImage = new THREE.Mesh(plane2, material2);
meshImage.position.set(1000, -40, 200);
meshImage.userData.name = 'image';
meshImage.rotateY(Math.PI / 2);
function getTextureMaterial(path) {
var texture = new THREE.Texture(texture_placeholder);
var material = new THREE.MeshBasicMaterial({
color: new THREE.Color(0xff0000),
map: texture,
overdraw: 0.5,
side: THREE.DoubleSide,
});
var image = new Image();
image.onload = function() {
texture.image = this;
texture.needsUpdate = true;
};
image.src = path;
return material;
}