Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
85441c17
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,发现更多精彩内容 >>
提交
85441c17
编写于
5月 25, 2012
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added event.preventDefault to TrackballControls as per suggestion in #1986.
上级
28236ba1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
6 addition
and
2 deletion
+6
-2
build/Three.js
build/Three.js
+2
-1
build/custom/ThreeExtras.js
build/custom/ThreeExtras.js
+2
-1
src/extras/controls/TrackballControls.js
src/extras/controls/TrackballControls.js
+2
-0
未找到文件。
build/Three.js
浏览文件 @
85441c17
...
...
@@ -615,7 +615,8 @@ d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.m
b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=m:o.addSelf(a.sub(m,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan){c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance);g.lengthSq()<c.minDistance*c.minDistance&&c.object.position.add(c.target,g.setLength(c.minDistance))}};this.update=function(){g.copy(c.object.position).subSelf(c.target);
c.noRotate||c.rotateCamera();c.noZoom||c.zoomCamera();c.noPan||c.panCamera();c.object.position.add(c.target,g);c.checkDistances();c.object.lookAt(c.target);if(d.distanceTo(c.object.position)>0){c.dispatchEvent(p);d.copy(c.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",function(a){if(c.enabled){if(e){h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY);j=l=c.getMouseOnScreen(a.clientX,a.clientY);o=
m=c.getMouseOnScreen(a.clientX,a.clientY);e=false}f!==-1&&(f===0&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):f===2&&!c.noPan&&(m=c.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();if(f===-1){f=a.button;f===0&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?j=l=c.getMouseOnScreen(a.clientX,
a
.
clientY
):
this
.
noPan
||
(
o
=
m
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
))}}},
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
function
(
a
){
if
(
c
.
enabled
){
a
.
preventDefault
();
a
.
stopPropagation
();
f
=-
1
}},
false
);
window
.
addEventListener
(
"
keydown
"
,
function
(
a
){
if
(
c
.
enabled
&&
f
===-
1
){
a
.
keyCode
===
c
.
keys
[
0
]
&&!
c
.
noRotate
?
f
=
0
:
a
.
keyCode
===
c
.
keys
[
1
]
&&!
c
.
noZoom
?
f
=
1
:
a
.
keyCode
===
c
.
keys
[
2
]
&&!
c
.
noPan
&&
(
f
=
2
);
f
!==-
1
&&
(
e
=
true
)}},
false
);
window
.
addEventListener
(
"
keyup
"
,
function
(){
c
.
enabled
&&
f
!==-
1
&&
(
f
=-
1
)},
false
)};
a.clientY):this.noPan||(o=m=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled){a.preventDefault();if(f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)},
false)};
THREE.OrbitControls=function(a,b){var c,d,e;function f(){return 2*Math.PI/60/60*i.autoRotateSpeed}function g(a){a.preventDefault();if(s===c){o.set(a.clientX,a.clientY);m.sub(o,l);i.rotateLeft(2*Math.PI*m.x/j*i.userRotateSpeed);i.rotateUp(2*Math.PI*m.y/j*i.userRotateSpeed);l.copy(o)}else if(s===d){r.set(a.clientX,a.clientY);n.sub(r,p);n.y>0?i.zoomIn():i.zoomOut();p.copy(r)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false);
s=e}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,j=1800,l=new THREE.Vector2,o=new THREE.Vector2,m=new THREE.Vector2,p=new THREE.Vector2,r=new THREE.Vector2,n=new THREE.Vector2,q=0,t=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var s=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f());
t=t-a};this.rotateRight=function(a){a===void 0&&(a=f());t=t+a};this.rotateUp=function(a){a===void 0&&(a=f());q=q-a};this.rotateDown=function(a){a===void 0&&(a=f());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f());
...
...
build/custom/ThreeExtras.js
浏览文件 @
85441c17
...
...
@@ -172,7 +172,8 @@ d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.m
b
.
addSelf
(
c
.
object
.
up
.
clone
().
setLength
(
a
.
y
));
c
.
object
.
position
.
addSelf
(
b
);
c
.
target
.
addSelf
(
b
);
c
.
staticMoving
?
n
=
k
:
n
.
addSelf
(
a
.
sub
(
k
,
n
).
multiplyScalar
(
c
.
dynamicDampingFactor
))}};
this
.
checkDistances
=
function
(){
if
(
!
c
.
noZoom
||!
c
.
noPan
){
c
.
object
.
position
.
lengthSq
()
>
c
.
maxDistance
*
c
.
maxDistance
&&
c
.
object
.
position
.
setLength
(
c
.
maxDistance
);
g
.
lengthSq
()
<
c
.
minDistance
*
c
.
minDistance
&&
c
.
object
.
position
.
add
(
c
.
target
,
g
.
setLength
(
c
.
minDistance
))}};
this
.
update
=
function
(){
g
.
copy
(
c
.
object
.
position
).
subSelf
(
c
.
target
);
c
.
noRotate
||
c
.
rotateCamera
();
c
.
noZoom
||
c
.
zoomCamera
();
c
.
noPan
||
c
.
panCamera
();
c
.
object
.
position
.
add
(
c
.
target
,
g
);
c
.
checkDistances
();
c
.
object
.
lookAt
(
c
.
target
);
if
(
d
.
distanceTo
(
c
.
object
.
position
)
>
0
){
c
.
dispatchEvent
(
m
);
d
.
copy
(
c
.
object
.
position
)}};
this
.
domElement
.
addEventListener
(
"
contextmenu
"
,
function
(
a
){
a
.
preventDefault
()},
false
);
this
.
domElement
.
addEventListener
(
"
mousemove
"
,
function
(
a
){
if
(
c
.
enabled
){
if
(
e
){
h
=
i
=
c
.
getMouseProjectionOnBall
(
a
.
clientX
,
a
.
clientY
);
j
=
l
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
);
n
=
k
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
);
e
=
false
}
f
!==-
1
&&
(
f
===
0
&&!
c
.
noRotate
?
i
=
c
.
getMouseProjectionOnBall
(
a
.
clientX
,
a
.
clientY
):
f
===
1
&&!
c
.
noZoom
?
l
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
):
f
===
2
&&!
c
.
noPan
&&
(
k
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
)))}},
false
);
this
.
domElement
.
addEventListener
(
"
mousedown
"
,
function
(
a
){
if
(
c
.
enabled
){
a
.
preventDefault
();
a
.
stopPropagation
();
if
(
f
===-
1
){
f
=
a
.
button
;
f
===
0
&&!
c
.
noRotate
?
h
=
i
=
c
.
getMouseProjectionOnBall
(
a
.
clientX
,
a
.
clientY
):
f
===
1
&&!
c
.
noZoom
?
j
=
l
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
):
this
.
noPan
||
(
n
=
k
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
))}}},
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
function
(
a
){
if
(
c
.
enabled
){
a
.
preventDefault
();
a
.
stopPropagation
();
f
=-
1
}},
false
);
window
.
addEventListener
(
"
keydown
"
,
function
(
a
){
if
(
c
.
enabled
&&
f
===-
1
){
a
.
keyCode
===
c
.
keys
[
0
]
&&!
c
.
noRotate
?
f
=
0
:
a
.
keyCode
===
c
.
keys
[
1
]
&&!
c
.
noZoom
?
f
=
1
:
a
.
keyCode
===
c
.
keys
[
2
]
&&!
c
.
noPan
&&
(
f
=
2
);
f
!==-
1
&&
(
e
=
true
)}},
false
);
window
.
addEventListener
(
"
keyup
"
,
function
(){
c
.
enabled
&&
f
!==-
1
&&
(
f
=-
1
)},
false
)};
a
.
clientY
):
this
.
noPan
||
(
n
=
k
=
c
.
getMouseOnScreen
(
a
.
clientX
,
a
.
clientY
))}}},
false
);
this
.
domElement
.
addEventListener
(
"
mouseup
"
,
function
(
a
){
if
(
c
.
enabled
){
a
.
preventDefault
();
a
.
stopPropagation
();
f
=-
1
}},
false
);
window
.
addEventListener
(
"
keydown
"
,
function
(
a
){
if
(
c
.
enabled
){
a
.
preventDefault
();
if
(
f
===-
1
){
a
.
keyCode
===
c
.
keys
[
0
]
&&!
c
.
noRotate
?
f
=
0
:
a
.
keyCode
===
c
.
keys
[
1
]
&&!
c
.
noZoom
?
f
=
1
:
a
.
keyCode
===
c
.
keys
[
2
]
&&!
c
.
noPan
&&
(
f
=
2
);
f
!==-
1
&&
(
e
=
true
)}}},
false
);
window
.
addEventListener
(
"
keyup
"
,
function
(){
c
.
enabled
&&
f
!==-
1
&&
(
f
=-
1
)},
false
)};
THREE
.
OrbitControls
=
function
(
b
,
a
){
var
c
,
d
,
e
;
function
f
(){
return
2
*
Math
.
PI
/
60
/
60
*
i
.
autoRotateSpeed
}
function
g
(
a
){
a
.
preventDefault
();
if
(
o
===
c
){
n
.
set
(
a
.
clientX
,
a
.
clientY
);
k
.
sub
(
n
,
l
);
i
.
rotateLeft
(
2
*
Math
.
PI
*
k
.
x
/
j
*
i
.
userRotateSpeed
);
i
.
rotateUp
(
2
*
Math
.
PI
*
k
.
y
/
j
*
i
.
userRotateSpeed
);
l
.
copy
(
n
)}
else
if
(
o
===
d
){
p
.
set
(
a
.
clientX
,
a
.
clientY
);
q
.
sub
(
p
,
m
);
q
.
y
>
0
?
i
.
zoomIn
():
i
.
zoomOut
();
m
.
copy
(
p
)}}
function
h
(){
if
(
i
.
userRotate
){
document
.
removeEventListener
(
"
mousemove
"
,
g
,
false
);
document
.
removeEventListener
(
"
mouseup
"
,
h
,
false
);
o
=
e
}}
THREE
.
EventTarget
.
call
(
this
);
this
.
object
=
b
;
this
.
domElement
=
a
!==
void
0
?
a
:
document
;
this
.
center
=
new
THREE
.
Vector3
;
this
.
userZoom
=
true
;
this
.
userZoomSpeed
=
1
;
this
.
userRotate
=
true
;
this
.
userRotateSpeed
=
1
;
this
.
autoRotate
=
false
;
this
.
autoRotateSpeed
=
2
;
var
i
=
this
,
j
=
1800
,
l
=
new
THREE
.
Vector2
,
n
=
new
THREE
.
Vector2
,
k
=
new
THREE
.
Vector2
,
m
=
new
THREE
.
Vector2
,
p
=
new
THREE
.
Vector2
,
q
=
new
THREE
.
Vector2
,
r
=
0
,
s
=
0
,
t
=
1
,
v
=
new
THREE
.
Vector3
;
e
=-
1
;
c
=
0
;
d
=
1
;
var
o
=
e
,
x
=
{
type
:
"
change
"
};
this
.
rotateLeft
=
function
(
a
){
a
===
void
0
&&
(
a
=
f
());
s
=
s
-
a
};
this
.
rotateRight
=
function
(
a
){
a
===
void
0
&&
(
a
=
f
());
s
=
s
+
a
};
this
.
rotateUp
=
function
(
a
){
a
===
void
0
&&
(
a
=
f
());
r
=
r
-
a
};
this
.
rotateDown
=
function
(
a
){
a
===
void
0
&&
(
a
=
f
());
r
=
r
+
a
};
this
.
zoomIn
=
function
(
a
){
a
===
void
0
&&
(
a
=
Math
.
pow
(
0.95
,
i
.
userZoomSpeed
));
t
=
t
/
a
};
this
.
zoomOut
=
function
(
a
){
a
===
void
0
&&
(
a
=
Math
.
pow
(
0.95
,
i
.
userZoomSpeed
));
t
=
t
*
a
};
this
.
update
=
function
(){
var
a
=
this
.
object
.
position
,
b
=
a
.
clone
().
subSelf
(
this
.
center
),
c
=
Math
.
atan2
(
b
.
x
,
b
.
z
),
d
=
Math
.
atan2
(
Math
.
sqrt
(
b
.
x
*
b
.
x
+
b
.
z
*
b
.
z
),
b
.
y
);
this
.
autoRotate
&&
this
.
rotateLeft
(
f
());
...
...
src/extras/controls/TrackballControls.js
浏览文件 @
85441c17
...
...
@@ -258,6 +258,8 @@ THREE.TrackballControls = function ( object, domElement ) {
if
(
!
_this
.
enabled
)
return
;
event
.
preventDefault
();
if
(
_state
!==
STATE
.
NONE
)
{
return
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录