Code Monkey home page Code Monkey logo

Comments (5)

fcor avatar fcor commented on June 11, 2024

You could use the markerFound event to detect when the marker is visible and then read the world position of the model so you can place whatever you want in that position of the screen.

For easier handling, you will probably need two references of the model so you can initially show it on top of the marker and then hide it and show a different one in that world position.

Check out here how to use three.js in a-frame:

https://aframe.io/docs/1.2.0/introduction/developing-with-threejs.html

And here's how to get world position of a 3D object in three.js:

https://threejs.org/docs/#api/en/core/Object3D.getWorldPosition

from arjs-gestures.

hahaxiaowai avatar hahaxiaowai commented on June 11, 2024

Thanks for answering,I try first

from arjs-gestures.

hahaxiaowai avatar hahaxiaowai commented on June 11, 2024

oh , I finished,Thanks!

from arjs-gestures.

dirkk0 avatar dirkk0 commented on June 11, 2024

@hahaxiaowai could you share an example of how you achieved this?

from arjs-gestures.

hahaxiaowai avatar hahaxiaowai commented on June 11, 2024

@hahaxiaowai could you share an example of how you achieved this?

My way of implementation may not be what you want,I just add the model to it when the markerFound is triggered,Then change the model's rotate and scale accordingly when handleRotation and handleScale are triggered

this.el.sceneEl.addEventListener("markerFound", (e) => {
      this.isVisible = true;
      const scene = document.querySelector("a-scene").object3D;
      const loader = new THREE.GLTFLoader();

      loader.load("building.gltf",  (gltf)=> {
        const model = gltf.scene;
        model.position.set(0, 0, -10);
        model.scale.set(0.0005, 0.0005, 0.0005);
        model.traverse(function (child) {
          // if ( child.isMesh ) child.material.envMap = envMap;
        });
        this.model = model;
        scene.add(model);
      });
    });

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.