API Example: Camera Offset

Try it out:

Orient the scene above to the desired view and then click the button below to get the current offset values.

Enter offset values in the boxes below and click the button to immediately update the camera offset in the example. Values outside of the limits imposed by the scene will be clamped to the min/max.

How it works:

See the annotated javascript from this page below for one way to use the ‘get’ and ‘set’ camera offset functions.

Getting and displaying camera offset:

function getCameraOffset(displayElement) {
	// Get Explorer element by id
	var voyagerElement = document.getElementById("voyager");
	// Call getCameraOffset() on the object and store the resulting array
	const offset = voyagerElement.getCameraOffset();
	
	// Format the offset values and assign to the inner 
	// text of the passed in display element
	displayElement.innerText = "X: " + offset[0].toFixed(3) + "	Y: " + offset[1].toFixed(3) + "	Z: " + offset[2].toFixed(3);
}

Setting new camera offset values:

function setCameraOffset(x, y, z) {
	// Get Explorer element by id
	var voyagerElement = document.getElementById("voyager");	
	// Call setCameraOffset() on the object with the values
	// of the x, y, and z input elements as params
	voyagerElement.setCameraOffset(x.value, y.value, z.value);
}