Need help with raycast, the array is empty

I want to do raycasting but the pickableShapes is empty

C1.prototype.doRayCast = function (screenPosition) {
    // Initialise the ray and work out the direction of the ray from the a screen position, screenPosition.y,, this.ray.direction); 

    // Test the ray against all the objects registered to this picker
    for (var i = 0; i < this.pickableShapes.length; ++i) {
        var pickableShape = this.pickableShapes[i];
        var result = pickableShape.intersectsRay(this.ray, this.hitPosition);


Hi @grzesiekmq,

If you are trying to use the Entity Picking without physics example, then you have to get all the relevant code from the shape-picker.js script.

The pickableShapes array is indeed empty on its own, you will have to fill it with the shapes that will be tested for picking.

Check the code/sample from the tutorials page on how to do that:

1 Like

Iā€™m looking for solution similar to entity picking but do the raycasting in the model to look for the MeshInstance when the ray is intersected

You will have to extend the example above to create one shape for each mesh instance, then it will work.

1 Like