Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Add MeshPrimitiveModes #387

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
32 changes: 32 additions & 0 deletions 2.0/MeshPrimitiveModes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# MeshPrimitiveModes

An example that shows rendering modes that are supported for mesh primitives in glTF.

## Screenshot

![screenshot](screenshot/screenshot.png)

## Structure

The example contains seven meshes, each with one mesh primitive. All mesh primitives have the same vertex positions, forming a regular hexagon:
```
3
4 2
0
5 1
6
```

Each mesh primitive has a different `mode`, corresponding to the glTF [mesh topology types](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#meshes-overview). The `indices` of each mesh primitive for the respective modes are as follows:

- indices for `mode=0` (`POINTS`): `[0, 1, 2, 3, 4, 5, 6]`
- indices for `mode=1` (`LINES`): `[0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6]`
- indices for `mode=2` (`LINE_LOOP`): `[0, 1, 2, 3, 4, 5, 6]`
- indices for `mode=3` (`LINE_STRIP`): `[0, 1, 2, 3, 4, 5, 6]`
- indices for `mode=4` (`TRIANGLES`): `[0, 1, 2, 0, 2, 3, 0, 3, 4, 0, 4, 5, 0, 5, 6, 0, 6, 1]`
- indices for `mode=5` (`TRIANGLE_STRIP`): `[2, 3, 1, 4, 6, 5]` (vertex `0` is unused here)
- indices for `mode=6` (`TRIANGLE_FAN`): `[0, 1, 2, 3, 4, 5, 6, 1]`

## License Information

Public domain ([CC0](https://creativecommons.org/publicdomain/zero/1.0/))
233 changes: 233 additions & 0 deletions 2.0/MeshPrimitiveModes/glTF-Embedded/MeshPrimitiveModes.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
{
"asset": {
"version": "2.0"
},

"scene": 0,
"scenes": [
{
"nodes": [0, 1, 2, 3, 4, 5, 6]
}
],

"nodes": [
{
"translation": [-0, 3, 0],
"mesh": 0
},
{
"translation": [-2, 0, 0],
"mesh": 1
},
{
"translation": [0, 0, 0],
"mesh": 2
},
{
"translation": [2, 0, 0],
"mesh": 3
},
{
"translation": [-2, -3, 0],
"mesh": 4
},
{
"translation": [0, -3, 0],
"mesh": 5
},
{
"translation": [2, -3, 0],
"mesh": 6
}
],

"meshes": [
{
"name": "mesh with POINTS",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 0,
"mode": 0
}
]
},
{
"name": "mesh with LINES",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 1,
"mode": 1
}
]
},
{
"name": "mesh with LINE_LOOP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 2,
"mode": 2
}
]
},
{
"name": "mesh with LINE_STRIP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 3,
"mode": 3
}
]
},
{
"name": "mesh with TRIANGLES",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 4,
"mode": 4
}
]
},
{
"name": "mesh with GL_TRIANGLE_STRIP",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 5,
"mode": 5
}
]
},
{
"name": "mesh with GL_TRIANGLE_FAN",
"primitives": [
{
"attributes": {
"POSITION": 7
},
"indices": 6,
"mode": 6
}
]
}
],

"buffers": [
{
"uri" : "data:application/gltf-buffer;base64,AAABAAIAAwAEAAUABgAAAAEAAAACAAAAAwAAAAQAAAAFAAAABgAAAAEAAgADAAQABQAGAAAAAQACAAMABAAFAAYAAAABAAIAAAACAAMAAAADAAQAAAAEAAUAAAAFAAYAAAAGAAEAAgADAAEABAAGAAUAAAABAAIAAwAEAAUABgABAAAAAAAAAAAAAAAAAAAALbJdPwAAAL8AAAAALbJdPwAAAD8AAAAAAAAAAAAAgD8AAAAALbJdvwAAAD8AAAAALbJdvwAAAL8AAAAAAAAAAAAAgL8AAAAA",
"byteLength": 216
}
],
"bufferViews": [
{
"buffer": 0,
"byteOffset": 0,
"byteLength": 130,
"target": 34963
},
{
"buffer": 0,
"byteOffset": 132,
"byteLength": 84,
"target": 34962
}
],
"accessors": [
{
"name": "indices for POINTS",
"bufferView": 0,
"byteOffset": 0,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINES",
"bufferView": 0,
"byteOffset": 14,
"componentType": 5123,
"count": 12,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINE_LOOP",
"bufferView": 0,
"byteOffset": 38,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for LINE_STRIP",
"bufferView": 0,
"byteOffset": 52,
"componentType": 5123,
"count": 7,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for TRIANGLES",
"bufferView": 0,
"byteOffset": 66,
"componentType": 5123,
"count": 18,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "indices for TRIANGLE_STRIP",
"bufferView": 0,
"byteOffset": 102,
"componentType": 5123,
"count": 6,
"type": "SCALAR",
"max": [6],
"min": [1]
},
{
"name": "indices for TRIANGLE_FAN",
"bufferView": 0,
"byteOffset": 114,
"componentType": 5123,
"count": 8,
"type": "SCALAR",
"max": [6],
"min": [0]
},
{
"name": "positions",
"bufferView": 1,
"byteOffset": 0,
"componentType": 5126,
"count": 7,
"type": "VEC3",
"max": [0.866, 1.0, 0.0],
"min": [-0.866, -1.0, 0.0]
}
]
}
Loading