Skip to content

Commit 606410b

Browse files
committed
force lighting param update
1 parent 38f1970 commit 606410b

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

dist/aframe-environment-component.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,9 @@
370370
}
371371

372372
// scene lights
373-
if (this.data.lighting !== oldData.lighting) {
374-
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
375-
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
376-
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
377-
}
378-
373+
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
374+
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
375+
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
379376

380377
// check if ground geometry needs to be calculated
381378
var updateGroundGeometry =
@@ -613,12 +610,20 @@
613610

614611
// ground material diffuse map is the regular ground texture and the grid texture
615612
// is used in the emissive map. This way, the grid is always equally visible, even at night.
616-
this.groundMaterial = new THREE.MeshLambertMaterial({
613+
this.groundMaterialProps = {
617614
map: this.groundTexture,
618615
emissive: new THREE.Color(0xFFFFFF),
619-
emissiveMap: this.gridTexture,
620-
shading: this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading
621-
});
616+
emissiveMap: this.gridTexture
617+
};
618+
619+
// use .shading for A-Frame < 0.7.0 and .flatShading for A-Frame >= 0.7.0
620+
if (new THREE.Material().hasOwnProperty('shading')) {
621+
this.groundMaterialProps.shading = this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading;
622+
} else {
623+
this.groundMaterialProps.flatShading = this.data.flatShading;
624+
}
625+
626+
this.groundMaterial = new THREE.MeshLambertMaterial(this.groundMaterialProps);
622627
}
623628

624629
var groundctx = this.groundCanvas.getContext('2d');

dist/aframe-environment-component.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,9 @@ AFRAME.registerComponent('environment', {
324324
}
325325

326326
// scene lights
327-
if (this.data.lighting !== oldData.lighting) {
328-
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
329-
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
330-
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
331-
}
332-
327+
this.sunlight.setAttribute('light', {type: this.data.lighting == 'point' ? 'point' : 'directional'});
328+
this.sunlight.setAttribute('visible', this.data.lighting !== 'none');
329+
this.hemilight.setAttribute('visible', this.data.lighting !== 'none');
333330

334331
// check if ground geometry needs to be calculated
335332
var updateGroundGeometry =

tests/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<meta name="description" content="A-Frame Environment Component">
77
<meta name="author" content="Diego F. Goberna">
88
<script src="https://aframe.io/releases/0.7.0/aframe.min.js"></script>
9-
<script src="../dist/aframe-environment-component.min.js"></script>
10-
<!--<script src="../index.js"></script>-->
9+
<!--<script src="../dist/aframe-environment-component.min.js"></script>-->
10+
<script src="../index.js"></script>
1111
<link href="https://fonts.googleapis.com/css?family=Voces" rel="stylesheet">
1212

1313
<style>

0 commit comments

Comments
 (0)