mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: static states
This commit is contained in:
1 parent
5d1352590a
commit
6e7df526ff
2 files changed
+21
-12
No files matched your search
@@ -163,6 +163,7 @@ export const TankModel = memo(() => {
|
|||||||
});
|
});
|
||||||
mutateTankopediaTemporary((draft) => {
|
mutateTankopediaTemporary((draft) => {
|
||||||
draft.shot = undefined;
|
draft.shot = undefined;
|
||||||
|
draft.highlightArmor = undefined;
|
||||||
});
|
});
|
||||||
window.addEventListener('pointermove', handlePointerMove);
|
window.addEventListener('pointermove', handlePointerMove);
|
||||||
window.addEventListener('pointerup', handlePointerUp);
|
window.addEventListener('pointerup', handlePointerUp);
|
||||||
@@ -239,6 +240,7 @@ export const TankModel = memo(() => {
|
|||||||
});
|
});
|
||||||
mutateTankopediaTemporary((draft) => {
|
mutateTankopediaTemporary((draft) => {
|
||||||
draft.shot = undefined;
|
draft.shot = undefined;
|
||||||
|
draft.highlightArmor = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
position.set(event.clientX, event.clientY);
|
position.set(event.clientX, event.clientY);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useThree } from '@react-three/fiber';
|
import { useThree } from '@react-three/fiber';
|
||||||
import { clamp } from 'lodash';
|
import { clamp } from 'lodash';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback, useEffect, useMemo } from 'react';
|
||||||
import {
|
import {
|
||||||
Color,
|
Color,
|
||||||
Intersection,
|
Intersection,
|
||||||
@@ -377,8 +377,6 @@ export function SpacedArmorSceneComponent({
|
|||||||
if (props.static) {
|
if (props.static) {
|
||||||
const x = clamp(thickness / props.thicknessRange.quartile, 0, 1);
|
const x = clamp(thickness / props.thicknessRange.quartile, 0, 1);
|
||||||
const y = Math.sqrt(x);
|
const y = Math.sqrt(x);
|
||||||
const r = -((1 - y) ** 2) + 1;
|
|
||||||
const g = -(y ** 2) + 1;
|
|
||||||
|
|
||||||
let color: Color;
|
let color: Color;
|
||||||
let opacity: number;
|
let opacity: number;
|
||||||
@@ -387,7 +385,7 @@ export function SpacedArmorSceneComponent({
|
|||||||
|
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case ArmorType.Core:
|
case ArmorType.Core:
|
||||||
color = new Color(r, g, 0);
|
color = new Color(-((1 - y) ** 2) + 1, -(y ** 2) + 1, 0);
|
||||||
opacity = 1;
|
opacity = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -406,13 +404,17 @@ export function SpacedArmorSceneComponent({
|
|||||||
|
|
||||||
opacity = clamp(opacity, 0, 1);
|
opacity = clamp(opacity, 0, 1);
|
||||||
|
|
||||||
const material = new MeshStandardMaterial({
|
const material = useMemo(
|
||||||
color,
|
() =>
|
||||||
opacity,
|
new MeshStandardMaterial({
|
||||||
transparent: true,
|
color,
|
||||||
depthWrite,
|
opacity,
|
||||||
...(clip ? { clippingPlanes: [clip] } : {}),
|
transparent: true,
|
||||||
});
|
depthWrite,
|
||||||
|
...(clip ? { clippingPlanes: [clip] } : {}),
|
||||||
|
}),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hook inside an if statement?? don't panic! I assure you the static prop
|
* hook inside an if statement?? don't panic! I assure you the static prop
|
||||||
@@ -425,14 +427,17 @@ export function SpacedArmorSceneComponent({
|
|||||||
if (thisName === undefined) {
|
if (thisName === undefined) {
|
||||||
// nothing selected, go back to defaults
|
// nothing selected, go back to defaults
|
||||||
material.opacity = opacity;
|
material.opacity = opacity;
|
||||||
|
material.transparent = true;
|
||||||
material.color = color;
|
material.color = color;
|
||||||
} else if (thisName === props.name) {
|
} else if (thisName === props.name) {
|
||||||
// this selected, stand out!
|
// this selected, stand out!
|
||||||
material.opacity = 1;
|
material.opacity = 1;
|
||||||
|
material.transparent = false;
|
||||||
material.color = color;
|
material.color = color;
|
||||||
} else {
|
} else {
|
||||||
// something else selected, become background
|
// something else selected, become background
|
||||||
material.opacity = 1 / 4;
|
material.opacity = 1 / 4;
|
||||||
|
material.transparent = true;
|
||||||
material.color = unselectedColor;
|
material.color = unselectedColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -443,9 +448,11 @@ export function SpacedArmorSceneComponent({
|
|||||||
);
|
);
|
||||||
|
|
||||||
return unsubscribe;
|
return unsubscribe;
|
||||||
});
|
}, []);
|
||||||
|
|
||||||
return jsxTree(node, {
|
return jsxTree(node, {
|
||||||
|
castShadow: true,
|
||||||
|
receiveShadow: true,
|
||||||
material,
|
material,
|
||||||
renderOrder,
|
renderOrder,
|
||||||
userData: {
|
userData: {
|
||||||
|
|||||||
Reference in new issue
Block a user