three.js:Failed to execute 'texImage2D'

使用three.js贴图片时报错:Failed to execute 'texImage2D' on 'WebGLRenderingContext': No function was found that matched the signature
clipboard.png
代码参照官方写的以下: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,实在不知道为何会报错,搜了下没发现有相关的错,因而仔细看了下错误提示,发现上面有这么一句话
clipboard.png
一开始我觉得这是three.js内部给图片修改尺寸的提示,没注意看,实在找不出别的问题就试着改了下,我照着这个比例改的图片,而后就发现不报错了,试了别的比例发现只能按照长宽比为2ⁿ:1的比例改。先记录一下,有空能够查查为何。spa

相关文章
相关标签/搜索