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.

Set material from project.js

Home Forums Programming Set material from project.js

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #31742
    jortijn
    Participant

    Hi All,

    I would like to set a material(defined in blender wood1, wood2, wood3) of an object(Cube) from the function prepareExternalInterface(app) as this gets called from my application when I change an input.

    I have an example that uses
    app.ExternalInterface.updateScene({“COLOR” : colorInputValue});
    however updateScene is not found

    I found this example
    obj.material = new v3d.MeshPhongMaterial({ color: ‘#00BB00’, emissive: ‘#550000’ });

    and that works but I want to set the material defined in Blender to an object(Cube)

    Am I on the wrong path here as I did see that I can call JS from puzzles not sure how I get the value back from the function prepareExternalInterface(app)

    Many thanks,

    Jortijn

    #31745

    Hi,

    please use the puzzle assign material, or, if you prefer programming, the code that this puzzle generates.

    Chief 3D Verger | LinkedIn | Twitter

    #31746
    jortijn
    Participant

    Hi Yuri,

    Thank you for your quick reply.

    As I get a JSON back from our application with an input value

    How do I pass this back to puzzle?

    my current function

    app.ExternalInterface.parse_selections = function (selections) {
    var colorInputValue = ( selections[‘COLOR’] != undefined ) ? selections[‘COLOR’] : ‘CHROME’ ;
    console.log(“colorInputValue” + colorInputValue);
    };

    The color selection is right as I can see it in my logger I am not sure how I can get puzzle to trigger when parse_selections function is called and to pickup the JSON in the dictionary?

    I probably should add we had something like “when called from JS as” but I can’t find that in puzzle(See attachment).

    Many thanks,

    Jortijn

    #31750
    #31751
    jortijn
    Participant

    Hi Yuri,

    Thank you! you pointed me in the right direction it works great now!

    for others(hope this is allowed)
    app.ExternalInterface.parse_selections = function (selections) {
    var colorInputValue = ( selections[‘COLOR’] != undefined ) ? selections[‘COLOR’] : ‘CHROME’ ;
    v3d.puzzles.procedures.cubeColor(colorInputValue);
    };

    and for the puzzle see the image attached.

    Kind regards,

    Jortijn

    #31760

    glad it helped! :good:

    Chief 3D Verger | LinkedIn | Twitter

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