patching last commit
This commit is contained in:
@@ -170,13 +170,12 @@ impl ClientState for HexagonLauncher {
|
|||||||
.apps
|
.apps
|
||||||
.iter()
|
.iter()
|
||||||
.map(|a| Snapshot {
|
.map(|a| Snapshot {
|
||||||
- name: a.app.name().unwrap_or_default(),
|
name: a.app.name().unwrap_or_default().to_string(),
|
||||||
+ name: a.app.name().unwrap_or_default().to_string(),
|
cached_texture: a.cached_texture.get().cloned(),
|
||||||
cached_texture: a.cached_texture.get().cloned(),
|
cached_gltf: a.cached_gltf.get().cloned(),
|
||||||
cached_gltf: a.cached_gltf.get().cloned(),
|
})
|
||||||
})
|
.collect();
|
||||||
.collect();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
impl Reify for HexagonLauncher {
|
impl Reify for HexagonLauncher {
|
||||||
#[tracing::instrument(skip_all)]
|
#[tracing::instrument(skip_all)]
|
||||||
@@ -278,50 +277,52 @@ impl ClientState for HexagonLauncher {
|
|||||||
let pos = self.positions[i];
|
let pos = self.positions[i];
|
||||||
// build spatial + cheap model from snapshot (no per-app state access)
|
// build spatial + cheap model from snapshot (no per-app state access)
|
||||||
let mut spatial = Spatial::default().pos(pos).build();
|
let mut spatial = Spatial::default().pos(pos).build();
|
||||||
+
|
|
||||||
+ // attach model from snapshot (gltf preferred, else namespaced + texture)
|
// attach model from snapshot (gltf preferred, else namespaced + texture)
|
||||||
+ if let Some(gltf) = snap.cached_gltf {
|
if let Some(gltf) = snap.cached_gltf {
|
||||||
+ if let Ok(builder) = Model::direct(gltf.to_string_lossy().to_string()) {
|
if let Ok(builder) = Model::direct(gltf.to_string_lossy().to_string()) {
|
||||||
+ spatial = spatial.child(builder.transform(Transform::from_rotation_scale(
|
spatial = spatial.child(
|
||||||
+ Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
|
builder
|
||||||
+ [MODEL_SCALE; 3],
|
.transform(Transform::from_rotation_scale(
|
||||||
+ )).build());
|
Quat::from_rotation_x(PI / 2.0)
|
||||||
+ }
|
* Quat::from_rotation_y(PI),
|
||||||
+ } else {
|
[MODEL_SCALE; 3],
|
||||||
+ let mut mb = Model::namespaced("protostar", "hexagon/hexagon")
|
))
|
||||||
+ .transform(Transform::from_rotation_scale(
|
.build(),
|
||||||
+ Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
|
);
|
||||||
+ [MODEL_SCALE; 3],
|
}
|
||||||
+ ))
|
} else {
|
||||||
+ .part(ModelPart::new("Hex").mat_param(
|
let mut mb = Model::namespaced("protostar", "hexagon/hexagon")
|
||||||
+ "color",
|
.transform(Transform::from_rotation_scale(
|
||||||
+ MaterialParameter::Color(if self.open {
|
Quat::from_rotation_x(PI / 2.0) * Quat::from_rotation_y(PI),
|
||||||
+ BTN_SELECTED_COLOR
|
[MODEL_SCALE; 3],
|
||||||
+ } else {
|
))
|
||||||
+ BTN_COLOR
|
.part(ModelPart::new("Hex").mat_param(
|
||||||
+ }),
|
"color",
|
||||||
+ ));
|
MaterialParameter::Color(if self.open {
|
||||||
+ if let Some(tex) = snap.cached_texture {
|
BTN_SELECTED_COLOR
|
||||||
+ mb = mb.part(ModelPart::new("Icon").mat_param(
|
} else {
|
||||||
+ "diffuse",
|
BTN_COLOR
|
||||||
+ MaterialParameter::Texture(tex),
|
}),
|
||||||
+ ));
|
));
|
||||||
+ }
|
if let Some(tex) = snap.cached_texture {
|
||||||
+ spatial = spatial.child(mb.build());
|
mb = mb.part(ModelPart::new("Icon").mat_param(
|
||||||
+ }
|
"diffuse",
|
||||||
+
|
MaterialParameter::Texture(tex),
|
||||||
+ // attach a Button that mutates real state when used (captures index)
|
));
|
||||||
+ spatial.child(
|
}
|
||||||
+ Button::new(move |state: &mut HexagonLauncher| {
|
spatial = spatial.child(mb.build());
|
||||||
+ // example: toggle open / or launch the app via state.apps[i]
|
}
|
||||||
+ // keep mutation here, but we avoid doing this per-frame.
|
|
||||||
+ // if you need to launch: state.apps[i].launch(...);
|
// attach a Button that mutates real state when used (captures index)
|
||||||
+ tracing::debug!(index = i, "app button pressed");
|
spatial.child(
|
||||||
+ })
|
Button::new(move |state: &mut HexagonLauncher| {
|
||||||
+ .pos([0.0, 0.0, 0.0])
|
tracing::debug!(index = i, "app button pressed");
|
||||||
+ .size([0.01; 2])
|
})
|
||||||
+ .build(),
|
.pos([0.0, 0.0, 0.0])
|
||||||
+ )
|
.size([0.01; 2])
|
||||||
|
.build(),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user