A 3D model viewer in JavaScript.
npm install ara3d-viewerara3d-viewer.js) making it easy to integrate a custom 3D viewer into your website with just a couple of lines of code.
Simple Ara Viewer Example
`
API
* .run
* .setOptions
* .defaultOptions
* .addModel
* .removeModel
* .scene
* .pause
Build Process
Call npm run build. This will call a gulp script (gulpfile.js) that minifies and concatenates the sources.
The main viewer code is writtein in TypeScript, and has to be built separately before running gulp.
Testing Process
Testing is done using Mocha and can be executed by npm test:
https://threejs.org/docs/#manual/en/buildTools/Testing-with-NPM
The Sources and Dependencies
The distributable file ara-viewer.js is a concatenation of:
* Three.JS
* The main Three.JS distributable
* WebGL statistics utility
* WebGL detector utility
* Several file loaders for Three.JS from the examples/loaders folder
* Three.JS Orbit controls from the examples/controls folder
* Dat.GUI
* The ara-viewer-main.js source file which encapsulates common Three JS boiler plate
Options
The Ara viewer can be fully customized by passing a JSON object, describing the 3D scene.
`
{
dom: document.getElement().body,
models: [
{
url: 'myfiles.stl',
transform: {
},
},
{
primitive: plane,
width: 40,
height: 40,
material: {
color: 0x999999,
specular: 0x101010,
},
transform: {
rotation: {
x: -Math.PI/2,
},
position: {
y: -0.5
}
},
},
],
lights: [
{
type: hemisphere,
skyColor: 0x443333,
groundColor: 0x111122,
intensity: 1,
},
{
type: shadowedLight,
position: { x: },
color:
intensity:
}
]
camera: {
target: { y: -0.1 },
position: { x: 3, y: 0.15, z: 3 },
fov: 35,
near: 1,
far: 15,
},
background: {
color: 0x72645b,
},
fog: {
color: 0x72645b
near: 2,
far: 15,
},
stats: true,
controls: true,
}
``