Code Monkey home page Code Monkey logo

multiplewindow3dscene's Introduction

Multiple Window 3D Scene using Three.js

Introduction

This project demonstrates a unique approach to creating and managing a 3D scene across multiple browser windows using Three.js and localStorage. It's designed for developers interested in advanced web graphics and window management techniques.

Features

  • 3D scene creation and rendering with Three.js.
  • Synchronization of 3D scenes across multiple browser windows.
  • Dynamic window management and state synchronization using localStorage.

Installation

Clone the repository and open index.html in your browser to start exploring the 3D scene.

git clone https://github.com/bgstaal/multipleWindow3dScene

Usage

The main application logic is contained within main.js and WindowManager.js. The 3D scene is rendered in index.html, which serves as the entry point of the application.

Structure and Components

  • index.html: Entry point that sets up the HTML structure and includes the Three.js library and the main script.
  • WindowManager.js: Core class managing window creation, synchronization, and state management across multiple windows.
  • main.js: Contains the logic for initializing the 3D scene, handling window events, and rendering the scene.
  • three.r124.min.js: Minified version of the Three.js library used for 3D graphics rendering.

Detailed Functionality

  • WindowManager.js handles the lifecycle of multiple browser windows, including creation, synchronization, and removal. It uses localStorage to maintain state across windows.
  • main.js initializes the 3D scene using Three.js, manages the window's resize events, and updates the scene based on window interactions.

Contributing

Contributions to enhance or expand the project are welcome. Feel free to fork the repository, make changes, and submit pull requests.

License

This project is open-sourced under the MIT License.

Acknowledgments

  • The Three.js team for their comprehensive 3D library.
  • x.com/didntdrinkwater for this readme.

Contact

For more information and updates, follow @nonfigurativ on Twitter.

multiplewindow3dscene's People

Contributors

bgstaal avatar younesbram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multiplewindow3dscene's Issues

Getting Started - For all those who are confused.

If you looked at this Twitter Post and came here to reproduce what was shown in the video, locally, you might be a bit confused.
Since the repo seems to be stagnant and the README is a bit vague, I am attempting to clear up some of the confusion.


General Usage

If you simply wish to try the project out, there's a live deployment.
Although this doesn't work as intended on my browser.

Or, if you want to try it out locally, you need to:

  • Clone the repository.
  • Start a server using the cloned repo using any tool of your liking (try serve, or live-server), then go to the server url in your browser.

Note: Simply opening index.html will show you a white screen.
At this point, you will see a spinning cube with red edges, that means everything is fine.


What about the Spheres?

This is just a stripped down version of that project, intended to be a basic example, hence the red cube. You can create someting similar by experimenting a bit. See here.


Note: These answers have been posted in other issues on this repo as well, I have tried to put all the basic answers together in one place. If @bgstaal wants, I can add these in the README as well.


How do we run this?

Sorry if this is a dumb question, but how do we run this code?

I tried loading the html file in a browser, but got errors in the browser console...

Access to script at 'file:///D:/multipleWindow3dScene-main/main.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome-untrusted, https, edge.
main.js:1

Failed to load resource: net::ERR_FAILED

Please advise (in simple terms!) how we run this amazing code.

Thanks

Function to call another function

What is the point of the function windowsUpdated? All the function do is just call another function. It seems like it could be removed from the code.

Could you share the full demonstration code?

Hi, I saw the original video and it's really amazing, but when I tried to play locally, I only saw a simple cube.

Many people may have the same problems when runing this project at first sight.

Could you share the full demonstration code?

See also #17 (comment), #10.

Cors Policy

How to solve this :
Access to script at 'file:///D:/user/Threejs/multipleWindow3dScene-main/main.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

Overlapping objects in split screen

If we use split screen (feature available in Microsoft edge browser) the object gets duplicated onto the screen (check first screenshot) and when we exit the mode, it becomes one, but strangely (as in second screenshot), and this window gets isolated from other windows and other windows can no longer participate with this window (third screenshot).

SCREENSHOT 1
SCREENSHOT 2
SCREENSHOT 3

ps: I'm a beginner here and also trying to understand what and why's that happening,

Addressing the video --'Viral Video of Two Spherical Earths Syphoning Particles' -- Answer is HERE:

Screenshot 2024-02-04 201543

If you have come here and on a whim downloaded this code ( like I did ),
It can be frustrating to just discover that it displays '3D wire-cubes'.

I can understand the confusion you arrive to, after I have spent some time digging into this to seek an answer (...and maybe the source code..), so fear not; read on for a better understanding to where this code is at, and what's going on in the posted picture.


The Source Code:
If you came here for a copy paste, please don't shoot the messanger on this one. .
The true author behind the work above, is actually (I didn't know this existed) an artist. You can see the true poster and more of his work's links on his twitter here.

"Okay? Well I want to do that 'thing in the photo'"

  • Download this repo, and start to poke and play around.
  • Go outsource information on three.js. Get a understanding of its range of potential.
  • After this it's fuzzy for me to answer.

I have picked this up a project knowing very little in python. I wanted to tackle a project while going through the college course and learn navigation, function, and writing.

So I am novice on this input; just wanted to have a explanation to anyone coming here from any media source of that video. Wanted to give it's credit, and help OP 'bgstall' with the barrage of request for that.

Hope this helped.

-Notes-
I can say from my time on this project its a very adept learning curve, but a rather fun and addicting one.
Play around with creating your own shapes, or importing a three.js model.
Play around with containers for the spheres to get the photo reference's results.

Will post 'pull request' if I manage to get something similar to what Biorn Staal created in the reference photo.

It shows as cubes, not as sphere. how to fix it?

Starting up http-server, serving ./

http-server version: 14.1.1

http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none

Available on:
http://127.0.0.1:8080
http://172.31.196.87:8080
Hit CTRL-C to stop the server

[2023-11-26T11:55:38.646Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
(node:375) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use node --trace-deprecation ... to show where the warning was created)
[2023-11-26T11:55:39.144Z] "GET /three.r124.min.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:39.162Z] "GET /main.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:40.009Z] "GET /WindowManager.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:49.924Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:50.115Z] "GET /three.r124.min.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:50.367Z] "GET /main.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:50.742Z] "GET /WindowManager.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:50.926Z] "GET /favicon.ico" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:55:50.929Z] "GET /favicon.ico" Error (404): "Not found"
[2023-11-26T11:56:04.475Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:56:04.808Z] "GET /three.r124.min.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:56:04.908Z] "GET /main.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:56:05.956Z] "GET /WindowManager.js" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:56:06.154Z] "GET /favicon.ico" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:56:06.158Z] "GET /favicon.ico" Error (404): "Not found"
[2023-11-26T11:57:39.339Z] "GET /favicon.ico" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"
[2023-11-26T11:57:39.340Z] "GET /favicon.ico" Error (404): "Not found"

White Screen

I cloned the repo and then open index.html but the screen is only White and nothing else! any idea?
image

Development of this amazing project

Thanks for this amazing code!! Based on this multiwindow interaction code, we build a Multi-window Interactive Planet-Satellite System. Check it here.
demo

We hope this can provide some help to anyone who wants to play with this codebase.

HMR & clear localstorage

This issue occurred while I was reading the code.
I opened the live server plugin in vscode. After I modified the code page and updated it, the Windows data in the local storage would be garbled. The length of the array will become longer. And it cannot be fixed, even if cleaning up local storage. (The reason is that Windows Manager has already saved incorrect data and is listening for storage changes. Therefore, the error data has been continuously recovered.)
It may never appear in a production environment.

How to run this

Hi,
I know this question has been answered before, but I am very new to coding, and need a detailed explaination of how and where I am supposed to run this code.

Thank you

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.