|
370 | 370 | }
|
371 | 371 |
|
372 | 372 | // 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'); |
379 | 376 |
|
380 | 377 | // check if ground geometry needs to be calculated
|
381 | 378 | var updateGroundGeometry =
|
|
613 | 610 |
|
614 | 611 | // ground material diffuse map is the regular ground texture and the grid texture
|
615 | 612 | // 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 = { |
617 | 614 | map: this.groundTexture,
|
618 | 615 | 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); |
622 | 627 | }
|
623 | 628 |
|
624 | 629 | var groundctx = this.groundCanvas.getContext('2d');
|
|
0 commit comments