0.1.1 • Published 12 years ago
svg-3d-simplicial-complex v0.1.1
svg-3d-simplicial-complex
Renders a simplicial complex to a list of elements in an SVG file
Example
var bunny = require("bunny")
var mat4 = require("gl-matrix").mat4
var render = require("svg-3d-simplicial-complex")
console.log('<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"version="1.1">')
console.log(render(bunny.cells, bunny.positions, {
view: mat4.lookAt(mat4.create(), [5, 10, 20], [0,2,0], [0,1,0]),
projection: mat4.perspective(mat4.create(),
Math.PI/4.0,
1.0,
0.1,
1000.0),
viewport: [[0,0], [512,512]]
}))
console.log("</svg>")Output svg:
Install
npm install svg-3d-simplicial-complexAPI
require("svg-3d-simplicial-complex")(cells,positions,[,options])
Renders a simplicial complex as a list of elements
cellsis an indexed list of facetspositionsis a list of vertex positionsoptionsis an object that has the following optional properties:modelthe model matrix for the cameraviewthe view matrix for the cameraprojectionthe projection matrix for the cameraviewportthe viewport for the rendered svg
Conventions for camera and viewport follow those from WebGL
Returns A string of <polygon> svg elements that renders the simplicial complex.
Credits
(c) 2014 Mikola Lysenko. MIT License