three.js: texture goes all black

前端 未结 3 952
你的背包
你的背包 2021-01-22 09:14

I have a simple geometry for a box, that I\'m trying to decorate with a texture. However, my box doesn\'t show at all (or perhaps it is 100% black). This current question is evo

3条回答
  •  余生分开走
    2021-01-22 09:55

    Error console tells it is another CORS-Problem:

    DOMException [SecurityError: "The operation is insecure."

    Set the CrossOrigin attribute to empty:

    var loader = new THREE.TextureLoader();
    loader.crossOrigin = "";
    loader.load("http://mrdoob.github.io/three.js/examples/textures/crate.gif",
        function( texture ) {
            //...
        },
        function () {},  // onProgress function
        function ( error ) { console.log( error ) } // onError function
    );
    

提交回复
热议问题