예제 #1
0
    public IEnumerator AttachedGetsReplacedOnNewAttachment()
    {
        DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

        // set first GLTF
        string gltfId1 = TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                                       JsonConvert.SerializeObject(new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb"
        }));
        var gltf1 = scene.GetSharedComponent(gltfId1);

        LoadWrapper gltfLoader = GLTFShape.GetLoaderForEntity(entity);

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

        Assert.AreEqual(gltf1, entity.GetSharedComponent(typeof(BaseShape)));

        // set second GLTF
        string gltfId2 = TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                                       JsonConvert.SerializeObject(new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/Trunk/Trunk.glb"
        }));

        gltfLoader = GLTFShape.GetLoaderForEntity(entity);
        yield return(new WaitUntil(() => gltfLoader.alreadyLoaded));

        Assert.AreEqual(scene.GetSharedComponent(gltfId2), entity.GetSharedComponent(typeof(BaseShape)));
        Assert.IsFalse(gltf1.attachedEntities.Contains(entity));
    }
예제 #2
0
    public IEnumerator VisibleProperty()
    {
        string entityId = "entityId";

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

        yield return(null);

        // Create shape component
        var shapeModel = new LoadableShape <LoadWrapper_GLTF, LoadableShape.Model> .Model();

        shapeModel.src = Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb";

        var shapeComponent = TestHelpers.SharedComponentCreate <LoadableShape <LoadWrapper_GLTF, LoadableShape.Model>, LoadableShape <LoadWrapper_GLTF, LoadableShape.Model> .Model>(scene, CLASS_ID.GLTF_SHAPE, shapeModel);

        yield return(shapeComponent.routine);

        TestHelpers.SharedComponentAttach(shapeComponent, entity);

        var shapeLoader = GLTFShape.GetLoaderForEntity(entity);

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

        yield return(TestHelpers.TestShapeVisibility(shapeComponent, shapeModel, entity));
    }
    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 = DCL.Helpers.Utils.GetTestsAssetsPath() + "/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;
    }
예제 #4
0
    public IEnumerator PreExistentShapeImmediateUpdate()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        var componentId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                                            new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/Trunk/Trunk.glb"
        }));

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

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

        TestHelpers.UpdateShape(scene, componentId, JsonConvert.SerializeObject(
                                    new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb"
        }));

        gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
        yield return(new WaitUntil(() => gltfShape.alreadyLoaded));

        Assert.AreEqual(1,
                        scene.entities[entityId].gameObject.GetComponentsInChildren <InstantiatedGLTFObject>().Length,
                        "Only 1 'InstantiatedGLTFObject' should remain once the GLTF shape has been updated");
    }
예제 #5
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 = Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb"
            }));
            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

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

            Assert.IsTrue(MeshIsInvalid(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);

            Assert.IsFalse(MeshIsInvalid(entity.meshesInfo));
        }
    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]);
    }
예제 #7
0
        public IEnumerator NonSkeletalAnimationsSupport()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            TestHelpers.SetEntityTransform(scene, entity, new Vector3(8, 2, 8), Quaternion.identity, Vector3.one);

            Assert.IsTrue(entity.gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null,
                          "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");

            TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                          JsonConvert.SerializeObject(new
            {
                src = Utils.GetTestsAssetsPath() + "/GLB/non-skeletal-3-transformations.glb"
            }));

            string clipName = "All";

            DCLAnimator.Model animatorModel = new DCLAnimator.Model
            {
                states = new DCLAnimator.Model.DCLAnimationState[]
                {
                    new DCLAnimator.Model.DCLAnimationState
                    {
                        name    = "clip01",
                        clip    = clipName,
                        playing = false,
                        weight  = 1,
                        speed   = 1,
                        looping = false
                    }
                }
            };

            DCLAnimator animator = TestHelpers.EntityComponentCreate <DCLAnimator, DCLAnimator.Model>(scene, entity, animatorModel);

            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

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

            Assert.IsTrue(!animator.animComponent.isPlaying);
            Assert.AreEqual(animator.animComponent.clip.name, clipName);
            Assert.IsFalse(animator.animComponent.clip.wrapMode == WrapMode.Loop);

            Transform animatedGameObject = animator.animComponent.transform.GetChild(0);

            Vector3    originalScale = animatedGameObject.transform.localScale;
            Vector3    originalPos   = animatedGameObject.transform.localPosition;
            Quaternion originalRot   = animatedGameObject.transform.localRotation;

            // start animation
            animatorModel.states[0].playing = true;
            yield return(TestHelpers.EntityComponentUpdate(animator, animatorModel));

            yield return(new WaitForSeconds(3f));

            Assert.IsFalse(animatedGameObject.localScale == originalScale);
            Assert.IsFalse(animatedGameObject.localPosition == originalPos);
            Assert.IsFalse(animatedGameObject.localRotation == originalRot);
        }
예제 #8
0
        public IEnumerator DCLAnimatorResetAllAnimations()
        {
            var gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero,
                                                                  new LoadableShape.Model
            {
                src = Utils.GetTestsAssetsPath() + "/GLB/Shark/shark_anim.gltf"
            });
            var entity = gltfShape.attachedEntities.First();

            DCLAnimator.Model animatorModel = new DCLAnimator.Model
            {
                states = new[]
                {
                    new DCLAnimator.Model.DCLAnimationState
                    {
                        name    = "Bite",
                        clip    = "shark_skeleton_bite",
                        playing = true,
                        weight  = 1,
                        speed   = 1
                    },
                    new DCLAnimator.Model.DCLAnimationState
                    {
                        name    = "Swim",
                        clip    = "shark_skeleton_swim",
                        playing = true,
                        weight  = 1,
                        speed   = 1
                    }
                }
            };

            DCLAnimator animator =
                TestHelpers.EntityComponentCreate <DCLAnimator, DCLAnimator.Model>(scene, entity, animatorModel);
            LoadWrapper gltfLoader = GLTFShape.GetLoaderForEntity(entity);

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

            yield return(animator.routine);

            yield return(new WaitForSeconds(1.5f));

            Animation animation = entity.gameObject.GetComponentInChildren <Animation>();

            foreach (AnimationState animState in animation)
            {
                Assert.AreNotEqual(0f, animState.time);
            }

            animatorModel.states[0].shouldReset = true;
            animatorModel.states[1].shouldReset = true;

            yield return(TestHelpers.EntityComponentUpdate(animator, animatorModel));

            foreach (AnimationState animState in animation)
            {
                Assert.AreEqual(0f, animState.time);
            }
        }
예제 #9
0
        public static GLTFShape CreateEntityWithGLTFShape(ParcelScene scene, Vector3 position, GLTFShape.Model model,
                                                          out DecentralandEntity entity)
        {
            entity = CreateSceneEntity(scene);
            GLTFShape gltfShape = AttachGLTFShape(entity, scene, position, model);

            return(gltfShape);
        }
예제 #10
0
        public static GLTFShape AttachGLTFShape(DecentralandEntity entity, ParcelScene scene, Vector3 position, GLTFShape.Model model)
        {
            string    componentId = GetComponentUniqueId(scene, "gltfShape", (int)CLASS_ID.GLTF_SHAPE, entity.entityId);
            GLTFShape gltfShape   = SharedComponentCreate <GLTFShape, GLTFShape.Model>(scene, CLASS_ID.GLTF_SHAPE, model);

            SetEntityTransform(scene, entity, position, Quaternion.identity, Vector3.one);
            SharedComponentAttach(gltfShape, entity);
            return(gltfShape);
        }
예제 #11
0
    public void OnReadyBeforeLoading()
    {
        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/Trevor/Trevor.glb", out DecentralandEntity entity);

        bool isOnReady = false;

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

        Assert.IsFalse(isOnReady);
    }
예제 #12
0
        public IEnumerator ResetMaterialCorrectlyWhenInvalidEntitiesAreRemoved()
        {
            var entity = TestHelpers.CreateSceneEntity(scene);

            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model {
                position = new Vector3(8, 1, 8)
            });
            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);

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

            yield return(null);

            SBC_Asserts.AssertMeshIsInvalid(entity.meshesInfo);

            TestHelpers.RemoveSceneEntity(scene, entity.entityId);

            Environment.i.platform.parcelScenesCleaner.ForceCleanup();

            yield return(null);

            var entity2 = TestHelpers.CreateSceneEntity(scene);

            TestHelpers.SetEntityTransform(scene, entity2, new DCLTransform.Model {
                position = new Vector3(8, 1, 8)
            });
            TestHelpers.CreateAndSetShape(scene, entity2.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                              new
            {
                src = TestAssetsUtils.GetPath() + "/GLB/PalmTree_01.glb"
            }));

            LoadWrapper gltfShape2 = GLTFShape.GetLoaderForEntity(entity2);

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

            yield return(null);

            SBC_Asserts.AssertMeshIsValid(entity2.meshesInfo);
        }
예제 #13
0
    public IEnumerator OnReadyWaitLoading()
    {
        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, TestAssetsUtils.GetPath() + "/GLB/Trevor/Trevor.glb", out IDCLEntity entity);

        bool isOnReady = false;

        gltfShape.CallWhenReady((x) => { isOnReady = true; });
        yield return(TestHelpers.WaitForGLTFLoad(entity));

        Assert.IsTrue(isOnReady);
    }
예제 #14
0
    public IEnumerator OnReadyAfterLoadingInstantlyCalled()
    {
        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/Trevor/Trevor.glb", out DecentralandEntity entity);

        yield return(TestHelpers.WaitForGLTFLoad(entity));

        bool isOnReady = false;

        gltfShape.CallWhenReady((x) => { isOnReady = true; });
        Assert.IsTrue(isOnReady);
    }
예제 #15
0
    public void OnReadyWithoutAttachInstantlyCalled()
    {
        GLTFShape gltfShape = TestHelpers.SharedComponentCreate <GLTFShape, GLTFShape.Model>(scene, CLASS_ID.GLTF_SHAPE, new LoadableShape.Model()
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/Trevor/Trevor.glb"
        });

        bool isOnReady = false;

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

        Assert.IsTrue(isOnReady);
    }
예제 #16
0
        public IEnumerator UpdateAnimationComponent()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            Assert.IsTrue(entity.gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null,
                          "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");

            TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                          JsonConvert.SerializeObject(new
            {
                src = Utils.GetTestsAssetsPath() + "/GLB/CesiumMan/CesiumMan.glb"
            }));

            string clipName = "animation:0";

            DCLAnimator.Model animatorModel = new DCLAnimator.Model
            {
                states = new DCLAnimator.Model.DCLAnimationState[]
                {
                    new DCLAnimator.Model.DCLAnimationState
                    {
                        name    = "clip01",
                        clip    = clipName,
                        playing = true,
                        weight  = 1,
                        speed   = 1,
                        looping = false
                    }
                }
            };

            DCLAnimator animator = TestHelpers.EntityComponentCreate <DCLAnimator, DCLAnimator.Model>(scene, entity, animatorModel);

            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

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

            Assert.IsTrue(animator.animComponent.isPlaying);
            Assert.AreEqual(animator.animComponent.clip.name, clipName);
            Assert.IsFalse(animator.animComponent.clip.wrapMode == WrapMode.Loop);

            yield return(null);

            // update component properties
            animatorModel.states[0].playing = false;
            animatorModel.states[0].looping = true;
            yield return(TestHelpers.EntityComponentUpdate(animator, animatorModel));

            Assert.IsFalse(animator.animComponent.isPlaying);
            Assert.IsTrue(animator.animComponent.clip.wrapMode == WrapMode.Loop);
        }
예제 #17
0
    public IEnumerator SceneObjectFloorObject()
    {
        SceneObject sceneObject = BuilderInWorldUtils.CreateFloorSceneObject();

        LoadParcelScenesMessage.UnityParcelScene data = scene.sceneData;
        data.contents = new List <ContentServerUtils.MappingPair>();
        data.baseUrl  = BuilderInWorldSettings.BASE_URL_CATALOG;

        foreach (KeyValuePair <string, string> content in sceneObject.contents)
        {
            ContentServerUtils.MappingPair mappingPair = new ContentServerUtils.MappingPair();
            mappingPair.file = content.Key;
            mappingPair.hash = content.Value;
            bool found = false;
            foreach (ContentServerUtils.MappingPair mappingPairToCheck in data.contents)
            {
                if (mappingPairToCheck.file == mappingPair.file)
                {
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                data.contents.Add(mappingPair);
            }
        }

        Environment.i.world.sceneController.UpdateParcelScenesExecute(data);


        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            assetId = BuilderInWorldSettings.FLOOR_TEXTURE_VALUE,
            src     = BuilderInWorldSettings.FLOOR_MODEL
        }));;

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

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

        Assert.IsTrue(
            scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() != null,
            "Floor should be loaded, is the SceneObject not working anymore?");
    }
예제 #18
0
    public IEnumerator LoadModel(string path, System.Action <InstantiatedGLTFObject> OnFinishLoading)
    {
        string             src       = Utils.GetTestsAssetsPath() + path;
        DecentralandEntity entity    = null;
        GLTFShape          gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, src, out entity);

        yield return(gltfShape.routine);

        yield return(new WaitForSeconds(4));

        if (OnFinishLoading != null)
        {
            OnFinishLoading.Invoke(entity.meshRootGameObject.GetComponentInChildren <InstantiatedGLTFObject>());
        }
    }
예제 #19
0
    public void CustomContentProvider()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        string mockupAssetId = "cdd5a4ea94388dd21babdecd26dd560f739dce2fbb8c99cc10a45bb8306b6076";
        string mockupKey     = "key";
        string mockupValue   = "Value";

        SceneAssetPack sceneAssetPack = new SceneAssetPack();

        sceneAssetPack.assets = new System.Collections.Generic.List <SceneObject>();
        sceneAssetPack.id     = "mockupId";

        SceneObject sceneObject = new SceneObject();

        sceneObject.id       = mockupAssetId;
        sceneObject.contents = new System.Collections.Generic.Dictionary <string, string>();
        sceneObject.contents.Add(mockupKey, mockupValue);

        sceneAssetPack.assets.Add(sceneObject);

        AssetCatalogBridge.AddSceneAssetPackToCatalog(sceneAssetPack);

        TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            assetId = mockupAssetId,
            src     = Utils.GetTestsAssetsPath() + "/GLB/Lantern/Lantern.glb"
        }));


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

        if (!(gltfShape is LoadWrapper_GLTF))
        {
            Assert.Fail();
        }


        LoadWrapper_GLTF gltfWrapper           = (LoadWrapper_GLTF)gltfShape;
        ContentProvider  customContentProvider = AssetCatalogBridge.GetContentProviderForAssetIdInSceneObjectCatalog(mockupAssetId);

        Assert.AreEqual(customContentProvider.baseUrl, gltfWrapper.customContentProvider.baseUrl);
        Assert.AreEqual(mockupKey, gltfWrapper.customContentProvider.contents[0].file);
        Assert.AreEqual(mockupValue, gltfWrapper.customContentProvider.contents[0].hash);
    }
        public IEnumerator AudioSourceWithMeshIsDisabled()
        {
            TestHelpers.CreateEntityWithGLTFShape(scene, new Vector3(8, 1, 8), TestAssetsUtils.GetPath() + "/GLB/PalmTree_01.glb", out var entity);
            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

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

            TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model {
                position = new Vector3(-28, 1, 8)
            });
            yield return(TestHelpers.CreateAudioSourceWithClipForEntity(entity));

            AudioSource dclAudioSource = entity.gameObject.GetComponentInChildren <AudioSource>();

            Assert.AreEqual(0, dclAudioSource.volume);
        }
        public IEnumerator NotLeaveCollidersOnRecycledMeshes()
        {
            // 1. Instantiate entity and add an OnPointerDown component
            string entity1Id = "1";
            var    entity1   = TestHelpers.CreateSceneEntity(scene, entity1Id);

            string onPointerId         = "pointerevent-1";
            var    onPointerEventModel = new OnPointerDown.Model()
            {
                type = OnPointerDown.NAME,
                uuid = onPointerId
            };
            var onPointerDownComponent = TestHelpers.EntityComponentCreate <OnPointerDown, OnPointerDown.Model>(scene, entity1,
                                                                                                                onPointerEventModel, CLASS_ID_COMPONENT.UUID_CALLBACK);

            // 2. Attach a shape
            var shapeModel = new LoadableShape <LoadWrapper_GLTF, LoadableShape.Model> .Model();

            shapeModel.src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb";
            var shapeComponentId = TestHelpers.CreateAndSetShape(scene, entity1Id, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(shapeModel));

            LoadWrapper gltfShapeLoader1 = GLTFShape.GetLoaderForEntity(scene.entities[entity1Id]);

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

            yield return(null);

            // 3. Save the mesh GO reference
            Transform shapeInstanceRootTransform = entity1.meshRootGameObject.transform.GetChild(0);

            Debug.Log("saved mesh GO: ", shapeInstanceRootTransform);

            // 4. Remove shape so that it returns to its pool
            entity1.RemoveSharedComponent(typeof(BaseShape));
            yield return(null);

            // 5. Check that the pooled mesh doesn't have the collider children and the onPointerEvent component
            // doesn't have any instantiated collider (since its entity doesn't have a mesh now)
            var childMeshColliders = shapeInstanceRootTransform.GetComponentsInChildren <MeshCollider>(true);

            foreach (MeshCollider collider in childMeshColliders)
            {
                Assert.IsTrue(collider.gameObject.layer != PhysicsLayers.onPointerEventLayer);
            }

            Assert.IsNull(onPointerDownComponent.pointerEventHandler.eventColliders.colliders);
        }
예제 #22
0
        public IEnumerator CreateAnimationComponent()
        {
            DecentralandEntity entity = TestHelpers.CreateSceneEntity(scene);

            Assert.IsTrue(entity.gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null,
                          "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist");

            TestHelpers.CreateAndSetShape(scene, entity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE,
                                          JsonConvert.SerializeObject(new
            {
                src = Utils.GetTestsAssetsPath() + "/GLB/CesiumMan/CesiumMan.glb"
            }));

            DCLAnimator.Model animatorModel = new DCLAnimator.Model
            {
                states = new DCLAnimator.Model.DCLAnimationState[]
                {
                    new DCLAnimator.Model.DCLAnimationState
                    {
                        name    = "clip01",
                        clip    = "animation:0",
                        playing = true,
                        weight  = 1,
                        speed   = 1
                    }
                }
            };

            DCLAnimator animator =
                TestHelpers.EntityComponentCreate <DCLAnimator, DCLAnimator.Model>(scene, entity, animatorModel);

            LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity);

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

            Assert.IsTrue(entity.gameObject.GetComponentInChildren <Animation>() != null,
                          "'GLTFScene' child object with 'Animator' component should exist if the GLTF was loaded correctly.");
            Assert.IsTrue(entity.gameObject.GetComponentInChildren <DCLAnimator>() != null,
                          "'GLTFScene' child object with 'DCLAnimator' component should exist if the GLTF was loaded correctly.");

            yield return(animator.routine);

            animator = entity.gameObject.GetComponentInChildren <DCLAnimator>();

            Assert.IsTrue(animator.GetStateByString("clip01") != null, "dclAnimator.GetStateByString fail!");
            Assert.IsTrue(animator.model.states[0].clip != null, "dclAnimator clipReference is null!");
        }
예제 #23
0
    public IEnumerator LoadModel(string path, System.Action <IDCLEntity, InstantiatedGLTFObject> OnFinishLoading)
    {
        string src = Utils.GetTestsAssetsPath() + path;

        IDCLEntity entity = null;

        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, src, out entity);

        yield return(gltfShape.routine);

        yield return(new WaitForAllMessagesProcessed());

        yield return(new WaitUntil(() => GLTFComponent.downloadingCount == 0));

        if (OnFinishLoading != null)
        {
            OnFinishLoading.Invoke(entity, entity.meshRootGameObject.GetComponentInChildren <InstantiatedGLTFObject>());
        }
    }
예제 #24
0
    public IEnumerator OnDestroyWhileLoading()
    {
        GLTFShape gltfShape  = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/Trevor/Trevor.glb", out DecentralandEntity entity);
        GLTFShape gltfShape2 = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb", out DecentralandEntity entity2);
        GLTFShape gltfShape3 = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/DamagedHelmet/DamagedHelmet.glb", out DecentralandEntity entity3);

        TestHelpers.SetEntityParent(scene, entity2, entity);
        TestHelpers.SetEntityParent(scene, entity3, entity);

        yield return(null);

        yield return(null);

        yield return(null);

        Object.Destroy(entity.gameObject);

        yield return(null);
    }
    public IEnumerator ProcessTextureOffsetAndScale()
    {
        yield return(InitVisualTestsScene("GLTFImporterVisualTests_ProcessTextureOffsetAndScale"));

        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, TestAssetsUtils.GetPath() + "/GLB/PlaneUVsOffset/planeUVsOffset.glb", out IDCLEntity entity);

        yield return(gltfShape.routine);

        yield return(new WaitForAllMessagesProcessed());

        yield return(new WaitUntil(() => GLTFComponent.downloadingCount == 0));

        Vector3 camPos    = new Vector3(0f, 2f, 5f);
        Vector3 camTarget = new Vector3(7.5f, 0f, 10f);

        VisualTestHelpers.RepositionVisualTestsCamera(VisualTestController.i.camera, camPos, camTarget);
        yield return(new WaitForAllMessagesProcessed());

        yield return(VisualTestHelpers.TakeSnapshot());
    }
예제 #26
0
    public IEnumerator ProcessTexturesUVs()
    {
        yield return(InitVisualTestsScene("GLTFImporterVisualTests_ProcessTexturesUVs"));

        GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, Utils.GetTestsAssetsPath() + "/GLB/PlaneUVsMultichannel/PlaneUVsMultichannel.glb", out DecentralandEntity entity);

        yield return(gltfShape.routine);

        yield return(new WaitForAllMessagesProcessed());

        yield return(new WaitUntil(() => GLTFComponent.downloadingCount == 0));

        Vector3 camPos    = new Vector3(0f, 2f, 5f);
        Vector3 camTarget = new Vector3(7.5f, 0f, 10f);

        VisualTestHelpers.RepositionVisualTestsCamera(camPos, camTarget);
        yield return(new WaitForAllMessagesProcessed());

        yield return(VisualTestHelpers.TakeSnapshot());
    }
예제 #27
0
    public IEnumerator TestEntityInsidePublish()
    {
        //Arrange
        DCLBuilderInWorldEntity entity = biwEntityHandler.CreateEmptyEntity(scene, Vector3.zero, Vector3.zero);

        TestHelpers.CreateAndSetShape(scene, entity.rootEntity.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                          new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/Trunk/Trunk.glb"
        }));

        LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entity.rootEntity.entityId]);

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

        //Act
        entity.rootEntity.gameObject.transform.position = new Vector3(5, 0, 5);

        //Assert
        Assert.IsTrue(biwPublishController.CanPublish());
    }
예제 #28
0
        public static IEnumerator GLTFShapeIsInvalidatedWhenStartingOutOfBounds(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);
        }
예제 #29
0
    private void AddShape(CatalogItem catalogItem, DCLBuilderInWorldEntity entity)
    {
        if (catalogItem.IsNFT())
        {
            NFTShape nftShape = (NFTShape)sceneToEdit.SharedComponentCreate(catalogItem.id, Convert.ToInt32(CLASS_ID.NFT_SHAPE));
            nftShape.model         = new NFTShape.Model();
            nftShape.model.color   = new Color(0.6404918f, 0.611472f, 0.8584906f);
            nftShape.model.src     = catalogItem.model;
            nftShape.model.assetId = catalogItem.id;

            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, nftShape.id);
        }
        else
        {
            GLTFShape mesh = (GLTFShape)sceneToEdit.SharedComponentCreate(catalogItem.id, Convert.ToInt32(CLASS_ID.GLTF_SHAPE));
            mesh.model         = new LoadableShape.Model();
            mesh.model.src     = catalogItem.model;
            mesh.model.assetId = catalogItem.id;
            sceneToEdit.SharedComponentAttach(entity.rootEntity.entityId, mesh.id);
        }
    }
예제 #30
0
    public IEnumerator PreExistentShapeUpdate()
    {
        string entityId = "1";

        TestHelpers.CreateSceneEntity(scene, entityId);

        var componentId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(
                                                            new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/Trunk/Trunk.glb"
        }));

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

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

        {
            var gltfObject = scene.entities[entityId].gameObject.GetComponentInChildren <InstantiatedGLTFObject>();

            Assert.IsTrue(gltfObject != null, "InstantiatedGLTFObject is null in first object!");
            Assert.IsTrue(gltfObject.transform.Find("TreeStump_01") != null, "Can't find \"TreeStump_01!\"");
        }

        TestHelpers.UpdateShape(scene, componentId, JsonConvert.SerializeObject(
                                    new
        {
            src = Utils.GetTestsAssetsPath() + "/GLB/PalmTree_01.glb"
        }));

        gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]);
        yield return(new WaitUntil(() => gltfShape.alreadyLoaded));

        {
            var gltfObject = scene.entities[entityId].gameObject.GetComponentInChildren <InstantiatedGLTFObject>();

            Assert.IsTrue(gltfObject != null, "InstantiatedGLTFObject is null in second object!");
            Assert.IsTrue(gltfObject.transform.Find("PalmTree_01") != null,
                          "Can't find \"PalmTree_01\"!");
        }
    }