assets

Managing assets

Methods

(static) addRoot(urlRoot)

Add a location to search for scene assets.

Parameters:
Name Type Description
urlRoot string

URL root of location

(static) getImageUrl(id, options) → {String}

get the url for optimized images.

Parameters:
Name Type Description
id String
options Object

options for optimize image with thumbor

Returns:

the url pointing to the asset.

Type
String

(static) getUrl(id) → {String}

get the url for the asset.

Parameters:
Name Type Description
id String
Returns:

the url pointing to the asset.

Type
String

(static) importImage(image, options)

This will upload an image, add an image node to the scene graph, and return an object with the id of the new node, and the id of the uploaded asset.

If you save the assetId, that assetId can be passed into this function to get a new image node for the scene. That means you can restore the state of a scene without having to reimport the previous image.

See The demo example for an example of usage.

Parameters:
Name Type Description
image File | String

A File to import, an assetId from a previous import, or url src of image.

options Object
Properties
Name Type Description
resizeTo Number

A max width/height to resize the image to (preserves aspect ratio of image)

targetFormat String

the format of the result image when importing

quality Number

compression level of the result image

dpi Number

dpi of the result image, default is 72

scale Number

index to scale the picture

keepAspectRatio Boolean
Returns:

Promise resolve to an object with assetId and imageNodeId keys