I am getting to know Babylon by creating a simple scene with some objects. I wanted to have an arrow that points to a specific object. I copied the code for that from here and it worked perfectly: https://playground.babylonjs.com/#6LFX67#5
Now, I wanted to clean up createScene() a bit by extracting the code to create the arrow and the code inside scene.onBeforeRenderObservable.add() to separate methods outside of createScene(). See https://playground.babylonjs.com/#6LFX67#11 for how that looks. The problem with that is that I need to pass camera, arrow and position to the callback function in scene.onBeforeRenderObservable.add(), so like this:
cameraRotation(camera, arrow, contentPosition)
);
The problem is that that executes the function right there and then, so only once. If I pass test, a function without parameters, everything works as expected.
I’m sure there’s a simple solution for this that I don’t know.