These docs are for v1.2. Click to read the latest docs for v2-beta.x.

🚧

SoftbodyComponent depends on PhysicsComponent and MeshComponent (They should be set first).

This component adds softbody utilities and overwrites 3d transforms to make them usable with softbody.

Added methods

.proccessSoftbodyGeometry(geometry)

This function applies position, scale and rotation to geometry (not to mesh object). It is because transfered data is geometry vertices rather than transforms.

Making a Softbody mesh Component

// ...
import MeshComponent from 'whs/lib/core/MeshComponent';
import PhysicsComponent from 'whs/lib/core/PhysicsComponent';
import SoftbodyComponent from 'whs/lib/core/SoftbodyComponent';
// ...

@SoftbodyComponent
@PhysicsComponent
@MeshComponent
class BasicSphere extends Component {
  // ...


  buildGeometry(params = {}) {
    const GConstruct = 
      params.buffer && !params.softbody 
        ? THREE.SphereBufferGeometry 
        : THREE.SphereGeometry;

    const geometry = new GConstruct(
      params.geometry.radius,
      params.geometry.widthSegments,
      params.geometry.heightSegments
    );

    if (params.softbody) this.proccessSoftbodyGeometry(geometry);

    return geometry;
  }
}