@webarkit/jsartoolkit-nft
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -0,0 +0,0 @@ { |
@@ -1,3 +0,3 @@ | ||
var browser = (function () { | ||
var test = function (regexp) { | ||
const browser = (function () { | ||
const test = function (regexp) { | ||
return regexp.test(navigator.userAgent); | ||
@@ -35,4 +35,5 @@ }; | ||
let next = null; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -50,6 +51,5 @@ case "load": { | ||
var next = null; | ||
var ar = null; | ||
var markerResult = null; | ||
var marker; | ||
let ar = null; | ||
let markerResult = null; | ||
let marker; | ||
@@ -67,5 +67,5 @@ const WARM_UP_TOLERANCE = 5; | ||
var onLoad = function (arController) { | ||
const onLoad = function (arController) { | ||
ar = arController; | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
@@ -97,3 +97,3 @@ ar.addEventListener("getNFTMarker", function (ev) { | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -100,0 +100,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
var browser = (function () { | ||
var test = function (regexp) { | ||
const browser = (function () { | ||
const test = function (regexp) { | ||
return regexp.test(navigator.userAgent); | ||
@@ -38,4 +38,5 @@ }; | ||
let next = null; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -53,12 +54,11 @@ case "load": { | ||
var next = null; | ||
var ar = null; | ||
var markerResult = null; | ||
var marker; | ||
let ar = null; | ||
let markerResult = null; | ||
let marker; | ||
// jsfeatNext settings | ||
var radius; | ||
var sigma; | ||
let radius; | ||
let sigma; | ||
const jsfeat = jsfeatNext.jsfeatNext; | ||
const imgproc = new jsfeat.imgproc(); | ||
var img_u8, width, height; | ||
let img_u8, width, height; | ||
@@ -69,3 +69,3 @@ const WARM_UP_TOLERANCE = 5; | ||
// initialize the OneEuroFilter | ||
var oef = true; | ||
const oef = true; | ||
let filterMinCF = 0.0001; | ||
@@ -77,3 +77,3 @@ let filterBeta = 0.01; | ||
tickCount += 1; | ||
var mat; | ||
let mat; | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
@@ -95,9 +95,9 @@ mat = filter.filter(Date.now(), matrixGL_RH); | ||
var onLoad = function (arController) { | ||
const onLoad = function (arController) { | ||
ar = arController; | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
ar.addEventListener("getNFTMarker", function (ev) { | ||
var mat; | ||
if (oef == true) { | ||
let mat; | ||
if (oef === true) { | ||
mat = oefFilter(ev.data.matrixGL_RH); | ||
@@ -131,3 +131,3 @@ } else { | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -149,4 +149,4 @@ }; | ||
imgproc.grayscale(next.data, width, height, img_u8); | ||
var r = radius | 0; | ||
var kernel_size = (r + 1) << 1; | ||
const r = radius | 0; | ||
const kernel_size = (r + 1) << 1; | ||
imgproc.gaussian_blur(img_u8, img_u8, kernel_size, sigma); | ||
@@ -153,0 +153,0 @@ ar.setGrayData(img_u8.data); |
@@ -1,2 +0,2 @@ | ||
var scope; | ||
let scope; | ||
if (typeof window !== 'undefined') { | ||
@@ -61,3 +61,3 @@ scope = window; | ||
this.version = '1.7.0'; | ||
this.version = '1.7.1'; | ||
console.info('JsartoolkitNFT ', this.version); | ||
@@ -350,3 +350,3 @@ | ||
glMat[3 + 3 * 4] = 1.0; | ||
if (scale != undefined && scale !== 0.0) { | ||
if (scale !== undefined && scale !== 0.0) { | ||
glMat[12] *= scale; | ||
@@ -701,7 +701,7 @@ glMat[13] *= scale; | ||
if (this.videoLuma) { | ||
var q = 0; | ||
let q = 0; | ||
//Create luma from video data assuming Pixelformat AR_PIXEL_FORMAT_RGBA (ARToolKitJS.cpp L: 43) | ||
for (var p = 0; p < this.videoSize; p++) { | ||
var r = data[q + 0], g = data[q + 1], b = data[q + 2]; | ||
for (let p = 0; p < this.videoSize; p++) { | ||
const r = data[q], g = data[q + 1], b = data[q + 2]; | ||
// videoLuma[p] = (r+r+b+g+g+g)/6; // https://stackoverflow.com/a/596241/5843642 | ||
@@ -816,3 +816,3 @@ this.videoLuma[p] = (r + r + r + b + g + g + g + g) >> 3; | ||
// | ||
var artoolkitNFT = { | ||
const artoolkitNFT = { | ||
@@ -828,3 +828,3 @@ UNKNOWN_MARKER: -1, | ||
var FUNCTIONS = [ | ||
const FUNCTIONS = [ | ||
'setup', | ||
@@ -871,3 +871,3 @@ 'teardown', | ||
for (var m in Module) { | ||
for (const m in Module) { | ||
if (m.match(/^AR/)) | ||
@@ -881,7 +881,7 @@ artoolkitNFT[m] = Module[m]; | ||
function addNFTMarker(arId, url, callback, onError) { | ||
var mId = marker_count++; | ||
var prefix = '/markerNFT_' + mId; | ||
var filename1 = prefix + '.fset'; | ||
var filename2 = prefix + '.iset'; | ||
var filename3 = prefix + '.fset3'; | ||
const mId = marker_count++; | ||
const prefix = '/markerNFT_' + mId; | ||
const filename1 = prefix + '.fset'; | ||
const filename2 = prefix + '.iset'; | ||
const filename3 = prefix + '.fset3'; | ||
ajax(url + '.fset', filename1, function () { | ||
@@ -897,6 +897,6 @@ ajax(url + '.iset', filename2, function () { | ||
function addNFTMarkers(arId, urls, callback, onError) { | ||
var prefixes = []; | ||
var pending = urls.length * 3; | ||
var onSuccess = (filename) => { | ||
function addNFTMarkers(arId, urls, callback, onerror) { | ||
const prefixes = []; | ||
let pending = urls.length * 3; | ||
const onSuccess = (filename) => { | ||
pending -= 1; | ||
@@ -917,15 +917,15 @@ if (pending === 0) { | ||
} | ||
} | ||
var onError = (filename, errorNumber) => { | ||
}; | ||
const onError = (filename, errorNumber) => { | ||
console.log("failed to load: ", filename); | ||
onError(errorNumber); | ||
} | ||
onerror(errorNumber); | ||
}; | ||
for (var i = 0; i < urls.length; i++) { | ||
var url = urls[i]; | ||
var prefix = '/markerNFT_' + marker_count; | ||
const url = urls[i]; | ||
const prefix = '/markerNFT_' + marker_count; | ||
prefixes.push(prefix); | ||
var filename1 = prefix + '.fset'; | ||
var filename2 = prefix + '.iset'; | ||
var filename3 = prefix + '.fset3'; | ||
const filename1 = prefix + '.fset'; | ||
const filename2 = prefix + '.iset'; | ||
const filename3 = prefix + '.fset3'; | ||
@@ -943,8 +943,10 @@ ajax(url + '.fset', filename1, onSuccess.bind(filename1), onError.bind(filename1)); | ||
var camera_count = 0; | ||
let camera_count = 0; | ||
function loadCamera(url, callback, errorCallback) { | ||
var filename = '/camera_param_' + camera_count++; | ||
var writeCallback = function (errorCode) { | ||
const filename = '/camera_param_' + camera_count++; | ||
const writeCallback = function (errorCode) { | ||
if (!Module._loadCamera) { | ||
if (callback) callback(id); setTimeout(writeCallback, 10); | ||
if (callback) callback(id); | ||
setTimeout(writeCallback, 10); | ||
} else { | ||
@@ -1001,3 +1003,3 @@ var id = Module._loadCamera(filename); | ||
function ajax(url, target, callback, errorCallback) { | ||
var oReq = new XMLHttpRequest(); | ||
const oReq = new XMLHttpRequest(); | ||
oReq.open('GET', url, true); | ||
@@ -1009,4 +1011,4 @@ oReq.responseType = 'arraybuffer'; // blob arraybuffer | ||
// console.log('ajax done for ', url); | ||
var arrayBuffer = oReq.response; | ||
var byteArray = new Uint8Array(arrayBuffer); | ||
const arrayBuffer = oReq.response; | ||
const byteArray = new Uint8Array(arrayBuffer); | ||
writeByteArrayToFS(target, byteArray, callback); | ||
@@ -1031,3 +1033,3 @@ } | ||
runWhenLoaded(); | ||
var event = new Event('artoolkitNFT-loaded'); | ||
const event = new Event('artoolkitNFT-loaded'); | ||
scope.dispatchEvent(event); | ||
@@ -1034,0 +1036,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
var browser = (function () { | ||
var test = function (regexp) { | ||
const browser = (function () { | ||
const test = function (regexp) { | ||
return regexp.test(navigator.userAgent); | ||
@@ -35,4 +35,5 @@ }; | ||
let next = null; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -50,6 +51,5 @@ case "load": { | ||
var next = null; | ||
var ar = null; | ||
var markerResult = null; | ||
var marker; | ||
let ar = null; | ||
let markerResult = null; | ||
let marker; | ||
@@ -60,3 +60,3 @@ const WARM_UP_TOLERANCE = 5; | ||
// initialize the OneEuroFilter | ||
var oef = true; | ||
const oef = true; | ||
let filterMinCF = 0.0001; | ||
@@ -71,3 +71,3 @@ let filterBeta = 0.01; | ||
tickCount += 1; | ||
var mat; | ||
let mat; | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
@@ -84,3 +84,3 @@ mat = filter.filter(Date.now(), matrixGL_RH); | ||
var onLoad = function (arController) { | ||
const onLoad = function (arController) { | ||
ar = arController; | ||
@@ -90,4 +90,4 @@ var cameraMatrix = ar.getCameraMatrix(); | ||
ar.addEventListener("getNFTMarker", function (ev) { | ||
var mat; | ||
if (oef == true) { | ||
let mat; | ||
if (oef === true) { | ||
mat = oefFilter(ev.data.matrixGL_RH); | ||
@@ -130,3 +130,3 @@ } else { | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -133,0 +133,0 @@ }; |
@@ -1,3 +0,3 @@ | ||
var browser = (function () { | ||
var test = function (regexp) { | ||
const browser = (function () { | ||
const test = function (regexp) { | ||
return regexp.test(navigator.userAgent); | ||
@@ -35,4 +35,5 @@ }; | ||
let next = null; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -50,6 +51,5 @@ case "load": { | ||
var next = null; | ||
var ar = null; | ||
var markerResult = null; | ||
var marker1, marker2, marker3; | ||
let ar = null; | ||
let markerResult = null; | ||
let marker1, marker2, marker3; | ||
@@ -67,5 +67,5 @@ const WARM_UP_TOLERANCE = 5; | ||
var onLoad = function (arController) { | ||
const onLoad = function (arController) { | ||
ar = arController; | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
@@ -75,3 +75,3 @@ ar.addEventListener("getNFTMarker", function (ev) { | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
var mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
const mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
markerResult = { | ||
@@ -92,3 +92,3 @@ type: "found", | ||
ar.loadNFTMarkers(msg.marker, function (ids) { | ||
for (var i = 0; i < ids.length; i++) { | ||
for (let i = 0; i < ids.length; i++) { | ||
ar.trackNFTMarkerId(i); | ||
@@ -125,3 +125,3 @@ nftMarkers.push_back(ar.getNFTData(i, i)); | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -128,0 +128,0 @@ }; |
; (function () { | ||
'use strict' | ||
var scope; | ||
let scope; | ||
if (typeof window !== 'undefined') { | ||
@@ -14,27 +14,27 @@ scope = window; | ||
/** | ||
The ARControllerNFT is the main object for doing AR marker detection with JSARToolKit. | ||
The ARControllerNFT is the main object for doing AR marker detection with JSARToolKit. | ||
To use an ARControllerNFT, you need to tell it the dimensions to use for the AR processing canvas and | ||
pass it an ARCameraParamNFT to define the camera parameters to use when processing images. | ||
The ARCameraParamNFT defines the lens distortion and aspect ratio of the camera used. | ||
See https://www.artoolworks.com/support/library/Calibrating_your_camera for more information about AR camera parameters and how to make and use them. | ||
To use an ARControllerNFT, you need to tell it the dimensions to use for the AR processing canvas and | ||
pass it an ARCameraParamNFT to define the camera parameters to use when processing images. | ||
The ARCameraParamNFT defines the lens distortion and aspect ratio of the camera used. | ||
See https://www.artoolworks.com/support/library/Calibrating_your_camera for more information about AR camera parameters and how to make and use them. | ||
If you pass an image as the first argument, the ARControllerNFT uses that as the image to process, | ||
using the dimensions of the image as AR processing canvas width and height. If the first argument | ||
to ARControllerNFT is an image, the second argument is used as the camera param. | ||
If you pass an image as the first argument, the ARControllerNFT uses that as the image to process, | ||
using the dimensions of the image as AR processing canvas width and height. If the first argument | ||
to ARControllerNFT is an image, the second argument is used as the camera param. | ||
The camera parameters argument can be either an ARCameraParamNFT or an URL to a camera definition file. | ||
If the camera argument is an URL, it is loaded into a new ARCameraParamNFT, and the ARControllerNFT dispatches | ||
a 'load' event and calls the onload method if it is defined. | ||
The camera parameters argument can be either an ARCameraParamNFT or an URL to a camera definition file. | ||
If the camera argument is an URL, it is loaded into a new ARCameraParamNFT, and the ARControllerNFT dispatches | ||
a 'load' event and calls the onload method if it is defined. | ||
@exports ARControllerNFT | ||
@constructor | ||
@exports ARControllerNFT | ||
@constructor | ||
@param {number} width The width of the images to process. | ||
@param {number} height The height of the images to process. | ||
@param {ARCameraParamNFT | string} camera The ARCameraParamNFT to use for image processing. If this is a string, the ARControllerNFT treats it as an URL and tries to load it as a ARCameraParamNFT definition file, calling ARControllerNFT#onload on success. | ||
*/ | ||
var ARControllerNFT = function (width, height, cameraPara) { | ||
@param {number} width The width of the images to process. | ||
@param {number} height The height of the images to process. | ||
@param {ARCameraParamNFT | string} camera The ARCameraParamNFT to use for image processing. If this is a string, the ARControllerNFT treats it as an URL and tries to load it as a ARCameraParamNFT definition file, calling ARControllerNFT#onload on success. | ||
*/ | ||
const ARControllerNFT = function (width, height, cameraPara) { | ||
this.id = undefined; | ||
var w = width, h = height; | ||
const w = width, h = height; | ||
@@ -65,3 +65,3 @@ this.listeners = {}; | ||
this.version = '1.7.0'; | ||
this.version = '1.7.1'; | ||
console.info('JsartoolkitNFT ', this.version); | ||
@@ -95,3 +95,3 @@ console.warn("This library is deprecated, use the ES6 version instead!! It will be removed in a future release.") | ||
for (var t in this) { | ||
for (const t in this) { | ||
this[t] = null; | ||
@@ -129,3 +129,3 @@ } | ||
// get NFT markers | ||
var k, o; | ||
let k, o; | ||
for (k in this.nftMarkers) { | ||
@@ -138,11 +138,11 @@ o = this.nftMarkers[k]; | ||
// detect NFT markers | ||
var nftMarkerCount = this.nftMarkerCount; | ||
const nftMarkerCount = this.nftMarkerCount; | ||
this.detectNFTMarker(); | ||
// in ms | ||
var MARKER_LOST_TIME = 200; | ||
const MARKER_LOST_TIME = 200; | ||
for (var i = 0; i < nftMarkerCount; i++) { | ||
var nftMarkerInfo = this.getNFTMarker(i); | ||
var markerType = artoolkitNFT.NFT_MARKER; | ||
for (let i = 0; i < nftMarkerCount; i++) { | ||
const nftMarkerInfo = this.getNFTMarker(i); | ||
const markerType = artoolkitNFT.NFT_MARKER; | ||
@@ -153,3 +153,3 @@ if (nftMarkerInfo.found) { | ||
var visible = this.trackNFTMarkerId(i); | ||
const visible = this.trackNFTMarkerId(i); | ||
visible.matrix.set(nftMarkerInfo.pose); | ||
@@ -214,3 +214,3 @@ visible.inCurrent = true; | ||
ARControllerNFT.prototype.trackNFTMarkerId = function (id, markerWidth) { | ||
var obj = this.nftMarkers[id]; | ||
let obj = this.nftMarkers[id]; | ||
if (!obj) { | ||
@@ -270,5 +270,5 @@ this.nftMarkers[id] = obj = { | ||
ARControllerNFT.prototype.dispatchEvent = function (event) { | ||
var listeners = this.listeners[event.name]; | ||
const listeners = this.listeners[event.name]; | ||
if (listeners) { | ||
for (var i = 0; i < listeners.length; i++) { | ||
for (let i = 0; i < listeners.length; i++) { | ||
listeners[i].call(this, event); | ||
@@ -299,3 +299,3 @@ } | ||
ARControllerNFT.prototype.loadNFTMarkers = function (markerURLs, onSuccess, onError) { | ||
var self = this; | ||
const self = this; | ||
artoolkitNFT.addNFTMarkers(this.id, markerURLs, function (ids) { | ||
@@ -371,3 +371,3 @@ self.nftMarkerCount += ids.length; | ||
ARControllerNFT.prototype.arglCameraViewRHf = function (glMatrix, glRhMatrix, scale) { | ||
var m_modelview; | ||
let m_modelview; | ||
if (glRhMatrix == undefined) | ||
@@ -700,11 +700,11 @@ m_modelview = new Float64Array(16); | ||
} | ||
var data = imageData.data; // this is of type Uint8ClampedArray: The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0-255 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) | ||
const data = imageData.data; // this is of type Uint8ClampedArray: The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0-255 (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8ClampedArray) | ||
//Here we have access to the unmodified video image. We now need to add the videoLuma chanel to be able to serve the underlying ARTK API | ||
if (this.videoLuma) { | ||
var q = 0; | ||
let q = 0; | ||
//Create luma from video data assuming Pixelformat AR_PIXEL_FORMAT_RGBA (ARToolKitJS.cpp L: 43) | ||
for (var p = 0; p < this.videoSize; p++) { | ||
var r = data[q + 0], g = data[q + 1], b = data[q + 2]; | ||
for (let p = 0; p < this.videoSize; p++) { | ||
const r = data[q], g = data[q + 1], b = data[q + 2]; | ||
// videoLuma[p] = (r+r+b+g+g+g)/6; // https://stackoverflow.com/a/596241/5843642 | ||
@@ -743,3 +743,3 @@ this.videoLuma[p] = (r + r + r + b + g + g + g + g) >> 3; | ||
*/ | ||
var ARCameraParamNFT = function (src, onload, onerror) { | ||
const ARCameraParamNFT = function (src, onload, onerror) { | ||
this.id = -1; | ||
@@ -819,3 +819,3 @@ this._src = ''; | ||
// | ||
var artoolkitNFT = { | ||
const artoolkitNFT = { | ||
@@ -831,3 +831,3 @@ UNKNOWN_MARKER: -1, | ||
var FUNCTIONS = [ | ||
const FUNCTIONS = [ | ||
'setup', | ||
@@ -874,3 +874,3 @@ 'teardown', | ||
for (var m in Module) { | ||
for (const m in Module) { | ||
if (m.match(/^AR/)) | ||
@@ -881,10 +881,10 @@ artoolkitNFT[m] = Module[m]; | ||
var marker_count = 0; | ||
let marker_count = 0; | ||
function addNFTMarker(arId, url, callback, onError) { | ||
var mId = marker_count++; | ||
var prefix = '/markerNFT_' + mId; | ||
var filename1 = prefix + '.fset'; | ||
var filename2 = prefix + '.iset'; | ||
var filename3 = prefix + '.fset3'; | ||
const mId = marker_count++; | ||
const prefix = '/markerNFT_' + mId; | ||
const filename1 = prefix + '.fset'; | ||
const filename2 = prefix + '.iset'; | ||
const filename3 = prefix + '.fset3'; | ||
ajax(url + '.fset', filename1, function () { | ||
@@ -900,6 +900,6 @@ ajax(url + '.iset', filename2, function () { | ||
function addNFTMarkers(arId, urls, callback, onError) { | ||
var prefixes = []; | ||
var pending = urls.length * 3; | ||
var onSuccess = (filename) => { | ||
function addNFTMarkers(arId, urls, callback, onerror) { | ||
const prefixes = []; | ||
let pending = urls.length * 3; | ||
const onSuccess = (filename) => { | ||
pending -= 1; | ||
@@ -912,3 +912,3 @@ if (pending === 0) { | ||
} | ||
var ret = Module._addNFTMarkers(arId, vec); | ||
const ret = Module._addNFTMarkers(arId, vec); | ||
for (let i = 0; i < ret.size(); i++) { | ||
@@ -922,14 +922,14 @@ markerIds.push(ret.get(i)); | ||
} | ||
var onError = (filename, errorNumber) => { | ||
const onError = (filename, errorNumber) => { | ||
console.log("failed to load: ", filename); | ||
onError(errorNumber); | ||
onerror(errorNumber); | ||
} | ||
for (var i = 0; i < urls.length; i++) { | ||
var url = urls[i]; | ||
var prefix = '/markerNFT_' + marker_count; | ||
for (let i = 0; i < urls.length; i++) { | ||
const url = urls[i]; | ||
const prefix = '/markerNFT_' + marker_count; | ||
prefixes.push(prefix); | ||
var filename1 = prefix + '.fset'; | ||
var filename2 = prefix + '.iset'; | ||
var filename3 = prefix + '.fset3'; | ||
const filename1 = prefix + '.fset'; | ||
const filename2 = prefix + '.iset'; | ||
const filename3 = prefix + '.fset3'; | ||
@@ -947,10 +947,11 @@ ajax(url + '.fset', filename1, onSuccess.bind(filename1), onError.bind(filename1)); | ||
var camera_count = 0; | ||
let camera_count = 0; | ||
function loadCamera(url, callback, errorCallback) { | ||
var filename = '/camera_param_' + camera_count++; | ||
var writeCallback = function (errorCode) { | ||
const filename = '/camera_param_' + camera_count++; | ||
const writeCallback = function (errorCode) { | ||
const id = Module._loadCamera(filename); | ||
if (!Module._loadCamera) { | ||
if (callback) callback(id); setTimeout(writeCallback, 10); | ||
} else { | ||
var id = Module._loadCamera(filename); | ||
if (callback) callback(id); | ||
@@ -971,4 +972,4 @@ } | ||
function writeStringToFS(target, string, callback) { | ||
var byteArray = new Uint8Array(string.length); | ||
for (var i = 0; i < byteArray.length; i++) { | ||
const byteArray = new Uint8Array(string.length); | ||
for (let i = 0; i < byteArray.length; i++) { | ||
byteArray[i] = string.charCodeAt(i) & 0xff; | ||
@@ -991,3 +992,3 @@ } | ||
function ajax(url, target, callback, errorCallback) { | ||
var oReq = new XMLHttpRequest(); | ||
const oReq = new XMLHttpRequest(); | ||
oReq.open('GET', url, true); | ||
@@ -999,4 +1000,4 @@ oReq.responseType = 'arraybuffer'; // blob arraybuffer | ||
// console.log('ajax done for ', url); | ||
var arrayBuffer = oReq.response; | ||
var byteArray = new Uint8Array(arrayBuffer); | ||
const arrayBuffer = oReq.response; | ||
const byteArray = new Uint8Array(arrayBuffer); | ||
writeByteArrayToFS(target, byteArray, callback); | ||
@@ -1020,3 +1021,3 @@ } | ||
runWhenLoaded(); | ||
var event = new Event('artoolkitNFT-loaded'); | ||
const event = new Event('artoolkitNFT-loaded'); | ||
scope.dispatchEvent(event); | ||
@@ -1023,0 +1024,0 @@ }; |
@@ -6,3 +6,3 @@ import ARToolkitNFT from "../build/artoolkitNFT_embed_ES6_wasm.js"; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -23,4 +23,4 @@ case "load": { | ||
var ar = null; | ||
var markerResult = null; | ||
var marker; | ||
let markerResult = null; | ||
//var marker; | ||
@@ -38,3 +38,3 @@ const WARM_UP_TOLERANCE = 5; | ||
tickCount += 1; | ||
var mat; | ||
let mat; | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
@@ -54,9 +54,9 @@ mat = filter.filter(Date.now(), matrixGL_RH); | ||
var onLoad = function () { | ||
const onLoad = function () { | ||
ar = new arTK.ARControllerNFT(msg.pw, msg.ph, param); | ||
console.log(ar); | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
ar.addEventListener("getNFTMarker", function (ev) { | ||
var mat; | ||
let mat; | ||
if (oef == true) { | ||
@@ -99,3 +99,3 @@ mat = oefFilter(ev.data.matrixGL_RH); | ||
// we cannot pass the entire ARControllerNFT, so we re-create one inside the Worker, starting from camera_param | ||
var param = new arTK.ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
const param = new arTK.ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
//});//event listener | ||
@@ -102,0 +102,0 @@ } |
@@ -52,4 +52,4 @@ var browser = (function () { | ||
var ar = null; | ||
var markerResult = null; | ||
var marker1, marker2, marker3; | ||
let markerResult = null; | ||
let marker1, marker2, marker3; | ||
@@ -68,5 +68,5 @@ const WARM_UP_TOLERANCE = 5; | ||
var onLoad = function () { | ||
const onLoad = function () { | ||
ar = new ARControllerNFT(msg.pw, msg.ph, param); | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
@@ -76,3 +76,3 @@ ar.addEventListener("getNFTMarker", function (ev) { | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
var mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
const mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
markerResult = { | ||
@@ -91,3 +91,3 @@ type: "found", | ||
ar.loadNFTMarkers(msg.marker, function (ids) { | ||
for (var i = 0; i < ids.length; i++) { | ||
for (let i = 0; i < ids.length; i++) { | ||
ar.trackNFTMarkerId(i); | ||
@@ -114,3 +114,3 @@ } | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -122,3 +122,3 @@ }; | ||
// we cannot pass the entire ARControllerNFT, so we re-create one inside the Worker, starting from camera_param | ||
var param = new ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
const param = new ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
}); | ||
@@ -125,0 +125,0 @@ } |
@@ -1,3 +0,3 @@ | ||
var browser = (function () { | ||
var test = function (regexp) { | ||
const browser = (function () { | ||
const test = function (regexp) { | ||
return regexp.test(navigator.userAgent); | ||
@@ -35,4 +35,5 @@ }; | ||
let next = null; | ||
self.onmessage = function (e) { | ||
var msg = e.data; | ||
const msg = e.data; | ||
switch (msg.type) { | ||
@@ -51,6 +52,5 @@ case "load": { | ||
var next = null; | ||
var ar = null; | ||
var markerResult = null; | ||
var marker; | ||
let ar = null; | ||
let markerResult = null; | ||
let marker; | ||
@@ -69,5 +69,5 @@ const WARM_UP_TOLERANCE = 5; | ||
var onLoad = function () { | ||
const onLoad = function () { | ||
ar = new ARControllerNFT(msg.pw, msg.ph, param); | ||
var cameraMatrix = ar.getCameraMatrix(); | ||
const cameraMatrix = ar.getCameraMatrix(); | ||
@@ -77,3 +77,3 @@ ar.addEventListener("getNFTMarker", function (ev) { | ||
if (tickCount > WARM_UP_TOLERANCE) { | ||
var mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
const mat = filter.filter(Date.now(), ev.data.matrixGL_RH); | ||
markerResult = { | ||
@@ -105,3 +105,3 @@ type: "found", | ||
var onError = function (error) { | ||
const onError = function (error) { | ||
console.error(error); | ||
@@ -113,3 +113,3 @@ }; | ||
// we cannot pass the entire ARControllerNFT, so we re-create one inside the Worker, starting from camera_param | ||
var param = new ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
const param = new ARCameraParamNFT(msg.camera_para, onLoad, onError); | ||
}); | ||
@@ -116,0 +116,0 @@ } |
@@ -0,0 +0,0 @@ GNU LESSER GENERAL PUBLIC LICENSE |
{ | ||
"name": "@webarkit/jsartoolkit-nft", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"main": "dist/ARToolkitNFT.js", | ||
@@ -39,16 +39,16 @@ "types": "types/src/index.d.ts", | ||
"devDependencies": { | ||
"@babel/core": "^7.23.7", | ||
"@babel/plugin-transform-runtime": "^7.23.6", | ||
"@babel/preset-env": "^7.23.6", | ||
"babel-loader": "^9.1.3", | ||
"karma": "^6.4.2", | ||
"@babel/core": "7.26.0", | ||
"@babel/plugin-transform-runtime": "^7.25.9", | ||
"@babel/preset-env": "7.26.0", | ||
"babel-loader": "^9.2.1", | ||
"karma": "^6.4.4", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-firefox-launcher": "^2.1.2", | ||
"karma-qunit": "^4.1.2", | ||
"prettier": "^3.1.1", | ||
"qunit": "^2.20.0", | ||
"karma-firefox-launcher": "^2.1.3", | ||
"karma-qunit": "^4.2.1", | ||
"prettier": "^3.3.3", | ||
"qunit": "^2.22.0", | ||
"ts-loader": "^9.5.1", | ||
"typedoc": "^0.25.6", | ||
"typescript": "^5.3.3", | ||
"webpack": "^5.89.0", | ||
"typedoc": "^0.26.10", | ||
"typescript": "5.5.4", | ||
"webpack": "5.95.0", | ||
"webpack-cli": "^5.1.4" | ||
@@ -62,2 +62,4 @@ }, | ||
"build-no-libar": "node tools/makem.js --no-libar; echo Built at `date`", | ||
"build-docker": "docker exec emscripten-jsartoolkitnft npm run build", | ||
"build-docker-no-libar": "docker exec emscripten-jsartoolkitnft npm run build-no-libar", | ||
"test-browser": "karma start --browsers Chrome,Firefox,ChromeHeadless,FirefoxHeadless", | ||
@@ -67,9 +69,10 @@ "test": "karma start", | ||
"format-check": "prettier --check .", | ||
"format": "prettier --write ." | ||
"format": "prettier --write .", | ||
"setup-docker": "docker run -dit --name emscripten-jsartoolkitnft -v $(pwd):/src emscripten/emsdk:3.1.69 bash" | ||
}, | ||
"license": "LGPL-3.0", | ||
"dependencies": { | ||
"@babel/runtime": "^7.23.7", | ||
"axios": "^1.6.4" | ||
"@babel/runtime": "7.26.0", | ||
"axios": "1.7.7" | ||
} | ||
} |
@@ -89,2 +89,12 @@ ![github releases](https://flat.badgen.net/github/release/webarkit/jsartoolkitNFT) | ||
``` | ||
**Note**: All the examples in the repository are running the code inside a Worker (don't use it in the main thread!). So i you need to import the library in a worker you need to use the `importScripts` function. | ||
```javascript | ||
// example of import in a worker with the wasm code lib | ||
importScripts("../build/artoolkitNFT_wasm.js"); | ||
// or the dist lib | ||
importScripts("../dist/ARToolkitNFT.js"); | ||
``` | ||
## Downloads | ||
@@ -91,0 +101,0 @@ |
@@ -0,0 +0,0 @@ { |
export default Module; | ||
declare function Module(Module?: {}): any; | ||
declare function Module(moduleArg?: {}): Promise<any>; |
@@ -0,0 +0,0 @@ declare function threadPrintErr(...args: any[]): void; |
export default Module; | ||
declare function Module(Module?: {}): any; | ||
declare function Module(moduleArg?: {}): Promise<any>; |
export default Module; | ||
declare function Module(Module?: {}): any; | ||
declare function Module(moduleArg?: {}): Promise<any>; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 3 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
15921630
86
4
169
22
24
30957
+ Addedaxios@1.7.7(transitive)
- Removedaxios@1.7.9(transitive)
Updated@babel/runtime@7.26.0
Updatedaxios@1.7.7