PHPackages                             libre3d/render-3d - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. libre3d/render-3d

ActiveLibrary

libre3d/render-3d
=================

Wrapper library to help render preview images for common 3D file formats.

1.2.1(8y ago)331.4k4[4 issues](https://github.com/libre3d/render-3d/issues)LGPLPHPPHP &gt;=5.4.0

Since Dec 18Pushed 8y ago6 watchersCompare

[ Source](https://github.com/libre3d/render-3d)[ Packagist](https://packagist.org/packages/libre3d/render-3d)[ Docs](http://github.com/libre3d/render-3d)[ RSS](/packages/libre3d-render-3d/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (7)Used By (0)

[![Build Status](https://camo.githubusercontent.com/81cbd0f673850a3d3493c1f7d8a6e74807962788878ef3a03db7341badb28522/68747470733a2f2f7472617669732d63692e6f72672f6c6962726533642f72656e6465722d33642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/libre3d/render-3d)[![codecov.io](https://camo.githubusercontent.com/83a4058ff01b9fc45a7bc4094a7105f04e9f102ed4be220c8a5f37c98792dc93/68747470733a2f2f636f6465636f762e696f2f6769746875622f6c6962726533642f72656e6465722d33642f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/libre3d/render-3d?branch=master)

render-3d
=========

[](#render-3d)

Wrapper library to help render common 3d file formats.

Requirements
============

[](#requirements)

This requires a few things to work.

- For **Open SCAD** files: Requires [Open SCAD](http://www.openscad.org/)
- For the actual rendering, requires [POV Ray](http://www.povray.org/)
- [Composer](https://getcomposer.org/)
- **stl2pov v3.2.0+** python script, part of [stltools](http://rsmith.home.xs4all.nl/software/stltools.html))
    - No longer required as of 1.2.0. See issue #4 for details.

Installation
============

[](#installation)

If you are using composer, just add `"libre3d/render-3d": "~1.2.0"` to the `require` section, then run `composer update`.

Or if you do not use composer, clone this repository. Then [get composer](http://getcomposer.com). Then run `composer install` from the root folder of this library to install dependencies.

Usage
=====

[](#usage)

If you don't already have the composer vendor autoload PHP file included in your project, you will need to include it like:

```
require 'render-3d/vendor/autoload.php';
```

That path may need to be adjusted.

Then you will need to initialize the Render3d object and let it know the locations of a few things (note that this is a quick example, there are many options and different ways that files can be rendered using this library):

```
$render3d = new \Libre3d\Render3d\Render3d();

// this is the working directory, where it will put any files used during the render process, as well as the final
// rendered image.
$render3d->workingDir('/path/to/working/folder/');

// Set paths to the executables on this system
$render3d->executable('openscad', '/path/to/openscad');
$render3d->executable('povray', '/path/to/povray');

try {
	// This will copy in your starting file into the working DIR if you give the full path to the starting file.
	// This will also set the fileType for you.
	$render3d->filename('/path/to/starting/stlfile.stl');

	// Render!  This will do all the necessary conversions as long as the render engine (in this
	// case, the default engine, PovRAY) "knows" how to convert the file into a file it can use for rendering.
	// Note that this is a multi-step process that can be further broken down if you need it to.
	$renderedImagePath = $render3d->render('povray');

	echo "Render successful!  Rendered image will be at $renderedImagePath";
} catch (\Exception $e) {
	echo "Render failed :( Exception: ".$e->getMessage();
}
```

The main workflow:
==================

[](#the-main-workflow)

- Convert to STL file format (if not starting with an STL file)
- Convert the STL to a POVRay file format.
- Render an image using povray and a common scene template.

Options
=======

[](#options)

The `$Render3d->render()` method takes an optional second parameter for `$options`, which is an array of options. You can also set the options before hand calling `$Render3d->options(['option1' => 'val1']);`

Here are a few options of note:

- **buffer** This controls what is done with output from the commands run on the command line. The valid values are:
    - `Render3d::BUFFER_OFF` - Default value. Nothing is displayed and nothing is buffered.
    - `Render3d::BUFFER_ON` - Buffers the output, and saves so that you can later retrieve it with `$Render3d->getBufferAndClean()`
    - `Render3d::BUFFER_STD_OUT` - Sends any output directly to std out (sends to the browser or console)
- **width** - The width of the rendered image, in pixels. Defaults to 1600
- **height** - The height of the rendered image, in pixels. Defaults to 1200
- **fwrite\_buffer\_size** - integer - Buffer size in bytes, when writing the POV file (and possibly others). Some systems may see better performance with a different buffer size other than the default. Defaults to 8000 (set to 0 for no fwrite buffering)

Version &amp; Changelog
=======================

[](#version--changelog)

We adhere to the [Semantic Versioning Specification (SemVer)](http://semver.org/).

**Changelog:** We use Github issues and milestones to keep track of changes from version to version. To see what changes were in a specific version, look at the closed issues for the corresponding milestone.

Credit
======

[](#credit)

**Origin**

This library started out as a port of a bash script, though we mainly took the overall "how it works" and re-wrote most of the fine details. The original page talking about it is no longer around, but luckily we found a cached version on [Wayback](https://web.archive.org/web/20110312125335/http://www.robottrouble.com/2009/12/01/auto-rendering-stl-files-to-png/)

You can find the original files still (as of the last time I checked) at  - the `render.sh` is the overall file that does everything.

We took the "idea" of how the shell script did things, and ported it into a PHP library that made system calls. The look of the rendered images was lacking, so the scene's template file was almost completely changed. We found that POVRay has a lot of potential behind it if you take the time to learn how to set up the scene and do a little math to figure out the best camera angle and such.

**src/Scenes/axes\_macro.inc**

Like the bash script, we also stuck to using the [AxesAndGridMacro](http://lib.povray.org/searchcollection/index2.php?objectName=AxesAndGridMacro&contributorTag=SharkD)to create a nice grid. We didn't change the inc file but we drastically changed how it was used, it mainly just renders a grid on the floor now. We also made it change the grid size dynamically depending on the size of the model, it will always be in a scale of 10, like 10 mm, 10cm, etc. depending on how large the model is.

**stl2pov**

Early versions relied on the [stl2pov python script](http://rsmith.home.xs4all.nl/software/stltools.html). In version 1.2.0 the conversion has been ported into this PHP script.

We want to give a **special thanks** to the author of [stltools](http://rsmith.home.xs4all.nl/software/stltools.html), he has been a great help with our quest to port the functionality into PHP by answering our questions in-depth. If you are looking for conversion tools that use Python, we highly recommend [stltools](http://rsmith.home.xs4all.nl/software/stltools.html).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~182 days

Recently: every ~223 days

Total

6

Last Release

3255d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cce29867bc977c0b0df2ce47c9ff96ad99d8350e97d73b2d06d53a94bf6b16b?d=identicon)[jonyo](/maintainers/jonyo)

---

Top Contributors

[![jonyo](https://avatars.githubusercontent.com/u/2767294?v=4)](https://github.com/jonyo "jonyo (74 commits)")

---

Tags

renderstlscad

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/libre3d-render-3d/health.svg)

```
[![Health](https://phpackages.com/badges/libre3d-render-3d/health.svg)](https://phpackages.com/packages/libre3d-render-3d)
```

###  Alternatives

[jenssegers/blade

The standalone version of Laravel's Blade templating engine for use outside of Laravel.

8661.2M109](/packages/jenssegers-blade)[atk4/ui

Agile UI - Web Component Framework written in PHP

454540.1k32](/packages/atk4-ui)[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k13](/packages/phug-phug)[davidbadura/markdown-builder

Markdown Builder

22899.4k5](/packages/davidbadura-markdown-builder)[bnomei/kirby3-janitor

Kirby Plugin for running commands like cleaning the cache from within the Panel, PHP code or a cronjob

9339.9k2](/packages/bnomei-kirby3-janitor)[text/template

Simple and secure string-template-engine (Twig-like syntax) with nested if/elseif/else, loops, filters. Simple OOP api: Just one class doing the job (2-lines of code). Fast and secure: No code-generation, no eval'ed() code. Extensible by callbacks. Fully tested. Rich examples included.

38201.1k10](/packages/text-template)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
