Cannot pickPoint from the vertexData of this below

Hallo All,
i am creating a customScene by adding vertexData and adding it on a mesh…

after this, I like to pick the position of each vertex from this below scene and measure distance between the two points.

https://www.babylonjs-playground.com/#2S8L5U#35

Now using the above scene code, if I do this,
var vertexData = new BABYLON.VertexData();

    //calculate spiral conditions
    var finalAngle = 3.7 * Math.PI;
    var b = 0.23;
    var a = [];
    var l = rabbitPositions.length / 3;

    var colors = new Array(4 * l);
        colors = colors.fill(0).map((x) => {
        return Math.random();
    })

    //Create a custom mesh  
    var customMesh = new BABYLON.Mesh("custom", scene);

    //Assign positions
    vertexData.positions = rabbitPositions;
    vertexData.colors = colors;

    //Apply vertexData to custom mesh
    vertexData.applyToMesh(customMesh, true);

    var mat = new BABYLON.StandardMaterial("mat", scene);
    mat.emissiveColor = new BABYLON.Color3(1, 1, 1);
    //mat.disableLighting = true;
    mat.pointsCloud = true;
    mat.pointSize = 1;

    customMesh.material = mat;

        scene.onPointerDown = function (evt, pickResult) {
        if(evt.button != 0){
            return;
        }
        //left mouse click
        //pickedPoint the point you have clicked, transformed in 3D coordinates, depending on the object you’ve clicked. Null if no hit.
        if(evt.button == 0){
       console.log(pickResult);

}
this is what i get
e {_pickingUnavailable: false, hit: false, distance: 0, pickedPoint: null, pickedMesh: null, …}
bu: 0
bv: 0
distance: 0
faceId: -1
hit: false
originMesh: null
pickedMesh: null
pickedPoint: null
pickedSprite: null
ray: e {origin: e, direction: e, length: 1.7976931348623157e+308}
subMeshId: 0
_pickingUnavailable: false
proto: Object

instead of this pickingInfo : I want something like this below.
e {_pickingUnavailable: false, hit: true, distance: 23.237776793180558, pickedPoint: e, pickedMesh: t, …}
bu: 0.6707718003466827
bv: 0.19974599139453608
distance: 23.237776793180558
faceId: 9
hit: true
originMesh: null
pickedMesh: t {state: “”, metadata: null, reservedDataStore: null, _doNotSerialize: false, _isDisposed: false, …}
pickedPoint: e {x: -6.282334272636481, y: 2.600000000000005, z: -0.15226620307875116}
pickedSprite: null
ray: e {origin: e, direction: e, length: 1.7976931348623157e+308}
subMeshId: 0
_pickingUnavailable: false
proto: Object

Hey, do you mind sharing the repro which highlight the issue? I picked in your PG and I see there are hits so there must be something I not doing correctly to get the same issue as you

1 Like

Thank you for the response, i am trying to get distance between two pickedPoints. hit is not an issue in this playground i created, but i am not sure if we can use this to get distance.

can you share your code or playground with https://www.babylonjs-playground.com/#2S8L5U#35 that does the pickedPoint: {object hit}

When i used this above playground, i get pickedMesh as below not pickPoint… Can i used this to get the point x,y, z coordinates.

  1. bu: 0
  2. bv: 0
  3. distance: 193.08978515281527
  4. faceId: -1
  5. hit: true
  6. originMesh: null
  7. pickedMesh: t {state: “”, metadata: null, reservedDataStore: null, _doNotSerialize: false, _isDisposed: false, …}
  8. pickedPoint: null
  9. pickedSprite: null
  10. ray: e {origin: e, direction: e, length: 1.7976931348623157e+308}
  11. subMeshFaceId: -1
  12. subMeshId: -1
  13. thinInstanceIndex: -1
  14. _pickingUnavailable: false

ok gotcha! The mesh has no face so no pickedpoint per se
But you have the distance so the point is ray.origin + distance :slight_smile: