# Model

Class · category: Graphics

Source: https://github.com/playcanvas/engine/blob/f059dc005842f76e052cdf44d8370c8c7ec475ac/src/scene/model.js#L16

A model is a graphical object that can be added to or removed from a scene. It contains a
hierarchy and any number of mesh instances.

## Constructors

### constructor

```ts
new Model()
```

Creates a new model.

**Example**

```ts
// Create a new model
const model = new Model();
```

## Properties

### graph

```ts
graph: GraphNode | null = null
```

The root node of the model's graph node hierarchy.

### meshInstances

```ts
meshInstances: MeshInstance[] = []
```

An array of MeshInstances contained in this model.

### morphInstances

```ts
morphInstances: MorphInstance[] = []
```

An array of MorphInstances contained in this model.

### skinInstances

```ts
skinInstances: SkinInstance[] = []
```

An array of SkinInstances contained in this model.

## Methods

### clone

```ts
clone(): Model
```

Clones a model. The returned model has a newly created hierarchy and mesh instances, but
meshes are shared between the clone and the specified model.

**Returns** [`Model`](https://api.playcanvas.com/engine/classes/Model.md): A clone of the specified model.

**Example**

```ts
const clonedModel = model.clone();
```

### destroy

```ts
destroy(): void
```

Destroys skinning texture and possibly deletes vertex/index buffers of a model. Mesh is
reference-counted, so buffers are only deleted if all models with referencing mesh instances
were deleted. That means all in-scene models + the "base" one (asset.resource) which is
created when the model is parsed. It is recommended to use asset.unload() instead, which
will also remove the model from the scene.

### generateWireframe

```ts
generateWireframe(): void
```

Generates the necessary internal data for a model to be renderable as wireframe. Once this
function has been called, any mesh instance in the model can have its renderStyle property
set to [RENDERSTYLE_WIREFRAME](https://api.playcanvas.com/engine/variables/RENDERSTYLE_WIREFRAME.md).

**Example**

```ts
model.generateWireframe();
for (let i = 0; i < model.meshInstances.length; i++) {
    model.meshInstances[i].renderStyle = RENDERSTYLE_WIREFRAME;
}
```
