Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
362fc596
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,发现更多精彩内容 >>
提交
362fc596
编写于
8月 10, 2017
作者:
F
Fernando Serrano
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove WebGLConstans and use renderer.context instead
上级
f1804974
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
44 deletion
+12
-44
examples/js/exporters/GLTFExporter.js
examples/js/exporters/GLTFExporter.js
+12
-44
未找到文件。
examples/js/exporters/GLTFExporter.js
浏览文件 @
362fc596
...
...
@@ -2,39 +2,6 @@
* @author fernandojsg / http://fernandojsg.com
*/
// @TODO Move it to constants.js ?
var
WebGLConstants
=
{
POINTS
:
0x0000
,
LINES
:
0x0001
,
LINE_LOOP
:
0x0002
,
LINE_STRIP
:
0x0003
,
TRIANGLES
:
0x0004
,
TRIANGLE_STRIP
:
0x0005
,
TRIANGLE_FAN
:
0x0006
,
ARRAY_BUFFER
:
0x8892
,
ELEMENT_ARRAY_BUFFER
:
0x8893
,
BYTE
:
0x1400
,
UNSIGNED_BYTE
:
0x1401
,
SHORT
:
0x1402
,
UNSIGNED_SHORT
:
0x1403
,
INT
:
0x1404
,
UNSIGNED_INT
:
0x1405
,
FLOAT
:
0x1406
,
NEAREST
:
0x2600
,
LINEAR
:
0x2601
,
NEAREST_MIPMAP_NEAREST
:
0x2700
,
LINEAR_MIPMAP_NEAREST
:
0x2701
,
NEAREST_MIPMAP_LINEAR
:
0x2702
,
LINEAR_MIPMAP_LINEAR
:
0x2703
,
REPEAT
:
0x2901
,
CLAMP_TO_EDGE
:
0x812F
,
MIRRORED_REPEAT
:
0x8370
,
};
//------------------------------------------------------------------------------
// GLTF Exporter
//------------------------------------------------------------------------------
...
...
@@ -57,7 +24,8 @@ THREE.GLTFExporter.prototype = {
options
=
options
||
{};
var
glUtils
=
new
THREE
.
WebGLUtils
(
renderer
.
context
,
renderer
.
extensions
);
var
glUtils
=
new
THREE
.
WebGLUtils
(
this
.
renderer
.
context
,
this
.
renderer
.
extensions
);
var
gl
=
this
.
renderer
.
context
;
var
outputJSON
=
{
asset
:
{
...
...
@@ -134,16 +102,16 @@ THREE.GLTFExporter.prototype = {
var
dataView
=
new
DataView
(
new
ArrayBuffer
(
attribute
.
array
.
byteLength
)
);
var
offset
=
0
;
var
offsetInc
=
componentType
===
WebGLConstants
.
UNSIGNED_SHORT
?
2
:
4
;
var
offsetInc
=
componentType
===
gl
.
UNSIGNED_SHORT
?
2
:
4
;
for
(
var
i
=
0
;
i
<
attribute
.
count
;
i
++
)
{
for
(
var
a
=
0
;
a
<
attribute
.
itemSize
;
a
++
)
{
var
value
=
attribute
.
array
[
i
*
attribute
.
itemSize
+
a
];
if
(
componentType
===
WebGLConstants
.
FLOAT
)
{
if
(
componentType
===
gl
.
FLOAT
)
{
dataView
.
setFloat32
(
offset
,
value
,
true
);
}
else
if
(
componentType
===
WebGLConstants
.
UNSIGNED_INT
)
{
}
else
if
(
componentType
===
gl
.
UNSIGNED_INT
)
{
dataView
.
setUint8
(
offset
,
value
,
true
);
}
else
if
(
componentType
===
WebGLConstants
.
UNSIGNED_SHORT
)
{
}
else
if
(
componentType
===
gl
.
UNSIGNED_SHORT
)
{
dataView
.
setUint16
(
offset
,
value
,
true
);
}
offset
+=
offsetInc
;
...
...
@@ -162,7 +130,7 @@ THREE.GLTFExporter.prototype = {
* @return {[type]} [description]
*/
function
processBufferView
(
data
,
componentType
)
{
var
isVertexAttributes
=
componentType
===
WebGLConstants
.
FLOAT
;
var
isVertexAttributes
=
componentType
===
gl
.
FLOAT
;
if
(
!
outputJSON
.
bufferViews
)
{
outputJSON
.
bufferViews
=
[];
}
...
...
@@ -171,8 +139,8 @@ THREE.GLTFExporter.prototype = {
buffer
:
processBuffer
(
data
,
componentType
),
byteOffset
:
byteOffset
,
byteLength
:
data
.
array
.
byteLength
,
byteStride
:
data
.
itemSize
*
(
componentType
===
WebGLConstants
.
UNSIGNED_SHORT
?
2
:
4
),
target
:
isVertexAttributes
?
WebGLConstants
.
ARRAY_BUFFER
:
WebGLConstants
.
ELEMENT_ARRAY_BUFFER
byteStride
:
data
.
itemSize
*
(
componentType
===
gl
.
UNSIGNED_SHORT
?
2
:
4
),
target
:
isVertexAttributes
?
gl
.
ARRAY_BUFFER
:
gl
.
ELEMENT_ARRAY_BUFFER
};
byteOffset
+=
data
.
array
.
byteLength
;
...
...
@@ -205,8 +173,8 @@ THREE.GLTFExporter.prototype = {
];
// Detect the component type of the attribute array (float, uint or ushort)
var
componentType
=
attribute
instanceof
THREE
.
Float32BufferAttribute
?
WebGLConstants
.
FLOAT
:
(
attribute
instanceof
THREE
.
Uint32BufferAttribute
?
WebGLConstants
.
UNSIGNED_INT
:
WebGLConstants
.
UNSIGNED_SHORT
);
var
componentType
=
attribute
instanceof
THREE
.
Float32BufferAttribute
?
gl
.
FLOAT
:
(
attribute
instanceof
THREE
.
Uint32BufferAttribute
?
gl
.
UNSIGNED_INT
:
gl
.
UNSIGNED_SHORT
);
var
minMax
=
getMinMax
(
attribute
);
var
bufferView
=
processBufferView
(
attribute
,
componentType
);
...
...
@@ -348,7 +316,7 @@ THREE.GLTFExporter.prototype = {
var
geometry
=
mesh
.
geometry
;
// @FIXME Select the correct mode based on the mesh
var
mode
=
WebGLConstants
.
TRIANGLES
;
var
mode
=
gl
.
TRIANGLES
;
var
gltfMesh
=
{
primitives
:
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录