I'm too good, progressive streaming with only frustum sent, and if

nothing, just stream
This commit is contained in:
Thomas FORGIONE
2015-06-26 09:22:32 +02:00
parent 741f23e03d
commit 5ec0a152f5
4 changed files with 142 additions and 41 deletions

View File

@@ -714,3 +714,30 @@ PointerCamera.prototype.redoable = function() {
return this.history.redoable();
}
PointerCamera.prototype.toList = function() {
this.updateMatrix();
this.updateMatrixWorld();
var frustum = new THREE.Frustum();
var projScreenMatrix = new THREE.Matrix4();
projScreenMatrix.multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse);
frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse));
var ret =
[[this.position.x, this.position.y, this.position.z],
[this.target.x, this.target.y, this.target.z]];
for (var i = 0; i < frustum.planes.length; i++) {
var p = frustum.planes[i];
ret.push([
p.normal.x, p.normal.y, p.normal.z, p.constant
]);
}
return ret;
}

View File

@@ -202,8 +202,7 @@ ProgressiveLoaderGeometry.prototype.getCamera = function() {
if (this.camera === null)
return null;
return [this.camera.position.x, this.camera.position.y, this.camera.position.z,
this.camera.target.x, this.camera.target.y, this.camera.target.z];
return this.toList();
}
/**

View File

@@ -637,14 +637,23 @@ function initSponzaScene(scene, collidableObjects, loader, camera) {
loader.getCamera = function() {
return [
loader.camera.position.x * 10,
loader.camera.position.y * 10,
loader.camera.position.z * 10,
loader.camera.target.x * 10,
loader.camera.target.y * 10,
loader.camera.target.z * 10
];
var ret = loader.camera.toList();
ret[0][0] *= 10;
ret[0][1] *= 10;
ret[0][2] *= 10;
ret[1][0] *= 10;
ret[1][1] *= 10;
ret[1][2] *= 10;
// Planes
for (var i = 2; i < ret.length; i++) {
ret[i][3] *= 10;
}
return ret;
}
loader.obj.scale.set(0.1,0.1,0.1);