We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Sending variables for transform

Home Forums Programming Sending variables for transform

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #8043
    dragosburian
    Customer

    Hi everybody,

    What would be the best approach for receiving variables for applying transform? So far, I have the variable brought to the visual_logic.js file, yet transforming does not work from there, here is a code snippet:

    PL.init = function(appInstance, scope) {

    var vision_panel, motor_cover, roll_cover;

    var test = scope[‘variable_1’];
    setObjTransform(“width_control”, “scale”, test / 100, ”, ”, false);
    setObjTransform(“right_profile”, “position”, 1.3 * (test / 100), ”, ”, false);

    just like puzzles generate with the onclick event, but using my variable.

    #8051

    Hi,

    Can you print the test variable to the console? Does it output a correct value at least?

    Chief 3D Verger | LinkedIn | Twitter

    #8053
    dragosburian
    Customer

    Yes, the variable brings in the right value, the snag is with the transform function

    #8057

    Ok, can you attach here a narrowed down example so that we can take a look?

    Chief 3D Verger | LinkedIn | Twitter

    #8066
    dragosburian
    Customer

    Yes, this is part of the visual_logic.js, PL.init function

    PL.init = function(appInstance, scope) {

    var vision_panel, motor_cover, roll_cover;

    var test = scope[‘variable_1’];
    setObjTransform(“width_control”, “scale”, test / 100, ”, ”, false);
    setObjTransform(“right_profile”, “position”, 1.3 * (test / 100), ”, ”, false);

    scope is my variable, and I verified and it works, the value is the correct one, I have breakpoints for both transforms, it reaches the first, but the next is never reached, if you know what i mean. It’s as if it somehow gets redirected.

    #8069

    it reaches the first, but the next is never reached

    may be it throws an exception?

    Chief 3D Verger | LinkedIn | Twitter

    #8072
    dragosburian
    Customer

    TypeError: “objCache is undefined”
    getObjectByNamehttp://localhost:8668/applications/RR300%20Door/visual_logic.js:107:5setObjTransformhttp://localhost:8668/applications/RR300%20Door/visual_logic.js:220:27inithttp://localhost:8668/applications/RR300%20Door/visual_logic.js:74:2loadScenehttp://localhost:8668/applications/RR300%20Door/RR300%20Door.js:80:21loadhttp://localhost:8668/applications/RR300%20Door/v3d.js:1:880351parsehttp://localhost:8668/applications/RR300%20Door/v3d.js:1:771829parsehttp://localhost:8668/applications/RR300%20Door/v3d.js:1:780683

    maybe that is not where I should place that piece of code?

    #8073
    dragosburian
    Customer

    any ideas?

    #8074

    I guess you unintentionally deleted some code from visual_logic.js. The piece that starts from
    var objCache = {};

    Chief 3D Verger | LinkedIn | Twitter

    #8075
    dragosburian
    Customer

    Just checked, it is here, not deleted. Should this code be put maybe in another function, maybe that would work?

    #8076

    Difficult to say without seeing the entire listing. May be this is a syntax error or something.

    visual_logic.js is automatically generated by Puzzles, and honestly, it is not supposed to be manually edited. I’d really recommend to use the ExternalInterface namespace in your app JavaScript to add methods that will address the code generated by Puzzles, and use the when called puzzle as described here:

    https://www.soft8soft.com/docs/manual/en/introduction/Puzzles.html#when_called_from_JS

    Chief 3D Verger | LinkedIn | Twitter

    #8078
    dragosburian
    Customer

    Ok, but will this work with external variables as in my code?

    #8079

    Yes it will work. Just pass your variables as arguments to your jscallback function and use them in Puzzles for transform.
    Foe example:
    function runCode(app) {
    app.ExternalInterface.myJSCallback(scale);
    }

    Chief 3D Verger | LinkedIn | Twitter

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.