// Editor.Shape is a factory for physics shapes (Box, Sphere, Capsule, …). // Use it to produce an Editor.Components.Physics.Shape and assign that // to a ColliderComponent's `shape` property to give the collider a // geometry for physics simulation. constmodel = this.pluginSystem.findInterface(Editor.Model.IModel) asEditor.Model.IModel; constscene = model.project.scene;
// Create a scene object with a physics Collider. constobj = scene.createSceneObject('PhysicsBox'); constcollider = obj.addComponent('ColliderComponent') asEditor.Components.Physics.ColliderComponent;
// Produce a physics Box shape and attach it to the collider. constbox = Editor.Shape.createBoxShape(scene); collider.shape = box;
console.log(`Collider on ${obj.name} uses shape ${box.getTypeName()}`);
Represents a 2D or 3D shape object.
Example