使用three.js貼圖片時報錯:Failed to execute 'texImage2D' on 'WebGLRenderingContext': No function was found that matched the signature
代碼參照官方寫的以下:app
var loader = new THREE.TextureLoader(); // load a resource loader.load( // resource URL 'img/dabeijing.png', // onLoad callback function ( texture ) { var mesh = new THREE.Mesh(new THREE.SphereGeometry(1000, 100, 100), new THREE.MeshBasicMaterial({ map: texture})); _scene.add(mesh); }, // onProgress callback currently not supported undefined, // onError callback function ( err ) { console.error( 'An error happened.' +err); } );
剛開始用three.js,實在不知道爲何會報錯,搜了下沒發現有相關的錯,因而仔細看了下錯誤提示,發現上面有這麼一句話
一開始我覺得這是three.js內部給圖片修改尺寸的提示,沒注意看,實在找不出別的問題就試着改了下,我照着這個比例改的圖片,而後就發現不報錯了,試了別的比例發現只能按照長寬比爲2ⁿ:1的比例改。先記錄一下,有空能夠查查爲何。spa