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 () {
...
@@ -40,6 +40,7 @@ THREE.TransformGizmo = function () {
var
showPickers
=
false
;
//debug
var
showPickers
=
false
;
//debug
var
showActivePlane
=
false
;
//debug
var
showActivePlane
=
false
;
//debug
this
.
activePlane
=
undefined
;
this
.
init
=
function
()
{
this
.
init
=
function
()
{
...
@@ -144,7 +145,7 @@ THREE.TransformGizmo = 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 () {
...
@@ -156,7 +157,7 @@ THREE.TransformGizmo = function () {
handle
=
this
.
handleGizmos
[
i
][
0
];
handle
=
this
.
handleGizmos
[
i
][
0
];
if
(
handle
.
material
.
oldColor
)
{
if
(
handle
.
material
.
oldColor
!==
undefined
)
{
handle
.
material
.
color
.
copy
(
handle
.
material
.
oldColor
);
handle
.
material
.
color
.
copy
(
handle
.
material
.
oldColor
);
handle
.
material
.
opacity
=
handle
.
material
.
oldOpacity
;
handle
.
material
.
opacity
=
handle
.
material
.
oldOpacity
;
...
@@ -165,7 +166,7 @@ THREE.TransformGizmo = function () {
...
@@ -165,7 +166,7 @@ THREE.TransformGizmo = function () {
}
}
if
(
this
.
handleGizmos
[
axis
]
)
{
if
(
this
.
handleGizmos
[
axis
]
!==
undefined
)
{
handle
=
this
.
handleGizmos
[
axis
][
0
];
handle
=
this
.
handleGizmos
[
axis
][
0
];
...
@@ -574,11 +575,11 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -574,11 +575,11 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
gizmo
[
"
rotate
"
].
hide
();
this
.
gizmo
[
"
rotate
"
].
hide
();
this
.
gizmo
[
"
scale
"
].
hide
();
this
.
gizmo
[
"
scale
"
].
hide
();
this
.
object
=
false
;
this
.
object
=
undefined
;
this
.
snap
=
false
;
this
.
snap
=
false
;
this
.
space
=
"
world
"
;
this
.
space
=
"
world
"
;
this
.
size
=
1
;
this
.
size
=
1
;
this
.
axis
=
false
;
this
.
axis
=
undefined
;
var
scope
=
this
;
var
scope
=
this
;
...
@@ -658,8 +659,8 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -658,8 +659,8 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
detach
=
function
(
object
)
{
this
.
detach
=
function
(
object
)
{
scope
.
object
=
false
;
scope
.
object
=
undefined
;
this
.
axis
=
false
;
this
.
axis
=
undefined
;
this
.
gizmo
[
"
translate
"
].
hide
();
this
.
gizmo
[
"
translate
"
].
hide
();
this
.
gizmo
[
"
rotate
"
].
hide
();
this
.
gizmo
[
"
rotate
"
].
hide
();
...
@@ -705,7 +706,7 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -705,7 +706,7 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
update
=
function
()
{
this
.
update
=
function
()
{
if
(
!
scope
.
object
)
return
;
if
(
scope
.
object
===
undefined
)
return
;
scope
.
object
.
updateMatrixWorld
();
scope
.
object
.
updateMatrixWorld
();
worldPosition
.
getPositionFromMatrix
(
scope
.
object
.
matrixWorld
);
worldPosition
.
getPositionFromMatrix
(
scope
.
object
.
matrixWorld
);
...
@@ -729,13 +730,11 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -729,13 +730,11 @@ THREE.TransformControls = function ( camera, domElement ) {
this
.
gizmo
[
_mode
].
highlight
(
scope
.
axis
);
this
.
gizmo
[
_mode
].
highlight
(
scope
.
axis
);
scope
.
dispatchEvent
(
changeEvent
);
}
}
function
onPointerHover
(
event
)
{
function
onPointerHover
(
event
)
{
if
(
!
scope
.
object
||
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
_dragging
==
true
)
return
;
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
...
@@ -748,11 +747,13 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -748,11 +747,13 @@ THREE.TransformControls = function ( camera, domElement ) {
scope
.
axis
=
intersect
.
object
.
name
;
scope
.
axis
=
intersect
.
object
.
name
;
scope
.
update
();
scope
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
else
{
}
else
if
(
scope
.
axis
!==
undefined
)
{
scope
.
axis
=
false
;
scope
.
axis
=
undefined
;
scope
.
update
();
scope
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
}
...
@@ -760,14 +761,14 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -760,14 +761,14 @@ THREE.TransformControls = function ( camera, domElement ) {
function
onPointerDown
(
event
)
{
function
onPointerDown
(
event
)
{
if
(
!
scope
.
object
||
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
_dragging
==
true
)
return
;
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
var
pointer
=
event
.
touches
?
event
.
touches
[
0
]
:
event
;
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
);
var
intersect
=
intersectObjects
(
pointer
,
scope
.
gizmo
[
_mode
].
pickers
.
children
);
...
@@ -783,20 +784,16 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -783,20 +784,16 @@ THREE.TransformControls = function ( camera, domElement ) {
var
planeIntersect
=
intersectObjects
(
pointer
,
[
scope
.
gizmo
[
_mode
].
activePlane
]
);
var
planeIntersect
=
intersectObjects
(
pointer
,
[
scope
.
gizmo
[
_mode
].
activePlane
]
);
if
(
planeIntersect
)
{
oldPosition
.
copy
(
scope
.
object
.
position
);
oldScale
.
copy
(
scope
.
object
.
scale
);
oldPosition
.
copy
(
scope
.
object
.
position
);
oldScale
.
copy
(
scope
.
object
.
scale
);
oldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrix
);
worldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrixWorld
);
parentRotationMatrix
.
extractRotation
(
scope
.
object
.
parent
.
matrixWorld
);
oldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrix
);
parentScale
.
getScaleFromMatrix
(
tempMatrix
.
getInverse
(
scope
.
object
.
parent
.
matrixWorld
)
);
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 ) {
...
@@ -808,7 +805,7 @@ THREE.TransformControls = function ( camera, domElement ) {
function
onPointerMove
(
event
)
{
function
onPointerMove
(
event
)
{
if
(
!
scope
.
object
||
!
scope
.
axis
||
!
_dragging
)
return
;
if
(
scope
.
object
===
undefined
||
scope
.
axis
===
undefined
||
_dragging
==
false
)
return
;
event
.
preventDefault
();
event
.
preventDefault
();
event
.
stopPropagation
();
event
.
stopPropagation
();
...
@@ -817,169 +814,166 @@ THREE.TransformControls = function ( camera, domElement ) {
...
@@ -817,169 +814,166 @@ THREE.TransformControls = function ( camera, domElement ) {
var
planeIntersect
=
intersectObjects
(
pointer
,
[
scope
.
gizmo
[
_mode
].
activePlane
]
);
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
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
point
.
multiply
(
parentScale
);
if
(
scope
.
space
==
"
local
"
)
{
if
(
scope
.
space
==
"
local
"
)
{
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
if
(
scope
.
axis
.
search
(
"
X
"
)
==
-
1
)
point
.
x
=
0
;
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
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
);
point
.
applyMatrix4
(
oldRotationMatrix
);
scope
.
object
.
position
.
add
(
point
);
}
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
.
space
==
"
world
"
||
scope
.
axis
.
search
(
"
XYZ
"
)
!=
-
1
)
{
if
(
scope
.
axis
.
search
(
"
Y
"
)
==
-
1
)
point
.
y
=
0
;
if
(
scope
.
axis
.
search
(
"
Z
"
)
==
-
1
)
point
.
z
=
0
;
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
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
scope
.
object
.
position
.
add
(
point
);
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
.
snap
==
true
)
{
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
.
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
);
}
else
if
(
_mode
==
"
scale
"
)
{
point
.
multiply
(
parentScale
);
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
;
scale
=
1
+
(
(
point
.
y
)
/
50
);
scope
.
object
.
scale
.
y
=
oldScale
.
y
*
scale
;
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
scale
;
}
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
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
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
);
}
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
);
}
else
if
(
_mode
==
"
rotate
"
)
{
point
.
multiply
(
parentScale
);
tempVector
.
copy
(
offset
).
sub
(
worldPosition
);
tempVector
.
multiply
(
parentScale
);
if
(
scope
.
axis
==
"
E
"
)
{
point
.
sub
(
worldPosition
);
point
.
multiply
(
parentScale
);
tempVector
.
copy
(
offset
).
sub
(
worldPosition
);
tempVector
.
multiply
(
parentScale
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatrix
)
);
if
(
scope
.
axis
==
"
E
"
)
{
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatrix
)
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
lookAtMatri
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
(
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
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionE
);
quaternionE
.
setFromAxisAngle
(
eye
,
rotation
.
z
-
offsetRotation
.
z
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
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
)
);
quaternionE
.
setFromEuler
(
point
.
clone
().
cross
(
tempVector
).
normalize
()
);
// rotation axis
quaternionX
.
setFromAxisAngle
(
quaternionE
,
-
point
.
clone
().
angleTo
(
tempVector
)
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
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
)
);
tempVector
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
quaternionXYZ
.
setFromRotationMatrix
(
oldRotationMatrix
);
rotation
.
set
(
Math
.
atan2
(
point
.
z
,
point
.
y
),
Math
.
atan2
(
point
.
x
,
point
.
z
),
Math
.
atan2
(
point
.
y
,
point
.
x
)
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
x
)
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
if
(
scope
.
axis
==
"
X
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionX
);
quaternionXYZ
.
setFromRotationMatrix
(
oldRotationMatrix
);
if
(
scope
.
axis
==
"
Y
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionY
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
if
(
scope
.
axis
==
"
Z
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionZ
);
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
)
);
}
else
if
(
scope
.
space
==
"
world
"
)
{
offsetRotation
.
set
(
Math
.
atan2
(
tempVector
.
z
,
tempVector
.
y
),
Math
.
atan2
(
tempVector
.
x
,
tempVector
.
z
),
Math
.
atan2
(
tempVector
.
y
,
tempVector
.
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
)
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
tempQuaternion
.
setFromRotationMatrix
(
tempMatrix
.
getInverse
(
parentRotationMatrix
)
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
quaternionZ
.
setFromAxisAngle
(
unitZ
,
rotation
.
z
-
offsetRotation
.
z
);
quaternionXYZ
.
setFromRotationMatrix
(
worldRotationMatrix
);
if
(
scope
.
axis
==
"
X
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
quaternionX
.
setFromAxisAngle
(
unitX
,
rotation
.
x
-
offsetRotation
.
x
);
if
(
scope
.
axis
==
"
Y
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionY
);
quaternionY
.
setFromAxisAngle
(
unitY
,
rotation
.
y
-
offsetRotation
.
y
);
if
(
scope
.
axis
==
"
Z
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
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
.
update
();
scope
.
dispatchEvent
(
changeEvent
);
}
}
function
onPointerUp
(
event
)
{
function
onPointerUp
(
event
)
{
scope
.
axis
=
false
;
scope
.
axis
=
undefined
;
_dragging
=
false
;
_dragging
=
false
;
scope
.
update
();
scope
.
update
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录