Code Monkey home page Code Monkey logo

Comments (5)

fcor avatar fcor commented on June 12, 2024

Hi, I think you're right, that should be the reason. I had a similar issue implementing gestures on a multi marker app where I wanted to apply gestures to only one model/marker at once.

Instead of setting scale to "0 0 0" or "2 2 2" for displaying or not a single model, you could use visible="true" and visible="false". Here you cand find more information about it: https://aframe.io/docs/1.1.0/components/visible.html

The same way you enable/disable visibility based on which model is active or not, you can enable/disable gestures on a particular element/model using the enabled property. This way, you can ensure that gestures will only be applied to a specific element of your scene.

model1.setAttribute("gesture-handler", { enabled: false });
model2.setAttribute("gesture-handler", { enabled: true });

from arjs-gestures.

matijafumic avatar matijafumic commented on June 12, 2024

You are right. Thank you much. That's an easy fix

from arjs-gestures.

matijafumic avatar matijafumic commented on June 12, 2024

Final question. Can i reset my scale? I am using a box model on which I display the shoes. On tap, only the shoe changes, not the box. I then call box.setAttribute("scale", "2 2 2") and box.setAttribute("rotation", "0 0 0"); which temporarily changes the size. Then when i try to zoom into my model, box immediately switches to sizes previously put on with another shoe earlier in the app

from arjs-gestures.

fcor avatar fcor commented on June 12, 2024

Sounds like a bug. It would be great if you could share a working example to dig deeper :)

Could you try making the initial box size with width, height and depth? So your default box scale is 1 instead of 2? This way the scale would be only changed by the gesture handler. I think that could help to avoid weird behavior on initialScale in the meantime.

from arjs-gestures.

matijafumic avatar matijafumic commented on June 12, 2024

SOLVED:
All I needed to do is reset the scaleFactor in gestures.js every time a model is not visible. I just added this to the update method of gesture-handler

if(this.el.getAttribute("visible") === false){ this.el.object3D.scale.set(1, 1, 1); this.el.object3D.rotation.set(0, 0, 0); this.scaleFactor = 1; }

from arjs-gestures.

Related Issues (19)

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.