Back to package · Browse packages
1import scene3d "std:ui/scene3d" 2import ui_cmds "std:ui/commands" 3import ui_raster "std:ui/raster" 4import ui_avm "std:ui/avm" 5 6fn fail(msg) { 7 print("FAIL") 8 print(msg) 9 oren_exit(1) 10} 11 12fn px(buf, w, x, y, chan) { 13 return oren_bytes_get_u8(buf, (y * w + x) * 4 + chan) 14} 15 16fn main() { 17 var cmds = scene3d.commands_from_binary_file("assets/scene3d_card.os3d") 18 if oren_is_err(cmds) { fail(oren_err_msg(cmds)) } 19 var valid = ui_cmds.validate(cmds, 4, 4, {"strict_bounds": true}) 20 if oren_is_err(valid) { fail(oren_err_msg(valid)) } 21 var buf = ui_raster.rasterize(cmds, 4, 4, {"strict_bounds": true}) 22 if oren_is_err(buf) { fail(oren_err_msg(buf)) } 23 if px(buf, 4, 1, 1, 1) != 255 { fail("scene pixel") } 24 if px(buf, 4, 2, 2, 0) != 255 { fail("scene rgba triangle pixel") } 25 var rc = ui_avm.present_frame(cmds, 4, 4, { 26 "sequence": 1, 27 "scale_milli": 3000, 28 "drawable_w": 12, 29 "drawable_h": 12, 30 "target_hz_milli": 120000, 31 "strict_bounds": true 32 }) 33 if oren_is_err(rc) { fail(oren_err_msg(rc)) } 34 print("scene3d-asset demo OK") 35 oren_exit(0) 36} 37 38main() 39