Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
63cd35e0
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,发现更多精彩内容 >>
提交
63cd35e0
编写于
3月 16, 2019
作者:
L
linbingquan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Utils: Clean up
上级
a185fa19
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
50 deletion
+69
-50
utils/converters/fbx2three.js
utils/converters/fbx2three.js
+6
-2
utils/servers/simplehttpserver.js
utils/servers/simplehttpserver.js
+63
-48
未找到文件。
utils/converters/fbx2three.js
浏览文件 @
63cd35e0
...
...
@@ -28,9 +28,13 @@ global.window = {
innerWidth
:
1024
,
innerHeight
:
768
,
URL
:
{
createObjectURL
:
function
()
{
throw
new
Error
(
'
fbx2three: Images in binary format not yet supported.
'
);
}
}
};
...
...
@@ -40,7 +44,7 @@ THREE.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
)
)
{
if
(
!
fs
.
existsSync
(
url
)
)
{
onLoad
(
new
Buffer
(
''
)
);
return
;
...
...
@@ -54,7 +58,7 @@ THREE.ImageLoader.prototype.load = function ( url, onLoad ) {
// Convert image buffer to data URL.
THREE
.
ImageUtils
.
getDataURL
=
function
(
image
)
{
if
(
!
(
image
instanceof
Buffer
)
)
{
if
(
!
(
image
instanceof
Buffer
)
)
{
throw
new
Error
(
'
fbx2three: Image should be loaded as Buffer.
'
);
...
...
utils/servers/simplehttpserver.js
浏览文件 @
63cd35e0
...
...
@@ -13,10 +13,10 @@
*/
var
port
=
8000
,
http
=
require
(
'
http
'
),
urlParser
=
require
(
'
url
'
),
fs
=
require
(
'
fs
'
),
path
=
require
(
'
path
'
),
http
=
require
(
'
http
'
),
urlParser
=
require
(
'
url
'
),
fs
=
require
(
'
fs
'
),
path
=
require
(
'
path
'
),
currentDir
=
process
.
cwd
(),
mimeTypes
=
{
"
html
"
:
"
text/html
"
,
...
...
@@ -32,88 +32,103 @@ var port = 8000,
"
bin
"
:
"
application/octet-stream
"
};
port
=
process
.
argv
[
2
]
?
parseInt
(
process
.
argv
[
2
],
0
)
:
port
;
port
=
process
.
argv
[
2
]
?
parseInt
(
process
.
argv
[
2
],
0
)
:
port
;
function
handleRequest
(
request
,
response
)
{
function
handleRequest
(
request
,
response
)
{
var
urlObject
=
urlParser
.
parse
(
request
.
url
,
true
);
var
pathname
=
decodeURIComponent
(
urlObject
.
pathname
);
var
urlObject
=
urlParser
.
parse
(
request
.
url
,
true
);
var
pathname
=
decodeURIComponent
(
urlObject
.
pathname
);
console
.
log
(
'
[
'
+
(
new
Date
()).
toUTCString
()
+
'
]
'
+
'
"
'
+
request
.
method
+
'
'
+
pathname
+
'
"
'
);
console
.
log
(
'
[
'
+
(
new
Date
()
).
toUTCString
()
+
'
]
'
+
'
"
'
+
request
.
method
+
'
'
+
pathname
+
'
"
'
);
var
filePath
=
path
.
join
(
currentDir
,
pathname
);
var
filePath
=
path
.
join
(
currentDir
,
pathname
);
fs
.
stat
(
filePath
,
function
(
err
,
stats
)
{
fs
.
stat
(
filePath
,
function
(
err
,
stats
)
{
if
(
err
)
{
response
.
writeHead
(
404
,
{});
response
.
end
(
'
File not found!
'
);
if
(
err
)
{
response
.
writeHead
(
404
,
{}
);
response
.
end
(
'
File not found!
'
);
return
;
}
if
(
stats
.
isFile
()
)
{
if
(
stats
.
isFile
()
)
{
fs
.
readFile
(
filePath
,
function
(
err
,
data
)
{
fs
.
readFile
(
filePath
,
function
(
err
,
data
)
{
if
(
err
)
{
response
.
writeHead
(
404
,
{});
response
.
end
(
'
Opps. Resource not found
'
);
if
(
err
)
{
response
.
writeHead
(
404
,
{}
);
response
.
end
(
'
Opps. Resource not found
'
);
return
;
}
var
fileType
=
filePath
.
split
(
'
.
'
).
pop
().
toLowerCase
();
var
fileType
=
filePath
.
split
(
'
.
'
).
pop
().
toLowerCase
();
response
.
writeHead
(
200
,
{
"
Content-Type
"
:
mimeTypes
[
fileType
]
||
mimeTypes
[
'
bin
'
]
response
.
writeHead
(
200
,
{
"
Content-Type
"
:
mimeTypes
[
fileType
]
||
mimeTypes
[
'
bin
'
]
}
);
response
.
write
(
data
);
response
.
write
(
data
);
response
.
end
();
});
}
);
}
else
if
(
stats
.
isDirectory
()
)
{
}
else
if
(
stats
.
isDirectory
()
)
{
fs
.
readdir
(
filePath
,
function
(
error
,
files
)
{
fs
.
readdir
(
filePath
,
function
(
error
,
files
)
{
if
(
error
)
{
response
.
writeHead
(
500
,
{});
if
(
error
)
{
response
.
writeHead
(
500
,
{}
);
response
.
end
();
return
;
}
var
l
=
pathname
.
length
;
if
(
pathname
.
substring
(
l
-
1
)
!=
'
/
'
)
pathname
+=
'
/
'
;
if
(
pathname
.
substring
(
l
-
1
)
!=
'
/
'
)
pathname
+=
'
/
'
;
response
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/html
'
}
);
response
.
write
(
'
<!DOCTYPE html>
\n
<html><head><meta charset="UTF-8"><title>
'
+
filePath
+
'
</title></head><body>
'
);
response
.
write
(
'
<h1>
'
+
filePath
+
'
</h1>
'
);
response
.
write
(
'
<ul style="list-style:none;font-family:courier new;">
'
);
files
.
unshift
(
'
.
'
,
'
..
'
);
files
.
forEach
(
function
(
item
)
{
response
.
writeHead
(
200
,
{
'
Content-Type
'
:
'
text/html
'
}
);
response
.
write
(
'
<!DOCTYPE html>
\n
<html><head><meta charset="UTF-8"><title>
'
+
filePath
+
'
</title></head><body>
'
);
response
.
write
(
'
<h1>
'
+
filePath
+
'
</h1>
'
);
response
.
write
(
'
<ul style="list-style:none;font-family:courier new;">
'
);
files
.
unshift
(
'
.
'
,
'
..
'
);
files
.
forEach
(
function
(
item
)
{
var
urlpath
=
pathname
+
item
,
itemStats
=
fs
.
statSync
(
currentDir
+
urlpath
);
itemStats
=
fs
.
statSync
(
currentDir
+
urlpath
);
if
(
itemStats
.
isDirectory
()
)
{
if
(
itemStats
.
isDirectory
())
{
urlpath
+=
'
/
'
;
item
+=
'
/
'
;
}
response
.
write
(
'
<li><a href="
'
+
urlpath
+
'
">
'
+
item
+
'
</a></li>
'
);
});
response
.
write
(
'
<li><a href="
'
+
urlpath
+
'
">
'
+
item
+
'
</a></li>
'
);
}
);
response
.
end
(
'
</ul></body></html>
'
);
}
);
response
.
end
(
'
</ul></body></html>
'
);
});
}
});
}
);
}
http
.
createServer
(
handleRequest
).
listen
(
port
);
http
.
createServer
(
handleRequest
).
listen
(
port
);
require
(
'
dns
'
).
lookup
(
require
(
'
os
'
).
hostname
(),
function
(
err
,
addr
,
fam
)
{
console
.
log
(
'
Running at http://
'
+
addr
+
(
(
port
===
80
)
?
''
:
'
:
'
)
+
port
+
'
/
'
);
require
(
'
dns
'
).
lookup
(
require
(
'
os
'
).
hostname
(),
function
(
err
,
addr
,
fam
)
{
console
.
log
(
'
Running at http://
'
+
addr
+
((
port
===
80
)
?
''
:
'
:
'
)
+
port
+
'
/
'
);
});
}
);
console
.
log
(
'
Three.js server has started...
'
);
console
.
log
(
'
Base directory at
'
+
currentDir
);
console
.
log
(
'
Three.js server has started...
'
);
console
.
log
(
'
Base directory at
'
+
currentDir
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录