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

eod

parent 7b28f339
Branches
No related tags found
No related merge requests found
......@@ -25,7 +25,9 @@ $(function(){
modelMesh:modelMesh};
workers.map(xRange, fillWithElements, localEnv, incrCallback);
// for (var x=boundingBox.min.x;x<boundingBox.max.x;x+=cubeDim){
// fillWithElements(x);
// }
function incrCallback(result){
console.log(result);
......@@ -49,17 +51,20 @@ $(function(){
}
function fillWithElements(x){
console.log("here");
var meshesToAdd = [];
var cubeDim = localEnv.cubeDim;
var boundingBox = localEnv.boundingBox;
var modelClone = new THREE.Mesh(localEnv.modelMesh.geometry, localEnv.modelMesh.material);//had to do this for some reason
// var modelClone = new THREE.Mesh(localEnv.modelMesh.geometry, localEnv.modelMesh.material);//had to do this for some reason
for (var y=boundingBox.min.y;y<boundingBox.max.y;y+=cubeDim){
for (var z=boundingBox.min.z;z<boundingBox.max.z;z+=cubeDim){
var raycaster = new THREE.Raycaster(new THREE.Vector3(x+cubeDim/2, y+cubeDim/2, z+cubeDim/2),
new THREE.Vector3(0, 0, 1), 0, boundingBox.max.z-z+cubeDim/2);
var numIntersections = raycaster.intersectObject(modelClone).length;
var numIntersections = raycaster.intersectObject(modelMesh).length;
// console.log(numIntersections);
// if (numIntersections % 2 == 1) {
// console.log("here");
// }
// var mesh = createCubeGeometry(cubeDim);
// mesh.position.set(x+cubeDim/2, y+cubeDim/2, z+cubeDim/2);
// mesh.updateMatrix();
......
......@@ -7,6 +7,7 @@
$(function(){
three = three || {};
workers = workers || {};
modelMesh = {};
var modelScaleSlider = $('#stlModelScale');
......@@ -16,6 +17,9 @@ $(function(){
loader.addEventListener( 'load', function (e) {
var geometry = e.content;
resetUI();
_.each(workers.allWorkers, function(worker){
worker.postMessage({model: JSON.stringify(e.content)});
});
var material = new THREE.MeshLambertMaterial( { color:0xffa500, shading: THREE.FlatShading, transparent:true, opacity:0.5, side:THREE.DoubleSide} );
modelMesh = new THREE.Mesh(geometry, material);
three.scene.add(modelMesh);
......
......@@ -104,6 +104,6 @@ function persistentWorkers(numWorkers){
return URL.createObjectURL(blob);
}
return {map:map};//return all public methods and vars
return {map:map, allWorkers:allWorkers};//return all public methods and vars
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ function myWorker(){
localEnv = null;//local variables passed in from outside
working = false;//boolean that says whether I'm busy or not
arg = null;//main data we are crunching
modelMesh = null;//hold on to this so we don't have to keep passing it in
self.onmessage = function(e) {
var data = e.data;
......@@ -23,9 +24,10 @@ function myWorker(){
// importScripts(url + 'js/element.js');
}
//
// if (data.id){
// id = data.id;
// }
if (data.model){
var material = new THREE.MeshLambertMaterial({side:THREE.DoubleSide});
modelMesh = new THREE.Mesh(JSON.parse(data.model), material);
}
if (data.executable){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment