Spawning Entities in Amazon Sumerian (e.g programatically / dynamically) can be a difficult thing to figure out using Amazon’s Scripting API documentation.
The solution for this is simple once you know what to do, here is the simplified process on how to programmaticaly instantiate an instance of a predefined Entity:
Step 1
Step 2
Step 3
I’ve posted this script below (with comments) so you can now begin spawning entities within Amazon Sumerian. Enjoy! 😀
generateQuad.js
// import that preview version of the Sumerian Scripting API as a variable called 's' import * as s from 'module://sumerian-common/api'; // creating a parameter in the GUI for the Script, that lets you to drag an entity that you'd like to spawn onto it (in this case "Box 2") export const PROPERTIES = { // the name of the field that appears within the GUI entityToSpawn: { // the type of file that the parameter is expecting type: s.type.Entity, description: 'This can be an entity that exists in your scene or an entity that was dragged into the Assets panel for reuse.' } }; // the default function that is called automatically export default function(ctx, {entityToSpawn}) { // defining the class of the new entity that can be called upon start const spawnEntityInstance = new s.entity.LoadEntityInstanceAction({ entity: entityToSpawn, // use the entity that you've dragged onto the GUI onCreate: (entity) => { // on create set the position of the entity entity.position.setDirect(0,0,40); } }); // when the context starts, call the class that spawns an instance of the entity ctx.start(spawnEntityInstance); }