Digital Rain

I seem to be getting error msg’s…

Error msg :smile:

Please include cameras (not camera) as a dependency

Stack traceback :[C] in function ‘assert’

Main : 12 : in function ‘setup’

Main : 37 : attempt to index a nil value (global ‘scene’)
Stack traceback :

Main : 37 : in function ‘update’

Main : 29 : in function ‘draw’

Does anyone have any idea what went wrong ?
Using I-ph 6s…

@kendog400 - please post a little code, or point out which of the posts above you are referring to

It looks like you are referring to a 3D Craft package with assert, cameras and scene referred to. Are you posting in the right thread?

@kendog400 That looks like one of my error messages that I display when you don’t have CAMERAS selected as a dependency. I’m not sure which program your referring to. Just bring up the dependency list in the program and check CAMERAS.

It was this PGM…
It usted to work fine on i-pad (5)


displayMode(FULLSCREEN)

function setup()
    diameter=6
    sides=10
    assert(craft, "Please include Craft as a dependency")
    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
    v.ry=60
    for z=1,20 do
        pos,ind,col,nor={},{},{},{}
        bezier()
        createSkin()
        createTube()
    end
    createSphere(vec3(0,0,-200),20) --  starting red sphere
    createSphere(vec3(0,0,200),20)  --  ending red sphere  
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)
end


function bezier(cnt)
    local val=400
    local tab1={}
    local x0 = vec3(0,0,-200)
    local x1 = vec3(math.random(-val,val),math.random(-val,val),math.random(-val,val))
    local x2 = vec3(math.random(-val,val),math.random(-val,val),math.random(-val,val))
    local x3 = vec3(0,0,200)
    local xt
    for t=0,1.01,.02 do
        xt = (1-t)^3*x0 + 3*t*(1-t)^2*x1 + 3*t^2*(1-t)*x2 + t^3*x3         
        table.insert(tab1,xt)
    end
    for z=1,#tab1-1 do
        createLoop(tab1[z],tab1[z+1],false) -- createLoop on 1st to next to last point
    end
    createLoop(tab1[#tab1-1],tab1[#tab1],true)  -- createLoop on last point
end


function createLoop(p1,p2,last)
    local rp=vec3(1,1,1)
    local v1=rp-p1
    local r1=v1:cross(p2-p1)
    local s1=r1:cross(p2-p1)
    r1,s1=r1:normalize(),s1:normalize()    
    local n
    for a=0,359,360/sides do
        n = r1 * math.cos(math.rad(a)) + s1 * math.sin(math.rad(a))
        n=n*diameter
        if last 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
end


function createSkin()
    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 
    for z=1,#pos do
        if (z-1)%1000==0 then   -- change color on each tube
            c=color(math.random(255),math.random(255),math.random(255))
        end
        table.insert(col,c)
    end
end


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


function createTube()
    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

I liked the PGM…and now I’m getting better at figuring things, but yet not everything…

@kendog400 CAMERAS needs to be checked as a dependency, other than that the program works OK. Are you still having problems after you check CAMERAS as a dependency.

@kendog400 - very impressive demo (an old post from @dave1707).

p.s. remember to format your code posts with a space in a line after and before the ~~~

How do I check the camera as a dependency ? Sounds easy, but i,'m still confused…

@kendog400 When you’re in the editor, in the upper right is Do. Tap on that and it creates a dropdown. Tap on Dependencies and scroll down until you find Cameras. Tap the square and it will be checked and moved to the top of the list. That’s it, the program should run OK.