diff --git a/modules/glmv.js b/modules/glmv.js index 392f977..85c1808 100644 --- a/modules/glmv.js +++ b/modules/glmv.js @@ -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');