Skip to content
Snippets Groups Projects
Commit 4fc18826 authored by Amanda Ghassaei's avatar Amanda Ghassaei
Browse files

stl import rotations

parent 523d05ea
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ $(function(){ ...@@ -19,6 +19,7 @@ $(function(){
modelMesh = new THREE.Mesh(geometry); modelMesh = new THREE.Mesh(geometry);
three.scene.add(modelMesh); three.scene.add(modelMesh);
three.render(); three.render();
showDimensions(1);
$("#STLImportStats").fadeIn(); $("#STLImportStats").fadeIn();
}); });
...@@ -63,10 +64,35 @@ $(function(){ ...@@ -63,10 +64,35 @@ $(function(){
modelScaleSlider.change(function(){ modelScaleSlider.change(function(){
var value = $(this).slider('getValue'); var value = $(this).slider('getValue');
modelMesh.scale.set(value,value,value); modelMesh.scale.set(value,value,value);
showDimensions(value);
three.render(); three.render();
}); });
function setFileName(name){ function setFileName(name){
$("#STLFilename").html("Current file loaded:&nbsp&nbsp"+name); $("#STLFilename").html("Current file loaded:&nbsp&nbsp"+name);
} }
function showDimensions(scale){
var boundingBox = modelMesh.geometry.boundingBox;
$("#meshDimensions").html("Dimensions: " + ((boundingBox.max.x - boundingBox.min.x)*scale).toFixed(1) + " x " +
((boundingBox.max.y - boundingBox.min.y)*scale).toFixed(1) + " x " + ((boundingBox.max.z - boundingBox.min.z)*scale).toFixed(1));
}
$("#stlRotateX").click(function(e){
e.preventDefault();
modelMesh.rotateX(Math.PI/2);
three.render();
});
$("#stlRotateY").click(function(e){
e.preventDefault();
modelMesh.rotateY(Math.PI/2);
three.render();
});
$("#stlRotateZ").click(function(e){
e.preventDefault();
modelMesh.rotateZ(Math.PI/2);
three.render();
});
}); });
\ No newline at end of file
...@@ -98,10 +98,19 @@ ...@@ -98,10 +98,19 @@
</div><!-- /btn-group --> </div><!-- /btn-group -->
</div> </div>
</div> <!-- /.col-xs-3 --> </div> <!-- /.col-xs-3 -->
<div id="STLImportStats" class="col-xs-8"> <div id="STLImportStats" class="col-xs-9">
<div id="STLFilename"></div><br/>Dimensions:<br/> <div id="STLFilename"></div><br/><div id="meshDimensions"></div>
Change model scale: <div>Change model scale:</div>
<input id="stlModelScale" type="text" data-slider-min="0.0" data-slider-max="20" data-slider-step="0.1" data-slider-value="1"/> <input id="stlModelScale" type="text" data-slider-min="0.0" data-slider-max="20" data-slider-step="0.1" data-slider-value="1"/>
<div class="col-xs-4">
<a href="#" id="stlRotateX" class="btn btn-block btn-lg btn-default">Rotate X</a>
</div>
<div class="col-xs-4">
<a href="#" id="stlRotateY" class="btn btn-block btn-lg btn-default">Rotate Y</a>
</div>
<div class="col-xs-4">
<a href="#" id="stlRotateZ" class="btn btn-block btn-lg btn-default">Rotate Z</a>
</div>
</div> </div>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment