Add Unity importer scripts and handle CityJSON transform
This commit is contained in:
35
scripts_unity/Editor/GeoBoundsDebug.cs
Normal file
35
scripts_unity/Editor/GeoBoundsDebug.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public static class GeoBoundsDebug
|
||||
{
|
||||
[MenuItem("Tools/Geo/Print Selected Mesh Bounds")]
|
||||
public static void PrintSelectedMeshBounds()
|
||||
{
|
||||
foreach (var go in Selection.gameObjects)
|
||||
{
|
||||
var mf = go.GetComponent<MeshFilter>();
|
||||
if (mf == null || mf.sharedMesh == null)
|
||||
{
|
||||
Debug.Log($"{go.name}: no MeshFilter/mesh");
|
||||
continue;
|
||||
}
|
||||
|
||||
var mesh = mf.sharedMesh;
|
||||
var b = mesh.bounds;
|
||||
|
||||
// Mesh bounds are in local mesh space
|
||||
var centerWorld = go.transform.TransformPoint(b.center);
|
||||
|
||||
// Approximate size in world space (ignores rotation, good enough for diagnosis)
|
||||
var lossy = go.transform.lossyScale;
|
||||
var sizeWorld = new Vector3(
|
||||
Mathf.Abs(b.size.x * lossy.x),
|
||||
Mathf.Abs(b.size.y * lossy.y),
|
||||
Mathf.Abs(b.size.z * lossy.z)
|
||||
);
|
||||
|
||||
Debug.Log($"{go.name}: worldCenter={centerWorld}, worldSize={sizeWorld}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user