speed up true shadow
This commit is contained in:
parent
3f1126c7b2
commit
e300978bef
3 changed files with 8 additions and 3 deletions
|
|
@ -183,6 +183,7 @@
|
|||
top: 0, // z top
|
||||
mirror: false
|
||||
},
|
||||
this.cache = {};
|
||||
this.stats = {
|
||||
slice_time: 0,
|
||||
load_time: 0,
|
||||
|
|
|
|||
|
|
@ -1133,8 +1133,9 @@
|
|||
tzindex = [ tzindex.pop() ];
|
||||
}
|
||||
|
||||
let lsz; // only shadow up to bottom of last shadow for progressive union
|
||||
let terrain = slicer.slice(tzindex, { each: (data, index, total) => {
|
||||
let shadowAt = trueShadow ? CAM.shadowAt(widget, data.z) : [];
|
||||
let shadowAt = trueShadow ? CAM.shadowAt(widget, data.z, lsz) : [];
|
||||
tshadow = POLY.union(tshadow.slice().appendAll(data.tops).appendAll(shadowAt), 0.01, true);
|
||||
tslices.push(data.slice);
|
||||
if (false) {
|
||||
|
|
@ -1159,6 +1160,7 @@
|
|||
// .setLayer("lines2", {line: 0x444488, thin: true })
|
||||
// .addLines(p2, { thin: true });
|
||||
}
|
||||
lsz = data.z;
|
||||
progress(index / total);
|
||||
}, genso: true });
|
||||
|
||||
|
|
@ -1175,8 +1177,9 @@
|
|||
}
|
||||
|
||||
CAM.shadowAt = function(widget, z, ztop) {
|
||||
let geo = new THREE.BufferGeometry();
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(widget.vertices, 3));
|
||||
let geo = widget.cache.geo || new THREE.BufferGeometry()
|
||||
.setAttribute('position', new THREE.BufferAttribute(widget.vertices, 3));
|
||||
widget.cache.geo = geo;
|
||||
let rad = (Math.PI / 180);
|
||||
let deg = (180 / Math.PI);
|
||||
let angle = rad * 1;
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@
|
|||
};
|
||||
|
||||
let opList = [
|
||||
// silently preface op list with OpShadow
|
||||
new CAM.OPS.shadow(state, { type: "shadow" })
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue