# Abstract Class: ModelSettings (/jsdoc/pixi-vn-live2d/core/classes/ModelSettings)



Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:512

Parses, and provides access to the settings JSON.

## Extended by [#extended-by]

* [`CubismLegacyModelSettings`](/jsdoc/pixi-vn-live2d/core/classes/CubismLegacyModelSettings)
* [`CubismModelSettings`](/jsdoc/pixi-vn-live2d/core/classes/CubismModelSettings)

## Constructors [#constructors]

### Constructor [#constructor]

\> `protected` **new ModelSettings**(`json`): `ModelSettings`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:545

#### Parameters [#parameters]

##### json [#json]

`object` & `object`

The settings JSON object.

#### Returns [#returns]

`ModelSettings`

## Properties [#properties]

### json [#json-1]

\> **json**: `object`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:513

***

### moc [#moc]

\> `abstract` **moc**: `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:528

Relative path of he moc file, typically ends with `.moc` in Cubism 2 and `.moc3` in Cubism 4.

***

### name [#name]

\> **name**: `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:519

The model's name, typically used for displaying or logging. By default it's inferred from
the URL by taking the folder name (the second to last component). In Cubism 2 it'll be overwritten
by the `name` field of settings JSON.

***

### physics? [#physics]

\> `optional` &#x2A;*physics?**: `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:540

Relative path of the physics file.

***

### pose? [#pose]

\> `optional` &#x2A;*pose?**: `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:536

Relative path of the pose file.

***

### textures [#textures]

\> `abstract` **textures**: `string`\[]

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:532

Relative paths of the texture images.

***

### url [#url]

\> **url**: `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:524

URL of the model settings file, used to resolve paths of the resource files defined in settings.
This typically ends with `.model.json` in Cubism 2 and `.model3.json` in Cubism 4.

## Methods [#methods]

### getDefinedFiles() [#getdefinedfiles]

\> **getDefinedFiles**(): `string`\[]

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:594

Retrieves all resource files defined in the settings.

#### Returns [#returns-1]

`string`\[]

A flat array of the paths of all resource files.

```js
modelSettings.getDefinedFiles();
// returns: ["foo.moc", "foo.png", ...]
```

***

### getFileStem() [#getfilestem]

\> `protected` **getFileStem**(`path?`): `string` | `undefined`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:560

Returns the file name without extension from a path.

#### Parameters [#parameters-1]

##### path? [#path]

`string`

#### Returns [#returns-2]

`string` | `undefined`

***

### normalizeName() [#normalizename]

\> `protected` **normalizeName**(): `void`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:551

Ensures the model name is meaningful; falls back to the folder name when missing or placeholder.

#### Returns [#returns-3]

`void`

***

### replaceFiles() [#replacefiles]

\> **replaceFiles**(`replacer`): `void`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:584

Replaces the resource files by running each file through the `replacer`.

#### Parameters [#parameters-2]

##### replacer [#replacer]

(`file`, `path`) => `string`

Invoked with two arguments: `(file, path)`, where `file` is the file definition,
and `path` is its property path in the ModelSettings instance. A string must be returned to be the replacement.

```js
modelSettings.replaceFiles((file, path) => {
    // file = "foo.moc", path = "moc"
    // file = "foo.png", path = "textures[0]"
    // file = "foo.mtn", path = "motions.idle[0].file"
    // file = "foo.motion3.json", path = "motions.idle[0].File"

    return "bar/" + file;
});
```

#### Returns [#returns-4]

`void`

***

### resolveURL() [#resolveurl]

\> **resolveURL**(`path`): `string`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:567

Resolves a relative path using the [url](#url). This is used to resolve the resource files
defined in the settings.

#### Parameters [#parameters-3]

##### path [#path-1]

`string`

Relative path.

#### Returns [#returns-5]

`string`

Resolved path.

***

### setModelName() [#setmodelname]

\> `protected` **setModelName**(...`candidates`): `void`

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:556

Picks the first non-empty, non-placeholder name from candidates and applies it.
Falls back to [normalizeName](#normalizename) when no candidate is usable.

#### Parameters [#parameters-4]

##### candidates [#candidates]

...(`string` | `undefined`)\[]

#### Returns [#returns-6]

`void`

***

### validateFiles() [#validatefiles]

\> **validateFiles**(`files`): `string`\[]

Defined in: node\_modules/untitled-pixi-live2d-engine/types/index.d.ts:603

Validates that the files defined in the settings exist in given files. Each file will be
resolved by [resolveURL](/jsdoc/pixi-vn-live2d/core/functions/resolveURL) before comparison.

#### Parameters [#parameters-5]

##### files [#files]

`string`\[]

A flat array of file paths.

#### Returns [#returns-7]

`string`\[]

All the files which are defined in the settings and also exist in given files,
*including the optional files*.

#### Throws [#throws]

Error if any *essential* file is defined in settings but not included in given files.
