Something like:
Lua Code:
local units = {}
units.player = CreateFrame("PlayerModel", nil, UIParent)
units.player:SetSize(150, 200)
units.player:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
units.player:SetUnit("player")
units.player:SetCamera(2)
units.player:SetFacing(30)
units.player:RefreshCamera()
units.player:Show()
units.target = CreateFrame("PlayerModel", nil, UIParent)
units.target:SetSize(150, 200)
units.target:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
units.target:SetUnit("target")
units.target:SetCamera(2)
units.target:RefreshCamera()
units.target:Show()
units.target:SetScript("OnEvent", function(self, event, ...)
if event == "PLAYER_TARGET_CHANGED" then
if UnitExists("target") then
self:SetUnit("target")
self:Show()
else
self:Hide()
end
return
end
local unit = ...
local unitframe = units[unit]
if unitframe then
unitframe:SetUnit(unit)
end
end)
units.target:RegisterEvent("UNIT_MODEL_CHANGED")
units.target:RegisterEvent("UNIT_PORTRAIT_UPDATE")
units.target:RegisterEvent("PLAYER_TARGET_CHANGED")
The target frame traps the events for both models and checks against the unit parameter (for the UNIT_ events) for which one is being effected by the event then looks up the units table to find if and which frame to update.
You can use the model:SetPortraitZoom() and SetPosition() methods zoom/move the model within the frame.