Bitbybit Docs
    Preparing search index...

    Class BabylonPick

    Finding what is under a ray or the pointer: a pick shoots a ray into the scene and reports the first pickable mesh it hits, where, how far away and on which face. pickWithPickingRay uses the pointer's current position; the other methods read parts of a picking result.

    Index

    Constructors

    get from pick info

    • Reads how far along the ray the hit was, in scene units; meaningful only when hit is true.

      Parameters

      Returns number

      The distance to the hit

    • Reads the mesh a pick hit; meaningful only when hit is true.

      Parameters

      Returns AbstractMesh

      The mesh that was hit

    • Reads the point in the scene where a pick hit the mesh; meaningful only when hit is true.

      Parameters

      Returns Point3

      The hit point

    • Tells whether a pick hit anything at all; check it before reading the mesh, point or distance.

      Parameters

      Returns boolean

      True when something was hit

    • Reads the index of the sub-mesh that was hit, for meshes split into several material sections.

      Parameters

      Returns number

      The sub-mesh index

    • Reads the index of the triangle that was hit within its sub-mesh.

      Parameters

      Returns number

      The face index

    • Reads the first barycentric coordinate of the hit inside its triangle, the weight of the triangle's second vertex, used to work out texture coordinates.

      Parameters

      Returns number

      The barycentric U coordinate

    • Reads the second barycentric coordinate of the hit inside its triangle, the weight of the triangle's third vertex, used to work out texture coordinates.

      Parameters

      Returns number

      The barycentric V coordinate

    • Reads the sprite a pick hit, when sprites rather than meshes were picked.

      Parameters

      Returns Sprite

      The sprite that was hit

    pick

    • Shoots a ray into the scene and reports the first pickable mesh it hits, with the hit point and distance; read the parts with the other methods here.

      Parameters

      Returns PickingInfo

      The picking result

      const ray = bitbybit.babylon.ray.createRay({ origin: [0, 10, 0], direction: [0, -1, 0], length: 100 });
      const pick = bitbybit.babylon.pick.pickWithRay({ ray });
      const hit = bitbybit.babylon.pick.hit({ pickInfo: pick });
    • Shoots a ray from the active camera through the pointer's current position and reports the first pickable mesh it hits, the way a click selects.

      Returns PickingInfo

      The picking result

      bitbybit.babylon.scene.onPointerDown({ statement_update: () => {
      const pick = bitbybit.babylon.pick.pickWithPickingRay();
      if (bitbybit.babylon.pick.hit({ pickInfo: pick })) {
      console.log(bitbybit.babylon.pick.getPickedPoint({ pickInfo: pick }));
      }
      } });