iTrackerLib.jslib 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. mergeInto(LibraryManager.library, {
  2. StartWebGLiTracker: function(ids, name)
  3. {
  4. if(!window.iTracker){
  5. console.error('%ciTracker not found! Please make sure to use the iTracker WebGLTemplate in your ProjectSettings','font-size: 32px; font-weight: bold');
  6. throw new Error("Tracker not found! Please make sure to use the iTracker WebGLTemplate in your ProjectSettings");
  7. return;
  8. }
  9. window.iTracker.startTracker(UTF8ToString(ids), UTF8ToString(name));
  10. },
  11. StopWebGLiTracker: function()
  12. {
  13. window.iTracker.stopTracker();
  14. },
  15. IsWebGLiTrackerReady: function()
  16. {
  17. return window.iTracker != null;
  18. },
  19. SetWebGLiTrackerSettings: function(settings)
  20. {
  21. window.iTracker.setTrackerSettings(UTF8ToString(settings), "1.7.1.429689");
  22. },
  23. DebugImageTarget: function(id)
  24. {
  25. window.iTracker.debugImageTarget(UTF8ToString(id));
  26. },
  27. IsWebGLImageTracked: function(id)
  28. {
  29. return window.iTracker.isImageTracked(id);
  30. },
  31. GetWebGLWarpedTexture: function(targetId, textureId, resolution)
  32. {
  33. var canvasId = 'iTrackerWarpedTextureCanvas';
  34. var textureCanvas = window.iTracker.GetWebGLWarpedTexture(UTF8ToString(targetId), canvasId, resolution);
  35. //var textureCanvas = document.getElementById(canvasId);
  36. textureObj = GL.textures[textureId];
  37. if (textureCanvas == null || textureObj == null) return;
  38. GLctx.bindTexture(GLctx.TEXTURE_2D, textureObj);
  39. GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_S, GLctx.CLAMP_TO_EDGE);
  40. GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_T, GLctx.CLAMP_TO_EDGE);
  41. GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_MIN_FILTER, GLctx.LINEAR);
  42. GLctx.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
  43. GLctx.texSubImage2D(GLctx.TEXTURE_2D, 0, 0, 0, GLctx.RGBA, GLctx.UNSIGNED_BYTE, textureCanvas);
  44. GLctx.pixelStorei(GLctx.UNPACK_FLIP_Y_WEBGL, false);
  45. //console.log("WebGLGetWarpedImageTexture " + textureId, textureCanvas);
  46. },
  47. });