new RectMesh( [config])
Creates a new rectangular mesh.
Parameters:
| Name | Type | Argument | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
object |
<optional> |
An optional configuration object. |
||||||||||||||||||||||||||||||||
Properties of
|
|||||||||||||||||||||||||||||||||||
| 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. |
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 factornumber The scale factor to apply.
alignPD.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 imageobject The DOM
imgelement to use.configobject <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_urlstring The url of the image to load.
callbackfunction 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 boxTHREE.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 forceUpdateboolean <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