Creating a Presentation
This example demonstrates how to retrieve an existing presentation object, extract its JSON definition, modify its contents, and then apply the updated JSON to a new presentation using the IPresentation.PresentationJSON property. Instead of building a presentation definition entirely from scratch, this approach lets you start from a working presentation created in TerraExplorer, adjust only the relevant parts (for example, add a new action or edit parameters), and then generate a new presentation with the modified JSON. This method is often easier and more reliable than constructing the full JSON manually from the presentation schema.
try {
// Get existing presentation and extract its JSON
var oldPresentation = SGWorld.ProjectTree.GetObject(
SGWorld.ProjectTree.FindItem("Auburn - Fireworks & Water Body")
);
var json = JSON.parse(oldPresentation.PresentationJSON);
// Create new action as JSON object
var actionFlyTo = {
actionType: "FlyTo",
description: "",
options: {
activationAction: "Circle pattern",
duration: 5,
poi: {
altitude: 1494.09375,
distance: 3877278.555371787,
isRelative: false,
viewerPitch: -72.06956713327715,
viewerYaw: 355.4828574744612,
x: -103.95114771762604,
y: 35.60232149209262
}
}
};
// Add the newly created action to the existing JSON and set the JSON into a new presentation
json.presentation.steps[0].actions.push(actionFlyTo);
var newPresentation = SGWorld.Creator.CreatePresentation("", "New Presentation");
newPresentation.PresentationJSON = JSON.stringify(json);
} catch (ex) {
alert(ex);
}