the-world-engine
Version:
three.js based, unity like game engine for browser
17 lines (16 loc) • 618 B
JavaScript
import { Component } from "../../hierarchy_object/Component";
export class ObjectAttacher2D extends Component {
bo=null;
set target(t) {
this.bo = t;
t.transform.localPosition.x = this.transform.position.x;
t.transform.localPosition.y = this.transform.position.y;
t.transform.localEulerAngles.z = this.transform.eulerAngles.z;
}
onWorldMatrixUpdated() {
const t = this.bo.transform;
t.localPosition.x = this.transform.position.x;
t.localPosition.y = this.transform.position.y;
t.localEulerAngles.z = this.transform.eulerAngles.z;
}
}