diff --git a/three.js/TODO.md b/three.js/TODO.md deleted file mode 100644 index 9280c02523f5852d4144cbb34a347a4037adc7ba..0000000000000000000000000000000000000000 --- a/three.js/TODO.md +++ /dev/null @@ -1,5 +0,0 @@ -- GOAL: works well using only the positional tracking, not the stereo display - - thus it works well with all three.js examples -- handle resize - currently the canvas isnt using the css it should - -- LATER: make it work with a-frame diff --git a/three.js/examples/dev.html b/three.js/examples/dev.html index 91b863768c82fce148c30e411573b2e53c7248f5..80dc8a9a3cefb2a6c0d0ea40daf1b7027f8e4bd5 100644 --- a/three.js/examples/dev.html +++ b/three.js/examples/dev.html @@ -9,6 +9,7 @@ +
@@ -58,22 +59,10 @@ // handle arToolkitSource //////////////////////////////////////////////////////////////////////////////// - var arToolkitSource = new THREEx.ArToolkitSource({ - // to read from the webcam - sourceType : 'webcam', - - // to read from an image - // sourceType : 'image', - // sourceUrl : '../../data/images/img.jpg', - - // to read from a video - // sourceType : 'video', - // sourceUrl : '../../data/videos/headtracking.mp4', - - // sourceWidth: 80*3, - // sourceHeight: 60*3, - // - }) + + var artoolkitProfile = new THREEx.ArToolkitProfile('guess') + + var arToolkitSource = new THREEx.ArToolkitSource(artoolkitProfile.sourceParameters) arToolkitSource.init(function onReady(){ // handle resize of renderer @@ -91,14 +80,7 @@ // create atToolkitContext - var arToolkitContext = new THREEx.ArToolkitContext({ - cameraParametersUrl: '../../data/data/camera_para.dat', - detectionMode: 'mono', - imageSmoothingEnabled: false, - maxDetectionRate: 30, - sourceWidth: arToolkitSource.parameters.sourceWidth, - sourceHeight: arToolkitSource.parameters.sourceHeight, - }) + var arToolkitContext = new THREEx.ArToolkitContext(artoolkitProfile.contextParameters) // initialize it arToolkitContext.init(function onCompleted(){ // copy projection matrix to camera @@ -120,11 +102,7 @@ var markerRoot = new THREE.Group scene.add(markerRoot) - var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, { - type : 'pattern', - patternUrl : '../../data/data/patt.hiro' - // patternUrl : '../../data/data/patt.kanji' - }) + var artoolkitMarker = new THREEx.ArMarkerControls(arToolkitContext, markerRoot, artoolkitProfile.defaultMarkerParameters) ////////////////////////////////////////////////////////////////////////////////// // add an object in the scene diff --git a/three.js/threex-artoolkitcontext.js b/three.js/threex-artoolkitcontext.js index 6360fe299fc561e70a07fcb3a9b7c39780f1f55c..560aad7e504ee24307afe5a70d7488fcab696627 100644 --- a/three.js/threex-artoolkitcontext.js +++ b/three.js/threex-artoolkitcontext.js @@ -25,7 +25,7 @@ THREEx.ArToolkitContext = function(parameters){ // enable image smoothing or not for canvas copy - default to true // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/imageSmoothingEnabled - imageSmoothingEnabled : parameters.imageSmoothingEnabled !== undefined ? parameters.imageSmoothingEnabled : true, + imageSmoothingEnabled : parameters.imageSmoothingEnabled !== undefined ? parameters.imageSmoothingEnabled : false, } this.arController = null; diff --git a/three.js/threex-artoolkitprofile.js b/three.js/threex-artoolkitprofile.js new file mode 100644 index 0000000000000000000000000000000000000000..b2e55b0a607cc6b6c6215ed3d9429470d4f6482e --- /dev/null +++ b/three.js/threex-artoolkitprofile.js @@ -0,0 +1,89 @@ +var THREEx = THREEx || {} + +THREEx.ArToolkitProfile = function(label){ + if( label === 'guess' ) label = this._guessLabel() + + this.reset() + this.setProfile(label) +} + +THREEx.ArToolkitProfile.prototype.reset = function () { + this.sourceParameters = {} + this.contextParameters = {} + this.defaultMarkerParameters = {} +}; + +THREEx.ArToolkitProfile.prototype._guessLabel = function () { + // TODO implement this + return 'desktop' +}; + +THREEx.ArToolkitProfile.prototype.setProfile = function (label) { + if( 'desktop' ){ + this.desktopProfile() + }else if( 'mobile' ){ + this.mobileProfile() + }else console.assert('false') +}; + +THREEx.ArToolkitProfile.prototype.desktopProfile = function () { + this.sourceParameters = { + // to read from the webcam + sourceType : 'webcam', + + // to read from an image + // sourceType : 'image', + // sourceUrl : '../../data/images/img.jpg', + + // to read from a video + // sourceType : 'video', + // sourceUrl : '../../data/videos/headtracking.mp4', + + // sourceWidth: 80*3, + // sourceHeight: 60*3, + // + } + + this.contextParameters = { + cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat', + detectionMode: 'mono', + maxDetectionRate: 30, + } + this.defaultMarkerParameters = { + type : 'pattern', + // patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro' + patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji' + } +} + +THREEx.ArToolkitProfile.prototype.mobileProfile = function () { + this.sourceParameters = { + // to read from the webcam + sourceType : 'webcam', + + // to read from an image + // sourceType : 'image', + // sourceUrl : '../../data/images/img.jpg', + + // to read from a video + // sourceType : 'video', + // sourceUrl : '../../data/videos/headtracking.mp4', + + sourceWidth: 80*3, + sourceHeight: 60*3, + // + } + + this.contextParameters = { + cameraParametersUrl: THREEx.ArToolkitContext.baseURL + '../data/data/camera_para.dat', + detectionMode: 'mono', + maxDetectionRate: 30, + sourceWidth: this.sourceParameters.sourceWidth, + sourceHeight: this.sourceParameters.sourceHeight, + } + this.defaultMarkerParameters = { + type : 'pattern', + // patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.hiro' + patternUrl : THREEx.ArToolkitContext.baseURL + '../data/data/patt.kanji' + } +}