1 Star 0 Fork 0

viva302/threebox

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
object.test.js 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
peterqliu 提交于 6年前 . wrap
function objectTest(instance){
var mesh = new THREE.Mesh();
var group
test('OBJECT _makeGroup from one object', function(t){
group = instance.objects._makeGroup(mesh, {foo: true});
t.equal(group.userData.foo, true);
t.equal(group.type, 'Group');
t.equal(group.children.length, 1);
t.end();
});
test('OBJECT _makeGroup from multiple objects', function(t){
var mesh2 = new THREE.Mesh();
group = instance.objects._makeGroup([mesh, mesh2], {foo: false});
t.equal(group.userData.foo, false);
t.equal(group.type, 'Group');
t.equal(group.children.length, 2);
t.end();
})
test('OBJECT _addMethods static', function(t){
group = instance.objects._makeGroup(mesh, {});
var addedMethods = instance.objects._addMethods(group, true);
t.equal(addedMethods.setCoords, undefined);
t.equal(addedMethods.type, 'Group');
t.end();
})
test('OBJECT _addMethods dynamic', function(t){
var sphere = instance.sphere({units: 'meters'});
t.equal(sphere.type, 'Group');
t.equal(typeof sphere.followPath, 'function');
t.deepEqual(sphere.coordinates, [0,0,0]);
t.end();
})
test('OBJECT setCoords updates both position and scale', function(t){
var sphere = instance.sphere({units: 'meters'});
var newPosition = [0,-20];
sphere.setCoords(newPosition)
var scaleFactor = instance.projectedUnitsPerMeter(newPosition[1]);
vector3Equals(t, sphere.position, instance.projectToWorld(newPosition));
t.equal(sphere.scale.x, scaleFactor);
t.deepEqual(sphere.coordinates, newPosition)
t.end();
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/viva302/threebox.git
git@gitee.com:viva302/threebox.git
viva302
threebox
threebox
master

搜索帮助