Skip to content

Commit

Permalink
Updated sample tilesets to 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed Jul 30, 2018
1 parent ff9f2ad commit fa7b7ff
Show file tree
Hide file tree
Showing 210 changed files with 451 additions and 737 deletions.
35 changes: 33 additions & 2 deletions Source/Scene/Cesium3DTileBatchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,38 @@ define([
'} \n';
}

function replaceDiffuseTextureCalls(source, diffuseAttributeOrUniformName) {
var functionCall = 'texture2D(' + diffuseAttributeOrUniformName;

var fromIndex = 0;
var startIndex = source.indexOf(functionCall, fromIndex);
var endIndex;

while (startIndex > -1) {
var nestedLevel = 0;
for (var i = startIndex; i < source.length; ++i) {
var character = source.charAt(i);
if (character === '(') {
++nestedLevel;
} else if (character === ')') {
--nestedLevel;
if (nestedLevel === 0) {
endIndex = i + 1;
break;
}
}
}
var extractedFunction = source.slice(startIndex, endIndex);
var replacedFunction = 'tile_diffuse_final(' + extractedFunction + ', tile_diffuse)';

source = source.slice(0, startIndex) + replacedFunction + source.slice(endIndex);
fromIndex = startIndex + replacedFunction.length;
startIndex = source.indexOf(functionCall, fromIndex);
}

return source;
}

function modifyDiffuse(source, diffuseAttributeOrUniformName, applyHighlight) {
// If the glTF does not specify the _3DTILESDIFFUSE semantic, return the default shader.
// Otherwise if _3DTILESDIFFUSE is defined prefer the shader below that can switch the color mode at runtime.
Expand Down Expand Up @@ -1030,8 +1062,7 @@ define([
// Regex handles up to one level of nested parentheses:
// E.g. texture2D(u_diffuse, uv)
// E.g. texture2D(u_diffuse, computeUV(index))
regex = new RegExp('texture2D\\(' + diffuseAttributeOrUniformName + '.*?(\\)\\)|\\))', 'g');
source = source.replace(regex, 'tile_diffuse_final($&, tile_diffuse)');
source = replaceDiffuseTextureCalls(source, diffuseAttributeOrUniformName);
setColor =
' tile_diffuse = tile_featureColor; \n' +
' tile_main(); \n';
Expand Down
2 changes: 1 addition & 1 deletion Source/Scene/Cesium3DTileset.js
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ define([
}

if (tileset.debugShowUrl) {
labelString += '\nUrl: ' + tile._header.content.url;
labelString += '\nUrl: ' + tile._header.content.uri;
attributes++;
}

Expand Down
11 changes: 10 additions & 1 deletion Source/Scene/ClassificationModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ define([
'../Core/RuntimeError',
'../Core/Transforms',
'../Core/WebGLConstants',
'../ThirdParty/GltfPipeline/addDefaults',
'../ThirdParty/GltfPipeline/ForEach',
'../ThirdParty/GltfPipeline/getAccessorByteStride',
'../ThirdParty/GltfPipeline/numberOfComponentsForType',
'../ThirdParty/GltfPipeline/parseBinaryGltf',
'../ThirdParty/GltfPipeline/processModelMaterialsCommon',
'../ThirdParty/GltfPipeline/processPbrMetallicRoughness',
'../ThirdParty/when',
'./Axis',
'./ClassificationType',
Expand Down Expand Up @@ -56,10 +59,13 @@ define([
RuntimeError,
Transforms,
WebGLConstants,
addDefaults,
ForEach,
getAccessorByteStride,
numberOfComponentsForType,
parseBinaryGltf,
processModelMaterialsCommon,
processPbrMetallicRoughness,
when,
Axis,
ClassificationType,
Expand Down Expand Up @@ -124,7 +130,10 @@ define([

if (gltf instanceof Uint8Array) {
// Binary glTF
gltf = parseBinaryGltf(gltf);
gltf = parseBinaryGltf(gltf); // Updates to 2.0 and adds pipeline extras
addDefaults(gltf);
processModelMaterialsCommon(gltf);
processPbrMetallicRoughness(gltf);
} else {
throw new RuntimeError('Only binary glTF is supported as a classifier.');
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,9 @@ define([
distances = boundingVolume.computePlaneDistances(position, direction, distances);
near = Math.min(near, distances.start);
far = Math.max(far, distances.stop);
if (isNaN(near)) {
debugger;
}

// Compute a tight near and far plane for commands that receive shadows. This helps compute
// good splits for cascaded shadow maps. Ignore commands that exceed the maximum distance.
Expand Down
8 changes: 6 additions & 2 deletions Source/ThirdParty/GltfPipeline/addDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,12 @@ define([
options = defaultValue(options, {});
addDefaultsFromTemplate(gltf, gltfTemplate);
addDefaultTransformToAnimatedNodes(gltf);
addDefaultMaterial(gltf);
addDefaultTechnique(gltf);

if (gltf.asset.extras.gltf_pipeline_upgrade_10to20) {
addDefaultMaterial(gltf);
addDefaultTechnique(gltf);
}

addDefaultByteOffsets(gltf);
selectDefaultScene(gltf);
inferBufferViewTargets(gltf);
Expand Down
7 changes: 7 additions & 0 deletions Source/ThirdParty/GltfPipeline/processPbrMetallicRoughness.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ define([
}
}

if (optimizeForCesium) {
var baseColorParameter = defaultValue(techniqueParameters.baseColorTexture, techniqueParameters.baseColorFactor);
if (defined(baseColorParameter)) {
baseColorParameter.semantic = '_3DTILESDIFFUSE';
}
}

// Generate uniforms object before attributes are added
var techniqueUniforms = {};
for (var paramName in techniqueParameters) {
Expand Down
Binary file not shown.
14 changes: 7 additions & 7 deletions Specs/Data/Cesium3DTiles/Batched/BatchedColors/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196683129064435
"minimum": -1.3196959060375169,
"maximum": -1.3196607462778132
},
"Latitude": {
"minimum": 0.698861998722264,
"maximum": 0.6988888301460953
"minimum": 0.6988590050687061,
"maximum": 0.6988864387845588
},
"Height": {
"minimum": 6.929546581581235,
"maximum": 13.581844886764884
"minimum": 6.1022464875131845,
"maximum": 13.410263679921627
}
},
"geometricError": 70,
Expand All @@ -35,7 +35,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedColors.b3dm"
"uri": "batchedColors.b3dm"
}
}
}
Binary file not shown.
14 changes: 7 additions & 7 deletions Specs/Data/Cesium3DTiles/Batched/BatchedColorsMix/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196683129064435
"minimum": -1.3196959060375169,
"maximum": -1.3196607462778132
},
"Latitude": {
"minimum": 0.698861998722264,
"maximum": 0.6988888301460953
"minimum": 0.6988590050687061,
"maximum": 0.6988864387845588
},
"Height": {
"minimum": 6.929546581581235,
"maximum": 13.581844886764884
"minimum": 6.1022464875131845,
"maximum": 13.410263679921627
}
},
"geometricError": 70,
Expand All @@ -35,7 +35,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedColorsMix.b3dm"
"uri": "batchedColorsMix.b3dm"
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196683129064435
"minimum": -1.3196959060375169,
"maximum": -1.3196607462778132
},
"Latitude": {
"minimum": 0.698861998722264,
"maximum": 0.6988888301460953
"minimum": 0.6988590050687061,
"maximum": 0.6988864387845588
},
"Height": {
"minimum": 6.929546581581235,
"maximum": 13.581844886764884
"minimum": 6.1022464875131845,
"maximum": 13.410263679921627
}
},
"geometricError": 70,
Expand All @@ -35,7 +35,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedColorsTranslucent.b3dm"
"uri": "batchedColorsTranslucent.b3dm"
}
}
}
Binary file not shown.

This file was deleted.

Binary file not shown.
32 changes: 25 additions & 7 deletions Specs/Data/Cesium3DTiles/Batched/BatchedDeprecated1/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196718547473905
"minimum": -1.3196959060375169,
"maximum": -1.3196607462778132
},
"Latitude": {
"minimum": 0.6988624606923348,
"maximum": 0.6988888301460953
"minimum": 0.6988590050687061,
"maximum": 0.6988864387845588
},
"Height": {
"minimum": 6.2074098233133554,
"maximum": 12.83180232718587
"minimum": 6.1022464875131845,
"maximum": 13.410263679921627
}
},
"geometricError": 70,
"root": {
"transform": [
0.9686356343768792,
0.24848542777253735,
0,
0,
-0.15986460744966327,
0.623177611820219,
0.765567091384559,
0,
0.19023226619126932,
-0.7415555652213445,
0.6433560667227647,
0,
1215011.9317263428,
-4736309.3434217675,
4081602.0044800863,
1
],
"refine": "ADD",
"boundingVolume": {
"region": [
Expand All @@ -35,7 +53,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedDeprecated1.b3dm"
"uri": "batchedDeprecated1.b3dm"
}
}
}
Binary file not shown.
32 changes: 25 additions & 7 deletions Specs/Data/Cesium3DTiles/Batched/BatchedDeprecated2/tileset.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@
"maximum": 9
},
"Longitude": {
"minimum": -1.3196972173766555,
"maximum": -1.3196718547473905
"minimum": -1.3196959060375169,
"maximum": -1.3196607462778132
},
"Latitude": {
"minimum": 0.6988624606923348,
"maximum": 0.6988888301460953
"minimum": 0.6988590050687061,
"maximum": 0.6988864387845588
},
"Height": {
"minimum": 6.2074098233133554,
"maximum": 12.83180232718587
"minimum": 6.1022464875131845,
"maximum": 13.410263679921627
}
},
"geometricError": 70,
"root": {
"transform": [
0.9686356343768792,
0.24848542777253735,
0,
0,
-0.15986460744966327,
0.623177611820219,
0.765567091384559,
0,
0.19023226619126932,
-0.7415555652213445,
0.6433560667227647,
0,
1215011.9317263428,
-4736309.3434217675,
4081602.0044800863,
1
],
"refine": "ADD",
"boundingVolume": {
"region": [
Expand All @@ -35,7 +53,7 @@
},
"geometricError": 0,
"content": {
"url": "batchedDeprecated2.b3dm"
"uri": "batchedDeprecated2.b3dm"
}
}
}
Binary file not shown.
Loading

0 comments on commit fa7b7ff

Please sign in to comment.