Light Posted April 25, 2016 Share Posted April 25, 2016 Good day. I'm working in small proyect using babylon.js, it's so great, but im having some troubles. 1) How do i detect if im looking directly to an object? I try to search for options and found on playground a solution to make a line from camera and detect a collition with line and object. But its not the best solution can you help me with this? And not working well sometimes, because of VR camera distortion. And line have alpha at 1 but i still can see it. lines = BABYLON.Mesh.CreateLines("lineMesh", [ new BABYLON.Vector3(0, 0, 0), new BABYLON.Vector3(0, 0, 3000) ], scene); lines.material.alpha = 1; lines.parent = camera; sphere = BABYLON.Mesh.CreateSphere("sphere1", 16, 100, scene); sphere.position=new BABYLON.Vector3(300,-400,-500); if(lines.intersectsMesh(sphere, true)){ console.log("you found me"); } 2) I have an object flying slowly around me sometimes when it on top of me or below me in Y=0, it disappears or start to flashing if im looking at it until its not around Y=0. 3) I'm using VRDeviceOrientationFreeCamera if I have distortion at 0 it's OK but if I change it, it's bacame too laggie. Is there any solution? Thanks for all possible help. Sorry for my bad English. Quote Link to comment Share on other sites More sharing options...
RaananW Posted April 26, 2016 Share Posted April 26, 2016 Hi Light, you could use the scene.pickWithRay function for that. It fires the predefined ray (in your case a ray in the camera's direction) and checks if it collides against the meshes define din the predicate. It returns a PickingInfo object that contains all the info you need about the collision point. You can see how it works in this cool example (that is not made by me! I just found it) - http://www.babylonjs-playground.com/#1BAPRM#68 Quote Link to comment Share on other sites More sharing options...
Light Posted April 26, 2016 Author Share Posted April 26, 2016 Thanks for response. I will try to implement this in my project. Still have no idea what to do with the flickering sometimes, not sure why it's happening. 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.