hiukim / mind-ar-js

Web Augmented Reality. Image Tracking, Face Tracking. Tensorflow.js
MIT License
2.22k stars 415 forks source link

Usage of your own THREE Renderer, Camera and Scene #260

Closed FireDragonGameStudio closed 1 year ago

FireDragonGameStudio commented 2 years ago

Hi, is it possible to link my own scene, camera and renderer to MindAR, if I already have three.js in my project? I tried to init my MindARThree like this

const mindarThree = new MINDAR.IMAGE.MindARThree({
    container: document.querySelector("#container"),
    imageTargetSrc: "https://cdn.jsdelivr.net/npm/mind-ar@1.1.5/examples/image-tracking/assets/card-example/card.mind",
    renderer: myRenderer,
    scene: myScene,
    camera: myMainCamera
});

const anchor = mindarThree.addAnchor(0);
const geometry = new THREE.PlaneGeometry(1, 0.55);
const material = new THREE.MeshBasicMaterial( {color: 0x00ffff, transparent: true, opacity: 0.5} );
const plane = new THREE.Mesh( geometry, material );
anchor.group.add(plane);

This throws no errors, but the added anchor is not shown at all, while the tracked image is detected. It feels like the anchor is not part of my scene.

br, Max

hiukim commented 1 year ago

not really. why do you want to do that?

FireDragonGameStudio commented 1 year ago

I tried to add MindAR to Needle Engine Tools (https://engine.needle.tools/docs/) and they already provide a three.js environment, where I tried to integrate MindAR.