mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
optimize scene lighting and rnederer
This commit is contained in:
1 parent
19f22993f1
commit
63a0143d4f
4 files changed
+11
-21
No files matched your search
+7
-9
@@ -8,17 +8,17 @@ import { Tankopedia } from "../../../../../../stores/tankopedia";
|
|||||||
import { TankopediaPersistent } from "../../../../../../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../../../../../stores/tankopediaPersistent";
|
||||||
import { HelpingSpotLight } from "../../../../../HelpingSpotLight";
|
import { HelpingSpotLight } from "../../../../../HelpingSpotLight";
|
||||||
|
|
||||||
const ANGLE = Math.PI * 2 ** -2;
|
const ANGLE = degToRad(10);
|
||||||
const REVEAL_ANIMATION_TIME = 3;
|
const REVEAL_ANIMATION_TIME = 3;
|
||||||
const TRANSITION_ANIMATION_TIME = 0.5;
|
const TRANSITION_ANIMATION_TIME = 0.5;
|
||||||
|
|
||||||
const LIGHTS_COUNT = 5;
|
const LIGHTS_COUNT = 4;
|
||||||
const THETA_OFFSET = degToRad(-152);
|
const THETA_OFFSET = degToRad(180 - 45);
|
||||||
const LIGHT_DISTANCE = 13;
|
const LIGHT_DISTANCE = 20;
|
||||||
const LIGHT_HEIGHT_0 = 4;
|
const LIGHT_HEIGHT_0 = 4;
|
||||||
const LIGHT_HEIGHT_1 = 2;
|
const LIGHT_HEIGHT_1 = 6;
|
||||||
const INTENSITY_0 = 3.5;
|
const INTENSITY_0 = 6;
|
||||||
const INTENSITY_1 = 1.5;
|
const INTENSITY_1 = 3;
|
||||||
const HEMISPHERE_INTENSITY = 2;
|
const HEMISPHERE_INTENSITY = 2;
|
||||||
|
|
||||||
export const transitionEvent = new Quicklime<number>(0);
|
export const transitionEvent = new Quicklime<number>(0);
|
||||||
@@ -115,8 +115,6 @@ function Animator({ stop, t0, animationTime, wrapper }: AnimatorProps) {
|
|||||||
const dt = performance.now() / 1e3 - t0.current;
|
const dt = performance.now() / 1e3 - t0.current;
|
||||||
const x = clamp(dt / animationTime.current, 0, 2);
|
const x = clamp(dt / animationTime.current, 0, 2);
|
||||||
|
|
||||||
console.log(x);
|
|
||||||
|
|
||||||
if (x === 2) {
|
if (x === 2) {
|
||||||
stop();
|
stop();
|
||||||
return;
|
return;
|
||||||
|
|||||||
+2
-10
@@ -1,10 +1,9 @@
|
|||||||
import { invalidate, useFrame } from "@react-three/fiber";
|
import { invalidate } from "@react-three/fiber";
|
||||||
import { clamp } from "lodash-es";
|
|
||||||
import { Quicklime, type QuicklimeEvent } from "quicklime";
|
import { Quicklime, type QuicklimeEvent } from "quicklime";
|
||||||
import { useEffect, useRef } from "react";
|
import { useEffect, useRef } from "react";
|
||||||
import { Mesh, MeshStandardMaterial } from "three";
|
import { Mesh, MeshStandardMaterial } from "three";
|
||||||
|
|
||||||
const SIZE = 2 ** 6;
|
const SIZE = 14;
|
||||||
|
|
||||||
export const screenshotReadyEvent = new Quicklime(false);
|
export const screenshotReadyEvent = new Quicklime(false);
|
||||||
|
|
||||||
@@ -12,11 +11,6 @@ export function SceneProps() {
|
|||||||
const mesh = useRef<Mesh>(null!);
|
const mesh = useRef<Mesh>(null!);
|
||||||
const material = useRef<MeshStandardMaterial>(null);
|
const material = useRef<MeshStandardMaterial>(null);
|
||||||
|
|
||||||
useFrame(({ camera }) => {
|
|
||||||
if (!material.current) return;
|
|
||||||
material.current.opacity = clamp(0.5 * camera.position.y, 0, 0.5);
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleScreenshotReady(event: QuicklimeEvent<boolean>) {
|
function handleScreenshotReady(event: QuicklimeEvent<boolean>) {
|
||||||
mesh.current.visible = !event.data;
|
mesh.current.visible = !event.data;
|
||||||
@@ -36,11 +30,9 @@ export function SceneProps() {
|
|||||||
receiveShadow
|
receiveShadow
|
||||||
visible={!screenshotReadyEvent.last!}
|
visible={!screenshotReadyEvent.last!}
|
||||||
ref={mesh}
|
ref={mesh}
|
||||||
renderOrder={-1}
|
|
||||||
>
|
>
|
||||||
<planeGeometry args={[SIZE, SIZE]} />
|
<planeGeometry args={[SIZE, SIZE]} />
|
||||||
<meshStandardMaterial
|
<meshStandardMaterial
|
||||||
transparent
|
|
||||||
ref={material}
|
ref={material}
|
||||||
color="black"
|
color="black"
|
||||||
roughness={1}
|
roughness={1}
|
||||||
|
|||||||
+1
-1
@@ -156,7 +156,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
|
|||||||
localClippingEnabled: true,
|
localClippingEnabled: true,
|
||||||
preserveDrawingBuffer: true,
|
preserveDrawingBuffer: true,
|
||||||
}}
|
}}
|
||||||
shadows="soft"
|
shadows="basic"
|
||||||
onPointerDown={handlePointerDown}
|
onPointerDown={handlePointerDown}
|
||||||
onPointerMissed={() => {
|
onPointerMissed={() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
|
|||||||
@@ -40,5 +40,5 @@ export const TankopediaPersistent = new Varuna<TankopediaPersistent>(
|
|||||||
direction: "ascending",
|
direction: "ascending",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"tankopedia-2"
|
"tankopedia-3",
|
||||||
);
|
);
|
||||||
Reference in new issue
Block a user