Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
8dddb4e1
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,发现更多精彩内容 >>
未验证
提交
8dddb4e1
编写于
1月 31, 2019
作者:
M
Mr.doob
提交者:
GitHub
1月 31, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15675 from sunag/dev-fix-nameconflict
NodeMaterial - fix name conflict + label + gets and sets
上级
53612dfc
4c41c569
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
107 addition
and
42 deletion
+107
-42
examples/js/nodes/accessors/CameraNode.js
examples/js/nodes/accessors/CameraNode.js
+2
-2
examples/js/nodes/accessors/NormalNode.js
examples/js/nodes/accessors/NormalNode.js
+1
-1
examples/js/nodes/accessors/PositionNode.js
examples/js/nodes/accessors/PositionNode.js
+1
-1
examples/js/nodes/core/FunctionNode.js
examples/js/nodes/core/FunctionNode.js
+1
-1
examples/js/nodes/core/InputNode.js
examples/js/nodes/core/InputNode.js
+12
-4
examples/js/nodes/core/NodeBuilder.js
examples/js/nodes/core/NodeBuilder.js
+10
-12
examples/js/nodes/core/TempNode.js
examples/js/nodes/core/TempNode.js
+23
-9
examples/js/nodes/inputs/ScreenNode.js
examples/js/nodes/inputs/ScreenNode.js
+1
-1
examples/js/nodes/utils/TimerNode.js
examples/js/nodes/utils/TimerNode.js
+2
-2
examples/js/nodes/utils/VelocityNode.js
examples/js/nodes/utils/VelocityNode.js
+1
-1
examples/webgl_materials_nodes.html
examples/webgl_materials_nodes.html
+53
-8
未找到文件。
examples/js/nodes/accessors/CameraNode.js
浏览文件 @
8dddb4e1
...
...
@@ -101,7 +101,7 @@ CameraNode.prototype.getType = function ( builder ) {
};
CameraNode
.
prototype
.
is
Unique
=
function
(
builder
)
{
CameraNode
.
prototype
.
get
Unique
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
@@ -116,7 +116,7 @@ CameraNode.prototype.isUnique = function ( builder ) {
};
CameraNode
.
prototype
.
is
Shared
=
function
(
builder
)
{
CameraNode
.
prototype
.
get
Shared
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
examples/js/nodes/accessors/NormalNode.js
浏览文件 @
8dddb4e1
...
...
@@ -21,7 +21,7 @@ NormalNode.prototype = Object.create( TempNode.prototype );
NormalNode
.
prototype
.
constructor
=
NormalNode
;
NormalNode
.
prototype
.
nodeType
=
"
Normal
"
;
NormalNode
.
prototype
.
is
Shared
=
function
(
builder
)
{
NormalNode
.
prototype
.
get
Shared
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
examples/js/nodes/accessors/PositionNode.js
浏览文件 @
8dddb4e1
...
...
@@ -36,7 +36,7 @@ PositionNode.prototype.getType = function ( ) {
};
PositionNode
.
prototype
.
is
Shared
=
function
(
builder
)
{
PositionNode
.
prototype
.
get
Shared
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
examples/js/nodes/core/FunctionNode.js
浏览文件 @
8dddb4e1
...
...
@@ -25,7 +25,7 @@ FunctionNode.prototype.nodeType = "Function";
FunctionNode
.
prototype
.
useKeywords
=
true
;
FunctionNode
.
prototype
.
is
Shared
=
function
(
builder
,
output
)
{
FunctionNode
.
prototype
.
get
Shared
=
function
(
builder
,
output
)
{
return
!
this
.
isMethod
;
...
...
examples/js/nodes/core/InputNode.js
浏览文件 @
8dddb4e1
...
...
@@ -18,7 +18,15 @@ function InputNode( type, params ) {
InputNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
InputNode
.
prototype
.
constructor
=
InputNode
;
InputNode
.
prototype
.
isReadonly
=
function
(
builder
)
{
InputNode
.
prototype
.
setReadonly
=
function
(
value
)
{
this
.
readonly
=
value
;
return
this
;
};
InputNode
.
prototype
.
getReadonly
=
function
(
builder
)
{
return
this
.
readonly
;
...
...
@@ -48,7 +56,7 @@ InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needs
type
=
type
||
this
.
getType
(
builder
);
var
data
=
builder
.
getNodeData
(
uuid
),
readonly
=
this
.
is
Readonly
(
builder
)
&&
this
.
generateReadonly
!==
undefined
;
readonly
=
this
.
get
Readonly
(
builder
)
&&
this
.
generateReadonly
!==
undefined
;
if
(
readonly
)
{
...
...
@@ -60,7 +68,7 @@ InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needs
if
(
!
data
.
vertex
)
{
data
.
vertex
=
builder
.
createVertexUniform
(
type
,
this
,
ns
,
needsUpdate
);
data
.
vertex
=
builder
.
createVertexUniform
(
type
,
this
,
ns
,
needsUpdate
,
this
.
getLabel
()
);
}
...
...
@@ -70,7 +78,7 @@ InputNode.prototype.generate = function ( builder, output, uuid, type, ns, needs
if
(
!
data
.
fragment
)
{
data
.
fragment
=
builder
.
createFragmentUniform
(
type
,
this
,
ns
,
needsUpdate
);
data
.
fragment
=
builder
.
createFragmentUniform
(
type
,
this
,
ns
,
needsUpdate
,
this
.
getLabel
()
);
}
...
...
examples/js/nodes/core/NodeBuilder.js
浏览文件 @
8dddb4e1
...
...
@@ -443,9 +443,7 @@ NodeBuilder.prototype = {
},
getVar
:
function
(
uuid
,
type
,
ns
,
shader
)
{
shader
=
shader
||
'
varying
'
;
getVar
:
function
(
uuid
,
type
,
ns
,
shader
=
'
varying
'
,
prefix
=
'
V
'
,
label
=
''
)
{
var
vars
=
this
.
getVars
(
shader
),
data
=
vars
[
uuid
];
...
...
@@ -453,7 +451,7 @@ NodeBuilder.prototype = {
if
(
!
data
)
{
var
index
=
vars
.
length
,
name
=
ns
?
ns
:
'
n
Vv
'
+
index
;
name
=
ns
?
ns
:
'
n
ode
'
+
prefix
+
index
+
(
label
?
'
_
'
+
label
:
''
)
;
data
=
{
name
:
name
,
type
:
type
};
...
...
@@ -466,9 +464,9 @@ NodeBuilder.prototype = {
},
getTempVar
:
function
(
uuid
,
type
,
ns
)
{
getTempVar
:
function
(
uuid
,
type
,
ns
,
label
)
{
return
this
.
getVar
(
uuid
,
type
,
ns
,
this
.
shader
);
return
this
.
getVar
(
uuid
,
type
,
ns
,
this
.
shader
,
'
T
'
,
label
);
},
...
...
@@ -551,14 +549,14 @@ NodeBuilder.prototype = {
},
createUniform
:
function
(
shader
,
type
,
node
,
ns
,
needsUpdate
)
{
createUniform
:
function
(
shader
,
type
,
node
,
ns
,
needsUpdate
,
label
)
{
var
uniforms
=
this
.
inputs
.
uniforms
,
index
=
uniforms
.
list
.
length
;
var
uniform
=
new
NodeUniform
(
{
type
:
type
,
name
:
ns
?
ns
:
'
n
Vu
'
+
index
,
name
:
ns
?
ns
:
'
n
odeU
'
+
index
+
(
label
?
'
_
'
+
label
:
''
)
,
node
:
node
,
needsUpdate
:
needsUpdate
}
);
...
...
@@ -574,15 +572,15 @@ NodeBuilder.prototype = {
},
createVertexUniform
:
function
(
type
,
node
,
ns
,
needsUpdate
)
{
createVertexUniform
:
function
(
type
,
node
,
ns
,
needsUpdate
,
label
)
{
return
this
.
createUniform
(
'
vertex
'
,
type
,
node
,
ns
,
needsUpdate
);
return
this
.
createUniform
(
'
vertex
'
,
type
,
node
,
ns
,
needsUpdate
,
label
);
},
createFragmentUniform
:
function
(
type
,
node
,
ns
,
needsUpdate
)
{
createFragmentUniform
:
function
(
type
,
node
,
ns
,
needsUpdate
,
label
)
{
return
this
.
createUniform
(
'
fragment
'
,
type
,
node
,
ns
,
needsUpdate
);
return
this
.
createUniform
(
'
fragment
'
,
type
,
node
,
ns
,
needsUpdate
,
label
);
},
...
...
examples/js/nodes/core/TempNode.js
浏览文件 @
8dddb4e1
...
...
@@ -23,9 +23,9 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
output
=
output
||
this
.
getType
(
builder
);
if
(
this
.
is
Shared
(
builder
,
output
)
)
{
if
(
this
.
get
Shared
(
builder
,
output
)
)
{
var
isUnique
=
this
.
is
Unique
(
builder
,
output
);
var
isUnique
=
this
.
get
Unique
(
builder
,
output
);
if
(
isUnique
&&
this
.
constructor
.
uuid
===
undefined
)
{
...
...
@@ -40,7 +40,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
if
(
builder
.
parsing
)
{
if
(
(
data
.
deps
||
0
)
>
0
)
{
if
(
(
data
.
deps
||
0
)
>
0
||
this
.
getLabel
()
)
{
this
.
appendDepsNode
(
builder
,
data
,
output
);
...
...
@@ -56,7 +56,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
return
data
.
name
;
}
else
if
(
!
this
.
isShared
(
builder
,
type
)
||
(
!
builder
.
optimize
||
data
.
deps
==
1
)
)
{
}
else
if
(
!
this
.
getLabel
()
&&
(
!
this
.
getShared
(
builder
,
type
)
||
(
!
builder
.
optimize
||
data
.
deps
===
1
)
)
)
{
return
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
...
...
@@ -88,23 +88,37 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
};
TempNode
.
prototype
.
is
Shared
=
function
(
builder
,
output
)
{
TempNode
.
prototype
.
get
Shared
=
function
(
builder
,
output
)
{
return
output
!==
'
sampler2D
'
&&
output
!==
'
samplerCube
'
&&
this
.
shared
;
};
TempNode
.
prototype
.
is
Unique
=
function
(
builder
,
output
)
{
TempNode
.
prototype
.
get
Unique
=
function
(
builder
,
output
)
{
return
this
.
unique
;
};
TempNode
.
prototype
.
setLabel
=
function
(
name
)
{
this
.
label
=
name
;
return
this
;
};
TempNode
.
prototype
.
getLabel
=
function
(
builder
)
{
return
this
.
label
;
};
TempNode
.
prototype
.
getUuid
=
function
(
unique
)
{
var
uuid
=
unique
||
unique
==
undefined
?
this
.
constructor
.
uuid
||
this
.
uuid
:
this
.
uuid
;
if
(
typeof
this
.
scope
==
"
string
"
)
uuid
=
this
.
scope
+
'
-
'
+
uuid
;
if
(
typeof
this
.
scope
==
=
"
string
"
)
uuid
=
this
.
scope
+
'
-
'
+
uuid
;
return
uuid
;
...
...
@@ -122,11 +136,11 @@ TempNode.prototype.getTemp = function ( builder, uuid ) {
TempNode
.
prototype
.
generate
=
function
(
builder
,
output
,
uuid
,
type
,
ns
)
{
if
(
!
this
.
is
Shared
(
builder
,
output
)
)
console
.
error
(
"
THREE.TempNode is not shared!
"
);
if
(
!
this
.
get
Shared
(
builder
,
output
)
)
console
.
error
(
"
THREE.TempNode is not shared!
"
);
uuid
=
uuid
||
this
.
uuid
;
return
builder
.
getTempVar
(
uuid
,
type
||
this
.
getType
(
builder
),
ns
).
name
;
return
builder
.
getTempVar
(
uuid
,
type
||
this
.
getType
(
builder
),
ns
,
this
.
getLabel
()
).
name
;
};
...
...
examples/js/nodes/inputs/ScreenNode.js
浏览文件 @
8dddb4e1
...
...
@@ -15,7 +15,7 @@ ScreenNode.prototype = Object.create( TextureNode.prototype );
ScreenNode
.
prototype
.
constructor
=
ScreenNode
;
ScreenNode
.
prototype
.
nodeType
=
"
Screen
"
;
ScreenNode
.
prototype
.
is
Unique
=
function
()
{
ScreenNode
.
prototype
.
get
Unique
=
function
()
{
return
true
;
...
...
examples/js/nodes/utils/TimerNode.js
浏览文件 @
8dddb4e1
...
...
@@ -24,7 +24,7 @@ TimerNode.prototype = Object.create( FloatNode.prototype );
TimerNode
.
prototype
.
constructor
=
TimerNode
;
TimerNode
.
prototype
.
nodeType
=
"
Timer
"
;
TimerNode
.
prototype
.
is
Readonly
=
function
()
{
TimerNode
.
prototype
.
get
Readonly
=
function
()
{
// never use TimerNode as readonly but aways as "uniform"
...
...
@@ -32,7 +32,7 @@ TimerNode.prototype.isReadonly = function () {
};
TimerNode
.
prototype
.
is
Unique
=
function
()
{
TimerNode
.
prototype
.
get
Unique
=
function
()
{
// share TimerNode "uniform" input if is used on more time with others TimerNode
...
...
examples/js/nodes/utils/VelocityNode.js
浏览文件 @
8dddb4e1
...
...
@@ -21,7 +21,7 @@ VelocityNode.prototype = Object.create( Vector3Node.prototype );
VelocityNode
.
prototype
.
constructor
=
VelocityNode
;
VelocityNode
.
prototype
.
nodeType
=
"
Velocity
"
;
VelocityNode
.
prototype
.
is
Readonly
=
function
(
builder
)
{
VelocityNode
.
prototype
.
get
Readonly
=
function
(
builder
)
{
return
false
;
...
...
examples/webgl_materials_nodes.html
浏览文件 @
8dddb4e1
...
...
@@ -203,6 +203,7 @@
'
misc / varying
'
:
'
varying
'
,
'
misc / void-function
'
:
'
void-function
'
,
'
misc / readonly
'
:
'
readonly
'
,
'
misc / label
'
:
'
label
'
,
'
misc / custom-attribute
'
:
'
custom-attribute
'
}
).
onFinishChange
(
function
()
{
...
...
@@ -274,8 +275,9 @@
}
var
name
=
param
.
example
;
var
mtl
;
var
name
=
param
.
example
,
defaultSide
=
THREE
.
DoubleSide
,
mtl
;
clearGui
();
...
...
@@ -1576,6 +1578,8 @@
mtl
.
environment
=
new
THREE
.
ColorNode
(
0xFFFFFF
);
mtl
.
alpha
=
clouds
;
defaultSide
=
THREE
.
FrontSide
;
// GUI
addGui
(
'
color
'
,
mtl
.
environment
.
value
.
getHex
(),
function
(
val
)
{
...
...
@@ -2243,6 +2247,7 @@
//THREE.NodeLib.add( new THREE.ConstNode("float MY_CONST .05") )
// reserved keywords
console
.
log
(
THREE
.
NodeLib
.
keywords
);
// keywords conflit? use this to disable:
...
...
@@ -2521,15 +2526,55 @@
mtl
=
new
THREE
.
PhongNodeMaterial
();
mtl
.
color
=
new
THREE
.
ColorNode
(
0xFFFFFF
);
mtl
.
specular
=
new
THREE
.
FloatNode
(
.
5
);
mtl
.
shininess
=
new
THREE
.
FloatNode
(
15
);
// not use "uniform" input ( for optimization )
// instead use explicit declaration, for example:
// vec3( 1.0, 1.0, 1.0 ) instead "uniform vec3"
// if readonly is true not allow change the value after build the shader material
mtl
.
color
.
readonly
=
mtl
.
specular
.
readonly
=
mtl
.
shininess
.
readonly
=
true
;
mtl
.
color
=
new
THREE
.
ColorNode
(
0xFFFFFF
).
setReadonly
(
true
);
mtl
.
specular
=
new
THREE
.
FloatNode
(
.
5
).
setReadonly
(
true
);
mtl
.
shininess
=
new
THREE
.
FloatNode
(
15
).
setReadonly
(
true
);
break
;
case
'
label
'
:
// MATERIAL
mtl
=
new
THREE
.
PhongNodeMaterial
();
// label can be useful for finding the nodes as variables in debug level
// but this always force the creation of a variable
// same as the code can be writed in the same line (inline)
// for optimization this is not recommended
var
colorInput
=
new
THREE
.
ColorNode
(
0xFFFFFF
).
setLabel
(
"
colorInput
"
);
var
specularInput
=
new
THREE
.
FloatNode
(
.
5
).
setLabel
(
"
specularInput
"
);
var
colorMix
=
new
THREE
.
OperatorNode
(
colorInput
,
new
THREE
.
ColorNode
(
0x6495ED
).
setReadonly
(
true
),
THREE
.
OperatorNode
.
MUL
).
setLabel
(
"
colorMix
"
);
mtl
.
color
=
colorMix
;
mtl
.
specular
=
specularInput
;
// default: without use label
// this is optimized writed the code in a single line (inline)
// for the reason that this node is used only once in this shader program
mtl
.
shininess
=
new
THREE
.
OperatorNode
(
new
THREE
.
FloatNode
(
10
).
setReadonly
(
true
),
new
THREE
.
FloatNode
(
5
).
setReadonly
(
true
),
THREE
.
OperatorNode
.
ADD
);
mtl
.
build
();
// show names glsl fragment shader
// open console e find using CTRL+F "colorMix" for example
console
.
log
(
mtl
.
fragmentShader
);
break
;
...
...
@@ -2848,7 +2893,7 @@
// set material
mtl
.
side
=
THREE
.
Double
Side
;
mtl
.
side
=
default
Side
;
mesh
.
material
=
mtl
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录