Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
d09193d2
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,发现更多精彩内容 >>
未验证
提交
d09193d2
编写于
7月 13, 2020
作者:
M
Mr.doob
提交者:
GitHub
7月 13, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19833 from sunag/dev-gethash
NodeMaterial: getHash and customProgramCacheKey
上级
470f9cd1
ef45f9f3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
85 addition
and
26 deletion
+85
-26
examples/jsm/nodes/core/InputNode.js
examples/jsm/nodes/core/InputNode.js
+2
-0
examples/jsm/nodes/core/Node.d.ts
examples/jsm/nodes/core/Node.d.ts
+2
-0
examples/jsm/nodes/core/Node.js
examples/jsm/nodes/core/Node.js
+38
-0
examples/jsm/nodes/effects/BlurNode.js
examples/jsm/nodes/effects/BlurNode.js
+1
-0
examples/jsm/nodes/effects/ColorAdjustmentNode.js
examples/jsm/nodes/effects/ColorAdjustmentNode.js
+1
-0
examples/jsm/nodes/materials/NodeMaterial.d.ts
examples/jsm/nodes/materials/NodeMaterial.d.ts
+1
-0
examples/jsm/nodes/materials/NodeMaterial.js
examples/jsm/nodes/materials/NodeMaterial.js
+37
-26
examples/jsm/nodes/math/MathNode.js
examples/jsm/nodes/math/MathNode.js
+1
-0
examples/jsm/nodes/misc/BumpMapNode.js
examples/jsm/nodes/misc/BumpMapNode.js
+1
-0
examples/jsm/nodes/utils/ColorSpaceNode.js
examples/jsm/nodes/utils/ColorSpaceNode.js
+1
-0
未找到文件。
examples/jsm/nodes/core/InputNode.js
浏览文件 @
d09193d2
...
...
@@ -22,6 +22,8 @@ InputNode.prototype.setReadonly = function ( value ) {
this
.
readonly
=
value
;
this
.
hashProperties
=
this
.
readonly
?
[
"
value
"
]
:
undefined
;
return
this
;
};
...
...
examples/jsm/nodes/core/Node.d.ts
浏览文件 @
d09193d2
...
...
@@ -10,6 +10,7 @@ export class Node {
userData
:
object
;
readonly
isNode
:
true
;
frameId
:
number
|
undefined
;
hashProperties
:
string
[]
|
undefined
;
analyze
(
builder
:
NodeBuilder
,
settings
?:
object
):
void
;
analyzeAndFlow
(
builder
:
NodeBuilder
,
output
:
string
,
settings
?:
object
):
object
;
...
...
@@ -21,6 +22,7 @@ export class Node {
getName
(
builder
:
NodeBuilder
):
string
;
getType
(
builder
:
NodeBuilder
,
output
?:
string
):
string
;
getJSONNode
(
meta
?:
object
|
string
):
object
|
undefined
;
getHash
():
string
;
copy
(
source
:
Node
):
this
;
createJSONNode
(
meta
?:
object
|
string
):
object
;
toJSON
(
meta
?:
object
|
string
):
object
;
...
...
examples/jsm/nodes/core/Node.js
浏览文件 @
d09193d2
...
...
@@ -22,6 +22,8 @@ Node.prototype = {
isNode
:
true
,
hashProperties
:
undefined
,
analyze
:
function
(
builder
,
settings
)
{
settings
=
settings
||
{};
...
...
@@ -100,6 +102,42 @@ Node.prototype = {
},
getHash
:
function
()
{
var
hash
=
'
{
'
;
var
prop
,
obj
;
for
(
prop
in
this
)
{
obj
=
this
[
prop
];
if
(
obj
instanceof
Node
)
{
hash
+=
'
"
'
+
prop
+
'
":
'
+
obj
.
getHash
()
+
'
,
'
;
}
}
if
(
this
.
hashProperties
)
{
for
(
var
i
=
0
;
i
<
this
.
hashProperties
.
length
;
i
++
)
{
prop
=
this
.
hashProperties
[
i
];
obj
=
this
[
prop
];
hash
+=
'
"
'
+
prop
+
'
":"
'
+
String
(
obj
)
+
'
",
'
;
}
}
hash
+=
'
"id":"
'
+
this
.
uuid
+
'
"}
'
;
return
hash
;
},
appendDepsNode
:
function
(
builder
,
data
,
output
)
{
data
.
deps
=
(
data
.
deps
||
0
)
+
1
;
...
...
examples/jsm/nodes/effects/BlurNode.js
浏览文件 @
d09193d2
...
...
@@ -73,6 +73,7 @@ BlurNode.Nodes = ( function () {
BlurNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
BlurNode
.
prototype
.
constructor
=
BlurNode
;
BlurNode
.
prototype
.
nodeType
=
"
Blur
"
;
BlurNode
.
prototype
.
hashProperties
=
[
"
blurX
"
,
"
blurY
"
];
BlurNode
.
prototype
.
updateFrame
=
function
(
/* frame */
)
{
...
...
examples/jsm/nodes/effects/ColorAdjustmentNode.js
浏览文件 @
d09193d2
...
...
@@ -77,6 +77,7 @@ ColorAdjustmentNode.CONTRAST = 'contrast';
ColorAdjustmentNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ColorAdjustmentNode
.
prototype
.
constructor
=
ColorAdjustmentNode
;
ColorAdjustmentNode
.
prototype
.
nodeType
=
"
ColorAdjustment
"
;
ColorAdjustmentNode
.
prototype
.
hashProperties
=
[
"
method
"
];
ColorAdjustmentNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
...
...
examples/jsm/nodes/materials/NodeMaterial.d.ts
浏览文件 @
d09193d2
...
...
@@ -27,6 +27,7 @@ export class NodeMaterial extends ShaderMaterial {
updateFrame
(
frame
:
NodeFrame
):
void
;
build
(
params
?:
NodeMaterialBuildParams
):
this
;
getHash
():
string
;
copy
(
source
:
NodeMaterial
):
this
;
}
examples/jsm/nodes/materials/NodeMaterial.js
浏览文件 @
d09193d2
...
...
@@ -26,32 +26,6 @@ function NodeMaterial( vertex, fragment ) {
this
.
updaters
=
[];
// onBeforeCompile can't be in the prototype because onBeforeCompile.toString varies per material
this
.
onBeforeCompile
=
function
(
shader
,
renderer
)
{
var
materialProperties
=
renderer
.
properties
.
get
(
this
);
if
(
this
.
version
!==
materialProperties
.
__version
)
{
this
.
build
(
{
renderer
:
renderer
}
);
shader
.
uniforms
=
this
.
uniforms
;
shader
.
vertexShader
=
this
.
vertexShader
;
shader
.
fragmentShader
=
this
.
fragmentShader
;
}
};
// it fix the programCache and share the code with others materials
this
.
onBeforeCompile
.
toString
=
function
()
{
return
scope
.
needsCompile
;
};
}
NodeMaterial
.
prototype
=
Object
.
create
(
ShaderMaterial
.
prototype
);
...
...
@@ -91,6 +65,43 @@ Object.defineProperties( NodeMaterial.prototype, {
}
);
NodeMaterial
.
prototype
.
onBeforeCompile
=
function
(
shader
,
renderer
)
{
var
materialProperties
=
renderer
.
properties
.
get
(
this
);
if
(
this
.
version
!==
materialProperties
.
__version
)
{
this
.
build
(
{
renderer
:
renderer
}
);
shader
.
uniforms
=
this
.
uniforms
;
shader
.
vertexShader
=
this
.
vertexShader
;
shader
.
fragmentShader
=
this
.
fragmentShader
;
}
};
NodeMaterial
.
prototype
.
customProgramCacheKey
=
function
()
{
var
hash
=
this
.
getHash
();
return
hash
;
};
NodeMaterial
.
prototype
.
getHash
=
function
()
{
var
hash
=
'
{
'
;
hash
+=
'
"vertex":
'
+
this
.
vertex
.
getHash
()
+
'
,
'
;
hash
+=
'
"fragment":
'
+
this
.
fragment
.
getHash
();
hash
+=
'
}
'
;
return
hash
;
};
NodeMaterial
.
prototype
.
updateFrame
=
function
(
frame
)
{
for
(
var
i
=
0
;
i
<
this
.
updaters
.
length
;
++
i
)
{
...
...
examples/jsm/nodes/math/MathNode.js
浏览文件 @
d09193d2
...
...
@@ -66,6 +66,7 @@ MathNode.FACEFORWARD = 'faceforward';
MathNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
MathNode
.
prototype
.
constructor
=
MathNode
;
MathNode
.
prototype
.
nodeType
=
"
Math
"
;
MathNode
.
prototype
.
hashProperties
=
[
"
method
"
];
MathNode
.
prototype
.
getNumInputs
=
function
(
/*builder*/
)
{
...
...
examples/jsm/nodes/misc/BumpMapNode.js
浏览文件 @
d09193d2
...
...
@@ -96,6 +96,7 @@ BumpMapNode.Nodes = ( function () {
BumpMapNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
BumpMapNode
.
prototype
.
constructor
=
BumpMapNode
;
BumpMapNode
.
prototype
.
nodeType
=
"
BumpMap
"
;
BumpMapNode
.
prototype
.
hashProperties
=
[
"
toNormalMap
"
];
BumpMapNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
...
...
examples/jsm/nodes/utils/ColorSpaceNode.js
浏览文件 @
d09193d2
...
...
@@ -239,6 +239,7 @@ ColorSpaceNode.getEncodingComponents = function ( encoding ) {
ColorSpaceNode
.
prototype
=
Object
.
create
(
TempNode
.
prototype
);
ColorSpaceNode
.
prototype
.
constructor
=
ColorSpaceNode
;
ColorSpaceNode
.
prototype
.
nodeType
=
"
ColorSpace
"
;
ColorSpaceNode
.
prototype
.
hashProperties
=
[
"
method
"
];
ColorSpaceNode
.
prototype
.
generate
=
function
(
builder
,
output
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录