Device camera not rendering with 3d background

Hi, I have been trying to show the device camera on needle engine export from Unity but it does not work. I have created a needleruntime project on stackblitz and it works there. But the same code does not work when I export it from Unity. Here is my stackblitz code.

Original Post on Discord

by user 373346625025736705

It will work the same way when you add it to your web project. That’s not exported from Unity unless you put the code in a typescript class and make it a needle engine component which you can then assign in Unity.

Just copy paste the code from main.ts from stackblitz into the main.ts in your web project that you have setup in unity and you are done :slightly_smiling_face:

To open the web project just click “Open Workspace” on the ExportInfo component :slightly_smiling_face: i hope that helps

Yeah, thats exactly what I have done. The camera also turns on, but does not render. I tried making the body background transparent, make the unity camera solid and trasparent, but nothing works

by user 373346625025736705

Try one of these

  • adding the camera behind the needle engine element + set the camera to solid color and alpha 0
  • or adding your video element to the shadowDom (assuming your project in unity uses needle engine >= 3.7.x). That would be context.domElement.shadowRoot (or shadowDom? Sorry just on the phone here right now ^^ its already late)

Tried the second one, it works. Thanks a lot.
Sorry for pinging this late. Can I know what time zone you guys are in, so next time I will try to ask questions in office hours. I am working on a mediapipe AR face filter app, and may ask questions as I keep getting stuck.

by user 373346625025736705

No worries, just ask anytime.
We are in cest
Good to hear that you got it working :slightly_smiling_face: looking forward to what you make!