Javascript, Zero value, side effect?

  • Hi,

    Did anyone else find out a "0" value problem under KrPano / JavaScript?

    After a while, in my case: after the 6th scene loading...

    Real sequential code
    set(_i, 0); (or def(_i, integer, 0); )
    trace('brut: ', get(_i));
    fround(get(_i), '_i');
    trace('rounded: ', get(_i));

    Trace production:
    INFO: brut: 0.001
    INFO: rounded: 0.001

    With
    <action name="fround" type="Javascript"><![CDATA[
    var _varg = args[1];
    var _vtgt = args[2];
    var _round = parseFloat(_varg).toFixed(0);
    krpano.set(_vtgt, _round);
    ]]></action>

    Under Javascript, the 0.001 was/is a known problem, normaly solved with fround similar function. not under Krpano.
    I saw the problem under Chrome/FireFox (Mac OS) and IE/FireFox (Windows 7, 8...)

    The problem is really important for array access based on "for" loop
    for(set(_i, 0), _i LT _imax, inc(_i),
    ...
    );
    _i starts at 0.001 value, so imagine array_name[get(_i)].value *cry*

  • Hi,

    that seems to be a bug in the HTML5-VR Audio Plugin - inside its xml code I have found this line:

    Code
    if(%3 == 0, set(%3, 0.001));


    And that code means - when called with '0' as third parameter, it creates a variable named '0' and sets it to the value '0.001'.

    And that might be the reason for that strange behavior in your code.

    Best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!