收藏
回答

微信小程序AR基于three.js,创建cube后纹理加载不出来,显示为黑色,这是什么原因?

//加载cube
const geometry = new THREE.BoxBufferGeometry(0.20.20.2);
/* This doesn't work on iOS because of Uint8ClampedArray bug:
    https://developers.weixin.qq.com/community/develop/doc/000408d4f304e038c20e4a00a51400
    */
/*
    const rgbaData = new Uint8ClampedArray([
    255,255,255,0,
    0,0,0,0,
    0,0,0,0,
    255,255,255,0
]);*/


const rgbaData = new Uint8Array([
    255,255,255,0,
    0,0,0,0,
    0,0,0,0,
    255,255,255,0
]);


const texture = new THREE.DataTexture(rgbaData,2,2);
texture.needsUpdate = true;


const material = new THREE.MeshBasicMaterial({ map: texture });


const mesh = new THREE.Mesh(geometry, material);
mainModel = mesh;
scene.add(mesh);

回答关注问题邀请回答
收藏
登录 后发表内容