diff --git a/Assets/ISG-ARF/Common_Application/Scenes/ExampleGLTF.unity b/Assets/ISG-ARF/Common_Application/Scenes/ExampleGLTF.unity index fcc6e2d9a650c6dd5463828dde21a27789ce4c0b..dbf7bf79382a277195bd76cb9bf05216b937bd03 100644 --- a/Assets/ISG-ARF/Common_Application/Scenes/ExampleGLTF.unity +++ b/Assets/ISG-ARF/Common_Application/Scenes/ExampleGLTF.unity @@ -569,7 +569,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f7351c94a4c22144284b9eac3270dc8d, type: 3} m_Name: m_EditorClassIdentifier: - _PathToGLTF: ARSceneThreeAnchor.glb + _PathToGLTF: https://www.dropbox.com/scl/fi/yzc04vh687ujgw717r7vm/ARSceneThreeAnchor.glb?rlkey=dm07iorvs0zsdynoh6exl0k4v&st=7d1tqswp&dl=1 _ValiditySubscription: 10000000 _DisableObjectWhenNotTracked: 1 --- !u!4 &842320175 diff --git a/Assets/ISG-ARF/Common_Application/Scripts/SceneManagementGLTF.cs b/Assets/ISG-ARF/Common_Application/Scripts/SceneManagementGLTF.cs index 43f3a26c3e8b2e9d4495bcd69789997aefe96549..6db9045fed4d13c81705a70042c687f5429e039d 100644 --- a/Assets/ISG-ARF/Common_Application/Scripts/SceneManagementGLTF.cs +++ b/Assets/ISG-ARF/Common_Application/Scripts/SceneManagementGLTF.cs @@ -18,7 +18,7 @@ public class SceneManagementGLTF : MonoBehaviour /// <summary> /// If true : before first tracking, objects are hidden /// </summary> - public bool _DisableObjectWhenNotTracked; + public bool _DisableObjectWhenNotTracked; /// <summary> /// List of trackables and anchors in the AR Scene @@ -34,8 +34,8 @@ public class SceneManagementGLTF : MonoBehaviour await LoadGltfBinaryFromMemory(); Transform loaded = this.transform.GetChild(0); FindWorldStorageTransform(loaded); - - foreach(KeyValuePair<Guid , Transform> toSubscribe in m_trackablesAndAnchorsInARScene) + + foreach (KeyValuePair<Guid, Transform> toSubscribe in m_trackablesAndAnchorsInARScene) { toSubscribe.Value.gameObject.SetActive(!_DisableObjectWhenNotTracked); // disable object when not tracked int validity = _ValiditySubscription; @@ -54,7 +54,7 @@ public class SceneManagementGLTF : MonoBehaviour { if (pose.EstimationState != ETSI.ARF.OpenAPI.WorldAnalysis.PoseEstimationState.OK) { - Debug.Log("State Not Ok for " + pose.Uuid + " "+ pose.EstimationState.ToString() + " " + pose.InstructionInfo); + Debug.Log("State Not Ok for " + pose.Uuid + " " + pose.EstimationState.ToString() + " " + pose.InstructionInfo); return; } @@ -64,8 +64,8 @@ public class SceneManagementGLTF : MonoBehaviour if (m_trackablesAndAnchorsInARScene.ContainsKey(pose.Uuid)) { m_trackablesAndAnchorsInARScene[pose.Uuid].transform.gameObject.SetActive(true); - m_trackablesAndAnchorsInARScene[pose.Uuid].transform.position = WorldAnalysisUnityHelper.ConvertETSIVector3ToUnity(value.Position); - m_trackablesAndAnchorsInARScene[pose.Uuid].transform.rotation = WorldAnalysisUnityHelper.ConvertETSIARFQuaternionToUnity(value.Rotation); + m_trackablesAndAnchorsInARScene[pose.Uuid].transform.position = WorldAnalysisUnityHelper.ConvertETSIVector3ToUnity(value.Position); + m_trackablesAndAnchorsInARScene[pose.Uuid].transform.rotation = WorldAnalysisUnityHelper.ConvertETSIARFQuaternionToUnity(value.Rotation); } else { @@ -74,7 +74,7 @@ public class SceneManagementGLTF : MonoBehaviour } else { - Debug.LogWarning("Pose value type not supported yet :" +pose.Value.Type); // Todo : manage other types + Debug.LogWarning("Pose value type not supported yet :" + pose.Value.Type); // Todo : manage other types } } @@ -85,14 +85,21 @@ public class SceneManagementGLTF : MonoBehaviour /// <returns>ascync method</returns> protected async Task LoadGltfBinaryFromMemory() { + string filePath = ""; + if (_PathToGLTF.StartsWith("http")) + { + KeyValuePair<string, string> download = System.Threading.Tasks.Task.Run(() => WorldAnalysisARFoundationHelper.DownloadFileHTTP(_PathToGLTF)).Result; // synchronous : not perfect at all prevent to add another mesh while bundle is downloading + filePath = download.Key; + } + else + { #if UNITY_EDITOR - string prefix = Application.streamingAssetsPath; + string prefix = Application.streamingAssetsPath; #else string prefix = Application.persistentDataPath; -#endif - var filePath = prefix + "/" + _PathToGLTF; - - Debug.Log("PATH : " + filePath); +#endif + filePath = prefix + "/" + _PathToGLTF; + } byte[] data = File.ReadAllBytes(filePath); Debug.Log("File Size " + data.Length); @@ -121,7 +128,7 @@ public class SceneManagementGLTF : MonoBehaviour Debug.Log("Add " + id + " " + trGLTF.name); m_trackablesAndAnchorsInARScene.Add(new Guid(id), trGLTF); } - foreach(Transform child in trGLTF) + foreach (Transform child in trGLTF) { FindWorldStorageTransform(child); }