Giter Site home page Giter Site logo

Comments (11)

lexaknyazev avatar lexaknyazev commented on June 28, 2024 1

@javagl master branch supports now glTF 2.0. Hosted online version was also updated.

from gltf-sample-models.

javagl avatar javagl commented on June 28, 2024

It's probably not a "good" model, unless good==simple, but I started creating a "SimpleSparseAccessors" model.

EDIT: Updated based on KhronosGroup/glTF-Validator#18 - The model now passes 2.0 validation

The embedded version is here:

{
  "accessors" : [ {
    "bufferView" : 0,
    "byteOffset" : 0,
    "componentType" : 5123,
    "count" : 36,
    "type" : "SCALAR",
    "max" : [ 13 ],
    "min" : [ 0 ]
  }, {
    "bufferView" : 1,
    "byteOffset" : 0,
    "componentType" : 5126,
    "count" : 14,
    "type" : "VEC3",
    "max" : [ 6.0, 4.0, 0.0 ],
    "min" : [ 0.0, 0.0, 0.0 ],
    "sparse" : {
      "count" : 3,
      "indices" : {
        "bufferView" : 2,
        "byteOffset" : 0,
        "componentType" : 5123
      },
      "values" : {
        "bufferView" : 3,
        "byteOffset" : 0
      }
    }
  } ],
  "asset" : {
    "version" : "2.0"
  },
  "buffers" : [ {
    "uri" : "data:application/gltf-buffer;base64,AAAIAAcAAAABAAgAAQAJAAgAAQACAAkAAgAKAAkAAgADAAoAAwALAAoAAwAEAAsABAAMAAsABAAFAAwABQANAAwABQAGAA0AAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAQAAAAAAAAAAAAABAQAAAAAAAAAAAAACAQAAAAAAAAAAAAACgQAAAAAAAAAAAAADAQAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAQAAAgD8AAAAAAABAQAAAgD8AAAAAAACAQAAAgD8AAAAAAACgQAAAgD8AAAAAAADAQAAAgD8AAAAACAAKAAwAAAAAAIA/AAAAQAAAAAAAAEBAAABAQAAAAAAAAKBAAACAQAAAAAA=",
    "byteLength" : 284
  } ],
  "bufferViews" : [ {
    "buffer" : 0,
    "byteOffset" : 0,
    "byteLength" : 72,
    "target" : 34963
  }, {
    "buffer" : 0,
    "byteOffset" : 72,
    "byteLength" : 168
  }, {
    "buffer" : 0,
    "byteOffset" : 240,
    "byteLength" : 6
  }, {
    "buffer" : 0,
    "byteOffset" : 248,
    "byteLength" : 36
  } ],
  "meshes" : [ {
    "primitives" : [ {
      "attributes" : {
        "POSITION" : 1
      },
      "indices" : 0
    } ]
  } ],
  "nodes" : [ {
    "mesh" : 0
  } ],
  "scenes" : [ {
    "nodes" : [ 0 ]
  } ]
}

Rendering it should look as in this screenshot:

screenshot

As soon as it can be validated and the kinks are ironed out, I'd add it as a PR, together with a description.

from gltf-sample-models.

lexaknyazev avatar lexaknyazev commented on June 28, 2024

@javagl
Validator supports sparse accessors. Unrelated crash has been fixed.

from gltf-sample-models.

javagl avatar javagl commented on June 28, 2024

OT: @lexaknyazev You mentioned this once, and I wanted to validate it yesterday, but the dev branch was gone, and I saw KhronosGroup/glTF-Validator#17 , so just deferred this for now. Did you use the .snapshot?

from gltf-sample-models.

donmccurdy avatar donmccurdy commented on June 28, 2024

I think there may be a mistake in the sample:

screen shot 2017-11-04 at 7 07 46 pm

In the screenshot above, note that the values array (right column) contains zeros for all of the x positions. The original bufferView has non-zero x positions for these indices, and so after the sparse values are applied to the accessor, y is right but x is reset to zero. In three.js (work-in-progress implementation) I see this:

screen shot 2017-11-04 at 7 09 55 pm

from gltf-sample-models.

donmccurdy avatar donmccurdy commented on June 28, 2024

Work in progress for three.js: donmccurdy/three.js@3b504ef

from gltf-sample-models.

javagl avatar javagl commented on June 28, 2024

@donmccurdy Adding a quick debug output for me gives

Sparse:
[(   1.00000,    2.00000,    0.00000), 
 (   3.00000,    3.00000,    0.00000), 
 (   5.00000,    4.00000,    0.00000)]

which seem to be the right values.

A quick standalone test that only decodes the given buffer and prints the relevant values...

public static void main(String[] args)
{
    String s = "AAAIAAcAAAABAAgAAQAJAAgAAQACAAkAAgAKAAkAAgADAAoAAwALAAoAAwAEAAsABAAMAAsABAAFAAwABQANAAwABQAGAA0AAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAQAAAAAAAAAAAAABAQAAAAAAAAAAAAACAQAAAAAAAAAAAAACgQAAAAAAAAAAAAADAQAAAAAAAAAAAAAAAAAAAgD8AAAAAAACAPwAAgD8AAAAAAAAAQAAAgD8AAAAAAABAQAAAgD8AAAAAAACAQAAAgD8AAAAAAACgQAAAgD8AAAAAAADAQAAAgD8AAAAACAAKAAwAAAAAAIA/AAAAQAAAAAAAAEBAAABAQAAAAAAAAKBAAACAQAAAAAA=";
    byte data[] = Base64.getDecoder().decode(s);
    ByteBuffer bb = ByteBuffer.wrap(data).order(ByteOrder.nativeOrder());
    bb.position(248);
    FloatBuffer fb = bb.asFloatBuffer();
    for (int i=0; i<fb.limit(); i++)
    {
        System.out.println("At "+i+" have "+fb.get(i));
    }
}

also seems to be right.

Note that before the EDIT in the above post, the model contained values that might cause the effect that you observe. I'm not sure where the difference might come from, but will have another look ASAP.

from gltf-sample-models.

donmccurdy avatar donmccurdy commented on June 28, 2024

Oops, you're right β€” I had an old version of the file. Looks good now:

screen shot 2017-11-06 at 8 44 20 pm

from gltf-sample-models.

CentaurMare avatar CentaurMare commented on June 28, 2024

I implemented sparse accessors today in my viewer, this model was critical! Thanks!
The documentation for sparse accessors is a bit, well, sparse. Probably needs some pretty diagrams. It took me days reading and re-reading (off and on) the document and I couldn't understand it, once my brain clicked it was only half an hour to implement.

from gltf-sample-models.

emackey avatar emackey commented on June 28, 2024

@CentaurMare This model did get merged into the sample models repo. The README file has some diagrams. Are more/better diagrams needed?

Since this issue is in the samples repo and not the main glTF repo, I'm tempted to say this should be closed, would you agree? If more official documentation/diagrams are needed, issues or pull requests could be filed to the appropriate place(s) for that.

from gltf-sample-models.

CentaurMare avatar CentaurMare commented on June 28, 2024

@emackey, yes, this can be closed. Better diagrams and/or wording are definitely needed in the spec, I will attempt to write something up and file against the spec.

from gltf-sample-models.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.