{"_id":"@bitruvius/tiles3d-mesh","_rev":"8-d73cf670ac764839745664e800f70b46","name":"@bitruvius/tiles3d-mesh","dist-tags":{"latest":"0.3.3"},"versions":{"0.3.0":{"name":"@bitruvius/tiles3d-mesh","version":"0.3.0","keywords":["bitruvius","geospatial","3d-tiles","mesh","draco","ktx2","worker","decoder"],"license":"SEE LICENSE IN LICENSE","_id":"@bitruvius/tiles3d-mesh@0.3.0","maintainers":[{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},{"name":"danrhedges","email":"danrhedges@gmail.com"}],"homepage":"https://dev.bitruvius.com/sdks/js/","bugs":{"url":"https://github.com/bitruvius/support"},"dist":{"shasum":"a03766edbfd1c35f0ba84f4ba16658ae5e5e5e1b","tarball":"https://registry.npmjs.org/@bitruvius/tiles3d-mesh/-/tiles3d-mesh-0.3.0.tgz","fileCount":12,"integrity":"sha512-0iJxbPVj0vfC+Z78OGepCb8bPiEnYS1kH4O0xskqfzeA8KUT1Dr7qpqYc7shmI9MT668ZQuKoq8JQExabp5nZQ==","signatures":[{"sig":"MEUCIQD4udhs0XC55JMunCiyEznu276h1l51bx5fn/kWI3x8QAIgajGcLhfRWXArNwqukxXIRq3tiM9iZLTTKDFLcqiU9KU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32470},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"a03766edbfd1c35f0ba84f4ba16658ae5e5e5e1b","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"test":"bun test","build":"bun build ./src/index.ts ./src/mesh-decode-worker.ts --outdir dist --format esm --target browser --minify --external '@bitruvius/*' && tsc --emitDeclarationOnly"},"_npmUser":{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},"_integrity":"sha512-0iJxbPVj0vfC+Z78OGepCb8bPiEnYS1kH4O0xskqfzeA8KUT1Dr7qpqYc7shmI9MT668ZQuKoq8JQExabp5nZQ==","_npmVersion":"10.8.3","description":"Composed off-main-thread decoder for OGC 3D-Tiles textured meshes: wires @bitruvius/gltf + draco + meshopt + ktx2 into a worker-pooled MeshTileDecoder","directories":{},"sideEffects":["./src/index.ts"],"_nodeVersion":"24.3.0","dependencies":{"@bitruvius/gltf":"^0.3.0","@bitruvius/ktx2":"^0.3.0","@bitruvius/draco":"^0.3.0","@bitruvius/meshopt":"^0.3.0","@bitruvius/geo-core":"^0.3.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tiles3d-mesh_0.3.0_1785722182268_0.2174087434272849","host":"s3://npm-registry-packages-npm-production"}},"0.3.1":{"name":"@bitruvius/tiles3d-mesh","version":"0.3.1","keywords":["bitruvius","geospatial","3d-tiles","mesh","draco","ktx2","worker","decoder"],"license":"SEE LICENSE IN LICENSE","_id":"@bitruvius/tiles3d-mesh@0.3.1","maintainers":[{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},{"name":"danrhedges","email":"danrhedges@gmail.com"}],"homepage":"https://dev.bitruvius.com/sdks/js/","bugs":{"url":"https://github.com/bitruvius/support"},"dist":{"shasum":"f34d7491d119b723abe79fb25d07efd4ca9b06dc","tarball":"https://registry.npmjs.org/@bitruvius/tiles3d-mesh/-/tiles3d-mesh-0.3.1.tgz","fileCount":12,"integrity":"sha512-c04bbdEbmI5WGpoMw5CibNG9qsVG3AH9mcy1YCWODBSVTHAFv+3fxPKwaKoeUm8K9vBNobEq+7c1gyV4C7l5RQ==","signatures":[{"sig":"MEUCIA1F+VUWf8H4ZsR4hQAdvaPsh4LBrlztXA4vg5dJNPQ4AiEAm3y4F/Z3KO09NGxZ+eC4nEH38OoJ93vlcL3jhL+StZk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32800},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"f34d7491d119b723abe79fb25d07efd4ca9b06dc","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"test":"bun test","build":"bun build ./src/index.ts ./src/mesh-decode-worker.ts --outdir dist --format esm --target browser --minify --external '@bitruvius/*' && tsc --emitDeclarationOnly"},"_npmUser":{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},"_integrity":"sha512-c04bbdEbmI5WGpoMw5CibNG9qsVG3AH9mcy1YCWODBSVTHAFv+3fxPKwaKoeUm8K9vBNobEq+7c1gyV4C7l5RQ==","_npmVersion":"10.8.3","description":"Composed off-main-thread decoder for OGC 3D-Tiles textured meshes: wires @bitruvius/gltf + draco + meshopt + ktx2 into a worker-pooled MeshTileDecoder","directories":{},"sideEffects":["./src/index.ts"],"_nodeVersion":"24.3.0","dependencies":{"@bitruvius/gltf":"^0.3.1","@bitruvius/ktx2":"^0.3.1","@bitruvius/draco":"^0.3.1","@bitruvius/meshopt":"^0.3.1","@bitruvius/geo-core":"^0.3.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tiles3d-mesh_0.3.1_1785725527869_0.39618196492632296","host":"s3://npm-registry-packages-npm-production"}},"0.3.2":{"name":"@bitruvius/tiles3d-mesh","version":"0.3.2","keywords":["bitruvius","geospatial","3d-tiles","mesh","draco","ktx2","worker","decoder"],"license":"SEE LICENSE IN LICENSE","_id":"@bitruvius/tiles3d-mesh@0.3.2","maintainers":[{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},{"name":"danrhedges","email":"danrhedges@gmail.com"}],"homepage":"https://dev.bitruvius.com/sdks/js/","bugs":{"url":"https://github.com/bitruvius/support"},"dist":{"shasum":"7910d93536c6b5e577c3e70f3c195cc9540868af","tarball":"https://registry.npmjs.org/@bitruvius/tiles3d-mesh/-/tiles3d-mesh-0.3.2.tgz","fileCount":12,"integrity":"sha512-MP098th2TfFGeP/1kwidXNtb71VrE0p+GQi7arZiyxalhVnVk6H4FTsEjkRxYj3A6E9LlfhfgDi57FXqeKO7Fw==","signatures":[{"sig":"MEQCIFs5xOHvjIlkhDmvAnsK3mLNzNnuiMm36N9bD3H9car5AiAKOkgBeFn4kwYmjkKoTiJ4KR/7FzmYOMZVZVcCx/VvfA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":32800},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"7910d93536c6b5e577c3e70f3c195cc9540868af","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"test":"bun test","build":"bun build ./src/index.ts ./src/mesh-decode-worker.ts --outdir dist --format esm --target browser --minify --external '@bitruvius/*' && tsc --emitDeclarationOnly"},"_npmUser":{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},"_integrity":"sha512-MP098th2TfFGeP/1kwidXNtb71VrE0p+GQi7arZiyxalhVnVk6H4FTsEjkRxYj3A6E9LlfhfgDi57FXqeKO7Fw==","_npmVersion":"10.8.3","description":"Composed off-main-thread decoder for OGC 3D-Tiles textured meshes: wires @bitruvius/gltf + draco + meshopt + ktx2 into a worker-pooled MeshTileDecoder","directories":{},"sideEffects":["./src/index.ts"],"_nodeVersion":"24.3.0","dependencies":{"@bitruvius/gltf":"^0.3.2","@bitruvius/ktx2":"^0.3.2","@bitruvius/draco":"^0.3.2","@bitruvius/meshopt":"^0.3.2","@bitruvius/geo-core":"^0.3.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/tiles3d-mesh_0.3.2_1785952494711_0.4455179515377714","host":"s3://npm-registry-packages-npm-production"}},"0.3.3":{"_id":"@bitruvius/tiles3d-mesh@0.3.3","bugs":{"url":"https://github.com/bitruvius/support"},"dist":{"shasum":"e1c1e20746ae37d19a87316f5d22270120e5e109","tarball":"https://registry.npmjs.org/@bitruvius/tiles3d-mesh/-/tiles3d-mesh-0.3.3.tgz","fileCount":12,"integrity":"sha512-kEpxMxl0tkcagt7ppTsFC/677g+Dvlqh9FH13oFV+uLslyLhaZml3bZWEH5uUMWWvu+ahv8BmyMgDSwJDfPA0A==","signatures":[{"sig":"MEYCIQDNpE1KQb1mMyoNlgitvdC3xQ4Ut8ra61T60LWWftU1KAIhAMWJMD2TWZiA89REmISmzDAlzHGSPQq6/Z2d5BpNTxN4","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIHB82WMRm2ENjFgApWtosyxbcm7g5E91kQyFZtkfSIuXAiApUzYp2eBHOxsoWxCHVD+74ROil3yNhftGNTZttkY1iQ=="}],"unpackedSize":32800},"main":"./dist/index.js","name":"@bitruvius/tiles3d-mesh","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","shasum":"e1c1e20746ae37d19a87316f5d22270120e5e109","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"license":"SEE LICENSE IN LICENSE","scripts":{"test":"bun test","build":"bun build ./src/index.ts ./src/mesh-decode-worker.ts --outdir dist --format esm --target browser --minify --external '@bitruvius/*' && tsc --emitDeclarationOnly"},"version":"0.3.3","_npmUser":{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},"homepage":"https://dev.bitruvius.com/sdks/js/","keywords":["bitruvius","geospatial","3d-tiles","mesh","draco","ktx2","worker","decoder"],"_integrity":"sha512-kEpxMxl0tkcagt7ppTsFC/677g+Dvlqh9FH13oFV+uLslyLhaZml3bZWEH5uUMWWvu+ahv8BmyMgDSwJDfPA0A==","_npmVersion":"10.8.3","description":"Composed off-main-thread decoder for OGC 3D-Tiles textured meshes: wires @bitruvius/gltf + draco + meshopt + ktx2 into a worker-pooled MeshTileDecoder","directories":{},"maintainers":[{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},{"name":"danrhedges","email":"danrhedges@gmail.com"}],"sideEffects":["./src/index.ts"],"_nodeVersion":"24.3.0","dependencies":{"@bitruvius/gltf":"^0.3.3","@bitruvius/ktx2":"^0.3.3","@bitruvius/draco":"^0.3.3","@bitruvius/meshopt":"^0.3.3","@bitruvius/geo-core":"^0.3.3"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tiles3d-mesh_0.3.3_1790299987822_0.8572231375368078"}}},"time":{"created":"2026-08-03T01:56:22.074Z","modified":"2026-09-25T01:33:08.053Z","0.1.0":"2026-07-24T21:36:26.691Z","0.3.0":"2026-08-03T01:56:22.414Z","0.3.1":"2026-08-03T02:52:08.016Z","0.3.2":"2026-08-05T17:54:54.833Z","0.3.3":"2026-09-25T01:33:07.910Z"},"bugs":{"url":"https://github.com/bitruvius/support"},"license":"SEE LICENSE IN LICENSE","homepage":"https://dev.bitruvius.com/sdks/js/","keywords":["bitruvius","geospatial","3d-tiles","mesh","draco","ktx2","worker","decoder"],"description":"Composed off-main-thread decoder for OGC 3D-Tiles textured meshes: wires @bitruvius/gltf + draco + meshopt + ktx2 into a worker-pooled MeshTileDecoder","maintainers":[{"name":"geoffhtaylor3d","email":"geoffhtaylor3d@gmail.com"},{"name":"danrhedges","email":"danrhedges@gmail.com"}],"readme":"<p align=\"center\">\n  <a href=\"https://bitruvius.com\"><img src=\"https://cdn.bitruvius.com/brand/bitruvius-logo.png\" width=\"360\" alt=\"Bitruvius\"></a>\n</p>\n\n# @bitruvius/tiles3d-mesh\n\n**Textured 3D Tiles meshes, decoded off the main thread and handed back GPU-ready.**\n\n> **Internal building block.** This package exists so that\n> [`@bitruvius/sdk-maplibre`](https://www.npmjs.com/package/@bitruvius/sdk-maplibre) and the\n> Bitruvius codecs can resolve their dependencies on npm. It has no standalone product story.\n> Unless you are deliberately building against it, install the SDK instead.\n\n## What it does\n\nGive it tile bytes (`b3dm`, `i3dm`, `cmpt` or `glb`) and a georeference context. It unwraps the\ncontainer, decodes Draco and meshopt geometry, transcodes KTX2 textures, decodes JPEG and PNG\ntextures, and returns one `PackedMeshTile` rebased into the shared-scene ENU frame in metres.\n\nAll of that runs in a Web Worker pool by default, so a streaming city model does not spend the\nrender thread's frame budget. Tile bytes transfer into the worker and every buffer of the packed\ntile transfers back out, both zero-copy.\n\n## Why it is its own package\n\nThe composition needs an owner, and neither of its neighbours can be it.\n\n**The parser must stay codec-free.** [`@bitruvius/gltf`](https://www.npmjs.com/package/@bitruvius/gltf) consumes compression through\nseams whose interfaces live in `@bitruvius/geo-core`, so an uncompressed tileset decodes without\ndownloading a single WebAssembly binary. Something still has to wire `DracoDecoder`,\n`MeshoptGltfDecoder`, `Ktx2BasisTranscoder` and an image decoder into a working decoder. Do it in\nthe parser and every consumer inherits megabytes of wasm it may never use.\n\n**The renderer must not be it either.** Put the wiring in the MapLibre layer and the only way to\ndecode a 3D Tiles mesh is to adopt MapLibre. The composition lives here instead, so a custom\nrenderer gets the same decoder the SDK uses.\n\n**Mesh and point content must not drag each other's codecs.** The sibling package\n[`@bitruvius/tiles3d-points`](https://www.npmjs.com/package/@bitruvius/tiles3d-points) depends only on core, the parser and Draco. A LiDAR\napplication therefore never pulls the KTX2 transcoder or the meshopt wasm, and a mesh application\nnever pays for a point path it does not render. That is only true while the two compositions are\nseparate packages.\n\n**The worker chunk has to be built by whoever owns the wiring.** `src/mesh-decode-worker.ts` is\npublished as its own chunk, and a worker cannot reliably resolve its sibling packages' wasm against\nits own base URL. So the Draco and KTX2 binaries are resolved on the main thread, forwarded with\nthe first request to each worker, and cached there. That handshake touches the codecs, the parser\nand the pool at once, which is exactly the set of dependencies this package has and no other\npackage should take on.\n\nTwo failure modes are handled here for the same reason. A pool that cannot spawn at all (a CSP\nwithout `worker-src blob:`, a missing chunk) is reported once, through `onDegraded` and one console\nwarning, and every later decode runs on the calling thread: slower, but the layer renders instead\nof staying empty. And a cross-origin CDN page cannot call `new Worker(cdnUrl)`, so the CDN build\nfetches the published worker chunk over CORS and spawns it from a same-origin Blob URL.\n\n## What is in it\n\n| Export | What it does |\n| --- | --- |\n| **`createMeshDecoder(opts)`** | The factory. Worker pool on by default, sized `hardwareConcurrency - 1` clamped to 1..8; `workers: false` selects the main-thread path, as does any environment with no `Worker`; `poolSize`, `spawn` and `onDegraded` tune the rest. Returns a `MeshTileDecoder`. |\n| **`WorkerGltfMeshDecoder`** | The pool itself, for when you need to supply explicit Draco or KTX2 wasm bytes or URLs rather than let them auto-resolve. |\n| **`browserImageDecoder`** | The JPEG/PNG `decodeImage` seam. `createImageBitmap` with no premultiply and no colour conversion, returning the `ImageBitmap` for a direct `texImage2D` upload instead of an OffscreenCanvas RGBA readback per tile. |\n| **`MeshDecodeRequest`** | The worker wire-protocol type. Useful when you host the worker yourself. |\n\n```ts\nimport { createMeshDecoder } from '@bitruvius/tiles3d-mesh';\n\n// Off-main-thread worker pool (default).\nconst decoder = createMeshDecoder();\n\n// Cross-origin CDN: no module workers, so decode on the main thread.\nconst cdnDecoder = createMeshDecoder({ workers: false });\n```\n\nPass the result to `Tiles3DMeshEngine` from [`@bitruvius/tiles3d`](https://www.npmjs.com/package/@bitruvius/tiles3d), or as the `decoder`\noption of `Tiles3DMeshLayer` from\n[`@bitruvius/sdk-maplibre`](https://www.npmjs.com/package/@bitruvius/sdk-maplibre). Size the\nengine's decode concurrency to the decoder's `concurrency`, and call `dispose()` to tear the pool\ndown. `MeshTileDecoder` and `PackedMeshTile` are contracts from\n[`@bitruvius/geo-core`](https://www.npmjs.com/package/@bitruvius/geo-core), not types this package invents, which is what lets a decoder\nbuilt here drop into a renderer that never heard of it.\n\n## Who should depend on it\n\nAlmost nobody, directly. To stream 3D Tiles meshes into a map, install\n[`@bitruvius/sdk-maplibre`](https://www.npmjs.com/package/@bitruvius/sdk-maplibre), whose mesh layer\nconstructs this decoder for you.\n\nTake it directly when you are building your own renderer or pipeline on the Bitruvius contracts,\nwhen you want to tune worker concurrency against your own tile budget, or when you need to serve\nthe codec wasm from a location you control.\n\nIts runtime dependencies are `@bitruvius/geo-core`, `@bitruvius/gltf`, `@bitruvius/draco`,\n`@bitruvius/meshopt` and `@bitruvius/ktx2`.\n\n## Trademarks\n\nCesium and 3D Tiles are trademarks of Cesium GS, Inc. glTF and KTX are trademarks of The Khronos\nGroup Inc. OGC is a trademark of the Open Geospatial Consortium. Google and Draco are trademarks of\nGoogle LLC. MapLibre is a trademark of the MapLibre organization. All other marks are the property\nof their respective owners.\n\nThese names are used solely to describe the data formats this software interoperates with.\nBitruvius is not affiliated with, sponsored by, or endorsed by any of them, and no such\nrelationship is implied. Implementing a published specification is not a claim of certification: Bitruvius has not undergone OGC compliance testing for any standard.\n\n## License\n\nProprietary. The full terms ship as `LICENSE` inside this package, and are readable\nbefore installing at [cdn.bitruvius.com/legal/sdk-license-v1.txt](https://cdn.bitruvius.com/legal/sdk-license-v1.txt).\n\n© Bitruvius, Inc.\n","readmeFilename":"README.md"}