- コミット日時:
- 2009/05/23 10:48:54 (3 年前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
js/JSARToolKit/trunk/js/jsar.js
r2569 r2702 268 268 JSAR.prototype._lastDetected; 269 269 JSAR.prototype._captureStarted; 270 JSAR.prototype.detectCallback = function ( json ) { 271 var result = eval("("+json+")"); 272 273 // console log 274 if ( result.detected ) { 275 // this._log( json ); 276 } 277 270 JSAR.prototype.detectCallback = function ( result ) { 278 271 // marker object 279 272 if ( result.detected ) { js/JSARToolKit/trunk/src/JSAR.as
r2565 r2702 1 /* 1 /* 2 2 * JSAR.as - JSARToolKit 3 3 * Copyright (c) 2009 Yusuke Kawasaki http://www.kawa.net/ 4 * 4 * 5 5 * Permission is hereby granted, free of charge, to any person 6 6 * obtaining a copy of this software and associated documentation … … 11 11 * Software is furnished to do so, subject to the following 12 12 * conditions: 13 * 13 * 14 14 * The above copyright notice and this permission notice shall be 15 15 * included in all copies or substantial portions of the Software. 16 * 16 * 17 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 18 18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES … … 23 23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 24 24 * OTHER DEALINGS IN THE SOFTWARE. 25 * 25 * 26 26 */ 27 27 28 28 package { 29 29 30 30 import flash.display.Bitmap; 31 31 import flash.display.BitmapData; … … 41 41 import flash.net.URLLoaderDataFormat; 42 42 import flash.net.URLRequest; 43 44 43 import flash.external.ExternalInterface; 45 46 import com.adobe.serialization.json.JSONEncoder;47 44 48 45 import org.libspark.flartoolkit.core.FLARCode; 49 46 import org.libspark.flartoolkit.core.param.FLARParam; 50 47 import org.libspark.flartoolkit.core.types.FLARIntPoint; 51 import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData; 48 import org.libspark.flartoolkit.core.raster.rgb.FLARRgbRaster_BitmapData; 52 49 import org.libspark.flartoolkit.detector.FLARMultiMarkerDetector; 53 50 import org.libspark.flartoolkit.detector.FLARMultiMarkerDetectorResult; … … 69 66 private var _cameraReady:Boolean = false; 70 67 private var _codeLoaded:int = 0; 71 68 72 69 private var _captureX:int = 640; 73 70 private var _captureY:int = 480; … … 79 76 private var _scaleY:Number = 1.0; 80 77 private var _enableMic:Boolean = false; 81 78 82 79 private var _codeSize:int = 80; 83 80 private var _codePixel:int = 16; … … 87 84 private var _raster:FLARRgbRaster_BitmapData; 88 85 private var _detector:FLARMultiMarkerDetector; 89 86 90 87 private var _camera:Camera; 91 88 private var _video:Video; … … 111 108 this._scaleX = 1.0 * this._displayX / this._captureX; 112 109 this._scaleY = 1.0 * this._displayY / this._captureY; 113 110 114 111 // setup webcam 115 112 this._camera = Camera.getCamera(); … … 152 149 153 150 private function _onLoadedParam(e:Event):void { 154 // this._ log( '_onLoadedParam e='+e );151 // this._info( '_onLoadedParam e='+e ); 155 152 this._cameraLoader.removeEventListener(Event.COMPLETE, this._onLoadedParam); 156 153 … … 159 156 160 157 // set capture size again 161 this._param.changeScreenSize(this._captureX, this._captureY); 158 this._param.changeScreenSize(this._captureX, this._captureY); 162 159 163 160 // loading done 164 161 this._cameraLoader.removeEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); 165 162 this._cameraLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.dispatchEvent); 166 this._cameraLoader = null; 163 this._cameraLoader = null; 167 164 this._cameraReady = true; 168 165 } … … 178 175 this._loadNextCode(); 179 176 } 180 177 181 178 private function _loadNextCode():void { 182 // this._ log( '_loadNextCode _codeLoaded=' + this._codeLoaded + ' / ' + this._codeFiles.length );179 // this._info( '_loadNextCode _codeLoaded=' + this._codeLoaded + ' / ' + this._codeFiles.length ); 183 180 if ( this._codeLoaded >= this._codeFiles.length ) { 184 181 this._onCompleteLoadCode(); … … 186 183 // load pattern file 187 184 var codeFile:String = this._codeFiles[this._codeLoaded]; 188 // this._ log( '_loadNextCode codeFile=' + codeFile );185 // this._info( '_loadNextCode codeFile=' + codeFile ); 189 186 190 187 this._codeLoader.addEventListener(Event.COMPLETE, this._onLoadedCode); … … 193 190 } 194 191 } 195 192 196 193 private function _onLoadedCode(e:Event):void { 197 // this._ log( '_onLoadedCode _codeLoaded=' + this._codeLoaded );194 // this._info( '_onLoadedCode _codeLoaded=' + this._codeLoaded ); 198 195 this._codeLoader.removeEventListener(Event.COMPLETE, this._onLoadedCode); 199 196 200 197 var acode:FLARCode = new FLARCode(this._codePixel, this._codePixel); 201 198 acode.loadARPatt(this._codeLoader.data); 202 199 203 200 this._codeList[this._codeLoaded] = acode; 204 this._codeSizes[this._codeLoaded] = this._codeSize; 201 this._codeSizes[this._codeLoaded] = this._codeSize; 205 202 this._codeLoaded ++; 206 203 this._loadNextCode(); 207 204 } 208 205 209 206 private function _onCompleteLoadCode():void { 210 // this._ log( '_onCompleteLoadCode this._codeLoaded=' + this._codeLoaded );211 207 // this._info( '_onCompleteLoadCode this._codeLoaded=' + this._codeLoaded ); 208 212 209 // loading done 213 210 this._codeLoader.removeEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); … … 223 220 this._getDetectResult( arg ); 224 221 if ( arg.error ) { 225 this._ log( 'detection failed: ' + arg.error);222 this._info( 'detection failed: ' + arg.error); 226 223 } 227 224 this._call_javascript( callback, arg ); 228 225 } 229 226 230 227 private function _getDetectResult( arg:Object ):void { 231 228 // camera is denied by user … … 244 241 if (this._mic) { 245 242 var vol:Number = this._mic.activityLevel 246 // this._ log( 'vol='+vol );243 // this._info( 'vol='+vol ); 247 244 if ( vol >= 0 ) arg.mic = vol; 248 245 } … … 277 274 y: Math.floor(ipoint.y * this._scaleY) 278 275 }; 279 // this._ log( 'x=' + apoint.x + ' y=' + apoint.y );276 // this._info( 'x=' + apoint.x + ' y=' + apoint.y ); 280 277 vertex[j] = apoint; 281 278 } … … 288 285 markers.push( hash ); 289 286 } 290 287 291 288 if ( markers.length > 0 ) { 292 289 arg.detected = true; … … 295 292 } 296 293 297 private function _log( mess:String ):void { 298 ExternalInterface.call( "(function(){if(window.console)console.log('"+mess+"');})" ); 299 } 300 301 private function _call_javascript( callback:String, arg:* ):void { 302 var str:String = new JSONEncoder( arg ).getString(); 303 // ExternalInterface.call( "(function(){function(){"+callback+"('"+str+"');})" ); 304 ExternalInterface.call( "(function(){window.setTimeout(function(){"+callback+"('"+str+"');},1);})" ); 294 // message to javascript console 295 private function _info( mess:String ):void { 296 ExternalInterface.call( "(function(m){if(window.console)console.log(m);})",mess ); 297 } 298 299 // javascript callback 300 private function _call_javascript( ... args ):void { 301 try { 302 ExternalInterface.call.apply( null, args ); 303 } catch (e:Error) { 304 this._err( 'callback failed: ' + e.message ); 305 } 305 306 } 306 307 } js/JSARToolKit/trunk/src/JSAR.as3proj
r2560 r2702 14 14 <!-- Other classes to be compiled into your SWF --> 15 15 <classpaths> 16 < !-- example: <class path="..." /> -->16 <class path="../../../../as3/FLARToolKit/trunk/src" /> 17 17 </classpaths> 18 18 <!-- Build options --> … … 77 77 <options> 78 78 <option showHiddenPaths="False" /> 79 <option testMovie="NewTab" /> 79 <option testMovie="OpenDocument" /> 80 <option testMovieCommand="../examples/jsarlogo.html" /> 80 81 </options> 81 82 </project>

