reearth / resium

React components for 🌏 Cesium
https://resium.reearth.io
MIT License
705 stars 130 forks source link

Difference between the onClick in the viewer and the onClick in each entities? #632

Open federicomarcantognini opened 9 months ago

federicomarcantognini commented 9 months ago

I would like to get the metadata from the clicked instance, I can achieve that by either onClick as a prop on the entity and in the viewer. What is the difference and what's faster?

in the viewer: <Viewer onClick={(e, target) => { if (target?.id instanceof Entity) { // target.id is an Entity! } else if (target?.primitive instanceof Primitive) { // target.id is a Primitive! } else if (target instanceof Cesium3DTileFeature) { // target is a Cesium3DTileFeature! } }} />

in the Entity: onClick={(moment, entity) => onClick(entity.id._name, moment)}