WANNA UI
WANNA provides easy-to-customize pre-built UI for different 3D experiences. The set of available experiences depends on the product category:
- footwear - virtual try-on
- watches - virtual try-on
- handbags - 3D Viewer
This UI is delivered as React component to be used together with the WANNA SDK for Web, which provides the core experiences.
Install
-
Install wanna-sdk library
-
Install wanna-ui library (this library)
-
Add the following rules into your Webpack file:
module: {
rules: [
{
test: /wanna-sdk\/.*iframe.html$/,
loader: 'file-loader',
},
{
test: /wanna-sdk\/.*core.js$/,
loader: 'file-loader',
options: {
name: 'core.js',
},
},
...
],
}
If instead of Webpack you use Rollup JS, or something similar, you have to add some rules like that to add core.js and iframe.html files into your public folder and get iframe.html path to import it in the example below.
- Make sure that your babel.config has modules: 'umd', field in settings (not necessary but may trigger some problems)
Try out WANNA UI component
- Import WANNA SDK to your project from wanna-sdk library
- Import the iframe from wanna-sdk/iframe
- Import wanna-sdk/core
- Import the WannaUI component from wanna-ui. Below in this guide, the WannaUI name is used to refer to this component.
- Import the component styles import 'wanna-ui/lib/styles.css'
- Launch the component and pass the required parameters.
Important! The sets of parameters for Virtual try-on and 3D modes are different. See the descriptions below.
Example:
import wannaSdk from 'wanna-sdk'
import wannaSdkIframe from 'wanna-sdk/iframe'
import WannaUI from 'wanna-ui'
import 'wanna-ui/lib/styles.css'
import 'wanna-sdk/core'
const WrapperComponent = ({ models, license }) => (
<WannaUI
wannaSdk={wannaSdk}
iframeSrc={wannaSdkIframe}
models={models}
license={license}
/>
);
AR mode
For some categories, WANNA provides pre-built UI for virtual try-on.
To launch the UI you should run the component in AR mode using the mode={wannaSdk.MODE_TYPE_AR} prop. When launching the component requests camera access and then shows the video stream.
Notes:
Props footerLeftComponent, footerRightComponent aren't supported in the AR mode. The rest props from the Props list below are supported.
The models' list (models prop) supports only the following fields:
[
{
id: '<string>',
image: <IMAGE>,
brand: '<string>',
name: '<string>',
purchaseUrl: '<link for buy button>',
},
...
]
Example:
const WrapperComponent = ({ models, license }) => (
<WannaUI
wannaSdk={wannaSdk}
iframeSrc={wannaSdkIframe}
license={license}
mode={wannaSdk.MODE_TYPE_AR}
modelsType={wannaSdk.MODEL_TYPE_SNEAKER}
theme={wannaSdk.THEME_DARK}
models={
[
{
id: 'wanna01',
image: <Image />,
brand: 'WANNA Design',
name: 'Devana Fluorescent Lime',
purchaseUrl: 'https://wanna.fashion/',
},
{
id: 'wanna02',
image: <Image />,
brand: 'WANNA Design',
name: 'Svarog White',
},
]
}
/>
);
3D mode
For some categories, WANNA provides the 3D Viewer.
To launch the UI you should run the component in 3D mode using the mode={wannaSdk.MODE_TYPE_3D} prop. In comparison with the AR mode, the component will launch immediately without requesting camera access.
Installation
First, add both @wannaby/wanna-ui
and @wannaby/wanna-sdk
to your project dependencies:
yarn add @wannaby/wanna-ui @wannaby/wanna-sdk
Then import component and SDK and use them in your application:
import WannaUI from '@wannaby/wanna-ui';
import WannaSDK from '@wannaby/wanna-sdk';
const WrapperComponent = ({ license }) => (
<WannaUI
license={license}
mode={wannaSDK.MODE_TYPE_3D}
modelsType={wannaSDK.MODEL_TYPE_BAG}
models={
[
{
id: 'bag_model_id',
brand: 'Brand Name',
name: 'Model Name',
price: '$ 1,200',
pois: [
'',
'Here you can put the text that will be displayed for the 2nd POI',
'Here you can put the text that will be displayed for the 3nd POI',
],
},
]
}
/>
);
Notes
In this version, the 3D mode works only for bag models: modelsType={wannaSDK.MODEL_TYPE_BAG}
. Also, you need to pass mode={wannaSDK.MODE_TYPE_3D}
Only one model could be passed to the component. If you specify several models in the array, only the first one would be shown in the 3D Viewer. All props are supported.
The models' list (models prop) supports the following fields:
[
{
id: '<string>',
image: <IMAGE>,
name: '<string>',
price: '<string>',
pois: [<string>|<null>, ...],
},
...
]
Component props
The following Props are supported in the WannaUI component.
propTypes = {
wannaSdk: PropTypes.object.isRequired,
license: PropTypes.string.isRequired,
models: PropTypes.arrayOf(
PropTypes.shape({
brand: PropTypes.string,
id: PropTypes.string,
image: PropTypes.string,
name: PropTypes.string,
purchaseUrl: PropTypes.string,
})
).isRequired,
iframeSrc: PropTypes.string.isRequired,
theme: PropTypes.oneOf(['dark', 'light']),
mainColor: PropTypes.string,
logoUrl: PropTypes.string,
watermarkUrl: PropTypes.string,
brandImageUrl: PropTypes.string,
modelsType: PropTypes.oneOf(['sneakers', 'watch', 'bag']),
headerComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
footerLeftComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
footerRightComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
loadingComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
onError: PropTypes.func,
onCameraAccessRequested: PropTypes.func,
onCheckCameraPermissionsSuccess: PropTypes.func,
onCheckCameraPermissionsFail: PropTypes.func,
onFreezeOnCameraChange: PropTypes.func,
onPhotoSaved: PropTypes.func,
onPhotoShared: PropTypes.func,
onModelLoadingFail: PropTypes.func,
onModelLoadingSuccess: PropTypes.func,
onModelLoading: PropTypes.func,
onPhotoTaken: PropTypes.func,
onTryOn: PropTypes.func,
onHeaderBackClick: PropTypes.func,
onModel3dPoiChanged: PropTypes.func,
onModel3dResetView: PropTypes.func,
onModel3dShowReferences: PropTypes.func,
font: PropTypes.shape({
file: PropTypes.string.isRequired,
family: PropTypes.string.isRequired,
}),
mode: PropTypes.oneOf(['ar', '3d']),
viewMode: PropTypes.oneOf(['mobile', 'desktop']).isRequired,
dimensionsUnit: PropTypes.oneOf(['cm', 'inch']),
showOnboarding: PropTypes.bool,
labels: PropTypes.object,
}
WANNA gives you the full flexibility to customize the provided UI. You can use your own custom Header component passing it as render-prop in headerComponent prop. This component will be used in the WannaUI component, the Error screen, and the Rotate screen.
The Header component will get the following props:
propTypes = {
appWasInit: PropTypes.bool,
screenInteraction: PropTypes.bool,
brand: PropTypes.string,
name: PropTypes.string,
brandImageUrl: PropTypes.string,
modelId: PropTypes.string,
style: PropTypes.object,
mode: PropTypes.oneOf(['ar', '3d']),
viewMode: PropTypes.oneOf(['mobile', 'desktop']).isRequired,
onBack: PropTypes.func,
...rest - selected model params list. Gets from models list.
}
Loading component
To match your website better, you can use your own custom Loading component passing it as render-prop in loadingComponent prop. This component will be used in the Main component during the initialization and a model loading.
The Loading component will get the following props:
propTypes = {
children: PropTypes.node,
progress: PropTypes.number,
image: PropTypes.node,
loadingColor: PropTypes.string,
theme: PropTypes.oneOf([...THEME_TYPES]),
modelsType: PropTypes.string,
mode: PropTypes.oneOf(['ar', '3d']),
type: PropTypes.oneOf([
LOADING_TYPE_INIT,
LOADING_TYPE_MODEL,
LOADING_TYPE_MODE_CHANGE,
]),
}
You can fully customize the footer by using your own custom footer components and passing them as render-props in footerRightComponent, footerLeftComponent props. These components are used in the Main component footer when the component is initing and a model is loading.
The components will get the following props:
propTypes = {
viewMode: PropTypes.oneOf(['mobile', 'desktop']).isRequired,
screenInteraction: PropTypes.bool,
on3dReset: PropTypes.func.isRequired,
on3dZoomOut: PropTypes.func.isRequired,
on3dZoomIn: PropTypes.func.isRequired,
onToggleRefenences: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]),
model: PropTypes.object.isRequired,
activeShowReference: PropTypes.bool,
onboardingIsRunning: PropTypes.bool,
resetDisabled: PropTypes.bool,
}
Labels default values
{
"buyNow": "Buy now",
"cameraAccessRequired": "Camera access is required for virtual try-on",
"canHold": "Can hold",
"cantDownloadModel": "Can't download the model.",
"cantSharePhoto": "Can't share a photo.",
"cantTakePhoto": "Can't take a photo.",
"cantToggleDimensions": "Can't toggle model dimensions",
"cantZoomInTheModel": "Can't zoom in the model",
"cantZoomOutTheModel": "Can't zoom out the model",
"cantResetTheModel": "Can't reset the model",
"cantChangeTheModelViewpoint": "Can't change the model viewpoint",
"copyLink": "Copy link",
"copied": "Copied",
"copyFailure": "Can't copy, do it manually",
"doubleClickToFocus": "Double click to select focus point",
"doubleTapToFocus": "Double tap to select focus point",
"feet": "feet",
"forPhoto": "for photo",
"hand": "hand",
"generating": "Generating",
"initializingApp": "Initializing App...",
"noImage": "No image",
"noCameraDefault": "Check Camera permissions for you app in Settings. After that return to this page and press Reload Button.",
"noCameraWeChat": "Check Settings > WeChat > Camera and turn on the toggle. After that return to this page and press Reload Button.",
"noCameraFacebook": "Check Settings > Facebook > Camera and turn on the toggle. After that return to this page and press Reload Button.",
"noCameraInstagram": "Check Settings > Instagram > Camera and turn on the toggle. After that return to this page and press Reload Button.",
"noCameraChrome": "Check Settings > Chrome > Camera and turn on the toggle. After that return to this page and press Reload Button.",
"noCameraSafari": "Check Settings > Safari > Camera. And select ‘Ask’ or ‘Allow’. After that return to this page and press Reload Button.",
"loadingModel": "Loading model",
"pinchToZoom": "Pinch to zoom",
"pointTheCamera": "Point the camera at your",
"pleaseComeBackLater": "Please come back later",
"reload": "Reload",
"rotateThePhoneToTryOn": "Rotate the phone to try on",
"rotateThePhoneFor3d": "Rotate the phone to view in 3D",
"save": "Save",
"scanQrcode": "Scan QR-code to try on",
"share": "Share",
"sharingPhotoError": "Can't share a photo.",
"somethingWentWrong": "Something went wrong. But we’re working on it",
"starting3dViewer": "Starting 3D Viewer",
"tap": "Tap",
"toTryOnUse": "To try on use Safari on iOS and Chrome on Android",
"useSafariOrChrome": "Use Safari on iOS and Chrome on Android",
"useWiFiToTryOn": "Use a Wi-Fi network to start try-on faster",
"useWiFi": "Use a Wi-Fi network to start faster",
"modeChanging": "Changing mode"
}