summaryrefslogtreecommitdiff
path: root/world
diff options
context:
space:
mode:
Diffstat (limited to 'world')
-rw-r--r--world/Cargo.toml3
-rw-r--r--world/src/main.rs35
2 files changed, 18 insertions, 20 deletions
diff --git a/world/Cargo.toml b/world/Cargo.toml
index bdfc1f1..540b54b 100644
--- a/world/Cargo.toml
+++ b/world/Cargo.toml
@@ -10,4 +10,5 @@ env_logger = "0.11.6"
gltf = { version = "1.4.1", features = ["extras", "names"] }
log = "0.4.22"
weareshared = { path = "../shared" }
-rand = "0.9.0-beta.1" \ No newline at end of file
+rand = "0.9.0-beta.1"
+image = "0.25.5"
diff --git a/world/src/main.rs b/world/src/main.rs
index 033d176..7bcd021 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -1,6 +1,7 @@
#![feature(iter_array_chunks)]
use anyhow::Result;
use clap::Parser;
+use log::info;
use rand::random;
use std::{
io::Write,
@@ -12,7 +13,7 @@ use std::{
use weareshared::{
Affine3A, Vec3A,
packets::{Data, Object, Packet, ReadWrite},
- resources::{Attribute, AttributeArray, IndexArray, Part, Prefab},
+ resources::{AttributeArray, IndexArray, Part, Prefab},
store::ResourceStore,
vec3a,
};
@@ -73,38 +74,34 @@ fn main() -> Result<()> {
.array_chunks::<3>()
.collect::<Vec<_>>();
- let mut albedo = None;
+ let mut tex_pbr_albedo = None;
if let Some(tex) = p.material().pbr_metallic_roughness().base_color_texture() {
let s = tex.texture().source().source();
if let gltf::image::Source::View { view, mime_type } = s {
- let buf = &buffers[view.buffer().index()];
- albedo = Some(store.set(&buf.0)?);
+ info!("albedo texture is of type {mime_type:?}");
+ let buf = &buffers[view.buffer().index()].0
+ [view.offset()..view.offset() + view.length()];
+ tex_pbr_albedo = Some(store.set(buf)?);
}
}
let part = store.set(
&Part {
va_position: Some([
- Attribute::Vertex(store.set(&AttributeArray(pos_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(pos_y).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(pos_z).write_alloc())?),
+ store.set(&AttributeArray(pos_x).write_alloc())?,
+ store.set(&AttributeArray(pos_y).write_alloc())?,
+ store.set(&AttributeArray(pos_z).write_alloc())?,
]),
va_normal: Some([
- Attribute::Vertex(store.set(&AttributeArray(norm_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(norm_y).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(norm_z).write_alloc())?),
+ store.set(&AttributeArray(norm_x).write_alloc())?,
+ store.set(&AttributeArray(norm_y).write_alloc())?,
+ store.set(&AttributeArray(norm_z).write_alloc())?,
]),
va_texcoord: Some([
- Attribute::Vertex(store.set(&AttributeArray(uv_x).write_alloc())?),
- Attribute::Vertex(store.set(&AttributeArray(uv_y).write_alloc())?),
+ store.set(&AttributeArray(uv_x).write_alloc())?,
+ store.set(&AttributeArray(uv_y).write_alloc())?,
]),
- va_pbr_albedo: albedo.map(|a| {
- [
- Attribute::Texture(a, 0),
- Attribute::Texture(a, 1),
- Attribute::Texture(a, 2),
- ]
- }),
+ tex_pbr_albedo,
index: Some(store.set(&IndexArray(index).write_alloc())?),
..Part::default()
}