From 02fddda5cc52575a5fba22b895ead128efb2b4ff Mon Sep 17 00:00:00 2001 From: Jerome Etienne Date: Sat, 29 Apr 2017 11:39:21 +0100 Subject: [PATCH] more work --- README.md | 3 +- TODO.md | 1 - three.js/examples/multi-markers/ALGO.md | 71 ------------------ three.js/examples/multi-markers/README.md | 75 +++++++++++++++++++ three.js/examples/multi-markers/TODO.md | 36 ++++----- .../multi-markers/examples/learner.html | 2 + .../multi-markers/examples/player.html | 2 - three.js/threex-arbasecontrols.js | 24 ++++++ three.js/threex-arsmoothedcontrols.js | 2 +- 9 files changed, 118 insertions(+), 98 deletions(-) delete mode 100644 three.js/examples/multi-markers/ALGO.md create mode 100644 three.js/threex-arbasecontrols.js diff --git a/README.md b/README.md index 1917299..209282a 100644 --- a/README.md +++ b/README.md @@ -106,8 +106,7 @@ by ```html - - + diff --git a/TODO.md b/TODO.md index bab6c27..f0782b2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,6 @@ - do a webvr demo with a hole in the ground. - good for tango - possible demo: hole in the wall, refraction, liquid marker but on all the wall - - release soon and start doing dev/master - create a dev branch - release AR.js as 1.2 diff --git a/three.js/examples/multi-markers/ALGO.md b/three.js/examples/multi-markers/ALGO.md deleted file mode 100644 index fae9837..0000000 --- a/three.js/examples/multi-markers/ALGO.md +++ /dev/null @@ -1,71 +0,0 @@ -# High Level Description - -The workflow is splitted into 3 steps : - -1. collect statistics about the relative position of each marker couple -1. generation of multi-marker description -1. using the multi-marker - -So we first have a learning phase to collect data and generating result, then -we have a usage phase, where the multi-marker is used in a AR application. - -So in short, you put all your markers where you like them. Then you scan them -with your phone to collect statistics about their relative position. -When you are done, you start using the AR application with this multi-marker. - -# Definitions -- a multi-marker is several markers acting as one -- a markerA is said to be a sub-marker of a multi-marker - -# Learning Algo description -- every time i see markerA and markerB at the same time, i store statistics on their relative position -- such couple is called a seen-couple -- the statistics collected are simply an average of position/quaternion/scale -- this statistics can be trivially expressed as a transformation matrix - -# Generation of Multi-Marker description -- when the learning is considered completed, we generate a multi marker description - - it is a json file in which each sub-markers has a transformation matrix relative to the origin sub-marker -- the first sub-marker is the anchor/root sub-marker. -- The origin position of the multi-marker is the origin sub-marker -- the origin sub-marker MUST be seen at least once during the learning phase - -## Description Format -- the description format is simple: -- it is a list with one item for each sub-markers - - it contains a description of the sub-markers (e.g. marker barcode 3) - - and a poseMatrix which is the transformation matrix relative to the origin sub-markers - - the first item is the origin sub-marker - - ---- - -# Computation of the average matrix for each sub-marker - -Once statistics are collected, we need to produce a description of this new -area. This is a json structure describing each sub-marker and their respective -position. - -Here are the algo which can be used - -## Minimal Algo - assume origin always visible -- Assume that the origin sub-marker is ALWAYS visible -- Look on all the seen-couple of the origin sub-marker -- for each sub-markers, you got the relative position with the origin sub-marker -- just generate the transformation matrix for it - -This is the one implemented - -## Minimal Algo - origin may sometime be invisible -- do first pass where you compute all couple which contain the origin submarkers -- so you computed the transformation matrix for each sub-marker which has been - visible with the origin marker -- you computed the level 1 of transformation matrices -- the level 0 would the transformation matrix of the origin sub-marker. But it is - always the identity matrix. -- you do an iterative process, where each iterations compute one more level. - -Algo for one iteration -1. for each sub-markers, check all the seen couple it appears in -2. if at least one already has a transformation matrix, compute the transformation -3. Loop until all sub-markers got computed diff --git a/three.js/examples/multi-markers/README.md b/three.js/examples/multi-markers/README.md index 6a0f4a1..c791e0c 100644 --- a/three.js/examples/multi-markers/README.md +++ b/three.js/examples/multi-markers/README.md @@ -35,3 +35,78 @@ Thus even if only one sub-marker is visible, multi-marker position will still be I tried to workaround those issues, but it rapidely became a pain. So i prefered to devote my energy at building a good version instead of working around those bugs. + + +--- + +# High Level Description + +The workflow is splitted into 3 steps : + +1. collect statistics about the relative position of each marker couple +1. generation of multi-marker description +1. using the multi-marker + +So we first have a learning phase to collect data and generating result, then +we have a usage phase, where the multi-marker is used in a AR application. + +So in short, you put all your markers where you like them. Then you scan them +with your phone to collect statistics about their relative position. +When you are done, you start using the AR application with this multi-marker. + +# Definitions +- a multi-marker is several markers acting as one +- a markerA is said to be a sub-marker of a multi-marker + +# Learning Algo description +- every time i see markerA and markerB at the same time, i store statistics on their relative position +- such couple is called a seen-couple +- the statistics collected are simply an average of position/quaternion/scale +- this statistics can be trivially expressed as a transformation matrix + +# Generation of Multi-Marker description +- when the learning is considered completed, we generate a multi marker description + - it is a json file in which each sub-markers has a transformation matrix relative to the origin sub-marker +- the first sub-marker is the anchor/root sub-marker. +- The origin position of the multi-marker is the origin sub-marker +- the origin sub-marker MUST be seen at least once during the learning phase + +## Description Format +- the description format is simple: +- it is a list with one item for each sub-markers + - it contains a description of the sub-markers (e.g. marker barcode 3) + - and a poseMatrix which is the transformation matrix relative to the origin sub-markers + - the first item is the origin sub-marker + + +--- + +# Computation of the average matrix for each sub-marker + +Once statistics are collected, we need to produce a description of this new +area. This is a json structure describing each sub-marker and their respective +position. + +Here are the algo which can be used + +## Minimal Algo - assume origin always visible +- Assume that the origin sub-marker is ALWAYS visible +- Look on all the seen-couple of the origin sub-marker +- for each sub-markers, you got the relative position with the origin sub-marker +- just generate the transformation matrix for it + +This is the one implemented + +## Minimal Algo - origin may sometime be invisible +- do first pass where you compute all couple which contain the origin submarkers +- so you computed the transformation matrix for each sub-marker which has been + visible with the origin marker +- you computed the level 1 of transformation matrices +- the level 0 would the transformation matrix of the origin sub-marker. But it is + always the identity matrix. +- you do an iterative process, where each iterations compute one more level. + +Algo for one iteration +1. for each sub-markers, check all the seen couple it appears in +2. if at least one already has a transformation matrix, compute the transformation +3. Loop until all sub-markers got computed diff --git a/three.js/examples/multi-markers/TODO.md b/three.js/examples/multi-markers/TODO.md index b5f1160..c4e3a48 100644 --- a/three.js/examples/multi-markers/TODO.md +++ b/three.js/examples/multi-markers/TODO.md @@ -1,31 +1,25 @@ +- what to do with the official multimarker support + - make an example for it, and keep supporting it + +- make all markers children of a parent THREEx.ArBaseControls() + - GOAL: make it explicit what is expected from a AR controls + - emit event + - have id + - anything which is common + - TODO put a smoother on sub-marker while learning ? as a way to remove noise ? + - do it and hide it behind a flags + - in relation with THREEx.ArBaseControls - do an apps which does something with it - - a minecraft going from markers to markers + - a minecraft going from submarkers to submarkers - add a-frame support - - support for learning new area + - support for learning new area - can i just use the area-learner.html - support of multi-marker description -- do a post about multimarker - - how to use them, - - workflow: learning then using - - pro: larger area can be coverded by - -- what to do with the official multimarker support - - make an example for it, and keep supporting it - - - -# How to compute the result of the learning -- we got statistics on the position/orientation/scale between each marker seen simultaneously -- we want a transposition matrix relative to the origin markersControls +- do a post about multimarker - https://medium.com/p/4bcafc785dfd/edit -- step1 - build the transposition matrix relative the origin marker controls - - store it in the userData - - use similar format as local matrix -- step2 - generate the file - -- LATER: how to get more robust statistics? +- DONE merge it all in the README.md diff --git a/three.js/examples/multi-markers/examples/learner.html b/three.js/examples/multi-markers/examples/learner.html index 2ae6e25..9381db6 100644 --- a/three.js/examples/multi-markers/examples/learner.html +++ b/three.js/examples/multi-markers/examples/learner.html @@ -164,6 +164,8 @@ markerControls.object3d.add( markerHelper.object3d ) } + // TODO here put a THREEx.ArSmoothedControls behind a flag - could be useful for tunning + // store it in the parameters subMarkersControls.push(markerControls) }) diff --git a/three.js/examples/multi-markers/examples/player.html b/three.js/examples/multi-markers/examples/player.html index a327e06..1c22d77 100644 --- a/three.js/examples/multi-markers/examples/player.html +++ b/three.js/examples/multi-markers/examples/player.html @@ -302,8 +302,6 @@ multiMarkerPlay(JSON.stringify(multiMarkerFile)) } - - ////////////////////////////////////////////////////////////////////////////////// // render the whole thing on the page diff --git a/three.js/threex-arbasecontrols.js b/three.js/threex-arbasecontrols.js new file mode 100644 index 0000000..e179f66 --- /dev/null +++ b/three.js/threex-arbasecontrols.js @@ -0,0 +1,24 @@ +var THREEx = THREEx || {} + +THREEx.ArBaseControls = function(object3d){ + this.id = THREEx.ArBaseControls.id++ + this.object3d = object3d + + // Events to honor + // this.dispatchEvent({ type: 'becameVisible' }) + // this.dispatchEvent({ type: 'becameUnVisible' }) +} + +THREEx.ArBaseControls.id = 0 + +Object.assign( THREEx.ArBaseControls.prototype, THREE.EventDispatcher.prototype ); + +////////////////////////////////////////////////////////////////////////////// +// Functions +////////////////////////////////////////////////////////////////////////////// +/** + * error catching function for update() + */ +THREEx.ArBaseControls.prototype.update = function(){ + console.assert(false, 'you need to implement your own update') +} diff --git a/three.js/threex-arsmoothedcontrols.js b/three.js/threex-arsmoothedcontrols.js index 6f99394..ed118f0 100644 --- a/three.js/threex-arsmoothedcontrols.js +++ b/three.js/threex-arsmoothedcontrols.js @@ -103,7 +103,7 @@ THREEx.ArSmoothedControls.prototype.update = function(targetObject3d){ object3d.scale.lerp(targetObject3d.scale, parameters.lerpScale) } - // disabled the lerp by directly copying targetObject3d position/quaternion/scale + // disable the lerp by directly copying targetObject3d position/quaternion/scale // if( false ){ // this.object3d.position.copy( targetObject3d.position ) // this.object3d.quaternion.copy( targetObject3d.quaternion ) -- GitLab