Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
1a336dc2
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,发现更多精彩内容 >>
提交
1a336dc2
编写于
12月 17, 2016
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed unused EventDispatcher from loaders and clean up.
上级
a387fd3a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
122 addition
and
114 deletion
+122
-114
examples/js/loaders/MTLLoader.js
examples/js/loaders/MTLLoader.js
+41
-34
examples/js/loaders/NRRDLoader.js
examples/js/loaders/NRRDLoader.js
+44
-44
examples/js/loaders/PCDLoader.js
examples/js/loaders/PCDLoader.js
+37
-36
未找到文件。
examples/js/loaders/MTLLoader.js
浏览文件 @
1a336dc2
...
...
@@ -4,13 +4,15 @@
* @author angelxuanchang
*/
THREE
.
MTLLoader
=
function
(
manager
)
{
THREE
.
MTLLoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
Object
.
assign
(
THREE
.
MTLLoader
.
prototype
,
THREE
.
EventDispatcher
.
prototype
,
{
THREE
.
MTLLoader
.
prototype
=
{
constructor
:
THREE
.
MTLLoader
,
/**
* Loads and parses a MTL asset from a URL.
...
...
@@ -69,13 +71,13 @@ Object.assign( THREE.MTLLoader.prototype, THREE.EventDispatcher.prototype, {
* mtlLoader.setTexturePath( 'assets/textures/' );
* mtlLoader.load( 'my.mtl', ... );
*/
setTexturePath
:
function
(
path
)
{
setTexturePath
:
function
(
path
)
{
this
.
texturePath
=
path
;
},
setBaseUrl
:
function
(
path
)
{
setBaseUrl
:
function
(
path
)
{
console
.
warn
(
'
THREE.MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead.
'
);
...
...
@@ -165,7 +167,7 @@ Object.assign( THREE.MTLLoader.prototype, THREE.EventDispatcher.prototype, {
}
}
)
;
};
/**
* Create a new THREE-MTLLoader.MaterialCreator
...
...
@@ -182,7 +184,7 @@ Object.assign( THREE.MTLLoader.prototype, THREE.EventDispatcher.prototype, {
* @constructor
*/
THREE
.
MTLLoader
.
MaterialCreator
=
function
(
baseUrl
,
options
)
{
THREE
.
MTLLoader
.
MaterialCreator
=
function
(
baseUrl
,
options
)
{
this
.
baseUrl
=
baseUrl
||
''
;
this
.
options
=
options
;
...
...
@@ -212,7 +214,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
},
setMaterials
:
function
(
materialsInfo
)
{
setMaterials
:
function
(
materialsInfo
)
{
this
.
materialsInfo
=
this
.
convert
(
materialsInfo
);
this
.
materials
=
{};
...
...
@@ -221,7 +223,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
},
convert
:
function
(
materialsInfo
)
{
convert
:
function
(
materialsInfo
)
{
if
(
!
this
.
options
)
return
materialsInfo
;
...
...
@@ -274,6 +276,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
default
:
break
;
}
if
(
save
)
{
...
...
@@ -300,13 +303,13 @@ THREE.MTLLoader.MaterialCreator.prototype = {
},
getIndex
:
function
(
materialName
)
{
getIndex
:
function
(
materialName
)
{
return
this
.
nameLookup
[
materialName
];
},
getAsArray
:
function
()
{
getAsArray
:
function
()
{
var
index
=
0
;
...
...
@@ -347,33 +350,33 @@ THREE.MTLLoader.MaterialCreator.prototype = {
};
var
resolveURL
=
function
(
baseUrl
,
url
)
{
function
resolveURL
(
baseUrl
,
url
)
{
if
(
typeof
url
!==
'
string
'
||
url
===
''
)
return
''
;
// Absolute URL
if
(
/^https
?
:
\/\/
/i
.
test
(
url
)
)
{
return
url
;
}
if
(
/^https
?
:
\/\/
/i
.
test
(
url
)
)
return
url
;
return
baseUrl
+
url
;
};
function
setMapForType
(
mapType
,
value
)
{
}
function
setMapForType
(
mapType
,
value
)
{
if
(
params
[
mapType
]
)
return
;
// Keep the first encountered texture
var
texParams
=
scope
.
getTextureParams
(
value
,
params
);
var
map
=
scope
.
loadTexture
(
resolveURL
(
scope
.
baseUrl
,
texParams
.
url
)
);
map
.
repeat
.
copy
(
texParams
.
scale
);
map
.
offset
.
copy
(
texParams
.
offset
);
map
.
wrapS
=
scope
.
wrap
;
map
.
wrapT
=
scope
.
wrap
;
params
[
mapType
]
=
map
;
}
for
(
var
prop
in
mat
)
{
...
...
@@ -412,7 +415,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
case
'
map_ks
'
:
// Specular map
setMapForType
(
"
specularMap
"
,
value
);
break
;
...
...
@@ -420,8 +423,8 @@ THREE.MTLLoader.MaterialCreator.prototype = {
case
'
map_bump
'
:
case
'
bump
'
:
// Bump texture map
// Bump texture map
setMapForType
(
"
bumpMap
"
,
value
);
break
;
...
...
@@ -466,9 +469,10 @@ THREE.MTLLoader.MaterialCreator.prototype = {
this
.
materials
[
materialName
]
=
new
THREE
.
MeshPhongMaterial
(
params
);
return
this
.
materials
[
materialName
];
},
getTextureParams
:
function
(
value
,
matParams
)
{
getTextureParams
:
function
(
value
,
matParams
)
{
var
texParams
=
{
...
...
@@ -477,34 +481,37 @@ THREE.MTLLoader.MaterialCreator.prototype = {
};
var
items
=
value
.
split
(
/
\s
+/
);
var
items
=
value
.
split
(
/
\s
+/
);
var
pos
;
pos
=
items
.
indexOf
(
'
-bm
'
);
if
(
pos
>=
0
)
{
pos
=
items
.
indexOf
(
'
-bm
'
);
if
(
pos
>=
0
)
{
matParams
.
bumpScale
=
parseFloat
(
items
[
pos
+
1
]
);
matParams
.
bumpScale
=
parseFloat
(
items
[
pos
+
1
]
);
items
.
splice
(
pos
,
2
);
}
pos
=
items
.
indexOf
(
'
-s
'
);
if
(
pos
>=
0
)
{
pos
=
items
.
indexOf
(
'
-s
'
);
texParams
.
scale
.
set
(
parseFloat
(
items
[
pos
+
1
]
),
parseFloat
(
items
[
pos
+
2
]
)
);
if
(
pos
>=
0
)
{
texParams
.
scale
.
set
(
parseFloat
(
items
[
pos
+
1
]
),
parseFloat
(
items
[
pos
+
2
]
)
);
items
.
splice
(
pos
,
4
);
// we expect 3 parameters here!
}
pos
=
items
.
indexOf
(
'
-o
'
);
if
(
pos
>=
0
)
{
pos
=
items
.
indexOf
(
'
-o
'
);
if
(
pos
>=
0
)
{
texParams
.
offset
.
set
(
parseFloat
(
items
[
pos
+
1
]
),
parseFloat
(
items
[
pos
+
2
]
)
);
texParams
.
offset
.
set
(
parseFloat
(
items
[
pos
+
1
]
),
parseFloat
(
items
[
pos
+
2
]
)
);
items
.
splice
(
pos
,
4
);
// we expect 3 parameters here!
}
texParams
.
url
=
items
.
join
(
'
'
).
trim
();
texParams
.
url
=
items
.
join
(
'
'
).
trim
();
return
texParams
;
},
...
...
examples/js/loaders/NRRDLoader.js
浏览文件 @
1a336dc2
THREE
.
NRRDLoader
=
function
(
manager
)
{
THREE
.
NRRDLoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
};
Object
.
assign
(
THREE
.
NRRDLoader
.
prototype
,
THREE
.
EventDispatcher
.
prototype
,
{
THREE
.
NRRDLoader
.
prototype
=
{
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
constructor
:
THREE
.
NRRDLoader
,
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
var
scope
=
this
;
var
loader
=
new
THREE
.
FileLoader
(
scope
.
manager
);
loader
.
setResponseType
(
'
arraybuffer
'
);
loader
.
load
(
url
,
function
(
data
)
{
loader
.
load
(
url
,
function
(
data
)
{
onLoad
(
scope
.
parse
(
data
)
);
...
...
@@ -21,9 +23,9 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
},
//this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X
parse
:
function
(
data
)
{
parse
:
function
(
data
)
{
// this parser is largely inspired from the XTK NRRD parser : https://github.com/xtk/X
var
_data
=
data
;
...
...
@@ -33,10 +35,6 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
var
_littleEndian
=
true
;
var
_lastMin
=
-
Infinity
;
var
_lastMax
=
Infinity
;
var
headerObject
=
{};
function
scan
(
type
,
chunks
)
{
...
...
@@ -206,10 +204,9 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
var
number
=
''
;
start
=
start
||
0
;
end
=
end
||
data
.
length
;
var
lastSpace
=
start
;
var
value
;
//length of the result is the product of the sizes
var
lengthOfTheResult
=
headerObject
.
sizes
.
reduce
(
function
(
previous
,
current
)
{
var
lengthOfTheResult
=
headerObject
.
sizes
.
reduce
(
function
(
previous
,
current
)
{
return
previous
*
current
;
...
...
@@ -238,8 +235,7 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
number
+=
String
.
fromCharCode
(
value
);
}
else
{
}
else
{
if
(
number
!==
''
)
{
...
...
@@ -292,20 +288,23 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
var
inflate
=
new
Zlib
.
Gunzip
(
new
Uint8Array
(
_data
)
);
_data
=
inflate
.
decompress
();
}
else
if
(
headerObject
.
encoding
===
'
ascii
'
||
headerObject
.
encoding
===
'
text
'
||
headerObject
.
encoding
===
'
txt
'
||
headerObject
.
encoding
===
'
hex
'
)
{
}
else
if
(
headerObject
.
encoding
===
'
ascii
'
||
headerObject
.
encoding
===
'
text
'
||
headerObject
.
encoding
===
'
txt
'
||
headerObject
.
encoding
===
'
hex
'
)
{
_data
=
parseDataAsText
(
_data
);
}
else
if
(
headerObject
.
encoding
===
'
raw
'
)
{
}
else
if
(
headerObject
.
encoding
===
'
raw
'
)
{
//we need to copy the array to create a new array buffer, else we retrieve the original arraybuffer with the header
var
_copy
=
new
Uint8Array
(
_data
.
length
);
for
(
var
i
=
0
;
i
<
_data
.
length
;
i
++
)
{
_copy
[
i
]
=
_data
[
i
];
var
_copy
=
new
Uint8Array
(
_data
.
length
);
for
(
var
i
=
0
;
i
<
_data
.
length
;
i
++
)
{
_copy
[
i
]
=
_data
[
i
];
}
_data
=
_copy
;
}
// .. let's use the underlying array buffer
_data
=
_data
.
buffer
;
...
...
@@ -351,10 +350,9 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
_spaceX
=
-
1
;
_spaceY
=
-
1
;
}
else
if
(
headerObject
.
space
===
'
left-anterior-superior
'
)
{
}
else
if
(
headerObject
.
space
===
'
left-anterior-superior
'
)
{
_spaceX
=
-
1
_spaceX
=
-
1
;
}
...
...
@@ -366,8 +364,7 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
0
,
0
,
_spaceZ
,
0
,
0
,
0
,
0
,
1
);
}
else
{
}
else
{
var
v
=
headerObject
.
vectors
;
var
origin
=
headerObject
.
space_origin
;
...
...
@@ -406,7 +403,7 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
},
parseChars
:
function
(
array
,
start
,
end
)
{
parseChars
:
function
(
array
,
start
,
end
)
{
// without borders, use the whole array
if
(
start
===
undefined
)
{
...
...
@@ -435,9 +432,10 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
fieldFunctions
:
{
type
:
function
(
data
)
{
type
:
function
(
data
)
{
switch
(
data
)
{
case
'
uchar
'
:
case
'
unsigned char
'
:
case
'
uint8
'
:
...
...
@@ -484,33 +482,35 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
break
;
default
:
throw
new
Error
(
'
Unsupported NRRD data type:
'
+
data
);
}
return
this
.
type
=
data
;
},
endian
:
function
(
data
)
{
endian
:
function
(
data
)
{
return
this
.
endian
=
data
;
},
encoding
:
function
(
data
)
{
encoding
:
function
(
data
)
{
return
this
.
encoding
=
data
;
},
dimension
:
function
(
data
)
{
dimension
:
function
(
data
)
{
return
this
.
dim
=
parseInt
(
data
,
10
);
},
sizes
:
function
(
data
)
{
sizes
:
function
(
data
)
{
var
i
;
return
this
.
sizes
=
(
function
()
{
return
this
.
sizes
=
(
function
()
{
var
_i
,
_len
,
_ref
,
_results
;
_ref
=
data
.
split
(
/
\s
+/
);
...
...
@@ -527,30 +527,30 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
},
space
:
function
(
data
)
{
space
:
function
(
data
)
{
return
this
.
space
=
data
;
},
'
space origin
'
:
function
(
data
)
{
'
space origin
'
:
function
(
data
)
{
return
this
.
space_origin
=
data
.
split
(
"
(
"
)[
1
].
split
(
"
)
"
)[
0
].
split
(
"
,
"
);
},
'
space directions
'
:
function
(
data
)
{
'
space directions
'
:
function
(
data
)
{
var
f
,
parts
,
v
;
parts
=
data
.
match
(
/
\(
.*
?\)
/g
);
return
this
.
vectors
=
(
function
()
{
return
this
.
vectors
=
(
function
()
{
var
_i
,
_len
,
_results
;
_results
=
[];
for
(
_i
=
0
,
_len
=
parts
.
length
;
_i
<
_len
;
_i
++
)
{
v
=
parts
[
_i
];
_results
.
push
(
(
function
()
{
_results
.
push
(
(
function
()
{
var
_j
,
_len2
,
_ref
,
_results2
;
_ref
=
v
.
slice
(
1
,
-
1
).
split
(
/,/
);
...
...
@@ -572,14 +572,14 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
},
spacings
:
function
(
data
)
{
spacings
:
function
(
data
)
{
var
f
,
parts
;
parts
=
data
.
split
(
/
\s
+/
);
return
this
.
spacings
=
(
function
()
{
return
this
.
spacings
=
(
function
()
{
var
_i
,
_len
,
_results
=
[];
var
_i
,
_len
,
_results
;
_results
=
[];
for
(
_i
=
0
,
_len
=
parts
.
length
;
_i
<
_len
;
_i
++
)
{
f
=
parts
[
_i
];
...
...
@@ -593,4 +593,4 @@ Object.assign( THREE.NRRDLoader.prototype, THREE.EventDispatcher.prototype, {
}
}
}
)
;
};
examples/js/loaders/PCDLoader.js
浏览文件 @
1a336dc2
...
...
@@ -7,7 +7,7 @@
*
*/
THREE
.
PCDLoader
=
function
(
manager
)
{
THREE
.
PCDLoader
=
function
(
manager
)
{
this
.
manager
=
(
manager
!==
undefined
)
?
manager
:
THREE
.
DefaultLoadingManager
;
this
.
littleEndian
=
true
;
...
...
@@ -15,15 +15,17 @@ THREE.PCDLoader = function( manager ) {
};
Object
.
assign
(
THREE
.
PCDLoader
.
prototype
,
THREE
.
EventDispatcher
.
prototype
,
{
THREE
.
PCDLoader
.
prototype
=
{
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
constructor
:
THREE
.
PCDLoader
,
load
:
function
(
url
,
onLoad
,
onProgress
,
onError
)
{
var
scope
=
this
;
var
loader
=
new
THREE
.
FileLoader
(
scope
.
manager
);
loader
.
setResponseType
(
'
arraybuffer
'
);
loader
.
load
(
url
,
function
(
data
)
{
loader
.
load
(
url
,
function
(
data
)
{
onLoad
(
scope
.
parse
(
data
,
url
)
);
...
...
@@ -31,7 +33,7 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
},
binarryToStr
:
function
(
data
)
{
binarryToStr
:
function
(
data
)
{
var
text
=
""
;
var
charArray
=
new
Uint8Array
(
data
);
...
...
@@ -44,7 +46,7 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
},
parseHeader
:
function
(
data
)
{
parseHeader
:
function
(
data
)
{
var
PCDheader
=
{};
var
result1
=
data
.
search
(
/
[\r\n]
DATA
\s(\S
*
)\s
/i
);
...
...
@@ -56,47 +58,47 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
PCDheader
.
str
=
PCDheader
.
str
.
replace
(
/
\#
.*/gi
,
""
);
PCDheader
.
version
=
/VERSION
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
version
!=
null
)
PCDheader
.
version
=
parseFloat
(
PCDheader
.
version
[
1
]
);
PCDheader
.
version
=
parseFloat
(
PCDheader
.
version
[
1
]
);
PCDheader
.
fields
=
/FIELDS
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
fields
!=
null
)
PCDheader
.
fields
=
PCDheader
.
fields
[
1
].
split
(
"
"
);
PCDheader
.
fields
=
PCDheader
.
fields
[
1
].
split
(
"
"
);
PCDheader
.
size
=
/SIZE
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
size
!=
null
)
PCDheader
.
size
=
PCDheader
.
size
[
1
].
split
(
"
"
).
map
(
function
(
x
)
{
PCDheader
.
size
=
PCDheader
.
size
[
1
].
split
(
"
"
).
map
(
function
(
x
)
{
return
parseInt
(
x
,
10
);
}
);
PCDheader
.
type
=
/TYPE
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
type
!=
null
)
PCDheader
.
type
=
PCDheader
.
type
[
1
].
split
(
"
"
);
PCDheader
.
type
=
PCDheader
.
type
[
1
].
split
(
"
"
);
PCDheader
.
count
=
/COUNT
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
count
!=
null
)
PCDheader
.
count
=
PCDheader
.
count
[
1
].
split
(
"
"
).
map
(
function
(
x
)
{
PCDheader
.
count
=
PCDheader
.
count
[
1
].
split
(
"
"
).
map
(
function
(
x
)
{
return
parseInt
(
x
,
10
);
}
);
PCDheader
.
width
=
/WIDTH
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
width
!=
null
)
PCDheader
.
width
=
parseInt
(
PCDheader
.
width
[
1
]
);
PCDheader
.
width
=
parseInt
(
PCDheader
.
width
[
1
]
);
PCDheader
.
height
=
/HEIGHT
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
height
!=
null
)
PCDheader
.
height
=
parseInt
(
PCDheader
.
height
[
1
]
);
PCDheader
.
height
=
parseInt
(
PCDheader
.
height
[
1
]
);
PCDheader
.
viewpoint
=
/VIEWPOINT
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
viewpoint
!=
null
)
PCDheader
.
viewpoint
=
PCDheader
.
viewpoint
[
1
];
PCDheader
.
viewpoint
=
PCDheader
.
viewpoint
[
1
];
PCDheader
.
points
=
/POINTS
(
.*
)
/i
.
exec
(
PCDheader
.
str
);
if
(
PCDheader
.
points
!=
null
)
PCDheader
.
points
=
parseInt
(
PCDheader
.
points
[
1
],
10
);
PCDheader
.
points
=
parseInt
(
PCDheader
.
points
[
1
],
10
);
if
(
PCDheader
.
points
==
null
)
PCDheader
.
points
=
PCDheader
.
width
*
PCDheader
.
height
;
PCDheader
.
points
=
PCDheader
.
width
*
PCDheader
.
height
;
if
(
PCDheader
.
count
==
null
)
{
PCDheader
.
count
=
[];
for
(
var
i
=
0
;
i
<
PCDheader
.
fields
;
i
++
)
PCDheader
.
count
.
push
(
1
);
PCDheader
.
count
.
push
(
1
);
}
...
...
@@ -106,11 +108,11 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
if
(
PCDheader
.
data
==
"
ascii
"
)
{
PCDheader
.
offset
[
PCDheader
.
fields
[
i
]]
=
i
;
PCDheader
.
offset
[
PCDheader
.
fields
[
i
]
]
=
i
;
}
else
{
PCDheader
.
offset
[
PCDheader
.
fields
[
i
]]
=
sizeSum
;
PCDheader
.
offset
[
PCDheader
.
fields
[
i
]
]
=
sizeSum
;
sizeSum
+=
PCDheader
.
size
[
i
];
}
...
...
@@ -123,7 +125,7 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
},
parse
:
function
(
data
,
url
)
{
parse
:
function
(
data
,
url
)
{
var
textData
=
this
.
binarryToStr
(
data
);
...
...
@@ -134,13 +136,13 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
// Parse the data
var
position
=
false
;
if
(
PCDheader
.
offset
.
x
!=
undefined
)
position
=
new
Float32Array
(
PCDheader
.
points
*
3
);
position
=
new
Float32Array
(
PCDheader
.
points
*
3
);
var
color
=
false
;
if
(
PCDheader
.
offset
.
rgb
!=
undefined
)
color
=
new
Float32Array
(
PCDheader
.
points
*
3
);
if
(
PCDheader
.
offset
.
rgb
!=
undefined
)
color
=
new
Float32Array
(
PCDheader
.
points
*
3
);
var
normal
=
false
;
if
(
PCDheader
.
offset
.
normal_x
!=
undefined
)
normal
=
new
Float32Array
(
PCDheader
.
points
*
3
);
normal
=
new
Float32Array
(
PCDheader
.
points
*
3
);
if
(
PCDheader
.
data
==
"
ascii
"
)
{
...
...
@@ -160,11 +162,11 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
}
if
(
offset
.
rgb
!=
undefined
)
{
var
c
=
new
Float32Array
(
[
parseFloat
(
line
[
offset
.
rgb
]
)]
);
var
c
=
new
Float32Array
(
[
parseFloat
(
line
[
offset
.
rgb
]
)
]
);
var
dataview
=
new
DataView
(
c
.
buffer
,
0
);
color
[
i3
+
0
]
=
dataview
.
getUint8
(
0
)
/
255.0
;
color
[
i3
+
1
]
=
dataview
.
getUint8
(
1
)
/
255.0
;
color
[
i3
+
2
]
=
dataview
.
getUint8
(
2
)
/
255.0
;
color
[
i3
+
0
]
=
dataview
.
getUint8
(
0
)
/
255.0
;
color
[
i3
+
1
]
=
dataview
.
getUint8
(
1
)
/
255.0
;
color
[
i3
+
2
]
=
dataview
.
getUint8
(
2
)
/
255.0
;
}
if
(
offset
.
normal_x
!=
undefined
)
{
...
...
@@ -222,19 +224,18 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
var
geometry
=
new
THREE
.
BufferGeometry
();
if
(
position
!=
false
)
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
position
,
3
)
);
geometry
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
position
,
3
)
);
if
(
color
!=
false
)
geometry
.
addAttribute
(
'
color
'
,
new
THREE
.
BufferAttribute
(
color
,
3
)
);
geometry
.
addAttribute
(
'
color
'
,
new
THREE
.
BufferAttribute
(
color
,
3
)
);
if
(
normal
!=
false
)
geometry
.
addAttribute
(
'
normal
'
,
new
THREE
.
BufferAttribute
(
normal
,
3
)
);
geometry
.
addAttribute
(
'
normal
'
,
new
THREE
.
BufferAttribute
(
normal
,
3
)
);
geometry
.
computeBoundingSphere
();
var
material
=
new
THREE
.
PointsMaterial
(
{
size
:
0.005
,
vertexColors
:
!
(
color
==
false
)
}
);
var
material
=
new
THREE
.
PointsMaterial
(
{
size
:
0.005
,
vertexColors
:
!
(
color
==
false
)
}
);
if
(
color
==
false
)
material
.
color
.
setHex
(
Math
.
random
()
*
0xffffff
);
var
mesh
=
new
THREE
.
Points
(
geometry
,
material
);
var
name
=
url
.
split
(
''
).
reverse
().
join
(
''
);
name
=
/
([^\/]
*
)
/
.
exec
(
name
);
...
...
@@ -244,6 +245,6 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, {
return
mesh
;
}
,
}
}
)
;
};
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录