sceneview-android icon indicating copy to clipboard operation
sceneview-android copied to clipboard

Fix Node and LightNode look methods

Open SeyedAlirezaFatemi opened this issue 2 years ago • 2 comments

SeyedAlirezaFatemi avatar Jul 20 '22 14:07 SeyedAlirezaFatemi

Please don't merge yet

ThomasGorisse avatar Jul 24 '22 11:07 ThomasGorisse

There is one problem: If the parent is doing a smooth transform, then the worldToParent that we use in the child is based on the parent's transform not smoothTransform and that causes problems. For example if we do this:

parentNode.lookAt(sceneView.camera.worldPosition, smooth = true)
childNode.lookAt(sceneView.camera.worldPosition, smooth = true)

the child will do a wrong rotation and it's like it does double the rotation that was needed to look at the camera and will end up not looking at the camera. Any ideas how we can fix this? Btw, changing:

    open val worldTransform: Mat4
        get() = parentNode?.let { it.worldTransform * transform } ?: transform

to:

    open val worldTransform: Mat4
        get() = parentNode?.let { it.worldTransform * smoothTransform } ?: smoothTransform

makes everything so slow and laggy and also removes the smooth effect.

SeyedAlirezaFatemi avatar Jul 25 '22 07:07 SeyedAlirezaFatemi