{"_id":"@antoninrousset/three-edge-projection","name":"@antoninrousset/three-edge-projection","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.3":{"name":"@antoninrousset/three-edge-projection","version":"0.0.3","description":"[![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-edge-projection/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-edge-projection/actions) [![github](https://flat.badgen.net/badge/ic","main":"src/index.js","scripts":{"start":"parcel serve ./example/*.html --dist-dir ./example/dev-bundle/ --no-hmr","build-examples":"cd example && parcel build ./*.html --dist-dir ./bundle/ --public-url . --no-cache --no-content-hash","lint":"eslint \"./src/**/*.js\" \"./example/*.js\"","test":"cd test && jest"},"keywords":["graphics","tree","bounds","threejs","three-js","bounds-hierarchy","performance","geometry","mesh","acceleration","projection","edges"],"author":{"name":"Garrett Johnson","email":"garrett.kjohnson@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/gkjohnson/three-edge-projection.git"},"bugs":{"url":"https://github.com/gkjohnson/three-edge-projection/issues"},"homepage":"https://github.com/gkjohnson/three-edge-projection#readme","peerDependencies":{"three":"^0.155.0","three-mesh-bvh":"^0.6.0","clipper2-js":"^0.9.0"},"devDependencies":{"@babel/core":"^7.15.5","@babel/preset-env":"^7.15.4","@types/jest":"^27.0.2","@typescript-eslint/eslint-plugin":"^4.33.0","@typescript-eslint/parser":"^4.33.0","eslint":"^7.32.0","eslint-config-mdcs":"^5.0.0","eslint-plugin-jest":"^23.20.0","jest":"^27.2.4","parcel":"^2.9.3","three":"^0.155.0","three-mesh-bvh":"^0.6.6"},"_id":"@antoninrousset/three-edge-projection@0.0.3","gitHead":"d31ca8702566408fc0540f7ce08531e2c2881572","_nodeVersion":"24.3.0","_npmVersion":"11.4.2","dist":{"integrity":"sha512-FMk3v7uyHDFSIynz4oRyem+ICyCXhYs4Bw2O15ZTeYyLZnrrhMuTCaIfWbxMklXUTRvLIzFsHUHNNxPahmphjw==","shasum":"dacc9e68b34fa6a0d911384ab6e9a6f1da7f985c","tarball":"https://registry.npmjs.org/@antoninrousset/three-edge-projection/-/three-edge-projection-0.0.3.tgz","fileCount":23,"unpackedSize":48810,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGx773uemz41Y2TrD11R1D/rojNXAw9U/8vksZbeBuIsAiABmlWxZ/xe10zGfmJy5U8uhTyuwZ23u9iHKi4fVTkE8g=="}]},"_npmUser":{"name":"antoninrousset","email":"antonin@rousset.com"},"directories":{},"maintainers":[{"name":"antoninrousset","email":"antonin@rousset.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/three-edge-projection_0.0.3_1761650801859_0.0322135109080921"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-28T11:26:41.711Z","0.0.3":"2025-10-28T11:26:42.049Z","modified":"2025-10-28T11:26:42.604Z"},"maintainers":[{"name":"antoninrousset","email":"antonin@rousset.com"}],"description":"[![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-edge-projection/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-edge-projection/actions) [![github](https://flat.badgen.net/badge/ic","homepage":"https://github.com/gkjohnson/three-edge-projection#readme","keywords":["graphics","tree","bounds","threejs","three-js","bounds-hierarchy","performance","geometry","mesh","acceleration","projection","edges"],"repository":{"type":"git","url":"git+https://github.com/gkjohnson/three-edge-projection.git"},"author":{"name":"Garrett Johnson","email":"garrett.kjohnson@gmail.com"},"bugs":{"url":"https://github.com/gkjohnson/three-edge-projection/issues"},"license":"MIT","readme":"# three-edge-projection\n\n\n[![build](https://img.shields.io/github/actions/workflow/status/gkjohnson/three-edge-projection/node.js.yml?style=flat-square&label=build&branch=main)](https://github.com/gkjohnson/three-edge-projection/actions)\n[![github](https://flat.badgen.net/badge/icon/github?icon=github&label)](https://github.com/gkjohnson/three-edge-projection/)\n[![twitter](https://flat.badgen.net/badge/twitter/@garrettkjohnson/?icon&label)](https://twitter.com/garrettkjohnson)\n[![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square&color=1da1f2)](https://github.com/sponsors/gkjohnson/)\n\n![](./docs/banner.png)\n\nEdge projection based on [three-mesh-bvh](https://github.com/gkjohnson/three-mesh-bvh/) to extract visible projected lines along the y-axis into flattened line segments for scalable 2d rendering. Additonally includes a silhouette mesh generator based on [clipper2-js](https://www.npmjs.com/package/clipper2-js) to merge flattened triangles.\n\n# Examples\n\n[Geometry edge projection](https://gkjohnson.github.io/three-edge-projection/example/bundle/edgeProjection.html)\n\n[Silhouette projection](https://gkjohnson.github.io/three-edge-projection/example/bundle/silhouetteProjection.html)\n\n[Floor plan projection](https://gkjohnson.github.io/three-edge-projection/example/bundle/floorProjection.html)\n\n[Planar intersection](https://gkjohnson.github.io/three-edge-projection/example/bundle/planarIntersection.html)\n\n# Use\n\n**Generator**\n\nMore granular API with control over when edge trimming work happens.\n\n```js\nconst generator = new ProjectionGenerator();\ngenerator.generate( geometry );\n\nlet result = task.next();\nwhile ( ! result.done ) {\n\n\tresult = task.next();\n\n}\n\nconst lines = new LineSegments( result.value, material );\nscene.add( lines );\n```\n\n**Promise**\n\nSimpler API with less control over when the work happens.\n\n```js\nconst generator = new ProjectionGenerator();\nconst geometry = await generator.generateAsync( geometry );\nconst mesh = new Mesh( result.value, material );\nscene.add( mesh );\n```\n\n\n# API\n\n## ProjectionGenerator\n\n### .sortEdges\n\n```js\nsortEdges = true : Boolean\n```\n\nWhether to sort edges along the Y axis before iterating over the edges.\n\n### .iterationTime\n\n```js\niterationTime = 30 : Number\n```\n\nHow long to spend trimming edges before yielding.\n\n### .angleThreshold\n\n```js\nangleThreshold = 50 : Number\n```\n\nThe threshold angle in degrees at which edges are generated.\n\n### .includeIntersectionEdges\n\n```js\nincludeIntersectionEdges = true : Boolean\n```\n\nWhether to generate edges representing the intersections between triangles.\n\n### .generate\n\n```js\n*generate(\n\tgeometry : MeshBVH | BufferGeometry,\n\toptions : {\n\t\tonProgress: ( percent : Number ) => void,\n\t}\n) : BufferGeometry\n```\n\nGenerate the edge geometry using a generator function.\n\n### .generateAsync\n\n```js\ngenerateAsync(\n\tgeometry : MeshBVH | BufferGeometry,\n\toptions : {\n\t\tonProgress: ( percent : Number ) => void,\n\t\tsignal: AbortSignal,\n\t}\n) : Promise<BufferGeometry>\n```\n\nGenerate the geometry with a promise-style API.\n\n## SilhouetteGenerator\n\nUsed for generating a projected silhouette of a geometry using the [clipper2-js](https://www.npmjs.com/package/clipper2-js) project. Performing these operations can be extremely slow with more complex geometry and not always yield a stable result.\n\n### .iterationTime\n\n```js\niterationTime = 10 : Number\n```\n\nHow long to spend trimming edges before yielding.\n\n### .doubleSided\n\n```js\ndoubleSided = false : Boolean\n```\n\nIf `false` then only the triangles facing upwards are included in the silhouette.\n\n### .sortTriangles\n\n```js\nsortTriangles = false : Boolean\n```\n\nWhether to sort triangles and project them large-to-small. In some cases this can cause the performance to drop since the union operation is best performed with smooth, simple edge shapes.\n\n### .output\n\n```js\noutput = OUTPUT_MESH | OUTPUT_LINE_SEGMENTS | OUTPUT_BOTH\n```\n\nWhether to output mesh geometry, line segments geometry, or both in an array ( `[ mesh, line segments ]` );\n\n### .generate\n\n```js\n*generate(\n\tgeometry : BufferGeometry,\n\toptions : {\n\t\tonProgress: ( percent : Number ) => void,\n\t}\n) : BufferGeometry\n```\n\nGenerate the geometry using a generator function.\n\n### .generateAsync\n\n```js\ngenerateAsync(\n\tgeometry : BufferGeometry,\n\toptions : {\n\t\tonProgress: ( percent : Number ) => void,\n\t\tsignal: AbortSignal,\n\t}\n) : Promise<BufferGeometry>\n```\n\nGenerate the silhouette geometry with a promise-style API.\n\n## PlanarIntersectionGenerator\n\n### .plane\n\n```js\nplane : Plane\n```\n\nPlane that defaults to y up plane at the origin.\n\n### .generate\n\n```js\ngenerate( geometry : MeshBVH | BufferGeometry ) : BufferGeometry\n```\n\nGenerates a geometry of the resulting line segments from the planar intersection.\n","readmeFilename":"README.md","_rev":"1-5b8e67cb1090b0c6b698e3c57bb7bea2"}