Skip to main content

@novorender/web_app / OfflineScene

Class: OfflineScene

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 id(): string

Get the scene id.

Returns

string

Defined in

@novorender/offline/scene.ts:33

Constructors

new OfflineScene()

new OfflineScene(
context,
dir,
manifest): OfflineScene

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

Defined in

@novorender/offline/scene.ts:19

Methods

delete()

delete(): Promise<void>

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

Returns

Promise<void>

Defined in

@novorender/offline/scene.ts:38


deleteStaleFiles()

deleteStaleFiles(sceneIndexUrl, abortSignal): Promise<boolean>

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.

Defined in

@novorender/offline/scene.ts:116


getUsedSize()

getUsedSize(): Promise<number>

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.

Defined in

@novorender/offline/scene.ts:56


readManifest()

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

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

Defined in

@novorender/offline/scene.ts:73


sync()

sync(sceneIndexUrl, abortSignal): Promise<boolean>

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.

Defined in

@novorender/offline/scene.ts:166

Properties

context

readonly context: OfflineViewState;

The offline context for this scene.

Defined in

@novorender/offline/scene.ts:21


dir

readonly dir: OfflineDirectoryOPFS;

The storage directory for this scene.

Defined in

@novorender/offline/scene.ts:23


logger

logger: undefined | Logger;

Logger for errors and status updates.

Defined in

@novorender/offline/scene.ts:18


manifest

manifest: SceneManifest;

The file manifest this scene.

Remarks

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

Defined in

@novorender/offline/scene.ts:29