private cam: Camera;
onEnable() {
this.cam = this.gameObject.getComponent(Camera);
}
onAfterRender(){
this.cam.renderNow();
}
Something like this- typed on a phone, canāt verify right now
Might be the method is called something else?
Or Iām importing the wron camera
(I might add that TypeScript is very new to me, so things move a bit slow⦠)
by user 219335701790064640
Camera from @needle-tools/engine, not the one from three
Tried both
by user 219335701790064640
Then Iāll have to check later, sorry, on the go right now
You can check if intellisense gives you the right name
I scrolled through all definitions.
But thereās no hurry, I can wait
Thank you anyway!
by user 219335701790064640
I think its this.context.renderNow(myCam)
Or just use the threejs renderer directly, you can access it with this.context.renderer
Hereās a WIP for a custom āCameraLayerā
import { Behaviour, Camera } from "@needle-tools/engine";
import { PerspectiveCamera } from "three";
// Documentation ā https://docs.needle.tools/scripting
export class CameraLayer extends Behaviour {
private cam: Camera | null = null;
onEnable() {
// getting the Camera component from the same GameObject
this.cam = this.gameObject.getComponent(Camera);
if (!this.cam) {
console.warn("CameraLayer requires a Camera component");
this.enabled = false;
}
}
onAfterRender(): void {
if (!this.cam) return;
// we remember the current background as we want to turn it off for the layer
const currentBackground = this.scene.background;
// we don't want automatic color clear anymore here
this.context.renderer.autoClearColor = false;
// if this is a Perspective Cam, update the aspect
if (this.cam.cam instanceof PerspectiveCamera) {
this.context.updateAspect(this.cam.cam);
}
// clear background, render, and restore the background
this.scene.background = null;
this.context.renderNow(this.cam.cam);
this.scene.background = currentBackground;
}
}
I can not for the life of me get the other camera to render
Iāve copied your code and have to cameras in my scene. Both cameras, as of now, is set to render the whole scene but from differen angles. But I only see what āMain Cameraā is rendering.
Is there perhaps some setup in the scene I am missing?
by user 219335701790064640
Updated the code, now it should work
Make sure the component is on the ālayeredā camera
Make sure your main camera is tagged āMainCameraā
Hereās how it should look for two cameras, the second one just draws on top of everything.
So weird. The code makes every sense as well?
Hereās a screen grab of the two cameras aswell (FX Camera is the layered one)
Is there something Iām doing wrong?
by user 219335701790064640
looks ok. maybe put it on ādefaultā layer for now for testing?
I made a texture the render target and put a Raw image on top of the screen to confirm that the camera is indeed working, but I canāt seem to get it to render to the screen.
This is very confusing, it should work
by user 219335701790064640
Is it possible to get a videocall or something? Another day perhaps?
If I can get this method to work Iām pretty much set regarding the project Iām working on
by user 219335701790064640
Can you make an empty scene with just two cameras (one MainCamera) and a cube, and the second cam having the script?