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]
|
let headElem = document.getElementsByTagName('head')[0]
|
||||||
headElem.appendChild(modelLoad)
|
headElem.appendChild(modelLoad)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets listener and attributes on model-viewer to
|
||||||
|
* allow for click registering of a new hotspot
|
||||||
|
*/
|
||||||
readyAddHotspot = function() {
|
readyAddHotspot = function() {
|
||||||
const previewMv = $('model-viewer')
|
const previewMv = $('model-viewer')
|
||||||
previewMv.one('click', clickAddHotspot)
|
previewMv.one('click', clickAddHotspot)
|
||||||
@@ -11,6 +15,14 @@ readyAddHotspot = function() {
|
|||||||
previewMv[0].disableTap = true
|
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) {
|
clickAddHotspot = function(e) {
|
||||||
const previewMv = $('model-viewer')
|
const previewMv = $('model-viewer')
|
||||||
previewMv.removeClass('AddingHotspot')
|
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) {
|
onAnnotation = function(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
let targetAnnotation = e.target.slot.split('-')[1];
|
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() {
|
clearAnnotations = function() {
|
||||||
[...document.getElementsByClassName('HotspotAnnotation')].forEach( an => {
|
[...document.getElementsByClassName('HotspotAnnotation')].forEach( an => {
|
||||||
an.classList.add('HiddenAnnotation');
|
an.classList.add('HiddenAnnotation');
|
||||||
|
|||||||
Reference in New Issue
Block a user