Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* change raycaster to be non-recursive since there appears to be a wrapper around an entity's object3D, use its children instead * add simple example of non-recursive raycaster and dynamically created box add geometry so that raycaster actually adds something wait until next tick to satisfy Firefox; remove extra tick * changes per discussion on PR * changes per discussion on PR
- Loading branch information
1 parent
f8db222
commit 59b3cf0
Showing
5 changed files
with
231 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>Raycaster</title> | ||
<meta name="description" content="Raycaster - A-Frame"> | ||
<script src="../../../dist/aframe-master.js"></script> | ||
</head> | ||
<body> | ||
|
||
<script> | ||
|
||
AFRAME.registerComponent('raycast-blab', { | ||
init: function () { | ||
this.el.addEventListener('raycaster-intersected', function (evt) { | ||
var el = evt.detail.target; | ||
// May get two intersection events per tick; same element, different faces. | ||
console.log('raycaster-intersected ' + el.outerHTML); | ||
el.setAttribute('material', 'color', '#7f7'); | ||
}); | ||
|
||
this.el.addEventListener('raycaster-intersected-cleared', function (evt) { | ||
var el = evt.detail.target; | ||
// May get two intersection events per tick; same element, different faces. | ||
console.log('raycaster-intersected-cleared ' + el.outerHTML); | ||
el.setAttribute('material', 'color', '#f77'); | ||
}); | ||
} | ||
}); | ||
|
||
</script> | ||
|
||
<a-scene> | ||
<a-entity camera look-controls wasd-controls raycaster="recursive: false; interval: 1000"></a-entity> | ||
<a-entity geometry="primitive: box" material="color: #000" position="0 0 -2" raycast-blab></a-entity> | ||
</a-scene> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters