Bad news, seems like you can only set custom camera for the model if Model:HasCustomCamera() returns true.
Also managed to fix the flipping issue like this:
Lua Code:
local frame2 = CreateFrame("Frame", nil, UIParent)
frame2:SetPoint("Center", - 128, 0)
frame2:SetWidth(512)
frame2:SetHeight(512)
frame2:SetAlpha(1)
local model2 = CreateFrame("PlayerModel", nil, frame2)
model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
model2:SetAlpha(1)
model2:SetAllPoints(frame2)
model2:SetCustomCamera(1)
local x, y, z = model2:GetCameraPosition()
local r = math.sqrt((x * x) + (z * z))
print(x, y, z, r)
print(model2:HasCustomCamera())
--model2:SetLight(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
local degree = 90
local slider = CreateFrame("Slider", nil, UIParent, "OptionsSliderTemplate")
slider:ClearAllPoints()
slider:SetPoint("Center", UIParent, "Center", 0, 300)
slider:SetMinMaxValues(0, 90)
slider:SetValue(0)
slider:SetValueStep(1)
slider:SetScript("OnValueChanged", function(slider, value)
degree = value
ModelBasics_UpdateModel2()
end)
function ModelBasics_UpdateModel2()
--model2:SetModel("Creature/LasherSunflower/lasher_sunflower.m2")
--model2:SetRotation(math.rad(0))
model2:SetCustomCamera(1)
local xx = math.sin(math.rad(degree)) * r
local zz = math.cos(math.rad(degree)) * r
if xx > 0.1 then
model2:SetCameraPosition(xx, y, zz)
else
model2:SetCameraPosition(0.1, y, zz)
end
--model2:SetCameraTarget(0, y, 0)
--model2:SetAllPoints(frame2)
end
--model2:SetCamera(2)
ModelBasics_UpdateModel2()