Skip to main content

@novorender/api / OfflineScene

Class: OfflineScene

Defined in: @novorender/src/offline/scene.ts:18

An offline scene.

Remarks​

This class supports incremental synchronization between offline and online storage. Error and status updates are reported to the logger property. By default it's undefined, so to display status, events and progress, you must assign your own object implementing the Logger interface.

Accessors​

id​

Get Signature​

get id(): string;

Defined in: @novorender/src/offline/scene.ts:35

Get the scene id.

Returns​

string

Constructors​

Constructor​

new OfflineScene(
context,
dir,
manifest): OfflineScene;

Defined in: @novorender/src/offline/scene.ts:21

Parameters​

ParameterTypeDescription
contextOfflineViewStateThe offline context for this scene.
dirOfflineDirectoryOPFSThe storage directory for this scene.
manifestSceneManifestThe file manifest this scene. Remarks Initially, this may be empty or partial. It may change when the scene is synchronized.

Returns​

OfflineScene

Methods​

delete()​

delete(): Promise<void>;

Defined in: @novorender/src/offline/scene.ts:40

Delete all downloaded files for this scene and remove it from the context's list of offline scenes.

Returns​

Promise<void>


deleteStaleFiles()​

deleteStaleFiles(sceneIndexUrl, abortSignal): Promise<boolean>;

Defined in: @novorender/src/offline/scene.ts:122

Delete files which are no longer used by the current manifest

Parameters​

ParameterTypeDescription
sceneIndexUrlURLThe url to the scene index.json file, complete with sas key.
abortSignalAbortSignalA signal to abort downloads/synchronization.

Returns​

Promise<boolean>

True, if completed successfully, false if not.

Remarks​

Errors are logged in the logger.


getUsedSize()​

getUsedSize(): Promise<number>;

Defined in: @novorender/src/offline/scene.ts:58

Get total number of used bytes.

Returns​

Promise<number>

Remarks​

This file will scan through all the offline files to sum of their total size, which can take a long time to complete. Use manifest data instead if a valid manifest if available.


readManifest()​

readManifest(manifestUrl, abortSignal): Promise<undefined | number>;

Defined in: @novorender/src/offline/scene.ts:75

Reads the manifest file.

Parameters​

ParameterTypeDescription
manifestUrlURLThe url to the offline manifest, with sas key.
abortSignalAbortSignalA signal to abort downloads/synchronization.

Returns​

Promise<undefined | number>

Total number of bytes in scene, if it fails it returns undefined


sync()​

sync(sceneIndexUrl, abortSignal): Promise<boolean>;

Defined in: @novorender/src/offline/scene.ts:175

Incrementally synchronize scene files with online storage.

Parameters​

ParameterTypeDescription
sceneIndexUrlURLThe url to the scene index.json file, complete with sas key.
abortSignalAbortSignalA signal to abort downloads/synchronization.

Returns​

Promise<boolean>

True, if completed successfully, false if not.

Remarks​

Synchronization may be resumed after an abort/failure. It compares the file manifest of local files with the online version and downloads only the difference. Errors are logged in the logger.

Properties​

context​

readonly context: OfflineViewState;

Defined in: @novorender/src/offline/scene.ts:23

The offline context for this scene.


dir​

readonly dir: OfflineDirectoryOPFS;

Defined in: @novorender/src/offline/scene.ts:25

The storage directory for this scene.


logger​

logger: undefined | Logger;

Defined in: @novorender/src/offline/scene.ts:20

Logger for errors and status updates.


manifest​

manifest: SceneManifest;

Defined in: @novorender/src/offline/scene.ts:31

The file manifest this scene.

Remarks​

Initially, this may be empty or partial. It may change when the scene is synchronized.