Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ AFRAME.registerComponent('environment', {
this.stars = null;

// create ground
this.groundMaterial = null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same line is at line 178 below.

this.ground = document.createElement('a-entity');
this.ground.setAttribute('rotation', '-90 0 0');
this.ground.classList.add('environmentGround');
Expand Down Expand Up @@ -405,6 +404,35 @@ AFRAME.registerComponent('environment', {
this.dumpParametersDiff();
},

remove: function() {
if (this.userFog) {
this.el.sceneEl.setAttribute('fog', this.userFog);
}
else {
this.el.sceneEl.removeAttribute('fog');
}
this.el.removeChild(this.hemilight);
this.el.removeChild(this.sunlight);
if (this.groundTexture) this.groundTexture.dispose();
if (this.gridTexture) this.gridTexture.dispose();
if (this.groundMaterial) this.groundMaterial.dispose();
if (this.groundGeometry) this.groundGeometry.dispose();
this.el.removeChild(this.ground);
var dressingMesh = this.dressing.getObject3D('mesh');
if (dressingMesh && dressingMesh.children.length > 0) {
dressingMesh.children[0].material.dispose();
dressingMesh.children[0].geometry.dispose();
}
this.el.removeChild(this.dressing);
this.el.removeChild(this.sky);
if (this.stars) {
var mesh = this.stars.getObject3D('mesh');
mesh.material.dispose();
mesh.geometry.dispose();
this.el.removeChild(this.stars);
}
},

// logs current parameters to console, for saving to a preset
logPreset: function () {
var str = '{';
Expand Down Expand Up @@ -590,12 +618,7 @@ AFRAME.registerComponent('environment', {
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.environmentData.flatShading ? THREE.FlatShading : THREE.SmoothShading;
} else {
this.groundMaterialProps.flatShading = this.environmentData.flatShading;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only support aframe 1.3.0 and above with the current code related to geometries, so we can remove this material check.

this.groundMaterialProps.flatShading = this.environmentData.flatShading;

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