使用FileLoader
和DracoLoader
加载
DracoLoader
也可以加在但是不知为何 和FileLoader
一起用才能加载完整的资源
const fileLoader = new THREE.FileLoader();
const dracoLoader = new DRACOLoader();
dracoLoader.setDecoderConfig({ type: "js" });
dracoLoader.setDecoderPath("/draco/");
dracoLoader.preload()
解析
const taskConfig = {attributeIDs: {position: "POSITION",color: "COLOR",size: "GENERIC",uv: "TEX_COORD",},attributeTypes: {position: "Float32Array",color: "Float32Array",size: "Float32Array",uv: "Float32Array",},useUniqueIDs: false,};fileLoader.setResponseType("arraybuffer").load(url, (arrayBuffer) => {this.dracoLoader//@ts-ignore:.decodeGeometry(arrayBuffer, taskConfig).then((geo: THREE.BufferGeometry) => {console.log(geo);}).catch((err: Error) => {console.error(err);});});