So I am using cesium tiles in one of my VR project and I cull the tiles to a box as described in this thread Add ability to exclude tiles by implementing a C# class. by kring · Pull Request #248 · CesiumGS/cesium-unity · GitHub, I did everything but exclusion is not clean, when I am moving the tiles or scaling it goes outside the box, giving an unpleasant effect, Attached a gif to show what I am encountering.
Can you explain in more detail what you’re doing? What do you mean by “when I am moving the tiles or scaling”?
So I figured if i transform the Cesium 3D tileset, then we can see another part of the terrain, so that is what I am doing in the gif, and when I am doing so exclusion is not done properly
Do you mean you’re changing the Cesium3DTileset’s Transform?
If so, you might have more luck changing the CesiumGeoreference’s Transform instead. Or, better yet, change the Origin Longitude/Latitude/Height of the CesiumGeoreference.
I’ll probably be able to help more if you share more detail, such as your actual script that is doing the transformation.
Basically I have shrinked down the terrain to display it on table size, wherein I am using exclusion, and when on table I am using controllers to transform the position to move the terrain and give a good animation like above, In script too I am just transforming position and scale, nothing else
As for changing CesiumGeoreference’s Transform I didn’t find it much good, as its changing the location not much of use when I am putting it at a particular location.
Below is the script I am using
using CesiumForUnity;
using UnityEngine;
public class TerrainManipulator : MonoBehaviour
{
public Transform targetObject; // The object to manipulate
public float moveSpeed = 1.0f; // Speed for moving the object
public float scaleSpeed = 0.1f; // Speed for scaling the object
//public Cesium3DTileset tileSet;
void Update()
{
// Handle Oculus input for VR
HandleOculusInput();
// Handle keyboard input for debug/testing in editor
HandleDebugInput();
}
private void HandleOculusInput()
{
// Thumbstick input for movement (right thumbstick)
Vector2 rightThumbstickInput = OVRInput.Get(OVRInput.Axis2D.SecondaryThumbstick);
MoveObject(rightThumbstickInput);
// Thumbstick input for scaling (left thumbstick)
Vector2 leftThumbstickInput = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
ScaleObject(leftThumbstickInput);
}
private void HandleDebugInput()
{
// Key inputs for movement
float moveX = 0, moveZ = 0;
if (Input.GetKey(KeyCode.W)) moveZ = 1; // Move forward
if (Input.GetKey(KeyCode.S)) moveZ = -1; // Move backward
if (Input.GetKey(KeyCode.A)) moveX = -1; // Move left
if (Input.GetKey(KeyCode.D)) moveX = 1; // Move right
Vector2 moveInput = new Vector2(moveX, moveZ);
MoveObject(moveInput);
// Key inputs for scaling
float scaleInput = 0;
if (Input.GetKey(KeyCode.UpArrow)) scaleInput = 1; // Scale up
if (Input.GetKey(KeyCode.DownArrow)) scaleInput = -1; // Scale down
Vector2 scaleInputVector = new Vector2(0, scaleInput);
ScaleObject(scaleInputVector);
}
private void MoveObject(Vector2 input)
{
// Move the object based on input from thumbstick or keyboard
if(input != Vector2.zero)
{
Vector3 moveDirection = new Vector3(input.x, 0, input.y);
targetObject.position += moveDirection * moveSpeed * Time.deltaTime;
}
//tileSet.RecreateTileset();
}
private void ScaleObject(Vector2 input)
{
// Scale the object based on input from thumbstick or keyboard
if (input.y != 0)
{
float scaleChange = input.y * scaleSpeed * Time.deltaTime;
targetObject.localScale += new Vector3(scaleChange, scaleChange, scaleChange);
//tileSet.RecreateTileset();
}
}
}
Hey @Kevin_Ring, Thanks for all the replies and help, but can you please help me quick as I am running on a deadline and already been lot late.
Thanks
Hi @SethiShreya,
I still don’t understand your comments about the CesiumGeoreference. You’re trying to show a piece of the globe on a table in your Unity world. When the user manipulates the controllers, you want to change which piece of the globe is shown, but the table stays still. Do I have that right? If so, changing the CesiumGeoreference seems like the correct approach to me. It controls which location on the globe maps to (0,0,0) in the Unity coordinate system. Then the Unity Transform on the CesiumGeoreference controls where that coordinate system is located in the Unity world.
That’s not much of a problem, I am more concerned to clean clipping as for static map too clipping is not clean, it still go beyond the box collider and I guess that is the reason why when I am moving the map it is not clean.
So please help me with clipping making it more clean.
Hi @SethiShreya,
I think there may be a misunderstanding. In the CesiumBoxExcluder
on the PR you linked, the class will exclude any tiles that fall completely outside the box. This means that tiles that fall partially inside the box will still be included. However, the tiles are included as their whole selves – there is no actual clipping of the geometry, so you’ll see some of the tiles spilling out of the area.
What you might want to do is follow this explanation in Kevin’s PR here: Add ability to exclude tiles by implementing a C# class. by kring · Pull Request #248 · CesiumGS/cesium-unity · GitHub
The above comment explains how you can create a material to hide the parts of tiles that fall outside that box excluder. Note that it is a minimal example – you may have to change parts in order to implement certain effects. For example, if the box ever moves at runtime, you’ll have to use a material parameter to reflect its changing position.
I hope this clears things up. Let us know if there’s still any confusion.