Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
73673e91
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,发现更多精彩内容 >>
提交
73673e91
编写于
10月 18, 2014
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5463 from vincent/dev.missingloadmanagers
Adds missing LoadingManager in some loaders
上级
4be9e804
22bd3b2c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
75 addition
and
65 deletion
+75
-65
examples/js/loaders/OBJMTLLoader.js
examples/js/loaders/OBJMTLLoader.js
+17
-13
examples/js/loaders/SceneLoader.js
examples/js/loaders/SceneLoader.js
+7
-5
examples/js/loaders/TGALoader.js
examples/js/loaders/TGALoader.js
+51
-47
未找到文件。
examples/js/loaders/OBJMTLLoader.js
浏览文件 @
73673e91
...
...
@@ -5,7 +5,11 @@
* @author angelxuanchang
*/
THREE
.
OBJMTLLoader
=
function
()
{};
THREE
.
OBJMTLLoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
THREE
.
OBJMTLLoader
.
prototype
=
{
...
...
@@ -147,7 +151,7 @@ THREE.OBJMTLLoader.prototype = {
}
}
function
add_uvs
(
a
,
b
,
c
)
{
geometry
.
faceVertexUvs
[
0
].
push
(
[
...
...
@@ -157,19 +161,19 @@ THREE.OBJMTLLoader.prototype = {
]
);
}
function
handle_face_line
(
faces
,
uvs
,
normals_inds
)
{
if
(
faces
[
3
]
===
undefined
)
{
add_face
(
faces
[
0
],
faces
[
1
],
faces
[
2
],
normals_inds
);
if
(
!
(
uvs
===
undefined
)
&&
uvs
.
length
>
0
)
{
add_uvs
(
uvs
[
0
],
uvs
[
1
],
uvs
[
2
]
);
}
}
else
{
if
(
!
(
normals_inds
===
undefined
)
&&
normals_inds
.
length
>
0
)
{
add_face
(
faces
[
0
],
faces
[
1
],
faces
[
3
],
[
normals_inds
[
0
],
normals_inds
[
1
],
normals_inds
[
3
]
]);
...
...
@@ -181,7 +185,7 @@ THREE.OBJMTLLoader.prototype = {
add_face
(
faces
[
1
],
faces
[
2
],
faces
[
3
]);
}
if
(
!
(
uvs
===
undefined
)
&&
uvs
.
length
>
0
)
{
add_uvs
(
uvs
[
0
],
uvs
[
1
],
uvs
[
3
]
);
...
...
@@ -190,7 +194,7 @@ THREE.OBJMTLLoader.prototype = {
}
}
}
...
...
@@ -218,7 +222,7 @@ THREE.OBJMTLLoader.prototype = {
var
face_pattern3
=
/f
(
+
(\d
+
)\/(\d
+
)\/(\d
+
))(
+
(\d
+
)\/(\d
+
)\/(\d
+
))(
+
(\d
+
)\/(\d
+
)\/(\d
+
))(
+
(\d
+
)\/(\d
+
)\/(\d
+
))?
/
;
// f vertex//normal vertex//normal vertex//normal ...
// f vertex//normal vertex//normal vertex//normal ...
var
face_pattern4
=
/f
(
+
(\d
+
)\/\/(\d
+
))(
+
(\d
+
)\/\/(\d
+
))(
+
(\d
+
)\/\/(\d
+
))(
+
(\d
+
)\/\/(\d
+
))?
/
...
...
@@ -275,7 +279,7 @@ THREE.OBJMTLLoader.prototype = {
}
else
if
(
(
result
=
face_pattern2
.
exec
(
line
)
)
!==
null
)
{
// ["f 1/1 2/2 3/3", " 1/1", "1", "1", " 2/2", "2", "2", " 3/3", "3", "3", undefined, undefined, undefined]
handle_face_line
(
[
result
[
2
],
result
[
5
],
result
[
8
],
result
[
11
]
],
//faces
[
result
[
3
],
result
[
6
],
result
[
9
],
result
[
12
]
]
//uv
...
...
@@ -304,7 +308,7 @@ THREE.OBJMTLLoader.prototype = {
}
else
if
(
/^o /
.
test
(
line
)
)
{
// object
meshN
();
face_offset
=
face_offset
+
vertices
.
length
;
vertices
=
[];
...
...
@@ -350,7 +354,7 @@ THREE.OBJMTLLoader.prototype = {
//Add last object
meshN
(
undefined
,
undefined
);
return
group
;
}
...
...
examples/js/loaders/SceneLoader.js
浏览文件 @
73673e91
...
...
@@ -2,7 +2,7 @@
* @author alteredq / http://alteredqualia.com/
*/
THREE
.
SceneLoader
=
function
()
{
THREE
.
SceneLoader
=
function
(
manager
)
{
this
.
onLoadStart
=
function
()
{};
this
.
onLoadProgress
=
function
()
{};
...
...
@@ -16,6 +16,8 @@ THREE.SceneLoader = function () {
this
.
addGeometryHandler
(
"
ascii
"
,
THREE
.
JSONLoader
);
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
THREE
.
SceneLoader
.
prototype
=
{
...
...
@@ -449,7 +451,7 @@ THREE.SceneLoader.prototype = {
camera
.
lookAt
(
new
THREE
.
Vector3
().
fromArray
(
objJSON
.
target
)
);
}
}
parent
.
add
(
camera
);
...
...
@@ -989,7 +991,7 @@ THREE.SceneLoader.prototype = {
texture
=
new
THREE
.
Texture
();
loader
=
new
THREE
.
ImageLoader
();
(
function
(
texture
)
{
loader
.
load
(
fullUrl
,
function
(
image
)
{
...
...
@@ -1000,9 +1002,9 @@ THREE.SceneLoader.prototype = {
textureCallback
();
}
);
}
)(
texture
)
}
...
...
examples/js/loaders/TGALoader.js
浏览文件 @
73673e91
...
...
@@ -3,19 +3,23 @@
* @author mrdoob / http://mrdoob.com/
*/
THREE
.
TGALoader
=
function
()
{};
THREE
.
TGALoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
THREE
.
TGALoader
.
prototype
=
{
constructor
:
THREE
.
TGALoader
,
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
var
scope
=
this
;
var
texture
=
new
THREE
.
DataTexture
();
var
loader
=
new
THREE
.
XHRLoader
();
var
loader
=
new
THREE
.
XHRLoader
(
scope
.
manager
);
loader
.
setResponseType
(
'
arraybuffer
'
);
loader
.
load
(
url
,
function
(
buffer
)
{
...
...
@@ -32,7 +36,7 @@ THREE.TGALoader.prototype = {
// reference from vthibault, https://github.com/vthibault/roBrowser/blob/master/src/Loaders/Targa.js
parse
:
function
(
buffer
)
{
// TGA Constants
var
TGA_TYPE_NO_DATA
=
0
,
TGA_TYPE_INDEXED
=
1
,
...
...
@@ -49,14 +53,14 @@ THREE.TGALoader.prototype = {
TGA_ORIGIN_UL
=
0x02
,
TGA_ORIGIN_UR
=
0x03
;
if
(
buffer
.
length
<
19
)
console
.
error
(
'
THREE.TGALoader.parse: Not enough data to contain header.
'
);
var
content
=
new
Uint8Array
(
buffer
),
offset
=
0
,
header
=
{
id_length
:
content
[
offset
++
],
id_length
:
content
[
offset
++
],
colormap_type
:
content
[
offset
++
],
image_type
:
content
[
offset
++
],
colormap_index
:
content
[
offset
++
]
|
content
[
offset
++
]
<<
8
,
...
...
@@ -72,7 +76,7 @@ THREE.TGALoader.prototype = {
pixel_size
:
content
[
offset
++
],
flags
:
content
[
offset
++
]
};
function
tgaCheckHeader
(
header
)
{
switch
(
header
.
image_type
)
{
...
...
@@ -110,7 +114,7 @@ THREE.TGALoader.prototype = {
console
.
error
(
'
THREE.TGALoader.parse.tgaCheckHeader: Invalid image size
'
);
}
// Check image pixel size
// Check image pixel size
if
(
header
.
pixel_size
!==
8
&&
header
.
pixel_size
!==
16
&&
header
.
pixel_size
!==
24
&&
...
...
@@ -131,10 +135,10 @@ THREE.TGALoader.prototype = {
offset
+=
header
.
id_length
;
// Get targa information about RLE compression and palette
var
use_rle
=
false
,
use_pal
=
false
,
var
use_rle
=
false
,
use_pal
=
false
,
use_grey
=
false
;
switch
(
header
.
image_type
)
{
case
TGA_TYPE_RLE_INDEXED
:
...
...
@@ -145,7 +149,7 @@ THREE.TGALoader.prototype = {
case
TGA_TYPE_INDEXED
:
use_pal
=
true
;
break
;
case
TGA_TYPE_RLE_RGB
:
use_rle
=
true
;
break
;
...
...
@@ -163,27 +167,27 @@ THREE.TGALoader.prototype = {
break
;
}
// Parse tga image buffer
function
tgaParse
(
use_rle
,
use_pal
,
header
,
offset
,
data
)
{
var
pixel_data
,
pixel_size
,
pixel_total
,
palettes
;
pixel_size
=
header
.
pixel_size
>>
3
;
pixel_total
=
header
.
width
*
header
.
height
*
pixel_size
;
// Read palettes
if
(
use_pal
)
{
palettes
=
data
.
subarray
(
offset
,
offset
+=
header
.
colormap_length
*
(
header
.
colormap_size
>>
3
)
);
}
// Read RLE
if
(
use_rle
)
{
pixel_data
=
new
Uint8Array
(
pixel_total
);
var
c
,
count
,
i
;
var
shift
=
0
;
var
pixels
=
new
Uint8Array
(
pixel_size
);
...
...
@@ -221,19 +225,19 @@ THREE.TGALoader.prototype = {
offset
,
offset
+=
(
use_pal
?
header
.
width
*
header
.
height
:
pixel_total
)
);
}
return
{
pixel_data
:
pixel_data
,
palettes
:
palettes
return
{
pixel_data
:
pixel_data
,
palettes
:
palettes
};
}
function
tgaGetImageData8bits
(
imageData
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
,
palettes
)
{
var
colormap
=
palettes
;
var
color
,
i
=
0
,
x
,
y
;
var
width
=
header
.
width
;
for
(
y
=
y_start
;
y
!==
y_end
;
y
+=
y_step
)
{
for
(
x
=
x_start
;
x
!==
x_end
;
x
+=
x_step
,
i
++
)
{
color
=
image
[
i
];
...
...
@@ -284,8 +288,8 @@ THREE.TGALoader.prototype = {
return
imageData
;
};
function
tgaGetImageData32bits
(
imageData
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
)
{
function
tgaGetImageData32bits
(
imageData
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
)
{
var
i
=
0
,
x
,
y
;
var
width
=
header
.
width
;
...
...
@@ -322,7 +326,7 @@ THREE.TGALoader.prototype = {
};
function
tgaGetImageDataGrey16bits
(
imageData
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
)
{
function
tgaGetImageDataGrey16bits
(
imageData
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
)
{
var
i
=
0
,
x
,
y
;
var
width
=
header
.
width
;
...
...
@@ -339,7 +343,7 @@ THREE.TGALoader.prototype = {
return
imageData
;
};
function
getTgaRGBA
(
width
,
height
,
image
,
palette
)
{
var
x_start
,
...
...
@@ -347,9 +351,9 @@ THREE.TGALoader.prototype = {
x_step
,
y_step
,
x_end
,
y_end
,
y_end
,
data
=
new
Uint8Array
(
width
*
height
*
4
);
switch
(
(
header
.
flags
&
TGA_ORIGIN_MASK
)
>>
TGA_ORIGIN_SHIFT
)
{
default
:
case
TGA_ORIGIN_UL
:
...
...
@@ -360,7 +364,7 @@ THREE.TGALoader.prototype = {
y_step
=
1
;
y_end
=
height
;
break
;
case
TGA_ORIGIN_BL
:
x_start
=
0
;
x_step
=
1
;
...
...
@@ -369,7 +373,7 @@ THREE.TGALoader.prototype = {
y_step
=
-
1
;
y_end
=
-
1
;
break
;
case
TGA_ORIGIN_UR
:
x_start
=
width
-
1
;
x_step
=
-
1
;
...
...
@@ -378,7 +382,7 @@ THREE.TGALoader.prototype = {
y_step
=
1
;
y_end
=
height
;
break
;
case
TGA_ORIGIN_BR
:
x_start
=
width
-
1
;
x_step
=
-
1
;
...
...
@@ -388,10 +392,10 @@ THREE.TGALoader.prototype = {
y_end
=
-
1
;
break
;
}
}
if
(
use_grey
)
{
switch
(
header
.
pixel_size
)
{
case
8
:
tgaGetImageDataGrey8bits
(
data
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
);
...
...
@@ -403,18 +407,18 @@ THREE.TGALoader.prototype = {
console
.
error
(
'
THREE.TGALoader.parse.getTgaRGBA: not support this format
'
);
break
;
}
}
else
{
switch
(
header
.
pixel_size
)
{
case
8
:
tgaGetImageData8bits
(
data
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
,
palette
);
break
;
case
16
:
tgaGetImageData16bits
(
data
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
);
break
;
case
24
:
tgaGetImageData24bits
(
data
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
);
break
;
...
...
@@ -422,10 +426,10 @@ THREE.TGALoader.prototype = {
case
32
:
tgaGetImageData32bits
(
data
,
y_start
,
y_step
,
y_end
,
x_start
,
x_step
,
x_end
,
image
);
break
;
default
:
console
.
error
(
'
THREE.TGALoader.parse.getTgaRGBA: not support this format
'
);
break
;
break
;
}
}
...
...
@@ -436,10 +440,10 @@ THREE.TGALoader.prototype = {
return
data
;
}
var
result
=
tgaParse
(
use_rle
,
use_pal
,
header
,
offset
,
content
);
var
rgbaData
=
getTgaRGBA
(
header
.
width
,
header
.
height
,
result
.
pixel_data
,
result
.
palettes
);
return
{
width
:
header
.
width
,
height
:
header
.
height
,
...
...
@@ -448,4 +452,4 @@ THREE.TGALoader.prototype = {
}
};
\ No newline at end of file
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录