csg-viewer
![Build Status](https://travis-ci.org/jscad/csg-viewer.svg)
3D viewer for Csg.js / Openjscad csg/cag data : small, fast, simple
This is a very early version of this viewer ! Expect changes !
Overview
Table of Contents
Installation
npm install jscad/csg-viewer
Usage
import makeViewer from 'csg-viewer'
const makeViewer = require('csg-viewer')
const viewerOptions = {
background: [0.211, 0.2, 0.207, 1],
meshColor: [0.4, 0.6, 0.5, 1],
grid: {
display: true,
color: [1, 1, 1, 0.1]
},
camera: {
position: [450, 550, 700]
},
controls: {
limits: {
maxDistance: 1600,
minDistance: 0.01
}
}
}
const {csgViewer, viewerDefaults, viewerState$} = makeViewer(document.body, viewerOptions)
let csg = CSG.cube()
csgViewer(viewerOptions, {solids: csg})
csgViewer({camera: { position: [0, 100, 100] }})
csg = CSG.sphere()
csgViewer({}, {solids: csg})
csgViewer({controls: {autoRotate: {enabled: true}}})
Test
There are no unit tests for the 3d viewer, however there is a small demo that is very practical to iterate fast and to see something visual without a complicated setup:
type:
npm run dev
this will start the demo at localhost:9966
API
Work in progress!
License
The MIT License (MIT)
(unless specified otherwise)