THREE.js Collada textures not loading

后端 未结 1 1805
予麋鹿
予麋鹿 2021-01-26 20:16

1) start local web server

C:\\Users\\Public\\Documents\\Rick>http-server . -p 8832 --cors
Starting up http-server, serving . on: ht         


        
相关标签:
1条回答
  • 2021-01-26 20:35

    I had the same problem. ColladaLoader.js currently does not address CORS out-of-the-box. In order to render your textures, it implements either the Loader class or the ImageLoader class (depending upon the situation). Both need to have the CORS origin assigned to either '' or 'anonymous' if you want to avoid cross-origin errors in all cases for Collada references.

    Go to this line in ColladaLoader.js:

    texture = loader.load( url );
    

    Add this line right above it:

    loader.crossOrigin = '';
    

    Then go to this line in the same script:

    loader = new THREE.ImageLoader();
    

    And add this line right below it:

    loader.setCrossOrigin( '' );
    

    And voila! My cross-origin errors went away after I made this change.

    0 讨论(0)
提交回复
热议问题