Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
3eff5909
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,发现更多精彩内容 >>
提交
3eff5909
编写于
9月 05, 2013
作者:
A
Aleksandar Rodic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added touch support for transform controls
improved touch support for editor controls
上级
1fc4e4e1
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
220 addition
and
196 deletion
+220
-196
editor/js/Viewport.js
editor/js/Viewport.js
+4
-11
examples/js/controls/EditorControls.js
examples/js/controls/EditorControls.js
+42
-18
examples/js/controls/TransformControls.js
examples/js/controls/TransformControls.js
+174
-167
未找到文件。
editor/js/Viewport.js
浏览文件 @
3eff5909
...
...
@@ -43,8 +43,9 @@ var Viewport = function ( editor ) {
var
transformControls
=
new
THREE
.
TransformControls
(
camera
,
container
.
dom
);
transformControls
.
addEventListener
(
'
change
'
,
function
()
{
// TODO: Differentiate from transform hovers change and object transform change
controls
.
enabled
=
true
;
if
(
transformControls
.
axis
)
controls
.
enabled
=
false
;
if
(
editor
.
selected
)
signals
.
objectChanged
.
dispatch
(
editor
.
selected
);
}
);
...
...
@@ -98,12 +99,7 @@ var Viewport = function ( editor ) {
y
=
(
event
.
clientY
-
rect
.
top
)
/
rect
.
height
;
onMouseDownPosition
.
set
(
x
,
y
);
if
(
transformControls
.
hovered
===
false
)
{
controls
.
enabled
=
true
;
document
.
addEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
}
document
.
addEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
};
...
...
@@ -144,8 +140,6 @@ var Viewport = function ( editor ) {
}
controls
.
enabled
=
false
;
document
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
);
};
...
...
@@ -175,7 +169,6 @@ var Viewport = function ( editor ) {
signals
.
objectChanged
.
dispatch
(
camera
);
}
);
controls
.
enabled
=
false
;
// signals
...
...
examples/js/controls/EditorControls.js
浏览文件 @
3eff5909
...
...
@@ -193,29 +193,37 @@ THREE.EditorControls = function ( object, domElement ) {
// touch
var
touch
=
new
THREE
.
Vector3
();
var
prevTouch
=
new
THREE
.
Vector3
();
var
touches
=
[
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
()
];
var
prevTouches
=
[
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
(),
new
THREE
.
Vector3
()
];
var
prevDistance
=
null
;
function
touchStart
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
var
touches
=
event
.
touches
;
switch
(
event
.
touches
.
length
)
{
switch
(
touches
.
length
)
{
case
1
:
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
);
touches
[
1
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
);
break
;
case
2
:
var
dx
=
touches
[
0
].
pageX
-
touches
[
1
].
pageX
;
var
dy
=
touches
[
0
].
pageY
-
touches
[
1
].
pageY
;
prevDistance
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
)
;
touches
[
1
].
set
(
event
.
touches
[
1
].
pageX
,
event
.
touches
[
1
].
pageY
,
0
)
;
prevDistance
=
touches
[
0
].
distanceTo
(
touches
[
1
]
);
break
;
}
prevTouch
.
set
(
touches
[
0
].
pageX
,
touches
[
0
].
pageY
,
0
);
prevTouches
[
0
].
copy
(
touches
[
0
]
);
prevTouches
[
1
].
copy
(
touches
[
1
]
);
}
function
touchMove
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
...
...
@@ -223,31 +231,47 @@ THREE.EditorControls = function ( object, domElement ) {
event
.
preventDefault
();
event
.
stopPropagation
();
var
touches
=
event
.
touches
;
var
getClosest
=
function
(
touch
,
touches
)
{
var
closest
=
touches
[
0
];
touch
.
set
(
touches
[
0
].
pageX
,
touches
[
0
].
pageY
,
0
);
for
(
var
i
in
touches
)
{
if
(
closest
.
distanceTo
(
touch
)
>
touches
[
i
].
distanceTo
(
touch
)
)
closest
=
touches
[
i
];
}
switch
(
touches
.
length
)
{
return
closest
;
}
switch
(
event
.
touches
.
length
)
{
case
1
:
scope
.
rotate
(
touch
.
sub
(
prevTouch
).
multiplyScalar
(
-
0.005
)
);
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
);
touches
[
1
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
);
scope
.
rotate
(
touches
[
0
].
sub
(
getClosest
(
touches
[
0
]
,
prevTouches
)
).
multiplyScalar
(
-
0.005
)
);
break
;
case
2
:
var
dx
=
touches
[
0
].
pageX
-
touches
[
1
].
pageX
;
var
dy
=
touches
[
0
].
pageY
-
touches
[
1
].
pageY
;
var
distance
=
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
)
;
touches
[
1
].
set
(
event
.
touches
[
1
].
pageX
,
event
.
touches
[
1
].
pageY
,
0
)
;
distance
=
touches
[
0
].
distanceTo
(
touches
[
1
]
);
scope
.
zoom
(
new
THREE
.
Vector3
(
0
,
0
,
prevDistance
-
distance
)
);
prevDistance
=
distance
;
break
;
case
3
:
scope
.
pan
(
touch
.
sub
(
prevTouch
).
setX
(
-
touch
.
x
)
);
var
offset0
=
touches
[
0
].
clone
().
sub
(
getClosest
(
touches
[
0
]
,
prevTouches
)
);
var
offset1
=
touches
[
1
].
clone
().
sub
(
getClosest
(
touches
[
1
]
,
prevTouches
)
);
offset0
.
x
=
-
offset0
.
x
;
offset1
.
x
=
-
offset1
.
x
;
scope
.
pan
(
offset0
.
add
(
offset1
).
multiplyScalar
(
0.5
)
);
break
;
}
prevTouch
.
set
(
touches
[
0
].
pageX
,
touches
[
0
].
pageY
,
0
);
prevTouches
[
0
].
copy
(
touches
[
0
]
);
prevTouches
[
1
].
copy
(
touches
[
1
]
);
}
...
...
examples/js/controls/TransformControls.js
浏览文件 @
3eff5909
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录