Search code examples
javascriptwebaframeartoolkitar.js

Aframe Multiple Pattern Ratio


Hello I want To Use Multiple Patterns With Different Ratio . Can Any One Help Me to Sort Out This . I Can Use Use Multiple Markers With Different Ratio But I Am Not Able To Use Multiple Markers With Dirrerent Ration .

Like Pattern One (Hiro) - HIRO ( Which has ratio of 0.50 by default),

Pattern Two (Custom QR Code) With Ratio 0.75 - PATTERN,

Tag <a-scene arjs="patternRatio: 0.75">
<a-marker type="pattern" preset="hiro" vidhandler="target: #vid1">
--------
<a-marker
        type="pattern"
        url="https://cdn.glitch.com/e85b316e-eed9-4e96-814e-d12630bc00df%2Fpattern-qr-code.patt?v=1577440081157"
        vidhandler="target: #vid2"
      >

Glitch : Multi Pattern Code


Solution

  • I think that actually it is not possible, because is not implemented. You could add as you did patternRatio to the <a-scene> but this will add the same patternRatio to all markers in the scene. You could add PatternRatio to the a-marker component inside the component-anchor.js in this way:

    // FIXME
    AFRAME.registerPrimitive('a-marker', AFRAME.utils.extendDeep({}, AFRAME.primitives.getMeshMixin(), {
        defaultComponents: {
            'arjs-anchor': {},
            'arjs-hit-testing': {},
        },
        mappings: {
            'type': 'arjs-anchor.type',
            'size': 'arjs-anchor.size',
            'url': 'arjs-anchor.patternUrl',
            'patternRatio': 'arjs-anchor.patternRatio', // add this line !
            'value': 'arjs-anchor.barcodeValue',
            'preset': 'arjs-anchor.preset',
            'min-confidence': 'arjs-anchor.minConfidence',
            'marker-helpers': 'arjs-anchor.markerhelpers',
            'smooth': 'arjs-anchor.smooth',
            'smooth-count': 'arjs-anchor.smoothCount',
            'smooth-tolerance': 'arjs-anchor.smoothTolerance',
            'smooth-threshold': 'arjs-anchor.smoothThreshold',
    
            'hit-testing-render-debug': 'arjs-hit-testing.renderDebug',
            'hit-testing-enabled': 'arjs-hit-testing.enabled',
        }
    }))
    

    you should rebuild the lib before using, run: npm install and then npm run build in the main AR.js folder. I have not tested the code so i can not sure that this code works. BTW it will be nice to add such a feature...