Git Product home page Git Product logo

expo-three-orbit-controls's Introduction

expo-three-orbit-controls

supports iOS supports Android supports web

This is a very rough port of Three.js OrbitControls for universal React apps with Expo.

  • Fully written in TypeScript because it's the best! ๐ŸŒŸ
  • Internally this uses a basic PanResponder for gestures. PRs to migrate PanResponder to React Native Gesture Handler are very welcome.
  • On web, two finger gestures aren't currently implemented.
  • On native, the camera may jump when panning + zooming ends due to issues with React Native PanResponder.

โ˜๏ธ Installation

yarn add expo-three-orbit-controls

๐Ÿš€ Usage

Import into your project:

import OrbitControlsView from 'expo-three-orbit-controls';

Check out the example for more info.

expo-three-orbit-controls's People

Contributors

evanbacon avatar igorroman777 avatar kif11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

expo-three-orbit-controls's Issues

Converting App.js to App.tsx and now the example doesn't work

So I tried implementing the example given with a blank typescript app on react native and got it to work!! However, when tried to implement the same code into my project that was made using javascript I changed the App.js file to be a App.tsx file but , it gives me the error shown in the picture.

image

Sometimes obj is disappear OR stop rotating.

<OrbitControlsView camera={this.camera}>
  <GLView
    style={style}
    onContextCreate={gl => this.onContextCreate(gl)}
  />
</OrbitControlsView>
async componentDidMount() {
    const selected = {
      type: 'obj',
      name: 'BloodCell',
      isometric: false,
      model: require('./models/blood/BloodCell.obj'),
      textures: [
        {
          name: 'axepCube3',
          image: require('./models/blood/BloodCell_BaseColor.png')
        }
      ]
    }

    this.model = await loadModel(selected)
    this.setState({isLoading: false})
  }
onContextCreate = async gl => {
    try {
      const {drawingBufferWidth: width, drawingBufferHeight: height} = gl
      const sceneColor = 'transparent'

      this.renderer = new Renderer({gl})
      this.renderer.setSize(width, height)

      this.camera = new PerspectiveCamera(75, width / height, 0.5, 1000)
      this.camera.position.set(0, 0, 10)

      this.scene = new Scene()

      this.pointLight = new PointLight(0xffffff, 2, 1000, 1)
      this.pointLight.position.set(0, 30, 100)

      const hemisphereLight = new HemisphereLight(0xffffbb, 0x080820, 1)
      this.scene.add(hemisphereLight)

      const ambientLight = new AmbientLight(0x404040) // soft white light
      this.scene.add(ambientLight)

      // center pivot
      const bbox = new Box3().setFromObject(this.model)
      const center = new Vector3()
      bbox.getCenter(center)
      this.model.position.sub(center)

      let models = []
      this.scene.add(this.model)
      models.push(this.model)

      this.setState({camera: this.camera})

      const render = () => {
        this.timeout = requestAnimationFrame(render)
        this.renderer.render(this.scene, this.camera)
        gl.endFrameEXP()
      }

      render()
    } catch (error) {
      console.log('error', error)
    }
  }

Can anyone please help me, i am not able to fix this.

Weekly Digest (23 January, 2020 - 30 January, 2020)

Here's the Weekly Digest for EvanBacon/expo-three-orbit-controls:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please ๐Ÿ‘€ Watch and โญ Star the repository EvanBacon/expo-three-orbit-controls to receive next weekly updates. ๐Ÿ˜ƒ

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. ๐Ÿ“†

WARN THREE.Quaternion: .inverse() has been renamed to invert().

I am using expo-three with three.js.
After updating three.js to 0.128 I get the warning:

WARN THREE.Quaternion: .inverse() has been renamed to invert().

But I have no line in my code with: .inverse()

OrbitControls uses e.g. the

var quatInverse = quat.clone().inverse();

Yes, without OrbitControlsView there is no warning!

Question: Only allow to orbit horizontally

Hey, thank you for your work on this library. It helps alot ๐Ÿ‘ .

I was wondering if you have an idea, how I can stop the camera from moving vertically and only allow to horizontally orbit the object?

Disable Zoom Function IOS

I've been developing a feature using this package and I've been testing primarily on Android where it works flawlessly. Recently another team member was testing on their IPhone and was able to do a pinch zoom which after hitting the center of the pivot point locked up the application. Anyone know if there's a prop to disable zoom?

How to add click "on press" event?

I want to add an on-press event together with rotate and zoom.

Can anyone please help me.

<OrbitControlsView camera={this.camera} onPress={this.onPress}>
  <GLView
    style={style}
    onContextCreate={gl => this.onContextCreate(gl)}
  />
</OrbitControlsView>

react-three-fiber + expo-three-orbit-controls example?

Hi! Is there even a way to make it work with the Canvas component that react-three-fiber is providing? I was trying to wrap Canvas with your component but it doesn't seem to work like that.

const ThreeCanvas = () => {
  const {assetsStore: { fetchAssets }} = useStore()
  const {camera} = useThree()
  
  useEffect(() => {
    fetchAssets()
  }, [])

return (
<OrbitControlsView style={{ flex: 1 }} camera={camera}>
    <Canvas
      shadowMap
      gl={{antialias: true, logarithmicDepthBuffer: true}}
    >
      <Camera position={[0, 30, 100]} far={50000}/>
      <ambientLight/>
      <spotLight intensity={0.3} position={[30, 30, 50]} angle={0.2} penumbra={1} castShadow/>
      <spotLight intensity={0.3} position={[-30, 30, 50]} angle={0.2} penumbra={1} castShadow/>
      <Sphere position={[2, 3, 0]} castShadow/>
      <Box castShadow/>
      <Skybox/>
      <Plane receiveShadow/>
    </Canvas>
</OrbitControlsView>
)}

Doesnt seem to work

When I try to implement this in my react native code, the orbit controls dont respond to touch

Zoom dont work

Hi, well i am trying to use the zoom whit two finger bunt not work

Weekly Digest (26 January, 2020 - 2 February, 2020)

Here's the Weekly Digest for EvanBacon/expo-three-orbit-controls:


ISSUES

Last week, no issues were created.


PULL REQUESTS

Last week, no pull requests were created, updated or merged.


COMMITS

Last week there were no commits.


CONTRIBUTORS

Last week there were no contributors.


STARGAZERS

Last week there were no stargazers.


RELEASES

Last week there were no releases.


That's all for last week, please ๐Ÿ‘€ Watch and โญ Star the repository EvanBacon/expo-three-orbit-controls to receive next weekly updates. ๐Ÿ˜ƒ

You can also view all Weekly Digests by clicking here.

Your Weekly Digest bot. ๐Ÿ“†

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.