Constructor
.new Extrude(paramsopt)
Extrude geometry means that you can create a 3D mesh from any 2D shape using three.js geometry based on THREE.Vector2.
Such implementation will help you to make volumed shapes that have their own depth and can be seen from all angels.
You can also find some interesting examples made using three.js which is a core of whs.js, such as:
Such examples can be easily implemented using whitestorm.js or it's plugins. Use Extrude class with THREE.Shape to get extrude effect of shape defined by 2D vectors.
This class is similar to THREE.ExtrudeGeometry,
but it also contains all properties, applied by Shape, such as material, mass and vectors like position (pos) and rotation (rot).
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
params |
Object
|
<optional> |
The params. |
Example
Creating a shape, then an Extrude from it
const shape = new THREE.Shape([
new THREE.Vector2(-4,-4),
new THREE.Vector2(-2,0),
new THREE.Vector2(-4,4),
new THREE.Vector2(0,2),
new THREE.Vector2(4,4),
new THREE.Vector2(2,0),
new THREE.Vector2(4,-4),
new THREE.Vector2(0,-2)
]);
const extrude = new Extrude({
geometry: {
shapes: shape,
options: {
bevelEnabled: false,
bevelSize: 0,
amount: 2
}
},
material: new THREE.MeshBasicMaterial({
color: 0xffffff
}),
position: [0, 100, 0]
});
extrude.addTo(app);
Extends module:core.MeshComponent
Members
(private) ._wait :Array
Array of promises that should be resolved before Component is ready.
- Inherited From:
- Source:
.children :Array
Collection of child Components.
- Inherited From:
- Source:
.defaults :Object
Default values for parameters
- Overrides:
- Default Value:
{ geometry: { shapes: [], options: {} } }- Source:
.instructions :Object
Instructions
- Overrides:
- Default Value:
{ geometry: ['shapes', 'options'] }- Source:
.isDeffered :Boolean
Returns whether the object is async (wait promises are more than 0).
- Inherited From:
- Source:
.manager :ModuleManager
Returns the ModuleManager used for this component.
- Inherited From:
- Source:
.modules :Array
Collection of modules.
- Inherited From:
- Source:
.native :Object
Returns the native object used for this component.
- Inherited From:
- Source:
Methods
(static) .build(params) → {THREE.Mesh}
Build livecycle creates a mesh using input params.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
params |
Object
|
Component parameters. |
.add(object) → {Promise}
Add a child Component.
- Inherited From:
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Component
|
Component that should be added as a |
.addTo(object)
Adds this Component to specified App/Component.
- Inherited From:
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Component
|
Component that will be a parent of |
.clone() → {MeshComponent}
Make a clone of this MeshComponent using .copy()
- Inherited From:
- Source:
.copy() → {this}
Copy source transforms & execute Component.copy()
- Inherited From:
- Source:
.defer(func)
Execute func (Callback) when Component is ready.
- Inherited From:
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
func |
function
|
Callback. |
.remove(object)
Remove a child Component.
- Inherited From:
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
object |
Component
|
Component that should be a child of this Component. |
.updateParams() → {Object}
Updates parameters of the Component.
- Inherited From:
- Source:
.wait(promiseopt) → {Promise}
Wait for a promise.
- Inherited From:
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
promise |
Promise
|
<optional> |
The promise that should be added to a queue. |
.wrap() → {Promise}
Wraps transforms (position & rotation)
- Inherited From:
- Source: