question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Thanks for a really good and extendable repository. I have a question. I have created a custom GridSystem that extends the VglObject3D. It works as expected. Now I would like to add OrbitControls. How would you do it? So far I have created a new vue component that import THREE.OrbitControls. But how would you instantiate the OrbitControls component with a camera attached?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
notchriscommented, May 22, 2020

@fraguada I was able to solve it by doing this:

Vue.component('OrbitControls', {
  inject: ['vglNamespace'],
  props: ['camera'],
  computed: {
    cmr () {
      return this.vglNamespace.cameras.hash.c
    }
  },
  watch: {
    cmr: {
      handler(cmr) {
      	Vue.nextTick(() => {
           const controls = new OrbitControls(cmr, this.$parent.$el)
           controls.addEventListener('change', () => {
             this.$parent.requestRender()
           })
        })
      },
      immediate: true,
    }
  },
  render(h) {
    return h('div');
  },
});

jsfiddle

1reaction
fraguadacommented, May 25, 2020

Thanks @notchris. That did it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

OrbitControls – three.js docs
Orbit controls allow the camera to orbit around a target. To use this, as with all files in the /examples directory, you will...
Read more >
Orbit Controls - Three.js Tutorials - sbcode.net
Description. Orbit controls allow the camera to orbit around a target. <> ...
Read more >
What are OrbitControls in three.js? - Educative.io
The three.js library in JavaScript uses WebGL to render animations on the web. We use OrbitControls to make the camera orbit a target....
Read more >
three-orbit-controls | Yarn - Package Manager
Fast, reliable, and secure dependency management.
Read more >
OrbitControls not working with Loading file - Stack Overflow
OrbitControls is not directly exported as part of the Three.js library; instead it's exported as part of the examples .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found