All Projects → rastapasta → React Native Gl Model View

rastapasta / React Native Gl Model View

Licence: mit
📺 Display and animate textured Wavefront .OBJ 3D models with 60fps - native bridge to GLView (iOS) and jPCT-AE (Android)

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to React Native Gl Model View

react-native-swipe-action-list
A list view that supports swipe actions for React Native (Android & iOS).
Stars: ✭ 18 (-94.25%)
Mutual labels:  react-native-component
react-native-boilerplate
React Native Boilerplate - React Native Starter Kits : react-navigation and its dependencies, redux, redux persist and redux thunk, redux toolkit, react native vector icons, react-native async storage
Stars: ✭ 68 (-78.27%)
Mutual labels:  react-native-component
ExploreRN
新版本RN项目,Base on 0.66.4,包含众多RN组件,先实践后使用,累积方案应对各种场景,后端地址:https://github.com/supervons/ExploreKoa
Stars: ✭ 112 (-64.22%)
Mutual labels:  react-native-component
react-native-bubble-tabbar
🧼 Bubble Tab Bar Component for React Native which supports React Navigation V5 and TypeScript
Stars: ✭ 43 (-86.26%)
Mutual labels:  react-native-component
react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-94.25%)
Mutual labels:  react-native-component
react-native-responsive-image-view
React Native component for scaling an Image within the parent View
Stars: ✭ 152 (-51.44%)
Mutual labels:  react-native-component
react-native-window-guard
SafeAreaView alternative for React Native which provides relevant window insets for both iOS and Android.
Stars: ✭ 30 (-90.42%)
Mutual labels:  react-native-component
React Native Maps Super Cluster
A Clustering-enabled map for React Native
Stars: ✭ 284 (-9.27%)
Mutual labels:  react-native-component
react-native-android-bottom-navigation
Native UI Component of Android's BottomNavigation for react-native
Stars: ✭ 18 (-94.25%)
Mutual labels:  react-native-component
monalisa-ui
MonalisaUI ✨ React Native UI Library
Stars: ✭ 37 (-88.18%)
Mutual labels:  react-native-component
react-native-touchable-safe
A single easy-to-use `<Touchable>` component, which harnesses the power of all React Native's `Touchable*` components.
Stars: ✭ 15 (-95.21%)
Mutual labels:  react-native-component
react-native-user-inactivity
Simple component that alerts when the user is inactive (i.e. when the App surface hasn't been touched for X ms)
Stars: ✭ 148 (-52.72%)
Mutual labels:  react-native-component
react-native-background-shapes
Beautiful backgrounds shapes to React Native based in flex (Android + IOS)
Stars: ✭ 65 (-79.23%)
Mutual labels:  react-native-component
react-native-masonry-brick-list
Staggered Or Masonary List View For React Native Written in pure js
Stars: ✭ 24 (-92.33%)
Mutual labels:  react-native-component
react-native-gesture-detector
Create and detect custom, complex gestures in React Native. 🍭
Stars: ✭ 75 (-76.04%)
Mutual labels:  react-native-component
react-native-card-list
A React Native component which displays a list of image cards that zoom to fullscreen
Stars: ✭ 19 (-93.93%)
Mutual labels:  react-native-component
react-native-category
react-native-category
Stars: ✭ 23 (-92.65%)
Mutual labels:  react-native-component
React Native Blur
React Native Blur component
Stars: ✭ 3,179 (+915.65%)
Mutual labels:  react-native-component
React Native Mentions
Mentions textbox for React Native. Works on both ios and android. 🐳
Stars: ✭ 277 (-11.5%)
Mutual labels:  react-native-component
react-native-bouncing-ball
react native component bouncing ball for iOS and Android
Stars: ✭ 36 (-88.5%)
Mutual labels:  react-native-component

react-native-gl-model-view

npm version license

A <ModelView> component for react-native, allowing you to display and animate any Wavefront .OBJ 3D object. Realized with a native bridge to GLView for iOS and a native bridge to jPCT-AE for Android.

Main features:

Getting started

Since React Native 0.60 and higher, autolinking makes the installation process much simpler.

$ yarn add react-native-gl-model-view

# Update your pods (iOS)
$ cd ios
$ pod install

Using React Native Link (React Native 0.59 and lower)

Run react-native link react-native-gl-model-view after which you should be able to use this library on iOS and Android.

iOS Manual installation

$ yarn add react-native-gl-model-view

Afterwards add following lines to your Podfile:

pod 'React', :path => '../node_modules/react-native'
pod 'RNGLModelView', :path => '../node_modules/react-native-gl-model-view'

Android Manual installation

$ yarn add react-native-gl-model-view

Afterwards, add the following lines to the android/settings.gradle file:

include ':react-native-gl-model-view'
project(':react-native-gl-model-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gl-model-view/android/app')

Finally, add the react-native-gl-model-view project as a dependency of the android/app/build.gradle file:

dependencies {
    compile project(':react-native-gl-model-view')
    ...
}

Usage

Model and texture loading

iOS

To load a model on iOS, you need to put the file at the root of your Xcode project via the editor.

Android

To load a model on Android, you need to place the model in the android/app/src/main/assets folder. Create a new folder if it doesn't exist yet.

Static

import ModelView from 'react-native-gl-model-view';

<ModelView
    model={{
      uri: 'model.obj',
    }}
    texture={{
      uri: 'texture.png',
    }}

    scale={0.01}

    translateZ={-2}
    rotateZ={270}

    style={{flex: 1}}
/>

Animated

Make the <ModelView>'s native props animatable by wrapping the Animated API around it:

import ModelView from 'react-native-gl-model-view';
import { Animated, Easing } from 'react-native';

const AnimatedModelView = Animated.createAnimatedComponent(ModelView);

As this usage of the Animated API is kinda hacky, you must call the private __makeNative() method on all Animated.Values before using Animated.multiply and such.

constructor() {
    this.state = {
        zoom: new Animated.Value(0),
        // ...
    };
    Object.keys(this.state).forEach(key =>
        this.state[key] instanceof Animated.Value &&
        this.state[key].__makeNative()
    );
}

Now you can apply all the Animated API magic to the <AnimatedModelView>'s props.

render() {
    <AnimatedModelView
        ...
        animate={true}
        translateZ={this.state.zoom}
    />
}
componentDidMount() {
    Animated.timing(this.state.zoom, {
        toValue: -2,
        useNativeDriver: true,
        duration: 2000,
        easing: Easing.bounce
    }).start();
}

Properties

Prop Default Type Description
model undefined object filename or URL of the model as uri
texture undefined object filename or URL of the texture as uri
tint {r: 1.0, g: 1.0, b: 1.0, a: 1.0} object Tints the texture or set the color of the model if there is no texture
animate false bool Model re-renders each 1/60s when set to true
flipTexture false bool The texture will be flipped vertically when set to true
scale 1 number Scale all axes of the model by given factor (overwrites scale*)
scaleX 1 number Scale X axis by given factor
scaleY 1 number Scale Y axis by given factor
scaleZ 1 number Scale Z axis by given factor
rotateX 0 number Rotate around X axis by given degree
rotateY 0 number Rotate around Y axis by given degree
rotateZ 0 number Rotate around Z axis by given degree
translateX 0 number Translate X position by given points
translateY 0 number Translate Y position by given points
translateZ 0 number Translate Z position by given points

Examples

Check out the example project:

To install the dependencies, switch into the example folder and set it up as following:

$ yarn

To build and run the app, set it up as following:

iOS

$ cd ios
$ pod install
$ cd ..
$ react-native run-ios

Android

$ react-native run-android

Special thanks

License

The MIT License (MIT)

Copyright (c) 2019 Michael Straßburger Copyright (c) 2019 The react-native-gl-model-view authors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].