bgstaal / multipleWindow3dScene

A quick example of how one can "synchronize" a 3d scene across multiple windows using three.js and localStorage
MIT License
16.44k stars 2.56k forks source link

Suggestion : Channel Broadcast instead of locale storage #8

Open zakarialaoui10 opened 9 months ago

zakarialaoui10 commented 9 months ago

I suggest to use Channel Broadcast instead of locale storage

Using Channel Broadcast can be a more efficient way to manage communication between components or services compared to local storage, as it allows for real-time updates without the need for persistent storage.

I am already using this approach on similar project Screenshot_20231124-155728_GitHub.jpg

https://github.com/zakarialaoui10/ziko.js

szucsz commented 8 months ago

in case someone is interested, here you can find the window manager implemented with channel broadcast: https://github.com/szucsz/multipleWindow3dScene/tree/broadcast-channel

and the published app: https://szucsz.github.io/multipleWindow3dScene/

liushengrui527 commented 8 months ago

I suggest to use Channel Broadcast instead of locale storage Scene=new SceneGl ( 400, 400 )

b=cube3(2)

Scene .addGl(b)

c=Ziko. Events. Channel( "test")

btn("Update Scene Color") .onClick(( )=>[

const Color=Random.color( )

Scene . background(Color)

c. emit("update scene color", Color

c. on( "update scene color" , e=>Scene[0]color(e))

btn("Update Mesh Color") .onClick(()=>

const Color=Random.color ( )

Scene[0] .color (Color)

c. emit("update mesh_ color" , Color )

))