import { Euler , Group , Matrix4 , Object3D , Quaternion , Vector3 } from 'three' ; import { AbstractObject } from './abstract-object' ; export class WorldObject extends AbstractObject < Group > { protected readonly group = new Group ( ) ; private readonly physicalObjects : Object3D [ ] = [ ] ; private readonly tmpVector = new Vector3 ( ) ; private readonly tmpEuler = new Euler ( ) ; private readonly tmpQuaternion = new Quaternion ( ) ; private invisible = false ; constructor ( protected name ) { super ( name ) ; } getMatrix ( ) { this . group . updateMatrixWorld ( true ) ; return this . group . matrixWorld ; } getAbsolutePosition ( ) { this . group . getWorldPosition ( this . tmpVector ) ; return this . tmpVector ; } getAbsoluteRotation ( ) { return this . tmpEuler . setFromQuaternion ( this . getAbsoluteQuaternion ( ) ) ; } getAbsoluteQuaternion ( ) { this . group . getWorldQuaternion ( this . tmpQuaternion ) ; return this . tmpQuaternion ; } addPhysicalObject ( object ) { this . add ( object ) ; this . physicalObjects . push ( object ) ; } getPhysicalObjects ( ) { return this . physicalObjects ; } hide ( ) { this . group . visible = false ; } show ( ) { this . group . visible = true ; } makeInvisible ( ) { this . invisible = true ; } makeVisible ( ) { this . invisible = false ; } isVisible ( ) { return this . group . visible && ! this . invisible ; } isInvisible ( ) { return this . invisible ; } }