Phaser API Documentation

  Version: 

Member of: Phaser.Geom.Mesh

<static> GenerateObjVerts(data, [mesh], [scale], [x], [y], [z], [rotateX], [rotateY], [rotateZ], [zIsUp])

Description:

This method will return an object containing Face and Vertex instances, generated from the parsed triangulated OBJ Model data given to this function.

The obj data should have been parsed in advance via the ParseObj function:

var data = Phaser.Geom.Mesh.ParseObj(rawData, flipUV);

var results = GenerateObjVerts(data);

Alternatively, you can parse obj files loaded via the OBJFile loader:

preload ()
{
  this.load.obj('alien', 'assets/3d/alien.obj);
}

var results = GenerateObjVerts(this.cache.obj.get('alien));

Make sure your 3D package has triangulated the model data prior to exporting it.

You can use the data returned by this function to populate the vertices of a Mesh Game Object.

You may add multiple models to a single Mesh, although they will act as one when moved or rotated. You can scale the model data, should it be too small (or large) to visualize. You can also offset the model via the x, y and z parameters.

Parameters:

name type arguments Default description
data Phaser.Types.Geom.Mesh.OBJData

The parsed OBJ model data.

mesh Phaser.GameObjects.Mesh <optional>

An optional Mesh Game Object. If given, the generated Faces will be automatically added to this Mesh. Set to null to skip.

scale number <optional> 1

An amount to scale the model data by. Use this if the model has exported too small, or large, to see.

x number <optional> 0

Translate the model x position by this amount.

y number <optional> 0

Translate the model y position by this amount.

z number <optional> 0

Translate the model z position by this amount.

rotateX number <optional> 0

Rotate the model on the x axis by this amount, in radians.

rotateY number <optional> 0

Rotate the model on the y axis by this amount, in radians.

rotateZ number <optional> 0

Rotate the model on the z axis by this amount, in radians.

zIsUp boolean <optional> true

Is the z axis up (true), or is y axis up (false)?

Returns:
Description:

The parsed Face and Vertex objects.

Since: 3.50.0