Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
3bc9e619
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,体验更适合开发者的 AI 搜索 >>
提交
3bc9e619
编写于
12月 23, 2020
作者:
M
Mugen87
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove converter scripts.
上级
96c001f4
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
0 addition
and
128 deletion
+0
-128
utils/converters/README.md
utils/converters/README.md
+0
-18
utils/converters/fbx2three.js
utils/converters/fbx2three.js
+0
-81
utils/converters/obj2three.js
utils/converters/obj2three.js
+0
-29
未找到文件。
utils/converters/README.md
已删除
100644 → 0
浏览文件 @
96c001f4
Utilities for converting model files to the Three.js JSON format.
It's necessary to install the
[
esm
](
https://www.npmjs.com/package/esm
)
npm package before you can use the converters.
## obj2three.js
Usage:
```
node -r esm obj2three.js model.obj
```
## fbx2three.js
Usage:
```
node -r esm fbx2three.js model.fbx
```
utils/converters/fbx2three.js
已删除
100644 → 0
浏览文件 @
96c001f4
import
fs
from
'
fs
'
;
import
path
from
'
path
'
;
import
{
FBXLoader
}
from
'
../../examples/jsm/loaders/FBXLoader.js
'
;
import
{
ImageLoader
,
ImageUtils
,
LoaderUtils
}
from
'
../../build/three.module.js
'
;
if
(
process
.
argv
.
length
<=
2
)
{
console
.
log
(
`Usage:
${
path
.
basename
(
__filename
)}
model.fbx`
);
process
.
exit
(
-
1
);
}
//
const
PRECISION
=
6
;
function
parseNumber
(
key
,
value
)
{
return
typeof
value
===
'
number
'
?
parseFloat
(
value
.
toFixed
(
PRECISION
)
)
:
value
;
}
global
.
window
=
{
innerWidth
:
1024
,
innerHeight
:
768
,
URL
:
{
createObjectURL
:
function
()
{
throw
new
Error
(
'
fbx2three: Images in binary format not yet supported.
'
);
}
}
};
// HTML Images are not available, so use a Buffer instead.
ImageLoader
.
prototype
.
load
=
function
(
url
,
onLoad
)
{
if
(
this
.
path
!==
undefined
)
url
=
this
.
path
+
url
;
// If image isn't found, try to ignore it.
if
(
!
fs
.
existsSync
(
url
)
)
{
onLoad
(
new
Buffer
(
''
)
);
return
;
}
onLoad
(
fs
.
readFileSync
(
url
)
);
};
// Convert image buffer to data URL.
ImageUtils
.
getDataURL
=
function
(
image
)
{
if
(
!
(
image
instanceof
Buffer
)
)
{
throw
new
Error
(
'
fbx2three: Image should be loaded as Buffer.
'
);
}
let
dataURL
=
'
data:
'
;
dataURL
+=
this
.
format
===
THREE
.
RGBAFormat
?
'
image/png
'
:
'
image/jpeg
'
;
dataURL
+=
'
;base64,
'
;
dataURL
+=
image
.
toString
(
'
base64
'
);
return
dataURL
;
};
//
const
file
=
process
.
argv
[
2
];
const
resourceDirectory
=
LoaderUtils
.
extractUrlBase
(
file
);
const
loader
=
new
FBXLoader
();
const
arraybuffer
=
fs
.
readFileSync
(
file
).
buffer
;
const
object
=
loader
.
parse
(
arraybuffer
,
resourceDirectory
);
const
content
=
JSON
.
stringify
(
object
.
toJSON
(),
parseNumber
);
fs
.
writeFileSync
(
path
.
basename
(
file
,
'
.fbx
'
)
+
'
.json
'
,
content
,
'
utf8
'
);
utils/converters/obj2three.js
已删除
100644 → 0
浏览文件 @
96c001f4
import
fs
from
'
fs
'
;
import
path
from
'
path
'
;
import
{
OBJLoader
}
from
'
../../examples/jsm/loaders/OBJLoader.js
'
;
if
(
process
.
argv
.
length
<=
2
)
{
console
.
log
(
"
Usage:
"
+
path
.
basename
(
__filename
)
+
"
model.obj
"
);
process
.
exit
(
-
1
);
}
//
const
PRECISION
=
6
;
function
parseNumber
(
key
,
value
)
{
return
typeof
value
===
'
number
'
?
parseFloat
(
value
.
toFixed
(
PRECISION
)
)
:
value
;
}
const
file
=
process
.
argv
[
2
];
const
loader
=
new
OBJLoader
();
const
text
=
fs
.
readFileSync
(
file
,
'
utf8
'
);
const
content
=
JSON
.
stringify
(
loader
.
parse
(
text
).
toJSON
(),
parseNumber
);
fs
.
writeFileSync
(
path
.
basename
(
file
,
'
.obj
'
)
+
'
.json
'
,
content
,
'
utf8
'
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录