Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
20b77b27
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,体验更适合开发者的 AI 搜索 >>
提交
20b77b27
编写于
7月 28, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reverting MeshFaceMaterial removal.
上级
d2fb8f23
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
23 deletion
+58
-23
examples/canvas_materials.html
examples/canvas_materials.html
+9
-0
examples/js/loaders/BinaryLoader.js
examples/js/loaders/BinaryLoader.js
+7
-7
examples/js/renderers/Projector.js
examples/js/renderers/Projector.js
+1
-1
examples/webgl_materials.html
examples/webgl_materials.html
+16
-3
src/core/Face3.js
src/core/Face3.js
+5
-1
src/core/Geometry.js
src/core/Geometry.js
+5
-1
src/extras/geometries/BoxGeometry.js
src/extras/geometries/BoxGeometry.js
+9
-7
src/loaders/JSONLoader.js
src/loaders/JSONLoader.js
+6
-3
未找到文件。
examples/canvas_materials.html
浏览文件 @
20b77b27
...
...
@@ -80,6 +80,15 @@
];
for
(
var
i
=
0
,
l
=
geometry
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
geometry
.
faces
[
i
];
if
(
Math
.
random
()
>
0.5
)
face
.
materialIndex
=
Math
.
floor
(
Math
.
random
()
*
materials
.
length
);
}
materials
.
push
(
new
THREE
.
MeshFaceMaterial
(
materials
)
);
objects
=
[];
for
(
var
i
=
0
,
l
=
materials
.
length
;
i
<
l
;
i
++
)
{
...
...
examples/js/loaders/BinaryLoader.js
浏览文件 @
20b77b27
...
...
@@ -232,7 +232,7 @@ THREE.BinaryLoader.prototype = {
+ metaData.nquad_smooth_uv * ( metaData.vertex_index_bytes*4 + metaData.material_index_bytes + metaData.normal_index_bytes*4 + metaData.uv_index_bytes*4 );
console.log( "total bytes: " + total );
*/
return
metaData
;
}
...
...
@@ -429,7 +429,7 @@ THREE.BinaryLoader.prototype = {
m
=
materialIndexBuffer
[
i
];
scope
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
b
,
c
)
);
scope
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
b
,
c
,
null
,
null
,
m
)
);
}
...
...
@@ -451,8 +451,8 @@ THREE.BinaryLoader.prototype = {
m
=
materialIndexBuffer
[
i
];
scope
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
b
,
d
)
);
scope
.
faces
.
push
(
new
THREE
.
Face3
(
b
,
c
,
d
)
);
scope
.
faces
.
push
(
new
THREE
.
Face3
(
a
,
b
,
d
,
null
,
null
,
m
)
);
scope
.
faces
.
push
(
new
THREE
.
Face3
(
b
,
c
,
d
,
null
,
null
,
m
)
);
}
...
...
@@ -495,7 +495,7 @@ THREE.BinaryLoader.prototype = {
new
THREE
.
Vector3
(
nax
,
nay
,
naz
),
new
THREE
.
Vector3
(
nbx
,
nby
,
nbz
),
new
THREE
.
Vector3
(
ncx
,
ncy
,
ncz
)
]
)
);
]
,
null
,
m
)
);
}
...
...
@@ -544,13 +544,13 @@ THREE.BinaryLoader.prototype = {
new
THREE
.
Vector3
(
nax
,
nay
,
naz
),
new
THREE
.
Vector3
(
nbx
,
nby
,
nbz
),
new
THREE
.
Vector3
(
ndx
,
ndy
,
ndz
)
]
)
);
]
,
null
,
m
)
);
scope
.
faces
.
push
(
new
THREE
.
Face3
(
b
,
c
,
d
,
[
new
THREE
.
Vector3
(
nbx
,
nby
,
nbz
),
new
THREE
.
Vector3
(
ncx
,
ncy
,
ncz
),
new
THREE
.
Vector3
(
ndx
,
ndy
,
ndz
)
]
)
);
]
,
null
,
m
)
);
}
...
...
examples/js/renderers/Projector.js
浏览文件 @
20b77b27
...
...
@@ -517,7 +517,7 @@ THREE.Projector = function () {
var
face
=
faces
[
f
];
material
=
isFaceMaterial
===
true
?
objectMaterials
.
materials
[
0
]
// objectMaterials.materials[
face.materialIndex ]
?
objectMaterials
.
materials
[
face
.
materialIndex
]
:
object
.
material
;
if
(
material
===
undefined
)
continue
;
...
...
examples/webgl_materials.html
浏览文件 @
20b77b27
...
...
@@ -91,6 +91,18 @@
var
geometry_smooth
=
new
THREE
.
SphereGeometry
(
70
,
32
,
16
);
var
geometry_flat
=
new
THREE
.
SphereGeometry
(
70
,
32
,
16
);
var
geometry_pieces
=
new
THREE
.
SphereGeometry
(
70
,
32
,
16
);
// Extra geometry to be broken down for MeshFaceMaterial
for
(
var
i
=
0
,
l
=
geometry_pieces
.
faces
.
length
;
i
<
l
;
i
++
)
{
var
face
=
geometry_pieces
.
faces
[
i
];
face
.
materialIndex
=
Math
.
floor
(
Math
.
random
()
*
materials
.
length
);
}
geometry_pieces
.
materials
=
materials
;
materials
.
push
(
new
THREE
.
MeshFaceMaterial
(
materials
)
);
objects
=
[];
...
...
@@ -100,7 +112,8 @@
material
=
materials
[
i
];
geometry
=
material
.
shading
==
THREE
.
FlatShading
?
geometry_flat
:
geometry_smooth
;
geometry
=
material
instanceof
THREE
.
MeshFaceMaterial
?
geometry_pieces
:
(
material
.
shading
==
THREE
.
FlatShading
?
geometry_flat
:
geometry_smooth
);
sphere
=
new
THREE
.
Mesh
(
geometry
,
material
);
...
...
@@ -225,8 +238,8 @@
}
materials
[
materials
.
length
-
2
].
emissive
.
setHSL
(
0.54
,
1
,
0.35
*
(
0.5
+
0.5
*
Math
.
sin
(
35
*
timer
)
)
);
materials
[
materials
.
length
-
3
].
emissive
.
setHSL
(
0.04
,
1
,
0.35
*
(
0.5
+
0.5
*
Math
.
cos
(
35
*
timer
)
)
);
materials
[
materials
.
length
-
3
].
emissive
.
setHSL
(
0.54
,
1
,
0.35
*
(
0.5
+
0.5
*
Math
.
sin
(
35
*
timer
)
)
);
materials
[
materials
.
length
-
4
].
emissive
.
setHSL
(
0.04
,
1
,
0.35
*
(
0.5
+
0.5
*
Math
.
cos
(
35
*
timer
)
)
);
particleLight
.
position
.
x
=
Math
.
sin
(
timer
*
7
)
*
300
;
particleLight
.
position
.
y
=
Math
.
cos
(
timer
*
5
)
*
400
;
...
...
src/core/Face3.js
浏览文件 @
20b77b27
...
...
@@ -3,7 +3,7 @@
* @author alteredq / http://alteredqualia.com/
*/
THREE
.
Face3
=
function
(
a
,
b
,
c
,
normal
,
color
)
{
THREE
.
Face3
=
function
(
a
,
b
,
c
,
normal
,
color
,
materialIndex
)
{
this
.
a
=
a
;
this
.
b
=
b
;
...
...
@@ -17,6 +17,8 @@ THREE.Face3 = function ( a, b, c, normal, color ) {
this
.
vertexTangents
=
[];
this
.
materialIndex
=
materialIndex
!==
undefined
?
materialIndex
:
0
;
};
THREE
.
Face3
.
prototype
=
{
...
...
@@ -32,6 +34,8 @@ THREE.Face3.prototype = {
this
.
normal
.
copy
(
source
.
normal
);
this
.
color
.
copy
(
source
.
color
);
this
.
materialIndex
=
source
.
materialIndex
;
for
(
var
i
=
0
,
il
=
source
.
vertexNormals
.
length
;
i
<
il
;
i
++
)
{
this
.
vertexNormals
[
i
]
=
source
.
vertexNormals
[
i
].
clone
();
...
...
src/core/Geometry.js
浏览文件 @
20b77b27
...
...
@@ -645,7 +645,7 @@ THREE.Geometry.prototype = {
},
merge
:
function
(
geometry
,
matrix
)
{
merge
:
function
(
geometry
,
matrix
,
materialIndexOffset
)
{
if
(
geometry
instanceof
THREE
.
Geometry
===
false
)
{
...
...
@@ -663,6 +663,8 @@ THREE.Geometry.prototype = {
uvs1
=
this
.
faceVertexUvs
[
0
],
uvs2
=
geometry
.
faceVertexUvs
[
0
];
if
(
materialIndexOffset
===
undefined
)
materialIndexOffset
=
0
;
if
(
matrix
!==
undefined
)
{
normalMatrix
=
new
THREE
.
Matrix3
().
getNormalMatrix
(
matrix
);
...
...
@@ -723,6 +725,8 @@ THREE.Geometry.prototype = {
}
faceCopy
.
materialIndex
=
face
.
materialIndex
+
materialIndexOffset
;
faces1
.
push
(
faceCopy
);
}
...
...
src/extras/geometries/BoxGeometry.js
浏览文件 @
20b77b27
...
...
@@ -28,14 +28,14 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
var
height_half
=
height
/
2
;
var
depth_half
=
depth
/
2
;
buildPlane
(
'
z
'
,
'
y
'
,
-
1
,
-
1
,
depth
,
height
,
width_half
);
// px
buildPlane
(
'
z
'
,
'
y
'
,
1
,
-
1
,
depth
,
height
,
-
width_half
);
// nx
buildPlane
(
'
x
'
,
'
z
'
,
1
,
1
,
width
,
depth
,
height_half
);
// py
buildPlane
(
'
x
'
,
'
z
'
,
1
,
-
1
,
width
,
depth
,
-
height_half
);
// ny
buildPlane
(
'
x
'
,
'
y
'
,
1
,
-
1
,
width
,
height
,
depth_half
);
// pz
buildPlane
(
'
x
'
,
'
y
'
,
-
1
,
-
1
,
width
,
height
,
-
depth_half
);
// nz
buildPlane
(
'
z
'
,
'
y
'
,
-
1
,
-
1
,
depth
,
height
,
width_half
,
0
);
// px
buildPlane
(
'
z
'
,
'
y
'
,
1
,
-
1
,
depth
,
height
,
-
width_half
,
1
);
// nx
buildPlane
(
'
x
'
,
'
z
'
,
1
,
1
,
width
,
depth
,
height_half
,
2
);
// py
buildPlane
(
'
x
'
,
'
z
'
,
1
,
-
1
,
width
,
depth
,
-
height_half
,
3
);
// ny
buildPlane
(
'
x
'
,
'
y
'
,
1
,
-
1
,
width
,
height
,
depth_half
,
4
);
// pz
buildPlane
(
'
x
'
,
'
y
'
,
-
1
,
-
1
,
width
,
height
,
-
depth_half
,
5
);
// nz
function
buildPlane
(
u
,
v
,
udir
,
vdir
,
width
,
height
,
depth
)
{
function
buildPlane
(
u
,
v
,
udir
,
vdir
,
width
,
height
,
depth
,
materialIndex
)
{
var
w
,
ix
,
iy
,
gridX
=
scope
.
widthSegments
,
...
...
@@ -100,6 +100,7 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
var
face
=
new
THREE
.
Face3
(
a
+
offset
,
b
+
offset
,
d
+
offset
);
face
.
normal
.
copy
(
normal
);
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
);
face
.
materialIndex
=
materialIndex
;
scope
.
faces
.
push
(
face
);
scope
.
faceVertexUvs
[
0
].
push
(
[
uva
,
uvb
,
uvd
]
);
...
...
@@ -107,6 +108,7 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
face
=
new
THREE
.
Face3
(
b
+
offset
,
c
+
offset
,
d
+
offset
);
face
.
normal
.
copy
(
normal
);
face
.
vertexNormals
.
push
(
normal
.
clone
(),
normal
.
clone
(),
normal
.
clone
()
);
face
.
materialIndex
=
materialIndex
;
scope
.
faces
.
push
(
face
);
scope
.
faceVertexUvs
[
0
].
push
(
[
uvb
.
clone
(),
uvc
,
uvd
.
clone
()
]
);
...
...
src/loaders/JSONLoader.js
浏览文件 @
20b77b27
...
...
@@ -91,7 +91,7 @@ THREE.JSONLoader.prototype = {
offset
,
zLength
,
colorIndex
,
normalIndex
,
uvIndex
,
colorIndex
,
normalIndex
,
uvIndex
,
materialIndex
,
type
,
isQuad
,
...
...
@@ -178,7 +178,9 @@ THREE.JSONLoader.prototype = {
if
(
hasMaterial
)
{
offset
++
;
materialIndex
=
faces
[
offset
++
];
faceA
.
materialIndex
=
materialIndex
;
faceB
.
materialIndex
=
materialIndex
;
}
...
...
@@ -285,7 +287,8 @@ THREE.JSONLoader.prototype = {
if
(
hasMaterial
)
{
offset
++
;
materialIndex
=
faces
[
offset
++
];
face
.
materialIndex
=
materialIndex
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录