Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.DS_Store
.idea/
.idea/workspace.xml
13 changes: 13 additions & 0 deletions .idea/CSnap.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/libraries/R_User_Library.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2,183 changes: 2,183 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

68 changes: 61 additions & 7 deletions STLExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,77 @@
*
*/

//this code is last done by Jimmy Ruan
//reach me @ 773-280-1417
// [email protected] (may or may not be reachable after I graduated)

// Jimmy's note: the original code seems like it's pulled from Three.js's example code
// at https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLExporter.js

THREE.STLExporter = function () {};

THREE.STLExporter.prototype = {

constructor: THREE.STLExporter,

parse: ( function () {

/*
var vector = new THREE.Vector3();
var normalMatrixWorld = new THREE.Matrix3();

return function parse( scene, options ) {

if ( options === undefined ) options = {};
*/
return function parse( image, directory, filename, options ) {
//simply sends the image to the backend to let it process the STL file
//then send a request for the STL file, subsequently saving the resulting received file
//parameter:
// image [required](data URI): the url of the image (converted using toDataURL or the like)
// directory [required](str): the directory the STL file should be saved to
// filename (str): the filename to name the STL file as
// *NOTE: TODO: filename may not be needed as it can be sent via the resulting request
// options: various options specifying parameters to create the STL file with
// TODO: do something with options

//<jimmy's code>
//simply prints the string into console
//copy the URL into the address bar itself during debugging
//the url should display the image of the stage by entering it into the address bar
console.log("IMAGE URL:\n" + image);
console.log("\n\nSending image url into " + directory);

//send post request to backend with data url
//should receive the STL model as a response
fetch(directory,
{
method: "POST",
body: image //note to future self: this is the form data
//change the form data however you like to fit backend
//try not to do the other way around
//mode: whatever value gets rid of cors error
//may or may not need to change mode to avoid cross site origin security error

//add other stuff here
//reference: https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/fetch
}
)
.then(function() { //now we get the resulting STL file
fetch(directory)
.then(function(response) {
return response.blob();
})
.then(function(STLBlob) {
saveAs(STLBlob, filename); //this should download the file
});
})
.catch(function(errorMessage) {
console.log("Failed to send image to " + directory);
console.log("Error: " + errorMessage);
});
//</jimmy's code>

/*
//<code from three.STLEXPORTER>

var binary = options.binary !== undefined ? options.binary : false;

//

var objects = [];
var triangles = 0;

Expand Down Expand Up @@ -158,7 +210,9 @@ THREE.STLExporter.prototype = {
return output;

}
//</code from three.STLEXPORTER>

*/
};

}() )
Expand Down
3 changes: 2 additions & 1 deletion csnap.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CSnap - Snap! with culture</title>
<link rel="shortcut icon" href="http://snap.berkeley.edu/fav3.gif" type="image/gif">

<script type="text/javascript">
var config = {
"modules": [],
Expand Down Expand Up @@ -61,7 +62,7 @@
</head>
<body style="margin: 0;">
<canvas id="world" tabindex="1" style="position: absolute;" />
<!--<script>-->
<!--<script>-->
<!--// TogetherJS configuration would go here, but we'll talk about that-->
<!--// later-->
<!--</script>-->
Expand Down
Loading