Verge3D PzLib API — Objects

# Objects

#### generateUniqueObjectName(name) → {string}

Generate an object name from the given base name so that it's unique for the current scene. The result is the base name with an optional number appended to it (e.g. "name", "name2", "name3", "name4", ...). The number is incremented until the result becomes a unique object name.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | string | The base name.

##### Returns:

New unique object name.

Type
  string

#### getAllObjectNames() → {Array.<string>}

Get the names of all objects on the scene.

##### Returns:

Array of names of all scene objects.

Type
  Array.<string>

#### getObjectByName(objName) → (nullable) {v3d.Object3D}

Get object by its name from the scene.

##### Parameters:

Name | Type | Description
--- | --- | ---
`objName` | string | Object name.

##### Returns:

Object or null if not found.

Type
  v3d.Object3D

#### getObjectName(obj) → {string}

Get the name of the given object. This function also considers auto-generated child meshes of multi-material objects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | v3d.Object3D | The object.

##### Returns:

The name of the object.

Type
  string

#### getObjectNamesByGroupName(groupName) → {Array.<string>}

Get the names of all objects belonging to the given group.

##### Parameters:

Name | Type | Description
--- | --- | ---
`groupName` | string | Group name.

##### Returns:

Array of names of all objects belonging to the given group.

Type
  Array.<string>

#### getObjectUUID(obj) → {string}

Get the UUID of the given object. This function also considers auto-generated child meshes of multi-material objects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | v3d.Object3D | The object.

##### Returns:

The UUID of the object.

Type
  string

#### isMeshObject(obj) → {boolean}

Check if the given object is either a mesh (being of type v3d.Mesh) or a multi-material mesh (being of type v3d.Group with its direct children being material generated meshes). Return "false" otherwise.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | v3d.Object3D | Object to check.

##### Returns:

Check result.

Type
  boolean

#### isObjectAmongObjects(objNameToCheck, objUUIDToCheck, objNames) → {boolean}

Check if a particular object is among the given array of objects. This function also considers auto-generated child meshes of multi-material objects.

##### Parameters:

Name | Type | Description
--- | --- | ---
`objNameToCheck` | string | The name of the object to check if it's among the given array of objects.
`objUUIDToCheck` | string | The UUID of the object to check if it's among the given array of objects.
`objNames` | Array | Array of the object names to search in.

##### Returns:

Check result.

Type
  boolean

#### isObjectWorthProcessing(obj) → {boolean}

Check if the given object is "worth processing", i.e. not irrelevant nor purely utilitarian. This function is useful for listing all relevant objects from a scene (see "objectList" and "groupList" puzzles) and for filtering out irrelevant ones when traversing a scene.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | v3d.Object3D | Object to check.

##### Returns:

Check result.

Type
  boolean

#### removeObject(obj, objName)

Remove object from paent and cleanup cache.

##### Parameters:

Name | Type | Description
--- | --- | ---
`obj` | v3d.Object3D | The object.
`objName` | string | The name of the object.

#### retrieveObjectNames(objNames) → {Array.<string>}

Retreive object names from the given "objNames" parameter which potentially represents an object, or an array of objects, or a group or all objects at once. Empty string names ('') are always filtered out.

##### Parameters:

Name | Type | Description
--- | --- | ---
`objNames` | string | Array | An object name, an array of object names, an array in the format ["GROUP", GROUP_NAME], an array in the format ["ALL_OBJECTS"].

##### Returns:

Array of retrieved object names.

Type
  Array.<string>

#### retrieveObjectNamesAccum(objNames, namesAccum)

Accumulate object names from the given "currObjNames" parameter. This is just a helper function which is supposed to be called from "retrieveObjectNames".

##### Parameters:

Name | Type | Description
--- | --- | ---
`objNames` | string | Array | An object name, an array of object names, an array in the format ["GROUP", GROUP_NAME], an array in the format ["ALL_OBJECTS"].
`namesAccum` | Array.<string> | Array accumulating object names.