Skip to content

Commit

Permalink
update for AR
Browse files Browse the repository at this point in the history
  • Loading branch information
loiclopez committed Nov 16, 2019
1 parent 2237bb6 commit 0a8446c
Show file tree
Hide file tree
Showing 16 changed files with 180 additions and 87 deletions.
Binary file added android/app/src/main/assets/custom/Arrow.vrx
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions android/link-assets-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,34 @@
"path": "app/theme/fonts/Montserrat-ThinItalic.ttf",
"sha1": "62dcb447998b27a83872d75439ce35124fe08aa7"
},
{
"path": "app/assets/3Dasset/Arrow.vrx",
"sha1": "3c0b14c9f82cd0a483294e362d86c65621ee9168"
},
{
"path": "app/assets/3Dasset/BBackground.png",
"sha1": "5726021f6512ffc43a565a9c8f8ac702cfc9013a"
},
{
"path": "app/assets/3Dasset/BBackgroundSpeed.png",
"sha1": "16fb3c49a51dc559b8c6c85617de124c612062d7"
},
{
"path": "app/assets/3Dasset/CheckPointWithAnim.vrx",
"sha1": "7e7ce08f8b6906922c7bed1d51801d99ab045ef1"
},
{
"path": "app/assets/3Dasset/IdleAndRun.vrx",
"sha1": "f86d95373f6b7fe5d3d6498f5b1a26fc907bd86e"
},
{
"path": "app/assets/3Dasset/IdleAndRunFastAndSlow.vrx",
"sha1": "84f9774f0988bd303a08ea872122cd7c2ae90177"
},
{
"path": "app/assets/3Dasset/RunningOnPlace.vrx",
"sha1": "e7811cf86e3becce23b29bbe72b04223c4324a16"
},
{
"path": "app/assets/fonts/FontAwesome5_Pro_Brands.ttf",
"sha1": "9b9fa983528cec8125e6dc8b65cf44e8ef6510f0"
Expand Down
147 changes: 74 additions & 73 deletions app/screens/augmented-reality-screen/augmented-reality-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ import { color } from "@theme"
import { action, observable } from "mobx"
import { observer } from "mobx-react"
import * as React from "react"
import { View, ViewStyle } from "react-native"
import { ViewStyle } from "react-native"
import { NavigationScreenProps } from "react-navigation"
import { ViroARScene, ViroConstants, ViroText, ViroAmbientLight,
Viro3DObject, ViroARCamera, ViroBox, ViroButton, ViroARPlaneSelector, ViroNode } from "react-viro"
import { TextInput } from "react-native-paper"
import {
ViroARScene, ViroConstants, ViroText, ViroAmbientLight,
Viro3DObject, ViroARCamera, ViroBox, ViroButton, ViroARPlaneSelector, ViroNode,
} from "react-viro"
import autobind from "autobind-decorator"

export interface IAugmentedRealityScreenProps extends NavigationScreenProps<{}> {
}

const Animation = require("../../assets/3Dasset/IdleAndRun.vrx");
const AnimationRun = require("../../assets/3Dasset/IdleAndRunFastAndSlow.vrx");
const Arrow = require("../../assets/3Dasset/Arrow.vrx");
const CheckPoint = require("../../assets/3Dasset/CheckPointWithAnim.vrx");
import { noop } from "lodash-es"

const ROOT: ViewStyle = {
backgroundColor: color.background
}
Expand All @@ -25,22 +24,18 @@ const ROOT: ViewStyle = {
*/
@observer
export class AugmentedRealityScreen extends React.Component<IAugmentedRealityScreenProps> {
@observable private Active = true

@observable private AnimationName = "Idle"
@observable private Speed = "RunFast";
@observable private text = "Initializing AR..."
@observable private Active = true

@action.bound
private AdaptSpeed(scrollPosition: any, source: any): void {
// tslint:disable-next-line:prefer-function-over-method
private AdaptSpeed(scrollPosition: number[], source: number[]): void {
console.log(scrollPosition[0] + scrollPosition[1]);
}

@action.bound
private switchModel(): void {
this.Active = !this.Active;
}

@action.bound
private onInitialized(state: string, reason: string): void {
if (state === ViroConstants.TRACKING_NORMAL) {
Expand All @@ -49,63 +44,62 @@ export class AugmentedRealityScreen extends React.Component<IAugmentedRealityScr
}
}

@action.bound
private SwitchAnimation(): void {
if (this.AnimationName === "Idle") {
this.AnimationName = this.Speed;
} else {
this.AnimationName = "Idle";
}
}
@action.bound
private switchSpeed() : void {
if (this.Speed === "RunFast") {
this.Speed = "RunSlow";
if (this.AnimationName !== "Idle") {
this.AnimationName = this.Speed;
}
}
else if (this.Speed === "RunSlow") {
this.Speed = "RunFast";
if (this.AnimationName !== "Idle") {
this.AnimationName = this.Speed;
}
}
private setButton() : any {
return(
<ViroARCamera>
<ViroButton
source={require("../../assets/3Dasset/BBackground.png")}
position={[-2, -4, -10]}
height={1}
width={1.5}
onClick={this.switchModel}
/>
<ViroButton
source={require("../../assets/3Dasset/BBackgroundSpeed.png")}
position={[2, -4, -10]}
height={1}
width={1.5}
onClick={this.switchSpeed}
/>
</ViroARCamera>
)
}

private setRunner() : any {
if (!this.Active) {
private setCheckpoint(): React.ReactNode {
if (this.Active) {
return(
<ViroNode position={[0, -1, -1]} dragType="FixedToPlane" onDrag={( )=>{}} >
<ViroNode position={[0, -1, -1]} dragType="FixedToPlane" onDrag={noop} >
<Viro3DObject
source={AnimationRun}
source={require("../../assets/3Dasset/CheckPointWithAnim.vrx")}
highAccuracyEvents
position={[0, -0.8, -3]}
scale={[0.009, 0.009, 0.009]}
rotation={[0, 180, 0]}
position={[0, 0.5, 0]}
scale={[0.02, 0.02, 0.02]}
type="VRX"
onClick={this.SwitchAnimation}
animation={{name: this.AnimationName,
animation={{name: "Take 001",
run: true,
loop: true,
interruptible: true}}
/>
</ViroNode>
)
}

return null
}

private setCheckpoint() : any {
if (this.Active) {
private setRunner() : any {
if (!this.Active) {
return(
<ViroNode position={[0, -1, -1]} dragType="FixedToPlane" onDrag={( )=>{}} >
<ViroNode position={[0, -1, -1]} dragType="FixedToPlane" onDrag={noop} >
<Viro3DObject
source={CheckPoint}
source={require("../../assets/3Dasset/IdleAndRunFastAndSlow.vrx")}
highAccuracyEvents
position={[0, 0.5, 0]}
scale={[0.02, 0.02, 0.02]}
position={[0, -0.8, -3]}
scale={[0.009, 0.009, 0.009]}
rotation={[0, 180, 0]}
type="VRX"
animation={{name: "Take 001",
onClick={this.SwitchAnimation}
animation={{name: this.AnimationName,
run: true,
loop: true,
interruptible: true}}
Expand All @@ -115,29 +109,36 @@ export class AugmentedRealityScreen extends React.Component<IAugmentedRealityScr
}
}

private setButton() : any {
return(
<ViroARCamera>
<ViroButton
source={require("../../assets/3Dasset/BBackground.png")}
position={[-2, -4, -10]}
height={1}
width={1.5}
onClick={this.switchModel}
/>
<ViroButton
source={require("../../assets/3Dasset/BBackgroundSpeed.png")}
position={[2, -4, -10]}
height={1}
width={1.5}
onClick={this.switchSpeed}
/>
</ViroARCamera>
)
@action.bound
private SwitchAnimation(): void {
// tslint:disable-next-line:prefer-conditional-expression
if (this.AnimationName === "Idle") {
this.AnimationName = this.Speed;
} else {
this.AnimationName = "Idle";
}
}

@action.bound
private switchModel(): void {
this.Active = !this.Active;
}
@action.bound
private switchSpeed() : void {
if (this.Speed === "RunFast") {
this.Speed = "RunSlow";
if (this.AnimationName !== "Idle") {
this.AnimationName = this.Speed;
}
} else if (this.Speed === "RunSlow") {
this.Speed = "RunFast";
if (this.AnimationName !== "Idle") {
this.AnimationName = this.Speed;
}
}
}

public render(): React.ReactNode {
const { text } = this

return (
<ViroARScene style={ROOT} onTrackingUpdated={this.onInitialized}>
Expand Down
16 changes: 11 additions & 5 deletions app/screens/user-profile-screen/user-profile-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Button, Screen, Text } from "@components"
import { color, spacing } from "@theme"
import { NavigationScreenProps } from "react-navigation"
import { NavigationBackButtonWithNestedStackNavigator } from "@navigation/components"
import { IPersonalTokens, IPost, IUser } from "@services/api"
import { HttpResponse, IPersonalTokens, IPost, IUser } from "@services/api"
import { Avatar, DefaultRnpAvatarSize } from "@components/avatar"
import { palette } from "@theme/palette"
import { headerShadow } from "@utils/shadows"
Expand All @@ -23,8 +23,8 @@ import { FontawesomeIcon } from "@components/fontawesome-icon"
import { IFollowScreenNavigationScreenProps } from "@screens/follow-screen"
import { FAB, PartialIconProps } from "react-native-paper"
import moment from "moment"
import { IBoolFunction, IVoidFunction } from "@custom-types"
import { noop } from "lodash-es"
import { IVoidFunction } from "@custom-types"
import { isEmpty, noop } from "lodash-es"

// tslint:disable:id-length

Expand Down Expand Up @@ -195,6 +195,7 @@ export class UserProfileScreenImpl extends React.Component<IPersonalProfileScree
constructor(props: IPersonalProfileScreenProps) {
super(props)
this.userProfile = props.navigation.getParam("me") ? props.userModel : props.navigation.getParam("user")
console.tron.logImportant(this.userProfile)
const pictureToken = props.navigation.getParam("pictureToken")
if (pictureToken) {
this.avatarUrl = props.api.buildAvatarUrl(this.userProfile.id, pictureToken)
Expand Down Expand Up @@ -381,7 +382,7 @@ export class UserProfileScreenImpl extends React.Component<IPersonalProfileScree
private async toggleFollow(): Promise<void> {
const { api } = this.props
if (this.isUserFollowedByVisitor) {
await api.delete(`user/me/follows/${this.userProfile.follow.follow_id}`)
await api.delete(`user/me/follows/${this.userProfile.follow.id}`).catch(noop)
this.userPosts = []
} else {
const followResponse: ApiResponse<IUser["follow"]> = await api.post(`user/${this.userProfile.id}/follows`)
Expand Down Expand Up @@ -421,7 +422,12 @@ export class UserProfileScreenImpl extends React.Component<IPersonalProfileScree
if (user) {
const userProfileRequest: ApiResponse<IUser> = await api.get(`user/${user.id}/profile`)
this.userProfile = { ...userProfileRequest.data, nick_name: this.userProfile.nick_name }
this.isUserFollowedByVisitor = userProfileRequest.data.follow.status
const followResponse: ApiResponse<any> = await api.get(`user/${user.id}/follows`).catch(noop)
if (!isEmpty(followResponse.data)) {
console.tron.logImportant(followResponse.data)
this.userProfile.follow = followResponse.data;
}
this.isUserFollowedByVisitor = followResponse.status === HttpResponse.OK;
}

await this.fetchPosts().catch(noop)
Expand Down
1 change: 1 addition & 0 deletions app/services/asset/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export enum FileExtension {
PNG = "png",
JPG = "jpg",
JSON = "json",
VRX = "vrx"
}

/**
Expand Down
29 changes: 28 additions & 1 deletion ios/ExoRun.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
};
objectVersion = 46;
objects = {

/* Begin PBXBuildFile section */
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
Expand Down Expand Up @@ -39,6 +38,13 @@
E1AEDCA242584DBBBC2B4552 /* FontAwesome5_Pro_Solid.ttf in Resources */ = {isa = PBXBuildFile; fileRef = FB52629DAF0F4C5EA2F73B2F /* FontAwesome5_Pro_Solid.ttf */; };
E4A6AA9B2C7346F3B80E44DC /* Montserrat-ExtraLightItalic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = B837E49A7A0445D486A281F3 /* Montserrat-ExtraLightItalic.ttf */; };
E4EB15E435C34271A063014C /* Montserrat-Italic.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 0B00BFB64D2145AC8166FED6 /* Montserrat-Italic.ttf */; };
04D71DA036BA4C8097A9163B /* Arrow.vrx in Resources */ = {isa = PBXBuildFile; fileRef = FAC165AA79E849B29B0BF574 /* Arrow.vrx */; };
E2CFADF2BE904B73AA5BA209 /* BBackground.png in Resources */ = {isa = PBXBuildFile; fileRef = 49933227579143E2A47D567F /* BBackground.png */; };
77E9501B22F242299AF75EB5 /* BBackgroundSpeed.png in Resources */ = {isa = PBXBuildFile; fileRef = 7452C7E289B74D89ACA4BC3D /* BBackgroundSpeed.png */; };
03A8B60F75C04B2687E52740 /* CheckPointWithAnim.vrx in Resources */ = {isa = PBXBuildFile; fileRef = FB84400053C3432F86FF62DE /* CheckPointWithAnim.vrx */; };
730C19DAB9AA4035953129BC /* IdleAndRun.vrx in Resources */ = {isa = PBXBuildFile; fileRef = D56F0EC60193451892598284 /* IdleAndRun.vrx */; };
B80B601518634A42A36D5C67 /* IdleAndRunFastAndSlow.vrx in Resources */ = {isa = PBXBuildFile; fileRef = 86CFF981E27043CA83044A53 /* IdleAndRunFastAndSlow.vrx */; };
1E4AB9B6A3894A2599D6758A /* RunningOnPlace.vrx in Resources */ = {isa = PBXBuildFile; fileRef = 8A5BF7AD9B09449391ED2F46 /* RunningOnPlace.vrx */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -92,6 +98,13 @@
E84CDE90AC4C4F609F3E2222 /* Montserrat-ThinItalic.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Montserrat-ThinItalic.ttf"; path = "../app/theme/fonts/Montserrat-ThinItalic.ttf"; sourceTree = "<group>"; };
ED2F190971234B8DAE0340A1 /* Montserrat-BlackItalic.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = "Montserrat-BlackItalic.ttf"; path = "../app/theme/fonts/Montserrat-BlackItalic.ttf"; sourceTree = "<group>"; };
FB52629DAF0F4C5EA2F73B2F /* FontAwesome5_Pro_Solid.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = FontAwesome5_Pro_Solid.ttf; path = ../app/assets/fonts/FontAwesome5_Pro_Solid.ttf; sourceTree = "<group>"; };
FAC165AA79E849B29B0BF574 /* Arrow.vrx */ = {isa = PBXFileReference; name = "Arrow.vrx"; path = "../app/assets/3Dasset/Arrow.vrx"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
49933227579143E2A47D567F /* BBackground.png */ = {isa = PBXFileReference; name = "BBackground.png"; path = "../app/assets/3Dasset/BBackground.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
7452C7E289B74D89ACA4BC3D /* BBackgroundSpeed.png */ = {isa = PBXFileReference; name = "BBackgroundSpeed.png"; path = "../app/assets/3Dasset/BBackgroundSpeed.png"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
FB84400053C3432F86FF62DE /* CheckPointWithAnim.vrx */ = {isa = PBXFileReference; name = "CheckPointWithAnim.vrx"; path = "../app/assets/3Dasset/CheckPointWithAnim.vrx"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
D56F0EC60193451892598284 /* IdleAndRun.vrx */ = {isa = PBXFileReference; name = "IdleAndRun.vrx"; path = "../app/assets/3Dasset/IdleAndRun.vrx"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
86CFF981E27043CA83044A53 /* IdleAndRunFastAndSlow.vrx */ = {isa = PBXFileReference; name = "IdleAndRunFastAndSlow.vrx"; path = "../app/assets/3Dasset/IdleAndRunFastAndSlow.vrx"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
8A5BF7AD9B09449391ED2F46 /* RunningOnPlace.vrx */ = {isa = PBXFileReference; name = "RunningOnPlace.vrx"; path = "../app/assets/3Dasset/RunningOnPlace.vrx"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = unknown; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -162,6 +175,13 @@
4FA04FF809CA4C38B41B1097 /* exorun-text.png */,
3E87F2F4C4A245819BCFDCC5 /* exosuite-loader.png */,
D03CD94E7C48410EB6FEA959 /* exosuite-logo.png */,
FAC165AA79E849B29B0BF574 /* Arrow.vrx */,
49933227579143E2A47D567F /* BBackground.png */,
7452C7E289B74D89ACA4BC3D /* BBackgroundSpeed.png */,
FB84400053C3432F86FF62DE /* CheckPointWithAnim.vrx */,
D56F0EC60193451892598284 /* IdleAndRun.vrx */,
86CFF981E27043CA83044A53 /* IdleAndRunFastAndSlow.vrx */,
8A5BF7AD9B09449391ED2F46 /* RunningOnPlace.vrx */,
);
name = Resources;
sourceTree = "<group>";
Expand Down Expand Up @@ -321,6 +341,13 @@
229D3A83010544D4ADC2777A /* exorun-text.png in Resources */,
3ABE4FB36A55469AABEC2CFD /* exosuite-loader.png in Resources */,
155A67FD15B44150A8806B0D /* exosuite-logo.png in Resources */,
04D71DA036BA4C8097A9163B /* Arrow.vrx in Resources */,
E2CFADF2BE904B73AA5BA209 /* BBackground.png in Resources */,
77E9501B22F242299AF75EB5 /* BBackgroundSpeed.png in Resources */,
03A8B60F75C04B2687E52740 /* CheckPointWithAnim.vrx in Resources */,
730C19DAB9AA4035953129BC /* IdleAndRun.vrx in Resources */,
B80B601518634A42A36D5C67 /* IdleAndRunFastAndSlow.vrx in Resources */,
1E4AB9B6A3894A2599D6758A /* RunningOnPlace.vrx in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Loading

0 comments on commit 0a8446c

Please sign in to comment.