144 lines
3.4 KiB
JavaScript
144 lines
3.4 KiB
JavaScript
var chai = require('chai'),
|
|
sinon = require("sinon"),
|
|
sinonChai = require("sinon-chai"),
|
|
config = require('../config.js'),
|
|
assert = chai.assert,
|
|
GameLib = require('../build/game-lib'),
|
|
CANNON = require('cannon'),
|
|
THREE = require('three');
|
|
|
|
chai.use(sinonChai);
|
|
|
|
describe('GameLib object creation', function(){
|
|
|
|
this.timeout(0);
|
|
|
|
before(function(){
|
|
|
|
});
|
|
|
|
after(function(){
|
|
|
|
});
|
|
|
|
beforeEach(function(done) {
|
|
done();
|
|
});
|
|
|
|
afterEach(function(done){
|
|
done();
|
|
});
|
|
|
|
it('Should create a Bone object', function (done) {
|
|
|
|
var bone = new GameLib.D3.Bone(
|
|
null,
|
|
1,
|
|
'test bone 1',
|
|
[2, 3, 4]
|
|
);
|
|
|
|
assert(bone.position instanceof GameLib.D3.Vector3);
|
|
assert(bone.rotation instanceof GameLib.D3.Vector3);
|
|
assert(bone.scale instanceof GameLib.D3.Vector3);
|
|
assert(bone.up instanceof GameLib.D3.Vector3);
|
|
assert(bone.quaternion instanceof GameLib.D3.Vector4);
|
|
assert(bone.parentBoneId == null);
|
|
assert.deepEqual(bone.childBoneIds, [2,3,4]);
|
|
|
|
done();
|
|
});
|
|
|
|
it('Should create a BoneWeight object', function (done) {
|
|
|
|
var boneWeight = new GameLib.D3.BoneWeight(
|
|
1,
|
|
0.5
|
|
);
|
|
|
|
assert(boneWeight.boneIndex == 1);
|
|
assert(boneWeight.weight == 0.5);
|
|
|
|
done();
|
|
});
|
|
|
|
it('Should create a Broadphase object', function (done) {
|
|
|
|
var engine = new GameLib.D3.Engine(
|
|
GameLib.D3.Engine.ENGINE_TYPE_CANNON,
|
|
CANNON
|
|
);
|
|
|
|
assert(engine.engineType == GameLib.D3.Engine.ENGINE_TYPE_CANNON);
|
|
assert(engine.instance instanceof Object);
|
|
|
|
var broadphase = new GameLib.D3.Broadphase(
|
|
null,
|
|
'broad-phase',
|
|
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
|
engine,
|
|
true
|
|
);
|
|
|
|
assert(broadphase.id == null);
|
|
assert(broadphase.instance instanceof CANNON.NaiveBroadphase);
|
|
assert(broadphase.engine instanceof GameLib.D3.Engine);
|
|
assert(broadphase.name == 'broad-phase');
|
|
assert(broadphase.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE);
|
|
|
|
done();
|
|
});
|
|
|
|
it('Should create a Color object', function (done) {
|
|
|
|
var color = new GameLib.D3.Color(
|
|
0.1,
|
|
0.2,
|
|
0.3,
|
|
0.4
|
|
);
|
|
|
|
assert(color.r == 0.1);
|
|
assert(color.g == 0.2);
|
|
assert(color.b == 0.3);
|
|
assert(color.a == 0.4);
|
|
|
|
done();
|
|
});
|
|
|
|
it('Should create a Color object', function (done) {
|
|
|
|
var color = new GameLib.D3.Color(
|
|
0.1,
|
|
0.2,
|
|
0.3,
|
|
0.4
|
|
);
|
|
|
|
assert(color.r == 0.1);
|
|
assert(color.g == 0.2);
|
|
assert(color.b == 0.3);
|
|
assert(color.a == 0.4);
|
|
|
|
done();
|
|
});
|
|
|
|
|
|
it('Should create an Engine object', function (done) {
|
|
|
|
var engine = new GameLib.D3.Engine(
|
|
GameLib.D3.Engine.ENGINE_TYPE_CANNON,
|
|
CANNON
|
|
);
|
|
|
|
assert(engine.engineType == GameLib.D3.Engine.ENGINE_TYPE_CANNON);
|
|
assert(engine.instance instanceof Object);
|
|
|
|
done();
|
|
});
|
|
|
|
it('Should create a FlyControls object', function (done) {
|
|
console.log("Cannot test FlyControls server side");
|
|
done();
|
|
});
|
|
}); |