{"id":15387028,"url":"https://github.com/gkjohnson/three-edge-projection","last_synced_at":"2025-11-13T22:52:29.482Z","repository":{"id":195507630,"uuid":"679968253","full_name":"gkjohnson/three-edge-projection","owner":"gkjohnson","description":"Visible geometry edge projection and flattening based on three-mesh-bvh.","archived":false,"fork":false,"pushed_at":"2024-04-19T20:38:17.000Z","size":1149,"stargazers_count":154,"open_issues_count":10,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-10T00:51:55.347Z","etag":null,"topics":["dxf","edges","geometry","graphics","outline","silhouette","svg","three-mesh-bvh","threejs"],"latest_commit_sha":null,"homepage":"https://gkjohnson.github.io/three-edge-projection/example/bundle/edgeProjection.html","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/gkjohnson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-08-18T03:22:05.000Z","updated_at":"2024-12-04T17:46:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3e1c55cc-c622-44ed-93cf-91efbc865698","html_url":"https://github.com/gkjohnson/three-edge-projection","commit_stats":{"total_commits":106,"total_committers":3,"mean_commits":"35.333333333333336","dds":"0.018867924528301883","last_synced_commit":"e96486f8a1b21119798eeeee78a9e6cb7c12ef8d"},"previous_names":["gkjohnson/three-edge-projection"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkjohnson%2Fthree-edge-projection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkjohnson%2Fthree-edge-projection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkjohnson%2Fthree-edge-projection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gkjohnson%2Fthree-edge-projection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gkjohnson","download_url":"https://codeload.github.com/gkjohnson/three-edge-projection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230408170,"owners_count":18220974,"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":["dxf","edges","geometry","graphics","outline","silhouette","svg","three-mesh-bvh","threejs"],"created_at":"2024-10-01T14:51:25.775Z","updated_at":"2025-11-13T22:52:24.438Z","avatar_url":"https://github.com/gkjohnson.png","language":"JavaScript","funding_links":["https://github.com/sponsors/gkjohnson/"],"categories":[],"sub_categories":[],"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\u0026label=build\u0026branch=main)](https://github.com/gkjohnson/three-edge-projection/actions)\n[![github](https://flat.badgen.net/badge/icon/github?icon=github\u0026label)](https://github.com/gkjohnson/three-edge-projection/)\n[![twitter](https://flat.badgen.net/badge/twitter/@garrettkjohnson/?icon\u0026label)](https://twitter.com/garrettkjohnson)\n[![sponsors](https://img.shields.io/github/sponsors/gkjohnson?style=flat-square\u0026color=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 ) =\u003e 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 ) =\u003e void,\n\t\tsignal: AbortSignal,\n\t}\n) : Promise\u003cBufferGeometry\u003e\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 ) =\u003e 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 ) =\u003e void,\n\t\tsignal: AbortSignal,\n\t}\n) : Promise\u003cBufferGeometry\u003e\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkjohnson%2Fthree-edge-projection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgkjohnson%2Fthree-edge-projection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgkjohnson%2Fthree-edge-projection/lists"}