Created
September 4, 2017 09:45
-
-
Save ngokevin/07ed72398f2c3a559ba6eccad3024791 to your computer and use it in GitHub Desktop.
Useful A-Frame utilities.
This file contains hidden or 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
/** | |
* Helper to visualize lines. | |
*/ | |
window.drawLine = (function () { | |
var els = {}; | |
return function (name, vec1, vec2, color) { | |
if (!els[name]) { | |
els[name] = document.createElement('a-entity'); | |
els[name].setAttribute('line', 'color', color || '#FFF'); | |
els[name].setAttribute('id', name); | |
AFRAME.scenes[0].appendChild(els[name]); | |
} | |
els[name].setAttribute('line', 'start', vec1.clone()); | |
els[name].setAttribute('line', 'end', vec2.clone()); | |
}; | |
})(); | |
/** | |
* Helper to visualize vectors. | |
*/ | |
window.drawVec3 = (function () { | |
var els = {}; | |
return function (name, vec3, color) { | |
if (!els[name]) { | |
els[name] = document.createElement('a-sphere'); | |
els[name].setAttribute('color', color || '#FFF'); | |
els[name].setAttribute('radius', 0.02); | |
els[name].setAttribute('id', name); | |
els[name].setAttribute('text', {align: 'center', value: name, side: 'double'}); | |
AFRAME.scenes[0].appendChild(els[name]); | |
} | |
els[name].setAttribute('position', vec3.clone()); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment