2023-09-15 04:49:31 +08:00
|
|
|
export class physicsObject{
|
|
|
|
//array of floats [3]
|
2023-09-16 14:57:54 +08:00
|
|
|
position : number[] = [0,0,0]
|
|
|
|
rotation : number[] = [0,0,0]
|
|
|
|
velocity : number[] = [0,0,0]
|
|
|
|
angularVelocity : number[] = [0,0,0]
|
2023-11-01 10:01:57 +08:00
|
|
|
|
2023-11-02 02:46:59 +08:00
|
|
|
static isKinematic(o:physicsObject){
|
|
|
|
return !o.hasOwnProperty("velocity")
|
|
|
|
}
|
|
|
|
|
|
|
|
static copyAll(o: physicsObject) {
|
2023-11-01 10:01:57 +08:00
|
|
|
let pObject = Object.assign({}, o)
|
2023-11-02 02:46:59 +08:00
|
|
|
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
|
|
|
|
}
|
2023-11-01 10:01:57 +08:00
|
|
|
|
2023-11-02 02:46:59 +08:00
|
|
|
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
|
|
|
|
}
|
2023-11-01 10:01:57 +08:00
|
|
|
return pObject
|
|
|
|
}
|
2023-09-15 04:49:31 +08:00
|
|
|
}
|