Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
59db2ace
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,发现更多精彩内容 >>
提交
59db2ace
编写于
9月 19, 2013
作者:
A
Aleksandar Rodic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed changed event up update only on visual change
changed conditional statements to be more explicit
上级
9e0ebbad
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
117 addition
and
123 deletion
+117
-123
examples/js/controls/TransformControls.js
examples/js/controls/TransformControls.js
+117
-123
未找到文件。
examples/js/controls/TransformControls.js
浏览文件 @
59db2ace
...
...
@@ -40,6 +40,7 @@ THREE.TransformGizmo = function () {
var
showPickers
=
false
;
//debug
var
showActivePlane
=
false
;
//debug
this
.
activePlane
=
undefined
;
this
.
init
=
function
()
{
...
...
@@ -144,7 +145,7 @@ THREE.TransformGizmo = function () {
}
if
(
this
.
activePlane
)
this
.
activePlane
.
visible
=
showActivePlane
;
if
(
this
.
activePlane
!==
undefined
)
this
.
activePlane
.
visible
=
showActivePlane
;
}
...
...
@@ -156,7 +157,7 @@ THREE.TransformGizmo = function () {
handle
=
this
.
handleGizmos
[
i
][
0
];
if
(
handle
.
material
.
oldColor
)
{
if
(
handle
.
material
.
oldColor
!==
undefined
)
{
handle
.
material
.
color
.
copy
(
handle
.
material
.
oldColor
);
handle
.
material
.
opacity
=
handle
.
material
.
oldOpacity
;
...
...
@@ -165,7 +166,7 @@ THREE.TransformGizmo = function () {
}
if
(
this
.
handleGizmos
[
axis
]
)
{
if
(
this
.
handleGizmos
[
axis
]
!==
undefined
)
{
handle
=
this
.
handleGizmos
[
axis
][
0
];
...
...
@@ -574,11 +575,11 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
gizmo
[
"
rotate
"
].
hide
();
this
.
gizmo
[
"
scale
"
].
hide
();
this
.
object
=
false
;
this
.
object
=
undefined
;
this
.
snap
=
false
;
this
.
space
=
"
world
"
;
this
.
size
=
1
;
this
.
axis
=
false
;
this
.
axis
=
undefined
;
var
scope
=
this
;
...
...
@@ -658,8 +659,8 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
detach
=
function
(
object
)
{
scope
.
object
=
false
;
this
.
axis
=
false
;
scope
.
object
=
undefined
;
this
.
axis
=
undefined
;
this
.
gizmo
[
"
translate
"
].
hide
();
this
.
gizmo
[
"
rotate
"
].
hide
();
...
...
@@ -705,7 +706,7 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
update
=
function
()
{
if
(
!
scope
.
object
)
return
;
if
(
scope
.
object
===
undefined
)
return
;
scope
.
object
.
updateMatrixWorld
();
worldPosition
.
getPositionFromMatrix
(
scope
.
object
.
matrixWorld
);
...
...
@@ -729,13 +730,11 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
gizmo
[
_mode
].
highlight
(
scope
.
axis
);
scope
.
dispatchEvent
(
changeEvent
);
}
function
onPointerHover
(
event
)
{
if
(
!
scope
.
object
||
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
_dragging
==
true
)
return
;
event
.
preventDefault
();
event
.
stopPropagation
();
...
...
@@ -748,11 +747,13 @@ THREE.TransformControls = function ( camera, domElement ) {
scope
.
axis
=
intersect
.
object
.
name
;
scope
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
else
{
}
else
if
(
scope
.
axis
!==
undefined
)
{
scope
.
axis
=
false
;
scope
.
axis
=
undefined
;
scope
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
...
...
@@ -760,14 +761,14 @@ THREE.TransformControls = function ( camera, domElement ) {
function
onPointerDown
(
event
)
{
if
(
!
scope
.
object
||
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
_dragging
==
true
)
return
;
event
.
preventDefault
();
event
.
stopPropagation
();
var
pointer
=
event
.
touches
?
event
.
touches
[
0
]
:
event
;
if
(
pointer
.
button
===
0
||
pointer
.
button
==
undefined
)
{
if
(
pointer
.
button
===
0
||
pointer
.
button
==
=
undefined
)
{
var
intersect
=
intersectObjects
(
pointer
,
scope
.
gizmo
[
_mode
].
pickers
.
children
);
...
...
@@ -783,20 +784,16 @@ THREE.TransformControls = function ( camera, domElement ) {
var
planeIntersect
=
intersectObjects
(
pointer
,
[
scope
.
gizmo
[
_mode
].
activePlane
]
);
if
(
planeIntersect
)
{
oldPosition
.
copy
(
scope
.
object
.
position
);
oldScale
.
copy
(
scope
.
object
.
scale
);
oldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrix
);
worldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrixWorld
);
oldPosition
.
copy
(
scope
.
object
.
position
);
oldScale
.
copy
(
scope
.
object
.
scale
);
parentRotationMatrix
.
extractRotation
(
scope
.
object
.
parent
.
matrixWorld
);
parentScale
.
getScaleFromMatrix
(
tempMatrix
.
getInverse
(
scope
.
object
.
parent
.
matrixWorld
)
);
oldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrix
);
worldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrixWorld
);
offset
.
copy
(
planeIntersect
.
point
);
parentRotationMatrix
.
extractRotation
(
scope
.
object
.
parent
.
matrixWorld
);
parentScale
.
getScaleFromMatrix
(
tempMatrix
.
getInverse
(
scope
.
object
.
parent
.
matrixWorld
)
);
}
offset
.
copy
(
planeIntersect
.
point
);
}
...
...
@@ -808,7 +805,7 @@ THREE.TransformControls = function ( camera, domElement ) {
function
onPointerMove
(
event
)
{
if
(
!
scope
.
object
||
!
scope
.
axis
||
!
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
scope
.
axis
===
undefined
||
_dragging
==
false
)
return
;
event
.
preventDefault
();
event
.
stopPropagation
();
...
...
@@ -817,169 +814,166 @@ THREE.TransformControls = function ( camera, domElement ) {
var
planeIntersect
=
intersectObjects
(
pointer
,
[
scope
.
gizmo
[
_mode
].
activePlane
]
);
if
(
planeIntersect
)
{
point
.
copy
(
planeIntersect
.
point
);
point
.
copy
(
planeIntersect
.
point
);
if
(
_mode
==
"
translate
"
)
{
if
(
_mode
==
"
translate
"
)
{
point
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
point
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
if
(
scope
.
space
==
"
local
"
)
{
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
if
(
scope
.
space
==
"
local
"
)
{
if
(
scope
.
axis
.
search
(
"
X
"
)
==
-
1
)
point
.
x
=
0
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
point
.
applyMatrix4
(
oldRotationMatrix
);
if
(
scope
.
axis
.
search
(
"
X
"
)
==
-
1
)
point
.
x
=
0
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
scope
.
object
.
position
.
copy
(
oldPosition
);
scope
.
object
.
position
.
add
(
point
);
point
.
applyMatrix4
(
oldRotationMatrix
);
}
scope
.
object
.
position
.
copy
(
oldPosition
);
scope
.
object
.
position
.
add
(
point
);
if
(
scope
.
space
==
"
world
"
||
scope
.
axis
.
search
(
"
XYZ
"
)
!=
-
1
)
{
}
if
(
scope
.
axis
.
search
(
"
X
"
)
==
-
1
)
point
.
x
=
0
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
if
(
scope
.
space
==
"
world
"
||
scope
.
axis
.
search
(
"
XYZ
"
)
!=
-
1
)
{
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
if
(
scope
.
axis
.
search
(
"
X
"
)
==
-
1
)
point
.
x
=
0
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
scope
.
object
.
position
.
copy
(
oldPosition
);
scope
.
object
.
position
.
add
(
point
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
if
(
scope
.
snap
)
{
scope
.
object
.
position
.
copy
(
oldPosition
);
scope
.
object
.
position
.
add
(
point
);
if
(
scope
.
axis
.
search
(
"
X
"
)
!=
-
1
)
scope
.
object
.
position
.
x
=
Math
.
round
(
scope
.
object
.
position
.
x
/
scope
.
snap
)
*
scope
.
snap
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
!=
-
1
)
scope
.
object
.
position
.
y
=
Math
.
round
(
scope
.
object
.
position
.
y
/
scope
.
snap
)
*
scope
.
snap
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
!=
-
1
)
scope
.
object
.
position
.
z
=
Math
.
round
(
scope
.
object
.
position
.
z
/
scope
.
snap
)
*
scope
.
snap
;
}
if
(
scope
.
snap
==
true
)
{
if
(
scope
.
axis
.
search
(
"
X
"
)
!=
-
1
)
scope
.
object
.
position
.
x
=
Math
.
round
(
scope
.
object
.
position
.
x
/
scope
.
snap
)
*
scope
.
snap
;
if
(
scope
.
axis
.
search
(
"
Y
"
)
!=
-
1
)
scope
.
object
.
position
.
y
=
Math
.
round
(
scope
.
object
.
position
.
y
/
scope
.
snap
)
*
scope
.
snap
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
!=
-
1
)
scope
.
object
.
position
.
z
=
Math
.
round
(
scope
.
object
.
position
.
z
/
scope
.
snap
)
*
scope
.
snap
;
}
}
else
if
(
_mode
==
"
scale
"
)
{
}
point
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
}
else
if
(
_mode
==
"
scale
"
)
{
if
(
scope
.
space
==
"
local
"
)
{
point
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
if
(
scope
.
axis
==
"
XYZ
"
)
{
if
(
scope
.
space
==
"
local
"
)
{
scale
=
1
+
(
(
point
.
y
)
/
50
);
if
(
scope
.
axis
==
"
XYZ
"
)
{
scope
.
object
.
scale
.
x
=
oldScale
.
x
*
scale
;
scope
.
object
.
scale
.
y
=
oldScale
.
y
*
scale
;
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
scale
;
scale
=
1
+
(
(
point
.
y
)
/
50
);
}
else
{
scope
.
object
.
scale
.
x
=
oldScale
.
x
*
scale
;
scope
.
object
.
scale
.
y
=
oldScale
.
y
*
scale
;
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
scale
;
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
}
else
{
if
(
scope
.
axis
==
"
X
"
)
scope
.
object
.
scale
.
x
=
oldScale
.
x
*
(
1
+
point
.
x
/
50
);
if
(
scope
.
axis
==
"
Y
"
)
scope
.
object
.
scale
.
y
=
oldScale
.
y
*
(
1
+
point
.
y
/
50
);
if
(
scope
.
axis
==
"
Z
"
)
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
(
1
+
point
.
z
/
50
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
}
if
(
scope
.
axis
==
"
X
"
)
scope
.
object
.
scale
.
x
=
oldScale
.
x
*
(
1
+
point
.
x
/
50
);
if
(
scope
.
axis
==
"
Y
"
)
scope
.
object
.
scale
.
y
=
oldScale
.
y
*
(
1
+
point
.
y
/
50
);
if
(
scope
.
axis
==
"
Z
"
)
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
(
1
+
point
.
z
/
50
);
}
}
else
if
(
_mode
==
"
rotate
"
)
{
}
point
.
sub
(
worldPosition
);
point
.
multiply
(
parentScale
);
tempVector
.
copy
(
offset
).
sub
(
worldPosition
);
tempVector
.
multiply
(
parentScale
);
}
else
if
(
_mode
==
"
rotate
"
)
{
if
(
scope
.
axis
==
"
E
"
)
{
point
.
sub
(
worldPosition
);
point
.
multiply
(
parentScale
);
tempVector
.
copy
(
offset
).
sub
(
worldPosition
);
tempVector
.
multiply
(
parentScale
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatrix
)
);
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatrix
)
);
if
(
scope
.
axis
==
"
E
"
)
{
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatri
x
)
);
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatri
x
)
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
quaternionE
.
setFromAxisAngle
(
eye
,
rotation
.
z
-
offsetRotation
.
z
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionE
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
quaternionE
.
setFromAxisAngle
(
eye
,
rotation
.
z
-
offsetRotation
.
z
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionE
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
}
else
if
(
scope
.
axis
==
"
XYZE
"
)
{
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
quaternionE
.
setFromEuler
(
point
.
clone
().
cross
(
tempVector
).
normalize
()
);
// rotation axis
}
else
if
(
scope
.
axis
==
"
XYZE
"
)
{
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
quaternionX
.
setFromAxisAngle
(
quaternionE
,
-
point
.
clone
().
angleTo
(
tempVector
)
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
quaternionE
.
setFromEuler
(
point
.
clone
().
cross
(
tempVector
).
normalize
()
);
// rotation axis
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
quaternionX
.
setFromAxisAngle
(
quaternionE
,
-
point
.
clone
().
angleTo
(
tempVector
)
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
}
else
if
(
scope
.
space
==
"
local
"
)
{
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
}
else
if
(
scope
.
space
==
"
local
"
)
{
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
quaternionXYZ
.
setFromRotationMatrix
(
oldRotationMatrix
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
if
(
scope
.
axis
==
"
X
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionX
);
if
(
scope
.
axis
==
"
Y
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionY
);
if
(
scope
.
axis
==
"
Z
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionZ
);
quaternionXYZ
.
setFromRotationMatrix
(
oldRotationMatrix
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
scope
.
object
.
quaternion
.
copy
(
quaternionXYZ
);
if
(
scope
.
axis
==
"
X
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionX
);
if
(
scope
.
axis
==
"
Y
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionY
);
if
(
scope
.
axis
==
"
Z
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionZ
);
}
else
if
(
scope
.
space
==
"
world
"
)
{
scope
.
object
.
quaternion
.
copy
(
quaternionXYZ
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
}
else
if
(
scope
.
space
==
"
world
"
)
{
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
if
(
scope
.
axis
==
"
X
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
if
(
scope
.
axis
==
"
Y
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionY
);
if
(
scope
.
axis
==
"
Z
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
if
(
scope
.
axis
==
"
X
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
if
(
scope
.
axis
==
"
Y
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionY
);
if
(
scope
.
axis
==
"
Z
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
}
scope
.
object
.
quaternion
.
copy
(
tempQuaternion
);
}
}
scope
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
function
onPointerUp
(
event
)
{
scope
.
axis
=
false
;
scope
.
axis
=
undefined
;
_dragging
=
false
;
scope
.
update
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录