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

low poly part

parent a916e0c3
Branches
No related tags found
No related merge requests found
No preview for this file type
......@@ -167,6 +167,9 @@ DMACell.prototype._initParts = function(){
return [];//override in subclasses
};
DMACell.prototype.changePartType = function(){//override in subclasses
};
DMACell.prototype.removePart = function(index){
this.parts[index].destroy();
this.parts[index] = null;
......
......@@ -156,7 +156,22 @@ function DMARotatedEdgeCell(indices, scale, cellMode, partType){
DMARotatedEdgeCell.prototype = Object.create(DMACell.prototype);
DMARotatedEdgeCell.prototype._initParts = function(){
return [new DMAEdgeVoxPart(0, this)];
return this.changePartType(dmaGlobals.lattice.get("partType"));
};
DMARotatedEdgeCell.prototype.changePartType = function(type){
var newParts = [];
if (type == "vox"){
newParts.push(new DMAEdgeVoxPart(0, this));
} else if (type == "voxLowPoly"){
newParts.push(new DMAEdgeVoxPartLowPoly(0, this));
} else {
console.warn("part type not recognized");
return;
}
if (!this.parts) return newParts;
this.destroyParts();
this.parts = newParts;
};
DMARotatedEdgeCell.prototype._doMeshTransformations = function(mesh){
......
......@@ -180,6 +180,36 @@ var partMaterial = new THREE.MeshLambertMaterial({ color:0xffffff, shading: THRE
})();
(function () {
var unitPartGeo;
//import part geometry
var loader = new THREE.STLLoader();
loader.load("assets/stls/parts/edgeVoxPartLowPoly.stl", function(geometry){
unitPartGeo = geometry;
unitPartGeo.computeBoundingBox();
var unitScale = 0.706/unitPartGeo.boundingBox.max.y;
unitPartGeo.applyMatrix(new THREE.Matrix4().makeScale(unitScale, unitScale, unitScale));
});
function DMAEdgeVoxPartLowPoly(type, parent){
DMAPart.call(this, type, parent);
}
DMAEdgeVoxPartLowPoly.prototype = Object.create(DMAPart.prototype);
DMAEdgeVoxPartLowPoly.prototype._makeMeshForType = function(){
var mesh = new THREE.Mesh(unitPartGeo, partMaterial);
mesh.myPart = this;//need a ref back to this part
return mesh;
};
self.DMAEdgeVoxPartLowPoly = DMAEdgeVoxPartLowPoly;
})();
(function () {
var unitPartGeo;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment