Skip to content

Commit

Permalink
force lighting param update
Browse files Browse the repository at this point in the history
  • Loading branch information
feiss committed Mar 22, 2018
1 parent 38f1970 commit 606410b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
25 changes: 15 additions & 10 deletions dist/aframe-environment-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,9 @@
}

// scene lights
if (this.data.lighting !== oldData.lighting) {
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
}

this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');

// check if ground geometry needs to be calculated
var updateGroundGeometry =
Expand Down Expand Up @@ -613,12 +610,20 @@

// ground material diffuse map is the regular ground texture and the grid texture
// is used in the emissive map. This way, the grid is always equally visible, even at night.
this.groundMaterial = new THREE.MeshLambertMaterial({
this.groundMaterialProps = {
map: this.groundTexture,
emissive: new THREE.Color(0xFFFFFF),
emissiveMap: this.gridTexture,
shading: this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading
});
emissiveMap: this.gridTexture
};

// use .shading for A-Frame < 0.7.0 and .flatShading for A-Frame >= 0.7.0
if (new THREE.Material().hasOwnProperty('shading')) {
this.groundMaterialProps.shading = this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading;
} else {
this.groundMaterialProps.flatShading = this.data.flatShading;
}

this.groundMaterial = new THREE.MeshLambertMaterial(this.groundMaterialProps);
}

var groundctx = this.groundCanvas.getContext('2d');
Expand Down
4 changes: 2 additions & 2 deletions dist/aframe-environment-component.min.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,12 +324,9 @@ AFRAME.registerComponent('environment', {
}

// scene lights
if (this.data.lighting !== oldData.lighting) {
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
}

this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');

// check if ground geometry needs to be calculated
var updateGroundGeometry =
Expand Down
4 changes: 2 additions & 2 deletions tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="description" content="A-Frame Environment Component">
<meta name="author" content="Diego F. Goberna">
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
<script src="../dist/aframe-environment-component.min.js"></script>
<!--<script src="../index.js"></script>-->
<!--<script src="../dist/aframe-environment-component.min.js"></script>-->
<script src="../index.js"></script>
<link href="https://fonts.googleapis.com/css?family=Voces" rel="stylesheet">

<style>
Expand Down

0 comments on commit 606410b

Please sign in to comment.