From d1c8eee0aef90911b633c741bbfecd56f99d2f6e Mon Sep 17 00:00:00 2001 From: Jerome Etienne Date: Wed, 16 Aug 2017 14:24:56 +0100 Subject: [PATCH] more on tests + stuff --- three.js/build/ar.js | 16 +- three.js/examples/dev.html | 2 +- three.js/examples/test-runner.html | 326 +++++++++--------- .../src/threex/threex-artoolkitcontext.js | 16 +- three.js/src/threex/threex-artoolkitsource.js | 20 +- .../vendor/jsartoolkit5/js/artoolkit.api.js | 23 +- 6 files changed, 200 insertions(+), 203 deletions(-) diff --git a/three.js/build/ar.js b/three.js/build/ar.js index 8dda281..7c7d8d6 100644 --- a/three.js/build/ar.js +++ b/three.js/build/ar.js @@ -5327,7 +5327,7 @@ ARjs.Context.prototype._initArtoolkit = function(onCompleted){ // init controller var arController = new ARController(_this.parameters.canvasWidth, _this.parameters.canvasHeight, cameraParameters); _this.arController = arController - + // honor this.parameters.imageSmoothingEnabled arController.ctx.mozImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled; arController.ctx.webkitImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled; @@ -5391,15 +5391,11 @@ ARjs.Context.prototype.getProjectionMatrix = function(srcElement){ // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix // keep a backward compatibility with a console.warn - - if( this.parameters.trackingBackend === 'aruco' ){ - console.assert(false, 'dont call this function with aruco') - }else if( this.parameters.trackingBackend === 'artoolkit' ){ - console.assert(this.arController, 'arController MUST be initialized to call this function') - // get projectionMatrixArr from artoolkit - var projectionMatrixArr = this.arController.getCameraMatrix(); - var projectionMatrix = new THREE.Matrix4().fromArray(projectionMatrixArr) - }else console.assert(false) + console.assert( this.parameters.trackingBackend === 'artoolkit' ) + console.assert(this.arController, 'arController MUST be initialized to call this function') + // get projectionMatrixArr from artoolkit + var projectionMatrixArr = this.arController.getCameraMatrix(); + var projectionMatrix = new THREE.Matrix4().fromArray(projectionMatrixArr) // apply context._axisTransformMatrix - change artoolkit axis to match usual webgl one projectionMatrix.multiply(this._artoolkitProjectionAxisTransformMatrix) diff --git a/three.js/examples/dev.html b/three.js/examples/dev.html index 7160dc6..6b5671b 100644 --- a/three.js/examples/dev.html +++ b/three.js/examples/dev.html @@ -122,7 +122,7 @@ arToolkitContext.update( arToolkitSource.domElement ) }) - + //////////////////////////////////////////////////////////////////////////////// // Create a ArMarkerControls diff --git a/three.js/examples/test-runner.html b/three.js/examples/test-runner.html index 42288e0..2d62de6 100644 --- a/three.js/examples/test-runner.html +++ b/three.js/examples/test-runner.html @@ -1,211 +1,188 @@ - + - - + + - - - - - - + + + + + + - + + + + - + + + + + + + + + + + + +
- AR.js - BLABLA test runner for three.js + AR.js - Session API demo with multi tracking and hit testing + - by @jerome_etienne
- Marker image - hiro for artoolkit - / - 1001 for aruco + Markers page
- Backend: - switch to : - artoolkit - / - aruco - / - tango - - - current : unknown + Tracking Backend: + artoolkit + / + aruco + / + area artoolkit + / + area aruco + / + tango + / + best
diff --git a/three.js/src/threex/threex-artoolkitcontext.js b/three.js/src/threex/threex-artoolkitcontext.js index eedb86d..6e794cb 100644 --- a/three.js/src/threex/threex-artoolkitcontext.js +++ b/three.js/src/threex/threex-artoolkitcontext.js @@ -195,7 +195,7 @@ ARjs.Context.prototype._initArtoolkit = function(onCompleted){ // init controller var arController = new ARController(_this.parameters.canvasWidth, _this.parameters.canvasHeight, cameraParameters); _this.arController = arController - + // honor this.parameters.imageSmoothingEnabled arController.ctx.mozImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled; arController.ctx.webkitImageSmoothingEnabled = _this.parameters.imageSmoothingEnabled; @@ -259,15 +259,11 @@ ARjs.Context.prototype.getProjectionMatrix = function(srcElement){ // FIXME rename this function to say it is artoolkit specific - getArtoolkitProjectMatrix // keep a backward compatibility with a console.warn - - if( this.parameters.trackingBackend === 'aruco' ){ - console.assert(false, 'dont call this function with aruco') - }else if( this.parameters.trackingBackend === 'artoolkit' ){ - console.assert(this.arController, 'arController MUST be initialized to call this function') - // get projectionMatrixArr from artoolkit - var projectionMatrixArr = this.arController.getCameraMatrix(); - var projectionMatrix = new THREE.Matrix4().fromArray(projectionMatrixArr) - }else console.assert(false) + console.assert( this.parameters.trackingBackend === 'artoolkit' ) + console.assert(this.arController, 'arController MUST be initialized to call this function') + // get projectionMatrixArr from artoolkit + var projectionMatrixArr = this.arController.getCameraMatrix(); + var projectionMatrix = new THREE.Matrix4().fromArray(projectionMatrixArr) // apply context._axisTransformMatrix - change artoolkit axis to match usual webgl one projectionMatrix.multiply(this._artoolkitProjectionAxisTransformMatrix) diff --git a/three.js/src/threex/threex-artoolkitsource.js b/three.js/src/threex/threex-artoolkitsource.js index b3ca5d3..36a0f9a 100644 --- a/three.js/src/threex/threex-artoolkitsource.js +++ b/three.js/src/threex/threex-artoolkitsource.js @@ -289,11 +289,14 @@ ARjs.Source.prototype.toggleMobileTorch = function(){ // handle resize //////////////////////////////////////////////////////////////////////////////// -ARjs.Source.prototype.onResizeElement = function(mirrorDomElements){ +ARjs.Source.prototype.onResizeElement = function(){ var _this = this var screenWidth = window.innerWidth var screenHeight = window.innerHeight + // sanity check + console.assert( arguments.length === 0 ) + // compute sourceWidth, sourceHeight if( this.domElement.nodeName === "IMG" ){ var sourceWidth = this.domElement.naturalWidth @@ -330,21 +333,6 @@ ARjs.Source.prototype.onResizeElement = function(mirrorDomElements){ this.domElement.style.width = screenWidth+'px' this.domElement.style.marginLeft = '0px' } - - - if( arguments.length !== 0 ){ - debugger - console.warn('use bad signature for arToolkitSource.copyElementSizeTo') - } - // honor default parameters - // if( mirrorDomElements !== undefined ) console.warn('still use the old resize. fix it') - if( mirrorDomElements === undefined ) mirrorDomElements = [] - if( mirrorDomElements instanceof Array === false ) mirrorDomElements = [mirrorDomElements] - - // Mirror _this.domElement.style to mirrorDomElements - mirrorDomElements.forEach(function(domElement){ - _this.copyElementSizeTo(domElement) - }) } ARjs.Source.prototype.copyElementSizeTo = function(otherElement){ diff --git a/three.js/vendor/jsartoolkit5/js/artoolkit.api.js b/three.js/vendor/jsartoolkit5/js/artoolkit.api.js index 21af06f..136cb81 100644 --- a/three.js/vendor/jsartoolkit5/js/artoolkit.api.js +++ b/three.js/vendor/jsartoolkit5/js/artoolkit.api.js @@ -981,16 +981,19 @@ } - if (this.orientation === 'portrait') { - this.ctx.save(); - this.ctx.translate(this.canvas.width, 0); - this.ctx.rotate(Math.PI/2); - this.ctx.drawImage(image, 0, 0, this.canvas.height, this.canvas.width); // draw video - this.ctx.restore(); - } else { - this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video - } - + // if (this.orientation === 'portrait') { + // this.ctx.save(); + // this.ctx.translate(this.canvas.width, 0); + // this.ctx.rotate(Math.PI/2); + // this.ctx.drawImage(image, 0, 0, this.canvas.height, this.canvas.width); // draw video + // this.ctx.restore(); + // } else { + // debugger + // this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video + // } + + + this.ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height); // draw video var imageData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); var data = imageData.data; -- GitLab