Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
4509d055
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,体验更适合开发者的 AI 搜索 >>
提交
4509d055
编写于
4月 22, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
EditorControls and TransformControls clean up.
上级
14f0ebfe
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
109 addition
and
98 deletion
+109
-98
examples/js/controls/EditorControls.js
examples/js/controls/EditorControls.js
+1
-1
examples/js/controls/TransformControls.js
examples/js/controls/TransformControls.js
+108
-97
未找到文件。
examples/js/controls/EditorControls.js
浏览文件 @
4509d055
...
...
@@ -7,7 +7,7 @@
THREE
.
EditorControls
=
function
(
object
,
domElement
)
{
var
domElement
=
(
domElement
!==
undefined
)
?
domElement
:
document
;
domElement
=
(
domElement
!==
undefined
)
?
domElement
:
document
;
// API
...
...
examples/js/controls/TransformControls.js
浏览文件 @
4509d055
...
...
@@ -20,9 +20,9 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
this
.
scale
=
1
;
this
.
snapDist
=
null
;
this
.
modifierAxis
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
gizmo
=
new
THREE
.
Object3D
();
this
.
modifierAxis
=
new
THREE
.
Vector3
(
1
,
1
,
1
);
this
.
gizmo
=
new
THREE
.
Object3D
();
var
scope
=
this
;
var
showPickers
=
false
;
// debug
...
...
@@ -40,7 +40,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
var
lookAtMatrix
=
new
THREE
.
Matrix4
();
var
eye
=
new
THREE
.
Vector3
()
var
tempMatrix
=
new
THREE
.
Matrix4
();
var
tempVector
=
new
THREE
.
Vector3
();
var
tempQuaternion
=
new
THREE
.
Quaternion
();
...
...
@@ -125,7 +125,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
var
magenta
=
[
1
,
0
,
1
,
0.2
];
var
yellow
=
[
1
,
1
,
0
,
0.2
];
var
mesh
;
var
geometry
,
mesh
;
// line axes
...
...
@@ -151,22 +151,24 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
displayAxes
[
'
translate
'
].
add
(
mesh
);
pickerAxes
[
'
translate
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneGeometry
(
0.2
,
0.2
),
HandleMaterial
(
yellow
)
);
geometry
=
new
THREE
.
PlaneGeometry
(
0.2
,
0.2
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
yellow
)
);
mesh
.
position
.
set
(
0.1
,
0.1
,
0
);
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TXY
'
;
displayAxes
[
'
translate
'
].
add
(
mesh
);
pickerAxes
[
'
translate
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneGeometry
(
0.2
,
0.2
)
,
HandleMaterial
(
cyan
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
cyan
)
);
mesh
.
position
.
set
(
0
,
0.1
,
0.1
);
mesh
.
rotation
.
y
=
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TYZ
'
;
displayAxes
[
'
translate
'
].
add
(
mesh
);
pickerAxes
[
'
translate
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneGeometry
(
0.2
,
0.2
)
,
HandleMaterial
(
magenta
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
magenta
)
);
mesh
.
position
.
set
(
0.1
,
0
,
0.1
);
mesh
.
rotation
.
x
=
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
...
...
@@ -174,40 +176,44 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
displayAxes
[
'
translate
'
].
add
(
mesh
);
pickerAxes
[
'
translate
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0
,
0.05
,
0.2
,
4
,
1
,
true
),
HandleMaterial
(
red
)
);
geometry
=
new
THREE
.
CylinderGeometry
(
0
,
0.05
,
0.2
,
4
,
1
,
true
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
red
)
);
mesh
.
position
.
x
=
0.9
;
mesh
.
rotation
.
z
=
-
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TX
'
;
displayAxes
[
'
translate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0
,
0.05
,
0.2
,
4
,
1
,
true
)
,
HandleMaterial
(
green
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
green
)
);
mesh
.
position
.
y
=
0.9
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TY
'
;
displayAxes
[
'
translate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0
,
0.05
,
0.2
,
4
,
1
,
true
)
,
HandleMaterial
(
blue
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
blue
)
);
mesh
.
position
.
z
=
0.9
;
mesh
.
rotation
.
x
=
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TZ
'
;
displayAxes
[
'
translate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0.04
,
0.04
,
0.8
,
4
,
1
,
false
),
HandleMaterial
(
red
)
);
geometry
=
new
THREE
.
CylinderGeometry
(
0.04
,
0.04
,
0.8
,
4
,
1
,
false
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
red
)
);
mesh
.
position
.
x
=
0.6
;
mesh
.
rotation
.
z
=
-
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TX
'
;
pickerAxes
[
'
translate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0.04
,
0.04
,
0.8
,
4
,
1
,
false
)
,
HandleMaterial
(
green
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
green
)
);
mesh
.
position
.
y
=
0.6
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
TY
'
;
pickerAxes
[
'
translate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CylinderGeometry
(
0.04
,
0.04
,
0.8
,
4
,
1
,
false
)
,
HandleMaterial
(
blue
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
blue
)
);
mesh
.
position
.
z
=
0.6
;
mesh
.
rotation
.
x
=
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
...
...
@@ -216,26 +222,28 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
// scale manipulators
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CubeGeometry
(
0.1
,
0.1
,
0.1
),
HandleMaterial
(
white
)
);
geometry
=
new
THREE
.
CubeGeometry
(
0.1
,
0.1
,
0.1
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
white
)
);
mesh
.
name
=
'
SXYZ
'
;
displayAxes
[
'
scale
'
].
add
(
mesh
);
pickerAxes
[
'
scale
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CubeGeometry
(
0.1
,
0.1
,
0.1
)
,
HandleMaterial
(
red
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
red
)
);
mesh
.
position
.
set
(
1
,
0
,
0
);
bakeTransformations
(
mesh
);
mesh
.
name
=
'
SX
'
;
displayAxes
[
'
scale
'
].
add
(
mesh
);
pickerAxes
[
'
scale
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CubeGeometry
(
0.1
,
0.1
,
0.1
)
,
HandleMaterial
(
green
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
green
)
);
mesh
.
position
.
set
(
0
,
1
,
0
);
bakeTransformations
(
mesh
);
mesh
.
name
=
'
SY
'
;
displayAxes
[
'
scale
'
].
add
(
mesh
);
pickerAxes
[
'
scale
'
].
add
(
mesh
.
clone
()
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
CubeGeometry
(
0.1
,
0.1
,
0.1
)
,
HandleMaterial
(
blue
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
blue
)
);
mesh
.
position
.
set
(
0
,
0
,
1
);
bakeTransformations
(
mesh
);
mesh
.
name
=
'
SZ
'
;
...
...
@@ -244,9 +252,9 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
// rotate manipulators
var
Circle
=
function
(
radius
,
facing
,
arc
)
{
var
geometry
=
new
THREE
.
Geometry
();
var
Circle
=
function
(
radius
,
facing
,
arc
)
{
geometry
=
new
THREE
.
Geometry
();
arc
=
arc
?
arc
:
1
;
for
(
var
i
=
0
;
i
<=
64
*
arc
;
++
i
)
{
if
(
facing
==
'
x
'
)
geometry
.
vertices
.
push
(
new
THREE
.
Vector3
(
0
,
Math
.
cos
(
i
/
32
*
Math
.
PI
),
Math
.
sin
(
i
/
32
*
Math
.
PI
)
).
multiplyScalar
(
radius
)
);
...
...
@@ -277,21 +285,23 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
mesh
.
name
=
'
RE
'
;
displayAxes
[
'
rotate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
TorusGeometry
(
1
,
0.05
,
4
,
6
,
Math
.
PI
),
HandleMaterial
(
cyan
)
);
geometry
=
new
THREE
.
TorusGeometry
(
1
,
0.05
,
4
,
6
,
Math
.
PI
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
cyan
)
);
mesh
.
rotation
.
z
=
-
Math
.
PI
/
2
;
mesh
.
rotation
.
y
=
-
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
RX
'
;
pickerAxes
[
'
rotate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
TorusGeometry
(
1
,
0.05
,
4
,
6
,
Math
.
PI
)
,
HandleMaterial
(
magenta
)
);
mesh
.
rotation
.
z
=
Math
.
PI
;
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
magenta
)
);
mesh
.
rotation
.
z
=
Math
.
PI
;
mesh
.
rotation
.
x
=
-
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
RY
'
;
pickerAxes
[
'
rotate
'
].
add
(
mesh
);
mesh
=
new
THREE
.
Mesh
(
new
THREE
.
TorusGeometry
(
1
,
0.05
,
4
,
6
,
Math
.
PI
)
,
HandleMaterial
(
yellow
)
);
mesh
=
new
THREE
.
Mesh
(
geometry
,
HandleMaterial
(
yellow
)
);
mesh
.
rotation
.
z
=
-
Math
.
PI
/
2
;
bakeTransformations
(
mesh
);
mesh
.
name
=
'
RZ
'
;
...
...
@@ -311,7 +321,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
// intersection planes
{
var
planes
=
new
THREE
.
Object3D
();
this
.
gizmo
.
add
(
planes
);
...
...
@@ -333,26 +343,26 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
}
this
.
attatch
=
function
(
object
)
{
this
.
attatch
=
function
(
object
)
{
this
.
object
=
object
;
this
.
object
=
object
;
this
.
updateMode
();
this
.
domElement
.
addEventListener
(
'
mousedown
'
,
onMouseDown
,
false
);
document
.
addEventListener
(
'
keydown
'
,
onKeyDown
,
false
);
}
}
this
.
detatch
=
function
(
object
)
{
this
.
detatch
=
function
(
object
)
{
this
.
hide
();
this
.
domElement
.
removeEventListener
(
'
mousedown
'
,
onMouseDown
,
false
);
document
.
removeEventListener
(
'
keydown
'
,
onKeyDown
,
false
);
}
}
this
.
updateGizmo
=
function
()
{
this
.
updateGizmo
=
function
()
{
this
.
object
.
updateMatrixWorld
();
worldPosition
.
getPositionFromMatrix
(
this
.
object
.
matrixWorld
);
...
...
@@ -367,13 +377,14 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
this
.
gizmo
.
scale
.
set
(
scale
,
scale
,
scale
);
for
(
var
i
in
this
.
gizmo
.
children
)
{
for
(
var
j
in
this
.
gizmo
.
children
[
i
].
children
)
{
object
=
this
.
gizmo
.
children
[
i
].
children
[
j
];
name
=
object
.
name
;
if
(
name
.
search
(
'
E
'
)
!=
-
1
){
lookAtMatrix
.
lookAt
(
camPosition
,
worldPosition
,
tempVector
.
set
(
0
,
1
,
0
));
object
.
rotation
.
setEulerFromRotationMatrix
(
lookAtMatrix
);
...
...
@@ -392,21 +403,21 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
if
(
name
==
'
RX
'
)
{
quaternionX
.
setFromAxisAngle
(
unitX
,
Math
.
atan2
(
-
eye
.
y
,
eye
.
z
)
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionX
);
}
if
(
name
==
'
RY
'
)
{
quaternionY
.
setFromAxisAngle
(
unitY
,
Math
.
atan2
(
eye
.
x
,
eye
.
z
)
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionY
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionY
);
}
if
(
name
==
'
RZ
'
)
{
quaternionZ
.
setFromAxisAngle
(
unitZ
,
Math
.
atan2
(
eye
.
y
,
eye
.
x
)
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
}
}
object
.
rotation
.
setEulerFromQuaternion
(
tempQuaternion
);
}
else
if
(
this
.
space
==
'
world
'
)
{
...
...
@@ -434,10 +445,10 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
}
this
.
callback
();
}
this
.
hide
=
function
()
{
}
this
.
hide
=
function
()
{
for
(
var
i
in
displayAxes
)
{
...
...
@@ -459,79 +470,79 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
}
}
}
this
.
updateMode
=
function
()
{
this
.
updateMode
=
function
()
{
this
.
hide
();
this
.
hide
();
if
(
scope
.
mode
==
'
scale
'
)
scope
.
space
=
'
local
'
;
if
(
scope
.
mode
==
'
scale
'
)
scope
.
space
=
'
local
'
;
for
(
var
i
in
displayAxes
[
this
.
mode
].
children
)
{
displayAxes
[
this
.
mode
].
children
[
i
].
visible
=
true
;
}
for
(
var
i
in
pickerAxes
[
this
.
mode
].
children
)
{
pickerAxes
[
this
.
mode
].
children
[
i
].
visible
=
showPickers
;
}
scope
.
updateGizmo
();
}
}
this
.
setIntersectionPlane
=
function
()
{
this
.
setIntersectionPlane
=
function
()
{
if
(
isActive
(
"
X
"
)
||
isActive
(
"
Y
"
)
)
{
if
(
isActive
(
"
X
"
)
||
isActive
(
"
Y
"
)
)
{
currentPlane
=
'
XY
'
;
currentPlane
=
'
XY
'
;
}
}
if
(
isActive
(
"
Z
"
)
)
{
if
(
isActive
(
"
Z
"
)
)
{
currentPlane
=
'
YZ
'
;
currentPlane
=
'
YZ
'
;
}
}
if
(
isActive
(
"
XZ
"
)
)
{
if
(
isActive
(
"
XZ
"
)
)
{
currentPlane
=
'
XZ
'
;
currentPlane
=
'
XZ
'
;
}
}
if
(
isActive
(
"
XYZ
"
)
||
isActive
(
"
E
"
)
)
{
if
(
isActive
(
"
XYZ
"
)
||
isActive
(
"
E
"
)
)
{
currentPlane
=
'
XYZE
'
;
currentPlane
=
'
XYZE
'
;
}
}
if
(
isActive
(
"
RX
"
)
)
{
if
(
isActive
(
"
RX
"
)
)
{
currentPlane
=
'
YZ
'
;
currentPlane
=
'
YZ
'
;
}
}
if
(
isActive
(
"
RY
"
)
)
{
if
(
isActive
(
"
RY
"
)
)
{
currentPlane
=
'
XZ
'
;
currentPlane
=
'
XZ
'
;
}
}
if
(
isActive
(
"
RZ
"
)
)
{
if
(
isActive
(
"
RZ
"
)
)
{
currentPlane
=
'
XY
'
;
currentPlane
=
'
XY
'
;
}
}
scope
.
updateGizmo
();
scope
.
updateGizmo
();
}
}
function
onMouseDown
(
event
)
{
function
onMouseDown
(
event
)
{
event
.
preventDefault
();
...
...
@@ -555,14 +566,14 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
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
);
oldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrix
);
worldRotationMatrix
.
extractRotation
(
scope
.
object
.
matrixWorld
);
parentRotationMatrix
.
extractRotation
(
scope
.
object
.
parent
.
matrixWorld
);
parentScale
.
getScaleFromMatrix
(
tempMatrix
.
getInverse
(
scope
.
object
.
parent
.
matrixWorld
)
);
parentRotationMatrix
.
extractRotation
(
scope
.
object
.
parent
.
matrixWorld
);
parentScale
.
getScaleFromMatrix
(
tempMatrix
.
getInverse
(
scope
.
object
.
parent
.
matrixWorld
)
);
offset
.
copy
(
planeIntersect
.
point
);
...
...
@@ -589,7 +600,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
point
.
copy
(
planeIntersect
.
point
);
if
(
(
scope
.
mode
==
'
translate
'
)
&&
isActive
(
"
T
"
)
)
{
point
.
sub
(
offset
);
point
.
multiply
(
parentScale
);
...
...
@@ -619,11 +630,11 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
scope
.
object
.
position
.
copy
(
oldPosition
);
scope
.
object
.
position
.
add
(
point
);
if
(
scope
.
snapDist
)
{
if
(
isActive
(
"
X
"
)
)
scope
.
object
.
position
.
x
=
Math
.
round
(
scope
.
object
.
position
.
x
/
scope
.
snapDist
)
*
scope
.
snapDist
;
if
(
isActive
(
"
Y
"
)
)
scope
.
object
.
position
.
y
=
Math
.
round
(
scope
.
object
.
position
.
y
/
scope
.
snapDist
)
*
scope
.
snapDist
;
if
(
isActive
(
"
Z
"
)
)
scope
.
object
.
position
.
z
=
Math
.
round
(
scope
.
object
.
position
.
z
/
scope
.
snapDist
)
*
scope
.
snapDist
;
if
(
isActive
(
"
Y
"
)
)
scope
.
object
.
position
.
y
=
Math
.
round
(
scope
.
object
.
position
.
y
/
scope
.
snapDist
)
*
scope
.
snapDist
;
if
(
isActive
(
"
Z
"
)
)
scope
.
object
.
position
.
z
=
Math
.
round
(
scope
.
object
.
position
.
z
/
scope
.
snapDist
)
*
scope
.
snapDist
;
}
}
...
...
@@ -636,7 +647,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
if
(
scope
.
space
==
'
local
'
)
{
if
(
isActive
(
"
XYZ
"
))
{
scale
=
1
+
(
(
point
.
y
)
/
50
);
scope
.
object
.
scale
.
x
=
oldScale
.
x
*
scale
;
...
...
@@ -644,7 +655,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
scope
.
object
.
scale
.
z
=
oldScale
.
z
*
scale
;
}
else
{
point
.
applyMatrix4
(
tempMatrix
.
getInverse
(
worldRotationMatrix
)
);
if
(
!
(
isActive
(
"
X
"
))
||
scope
.
modifierAxis
.
x
!=
1
)
point
.
x
=
0
;
...
...
@@ -681,7 +692,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionE
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
scope
.
object
.
rotation
.
setEulerFromQuaternion
(
tempQuaternion
);
}
else
if
(
scope
.
active
==
"
RXYZ
"
)
{
...
...
@@ -705,7 +716,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
if
(
scope
.
active
==
"
RX
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionX
);
if
(
scope
.
active
==
"
RY
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionY
);
if
(
scope
.
active
==
"
RZ
"
)
quaternionXYZ
.
multiplyQuaternions
(
quaternionXYZ
,
quaternionZ
);
scope
.
object
.
rotation
.
setEulerFromQuaternion
(
quaternionXYZ
);
}
else
if
(
scope
.
space
==
'
world
'
)
{
...
...
@@ -725,7 +736,7 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
if
(
scope
.
active
==
"
RZ
"
)
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionZ
);
tempQuaternion
.
multiplyQuaternions
(
tempQuaternion
,
quaternionXYZ
);
scope
.
object
.
rotation
.
setEulerFromQuaternion
(
tempQuaternion
);
}
...
...
@@ -762,26 +773,26 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
if
(
event
.
keyCode
==
69
)
{
// E
if
(
scope
.
mode
==
'
rotate
'
)
scope
.
space
=
(
scope
.
space
==
'
world
'
)
?
'
local
'
:
'
world
'
;
if
(
scope
.
mode
==
'
rotate
'
)
scope
.
space
=
(
scope
.
space
==
'
world
'
)
?
'
local
'
:
'
world
'
;
scope
.
mode
=
'
rotate
'
;
}
if
(
event
.
keyCode
==
82
)
{
// R
scope
.
mode
=
'
scale
'
;
scope
.
space
=
'
local
'
;
}
if
(
event
.
keyCode
==
187
||
event
.
keyCode
==
107
)
{
// +,=,num+
scope
.
scale
+=
0.1
}
if
(
event
.
keyCode
==
189
||
event
.
keyCode
==
109
)
{
// -,_,num-
scope
.
scale
-=
0.1
scope
.
scale
=
Math
.
max
(
scope
.
scale
,
0.1
);
...
...
@@ -801,10 +812,10 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
projector
.
unprojectVector
(
pointerVector
,
scope
.
camera
);
ray
.
set
(
camPosition
,
pointerVector
.
sub
(
camPosition
).
normalize
()
);
var
intersections
=
ray
.
intersectObjects
(
objects
,
true
);
return
intersections
[
0
]
?
intersections
[
0
]
:
false
;
}
function
isActive
(
name
)
{
...
...
@@ -825,4 +836,4 @@ THREE.TransformControls = function ( camera, domElement, callback ) {
};
THREE
.
TransformControls
.
prototype
=
Object
.
create
(
THREE
.
EventDispatcher
.
prototype
);
\ No newline at end of file
THREE
.
TransformControls
.
prototype
=
Object
.
create
(
THREE
.
EventDispatcher
.
prototype
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录