Skip to content

Commit 962f990

Browse files
committed
Rename g4mf_id to g4mf_index
1 parent eb7b1fc commit 962f990

21 files changed

+47
-45
lines changed

specification/parts/core.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44

55
This file describes the core foundational data schemas underlying the Good 4D Model Format (G4MF). These structures are used generally everywhere in G4MF files, not just in specific parts.
66

7-
## IDs
7+
All schemas that start with `g4mf_` (underscore) are the basic core foundational data schemas, while `g4mf.` (dot) built on top of these to define more complex structures. All of these are part of the core G4MF specification, but the `g4mf_` schemas described here are the core of the core.
88

9-
The G4MF ID schema defines an integer used to refer to other items in the G4MF file by index in an array. Which array is being referenced is defined by the context in which the ID is used. For example, a node's `"mesh"` property is defined as referring to a mesh in the G4MF file's `"meshes"` array, so the ID is an index into that array.
9+
## Integer Index Identifiers
1010

11-
If defined, the ID MUST be a valid index in the array it is referencing. The ID MUST NOT be out of bounds of the target array. The ID MUST be an integer, with no fractional part; values such as `1.5` are not valid IDs. The ID of `-1` is reserved as a placeholder value when the relevant field not defined, indicating the lack of pointing to anything, and may be thought of as equivalent to a `null` or `undefined` value. If an array of IDs is defined, sensitive to what slot the ID is in, and the schema allows it, the value `-1` MAY be used as a placeholder for that slot, indicating that the slot does not point to anything. For example, in a skeleton's `"joints"` array, `-1` may be used to indicate that there is no bone controlling that joint. However, in all other cases, such as for standalone properties like `"mesh"`, negative IDs MUST NOT be written to G4MF files. Valid IDs written into standalone properties in G4MF files MUST be integers greater than or equal to `0` and less than the length of the array they are referencing.
11+
The G4MF Integer Index Identifier schema (`g4mf_index`), or Index for short, defines an integer used to refer to other items in the G4MF file by index in an array. Which array is being referenced is defined by the context in which the Index is used. For example, a node's `"mesh"` property is defined as referring to a mesh in the G4MF file's `"meshes"` array, so the G4MF Integer Index Identifier is an index into that array.
12+
13+
If defined, the Index MUST be a valid index in the array it is referencing. The Index MUST NOT be out of bounds of the target array. The Index MUST be an integer, with no fractional part; values such as `1.5` are not valid indices. The Index of `-1` is reserved as a placeholder value when the relevant field not defined, indicating the lack of pointing to anything, and may be thought of as equivalent to a `null` or `undefined` value. If an array of indices is defined, sensitive to what slot the Index is in, and the schema allows it, the value `-1` MAY be used as a placeholder for that slot, indicating that the slot does not point to anything. For example, in a skeleton's `"joints"` array, `-1` may be used to indicate that there is no bone controlling that joint. However, in other cases, such as for standalone properties like `"mesh"`, negative indices MUST NOT be written to G4MF files. Valid indices written into standalone properties in G4MF files MUST be integers greater than or equal to `0` and less than the length of the array they are referencing.
1214

1315
## Items
1416

15-
Items are the base schema for all JSON objects in G4MF. All G4MF schemas of type `object` inherit the G4MF Item schema, or inherit a descendant schema. This includes the root object of the G4MF file itself, which is also an item. The only G4MF schema which does not inherit from the G4MF Item schema is G4MF ID, which is not an `object`, but rather an `integer`. Similarly, all valid user-defined G4MF extensions with schemas of type `object` MUST have G4MF Item schema as a base class, inheriting from it or a descendant schema.
17+
The G4MF Item schema (`g4mf_item`) is the base schema for all JSON objects in G4MF. All G4MF schemas of type `object` inherit the G4MF Item schema, or inherit a descendant schema. This includes the root object of the G4MF file itself, which is also an item. The only G4MF schema which does not inherit from the G4MF Item schema is G4MF Integer Index Identifier, which is not an `object`, but rather an `integer`. Similarly, all valid user-defined G4MF extensions with schemas of type `object` MUST have G4MF Item schema as a base class, inheriting from it or a descendant schema.
1618

1719
### Properties
1820

@@ -51,15 +53,15 @@ If defined, this MUST be unique within the G4MF file, across all items, includin
5153

5254
The name uniqueness requirement exists for all items within a file, but does not apply for names between files. Two G4MF files may have up to two nodes with the same name between them, such as a each having a node named `"Crate"`. If a G4MF file uses another G4MF file as a model (see [G4MF Model](model/model_file_ref.md)), this means that there may be multiple nodes or other items with the same name in the overall scene hierarchy. Therefore, names are not guaranteed to be globally unique across the entire scene hierarchy, but they are guaranteed to be unique within a single G4MF file.
5355

54-
Names in G4MF may be thought of as serving the same purpose as `"id"` values in other formats. They serve as unique identifiers for items within a file, allowing for external systems to unambiguously refer to specific items by name. However, this property is named `"name"` rather than `"id"` to avoid confusion with other schemes, such as numeric IDs, numeric indices, UUIDs, URIs, or other ways to specify identifiers. The `"name"` property is intended to be a human-readable and meaningful unique identifier, meant for display in user interfaces, referencing externally, and conveying semantic meaning about the item it names, such as G4MF nodes named after bones in a character skeleton rig (see [G4MF Characters/Avatars](mesh/character_avatar.md)). Note that within a G4MF file, items are referred to by index in a specification-defined array (see [IDs](#ids)), ensuring that internal references are compact, efficient, and always refer to the correct data type. For example, this design makes it impossible for a mesh's `"material"` property to refer to a node, mesh, texture, or any other non-material item. However, indices are likely to change across file edits; therefore, unique names provide a way for external references to refer to items in a more stable way.
56+
Names in G4MF may be thought of as serving the same purpose as `"id"` values in other formats. They serve as unique identifiers for items within a file, allowing for external systems to unambiguously refer to specific items by name. However, this property is named `"name"` rather than `"id"` to avoid confusion with other schemes, such as numeric IDs, numeric indices, UUIDs, URIs, or other ways to specify identifiers. The `"name"` property is intended to be a human-readable and meaningful unique identifier, meant for display in user interfaces, referencing externally, and conveying semantic meaning about the item it names, such as G4MF nodes named after bones in a character skeleton rig (see [G4MF Characters/Avatars](mesh/character_avatar.md)). Note that within a G4MF file, items are referred to by index in a specification-defined array (see [Integer Index Identifiers](#integer-index-identifiers)), ensuring that internal references are compact, efficient, and always refer to the correct data type. For example, this design makes it impossible for a mesh's `"material"` property to refer to a node, mesh, texture, or any other non-material item. However, indices are likely to change across file edits; therefore, unique names provide a way for external references to refer to items in a more stable way.
5557

5658
All names in a G4MF file MUST NOT contain the following characters: `"`, `.`, `:`, `@`, `{`, `}`, `[`, `]`, `/`, and literal `\`. The `\` character is reserved as the JSON escape character and may be used for escaping characters, but names MUST NOT contain literal backslashes as a standalone character in the decoded string. The characters `{}[]/` are reserved for use in JSON pointer paths, and the characters `".:@` are reserved for use in runtime-determined path syntaxes and selectors across many programming languages and contexts, so these characters are forbidden in names to avoid ambiguity and potential parsing issues when names are used in these contexts.
5759

5860
Furthermore, names MUST NOT contain any control characters, even escaped control characters, including both ASCII control characters and the extended Unicode control characters, as is already required for the entire G4MF JSON structure, except that while the G4MF JSON allows newline and tab characters, names additionally MUST NOT contain newline or tab characters. Names are RECOMMENDED to not contain spaces and not contain other punctuation characters that can be interpreted as special characters in certain contexts, however, all other characters not explicitly forbidden are allowed.
5961

6062
## File References
6163

62-
When G4MF files need to reference data that could be found in an external file, such as an image file, model file, audio file, or any other file, they use a G4MF File Reference. All file references are required to define the file's MIME type, and may refer to stored data either in a buffer view or an external file URI.
64+
When G4MF files need to reference data that could be found in an external file, such as an image file, model file, audio file, or any other file, they use a G4MF File Reference (`g4mf_file_ref`). All file references are required to define the file's MIME type, and may refer to stored data either in a buffer view or an external file URI.
6365

6466
The only case where a G4MF File Reference is not used for referencing external data is in [G4MF Buffers](data.md#buffers) themselves. All G4MF File References are allowed to store data in buffer views, but buffer views reference data stored in buffers, therefore it would be a circular reference. Additionally, the `"mimeType"` property is not useful for buffers, since they are by definition unstructured blobs of binary data, which only have structure defined by the buffer views and accessors using them.
6567

specification/parts/model/node_model_instance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Each model is a [G4MF File Reference](../core.md#file-references) which points t
3737

3838
The `"nodeAdditionalChildren"` property is an object that allows appending host nodes as children of specific nodes within the referenced model. If not defined, the model instance uses only the children defined by the source model.
3939

40-
Each key in the `"nodeAdditionalChildren"` object is the name of a node in the source model, and the value is an array of [G4MF IDs](../core.md#ids) indices referencing nodes in the host G4MF file. These nodes are appended to the end of the children list of the corresponding node during instantiation. This property is additive only and does not replace or remove the source model's children. To replace the children entirely, use `"nodeOverrides"` to set the `"children"` array. To remove only some child nodes from the instance, set that node's override to `null` in `"nodeOverrides"`.
40+
Each key in the `"nodeAdditionalChildren"` object is the name of a node in the source model, and the value is an array of [G4MF Integer Index Identifiers](../core.md#integer-index-identifiers) indices referencing nodes in the host G4MF file. These nodes are appended to the end of the children list of the corresponding node during instantiation. This property is additive only and does not replace or remove the source model's children. To replace the children entirely, use `"nodeOverrides"` to set the `"children"` array. To remove only some child nodes from the instance, set that node's override to `null` in `"nodeOverrides"`.
4141

4242
### Node Overrides
4343

@@ -66,7 +66,7 @@ When override properties are merged, the resulting combined object MUST satisfy
6666

6767
When merging override properties, the following rules apply:
6868

69-
- All [G4MF IDs](../core.md#ids) (indices) in override properties refer to the document-level arrays of the host G4MF file, not the referenced model file. For example, if a model contains a mesh instance node, and the model instance overrides the material to use index `0`, then that refers to the first material in the host G4MF file's `"materials"` array, not the model file's materials.
69+
- All [G4MF Integer Index Identifiers](../core.md#integer-index-identifiers) (indices) in override properties refer to the document-level arrays of the host G4MF file, not the referenced model file. For example, if a model contains a mesh instance node, and the model instance overrides the material to use index `0`, then that refers to the first material in the host G4MF file's `"materials"` array, not the model file's materials.
7070

7171
- All non-null object types have their items merged recursively. This includes the overridden object itself, implying that partial overrides are valid and expected. For example, if a model contains a node with `"physics": { "motion": { "type": "dynamic" } }`, and a model instance contains an override with `"physics": { "motion": { "mass": 5.0 } }`, then the resulting node will have `"physics": { "motion": { "type": "dynamic", "mass": 5.0 } }`.
7272

specification/schema/g4mf.accessor.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"allOf": [{ "$ref": "g4mf_item.schema.json" }],
88
"properties": {
99
"bufferView": {
10-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
10+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
1111
"description": "The index of the buffer view that contains the data for this accessor. This is a reference to a buffer view in the G4MF file's document-level `bufferViews` array."
1212
},
1313
"componentType": {

specification/schema/g4mf.bufferView.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"allOf": [{ "$ref": "g4mf_item.schema.json" }],
88
"properties": {
99
"buffer": {
10-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
10+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
1111
"description": "The index of the buffer that contains the data for this buffer view. This is a reference to a buffer in the G4MF file's document-level `buffers` array.",
1212
"default": 0
1313
},

specification/schema/g4mf.node.model_instance.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
},
1616
"model": {
17-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
17+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
1818
"description": "The index of the model that this node references. This is a reference to a model in the G4MF file's models array. This property is required for a model instance."
1919
},
2020
"nodeAdditionalChildren": {
@@ -23,7 +23,7 @@
2323
"additionalProperties": {
2424
"type": "array",
2525
"items": {
26-
"allOf": [{ "$ref": "g4mf_id.schema.json" }]
26+
"allOf": [{ "$ref": "g4mf_index.schema.json" }]
2727
}
2828
}
2929
},

specification/schema/g4mf.node.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
"type": "array",
2424
"description": "The indices of this node's children.",
2525
"items": {
26-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
26+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
2727
"minimum": 1
2828
},
2929
"uniqueItems": true,
3030
"minItems": 1
3131
},
3232
"light": {
33-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
33+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
3434
"description": "The index of the light that this node references. This is a reference to a light in the G4MF file's lights array. If not defined, this node is not a light source."
3535
},
3636
"meshInstance": {

specification/schema/g4mf_file_ref.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"allOf": [{ "$ref": "g4mf_item.schema.json" }],
88
"properties": {
99
"bufferView": {
10-
"allOf": [{ "$ref": "g4mf_id.schema.json" }],
10+
"allOf": [{ "$ref": "g4mf_index.schema.json" }],
1111
"description": "The index of the buffer view that contains the file data. This is a reference to a buffer view in the G4MF file's buffer views array."
1212
},
1313
"mimeType": {

specification/schema/g4mf_id.schema.json renamed to specification/schema/g4mf_index.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://json-schema.org/draft/2020-12/schema",
3-
"$id": "g4mf_id.schema.json",
4-
"title": "G4MF Identifier",
3+
"$id": "g4mf_index.schema.json",
4+
"title": "G4MF Integer Index Identifier",
55
"description": "An integer index used to identify an object in a G4MF file. This is used to reference objects in arrays, such as nodes, meshes, materials, and textures. When defined, the index MUST be valid in the range of the array it is referencing. An index of -1 MAY be used by extensions or parsers to indicate that a field does not point to an object by default, but this MUST NOT be written to a G4MF file.",
66
"type": "integer",
77
"minimum": 0

specification/schema/mesh/deformation/g4mf.mesh.blend.shape.target.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"allOf": [{ "$ref": "../../g4mf_item.schema.json" }],
88
"properties": {
99
"indices": {
10-
"allOf": [{ "$ref": "../../g4mf_id.schema.json" }],
10+
"allOf": [{ "$ref": "../../g4mf_index.schema.json" }],
1111
"description": "The index of the accessor that contains the indices for the mesh deformation blend shape morph target."
1212
},
1313
"offsets": {
14-
"allOf": [{ "$ref": "../../g4mf_id.schema.json" }],
14+
"allOf": [{ "$ref": "../../g4mf_index.schema.json" }],
1515
"description": "The index of the accessor that contains the offsets or displacements for the mesh deformation blend shape morph target."
1616
}
1717
},

specification/schema/mesh/deformation/g4mf.mesh.skin.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
}
1515
},
1616
"groups": {
17-
"allOf": [{ "$ref": "../../g4mf_id.schema.json" }],
17+
"allOf": [{ "$ref": "../../g4mf_index.schema.json" }],
1818
"description": "The index of the accessor that contains the group indices which influence the corresponding vertices. The size must match the number of indices in `vertices` and `weights`."
1919
},
2020
"vertices": {
21-
"allOf": [{ "$ref": "../../g4mf_id.schema.json" }],
21+
"allOf": [{ "$ref": "../../g4mf_index.schema.json" }],
2222
"description": "The index of the accessor that contains the indices of skinned vertices, with multiple indices for each vertex if it is influenced by multiple groups. The size must match the number of indices in `groups` and `weights`."
2323
},
2424
"weights": {
25-
"allOf": [{ "$ref": "../../g4mf_id.schema.json" }],
25+
"allOf": [{ "$ref": "../../g4mf_index.schema.json" }],
2626
"description": "The index of the accessor that contains the weights for how strongly each group influences the corresponding vertex. The size must match the number of indices in `groups` and `vertices`."
2727
}
2828
},

0 commit comments

Comments
 (0)