Home › Forums › Programming › Set material from project.js
- This topic has 5 replies, 2 voices, and was last updated 5 years, 2 months ago by
Yuri Kovelenov.
-
AuthorPosts
-
2020-08-19 at 3:56 pm #31742
jortijn
ParticipantHi 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 foundI 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
2020-08-19 at 4:29 pm #31745
Yuri KovelenovStaff2020-08-19 at 4:40 pm #31746jortijn
ParticipantHi 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
2020-08-19 at 4:57 pm #31750
Yuri KovelenovStaffYou can trigger puzzles from JS as shown here:
2020-08-19 at 5:37 pm #31751jortijn
ParticipantHi 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
2020-08-20 at 5:46 am #31760
Yuri KovelenovStaff -
AuthorPosts
- You must be logged in to reply to this topic.
