Skip to content

Commit

Permalink
Merge pull request #5077 from AnalyticalGraphicsInc/url-with-query
Browse files Browse the repository at this point in the history
3D Tiles - Use tileset version when querying external uris
  • Loading branch information
pjcozzi committed Mar 7, 2017
2 parents bf8d276 + aade1a0 commit dad1fd8
Show file tree
Hide file tree
Showing 17 changed files with 373 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Source/Scene/Batched3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ define([
gltf : gltfView,
cull : false, // The model is already culled by the 3D tiles
releaseGltfJson : true, // Models are unique and will not benefit from caching so save memory
basePath : getBaseUri(this._url),
basePath : getBaseUri(this._url, true),
modelMatrix : this._tile.computedTransform,
shadows: this._tileset.shadows,
debugWireframe: this._tileset.debugWireframe,
Expand Down
11 changes: 7 additions & 4 deletions Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ define([

if (getExtensionFromUri(url) === 'json') {
tilesetUrl = url;
baseUrl = getBaseUri(url);
baseUrl = getBaseUri(url, true);
} else if (isDataUri(url)) {
tilesetUrl = url;
baseUrl = '';
Expand Down Expand Up @@ -893,13 +893,16 @@ define([
var stats = that._statistics;

// Append the version to the baseUrl
var versionQuery = '?v=' + defaultValue(tilesetJson.asset.tilesetVersion, '0.0');
that._baseUrl = joinUrls(that._baseUrl, versionQuery);
var hasVersionQuery = /[?&]v=/.test(tilesetUrl);
if (!hasVersionQuery) {
var versionQuery = '?v=' + defaultValue(tilesetJson.asset.tilesetVersion, '0.0');
that._baseUrl = joinUrls(that._baseUrl, versionQuery);
tilesetUrl = joinUrls(tilesetUrl, versionQuery, false);
}

// A tileset.json referenced from a tile may exist in a different directory than the root tileset.
// Get the baseUrl relative to the external tileset.
var baseUrl = getBaseUri(tilesetUrl, true);
baseUrl = joinUrls(baseUrl, versionQuery);
var rootTile = new Cesium3DTile(that, baseUrl, tilesetJson.root, parentTile);

var refiningTiles = [];
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/Instanced3DModel3DTileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,10 @@ define([

if (gltfFormat === 0) {
var gltfUrl = getStringFromTypedArray(gltfView);
collectionOptions.url = joinUrls(getBaseUri(this._url), gltfUrl);
collectionOptions.url = joinUrls(getBaseUri(this._url, true), gltfUrl);
} else {
collectionOptions.gltf = gltfView;
collectionOptions.basePath = getBaseUri(this._url);
collectionOptions.basePath = getBaseUri(this._url, true);
}

var eastNorthUp = featureTable.getGlobalProperty('EAST_NORTH_UP');
Expand Down
8 changes: 5 additions & 3 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1549,13 +1549,15 @@ define([
++model._loadResources.pendingTextureLoads;
var imagePath = joinUrls(model._baseUri, gltfImage.uri);

var promise;
if (ktxRegex.test(imagePath)) {
loadKTX(imagePath).then(imageLoad(model, id)).otherwise(getFailedLoadFunction(model, 'image', imagePath));
promise = RequestScheduler.request(imagePath, loadKTX, undefined, model._requestType);
} else if (crnRegex.test(imagePath)) {
loadCRN(imagePath).then(imageLoad(model, id)).otherwise(getFailedLoadFunction(model, 'image', imagePath));
promise = RequestScheduler.request(imagePath, loadCRN, undefined, model._requestType);
} else {
loadImage(imagePath).then(imageLoad(model, id)).otherwise(getFailedLoadFunction(model, 'image', imagePath));
promise = RequestScheduler.request(imagePath, loadImage, undefined, model._requestType);
}
promise.then(imageLoad(model, id)).otherwise(getFailedLoadFunction(model, 'image', imagePath));
}
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
precision highp float;
uniform vec4 u_ambient;
uniform sampler2D u_diffuse;
uniform vec4 u_emission;
uniform vec4 u_specular;
uniform float u_shininess;
uniform float u_transparency;
varying vec3 v_positionEC;
varying vec3 v_normal;
varying vec2 v_texcoord_0;
void main(void) {
vec3 normal = normalize(v_normal);
vec4 diffuse = texture2D(u_diffuse, v_texcoord_0);
vec3 diffuseLight = vec3(0.0, 0.0, 0.0);
vec3 specular = u_specular.rgb;
vec3 specularLight = vec3(0.0, 0.0, 0.0);
vec3 emission = u_emission.rgb;
vec3 ambient = u_ambient.rgb;
vec3 viewDir = -normalize(v_positionEC);
vec3 ambientLight = vec3(0.0, 0.0, 0.0);
ambientLight += vec3(0.2, 0.2, 0.2);
vec3 l = vec3(0.0, 0.0, 1.0);
diffuseLight += vec3(1.0, 1.0, 1.0) * max(dot(normal,l), 0.);
vec3 reflectDir = reflect(-l, normal);
float specularIntensity = max(0., pow(max(dot(reflectDir, viewDir), 0.), u_shininess));
specularLight += vec3(1.0, 1.0, 1.0) * specularIntensity;
vec3 color = vec3(0.0, 0.0, 0.0);
color += diffuse.rgb * diffuseLight;
color += specular * specularLight;
color += emission;
color += ambient * ambientLight;
gl_FragColor = vec4(color * diffuse.a * u_transparency, diffuse.a * u_transparency);
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
precision highp float;
uniform mat4 u_modelViewMatrix;
uniform mat4 u_projectionMatrix;
uniform mat3 u_normalMatrix;
attribute vec3 a_position;
varying vec3 v_positionEC;
attribute vec3 a_normal;
varying vec3 v_normal;
attribute vec2 a_texcoord_0;
varying vec2 v_texcoord_0;
void main(void) {
vec4 pos = u_modelViewMatrix * vec4(a_position,1.0);
v_positionEC = pos.xyz;
gl_Position = u_projectionMatrix * pos;
v_normal = u_normalMatrix * a_normal;
v_texcoord_0 = a_texcoord_0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"asset": {
"version": "0.0",
"tilesetVersion": "1.2.3"
},
"geometricError": 70,
"root": {
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"children": [
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "tileset2/tileset2.json"
}
},
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "external.b3dm"
},
"transform": [
0.9686325809759725,
0.24849733011005554,
0,
0,
-0.15987226587942635,
0.6231756512501834,
0.7655670880409421,
0,
0.190241377398304,
-0.7415532243993574,
0.6433560707015301,
0,
1215072.0326519238,
-4736301.828828896,
4081608.4380407534,
1
]
},
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "external.i3dm"
},
"transform": [
0.9686335987925251,
0.24849336266838487,
0,
0,
-0.15986971340174239,
0.6231763060686413,
0.7655670880409422,
0,
0.1902383400555372,
-0.7415540036062118,
0.6433560707015301,
0,
1215052.6331380012,
-4736306.80562453,
4081608.4380407534,
1
]
},
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "embed.i3dm"
},
"transform": [
0.9686346165928273,
0.24848939522254557,
0,
0,
-0.15986716092137648,
0.6231769608766445,
0.7655670880409424,
0,
0.19023530270957903,
-0.7415547828006255,
0.6433560707015301,
0,
1215033.2336036952,
-4736311.782340704,
4081608.4380407534,
1
]
}
]
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
{
"asset": {
"version": "0.0"
},
"geometricError": 70,
"root": {
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"children": [
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "external.b3dm"
},
"transform": [
0.9686356343768792,
0.24848542777253735,
0,
0,
-0.1598646084383285,
0.6231776156741929,
0.7655670880409422,
0,
0.19023226536042928,
-0.7415555619825982,
0.6433560707015301,
0,
1215013.8340490046,
-4736316.75897742,
4081608.4380407534,
1
]
},
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "external.i3dm"
},
"transform": [
0.9686366521446808,
0.2484814603183605,
0,
0,
-0.1598620559525986,
0.6231782704612867,
0.7655670880409423,
0,
0.19022922800808817,
-0.7415563411521302,
0.6433560707015301,
0,
1214994.4344739306,
-4736321.735534675,
4081608.4380407534,
1
]
},
{
"boundingVolume": {
"region": [
-1.3197004795898053,
0.6988582109,
-1.3196595204101946,
0.6988897891,
0,
20
]
},
"geometricError": 70,
"refine": "add",
"content": {
"url": "embed.i3dm"
},
"transform": [
0.9686376698962317,
0.24847749286001491,
0,
0,
-0.1598595034641867,
0.6231789252379254,
0.7655670880409422,
0,
0.19022619065255567,
-0.7415571203092216,
0.6433560707015301,
0,
1214975.0348784733,
-4736326.712012473,
4081608.4380407534,
1
]
}
]
}
}

0 comments on commit dad1fd8

Please sign in to comment.