Important Geenee SDK rendering pipeline callbacks:
Use it in 'Model' level custom code.
this is an analog of requestAnimationFrame
-based render loop but in good sync with camera feed and image recognition algorithm. You just need to reassign onRender function
const render = (context) => {
console.log(context, 'frame is rendered');
// look at the camera
this.object3D.lookAt(this.activeSceneModel.camera.position);
this.object3D.rotation.x = 0;
this.object3D.rotation.z = 0;
}
this.activeSceneModel.userCallbacks.onRender = render;
where context
- is a Canvas Context with a following properties:
gl: THREE.WebGLRenderer;
aspect: number;
subscribe: (callback: React.MutableRefObject<RenderCallback>, priority?: number) => () => void;
setDefaultCamera: (camera: Camera) => void;
invalidate: () => void;
intersect: (event?: DomEvent) => void;
camera: Camera;
raycaster: THREE.Raycaster;
mouse: THREE.Vector2;
clock: THREE.Clock;
scene: THREE.Scene;
size: RectReadOnly;
viewport: ViewportData;
events: DomEventHandlers;
forceResize: () => void;