Closed Troxid closed 5 years ago
Pinging @MackeyK24
Can you please send me the project as a .unitypackage soi can look at the parent child relationship and hopefully make code adjustments (apparently when light is a child transform )
Just to clarify... So you are saying that using the Inverse Transform Direction when light is a child ?
Hello @MackeyK24
Can you please send me the project as a .unitypackage soi can look at the parent child relationship and hopefully make code adjustments (apparently when light is a child transform )
No sorry, i can't send the original project, but i have created a simple project which reproduce the problem. (red lamps without parents, green lamps with parent). https://drive.google.com/open?id=1lw5jBwvReA-3fIa9CMWz7PtBTUrKQoKv
Just to clarify... So you are saying that using the Inverse Transform Direction when light is a child ?
Yep, i had tried with TransformDirection
and it was not working properly.
As i undestand from documentation:
Transforms a direction from world space to local space.
What we need.
We can use old behavior for non-child light and fixed (i hope it's true) for childs.
if (light.transform.parent != null)
{
var direction = light.transform.forward;
var transformedDirection = light.transform.InverseTransformDirection(direction);
babylonLight.direction = transformedDirection.ToFloat();
}
else
{
// Old behavior for global lights
var direction = new Vector3(0, 0, 1);
var transformedDirection = light.transform.TransformDirection(direction);
babylonLight.direction = transformedDirection.ToFloat();
}
Up?
Well, for now, folks that are still gonna use the old version. This one can be fixed by using @Troxid fixes above.
New toolkit is GLTF 2.0 spec now
Light can camera transforms are exported differently (GLTF 2.0 spec) now and does NOT use light.transform.TransformDirection or the Inverse for exported the light component that is attached to a node. They are exported as component on a node where the node itself has the transform. The light or camera is just a child rig wither point Babylon.Forward for left and systems and BABYLON.Backwards() for right handed system.
Exporter: Unity - Version 4.0.0 - Alpha 10
When
Spot light
is used in the parent and its parent get transform - an exported direction is wrong.Unity scene and right light direction (pink arrows):
Exported scene:
I think problem is in
Babylon/Sources/SceneBuilder.Light.cs
I changed it to:
and it seems to be working fine:
I can't check it for 100%, because the
Inspector
doesn't show me the orientation of light.