repo: janusweb
action: commit
revision: 
path_from: 
revision_from: c94bf98138fa00cf0eadf6ca7431c4ad7826abb5:
path_to: 
revision_to: 
git.thebackupbox.net
janusweb
git clone git://git.thebackupbox.net/janusweb
commit c94bf98138fa00cf0eadf6ca7431c4ad7826abb5
Author: James Baicoianu 
Date:   Wed Sep 11 13:33:54 2024 -0700

    Support THREE objects for player.lookAt(), and look from the head not the feet

diff --git a/scripts/janusplayer.js b/scripts/janusplayer.js
index c655c48f2745b283093403c5a16891fa0261d272..
index ..be8892d75e8ecd9f36f0ba6f2a6b62414698c5c2 100644
--- a/scripts/janusplayer.js
+++ b/scripts/janusplayer.js
@@ -1110,13 +1110,17 @@ document.body.dispatchEvent(click);
     }
     this.lookAt = function(other, up, turnhead) {
       if (!up) up = new THREE.Vector3(0,1,0);
+      if (!other) return;
       var otherpos = false;
       if (other.properties && other.properties.position) {
         otherpos = other.localToWorld(new THREE.Vector3());
+      } else if (other instanceof THREE.Object3D) {
+        if (!otherpos) otherpos = new THREE.Vector3();
+        other.getWorldPosition(otherpos);
       } else if (other instanceof THREE.Vector3) {
         otherpos = other.clone();
       }
-      var thispos = this.localToWorld(new THREE.Vector3());
+      var thispos = this.head.localToWorld(new THREE.Vector3());

       if (otherpos) {
         var dir = thispos.clone().sub(otherpos).normalize();

-----END OF PAGE-----