init
ts
function init(canvas: HTMLCanvasElement, options?: InitOptions): Promise<ImFusion>;Initialize the ImFusion Web SDK.
Parameters
| Parameter | Type | Description |
|---|---|---|
canvas | HTMLCanvasElement | The canvas element to render into |
options? | InitOptions | Optional initialization options |
Returns
Promise resolving to the ImFusion instance
Example
ts
// Basic usage
const imf = await init(myCanvas);
// With auto-resize enabled
const imf = await init(myCanvas, { autoResize: true });
// With custom DPI scale and manual input handling
const imf = await init(myCanvas, {
dpiScale: 2,
autoInputHandling: false,
});You can call preloadWasm ahead of init() to initiate the wasm
fetch and compilation if canvas is not yet available.