Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
db017959
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,发现更多精彩内容 >>
未验证
提交
db017959
编写于
2月 25, 2020
作者:
M
Mr.doob
提交者:
GitHub
2月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18728 from Mugen87/dev43
Utils: Move converters to modules.
上级
f5d83e9d
b0db7436
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
30 deletion
+27
-30
utils/converters/README.md
utils/converters/README.md
+3
-2
utils/converters/fbx2three.js
utils/converters/fbx2three.js
+15
-18
utils/converters/obj2three.js
utils/converters/obj2three.js
+9
-10
未找到文件。
utils/converters/README.md
浏览文件 @
db017959
Utilities for converting model files to the Three.js JSON format.
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
## obj2three.js
Usage:
Usage:
```
```
node obj2three.js model.obj
node
-r esm
obj2three.js model.obj
```
```
## fbx2three.js
## fbx2three.js
...
@@ -13,5 +14,5 @@ node obj2three.js model.obj
...
@@ -13,5 +14,5 @@ node obj2three.js model.obj
Usage:
Usage:
```
```
node fbx2three.js model.fbx
node
-r esm
fbx2three.js model.fbx
```
```
utils/converters/fbx2three.js
浏览文件 @
db017959
var
fs
=
require
(
'
fs
'
);
import
fs
from
'
fs
'
;
var
path
=
require
(
'
path
'
);
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
)
{
if
(
process
.
argv
.
length
<=
2
)
{
...
@@ -10,7 +13,7 @@ if ( process.argv.length <= 2 ) {
...
@@ -10,7 +13,7 @@ if ( process.argv.length <= 2 ) {
//
//
var
PRECISION
=
6
;
const
PRECISION
=
6
;
function
parseNumber
(
key
,
value
)
{
function
parseNumber
(
key
,
value
)
{
...
@@ -18,12 +21,6 @@ function parseNumber( key, value ) {
...
@@ -18,12 +21,6 @@ function parseNumber( key, value ) {
}
}
THREE
=
require
(
'
../../build/three.js
'
);
require
(
'
../../examples/js/curves/NURBSCurve.js
'
);
require
(
'
../../examples/js/curves/NURBSUtils.js
'
);
require
(
'
../../examples/js/loaders/FBXLoader.js
'
);
global
.
Zlib
=
require
(
'
../../examples/js/libs/inflate.min.js
'
).
Zlib
;
global
.
window
=
{
global
.
window
=
{
innerWidth
:
1024
,
innerWidth
:
1024
,
innerHeight
:
768
,
innerHeight
:
768
,
...
@@ -39,7 +36,7 @@ global.window = {
...
@@ -39,7 +36,7 @@ global.window = {
};
};
// HTML Images are not available, so use a Buffer instead.
// HTML Images are not available, so use a Buffer instead.
THREE
.
ImageLoader
.
prototype
.
load
=
function
(
url
,
onLoad
)
{
ImageLoader
.
prototype
.
load
=
function
(
url
,
onLoad
)
{
if
(
this
.
path
!==
undefined
)
url
=
this
.
path
+
url
;
if
(
this
.
path
!==
undefined
)
url
=
this
.
path
+
url
;
...
@@ -56,7 +53,7 @@ THREE.ImageLoader.prototype.load = function ( url, onLoad ) {
...
@@ -56,7 +53,7 @@ THREE.ImageLoader.prototype.load = function ( url, onLoad ) {
};
};
// Convert image buffer to data URL.
// Convert image buffer to data URL.
THREE
.
ImageUtils
.
getDataURL
=
function
(
image
)
{
ImageUtils
.
getDataURL
=
function
(
image
)
{
if
(
!
(
image
instanceof
Buffer
)
)
{
if
(
!
(
image
instanceof
Buffer
)
)
{
...
@@ -64,7 +61,7 @@ THREE.ImageUtils.getDataURL = function ( image ) {
...
@@ -64,7 +61,7 @@ THREE.ImageUtils.getDataURL = function ( image ) {
}
}
var
dataURL
=
'
data:
'
;
let
dataURL
=
'
data:
'
;
dataURL
+=
this
.
format
===
THREE
.
RGBAFormat
?
'
image/png
'
:
'
image/jpeg
'
;
dataURL
+=
this
.
format
===
THREE
.
RGBAFormat
?
'
image/png
'
:
'
image/jpeg
'
;
dataURL
+=
'
;base64,
'
;
dataURL
+=
'
;base64,
'
;
dataURL
+=
image
.
toString
(
'
base64
'
);
dataURL
+=
image
.
toString
(
'
base64
'
);
...
@@ -74,11 +71,11 @@ THREE.ImageUtils.getDataURL = function ( image ) {
...
@@ -74,11 +71,11 @@ THREE.ImageUtils.getDataURL = function ( image ) {
//
//
var
file
=
process
.
argv
[
2
];
const
file
=
process
.
argv
[
2
];
var
resourceDirectory
=
THREE
.
LoaderUtils
.
extractUrlBase
(
file
);
const
resourceDirectory
=
LoaderUtils
.
extractUrlBase
(
file
);
var
loader
=
new
THREE
.
FBXLoader
();
const
loader
=
new
FBXLoader
();
var
arraybuffer
=
fs
.
readFileSync
(
file
).
buffer
;
const
arraybuffer
=
fs
.
readFileSync
(
file
).
buffer
;
var
object
=
loader
.
parse
(
arraybuffer
,
resourceDirectory
);
const
object
=
loader
.
parse
(
arraybuffer
,
resourceDirectory
);
var
content
=
JSON
.
stringify
(
object
.
toJSON
(),
parseNumber
);
const
content
=
JSON
.
stringify
(
object
.
toJSON
(),
parseNumber
);
fs
.
writeFileSync
(
path
.
basename
(
file
,
'
.fbx
'
)
+
'
.json
'
,
content
,
'
utf8
'
);
fs
.
writeFileSync
(
path
.
basename
(
file
,
'
.fbx
'
)
+
'
.json
'
,
content
,
'
utf8
'
);
utils/converters/obj2three.js
浏览文件 @
db017959
var
fs
=
require
(
'
fs
'
);
import
fs
from
'
fs
'
;
var
path
=
require
(
'
path
'
);
import
path
from
'
path
'
;
import
{
OBJLoader
}
from
'
../../examples/jsm/loaders/OBJLoader.js
'
;
if
(
process
.
argv
.
length
<=
2
)
{
if
(
process
.
argv
.
length
<=
2
)
{
...
@@ -10,7 +12,7 @@ if ( process.argv.length <= 2 ) {
...
@@ -10,7 +12,7 @@ if ( process.argv.length <= 2 ) {
//
//
var
PRECISION
=
6
;
const
PRECISION
=
6
;
function
parseNumber
(
key
,
value
)
{
function
parseNumber
(
key
,
value
)
{
...
@@ -18,13 +20,10 @@ function parseNumber( key, value ) {
...
@@ -18,13 +20,10 @@ function parseNumber( key, value ) {
}
}
THREE
=
require
(
'
../../build/three.js
'
);
const
file
=
process
.
argv
[
2
];
require
(
'
../../examples/js/loaders/OBJLoader.js
'
);
const
loader
=
new
OBJLoader
();
var
file
=
process
.
argv
[
2
];
var
loader
=
new
THREE
.
OBJLoader
();
var
text
=
fs
.
readFileSync
(
file
,
'
utf8
'
);
const
text
=
fs
.
readFileSync
(
file
,
'
utf8
'
);
var
content
=
JSON
.
stringify
(
loader
.
parse
(
text
).
toJSON
(),
parseNumber
);
const
content
=
JSON
.
stringify
(
loader
.
parse
(
text
).
toJSON
(),
parseNumber
);
fs
.
writeFileSync
(
path
.
basename
(
file
,
'
.obj
'
)
+
'
.json
'
,
content
,
'
utf8
'
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录