Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
24511738
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,发现更多精彩内容 >>
未验证
提交
24511738
编写于
1月 28, 2019
作者:
M
Mr.doob
提交者:
GitHub
1月 28, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15650 from Mugen87/dev26
FirstPersonControls: Added .lookAt()
上级
ee696d18
6c337ef4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
69 addition
and
32 deletion
+69
-32
examples/js/controls/FirstPersonControls.js
examples/js/controls/FirstPersonControls.js
+50
-8
examples/webgl_nearestneighbour.html
examples/webgl_nearestneighbour.html
+3
-0
examples/webgl_shadowmap.html
examples/webgl_shadowmap.html
+8
-12
examples/webgl_shadowmap_performance.html
examples/webgl_shadowmap_performance.html
+8
-12
未找到文件。
examples/js/controls/FirstPersonControls.js
浏览文件 @
24511738
...
...
@@ -34,9 +34,6 @@ THREE.FirstPersonControls = function ( object, domElement ) {
this
.
mouseX
=
0
;
this
.
mouseY
=
0
;
this
.
lat
=
0
;
this
.
lon
=
0
;
this
.
moveForward
=
false
;
this
.
moveBackward
=
false
;
this
.
moveLeft
=
false
;
...
...
@@ -47,6 +44,17 @@ THREE.FirstPersonControls = function ( object, domElement ) {
this
.
viewHalfX
=
0
;
this
.
viewHalfY
=
0
;
// private variables
var
lat
=
0
;
var
lon
=
0
;
var
lookDirection
=
new
THREE
.
Vector3
();
var
spherical
=
new
THREE
.
Spherical
();
var
target
=
new
THREE
.
Vector3
();
//
if
(
this
.
domElement
!==
document
)
{
this
.
domElement
.
setAttribute
(
'
tabindex
'
,
-
1
);
...
...
@@ -181,6 +189,26 @@ THREE.FirstPersonControls = function ( object, domElement ) {
};
this
.
lookAt
=
function
(
x
,
y
,
z
)
{
if
(
x
.
isVector3
)
{
target
.
copy
(
x
);
}
else
{
target
.
set
(
x
,
y
,
z
);
}
this
.
object
.
lookAt
(
target
);
setOrientation
(
this
);
return
this
;
};
this
.
update
=
function
()
{
var
targetPosition
=
new
THREE
.
Vector3
();
...
...
@@ -229,13 +257,13 @@ THREE.FirstPersonControls = function ( object, domElement ) {
}
this
.
lon
-=
this
.
mouseX
*
actualLookSpeed
;
if
(
this
.
lookVertical
)
this
.
lat
-=
this
.
mouseY
*
actualLookSpeed
*
verticalLookRatio
;
lon
-=
this
.
mouseX
*
actualLookSpeed
;
if
(
this
.
lookVertical
)
lat
-=
this
.
mouseY
*
actualLookSpeed
*
verticalLookRatio
;
this
.
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
this
.
lat
)
);
lat
=
Math
.
max
(
-
85
,
Math
.
min
(
85
,
lat
)
);
var
phi
=
THREE
.
Math
.
degToRad
(
90
-
this
.
lat
);
var
theta
=
THREE
.
Math
.
degToRad
(
this
.
lon
);
var
phi
=
THREE
.
Math
.
degToRad
(
90
-
lat
);
var
theta
=
THREE
.
Math
.
degToRad
(
lon
);
if
(
this
.
constrainVertical
)
{
...
...
@@ -295,6 +323,20 @@ THREE.FirstPersonControls = function ( object, domElement ) {
}
function
setOrientation
(
controls
)
{
var
quaternion
=
controls
.
object
.
quaternion
;
lookDirection
.
set
(
0
,
0
,
-
1
).
applyQuaternion
(
quaternion
);
spherical
.
setFromVector3
(
lookDirection
);
lat
=
90
-
THREE
.
Math
.
radToDeg
(
spherical
.
phi
);
lon
=
THREE
.
Math
.
radToDeg
(
spherical
.
theta
);
}
this
.
handleResize
();
setOrientation
(
this
);
};
examples/webgl_nearestneighbour.html
浏览文件 @
24511738
...
...
@@ -90,6 +90,9 @@
controls
.
movementSpeed
=
100
;
controls
.
lookSpeed
=
0.1
;
controls
.
lookAt
(
500
,
500
,
500
);
// add a skybox background
var
cubeTextureLoader
=
new
THREE
.
CubeTextureLoader
();
...
...
examples/webgl_shadowmap.html
浏览文件 @
24511738
...
...
@@ -85,29 +85,25 @@
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
//
SCENE
CAMERA
// CAMERA
camera
=
new
THREE
.
PerspectiveCamera
(
23
,
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
NEAR
,
FAR
);
camera
.
position
.
set
(
700
,
50
,
1900
);
// SCENE
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x59472b
);
scene
.
fog
=
new
THREE
.
Fog
(
0x59472b
,
1000
,
FAR
);
controls
=
new
THREE
.
FirstPersonControls
(
camera
);
controls
.
lookSpeed
=
0.0125
;
controls
.
movementSpeed
=
500
;
controls
.
noFly
=
false
;
controls
.
lookVertical
=
true
;
controls
.
constrainVertical
=
true
;
controls
.
verticalMin
=
1.5
;
controls
.
verticalMax
=
2.0
;
controls
.
lon
=
250
;
controls
.
lat
=
30
;
// SCENE
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x59472b
);
scene
.
fog
=
new
THREE
.
Fog
(
0x59472b
,
1000
,
FAR
);
controls
.
lookAt
(
scene
.
position
);
// LIGHTS
...
...
examples/webgl_shadowmap_performance.html
浏览文件 @
24511738
...
...
@@ -81,29 +81,25 @@
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
//
SCENE
CAMERA
// CAMERA
camera
=
new
THREE
.
PerspectiveCamera
(
23
,
SCREEN_WIDTH
/
SCREEN_HEIGHT
,
NEAR
,
FAR
);
camera
.
position
.
set
(
700
,
50
,
1900
);
// SCENE
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x59472b
);
scene
.
fog
=
new
THREE
.
Fog
(
0x59472b
,
1000
,
FAR
);
controls
=
new
THREE
.
FirstPersonControls
(
camera
);
controls
.
lookSpeed
=
0.0125
;
controls
.
movementSpeed
=
500
;
controls
.
noFly
=
false
;
controls
.
lookVertical
=
true
;
controls
.
constrainVertical
=
true
;
controls
.
verticalMin
=
1.5
;
controls
.
verticalMax
=
2.0
;
controls
.
lon
=
250
;
controls
.
lat
=
30
;
// SCENE
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x59472b
);
scene
.
fog
=
new
THREE
.
Fog
(
0x59472b
,
1000
,
FAR
);
controls
.
lookAt
(
scene
.
position
);
// LIGHTS
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录