Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
805d92d7
T
three.js
项目概览
车家大少爷
/
three.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
three.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
805d92d7
编写于
12月 25, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7849 from sunag/dev
NodeMaterial auto cache JoinNode and cleanup
上级
ccd048ee
f7a086cf
变更
24
隐藏空白更改
内联
并排
Showing
24 changed file
with
95 addition
and
103 deletion
+95
-103
examples/js/nodes/ConstNode.js
examples/js/nodes/ConstNode.js
+3
-3
examples/js/nodes/NodeMaterial.js
examples/js/nodes/NodeMaterial.js
+25
-21
examples/js/nodes/accessors/CameraNode.js
examples/js/nodes/accessors/CameraNode.js
+3
-3
examples/js/nodes/accessors/ColorsNode.js
examples/js/nodes/accessors/ColorsNode.js
+3
-3
examples/js/nodes/accessors/NormalNode.js
examples/js/nodes/accessors/NormalNode.js
+3
-3
examples/js/nodes/accessors/PositionNode.js
examples/js/nodes/accessors/PositionNode.js
+3
-3
examples/js/nodes/accessors/UVNode.js
examples/js/nodes/accessors/UVNode.js
+3
-3
examples/js/nodes/inputs/ColorNode.js
examples/js/nodes/inputs/ColorNode.js
+1
-1
examples/js/nodes/inputs/Vector2Node.js
examples/js/nodes/inputs/Vector2Node.js
+1
-1
examples/js/nodes/inputs/Vector3Node.js
examples/js/nodes/inputs/Vector3Node.js
+1
-1
examples/js/nodes/inputs/Vector4Node.js
examples/js/nodes/inputs/Vector4Node.js
+1
-1
examples/js/nodes/materials/PhongNode.js
examples/js/nodes/materials/PhongNode.js
+6
-6
examples/js/nodes/materials/PhongNodeMaterial.js
examples/js/nodes/materials/PhongNodeMaterial.js
+2
-2
examples/js/nodes/materials/StandardNode.js
examples/js/nodes/materials/StandardNode.js
+1
-10
examples/js/nodes/materials/StandardNodeMaterial.js
examples/js/nodes/materials/StandardNodeMaterial.js
+2
-2
examples/js/nodes/math/Math1Node.js
examples/js/nodes/math/Math1Node.js
+3
-3
examples/js/nodes/math/Math2Node.js
examples/js/nodes/math/Math2Node.js
+3
-3
examples/js/nodes/math/Math3Node.js
examples/js/nodes/math/Math3Node.js
+3
-3
examples/js/nodes/math/OperatorNode.js
examples/js/nodes/math/OperatorNode.js
+4
-5
examples/js/nodes/postprocessing/NodePass.js
examples/js/nodes/postprocessing/NodePass.js
+2
-3
examples/js/nodes/utils/JoinNode.js
examples/js/nodes/utils/JoinNode.js
+4
-4
examples/js/nodes/utils/NormalMapNode.js
examples/js/nodes/utils/NormalMapNode.js
+1
-1
examples/js/nodes/utils/SwitchNode.js
examples/js/nodes/utils/SwitchNode.js
+13
-14
examples/webgl_materials_nodes.html
examples/webgl_materials_nodes.html
+4
-4
未找到文件。
examples/js/nodes/ConstNode.js
浏览文件 @
805d92d7
...
...
@@ -10,9 +10,6 @@ THREE.ConstNode = function( name, useDefine ) {
};
THREE
.
ConstNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
ConstNode
.
prototype
.
constructor
=
THREE
.
ConstNode
;
THREE
.
ConstNode
.
PI
=
'
PI
'
;
THREE
.
ConstNode
.
PI2
=
'
PI2
'
;
THREE
.
ConstNode
.
RECIPROCAL_PI
=
'
RECIPROCAL_PI
'
;
...
...
@@ -20,6 +17,9 @@ THREE.ConstNode.RECIPROCAL_PI2 = 'RECIPROCAL_PI2';
THREE
.
ConstNode
.
LOG2
=
'
LOG2
'
;
THREE
.
ConstNode
.
EPSILON
=
'
EPSILON
'
;
THREE
.
ConstNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
ConstNode
.
prototype
.
constructor
=
THREE
.
ConstNode
;
THREE
.
ConstNode
.
prototype
.
parse
=
function
(
src
,
useDefine
)
{
var
name
,
type
;
...
...
examples/js/nodes/NodeMaterial.js
浏览文件 @
805d92d7
...
...
@@ -11,10 +11,7 @@ THREE.NodeMaterial = function( vertex, fragment ) {
};
THREE
.
NodeMaterial
.
prototype
=
Object
.
create
(
THREE
.
ShaderMaterial
.
prototype
);
THREE
.
NodeMaterial
.
prototype
.
constructor
=
THREE
.
NodeMaterial
;
THREE
.
NodeMaterial
.
Type
=
{
THREE
.
NodeMaterial
.
types
=
{
t
:
'
sampler2D
'
,
tc
:
'
samplerCube
'
,
bv1
:
'
bool
'
,
...
...
@@ -26,39 +23,46 @@ THREE.NodeMaterial.Type = {
v4
:
'
vec4
'
};
THREE
.
NodeMaterial
.
GetShortcuts
=
function
(
prop
,
name
)
{
THREE
.
NodeMaterial
.
addShortcuts
=
function
(
proto
,
prop
,
list
)
{
return
{
get
:
function
()
{
function
applyShortcut
(
prop
,
name
)
{
return
this
[
prop
][
name
];
return
{
get
:
function
()
{
},
set
:
function
(
val
)
{
return
this
[
prop
][
name
];
this
[
prop
][
name
]
=
val
;
},
set
:
function
(
val
)
{
this
[
prop
][
name
]
=
val
;
}
};
}
};
};
return
(
function
()
{
THREE
.
NodeMaterial
.
Shortcuts
=
function
(
proto
,
prop
,
list
)
{
var
shortcuts
=
{};
var
shortcuts
=
{};
for
(
var
i
=
0
;
i
<
list
.
length
;
++
i
)
{
for
(
var
i
=
0
;
i
<
list
.
length
;
++
i
)
{
var
name
=
list
[
i
];
var
name
=
list
[
i
]
;
shortcuts
[
name
]
=
applyShortcut
(
prop
,
name
)
;
shortcuts
[
name
]
=
this
.
GetShortcuts
(
prop
,
name
);
}
}
Object
.
defineProperties
(
proto
,
shortcuts
);
Object
.
defineProperties
(
proto
,
shortcuts
);
})(
);
};
THREE
.
NodeMaterial
.
prototype
=
Object
.
create
(
THREE
.
ShaderMaterial
.
prototype
);
THREE
.
NodeMaterial
.
prototype
.
constructor
=
THREE
.
NodeMaterial
;
THREE
.
NodeMaterial
.
prototype
.
updateAnimation
=
function
(
delta
)
{
for
(
var
i
=
0
;
i
<
this
.
requestUpdate
.
length
;
++
i
)
{
...
...
@@ -388,7 +392,7 @@ THREE.NodeMaterial.prototype.getCodePars = function( pars, prefix ) {
if
(
parsType
==
'
t
'
&&
parsValue
instanceof
THREE
.
CubeTexture
)
parsType
=
'
tc
'
;
var
type
=
THREE
.
NodeMaterial
.
Type
[
parsType
];
var
type
=
THREE
.
NodeMaterial
.
types
[
parsType
];
if
(
type
==
undefined
)
throw
new
Error
(
"
Node pars
"
+
parsType
+
"
not found.
"
);
...
...
examples/js/nodes/accessors/CameraNode.js
浏览文件 @
805d92d7
...
...
@@ -11,12 +11,12 @@ THREE.CameraNode = function( scope, camera ) {
};
THREE
.
CameraNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
CameraNode
.
prototype
.
constructor
=
THREE
.
CameraNode
;
THREE
.
CameraNode
.
POSITION
=
'
position
'
;
THREE
.
CameraNode
.
DEPTH
=
'
depth
'
;
THREE
.
CameraNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
CameraNode
.
prototype
.
constructor
=
THREE
.
CameraNode
;
THREE
.
CameraNode
.
prototype
.
setCamera
=
function
(
camera
)
{
this
.
camera
=
camera
;
...
...
examples/js/nodes/accessors/ColorsNode.js
浏览文件 @
805d92d7
...
...
@@ -10,12 +10,12 @@ THREE.ColorsNode = function( index ) {
};
THREE
.
ColorsNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
ColorsNode
.
prototype
.
constructor
=
THREE
.
ColorsNode
;
THREE
.
ColorsNode
.
vertexDict
=
[
'
color
'
,
'
color2
'
];
THREE
.
ColorsNode
.
fragmentDict
=
[
'
vColor
'
,
'
vColor2
'
];
THREE
.
ColorsNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
ColorsNode
.
prototype
.
constructor
=
THREE
.
ColorsNode
;
THREE
.
ColorsNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
material
=
builder
.
material
;
...
...
examples/js/nodes/accessors/NormalNode.js
浏览文件 @
805d92d7
...
...
@@ -10,13 +10,13 @@ THREE.NormalNode = function( scope ) {
};
THREE
.
NormalNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
NormalNode
.
prototype
.
constructor
=
THREE
.
NormalNode
;
THREE
.
NormalNode
.
LOCAL
=
'
local
'
;
THREE
.
NormalNode
.
WORLD
=
'
world
'
;
THREE
.
NormalNode
.
VIEW
=
'
view
'
;
THREE
.
NormalNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
NormalNode
.
prototype
.
constructor
=
THREE
.
NormalNode
;
THREE
.
NormalNode
.
prototype
.
isShared
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
examples/js/nodes/accessors/PositionNode.js
浏览文件 @
805d92d7
...
...
@@ -10,14 +10,14 @@ THREE.PositionNode = function( scope ) {
};
THREE
.
PositionNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
PositionNode
.
prototype
.
constructor
=
THREE
.
PositionNode
;
THREE
.
PositionNode
.
LOCAL
=
'
local
'
;
THREE
.
PositionNode
.
WORLD
=
'
world
'
;
THREE
.
PositionNode
.
VIEW
=
'
view
'
;
THREE
.
PositionNode
.
PROJECTION
=
'
projection
'
;
THREE
.
PositionNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
PositionNode
.
prototype
.
constructor
=
THREE
.
PositionNode
;
THREE
.
PositionNode
.
prototype
.
getType
=
function
(
builder
)
{
switch
(
this
.
scope
)
{
...
...
examples/js/nodes/accessors/UVNode.js
浏览文件 @
805d92d7
...
...
@@ -10,12 +10,12 @@ THREE.UVNode = function( index ) {
};
THREE
.
UVNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
UVNode
.
prototype
.
constructor
=
THREE
.
UVNode
;
THREE
.
UVNode
.
vertexDict
=
[
'
uv
'
,
'
uv2
'
];
THREE
.
UVNode
.
fragmentDict
=
[
'
vUv
'
,
'
vUv2
'
];
THREE
.
UVNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
UVNode
.
prototype
.
constructor
=
THREE
.
UVNode
;
THREE
.
UVNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
material
=
builder
.
material
;
...
...
examples/js/nodes/inputs/ColorNode.js
浏览文件 @
805d92d7
...
...
@@ -13,4 +13,4 @@ THREE.ColorNode = function( color ) {
THREE
.
ColorNode
.
prototype
=
Object
.
create
(
THREE
.
InputNode
.
prototype
);
THREE
.
ColorNode
.
prototype
.
constructor
=
THREE
.
ColorNode
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
ColorNode
.
prototype
,
'
value
'
,
[
'
r
'
,
'
g
'
,
'
b
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
ColorNode
.
prototype
,
'
value
'
,
[
'
r
'
,
'
g
'
,
'
b
'
]
);
examples/js/nodes/inputs/Vector2Node.js
浏览文件 @
805d92d7
...
...
@@ -13,4 +13,4 @@ THREE.Vector2Node = function( x, y ) {
THREE
.
Vector2Node
.
prototype
=
Object
.
create
(
THREE
.
InputNode
.
prototype
);
THREE
.
Vector2Node
.
prototype
.
constructor
=
THREE
.
Vector2Node
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
Vector2Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
Vector2Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
]
);
examples/js/nodes/inputs/Vector3Node.js
浏览文件 @
805d92d7
...
...
@@ -14,4 +14,4 @@ THREE.Vector3Node = function( x, y, z ) {
THREE
.
Vector3Node
.
prototype
=
Object
.
create
(
THREE
.
InputNode
.
prototype
);
THREE
.
Vector3Node
.
prototype
.
constructor
=
THREE
.
Vector3Node
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
Vector3Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
,
'
z
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
Vector3Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
,
'
z
'
]
);
examples/js/nodes/inputs/Vector4Node.js
浏览文件 @
805d92d7
...
...
@@ -13,4 +13,4 @@ THREE.Vector4Node = function( x, y, z, w ) {
THREE
.
Vector4Node
.
prototype
=
Object
.
create
(
THREE
.
InputNode
.
prototype
);
THREE
.
Vector4Node
.
prototype
.
constructor
=
THREE
.
Vector4Node
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
Vector4Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
,
'
z
'
,
'
w
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
Vector4Node
.
prototype
,
'
value
'
,
[
'
x
'
,
'
y
'
,
'
z
'
,
'
w
'
]
);
examples/js/nodes/materials/PhongNode.js
浏览文件 @
805d92d7
...
...
@@ -27,7 +27,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
transform
=
this
.
transform
?
this
.
transform
.
verifyAndBuildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
transform
=
this
.
transform
?
this
.
transform
.
verifyAndBuildCode
(
builder
,
'
v3
'
,
'
transform
'
)
:
undefined
;
material
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
...
...
@@ -114,7 +114,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
if
(
this
.
normalScale
&&
this
.
normal
)
this
.
normalScale
.
verify
(
builder
);
if
(
this
.
environment
)
this
.
environment
.
verify
(
builder
);
if
(
this
.
environment
Intensity
&&
this
.
environment
)
this
.
environmentIntensity
.
verify
(
builder
);
if
(
this
.
environment
Alpha
&&
this
.
environment
)
this
.
environmentAlpha
.
verify
(
builder
);
// build code
...
...
@@ -133,7 +133,7 @@ THREE.PhongNode.prototype.build = function( builder ) {
var
normalScale
=
this
.
normalScale
&&
this
.
normal
?
this
.
normalScale
.
buildCode
(
builder
,
'
v2
'
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
buildCode
(
builder
,
'
c
'
)
:
undefined
;
var
environment
Intensity
=
this
.
environmentIntensity
&&
this
.
environment
?
this
.
environmentIntensity
.
buildCode
(
builder
,
'
fv1
'
)
:
undefined
;
var
environment
Alpha
=
this
.
environmentAlpha
&&
this
.
environment
?
this
.
environmentAlpha
.
buildCode
(
builder
,
'
fv1
'
)
:
undefined
;
material
.
requestAttrib
.
transparent
=
alpha
!=
undefined
;
...
...
@@ -236,11 +236,11 @@ THREE.PhongNode.prototype.build = function( builder ) {
output
.
push
(
environment
.
code
);
if
(
environment
Intensity
)
{
if
(
environment
Alpha
)
{
output
.
push
(
environment
Intensity
.
code
);
output
.
push
(
environment
Alpha
.
code
);
output
.
push
(
"
outgoingLight = mix(
"
+
'
outgoingLight
'
+
"
,
"
+
environment
.
result
+
"
,
"
+
environment
Intensity
.
result
+
"
);
"
);
output
.
push
(
"
outgoingLight = mix(
"
+
'
outgoingLight
'
+
"
,
"
+
environment
.
result
+
"
,
"
+
environment
Alpha
.
result
+
"
);
"
);
}
else
{
...
...
examples/js/nodes/materials/PhongNodeMaterial.js
浏览文件 @
805d92d7
...
...
@@ -13,5 +13,5 @@ THREE.PhongNodeMaterial = function() {
THREE
.
PhongNodeMaterial
.
prototype
=
Object
.
create
(
THREE
.
NodeMaterial
.
prototype
);
THREE
.
PhongNodeMaterial
.
prototype
.
constructor
=
THREE
.
PhongNodeMaterial
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
PhongNodeMaterial
.
prototype
,
'
node
'
,
[
'
color
'
,
'
alpha
'
,
'
specular
'
,
'
shininess
'
,
'
normal
'
,
'
normalScale
'
,
'
emissive
'
,
'
ambient
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
environment
Intensity
'
,
'
transform
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
PhongNodeMaterial
.
prototype
,
'
node
'
,
[
'
color
'
,
'
alpha
'
,
'
specular
'
,
'
shininess
'
,
'
normal
'
,
'
normalScale
'
,
'
emissive
'
,
'
ambient
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
environment
Alpha
'
,
'
transform
'
]
);
examples/js/nodes/materials/StandardNode.js
浏览文件 @
805d92d7
...
...
@@ -27,7 +27,7 @@ THREE.StandardNode.prototype.build = function( builder ) {
if
(
builder
.
isShader
(
'
vertex
'
)
)
{
var
transform
=
this
.
transform
?
this
.
transform
.
verifyAndBuildCode
(
builder
,
'
v3
'
)
:
undefined
;
var
transform
=
this
.
transform
?
this
.
transform
.
verifyAndBuildCode
(
builder
,
'
v3
'
,
'
transform
'
)
:
undefined
;
material
.
mergeUniform
(
THREE
.
UniformsUtils
.
merge
(
[
...
...
@@ -120,7 +120,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
if
(
this
.
normalScale
&&
this
.
normal
)
this
.
normalScale
.
verify
(
builder
);
if
(
this
.
environment
)
this
.
environment
.
verify
(
builder
,
'
env
'
,
requires
);
// isolate environment from others inputs ( see TextureNode, CubeTextureNode )
if
(
this
.
environmentIntensity
&&
this
.
environment
)
this
.
environmentIntensity
.
verify
(
builder
);
// build code
...
...
@@ -139,7 +138,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
var
normalScale
=
this
.
normalScale
&&
this
.
normal
?
this
.
normalScale
.
buildCode
(
builder
,
'
v2
'
)
:
undefined
;
var
environment
=
this
.
environment
?
this
.
environment
.
buildCode
(
builder
,
'
c
'
,
'
env
'
,
requires
)
:
undefined
;
var
environmentIntensity
=
this
.
environmentIntensity
&&
this
.
environment
?
this
.
environmentIntensity
.
buildCode
(
builder
,
'
fv1
'
)
:
undefined
;
material
.
requestAttrib
.
transparent
=
alpha
!=
undefined
;
...
...
@@ -254,13 +252,6 @@ THREE.StandardNode.prototype.build = function( builder ) {
output
.
push
(
environment
.
code
);
output
.
push
(
"
RE_IndirectSpecular(
"
+
environment
.
result
+
"
, geometry, material, reflectedLight );
"
);
if
(
environmentIntensity
)
{
output
.
push
(
environmentIntensity
.
code
);
output
.
push
(
"
reflectedLight.indirectSpecular *=
"
+
environmentIntensity
.
result
+
"
;
"
);
}
}
output
.
push
(
"
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;
"
);
...
...
examples/js/nodes/materials/StandardNodeMaterial.js
浏览文件 @
805d92d7
...
...
@@ -13,5 +13,5 @@ THREE.StandardNodeMaterial = function() {
THREE
.
StandardNodeMaterial
.
prototype
=
Object
.
create
(
THREE
.
NodeMaterial
.
prototype
);
THREE
.
StandardNodeMaterial
.
prototype
.
constructor
=
THREE
.
StandardNodeMaterial
;
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
StandardNodeMaterial
.
prototype
,
'
node
'
,
[
'
color
'
,
'
alpha
'
,
'
roughness
'
,
'
metalness
'
,
'
normal
'
,
'
normalScale
'
,
'
emissive
'
,
'
ambient
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
environmentIntensity
'
,
'
transform
'
]
);
THREE
.
NodeMaterial
.
add
Shortcuts
(
THREE
.
StandardNodeMaterial
.
prototype
,
'
node
'
,
[
'
color
'
,
'
alpha
'
,
'
roughness
'
,
'
metalness
'
,
'
normal
'
,
'
normalScale
'
,
'
emissive
'
,
'
ambient
'
,
'
shadow
'
,
'
ao
'
,
'
environment
'
,
'
transform
'
]
);
examples/js/nodes/math/Math1Node.js
浏览文件 @
805d92d7
...
...
@@ -12,9 +12,6 @@ THREE.Math1Node = function( a, method ) {
};
THREE
.
Math1Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math1Node
.
prototype
.
constructor
=
THREE
.
Math1Node
;
THREE
.
Math1Node
.
RAD
=
'
radians
'
;
THREE
.
Math1Node
.
DEG
=
'
degrees
'
;
THREE
.
Math1Node
.
EXP
=
'
exp
'
;
...
...
@@ -39,6 +36,9 @@ THREE.Math1Node.LENGTH = 'length';
THREE
.
Math1Node
.
NEGATE
=
'
negate
'
;
THREE
.
Math1Node
.
INVERT
=
'
invert
'
;
THREE
.
Math1Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math1Node
.
prototype
.
constructor
=
THREE
.
Math1Node
;
THREE
.
Math1Node
.
prototype
.
getType
=
function
(
builder
)
{
switch
(
this
.
method
)
{
...
...
examples/js/nodes/math/Math2Node.js
浏览文件 @
805d92d7
...
...
@@ -13,9 +13,6 @@ THREE.Math2Node = function( a, b, method ) {
};
THREE
.
Math2Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math2Node
.
prototype
.
constructor
=
THREE
.
Math2Node
;
THREE
.
Math2Node
.
MIN
=
'
min
'
;
THREE
.
Math2Node
.
MAX
=
'
max
'
;
THREE
.
Math2Node
.
MOD
=
'
mod
'
;
...
...
@@ -26,6 +23,9 @@ THREE.Math2Node.DOT = 'dot';
THREE
.
Math2Node
.
CROSS
=
'
cross
'
;
THREE
.
Math2Node
.
POW
=
'
pow
'
;
THREE
.
Math2Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math2Node
.
prototype
.
constructor
=
THREE
.
Math2Node
;
THREE
.
Math2Node
.
prototype
.
getInputType
=
function
(
builder
)
{
// use the greater length vector
...
...
examples/js/nodes/math/Math3Node.js
浏览文件 @
805d92d7
...
...
@@ -14,14 +14,14 @@ THREE.Math3Node = function( a, b, c, method ) {
};
THREE
.
Math3Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math3Node
.
prototype
.
constructor
=
THREE
.
Math3Node
;
THREE
.
Math3Node
.
MIX
=
'
mix
'
;
THREE
.
Math3Node
.
REFRACT
=
'
refract
'
;
THREE
.
Math3Node
.
SMOOTHSTEP
=
'
smoothstep
'
;
THREE
.
Math3Node
.
FACEFORWARD
=
'
faceforward
'
;
THREE
.
Math3Node
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
Math3Node
.
prototype
.
constructor
=
THREE
.
Math3Node
;
THREE
.
Math3Node
.
prototype
.
getType
=
function
(
builder
)
{
var
a
=
builder
.
getFormatLength
(
this
.
a
.
getType
(
builder
)
);
...
...
examples/js/nodes/math/OperatorNode.js
浏览文件 @
805d92d7
...
...
@@ -6,21 +6,20 @@ THREE.OperatorNode = function( a, b, op ) {
THREE
.
TempNode
.
call
(
this
);
this
.
op
=
op
||
THREE
.
OperatorNode
.
ADD
;
this
.
a
=
a
;
this
.
b
=
b
;
this
.
op
=
op
||
THREE
.
OperatorNode
.
ADD
;
};
THREE
.
OperatorNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
OperatorNode
.
prototype
.
constructor
=
THREE
.
OperatorNode
;
THREE
.
OperatorNode
.
ADD
=
'
+
'
;
THREE
.
OperatorNode
.
SUB
=
'
-
'
;
THREE
.
OperatorNode
.
MUL
=
'
*
'
;
THREE
.
OperatorNode
.
DIV
=
'
/
'
;
THREE
.
OperatorNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
OperatorNode
.
prototype
.
constructor
=
THREE
.
OperatorNode
;
THREE
.
OperatorNode
.
prototype
.
getType
=
function
(
builder
)
{
// use the greater length vector
...
...
examples/js/nodes/postprocessing/NodePass.js
浏览文件 @
805d92d7
...
...
@@ -20,6 +20,8 @@ THREE.NodePass = function() {
THREE
.
NodePass
.
prototype
=
Object
.
create
(
THREE
.
ShaderPass
.
prototype
);
THREE
.
NodePass
.
prototype
.
constructor
=
THREE
.
NodePass
;
THREE
.
NodeMaterial
.
addShortcuts
(
THREE
.
NodePass
.
prototype
,
'
fragment
'
,
[
'
value
'
]
);
THREE
.
NodePass
.
prototype
.
build
=
function
()
{
this
.
node
.
build
();
...
...
@@ -28,6 +30,3 @@ THREE.NodePass.prototype.build = function() {
this
.
material
=
this
.
node
;
};
THREE
.
NodeMaterial
.
Shortcuts
(
THREE
.
NodePass
.
prototype
,
'
fragment
'
,
[
'
value
'
]
);
examples/js/nodes/utils/JoinNode.js
浏览文件 @
805d92d7
...
...
@@ -4,7 +4,7 @@
THREE
.
JoinNode
=
function
(
x
,
y
,
z
,
w
)
{
THREE
.
GL
Node
.
call
(
this
,
'
fv1
'
);
THREE
.
Temp
Node
.
call
(
this
,
'
fv1
'
);
this
.
x
=
x
;
this
.
y
=
y
;
...
...
@@ -13,11 +13,11 @@ THREE.JoinNode = function( x, y, z, w ) {
};
THREE
.
JoinNode
.
prototype
=
Object
.
create
(
THREE
.
GLNode
.
prototype
);
THREE
.
JoinNode
.
prototype
.
constructor
=
THREE
.
JoinNode
;
THREE
.
JoinNode
.
inputs
=
[
'
x
'
,
'
y
'
,
'
z
'
,
'
w
'
];
THREE
.
JoinNode
.
prototype
=
Object
.
create
(
THREE
.
TempNode
.
prototype
);
THREE
.
JoinNode
.
prototype
.
constructor
=
THREE
.
JoinNode
;
THREE
.
JoinNode
.
prototype
.
getNumElements
=
function
()
{
var
inputs
=
THREE
.
JoinNode
.
inputs
;
...
...
examples/js/nodes/utils/NormalMapNode.js
浏览文件 @
805d92d7
...
...
@@ -34,7 +34,7 @@ THREE.NormalMapNode.prototype.generate = function( builder, output ) {
}
else
{
console
.
warn
(
"
THREE.NormalMap is not compatible with
"
+
builder
.
shader
+
"
shader.
"
);
console
.
warn
(
"
THREE.NormalMap
Node
is not compatible with
"
+
builder
.
shader
+
"
shader.
"
);
return
builder
.
format
(
'
vec3( 0.0 )
'
,
this
.
type
,
output
);
...
...
examples/js/nodes/utils/SwitchNode.js
浏览文件 @
805d92d7
...
...
@@ -2,13 +2,12 @@
* @author sunag / http://www.sunag.com.br/
*/
THREE
.
SwitchNode
=
function
(
a
,
component
)
{
THREE
.
SwitchNode
=
function
(
node
,
components
)
{
THREE
.
GLNode
.
call
(
this
,
'
fv1
'
);
this
.
component
=
component
||
'
x
'
;
this
.
a
=
a
;
this
.
node
=
node
;
this
.
components
=
components
||
'
x
'
;
};
...
...
@@ -17,26 +16,26 @@ THREE.SwitchNode.prototype.constructor = THREE.SwitchNode;
THREE
.
SwitchNode
.
prototype
.
getType
=
function
(
builder
)
{
return
builder
.
getFormatByLength
(
this
.
component
.
length
);
return
builder
.
getFormatByLength
(
this
.
component
s
.
length
);
};
THREE
.
SwitchNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
var
type
=
this
.
a
.
getType
(
builder
);
var
type
=
this
.
node
.
getType
(
builder
);
var
inputLength
=
builder
.
getFormatLength
(
type
)
-
1
;
var
a
=
this
.
a
.
build
(
builder
,
type
);
var
node
=
this
.
node
.
build
(
builder
,
type
);
var
outputLength
=
0
;
var
i
,
len
=
this
.
component
.
length
;
var
i
,
len
=
this
.
component
s
.
length
;
// get max length
for
(
i
=
0
;
i
<
len
;
i
++
)
{
outputLength
=
Math
.
max
(
outputLength
,
builder
.
getIndexByElement
(
this
.
component
.
charAt
(
i
)
)
);
outputLength
=
Math
.
max
(
outputLength
,
builder
.
getIndexByElement
(
this
.
component
s
.
charAt
(
i
)
)
);
}
...
...
@@ -44,12 +43,12 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
// build switch
a
+=
'
.
'
;
node
+=
'
.
'
;
for
(
i
=
0
;
i
<
len
;
i
++
)
{
var
elm
=
this
.
component
.
charAt
(
i
);
var
idx
=
builder
.
getIndexByElement
(
this
.
component
.
charAt
(
i
)
);
var
elm
=
this
.
component
s
.
charAt
(
i
);
var
idx
=
builder
.
getIndexByElement
(
this
.
component
s
.
charAt
(
i
)
);
if
(
idx
>
outputLength
)
idx
=
outputLength
;
...
...
@@ -59,10 +58,10 @@ THREE.SwitchNode.prototype.generate = function( builder, output ) {
}
a
+=
builder
.
getElementByIndex
(
idx
);
node
+=
builder
.
getElementByIndex
(
idx
);
}
return
builder
.
format
(
a
,
this
.
getType
(
builder
),
output
);
return
builder
.
format
(
node
,
this
.
getType
(
builder
),
output
);
};
examples/webgl_materials_nodes.html
浏览文件 @
805d92d7
...
...
@@ -273,7 +273,7 @@
//mtl.shadow = // shadowmap
//mtl.ao = // ambient occlusion
//mtl.environment = // reflection map (CubeMap recommended)
//mtl.environment
Intensity = // environment intensity
//mtl.environment
Alpha = // environment alpha
//mtl.transform = // vertex transformation
var
mask
=
new
THREE
.
SwitchNode
(
new
THREE
.
TextureNode
(
decalDiffuse
),
'
w
'
);
...
...
@@ -282,7 +282,7 @@
mtl
.
specular
=
new
THREE
.
FloatNode
(
.
5
);
mtl
.
shininess
=
new
THREE
.
FloatNode
(
15
);
mtl
.
environment
=
new
THREE
.
CubeTextureNode
(
cubemap
);
mtl
.
environment
Intensity
=
mask
;
mtl
.
environment
Alpha
=
mask
;
mtl
.
normal
=
new
THREE
.
TextureNode
(
grassNormal
);
mtl
.
normalScale
=
new
THREE
.
Math1Node
(
mask
,
THREE
.
Math1Node
.
INVERT
);
...
...
@@ -305,7 +305,7 @@
//mtl.shadow = // shadowmap
//mtl.ao = // ambient occlusion
//mtl.environment = // reflection map (CubeMap recommended)
//mtl.environment
Intensity = // environment intensity
//mtl.environment
Alpha = // environment alpha
//mtl.transform = // vertex transformation
var
mask
=
new
THREE
.
SwitchNode
(
new
THREE
.
TextureNode
(
decalDiffuse
),
'
w
'
);
...
...
@@ -619,7 +619,7 @@
mtl
.
color
=
new
THREE
.
ColorNode
(
0x3399FF
);
mtl
.
environment
=
color
;
mtl
.
environment
Intensity
=
new
THREE
.
Math1Node
(
fresnel
,
THREE
.
Math1Node
.
SAT
);
mtl
.
environment
Alpha
=
new
THREE
.
Math1Node
(
fresnel
,
THREE
.
Math1Node
.
SAT
);
// GUI
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录