{"id":16473098,"url":"https://github.com/binki/node-babylonjs-blender","last_synced_at":"2025-03-23T11:32:50.034Z","repository":{"id":57189053,"uuid":"71208156","full_name":"binki/node-babylonjs-blender","owner":"binki","description":"CLI and node library wrapper around BabyonJS’s Blender export addon.","archived":false,"fork":false,"pushed_at":"2019-07-07T17:11:24.000Z","size":259,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T20:07:35.105Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-18T04:14:29.000Z","updated_at":"2023-08-08T10:50:05.000Z","dependencies_parsed_at":"2022-09-15T03:53:33.037Z","dependency_job_id":null,"html_url":"https://github.com/binki/node-babylonjs-blender","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fnode-babylonjs-blender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fnode-babylonjs-blender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fnode-babylonjs-blender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fnode-babylonjs-blender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binki","download_url":"https://codeload.github.com/binki/node-babylonjs-blender/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245097158,"owners_count":20560311,"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":[],"created_at":"2024-10-11T12:25:20.542Z","updated_at":"2025-03-23T11:32:49.643Z","avatar_url":"https://github.com/binki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/binki/node-babylonjs-blender.svg?branch=master)](https://travis-ci.org/binki/node-babylonjs-blender)\n[![Build status](https://ci.appveyor.com/api/projects/status/ynqc3cbu59ydrw0w?svg=true)](https://ci.appveyor.com/project/binki/node-babylonjs-blender)\n\n# Synopsis\n\nThis makes it easier (hopefully) to export a Blender scene as\nBabylonJS, reducing the need to write custom tools for your own\nbuildsystem.\n\n# Installation\n\nTo use this module, you must perform the following configuration\nsteps:\n\n1. Ensure `blender` is in your `PATH`. If you are using Windows, it is\n   your responsibility to figure out how to do this. Most Operating\n   Systems and Package Managers will manage this for you—and if they\n   don’t, that means you know what you are doing and are thus on your\n   own ^^.\n\n2. Install (official/normal, Tower of Babylon not supported—patches\n   welcome of course) [the BabylonJS Blender\n   Exporter](https://doc.babylonjs.com/exporters/Installing__the_Babylon_Exporter)\n   from\n   [here](https://github.com/BabylonJS/Babylon.js/tree/master/Exporters/Blender)\n   into Blender. You may use the `node-babylonjs-blender-install`\n   command to automatically do this for you. This command downloads a\n   specific known working addon version by default, but if you specify\n   a `.zip` file as an argument it will install that as a Blender\n   addon for you (even non-BabylonJS addons).\n\n# Usage\n\nCurrently, all of the interfaces operate on real files. If other sorts\nof handling is needed, please [submit\npatches/issues](https://github.com/binki/node-babylonjs-blender) to\ndiscuss both how to do this and what the API should look like.\n\nCurrently, blender is interacted with in a sessionless way, but it is\npossible that great performance gains could be realized by persisting\nand reusing a blender instance for many scenes. The API and CLI\nprovide a batching interface, so any improvements to the\nimplementation will automatically benefit consumers of those\ninterfaces.\n\n## CLI\n\n### Installation\n\nDepending on how you use `npm`, the following might be how\nyou obtain this tool:\n\n    $ npm install -g babylonjs-blender\n\n### Usage\n\nThe CLI is quite simplified but it does (pointlessly, for now) support\nbatching. Just specify all of the files that need to be exported as\narguments:\n\n    $ node-babylonjs-blender myBlendFile1.blend myBlendFile2.blend\n\nEach output shall be written out to the current directory with\n`.blend` stripping off (if it exists) and `.babylon`\nappended. Appending `.babylon` is not optional and is intended to\nencourage respect of conventions.\n\nTo run jobs in parallel, use `-j`. This is similar to `make(1)`’s `-j`\nexcept that for specifying unlimited jobs you have to provide an empty\nstring as an argument because of the limitations of the used\n`getopt(3)` implementation. However, it is recommended not to use\nunlimited jobs unless you know what you are doing.\n\n4 parallel jobs:\n\n    $ node-babylonjs-blender -j4 *.blend\n\nUnlimited jobs example for completeness:\n\n    $ node-babylonjs-blender -j '' *.blend\n\nTo request the exporter to inline textures (instead of emitting them\nas separate files), use the `-i` option. This will make the resulting\nfiles easier to load but will prevent BabylonJS from doing incremental\nloading.\n\nFor a review of options, see `-h` or `--help`:\n\n    $ node-babylonjs-blender --help\n\n## API\n\n### Installation\n\nTo reference in your project to consume the API, install [the npm\n`babylonjs-blender`\npackage](https://www.npmjs.com/package/babylonjs-blender) package:\n\n    $ npm install --save babylonjs-blender\n\n### Usage\n\nThe module is callable. You may pass a job to it (a plain object with\n`input` and `output` keys) or pass those as separate arguments. It\nreturns a Promise whose value is a job object. If you passed in a\nplain object job, the resolved value is identical. Otherwise, it is\ngenerated. If `output` was not supplied (as an argument or key), the\nresolved value’s `output` key will specify the path of the exported\nfile.\n\n    const babylonjsBlender = require('babylonjs-blender');\n    babylonjsBlender('myFile.blend', 'arbitraryName.babylon').then(job =\u003e {\n      console.log('Blender finished');\n    });\n    babylonjsBlender('myFile.blend').then(job =\u003e {\n      console.log(`Blender wrote output to ${job.output}.`);\n    });\n    babylonjsBlender({\n      input: 'myFile.blend',\n      inlineTextures: true,\n    }).then(job =\u003e {\n      console.log(`Blender wrote output to ${job.output}.`);\n    });\n\n### Job Object\n\nAs mentioned, each job is represented by a plain object. The keys are\ndefined as follows:\n\n* `input` *in* (required): The path to the input Blender file.\n\n* `output` *in/out* (optional): The path to the destination file. Will\n   be set for you if unspecified.\n\n* `outputPath` *in/out* (optional): The path to store textures\n   in. Defaults to `path.dirname(output)`. Will be set for you if\n   unspecified.\n\n* `builtAssets` *out*: The filenames (relative to `outputPath`) of any\n   generated textures. If `inlineTextures` will always be empty.\n\n* `inlineTextures` *in/out* (optional): Inline textures rather than\n   writing them as separate files. This asks the blender exporter\n   addon to embed the textures as `data:image…` URis directly in the\n   generated babylon file. Defaults to `false`.\n\n* `userData` *in/out* (optional): This key is set aside for the\n   caller’s use.  No future version of this library will repurpose\n   this key for itself. This may be useful to tack arbitrary data to a\n   job. Note that you may opt to use Symbols directly on the object\n   instead.\n\n### Batching\n\nIt is conceivable that in the future this module might gain the\nability to reuse blender instances. If it does, each subsequent job\ncan save up to the amount of time blender takes to initialize\nitself. The implementation does not support that now, but provides a\nbatching API.\n\nThe exported `BabylonjsBlenderWorker` class may be instantiated to\nrepresent a reusable exporter instance. A worker is an object stream\nwhich accepts job objects (see above) or strings. The worker will\nprocess one job object at a time and emit a job object upon\ncompletion. If the `output` property was not set on the job, it will\nbe set as the job is consumed.\n\n    const BabylonjsBlenderWorker = require('babylonjs-blender').BabylonjsBlenderWorker;\n    const worker = new BabylonjsBlenderWorker();\n    for (const job in ['a.blend', 'b.blend', ]) {\n      worker.write(job);\n    }\n    worker.end();\n    worker.on('data', job =\u003e {\n      console.log(`${job.input} exported to ${job.output}`);\n    });\n\nAs convenience, the worker also provides `process()` which returns a\nPromise and behaves much like calling the module as a function\ndirectly except that it uses the current worker. It also uses the\nstreams interface, so if you have the stream piped to anywhere or are\nlistening on any stream events, you will observe jobs created by\nit. You are free to mix this with streams-style code or call it\nmultiple times prior to completion.\n\n    const BabylonjsBlenderWorker = require('babylonjs-blender').BabylonjsBlenderWorker;\n    const worker = new BabylonjsBlenderWorker();\n    worker.process('x.blend')\n      .then(job =\u003e {\n        console.log(`${job.input} exported to ${job.output}`);\n      });\n    worker.end();\n\nIf you have a large number of jobs, it is recommended to pool workers\nand distribute jobs among them as they become available. Currently I\ndo not know of a very easy way to do this, but I think [the\nimplementation of the CLI](bin/node-babylonjs-blender.js) is an\nexample of how to accomplish this.\n\nThe constructor accepts `options` which is passed through to the\n`Transform` constructor. You may override things like `highWaterMark`\nif you use that to control load balancing among workers (I haven’t\nfound a good solution for this yet, but I’m imagining that a stream\nfanout/fanin construct could be made and automtaically balance based\non `highWaterMark` and\n[`drain`](https://nodejs.org/api/stream.html#stream_event_drain)).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinki%2Fnode-babylonjs-blender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinki%2Fnode-babylonjs-blender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinki%2Fnode-babylonjs-blender/lists"}