Aframe 1.0.4 - setting scene.environment does not update materials

258 views Asked by At

So I saw an old post here:

https://discourse.threejs.org/t/is-there-a-way-to-increase-scene-environment-map-exposure-without-affecting-unlit-materials/13458/4

That says... "If you apply the env map to Scene.environment, it is automatically used as the environment map for all physical materials in the scene (assumed the material’s envmap is not set)."

So tried this using an Aframe component on the scene:

AFRAME.registerComponent('setenvironment', {
  init: function () {
    var sceneEl = this.el;
    var loader = new THREE.CubeTextureLoader();
    loader.setPath('./');

    var textureCube = loader.load([
      './images/py.png', './images/pz.png',
      './images/nx.png', './images/ny.png',
      './images/px.png', './images/nz.png'
    ]);
    textureCube.encoding = THREE.sRGBEncoding;
    sceneEl.object3D.environment = textureCube;
  }
});

The environment attribute is successfully set, but the other objects materials still have envMap set to null and the environment lighting does not take effect on the materials.

Any ideas?

1

There are 1 answers

1
Piotr Adam Milewski On BEST ANSWER

aframe 1.0.4 uses three.js revision 111dev. The scene's environment property was introduced in revision 112 (source).

If you use the aframe master build - it seems to be working properly (as its based on three.js r119).

Otherwise, you'll have to iterate through the meshes, and set the material.envMap property manually.