Rotation Help

I want to rotate an object with a flat bottom surface so that it looks like the picture attached. How exactly am I supposed to do this? Here’s my code:

-- Odd
--assert(OrbitViewer)
function setup()
    -- Create a new craft scene
    scene = craft.scene()
    scene.physics.gravity = vec3(0, -14, 0)
    scene.sky.material.sky = color(255, 72, 0)
    scene.sky.material.horizon = color(224, 147, 143) 
    cameraSettings = scene.camera:get(craft.camera)
    cameraSettings.nearPlane = 0.001
    viewer.mode = FULLSCREEN
    rotation = 0.15
    rotation2 = 0
    dead = false
    lavaS = {x = 0.12, y = 0.12, z = 0.12}
    
    
    -- Create a new entity
    earth = scene:entity()
    earth.model = craft.model(asset.builtin.Primitives.Sphere)
    earth.position = vec3(0, 0, 0)
    earth.eulerAngles = vec3(0, 0, 0)
    earth.scale = vec3(1, 1, 1) / 8
    earth.material = craft.material(asset.builtin.Materials.Standard)
    earth.material.diffuse = color(186, 255, 0)
    
    player = scene:entity()
    body = player:add(craft.rigidbody, STATIC)
    player.model = craft.model(asset.builtin.Primitives.Sphere)
    player:add(craft.shape.model, player.model)
    player.position = vec3(0, 0, -0.4)
    player.eulerAngles = vec3(0, 0, 0)
    player.scale = vec3(0.1, 0.1, 0.1) / 8 
    parameter.watch("player.y")
    parameter.watch("player.x")
    parameter.watch("rotation2")
    
    makeSpike(vec3(0, player.y, -0.13), quat.eulerAngles(-90, 90, -90))
    makeLava(vec3(-0.03, player.y, -0.12), quat.eulerAngles(-0, 90, -90))
    
    scene.camera.z = -.5
end

function makeSpike(p, e)
    spike = scene:entity()
    sb = spike:add(craft.rigidbody, STATIC)
    spike.model = craft.model(asset.builtin.CastleKit.towerTopRoof_obj)
    spike:add(craft.shape.model, spike.model)
    spike.position = p
    spike.rotation = e
    spike.scale = vec3(0.01, 0.01, 0.01) / 8
end

function makeLava(p, e)
    lava = scene:entity()
    lb = lava:add(craft.rigidbody, STATIC)
    lava.model = craft.model(asset.builtin.Nature.naturePack_016_obj)
    lava:add(craft.shape.model, lava.model)
    lava.position = p
    lava.rotation = e
    lava.scale = vec3(0.12, 0.12, 0.12) / 8
    lava.material = craft.material(asset.builtin.Materials.Standard)
    lava.material.map = readImage(asset.builtin.Blocks.Lava)
end

function touched(touch)  
    if touch.state == BEGAN and touch.tapCount == 2 then
        zoomOne = tween(0.25, cameraSettings, {fieldOfView = 35}, tween.easing.cubicIn)
        zoomTwo = tween(0.25, cameraSettings, {fieldOfView = 45}, tween.easing.cubicOut)
        tween.sequence(zoomOne, zoomTwo)
    end
    
    if touch.state == BEGAN then
        
    end
    
    if touch.state == MOVING and touch.deltaX > 0 then
        rotation = rotation + 2
    end
    
    if touch.state == MOVING and touch.deltaX < 0 then
        rotation = rotation - 2
    end
    
    if touch.state == MOVING and touch.deltaY > 0 then
        rotation2 = rotation2 + 2
    end
    
    if touch.state == MOVING and touch.deltaY < 0 then
        rotation2 = rotation2 - 2
    end
end

function update(dt)
    -- Update the scene (physics, transforms etc)
    scene:update(dt)
    player.rotation = quat.eulerAngles(rotation2, rotation, 0)    
    player.position = player.forward * 0.068 * 2.0
    if lavaS.x == 0.12 and lavaS.y == 0.12 then
        scaleOne = tween(0.5, lavaS, {x = 0.18, y = 0.18, z = 0.18}, tween.easing.cubicInOut)
        scaleTwo = tween(0.5, lavaS, {x = 0.12, y = 0.12, z = 0.12}, tween.easing.cubicInOut)
        tween.sequence(scaleOne, scaleTwo)
    end
    lava.scale = vec3(lavaS.x, lavaS.y, lavaS.z) / 8
end

-- Called automatically by codea 
function draw()
    update(DeltaTime)
    
    -- Draw the scene
    scene:draw() 
    calc()   
end

function calc()
    if dead == false then
    x = math.abs(player.position.x - spike.position.x)
    y = math.abs(player.position.y - spike.position.y)
    z = math.abs(player.position.z - spike.position.z)
    if x<.014 and y<.014 and z<.014 then
          print("hit")
          dead = true
          if dead == true then
              tween(1.5, player, {scale = vec3(0, 0, 0)}, tween.easing.cubicIn, function() player:destroy() end)
          end
      end
        
        x2 = math.abs(player.position.x - lava.position.x)
        y2 = math.abs(player.position.y - lava.position.y)
        z2 = math.abs(player.position.z - lava.position.z)
        if x2<.014 and y2<.014 and z2<.014 then
            print("hit")
            dead = true
            if dead == true then
                tween(1.5, player, {scale = vec3(0, 0, 0)}, tween.easing.cubicIn, function() player:destroy() end)
            end
        end
    end
 end

If someone is able to change my code to what I want it to do, that would be greatly appreciated. Thanks in advance :slight_smile: P.S the code I want changed is the “lava” entity in the scene.

If you have it a little lower than the surface, it might look like what you want.