Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
d681e0f0
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,发现更多精彩内容 >>
提交
d681e0f0
编写于
5月 17, 2017
作者:
T
Takahiro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improve the converting performance from ArrayBuffer to String with TextCoder and some tunings.
上级
9c6b7a9a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
61 addition
and
25 deletion
+61
-25
examples/js/loaders/FBXLoader.js
examples/js/loaders/FBXLoader.js
+6
-0
examples/js/loaders/GLTF2Loader.js
examples/js/loaders/GLTF2Loader.js
+10
-3
examples/js/loaders/GLTFLoader.js
examples/js/loaders/GLTFLoader.js
+10
-3
examples/js/loaders/PLYLoader.js
examples/js/loaders/PLYLoader.js
+14
-14
examples/js/loaders/STLLoader.js
examples/js/loaders/STLLoader.js
+13
-4
examples/js/loaders/XLoader.js
examples/js/loaders/XLoader.js
+8
-1
未找到文件。
examples/js/loaders/FBXLoader.js
浏览文件 @
d681e0f0
...
...
@@ -4960,6 +4960,12 @@
var
array
=
new
Uint8Array
(
buffer
,
from
,
to
);
if
(
window
.
TextDecoder
!==
undefined
)
{
return
new
TextDecoder
().
decode
(
array
);
}
var
s
=
''
;
for
(
var
i
=
0
,
il
=
array
.
length
;
i
<
il
;
i
++
)
{
...
...
examples/js/loaders/GLTF2Loader.js
浏览文件 @
d681e0f0
...
...
@@ -978,13 +978,20 @@ THREE.GLTF2Loader = ( function () {
}
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
// throws a "maximum call stack size exceeded" error for large arrays.
function
convertUint8ArrayToString
(
array
)
{
if
(
window
.
TextDecoder
!==
undefined
)
{
return
new
TextDecoder
().
decode
(
array
);
}
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
// throws a "maximum call stack size exceeded" error for large arrays.
var
s
=
''
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
for
(
var
i
=
0
,
il
=
array
.
length
;
i
<
il
;
i
++
)
{
s
+=
String
.
fromCharCode
(
array
[
i
]
);
...
...
examples/js/loaders/GLTFLoader.js
浏览文件 @
d681e0f0
...
...
@@ -662,13 +662,20 @@ THREE.GLTFLoader = ( function () {
}
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
// throws a "maximum call stack size exceeded" error for large arrays.
function
convertUint8ArrayToString
(
array
)
{
if
(
window
.
TextDecoder
!==
undefined
)
{
//return new TextDecoder().decode( array );
}
// Avoid the String.fromCharCode.apply(null, array) shortcut, which
// throws a "maximum call stack size exceeded" error for large arrays.
var
s
=
''
;
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
for
(
var
i
=
0
,
il
=
array
.
length
;
i
<
il
;
i
++
)
{
s
+=
String
.
fromCharCode
(
array
[
i
]
);
...
...
examples/js/loaders/PLYLoader.js
浏览文件 @
d681e0f0
...
...
@@ -61,19 +61,19 @@ THREE.PLYLoader.prototype = {
parse
:
function
(
data
)
{
function
isASCII
(
data
)
{
function
bin2str
(
buf
)
{
var
header
=
parseHeader
(
bin2str
(
data
)
);
return
header
.
format
===
'
ascii
'
;
var
array_buffer
=
new
Uint8Array
(
buf
);
}
if
(
window
.
TextDecoder
!==
undefined
)
{
function
bin2str
(
buf
)
{
return
new
TextDecoder
().
decode
(
array_buffer
);
}
var
array_buffer
=
new
Uint8Array
(
buf
);
var
str
=
''
;
for
(
var
i
=
0
;
i
<
buf
.
byteLength
;
i
++
)
{
for
(
var
i
=
0
,
il
=
buf
.
byteLength
;
i
<
il
;
i
++
)
{
str
+=
String
.
fromCharCode
(
array_buffer
[
i
]
);
// implicitly assumes little-endian
...
...
@@ -249,7 +249,7 @@ THREE.PLYLoader.prototype = {
}
function
parseASCII
(
data
)
{
function
parseASCII
(
data
,
header
)
{
// PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)
...
...
@@ -263,8 +263,6 @@ THREE.PLYLoader.prototype = {
var
result
;
var
header
=
parseHeader
(
data
);
var
patternBody
=
/end_header
\s([\s\S]
*
)
$/
;
var
body
=
''
;
if
(
(
result
=
patternBody
.
exec
(
data
)
)
!==
null
)
{
...
...
@@ -446,7 +444,7 @@ THREE.PLYLoader.prototype = {
}
function
parseBinary
(
data
)
{
function
parseBinary
(
data
,
header
)
{
var
buffer
=
{
indices
:
[],
...
...
@@ -456,7 +454,6 @@ THREE.PLYLoader.prototype = {
colors
:
[]
};
var
header
=
parseHeader
(
bin2str
(
data
)
);
var
little_endian
=
(
header
.
format
===
'
binary_little_endian
'
);
var
body
=
new
DataView
(
data
,
header
.
headerLength
);
var
result
,
loc
=
0
;
...
...
@@ -486,11 +483,14 @@ THREE.PLYLoader.prototype = {
if
(
data
instanceof
ArrayBuffer
)
{
geometry
=
isASCII
(
data
)
?
parseASCII
(
bin2str
(
data
)
)
:
parseBinary
(
data
);
var
text
=
bin2str
(
data
);
var
header
=
parseHeader
(
text
);
geometry
=
header
.
format
===
'
ascii
'
?
parseASCII
(
text
,
header
)
:
parseBinary
(
data
,
header
);
}
else
{
geometry
=
parseASCII
(
data
);
geometry
=
parseASCII
(
data
,
parseHeader
(
data
)
);
}
...
...
examples/js/loaders/STLLoader.js
浏览文件 @
d681e0f0
...
...
@@ -245,13 +245,22 @@ THREE.STLLoader.prototype = {
if
(
typeof
buf
!==
"
string
"
)
{
var
array_buffer
=
new
Uint8Array
(
buf
);
var
strArray
=
[];
for
(
var
i
=
0
;
i
<
buf
.
byteLength
;
i
++
)
{
strArray
.
push
(
String
.
fromCharCode
(
array_buffer
[
i
]
));
// implicitly assumes little-endian
if
(
window
.
TextDecoder
!==
undefined
)
{
return
new
TextDecoder
().
decode
(
array_buffer
);
}
return
strArray
.
join
(
''
);
var
str
=
''
;
for
(
var
i
=
0
,
il
=
buf
.
byteLength
;
i
<
il
;
i
++
)
{
str
+=
String
.
fromCharCode
(
array_buffer
[
i
]
);
// implicitly assumes little-endian
}
return
str
;
}
else
{
...
...
examples/js/loaders/XLoader.js
浏览文件 @
d681e0f0
...
...
@@ -362,8 +362,15 @@ THREE.XLoader = function () {
if
(
typeof
buf
!==
"
string
"
)
{
var
array_buffer
=
new
Uint8Array
(
buf
);
if
(
window
.
TextDecoder
!==
undefined
)
{
return
new
TextDecoder
().
decode
(
array_buffer
);
}
var
str
=
''
;
for
(
var
i
=
0
;
i
<
buf
.
byteLength
;
i
++
)
{
for
(
var
i
=
0
,
il
=
buf
.
byteLength
;
i
<
il
;
i
++
)
{
str
+=
String
.
fromCharCode
(
array_buffer
[
i
]
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录