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, or in a browser to create interactive applications.
Constructors#
Constructor#
CreativeEngine
CreativeEngineEngine Management#
update()#
Update the engine’s internal state and render to the canvas, if a scene exists.
Returns#
boolean
Signature#
update(): booleaninit()#
Initialize a CreativeEngine with an optional configuration.
Parameters#
| Parameter | Type | Description |
|---|---|---|
config? |
Partial<Configuration> |
Optional configuration object for engine initialization. |
Returns#
Promise<CreativeEngine>
A promise that resolves to an engine instance.
Signature#
init(config?: Partial<Configuration>): Promise<CreativeEngine>getBaseURL()#
Returns the configured base URL for the engine’s assets.
Returns#
string
The absolute base URL configured for this engine instance.
Example#
const engine = await CreativeEngine.init({ baseURL: 'https://my-cdn.example.com/assets/'});
console.log(engine.getBaseURL()); // 'https://my-cdn.example.com/assets/'Signature#
getBaseURL(): stringAsset Sources#
addDefaultAssetSources()#
Register a set of asset sources containing default assets.
Available default asset sources:
'ly.img.sticker'- Various stickers'ly.img.vectorpath'- Shapes and arrows'ly.img.filter.lut'- LUT effects of various kinds'ly.img.filter.duotone'- Color effects of various kinds
These assets are parsed at {{base_url}}/<id>/content.json, where
base_url defaults to the engine’s configured baseURL. For @cesdk/node
that is the local package (file://<pkg>/assets/), which does not bundle
these sources, so pass a baseURL to load them.
Each source is created via addLocalSource and populated with the parsed assets. To modify the available
assets, you may either exclude certain IDs via excludeAssetSourceIds or alter the sources after creation.
Parameters#
| Parameter | Type | Description |
|---|---|---|
options? |
{ baseURL?: string; excludeAssetSourceIds?: DefaultAssetSourceId[]; } |
Configuration options for loading default asset sources. |
options.baseURL? |
string |
The source of the asset definitions, must be absolute. Defaults to the engine’s configured baseURL. |
options.excludeAssetSourceIds? |
DefaultAssetSourceId[] |
A list of IDs, that will be ignored during load. |
Returns#
Promise<void>
A promise that resolves when all asset sources are loaded.
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.
Note: These are demonstration assets not meant for production use.
Available demo asset sources:
'ly.img.image'- Sample images'ly.img.image.upload'- Demo source to upload image assets'ly.img.audio'- Sample audios'ly.img.audio.upload'- Demo source to upload audio assets'ly.img.video'- Sample videos'ly.img.video.upload'- Demo source to upload video assets
Parameters#
| Parameter | Type | Description |
|---|---|---|
options? |
{ baseURL?: string; excludeAssetSourceIds?: DemoAssetSourceId[]; sceneMode?: "Design" |
"Video"; withUploadAssetSources?: boolean; } |
options.baseURL? |
string |
The source of the demo asset definitions, must be absolute. Defaults to the engine’s configured baseURL. |
options.excludeAssetSourceIds? |
DemoAssetSourceId[] |
A list of IDs, that will be ignored during load |
options.sceneMode? |
"Design" |
"Video" |
options.withUploadAssetSources? |
boolean |
If ‘true’ asset sources for uploads are added (default false) |
Returns#
Promise<void>
A promise that resolves when all demo asset sources are loaded.
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().
Other#
actions#
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.
ly.img.* actions (no host UI), but the API is
identical to the browser engine.version#
version: string;