1<?php 2 3set_time_limit(0); 4require_once('Image/3D.php'); 5 6$world = new Image_3D(); 7$world->setColor(new Image_3D_Color(240, 240, 240)); 8 9$light1 = $world->createLight('Light', array(-300, 0, -300)); 10$light1->setColor(new Image_3D_Color(100, 100, 255)); 11 12$light2 = $world->createLight('Light', array(300, -300, -300)); 13$light2->setColor(new Image_3D_Color(100, 255, 100)); 14 15$count = 3; 16 17$size = 20; 18$offset = 10; 19 20for ($x = -($count - 1) / 2; $x <= ($count - 1) / 2; ++$x) { 21 for ($y = -($count - 1) / 2; $y <= ($count - 1) / 2; ++$y) { 22 for ($z = -($count - 1) / 2; $z <= ($count - 1) / 2; ++$z) { 23// if (max(abs($x), abs($y), abs($z)) < ($count - 1) / 2) continue; 24 if (max($x, $y, $z) <= 0) continue; 25 26 $cube = $world->createObject('quadcube', array($size, $size, $size)); 27 $cube->setColor(new Image_3D_Color(255, 255, 255, 75)); 28 $cube->transform($world->createMatrix('Move', array($x * ($size + $offset), $y * ($size + $offset), $z * ($size + $offset)))); 29 } 30 } 31} 32 33$world->transform($world->createMatrix('Rotation', array(220, 50, 0))); 34$world->transform($world->createMatrix('Scale', array(2, 2, 2))); 35 36$world->setOption(Image_3D::IMAGE_3D_OPTION_BF_CULLING, true); 37$world->setOption(Image_3D::IMAGE_3D_OPTION_FILLED, true); 38 39$world->createRenderer('perspectively'); 40$world->createDriver('SVGControl'); 41$world->render(250, 250, 'Image_3D_Cubes.svg'); 42 43echo $world->stats(); 44 45