### Initialize Scene Inline
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.2.5/README.md
Demonstrates initializing a Unicorn Studio scene directly within your HTML. Elements with `data-us-project` or `data-us-project-src` attributes will be automatically initialized when `UnicornStudio.init()` is called. This method handles scene setup and provides a promise that resolves when scenes are ready or rejects on error.
```html
```
--------------------------------
### Initialize Scene Inline
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.2.3/README.md
This example shows how to initialize a Unicorn Studio scene using inline HTML elements with `data-us-project` and `data-us-project-src` attributes. The `UnicornStudio.init()` function is called to render the scenes. It handles both project IDs and custom JSON file paths. The initialization returns a promise that resolves with the ready scenes or rejects with an error.
```html
```
--------------------------------
### Initialize Scene Inline
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.3.1/README.md
This example shows how to initialize a Unicorn Studio scene directly within your HTML. Elements with the `data-us-project` attribute will be automatically initialized when `UnicornStudio.init()` is called. You can also specify the source of your project JSON using `data-us-project-src`. Various data attributes are available to configure the scene's appearance and behavior, such as scale, DPI, lazy loading, and accessibility.
```html
```
--------------------------------
### Add Scene Dynamically
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.2.2/README.md
This example shows how to add a Unicorn Studio scene dynamically using JavaScript. You provide an element ID, project details, and optional configuration like FPS, scale, DPI, and interactivity settings. The `addScene` method returns a promise that resolves with the scene object, which has a `destroy` method.
```javascript
UnicornStudio.addScene({
elementId: 'unicorn', // id of the HTML element to render your scene in (the scene will use its dimensions)
fps: 60, // frames per second (0-120) [optional]
scale: 1, // rendering scale, use smaller values for performance boost (0.25-1) [optional]
dpi: 1, // pixel ratio [optional]
projectId: 'YOUR_PROJECT_EMBED_ID', // the id string for your embed (get this from "embed" export)
filePath: 'path/to/your/PROJECT_ID.json', // if youre hosting your own exported json code, point to it here
interactivity: { // [optional]
mouse: {
disableMobile: true, // disable touch movement on mobile
}
}
}).then(scene => { // scene is ready
// To remove a scene, you can use:
// scene.destroy()
}).catch((err) => {
console.error(err);
});
```
--------------------------------
### Add Scene Dynamically
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.2.6/README.md
This example shows how to add a Unicorn Studio scene dynamically using JavaScript. The `UnicornStudio.addScene` function takes an object with configuration options like `elementId`, `projectId`, `filePath`, and various rendering parameters. It returns a promise that resolves with the scene object, which includes a `destroy` method.
```javascript
```
--------------------------------
### Add Scene Dynamically
Source: https://github.com/georgehastings/embed-unicornstudio/blob/main/v1.4.1/README.md
This example shows how to add a Unicorn Studio scene dynamically using JavaScript. The `addScene` method allows you to specify the target element, project ID or file path, and various rendering and interactivity options. It returns a promise that resolves with the scene instance, which can be used to destroy the scene later.
```javascript
UnicornStudio.addScene({
elementId: "unicorn", // id of the HTML element to render your scene in (the scene will use its dimensions)
fps: 60, // frames per second (0-120) [optional]
scale: 1, // rendering scale, use smaller values for performance boost (0.25-1) [optional]
dpi: 1, // pixel ratio [optional]
projectId: "YOUR_PROJECT_EMBED_ID", // the id string for your embed (get this from "embed" export)
lazyLoad: true, // will not initialize the scene until it scrolls into view
filePath: "path/to/your/PROJECT_ID.json", // if youre hosting your own exported json code, point to it here (do not use both filePath and projectId, only one is required)
altText: "Welcome to Unicorn Studio", // optional text for SEO, going inside the