From 41354e2d706edffe44a4ba53256f8eb6d723b330 Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Fri, 25 Oct 2024 18:46:55 -0700 Subject: [PATCH] Clean up js and add DocBlocks Signed-off-by: Justin Georgi --- modules/glmv.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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');