From 9b85bc6cdd1f28a1f82d768f1480825037a04a91 Mon Sep 17 00:00:00 2001 From: Kevin Levron Date: Sun, 7 Mar 2021 01:30:04 +0100 Subject: [PATCH] add lookAt --- src/core/Object3D.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 026b8b3..4b20eb3 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -1,3 +1,4 @@ +import { watch } from 'vue'; import { bindProp } from '../tools.js'; export default { @@ -6,6 +7,7 @@ export default { position: Object, rotation: Object, scale: Object, + lookAt: { type: Object, default: null }, }, // can't use setup because it will not be used in sub components // setup() {}, @@ -21,6 +23,9 @@ export default { bindProp(this, 'rotation', this.o3d.rotation); bindProp(this, 'scale', this.o3d.scale); + if (this.lookAt) this.o3d.lookAt(this.lookAt.x, this.lookAt.y, this.lookAt.z); + watch(() => this.lookAt, (v) => { this.o3d.lookAt(v.x, v.y, v.z); }, { deep: true }); + if (this.$parent.add) this.$parent.add(this.o3d); }, add(o) { this.o3d.add(o); },