Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (49 sloc) 1.42 KB
<!DOCTYPE html><html><head><meta charset="utf-8"/>
<title>dual-drawline-VR for Oculus Quest</title>
<script src="https://aframe.io/releases/0.9.2/aframe.min.js"></script>
<script>'use strict'
const list = []
AFRAME.registerComponent('input-listen', {
init: function() {
this.line = null
this.bkp = null
const scene = document.querySelector('a-scene')
const self = this
this.el.addEventListener('triggerdown', function(evt) {
if (!self.line) {
self.line = document.createElement('a-entity')
scene.appendChild(self.line)
list.push(self.line)
self.bkp = this.object3D.getWorldPosition()
}
})
this.el.addEventListener('triggerup', function(evt) {
self.line = null
})
const removeLine = function() {
const line = list.pop()
if (line)
scene.removeChild(line)
return line
}
this.el.addEventListener('gripdown', function(evt) {
removeLine()
self.line = null
})
this.el.addEventListener('bbuttondown', function(evt) {
while (removeLine());
})
},
tick: function() {
if (this.line) {
const p = this.el.object3D.getWorldPosition()
this.line.setAttribute('line', { start: this.bkp, end: p, color: "#F00" })
}
}
})
</script></head><body><a-scene>
<a-sky color="#000"></a-sky>
<a-entity id='handright' oculus-touch-controls='hand: right' input-listen></a-entity>
<a-entity id='handleft' oculus-touch-controls='hand: left' input-listen></a-entity>
</a-scene>
</body></html>
You can’t perform that action at this time.