Skip to content

Commit

Permalink
Merge pull request #834 from mozilla/feature/prefiltered-envmap
Browse files Browse the repository at this point in the history
Prefilter environment maps
  • Loading branch information
robertlong authored Jan 12, 2019
2 parents a48e765 + 40b07c2 commit 74e1adc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/components/skybox.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import "three/examples/js/pmrem/PMREMGenerator";
import "three/examples/js/pmrem/PMREMCubeUVPacker";

/**
* @author zz85 / https://github.com/zz85
*
Expand Down Expand Up @@ -295,11 +298,17 @@ AFRAME.registerComponent("skybox", {
const environmentMapComponent = this.el.sceneEl.components["environment-map"];

if (environmentMapComponent) {
const renderer = this.el.sceneEl.renderer;
this.skyScene.add(this.sky);
this.cubeCamera.update(this.el.sceneEl.renderer, this.skyScene);
this.cubeCamera.update(renderer, this.skyScene);
this.el.setObject3D("mesh", this.sky);

environmentMapComponent.updateEnvironmentMap(this.cubeCamera.renderTarget.texture);
const pmremGenerator = new THREE.PMREMGenerator(this.cubeCamera.renderTarget.texture);
pmremGenerator.update(renderer);
const pmremCubeUVPacker = new THREE.PMREMCubeUVPacker(pmremGenerator.cubeLods);
pmremCubeUVPacker.update(renderer);
environmentMapComponent.updateEnvironmentMap(pmremCubeUVPacker.CubeUVRenderTarget.texture);
pmremGenerator.dispose();
pmremCubeUVPacker.dispose();
}
},

Expand Down

0 comments on commit 74e1adc

Please sign in to comment.