From e86952b46988b4ca718e891c45fd1db4352c4402 Mon Sep 17 00:00:00 2001 From: work <840004959@qq.com> Date: Tue, 18 Nov 2025 09:30:21 +0000 Subject: [PATCH 1/2] fix(multi-client): Prevent duplicate lights when multiple clients connect --- gz3d/src/gzscene.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gz3d/src/gzscene.js b/gz3d/src/gzscene.js index a0ca5dff..dd619e7c 100644 --- a/gz3d/src/gzscene.js +++ b/gz3d/src/gzscene.js @@ -335,12 +335,14 @@ GZ3D.Scene.prototype.initScene = function() { this.emitter.emit('show_grid', 'show'); - // create a sun light - var obj = this.createLight(3, new THREE.Color(0.8, 0.8, 0.8), 0.9, - {position: {x:0, y:0, z:10}, orientation: {x:0, y:0, z:0, w:1}}, - null, true, 'sun', {x: 0.5, y: 0.1, z: -0.9}); - - this.add(obj); + var existingSun = this.getByName('sun'); + if (!existingSun) { + // create a sun light + var obj = this.createLight(3, new THREE.Color(0.8, 0.8, 0.8), 0.9, + {position: {x:0, y:0, z:10}, orientation: {x:0, y:0, z:0, w:1}}, + null, true, 'sun', {x: 0.5, y: 0.1, z: -0.9}); + this.add(obj); + } }; GZ3D.Scene.prototype.setSDFParser = function(sdfParser) From 191bd42ea701f4f25bd30c594dcb813100285650 Mon Sep 17 00:00:00 2001 From: work <840004959@qq.com> Date: Tue, 18 Nov 2025 09:33:31 +0000 Subject: [PATCH 2/2] fix(multi-client): Prevent duplicate lights when multiple clients connect --- gz3d/src/gzscene.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gz3d/src/gzscene.js b/gz3d/src/gzscene.js index dd619e7c..b22d0fa8 100644 --- a/gz3d/src/gzscene.js +++ b/gz3d/src/gzscene.js @@ -332,9 +332,8 @@ GZ3D.Scene.prototype.init = function() }; GZ3D.Scene.prototype.initScene = function() -{ +{ this.emitter.emit('show_grid', 'show'); - var existingSun = this.getByName('sun'); if (!existingSun) { // create a sun light