UNPKG

whs-cube-spheres

Version:

This plugin has a container with multiple spheres.

54 lines (43 loc) 1.15 kB
import { Mesh, DodecahedronBufferGeometry, DodecahedronGeometry } from 'three'; import {MeshComponent} from '../../core/MeshComponent'; class Dodecahedron extends MeshComponent { static defaults = { ...MeshComponent.defaults, geometry: { radius: 1, detail: 0 } }; static instructions = { ...MeshComponent.instructions, geometry: ['radius', 'detail'] }; constructor(params = {}) { super(params, Dodecahedron.defaults, Dodecahedron.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 ? DodecahedronBufferGeometry : DodecahedronGeometry; return new GConstruct( params.geometry.radius, params.geometry.detail ); } } export { Dodecahedron };