Giter Club home page Giter Club logo

kdb-viewer's Introduction

kdb-viewer

A simple webgl xyz file renderer for the KDB project.

Example

See the included example.html file for an example.

Click here to see the example live.

Interaction

  • Click with the left mouse button on the view and translate your mouse to rotate the view.
  • Use your scroll wheel on the view to zoom in and out.

Using the prebuilt script

Copy the kdb-viewer.min.js script onto your server and insert the following in your <head> tag:

  <script src="kdb-viewer.min.js"></script>

This will add the ViewManager object to the global namespace, ready to use.

API

Create a new ViewManager instance:

const manager = ViewManager();

Pass an xyz file as a string and a radius scale parameter to the addView function to create a new view canvas:

const caffeine = `24
Caffeine
H      -3.3804130    -1.1272367     0.5733036
N       0.9668296    -1.0737425    -0.8198227...`

const view = manager.addView(caffeine, 1.0);

The resulting view object is a canvas that will respond to mouse events and render your data. Append it to your document however you'd like:

document.body.appendChild(view);

Calling the removeView function will remove the canvas from its container and destroy all events associated with it.

manager.removeView(view);

Contributing

  • Install Node.js. I recommend nvm for this.
  • Clone this repo.
  • Enter the repo and execute npm i to install the dependencies.
  • Run npm start and point your browser to http://localhost:9966.
  • Edit the source files (from higher-to-lower levels of abstraction: example.js, view-manager.js, and viewer.js).
  • Save your changes. The browser should automatically reload.
  • Run npm run build to rebuild kdb-viewer.min.js.

kdb-viewer's People

Contributors

wwwtyro avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.