diff --git a/CHANGELOG.md b/CHANGELOG.md index e5ab89e9..d590f662 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,24 @@ The `gltf` crate adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## [1.4.0] - 2023-12-17 + +### Added + +- New API for reading arbitary extension data. +- Interval improvements to prevent panics on 32 bit systems when loading large glTF files. + +### Changed + +- Offsets and sizes in the `gltf-json` crate have been widened to 64 bits. +- Loading glTF on a 32 bit system containing offsets or sizes larger than `u32` will + result in a validation error. + +### Fixed + +- `Gltf::from_reader` no longer winds the reader back to offset zero. +- Broken link in `Material::unlit` documentation. + ## [1.3.0] - 2023-08-21 ### Added diff --git a/Cargo.toml b/Cargo.toml index ef385f38..96212f03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gltf" -version = "1.3.0" +version = "1.4.0" authors = ["David Harvey-Macaulay "] description = "glTF 2.0 loader" documentation = "https://docs.rs/gltf" @@ -25,7 +25,7 @@ approx = "0.5" [dependencies] base64 = { optional = true, version = "0.13" } byteorder = "1.3" -gltf-json = { path = "gltf-json", version = "1.3.0" } +gltf-json = { path = "gltf-json", version = "1.4.0" } lazy_static = "1" urlencoding = { optional = true, version = "2.1" } serde_json = { features = ["raw_value"], version = "1.0" } diff --git a/gltf-derive/Cargo.toml b/gltf-derive/Cargo.toml index c4808203..78c1d97a 100644 --- a/gltf-derive/Cargo.toml +++ b/gltf-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gltf-derive" -version = "1.3.0" +version = "1.4.0" authors = ["David Harvey-Macaulay "] description = "Internal macros for the gltf crate" repository = "https://github.com/gltf-rs/gltf" diff --git a/gltf-json/Cargo.toml b/gltf-json/Cargo.toml index 24895bea..2511ac3d 100644 --- a/gltf-json/Cargo.toml +++ b/gltf-json/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gltf-json" -version = "1.3.0" +version = "1.4.0" authors = ["David Harvey-Macaulay "] description = "JSON parsing for the gltf crate" repository = "https://github.com/gltf-rs/gltf" @@ -9,7 +9,7 @@ edition = "2021" rust-version = "1.61" [dependencies] -gltf-derive = { path = "../gltf-derive", version = "1.3.0" } +gltf-derive = { path = "../gltf-derive", version = "1.4.0" } serde = "1.0" serde_derive = "1.0" serde_json = { features = ["raw_value"], version = "1.0" } diff --git a/src/accessor/mod.rs b/src/accessor/mod.rs index be04545d..a932658f 100644 --- a/src/accessor/mod.rs +++ b/src/accessor/mod.rs @@ -140,7 +140,7 @@ impl<'a> Accessor<'a> { self.json.component_type.unwrap().0 } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -148,7 +148,7 @@ impl<'a> Accessor<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/animation/mod.rs b/src/animation/mod.rs index 29d8ae05..eecad625 100644 --- a/src/animation/mod.rs +++ b/src/animation/mod.rs @@ -113,7 +113,7 @@ impl<'a> Animation<'a> { } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -121,7 +121,7 @@ impl<'a> Animation<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/buffer.rs b/src/buffer.rs index e25be67e..492fa88c 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -103,7 +103,7 @@ impl<'a> Buffer<'a> { self.json.name.as_deref() } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -111,7 +111,7 @@ impl<'a> Buffer<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -186,7 +186,7 @@ impl<'a> View<'a> { self.json.target.map(|target| target.unwrap()) } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -194,7 +194,7 @@ impl<'a> View<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/camera.rs b/src/camera.rs index 1feb212e..a4ce37b0 100644 --- a/src/camera.rs +++ b/src/camera.rs @@ -89,7 +89,7 @@ impl<'a> Camera<'a> { } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -97,7 +97,7 @@ impl<'a> Camera<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -137,7 +137,7 @@ impl<'a> Orthographic<'a> { self.json.znear } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -145,7 +145,7 @@ impl<'a> Orthographic<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -185,7 +185,7 @@ impl<'a> Perspective<'a> { self.json.znear } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -193,7 +193,7 @@ impl<'a> Perspective<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/image.rs b/src/image.rs index 24e55cf9..e1904dbe 100644 --- a/src/image.rs +++ b/src/image.rs @@ -131,7 +131,7 @@ impl<'a> Image<'a> { } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -139,7 +139,7 @@ impl<'a> Image<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/lib.rs b/src/lib.rs index 909f0af2..065d7bc9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -446,7 +446,7 @@ impl Document { } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -454,7 +454,7 @@ impl Document { Some(&root.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/material.rs b/src/material.rs index ad382782..b0f28992 100644 --- a/src/material.rs +++ b/src/material.rs @@ -96,7 +96,7 @@ impl<'a> Material<'a> { PbrMetallicRoughness::new(self.document, &self.json.pbr_metallic_roughness) } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -239,7 +239,7 @@ impl<'a> Material<'a> { /// Returns `true` if the [`KHR_materials_unlit`] property was specified, in which /// case the renderer should prefer to ignore all PBR values except `baseColor`. /// - /// [`KHR_materials_unlit`](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit#overview) + /// [`KHR_materials_unlit`]: https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit#overview #[cfg(feature = "KHR_materials_unlit")] #[cfg_attr(docsrs, doc(cfg(feature = "KHR_materials_unlit")))] pub fn unlit(&self) -> bool { @@ -320,7 +320,7 @@ impl<'a> PbrMetallicRoughness<'a> { }) } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -610,7 +610,7 @@ impl<'a> NormalTexture<'a> { self.texture.clone() } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -665,7 +665,7 @@ impl<'a> OcclusionTexture<'a> { self.texture.clone() } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { diff --git a/src/mesh/mod.rs b/src/mesh/mod.rs index fe74e119..bbf6b2ff 100644 --- a/src/mesh/mod.rs +++ b/src/mesh/mod.rs @@ -148,7 +148,7 @@ impl<'a> Mesh<'a> { self.index } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -156,7 +156,7 @@ impl<'a> Mesh<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -215,7 +215,7 @@ impl<'a> Primitive<'a> { Bounds { min, max } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -223,7 +223,7 @@ impl<'a> Primitive<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/scene/mod.rs b/src/scene/mod.rs index 1f58ad55..71db9f91 100644 --- a/src/scene/mod.rs +++ b/src/scene/mod.rs @@ -145,7 +145,7 @@ impl<'a> Node<'a> { } } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -153,7 +153,7 @@ impl<'a> Node<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -245,7 +245,7 @@ impl<'a> Scene<'a> { self.index } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -253,7 +253,7 @@ impl<'a> Scene<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/skin/mod.rs b/src/skin/mod.rs index 1d5708a5..0298cde9 100644 --- a/src/skin/mod.rs +++ b/src/skin/mod.rs @@ -46,7 +46,7 @@ impl<'a> Skin<'a> { self.index } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -54,7 +54,7 @@ impl<'a> Skin<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { diff --git a/src/texture.rs b/src/texture.rs index ad08a743..3aab4e07 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -101,7 +101,7 @@ impl<'a> Sampler<'a> { self.json.wrap_t.unwrap() } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -109,7 +109,7 @@ impl<'a> Sampler<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -165,7 +165,7 @@ impl<'a> Texture<'a> { .unwrap() } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -173,7 +173,7 @@ impl<'a> Texture<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> { @@ -215,7 +215,7 @@ impl<'a> Info<'a> { .map(TextureTransform::new) } - /// Returns the extension values map + /// Returns extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extensions(&self) -> Option<&Map> { @@ -223,7 +223,7 @@ impl<'a> Info<'a> { Some(&ext.others) } - /// Return a value for a given extension name + /// Queries extension data unknown to this crate version. #[cfg(feature = "extensions")] #[cfg_attr(docsrs, doc(cfg(feature = "extensions")))] pub fn extension_value(&self, ext_name: &str) -> Option<&Value> {