Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3bbaec7d
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,发现更多精彩内容 >>
提交
3bbaec7d
编写于
7月 07, 2013
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Geometry/MaterialExporter: Added vertex/face colors support.
上级
e2aa730a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
96 addition
and
27 deletion
+96
-27
editor/index.html
editor/index.html
+1
-1
editor/js/Sidebar.Material.js
editor/js/Sidebar.Material.js
+12
-2
examples/js/exporters/GeometryExporter.js
examples/js/exporters/GeometryExporter.js
+66
-17
examples/js/exporters/MaterialExporter.js
examples/js/exporters/MaterialExporter.js
+3
-0
src/loaders/JSONLoader.js
src/loaders/JSONLoader.js
+11
-7
src/loaders/MaterialLoader.js
src/loaders/MaterialLoader.js
+3
-0
未找到文件。
editor/index.html
浏览文件 @
3bbaec7d
...
...
@@ -78,7 +78,7 @@
</head>
<body>
<script
src=
"../build/three.js"
></script>
<script
src=
"../build/three.
min.
js"
></script>
<script
src=
"../examples/js/libs/system.min.js"
></script>
<script
src=
"../examples/js/controls/EditorControls.js"
></script>
...
...
editor/js/Sidebar.Material.js
浏览文件 @
3bbaec7d
...
...
@@ -244,7 +244,11 @@ Sidebar.Material = function ( signals ) {
if
(
material
)
{
material
.
name
=
materialName
.
getValue
();
if
(
material
.
name
!==
undefined
)
{
material
.
name
=
materialName
.
getValue
();
}
if
(
material
instanceof
materialClasses
[
materialClass
.
getValue
()
]
==
false
)
{
...
...
@@ -450,6 +454,7 @@ Sidebar.Material = function ( signals ) {
function
updateRows
()
{
var
properties
=
{
'
name
'
:
materialNameRow
,
'
color
'
:
materialColorRow
,
'
ambient
'
:
materialAmbientRow
,
'
emissive
'
:
materialEmissiveRow
,
...
...
@@ -499,7 +504,12 @@ Sidebar.Material = function ( signals ) {
var
material
=
object
.
material
;
materialName
.
setValue
(
material
.
name
);
if
(
material
.
name
!==
undefined
)
{
materialName
.
setValue
(
material
.
name
);
}
materialClass
.
setValue
(
getMaterialInstanceName
(
material
)
);
if
(
material
.
color
!==
undefined
)
{
...
...
examples/js/exporters/GeometryExporter.js
浏览文件 @
3bbaec7d
...
...
@@ -28,9 +28,10 @@ THREE.GeometryExporter.prototype = {
}
var
faces
=
[];
var
uvs
=
[[]];
var
normals
=
[];
var
normalsHash
=
{};
var
colors
=
[];
var
colorsHash
=
{};
for
(
var
i
=
0
;
i
<
geometry
.
faces
.
length
;
i
++
)
{
...
...
@@ -41,9 +42,9 @@ THREE.GeometryExporter.prototype = {
var
hasFaceUv
=
false
;
// geometry.faceUvs[ 0 ][ i ] !== undefined;
var
hasFaceVertexUv
=
false
;
// geometry.faceVertexUvs[ 0 ][ i ] !== undefined;
var
hasFaceNormal
=
face
.
normal
.
length
()
>
0
;
var
hasFaceVertexNormal
=
face
.
vertexNormals
[
0
]
!==
undefined
;
var
hasFaceColor
=
fa
lse
;
// face.color
;
var
hasFaceVertexColor
=
fa
lse
;
// face.vertexColors[ 0 ] !== undefined
;
var
hasFaceVertexNormal
=
face
.
vertexNormals
.
length
>
0
;
var
hasFaceColor
=
fa
ce
.
color
.
r
!==
1
&&
face
.
color
.
g
!==
1
&&
face
.
color
.
b
!==
1
;
var
hasFaceVertexColor
=
fa
ce
.
vertexColors
.
length
>
0
;
var
faceType
=
0
;
...
...
@@ -112,8 +113,7 @@ THREE.GeometryExporter.prototype = {
if
(
hasFaceNormal
)
{
var
faceNormal
=
face
.
normal
;
faces
.
push
(
getNormalIndex
(
faceNormal
.
x
,
faceNormal
.
y
,
faceNormal
.
z
)
);
faces
.
push
(
getNormalIndex
(
face
.
normal
)
);
}
...
...
@@ -124,18 +124,49 @@ THREE.GeometryExporter.prototype = {
if
(
isTriangle
)
{
faces
.
push
(
getNormalIndex
(
vertexNormals
[
0
]
.
x
,
vertexNormals
[
0
].
y
,
vertexNormals
[
0
].
z
),
getNormalIndex
(
vertexNormals
[
1
]
.
x
,
vertexNormals
[
1
].
y
,
vertexNormals
[
1
].
z
),
getNormalIndex
(
vertexNormals
[
2
]
.
x
,
vertexNormals
[
2
].
y
,
vertexNormals
[
2
].
z
)
getNormalIndex
(
vertexNormals
[
0
]
),
getNormalIndex
(
vertexNormals
[
1
]
),
getNormalIndex
(
vertexNormals
[
2
]
)
);
}
else
{
faces
.
push
(
getNormalIndex
(
vertexNormals
[
0
].
x
,
vertexNormals
[
0
].
y
,
vertexNormals
[
0
].
z
),
getNormalIndex
(
vertexNormals
[
1
].
x
,
vertexNormals
[
1
].
y
,
vertexNormals
[
1
].
z
),
getNormalIndex
(
vertexNormals
[
2
].
x
,
vertexNormals
[
2
].
y
,
vertexNormals
[
2
].
z
),
getNormalIndex
(
vertexNormals
[
3
].
x
,
vertexNormals
[
3
].
y
,
vertexNormals
[
3
].
z
)
getNormalIndex
(
vertexNormals
[
0
]
),
getNormalIndex
(
vertexNormals
[
1
]
),
getNormalIndex
(
vertexNormals
[
2
]
),
getNormalIndex
(
vertexNormals
[
3
]
)
);
}
}
if
(
hasFaceColor
)
{
faces
.
push
(
getColorIndex
(
face
.
color
)
);
}
if
(
hasFaceVertexColor
)
{
var
vertexColors
=
face
.
vertexColors
;
if
(
isTriangle
)
{
faces
.
push
(
getColorIndex
(
vertexColors
[
0
]
),
getColorIndex
(
vertexColors
[
1
]
),
getColorIndex
(
vertexColors
[
2
]
)
);
}
else
{
faces
.
push
(
getColorIndex
(
vertexColors
[
0
]
),
getColorIndex
(
vertexColors
[
1
]
),
getColorIndex
(
vertexColors
[
2
]
),
getColorIndex
(
vertexColors
[
3
]
)
);
}
...
...
@@ -150,9 +181,9 @@ THREE.GeometryExporter.prototype = {
}
function
getNormalIndex
(
x
,
y
,
z
)
{
function
getNormalIndex
(
normal
)
{
var
hash
=
x
.
toString
()
+
y
.
toString
()
+
z
.
toString
();
var
hash
=
normal
.
x
.
toString
()
+
normal
.
y
.
toString
()
+
normal
.
z
.
toString
();
if
(
normalsHash
[
hash
]
!==
undefined
)
{
...
...
@@ -161,15 +192,33 @@ THREE.GeometryExporter.prototype = {
}
normalsHash
[
hash
]
=
normals
.
length
/
3
;
normals
.
push
(
x
,
y
,
z
);
normals
.
push
(
normal
.
x
,
normal
.
y
,
normal
.
z
);
return
normalsHash
[
hash
];
}
function
getColorIndex
(
color
)
{
var
hash
=
color
.
r
.
toString
()
+
color
.
g
.
toString
()
+
color
.
b
.
toString
();
if
(
colorsHash
[
hash
]
!==
undefined
)
{
return
colorsHash
[
hash
];
}
colorsHash
[
hash
]
=
colors
.
length
;
colors
.
push
(
color
.
getHex
()
);
return
colorsHash
[
hash
];
}
output
.
vertices
=
vertices
;
output
.
normals
=
normals
;
output
.
uvs
=
uvs
;
output
.
colors
=
colors
;
// output.uvs = uvs;
output
.
faces
=
faces
;
//
...
...
examples/js/exporters/MaterialExporter.js
浏览文件 @
3bbaec7d
...
...
@@ -26,6 +26,7 @@ THREE.MaterialExporter.prototype = {
output
.
type
=
'
MeshBasicMaterial
'
;
output
.
color
=
material
.
color
.
getHex
();
output
.
vertexColors
=
material
.
vertexColors
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
...
...
@@ -36,6 +37,7 @@ THREE.MaterialExporter.prototype = {
output
.
color
=
material
.
color
.
getHex
();
output
.
ambient
=
material
.
ambient
.
getHex
();
output
.
emissive
=
material
.
emissive
.
getHex
();
output
.
vertexColors
=
material
.
vertexColors
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
...
...
@@ -48,6 +50,7 @@ THREE.MaterialExporter.prototype = {
output
.
emissive
=
material
.
emissive
.
getHex
();
output
.
specular
=
material
.
specular
.
getHex
();
output
.
shininess
=
material
.
shininess
;
output
.
vertexColors
=
material
.
vertexColors
;
output
.
opacity
=
material
.
opacity
;
output
.
transparent
=
material
.
transparent
;
output
.
wireframe
=
material
.
wireframe
;
...
...
src/loaders/JSONLoader.js
浏览文件 @
3bbaec7d
...
...
@@ -140,18 +140,22 @@ THREE.JSONLoader.prototype.parse = function ( json, texturePath ) {
nUvLayers
=
0
;
// disregard empty arrays
if
(
json
.
uvs
!==
undefined
)
{
for
(
i
=
0
;
i
<
json
.
uvs
.
length
;
i
++
)
{
// disregard empty arrays
if
(
json
.
uvs
[
i
].
length
)
nUvLayers
++
;
for
(
i
=
0
;
i
<
json
.
uvs
.
length
;
i
++
)
{
}
if
(
json
.
uvs
[
i
].
length
)
nUvLayers
++
;
}
for
(
i
=
0
;
i
<
nUvLayers
;
i
++
)
{
for
(
i
=
0
;
i
<
nUvLayers
;
i
++
)
{
geometry
.
faceUvs
[
i
]
=
[];
geometry
.
faceVertexUvs
[
i
]
=
[];
geometry
.
faceUvs
[
i
]
=
[];
geometry
.
faceVertexUvs
[
i
]
=
[];
}
}
...
...
src/loaders/MaterialLoader.js
浏览文件 @
3bbaec7d
...
...
@@ -43,6 +43,7 @@ THREE.MaterialLoader.prototype = {
material
=
new
THREE
.
MeshBasicMaterial
(
{
color
:
json
.
color
,
vertexColors
:
json
.
vertexColors
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
...
...
@@ -58,6 +59,7 @@ THREE.MaterialLoader.prototype = {
color
:
json
.
color
,
ambient
:
json
.
ambient
,
emissive
:
json
.
emissive
,
vertexColors
:
json
.
vertexColors
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
...
...
@@ -75,6 +77,7 @@ THREE.MaterialLoader.prototype = {
emissive
:
json
.
emissive
,
specular
:
json
.
specular
,
shininess
:
json
.
shininess
,
vertexColors
:
json
.
vertexColors
,
opacity
:
json
.
opacity
,
transparent
:
json
.
transparent
,
wireframe
:
json
.
wireframe
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录