Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/raymarch
Raymarching based renderer for volume visualization
https://github.com/mikolalysenko/raymarch
Last synced: about 2 months ago
JSON representation
Raymarching based renderer for volume visualization
- Host: GitHub
- URL: https://github.com/mikolalysenko/raymarch
- Owner: mikolalysenko
- License: mit
- Created: 2013-10-01T23:44:28.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-09-14T16:35:35.000Z (over 10 years ago)
- Last Synced: 2024-10-20T14:28:17.711Z (2 months ago)
- Language: JavaScript
- Homepage: mikolalysenko.github.io/raymarch
- Size: 400 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
raymarch
========
A basic ray marching volume rendering module.Install
=======npm install raymarch
Example
=======[View this demo in your browser right now](http://mikolalysenko.github.io/raymarch/)
```javascript
var createVolumeRenderer = require("raymarch")
var shell = require("gl-now")()
var camera = require("game-shell-orbit-camera")(shell)
var glm = require("gl-matrix")
var voxelize = require("voxelize")
var bunny = require("bunny")
var ops = require("ndarray-ops")camera.lookAt([3,0,0], [0,0,0], [0,1,0])
var viewer
shell.on("gl-init", function() {
var voxels = voxelize(bunny.cells, bunny.positions, 0.1).voxels
ops.mulseq(voxels, 255)
viewer = createVolumeRenderer(shell.gl, voxels)
})shell.on("gl-render", function() {
viewer.projection = glm.mat4.perspective(new Float32Array(16), Math.PI/4.0, shell.width/shell.height, 0.01, 1000.0)
viewer.view = camera.view()
viewer.draw()
})
```# API
```javascript
var createVolumeViewer = require("raymarch")
```## Constructor
### `viewer = createVolumeViewer(gl, array)`
Creates a volume viewer object## Methods
### `viewer.model`
The current model matrix for the viewer### `viewer.view`
The current view matrix for the viewer### `viewer.projection`
The current projection matrix for the viewer### `viewer.draw()`
Draws the current volume to the screen### `viewer.dispose()`
Releases all resources associated with this viewer.# Credits
(c) 2013 Mikola Lysenko. MIT License