1<?php 2 3$iterations = 40; 4$images = 'php://output'; 5 6set_time_limit(0); 7require_once('Image/3D.php'); 8 9$world = new Image_3D(); 10$world->setColor(new Image_3D_Color(0, 0, 0)); 11 12$light1 = $world->createLight('Light', array(-500, 0, -500)); 13$light1->setColor(new Image_3D_Color(255, 50, 50)); 14 15$light2 = $world->createLight('Light', array(500, 0, -500)); 16$light2->setColor(new Image_3D_Color(50, 50, 255)); 17 18$p1 = $world->createObject('torus', array('inner_radius' => 50, 'outer_radius' => 90, 'detail_1' => 10, 'detail_2' => 1)); 19$p1->setColor(new Image_3D_Color(255, 255, 255)); 20 21$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, false); 22$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true); 23 24$rotation = $world->createMatrix('Rotation', array(0, 0, 15)); 25$Xrotation = $world->createMatrix('Rotation', array(10, 2, 0)); 26$move = $world->createMatrix('Move', array(0, 0, -10)); 27$renderer = $world->createRenderer('perspectively'); 28$driver = $world->createDriver('ASCII'); 29 30$world->render(2 * 100, 6 * 50, $images); 31 32$start = microtime(true); 33$i = 0; 34while ($i++ < $iterations) { 35 $light1->transform($rotation); 36 $light2->transform($rotation); 37 $p1->setColor(new Image_3D_Color(255, 255, 255)); 38 $p1->transform($Xrotation); 39 40 $driver->reset(); 41 $renderer->render($images); 42} 43 44$time = microtime(true) - $start; 45printf("%2.2f fps\n", $iterations / $time); 46 47