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

wanted to leave this in some working order tonight

parent b5acc586
No related branches found
No related tags found
No related merge requests found
......@@ -20,67 +20,47 @@ $(function(){
xRange.push(x);
}
var localEnv = {boundingBox:boundingBox,
cubeDim:cubeDim,
modelMesh:modelMesh};
var localEnv = {boundingBox:boundingBox,cubeDim:cubeDim,modelMesh:modelMesh};
workers.map(xRange, fillWithElements, localEnv, incrCallback);
// for (var x=boundingBox.min.x;x<boundingBox.max.x;x+=cubeDim){
// fillWithElements(x);
// }
// workers.map(xRange, fillWithElements, localEnv, incrCallback);
for (x=boundingBox.min.x;x<boundingBox.max.x;x+=cubeDim){
var boxOrigins = fillWithElements(x);
_.each(boxOrigins, function(origin){
var mesh = createCubeGeometry(cubeDim);
mesh.position.set(origin[0], origin[1], origin[2]);
mesh.updateMatrix();
mesh.matrixAutoUpdate = false;
three.scene.add(mesh);
});
}
three.render();
function incrCallback(result){
console.log(result);
}
function merge(meshes){
var allMeshes = meshes[1];
for (var i=2;i<meshes.length;i++){
allMeshes.concat(meshes[i]);
}
return allMeshes;
}
function addToScene(arguments){
// console.log("amanda");
// console.log(arguments.length);
// _.each(arguments, function(mesh){
// three.scene.add(mesh);
// });
three.render();
}
function fillWithElements(x){
console.log("here");
var meshesToAdd = [];
var origins = [];
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
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(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();
// mesh.matrixAutoUpdate = false;
// meshesToAdd.push(mesh);
//// global.env.three.scene.add(mesh);
// } else if (numIntersections == 0){
// }
if (numIntersections % 2 == 1){
origins.push([x,y,z]);
} else if (numIntersections == 0){
break;
}
}
}
return x*x;
return origins;
}
});
function createCubeGeometry(size){
console.log(cubeGeo);
var geometry = new THREE.BoxGeometry(size, size, size);
var material = new THREE.MeshLambertMaterial( { color:0xffffff} );
return new THREE.Mesh( geometry, material );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment