From 321f47bca5ce0ba56c903d804b6f1200a21fae8b Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Sun, 15 Jan 2023 17:42:25 +0100 Subject: [PATCH] merged screenshot, snapping to 10cm (invisible) grid --- index.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index bc9de38..4f6dd7a 100644 --- a/index.html +++ b/index.html @@ -1960,11 +1960,20 @@ AFRAME.registerComponent('snap-on-pinchended', { init: function(){ let el = this.el this.el.addEventListener('released', function (event) { - if (tile_snapping_enabled) el.setAttribute("rotation", "0 0 0") + if (tile_snapping_enabled) { + el.setAttribute("rotation", "0 0 0") + // could limit to an axis or two, e.g here y axis probably should be kept or at least adjust to next 1/6th rotation + // could snap to invisible grid too, e.g every 1 or 1/10th unit + var pos = AFRAME.utils.coordinates.parse( el.getAttribute("position") ) + pos.x = pos.x.toFixed(1) // i.e .1m so 1/10th of a meter here, 10cm + pos.y = pos.y.toFixed(1) + pos.z = pos.z.toFixed(1) + el.setAttribute("position", AFRAME.utils.coordinates.stringify(pos)) // if works, generalize and add to https://git.benetou.fr/utopiah/text-code-xr-engine/issues/66 // should come back from emit('released') // could rely on getClosestTilesSnappingPosition() // if it works, might check if position is not already used by a tile + } }) } }) @@ -2056,13 +2065,14 @@ function addScreenshot(){ - + +