Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
kovacsv committed Sep 30, 2013
2 parents 3ce44f9 + 602f324 commit f2ef704
Show file tree
Hide file tree
Showing 67 changed files with 3,945 additions and 273 deletions.
104 changes: 52 additions & 52 deletions build/jsmodeler.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions documentation/demo/include/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ JSMDemo.prototype =
Initialize : function (canvasName, uiDivName)
{
var viewerSettings = {
'cameraEyePosition' : [-3.0, -2.5, 2.0],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [-3.0, -2.5, 2.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

this.viewer = new JSM.Viewer ();
Expand Down
6 changes: 3 additions & 3 deletions documentation/examples/clock.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@
};

var viewerSettings = {
"cameraEyePosition" : [2.0, 2.0, 2.0],
"cameraCenterPosition" : [0.0, 0.0, 0.0],
"cameraUpVector" : [1, 0, 0]
cameraEyePosition : [2.0, 2.0, 2.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [1, 0, 0]
};

window.onresize = Resize;
Expand Down
6 changes: 3 additions & 3 deletions documentation/examples/deform.html
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@
Resize ();

var viewerSettings = {
'cameraEyePosition' : [-5.0, -5.0, 5.0],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [-5.0, -5.0, 5.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

viewer = new JSM.Viewer ();
Expand Down
6 changes: 3 additions & 3 deletions documentation/examples/legobuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
};

var viewerSettings = {
"cameraEyePosition" : [1.0, -1.5, 1.0],
"cameraCenterPosition" : [0.0, 0.0, 0.0],
"cameraUpVector" : [0, 0, 1]
cameraEyePosition : [1.0, -1.5, 1.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0, 0, 1]
};

window.onresize = Resize;
Expand Down
8 changes: 4 additions & 4 deletions documentation/examples/robot/robot.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@
}

var viewerSettings = {
'cameraEyePosition' : [-4, -4, 4],
'cameraCenterPosition' : [0.0, 0.0, 1.5],
'cameraUpVector' : [0.0, 0.0, 1.0],
'cameraDisableZoom' : true
cameraEyePosition : [-4, -4, 4],
cameraCenterPosition : [0.0, 0.0, 1.5],
cameraUpVector : [0.0, 0.0, 1.0],
cameraDisableZoom : true
};

viewer = new JSM.Viewer ();
Expand Down
6 changes: 3 additions & 3 deletions documentation/examples/solids.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@
{
ShowHide (1, 3);
var viewerSettings = {
'cameraEyePosition' : [3, 2, 3],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [3, 2, 3],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

window.onresize = Resize;
Expand Down
8 changes: 4 additions & 4 deletions documentation/examples/tictactoe.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@
ticTacToe = new TicTacToe ();

var viewerSettings = {
'cameraEyePosition' : [14.0, -14.0, 16.0],
'cameraCenterPosition' : [4.5, 4.5, 4.5],
'cameraUpVector' : [0.0, 0.0, 1.0],
'cameraDisableZoom' : true
cameraEyePosition : [14.0, -14.0, 16.0],
cameraCenterPosition : [4.5, 4.5, 4.5],
cameraUpVector : [0.0, 0.0, 1.0],
cameraDisableZoom : true
};

var canvas = document.getElementById ('example');
Expand Down
6 changes: 3 additions & 3 deletions documentation/tutorial/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@
}

var viewerSettings = {
'cameraEyePosition' : [-2.0, -1.5, 1.0],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [-2.0, -1.5, 1.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

window.onresize = Resize;
Expand Down
6 changes: 3 additions & 3 deletions documentation/tutorial/minimal.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
function Load ()
{
var viewerSettings = {
'cameraEyePosition' : [-2.0, -1.5, 1.0],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [-2.0, -1.5, 1.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

var viewer = new JSM.Viewer ();
Expand Down
6 changes: 3 additions & 3 deletions documentation/tutorial/tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
JSModeler contains a built-in viewer to show models. The viewer needs the THREE.js framework, and we can initialize it for an existing canvas in the onload event of the page. If we have a canvas with an id "example", we can use the following code to initialize the viewer.
<pre>
var viewerSettings = {
'cameraEyePosition' : [-2.0, -1.5, 1.0],
'cameraCenterPosition' : [0.0, 0.0, 0.0],
'cameraUpVector' : [0.0, 0.0, 1.0]
cameraEyePosition : [-2.0, -1.5, 1.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0.0, 0.0, 1.0]
};

var viewer = new JSM.Viewer ();
Expand Down
174 changes: 174 additions & 0 deletions sandbox/charts.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
<!--
Author: Kovacs Viktor
Homepage: http://www.kovacsv.hu
-->

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<meta http-equiv="content-type" content="text/html;charset=utf-8">
<script type="text/javascript" src="../src/core/jsm.js"></script>
<script type="text/javascript" src="../src/geometry/determinant.js"></script>
<script type="text/javascript" src="../src/geometry/matrix.js"></script>
<script type="text/javascript" src="../src/geometry/coord.js"></script>
<script type="text/javascript" src="../src/geometry/coordutils.js"></script>
<script type="text/javascript" src="../src/geometry/coordsystem.js"></script>
<script type="text/javascript" src="../src/geometry/coordsystemutils.js"></script>
<script type="text/javascript" src="../src/geometry/sector.js"></script>
<script type="text/javascript" src="../src/geometry/sectorutils.js"></script>
<script type="text/javascript" src="../src/geometry/line.js"></script>
<script type="text/javascript" src="../src/geometry/lineutils.js"></script>
<script type="text/javascript" src="../src/geometry/transformation.js"></script>
<script type="text/javascript" src="../src/geometry/transformationutils.js"></script>
<script type="text/javascript" src="../src/geometry/polygon.js"></script>
<script type="text/javascript" src="../src/geometry/polygonutils.js"></script>
<script type="text/javascript" src="../src/geometry/plane.js"></script>
<script type="text/javascript" src="../src/geometry/planeutils.js"></script>
<script type="text/javascript" src="../src/geometry/projection.js"></script>
<script type="text/javascript" src="../src/geometry/convexhull.js"></script>
<script type="text/javascript" src="../src/modeler/camera.js"></script>
<script type="text/javascript" src="../src/modeler/body.js"></script>
<script type="text/javascript" src="../src/modeler/bodyutils.js"></script>
<script type="text/javascript" src="../src/modeler/adjacencylist.js"></script>
<script type="text/javascript" src="../src/modeler/cututils.js"></script>
<script type="text/javascript" src="../src/modeler/textureutils.js"></script>
<script type="text/javascript" src="../src/modeler/model.js"></script>
<script type="text/javascript" src="../src/modeler/material.js"></script>
<script type="text/javascript" src="../src/modeler/generator.js"></script>
<script type="text/javascript" src="../src/modeler/solidgenerator.js"></script>
<script type="text/javascript" src="../src/modeler/svgtomodel.js"></script>
<script type="text/javascript" src="../src/modeler/exporter.js"></script>
<script type="text/javascript" src="../build/three.min.js"></script>
<script type="text/javascript" src="../src/viewer/converter.js"></script>
<script type="text/javascript" src="../src/viewer/mouse.js"></script>
<script type="text/javascript" src="../src/viewer/touch.js"></script>
<script type="text/javascript" src="../src/viewer/viewer.js"></script>
<title>Example</title>

<script type="text/javascript">
var viewer = null;

function GenerateChart ()
{
function GetMaximumCount (chart)
{
var max = 0;
var i, j, current;
for (i = 0; i < chart.values.length; i++) {
current = chart.values[i];
if (current.length > max) {
max = current.length;
}
}
return max;
}

function GenerateBoundingBody (model, materials, chart)
{
var rowCount = GetMaximumCount (chart);
var columnCount = chart.values.length;
var xSize = rowCount * chart.itemSize + (rowCount - 1) * chart.itemOffsetX + 2 * chart.itemSize;
var ySize = columnCount * chart.itemSize + (columnCount - 1) * chart.itemOffsetY + 2 * chart.itemSize;
var offsetX = xSize / 2.0 - 3.0 * chart.itemSize / 2.0;
var offsetY = ySize / 2.0 - 3.0 * chart.itemSize / 2.0;
var bottom = JSM.GenerateRectangle (xSize, ySize);
bottom.Transform (new JSM.TranslationTransformation (new JSM.Vector (offsetX, offsetY, 0.0)));
bottom.SetPolygonsMaterialIndex (0);
model.AddBody (bottom);
}

function GenerateOneValueBody (model, materials, chart, i, j)
{
var height = chart.values[i][j];
var offsetX = j * (chart.itemSize + chart.itemOffsetX);
var offsetY = i * (chart.itemSize + chart.itemOffsetY);
var body = JSM.GenerateCuboidSides (chart.itemSize, chart.itemSize, height, [1, 1, 1, 1, 0, 1]);
body.Transform (new JSM.TranslationTransformation (new JSM.Vector (offsetX, offsetY, height / 2.0)));
var material = 1 + (i % (materials.Count () - 1));
body.SetPolygonsMaterialIndex (material);
model.AddBody (body);
}

function GenerateValueBodies (model, materials, chart)
{
var i, j;
for (i = 0; i < chart.values.length; i++) {
for (j = 0; j < chart.values[i].length; j++) {
GenerateOneValueBody (model, materials, chart, i, j);
}
}
}

var chart = {
values : [
[2, 4, 3, 5, 1, 4, 2],
[1, 5, 3, 4],
[3, 1, 2, 5, 1, 3]
],
itemSize : 1.0,
itemOffsetX : 0.5,
itemOffsetY : 0.5,
};

var model = new JSM.Model ();
var materials = new JSM.Materials ();
materials.AddMaterial (new JSM.Material (0xf0f0f0, 0xf0f0f0));
materials.AddMaterial (new JSM.Material (0x008ab8, 0x008ab8));
materials.AddMaterial (new JSM.Material (0x279b61, 0x279b61));
materials.AddMaterial (new JSM.Material (0x993333, 0x993333));
materials.AddMaterial (new JSM.Material (0xffcc33, 0xffcc33));
materials.AddMaterial (new JSM.Material (0x95cae4, 0x95cae4));
materials.AddMaterial (new JSM.Material (0xa3e496, 0xa3e496));
materials.AddMaterial (new JSM.Material (0xcc3333, 0xcc3333));
materials.AddMaterial (new JSM.Material (0xffff7a, 0xffff7a));

GenerateBoundingBody (model, materials, chart);
GenerateValueBodies (model, materials, chart);

return [model, materials];
}

function Load ()
{
var TextureLoaded = function () {
viewer.Draw ();
};

var viewerSettings = {
cameraEyePosition : [3.0, -2.0, 1.0],
cameraCenterPosition : [0.0, 0.0, 0.0],
cameraUpVector : [0, 0, 1],
cameraDisableZoom : true
};

viewer = new JSM.Viewer ();
viewer.Start ('example', viewerSettings);

var model = GenerateChart ();
var conversionData = new JSM.ConversionData (null, true, true);
var meshes = JSM.ConvertModelToThreeMeshes (model[0], model[1], conversionData);
for (var i = 0; i < meshes.length; i++) {
viewer.AddMesh (meshes[i]);
}

viewer.FitInWindow ();
viewer.Draw ();
}

window.onload = function ()
{
Load ();
}
</script>

</head>

<body>
<canvas id="example" width="1000" height="500"></canvas>
</body>

</html>
Loading

0 comments on commit f2ef704

Please sign in to comment.