README
cordova-vuforia
Vuforia plugin for Cordova.(The first version only support Android.)
Installation
cordova plugin add cordova-vuforia
Usage
Initialize Vufofia
CordovaVuforia.initVuforia(options, success, error)
optionsoptions.vuforiaLicenselicense of vuforia developersuccesscallback when successerrorcallback when failure
initVuforiashould be used at first when you decide to start vuforia.
Start Vuforia
CordovaVuforia.startVuforia(options, success, error)
optionsoptions.camerawhich camera to use, "0" for back-camera, "1" for front-cameraoptions.typetarget recognition mode, "0" for image-target-recognition, "1" for user-defined-target-recognitionsuccesscallback when successerrorcallback when failure
You should set the background of the webpage to "transparent" after
startVuforiato make sure the camera view can be shown. Because the "WebView" layer is above the native layer and the camera layer. So if there is any background colors or elements, it will block the camera, and you might see nothing worked.
stylesheet example
body.vuforia-show {
background-color: transparent !important;
}
Stop Vuforia
CordovaVuforia.stopVuforia(success, error)
successcallback when successerrorcallback when failure
Set the recognition mode of vuforia
CordovaVuforia.setRecognitionType(options, success, error)
optionsoptions.typetarget recognition mode, "0" for image-target-recognition, "1" for user-defined-target-recognitionsuccesscallback when successerrorcallback when failure
Set the Image-Target model
CordovaVuforia.setImageTargetModel(options, success, error)
optionsoptions.imageNameImage-Target nameoptions.matrixmatrixoptions.matrix.posXoffset of "x" axisoptions.matrix.posYoffset of "y" axisoptions.matrix.posZoffset of "z" axisoptions.matrix.scaleXscale percent of "x" axisoptions.matrix.scaleYscale percent of "y" axisoptions.matrix.scaleZscale percent of "z" axisoptions.matrix.rotaterotation angle (anticlockwise)options.mapthe model's filepath, stored at/models/options.filepaththe filepath of target's configure, stored at/targets/, such asStoneAndChips.xmlsuccesscallback when successerrorcallback when failure
Get User-Defined-Target
CordovaVuforia.getUserDefinedTarget(success, error)
successcallback when successerrorcallback when failure
Set User-Defined-Target model
CordovaVuforia.setUserDefinedTargetModel(options, success, error)
options.matrixmatrixoptions.matrix.posXoffset of "x" axisoptions.matrix.posYoffset of "y" axisoptions.matrix.posZoffset of "z" axisoptions.matrix.scaleXscale percent of "x" axisoptions.matrix.scaleYscale percent of "y" axisoptions.matrix.scaleZscale percent of "z" axisoptions.matrix.rotaterotation angle (anticlockwise)options.mapthe model's filepath, stored at/models/successcallback when successerrorcallback when failure
Remove User-Defined-Target
CordovaVuforia.removeUserDefinedTarget(success, error)
successcallback when successerrorcallback when failure
Event when target be found
document.addEventListener('CordovaVuforia.onTargetFound', function(data) {})
datadata.statusthe status for whether target was found or not. "1" for found, "0" for not or losing target.data.imageNameImage-Target name. (only return when found, and "status" is "1")
TODO
- support iOS
Demo
Ionic 3 Demo https://github.com/ztl19930409/ionic-for-cordova-vuforia