0

For some reason when I'm trying to cast a ray using viewer.rayIntersect it still hits transparent objects.

Looking at the rayIntersect implementation it looks like _modelQueue.rayIntersect ignores transparent objects while avp.VBIntersector.intersectObject does not.

// ... rayIntersect implementation
var result = _modelQueue.rayIntersect(ray.origin, ray.direction, ignoreTransparent, dbIds, modelIds, intersections);

if (this.sceneAfter.children.length) {
    var raycaster = new THREE.Raycaster(ray.origin, ray.direction, this.camera.near, this.camera.far);
    var intersects = [];
    avp.VBIntersector.intersectObject(this.sceneAfter, raycaster, intersects, true);

    if (intersects.length) {
        if (!result || intersects[0].distance < result.distance) {
            result = intersects[0];
        }
    }
}

// ... rayIntersect implementation

Is there another way to cast a ray to get around this issue?

Edit:

Maybe it worth mentioning that the ray hits a Room Geometry (though invisible):

Room Geometry

The blue dot is the ray intersection point, you can see it 'floats in the air' instead of being on the floor.

I'm using version 3.1

Cœur
  • 37,241
  • 25
  • 195
  • 267
Naoric
  • 355
  • 2
  • 10
  • Seems to work on my side. That setting apply to the transparent components that are being hidden in ghost mode. From the picture you provide there is no way to tell because your blue dot is a 2D overlay so it would look exactly the same if it was on the floor... Can you provide a sample rvt document? You could also test in v 3.3, there should be no breaking changes between this version and 3.1. Thanks – Felipe Jan 09 '18 at 02:06
  • @PhilippeLeefsma It is an overlay, I'm using a ray to determine its position and then on camera movement I translate it (`worldToClient`) back its 2D position. You can see the problem more clearly here: https://framapic.org/0Nxvrgsnyo9B/Kt6Gd2cnjHyf.gif `modelQueue.rayIntersect` returns a point on the floor with the correct node while `VBIntersector` returns the point above... I'm uploading the model and will share soon. Thank you for the quick reply! – Naoric Jan 09 '18 at 08:15
  • VBIntersector is not a public API object, so you shouldn't use it. Since rayIntersect returns the correct result, can you clarify what is the problem? – Felipe Jan 09 '18 at 08:39
  • I am not using `VBIntersector`, I'm using `viewer.clientToWorld` method that calls to `model.rayIntersect`, *the code above is not my code* it is the viewer's implementation of `model.rayIntersect`. While trying to understand why I get the "roof" intersection point, I debugged the code above and found that internally there are two implementations (probably for specific situations) that returns different results. I was trying to make the question more specific, sorry for the misunderstanding. – Naoric Jan 09 '18 at 10:15
  • @PhilippeLeefsma Here's the model: https://drive.google.com/file/d/17uxop_0OXcG88SdB1WDqbB70F0NI9Je9/view?usp=sharing – Naoric Jan 09 '18 at 11:28
  • Works fine on my side, here is a recording of one of my latest sample against your model, which is using clientToWorld, you can see that I'm toggling visibility of the roof elements and it successfully select the floor to attach markups: https://www.screencast.com/t/tGXCELZmeBd6. You can find more details about that sample in that article: http://autode.sk/2D2irk8 – Felipe Jan 11 '18 at 06:42

0 Answers0