Skip to content
Snippets Groups Projects
Commit 4b43658f authored by lacoche's avatar lacoche
Browse files

gltf sample can now get gltf from link

parent 5db05740
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment