I want to interact with my windmills(like silhouette, or highlight the node I hovered), and I tried three methods to add models,
- Model.fromGLtf()
- Cesium 3d tiles
- ModelInstanceCollection
and I found that, In the first way, I can only highlight(or silhouette) a whole model, in the second way, I can pick the component and see highligh or silhouette in the component(maybe feature?) while in the third way, It just doesn’t work at all.
this.handler.setInputAction((movement) => {
this.selected = [];
var pickedObject = this.viewer.scene.pick(movement.endPosition);
if (defined(pickedObject)) {
console.log({ pickedObject });
this.selected.push(pickedObject.primitive);
if(pickedObject instanceof Cesium3DTileFeature){
self.stage.selected = [pickedObject];
}else {
self.stage.selected = [pickedObject.primitive];
}
} else {
self.stage.selected = [];
}
});
below is the result in the first way(selecting a model):
below is the result in the third way(selecting a 3dtile):
So my puzzle is, can I pick a component(something like a ModelNode, or Cesium3DtileFeature) and highlight (or silhouette) a component in the first or the third way?
Thanks
Xiao
Hi @baoxiao,
Thank you for the detailed forum post. Some of these questions are slightly outside my CesiumJS domain of comfort, but I am going to give this my best shot As always, input from the rest of the community is welcomed!
It seems like in your first example, you were able to select an entire model, but you would like to select and highlight a ModelNode
. From what I can tell, the logic in your handler
code does not have a separate case to determine if the pickedObject
is a ModelNode
and highlight it appropriately. I recommend experimenting with adding an “else if” statement that handles this case.
You could also temporarily add a console.log(pickedObject.constructor.name)
statement to your current else case. This would help you determine if you are ever selecting a ModelNode
.
In your third example, you indicated that you were able to select 3DTile
, but you would like to select a Cesium3DTileFeature
. Are you certain that you are not already selecting a Cesium3DTileFeature? Based on your handler
code, it seems like you are updating self.stage.selected
with [pickedObject]
, where pickedObject
is a Cesium3DTileFeature.
Thanks again for your community forum post! I am looking forward to hearing back from you and am curious to get your overall thoughts.
Best,
Sam
Thank you very much , I found that I am not expressing very clearly, I wanted to figure out: "Can I pick a component(something like a ModelNode, or Cesium3DtileFeature) in ModelCollectionInstance or in Model and highlight (or silhouette) a component like picking Cesium3dTilesFeature in 3dtiles ? "
what I want is picking Like a Cesium3DtileFeature, that’s more detailed, right.
And In fact, I tried to push the pickedObject.node(which is a ModelNode class) to the self.stage.selected, It just didn’t work. I also tried pickedObject.mesh, still, doesn’t work.
Just now, I tried to log the pickedObject.constructor.name, its output is just a ‘object’, which I think doesn’t mean a lot.
Cheers
Xiao
Hi @baoxiao,
Thank you for the clarification! I also appreciate all the additional information. Can you please share a sandcastle demo that showcases what you have so far?
Best,
Sam