Jump to content

Babylon.js scene.registerBeforeRender collapsing


SuperPudding
 Share

Recommended Posts

Hello guys, First of all this is my first time here on the forum, but I have read some of the other posts and they've been of great help, so thanks for everyone here already.

I'm new to web developing and even newer to babylon.js so my problems may be simply caused by a lack of knowledge. Anyway, I'm trying to develop a project and I have some problems with moving the camera, I believe they are somewhere in the registerBeforeRender function.

In order to make the camera able to rotate in any direction I attached it to a parent mesh and I'm moving it instead. In my html page I have a button, which upon being pressed should make the camera move to a certain position and rotate in a certain direction. I wanted the movement to be "fluid" (the camera doesn't "jump" to said position but rather the user sees its movement), so I move it in the registerBeforeRender function, a little bit every time.

My problem is that in some cases something goes wrong and the function collapses. I'm left with a blank canvas and all the meshes dissappear.

If anyone knows why that might happen I would appreciate an adive. Sadly I can't add my code right now as it's on another computer, if it's too hard to help me without it I'll upload it here soon.

Thank you in advance.

Link to comment
Share on other sites

Update: Found the problem. It wasn't so much the registerBeforeRender function itself but rather an unhaldled exeption from a math function that was called form it. I discovered that Vector3.normalize() can set the length of the vector to a little bit more than 1. That caused a problem in the arccos function (I was trying to get the angle between two vectors).

By the way thanks for the tip RaananW, I do not know how to use the follow camera yet but it might be helpful.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...