Simple 3d sense

Can some one give me a simple 3d scene so I can get my foot in the door using simple shapes. Coolcodea is fun but out dated.


viewer.mode=FULLSCREEN

function setup()
    assert(OrbitViewer, "Please include Cameras as a dependency")
    
    scene = craft.scene()
    v=scene.camera:add(OrbitViewer, vec3(0,0,0), 100, 0, 200)
    v.rx,v.ry=10,-20

    createFloor()
    createSphere(6,20,5)
    createShape1(0,4,6)
    createShape2(12,4,6)
end

function draw()
    update(DeltaTime)
    scene:draw() 
end

function update(dt)
    scene:update(dt)
end

function createFloor()
    floor=scene:entity()
    f1=floor:add(craft.rigidbody,STATIC)
    floor.position=vec3(0,4,0)
    floor.model = craft.model.plane(vec2(60,60))
    floor:add(craft.shape.model,floor.model)
    floor.material = craft.material(asset.builtin.Materials.Standard)
    floor.material.map = readImage(asset.builtin.Surfaces.Basic_Bricks_Roughness)
end

function createSphere(x,y,z)
    sphere=scene:entity()
    s1=sphere:add(craft.rigidbody,DYNAMIC)
    sphere.position=vec3(x,y,z)
    sphere.model = craft.model.icosphere(1,5)
    sphere:add(craft.shape.sphere,1)
    sphere.material = craft.material(asset.builtin.Materials.Specular)
    sphere.material.map = readImage(asset.builtin.Blocks.Brick_Red)    
end

function createShape1(x,y,z)
    local model = craft.model("CastleKit:wallNarrowStairsFence")
    e = scene:entity()
    e.model = model
    e.position=vec3(x,y,z)
    e:add(craft.rigidbody, STATIC)
    e:add(craft.shape.model, model)    
end

function createShape2(x,y,z)
    local model = craft.model(asset.builtin.CastleKit.wallNarrowWoodFence_obj)  
    e = scene:entity()
    e.model = model
    e.position=vec3(x,y,z)
    e:add(craft.rigidbody, STATIC)
    e:add(craft.shape.model, model)
end


1 Like

Thank you I can understand this better.