Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Adds position debug via event
Browse files Browse the repository at this point in the history
  • Loading branch information
flyandi committed Feb 19, 2021
1 parent 36a9345 commit a790b16
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/viewer/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import TWEEN from '@tweenjs/tween.js';
* @param {boolean} [options.autoReticleSelect=true] - Auto select a clickable target after dwellTime
* @param {boolean} [options.viewIndicator=false] - Adds an angle view indicator in upper left corner
* @param {number} [options.indicatorSize=30] - Size of View Indicator
* @param {string} [options.output='none'] - Whether and where to output raycast position. Could be 'console' or 'overlay'
* @param {string} [options.output='none'] - Whether and where to output raycast position. Could be 'event', 'console' or 'overlay'.
* @param {boolean} [options.autoRotate=false] - Auto rotate
* @param {number} [options.autoRotateSpeed=2.0] - Auto rotate speed as in degree per second. Positive is counter-clockwise and negative is clockwise.
* @param {number} [options.autoRotateActivationDuration=5000] - Duration before auto rotatation when no user interactivity in ms
Expand Down Expand Up @@ -1306,12 +1306,22 @@ Viewer.prototype = Object.assign( Object.create( THREE.EventDispatcher.prototype
const world = this.panorama.getWorldPosition( new THREE.Vector3() );
point.sub( world ).multiply( converter );

const message = `${point.x.toFixed(2)}, ${point.y.toFixed(2)}, ${point.z.toFixed(2)}`;
const position = {
x: point.x.toFixed(2),
y: point.y.toFixed(2),
z: point.z.toFixed(2),
};

const message = `${position.x}, ${position.y}, ${position.z}`;

if ( point.length() === 0 ) { return; }

switch ( this.options.output ) {

case 'event':
this.dispatchEvent( { type: 'position-update', position: position } );
break;

case 'console':
console.info( message );
break;
Expand Down

0 comments on commit a790b16

Please sign in to comment.