-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
170 changes: 170 additions & 0 deletions
170
samples/1.1/EXT_Structural_Metadata/SimplePropertyTexture/SimplePropertyTexture.gltf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"extensions" : { | ||
"EXT_structural_metadata" : { | ||
"schema" : { | ||
"id": "SimplePropertyTextureSchema", | ||
"classes" : { | ||
"buildingComponents" : { | ||
"name" : "Building properties", | ||
"properties" : { | ||
"insideTemperature" : { | ||
"name" : "Inside Temperature", | ||
"type" : "SCALAR", | ||
"componentType" : "UINT8" | ||
}, | ||
"outsideTemperature" : { | ||
"name" : "Outside Temperature", | ||
"type" : "SCALAR", | ||
"componentType" : "UINT8" | ||
}, | ||
"insulation" : { | ||
"name" : "Insulation Thickness", | ||
"type" : "SCALAR", | ||
"componentType" : "UINT8", | ||
"normalized" : true | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"propertyTextures" : [ { | ||
"class" : "buildingComponents", | ||
"properties" : { | ||
"insideTemperature" : { | ||
"index" : 1, | ||
"texCoord" : 0, | ||
"channels" : [ 0 ] | ||
}, | ||
"outsideTemperature" : { | ||
"index" : 1, | ||
"texCoord" : 0, | ||
"channels" : [ 1 ] | ||
}, | ||
"insulation" : { | ||
"index" : 1, | ||
"texCoord" : 0, | ||
"channels" : [ 2 ] | ||
} | ||
} | ||
} ] | ||
} | ||
}, | ||
"extensionsUsed" : [ "EXT_structural_metadata" ], | ||
"accessors" : [ { | ||
"bufferView" : 0, | ||
"byteOffset" : 0, | ||
"componentType" : 5123, | ||
"count" : 6, | ||
"type" : "SCALAR", | ||
"max" : [ 3 ], | ||
"min" : [ 0 ] | ||
}, { | ||
"bufferView" : 1, | ||
"byteOffset" : 0, | ||
"componentType" : 5126, | ||
"count" : 4, | ||
"type" : "VEC3", | ||
"max" : [ 1.0, 1.0, 0.0 ], | ||
"min" : [ 0.0, 0.0, 0.0 ] | ||
}, { | ||
"bufferView" : 2, | ||
"byteOffset" : 0, | ||
"componentType" : 5126, | ||
"count" : 4, | ||
"type" : "VEC3", | ||
"max" : [ 0.0, 0.0, 1.0 ], | ||
"min" : [ 0.0, 0.0, 1.0 ] | ||
}, { | ||
"bufferView" : 3, | ||
"byteOffset" : 0, | ||
"componentType" : 5126, | ||
"count" : 4, | ||
"type" : "VEC2", | ||
"max" : [ 1.0, 1.0 ], | ||
"min" : [ 0.0, 0.0 ] | ||
} ], | ||
"asset" : { | ||
"generator" : "JglTF from https://github.com/javagl/JglTF", | ||
"version" : "2.0" | ||
}, | ||
"buffers" : [ { | ||
"uri" : "data:application/gltf-buffer;base64,AAABAAIAAQADAAIAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgD8AAIA/AACAPwAAAAAAAAAAAACAPwAAAAA=", | ||
"byteLength" : 140 | ||
} ], | ||
"bufferViews" : [ { | ||
"buffer" : 0, | ||
"byteOffset" : 0, | ||
"byteLength" : 12, | ||
"target" : 34963 | ||
}, { | ||
"buffer" : 0, | ||
"byteOffset" : 12, | ||
"byteLength" : 48, | ||
"target" : 34962 | ||
}, { | ||
"buffer" : 0, | ||
"byteOffset" : 60, | ||
"byteLength" : 48, | ||
"target" : 34962 | ||
}, { | ||
"buffer" : 0, | ||
"byteOffset" : 108, | ||
"byteLength" : 32, | ||
"target" : 34962 | ||
} ], | ||
"images" : [ { | ||
"uri" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAA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lCyBW+7lpDnyNS34gcTQRltTPbAeEdFjcSQ0X9EOhGPYjhgLA7xh3kjxEEpMj1qQj7iAzAYoPELzYtuwK02M06WywAFDfX1MdJEoOtSZ7Allz1mYmWZDNL0pNF6ezu9jsQJUcNK7qzbWvMdSYQ8Jo7KKK8/uo4dxreHe0/HgF2/IqBen/za+Di69Sf8cZz5jmk+hcuhdd2tWLz8IE5MbFnRWT+yyU5vZJRtAOqlvq6MDeOrstu0UidsoO0Ak9xGwE+67+34salNEBSCxX7Bexg0rbq6TFvwAAAABJRU5ErkJggg==", | ||
"mimeType" : "image/png" | ||
} ], | ||
"materials" : [ { | ||
"pbrMetallicRoughness" : { | ||
"baseColorFactor" : [ 1.0, 1.0, 1.0, 1.0 ], | ||
"baseColorTexture" : { | ||
"index" : 0, | ||
"texCoord" : 0 | ||
}, | ||
"metallicFactor" : 0.0, | ||
"roughnessFactor" : 1.0 | ||
}, | ||
"alphaMode" : "OPAQUE", | ||
"doubleSided" : true | ||
} ], | ||
"meshes" : [ { | ||
"primitives" : [ { | ||
"extensions" : { | ||
"EXT_structural_metadata" : { | ||
"propertyTextures" : [ 0 ] | ||
} | ||
}, | ||
"attributes" : { | ||
"POSITION" : 1, | ||
"NORMAL" : 2, | ||
"TEXCOORD_0" : 3 | ||
}, | ||
"indices" : 0, | ||
"material" : 0, | ||
"mode" : 4 | ||
} ] | ||
} ], | ||
"nodes" : [ { | ||
"mesh" : 0 | ||
} ], | ||
"samplers" : [ { | ||
"magFilter" : 9728, | ||
"minFilter" : 9728 | ||
} ], | ||
"scene" : 0, | ||
"scenes" : [ { | ||
"nodes" : [ 0 ] | ||
} ], | ||
"textures" : [ { | ||
"sampler" : 0, | ||
"source" : 0 | ||
}, { | ||
"sampler" : 0, | ||
"source" : 1 | ||
} ] | ||
} |
75 changes: 75 additions & 0 deletions
75
samples/1.1/EXT_Structural_Metadata/SimplePropertyTexture/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<script src="https://cesium.com/downloads/cesiumjs/releases/1.112/Build/Cesium/Cesium.js"></script> | ||
<link href="https://cesium.com/downloads/cesiumjs/releases/1.112/Build/Cesium/Widgets/widgets.css" rel="stylesheet"> | ||
|
||
<style> | ||
html, body, #cesiumContainer { | ||
width: 100%; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
overflow: hidden; | ||
} | ||
|
||
.toolbar-left { | ||
display: block; | ||
position: absolute; | ||
top: 5px; | ||
left: 5px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="cesiumContainer"></div> | ||
<script type="module"> | ||
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiNDc1ZjQwMS1hOGI2LTQyNmUtYmYxMi1jODlhNDNlMjViZTkiLCJpZCI6NDc4OSwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MTYyNTg3OX0.mNoGLdYuwqsnRRkQtdYNMbJfMBoZF2hPkbc4SRVVqNw'; | ||
const viewer = new Cesium.Viewer("cesiumContainer"); | ||
|
||
const tileset = viewer.scene.primitives.add( | ||
await Cesium.Cesium3DTileset.fromUrl( | ||
"tileset.json", | ||
{ | ||
debugShowBoundingVolume: true, | ||
} | ||
) | ||
); | ||
|
||
tileset.modelMatrix = Cesium.Transforms.eastNorthUpToFixedFrame( | ||
Cesium.Cartesian3.fromDegrees(-75.152325, 39.94704, 0) | ||
); | ||
const offset = new Cesium.HeadingPitchRange( | ||
0, | ||
Cesium.Math.toRadians(-22.5), | ||
4.0 | ||
); | ||
|
||
// Create a custom (fragment) shader that accesses the metadata value with the | ||
// given property name, normalizes it to a value in [0,1] based on the given | ||
// source range, and uses that value as the brightness for the fragment. | ||
function createShader(propertyName, sourceMin, sourceMax) { | ||
const shader = new Cesium.CustomShader({ | ||
fragmentShaderText: ` | ||
void fragmentMain(FragmentInput fsInput, inout czm_modelMaterial material) | ||
{ | ||
float value = float(fsInput.metadata.${propertyName}); | ||
float range = float(${sourceMax}) - float(${sourceMin}); | ||
float brightness = (value - float(${sourceMin})) / range; | ||
material.diffuse = vec3(brightness); | ||
} | ||
`, | ||
}); | ||
return shader; | ||
} | ||
|
||
viewer.zoomTo(tileset, offset); | ||
tileset.customShader = undefined; | ||
tileset.customShader = createShader("insideTemperature", 0.0, 255.0); | ||
// tileset.customShader = createShader("outsideTemperature", 0.0, 255.0); | ||
// tileset.customShader = createShader("insulation", 0.0, 1.0); | ||
|
||
</script> | ||
</body> | ||
</html> |
19 changes: 19 additions & 0 deletions
19
samples/1.1/EXT_Structural_Metadata/SimplePropertyTexture/tileset.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"asset" : { | ||
"version" : "1.1" | ||
}, | ||
"geometricError" : 100.0, | ||
"root" : { | ||
"content" : { | ||
"uri" : "SimplePropertyTexture.gltf" | ||
}, | ||
"boundingVolume" : { | ||
"box" : [ | ||
0.5, 0.0, 0.5, | ||
0.5, 0.0, 0.0, | ||
0.0, 0.01, 0.0, | ||
0.0, 0.0, 0.5] | ||
}, | ||
"geometricError" : 0.0 | ||
} | ||
} |