Skip to content

Commit

Permalink
Add onboarding demo animation
Browse files Browse the repository at this point in the history
  • Loading branch information
KilianBoute committed Jul 12, 2024
1 parent a310fbc commit 5ca32e3
Show file tree
Hide file tree
Showing 9 changed files with 727 additions and 13 deletions.
1 change: 1 addition & 0 deletions ui/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module '*.glb'
20 changes: 17 additions & 3 deletions ui/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@


/** @type {import('next').NextConfig} */
const nextConfig = {
// basePath: "/facial-access-control", <==== required for github pages only.
output: "standalone",
output: "standalone",
webpack(config) {
config.module.rules.push({
test: /\.(glb|gltf)$/,
use: [
{
loader: 'file-loader',
options: {
publicPath: '/_next/static/models/',
outputPath: 'static/models/',
name: '[name].[ext]',
},
},
],
});
return config;
},
};

export default nextConfig;
6 changes: 6 additions & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
},
"dependencies": {
"@hookform/resolvers": "^3.5.0",
"@react-three/drei": "^9.108.3",
"@react-three/fiber": "^8.16.8",
"@reduxjs/toolkit": "^2.2.5",
"@testing-library/jest-dom": "^6.4.6",
"@types/crypto-js": "^4.2.2",
"@types/three": "^0.166.0",
"@uug-ai/ui": "^1.0.39",
"autoprefixer": "^10.4.19",
"base-64": "^1.0.0",
"cookies-next": "^4.2.1",
"crypto-js": "^4.2.0",
"drei": "^2.2.21",
"file-loader": "^6.2.0",
"next": "14",
"next-auth": "^4.24.7",
"next-router-mock": "^0.9.13",
Expand All @@ -34,6 +39,7 @@
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^3.1.0",
"tailwindcss": "^3.4.3",
"three": "^0.166.1",
"ts-jest": "^29.1.4",
"ts-node": "^10.9.2",
"zod": "^3.23.8"
Expand Down
20 changes: 20 additions & 0 deletions ui/src/app/onboarding/components/FacescanCanvas.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React, { Suspense } from 'react'
import { Canvas } from '@react-three/fiber'
import {Head} from '@/models/Head.jsx'
import { Box, Button } from '@/components/ui'

const FacescanCanvas = () => {
return (
<Box className='grow flex p-8 flex-col justify-center align-center w-full' id="canvas-container">
<Canvas className='' camera={{ near: 0.1, far: 1000, position: [0, 0, 10] }}>
<Suspense fallback={null}>
<directionalLight position={[0, 0, 5]} color="white" />
<Head />
</Suspense>
</Canvas>
<Button variant='light' colorscheme='secondary' className='mx-8'>Start recording</Button>
</Box>
)
}

export default FacescanCanvas
50 changes: 50 additions & 0 deletions ui/src/app/onboarding/components/OnboardingForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Button, Input, Password, Row, Stack, Text } from '@/components/ui'
import { Box } from '@react-three/drei'
import React from 'react'

const OnboardingForm = () => {
return (
<form className='w-full h-full'>
<Stack className='gap-4 grow-0'>
<Row className='gap-4'>
<Stack>
<Text as='label' htmlFor="firstname">First Name</Text>
<Input type="text" id="firstname" name="firstname" placeholder='first name' required/>
</Stack>
<Stack>
<Text as='label' htmlFor='lastname'>Last Name</Text>
<Input type='text' id='lastname' name='lastname' placeholder='last name' required/>
</Stack>
</Row>
<Row>
<Stack className='w-full'>
<Text as='label' htmlFor='email'>Email</Text>
<Input
type="text"
name="email"
id="email"
placeholder="email"
required
/>
</Stack>
</Row>
<Stack>
<Text as='label' htmlFor='password'>Password</Text>
<Password
name="password"
id="password"
placeholder="password"
required
/>
</Stack>
<div className='border-2'><Text as='p'>No recording added yet</Text></div>
<Button type="submit" name="Sign in" variant="solid" width='full' className='place-self-end'>
Submit
</Button>
</Stack>

</form>
)
}

export default OnboardingForm
14 changes: 12 additions & 2 deletions ui/src/app/onboarding/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use client';

import { Row, Box, Stack, Text, Input, Password, VideoCapture, Button, Icon, Socials, Logo } from '@/components/ui'
import React from 'react'
import FacescanCanvas from './components/FacescanCanvas'
import OnboardingForm from './components/OnboardingForm';

const Onboarding = () => {
return (
Expand All @@ -11,6 +15,9 @@ const Onboarding = () => {
Please enter your information and record a short video so we can get you up and running in no time!
</Text>
<Text as='p' size='md' color='light' className='mb-4'>
Look directly at the camera. Then, slowly tilt your head to the left and right as demonstrated in the illustration below.
</Text>
<Text as='p' size='md' color='light' className='mb-4'>
For more information, visit &nbsp;
<Text
as="a"
Expand All @@ -21,10 +28,13 @@ const Onboarding = () => {
uug.ai.
</Text>
</Text>
<OnboardingForm/>

</Stack>
<Stack className='bg-primary-900 p-8 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-blue-900 via-primary-900 to-primary-950'>

<Stack className='bg-primary-900 gap-8 p-8 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-blue-900 via-primary-900 to-primary-950'>
<Logo color="white" className='place-self-end'/>
<Box className='grow'/>
<FacescanCanvas/>
<Socials color="secondary" className='place-self-center justify-self-end'/>
</Stack>
</Row>
Expand Down
Binary file added ui/src/assets/3d/chmil_mannequin_bust_2024.glb
Binary file not shown.
44 changes: 44 additions & 0 deletions ui/src/models/Head.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
Author: CHMIL Studio (https://sketchfab.com/chmilstudio)
License: CC-BY-4.0 (http://creativecommons.org/licenses/by/4.0/)
Source: https://sketchfab.com/3d-models/chmil-mannequin-bust-2024-d5606415cb9e44009b562942b23e943f
Title: CHMIL Mannequin Bust 2024
*/

import React, { useRef } from 'react'
import { useGLTF } from '@react-three/drei'
import model from '../assets/3d/chmil_mannequin_bust_2024.glb'
import { useFrame } from '@react-three/fiber';

export function Head(props) {
const headRef = useRef();
const { nodes, materials } = useGLTF(model)

useFrame(({ clock }) => {
if (headRef.current) {
// Calculate rotation angle using sine wave
let angle = Math.sin(clock.getElapsedTime()) * Math.PI / 2; // Adjust the amplitude as needed

// Clamp rotation angle to be within -90 degrees to 90 degrees
headRef.current.rotation.y = Math.max(-Math.PI / 2.5, Math.min(angle, Math.PI / 2.5));
}
});

return (
<group ref={headRef} {...props} dispose={null}>
<group rotation={[-Math.PI / 2, 0, 0]}>
<mesh
castShadow
receiveShadow
geometry={nodes.final_for_upload_final_for_upload0_0.geometry}
material={materials.final_for_upload0}
rotation={[Math.PI / 2, 0, 0]}
scale={0.1}
/>
</group>
</group>
)
}

useGLTF.preload(model)
Loading

0 comments on commit 5ca32e3

Please sign in to comment.