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

how to use schema.json in gltf2.0 #87

Closed
chen21439 opened this issue Aug 30, 2023 · 7 comments
Closed

how to use schema.json in gltf2.0 #87

chen21439 opened this issue Aug 30, 2023 · 7 comments

Comments

@chen21439
Copy link

[featureIdTexture.schema.json.](https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_mesh_features)

for example in the document,it use shema.json to generate featureId for each vertex,i want to know waht software can do this ,can you give me more information @javagl

@javagl
Copy link
Contributor

javagl commented Aug 30, 2023

As far as I know, there is no software that can assign feature IDs to vertices directly. (I have heard rumors that Blender can assign ~"per-vertex attributes", but this would not be exported to glTF by default). You have to know which vertex should receive which ID, and assign this information to the vertices when you are creating the glTF.

I'm also not aware of any open-source software or library that can (officially) generate glTFs that have this extension. I recently added support for this extension in 3d-tiles-tools, and an example for assigning feature IDs to vertices is shown in the ExtMeshFeaturesDemo.ts. But this is not part of any official API, and it may be changed arbitrarily or even removed at any time. Maybe there will be broader support for this extension in the future.

@chen21439
Copy link
Author

chen21439 commented Sep 8, 2023

@javagl thank you for you reply,i pull the 3d-tiles-tools and run the ExtMeshFeaturesDemo.ts but it throw a error
image
in method savePixelsInternal

const data = putPixelData(pixels, new Uint8Array(width * height * channels));

the data is empty

@javagl
Copy link
Contributor

javagl commented Sep 8, 2023

From a quick glance, this error seems to come from the ndarray library. What happens when you run this test:

import { savePixels } from "ndarray-pixels";
import NdArray from "ndarray";

async function runTest() {
  const sizeX = 3;
  const sizeY = 3;
  const pixels = NdArray(new Uint8Array(sizeX * sizeY), [sizeX, sizeY]);
  for (let x = 0; x < pixels.shape[0]; x++) {
    for (let y = 0; y < pixels.shape[1]; y++) {
      pixels.set(x, y, x * sizeY + y);
    }
  }
  console.log("pixels ", pixels);
  const image = await savePixels(pixels, "image/png");
  console.log("image ", image);
}

runTest();

@chen21439
Copy link
Author

@javagl image it shows that

@chen21439
Copy link
Author

i think the problem occur in ndarray-pixels-node.cjs putPixelData()
image

@javagl
Copy link
Contributor

javagl commented Sep 8, 2023

There seems to be a difference between a JavaScript and a TypeScript context. I haven't understood all the details here yet, but opened donmccurdy/ndarray-pixels#156

As a quick fix, you could change the code that fills the pixels, to anticipate that there are 4 channels (and the values are written into channel 3):

  // Create an image with integer values that serve as feature IDs
  const sizeX = 3;
  const sizeY = 3;
  const pixels = NdArray(new Uint8Array(sizeX * sizeY * 4), [sizeX, sizeY, 4]);
  for (let x = 0; x < pixels.shape[0]; x++) {
    for (let y = 0; y < pixels.shape[1]; y++) {
      pixels.set(x, y, 3, x * sizeY + y);
    }
  }

(I haven't tested it thoroughly, but it should solve the issue for now).

But note that the example only generates "some dummy data", only for testing the implementation of the extension. I have also opened CesiumGS/3d-tiles-tools#62 to track the process to create an extended/updated/fixed demo.

@javagl
Copy link
Contributor

javagl commented Feb 2, 2024

I assume that this can be closed for now.

But a small aside: Somone wrote a nice summary of how to add metadata information to models in Blender at https://community.cesium.com/t/gltf2-0-in-ue5-2-metadata-ext-structural-metadata-ext-mesh-features/26873/8 . There may be some manual steps involved, but it will certainly provide a good starting point.

@javagl javagl closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants