我的Chrome版本中的跨源圖像負荷爲31.0.1650.57three.js所:通過跨來源資源共享策略拒絕
我學習three.js所和https://github.com/jeromeetienne/threex.planets/
下載一個星球,但樣品當我運行earth.html
一個奇怪的錯誤發生,因爲標題說:
THREE.WebGLRenderer 59 three.min.js:424
Cross-origin image load denied by Cross-Origin Resource Sharing policy. earth.html:1
Uncaught SecurityError: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': the canvas has been tainted by cross-origin data. threex.planets.js:73
(anonymous function) threex.planets.js:73
我通過代碼看,發現一些可能與這個錯誤:
THREEx.Planets.baseURL = '../'
...
map: THREE.ImageUtils.loadTexture(THREEx.Planets.baseURL+'images/earthmap1k.jpg'),
但我不知道如何解決它,我是比較新的JavaScript,
希望有人幫助我!
謝謝!
https://github.com/mrdoob/three.js/wiki/How-to-run-things-locally 這是否幫助?你需要一個本地服務器來在本地運行紋理加載示例... – GuyGood
是的,我已經通過使用Node.js運行本地服務器解決了這個問題,非常感謝! –