Skip to content

Commit

Permalink
improved interaction code
Browse files Browse the repository at this point in the history
  • Loading branch information
stemkoski committed Feb 22, 2022
1 parent 1db72c4 commit 1d5f28d
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions quest-interact.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,14 @@
{
this.colors = ["red", "orange", "yellow", "green", "blue", "violet"];

this.intersecting = false;
let self = this;

// this happens once, when intersection begins
this.el.addEventListener("raycaster-intersected", function(event)
{ self.intersecting = true; } );

// this happens once, when intersection ends
this.el.addEventListener("raycaster-intersected-cleared", function(event)
{ self.intersecting = false; } );

this.rightController = document.querySelector("#right-controller-entity");
this.rightData = this.rightController.components["controller-listener"];
this.hoverData = this.el.components["raycaster-hover"];
},

tick: function()
{
// this.rightData = this.rightController.components["controller-listener"]; // remove?
if (this.intersecting && this.rightData.trigger.pressed )
if (this.hoverData.hasFocus && this.rightData.trigger.pressed )
{
let index = Math.floor( this.colors.length * Math.random() );
let color = this.colors[index];
Expand Down

0 comments on commit 1d5f28d

Please sign in to comment.