Clean up js and add DocBlocks
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -4,6 +4,10 @@ modelLoad.setAttribute('src','https://ajax.googleapis.com/ajax/libs/model-viewer
|
||||
let headElem = document.getElementsByTagName('head')[0]
|
||||
headElem.appendChild(modelLoad)
|
||||
|
||||
/**
|
||||
* Sets listener and attributes on model-viewer to
|
||||
* allow for click registering of a new hotspot
|
||||
*/
|
||||
readyAddHotspot = function() {
|
||||
const previewMv = $('model-viewer')
|
||||
previewMv.one('click', clickAddHotspot)
|
||||
@@ -11,6 +15,14 @@ readyAddHotspot = function() {
|
||||
previewMv[0].disableTap = true
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener callback to retrieve the info
|
||||
* about the model surface point selected by the
|
||||
* mouse and add that information to the editor
|
||||
* text input
|
||||
*
|
||||
* @param {PointerEvent} e
|
||||
*/
|
||||
clickAddHotspot = function(e) {
|
||||
const previewMv = $('model-viewer')
|
||||
previewMv.removeClass('AddingHotspot')
|
||||
@@ -41,6 +53,13 @@ clickAddHotspot = function(e) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener callback to toggle the visibility
|
||||
* of a hotspot's annotation when the hotspot is
|
||||
* clicked
|
||||
*
|
||||
* @param {PointerEvent} e
|
||||
*/
|
||||
onAnnotation = function(e) {
|
||||
e.stopPropagation();
|
||||
let targetAnnotation = e.target.slot.split('-')[1];
|
||||
@@ -56,6 +75,11 @@ onAnnotation = function(e) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Event listener callback to hide all hotspot
|
||||
* annotations when the model-viewer receives
|
||||
* a click event
|
||||
*/
|
||||
clearAnnotations = function() {
|
||||
[...document.getElementsByClassName('HotspotAnnotation')].forEach( an => {
|
||||
an.classList.add('HiddenAnnotation');
|
||||
|
||||
Reference in New Issue
Block a user