Class: WebScene

WebScene

Describe the objects of content, style, environment settings, and elements in the current scene. Corresponding to the WebScene standard JSON file

new WebScene()

Name Type Description
options.authoringApp String

Generate the app name for webScene

options.authoringAppVersion String optional

Generate the app version number for webScene

Methods

static toJSON(options){Object}

Save a WebScene object as JSON and return it

Name Type Description
options Object

Save parameters

Name Type Default Description
webScene WebScene

The webScene object to be saved. Required

template boolean false optional

Do you want to save as a template

Returns:
Type Description
Object Return the current scene information.
Examples
// Save the webscene and return the result
const currentWebScene = viewer.webScene;
SuperMap3D.WebScene.toJSON({
webScene: currentWebScene,
      });
// Save the webscene template and return the result
const currentWebScene = viewer.webScene;
SuperMap3D.WebScene.toJSON({
webScene: currentWebScene,
template : true
      });

static toJSONAndDownload(options){undefined}

Save a WebScene object as JSON and download it locally

Name Type Description
options Object

Save parameters

Name Type Default Description
webScene WebScene

The webScene object to be saved. Required

name String optional

Name of the saved JSON file

template boolean false optional

Do you want to save as a template

Returns:
Type Description
undefined undefined
Examples
// Save the webscene to a JSON file named 'test' and download it
const currentWebScene = viewer.webScene;
SuperMap3D.WebScene.toJSONAndDownload({
webScene: currentWebScene,
name: "test",
      });
// Save the webscene template to a JSON file named 'testTemplate' and download it
const currentWebScene = viewer.webScene;
SuperMap3D.WebScene.toJSONAndDownload({
webScene: currentWebScene,
name: "testTemplate",
template : true
      });

fromJSON()

Read the JSON file of WebScene. Apply the settings in the WebScene file to the scene

Example
// Read a JSON file and set it to WebScene.
// fileStream is the file stream read by FileReader
const jsonObj = JSON.parse(fileStream);
const currentWebScene = viewer.webScene;
currentWebScene.fromJSON(jsonObj);