I hope some of you really smart devs can help! Paging @sharp@Vinc3r
I am creating a 360 style tour using a base mesh and projecting a cube map from the camera location the cube map was generated from.
Something about how I am calculting my Reflection Matrix is not working correctly. I am subtracting the camera position from the mesh position and it is so close, but appears to be flipped vertically and I cannot figure it out. If I play with the Y value, say change it to -150 instead of 150, then I drop low enough to see the clean cube map (no geo messing it up as I am underneath), but it is upside down.
Ignore the setTimeout, it is a quick and dirty for the playground to a) show me the base mesh quickly and b) wait for the everything to load before called.
(notice the * -1 line 20, Iām not sure if the getAbsolutePosition() line 19 is necessary)
The simplest solution is to use .babylon format. For glTF you have to burn some neurons to know in which way the matrix have ot be rotated (you can see Iāve tried this in my PG, without success)
Also the .gltf/.glb should work just fine. We are using a plugin called Layama that does all this for us in Unreal, and spits out a babylon web app ready to go, but wanting to recode ourselves to make some tweaks. They use this exact mesh file with this exact cube map and camera position
Looking at your rotation code at line 27 @Vinc3r I think rotating 180 on X does flip the reflection matrix, but it also resets the centre of the projection. Any ideas on how to flip it but keep the projection centre that is based on the mesh.subtract(cameraPosition)?
Iāve used a free camera 'cause the cam needs to not move from its position
free camera
arc rotate camera
When it comes to matrix operations, I have to say that Iām more in āI donāt know what Iām doingā than āIām a mathematical expertā So I canāt help about how to fix this even if I understand the logic we have to do here.
Yes I did see the async import returns a promise. Man Iāve tried so many ways to flip the matrix but I canāt seem to do anything without messing with the reflection centre. I also have absolutely no idea what is going on with the matrices so I am really just poking and prodding.
Hi @m-silver, I agree you can give a try to the @Vinc3r trick, it is not that dirty because changing the names of the jpegs in your export script is always a better solution than computing matrices :p.
You can use the parameter āfilesā in the constructor CubeTexture | Babylon.js Documentation like this :
I tried this and it actually jumbles everything completely. The current reflection matrix is in the right place, just upside down, so if swap the px and nx it goes all over the place - see here Babylon.js Playground