all stable - no physics yet
parent
8f233d804d
commit
fb11e681cd
|
@ -17482,7 +17482,7 @@ GameLib.D3.World.prototype.fixupTriangleMeshShape = <span class="fstat-no" title
|
|||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:01:34 GMT+0200 (CEST)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:03:55 GMT+0200 (CEST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:01:34 GMT+0200 (CEST)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:03:55 GMT+0200 (CEST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:01:34 GMT+0200 (CEST)
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 16:03:55 GMT+0200 (CEST)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -98,15 +98,13 @@ GameLib.D3.Bone = function(
|
|||
* @param name String
|
||||
* @param broadphaseType Number
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param createInstance Boolean
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Broadphase = function(
|
||||
id,
|
||||
name,
|
||||
broadphaseType,
|
||||
engine,
|
||||
createInstance
|
||||
engine
|
||||
) {
|
||||
this.id = id;
|
||||
|
||||
|
@ -120,16 +118,10 @@ GameLib.D3.Broadphase = function(
|
|||
}
|
||||
this.broadphaseType = broadphaseType;
|
||||
|
||||
if (typeof engine == 'undefined') {
|
||||
engine = null;
|
||||
}
|
||||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
this.instance = null;
|
||||
|
||||
if (createInstance) {
|
||||
this.createInstance();
|
||||
}
|
||||
this.instance = this.createInstance();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -137,13 +129,6 @@ GameLib.D3.Broadphase = function(
|
|||
*/
|
||||
GameLib.D3.Broadphase.prototype.createInstance = function() {
|
||||
|
||||
if (!(this.engine instanceof GameLib.D3.Engine)) {
|
||||
console.warn('No Engine');
|
||||
throw new Error('No Engine');
|
||||
}
|
||||
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
var instance = null;
|
||||
|
||||
if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE) {
|
||||
|
@ -151,14 +136,12 @@ GameLib.D3.Broadphase.prototype.createInstance = function() {
|
|||
} else if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID) {
|
||||
instance = new this.engine.instance.GridBroadphase();
|
||||
} else if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP) {
|
||||
instance = new this.engine.instance.SAPBroardphase();
|
||||
instance = new this.engine.instance.SAPBroadphase();
|
||||
} else {
|
||||
console.warn('Unsupported broadphase type: ' + this.broadphaseType);
|
||||
throw new Error('Unsupported broadphase type: ' + this.broadphaseType);
|
||||
}
|
||||
|
||||
this.instance = instance;
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
|
@ -3885,41 +3868,84 @@ GameLib.D3.SkyBox.prototype.render = function (
|
|||
/**
|
||||
* Physics Solver Superset
|
||||
* @param id
|
||||
* @param name
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param solverType
|
||||
* @param name
|
||||
* @param iterations
|
||||
* @param tolerance
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Physics.Solver = function(
|
||||
GameLib.D3.Solver = function(
|
||||
id,
|
||||
name,
|
||||
engine,
|
||||
solverType,
|
||||
name,
|
||||
iterations,
|
||||
tolerance
|
||||
) {
|
||||
this.id = id;
|
||||
|
||||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
if (typeof solverType == 'undefined') {
|
||||
solverType = GameLib.D3.Solver.GS_SOLVER;
|
||||
}
|
||||
this.solverType = solverType;
|
||||
|
||||
if (typeof name == 'undefined') {
|
||||
if (solverType == GameLib.D3.Physics.SPLIT_SOLVER) {
|
||||
if (this.solverType == GameLib.D3.Solver.SPLIT_SOLVER) {
|
||||
name = 'split solver';
|
||||
} else if (solverType == GameLib.D3.Physics.GS_SOLVER) {
|
||||
} else if (this.solverType == GameLib.D3.Solver.GS_SOLVER) {
|
||||
name = 'gs solver';
|
||||
} else {
|
||||
name = 'unknown solver';
|
||||
}
|
||||
}
|
||||
this.name = name;
|
||||
this.solverType = solverType;
|
||||
|
||||
if (typeof iterations == 'undefined') {
|
||||
iterations = 10;
|
||||
}
|
||||
this.iterations = iterations;
|
||||
|
||||
if (typeof tolerance == 'undefined') {
|
||||
tolerance = 1e-7;
|
||||
}
|
||||
this.tolerance = tolerance;
|
||||
|
||||
this.instance = this.createInstance();
|
||||
|
||||
this.instance.tolerance = tolerance;
|
||||
this.instance.iterations = iterations;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a custom solver instance
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.D3.Solver.prototype.createInstance = function(){
|
||||
|
||||
var instance = null;
|
||||
|
||||
if (this.solverType == GameLib.D3.Solver.SPLIT_SOLVER) {
|
||||
instance = new this.engine.instance.SplitSolver();
|
||||
} else if (this.solverType == GameLib.D3.Solver.GS_SOLVER) {
|
||||
instance = new this.engine.instance.GSSolver();
|
||||
} else {
|
||||
console.warn('Unsupported solver type: ' + this.solverType);
|
||||
throw new Error('Unsupported solver type: ' + this.solverType);
|
||||
}
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Solver Types
|
||||
* @type {number}
|
||||
*/
|
||||
GameLib.D3.Physics.SPLIT_SOLVER = 0x1;
|
||||
GameLib.D3.Physics.GS_SOLVER = 0x2;
|
||||
GameLib.D3.Solver.SPLIT_SOLVER = 0x1;
|
||||
GameLib.D3.Solver.GS_SOLVER = 0x2;
|
||||
|
||||
/**
|
||||
* Texture Superset
|
||||
|
@ -5000,19 +5026,20 @@ GameLib.D3.World = function(
|
|||
this.gravity = gravity;
|
||||
|
||||
if (typeof broadphase == 'undefined') {
|
||||
broadphase = new GameLib.D3.Physics.Broadphase(
|
||||
broadphase = new GameLib.D3.Broadphase(
|
||||
null,
|
||||
'broadPhaseNaive',
|
||||
GameLib.D3.Physics.BROADPHASE_TYPE_NAIVE
|
||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
engine
|
||||
);
|
||||
}
|
||||
this.broadphase = broadphase;
|
||||
|
||||
if (typeof solver == 'undefined') {
|
||||
solver = new GameLib.D3.Physics.Solver(
|
||||
solver = new GameLib.D3.Solver(
|
||||
null,
|
||||
'GSSolver',
|
||||
GameLib.D3.Physics.GS_SOLVER
|
||||
GameLib.D3.Solver.GS_SOLVER
|
||||
);
|
||||
}
|
||||
this.solver = solver;
|
||||
|
@ -5067,9 +5094,9 @@ GameLib.D3.World.prototype.addRigidBody = function(
|
|||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.addVehicle = function(
|
||||
vehicle // note: physics.vehicle
|
||||
vehicle
|
||||
) {
|
||||
vehicle.instance.addToWorld(this.world.instance);
|
||||
vehicle.instance.addToWorld(this.instance);
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.step = function(
|
||||
|
@ -5160,12 +5187,12 @@ GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function(
|
|||
})
|
||||
);
|
||||
|
||||
for(var i = 0, l = triangleMeshShape.instance.vertices.length / 3; i < l; ++i) {
|
||||
for(var v = 0, l = triangleMeshShape.instance.vertices.length / 3; v < l; ++v) {
|
||||
graphicsGeometry.vertices.push(
|
||||
new graphics.instance.Vector3(
|
||||
triangleMeshShape.instance.vertices[i * 3],
|
||||
triangleMeshShape.instance.vertices[i * 3 + 1],
|
||||
triangleMeshShape.instance.vertices[i * 3 + 2]
|
||||
triangleMeshShape.instance.vertices[v * 3],
|
||||
triangleMeshShape.instance.vertices[v * 3 + 1],
|
||||
triangleMeshShape.instance.vertices[v * 3 + 2]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,15 +4,13 @@
|
|||
* @param name String
|
||||
* @param broadphaseType Number
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param createInstance Boolean
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Broadphase = function(
|
||||
id,
|
||||
name,
|
||||
broadphaseType,
|
||||
engine,
|
||||
createInstance
|
||||
engine
|
||||
) {
|
||||
this.id = id;
|
||||
|
||||
|
@ -26,16 +24,10 @@ GameLib.D3.Broadphase = function(
|
|||
}
|
||||
this.broadphaseType = broadphaseType;
|
||||
|
||||
if (typeof engine == 'undefined') {
|
||||
engine = null;
|
||||
}
|
||||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
this.instance = null;
|
||||
|
||||
if (createInstance) {
|
||||
this.createInstance();
|
||||
}
|
||||
this.instance = this.createInstance();
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -43,13 +35,6 @@ GameLib.D3.Broadphase = function(
|
|||
*/
|
||||
GameLib.D3.Broadphase.prototype.createInstance = function() {
|
||||
|
||||
if (!(this.engine instanceof GameLib.D3.Engine)) {
|
||||
console.warn('No Engine');
|
||||
throw new Error('No Engine');
|
||||
}
|
||||
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
var instance = null;
|
||||
|
||||
if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE) {
|
||||
|
@ -57,14 +42,12 @@ GameLib.D3.Broadphase.prototype.createInstance = function() {
|
|||
} else if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_GRID) {
|
||||
instance = new this.engine.instance.GridBroadphase();
|
||||
} else if (this.broadphaseType == GameLib.D3.Broadphase.BROADPHASE_TYPE_SAP) {
|
||||
instance = new this.engine.instance.SAPBroardphase();
|
||||
instance = new this.engine.instance.SAPBroadphase();
|
||||
} else {
|
||||
console.warn('Unsupported broadphase type: ' + this.broadphaseType);
|
||||
throw new Error('Unsupported broadphase type: ' + this.broadphaseType);
|
||||
}
|
||||
|
||||
this.instance = instance;
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,38 +1,81 @@
|
|||
/**
|
||||
* Physics Solver Superset
|
||||
* @param id
|
||||
* @param name
|
||||
* @param engine GameLib.D3.Engine
|
||||
* @param solverType
|
||||
* @param name
|
||||
* @param iterations
|
||||
* @param tolerance
|
||||
* @constructor
|
||||
*/
|
||||
GameLib.D3.Physics.Solver = function(
|
||||
GameLib.D3.Solver = function(
|
||||
id,
|
||||
name,
|
||||
engine,
|
||||
solverType,
|
||||
name,
|
||||
iterations,
|
||||
tolerance
|
||||
) {
|
||||
this.id = id;
|
||||
|
||||
this.engine = engine;
|
||||
this.engine.isNotCannonThrow();
|
||||
|
||||
if (typeof solverType == 'undefined') {
|
||||
solverType = GameLib.D3.Solver.GS_SOLVER;
|
||||
}
|
||||
this.solverType = solverType;
|
||||
|
||||
if (typeof name == 'undefined') {
|
||||
if (solverType == GameLib.D3.Physics.SPLIT_SOLVER) {
|
||||
if (this.solverType == GameLib.D3.Solver.SPLIT_SOLVER) {
|
||||
name = 'split solver';
|
||||
} else if (solverType == GameLib.D3.Physics.GS_SOLVER) {
|
||||
} else if (this.solverType == GameLib.D3.Solver.GS_SOLVER) {
|
||||
name = 'gs solver';
|
||||
} else {
|
||||
name = 'unknown solver';
|
||||
}
|
||||
}
|
||||
this.name = name;
|
||||
this.solverType = solverType;
|
||||
|
||||
if (typeof iterations == 'undefined') {
|
||||
iterations = 10;
|
||||
}
|
||||
this.iterations = iterations;
|
||||
|
||||
if (typeof tolerance == 'undefined') {
|
||||
tolerance = 1e-7;
|
||||
}
|
||||
this.tolerance = tolerance;
|
||||
|
||||
this.instance = this.createInstance();
|
||||
|
||||
this.instance.tolerance = tolerance;
|
||||
this.instance.iterations = iterations;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a custom solver instance
|
||||
* @returns {*}
|
||||
*/
|
||||
GameLib.D3.Solver.prototype.createInstance = function(){
|
||||
|
||||
var instance = null;
|
||||
|
||||
if (this.solverType == GameLib.D3.Solver.SPLIT_SOLVER) {
|
||||
instance = new this.engine.instance.SplitSolver();
|
||||
} else if (this.solverType == GameLib.D3.Solver.GS_SOLVER) {
|
||||
instance = new this.engine.instance.GSSolver();
|
||||
} else {
|
||||
console.warn('Unsupported solver type: ' + this.solverType);
|
||||
throw new Error('Unsupported solver type: ' + this.solverType);
|
||||
}
|
||||
|
||||
return instance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Solver Types
|
||||
* @type {number}
|
||||
*/
|
||||
GameLib.D3.Physics.SPLIT_SOLVER = 0x1;
|
||||
GameLib.D3.Physics.GS_SOLVER = 0x2;
|
||||
GameLib.D3.Solver.SPLIT_SOLVER = 0x1;
|
||||
GameLib.D3.Solver.GS_SOLVER = 0x2;
|
||||
|
|
|
@ -29,19 +29,20 @@ GameLib.D3.World = function(
|
|||
this.gravity = gravity;
|
||||
|
||||
if (typeof broadphase == 'undefined') {
|
||||
broadphase = new GameLib.D3.Physics.Broadphase(
|
||||
broadphase = new GameLib.D3.Broadphase(
|
||||
null,
|
||||
'broadPhaseNaive',
|
||||
GameLib.D3.Physics.BROADPHASE_TYPE_NAIVE
|
||||
GameLib.D3.Broadphase.BROADPHASE_TYPE_NAIVE,
|
||||
engine
|
||||
);
|
||||
}
|
||||
this.broadphase = broadphase;
|
||||
|
||||
if (typeof solver == 'undefined') {
|
||||
solver = new GameLib.D3.Physics.Solver(
|
||||
solver = new GameLib.D3.Solver(
|
||||
null,
|
||||
'GSSolver',
|
||||
GameLib.D3.Physics.GS_SOLVER
|
||||
GameLib.D3.Solver.GS_SOLVER
|
||||
);
|
||||
}
|
||||
this.solver = solver;
|
||||
|
@ -96,9 +97,9 @@ GameLib.D3.World.prototype.addRigidBody = function(
|
|||
* @constructor
|
||||
*/
|
||||
GameLib.D3.World.prototype.addVehicle = function(
|
||||
vehicle // note: physics.vehicle
|
||||
vehicle
|
||||
) {
|
||||
vehicle.instance.addToWorld(this.world.instance);
|
||||
vehicle.instance.addToWorld(this.instance);
|
||||
};
|
||||
|
||||
GameLib.D3.World.prototype.step = function(
|
||||
|
@ -189,12 +190,12 @@ GameLib.D3.World.prototype.generateWireframeViewTriangleMesh = function(
|
|||
})
|
||||
);
|
||||
|
||||
for(var i = 0, l = triangleMeshShape.instance.vertices.length / 3; i < l; ++i) {
|
||||
for(var v = 0, l = triangleMeshShape.instance.vertices.length / 3; v < l; ++v) {
|
||||
graphicsGeometry.vertices.push(
|
||||
new graphics.instance.Vector3(
|
||||
triangleMeshShape.instance.vertices[i * 3],
|
||||
triangleMeshShape.instance.vertices[i * 3 + 1],
|
||||
triangleMeshShape.instance.vertices[i * 3 + 2]
|
||||
triangleMeshShape.instance.vertices[v * 3],
|
||||
triangleMeshShape.instance.vertices[v * 3 + 1],
|
||||
triangleMeshShape.instance.vertices[v * 3 + 2]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue