src/index.js
38 |export { OctreeHelper } from "./OctreeHelper.js";
39 |
40 |
41 | ├── docs ├── lint.json ├── image │ ├── github.png │ ├── search.png │ ├── esdoc-logo-mini.png │ ├── esdoc-logo-mini-black.png │ ├── badge.svg │ └── manual-badge.svg ├── coverage.json ├── script │ ├── patch-for-local.js │ ├── manual.js │ ├── pretty-print.js │ ├── inherited-summary.js │ ├── inner-link.js │ ├── test-summary.js │ ├── search.js │ ├── prettify │ │ ├── Apache-License-2.0.txt │ │ └── prettify.js │ └── search_index.js ├── css │ ├── identifiers.css │ ├── source.css │ ├── test.css │ ├── github.css │ ├── search.css │ ├── prettify-tomorrow.css │ ├── manual.css │ └── style.css ├── badge.svg ├── file │ └── src │ │ ├── index.js.html │ │ └── OctreeHelper.js.html ├── identifiers.html ├── source.html ├── index.html ├── ast │ └── source │ │ └── index.js.json ├── class │ └── src │ │ └── OctreeHelper.js~OctreeHelper.html └── index.json ├── .travis.yml ├── src ├── index.js └── OctreeHelper.js ├── babel.config.js ├── .esdoc.json ├── .gitattributes ├── test └── OctreeHelper.js ├── LICENSE.md ├── .gitignore ├── package.json ├── rollup.config.js └── README.md /docs/lint.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "node" 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | export { OctreeHelper } from "./OctreeHelper.js"; 2 | -------------------------------------------------------------------------------- /docs/image/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vanruesc/octree-helper/HEAD/docs/image/github.png -------------------------------------------------------------------------------- /docs/image/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vanruesc/octree-helper/HEAD/docs/image/search.png -------------------------------------------------------------------------------- /docs/image/esdoc-logo-mini.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vanruesc/octree-helper/HEAD/docs/image/esdoc-logo-mini.png -------------------------------------------------------------------------------- /docs/image/esdoc-logo-mini-black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vanruesc/octree-helper/HEAD/docs/image/esdoc-logo-mini-black.png -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | 3 | api.cache.forever(); 4 | 5 | return { 6 | compact: false, 7 | comments: false, 8 | presets: [ 9 | ["@babel/preset-env"] 10 | ] 11 | }; 12 | 13 | }; 14 | -------------------------------------------------------------------------------- /docs/coverage.json: -------------------------------------------------------------------------------- 1 | { 2 | "coverage": "100%", 3 | "expectCount": 7, 4 | "actualCount": 7, 5 | "files": { 6 | "src/OctreeHelper.js": { 7 | "expectCount": 7, 8 | "actualCount": 7, 9 | "undocumentLines": [] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /docs/script/patch-for-local.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | if (location.protocol === 'file:') { 3 | var elms = document.querySelectorAll('a[href="./"]'); 4 | for (var i = 0; i < elms.length; i++) { 5 | elms[i].href = './index.html'; 6 | } 7 | } 8 | })(); 9 | -------------------------------------------------------------------------------- /.esdoc.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "source": "src", 4 | "destination": "docs", 5 | 6 | "plugins": [{ 7 | "name": "esdoc-standard-plugin", 8 | "option": { 9 | "accessor": { 10 | "access": ["public", "protected"], 11 | "autoPrivate": true 12 | } 13 | } 14 | }, { 15 | "name": "esdoc-importpath-plugin", 16 | "option": { 17 | "stripPackageName": false, 18 | "replaces": [{ 19 | "from": "^src/.*", 20 | "to": "" 21 | }] 22 | } 23 | }] 24 | 25 | } 26 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | 19 | # Linguist language statistics 20 | build/* linguist-generated 21 | -------------------------------------------------------------------------------- /docs/script/manual.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var matched = location.pathname.match(/\/(manual\/.*\.html)$/); 3 | if (!matched) return; 4 | 5 | var currentName = matched[1]; 6 | var cssClass = '.navigation .manual-toc li[data-link="' + currentName + '"]'; 7 | var styleText = cssClass + '{ display: block; }\n'; 8 | styleText += cssClass + '.indent-h1 a { color: #039BE5 }'; 9 | var style = document.createElement('style'); 10 | style.textContent = styleText; 11 | document.querySelector('head').appendChild(style); 12 | })(); 13 | -------------------------------------------------------------------------------- /docs/css/identifiers.css: -------------------------------------------------------------------------------- 1 | .identifiers-wrap { 2 | display: flex; 3 | align-items: flex-start; 4 | } 5 | 6 | .identifier-dir-tree { 7 | background: #fff; 8 | border: solid 1px #ddd; 9 | border-radius: 0.25em; 10 | top: 52px; 11 | position: -webkit-sticky; 12 | position: sticky; 13 | max-height: calc(100vh - 155px); 14 | overflow-y: scroll; 15 | min-width: 200px; 16 | margin-left: 1em; 17 | } 18 | 19 | .identifier-dir-tree-header { 20 | padding: 0.5em; 21 | background-color: #fafafa; 22 | border-bottom: solid 1px #ddd; 23 | } 24 | 25 | .identifier-dir-tree-content { 26 | padding: 0 0.5em 0; 27 | } 28 | 29 | .identifier-dir-tree-content > div { 30 | padding-top: 0.25em; 31 | padding-bottom: 0.25em; 32 | } 33 | 34 | .identifier-dir-tree-content a { 35 | color: inherit; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /docs/badge.svg: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /docs/image/badge.svg: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /docs/image/manual-badge.svg: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /docs/script/pretty-print.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | prettyPrint(); 3 | var lines = document.querySelectorAll('.prettyprint.linenums li[class^="L"]'); 4 | for (var i = 0; i < lines.length; i++) { 5 | lines[i].id = 'lineNumber' + (i + 1); 6 | } 7 | 8 | var matched = location.hash.match(/errorLines=([\d,]+)/); 9 | if (matched) { 10 | var lines = matched[1].split(','); 11 | for (var i = 0; i < lines.length; i++) { 12 | var id = '#lineNumber' + lines[i]; 13 | var el = document.querySelector(id); 14 | el.classList.add('error-line'); 15 | } 16 | return; 17 | } 18 | 19 | if (location.hash) { 20 | // ``[ ] . ' " @`` are not valid in DOM id. so must escape these. 21 | var id = location.hash.replace(/([\[\].'"@$])/g, '\\$1'); 22 | var line = document.querySelector(id); 23 | if (line) line.classList.add('active'); 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /test/OctreeHelper.js: -------------------------------------------------------------------------------- 1 | import test from "ava"; 2 | import { Vector3 } from "math-ds"; 3 | import { Octant, Octree } from "sparse-octree"; 4 | import { OctreeHelper } from "../build/octree-helper.js"; 5 | 6 | const octree = new Octree(new Octant( 7 | new Vector3(-1, -1, -1), 8 | new Vector3(1, 1, 1) 9 | )); 10 | 11 | octree.root.split(); 12 | 13 | test("can be instantiated", t => { 14 | 15 | const object = new OctreeHelper(); 16 | 17 | t.truthy(object); 18 | 19 | }); 20 | 21 | test("creates geometry for each tree level", t => { 22 | 23 | const helper = new OctreeHelper(octree); 24 | 25 | t.is(helper.children.length, 2, "should have a child for each level"); 26 | 27 | }); 28 | 29 | test("an be destroyed", t => { 30 | 31 | const helper = new OctreeHelper(octree); 32 | 33 | helper.dispose(); 34 | 35 | t.is(helper.children.length, 0, "should delete all children"); 36 | 37 | }); 38 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright © 2016 Raoul van Rüschen 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In 4 | no event will the authors be held liable for any damages arising from the use of 5 | this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, including 8 | commercial applications, and to alter it and redistribute it freely, subject to 9 | the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not claim 12 | that you wrote the original software. If you use this software in a product, 13 | an acknowledgment in the product documentation would be appreciated but is 14 | not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /docs/script/inherited-summary.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | function toggle(ev) { 3 | var button = ev.target; 4 | var parent = ev.target.parentElement; 5 | while(parent) { 6 | if (parent.tagName === 'TABLE' && parent.classList.contains('summary')) break; 7 | parent = parent.parentElement; 8 | } 9 | 10 | if (!parent) return; 11 | 12 | var tbody = parent.querySelector('tbody'); 13 | if (button.classList.contains('opened')) { 14 | button.classList.remove('opened'); 15 | button.classList.add('closed'); 16 | tbody.style.display = 'none'; 17 | } else { 18 | button.classList.remove('closed'); 19 | button.classList.add('opened'); 20 | tbody.style.display = 'block'; 21 | } 22 | } 23 | 24 | var buttons = document.querySelectorAll('.inherited-summary thead .toggle'); 25 | for (var i = 0; i < buttons.length; i++) { 26 | buttons[i].addEventListener('click', toggle); 27 | } 28 | })(); 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # Linux 25 | # ========================= 26 | 27 | *.swp 28 | 29 | # OSX 30 | # ========================= 31 | 32 | .DS_Store 33 | .AppleDouble 34 | .LSOverride 35 | 36 | # Thumbnails 37 | ._* 38 | 39 | # Files that might appear on external disk 40 | .Spotlight-V100 41 | .Trashes 42 | 43 | # Directories potentially created on remote AFP share 44 | .AppleDB 45 | .AppleDesktop 46 | Network Trash Folder 47 | Temporary Items 48 | .apdisk 49 | 50 | # Dependencies 51 | node_modules 52 | 53 | # Logs 54 | *.log 55 | 56 | # IDE settings 57 | .project 58 | .idea 59 | .vscore 60 | 61 | # Backup 62 | .backup 63 | 64 | # Temporary files 65 | *.tmp 66 | -------------------------------------------------------------------------------- /docs/script/inner-link.js: -------------------------------------------------------------------------------- 1 | // inner link(#foo) can not correctly scroll, because page has fixed header, 2 | // so, I manually scroll. 3 | (function(){ 4 | var matched = location.hash.match(/errorLines=([\d,]+)/); 5 | if (matched) return; 6 | 7 | function adjust() { 8 | window.scrollBy(0, -55); 9 | var el = document.querySelector('.inner-link-active'); 10 | if (el) el.classList.remove('inner-link-active'); 11 | 12 | // ``[ ] . ' " @`` are not valid in DOM id. so must escape these. 13 | var id = location.hash.replace(/([\[\].'"@$])/g, '\\$1'); 14 | var el = document.querySelector(id); 15 | if (el) el.classList.add('inner-link-active'); 16 | } 17 | 18 | window.addEventListener('hashchange', adjust); 19 | 20 | if (location.hash) { 21 | setTimeout(adjust, 0); 22 | } 23 | })(); 24 | 25 | (function(){ 26 | var els = document.querySelectorAll('[href^="#"]'); 27 | var href = location.href.replace(/#.*$/, ''); // remove existed hash 28 | for (var i = 0; i < els.length; i++) { 29 | var el = els[i]; 30 | el.href = href + el.getAttribute('href'); // because el.href is absolute path 31 | } 32 | })(); 33 | -------------------------------------------------------------------------------- /docs/css/source.css: -------------------------------------------------------------------------------- 1 | table.files-summary { 2 | width: 100%; 3 | margin: 10px 0; 4 | border-spacing: 0; 5 | border: 0; 6 | border-collapse: collapse; 7 | text-align: right; 8 | } 9 | 10 | table.files-summary tbody tr:hover { 11 | background: #eee; 12 | } 13 | 14 | table.files-summary td:first-child, 15 | table.files-summary td:nth-of-type(2) { 16 | text-align: left; 17 | } 18 | 19 | table.files-summary[data-use-coverage="false"] td.coverage { 20 | display: none; 21 | } 22 | 23 | table.files-summary thead { 24 | background: #fafafa; 25 | } 26 | 27 | table.files-summary td { 28 | border: solid 1px #ddd; 29 | padding: 4px 10px; 30 | vertical-align: top; 31 | } 32 | 33 | table.files-summary td.identifiers > span { 34 | display: block; 35 | margin-top: 4px; 36 | } 37 | table.files-summary td.identifiers > span:first-child { 38 | margin-top: 0; 39 | } 40 | 41 | table.files-summary .coverage-count { 42 | font-size: 12px; 43 | color: #aaa; 44 | display: inline-block; 45 | min-width: 40px; 46 | } 47 | 48 | .total-coverage-count { 49 | position: relative; 50 | bottom: 2px; 51 | font-size: 12px; 52 | color: #666; 53 | font-weight: 500; 54 | padding-left: 5px; 55 | } 56 | -------------------------------------------------------------------------------- /docs/css/test.css: -------------------------------------------------------------------------------- 1 | table.test-summary thead { 2 | background: #fafafa; 3 | } 4 | 5 | table.test-summary thead .test-description { 6 | width: 50%; 7 | } 8 | 9 | table.test-summary { 10 | width: 100%; 11 | margin: 10px 0; 12 | border-spacing: 0; 13 | border: 0; 14 | border-collapse: collapse; 15 | } 16 | 17 | table.test-summary thead .test-count { 18 | width: 3em; 19 | } 20 | 21 | table.test-summary tbody tr:hover { 22 | background-color: #eee; 23 | } 24 | 25 | table.test-summary td { 26 | border: solid 1px #ddd; 27 | padding: 4px 10px; 28 | vertical-align: top; 29 | } 30 | 31 | table.test-summary td p { 32 | margin: 0; 33 | } 34 | 35 | table.test-summary tr.test-interface .toggle { 36 | display: inline-block; 37 | float: left; 38 | margin-right: 4px; 39 | cursor: pointer; 40 | font-size: 0.8em; 41 | padding-top: 0.25em; 42 | } 43 | 44 | table.test-summary tr.test-interface .toggle.opened:before { 45 | content: '▼'; 46 | } 47 | 48 | table.test-summary tr.test-interface .toggle.closed:before { 49 | content: '▶'; 50 | } 51 | 52 | table.test-summary .test-target > span { 53 | display: block; 54 | margin-top: 4px; 55 | } 56 | table.test-summary .test-target > span:first-child { 57 | margin-top: 0; 58 | } 59 | -------------------------------------------------------------------------------- /docs/css/github.css: -------------------------------------------------------------------------------- 1 | /* github markdown */ 2 | .github-markdown { 3 | font-size: 16px; 4 | } 5 | 6 | .github-markdown h1, 7 | .github-markdown h2, 8 | .github-markdown h3, 9 | .github-markdown h4, 10 | .github-markdown h5 { 11 | margin-top: 1em; 12 | margin-bottom: 16px; 13 | font-weight: bold; 14 | padding: 0; 15 | } 16 | 17 | .github-markdown h1:nth-of-type(1) { 18 | margin-top: 0; 19 | } 20 | 21 | .github-markdown h1 { 22 | font-size: 2em; 23 | padding-bottom: 0.3em; 24 | } 25 | 26 | .github-markdown h2 { 27 | font-size: 1.75em; 28 | padding-bottom: 0.3em; 29 | } 30 | 31 | .github-markdown h3 { 32 | font-size: 1.5em; 33 | } 34 | 35 | .github-markdown h4 { 36 | font-size: 1.25em; 37 | } 38 | 39 | .github-markdown h5 { 40 | font-size: 1em; 41 | } 42 | 43 | .github-markdown ul, .github-markdown ol { 44 | padding-left: 2em; 45 | } 46 | 47 | .github-markdown pre > code { 48 | font-size: 0.85em; 49 | } 50 | 51 | .github-markdown table { 52 | margin-bottom: 1em; 53 | border-collapse: collapse; 54 | border-spacing: 0; 55 | } 56 | 57 | .github-markdown table tr { 58 | background-color: #fff; 59 | border-top: 1px solid #ccc; 60 | } 61 | 62 | .github-markdown table th, 63 | .github-markdown table td { 64 | padding: 6px 13px; 65 | border: 1px solid #ddd; 66 | } 67 | 68 | .github-markdown table tr:nth-child(2n) { 69 | background-color: #f8f8f8; 70 | } 71 | 72 | .github-markdown hr { 73 | border-right: 0; 74 | border-bottom: 1px solid #e5e5e5; 75 | border-left: 0; 76 | border-top: 0; 77 | } 78 | 79 | /** badge(.svg) does not have border */ 80 | .github-markdown img:not([src*=".svg"]) { 81 | max-width: 100%; 82 | box-shadow: 1px 1px 1px rgba(0,0,0,0.5); 83 | } 84 | -------------------------------------------------------------------------------- /docs/css/search.css: -------------------------------------------------------------------------------- 1 | /* search box */ 2 | .search-box { 3 | position: absolute; 4 | top: 10px; 5 | right: 50px; 6 | padding-right: 8px; 7 | padding-bottom: 10px; 8 | line-height: normal; 9 | font-size: 12px; 10 | } 11 | 12 | .search-box img { 13 | width: 20px; 14 | vertical-align: top; 15 | } 16 | 17 | .search-input { 18 | display: inline; 19 | visibility: hidden; 20 | width: 0; 21 | padding: 2px; 22 | height: 1.5em; 23 | outline: none; 24 | background: transparent; 25 | border: 1px #0af; 26 | border-style: none none solid none; 27 | vertical-align: bottom; 28 | } 29 | 30 | .search-input-edge { 31 | display: none; 32 | width: 1px; 33 | height: 5px; 34 | background-color: #0af; 35 | vertical-align: bottom; 36 | } 37 | 38 | .search-result { 39 | position: absolute; 40 | display: none; 41 | height: 600px; 42 | width: 100%; 43 | padding: 0; 44 | margin-top: 5px; 45 | margin-left: 24px; 46 | background: white; 47 | box-shadow: 1px 1px 4px rgb(0,0,0); 48 | white-space: nowrap; 49 | overflow-y: scroll; 50 | } 51 | 52 | .search-result-import-path { 53 | color: #aaa; 54 | font-size: 12px; 55 | } 56 | 57 | .search-result li { 58 | list-style: none; 59 | padding: 2px 4px; 60 | } 61 | 62 | .search-result li a { 63 | display: block; 64 | } 65 | 66 | .search-result li.selected { 67 | background: #ddd; 68 | } 69 | 70 | .search-result li.search-separator { 71 | background: rgb(37, 138, 175); 72 | color: white; 73 | } 74 | 75 | .search-box.active .search-input { 76 | visibility: visible; 77 | transition: width 0.2s ease-out; 78 | width: 300px; 79 | } 80 | 81 | .search-box.active .search-input-edge { 82 | display: inline-block; 83 | } 84 | 85 | -------------------------------------------------------------------------------- /docs/script/test-summary.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | function toggle(ev) { 3 | var button = ev.target; 4 | var parent = ev.target.parentElement; 5 | while(parent) { 6 | if (parent.tagName === 'TR' && parent.classList.contains('test-interface')) break; 7 | parent = parent.parentElement; 8 | } 9 | 10 | if (!parent) return; 11 | 12 | var direction; 13 | if (button.classList.contains('opened')) { 14 | button.classList.remove('opened'); 15 | button.classList.add('closed'); 16 | direction = 'closed'; 17 | } else { 18 | button.classList.remove('closed'); 19 | button.classList.add('opened'); 20 | direction = 'opened'; 21 | } 22 | 23 | var targetDepth = parseInt(parent.dataset.testDepth, 10) + 1; 24 | var nextElement = parent.nextElementSibling; 25 | while (nextElement) { 26 | var depth = parseInt(nextElement.dataset.testDepth, 10); 27 | if (depth >= targetDepth) { 28 | if (direction === 'opened') { 29 | if (depth === targetDepth) nextElement.style.display = ''; 30 | } else if (direction === 'closed') { 31 | nextElement.style.display = 'none'; 32 | var innerButton = nextElement.querySelector('.toggle'); 33 | if (innerButton && innerButton.classList.contains('opened')) { 34 | innerButton.classList.remove('opened'); 35 | innerButton.classList.add('closed'); 36 | } 37 | } 38 | } else { 39 | break; 40 | } 41 | nextElement = nextElement.nextElementSibling; 42 | } 43 | } 44 | 45 | var buttons = document.querySelectorAll('.test-summary tr.test-interface .toggle'); 46 | for (var i = 0; i < buttons.length; i++) { 47 | buttons[i].addEventListener('click', toggle); 48 | } 49 | 50 | var topDescribes = document.querySelectorAll('.test-summary tr[data-test-depth="0"]'); 51 | for (var i = 0; i < topDescribes.length; i++) { 52 | topDescribes[i].style.display = ''; 53 | } 54 | })(); 55 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "octree-helper", 3 | "version": "1.1.6", 4 | "description": "An octree visualization tool for three.js.", 5 | "homepage": "https://github.com/vanruesc/octree-helper", 6 | "main": "build/octree-helper.js", 7 | "module": "build/octree-helper.esm.js", 8 | "sideEffects": false, 9 | "license": "Zlib", 10 | "keywords": [ 11 | "octree", 12 | "helper", 13 | "three.js", 14 | "3d", 15 | "geometry", 16 | "mesh", 17 | "render", 18 | "visualize" 19 | ], 20 | "author": { 21 | "name": "Raoul van Rüschen", 22 | "email": "vanruesc@outlook.de" 23 | }, 24 | "repository": { 25 | "type": "git", 26 | "url": "https://github.com/vanruesc/octree-helper.git" 27 | }, 28 | "bugs": { 29 | "url": "https://github.com/vanruesc/octree-helper/issues" 30 | }, 31 | "files": [ 32 | "build" 33 | ], 34 | "scripts": { 35 | "ava": "ava", 36 | "build": "rollup -c", 37 | "build:production": "cross-env NODE_ENV=production npm run build", 38 | "watch": "rollup -c -w", 39 | "doc": "rimraf docs && esdoc", 40 | "pretest": "npm run build:production", 41 | "test": "ava", 42 | "prepack": "npm test && npm run doc" 43 | }, 44 | "ava": { 45 | "failFast": true, 46 | "files": [ 47 | "test/**/*.js" 48 | ], 49 | "require": [ 50 | "esm" 51 | ] 52 | }, 53 | "eslintConfig": { 54 | "extends": "delta" 55 | }, 56 | "dependencies": { 57 | "sparse-octree": "6.x.x" 58 | }, 59 | "peerDependencies": { 60 | "three": ">= 0.110.0 < 0.119.0" 61 | }, 62 | "devDependencies": { 63 | "@babel/core": "7.x.x", 64 | "@babel/preset-env": "7.x.x", 65 | "@rollup/plugin-babel": "5.x.x", 66 | "@rollup/plugin-node-resolve": "8.x.x", 67 | "ava": "3.x.x", 68 | "cross-env": "7.x.x", 69 | "esdoc": "1.x.x", 70 | "esdoc-importpath-plugin": "1.x.x", 71 | "esdoc-standard-plugin": "1.x.x", 72 | "eslint-config-delta": "1.x.x", 73 | "esm": "3.x.x", 74 | "iterator-result": "1.x.x", 75 | "math-ds": "1.x.x", 76 | "rimraf": "3.x.x", 77 | "rollup": "2.x.x", 78 | "rollup-plugin-eslint": "6.x.x", 79 | "rollup-plugin-terser": "6.x.x", 80 | "three": "0.118.x" 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from "@rollup/plugin-babel"; 2 | import resolve from "@rollup/plugin-node-resolve"; 3 | import { eslint } from "rollup-plugin-eslint"; 4 | import { terser } from "rollup-plugin-terser"; 5 | 6 | const pkg = require("./package.json"); 7 | const date = (new Date()).toDateString(); 8 | 9 | // Meta settings. 10 | 11 | const banner = `/** 12 | * ${pkg.name} v${pkg.version} build ${date} 13 | * ${pkg.homepage} 14 | * Copyright ${date.slice(-4)} ${pkg.author.name} 15 | * @license ${pkg.license} 16 | */`; 17 | 18 | const production = (process.env.NODE_ENV === "production"); 19 | const external = Object.keys(pkg.peerDependencies); 20 | const globals = Object.assign({}, ...external.map((value) => ({ 21 | [value]: value.replace(/-/g, "").toUpperCase() 22 | }))); 23 | 24 | // Plugin settings. 25 | 26 | const settings = { 27 | 28 | babel: { 29 | babelHelpers: "bundled" 30 | } 31 | 32 | } 33 | 34 | // Bundle configurations. 35 | 36 | const lib = { 37 | 38 | module: { 39 | input: "src/index.js", 40 | external, 41 | plugins: [resolve(), eslint()], 42 | output: [ 43 | { 44 | file: pkg.module, 45 | format: "esm", 46 | globals, 47 | banner 48 | }, { 49 | file: pkg.main, 50 | format: "esm", 51 | globals 52 | }, { 53 | file: pkg.main.replace(".js", ".min.js"), 54 | format: "esm", 55 | globals 56 | } 57 | ] 58 | }, 59 | 60 | main: { 61 | input: production ? pkg.main : "src/index.js", 62 | external, 63 | plugins: production ? [babel(settings.babel)] : [resolve(), eslint()], 64 | output: { 65 | file: pkg.main, 66 | format: "umd", 67 | name: pkg.name.replace(/-/g, "").toUpperCase(), 68 | globals, 69 | banner 70 | } 71 | }, 72 | 73 | min: { 74 | input: pkg.main.replace(".js", ".min.js"), 75 | external, 76 | plugins: [terser(), babel(settings.babel)], 77 | output: { 78 | file: pkg.main.replace(".js", ".min.js"), 79 | format: "umd", 80 | name: pkg.name.replace(/-/g, "").toUpperCase(), 81 | globals, 82 | banner 83 | } 84 | } 85 | 86 | }; 87 | 88 | export default production ? [lib.module, lib.main, lib.min] : [lib.main]; 89 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Octree Helper 2 | 3 | [](https://travis-ci.org/vanruesc/octree-helper) 4 | [](https://www.npmjs.com/package/octree-helper) 5 | [](https://david-dm.org/vanruesc/octree-helper?type=peer) 6 | 7 | :warning: __Deprecation Notice: The octree helper is now included in [sparse-octree](https://github.com/vanruesc/sparse-octree).__ :warning: 8 | 9 | An octree visualization tool for [three.js](https://threejs.org/). 10 | 11 | *[Demo](https://vanruesc.github.io/sparse-octree/public/demo) · [Documentation](https://vanruesc.github.io/octree-helper/docs)* 12 | 13 | 14 | ## Installation 15 | 16 | This library requires the peer dependency [three](https://github.com/mrdoob/three.js/). 17 | 18 | ```sh 19 | npm install three octree-helper 20 | ``` 21 | 22 | 23 | ## Requirements 24 | 25 | This helper can visualize any octree that conforms to the following protocols: 26 | 27 | - [Tree](https://vanruesc.github.io/sparse-octree/public/docs/class/src/core/Tree.js~Tree.html) 28 | - [Node](https://vanruesc.github.io/sparse-octree/public/docs/class/src/core/Node.js~Node.html) 29 | 30 | 31 | ## Usage 32 | 33 | The following example uses the [sparse-octree](https://github.com/vanruesc/sparse-octree) module. 34 | 35 | ```javascript 36 | import { Scene } from "three"; 37 | import { Octree } from "sparse-octree"; 38 | import { OctreeHelper } from "octree-helper"; 39 | 40 | const scene = new Scene(); 41 | const octree = new Octree(); 42 | const octreeHelper = new OctreeHelper(octree); 43 | 44 | // Render the helper. 45 | scene.add(octreeHelper); 46 | 47 | // Set a different octree. 48 | octreeHelper.octree = otherOctree; 49 | 50 | // Destroy the helper geometry and rebuild. 51 | octreeHelper.update(); 52 | 53 | // Destroy the helper geometry. 54 | octreeHelper.dispose(); 55 | ``` 56 | 57 | 58 | ## Contributing 59 | 60 | Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code. 61 | -------------------------------------------------------------------------------- /docs/file/src/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
23 |
24 |
25 | 
export { OctreeHelper } from "./OctreeHelper.js";
39 |
40 |
41 |
23 |
24 |
25 | 
| summary | ||
| 50 | public 51 | 52 | 53 | 54 | 55 | | 56 |
57 |
58 |
65 | 59 | C 60 | 61 | 62 | OctreeHelper 63 | 64 |
66 |
67 |
68 |
71 | An octree helper. 69 | |
72 | 73 | 74 | 75 | | 76 |
23 |
24 |
25 | 
| File | 43 |Identifier | 44 |Document | 45 | 46 | 47 | 48 |
| src/OctreeHelper.js | 54 |OctreeHelper | 55 |100 %7/7 | 56 | 57 | 58 | 59 |
| src/index.js | 62 |- | 63 |- | 64 | 65 | 66 | 67 |
23 |
24 |
25 | 
An octree visualization tool for three.js.
41 | 42 |This library requires the peer dependency three.
43 |npm install three octree-helper
44 |
45 | This helper can visualize any octree that conforms to the following protocols:
46 | 50 |The following example uses the sparse-octree module.
51 |import { Scene } from "three";
52 | import { Octree } from "sparse-octree";
53 | import { OctreeHelper } from "octree-helper";
54 |
55 | const scene = new Scene();
56 | const octree = new Octree();
57 | const octreeHelper = new OctreeHelper(octree);
58 |
59 | // Render the helper.
60 | scene.add(octreeHelper);
61 |
62 | // Set a different octree.
63 | octreeHelper.octree = otherOctree;
64 |
65 | // Destroy the helper geometry and rebuild.
66 | octreeHelper.update();
67 |
68 | // Destroy the helper geometry.
69 | octreeHelper.dispose();
70 |
71 | Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
72 |
23 |
24 |
25 | 
import { edges, layout } from "sparse-octree";
39 |
40 | import {
41 | BufferAttribute,
42 | BufferGeometry,
43 | Group,
44 | LineSegments,
45 | LineBasicMaterial
46 | } from "three";
47 |
48 | /**
49 | * An octree helper.
50 | */
51 |
52 | export class OctreeHelper extends Group {
53 |
54 | /**
55 | * Constructs a new octree helper.
56 | *
57 | * @param {Tree} [octree=null] - An octree.
58 | */
59 |
60 | constructor(octree = null) {
61 |
62 | super();
63 |
64 | /**
65 | * The name of this object.
66 | *
67 | * @type {String}
68 | * @protected
69 | */
70 |
71 | this.name = "OctreeHelper";
72 |
73 | /**
74 | * The octree.
75 | *
76 | * @type {Tree}
77 | */
78 |
79 | this.octree = octree;
80 |
81 | this.update();
82 |
83 | }
84 |
85 | /**
86 | * Creates octant geometry.
87 | *
88 | * @private
89 | * @param {Iterator} octants - An octant iterator.
90 | * @param {Number} octantCount - The size of the given sequence.
91 | */
92 |
93 | createLineSegments(octants, octantCount) {
94 |
95 | const maxOctants = (Math.pow(2, 16) / 8) - 1;
96 | const group = new Group();
97 |
98 | const material = new LineBasicMaterial({
99 | color: 0xffffff * Math.random()
100 | });
101 |
102 | let result;
103 | let vertexCount;
104 | let length;
105 |
106 | let indices, positions;
107 | let octant, min, max;
108 | let geometry;
109 |
110 | let i, j, c, d, n;
111 | let corner, edge;
112 |
113 | // Create geometry in multiple runs to limit the amount of vertices.
114 | for(i = 0, length = 0, n = Math.ceil(octantCount / maxOctants); n > 0; --n) {
115 |
116 | length += (octantCount < maxOctants) ? octantCount : maxOctants;
117 | octantCount -= maxOctants;
118 |
119 | vertexCount = length * 8;
120 | indices = new Uint16Array(vertexCount * 3);
121 | positions = new Float32Array(vertexCount * 3);
122 |
123 | // Continue where the previous run left off.
124 | for(c = 0, d = 0, result = octants.next(); !result.done && i < length;) {
125 |
126 | octant = result.value;
127 | min = octant.min;
128 | max = octant.max;
129 |
130 | // Create line connections based on the current vertex count.
131 | for(j = 0; j < 12; ++j) {
132 |
133 | edge = edges[j];
134 |
135 | indices[d++] = c + edge[0];
136 | indices[d++] = c + edge[1];
137 |
138 | }
139 |
140 | // Create the vertices.
141 | for(j = 0; j < 8; ++j, ++c) {
142 |
143 | corner = layout[j];
144 |
145 | positions[c * 3] = (corner[0] === 0) ? min.x : max.x;
146 | positions[c * 3 + 1] = (corner[1] === 0) ? min.y : max.y;
147 | positions[c * 3 + 2] = (corner[2] === 0) ? min.z : max.z;
148 |
149 | }
150 |
151 | if(++i < length) {
152 |
153 | result = octants.next();
154 |
155 | }
156 |
157 | }
158 |
159 | geometry = new BufferGeometry();
160 | geometry.setIndex(new BufferAttribute(indices, 1));
161 | geometry.setAttribute("position", new BufferAttribute(positions, 3));
162 |
163 | group.add(new LineSegments(geometry, material));
164 |
165 | }
166 |
167 | this.add(group);
168 |
169 | }
170 |
171 | /**
172 | * Updates the helper geometry.
173 | */
174 |
175 | update() {
176 |
177 | const depth = (this.octree !== null) ? this.octree.getDepth() : -1;
178 |
179 | let level = 0;
180 | let result;
181 |
182 | // Remove existing geometry.
183 | this.dispose();
184 |
185 | while(level <= depth) {
186 |
187 | result = this.octree.findNodesByLevel(level);
188 |
189 | this.createLineSegments(
190 | result[Symbol.iterator](),
191 | (typeof result.size === "number") ? result.size : result.length
192 | );
193 |
194 | ++level;
195 |
196 | }
197 |
198 | }
199 |
200 | /**
201 | * Destroys this helper.
202 | */
203 |
204 | dispose() {
205 |
206 | const groups = this.children;
207 |
208 | let group, children;
209 | let i, j, il, jl;
210 |
211 | for(i = 0, il = groups.length; i < il; ++i) {
212 |
213 | group = groups[i];
214 | children = group.children;
215 |
216 | for(j = 0, jl = children.length; j < jl; ++j) {
217 |
218 | children[j].geometry.dispose();
219 | children[j].material.dispose();
220 |
221 | }
222 |
223 | while(children.length > 0) {
224 |
225 | group.remove(children[0]);
226 |
227 | }
228 |
229 | }
230 |
231 | while(groups.length > 0) {
232 |
233 | this.remove(groups[0]);
234 |
235 | }
236 |
237 | }
238 |
239 | }
240 |
241 |
242 |
23 |
24 |
25 | 
import {OctreeHelper} from 'octree-helper'An octree helper.
65 || Public Constructor | ||
| 85 | public 86 | 87 | 88 | 89 | 90 | | 91 |
92 |
93 |
100 | 94 | 95 | 96 | 97 | constructor(octree: Tree) 98 | 99 |
101 |
102 |
103 |
106 | Constructs a new octree helper. 104 | |
107 | 108 | 109 | 110 | | 111 |
| Public Members | ||
| 121 | public 122 | 123 | 124 | 125 | 126 | | 127 |
128 |
129 |
136 | 130 | 131 | 132 | 133 | octree: Tree 134 | 135 |
137 |
138 |
139 |
142 | The octree. 140 | |
143 | 144 | 145 | 146 | | 147 |
| Protected Members | ||
| 156 | protected 157 | 158 | 159 | 160 | 161 | | 162 |
163 |
171 |
172 |
173 |
174 |
177 | The name of this object. 175 | |
178 | 179 | 180 | 181 | | 182 |
| Public Methods | ||
| 192 | public 193 | 194 | 195 | 196 | 197 | | 198 |
199 |
200 |
207 | 201 | 202 | 203 | 204 | dispose() 205 | 206 |
208 |
209 |
210 |
213 | Destroys this helper. 211 | |
214 | 215 | 216 | 217 | | 218 |
| 221 | public 222 | 223 | 224 | 225 | 226 | | 227 |
228 |
229 |
236 | 230 | 231 | 232 | 233 | update() 234 | 235 |
237 |
238 |
239 |
242 | Updates the helper geometry. 240 | |
243 | 244 | 245 | 246 | | 247 |
Constructs a new octree helper.
278 || Name | Type | Attribute | Description |
| octree | 292 |Tree | 293 |
|
295 | An octree. 296 | |
297 |
The octree.
343 |The name of this object.
389 |Destroys this helper.
436 |Updates the helper geometry.
480 |=h&&(b+=2);f>=k&&(w+=2)}}finally{g&&(g.style.display=a)}}catch(x){E.console&&console.log(x&&x.stack||x)}}var E=window,C=["break,continue,do,else,for,if,return,while"], 34 | F=[[C,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,restrict,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"],"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],H=[F,"alignas,alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,noexcept,noreturn,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"], 35 | O=[F,"abstract,assert,boolean,byte,extends,finally,final,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"],P=[F,"abstract,add,alias,as,ascending,async,await,base,bool,by,byte,checked,decimal,delegate,descending,dynamic,event,finally,fixed,foreach,from,get,global,group,implicit,in,interface,internal,into,is,join,let,lock,null,object,out,override,orderby,params,partial,readonly,ref,remove,sbyte,sealed,select,set,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,value,var,virtual,where,yield"], 36 | F=[F,"abstract,async,await,constructor,debugger,enum,eval,export,function,get,implements,instanceof,interface,let,null,set,undefined,var,with,yield,Infinity,NaN"],Q=[C,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"],R=[C,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],C=[C,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"], 37 | S=/^(DIR|FILE|array|vector|(de|priority_)?queue|(forward_)?list|stack|(const_)?(reverse_)?iterator|(unordered_)?(multi)?(set|map)|bitset|u?(int|float)\d*)\b/,W=/\S/,X=y({keywords:[H,P,O,F,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",Q,R,C],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),I={};t(X,["default-code"]);t(G([],[["pln",/^[^]+/],["dec", 38 | /^]*(?:>|$)/],["com",/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^