[SOLVED] How to viewport of camera (splitscreen)


#1

I try to set the viewport parameter

image

var OrigCam = pc.createScript('origCam');

// initialize code called once per entity
OrigCam.prototype.initialize = function() {
    var cameraComponent = entity.camera;
    cameraComponent.viewport = new pc.CameraComponent().viewMatrix.set ...(?)
};

{with help from https://developer.playcanvas.com/en/api/pc.CameraComponent.html}


#2

You need this:

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

So, this would give you the default, fullscreen viewport:

    this.entity.camera.rect = new pc.Vec4(0, 0, 1, 1);

This would restrict rendering to the lower left of the screen:

    this.entity.camera.rect = new pc.Vec4(0, 0, 0.5, 0.5);

#3

thanks Will, … it works