Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
95c6dcc9
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,发现更多精彩内容 >>
未验证
提交
95c6dcc9
编写于
6月 20, 2019
作者:
M
Mr.doob
提交者:
GitHub
6月 20, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16796 from sunag/dev-fix-TextureCubeNode
NodeMaterial revision
上级
604925a8
5990dce0
变更
34
隐藏空白更改
内联
并排
Showing
34 changed file
with
1021 addition
and
700 deletion
+1021
-700
examples/files.js
examples/files.js
+1
-0
examples/js/nodes/Nodes.js
examples/js/nodes/Nodes.js
+1
-3
examples/js/nodes/THREE.Nodes.js
examples/js/nodes/THREE.Nodes.js
+2
-6
examples/js/nodes/core/ConstNode.js
examples/js/nodes/core/ConstNode.js
+3
-3
examples/js/nodes/core/FunctionNode.js
examples/js/nodes/core/FunctionNode.js
+4
-4
examples/js/nodes/core/Node.js
examples/js/nodes/core/Node.js
+14
-11
examples/js/nodes/core/NodeBuilder.js
examples/js/nodes/core/NodeBuilder.js
+5
-2
examples/js/nodes/core/StructNode.js
examples/js/nodes/core/StructNode.js
+2
-2
examples/js/nodes/core/TempNode.js
examples/js/nodes/core/TempNode.js
+2
-2
examples/js/nodes/inputs/CubeTextureNode.js
examples/js/nodes/inputs/CubeTextureNode.js
+17
-5
examples/js/nodes/inputs/TextureNode.js
examples/js/nodes/inputs/TextureNode.js
+18
-6
examples/js/nodes/materials/NodeMaterial.js
examples/js/nodes/materials/NodeMaterial.js
+16
-14
examples/js/nodes/materials/nodes/PhongNode.js
examples/js/nodes/materials/nodes/PhongNode.js
+29
-29
examples/js/nodes/materials/nodes/RawNode.js
examples/js/nodes/materials/nodes/RawNode.js
+1
-1
examples/js/nodes/materials/nodes/SpriteNode.js
examples/js/nodes/materials/nodes/SpriteNode.js
+8
-8
examples/js/nodes/materials/nodes/StandardNode.js
examples/js/nodes/materials/nodes/StandardNode.js
+48
-33
examples/js/nodes/math/CondNode.js
examples/js/nodes/math/CondNode.js
+7
-7
examples/js/nodes/math/Math1Node.js
examples/js/nodes/math/Math1Node.js
+0
-117
examples/js/nodes/math/Math2Node.js
examples/js/nodes/math/Math2Node.js
+0
-140
examples/js/nodes/math/Math3Node.js
examples/js/nodes/math/Math3Node.js
+0
-121
examples/js/nodes/math/MathNode.js
examples/js/nodes/math/MathNode.js
+268
-0
examples/js/nodes/misc/TextureCubeNode.js
examples/js/nodes/misc/TextureCubeNode.js
+64
-13
examples/js/nodes/misc/TextureCubeUVNode.js
examples/js/nodes/misc/TextureCubeUVNode.js
+3
-4
examples/js/nodes/utils/ColorSpaceNode.js
examples/js/nodes/utils/ColorSpaceNode.js
+48
-38
examples/nodes/caustic.json
examples/nodes/caustic.json
+1
-1
examples/nodes/displace.json
examples/nodes/displace.json
+1
-1
examples/nodes/wave.json
examples/nodes/wave.json
+1
-1
examples/nodes/xray.json
examples/nodes/xray.json
+1
-1
examples/webgl_materials_envmaps_hdr_nodes.html
examples/webgl_materials_envmaps_hdr_nodes.html
+302
-0
examples/webgl_materials_nodes.html
examples/webgl_materials_nodes.html
+120
-93
examples/webgl_mirror_nodes.html
examples/webgl_mirror_nodes.html
+2
-2
examples/webgl_postprocessing_nodes.html
examples/webgl_postprocessing_nodes.html
+15
-15
examples/webgl_postprocessing_nodes_pass.html
examples/webgl_postprocessing_nodes_pass.html
+13
-13
examples/webgl_sprites_nodes.html
examples/webgl_sprites_nodes.html
+4
-4
未找到文件。
examples/files.js
浏览文件 @
95c6dcc9
...
...
@@ -159,6 +159,7 @@ var files = {
"
webgl_materials_envmaps
"
,
"
webgl_materials_envmaps_exr
"
,
"
webgl_materials_envmaps_hdr
"
,
"
webgl_materials_envmaps_hdr_nodes
"
,
"
webgl_materials_envmaps_parallax
"
,
"
webgl_materials_grass
"
,
"
webgl_materials_lightmap
"
,
...
...
examples/js/nodes/Nodes.js
浏览文件 @
95c6dcc9
...
...
@@ -50,9 +50,7 @@ export { ResolutionNode } from './accessors/ResolutionNode.js';
// math
export
{
Math1Node
}
from
'
./math/Math1Node.js
'
;
export
{
Math2Node
}
from
'
./math/Math2Node.js
'
;
export
{
Math3Node
}
from
'
./math/Math3Node.js
'
;
export
{
MathNode
}
from
'
./math/MathNode.js
'
;
export
{
OperatorNode
}
from
'
./math/OperatorNode.js
'
;
export
{
CondNode
}
from
'
./math/CondNode.js
'
;
...
...
examples/js/nodes/THREE.Nodes.js
浏览文件 @
95c6dcc9
...
...
@@ -50,9 +50,7 @@ import {
// math
Math1Node
,
Math2Node
,
Math3Node
,
MathNode
,
OperatorNode
,
CondNode
,
...
...
@@ -163,9 +161,7 @@ THREE.ResolutionNode = ResolutionNode;
// math
THREE
.
Math1Node
=
Math1Node
;
THREE
.
Math2Node
=
Math2Node
;
THREE
.
Math3Node
=
Math3Node
;
THREE
.
MathNode
=
MathNode
;
THREE
.
OperatorNode
=
OperatorNode
;
THREE
.
CondNode
=
CondNode
;
...
...
examples/js/nodes/core/ConstNode.js
浏览文件 @
95c6dcc9
...
...
@@ -10,7 +10,7 @@ function ConstNode( src, useDefine ) {
TempNode
.
call
(
this
);
this
.
eval
(
src
||
ConstNode
.
PI
,
useDefine
);
this
.
parse
(
src
||
ConstNode
.
PI
,
useDefine
);
}
...
...
@@ -31,7 +31,7 @@ ConstNode.prototype.getType = function ( builder ) {
};
ConstNode
.
prototype
.
eval
=
function
(
src
,
useDefine
)
{
ConstNode
.
prototype
.
parse
=
function
(
src
,
useDefine
)
{
this
.
src
=
src
||
''
;
...
...
@@ -100,7 +100,7 @@ ConstNode.prototype.copy = function ( source ) {
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
eval
(
source
.
src
,
source
.
useDefine
);
this
.
parse
(
source
.
src
,
source
.
useDefine
);
};
...
...
examples/js/nodes/core/FunctionNode.js
浏览文件 @
95c6dcc9
...
...
@@ -15,7 +15,7 @@ function FunctionNode( src, includes, extensions, keywords, type ) {
TempNode
.
call
(
this
,
type
);
this
.
eval
(
src
,
includes
,
extensions
,
keywords
);
this
.
parse
(
src
,
includes
,
extensions
,
keywords
);
}
...
...
@@ -117,7 +117,7 @@ FunctionNode.prototype.generate = function ( builder, output ) {
}
if
(
prop
!=
reference
)
{
if
(
prop
!=
=
reference
)
{
src
=
src
.
substring
(
0
,
match
.
index
+
offset
)
+
reference
+
src
.
substring
(
match
.
index
+
prop
.
length
+
offset
);
...
...
@@ -151,7 +151,7 @@ FunctionNode.prototype.generate = function ( builder, output ) {
};
FunctionNode
.
prototype
.
eval
=
function
(
src
,
includes
,
extensions
,
keywords
)
{
FunctionNode
.
prototype
.
parse
=
function
(
src
,
includes
,
extensions
,
keywords
)
{
this
.
src
=
src
||
''
;
...
...
@@ -222,7 +222,7 @@ FunctionNode.prototype.copy = function ( source ) {
this
.
isMethod
=
source
.
isMethod
;
this
.
useKeywords
=
source
.
useKeywords
;
this
.
eval
(
source
.
src
,
source
.
includes
,
source
.
extensions
,
source
.
keywords
);
this
.
parse
(
source
.
src
,
source
.
includes
,
source
.
extensions
,
source
.
keywords
);
if
(
source
.
type
!==
undefined
)
this
.
type
=
source
.
type
;
...
...
examples/js/nodes/core/Node.js
浏览文件 @
95c6dcc9
...
...
@@ -20,11 +20,11 @@ Node.prototype = {
isNode
:
true
,
pars
e
:
function
(
builder
,
settings
)
{
analyz
e
:
function
(
builder
,
settings
)
{
settings
=
settings
||
{};
builder
.
pars
ing
=
true
;
builder
.
analyz
ing
=
true
;
this
.
build
(
builder
.
addFlow
(
settings
.
slot
,
settings
.
cache
,
settings
.
context
),
'
v4
'
);
...
...
@@ -33,31 +33,34 @@ Node.prototype = {
builder
.
removeFlow
();
builder
.
pars
ing
=
false
;
builder
.
analyz
ing
=
false
;
},
parseAndBuildCode
:
function
(
builder
,
output
,
settings
)
{
analyzeAndFlow
:
function
(
builder
,
output
,
settings
)
{
settings
=
settings
||
{};
this
.
pars
e
(
builder
,
settings
);
this
.
analyz
e
(
builder
,
settings
);
return
this
.
buildCode
(
builder
,
output
,
settings
);
return
this
.
flow
(
builder
,
output
,
settings
);
},
buildCode
:
function
(
builder
,
output
,
settings
)
{
flow
:
function
(
builder
,
output
,
settings
)
{
settings
=
settings
||
{};
var
data
=
{
result
:
this
.
build
(
builder
.
addFlow
(
settings
.
slot
,
settings
.
cache
,
settings
.
context
),
output
)
};
builder
.
addFlow
(
settings
.
slot
,
settings
.
cache
,
settings
.
context
)
data
.
code
=
builder
.
clearNodeCode
();
var
flow
=
{};
flow
.
result
=
this
.
build
(
builder
,
output
);
flow
.
code
=
builder
.
clearNodeCode
();
flow
.
extra
=
builder
.
context
.
extra
;
builder
.
removeFlow
();
return
data
;
return
flow
;
},
...
...
@@ -67,7 +70,7 @@ Node.prototype = {
var
data
=
builder
.
getNodeData
(
uuid
||
this
);
if
(
builder
.
pars
ing
)
{
if
(
builder
.
analyz
ing
)
{
this
.
appendDepsNode
(
builder
,
data
,
output
);
...
...
examples/js/nodes/core/NodeBuilder.js
浏览文件 @
95c6dcc9
...
...
@@ -13,6 +13,8 @@ import { Vector3Node } from '../inputs/Vector3Node.js';
import
{
Vector4Node
}
from
'
../inputs/Vector4Node.js
'
;
import
{
TextureNode
}
from
'
../inputs/TextureNode.js
'
;
import
{
CubeTextureNode
}
from
'
../inputs/CubeTextureNode.js
'
;
import
{
TextureCubeNode
}
from
'
../misc/TextureCubeNode.js
'
;
var
elements
=
NodeUtils
.
elements
,
constructors
=
[
'
float
'
,
'
vec2
'
,
'
vec3
'
,
'
vec4
'
],
...
...
@@ -140,8 +142,7 @@ function NodeBuilder() {
// --
this
.
parsing
=
false
;
this
.
optimize
=
true
;
this
.
analyzing
=
false
;
}
...
...
@@ -278,6 +279,8 @@ NodeBuilder.prototype = {
addContext
:
function
(
context
)
{
this
.
context
=
Object
.
assign
(
{},
this
.
context
,
context
);
this
.
context
.
extra
=
this
.
context
.
extra
||
{};
this
.
contexts
.
push
(
this
.
context
);
return
this
;
...
...
examples/js/nodes/core/StructNode.js
浏览文件 @
95c6dcc9
...
...
@@ -11,7 +11,7 @@ function StructNode( src ) {
TempNode
.
call
(
this
);
this
.
eval
(
src
);
this
.
parse
(
src
);
}
...
...
@@ -55,7 +55,7 @@ StructNode.prototype.generate = function ( builder, output ) {
};
StructNode
.
prototype
.
eval
=
function
(
src
)
{
StructNode
.
prototype
.
parse
=
function
(
src
)
{
this
.
src
=
src
||
''
;
...
...
examples/js/nodes/core/TempNode.js
浏览文件 @
95c6dcc9
...
...
@@ -38,7 +38,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
var
data
=
builder
.
getNodeData
(
uuid
),
type
=
data
.
output
||
this
.
getType
(
builder
);
if
(
builder
.
pars
ing
)
{
if
(
builder
.
analyz
ing
)
{
if
(
(
data
.
deps
||
0
)
>
0
||
this
.
getLabel
()
)
{
...
...
@@ -56,7 +56,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
return
data
.
name
;
}
else
if
(
!
this
.
getLabel
()
&&
(
!
this
.
getShared
(
builder
,
type
)
||
(
!
builder
.
optimiz
e
||
data
.
deps
===
1
)
)
)
{
}
else
if
(
!
this
.
getLabel
()
&&
(
!
this
.
getShared
(
builder
,
type
)
||
(
builder
.
context
.
ignoreCach
e
||
data
.
deps
===
1
)
)
)
{
return
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
...
...
examples/js/nodes/inputs/CubeTextureNode.js
浏览文件 @
95c6dcc9
...
...
@@ -5,6 +5,7 @@
import
{
InputNode
}
from
'
../core/InputNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
function
CubeTextureNode
(
value
,
uv
,
bias
)
{
...
...
@@ -49,16 +50,27 @@ CubeTextureNode.prototype.generate = function ( builder, output ) {
if
(
bias
)
code
=
'
texCubeBias(
'
+
cubetex
+
'
,
'
+
uv
+
'
,
'
+
bias
+
'
)
'
;
else
code
=
'
texCube(
'
+
cubetex
+
'
,
'
+
uv
+
'
)
'
;
// add this context to replace ColorSpaceNode.input to code
// add a custom context for fix incompatibility with the core
// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
// this should be removed in the future
// context.include =: is used to include or not functions if used FunctionNode
// context.ignoreCache =: not create variables temp nodeT0..9 to optimize the code
var
context
=
{
include
:
builder
.
isShader
(
'
vertex
'
),
ignoreCache
:
true
};
var
outputType
=
this
.
getType
(
builder
);
builder
.
addContext
(
{
input
:
code
,
encoding
:
builder
.
getTextureEncodingFromMap
(
this
.
value
),
include
:
builder
.
isShader
(
'
vertex
'
)
}
);
builder
.
addContext
(
context
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
this
);
code
=
this
.
colorSpace
.
build
(
builder
,
this
.
type
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
new
ExpressionNode
(
''
,
outputType
)
);
this
.
colorSpace
.
fromEncoding
(
builder
.
getTextureEncodingFromMap
(
this
.
value
)
);
this
.
colorSpace
.
input
.
parse
(
code
);
code
=
this
.
colorSpace
.
build
(
builder
,
outputType
);
// end custom context
builder
.
removeContext
();
return
builder
.
format
(
code
,
this
.
t
ype
,
output
);
return
builder
.
format
(
code
,
outputT
ype
,
output
);
};
...
...
examples/js/nodes/inputs/TextureNode.js
浏览文件 @
95c6dcc9
...
...
@@ -5,6 +5,7 @@
import
{
InputNode
}
from
'
../core/InputNode.js
'
;
import
{
UVNode
}
from
'
../accessors/UVNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
function
TextureNode
(
value
,
uv
,
bias
,
project
)
{
...
...
@@ -39,7 +40,7 @@ TextureNode.prototype.generate = function ( builder, output ) {
uv
=
this
.
uv
.
build
(
builder
,
this
.
project
?
'
v4
'
:
'
v2
'
),
bias
=
this
.
bias
?
this
.
bias
.
build
(
builder
,
'
f
'
)
:
undefined
;
if
(
bias
==
undefined
&&
builder
.
context
.
bias
)
{
if
(
bias
==
=
undefined
&&
builder
.
context
.
bias
)
{
bias
=
new
builder
.
context
.
bias
(
this
).
build
(
builder
,
'
f
'
);
...
...
@@ -53,16 +54,27 @@ TextureNode.prototype.generate = function ( builder, output ) {
if
(
bias
)
code
=
method
+
'
(
'
+
tex
+
'
,
'
+
uv
+
'
,
'
+
bias
+
'
)
'
;
else
code
=
method
+
'
(
'
+
tex
+
'
,
'
+
uv
+
'
)
'
;
// add this context to replace ColorSpaceNode.input to code
// add a custom context for fix incompatibility with the core
// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
// this should be removed in the future
// context.include is used to include or not functions if used FunctionNode
// context.ignoreCache =: not create temp variables nodeT0..9 to optimize the code
var
context
=
{
include
:
builder
.
isShader
(
'
vertex
'
),
ignoreCache
:
true
};
var
outputType
=
this
.
getType
(
builder
);
builder
.
addContext
(
{
input
:
code
,
encoding
:
builder
.
getTextureEncodingFromMap
(
this
.
value
),
include
:
builder
.
isShader
(
'
vertex
'
)
}
);
builder
.
addContext
(
context
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
this
);
code
=
this
.
colorSpace
.
build
(
builder
,
this
.
type
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
new
ExpressionNode
(
''
,
outputType
)
);
this
.
colorSpace
.
fromEncoding
(
builder
.
getTextureEncodingFromMap
(
this
.
value
)
);
this
.
colorSpace
.
input
.
parse
(
code
);
code
=
this
.
colorSpace
.
build
(
builder
,
outputType
);
// end custom context
builder
.
removeContext
();
return
builder
.
format
(
code
,
this
.
t
ype
,
output
);
return
builder
.
format
(
code
,
outputT
ype
,
output
);
};
...
...
examples/js/nodes/materials/NodeMaterial.js
浏览文件 @
95c6dcc9
...
...
@@ -18,6 +18,22 @@ function NodeMaterial( vertex, fragment ) {
this
.
updaters
=
[];
// onBeforeCompile can't be in the prototype because onBeforeCompile.toString varies per material
this
.
onBeforeCompile
=
function
(
shader
,
renderer
)
{
if
(
this
.
needsUpdate
)
{
this
.
build
(
{
renderer
:
renderer
}
);
shader
.
uniforms
=
this
.
uniforms
;
shader
.
vertexShader
=
this
.
vertexShader
;
shader
.
fragmentShader
=
this
.
fragmentShader
;
}
};
// it fix the programCache and share the code with others materials
this
.
onBeforeCompile
.
toString
=
function
()
{
...
...
@@ -74,20 +90,6 @@ NodeMaterial.prototype.updateFrame = function ( frame ) {
};
NodeMaterial
.
prototype
.
onBeforeCompile
=
function
(
shader
,
renderer
)
{
if
(
this
.
needsUpdate
)
{
this
.
build
(
{
renderer
:
renderer
}
);
shader
.
uniforms
=
this
.
uniforms
;
shader
.
vertexShader
=
this
.
vertexShader
;
shader
.
fragmentShader
=
this
.
fragmentShader
;
}
};
NodeMaterial
.
prototype
.
build
=
function
(
params
)
{
params
=
params
||
{};
...
...
examples/js/nodes/materials/nodes/PhongNode.js
浏览文件 @
95c6dcc9
...
...
@@ -30,7 +30,7 @@ PhongNode.prototype.build = function ( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
analyzeAndFlow
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
...
...
@@ -101,51 +101,51 @@ PhongNode.prototype.build = function ( builder ) {
}
else
{
//
pars
e all nodes to reuse generate codes
//
analyz
e all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
pars
e
(
builder
);
if
(
this
.
mask
)
this
.
mask
.
analyz
e
(
builder
);
this
.
color
.
pars
e
(
builder
,
{
slot
:
'
color
'
}
);
this
.
specular
.
pars
e
(
builder
);
this
.
shininess
.
pars
e
(
builder
);
this
.
color
.
analyz
e
(
builder
,
{
slot
:
'
color
'
}
);
this
.
specular
.
analyz
e
(
builder
);
this
.
shininess
.
analyz
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
pars
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
analyz
e
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
pars
e
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
analyz
e
(
builder
);
if
(
this
.
light
)
this
.
light
.
pars
e
(
builder
,
{
cache
:
'
light
'
}
);
if
(
this
.
light
)
this
.
light
.
analyz
e
(
builder
,
{
cache
:
'
light
'
}
);
if
(
this
.
ao
)
this
.
ao
.
pars
e
(
builder
);
if
(
this
.
ambient
)
this
.
ambient
.
pars
e
(
builder
);
if
(
this
.
shadow
)
this
.
shadow
.
pars
e
(
builder
);
if
(
this
.
emissive
)
this
.
emissive
.
pars
e
(
builder
,
{
slot
:
'
emissive
'
}
);
if
(
this
.
ao
)
this
.
ao
.
analyz
e
(
builder
);
if
(
this
.
ambient
)
this
.
ambient
.
analyz
e
(
builder
);
if
(
this
.
shadow
)
this
.
shadow
.
analyz
e
(
builder
);
if
(
this
.
emissive
)
this
.
emissive
.
analyz
e
(
builder
,
{
slot
:
'
emissive
'
}
);
if
(
this
.
environment
)
this
.
environment
.
pars
e
(
builder
,
{
slot
:
'
environment
'
}
);
if
(
this
.
environmentAlpha
&&
this
.
environment
)
this
.
environmentAlpha
.
pars
e
(
builder
);
if
(
this
.
environment
)
this
.
environment
.
analyz
e
(
builder
,
{
slot
:
'
environment
'
}
);
if
(
this
.
environmentAlpha
&&
this
.
environment
)
this
.
environmentAlpha
.
analyz
e
(
builder
);
// build code
var
mask
=
this
.
mask
?
this
.
mask
.
buildCode
(
builder
,
'
b
'
)
:
undefined
;
var
mask
=
this
.
mask
?
this
.
mask
.
flow
(
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
'
);
var
color
=
this
.
color
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
);
var
specular
=
this
.
specular
.
flow
(
builder
,
'
c
'
);
var
shininess
=
this
.
shininess
.
flow
(
builder
,
'
f
'
);
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
alpha
=
this
.
alpha
?
this
.
alpha
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
buildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
flow
(
builder
,
'
v3
'
)
:
undefined
;
var
light
=
this
.
light
?
this
.
light
.
buildCode
(
builder
,
'
v3
'
,
{
cache
:
'
light
'
}
)
:
undefined
;
var
light
=
this
.
light
?
this
.
light
.
flow
(
builder
,
'
v3
'
,
{
cache
:
'
light
'
}
)
:
undefined
;
var
ao
=
this
.
ao
?
this
.
ao
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
ambient
=
this
.
ambient
?
this
.
ambient
.
buildCode
(
builder
,
'
c
'
)
:
undefined
;
var
shadow
=
this
.
shadow
?
this
.
shadow
.
buildCode
(
builder
,
'
c
'
)
:
undefined
;
var
emissive
=
this
.
emissive
?
this
.
emissive
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
emissive
'
}
)
:
undefined
;
var
ao
=
this
.
ao
?
this
.
ao
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
ambient
=
this
.
ambient
?
this
.
ambient
.
flow
(
builder
,
'
c
'
)
:
undefined
;
var
shadow
=
this
.
shadow
?
this
.
shadow
.
flow
(
builder
,
'
c
'
)
:
undefined
;
var
emissive
=
this
.
emissive
?
this
.
emissive
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
emissive
'
}
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
environment
'
}
)
:
undefined
;
var
environmentAlpha
=
this
.
environmentAlpha
&&
this
.
environment
?
this
.
environmentAlpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
environment
'
}
)
:
undefined
;
var
environmentAlpha
=
this
.
environmentAlpha
&&
this
.
environment
?
this
.
environmentAlpha
.
flow
(
builder
,
'
f
'
)
:
undefined
;
builder
.
requires
.
transparent
=
alpha
!=
undefined
;
builder
.
requires
.
transparent
=
alpha
!=
=
undefined
;
builder
.
addParsCode
(
[
"
#include <fog_pars_fragment>
"
,
...
...
examples/js/nodes/materials/nodes/RawNode.js
浏览文件 @
95c6dcc9
...
...
@@ -18,7 +18,7 @@ RawNode.prototype.nodeType = "Raw";
RawNode
.
prototype
.
generate
=
function
(
builder
)
{
var
data
=
this
.
value
.
parseAndBuildCode
(
builder
,
this
.
type
),
var
data
=
this
.
value
.
analyzeAndFlow
(
builder
,
this
.
type
),
code
=
data
.
code
+
'
\n
'
;
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
...
...
examples/js/nodes/materials/nodes/SpriteNode.js
浏览文件 @
95c6dcc9
...
...
@@ -29,7 +29,7 @@ SpriteNode.prototype.build = function ( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
analyzeAndFlow
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
THREE
.
UniformsLib
.
fog
...
...
@@ -121,19 +121,19 @@ SpriteNode.prototype.build = function ( builder ) {
"
#include <logdepthbuf_fragment>
"
].
join
(
"
\n
"
)
);
//
pars
e all nodes to reuse generate codes
//
analyz
e all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
pars
e
(
builder
);
if
(
this
.
mask
)
this
.
mask
.
analyz
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
pars
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
analyz
e
(
builder
);
this
.
color
.
pars
e
(
builder
,
{
slot
:
'
color
'
}
);
this
.
color
.
analyz
e
(
builder
,
{
slot
:
'
color
'
}
);
// build code
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
'
}
),
var
mask
=
this
.
mask
?
this
.
mask
.
flow
(
builder
,
'
b
'
)
:
undefined
,
alpha
=
this
.
alpha
?
this
.
alpha
.
flow
(
builder
,
'
f
'
)
:
undefined
,
color
=
this
.
color
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
),
output
=
[];
if
(
mask
)
{
...
...
examples/js/nodes/materials/nodes/StandardNode.js
浏览文件 @
95c6dcc9
...
...
@@ -33,7 +33,7 @@ StandardNode.prototype.build = function ( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
analyzeAndFlow
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
...
...
@@ -42,6 +42,15 @@ StandardNode.prototype.build = function ( builder ) {
]
)
);
if
(
THREE
.
UniformsLib
.
LTC_1
)
{
// add ltc data textures to material uniforms
builder
.
uniforms
.
ltc_1
=
{
value
:
undefined
};
builder
.
uniforms
.
ltc_2
=
{
value
:
undefined
};
}
builder
.
addParsCode
(
[
"
varying vec3 vViewPosition;
"
,
...
...
@@ -115,59 +124,59 @@ StandardNode.prototype.build = function ( builder ) {
var
useClearCoat
=
!
builder
.
isDefined
(
'
STANDARD
'
);
//
pars
e all nodes to reuse generate codes
//
analyz
e all nodes to reuse generate codes
if
(
this
.
mask
)
this
.
mask
.
pars
e
(
builder
);
if
(
this
.
mask
)
this
.
mask
.
analyz
e
(
builder
);
this
.
color
.
pars
e
(
builder
,
{
slot
:
'
color
'
,
context
:
contextGammaOnly
}
);
this
.
roughness
.
pars
e
(
builder
);
this
.
metalness
.
pars
e
(
builder
);
this
.
color
.
analyz
e
(
builder
,
{
slot
:
'
color
'
,
context
:
contextGammaOnly
}
);
this
.
roughness
.
analyz
e
(
builder
);
this
.
metalness
.
analyz
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
pars
e
(
builder
);
if
(
this
.
alpha
)
this
.
alpha
.
analyz
e
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
pars
e
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
analyz
e
(
builder
);
if
(
this
.
clearCoat
)
this
.
clearCoat
.
pars
e
(
builder
);
if
(
this
.
clearCoatRoughness
)
this
.
clearCoatRoughness
.
pars
e
(
builder
);
if
(
this
.
clearCoat
)
this
.
clearCoat
.
analyz
e
(
builder
);
if
(
this
.
clearCoatRoughness
)
this
.
clearCoatRoughness
.
analyz
e
(
builder
);
if
(
this
.
reflectivity
)
this
.
reflectivity
.
pars
e
(
builder
);
if
(
this
.
reflectivity
)
this
.
reflectivity
.
analyz
e
(
builder
);
if
(
this
.
light
)
this
.
light
.
pars
e
(
builder
,
{
cache
:
'
light
'
}
);
if
(
this
.
light
)
this
.
light
.
analyz
e
(
builder
,
{
cache
:
'
light
'
}
);
if
(
this
.
ao
)
this
.
ao
.
pars
e
(
builder
);
if
(
this
.
ambient
)
this
.
ambient
.
pars
e
(
builder
);
if
(
this
.
shadow
)
this
.
shadow
.
pars
e
(
builder
);
if
(
this
.
emissive
)
this
.
emissive
.
pars
e
(
builder
,
{
slot
:
'
emissive
'
}
);
if
(
this
.
ao
)
this
.
ao
.
analyz
e
(
builder
);
if
(
this
.
ambient
)
this
.
ambient
.
analyz
e
(
builder
);
if
(
this
.
shadow
)
this
.
shadow
.
analyz
e
(
builder
);
if
(
this
.
emissive
)
this
.
emissive
.
analyz
e
(
builder
,
{
slot
:
'
emissive
'
}
);
if
(
this
.
environment
)
this
.
environment
.
pars
e
(
builder
,
{
cache
:
'
env
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
);
// isolate environment from others inputs ( see TextureNode, CubeTextureNode )
if
(
this
.
environment
)
this
.
environment
.
analyz
e
(
builder
,
{
cache
:
'
env
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
);
// isolate environment from others inputs ( see TextureNode, CubeTextureNode )
// build code
var
mask
=
this
.
mask
?
this
.
mask
.
buildCode
(
builder
,
'
b
'
)
:
undefined
;
var
mask
=
this
.
mask
?
this
.
mask
.
flow
(
builder
,
'
b
'
)
:
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
'
);
var
color
=
this
.
color
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
color
'
,
context
:
contextGammaOnly
}
);
var
roughness
=
this
.
roughness
.
flow
(
builder
,
'
f
'
);
var
metalness
=
this
.
metalness
.
flow
(
builder
,
'
f
'
);
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
alpha
=
this
.
alpha
?
this
.
alpha
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
buildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
flow
(
builder
,
'
v3
'
)
:
undefined
;
var
clearCoat
=
this
.
clearCoat
?
this
.
clearCoat
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
clearCoatRoughness
=
this
.
clearCoatRoughness
?
this
.
clearCoatRoughness
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
clearCoat
=
this
.
clearCoat
?
this
.
clearCoat
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
clearCoatRoughness
=
this
.
clearCoatRoughness
?
this
.
clearCoatRoughness
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
reflectivity
=
this
.
reflectivity
?
this
.
reflectivity
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
reflectivity
=
this
.
reflectivity
?
this
.
reflectivity
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
light
=
this
.
light
?
this
.
light
.
buildCode
(
builder
,
'
v3
'
,
{
cache
:
'
light
'
}
)
:
undefined
;
var
light
=
this
.
light
?
this
.
light
.
flow
(
builder
,
'
v3
'
,
{
cache
:
'
light
'
}
)
:
undefined
;
var
ao
=
this
.
ao
?
this
.
ao
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
ambient
=
this
.
ambient
?
this
.
ambient
.
buildCode
(
builder
,
'
c
'
)
:
undefined
;
var
shadow
=
this
.
shadow
?
this
.
shadow
.
buildCode
(
builder
,
'
c
'
)
:
undefined
;
var
emissive
=
this
.
emissive
?
this
.
emissive
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
emissive
'
}
)
:
undefined
;
var
ao
=
this
.
ao
?
this
.
ao
.
flow
(
builder
,
'
f
'
)
:
undefined
;
var
ambient
=
this
.
ambient
?
this
.
ambient
.
flow
(
builder
,
'
c
'
)
:
undefined
;
var
shadow
=
this
.
shadow
?
this
.
shadow
.
flow
(
builder
,
'
c
'
)
:
undefined
;
var
emissive
=
this
.
emissive
?
this
.
emissive
.
flow
(
builder
,
'
c
'
,
{
slot
:
'
emissive
'
}
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
buildCode
(
builder
,
'
c
'
,
{
cache
:
'
env
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
flow
(
builder
,
'
c
'
,
{
cache
:
'
env
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
)
:
undefined
;
var
clearCoatEnv
=
useClearCoat
&&
environment
?
this
.
environment
.
buildCode
(
builder
,
'
c
'
,
{
cache
:
'
clearCoat
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
)
:
undefined
;
var
clearCoatEnv
=
useClearCoat
&&
environment
?
this
.
environment
.
flow
(
builder
,
'
c
'
,
{
cache
:
'
clearCoat
'
,
context
:
contextEnvironment
,
slot
:
'
environment
'
}
)
:
undefined
;
builder
.
requires
.
transparent
=
alpha
!==
undefined
;
...
...
@@ -370,6 +379,12 @@ StandardNode.prototype.build = function ( builder ) {
output
.
push
(
"
radiance +=
"
+
environment
.
result
+
"
;
"
);
if
(
environment
.
extra
.
irradiance
)
{
output
.
push
(
"
irradiance += PI *
"
+
environment
.
extra
.
irradiance
+
"
;
"
);
}
}
output
.
push
(
...
...
examples/js/nodes/math/CondNode.js
浏览文件 @
95c6dcc9
...
...
@@ -32,10 +32,10 @@ CondNode.prototype.nodeType = "Cond";
CondNode
.
prototype
.
getType
=
function
(
builder
)
{
if
(
this
.
ifNode
)
{
var
ifType
=
this
.
ifNode
.
getType
(
builder
);
var
elseType
=
this
.
elseNode
.
getType
(
builder
);
if
(
builder
.
getTypeLength
(
elseType
)
>
builder
.
getTypeLength
(
ifType
)
)
{
return
elseType
;
...
...
@@ -43,7 +43,7 @@ CondNode.prototype.getType = function ( builder ) {
}
return
ifType
;
}
return
'
b
'
;
...
...
@@ -69,18 +69,18 @@ CondNode.prototype.generate = function ( builder, output ) {
a
=
this
.
a
.
build
(
builder
,
condType
),
b
=
this
.
b
.
build
(
builder
,
condType
),
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
);
...
...
examples/js/nodes/math/Math1Node.js
已删除
100644 → 0
浏览文件 @
604925a8
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
Math1Node
(
a
,
method
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
method
=
method
;
}
Math1Node
.
RAD
=
'
radians
'
;
Math1Node
.
DEG
=
'
degrees
'
;
Math1Node
.
EXP
=
'
exp
'
;
Math1Node
.
EXP2
=
'
exp2
'
;
Math1Node
.
LOG
=
'
log
'
;
Math1Node
.
LOG2
=
'
log2
'
;
Math1Node
.
SQRT
=
'
sqrt
'
;
Math1Node
.
INV_SQRT
=
'
inversesqrt
'
;
Math1Node
.
FLOOR
=
'
floor
'
;
Math1Node
.
CEIL
=
'
ceil
'
;
Math1Node
.
NORMALIZE
=
'
normalize
'
;
Math1Node
.
FRACT
=
'
fract
'
;
Math1Node
.
SATURATE
=
'
saturate
'
;
Math1Node
.
SIN
=
'
sin
'
;
Math1Node
.
COS
=
'
cos
'
;
Math1Node
.
TAN
=
'
tan
'
;
Math1Node
.
ASIN
=
'
asin
'
;
Math1Node
.
ACOS
=
'
acos
'
;
Math1Node
.
ARCTAN
=
'
atan
'
;
Math1Node
.
ABS
=
'
abs
'
;
Math1Node
.
SIGN
=
'
sign
'
;
Math1Node
.
LENGTH
=
'
length
'
;
Math1Node
.
NEGATE
=
'
negate
'
;
Math1Node
.
INVERT
=
'
invert
'
;
Math1Node
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
Math1Node
.
prototype
.
constructor
=
Math1Node
;
Math1Node
.
prototype
.
nodeType
=
"
Math1
"
;
Math1Node
.
prototype
.
getType
=
function
(
builder
)
{
switch
(
this
.
method
)
{
case
Math1Node
.
LENGTH
:
return
'
f
'
;
}
return
this
.
a
.
getType
(
builder
);
};
Math1Node
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
type
=
this
.
getType
(
builder
),
result
=
this
.
a
.
build
(
builder
,
type
);
switch
(
this
.
method
)
{
case
Math1Node
.
NEGATE
:
result
=
'
( -
'
+
result
+
'
)
'
;
break
;
case
Math1Node
.
INVERT
:
result
=
'
( 1.0 -
'
+
result
+
'
)
'
;
break
;
default
:
result
=
this
.
method
+
'
(
'
+
result
+
'
)
'
;
break
;
}
return
builder
.
format
(
result
,
type
,
output
);
};
Math1Node
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
method
=
source
.
method
;
};
Math1Node
.
prototype
.
toJSON
=
function
(
meta
)
{
var
data
=
this
.
getJSONNode
(
meta
);
if
(
!
data
)
{
data
=
this
.
createJSONNode
(
meta
);
data
.
a
=
this
.
a
.
toJSON
(
meta
).
uuid
;
data
.
method
=
this
.
method
;
}
return
data
;
};
export
{
Math1Node
};
examples/js/nodes/math/Math2Node.js
已删除
100644 → 0
浏览文件 @
604925a8
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
Math2Node
(
a
,
b
,
method
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
b
=
b
;
this
.
method
=
method
;
}
Math2Node
.
MIN
=
'
min
'
;
Math2Node
.
MAX
=
'
max
'
;
Math2Node
.
MOD
=
'
mod
'
;
Math2Node
.
STEP
=
'
step
'
;
Math2Node
.
REFLECT
=
'
reflect
'
;
Math2Node
.
DISTANCE
=
'
distance
'
;
Math2Node
.
DOT
=
'
dot
'
;
Math2Node
.
CROSS
=
'
cross
'
;
Math2Node
.
POW
=
'
pow
'
;
Math2Node
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
Math2Node
.
prototype
.
constructor
=
Math2Node
;
Math2Node
.
prototype
.
nodeType
=
"
Math2
"
;
Math2Node
.
prototype
.
getInputType
=
function
(
builder
)
{
// use the greater length vector
if
(
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
)
>
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
)
)
{
return
this
.
b
.
getType
(
builder
);
}
return
this
.
a
.
getType
(
builder
);
};
Math2Node
.
prototype
.
getType
=
function
(
builder
)
{
switch
(
this
.
method
)
{
case
Math2Node
.
DISTANCE
:
case
Math2Node
.
DOT
:
return
'
f
'
;
case
Math2Node
.
CROSS
:
return
'
v3
'
;
}
return
this
.
getInputType
(
builder
);
};
Math2Node
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
a
,
b
,
type
=
this
.
getInputType
(
builder
),
al
=
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
),
bl
=
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
);
// optimzer
switch
(
this
.
method
)
{
case
Math2Node
.
CROSS
:
a
=
this
.
a
.
build
(
builder
,
'
v3
'
);
b
=
this
.
b
.
build
(
builder
,
'
v3
'
);
break
;
case
Math2Node
.
STEP
:
a
=
this
.
a
.
build
(
builder
,
al
===
1
?
'
f
'
:
type
);
b
=
this
.
b
.
build
(
builder
,
type
);
break
;
case
Math2Node
.
MIN
:
case
Math2Node
.
MAX
:
case
Math2Node
.
MOD
:
a
=
this
.
a
.
build
(
builder
,
type
);
b
=
this
.
b
.
build
(
builder
,
bl
===
1
?
'
f
'
:
type
);
break
;
default
:
a
=
this
.
a
.
build
(
builder
,
type
);
b
=
this
.
b
.
build
(
builder
,
type
);
break
;
}
return
builder
.
format
(
this
.
method
+
'
(
'
+
a
+
'
,
'
+
b
+
'
)
'
,
this
.
getType
(
builder
),
output
);
};
Math2Node
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
method
=
source
.
method
;
};
Math2Node
.
prototype
.
toJSON
=
function
(
meta
)
{
var
data
=
this
.
getJSONNode
(
meta
);
if
(
!
data
)
{
data
=
this
.
createJSONNode
(
meta
);
data
.
a
=
this
.
a
.
toJSON
(
meta
).
uuid
;
data
.
b
=
this
.
b
.
toJSON
(
meta
).
uuid
;
data
.
method
=
this
.
method
;
}
return
data
;
};
export
{
Math2Node
};
examples/js/nodes/math/Math3Node.js
已删除
100644 → 0
浏览文件 @
604925a8
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
Math3Node
(
a
,
b
,
c
,
method
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
b
=
b
;
this
.
c
=
c
;
this
.
method
=
method
;
}
Math3Node
.
MIX
=
'
mix
'
;
Math3Node
.
CLAMP
=
'
clamp
'
;
Math3Node
.
REFRACT
=
'
refract
'
;
Math3Node
.
SMOOTHSTEP
=
'
smoothstep
'
;
Math3Node
.
FACEFORWARD
=
'
faceforward
'
;
Math3Node
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
Math3Node
.
prototype
.
constructor
=
Math3Node
;
Math3Node
.
prototype
.
nodeType
=
"
Math3
"
;
Math3Node
.
prototype
.
getType
=
function
(
builder
)
{
var
a
=
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
);
var
b
=
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
);
var
c
=
builder
.
getTypeLength
(
this
.
c
.
getType
(
builder
)
);
if
(
a
>
b
&&
a
>
c
)
{
return
this
.
a
.
getType
(
builder
);
}
else
if
(
b
>
c
)
{
return
this
.
b
.
getType
(
builder
);
}
return
this
.
c
.
getType
(
builder
);
};
Math3Node
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
a
,
b
,
c
,
al
=
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
),
bl
=
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
),
cl
=
builder
.
getTypeLength
(
this
.
c
.
getType
(
builder
)
),
type
=
this
.
getType
(
builder
);
// optimzer
switch
(
this
.
method
)
{
case
Math3Node
.
REFRACT
:
a
=
this
.
a
.
build
(
builder
,
type
);
b
=
this
.
b
.
build
(
builder
,
type
);
c
=
this
.
c
.
build
(
builder
,
'
f
'
);
break
;
case
Math3Node
.
MIX
:
a
=
this
.
a
.
build
(
builder
,
type
);
b
=
this
.
b
.
build
(
builder
,
type
);
c
=
this
.
c
.
build
(
builder
,
cl
===
1
?
'
f
'
:
type
);
break
;
default
:
a
=
this
.
a
.
build
(
builder
,
type
);
b
=
this
.
b
.
build
(
builder
,
type
);
c
=
this
.
c
.
build
(
builder
,
type
);
break
;
}
return
builder
.
format
(
this
.
method
+
'
(
'
+
a
+
'
,
'
+
b
+
'
,
'
+
c
+
'
)
'
,
type
,
output
);
};
Math3Node
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
c
=
source
.
c
;
this
.
method
=
source
.
method
;
};
Math3Node
.
prototype
.
toJSON
=
function
(
meta
)
{
var
data
=
this
.
getJSONNode
(
meta
);
if
(
!
data
)
{
data
=
this
.
createJSONNode
(
meta
);
data
.
a
=
this
.
a
.
toJSON
(
meta
).
uuid
;
data
.
b
=
this
.
b
.
toJSON
(
meta
).
uuid
;
data
.
c
=
this
.
c
.
toJSON
(
meta
).
uuid
;
data
.
method
=
this
.
method
;
}
return
data
;
};
export
{
Math3Node
};
examples/js/nodes/math/MathNode.js
0 → 100644
浏览文件 @
95c6dcc9
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
MathNode
(
a
,
bOrMethod
,
cOrMethod
,
method
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
typeof
bOrMethod
!==
'
string
'
?
this
.
b
=
bOrMethod
:
method
=
bOrMethod
;
typeof
cOrMethod
!==
'
string
'
?
this
.
c
=
cOrMethod
:
method
=
cOrMethod
;
this
.
method
=
method
;
}
// 1 input
MathNode
.
RAD
=
'
radians
'
;
MathNode
.
DEG
=
'
degrees
'
;
MathNode
.
EXP
=
'
exp
'
;
MathNode
.
EXP2
=
'
exp2
'
;
MathNode
.
LOG
=
'
log
'
;
MathNode
.
LOG2
=
'
log2
'
;
MathNode
.
SQRT
=
'
sqrt
'
;
MathNode
.
INV_SQRT
=
'
inversesqrt
'
;
MathNode
.
FLOOR
=
'
floor
'
;
MathNode
.
CEIL
=
'
ceil
'
;
MathNode
.
NORMALIZE
=
'
normalize
'
;
MathNode
.
FRACT
=
'
fract
'
;
MathNode
.
SATURATE
=
'
saturate
'
;
MathNode
.
SIN
=
'
sin
'
;
MathNode
.
COS
=
'
cos
'
;
MathNode
.
TAN
=
'
tan
'
;
MathNode
.
ASIN
=
'
asin
'
;
MathNode
.
ACOS
=
'
acos
'
;
MathNode
.
ARCTAN
=
'
atan
'
;
MathNode
.
ABS
=
'
abs
'
;
MathNode
.
SIGN
=
'
sign
'
;
MathNode
.
LENGTH
=
'
length
'
;
MathNode
.
NEGATE
=
'
negate
'
;
MathNode
.
INVERT
=
'
invert
'
;
// 2 inputs
MathNode
.
MIN
=
'
min
'
;
MathNode
.
MAX
=
'
max
'
;
MathNode
.
MOD
=
'
mod
'
;
MathNode
.
STEP
=
'
step
'
;
MathNode
.
REFLECT
=
'
reflect
'
;
MathNode
.
DISTANCE
=
'
distance
'
;
MathNode
.
DOT
=
'
dot
'
;
MathNode
.
CROSS
=
'
cross
'
;
MathNode
.
POW
=
'
pow
'
;
// 3 inputs
MathNode
.
MIX
=
'
mix
'
;
MathNode
.
CLAMP
=
'
clamp
'
;
MathNode
.
REFRACT
=
'
refract
'
;
MathNode
.
SMOOTHSTEP
=
'
smoothstep
'
;
MathNode
.
FACEFORWARD
=
'
faceforward
'
;
MathNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
MathNode
.
prototype
.
constructor
=
MathNode
;
MathNode
.
prototype
.
nodeType
=
"
Math
"
;
MathNode
.
prototype
.
getNumInputs
=
function
(
builder
)
{
switch
(
this
.
method
)
{
case
MathNode
.
MIX
:
case
MathNode
.
CLAMP
:
case
MathNode
.
REFRACT
:
case
MathNode
.
SMOOTHSTEP
:
case
MathNode
.
FACEFORWARD
:
return
3
;
case
MathNode
.
MIN
:
case
MathNode
.
MAX
:
case
MathNode
.
MOD
:
case
MathNode
.
STEP
:
case
MathNode
.
REFLECT
:
case
MathNode
.
DISTANCE
:
case
MathNode
.
DOT
:
case
MathNode
.
CROSS
:
case
MathNode
.
POW
:
return
2
;
default
:
return
1
;
}
};
MathNode
.
prototype
.
getInputType
=
function
(
builder
)
{
var
a
=
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
);
var
b
=
this
.
b
?
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
)
:
0
;
var
c
=
this
.
c
?
builder
.
getTypeLength
(
this
.
c
.
getType
(
builder
)
)
:
0
;
if
(
a
>
b
&&
a
>
c
)
{
return
this
.
a
.
getType
(
builder
);
}
else
if
(
b
>
c
)
{
return
this
.
b
.
getType
(
builder
);
}
return
this
.
c
.
getType
(
builder
);
};
MathNode
.
prototype
.
getType
=
function
(
builder
)
{
switch
(
this
.
method
)
{
case
MathNode
.
LENGTH
:
case
MathNode
.
DISTANCE
:
case
MathNode
.
DOT
:
return
'
f
'
;
case
MathNode
.
CROSS
:
return
'
v3
'
;
}
return
this
.
getInputType
(
builder
);
};
MathNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
a
,
b
,
c
,
al
=
this
.
a
?
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
)
:
0
,
bl
=
this
.
b
?
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
)
:
0
,
cl
=
this
.
c
?
builder
.
getTypeLength
(
this
.
c
.
getType
(
builder
)
)
:
0
,
inputType
=
this
.
getInputType
(
builder
),
nodeType
=
this
.
getType
(
builder
);
switch
(
this
.
method
)
{
// 1 input
case
MathNode
.
NEGATE
:
return
builder
.
format
(
'
( -
'
+
this
.
a
.
build
(
builder
,
inputType
)
+
'
)
'
,
inputType
,
output
);
case
MathNode
.
INVERT
:
return
builder
.
format
(
'
( 1.0 -
'
+
this
.
a
.
build
(
builder
,
inputType
)
+
'
)
'
,
inputType
,
output
);
// 2 inputs
case
MathNode
.
CROSS
:
a
=
this
.
a
.
build
(
builder
,
'
v3
'
);
b
=
this
.
b
.
build
(
builder
,
'
v3
'
);
break
;
case
MathNode
.
STEP
:
a
=
this
.
a
.
build
(
builder
,
al
===
1
?
'
f
'
:
inputType
);
b
=
this
.
b
.
build
(
builder
,
inputType
);
break
;
case
MathNode
.
MIN
:
case
MathNode
.
MAX
:
case
MathNode
.
MOD
:
a
=
this
.
a
.
build
(
builder
,
inputType
);
b
=
this
.
b
.
build
(
builder
,
bl
===
1
?
'
f
'
:
inputType
);
break
;
// 3 inputs
case
MathNode
.
REFRACT
:
a
=
this
.
a
.
build
(
builder
,
inputType
);
b
=
this
.
b
.
build
(
builder
,
inputType
);
c
=
this
.
c
.
build
(
builder
,
'
f
'
);
break
;
case
MathNode
.
MIX
:
a
=
this
.
a
.
build
(
builder
,
inputType
);
b
=
this
.
b
.
build
(
builder
,
inputType
);
c
=
this
.
c
.
build
(
builder
,
cl
===
1
?
'
f
'
:
inputType
);
break
;
// default
default
:
a
=
this
.
a
.
build
(
builder
,
inputType
);
if
(
this
.
b
)
b
=
this
.
b
.
build
(
builder
,
inputType
);
if
(
this
.
c
)
c
=
this
.
c
.
build
(
builder
,
inputType
);
break
;
}
// build function call
var
params
=
[];
params
.
push
(
a
);
if
(
b
)
params
.
push
(
b
);
if
(
c
)
params
.
push
(
c
);
var
numInputs
=
this
.
getNumInputs
(
builder
);
if
(
params
.
length
!==
numInputs
)
{
throw
Error
(
`Arguments not match used in "
${
this
.
method
}
". Require
${
numInputs
}
, currently
${
params
.
length
}
.`
);
}
return
builder
.
format
(
this
.
method
+
'
(
'
+
params
.
join
(
'
,
'
)
+
'
)
'
,
nodeType
,
output
);
};
MathNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
c
=
source
.
c
;
this
.
method
=
source
.
method
;
};
MathNode
.
prototype
.
toJSON
=
function
(
meta
)
{
var
data
=
this
.
getJSONNode
(
meta
);
if
(
!
data
)
{
data
=
this
.
createJSONNode
(
meta
);
data
.
a
=
this
.
a
.
toJSON
(
meta
).
uuid
;
if
(
this
.
b
)
data
.
b
=
this
.
b
.
toJSON
(
meta
).
uuid
;
if
(
this
.
c
)
data
.
c
=
this
.
c
.
toJSON
(
meta
).
uuid
;
data
.
method
=
this
.
method
;
}
return
data
;
};
export
{
MathNode
};
examples/js/nodes/misc/TextureCubeNode.js
浏览文件 @
95c6dcc9
...
...
@@ -3,14 +3,32 @@
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
import
{
TextureCubeUVNode
}
from
'
./TextureCubeUVNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
NormalNode
}
from
'
../accessors/NormalNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
import
{
BlinnExponentToRoughnessNode
}
from
'
../bsdfs/BlinnExponentToRoughnessNode.js
'
;
function
TextureCubeNode
(
value
,
uv
)
{
function
TextureCubeNode
(
value
,
textureSize
)
{
TempNode
.
call
(
this
,
'
v4
'
);
this
.
value
=
value
;
this
.
uv
=
uv
||
new
TextureCubeUVNode
();
this
.
textureSize
=
textureSize
||
new
FloatNode
(
1024
);
this
.
radianceCache
=
{
uv
:
new
TextureCubeUVNode
(
new
ReflectNode
(
ReflectNode
.
VECTOR
),
this
.
textureSize
,
new
BlinnExponentToRoughnessNode
()
)
};
this
.
irradianceCache
=
{
uv
:
new
TextureCubeUVNode
(
new
NormalNode
(
NormalNode
.
WORLD
),
this
.
textureSize
,
new
FloatNode
(
1
).
setReadonly
(
true
)
)
};
}
...
...
@@ -18,18 +36,55 @@ TextureCubeNode.prototype = Object.create( TempNode.prototype );
TextureCubeNode
.
prototype
.
constructor
=
TextureCubeNode
;
TextureCubeNode
.
prototype
.
nodeType
=
"
TextureCube
"
;
TextureCubeNode
.
prototype
.
generateTextureCubeUV
=
function
(
builder
,
cache
)
{
var
uv_10
=
cache
.
uv
.
build
(
builder
)
+
'
.uv_10
'
,
uv_20
=
cache
.
uv
.
build
(
builder
)
+
'
.uv_20
'
,
t
=
cache
.
uv
.
build
(
builder
)
+
'
.t
'
;
var
color10
=
'
texture2D(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
uv_10
+
'
)
'
,
color20
=
'
texture2D(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
uv_20
+
'
)
'
;
// add a custom context for fix incompatibility with the core
// include ColorSpace function only for vertex shader (in fragment shader color space functions is added automatically by core)
// this should be removed in the future
// context.include =: is used to include or not functions if used FunctionNode
// context.ignoreCache =: not create temp variables nodeT0..9 to optimize the code
var
context
=
{
include
:
builder
.
isShader
(
'
vertex
'
),
ignoreCache
:
true
};
var
outputType
=
this
.
getType
(
builder
);
builder
.
addContext
(
context
);
cache
.
colorSpace10
=
cache
.
colorSpace10
||
new
ColorSpaceNode
(
new
ExpressionNode
(
''
,
outputType
)
);
cache
.
colorSpace10
.
fromDecoding
(
builder
.
getTextureEncodingFromMap
(
this
.
value
.
value
)
);
cache
.
colorSpace10
.
input
.
parse
(
color10
);
color10
=
cache
.
colorSpace10
.
build
(
builder
,
outputType
);
cache
.
colorSpace20
=
cache
.
colorSpace20
||
new
ColorSpaceNode
(
new
ExpressionNode
(
''
,
outputType
)
);
cache
.
colorSpace20
.
fromDecoding
(
builder
.
getTextureEncodingFromMap
(
this
.
value
.
value
)
);
cache
.
colorSpace20
.
input
.
parse
(
color20
);
color20
=
cache
.
colorSpace20
.
build
(
builder
,
outputType
);
// end custom context
builder
.
removeContext
();
return
'
mix(
'
+
color10
+
'
,
'
+
color20
+
'
,
'
+
t
+
'
).rgb
'
;
};
TextureCubeNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
var
uv_10
=
this
.
uv
.
build
(
builder
)
+
'
.uv_10
'
,
uv_20
=
this
.
uv
.
build
(
builder
)
+
'
.uv_20
'
,
t
=
this
.
uv
.
build
(
builder
)
+
'
.t
'
;
var
radiance
=
this
.
generateTextureCubeUV
(
builder
,
this
.
radianceCache
);
var
irradiance
=
this
.
generateTextureCubeUV
(
builder
,
this
.
irradianceCache
);
var
color10
=
builder
.
getTexelDecodingFunctionFromTexture
(
'
texture2D(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
uv_10
+
'
)
'
,
this
.
value
.
value
),
color20
=
builder
.
getTexelDecodingFunctionFromTexture
(
'
texture2D(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
uv_20
+
'
)
'
,
this
.
value
.
value
);
builder
.
context
.
extra
.
irradiance
=
irradiance
;
return
builder
.
format
(
'
vec4(
mix(
'
+
color10
+
'
,
'
+
color20
+
'
,
'
+
t
+
'
).rgb
, 1.0 )
'
,
this
.
getType
(
builder
),
output
);
return
builder
.
format
(
'
vec4(
'
+
radiance
+
'
, 1.0 )
'
,
this
.
getType
(
builder
),
output
);
}
else
{
...
...
@@ -49,11 +104,7 @@ TextureCubeNode.prototype.toJSON = function ( meta ) {
data
=
this
.
createJSONNode
(
meta
);
data
.
uv
=
this
.
uv
.
toJSON
(
meta
).
uuid
;
data
.
textureSize
=
this
.
textureSize
.
toJSON
(
meta
).
uuid
;
data
.
blinnExponentToRoughness
=
this
.
blinnExponentToRoughness
.
toJSON
(
meta
).
uuid
;
if
(
this
.
roughness
)
data
.
roughness
=
this
.
roughness
.
toJSON
(
meta
).
uuid
;
data
.
value
=
this
.
value
.
toJSON
(
meta
).
uuid
;
}
...
...
examples/js/nodes/misc/TextureCubeUVNode.js
浏览文件 @
95c6dcc9
...
...
@@ -8,15 +8,14 @@ import { StructNode } from '../core/StructNode.js';
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
BlinnExponentToRoughnessNode
}
from
'
../bsdfs/BlinnExponentToRoughnessNode.js
'
;
function
TextureCubeUVNode
(
uv
,
textureSize
,
blinnExponentToRoughness
)
{
TempNode
.
call
(
this
,
'
TextureCubeUVData
'
);
// TextureCubeUVData is type as StructNode
this
.
uv
=
uv
||
new
ReflectNode
(
ReflectNode
.
VECTOR
)
;
this
.
textureSize
=
textureSize
||
new
FloatNode
(
1024
)
;
this
.
blinnExponentToRoughness
=
blinnExponentToRoughness
||
new
BlinnExponentToRoughnessNode
()
;
this
.
uv
=
uv
;
this
.
textureSize
=
textureSize
;
this
.
blinnExponentToRoughness
=
blinnExponentToRoughness
;
}
...
...
examples/js/nodes/utils/ColorSpaceNode.js
浏览文件 @
95c6dcc9
...
...
@@ -4,7 +4,9 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
ConstNode
}
from
'
../core/ConstNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
ExpressionNode
}
from
'
../core/ExpressionNode.js
'
;
function
ColorSpaceNode
(
input
,
method
)
{
...
...
@@ -12,7 +14,7 @@ function ColorSpaceNode( input, method ) {
this
.
input
=
input
;
this
.
method
=
method
||
ColorSpaceNode
.
LINEAR
;
this
.
method
=
method
||
ColorSpaceNode
.
LINEAR
_TO_LINEAR
;
}
...
...
@@ -201,70 +203,78 @@ ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD';
ColorSpaceNode
.
LINEAR_TO_LOG_LUV
=
'
LinearToLogLuv
'
;
ColorSpaceNode
.
LOG_LUV_TO_LINEAR
=
'
LogLuvToLinear
'
;
ColorSpaceNode
.
getEncodingComponents
=
function
(
encoding
)
{
switch
(
encoding
)
{
case
THREE
.
LinearEncoding
:
return
[
'
Linear
'
];
case
THREE
.
sRGBEncoding
:
return
[
'
sRGB
'
];
case
THREE
.
RGBEEncoding
:
return
[
'
RGBE
'
];
case
THREE
.
RGBM7Encoding
:
return
[
'
RGBM
'
,
new
FloatNode
(
7.0
).
setReadonly
(
true
)
];
case
THREE
.
RGBM16Encoding
:
return
[
'
RGBM
'
,
new
FloatNode
(
16.0
).
setReadonly
(
true
)
];
case
THREE
.
RGBDEncoding
:
return
[
'
RGBD
'
,
new
FloatNode
(
256.0
).
setReadonly
(
true
)
];
case
THREE
.
GammaEncoding
:
return
[
'
Gamma
'
,
new
ExpressionNode
(
'
float( GAMMA_FACTOR )
'
,
'
f
'
)
];
}
};
ColorSpaceNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ColorSpaceNode
.
prototype
.
constructor
=
ColorSpaceNode
;
ColorSpaceNode
.
prototype
.
nodeType
=
"
Color
Adjustment
"
;
ColorSpaceNode
.
prototype
.
nodeType
=
"
Color
Space
"
;
ColorSpaceNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
input
=
builder
.
context
.
input
||
this
.
input
.
build
(
builder
,
'
v4
'
),
encodingMethod
=
builder
.
context
.
encoding
!==
undefined
?
this
.
getEncodingMethod
(
builder
.
context
.
encoding
)
:
[
this
.
method
],
factor
=
this
.
factor
?
this
.
factor
.
build
(
builder
,
'
f
'
)
:
encodingMethod
[
1
];
var
input
=
this
.
input
.
build
(
builder
,
'
v4
'
);
var
outputType
=
this
.
getType
(
builder
);
var
method
=
builder
.
include
(
ColorSpaceNode
.
Nodes
[
encodingMethod
[
0
]
]
);
var
methodNode
=
ColorSpaceNode
.
Nodes
[
this
.
method
];
var
method
=
builder
.
include
(
methodNode
);
if
(
factor
)
{
if
(
method
===
ColorSpaceNode
.
LINEAR_TO_LINEAR
)
{
return
builder
.
format
(
method
+
'
(
'
+
input
+
'
,
'
+
factor
+
'
)
'
,
this
.
getType
(
builder
)
,
output
);
return
builder
.
format
(
input
,
outputType
,
output
);
}
else
{
return
builder
.
format
(
method
+
'
(
'
+
input
+
'
)
'
,
this
.
getType
(
builder
),
output
);
if
(
methodNode
.
inputs
.
length
===
2
)
{
}
var
factor
=
this
.
factor
.
build
(
builder
,
'
f
'
);
}
;
return
builder
.
format
(
method
+
'
(
'
+
input
+
'
,
'
+
factor
+
'
)
'
,
outputType
,
output
)
;
ColorSpaceNode
.
prototype
.
getDecodingMethod
=
function
(
encoding
)
{
}
else
{
var
components
=
this
.
getEncodingComponents
(
encoding
);
return
builder
.
format
(
method
+
'
(
'
+
input
+
'
)
'
,
outputType
,
output
);
components
[
0
]
+=
'
ToLinear
'
;
}
return
components
;
}
};
ColorSpaceNode
.
prototype
.
getEncodingMethod
=
function
(
encoding
)
{
ColorSpaceNode
.
prototype
.
fromEncoding
=
function
(
encoding
)
{
var
components
=
this
.
getEncodingComponents
(
encoding
);
var
components
=
ColorSpaceNode
.
getEncodingComponents
(
encoding
);
components
[
0
]
=
'
LinearTo
'
+
components
[
0
];
return
components
;
this
.
method
=
'
LinearTo
'
+
components
[
0
];
this
.
factor
=
components
[
1
];
};
ColorSpaceNode
.
prototype
.
getEncodingComponents
=
function
(
encoding
)
{
ColorSpaceNode
.
prototype
.
fromDecoding
=
function
(
encoding
)
{
switch
(
encoding
)
{
var
components
=
ColorSpaceNode
.
getEncodingComponents
(
encoding
);
case
THREE
.
LinearEncoding
:
return
[
'
Linear
'
];
case
THREE
.
sRGBEncoding
:
return
[
'
sRGB
'
];
case
THREE
.
RGBEEncoding
:
return
[
'
RGBE
'
];
case
THREE
.
RGBM7Encoding
:
return
[
'
RGBM
'
,
'
7.0
'
];
case
THREE
.
RGBM16Encoding
:
return
[
'
RGBM
'
,
'
16.0
'
];
case
THREE
.
RGBDEncoding
:
return
[
'
RGBD
'
,
'
256.0
'
];
case
THREE
.
GammaEncoding
:
return
[
'
Gamma
'
,
'
float( GAMMA_FACTOR )
'
];
}
this
.
method
=
components
[
0
]
+
'
ToLinear
'
;
this
.
factor
=
components
[
1
];
};
...
...
examples/nodes/caustic.json
浏览文件 @
95c6dcc9
{
"nodes"
:{
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
:{
"uuid"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
,
"nodeType"
:
"Standard"
,
"color"
:
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
,
"roughness"
:
"B75EB152-60CF-4274-8674-C4220C3E34A9"
,
"metalness"
:
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
,
"ambient"
:
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
},
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
:{
"uuid"
:
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
,
"nodeType"
:
"Math3"
,
"a"
:
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
,
"b"
:
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
,
"c"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"method"
:
"mix"
},
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
:{
"uuid"
:
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
:{
"uuid"
:
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
,
"nodeType"
:
"Math3"
,
"a"
:
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
,
"b"
:
"B45D1B51-7344-4713-BC65-B048397A0194"
,
"c"
:
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
,
"method"
:
"mix"
},
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
:{
"uuid"
:
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"B45D1B51-7344-4713-BC65-B048397A0194"
:{
"uuid"
:
"B45D1B51-7344-4713-BC65-B048397A0194"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
:{
"uuid"
:
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
,
"nodeType"
:
"Math1"
,
"a"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"method"
:
"saturate"
},
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
:{
"uuid"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"nodeType"
:
"Operator"
,
"a"
:
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
,
"b"
:
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
,
"op"
:
"*"
},
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
:{
"uuid"
:
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
,
"nodeType"
:
"FunctionCall"
,
"value"
:
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
,
"inputs"
:{
"p"
:
"9A81F84F-DE02-473E-B5F6-8212D072753F"
,
"time"
:
"BE94EED7-4A76-4350-B23E-25E52241C901"
}},
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
:{
"uuid"
:
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
,
"nodeType"
:
"Function"
,
"name"
:
"voronoiLayers"
,
"src"
:
"float voronoiLayers(vec2 p, in float time) {
\n\t
float v = 0.0;
\n\t
float a = 0.4;
\n\t
for (int i = 0; i < 3; i++) {
\n\t\t
v += voronoi(p, time) * a;
\n\t\t
p *= 2.0;
\n\t\t
a *= 0.5;
\n\t
}
\n\t
return v;
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{},
"includes"
:[
"36912270-771A-4D33-BB5E-373EC2E4B72E"
]},
"36912270-771A-4D33-BB5E-373EC2E4B72E"
:{
"uuid"
:
"36912270-771A-4D33-BB5E-373EC2E4B72E"
,
"nodeType"
:
"Function"
,
"name"
:
"voronoi"
,
"src"
:
"float voronoi(vec2 p, in float time) {
\n\t
vec2 n = floor(p);
\n\t
vec2 f = fract(p);
\n\t
float md = 5.0;
\n\t
vec2 m = vec2(0.0);
\n\t
for (int i = -1; i <= 1; i++) {
\n\t\t
for (int j = -1; j <= 1; j++) {
\n\t\t\t
vec2 g = vec2(i, j);
\n\t\t\t
vec2 o = hash2(n + g);
\n\t\t\t
o = 0.5 + 0.5 * sin(time + 5.038 * o);
\n\t\t\t
vec2 r = g + o - f;
\n\t\t\t
float d = dot(r, r);
\n\t\t\t
if (d < md) {
\n\t\t\t\t
md = d;
\n\t\t\t\t
m = n+g+o;
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\t
return md;
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{},
"includes"
:[
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
]},
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
:{
"uuid"
:
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
,
"nodeType"
:
"Function"
,
"name"
:
"hash2"
,
"src"
:
"vec2 hash2(vec2 p) {
\n\t
return fract(sin(vec2(dot(p, vec2(123.4, 748.6)), dot(p, vec2(547.3, 659.3))))*5232.85324);
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{}},
"9A81F84F-DE02-473E-B5F6-8212D072753F"
:{
"uuid"
:
"9A81F84F-DE02-473E-B5F6-8212D072753F"
,
"nodeType"
:
"Operator"
,
"a"
:
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
,
"b"
:
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
,
"op"
:
"*"
},
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
:{
"uuid"
:
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
,
"nodeType"
:
"Switch"
,
"node"
:
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
,
"components"
:
"xz"
},
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
:{
"uuid"
:
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
,
"nodeType"
:
"Position"
,
"scope"
:
"world"
},
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
:{
"uuid"
:
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
,
"nodeType"
:
"Float"
,
"value"
:
0.1
},
"BE94EED7-4A76-4350-B23E-25E52241C901"
:{
"uuid"
:
"BE94EED7-4A76-4350-B23E-25E52241C901"
,
"nodeType"
:
"Operator"
,
"a"
:
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
,
"b"
:
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
,
"op"
:
"*"
},
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
:{
"uuid"
:
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
:{
"uuid"
:
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
2
},
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
:{
"uuid"
:
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
,
"nodeType"
:
"Float"
,
"value"
:
1.5
},
"347D0A31-9222-4D15-8B36-1485AD47289E"
:{
"uuid"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"nodeType"
:
"Operator"
,
"a"
:
"14A35D0F-7E5A-4415-9C8A-73111B070390"
,
"b"
:
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
,
"op"
:
"*"
},
"14A35D0F-7E5A-4415-9C8A-73111B070390"
:{
"uuid"
:
"14A35D0F-7E5A-4415-9C8A-73111B070390"
,
"nodeType"
:
"Float"
,
"value"
:
1
},
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
:{
"uuid"
:
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
,
"nodeType"
:
"Math1"
,
"a"
:
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
,
"method"
:
"saturate"
},
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
:{
"uuid"
:
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
,
"nodeType"
:
"Switch"
,
"node"
:
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
,
"components"
:
"y"
},
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
:{
"uuid"
:
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
,
"nodeType"
:
"Normal"
,
"scope"
:
"world"
},
"B75EB152-60CF-4274-8674-C4220C3E34A9"
:{
"uuid"
:
"B75EB152-60CF-4274-8674-C4220C3E34A9"
,
"nodeType"
:
"Float"
,
"value"
:
0.5
},
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
:{
"uuid"
:
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
,
"nodeType"
:
"Float"
,
"value"
:
0.5
},
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
:{
"uuid"
:
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
,
"nodeType"
:
"Operator"
,
"a"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"b"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"op"
:
"*"
}},
"materials"
:{
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
:{
"uuid"
:
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
,
"type"
:
"StandardNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
,
"fragment"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
}},
"material"
:
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
}
\ No newline at end of file
{
"nodes"
:{
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
:{
"uuid"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
,
"nodeType"
:
"Standard"
,
"color"
:
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
,
"roughness"
:
"B75EB152-60CF-4274-8674-C4220C3E34A9"
,
"metalness"
:
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
,
"ambient"
:
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
},
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
:{
"uuid"
:
"870FC985-0C7C-4EB1-87F7-C10027A8983C"
,
"nodeType"
:
"Math"
,
"a"
:
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
,
"b"
:
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
,
"c"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"method"
:
"mix"
},
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
:{
"uuid"
:
"085DEB3A-FD4B-48A4-BA95-7762AA286854"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
:{
"uuid"
:
"70B5B1FE-9D8D-4E5C-89A1-7F164F2E6DDD"
,
"nodeType"
:
"Math"
,
"a"
:
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
,
"b"
:
"B45D1B51-7344-4713-BC65-B048397A0194"
,
"c"
:
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
,
"method"
:
"mix"
},
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
:{
"uuid"
:
"6F0CE905-5A0B-4CBD-AC6B-519C392B45FC"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"B45D1B51-7344-4713-BC65-B048397A0194"
:{
"uuid"
:
"B45D1B51-7344-4713-BC65-B048397A0194"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
:{
"uuid"
:
"FADA01E1-DBD7-4DC2-9BA1-8276F4DF1ACD"
,
"nodeType"
:
"Math"
,
"a"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"method"
:
"saturate"
},
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
:{
"uuid"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"nodeType"
:
"Operator"
,
"a"
:
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
,
"b"
:
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
,
"op"
:
"*"
},
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
:{
"uuid"
:
"C5F7404C-B0FD-46DE-95F1-8361904A10B1"
,
"nodeType"
:
"FunctionCall"
,
"value"
:
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
,
"inputs"
:{
"p"
:
"9A81F84F-DE02-473E-B5F6-8212D072753F"
,
"time"
:
"BE94EED7-4A76-4350-B23E-25E52241C901"
}},
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
:{
"uuid"
:
"189E9DE8-6D4A-4763-AC9A-EA4A2608DCF3"
,
"nodeType"
:
"Function"
,
"name"
:
"voronoiLayers"
,
"src"
:
"float voronoiLayers(vec2 p, in float time) {
\n\t
float v = 0.0;
\n\t
float a = 0.4;
\n\t
for (int i = 0; i < 3; i++) {
\n\t\t
v += voronoi(p, time) * a;
\n\t\t
p *= 2.0;
\n\t\t
a *= 0.5;
\n\t
}
\n\t
return v;
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{},
"includes"
:[
"36912270-771A-4D33-BB5E-373EC2E4B72E"
]},
"36912270-771A-4D33-BB5E-373EC2E4B72E"
:{
"uuid"
:
"36912270-771A-4D33-BB5E-373EC2E4B72E"
,
"nodeType"
:
"Function"
,
"name"
:
"voronoi"
,
"src"
:
"float voronoi(vec2 p, in float time) {
\n\t
vec2 n = floor(p);
\n\t
vec2 f = fract(p);
\n\t
float md = 5.0;
\n\t
vec2 m = vec2(0.0);
\n\t
for (int i = -1; i <= 1; i++) {
\n\t\t
for (int j = -1; j <= 1; j++) {
\n\t\t\t
vec2 g = vec2(i, j);
\n\t\t\t
vec2 o = hash2(n + g);
\n\t\t\t
o = 0.5 + 0.5 * sin(time + 5.038 * o);
\n\t\t\t
vec2 r = g + o - f;
\n\t\t\t
float d = dot(r, r);
\n\t\t\t
if (d < md) {
\n\t\t\t\t
md = d;
\n\t\t\t\t
m = n+g+o;
\n\t\t\t
}
\n\t\t
}
\n\t
}
\n\t
return md;
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{},
"includes"
:[
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
]},
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
:{
"uuid"
:
"DEEA59B5-DB78-4936-92C2-0EEBA9E335FD"
,
"nodeType"
:
"Function"
,
"name"
:
"hash2"
,
"src"
:
"vec2 hash2(vec2 p) {
\n\t
return fract(sin(vec2(dot(p, vec2(123.4, 748.6)), dot(p, vec2(547.3, 659.3))))*5232.85324);
\n
}"
,
"isMethod"
:
true
,
"useKeywords"
:
true
,
"extensions"
:{},
"keywords"
:{}},
"9A81F84F-DE02-473E-B5F6-8212D072753F"
:{
"uuid"
:
"9A81F84F-DE02-473E-B5F6-8212D072753F"
,
"nodeType"
:
"Operator"
,
"a"
:
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
,
"b"
:
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
,
"op"
:
"*"
},
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
:{
"uuid"
:
"EAEC9892-ABE1-456C-BD3C-9AB888B3ED0B"
,
"nodeType"
:
"Switch"
,
"node"
:
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
,
"components"
:
"xz"
},
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
:{
"uuid"
:
"DDBEB2EC-65A8-40DF-BB1F-F6EBC4E73107"
,
"nodeType"
:
"Position"
,
"scope"
:
"world"
},
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
:{
"uuid"
:
"1FCD9B13-EABD-47A7-8082-E6F6AA15EC7E"
,
"nodeType"
:
"Float"
,
"value"
:
0.1
},
"BE94EED7-4A76-4350-B23E-25E52241C901"
:{
"uuid"
:
"BE94EED7-4A76-4350-B23E-25E52241C901"
,
"nodeType"
:
"Operator"
,
"a"
:
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
,
"b"
:
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
,
"op"
:
"*"
},
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
:{
"uuid"
:
"0F6183F0-9601-4208-BFC1-C4D39A524F74"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
:{
"uuid"
:
"3A74C273-243B-4C6F-AC6F-FD20D6D5DABB"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
2
},
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
:{
"uuid"
:
"72654FD1-36AD-4337-8BA0-B3D867EFB091"
,
"nodeType"
:
"Float"
,
"value"
:
1.5
},
"347D0A31-9222-4D15-8B36-1485AD47289E"
:{
"uuid"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"nodeType"
:
"Operator"
,
"a"
:
"14A35D0F-7E5A-4415-9C8A-73111B070390"
,
"b"
:
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
,
"op"
:
"*"
},
"14A35D0F-7E5A-4415-9C8A-73111B070390"
:{
"uuid"
:
"14A35D0F-7E5A-4415-9C8A-73111B070390"
,
"nodeType"
:
"Float"
,
"value"
:
1
},
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
:{
"uuid"
:
"13325E4A-A4EE-4D3F-86DF-0EB77BB56DB3"
,
"nodeType"
:
"Math"
,
"a"
:
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
,
"method"
:
"saturate"
},
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
:{
"uuid"
:
"9B0DF80C-F8CE-4122-B63F-E370CFDA47D4"
,
"nodeType"
:
"Switch"
,
"node"
:
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
,
"components"
:
"y"
},
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
:{
"uuid"
:
"481D32AF-83D9-4AE2-954C-6C887FD4B964"
,
"nodeType"
:
"Normal"
,
"scope"
:
"world"
},
"B75EB152-60CF-4274-8674-C4220C3E34A9"
:{
"uuid"
:
"B75EB152-60CF-4274-8674-C4220C3E34A9"
,
"nodeType"
:
"Float"
,
"value"
:
0.5
},
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
:{
"uuid"
:
"8C8293C6-9DA8-456B-89AB-803E3479DFBF"
,
"nodeType"
:
"Float"
,
"value"
:
0.5
},
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
:{
"uuid"
:
"BF3FBBDC-F57A-4116-B8DC-625F8821C075"
,
"nodeType"
:
"Operator"
,
"a"
:
"13EA9413-2C8B-4B1C-92EE-0A334971AB77"
,
"b"
:
"347D0A31-9222-4D15-8B36-1485AD47289E"
,
"op"
:
"*"
}},
"materials"
:{
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
:{
"uuid"
:
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
,
"type"
:
"StandardNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
,
"fragment"
:
"2E025DBF-0C15-444E-B7B8-A6F265A303F7"
}},
"material"
:
"03756E07-B6B1-436D-A28B-1EB9043B2CD2"
}
\ No newline at end of file
examples/nodes/displace.json
浏览文件 @
95c6dcc9
{
"nodes"
:{
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
:{
"uuid"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
,
"nodeType"
:
"Phong"
,
"position"
:
"A298C150-1E98-425D-8552-CF4690C3238E"
,
"color"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"specular"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"shininess"
:
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
,
"emissive"
:
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
},
"A298C150-1E98-425D-8552-CF4690C3238E"
:{
"uuid"
:
"A298C150-1E98-425D-8552-CF4690C3238E"
,
"nodeType"
:
"Operator"
,
"a"
:
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
,
"b"
:
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
,
"op"
:
"+"
},
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
:{
"uuid"
:
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
:{
"uuid"
:
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
,
"nodeType"
:
"Operator"
,
"a"
:
"C4573235-0C78-460A-BB35-E41470304BD5"
,
"b"
:
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
,
"op"
:
"*"
},
"C4573235-0C78-460A-BB35-E41470304BD5"
:{
"uuid"
:
"C4573235-0C78-460A-BB35-E41470304BD5"
,
"nodeType"
:
"Operator"
,
"a"
:
"0E355E3B-23AB-4225-9477-312295B18436"
,
"b"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"op"
:
"*"
},
"0E355E3B-23AB-4225-9477-312295B18436"
:{
"uuid"
:
"0E355E3B-23AB-4225-9477-312295B18436"
,
"nodeType"
:
"Normal"
,
"scope"
:
"local"
},
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
:{
"uuid"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"nodeType"
:
"Switch"
,
"node"
:
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
,
"components"
:
"w"
},
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
:{
"uuid"
:
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
,
"nodeType"
:
"Texture"
,
"value"
:
"cloud"
,
"uv"
:
"273D729E-E18D-47AE-8299-F069FDB6C43A"
,
"project"
:
false
},
"273D729E-E18D-47AE-8299-F069FDB6C43A"
:{
"uuid"
:
"273D729E-E18D-47AE-8299-F069FDB6C43A"
,
"nodeType"
:
"Operator"
,
"a"
:
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
,
"b"
:
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
,
"op"
:
"+"
},
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
:{
"uuid"
:
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
,
"nodeType"
:
"Operator"
,
"a"
:
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
,
"b"
:
"801913CD-EC7A-47BE-A54C-3D86020B0847"
,
"op"
:
"*"
},
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
:{
"uuid"
:
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"801913CD-EC7A-47BE-A54C-3D86020B0847"
:{
"uuid"
:
"801913CD-EC7A-47BE-A54C-3D86020B0847"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
0.2
},
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
:{
"uuid"
:
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
,
"nodeType"
:
"UV"
,
"index"
:
0
},
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
:{
"uuid"
:
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
,
"nodeType"
:
"Float"
,
"value"
:
2
},
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
:{
"uuid"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0
,
"b"
:
0
},
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
:{
"uuid"
:
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
,
"nodeType"
:
"Float"
,
"value"
:
30
},
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
:{
"uuid"
:
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
,
"nodeType"
:
"Math3"
,
"a"
:
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
,
"b"
:
"65010573-EE24-42A3-B32C-3945F3CF2E93"
,
"c"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"method"
:
"mix"
},
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
:{
"uuid"
:
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"65010573-EE24-42A3-B32C-3945F3CF2E93"
:{
"uuid"
:
"65010573-EE24-42A3-B32C-3945F3CF2E93"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
}},
"materials"
:{
"BCB86F69-822F-4F9C-838B-70F657904D05"
:{
"uuid"
:
"BCB86F69-822F-4F9C-838B-70F657904D05"
,
"type"
:
"PhongNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
,
"fragment"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
}},
"material"
:
"BCB86F69-822F-4F9C-838B-70F657904D05"
}
\ No newline at end of file
{
"nodes"
:{
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
:{
"uuid"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
,
"nodeType"
:
"Phong"
,
"position"
:
"A298C150-1E98-425D-8552-CF4690C3238E"
,
"color"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"specular"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"shininess"
:
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
,
"emissive"
:
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
},
"A298C150-1E98-425D-8552-CF4690C3238E"
:{
"uuid"
:
"A298C150-1E98-425D-8552-CF4690C3238E"
,
"nodeType"
:
"Operator"
,
"a"
:
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
,
"b"
:
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
,
"op"
:
"+"
},
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
:{
"uuid"
:
"6449FE7E-56E7-490E-9CA9-9F5E9A540AFD"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
:{
"uuid"
:
"09ECA9C2-8B78-422B-B3DA-2194BCBC5FCA"
,
"nodeType"
:
"Operator"
,
"a"
:
"C4573235-0C78-460A-BB35-E41470304BD5"
,
"b"
:
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
,
"op"
:
"*"
},
"C4573235-0C78-460A-BB35-E41470304BD5"
:{
"uuid"
:
"C4573235-0C78-460A-BB35-E41470304BD5"
,
"nodeType"
:
"Operator"
,
"a"
:
"0E355E3B-23AB-4225-9477-312295B18436"
,
"b"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"op"
:
"*"
},
"0E355E3B-23AB-4225-9477-312295B18436"
:{
"uuid"
:
"0E355E3B-23AB-4225-9477-312295B18436"
,
"nodeType"
:
"Normal"
,
"scope"
:
"local"
},
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
:{
"uuid"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"nodeType"
:
"Switch"
,
"node"
:
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
,
"components"
:
"w"
},
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
:{
"uuid"
:
"43D31AB8-1DD6-46BE-8969-0668FAB513E2"
,
"nodeType"
:
"Texture"
,
"value"
:
"cloud"
,
"uv"
:
"273D729E-E18D-47AE-8299-F069FDB6C43A"
,
"project"
:
false
},
"273D729E-E18D-47AE-8299-F069FDB6C43A"
:{
"uuid"
:
"273D729E-E18D-47AE-8299-F069FDB6C43A"
,
"nodeType"
:
"Operator"
,
"a"
:
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
,
"b"
:
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
,
"op"
:
"+"
},
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
:{
"uuid"
:
"C46D2A54-57A8-4649-AF9B-09D011AF3BFD"
,
"nodeType"
:
"Operator"
,
"a"
:
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
,
"b"
:
"801913CD-EC7A-47BE-A54C-3D86020B0847"
,
"op"
:
"*"
},
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
:{
"uuid"
:
"F81EC887-A160-455B-B1DE-A0FA2B7FAC36"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"801913CD-EC7A-47BE-A54C-3D86020B0847"
:{
"uuid"
:
"801913CD-EC7A-47BE-A54C-3D86020B0847"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
0.2
},
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
:{
"uuid"
:
"C43B8DA9-AFF5-4690-B2EA-3EED061C0662"
,
"nodeType"
:
"UV"
,
"index"
:
0
},
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
:{
"uuid"
:
"1FF6B149-BCA7-4F37-91E9-8AFA8770F084"
,
"nodeType"
:
"Float"
,
"value"
:
2
},
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
:{
"uuid"
:
"DCD2B815-345D-4600-BAFD-BE26925C60E6"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0
,
"b"
:
0
},
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
:{
"uuid"
:
"5E1EEAA6-F057-4D5F-8607-E9F8265D2B0A"
,
"nodeType"
:
"Float"
,
"value"
:
30
},
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
:{
"uuid"
:
"BF320EA1-F523-4314-9B87-07E33F39CC6C"
,
"nodeType"
:
"Math"
,
"a"
:
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
,
"b"
:
"65010573-EE24-42A3-B32C-3945F3CF2E93"
,
"c"
:
"ABD03824-B7F8-46A4-9006-03FBA06618A9"
,
"method"
:
"mix"
},
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
:{
"uuid"
:
"F9EA5DC0-2BC8-4C38-A480-1DA3D0680AAE"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"65010573-EE24-42A3-B32C-3945F3CF2E93"
:{
"uuid"
:
"65010573-EE24-42A3-B32C-3945F3CF2E93"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
}},
"materials"
:{
"BCB86F69-822F-4F9C-838B-70F657904D05"
:{
"uuid"
:
"BCB86F69-822F-4F9C-838B-70F657904D05"
,
"type"
:
"PhongNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
,
"fragment"
:
"A9543A4D-4036-4AB3-AEF1-0AE10CFDD4A6"
}},
"material"
:
"BCB86F69-822F-4F9C-838B-70F657904D05"
}
\ No newline at end of file
examples/nodes/wave.json
浏览文件 @
95c6dcc9
{
"nodes"
:{
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
:{
"uuid"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
,
"nodeType"
:
"Phong"
,
"position"
:
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
,
"color"
:
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
,
"specular"
:
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
,
"shininess"
:
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
},
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
:{
"uuid"
:
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
,
"nodeType"
:
"Operator"
,
"a"
:
"28F9F474-E77F-4373-BA46-D39F8588A56B"
,
"b"
:
"B792813E-FC18-4440-8256-E4030E9D7E3A"
,
"op"
:
"+"
},
"28F9F474-E77F-4373-BA46-D39F8588A56B"
:{
"uuid"
:
"28F9F474-E77F-4373-BA46-D39F8588A56B"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"B792813E-FC18-4440-8256-E4030E9D7E3A"
:{
"uuid"
:
"B792813E-FC18-4440-8256-E4030E9D7E3A"
,
"nodeType"
:
"Join"
,
"inputs"
:{
"x"
:
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
,
"y"
:
"B7A4178E-D407-4444-9633-741A8C2DAD09"
,
"z"
:
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
}},
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
:{
"uuid"
:
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
,
"nodeType"
:
"Float"
,
"value"
:
0
},
"B7A4178E-D407-4444-9633-741A8C2DAD09"
:{
"uuid"
:
"B7A4178E-D407-4444-9633-741A8C2DAD09"
,
"nodeType"
:
"Operator"
,
"a"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"b"
:
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
,
"op"
:
"*"
},
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
:{
"uuid"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"nodeType"
:
"Switch"
,
"node"
:
"575F9E64-5B6D-4A95-9522-3A27919165BF"
,
"components"
:
"x"
},
"575F9E64-5B6D-4A95-9522-3A27919165BF"
:{
"uuid"
:
"575F9E64-5B6D-4A95-9522-3A27919165BF"
,
"nodeType"
:
"Math1"
,
"a"
:
"4EF09677-828F-4164-BE18-2E8E87A3E969"
,
"method"
:
"sin"
},
"4EF09677-828F-4164-BE18-2E8E87A3E969"
:{
"uuid"
:
"4EF09677-828F-4164-BE18-2E8E87A3E969"
,
"nodeType"
:
"Operator"
,
"a"
:
"DA817C54-9793-4850-9B90-A087050C6335"
,
"b"
:
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
,
"op"
:
"+"
},
"DA817C54-9793-4850-9B90-A087050C6335"
:{
"uuid"
:
"DA817C54-9793-4850-9B90-A087050C6335"
,
"nodeType"
:
"Operator"
,
"a"
:
"87304A41-2F18-4A98-92F1-9869F01786D3"
,
"b"
:
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
,
"op"
:
"*"
},
"87304A41-2F18-4A98-92F1-9869F01786D3"
:{
"uuid"
:
"87304A41-2F18-4A98-92F1-9869F01786D3"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
:{
"uuid"
:
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
,
"nodeType"
:
"Float"
,
"value"
:
0.4
},
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
:{
"uuid"
:
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
,
"nodeType"
:
"Operator"
,
"a"
:
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
,
"b"
:
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
,
"op"
:
"*"
},
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
:{
"uuid"
:
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
:{
"uuid"
:
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
5
},
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
:{
"uuid"
:
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
,
"nodeType"
:
"Float"
,
"value"
:
1
},
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
:{
"uuid"
:
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
,
"nodeType"
:
"Float"
,
"value"
:
0
},
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
:{
"uuid"
:
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
,
"nodeType"
:
"Math3"
,
"a"
:
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
,
"b"
:
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
,
"c"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"method"
:
"mix"
},
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
:{
"uuid"
:
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
:{
"uuid"
:
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
:{
"uuid"
:
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
:{
"uuid"
:
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
,
"nodeType"
:
"Float"
,
"value"
:
30
}},
"materials"
:{
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
:{
"uuid"
:
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
,
"type"
:
"PhongNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
,
"fragment"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
}},
"material"
:
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
}
\ No newline at end of file
{
"nodes"
:{
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
:{
"uuid"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
,
"nodeType"
:
"Phong"
,
"position"
:
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
,
"color"
:
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
,
"specular"
:
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
,
"shininess"
:
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
},
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
:{
"uuid"
:
"39ED31F8-337B-49A4-9DBE-B43B1F5D180B"
,
"nodeType"
:
"Operator"
,
"a"
:
"28F9F474-E77F-4373-BA46-D39F8588A56B"
,
"b"
:
"B792813E-FC18-4440-8256-E4030E9D7E3A"
,
"op"
:
"+"
},
"28F9F474-E77F-4373-BA46-D39F8588A56B"
:{
"uuid"
:
"28F9F474-E77F-4373-BA46-D39F8588A56B"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"B792813E-FC18-4440-8256-E4030E9D7E3A"
:{
"uuid"
:
"B792813E-FC18-4440-8256-E4030E9D7E3A"
,
"nodeType"
:
"Join"
,
"inputs"
:{
"x"
:
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
,
"y"
:
"B7A4178E-D407-4444-9633-741A8C2DAD09"
,
"z"
:
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
}},
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
:{
"uuid"
:
"F84376EF-6595-4A0F-AE1C-C183AE4D6392"
,
"nodeType"
:
"Float"
,
"value"
:
0
},
"B7A4178E-D407-4444-9633-741A8C2DAD09"
:{
"uuid"
:
"B7A4178E-D407-4444-9633-741A8C2DAD09"
,
"nodeType"
:
"Operator"
,
"a"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"b"
:
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
,
"op"
:
"*"
},
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
:{
"uuid"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"nodeType"
:
"Switch"
,
"node"
:
"575F9E64-5B6D-4A95-9522-3A27919165BF"
,
"components"
:
"x"
},
"575F9E64-5B6D-4A95-9522-3A27919165BF"
:{
"uuid"
:
"575F9E64-5B6D-4A95-9522-3A27919165BF"
,
"nodeType"
:
"Math"
,
"a"
:
"4EF09677-828F-4164-BE18-2E8E87A3E969"
,
"method"
:
"sin"
},
"4EF09677-828F-4164-BE18-2E8E87A3E969"
:{
"uuid"
:
"4EF09677-828F-4164-BE18-2E8E87A3E969"
,
"nodeType"
:
"Operator"
,
"a"
:
"DA817C54-9793-4850-9B90-A087050C6335"
,
"b"
:
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
,
"op"
:
"+"
},
"DA817C54-9793-4850-9B90-A087050C6335"
:{
"uuid"
:
"DA817C54-9793-4850-9B90-A087050C6335"
,
"nodeType"
:
"Operator"
,
"a"
:
"87304A41-2F18-4A98-92F1-9869F01786D3"
,
"b"
:
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
,
"op"
:
"*"
},
"87304A41-2F18-4A98-92F1-9869F01786D3"
:{
"uuid"
:
"87304A41-2F18-4A98-92F1-9869F01786D3"
,
"nodeType"
:
"Position"
,
"scope"
:
"local"
},
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
:{
"uuid"
:
"ECE889D2-A244-49EF-9ECF-BB685CD84828"
,
"nodeType"
:
"Float"
,
"value"
:
0.4
},
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
:{
"uuid"
:
"CE06CC57-FAFF-4EF7-A0E3-1D71ED0A4EFD"
,
"nodeType"
:
"Operator"
,
"a"
:
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
,
"b"
:
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
,
"op"
:
"*"
},
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
:{
"uuid"
:
"D035D8DE-7C30-4372-A5E5-9A03169CFA96"
,
"nodeType"
:
"Timer"
,
"name"
:
"time"
,
"scope"
:
"global"
,
"scale"
:
1
,
"useTimeScale"
:
false
},
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
:{
"uuid"
:
"2090FF81-9723-4F1F-BF10-2F223F879DA5"
,
"nodeType"
:
"Float"
,
"name"
:
"speed"
,
"value"
:
5
},
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
:{
"uuid"
:
"0A80D285-164D-4857-B8B9-30CE5CEC6931"
,
"nodeType"
:
"Float"
,
"value"
:
1
},
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
:{
"uuid"
:
"F5785794-4DB6-47F6-AAB6-78DFC896B782"
,
"nodeType"
:
"Float"
,
"value"
:
0
},
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
:{
"uuid"
:
"1628C697-A4FC-4F02-9746-1CFAC6C6E85B"
,
"nodeType"
:
"Math"
,
"a"
:
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
,
"b"
:
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
,
"c"
:
"526B9B70-CBA1-47E4-9CEF-0CE5A9C4F041"
,
"method"
:
"mix"
},
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
:{
"uuid"
:
"48DEB7D7-83ED-4679-BB0B-45A11052AA5F"
,
"nodeType"
:
"Color"
,
"r"
:
0
,
"g"
:
0.32941176470588235
,
"b"
:
0.8745098039215686
},
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
:{
"uuid"
:
"8C0EACD5-DEA2-431B-B083-06FB93DB7D2A"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
},
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
:{
"uuid"
:
"D730CA9D-A641-4289-BEF8-348CDD7218B6"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
:{
"uuid"
:
"73E26FEC-C8C2-4E9E-8A4A-209A88156348"
,
"nodeType"
:
"Float"
,
"value"
:
30
}},
"materials"
:{
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
:{
"uuid"
:
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
,
"type"
:
"PhongNodeMaterial"
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
,
"fragment"
:
"6BB91CE5-93BA-41BF-88C6-8D03721D4790"
}},
"material"
:
"7DCC94F3-82FE-4A67-B5DB-8ACE85789BAA"
}
\ No newline at end of file
examples/nodes/xray.json
浏览文件 @
95c6dcc9
{
"nodes"
:{
"42ED4EED-5956-4583-91BB-04BF1D350635"
:{
"uuid"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
,
"nodeType"
:
"Phong"
,
"color"
:
"935DF79A-E12B-4692-9717-089EEC8EA392"
,
"specular"
:
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
,
"shininess"
:
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
,
"alpha"
:
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
,
"emissive"
:
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
},
"935DF79A-E12B-4692-9717-089EEC8EA392"
:{
"uuid"
:
"935DF79A-E12B-4692-9717-089EEC8EA392"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
:{
"uuid"
:
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
:{
"uuid"
:
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
,
"nodeType"
:
"Float"
,
"value"
:
30
},
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
:{
"uuid"
:
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
,
"nodeType"
:
"Math2"
,
"a"
:
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
,
"b"
:
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
,
"method"
:
"pow"
},
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
:{
"uuid"
:
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
,
"nodeType"
:
"Operator"
,
"a"
:
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
,
"b"
:
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
,
"op"
:
"+"
},
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
:{
"uuid"
:
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
,
"nodeType"
:
"Math2"
,
"a"
:
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
,
"b"
:
"70625377-B34E-4314-8782-360AEB31DAE8"
,
"method"
:
"dot"
},
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
:{
"uuid"
:
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
,
"nodeType"
:
"Normal"
,
"scope"
:
"view"
},
"70625377-B34E-4314-8782-360AEB31DAE8"
:{
"uuid"
:
"70625377-B34E-4314-8782-360AEB31DAE8"
,
"nodeType"
:
"Vector3"
,
"x"
:
0
,
"y"
:
0
,
"z"
:
-1.3
},
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
:{
"uuid"
:
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
,
"nodeType"
:
"Float"
,
"value"
:
1.3
},
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
:{
"uuid"
:
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
,
"nodeType"
:
"Float"
,
"value"
:
3
},
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
:{
"uuid"
:
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
}},
"materials"
:{
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
:{
"uuid"
:
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
,
"type"
:
"PhongNodeMaterial"
,
"blending"
:
2
,
"depthWrite"
:
false
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
,
"fragment"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
}},
"material"
:
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
}
\ No newline at end of file
{
"nodes"
:{
"42ED4EED-5956-4583-91BB-04BF1D350635"
:{
"uuid"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
,
"nodeType"
:
"Phong"
,
"color"
:
"935DF79A-E12B-4692-9717-089EEC8EA392"
,
"specular"
:
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
,
"shininess"
:
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
,
"alpha"
:
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
,
"emissive"
:
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
},
"935DF79A-E12B-4692-9717-089EEC8EA392"
:{
"uuid"
:
"935DF79A-E12B-4692-9717-089EEC8EA392"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
:{
"uuid"
:
"D1BEE618-E2F4-456D-9FA1-C920FEADBDB2"
,
"nodeType"
:
"Color"
,
"r"
:
0.06666666666666667
,
"g"
:
0.06666666666666667
,
"b"
:
0.06666666666666667
},
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
:{
"uuid"
:
"CAE5134E-21AF-400D-8ADA-676E1FEDD516"
,
"nodeType"
:
"Float"
,
"value"
:
30
},
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
:{
"uuid"
:
"6B098103-A6FC-4B04-9F01-F9F1543058B5"
,
"nodeType"
:
"Math"
,
"a"
:
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
,
"b"
:
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
,
"method"
:
"pow"
},
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
:{
"uuid"
:
"014502D4-A364-4A19-90E6-B4FA8DD32AAD"
,
"nodeType"
:
"Operator"
,
"a"
:
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
,
"b"
:
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
,
"op"
:
"+"
},
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
:{
"uuid"
:
"413651FE-5DC4-47E8-9933-99DA021A7FF1"
,
"nodeType"
:
"Math"
,
"a"
:
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
,
"b"
:
"70625377-B34E-4314-8782-360AEB31DAE8"
,
"method"
:
"dot"
},
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
:{
"uuid"
:
"1269FC2B-2D70-4D7A-8290-503463CE4EF5"
,
"nodeType"
:
"Normal"
,
"scope"
:
"view"
},
"70625377-B34E-4314-8782-360AEB31DAE8"
:{
"uuid"
:
"70625377-B34E-4314-8782-360AEB31DAE8"
,
"nodeType"
:
"Vector3"
,
"x"
:
0
,
"y"
:
0
,
"z"
:
-1.3
},
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
:{
"uuid"
:
"0B859498-008B-4C2A-B364-F10B0E1DCE5F"
,
"nodeType"
:
"Float"
,
"value"
:
1.3
},
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
:{
"uuid"
:
"43394E4D-0B9F-4657-ABD7-E3BF886E77A1"
,
"nodeType"
:
"Float"
,
"value"
:
3
},
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
:{
"uuid"
:
"AF0A964B-8A14-45D0-BA62-FAE6E0C61888"
,
"nodeType"
:
"Color"
,
"r"
:
1
,
"g"
:
1
,
"b"
:
1
}},
"materials"
:{
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
:{
"uuid"
:
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
,
"type"
:
"PhongNodeMaterial"
,
"blending"
:
2
,
"depthWrite"
:
false
,
"fog"
:
false
,
"lights"
:
true
,
"vertex"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
,
"fragment"
:
"42ED4EED-5956-4583-91BB-04BF1D350635"
}},
"material"
:
"0D0CAE86-4B94-4048-A2BE-A8B7387A5A91"
}
\ No newline at end of file
examples/webgl_materials_envmaps_hdr_nodes.html
0 → 100644
浏览文件 @
95c6dcc9
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
threejs webgl - node material - hdr environment mapping
</title>
<meta
charset=
"utf-8"
>
<meta
name=
"viewport"
content=
"width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"
>
<style>
body
{
color
:
#fff
;
font-family
:
Monospace
;
font-size
:
13px
;
text-align
:
center
;
background-color
:
#000
;
margin
:
0px
;
overflow
:
hidden
;
}
a
{
color
:
#00f
}
#info
{
position
:
absolute
;
top
:
0px
;
width
:
100%
;
padding
:
5px
;
}
</style>
</head>
<body>
<div
id=
"container"
></div>
<div
id=
"info"
><a
href=
"http://threejs.org"
target=
"_blank"
rel=
"noopener"
>
threejs
</a>
- High dynamic range (RGBE) Image-based Lighting (IBL)
<br
/>
using run-time generated pre-filtered roughness mipmaps (PMREM)
<br/>
Created by Prashant Sharma and
<a
href=
"http://clara.io/"
target=
"_blank"
rel=
"noopener"
>
Ben Houston
</a>
.
</div>
<script
src=
"../build/three.js"
></script>
<script
src=
"js/controls/OrbitControls.js"
></script>
<script
src=
"js/loaders/RGBELoader.js"
></script>
<script
src=
"js/loaders/HDRCubeTextureLoader.js"
></script>
<script
src=
"js/WebGL.js"
></script>
<script
src=
"js/libs/stats.min.js"
></script>
<script
src=
"js/pmrem/PMREMGenerator.js"
></script>
<script
src=
"js/pmrem/PMREMCubeUVPacker.js"
></script>
<script
src=
"js/libs/dat.gui.min.js"
></script>
<script
type=
"module"
>
/*
* COPIED FROM webgl_materials_envmaps_hdr.html
*
*
*
*/
import
'
./js/nodes/THREE.Nodes.js
'
;
if
(
WEBGL
.
isWebGLAvailable
()
===
false
)
{
document
.
body
.
appendChild
(
WEBGL
.
getWebGLErrorMessage
()
);
}
var
params
=
{
envMap
:
'
HDR
'
,
roughness
:
0.0
,
metalness
:
0.0
,
exposure
:
1.0
,
nodes
:
true
,
animate
:
true
,
debug
:
false
,
};
var
container
,
stats
;
var
camera
,
scene
,
renderer
,
controls
;
var
torusMesh
,
torusMeshNode
,
planeMesh
;
var
ldrCubeRenderTarget
,
hdrCubeRenderTarget
,
rgbmCubeRenderTarget
;
var
ldrCubeMap
,
hdrCubeMap
,
rgbmCubeMap
;
init
();
animate
();
function
init
()
{
container
=
document
.
createElement
(
'
div
'
);
document
.
body
.
appendChild
(
container
);
camera
=
new
THREE
.
PerspectiveCamera
(
40
,
window
.
innerWidth
/
window
.
innerHeight
,
1
,
1000
);
camera
.
position
.
set
(
0
,
0
,
120
);
scene
=
new
THREE
.
Scene
();
scene
.
background
=
new
THREE
.
Color
(
0x000000
);
renderer
=
new
THREE
.
WebGLRenderer
();
renderer
.
toneMapping
=
THREE
.
LinearToneMapping
;
//
var
geometry
=
new
THREE
.
TorusKnotBufferGeometry
(
18
,
8
,
150
,
20
);
var
material
;
material
=
new
THREE
.
MeshStandardMaterial
();
material
.
color
=
new
THREE
.
Color
(
0xffffff
);
material
.
roughness
=
params
.
metalness
;
material
.
metalness
=
params
.
roguhness
;
torusMesh
=
new
THREE
.
Mesh
(
geometry
,
material
);
scene
.
add
(
torusMesh
);
material
=
new
THREE
.
MeshStandardNodeMaterial
();
material
.
color
=
new
THREE
.
Color
(
0xffffff
);
material
.
roughness
=
params
.
metalness
;
material
.
metalness
=
params
.
roguhness
;
torusMeshNode
=
new
THREE
.
Mesh
(
geometry
,
material
);
scene
.
add
(
torusMeshNode
);
planeMesh
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(
200
,
200
),
new
THREE
.
MeshBasicMaterial
()
);
planeMesh
.
position
.
y
=
-
50
;
planeMesh
.
rotation
.
x
=
-
Math
.
PI
*
0.5
;
scene
.
add
(
planeMesh
);
var
hdrUrls
=
[
'
px.hdr
'
,
'
nx.hdr
'
,
'
py.hdr
'
,
'
ny.hdr
'
,
'
pz.hdr
'
,
'
nz.hdr
'
];
hdrCubeMap
=
new
THREE
.
HDRCubeTextureLoader
()
.
setPath
(
'
./textures/cube/pisaHDR/
'
)
.
load
(
THREE
.
UnsignedByteType
,
hdrUrls
,
function
()
{
var
pmremGenerator
=
new
THREE
.
PMREMGenerator
(
hdrCubeMap
);
pmremGenerator
.
update
(
renderer
);
var
pmremCubeUVPacker
=
new
THREE
.
PMREMCubeUVPacker
(
pmremGenerator
.
cubeLods
);
pmremCubeUVPacker
.
update
(
renderer
);
hdrCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
hdrCubeMap
.
magFilter
=
THREE
.
LinearFilter
;
hdrCubeMap
.
needsUpdate
=
true
;
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
var
ldrUrls
=
[
'
px.png
'
,
'
nx.png
'
,
'
py.png
'
,
'
ny.png
'
,
'
pz.png
'
,
'
nz.png
'
];
ldrCubeMap
=
new
THREE
.
CubeTextureLoader
()
.
setPath
(
'
./textures/cube/pisa/
'
)
.
load
(
ldrUrls
,
function
()
{
ldrCubeMap
.
encoding
=
THREE
.
GammaEncoding
;
var
pmremGenerator
=
new
THREE
.
PMREMGenerator
(
ldrCubeMap
);
pmremGenerator
.
update
(
renderer
);
var
pmremCubeUVPacker
=
new
THREE
.
PMREMCubeUVPacker
(
pmremGenerator
.
cubeLods
);
pmremCubeUVPacker
.
update
(
renderer
);
ldrCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
var
rgbmUrls
=
[
'
px.png
'
,
'
nx.png
'
,
'
py.png
'
,
'
ny.png
'
,
'
pz.png
'
,
'
nz.png
'
];
rgbmCubeMap
=
new
THREE
.
CubeTextureLoader
()
.
setPath
(
'
./textures/cube/pisaRGBM16/
'
)
.
load
(
rgbmUrls
,
function
()
{
rgbmCubeMap
.
encoding
=
THREE
.
RGBM16Encoding
;
rgbmCubeMap
.
format
=
THREE
.
RGBAFormat
;
var
pmremGenerator
=
new
THREE
.
PMREMGenerator
(
rgbmCubeMap
);
pmremGenerator
.
update
(
renderer
);
var
pmremCubeUVPacker
=
new
THREE
.
PMREMCubeUVPacker
(
pmremGenerator
.
cubeLods
);
pmremCubeUVPacker
.
update
(
renderer
);
rgbmCubeRenderTarget
=
pmremCubeUVPacker
.
CubeUVRenderTarget
;
rgbmCubeMap
.
magFilter
=
THREE
.
LinearFilter
;
rgbmCubeMap
.
needsUpdate
=
true
;
pmremGenerator
.
dispose
();
pmremCubeUVPacker
.
dispose
();
}
);
renderer
.
setPixelRatio
(
window
.
devicePixelRatio
);
renderer
.
setSize
(
window
.
innerWidth
,
window
.
innerHeight
);
container
.
appendChild
(
renderer
.
domElement
);
//renderer.toneMapping = THREE.ReinhardToneMapping;
renderer
.
gammaInput
=
true
;
// ???
renderer
.
gammaOutput
=
true
;
stats
=
new
Stats
();
container
.
appendChild
(
stats
.
dom
);
controls
=
new
THREE
.
OrbitControls
(
camera
,
renderer
.
domElement
);
controls
.
minDistance
=
50
;
controls
.
maxDistance
=
300
;
window
.
addEventListener
(
'
resize
'
,
onWindowResize
,
false
);
var
gui
=
new
dat
.
GUI
();
gui
.
add
(
params
,
'
envMap
'
,
[
'
LDR
'
,
'
HDR
'
,
'
RGBM16
'
]
);
gui
.
add
(
params
,
'
roughness
'
,
0
,
1
,
0.01
);
gui
.
add
(
params
,
'
metalness
'
,
0
,
1
,
0.01
);
gui
.
add
(
params
,
'
exposure
'
,
0
,
2
,
0.01
);
gui
.
add
(
params
,
'
nodes
'
,
true
);
gui
.
add
(
params
,
'
animate
'
,
true
);
gui
.
add
(
params
,
'
debug
'
,
false
);
gui
.
open
();
}
function
onWindowResize
()
{
var
width
=
window
.
innerWidth
;
var
height
=
window
.
innerHeight
;
camera
.
aspect
=
width
/
height
;
camera
.
updateProjectionMatrix
();
renderer
.
setSize
(
width
,
height
);
}
function
animate
()
{
requestAnimationFrame
(
animate
);
stats
.
begin
();
render
();
stats
.
end
();
}
function
render
()
{
torusMesh
.
material
.
roughness
=
params
.
roughness
;
torusMesh
.
material
.
metalness
=
params
.
metalness
;
torusMeshNode
.
material
.
roughness
=
params
.
roughness
;
torusMeshNode
.
material
.
metalness
=
params
.
metalness
;
torusMesh
.
visible
=
!
params
.
nodes
;
torusMeshNode
.
visible
=
params
.
nodes
;
var
renderTarget
,
cubeMap
;
switch
(
params
.
envMap
)
{
case
'
LDR
'
:
renderTarget
=
ldrCubeRenderTarget
;
cubeMap
=
ldrCubeMap
;
break
;
case
'
HDR
'
:
renderTarget
=
hdrCubeRenderTarget
;
cubeMap
=
hdrCubeMap
;
break
;
case
'
RGBM16
'
:
renderTarget
=
rgbmCubeRenderTarget
;
cubeMap
=
rgbmCubeMap
;
break
;
}
var
newEnvMap
=
renderTarget
?
renderTarget
.
texture
:
null
;
if
(
newEnvMap
&&
newEnvMap
!==
torusMesh
.
material
.
envMap
)
{
torusMesh
.
material
.
envMap
=
newEnvMap
;
torusMesh
.
material
.
needsUpdate
=
true
;
torusMeshNode
.
material
.
envMap
=
newEnvMap
;
torusMeshNode
.
material
.
needsUpdate
=
true
;
planeMesh
.
material
.
map
=
newEnvMap
;
planeMesh
.
material
.
needsUpdate
=
true
;
}
if
(
params
.
animate
)
{
torusMesh
.
rotation
.
y
+=
0.005
;
torusMeshNode
.
rotation
.
y
=
torusMesh
.
rotation
.
y
;
}
planeMesh
.
visible
=
params
.
debug
;
scene
.
background
=
cubeMap
;
renderer
.
toneMappingExposure
=
params
.
exposure
;
renderer
.
render
(
scene
,
camera
);
}
</script>
</body>
</html>
examples/webgl_materials_nodes.html
浏览文件 @
95c6dcc9
...
...
@@ -177,6 +177,7 @@
'
adv / translucent
'
:
'
translucent
'
,
'
node / position
'
:
'
node-position
'
,
'
node / normal
'
:
'
node-normal
'
,
'
node / reflect
'
:
'
node-reflect
'
,
'
misc / smoke
'
:
'
smoke
'
,
'
misc / firefly
'
:
'
firefly
'
,
'
misc / reserved-keywords
'
:
'
reserved-keywords
'
,
...
...
@@ -209,7 +210,7 @@
}
);
}
else
if
(
typeof
value
==
'
object
'
)
{
}
else
if
(
typeof
value
==
=
'
object
'
)
{
param
[
name
]
=
value
[
Object
.
keys
(
value
)[
0
]
];
...
...
@@ -292,7 +293,7 @@
mtl
.
environment
=
new
THREE
.
CubeTextureNode
(
cubemap
);
mtl
.
environmentAlpha
=
mask
;
mtl
.
normal
=
new
THREE
.
NormalMapNode
(
new
THREE
.
TextureNode
(
getTexture
(
"
grassNormal
"
)
)
);
mtl
.
normal
.
scale
=
new
THREE
.
Math
1Node
(
mask
,
THREE
.
Math1
Node
.
INVERT
);
mtl
.
normal
.
scale
=
new
THREE
.
Math
Node
(
mask
,
THREE
.
Math
Node
.
INVERT
);
break
;
...
...
@@ -325,22 +326,22 @@
var
roughnessB
=
new
THREE
.
FloatNode
(
0
);
var
metalnessB
=
new
THREE
.
FloatNode
(
1
);
var
roughness
=
new
THREE
.
Math
3
Node
(
var
roughness
=
new
THREE
.
MathNode
(
roughnessA
,
roughnessB
,
mask
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
metalness
=
new
THREE
.
Math
3
Node
(
var
metalness
=
new
THREE
.
MathNode
(
metalnessA
,
metalnessB
,
mask
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
normalMask
=
new
THREE
.
OperatorNode
(
new
THREE
.
Math
1Node
(
mask
,
THREE
.
Math1
Node
.
INVERT
),
new
THREE
.
Math
Node
(
mask
,
THREE
.
Math
Node
.
INVERT
),
normalScale
,
THREE
.
OperatorNode
.
MUL
);
...
...
@@ -538,22 +539,22 @@
var
clearCoat
=
new
THREE
.
FloatNode
(
1
);
var
clearCoatRoughness
=
new
THREE
.
FloatNode
(
1
);
var
roughness
=
new
THREE
.
Math
3
Node
(
var
roughness
=
new
THREE
.
MathNode
(
roughnessA
,
roughnessB
,
mask
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
metalness
=
new
THREE
.
Math
3
Node
(
var
metalness
=
new
THREE
.
MathNode
(
metalnessA
,
metalnessB
,
mask
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
normalMask
=
new
THREE
.
OperatorNode
(
new
THREE
.
Math
1Node
(
mask
,
THREE
.
Math1
Node
.
INVERT
),
new
THREE
.
Math
Node
(
mask
,
THREE
.
Math
Node
.
INVERT
),
normalScale
,
THREE
.
OperatorNode
.
MUL
);
...
...
@@ -661,7 +662,7 @@
THREE
.
OperatorNode
.
ADD
);
var
wave
=
new
THREE
.
Math
1Node
(
posContinuous
,
THREE
.
Math1
Node
.
SIN
);
var
wave
=
new
THREE
.
Math
Node
(
posContinuous
,
THREE
.
Math
Node
.
SIN
);
wave
=
new
THREE
.
SwitchNode
(
wave
,
'
x
'
);
var
waveScale
=
new
THREE
.
OperatorNode
(
...
...
@@ -688,11 +689,11 @@
THREE
.
OperatorNode
.
ADD
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
colorB
,
colorA
,
wave
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
.
color
=
color
;
...
...
@@ -752,10 +753,10 @@
var
power
=
new
THREE
.
FloatNode
(
3
);
var
color
=
new
THREE
.
ColorNode
(
0xFFFFFF
);
var
viewZ
=
new
THREE
.
Math
2
Node
(
var
viewZ
=
new
THREE
.
MathNode
(
new
THREE
.
NormalNode
(),
new
THREE
.
Vector3Node
(
0
,
0
,
-
intensity
),
THREE
.
Math
2
Node
.
DOT
THREE
.
MathNode
.
DOT
);
var
rim
=
new
THREE
.
OperatorNode
(
...
...
@@ -764,10 +765,10 @@
THREE
.
OperatorNode
.
ADD
);
var
rimPower
=
new
THREE
.
Math
2
Node
(
var
rimPower
=
new
THREE
.
MathNode
(
rim
,
power
,
THREE
.
Math
2
Node
.
POW
THREE
.
MathNode
.
POW
);
var
rimColor
=
new
THREE
.
OperatorNode
(
...
...
@@ -812,7 +813,7 @@
mtl
.
blending
=
THREE
.
AdditiveBlending
;
mtl
.
depthWrite
=
false
;
}
else
{
}
else
{
mtl
.
emissive
=
rimColor
;
mtl
.
alpha
=
null
;
...
...
@@ -1033,10 +1034,10 @@
var
power
=
new
THREE
.
FloatNode
(
1
);
var
color
=
new
THREE
.
CubeTextureNode
(
cubemap
);
var
viewZ
=
new
THREE
.
Math
2
Node
(
var
viewZ
=
new
THREE
.
MathNode
(
new
THREE
.
NormalNode
(),
new
THREE
.
Vector3Node
(
0
,
0
,
-
1
),
THREE
.
Math
2
Node
.
DOT
THREE
.
MathNode
.
DOT
);
var
theta
=
new
THREE
.
OperatorNode
(
...
...
@@ -1045,10 +1046,10 @@
THREE
.
OperatorNode
.
ADD
);
var
thetaPower
=
new
THREE
.
Math
2
Node
(
var
thetaPower
=
new
THREE
.
MathNode
(
theta
,
power
,
THREE
.
Math
2
Node
.
POW
THREE
.
MathNode
.
POW
);
var
fresnel
=
new
THREE
.
OperatorNode
(
...
...
@@ -1059,7 +1060,7 @@
mtl
.
color
=
new
THREE
.
ColorNode
(
0x3399FF
);
mtl
.
environment
=
color
;
mtl
.
environmentAlpha
=
new
THREE
.
Math
1Node
(
fresnel
,
THREE
.
Math1
Node
.
SATURATE
);
mtl
.
environmentAlpha
=
new
THREE
.
Math
Node
(
fresnel
,
THREE
.
Math
Node
.
SATURATE
);
// GUI
...
...
@@ -1105,11 +1106,11 @@
var
mask
=
new
THREE
.
TextureNode
(
getTexture
(
"
decalDiffuse
"
),
uvScale
);
var
maskAlphaChannel
=
new
THREE
.
SwitchNode
(
mask
,
'
w
'
);
var
blend
=
new
THREE
.
Math
3
Node
(
var
blend
=
new
THREE
.
MathNode
(
tex1
,
tex2
,
maskAlphaChannel
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
.
color
=
blend
;
...
...
@@ -1195,9 +1196,9 @@
THREE
.
OperatorNode
.
ADD
);
var
clamp0at1
=
new
THREE
.
Math
1Node
(
offsetClamp
,
THREE
.
Math1
Node
.
SATURATE
);
var
clamp0at1
=
new
THREE
.
Math
Node
(
offsetClamp
,
THREE
.
Math
Node
.
SATURATE
);
var
blend
=
new
THREE
.
Math
3Node
(
top
,
bottom
,
clamp0at1
,
THREE
.
Math3
Node
.
MIX
);
var
blend
=
new
THREE
.
Math
Node
(
top
,
bottom
,
clamp0at1
,
THREE
.
Math
Node
.
MIX
);
mtl
.
color
=
blend
;
...
...
@@ -1268,11 +1269,11 @@
THREE
.
OperatorNode
.
ADD
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
colorB
,
colorA
,
texArea
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
.
color
=
mtl
.
specular
=
new
THREE
.
ColorNode
(
0
);
...
...
@@ -1322,11 +1323,11 @@
var
tex
=
new
THREE
.
TextureNode
(
getTexture
(
"
cloud
"
)
);
var
texArea
=
new
THREE
.
SwitchNode
(
tex
,
'
w
'
);
var
thresholdBorder
=
new
THREE
.
Math
3
Node
(
var
thresholdBorder
=
new
THREE
.
MathNode
(
new
THREE
.
OperatorNode
(
threshold
,
borderSize
,
THREE
.
OperatorNode
.
ADD
),
threshold
,
texArea
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
thresholdEmissive
=
new
THREE
.
OperatorNode
(
...
...
@@ -1394,7 +1395,7 @@
THREE
.
OperatorNode
.
MUL
);
var
cycle
=
new
THREE
.
Math
1Node
(
sinCycleInSecs
,
THREE
.
Math1
Node
.
SIN
);
var
cycle
=
new
THREE
.
Math
Node
(
sinCycleInSecs
,
THREE
.
Math
Node
.
SIN
);
// round sin to 0 at 1
cycle
=
new
THREE
.
OperatorNode
(
cycle
,
new
THREE
.
FloatNode
(
1
),
THREE
.
OperatorNode
.
ADD
);
...
...
@@ -1406,11 +1407,11 @@
var
tex
=
new
THREE
.
TextureNode
(
getTexture
(
"
cloud
"
)
);
var
texArea
=
new
THREE
.
SwitchNode
(
tex
,
'
w
'
);
var
thresholdBorder
=
new
THREE
.
Math
3
Node
(
var
thresholdBorder
=
new
THREE
.
MathNode
(
new
THREE
.
OperatorNode
(
threshold
,
fireSize
,
THREE
.
OperatorNode
.
ADD
),
threshold
,
texArea
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
fireStartAnimatedColor
=
new
THREE
.
ColorAdjustmentNode
(
...
...
@@ -1425,18 +1426,18 @@
THREE
.
ColorAdjustmentNode
.
SATURATION
);
var
fireColor
=
new
THREE
.
Math
3
Node
(
var
fireColor
=
new
THREE
.
MathNode
(
fireEndAnimatedColor
,
fireStartAnimatedColor
,
thresholdBorder
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
thresholdBurnedBorder
=
new
THREE
.
Math
3
Node
(
var
thresholdBurnedBorder
=
new
THREE
.
MathNode
(
new
THREE
.
OperatorNode
(
threshold
,
burnedSize
,
THREE
.
OperatorNode
.
ADD
),
threshold
,
texArea
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
fireEmissive
=
new
THREE
.
OperatorNode
(
...
...
@@ -1445,11 +1446,11 @@
THREE
.
OperatorNode
.
MUL
);
var
burnedResultColor
=
new
THREE
.
Math
3
Node
(
var
burnedResultColor
=
new
THREE
.
MathNode
(
color
,
burnedColor
,
thresholdBurnedBorder
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
// APPLY
...
...
@@ -1582,11 +1583,11 @@
depth
.
near
.
value
=
1
;
depth
.
far
.
value
=
200
;
var
colors
=
new
THREE
.
Math
3
Node
(
var
colors
=
new
THREE
.
MathNode
(
colorB
,
colorA
,
depth
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
=
new
THREE
.
PhongNodeMaterial
();
...
...
@@ -1693,7 +1694,7 @@
var
mask
=
new
THREE
.
SwitchNode
(
worldNormal
,
'
y
'
);
// clamp0at1
mask
=
new
THREE
.
Math
1Node
(
mask
,
THREE
.
Math1
Node
.
SATURATE
);
mask
=
new
THREE
.
Math
Node
(
mask
,
THREE
.
Math
Node
.
SATURATE
);
var
timeOffset
=
new
THREE
.
OperatorNode
(
time
,
...
...
@@ -1723,18 +1724,18 @@
THREE
.
OperatorNode
.
MUL
);
var
voronoiColors
=
new
THREE
.
Math
3
Node
(
var
voronoiColors
=
new
THREE
.
MathNode
(
colorB
,
colorA
,
new
THREE
.
Math
1Node
(
voronoiIntensity
,
THREE
.
Math1
Node
.
SATURATE
),
// mix needs clamp
THREE
.
Math
3
Node
.
MIX
new
THREE
.
Math
Node
(
voronoiIntensity
,
THREE
.
Math
Node
.
SATURATE
),
// mix needs clamp
THREE
.
MathNode
.
MIX
);
var
caustic
=
new
THREE
.
Math
3
Node
(
var
caustic
=
new
THREE
.
MathNode
(
color
,
voronoiColors
,
maskCaustic
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
causticLights
=
new
THREE
.
OperatorNode
(
...
...
@@ -1805,7 +1806,7 @@
var
colorB
=
new
THREE
.
ColorNode
(
0x3366FF
);
var
pos
=
new
THREE
.
PositionNode
();
var
posNorm
=
new
THREE
.
Math
1Node
(
pos
,
THREE
.
Math1
Node
.
NORMALIZE
);
var
posNorm
=
new
THREE
.
Math
Node
(
pos
,
THREE
.
Math
Node
.
NORMALIZE
);
var
mask
=
new
THREE
.
SwitchNode
(
posNorm
,
'
y
'
);
...
...
@@ -1833,11 +1834,11 @@
THREE
.
OperatorNode
.
ADD
);
var
colors
=
new
THREE
.
Math
3
Node
(
var
colors
=
new
THREE
.
MathNode
(
colorB
,
colorA
,
mask
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
.
color
=
colors
;
...
...
@@ -1887,13 +1888,13 @@
var
mildness
=
new
THREE
.
FloatNode
(
1.6
);
var
fur
=
new
THREE
.
FloatNode
(
.
5
);
var
posDirection
=
new
THREE
.
Math
1Node
(
new
THREE
.
PositionNode
(
THREE
.
PositionNode
.
VIEW
),
THREE
.
Math1
Node
.
NORMALIZE
);
var
norDirection
=
new
THREE
.
Math
1Node
(
new
THREE
.
NormalNode
(),
THREE
.
Math1
Node
.
NORMALIZE
);
var
posDirection
=
new
THREE
.
Math
Node
(
new
THREE
.
PositionNode
(
THREE
.
PositionNode
.
VIEW
),
THREE
.
Math
Node
.
NORMALIZE
);
var
norDirection
=
new
THREE
.
Math
Node
(
new
THREE
.
NormalNode
(),
THREE
.
Math
Node
.
NORMALIZE
);
var
viewZ
=
new
THREE
.
Math
2
Node
(
var
viewZ
=
new
THREE
.
MathNode
(
posDirection
,
norDirection
,
THREE
.
Math
2
Node
.
DOT
THREE
.
MathNode
.
DOT
);
// without luma correction for now
...
...
@@ -1913,7 +1914,7 @@
mtl
.
normal
=
new
THREE
.
NormalMapNode
(
new
THREE
.
TextureNode
(
getTexture
(
"
grassNormal
"
)
)
);
mtl
.
normal
.
scale
=
furScale
;
mtl
.
environment
=
mildnessColor
;
mtl
.
environmentAlpha
=
new
THREE
.
Math
1Node
(
viewZ
,
THREE
.
Math1
Node
.
INVERT
);
mtl
.
environmentAlpha
=
new
THREE
.
Math
Node
(
viewZ
,
THREE
.
Math
Node
.
INVERT
);
mtl
.
shininess
=
new
THREE
.
FloatNode
(
0
);
// GUI
...
...
@@ -1954,11 +1955,11 @@
var
lightLuminance
=
new
THREE
.
LuminanceNode
(
directLight
);
var
lightWrap
=
new
THREE
.
Math
3
Node
(
var
lightWrap
=
new
THREE
.
MathNode
(
wrapShadow
,
wrapLight
,
lightLuminance
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
lightTransition
=
new
THREE
.
OperatorNode
(
...
...
@@ -1967,7 +1968,7 @@
THREE
.
OperatorNode
.
MUL
);
var
wrappedLight
=
new
THREE
.
Math
1Node
(
lightTransition
,
THREE
.
Math1
Node
.
SIN
);
var
wrappedLight
=
new
THREE
.
Math
Node
(
lightTransition
,
THREE
.
Math
Node
.
SIN
);
var
wrappedLightColor
=
new
THREE
.
OperatorNode
(
wrappedLight
,
...
...
@@ -1975,7 +1976,7 @@
THREE
.
OperatorNode
.
MUL
);
var
bloodArea
=
new
THREE
.
Math
1Node
(
wrappedLightColor
,
THREE
.
Math1
Node
.
SATURATE
);
var
bloodArea
=
new
THREE
.
Math
Node
(
wrappedLightColor
,
THREE
.
Math
Node
.
SATURATE
);
var
totalLight
=
new
THREE
.
OperatorNode
(
directLight
,
...
...
@@ -2058,9 +2059,9 @@
THREE
.
OperatorNode
.
MUL
);
var
celLight
=
new
THREE
.
Math
1
Node
(
var
celLight
=
new
THREE
.
MathNode
(
preCelLight
,
THREE
.
Math
1
Node
.
CEIL
THREE
.
MathNode
.
CEIL
);
var
posCelLight
=
new
THREE
.
OperatorNode
(
...
...
@@ -2071,18 +2072,18 @@
// LINE
var
posDirection
=
new
THREE
.
Math
1Node
(
new
THREE
.
PositionNode
(
THREE
.
PositionNode
.
VIEW
),
THREE
.
Math1
Node
.
NORMALIZE
);
var
norDirection
=
new
THREE
.
Math
1Node
(
new
THREE
.
NormalNode
(),
THREE
.
Math1
Node
.
NORMALIZE
);
var
posDirection
=
new
THREE
.
Math
Node
(
new
THREE
.
PositionNode
(
THREE
.
PositionNode
.
VIEW
),
THREE
.
Math
Node
.
NORMALIZE
);
var
norDirection
=
new
THREE
.
Math
Node
(
new
THREE
.
NormalNode
(),
THREE
.
Math
Node
.
NORMALIZE
);
var
viewZ
=
new
THREE
.
Math
2
Node
(
var
viewZ
=
new
THREE
.
MathNode
(
posDirection
,
norDirection
,
THREE
.
Math
2
Node
.
DOT
THREE
.
MathNode
.
DOT
);
var
lineOutside
=
new
THREE
.
Math
1
Node
(
var
lineOutside
=
new
THREE
.
MathNode
(
viewZ
,
THREE
.
Math
1
Node
.
ABS
THREE
.
MathNode
.
ABS
);
var
line
=
new
THREE
.
OperatorNode
(
...
...
@@ -2091,14 +2092,14 @@
THREE
.
OperatorNode
.
DIV
);
var
lineScaled
=
new
THREE
.
Math
3
Node
(
var
lineScaled
=
new
THREE
.
MathNode
(
line
,
lineSize
,
lineInner
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
innerContour
=
new
THREE
.
Math
1Node
(
new
THREE
.
Math1Node
(
lineScaled
,
THREE
.
Math1Node
.
SATURATE
),
THREE
.
Math1
Node
.
INVERT
);
var
innerContour
=
new
THREE
.
Math
Node
(
new
THREE
.
MathNode
(
lineScaled
,
THREE
.
MathNode
.
SATURATE
),
THREE
.
Math
Node
.
INVERT
);
// APPLY
...
...
@@ -2291,6 +2292,32 @@
break
;
case
'
node-reflect
'
:
// MATERIAL
var
node
=
new
THREE
.
ReflectNode
();
mtl
=
new
THREE
.
PhongNodeMaterial
();
mtl
.
environment
=
new
THREE
.
CubeTextureNode
(
cubemap
,
node
);
// GUI
addGui
(
'
scope
'
,
{
vector
:
THREE
.
ReflectNode
.
VECTOR
,
cube
:
THREE
.
ReflectNode
.
CUBE
,
sphere
:
THREE
.
ReflectNode
.
SPHERE
},
function
(
val
)
{
node
.
scope
=
val
;
mtl
.
needsUpdate
=
true
;
}
);
break
;
case
'
varying
'
:
// MATERIAL
...
...
@@ -2474,11 +2501,11 @@
var
timer
=
new
THREE
.
TimerNode
(
.
01
,
THREE
.
TimerNode
.
LOCAL
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
rttStore
,
blur
,
new
THREE
.
FloatNode
(
.
6
),
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
blur
.
horizontal
=
blur
.
vertical
=
timer
;
...
...
@@ -2594,11 +2621,11 @@
uv
:
new
THREE
.
UVNode
()
}
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
new
THREE
.
TextureNode
(
getTexture
(
"
brick
"
)
),
blurredTexture
,
alpha
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
mtl
.
color
=
color
;
...
...
@@ -2698,7 +2725,7 @@
THREE
.
OperatorNode
.
MUL
);
var
cycle
=
new
THREE
.
Math
1Node
(
sinCycleInSecs
,
THREE
.
Math1
Node
.
SIN
);
var
cycle
=
new
THREE
.
Math
Node
(
sinCycleInSecs
,
THREE
.
Math
Node
.
SIN
);
var
cycleColor
=
new
THREE
.
OperatorNode
(
cycle
,
...
...
@@ -2706,7 +2733,7 @@
THREE
.
OperatorNode
.
MUL
);
var
cos
=
new
THREE
.
Math
1Node
(
cycleColor
,
THREE
.
Math1
Node
.
SIN
);
var
cos
=
new
THREE
.
Math
Node
(
cycleColor
,
THREE
.
Math
Node
.
SIN
);
mtl
.
color
=
new
THREE
.
ColorNode
(
0
);
mtl
.
emissive
=
cos
;
...
...
@@ -2731,10 +2758,10 @@
var
viewPos
=
new
THREE
.
PositionNode
(
THREE
.
PositionNode
.
VIEW
);
var
cameraPosition
=
new
THREE
.
CameraNode
(
THREE
.
CameraNode
.
POSITION
);
var
cameraDistance
=
new
THREE
.
Math
2
Node
(
var
cameraDistance
=
new
THREE
.
MathNode
(
modelPos
,
cameraPosition
,
THREE
.
Math
2
Node
.
DISTANCE
THREE
.
MathNode
.
DISTANCE
);
var
viewPosZ
=
new
THREE
.
SwitchNode
(
viewPos
,
'
z
'
);
...
...
@@ -2751,11 +2778,11 @@
THREE
.
OperatorNode
.
ADD
);
var
objectDepth
=
new
THREE
.
Math
3
Node
(
var
objectDepth
=
new
THREE
.
MathNode
(
distanceRadius
,
new
THREE
.
FloatNode
(
0
),
new
THREE
.
FloatNode
(
50
),
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
// RTT ( get back distance )
...
...
@@ -2782,33 +2809,33 @@
THREE
.
OperatorNode
.
SUB
);
var
sss
=
new
THREE
.
Math
3
Node
(
var
sss
=
new
THREE
.
MathNode
(
new
THREE
.
FloatNode
(
-
.
1
),
new
THREE
.
FloatNode
(
.
5
),
difference
,
THREE
.
Math
3
Node
.
SMOOTHSTEP
THREE
.
MathNode
.
SMOOTHSTEP
);
var
sssAlpha
=
new
THREE
.
Math
1Node
(
sss
,
THREE
.
Math1
Node
.
SATURATE
);
var
sssAlpha
=
new
THREE
.
Math
Node
(
sss
,
THREE
.
Math
Node
.
SATURATE
);
var
frontColor
,
backColor
;
if
(
name
==
'
sss
'
)
{
var
sssOut
=
new
THREE
.
Math
2
Node
(
var
sssOut
=
new
THREE
.
MathNode
(
objectDepth
,
sssAlpha
,
THREE
.
Math
2
Node
.
MIN
THREE
.
MathNode
.
MIN
);
frontColor
=
new
THREE
.
ColorNode
(
0xd4cfbb
);
backColor
=
new
THREE
.
ColorNode
(
0xd04327
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
backColor
,
frontColor
,
sssOut
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
light
=
new
THREE
.
OperatorNode
(
...
...
@@ -2829,11 +2856,11 @@
frontColor
=
new
THREE
.
ColorNode
(
0xd04327
);
backColor
=
new
THREE
.
ColorNode
(
0x1a0e14
);
var
color
=
new
THREE
.
Math
3
Node
(
var
color
=
new
THREE
.
MathNode
(
frontColor
,
backColor
,
sssAlpha
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
light
=
new
THREE
.
OperatorNode
(
...
...
@@ -2973,7 +3000,7 @@
// update material animation and/or gpu calcs (pre-renderer)
frame
.
update
(
delta
).
setRenderer
(
renderer
);
frame
.
setRenderer
(
renderer
).
update
(
delta
);
if
(
mesh
.
material
instanceof
THREE
.
NodeMaterial
)
{
...
...
examples/webgl_mirror_nodes.html
浏览文件 @
95c6dcc9
...
...
@@ -97,9 +97,9 @@
var
normalMap
=
new
THREE
.
TextureNode
(
decalNormal
);
var
normalXY
=
new
THREE
.
SwitchNode
(
normalMap
,
'
xy
'
);
var
normalXYFlip
=
new
THREE
.
Math
1
Node
(
var
normalXYFlip
=
new
THREE
.
MathNode
(
normalXY
,
THREE
.
Math
1
Node
.
INVERT
THREE
.
MathNode
.
INVERT
);
var
offsetNormal
=
new
THREE
.
OperatorNode
(
...
...
examples/webgl_postprocessing_nodes.html
浏览文件 @
95c6dcc9
...
...
@@ -172,11 +172,11 @@
var
color
=
new
THREE
.
ColorNode
(
0xFFFFFF
);
var
percent
=
new
THREE
.
FloatNode
(
.
5
);
var
fade
=
new
THREE
.
Math
3
Node
(
var
fade
=
new
THREE
.
MathNode
(
new
THREE
.
ScreenNode
(),
color
,
percent
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepost
.
output
=
fade
;
...
...
@@ -204,13 +204,13 @@
var
alpha
=
new
THREE
.
FloatNode
(
1
);
var
screen
=
new
THREE
.
ScreenNode
();
var
inverted
=
new
THREE
.
Math
1Node
(
screen
,
THREE
.
Math1
Node
.
INVERT
);
var
inverted
=
new
THREE
.
Math
Node
(
screen
,
THREE
.
Math
Node
.
INVERT
);
var
fade
=
new
THREE
.
Math
3
Node
(
var
fade
=
new
THREE
.
MathNode
(
screen
,
inverted
,
alpha
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepost
.
output
=
fade
;
...
...
@@ -293,9 +293,9 @@
var
normalXY
=
new
THREE
.
SwitchNode
(
normal
,
'
xy
'
);
var
scale
=
new
THREE
.
FloatNode
(
.
5
);
var
normalXYFlip
=
new
THREE
.
Math
1
Node
(
var
normalXYFlip
=
new
THREE
.
MathNode
(
normalXY
,
THREE
.
Math
1
Node
.
INVERT
THREE
.
MathNode
.
INVERT
);
var
offsetNormal
=
new
THREE
.
OperatorNode
(
...
...
@@ -310,11 +310,11 @@
THREE
.
OperatorNode
.
MUL
);
var
scaleNormal
=
new
THREE
.
Math
3
Node
(
var
scaleNormal
=
new
THREE
.
MathNode
(
new
THREE
.
FloatNode
(
1
),
scaleTexture
,
scale
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
offsetCoord
=
new
THREE
.
OperatorNode
(
...
...
@@ -355,11 +355,11 @@
var
previousFrame
=
new
THREE
.
RTTNode
(
size
.
width
,
size
.
height
,
screen
);
var
motionBlur
=
new
THREE
.
Math
3
Node
(
var
motionBlur
=
new
THREE
.
MathNode
(
previousFrame
,
screen
,
new
THREE
.
FloatNode
(
.
5
),
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
currentFrame
=
new
THREE
.
RTTNode
(
size
.
width
,
size
.
height
,
motionBlur
);
...
...
@@ -383,9 +383,9 @@
THREE
.
OperatorNode
.
MUL
);
var
blocksSize
=
new
THREE
.
Math
1
Node
(
var
blocksSize
=
new
THREE
.
MathNode
(
blocks
,
THREE
.
Math
1
Node
.
FLOOR
THREE
.
MathNode
.
FLOOR
);
var
mosaicUV
=
new
THREE
.
OperatorNode
(
...
...
@@ -394,11 +394,11 @@
THREE
.
OperatorNode
.
DIV
);
var
fadeScreen
=
new
THREE
.
Math
3
Node
(
var
fadeScreen
=
new
THREE
.
MathNode
(
uv
,
mosaicUV
,
fade
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepost
.
output
=
new
THREE
.
ScreenNode
(
fadeScreen
);
...
...
examples/webgl_postprocessing_nodes_pass.html
浏览文件 @
95c6dcc9
...
...
@@ -177,11 +177,11 @@
var
color
=
new
THREE
.
ColorNode
(
0xFFFFFF
);
var
percent
=
new
THREE
.
FloatNode
(
.
5
);
var
fade
=
new
THREE
.
Math
3
Node
(
var
fade
=
new
THREE
.
MathNode
(
new
THREE
.
ScreenNode
(),
color
,
percent
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepass
.
input
=
fade
;
...
...
@@ -209,13 +209,13 @@
var
alpha
=
new
THREE
.
FloatNode
(
1
);
var
screen
=
new
THREE
.
ScreenNode
();
var
inverted
=
new
THREE
.
Math
1Node
(
screen
,
THREE
.
Math1
Node
.
INVERT
);
var
inverted
=
new
THREE
.
Math
Node
(
screen
,
THREE
.
Math
Node
.
INVERT
);
var
fade
=
new
THREE
.
Math
3
Node
(
var
fade
=
new
THREE
.
MathNode
(
screen
,
inverted
,
alpha
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepass
.
input
=
fade
;
...
...
@@ -298,9 +298,9 @@
var
normalXY
=
new
THREE
.
SwitchNode
(
normal
,
'
xy
'
);
var
scale
=
new
THREE
.
FloatNode
(
.
5
);
var
normalXYFlip
=
new
THREE
.
Math
1
Node
(
var
normalXYFlip
=
new
THREE
.
MathNode
(
normalXY
,
THREE
.
Math
1
Node
.
INVERT
THREE
.
MathNode
.
INVERT
);
var
offsetNormal
=
new
THREE
.
OperatorNode
(
...
...
@@ -315,11 +315,11 @@
THREE
.
OperatorNode
.
MUL
);
var
scaleNormal
=
new
THREE
.
Math
3
Node
(
var
scaleNormal
=
new
THREE
.
MathNode
(
new
THREE
.
FloatNode
(
1
),
scaleTexture
,
scale
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
var
offsetCoord
=
new
THREE
.
OperatorNode
(
...
...
@@ -364,9 +364,9 @@
THREE
.
OperatorNode
.
MUL
);
var
blocksSize
=
new
THREE
.
Math
1
Node
(
var
blocksSize
=
new
THREE
.
MathNode
(
blocks
,
THREE
.
Math
1
Node
.
FLOOR
THREE
.
MathNode
.
FLOOR
);
var
mosaicUV
=
new
THREE
.
OperatorNode
(
...
...
@@ -375,11 +375,11 @@
THREE
.
OperatorNode
.
DIV
);
var
fadeScreen
=
new
THREE
.
Math
3
Node
(
var
fadeScreen
=
new
THREE
.
MathNode
(
uv
,
mosaicUV
,
fade
,
THREE
.
Math
3
Node
.
MIX
THREE
.
MathNode
.
MIX
);
nodepass
.
input
=
new
THREE
.
ScreenNode
(
fadeScreen
);
...
...
examples/webgl_sprites_nodes.html
浏览文件 @
95c6dcc9
...
...
@@ -82,9 +82,9 @@
THREE
.
OperatorNode
.
MUL
);
var
uvIntegerTimer
=
new
THREE
.
Math
1
Node
(
var
uvIntegerTimer
=
new
THREE
.
MathNode
(
uvTimer
,
THREE
.
Math
1
Node
.
FLOOR
THREE
.
MathNode
.
FLOOR
);
var
uvFrameOffset
=
new
THREE
.
OperatorNode
(
...
...
@@ -126,12 +126,12 @@
sprite2
.
scale
.
y
=
spriteHeight
;
sprite2
.
material
.
color
=
new
THREE
.
TextureNode
(
walkingManTexture
);
sprite2
.
material
.
color
.
uv
=
createHorizontalSpriteSheetNode
(
8
,
30
);
sprite2
.
material
.
color
=
new
THREE
.
Math
1Node
(
sprite2
.
material
.
color
,
THREE
.
Math1
Node
.
INVERT
);
sprite2
.
material
.
color
=
new
THREE
.
Math
Node
(
sprite2
.
material
.
color
,
THREE
.
Math
Node
.
INVERT
);
sprite2
.
material
.
spherical
=
false
;
// look at camera horizontally only, very used in vegetation
// horizontal zigzag sprite
sprite2
.
material
.
position
=
new
THREE
.
OperatorNode
(
new
THREE
.
OperatorNode
(
new
THREE
.
Math
1Node
(
new
THREE
.
TimerNode
(
3
),
THREE
.
Math1
Node
.
SIN
),
// 3 is speed (time scale)
new
THREE
.
Math
Node
(
new
THREE
.
TimerNode
(
3
),
THREE
.
Math
Node
.
SIN
),
// 3 is speed (time scale)
new
THREE
.
Vector2Node
(
.
3
,
0
),
// horizontal scale (position)
THREE
.
OperatorNode
.
MUL
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录