Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
24134473
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,发现更多精彩内容 >>
提交
24134473
编写于
2月 05, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DragControls: Clean up.
上级
48aa7642
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
33 deletion
+33
-33
examples/js/controls/DragControls.js
examples/js/controls/DragControls.js
+33
-33
未找到文件。
examples/js/controls/DragControls.js
浏览文件 @
24134473
...
...
@@ -23,23 +23,23 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var
me
=
this
;
this
.
on
=
function
(
event
,
handler
)
{
if
(
!
_listeners
[
event
]
)
_listeners
[
event
]
=
[];
_listeners
[
event
].
push
(
handler
);
return
me
;
};
this
.
off
=
function
(
event
,
handler
)
{
var
l
=
_listeners
[
event
];
if
(
!
l
)
return
me
;
if
(
l
.
indexOf
(
handler
)
>
-
1
)
{
l
.
splice
(
handler
,
1
);
}
return
me
;
...
...
@@ -47,52 +47,52 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
};
var
notify
=
function
(
event
,
data
,
member
)
{
var
l
=
_listeners
[
event
];
if
(
!
l
)
return
;
if
(
!
member
)
{
for
(
var
i
=
0
;
i
<
l
.
length
;
i
++
)
{
l
[
i
](
data
);
}
}
};
this
.
setObjects
=
function
(
objects
)
{
if
(
objects
instanceof
THREE
.
Scene
)
{
_objects
=
objects
.
children
;
}
else
{
_objects
=
objects
;
}
};
this
.
setObjects
(
_objects
);
this
.
activate
=
function
()
{
_domElement
.
addEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
_domElement
.
addEventListener
(
'
mousedown
'
,
onDocumentMouseDown
,
false
);
_domElement
.
addEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
};
this
.
deactivate
=
function
()
{
_domElement
.
removeEventListener
(
'
mousemove
'
,
onDocumentMouseMove
,
false
);
_domElement
.
removeEventListener
(
'
mousedown
'
,
onDocumentMouseDown
,
false
);
_domElement
.
removeEventListener
(
'
mouseup
'
,
onDocumentMouseUp
,
false
);
};
this
.
dispose
=
function
()
{
...
...
@@ -115,7 +115,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
if
(
_selected
&&
me
.
enabled
)
{
var
normal
=
_selected
.
normal
;
// I found this article useful about plane-line intersections
...
...
@@ -127,7 +127,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
// bail
console
.
log
(
'
no or infinite solutions
'
);
return
;
}
var
num
=
normal
.
dot
(
p3subp1
.
copy
(
_selected
.
point
).
sub
(
ray
.
origin
)
);
...
...
@@ -139,24 +139,24 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var
xLock
,
yLock
,
zLock
=
false
;
var
moveX
,
moveY
,
moveZ
;
if
(
xLock
)
{
moveX
=
true
;
moveY
=
false
;
moveZ
=
false
;
}
else
if
(
yLock
)
{
moveX
=
false
;
moveY
=
true
;
moveZ
=
false
;
}
else
{
moveX
=
moveY
=
moveZ
=
true
;
}
// Reverse Matrix?
...
...
@@ -180,7 +180,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
notify
(
'
hoveron
'
,
_hovered
);
}
else
{
notify
(
'
hoveroff
'
,
_hovered
);
_hovered
=
null
;
_domElement
.
style
.
cursor
=
'
auto
'
;
...
...
@@ -202,7 +202,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
var
normal
=
ray
.
direction
;
// normal ray to the camera position
if
(
intersects
.
length
>
0
)
{
_selected
=
intersects
[
0
];
_selected
.
ray
=
ray
;
_selected
.
normal
=
normal
;
...
...
@@ -225,7 +225,7 @@ THREE.DragControls = function( _camera, _objects, _domElement ) {
notify
(
'
dragend
'
,
_selected
);
_selected
=
null
;
}
_domElement
.
style
.
cursor
=
'
auto
'
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录