Skip to content

Commit d5098d9

Browse files
committed
Fix preview image issue with scenelayer
1 parent 7af91ee commit d5098d9

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/components/structural/View.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,19 @@ class View extends Component {
158158
//ambient light doesn't have an indicator
159159
switch(ent.light.type){
160160
case "point":
161-
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} pointlightindicator={`color: ${ent.color};`}></a-entity>;
161+
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} pointlightindicator={`color: ${ent.color};`} layer="type:group; layer:1"></a-entity>;
162162
case "spot":
163163
let target = true;
164164
if(!ent.light.target) {
165165
position = "";
166166
target = false;
167167
}
168-
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} spotlightindicator={`color: ${ent.color}; target:${target}`} indicatorrotation={position}></a-entity>;
168+
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} spotlightindicator={`color: ${ent.color}; target:${target}`} indicatorrotation={position} layer="type:group; layer:1"></a-entity>;
169169
case "directional":
170-
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} directionallightindicator={`color: ${ent.color};`} indicatorrotation={position}></a-entity>;
170+
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} directionallightindicator={`color: ${ent.color};`} indicatorrotation={position} layer="type:group; layer:1"></a-entity>;
171171
case "hemisphere":
172-
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} hemispherelightindicator={`color: ${ent.color}; secondColor: ${ent.light.secondColor}`}></a-entity>;
172+
return <a-entity id={ent.id+"Ind"} key={ent.id+"Ind"} hemispherelightindicator={`color: ${ent.color}; secondColor: ${ent.light.secondColor}`} layer="type:group; layer:1"></a-entity>;
173173
default:
174-
return null;
175174
}
176175
}
177176
//return string that contains necessary configuration for shadow based on light's type

src/utils/AframeReg.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,14 @@ AFRAME.registerComponent("layer",{
3939
},
4040
},
4141
init: function(){
42-
this.el.getObject3D(this.data.type).layers.set(this.data.layer);
42+
let obj = this.el.getObject3D(this.data.type);
43+
if(this.data.type === "group"){
44+
obj.children.forEach((child)=>{
45+
child.layers.set(this.data.layer);
46+
});
47+
} else {
48+
obj.layers.set(this.data.layer);
49+
}
4350
}
4451
});
4552

@@ -55,11 +62,11 @@ AFRAME.registerComponent("scenelayer",{
5562
},
5663
tick: function(){
5764
this.renderer.autoClear = true;
58-
this.camera.layers.set(0);
65+
this.camera.layers.set(1);
5966
this.renderer.render(this.scene, this.camera);
6067

6168
this.renderer.autoClear = false;
62-
this.camera.layers.set(1);
69+
this.camera.layers.set(0);
6370
this.renderer.render(this.scene, this.camera);
6471
}
6572
});

0 commit comments

Comments
 (0)