Hello, i’m new to Needle Engine and three.js in general and I was trying to figure out how exactly a workflow for my needs would look like.
I need to add some simple mini-games to a next.js project. To make these mini-games i wanted to use unity as i have some experience in it and it seems like a good base for creating my environments. However im quite confused as to how exactly i can export a project from unity and use it through next.js. Right now my exports create a /dist folder with /assets /include subfolders and an index.html that is used to hold everything.
As an example i started with the Musical Instruments sample, and it produces a glb file and some that i can use by grabing its scene and rendering it like the next.js and react needle examples show (add it to a threejs canvas and tadaa).
However im still now quite sure how exactly i could interact with scripts that i made in unity (technically .ts scripts as pure c# doesnt work. figured that out).
Is there some object attached to the window that im supposed to call? Are the scripts within the glb object?
If for example within my game i have 4 levels, and i need to know at which level the user’s at, but that information is fetched from my next.js wrapper app, how can i pass that to my game?
This might be a noob question but im really confused and i couldnt quite get an answer from the samples and documentation.
Thank you so much in advance
Hi Helgi! I’m an AI-powered assistant here to help you. While I can’t answer your question directly, I can help with topics related to Needle Engine, three.js, and basic Unity or Blender support. Please let me know your OS, Needle Engine version, and Unity or Blender version you’re using, and I’ll do my best to assist you!
2 replies left - GPT 4O thread_2CUEhhiH5yc3VZNS9KJj9b4E Reply to this message to continue the conversation
there are many ways to structure your app and pass your data around.
For example in sveltekit + Needle you can read/write and subscribe to Svelte stores to let components react to the state of your app. The same would be true for react or next where this could be e.g. zustand.
There are also a bunch of samples that might be helpful but generally speaking: you’re using Unity to setup your data and state and this information gets exported and is then stored in the glTF. When your web app starts we load the glTF and create the components with your data that you setup in Unity (with all the hierarchy, materials, animations) and your scripts are like in any other javascript web app accessible.
I’ll link a few videos for you below that might help you to get started:
Samples:
Quick Stackblitz example using a scene from our website where I just access some objects / add components for dragging the people:
I hope it helps. We’ll add more examples - please let me know if things are still unclear