Giter VIP home page Giter VIP logo

Comments (3)

kring avatar kring commented on May 31, 2024

At a high level, here's what I'm thinking for the various MonoBehaviours in our georeferencing system. It's pretty similar to what we're doing with Unreal, but there are some minor differences.

CesiumGeoreference

Defines the current mapping between globe coordinates and Unity world coordinates.

This component specifies a particular point on the globe, and forms a coordinate system at that point where the X axis points East, the Y axis points Up, and the Z axis points North. Coordinates are in meters. The Unity Transform attached to the same GameObject is usually an identity transform, which means that this globe coordinate system shares an origin with the Unity world, and the axes of each are aligned. If it's not an identity transformation, it specifies how coordinates in the global coordinate system are transformed into Unity world coordinates. For example:

  • A uniform scale of 0.5 means the globe is shown at half its normal size.
  • A position of (100.0, 0.0, 0.0) means that the location specified in the CesiumGeoreference component is located at coordinates (100.0, 0.0, 0.0) in the Unity world.

A Scene usually has only one CesiumGeoreference, but nothing forbids using multiple in unusual circumstances. For example, to map multiple instances of the globe into different locations in the Unity world.

CesiumGlobeAnchor

Specifies the position and orientation of a GameObject on the globe. This is then mapped into the Unity world by a CesiumGeoreference.

A CesiumGlobeAnchor finds the corresponding CesiumGeoreference using Unity's GetComponentInParent method. So, it starts with the GameObject to which it is attached, and then checks its parent GameObject, then its grandparent GameObject, and so on.

Only game objects with a CesiumGlobeAnchor component attached to them are affected by changes in the CesiumGeoreference component and its Transform, because only those objects are positioned and oriented in globe coordinates.

When a GameObject with a CesiumGlobeAnchor is moved (including through normal Unity mechanisms like physics), the object's orientation may optionally be updated based on the new location. For example, if an object representing a person is standing upright at a particular location on the globe, and it is then moved to the other side of the globe, the CesiumGlobeAnchor may be configured to respond in one of two ways:

  • Keep the original orientation relative to the Unity world. The person might appear to be standing on their head on the other side of the globe.
  • Keep the original orientation relative to a local horizontal coordinate system on the globe even as that coordinate system moves to the other side of the globe. So in this case, the person will be upright after the move as well.

By adding this component to a parent object, users can create a local coordinate system on the globe and add normal, non-globe-aware objects to it. The local coordinate system - and all objects in it - will move with the globe.

CesiumOriginShift

Attach this component to a GameObject, usually a camera, to make the CesiumGeoreference globe position follow that game object. Each time the object moves, the component computes the object's new globe position and then sets the CesiumGeoreference origin such that that globe position is at the center of the Unity world. Then it updates the object's position to be (0, 0, 0). The object's globe position and the computed origin position can be different if CesiumGeoreference doesn't use an identity transform. If the object also has a CesiumGlobeAnchor attached, then its orientation will optionally be updated as well so that the object remains upright in its new position on the globe.

In the common case where this component is attached to the main camera, this component effectively makes the world move around the camera instead of the camera moving through the world, enabling the scene to be rendered with maximum precision.

The user may select whether the origin shifts continuously every time the object moves, or whether it only shifts when the object moves beyond a certain distance from the origin. The latter improves performance by moving objects less frequently, at the cost of some precision.

CesiumSubLevel

Designates a sub-level that becomes active when an object with the CesiumOriginShift component (usually a camera) comes within a user-defined range. All other sub-levels are deactivated. If the object is within range of multiple sub-levels, only the closest one is activated. This enables users to define multiple independent areas on the globe, each of which acts like a normal Unity scene, while allowing seamless movement between them.

Objects with the CesiumSubLevel component should be placed as children of an object with a CesiumGeoereference, and the CesiumGeoreference forms a sort of "scope" for the sub-levels. Only one sub-level within a CesiumGeoreference is active at any given time; specifically, the closest one. A sub-level has its own georeference origin and transform, and both are applied to the real CesiumGeoreference when the sub-level is activated.

Objects within a sub-level are activated and deactivated, but they are never subjected to an origin shift. This allows almost any Unity object to be used within a sub-level without any drama.

from cesium-unity.

kring avatar kring commented on May 31, 2024

Feedback welcome on the above before I start implementing it next week!

from cesium-unity.

kring avatar kring commented on May 31, 2024

This is implemented in #79 and #82.

from cesium-unity.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.