playcanvas / engine

Powerful web graphics runtime built on WebGL, WebGPU, WebXR and glTF
https://playcanvas.com
MIT License
9.73k stars 1.36k forks source link

[BETA] ESM Multi-Camera script updates #7078

Closed kpal81xd closed 3 weeks ago

kpal81xd commented 3 weeks ago

N.B. This script is currently in beta and not finalized

Usage

import { MultiCamera } from 'playcanvas/scripts/camera/multi-camera.js';
// ...
const camera = new Entity('camera');
camera.addComponent('script');
const script = camera.script.create(MultiCamera);

// optional: set scene size
script.sceneSize = 100

// focus
const point = new Vec3(0, 0, 0);
script.focus(point);
// or
const start = new Vec3(0, 20, 20);
script.focus(point, start);

// zoom
script.resetZoom(start.distance(point));