Skip to content

Commit 899f3dd

Browse files
committed
Refactor model files and image files into a unified files array
1 parent 6a1564d commit 899f3dd

File tree

9 files changed

+48
-46
lines changed

9 files changed

+48
-46
lines changed

specification/parts/core.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Only one of `"bufferView"` or `"uri"` MUST be defined. Both properties SHOULD NO
8383

8484
The `"uri"` property is a string that defines the URI of the file. If not specified, the default value is an empty string, meaning there is no URI.
8585

86-
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the model is located there. Implementations may cache and reuse downloaded models as they see fit. If the URI starts with any other scheme, it uses that protocol. If the URI does not contain `://`, it is treated as a relative path to the G4MF file's location.
86+
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the file is located there. Implementations may cache and reuse downloaded files as they see fit. If the URI starts with any other scheme, it uses that protocol. If the URI does not contain `://`, it is treated as a relative path to the G4MF file's location.
8787

8888
File names SHOULD use snake case and all lowercase letters to avoid case sensitivity issues across platforms. When one G4MF resource corresponds to one file, it SHOULD have its name property set to the name of the file, excluding the file extension. This is recommended for the purposes of clarity and semantic preservation during embedding, but any name is allowed, including no name at all.
8989

specification/parts/data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ When compressed data is stored in a separate file or a data URI, `"compression"`
4646

4747
The `"uri"` property is a string that may either be a URI to an external file, or a base64-encoded string. This property is required, except for buffer index 0 in binary G4MF files, which refers to the binary blob data chunk at the end of the file.
4848

49-
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the model is located there. Implementations may cache and reuse downloaded models as they see fit. If the URI starts with any other scheme, it uses that protocol. If using a base64-encoded string, it MUST be a data URI, which starts with the MIME type data prefix `data:application/octet-stream;base64,` and is followed by the base64-encoded data. If the URI does not contain `://` and is not a data URI, it is treated as a relative path to the G4MF file's location.
49+
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the buffer file is located there. Implementations may cache and reuse downloaded buffer files as they see fit. If the URI starts with any other scheme, it uses that protocol. If using a base64-encoded string, it MUST be a data URI, which starts with the MIME type data prefix `data:application/octet-stream;base64,` and is followed by the base64-encoded data. If the URI does not contain `://` and is not a data URI, it is treated as a relative path to the G4MF file's location.
5050

5151
For binary `.g4b` G4MF files, `"uri"` MUST NOT be defined when the buffer refers to a binary blob data chunk at the end of the file. For all other buffers in a binary G4MF, `"uri"` SHOULD NOT contain base64-encoded data, since that would be less efficient than just storing the same data in the binary blob data chunks. Binary G4MF files SHOULD either have buffer data stored in binary blob chunks at the end of the file, or store buffer data in external files, or a mix, but not store buffer data in base64-encoded data URIs.
5252

specification/parts/model/model_file_ref.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ Models are references to other self-contained files that can be used in the scen
66

77
These models are usually used by nodes, where each node using the model becomes a new instance of the model's nodes, and the host G4MF can override the properties of the instantiated model's nodes. This allows for modularity and reusability of models across different scenes and applications. See [G4MF Node Model Instance](node_model_instance.md) for more information about how models are used by nodes. Additionally, models may be used for any other purpose, including as libraries of resources, like a library of meshes, materials, textures, or any other data.
88

9-
Critically, there is one requirement for models used by nodes, regardless of format: they MUST be some kind of data that can be imported as a node or hierarchy of nodes, and placed in the scene hierarchy. This means that models cannot be arbitrary files, such as images or audio files. If there is a desire to have images visible in the scene, the node in the scene hierarchy should be a mesh with the image applied as a texture, defining the size, shape, orientation, and other visual characteristics. If there is a desire to have audio files in the scene, an extension should be used to define an audio node with volume, spatialization, and other playback characteristics. Models MUST be things that can be imported as nodes, a hierarchy of nodes, or directly used on a node, such as importing an OFF file as a standalone mesh and placing it on a mesh node.
9+
Critically, there is one requirement for models used by nodes, regardless of format: they MUST be some kind of data that can be imported as a node or hierarchy of nodes, and placed in the scene hierarchy. This means that models cannot be arbitrary files, such as image files or audio files. If there is a desire to have images visible in the scene, the node in the scene hierarchy should be a mesh with the image applied as a texture, defining the size, shape, orientation, and other visual characteristics. If there is a desire to have audio files in the scene, an extension should be used to define an audio node with volume, spatialization, and other playback characteristics. Models MUST be things that can be imported as nodes, a hierarchy of nodes, or directly used on a node, such as importing an OFF file as a standalone mesh and placing it on a mesh node.
1010

1111
Implementations may choose to support any formats they wish. Support for referencing other G4MF files is highly recommended. However, the ability to reference other files at all is a niche feature, so implementations may choose not to support it at all. If a given model format referenced by a G4MF file is not supported, implementations SHOULD show a warning when importing the G4MF file.
1212

1313
Note that G4MF requires that all named items in the file have unique names. This requirement does not exist for names between files, so a G4MF file imported into another G4MF file may have two nodes with the same name between them. Also, if a model with multiple nodes is instantiated multiple times, there will necessarily be multiple nodes in the overall scene hierarchy which have the same name. 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.
1414

1515
## Properties
1616

17-
These properties are the same as defined for all [G4MF File References](../core.md#file-references), but are listed here for clarity and to elaborate on the descriptions.
17+
Model files are stored in the G4MF's document-level `"files"` array as file references. This is the same array that is used for image files, audio files, and any other files. This list of properties is the same as defined for all [G4MF File References](../core.md#file-references), but are listed here for clarity and to elaborate on the descriptions.
1818

1919
| Property | Type | Description | Default |
2020
| -------------- | --------- | ------------------------------------------------------------------- | --------------------- |
@@ -32,7 +32,7 @@ Only one of `"bufferView"` or `"uri"` MUST be defined. Both properties SHOULD NO
3232

3333
The `"uri"` property is a string that defines the URI of the model file. If not specified, the default value is an empty string, meaning there is no URI.
3434

35-
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the model is located there. Implementations may cache and reuse downloaded models as they see fit. If the URI starts with any other scheme, it uses that protocol. If the URI does not contain `://`, it is treated as a relative path to the G4MF file's location.
35+
The URI may be relative to the G4MF file's location, or alternatively, may be a web address, or any other valid URI format. If the URI starts with `https://`, it is treated as a web address and indicates the model file is located there. Implementations may cache and reuse downloaded model files as they see fit. If the URI starts with any other scheme, it uses that protocol. If the URI does not contain `://`, it is treated as a relative path to the G4MF file's location.
3636

3737
File names SHOULD use snake case and all lowercase letters to avoid case sensitivity issues across platforms, such as `my_model.g4b`. When embedding a model data into a buffer view, the name property SHOULD be set to the name of the file that would exist if it were external, excluding the file extension. For example, if a separate file would look like `{ "mimeType": "model/g4mf-binary", "uri": "my_model.g4b" }`, the embedded equivalent SHOULD look like `{ "bufferView": 0, "mimeType": "model/g4mf-binary", "name": "my_model" }` with `0` replaced with the correct index. This is recommended for the purposes of clarity and semantic preservation during embedding, but any name is allowed, including no name at all.
3838

specification/parts/model/node_model_instance.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Overview
44

5-
G4MF allows referencing external model files. These model files may then be instanced on 0 or more nodes in the scene hierarchy using the `"modelInstance"` property on nodes. Each model instance MAY specify overrides for nodes and materials within the referenced model, allowing for per-instance customization.
5+
G4MF allows referencing external model files. These model files may then be instanced on 0 or more nodes in the scene hierarchy using the `"modelInstance"` property on nodes. Each model instance MAY specify overrides for nodes and materials within the referenced model, allowing for per-instance customization. Model file references exist in the same document-level `"files"` array as all other file references, such as image files, and are referenced by index.
66

77
See [G4MF Model File Reference](model_file_ref.md) for the details of the data within each model.
88

@@ -15,7 +15,7 @@ The following example defines.
1515
| Property | Type | Description | Default |
1616
| -------------------------- | --------- | -------------------------------------------------------------------------------- | ---------------------------- |
1717
| **materialOverrides** | `object` | A map of unique material names to overrides for materials within the model. | `{}` No material overrides. |
18-
| **model** | `integer` | The index of the model that this node references. | Required, no default. |
18+
| **file** | `integer` | The index of the model file that this node references. | Required, no default. |
1919
| **nodeAdditionalChildren** | `object` | A map of unique node names to arrays of host node indices to append as children. | `{}` No additional children. |
2020
| **nodeOverrides** | `object` | A map of unique node names to overrides for nodes within the model. | `{}` No node overrides. |
2121

@@ -27,11 +27,11 @@ Each key in the `"materialOverrides"` object is the name of a material in the so
2727

2828
See [G4MF Material](../mesh/material.md) for more information about materials, and see [Override Mechanism](#override-mechanism) below for details on how overrides are applied.
2929

30-
### Model
30+
### File
3131

32-
The `"model"` property is an integer index that references a model in the document-level `"models"` array. This property is required and has no default value.
32+
The `"file"` property is an integer index that references a model file in the document-level `"files"` array. This property is required and has no default value.
3333

34-
Each model is a [G4MF File Reference](../core.md#file-references) which points to a file containing the model data, with valid target files being anything that can be instantiated as a node or hierarchy of nodes, such as another G4MF file. See [G4MF Model File Reference](model_file_ref.md) for the details of the properties found on each model, which are referred to by index in each model instance.
34+
Each model is a [G4MF File Reference](../core.md#file-references) which points to a file containing the model data, with valid target files being anything that can be instantiated as a node or hierarchy of nodes, such as another G4MF file. Only files that can be instantiated as a tree of nodes are valid targets for the model instance's `"file"` property. See [G4MF Model File Reference](model_file_ref.md) for the details of the properties found on each model file, which are referred to by index here in each model instance.
3535

3636
### Node Additional Children
3737

specification/parts/node.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The following example defines a 4-dimensional G4MF file with a root node at inde
4848
| **camera** | `object` | If this node is a camera, the camera properties. | `undefined` (no camera) |
4949
| **light** | `object` | If this node is a light, the light properties. | `undefined` (no light) |
5050
| **meshInstance** | `object` | If this node is a mesh instance, the mesh properties. | `undefined` (no mesh) |
51-
| **modelInstance** | `integer` | If this node is a model instance, the index of the model. | `undefined` (no model) |
51+
| **modelInstance** | `object` | If this node is a model instance, the model properties. | `undefined` (no model) |
5252
| **physics** | `object` | If this node is a physics object, the physics properties. | `undefined` (no physics) |
5353
| **skeleton** | `object` | If this node is a skeleton root, the skeleton properties. | `undefined` (no skeleton) |
5454

0 commit comments

Comments
 (0)