IEnumerator Start()
    {
        yield return(InitScene());

        string entityId = "1";

        var entity = TestHelpers.CreateSceneEntity(scene, entityId);

        string shapeId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                                       JsonConvert.SerializeObject(new
        {
            src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"
        }));

        LoadWrapper_GLTF gltfShape = GLTFShape.GetLoaderForEntity(entity) as LoadWrapper_GLTF;

        yield return(new DCL.WaitUntil(() => gltfShape.alreadyLoaded, 7f));

        TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, -1, 8), Quaternion.identity, new Vector3(0.5f, 0.5f, 0.5f));

        var onClickComponentModel = new OnClick.Model()
        {
            type   = OnClick.NAME,
            uuid   = "pointerevent-1",
            button = this.button.ToString()
        };
        var onClickComponent = TestHelpers.EntityComponentCreate <OnClick, OnClick.Model>(scene, entity, onClickComponentModel, CLASS_ID_COMPONENT.UUID_CALLBACK);

        scene.sceneLifecycleHandler.SetInitMessagesDone();

        OnPointerEvent.enableInteractionHoverFeedback = true;
    }
Esempio n. 2
0
    void Update()
    {
        if (Input.GetKeyUp(KeyCode.Z))
        {
            counter++;
            counter %= 3;
            switch (counter)
            {
            case 0:
                string url = TestAssetsUtils.GetPath() + "/GLB/TrunkSeparatedTextures/Trunk.glb";
                Generate(url);
                break;

            case 1:
                string url2 = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb";
                Generate(url2);
                break;

            case 2:
                string url3 = TestAssetsUtils.GetPath() + "/GLB/DamagedHelmet/DamagedHelmet.glb";
                Generate(url3);
                break;
            }
        }
        else if (Input.GetKeyUp(KeyCode.X))
        {
            if (promiseList.Count > 0)
            {
                var promiseToRemove = promiseList[Random.Range(0, promiseList.Count)];
                keeper.Forget(promiseToRemove);
                promiseList.Remove(promiseToRemove);
            }
        }
    }
    public IEnumerator OBJShapeUpdate()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        Material placeholderLoadingMaterial = Resources.Load <Material>("Materials/AssetLoading");

        yield return(null);

        Assert.IsTrue(scene.entities[entityId].meshRootGameObject == null,
                      "Since the shape hasn't been updated yet, the child mesh shouldn't exist");

        TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.OBJ_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            src = TestAssetsUtils.GetPath() + "/OBJ/teapot.obj"
        }));

        LoadWrapper objShape = LoadableShape.GetLoaderForEntity(scene.entities[entityId]);

        yield return(new WaitUntil(() => objShape.alreadyLoaded));

        Assert.IsTrue(scene.entities[entityId].meshRootGameObject != null,
                      "Every entity with a shape should have the mandatory 'Mesh' object as a child");

        var childRenderer = scene.entities[entityId].meshRootGameObject.GetComponentInChildren <MeshRenderer>();

        Assert.IsTrue(childRenderer != null,
                      "Since the shape has already been updated, the child renderer should exist");
        Assert.AreNotSame(placeholderLoadingMaterial, childRenderer.sharedMaterial,
                          "Since the shape has already been updated, the child renderer found shouldn't have the 'AssetLoading' placeholder material");
    }
Esempio n. 4
0
        public static IEnumerator GLTFShapeIsResetWhenReenteringBounds(ParcelScene scene)
        {
            var entity = TestHelpers.CreateSceneEntity(scene);

            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model {
                position = new Vector3(18, 1, 18)
            });

            TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                              new
            {
                src = TestAssetsUtils.GetPath() + "/GLB/PalmTree_01.glb"
            }));
            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

            yield return(new UnityEngine.WaitUntil(() => gltfShape.alreadyLoaded));

            yield return(null);

            AssertMeshIsInvalid(entity.meshesInfo);

            // Move object to surpass the scene boundaries
            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model {
                position = new Vector3(8, 1, 8)
            });

            yield return(null);

            yield return(null);

            AssertMeshIsValid(entity.meshesInfo);
        }
    public IEnumerator UnloadWhenEntityDestroyedBeforeFinishing()
    {
        GameObject meshRootGameObject = new GameObject();

        string url = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb";

        IDCLEntity entity = Substitute.For <IDCLEntity>();

        entity.meshRootGameObject.Returns(meshRootGameObject);

        LoadWrapper_GLTF wrapper = Substitute.ForPartsOf <LoadWrapper_GLTF>();

        wrapper.entity = entity;
        wrapper.customContentProvider = new ContentProvider();

        bool loaded   = false;
        bool failed   = false;
        bool unloaded = false;

        wrapper.WhenForAnyArgs(x => x.Unload()).Do((info) => unloaded = true);

        wrapper.Load(url, loadWrapper => loaded = true, loadWrapper => failed = true);

        entity.OnCleanupEvent?.Invoke(entity);

        yield return(new WaitUntil(() => loaded || failed || unloaded));

        Object.Destroy(meshRootGameObject);

        Assert.IsTrue(unloaded, "Unload should be called if entity is cleaned up while loading mesh");
    }
Esempio n. 6
0
        public IEnumerator NotFailIfExternalTexturesAreMissing()
        {
            ContentServerUtils.MappingPair[] input =
            {
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.gltf", hash = "SimpleCubeWithSharedNormal.gltf"
                },
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.bin", hash = "SimpleCubeWithSharedNormal.bin"
                },
            };

            core.settings.baseUrl = TestAssetsUtils.GetPath() + "/GLTF/SimpleCube/";

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, core.settings);

            core.Convert(input);

            yield return(new WaitUntil(() => core.state.step == ABConverter.Core.State.Step.FINISHED));

            Assert.IsTrue(core.state.lastErrorCode == ABConverter.Core.ErrorCodes.SUCCESS);
            LogAssert.Expect(LogType.Error, new Regex(@"^.*?Buffer file not found"));
            LogAssert.Expect(LogType.Error, new Regex(@"^.*?Buffer file not found"));
        }
    public IEnumerator WorkCorrectlyWhenAttachedBeforeShape()
    {
        IDCLEntity entity = TestHelpers.CreateSceneEntity(scene);

        DCLTexture dclTexture = TestHelpers.CreateDCLTexture(
            scene,
            TestAssetsUtils.GetPath() + "/Images/atlas.png",
            DCLTexture.BabylonWrapMode.CLAMP,
            FilterMode.Bilinear);

        yield return(dclTexture.routine);

        BasicMaterial mat = TestHelpers.SharedComponentCreate <BasicMaterial, BasicMaterial.Model>
                                (scene, CLASS_ID.BASIC_MATERIAL,
                                new BasicMaterial.Model
        {
            texture   = dclTexture.id,
            alphaTest = 0.5f
        });

        yield return(mat.routine);

        TestHelpers.SharedComponentAttach(mat, entity);

        SphereShape shape = TestHelpers.SharedComponentCreate <SphereShape, SphereShape.Model>(scene,
                                                                                               CLASS_ID.SPHERE_SHAPE,
                                                                                               new SphereShape.Model {
        });

        TestHelpers.SharedComponentAttach(shape, entity);

        Assert.IsTrue(entity.meshRootGameObject != null);
        Assert.IsTrue(entity.meshRootGameObject.GetComponent <MeshRenderer>() != null);
        Assert.AreEqual(entity.meshRootGameObject.GetComponent <MeshRenderer>().sharedMaterial, mat.material);
    }
    protected override IEnumerator SetUp()
    {
        yield return(base.SetUp());

        TestHelpers.CreateSceneEntity(scene, ENTITY_ID);

        TestHelpers.CreateAndSetShape(scene, ENTITY_ID, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb"
        }));

        LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[ENTITY_ID]);

        yield return(new DCL.WaitUntil(() => gltfShape.alreadyLoaded));

        outlinerController = new BIWOutlinerController();
        entityHandler      = new BIWEntityHandler();

        var referencesController = BIWTestHelper.CreateReferencesControllerWithGenericMocks(
            outlinerController,
            entityHandler
            );

        outlinerController.Init(referencesController);
        entityHandler.Init(referencesController);

        entityHandler.EnterEditMode(scene);
        outlinerController.EnterEditMode(scene);

        entity = entityHandler.GetConvertedEntity(scene.entities[ENTITY_ID]);
    }
        protected override AssetPromise_GLTF CreatePromise()
        {
            string url  = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb";
            var    prom = new AssetPromise_GLTF(contentProvider, url);

            return(prom);
        }
    public static BaseDictionary <string, WearableItem> CreateTestCatalogLocal()
    {
        List <WearableItemDummy> wearables = Object.Instantiate(Resources.Load <WearableItemDummyListVariable>("TestCatalogArrayLocalAssets")).list;

        foreach (var wearableItem in wearables)
        {
            wearableItem.baseUrl = TestAssetsUtils.GetPath() + "/Avatar/Assets/";

            foreach (var rep in wearableItem.data.representations)
            {
                rep.contents = rep.contents.Select((x) =>
                {
                    x.hash = x.key;
                    return(x);
                })
                               .ToArray();
            }

            wearableItem.thumbnail = "";
        }

        CatalogController.wearableCatalog.Clear();
        var dummyWereables = wearables.Select(x => new KeyValuePair <string, WearableItem>(x.id, x)).ToArray();

        foreach (var item in dummyWereables)
        {
            CatalogController.wearableCatalog.Add(item.Key, item.Value);
        }

        return(CatalogController.wearableCatalog);
    }
Esempio n. 11
0
        public IEnumerator VideoTextureReplaceOtherTextureCorrectly()
        {
            DCLVideoTexture videoTexture = CreateDCLVideoTexture(scene, "it-wont-load-during-test");

            yield return(videoTexture.routine);

            Assert.IsTrue(videoTexture.attachedMaterials.Count == 0, "DCLVideoTexture started with attachedMaterials != 0");

            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(
                scene,
                TestAssetsUtils.GetPath() + "/Images/atlas.png",
                DCLTexture.BabylonWrapMode.CLAMP,
                FilterMode.Bilinear);

            yield return(dclTexture.routine);

            BasicMaterial mat = TestHelpers.SharedComponentCreate <BasicMaterial, BasicMaterial.Model>
                                    (scene, CLASS_ID.BASIC_MATERIAL,
                                    new BasicMaterial.Model
            {
                texture = dclTexture.id
            });

            yield return(mat.routine);

            yield return(TestHelpers.SharedComponentUpdate <BasicMaterial, BasicMaterial.Model>(mat, new BasicMaterial.Model()
            {
                texture = videoTexture.id
            }));

            Assert.IsTrue(videoTexture.attachedMaterials.Count == 1, $"did DCLVideoTexture attach to material? {videoTexture.attachedMaterials.Count} expected 1");
        }
Esempio n. 12
0
        protected AssetPromise_Texture CreatePromise()
        {
            string url  = TestAssetsUtils.GetPath() + "/Images/atlas.png";
            var    prom = new AssetPromise_Texture(url);

            return(prom);
        }
Esempio n. 13
0
        public IEnumerator NotGenerateColorMapsWithDXTnm()
        {
            ContentServerUtils.MappingPair[] input =
            {
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.gltf", hash = "SimpleCubeWithSharedNormal.gltf"
                },
                new ContentServerUtils.MappingPair {
                    file = "SimpleCubeWithSharedNormal.bin", hash = "SimpleCubeWithSharedNormal.bin"
                },
                new ContentServerUtils.MappingPair {
                    file = "Textures/Test.png", hash = "Test.png"
                }
            };

            core.settings.baseUrl  = TestAssetsUtils.GetPath() + "/GLTF/SimpleCube/";
            core.settings.verbose  = true;
            core.settings.dumpOnly = true;
            core.settings.deleteDownloadPathAfterFinished = false;

            env  = ABConverter.Environment.CreateWithDefaultImplementations();
            core = new ABConverter.Core(env, core.settings);

            core.Convert(input);

            yield return(new WaitUntil(() => core.state.step == ABConverter.Core.State.Step.FINISHED));

            Assert.IsTrue(core.state.lastErrorCode == ABConverter.Core.ErrorCodes.SUCCESS);

            string          importerPath = $"{core.finalDownloadedPath}Test.png{ABConverter.Config.DASH}Test.png.png";
            TextureImporter importer     = env.assetDatabase.GetImporterAtPath(importerPath) as TextureImporter;

            Assert.IsTrue(importer != null, "Texture importer is null!");
            Assert.IsTrue(TextureImporterType.NormalMap != importer.textureType, "Texture is used for color! It shouldn't be never importer as normal map!");
        }
Esempio n. 14
0
        protected AssetPromise_Texture CreatePromise(TextureWrapMode wrapmode, FilterMode filterMode)
        {
            string url = TestAssetsUtils.GetPath() + "/Images/atlas.png";
            AssetPromise_Texture prom = new AssetPromise_Texture(url, wrapmode, filterMode);

            return(prom);
        }
Esempio n. 15
0
        protected override AssetPromise_AB CreatePromise()
        {
            string contentUrl = TestAssetsUtils.GetPath() + "/AssetBundles/";
            string hash       = "QmYACL8SnbXEonXQeRHdWYbfm8vxvaFAWnsLHUaDG4ABp5";
            var    prom       = new AssetPromise_AB(contentUrl, hash);

            return(prom);
        }
Esempio n. 16
0
        protected override AssetPromise_AB_GameObject CreatePromise()
        {
            string contentUrl = TestAssetsUtils.GetPath() + "/AssetBundles/";
            string hash       = "QmNS4K7GaH63T9rhAfkrra7ADLXSEeco8FTGknkPnAVmKM";
            var    prom       = new AssetPromise_AB_GameObject(contentUrl, hash);

            return(prom);
        }
Esempio n. 17
0
        public void AudioClip_OnReadyBeforeLoading()
        {
            DCLAudioClip dclAudioClip = CreateAudioClip(TestAssetsUtils.GetPath() + "/Audio/short_effect.ogg", true, true, 1);
            bool         isOnReady    = false;

            dclAudioClip.CallWhenReady((x) => { isOnReady = true; });

            Assert.IsTrue(isOnReady); //DCLAudioClip is ready on creation
        }
Esempio n. 18
0
        public void Texture_OnReadyBeforeLoading()
        {
            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene, TestAssetsUtils.GetPath() + "/Images/avatar.png");
            bool       isOnReady  = false;

            dclTexture.CallWhenReady((x) => { isOnReady = true; });

            Assert.IsTrue(isOnReady); //DCLTexture is ready on creation
        }
Esempio n. 19
0
        public IEnumerator FailCorrectlyWhenGivenWrongURL()
        {
            var keeper = new AssetPromiseKeeper_GLTF();

            //NOTE(Brian): Expect the 404 error
            LogAssert.Expect(LogType.Error, new Regex("^*.?404"));

            string url = TestAssetsUtils.GetPath() + "/non_existing_url.glb";

            AssetPromise_GLTF prom  = new AssetPromise_GLTF(scene.contentProvider, url);
            Asset_GLTF        asset = null;
            bool failEventCalled1   = false;

            prom.OnSuccessEvent += (x) => { asset = x; };
            prom.OnFailEvent    += (x) => { failEventCalled1 = true; };

            AssetPromise_GLTF prom2  = new AssetPromise_GLTF(scene.contentProvider, url);
            Asset_GLTF        asset2 = null;
            bool failEventCalled2    = false;

            prom2.OnSuccessEvent += (x) => { asset2 = x; };
            prom2.OnFailEvent    += (x) => { failEventCalled2 = true; };

            AssetPromise_GLTF prom3  = new AssetPromise_GLTF(scene.contentProvider, url);
            Asset_GLTF        asset3 = null;
            bool failEventCalled3    = false;

            prom3.OnSuccessEvent += (x) => { asset3 = x; };
            prom3.OnFailEvent    += (x) => { failEventCalled3 = true; };

            keeper.Keep(prom);
            keeper.Keep(prom2);
            keeper.Keep(prom3);

            Assert.AreEqual(3, keeper.waitingPromisesCount);

            yield return(prom);

            yield return(prom2);

            yield return(prom3);

            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom.state);
            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom2.state);
            Assert.AreNotEqual(AssetPromiseState.FINISHED, prom3.state);

            Assert.IsTrue(failEventCalled1);
            Assert.IsTrue(failEventCalled2);
            Assert.IsTrue(failEventCalled3);

            Assert.IsFalse(asset != null);
            Assert.IsFalse(asset2 != null);
            Assert.IsFalse(asset3 != null);

            Assert.IsFalse(keeper.library.Contains(asset));
            Assert.AreNotEqual(1, keeper.library.masterAssets.Count);
        }
Esempio n. 20
0
        public IEnumerator Texture_OnReadyWaitLoading()
        {
            DCLTexture dclTexture = TestHelpers.CreateDCLTexture(scene, TestAssetsUtils.GetPath() + "/Images/avatar.png");
            bool       isOnReady  = false;

            dclTexture.CallWhenReady((x) => { isOnReady = true; });
            yield return(dclTexture.routine);

            Assert.IsTrue(isOnReady);
        }
Esempio n. 21
0
        public IEnumerator AudioClip_OnReadyWaitLoading()
        {
            DCLAudioClip dclAudioClip = CreateAudioClip(TestAssetsUtils.GetPath() + "/Audio/short_effect.ogg", true, true, 1);
            bool         isOnReady    = false;

            dclAudioClip.CallWhenReady((x) => { isOnReady = true; });
            yield return(dclAudioClip.routine);

            Assert.IsTrue(isOnReady);
        }