Skip to content
Permalink
Browse files

add mesh weight and cost

  • Loading branch information...
lautr3k committed Mar 19, 2016
1 parent f9e4b34 commit 3daa27d08fc3a04e510852476e500202a0aca155
Showing with 17 additions and 7 deletions.
  1. +4 −0 index.html
  2. +13 −7 js/main.js
@@ -82,6 +82,10 @@ <h3 class="panel-title">Mesh</h3>
<span class="info-label">Weight <small>(g)</small></span>
<span class="info-value" id="mesh-weight">0</span>
</div>
<div class="info">
<span class="info-label">Cost <small>($)</small></span>
<span class="info-value" id="mesh-cost">0</span>
</div>
</div>
</div><!-- #mesh -->

@@ -213,12 +213,14 @@ var $meshBody = initPanel('mesh');
var $meshFaces = $meshBody.find('#mesh-faces');
var $meshVolume = $meshBody.find('#mesh-volume');
var $meshWeight = $meshBody.find('#mesh-weight');
var $meshCost = $meshBody.find('#mesh-cost');
var $meshSizeX = $meshBody.find('#mesh-size-x');
var $meshSizeY = $meshBody.find('#mesh-size-y');
var $meshSizeZ = $meshBody.find('#mesh-size-z');
var $meshSizeUnit = $meshBody.find('.mesh-size-unit');

function updateMeshInfoUI(mesh) {
function updateMeshInfoUI() {
var mesh = slicer.mesh;
var size = mesh.getSize();
var unit = settings.get('buildVolume.unit');

@@ -236,9 +238,14 @@ function updateMeshInfoUI(mesh) {
$meshSizeY.html(size.y.toFixed(2));
$meshSizeZ.html(size.z.toFixed(2));

var volume = parseInt(mesh.getVolume() / 1000); // cm3/ml
var weight = (volume * settings.get('resin.density')).toFixed(2); // g
var cost = volume * settings.get('resin.price') / 1000;

$meshFaces.html(mesh.geometry.faces.length);
$meshVolume.html(parseInt(mesh.getVolume() / 1000)); // cm3/ml
$meshWeight.html(0);
$meshVolume.html(volume);
$meshWeight.html(weight);
$meshCost.html(cost);
}

// Slicer panel
@@ -306,9 +313,7 @@ function updateBuildVolumeSettings() {
viewer3d.dropObject(slicer.mesh);
viewer3d.render();

if (size) {
updateMeshInfoUI(slicer.mesh);
}
size && updateMeshInfoUI();

updateBuildVolumeSizeStep();
slice($sliderInput.slider('getValue'));
@@ -334,6 +339,7 @@ function updateResinUI() {
function updateResinSettings() {
settings.set('resin.price' , $resinPrice.val());
settings.set('resin.density', $resinDensity.val());
updateMeshInfoUI();
}

$('#resin input').on('input', updateResinSettings);
@@ -414,7 +420,7 @@ loader.onGeometry = function(geometry) {
viewer3d.render();

// update mesh info
updateMeshInfoUI(slicer.mesh);
updateMeshInfoUI();

// get first slice
//slice(1);

0 comments on commit 3daa27d

Please sign in to comment.
You can’t perform that action at this time.