Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite tiles #3158

Merged
merged 8 commits into from
Nov 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions Apps/Sandcastle/gallery/Cities.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@
var scene = viewer.scene;
var city = scene.primitives.add(new Cesium.Cesium3DTileset({
//url : 'http://localhost:8002/tilesets/Cambridge',
url : 'http://localhost:8002/tilesets/London_Canary_Wharf',
//url : 'http://localhost:8002/tilesets/London_Canary_Wharf',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid submitting these temporary changes to Cities.html in the future.

//url : 'http://localhost:8002/tilesets/trees',
//url : 'http://localhost:8002/tilesets/Philly',
//url : 'http://localhost:8002/tilesets/Seattle',
url : 'http://localhost:8002/tilesets/Seattle',
//url : 'http://localhost:8002/tilesets/SeattleTrees',
//url : 'http://localhost:8002/tilesets/SeattleComposite',

// Defaults:
maximumScreenSpaceError : 16,
Expand All @@ -51,10 +52,10 @@

viewer.camera.setView({
//destination : Cesium.Cartesian3.fromDegrees(-71.1106, 42.3736, 5000.0) // Cambridge
destination : Cesium.Cartesian3.fromDegrees(0.0183, 51.5036, 5000.0) // Canary Wharf
//destination : Cesium.Cartesian3.fromDegrees(0.0183, 51.5036, 5000.0) // Canary Wharf
//destination : Cesium.Cartesian3.fromRadians(-1.2911323805815227, 0.7097150757974291, 5000.0) // NYC Trees
//destination : Cesium.Cartesian3.fromDegrees(-75.1667, 39.9500, 5000.0) // Philly trees
//destination : Cesium.Cartesian3.fromDegrees(-122.3331, 47.6097, 5000.0) // Seattle
destination : Cesium.Cartesian3.fromDegrees(-122.3331, 47.6097, 5000.0) // Seattle
});

scene.debugShowFramesPerSecond = true;
Expand Down
33 changes: 33 additions & 0 deletions Source/Core/BoundingSphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define([
'./GeographicProjection',
'./Intersect',
'./Interval',
'./Matrix3',
'./Matrix4',
'./Plane',
'./Rectangle'
Expand All @@ -24,6 +25,7 @@ define([
GeographicProjection,
Intersect,
Interval,
Matrix3,
Matrix4,
Plane,
Rectangle) {
Expand Down Expand Up @@ -590,6 +592,37 @@ define([
return result;
};

var fromOrientedBoundingBoxScratchU = new Cartesian3();
var fromOrientedBoundingBoxScratchV = new Cartesian3();
var fromOrientedBoundingBoxScratchW = new Cartesian3();

/**
* Computes a tight-fitting bounding sphere enclosing the provided oriented bounding box.
*
* @param {OrientedBoundingBox} orientedBoundingBox The oriented bounding box.
* @param {BoundingSphere} [result] The object onto which to store the result.
* @returns {BoundingSphere} The modified result parameter or a new BoundingSphere instance if none was provided.
*/
BoundingSphere.fromOrientedBoundingBox = function(orientedBoundingBox, result) {
if (!defined(result)) {
result = new BoundingSphere();
}

var halfAxes = orientedBoundingBox.halfAxes;
var u = Matrix3.getColumn(halfAxes, 0, fromOrientedBoundingBoxScratchU);
var v = Matrix3.getColumn(halfAxes, 1, fromOrientedBoundingBoxScratchV);
var w = Matrix3.getColumn(halfAxes, 2, fromOrientedBoundingBoxScratchW);

var uHalf = Cartesian3.magnitude(u);
var vHalf = Cartesian3.magnitude(v);
var wHalf = Cartesian3.magnitude(w);

result.center = Cartesian3.clone(orientedBoundingBox.center, result.center);
result.radius = Math.max(uHalf, vHalf, wHalf);

return result;
};

/**
* Duplicates a BoundingSphere instance.
*
Expand Down
15 changes: 2 additions & 13 deletions Source/Core/OrientedBoundingBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ define([
/**
* Determines whether or not a bounding box is hidden from view by the occluder.
*
* @param {OrientedBoundingBox} sphere The bounding box surrounding the occludee object.
* @param {OrientedBoundingBox} box The bounding box surrounding the occludee object.
* @param {Occluder} occluder The occluder.
* @returns {Boolean} <code>true</code> if the sphere is not visible; otherwise <code>false</code>.
*/
Expand All @@ -625,18 +625,7 @@ define([
}
//>>includeEnd('debug');

var halfAxes = box.halfAxes;
var u = Matrix3.getColumn(halfAxes, 0, scratchCartesianU);
var v = Matrix3.getColumn(halfAxes, 1, scratchCartesianV);
var w = Matrix3.getColumn(halfAxes, 2, scratchCartesianW);

var uHalf = Cartesian3.magnitude(u);
var vHalf = Cartesian3.magnitude(v);
var wHalf = Cartesian3.magnitude(w);

var sphere = scratchBoundingSphere;
sphere.center = Cartesian3.clone(box.center, sphere.center);
sphere.radius = Math.max(uHalf, vHalf, wHalf);
var sphere = BoundingSphere.fromOrientedBoundingBox(box, scratchBoundingSphere);

return !occluder.isBoundingSphereVisible(sphere);
};
Expand Down
18 changes: 17 additions & 1 deletion Source/Core/getStringFromTypedArray.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/*global define*/
define([
'./defaultValue',
'./defined',
'./DeveloperError'
], function(
defaultValue,
defined,
DeveloperError) {
"use strict";
Expand All @@ -11,13 +13,27 @@ define([
/**
* @private
*/
var getStringFromTypedArray = function(uint8Array) {
var getStringFromTypedArray = function(uint8Array, byteOffset, byteLength) {
//>>includeStart('debug', pragmas.debug);
if (!defined(uint8Array)) {
throw new DeveloperError('uint8Array is required.');
}
if (byteOffset < 0) {
throw new DeveloperError('byteOffset cannot be negative.');
}
if (byteLength < 0) {
throw new DeveloperError('byteLength cannot be negative.');
}
if ((byteOffset + byteLength) > uint8Array.byteLength) {
throw new DeveloperError('sub-region exceeds array bounds.');
}
//>>includeEnd('debug');

byteOffset = defaultValue(byteOffset, 0);
byteLength = defaultValue(byteLength, uint8Array.byteLength - byteOffset);

uint8Array = uint8Array.subarray(byteOffset, byteOffset + byteLength);

return getStringFromTypedArray.decode(uint8Array);
};

Expand Down