Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
74c50698
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,发现更多精彩内容 >>
未验证
提交
74c50698
编写于
9月 14, 2019
作者:
M
Michael Herzog
提交者:
GitHub
9月 14, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #17498 from Mugen87/dev38
Examples: Move EditorControls to editor/js.
上级
6ea23ca3
6d630491
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
2 addition
and
356 deletion
+2
-356
editor/index.html
editor/index.html
+1
-1
editor/js/EditorControls.js
editor/js/EditorControls.js
+1
-1
examples/jsm/controls/EditorControls.d.ts
examples/jsm/controls/EditorControls.d.ts
+0
-26
examples/jsm/controls/EditorControls.js
examples/jsm/controls/EditorControls.js
+0
-327
utils/modularize.js
utils/modularize.js
+0
-1
未找到文件。
editor/index.html
浏览文件 @
74c50698
...
...
@@ -16,7 +16,6 @@
<script
src=
"../build/three.js"
></script>
<script
src=
"../examples/js/controls/EditorControls.js"
></script>
<script
src=
"../examples/js/controls/TransformControls.js"
></script>
<script
src=
"../examples/js/libs/chevrotain.min.js"
></script>
<!-- VRML -->
...
...
@@ -94,6 +93,7 @@
<script
src=
"../examples/js/vr/WebVR.js"
></script>
<script
src=
"js/EditorControls.js"
></script>
<script
src=
"js/Storage.js"
></script>
<script
src=
"js/Editor.js"
></script>
...
...
e
xamples/js/control
s/EditorControls.js
→
e
ditor/j
s/EditorControls.js
浏览文件 @
74c50698
...
...
@@ -175,7 +175,7 @@ THREE.EditorControls = function ( object, domElement ) {
}
function
onMouseUp
(
event
)
{
function
onMouseUp
(
/* event */
)
{
domElement
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
,
false
);
domElement
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
...
...
examples/jsm/controls/EditorControls.d.ts
已删除
100644 → 0
浏览文件 @
6ea23ca3
import
{
Camera
,
EventDispatcher
,
Vector3
,
Object3D
}
from
'
../../../src/Three
'
;
export
class
EditorControls
extends
EventDispatcher
{
constructor
(
object
:
Camera
,
domElement
?:
HTMLElement
);
object
:
Camera
;
domElement
:
HTMLElement
|
HTMLDocument
;
enabled
:
boolean
;
center
:
Vector3
;
panSpeed
:
number
;
zoomSpeed
:
number
;
rotationSpeed
:
number
;
focus
(
target
:
Object3D
):
void
;
pan
(
delta
:
Vector3
):
void
;
zoom
(
delta
:
Vector3
):
void
;
rotate
(
delta
:
Vector3
):
void
;
dispose
():
void
;
}
examples/jsm/controls/EditorControls.js
已删除
100644 → 0
浏览文件 @
6ea23ca3
/**
* @author qiao / https://github.com/qiao
* @author mrdoob / http://mrdoob.com
* @author alteredq / http://alteredqualia.com/
* @author WestLangley / http://github.com/WestLangley
*/
import
{
Box3
,
EventDispatcher
,
Matrix3
,
Sphere
,
Spherical
,
Vector2
,
Vector3
}
from
"
../../../build/three.module.js
"
;
var
EditorControls
=
function
(
object
,
domElement
)
{
domElement
=
(
domElement
!==
undefined
)
?
domElement
:
document
;
// API
this
.
enabled
=
true
;
this
.
center
=
new
Vector3
();
this
.
panSpeed
=
0.002
;
this
.
zoomSpeed
=
0.1
;
this
.
rotationSpeed
=
0.005
;
// internals
var
scope
=
this
;
var
vector
=
new
Vector3
();
var
delta
=
new
Vector3
();
var
box
=
new
Box3
();
var
STATE
=
{
NONE
:
-
1
,
ROTATE
:
0
,
ZOOM
:
1
,
PAN
:
2
};
var
state
=
STATE
.
NONE
;
var
center
=
this
.
center
;
var
normalMatrix
=
new
Matrix3
();
var
pointer
=
new
Vector2
();
var
pointerOld
=
new
Vector2
();
var
spherical
=
new
Spherical
();
var
sphere
=
new
Sphere
();
// events
var
changeEvent
=
{
type
:
'
change
'
};
this
.
focus
=
function
(
target
)
{
var
distance
;
box
.
setFromObject
(
target
);
if
(
box
.
isEmpty
()
===
false
)
{
box
.
getCenter
(
center
);
distance
=
box
.
getBoundingSphere
(
sphere
).
radius
;
}
else
{
// Focusing on an Group, AmbientLight, etc
center
.
setFromMatrixPosition
(
target
.
matrixWorld
);
distance
=
0.1
;
}
delta
.
set
(
0
,
0
,
1
);
delta
.
applyQuaternion
(
object
.
quaternion
);
delta
.
multiplyScalar
(
distance
*
4
);
object
.
position
.
copy
(
center
).
add
(
delta
);
scope
.
dispatchEvent
(
changeEvent
);
};
this
.
pan
=
function
(
delta
)
{
var
distance
=
object
.
position
.
distanceTo
(
center
);
delta
.
multiplyScalar
(
distance
*
scope
.
panSpeed
);
delta
.
applyMatrix3
(
normalMatrix
.
getNormalMatrix
(
object
.
matrix
)
);
object
.
position
.
add
(
delta
);
center
.
add
(
delta
);
scope
.
dispatchEvent
(
changeEvent
);
};
this
.
zoom
=
function
(
delta
)
{
var
distance
=
object
.
position
.
distanceTo
(
center
);
delta
.
multiplyScalar
(
distance
*
scope
.
zoomSpeed
);
if
(
delta
.
length
()
>
distance
)
return
;
delta
.
applyMatrix3
(
normalMatrix
.
getNormalMatrix
(
object
.
matrix
)
);
object
.
position
.
add
(
delta
);
scope
.
dispatchEvent
(
changeEvent
);
};
this
.
rotate
=
function
(
delta
)
{
vector
.
copy
(
object
.
position
).
sub
(
center
);
spherical
.
setFromVector3
(
vector
);
spherical
.
theta
+=
delta
.
x
*
scope
.
rotationSpeed
;
spherical
.
phi
+=
delta
.
y
*
scope
.
rotationSpeed
;
spherical
.
makeSafe
();
vector
.
setFromSpherical
(
spherical
);
object
.
position
.
copy
(
center
).
add
(
vector
);
object
.
lookAt
(
center
);
scope
.
dispatchEvent
(
changeEvent
);
};
// mouse
function
onMouseDown
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
if
(
event
.
button
===
0
)
{
state
=
STATE
.
ROTATE
;
}
else
if
(
event
.
button
===
1
)
{
state
=
STATE
.
ZOOM
;
}
else
if
(
event
.
button
===
2
)
{
state
=
STATE
.
PAN
;
}
pointerOld
.
set
(
event
.
clientX
,
event
.
clientY
);
domElement
.
addEventListener
(
'
mousemove
'
,
onMouseMove
,
false
);
domElement
.
addEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
domElement
.
addEventListener
(
'
mouseout
'
,
onMouseUp
,
false
);
domElement
.
addEventListener
(
'
dblclick
'
,
onMouseUp
,
false
);
}
function
onMouseMove
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
pointer
.
set
(
event
.
clientX
,
event
.
clientY
);
var
movementX
=
pointer
.
x
-
pointerOld
.
x
;
var
movementY
=
pointer
.
y
-
pointerOld
.
y
;
if
(
state
===
STATE
.
ROTATE
)
{
scope
.
rotate
(
delta
.
set
(
-
movementX
,
-
movementY
,
0
)
);
}
else
if
(
state
===
STATE
.
ZOOM
)
{
scope
.
zoom
(
delta
.
set
(
0
,
0
,
movementY
)
);
}
else
if
(
state
===
STATE
.
PAN
)
{
scope
.
pan
(
delta
.
set
(
-
movementX
,
movementY
,
0
)
);
}
pointerOld
.
set
(
event
.
clientX
,
event
.
clientY
);
}
function
onMouseUp
(
event
)
{
domElement
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
,
false
);
domElement
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
domElement
.
removeEventListener
(
'
mouseout
'
,
onMouseUp
,
false
);
domElement
.
removeEventListener
(
'
dblclick
'
,
onMouseUp
,
false
);
state
=
STATE
.
NONE
;
}
function
onMouseWheel
(
event
)
{
event
.
preventDefault
();
// Normalize deltaY due to https://bugzilla.mozilla.org/show_bug.cgi?id=1392460
scope
.
zoom
(
delta
.
set
(
0
,
0
,
event
.
deltaY
>
0
?
1
:
-
1
)
);
}
function
contextmenu
(
event
)
{
event
.
preventDefault
();
}
this
.
dispose
=
function
()
{
domElement
.
removeEventListener
(
'
contextmenu
'
,
contextmenu
,
false
);
domElement
.
removeEventListener
(
'
mousedown
'
,
onMouseDown
,
false
);
domElement
.
removeEventListener
(
'
wheel
'
,
onMouseWheel
,
false
);
domElement
.
removeEventListener
(
'
mousemove
'
,
onMouseMove
,
false
);
domElement
.
removeEventListener
(
'
mouseup
'
,
onMouseUp
,
false
);
domElement
.
removeEventListener
(
'
mouseout
'
,
onMouseUp
,
false
);
domElement
.
removeEventListener
(
'
dblclick
'
,
onMouseUp
,
false
);
domElement
.
removeEventListener
(
'
touchstart
'
,
touchStart
,
false
);
domElement
.
removeEventListener
(
'
touchmove
'
,
touchMove
,
false
);
};
domElement
.
addEventListener
(
'
contextmenu
'
,
contextmenu
,
false
);
domElement
.
addEventListener
(
'
mousedown
'
,
onMouseDown
,
false
);
domElement
.
addEventListener
(
'
wheel
'
,
onMouseWheel
,
false
);
// touch
var
touches
=
[
new
Vector3
(),
new
Vector3
(),
new
Vector3
()
];
var
prevTouches
=
[
new
Vector3
(),
new
Vector3
(),
new
Vector3
()
];
var
prevDistance
=
null
;
function
touchStart
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
switch
(
event
.
touches
.
length
)
{
case
1
:
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
touches
[
1
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
break
;
case
2
:
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
touches
[
1
].
set
(
event
.
touches
[
1
].
pageX
,
event
.
touches
[
1
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
prevDistance
=
touches
[
0
].
distanceTo
(
touches
[
1
]
);
break
;
}
prevTouches
[
0
].
copy
(
touches
[
0
]
);
prevTouches
[
1
].
copy
(
touches
[
1
]
);
}
function
touchMove
(
event
)
{
if
(
scope
.
enabled
===
false
)
return
;
event
.
preventDefault
();
event
.
stopPropagation
();
function
getClosest
(
touch
,
touches
)
{
var
closest
=
touches
[
0
];
for
(
var
i
in
touches
)
{
if
(
closest
.
distanceTo
(
touch
)
>
touches
[
i
].
distanceTo
(
touch
)
)
closest
=
touches
[
i
];
}
return
closest
;
}
switch
(
event
.
touches
.
length
)
{
case
1
:
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
touches
[
1
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
scope
.
rotate
(
touches
[
0
].
sub
(
getClosest
(
touches
[
0
],
prevTouches
)
).
multiplyScalar
(
-
1
)
);
break
;
case
2
:
touches
[
0
].
set
(
event
.
touches
[
0
].
pageX
,
event
.
touches
[
0
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
touches
[
1
].
set
(
event
.
touches
[
1
].
pageX
,
event
.
touches
[
1
].
pageY
,
0
).
divideScalar
(
window
.
devicePixelRatio
);
var
distance
=
touches
[
0
].
distanceTo
(
touches
[
1
]
);
scope
.
zoom
(
delta
.
set
(
0
,
0
,
prevDistance
-
distance
)
);
prevDistance
=
distance
;
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
)
);
break
;
}
prevTouches
[
0
].
copy
(
touches
[
0
]
);
prevTouches
[
1
].
copy
(
touches
[
1
]
);
}
domElement
.
addEventListener
(
'
touchstart
'
,
touchStart
,
false
);
domElement
.
addEventListener
(
'
touchmove
'
,
touchMove
,
false
);
};
EditorControls
.
prototype
=
Object
.
create
(
EventDispatcher
.
prototype
);
EditorControls
.
prototype
.
constructor
=
EditorControls
;
export
{
EditorControls
};
utils/modularize.js
浏览文件 @
74c50698
...
...
@@ -20,7 +20,6 @@ var files = [
{
path
:
'
controls/DragControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
controls/DeviceOrientationControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
controls/EditorControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
controls/FirstPersonControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
controls/FlyControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
{
path
:
'
controls/OrbitControls.js
'
,
dependencies
:
[],
ignoreList
:
[]
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录