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

EXT_feature_metadata feedback #2019

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
52e466c
Feature metadata draft
lilleyse Feb 19, 2021
02f08ab
New draft for version 1.0.0
lilleyse Feb 21, 2021
aa4e1dd
Add examples section
lilleyse Feb 22, 2021
30df478
Updates from review
lilleyse Feb 22, 2021
a68f643
Fix min/max schema
lilleyse Feb 22, 2021
26ff97c
Peer review edits
lilleyse Feb 22, 2021
405137c
Resolve TODOs
lilleyse Feb 23, 2021
e6f3c2a
Wording
lilleyse Feb 23, 2021
973865e
Insert Wetzel output
ptrgags Feb 23, 2021
8885cd0
Wetzel output revisions
lilleyse Feb 23, 2021
4f0ab88
Add last figure
lilleyse Feb 24, 2021
d7f3339
Addressed review feedback
lilleyse Feb 24, 2021
3c981cc
Fix schema TOC indentation
lilleyse Feb 24, 2021
a71267e
Don't make class required in case the model does not have metadata
lilleyse Feb 24, 2021
75397a9
Schema wording tweaks
lilleyse Feb 24, 2021
35eb9bf
Change bufferView type back to integer
lilleyse Feb 24, 2021
8fcb230
Update extensions/2.0/Vendor/EXT_feature_metadata/1.0.0/schema/featur…
lilleyse Feb 24, 2021
d22a9d1
Update links to Cesium 3D Metadata spec
lilleyse Feb 24, 2021
e2a54d9
Update date
lilleyse Feb 24, 2021
ceaefcf
Minor updates
lilleyse Feb 24, 2021
97b5ac6
Update links to EXT_mesh_gpu_instancing
lilleyse Feb 24, 2021
6ff6344
Reorder classes/enums
lilleyse Feb 25, 2021
39b824e
Wording
lilleyse Feb 25, 2021
3a907d0
Tweaks
lilleyse Feb 25, 2021
972f7dc
Update README.md
lilleyse Apr 27, 2021
1675ae2
Clarify enum binary properties
lilleyse Jun 21, 2021
91ae3fa
Fix year
lilleyse Jul 31, 2021
3bf5af9
Change number to integer in JSON schema
lilleyse Aug 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
682 changes: 682 additions & 0 deletions extensions/2.0/Vendor/EXT_feature_metadata/0.0.0/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Texture Metadata Example: Microcosm

This glTF example is a mesh that represents a lot of different types of
terrain in one small tile

This example simulates using per-texel metadata for land cover
classification as well as the Normalized Difference Vegetation Index (NDVI)
values.

The data here is hand-made until we can get more realistic data.

### Script to generate metadata

To generate the metadata buffer, run `node microcosm-metadata.js`. This
will overwrite `microcosm.bin` and print out JSON to add to the bufferViews
of the glTF.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
'use strict';

const fs = require('fs');

/**
* Need to know these lengths:
* - total buffer length
*
* - LULC Name bufferView length and offsets
* - LULC Name offsets bufferView length and offsets
* - LULC Color bufferView length and offsets
*/

// This is how I mapped the color values in GIMP. Kinda haphazard admittedly.
const landCoverValues = {
0: {
name: "Grassland",
color: [118, 163, 11]
},
32: {
name: "Rocky Ground",
color: [110, 110, 110]
},
64: {
name: "Desert",
color: [212, 209, 182]
},
128: {
name: "River",
color: [82, 173, 204]
},
208: {
name: "Forest",
color: [50, 84, 51]
},
255: {
name: "Building",
color: [194, 194, 194]
}
};

const unusedLandCover = {
name: "Unused",
color: [0, 0, 0]
};

const numberOfLandCoverFeatures = 256;
const sizeOfColor = 3;

function makeLandCoverColors() {
const bufferLength = numberOfLandCoverFeatures * sizeOfColor;
const buffer = Buffer.alloc(bufferLength);
for (let i = 0; i < numberOfLandCoverFeatures; i++) {
const feature = landCoverValues[i];
if (feature !== undefined) {
const [r, g, b] = feature.color;
buffer[3 * i] = r;
buffer[3 * i + 1] = g;
buffer[3 * i + 2] = b;
}

// Otherwise the default color of 0, 0, 0 is used,
// but the buffer is allocated with all 0s so no work is needed here.
}
return buffer;
}

function makeLandCoverNames() {
const offsets = new Uint32Array(numberOfLandCoverFeatures + 1);
let nameText = '';
let currentOffset = 0;
for (let i = 0; i < numberOfLandCoverFeatures; i++) {
let feature = landCoverValues[i];
if (feature === undefined) {
feature = unusedLandCover;
}

const name = feature.name;
const nameLength = Buffer.byteLength(name, 'utf8');

offsets[i] = currentOffset;
currentOffset += nameLength;

nameText += name;
}
offsets[numberOfLandCoverFeatures] = currentOffset;

const namesBuffer = Buffer.from(nameText, 'utf8');

// Convert from Uint32Array -> Buffer (which is a Uint8Array)
const offsetsBuffer = Buffer.from(offsets.buffer);
return [namesBuffer, offsetsBuffer];
}

function makeBufferViews() {
const [landCoverNames, landCoverOffsets] = makeLandCoverNames();
const landCoverColor = makeLandCoverColors();

return [
{
name: "LULC Name",
bufferView: landCoverNames
},
{
name: "LULC Name Offsets",
bufferView: landCoverOffsets,
},
{
name: "LULC Color",
bufferView: landCoverColor
}
]
}

function makeBinFile() {
const bufferViewInfos = makeBufferViews();
const bufferViews = [];
const stats = [];
let offset = 0;
for (const bufferViewInfo of bufferViewInfos) {
if (offset % 8 != 0) {
const paddingBytes = 8 - (offset % 8);
console.log(`Offset not aligned, adding ${paddingBytes} of padding`);
const padding = Buffer.alloc(paddingBytes);
bufferViews.push(padding);
offset += paddingBytes;
}

const bufferView = bufferViewInfo.bufferView;
const byteLength = bufferView.byteLength;
stats.push({
name: bufferViewInfo.name,
buffer: 1,
byteLength: byteLength,
byteOffset: offset
});
offset += byteLength;

bufferViews.push(bufferView);
}

const buffer = Buffer.concat(bufferViews);
fs.writeFileSync('microcosm-metadata.bin', buffer, 'utf8');

console.log(JSON.stringify(stats, undefined, 4));
console.log('totalLength:', buffer.byteLength);
}

makeBinFile();
Binary file not shown.
Loading