Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
f8ac3ca2
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,发现更多精彩内容 >>
提交
f8ac3ca2
编写于
8月 16, 2017
作者:
M
Mr.doob
提交者:
GitHub
8月 16, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11968 from fernandojsg/gltfconst
Fix #11962 Remove WebGLUtils and renderer dependency
上级
7fb838c3
ba5f094e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
60 addition
and
30 deletion
+60
-30
examples/js/exporters/GLTFExporter.js
examples/js/exporters/GLTFExporter.js
+59
-29
examples/misc_exporter_gltf.html
examples/misc_exporter_gltf.html
+1
-1
未找到文件。
examples/js/exporters/GLTFExporter.js
浏览文件 @
f8ac3ca2
...
...
@@ -2,14 +2,47 @@
* @author fernandojsg / http://fernandojsg.com
*/
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
var
WEBGL_CONSTANTS
=
{
POINTS
:
0x0000
,
LINES
:
0x0001
,
LINE_LOOP
:
0x0002
,
LINE_STRIP
:
0x0003
,
TRIANGLES
:
0x0004
,
TRIANGLE_STRIP
:
0x0005
,
TRIANGLE_FAN
:
0x0006
,
UNSIGNED_BYTE
:
0x1401
,
UNSIGNED_SHORT
:
0x1403
,
FLOAT
:
0x1406
,
UNSIGNED_INT
:
0x1405
,
ARRAY_BUFFER
:
0x8892
,
ELEMENT_ARRAY_BUFFER
:
0x8893
,
NEAREST
:
0x2600
,
LINEAR
:
0x2601
,
NEAREST_MIPMAP_NEAREST
:
0x2700
,
LINEAR_MIPMAP_NEAREST
:
0x2701
,
NEAREST_MIPMAP_LINEAR
:
0x2702
,
LINEAR_MIPMAP_LINEAR
:
0x2703
};
var
THREE_TO_WEBGL
=
{
// @TODO Replace with computed property name [THREE.*] when available on es6
1003
:
WEBGL_CONSTANTS
.
NEAREST
,
1004
:
WEBGL_CONSTANTS
.
LINEAR
,
1005
:
WEBGL_CONSTANTS
.
NEAREST_MIPMAP_NEAREST
,
1006
:
WEBGL_CONSTANTS
.
LINEAR_MIPMAP_NEAREST
,
1007
:
WEBGL_CONSTANTS
.
NEAREST_MIPMAP_LINEAR
,
1008
:
WEBGL_CONSTANTS
.
LINEAR_MIPMAP_LINEAR
};
//------------------------------------------------------------------------------
// GLTF Exporter
//------------------------------------------------------------------------------
THREE
.
GLTFExporter
=
function
(
renderer
)
{
this
.
renderer
=
renderer
;
};
THREE
.
GLTFExporter
=
function
()
{};
THREE
.
GLTFExporter
.
prototype
=
{
...
...
@@ -26,9 +59,6 @@ THREE.GLTFExporter.prototype = {
options
=
options
||
{};
var
glUtils
=
new
THREE
.
WebGLUtils
(
this
.
renderer
.
context
,
this
.
renderer
.
extensions
);
var
gl
=
this
.
renderer
.
context
;
var
outputJSON
=
{
asset
:
{
...
...
@@ -118,7 +148,7 @@ THREE.GLTFExporter.prototype = {
var
dataView
=
new
DataView
(
new
ArrayBuffer
(
attribute
.
array
.
byteLength
)
);
var
offset
=
0
;
var
offsetInc
=
componentType
===
gl
.
UNSIGNED_SHORT
?
2
:
4
;
var
offsetInc
=
componentType
===
WEBGL_CONSTANTS
.
UNSIGNED_SHORT
?
2
:
4
;
for
(
var
i
=
0
;
i
<
attribute
.
count
;
i
++
)
{
...
...
@@ -126,15 +156,15 @@ THREE.GLTFExporter.prototype = {
var
value
=
attribute
.
array
[
i
*
attribute
.
itemSize
+
a
];
if
(
componentType
===
gl
.
FLOAT
)
{
if
(
componentType
===
WEBGL_CONSTANTS
.
FLOAT
)
{
dataView
.
setFloat32
(
offset
,
value
,
true
);
}
else
if
(
componentType
===
gl
.
UNSIGNED_INT
)
{
}
else
if
(
componentType
===
WEBGL_CONSTANTS
.
UNSIGNED_INT
)
{
dataView
.
setUint8
(
offset
,
value
,
true
);
}
else
if
(
componentType
===
gl
.
UNSIGNED_SHORT
)
{
}
else
if
(
componentType
===
WEBGL_CONSTANTS
.
UNSIGNED_SHORT
)
{
dataView
.
setUint16
(
offset
,
value
,
true
);
...
...
@@ -160,7 +190,7 @@ THREE.GLTFExporter.prototype = {
*/
function
processBufferView
(
data
,
componentType
)
{
var
isVertexAttributes
=
componentType
===
gl
.
FLOAT
;
var
isVertexAttributes
=
componentType
===
WEBGL_CONSTANTS
.
FLOAT
;
if
(
!
outputJSON
.
bufferViews
)
{
...
...
@@ -173,8 +203,8 @@ THREE.GLTFExporter.prototype = {
buffer
:
processBuffer
(
data
,
componentType
),
byteOffset
:
byteOffset
,
byteLength
:
data
.
array
.
byteLength
,
byteStride
:
data
.
itemSize
*
(
componentType
===
gl
.
UNSIGNED_SHORT
?
2
:
4
),
target
:
isVertexAttributes
?
gl
.
ARRAY_BUFFER
:
gl
.
ELEMENT_ARRAY_BUFFER
byteStride
:
data
.
itemSize
*
(
componentType
===
WEBGL_CONSTANTS
.
UNSIGNED_SHORT
?
2
:
4
),
target
:
isVertexAttributes
?
WEBGL_CONSTANTS
.
ARRAY_BUFFER
:
WEBGL_CONSTANTS
.
ELEMENT_ARRAY_BUFFER
};
...
...
@@ -221,15 +251,15 @@ THREE.GLTFExporter.prototype = {
// Detect the component type of the attribute array (float, uint or ushort)
if
(
attribute
.
array
.
constructor
===
Float32Array
)
{
componentType
=
gl
.
FLOAT
;
componentType
=
WEBGL_CONSTANTS
.
FLOAT
;
}
else
if
(
attribute
.
array
.
constructor
===
Uint32Array
)
{
componentType
=
gl
.
UNSIGNED_INT
;
componentType
=
WEBGL_CONSTANTS
.
UNSIGNED_INT
;
}
else
if
(
attribute
.
array
.
constructor
===
Uint16Array
)
{
componentType
=
gl
.
UNSIGNED_SHORT
;
componentType
=
WEBGL_CONSTANTS
.
UNSIGNED_SHORT
;
}
else
{
...
...
@@ -305,10 +335,10 @@ THREE.GLTFExporter.prototype = {
var
gltfSampler
=
{
magFilter
:
glUtils
.
convert
(
map
.
magFilter
)
,
minFilter
:
glUtils
.
convert
(
map
.
minFilter
)
,
wrapS
:
glUtils
.
convert
(
map
.
wrapS
)
,
wrapT
:
glUtils
.
convert
(
map
.
wrapT
)
magFilter
:
THREE_TO_WEBGL
[
map
.
magFilter
]
,
minFilter
:
THREE_TO_WEBGL
[
map
.
minFilter
]
,
wrapS
:
THREE_TO_WEBGL
[
map
.
wrapS
]
,
wrapT
:
THREE_TO_WEBGL
[
map
.
wrapT
]
};
...
...
@@ -500,19 +530,19 @@ THREE.GLTFExporter.prototype = {
// Use the correct mode
if
(
mesh
instanceof
THREE
.
LineSegments
)
{
mode
=
gl
.
LINES
;
mode
=
WEBGL_CONSTANTS
.
LINES
;
}
else
if
(
mesh
instanceof
THREE
.
LineLoop
)
{
mode
=
gl
.
LINE_LOOP
;
mode
=
WEBGL_CONSTANTS
.
LINE_LOOP
;
}
else
if
(
mesh
instanceof
THREE
.
Line
)
{
mode
=
gl
.
LINE_STRIP
;
mode
=
WEBGL_CONSTANTS
.
LINE_STRIP
;
}
else
if
(
mesh
instanceof
THREE
.
Points
)
{
mode
=
gl
.
POINTS
;
mode
=
WEBGL_CONSTANTS
.
POINTS
;
}
else
{
...
...
@@ -527,15 +557,15 @@ THREE.GLTFExporter.prototype = {
if
(
mesh
.
drawMode
===
THREE
.
TriangleFanDrawMode
)
{
console
.
warn
(
'
GLTFExporter: TriangleFanDrawMode and wireframe incompatible.
'
);
mode
=
gl
.
TRIANGLE_FAN
;
mode
=
WEBGL_CONSTANTS
.
TRIANGLE_FAN
;
}
else
if
(
mesh
.
drawMode
===
THREE
.
TriangleStripDrawMode
)
{
mode
=
mesh
.
material
.
wireframe
?
gl
.
LINE_STRIP
:
gl
.
TRIANGLE_STRIP
;
mode
=
mesh
.
material
.
wireframe
?
WEBGL_CONSTANTS
.
LINE_STRIP
:
WEBGL_CONSTANTS
.
TRIANGLE_STRIP
;
}
else
{
mode
=
mesh
.
material
.
wireframe
?
gl
.
LINES
:
gl
.
TRIANGLES
;
mode
=
mesh
.
material
.
wireframe
?
WEBGL_CONSTANTS
.
LINES
:
WEBGL_CONSTANTS
.
TRIANGLES
;
}
...
...
examples/misc_exporter_gltf.html
浏览文件 @
f8ac3ca2
...
...
@@ -39,7 +39,7 @@
function
exportGLTF
(
input
)
{
var
gltfExporter
=
new
THREE
.
GLTFExporter
(
renderer
);
var
gltfExporter
=
new
THREE
.
GLTFExporter
();
gltfExporter
.
parse
(
input
,
function
(
result
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录