File tree Expand file tree Collapse file tree 2 files changed +22
-11
lines changed
Expand file tree Collapse file tree 2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -22,13 +22,15 @@ AFRAME.registerComponent('street-environment', {
2222
2323 init : function ( ) {
2424 this . textureLoader = new THREE . TextureLoader ( ) ;
25- this . light1 =
26- this . el . sceneEl . querySelector ( '#env-light1' ) ||
27- this . createLight ( 'env-light1' , { type : 'ambient' , color : '#FFF' } ) ;
25+ this . light1 = this . createLight ( 'env-light1' , {
26+ type : 'ambient' ,
27+ color : '#FFF'
28+ } ) ;
2829 this . light1 . setAttribute ( 'data-layer-name' , 'Ambient Light' ) ;
29- this . light2 =
30- this . el . sceneEl . querySelector ( '#env-light2' ) ||
31- this . createLight ( 'env-light2' , { type : 'directional' , castShadow : true } ) ;
30+ this . light2 = this . createLight ( 'env-light2' , {
31+ type : 'directional' ,
32+ castShadow : true
33+ } ) ;
3234 this . light2 . setAttribute (
3335 'data-layer-name' ,
3436 'Directional Light • Shadow Caster'
@@ -132,5 +134,10 @@ AFRAME.registerComponent('street-environment', {
132134 light . setAttribute ( 'light' , attributes ) ;
133135 this . el . appendChild ( light ) ;
134136 return light ;
137+ } ,
138+
139+ remove ( ) {
140+ this . light1 . remove ( ) ;
141+ this . light2 . remove ( ) ;
135142 }
136143} ) ;
Original file line number Diff line number Diff line change @@ -31,19 +31,23 @@ function newScene(
3131 clearUrlHash = true ,
3232 addDefaultStreet = true
3333) {
34- const environmentEl = checkOrCreateEntity (
34+ let environmentEl = document . getElementById ( 'environment' ) ;
35+ if ( environmentEl ) environmentEl . removeAttribute ( 'street-environment' ) ;
36+ environmentEl = checkOrCreateEntity (
3537 'environment' ,
3638 AFRAME . scenes [ 0 ] ,
3739 'Environment'
3840 ) ;
39- // Use third param clobber to true to reset to default values
40- environmentEl . setAttribute ( 'street-environment' , '' , true ) ;
41- const geoLayer = checkOrCreateEntity (
41+ environmentEl . setAttribute ( 'street-environment' , '' ) ;
42+
43+ let geoLayer = document . getElementById ( 'reference-layers' ) ;
44+ if ( geoLayer ) geoLayer . removeAttribute ( 'street-geo' ) ;
45+ geoLayer = checkOrCreateEntity (
4246 'reference-layers' ,
4347 AFRAME . scenes [ 0 ] ,
4448 'Geospatial Layers'
4549 ) ;
46- geoLayer . removeAttribute ( 'street-geo' ) ;
50+
4751 const streetContainerEl = checkOrCreateEntity (
4852 'street-container' ,
4953 AFRAME . scenes [ 0 ] ,
You can’t perform that action at this time.
0 commit comments