How to calculate boundingbox of entity?

665 views
Skip to first unread message

long...@gmail.com

unread,
Jun 6, 2019, 5:36:39 AM6/6/19
to cesium-dev
Dear all,
I want to draw a box around an object when it has picked on map. But I don't know how to calculate bounding box of this object. I think we should have some calculation from model matrix. Does anyone have any suggestion for this task?
Thank all.

Omar Shehata

unread,
Jun 12, 2019, 2:23:34 PM6/12/19
to cesium-dev
The model matrix mostly describes the position, orientation and scale applied to a model or entity, not necessarily the dimensions of the geometry itself. What kind of entity is it? I think there's different ways to do this depending on what kind of geometry type it is, or if it's a billboard etc.

Although, taking another look, it looks like there does exist a private function DataSourceDisplay.getBoundingSphere that can compute this for any given entity. This is what the viewer uses to figure out how to fly to/zoom to an entity. You can look at the code for it to see how it does it, or try to call it directly.

Let me know if you figure out a good way to do this!

Pham Long

unread,
Jun 13, 2019, 4:36:40 AM6/13/19
to cesiu...@googlegroups.com
Entity in my question is billboard, polyline, polygon, 3D model. I try to enable boundingsphere of billboard but it's look to large. Could you give me some examples how to use  DataSourceDisplay.getBoundingSphere? Thank for your support.
This image show what i want to do.
BBox_Geode.png

Vào Th 5, 13 thg 6, 2019 vào lúc 01:23 Omar Shehata <omar.same...@gmail.com> đã viết:
--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/BSXl9QhzlXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cesium-dev/e9f8ef35-df55-4157-a929-ea253fd20e53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pham Long

unread,
Jun 13, 2019, 6:04:56 AM6/13/19
to cesiu...@googlegroups.com
Hi,
I'm using  DataSourceDisplay.getBoundingSphere to calculate bounding sphere. This is result, i use circle to draw bounding on map.
Screenshot_1.png

It's look good but i want to calculate bounding rectangle. How could i do it?

Vào Th 5, 13 thg 6, 2019 vào lúc 15:36 Pham Long <long...@gmail.com> đã viết:

long...@gmail.com

unread,
Jun 17, 2019, 4:35:15 AM6/17/19
to cesium-dev
I'm using third party to calculate bounding rectangle. Now, it's work properly.
Thank for your support.
Screenshot_2.png

Omar Shehata

unread,
Jul 9, 2019, 2:17:54 PM7/9/19
to cesium-dev
In case anyone else runs into the same issue, can you post what you used to calculate the bounding rectangle?

Pham Long

unread,
Jul 9, 2019, 9:51:02 PM7/9/19
to cesiu...@googlegroups.com
Hi,
I already sad above post. I used third party to calculate the bounding box of entity. I my case I use JSTS library to calculate boundingbox (getEnvelope function).

Vào Th 4, 10 thg 7, 2019 vào lúc 01:17 Omar Shehata <omar.same...@gmail.com> đã viết:
--
You received this message because you are subscribed to a topic in the Google Groups "cesium-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cesium-dev/BSXl9QhzlXs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cesium-dev+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages