Class: RectMesh

PD. RectMesh

Defines an editable rectangular mesh.

Rectangular meshes can be used to edit and display structural grids, background images and other elements that are rectangle-based.


new RectMesh( [config])

Creates a new rectangular mesh.

Parameters:
Name Type Argument Description
config object <optional>

An optional configuration object.

Properties of config:
Name Type Argument Description
width number <optional>

The width of the rectangle in the X-axis, in model units.

depth number <optional>

The depth of the rectangle in the Y-axis, in model units.

height number <optional>

The height of the rectangle in the Z-axis, in model units.

size Array <optional>

Sets the width, depth and height of the rectangle, in model units.

keepAspectRatio boolean <optional>

Whether or not to maintain the depth/width aspect ratio when changing a dimension.

material THREE.Material <optional>

The material to render the rectangle.

texture THREE.Texture <optional>

The material to render the rectangle.

Author:
  • drajmarsh

Extends

  • THREE.Mesh

Members


:number

aspectRatio

The aspect ratio of the rectangle.

This is calculated as the Y-axis size divided by the X-axis size.

Type
  • number

:number

depth

The size of the rectangular mesh in the Y-axis, in model units.

Type
  • number

:THREE.Box3

extents

The extents of the rectangular mesh in absolute model coordinates.

Type
  • THREE.Box3

:boolean

hasChanged

Whether or not the mesh has changed and needs to update.

Type
  • boolean

:number

height

The size of the rectangular mesh in the Z-axis, in model units.

Type
  • number

:boolean

isRectMesh <readonly>

A flag identifying this object as a rectangular mesh.

Type
  • boolean

:boolean

keepAspectRatio

Whether or not to maintain the aspect ratio of the rect.

Type
  • boolean

:number

opacity

The opacity of the rectangular mesh material.

Type
  • number

:THREE.Texture|null

texture

The image texture mapped to the rectangle surface, if any.

Type
  • THREE.Texture | null

:boolean

visible

Whether or not the rect/image is visible in the model.

Type
  • boolean

:number

width

The size of the rectangular mesh in the X-axis, in model units.

Type
  • number

Methods


applyScaleFactor(factor [, align])

Applies a scale factor to resize the geometry.

Parameters:
Name Type Argument Default Description
factor number

The scale factor to apply.

align PD.ALIGN | THREE.Vector3 <optional>
0

An optional alignment override or point to scale about.

Returns:

Returns this mesh to support method chaining.

Type
PD.RectMesh

assignImage(image [, config])

Assigns an img element to texture map the rectangle.

Parameters:
Name Type Argument Description
image object

The DOM img element to use.

config object <optional>

An optional JSON object to configure the texture.

Returns:

Returns this mesh to support method chaining.

Type
PD.RectMesh

dispose()

Removes the geometry, materials and texture from the GPU.

NOTE: Only call this method when the mesh is no longer needed and you wish to free all its resources and remove it from the GPU.

Returns:

Returns this mesh instance to support method chaining.

Type
PD.RectMesh

loadImage(image_url, callback)

Loads in an image file to texture map the rectangle.

Parameters:
Name Type Description
image_url string

The url of the image to load.

callback function

The callback function once loaded.

Returns:

Returns this mesh to support method chaining.

Type
PD.RectMesh

setExtents(box)

Updates the rectangle geometry from bounding box.

Override this method for subclasses that use more complex geometry.

Parameters:
Name Type Description
box THREE.Box3

The new extents of the rectangular mesh.

Returns:

Returns this mesh to support method chaining.

Type
PD.RectMesh

update( [forceUpdate])

Updates the rectangular mesh when things change.

Parameters:
Name Type Argument Description
forceUpdate boolean <optional>

Whether or not to update even if mesh has not changed, defaults to false.

Returns:

Returns this mesh to support method chaining.

Type
PD.RectMesh

createRectangleGeometry() <static>

Creates the mesh geometry for a simple unit rectangle.

Returns:

Returns a new geometry object with two triangles.

Type
THREE.BufferGeometry