|
|
@ -99,7 +99,7 @@ var selectionPinchMode = false |
|
|
|
var groupingMode = false |
|
|
|
var groupingMode = false |
|
|
|
var sketchEl |
|
|
|
var sketchEl |
|
|
|
var lastPointSketch |
|
|
|
var lastPointSketch |
|
|
|
var hudTextEl |
|
|
|
var hudTextEl // should instead rely on the #typinghud selector in most cases |
|
|
|
const startingText = "[]" |
|
|
|
const startingText = "[]" |
|
|
|
var drawingMode = false |
|
|
|
var drawingMode = false |
|
|
|
var added = [] |
|
|
|
var added = [] |
|
|
@ -638,13 +638,16 @@ AFRAME.registerComponent('screenstack', { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getClosestTargetElements( pos, threshold=0.05 ){ |
|
|
|
function getClosestTargetElement( pos, threshold=0.05 ){ // 10x lower threshold for flight mode |
|
|
|
|
|
|
|
// TODO Bbox intersects rather than position |
|
|
|
// TODO Bbox intersects rather than position |
|
|
|
var res = null |
|
|
|
return targets.filter( e => e.getAttribute("visible") == true).map( t => { return { el: t, dist : pos.distanceTo(t.getAttribute("position") ) } }) |
|
|
|
const matches = targets.filter( e => e.getAttribute("visible") == true).map( t => { return { el: t, dist : pos.distanceTo(t.getAttribute("position") ) } }) |
|
|
|
|
|
|
|
.filter( t => t.dist < threshold ) |
|
|
|
.filter( t => t.dist < threshold ) |
|
|
|
.sort( (a,b) => a.dist > b.dist) |
|
|
|
.sort( (a,b) => a.dist > b.dist) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getClosestTargetElement( pos, threshold=0.05 ){ // 10x lower threshold for flight mode |
|
|
|
|
|
|
|
var res = null |
|
|
|
|
|
|
|
const matches = getClosestTargetElements( pos, threshold) |
|
|
|
if (matches.length > 0) res = matches[0].el |
|
|
|
if (matches.length > 0) res = matches[0].el |
|
|
|
return res |
|
|
|
return res |
|
|
|
} |
|
|
|
} |
|
|
@ -738,8 +741,16 @@ function addToGroup( position ){ |
|
|
|
addBoundingBoxToTextElement( el ) |
|
|
|
addBoundingBoxToTextElement( el ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function appendToFeedbackHUD(txt){ |
|
|
|
|
|
|
|
setFeedbackHUD( document.querySelector("#feedbackhud").getAttribute("value") + " " + txt ) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setFeedbackHUD(txt){ |
|
|
|
|
|
|
|
document.querySelector("#feedbackhud").setAttribute("value",txt) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function appendToHUD(txt){ |
|
|
|
function appendToHUD(txt){ |
|
|
|
const textHUD = document.querySelector("[hud]>a-troika-text").getAttribute("value") |
|
|
|
const textHUD = document.querySelector("#typinghud").getAttribute("value") |
|
|
|
if ( textHUD == startingText) |
|
|
|
if ( textHUD == startingText) |
|
|
|
setHUD( txt ) |
|
|
|
setHUD( txt ) |
|
|
|
else |
|
|
|
else |
|
|
@ -747,7 +758,7 @@ function appendToHUD(txt){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setHUD(txt){ |
|
|
|
function setHUD(txt){ |
|
|
|
document.querySelector("[hud]>a-troika-text").setAttribute("value",txt) |
|
|
|
document.querySelector("#typinghud").setAttribute("value",txt) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
AFRAME.registerComponent('wristattachsecondary',{ |
|
|
|
AFRAME.registerComponent('wristattachsecondary',{ |
|
|
@ -790,7 +801,7 @@ AFRAME.registerComponent('pinchsecondary', { |
|
|
|
if (setupMode) setupBBox["B"] = event.detail.position |
|
|
|
if (setupMode) setupBBox["B"] = event.detail.position |
|
|
|
if ( setupBBox["A"] && setupBBox["B"] ) { |
|
|
|
if ( setupBBox["A"] && setupBBox["B"] ) { |
|
|
|
setupMode = false |
|
|
|
setupMode = false |
|
|
|
setHUD( JSON.stringify(setupBBox)) |
|
|
|
setFeedbackHUD( JSON.stringify(setupBBox)) |
|
|
|
} |
|
|
|
} |
|
|
|
/* |
|
|
|
/* |
|
|
|
selectionPinchMode = false |
|
|
|
selectionPinchMode = false |
|
|
@ -803,14 +814,14 @@ AFRAME.registerComponent('pinchsecondary', { |
|
|
|
this.el.addEventListener('pinchmoved', function (event) { |
|
|
|
this.el.addEventListener('pinchmoved', function (event) { |
|
|
|
if (selectionPinchMode){ |
|
|
|
if (selectionPinchMode){ |
|
|
|
bbox.min.copy( event.detail.position ) |
|
|
|
bbox.min.copy( event.detail.position ) |
|
|
|
setHUD( "selectionPinchMode updated min") |
|
|
|
setFeedbackHUD( "selectionPinchMode updated min") |
|
|
|
if (!bbox.max.equal(zeroVector3)) |
|
|
|
if (!bbox.max.equal(zeroVector3)) |
|
|
|
selectionBox.update(); |
|
|
|
selectionBox.update(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
this.el.addEventListener('pinchstarted', function (event) { |
|
|
|
this.el.addEventListener('pinchstarted', function (event) { |
|
|
|
if (!selectionPinchMode) bbox.min.copy( zeroVector3 ) |
|
|
|
if (!selectionPinchMode) bbox.min.copy( zeroVector3 ) |
|
|
|
if (selectionPinchMode) setHUD( "selectionPinchMode started") |
|
|
|
if (selectionPinchMode) setFeedbackHUD( "selectionPinchMode started") |
|
|
|
}); |
|
|
|
}); |
|
|
|
}, |
|
|
|
}, |
|
|
|
remove: function() { |
|
|
|
remove: function() { |
|
|
@ -830,11 +841,14 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o |
|
|
|
// see own trigger-box component. Could use dedicated threejs helpers instead. |
|
|
|
// see own trigger-box component. Could use dedicated threejs helpers instead. |
|
|
|
// https://github.com/Utopiah/aframe-triggerbox-component/blob/master/aframe-triggerbox-component.js#L66 |
|
|
|
// https://github.com/Utopiah/aframe-triggerbox-component/blob/master/aframe-triggerbox-component.js#L66 |
|
|
|
// could make trigger zones visible as debug mode |
|
|
|
// could make trigger zones visible as debug mode |
|
|
|
|
|
|
|
var closests = getClosestTargetElements( event.detail.position ) |
|
|
|
|
|
|
|
if (closests && closests.length > 0) // avoiding self reference |
|
|
|
|
|
|
|
setFeedbackHUD("close enough, could stack with "+ closests[1].el.getAttribute("value") ) |
|
|
|
var dist = event.detail.position.distanceTo( document.querySelector("#box").object3D.position ) |
|
|
|
var dist = event.detail.position.distanceTo( document.querySelector("#box").object3D.position ) |
|
|
|
if (dist < .1){ |
|
|
|
if (dist < .1){ |
|
|
|
setHUD("close enough, replaced shortcut with "+ selectedElement.getAttribute("value") ) |
|
|
|
setFeedbackHUD("close enough, replaced shortcut with "+ selectedElement.getAttribute("value") ) |
|
|
|
wristShortcut = selectedElement.getAttribute("value") |
|
|
|
wristShortcut = selectedElement.getAttribute("value") |
|
|
|
setTimeout( _ => setHUD(""), 2000) |
|
|
|
setTimeout( _ => setFeedbackHUD(""), 2000) |
|
|
|
} |
|
|
|
} |
|
|
|
// unselect current target if any |
|
|
|
// unselect current target if any |
|
|
|
selectedElement = null; |
|
|
|
selectedElement = null; |
|
|
@ -843,7 +857,7 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o |
|
|
|
// somehow keeps on setting up... shouldn't once done. |
|
|
|
// somehow keeps on setting up... shouldn't once done. |
|
|
|
if ( setupBBox["A"] && setupBBox["B"] ) { |
|
|
|
if ( setupBBox["A"] && setupBBox["B"] ) { |
|
|
|
setupMode = false |
|
|
|
setupMode = false |
|
|
|
setHUD( JSON.stringify(setupBBox)) |
|
|
|
setFeedbackHUD( JSON.stringify(setupBBox)) |
|
|
|
} |
|
|
|
} |
|
|
|
if ( drawingMode ) draw( event.detail.position ) |
|
|
|
if ( drawingMode ) draw( event.detail.position ) |
|
|
|
if ( groupingMode ) addToGroup( event.detail.position ) |
|
|
|
if ( groupingMode ) addToGroup( event.detail.position ) |
|
|
@ -1029,13 +1043,19 @@ function parseKeys(status, key){ |
|
|
|
|
|
|
|
|
|
|
|
AFRAME.registerComponent('hud', { |
|
|
|
AFRAME.registerComponent('hud', { |
|
|
|
init: function(){ |
|
|
|
init: function(){ |
|
|
|
var el = this.el |
|
|
|
var feedbackHUDel= document.createElement("a-troika-text") |
|
|
|
var e = document.createElement("a-troika-text") |
|
|
|
feedbackHUDel.id = "feedbackhud" |
|
|
|
e.setAttribute("value", startingText) |
|
|
|
feedbackHUDel.setAttribute("value", "") |
|
|
|
e.setAttribute("position", "-0.05 0 -0.2") |
|
|
|
feedbackHUDel.setAttribute("position", "-0.05 0.01 -0.2") |
|
|
|
e.setAttribute("scale", "0.05 0.05 0.05") |
|
|
|
feedbackHUDel.setAttribute("scale", "0.05 0.05 0.05") |
|
|
|
el.appendChild( e ) |
|
|
|
this.el.appendChild( feedbackHUDel ) |
|
|
|
hudTextEl = e |
|
|
|
var typingHUDel = document.createElement("a-troika-text") |
|
|
|
|
|
|
|
typingHUDel.id = "typinghud" |
|
|
|
|
|
|
|
typingHUDel.setAttribute("value", startingText) |
|
|
|
|
|
|
|
typingHUDel.setAttribute("position", "-0.05 0 -0.2") |
|
|
|
|
|
|
|
typingHUDel.setAttribute("scale", "0.05 0.05 0.05") |
|
|
|
|
|
|
|
this.el.appendChild( typingHUDel ) |
|
|
|
|
|
|
|
hudTextEl = typingHUDel // should rely on the id based selector now |
|
|
|
document.addEventListener('keyup', function(event) { |
|
|
|
document.addEventListener('keyup', function(event) { |
|
|
|
parseKeys('keyup', event.key) |
|
|
|
parseKeys('keyup', event.key) |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1141,7 +1161,7 @@ function addGltfFromURLAsTarget( url, scale=1 ){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function showhistory(){ |
|
|
|
function showhistory(){ |
|
|
|
setHUD("history :\n") |
|
|
|
setFeedbackHUD("history :\n") |
|
|
|
commandhistory.map( i => appendToHUD(i.uninterpreted+"\n") ) |
|
|
|
commandhistory.map( i => appendToHUD(i.uninterpreted+"\n") ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1176,9 +1196,9 @@ function interpretJXR( code ){ |
|
|
|
if (code.length == 1) { // special case of being a single character, thus keyboard |
|
|
|
if (code.length == 1) { // special case of being a single character, thus keyboard |
|
|
|
if (code == ">") { // Enter equivalent |
|
|
|
if (code == ">") { // Enter equivalent |
|
|
|
addNewNote( hudTextEl.getAttribute("value") ) |
|
|
|
addNewNote( hudTextEl.getAttribute("value") ) |
|
|
|
hudTextEl.setAttribute("value", "") |
|
|
|
setHUD("") |
|
|
|
} else if (code == "<") { // Backspace equivalent |
|
|
|
} else if (code == "<") { // Backspace equivalent |
|
|
|
hudTextEl.setAttribute("value", hudTextEl.getAttribute("value").slice(0,-1)) |
|
|
|
setHUD( hudTextEl.getAttribute("value").slice(0,-1)) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
appendToHUD( code ) |
|
|
|
appendToHUD( code ) |
|
|
|
} |
|
|
|
} |
|
|
|