Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
590b8bbe
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,发现更多精彩内容 >>
提交
590b8bbe
编写于
1月 29, 2019
作者:
S
sunag
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
new mask slot and dissolve example
上级
0e79f251
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
174 addition
and
28 deletion
+174
-28
examples/js/nodes/materials/PhongNodeMaterial.js
examples/js/nodes/materials/PhongNodeMaterial.js
+1
-0
examples/js/nodes/materials/SpriteNodeMaterial.js
examples/js/nodes/materials/SpriteNodeMaterial.js
+1
-0
examples/js/nodes/materials/StandardNodeMaterial.js
examples/js/nodes/materials/StandardNodeMaterial.js
+1
-0
examples/js/nodes/materials/nodes/PhongNode.js
examples/js/nodes/materials/nodes/PhongNode.js
+21
-2
examples/js/nodes/materials/nodes/SpriteNode.js
examples/js/nodes/materials/nodes/SpriteNode.js
+23
-6
examples/js/nodes/materials/nodes/StandardNode.js
examples/js/nodes/materials/nodes/StandardNode.js
+22
-3
examples/js/nodes/math/CondNode.js
examples/js/nodes/math/CondNode.js
+35
-16
examples/webgl_materials_nodes.html
examples/webgl_materials_nodes.html
+70
-1
未找到文件。
examples/js/nodes/materials/PhongNodeMaterial.js
浏览文件 @
590b8bbe
...
...
@@ -32,6 +32,7 @@ NodeUtils.addShortcuts( PhongNodeMaterial.prototype, 'fragment', [
'
ao
'
,
'
environment
'
,
'
environmentAlpha
'
,
'
mask
'
,
'
position
'
]
);
...
...
examples/js/nodes/materials/SpriteNodeMaterial.js
浏览文件 @
590b8bbe
...
...
@@ -22,6 +22,7 @@ SpriteNodeMaterial.prototype.constructor = SpriteNodeMaterial;
NodeUtils
.
addShortcuts
(
SpriteNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
mask
'
,
'
position
'
,
'
spherical
'
]
);
...
...
examples/js/nodes/materials/StandardNodeMaterial.js
浏览文件 @
590b8bbe
...
...
@@ -34,6 +34,7 @@ NodeUtils.addShortcuts( StandardNodeMaterial.prototype, 'fragment', [
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
mask
'
,
'
position
'
]
);
...
...
examples/js/nodes/materials/nodes/PhongNode.js
浏览文件 @
590b8bbe
...
...
@@ -103,6 +103,8 @@ PhongNode.prototype.build = function ( builder ) {
// parse all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
parse
(
builder
);
this
.
color
.
parse
(
builder
,
{
slot
:
'
color
'
}
);
this
.
specular
.
parse
(
builder
);
this
.
shininess
.
parse
(
builder
);
...
...
@@ -123,6 +125,8 @@ PhongNode.prototype.build = function ( builder ) {
// build code
var
mask
=
this
.
mask
?
this
.
mask
.
buildCode
(
builder
,
'
b
'
)
:
undefined
;
var
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
);
var
specular
=
this
.
specular
.
buildCode
(
builder
,
'
c
'
);
var
shininess
=
this
.
shininess
.
buildCode
(
builder
,
'
f
'
);
...
...
@@ -157,8 +161,19 @@ PhongNode.prototype.build = function ( builder ) {
"
#include <normal_fragment_begin>
"
,
// prevent undeclared material
"
BlinnPhongMaterial material;
"
,
"
BlinnPhongMaterial material;
"
];
if
(
mask
)
{
output
.
push
(
mask
.
code
,
'
if (
'
+
mask
.
result
+
'
) discard;
'
);
}
output
.
push
(
color
.
code
,
"
vec3 diffuseColor =
"
+
color
.
result
+
"
;
"
,
"
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
"
,
...
...
@@ -172,7 +187,7 @@ PhongNode.prototype.build = function ( builder ) {
"
float shininess = max( 0.0001,
"
+
shininess
.
result
+
"
);
"
,
"
float specularStrength = 1.0;
"
// Ignored in MaterialNode ( replace to specular )
]
;
)
;
if
(
alpha
)
{
...
...
@@ -335,6 +350,8 @@ PhongNode.prototype.copy = function ( source ) {
this
.
specular
=
source
.
specular
;
this
.
shininess
=
source
.
shininess
;
if
(
source
.
mask
)
this
.
mask
=
source
.
mask
;
if
(
source
.
alpha
)
this
.
alpha
=
source
.
alpha
;
if
(
source
.
normal
)
this
.
normal
=
source
.
normal
;
...
...
@@ -370,6 +387,8 @@ PhongNode.prototype.toJSON = function ( meta ) {
data
.
specular
=
this
.
specular
.
toJSON
(
meta
).
uuid
;
data
.
shininess
=
this
.
shininess
.
toJSON
(
meta
).
uuid
;
if
(
this
.
mask
)
data
.
mask
=
this
.
mask
.
toJSON
(
meta
).
uuid
;
if
(
this
.
alpha
)
data
.
alpha
=
this
.
alpha
.
toJSON
(
meta
).
uuid
;
if
(
this
.
normal
)
data
.
normal
=
this
.
normal
.
toJSON
(
meta
).
uuid
;
...
...
examples/js/nodes/materials/nodes/SpriteNode.js
浏览文件 @
590b8bbe
...
...
@@ -123,18 +123,31 @@ SpriteNode.prototype.build = function ( builder ) {
// parse all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
parse
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
parse
(
builder
);
this
.
color
.
parse
(
builder
,
{
slot
:
'
color
'
}
);
// build code
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
,
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
);
var
mask
=
this
.
mask
?
this
.
mask
.
buildCode
(
builder
,
'
b
'
)
:
undefined
,
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
,
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
),
output
=
[];
if
(
mask
)
{
output
.
push
(
mask
.
code
,
'
if (
'
+
mask
.
result
+
'
) discard;
'
);
}
if
(
alpha
)
{
output
=
[
output
.
push
(
alpha
.
code
,
'
#ifdef ALPHATEST
'
,
...
...
@@ -143,14 +156,14 @@ SpriteNode.prototype.build = function ( builder ) {
'
#endif
'
,
color
.
code
,
"
gl_FragColor = vec4(
"
+
color
.
result
+
"
,
"
+
alpha
.
result
+
"
);
"
]
;
)
;
}
else
{
output
=
[
output
.
push
(
color
.
code
,
"
gl_FragColor = vec4(
"
+
color
.
result
+
"
, 1.0 );
"
]
;
)
;
}
...
...
@@ -180,6 +193,8 @@ SpriteNode.prototype.copy = function ( source ) {
if
(
source
.
spherical
!==
undefined
)
this
.
spherical
=
source
.
spherical
;
if
(
source
.
mask
)
this
.
mask
=
source
.
mask
;
if
(
source
.
alpha
)
this
.
alpha
=
source
.
alpha
;
};
...
...
@@ -202,6 +217,8 @@ SpriteNode.prototype.toJSON = function ( meta ) {
if
(
this
.
spherical
===
false
)
data
.
spherical
=
false
;
if
(
this
.
mask
)
data
.
mask
=
this
.
mask
.
toJSON
(
meta
).
uuid
;
if
(
this
.
alpha
)
data
.
alpha
=
this
.
alpha
.
toJSON
(
meta
).
uuid
;
}
...
...
examples/js/nodes/materials/nodes/StandardNode.js
浏览文件 @
590b8bbe
...
...
@@ -117,6 +117,8 @@ StandardNode.prototype.build = function ( builder ) {
// parse all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
parse
(
builder
);
this
.
color
.
parse
(
builder
,
{
slot
:
'
color
'
,
context
:
contextGammaOnly
}
);
this
.
roughness
.
parse
(
builder
);
this
.
metalness
.
parse
(
builder
);
...
...
@@ -141,6 +143,8 @@ StandardNode.prototype.build = function ( builder ) {
// build code
var
mask
=
this
.
mask
?
this
.
mask
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
,
context
:
contextGammaOnly
}
);
var
roughness
=
this
.
roughness
.
buildCode
(
builder
,
'
f
'
);
var
metalness
=
this
.
metalness
.
buildCode
(
builder
,
'
f
'
);
...
...
@@ -194,8 +198,19 @@ StandardNode.prototype.build = function ( builder ) {
// add before: prevent undeclared material
"
PhysicalMaterial material;
"
,
"
material.diffuseColor = vec3( 1.0 );
"
,
"
material.diffuseColor = vec3( 1.0 );
"
];
if
(
mask
)
{
output
.
push
(
mask
.
code
,
'
if (
'
+
mask
.
result
+
'
) discard;
'
);
}
output
.
push
(
color
.
code
,
"
vec3 diffuseColor =
"
+
color
.
result
+
"
;
"
,
"
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
"
,
...
...
@@ -207,7 +222,7 @@ StandardNode.prototype.build = function ( builder ) {
metalness
.
code
,
"
float metalnessFactor =
"
+
metalness
.
result
+
"
;
"
]
;
)
;
if
(
alpha
)
{
...
...
@@ -215,7 +230,7 @@ StandardNode.prototype.build = function ( builder ) {
alpha
.
code
,
'
#ifdef ALPHATEST
'
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
,
'
#endif
'
);
...
...
@@ -403,6 +418,8 @@ StandardNode.prototype.copy = function ( source ) {
this
.
roughness
=
source
.
roughness
;
this
.
metalness
=
source
.
metalness
;
if
(
source
.
mask
)
this
.
mask
=
source
.
mask
;
if
(
source
.
alpha
)
this
.
alpha
=
source
.
alpha
;
if
(
source
.
normal
)
this
.
normal
=
source
.
normal
;
...
...
@@ -442,6 +459,8 @@ StandardNode.prototype.toJSON = function ( meta ) {
data
.
roughness
=
this
.
roughness
.
toJSON
(
meta
).
uuid
;
data
.
metalness
=
this
.
metalness
.
toJSON
(
meta
).
uuid
;
if
(
this
.
mask
)
data
.
mask
=
this
.
mask
.
toJSON
(
meta
).
uuid
;
if
(
this
.
alpha
)
data
.
alpha
=
this
.
alpha
.
toJSON
(
meta
).
uuid
;
if
(
this
.
normal
)
data
.
normal
=
this
.
normal
.
toJSON
(
meta
).
uuid
;
...
...
examples/js/nodes/math/CondNode.js
浏览文件 @
590b8bbe
...
...
@@ -4,18 +4,18 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
CondNode
(
a
,
b
,
ifNode
,
elseNode
,
op
)
{
function
CondNode
(
a
,
b
,
op
,
ifNode
,
elseNode
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
b
=
b
;
this
.
op
=
op
;
this
.
ifNode
=
ifNode
;
this
.
elseNode
=
elseNode
;
this
.
op
=
op
;
}
CondNode
.
EQUAL
=
'
==
'
;
...
...
@@ -31,13 +31,22 @@ CondNode.prototype.nodeType = "Cond";
CondNode
.
prototype
.
getType
=
function
(
builder
)
{
if
(
builder
.
getTypeLength
(
this
.
elseNode
.
getType
(
builder
)
)
>
builder
.
getTypeLength
(
this
.
ifNode
.
getType
(
builder
)
)
)
{
if
(
this
.
ifNode
)
{
var
ifType
=
this
.
ifNode
.
getType
(
builder
);
var
elseType
=
this
.
elseNode
.
getType
(
builder
);
if
(
builder
.
getTypeLength
(
elseType
)
>
builder
.
getTypeLength
(
ifType
)
)
{
return
this
.
elseNode
.
getType
(
builder
)
;
return
elseType
;
}
}
return
this
.
ifNode
.
getType
(
builder
);
return
ifType
;
}
return
'
b
'
;
};
...
...
@@ -59,10 +68,20 @@ CondNode.prototype.generate = function ( builder, output ) {
condType
=
this
.
getCondType
(
builder
),
a
=
this
.
a
.
build
(
builder
,
condType
),
b
=
this
.
b
.
build
(
builder
,
condType
),
ifNode
=
this
.
ifNode
.
build
(
builder
,
type
),
elseNode
=
this
.
elseNode
.
build
(
builder
,
type
);
var
code
=
'
(
'
+
[
a
,
this
.
op
,
b
,
'
?
'
,
ifNode
,
'
:
'
,
elseNode
].
join
(
'
'
)
+
'
)
'
;
code
;
if
(
this
.
ifNode
)
{
var
ifCode
=
this
.
ifNode
.
build
(
builder
,
type
),
elseCode
=
this
.
elseNode
.
build
(
builder
,
type
);
code
=
'
(
'
+
[
a
,
this
.
op
,
b
,
'
?
'
,
ifCode
,
'
:
'
,
elseCode
].
join
(
'
'
)
+
'
)
'
;
}
else
{
code
=
'
(
'
+
a
+
'
'
+
this
.
op
+
'
'
+
b
+
'
)
'
;
}
return
builder
.
format
(
code
,
this
.
getType
(
builder
),
output
);
...
...
@@ -75,11 +94,11 @@ CondNode.prototype.copy = function ( source ) {
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
op
=
source
.
op
;
this
.
ifNode
=
source
.
ifNode
;
this
.
elseNode
=
source
.
elseNode
;
this
.
op
=
source
.
op
;
};
CondNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
@@ -93,11 +112,11 @@ CondNode.prototype.toJSON = function ( meta ) {
data
.
a
=
this
.
a
.
toJSON
(
meta
).
uuid
;
data
.
b
=
this
.
b
.
toJSON
(
meta
).
uuid
;
data
.
ifNode
=
this
.
ifNode
.
toJSON
(
meta
).
uuid
;
data
.
elseNode
=
this
.
elseNode
.
toJSON
(
meta
).
uuid
;
data
.
op
=
this
.
op
;
if
(
data
.
ifNode
)
data
.
ifNode
=
this
.
ifNode
.
toJSON
(
meta
).
uuid
;
if
(
data
.
elseNode
)
data
.
elseNode
=
this
.
elseNode
.
toJSON
(
meta
).
uuid
;
}
return
data
;
...
...
examples/webgl_materials_nodes.html
浏览文件 @
590b8bbe
...
...
@@ -180,6 +180,7 @@
'
adv / skin-phong
'
:
'
skin-phong
'
,
'
adv / caustic
'
:
'
caustic
'
,
'
adv / displace
'
:
'
displace
'
,
'
adv / dissolve
'
:
'
dissolve
'
,
'
adv / plush
'
:
'
plush
'
,
'
adv / toon
'
:
'
toon
'
,
'
adv / camera-depth
'
:
'
camera-depth
'
,
...
...
@@ -1321,6 +1322,74 @@
break
;
case
'
dissolve
'
:
// MATERIAL
mtl
=
new
THREE
.
StandardNodeMaterial
();
var
color
=
new
THREE
.
ColorNode
(
0xEEEEEE
);
var
borderColor
=
new
THREE
.
ColorNode
(
0x0054df
);
var
threshold
=
new
THREE
.
FloatNode
(
.
1
);
var
borderSize
=
new
THREE
.
FloatNode
(
.
2
);
// animate uv
var
tex
=
new
THREE
.
TextureNode
(
getTexture
(
"
cloud
"
)
);
var
texArea
=
new
THREE
.
SwitchNode
(
tex
,
'
w
'
);
var
thresholdBorder
=
new
THREE
.
Math3Node
(
new
THREE
.
OperatorNode
(
threshold
,
borderSize
,
THREE
.
OperatorNode
.
ADD
),
threshold
,
texArea
,
THREE
.
Math3Node
.
SMOOTHSTEP
);
var
thresholdEmissive
=
new
THREE
.
OperatorNode
(
borderColor
,
thresholdBorder
,
THREE
.
OperatorNode
.
MUL
);
// APPLY
mtl
.
color
=
color
;
mtl
.
emissive
=
thresholdEmissive
;
mtl
.
mask
=
new
THREE
.
CondNode
(
texArea
,
// a: value
threshold
,
// b: value
THREE
.
CondNode
.
LESS
// condition
);
// GUI
addGui
(
'
threshold
'
,
threshold
.
value
,
function
(
val
)
{
threshold
.
value
=
val
;
},
false
,
-
.
3
,
1.3
);
addGui
(
'
borderSize
'
,
borderSize
.
value
,
function
(
val
)
{
borderSize
.
value
=
val
;
},
false
,
0
,
.
5
);
addGui
(
'
color
'
,
color
.
value
.
getHex
(),
function
(
val
)
{
color
.
value
.
setHex
(
val
);
},
true
);
addGui
(
'
borderColor
'
,
borderColor
.
value
.
getHex
(),
function
(
val
)
{
borderColor
.
value
.
setHex
(
val
);
},
true
);
break
;
case
'
smoke
'
:
// MATERIAL
...
...
@@ -2172,7 +2241,7 @@
ifNode
=
new
THREE
.
ColorNode
(
0x0000FF
),
elseNode
=
new
THREE
.
ColorNode
(
0xFF0000
);
var
cond
=
new
THREE
.
CondNode
(
a
,
b
,
ifNode
,
elseNode
,
THREE
.
CondNode
.
EQUAL
);
var
cond
=
new
THREE
.
CondNode
(
a
,
b
,
THREE
.
CondNode
.
EQUAL
,
ifNode
,
elseNode
);
mtl
.
color
=
cond
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录