Jump to content

Arc Camera


lakhi
 Share

Recommended Posts

22 minutes ago, Deltakosh said:

Here is a code which set the camera up like you want:

https://www.babylonjs-playground.com/#HT80JV

Hi not actually up but in my case i am trying to put the camera perpendicularly so that in the screenshot below the line points from cue ball to group of balls. I have tried your code but its still in same position. the codes that i wrote for the camera is this

 

 var camera = new BABYLON.ArcRotateCamera("camera1", Math.PI / 2, 0, 10,new BABYLON.Vector3(0, 0, 0), scene);
 camera.setPosition(new BABYLON.Vector3(0, 0, -100));

download (1).png

Link to comment
Share on other sites

Have you tried the ArcFollowCamera http://doc.babylonjs.com/classes/2.5/arcfollowcamera ?  Or is it that you want to limit the rotation of the user, which you can do with alpha/beta upper and lower limits.  You can set the ArcRotateCamera target to any vector3 (http://doc.babylonjs.com/classes/2.5/arcrotatecamera).  Not sure exactly what you are asking.

Link to comment
Share on other sites

ok let me try again

the pool board that you see in the screenshot i got that from google and it was built in google o3d and basically its a 3d table.

originally in x,y axis the view of the table on first load is portrait but to make it look good i have changed it to 2d like view and turned off the 3d movements.

now i am trying to use babylon to create the line from cue but issue is its direction is x,y so i am just curious to find if the camera view can be rotated to 90 deg so that y axis become x and x axis become y.

sorry if my question is wrong i am trying to learn this technology

 

Link to comment
Share on other sites

ok cool yes i was able to fix the issue but i have a new issue now.

can you pls see the screenshot?

https://www.diigo.com/item/image/5pfye/v1mb

i am trying to make it so that the 2nd point from cue ball changes on mouse move.

my mouse pointer is on the red dot but the second point is not on the red dot and line goes too far from the pointer.

here is my full code

 

this.angleCue = function(){
            canvas = document.createElement('canvas');
            canvas.width = g_client.width;
            canvas.height = g_client.height;
            canvas.setAttribute("id", "canvasID");
            $('#o3d').append(canvas);
            engine = new BABYLON.Engine(canvas, true);
            scene = new BABYLON.Scene(engine);
            scene.clearColor = new BABYLON.Color4( 0, 0, 0, 0.1);
            var camera = new BABYLON.ArcRotateCamera("camera1", 0, 0, 0,new BABYLON.Vector3(0, 0, 0), scene);
            camera.setPosition(new BABYLON.Vector3(0, 0, -100));
            camera.attachControl(canvas, false);
            var pl = new BABYLON.PointLight("pl", new BABYLON.Vector3(0, 0, 0), scene);
            pl.diffuse = new BABYLON.Color3(1, 1, 1);
            pl.specular = new BABYLON.Color3(1, 0, 0);
            pl.intensity = 0.95;
            var path = [];
            var cue = g_physics.balls[0];
            var cue2 = g_physics.balls[8];
            path.push(new BABYLON.Vector3(cue.center[1],cue.center[0],0));
            path.push(new BABYLON.Vector3(cue2.center[1],cue2.center[0],0));
              mesh = BABYLON.Mesh.CreateLines("lines", path, scene, true);
            scene.render();
  };
  this.angleUpdate = function(x,y){
  var cue = g_physics.balls[0];
  var lastx = x-g_client.width/2;
    var lasty = y-g_client.height/2;
  var path = [];
    path.push(new BABYLON.Vector3(cue.center[1],cue.center[0],0));
    path.push(new BABYLON.Vector3(lasty, lastx, 0));
    mesh = BABYLON.Mesh.CreateLines(null, path, null, null, mesh);
    scene.render();
  };

 

can you please check this for me? angleUpdate function runs on mouse move

i know i am writing codes like a child :D sorry for disturbing you again and again

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...