Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Ablesons
three.js
提交
d208473d
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,发现更多精彩内容 >>
提交
d208473d
编写于
12月 01, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7708 from simonThiele/unittests
Unittests
上级
489a10f8
9197b1b9
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
92 addition
and
51 deletion
+92
-51
test/unit/core/BufferGeometry.js
test/unit/core/BufferGeometry.js
+0
-2
test/unit/core/InstancedBufferGeometry.js
test/unit/core/InstancedBufferGeometry.js
+7
-7
test/unit/extras/ImageUtils.test.js
test/unit/extras/ImageUtils.test.js
+10
-8
test/unit/extras/geometries/BoxGeometry.tests.js
test/unit/extras/geometries/BoxGeometry.tests.js
+1
-1
test/unit/geometry/EdgesGeometry.js
test/unit/geometry/EdgesGeometry.js
+3
-4
test/unit/math/Euler.js
test/unit/math/Euler.js
+9
-11
test/unit/math/Matrix4.js
test/unit/math/Matrix4.js
+8
-9
test/unit/math/Quaternion.js
test/unit/math/Quaternion.js
+0
-3
test/unit/qunit-utils.js
test/unit/qunit-utils.js
+54
-6
未找到文件。
test/unit/core/BufferGeometry.js
浏览文件 @
d208473d
...
...
@@ -184,8 +184,6 @@ test( "computeBoundingBox", function() {
ok
(
bb
.
min
.
x
===
bb
.
max
.
x
&&
bb
.
min
.
y
===
bb
.
max
.
y
&&
bb
.
min
.
z
===
bb
.
max
.
z
,
"
since there is only one vertex, max and min are equal
"
);
ok
(
bb
.
min
.
x
===
-
1
&&
bb
.
min
.
y
===
-
1
&&
bb
.
min
.
z
===
-
1
,
"
since there is only one vertex, min and max are this vertex
"
);
bb
=
getBBForVertices
(
[
-
1
]
);
});
test
(
"
computeBoundingSphere
"
,
function
()
{
...
...
test/unit/core/InstancedBufferGeometry.js
浏览文件 @
d208473d
...
...
@@ -20,16 +20,16 @@ test( "copy", function() {
var
instanceMock1
=
{};
var
instanceMock2
=
{};
var
indexMock
=
createClonableMock
();
var
attributeMock1
=
{}
;
var
attributeMock2
=
{}
;
var
defaultAttribute1
=
new
THREE
.
BufferAttribute
([
1
])
;
var
defaultAttribute2
=
new
THREE
.
BufferAttribute
([
2
])
;
var
instance
=
new
THREE
.
InstancedBufferGeometry
();
instance
.
addGroup
(
0
,
10
,
instanceMock1
);
instance
.
addGroup
(
10
,
5
,
instanceMock2
);
instance
.
setIndex
(
indexMock
);
instance
.
addAttribute
(
'
attributeMock1
'
,
attributeMock
1
);
instance
.
addAttribute
(
'
attributeMock2
'
,
attributeMock
2
);
instance
.
addAttribute
(
'
defaultAttribute1
'
,
defaultAttribute
1
);
instance
.
addAttribute
(
'
defaultAttribute2
'
,
defaultAttribute
2
);
var
copiedInstance
=
instance
.
copy
(
instance
);
...
...
@@ -38,10 +38,10 @@ test( "copy", function() {
ok
(
copiedInstance
.
index
===
indexMock
,
"
index was copied
"
);
ok
(
copiedInstance
.
index
.
callCount
===
1
,
"
index.clone was called once
"
);
ok
(
copiedInstance
.
attributes
[
'
attributeMock
1
'
]
instanceof
THREE
.
BufferAttribute
,
"
attribute was created
"
);
ok
(
copiedInstance
.
attributes
[
'
defaultAttribute
1
'
]
instanceof
THREE
.
BufferAttribute
,
"
attribute was created
"
);
// the given attribute mock was passed to the array property of the created buffer attribute
ok
(
copiedInstance
.
attributes
[
'
attributeMock1
'
].
array
===
attributeMock1
,
"
attribute was copied
"
);
ok
(
copiedInstance
.
attributes
[
'
attributeMock2
'
].
array
===
attributeMock2
,
"
attribute was copied
"
);
ok
(
copiedInstance
.
attributes
[
'
defaultAttribute1
'
].
array
[
0
]
===
defaultAttribute1
.
array
,
"
attribute was copied
"
);
ok
(
copiedInstance
.
attributes
[
'
defaultAttribute2
'
].
array
[
0
]
===
defaultAttribute2
.
array
,
"
attribute was copied
"
);
ok
(
copiedInstance
.
groups
[
0
].
start
===
0
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
0
].
count
===
10
,
"
group was copied
"
);
...
...
test/unit/extras/ImageUtils.test.js
浏览文件 @
d208473d
...
...
@@ -17,20 +17,19 @@ QUnit.test( "test load handler", function( assert ) {
var
done
=
assert
.
async
();
THREE
.
ImageUtils
.
loadTexture
(
good_url
,
undefined
,
function
(
tex
)
{
new
THREE
.
TextureLoader
().
load
(
good_url
,
function
(
tex
)
{
assert
.
success
(
"
load handler should be called
"
);
assert
.
ok
(
tex
,
"
texture is defined
"
);
assert
.
ok
(
tex
.
image
,
"
texture.image is defined
"
);
done
();
},
function
()
{
},
undefined
,
function
()
{
assert
.
fail
(
"
error handler should not be called
"
);
done
();
});
});
...
...
@@ -38,12 +37,16 @@ QUnit.test( "test error handler", function( assert ) {
var
done
=
assert
.
async
();
THREE
.
ImageUtils
.
loadTexture
(
bad_url
,
undefined
,
function
()
{
new
THREE
.
TextureLoader
().
load
(
bad_url
,
function
()
{
assert
.
fail
(
"
load handler should not be called
"
);
done
();
},
function
(
event
)
{
},
undefined
,
function
(
event
)
{
assert
.
success
(
"
error handler should be called
"
);
assert
.
ok
(
event
.
type
===
'
error
'
,
"
should have error event
"
);
...
...
@@ -59,12 +62,12 @@ QUnit.test( "test cached texture", function( assert ) {
var
done
=
assert
.
async
();
var
rtex1
=
THREE
.
ImageUtils
.
loadTexture
(
good_url
,
undefined
,
function
(
tex1
)
{
var
rtex1
=
new
THREE
.
TextureLoader
().
load
(
good_url
,
function
(
tex1
)
{
assert
.
ok
(
rtex1
.
image
!==
undefined
,
"
texture 1 image is loaded
"
);
assert
.
equal
(
rtex1
,
tex1
,
"
texture 1 callback is equal to return
"
);
var
rtex2
=
THREE
.
ImageUtils
.
loadTexture
(
good_url
,
undefined
,
function
(
tex2
)
{
var
rtex2
=
new
THREE
.
TextureLoader
().
load
(
good_url
,
function
(
tex2
)
{
assert
.
ok
(
rtex2
!==
undefined
,
"
cached callback is async
"
);
assert
.
ok
(
rtex2
.
image
!==
undefined
,
"
texture 2 image is loaded
"
);
...
...
@@ -82,4 +85,3 @@ QUnit.test( "test cached texture", function( assert ) {
assert
.
ok
(
rtex1
.
image
===
undefined
,
"
texture 1 image is not loaded
"
);
});
test/unit/extras/geometries/BoxGeometry.tests.js
浏览文件 @
d208473d
test/unit/geometry/EdgesGeometry.js
浏览文件 @
d208473d
...
...
@@ -152,7 +152,7 @@ function createIndexedBufferGeometry ( vertList, idxList ) {
vertices
=
vertices
.
subarray
(
0
,
3
*
numVerts
);
geom
.
addAttribute
(
'
index
'
,
new
THREE
.
BufferAttribute
(
indices
,
1
)
);
geom
.
setIndex
(
new
THREE
.
BufferAttribute
(
indices
,
1
)
);
geom
.
addAttribute
(
'
position
'
,
new
THREE
.
BufferAttribute
(
vertices
,
3
)
);
geom
.
computeFaceNormals
();
...
...
@@ -163,7 +163,7 @@ function createIndexedBufferGeometry ( vertList, idxList ) {
function
addDrawCalls
(
geometry
)
{
var
numTris
=
geometry
.
getAttribute
(
'
index
'
)
.
count
/
3
;
var
numTris
=
geometry
.
index
.
count
/
3
;
var
offset
=
0
;
for
(
var
i
=
0
;
i
<
numTris
;
i
++
)
{
...
...
@@ -171,8 +171,7 @@ function addDrawCalls ( geometry ) {
var
start
=
i
*
3
;
var
count
=
3
;
geometry
.
addDrawCall
(
start
,
count
,
offset
);
geometry
.
addGroup
(
start
,
count
);
}
return
geometry
;
...
...
test/unit/math/Euler.js
浏览文件 @
d208473d
...
...
@@ -66,11 +66,9 @@ test( "set/setFromVector3/toVector3", function() {
var
vec
=
new
THREE
.
Vector3
(
0
,
1
,
0
);
var
b
=
new
THREE
.
Euler
().
setFromVector3
(
vec
,
"
ZYX
"
);
console
.
log
(
a
,
b
);
ok
(
a
.
equals
(
b
),
"
Passed!
"
);
var
c
=
b
.
toVector3
();
console
.
log
(
c
,
vec
);
ok
(
c
.
equals
(
vec
),
"
Passed!
"
);
});
...
...
test/unit/math/Matrix4.js
浏览文件 @
d208473d
...
...
@@ -225,7 +225,6 @@ test( "makeBasis/extractBasis", function() {
b
.
extractBasis
(
outBasis
[
0
],
outBasis
[
1
],
outBasis
[
2
]
);
// check what goes in, is what comes out.
for
(
var
j
=
0
;
j
<
outBasis
.
length
;
j
++
)
{
console
.
log
(
outBasis
[
j
],
testBasis
[
j
]
);
ok
(
outBasis
[
j
].
equals
(
testBasis
[
j
]
),
"
Passed!
"
);
}
...
...
test/unit/math/Quaternion.js
浏览文件 @
d208473d
...
...
@@ -334,9 +334,6 @@ function slerpTestSkeleton( doSlerp, maxError ) {
result
=
doSlerp
(
[
0
,
D
,
0
,
D
],
[
0
,
-
D
,
0
,
D
],
0.5
);
ok
(
result
.
equals
(
0
,
0
,
0
,
1
),
"
W-Unit from diagonals
"
);
ok
(
isNormal
(
result
),
"
Approximately normal (W-Unit)
"
);
console
.
log
(
"
maxNormError
"
,
maxNormError
);
}
...
...
test/unit/qunit-utils.js
浏览文件 @
d208473d
...
...
@@ -56,14 +56,47 @@ function checkGeometryClone( geom ) {
var
copy
=
geom
.
clone
();
QUnit
.
assert
.
notEqual
(
copy
.
uuid
,
geom
.
uuid
,
"
clone uuid should differ from original
"
);
QUnit
.
assert
.
notEqual
(
copy
.
id
,
geom
.
id
,
"
clone id should differ from original
"
);
QUnit
.
assert
.
smartEqual
(
copy
,
geom
,
"
clone is equal to original
"
);
var
excludedProperties
=
[
'
parameters
'
,
'
widthSegments
'
,
'
heightSegments
'
,
'
depthSegments
'
];
var
differingProp
=
getDifferingProp
(
geom
,
copy
,
excludedProperties
);
ok
(
differingProp
===
undefined
,
'
properties are equal
'
);
differingProp
=
getDifferingProp
(
copy
,
geom
,
excludedProperties
);
ok
(
differingProp
===
undefined
,
'
properties are equal
'
);
// json round trip with clone
checkGeometryJsonRoundtrip
(
copy
);
}
function
getDifferingProp
(
geometryA
,
geometryB
,
excludedProperties
)
{
excludedProperties
=
excludedProperties
||
[];
var
geometryKeys
=
Object
.
keys
(
geometryA
);
var
cloneKeys
=
Object
.
keys
(
geometryB
);
var
keysWhichAreNotChecked
=
[
'
parameters
'
,
'
widthSegments
'
,
'
heightSegments
'
,
'
depthSegments
'
];
var
differingProp
=
undefined
;
for
(
var
i
=
0
,
l
=
geometryKeys
.
length
;
i
<
l
;
i
++
)
{
var
key
=
geometryKeys
[
i
];
if
(
excludedProperties
.
indexOf
(
key
)
>=
0
)
{
continue
;
}
if
(
cloneKeys
.
indexOf
(
key
)
<
0
)
{
differingProp
=
key
;
break
;
}
}
return
differingProp
;
}
// Compare json file with its source geometry.
function
checkGeometryJsonWriting
(
geom
,
json
)
{
...
...
@@ -108,7 +141,20 @@ function checkGeometryJsonReading( json, geom ) {
var
output
=
loader
.
parseGeometries
(
wrap
);
QUnit
.
assert
.
ok
(
output
[
geom
.
uuid
],
'
geometry matching source uuid not in output
'
);
QUnit
.
assert
.
smartEqual
(
output
[
geom
.
uuid
],
geom
,
'
Reconstruct geometry from ObjectLoader
'
);
// QUnit.assert.smartEqual( output[ geom.uuid ], geom, 'Reconstruct geometry from ObjectLoader' );
var
differing
=
getDifferingProp
(
output
[
geom
.
uuid
],
geom
,
[
'
bones
'
]);
if
(
differing
)
{
console
.
log
(
differing
);
}
var
excludedProperties
=
[
'
bones
'
];
var
differingProp
=
getDifferingProp
(
output
[
geom
.
uuid
],
geom
,
excludedProperties
);
ok
(
differingProp
===
undefined
,
'
properties are equal
'
);
differingProp
=
getDifferingProp
(
geom
,
output
[
geom
.
uuid
],
excludedProperties
);
ok
(
differingProp
===
undefined
,
'
properties are equal
'
);
}
// Verify geom -> json -> geom
...
...
@@ -207,9 +253,11 @@ function checkLightClone( light ) {
function
checkLightJsonWriting
(
light
,
json
)
{
QUnit
.
assert
.
equal
(
json
.
metadata
.
version
,
"
4.4
"
,
"
check metadata version
"
);
QUnit
.
assert
.
equalKey
(
light
,
json
,
'
type
'
);
QUnit
.
assert
.
equalKey
(
light
,
json
,
'
uuid
'
);
QUnit
.
assert
.
equal
(
json
.
id
,
undefined
,
"
should not persist id
"
);
var
object
=
json
.
object
;
QUnit
.
assert
.
equalKey
(
light
,
object
,
'
type
'
);
QUnit
.
assert
.
equalKey
(
light
,
object
,
'
uuid
'
);
QUnit
.
assert
.
equal
(
object
.
id
,
undefined
,
"
should not persist id
"
);
}
...
...
@@ -227,7 +275,7 @@ function checkLightJsonReading( json, light ) {
function
checkLightJsonRoundtrip
(
light
)
{
var
json
=
light
.
toJSON
();
checkLightJsonWriting
(
light
,
json
.
object
);
checkLightJsonWriting
(
light
,
json
);
checkLightJsonReading
(
json
,
light
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录