repo: janusweb action: commit revision: path_from: revision_from: 1b87630ea5449ea765f39869224dd8ab44ad51ba: path_to: revision_to:
commit 1b87630ea5449ea765f39869224dd8ab44ad51ba Author: James BaicoianuDate: Thu Oct 22 14:32:31 2020 -0700 Fix billboarding when in XR diff --git a/scripts/janusbase.js b/scripts/janusbase.js
--- a/scripts/janusbase.js
+++ b/scripts/janusbase.js
@@ -749,7 +749,12 @@ elation.require(['engine.things.generic', 'utils.template', 'janusweb.parts'], f
*/
// TODO - Simple trig makes this much faster, but to get the same functionality as before we'll need to implement each dimension
// For now, we only support billboarding with the Y axis locked (eg, doom sprites)
- parent.worldToLocal(player.camera.getWorldPosition(playerpos)).sub(this.position);
+ let views = this.engine.systems.render.views;
+ let camera = player.camera;
+ if (views.xr && views.xr.enabled && views.xr.camera && views.xr.camera.userData.thing) {
+ camera = views.xr.camera.userData.thing;
+ }
+ parent.worldToLocal(camera.getWorldPosition(playerpos)).sub(this.position);
dir.copy(playerpos).normalize();
if (billboard == 'y') {
this.rotation.set(0, Math.atan2(dir.x, dir.z), 0);
-----END OF PAGE-----