Prefetching working now
This commit is contained in:
@@ -181,6 +181,8 @@ L3D.PointerCamera = function() {
|
||||
* @param {Object}
|
||||
*/
|
||||
this.resetElements = {position: new THREE.Vector3(0,1,1), target: new THREE.Vector3()};
|
||||
|
||||
this.recommendationClicked = null;
|
||||
};
|
||||
L3D.PointerCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
|
||||
L3D.PointerCamera.prototype.constructor = L3D.PointerCamera;
|
||||
@@ -323,6 +325,7 @@ L3D.PointerCamera.prototype.hermiteMotion = function(time) {
|
||||
|
||||
if (this.t > 1) {
|
||||
this.movingHermite = false;
|
||||
this.recommendationClicked = null;
|
||||
this.anglesFromVectors();
|
||||
}
|
||||
};
|
||||
@@ -491,6 +494,8 @@ L3D.PointerCamera.prototype.moveHermite = function(recommendation, toSave) {
|
||||
|
||||
var otherCamera = recommendation.camera || recommendation;
|
||||
|
||||
this.recommendationClicked = otherCamera;
|
||||
|
||||
this.moving = false;
|
||||
this.movingHermite = true;
|
||||
this.t = 0;
|
||||
@@ -762,7 +767,9 @@ L3D.PointerCamera.prototype.toList = function() {
|
||||
|
||||
var ret =
|
||||
[[this.position.x, this.position.y, this.position.z],
|
||||
[this.target.x, this.target.y, this.target.z]];
|
||||
[this.target.x, this.target.y, this.target.z],
|
||||
this.recommendationClicked !== null
|
||||
];
|
||||
|
||||
for (var i = 0; i < frustum.planes.length; i++) {
|
||||
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
L3D.ProgressiveLoader = (function() {
|
||||
|
||||
if (typeof process === 'undefined') {
|
||||
process = {
|
||||
stderr : {
|
||||
write: function(str) {
|
||||
console.log(str);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a list as it is sent by the server and gives a slightly more comprehensible result
|
||||
* @param Array array corresponding to the line of the mesh file
|
||||
@@ -88,7 +98,7 @@ var _parseList = function(arr) {
|
||||
* @constructor
|
||||
* @memberOf L3D
|
||||
*/
|
||||
var ProgressiveLoader = function(path, scene, camera, callback, log, laggy) {
|
||||
var ProgressiveLoader = function(path, scene, camera, callback, log, laggy, prefetch) {
|
||||
|
||||
var self = this;
|
||||
|
||||
@@ -186,12 +196,24 @@ var ProgressiveLoader = function(path, scene, camera, callback, log, laggy) {
|
||||
*/
|
||||
this.camera = camera;
|
||||
|
||||
this.camera._moveReco = this.camera.moveReco;
|
||||
if (this.camera instanceof L3D.ReplayCamera) {
|
||||
this.camera._moveReco = this.camera.moveReco;
|
||||
|
||||
this.camera.moveReco = function(param) {
|
||||
self.socket.emit('reco', param);
|
||||
self.camera._moveReco.apply(self.camera, arguments);
|
||||
};
|
||||
this.camera.moveReco = function(param) {
|
||||
self.socket.emit('reco', param);
|
||||
self.camera._moveReco.apply(self.camera, arguments);
|
||||
};
|
||||
} else if (this.camera instanceof L3D.PointerCamera) {
|
||||
// Only good for sponza model
|
||||
this.camera._moveHermite = this.camera.moveHermite;
|
||||
|
||||
this.camera.moveHermite = function(param) {
|
||||
var toSend = param.position.x > 0 ? 0 : 1;
|
||||
self.socket.emit('reco', toSend);
|
||||
self.camera._moveHermite.apply(self.camera, arguments);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Number of total elements for loading
|
||||
@@ -220,6 +242,9 @@ var ProgressiveLoader = function(path, scene, camera, callback, log, laggy) {
|
||||
|
||||
this.mapFace = {};
|
||||
|
||||
this.prefetch = prefetch === undefined ? true : (!!prefetch);
|
||||
console.log(this.prefetch);
|
||||
|
||||
};
|
||||
|
||||
ProgressiveLoader.prototype.hasFace = function(face) {
|
||||
@@ -277,6 +302,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
|
||||
this.socket.on('elements', function(arr) {
|
||||
|
||||
process.stderr.write('Received ' + arr.length + '\n');
|
||||
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
|
||||
if (typeof self.log === 'function' && self.numberOfFacesReceived % self.modulus === 0) {
|
||||
@@ -360,6 +387,8 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
|
||||
self.numberOfFacesReceived++;
|
||||
|
||||
self.mapFace[elt.a + '-' + elt.b + '-' + elt.c] = true;
|
||||
|
||||
if (!self.meshes[elt.mesh].added) {
|
||||
|
||||
self.meshes[elt.mesh].added = true;
|
||||
@@ -392,7 +421,6 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
|
||||
}
|
||||
|
||||
self.mapFace[elt.a + '-' + elt.b + '-' + elt.c] = true;
|
||||
|
||||
|
||||
} else if (elt.type === 'global') {
|
||||
@@ -436,7 +464,7 @@ ProgressiveLoader.prototype.initIOCallbacks = function() {
|
||||
* Starts the communication with the server
|
||||
*/
|
||||
ProgressiveLoader.prototype.start = function() {
|
||||
this.socket.emit('request', this.objPath, this.laggy);
|
||||
this.socket.emit('request', this.objPath, this.laggy, this.prefetch);
|
||||
};
|
||||
|
||||
return ProgressiveLoader;
|
||||
|
||||
@@ -726,9 +726,13 @@ L3D.createSponzaRecommendations = function(width, height) {
|
||||
|
||||
return [
|
||||
createRecommendation(
|
||||
new THREE.Vector3(97.36225946503932,10.925697484337014,12.852363038244272),
|
||||
new THREE.Vector3(133.315101552449,18.576354168001703,-2.9229530646577633)
|
||||
)
|
||||
new THREE.Vector3(97.36225946503932,10.925697484337014,12.852363038244272),
|
||||
new THREE.Vector3(133.315101552449,18.576354168001703,-2.9229530646577633)
|
||||
),
|
||||
createRecommendation(
|
||||
new THREE.Vector3(-110.4869853758238,17.692671522169423,14.022902297589127),
|
||||
new THREE.Vector3(-147.9067343700736,16.890814116754584,-0.08806541935797796)
|
||||
)
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user