Is it possible to load models from three js to Unity

I’m trying to add my gltf models from three js to Unity through needle typescript. But I couldn’t able to figure out how to add it out.

Original Post on Discord

by user 1000084301179785266

If you are importing a gltf model then I’m assuming it is somewhere on your computer downloaded, If not, download it and then import it to unity by dragging it into the scene

by user 483253293477265409

No dude. I’m getting the gltf model data from avatar sdk plug-in. I can even add the plug-in in Unity. But rendering for Unity webgl is not good enough. So I’m trying to use it from needle!!

by user 1000084301179785266

this?

by user 483253293477265409

Yaah

by user 1000084301179785266

https://docs.avatarsdk.com/unity-plugin/3.0.1/scene_09_fullbody_export_sample.html

by user 483253293477265409

maybe that is useful

by user 483253293477265409

Yeah okay. But I really wanna to know is it possible to add meshes or models from three js to Unity through needle. Let’s please stick to this question!!

by user 1000084301179785266

I think @AFR is trying to understand what the actual question is -

  • you can import glTF/glb both in editor (in Unity) and at runtime (in the Browser)
  • if your plugin can export glTF/glb you can get those files into your runtime, yes.

I’m creating mesh from that gltf model and add to into Gameobject.Instantiate(mesh) but it’s not working. Im getting mesh from gltf model. But adding seems not working.

by user 1000084301179785266

I’m using Gameobject.Instantiate() in typescript

by user 1000084301179785266

I think I’ll need more context / sample code to understand what you’re trying. You can load glTF files at runtime, yes.

I’m newbie in js and ts. so pardon me if the code is dumb enough!!,

so this is part of avatar sdk script which creates gltf model, from here i’m getting the model “window.finalModel”
image.png

by user 1000084301179785266

And i’m taking the model into typescript of needle which i’m trying to instantiate the gameObject in unity. I know somewhere i’m going wrong adding that model to gameobject and instanitate the gameobject, but i don’t know where
image.png

by user 1000084301179785266

Where do you place in / call from the first code? Is that also a component?

when you have your model loaded in the code above (gltf.scene) it is already your “GameObject” that you try to create in the onClick method. (a GameObject in Needle Engine is defacto a three.js Object3D)

When you write code in typescript there is nothing like a Unity scene anymore - what you deal with there is the threejs scene in the browser. I

I assume when you say “get it back to Unity” you mean you want to render your model in the browser - is that correct?

Okay. Cool!! So we can’t create a Unity Gameobject from typescript. Got it.

by user 1000084301179785266

Is it possible to add needle on top on existing Unity project and make it run in web??

by user 1000084301179785266

So we can’t create a Unity Gameobject from typescript
You can create GameObjects from TypeScript. I’m still not sure what the question is

Yes, that’s one of the core ideas. You can write matching TypeScripts for your C# components (many built-in Unity components will “just work”) and run it in the web.