headless-three 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/index.js +7 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -108,6 +108,9 @@ Renders a scene to an image buffer or file. When saving to a file, the format is
108
108
  | `height` | `1024` | Output height in pixels |
109
109
  | `path` | | If provided, saves to this file path. Format is inferred from the extension |
110
110
  | `format` | | Output format (`"png"`, `"jpeg"`, `"webp"`, `"avif"`, `"tiff"`, etc.). Overrides extension inference |
111
+ | `colorSpace` | `THREE.SRGBColorSpace` | Renderer output color space |
112
+ | `clearColor` | `0x000000` | Background clear color |
113
+ | `clearAlpha` | `0` | Background clear alpha (0 = transparent) |
111
114
 
112
115
  ```js
113
116
  // Save to file (format inferred from extension)
package/index.js CHANGED
@@ -141,10 +141,16 @@ export default async function({ Canvas, Image, ImageData }) {
141
141
  return tex
142
142
  },
143
143
 
144
- async render({ scene, camera, width = 1024, height = 1024, path, format }) {
144
+ async render({ scene, camera, width = 1024, height = 1024, path, format, colorSpace, clearColor, clearAlpha }) {
145
145
  const glCtx = createContext(width, height)
146
146
  const renderer = new THREE.WebGLRenderer({ context: glCtx })
147
147
  renderer.setSize(width, height)
148
+ if (colorSpace) {
149
+ renderer.outputColorSpace = colorSpace
150
+ }
151
+ if (clearColor !== undefined || clearAlpha !== undefined) {
152
+ renderer.setClearColor(clearColor ?? 0x000000, clearAlpha ?? 0)
153
+ }
148
154
  camera.projectionMatrix.elements[5] *= -1
149
155
  const gl = renderer.getContext()
150
156
  const currentFrontFace = gl.getParameter(gl.FRONT_FACE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "headless-three",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Headless Three.js rendering for Node.js, made simple.",
5
5
  "author": "Ewan Howell <ewanhowell5195> & CCCode",
6
6
  "license": "MIT",