hiukim / mind-ar-js

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

Add glb file into Three.js facemesh example #173

Closed rudrdybo closed 2 years ago

rudrdybo commented 2 years ago

I am currently facing issue in adding a 3d model to three.js facemesh example.Please let me know the steps to achieve the same.

hiukim commented 2 years ago

Should be the same as how you load 3D model in three.js.

This gltfloader example could be a good start: https://threejs.org/examples/?q=gltf#webgl_loader_gltf

ghost commented 1 year ago

Should be the same as how you load 3D model in three.js.

This gltfloader example could be a good start: https://threejs.org/examples/?q=gltf#webgl_loader_gltf

Over there, the method (https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_gltf.html) specifies

<script type="importmap">
    {
        "imports": {
            "three": "../build/three.module.js",
            "three/addons/": "./jsm/"
        }
    }
</script>

to have three as the name for the three module, which GLTFLoader.js uses to import it. This conflicts when in the line const THREE = window.MINDAR.IMAGE.THREE; the module would again be imported, and causes to have duplicated modules loaded. image

I've tried replacing the definition of name to "three": "./mindar-image-three.prod.js" to use MindAR-three, but for some reason it can't load it properly, throwing errors like image How could I proceed in order to be able to use GLTFLoader.js? Have a nice day!