node.jsgltfonhoverscenegraphdeck.gl

onHover not working with scenegraph in deck.gl


my code - layer

new ScenegraphLayer({
  id:"22",
  scenegraph: "glb/22.glb",
  data: dataArray.glb22,
  getPosition: d => [d.geometry.coordinates[0],
                     d.geometry.coordinates[1], 0] ,
  sizeMinPixels: 1,
  sizeMaxPixels: 10,
  getOrientation: [0, 180, 90],
  getTranslation: [0, 0, 0],
  sizeUnits: 'meters',
  onHover: this._onHover
});

onHover Code is

_onHover({x, y, object}) {
  console.log("TTTTTTTTTTTTTTTTT");
}

but not working. this code working in geojsonLayer.

how to fix my code? I want onHover working in scenegraph-layer. thanks.


Solution

  • I think you just forgot to add pickable ability. onHover required pickable properties to be true. You can read more about that here.

    Here there is an online example of ScenegraphLayer from official documentantion and here you can see the source code. Pay attention to row 116:

    const layer =
        data &&
        new ScenegraphLayer({
          id: 'scenegraph-layer',
          data,
          pickable: true,
          ...
        });