threejs.miniprogram
threejs.miniprogram copied to clipboard
微信小程序AR基于three.js加载模型纹理失败,显示黑色
//加载cube const geometry = new THREE.BoxBufferGeometry(0.2, 0.2, 0.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);