5 ms·
Synchronize a 3D scene across multiple windows using Three.js and localStorage
- summitsummit 3y agoi wonder if a visual of any kind would help
- CharlesW 3y agoI believe that it's this: https://twitter.com/_nonfigurativ_/status/1727322594570027343 https://twitter.com/_nonfigurativ_/status/172732259457002734...
- Arrath 3y agoThat is neat as hell!
- dorkwood 3y agoThis can be said about 99% of GitHub repositories. When I first started using GitHub, I thought there must be some reason that no one ever included images in their README. Maybe it's not considered cool, I thought.
- janosdebugs 3y agoVisuals are hard to include because you need to store them somewhere. If you store the in the git repo, they bloat the repo. It's really annoying to clone a repo and having to wait forever because it has a bunch of binaries in it. I try to use SVG whenever possible, sometimes animated with CSS (see example[1]) as they are made if text and are much smaller. When I need non-SVG images, I host them externally, but that's a bit if an overhead and you need to make sure you don't break the image link accidentally. [1] https://github.com/gotesttools/gotestfmt https://github.com/gotesttools/gotestfmt
- rossant 3y agoI believe if you just copy paste an image in the GitHub text editor, or drag and drop one into it, GitHub will automatically upload it to their own image upload service and will insert the markdown code to show it.
- janosdebugs 3y agoI believe that's true, but I'd guess most people don't edit their README using the GitHub editor.
- jerbear4328 3y agoYeah, it's confusing to see empty READMEs like this, especially for a visual effect. The demo is at https://bgstaal.github.io/multipleWindow3dScene/ https://bgstaal.github.io/multipleWindow3dScene/ if you want to play around with it.
- supermatt 3y agoIs there some reason to prefer localStorage over https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_Channel_API https://developer.mozilla.org/en-US/docs/Web/API/Broadcast_C... ?
- brunohaid 3y agoBroadcast is messaging only, localStorage can elegantly handle messaging and state data.
- supermatt 3y agoBroadcast gives access to structuredClone and transferable objects. i.e. much reduced latency, which I would have thought desirable for this specific use-case (synchronising a 3d scene)
- dzign 3y agoNice discussion here : https://www.reddit.com/r/nextfuckinglevel/s/d7J6dCZ5s9 https://www.reddit.com/r/nextfuckinglevel/s/d7J6dCZ5s9
- pvg 3y agoDiscussed the other day here https://news.ycombinator.com/item?id=38413660 https://news.ycombinator.com/item?id=38413660
- brightball 3y agoSaw a great lightning talk about Three.js this summer. Had no idea what could be done with it before and it was a little mind blowing. https://youtu.be/QXPYYfxnTPU?si=Y56UmEhC8y3HkIPj https://youtu.be/QXPYYfxnTPU?si=Y56UmEhC8y3HkIPj
- SamBam 3y agoI would be fun to create a game with this. I'm imagining something where the different windows allow different affordances. E.g. one window is your night-vision specs and the other is your HUD. Or perhaps you have six or more windows of some fixed small size, but you need to keep track of a large and changing scene, so you need to place them carefully to track as much of the landscape as possible. Maybe each window is one of a spider's eight eyes.
- greggman6 3y ago[dead]
- jerbear4328 3y agoA link to try this yourself: https://bgstaal.github.io/multipleWindow3dScene https://bgstaal.github.io/multipleWindow3dScene The popular version by the same author with the very fancy graphics: https://twitter.com/_nonfigurativ_/status/1727322594570027343 https://twitter.com/_nonfigurativ_/status/172732259457002734... (Code is not public, this demo sparked the whole thing) The other project like this on HN the other day used Broadcast Channels instead of localStorage, so it didn't have the delay this one has: GitHub (has a GIF): https://github.com/Momciloo/fun-with-sockets/ https://github.com/Momciloo/fun-with-sockets/ HN discussion: https://news.ycombinator.com/item?id=38413660 https://news.ycombinator.com/item?id=38413660
- abetusk 3y agoIn my opinion, the magic here is the `window.screen[XY]`, not the communication method, which could be anything. As others have mentioned, you can do this with localStorage, websockets or even Cookies. The novelty is that each window knows its size and location (through `window.*`) and renders something interesting. I was a bit surprised to see that the browser gives information of where the window is in the window manager as I would have guessed that to be privileged information and a potential security issue, but what do I know.
- AustinDev 3y ago>I was a bit surprised to see that the browser gives information of where the window is in the window manager as I would have guessed that to be privileged information and a potential security issue, but what do I know. My browser doesn't do that. Well it always reports. [0,0]
- abetusk 3y agoGoing to let us in on the secret?