45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
export class physicsObject{
|
|
//array of floats [3]
|
|
position : number[] = [0,0,0]
|
|
rotation : number[] = [0,0,0]
|
|
velocity : number[] = [0,0,0]
|
|
angularVelocity : number[] = [0,0,0]
|
|
|
|
static isKinematic(o:physicsObject){
|
|
return !o.hasOwnProperty("velocity")
|
|
}
|
|
|
|
static copyAll(o: physicsObject) {
|
|
let pObject = Object.assign({}, o)
|
|
return pObject
|
|
}
|
|
|
|
static characterOnly(o: physicsObject) {
|
|
let pObject : any = {}
|
|
pObject.position = o.position
|
|
pObject.velocity = o.velocity
|
|
return pObject
|
|
}
|
|
|
|
static copyStart(o: physicsObject) {
|
|
let pObject : any = {}
|
|
pObject.position = o.position
|
|
pObject.rotation = o.rotation
|
|
if(!this.isKinematic(o)){
|
|
pObject.velocity = o.velocity
|
|
pObject.angularVelocity = o.angularVelocity
|
|
}
|
|
return pObject
|
|
}
|
|
|
|
static copyUpdate(o: physicsObject) {
|
|
let pObject : any = {}
|
|
if(!this.isKinematic(o)){
|
|
pObject.position = o.position
|
|
pObject.rotation = o.rotation
|
|
pObject.velocity = o.velocity
|
|
pObject.angularVelocity = o.angularVelocity
|
|
}
|
|
return pObject
|
|
}
|
|
} |