php3d/stl

PHP 7 的 STL 文件操作库

1.0.2 2016-07-27 22:36 UTC

This package is not auto-updated.

Last update: 2024-09-23 13:49:03 UTC


README

Build Status Scrutinizer Code Quality Build Status

摘要

此库为 PHP 7 提供从 STL 文件中读取和写入 3D 对象的功能,这对于 3D 打印中的 3D 对象操作非常有用。

设置

将以下内容添加到您的 composer.json 文件中

  [...]
  "require": {
      [...]
      "php3d/stl": "1.*"
  }

然后运行 composer

composer.phar install

示例

读取 STL 文件

use php3d\stl\STL;
use php3d\stl\STLFacetNormal;

$stl = STL::fromString(file_get_contents("/path/to/file.stl"));

添加新的面

$stl->addFacetNormal(STLFacetNormal::fromArray(array(
    "coordinates" => array( 1, 2, 3), // Facet normal coordinates.
    "vertex" => array(
        array(
            3, 4, 5
        ),
        array(
            3, 4, 5
        ),
        array(
            3, 4, 5
        )
    )
)));

分割对象

(new STLSplit($stl))->split();

写回文件

file_put_contents("/path/to/file.stl", $stl->toString());