View Projection
View projection is about setting up the virtual camera and getting the right shot. To date, strahl only supports perspective view projection as encountered in real life.
In order to setup view projection, a camera is required. If available, the associated controls must also be configured in order for the path tracer to register on changes and update the view as the controls are updated.
Basic Configuration
strahl offers basic camera configuration which is suitable for minimal cases. It permits configuring the camera viewport and some basic input.
runPathTracer(target, model, {
viewProjectionConfiguration: {
matrixWorldContent: [
-0.2902260614937414, 5.55111512312578e-17, 0.9569581146684689, 0,
0.27060288181982683, 0.9591865617562106, 0.08206838670951949, 0,
-0.9179013637535542, 0.28277400825800514, -0.2783809380562283, 0,
-3.1605996990714327, 0.8489691327469515, -0.6658356804354517, 1,
],
fov: 1.0,
aspect: 0.1,
cameraTargetDistance: 10,
},
});
matrixWorldContent— rotation and position of the camera as4x4matrixfov— field of view of the camera in degreesaspect— aspect ratiocameraTargetDistance— the distance to the center that theOrbitControlsshould orbit around
To get the matrixWorldContent of the current scene, you can use the corresponding lifecycle hook as described in Lifecycle Hooks.
Full Configuration
Alternatively, you can also set up custom camera and control instances. For details on how to setup the PerspectiveCamera, see Three.js PerspectiveCamera.
An example configuration may look like:
import { PerspectiveCamera } from "three";
const camera = new PerspectiveCamera(38, 1, 0.01, 1000);
(Optional) Camera Controls
strahl supports arbitrary controls, to set up, use for example:
import { OrbitControls } from "three/examples/jsm/Addons.js";
const controls = new OrbitControls(camera, canvas);
Tying it to strahl
The camera configuration can be passed to strahl as an optional parameter, to do so:
runPathTracer(target, model, {
viewProjectionConfiguration: {
camera,
controls,
},
});
strahl will attach itself to the controls to be notified of changes.