Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
5fd7ee2f
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,发现更多精彩内容 >>
提交
5fd7ee2f
编写于
7月 27, 2011
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Normalized FirstPersonCamera vertical look speed when using vertical look angle constrains.
上级
ae2357a0
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
18 addition
and
9 deletion
+18
-9
build/Three.js
build/Three.js
+4
-4
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+4
-4
src/extras/cameras/FirstPersonCamera.js
src/extras/cameras/FirstPersonCamera.js
+10
-1
未找到文件。
build/Three.js
浏览文件 @
5fd7ee2f
...
...
@@ -396,10 +396,10 @@ void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this
b
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
b
.
button
){
case
0
:
this
.
moveForward
=!
0
;
break
;
case
2
:
this
.
moveBackward
=!
0
}
this
.
mouseDragOn
=!
0
};
this
.
onMouseUp
=
function
(
b
){
b
.
preventDefault
();
b
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
b
.
button
){
case
0
:
this
.
moveForward
=!
1
;
break
;
case
2
:
this
.
moveBackward
=!
1
}
this
.
mouseDragOn
=!
1
};
this
.
onMouseMove
=
function
(
b
){
this
.
mouseX
=
b
.
clientX
-
this
.
windowHalfX
;
this
.
mouseY
=
b
.
clientY
-
this
.
windowHalfY
};
this
.
onKeyDown
=
function
(
b
){
switch
(
b
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
!
0
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
0
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=!
0
;
break
;
case
39
:
case
68
:
this
.
moveRight
=!
0
;
break
;
case
82
:
this
.
moveUp
=!
0
;
break
;
case
70
:
this
.
moveDown
=!
0
;
break
;
case
81
:
this
.
freeze
=!
this
.
freeze
}};
this
.
onKeyUp
=
function
(
b
){
switch
(
b
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=!
1
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
1
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=!
1
;
break
;
case
39
:
case
68
:
this
.
moveRight
=!
1
;
break
;
case
82
:
this
.
moveUp
=!
1
;
break
;
case
70
:
this
.
moveDown
=!
1
}};
this
.
update
=
function
(){
var
b
=
(
new
Date
).
getTime
();
this
.
tdiff
=
(
b
-
this
.
lastUpdate
)
/
1
E3
;
this
.
lastUpdate
=
b
;
if
(
!
this
.
freeze
){
this
.
autoSpeedFactor
=
this
.
heightSpeed
?
this
.
tdiff
*
((
this
.
position
.
y
<
this
.
heightMin
?
this
.
heightMin
:
this
.
position
.
y
>
this
.
heightMax
?
this
.
heightMax
:
this
.
position
.
y
)
-
this
.
heightMin
)
*
this
.
heightCoef
:
0
;
var
c
=
this
.
tdiff
*
this
.
movementSpeed
;(
this
.
moveForward
||
this
.
autoForward
&&!
this
.
moveBackward
)
&&
this
.
translateZ
(
-
(
c
+
this
.
autoSpeedFactor
));
this
.
moveBackward
&&
this
.
translateZ
(
c
);
this
.
moveLeft
&&
this
.
translateX
(
-
c
);
this
.
moveRight
&&
this
.
translateX
(
c
);
this
.
moveUp
&&
this
.
translateY
(
c
);
this
.
moveDown
&&
this
.
translateY
(
-
c
);
c
=
this
.
tdiff
*
this
.
lookSpeed
;
this
.
activeLook
||
(
c
=
0
);
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
b
=
this
.
target
.
position
,
g
=
this
.
position
;
b
.
x
=
g
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
g
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
g
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
)}
this
.
lon
+
=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
(
this
.
phi
-
0
)
*
(
this
.
verticalMax
-
this
.
verticalMin
)
/
3.14
+
this
.
verticalMin
;
b
=
this
.
target
.
position
;
g
=
this
.
position
;
b
.
x
=
g
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
g
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
g
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
supr
.
update
.
call
(
this
)};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
b
){
b
.
preventDefault
()},
!
1
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKeyDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKeyUp
),
!
1
)};
THREE
.
FirstPersonCamera
.
prototype
=
new
THREE
.
Camera
;
THREE
.
FirstPersonCamera
.
prototype
.
constructor
=
THREE
.
FirstPersonCamera
;
THREE
.
FirstPersonCamera
.
prototype
.
supr
=
THREE
.
Camera
.
prototype
;
THREE
.
FirstPersonCamera
.
prototype
.
translate
=
function
(
b
,
c
){
this
.
matrix
.
rotateAxis
(
c
);
if
(
this
.
noFly
)
c
.
y
=
0
;
this
.
position
.
addSelf
(
c
.
multiplyScalar
(
b
));
this
.
target
.
position
.
addSelf
(
c
.
multiplyScalar
(
b
))};
this
.
moveRight
&&
this
.
translateX
(
c
);
this
.
moveUp
&&
this
.
translateY
(
c
);
this
.
moveDown
&&
this
.
translateY
(
-
c
);
c
=
this
.
tdiff
*
this
.
lookSpeed
;
this
.
activeLook
||
(
c
=
0
);
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
b
=
this
.
target
.
position
,
g
=
this
.
position
;
b
.
x
=
g
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
g
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
g
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
)}
b
=
1
;
this
.
constrainVertical
&&
(
b
=
3.14
/
(
this
.
verticalMax
-
this
.
verticalMin
));
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
*
b
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
(
this
.
phi
-
0
)
*
(
this
.
verticalMax
-
this
.
verticalMin
)
/
3.14
+
this
.
verticalMin
;
b
=
this
.
target
.
position
;
g
=
this
.
position
;
b
.
x
=
g
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
b
.
y
=
g
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
b
.
z
=
g
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
supr
.
update
.
call
(
this
)};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
b
){
b
.
preventDefault
()},
!
1
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKeyDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKeyUp
),
!
1
)}
;
THREE
.
FirstPersonCamera
.
prototype
=
new
THREE
.
Camera
;
THREE
.
FirstPersonCamera
.
prototype
.
constructor
=
THREE
.
FirstPersonCamera
;
THREE
.
FirstPersonCamera
.
prototype
.
supr
=
THREE
.
Camera
.
prototype
;
THREE
.
FirstPersonCamera
.
prototype
.
translate
=
function
(
b
,
c
){
this
.
matrix
.
rotateAxis
(
c
);
if
(
this
.
noFly
)
c
.
y
=
0
;
this
.
position
.
addSelf
(
c
.
multiplyScalar
(
b
));
this
.
target
.
position
.
addSelf
(
c
.
multiplyScalar
(
b
))};
THREE
.
PathCamera
=
function
(
b
){
function
c
(
b
,
e
,
c
,
f
){
var
h
=
{
name
:
c
,
fps
:
0.6
,
length
:
f
,
hierarchy
:[]},
g
,
k
=
e
.
getControlPointsArray
(),
m
=
e
.
getLength
(),
o
=
k
.
length
,
H
=
0
;
g
=
o
-
1
;
e
=
{
parent
:
-
1
,
keys
:[]};
e
.
keys
[
0
]
=
{
time
:
0
,
pos
:
k
[
0
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
e
.
keys
[
g
]
=
{
time
:
f
,
pos
:
k
[
g
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
for
(
g
=
1
;
g
<
o
-
1
;
g
++
)
H
=
f
*
m
.
chunks
[
g
]
/
m
.
total
,
e
.
keys
[
g
]
=
{
time
:
H
,
pos
:
k
[
g
]};
h
.
hierarchy
[
0
]
=
e
;
THREE
.
AnimationHandler
.
add
(
h
);
return
new
THREE
.
Animation
(
b
,
c
,
THREE
.
AnimationHandler
.
CATMULLROM_FORWARD
,
!
1
)}
function
e
(
b
,
e
){
var
c
,
f
,
h
=
new
THREE
.
Geometry
;
for
(
c
=
0
;
c
<
b
.
points
.
length
*
e
;
c
++
)
f
=
c
/
(
b
.
points
.
length
*
e
),
f
=
b
.
getPoint
(
f
),
h
.
vertices
[
c
]
=
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
f
.
x
,
f
.
y
,
f
.
z
));
return
h
}
function
f
(
b
,
c
){
var
f
=
e
(
c
,
10
),
h
=
e
(
c
,
10
),
g
=
new
THREE
.
LineBasicMaterial
({
color
:
16711680
,
linewidth
:
3
});
lineObj
=
new
THREE
.
Line
(
f
,
g
);
particleObj
=
new
THREE
.
ParticleSystem
(
h
,
new
THREE
.
ParticleBasicMaterial
({
color
:
16755200
,
size
:
3
}));
lineObj
.
scale
.
set
(
1
,
1
,
1
);
b
.
addChild
(
lineObj
);
particleObj
.
scale
.
set
(
1
,
1
,
1
);
b
.
addChild
(
particleObj
);
h
=
new
THREE
.
SphereGeometry
(
1
,
16
,
8
);
g
=
new
THREE
.
MeshBasicMaterial
({
color
:
65280
});
for
(
i
=
0
;
i
<
c
.
points
.
length
;
i
++
)
f
=
new
THREE
.
Mesh
(
h
,
g
),
f
.
position
.
copy
(
c
.
points
[
i
]),
f
.
updateMatrix
(),
b
.
addChild
(
f
)}
THREE
.
Camera
.
call
(
this
,
b
.
fov
,
b
.
aspect
,
b
.
near
,
b
.
far
,
b
.
target
);
this
.
id
=
"
PathCamera
"
+
THREE
.
PathCameraIdCounter
++
;
this
.
duration
=
1
E4
;
this
.
waypoints
=
[];
this
.
useConstantSpeed
=!
0
;
this
.
resamplingCoef
=
50
;
this
.
debugPath
=
new
THREE
.
Object3D
;
this
.
debugDummy
=
new
THREE
.
Object3D
;
this
.
animationParent
=
new
THREE
.
Object3D
;
this
.
lookSpeed
=
0.0050
;
this
.
lookHorizontal
=
...
...
build/custom/ThreeExtras.js
浏览文件 @
5fd7ee2f
...
...
@@ -40,10 +40,10 @@ void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this
a
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
a
.
button
){
case
0
:
this
.
moveForward
=!
0
;
break
;
case
2
:
this
.
moveBackward
=!
0
}
this
.
mouseDragOn
=!
0
};
this
.
onMouseUp
=
function
(
a
){
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
this
.
activeLook
)
switch
(
a
.
button
){
case
0
:
this
.
moveForward
=!
1
;
break
;
case
2
:
this
.
moveBackward
=!
1
}
this
.
mouseDragOn
=!
1
};
this
.
onMouseMove
=
function
(
a
){
this
.
mouseX
=
a
.
clientX
-
this
.
windowHalfX
;
this
.
mouseY
=
a
.
clientY
-
this
.
windowHalfY
};
this
.
onKeyDown
=
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=
!
0
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
0
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=!
0
;
break
;
case
39
:
case
68
:
this
.
moveRight
=!
0
;
break
;
case
82
:
this
.
moveUp
=!
0
;
break
;
case
70
:
this
.
moveDown
=!
0
;
break
;
case
81
:
this
.
freeze
=!
this
.
freeze
}};
this
.
onKeyUp
=
function
(
a
){
switch
(
a
.
keyCode
){
case
38
:
case
87
:
this
.
moveForward
=!
1
;
break
;
case
37
:
case
65
:
this
.
moveLeft
=!
1
;
break
;
case
40
:
case
83
:
this
.
moveBackward
=!
1
;
break
;
case
39
:
case
68
:
this
.
moveRight
=!
1
;
break
;
case
82
:
this
.
moveUp
=!
1
;
break
;
case
70
:
this
.
moveDown
=!
1
}};
this
.
update
=
function
(){
var
a
=
(
new
Date
).
getTime
();
this
.
tdiff
=
(
a
-
this
.
lastUpdate
)
/
1
E3
;
this
.
lastUpdate
=
a
;
if
(
!
this
.
freeze
){
this
.
autoSpeedFactor
=
this
.
heightSpeed
?
this
.
tdiff
*
((
this
.
position
.
y
<
this
.
heightMin
?
this
.
heightMin
:
this
.
position
.
y
>
this
.
heightMax
?
this
.
heightMax
:
this
.
position
.
y
)
-
this
.
heightMin
)
*
this
.
heightCoef
:
0
;
var
c
=
this
.
tdiff
*
this
.
movementSpeed
;(
this
.
moveForward
||
this
.
autoForward
&&!
this
.
moveBackward
)
&&
this
.
translateZ
(
-
(
c
+
this
.
autoSpeedFactor
));
this
.
moveBackward
&&
this
.
translateZ
(
c
);
this
.
moveLeft
&&
this
.
translateX
(
-
c
);
this
.
moveRight
&&
this
.
translateX
(
c
);
this
.
moveUp
&&
this
.
translateY
(
c
);
this
.
moveDown
&&
this
.
translateY
(
-
c
);
c
=
this
.
tdiff
*
this
.
lookSpeed
;
this
.
activeLook
||
(
c
=
0
);
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
a
=
this
.
target
.
position
,
f
=
this
.
position
;
a
.
x
=
f
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
a
.
y
=
f
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
a
.
z
=
f
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
)}
this
.
lon
+
=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
(
this
.
phi
-
0
)
*
(
this
.
verticalMax
-
this
.
verticalMin
)
/
3.14
+
this
.
verticalMin
;
a
=
this
.
target
.
position
;
f
=
this
.
position
;
a
.
x
=
f
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
a
.
y
=
f
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
a
.
z
=
f
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
supr
.
update
.
call
(
this
)};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
!
1
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKeyDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKeyUp
),
!
1
)};
THREE
.
FirstPersonCamera
.
prototype
=
new
THREE
.
Camera
;
THREE
.
FirstPersonCamera
.
prototype
.
constructor
=
THREE
.
FirstPersonCamera
;
THREE
.
FirstPersonCamera
.
prototype
.
supr
=
THREE
.
Camera
.
prototype
;
THREE
.
FirstPersonCamera
.
prototype
.
translate
=
function
(
a
,
c
){
this
.
matrix
.
rotateAxis
(
c
);
if
(
this
.
noFly
)
c
.
y
=
0
;
this
.
position
.
addSelf
(
c
.
multiplyScalar
(
a
));
this
.
target
.
position
.
addSelf
(
c
.
multiplyScalar
(
a
))};
this
.
moveRight
&&
this
.
translateX
(
c
);
this
.
moveUp
&&
this
.
translateY
(
c
);
this
.
moveDown
&&
this
.
translateY
(
-
c
);
c
=
this
.
tdiff
*
this
.
lookSpeed
;
this
.
activeLook
||
(
c
=
0
);
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
var
a
=
this
.
target
.
position
,
f
=
this
.
position
;
a
.
x
=
f
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
a
.
y
=
f
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
a
.
z
=
f
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
)}
a
=
1
;
this
.
constrainVertical
&&
(
a
=
3.14
/
(
this
.
verticalMax
-
this
.
verticalMin
));
this
.
lon
+=
this
.
mouseX
*
c
;
this
.
lookVertical
&&
(
this
.
lat
-=
this
.
mouseY
*
c
*
a
);
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
));
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
this
.
phi
=
(
this
.
phi
-
0
)
*
(
this
.
verticalMax
-
this
.
verticalMin
)
/
3.14
+
this
.
verticalMin
;
a
=
this
.
target
.
position
;
f
=
this
.
position
;
a
.
x
=
f
.
x
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
cos
(
this
.
theta
);
a
.
y
=
f
.
y
+
100
*
Math
.
cos
(
this
.
phi
);
a
.
z
=
f
.
z
+
100
*
Math
.
sin
(
this
.
phi
)
*
Math
.
sin
(
this
.
theta
);
this
.
supr
.
update
.
call
(
this
)};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
!
1
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
c
(
this
,
this
.
onMouseMove
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
c
(
this
,
this
.
onMouseDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
c
(
this
,
this
.
onMouseUp
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keydown
"
,
c
(
this
,
this
.
onKeyDown
),
!
1
);
this
.
domElement
.
addEventListener
(
"
keyup
"
,
c
(
this
,
this
.
onKeyUp
),
!
1
)}
;
THREE
.
FirstPersonCamera
.
prototype
=
new
THREE
.
Camera
;
THREE
.
FirstPersonCamera
.
prototype
.
constructor
=
THREE
.
FirstPersonCamera
;
THREE
.
FirstPersonCamera
.
prototype
.
supr
=
THREE
.
Camera
.
prototype
;
THREE
.
FirstPersonCamera
.
prototype
.
translate
=
function
(
a
,
c
){
this
.
matrix
.
rotateAxis
(
c
);
if
(
this
.
noFly
)
c
.
y
=
0
;
this
.
position
.
addSelf
(
c
.
multiplyScalar
(
a
));
this
.
target
.
position
.
addSelf
(
c
.
multiplyScalar
(
a
))};
THREE
.
PathCamera
=
function
(
a
){
function
c
(
a
,
b
,
c
,
e
){
var
g
=
{
name
:
c
,
fps
:
0.6
,
length
:
e
,
hierarchy
:[]},
h
,
f
=
b
.
getControlPointsArray
(),
j
=
b
.
getLength
(),
k
=
f
.
length
,
y
=
0
;
h
=
k
-
1
;
b
=
{
parent
:
-
1
,
keys
:[]};
b
.
keys
[
0
]
=
{
time
:
0
,
pos
:
f
[
0
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
b
.
keys
[
h
]
=
{
time
:
e
,
pos
:
f
[
h
],
rot
:[
0
,
0
,
0
,
1
],
scl
:[
1
,
1
,
1
]};
for
(
h
=
1
;
h
<
k
-
1
;
h
++
)
y
=
e
*
j
.
chunks
[
h
]
/
j
.
total
,
b
.
keys
[
h
]
=
{
time
:
y
,
pos
:
f
[
h
]};
g
.
hierarchy
[
0
]
=
b
;
THREE
.
AnimationHandler
.
add
(
g
);
return
new
THREE
.
Animation
(
a
,
c
,
THREE
.
AnimationHandler
.
CATMULLROM_FORWARD
,
!
1
)}
function
b
(
a
,
b
){
var
c
,
e
,
g
=
new
THREE
.
Geometry
;
for
(
c
=
0
;
c
<
a
.
points
.
length
*
b
;
c
++
)
e
=
c
/
(
a
.
points
.
length
*
b
),
e
=
a
.
getPoint
(
e
),
g
.
vertices
[
c
]
=
new
THREE
.
Vertex
(
new
THREE
.
Vector3
(
e
.
x
,
e
.
y
,
e
.
z
));
return
g
}
function
g
(
a
,
c
){
var
e
=
b
(
c
,
10
),
g
=
b
(
c
,
10
),
h
=
new
THREE
.
LineBasicMaterial
({
color
:
16711680
,
linewidth
:
3
});
lineObj
=
new
THREE
.
Line
(
e
,
h
);
particleObj
=
new
THREE
.
ParticleSystem
(
g
,
new
THREE
.
ParticleBasicMaterial
({
color
:
16755200
,
size
:
3
}));
lineObj
.
scale
.
set
(
1
,
1
,
1
);
a
.
addChild
(
lineObj
);
particleObj
.
scale
.
set
(
1
,
1
,
1
);
a
.
addChild
(
particleObj
);
g
=
new
THREE
.
SphereGeometry
(
1
,
16
,
8
);
h
=
new
THREE
.
MeshBasicMaterial
({
color
:
65280
});
for
(
i
=
0
;
i
<
c
.
points
.
length
;
i
++
)
e
=
new
THREE
.
Mesh
(
g
,
h
),
e
.
position
.
copy
(
c
.
points
[
i
]),
e
.
updateMatrix
(),
a
.
addChild
(
e
)}
THREE
.
Camera
.
call
(
this
,
a
.
fov
,
a
.
aspect
,
a
.
near
,
a
.
far
,
a
.
target
);
this
.
id
=
"
PathCamera
"
+
THREE
.
PathCameraIdCounter
++
;
this
.
duration
=
1
E4
;
this
.
waypoints
=
[];
this
.
useConstantSpeed
=!
0
;
this
.
resamplingCoef
=
50
;
this
.
debugPath
=
new
THREE
.
Object3D
;
this
.
debugDummy
=
new
THREE
.
Object3D
;
this
.
animationParent
=
new
THREE
.
Object3D
;
this
.
lookSpeed
=
0.0050
;
this
.
lookHorizontal
=
...
...
src/extras/cameras/FirstPersonCamera.js
浏览文件 @
5fd7ee2f
...
...
@@ -253,11 +253,20 @@ THREE.FirstPersonCamera = function ( parameters ) {
}
var
verticalLookRatio
=
1
;
if
(
this
.
constrainVertical
)
{
verticalLookRatio
=
3.14
/
(
this
.
verticalMax
-
this
.
verticalMin
);
}
this
.
lon
+=
this
.
mouseX
*
actualLookSpeed
;
if
(
this
.
lookVertical
)
this
.
lat
-=
this
.
mouseY
*
actualLookSpeed
;
if
(
this
.
lookVertical
)
this
.
lat
-=
this
.
mouseY
*
actualLookSpeed
*
verticalLookRatio
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
)
);
this
.
phi
=
(
90
-
this
.
lat
)
*
Math
.
PI
/
180
;
this
.
theta
=
this
.
lon
*
Math
.
PI
/
180
;
if
(
this
.
constrainVertical
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录