ua4192 Posted June 22, 2017 Share Posted June 22, 2017 Hi again. I am not sure if this is the correct section for reporting this problem, sorry if not. I have prepared this PG: http://www.babylonjs-playground.com/#2JBSNA#20 What I was trying to do was to set the basic views ( 6 face views from the Bounding Box of the selected mesh in the scene ) The idea was quite simple, but there are 2 views that are failing and the problem is very strange. My feeling is that there is something wrong in the camera.setPosition function with the provided numbers. Have a look into the function set_camera() and you will see. Just try to change the lines 73 and 74 to switch between different camera positions (camera_p1, camera_p2, ... , camera_p6) camera_p1: ok camera_p2: ok camera_p3: ko (problem in setting camera position, X and Z are not recognized as numbers) camera_p4: ko (problem in setting camera position, X and Z are not recognized as numbers) camera_p5: ok camera_p6: ok Yesterday I was trying to find the problem but I was not able to. This is driving me crazy!!! Best regards and many thanks as usual for you support. This portal is the best!!!! Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 22, 2017 Author Share Posted June 22, 2017 Hi again. A better example with logs to be analyzed: http://www.babylonjs-playground.com/#2JBSNA#27 Just change the line 87 to switch between different views, not working ones, 3 and 4. Best regards Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 22, 2017 Author Share Posted June 22, 2017 Hi again. Finally I got it. It seems that when I set the target using center coordinates it soen't work. If you want to see my solution: http://www.babylonjs-playground.com/#2JBSNA#30 Best regards Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 22, 2017 Share Posted June 22, 2017 Well done And no it was not the good section so I moved you to questions. Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 22, 2017 Author Share Posted June 22, 2017 Hi again. I am sorry but there is a bug in camera.setPosition. Sometimes the numbers you pass through the vector3 are not properly recognized by the command. My first supposition was good. Could you have a look into the babylon.jscode? By noi I have resolved by adding a small value to the value (0.000000001) but this is not good. Best regards Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 22, 2017 Share Posted June 22, 2017 Quote Could you have a look into the babylon.jscode? Lol Can you please repro the issue in the PG? Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 22, 2017 Author Share Posted June 22, 2017 Sure. Here you can see: http://www.babylonjs-playground.com/#2JBSNA#34 Try to set manually camera position to 5.046899795532227,-162.91392005903518, 70.27924661865235 and you will see that it doesn't work camera position (X and Y) are detedted as NaN Try to uncomment line 68 and comment 67. You will see. To switch between views coment again 68 and uncomment 67. and change lines 74 and 75. For views p1, p2, p4, p5 and p6 it works but it is random. Best regards Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 23, 2017 Share Posted June 23, 2017 Taking out the comment on line 23 gives you the views you want http://www.babylonjs-playground.com/#2JBSNA#37 However if you just want to see the skull's top, front, left, right, back and bottom it is much simpler to use the camera's alpha and beta values http://www.babylonjs-playground.com/#FZJRWJ GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 24, 2017 Author Share Posted June 24, 2017 Hi. Many thanks by the PG. I will use camera in this way, much more elegant. But why sometimes numbers are not prerly recognized to set the camera position? CAn you exaplin the bahaviour I faced in my example? I continue not understanding where was my problem. Best regards Quote Link to comment Share on other sites More sharing options...
JohnK Posted June 24, 2017 Share Posted June 24, 2017 2 hours ago, ua4192 said: CAn you exaplin the bahaviour I faced in my example? I will give it go. When you set the camera target new values for alpha and beta are calculated. Alpha is calculated from x and z values using trigonometry, by using the initial settings for position and target with x and z values equal then alpha is calculate from 0/0 which is indeterminate and gives a null result so the mesh cannot be displayed. When you set an initial target with x and z not the same as the x and z positions then an alpha can be calculated and because of the way the code is ordered, setting a new position with x and z the same as x and z in the target still allows alpha to be calculated. Hence setting camera.target = model first stops the problem with your camera setting. However it would still be possible to give the camera positions where the x and z values were the same as the current target position. It would always be possible to check for this and adjust as necessary. IMHO it is not possible to do this automatically in the BJS code because although you could avoid it by changing the x and z values slightly but would not know whether the users intention was to adjust x or z singularly or together or positively or negatively. Quote Link to comment Share on other sites More sharing options...
ua4192 Posted June 25, 2017 Author Share Posted June 25, 2017 Hi. Now I understand the problem. Many thanks for the explanation. Best regards Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.