mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
fix: type
This commit is contained in:
1 parent
e682172486
commit
2512134e15
1 file changed
+21
-10
@@ -4,7 +4,6 @@ import { useCallback } from 'react';
|
|||||||
import {
|
import {
|
||||||
Intersection,
|
Intersection,
|
||||||
MeshBasicMaterial,
|
MeshBasicMaterial,
|
||||||
MeshStandardMaterial,
|
|
||||||
Object3D,
|
Object3D,
|
||||||
Plane,
|
Plane,
|
||||||
Quaternion,
|
Quaternion,
|
||||||
@@ -31,12 +30,10 @@ function to255(value: number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SpacedArmorSceneComponentProps = {
|
type SpacedArmorSceneComponentProps = {
|
||||||
static?: boolean;
|
|
||||||
node: Object3D;
|
node: Object3D;
|
||||||
thickness: number;
|
thickness: number;
|
||||||
scene: Scene;
|
scene: Scene;
|
||||||
clip?: Plane;
|
clip?: Plane;
|
||||||
thicknessRange: ThicknessRange;
|
|
||||||
} & (
|
} & (
|
||||||
| {
|
| {
|
||||||
type: Exclude<ArmorType, ArmorType.External>;
|
type: Exclude<ArmorType, ArmorType.External>;
|
||||||
@@ -45,7 +42,16 @@ type SpacedArmorSceneComponentProps = {
|
|||||||
type: ArmorType.External;
|
type: ArmorType.External;
|
||||||
variant: ExternalModuleVariant;
|
variant: ExternalModuleVariant;
|
||||||
}
|
}
|
||||||
);
|
) &
|
||||||
|
(
|
||||||
|
| {
|
||||||
|
static?: false;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
static: true;
|
||||||
|
thicknessRange: ThicknessRange;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
export type ExternalModuleVariant = 'gun' | 'track';
|
export type ExternalModuleVariant = 'gun' | 'track';
|
||||||
export type ArmorUserData = {
|
export type ArmorUserData = {
|
||||||
@@ -77,8 +83,6 @@ export function SpacedArmorSceneComponent({
|
|||||||
thickness,
|
thickness,
|
||||||
scene,
|
scene,
|
||||||
clip,
|
clip,
|
||||||
static: staticMode,
|
|
||||||
thicknessRange,
|
|
||||||
...props
|
...props
|
||||||
}: SpacedArmorSceneComponentProps) {
|
}: SpacedArmorSceneComponentProps) {
|
||||||
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
|
const tankopediaEphemeralStore = TankopediaEphemeral.useStore();
|
||||||
@@ -374,14 +378,16 @@ export function SpacedArmorSceneComponent({
|
|||||||
[camera],
|
[camera],
|
||||||
);
|
);
|
||||||
|
|
||||||
if (staticMode) {
|
if (props.static) {
|
||||||
const x = clamp(thickness / 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 r = -((1 - y) ** 2) + 1;
|
||||||
const g = -(y ** 2) + 1;
|
const g = -(y ** 2) + 1;
|
||||||
|
|
||||||
let color: string;
|
let color: string;
|
||||||
let opacity: number;
|
let opacity: number;
|
||||||
|
let renderOrder = 1;
|
||||||
|
let depthWrite = true;
|
||||||
|
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
case ArmorType.Core:
|
case ArmorType.Core:
|
||||||
@@ -397,16 +403,21 @@ export function SpacedArmorSceneComponent({
|
|||||||
case ArmorType.External:
|
case ArmorType.External:
|
||||||
color = `rgb(0, 255, 255)`;
|
color = `rgb(0, 255, 255)`;
|
||||||
opacity = 1 / 8;
|
opacity = 1 / 8;
|
||||||
|
renderOrder = 0;
|
||||||
|
depthWrite = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsxTree(node, {
|
return jsxTree(node, {
|
||||||
material: new MeshStandardMaterial({
|
material: new MeshBasicMaterial({
|
||||||
color,
|
color,
|
||||||
opacity,
|
opacity,
|
||||||
transparent: opacity !== 1,
|
transparent: opacity < 1,
|
||||||
|
depthWrite,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
renderOrder,
|
||||||
|
|
||||||
userData: {
|
userData: {
|
||||||
type: props.type,
|
type: props.type,
|
||||||
variant: props.type === ArmorType.External ? props.variant : 'gun',
|
variant: props.type === ArmorType.External ? props.variant : 'gun',
|
||||||
|
|||||||
Reference in new issue
Block a user