API Example: Camera Orbit

Try it out:

Orient the seen above to the desired view and then click the button below to get the yaw and pitch values.

Enter yaw and pitch angles (degrees) in the boxes below and click the button to immediately update the camera orbit in the example.

How it works:

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

Getting and displaying camera orbit:

function getCameraOrbit(displayElement) {
	// Get Explorer element by id
	var voyagerElement = document.getElementById("voyager");
	// Call getCameraOrbit() on the object and store the resulting array
	const orbitAngles = voyagerElement.getCameraOrbit();
	
	// Format the angles and assign to the inner text of
	// the passed in display element
	displayElement.innerText = "Yaw: " + orbitAngles[0] + "	Pitch: " + orbitAngles[1];
}

Setting new camera orbit values:

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