php3d/stl

STL file manipulation library for PHP 7


Keywords
3d, stl, stereolithography, 3d printing
License
MIT

Documentation

php3d-stl

Build Status Scrutinizer Code Quality Build Status

Synopsis

This library provides PHP 7 functionality for reading and writing from and to 3D objects stored in STereoLithography (STL) files, useful for manipulating 3D objects for 3D Printing.

Set-up

Add this to your composer.json file:

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

Then run composer:

composer.phar install

Examples

Read an STL file:

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

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

Add a new facet:

$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
        )
    )
)));

To split an object:

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

Write back to file:

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