|
@@ -43229,6 +43229,7 @@
|
|
|
if (count <= 1) {
|
|
|
geo = voidGeometry;
|
|
|
this.geoPoints = [];
|
|
|
+ this.curve = null;
|
|
|
} else {
|
|
|
if (Potree.settings.pathSmooth) {
|
|
|
//使用曲线
|
|
@@ -59318,6 +59319,7 @@
|
|
|
position: 'red',
|
|
|
target: 'blue'
|
|
|
};
|
|
|
+ var lastQuaternion;
|
|
|
var lineMats$1;
|
|
|
var getLineMat = function getLineMat(name) {
|
|
|
if (!lineMats$1) {
|
|
@@ -59578,36 +59580,49 @@
|
|
|
percent = easing.easeOutSine(originPercent-(1-easePercent), 1-easePercent, easePercent, easePercent)
|
|
|
} */
|
|
|
|
|
|
- var quaternion, position;
|
|
|
- if (percent < 1) {
|
|
|
- //修改第二层:使用每个点的重定位的 newPointsPercents
|
|
|
-
|
|
|
- this.currentIndex = this.newPointsPercents.findIndex(e => e > percent) - 1;
|
|
|
- //假设每个节点的百分比是精确的,那么:
|
|
|
- var curIndexPercent = this.newPointsPercents[this.currentIndex];
|
|
|
- var nextIndexPercent = this.newPointsPercents[this.currentIndex + 1];
|
|
|
- var progress = (percent - curIndexPercent) / (nextIndexPercent - curIndexPercent); //在这两个节点间的百分比
|
|
|
-
|
|
|
- //投影到原本的 posCurve.pointsPercent上:
|
|
|
- var curIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex];
|
|
|
- var nextIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex + 1];
|
|
|
- percent = curIndexOriPercent + (nextIndexOriPercent - curIndexOriPercent) * progress;
|
|
|
- var endQuaternion = this.quaternions[this.currentIndex + 1];
|
|
|
- var startQuaternion = this.quaternions[this.currentIndex];
|
|
|
- quaternion = new Quaternion().copy(startQuaternion);
|
|
|
- lerp.quaternion(quaternion, endQuaternion)(progress);
|
|
|
-
|
|
|
- /* let endPos = this.posCurve.points[this.currentIndex+1]
|
|
|
- let startPos = this.posCurve.points[this.currentIndex]
|
|
|
- position = (new THREE.Vector3()).copy(startPos)
|
|
|
- lerp.vector(position, endPos)(progress) */
|
|
|
+ var position = this.posCurve.getPointAt(percent); // 需要this.posCurve.points.length>1 否则报错
|
|
|
+ var quaternion;
|
|
|
+ if (this.quaFromCurveTan) {
|
|
|
+ //沿着curve行走,目视curve前方
|
|
|
+ var percent2 = percent + (this.tangentDt || 0.001);
|
|
|
+ if (percent2 <= 1) {
|
|
|
+ var position2 = this.posCurve.getPointAt(percent2);
|
|
|
+ quaternion = math.getQuaFromPosAim(position, position2);
|
|
|
+ } else {
|
|
|
+ quaternion = lastQuaternion;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.currentIndex = this.posCurve.points.length - 1;
|
|
|
- quaternion = this.quaternions[this.currentIndex];
|
|
|
- position = this.posCurve.points[this.currentIndex];
|
|
|
+ if (percent < 1) {
|
|
|
+ //修改第二层:使用每个点的重定位的 newPointsPercents
|
|
|
+
|
|
|
+ this.currentIndex = this.newPointsPercents.findIndex(e => e > percent) - 1;
|
|
|
+ //假设每个节点的百分比是精确的,那么:
|
|
|
+ var curIndexPercent = this.newPointsPercents[this.currentIndex];
|
|
|
+ var nextIndexPercent = this.newPointsPercents[this.currentIndex + 1];
|
|
|
+ var progress = (percent - curIndexPercent) / (nextIndexPercent - curIndexPercent); //在这两个节点间的百分比
|
|
|
+
|
|
|
+ //投影到原本的 posCurve.pointsPercent上:
|
|
|
+ var curIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex];
|
|
|
+ var nextIndexOriPercent = this.posCurve.pointsPercent[this.currentIndex + 1];
|
|
|
+ percent = curIndexOriPercent + (nextIndexOriPercent - curIndexOriPercent) * progress;
|
|
|
+ var endQuaternion = this.quaternions[this.currentIndex + 1];
|
|
|
+ var startQuaternion = this.quaternions[this.currentIndex];
|
|
|
+ quaternion = new Quaternion().copy(startQuaternion);
|
|
|
+ lerp.quaternion(quaternion, endQuaternion)(progress);
|
|
|
+
|
|
|
+ /* if(this.posInterpolate){
|
|
|
+ let endPos = this.posCurve.points[this.currentIndex+1]
|
|
|
+ let startPos = this.posCurve.points[this.currentIndex]
|
|
|
+ position = (new THREE.Vector3()).copy(startPos)
|
|
|
+ lerp.vector(position, endPos)(progress)
|
|
|
+ } */
|
|
|
+ } else {
|
|
|
+ this.currentIndex = this.posCurve.points.length - 1;
|
|
|
+ quaternion = this.quaternions[this.currentIndex];
|
|
|
+ position = this.posCurve.points[this.currentIndex];
|
|
|
+ }
|
|
|
}
|
|
|
- position = this.posCurve.getPointAt(percent); // 需要this.posCurve.points.length>1 否则报错
|
|
|
-
|
|
|
+ lastQuaternion = quaternion;
|
|
|
//console.log(this.currentIndex, originPercent)
|
|
|
//缓动:
|
|
|
var aimQua, aimPos;
|
|
@@ -59620,8 +59635,8 @@
|
|
|
aimQua = camera.quaternion.clone();
|
|
|
aimPos = camera.position.clone();
|
|
|
}
|
|
|
- transitionRatio = transitionRatio || 1 / Potree.settings.cameraAniSmoothRatio; //渐变系数,越小缓动程度越高,越平滑
|
|
|
- transitionRatio *= delta * 60; //假设标准帧率为60fps,当帧率低时(delta大时)要降低缓动
|
|
|
+ transitionRatio = transitionRatio || 1 / (this.cameraAniSmoothRatio || Potree.settings.cameraAniSmoothRatio); //渐变系数,越小缓动程度越高,越平滑
|
|
|
+ transitionRatio *= delta * 60; //假设标准帧率为60fps,当帧率低时(delta大时) 降低缓动。速度快时缓动太高会偏移路径
|
|
|
//console.log(transitionRatio, delta) //画面ui变化会使delta变大
|
|
|
transitionRatio = MathUtils.clamp(transitionRatio, 0, 1);
|
|
|
lerp.quaternion(aimQua, quaternion)(transitionRatio); //每次只改变一点点
|
|
@@ -59710,7 +59725,7 @@
|
|
|
var frame = this.at(percent, e.delta, transitionRatio);
|
|
|
if (currentIndex != this.currentIndex) {
|
|
|
currentIndex = this.currentIndex;
|
|
|
- console.log('updateCurrentIndex', currentIndex);
|
|
|
+ //console.log('updateCurrentIndex', currentIndex)
|
|
|
this.dispatchEvent({
|
|
|
type: 'updateCurrentIndex',
|
|
|
currentIndex
|
|
@@ -74207,30 +74222,30 @@
|
|
|
class CameraAnimationCurve extends EventDispatcher {
|
|
|
//沿着curve轨迹的相机动画,不指定target,因视线沿着路线
|
|
|
|
|
|
- constructor(curve, points, UtoTMapArr, duration) {
|
|
|
+ constructor(curve, duration, tangentDt) {
|
|
|
+ //直接传入curve得到的points和UtoTMapArr
|
|
|
//简单写
|
|
|
super();
|
|
|
+ this.quaFromCurveTan = true;
|
|
|
this.viewer = viewer;
|
|
|
- this.curve = curve;
|
|
|
+ //this.curve = curve
|
|
|
this.duration = duration;
|
|
|
- this.newPointsPercents = UtoTMapArr.slice();
|
|
|
- this.posCurve = {
|
|
|
- points,
|
|
|
- pointsPercent: this.newPointsPercents,
|
|
|
- getPointAt(t) {
|
|
|
- return curve.getPointAt(t);
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
+ this.cameraAniSmoothRatio = 5; //缓动系数设置小点,尽量贴合路径,尤其速度快时
|
|
|
+ //this.newPointsPercents = UtoTMapArr.slice()
|
|
|
+ //this.posInterpolate = true //不直接在curve上取点,因为UtoTMapArr也是getUtoTmapping得来的, curve上getUtoTmapping后和这个不对应。否则要再算一遍pointsPercent
|
|
|
+
|
|
|
+ /* this.posCurve = { points getPointAt(t){
|
|
|
+ return curve.getPointAt(t)
|
|
|
+ } } */
|
|
|
+ this.posCurve = curve;
|
|
|
//每个点直接朝向前面那个点
|
|
|
- this.quaternions = [];
|
|
|
- var quaternion,
|
|
|
- length = points.length;
|
|
|
- for (var i = 0; i < length - 1; i++) {
|
|
|
- quaternion = math.getQuaFromPosAim(points[i], points[i + 1]);
|
|
|
- this.quaternions.push(quaternion);
|
|
|
+ /* this.quaternions = []
|
|
|
+ let quaternion, length = points.length
|
|
|
+ for(let i=0; i<length-1; i++){
|
|
|
+ quaternion = math.getQuaFromPosAim( points[i], points[i+1])
|
|
|
+ this.quaternions.push(quaternion)
|
|
|
}
|
|
|
- this.quaternions.push(quaternion); //最后一个点的朝向和前一个相同即可
|
|
|
+ this.quaternions.push(quaternion)//最后一个点的朝向和前一个相同即可 */
|
|
|
}
|
|
|
setVisible() {}
|
|
|
updateFrustum() {}
|
|
@@ -74445,8 +74460,8 @@
|
|
|
};
|
|
|
return result;
|
|
|
},
|
|
|
- createCurveAni(curve, points, UtoTMapArr, duration) {
|
|
|
- var ani = new CameraAnimationCurve(curve, points, UtoTMapArr, duration);
|
|
|
+ createCurveAni(curve, duration, tangentDt) {
|
|
|
+ var ani = new CameraAnimationCurve(curve, duration, tangentDt);
|
|
|
return ani;
|
|
|
}
|
|
|
};
|