Draw mesh in codea craft?

I’m trying to make an “Obj Model Maker” in the latest version of Codea (with the efficient build-in 3D processing code),but I has faced several problems.(forgive my poor English)

1.I want to make the Modeler based on the triangles,so I probably have to use the meshes in the craft? But I can’t find any way to do that.

2.As shown in the screenshot,I made an axis in the corner ,I use the code
“scene.debug:line(vec3(), vec3(), color())”
which I discovered by coincidence and I don’t know how the "scene.debug"works.

3.I found the display effect of the code"line" likes the method “bound” shown in a build-in example.But the bound can be covered by other models ,while the method “line” only can be drawn on the top.Is there any way to draw a “line” just like the "bounds"that can be covered?

4.I made the axis by creating another scene and drawing the axis in it.Then I draw the scene in another image and then draw the image in the corner,which makes the background of the axis is black.Is there any way to make it transparent,just like it’s hovering on the screen?

5.As mentioned before, the method"line" is discovered by coincidence,why it wasn’t listed?

@0Point Here’s some code that I used to create a tube based on different number of sides. I create various tables that allows a texture, color, etc. This might help you understand how to create different sides for a model.

PS. I added scene.debug:line which shows that the line can be covered by the image that you mention in your #3.

displayMode(FULLSCREEN)

function setup()
    assert(OrbitViewer, "Please include Cameras (not Camera) as a dependency")    
        
    scene = craft.scene()
    v=scene.camera:add(OrbitViewer,vec3(0,0,0), 700, 0, 2000)
    v.camera.farPlane=3000
    
    nbrSides=4

    -- calculate sides of tube
    tube(vec3(0,1,2),vec3(300,1,2),60,nbrSides)
    
    -- draw spheres at corner points of tube sides
    for z=1,#pos do
        createSphere(pos[z],1)
    end
end

function draw()
    update(DeltaTime)
    scene:draw() 
    text("Slide your finger around the screen to rotate the image.",WIDTH/2,HEIGHT-25)
    text("Use two fingers to zoom in, zoom out or to move the image.",WIDTH/2,HEIGHT-50)
end

function update(dt)
    scene:update(dt)    
    scene.debug:line(vec3(0,-200,-100),vec3(200,200,100),color(255))  
end

function tube(p1,p2,dia,sides)
    pos,ind,nor,col={},{},{},{}
    rp=vec3(100,100,100)
    v1=rp-p1
    r1=v1:cross(p2-p1)
    s1=r1:cross(p2-p1)
    
    r1=r1:normalize()
    s1=s1:normalize() 
    
    -- create points based on number of sides
    for a=0,719,360/sides do
        n = r1 * math.cos(math.rad(a)) + s1 * math.sin(math.rad(a))
        n=n*dia
        if a>359 then
            table.insert(pos,n + p2)    -- add p2 to last loop
        else
            table.insert(pos,n + p1)    -- add p1 to loop
        end
        table.insert(nor,n)
    end
    
    -- calculate indicies
    local o,p={1,2,3,4,5,6,3,2,1,6,5,4},{}
    for z=1,#pos-sides do
        p[1],p[2],p[3],p[4],p[5],p[6]=z,z+1,z+sides+1,z,z+sides+1,z+sides
        if z%sides==0 then
            p[2]=z-sides+1
            p[3]=z+1
            p[5]=z+1
        end
        for t=1,12 do
            table.insert(ind,p[o[t]])
        end
    end 
    
    -- create color table
    for z=1,#pos do
        table.insert(col,color(255,0,0))
        --table.insert(col,color(math.random(255),math.random(255),math.random(255)))
    end
    
    -- draw sides 
    local pt=scene:entity()
    pt.model = craft.model()
    pt.model.positions=pos
    pt.model.indices=ind
    pt.model.colors=col
    pt.model.normals=nor
    pt.material = craft.material("Materials:Specular")   
end

function createSphere(p,size)
    local pt=scene:entity()
    pt.position=p
    pt.model = craft.model.icosphere(size,2)
    pt.material = craft.material("Materials:Specular")
    pt.material.diffuse=color(255)
end

@dave1707 Thanks!Through your code found that I didn’t understand how index works before.Now I think I’m going to practice this for a while.

@0Point Not sure when you first looked at my code above. Did you notice that I added scene.debug:line to the code to show that the line drawn can be hidden by the model.

@dave1707 Yes,but I’m confused why my line can’t be hidden,perhaps I haven’t seen it clearly. :-I