{"id":15493536,"url":"https://github.com/sinclairzx81/blender-node","last_synced_at":"2025-04-22T20:11:53.285Z","repository":{"id":37705252,"uuid":"256678158","full_name":"sinclairzx81/blender-node","owner":"sinclairzx81","description":"NodeJS binding to Blenders Python Scripting Environment","archived":false,"fork":false,"pushed_at":"2022-06-23T11:07:33.000Z","size":6501,"stargazers_count":64,"open_issues_count":1,"forks_count":10,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-22T20:11:49.125Z","etag":null,"topics":["blender","interop","nodejs","rendering"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sinclairzx81.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-18T05:38:41.000Z","updated_at":"2025-03-20T18:40:57.000Z","dependencies_parsed_at":"2022-09-15T22:43:07.043Z","dependency_job_id":null,"html_url":"https://github.com/sinclairzx81/blender-node","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fblender-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fblender-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fblender-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sinclairzx81%2Fblender-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sinclairzx81","download_url":"https://codeload.github.com/sinclairzx81/blender-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250316056,"owners_count":21410476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blender","interop","nodejs","rendering"],"created_at":"2024-10-02T08:07:55.828Z","updated_at":"2025-04-22T20:11:53.248Z","avatar_url":"https://github.com/sinclairzx81.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BlenderNode\n\nNodeJS binding to the Blender Python Scripting Environment\n\n## Example\n```typescript\nimport { Blender } from '../src/index'\n\nconst bpy = new Blender()\nbpy.ops.wm.open_mainfile({ filepath: 'model.blend' })\nbpy.context.scene.render.filepath = 'output.png'\nbpy.context.scene.render.resolution_x = 800\nbpy.context.scene.render.resolution_y = 600\nbpy.context.scene.cycles.device = 'CPU'\nbpy.context.scene.cycles.samples = 64\nbpy.ops.render.render({ \n    write_still: true, \n    use_viewport: true \n})\nbpy.dispose()\n```\n\n## Overview\n\nBlenderNode is an experimental NodeJS binding to Blenders Python Scripting REPL. It provides marshalled access to Blenders `bpy.data`, `bpy.ops` and `bpy.context` objects enabling headless scripts to be developed within a NodeJS environment. The library itself is primarily generated from the official Blender 2.82a documentation and provides generated TypeScript documentation across all Python classes found in the `types` and `ops` Blender namespaces.\n\nThis project was written as a proof of concept to test the feasibility of having JavaScript naturally interact with the Blender Python REPL environment purely over stdio. It uses a variety of novel approaches to facilitate interactions, including synchronous IO to the Blender process using threads and atomics, as well as various JavaScript tricks to have JavaScript map over to Python data structures.\n\nBuilt against Blender 2.82a. Requires Node v12.16.1 and above.\n\nLicense MIT\n\n## Example\n\nThe following sets up a new scene and adds a camera and mesh. It is important that Blender is added to a `PATH` environment variable. The Blender process will be started with the call to the `Blender()` constructor.\n\n```typescript\nimport { Blender } from '../src/index'\n\nconst bpy = new Blender()\n\n// create camera\nconst camera_data = bpy.data.cameras.new({ name: \"camera-data\" })\nconst camera = bpy.data.objects.new({ \n    name: 'camera-object', \n    object_data: camera_data \n})\n\n// create mesh\nconst mesh_data = bpy.data.meshes.new({ name: 'mesh-data'})\nconst mesh = bpy.data.objects.new({ \n    name: 'mesh-object', \n    object_data: mesh_data \n})\nmesh_data.from_pydata({\n    vertices: [\n        [1, 0, 0], \n        [0, 1, 0], \n        [1, 1, 0]\n    ],\n    edges: [\n        [0, 1], \n        [1, 2], \n        [2, 0]\n    ],\n    faces: [[0]]\n})\nmesh_data.calc_normals()\n\n// create scene, add mesh and camera.\nconst scene = bpy.data.scenes.new({name: 'my-scene'})\nscene.camera = camera\nscene.collection.objects.link({ object: mesh })\n\n// list out vertices and normals\nfor(const vertex of mesh_data.vertices) {\n    console.log(vertex.co, vertex.normal)\n}\n\n// terminate blender process\nbpy.dispose()\n```\n\n## Performance\n\nBlenderNode interacts with Blender via stdio pipes. While interactions to the Blender process are asynchronous, this library will block while interacting with Blender. This is by design and inline with Blenders modal API. Calls made to the Blender process will block until Blender has responded. This includes reading and writing data to Blender properties, as well as calling functions.\n\nBlocking the NodeJS thread is generally not a problem for simple scripts, however if looking to run Blender in a HTTP or other network context, it is highly recommended moving all code that interacts with Blender to a separate NodeJS Worker Thread.\n\n## Project Tasks\n\n```bash\nnpm start              # same as example:index\nnpm run clean          # cleans the project.\nnpm run build          # builds the project.\nnpm run example:index  # runs the 'index' example in watch mode\nnpm run example:scene  # runs the 'scene' example in watch mode\nnpm run example:render # runs the 'render' example in watch mode\nnpm run generate       # generates and caches the API from blender documentation\nnpm run generate:full  # rebuilds the cache and re-generates\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fblender-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsinclairzx81%2Fblender-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsinclairzx81%2Fblender-node/lists"}