When trying to apply a texture on a THREE.MeshPhongMaterial, the texture fails to load. Here's the code snippet:
let earth_geometry = new THREE.SphereGeometry(450, 10, 10)
let earth_material = new THREE.MeshPhongMaterial({
emissive: 0xffffff
})
let earth = new THREE.Mesh(earth_geometry, earth_material)
loadImage(earth_material, '/img/earth.jpg')
scene.add(earth)
function loadImage(material, url) {
let texture = new THREE.TextureLoader().load(url, (e) => {
texture.minFilter = THREE.LinearFilter
texture.anisotropy = 8
material.map = texture
material.needsUpdate = true
})
Interestingly, if I switch to THREE.MeshBasicMaterial()
, the texture loads fine.
Why does it behave differently with THREE.MeshPhongMaterial
?