You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm relatively new to functional programming style. I have successfully set up a simulation on the web using matter js. It works well in its current state. The simulation reaches a state when all bodies are sleeping and will never interact again.
What I want to do is determine that all bodies are sleeping and stop the engine and renderer when this occurs.
I see in #313 that there is a filter for determining if all bodies are sleeping. What is the best way to use this filter? Would it be best to attach it to one of the events? I have tried afterTick and afterRender but I'm not sure what is the best way to do this and I'm honestly a little confused about the provided events.
I also want to draw text and other shapes on the canvas after the simulation completes. The text and shapes do not need to interact with the bodies, they are only an overlay. It seems that I have to use the Runner to stop the engine before I am able to draw anything else to the canvas outside of matter. This is why I want to stop the simulation when all bodies come to rest, halt the renderer, and then draw the things I want to the canvas.
Or perhaps I am mistaken about how to draw to the canvas. Why is it that I can only draw to the canvas when I stop the renderer? I was originally working with the default Render engine. I saw your recommendation in several places that I should copy it and make modifications to it. I have done this so I can modify how the background is set up. I'd like to figure out how to successfully overlay things now and I'm very stuck.
Thanks for this awesome project. It is great work!
The text was updated successfully, but these errors were encountered:
I see in #313 that there is a filter for determining if all bodies are sleeping. What is the best way to use this filter?
Yeah you should use it in afterTick and have it call Render.stop(render) when it returns true.
Why is it that I can only draw to the canvas when I stop the renderer?
Are you drawing once or on every frame? Because the renderer clears itself before every frame even if there's nothing happening, so what ever you draw externally will get cleared unless you draw it every time in the afterRender event. Maybe that's the issue?
Thanks for the response. I was drawing before starting the renderer.
After looking into the source for the renderer I realized that it was clearing itself every frame. I ended up modifying the renderer so it would also redraw my other items after the other physics stuff. Would it be considered best practice to put this in an afterRender event?
I'm relatively new to functional programming style. I have successfully set up a simulation on the web using matter js. It works well in its current state. The simulation reaches a state when all bodies are sleeping and will never interact again.
What I want to do is determine that all bodies are sleeping and stop the engine and renderer when this occurs.
I see in #313 that there is a filter for determining if all bodies are sleeping. What is the best way to use this filter? Would it be best to attach it to one of the events? I have tried afterTick and afterRender but I'm not sure what is the best way to do this and I'm honestly a little confused about the provided events.
I also want to draw text and other shapes on the canvas after the simulation completes. The text and shapes do not need to interact with the bodies, they are only an overlay. It seems that I have to use the Runner to stop the engine before I am able to draw anything else to the canvas outside of matter. This is why I want to stop the simulation when all bodies come to rest, halt the renderer, and then draw the things I want to the canvas.
Or perhaps I am mistaken about how to draw to the canvas. Why is it that I can only draw to the canvas when I stop the renderer? I was originally working with the default Render engine. I saw your recommendation in several places that I should copy it and make modifications to it. I have done this so I can modify how the background is set up. I'd like to figure out how to successfully overlay things now and I'm very stuck.
Thanks for this awesome project. It is great work!
The text was updated successfully, but these errors were encountered: