Hello I want to instantiate a cube with a gps coordinate. (lat, long, alt)
But I get is some wrong coordiantes when I Instantiate a cube and put the values into Cesium Globe Anchor. Can you explain why?
My simple code looks like this.
{
double latitude = 37.5555;
double longitude = 126.5333;
GameObject hydrangt = Instantiate(cube, CesiumGeoReference.transform) as GameObject;
temp = new double3(latitude, longitude, 0);
hydrant.GetComponent().longitudeLatitudeHeight = temp;
Debug.Log("Latitude: " + latitude + ", Longitude: " + longitude);
}
I dunno why but CesiumGlobeAnchor isn’t appearing in hydrant.GetComponent<>() here.
Looks like a bug.
But I get is some wrong coordiantes when I Instantiate a cube and put the values into Cesium Globe Anchor. Can you explain why?
Yep, longitude is supposed to be first.
I dunno why but CesiumGlobeAnchor isn’t appearing in hydrant.GetComponent<>() here.
Looks like a bug.
Use the “Preformatted text” button on a separate line, and put the code where it says. Otherwise your code is interpreted as markdown, and so <CesiumGlobeAnchor>
is interpreted as HTML.
Holy moly, that was a pretty dumb question with a smart answer. Made it working right away.
Thank you.
By the way do you perhaps have any ideas on putting the objects exactly on the 3d tiles neatly?
I know each tiles has a collider but all of those tiles are turned on and off where the camera is facing.
Right now I have more than 500 objects and trying to place them neatly on the tiles.
That’s a much harder question, unfortunately. The only option right now is to do a line trace against the surface, but of course the surface can change as the level of detail changes.
1 Like
Can you tell me if this might work?
I would first get ECEF position and through lat and long coordinates using TransformUnityPositionToEarthCenteredEarthFixed method and pass it to CesiumWgs84Ellipsoid.EarthCenteredEarthFixedToLongitudeLatitudeHeight.
From there I would get the height and input every object according to its height.
Come to think of it that won’t work because the height is already wrong. Hmm, maybe I will need to fire a raycast to the tiles and get that height
Yep, ray casting is the way to do it. That’s what I meant by “line trace” above.
1 Like