@name Axes

Entity=entity()
Pos=entity():pos()

function drawLine(Index,Pos1:vector,Pos2:vector,Color:vector,XScale) {
    Color/=2
    local Center=Entity:toWorld((Pos1+Pos2)/2)
    local Angle=(Pos1-Pos2):toAngle()
    local Scale=(Pos1-Pos2):length()/12
    holoCreate(Index,Center,vec(Scale,XScale,XScale),Angle)
    holoColor(Index,vec4(Color,128))
}

holoCreate(1,Pos,vec(5,0.01,0.01),ang())
holoColor(1,vec4(255,0,0,255))
holoCreate(2,Pos,vec(0.01,5,0.01),ang())
holoColor(2,vec4(0,255,0,255))
holoCreate(3,Pos,vec(0.01,0.01,5),ang())
holoColor(3,vec4(0,0,255,255))

holoMaterial(1,"debug/debugdrawflat")
holoMaterial(2,"debug/debugdrawflat")
holoMaterial(3,"debug/debugdrawflat")

holoParent(1,Entity)
holoParent(2,Entity)
holoParent(3,Entity)

local X=6
local Y=12
local Z=6

local Poser=table(

    #Back
    vec(-X,-Y,-Z),
    vec(-X,-Y,Z),
    vec(X,-Y,Z),
    
    vec(-X,-Y,-Z),
    vec(X,-Y,-Z),
    vec(X,-Y,Z),
    
    # Front
    vec(-X,Y,-Z),
    vec(-X,Y,Z),
    vec(X,Y,Z),
    
    vec(-X,Y,-Z),
    vec(X,Y,-Z),
    vec(X,Y,Z),
    
    # Left
    vec(-X,Y,-Z),
    vec(-X,-Y,-Z),
    vec(-X,-Y,Z),
    
    vec(-X,Y,Z),
    vec(-X,Y,-Z),
    vec(-X,-Y,Z),
    
    # Right
    vec(X,Y,-Z),
    vec(X,-Y,-Z),
    vec(X,-Y,Z),
    
    vec(X,Y,Z),
    vec(X,Y,-Z),
    vec(X,-Y,Z),
    
    # Top
    vec(X,Y,Z),
    vec(-X,Y,Z),
    vec(-X,-Y,Z),
    
    vec(-X,-Y,Z),
    vec(X,-Y,Z),
    vec(X,Y,Z),
    
    # Bottom
    vec(X,Y,-Z),
    vec(-X,Y,-Z),
    vec(-X,-Y,-Z),
    
    vec(-X,-Y,-Z),
    vec(X,-Y,-Z),
    vec(X,Y,-Z)
    
    
)

local MaxPoly=ceil(Poser:count()/3)
local Index=8
local Poly=randvec(vec(),vec(255))
# 11.862497 11.862513 3.000000	
# models/hunter/triangles/025x025.mdl
Polygon=array()

for(I=1,Poser:count()) {
    local V=Poser[I,vector]
    Index++
    Polygon:pushVector(V)
    if((I)%3==0) {
        Poly=randvec(vec(),vec(255)) #hsv2rgb((ceil(Index/3)/MaxPoly)*360,1,1)
        local MaxScale=randint(100,1000)/10000
        Index++
        drawLine(Index,Polygon[1,vector],Polygon[2,vector],Poly,MaxScale)
        Index++
        drawLine(Index,Polygon[2,vector],Polygon[3,vector],Poly,MaxScale)
        Index++
        drawLine(Index,Polygon[3,vector],Polygon[1,vector],Poly,MaxScale)
        Index++
        Polygon:clear()
    }
    holoCreate(Index,Pos+V,vec(0.1),ang())
    holoColor(Index,vec4(Poly,128))
    # holoMaterial(Index,"debug/debugdrawflat")
}

entity():setAlpha(0)
