@@ -271,6 +271,15 @@ export class GameClient {
271271 * @param entities - Array of all entity data
272272 */
273273 private handleWorldState ( players : PlayerData [ ] , entities : EntityData [ ] ) : void {
274+ // Debug: Log entity information
275+ if ( entities . length > 0 ) {
276+ console . log ( `[WorldState] Received ${ entities . length } entities:` , entities . map ( e => ( {
277+ id : e . id ,
278+ type : e . entity_type ,
279+ position : e . position
280+ } ) ) ) ;
281+ }
282+
274283 // Update players
275284 for ( const playerData of players ) {
276285 if ( playerData . id !== this . user . id ) {
@@ -293,6 +302,7 @@ export class GameClient {
293302 existingEntity . position = entityData . position ;
294303 existingEntity . rotation = entityData . rotation ;
295304 } else {
305+ console . log ( `[WorldState] Adding new entity: ${ entityData . id } (${ entityData . entity_type } ) at` , entityData . position ) ;
296306 this . addEntity ( entityData ) ;
297307 }
298308 }
@@ -396,8 +406,13 @@ export class GameClient {
396406
397407 private addEntity ( entityData : EntityData ) : void {
398408 const entity = Entity . fromData ( entityData ) ;
399- this . scene ?. add ( entity . mesh ) ;
400- this . entities . set ( entityData . id , entity ) ;
409+ if ( this . scene ) {
410+ this . scene . add ( entity . mesh ) ;
411+ this . entities . set ( entityData . id , entity ) ;
412+ console . log ( `[Entity] Added entity ${ entityData . id } to scene. Mesh position:` , entity . mesh . position , 'Entity count:' , this . entities . size ) ;
413+ } else {
414+ console . error ( '[Entity] Cannot add entity - scene is null!' ) ;
415+ }
401416 }
402417
403418 private removeEntity ( entityId : string ) : void {
0 commit comments