Example #1
0
    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);
                }
            }
        }
    }
Example #2
0
        public GLTFModel ParseGltfModel(HtmlNode htmlNode)
        {
            checkForNullHtmlNode(htmlNode);
            var gltfModel = new GLTFModel();

            ProcessPosition(htmlNode, gltfModel);
            ProcessRotation(htmlNode, gltfModel);
            gltfModel.Source = GetStringAttribute(htmlNode, "src");

            return(gltfModel);
        }
Example #3
0
        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);
        }
Example #4
0
 public void MakeGltfModel(GLTFModel model)
 {
     StartCoroutine(LoadGLTFFromWeb(model));
 }