diff --git a/index.html b/index.html index 5046dea..4e7ff5f 100644 --- a/index.html +++ b/index.html @@ -5,8 +5,7 @@ - - + @@ -20,12 +19,45 @@ // onreleased does not work on 1.6 yet works on 1.5 // also minimalist example on event to emit() then receive on component does work +function showFurnitures(filterAwayLabel=""){ // e.g "wall" to avoid walls + // must be done after entering AR + Array.from(document.querySelectorAll("[data-world-mesh]") ) + .filter( el => el.getAttribute("data-world-mesh") != filterAwayLabel) + .map( el => el.setAttribute("visible", "true") ) // probably need a mixin first + .map( el => el.setAttribute("wireframe", "true") ) +} + function getFurnitures(){ // from https://aframe.io/docs/1.6.0/components/real-world-meshing.html worldMeshes = Array.from(document.querySelectorAll("[data-world-mesh]") ) // should be done after entering AR worldMeshes.map( el => console.log( el.getAttribute("data-world-mesh") ) ) // should be use in order to snap onreleased to a specific object, e.g + return worldMeshes +} + +function attachWorldMeshLookAt(){ + console.log('testing attachWorldMeshLookAt()') + let target + Array.from( document.querySelectorAll("[data-world-mesh]") ) + .filter( el => el.getAttribute("data-world-mesh") != "wall") // avoiding walls + .map( el => { + // could probably filter() instead, even querySelector directly + if ( el.states.includes( "cursor-hovered" ) ) target = el + }) + if (!target) { + console.log('no target entity of semantic label found') + console.log('(consider doing room setup again and looking at entity before releasing)') + } else { + let latest = selectedElements[selectedElements.length-1].element + console.log('putting', latest, 'on', target.getAttribute("real-world-mesh" )) + latest.setAttribute( "position", target.getAttribute("position") ) + latest.setAttribute( "rotation", target.getAttribute("rotation") ) + // note that this will NOT work well on objects with depth, e.g table, but rather on screens, art piece, walls (even arguable) + // could add optional parameter to add "on top of" or other positionning + // could be based on the limited type of labels too + // could stack, or even add random offsets to void overlap + } } function attachFirstWorldMeshFromLabel(label){ @@ -421,8 +453,12 @@ setTimeout( _ => { + + + +