Skip to main content

Editor.Shape

Class

Represents a 2D or 3D shape object.

Index

Example

// 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.
const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;

// Create a scene object with a physics Collider.
const obj = scene.createSceneObject('PhysicsBox');
const collider = obj.addComponent('ColliderComponent') as Editor.Components.Physics.ColliderComponent;

// Produce a physics Box shape and attach it to the collider.
const box = Editor.Shape.createBoxShape(scene);
collider.shape = box;

console.log(`Collider on ${obj.name} uses shape ${box.getTypeName()}`);

// Available factory methods: createBoxShape, createSphereShape,
// createCapsuleShape, createConeShape, createCylinderShape,
// createLevelSetShape, createMeshShape.

Methods

createBoxShape()

static createBoxShape(scene): Box

Creates a box-shaped physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Box


createCapsuleShape()

static createCapsuleShape(scene): Capsule

Creates a capsule-shaped physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Capsule


createConeShape()

static createConeShape(scene): Cone

Creates a cone-shaped physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Cone


createCylinderShape()

static createCylinderShape(scene): Cylinder

Creates a cylinder-shaped physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Cylinder


createLevelSetShape()

static createLevelSetShape(scene): LevelSet

Creates a level set physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

LevelSet


createMeshShape()

static createMeshShape(scene): Mesh

Creates a mesh-based physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Mesh


createSphereShape()

static createSphereShape(scene): Sphere

Creates a sphere-shaped physics collision component and adds it to the given scene.

Parameters

ParameterType
sceneScene

Returns

Sphere