jure / aframe-blink-controls

A teleport (blink with rotation) component for A-Frame
https://jure.github.io/aframe-blink-controls
MIT License
50 stars 17 forks source link

bug: teleporting breaks when teleported to position with negative z-value, #30

Open coderofsalvation opened 9 months ago

coderofsalvation commented 9 months ago

try teleporting to a mesh at 0,0,-10, you'll see that it throws some kindof computeBoundingSphere error.

vincentfretin commented 9 months ago

I also add the issue in one of my scene. I just moved up my whole scene to fix the issue. If I remember, the issue was with square of some negative number like Math.sqrt(-20) giving NaN. I think it was here https://github.com/jure/aframe-blink-controls/blob/4c53449a8410d42e7681d47c0c458b52e11e3456/src/index.js#L532 Not sure how we can solve that.

coderofsalvation commented 9 months ago

kudos for having discovered the same (it took me a while to figure this bug out) Anyways, my tiny math-brain does not really know what p0 v0 and a mean (energy, velocity and amplitude?).

I'm trying to fiddle with it in the javascript browser-console, thinking whether simply wrapping values in Math.abs() will do the job (I mean the output of sqrt is always positive)

$('[blink-controls]').components['blink-controls'].parabolicCurveMaxRoot = function (p0, v0, a) {
    const root = (-v0.y - Math.sqrt( Math.abs(v0.y) ** 2 - 4 * (0.5 * Math.abs(a.y) ) * Math.abs(p0.y) ) ) / (2 * 0.5 * Math.abs(a.y) )
    return root
}

will test it asap