The question about gamma rays

This is the code I modified for an official example. When the ray detects a grid in front, it will give the location to a new grid. Continue to look for it until it is empty.

Now there are two problems, that is, if I have to set the length of ray, because when my length is small, he will always be detected box2, when I set the length to 50 or more, the rays through the model, so he will be in accordance with the written inside my judgment, to get to the location of the grid to pick up the current position of the ray, I don’t know why this is, another reason is that, as you see from the picture, he would emit two ray, I don’t know what reason is this, there is a ray has been down to launch, will continue to test my terrain, I don’t need,I just want one ray emission, so how do I do that

1 Like

I have no idea what you are trying to ask?

1 Like

Isolate the error. Too many concepts simultaneous. Focus on proving one at at time. : )

Sometimes when extending the Ray Length, It can pick up two collisions. And that can be unexpected - make sure you are looking at the right collision when calculating position (a guess).

Emitting a second ray? Put a debugger or a console.log on your ray creation code and look to see it is initialized correctly. You will probably see how it isnt. : )

Two rays for two collisions…?


1 Like

You can see my PG, one of my rays is up, but the one below the ground, I don’t know where it came from,

Which browser do you use? On Chrome is only one ray:


You see, mine looks like this, and when you open up the scene, the first time it looks like it’s just going to show one line, you reruns it, or you change the position of the ray, and that’s it

ok. I understand.

I think there is something wrong with the ground-element (or it reflects the ray. there should be a parameter for the ground-element not to consider ray reflections.).
When this line is commented : // var ground = BABYLON.Mesh.CreateGround
you’ll get only one ray as desired.

So I can’t create terrain

It is because the 1st ray call vecToLocal and relies on a matrix which has not yet been computed.

You should either let a frame before or force the computation of the matrix when creating the box:

1 Like