How do I access the camera viewport width in code?

Hi. How do I access the camera viewport width in code?

I tried:
this.cameraEntity.camera.viewport[2]=0;
and
this.cameraEntity.camera.viewport.width=0;

but neither of those worked :frowning:

Any ideas?

Hi @Grimmy,

It’s a pc.Vec4, and the property name is rect:

Try this:

const rectWidth = this.cameraEntity.rect.z;

https://developer.playcanvas.com/en/api/pc.CameraComponent.html#rect

2 Likes

Perfect. Thanks!

1 Like