Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
2a838695
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,体验更适合开发者的 AI 搜索 >>
提交
2a838695
编写于
7月 13, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
WebGLRenderer: Replaced uniforms if with a switch.
上级
df8592a1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
167 addition
and
101 deletion
+167
-101
src/renderers/WebGLRenderer.js
src/renderers/WebGLRenderer.js
+167
-101
未找到文件。
src/renderers/WebGLRenderer.js
浏览文件 @
2a838695
...
...
@@ -4842,200 +4842,266 @@ THREE.WebGLRenderer = function ( parameters ) {
var
type
=
uniform
.
type
;
var
value
=
uniform
.
value
;
if
(
type
===
'
i
'
)
{
// single integer
switch
(
type
)
{
_gl
.
uniform1i
(
location
,
value
);
case
'
i
'
:
}
else
if
(
type
===
'
f
'
)
{
// single float
// single integer
_gl
.
uniform1i
(
location
,
value
);
_gl
.
uniform1f
(
location
,
value
)
;
break
;
}
else
if
(
type
===
'
v2
'
)
{
// single THREE.Vector2
case
'
f
'
:
_gl
.
uniform2f
(
location
,
value
.
x
,
value
.
y
);
// single float
_gl
.
uniform1f
(
location
,
value
);
}
else
if
(
type
===
'
v3
'
)
{
// single THREE.Vector3
break
;
_gl
.
uniform3f
(
location
,
value
.
x
,
value
.
y
,
value
.
z
);
case
'
v2
'
:
}
else
if
(
type
===
'
v4
'
)
{
// single THREE.Vector4
// single THREE.Vector2
_gl
.
uniform2f
(
location
,
value
.
x
,
value
.
y
);
_gl
.
uniform4f
(
location
,
value
.
x
,
value
.
y
,
value
.
z
,
value
.
w
)
;
break
;
}
else
if
(
type
===
'
c
'
)
{
// single THREE.Color
case
'
v3
'
:
_gl
.
uniform3f
(
location
,
value
.
r
,
value
.
g
,
value
.
b
);
// single THREE.Vector3
_gl
.
uniform3f
(
location
,
value
.
x
,
value
.
y
,
value
.
z
);
}
else
if
(
type
===
'
iv1
'
)
{
// flat array of integers (JS or typed array)
break
;
_gl
.
uniform1iv
(
location
,
value
);
case
'
v4
'
:
}
else
if
(
type
===
'
iv
'
)
{
// flat array of integers with 3 x N size (JS or typed array)
// single THREE.Vector4
_gl
.
uniform4f
(
location
,
value
.
x
,
value
.
y
,
value
.
z
,
value
.
w
);
_gl
.
uniform3iv
(
location
,
value
)
;
break
;
}
else
if
(
type
===
'
fv1
'
)
{
// flat array of floats (JS or typed array)
case
'
c
'
:
_gl
.
uniform1fv
(
location
,
value
);
// single THREE.Color
_gl
.
uniform3f
(
location
,
value
.
r
,
value
.
g
,
value
.
b
);
}
else
if
(
type
===
'
fv
'
)
{
// flat array of floats with 3 x N size (JS or typed array)
break
;
_gl
.
uniform3fv
(
location
,
value
);
case
'
iv1
'
:
}
else
if
(
type
===
'
v2v
'
)
{
// array of THREE.Vector2
// flat array of integers (JS or typed array)
_gl
.
uniform1iv
(
location
,
value
);
if
(
uniform
.
_array
===
undefined
)
{
break
;
uniform
.
_array
=
new
Float32Array
(
2
*
value
.
length
);
case
'
iv
'
:
}
// flat array of integers with 3 x N size (JS or typed array)
_gl
.
uniform3iv
(
location
,
value
);
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
break
;
offset
=
i
*
2
;
case
'
fv1
'
:
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
// flat array of floats (JS or typed array)
_gl
.
uniform1fv
(
location
,
value
)
;
}
break
;
_gl
.
uniform2fv
(
location
,
uniform
.
_array
);
case
'
fv
'
:
}
else
if
(
type
===
'
v3v
'
)
{
// array of THREE.Vector3
// flat array of floats with 3 x N size (JS or typed array)
_gl
.
uniform3fv
(
location
,
value
);
if
(
uniform
.
_array
===
undefined
)
{
break
;
uniform
.
_array
=
new
Float32Array
(
3
*
value
.
length
);
case
'
v2v
'
:
}
// array of THREE.Vector2
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
if
(
uniform
.
_array
===
undefined
)
{
offset
=
i
*
3
;
uniform
.
_array
=
new
Float32Array
(
2
*
value
.
length
)
;
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
uniform
.
_array
[
offset
+
2
]
=
value
[
i
].
z
;
}
}
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
_gl
.
uniform3fv
(
location
,
uniform
.
_array
)
;
offset
=
i
*
2
;
}
else
if
(
type
===
'
v4v
'
)
{
// array of THREE.Vector4
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
if
(
uniform
.
_array
===
undefined
)
{
}
uniform
.
_array
=
new
Float32Array
(
4
*
value
.
length
);
_gl
.
uniform2fv
(
location
,
uniform
.
_array
);
}
break
;
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
case
'
v3v
'
:
offset
=
i
*
4
;
// array of THREE.Vector3
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
uniform
.
_array
[
offset
+
2
]
=
value
[
i
].
z
;
uniform
.
_array
[
offset
+
3
]
=
value
[
i
].
w
;
if
(
uniform
.
_array
===
undefined
)
{
}
uniform
.
_array
=
new
Float32Array
(
3
*
value
.
length
);
_gl
.
uniform4fv
(
location
,
uniform
.
_array
);
}
}
else
if
(
type
===
'
m3
'
)
{
// single THREE.Matrix3
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
_gl
.
uniformMatrix3fv
(
location
,
false
,
value
.
elements
)
;
offset
=
i
*
3
;
}
else
if
(
type
===
'
m3v
'
)
{
// array of THREE.Matrix3
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
uniform
.
_array
[
offset
+
2
]
=
value
[
i
].
z
;
if
(
uniform
.
_array
===
undefined
)
{
}
uniform
.
_array
=
new
Float32Array
(
9
*
value
.
length
);
_gl
.
uniform3fv
(
location
,
uniform
.
_array
);
}
break
;
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
case
'
v4v
'
:
value
[
i
].
flattenToArrayOffset
(
uniform
.
_array
,
i
*
9
);
// array of THREE.Vector4
}
if
(
uniform
.
_array
===
undefined
)
{
_gl
.
uniformMatrix3fv
(
location
,
false
,
uniform
.
_array
);
uniform
.
_array
=
new
Float32Array
(
4
*
value
.
length
);
}
else
if
(
type
===
'
m4
'
)
{
// single THREE.Matrix4
}
_gl
.
uniformMatrix4fv
(
location
,
false
,
value
.
elements
);
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
}
else
if
(
type
===
'
m4v
'
)
{
// array of THREE.Matrix4
offset
=
i
*
4
;
if
(
uniform
.
_array
===
undefined
)
{
uniform
.
_array
[
offset
]
=
value
[
i
].
x
;
uniform
.
_array
[
offset
+
1
]
=
value
[
i
].
y
;
uniform
.
_array
[
offset
+
2
]
=
value
[
i
].
z
;
uniform
.
_array
[
offset
+
3
]
=
value
[
i
].
w
;
uniform
.
_array
=
new
Float32Array
(
16
*
value
.
length
);
}
}
_gl
.
uniform4fv
(
location
,
uniform
.
_array
);
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
break
;
value
[
i
].
flattenToArrayOffset
(
uniform
.
_array
,
i
*
16
);
case
'
m3
'
:
}
// single THREE.Matrix3
_gl
.
uniformMatrix3fv
(
location
,
false
,
value
.
elements
);
_gl
.
uniformMatrix4fv
(
location
,
false
,
uniform
.
_array
)
;
break
;
}
else
if
(
type
===
'
t
'
)
{
// single THREE.Texture (2d or cube)
case
'
m3v
'
:
texture
=
value
;
textureUnit
=
getTextureUnit
();
// array of THREE.Matrix3
_gl
.
uniform1i
(
location
,
textureUnit
);
if
(
uniform
.
_array
===
undefined
)
{
if
(
!
texture
)
continue
;
uniform
.
_array
=
new
Float32Array
(
9
*
value
.
length
)
;
if
(
texture
instanceof
THREE
.
CubeTexture
||
(
texture
.
image
instanceof
Array
&&
texture
.
image
.
length
===
6
)
)
{
// CompressedTexture can have Array in image :/
}
setCubeTexture
(
texture
,
textureUnit
);
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
}
else
if
(
texture
instanceof
THREE
.
WebGLRenderTargetCube
)
{
value
[
i
].
flattenToArrayOffset
(
uniform
.
_array
,
i
*
9
);
setCubeTextureDynamic
(
texture
,
textureUnit
);
}
}
else
{
_gl
.
uniformMatrix3fv
(
location
,
false
,
uniform
.
_array
);
_this
.
setTexture
(
texture
,
textureUnit
)
;
break
;
}
case
'
m4
'
:
}
else
if
(
type
===
'
tv
'
)
{
// array of THREE.Texture (2d)
// single THREE.Matrix4
_gl
.
uniformMatrix4fv
(
location
,
false
,
value
.
elements
);
if
(
uniform
.
_array
===
undefined
)
{
break
;
uniform
.
_array
=
[];
case
'
m4v
'
:
}
// array of THREE.Matrix4
for
(
var
i
=
0
,
il
=
uniform
.
value
.
length
;
i
<
il
;
i
++
)
{
if
(
uniform
.
_array
===
undefined
)
{
uniform
.
_array
[
i
]
=
getTextureUnit
(
);
uniform
.
_array
=
new
Float32Array
(
16
*
value
.
length
);
}
}
for
(
var
i
=
0
,
il
=
value
.
length
;
i
<
il
;
i
++
)
{
value
[
i
].
flattenToArrayOffset
(
uniform
.
_array
,
i
*
16
);
}
_gl
.
uniformMatrix4fv
(
location
,
false
,
uniform
.
_array
);
break
;
_gl
.
uniform1iv
(
location
,
uniform
.
_array
);
case
'
t
'
:
for
(
var
i
=
0
,
il
=
uniform
.
value
.
length
;
i
<
il
;
i
++
)
{
// single THREE.Texture (2d or cube)
texture
=
uniform
.
value
[
i
];
textureUnit
=
uniform
.
_array
[
i
];
texture
=
value
;
textureUnit
=
getTextureUnit
();
_gl
.
uniform1i
(
location
,
textureUnit
);
if
(
!
texture
)
continue
;
_this
.
setTexture
(
texture
,
textureUnit
);
if
(
texture
instanceof
THREE
.
CubeTexture
||
(
texture
.
image
instanceof
Array
&&
texture
.
image
.
length
===
6
)
)
{
// CompressedTexture can have Array in image :/
}
setCubeTexture
(
texture
,
textureUnit
);
}
else
{
}
else
if
(
texture
instanceof
THREE
.
WebGLRenderTargetCube
)
{
setCubeTextureDynamic
(
texture
,
textureUnit
);
}
else
{
_this
.
setTexture
(
texture
,
textureUnit
);
}
break
;
case
'
tv
'
:
// array of THREE.Texture (2d)
if
(
uniform
.
_array
===
undefined
)
{
uniform
.
_array
=
[];
}
for
(
var
i
=
0
,
il
=
uniform
.
value
.
length
;
i
<
il
;
i
++
)
{
uniform
.
_array
[
i
]
=
getTextureUnit
();
}
_gl
.
uniform1iv
(
location
,
uniform
.
_array
);
for
(
var
i
=
0
,
il
=
uniform
.
value
.
length
;
i
<
il
;
i
++
)
{
texture
=
uniform
.
value
[
i
];
textureUnit
=
uniform
.
_array
[
i
];
if
(
!
texture
)
continue
;
_this
.
setTexture
(
texture
,
textureUnit
);
}
break
;
default
:
console
.
warn
(
'
THREE.WebGLRenderer: Unknown uniform type:
'
+
type
);
console
.
warn
(
'
THREE.WebGLRenderer: Unknown uniform type:
'
+
type
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录