Search the Community
Showing results for tags 'ray'.
-
I'm able to pick sprites with Scene.pickSprite, but is there a way to pick them with scene.pickWithRay? PickWithRay only seems to return meshes (I've set isPickable to true on the sprites and confirmed that they're pickable with Scene.pickSprite). The use-case is, I'm trying to pick sprites with a 3DoF VR Controller, so I don't have a 2d pointerX and pointerY to work with, only the controller's forward ray. I'm thinking that my options are: a. Use Vector3.Project to try to unproject the pickedPoint of pickWithRay (I'm using a skybox, so the ray will always hit something), then put that point into Scene.pickSprite. I tried this quickly, but I think the unprojected point might be off b. replace the sprites with billboarded mesh instances that can directly be hit with pickWithRay. I suspect this might be the easiest option? Or is there some easier way to pick a sprite with a ray?
-
I'm able to get RayHelper working to an extent in the sense that I can only see the ray at certain angles to my mesh that the ray is attached to. Is this a known issue? Thanks all!
-
Hey everyone. I'm having a bit of trouble figuring out ray casting when the camera's parent is set to a mesh. I exhausted Google search and I'm hoping someone as some insight. Here's the scoop. I have a car that drives around a scene. I also have a FreeCamera that's parent is set to the car. The camera's position is set just above the car so you can see the front of it. (As if you placed a GoPro on the roof). I want the user to be able to rotate the camera in all directions to see around the car as it is driving (you can look out the back side as the vehicle drives forward). The rotation of the camera does not set the direction of the car. I am using scene.pickWithRay() with a reticle in the center of the camera. Everything works great when driving forward, until the car rotates it's direction. Then my ray is offset by that rotation. I'm not sure how to correct the offset when defining the ray. Here is how I'm currently defining the ray within my render loop... var ray = new BABYLON.Ray(camera.position.add(camera.parent.getAbsolutePosition()), camera.getTarget().subtract(camera.position).normalize()); Any ideas would be greatly appreciated. Thanks so much!
- 4 replies
-
- ray casting
- ray
-
(and 1 more)
Tagged with:
-
I'm trying to attach the ray I put in my scene to my active camera so I can move around the camera and have the ray hit whatever my camera is looking at. I've been able to get the ray into my scene, and have it hit something, but haven't been able to figure out how to attach it to my camera so it follows it. My best attempt was trying to create a box, attach it my camera as it's parent and then attach the ray to that box using rayhelper.attachtomesh but my ray is no longer visible when doing this. Any help please.
- 5 replies
-
- ray
- ray casting
-
(and 1 more)
Tagged with:
-
This is out of my Math skill set at the moment. I am casting rays from on an event. I want to draw a plane along the ray.
-
I've got a properly defined BABYLON.Ray with an origin, a rotation, and a length. How do I get the "destination" of the Ray? Thank you much! Mike
-
Hey guys, I am currently working on a litte project but I need to have a way to check if between two different Meshes theres another one. The current Situation is, that the Ray ignores Walls and just goes through them and so I get meshes which are behind obstacles. For an example: I want to make some kind of this: http://babylonjs-playground.com/#1QF77H#2 --- Important here is, that the waypoints in my Code are imported by Blender and are saved in an Array (TP), if this maks any difference... The problem is, I cannot transfer this into my code, and I since now I invested about 2 hours of testing an rewriting things but I always get far too many points.Maybe the problem is the if-statement in line 12 (screen). I really hope you guys can help me Shakes EDIT: Sorry for all grammar and/or other mistakes :/
- 4 replies
-
- getboundinginfo
- intersectsbox
-
(and 2 more)
Tagged with:
-
Hey, it's me and my bloody Rays again! I went through a bunch of Babylon's classes, but just can't wrap my head around World vs Local vs BoundingBoxes vs Rays. It looks like PickWithRay (and Mesh.intersects(Ray)) only work if meshes' positions are not changed! Here's the PG: http://www.babylonjs-playground.com/#1C86DD Line 40 returns "true" even though the target mesh is outside Ray's path. It just hurts my brain!
- 18 replies
-
- collisions
- ray
-
(and 1 more)
Tagged with:
-
Ahoy! For those of us who played games quite a bit (most of us, no doubt), we've seen plenty of (chain) lightning effects (example screenshot in the spoilers). Now, even though I've seen such effects plenty of times, I wouldn't know where to start to make such a thing. My question is: how would something like this be accomplished in PixiJS? I'd prefer a way without having to rely on WebGL, if at all possible, though, but WebGL-specific answers are welcome too, of course. Example screenshot (P.s. sorry if this image is hogging someone's bandwidth... I could not find a spoiler tag or something similar) -MikauSchekzen
-
Hi, Another head scratcher for me: I'm trying to cast rays to detect if an a object (A) is in "view" of another object (B). B has got lookAt(A) attached to it, so this is how I'm constructing the ray: var ray = new BABYLON.Ray(this.mesh.position, this.mesh.rotationQuaternion.toEulerAngles().normalize()); It's not working, so what am I doing wrong?
-
Hello everybody, I have two requests for features. I would like to know if these were possible? 1. Hidden lines view Would there be any possibility to create something like this: So like defining a view point and create a flat image with only the edges visible (The faces, not the triangles) ? Best for me would be a list of polygons and their points but a static image would be great either. 2. Create shadow map (and more?) with a raytracer In our application we have a static scene most of the time. It may change every 10 seconds (if the user wants so) and the recalculation time is not a problem (could be 3+ seconds for example). So for this case the best possible quality is more important than the fastest calculation. I don't think I would be the only one who needs some like these features. Thanks and have a great day! Kevin
-
Hi evevryone, to describe want i want to archive i have found this example: http://www.babylonjs-playground.com/#10VR41#11 I want to create something very similar, but: 1) I would like to know if there is a way to do it without animation 2) Cast Ray at picked (with length from source to picked destination) point to check collision Once i hove found a good example, but cant it find anymore, there was an android robot that were launching rays at mouse picked position 3) How could i perform this actions even if for example: left mouse button is pressed (i would like to perform this action even on continuous press)
-
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.
-
I am currently building the AI for some baddies in a simple video game I'm making. The levels are mostly horizontal with some floating platforms here and there. Using `enemy.state` as an attribute to keep track of what the enemy is doing and by tracking the x and y distances between the player and the baddies, I am able to create a semi-working AI system. But there are still glitches. For example: if the baddie is on a hovering platform and the player is directly below that platform, the baddies doesn't know to walk off the platform to get to the player. Are there ways to create "rays", like with Unity? Essentially, a "ray" is an orb that surrounds the object and detects its relation to other things around it. This way the object can navigate levels in a human-like way. Anything along those lines, or any AI tips and techniques/tutorials would be greatly appreciated!
- 1 reply
-
- artificial
- intelligence
-
(and 5 more)
Tagged with:
-
Howdy, http://www.babylonjs-playground.com/#11DXRI This is the main problem from the other thread about moving with collisions. Ray casting just doesn't seem to work right as soon as the mesh is scaled (along the y axis?). This really seems like a bug to me ... or I am doing something horribly wrong here :-/ Can that be fixed somehow?
- 8 replies
-
- ray
- pickWithRay
-
(and 1 more)
Tagged with:
-
Hello guys, I'm doing an app to control objects via a Kinect sensor. I finally managed to control two hands (they are just images) on the screen, and the next step is to be able to put a Hand in front of a sphere and allow this sphere to follow the position of the hand. My hand is just an Image on the screen I move it by changing his left and top css properties, and my problem is how to know when my hand "touched" the sphere. I've tried with BABYLON.Ray(hand.x,hand.y) but it's like the ray is pointing somewhere I don't know, and the "touch" occurs somewhere far from the sphere. Any ideas ? Thank you in advance.
- 2 replies
-
- projection
- ray
-
(and 1 more)
Tagged with:
-
Hello, I'm loading my scene from Blender, containing a simple plane (acting as ground), a camera and a light. I put a sphere (diam 1) on my ground and a ray with origin the center of the sphere and the vector direction (0,-1,0) When I move the sphere on this ground (say on the z axis only for example) , I check the altitude of the ground with scene.pickWithRay using the predicate to exclude my sphere. This works. But, when my sphere comes at the middle of the ground(for example), I clone this ground, change its id and set its position (z axis) at the end of the last ground (to fake an "infinite road"). My problem is that when my sphere comes on the second ground, the method scene.pickWithRay does not hit anything ..;o(( When I used the method Mesh.intersects(Ray), I had to express the ray in the world of the Mesh I wanted to test against. But I think I read in the forum that scene.pickWithRay does not require to make this transformation. Does the problem comes from the fact that I clone the "ground mesh" and set its position via mesh.position ?? Thanks for your help !