チェンジセット 2702: js

差分発生行の前後
無視リスト:
コミット日時:
2009/05/23 10:48:54 (3 年前)
コミッタ:
kawanet
ログメッセージ:

JSARToolKit - no json needed

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • js/JSARToolKit/trunk/js/jsar.js

    r2569 r2702  
    268268JSAR.prototype._lastDetected; 
    269269JSAR.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  
     270JSAR.prototype.detectCallback = function ( result ) { 
    278271    // marker object 
    279272    if ( result.detected ) { 
  • js/JSARToolKit/trunk/src/JSAR.as

    r2565 r2702  
    1 /*  
     1/* 
    22 * JSAR.as - JSARToolKit 
    33 * Copyright (c) 2009 Yusuke Kawasaki http://www.kawa.net/ 
    4  *  
     4 * 
    55 * Permission is hereby granted, free of charge, to any person 
    66 * obtaining a copy of this software and associated documentation 
     
    1111 * Software is furnished to do so, subject to the following 
    1212 * conditions: 
    13  *  
     13 * 
    1414 * The above copyright notice and this permission notice shall be 
    1515 * included in all copies or substantial portions of the Software. 
    16  *  
     16 * 
    1717 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    1818 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 
     
    2323 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
    2424 * OTHER DEALINGS IN THE SOFTWARE. 
    25  *  
     25 * 
    2626 */ 
    2727 
    2828package { 
    29      
     29 
    3030    import flash.display.Bitmap; 
    3131    import flash.display.BitmapData; 
     
    4141    import flash.net.URLLoaderDataFormat; 
    4242    import flash.net.URLRequest; 
    43          
    4443    import flash.external.ExternalInterface; 
    45      
    46     import com.adobe.serialization.json.JSONEncoder; 
    4744 
    4845    import org.libspark.flartoolkit.core.FLARCode; 
    4946    import org.libspark.flartoolkit.core.param.FLARParam; 
    5047    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; 
    5249    import org.libspark.flartoolkit.detector.FLARMultiMarkerDetector; 
    5350    import org.libspark.flartoolkit.detector.FLARMultiMarkerDetectorResult; 
     
    6966        private var _cameraReady:Boolean = false; 
    7067        private var _codeLoaded:int      = 0; 
    71          
     68 
    7269        private var _captureX:int        = 640; 
    7370        private var _captureY:int        = 480; 
     
    7976        private var _scaleY:Number       = 1.0; 
    8077                private var _enableMic:Boolean    = false; 
    81          
     78 
    8279        private var _codeSize:int        = 80; 
    8380        private var _codePixel:int       = 16; 
     
    8784        private var _raster:FLARRgbRaster_BitmapData; 
    8885        private var _detector:FLARMultiMarkerDetector; 
    89          
     86 
    9087        private var _camera:Camera; 
    9188        private var _video:Video; 
     
    111108            this._scaleX = 1.0 * this._displayX / this._captureX; 
    112109            this._scaleY = 1.0 * this._displayY / this._captureY; 
    113              
     110 
    114111            // setup webcam 
    115112            this._camera = Camera.getCamera(); 
     
    152149 
    153150        private function _onLoadedParam(e:Event):void { 
    154             // this._log( '_onLoadedParam e='+e ); 
     151            // this._info( '_onLoadedParam e='+e ); 
    155152            this._cameraLoader.removeEventListener(Event.COMPLETE, this._onLoadedParam); 
    156153 
     
    159156                         
    160157                        // set capture size again 
    161             this._param.changeScreenSize(this._captureX, this._captureY);    
     158            this._param.changeScreenSize(this._captureX, this._captureY); 
    162159 
    163160            // loading done 
    164161            this._cameraLoader.removeEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); 
    165162            this._cameraLoader.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.dispatchEvent); 
    166             this._cameraLoader = null;   
     163            this._cameraLoader = null; 
    167164            this._cameraReady  = true; 
    168165        } 
     
    178175            this._loadNextCode(); 
    179176        } 
    180          
     177 
    181178        private function _loadNextCode():void { 
    182             // this._log( '_loadNextCode _codeLoaded=' + this._codeLoaded + ' / ' + this._codeFiles.length ); 
     179            // this._info( '_loadNextCode _codeLoaded=' + this._codeLoaded + ' / ' + this._codeFiles.length ); 
    183180            if ( this._codeLoaded >= this._codeFiles.length ) { 
    184181                this._onCompleteLoadCode(); 
     
    186183                // load pattern file 
    187184                var codeFile:String = this._codeFiles[this._codeLoaded]; 
    188                 // this._log( '_loadNextCode codeFile=' + codeFile ); 
     185                // this._info( '_loadNextCode codeFile=' + codeFile ); 
    189186 
    190187                this._codeLoader.addEventListener(Event.COMPLETE, this._onLoadedCode); 
     
    193190            } 
    194191        } 
    195          
     192 
    196193        private function _onLoadedCode(e:Event):void { 
    197             // this._log( '_onLoadedCode _codeLoaded=' + this._codeLoaded ); 
     194            // this._info( '_onLoadedCode _codeLoaded=' + this._codeLoaded ); 
    198195            this._codeLoader.removeEventListener(Event.COMPLETE, this._onLoadedCode); 
    199              
     196 
    200197            var acode:FLARCode = new FLARCode(this._codePixel, this._codePixel); 
    201198            acode.loadARPatt(this._codeLoader.data); 
    202199 
    203200            this._codeList[this._codeLoaded] = acode; 
    204             this._codeSizes[this._codeLoaded] = this._codeSize;      
     201            this._codeSizes[this._codeLoaded] = this._codeSize; 
    205202            this._codeLoaded ++; 
    206203            this._loadNextCode(); 
    207204        } 
    208          
     205 
    209206        private function _onCompleteLoadCode():void { 
    210             // this._log( '_onCompleteLoadCode this._codeLoaded=' + this._codeLoaded ); 
    211              
     207            // this._info( '_onCompleteLoadCode this._codeLoaded=' + this._codeLoaded ); 
     208 
    212209            // loading done 
    213210            this._codeLoader.removeEventListener(IOErrorEvent.IO_ERROR, this.dispatchEvent); 
     
    223220            this._getDetectResult( arg ); 
    224221            if ( arg.error ) { 
    225                 this._log( 'detection failed: ' + arg.error); 
     222                this._info( 'detection failed: ' + arg.error); 
    226223            } 
    227224            this._call_javascript( callback, arg ); 
    228225        } 
    229              
     226 
    230227        private function _getDetectResult( arg:Object ):void { 
    231228            // camera is denied by user 
     
    244241                        if (this._mic) { 
    245242                                var vol:Number = this._mic.activityLevel 
    246 //                              this._log( 'vol='+vol ); 
     243//                              this._info( 'vol='+vol ); 
    247244                                if ( vol >= 0 ) arg.mic = vol; 
    248245                        } 
     
    277274                        y: Math.floor(ipoint.y * this._scaleY) 
    278275                    }; 
    279                     // this._log( 'x=' + apoint.x + ' y=' + apoint.y ); 
     276                    // this._info( 'x=' + apoint.x + ' y=' + apoint.y ); 
    280277                    vertex[j] = apoint; 
    281278                } 
     
    288285                markers.push( hash ); 
    289286            } 
    290              
     287 
    291288            if ( markers.length > 0 ) { 
    292289                arg.detected = true; 
     
    295292        } 
    296293 
    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                        } 
    305306        } 
    306307    } 
  • js/JSARToolKit/trunk/src/JSAR.as3proj

    r2560 r2702  
    1414  <!-- Other classes to be compiled into your SWF --> 
    1515  <classpaths> 
    16     <!-- example: <class path="..." /> --
     16    <class path="../../../../as3/FLARToolKit/trunk/src" /
    1717  </classpaths> 
    1818  <!-- Build options --> 
     
    7777  <options> 
    7878    <option showHiddenPaths="False" /> 
    79     <option testMovie="NewTab" /> 
     79    <option testMovie="OpenDocument" /> 
     80    <option testMovieCommand="../examples/jsarlogo.html" /> 
    8081  </options> 
    8182</project>