mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
fix: invalidate frame on uniform change
This commit is contained in:
1 parent
1f7b78dabc
commit
099e878c55
3 files changed
+23
-1
No files matched your search
+10
-1
@@ -4,7 +4,7 @@ import {
|
|||||||
isExplosive,
|
isExplosive,
|
||||||
resolvePenetrationCoefficient,
|
resolvePenetrationCoefficient,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import { useFrame } from '@react-three/fiber';
|
import { invalidate, useFrame } from '@react-three/fiber';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { MeshBasicMaterial, Object3D, ShaderMaterial, Vector2 } from 'three';
|
import { MeshBasicMaterial, Object3D, ShaderMaterial, Vector2 } from 'three';
|
||||||
import { degToRad } from 'three/src/math/MathUtils.js';
|
import { degToRad } from 'three/src/math/MathUtils.js';
|
||||||
@@ -74,12 +74,15 @@ export function PrimaryArmorSceneComponent({
|
|||||||
const duel = duelStore.getState();
|
const duel = duelStore.getState();
|
||||||
await handleProtagonistEquipmentChange(duel.protagonist.equipmentMatrix);
|
await handleProtagonistEquipmentChange(duel.protagonist.equipmentMatrix);
|
||||||
await handleAntagonistEquipmentChange(duel.antagonist.equipmentMatrix);
|
await handleAntagonistEquipmentChange(duel.antagonist.equipmentMatrix);
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
function handleGreenPenetrationChange(greenPenetration: boolean) {
|
function handleGreenPenetrationChange(greenPenetration: boolean) {
|
||||||
material.uniforms.greenPenetration.value = greenPenetration;
|
material.uniforms.greenPenetration.value = greenPenetration;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
function handleOpaqueChange(opaque: boolean) {
|
function handleOpaqueChange(opaque: boolean) {
|
||||||
material.uniforms.opaque.value = opaque;
|
material.uniforms.opaque.value = opaque;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
function handleWireframeChange(wireframe: boolean) {
|
function handleWireframeChange(wireframe: boolean) {
|
||||||
material.wireframe = wireframe;
|
material.wireframe = wireframe;
|
||||||
@@ -96,6 +99,8 @@ export function PrimaryArmorSceneComponent({
|
|||||||
material.uniforms.thickness.value = hasEnhancedArmor
|
material.uniforms.thickness.value = hasEnhancedArmor
|
||||||
? thickness * 1.03
|
? thickness * 1.03
|
||||||
: thickness;
|
: thickness;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
||||||
const duel = duelStore.getState();
|
const duel = duelStore.getState();
|
||||||
@@ -110,6 +115,8 @@ export function PrimaryArmorSceneComponent({
|
|||||||
material.uniforms.penetration.value =
|
material.uniforms.penetration.value =
|
||||||
penetration *
|
penetration *
|
||||||
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleShellChange(duelStore.getState().antagonist.shell);
|
handleShellChange(duelStore.getState().antagonist.shell);
|
||||||
@@ -156,6 +163,8 @@ export function PrimaryArmorSceneComponent({
|
|||||||
spacedArmorRenderTarget.depthTexture;
|
spacedArmorRenderTarget.depthTexture;
|
||||||
material.uniforms.inverseProjectionMatrix.value =
|
material.uniforms.inverseProjectionMatrix.value =
|
||||||
camera.projectionMatrixInverse;
|
camera.projectionMatrixInverse;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
+6
@@ -2,6 +2,7 @@ import {
|
|||||||
resolvePenetrationCoefficient,
|
resolvePenetrationCoefficient,
|
||||||
type ShellDefinition,
|
type ShellDefinition,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
|
import { invalidate } from '@react-three/fiber';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
AdditiveBlending,
|
AdditiveBlending,
|
||||||
@@ -51,6 +52,7 @@ export function SpacedArmorSubExternal({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleShellChange(shell: ShellDefinition) {
|
function handleShellChange(shell: ShellDefinition) {
|
||||||
material.uniforms.penetration.value = shell.penetration.near;
|
material.uniforms.penetration.value = shell.penetration.near;
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
async function handleProtagonistEquipmentChange(
|
async function handleProtagonistEquipmentChange(
|
||||||
equipment: EquipmentMatrix,
|
equipment: EquipmentMatrix,
|
||||||
@@ -64,6 +66,8 @@ export function SpacedArmorSubExternal({
|
|||||||
material.uniforms.thickness.value = hasEnhancedArmor
|
material.uniforms.thickness.value = hasEnhancedArmor
|
||||||
? thickness * 1.03
|
? thickness * 1.03
|
||||||
: thickness;
|
: thickness;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
||||||
const duel = duelStore.getState();
|
const duel = duelStore.getState();
|
||||||
@@ -78,6 +82,8 @@ export function SpacedArmorSubExternal({
|
|||||||
material.uniforms.penetration.value =
|
material.uniforms.penetration.value =
|
||||||
penetration *
|
penetration *
|
||||||
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleShellChange(duelStore.getState().antagonist.shell);
|
handleShellChange(duelStore.getState().antagonist.shell);
|
||||||
|
|||||||
+7
@@ -3,6 +3,7 @@ import {
|
|||||||
resolvePenetrationCoefficient,
|
resolvePenetrationCoefficient,
|
||||||
type ShellDefinition,
|
type ShellDefinition,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
|
import { invalidate } from '@react-three/fiber';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
AdditiveBlending,
|
AdditiveBlending,
|
||||||
@@ -61,6 +62,8 @@ export function SpacedArmorSubSpaced({
|
|||||||
material.uniforms.normalization.value = degToRad(
|
material.uniforms.normalization.value = degToRad(
|
||||||
shell.normalization ?? 0,
|
shell.normalization ?? 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
async function handleProtagonistEquipmentChange(
|
async function handleProtagonistEquipmentChange(
|
||||||
equipment: EquipmentMatrix,
|
equipment: EquipmentMatrix,
|
||||||
@@ -74,6 +77,8 @@ export function SpacedArmorSubSpaced({
|
|||||||
material.uniforms.thickness.value = hasEnhancedArmor
|
material.uniforms.thickness.value = hasEnhancedArmor
|
||||||
? thickness * 1.03
|
? thickness * 1.03
|
||||||
: thickness;
|
: thickness;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
async function handleAntagonistEquipmentChange(equipment: EquipmentMatrix) {
|
||||||
const duel = duelStore.getState();
|
const duel = duelStore.getState();
|
||||||
@@ -88,6 +93,8 @@ export function SpacedArmorSubSpaced({
|
|||||||
material.uniforms.penetration.value =
|
material.uniforms.penetration.value =
|
||||||
penetration *
|
penetration *
|
||||||
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
resolvePenetrationCoefficient(hasCalibratedShells, shell.type);
|
||||||
|
|
||||||
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleShellChange(duelStore.getState().antagonist.shell);
|
handleShellChange(duelStore.getState().antagonist.shell);
|
||||||
|
|||||||
Reference in new issue
Block a user