Update DrawSession.ts (#762)

This commit is contained in:
Steve Ruiz 2022-06-27 16:04:38 +01:00 committed by GitHub
parent ff471e0d6d
commit 0d3bfd4eeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,13 +30,20 @@ export class DrawSession extends BaseSession {
this.isExtending = initialPoints.length > 0
const newPoints: number[][] = []
if (this.isExtending) {
const prevPoint = initialPoints[initialPoints.length - 1]
newPoints.push(prevPoint, prevPoint)
// Continuing with shift
const len = Math.ceil(Vec.dist(prevPoint, currentPoint) / 16)
for (let i = 0; i < len; i++) {
const t = i / (len - 1)
newPoints.push(Vec.lrp(prevPoint, currentPoint, t).concat(prevPoint[2]))
const prevPoint = initialPoints[initialPoints.length - 1]
if (prevPoint) {
newPoints.push(prevPoint, prevPoint)
const len = Math.floor(Vec.dist(prevPoint, currentPoint) / 16)
if (len > 1) {
for (let i = 0; i < len; i++) {
const t = i / (len - 1)
newPoints.push(Vec.lrp(prevPoint, currentPoint, t).concat(prevPoint[2]))
}
} else {
newPoints.push(currentPoint, currentPoint)
}
}
} else {
newPoints.push(currentPoint)