Skip to content

Commit

Permalink
Revert "Squashed commit of the following:"
Browse files Browse the repository at this point in the history
This reverts commit 465b481.
  • Loading branch information
Jarvv committed Sep 26, 2024
1 parent 465b481 commit c06ad60
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 90 deletions.
26 changes: 4 additions & 22 deletions src/components/Avatar/Avatar.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
SpawnState,
EffectConfiguration,
LightingProps,
AnimationConfiguration,
MaterialConfiguration
AnimationConfiguration
} from 'src/types';
import { BaseCanvas } from 'src/components/BaseCanvas';
import { AnimationModel, HalfBodyModel, StaticModel, PoseModel } from 'src/components/Models';
Expand Down Expand Up @@ -157,10 +156,6 @@ export interface AvatarProps extends LightingProps, EnvironmentProps, Omit<BaseM
animations?: Record<string, string>;
activeAnimation?: string;
animationConfig?: AnimationConfiguration;
/**
* Control properties of materials.
*/
materialConfig?: MaterialConfiguration;
}

/**
Expand Down Expand Up @@ -205,8 +200,7 @@ const Avatar: FC<AvatarProps> = ({
backLightPosition,
lightTarget,
fov = 50,
animationConfig,
materialConfig
animationConfig
}) => {
const setSpawnState = useSetAtom(spawnState);

Expand All @@ -230,7 +224,6 @@ const Avatar: FC<AvatarProps> = ({
onLoaded={onLoaded}
bloom={effects?.bloom}
animationConfig={animationConfig}
materialConfig={materialConfig}
/>
);
}
Expand All @@ -246,7 +239,6 @@ const Avatar: FC<AvatarProps> = ({
onLoaded={onLoaded}
headMovement={headMovement}
bloom={effects?.bloom}
materialConfig={materialConfig}
/>
);
}
Expand All @@ -261,7 +253,6 @@ const Avatar: FC<AvatarProps> = ({
onLoaded={onLoaded}
headMovement={headMovement}
bloom={effects?.bloom}
materialConfig={materialConfig}
/>
);
}
Expand All @@ -275,20 +266,12 @@ const Avatar: FC<AvatarProps> = ({
poseSrc={poseSrc!}
onLoaded={onLoaded}
bloom={effects?.bloom}
materialConfig={materialConfig}
/>
);
}

return (
<StaticModel
modelSrc={modelSrc}
scale={scale}
onLoaded={onLoaded}
emotion={emotion}
bloom={effects?.bloom}
materialConfig={materialConfig}
/>
<StaticModel modelSrc={modelSrc} scale={scale} onLoaded={onLoaded} emotion={emotion} bloom={effects?.bloom} />
);
}, [
modelSrc,
Expand All @@ -303,8 +286,7 @@ const Avatar: FC<AvatarProps> = ({
effects?.bloom,
idleRotation,
headMovement,
animationConfig,
materialConfig
animationConfig
]);

useEffect(() => triggerCallback(onLoading), [modelSrc, animationSrc, onLoading]);
Expand Down
1 change: 0 additions & 1 deletion src/components/Avatar/Avatar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ Static.args = {
color: 'rgb(9,20,26)'
},
style: {},
materialConfig: { emissiveIntensity: 3.3 },
/* eslint-disable no-console */
onLoaded: () => console.info('EVENT: static avatar loaded'),
onLoading: () => console.info('EVENT: loading static avatar'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export const AnimationModel: FC<AnimationModelProps> = ({
onLoaded,
headMovement = false,
emotion,
bloom,
materialConfig
bloom
}) => {
const ref = useRef<Group>(null);
const [animationRunning, setAnimationRunning] = useState(true);
Expand Down Expand Up @@ -85,7 +84,6 @@ export const AnimationModel: FC<AnimationModelProps> = ({
onLoaded={onLoaded}
onSpawnAnimationFinish={onSpawnAnimationFinish}
bloom={bloom}
materialConfig={materialConfig}
/>
);
};
14 changes: 2 additions & 12 deletions src/components/Models/HalfBodyModel/HalfBodyModel.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const HalfBodyModel: FC<HalfBodyModelProps> = ({
setModelFallback,
onLoaded,
headMovement = false,
bloom,
materialConfig
bloom
}) => {
const ref = useRef<Group>(null);
const { scene } = useGltfLoader(modelSrc);
Expand Down Expand Up @@ -64,14 +63,5 @@ export const HalfBodyModel: FC<HalfBodyModelProps> = ({
useEmotion(nodes, emotion);
useFallback(nodes, setModelFallback);

return (
<Model
modelRef={ref}
scene={scene}
scale={scale}
onLoaded={onLoaded}
bloom={bloom}
materialConfig={materialConfig}
/>
);
return <Model modelRef={ref} scene={scene} scale={scale} onLoaded={onLoaded} bloom={bloom} />;
};
12 changes: 2 additions & 10 deletions src/components/Models/Model/Model.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ interface ModelProps extends BaseModelProps {

const ROTATION_STEP = 0.005;

export const Model: FC<ModelProps> = ({
scene,
scale = 1,
modelRef,
onLoaded,
onSpawnAnimationFinish,
bloom,
materialConfig
}) => {
export const Model: FC<ModelProps> = ({ scene, scale = 1, modelRef, onLoaded, onSpawnAnimationFinish, bloom }) => {
const { materials } = useGraph(scene);
const { gl } = useThree();
const [isTouching, setIsTouching] = useState(false);
Expand Down Expand Up @@ -61,7 +53,7 @@ export const Model: FC<ModelProps> = ({
[isTouching, touchEvent, scene]
);

normaliseMaterialsConfig(materials, bloom, materialConfig);
normaliseMaterialsConfig(materials, bloom);
scene.traverse((object) => {
const node = object;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const MultipleAnimationModel: FC<MultipleAnimationModelProps> = ({
onLoaded,
emotion,
bloom,
animationConfig,
materialConfig
animationConfig
}) => {
const mixerRef = useRef<AnimationMixer | null>(null);
const activeActionRef = useRef<AnimationAction | null>(null);
Expand Down Expand Up @@ -104,5 +103,5 @@ export const MultipleAnimationModel: FC<MultipleAnimationModelProps> = ({
useIdleExpression('blink', nodes);
useFallback(nodes, setModelFallback);

return <Model scene={scene} scale={scale} onLoaded={onLoaded} bloom={bloom} materialConfig={materialConfig} />;
return <Model scene={scene} scale={scale} onLoaded={onLoaded} bloom={bloom} />;
};
14 changes: 2 additions & 12 deletions src/components/Models/PoseModel/PoseModel.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export const PoseModel: FC<PoseModelProps> = ({
emotion,
setModelFallback,
onLoaded,
bloom,
materialConfig
bloom
}) => {
const { scene } = useGltfLoader(modelSrc);
const { nodes } = useGraph(scene);
Expand All @@ -34,14 +33,5 @@ export const PoseModel: FC<PoseModelProps> = ({
useEmotion(nodes, emotion);
useFallback(nodes, setModelFallback);

return (
<Model
modelRef={modelRef}
scene={scene}
scale={scale}
onLoaded={onLoaded}
bloom={bloom}
materialConfig={materialConfig}
/>
);
return <Model modelRef={modelRef} scene={scene} scale={scale} onLoaded={onLoaded} bloom={bloom} />;
};
14 changes: 2 additions & 12 deletions src/components/Models/StaticModel/StaticModel.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,13 @@ export const StaticModel: FC<StaticModelProps> = ({
setModelFallback,
onLoaded,
emotion,
bloom,
materialConfig
bloom
}) => {
const { scene } = useGltfLoader(modelSrc);
const { nodes } = useGraph(scene);

useEmotion(nodes, emotion);
useFallback(nodes, setModelFallback);

return (
<Model
modelRef={modelRef}
scene={scene}
scale={scale}
onLoaded={onLoaded}
bloom={bloom}
materialConfig={materialConfig}
/>
);
return <Model modelRef={modelRef} scene={scene} scale={scale} onLoaded={onLoaded} bloom={bloom} />;
};
10 changes: 3 additions & 7 deletions src/services/Models.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type { ObjectMap, SkinnedMeshProps } from '@react-three/fiber';
import { GLTF, GLTFLoader, DRACOLoader } from 'three-stdlib';
import { suspend } from 'suspend-react';
import { Emotion } from 'src/components/Avatar/Avatar.component';
import { BloomConfiguration, MaterialConfiguration } from 'src/types';
import { BloomConfiguration } from 'src/types';
import { MeshoptDecoder } from './meshopt_decoder';

export interface CustomNode extends Object3D {
Expand Down Expand Up @@ -75,11 +75,7 @@ export const lerp = (start: number, end: number, time = 0.05): number => start *
/**
* Avoid texture pixelation and add depth effect.
*/
export const normaliseMaterialsConfig = (
materials: Record<string, Material>,
bloomConfig?: BloomConfiguration,
materialConfig?: MaterialConfiguration
) => {
export const normaliseMaterialsConfig = (materials: Record<string, Material>, bloomConfig?: BloomConfiguration) => {
Object.values(materials).forEach((material) => {
const mat = material as MeshStandardMaterial;
if (mat.map) {
Expand All @@ -92,7 +88,7 @@ export const normaliseMaterialsConfig = (
}

if (mat.emissiveMap) {
mat.emissiveIntensity = bloomConfig?.materialIntensity ?? materialConfig?.emissiveIntensity ?? 3.3;
mat.emissiveIntensity = bloomConfig?.materialIntensity || 3.3;
}
});
};
Expand Down
8 changes: 0 additions & 8 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export interface BaseModelProps {
onLoading?: () => void;
setModelFallback?: (fallback: JSX.Element) => void;
bloom?: BloomConfiguration;
materialConfig?: MaterialConfiguration;
}

export type HeadBlendShapeType =
Expand Down Expand Up @@ -187,10 +186,3 @@ export interface SpawnState {
loop?: number | null;
} | null;
}

export type MaterialConfiguration = {
/**
* Emissive material intensity.
*/
emissiveIntensity?: number;
};

0 comments on commit c06ad60

Please sign in to comment.