import { Entity, EntityConfig, CollisionType, AmmoShape } from '../../src' import * as THREE from 'three' export interface ExampleProps extends EntityConfig {} export class ExampleEntity extends Entity { constructor(userData: ExampleProps) { super('example', userData) } async addPhysicsBody() { const environment = this.PhysicEnv const shapes: Array = [] const shape1 = environment.createShape( 'box', { length: 500, width: 500, height: 500 }, new THREE.Vector3(0, 0, 0), new THREE.Euler(0, 0, 0) ) shapes.push(shape1) const shape2 = environment.createShape( 'cylinder', { length: 100, width: 50, height: 1000 }, new THREE.Vector3(0, 750, 0), new THREE.Euler(0, 0, 0) ) shapes.push(shape2) const ammoBodyInfo = environment.createBodyInfo(shapes, 0.5, 0.5, CollisionType.DYNAMICS) const body = await environment.addBody(this, this.group, 1, ammoBodyInfo) this.setWholePhyBody(body) } async loadModel() { const box = new THREE.Mesh( new THREE.BoxGeometry(500, 500, 500), new THREE.MeshBasicMaterial({ color: 'red', transparent: true, opacity: 0.5 }) ) this.addModelToGroup(box) } async onAdded() {} onRemoved(): void {} onUpdating(deltaTime: number): void {} }