Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
796363ca
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,发现更多精彩内容 >>
提交
796363ca
编写于
3月 04, 2014
作者:
W
WestLangley
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Set Camera.up as the orbit axis in OrbitControls
上级
7c114628
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
59 addition
and
8 deletion
+59
-8
docs/api/math/Quaternion.html
docs/api/math/Quaternion.html
+11
-4
examples/js/controls/OrbitControls.js
examples/js/controls/OrbitControls.js
+15
-1
examples/js/controls/TrackballControls.js
examples/js/controls/TrackballControls.js
+6
-1
src/math/Quaternion.js
src/math/Quaternion.js
+27
-2
未找到文件。
docs/api/math/Quaternion.html
浏览文件 @
796363ca
...
...
@@ -57,24 +57,31 @@
Copies values of *q* to this quaternion.
</div>
<h3>
.setFromEuler( [page:
Vector3 vecto
r] ) [page:Quaternion]
</h3>
<h3>
.setFromEuler( [page:
Euler eule
r] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation specified by Euler angle
s
.
Sets this quaternion from rotation specified by Euler angle.
</div>
<h3>
.setFromAxisAngle( [page:Vector3 axis], [page:Float angle] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation specified by axis and angle.
<br
/>
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm].
<br
/>
*Axis*
have
to be normalized, *angle* is in radians.
*Axis*
is asumed
to be normalized, *angle* is in radians.
</div>
<h3>
.setFromRotationMatrix( [page:Matrix4 m] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion from rotation component of *m*.
Sets this quaternion from rotation component of *m*.
<br
/>
Adapted from [link:http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm].
</div>
<h3>
.setFromUnitVectors( [page:Vector3 vFrom], [page:Vector3 vTo] ) [page:Quaternion]
</h3>
<div>
Sets this quaternion to the rotation required to rotate direction vector *vFrom* to direction vector *vTo*.
<br
/>
Adapted from [link:http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors].
<br
/>
*vFrom* and *vTo* are assumed to be normalized.
</div>
<h3>
.inverse() [page:Quaternion]
</h3>
<div>
Inverts this quaternion.
...
...
examples/js/controls/OrbitControls.js
浏览文件 @
796363ca
...
...
@@ -108,6 +108,11 @@ THREE.OrbitControls = function ( object, domElement ) {
this
.
target0
=
this
.
target
.
clone
();
this
.
position0
=
this
.
object
.
position
.
clone
();
// so camera.up is the orbit axis
var
quat
=
new
THREE
.
Quaternion
().
setFromUnitVectors
(
object
.
up
,
new
THREE
.
Vector3
(
0
,
1
,
0
)
);
var
quatInverse
=
quat
.
clone
().
inverse
();
// events
var
changeEvent
=
{
type
:
'
change
'
};
...
...
@@ -229,6 +234,9 @@ THREE.OrbitControls = function ( object, domElement ) {
offset
.
copy
(
position
).
sub
(
this
.
target
);
// rotate offset to "y-axis-is-up" space
offset
.
applyQuaternion
(
quat
);
// angle from z-axis around y-axis
var
theta
=
Math
.
atan2
(
offset
.
x
,
offset
.
z
);
...
...
@@ -264,6 +272,9 @@ THREE.OrbitControls = function ( object, domElement ) {
offset
.
y
=
radius
*
Math
.
cos
(
phi
);
offset
.
z
=
radius
*
Math
.
sin
(
phi
)
*
Math
.
cos
(
theta
);
// rotate offset back to "camera-up-vector-is-up" space
offset
.
applyQuaternion
(
quatInverse
);
position
.
copy
(
this
.
target
).
add
(
offset
);
this
.
object
.
lookAt
(
this
.
target
);
...
...
@@ -273,7 +284,7 @@ THREE.OrbitControls = function ( object, domElement ) {
scale
=
1
;
pan
.
set
(
0
,
0
,
0
);
if
(
lastPosition
.
distanceTo
(
this
.
object
.
position
)
>
EPS
)
{
if
(
lastPosition
.
distanceTo
Squared
(
this
.
object
.
position
)
>
EPS
)
{
this
.
dispatchEvent
(
changeEvent
);
...
...
@@ -620,6 +631,9 @@ THREE.OrbitControls = function ( object, domElement ) {
window
.
addEventListener
(
'
keydown
'
,
onKeyDown
,
false
);
// force an update at start
this
.
update
();
};
THREE
.
OrbitControls
.
prototype
=
Object
.
create
(
THREE
.
EventDispatcher
.
prototype
);
examples/js/controls/TrackballControls.js
浏览文件 @
796363ca
...
...
@@ -38,6 +38,8 @@ THREE.TrackballControls = function ( object, domElement ) {
this
.
target
=
new
THREE
.
Vector3
();
var
EPS
=
0.000001
;
var
lastPosition
=
new
THREE
.
Vector3
();
var
_state
=
STATE
.
NONE
,
...
...
@@ -315,7 +317,7 @@ THREE.TrackballControls = function ( object, domElement ) {
_this
.
object
.
lookAt
(
_this
.
target
);
if
(
lastPosition
.
distanceToSquared
(
_this
.
object
.
position
)
>
0
)
{
if
(
lastPosition
.
distanceToSquared
(
_this
.
object
.
position
)
>
EPS
)
{
_this
.
dispatchEvent
(
changeEvent
);
...
...
@@ -587,6 +589,9 @@ THREE.TrackballControls = function ( object, domElement ) {
this
.
handleResize
();
// force an update at start
this
.
update
();
};
THREE
.
TrackballControls
.
prototype
=
Object
.
create
(
THREE
.
EventDispatcher
.
prototype
);
src/math/Quaternion.js
浏览文件 @
796363ca
...
...
@@ -180,8 +180,9 @@ THREE.Quaternion.prototype = {
setFromAxisAngle
:
function
(
axis
,
angle
)
{
// from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
// axis have to be normalized
// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
// assumes axis is normalized
var
halfAngle
=
angle
/
2
,
s
=
Math
.
sin
(
halfAngle
);
...
...
@@ -255,6 +256,30 @@ THREE.Quaternion.prototype = {
},
setFromUnitVectors
:
function
()
{
// http://lolengine.net/blog/2013/09/18/beautiful-maths-quaternion-from-vectors
// assumes direction vectors vFrom and vTo are normalized
var
v1
;
return
function
(
vFrom
,
vTo
)
{
if
(
v1
===
undefined
)
v1
=
new
THREE
.
Vector3
();
v1
.
crossVectors
(
vFrom
,
vTo
);
this
.
set
(
v1
.
x
,
v1
.
y
,
v1
.
z
,
vFrom
.
dot
(
vTo
)
+
1
).
normalize
();
this
.
_updateEuler
();
return
this
;
}
}(),
inverse
:
function
()
{
this
.
conjugate
().
normalize
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录