{"id":18963832,"url":"https://github.com/janeliascicomp/sharkviewer","last_synced_at":"2025-07-16T23:35:44.722Z","repository":{"id":974143,"uuid":"93181094","full_name":"JaneliaSciComp/SharkViewer","owner":"JaneliaSciComp","description":"SharkViewer is a web-based viewer for SWC neuron files. It is written entirely in JavaScript using Three.js. ","archived":false,"fork":false,"pushed_at":"2023-01-08T10:55:49.000Z","size":330271,"stargazers_count":24,"open_issues_count":3,"forks_count":11,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T20:21:20.356Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JaneliaSciComp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-02T15:48:51.000Z","updated_at":"2024-07-11T04:21:10.000Z","dependencies_parsed_at":"2023-01-13T10:49:14.333Z","dependency_job_id":null,"html_url":"https://github.com/JaneliaSciComp/SharkViewer","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2FSharkViewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2FSharkViewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2FSharkViewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JaneliaSciComp%2FSharkViewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JaneliaSciComp","download_url":"https://codeload.github.com/JaneliaSciComp/SharkViewer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249201117,"owners_count":21229004,"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-11-08T14:21:57.958Z","updated_at":"2025-04-16T05:31:28.281Z","avatar_url":"https://github.com/JaneliaSciComp.png","language":"JavaScript","readme":"![SharkLogo](old/images/SharkLogo.png)\n\n![Badge](https://zenodo.org/badge/doi/10.5281/zenodo.10053.png)\n\n# Shark Viewer\n\n## NEW\n**09-26-2014** - Synapse Annotations. Load annotations from a separate file with format \"x y z\\n\" for each annotation. You can use annotation\\_parser(annotation\\_text) to parse it into the format [{'x': x, 'y': y, 'z':z}, {'x': x1, 'y': y1, 'z':z1}, ..., {'x': xn, 'y': yn, 'z':zn}] and load that into the annotation property of SharkViewer.\n\n**08-08-2014** - Three.js loader version: html/js/sharkviewer_loader.js\nIf you want to use the neuron rendered from SharkViewer in another scene use this version. html/Shark\\_Viewer\\_Loader\\_Version.html shows an example of how to use it.\n\n**06-18-2014** - Serverless SharkViewer! Now the html/Shark\\_Viewer.html file allows you to load and view your own SWC files without a server. Simply download the repository and open Shark\\_Viewer.html in a browser, then use the form to view your own SWC files.\n\n## DESCRIPTION\nSharkViewer is a web-based viewer for SWC neuron files. It is written entirely in JavaScript using Three.js.\nTo view SWC format guidelines visit: http://research.mssm.edu/cnic/swc.html\n\n## EXAMPLE\nhttp://janeliascicomp.github.io/SharkViewer/\n\n## QUICK START\n1. Install the dependencies\n```zsh\nnpm install\n```\n1. Start up a test server\n```zsh\nnpm run start\n```\n1. Click 'Choose File' button to load a SWC file.\n\n## USAGE\n\n### AS A MODULE\n1. fetch the package\n```\nnpm install @janelia/sharkviewer\n```\n1. import\n```javascript\nimport SharkViewer, { swcParser } from sharkViewer;\n```\n1. Create a new SharkViewer object. At a minimum you need to give it a DOM element to attach a canvas to.\n```javascript\nvar s = new sharkViewer({ dom_element: 'container' });\n```\n1. Initialize the SharkViewer\n```javascript\ns.init();\n```\n1. Animate the SharkViewer\n```javascript\ns.animate();\n```\n1. load in a neuron swc file.\n```javascript\nconst swcJSON = swcParser(swcText);\ns.loadNeuron('neuron_name', '#ff0000', swcJSON);\n```\n\n\n### AS A LIBRARY\n1. download this repository\n1. copy lib/shark_viewer.js and lib/three.min.js into your project\n1. Load the javascript files into your page\n```HTML\n\u003cscript src=\"three.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"shark_viewer.js\"\u003e\u003c/script\u003e\n```\n1. Create a new SharkViewer object. At a minimum you need to give it a DOM element to attach a canvas to.\n```javascript\nvar s = new sharkViewer.default({ swc: swc, dom_element: 'container' });\n```\n1. Initialize the SharkViewer\n```javascript\ns.init();\n```\n1. Animate the SharkViewer\n```javascript\ns.animate();\n```\n1. Load an SWC file into json. There is a helper function swcParser(swcText) available, or you can write your own to process it server side and load via AJAX.\n```javascript\nvar swcJSON = sharkViewer.swcParser(swcTxt); ;\ns.loadNeuron('neuron_name', '#ff0000', swcJSON);\n```\n\nlib/index.html shows an example of this setup.\n\n### sharkViewer.default()\n\nCreate a new SharkViewer instance to display a collection of neurons.\n\n#### Arguments\n\n* dom_element - html element that will receive the webgl canvas\n  * *Default*: 'container'\n\n* mode - sphere (full 3-D rendering for nodes and connections, slow), particle (uses particle system to speed rendering and make it look better), or skeleton (no nodes, just connections, very fast)\n  * *Default*: 'particle'\n\n* show_cones - show cones between cylinders for particle and sphere mode\n  * *Default*: true;\n\n* colors - color array for display, nodes of type 0 show as first color, etc.\n  * *Default*:\n    ```\n    [\n\t    0x00be9e,\n\t    0x3919cb,\n\t    0x7d0bc4,\n\t    0xff6700,\n\t    0x3eef00,\n\t    0xffce00,\n\t    0xf50027,\n\t    0x606060,\n    ]\n    ```\n* metadata - array of javascript objects with labels and type numbers to display as legend (type number matches to type column in swc file)  format:\n  * *Default*: false\n  * Example:\n```\n[{\"label\":\"undefined\",\"type\":0},{\"label\":\"soma\",\"type\":1}]\n```\n* annotation - array of javascript objects with x, y, z coordinates to display as synapse annotations.\n  * *Default*: false\n  * Example:\n```\n[{'x': x, 'y': y, 'z':z}, {'x': x1, 'y': y1, 'z':z1}, ..., {'x': xn, 'y': yn, 'z':zn}]\n```\n* annotation_color - color to display annotations\n\n  *Default* 0x111111\n\n### sharkViewer.swcParser(swcText)\n\nParse SWC files into a JSON format for loading into the viewer.\n\n#### Arguments\n\n* **swcText** [string]:\n    An SWC file based on the format described at [http://research.mssm.edu/cnic/swc.html](http://research.mssm.edu/cnic/swc.html)\n\n\n### sharkViewer.loadNeuron(name, color, swcJSON, updateCamera)\n\nLoad a neuron SWC JSON object into the viewer and center the camera around it.\n\n#### Arguments\n\n* **name** [string]: A simple text string used to identify the object.\n  Used by other functions to remove or hide it.\n* **color** [string]: Hexadecimal string to determine the color of the neuron.\n* **swcJSON** [JSON]: JSON string representation of the SWC file. A description of\nthe expected format is shown below.\n```javascript\nswc json object: {\n    id : {\n        type: \u003ctype number of node (string)\u003e,\n        x: \u003cx position of node (float)\u003e,\n        y: \u003cy position of node (float)\u003e,\n        z: \u003cz position of node (float)\u003e,\n        parent: \u003cid number of node parent (-1 if no parent)\u003e,\n        radius: \u003cradius of node (float)\u003e,\n    }\n}\n```\n* **updateCamera** [boolean]: If false the camera will not center around the newly added object.\n\n### unloadNeuron(name)\n\nRemove the neuron from memory and stop displaying it.\n\n#### Arguments\n\n* **name** [string]: The name used when loading the neuron.\n\n### setNeuronVisible(name, visible)\n\nShow or hide the neuron object, without removing it from the scene.\n\n#### Arguments\n\n* **name** [string]: The name used when loading the neuron.\n* **visible** [boolean]: true to show the neuron, false to hide it.\n\n\n## Author Information\nSharkViewer was originally written by Charlotte Weaver (\u003cweaverc10@janelia.hhmi.org\u003e) and Christopher Bruns (\u003cbrunsc@janelia.hhmi.org\u003e)\n\n## Contributors\n- Patrick Edson\n- Jody Clements\n- Phillip Hubbard\n\n[![Janelia Research Campus](old/images/hhmi_janelia_transparentbkgrnd.png)](http://www.janelia.org)\n\n[Scientific Computing](http://www.janelia.org/research-resources/computing-resources)\n\n[Janelia Research Campus](http://www.janelia.org)\n\n[Howard Hughes Medical Institute](http://www.hhmi.org)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneliascicomp%2Fsharkviewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaneliascicomp%2Fsharkviewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaneliascicomp%2Fsharkviewer/lists"}