import { MeshLambertMaterial , BoxGeometry } from "three" ; import { SoftVis3dMesh } from "../../domain/SoftVis3dMesh" ; import { SoftVis3dShape } from "../../domain/SoftVis3dShape" ; export class ObjectFactory { public static getSceneObjects ( shapes ) { const result = [ ] ; for ( const shape of shapes ) { result . push ( this . _getShape ( shape ) ) ; } return result ; } private static _getShape ( element ) { element . opacity = 1 ; const z = element . position . _z + Math . floor ( element . dimensions . height / 2 ) ; const geometry = new BoxGeometry ( element . dimensions . length , element . dimensions . height , element . dimensions . width ) ; const material = new MeshLambertMaterial ( { color : element . color , transparent : true , opacity : element . opacity , } ) ; const cube = new SoftVis3dMesh ( element . key , geometry , material ) ; cube . position . setX ( element . position . _x ) ; cube . position . setY ( z ) ; cube . position . setZ ( element . position . _y ) ; return cube ; } }