Home › Forums › Bug Reports and Feature Requests › assignMat for second time fails?
Tagged: configurator, iframe, javascript, visual_logic
- This topic has 6 replies, 4 voices, and was last updated 2 years, 6 months ago by kdv.
-
AuthorPosts
-
2021-06-09 at 12:17 pm #41965precismoCustomer
Hi Verge!
First of all, thank you for great version 3.7! I am very happy with all new functionality!
Im trying to make custom configurator for our customers running through iframe. I tried to mimic demos simple configurator and Recliner which are doing exactly what I need. Triggering geometry through puzzle is working, however when I try to change material on some objects via assignMat in visual_logic.js it works only the first time i make this change. Any change of material for the second time fails and does not happen. Seems bit odd to me.
Relevant lines 594 in my visual_logic:
eventHTMLElem('click', 'button1', true, function(event) { listMaterials(); assignMat('Sphere', 'zlato'); assignMat('Cube2', 'zlato'); assignMat('Cube', 'zlato'); /*console.log(getObjectMaterial('Sphere')) if(getObjectMaterial('Sphere')=='zlatonormal2'){ assignMat('Sphere', 'zlato'); } else { assignMat('Sphere', 'zlatonormal2'); }*/ }); ... eventHTMLElem('click', 'button3', true, function(event) { assignMat('Sphere', 'zlatonormal2'); assignMat('Cube2', 'zlatonormal2'); assignMat('Cube', 'zlatonormal2'); listMaterials(); });
Im attaching full demo as zip – plrease refer to index.html which is nesting configurator.html in iframe.
It seems like material is not visible second time it is attached to the object: function assignMat returns on this line:
var mat = v3d.SceneUtils.getMaterialByName(appInstance, matName); if (!mat) return
This does not happen first time material is attached though.
Please can you help me resolve this issue?
2021-06-10 at 4:56 am #41975precismoCustomerAttachement was blocked, here is link to it: http://skygazer.eu/precismo/configurator/configurator.zip
2021-06-15 at 7:07 am #42040Mikhail LuzyaninStaffBecause zlato2 material exist only on the sphere and you replace it by zlato material it just not present anymore on the scene. Assign all materials to a simple invisible object that you will always keep unchanged.
Co-founder and lead graphics specialist at Soft8Soft.
2021-06-28 at 11:00 am #42347precismoCustomerUnderstand, thank you!
2022-03-10 at 9:55 am #50138precismoCustomerNote to anyone having this issue: materials are assigned to meshes in scene. Once replaced they do not exist anywhere else, thus just got deleted by garbage collector. Solution is to pick all materials manually to some array for further use.
2022-03-11 at 4:47 pm #50183AVerge3DerParticipantIf in Blender click the Fake User button.
Attachments:
You must be logged in to view attached files.2022-04-25 at 9:24 am #51346kdvParticipantIf in Blender click the Fake User button.
it doesn’t work. only hidden primitives help to save materials from being eliminated by GC )))
Puzzles and JS coding. Fast and expensive.
If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of the meaning at all.
-
AuthorPosts
- You must be logged in to reply to this topic.