feat: more fluid

This commit is contained in:
tresabhi committed 2025-03-23 17:50:26 -05:00
1 parent 3b937a6f35
commit 80325aa3b2
3 files changed
+22 -29

No files matched your search

@@ -18,7 +18,7 @@ import {
type CSGGeometryRef, type CSGGeometryRef,
} from '@react-three/csg'; } from '@react-three/csg';
import { useGLTF } from '@react-three/drei'; import { useGLTF } from '@react-three/drei';
import { useEffect, useRef } from 'react'; import { Fragment, useEffect, useRef } from 'react';
import type { Mesh } from 'three'; import type { Mesh } from 'three';
import { import {
Color, Color,
@@ -118,7 +118,7 @@ export function DissectorSceneComponent({
opacity: 2 ** -1, opacity: 2 ** -1,
side: DoubleSide, side: DoubleSide,
color: moduleColor[armorPlate.type], color: moduleColor[armorPlate.type],
clippingPlanes: isModule ? undefined : [clippingPlane.current], clippingPlanes: isModule ? [] : [clippingPlane.current],
}), }),
); );
const outline = useRef<LineSegments>(null); const outline = useRef<LineSegments>(null);
@@ -137,7 +137,7 @@ export function DissectorSceneComponent({
opacity: 2 ** -6, opacity: 2 ** -6,
side: DoubleSide, side: DoubleSide,
color: moduleOutlineColor[armorPlate.type], color: moduleOutlineColor[armorPlate.type],
clippingPlanes: isModule ? undefined : [clippingPlaneInverse.current], clippingPlanes: isModule ? [] : [clippingPlaneInverse.current],
}), }),
); );
const worldPosition = new Vector3(); const worldPosition = new Vector3();
@@ -177,9 +177,13 @@ export function DissectorSceneComponent({
}; };
}, []); }, []);
if (isModule) { return (
return ( <Fragment key={props.key}>
<> <lineSegments ref={outline} material={outlineMaterial.current}>
<edgesGeometry args={[props.geometry, 45]} />
</lineSegments>
{isModule && (
<mesh <mesh
material={material.current} material={material.current}
ref={baseWrapper} ref={baseWrapper}
@@ -199,23 +203,14 @@ export function DissectorSceneComponent({
</group> </group>
</Geometry> </Geometry>
</mesh> </mesh>
)}
<lineSegments ref={outline} material={outlineMaterial.current}> {!isModule && (
<lineSegments material={outlineMaterialInverse.current}>
<edgesGeometry args={[props.geometry, 45]} /> <edgesGeometry args={[props.geometry, 45]} />
</lineSegments> </lineSegments>
</> )}
); </Fragment>
}
return (
<>
<lineSegments material={outlineMaterial.current}>
<edgesGeometry args={[props.geometry, 45]} />
</lineSegments>
<lineSegments material={outlineMaterialInverse.current}>
<edgesGeometry args={[props.geometry, 45]} />
</lineSegments>
</>
); );
}, },
}); });
@@ -227,10 +227,11 @@ export function SceneProps() {
dissectEvent.emit({ dissectEvent.emit({
rotation: rotation:
lastDissection.rotation + (4 * delta.current.x) / window.innerWidth, lastDissection.rotation +
// offset: 0, 2 * Math.PI * (delta.current.x / window.innerWidth),
offset: clamp( offset: clamp(
lastDissection.offset + (4 * delta.current.y) / window.innerHeight, lastDissection.offset +
GRID_SIZE * (delta.current.y / window.innerHeight),
-5, -5,
5, 5,
), ),
@@ -8,11 +8,10 @@ export function jsxTree(
mesh?: (mesh: Mesh, props: MeshProps) => ReactNode; mesh?: (mesh: Mesh, props: MeshProps) => ReactNode;
group?: (object3d: Object3D, props: Object3DProps) => ReactNode; group?: (object3d: Object3D, props: Object3DProps) => ReactNode;
}, },
key?: string,
): ReactNode { ): ReactNode {
if (node instanceof Mesh) { if (node instanceof Mesh) {
const props = { const props = {
key, key: node.uuid,
geometry: node.geometry, geometry: node.geometry,
material: node.material, material: node.material,
position: node.position, position: node.position,
@@ -23,13 +22,11 @@ export function jsxTree(
return mergers?.mesh ? mergers.mesh(node, props) : <mesh {...props} />; return mergers?.mesh ? mergers.mesh(node, props) : <mesh {...props} />;
} else if (node instanceof Object3D) { } else if (node instanceof Object3D) {
const props = { const props = {
key, key: node.uuid,
position: node.position, position: node.position,
rotation: node.rotation, rotation: node.rotation,
scale: node.scale, scale: node.scale,
children: node.children.map((child) => children: node.children.map((child) => jsxTree(child, mergers)),
jsxTree(child, mergers, child.uuid),
),
}; };
return mergers?.group ? mergers.group(node, props) : <group {...props} />; return mergers?.group ? mergers.group(node, props) : <group {...props} />;