stlviewer.js

changeset 17
dee15870206a
parent 13
39fb313ba27c
child 18
ff1941c85fd3
equal deleted inserted replaced
16:800e8da193a7 17:dee15870206a
63 }, 63 },
64 success: function(data) { 64 success: function(data) {
65 //console.log(data); 65 //console.log(data);
66 // remove all meshes 66 // remove all meshes
67 clear_scene(); 67 clear_scene();
68 var content = "<h2>Material:</h2><ul>";
69 var weight = 0.0;
70 var length = 0;
71 var volume = 0;
68 // append the objects with positioning 72 // append the objects with positioning
69 for (i = 0; i<data.objects.length; i++) { 73 for (i = 0; i<data.objects.length; i++) {
70 var obj = data.objects[i]; 74 var obj = data.objects[i];
75 content += "<li>";
71 if (obj[5] == "") { 76 if (obj[5] == "") {
72 // spacer 77 // spacer
73 filename = "stl/spacer_" + obj[4][0] + '.stl'; 78 filename = "stl/spacer_" + obj[4][0] + '.stl';
74 material = 'm_spacer'; 79 material = 'm_spacer';
80 content += "Spacer: " + obj[4][0] + " (" + obj[4][1] + "mm)"
75 } else { 81 } else {
76 // cylinder 82 // cylinder
77 filename = "stl/cylinder_" + obj[5] + '.stl'; 83 filename = "stl/cylinder_" + obj[5] + '.stl';
78 material = 'm_cylinder'; 84 material = 'm_cylinder';
85 content += "Cylinder: " + obj[4][4] + " (" + obj[4][0] + "mm)"
86 weight += obj[4][3];
87 volume += obj[4][2];
88 if (obj[4][1] > length) length = obj[4][1];
79 } 89 }
80 position = [data.scale3d * 0.01 * obj[0], 0, 0]; 90 position = [data.scale3d * 0.01 * obj[0], 0, 0];
81 loadSTL(filename, material + "", position); 91 loadSTL(filename, material + "", position);
92 content += "</li>"
82 } 93 }
94
95 content += "</ul><br/>Total cylinder weight: " + Math.ceil(weight) + " kg<br/>";
96 content += "Total cylinder volume: " + Math.floor(volume) + " ℓ<br/>";
97 content += "Max cylinder length: " + Math.ceil(length / 10) + " cm<br/>"
98
99 $("#infocontainer").html(content);
83 100
84 } 101 }
85 }); 102 });
86 } 103 }
87 104

mercurial