jeromeetienne / AR.js

Efficient Augmented Reality for the Web - 60fps on mobile!
MIT License
15.78k stars 2.22k forks source link

Adding Maker and 3dModel #61

Closed ghost closed 6 years ago

ghost commented 7 years ago

Hello How to add my own maker and 3dmodels in webAR using A-Frame

Thanks in advance

chisaipete commented 7 years ago

Check out the A-Frame documentation on how to load a model. I basically used the tag as documented here.

I'm stumbling through the "own marker" bit, but I was trying to use barcode markers and they are currently broken. The theory for one of the other markers is that you'd probably have to add the training pattern for the marker (not Hiro or Kanji) and ensure it's loaded into jsartoolkit properly, but I haven't done that yet.

darasat commented 7 years ago

for use my own pattern I did the following:

  1. I create my own github data --> https://github.com/darasat/data ( I trained the pattern with http://flash.tarotaro.org/blog/2009/07/12/mgo2/)

  2. I create a variable in the aframe-ar.js called testURL THREEx.ArToolkitContext.testURL = 'https://raw.githubusercontent.com/darasat/data/'

  3. Following in the parameters section

THREEx.ArToolkitProfile.prototype.reset = function () { this.sourceParameters = { // to read from the webcam sourceType : 'webcam', }

this.contextParameters = {
    cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat',
    detectionMode: 'mono',
}
this.defaultMarkerParameters = {
    type : 'pattern',
    patternUrl : THREEx.ArToolkitContext.testURL + 'master/tiger.patt'
}
return this

};

  1. After this in the markers section

THREEx.ArToolkitProfile.prototype.testMarker = function () { this.contextParameters.detectionMode = 'mono'

this.defaultMarkerParameters.type = 'pattern'
this.defaultMarkerParameters.patternUrl = THREEx.ArToolkitContext.testURL+ 'master/tiger.patt'
return this

}

  1. Finally in the init function add the comparison with the new marker created

init: function () { // honor this.data.preset if( this.data.preset === 'tiger' ){ this.data.type = 'pattern' this.data.patternUrl = THREEx.ArToolkitContext.testURL+'master/tiger.patt' }

  1. In the HTML add a aframe scene with the assets from the model and new preset pattern in this case tiger model for example

and this works!

I hope this solves the problem of the own marker with custom 3d Model, greetings from Colombia.

gundanx10 commented 5 years ago

custom marker #