安装库
composer require rikudou/php-scad:dev-master
这个库的事情事理只是用来天生OpenSCAD的代码,OpenSCAD也是一个开源项目,OpenSCAD 是一个自由的 3D CAD 软件。OpenSCAD 非常轻量和灵巧。OpenSCAD 不是交互式的。你须要‘编程’模型,OpenSCAD 来阐明这些代码来渲染一个可视化模型。在某种意义上说,它是一个编译器。你不能直接绘制模型,而是描述模型。
OpenSCAD

PhpScad库可以天生OpenSCAD代码,像下面所示的
translate([10, 0, 0]) // translate([x, y, z]) - moves the model by given coordinatescube([10, 10, 10]); // cube([width, depth, height])difference() { // only the difference between child objects is rendered cube([5, 10, 15]); cylinder(10, 5, 5); // cylinder(height, bottomRadius, topRadius)}
下面是预览图
PHP代码如下
<?phpuse Rikudou\PhpScad\ScadModel;use Rikudou\PhpScad\Shape\Cube;use Rikudou\PhpScad\Combination\Difference;use Rikudou\PhpScad\Shape\Cylinder;$model = new ScadModel();$model = $model ->withRenderable((new Cube(width: 10, depth: 10, height: 10))->movedRight(10)) // using named parameters ->withRenderable(new Difference( new Cube(5, 10, 15), // using positional parameters new Cylinder(height: 10, bottomRadius: 5, topRadius: 5), ));$model->render(__DIR__ . '/output.scad');
感兴趣的可以去玩下
OpenSCAD
OpenSCAD
#程序员#
#寻衅30天在头条写日记#
#runphp#