Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
2890d7e4
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,发现更多精彩内容 >>
提交
2890d7e4
编写于
7月 27, 2021
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Editor: Added SidebarMaterialColorProperty.
上级
dded9d56
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
98 addition
and
70 deletion
+98
-70
editor/js/Sidebar.Material.ColorProperty.js
editor/js/Sidebar.Material.ColorProperty.js
+90
-0
editor/js/Sidebar.Material.js
editor/js/Sidebar.Material.js
+7
-70
editor/sw.js
editor/sw.js
+1
-0
未找到文件。
editor/js/Sidebar.Material.ColorProperty.js
0 → 100644
浏览文件 @
2890d7e4
import
{
UIColor
,
UINumber
,
UIRow
,
UIText
}
from
'
./libs/ui.js
'
;
import
{
SetMaterialColorCommand
}
from
'
./commands/SetMaterialColorCommand.js
'
;
import
{
SetMaterialValueCommand
}
from
'
./commands/SetMaterialValueCommand.js
'
;
function
SidebarMaterialColorProperty
(
editor
,
property
,
name
)
{
const
signals
=
editor
.
signals
;
const
container
=
new
UIRow
();
container
.
add
(
new
UIText
(
name
).
setWidth
(
'
90px
'
)
);
const
color
=
new
UIColor
().
onInput
(
onChange
);
container
.
add
(
color
);
let
emissiveIntensity
;
if
(
property
===
'
emissive
'
)
{
emissiveIntensity
=
new
UINumber
(
1
).
setWidth
(
'
30px
'
).
onChange
(
onChange
);
container
.
add
(
emissiveIntensity
);
}
let
object
=
null
;
let
material
=
null
;
function
onChange
()
{
if
(
material
[
property
].
getHex
()
!==
color
.
getHexValue
()
)
{
editor
.
execute
(
new
SetMaterialColorCommand
(
editor
,
object
,
property
,
color
.
getHexValue
(),
/* TODO: currentMaterialSlot*/
0
)
);
}
if
(
emissiveIntensity
!==
undefined
)
{
if
(
material
.
emissiveIntensity
!==
emissiveIntensity
.
getValue
()
)
{
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
object
,
'
emissiveIntensity
'
,
emissiveIntensity
.
getValue
(),
/* TODO: currentMaterialSlot*/
0
)
);
}
}
}
function
update
()
{
if
(
object
===
null
)
return
;
if
(
object
.
material
===
undefined
)
return
;
material
=
object
.
material
;
if
(
property
in
material
)
{
color
.
setHexValue
(
material
[
property
].
getHexString
()
);
if
(
emissiveIntensity
!==
undefined
)
{
emissiveIntensity
.
setValue
(
material
.
emissiveIntensity
);
}
container
.
setDisplay
(
''
);
}
else
{
container
.
setDisplay
(
'
none
'
);
}
}
//
signals
.
objectSelected
.
add
(
function
(
selected
)
{
object
=
selected
;
update
();
}
);
signals
.
materialChanged
.
add
(
update
);
return
container
;
}
export
{
SidebarMaterialColorProperty
};
editor/js/Sidebar.Material.js
浏览文件 @
2890d7e4
...
@@ -9,6 +9,7 @@ import { SetMaterialMapCommand } from './commands/SetMaterialMapCommand.js';
...
@@ -9,6 +9,7 @@ import { SetMaterialMapCommand } from './commands/SetMaterialMapCommand.js';
import
{
SetMaterialValueCommand
}
from
'
./commands/SetMaterialValueCommand.js
'
;
import
{
SetMaterialValueCommand
}
from
'
./commands/SetMaterialValueCommand.js
'
;
import
{
SetMaterialVectorCommand
}
from
'
./commands/SetMaterialVectorCommand.js
'
;
import
{
SetMaterialVectorCommand
}
from
'
./commands/SetMaterialVectorCommand.js
'
;
import
{
SidebarMaterialColorProperty
}
from
'
./Sidebar.Material.ColorProperty.js
'
;
var
materialClasses
=
{
var
materialClasses
=
{
'
LineBasicMaterial
'
:
THREE
.
LineBasicMaterial
,
'
LineBasicMaterial
'
:
THREE
.
LineBasicMaterial
,
'
LineDashedMaterial
'
:
THREE
.
LineDashedMaterial
,
'
LineDashedMaterial
'
:
THREE
.
LineDashedMaterial
,
...
@@ -134,13 +135,8 @@ function SidebarMaterial( editor ) {
...
@@ -134,13 +135,8 @@ function SidebarMaterial( editor ) {
// color
// color
var
materialColorRow
=
new
UIRow
();
const
materialColor
=
new
SidebarMaterialColorProperty
(
editor
,
'
color
'
,
strings
.
getKey
(
'
sidebar/material/color
'
)
);
var
materialColor
=
new
UIColor
().
onInput
(
update
);
container
.
add
(
materialColor
);
materialColorRow
.
add
(
new
UIText
(
strings
.
getKey
(
'
sidebar/material/color
'
)
).
setWidth
(
'
90px
'
)
);
materialColorRow
.
add
(
materialColor
);
container
.
add
(
materialColorRow
);
// roughness
// roughness
...
@@ -188,25 +184,13 @@ function SidebarMaterial( editor ) {
...
@@ -188,25 +184,13 @@ function SidebarMaterial( editor ) {
// emissive
// emissive
var
materialEmissiveRow
=
new
UIRow
();
const
materialEmissive
=
new
SidebarMaterialColorProperty
(
editor
,
'
emissive
'
,
strings
.
getKey
(
'
sidebar/material/emissive
'
)
);
var
materialEmissive
=
new
UIColor
().
setHexValue
(
0x000000
).
onInput
(
update
);
container
.
add
(
materialEmissive
);
var
materialEmissiveIntensity
=
new
UINumber
(
1
).
setWidth
(
'
30px
'
).
onChange
(
update
);
materialEmissiveRow
.
add
(
new
UIText
(
strings
.
getKey
(
'
sidebar/material/emissive
'
)
).
setWidth
(
'
90px
'
)
);
materialEmissiveRow
.
add
(
materialEmissive
);
materialEmissiveRow
.
add
(
materialEmissiveIntensity
);
container
.
add
(
materialEmissiveRow
);
// specular
// specular
var
materialSpecularRow
=
new
UIRow
();
const
materialSpecular
=
new
SidebarMaterialColorProperty
(
editor
,
'
specular
'
,
strings
.
getKey
(
'
sidebar/material/specular
'
)
);
var
materialSpecular
=
new
UIColor
().
setHexValue
(
0x111111
).
onInput
(
update
);
container
.
add
(
materialSpecular
);
materialSpecularRow
.
add
(
new
UIText
(
strings
.
getKey
(
'
sidebar/material/specular
'
)
).
setWidth
(
'
90px
'
)
);
materialSpecularRow
.
add
(
materialSpecular
);
container
.
add
(
materialSpecularRow
);
// shininess
// shininess
...
@@ -646,12 +630,6 @@ function SidebarMaterial( editor ) {
...
@@ -646,12 +630,6 @@ function SidebarMaterial( editor ) {
}
}
if
(
material
.
color
!==
undefined
&&
material
.
color
.
getHex
()
!==
materialColor
.
getHexValue
()
)
{
editor
.
execute
(
new
SetMaterialColorCommand
(
editor
,
currentObject
,
'
color
'
,
materialColor
.
getHexValue
(),
currentMaterialSlot
)
);
}
if
(
material
.
roughness
!==
undefined
&&
Math
.
abs
(
material
.
roughness
-
materialRoughness
.
getValue
()
)
>=
epsilon
)
{
if
(
material
.
roughness
!==
undefined
&&
Math
.
abs
(
material
.
roughness
-
materialRoughness
.
getValue
()
)
>=
epsilon
)
{
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
currentObject
,
'
roughness
'
,
materialRoughness
.
getValue
(),
currentMaterialSlot
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
currentObject
,
'
roughness
'
,
materialRoughness
.
getValue
(),
currentMaterialSlot
)
);
...
@@ -688,24 +666,6 @@ function SidebarMaterial( editor ) {
...
@@ -688,24 +666,6 @@ function SidebarMaterial( editor ) {
}
}
if
(
material
.
emissive
!==
undefined
&&
material
.
emissive
.
getHex
()
!==
materialEmissive
.
getHexValue
()
)
{
editor
.
execute
(
new
SetMaterialColorCommand
(
editor
,
currentObject
,
'
emissive
'
,
materialEmissive
.
getHexValue
(),
currentMaterialSlot
)
);
}
if
(
material
.
emissiveIntensity
!==
undefined
&&
material
.
emissiveIntensity
!==
materialEmissiveIntensity
.
getValue
()
)
{
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
currentObject
,
'
emissiveIntensity
'
,
materialEmissiveIntensity
.
getValue
(),
currentMaterialSlot
)
);
}
if
(
material
.
specular
!==
undefined
&&
material
.
specular
.
getHex
()
!==
materialSpecular
.
getHexValue
()
)
{
editor
.
execute
(
new
SetMaterialColorCommand
(
editor
,
currentObject
,
'
specular
'
,
materialSpecular
.
getHexValue
(),
currentMaterialSlot
)
);
}
if
(
material
.
shininess
!==
undefined
&&
Math
.
abs
(
material
.
shininess
-
materialShininess
.
getValue
()
)
>=
epsilon
)
{
if
(
material
.
shininess
!==
undefined
&&
Math
.
abs
(
material
.
shininess
-
materialShininess
.
getValue
()
)
>=
epsilon
)
{
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
currentObject
,
'
shininess
'
,
materialShininess
.
getValue
(),
currentMaterialSlot
)
);
editor
.
execute
(
new
SetMaterialValueCommand
(
editor
,
currentObject
,
'
shininess
'
,
materialShininess
.
getValue
(),
currentMaterialSlot
)
);
...
@@ -1233,13 +1193,10 @@ function SidebarMaterial( editor ) {
...
@@ -1233,13 +1193,10 @@ function SidebarMaterial( editor ) {
var
properties
=
{
var
properties
=
{
'
name
'
:
materialNameRow
,
'
name
'
:
materialNameRow
,
'
color
'
:
materialColorRow
,
'
roughness
'
:
materialRoughnessRow
,
'
roughness
'
:
materialRoughnessRow
,
'
metalness
'
:
materialMetalnessRow
,
'
metalness
'
:
materialMetalnessRow
,
'
emissive
'
:
materialEmissiveRow
,
// 'sheen': materialSheenRow,
// 'sheen': materialSheenRow,
'
transmission
'
:
materialTransmissionRow
,
'
transmission
'
:
materialTransmissionRow
,
'
specular
'
:
materialSpecularRow
,
'
shininess
'
:
materialShininessRow
,
'
shininess
'
:
materialShininessRow
,
'
clearcoat
'
:
materialClearcoatRow
,
'
clearcoat
'
:
materialClearcoatRow
,
'
clearcoatRoughness
'
:
materialClearcoatRoughnessRow
,
'
clearcoatRoughness
'
:
materialClearcoatRoughnessRow
,
...
@@ -1356,12 +1313,6 @@ function SidebarMaterial( editor ) {
...
@@ -1356,12 +1313,6 @@ function SidebarMaterial( editor ) {
materialClass
.
setValue
(
material
.
type
);
materialClass
.
setValue
(
material
.
type
);
if
(
material
.
color
!==
undefined
)
{
materialColor
.
setHexValue
(
material
.
color
.
getHexString
()
);
}
if
(
material
.
roughness
!==
undefined
)
{
if
(
material
.
roughness
!==
undefined
)
{
materialRoughness
.
setValue
(
material
.
roughness
);
materialRoughness
.
setValue
(
material
.
roughness
);
...
@@ -1389,20 +1340,6 @@ function SidebarMaterial( editor ) {
...
@@ -1389,20 +1340,6 @@ function SidebarMaterial( editor ) {
}
}
if
(
material
.
emissive
!==
undefined
)
{
materialEmissive
.
setHexValue
(
material
.
emissive
.
getHexString
()
);
materialEmissiveIntensity
.
setValue
(
material
.
emissiveIntensity
);
}
if
(
material
.
specular
!==
undefined
)
{
materialSpecular
.
setHexValue
(
material
.
specular
.
getHexString
()
);
}
if
(
material
.
shininess
!==
undefined
)
{
if
(
material
.
shininess
!==
undefined
)
{
materialShininess
.
setValue
(
material
.
shininess
);
materialShininess
.
setValue
(
material
.
shininess
);
...
...
editor/sw.js
浏览文件 @
2890d7e4
...
@@ -175,6 +175,7 @@ const assets = [
...
@@ -175,6 +175,7 @@ const assets = [
'
./js/Sidebar.Geometry.TubeGeometry.js
'
,
'
./js/Sidebar.Geometry.TubeGeometry.js
'
,
'
./js/Sidebar.Geometry.TeapotGeometry.js
'
,
'
./js/Sidebar.Geometry.TeapotGeometry.js
'
,
'
./js/Sidebar.Material.js
'
,
'
./js/Sidebar.Material.js
'
,
'
./js/Sidebar.Material.ColorProperty.js
'
,
'
./js/Sidebar.Animation.js
'
,
'
./js/Sidebar.Animation.js
'
,
'
./js/Sidebar.Script.js
'
,
'
./js/Sidebar.Script.js
'
,
'
./js/Strings.js
'
,
'
./js/Strings.js
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录