Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
车家大少爷
three.js
提交
1cb359e6
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,发现更多精彩内容 >>
提交
1cb359e6
编写于
11月 16, 2015
作者:
M
Mr.doob
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7604 from simonThiele/unittests
Add unit tests
上级
28bcdf8f
9662c39e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
188 addition
and
0 deletion
+188
-0
test/unit/core/InstancedBufferAttribute.js
test/unit/core/InstancedBufferAttribute.js
+29
-0
test/unit/core/InstancedBufferGeometry.js
test/unit/core/InstancedBufferGeometry.js
+51
-0
test/unit/core/InstancedInterleavedBuffer.js
test/unit/core/InstancedInterleavedBuffer.js
+20
-0
test/unit/core/InterleavedBuffer.js
test/unit/core/InterleavedBuffer.js
+46
-0
test/unit/core/InterleavedBufferAttribute.js
test/unit/core/InterleavedBufferAttribute.js
+36
-0
test/unit/unittests_three.html
test/unit/unittests_three.html
+6
-0
未找到文件。
test/unit/core/InstancedBufferAttribute.js
0 → 100644
浏览文件 @
1cb359e6
/**
* @author simonThiele / https://github.com/simonThiele
*/
module
(
"
InstancedBufferAttribute
"
);
test
(
"
can be created
"
,
function
()
{
var
instance
=
new
THREE
.
InstancedBufferAttribute
(
new
Float32Array
(
10
),
2
);
ok
(
instance
.
meshPerAttribute
===
1
,
"
ok
"
);
instance
=
new
THREE
.
InstancedBufferAttribute
(
new
Float32Array
(
10
),
2
,
123
);
ok
(
instance
.
meshPerAttribute
===
123
,
"
ok
"
);
});
test
(
"
copy
"
,
function
()
{
var
array
=
new
Float32Array
([
1
,
2
,
3
,
7
,
8
,
9
]);
var
instance
=
new
THREE
.
InstancedBufferAttribute
(
array
,
2
,
123
);
var
copiedInstance
=
instance
.
copy
(
instance
);
ok
(
copiedInstance
instanceof
THREE
.
InstancedBufferAttribute
,
"
the clone has the correct type
"
);
ok
(
copiedInstance
.
itemSize
===
2
,
"
itemSize was copied
"
);
ok
(
copiedInstance
.
meshPerAttribute
===
123
,
"
meshPerAttribute was copied
"
);
for
(
var
i
=
0
;
i
<
array
.
length
;
i
++
)
{
ok
(
copiedInstance
.
array
[
i
]
===
array
[
i
],
"
array was copied
"
);
}
});
test/unit/core/InstancedBufferGeometry.js
0 → 100644
浏览文件 @
1cb359e6
/**
* @author simonThiele / https://github.com/simonThiele
*/
module
(
"
InstancedBufferGeometry
"
);
function
createClonableMock
()
{
return
{
callCount
:
0
,
clone
:
function
()
{
this
.
callCount
++
;
return
this
;
}
}
}
test
(
"
copy
"
,
function
()
{
var
instanceMock1
=
{};
var
instanceMock2
=
{};
var
indexMock
=
createClonableMock
();
var
attributeMock1
=
{};
var
attributeMock2
=
{};
var
instance
=
new
THREE
.
InstancedBufferGeometry
();
instance
.
addGroup
(
0
,
10
,
instanceMock1
);
instance
.
addGroup
(
10
,
5
,
instanceMock2
);
instance
.
setIndex
(
indexMock
);
instance
.
addAttribute
(
'
attributeMock1
'
,
attributeMock1
);
instance
.
addAttribute
(
'
attributeMock2
'
,
attributeMock2
);
var
copiedInstance
=
instance
.
copy
(
instance
);
ok
(
copiedInstance
instanceof
THREE
.
InstancedBufferGeometry
,
"
the clone has the correct type
"
);
ok
(
copiedInstance
.
index
===
indexMock
,
"
index was copied
"
);
ok
(
copiedInstance
.
index
.
callCount
===
1
,
"
index.clone was called once
"
);
ok
(
copiedInstance
.
attributes
[
'
attributeMock1
'
]
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
.
groups
[
0
].
start
===
0
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
0
].
count
===
10
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
0
].
instances
===
instanceMock1
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
1
].
start
===
10
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
1
].
count
===
5
,
"
group was copied
"
);
ok
(
copiedInstance
.
groups
[
1
].
instances
===
instanceMock2
,
"
group was copied
"
);
});
test/unit/core/InstancedInterleavedBuffer.js
0 → 100644
浏览文件 @
1cb359e6
/**
* @author simonThiele / https://github.com/simonThiele
*/
module
(
"
InstancedInterleavedBuffer
"
);
test
(
"
can be created
"
,
function
()
{
var
array
=
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
);
var
instance
=
new
THREE
.
InstancedInterleavedBuffer
(
array
,
3
);
ok
(
instance
.
meshPerAttribute
===
1
,
"
ok
"
);
});
test
(
"
copy
"
,
function
()
{
var
array
=
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
);
var
instance
=
new
THREE
.
InstancedInterleavedBuffer
(
array
,
3
);
var
copiedInstance
=
instance
.
copy
(
instance
);
ok
(
copiedInstance
.
meshPerAttribute
===
1
,
"
additional attribute was copied
"
);
});
test/unit/core/InterleavedBuffer.js
0 → 100644
浏览文件 @
1cb359e6
/**
* @author simonThiele / https://github.com/simonThiele
*/
module
(
"
InterleavedBuffer
"
);
function
checkInstanceAgainstCopy
(
instance
,
copiedInstance
)
{
ok
(
copiedInstance
instanceof
THREE
.
InterleavedBuffer
,
"
the clone has the correct type
"
);
for
(
var
i
=
0
;
i
<
instance
.
array
.
length
;
i
++
)
{
ok
(
copiedInstance
.
array
[
i
]
===
instance
.
array
[
i
],
"
array was copied
"
);
}
ok
(
copiedInstance
.
stride
===
instance
.
stride
,
"
stride was copied
"
);
ok
(
copiedInstance
.
dynamic
===
true
,
"
dynamic was copied
"
);
}
test
(
"
length and count
"
,
function
()
{
var
instance
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
),
3
);
ok
(
instance
.
length
===
6
,
"
length is calculated via array length
"
);
ok
(
instance
.
count
===
2
,
"
count is calculated via array length / stride
"
);
});
test
(
"
copy
"
,
function
()
{
var
array
=
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
);
var
instance
=
new
THREE
.
InterleavedBuffer
(
array
,
3
);
instance
.
setDynamic
(
true
);
checkInstanceAgainstCopy
(
instance
,
instance
.
copy
(
instance
)
);
});
test
(
"
clone
"
,
function
()
{
var
array
=
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
);
var
instance
=
new
THREE
.
InterleavedBuffer
(
array
,
3
);
instance
.
setDynamic
(
true
);
checkInstanceAgainstCopy
(
instance
,
instance
.
clone
()
);
});
test
(
"
set
"
,
function
()
{
var
instance
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
),
3
);
instance
.
set
(
[
0
,
-
1
]
);
ok
(
instance
.
array
[
0
]
===
0
&&
instance
.
array
[
1
]
===
-
1
,
"
replace at first by default
"
);
});
test/unit/core/InterleavedBufferAttribute.js
0 → 100644
浏览文件 @
1cb359e6
/**
* @author simonThiele / https://github.com/simonThiele
*/
module
(
"
InterleavedBufferAttribute
"
);
test
(
"
length and count
"
,
function
()
{
var
buffer
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
),
3
);
var
instance
=
new
THREE
.
InterleavedBufferAttribute
(
buffer
,
2
,
0
);
ok
(
instance
.
count
===
2
,
"
count is calculated via array length / stride
"
);
});
test
(
"
setX
"
,
function
()
{
var
buffer
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
),
3
);
var
instance
=
new
THREE
.
InterleavedBufferAttribute
(
buffer
,
2
,
0
);
instance
.
setX
(
0
,
123
);
instance
.
setX
(
1
,
321
);
ok
(
instance
.
data
.
array
[
0
]
===
123
&&
instance
.
data
.
array
[
3
]
===
321
,
"
x was calculated correct based on index and default offset
"
);
buffer
=
new
THREE
.
InterleavedBuffer
(
new
Float32Array
(
[
1
,
2
,
3
,
7
,
8
,
9
]
),
3
);
instance
=
new
THREE
.
InterleavedBufferAttribute
(
buffer
,
2
,
1
);
instance
.
setX
(
0
,
123
);
instance
.
setX
(
1
,
321
);
// the offset was defined as 1, so go one step futher in the array
ok
(
instance
.
data
.
array
[
1
]
===
123
&&
instance
.
data
.
array
[
4
]
===
321
,
"
x was calculated correct based on index and default offset
"
);
});
// setY, setZ and setW are calculated in the same way so not testing this
test/unit/unittests_three.html
浏览文件 @
1cb359e6
...
...
@@ -22,6 +22,12 @@
<script
src=
"cameras/OrthographicCamera.js"
></script>
<script
src=
"cameras/PerspectiveCamera.js"
></script>
<script
src=
"core/InstancedBufferAttribute.js"
></script>
<script
src=
"core/InstancedBufferGeometry.js"
></script>
<script
src=
"core/InstancedInterleavedBuffer.js"
></script>
<script
src=
"core/InterleavedBuffer.js"
></script>
<script
src=
"core/InterleavedBufferAttribute.js"
></script>
<script
src=
"core/BufferAttribute.js"
></script>
<script
src=
"core/BufferGeometry.js"
></script>
<script
src=
"core/Clock.js"
></script>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录