Skip to content

Commit ae3d8cd

Browse files
authored
Merge pull request #31 from PButcher/patch-1
Update groundMaterial shading
2 parents f4343cb + c677c5e commit ae3d8cd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

index.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,12 +567,20 @@ AFRAME.registerComponent('environment', {
567567

568568
// ground material diffuse map is the regular ground texture and the grid texture
569569
// is used in the emissive map. This way, the grid is always equally visible, even at night.
570-
this.groundMaterial = new THREE.MeshLambertMaterial({
570+
this.groundMaterialProps = {
571571
map: this.groundTexture,
572572
emissive: new THREE.Color(0xFFFFFF),
573-
emissiveMap: this.gridTexture,
574-
shading: this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading
575-
});
573+
emissiveMap: this.gridTexture
574+
};
575+
576+
// use .shading for A-Frame < 0.7.0 and .flatShading for A-Frame >= 0.7.0
577+
if (new THREE.Material().hasOwnProperty('shading')) {
578+
this.groundMaterialProps.shading = this.data.flatShading ? THREE.FlatShading : THREE.SmoothShading;
579+
} else {
580+
this.groundMaterialProps.flatShading = this.data.flatShading;
581+
}
582+
583+
this.groundMaterial = new THREE.MeshLambertMaterial(this.groundMaterialProps);
576584
}
577585

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

0 commit comments

Comments
 (0)