Skip to content

How to render 2 different perspectives of the same scene (e.g. Split-Screen) #166

Answered by jnsmalm
lovelle-cardoso asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, you can do something like this:

class SplitScreen extends PIXI3D.CompositeSprite {
  constructor(renderer, object) {
    super(renderer, {
      width: renderer.width, height: renderer.height / 2, objectToRender: object
    })
    this.camera = new PIXI3D.Camera(renderer)
    this.camera.aspect = this._renderTexture.width / this._renderTexture.height
  }

  renderObject(object) {
    let currentCamera = PIXI3D.Camera.main
    this.camera.aspect = this._renderTexture.width / this._renderTexture.height
    PIXI3D.Camera.main = this.camera
    super.renderObject(object)
    PIXI3D.Camera.main = currentCamera
  }

  changeSize(width, height) {
    this._renderTexture.resize(width, height, 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@lovelle-cardoso
Comment options

Answer selected by lovelle-cardoso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants