org.outernet.cesium-unity 1.15.3-linux.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +420 -0
- package/CHANGES.md.meta +7 -0
- package/Editor/BuildCesiumForUnity.cs +186 -0
- package/Editor/BuildCesiumForUnity.cs.meta +11 -0
- package/Editor/Cesium3DTilesetEditor.cs +542 -0
- package/Editor/Cesium3DTilesetEditor.cs.meta +11 -0
- package/Editor/CesiumBingMapsRasterOverlayEditor.cs +66 -0
- package/Editor/CesiumBingMapsRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumCameraControllerEditor.cs +174 -0
- package/Editor/CesiumCameraControllerEditor.cs.meta +11 -0
- package/Editor/CesiumCameraManagerEditor.cs +65 -0
- package/Editor/CesiumCameraManagerEditor.cs.meta +11 -0
- package/Editor/CesiumCartographicPolygonEditor.cs +23 -0
- package/Editor/CesiumCartographicPolygonEditor.cs.meta +11 -0
- package/Editor/CesiumDebugColorizeTilesRasterOverlayEditor.cs +41 -0
- package/Editor/CesiumDebugColorizeTilesRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumEditor.asmdef +26 -0
- package/Editor/CesiumEditor.asmdef.meta +7 -0
- package/Editor/CesiumEditorStyle.cs +188 -0
- package/Editor/CesiumEditorStyle.cs.meta +11 -0
- package/Editor/CesiumEditorUtility.cs +394 -0
- package/Editor/CesiumEditorUtility.cs.meta +11 -0
- package/Editor/CesiumEditorWindow.cs +447 -0
- package/Editor/CesiumEditorWindow.cs.meta +11 -0
- package/Editor/CesiumFlyToControllerEditor.cs +76 -0
- package/Editor/CesiumFlyToControllerEditor.cs.meta +11 -0
- package/Editor/CesiumGeoreferenceEditor.cs +277 -0
- package/Editor/CesiumGeoreferenceEditor.cs.meta +11 -0
- package/Editor/CesiumGlobeAnchorEditor.cs +202 -0
- package/Editor/CesiumGlobeAnchorEditor.cs.meta +11 -0
- package/Editor/CesiumInspectorGUI.cs +187 -0
- package/Editor/CesiumInspectorGUI.cs.meta +11 -0
- package/Editor/CesiumIonAsset.cs +192 -0
- package/Editor/CesiumIonAsset.cs.meta +11 -0
- package/Editor/CesiumIonAssetsWindow.cs +257 -0
- package/Editor/CesiumIonAssetsWindow.cs.meta +11 -0
- package/Editor/CesiumIonRasterOverlayEditor.cs +87 -0
- package/Editor/CesiumIonRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumIonServerManager.cs +153 -0
- package/Editor/CesiumIonServerManager.cs.meta +11 -0
- package/Editor/CesiumIonServerSelector.cs +127 -0
- package/Editor/CesiumIonServerSelector.cs.meta +11 -0
- package/Editor/CesiumIonSession.cs +102 -0
- package/Editor/CesiumIonSession.cs.meta +11 -0
- package/Editor/CesiumPolygonRasterOverlayEditor.cs +102 -0
- package/Editor/CesiumPolygonRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumRasterOverlayEditor.cs +230 -0
- package/Editor/CesiumRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumSubSceneEditor.cs +201 -0
- package/Editor/CesiumSubSceneEditor.cs.meta +11 -0
- package/Editor/CesiumTileMapServiceRasterOverlayEditor.cs +88 -0
- package/Editor/CesiumTileMapServiceRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumWebMapServiceRasterOverlayEditor.cs +111 -0
- package/Editor/CesiumWebMapServiceRasterOverlayEditor.cs.meta +11 -0
- package/Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs +277 -0
- package/Editor/CesiumWebMapTileServiceRasterOverlayEditor.cs.meta +3 -0
- package/Editor/CompileCesiumForUnityNative.cs +581 -0
- package/Editor/CompileCesiumForUnityNative.cs.meta +11 -0
- package/Editor/ConfigureReinterop.cs +255 -0
- package/Editor/ConfigureReinterop.cs.meta +11 -0
- package/Editor/Helpers.cs +102 -0
- package/Editor/Helpers.cs.meta +11 -0
- package/Editor/IonAssetsMultiColumnHeader.cs +45 -0
- package/Editor/IonAssetsMultiColumnHeader.cs.meta +11 -0
- package/Editor/IonAssetsTreeView.cs +214 -0
- package/Editor/IonAssetsTreeView.cs.meta +11 -0
- package/Editor/IonMissingAssetWindow.cs +65 -0
- package/Editor/IonMissingAssetWindow.cs.meta +11 -0
- package/Editor/IonTokenTroubleshootingWindow.cs +615 -0
- package/Editor/IonTokenTroubleshootingWindow.cs.meta +11 -0
- package/Editor/NativeDownloadHandler.cs +35 -0
- package/Editor/NativeDownloadHandler.cs.meta +11 -0
- package/Editor/QuickAddItem.cs +43 -0
- package/Editor/QuickAddItem.cs.meta +11 -0
- package/Editor/Resources/Cesium-128x128.png +0 -0
- package/Editor/Resources/Cesium-128x128.png.meta +98 -0
- package/Editor/Resources/Cesium-24x24.png +0 -0
- package/Editor/Resources/Cesium-24x24.png.meta +123 -0
- package/Editor/Resources/Cesium-64x64.png +0 -0
- package/Editor/Resources/Cesium-64x64.png.meta +98 -0
- package/Editor/Resources/Cesium-for-Unity-dark.png +0 -0
- package/Editor/Resources/Cesium-for-Unity-dark.png.meta +123 -0
- package/Editor/Resources/Cesium-for-Unity-light.png +0 -0
- package/Editor/Resources/Cesium-for-Unity-light.png.meta +123 -0
- package/Editor/Resources/Cesium-icon-16x16.png +0 -0
- package/Editor/Resources/Cesium-icon-16x16.png.meta +98 -0
- package/Editor/Resources/FontAwesome/attribution.txt +9 -0
- package/Editor/Resources/FontAwesome/attribution.txt.meta +7 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.png +0 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/book-reader-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/check-solid.png +0 -0
- package/Editor/Resources/FontAwesome/check-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/check-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/check-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/cloud-upload-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/folder.png +0 -0
- package/Editor/Resources/FontAwesome/folder.png.meta +147 -0
- package/Editor/Resources/FontAwesome/folder.svg +5 -0
- package/Editor/Resources/FontAwesome/folder.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.png +0 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/hands-helping-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/key-solid.png +0 -0
- package/Editor/Resources/FontAwesome/key-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/key-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/key-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/plus-solid.png +0 -0
- package/Editor/Resources/FontAwesome/plus-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/plus-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/plus-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/sign-out-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.png +0 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/sync-alt-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome/times-solid.png +0 -0
- package/Editor/Resources/FontAwesome/times-solid.png.meta +98 -0
- package/Editor/Resources/FontAwesome/times-solid.svg +1 -0
- package/Editor/Resources/FontAwesome/times-solid.svg.meta +7 -0
- package/Editor/Resources/FontAwesome.meta +8 -0
- package/Editor/Resources.meta +8 -0
- package/Editor/SelectIonTokenWindow.cs +249 -0
- package/Editor/SelectIonTokenWindow.cs.meta +11 -0
- package/Editor/arm64.meta +8 -0
- package/Editor/csc.rsp +1 -0
- package/Editor/csc.rsp.meta +7 -0
- package/Editor/libCesiumForUnityNative-Editor.so +0 -0
- package/Editor/libCesiumForUnityNative-Editor.so.meta +2 -0
- package/Editor/libCesiumForUnityNative-Runtime.so +0 -0
- package/Editor/libCesiumForUnityNative-Runtime.so.meta +2 -0
- package/Editor/x86_64.meta +8 -0
- package/Editor.meta +8 -0
- package/LICENSE +201 -0
- package/LICENSE.meta +7 -0
- package/Plugins/Standalone/libCesiumForUnityNative-Runtime.so +0 -0
- package/Plugins/Standalone/libCesiumForUnityNative-Runtime.so.meta +2 -0
- package/Plugins/Standalone.meta +8 -0
- package/Plugins.meta +8 -0
- package/README.md +39 -0
- package/README.md.meta +7 -0
- package/Reinterop.deps.json +172 -0
- package/Reinterop.deps.json.meta +7 -0
- package/Reinterop.dll +0 -0
- package/Reinterop.dll.meta +79 -0
- package/Runtime/Cesium3DTile.cs +37 -0
- package/Runtime/Cesium3DTile.cs.meta +11 -0
- package/Runtime/Cesium3DTileset.cs +788 -0
- package/Runtime/Cesium3DTileset.cs.meta +11 -0
- package/Runtime/Cesium3DTilesetLoadFailureDetails.cs +65 -0
- package/Runtime/Cesium3DTilesetLoadFailureDetails.cs.meta +11 -0
- package/Runtime/CesiumBackwardCompatibility.cs +163 -0
- package/Runtime/CesiumBackwardCompatibility.cs.meta +11 -0
- package/Runtime/CesiumBingMapsRasterOverlay.cs +72 -0
- package/Runtime/CesiumBingMapsRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumCameraController.cs +827 -0
- package/Runtime/CesiumCameraController.cs.meta +11 -0
- package/Runtime/CesiumCameraManager.cs +105 -0
- package/Runtime/CesiumCameraManager.cs.meta +11 -0
- package/Runtime/CesiumCartographicPolygon.cs +152 -0
- package/Runtime/CesiumCartographicPolygon.cs.meta +11 -0
- package/Runtime/CesiumCreditSystem.cs +343 -0
- package/Runtime/CesiumCreditSystem.cs.meta +11 -0
- package/Runtime/CesiumCreditSystemUI.cs +402 -0
- package/Runtime/CesiumCreditSystemUI.cs.meta +11 -0
- package/Runtime/CesiumDebugColorizeTilesRasterOverlay.cs +21 -0
- package/Runtime/CesiumDebugColorizeTilesRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumEllipsoid.cs +107 -0
- package/Runtime/CesiumEllipsoid.cs.meta +11 -0
- package/Runtime/CesiumFeature.cs +279 -0
- package/Runtime/CesiumFeature.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdAttribute.cs +61 -0
- package/Runtime/CesiumFeatureIdAttribute.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdSet.cs +165 -0
- package/Runtime/CesiumFeatureIdSet.cs.meta +11 -0
- package/Runtime/CesiumFeatureIdTexture.cs +68 -0
- package/Runtime/CesiumFeatureIdTexture.cs.meta +11 -0
- package/Runtime/CesiumFlyToController.cs +539 -0
- package/Runtime/CesiumFlyToController.cs.meta +11 -0
- package/Runtime/CesiumGeoreference.cs +628 -0
- package/Runtime/CesiumGeoreference.cs.meta +11 -0
- package/Runtime/CesiumGlobeAnchor.cs +664 -0
- package/Runtime/CesiumGlobeAnchor.cs.meta +11 -0
- package/Runtime/CesiumGlobeAnchorBackwardCompatibility0dot2dot0.cs +105 -0
- package/Runtime/CesiumGlobeAnchorBackwardCompatibility0dot2dot0.cs.meta +11 -0
- package/Runtime/CesiumIntMatN.cs +398 -0
- package/Runtime/CesiumIntMatN.cs.meta +11 -0
- package/Runtime/CesiumIntVecN.cs +525 -0
- package/Runtime/CesiumIntVecN.cs.meta +11 -0
- package/Runtime/CesiumIonRasterOverlay.cs +110 -0
- package/Runtime/CesiumIonRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumIonServer.cs +137 -0
- package/Runtime/CesiumIonServer.cs.meta +11 -0
- package/Runtime/CesiumMetadata.cs +33 -0
- package/Runtime/CesiumMetadata.cs.meta +11 -0
- package/Runtime/CesiumMetadataValue.cs +1764 -0
- package/Runtime/CesiumMetadataValue.cs.meta +11 -0
- package/Runtime/CesiumMetadataValueType.cs +203 -0
- package/Runtime/CesiumMetadataValueType.cs.meta +11 -0
- package/Runtime/CesiumModelMetadata.cs +26 -0
- package/Runtime/CesiumModelMetadata.cs.meta +11 -0
- package/Runtime/CesiumObjectPool.cs +74 -0
- package/Runtime/CesiumObjectPool.cs.meta +11 -0
- package/Runtime/CesiumObjectPools.cs +39 -0
- package/Runtime/CesiumObjectPools.cs.meta +11 -0
- package/Runtime/CesiumOriginShift.cs +146 -0
- package/Runtime/CesiumOriginShift.cs.meta +11 -0
- package/Runtime/CesiumPointCloudRenderer.cs +246 -0
- package/Runtime/CesiumPointCloudRenderer.cs.meta +11 -0
- package/Runtime/CesiumPointCloudShading.cs +76 -0
- package/Runtime/CesiumPointCloudShading.cs.meta +11 -0
- package/Runtime/CesiumPolygonRasterOverlay.cs +109 -0
- package/Runtime/CesiumPolygonRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumPrimitiveFeatures.cs +130 -0
- package/Runtime/CesiumPrimitiveFeatures.cs.meta +11 -0
- package/Runtime/CesiumPropertyArray.cs +64 -0
- package/Runtime/CesiumPropertyArray.cs.meta +11 -0
- package/Runtime/CesiumPropertyTable.cs +126 -0
- package/Runtime/CesiumPropertyTable.cs.meta +11 -0
- package/Runtime/CesiumPropertyTableProperty.cs +1734 -0
- package/Runtime/CesiumPropertyTableProperty.cs.meta +11 -0
- package/Runtime/CesiumRasterOverlay.cs +239 -0
- package/Runtime/CesiumRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumRasterOverlayLoadFailureDetails.cs +65 -0
- package/Runtime/CesiumRasterOverlayLoadFailureDetails.cs.meta +11 -0
- package/Runtime/CesiumRuntime.asmdef +32 -0
- package/Runtime/CesiumRuntime.asmdef.meta +7 -0
- package/Runtime/CesiumRuntime.cs +3 -0
- package/Runtime/CesiumRuntime.cs.meta +11 -0
- package/Runtime/CesiumRuntimeSettings.cs +188 -0
- package/Runtime/CesiumRuntimeSettings.cs.meta +11 -0
- package/Runtime/CesiumSampleHeightResult.cs +47 -0
- package/Runtime/CesiumSampleHeightResult.cs.meta +11 -0
- package/Runtime/CesiumSimplePlanarEllipsoidCurve.cs +93 -0
- package/Runtime/CesiumSimplePlanarEllipsoidCurve.cs.meta +11 -0
- package/Runtime/CesiumSubScene.cs +473 -0
- package/Runtime/CesiumSubScene.cs.meta +11 -0
- package/Runtime/CesiumTileExcluder.cs +47 -0
- package/Runtime/CesiumTileExcluder.cs.meta +11 -0
- package/Runtime/CesiumTileMapServiceRasterOverlay.cs +93 -0
- package/Runtime/CesiumTileMapServiceRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumWebMapServiceRasterOverlay.cs +129 -0
- package/Runtime/CesiumWebMapServiceRasterOverlay.cs.meta +11 -0
- package/Runtime/CesiumWebMapTileServiceRasterOverlay.cs +414 -0
- package/Runtime/CesiumWebMapTileServiceRasterOverlay.cs.meta +3 -0
- package/Runtime/CesiumWgs84Ellipsoid.cs +75 -0
- package/Runtime/CesiumWgs84Ellipsoid.cs.meta +11 -0
- package/Runtime/ConfigureReinterop.cs +926 -0
- package/Runtime/ConfigureReinterop.cs.meta +11 -0
- package/Runtime/Helpers.cs +122 -0
- package/Runtime/Helpers.cs.meta +11 -0
- package/Runtime/ICesiumRestartable.cs +17 -0
- package/Runtime/ICesiumRestartable.cs.meta +11 -0
- package/Runtime/NativeCoroutine.cs +28 -0
- package/Runtime/NativeCoroutine.cs.meta +11 -0
- package/Runtime/NativeDownloadHandler.cs +29 -0
- package/Runtime/NativeDownloadHandler.cs.meta +11 -0
- package/Runtime/Resources/CesiumCreditSystem.prefab +78 -0
- package/Runtime/Resources/CesiumCreditSystem.prefab.meta +7 -0
- package/Runtime/Resources/CesiumCreditSystemRuntimeTheme.tss +2 -0
- package/Runtime/Resources/CesiumCreditSystemRuntimeTheme.tss.meta +11 -0
- package/Runtime/Resources/CesiumCreditSystemUI.uxml +4 -0
- package/Runtime/Resources/CesiumCreditSystemUI.uxml.meta +10 -0
- package/Runtime/Resources/CesiumCreditSystemUIPanelSettings.asset +38 -0
- package/Runtime/Resources/CesiumCreditSystemUIPanelSettings.asset.meta +8 -0
- package/Runtime/Resources/CesiumDefaultTilesetMaterial.mat +232 -0
- package/Runtime/Resources/CesiumDefaultTilesetMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumDefaultTilesetShader.shadergraph +14271 -0
- package/Runtime/Resources/CesiumDefaultTilesetShader.shadergraph.meta +10 -0
- package/Runtime/Resources/CesiumPointCloudShading.hlsl +156 -0
- package/Runtime/Resources/CesiumPointCloudShading.hlsl.meta +7 -0
- package/Runtime/Resources/CesiumPointCloudShadingMaterial.mat +125 -0
- package/Runtime/Resources/CesiumPointCloudShadingMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumPointCloudShadingShader.shader +73 -0
- package/Runtime/Resources/CesiumPointCloudShadingShader.shader.meta +10 -0
- package/Runtime/Resources/CesiumRasterOverlay.shadersubgraph +2207 -0
- package/Runtime/Resources/CesiumRasterOverlay.shadersubgraph.meta +10 -0
- package/Runtime/Resources/CesiumSelectTexCoords.shadersubgraph +722 -0
- package/Runtime/Resources/CesiumSelectTexCoords.shadersubgraph.meta +10 -0
- package/Runtime/Resources/CesiumUnlitTilesetMaterial.mat +261 -0
- package/Runtime/Resources/CesiumUnlitTilesetMaterial.mat.meta +8 -0
- package/Runtime/Resources/CesiumUnlitTilesetShader.shadergraph +5873 -0
- package/Runtime/Resources/CesiumUnlitTilesetShader.shadergraph.meta +10 -0
- package/Runtime/Resources/DynamicCamera.prefab +253 -0
- package/Runtime/Resources/DynamicCamera.prefab.meta +7 -0
- package/Runtime/Resources/TransformTextureCoordinates.shadersubgraph +2171 -0
- package/Runtime/Resources/TransformTextureCoordinates.shadersubgraph.meta +10 -0
- package/Runtime/Resources/green1x1.png +0 -0
- package/Runtime/Resources/green1x1.png.meta +123 -0
- package/Runtime/Resources.meta +8 -0
- package/Runtime/TestGltfModel.cs +56 -0
- package/Runtime/TestGltfModel.cs.meta +11 -0
- package/Runtime/TestReinterop.cs +21 -0
- package/Runtime/TestReinterop.cs.meta +11 -0
- package/Runtime/UnityLifetime.cs +27 -0
- package/Runtime/UnityLifetime.cs.meta +11 -0
- package/Runtime/WaitForTask.cs +25 -0
- package/Runtime/WaitForTask.cs.meta +11 -0
- package/Runtime/csc.rsp +1 -0
- package/Runtime/csc.rsp.meta +7 -0
- package/Runtime.meta +8 -0
- package/ThirdParty.json +27 -0
- package/ThirdParty.json.meta +7 -0
- package/WGS84.asset +18 -0
- package/WGS84.asset.meta +8 -0
- package/package.json +29 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
using Reinterop;
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
using Unity.Mathematics;
|
|
6
|
+
|
|
7
|
+
#if UNITY_EDITOR
|
|
8
|
+
using UnityEditor;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
namespace CesiumForUnity
|
|
12
|
+
{
|
|
13
|
+
/// <summary>
|
|
14
|
+
/// Anchors this game object to the globe. An anchored game object can be placed anywhere on the globe with
|
|
15
|
+
/// high precision, and it will stay in its proper place on the globe when the
|
|
16
|
+
/// <see cref="CesiumGeoreference"/> origin changes.
|
|
17
|
+
/// </summary>
|
|
18
|
+
/// <remarks>
|
|
19
|
+
/// <para>
|
|
20
|
+
/// A game object with this component _must_ be nested inside a <see cref="CesiumGeoreference"/>. That is,
|
|
21
|
+
/// the game object itself, or one of its ancestors, must have a <see cref="CesiumGeoreference"/> attached.
|
|
22
|
+
/// Otherwise, this component will throw an exception in `OnEnable`.
|
|
23
|
+
/// </para>
|
|
24
|
+
/// <para>
|
|
25
|
+
/// An anchored game object is still allowed to move. It may be moved either by setting
|
|
26
|
+
/// properties on this instance, or by updating the game object's `Transform`. If the object is
|
|
27
|
+
/// expected to move outside of the Editor via a `Transform` change, be sure that the
|
|
28
|
+
/// <see cref="detectTransformChanges"/> property is set to true so that this instance updates
|
|
29
|
+
/// accordingly.
|
|
30
|
+
/// </para>
|
|
31
|
+
/// <para>
|
|
32
|
+
/// When this component is moved relative to the globe and
|
|
33
|
+
/// <see cref="adjustOrientationForGlobeWhenMoving"/> is enabled, the orientation of the game object will
|
|
34
|
+
/// also be updated in order to keep the object upright.
|
|
35
|
+
/// </para>
|
|
36
|
+
/// <para>
|
|
37
|
+
/// In most cases, the Transform of the ancestors of the GameObject that contains this component should
|
|
38
|
+
/// be an identity transform: 0 position, 0 rotation, 1 scale. Otherwise, this globe anchor's position will
|
|
39
|
+
/// be misaligned with other globe-aligned objects that are transformed differently. However, it is
|
|
40
|
+
/// sometimes useful to purposely offset an object or group of objects.
|
|
41
|
+
/// </para>
|
|
42
|
+
/// </remarks>
|
|
43
|
+
[ExecuteInEditMode]
|
|
44
|
+
[ReinteropNativeImplementation("CesiumForUnityNative::CesiumGlobeAnchorImpl", "CesiumGlobeAnchorImpl.h", staticOnly: true)]
|
|
45
|
+
[AddComponentMenu("Cesium/Cesium Globe Anchor")]
|
|
46
|
+
[IconAttribute("Packages/com.cesium.unity/Editor/Resources/Cesium-24x24.png")]
|
|
47
|
+
public partial class CesiumGlobeAnchor : MonoBehaviour, ICesiumRestartable
|
|
48
|
+
{
|
|
49
|
+
#region Fields
|
|
50
|
+
|
|
51
|
+
// These fields are marked internal so that they can be accessed from C++.
|
|
52
|
+
// See https://github.com/CesiumGS/cesium-unity/issues/210
|
|
53
|
+
|
|
54
|
+
[SerializeField]
|
|
55
|
+
internal bool _adjustOrientationForGlobeWhenMoving = true;
|
|
56
|
+
|
|
57
|
+
[SerializeField]
|
|
58
|
+
internal bool _detectTransformChanges = true;
|
|
59
|
+
|
|
60
|
+
[SerializeField]
|
|
61
|
+
internal double4x4 _localToGlobeFixedMatrix = double4x4.identity;
|
|
62
|
+
|
|
63
|
+
// True if _localToGlobeFixedMatrix has a valid value.
|
|
64
|
+
// False if it has not yet been initialized from the Transform.
|
|
65
|
+
[SerializeField]
|
|
66
|
+
internal bool _localToGlobeFixedMatrixIsValid = false;
|
|
67
|
+
|
|
68
|
+
// The last known local Transform, used to detect changes in the Transform so that
|
|
69
|
+
// the precise globe coordinates can be recomputed from it. These are invalid before OnEnable.
|
|
70
|
+
[NonSerialized]
|
|
71
|
+
internal bool _lastLocalsAreValid = false;
|
|
72
|
+
|
|
73
|
+
[NonSerialized]
|
|
74
|
+
internal Vector3 _lastLocalPosition;
|
|
75
|
+
|
|
76
|
+
[NonSerialized]
|
|
77
|
+
internal Quaternion _lastLocalRotation;
|
|
78
|
+
|
|
79
|
+
[NonSerialized]
|
|
80
|
+
internal Vector3 _lastLocalScale;
|
|
81
|
+
|
|
82
|
+
// The resolved georeference containing this globe anchor. This is just a cache
|
|
83
|
+
// of `GetComponentInParent<CesiumGeoreference>()`.
|
|
84
|
+
[NonSerialized]
|
|
85
|
+
internal CesiumGeoreference _georeference;
|
|
86
|
+
|
|
87
|
+
[NonSerialized]
|
|
88
|
+
internal double3? _lastEllipsoidRadii;
|
|
89
|
+
|
|
90
|
+
#endregion
|
|
91
|
+
|
|
92
|
+
#region User-editable properties
|
|
93
|
+
|
|
94
|
+
/// <summary>
|
|
95
|
+
/// Gets or sets whether to adjust the game object's orientation based on globe curvature as the
|
|
96
|
+
/// game object moves.
|
|
97
|
+
/// </summary>
|
|
98
|
+
/// <remarks>
|
|
99
|
+
/// <para>
|
|
100
|
+
/// The Earth is not flat, so as we move across its surface, the direction of
|
|
101
|
+
/// "up" changes. If we ignore this fact and leave an object's orientation
|
|
102
|
+
/// unchanged as it moves over the globe surface, the object will become
|
|
103
|
+
/// increasingly tilted and eventually be completely upside-down when we arrive
|
|
104
|
+
/// at the opposite side of the globe.
|
|
105
|
+
/// </para>
|
|
106
|
+
/// <para>
|
|
107
|
+
/// When this setting is enabled, this component will automatically apply a
|
|
108
|
+
/// rotation to the game object to account for globe curvature any time the game
|
|
109
|
+
/// object's position on the globe changes.
|
|
110
|
+
/// </para>
|
|
111
|
+
/// <para>
|
|
112
|
+
/// This property should usually be enabled, but it may be useful to disable it
|
|
113
|
+
/// when your application already accounts for globe curvature itself when it
|
|
114
|
+
/// updates a game object's position and orientation, because in that case the
|
|
115
|
+
/// game object would be over-rotated.
|
|
116
|
+
/// </para>
|
|
117
|
+
/// </remarks>
|
|
118
|
+
public bool adjustOrientationForGlobeWhenMoving
|
|
119
|
+
{
|
|
120
|
+
get => this._adjustOrientationForGlobeWhenMoving;
|
|
121
|
+
set => this._adjustOrientationForGlobeWhenMoving = value;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
/// Gets or sets whether to automatically detect changes in the game object's <code>Transform</code>
|
|
126
|
+
/// and update the precise globe coordinates accordingly.
|
|
127
|
+
/// </summary>
|
|
128
|
+
/// <remarks>
|
|
129
|
+
/// <para>
|
|
130
|
+
/// Setting this property to true runs a coroutine to poll for an update to the <code>Transform</code>
|
|
131
|
+
/// so that it can be reflected in the precise coordinates. When this is property is false,
|
|
132
|
+
/// the coroutine and polling are not necessary, but the precise coordinates may become out of sync
|
|
133
|
+
/// with the <code>Transform</code>.
|
|
134
|
+
/// </para>
|
|
135
|
+
/// <para>
|
|
136
|
+
/// When this is false, you can still directly set the precise coordinates, and the <code>Transform</code>
|
|
137
|
+
/// will update accordingly. You can also call <see cref="Sync"/> after setting the <code>Transform</code>
|
|
138
|
+
/// to manually update the precise coordinates.
|
|
139
|
+
/// </para>
|
|
140
|
+
/// </remarks>
|
|
141
|
+
public bool detectTransformChanges
|
|
142
|
+
{
|
|
143
|
+
get => this._detectTransformChanges;
|
|
144
|
+
set
|
|
145
|
+
{
|
|
146
|
+
this._detectTransformChanges = value;
|
|
147
|
+
this.StartOrStopDetectingTransformChanges();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/// <summary>
|
|
152
|
+
/// Gets or sets the 4x4 transformation matrix from this game object's local coordinate system
|
|
153
|
+
/// to the Earth-Centered, Earth-Fixed (ECEF) coordinate system.
|
|
154
|
+
/// </summary>
|
|
155
|
+
/// <remarks>
|
|
156
|
+
/// The ECEF coordinate system is a right-handed system located at the center of the Earth.
|
|
157
|
+
/// The +X axis points to the intersection of the Equator and Prime Meridian (zero degrees
|
|
158
|
+
/// longitude). The +Y axis points to the intersection of the Equator and +90 degrees
|
|
159
|
+
/// longitude. The +Z axis points up through the North Pole.
|
|
160
|
+
/// </remarks>
|
|
161
|
+
public double4x4 localToGlobeFixedMatrix
|
|
162
|
+
{
|
|
163
|
+
get
|
|
164
|
+
{
|
|
165
|
+
this.InitializeEcefIfNeeded();
|
|
166
|
+
return this._localToGlobeFixedMatrix;
|
|
167
|
+
}
|
|
168
|
+
set
|
|
169
|
+
{
|
|
170
|
+
this.InitializeEcefIfNeeded();
|
|
171
|
+
this.UpdateEcef(value);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// <summary>
|
|
176
|
+
/// Gets or sets the longitude, latitude, and height of this object. The Longitude (X) is in the range -180 to 180 degrees.
|
|
177
|
+
/// The Latitude (Y) is in the range -90 to 90 degrees. The Height (Z) is measured in meters above the WGS84
|
|
178
|
+
/// ellipsoid. Do not confused an ellipsoidal height with a geoid height or height above mean sea level, which
|
|
179
|
+
/// can be tens of meters higher or lower depending on where in the world the object is located.
|
|
180
|
+
/// </summary>
|
|
181
|
+
/// <remarks>
|
|
182
|
+
/// When the position is set via this property, it is internally converted to and stored in Earth-Centered,
|
|
183
|
+
/// Earth-Fixed Coordinates. As a result, getting this property will not necessarily return
|
|
184
|
+
/// the exact value that was set.
|
|
185
|
+
/// </remarks>
|
|
186
|
+
public double3 longitudeLatitudeHeight
|
|
187
|
+
{
|
|
188
|
+
get
|
|
189
|
+
{
|
|
190
|
+
this.UpdateGeoreferenceIfNecessary();
|
|
191
|
+
|
|
192
|
+
if (this._georeference == null || this._georeference.ellipsoid == null)
|
|
193
|
+
{
|
|
194
|
+
// Cannot get property if there is no georeference, or the georeference has no ellipsoid.
|
|
195
|
+
return new double3(0.0, 0.0, 0.0);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return this._georeference.ellipsoid.CenteredFixedToLongitudeLatitudeHeight(this.positionGlobeFixed);
|
|
199
|
+
}
|
|
200
|
+
set
|
|
201
|
+
{
|
|
202
|
+
this.UpdateGeoreferenceIfNecessary();
|
|
203
|
+
|
|
204
|
+
if (this._georeference == null || this._georeference.ellipsoid == null)
|
|
205
|
+
{
|
|
206
|
+
// Cannot set property if there is no georeference, or the georeference has no ellipsoid.
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
this.positionGlobeFixed = this._georeference.ellipsoid.LongitudeLatitudeHeightToCenteredFixed(value);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/// <summary>
|
|
215
|
+
/// Gets or sets the game object's position in the Earth-Centered, Earth-Fixed (ECEF) coordinates in meters.
|
|
216
|
+
/// </summary>
|
|
217
|
+
/// <remarks>
|
|
218
|
+
/// See <see cref="localToGlobeFixedMatrix"/> for an explanation of the ECEF coordinate system.
|
|
219
|
+
/// </remarks>
|
|
220
|
+
public double3 positionGlobeFixed
|
|
221
|
+
{
|
|
222
|
+
get => this.localToGlobeFixedMatrix.c3.xyz;
|
|
223
|
+
set
|
|
224
|
+
{
|
|
225
|
+
double4x4 newModelToEcef = this.localToGlobeFixedMatrix;
|
|
226
|
+
newModelToEcef.c3 = new double4(value.x, value.y, value.z, 1.0);
|
|
227
|
+
this.localToGlobeFixedMatrix = newModelToEcef;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/// <summary>
|
|
232
|
+
/// Gets or sets the rotation from the game object's coordinate system to the
|
|
233
|
+
/// Earth-Centered, Earth-Fixed axes.
|
|
234
|
+
/// </summary>
|
|
235
|
+
/// <remarks>
|
|
236
|
+
/// <para>
|
|
237
|
+
/// See <see cref="localToGlobeFixedMatrix"/> for an explanation of the ECEF coordinate system.
|
|
238
|
+
/// </para>
|
|
239
|
+
/// <para>
|
|
240
|
+
/// When the rotation is set via this property, it is internally converted to and stored in the
|
|
241
|
+
/// <see cref="localToGlobeFixedMatrix"/> property. As a result, getting this property will not
|
|
242
|
+
/// necessarily return the exact value that was set.
|
|
243
|
+
/// </para>
|
|
244
|
+
/// </remarks>
|
|
245
|
+
public quaternion rotationGlobeFixed
|
|
246
|
+
{
|
|
247
|
+
get
|
|
248
|
+
{
|
|
249
|
+
double3 translation;
|
|
250
|
+
quaternion rotation;
|
|
251
|
+
double3 scale;
|
|
252
|
+
|
|
253
|
+
Helpers.MatrixToTranslationRotationAndScale(this.localToGlobeFixedMatrix, out translation, out rotation, out scale);
|
|
254
|
+
|
|
255
|
+
return rotation;
|
|
256
|
+
}
|
|
257
|
+
set
|
|
258
|
+
{
|
|
259
|
+
double3 translation;
|
|
260
|
+
quaternion rotation;
|
|
261
|
+
double3 scale;
|
|
262
|
+
|
|
263
|
+
Helpers.MatrixToTranslationRotationAndScale(this.localToGlobeFixedMatrix, out translation, out rotation, out scale);
|
|
264
|
+
this.localToGlobeFixedMatrix = Helpers.TranslationRotationAndScaleToMatrix(translation, value, scale);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/// <summary>
|
|
269
|
+
/// Gets or sets the rotation from the game object's coordinate system to a local coordinate system
|
|
270
|
+
/// centered on this object where the +X points in the local East direction, the +Y axis points in
|
|
271
|
+
/// the local Up direction, and the +Z axis points in the local North direction.
|
|
272
|
+
/// </summary>
|
|
273
|
+
/// <remarks>
|
|
274
|
+
/// When the rotation is set via this property, it is internally converted to and stored in the
|
|
275
|
+
/// <see cref="localToGlobeFixedMatrix"/> property. As a result, getting this property will not
|
|
276
|
+
/// necessarily return the exact value that was set.
|
|
277
|
+
/// </remarks>
|
|
278
|
+
public quaternion rotationEastUpNorth
|
|
279
|
+
{
|
|
280
|
+
get
|
|
281
|
+
{
|
|
282
|
+
this.InitializeEcefIfNeeded();
|
|
283
|
+
return this.GetLocalToEastUpNorthRotation();
|
|
284
|
+
}
|
|
285
|
+
set
|
|
286
|
+
{
|
|
287
|
+
this.InitializeEcefIfNeeded();
|
|
288
|
+
this.SetLocalToEastUpNorthRotation(value);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/// <summary>
|
|
293
|
+
/// Gets the scale from the game object's coordinate system to the Earth-Centered,
|
|
294
|
+
/// Earth-Fixed coordinate system. Because ECEF is right-handed and Unity is left-handed,
|
|
295
|
+
/// this scale will almost always be negative.
|
|
296
|
+
/// </summary>
|
|
297
|
+
/// <remarks>
|
|
298
|
+
/// See <see cref="localToGlobeFixedMatrix"/> for an explanation of the ECEF coordinate system.
|
|
299
|
+
/// </remarks>
|
|
300
|
+
public double3 scaleGlobeFixed
|
|
301
|
+
{
|
|
302
|
+
get
|
|
303
|
+
{
|
|
304
|
+
double3 translation;
|
|
305
|
+
quaternion rotation;
|
|
306
|
+
double3 scale;
|
|
307
|
+
|
|
308
|
+
Helpers.MatrixToTranslationRotationAndScale(this.localToGlobeFixedMatrix, out translation, out rotation, out scale);
|
|
309
|
+
|
|
310
|
+
return scale;
|
|
311
|
+
}
|
|
312
|
+
set
|
|
313
|
+
{
|
|
314
|
+
double3 translation;
|
|
315
|
+
quaternion rotation;
|
|
316
|
+
double3 scale;
|
|
317
|
+
|
|
318
|
+
Helpers.MatrixToTranslationRotationAndScale(this.localToGlobeFixedMatrix, out translation, out rotation, out scale);
|
|
319
|
+
this.localToGlobeFixedMatrix = Helpers.TranslationRotationAndScaleToMatrix(translation, rotation, value);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/// <summary>
|
|
324
|
+
/// Gets or sets the scale from the game object's coordinate system to a local coordinate system
|
|
325
|
+
/// centered on this object where the +X points in the local East direction, the +Y axis points in
|
|
326
|
+
/// the local Up direction, and the +Z axis points in the local North direction.
|
|
327
|
+
/// </summary>
|
|
328
|
+
/// <remarks>
|
|
329
|
+
/// When the rotation is set via this property, it is internally converted to and stored in the
|
|
330
|
+
/// <see cref="localToGlobeFixedMatrix"/> property. As a result, getting this property will not
|
|
331
|
+
/// necessarily return the exact value that was set.
|
|
332
|
+
/// </remarks>
|
|
333
|
+
public double3 scaleEastUpNorth
|
|
334
|
+
{
|
|
335
|
+
get => -this.scaleGlobeFixed;
|
|
336
|
+
set => this.scaleGlobeFixed = -value;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
#endregion
|
|
340
|
+
|
|
341
|
+
#region Deprecated Functionality
|
|
342
|
+
|
|
343
|
+
[Obsolete("Use positionGlobeFixed.x instead.")]
|
|
344
|
+
public double ecefX
|
|
345
|
+
{
|
|
346
|
+
get => this.positionGlobeFixed.x;
|
|
347
|
+
set
|
|
348
|
+
{
|
|
349
|
+
double3 position = this.positionGlobeFixed;
|
|
350
|
+
position.x = value;
|
|
351
|
+
this.positionGlobeFixed = position;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
[Obsolete("Use positionGlobeFixed.y instead.")]
|
|
356
|
+
public double ecefY
|
|
357
|
+
{
|
|
358
|
+
get => this.positionGlobeFixed.y;
|
|
359
|
+
set
|
|
360
|
+
{
|
|
361
|
+
double3 position = this.positionGlobeFixed;
|
|
362
|
+
position.y = value;
|
|
363
|
+
this.positionGlobeFixed = position;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
[Obsolete("Use positionGlobeFixed.z instead.")]
|
|
368
|
+
public double ecefZ
|
|
369
|
+
{
|
|
370
|
+
get => this.positionGlobeFixed.z;
|
|
371
|
+
set
|
|
372
|
+
{
|
|
373
|
+
double3 position = this.positionGlobeFixed;
|
|
374
|
+
position.z = value;
|
|
375
|
+
this.positionGlobeFixed = position;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
[Obsolete("Use longitudeLatitudeHeight.x instead.")]
|
|
380
|
+
public double longitude
|
|
381
|
+
{
|
|
382
|
+
get => this.longitudeLatitudeHeight.x;
|
|
383
|
+
set
|
|
384
|
+
{
|
|
385
|
+
double3 position = this.longitudeLatitudeHeight;
|
|
386
|
+
position.x = value;
|
|
387
|
+
this.longitudeLatitudeHeight = position;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
[Obsolete("Use longitudeLatitudeHeight.y instead.")]
|
|
392
|
+
public double latitude
|
|
393
|
+
{
|
|
394
|
+
get => this.longitudeLatitudeHeight.y;
|
|
395
|
+
set
|
|
396
|
+
{
|
|
397
|
+
double3 position = this.longitudeLatitudeHeight;
|
|
398
|
+
position.y = value;
|
|
399
|
+
this.longitudeLatitudeHeight = position;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
[Obsolete("Use longitudeLatitudeHeight.z instead.")]
|
|
404
|
+
public double height
|
|
405
|
+
{
|
|
406
|
+
get => this.longitudeLatitudeHeight.z;
|
|
407
|
+
set
|
|
408
|
+
{
|
|
409
|
+
double3 position = this.longitudeLatitudeHeight;
|
|
410
|
+
position.z = value;
|
|
411
|
+
this.longitudeLatitudeHeight = position;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
[Obsolete("Set the longitudeLatitudeHeight property instead.")]
|
|
416
|
+
public void SetPositionLongitudeLatitudeHeight(double longitude, double latitude, double height)
|
|
417
|
+
{
|
|
418
|
+
this.longitudeLatitudeHeight = new double3(longitude, latitude, height);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
[Obsolete("Set the positionGlobeFixed property instead.")]
|
|
423
|
+
public void SetPositionEarthCenteredEarthFixed(double x, double y, double z)
|
|
424
|
+
{
|
|
425
|
+
this.positionGlobeFixed = new double3(x, y, z);
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
#endregion
|
|
429
|
+
|
|
430
|
+
#region Public Methods
|
|
431
|
+
|
|
432
|
+
/// <summary>
|
|
433
|
+
/// Synchronizes the properties of this `CesiumGlobeAnchor`.
|
|
434
|
+
/// </summary>
|
|
435
|
+
/// <remarks>
|
|
436
|
+
/// <para>
|
|
437
|
+
/// It is usually not necessary to call this method because it is called automatically when
|
|
438
|
+
/// needed. However, it may be be useful in special situations or when the timing of the
|
|
439
|
+
/// automatic calls is not ideal.
|
|
440
|
+
/// </para>
|
|
441
|
+
/// <para>
|
|
442
|
+
/// For example, if the Transform is updated via a coroutine,
|
|
443
|
+
/// then the globe anchor's check for a change in the Transform may run _before_ the change,
|
|
444
|
+
/// in which case the new Transform won't be noted until the _next_ frame. Calling this
|
|
445
|
+
/// method after modifying the Transform will avoid the one frame delay.
|
|
446
|
+
/// </para>
|
|
447
|
+
/// <para>This method performs the following actions:
|
|
448
|
+
/// </para>
|
|
449
|
+
/// <list type="bullet">
|
|
450
|
+
/// <item>
|
|
451
|
+
/// If the <see cref="localToGlobeFixedMatrix"/> transform has not yet been set, it is computed
|
|
452
|
+
/// from the game object's current `Transform`.
|
|
453
|
+
/// </item>
|
|
454
|
+
/// <item>
|
|
455
|
+
/// If the game object's `Transform` has changed since the last time `OnEnable`,
|
|
456
|
+
/// or if a position setter was called, this method updates all of this instance's position
|
|
457
|
+
/// properties from the current transform. This works even if <see cref="detectTransformChanges"/> is
|
|
458
|
+
/// disabled. It will also update the object's orientation if
|
|
459
|
+
/// <see cref="adjustOrientationForGlobeWhenMoving"/> is enabled.
|
|
460
|
+
/// </item>
|
|
461
|
+
/// <item>
|
|
462
|
+
/// If the origin of the <see cref="CesiumGeoreference"/> has changed, the game object's `Transform` is
|
|
463
|
+
/// updated based on the <see cref="localToGlobeFixedMatrix"/> transform and the new georeference origin.
|
|
464
|
+
/// </item>
|
|
465
|
+
/// </list>
|
|
466
|
+
/// </remarks>
|
|
467
|
+
public void Sync()
|
|
468
|
+
{
|
|
469
|
+
// If the ellipsoid changed since last sync, we need to update from transform since our ECEF mapping
|
|
470
|
+
// is going to be invalid.
|
|
471
|
+
bool isEllipsoidChanged = this._lastEllipsoidRadii.HasValue && this._georeference != null ?
|
|
472
|
+
(this._lastEllipsoidRadii.Value.x != this._georeference.ellipsoid.radii.x ||
|
|
473
|
+
this._lastEllipsoidRadii.Value.y != this._georeference.ellipsoid.radii.y ||
|
|
474
|
+
this._lastEllipsoidRadii.Value.z != this._georeference.ellipsoid.radii.z) : true;
|
|
475
|
+
|
|
476
|
+
// If we don't have a local -> globe fixed matrix yet, we must update from the Transform
|
|
477
|
+
bool updateFromTransform = !this._localToGlobeFixedMatrixIsValid;
|
|
478
|
+
if (!isEllipsoidChanged && !updateFromTransform && this._lastLocalsAreValid)
|
|
479
|
+
{
|
|
480
|
+
// We may also need to update from the Transform if it has changed
|
|
481
|
+
// since the last time we computed the local -> globe fixed matrix.
|
|
482
|
+
updateFromTransform =
|
|
483
|
+
this._lastLocalPosition != this.transform.localPosition ||
|
|
484
|
+
this._lastLocalRotation != this.transform.localRotation ||
|
|
485
|
+
this._lastLocalScale != this.transform.localScale;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
if (isEllipsoidChanged || updateFromTransform)
|
|
489
|
+
this.UpdateEcefFromTransform();
|
|
490
|
+
else
|
|
491
|
+
this.UpdateEcef(this._localToGlobeFixedMatrix);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/// <summary>
|
|
495
|
+
/// Completely re-initializes the state of this object from its serialized properties. This is called automatically
|
|
496
|
+
/// by `OnEnable` and is not usually necessary to call directly. It can sometimes be useful after Unity has
|
|
497
|
+
/// modified the private, serializable fields of this instance. For example: after an undo or redo operation.
|
|
498
|
+
/// </summary>
|
|
499
|
+
public void Restart()
|
|
500
|
+
{
|
|
501
|
+
this.UpdateGeoreference();
|
|
502
|
+
|
|
503
|
+
if (this._georeference == null)
|
|
504
|
+
Debug.LogWarning($"{this.gameObject.name} is not nested inside a game object with a CesiumGeoreference. Most of its CesiumGlobeAnchor functionality will not work.");
|
|
505
|
+
|
|
506
|
+
this.Sync();
|
|
507
|
+
this.StartOrStopDetectingTransformChanges();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
#endregion
|
|
511
|
+
|
|
512
|
+
#region Unity Messages
|
|
513
|
+
|
|
514
|
+
private void UpdateGeoreference()
|
|
515
|
+
{
|
|
516
|
+
if (this._georeference != null)
|
|
517
|
+
this._georeference.RemoveGlobeAnchor(this);
|
|
518
|
+
|
|
519
|
+
this._georeference = this.gameObject.GetComponentInParent<CesiumGeoreference>();
|
|
520
|
+
|
|
521
|
+
if (this._georeference != null)
|
|
522
|
+
{
|
|
523
|
+
this._georeference.Initialize();
|
|
524
|
+
if (this.isActiveAndEnabled)
|
|
525
|
+
this._georeference.AddGlobeAnchor(this);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
internal void UpdateGeoreferenceIfNecessary()
|
|
530
|
+
{
|
|
531
|
+
if (this._georeference == null)
|
|
532
|
+
this.UpdateGeoreference();
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
private void OnEnable()
|
|
536
|
+
{
|
|
537
|
+
this.Restart();
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
/// <summary>
|
|
541
|
+
/// Called by the Editor when the user chooses to "reset" the component.
|
|
542
|
+
/// The implementation here makes sure the newly-reset values for the serialized
|
|
543
|
+
/// properties are applied.
|
|
544
|
+
/// </summary>
|
|
545
|
+
private void Reset()
|
|
546
|
+
{
|
|
547
|
+
this.Restart();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
private void OnDisable()
|
|
551
|
+
{
|
|
552
|
+
if (this._georeference != null)
|
|
553
|
+
this._georeference.RemoveGlobeAnchor(this);
|
|
554
|
+
this._georeference = null;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
private void OnTransformParentChanged()
|
|
558
|
+
{
|
|
559
|
+
this.UpdateGeoreference();
|
|
560
|
+
this.Sync();
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
#endregion
|
|
564
|
+
|
|
565
|
+
#region Coroutines
|
|
566
|
+
|
|
567
|
+
private void StartOrStopDetectingTransformChanges()
|
|
568
|
+
{
|
|
569
|
+
this.StopCoroutine("DetectTransformChanges");
|
|
570
|
+
|
|
571
|
+
bool start = this._detectTransformChanges;
|
|
572
|
+
|
|
573
|
+
#if UNITY_EDITOR
|
|
574
|
+
// Always detect changes in Edit mode.
|
|
575
|
+
if (!EditorApplication.isPlaying)
|
|
576
|
+
start = true;
|
|
577
|
+
#endif
|
|
578
|
+
|
|
579
|
+
// Can't start a coroutine on an inactive game object
|
|
580
|
+
if (!this.isActiveAndEnabled)
|
|
581
|
+
start = false;
|
|
582
|
+
|
|
583
|
+
if (start)
|
|
584
|
+
this.StartCoroutine("DetectTransformChanges");
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
private IEnumerator DetectTransformChanges()
|
|
588
|
+
{
|
|
589
|
+
// Detect changes in the Transform component.
|
|
590
|
+
// We don't use Transform.hasChanged because we can't control when it is reset to false.
|
|
591
|
+
WaitUntil waitForChanges = new WaitUntil(() => this._lastLocalsAreValid && (
|
|
592
|
+
this.transform.localPosition != this._lastLocalPosition ||
|
|
593
|
+
this.transform.localRotation != this._lastLocalRotation ||
|
|
594
|
+
this.transform.localScale != this._lastLocalScale));
|
|
595
|
+
|
|
596
|
+
while (true)
|
|
597
|
+
{
|
|
598
|
+
yield return waitForChanges;
|
|
599
|
+
this.UpdateEcefFromTransform();
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
#endregion
|
|
604
|
+
|
|
605
|
+
#region Updaters
|
|
606
|
+
|
|
607
|
+
private void InitializeEcefIfNeeded()
|
|
608
|
+
{
|
|
609
|
+
if (!this._localToGlobeFixedMatrixIsValid)
|
|
610
|
+
this.UpdateEcefFromTransform();
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
private void UpdateEcef(double4x4 newModelToEcef)
|
|
614
|
+
{
|
|
615
|
+
this.UpdateGeoreferenceIfNecessary();
|
|
616
|
+
this.SetNewLocalToGlobeFixedMatrix(newModelToEcef);
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
private void UpdateEcefFromTransform()
|
|
620
|
+
{
|
|
621
|
+
this.UpdateGeoreferenceIfNecessary();
|
|
622
|
+
if (this._georeference != null)
|
|
623
|
+
this.SetNewLocalToGlobeFixedMatrixFromTransform();
|
|
624
|
+
#if UNITY_EDITOR
|
|
625
|
+
PrefabUtility.RecordPrefabInstancePropertyModifications(this);
|
|
626
|
+
#endif
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/// <summary>
|
|
630
|
+
/// Sets a new model-to-ECEF matrix, rotating it for the new globe position if
|
|
631
|
+
/// <see cref="adjustOrientationForGlobeWhenMoving"/> is true and also updating
|
|
632
|
+
/// the object's Transform. Be sure the georeference is initialized before
|
|
633
|
+
/// calling this method.
|
|
634
|
+
/// </summary>
|
|
635
|
+
/// <param name="newLocalToGlobeFixedMatrix">The new transformation matrix from the local coordinate system to Earth-Centered, Earth-Fixed.</param>
|
|
636
|
+
private partial void SetNewLocalToGlobeFixedMatrix(double4x4 newLocalToGlobeFixedMatrix);
|
|
637
|
+
|
|
638
|
+
/// <summary>
|
|
639
|
+
/// Sets a new model-to-ECEF matrix from the current value of the object's
|
|
640
|
+
/// Transform. Also rotates the object for the new globe position if
|
|
641
|
+
/// <see cref="adjustOrientationForGlobeWhenMoving"/> is true. Be sure that the
|
|
642
|
+
/// georeference is intialized before calling this method.
|
|
643
|
+
/// </summary>
|
|
644
|
+
private partial void SetNewLocalToGlobeFixedMatrixFromTransform();
|
|
645
|
+
|
|
646
|
+
/// <summary>
|
|
647
|
+
/// Gets the current rotation from the local axes to a set of axes where
|
|
648
|
+
/// +X points East, +Y points Up, and +Z points East at the object's position.
|
|
649
|
+
/// Be sure that the georeference is initialized before calling this method.
|
|
650
|
+
/// </summary>
|
|
651
|
+
/// <returns>The rotation.</returns>
|
|
652
|
+
private partial quaternion GetLocalToEastUpNorthRotation();
|
|
653
|
+
|
|
654
|
+
/// <summary>
|
|
655
|
+
/// Sets the current rotation from the model's axes to a set of axes where
|
|
656
|
+
/// +X points East, +Y points Up, and +Z points East at the object's position.
|
|
657
|
+
/// Be sure that the georeference is initialized before calling this method.
|
|
658
|
+
/// </summary>
|
|
659
|
+
/// <param name="newRotation">The new rotation.</param>
|
|
660
|
+
private partial void SetLocalToEastUpNorthRotation(quaternion newRotation);
|
|
661
|
+
|
|
662
|
+
#endregion
|
|
663
|
+
}
|
|
664
|
+
}
|