Portal = ScriptObject()

function Portal:Start()
    self.rotationSpeed = Vector3(0, 0, 0)
end

function Portal:Update(timeStep)
    local x = self.rotationSpeed.x * timeStep
    local y = self.rotationSpeed.y * timeStep
    local z = self.rotationSpeed.z * timeStep
    self.node:Rotate(Quaternion(x, y, z))
end

function Portal:TransformChanged()
    local dir = self.node:GetWorldUp()
    local pos = self.node:GetWorldPosition()
  
    local material = cache:GetResource("Material", "Materials/Gideon.xml")
    material:SetShaderParameter("PortalForward", Variant(dir))
    material:SetShaderParameter("PortalOrigin",  Variant(pos))
end