You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Put it anywhere in your scene to render a camera video behind your 3D scene Live demo
import{Behaviour,ClearFlags,RGBAColor}from"@needle-tools/engine";exportclassVideoBackgroundextendsBehaviour{asyncawake(){// create video element and put it inside the <needle-engine> componentconstvideo=document.createElement("video");video.style.cssText=` position: fixed; min-width: 100%; min-height: 100%; z-index: -1; `this.context.domElement.shadowRoot!.appendChild(video);// get webcam inputconstinput=awaitnavigator.mediaDevices.getUserMedia({video: true})if(!input)return;video.srcObject=input;video.play();// make sure the camera background is transparentconstcamera=this.context.mainCameraComponent;if(camera){camera.clearFlags=ClearFlags.SolidColor;camera.backgroundColor=newRGBAColor(125,125,125,0);}}}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Put it anywhere in your scene to render a camera video behind your 3D scene
Live demo
Beta Was this translation helpful? Give feedback.
All reactions