Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
b186b11
commit ae0e455
Showing
4 changed files
with
74 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<!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> | ||
<a-scene> | ||
<a-entity camera look-controls wasd-controls raycaster="recursive: false; interval: 1000"></a-entity> | ||
</a-scene> | ||
|
||
<script> | ||
var el = document.createElement('a-entity'); | ||
el.setAttribute('geometry', 'primitive: box'); | ||
el.setAttribute('material', 'color: #000'); | ||
el.setAttribute('position', '0 0 -2'); | ||
document.querySelector('a-scene').appendChild(el); | ||
|
||
document.querySelector('a-entity[geometry]').addEventListener('raycaster-intersected', function (evt) { | ||
// getting two intersection events per tick; same element, different faces... | ||
console.log('raycaster-intersected ' + evt.detail.el.outerHTML); | ||
this.setAttribute('material', 'color: #7f7'); | ||
}); | ||
|
||
document.querySelector('a-entity[geometry]').addEventListener('raycaster-intersected-cleared', function (evt) { | ||
// getting two intersection events per tick; same element, different faces... | ||
console.log('raycaster-intersected-cleared ' + evt.detail.el.outerHTML); | ||
this.setAttribute('material', 'color: #f77'); | ||
}); | ||
</script> | ||
</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