experiment with buckets object instead of array to handle negative z. avoid mutating output points in renderer
This commit is contained in:
parent
cda3dbd914
commit
54b9889ffa
3 changed files with 37 additions and 30 deletions
|
|
@ -125,17 +125,23 @@ class Slicer {
|
|||
* to reduce the search space in complex models
|
||||
*/
|
||||
computeBuckets() {
|
||||
let bounds = this.bounds;
|
||||
let zSum = this.zSum;
|
||||
let zMax = this.bounds.max.z;
|
||||
let points = this.points;
|
||||
let bucketCount = Math.max(1, Math.ceil(zMax / (zSum / points.length)) - 1);
|
||||
let zScale = this.zScale = 1 / (zMax / bucketCount);
|
||||
let buckets = this.buckets = [];
|
||||
if (bucketCount > 1 && !this.options.nobucket) {
|
||||
let buckets = this.buckets = {};
|
||||
if (bucketCount > 1) {// && !this.options.nobucket) {
|
||||
// create empty buckets
|
||||
for (let i = 0; i <= bucketCount + 1; i++) {
|
||||
buckets.push([]);
|
||||
let min = Math.floor(bounds.min.z * zScale);
|
||||
let max = Math.ceil(bounds.max.z * zScale);
|
||||
for (let i = min; i <= max; i++) {
|
||||
buckets[i] = [];
|
||||
}
|
||||
// for (let i = 0; i <= bucketCount + 1; i++) {
|
||||
// buckets.push([]);
|
||||
// }
|
||||
|
||||
// copy triples into all matching z-buckets
|
||||
for (let i = 0, il = points.length; i < il; ) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue