更新版本,修复镜像槽问题

This commit is contained in:
FishOrBear
2020-04-30 17:12:30 +08:00
parent d79d759091
commit 85db279fab
12 changed files with 2582 additions and 2218 deletions

View File

@@ -1,9 +1,9 @@
import * as THREE from "three";
import { MathUtils, Vector3 } from "three";
/**
* 轨道控制的数学类,观察向量和角度的互相转换
* 当x当抬头或者低头到90度时,触发万向锁.
*
*
* @class Orbit
*/
export class Orbit
@@ -20,19 +20,19 @@ export class Orbit
}
set RoX(v)
{
this.m_RoX = THREE.Math.clamp(v, Math.PI * -0.5, Math.PI * 0.5);
this.m_RoX = MathUtils.clamp(v, Math.PI * -0.5, Math.PI * 0.5);
}
/**
* 使用旋转角度 计算观察向量
*
* @param {THREE.Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
* @returns {THREE.Vector3} 返回观察向量
*
* @param {Vector3} [dir] 引用传入,如果传入,那么就不构造新的向量
* @returns {Vector3} 返回观察向量
* @memberof Orbit
*/
UpdateDirection(dir?: THREE.Vector3): THREE.Vector3
UpdateDirection(dir?: Vector3): Vector3
{
let rtDir = dir ? dir : new THREE.Vector3();
let rtDir = dir ? dir : new Vector3();
rtDir.z = Math.sin(this.m_RoX);
@@ -47,11 +47,11 @@ export class Orbit
/**
* 使用观察向量,计算旋转角度
*
* @param {THREE.Vector3} dir
*
* @param {Vector3} dir
* @memberof Orbit
*/
UpdateRoValue(dir: THREE.Vector3)
UpdateRoValue(dir: Vector3)
{
dir.normalize();
this.m_RoX = Math.asin(dir.z);
@@ -62,30 +62,30 @@ export class Orbit
}
/**
*
*
* 根据观察向量 求头部的向量.
*
*
* @static
* @param {THREE.Vector3} dir
* @param {THREE.Vector3} [up]
* @returns {THREE.Vector3}
* @param {Vector3} dir
* @param {Vector3} [up]
* @returns {Vector3}
* @memberof Orbit
*/
static ComputUpDirection(dir: THREE.Vector3, up?: THREE.Vector3): THREE.Vector3
static ComputUpDirection(dir: Vector3, up?: Vector3): Vector3
{
let upRes = up ? up : new THREE.Vector3();
if (dir.equals(new THREE.Vector3(0, 0, -1)))
let upRes = up ? up : new Vector3();
if (dir.equals(new Vector3(0, 0, -1)))
{
upRes.set(0, 1, 0);
}
else if (dir.equals(new THREE.Vector3(0, 0, 1)))
else if (dir.equals(new Vector3(0, 0, 1)))
{
upRes.set(0, -1, 0);
}
else
{
let xv = new THREE.Vector3();
xv.crossVectors(new THREE.Vector3(0, 0, 1), dir);
let xv = new Vector3();
xv.crossVectors(new Vector3(0, 0, 1), dir);
upRes.crossVectors(dir, xv);
upRes.normalize();
}