Comments (3)
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.
Feedback welcome on the above before I start implementing it next week!
from cesium-unity.
This is implemented in #79 and #82.
from cesium-unity.
Related Issues (20)
- Errors with Cesium for Unity package (created through developer guide) HOT 1
- Detangle `CesiumCameraController` from `CesiumFlyToController`
- Timeline for Vision Pro Support? HOT 1
- CesiumCreditSystem destroys itself when an additive scene is unloaded HOT 1
- Unable to override Cesium credit system because `CesiumCredit` is marked internal HOT 2
- Add bezier support to Cesium Cartographic Polygon
- Add support for viewing tiles in Iso orientation HOT 3
- Massive Memory Leak in Multitileset Scenes HOT 1
- Android one wont run - Error Unity DllNotFoundException: CesiumForUnityNative HOT 4
- 3Dtile is at the wrong place HOT 1
- Dynamic Camera suddenly slows a lot when going down
- option to 'Terrain Refresh instead of Application Termination/Crash' HOT 1
- Warnings in CesiumSamplesRequiresMagicLeap.cs
- When install Cesium in Unity, the web browser to login to Cesium does not appear? Any thoughts on this?
- BINARY_INVALID_ALIGNMENT works in CesiumJS but not in Cesium-Unity HOT 2
- No way to build and run on android HOT 2
- Error Scaling map on magic leap 2 HOT 1
- Error compiling shaders when building for android HOT 2
- Some Ion imagery assets attempt to load from localhost instead of the correct URLs HOT 1
- Android build broken on v1.9.0 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cesium-unity.