Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
ef9bdf6b
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,发现更多精彩内容 >>
提交
ef9bdf6b
编写于
1月 06, 2011
作者:
A
alteredq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small WebGLRenderer optimization: skip setting of uniforms which don't exist in shader program.
上级
a783870b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
7 addition
and
5 deletion
+7
-5
build/Three.js
build/Three.js
+1
-1
build/ThreeDebug.js
build/ThreeDebug.js
+1
-1
build/ThreeExtras.js
build/ThreeExtras.js
+1
-1
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+4
-2
未找到文件。
build/Three.js
浏览文件 @
ef9bdf6b
...
...
@@ -162,7 +162,7 @@ THREE.DirectionalLight&&y++;v instanceof THREE.PointLight&&t++}if(t+y<=4){u=y;t=
c
.
attachShader
(
s
,
i
(
"
fragment
"
,
v
+
t
));
c
.
attachShader
(
s
,
i
(
"
vertex
"
,
y
+
u
));
c
.
linkProgram
(
s
);
c
.
getProgramParameter
(
s
,
c
.
LINK_STATUS
)
||
alert
(
"
Could not initialise shaders
\n
VALIDATE_STATUS:
"
+
c
.
getProgramParameter
(
s
,
c
.
VALIDATE_STATUS
)
+
"
, gl error [
"
+
c
.
getError
()
+
"
]
"
);
s
.
uniforms
=
{};
s
.
attributes
=
{};
l
.
program
=
s
;
t
=
[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
];
for
(
h
in
l
.
uniforms
)
t
.
push
(
h
);
h
=
l
.
program
;
u
=
0
;
for
(
s
=
t
.
length
;
u
<
s
;
u
++
){
v
=
t
[
u
];
h
.
uniforms
[
v
]
=
c
.
getUniformLocation
(
h
,
v
)}
h
=
l
.
program
;
t
=
[
"
position
"
,
"
normal
"
,
"
uv
"
,
"
tangent
"
];
u
=
0
;
for
(
s
=
t
.
length
;
u
<
s
;
u
++
){
v
=
t
[
u
];
h
.
attributes
[
v
]
=
c
.
getAttribLocation
(
h
,
v
)}}
h
=
l
.
program
;
if
(
h
!=
k
){
c
.
useProgram
(
h
);
k
=
h
}
this
.
loadCamera
(
h
,
d
);
this
.
loadMatrices
(
h
);
if
(
l
instanceof
THREE
.
MeshPhongMaterial
||
l
instanceof
THREE
.
MeshLambertMaterial
){
d
=
this
.
setupLights
(
h
,
g
);
l
.
uniforms
.
enableLighting
.
value
=
d
.
directional
.
positions
.
length
+
d
.
point
.
positions
.
length
;
l
.
uniforms
.
ambientLightColor
.
value
=
d
.
ambient
;
l
.
uniforms
.
directionalLightColor
.
value
=
d
.
directional
.
colors
;
l
.
uniforms
.
directionalLightDirection
.
value
=
d
.
directional
.
positions
;
l
.
uniforms
.
pointLightColor
.
value
=
d
.
point
.
colors
;
l
.
uniforms
.
pointLightPosition
.
value
=
d
.
point
.
positions
}
if
(
l
instanceof
THREE
.
MeshBasicMaterial
||
l
instanceof
THREE
.
MeshLambertMaterial
||
l
instanceof
THREE
.
MeshPhongMaterial
)
f
(
l
,
o
);
l
instanceof
THREE
.
LineBasicMaterial
&&
e
(
l
,
o
);
if
(
l
instanceof
THREE
.
MeshPhongMaterial
){
l
.
uniforms
.
ambient
.
value
.
setRGB
(
l
.
ambient
.
r
,
l
.
ambient
.
g
,
l
.
ambient
.
b
);
l
.
uniforms
.
specular
.
value
.
setRGB
(
l
.
specular
.
r
,
l
.
specular
.
g
,
l
.
specular
.
b
);
l
.
uniforms
.
shininess
.
value
=
l
.
shininess
}
o
=
l
.
uniforms
;
for
(
r
in
o
)
{
g
=
o
[
r
].
type
;
d
=
o
[
r
].
value
;
t
=
h
.
uniforms
[
r
]
;
if
(
g
==
"
i
"
)
c
.
uniform1i
(
t
,
d
);
else
if
(
g
==
"
f
"
)
c
.
uniform1f
(
t
,
d
);
else
if
(
g
==
"
fv
"
)
c
.
uniform3fv
(
t
,
d
);
else
if
(
g
==
"
v2
"
)
c
.
uniform2f
(
t
,
d
.
x
,
d
.
y
);
else
if
(
g
==
"
v3
"
)
c
.
uniform3f
(
t
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
g
==
"
c
"
)
c
.
uniform3f
(
t
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
g
==
"
t
"
){
c
.
uniform1i
(
t
,
d
);
if
(
g
=
o
[
r
].
texture
)
if
(
g
.
image
instanceof
Array
&&
g
.
image
.
length
==
6
){
g
=
g
;
d
=
d
;
if
(
g
.
image
.
length
==
6
){
if
(
!
g
.
image
.
__webGLTextureCube
&&!
g
.
image
.
__cubeMapInitialized
&&
l
.
specular
.
b
);
l
.
uniforms
.
shininess
.
value
=
l
.
shininess
}
o
=
l
.
uniforms
;
for
(
r
in
o
)
if
(
t
=
h
.
uniforms
[
r
]){
g
=
o
[
r
].
type
;
d
=
o
[
r
].
value
;
if
(
g
==
"
i
"
)
c
.
uniform1i
(
t
,
d
);
else
if
(
g
==
"
f
"
)
c
.
uniform1f
(
t
,
d
);
else
if
(
g
==
"
fv
"
)
c
.
uniform3fv
(
t
,
d
);
else
if
(
g
==
"
v2
"
)
c
.
uniform2f
(
t
,
d
.
x
,
d
.
y
);
else
if
(
g
==
"
v3
"
)
c
.
uniform3f
(
t
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
g
==
"
c
"
)
c
.
uniform3f
(
t
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
g
==
"
t
"
){
c
.
uniform1i
(
t
,
d
);
if
(
g
=
o
[
r
].
texture
)
if
(
g
.
image
instanceof
Array
&&
g
.
image
.
length
==
6
){
g
=
g
;
d
=
d
;
if
(
g
.
image
.
length
==
6
){
if
(
!
g
.
image
.
__webGLTextureCube
&&!
g
.
image
.
__cubeMapInitialized
&&
g
.
image
.
loadCount
==
6
){
g
.
image
.
__webGLTextureCube
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
g
.
image
.
__webGLTextureCube
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_S
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_T
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MAG_FILTER
,
c
.
LINEAR
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MIN_FILTER
,
c
.
LINEAR_MIPMAP_LINEAR
);
for
(
t
=
0
;
t
<
6
;
++
t
)
c
.
texImage2D
(
c
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
t
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
g
.
image
[
t
]);
c
.
generateMipmap
(
c
.
TEXTURE_CUBE_MAP
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
null
);
g
.
image
.
__cubeMapInitialized
=
true
}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
g
.
image
.
__webGLTextureCube
)}}
else
{
g
=
g
;
d
=
d
;
if
(
!
g
.
__webGLTexture
&&
g
.
image
.
loaded
){
g
.
__webGLTexture
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_2D
,
g
.
__webGLTexture
);
c
.
texImage2D
(
c
.
TEXTURE_2D
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
g
.
image
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_S
,
j
(
g
.
wrap_s
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_T
,
j
(
g
.
wrap_t
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MAG_FILTER
,
j
(
g
.
mag_filter
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MIN_FILTER
,
j
(
g
.
min_filter
));
c
.
generateMipmap
(
c
.
TEXTURE_2D
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
null
)}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
g
.
__webGLTexture
)}}}
r
=
h
.
attributes
;
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
m
.
__webGLVertexBuffer
);
c
.
vertexAttribPointer
(
r
.
position
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
c
.
enableVertexAttribArray
(
r
.
position
);
if
(
r
.
normal
>=
0
){
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
m
.
__webGLNormalBuffer
);
...
...
build/ThreeDebug.js
浏览文件 @
ef9bdf6b
...
...
@@ -163,7 +163,7 @@ THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&t++}if(t+y<=4){u=y;t=
c
.
attachShader
(
s
,
i
(
"
fragment
"
,
w
+
t
));
c
.
attachShader
(
s
,
i
(
"
vertex
"
,
y
+
u
));
c
.
linkProgram
(
s
);
c
.
getProgramParameter
(
s
,
c
.
LINK_STATUS
)
||
alert
(
"
Could not initialise shaders
\n
VALIDATE_STATUS:
"
+
c
.
getProgramParameter
(
s
,
c
.
VALIDATE_STATUS
)
+
"
, gl error [
"
+
c
.
getError
()
+
"
]
"
);
s
.
uniforms
=
{};
s
.
attributes
=
{};
l
.
program
=
s
;
t
=
[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
];
for
(
h
in
l
.
uniforms
)
t
.
push
(
h
);
h
=
l
.
program
;
u
=
0
;
for
(
s
=
t
.
length
;
u
<
s
;
u
++
){
w
=
t
[
u
];
h
.
uniforms
[
w
]
=
c
.
getUniformLocation
(
h
,
w
)}
h
=
l
.
program
;
t
=
[
"
position
"
,
"
normal
"
,
"
uv
"
,
"
tangent
"
];
u
=
0
;
for
(
s
=
t
.
length
;
u
<
s
;
u
++
){
w
=
t
[
u
];
h
.
attributes
[
w
]
=
c
.
getAttribLocation
(
h
,
w
)}}
h
=
l
.
program
;
if
(
h
!=
k
){
c
.
useProgram
(
h
);
k
=
h
}
this
.
loadCamera
(
h
,
d
);
this
.
loadMatrices
(
h
);
if
(
l
instanceof
THREE
.
MeshPhongMaterial
||
l
instanceof
THREE
.
MeshLambertMaterial
){
d
=
this
.
setupLights
(
h
,
g
);
l
.
uniforms
.
enableLighting
.
value
=
d
.
directional
.
positions
.
length
+
d
.
point
.
positions
.
length
;
l
.
uniforms
.
ambientLightColor
.
value
=
d
.
ambient
;
l
.
uniforms
.
directionalLightColor
.
value
=
d
.
directional
.
colors
;
l
.
uniforms
.
directionalLightDirection
.
value
=
d
.
directional
.
positions
;
l
.
uniforms
.
pointLightColor
.
value
=
d
.
point
.
colors
;
l
.
uniforms
.
pointLightPosition
.
value
=
d
.
point
.
positions
}
if
(
l
instanceof
THREE
.
MeshBasicMaterial
||
l
instanceof
THREE
.
MeshLambertMaterial
||
l
instanceof
THREE
.
MeshPhongMaterial
)
f
(
l
,
o
);
l
instanceof
THREE
.
LineBasicMaterial
&&
e
(
l
,
o
);
if
(
l
instanceof
THREE
.
MeshPhongMaterial
){
l
.
uniforms
.
ambient
.
value
.
setRGB
(
l
.
ambient
.
r
,
l
.
ambient
.
g
,
l
.
ambient
.
b
);
l
.
uniforms
.
specular
.
value
.
setRGB
(
l
.
specular
.
r
,
l
.
specular
.
g
,
l
.
specular
.
b
);
l
.
uniforms
.
shininess
.
value
=
l
.
shininess
}
o
=
l
.
uniforms
;
for
(
r
in
o
)
{
g
=
o
[
r
].
type
;
d
=
o
[
r
].
value
;
t
=
h
.
uniforms
[
r
]
;
if
(
g
==
"
i
"
)
c
.
uniform1i
(
t
,
d
);
else
if
(
g
==
"
f
"
)
c
.
uniform1f
(
t
,
d
);
else
if
(
g
==
"
fv
"
)
c
.
uniform3fv
(
t
,
d
);
else
if
(
g
==
"
v2
"
)
c
.
uniform2f
(
t
,
d
.
x
,
d
.
y
);
else
if
(
g
==
"
v3
"
)
c
.
uniform3f
(
t
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
g
==
"
c
"
)
c
.
uniform3f
(
t
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
g
==
"
t
"
){
c
.
uniform1i
(
t
,
d
);
if
(
g
=
o
[
r
].
texture
)
if
(
g
.
image
instanceof
Array
&&
g
.
image
.
length
==
6
){
g
=
g
;
d
=
d
;
if
(
g
.
image
.
length
==
6
){
if
(
!
g
.
image
.
__webGLTextureCube
&&!
g
.
image
.
__cubeMapInitialized
&&
l
.
specular
.
b
);
l
.
uniforms
.
shininess
.
value
=
l
.
shininess
}
o
=
l
.
uniforms
;
for
(
r
in
o
)
if
(
t
=
h
.
uniforms
[
r
]){
g
=
o
[
r
].
type
;
d
=
o
[
r
].
value
;
if
(
g
==
"
i
"
)
c
.
uniform1i
(
t
,
d
);
else
if
(
g
==
"
f
"
)
c
.
uniform1f
(
t
,
d
);
else
if
(
g
==
"
fv
"
)
c
.
uniform3fv
(
t
,
d
);
else
if
(
g
==
"
v2
"
)
c
.
uniform2f
(
t
,
d
.
x
,
d
.
y
);
else
if
(
g
==
"
v3
"
)
c
.
uniform3f
(
t
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
g
==
"
c
"
)
c
.
uniform3f
(
t
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
g
==
"
t
"
){
c
.
uniform1i
(
t
,
d
);
if
(
g
=
o
[
r
].
texture
)
if
(
g
.
image
instanceof
Array
&&
g
.
image
.
length
==
6
){
g
=
g
;
d
=
d
;
if
(
g
.
image
.
length
==
6
){
if
(
!
g
.
image
.
__webGLTextureCube
&&!
g
.
image
.
__cubeMapInitialized
&&
g
.
image
.
loadCount
==
6
){
g
.
image
.
__webGLTextureCube
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
g
.
image
.
__webGLTextureCube
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_S
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_T
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MAG_FILTER
,
c
.
LINEAR
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MIN_FILTER
,
c
.
LINEAR_MIPMAP_LINEAR
);
for
(
t
=
0
;
t
<
6
;
++
t
)
c
.
texImage2D
(
c
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
t
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
g
.
image
[
t
]);
c
.
generateMipmap
(
c
.
TEXTURE_CUBE_MAP
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
null
);
g
.
image
.
__cubeMapInitialized
=
true
}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
g
.
image
.
__webGLTextureCube
)}}
else
{
g
=
g
;
d
=
d
;
if
(
!
g
.
__webGLTexture
&&
g
.
image
.
loaded
){
g
.
__webGLTexture
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_2D
,
g
.
__webGLTexture
);
c
.
texImage2D
(
c
.
TEXTURE_2D
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
g
.
image
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_S
,
j
(
g
.
wrap_s
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_T
,
j
(
g
.
wrap_t
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MAG_FILTER
,
j
(
g
.
mag_filter
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MIN_FILTER
,
j
(
g
.
min_filter
));
c
.
generateMipmap
(
c
.
TEXTURE_2D
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
null
)}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
g
.
__webGLTexture
)}}}
r
=
h
.
attributes
;
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
n
.
__webGLVertexBuffer
);
c
.
vertexAttribPointer
(
r
.
position
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
c
.
enableVertexAttribArray
(
r
.
position
);
if
(
r
.
normal
>=
0
){
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
n
.
__webGLNormalBuffer
);
...
...
build/ThreeExtras.js
浏览文件 @
ef9bdf6b
...
...
@@ -162,7 +162,7 @@ THREE.DirectionalLight&&E++;D instanceof THREE.PointLight&&w++}if(w+E<=4){z=E;w=
c
.
attachShader
(
x
,
g
(
"
fragment
"
,
D
+
w
));
c
.
attachShader
(
x
,
g
(
"
vertex
"
,
E
+
z
));
c
.
linkProgram
(
x
);
c
.
getProgramParameter
(
x
,
c
.
LINK_STATUS
)
||
alert
(
"
Could not initialise shaders
\n
VALIDATE_STATUS:
"
+
c
.
getProgramParameter
(
x
,
c
.
VALIDATE_STATUS
)
+
"
, gl error [
"
+
c
.
getError
()
+
"
]
"
);
x
.
uniforms
=
{};
x
.
attributes
=
{};
n
.
program
=
x
;
w
=
[
"
viewMatrix
"
,
"
modelViewMatrix
"
,
"
projectionMatrix
"
,
"
normalMatrix
"
,
"
objectMatrix
"
,
"
cameraPosition
"
];
for
(
l
in
n
.
uniforms
)
w
.
push
(
l
);
l
=
n
.
program
;
z
=
0
;
for
(
x
=
w
.
length
;
z
<
x
;
z
++
){
D
=
w
[
z
];
l
.
uniforms
[
D
]
=
c
.
getUniformLocation
(
l
,
D
)}
l
=
n
.
program
;
w
=
[
"
position
"
,
"
normal
"
,
"
uv
"
,
"
tangent
"
];
z
=
0
;
for
(
x
=
w
.
length
;
z
<
x
;
z
++
){
D
=
w
[
z
];
l
.
attributes
[
D
]
=
c
.
getAttribLocation
(
l
,
D
)}}
l
=
n
.
program
;
if
(
l
!=
i
){
c
.
useProgram
(
l
);
i
=
l
}
this
.
loadCamera
(
l
,
d
);
this
.
loadMatrices
(
l
);
if
(
n
instanceof
THREE
.
MeshPhongMaterial
||
n
instanceof
THREE
.
MeshLambertMaterial
){
d
=
this
.
setupLights
(
l
,
k
);
n
.
uniforms
.
enableLighting
.
value
=
d
.
directional
.
positions
.
length
+
d
.
point
.
positions
.
length
;
n
.
uniforms
.
ambientLightColor
.
value
=
d
.
ambient
;
n
.
uniforms
.
directionalLightColor
.
value
=
d
.
directional
.
colors
;
n
.
uniforms
.
directionalLightDirection
.
value
=
d
.
directional
.
positions
;
n
.
uniforms
.
pointLightColor
.
value
=
d
.
point
.
colors
;
n
.
uniforms
.
pointLightPosition
.
value
=
d
.
point
.
positions
}
if
(
n
instanceof
THREE
.
MeshBasicMaterial
||
n
instanceof
THREE
.
MeshLambertMaterial
||
n
instanceof
THREE
.
MeshPhongMaterial
)
f
(
n
,
q
);
n
instanceof
THREE
.
LineBasicMaterial
&&
e
(
n
,
q
);
if
(
n
instanceof
THREE
.
MeshPhongMaterial
){
n
.
uniforms
.
ambient
.
value
.
setRGB
(
n
.
ambient
.
r
,
n
.
ambient
.
g
,
n
.
ambient
.
b
);
n
.
uniforms
.
specular
.
value
.
setRGB
(
n
.
specular
.
r
,
n
.
specular
.
g
,
n
.
specular
.
b
);
n
.
uniforms
.
shininess
.
value
=
n
.
shininess
}
q
=
n
.
uniforms
;
for
(
u
in
q
)
{
k
=
q
[
u
].
type
;
d
=
q
[
u
].
value
;
w
=
l
.
uniforms
[
u
]
;
if
(
k
==
"
i
"
)
c
.
uniform1i
(
w
,
d
);
else
if
(
k
==
"
f
"
)
c
.
uniform1f
(
w
,
d
);
else
if
(
k
==
"
fv
"
)
c
.
uniform3fv
(
w
,
d
);
else
if
(
k
==
"
v2
"
)
c
.
uniform2f
(
w
,
d
.
x
,
d
.
y
);
else
if
(
k
==
"
v3
"
)
c
.
uniform3f
(
w
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
k
==
"
c
"
)
c
.
uniform3f
(
w
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
k
==
"
t
"
){
c
.
uniform1i
(
w
,
d
);
if
(
k
=
q
[
u
].
texture
)
if
(
k
.
image
instanceof
Array
&&
k
.
image
.
length
==
6
){
k
=
k
;
d
=
d
;
if
(
k
.
image
.
length
==
6
){
if
(
!
k
.
image
.
__webGLTextureCube
&&!
k
.
image
.
__cubeMapInitialized
&&
n
.
specular
.
b
);
n
.
uniforms
.
shininess
.
value
=
n
.
shininess
}
q
=
n
.
uniforms
;
for
(
u
in
q
)
if
(
w
=
l
.
uniforms
[
u
]){
k
=
q
[
u
].
type
;
d
=
q
[
u
].
value
;
if
(
k
==
"
i
"
)
c
.
uniform1i
(
w
,
d
);
else
if
(
k
==
"
f
"
)
c
.
uniform1f
(
w
,
d
);
else
if
(
k
==
"
fv
"
)
c
.
uniform3fv
(
w
,
d
);
else
if
(
k
==
"
v2
"
)
c
.
uniform2f
(
w
,
d
.
x
,
d
.
y
);
else
if
(
k
==
"
v3
"
)
c
.
uniform3f
(
w
,
d
.
x
,
d
.
y
,
d
.
z
);
else
if
(
k
==
"
c
"
)
c
.
uniform3f
(
w
,
d
.
r
,
d
.
g
,
d
.
b
);
else
if
(
k
==
"
t
"
){
c
.
uniform1i
(
w
,
d
);
if
(
k
=
q
[
u
].
texture
)
if
(
k
.
image
instanceof
Array
&&
k
.
image
.
length
==
6
){
k
=
k
;
d
=
d
;
if
(
k
.
image
.
length
==
6
){
if
(
!
k
.
image
.
__webGLTextureCube
&&!
k
.
image
.
__cubeMapInitialized
&&
k
.
image
.
loadCount
==
6
){
k
.
image
.
__webGLTextureCube
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
k
.
image
.
__webGLTextureCube
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_S
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_WRAP_T
,
c
.
CLAMP_TO_EDGE
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MAG_FILTER
,
c
.
LINEAR
);
c
.
texParameteri
(
c
.
TEXTURE_CUBE_MAP
,
c
.
TEXTURE_MIN_FILTER
,
c
.
LINEAR_MIPMAP_LINEAR
);
for
(
w
=
0
;
w
<
6
;
++
w
)
c
.
texImage2D
(
c
.
TEXTURE_CUBE_MAP_POSITIVE_X
+
w
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
k
.
image
[
w
]);
c
.
generateMipmap
(
c
.
TEXTURE_CUBE_MAP
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
null
);
k
.
image
.
__cubeMapInitialized
=
true
}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_CUBE_MAP
,
k
.
image
.
__webGLTextureCube
)}}
else
{
k
=
k
;
d
=
d
;
if
(
!
k
.
__webGLTexture
&&
k
.
image
.
loaded
){
k
.
__webGLTexture
=
c
.
createTexture
();
c
.
bindTexture
(
c
.
TEXTURE_2D
,
k
.
__webGLTexture
);
c
.
texImage2D
(
c
.
TEXTURE_2D
,
0
,
c
.
RGBA
,
c
.
RGBA
,
c
.
UNSIGNED_BYTE
,
k
.
image
);
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_S
,
h
(
k
.
wrap_s
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_WRAP_T
,
h
(
k
.
wrap_t
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MAG_FILTER
,
h
(
k
.
mag_filter
));
c
.
texParameteri
(
c
.
TEXTURE_2D
,
c
.
TEXTURE_MIN_FILTER
,
h
(
k
.
min_filter
));
c
.
generateMipmap
(
c
.
TEXTURE_2D
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
null
)}
c
.
activeTexture
(
c
.
TEXTURE0
+
d
);
c
.
bindTexture
(
c
.
TEXTURE_2D
,
k
.
__webGLTexture
)}}}
u
=
l
.
attributes
;
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
o
.
__webGLVertexBuffer
);
c
.
vertexAttribPointer
(
u
.
position
,
3
,
c
.
FLOAT
,
false
,
0
,
0
);
c
.
enableVertexAttribArray
(
u
.
position
);
if
(
u
.
normal
>=
0
){
c
.
bindBuffer
(
c
.
ARRAY_BUFFER
,
o
.
__webGLNormalBuffer
);
...
...
src/renderers/WebGLRenderer.js
浏览文件 @
ef9bdf6b
...
...
@@ -1089,10 +1089,12 @@ THREE.WebGLRenderer = function ( parameters ) {
for
(
u
in
uniforms
)
{
location
=
program
.
uniforms
[
u
];
if
(
!
location
)
continue
;
type
=
uniforms
[
u
].
type
;
value
=
uniforms
[
u
].
value
;
location
=
program
.
uniforms
[
u
];
if
(
type
==
"
i
"
)
{
_gl
.
uniform1i
(
location
,
value
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录