diff --git a/index.html b/index.html
index a61c485..1641fc4 100644
--- a/index.html
+++ b/index.html
@@ -2500,6 +2500,8 @@ function makeAnchorsVisibleOnTargets(){
function startMesher(){
let meshPoints = []
+ let meshTriangles = []
+ let offset
let meshEl = document.createElement("a-entity")
meshEl.className += "meshed"
AFRAME.scenes[0].appendChild( meshEl )
@@ -2507,6 +2509,8 @@ function startMesher(){
let elSecondary = document.querySelector('[pinchsecondary]')
elSecondary.addEventListener('pinchended', endedSecondary );
function endedSecondary(){
+ targets.push(meshEl)
+ //makeAnchorsVisibleOnTargets() // too large here
applyToClass("meshvertex", (e, val ) => e.setAttribute("visible", val), "false")
el.removeEventListener('pinchended', end)
elSecondary.removeEventListener('pinchended', endedSecondary );
@@ -2517,7 +2521,12 @@ function startMesher(){
function end(event) {
if (selectedElement) return
- let currentPos = AFRAME.utils.coordinates.stringify( event.detail.position)
+ let pos = event.detail.position.clone()
+ if (meshPoints.length==0){
+ meshOffset = event.detail.position.clone()
+ meshEl.getAttribute("position").add(meshOffset)
+ }
+ let currentPos = AFRAME.utils.coordinates.stringify( pos.sub(meshOffset) )
let controlSphere = document.createElement("a-sphere")
controlSphere.className += "meshvertex"
controlSphere.setAttribute("radius", 0.01)
@@ -2537,7 +2546,7 @@ function startMesher(){
meshEl.removeAttribute("line")
let ranked = meshPoints
.slice(0,-1)
- .map( t => { return { el: t, dist : event.detail.position.distanceTo(t.getAttribute("position") ) } })
+ .map( t => { return { el: t, dist : pos.distanceTo(t.getAttribute("position") ) } })
.sort( (a,b) => a.dist - b.dist)
let triangle = document.createElement("a-triangle")
triangle.setAttribute("vertex-a", currentPos)
@@ -2547,6 +2556,7 @@ function startMesher(){
AFRAME.utils.coordinates.stringify( ranked[1].el.getAttribute("position") ))
triangle.setAttribute("material", "side:double")
meshEl.appendChild( triangle )
+ meshTriangles.push( triangle )
}
}
}
@@ -2611,12 +2621,8 @@ AFRAME.registerComponent('startfunctions', {
-
-
-
-
-
+