Missing files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Creates an empty config generator (generating always empty configs)
|
||||
* @constructor
|
||||
* @param streamer {geo.MeshStreamer} the parent mesh streamer
|
||||
*/
|
||||
geo.ConfigGenerator = function(streamer) {
|
||||
|
||||
this.streamer = streamer;
|
||||
this.beginning = true;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates an empty configuration
|
||||
* @return {Object[]} an empty array
|
||||
*/
|
||||
geo.ConfigGenerator.prototype.generateMainConfig = function() {
|
||||
|
||||
process.stderr.write('Warning : empty config generator used\n');
|
||||
return [];
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates an empty configuration
|
||||
* @return {Object[]} an empty array
|
||||
*/
|
||||
geo.ConfigGenerator.prototype.generateFillingConfig = function() {
|
||||
|
||||
process.stderr.write('Warning : empty config generator used\n');
|
||||
return [];
|
||||
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Creates a configuration generator from a string that can be 'NV-PN', 'V-PP', 'V-PD', or 'V-PP-PD'
|
||||
* @param prefetchingPolicy {String} the string corresponding to the prefetching policy
|
||||
* @param streamer {Reference to the {@link geo.MeshStreamer}
|
||||
* @return {geo.ConfigGenerator} An instance of one of the subclasses of {@link geo.ConfigGenerator}
|
||||
*/
|
||||
geo.ConfigGenerator.createFromString = function(prefetchingPolicy, streamer) {
|
||||
|
||||
// Convert arguments into an array
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
args[0] = null;
|
||||
|
||||
// Shift that array in order to create a generator easily
|
||||
switch (prefetchingPolicy) {
|
||||
case 'NV-PN': return new (Function.prototype.bind.apply(geo.NV_PN_Generator,args));
|
||||
case 'V-PD': return new (Function.prototype.bind.apply(geo.V_PD_Generator,args));
|
||||
case 'V-PP': return new (Function.prototype.bind.apply(geo.V_PP_Generator,args));
|
||||
case 'V-PP-PD': return new (Function.prototype.bind.apply(geo.V_PP_PD_Generator,args));
|
||||
default:
|
||||
process.stderr.write('Warning : prefetch type not recognized, using default...\n');
|
||||
return new geo.ConfigGenerator();
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Class that represents a generator that streams first the frustum of the
|
||||
* camera, and then linearly according to the .obj file
|
||||
* @constructor
|
||||
* @augments geo.ConfigGenerator
|
||||
* @param streamer {geo.MeshStreamer} the parent mesh streamer
|
||||
*/
|
||||
geo.NV_PN_Generator = function(streamer) {
|
||||
|
||||
geo.ConfigGenerator.apply(this, arguments);
|
||||
|
||||
};
|
||||
|
||||
geo.NV_PN_Generator.prototype = Object.create(geo.ConfigGenerator);
|
||||
geo.NV_PN_Generator.prototype.constructor = geo.NV_PN_Generator;
|
||||
|
||||
/**
|
||||
* Generates a configuration with only the camera frustum, with proportion of 1
|
||||
* @returns {Object[]} an array with one element corresponding to the camera frustum
|
||||
*/
|
||||
geo.NV_PN_Generator.prototype.generateMainConfig = function(cameraFrustum, recommendationClicked) {
|
||||
|
||||
var config;
|
||||
|
||||
// Case without prefetch
|
||||
console.log("No prefetching");
|
||||
config = [{ frustum: cameraFrustum, proportion: 1}];
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates an empty configuration
|
||||
* @returns {Object[]} an empty array
|
||||
*/
|
||||
geo.NV_PN_Generator.prototype.generateFillingConfig = function(previousConfig, previousData, cameraFrustum, recommendationClicked) {
|
||||
|
||||
return [];
|
||||
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Class that represents a generator that streams the recommendation clicked if any, of the frustum
|
||||
* @constructor
|
||||
* @augments geo.ConfigGenerator
|
||||
* @param streamer {geo.MeshStreamer} the parent mesh streamer
|
||||
*/
|
||||
geo.V_PD_Generator = function() {
|
||||
|
||||
geo.ConfigGenerator.apply(this, arguments);
|
||||
|
||||
};
|
||||
|
||||
geo.V_PD_Generator.prototype = Object.create(geo.ConfigGenerator);
|
||||
geo.V_PD_Generator.prototype.constructor = geo.V_PD_Generator;
|
||||
|
||||
/**
|
||||
* Generates a config that streams everything on the recommendation clicked if any, or full on the frustum
|
||||
* @param cameraFrustum {Object} the frustum of the camera (with its position, target, and planes)
|
||||
* @param recommendationClicked {Number|null} id of the recommendation (can be null if no recommendations are clicked)
|
||||
* @returns {Object[]} an array with one element corresponding to the recommendation clicked, or the camera frustum if there are no recommendations clicked
|
||||
*/
|
||||
geo.V_PD_Generator.prototype.generateMainConfig = function(cameraFrustum, recommendationClicked) {
|
||||
|
||||
var config;
|
||||
if (recommendationClicked != null) {
|
||||
|
||||
if (this.streamer.beginning === true) {
|
||||
this.streamer.beginning = false;
|
||||
}
|
||||
|
||||
// Case full reco
|
||||
console.log("Going to " + recommendationClicked);
|
||||
console.log("Recommendation is clicking : full for " + JSON.stringify(this.streamer.mesh.recommendations[recommendationClicked].position));
|
||||
config = [{recommendationId : recommendationClicked + 1, proportion: 1, smart:true}];
|
||||
|
||||
} else if (this.streamer.beginning === true) {
|
||||
|
||||
console.log('Begining : full init');
|
||||
config = [{recommendationId : 0, proportion:1, smart: true}];
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// Case without prefetch
|
||||
console.log("No prefetching");
|
||||
config = [{ frustum: cameraFrustum, proportion: 1}];
|
||||
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a configuration with only the camera frustum, with proportion of 1
|
||||
* @returns {Object[]} an array with one element corresponding to the camera frustum
|
||||
*/
|
||||
geo.V_PD_Generator.prototype.generateFillingConfig = function() {
|
||||
|
||||
return [{proportion:1, frustum: cameraFrustum}];
|
||||
|
||||
};
|
||||
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Class that represents a generator that streams the frustum, and tries to preload recommendations that might be clicked
|
||||
* @constructor
|
||||
* @augments geo.ConfigGenerator
|
||||
* @param streamer {geo.MeshStreamer} the parent mesh streamer
|
||||
*/
|
||||
geo.V_PP_Generator = function() {
|
||||
|
||||
geo.ConfigGenerator.apply(this, arguments);
|
||||
|
||||
};
|
||||
|
||||
geo.V_PP_Generator.prototype = Object.create(geo.ConfigGenerator);
|
||||
geo.V_PP_Generator.prototype.constructor = geo.V_PP_Generator;
|
||||
|
||||
/**
|
||||
* Generates a config that streams partly the frustum, and splits the rest of the chunk among the recommendations that are likely to be clicked
|
||||
* @param cameraFrustum {Object} the frustum of the camera (with its position, target, and planes)
|
||||
* @returns {Object[]} an array with one element corresponding the camera frustum, and other for eventual recommendations to preload
|
||||
*/
|
||||
geo.V_PP_Generator.prototype.generateMainConfig = function(cameraFrustum) {
|
||||
|
||||
var config;
|
||||
|
||||
if (this.streamer.beginning === true) {
|
||||
|
||||
console.log('Begining : full init');
|
||||
config = [{recommendationId : 0, proportion:1, smart: true}];
|
||||
|
||||
} else {
|
||||
|
||||
// Case full prefetch
|
||||
console.log("Allow some prefetching");
|
||||
|
||||
didPrefetch = true;
|
||||
config = [{ frustum: cameraFrustum, proportion : this.streamer.frustumPercentage}];
|
||||
|
||||
if (this.streamer.predictionTable !== undefined) {
|
||||
|
||||
var sum = 0;
|
||||
|
||||
for (var i = 1; i <= this.streamer.mesh.recommendations.length; i++) {
|
||||
|
||||
sum += this.streamer.predictionTable[this.streamer.previousReco][i];
|
||||
|
||||
}
|
||||
|
||||
for (var i = 1; i <= this.streamer.mesh.recommendations.length; i++) {
|
||||
|
||||
if (this.streamer.predictionTable[this.streamer.previousReco][i] > 0) {
|
||||
|
||||
config.push({
|
||||
|
||||
proportion : this.streamer.predictionTable[this.streamer.previousReco][i] * this.streamer.prefetchPercentage / sum,
|
||||
recommendationId : i,
|
||||
smart: true
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
process.stderr.write('ERROR : PREDICTION TABLE IF UNDEFINED');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a config that depends on the previous configuration and that tries to fill the recommendations that were not already filled.
|
||||
* @param previousConfig {Object} the previous configuration list (that was launched on <code>generateMainConfig</code>
|
||||
* @param previousData {Object} the data that were given by the <code>nextElements</code> method on {@link geo.MeshStreamer}
|
||||
* @param cameraFrustum {Object} the frustum of the camera, containing its position, target and planes
|
||||
* @returns {Object[]} a configuration that tries to fill what was not filled before
|
||||
*/
|
||||
geo.V_PP_Generator.prototype.generateFillingConfig = function(previousConfig, previousData, cameraFrustum) {
|
||||
|
||||
var sum = 0;
|
||||
var newConfig = [];
|
||||
|
||||
for (var i = 0; i < previousConfig.length; i++) {
|
||||
|
||||
// Check if previousConfig was full
|
||||
if (previousResult.configSizes[i] >= this.streamer.chunk * previousConfig[i].proportion) {
|
||||
|
||||
newConfig.push(previousConfig[i]);
|
||||
sum += previousConfig[i].proportion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Normalize previousConfig probabilities
|
||||
for (var i = 0; i < newConfig.length; i++) {
|
||||
|
||||
newConfig[i].proportion /= sum;
|
||||
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* Class that represents a generator that streams the current recommendation clicked if any, or the frustum, and tries to preload recommendations that might be clicked
|
||||
* @constructor
|
||||
* @augments geo.V_PP_Generator
|
||||
* @param streamer {geo.MeshStreamer} the parent mesh streamer
|
||||
*/
|
||||
geo.V_PP_PD_Generator = function() {
|
||||
|
||||
geo.V_PP_Generator.apply(this, arguments);
|
||||
|
||||
};
|
||||
|
||||
geo.V_PP_PD_Generator.prototype = Object.create(geo.V_PP_Generator);
|
||||
geo.V_PP_PD_Generator.prototype.constructor = geo.V_PP_PD_Generator;
|
||||
|
||||
/**
|
||||
* Generates a config that streams partly the frustum, and splits the rest of the chunk among the recommendations that are likely to be clicked
|
||||
* @param cameraFrustum {Object} the frustum of the camera (with its position, target, and planes)
|
||||
* @param recommendationClicked {Number|null} id of the recommendation (can be null if no recommendations are clicked)
|
||||
* @returns {Object[]} an array with one element corresponding the current recommendation or the camera frustum, and others for eventual recommendations to preload
|
||||
*/
|
||||
geo.V_PP_PD_Generator.prototype.generateMainConfig = function(cameraFrustum, recommendationClicked) {
|
||||
|
||||
var config;
|
||||
|
||||
if (recommendationClicked != null) {
|
||||
|
||||
if (this.streamer.beginning === true) {
|
||||
this.streamer.beginning = false;
|
||||
}
|
||||
|
||||
// Case full reco
|
||||
console.log("Going to " + recommendationClicked);
|
||||
console.log("Recommendation is clicking : full for " + JSON.stringify(this.streamer.mesh.recommendations[recommendationClicked].position));
|
||||
config = [{recommendationId : recommendationClicked + 1, proportion: 1, smart:true}];
|
||||
|
||||
|
||||
|
||||
} else if (this.streamer.beginning === true) {
|
||||
|
||||
console.log('Begining : full init');
|
||||
config = [{recommendationId : 0, proportion:1, smart: true}];
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
// Case full prefetch
|
||||
console.log("Allow some prefetching");
|
||||
|
||||
config = [{ frustum: cameraFrustum, proportion : this.streamer.frustumPercentage}];
|
||||
|
||||
// Find best recommendation
|
||||
var bestReco;
|
||||
var bestScore = -Infinity;
|
||||
var bestIndex = null;
|
||||
|
||||
if (this.streamer.predictionTable !== undefined) {
|
||||
|
||||
var sum = 0;
|
||||
|
||||
for (var i = 1; i <= this.streamer.mesh.recommendations.length; i++) {
|
||||
|
||||
sum += this.streamer.predictionTable[this.streamer.previousReco][i];
|
||||
|
||||
}
|
||||
|
||||
for (var i = 1; i <= this.streamer.mesh.recommendations.length; i++) {
|
||||
|
||||
if (this.streamer.predictionTable[this.streamer.previousReco][i] > 0) {
|
||||
|
||||
config.push({
|
||||
|
||||
proportion : this.streamer.predictionTable[this.streamer.previousReco][i] * this.streamer.prefetchPercentage / sum,
|
||||
recommendationId : i,
|
||||
smart: true
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
process.stderr.write('ERROR : PREDICTION TABLE IF UNDEFINED');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return config;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Generates a config that depends on the previous configuration and that tries to fill the recommendations that were not already filled.
|
||||
* @param previousConfig {Object} the previous configuration list (that was launched on <code>generateMainConfig</code>
|
||||
* @param previousData {Object} the data that were given by the <code>nextElements</code> method on {@link geo.MeshStreamer}
|
||||
* @param cameraFrustum {Object} the frustum of the camera, containing its position, target and planes
|
||||
* @returns {Object[]} a configuration that tries to fill what was not filled before
|
||||
*/
|
||||
geo.V_PP_PD_Generator.prototype.generateFillingConfig = function(previousConfig, previousData, cameraFrustum) {
|
||||
|
||||
var sum = 0;
|
||||
var newConfig = [];
|
||||
|
||||
for (var i = 0; i < previousConfig.length; i++) {
|
||||
|
||||
// Check if previousConfig was full
|
||||
if (previousResult.configSizes[i] >= this.streamer.chunk * previousConfig[i].proportion) {
|
||||
|
||||
newConfig.push(previousConfig[i]);
|
||||
sum += previousConfig[i].proportion;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Normalize previousConfig probabilities
|
||||
for (var i = 0; i < newConfig.length; i++) {
|
||||
|
||||
newConfig[i].proportion /= sum;
|
||||
|
||||
}
|
||||
|
||||
return newConfig;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user