whs-cube-spheres
Version:
This plugin has a container with multiple spheres.
62 lines (49 loc) • 1.33 kB
JavaScript
import {
Mesh,
PlaneBufferGeometry,
PlaneGeometry
} from 'three';
import {MeshComponent} from '../../core/MeshComponent';
class Plane extends MeshComponent {
static defaults = {
...MeshComponent.defaults,
geometry: {
width: 10,
height: 10,
wSegments: 1,
hSegments: 1
}
};
static instructions = {
...MeshComponent.instructions,
geometry: ['width', 'height', 'wSegments', 'hSegments']
};
constructor(params = {}) {
super(params, Plane.defaults, Plane.instructions);
if (params.build) {
this.build(params);
super.wrap();
}
}
build(params = this.params) {
const {geometry, material} = this.applyBridge({
geometry: this.buildGeometry(params),
material: params.material
});
return this.applyBridge({mesh: new Mesh(geometry, material)}).mesh;
}
buildGeometry(params = {}) {
const GConstruct = params.buffer || params.softbody ? PlaneBufferGeometry : PlaneGeometry;
const geometry = new GConstruct(
params.geometry.width,
params.geometry.height,
params.geometry.wSegments,
params.geometry.hSegments
);
if (params.softbody) this.proccessSoftbodyGeometry(geometry);
return geometry;
}
}
export {
Plane
};