Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
f4a08e57
T
three.js
项目概览
Ablesons
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f4a08e57
编写于
5月 29, 2011
作者:
E
Eberhard Gräther
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added minMaxDistances to TrackballCamera and some refactorings
上级
6d08b498
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
55 addition
and
23 deletion
+55
-23
src/extras/cameras/TrackballCamera.js
src/extras/cameras/TrackballCamera.js
+55
-23
未找到文件。
src/extras/cameras/TrackballCamera.js
浏览文件 @
f4a08e57
/**
* @author Eberhard Gr
ä
ther / http://egraether.com/
* @author Eberhard Gr
ae
ther / http://egraether.com/
* parameters = {
* fov: <float>,
...
...
@@ -11,6 +11,7 @@
* radius: <float>,
* screen: { width : <float>, height : <float>, offsetLeft : <float>, offsetTop : <float> },
* rotateSpeed: <float>,
* zoomSpeed: <float>,
* panSpeed: <float>,
...
...
@@ -20,6 +21,9 @@
* staticMoving: <bool>,
* dynamicDampingFactor: <float>,
* minDistance: <float>,
* maxDistance: <float>,
* keys: <Array>, // [ rotateKey, zoomKey, panKey ],
* domElement: <HTMLElement>,
...
...
@@ -39,6 +43,7 @@ THREE.TrackballCamera = function ( parameters ) {
this
.
screen
=
parameters
.
screen
||
{
width
:
window
.
innerWidth
,
height
:
window
.
innerHeight
,
offsetLeft
:
0
,
offsetTop
:
0
};
this
.
radius
=
parameters
.
radius
||
(
this
.
screen
.
width
+
this
.
screen
.
height
)
/
4
;
this
.
rotateSpeed
=
parameters
.
rotateSpeed
||
1.0
;
this
.
zoomSpeed
=
parameters
.
zoomSpeed
||
1.2
;
this
.
panSpeed
=
parameters
.
panSpeed
||
0.3
;
...
...
@@ -48,7 +53,10 @@ THREE.TrackballCamera = function ( parameters ) {
this
.
staticMoving
=
parameters
.
staticMoving
||
false
;
this
.
dynamicDampingFactor
=
parameters
.
dynamicDampingFactor
||
0.2
;
this
.
keys
=
parameters
.
keys
||
[
65
/*A*/
,
83
/*S*/
,
68
/*D*/
];
this
.
minDistance
=
parameters
.
minDistance
||
0
;
this
.
maxDistance
=
parameters
.
maxDistance
||
Infinity
;
this
.
keys
=
parameters
.
keys
||
[
16
/*SHIFT*/
,
18
/*ALT*/
,
17
/*CTRL*/
];
this
.
useTarget
=
true
;
...
...
@@ -126,15 +134,21 @@ THREE.TrackballCamera = function ( parameters ) {
var
axis
=
(
new
THREE
.
Vector3
()).
cross
(
_rotateStart
,
_rotateEnd
).
normalize
(),
quaternion
=
new
THREE
.
Quaternion
();
angle
*=
this
.
rotateSpeed
;
quaternion
.
setFromAxisAngle
(
axis
,
-
angle
);
quaternion
.
multiplyVector3
(
this
.
position
);
quaternion
.
multiplyVector3
(
this
.
up
);
if
(
!
this
.
staticMoving
)
{
quaternion
.
multiplyVector3
(
_rotateEnd
);
if
(
this
.
staticMoving
)
{
_rotateStart
=
_rotateEnd
;
}
else
{
quaternion
.
setFromAxisAngle
(
axis
,
angle
*
(
this
.
dynamicDampingFactor
-
1.0
)
);
quaternion
.
multiplyVector3
(
_rotateStart
);
...
...
@@ -197,14 +211,32 @@ THREE.TrackballCamera = function ( parameters ) {
};
this
.
update
=
function
(
parentMatrixWorld
,
forceUpdate
,
camera
)
{
this
.
checkDistances
=
function
(
)
{
if
(
!
this
.
staticMoving
)
{
if
(
!
this
.
noZoom
||
!
this
.
noPan
)
{
this
.
rotateCamera
();
if
(
this
.
position
.
lengthSq
()
>
this
.
maxDistance
*
this
.
maxDistance
)
{
this
.
position
.
setLength
(
this
.
maxDistance
);
}
var
eye
=
this
.
position
.
clone
().
subSelf
(
this
.
target
.
position
);
if
(
eye
.
lengthSq
()
<
this
.
minDistance
*
this
.
minDistance
)
{
this
.
position
.
add
(
this
.
target
.
position
,
eye
.
setLength
(
this
.
minDistance
)
);
}
}
};
this
.
update
=
function
(
parentMatrixWorld
,
forceUpdate
,
camera
)
{
this
.
rotateCamera
();
if
(
!
this
.
noZoom
)
{
this
.
zoomCamera
();
...
...
@@ -217,10 +249,13 @@ THREE.TrackballCamera = function ( parameters ) {
}
this
.
checkDistances
();
this
.
supr
.
update
.
call
(
this
,
parentMatrixWorld
,
forceUpdate
,
camera
);
};
// listeners
function
keydown
(
event
)
{
...
...
@@ -232,16 +267,19 @@ THREE.TrackballCamera = function ( parameters ) {
}
else
if
(
event
.
keyCode
===
this
.
keys
[
this
.
STATE
.
ROTATE
]
)
{
_state
=
this
.
STATE
.
ROTATE
;
_keyPressed
=
true
;
}
else
if
(
event
.
keyCode
===
this
.
keys
[
this
.
STATE
.
ZOOM
]
)
{
}
else
if
(
event
.
keyCode
===
this
.
keys
[
this
.
STATE
.
ZOOM
]
&&
!
this
.
noZoom
)
{
_state
=
this
.
STATE
.
ZOOM
;
_keyPressed
=
true
;
}
else
if
(
event
.
keyCode
===
this
.
keys
[
this
.
STATE
.
PAN
]
)
{
}
else
if
(
event
.
keyCode
===
this
.
keys
[
this
.
STATE
.
PAN
]
&&
!
this
.
noPan
)
{
_state
=
this
.
STATE
.
PAN
;
}
if
(
_state
!==
this
.
STATE
.
NONE
)
{
_keyPressed
=
true
;
}
...
...
@@ -271,11 +309,11 @@ THREE.TrackballCamera = function ( parameters ) {
_rotateStart
=
_rotateEnd
=
this
.
getMouseProjectionOnBall
(
event
.
clientX
,
event
.
clientY
);
}
else
if
(
_state
===
this
.
STATE
.
ZOOM
)
{
}
else
if
(
_state
===
this
.
STATE
.
ZOOM
&&
!
this
.
noZoom
)
{
_zoomStart
=
_zoomEnd
=
this
.
getMouseOnScreen
(
event
.
clientX
,
event
.
clientY
);
}
else
{
}
else
if
(
!
this
.
noPan
)
{
_panStart
=
_panEnd
=
this
.
getMouseOnScreen
(
event
.
clientX
,
event
.
clientY
);
...
...
@@ -305,12 +343,6 @@ THREE.TrackballCamera = function ( parameters ) {
_rotateEnd
=
this
.
getMouseProjectionOnBall
(
event
.
clientX
,
event
.
clientY
);
if
(
this
.
staticMoving
)
{
this
.
rotateCamera
();
}
}
else
if
(
_state
===
this
.
STATE
.
ZOOM
&&
!
this
.
noZoom
)
{
_zoomEnd
=
this
.
getMouseOnScreen
(
event
.
clientX
,
event
.
clientY
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录