From 3f8b72bfc4d4890179b5080fedde6d1b0a18a9c3 Mon Sep 17 00:00:00 2001 From: Joacim Magnusson Date: Mon, 18 Nov 2024 00:07:14 +0100 Subject: [PATCH] Fix texture index mapper in examples --- examples/bombs.rs | 12 +++++++++++- examples/multiple_worlds.rs | 10 ++++++++++ examples/noise_terrain.rs | 12 ++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/examples/bombs.rs b/examples/bombs.rs index 1f36a08..f51d1cc 100644 --- a/examples/bombs.rs +++ b/examples/bombs.rs @@ -1,7 +1,7 @@ use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*, utils::HashMap}; use bevy_voxel_world::prelude::*; use noise::{HybridMulti, NoiseFn, Perlin}; -use std::time::Duration; +use std::{sync::Arc, time::Duration}; #[derive(Resource, Clone, Default)] struct MainWorld; @@ -14,6 +14,16 @@ impl VoxelWorldConfig for MainWorld { fn voxel_lookup_delegate(&self) -> VoxelLookupDelegate { Box::new(move |_chunk_pos| get_voxel_fn()) } + + fn texture_index_mapper(&self) -> Arc [u32; 3] + Send + Sync> { + Arc::new(|mat| match mat { + 0 => [0, 0, 0], + 1 => [1, 1, 1], + 2 => [2, 2, 2], + 3 => [3, 3, 3], + _ => [0, 0, 0], + }) + } } fn main() { diff --git a/examples/multiple_worlds.rs b/examples/multiple_worlds.rs index 07cf440..88a0aaf 100644 --- a/examples/multiple_worlds.rs +++ b/examples/multiple_worlds.rs @@ -35,6 +35,16 @@ impl VoxelWorldConfig for MainWorld { fn voxel_lookup_delegate(&self) -> VoxelLookupDelegate { Box::new(move |_chunk_pos| get_voxel_fn()) } + + fn texture_index_mapper(&self) -> Arc [u32; 3] + Send + Sync> { + Arc::new(|mat| match mat { + 0 => [0, 0, 0], + 1 => [1, 1, 1], + 2 => [2, 2, 2], + 3 => [3, 3, 3], + _ => [0, 0, 0], + }) + } } // This is the second world configuration. In this example, the second world is using a custom material. diff --git a/examples/noise_terrain.rs b/examples/noise_terrain.rs index fe1549e..a101dcb 100644 --- a/examples/noise_terrain.rs +++ b/examples/noise_terrain.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use bevy::{pbr::CascadeShadowConfigBuilder, prelude::*, utils::HashMap}; use bevy_voxel_world::prelude::*; use noise::{HybridMulti, NoiseFn, Perlin}; @@ -15,6 +17,16 @@ impl VoxelWorldConfig for MainWorld { fn voxel_lookup_delegate(&self) -> VoxelLookupDelegate { Box::new(move |_chunk_pos| get_voxel_fn()) } + + fn texture_index_mapper(&self) -> Arc [u32; 3] + Send + Sync> { + Arc::new(|mat| match mat { + 0 => [0, 0, 0], + 1 => [1, 1, 1], + 2 => [2, 2, 2], + 3 => [3, 3, 3], + _ => [0, 0, 0], + }) + } } fn main() {