Skip to Content
ExamplesSend the camera to Substance 3d API

Send the camera to Substance 3D API

The viewer can be used in conjunction with the Substance 3D API  to visualize your scene before sending it to the API.

This example demonstrates how to send the camera’s position and target coordinates from the viewer to the Substance 3D API.

Example

You can find a more complete example on Github : https://git.corp.adobe.com/clockwork/a3d-viewer/tree/develop/examples/src/examples/cameraForSubstance3dApi 

How to implement

Using npm :

npm install @a3d-viewer/viewer

Importing :

import { getCameraTransform } from '@a3d-viewer/viewer'

To get the camera information needed by the API, you can use getCameraTransform to easily convert the viewer’s camera to the format required by the API:

import { getCameraTransform } from '@a3d-viewer/viewer' const viewer = document.querySelector('a3d-viewer') // Pass the viewer's camera to get the transform const cameraTransform: Transform = getCameraTransform(viewer.viewerDetails.camera) // Example of how to calculate focal length from field of view (FOV) const focal = fovToFocal(viewer.viewerDetails.camera.fov, viewer.offsetWidth, viewer.offsetHeight) // The matrix can be send to the API console.log(cameraTransform.matrix) // The API uses focal length instead of FOV console.log(focal)
Last updated on