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)); }
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"); }
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; }
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]); }
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)); }
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); }
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); } }
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); }
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?"); }
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); }
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); }
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!"); }
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()); }
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); }
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\"!"); } }
public IEnumerator BuilderInWorldRendererEnableOutsideParcel() { //Arrange WebRequestController.Create(); ParcelScene scene = (ParcelScene)Environment.i.world.sceneController.CreateTestScene(); Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(new SceneBoundsFeedbackStyle_Simple()); var biwStyle = new SceneBoundsFeedbackStyle_BIW(); string entityId = "1"; TestHelpers.CreateSceneEntity(scene, entityId); Assert.IsTrue( scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null, "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist"); TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( new { src = TestAssetsUtils.GetPath() + "/GLB/Trunk/Trunk.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]); yield return(new DCL.WaitUntil(() => gltfShape.alreadyLoaded)); //Act scene.entities[entityId].gameObject.transform.position = new Vector3(100, 100, 100); Environment.i.world.sceneBoundsChecker.SetFeedbackStyle(biwStyle); yield return(null); //Assert foreach (var renderer in scene.entities[entityId].renderers) { Assert.IsTrue(renderer.enabled); } }
protected override IEnumerator SetUp() { yield return(base.SetUp()); BuilderInWorldController controller = Resources.FindObjectsOfTypeAll <BuilderInWorldController>()[0]; outlinerController = controller.outlinerController; TestHelpers.CreateSceneEntity(scene, ENTITY_ID); TestHelpers.CreateAndSetShape(scene, ENTITY_ID, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( new { src = Utils.GetTestsAssetsPath() + "/GLB/Trunk/Trunk.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[ENTITY_ID]); yield return(new WaitUntil(() => gltfShape.alreadyLoaded)); controller.builderInWorldEntityHandler.EnterEditMode(scene); entity = controller.builderInWorldEntityHandler.GetConvertedEntity(scene.entities[ENTITY_ID]); }
public IEnumerator NotCreateCollidersOnLoadingShape() { // 1. Instantiate entity and add an OnPointerDown component string entityId = "1"; var entity = TestHelpers.CreateSceneEntity(scene, entityId); string onPointerId = "pointerevent-1"; var model = new OnPointerEvent.Model() { type = OnPointerDown.NAME, uuid = onPointerId }; var onPointerDownComponent = TestHelpers.EntityComponentCreate <OnPointerDown, OnPointerEvent.Model>(scene, entity, model, CLASS_ID_COMPONENT.UUID_CALLBACK); // 2. Attach a shape var shapeModel = new LoadableShape.Model(); shapeModel.src = TestAssetsUtils.GetPath() + "/GLB/Lantern/Lantern.glb"; var componentId = TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(shapeModel)); // 3. Change a shape component property while it loads shapeModel.visible = false; TestHelpers.UpdateShape(scene, componentId, JsonConvert.SerializeObject(shapeModel)); var pointerEventColliders = onPointerDownComponent.pointerEventHandler.eventColliders.colliders; Assert.IsTrue(pointerEventColliders == null || pointerEventColliders.Length == 0); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]); yield return(new WaitUntil(() => gltfShape.alreadyLoaded)); // 4. Check if the PointerEvent colliders were created pointerEventColliders = onPointerDownComponent.pointerEventHandler.eventColliders.colliders; Assert.IsTrue(pointerEventColliders != null && pointerEventColliders.Length > 0); }
public IEnumerator StandardConfigurations() { yield return(InitVisualTestsScene("PBRMaterialVisualTests_StandardConfigurations")); Vector3 camTarget = new Vector3(8, 3, 8); VisualTestHelpers.RepositionVisualTestsCamera(VisualTestController.i.camera, new Vector3(9, 4, 17), camTarget); GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, new LoadableShape.Model { src = TestAssetsUtils.GetPath() + "/GLB/MaterialsScene.glb" }, out IDCLEntity entity); TestHelpers.SetEntityTransform(scene, entity, new DCLTransform.Model { position = new Vector3(0, 0, 8), rotation = Quaternion.Euler(90, 180, 0) }); LoadWrapper loader = GLTFShape.GetLoaderForEntity(entity); yield return(new WaitUntil(() => loader.alreadyLoaded)); yield return(VisualTestHelpers.TakeSnapshot()); }
public IEnumerator ShapeUpdate() { string entityId = "1"; TestHelpers.CreateSceneEntity(scene, entityId); Assert.IsTrue( scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null, "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist"); 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)); Assert.IsTrue( scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() != null, "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctly"); }
public static IEnumerator WaitForGLTFLoad(DecentralandEntity entity) { LoadWrapper_GLTF wrapper = GLTFShape.GetLoaderForEntity(entity) as LoadWrapper_GLTF; return(new WaitUntil(() => wrapper.alreadyLoaded)); }
public IEnumerator AnimationStartsAutomaticallyWithNoDCLAnimator() { // GLTFShape without DCLAnimator var 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 = TestAssetsUtils.GetPath() + "/GLB/CesiumMan/CesiumMan.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity); yield return(new WaitUntil(() => gltfShape.alreadyLoaded == true)); Animation animation = entity.meshRootGameObject.GetComponentInChildren <Animation>(); Assert.IsTrue(animation != null); Assert.IsTrue(animation.isPlaying); // GLTFShape with DCLAnimator var entity2 = TestHelpers.CreateSceneEntity(scene); Assert.IsTrue(entity2.gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null, "Since the shape hasn't been updated yet, the 'GLTFScene' child object shouldn't exist"); TestHelpers.CreateAndSetShape(scene, entity2.entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject(new { src = TestAssetsUtils.GetPath() + "/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 = false, weight = 1, speed = 1, looping = false } } }; DCLAnimator animator = TestHelpers.EntityComponentCreate <DCLAnimator, DCLAnimator.Model>(scene, entity, animatorModel); LoadWrapper gltfShape2 = GLTFShape.GetLoaderForEntity(entity); yield return(new WaitUntil(() => gltfShape2.alreadyLoaded == true)); Assert.IsTrue(animator.animComponent != null); Assert.AreEqual(animator.animComponent.clip.name, clipName); Assert.IsFalse(animator.animComponent.isPlaying); }
public IEnumerator DCLAnimatorResetAnimation() { GLTFShape gltfShape = TestHelpers.CreateEntityWithGLTFShape(scene, Vector3.zero, new LoadableShape.Model { src = TestAssetsUtils.GetPath() + "/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); animator.animComponent.cullingType = AnimationCullingType.AlwaysAnimate; yield return(null); Animation animation = entity.gameObject.GetComponentInChildren <Animation>(); foreach (AnimationState animState in animation) { Assert.AreNotEqual(0f, animState.time); } animatorModel.states[1].shouldReset = true; yield return(TestHelpers.EntityComponentUpdate(animator, animatorModel)); animator.ResetAnimation(animator.GetStateByString("Swim")); foreach (AnimationState animState in animation) { if (animator.GetStateByString("Swim").clipReference.name == animState.clip.name) { Assert.AreEqual(0f, animState.time); } else { Assert.AreNotEqual(0f, animState.time); } } }
public IEnumerator MaterialTransitionWithGLTF() { var entity1 = TestHelpers.CreateSceneEntity(scene); ParcelSettings.VISUAL_LOADING_ENABLED = true; var prevLoadingType = RendereableAssetLoadHelper.loadingType; RendereableAssetLoadHelper.loadingType = RendereableAssetLoadHelper.LoadingType.GLTF_ONLY; Shader hologramShader = Shader.Find("DCL/FX/Hologram"); Assert.IsTrue(hologramShader != null, "Hologram shader == null??"); DecentralandEntity entity = null; GLTFShape shape = TestHelpers.InstantiateEntityWithShape <GLTFShape, GLTFShape.Model> (scene, DCL.Models.CLASS_ID.GLTF_SHAPE, Vector3.zero, out entity, new GLTFShape.Model() { src = DCL.Helpers.Utils.GetTestsAssetsPath() + "/GLB/Lantern/Lantern.glb" }); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(entity); yield return(new WaitUntil(() => gltfShape.alreadyLoaded)); float timeout = 0; while (timeout < 10) { timeout += Time.deltaTime; if (entity.meshRootGameObject != null) { var c = entity.meshRootGameObject.GetComponentInChildren <MaterialTransitionController>(); if (c != null && c.placeholder != null) // NOTE(Brian): Wait for it { Assert.IsTrue(c.useHologram, "useHologram must be true"); Assert.IsTrue(entity.meshRootGameObject != null, "meshGameObject is null"); Assert.AreEqual(c.gameObject.transform, c.placeholder.transform.parent, "MaterialTransitionController is not parented correctly"); Assert.IsTrue(c.placeholder.GetComponent <MeshFilter>() != null, "MeshFilter missing from placeholder object"); Assert.IsTrue(c.placeholder.GetComponent <Renderer>() != null, "Renderer missing from placeholder object"); Assert.IsTrue(c.placeholder.GetComponent <Renderer>().sharedMaterial != null, "SharedMaterial missing from placeholder's renderer"); Assert.AreEqual(hologramShader, c.placeholder.GetComponent <Renderer>().sharedMaterial.shader, "Placeholder is not hologram"); yield return(new WaitForSeconds(2f)); Assert.IsTrue(c == null, "MaterialTransitionController should be destroyed by now!"); break; } } yield return(null); } Assert.Less(timeout, 10.1f, "Timeout! MaterialTransitionController never appeared?"); RendereableAssetLoadHelper.loadingType = prevLoadingType; yield return(null); }
public IEnumerator PreExistentShapeUpdate() { string entityId = "1"; TestHelpers.CreateSceneEntity(scene, entityId); var entity = scene.entities[entityId]; Assert.IsTrue(entity.meshRootGameObject == null, "meshGameObject should be null"); // Set its shape as a BOX var componentId = TestHelpers.CreateAndSetShape(scene, entityId, CLASS_ID.BOX_SHAPE, "{}"); yield return(((scene.GetSharedComponent(componentId)) as IDelayedComponent).routine); var meshName = entity.meshRootGameObject.GetComponent <MeshFilter>().mesh.name; Assert.AreEqual("DCL Box Instance", meshName); // Update its shape to a cylinder TestHelpers.CreateAndSetShape(scene, entityId, CLASS_ID.CYLINDER_SHAPE, "{}"); yield return((scene.GetSharedComponent(componentId) as IDelayedComponent).routine); Assert.IsTrue(entity.meshRootGameObject != null, "meshGameObject should not be null"); meshName = entity.meshRootGameObject.GetComponent <MeshFilter>().mesh.name; Assert.AreEqual("DCL Cylinder Instance", meshName); Assert.IsTrue(entity.meshRootGameObject.GetComponent <MeshFilter>() != null, "After updating the entity shape to a basic shape, the mesh filter shouldn't be removed from the object"); Assert.IsTrue(entity.meshesInfo.currentShape != null, "current shape must exist 1"); Assert.IsTrue(entity.meshesInfo.currentShape is CylinderShape, "current shape is BoxShape"); // Update its shape to a GLTF TestHelpers.CreateAndSetShape(scene, entityId, DCL.Models.CLASS_ID.GLTF_SHAPE, JsonConvert.SerializeObject( new { src = Utils.GetTestsAssetsPath() + "/GLB/Lantern/Lantern.glb" })); LoadWrapper gltfShape = GLTFShape.GetLoaderForEntity(scene.entities[entityId]); yield return(new WaitUntil(() => gltfShape.alreadyLoaded)); Assert.IsTrue(entity.meshesInfo.currentShape != null, "current shape must exist 2"); Assert.IsTrue(entity.meshesInfo.currentShape is GLTFShape, "current shape is GLTFShape"); Assert.IsTrue(entity.meshRootGameObject != null); Assert.IsTrue(entity.meshRootGameObject.GetComponent <MeshFilter>() == null, "After updating the entity shape to a GLTF shape, the mesh filter should be removed from the object"); Assert.IsTrue( scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() != null, "'GLTFScene' child object with 'InstantiatedGLTF' component should exist if the GLTF was loaded correctly"); // Update its shape to a sphere TestHelpers.CreateAndSetShape(scene, entityId, CLASS_ID.SPHERE_SHAPE, "{}"); yield return((scene.GetSharedComponent(componentId) as IDelayedComponent).routine); yield return(null); Assert.IsTrue(entity.meshRootGameObject != null); meshName = entity.meshRootGameObject.GetComponent <MeshFilter>().mesh.name; Assert.AreEqual("DCL Sphere Instance", meshName); Assert.IsTrue( scene.entities[entityId].gameObject.GetComponentInChildren <UnityGLTF.InstantiatedGLTFObject>() == null, "'GLTFScene' child object with 'InstantiatedGLTF' component shouldn't exist after the shape is updated to a non-GLTF shape"); }