{"_id":"@2003scape/rsc-models","_rev":"1-0e59229d68fbd4c4c72364425c51eced","name":"@2003scape/rsc-models","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@2003scape/rsc-models","version":"1.0.0","description":"(de)serialize runescape classic 3D models","main":"./src/index.js","bin":{"rsc-models":"src/bin.js"},"scripts":{"build-dev":"browserify browser.js > browser.bundle.js"},"repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-models.git"},"keywords":["runescape","rsc","3d","models","wavefront","obj","mtl"],"author":{"name":"2003Scape Team"},"license":"AGPL-3.0+","bugs":{"url":"https://github.com/2003scape/rsc-models/issues"},"homepage":"https://github.com/2003scape/rsc-models#readme","dependencies":{"buffer":"^5.2.1","mkdirp":"^1.0.4","obj-file-parser":"^0.5.3","yargs":"^16.2.0"},"devDependencies":{"@2003scape/rsc-archiver":"^1.1.1","@2003scape/rsc-config":"^1.0.1","browserify":"^17.0.0","three":"^0.137.5"},"gitHead":"994ef0368ddbedd41f8477537368062edba52862","_id":"@2003scape/rsc-models@1.0.0","_nodeVersion":"15.14.0","_npmVersion":"7.7.6","dist":{"integrity":"sha512-DsVjlbsitvwAEldGixjZDdAgY36V+odUceW8depSa9cY8BUchPS3cfEZPTBYQceMTlVYpGKyFtXiNhd3QdD0Jg==","shasum":"f4179ffbf8c21a7ca8ee612fdc6ebebb164060ed","tarball":"https://registry.npmjs.org/@2003scape/rsc-models/-/rsc-models-1.0.0.tgz","fileCount":18,"unpackedSize":397011,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJiB+4oCRA9TVsSAnZWagAAOdIP/2LDjE3uGPisVyzQciio\nlk6XfwwdmsGQvDoj12/bEnDIcTwvQqYHMibZEPPClxSNwY7jSVYVJCzc8L5a\nN6SuaTrHhzVL6eMeAa9/SbLDr/4DIwaan0r1kCyv7wtX1P2sWIYyd2UjeNcw\nNROopwPj3lCT4b6A0GPU/mSnrcE0WN21Z6u2abkNXYXP+CQaT/8RLggnMcm4\nndutLgxyBGQxhJNULfjY3OPN7jwbxOhPz9LschXoXN1N2Qw8NuIRuLiqr9T6\ngJNuwQc08VsxeZEhYWvdPbNyufOSyWGbwrlMVPcGpygv7rpSgq9pBXSui+0N\nzAJQFAFyIYyXSGbWjRxO03azV1ij7DTVVb/Mk5gXiW0J1nxg35GI+TO1m0Op\nRevl0EUmao31vSrVbA7LgZplxAW31wrhCTb7LY6k9OI8AAEvgkLwT5j9pJsY\nAF0PiQmwBFRFMKc7y5sAOk/AGfkPgcaRK9lz/jK9i8Ar6AXqsDOfBRGg8dTq\nK1f7DMi7rmFNg7DAlwymLCo9PxDoYGkKQnHSLcunaD80LUPeurA444Mzs984\nQKkS9TteWIbizrJ2oyhs/TCjxQbK1OSRjqbMSS4MLeVxj+dMQSW2NvijZVVU\nBiEWH/xQG0hQ/iKiR7xnlHSHa+g3F+p46aS+NVVLxpYN5nz5u40EvRX5p2uR\nKaZb\r\n=VzOu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDfdobb2oiJbikh73+Nu5QuXlrcKQ3zlh/frcCybyHedAiAWEwHjnJ2YhUFILY7dFZpjxAinvcJoCZ5OCZfhW2MT1A=="}]},"_npmUser":{"name":"misterhat","email":"misterhat144@gmail.com"},"directories":{},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rsc-models_1.0.0_1644686888774_0.39588359845180365"},"_hasShrinkwrap":false}},"time":{"created":"2022-02-12T17:28:08.707Z","1.0.0":"2022-02-12T17:28:08.983Z","modified":"2022-04-04T10:34:57.017Z"},"maintainers":[{"name":"misterhat","email":"misterhat144@gmail.com"}],"description":"(de)serialize runescape classic 3D models","homepage":"https://github.com/2003scape/rsc-models#readme","keywords":["runescape","rsc","3d","models","wavefront","obj","mtl"],"repository":{"type":"git","url":"git+https://github.com/2003scape/rsc-models.git"},"author":{"name":"2003Scape Team"},"bugs":{"url":"https://github.com/2003scape/rsc-models/issues"},"license":"AGPL-3.0+","readme":"# rsc-models\n(de)serialize runescape classic 3D model archives to and from\n[wavefront .obj and .mtl](https://en.wikipedia.org/wiki/Wavefront_.obj_file)\nfiles. supports automatic UV unwrapping. works with blender import and export.\nuse [rsc-sprites](https://github.com/2003scape/rsc-sprites) to dump and pack\ntextures.\n\n[three.js model viewer](https://2003scape.github.io/rsc-models)\n\n*models dumped and loaded into blender:*\n\n![altar model](./doc/altar-blender.png)\n![range model](./doc/range-blender.png)\n![fire model](./doc/fire-blender.png)\n![chest model](./doc/chest-blender.png)\n\n\n*models exported from blender and loaded into the game:*\n\n![n64 table model](./doc/n64-game.png)\n![yoshi and gnome trees](./doc/yoshi-gnome-game.png)\n\n## install\n\n    $ npm install @2003scape/rsc-models # -g for CLI program\n\n## cli usage\n```\nrsc-models <command>\n\nCommands:\n  rsc-models dump-obj <config> <archive>    dump model OBJs from models jag\n                                            archive\n  rsc-models pack-obj <config> <archive>    pack model OBJ(s) into models jag\n  <files..>                                 archive\n\nOptions:\n  --help     Show help                                                 [boolean]\n  --version  Show version number                                       [boolean]\n```\n\n    $ rsc-models dump-obj config85.jag models36.jag -o models36-obj/\n    $ rsc-models pack-obj config85.jag models37.jag yoshi.obj n64.obj\n\n## example\n```javascript\nconst fs = require('fs');\nconst { Config } = require('@2003scape/rsc-config');\nconst { Models } = require('@2003scape/rsc-models');\n\nconst config = new Config();\nconfig.loadArchive(fs.readFileSync('./config85.jag'));\n\nconst models = new Models(config);\nmodels.loadArchive(fs.readFileSync('./models36.jag'));\n\n// dumping wavefront\nconst tree = models.getModelByName('tree');\n\nfs.writeFileSync('./tree.obj', tree.getObj());\nfs.writeFileSync('./tree.mtl', tree.getMtl());\n\n// loading external wavefront\nconst yoshi = models.fromWavefront(\n    fs.readFileSync('./yoshi.obj', 'utf8'),\n    fs.readFileSync('./yoshi.mtl', 'utf8')\n);\n\nmodels.setModel('tree', yoshi);\n\nfs.writeFileSync('./models37.jag', models.toArchive());\n```\n\n## api\n### models = new Models({ objects, textures }, extraNames = ANIMATED\\_MODELS)\ncreate a new models (de)serializer instance. extraNames are an array of model\nnames that aren't stored in the config archive's objects cache.\n\n### models.loadArchive(buffer)\nloads a models jag archive buffer.\n\n### model.modelNames\narray of valid model names.\n\n### models.getModels()\nreturn an array of all `Model` instances.\n\n### models.getModelByName(name)\nreturn a `Model` instance by name (defined in\n[rsc-config](https://github.com/2003scape/rsc-config/blob/master/config-json/models.json)).\n\n### models.getModelById(id)\nreturn a `Model` instance based on index of model name.\n\n### models.fromWavefront(objFile, mtlFile)\nreturn a `Model` instance from wavefront .obj and .mtl file strings.\n\n### models.toArchive()\nreturn a models jag archive buffer.\n\n### model = new Model({ textureNames }, { name, vertices, faces }?)\ncreate a new model, either empty or using existing properies.\n\n### model.name\nname of ob3 file to use in archive (without extension).\n\n### model.vertices\narray of `{ x, y, z }` integers.\n\n### model.faces\n```javascript\n[\n    {\n        // front face material\n        fillFront: {\n            i: 1, // illumination, 0 or 1\n            r, g, b, // (0-248) each channel, or\n            texture: textureIndex // from rsc-config\n        } // or null,\n        fillBack: null, // same format as fillFront, or null\n        vertices: [] // array of vertex indexes (defined above)\n    }\n]\n```\n\n### model.updateFillIDs()\niterate through `model.faces` and update materials for .mtl file generation.\n\n### model.getObj()\nreturn model geometry string in wavefront .obj format.\n\n### model.getMtl()\nreturn model materials string in wavefront .mtl format.\n\n### model.toJSON()\nreturn public serializable properties.\n\n### ANIMATED\\_MODELS\narray of hard-coded model names that aren't in config archive.\n\n## model bugs\n\nthe following models have faces with less than three vertices:\n\n * logbridgelow\n * logbridgehigh\n * logbridgecurvedhigh\n * logbridgecurvedlow\n * treeplatformlow2\n * treeplatformhigh2\n * stonestand\n * grand tree-lev 0\n * tribalstature\n * grand tree-lev 1\n * grand tree-lev 2\n * fourwayplatform-lev 0\n * fourwayplatform-lev 1\n * grand tree-lev 3\n * blurberrybar\n * cave snaptrap\n * cave snaptrapa\n * rocksteps\n\nthere are also 25 secret models that are never loaded in the game (hashed):\n\n * 1037362809\n * -1060436729\n * -1115958269\n * -1220733691\n * 1227393374\n * -1263331649\n * 1347842162\n * -1430585029\n * 1512310831\n * 1526156672\n * 1540002513\n * 1657318544\n * 1721021053\n * 2142891767\n * -380606436\n * 515450526\n * 529296367\n * 538300861\n * 550294861\n * 564140702\n * 587507422\n * -669716258\n * -741690938\n * 763644315\n * 846098451\n\n## license\nCopyright 2022  2003Scape Team\n\nThis program is free software: you can redistribute it and/or modify it under\nthe terms of the GNU Affero General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your option)\nany later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY\nWARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A\nPARTICULAR PURPOSE. See the GNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License along\nwith this program. If not, see http://www.gnu.org/licenses/.\n","readmeFilename":"README.md"}