IEnumerator LoadGLTFFromWeb(GLTFModel model) { using (UnityWebRequest www = UnityWebRequest.Get(model.Source)) { yield return(www.Send()); if (www.isNetworkError || www.isHttpError) { Debug.Log(www.error); } else { Guid guid = Guid.NewGuid(); string fileName = guid.ToString(); string savePath = string.Format("{0}/{1}.glb", Application.persistentDataPath, fileName); File.WriteAllBytes(savePath, www.downloadHandler.data); GameObject newObject = Importer.LoadFromFile(savePath); if (newObject != null) { newObject.transform.position = new UnityEngine.Vector3(model.Position.X, model.Position.Y, model.Position.Z); newObject.transform.rotation = Quaternion.Euler(model.Rotation.X, model.Rotation.Y, model.Rotation.Z); } else { Debug.Log("Error loading " + model.Source); } } } }
public GLTFModel ParseGltfModel(HtmlNode htmlNode) { checkForNullHtmlNode(htmlNode); var gltfModel = new GLTFModel(); ProcessPosition(htmlNode, gltfModel); ProcessRotation(htmlNode, gltfModel); gltfModel.Source = GetStringAttribute(htmlNode, "src"); return(gltfModel); }
public void AFrameScenePresenter__MakeScene__ShouldHandleGltfModel() { // arrange var aFrameSceneBehavior = Substitute.For <IAFrameSceneBehavior>(); var gameObject = new GLTFModel(); _scene.DocumentElements.Add(gameObject); var presenter = new AFrameScenePresenter(aFrameSceneBehavior); // act presenter.MakeScene(_scene); // assert aFrameSceneBehavior.Received().MakeGltfModel(gameObject); }
public void MakeGltfModel(GLTFModel model) { StartCoroutine(LoadGLTFFromWeb(model)); }