Diffusion Studio is highly extensible using Pixi.js, an HTML5 creation engine. In this guide, we will walk through the steps of creating a custom Clip object using Pixi.js. Before diving into the example, let's first discuss the lifecycle of a Clip object.
The init() method is called asynchronously before the Clip is added to a track/composition. This makes it the ideal place for I/O operations, such as fetching assets or loading buffers.
This method is triggered right before the Clip is drawn to the canvas. Use enter() to perform any synchronous actions that need to be executed once, rather than on every render cycle.
The update() method is called on every redraw of the clip. It receives a Timestamp argument, which you can use to implement time-based state changes. The update() function may also return a promise—this is useful during video export to ensure frame accuracy. However, for playback, promises are not awaited to maintain smooth performance.
This method is called after the Clip has been drawn to the canvas for the last time. It is commonly used to perform cleanup operations, such as removing filters or other resources to free memory.