Home › Forums › Programming › How to execute self defined functions at any frame?
- This topic has 5 replies, 2 voices, and was last updated 4 years, 1 month ago by GLiFTeK.
-
AuthorPosts
-
2020-10-23 at 11:57 pm #34536derekwang0605Customer
Suppose I define a function
function changeColor(){
assignMat([‘GROUP’, mygroupName], myMat);
setMaterialColor(myMat, ’emissive’, math.random(), 0.5, 0.5, ”);
}
How to execute this funtion at frame 10/20/30?2020-10-24 at 4:07 am #34539GLiFTeKCustomerDo you mean frames of an animation or frames of your project’s fps? (24/30/60fps etc)?
For the latter, you could use the delta puzzle in the time category of the puzzles menu.
For animation frames there’s the “get animation frame” puzzle
(Accompanied by a play animation puzzle preceeding it of course)You’d want that wrapped in an if logic puzzle, where a variable representing the the current gotten frame equaling the desired frame is met.
I’m pretty sure that’s how it would work. On mobile now, haven’t tested it.
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-24 at 4:46 am #34542derekwang0605CustomerThank you for the help! It helps a lot! I mean the frames of myproject’s fps. I did not import any animation on the objects. For the latter, I used ‘after 1 seconds do’ puzzle like below as a nested loop:
registerSetTimeout(1, function() {
changeVis(‘Cube.001’, true);
registerSetTimeout(1, function() {
changeVis(‘Cube’, true);
});
});But I have a parent group list including 30 subgroups name and I want to settimeout 1 second for each subgroup to show. How to write a loop to implement these nested loops? Otherwise, there will be too many repetitive code lines.
2020-10-24 at 6:13 pm #34558GLiFTeKCustomerI don’t know if you’re using any puzzles, but You can also use the “time” puzzle do after
And put “0” frames in the field.
0 will mean the “next” immediate frame.Or put after puzzle 10/20/30 in a loop inside an if statement if needed.
Or see if the code that is created from all that is able to be used in your code (found in visual_logic.js)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-24 at 8:08 pm #34560derekwang0605CustomerThanks a lot! It worked very well by using the puzzle do after. I followed your way by putting 0, everything worked ok.
2020-10-24 at 10:45 pm #34562GLiFTeKCustomerAwesome.
Yeah Yuri mentioned that lil technique awhile back.
Very good secret
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! -
AuthorPosts
- You must be logged in to reply to this topic.