[英]Applying Textures in Three.js using a URL
我在Three.js中應用紋理時遇到了麻煩。 由於安全問題,我無法在Chrome中使用任何本地圖片,所以我想從網上應用圖片。 有沒有辦法使用URL將圖像映射到Three.js網格?
TextureLoader可以與網址一起使用,只需確保將crossOrigin設置為加載網址而不是網站的服務器。 這是一個例子:
const myUrl = 'http://www.myimage.com'
const textureLoader = new THREE.TextureLoader()
textureLoader.crossOrigin = "Anonymous"
const myTexture = textureLoader.load(myUrl)
myMesh.material.map(myTexture)
myMesh.material.needsUpdate = true
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.