如何为单独的 url threejs 加载图像
How to load Images for a separate url threejs
这里是菜鸟。我正在学习 threejs,我正在尝试从 Web 上的单独目录将纹理加载到圆柱体。希望有人能指出代码有什么问题:
var geometry = new THREE.CylinderBufferGeometry( 17, 17, 30, 35 );
var material = new THREE.MeshLambertMaterial( );
var cylinder = new THREE.Mesh( geometry, material );
const myUrl = 'https://user-images.githubusercontent.com/29174429/84787863-87516080-afff-11ea-9dca-3ed8d32d7b41.jpg'
const textureLoader = new THREE.TextureLoader()
textureLoader.crossOrigin = "Anonymous"
const myTexture = textureLoader.load(myUrl)
cylinder.material.map(myTexture)
谢谢。
cylinder.material.map(myTexture)
应该是:
cylinder.material.map = myTexture;
Material.map
是一个 属性,不是方法。此外,TextureLoader.crossOrigin
的默认值已经是anonymous
。
这里是菜鸟。我正在学习 threejs,我正在尝试从 Web 上的单独目录将纹理加载到圆柱体。希望有人能指出代码有什么问题:
var geometry = new THREE.CylinderBufferGeometry( 17, 17, 30, 35 );
var material = new THREE.MeshLambertMaterial( );
var cylinder = new THREE.Mesh( geometry, material );
const myUrl = 'https://user-images.githubusercontent.com/29174429/84787863-87516080-afff-11ea-9dca-3ed8d32d7b41.jpg'
const textureLoader = new THREE.TextureLoader()
textureLoader.crossOrigin = "Anonymous"
const myTexture = textureLoader.load(myUrl)
cylinder.material.map(myTexture)
谢谢。
cylinder.material.map(myTexture)
应该是:
cylinder.material.map = myTexture;
Material.map
是一个 属性,不是方法。此外,TextureLoader.crossOrigin
的默认值已经是anonymous
。