Search Docs
Loading...
Skip to content

Class: CreativeEngine

The CreativeEngine is the core processing unit of CE.SDK and handles state management, rendering, input handling, and much more. It provides APIs to directly interact with assets, blocks, scenes, and variables. These APIs can be used in a headless environment to build and manipulate designs programmatically.

Implements#

  • ICreativeEngine

Constructors#

Constructor#


Use CreativeEngine.init(). A public constructor keeps InstanceType<typeof CreativeEngine> valid.

Parameters#

Parameter Type
engine NativeEngine

Returns#

CreativeEngine

Methods#

hasInstance#


A WASM engine that init started counts as an instance, so code that checks instanceof keeps working.

Parameters#

Parameter Type
value unknown

Returns#

boolean


update()#


Update the engine’s internal state

Returns#

boolean

Whether the engine needed an update. A load that waits for the host to write the bytes of a buffer does not count.

Signature#

update(): boolean

getFrameInfo()#

Frame provenance and surface layout, read after update().

Returns#

FrameInfo

Signature#

getFrameInfo(): FrameInfo

attachCanvas()#

Attach a live-view host and let it drive the loop’s cadence, replacing any canvas already attached.

Parameters#

Parameter Type
canvas EngineCanvas

Returns#

void

Signature#

attachCanvas(canvas: EngineCanvas): void

detachCanvas()#

Detach the live-view host and return the loop to its headless cadence.

Returns#

void

Signature#

detachCanvas(): void

dispose()#


Dispose the engine and clean up all resources

Returns#

void

Implementation of#

ICreativeEngine.dispose

Signature#

dispose(): void

init()#


Initialize a CreativeEngine.

The device field selects the render backend of the native engine ('auto' | 'cpu' | 'gpu'), and the WASM engine ignores it.

config.engine chooses the engine. Unset, the CESDK_ENGINE environment variable chooses it, then 'auto'. With 'auto', the WASM engine starts when this host has no native binary, the binary does not load, or the license does not cover the native engine. The WASM engine then unlocks with the license that the native engine fetched, without a second activation. The native engine reads its own resources from the package, so config.baseURL can be remote or a folder of your own assets. The color emoji font still loads from <baseURL>/emoji/, unless the defaultEmojiFontFileUri setting names another file.

Parameters#

Parameter Type Description
config? Partial<Configuration> Engine configuration. All fields optional; defaults match @cesdk/node + 'auto' device selection.

Returns#

Promise<CreativeEngine>

A ready-to-use engine instance.

Throws#

UTILS.BASE_PATH_INVALID when config.baseURL is a URL that the engine cannot parse, such as one with [ in its path. Percent-encode such a character.

Signature#

init(config?: Partial<Configuration>): Promise<CreativeEngine>

getBaseURL()#


Get the base URL for engine assets

Returns#

string

Signature#

getBaseURL(): string

addDefaultAssetSources()#


Register a set of default asset sources containing default assets.

Works as on the WASM engine. Loads ${baseURL}/<source-id>/content.json for each id in the default set and registers the contents as a local asset source. baseURL defaults to the engine’s configured baseURL (the assets/ folder of the package if none was passed to init), which does not bundle these sources, so pass a baseURL to load them.

Parameters#

Parameter Type Description
__namedParameters? { baseURL?: string; excludeAssetSourceIds?: DefaultAssetSourceId[]; } -
__namedParameters.baseURL? string The source of the asset definitions, must be absolute. Defaults to the engine’s configured baseURL.
__namedParameters.excludeAssetSourceIds? DefaultAssetSourceId[] A list of IDs, that will be ignored during load.

Returns#

Promise<void>

Deprecated#

This method uses legacy v4 asset source IDs and will be removed in a future version. Please migrate to v5 asset sources using engine.asset.addLocalAssetSourceFromJSONURI().


addDemoAssetSources()#


Register a set of demo asset sources containing example assets.

Mirrors @cesdk/engine’s bindings/wasm/js_web/src/addDemoAssetSources.ts — accepts sceneMode, withUploadAssetSources, and the full demo source-ID union (templates + textComponents + uploads + media).

Parameters#

Parameter Type Description
__namedParameters? { baseURL?: string; excludeAssetSourceIds?: DemoAssetSourceId[]; sceneMode?: "Design" "Video"; withUploadAssetSources?: boolean; }
__namedParameters.baseURL? string The source of the demo asset definitions, must be absolute. Defaults to the engine’s configured baseURL.
__namedParameters.excludeAssetSourceIds? DemoAssetSourceId[] A list of IDs, that will be ignored during load
__namedParameters.sceneMode? "Design" "Video"
__namedParameters.withUploadAssetSources? boolean If ‘true’ asset sources for uploads are added (default false)

Returns#

Promise<void>

Deprecated#

This method uses legacy v3 demo asset source IDs and will be removed in a future version. Please migrate to v4 asset sources using engine.asset.addLocalAssetSourceFromJSONURI().

Properties#

Property Modifier Type Description
version readonly string The version of the CE.SDK Node package.
asset public AssetAPI Asset operations API
block public BlockAPI Block operations API
editor public EditorAPI Editor operations API
event public EventAPI Event subscription API
scene public SceneAPI Scene operations API
variable public VariableAPI Variable management API
actions public EngineActions Register, run, and discover named, overridable actions. On headless Node the registry starts with only the engine-default ly.img.* actions (no host UI), but the API is identical to the browser engine.
version readonly string The version of the CE.SDK Node package.