Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
c6011f2b
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,体验更适合开发者的 AI 搜索 >>
提交
c6011f2b
编写于
2月 23, 2021
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: Add center option.
上级
4d90e23c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
1 deletion
+31
-1
editor/js/Menubar.Edit.js
editor/js/Menubar.Edit.js
+28
-1
editor/js/Strings.js
editor/js/Strings.js
+3
-0
未找到文件。
editor/js/Menubar.Edit.js
浏览文件 @
c6011f2b
import
{
Box3
,
Vector3
}
from
'
../../build/three.module.js
'
;
import
{
UIPanel
,
UIRow
,
UIHorizontalRule
}
from
'
./libs/ui.js
'
;
import
{
AddObjectCommand
}
from
'
./commands/AddObjectCommand.js
'
;
import
{
RemoveObjectCommand
}
from
'
./commands/RemoveObjectCommand.js
'
;
import
{
SetPositionCommand
}
from
'
./commands/SetPositionCommand.js
'
;
function
MenubarEdit
(
editor
)
{
...
...
@@ -85,6 +88,30 @@ function MenubarEdit( editor ) {
options
.
add
(
new
UIHorizontalRule
()
);
// Center
var
option
=
new
UIRow
();
option
.
setClass
(
'
option
'
);
option
.
setTextContent
(
strings
.
getKey
(
'
menubar/edit/center
'
)
);
option
.
onClick
(
function
()
{
var
object
=
editor
.
selected
;
if
(
object
===
null
||
object
.
parent
===
null
)
return
;
// avoid centering the camera or scene
const
aabb
=
new
Box3
().
setFromObject
(
object
);
const
center
=
aabb
.
getCenter
(
new
Vector3
()
);
const
newPosition
=
new
Vector3
();
newPosition
.
x
=
object
.
position
.
x
+
(
object
.
position
.
x
-
center
.
x
);
newPosition
.
y
=
object
.
position
.
y
+
(
object
.
position
.
y
-
center
.
y
);
newPosition
.
z
=
object
.
position
.
z
+
(
object
.
position
.
z
-
center
.
z
);
editor
.
execute
(
new
SetPositionCommand
(
editor
,
object
,
newPosition
)
);
}
);
options
.
add
(
option
);
// Clone
var
option
=
new
UIRow
();
...
...
@@ -94,7 +121,7 @@ function MenubarEdit( editor ) {
var
object
=
editor
.
selected
;
if
(
object
.
parent
===
null
)
return
;
// avoid cloning the camera or scene
if
(
object
===
null
||
object
.
parent
===
null
)
return
;
// avoid cloning the camera or scene
object
=
object
.
clone
();
...
...
editor/js/Strings.js
浏览文件 @
c6011f2b
...
...
@@ -28,6 +28,7 @@ function Strings( config ) {
'
menubar/edit/undo
'
:
'
Undo (Ctrl+Z)
'
,
'
menubar/edit/redo
'
:
'
Redo (Ctrl+Shift+Z)
'
,
'
menubar/edit/clear_history
'
:
'
Clear History
'
,
'
menubar/edit/center
'
:
'
Center
'
,
'
menubar/edit/clone
'
:
'
Clone
'
,
'
menubar/edit/delete
'
:
'
Delete (Del)
'
,
'
menubar/edit/fixcolormaps
'
:
'
Fix Color Maps
'
,
...
...
@@ -354,6 +355,7 @@ function Strings( config ) {
'
menubar/edit/undo
'
:
'
Annuler (Ctrl+Z)
'
,
'
menubar/edit/redo
'
:
'
Refaire (Ctrl+Shift+Z)
'
,
'
menubar/edit/clear_history
'
:
'
Supprimer Historique
'
,
'
menubar/edit/center
'
:
'
Center
'
,
'
menubar/edit/clone
'
:
'
Cloner
'
,
'
menubar/edit/delete
'
:
'
Supprimer (Supp)
'
,
'
menubar/edit/fixcolormaps
'
:
'
Correction des couleurs
'
,
...
...
@@ -680,6 +682,7 @@ function Strings( config ) {
'
menubar/edit/undo
'
:
'
撤销 (Ctrl+Z)
'
,
'
menubar/edit/redo
'
:
'
重做 (Ctrl+Shift+Z)
'
,
'
menubar/edit/clear_history
'
:
'
清空历史记录
'
,
'
menubar/edit/center
'
:
'
Center
'
,
'
menubar/edit/clone
'
:
'
拷贝
'
,
'
menubar/edit/delete
'
:
'
删除 (Del)
'
,
'
menubar/edit/fixcolormaps
'
:
'
修复颜色贴图
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录