Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
7f6bc372
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,发现更多精彩内容 >>
提交
7f6bc372
编写于
3月 13, 2017
作者:
E
edsilv
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
updated DRACOLoader.js and draco_decoder.js
上级
4d4a569a
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
56 addition
and
37 deletion
+56
-37
examples/js/loaders/DRACOLoader.js
examples/js/loaders/DRACOLoader.js
+43
-22
examples/js/loaders/draco_decoder.js
examples/js/loaders/draco_decoder.js
+13
-15
未找到文件。
examples/js/loaders/DRACOLoader.js
浏览文件 @
7f6bc372
...
...
@@ -18,6 +18,7 @@ THREE.DRACOLoader = function(manager) {
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
this
.
materials
=
null
;
this
.
verbosity
=
0
;
};
...
...
@@ -39,6 +40,10 @@ THREE.DRACOLoader.prototype = {
this
.
path
=
value
;
},
setVerbosity
:
function
(
level
)
{
this
.
verbosity
=
level
;
},
decodeDracoFile
:
(
function
()
{
let
dracoDecoder
;
...
...
@@ -63,12 +68,16 @@ THREE.DRACOLoader.prototype = {
*/
const
geometryType
=
wrapper
.
GetEncodedGeometryType
(
buffer
);
if
(
geometryType
==
dracoDecoder
.
TRIANGULAR_MESH
)
{
//fileDisplayArea.innerText = "Loaded a mesh.\n";
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Loaded a mesh.
'
);
}
}
else
if
(
geometryType
==
dracoDecoder
.
POINT_CLOUD
)
{
//fileDisplayArea.innerText = "Loaded a point cloud.\n";
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Loaded a point cloud.
'
);
}
}
else
{
const
errorMsg
=
"
Error: Unknown geometry type.
"
;
//fileDisplayArea.innerText = errorMsg
;
const
errorMsg
=
'
THREE.DRACOLoader: Unknown geometry type.
'
console
.
error
(
errorMsg
)
;
throw
new
Error
(
errorMsg
);
}
return
scope
.
convertDracoGeometryTo3JS
(
wrapper
,
geometryType
,
buffer
,
...
...
@@ -96,8 +105,9 @@ THREE.DRACOLoader.prototype = {
let
geometryInfoStr
;
if
(
geometryType
==
dracoDecoder
.
TRIANGULAR_MESH
)
{
numFaces
=
dracoGeometry
.
num_faces
();
geometryInfoStr
+=
"
Number of faces loaded:
"
+
numFaces
.
toString
()
+
"
.
\n
"
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Number of faces loaded:
'
+
numFaces
.
toString
());
}
}
else
{
numFaces
=
0
;
}
...
...
@@ -105,17 +115,18 @@ THREE.DRACOLoader.prototype = {
numVertexCoordinates
=
numPoints
*
3
;
numTextureCoordinates
=
numPoints
*
2
;
numAttributes
=
dracoGeometry
.
num_attributes
();
geometryInfoStr
=
"
Number of points loaded:
"
+
numPoints
.
toString
()
+
"
.
\n
"
;
geometryInfoStr
+=
"
Number of attributes loaded:
"
+
numAttributes
.
toString
()
+
"
.
\n
"
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Number of points loaded:
'
+
numPoints
.
toString
());
console
.
log
(
'
Number of attributes loaded:
'
+
numAttributes
.
toString
());
}
// Get position attribute. Must exists.
const
posAttId
=
wrapper
.
GetAttributeId
(
dracoGeometry
,
dracoDecoder
.
POSITION
);
if
(
posAttId
==
-
1
)
{
const
errorMsg
=
"
No position attribute found in the mesh.
"
;
//fileDisplayArea.innerText = errorMsg
;
const
errorMsg
=
'
THREE.DRACOLoader: No position attribute found.
'
;
console
.
error
(
errorMsg
)
;
dracoDecoder
.
destroy
(
wrapper
);
dracoDecoder
.
destroy
(
dracoGeometry
);
throw
new
Error
(
errorMsg
);
...
...
@@ -129,7 +140,9 @@ THREE.DRACOLoader.prototype = {
dracoDecoder
.
COLOR
);
let
colAttributeData
;
if
(
colorAttId
!=
-
1
)
{
geometryInfoStr
+=
"
\n
Loaded color attribute.
\n
"
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Loaded color attribute.
'
);
}
const
colAttribute
=
wrapper
.
GetAttribute
(
dracoGeometry
,
colorAttId
);
colAttributeData
=
new
dracoDecoder
.
DracoFloat32Array
();
wrapper
.
GetAttributeFloatForAllPoints
(
dracoGeometry
,
colAttribute
,
...
...
@@ -141,7 +154,9 @@ THREE.DRACOLoader.prototype = {
wrapper
.
GetAttributeId
(
dracoGeometry
,
dracoDecoder
.
NORMAL
);
let
norAttributeData
;
if
(
normalAttId
!=
-
1
)
{
geometryInfoStr
+=
"
\n
Loaded normal attribute.
\n
"
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Loaded normal attribute.
'
);
}
const
norAttribute
=
wrapper
.
GetAttribute
(
dracoGeometry
,
normalAttId
);
norAttributeData
=
new
dracoDecoder
.
DracoFloat32Array
();
wrapper
.
GetAttributeFloatForAllPoints
(
dracoGeometry
,
norAttribute
,
...
...
@@ -153,7 +168,9 @@ THREE.DRACOLoader.prototype = {
wrapper
.
GetAttributeId
(
dracoGeometry
,
dracoDecoder
.
TEX_COORD
);
let
textCoordAttributeData
;
if
(
texCoordAttId
!=
-
1
)
{
geometryInfoStr
+=
"
\n
Loaded texture coordinate attribute.
\n
"
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Loaded texture coordinate attribute.
'
);
}
const
texCoordAttribute
=
wrapper
.
GetAttribute
(
dracoGeometry
,
texCoordAttId
);
textCoordAttributeData
=
new
dracoDecoder
.
DracoFloat32Array
();
...
...
@@ -180,8 +197,10 @@ THREE.DRACOLoader.prototype = {
// ThreeJS vertex colors need to be normalized to properly display
if
(
colorAttId
!=
-
1
)
{
geometryBuffer
.
colors
[
i
]
=
colAttributeData
.
GetValue
(
i
)
/
255
;
geometryBuffer
.
colors
[
i
+
1
]
=
colAttributeData
.
GetValue
(
i
+
1
)
/
255
;
geometryBuffer
.
colors
[
i
+
2
]
=
colAttributeData
.
GetValue
(
i
+
2
)
/
255
;
geometryBuffer
.
colors
[
i
+
1
]
=
colAttributeData
.
GetValue
(
i
+
1
)
/
255
;
geometryBuffer
.
colors
[
i
+
2
]
=
colAttributeData
.
GetValue
(
i
+
2
)
/
255
;
}
else
{
// Default is white. This is faster than TypedArray.fill().
geometryBuffer
.
colors
[
i
]
=
1.0
;
...
...
@@ -227,8 +246,6 @@ THREE.DRACOLoader.prototype = {
dracoDecoder
.
destroy
(
wrapper
);
dracoDecoder
.
destroy
(
dracoGeometry
);
//fileDisplayArea.innerText += geometryInfoStr;
// Import data to Three JS geometry.
const
geometry
=
new
THREE
.
BufferGeometry
();
if
(
geometryType
==
dracoDecoder
.
TRIANGULAR_MESH
)
{
...
...
@@ -248,9 +265,13 @@ THREE.DRACOLoader.prototype = {
geometry
.
addAttribute
(
'
uv
'
,
new
THREE
.
Float32BufferAttribute
(
geometryBuffer
.
uvs
,
2
));
}
//fileDisplayArea.innerText += ' decode:' + (decode_end - start_time);
//fileDisplayArea.innerText +=
// ' import:' + (performance.now() - decode_end);
this
.
decode_time
=
decode_end
-
start_time
;
this
.
import_time
=
performance
.
now
()
-
decode_end
;
if
(
this
.
verbosity
>
0
)
{
console
.
log
(
'
Decode time:
'
+
this
.
decode_time
);
console
.
log
(
'
Import time:
'
+
this
.
import_time
);
}
return
geometry
;
}
};
\ No newline at end of file
examples/js/loaders/draco_decoder.js
浏览文件 @
7f6bc372
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录