php3d/stl

STL file manipulation library for PHP 7

1.0.2 2016-07-27 22:36 UTC

This package is not auto-updated.

Last update: 2024-04-22 12:00:23 UTC


README

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