Giter VIP home page Giter VIP logo

Comments (6)

vincentfretin avatar vincentfretin commented on June 3, 2024

I have no issue with the default example and [email protected]
Calling document.querySelector('[orbit-controls]').components["orbit-controls"].controls.reset() works correctly.
Your issue is probably in your project. Please provide a glitch if you want further help.
Be sure to use 1.3.2, previous versions didn't have this line:

this.controls.saveState();

from superframe.

Sincenir avatar Sincenir commented on June 3, 2024

I have no issue with the default example and [email protected] Calling document.querySelector('[orbit-controls]').components["orbit-controls"].controls.reset() works correctly. Your issue is probably in your project. Please provide a glitch if you want further help. Be sure to use 1.3.2, previous versions didn't have this line:

this.controls.saveState();

I use it.
image
image
image

The three pictures above are:

  • Start perspective
  • Moved perspective
  • Reset perspective

My code:

setInterval(() => {
document
	.querySelector('[orbit-controls]')
	.components['orbit-controls'].controls.reset();
}, 3000);

I tried writing a simple demo and had this problem.

<head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/1.5.0/aframe.min.js"></script>
  <script src="https://unpkg.com/[email protected]/dist/aframe-environment-component.min.js"></script>
  <script src="https://unpkg.com/[email protected]/dist/aframe-orbit-controls.min.js"></script>

  <script>
    setInterval(() => {
      document
        .querySelector("[orbit-controls]")
        .components["orbit-controls"].controls.reset();
    }, 3000);
  </script>
</head>

<body>
  <a-scene
    shadow="enabled: true;"
    physics
    cursor="rayOrigin: ''"
    embedded="{needEmbedded}"
    environment="preset: forest"
  >
    <a-box position="0 1 0" width="2" height="2" depth="2"></a-box>
    <a-camera
      id="camera"
      orbit-controls="autoRotate: false; target: 0 0 0; initialPosition:0 1 5; minDistance:5; maxDistance: 180; rotateSpeed: 0.5"
    />
  </a-scene>
</body>

from superframe.

vincentfretin avatar vincentfretin commented on June 3, 2024

You're the second person that use the a-camera primitive and having issues. You need to disable look-controls and wasd-controls that is auto added by the a-camera primitive or just use a-entity with camera, see my comments on #331 (comment)

from superframe.

Sincenir avatar Sincenir commented on June 3, 2024

You're the second person that use the a-camera primitive and having issues. You need to disable look-controls and wasd-controls that is auto added by the a-camera primitive or just use a-entity with camera, see my comments on #331 (comment)

Prefect, I have used a-entity in my projects before.

I solved the problem by look-controls=”enabled: false“ and wasd-controls="enabled: false" .

What is the reason ? Although I turned on wasd, but I didn't operate the keyboard. Can't we solve this problem by adding attributes to element in our orbit-controls?

This new code:

<a-entity
	id="camera"
	camera="fov: {fov}"
	look-controls="enabled: false"
	wasd-controls="enabled: false"
	orbit-controls="target: 0 0 0; minDistance: 2; maxDistance: 180; initialPosition: 0 0 -20; rotateSpeed: 0.5"></a-entity>

from superframe.

vincentfretin avatar vincentfretin commented on June 3, 2024

The issue is that look-controls and wasd-controls is moving the entity object3D (THREE.Group instance), orbit-controls is moving the camera object that is a child of the entity object3D. look-controls and orbit-controls are registering both handlers for mouse movement.

from superframe.

Sincenir avatar Sincenir commented on June 3, 2024

The issue is that look-controls and wasd-controls is moving the entity object3D (THREE.Group instance), orbit-controls is moving the camera object that is a child of the entity object3D. look-controls and orbit-controls are registering both handlers for mouse movement.

My idea is whenther in the orbit-controls component, the init method can push this.el.setAttr('look-controls', 'enabled: false') in the next eventloop to solve this problem.

This avoids the need for additional configuiration every time we use it. There is a certain conflict between our orbital camera and look controls and look-controls and wasd-controls .

Of course this is just an idea, I'm not sure if it can be implemented , I will try it during non-working hours.

I tried it and found that I can solve the problem by adding setAttr to init. See code commit above.

from superframe.

Related Issues (20)

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.