How to set Camera farClipPlane or far at runtime?

Tried using this.cam?.farClipPlane = 100; in a copy of orbitcam, I get ERROR: Invalid assignment target

Original Post on Discord

by user 103054507105067008

Removed the ‘?’ but changing the far clip plane doesn’t seem to do anything at runtime in local server?

by user 103054507105067008

This object is over 900m long and setting the perspective camera far to 0.5 and near to 0.001 at runtime doesn’t change the far clipping

by user 103054507105067008

Changed the channel name: How to set Camera farClipPlane or far at runtime?

by user 103054507105067008

No luck with this either as I just wondered if the OrbitControls was using its own local cam, what am I doing wrong here?

        //@ts-ignore
        const perspCam = this.context.mainCamera as THREE.PerspectiveCamera;
        perspCam.near = 0.0165;
        perspCam.far = 0.69;
        //perspCam.far = this.maxZoom + 100;
        console.log(perspCam);

by user 103054507105067008

This without the questionmark is correct (you need to set it on the component since it will override the threejs camera settings when it gets applied)

@marcel :cactus: I used that, tried setting it to 1, makes no difference in the local server? Only thing that has any impact is me setting it on the Camera component in Unity then saving before I hit play but I can’t change it at runtime

by user 103054507105067008

Also tried this, no luck

        //@ts-ignore
        this.cam.farClipPlane = 1;

by user 103054507105067008

In the end, this was what worked: //@ts-ignore this.context.mainCameraComponent.farClipPlane = 0.5;

by user 103054507105067008

Great. Its what i meant here