3D Part Preview added to Parts Tracker


RE: 3D Part Preview added to Parts Tracker
#33
(2019-07-16, 13:50)Orion Pobursky Wrote: I think what is wanted is the colors for all the quads/tri/and subparts in the top level file to be randomized.

The following should cover that scenario:

Code:
// Half-Harlequin-mode:       var acceptedColors = [1, 2, 4, 5, 13, 14, 19, 22, 25, 27, 69, 71, 72, 73, 74, 77, 288, 308, 484];       THREE.LDRStep.prototype.addSubModel = function(subModel) {         subModel.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)];         this.subModels.push(subModel);       }       LDR.LDRGeometry.prototype.fromPartType = function(loader, pt) { loader.getMainModel().IS_MAIN_MODEL = true;         let geometries = [];         if(pt.steps.length === 0) {           console.warn("No steps in " + pt.ID);           return; // Empty - just make empty.         }         if(pt.IS_MAIN_MODEL) { // Harlequin the triangles and quads:           pt.steps.forEach(step => {             step.quads.forEach(quad => quad.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);             step.triangles.forEach(triangle => triangle.colorID = acceptedColors[Math.floor(Math.random() * acceptedColors.length)]);           });         }         pt.steps.forEach(step => {             let g = new LDR.LDRGeometry();             g.fromStep(loader, step);             geometries.push(g);         });         this.replaceWith(LDR.mergeGeometries(geometries));       }

It took me a bit longer to come up with this solution that I would like to admit! Big Grin
Reply
« Next Oldest | Next Newest »



Messages In This Thread
RE: 3D Part Preview added to Parts Tracker - by Lasse Deleuran - 2019-07-18, 6:42

Forum Jump:


Users browsing this thread: 1 Guest(s)