Commit 8f90ebf4 authored by Stefan Glaser's avatar Stefan Glaser

Fixed some bugs and updated dependencies.

* Adapted the joint order of the nao model to match the current replay specification. Adapted fallback parser logic to rearrange the joint angles in old 3D replay files.
* Added foul flags to 3D environment.
* Fixed a bug in the assignment of new parameters in world class.
* Adapted to threejs updates (MultiMaterial is now a simple array and XHRLoader is now called FileLoader).
parent 24fe7821
......@@ -26,21 +26,21 @@
},
"homepage": "https://gitlab.com/robocup.info/JaSMIn#README",
"devDependencies": {
"google-closure-compiler-js": "^20160916.0.0",
"google-closure-library": "^20160911.0.0",
"google-closure-compiler-js": "^20170806.0.0",
"google-closure-library": "^20170806.0.0",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-concat": "^2.6.0",
"gulp-load-plugins": "^1.3.0",
"gulp-notify": "^2.2.0",
"gulp-concat": "^2.6.1",
"gulp-load-plugins": "^1.5.0",
"gulp-notify": "^3.0.0",
"gulp-plumber": "^1.1.0",
"gulp-rename": "^1.2.2",
"gulp-sass": "^2.3.2",
"gulp-sourcemaps": "^2.1.1",
"gulp-util": "^3.0.7",
"gulp-sass": "^3.1.0",
"gulp-sourcemaps": "^2.6.1",
"gulp-util": "^3.0.8",
"path": "^0.12.7",
"three": "^0.81.2",
"vinyl": "^2.0.0",
"three": "^0.87.1",
"vinyl": "^2.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0"
}
......
......@@ -15,6 +15,22 @@ JaSMIn.D3 = {};
/**
* An enum providing meaning the indices for the different elements in the agent flags bitfield for 3D games.
* @enum {!number}
*/
JaSMIn.D3.AgentFlags = {
CROWDING: 0x00000001,
TOUCHING: 0x00000002,
ILLEGAL_DEFENCE: 0x00000004,
ILLEGAL_ATTACK: 0x00000008,
INCAPABLE: 0x00000010,
ILLEGAL_KICKOFF: 0x00000020,
CHARGING: 0x00000040,
};
/**
* An enum providing known environment parameter names for 3D games.
* @enum {!string}
......
......@@ -357,8 +357,9 @@ JaSMIn.ReplayParser.parseEnvironmentParams = function(dataLine, replay, storage)
// Environment-Parameter Line-Format:
// EP <single-line-json>
try {
var newParams = /** @type {!Object} */ (JSON.parse(dataLine.slice(3)));
replay.environmentParams.clear();
replay.environmentParams.paramObj = /** @type {!Object} */ (JSON.parse(dataLine.slice(3)));
replay.environmentParams.paramObj = newParams;
} catch (ex) {
console.log('Exception while parsing environment parameters:');
console.log(ex);
......@@ -384,8 +385,9 @@ JaSMIn.ReplayParser.parsePlayerParams = function(dataLine, replay) {
// Player-Parameter Line-Format:
// PP <single-line-json>
try {
var newParams = /** @type {!Object} */ (JSON.parse(dataLine.slice(3)));
replay.playerParams.clear();
replay.playerParams.paramObj = /** @type {!Object} */ (JSON.parse(dataLine.slice(3)));
replay.playerParams.paramObj = newParams;
} catch (ex) {
console.log('Exception while parsing player parameters:');
console.log(ex);
......@@ -707,9 +709,36 @@ JaSMIn.ReplayParser.parseAgentState_V0_3D = function(dataLine, replay, storage,
var jointData = [];
dataIdx += 7;
for (var i = dataIdx; i < line.length; i++) {
jointData[i - dataIdx] = parseFloat(line[i]) * JaSMIn.PIby180 / 100;
// Shuffle joint data
// Old joint order: <head> <l-arm> <l-leg> <r-arm> <r-leg>
// New joint order: <head> <r-arm> <l-arm> <r-leg> <l-leg>
var i;
var numLegJoints = line.length - dataIdx > 22 ? 7 : 6;
var lArmData = [];
var lLegData = [];
for (i = 0; i < 2 && dataIdx < line.length; i++, dataIdx++) {
jointData.push(parseFloat(line[dataIdx]) * JaSMIn.PIby180 / 100);
}
for (i = 0; i < 4 && dataIdx < line.length; i++, dataIdx++) {
lArmData.push(parseFloat(line[dataIdx]) * JaSMIn.PIby180 / 100);
}
for (i = 0; i < numLegJoints && dataIdx < line.length; i++, dataIdx++) {
lLegData.push(parseFloat(line[dataIdx]) * JaSMIn.PIby180 / 100);
}
for (i = 0; i < 4 && dataIdx < line.length; i++, dataIdx++) {
jointData.push(parseFloat(line[dataIdx]) * JaSMIn.PIby180 / 100);
}
for (i = 0; i < lArmData.length; i++) {
jointData.push(lArmData[i]);
}
for (i = 0; i < numLegJoints && dataIdx < line.length; i++, dataIdx++) {
jointData.push(parseFloat(line[dataIdx]) * JaSMIn.PIby180 / 100);
}
for (i = 0; i < lLegData.length; i++) {
jointData.push(lLegData[i]);
}
agentStates[playerNo] = new JaSMIn.AgentState(modelIdx, 0x00, position, quat, jointData, []);
};
......
......@@ -91,9 +91,9 @@ JaSMIn.JSONGeometryFactory.prototype.loadJSON = function() {
this.loading = true;
var scope = this;
var xhrLoader = new THREE.XHRLoader();
var fileLoader = new THREE.FileLoader();
xhrLoader.load(this.resourceFile,
fileLoader.load(this.resourceFile,
function(json) {
var objectLoader = new THREE.ObjectLoader();
var loadedGeometries = objectLoader.parseGeometries(JSON.parse(json));
......
......@@ -15,7 +15,7 @@ JaSMIn.MaterialFactory = function() {
* Create the material with the given name.
*
* @param {!string} name the unique name of the material
* @return {(!THREE.Material | !THREE.MultiMaterial)} the requested (multi-)material
* @return {(!THREE.Material | !Array<THREE.Material>)} the requested (multi-)material
* or a default material if the requested material definition was not found
*/
JaSMIn.MaterialFactory.prototype.createMaterial = function(name) {};
......@@ -130,7 +130,7 @@ JaSMIn.MeshFactory.prototype.createDummyMesh = function() {
* Fetch the material with the given name.
*
* @param {!string} name the unique name of the material
* @return {(!THREE.Material | !THREE.MultiMaterial)} the requested material
* @return {(!THREE.Material | !Array<THREE.Material>)} the requested material
*/
JaSMIn.MeshFactory.prototype.fetchMaterial = function(name) {
// Try fetching material from cache
......
......@@ -216,7 +216,7 @@ JaSMIn.SceneUtils.offsetMaterial = function(material, factor, units) {
*
* @param {!string} name the name of the mesh
* @param {(!THREE.Geometry | !THREE.BufferGeometry)} geometry the mesh geometry
* @param {(!THREE.Material | !THREE.MultiMaterial)} material the mesh material
* @param {(!THREE.Material | !Array<THREE.Material>)} material the mesh material
* @param {!boolean=} rotXNeg90 true if the mesh should be rotated around x about -90 degrees, false for no rotation
* @return {!THREE.Mesh} a new mesh with the specified properties
*/
......@@ -240,7 +240,7 @@ JaSMIn.SceneUtils.createMesh = function(name, geometry, material, rotXNeg90) {
*
* @param {!string} name the name of the mesh
* @param {(!THREE.Geometry | !THREE.BufferGeometry)} geometry the mesh geometry
* @param {(!THREE.Material | !THREE.MultiMaterial)} material the mesh material
* @param {(!THREE.Material | !Array<THREE.Material>)} material the mesh material
* @param {!number} x the x-coordinate of the mesh
* @param {!number} y the y-coordinate of the mesh
* @param {!number} z the z-coordinate of the mesh
......@@ -314,7 +314,7 @@ JaSMIn.SceneUtils.DummyMaterial = new THREE.MeshPhongMaterial({name: 'dummyMat',
/**
* Create a sky box material.
*
* @return {!THREE.MultiMaterial} the sky box material
* @return {!Array<THREE.Material>} the sky box material
*/
JaSMIn.SceneUtils.createSkyBoxMaterial = function() {
var texPosx = JaSMIn.SceneUtils.loadTexture('sky_posx.jpg');
......@@ -324,7 +324,7 @@ JaSMIn.SceneUtils.createSkyBoxMaterial = function() {
var texPosz = JaSMIn.SceneUtils.loadTexture('sky_posz.jpg');
var texNegz = JaSMIn.SceneUtils.loadTexture('sky_negx.jpg');
var materials = [
return [
new THREE.MeshBasicMaterial({ map: texPosx, side: THREE.BackSide }),
new THREE.MeshBasicMaterial({ map: texNegx, side: THREE.BackSide }),
new THREE.MeshBasicMaterial({ map: texPosy, side: THREE.BackSide }),
......@@ -332,10 +332,6 @@ JaSMIn.SceneUtils.createSkyBoxMaterial = function() {
new THREE.MeshBasicMaterial({ map: texPosz, side: THREE.BackSide }),
new THREE.MeshBasicMaterial({ map: texNegz, side: THREE.BackSide }),
];
var boxMaterial = new THREE.MultiMaterial(materials);
boxMaterial.name = 'skyBoxMat';
return boxMaterial;
};
......
......@@ -421,7 +421,7 @@ JaSMIn.WorldModelFactory.prototype.createBall = function(ball) {
* Fetch the material with the given name from the internal cache (or create it if not existent).
*
* @param {!string} name the unique name of the material
* @return {(!THREE.Material | !THREE.MultiMaterial)} the requested (multi-)material
* @return {(!THREE.Material | !Array<THREE.Material>)} the requested (multi-)material
* or a default material if the requested material definition was not found
*/
JaSMIn.WorldModelFactory.prototype.fetchMaterial = function(name) {
......
......@@ -87,7 +87,7 @@ JaSMIn.SoccerBot2DMaterialFactory = function() {
* Create the material with the given name.
*
* @param {!string} name the unique name of the material
* @return {(!THREE.Material | !THREE.MultiMaterial)} the requested (multi-)material
* @return {(!THREE.Material | !Array<THREE.Material>)} the requested (multi-)material
* or a default material if the requested material definition was not found
*/
JaSMIn.SoccerBot2DMaterialFactory.prototype.createMaterial = function(name) {
......
......@@ -131,8 +131,8 @@ JaSMIn.World = function() {
JaSMIn.World.prototype.create = function(type, environmentParams, playerParams, playerTypes, leftTeamDescription, rightTeamDescription) {
// Update parameters
this.type = type;
this.environmentParams.paramsObj = environmentParams;
this.playerParams.paramsObj = playerParams;
this.environmentParams = environmentParams;
this.playerParams = playerParams;
this.playerTypes = playerTypes;
......
......@@ -810,34 +810,6 @@ THREE.MeshBasicMaterial = function(parameters) {};
/******************************************************************************
* THREE.MultiMaterial
*****************************************************************************/
/**
* @constructor
* @param {Array<THREE.Material>} materials
*/
THREE.MultiMaterial = function(materials) {};
/**
* @type {!string}
*/
THREE.MultiMaterial.prototype.name;
/**
* @type {!THREE.Color}
*/
THREE.MultiMaterial.prototype.color;
/**
* @type {!Array<THREE.Material>}
*/
THREE.MultiMaterial.prototype.materials;
/******************************************************************************
* THREE.Texture
*****************************************************************************/
......@@ -1225,7 +1197,7 @@ THREE.CircleBufferGeometry = function(radius, segments, thetaStart, thetaLength)
* @constructor
* @extends {THREE.Object3D}
* @param {(THREE.Geometry | THREE.BufferGeometry | undefined)} geometry
* @param {(THREE.Material | THREE.MultiMaterial | undefined)} material
* @param {(THREE.Material | Array<THREE.Material> | undefined)} material
*/
THREE.Mesh = function(geometry, material) {};
......@@ -1235,7 +1207,7 @@ THREE.Mesh = function(geometry, material) {};
THREE.Mesh.prototype.geometry;
/**
* @type {(!THREE.Material | !THREE.MultiMaterial)}
* @type {(!THREE.Material | !Array<THREE.Material>)}
*/
THREE.Mesh.prototype.material;
......@@ -1528,13 +1500,13 @@ THREE.LoadingManager.prototype.onError;
/******************************************************************************
* THREE.XhrLoader
* THREE.FileLoader
*****************************************************************************/
/**
* @constructor
* @param {THREE.LoadingManager=} manager
*/
THREE.XHRLoader = function(manager) {};
THREE.FileLoader = function(manager) {};
/**
......@@ -1544,7 +1516,7 @@ THREE.XHRLoader = function(manager) {};
* @param {Function=} onError
* @return {XMLHttpRequest | string} the request object or the cached result
*/
THREE.XHRLoader.prototype.load = function(url, onLoad, onProgress, onError) {};
THREE.FileLoader.prototype.load = function(url, onLoad, onProgress, onError) {};
......
......@@ -65,7 +65,7 @@ JaSMIn.SymbolTreeParser.parseNode = function(input, startIdx, parentNode) {
}
startIdx = idx = JaSMIn.SymbolTreeParser.parseNode(input, idx + 1, newNode);
} else if (input.charAt(idx) === ')') {
// Found node termonator for this node
// Found node terminator for this node
if (idx > startIdx) {
// Add value to node
newNode.values.push(input.slice(startIdx, idx));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment