Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
9b26302c
T
three.js
项目概览
Ablesons
/
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,发现更多精彩内容 >>
未验证
提交
9b26302c
编写于
7月 26, 2018
作者:
M
Mr.doob
提交者:
GitHub
7月 26, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14427 from sunag/dev-nodematerial-r7
NodeMaterial - r7 (2)
上级
e475b4ec
4f71b42f
变更
87
展开全部
隐藏空白更改
内联
并排
Showing
87 changed file
with
5236 addition
and
3352 deletion
+5236
-3352
examples/files.js
examples/files.js
+2
-0
examples/js/nodes/Nodes.js
examples/js/nodes/Nodes.js
+7
-1
examples/js/nodes/THREE.Nodes.js
examples/js/nodes/THREE.Nodes.js
+43
-25
examples/js/nodes/accessors/CameraNode.js
examples/js/nodes/accessors/CameraNode.js
+22
-22
examples/js/nodes/accessors/ColorsNode.js
examples/js/nodes/accessors/ColorsNode.js
+7
-8
examples/js/nodes/accessors/LightNode.js
examples/js/nodes/accessors/LightNode.js
+6
-6
examples/js/nodes/accessors/NormalNode.js
examples/js/nodes/accessors/NormalNode.js
+7
-7
examples/js/nodes/accessors/PositionNode.js
examples/js/nodes/accessors/PositionNode.js
+8
-8
examples/js/nodes/accessors/ReflectNode.js
examples/js/nodes/accessors/ReflectNode.js
+6
-6
examples/js/nodes/accessors/ResolutionNode.js
examples/js/nodes/accessors/ResolutionNode.js
+18
-12
examples/js/nodes/accessors/ScreenUVNode.js
examples/js/nodes/accessors/ScreenUVNode.js
+7
-6
examples/js/nodes/accessors/UVNode.js
examples/js/nodes/accessors/UVNode.js
+6
-6
examples/js/nodes/bsdfs/BlinnExponentToRoughnessNode.js
examples/js/nodes/bsdfs/BlinnExponentToRoughnessNode.js
+4
-4
examples/js/nodes/bsdfs/BlinnShininessExponentNode.js
examples/js/nodes/bsdfs/BlinnShininessExponentNode.js
+1
-1
examples/js/nodes/bsdfs/RoughnessToBlinnExponentNode.js
examples/js/nodes/bsdfs/RoughnessToBlinnExponentNode.js
+12
-11
examples/js/nodes/core/AttributeNode.js
examples/js/nodes/core/AttributeNode.js
+9
-9
examples/js/nodes/core/ConstNode.js
examples/js/nodes/core/ConstNode.js
+12
-12
examples/js/nodes/core/ExpressionNode.js
examples/js/nodes/core/ExpressionNode.js
+17
-0
examples/js/nodes/core/FunctionCallNode.js
examples/js/nodes/core/FunctionCallNode.js
+5
-5
examples/js/nodes/core/FunctionNode.js
examples/js/nodes/core/FunctionNode.js
+25
-26
examples/js/nodes/core/InputNode.js
examples/js/nodes/core/InputNode.js
+5
-5
examples/js/nodes/core/Node.js
examples/js/nodes/core/Node.js
+45
-41
examples/js/nodes/core/NodeBuilder.js
examples/js/nodes/core/NodeBuilder.js
+260
-309
examples/js/nodes/core/NodeFrame.js
examples/js/nodes/core/NodeFrame.js
+23
-7
examples/js/nodes/core/NodeUniform.js
examples/js/nodes/core/NodeUniform.js
+6
-6
examples/js/nodes/core/NodeUtils.js
examples/js/nodes/core/NodeUtils.js
+9
-9
examples/js/nodes/core/StructNode.js
examples/js/nodes/core/StructNode.js
+28
-28
examples/js/nodes/core/TempNode.js
examples/js/nodes/core/TempNode.js
+17
-17
examples/js/nodes/core/VarNode.js
examples/js/nodes/core/VarNode.js
+10
-10
examples/js/nodes/effects/BlurNode.js
examples/js/nodes/effects/BlurNode.js
+15
-15
examples/js/nodes/effects/ColorAdjustmentNode.js
examples/js/nodes/effects/ColorAdjustmentNode.js
+24
-24
examples/js/nodes/effects/LuminanceNode.js
examples/js/nodes/effects/LuminanceNode.js
+10
-10
examples/js/nodes/inputs/ColorNode.js
examples/js/nodes/inputs/ColorNode.js
+4
-4
examples/js/nodes/inputs/CubeTextureNode.js
examples/js/nodes/inputs/CubeTextureNode.js
+13
-5
examples/js/nodes/inputs/FloatNode.js
examples/js/nodes/inputs/FloatNode.js
+4
-4
examples/js/nodes/inputs/IntNode.js
examples/js/nodes/inputs/IntNode.js
+4
-4
examples/js/nodes/inputs/Matrix3Node.js
examples/js/nodes/inputs/Matrix3Node.js
+8
-8
examples/js/nodes/inputs/Matrix4Node.js
examples/js/nodes/inputs/Matrix4Node.js
+8
-8
examples/js/nodes/inputs/PropertyNode.js
examples/js/nodes/inputs/PropertyNode.js
+9
-9
examples/js/nodes/inputs/RTTNode.js
examples/js/nodes/inputs/RTTNode.js
+143
-0
examples/js/nodes/inputs/ReflectorNode.js
examples/js/nodes/inputs/ReflectorNode.js
+4
-4
examples/js/nodes/inputs/ScreenNode.js
examples/js/nodes/inputs/ScreenNode.js
+1
-1
examples/js/nodes/inputs/TextureNode.js
examples/js/nodes/inputs/TextureNode.js
+13
-6
examples/js/nodes/inputs/Vector2Node.js
examples/js/nodes/inputs/Vector2Node.js
+3
-3
examples/js/nodes/inputs/Vector3Node.js
examples/js/nodes/inputs/Vector3Node.js
+4
-4
examples/js/nodes/inputs/Vector4Node.js
examples/js/nodes/inputs/Vector4Node.js
+3
-3
examples/js/nodes/materials/MeshStandardNodeMaterial.js
examples/js/nodes/materials/MeshStandardNodeMaterial.js
+1
-1
examples/js/nodes/materials/NodeMaterial.js
examples/js/nodes/materials/NodeMaterial.js
+26
-30
examples/js/nodes/materials/PhongNodeMaterial.js
examples/js/nodes/materials/PhongNodeMaterial.js
+14
-14
examples/js/nodes/materials/SpriteNodeMaterial.js
examples/js/nodes/materials/SpriteNodeMaterial.js
+6
-6
examples/js/nodes/materials/StandardNodeMaterial.js
examples/js/nodes/materials/StandardNodeMaterial.js
+17
-17
examples/js/nodes/materials/nodes/MeshStandardNode.js
examples/js/nodes/materials/nodes/MeshStandardNode.js
+25
-21
examples/js/nodes/materials/nodes/PhongNode.js
examples/js/nodes/materials/nodes/PhongNode.js
+36
-34
examples/js/nodes/materials/nodes/RawNode.js
examples/js/nodes/materials/nodes/RawNode.js
+8
-8
examples/js/nodes/materials/nodes/SpriteNode.js
examples/js/nodes/materials/nodes/SpriteNode.js
+59
-35
examples/js/nodes/materials/nodes/StandardNode.js
examples/js/nodes/materials/nodes/StandardNode.js
+34
-34
examples/js/nodes/math/CondNode.js
examples/js/nodes/math/CondNode.js
+107
-0
examples/js/nodes/math/Math1Node.js
examples/js/nodes/math/Math1Node.js
+12
-12
examples/js/nodes/math/Math2Node.js
examples/js/nodes/math/Math2Node.js
+19
-19
examples/js/nodes/math/Math3Node.js
examples/js/nodes/math/Math3Node.js
+16
-16
examples/js/nodes/math/OperatorNode.js
examples/js/nodes/math/OperatorNode.js
+7
-7
examples/js/nodes/misc/BumpMapNode.js
examples/js/nodes/misc/BumpMapNode.js
+32
-32
examples/js/nodes/misc/NormalMapNode.js
examples/js/nodes/misc/NormalMapNode.js
+15
-15
examples/js/nodes/misc/TextureCubeNode.js
examples/js/nodes/misc/TextureCubeNode.js
+4
-4
examples/js/nodes/misc/TextureCubeUVNode.js
examples/js/nodes/misc/TextureCubeUVNode.js
+26
-26
examples/js/nodes/postprocessing/NodePass.js
examples/js/nodes/postprocessing/NodePass.js
+11
-15
examples/js/nodes/postprocessing/NodePostProcessing.js
examples/js/nodes/postprocessing/NodePostProcessing.js
+128
-0
examples/js/nodes/procedural/CheckerNode.js
examples/js/nodes/procedural/CheckerNode.js
+75
-0
examples/js/nodes/procedural/NoiseNode.js
examples/js/nodes/procedural/NoiseNode.js
+11
-11
examples/js/nodes/utils/BypassNode.js
examples/js/nodes/utils/BypassNode.js
+23
-23
examples/js/nodes/utils/ColorSpaceNode.js
examples/js/nodes/utils/ColorSpaceNode.js
+297
-0
examples/js/nodes/utils/JoinNode.js
examples/js/nodes/utils/JoinNode.js
+7
-7
examples/js/nodes/utils/MaxMIPLevelNode.js
examples/js/nodes/utils/MaxMIPLevelNode.js
+7
-7
examples/js/nodes/utils/SwitchNode.js
examples/js/nodes/utils/SwitchNode.js
+9
-9
examples/js/nodes/utils/TimerNode.js
examples/js/nodes/utils/TimerNode.js
+15
-12
examples/js/nodes/utils/UVTransformNode.js
examples/js/nodes/utils/UVTransformNode.js
+17
-17
examples/js/nodes/utils/VelocityNode.js
examples/js/nodes/utils/VelocityNode.js
+7
-7
examples/nodes/displace.json
examples/nodes/displace.json
+1
-1
examples/nodes/wave.json
examples/nodes/wave.json
+1
-1
examples/webgl_loader_nodes.html
examples/webgl_loader_nodes.html
+106
-106
examples/webgl_materials_compile.html
examples/webgl_materials_compile.html
+2
-2
examples/webgl_materials_nodes.html
examples/webgl_materials_nodes.html
+1880
-1643
examples/webgl_mirror_nodes.html
examples/webgl_mirror_nodes.html
+206
-207
examples/webgl_performance_nodes.html
examples/webgl_performance_nodes.html
+269
-0
examples/webgl_postprocessing_nodes.html
examples/webgl_postprocessing_nodes.html
+64
-52
examples/webgl_postprocessing_nodes_pass.html
examples/webgl_postprocessing_nodes_pass.html
+560
-0
examples/webgl_sprites_nodes.html
examples/webgl_sprites_nodes.html
+179
-182
未找到文件。
examples/files.js
浏览文件 @
9b26302c
...
...
@@ -209,6 +209,7 @@ var files = {
"
webgl_panorama_equirectangular
"
,
"
webgl_performance
"
,
"
webgl_performance_doublesided
"
,
"
webgl_performance_nodes
"
,
"
webgl_performance_static
"
,
"
webgl_physics_cloth
"
,
"
webgl_physics_convex_break
"
,
...
...
@@ -232,6 +233,7 @@ var files = {
"
webgl_postprocessing_ssaa
"
,
"
webgl_postprocessing_ssaa_unbiased
"
,
"
webgl_postprocessing_nodes
"
,
"
webgl_postprocessing_nodes_pass
"
,
"
webgl_postprocessing_outline
"
,
"
webgl_postprocessing_pixel
"
,
"
webgl_postprocessing_procedural
"
,
...
...
examples/js/nodes/Nodes.js
浏览文件 @
9b26302c
...
...
@@ -2,7 +2,7 @@
// core
export
{
GLNode
}
from
'
./core/GL
Node.js
'
;
export
{
Node
}
from
'
./core/
Node.js
'
;
export
{
TempNode
}
from
'
./core/TempNode.js
'
;
export
{
InputNode
}
from
'
./core/InputNode.js
'
;
export
{
ConstNode
}
from
'
./core/ConstNode.js
'
;
...
...
@@ -10,6 +10,7 @@ export { VarNode } from './core/VarNode.js';
export
{
StructNode
}
from
'
./core/StructNode.js
'
;
export
{
AttributeNode
}
from
'
./core/AttributeNode.js
'
;
export
{
FunctionNode
}
from
'
./core/FunctionNode.js
'
;
export
{
ExpressionNode
}
from
'
./core/ExpressionNode.js
'
;
export
{
FunctionCallNode
}
from
'
./core/FunctionCallNode.js
'
;
export
{
NodeLib
}
from
'
./core/NodeLib.js
'
;
export
{
NodeUtils
}
from
'
./core/NodeUtils.js
'
;
...
...
@@ -32,6 +33,7 @@ export { CubeTextureNode } from './inputs/CubeTextureNode.js';
export
{
ScreenNode
}
from
'
./inputs/ScreenNode.js
'
;
export
{
ReflectorNode
}
from
'
./inputs/ReflectorNode.js
'
;
export
{
PropertyNode
}
from
'
./inputs/PropertyNode.js
'
;
export
{
RTTNode
}
from
'
./inputs/RTTNode.js
'
;
// accessors
...
...
@@ -51,10 +53,12 @@ export { Math1Node } from './math/Math1Node.js';
export
{
Math2Node
}
from
'
./math/Math2Node.js
'
;
export
{
Math3Node
}
from
'
./math/Math3Node.js
'
;
export
{
OperatorNode
}
from
'
./math/OperatorNode.js
'
;
export
{
CondNode
}
from
'
./math/CondNode.js
'
;
// procedural
export
{
NoiseNode
}
from
'
./procedural/NoiseNode.js
'
;
export
{
CheckerNode
}
from
'
./procedural/CheckerNode.js
'
;
// bsdfs
...
...
@@ -78,6 +82,7 @@ export { TimerNode } from './utils/TimerNode.js';
export
{
VelocityNode
}
from
'
./utils/VelocityNode.js
'
;
export
{
UVTransformNode
}
from
'
./utils/UVTransformNode.js
'
;
export
{
MaxMIPLevelNode
}
from
'
./utils/MaxMIPLevelNode.js
'
;
export
{
ColorSpaceNode
}
from
'
./utils/ColorSpaceNode.js
'
;
// effects
...
...
@@ -103,4 +108,5 @@ export { MeshStandardNodeMaterial } from './materials/MeshStandardNodeMaterial.j
// postprocessing
export
{
NodePostProcessing
}
from
'
./postprocessing/NodePostProcessing.js
'
;
//export { NodePass } from './postprocessing/NodePass.js';
examples/js/nodes/THREE.Nodes.js
浏览文件 @
9b26302c
import
{
import
{
// core
GL
Node
,
Node
,
TempNode
,
InputNode
,
ConstNode
,
...
...
@@ -10,15 +10,16 @@ import {
StructNode
,
AttributeNode
,
FunctionNode
,
ExpressionNode
,
FunctionCallNode
,
NodeLib
,
NodeUtils
,
NodeFrame
,
NodeUniform
,
NodeBuilder
,
// inputs
IntNode
,
FloatNode
,
Vector2Node
,
...
...
@@ -32,9 +33,10 @@ import {
ScreenNode
,
ReflectorNode
,
PropertyNode
,
RTTNode
,
// accessors
UVNode
,
ColorsNode
,
PositionNode
,
...
...
@@ -44,33 +46,35 @@ import {
ReflectNode
,
ScreenUVNode
,
ResolutionNode
,
// math
Math1Node
,
Math2Node
,
Math3Node
,
OperatorNode
,
CondNode
,
// procedural
NoiseNode
,
CheckerNode
,
// bsdfs
BlinnShininessExponentNode
,
BlinnExponentToRoughnessNode
,
RoughnessToBlinnExponentNode
,
// misc
TextureCubeUVNode
,
TextureCubeNode
,
NormalMapNode
,
BumpMapNode
,
// utils
BypassNode
,
JoinNode
,
SwitchNode
,
...
...
@@ -78,34 +82,39 @@ import {
VelocityNode
,
UVTransformNode
,
MaxMIPLevelNode
,
ColorSpaceNode
,
// effects
BlurNode
,
ColorAdjustmentNode
,
LuminanceNode
,
// material nodes
RawNode
,
SpriteNode
,
PhongNode
,
StandardNode
,
MeshStandardNode
,
// materials
NodeMaterial
,
SpriteNodeMaterial
,
PhongNodeMaterial
,
StandardNodeMaterial
,
MeshStandardNodeMaterial
MeshStandardNodeMaterial
,
// post-processing
NodePostProcessing
}
from
'
./Nodes.js
'
;
// core
THREE
.
GLNode
=
GL
Node
;
THREE
.
Node
=
Node
;
THREE
.
TempNode
=
TempNode
;
THREE
.
InputNode
=
InputNode
;
THREE
.
ConstNode
=
ConstNode
;
...
...
@@ -113,6 +122,7 @@ THREE.VarNode = VarNode;
THREE
.
StructNode
=
StructNode
;
THREE
.
AttributeNode
=
AttributeNode
;
THREE
.
FunctionNode
=
FunctionNode
;
THREE
.
ExpressionNode
=
ExpressionNode
;
THREE
.
FunctionCallNode
=
FunctionCallNode
;
THREE
.
NodeLib
=
NodeLib
;
THREE
.
NodeUtils
=
NodeUtils
;
...
...
@@ -135,6 +145,7 @@ THREE.CubeTextureNode = CubeTextureNode;
THREE
.
ScreenNode
=
ScreenNode
;
THREE
.
ReflectorNode
=
ReflectorNode
;
THREE
.
PropertyNode
=
PropertyNode
;
THREE
.
RTTNode
=
RTTNode
;
// accessors
...
...
@@ -154,10 +165,12 @@ THREE.Math1Node = Math1Node;
THREE
.
Math2Node
=
Math2Node
;
THREE
.
Math3Node
=
Math3Node
;
THREE
.
OperatorNode
=
OperatorNode
;
THREE
.
CondNode
=
CondNode
;
// procedural
THREE
.
NoiseNode
=
NoiseNode
;
THREE
.
CheckerNode
=
CheckerNode
;
// bsdfs
...
...
@@ -181,6 +194,7 @@ THREE.TimerNode = TimerNode;
THREE
.
VelocityNode
=
VelocityNode
;
THREE
.
UVTransformNode
=
UVTransformNode
;
THREE
.
MaxMIPLevelNode
=
MaxMIPLevelNode
;
THREE
.
ColorSpaceNode
=
ColorSpaceNode
;
// effects
...
...
@@ -203,3 +217,7 @@ THREE.SpriteNodeMaterial = SpriteNodeMaterial;
THREE
.
PhongNodeMaterial
=
PhongNodeMaterial
;
THREE
.
StandardNodeMaterial
=
StandardNodeMaterial
;
THREE
.
MeshStandardNodeMaterial
=
MeshStandardNodeMaterial
;
// post-processing
THREE
.
NodePostProcessing
=
NodePostProcessing
;
examples/js/nodes/accessors/CameraNode.js
浏览文件 @
9b26302c
...
...
@@ -6,7 +6,7 @@ import { TempNode } from '../core/TempNode.js';
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
FloatNode
}
from
'
../inputs/FloatNode.js
'
;
import
{
PositionNode
}
from
'
../accessors/PositionNode.js
'
;
function
CameraNode
(
scope
,
camera
)
{
TempNode
.
call
(
this
,
'
v3
'
);
...
...
@@ -14,33 +14,33 @@ function CameraNode( scope, camera ) {
this
.
setScope
(
scope
||
CameraNode
.
POSITION
);
this
.
setCamera
(
camera
);
};
}
CameraNode
.
Nodes
=
(
function
()
{
CameraNode
.
Nodes
=
(
function
()
{
var
depthColor
=
new
FunctionNode
(
[
"
float depthColor( float mNear, float mFar ) {
"
,
"
#ifdef USE_LOGDEPTHBUF_EXT
"
,
"
float depth = gl_FragDepthEXT / gl_FragCoord.w;
"
,
"
#else
"
,
"
float depth = gl_FragCoord.z / gl_FragCoord.w;
"
,
"
#endif
"
,
"
return 1.0 - smoothstep( mNear, mFar, depth );
"
,
"
}
"
].
join
(
"
\n
"
)
);
return
{
depthColor
:
depthColor
};
})();
}
)();
CameraNode
.
POSITION
=
'
position
'
;
CameraNode
.
DEPTH
=
'
depth
'
;
...
...
@@ -92,7 +92,7 @@ CameraNode.prototype.getType = function ( builder ) {
switch
(
this
.
scope
)
{
case
CameraNode
.
DEPTH
:
return
'
f
'
;
}
...
...
@@ -107,7 +107,7 @@ CameraNode.prototype.isUnique = function ( builder ) {
case
CameraNode
.
DEPTH
:
case
CameraNode
.
TO_VERTEX
:
return
true
;
}
...
...
@@ -121,7 +121,7 @@ CameraNode.prototype.isShared = function ( builder ) {
switch
(
this
.
scope
)
{
case
CameraNode
.
POSITION
:
return
false
;
}
...
...
@@ -180,15 +180,15 @@ CameraNode.prototype.onUpdateFrame = function ( frame ) {
};
CameraNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
setScope
(
source
.
scope
);
if
(
source
.
camera
)
{
this
.
setCamera
(
source
.
camera
);
}
switch
(
source
.
scope
)
{
...
...
@@ -201,7 +201,7 @@ CameraNode.prototype.copy = function ( source ) {
break
;
}
};
CameraNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/ColorsNode.js
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
NodeLib
}
from
'
../core/NodeLib.js
'
;
var
vertexDict
=
[
'
color
'
,
'
color2
'
],
fragmentDict
=
[
'
vColor
'
,
'
vColor2
'
];
function
ColorsNode
(
index
)
{
TempNode
.
call
(
this
,
'
v4
'
,
{
shared
:
false
}
);
this
.
index
=
index
||
0
;
}
;
}
ColorsNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ColorsNode
.
prototype
.
constructor
=
ColorsNode
;
...
...
@@ -30,11 +29,11 @@ ColorsNode.prototype.generate = function ( builder, output ) {
};
ColorsNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
index
=
source
.
index
;
};
ColorsNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/LightNode.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function LightNode( scope ) {
this
.
scope
=
scope
||
LightNode
.
TOTAL
;
}
;
}
LightNode
.
TOTAL
=
'
total
'
;
...
...
@@ -22,24 +22,24 @@ LightNode.prototype.generate = function ( builder, output ) {
if
(
builder
.
isCache
(
'
light
'
)
)
{
return
builder
.
format
(
'
reflectedLight.directDiffuse
'
,
this
.
getType
(
builder
)
,
output
);
return
builder
.
format
(
'
reflectedLight.directDiffuse
'
,
this
.
type
,
output
);
}
else
{
console
.
warn
(
"
THREE.LightNode is only compatible in
\"
light
\"
channel.
"
);
return
builder
.
format
(
'
vec3( 0.0 )
'
,
this
.
getType
(
builder
)
,
output
);
return
builder
.
format
(
'
vec3( 0.0 )
'
,
this
.
type
,
output
);
}
};
LightNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
scope
=
source
.
scope
;
};
LightNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/NormalNode.js
浏览文件 @
9b26302c
...
...
@@ -4,14 +4,14 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
NodeLib
}
from
'
../core/NodeLib.js
'
;
function
NormalNode
(
scope
)
{
TempNode
.
call
(
this
,
'
v3
'
);
this
.
scope
=
scope
||
NormalNode
.
LOCAL
;
}
;
}
NormalNode
.
LOCAL
=
'
local
'
;
NormalNode
.
WORLD
=
'
world
'
;
...
...
@@ -45,7 +45,7 @@ NormalNode.prototype.generate = function ( builder, output ) {
builder
.
requires
.
normal
=
true
;
result
=
builder
.
isShader
(
'
vertex
'
)
?
'
normal
'
:
'
vObjectN
ormal
'
;
result
=
'
n
ormal
'
;
break
;
...
...
@@ -54,7 +54,7 @@ NormalNode.prototype.generate = function ( builder, output ) {
builder
.
requires
.
worldNormal
=
true
;
result
=
builder
.
isShader
(
'
vertex
'
)
?
'
( modelMatrix * vec4( objectNormal, 0.0 ) ).xyz
'
:
'
vWNormal
'
;
break
;
case
NormalNode
.
VIEW
:
...
...
@@ -70,11 +70,11 @@ NormalNode.prototype.generate = function ( builder, output ) {
};
NormalNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
scope
=
source
.
scope
;
};
NormalNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/PositionNode.js
浏览文件 @
9b26302c
...
...
@@ -4,14 +4,14 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
NodeLib
}
from
'
../core/NodeLib.js
'
;
function
PositionNode
(
scope
)
{
TempNode
.
call
(
this
,
'
v3
'
);
this
.
scope
=
scope
||
PositionNode
.
LOCAL
;
}
;
}
PositionNode
.
LOCAL
=
'
local
'
;
PositionNode
.
WORLD
=
'
world
'
;
...
...
@@ -22,12 +22,12 @@ PositionNode.prototype = Object.create( TempNode.prototype );
PositionNode
.
prototype
.
constructor
=
PositionNode
;
PositionNode
.
prototype
.
nodeType
=
"
Position
"
;
PositionNode
.
prototype
.
getType
=
function
(
builder
)
{
PositionNode
.
prototype
.
getType
=
function
(
)
{
switch
(
this
.
scope
)
{
case
PositionNode
.
PROJECTION
:
return
'
v4
'
;
}
...
...
@@ -42,7 +42,7 @@ PositionNode.prototype.isShared = function ( builder ) {
case
PositionNode
.
LOCAL
:
case
PositionNode
.
WORLD
:
return
false
;
}
...
...
@@ -92,11 +92,11 @@ PositionNode.prototype.generate = function ( builder, output ) {
};
PositionNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
scope
=
source
.
scope
;
};
PositionNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/ReflectNode.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function ReflectNode( scope ) {
this
.
scope
=
scope
||
ReflectNode
.
CUBE
;
}
;
}
ReflectNode
.
CUBE
=
'
cube
'
;
ReflectNode
.
SPHERE
=
'
sphere
'
;
...
...
@@ -37,7 +37,7 @@ ReflectNode.prototype.getType = function ( builder ) {
ReflectNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
var
result
;
switch
(
this
.
scope
)
{
...
...
@@ -72,14 +72,14 @@ ReflectNode.prototype.generate = function ( builder, output ) {
}
return
builder
.
format
(
result
,
this
.
getType
(
this
.
type
),
output
);
return
builder
.
format
(
result
,
this
.
getType
(
builder
),
output
);
}
else
{
console
.
warn
(
"
THREE.ReflectNode is not compatible with
"
+
builder
.
shader
+
"
shader.
"
);
return
builder
.
format
(
'
vec3( 0.0 )
'
,
this
.
type
,
output
);
}
};
...
...
examples/js/nodes/accessors/ResolutionNode.js
浏览文件 @
9b26302c
...
...
@@ -3,14 +3,12 @@
*/
import
{
Vector2Node
}
from
'
../inputs/Vector2Node.js
'
;
function
ResolutionNode
(
renderer
)
{
Vector2Node
.
call
(
this
);
function
ResolutionNode
()
{
this
.
renderer
=
renderer
;
Vector2Node
.
call
(
this
)
;
}
;
}
ResolutionNode
.
prototype
=
Object
.
create
(
Vector2Node
.
prototype
);
ResolutionNode
.
prototype
.
constructor
=
ResolutionNode
;
...
...
@@ -18,20 +16,28 @@ ResolutionNode.prototype.nodeType = "Resolution";
ResolutionNode
.
prototype
.
updateFrame
=
function
(
frame
)
{
var
size
=
this
.
renderer
.
getSize
(),
pixelRatio
=
this
.
renderer
.
getPixelRatio
();
if
(
frame
.
renderer
)
{
var
size
=
frame
.
renderer
.
getSize
(),
pixelRatio
=
frame
.
renderer
.
getPixelRatio
();
this
.
x
=
size
.
width
*
pixelRatio
;
this
.
y
=
size
.
height
*
pixelRatio
;
}
else
{
this
.
x
=
size
.
width
*
pixelRatio
;
this
.
y
=
size
.
height
*
pixelRatio
;
console
.
warn
(
"
ResolutionNode need a renderer in NodeFrame
"
);
}
};
ResolutionNode
.
prototype
.
copy
=
function
(
source
)
{
Vector2Node
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
renderer
=
source
.
renderer
;
};
ResolutionNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/ScreenUVNode.js
浏览文件 @
9b26302c
...
...
@@ -3,14 +3,15 @@
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
ResolutionNode
}
from
'
./ResolutionNode.js
'
;
function
ScreenUVNode
(
resolution
)
{
TempNode
.
call
(
this
,
'
v2
'
);
this
.
resolution
=
resolution
;
this
.
resolution
=
resolution
||
new
ResolutionNode
()
;
}
;
}
ScreenUVNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ScreenUVNode
.
prototype
.
constructor
=
ScreenUVNode
;
...
...
@@ -37,11 +38,11 @@ ScreenUVNode.prototype.generate = function ( builder, output ) {
};
ScreenUVNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
resolution
=
source
.
resolution
;
};
ScreenUVNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/accessors/UVNode.js
浏览文件 @
9b26302c
...
...
@@ -4,17 +4,17 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
NodeLib
}
from
'
../core/NodeLib.js
'
;
var
vertexDict
=
[
'
uv
'
,
'
uv2
'
],
fragmentDict
=
[
'
vUv
'
,
'
vUv2
'
];
function
UVNode
(
index
)
{
TempNode
.
call
(
this
,
'
v2
'
,
{
shared
:
false
}
);
this
.
index
=
index
||
0
;
}
;
}
UVNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
UVNode
.
prototype
.
constructor
=
UVNode
;
...
...
@@ -31,11 +31,11 @@ UVNode.prototype.generate = function ( builder, output ) {
};
UVNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
index
=
source
.
index
;
};
UVNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/bsdfs/BlinnExponentToRoughnessNode.js
浏览文件 @
9b26302c
...
...
@@ -11,7 +11,7 @@ function BlinnExponentToRoughnessNode( blinnExponent ) {
this
.
blinnExponent
=
blinnExponent
||
new
BlinnShininessExponentNode
();
}
;
}
BlinnExponentToRoughnessNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
BlinnExponentToRoughnessNode
.
prototype
.
constructor
=
BlinnExponentToRoughnessNode
;
...
...
@@ -24,11 +24,11 @@ BlinnExponentToRoughnessNode.prototype.generate = function ( builder, output ) {
};
BlinnExponentToRoughnessNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
blinnExponent
=
source
.
blinnExponent
;
};
BlinnExponentToRoughnessNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/bsdfs/BlinnShininessExponentNode.js
浏览文件 @
9b26302c
...
...
@@ -8,7 +8,7 @@ function BlinnShininessExponentNode() {
TempNode
.
call
(
this
,
'
f
'
);
}
;
}
BlinnShininessExponentNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
BlinnShininessExponentNode
.
prototype
.
constructor
=
BlinnShininessExponentNode
;
...
...
examples/js/nodes/bsdfs/RoughnessToBlinnExponentNode.js
浏览文件 @
9b26302c
...
...
@@ -6,7 +6,7 @@ import { TempNode } from '../core/TempNode.js';
import
{
FunctionNode
}
from
'
../core/FunctionNode.js
'
;
import
{
MaxMIPLevelNode
}
from
'
../utils/MaxMIPLevelNode.js
'
;
import
{
BlinnShininessExponentNode
}
from
'
./BlinnShininessExponentNode.js
'
;
function
RoughnessToBlinnExponentNode
(
texture
)
{
TempNode
.
call
(
this
,
'
f
'
);
...
...
@@ -16,9 +16,9 @@ function RoughnessToBlinnExponentNode( texture ) {
this
.
maxMIPLevel
=
new
MaxMIPLevelNode
(
texture
);
this
.
blinnShininessExponent
=
new
BlinnShininessExponentNode
();
}
;
}
RoughnessToBlinnExponentNode
.
Nodes
=
(
function
()
{
RoughnessToBlinnExponentNode
.
Nodes
=
(
function
()
{
var
getSpecularMIPLevel
=
new
FunctionNode
(
[
// taken from here: http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html
...
...
@@ -27,18 +27,19 @@ RoughnessToBlinnExponentNode.Nodes = (function() {
// float envMapWidth = pow( 2.0, maxMIPLevelScalar );
// float desiredMIPLevel = log2( envMapWidth * sqrt( 3.0 ) ) - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );
"
float desiredMIPLevel = maxMIPLevelScalar
-
0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );
"
,
"
float desiredMIPLevel = maxMIPLevelScalar
+
0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );
"
,
// clamp to allowable LOD ranges.
"
return clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );
"
,
"
}
"
].
join
(
"
\n
"
)
);
return
{
getSpecularMIPLevel
:
getSpecularMIPLevel
};
})();
}
)();
RoughnessToBlinnExponentNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
RoughnessToBlinnExponentNode
.
prototype
.
constructor
=
RoughnessToBlinnExponentNode
;
...
...
@@ -49,7 +50,7 @@ RoughnessToBlinnExponentNode.prototype.generate = function ( builder, output ) {
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
this
.
maxMIPLevel
.
texture
=
this
.
texture
;
var
getSpecularMIPLevel
=
builder
.
include
(
RoughnessToBlinnExponentNode
.
Nodes
.
getSpecularMIPLevel
);
return
builder
.
format
(
getSpecularMIPLevel
+
'
(
'
+
this
.
blinnShininessExponent
.
build
(
builder
,
'
f
'
)
+
'
,
'
+
this
.
maxMIPLevel
.
build
(
builder
,
'
f
'
)
+
'
)
'
,
this
.
type
,
output
);
...
...
@@ -65,11 +66,11 @@ RoughnessToBlinnExponentNode.prototype.generate = function ( builder, output ) {
};
RoughnessToBlinnExponentNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
texture
=
source
.
texture
;
};
RoughnessToBlinnExponentNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/core/AttributeNode.js
浏览文件 @
9b26302c
...
...
@@ -2,17 +2,17 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
./GL
Node.js
'
;
import
{
Node
}
from
'
./
Node.js
'
;
function
AttributeNode
(
name
,
type
)
{
GL
Node
.
call
(
this
,
type
);
Node
.
call
(
this
,
type
);
this
.
name
=
name
;
}
;
}
AttributeNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
AttributeNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
AttributeNode
.
prototype
.
constructor
=
AttributeNode
;
AttributeNode
.
prototype
.
nodeType
=
"
Attribute
"
;
...
...
@@ -38,17 +38,17 @@ AttributeNode.prototype.generate = function ( builder, output ) {
name
=
builder
.
isShader
(
'
vertex
'
)
?
this
.
name
:
attribute
.
varying
.
name
;
console
.
log
(
attribute
);
return
builder
.
format
(
name
,
this
.
getType
(
builder
),
output
);
};
AttributeNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
type
=
source
.
type
;
};
AttributeNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/core/ConstNode.js
浏览文件 @
9b26302c
...
...
@@ -4,13 +4,15 @@
import
{
TempNode
}
from
'
./TempNode.js
'
;
var
declarationRegexp
=
/^
([
a-z_0-9
]
+
)\s([
a-z_0-9
]
+
)\s?\=?\s?(
.*
?)(\;
|$
)
/i
;
function
ConstNode
(
src
,
useDefine
)
{
TempNode
.
call
(
this
);
this
.
eval
(
src
||
ConstNode
.
PI
,
useDefine
);
}
;
}
ConstNode
.
PI
=
'
PI
'
;
ConstNode
.
PI2
=
'
PI2
'
;
...
...
@@ -19,8 +21,6 @@ ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2';
ConstNode
.
LOG2
=
'
LOG2
'
;
ConstNode
.
EPSILON
=
'
EPSILON
'
;
ConstNode
.
rDeclaration
=
/^
([
a-z_0-9
]
+
)\s([
a-z_0-9
]
+
)\s?\=?\s?(
.*
?)(\;
|$
)
/i
;
ConstNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ConstNode
.
prototype
.
constructor
=
ConstNode
;
ConstNode
.
prototype
.
nodeType
=
"
Const
"
;
...
...
@@ -37,9 +37,9 @@ ConstNode.prototype.eval = function ( src, useDefine ) {
var
name
,
type
,
value
=
""
;
var
match
=
this
.
src
.
match
(
ConstNode
.
rDeclaration
);
var
match
=
this
.
src
.
match
(
declarationRegexp
);
this
.
useDefine
=
useDefine
||
this
.
src
.
charAt
(
0
)
===
'
#
'
;
this
.
useDefine
=
useDefine
||
this
.
src
.
charAt
(
0
)
===
'
#
'
;
if
(
match
&&
match
.
length
>
1
)
{
...
...
@@ -74,10 +74,10 @@ ConstNode.prototype.build = function ( builder, output ) {
return
'
const
'
+
this
.
type
+
'
'
+
this
.
name
+
'
=
'
+
this
.
value
+
'
;
'
;
}
else
if
(
this
.
useDefine
)
{
}
else
if
(
this
.
useDefine
)
{
return
this
.
src
;
}
}
else
{
...
...
@@ -97,11 +97,11 @@ ConstNode.prototype.generate = function ( builder, output ) {
};
ConstNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
eval
(
source
.
src
,
source
.
useDefine
);
this
.
eval
(
source
.
src
,
source
.
useDefine
);
};
ConstNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/core/ExpressionNode.js
0 → 100644
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
FunctionNode
}
from
'
./FunctionNode.js
'
;
function
ExpressionNode
(
src
,
type
,
keywords
,
extensions
,
includes
)
{
FunctionNode
.
call
(
this
,
src
,
includes
,
extensions
,
keywords
,
type
);
}
ExpressionNode
.
prototype
=
Object
.
create
(
FunctionNode
.
prototype
);
ExpressionNode
.
prototype
.
constructor
=
ExpressionNode
;
ExpressionNode
.
prototype
.
nodeType
=
"
Expression
"
;
export
{
ExpressionNode
};
examples/js/nodes/core/FunctionCallNode.js
浏览文件 @
9b26302c
...
...
@@ -3,14 +3,14 @@
*/
import
{
TempNode
}
from
'
./TempNode.js
'
;
function
FunctionCallNode
(
func
,
inputs
)
{
TempNode
.
call
(
this
);
this
.
setFunction
(
func
,
inputs
);
}
;
}
FunctionCallNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
FunctionCallNode
.
prototype
.
constructor
=
FunctionCallNode
;
...
...
@@ -59,9 +59,9 @@ FunctionCallNode.prototype.generate = function ( builder, output ) {
};
FunctionCallNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
for
(
var
prop
in
source
.
inputs
)
{
this
.
inputs
[
prop
]
=
source
.
inputs
[
prop
];
...
...
@@ -69,7 +69,7 @@ FunctionCallNode.prototype.copy = function ( source ) {
}
this
.
value
=
source
.
value
;
};
FunctionCallNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/core/FunctionNode.js
浏览文件 @
9b26302c
...
...
@@ -6,32 +6,25 @@
import
{
TempNode
}
from
'
./TempNode.js
'
;
import
{
NodeLib
}
from
'
./NodeLib.js
'
;
function
FunctionNode
(
src
,
includesOrType
,
extensionsOrKeywords
,
keywordsOrExtensions
,
includes
)
{
var
declarationRegexp
=
/^
([
a-z_0-9
]
+
)\s([
a-z_0-9
]
+
)\s
*
\((
.*
?)\)
/i
,
propertiesRegexp
=
/
[
a-z_0-9
]
+/ig
;
this
.
isMethod
=
typeof
includesOrType
!==
"
string
"
;
this
.
useKeywords
=
true
;
function
FunctionNode
(
src
,
includes
,
extensions
,
keywords
,
type
)
{
TempNode
.
call
(
this
,
this
.
isMethod
?
null
:
includesOrType
)
;
this
.
isMethod
=
type
===
undefined
;
if
(
this
.
isMethod
)
{
this
.
eval
(
src
,
includesOrType
,
extensionsOrKeywords
,
keywordsOrExtensions
);
}
else
{
this
.
eval
(
src
,
includes
,
keywordsOrExtensions
,
extensionsOrKeywords
);
}
TempNode
.
call
(
this
,
type
);
}
;
this
.
eval
(
src
,
includes
,
extensions
,
keywords
)
;
FunctionNode
.
rDeclaration
=
/^
([
a-z_0-9
]
+
)\s([
a-z_0-9
]
+
)\s
*
\((
.*
?)\)
/i
;
FunctionNode
.
rProperties
=
/
[
a-z_0-9
]
+/ig
;
}
FunctionNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
FunctionNode
.
prototype
.
constructor
=
FunctionNode
;
FunctionNode
.
prototype
.
nodeType
=
"
Function
"
;
FunctionNode
.
prototype
.
useKeywords
=
true
;
FunctionNode
.
prototype
.
isShared
=
function
(
builder
,
output
)
{
return
!
this
.
isMethod
;
...
...
@@ -50,9 +43,12 @@ FunctionNode.prototype.getInputByName = function ( name ) {
while
(
i
--
)
{
if
(
this
.
inputs
[
i
].
name
===
name
)
if
(
this
.
inputs
[
i
].
name
===
name
)
{
return
this
.
inputs
[
i
];
}
}
};
...
...
@@ -63,9 +59,12 @@ FunctionNode.prototype.getIncludeByName = function ( name ) {
while
(
i
--
)
{
if
(
this
.
includes
[
i
].
name
===
name
)
if
(
this
.
includes
[
i
].
name
===
name
)
{
return
this
.
includes
[
i
];
}
}
};
...
...
@@ -86,9 +85,9 @@ FunctionNode.prototype.generate = function ( builder, output ) {
}
while
(
match
=
FunctionNode
.
rProperties
.
exec
(
this
.
src
)
)
{
while
(
match
=
propertiesRegexp
.
exec
(
this
.
src
)
)
{
var
prop
=
match
[
0
],
var
prop
=
match
[
0
],
isGlobal
=
this
.
isMethod
?
!
this
.
getInputByName
(
prop
)
:
true
,
reference
=
prop
;
...
...
@@ -156,7 +155,7 @@ FunctionNode.prototype.eval = function ( src, includes, extensions, keywords ) {
if
(
this
.
isMethod
)
{
var
match
=
this
.
src
.
match
(
FunctionNode
.
rDeclaration
);
var
match
=
this
.
src
.
match
(
declarationRegexp
);
this
.
inputs
=
[];
...
...
@@ -165,7 +164,7 @@ FunctionNode.prototype.eval = function ( src, includes, extensions, keywords ) {
this
.
type
=
match
[
1
];
this
.
name
=
match
[
2
];
var
inputs
=
match
[
3
].
match
(
FunctionNode
.
rProperties
);
var
inputs
=
match
[
3
].
match
(
propertiesRegexp
);
if
(
inputs
)
{
...
...
@@ -211,16 +210,16 @@ FunctionNode.prototype.eval = function ( src, includes, extensions, keywords ) {
};
FunctionNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
isMethod
=
source
.
isMethod
;
this
.
useKeywords
=
source
.
useKeywords
;
this
.
eval
(
source
.
src
,
source
.
includes
,
source
.
extensions
,
source
.
keywords
);
if
(
source
.
type
!==
undefined
)
this
.
type
=
source
.
type
;
};
FunctionNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/core/InputNode.js
浏览文件 @
9b26302c
...
...
@@ -13,7 +13,7 @@ function InputNode( type, params ) {
this
.
readonly
=
false
;
}
;
}
InputNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
InputNode
.
prototype
.
constructor
=
InputNode
;
...
...
@@ -25,17 +25,17 @@ InputNode.prototype.isReadonly = function ( builder ) {
};
InputNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
if
(
source
.
readonly
!==
undefined
)
this
.
readonly
=
source
.
readonly
;
};
InputNode
.
prototype
.
createJSONNode
=
function
(
meta
)
{
var
data
=
TempNode
.
prototype
.
createJSONNode
.
call
(
this
,
meta
);
if
(
this
.
readonly
===
true
)
data
.
readonly
=
this
.
readonly
;
return
data
;
...
...
examples/js/nodes/core/
GL
Node.js
→
examples/js/nodes/core/Node.js
浏览文件 @
9b26302c
...
...
@@ -2,7 +2,7 @@
* @author sunag / http://www.sunag.com.br/
*/
function
GL
Node
(
type
)
{
function
Node
(
type
)
{
this
.
uuid
=
THREE
.
Math
.
generateUUID
();
...
...
@@ -12,31 +12,31 @@ function GLNode( type ) {
this
.
userData
=
{};
};
}
Node
.
prototype
=
{
GLNode
.
prototype
=
{
constructor
:
Node
,
constructor
:
GLNode
,
isNode
:
true
,
parse
:
function
(
builder
,
settings
)
{
settings
=
settings
||
{};
builder
.
parsing
=
true
;
this
.
build
(
builder
.
add
Cache
(
settings
.
cache
,
settings
.
requires
).
addSlot
(
settings
.
slo
t
),
'
v4
'
);
this
.
build
(
builder
.
add
Flow
(
settings
.
slot
,
settings
.
cache
,
settings
.
contex
t
),
'
v4
'
);
builder
.
clearVertexNodeCode
()
builder
.
clearVertexNodeCode
()
;
builder
.
clearFragmentNodeCode
();
builder
.
remove
Cache
().
removeSlot
();
builder
.
remove
Flow
();
builder
.
parsing
=
false
;
},
parseAndBuildCode
:
function
(
builder
,
output
,
settings
)
{
settings
=
settings
||
{};
...
...
@@ -44,21 +44,21 @@ GLNode.prototype = {
this
.
parse
(
builder
,
settings
);
return
this
.
buildCode
(
builder
,
output
,
settings
);
},
buildCode
:
function
(
builder
,
output
,
settings
)
{
settings
=
settings
||
{};
var
data
=
{
result
:
this
.
build
(
builder
.
add
Cache
(
settings
.
cache
,
settings
.
context
).
addSlot
(
settings
.
slo
t
),
output
)
};
var
data
=
{
result
:
this
.
build
(
builder
.
add
Flow
(
settings
.
slot
,
settings
.
cache
,
settings
.
contex
t
),
output
)
};
data
.
code
=
builder
.
clearNodeCode
();
builder
.
remove
Cache
().
removeSlot
();
builder
.
remove
Flow
();
return
data
;
},
build
:
function
(
builder
,
output
,
uuid
)
{
...
...
@@ -67,7 +67,11 @@ GLNode.prototype = {
var
data
=
builder
.
getNodeData
(
uuid
||
this
);
if
(
builder
.
parsing
)
this
.
appendDepsNode
(
builder
,
data
,
output
);
if
(
builder
.
parsing
)
{
this
.
appendDepsNode
(
builder
,
data
,
output
);
}
if
(
builder
.
nodes
.
indexOf
(
this
)
===
-
1
)
{
...
...
@@ -82,9 +86,9 @@ GLNode.prototype = {
}
return
this
.
generate
(
builder
,
output
,
uuid
);
},
appendDepsNode
:
function
(
builder
,
data
,
output
)
{
data
.
deps
=
(
data
.
deps
||
0
)
+
1
;
...
...
@@ -97,29 +101,29 @@ GLNode.prototype = {
data
.
output
=
output
;
}
},
setName
:
function
(
name
)
{
setName
:
function
(
name
)
{
this
.
name
=
name
;
return
this
;
},
getName
:
function
(
builder
)
{
getName
:
function
(
builder
)
{
return
this
.
name
;
},
getType
:
function
(
builder
,
output
)
{
return
output
===
'
sampler2D
'
||
output
===
'
samplerCube
'
?
output
:
this
.
type
;
},
getJSONNode
:
function
(
meta
)
{
var
isRootObject
=
(
meta
===
undefined
||
typeof
meta
===
'
string
'
);
...
...
@@ -129,17 +133,17 @@ GLNode.prototype = {
return
meta
.
nodes
[
this
.
uuid
];
}
},
copy
:
function
(
source
)
{
if
(
source
.
name
!==
undefined
)
this
.
name
=
source
.
name
;
if
(
source
.
userData
!==
undefined
)
this
.
userData
=
JSON
.
parse
(
JSON
.
stringify
(
source
.
userData
)
);
},
createJSONNode
:
function
(
meta
)
{
var
isRootObject
=
(
meta
===
undefined
||
typeof
meta
===
'
string
'
);
...
...
@@ -162,15 +166,15 @@ GLNode.prototype = {
}
return
data
;
},
toJSON
:
function
(
meta
)
{
return
this
.
getJSONNode
(
meta
)
||
this
.
createJSONNode
(
meta
);
}
};
export
{
GL
Node
};
export
{
Node
};
examples/js/nodes/core/NodeBuilder.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/core/NodeFrame.js
浏览文件 @
9b26302c
...
...
@@ -6,9 +6,9 @@ function NodeFrame( time ) {
this
.
time
=
time
!==
undefined
?
time
:
0
;
this
.
frameI
d
=
0
;
this
.
i
d
=
0
;
}
;
}
NodeFrame
.
prototype
=
{
...
...
@@ -16,7 +16,7 @@ NodeFrame.prototype = {
update
:
function
(
delta
)
{
++
this
.
frameI
d
;
++
this
.
i
d
;
this
.
time
+=
delta
;
this
.
delta
=
delta
;
...
...
@@ -24,19 +24,35 @@ NodeFrame.prototype = {
return
this
;
},
setRenderer
:
function
(
renderer
)
{
this
.
renderer
=
renderer
;
return
this
;
},
setRenderTexture
:
function
(
renderTexture
)
{
this
.
renderTexture
=
renderTexture
;
return
this
;
},
updateNode
:
function
(
node
)
{
if
(
node
.
frameId
===
this
.
frameI
d
)
return
this
;
if
(
node
.
frameId
===
this
.
i
d
)
return
this
;
node
.
updateFrame
(
this
);
node
.
frameId
=
this
.
frameI
d
;
node
.
frameId
=
this
.
i
d
;
return
this
;
}
};
export
{
NodeFrame
};
examples/js/nodes/core/NodeUniform.js
浏览文件 @
9b26302c
...
...
@@ -11,26 +11,26 @@ function NodeUniform( params ) {
this
.
node
=
params
.
node
;
this
.
needsUpdate
=
params
.
needsUpdate
;
}
;
}
Object
.
defineProperties
(
NodeUniform
.
prototype
,
{
value
:
{
get
:
function
()
{
return
this
.
node
.
value
;
},
set
:
function
(
val
)
{
this
.
node
.
value
=
val
;
}
}
}
);
export
{
NodeUniform
};
examples/js/nodes/core/NodeUtils.js
浏览文件 @
9b26302c
...
...
@@ -13,37 +13,37 @@ var NodeUtils = {
if
(
subProperty
)
{
return
{
get
:
function
()
{
return
this
[
proxy
][
property
][
subProperty
];
},
set
:
function
(
val
)
{
this
[
proxy
][
property
][
subProperty
]
=
val
;
}
};
}
else
{
return
{
get
:
function
()
{
return
this
[
proxy
][
property
];
},
set
:
function
(
val
)
{
this
[
proxy
][
property
]
=
val
;
}
};
}
...
...
@@ -57,8 +57,8 @@ var NodeUtils = {
for
(
var
i
=
0
;
i
<
list
.
length
;
++
i
)
{
var
data
=
list
[
i
].
split
(
"
.
"
),
property
=
data
[
0
],
subProperty
=
data
[
1
];
property
=
data
[
0
],
subProperty
=
data
[
1
];
shortcuts
[
property
]
=
applyShortcut
(
proxy
,
property
,
subProperty
);
...
...
@@ -69,7 +69,7 @@ var NodeUtils = {
};
}()
};
export
{
NodeUtils
};
examples/js/nodes/core/StructNode.js
浏览文件 @
9b26302c
...
...
@@ -3,18 +3,17 @@
*/
import
{
TempNode
}
from
'
./TempNode.js
'
;
import
{
FunctionNode
}
from
'
./FunctionNode.js
'
;
var
declarationRegexp
=
/^struct
\s
*
([
a-z_0-9
]
+
)\s
*{
\s
*
((
.|
\n)
*
?)
}/img
,
propertiesRegexp
=
/
\s
*
(\w
*
?)\s
*
(\w
*
?)(\=
|
\;)
/img
;
function
StructNode
(
src
)
{
TempNode
.
call
(
this
);
TempNode
.
call
(
this
);
this
.
eval
(
src
);
};
StructNode
.
rDeclaration
=
/^struct
\s
*
([
a-z_0-9
]
+
)\s
*{
\s
*
((
.|
\n)
*
?)
}/img
;
StructNode
.
rProperties
=
/
\s
*
(\w
*
?)\s
*
(\w
*
?)(\=
|
\;)
/img
;
}
StructNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
StructNode
.
prototype
.
constructor
=
StructNode
;
...
...
@@ -32,9 +31,12 @@ StructNode.prototype.getInputByName = function ( name ) {
while
(
i
--
)
{
if
(
this
.
inputs
[
i
].
name
===
name
)
if
(
this
.
inputs
[
i
].
name
===
name
)
{
return
this
.
inputs
[
i
];
}
}
};
...
...
@@ -47,7 +49,7 @@ StructNode.prototype.generate = function ( builder, output ) {
}
else
{
return
builder
.
format
(
"
(
"
+
src
+
"
)
"
,
this
.
getType
(
builder
),
output
);
return
builder
.
format
(
'
(
'
+
src
+
'
)
'
,
this
.
getType
(
builder
),
output
);
}
...
...
@@ -56,34 +58,32 @@ StructNode.prototype.generate = function ( builder, output ) {
StructNode
.
prototype
.
eval
=
function
(
src
)
{
this
.
src
=
src
||
''
;
this
.
inputs
=
[];
var
declaration
=
StructNode
.
rDeclaration
.
exec
(
this
.
src
);
if
(
declaration
)
{
var
properties
=
declaration
[
2
],
matchType
,
matchName
;
while
(
matchType
=
FunctionNode
.
rProperties
.
exec
(
properties
)
)
{
matchName
=
FunctionNode
.
rProperties
.
exec
(
properties
)[
0
];
var
declaration
=
declarationRegexp
.
exec
(
this
.
src
);
if
(
declaration
)
{
var
properties
=
declaration
[
2
],
match
;
while
(
match
=
propertiesRegexp
.
exec
(
properties
)
)
{
this
.
inputs
.
push
(
{
name
:
matchName
,
type
:
matchType
type
:
match
[
1
]
,
name
:
match
[
2
]
}
);
}
this
.
name
=
declaration
[
1
];
this
.
name
=
declaration
[
1
];
}
else
{
this
.
name
=
''
;
}
this
.
type
=
this
.
name
;
};
...
...
examples/js/nodes/core/TempNode.js
浏览文件 @
9b26302c
...
...
@@ -3,20 +3,20 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
./GL
Node.js
'
;
import
{
Node
}
from
'
./
Node.js
'
;
function
TempNode
(
type
,
params
)
{
GL
Node
.
call
(
this
,
type
);
Node
.
call
(
this
,
type
);
params
=
params
||
{};
this
.
shared
=
params
.
shared
!==
undefined
?
params
.
shared
:
true
;
this
.
unique
=
params
.
unique
!==
undefined
?
params
.
unique
:
false
;
}
;
}
TempNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
TempNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
TempNode
.
prototype
.
constructor
=
TempNode
;
TempNode
.
prototype
.
build
=
function
(
builder
,
output
,
uuid
,
ns
)
{
...
...
@@ -35,36 +35,36 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
uuid
=
builder
.
getUuid
(
uuid
||
this
.
getUuid
(),
!
isUnique
);
var
data
=
builder
.
getNodeData
(
uuid
);
var
data
=
builder
.
getNodeData
(
uuid
),
type
=
data
.
output
||
this
.
getType
(
builder
);
if
(
builder
.
parsing
)
{
if
(
data
.
deps
||
0
>
0
)
{
if
(
(
data
.
deps
||
0
)
>
0
)
{
this
.
appendDepsNode
(
builder
,
data
,
output
);
return
this
.
generate
(
builder
,
type
,
uuid
);
return
this
.
generate
(
builder
,
output
,
uuid
);
}
return
GL
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
return
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
}
else
if
(
isUnique
)
{
data
.
name
=
data
.
name
||
GL
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
data
.
name
=
data
.
name
||
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
return
data
.
name
;
}
else
if
(
!
builder
.
optimize
||
data
.
deps
==
1
)
{
}
else
if
(
!
this
.
isShared
(
builder
,
type
)
||
(
!
builder
.
optimize
||
data
.
deps
==
1
)
)
{
return
GL
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
return
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
}
uuid
=
this
.
getUuid
(
false
);
var
name
=
this
.
getTemp
(
builder
,
uuid
),
type
=
data
.
output
||
this
.
getType
(
builder
);
var
name
=
this
.
getTemp
(
builder
,
uuid
);
if
(
name
)
{
...
...
@@ -84,7 +84,7 @@ TempNode.prototype.build = function ( builder, output, uuid, ns ) {
}
return
GL
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
return
Node
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
};
...
...
@@ -114,10 +114,10 @@ TempNode.prototype.getTemp = function ( builder, uuid ) {
uuid
=
uuid
||
this
.
uuid
;
var
tempVar
=
builder
.
getVars
()[
uuid
]
var
tempVar
=
builder
.
getVars
()[
uuid
];
return
tempVar
?
tempVar
.
name
:
undefined
;
};
TempNode
.
prototype
.
generate
=
function
(
builder
,
output
,
uuid
,
type
,
ns
)
{
...
...
examples/js/nodes/core/VarNode.js
浏览文件 @
9b26302c
...
...
@@ -2,17 +2,17 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
./GL
Node.js
'
;
import
{
Node
}
from
'
./
Node.js
'
;
function
VarNode
(
type
,
value
)
{
GL
Node
.
call
(
this
,
type
);
Node
.
call
(
this
,
type
);
this
.
value
=
value
;
}
;
}
VarNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
VarNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
VarNode
.
prototype
.
constructor
=
VarNode
;
VarNode
.
prototype
.
nodeType
=
"
Var
"
;
...
...
@@ -31,18 +31,18 @@ VarNode.prototype.generate = function ( builder, output ) {
builder
.
addNodeCode
(
varying
.
name
+
'
=
'
+
this
.
value
.
build
(
builder
,
this
.
getType
(
builder
)
)
+
'
;
'
);
}
return
builder
.
format
(
varying
.
name
,
this
.
getType
(
builder
),
output
);
};
VarNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
type
=
source
.
type
;
this
.
value
=
source
.
value
;
};
VarNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/effects/BlurNode.js
浏览文件 @
9b26302c
...
...
@@ -24,10 +24,10 @@ function BlurNode( value, uv, radius, size ) {
this
.
horizontal
=
new
FloatNode
(
1
/
64
);
this
.
vertical
=
new
FloatNode
(
1
/
64
);
};
}
BlurNode
.
Nodes
=
(
function
()
{
BlurNode
.
Nodes
=
(
function
()
{
var
blurX
=
new
FunctionNode
(
[
"
vec4 blurX( sampler2D texture, vec2 uv, float s ) {
"
,
"
vec4 sum = vec4( 0.0 );
"
,
...
...
@@ -40,10 +40,10 @@ BlurNode.Nodes = (function() {
"
sum += texture2D( texture, vec2( uv.x + 2.0 * s, uv.y ) ) * 0.12245;
"
,
"
sum += texture2D( texture, vec2( uv.x + 3.0 * s, uv.y ) ) * 0.0918;
"
,
"
sum += texture2D( texture, vec2( uv.x + 4.0 * s, uv.y ) ) * 0.051;
"
,
"
return sum;
"
,
"
return sum
* .667
;
"
,
"
}
"
].
join
(
"
\n
"
)
);
var
blurY
=
new
FunctionNode
(
[
"
vec4 blurY( sampler2D texture, vec2 uv, float s ) {
"
,
"
vec4 sum = vec4( 0.0 );
"
,
...
...
@@ -56,16 +56,16 @@ BlurNode.Nodes = (function() {
"
sum += texture2D( texture, vec2( uv.x, uv.y + 2.0 * s ) ) * 0.12245;
"
,
"
sum += texture2D( texture, vec2( uv.x, uv.y + 3.0 * s ) ) * 0.0918;
"
,
"
sum += texture2D( texture, vec2( uv.x, uv.y + 4.0 * s ) ) * 0.051;
"
,
"
return sum;
"
,
"
return sum
* .667
;
"
,
"
}
"
].
join
(
"
\n
"
)
);
return
{
blurX
:
blurX
,
blurY
:
blurY
};
})();
}
)();
BlurNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
...
...
@@ -98,7 +98,7 @@ BlurNode.prototype.generate = function ( builder, output ) {
var
blurX
=
builder
.
include
(
BlurNode
.
Nodes
.
blurX
),
blurY
=
builder
.
include
(
BlurNode
.
Nodes
.
blurY
);
if
(
this
.
blurX
)
{
blurCode
.
push
(
blurX
+
'
(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
this
.
uv
.
build
(
builder
,
'
v2
'
)
+
'
,
'
+
this
.
horizontal
.
build
(
builder
,
'
f
'
)
+
'
)
'
);
...
...
@@ -111,7 +111,7 @@ BlurNode.prototype.generate = function ( builder, output ) {
}
if
(
blurCode
.
length
==
2
)
code
=
'
(
'
+
blurCode
.
join
(
'
+
'
)
+
'
/ 2.0 )
'
;
if
(
blurCode
.
length
==
2
)
code
=
'
(
'
+
blurCode
.
join
(
'
+
'
)
+
'
/ 2.0 )
'
;
else
if
(
blurCode
.
length
)
code
=
'
(
'
+
blurCode
[
0
]
+
'
)
'
;
else
code
=
'
vec4( 0.0 )
'
;
...
...
@@ -128,9 +128,9 @@ BlurNode.prototype.generate = function ( builder, output ) {
};
BlurNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
=
source
.
value
;
this
.
uv
=
source
.
uv
;
this
.
radius
=
source
.
radius
;
...
...
@@ -139,7 +139,7 @@ BlurNode.prototype.copy = function ( source ) {
this
.
blurX
=
source
.
blurX
;
this
.
blurY
=
source
.
blurY
;
};
BlurNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
@@ -165,4 +165,4 @@ BlurNode.prototype.toJSON = function ( meta ) {
};
export
{
BlurNode
};
\ No newline at end of file
export
{
BlurNode
};
examples/js/nodes/effects/ColorAdjustmentNode.js
浏览文件 @
9b26302c
...
...
@@ -15,58 +15,58 @@ function ColorAdjustmentNode( rgb, adjustment, method ) {
this
.
method
=
method
||
ColorAdjustmentNode
.
SATURATION
;
};
}
ColorAdjustmentNode
.
Nodes
=
(
function
()
{
ColorAdjustmentNode
.
Nodes
=
(
function
()
{
var
hue
=
new
FunctionNode
(
[
"
vec3 hue(vec3 rgb, float adjustment) {
"
,
"
const mat3 RGBtoYIQ = mat3(0.299, 0.587, 0.114, 0.595716, -0.274453, -0.321263, 0.211456, -0.522591, 0.311135);
"
,
"
const mat3 YIQtoRGB = mat3(1.0, 0.9563, 0.6210, 1.0, -0.2721, -0.6474, 1.0, -1.107, 1.7046);
"
,
"
vec3 yiq = RGBtoYIQ * rgb;
"
,
"
float hue = atan(yiq.z, yiq.y) + adjustment;
"
,
"
float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);
"
,
"
return YIQtoRGB * vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));
"
,
"
}
"
].
join
(
"
\n
"
)
);
var
saturation
=
new
FunctionNode
(
[
// Algorithm from Chapter 16 of OpenGL Shading Language
"
vec3 saturation(vec3 rgb, float adjustment) {
"
,
"
vec3 intensity = vec3( luminance( rgb ) );
"
,
"
return mix( intensity, rgb, adjustment );
"
,
"
}
"
].
join
(
"
\n
"
),
[
LuminanceNode
.
Nodes
.
luminance
]
);
// include LuminanceNode function
var
vibrance
=
new
FunctionNode
(
[
// Shader by Evan Wallace adapted by @lo-th
"
vec3 vibrance(vec3 rgb, float adjustment) {
"
,
"
float average = (rgb.r + rgb.g + rgb.b) / 3.0;
"
,
"
float mx = max(rgb.r, max(rgb.g, rgb.b));
"
,
"
float amt = (mx - average) * (-3.0 * adjustment);
"
,
"
return mix(rgb.rgb, vec3(mx), amt);
"
,
"
}
"
].
join
(
"
\n
"
)
);
return
{
hue
:
hue
,
saturation
:
saturation
,
vibrance
:
vibrance
};
})();
}
)();
ColorAdjustmentNode
.
SATURATION
=
'
saturation
'
;
ColorAdjustmentNode
.
HUE
=
'
hue
'
;
...
...
@@ -99,16 +99,16 @@ ColorAdjustmentNode.prototype.generate = function ( builder, output ) {
}
var
method
=
builder
.
include
(
ColorAdjustmentNode
.
Nodes
[
this
.
method
]
);
var
method
=
builder
.
include
(
ColorAdjustmentNode
.
Nodes
[
this
.
method
]
);
return
builder
.
format
(
method
+
'
(
'
+
rgb
+
'
,
'
+
adjustment
+
'
)
'
,
this
.
getType
(
builder
),
output
);
};
ColorAdjustmentNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
rgb
=
source
.
rgb
;
this
.
adjustment
=
source
.
adjustment
;
this
.
method
=
source
.
method
;
...
...
@@ -133,4 +133,4 @@ ColorAdjustmentNode.prototype.toJSON = function ( meta ) {
};
export
{
ColorAdjustmentNode
};
\ No newline at end of file
export
{
ColorAdjustmentNode
};
examples/js/nodes/effects/LuminanceNode.js
浏览文件 @
9b26302c
...
...
@@ -12,18 +12,18 @@ function LuminanceNode( rgb ) {
this
.
rgb
=
rgb
;
};
}
LuminanceNode
.
Nodes
=
(
function
()
{
LuminanceNode
.
Nodes
=
(
function
()
{
var
LUMA
=
new
ConstNode
(
"
vec3 LUMA vec3( 0.2125, 0.7154, 0.0721 )
"
);
var
luminance
=
new
FunctionNode
(
[
// Algorithm from Chapter 10 of Graphics Shaders
"
float luminance( vec3 rgb ) {
"
,
"
return dot( rgb, LUMA );
"
,
"
}
"
].
join
(
"
\n
"
),
[
LUMA
]
);
...
...
@@ -31,8 +31,8 @@ LuminanceNode.Nodes = (function() {
LUMA
:
LUMA
,
luminance
:
luminance
};
})();
}
)();
LuminanceNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
LuminanceNode
.
prototype
.
constructor
=
LuminanceNode
;
...
...
@@ -47,11 +47,11 @@ LuminanceNode.prototype.generate = function ( builder, output ) {
};
LuminanceNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
rgb
=
source
.
rgb
;
};
LuminanceNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/ColorNode.js
浏览文件 @
9b26302c
...
...
@@ -11,7 +11,7 @@ function ColorNode( color, g, b ) {
this
.
value
=
color
instanceof
THREE
.
Color
?
color
:
new
THREE
.
Color
(
color
||
0
,
g
,
b
);
}
;
}
ColorNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
ColorNode
.
prototype
.
constructor
=
ColorNode
;
...
...
@@ -26,11 +26,11 @@ ColorNode.prototype.generateReadonly = function ( builder, output, uuid, type, n
};
ColorNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
.
copy
(
source
);
};
ColorNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/CubeTextureNode.js
浏览文件 @
9b26302c
...
...
@@ -4,6 +4,7 @@
import
{
InputNode
}
from
'
../core/InputNode.js
'
;
import
{
ReflectNode
}
from
'
../accessors/ReflectNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
function
CubeTextureNode
(
value
,
uv
,
bias
)
{
...
...
@@ -13,7 +14,7 @@ function CubeTextureNode( value, uv, bias ) {
this
.
uv
=
uv
||
new
ReflectNode
();
this
.
bias
=
bias
;
}
;
}
CubeTextureNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
CubeTextureNode
.
prototype
.
constructor
=
CubeTextureNode
;
...
...
@@ -48,22 +49,29 @@ CubeTextureNode.prototype.generate = function ( builder, output ) {
if
(
bias
)
code
=
'
texCubeBias(
'
+
cubetex
+
'
,
'
+
uv
+
'
,
'
+
bias
+
'
)
'
;
else
code
=
'
texCube(
'
+
cubetex
+
'
,
'
+
uv
+
'
)
'
;
code
=
builder
.
getTexelDecodingFunctionFromTexture
(
code
,
this
.
value
);
// add this context to replace ColorSpaceNode.input to code
builder
.
addContext
(
{
input
:
code
,
encoding
:
builder
.
getTextureEncodingFromMap
(
this
.
value
),
include
:
builder
.
isShader
(
'
vertex
'
)
}
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
this
);
code
=
this
.
colorSpace
.
build
(
builder
,
this
.
type
);
builder
.
removeContext
();
return
builder
.
format
(
code
,
this
.
type
,
output
);
};
CubeTextureNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
if
(
source
.
value
)
this
.
value
=
source
.
value
;
this
.
uv
=
source
.
uv
;
if
(
source
.
bias
)
this
.
bias
=
source
.
bias
;
};
CubeTextureNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/FloatNode.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function FloatNode( value ) {
this
.
value
=
value
||
0
;
}
;
}
FloatNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
FloatNode
.
prototype
.
constructor
=
FloatNode
;
...
...
@@ -23,11 +23,11 @@ FloatNode.prototype.generateReadonly = function ( builder, output, uuid, type, n
};
FloatNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
=
source
.
value
;
};
FloatNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/IntNode.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function IntNode( value ) {
this
.
value
=
Math
.
floor
(
value
||
0
);
}
;
}
IntNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
IntNode
.
prototype
.
constructor
=
IntNode
;
...
...
@@ -23,11 +23,11 @@ IntNode.prototype.generateReadonly = function ( builder, output, uuid, type, ns,
};
IntNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
=
source
.
value
;
};
IntNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/Matrix3Node.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function Matrix3Node( matrix ) {
this
.
value
=
matrix
||
new
THREE
.
Matrix3
();
}
;
}
Matrix3Node
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
Matrix3Node
.
prototype
.
constructor
=
Matrix3Node
;
...
...
@@ -19,19 +19,19 @@ Matrix3Node.prototype.nodeType = "Matrix3";
Object
.
defineProperties
(
Matrix3Node
.
prototype
,
{
elements
:
{
set
:
function
(
val
)
{
set
:
function
(
val
)
{
this
.
value
.
elements
=
val
;
},
get
:
function
()
{
return
this
.
value
.
elements
;
}
}
}
);
...
...
@@ -44,11 +44,11 @@ Matrix3Node.prototype.generateReadonly = function ( builder, output, uuid, type,
Matrix3Node
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
.
fromArray
(
source
.
elements
);
};
Matrix3Node
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/Matrix4Node.js
浏览文件 @
9b26302c
...
...
@@ -10,7 +10,7 @@ function Matrix4Node( matrix ) {
this
.
value
=
matrix
||
new
THREE
.
Matrix4
();
}
;
}
Matrix4Node
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
Matrix4Node
.
prototype
.
constructor
=
Matrix4Node
;
...
...
@@ -19,19 +19,19 @@ Matrix4Node.prototype.nodeType = "Matrix4";
Object
.
defineProperties
(
Matrix4Node
.
prototype
,
{
elements
:
{
set
:
function
(
val
)
{
set
:
function
(
val
)
{
this
.
value
.
elements
=
val
;
},
get
:
function
()
{
return
this
.
value
.
elements
;
}
}
}
);
...
...
@@ -43,11 +43,11 @@ Matrix4Node.prototype.generateReadonly = function ( builder, output, uuid, type,
};
Matrix4Node
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
scope
.
value
.
fromArray
(
source
.
elements
);
};
Matrix4Node
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/PropertyNode.js
浏览文件 @
9b26302c
...
...
@@ -3,15 +3,15 @@
*/
import
{
InputNode
}
from
'
../core/InputNode.js
'
;
function
PropertyNode
(
object
,
property
,
type
)
{
InputNode
.
call
(
this
,
type
);
this
.
object
=
object
;
this
.
property
=
property
;
}
;
}
PropertyNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
PropertyNode
.
prototype
.
constructor
=
PropertyNode
;
...
...
@@ -20,19 +20,19 @@ PropertyNode.prototype.nodeType = "Property";
Object
.
defineProperties
(
PropertyNode
.
prototype
,
{
value
:
{
get
:
function
()
{
return
this
.
object
[
this
.
property
];
},
set
:
function
(
val
)
{
set
:
function
(
val
)
{
this
.
object
[
this
.
property
]
=
val
;
}
}
}
);
...
...
examples/js/nodes/inputs/RTTNode.js
0 → 100644
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
NodeMaterial
}
from
'
../materials/NodeMaterial.js
'
;
import
{
TextureNode
}
from
'
./TextureNode.js
'
;
function
RTTNode
(
width
,
height
,
input
,
options
)
{
options
=
options
||
{};
this
.
input
=
input
;
this
.
clear
=
options
.
clear
!==
undefined
?
options
.
clear
:
true
;
this
.
renderTarget
=
new
THREE
.
WebGLRenderTarget
(
width
,
height
,
options
);
this
.
material
=
new
NodeMaterial
();
this
.
camera
=
new
THREE
.
OrthographicCamera
(
-
1
,
1
,
1
,
-
1
,
0
,
1
);
this
.
scene
=
new
THREE
.
Scene
();
this
.
quad
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(
2
,
2
),
this
.
material
);
this
.
quad
.
frustumCulled
=
false
;
// Avoid getting clipped
this
.
scene
.
add
(
this
.
quad
);
this
.
render
=
true
;
TextureNode
.
call
(
this
,
this
.
renderTarget
.
texture
);
}
RTTNode
.
prototype
=
Object
.
create
(
TextureNode
.
prototype
);
RTTNode
.
prototype
.
constructor
=
RTTNode
;
RTTNode
.
prototype
.
nodeType
=
"
RTT
"
;
RTTNode
.
prototype
.
build
=
function
(
builder
,
output
,
uuid
)
{
var
rttBuilder
=
new
THREE
.
NodeBuilder
();
rttBuilder
.
nodes
=
builder
.
nodes
;
rttBuilder
.
updaters
=
builder
.
updaters
;
this
.
material
.
fragment
.
value
=
this
.
input
;
this
.
material
.
build
(
{
builder
:
rttBuilder
}
);
return
TextureNode
.
prototype
.
build
.
call
(
this
,
builder
,
output
,
uuid
);
};
RTTNode
.
prototype
.
updateFramesaveTo
=
function
(
frame
)
{
this
.
saveTo
.
render
=
false
;
if
(
this
.
saveTo
!==
this
.
saveToCurrent
)
{
if
(
this
.
saveToMaterial
)
this
.
saveToMaterial
.
dispose
();
var
material
=
new
NodeMaterial
();
material
.
fragment
.
value
=
this
;
material
.
build
();
var
scene
=
new
THREE
.
Scene
();
var
quad
=
new
THREE
.
Mesh
(
new
THREE
.
PlaneBufferGeometry
(
2
,
2
),
material
);
quad
.
frustumCulled
=
false
;
// Avoid getting clipped
scene
.
add
(
quad
);
this
.
saveToScene
=
scene
;
this
.
saveToMaterial
=
material
;
}
this
.
saveToCurrent
=
this
.
saveTo
;
frame
.
renderer
.
render
(
this
.
saveToScene
,
this
.
camera
,
this
.
saveTo
.
renderTarget
,
this
.
saveTo
.
clear
);
};
RTTNode
.
prototype
.
updateFrame
=
function
(
frame
)
{
if
(
frame
.
renderer
)
{
// from the second frame
if
(
this
.
saveTo
&&
this
.
saveTo
.
render
===
false
)
{
this
.
updateFramesaveTo
(
frame
);
}
if
(
this
.
render
)
{
if
(
this
.
material
.
uniforms
.
renderTexture
)
{
this
.
material
.
uniforms
.
renderTexture
.
value
=
frame
.
renderTexture
;
}
frame
.
renderer
.
render
(
this
.
scene
,
this
.
camera
,
this
.
renderTarget
,
this
.
clear
);
}
// first frame
if
(
this
.
saveTo
&&
this
.
saveTo
.
render
===
true
)
{
this
.
updateFramesaveTo
(
frame
);
}
}
else
{
console
.
warn
(
"
RTTNode need a renderer in NodeFrame
"
);
}
};
RTTNode
.
prototype
.
copy
=
function
(
source
)
{
TextureNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
saveTo
=
source
.
saveTo
;
};
RTTNode
.
prototype
.
toJSON
=
function
(
meta
)
{
var
data
=
this
.
getJSONNode
(
meta
);
if
(
!
data
)
{
data
=
THREE
.
TextureNode
.
prototype
.
toJSON
.
call
(
this
,
meta
);
if
(
this
.
saveTo
)
data
.
saveTo
=
this
.
saveTo
.
toJSON
(
meta
).
uuid
;
}
return
data
;
};
export
{
RTTNode
};
examples/js/nodes/inputs/ReflectorNode.js
浏览文件 @
9b26302c
...
...
@@ -14,7 +14,7 @@ function ReflectorNode( mirror ) {
if
(
mirror
)
this
.
setMirror
(
mirror
);
}
;
}
ReflectorNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ReflectorNode
.
prototype
.
constructor
=
ReflectorNode
;
...
...
@@ -36,7 +36,7 @@ ReflectorNode.prototype.setMirror = function ( mirror ) {
};
ReflectorNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
this
.
uvResult
.
a
=
this
.
offset
;
...
...
@@ -61,9 +61,9 @@ ReflectorNode.prototype.generate = function ( builder, output ) {
};
ReflectorNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
scope
.
mirror
=
source
.
mirror
;
};
...
...
examples/js/nodes/inputs/ScreenNode.js
浏览文件 @
9b26302c
...
...
@@ -9,7 +9,7 @@ function ScreenNode( uv ) {
TextureNode
.
call
(
this
,
undefined
,
uv
);
}
;
}
ScreenNode
.
prototype
=
Object
.
create
(
TextureNode
.
prototype
);
ScreenNode
.
prototype
.
constructor
=
ScreenNode
;
...
...
examples/js/nodes/inputs/TextureNode.js
浏览文件 @
9b26302c
...
...
@@ -3,8 +3,8 @@
*/
import
{
InputNode
}
from
'
../core/InputNode.js
'
;
import
{
NodeBuilder
}
from
'
../core/NodeBuilder.js
'
;
import
{
UVNode
}
from
'
../accessors/UVNode.js
'
;
import
{
ColorSpaceNode
}
from
'
../utils/ColorSpaceNode.js
'
;
function
TextureNode
(
value
,
uv
,
bias
,
project
)
{
...
...
@@ -15,7 +15,7 @@ function TextureNode( value, uv, bias, project ) {
this
.
bias
=
bias
;
this
.
project
=
project
!==
undefined
?
project
:
false
;
}
;
}
TextureNode
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
TextureNode
.
prototype
.
constructor
=
TextureNode
;
...
...
@@ -53,23 +53,30 @@ TextureNode.prototype.generate = function ( builder, output ) {
if
(
bias
)
code
=
method
+
'
(
'
+
tex
+
'
,
'
+
uv
+
'
,
'
+
bias
+
'
)
'
;
else
code
=
method
+
'
(
'
+
tex
+
'
,
'
+
uv
+
'
)
'
;
code
=
builder
.
getTexelDecodingFunctionFromTexture
(
code
,
this
.
value
);
// add this context to replace ColorSpaceNode.input to code
builder
.
addContext
(
{
input
:
code
,
encoding
:
builder
.
getTextureEncodingFromMap
(
this
.
value
),
include
:
builder
.
isShader
(
'
vertex
'
)
}
);
this
.
colorSpace
=
this
.
colorSpace
||
new
ColorSpaceNode
(
this
);
code
=
this
.
colorSpace
.
build
(
builder
,
this
.
type
);
builder
.
removeContext
();
return
builder
.
format
(
code
,
this
.
type
,
output
);
};
TextureNode
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
if
(
source
.
value
)
this
.
value
=
source
.
value
;
this
.
uv
=
source
.
uv
;
if
(
source
.
bias
)
this
.
bias
=
source
.
bias
;
if
(
source
.
project
!==
undefined
)
this
.
project
=
source
.
project
;
};
TextureNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/Vector2Node.js
浏览文件 @
9b26302c
...
...
@@ -11,7 +11,7 @@ function Vector2Node( x, y ) {
this
.
value
=
x
instanceof
THREE
.
Vector2
?
x
:
new
THREE
.
Vector2
(
x
,
y
);
}
;
}
Vector2Node
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
Vector2Node
.
prototype
.
constructor
=
Vector2Node
;
...
...
@@ -26,9 +26,9 @@ Vector2Node.prototype.generateReadonly = function ( builder, output, uuid, type,
};
Vector2Node
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
.
copy
(
source
);
};
...
...
examples/js/nodes/inputs/Vector3Node.js
浏览文件 @
9b26302c
...
...
@@ -11,7 +11,7 @@ function Vector3Node( x, y, z ) {
this
.
value
=
x
instanceof
THREE
.
Vector3
?
x
:
new
THREE
.
Vector3
(
x
,
y
,
z
);
}
;
}
Vector3Node
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
Vector3Node
.
prototype
.
constructor
=
Vector3Node
;
...
...
@@ -26,11 +26,11 @@ Vector3Node.prototype.generateReadonly = function ( builder, output, uuid, type,
};
Vector3Node
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
.
copy
(
source
);
};
Vector3Node
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/inputs/Vector4Node.js
浏览文件 @
9b26302c
...
...
@@ -11,7 +11,7 @@ function Vector4Node( x, y, z, w ) {
this
.
value
=
x
instanceof
THREE
.
Vector4
?
x
:
new
THREE
.
Vector4
(
x
,
y
,
z
,
w
);
}
;
}
Vector4Node
.
prototype
=
Object
.
create
(
InputNode
.
prototype
);
Vector4Node
.
prototype
.
constructor
=
Vector4Node
;
...
...
@@ -26,9 +26,9 @@ Vector4Node.prototype.generateReadonly = function ( builder, output, uuid, type,
};
Vector4Node
.
prototype
.
copy
=
function
(
source
)
{
InputNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
.
copy
(
source
);
};
...
...
examples/js/nodes/materials/MeshStandardNodeMaterial.js
浏览文件 @
9b26302c
...
...
@@ -14,7 +14,7 @@ function MeshStandardNodeMaterial() {
this
.
type
=
"
MeshStandardNodeMaterial
"
;
}
;
}
MeshStandardNodeMaterial
.
prototype
=
Object
.
create
(
NodeMaterial
.
prototype
);
MeshStandardNodeMaterial
.
prototype
.
constructor
=
MeshStandardNodeMaterial
;
...
...
examples/js/nodes/materials/NodeMaterial.js
浏览文件 @
9b26302c
...
...
@@ -6,21 +6,17 @@ import { NodeBuilder } from '../core/NodeBuilder.js';
import
{
ColorNode
}
from
'
../inputs/ColorNode.js
'
;
import
{
PositionNode
}
from
'
../accessors/PositionNode.js
'
;
import
{
RawNode
}
from
'
./nodes/RawNode.js
'
;
function
NodeMaterial
(
vertex
,
fragment
)
{
THREE
.
ShaderMaterial
.
call
(
this
);
// prevent code share conflict, remove in future
this
.
defines
.
UUID
=
this
.
uuid
;
this
.
vertex
=
vertex
||
new
RawNode
(
new
PositionNode
(
PositionNode
.
PROJECTION
)
);
this
.
fragment
=
fragment
||
new
RawNode
(
new
ColorNode
(
0xFF0000
)
);
this
.
updaters
=
[];
}
;
}
NodeMaterial
.
prototype
=
Object
.
create
(
THREE
.
ShaderMaterial
.
prototype
);
NodeMaterial
.
prototype
.
constructor
=
NodeMaterial
;
...
...
@@ -31,13 +27,13 @@ NodeMaterial.prototype.isNodeMaterial = true;
Object
.
defineProperties
(
NodeMaterial
.
prototype
,
{
properties
:
{
get
:
function
()
{
return
this
.
fragment
.
properties
;
}
}
}
);
...
...
@@ -71,47 +67,47 @@ NodeMaterial.prototype.build = function ( params ) {
params
=
params
||
{};
var
builder
=
params
.
builder
||
new
NodeBuilder
();
builder
.
setMaterial
(
this
,
params
.
renderer
);
builder
.
build
(
this
.
vertex
,
this
.
fragment
);
this
.
vertexShader
=
builder
.
getCode
(
'
vertex
'
);
this
.
fragmentShader
=
builder
.
getCode
(
'
fragment
'
);
this
.
vertexShader
=
builder
.
getCode
(
'
vertex
'
);
this
.
fragmentShader
=
builder
.
getCode
(
'
fragment
'
);
this
.
defines
=
builder
.
defines
;
this
.
uniforms
=
builder
.
uniforms
;
this
.
extensions
=
builder
.
extensions
;
this
.
updaters
=
builder
.
updaters
;
this
.
fog
=
builder
.
requires
.
fog
;
this
.
lights
=
builder
.
requires
.
lights
;
this
.
transparent
=
builder
.
requires
.
transparent
||
this
.
blending
>
THREE
.
NormalBlending
;
this
.
needsUpdate
=
false
;
return
this
;
};
NodeMaterial
.
prototype
.
copy
=
function
(
source
)
{
var
uuid
=
this
.
uuid
;
for
(
var
name
in
source
)
{
this
[
name
]
=
source
[
name
];
for
(
var
name
in
source
)
{
this
[
name
]
=
source
[
name
];
}
this
.
uuid
=
uuid
;
if
(
source
.
userData
!==
undefined
)
{
if
(
source
.
userData
!==
undefined
)
{
this
.
userData
=
JSON
.
parse
(
JSON
.
stringify
(
source
.
userData
)
);
}
};
NodeMaterial
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
@@ -157,7 +153,7 @@ NodeMaterial.prototype.toJSON = function ( meta ) {
if
(
this
.
scale
!==
undefined
)
data
.
scale
=
this
.
scale
;
if
(
this
.
dithering
===
true
)
data
.
dithering
=
true
;
if
(
this
.
wireframe
===
true
)
data
.
wireframe
=
this
.
wireframe
;
if
(
this
.
wireframeLinewidth
>
1
)
data
.
wireframeLinewidth
=
this
.
wireframeLinewidth
;
if
(
this
.
wireframeLinecap
!==
'
round
'
)
data
.
wireframeLinecap
=
this
.
wireframeLinecap
;
...
...
@@ -165,7 +161,7 @@ NodeMaterial.prototype.toJSON = function ( meta ) {
if
(
this
.
alphaTest
>
0
)
data
.
alphaTest
=
this
.
alphaTest
;
if
(
this
.
premultipliedAlpha
===
true
)
data
.
premultipliedAlpha
=
this
.
premultipliedAlpha
;
if
(
this
.
morphTargets
===
true
)
data
.
morphTargets
=
true
;
if
(
this
.
skinning
===
true
)
data
.
skinning
=
true
;
...
...
@@ -174,7 +170,7 @@ NodeMaterial.prototype.toJSON = function ( meta ) {
data
.
fog
=
this
.
fog
;
data
.
lights
=
this
.
lights
;
data
.
vertex
=
this
.
vertex
.
toJSON
(
meta
).
uuid
;
data
.
fragment
=
this
.
fragment
.
toJSON
(
meta
).
uuid
;
...
...
examples/js/nodes/materials/PhongNodeMaterial.js
浏览文件 @
9b26302c
...
...
@@ -14,25 +14,25 @@ function PhongNodeMaterial() {
this
.
type
=
"
PhongNodeMaterial
"
;
}
;
}
PhongNodeMaterial
.
prototype
=
Object
.
create
(
NodeMaterial
.
prototype
);
PhongNodeMaterial
.
prototype
.
constructor
=
PhongNodeMaterial
;
NodeUtils
.
addShortcuts
(
PhongNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
specular
'
,
'
shininess
'
,
'
normal
'
,
'
emissive
'
,
'
ambient
'
,
'
light
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
NodeUtils
.
addShortcuts
(
PhongNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
specular
'
,
'
shininess
'
,
'
normal
'
,
'
emissive
'
,
'
ambient
'
,
'
light
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
environmentAlpha
'
,
'
transform
'
'
position
'
]
);
export
{
PhongNodeMaterial
};
examples/js/nodes/materials/SpriteNodeMaterial.js
浏览文件 @
9b26302c
...
...
@@ -14,16 +14,16 @@ function SpriteNodeMaterial() {
this
.
type
=
"
SpriteNodeMaterial
"
;
}
;
}
SpriteNodeMaterial
.
prototype
=
Object
.
create
(
NodeMaterial
.
prototype
);
SpriteNodeMaterial
.
prototype
.
constructor
=
SpriteNodeMaterial
;
NodeUtils
.
addShortcuts
(
SpriteNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
transform
'
,
'
spherical
'
NodeUtils
.
addShortcuts
(
SpriteNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
position
'
,
'
spherical
'
]
);
export
{
SpriteNodeMaterial
};
examples/js/nodes/materials/StandardNodeMaterial.js
浏览文件 @
9b26302c
...
...
@@ -14,27 +14,27 @@ function StandardNodeMaterial() {
this
.
type
=
"
StandardNodeMaterial
"
;
}
;
}
StandardNodeMaterial
.
prototype
=
Object
.
create
(
NodeMaterial
.
prototype
);
StandardNodeMaterial
.
prototype
.
constructor
=
StandardNodeMaterial
;
NodeUtils
.
addShortcuts
(
StandardNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
roughness
'
,
'
metalness
'
,
'
reflectivity
'
,
'
clearCoat
'
,
'
clearCoatRoughness
'
,
'
normal
'
,
'
emissive
'
,
'
ambient
'
,
'
light
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
transform
'
NodeUtils
.
addShortcuts
(
StandardNodeMaterial
.
prototype
,
'
fragment
'
,
[
'
color
'
,
'
alpha
'
,
'
roughness
'
,
'
metalness
'
,
'
reflectivity
'
,
'
clearCoat
'
,
'
clearCoatRoughness
'
,
'
normal
'
,
'
emissive
'
,
'
ambient
'
,
'
light
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
position
'
]
);
export
{
StandardNodeMaterial
};
examples/js/nodes/materials/nodes/MeshStandardNode.js
浏览文件 @
9b26302c
...
...
@@ -18,7 +18,7 @@ function MeshStandardNode() {
metalness
:
0.5
,
normalScale
:
new
THREE
.
Vector2
(
1
,
1
)
};
this
.
inputs
=
{
color
:
new
PropertyNode
(
this
.
properties
,
'
color
'
,
'
c
'
),
roughness
:
new
PropertyNode
(
this
.
properties
,
'
roughness
'
,
'
f
'
),
...
...
@@ -26,7 +26,7 @@ function MeshStandardNode() {
normalScale
:
new
PropertyNode
(
this
.
properties
,
'
normalScale
'
,
'
v2
'
)
};
}
;
}
MeshStandardNode
.
prototype
=
Object
.
create
(
StandardNode
.
prototype
);
MeshStandardNode
.
prototype
.
constructor
=
MeshStandardNode
;
...
...
@@ -37,53 +37,57 @@ MeshStandardNode.prototype.build = function ( builder ) {
var
props
=
this
.
properties
,
inputs
=
this
.
inputs
;
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
// slots
// * color
// * map
var
color
=
builder
.
findNode
(
props
.
color
,
inputs
.
color
),
map
=
builder
.
resolve
(
props
.
map
);
this
.
color
=
map
?
new
OperatorNode
(
color
,
map
,
OperatorNode
.
MUL
)
:
color
;
// slots
// * roughness
// * roughnessMap
var
roughness
=
builder
.
findNode
(
props
.
roughness
,
inputs
.
roughness
),
roughnessMap
=
builder
.
resolve
(
props
.
roughnessMap
);
this
.
roughness
=
roughnessMap
?
new
OperatorNode
(
roughness
,
new
SwitchNode
(
roughnessMap
,
"
g
"
),
OperatorNode
.
MUL
)
:
roughness
;
// slots
// * metalness
// * metalnessMap
var
metalness
=
builder
.
findNode
(
props
.
metalness
,
inputs
.
metalness
),
metalnessMap
=
builder
.
resolve
(
props
.
metalnessMap
);
this
.
metalness
=
metalnessMap
?
new
OperatorNode
(
metalness
,
new
SwitchNode
(
metalnessMap
,
"
b
"
),
OperatorNode
.
MUL
)
:
metalness
;
// slots
// * normalMap
// * normalScale
if
(
props
.
normalMap
)
{
this
.
normal
=
new
NormalMapNode
(
builder
.
resolve
(
props
.
normalMap
)
);
this
.
normal
.
scale
=
builder
.
findNode
(
props
.
normalScale
,
inputs
.
normalScale
)
this
.
normal
.
scale
=
builder
.
findNode
(
props
.
normalScale
,
inputs
.
normalScale
);
}
else
{
this
.
normal
=
undefined
;
}
// slots
// * envMap
this
.
environment
=
builder
.
resolve
(
props
.
envMap
);
}
// build code
return
StandardNode
.
prototype
.
build
.
call
(
this
,
builder
);
...
...
@@ -97,9 +101,9 @@ MeshStandardNode.prototype.toJSON = function ( meta ) {
if
(
!
data
)
{
data
=
this
.
createJSONNode
(
meta
);
console
.
warn
(
"
.toJSON not implemented in
"
,
this
);
console
.
warn
(
"
.toJSON not implemented in
"
,
this
);
}
return
data
;
...
...
examples/js/nodes/materials/nodes/PhongNode.js
浏览文件 @
9b26302c
...
...
@@ -2,21 +2,21 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
../../core/GL
Node.js
'
;
import
{
Node
}
from
'
../../core/
Node.js
'
;
import
{
ColorNode
}
from
'
../../inputs/ColorNode.js
'
;
import
{
FloatNode
}
from
'
../../inputs/FloatNode.js
'
;
function
PhongNode
()
{
GL
Node
.
call
(
this
);
Node
.
call
(
this
);
this
.
color
=
new
ColorNode
(
0xEEEEEE
);
this
.
specular
=
new
ColorNode
(
0x111111
);
this
.
shininess
=
new
FloatNode
(
30
);
}
;
}
PhongNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
PhongNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
PhongNode
.
prototype
.
constructor
=
PhongNode
;
PhongNode
.
prototype
.
nodeType
=
"
Phong
"
;
...
...
@@ -25,18 +25,17 @@ PhongNode.prototype.build = function ( builder ) {
var
code
;
builder
.
define
(
'
PHONG
'
);
builder
.
define
(
'
ALPHATEST
'
,
'
0.0
'
);
builder
.
requires
.
lights
=
true
;
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
transform
=
this
.
transform
?
this
.
transform
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
transform
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
THREE
.
UniformsLib
[
"
fog
"
]
,
THREE
.
UniformsLib
[
"
lights
"
]
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
]
)
);
...
...
@@ -49,13 +48,13 @@ PhongNode.prototype.build = function ( builder ) {
"
#endif
"
,
"
#include <common>
"
,
"
#include <encodings_pars_fragment>
"
,
// encoding functions
//"#include <encodings_pars_fragment>", // encoding functions
"
#include <fog_pars_vertex>
"
,
"
#include <morphtarget_pars_vertex>
"
,
"
#include <skinning_pars_vertex>
"
,
"
#include <shadowmap_pars_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
"
#include <logdepthbuf_pars_vertex>
"
,
"
#include <clipping_planes_pars_vertex>
"
].
join
(
"
\n
"
)
);
var
output
=
[
...
...
@@ -65,7 +64,7 @@ PhongNode.prototype.build = function ( builder ) {
"
#include <skinnormal_vertex>
"
,
"
#include <defaultnormal_vertex>
"
,
"
#ifndef FLAT_SHADED
"
,
//
N
ormal computed with derivatives when FLAT_SHADED
"
#ifndef FLAT_SHADED
"
,
//
n
ormal computed with derivatives when FLAT_SHADED
"
vNormal = normalize( transformedNormal );
"
,
...
...
@@ -74,11 +73,11 @@ PhongNode.prototype.build = function ( builder ) {
"
#include <begin_vertex>
"
];
if
(
transform
)
{
if
(
position
)
{
output
.
push
(
transform
.
code
,
transform
.
result
?
"
transformed =
"
+
transform
.
result
+
"
;
"
:
''
position
.
code
,
position
.
result
?
"
transformed =
"
+
position
.
result
+
"
;
"
:
''
);
}
...
...
@@ -89,11 +88,13 @@ PhongNode.prototype.build = function ( builder ) {
"
#include <project_vertex>
"
,
"
#include <fog_vertex>
"
,
"
#include <logdepthbuf_vertex>
"
,
"
#include <clipping_planes_vertex>
"
,
"
vViewPosition = - mvPosition.xyz;
"
,
"
#include <worldpos_vertex>
"
,
"
#include <shadowmap_vertex>
"
"
#include <shadowmap_vertex>
"
,
"
#include <fog_vertex>
"
);
code
=
output
.
join
(
"
\n
"
);
...
...
@@ -109,7 +110,6 @@ PhongNode.prototype.build = function ( builder ) {
if
(
this
.
alpha
)
this
.
alpha
.
parse
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
parse
(
builder
);
if
(
this
.
normalScale
&&
this
.
normal
)
this
.
normalScale
.
parse
(
builder
);
if
(
this
.
light
)
this
.
light
.
parse
(
builder
,
{
cache
:
'
light
'
}
);
...
...
@@ -130,7 +130,6 @@ PhongNode.prototype.build = function ( builder ) {
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
buildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
normalScale
=
this
.
normalScale
&&
this
.
normal
?
this
.
normalScale
.
buildCode
(
builder
,
'
v2
'
)
:
undefined
;
var
light
=
this
.
light
?
this
.
light
.
buildCode
(
builder
,
'
v3
'
,
{
cache
:
'
light
'
}
)
:
undefined
;
...
...
@@ -145,7 +144,6 @@ PhongNode.prototype.build = function ( builder ) {
builder
.
requires
.
transparent
=
alpha
!=
undefined
;
builder
.
addParsCode
(
[
"
#include <common>
"
,
"
#include <fog_pars_fragment>
"
,
"
#include <bsdfs>
"
,
"
#include <lights_pars_begin>
"
,
...
...
@@ -180,7 +178,11 @@ PhongNode.prototype.build = function ( builder ) {
output
.
push
(
alpha
.
code
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
'
#ifdef ALPHATEST
'
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
,
'
#endif
'
);
}
...
...
@@ -191,7 +193,7 @@ PhongNode.prototype.build = function ( builder ) {
normal
.
code
,
'
normal =
'
+
normal
.
result
+
'
;
'
);
}
// optimization for now
...
...
@@ -281,19 +283,19 @@ PhongNode.prototype.build = function ( builder ) {
}
}
/*
/*
switch( builder.material.combine ) {
case THREE.ENVMAP_BLENDING_MULTIPLY:
//output.push( "vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;" );
//outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
break;
}
*/
*/
if
(
alpha
)
{
output
.
push
(
"
gl_FragColor = vec4( outgoingLight,
"
+
alpha
.
result
+
"
);
"
);
...
...
@@ -320,12 +322,12 @@ PhongNode.prototype.build = function ( builder ) {
};
PhongNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
// vertex
if
(
source
.
transform
)
this
.
transform
=
source
.
transform
;
if
(
source
.
position
)
this
.
position
=
source
.
position
;
// fragment
...
...
@@ -341,7 +343,7 @@ PhongNode.prototype.copy = function ( source ) {
if
(
source
.
shadow
)
this
.
shadow
=
source
.
shadow
;
if
(
source
.
ao
)
this
.
ao
=
source
.
ao
;
if
(
source
.
emissive
)
this
.
emissive
=
source
.
emissive
;
if
(
source
.
ambient
)
this
.
ambient
=
source
.
ambient
;
...
...
@@ -360,7 +362,7 @@ PhongNode.prototype.toJSON = function ( meta ) {
// vertex
if
(
this
.
transform
)
data
.
transform
=
this
.
transform
.
toJSON
(
meta
).
uuid
;
if
(
this
.
position
)
data
.
position
=
this
.
position
.
toJSON
(
meta
).
uuid
;
// fragment
...
...
examples/js/nodes/materials/nodes/RawNode.js
浏览文件 @
9b26302c
...
...
@@ -2,17 +2,17 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
../../core/GL
Node.js
'
;
import
{
Node
}
from
'
../../core/
Node.js
'
;
function
RawNode
(
value
)
{
GL
Node
.
call
(
this
,
'
v4
'
);
Node
.
call
(
this
,
'
v4
'
);
this
.
value
=
value
;
}
;
}
RawNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
RawNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
RawNode
.
prototype
.
constructor
=
RawNode
;
RawNode
.
prototype
.
nodeType
=
"
Raw
"
;
...
...
@@ -36,11 +36,11 @@ RawNode.prototype.generate = function ( builder ) {
};
RawNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
=
source
.
value
;
};
RawNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/materials/nodes/SpriteNode.js
浏览文件 @
9b26302c
...
...
@@ -2,19 +2,19 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
../../core/GL
Node.js
'
;
import
{
Node
}
from
'
../../core/
Node.js
'
;
import
{
ColorNode
}
from
'
../../inputs/ColorNode.js
'
;
function
SpriteNode
()
{
GL
Node
.
call
(
this
);
Node
.
call
(
this
);
this
.
color
=
new
ColorNode
(
0xEEEEEE
);
this
.
spherical
=
true
;
}
;
}
SpriteNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
SpriteNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
SpriteNode
.
prototype
.
constructor
=
SpriteNode
;
SpriteNode
.
prototype
.
nodeType
=
"
Sprite
"
;
...
...
@@ -25,29 +25,32 @@ SpriteNode.prototype.build = function ( builder ) {
builder
.
define
(
'
SPRITE
'
);
builder
.
requires
.
lights
=
false
;
builder
.
requires
.
transparent
=
this
.
alpha
!=
undefined
;
builder
.
requires
.
transparent
=
this
.
alpha
!=
=
undefined
;
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
transform
=
this
.
transform
?
this
.
transform
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
transform
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
THREE
.
UniformsLib
[
"
fog
"
]
THREE
.
UniformsLib
.
fog
]
)
);
builder
.
addParsCode
(
[
"
#include <fog_pars_vertex>
"
"
#include <fog_pars_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
,
"
#include <clipping_planes_pars_vertex>
"
].
join
(
"
\n
"
)
);
output
=
[
"
#include <clipping_planes_fragment>
"
,
"
#include <begin_vertex>
"
];
if
(
transform
)
{
if
(
position
)
{
output
.
push
(
transform
.
code
,
transform
.
result
?
"
transformed =
"
+
transform
.
result
+
"
;
"
:
''
position
.
code
,
position
.
result
?
"
transformed =
"
+
position
.
result
+
"
;
"
:
''
);
}
...
...
@@ -98,43 +101,64 @@ SpriteNode.prototype.build = function ( builder ) {
'
modelViewMtx[2][1] = 0.0;
'
,
'
modelViewMtx[2][2] = 1.0;
'
,
// apply
'
gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( transformed, 1.0 );
'
"
gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( transformed, 1.0 );
"
,
"
#include <logdepthbuf_vertex>
"
,
"
#include <clipping_planes_vertex>
"
,
"
#include <fog_vertex>
"
);
}
else
{
builder
.
addParsCode
(
[
"
#include <fog_pars_fragment>
"
,
"
#include <logdepthbuf_pars_fragment>
"
,
"
#include <clipping_planes_pars_fragment>
"
].
join
(
"
\n
"
)
);
// parse all nodes to reuse generate codes
builder
.
addCode
(
[
"
#include <clipping_planes_fragment>
"
,
"
#include <logdepthbuf_fragment>
"
].
join
(
"
\n
"
)
);
this
.
color
.
parse
(
builder
,
{
slot
:
'
color
'
}
);
// parse all nodes to reuse generate codes
if
(
this
.
alpha
)
this
.
alpha
.
parse
(
builder
);
// build code
this
.
color
.
parse
(
builder
,
{
slot
:
'
color
'
}
);
var
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
);
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
// build code
output
=
[
color
.
code
];
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
,
color
=
this
.
color
.
buildCode
(
builder
,
'
c
'
,
{
slot
:
'
color
'
}
);
if
(
alpha
)
{
output
.
push
(
output
=
[
alpha
.
code
,
'
#ifdef ALPHATEST
'
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
,
'
#endif
'
,
color
.
code
,
"
gl_FragColor = vec4(
"
+
color
.
result
+
"
,
"
+
alpha
.
result
+
"
);
"
)
;
]
;
}
else
{
output
.
push
(
"
gl_FragColor = vec4(
"
+
color
.
result
+
"
, 1.0 );
"
);
output
=
[
color
.
code
,
"
gl_FragColor = vec4(
"
+
color
.
result
+
"
, 1.0 );
"
];
}
output
.
push
(
"
#include <fog_fragment>
"
);
output
.
push
(
"
#include <tonemapping_fragment>
"
,
"
#include <encodings_fragment>
"
,
"
#include <fog_fragment>
"
);
}
...
...
@@ -143,19 +167,19 @@ SpriteNode.prototype.build = function ( builder ) {
};
SpriteNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
// vertex
if
(
source
.
transform
)
this
.
transform
=
source
.
transform
;
if
(
source
.
position
)
this
.
position
=
source
.
position
;
// fragment
this
.
color
=
source
.
color
;
if
(
source
.
spherical
!==
undefined
)
this
.
spherical
=
source
.
transform
;
if
(
source
.
spherical
!==
undefined
)
this
.
spherical
=
source
.
spherical
;
if
(
source
.
alpha
)
this
.
alpha
=
source
.
alpha
;
};
...
...
@@ -170,12 +194,12 @@ SpriteNode.prototype.toJSON = function ( meta ) {
// vertex
if
(
this
.
transform
)
data
.
transform
=
this
.
transform
.
toJSON
(
meta
).
uuid
;
if
(
this
.
position
)
data
.
position
=
this
.
position
.
toJSON
(
meta
).
uuid
;
// fragment
data
.
color
=
this
.
color
.
toJSON
(
meta
).
uuid
;
if
(
this
.
spherical
===
false
)
data
.
spherical
=
false
;
if
(
this
.
alpha
)
data
.
alpha
=
this
.
alpha
.
toJSON
(
meta
).
uuid
;
...
...
examples/js/nodes/materials/nodes/StandardNode.js
浏览文件 @
9b26302c
...
...
@@ -2,22 +2,22 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
../../core/GL
Node.js
'
;
import
{
Node
}
from
'
../../core/
Node.js
'
;
import
{
ColorNode
}
from
'
../../inputs/ColorNode.js
'
;
import
{
FloatNode
}
from
'
../../inputs/FloatNode.js
'
;
import
{
RoughnessToBlinnExponentNode
}
from
'
../../bsdfs/RoughnessToBlinnExponentNode.js
'
;
function
StandardNode
()
{
GL
Node
.
call
(
this
);
Node
.
call
(
this
);
this
.
color
=
new
ColorNode
(
0xEEEEEE
);
this
.
roughness
=
new
FloatNode
(
0.5
);
this
.
metalness
=
new
FloatNode
(
0.5
);
}
;
}
StandardNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
StandardNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
StandardNode
.
prototype
.
constructor
=
StandardNode
;
StandardNode
.
prototype
.
nodeType
=
"
Standard
"
;
...
...
@@ -26,7 +26,6 @@ StandardNode.prototype.build = function ( builder ) {
var
code
;
builder
.
define
(
this
.
clearCoat
||
this
.
clearCoatRoughness
?
'
PHYSICAL
'
:
'
STANDARD
'
);
builder
.
define
(
'
ALPHATEST
'
,
'
0.0
'
);
builder
.
requires
.
lights
=
true
;
...
...
@@ -34,12 +33,12 @@ StandardNode.prototype.build = function ( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
transform
=
this
.
transform
?
this
.
transform
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
transform
'
}
)
:
undefined
;
var
position
=
this
.
position
?
this
.
position
.
parseAndBuildCode
(
builder
,
'
v3
'
,
{
cache
:
'
position
'
}
)
:
undefined
;
builder
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
THREE
.
UniformsLib
[
"
fog
"
]
,
THREE
.
UniformsLib
[
"
lights
"
]
THREE
.
UniformsLib
.
fog
,
THREE
.
UniformsLib
.
lights
]
)
);
...
...
@@ -52,13 +51,13 @@ StandardNode.prototype.build = function ( builder ) {
"
#endif
"
,
"
#include <common>
"
,
"
#include <encodings_pars_fragment>
"
,
// encoding functions
//"#include <encodings_pars_fragment>", // encoding functions
"
#include <fog_pars_vertex>
"
,
"
#include <morphtarget_pars_vertex>
"
,
"
#include <skinning_pars_vertex>
"
,
"
#include <shadowmap_pars_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
"
#include <logdepthbuf_pars_vertex>
"
,
"
#include <clipping_planes_pars_vertex>
"
].
join
(
"
\n
"
)
);
...
...
@@ -68,9 +67,6 @@ StandardNode.prototype.build = function ( builder ) {
"
#include <skinbase_vertex>
"
,
"
#include <skinnormal_vertex>
"
,
"
#include <defaultnormal_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
,
"
#include <logdepthbuf_pars_vertex>
"
,
"
#ifndef FLAT_SHADED
"
,
// Normal computed with derivatives when FLAT_SHADED
...
...
@@ -81,11 +77,11 @@ StandardNode.prototype.build = function ( builder ) {
"
#include <begin_vertex>
"
];
if
(
transform
)
{
if
(
position
)
{
output
.
push
(
transform
.
code
,
transform
.
result
?
"
transformed =
"
+
transform
.
result
+
"
;
"
:
''
position
.
code
,
position
.
result
?
"
transformed =
"
+
position
.
result
+
"
;
"
:
''
);
}
...
...
@@ -96,6 +92,7 @@ StandardNode.prototype.build = function ( builder ) {
"
#include <project_vertex>
"
,
"
#include <fog_vertex>
"
,
"
#include <logdepthbuf_vertex>
"
,
"
#include <clipping_planes_vertex>
"
,
"
vViewPosition = - mvPosition.xyz;
"
,
...
...
@@ -127,7 +124,6 @@ StandardNode.prototype.build = function ( builder ) {
if
(
this
.
alpha
)
this
.
alpha
.
parse
(
builder
);
if
(
this
.
normal
)
this
.
normal
.
parse
(
builder
);
if
(
this
.
normalScale
&&
this
.
normal
)
this
.
normalScale
.
parse
(
builder
);
if
(
this
.
clearCoat
)
this
.
clearCoat
.
parse
(
builder
);
if
(
this
.
clearCoatRoughness
)
this
.
clearCoatRoughness
.
parse
(
builder
);
...
...
@@ -152,7 +148,6 @@ StandardNode.prototype.build = function ( builder ) {
var
alpha
=
this
.
alpha
?
this
.
alpha
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
normal
=
this
.
normal
?
this
.
normal
.
buildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
normalScale
=
this
.
normalScale
&&
this
.
normal
?
this
.
normalScale
.
buildCode
(
builder
,
'
v2
'
)
:
undefined
;
var
clearCoat
=
this
.
clearCoat
?
this
.
clearCoat
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
var
clearCoatRoughness
=
this
.
clearCoatRoughness
?
this
.
clearCoatRoughness
.
buildCode
(
builder
,
'
f
'
)
:
undefined
;
...
...
@@ -182,7 +177,7 @@ StandardNode.prototype.build = function ( builder ) {
"
#endif
"
,
"
#include <
common
>
"
,
"
#include <
dithering_pars_fragment
>
"
,
"
#include <fog_pars_fragment>
"
,
"
#include <bsdfs>
"
,
"
#include <lights_pars_begin>
"
,
...
...
@@ -193,10 +188,12 @@ StandardNode.prototype.build = function ( builder ) {
].
join
(
"
\n
"
)
);
var
output
=
[
// prevent undeclared normal
"
#include <clipping_planes_fragment>
"
,
// add before: prevent undeclared normal
"
#include <normal_fragment_begin>
"
,
// prevent undeclared material
//
add before:
prevent undeclared material
"
PhysicalMaterial material;
"
,
"
material.diffuseColor = vec3( 1.0 );
"
,
...
...
@@ -217,7 +214,11 @@ StandardNode.prototype.build = function ( builder ) {
output
.
push
(
alpha
.
code
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
'
#ifdef ALPHATEST
'
,
'
if (
'
+
alpha
.
result
+
'
<= ALPHATEST ) discard;
'
,
'
#endif
'
);
}
...
...
@@ -228,7 +229,7 @@ StandardNode.prototype.build = function ( builder ) {
normal
.
code
,
'
normal =
'
+
normal
.
result
+
'
;
'
);
}
// optimization for now
...
...
@@ -356,7 +357,7 @@ StandardNode.prototype.build = function ( builder ) {
output
.
push
(
"
radiance +=
"
+
environment
.
result
+
"
;
"
);
}
output
.
push
(
"
#include <lights_fragment_end>
"
);
...
...
@@ -374,7 +375,6 @@ StandardNode.prototype.build = function ( builder ) {
}
output
.
push
(
"
#include <premultiplied_alpha_fragment>
"
,
"
#include <tonemapping_fragment>
"
,
"
#include <encodings_fragment>
"
,
"
#include <fog_fragment>
"
,
...
...
@@ -391,12 +391,12 @@ StandardNode.prototype.build = function ( builder ) {
};
StandardNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
// vertex
if
(
source
.
transform
)
this
.
transform
=
source
.
transform
;
if
(
source
.
position
)
this
.
position
=
source
.
position
;
// fragment
...
...
@@ -417,7 +417,7 @@ StandardNode.prototype.copy = function ( source ) {
if
(
source
.
shadow
)
this
.
shadow
=
source
.
shadow
;
if
(
source
.
ao
)
this
.
ao
=
source
.
ao
;
if
(
source
.
emissive
)
this
.
emissive
=
source
.
emissive
;
if
(
source
.
ambient
)
this
.
ambient
=
source
.
ambient
;
...
...
@@ -435,7 +435,7 @@ StandardNode.prototype.toJSON = function ( meta ) {
// vertex
if
(
this
.
transform
)
data
.
transform
=
this
.
transform
.
toJSON
(
meta
).
uuid
;
if
(
this
.
position
)
data
.
position
=
this
.
position
.
toJSON
(
meta
).
uuid
;
// fragment
...
...
@@ -456,7 +456,7 @@ StandardNode.prototype.toJSON = function ( meta ) {
if
(
this
.
shadow
)
data
.
shadow
=
this
.
shadow
.
toJSON
(
meta
).
uuid
;
if
(
this
.
ao
)
data
.
ao
=
this
.
ao
.
toJSON
(
meta
).
uuid
;
if
(
this
.
emissive
)
data
.
emissive
=
this
.
emissive
.
toJSON
(
meta
).
uuid
;
if
(
this
.
ambient
)
data
.
ambient
=
this
.
ambient
.
toJSON
(
meta
).
uuid
;
...
...
examples/js/nodes/math/CondNode.js
0 → 100644
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
CondNode
(
a
,
b
,
ifNode
,
elseNode
,
op
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
b
=
b
;
this
.
ifNode
=
ifNode
;
this
.
elseNode
=
elseNode
;
this
.
op
=
op
;
}
CondNode
.
EQUAL
=
'
==
'
;
CondNode
.
NOT_EQUAL
=
'
!=
'
;
CondNode
.
GREATER
=
'
>
'
;
CondNode
.
GREATER_EQUAL
=
'
>=
'
;
CondNode
.
LESS
=
'
<
'
;
CondNode
.
LESS_EQUAL
=
'
<=
'
;
CondNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
CondNode
.
prototype
.
constructor
=
CondNode
;
CondNode
.
prototype
.
nodeType
=
"
Cond
"
;
CondNode
.
prototype
.
getType
=
function
(
builder
)
{
if
(
builder
.
getTypeLength
(
this
.
elseNode
.
getType
(
builder
)
)
>
builder
.
getTypeLength
(
this
.
ifNode
.
getType
(
builder
)
)
)
{
return
this
.
elseNode
.
getType
(
builder
);
}
return
this
.
ifNode
.
getType
(
builder
);
};
CondNode
.
prototype
.
getCondType
=
function
(
builder
)
{
if
(
builder
.
getTypeLength
(
this
.
b
.
getType
(
builder
)
)
>
builder
.
getTypeLength
(
this
.
a
.
getType
(
builder
)
)
)
{
return
this
.
b
.
getType
(
builder
);
}
return
this
.
a
.
getType
(
builder
);
};
CondNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
type
=
this
.
getType
(
builder
),
condType
=
this
.
getCondType
(
builder
),
a
=
this
.
a
.
build
(
builder
,
condType
),
b
=
this
.
b
.
build
(
builder
,
condType
),
ifNode
=
this
.
ifNode
.
build
(
builder
,
type
),
elseNode
=
this
.
elseNode
.
build
(
builder
,
type
);
var
code
=
'
(
'
+
[
a
,
this
.
op
,
b
,
'
?
'
,
ifNode
,
'
:
'
,
elseNode
].
join
(
'
'
)
+
'
)
'
;
return
builder
.
format
(
code
,
this
.
getType
(
builder
),
output
);
};
CondNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
ifNode
=
source
.
ifNode
;
this
.
elseNode
=
source
.
elseNode
;
this
.
op
=
source
.
op
;
};
CondNode
.
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
.
ifNode
=
this
.
ifNode
.
toJSON
(
meta
).
uuid
;
data
.
elseNode
=
this
.
elseNode
.
toJSON
(
meta
).
uuid
;
data
.
op
=
this
.
op
;
}
return
data
;
};
export
{
CondNode
};
examples/js/nodes/math/Math1Node.js
浏览文件 @
9b26302c
...
...
@@ -10,9 +10,9 @@ function Math1Node( a, method ) {
this
.
a
=
a
;
this
.
method
=
method
||
Math1Node
.
SIN
;
this
.
method
=
method
;
}
;
}
Math1Node
.
RAD
=
'
radians
'
;
Math1Node
.
DEG
=
'
degrees
'
;
...
...
@@ -48,7 +48,7 @@ Math1Node.prototype.getType = function ( builder ) {
switch
(
this
.
method
)
{
case
Math1Node
.
LENGTH
:
return
'
f
'
;
}
...
...
@@ -65,21 +65,21 @@ Math1Node.prototype.generate = function ( builder, output ) {
switch
(
this
.
method
)
{
case
Math1Node
.
NEGATE
:
result
=
'
( -
'
+
result
+
'
)
'
;
break
;
case
Math1Node
.
INVERT
:
result
=
'
( 1.0 -
'
+
result
+
'
)
'
;
break
;
default
:
result
=
this
.
method
+
'
(
'
+
result
+
'
)
'
;
break
;
}
...
...
@@ -89,12 +89,12 @@ Math1Node.prototype.generate = function ( builder, 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
)
{
...
...
examples/js/nodes/math/Math2Node.js
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
Math2Node
(
a
,
b
,
method
)
{
...
...
@@ -11,9 +11,9 @@ function Math2Node( a, b, method ) {
this
.
a
=
a
;
this
.
b
=
b
;
this
.
method
=
method
||
Math2Node
.
DISTANCE
;
this
.
method
=
method
;
}
;
}
Math2Node
.
MIN
=
'
min
'
;
Math2Node
.
MAX
=
'
max
'
;
...
...
@@ -32,7 +32,7 @@ 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
);
...
...
@@ -49,11 +49,11 @@ Math2Node.prototype.getType = function ( builder ) {
case
Math2Node
.
DISTANCE
:
case
Math2Node
.
DOT
:
return
'
f
'
;
case
Math2Node
.
CROSS
:
return
'
v3
'
;
}
...
...
@@ -64,43 +64,43 @@ Math2Node.prototype.getType = function ( builder ) {
Math2Node
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
a
,
b
,
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
;
}
...
...
@@ -110,13 +110,13 @@ Math2Node.prototype.generate = function ( 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
)
{
...
...
examples/js/nodes/math/Math3Node.js
浏览文件 @
9b26302c
/**
* @author sunag / http://www.sunag.com.br/
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
Math3Node
(
a
,
b
,
c
,
method
)
{
...
...
@@ -12,9 +12,9 @@ function Math3Node( a, b, c, method ) {
this
.
b
=
b
;
this
.
c
=
c
;
this
.
method
=
method
||
Math3Node
.
MIX
;
this
.
method
=
method
;
}
;
}
Math3Node
.
MIX
=
'
mix
'
;
Math3Node
.
REFRACT
=
'
refract
'
;
...
...
@@ -32,13 +32,13 @@ Math3Node.prototype.getType = function ( 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
);
...
...
@@ -58,27 +58,27 @@ Math3Node.prototype.generate = function ( builder, output ) {
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
;
}
...
...
@@ -88,14 +88,14 @@ Math3Node.prototype.generate = function ( builder, 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
)
{
...
...
examples/js/nodes/math/OperatorNode.js
浏览文件 @
9b26302c
...
...
@@ -3,16 +3,16 @@
*/
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
function
OperatorNode
(
a
,
b
,
op
)
{
TempNode
.
call
(
this
);
this
.
a
=
a
;
this
.
b
=
b
;
this
.
op
=
op
||
OperatorNode
.
ADD
;
this
.
op
=
op
;
}
;
}
OperatorNode
.
ADD
=
'
+
'
;
OperatorNode
.
SUB
=
'
-
'
;
...
...
@@ -52,18 +52,18 @@ OperatorNode.prototype.generate = function ( builder, output ) {
var
a
=
this
.
a
.
build
(
builder
,
type
),
b
=
this
.
b
.
build
(
builder
,
type
);
return
builder
.
format
(
'
(
'
+
a
+
'
'
+
this
.
op
+
'
'
+
b
+
'
)
'
,
type
,
output
);
return
builder
.
format
(
'
(
'
+
a
+
'
'
+
this
.
op
+
'
'
+
b
+
'
)
'
,
type
,
output
);
};
OperatorNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
a
=
source
.
a
;
this
.
b
=
source
.
b
;
this
.
op
=
source
.
op
;
};
OperatorNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/misc/BumpMapNode.js
浏览文件 @
9b26302c
...
...
@@ -16,31 +16,31 @@ function BumpMapNode( value, scale ) {
this
.
scale
=
scale
||
new
FloatNode
(
1
);
this
.
toNormalMap
=
false
;
};
BumpMapNode
.
Nodes
=
(
function
()
{
}
BumpMapNode
.
Nodes
=
(
function
()
{
var
dHdxy_fwd
=
new
FunctionNode
(
[
// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen
// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf
// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)
"
vec2 dHdxy_fwd( sampler2D bumpMap, vec2 vUv, float bumpScale ) {
"
,
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
"
vec2 dSTdx = dFdx( vUv );
"
,
"
vec2 dSTdy = dFdy( vUv );
"
,
"
float Hll = bumpScale * texture2D( bumpMap, vUv ).x;
"
,
"
float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;
"
,
"
float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;
"
,
"
return vec2( dBx, dBy );
"
,
"
}
"
].
join
(
"
\n
"
),
null
,
{
derivatives
:
true
}
);
...
...
@@ -50,20 +50,20 @@ BumpMapNode.Nodes = (function() {
"
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {
"
,
// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988
"
vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );
"
,
"
vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );
"
,
"
vec3 vN = surf_norm;
"
,
// normalized
"
vec3 R1 = cross( vSigmaY, vN );
"
,
"
vec3 R2 = cross( vN, vSigmaX );
"
,
"
float fDet = dot( vSigmaX, R1 );
"
,
"
fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );
"
,
"
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
"
,
"
return normalize( abs( fDet ) * surf_norm - vGrad );
"
,
"
}
"
...
...
@@ -72,26 +72,26 @@ BumpMapNode.Nodes = (function() {
var
bumpToNormal
=
new
FunctionNode
(
[
"
vec3 bumpToNormal( sampler2D bumpMap, vec2 uv, float scale ) {
"
,
"
vec2 dSTdx = dFdx( uv );
"
,
"
vec2 dSTdy = dFdy( uv );
"
,
"
float Hll = texture2D( bumpMap, uv ).x;
"
,
"
float dBx = texture2D( bumpMap, uv + dSTdx ).x - Hll;
"
,
"
float dBy = texture2D( bumpMap, uv + dSTdy ).x - Hll;
"
,
"
return vec3( .5 - ( dBx * scale ), .5 - ( dBy * scale ), 1.0 );
"
,
"
}
"
].
join
(
"
\n
"
),
null
,
{
derivatives
:
true
}
);
return
{
dHdxy_fwd
:
dHdxy_fwd
,
perturbNormalArb
:
perturbNormalArb
,
bumpToNormal
:
bumpToNormal
};
})();
}
)();
BumpMapNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
BumpMapNode
.
prototype
.
constructor
=
BumpMapNode
;
...
...
@@ -102,21 +102,21 @@ BumpMapNode.prototype.generate = function ( builder, output ) {
if
(
builder
.
isShader
(
'
fragment
'
)
)
{
if
(
this
.
toNormalMap
)
{
var
bumpToNormal
=
builder
.
include
(
BumpMapNode
.
Nodes
.
bumpToNormal
);
return
builder
.
format
(
bumpToNormal
+
'
(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
this
.
value
.
uv
.
build
(
builder
,
'
v2
'
)
+
'
,
'
+
this
.
scale
.
build
(
builder
,
'
f
'
)
+
'
)
'
,
this
.
getType
(
builder
),
output
);
}
else
{
var
derivativeHeight
=
builder
.
include
(
BumpMapNode
.
Nodes
.
dHdxy_fwd
),
perturbNormalArb
=
builder
.
include
(
BumpMapNode
.
Nodes
.
perturbNormalArb
);
this
.
normal
=
this
.
normal
||
new
NormalNode
(
NormalNode
.
VIEW
);
this
.
normal
=
this
.
normal
||
new
NormalNode
();
this
.
position
=
this
.
position
||
new
PositionNode
(
PositionNode
.
VIEW
);
var
derivativeHeightCode
=
derivativeHeight
+
'
(
'
+
this
.
value
.
build
(
builder
,
'
sampler2D
'
)
+
'
,
'
+
this
.
value
.
uv
.
build
(
builder
,
'
v2
'
)
+
'
,
'
+
this
.
scale
.
build
(
builder
,
'
f
'
)
+
'
)
'
;
...
...
@@ -124,7 +124,7 @@ BumpMapNode.prototype.generate = function ( builder, output ) {
return
builder
.
format
(
perturbNormalArb
+
'
( -
'
+
this
.
position
.
build
(
builder
,
'
v3
'
)
+
'
,
'
+
this
.
normal
.
build
(
builder
,
'
v3
'
)
+
'
,
'
+
derivativeHeightCode
+
'
)
'
,
this
.
getType
(
builder
),
output
);
}
}
else
{
...
...
@@ -138,12 +138,12 @@ BumpMapNode.prototype.generate = function ( builder, output ) {
};
BumpMapNode
.
prototype
.
copy
=
function
(
source
)
{
TempNode
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
value
=
source
.
value
;
this
.
scale
=
source
.
scale
;
};
BumpMapNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/misc/NormalMapNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/misc/TextureCubeNode.js
浏览文件 @
9b26302c
...
...
@@ -4,7 +4,7 @@
import
{
TempNode
}
from
'
../core/TempNode.js
'
;
import
{
TextureCubeUVNode
}
from
'
./TextureCubeUVNode.js
'
;
function
TextureCubeNode
(
value
,
uv
)
{
TempNode
.
call
(
this
,
'
v4
'
);
...
...
@@ -12,7 +12,7 @@ function TextureCubeNode( value, uv ) {
this
.
value
=
value
;
this
.
uv
=
uv
||
new
TextureCubeUVNode
();
}
;
}
TextureCubeNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
TextureCubeNode
.
prototype
.
constructor
=
TextureCubeNode
;
...
...
@@ -25,12 +25,12 @@ TextureCubeNode.prototype.generate = function ( builder, output ) {
var
uv_10
=
this
.
uv
.
build
(
builder
)
+
'
.uv_10
'
,
uv_20
=
this
.
uv
.
build
(
builder
)
+
'
.uv_20
'
,
t
=
this
.
uv
.
build
(
builder
)
+
'
.t
'
;
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
);
return
builder
.
format
(
'
vec4( mix(
'
+
color10
+
'
,
'
+
color20
+
'
,
'
+
t
+
'
).rgb, 1.0 )
'
,
this
.
getType
(
builder
),
output
);
}
else
{
console
.
warn
(
"
THREE.TextureCubeNode is not compatible with
"
+
builder
.
shader
+
"
shader.
"
);
...
...
examples/js/nodes/misc/TextureCubeUVNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/postprocessing/NodePass.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/postprocessing/NodePostProcessing.js
0 → 100644
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/procedural/CheckerNode.js
0 → 100644
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/procedural/NoiseNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/BypassNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/ColorSpaceNode.js
0 → 100644
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/JoinNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/MaxMIPLevelNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/SwitchNode.js
浏览文件 @
9b26302c
...
...
@@ -2,18 +2,18 @@
* @author sunag / http://www.sunag.com.br/
*/
import
{
GLNode
}
from
'
../core/GL
Node.js
'
;
import
{
Node
}
from
'
../core/
Node.js
'
;
function
SwitchNode
(
node
,
components
)
{
GL
Node
.
call
(
this
);
Node
.
call
(
this
);
this
.
node
=
node
;
this
.
components
=
components
||
'
x
'
;
}
;
}
SwitchNode
.
prototype
=
Object
.
create
(
GL
Node
.
prototype
);
SwitchNode
.
prototype
=
Object
.
create
(
Node
.
prototype
);
SwitchNode
.
prototype
.
constructor
=
SwitchNode
;
SwitchNode
.
prototype
.
nodeType
=
"
Switch
"
;
...
...
@@ -74,12 +74,12 @@ SwitchNode.prototype.generate = function ( builder, output ) {
};
SwitchNode
.
prototype
.
copy
=
function
(
source
)
{
GL
Node
.
prototype
.
copy
.
call
(
this
,
source
);
Node
.
prototype
.
copy
.
call
(
this
,
source
);
this
.
node
=
source
.
node
;
this
.
components
=
source
.
components
;
};
SwitchNode
.
prototype
.
toJSON
=
function
(
meta
)
{
...
...
examples/js/nodes/utils/TimerNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/UVTransformNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/js/nodes/utils/VelocityNode.js
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/nodes/displace.json
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/nodes/wave.json
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_loader_nodes.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_materials_compile.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_materials_nodes.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_mirror_nodes.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_performance_nodes.html
0 → 100644
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_postprocessing_nodes.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_postprocessing_nodes_pass.html
0 → 100644
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
examples/webgl_sprites_nodes.html
浏览文件 @
9b26302c
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录