Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
eeae90e1
T
three.js
项目概览
车家大少爷
/
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,发现更多精彩内容 >>
提交
eeae90e1
编写于
3月 11, 2017
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Quaternion: Removed bi-directionality.
上级
d91bfaad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
129 addition
and
238 deletion
+129
-238
src/core/Object3D.js
src/core/Object3D.js
+4
-10
src/math/Euler.js
src/math/Euler.js
+10
-10
src/math/Quaternion.js
src/math/Quaternion.js
+115
-218
未找到文件。
src/core/Object3D.js
浏览文件 @
eeae90e1
...
...
@@ -32,24 +32,18 @@ function Object3D() {
this
.
up
=
Object3D
.
DefaultUp
.
clone
();
var
position
=
new
Vector3
();
var
rotation
=
new
Euler
();
var
quaternion
=
new
Quaternion
();
var
scale
=
new
Vector3
(
1
,
1
,
1
);
function
onRotationChange
()
{
quaternion
.
setFromEuler
(
rotation
,
false
);
}
var
rotation
=
new
Euler
();
function
on
Quatern
ionChange
()
{
function
on
Rotat
ionChange
()
{
rotation
.
setFromQuaternion
(
quaternion
,
undefined
,
false
);
quaternion
.
setFromEuler
(
rotation
);
}
rotation
.
onChange
(
onRotationChange
);
quaternion
.
onChange
(
onQuaternionChange
);
Object
.
defineProperties
(
this
,
{
position
:
{
...
...
@@ -123,7 +117,7 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, {
setRotationFromEuler
:
function
(
euler
)
{
this
.
quaternion
.
setFromEuler
(
euler
,
true
);
this
.
quaternion
.
setFromEuler
(
euler
);
},
...
...
src/math/Euler.js
浏览文件 @
eeae90e1
import
{
Quaternion
}
from
'
./Quaternion
'
;
import
{
Vector3
}
from
'
./Vector3
'
;
import
{
Matrix4
}
from
'
./Matrix4
'
;
import
{
_Math
}
from
'
./Math
'
;
/**
* @author mrdoob / http://mrdoob.com/
* @author WestLangley / http://github.com/WestLangley
* @author bhouston / http://clara.io
*/
import
{
Quaternion
}
from
'
./Quaternion
'
;
import
{
Vector3
}
from
'
./Vector3
'
;
import
{
Matrix4
}
from
'
./Matrix4
'
;
import
{
_Math
}
from
'
./Math
'
;
function
Euler
(
x
,
y
,
z
,
order
)
{
this
.
_x
=
x
||
0
;
...
...
@@ -24,7 +24,7 @@ Euler.DefaultOrder = 'XYZ';
Object
.
defineProperties
(
Euler
.
prototype
,
{
"
x
"
:
{
x
:
{
get
:
function
()
{
...
...
@@ -41,7 +41,7 @@ Object.defineProperties( Euler.prototype, {
},
"
y
"
:
{
y
:
{
get
:
function
()
{
...
...
@@ -58,7 +58,7 @@ Object.defineProperties( Euler.prototype, {
},
"
z
"
:
{
z
:
{
get
:
function
()
{
...
...
@@ -75,7 +75,7 @@ Object.defineProperties( Euler.prototype, {
},
"
order
"
:
{
order
:
{
get
:
function
()
{
...
...
@@ -92,7 +92,7 @@ Object.defineProperties( Euler.prototype, {
}
});
}
);
Object
.
assign
(
Euler
.
prototype
,
{
...
...
src/math/Quaternion.js
浏览文件 @
eeae90e1
import
{
Vector3
}
from
'
./Vector3
'
;
/**
* @author mikael emtinger / http://gomo.se/
* @author alteredq / http://alteredqualia.com/
...
...
@@ -7,25 +5,26 @@ import { Vector3 } from './Vector3';
* @author bhouston / http://clara.io
*/
import
{
Vector3
}
from
'
./Vector3
'
;
function
Quaternion
(
x
,
y
,
z
,
w
)
{
this
.
_
x
=
x
||
0
;
this
.
_
y
=
y
||
0
;
this
.
_
z
=
z
||
0
;
this
.
_
w
=
(
w
!==
undefined
)
?
w
:
1
;
this
.
x
=
x
||
0
;
this
.
y
=
y
||
0
;
this
.
z
=
z
||
0
;
this
.
w
=
(
w
!==
undefined
)
?
w
:
1
;
}
Object
.
assign
(
Quaternion
,
{
slerp
:
function
(
qa
,
qb
,
qm
,
t
)
{
slerp
:
function
(
qa
,
qb
,
qm
,
t
)
{
return
qm
.
copy
(
qa
).
slerp
(
qb
,
t
);
},
slerpFlat
:
function
(
dst
,
dstOffset
,
src0
,
srcOffset0
,
src1
,
srcOffset1
,
t
)
{
slerpFlat
:
function
(
dst
,
dstOffset
,
src0
,
srcOffset0
,
src1
,
srcOffset1
,
t
)
{
// fuzz-free, array-based Quaternion SLERP operation
...
...
@@ -89,88 +88,14 @@ Object.assign( Quaternion, {
}
);
Object
.
defineProperties
(
Quaternion
.
prototype
,
{
"
x
"
:
{
get
:
function
()
{
return
this
.
_x
;
},
set
:
function
(
value
)
{
this
.
_x
=
value
;
this
.
onChangeCallback
();
}
},
"
y
"
:
{
get
:
function
()
{
return
this
.
_y
;
},
set
:
function
(
value
)
{
this
.
_y
=
value
;
this
.
onChangeCallback
();
}
},
"
z
"
:
{
get
:
function
()
{
return
this
.
_z
;
},
set
:
function
(
value
)
{
this
.
_z
=
value
;
this
.
onChangeCallback
();
}
},
"
w
"
:
{
get
:
function
()
{
return
this
.
_w
;
},
set
:
function
(
value
)
{
this
.
_w
=
value
;
this
.
onChangeCallback
();
}
}
});
Object
.
assign
(
Quaternion
.
prototype
,
{
set
:
function
(
x
,
y
,
z
,
w
)
{
this
.
_x
=
x
;
this
.
_y
=
y
;
this
.
_z
=
z
;
this
.
_w
=
w
;
this
.
onChangeCallback
();
this
.
x
=
x
;
this
.
y
=
y
;
this
.
z
=
z
;
this
.
w
=
w
;
return
this
;
...
...
@@ -178,24 +103,22 @@ Object.assign( Quaternion.prototype, {
clone
:
function
()
{
return
new
this
.
constructor
(
this
.
_x
,
this
.
_y
,
this
.
_z
,
this
.
_
w
);
return
new
this
.
constructor
(
this
.
x
,
this
.
y
,
this
.
z
,
this
.
w
);
},
copy
:
function
(
quaternion
)
{
this
.
_x
=
quaternion
.
x
;
this
.
_y
=
quaternion
.
y
;
this
.
_z
=
quaternion
.
z
;
this
.
_w
=
quaternion
.
w
;
this
.
onChangeCallback
();
this
.
x
=
quaternion
.
x
;
this
.
y
=
quaternion
.
y
;
this
.
z
=
quaternion
.
z
;
this
.
w
=
quaternion
.
w
;
return
this
;
},
setFromEuler
:
function
(
euler
,
update
)
{
setFromEuler
:
function
(
euler
)
{
if
(
(
euler
&&
euler
.
isEuler
)
===
false
)
{
...
...
@@ -203,7 +126,7 @@ Object.assign( Quaternion.prototype, {
}
var
x
=
euler
.
_x
,
y
=
euler
.
_y
,
z
=
euler
.
_
z
,
order
=
euler
.
order
;
var
x
=
euler
.
x
,
y
=
euler
.
y
,
z
=
euler
.
z
,
order
=
euler
.
order
;
// http://www.mathworks.com/matlabcentral/fileexchange/
// 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
...
...
@@ -222,50 +145,48 @@ Object.assign( Quaternion.prototype, {
if
(
order
===
'
XYZ
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
}
else
if
(
order
===
'
YXZ
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
}
else
if
(
order
===
'
ZXY
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
}
else
if
(
order
===
'
ZYX
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
}
else
if
(
order
===
'
YZX
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
+
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
+
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
-
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
-
s1
*
s2
*
s3
;
}
else
if
(
order
===
'
XZY
'
)
{
this
.
_
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
_
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
_
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
_
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
this
.
x
=
s1
*
c2
*
c3
-
c1
*
s2
*
s3
;
this
.
y
=
c1
*
s2
*
c3
-
s1
*
c2
*
s3
;
this
.
z
=
c1
*
c2
*
s3
+
s1
*
s2
*
c3
;
this
.
w
=
c1
*
c2
*
c3
+
s1
*
s2
*
s3
;
}
if
(
update
!==
false
)
this
.
onChangeCallback
();
return
this
;
},
...
...
@@ -278,12 +199,10 @@ Object.assign( Quaternion.prototype, {
var
halfAngle
=
angle
/
2
,
s
=
Math
.
sin
(
halfAngle
);
this
.
_x
=
axis
.
x
*
s
;
this
.
_y
=
axis
.
y
*
s
;
this
.
_z
=
axis
.
z
*
s
;
this
.
_w
=
Math
.
cos
(
halfAngle
);
this
.
onChangeCallback
();
this
.
x
=
axis
.
x
*
s
;
this
.
y
=
axis
.
y
*
s
;
this
.
z
=
axis
.
z
*
s
;
this
.
w
=
Math
.
cos
(
halfAngle
);
return
this
;
...
...
@@ -308,42 +227,40 @@ Object.assign( Quaternion.prototype, {
s
=
0.5
/
Math
.
sqrt
(
trace
+
1.0
);
this
.
_
w
=
0.25
/
s
;
this
.
_
x
=
(
m32
-
m23
)
*
s
;
this
.
_
y
=
(
m13
-
m31
)
*
s
;
this
.
_
z
=
(
m21
-
m12
)
*
s
;
this
.
w
=
0.25
/
s
;
this
.
x
=
(
m32
-
m23
)
*
s
;
this
.
y
=
(
m13
-
m31
)
*
s
;
this
.
z
=
(
m21
-
m12
)
*
s
;
}
else
if
(
m11
>
m22
&&
m11
>
m33
)
{
s
=
2.0
*
Math
.
sqrt
(
1.0
+
m11
-
m22
-
m33
);
this
.
_
w
=
(
m32
-
m23
)
/
s
;
this
.
_
x
=
0.25
*
s
;
this
.
_
y
=
(
m12
+
m21
)
/
s
;
this
.
_
z
=
(
m13
+
m31
)
/
s
;
this
.
w
=
(
m32
-
m23
)
/
s
;
this
.
x
=
0.25
*
s
;
this
.
y
=
(
m12
+
m21
)
/
s
;
this
.
z
=
(
m13
+
m31
)
/
s
;
}
else
if
(
m22
>
m33
)
{
s
=
2.0
*
Math
.
sqrt
(
1.0
+
m22
-
m11
-
m33
);
this
.
_
w
=
(
m13
-
m31
)
/
s
;
this
.
_
x
=
(
m12
+
m21
)
/
s
;
this
.
_
y
=
0.25
*
s
;
this
.
_
z
=
(
m23
+
m32
)
/
s
;
this
.
w
=
(
m13
-
m31
)
/
s
;
this
.
x
=
(
m12
+
m21
)
/
s
;
this
.
y
=
0.25
*
s
;
this
.
z
=
(
m23
+
m32
)
/
s
;
}
else
{
s
=
2.0
*
Math
.
sqrt
(
1.0
+
m33
-
m11
-
m22
);
this
.
_
w
=
(
m21
-
m12
)
/
s
;
this
.
_
x
=
(
m13
+
m31
)
/
s
;
this
.
_
y
=
(
m23
+
m32
)
/
s
;
this
.
_
z
=
0.25
*
s
;
this
.
w
=
(
m21
-
m12
)
/
s
;
this
.
x
=
(
m13
+
m31
)
/
s
;
this
.
y
=
(
m23
+
m32
)
/
s
;
this
.
z
=
0.25
*
s
;
}
this
.
onChangeCallback
();
return
this
;
},
...
...
@@ -385,10 +302,10 @@ Object.assign( Quaternion.prototype, {
}
this
.
_
x
=
v1
.
x
;
this
.
_
y
=
v1
.
y
;
this
.
_
z
=
v1
.
z
;
this
.
_
w
=
r
;
this
.
x
=
v1
.
x
;
this
.
y
=
v1
.
y
;
this
.
z
=
v1
.
z
;
this
.
w
=
r
;
return
this
.
normalize
();
...
...
@@ -404,11 +321,9 @@ Object.assign( Quaternion.prototype, {
conjugate
:
function
()
{
this
.
_x
*=
-
1
;
this
.
_y
*=
-
1
;
this
.
_z
*=
-
1
;
this
.
onChangeCallback
();
this
.
x
*=
-
1
;
this
.
y
*=
-
1
;
this
.
z
*=
-
1
;
return
this
;
...
...
@@ -416,19 +331,19 @@ Object.assign( Quaternion.prototype, {
dot
:
function
(
v
)
{
return
this
.
_x
*
v
.
_x
+
this
.
_y
*
v
.
_y
+
this
.
_z
*
v
.
_z
+
this
.
_w
*
v
.
_
w
;
return
this
.
x
*
v
.
x
+
this
.
y
*
v
.
y
+
this
.
z
*
v
.
z
+
this
.
w
*
v
.
w
;
},
lengthSq
:
function
()
{
return
this
.
_x
*
this
.
_x
+
this
.
_y
*
this
.
_y
+
this
.
_z
*
this
.
_z
+
this
.
_w
*
this
.
_
w
;
return
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
;
},
length
:
function
()
{
return
Math
.
sqrt
(
this
.
_x
*
this
.
_x
+
this
.
_y
*
this
.
_y
+
this
.
_z
*
this
.
_z
+
this
.
_w
*
this
.
_
w
);
return
Math
.
sqrt
(
this
.
x
*
this
.
x
+
this
.
y
*
this
.
y
+
this
.
z
*
this
.
z
+
this
.
w
*
this
.
w
);
},
...
...
@@ -438,24 +353,22 @@ Object.assign( Quaternion.prototype, {
if
(
l
===
0
)
{
this
.
_
x
=
0
;
this
.
_
y
=
0
;
this
.
_
z
=
0
;
this
.
_
w
=
1
;
this
.
x
=
0
;
this
.
y
=
0
;
this
.
z
=
0
;
this
.
w
=
1
;
}
else
{
l
=
1
/
l
;
this
.
_x
=
this
.
_
x
*
l
;
this
.
_y
=
this
.
_
y
*
l
;
this
.
_z
=
this
.
_
z
*
l
;
this
.
_w
=
this
.
_
w
*
l
;
this
.
x
=
this
.
x
*
l
;
this
.
y
=
this
.
y
*
l
;
this
.
z
=
this
.
z
*
l
;
this
.
w
=
this
.
w
*
l
;
}
this
.
onChangeCallback
();
return
this
;
},
...
...
@@ -483,15 +396,13 @@ Object.assign( Quaternion.prototype, {
// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm
var
qax
=
a
.
_x
,
qay
=
a
.
_y
,
qaz
=
a
.
_z
,
qaw
=
a
.
_
w
;
var
qbx
=
b
.
_x
,
qby
=
b
.
_y
,
qbz
=
b
.
_z
,
qbw
=
b
.
_
w
;
var
qax
=
a
.
x
,
qay
=
a
.
y
,
qaz
=
a
.
z
,
qaw
=
a
.
w
;
var
qbx
=
b
.
x
,
qby
=
b
.
y
,
qbz
=
b
.
z
,
qbw
=
b
.
w
;
this
.
_x
=
qax
*
qbw
+
qaw
*
qbx
+
qay
*
qbz
-
qaz
*
qby
;
this
.
_y
=
qay
*
qbw
+
qaw
*
qby
+
qaz
*
qbx
-
qax
*
qbz
;
this
.
_z
=
qaz
*
qbw
+
qaw
*
qbz
+
qax
*
qby
-
qay
*
qbx
;
this
.
_w
=
qaw
*
qbw
-
qax
*
qbx
-
qay
*
qby
-
qaz
*
qbz
;
this
.
onChangeCallback
();
this
.
x
=
qax
*
qbw
+
qaw
*
qbx
+
qay
*
qbz
-
qaz
*
qby
;
this
.
y
=
qay
*
qbw
+
qaw
*
qby
+
qaz
*
qbx
-
qax
*
qbz
;
this
.
z
=
qaz
*
qbw
+
qaw
*
qbz
+
qax
*
qby
-
qay
*
qbx
;
this
.
w
=
qaw
*
qbw
-
qax
*
qbx
-
qay
*
qby
-
qaz
*
qbz
;
return
this
;
...
...
@@ -502,18 +413,18 @@ Object.assign( Quaternion.prototype, {
if
(
t
===
0
)
return
this
;
if
(
t
===
1
)
return
this
.
copy
(
qb
);
var
x
=
this
.
_x
,
y
=
this
.
_y
,
z
=
this
.
_z
,
w
=
this
.
_
w
;
var
x
=
this
.
x
,
y
=
this
.
y
,
z
=
this
.
z
,
w
=
this
.
w
;
// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/
var
cosHalfTheta
=
w
*
qb
.
_w
+
x
*
qb
.
_x
+
y
*
qb
.
_y
+
z
*
qb
.
_
z
;
var
cosHalfTheta
=
w
*
qb
.
w
+
x
*
qb
.
x
+
y
*
qb
.
y
+
z
*
qb
.
z
;
if
(
cosHalfTheta
<
0
)
{
this
.
_w
=
-
qb
.
_
w
;
this
.
_x
=
-
qb
.
_
x
;
this
.
_y
=
-
qb
.
_
y
;
this
.
_z
=
-
qb
.
_
z
;
this
.
w
=
-
qb
.
w
;
this
.
x
=
-
qb
.
x
;
this
.
y
=
-
qb
.
y
;
this
.
z
=
-
qb
.
z
;
cosHalfTheta
=
-
cosHalfTheta
;
...
...
@@ -525,10 +436,10 @@ Object.assign( Quaternion.prototype, {
if
(
cosHalfTheta
>=
1.0
)
{
this
.
_
w
=
w
;
this
.
_
x
=
x
;
this
.
_
y
=
y
;
this
.
_
z
=
z
;
this
.
w
=
w
;
this
.
x
=
x
;
this
.
y
=
y
;
this
.
z
=
z
;
return
this
;
...
...
@@ -538,10 +449,10 @@ Object.assign( Quaternion.prototype, {
if
(
Math
.
abs
(
sinHalfTheta
)
<
0.001
)
{
this
.
_w
=
0.5
*
(
w
+
this
.
_
w
);
this
.
_x
=
0.5
*
(
x
+
this
.
_
x
);
this
.
_y
=
0.5
*
(
y
+
this
.
_
y
);
this
.
_z
=
0.5
*
(
z
+
this
.
_
z
);
this
.
w
=
0.5
*
(
w
+
this
.
w
);
this
.
x
=
0.5
*
(
x
+
this
.
x
);
this
.
y
=
0.5
*
(
y
+
this
.
y
);
this
.
z
=
0.5
*
(
z
+
this
.
z
);
return
this
;
...
...
@@ -551,12 +462,10 @@ Object.assign( Quaternion.prototype, {
var
ratioA
=
Math
.
sin
(
(
1
-
t
)
*
halfTheta
)
/
sinHalfTheta
,
ratioB
=
Math
.
sin
(
t
*
halfTheta
)
/
sinHalfTheta
;
this
.
_w
=
(
w
*
ratioA
+
this
.
_w
*
ratioB
);
this
.
_x
=
(
x
*
ratioA
+
this
.
_x
*
ratioB
);
this
.
_y
=
(
y
*
ratioA
+
this
.
_y
*
ratioB
);
this
.
_z
=
(
z
*
ratioA
+
this
.
_z
*
ratioB
);
this
.
onChangeCallback
();
this
.
w
=
(
w
*
ratioA
+
this
.
w
*
ratioB
);
this
.
x
=
(
x
*
ratioA
+
this
.
x
*
ratioB
);
this
.
y
=
(
y
*
ratioA
+
this
.
y
*
ratioB
);
this
.
z
=
(
z
*
ratioA
+
this
.
z
*
ratioB
);
return
this
;
...
...
@@ -564,7 +473,7 @@ Object.assign( Quaternion.prototype, {
equals
:
function
(
quaternion
)
{
return
(
quaternion
.
_x
===
this
.
_x
)
&&
(
quaternion
.
_y
===
this
.
_y
)
&&
(
quaternion
.
_z
===
this
.
_z
)
&&
(
quaternion
.
_w
===
this
.
_
w
);
return
(
quaternion
.
x
===
this
.
x
)
&&
(
quaternion
.
y
===
this
.
y
)
&&
(
quaternion
.
z
===
this
.
z
)
&&
(
quaternion
.
w
===
this
.
w
);
},
...
...
@@ -572,12 +481,10 @@ Object.assign( Quaternion.prototype, {
if
(
offset
===
undefined
)
offset
=
0
;
this
.
_x
=
array
[
offset
];
this
.
_y
=
array
[
offset
+
1
];
this
.
_z
=
array
[
offset
+
2
];
this
.
_w
=
array
[
offset
+
3
];
this
.
onChangeCallback
();
this
.
x
=
array
[
offset
];
this
.
y
=
array
[
offset
+
1
];
this
.
z
=
array
[
offset
+
2
];
this
.
w
=
array
[
offset
+
3
];
return
this
;
...
...
@@ -588,24 +495,14 @@ Object.assign( Quaternion.prototype, {
if
(
array
===
undefined
)
array
=
[];
if
(
offset
===
undefined
)
offset
=
0
;
array
[
offset
]
=
this
.
_
x
;
array
[
offset
+
1
]
=
this
.
_
y
;
array
[
offset
+
2
]
=
this
.
_
z
;
array
[
offset
+
3
]
=
this
.
_
w
;
array
[
offset
]
=
this
.
x
;
array
[
offset
+
1
]
=
this
.
y
;
array
[
offset
+
2
]
=
this
.
z
;
array
[
offset
+
3
]
=
this
.
w
;
return
array
;
},
onChange
:
function
(
callback
)
{
this
.
onChangeCallback
=
callback
;
return
this
;
},
onChangeCallback
:
function
()
{}
}
}
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录