Skip to main content

class.OfflineScene

API > 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.

Constructors

constructor

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

Source

@novorender/offline/scene.ts:19

Properties

context

readonly context: OfflineViewState

The offline context for this scene.

Source

@novorender/offline/scene.ts:21


dir

readonly dir: OfflineDirectoryOPFS

The storage directory for this scene.

Source

@novorender/offline/scene.ts:23


logger

logger: undefined | Logger

Logger for errors and status updates.

Source

@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.

Source

@novorender/offline/scene.ts:29

Accessors

id

get id(): string

Get the scene id.

Returns

string

Source

@novorender/offline/scene.ts:33

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 >

Source

@novorender/offline/scene.ts:38


getUsedSize

getUsedSize(): Promise\< number >

Get total number of used bytes.

Returns

Promise\< number >

Source

@novorender/offline/scene.ts:56

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 >

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

Source

@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.

Source

@novorender/offline/scene.ts:118

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.