random IDs

beta.r3js.org
Theunis J. Botha 2016-10-28 15:28:34 +02:00
parent 5b3e5afd0c
commit 92faa265ab
16 changed files with 6947 additions and 3110 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -20,24 +20,24 @@
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">17.71% </span>
<span class="strong">15.55% </span>
<span class="quiet">Statements</span>
<span class='fraction'>309/1745</span>
<span class='fraction'>320/2058</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">3.87% </span>
<span class="strong">3.6% </span>
<span class="quiet">Branches</span>
<span class='fraction'>27/697</span>
<span class='fraction'>29/806</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">6.16% </span>
<span class="strong">5.96% </span>
<span class="quiet">Functions</span>
<span class='fraction'>9/146</span>
<span class='fraction'>9/151</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">17.71% </span>
<span class="strong">15.55% </span>
<span class="quiet">Lines</span>
<span class='fraction'>309/1745</span>
<span class='fraction'>320/2058</span>
</div>
</div>
</div>
@ -60,15 +60,15 @@
</thead>
<tbody><tr>
<td class="file low" data-value="game-lib.js"><a href="game-lib.js.html">game-lib.js</a></td>
<td data-value="17.71" class="pic low"><div class="chart"><div class="cover-fill" style="width: 17%;"></div><div class="cover-empty" style="width:83%;"></div></div></td>
<td data-value="17.71" class="pct low">17.71%</td>
<td data-value="1745" class="abs low">309/1745</td>
<td data-value="3.87" class="pct low">3.87%</td>
<td data-value="697" class="abs low">27/697</td>
<td data-value="6.16" class="pct low">6.16%</td>
<td data-value="146" class="abs low">9/146</td>
<td data-value="17.71" class="pct low">17.71%</td>
<td data-value="1745" class="abs low">309/1745</td>
<td data-value="15.55" class="pic low"><div class="chart"><div class="cover-fill" style="width: 15%;"></div><div class="cover-empty" style="width:85%;"></div></div></td>
<td data-value="15.55" class="pct low">15.55%</td>
<td data-value="2058" class="abs low">320/2058</td>
<td data-value="3.6" class="pct low">3.6%</td>
<td data-value="806" class="abs low">29/806</td>
<td data-value="5.96" class="pct low">5.96%</td>
<td data-value="151" class="abs low">9/151</td>
<td data-value="15.55" class="pct low">15.55%</td>
<td data-value="2058" class="abs low">320/2058</td>
</tr>
</tbody>
@ -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 Tue Oct 18 2016 15:35:01 GMT+0200 (CEST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 15:11:03 GMT+0200 (CEST)
</div>
</div>
<script src="../prettify.js"></script>

View File

@ -20,24 +20,24 @@
</h1>
<div class='clearfix'>
<div class='fl pad1y space-right2'>
<span class="strong">17.71% </span>
<span class="strong">15.55% </span>
<span class="quiet">Statements</span>
<span class='fraction'>309/1745</span>
<span class='fraction'>320/2058</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">3.87% </span>
<span class="strong">3.6% </span>
<span class="quiet">Branches</span>
<span class='fraction'>27/697</span>
<span class='fraction'>29/806</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">6.16% </span>
<span class="strong">5.96% </span>
<span class="quiet">Functions</span>
<span class='fraction'>9/146</span>
<span class='fraction'>9/151</span>
</div>
<div class='fl pad1y space-right2'>
<span class="strong">17.71% </span>
<span class="strong">15.55% </span>
<span class="quiet">Lines</span>
<span class='fraction'>309/1745</span>
<span class='fraction'>320/2058</span>
</div>
</div>
</div>
@ -60,15 +60,15 @@
</thead>
<tbody><tr>
<td class="file low" data-value="build/"><a href="build/index.html">build/</a></td>
<td data-value="17.71" class="pic low"><div class="chart"><div class="cover-fill" style="width: 17%;"></div><div class="cover-empty" style="width:83%;"></div></div></td>
<td data-value="17.71" class="pct low">17.71%</td>
<td data-value="1745" class="abs low">309/1745</td>
<td data-value="3.87" class="pct low">3.87%</td>
<td data-value="697" class="abs low">27/697</td>
<td data-value="6.16" class="pct low">6.16%</td>
<td data-value="146" class="abs low">9/146</td>
<td data-value="17.71" class="pct low">17.71%</td>
<td data-value="1745" class="abs low">309/1745</td>
<td data-value="15.55" class="pic low"><div class="chart"><div class="cover-fill" style="width: 15%;"></div><div class="cover-empty" style="width:85%;"></div></div></td>
<td data-value="15.55" class="pct low">15.55%</td>
<td data-value="2058" class="abs low">320/2058</td>
<td data-value="3.6" class="pct low">3.6%</td>
<td data-value="806" class="abs low">29/806</td>
<td data-value="5.96" class="pct low">5.96%</td>
<td data-value="151" class="abs low">9/151</td>
<td data-value="15.55" class="pct low">15.55%</td>
<td data-value="2058" class="abs low">320/2058</td>
</tr>
</tbody>
@ -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 Tue Oct 18 2016 15:35:01 GMT+0200 (CEST)
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Oct 28 2016 15:11:03 GMT+0200 (CEST)
</div>
</div>
<script src="prettify.js"></script>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1835,7 +1835,6 @@ GameLib.D3.Matrix4.prototype.lookAt = function (position, target, up) {
* @param physics
* @param parentMeshId
* @param parentSceneId
* @param rawData
* @constructor
*/
GameLib.D3.Mesh = function(
@ -1857,10 +1856,10 @@ GameLib.D3.Mesh = function(
up,
physics,
parentMeshId,
parentSceneId,
rawData
parentSceneId
) {
this.id = id;
this.meshId = GameLib.D3.Tools.RandomId();
this.path = path;
this.name = name;
this.meshType = meshType;
@ -1922,8 +1921,6 @@ GameLib.D3.Mesh = function(
this.parentMeshId = parentMeshId;
this.parentSceneId = parentSceneId;
this.rawData = null;// rawData;
};
@ -2423,9 +2420,9 @@ GameLib.D3.PolyVertex.prototype.clone = function() {
)
};
/**
*
* @param engine GamLib.D3.Engine
* @param chassisBody GamLib.D3.RigidBody
* Raycast Vehicles :)
* @param engine GameLib.D3.Engine
* @param chassisBody GameLib.D3.RigidBody
* @param wheels GameLib.D3.RaycastWheel[]
* @constructor
*/
@ -2437,6 +2434,8 @@ GameLib.D3.RaycastVehicle = function(
this.engine = engine;
this.engine.isNotCannonThrow();
this.componentId = GameLib.D3.Tools.RandomId();
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {
@ -2467,6 +2466,15 @@ GameLib.D3.RaycastVehicle.prototype.addWheel = function (
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
};
/**
* Returns updated wheel info
* @returns {*}
* @constructor
*/
GameLib.D3.RaycastVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelInfos;
};
GameLib.D3.RaycastWheel = function(
engine,
chassisConnectionPointLocal,
@ -2500,6 +2508,8 @@ GameLib.D3.RaycastWheel = function(
this.engine = engine;
this.engine.isNotCannonThrow();
this.componentId = GameLib.D3.Tools.RandomId();
if(typeof chassisConnectionPointLocal == 'undefined') {
chassisConnectionPointLocal = new this.engine.instance.Vec3();
}
@ -2674,9 +2684,9 @@ GameLib.D3.RaycastWheel.prototype.createInstance = function() {
/**
* Physics Rigid Body Vehicle Superset
* @param engine
* @param chassisBody
* @param wheels
* @param engine GameLib.D3.Engine
* @param chassisBody GameLib.D3.RigidBody
* @param wheels GameLib.D3.RigidWheel[]
* @constructor
*/
GameLib.D3.RigidBodyVehicle = function(
@ -2684,6 +2694,7 @@ GameLib.D3.RigidBodyVehicle = function(
chassisBody,
wheels
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.engine = engine;
this.engine.isNotCannonThrow();
@ -2697,6 +2708,14 @@ GameLib.D3.RigidBodyVehicle = function(
this.instance = this.createInstance();
};
/**
* Returns physics wheelbody info (for updates)
* @returns {Array}
*/
GameLib.D3.RigidBodyVehicle.prototype.getWheelInfo = function() {
return this.instance.wheelBodies;
};
/**
*
* @returns {GameLib.D3.RigidVehicle}
@ -2709,16 +2728,31 @@ GameLib.D3.RigidBodyVehicle.prototype.createInstance = function() {
/**
* Adds a wheel to this rigid body vehicle
* @constructor
*/
/**
*
* @param wheel
* @param wheel GameLib.D3.RigidWheel
*/
GameLib.D3.RigidBodyVehicle.prototype.addWheel = function(wheel) {
this.wheels.push(wheel);
this.instance.addWheel(wheel.instance);
this.instance.addWheel({
body: wheel.body.instance,
position: new this.engine.instance.Vec3(
wheel.position.x,
wheel.position.y,
wheel.position.z
),
axis: new this.engine.instance.Vec3(
wheel.axis.x,
wheel.axis.y,
wheel.axis.z
),
direction: new this.engine.instance.Vec3(
wheel.direction.x,
wheel.direction.y,
wheel.direction.z
)
});
};
/**
@ -2760,7 +2794,7 @@ GameLib.D3.RigidBody = function(
fixedRotation,
shape
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.position = position || new GameLib.D3.Vector3();
this.velocity = velocity || new GameLib.D3.Vector3();
this.angularVelocity = angularVelocity || new GameLib.D3.Vector3();
@ -2869,8 +2903,25 @@ GameLib.D3.RigidBody.prototype.addShape = function(
/**
* Created by tj on 28.10.16.
* Rigid Wheel superset
* @param body GameLib.D3.RigidBody
* @param position GameLib.D3.Vector3
* @param axis GameLib.D3.Vector3
* @param direction GameLib.D3.Vector3
* @constructor
*/
GameLib.D3.RigidWheel = function(
body,
position,
axis,
direction
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.body = body;
this.position = position;
this.axis = axis;
this.direction = direction;
};
/**
* Scenes are objects putting meshes into 'world space'
@ -2901,6 +2952,7 @@ GameLib.D3.Scene = function(
physics
) {
this.id = id;
this.sceneId = GameLib.D3.Tools.RandomId();
this.path = path;
this.name = name;
if (this.name.trim() == "") {
@ -4249,6 +4301,16 @@ GameLib.D3.Texture.loadMaps = function(
return textureMaps;
};
GameLib.D3.Tools = function(){};
/**
* Generates a random ID
* @returns {string}
* @constructor
*/
GameLib.D3.Tools.RandomId = function() {
return Math.random().toString(36).substr(2, 10);
};
/**
* TriangleEdge
* @param triangle

View File

@ -19,7 +19,6 @@
* @param physics
* @param parentMeshId
* @param parentSceneId
* @param rawData
* @constructor
*/
GameLib.D3.Mesh = function(
@ -41,10 +40,10 @@ GameLib.D3.Mesh = function(
up,
physics,
parentMeshId,
parentSceneId,
rawData
parentSceneId
) {
this.id = id;
this.meshId = GameLib.D3.Tools.RandomId();
this.path = path;
this.name = name;
this.meshType = meshType;
@ -106,8 +105,6 @@ GameLib.D3.Mesh = function(
this.parentMeshId = parentMeshId;
this.parentSceneId = parentSceneId;
this.rawData = null;// rawData;
};

View File

@ -13,6 +13,8 @@ GameLib.D3.RaycastVehicle = function(
this.engine = engine;
this.engine.isNotCannonThrow();
this.componentId = GameLib.D3.Tools.RandomId();
this.chassisBody = chassisBody;
if (typeof wheels == 'undefined') {

View File

@ -31,6 +31,8 @@ GameLib.D3.RaycastWheel = function(
this.engine = engine;
this.engine.isNotCannonThrow();
this.componentId = GameLib.D3.Tools.RandomId();
if(typeof chassisConnectionPointLocal == 'undefined') {
chassisConnectionPointLocal = new this.engine.instance.Vec3();
}

View File

@ -10,6 +10,7 @@ GameLib.D3.RigidBodyVehicle = function(
chassisBody,
wheels
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.engine = engine;
this.engine.isNotCannonThrow();

View File

@ -37,7 +37,7 @@ GameLib.D3.RigidBody = function(
fixedRotation,
shape
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.position = position || new GameLib.D3.Vector3();
this.velocity = velocity || new GameLib.D3.Vector3();
this.angularVelocity = angularVelocity || new GameLib.D3.Vector3();

View File

@ -12,6 +12,7 @@ GameLib.D3.RigidWheel = function(
axis,
direction
) {
this.componentId = GameLib.D3.Tools.RandomId();
this.body = body;
this.position = position;
this.axis = axis;

View File

@ -27,6 +27,7 @@ GameLib.D3.Scene = function(
physics
) {
this.id = id;
this.sceneId = GameLib.D3.Tools.RandomId();
this.path = path;
this.name = name;
if (this.name.trim() == "") {

10
src/game-lib-tools.js Normal file
View File

@ -0,0 +1,10 @@
GameLib.D3.Tools = function(){};
/**
* Generates a random ID
* @returns {string}
* @constructor
*/
GameLib.D3.Tools.RandomId = function() {
return Math.random().toString(36).substr(2, 10);
};

View File

@ -141,4 +141,5 @@ describe('GameLib object creation', function(){
console.log("Cannot test FlyControls server side");
done();
});
});