{"id":15314031,"url":"https://github.com/vanruesc/linear-octree","last_synced_at":"2025-04-15T01:51:02.943Z","repository":{"id":70175375,"uuid":"217146679","full_name":"vanruesc/linear-octree","owner":"vanruesc","description":"A sparse, linear octree data structure.","archived":false,"fork":false,"pushed_at":"2024-04-14T23:27:03.000Z","size":931,"stargazers_count":24,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-05-02T05:14:59.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vanruesc.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-23T20:23:05.000Z","updated_at":"2024-05-21T12:31:07.543Z","dependencies_parsed_at":"2023-02-24T10:30:22.225Z","dependency_job_id":"f3bd01e1-1957-4ae9-8b54-276cd1b7cacf","html_url":"https://github.com/vanruesc/linear-octree","commit_stats":{"total_commits":97,"total_committers":1,"mean_commits":97.0,"dds":0.0,"last_synced_commit":"04fb768f92db89a848bf14a250dfe658b5de3b33"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Flinear-octree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Flinear-octree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Flinear-octree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Flinear-octree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanruesc","download_url":"https://codeload.github.com/vanruesc/linear-octree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991539,"owners_count":21194894,"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-01T08:44:15.657Z","updated_at":"2025-04-15T01:51:02.928Z","avatar_url":"https://github.com/vanruesc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Linear Octree\n\n[![CI](https://github.com/vanruesc/linear-octree/actions/workflows/ci.yml/badge.svg)](https://github.com/vanruesc/linear-octree/actions/workflows/ci.yml)\n[![Version](https://badgen.net/npm/v/linear-octree?color=green)](https://www.npmjs.com/package/linear-octree)\n\nA sparse, linear octree data structure. For a pointer-based implementation see [sparse-octree](https://github.com/vanruesc/sparse-octree).\n\n*[Demo](https://vanruesc.github.io/linear-octree/demo)\u0026ensp;\u0026middot;\u0026ensp;[Documentation](https://vanruesc.github.io/linear-octree/docs)*\n\n\n## Installation\n\nThis library requires the peer dependency [three](https://github.com/mrdoob/three.js/).\n\n```sh\nnpm install three linear-octree\n``` \n\n\n## Usage\n\n```ts\nimport { KeyDesign, Octree } from \"linear-octree\";\nimport { Box3, Vector3 } from \"three\";\n\n// Define the bit distribution for the X-, Y- and Z-axis.\nconst keyDesign = new KeyDesign(4, 4, 4); // Tree depth = 4, 2^12 leaf octants\n\n// Define the octree world bounds.\nconst bounds = new Box3();\nbounds.min.set(-1, -1, -1);\nbounds.max.set(1, 1, 1);\n// Alternatively, define the bounds based on a cell size.\nconst cellSize = new Vector3(1, 1, 1);\nconst bounds = keyDesign.calculateBounds(cellSize, new Box3());\n\n// Create the octree.\nconst octree = new Octree\u003cstring\u003e(bounds, keyDesign);\n\n// Octree operations expect Uint key coordinates.\nconst keyCoordinates = new Vector3();\nconst worldPosition = new Vector3(0.5, 0.5, 0.5);\noctree.calculateKeyCoordinates(worldPosition, keyCoordinates);\n\n// Set and retrieve data.\nconst level = 0; // Octants of every level can store data.\noctree.set(keyCoordinates, level, \"my data\");\noctree.get(keyCoordinates, level); // =\u003e \"my data\"\noctree.delete(keyCoordinates, level);\noctree.get(keyCoordinates, level); // =\u003e undefined\n```\n\n## Key Design\n\n```ts\n// The largest uniform octree can contain 2^51 octants.\nconst keyDesign = new KeyDesign(17, 17, 17);\n// Octrees can be non-uniform with uneven bit distributions.\nconst keyDesign = new KeyDesign(21, 11, 21);\n// Bits can be set to zero to emulate a quad tree.\nconst keyDesign = new KeyDesign(26, 0, 26);\n```\n\n\n## Features\n\n- Linear structure\n  - Packs positional data into numeric keys\n  - Constant time access to octants, parents and neighbors at any depth level\n  - Low memory usage (no explicit positional data stored in octants)\n- Adheres to a [common octant layout](https://vanruesc.github.io/sparse-octree/docs/index.html#layout)\n- Supports raycasting\n- Supports culling\n- Can be extended to manage any data\n- Fully customizable 3-dimensional subdivisions\n\n\n## Contributing\n\nMaintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Flinear-octree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanruesc%2Flinear-octree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Flinear-octree/lists"}