Skip to content

Commit 93b6a6f

Browse files
authored
fix(multi-client): Prevent duplicate lights when multiple clients connect (#250)
* fix(multi-client): Prevent duplicate lights when multiple clients connect
1 parent 1082133 commit 93b6a6f

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

gz3d/src/gzscene.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -332,15 +332,16 @@ GZ3D.Scene.prototype.init = function()
332332
};
333333

334334
GZ3D.Scene.prototype.initScene = function()
335-
{
335+
{
336336
this.emitter.emit('show_grid', 'show');
337-
338-
// create a sun light
339-
var obj = this.createLight(3, new THREE.Color(0.8, 0.8, 0.8), 0.9,
340-
{position: {x:0, y:0, z:10}, orientation: {x:0, y:0, z:0, w:1}},
341-
null, true, 'sun', {x: 0.5, y: 0.1, z: -0.9});
342-
343-
this.add(obj);
337+
var existingSun = this.getByName('sun');
338+
if (!existingSun) {
339+
// create a sun light
340+
var obj = this.createLight(3, new THREE.Color(0.8, 0.8, 0.8), 0.9,
341+
{position: {x:0, y:0, z:10}, orientation: {x:0, y:0, z:0, w:1}},
342+
null, true, 'sun', {x: 0.5, y: 0.1, z: -0.9});
343+
this.add(obj);
344+
}
344345
};
345346

346347
GZ3D.Scene.prototype.setSDFParser = function(sdfParser)

0 commit comments

Comments
 (0)