Sky.SkyboxOrientation is incorrectly documented as using YXZ Rotation order but actually uses ZXY Rotation order

skyboxorientation was documented incorrectly as YXZ but instead uses the reverse(?) of that: ZXY. i was trying to figure out what was wrong with my code but it turns out documentation has it down wrong. please fix (or maybe this is an engine bug? not too sure.)

see video

script i used for testing this

local rs = game:GetService("RunService")
local sky = game:GetService("Lighting").Sky
local cam = workspace.CurrentCamera

i = 0

local userinputservice = game:GetService("UserInputService")
userinputservice.InputBegan:Connect(function(io, gpe)
	if gpe then return end

	if io.KeyCode == Enum.KeyCode.Z then
		i-=1
		print(Enum.RotationOrder:FromValue(i))
	end
	

	if io.KeyCode == Enum.KeyCode.X then
		i+=1
		print(Enum.RotationOrder:FromValue(i))
	end
	
end)

rs.PreRender:Connect(function()
	local x, y, z = cam.CFrame:ToEulerAngles(Enum.RotationOrder:FromValue(i))
	local dx, dy, dz = math.deg(x), math.deg(y), math.deg(z)
	
	sky.SkyboxOrientation = Vector3.new(dx,dy,dz)
end)

Page URL: https://create.roblox.com/docs/en-us/reference/engine/classes/Sky#SkyboxOrientation

Hi, thanks for the report. In the documentation there is a sample script that horizontally rotates a skybox, but at a slightly tilted angle of 30 degrees. The script does this by updating the Y value with deltaTime, to cause the animation, and then tilting the already-animated box by setting X = 30. If the rotation around Y came after the rotation around X, the effect would be more similar to a spinning top that’s coming to a halt, “wobbling” around the table. This is how we intended for “Y comes first” to be understood – you can easily script a spinning skybox at any orientation by animating Y and then tilting the whole thing to the desired angle.

Also, rotating the world contents by YXZ creates the same image as rotating the camera by ZXY, so maybe that’s where the reversal comes from?

Does this make sense or does it still seem like the example script does not agree with the documentation?

Thanks!

1 Like

oh! that makes a bit more sense. i figured it meant it applies the rotations in order of YXZ, following the logic that part.orientation sets. my mistake! thank you for checking though! maybe a little blurb telling you that it technically applies it in ZXY order* would help ease the confusion of some people**. i honestly thought it was incorrectly documented because of a different post, but now that im looking at it again, its not marked as solved..
yeah my mistake

* (i think it does, thats what made my code work so i hope so)
**(like me id assume)

sorry i forgot to mark it as solved :pensive_face:

1 Like

oh wait that was in a different thread

Hello! Just closing the loop here - I made a slight adjustment to the documentation to reinforce the Y-first application and a quick note to be careful about camera and object orientation affecting the appearance of rotation application.

Feel free to open up a new request if you find anything else and have a great rest of your week.
naahchos

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.