Whats the difference between onBeforeDrawObservable and onBeforeRenderObservable

Hi everybody,

I am looking for some life-cycle hooks of the mesh that I can use for my own framework. Here, I stumbled upon the observables on BeforeDrawObservable and onBeforeRenderObservable: Mesh | Babylon.js Documentation

Can anybody tell me what is the difference? Or: what is the difference between drawing and rendering?

Thanks,
Martin

Render could be considered the whole process chain from start to end. Lights, shaders, post, updating matrices etc…

While draw is the final step of that process placing it on the screen. Draw is a part of the render.

so BeforeRender would be the entry point before the entire render process starts, and BeforeDraw would the entry point for right before the render process does its final step of placing it on the screen.

1 Like

Hi. Scene lifecycle observers is part of scene and you can find all observers in scene section Scene | Babylon.js Documentation

and read this Observables | Babylon.js Documentation

@Pryme8: thanks for the explanation. That makes sense. So I guess, onBeforeRender would be the last chance to adjust the transform matrix or any other kind of setting, before it gets rendered

@kvasss: I have seen them as well. Do you think it would make more sense to use these events for my life cycle hooks?

1 Like

I made this diagram to answer another question like that (sadly couldn’t find the question itself :pensive:) with some of the observables called during render and their order:

EDIT: Ah, found it!
Some terms about mesh api - Questions - Babylon.js (babylonjs.com)

10 Likes

Hi @Marty just checking in, do you have any further questions :slight_smile:

no, but thank you for the nice diagram. :+1: