UVMapper

cjcliffe edited this page Oct 16, 2011 · 4 revisions

CubicVR.UVMapper

The UVMapper class provides a simple procedural interface to applying U,V coordinates to a Mesh.

UVMapper( init )

  • init : Can be undefined or an object constructor.
var uvm = new CubicVR.UVMapper({
  rotation: [0.0,0.0,0.0],  // U,V projection rotation.
  scale:    [1.0,1.0,1.0],  // U,V projection scale.
  center:   [0.0,0.0,0.0],  // U,V projection center.
  wrapW:    1.0,            // Width wrap count for wrapping projectors.
  wrapH:    1.0,            // Height wrap count for wrapping projectors.
  projectionMode: "planar", // U,V Projection Mode, see enums.
  projectionAxis: "x"       // U,V Projection Axis, see enums.
});

Enumerators:

Projection mode

  • "planar" : Planar projection along the given projection axis.
  • "cylindrical" : Cylindrical projection around the given projection axis.
  • "spherical" : Spherical projection around the given projection axis.
  • "cubic" : Cubic mapping applied based on surface normal direction.
  • "sky" : Cube-map sky mapping for application of a sky cube map.

Projection axis for "planar", "cylindrical" and "spherical" mapping

  • "x" : Projection on or around the X axis.
  • "y" : Projection on or around the Y axis.
  • "z" : Projection on or around the Z axis.

Methods:

apply( mesh, material, segment, start_face, end_face )

Apply the UVMapper to the given Mesh mesh using Material material on segment segment.

Parameters:

  • mesh : A Mesh to apply this UVMapper to.
  • material : A Material used on faces in the Mesh to apply UVMapper to.
  • segment (optional) : A specific segment to apply this UVMapper to, default: 0
  • start_face (optional) : A specific face number to start at, default 0
  • end_face (optional) : A specific face number to end at, default mesh.faces.length-1

Returns:

this reference for chaining operations.

setRotation( rotation )

Set the U,V Projection Rotation.

Parameters:

  • rotation : Rotation value to apply to the U,V projection, format [0.0, 0.0, 0.0]

Returns:

none

setScale( scale )

Set the U,V Projection Scale.

Parameters:

  • scale : Scale value to apply to the U,V projection, format [0.0, 0.0, 0.0]

Returns:

none

setCenter( center )

Set the U,V Projection Center.

Parameters:

  • center : Center value to apply to the U,V projection, format [0.0, 0.0, 0.0]

Returns:

none

setProjectionAxis( projection_axis )

Set the U,V Projection Axis.

Parameters:

  • projection_axis : Set the U,V Projection Axis, "x", "y" or "z"

Returns:

none

setProjectionMode( projection_mode )

Set the U,V Projection mode.

Parameters:

  • projection_mode : Set the U,V Projection Mode, "planar", "cylindrical", "spherical", "cubic" or "sky"

Returns:

none

setWrapW( wrap_w )

Set the U Projection Wrap Count, appplies to spherical and cylindrical projection modes.

Parameters:

  • wrap_w : Number of times to wrap horizontally

Returns:

none

setWrapH( wrap_h )

Set the V Projection Wrap Count, appplies to spherical projection modes.

Parameters:

  • wrap_h : Number of times to wrap vertically

Returns:

none