Home › Forums › General Questions › getMaterialByName not working.
- This topic has 4 replies, 3 voices, and was last updated 4 years, 1 month ago by GLiFTeK.
-
AuthorPosts
-
2020-09-29 at 2:17 pm #33567GLiFTeKCustomer
Hi,
I’ve got a var of an object by getObjectByName.
ie:app.scene.getObjectByName(meshName);
works great.now to get the material in it, “metal”..
i have tobe all fancy and do this trick?…
var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'materialName');
but it does not work and says that material is undefined.
where in the documents can i find info about this and why’s it not working?
thanks!
Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-09-30 at 7:33 am #33601Yuri KovelenovStaff2020-09-30 at 10:21 pm #33650GLiFTeKCustomerI’m trying to do it where WHATEVER the material from the object is named.. it can still dynamically get it from the object.. whatever object.
here is what i have..
(the cubes’s material name is “metal”.)
and here is my console readout…
material: visual_logic.js:477:13 metal visual_logic.js:478:13 mesh before script: visual_logic.js:480:13 Cube visual_logic.js:481:13 meshName: Cube visual_logic.js line 507 > Function:4:9 mesh after script: visual_logic.js:513:13 Object { uuid: "7E17F35D-5682-401F-9A60-BF011A861DB7", name: "Cube", type: "Mesh", parent: {…}, children: [], up: {…}, position: {…}, rotation: {…}, quaternion: {…}, scale: {…}, … } visual_logic.js:514:13 material before script: visual_logic.js:516:13 metal visual_logic.js:517:13 materialName: metal visual_logic.js line 519 > Function:4:9 material after script: visual_logic.js:526:13 null
this is being done because in the clipping planes script, you have to change a lot about the materials, and i like keeping materials that i’ve made in blender that have a lot of unique nodes etc. (this example is simple metal)
is this problem happening because i’m asking it about a variable value which is just a text name? how can i extract the material (whatever material) should i skip the get material puzzle and combine that’s code with the script code?
thanks!
Attachments:
You must be logged in to view attached files.Visit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature!2020-10-01 at 8:39 am #33662Ivan LyubovnikovStaffIn the second exec script puzzle it should be:
var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], materialName);
instead of:
var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'materialName');
Co-founder and lead developer at Soft8Soft.
2020-10-01 at 8:44 pm #33706GLiFTeKCustomerO gosh.
Silly me.
Thanks IvanVisit the GLIFTEK Verge3D Plugins Store!
GLIFTEK.com for Plugin Documentation & LIVE DEMOS!
LIKE The GLIFTEK Facebook Page for updates!
Join the Verge 3D Discord Server!
plz share Discord link & on your signature! -
AuthorPosts
- You must be logged in to reply to this topic.