idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
148,300 | public static GVRTexture loadFutureCubemapTexture ( GVRContext gvrContext , ResourceCache < GVRImage > textureCache , GVRAndroidResource resource , int priority , Map < String , Integer > faceIndexMap ) { GVRTexture tex = new GVRTexture ( gvrContext ) ; GVRImage cached = textureCache . get ( resource ) ; if ( cached != null ) { Log . v ( "ASSET" , "Future Texture: %s loaded from cache" , cached . getFileName ( ) ) ; tex . setImage ( cached ) ; } else { AsyncCubemapTexture . get ( ) . loadTexture ( gvrContext , CancelableCallbackWrapper . wrap ( GVRCubemapImage . class , tex ) , resource , priority , faceIndexMap ) ; } return tex ; } | Load a cube map texture asynchronously . | 177 | 9 |
148,301 | public static void loadCubemapTexture ( final GVRContext context , ResourceCache < GVRImage > textureCache , final TextureCallback callback , final GVRAndroidResource resource , int priority , Map < String , Integer > faceIndexMap ) throws IllegalArgumentException { validatePriorityCallbackParameters ( context , callback , resource , priority ) ; final GVRImage cached = textureCache == null ? null : ( GVRImage ) textureCache . get ( resource ) ; if ( cached != null ) { Log . v ( "ASSET" , "Texture: %s loaded from cache" , cached . getFileName ( ) ) ; context . runOnGlThread ( new Runnable ( ) { @ Override public void run ( ) { callback . loaded ( cached , resource ) ; } } ) ; } else { TextureCallback actualCallback = ( textureCache == null ) ? callback : ResourceCache . wrapCallback ( textureCache , callback ) ; AsyncCubemapTexture . loadTexture ( context , CancelableCallbackWrapper . wrap ( GVRCubemapImage . class , actualCallback ) , resource , priority , faceIndexMap ) ; } } | Load a cubemap texture asynchronously . | 242 | 10 |
148,302 | public static Bitmap decodeStream ( InputStream stream , boolean closeStream ) { return AsyncBitmapTexture . decodeStream ( stream , AsyncBitmapTexture . glMaxTextureSize , AsyncBitmapTexture . glMaxTextureSize , true , null , closeStream ) ; } | An internal method public only so that GVRContext can make cross - package calls . | 59 | 17 |
148,303 | public GVRShaderId getShaderType ( Class < ? extends GVRShader > shaderClass ) { GVRShaderId shaderId = mShaderTemplates . get ( shaderClass ) ; if ( shaderId == null ) { GVRContext ctx = getGVRContext ( ) ; shaderId = new GVRShaderId ( shaderClass ) ; mShaderTemplates . put ( shaderClass , shaderId ) ; shaderId . getTemplate ( ctx ) ; } return shaderId ; } | Retrieves the Material Shader ID associated with the given shader template class . | 110 | 16 |
148,304 | static String makeLayout ( String descriptor , String blockName , boolean useUBO ) { return NativeShaderManager . makeLayout ( descriptor , blockName , useUBO ) ; } | Make a string with the shader layout for a uniform block with a given descriptor . The format of the descriptor is the same as for a | 38 | 27 |
148,305 | public void rotateWithPivot ( float quatW , float quatX , float quatY , float quatZ , float pivotX , float pivotY , float pivotZ ) { NativeTransform . rotateWithPivot ( getNative ( ) , quatW , quatX , quatY , quatZ , pivotX , pivotY , pivotZ ) ; } | Modify the transform s current rotation in quaternion terms around a pivot other than the origin . | 80 | 20 |
148,306 | public static void setFaceNames ( String [ ] nameArray ) { if ( nameArray . length != 6 ) { throw new IllegalArgumentException ( "nameArray length is not 6." ) ; } for ( int i = 0 ; i < 6 ; i ++ ) { faceIndexMap . put ( nameArray [ i ] , i ) ; } } | Set the names of six images in the zip file . The default names of the six images are posx . png negx . png posy . png negx . png posz . png and negz . png . If the names of the six images in the zip file are different to the default ones this function must be called before load the zip file . | 74 | 79 |
148,307 | public boolean startDrag ( final GVRSceneObject sceneObject , final float hitX , final float hitY , final float hitZ ) { final GVRRigidBody dragMe = ( GVRRigidBody ) sceneObject . getComponent ( GVRRigidBody . getComponentType ( ) ) ; if ( dragMe == null || dragMe . getSimulationType ( ) != GVRRigidBody . DYNAMIC || ! contains ( dragMe ) ) return false ; GVRTransform t = sceneObject . getTransform ( ) ; final Vector3f relPos = new Vector3f ( hitX , hitY , hitZ ) ; relPos . mul ( t . getScaleX ( ) , t . getScaleY ( ) , t . getScaleZ ( ) ) ; relPos . rotate ( new Quaternionf ( t . getRotationX ( ) , t . getRotationY ( ) , t . getRotationZ ( ) , t . getRotationW ( ) ) ) ; final GVRSceneObject pivotObject = mPhysicsDragger . startDrag ( sceneObject , relPos . x , relPos . y , relPos . z ) ; if ( pivotObject == null ) return false ; mPhysicsContext . runOnPhysicsThread ( new Runnable ( ) { @ Override public void run ( ) { mRigidBodyDragMe = dragMe ; NativePhysics3DWorld . startDrag ( getNative ( ) , pivotObject . getNative ( ) , dragMe . getNative ( ) , hitX , hitY , hitZ ) ; } } ) ; return true ; } | Start the drag operation of a scene object with a rigid body . | 353 | 13 |
148,308 | public void stopDrag ( ) { mPhysicsDragger . stopDrag ( ) ; mPhysicsContext . runOnPhysicsThread ( new Runnable ( ) { @ Override public void run ( ) { if ( mRigidBodyDragMe != null ) { NativePhysics3DWorld . stopDrag ( getNative ( ) ) ; mRigidBodyDragMe = null ; } } } ) ; } | Stop the drag action . | 90 | 5 |
148,309 | public void setValue ( Vector3f scale ) { mX = scale . x ; mY = scale . y ; mZ = scale . z ; } | Sets the scale vector of the keyframe . | 33 | 10 |
148,310 | public void selectByName ( String childName ) { int i = 0 ; GVRSceneObject owner = getOwnerObject ( ) ; if ( owner == null ) { return ; } for ( GVRSceneObject child : owner . children ( ) ) { if ( child . getName ( ) . equals ( childName ) ) { mSwitchIndex = i ; return ; } ++ i ; } } | Sets the current switch index based on object name . This function finds the child of the scene object this component is attached to and sets the switch index to reference it so this is the object that will be displayed . | 83 | 43 |
148,311 | public void onAttach ( GVRSceneObject sceneObj ) { super . onAttach ( sceneObj ) ; GVRComponent comp = getComponent ( GVRRenderData . getComponentType ( ) ) ; if ( comp == null ) { throw new IllegalStateException ( "Cannot attach a morph to a scene object without a base mesh" ) ; } GVRMesh mesh = ( ( GVRRenderData ) comp ) . getMesh ( ) ; if ( mesh == null ) { throw new IllegalStateException ( "Cannot attach a morph to a scene object without a base mesh" ) ; } GVRShaderData mtl = getMaterial ( ) ; if ( ( mtl == null ) || ! mtl . getTextureDescriptor ( ) . contains ( "blendshapeTexture" ) ) { throw new IllegalStateException ( "Scene object shader does not support morphing" ) ; } copyBaseShape ( mesh . getVertexBuffer ( ) ) ; mtl . setInt ( "u_numblendshapes" , mNumBlendShapes ) ; mtl . setFloatArray ( "u_blendweights" , mWeights ) ; } | Attaches a morph to scene object with a base mesh | 248 | 11 |
148,312 | protected boolean intersect ( GVRSceneObject . BoundingVolume bv1 , GVRSceneObject . BoundingVolume bv2 ) { return ( bv1 . maxCorner . x >= bv2 . minCorner . x ) && ( bv1 . maxCorner . y >= bv2 . minCorner . y ) && ( bv1 . maxCorner . z >= bv2 . minCorner . z ) && ( bv1 . minCorner . x <= bv2 . maxCorner . x ) && ( bv1 . minCorner . y <= bv2 . maxCorner . y ) && ( bv1 . minCorner . z <= bv2 . maxCorner . z ) ; } | Determines whether or not two axially aligned bounding boxes in the same coordinate space intersect . | 163 | 20 |
148,313 | public static GVRVideoSceneObjectPlayer < MediaPlayer > makePlayerInstance ( final MediaPlayer mediaPlayer ) { return new GVRVideoSceneObjectPlayer < MediaPlayer > ( ) { @ Override public MediaPlayer getPlayer ( ) { return mediaPlayer ; } @ Override public void setSurface ( Surface surface ) { mediaPlayer . setSurface ( surface ) ; } @ Override public void release ( ) { mediaPlayer . release ( ) ; } @ Override public boolean canReleaseSurfaceImmediately ( ) { return true ; } @ Override public void pause ( ) { try { mediaPlayer . pause ( ) ; } catch ( final IllegalStateException exc ) { //intentionally ignored; might have been released already or never got to be //initialized } } @ Override public void start ( ) { mediaPlayer . start ( ) ; } @ Override public boolean isPlaying ( ) { return mediaPlayer . isPlaying ( ) ; } } ; } | Creates a player wrapper for the Android MediaPlayer . | 200 | 11 |
148,314 | public void setRefreshFrequency ( IntervalFrequency frequency ) { if ( NONE_REFRESH_INTERVAL == mRefreshInterval && IntervalFrequency . NONE != frequency ) { // Install draw-frame listener if frequency is no longer NONE getGVRContext ( ) . unregisterDrawFrameListener ( mFrameListener ) ; getGVRContext ( ) . registerDrawFrameListener ( mFrameListener ) ; } switch ( frequency ) { case REALTIME : mRefreshInterval = REALTIME_REFRESH_INTERVAL ; break ; case HIGH : mRefreshInterval = HIGH_REFRESH_INTERVAL ; break ; case MEDIUM : mRefreshInterval = MEDIUM_REFRESH_INTERVAL ; break ; case LOW : mRefreshInterval = LOW_REFRESH_INTERVAL ; break ; case NONE : mRefreshInterval = NONE_REFRESH_INTERVAL ; break ; default : break ; } } | Set the refresh frequency of this scene object . Use NONE for improved performance when the text is set initially and never changed . | 212 | 25 |
148,315 | public IntervalFrequency getRefreshFrequency ( ) { switch ( mRefreshInterval ) { case REALTIME_REFRESH_INTERVAL : return IntervalFrequency . REALTIME ; case HIGH_REFRESH_INTERVAL : return IntervalFrequency . HIGH ; case LOW_REFRESH_INTERVAL : return IntervalFrequency . LOW ; case MEDIUM_REFRESH_INTERVAL : return IntervalFrequency . MEDIUM ; default : return IntervalFrequency . NONE ; } } | Get the refresh frequency of this scene object . | 113 | 9 |
148,316 | private float [ ] generateParticleVelocities ( ) { float velocities [ ] = new float [ mEmitRate * 3 ] ; for ( int i = 0 ; i < mEmitRate * 3 ; i += 3 ) { Vector3f nexVel = getNextVelocity ( ) ; velocities [ i ] = nexVel . x ; velocities [ i + 1 ] = nexVel . y ; velocities [ i + 2 ] = nexVel . z ; } return velocities ; } | generate random velocities in the given range | 116 | 10 |
148,317 | private float [ ] generateParticleTimeStamps ( float totalTime ) { float timeStamps [ ] = new float [ mEmitRate * 2 ] ; for ( int i = 0 ; i < mEmitRate * 2 ; i += 2 ) { timeStamps [ i ] = totalTime + mRandom . nextFloat ( ) ; timeStamps [ i + 1 ] = 0 ; } return timeStamps ; } | Generate random time stamps from the current time upto the next one second . Passed as texture coordinates to the vertex shader an unused field is present with every pair passed . | 91 | 34 |
148,318 | public static WidgetLib init ( GVRContext gvrContext , String customPropertiesAsset ) throws InterruptedException , JSONException , NoSuchMethodException { if ( mInstance == null ) { // Constructor sets mInstance to ensure the initialization order new WidgetLib ( gvrContext , customPropertiesAsset ) ; } return mInstance . get ( ) ; } | Initialize an instance of Widget Lib . It has to be done before any usage of library . The application needs to hold onto the returned WidgetLib reference for as long as the library is going to be used . | 77 | 44 |
148,319 | public void BuildInteractiveObjectFromAnchor ( Sensor anchorSensor , String anchorDestination ) { InteractiveObject interactiveObject = new InteractiveObject ( ) ; interactiveObject . setSensor ( anchorSensor , anchorDestination ) ; interactiveObjects . add ( interactiveObject ) ; } | BuildInteractiveObjectFromAnchor is a special type of interactive object in that it does not get built using ROUTE s . | 57 | 28 |
148,320 | private void RunScript ( InteractiveObject interactiveObject , String functionName , Object [ ] parameters ) { boolean complete = false ; if ( V8JavaScriptEngine ) { GVRJavascriptV8File gvrJavascriptV8File = interactiveObject . getScriptObject ( ) . getGVRJavascriptV8File ( ) ; String paramString = "var params =[" ; for ( int i = 0 ; i < parameters . length ; i ++ ) { paramString += ( parameters [ i ] + ", " ) ; } paramString = paramString . substring ( 0 , ( paramString . length ( ) - 2 ) ) + "];" ; final GVRJavascriptV8File gvrJavascriptV8FileFinal = gvrJavascriptV8File ; final InteractiveObject interactiveObjectFinal = interactiveObject ; final String functionNameFinal = functionName ; final Object [ ] parametersFinal = parameters ; final String paramStringFinal = paramString ; gvrContext . runOnGlThread ( new Runnable ( ) { @ Override public void run ( ) { RunScriptThread ( gvrJavascriptV8FileFinal , interactiveObjectFinal , functionNameFinal , parametersFinal , paramStringFinal ) ; } } ) ; } // end V8JavaScriptEngine else { // Mozilla Rhino engine GVRJavascriptScriptFile gvrJavascriptFile = interactiveObject . getScriptObject ( ) . getGVRJavascriptScriptFile ( ) ; complete = gvrJavascriptFile . invokeFunction ( functionName , parameters ) ; if ( complete ) { // The JavaScript (JS) ran. Now get the return // values (saved as X3D data types such as SFColor) // stored in 'localBindings'. // Then call SetResultsFromScript() to set the GearVR values Bindings localBindings = gvrJavascriptFile . getLocalBindings ( ) ; SetResultsFromScript ( interactiveObject , localBindings ) ; } else { Log . e ( TAG , "Error in SCRIPT node '" + interactiveObject . getScriptObject ( ) . getName ( ) + "' running Rhino Engine JavaScript function '" + functionName + "'" ) ; } } } | Run the JavaScript program Output saved in localBindings | 458 | 10 |
148,321 | public Quaternionf ConvertDirectionalVectorToQuaternion ( Vector3f d ) { d . negate ( ) ; Quaternionf q = new Quaternionf ( ) ; // check for exception condition if ( ( d . x == 0 ) && ( d . z == 0 ) ) { // exception condition if direction is (0,y,0): // straight up, straight down or all zero's. if ( d . y > 0 ) { // direction straight up AxisAngle4f angleAxis = new AxisAngle4f ( - ( float ) Math . PI / 2 , 1 , 0 , 0 ) ; q . set ( angleAxis ) ; } else if ( d . y < 0 ) { // direction straight down AxisAngle4f angleAxis = new AxisAngle4f ( ( float ) Math . PI / 2 , 1 , 0 , 0 ) ; q . set ( angleAxis ) ; } else { // All zero's. Just set to identity quaternion q . identity ( ) ; } } else { d . normalize ( ) ; Vector3f up = new Vector3f ( 0 , 1 , 0 ) ; Vector3f s = new Vector3f ( ) ; d . cross ( up , s ) ; s . normalize ( ) ; Vector3f u = new Vector3f ( ) ; d . cross ( s , u ) ; u . normalize ( ) ; Matrix4f matrix = new Matrix4f ( s . x , s . y , s . z , 0 , u . x , u . y , u . z , 0 , d . x , d . y , d . z , 0 , 0 , 0 , 0 , 1 ) ; q . setFromNormalized ( matrix ) ; } return q ; } | Converts a vector into a quaternion . Used for the direction of spot and directional lights Called upon initialization and updates to those vectors | 381 | 27 |
148,322 | public static void count ( ) { long duration = SystemClock . uptimeMillis ( ) - startTime ; float avgFPS = sumFrames / ( duration / 1000f ) ; Log . v ( "FPSCounter" , "total frames = %d, total elapsed time = %d ms, average fps = %f" , sumFrames , duration , avgFPS ) ; } | Computes FPS average | 81 | 4 |
148,323 | public static void startCheck ( String extra ) { startCheckTime = System . currentTimeMillis ( ) ; nextCheckTime = startCheckTime ; Log . d ( Log . SUBSYSTEM . TRACING , "FPSCounter" , "[%d] startCheck %s" , startCheckTime , extra ) ; } | Start check of execution time | 70 | 5 |
148,324 | public static void timeCheck ( String extra ) { if ( startCheckTime > 0 ) { long now = System . currentTimeMillis ( ) ; long diff = now - nextCheckTime ; nextCheckTime = now ; Log . d ( Log . SUBSYSTEM . TRACING , "FPSCounter" , "[%d, %d] timeCheck: %s" , now , diff , extra ) ; } } | Computes execution time | 90 | 4 |
148,325 | public void animate ( GVRHybridObject object , float animationTime ) { GVRMeshMorph morph = ( GVRMeshMorph ) mTarget ; mKeyInterpolator . animate ( animationTime * mDuration , mCurrentValues ) ; morph . setWeights ( mCurrentValues ) ; } | Computes the blend weights for the given time and updates them in the target . | 64 | 16 |
148,326 | public synchronized void addRange ( final float range , final GVRSceneObject sceneObject ) { if ( null == sceneObject ) { throw new IllegalArgumentException ( "sceneObject must be specified!" ) ; } if ( range < 0 ) { throw new IllegalArgumentException ( "range cannot be negative" ) ; } final int size = mRanges . size ( ) ; final float rangePow2 = range * range ; final Object [ ] newElement = new Object [ ] { rangePow2 , sceneObject } ; for ( int i = 0 ; i < size ; ++ i ) { final Object [ ] el = mRanges . get ( i ) ; final Float r = ( Float ) el [ 0 ] ; if ( r > rangePow2 ) { mRanges . add ( i , newElement ) ; break ; } } if ( mRanges . size ( ) == size ) { mRanges . add ( newElement ) ; } final GVRSceneObject owner = getOwnerObject ( ) ; if ( null != owner ) { owner . addChildObject ( sceneObject ) ; } } | Add a range to this LOD group . Specify the scene object that should be displayed in this range . Add the LOG group as a component to the parent scene object . The scene objects associated with each range will automatically be added as children to the parent . | 235 | 52 |
148,327 | public void onDrawFrame ( float frameTime ) { final GVRSceneObject owner = getOwnerObject ( ) ; if ( owner == null ) { return ; } final int size = mRanges . size ( ) ; final GVRTransform t = getGVRContext ( ) . getMainScene ( ) . getMainCameraRig ( ) . getCenterCamera ( ) . getTransform ( ) ; for ( final Object [ ] range : mRanges ) { ( ( GVRSceneObject ) range [ 1 ] ) . setEnable ( false ) ; } for ( int i = size - 1 ; i >= 0 ; -- i ) { final Object [ ] range = mRanges . get ( i ) ; final GVRSceneObject child = ( GVRSceneObject ) range [ 1 ] ; if ( child . getParent ( ) != owner ) { Log . w ( TAG , "the scene object for distance greater than " + range [ 0 ] + " is not a child of the owner; skipping it" ) ; continue ; } final float [ ] values = child . getBoundingVolumeRawValues ( ) ; mCenter . set ( values [ 0 ] , values [ 1 ] , values [ 2 ] , 1.0f ) ; mVector . set ( t . getPositionX ( ) , t . getPositionY ( ) , t . getPositionZ ( ) , 1.0f ) ; mVector . sub ( mCenter ) ; mVector . negate ( ) ; float distance = mVector . dot ( mVector ) ; if ( distance >= ( Float ) range [ 0 ] ) { child . setEnable ( true ) ; break ; } } } | Do not call directly . | 349 | 5 |
148,328 | public static Shell createConsoleShell ( String prompt , String appName , Object ... handlers ) { ConsoleIO io = new ConsoleIO ( ) ; List < String > path = new ArrayList < String > ( 1 ) ; path . add ( prompt ) ; MultiMap < String , Object > modifAuxHandlers = new ArrayHashMultiMap < String , Object > ( ) ; modifAuxHandlers . put ( "!" , io ) ; Shell theShell = new Shell ( new Shell . Settings ( io , io , modifAuxHandlers , false ) , new CommandTable ( new DashJoinedNamer ( true ) ) , path ) ; theShell . setAppName ( appName ) ; theShell . addMainHandler ( theShell , "!" ) ; theShell . addMainHandler ( new HelpCommandHandler ( ) , "?" ) ; for ( Object h : handlers ) { theShell . addMainHandler ( h , "" ) ; } return theShell ; } | One of facade methods for operating the Shell . | 206 | 9 |
148,329 | public static Shell createConsoleShell ( String prompt , String appName , Object mainHandler ) { return createConsoleShell ( prompt , appName , mainHandler , new EmptyMultiMap < String , Object > ( ) ) ; } | Facade method for operating the Shell . | 46 | 8 |
148,330 | public static Shell createSubshell ( String pathElement , Shell parent , String appName , Object mainHandler , MultiMap < String , Object > auxHandlers ) { List < String > newPath = new ArrayList < String > ( parent . getPath ( ) ) ; newPath . add ( pathElement ) ; Shell subshell = new Shell ( parent . getSettings ( ) . createWithAddedAuxHandlers ( auxHandlers ) , new CommandTable ( parent . getCommandTable ( ) . getNamer ( ) ) , newPath ) ; subshell . setAppName ( appName ) ; subshell . addMainHandler ( subshell , "!" ) ; subshell . addMainHandler ( new HelpCommandHandler ( ) , "?" ) ; subshell . addMainHandler ( mainHandler , "" ) ; return subshell ; } | Facade method facilitating the creation of subshell . Subshell is created and run inside Command method and shares the same IO and naming strategy . | 176 | 28 |
148,331 | public static Shell createSubshell ( String pathElement , Shell parent , String appName , Object mainHandler ) { return createSubshell ( pathElement , parent , appName , mainHandler , new EmptyMultiMap < String , Object > ( ) ) ; } | Facade method facilitating the creation of subshell . Subshell is created and run inside Command method and shares the same IO and naming strtategy . | 53 | 30 |
148,332 | public void animate ( float animationTime , Matrix4f mat ) { mRotInterpolator . animate ( animationTime , mRotKey ) ; mPosInterpolator . animate ( animationTime , mPosKey ) ; mSclInterpolator . animate ( animationTime , mScaleKey ) ; mat . translationRotateScale ( mPosKey [ 0 ] , mPosKey [ 1 ] , mPosKey [ 2 ] , mRotKey [ 0 ] , mRotKey [ 1 ] , mRotKey [ 2 ] , mRotKey [ 3 ] , mScaleKey [ 0 ] , mScaleKey [ 1 ] , mScaleKey [ 2 ] ) ; } | Obtains the transform for a specific time in animation . | 142 | 11 |
148,333 | public void setAmbientIntensity ( float r , float g , float b , float a ) { setVec4 ( "ambient_intensity" , r , g , b , a ) ; } | Set the ambient light intensity . | 43 | 6 |
148,334 | public void setDiffuseIntensity ( float r , float g , float b , float a ) { setVec4 ( "diffuse_intensity" , r , g , b , a ) ; } | Set the diffuse light intensity . | 43 | 6 |
148,335 | public void setSpecularIntensity ( float r , float g , float b , float a ) { setVec4 ( "specular_intensity" , r , g , b , a ) ; } | Set the specular intensity of the light . | 43 | 9 |
148,336 | private float getQuaternionW ( float x , float y , float z ) { return ( float ) Math . cos ( Math . asin ( Math . sqrt ( x * x + y * y + z * z ) ) ) ; } | Finds the missing value . Seems to lose a degree of freedom but it doesn t . That degree of freedom is already lost by the sensor . | 52 | 29 |
148,337 | public void shutdown ( ) { debugConnection = null ; shuttingDown = true ; try { if ( serverSocket != null ) { serverSocket . close ( ) ; } } catch ( IOException e ) { e . printStackTrace ( ) ; } } | Shuts down the server . Active connections are not affected . | 53 | 12 |
148,338 | @ Override public void run ( ) { ExecutorService executorService = Executors . newFixedThreadPool ( maxClients ) ; try { serverSocket = new ServerSocket ( port , maxClients ) ; while ( ! shuttingDown ) { try { Socket socket = serverSocket . accept ( ) ; debugConnection = new DebugConnection ( socket ) ; executorService . submit ( debugConnection ) ; } catch ( SocketException e ) { // closed debugConnection = null ; } } } catch ( IOException e ) { e . printStackTrace ( ) ; } finally { try { debugConnection = null ; serverSocket . close ( ) ; } catch ( Exception e ) { } executorService . shutdownNow ( ) ; } } | Runs the server . | 155 | 5 |
148,339 | public synchronized void removeAllSceneObjects ( ) { final GVRCameraRig rig = getMainCameraRig ( ) ; final GVRSceneObject head = rig . getOwnerObject ( ) ; rig . removeAllChildren ( ) ; NativeScene . removeAllSceneObjects ( getNative ( ) ) ; for ( final GVRSceneObject child : mSceneRoot . getChildren ( ) ) { child . getParent ( ) . removeChildObject ( child ) ; } if ( null != head ) { mSceneRoot . addChildObject ( head ) ; } final int numControllers = getGVRContext ( ) . getInputManager ( ) . clear ( ) ; if ( numControllers > 0 ) { getGVRContext ( ) . getInputManager ( ) . selectController ( ) ; } getGVRContext ( ) . runOnGlThread ( new Runnable ( ) { @ Override public void run ( ) { NativeScene . deleteLightsAndDepthTextureOnRenderThread ( getNative ( ) ) ; } } ) ; } | Remove all scene objects . | 222 | 5 |
148,340 | public void setPickRay ( float ox , float oy , float oz , float dx , float dy , float dz ) { synchronized ( this ) { mRayOrigin . x = ox ; mRayOrigin . y = oy ; mRayOrigin . z = oz ; mRayDirection . x = dx ; mRayDirection . y = dy ; mRayDirection . z = dz ; } } | Sets the origin and direction of the pick ray . | 85 | 11 |
148,341 | public void onDrawFrame ( float frameTime ) { if ( isEnabled ( ) && ( mScene != null ) && mPickEventLock . tryLock ( ) ) { // Don't call if we are in the middle of processing another pick try { doPick ( ) ; } finally { mPickEventLock . unlock ( ) ; } } } | Called every frame if the picker is enabled to generate pick events . | 71 | 15 |
148,342 | public void processPick ( boolean touched , MotionEvent event ) { mPickEventLock . lock ( ) ; mTouched = touched ; mMotionEvent = event ; doPick ( ) ; mPickEventLock . unlock ( ) ; } | Scans the scene graph to collect picked items and generates appropriate pick and touch events . This function is called by the cursor controller internally but can also be used to funnel a stream of Android motion events into the picker . | 49 | 44 |
148,343 | protected void propagateOnNoPick ( GVRPicker picker ) { if ( mEventOptions . contains ( EventOptions . SEND_PICK_EVENTS ) ) { if ( mEventOptions . contains ( EventOptions . SEND_TO_LISTENERS ) ) { getGVRContext ( ) . getEventManager ( ) . sendEvent ( this , IPickEvents . class , "onNoPick" , picker ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_SCENE ) && ( mScene != null ) ) { getGVRContext ( ) . getEventManager ( ) . sendEvent ( mScene , IPickEvents . class , "onNoPick" , picker ) ; } } } | Propagate onNoPick events to listeners | 160 | 8 |
148,344 | protected void propagateOnMotionOutside ( MotionEvent event ) { if ( mEventOptions . contains ( EventOptions . SEND_TOUCH_EVENTS ) ) { if ( mEventOptions . contains ( EventOptions . SEND_TO_LISTENERS ) ) { getGVRContext ( ) . getEventManager ( ) . sendEvent ( this , ITouchEvents . class , "onMotionOutside" , this , event ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_SCENE ) && ( mScene != null ) ) { getGVRContext ( ) . getEventManager ( ) . sendEvent ( mScene , ITouchEvents . class , "onMotionOutside" , this , event ) ; } } } | Propagate onMotionOutside events to listeners | 160 | 8 |
148,345 | protected void propagateOnEnter ( GVRPickedObject hit ) { GVRSceneObject hitObject = hit . getHitObject ( ) ; GVREventManager eventManager = getGVRContext ( ) . getEventManager ( ) ; if ( mEventOptions . contains ( EventOptions . SEND_TOUCH_EVENTS ) ) { if ( mEventOptions . contains ( EventOptions . SEND_TO_LISTENERS ) ) { eventManager . sendEvent ( this , ITouchEvents . class , "onEnter" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_HIT_OBJECT ) ) { eventManager . sendEvent ( hitObject , ITouchEvents . class , "onEnter" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_SCENE ) && ( mScene != null ) ) { eventManager . sendEvent ( mScene , ITouchEvents . class , "onEnter" , hitObject , hit ) ; } } if ( mEventOptions . contains ( EventOptions . SEND_PICK_EVENTS ) ) { if ( mEventOptions . contains ( EventOptions . SEND_TO_LISTENERS ) ) { eventManager . sendEvent ( this , IPickEvents . class , "onEnter" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_HIT_OBJECT ) ) { eventManager . sendEvent ( hitObject , IPickEvents . class , "onEnter" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_SCENE ) && ( mScene != null ) ) { eventManager . sendEvent ( mScene , IPickEvents . class , "onEnter" , hitObject , hit ) ; } } } | Propagate onEnter events to listeners | 406 | 7 |
148,346 | protected void propagateOnTouch ( GVRPickedObject hit ) { if ( mEventOptions . contains ( EventOptions . SEND_TOUCH_EVENTS ) ) { GVREventManager eventManager = getGVRContext ( ) . getEventManager ( ) ; GVRSceneObject hitObject = hit . getHitObject ( ) ; if ( mEventOptions . contains ( EventOptions . SEND_TO_LISTENERS ) ) { eventManager . sendEvent ( this , ITouchEvents . class , "onTouchStart" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_HIT_OBJECT ) ) { eventManager . sendEvent ( hitObject , ITouchEvents . class , "onTouchStart" , hitObject , hit ) ; } if ( mEventOptions . contains ( EventOptions . SEND_TO_SCENE ) && ( mScene != null ) ) { eventManager . sendEvent ( mScene , ITouchEvents . class , "onTouchStart" , hitObject , hit ) ; } } } | Propagate onTouchStart events to listeners | 232 | 8 |
148,347 | protected GVRPickedObject findCollider ( GVRPickedObject [ ] pickList , GVRCollider findme ) { if ( pickList == null ) { return null ; } for ( GVRPickedObject hit : pickList ) { if ( ( hit != null ) && ( hit . hitCollider == findme ) ) { return hit ; } } return null ; } | Find the collision against a specific collider in a list of collisions . | 83 | 14 |
148,348 | public static final GVRPickedObject [ ] pickObjects ( GVRScene scene , float ox , float oy , float oz , float dx , float dy , float dz ) { sFindObjectsLock . lock ( ) ; try { final GVRPickedObject [ ] result = NativePicker . pickObjects ( scene . getNative ( ) , 0L , ox , oy , oz , dx , dy , dz ) ; return result ; } finally { sFindObjectsLock . unlock ( ) ; } } | Casts a ray into the scene graph and returns the objects it intersects . | 111 | 16 |
148,349 | static GVRPickedObject makeHitMesh ( long colliderPointer , float distance , float hitx , float hity , float hitz , int faceIndex , float barycentricx , float barycentricy , float barycentricz , float texu , float texv , float normalx , float normaly , float normalz ) { GVRCollider collider = GVRCollider . lookup ( colliderPointer ) ; if ( collider == null ) { Log . d ( TAG , "makeHit: cannot find collider for %x" , colliderPointer ) ; return null ; } return new GVRPicker . GVRPickedObject ( collider , new float [ ] { hitx , hity , hitz } , distance , faceIndex , new float [ ] { barycentricx , barycentricy , barycentricz } , new float [ ] { texu , texv } , new float [ ] { normalx , normaly , normalz } ) ; } | Internal utility to help JNI add hit objects to the pick list . Specifically for MeshColliders with picking for UV Barycentric and normal coordinates enabled | 219 | 30 |
148,350 | public static List < GVRAtlasInformation > loadAtlasInformation ( InputStream ins ) { try { int size = ins . available ( ) ; byte [ ] buffer = new byte [ size ] ; ins . read ( buffer ) ; return loadAtlasInformation ( new JSONArray ( new String ( buffer , "UTF-8" ) ) ) ; } catch ( JSONException je ) { je . printStackTrace ( ) ; } catch ( IOException ex ) { ex . printStackTrace ( ) ; } return null ; } | This method is a sync parse to the JSON stream of atlas information . | 112 | 15 |
148,351 | public void setSpeed ( float newValue ) { if ( newValue < 0 ) newValue = 0 ; this . pitch . setValue ( newValue ) ; this . speed . setValue ( newValue ) ; } | Assign float value to inputOutput SFFloat field named speed . Note that our implementation with ExoPlayer that pitch and speed will be set to the same value . | 45 | 35 |
148,352 | public String getUniformDescriptor ( GVRContext ctx ) { if ( mShaderTemplate == null ) { mShaderTemplate = makeTemplate ( ID , ctx ) ; ctx . getShaderManager ( ) . addShaderID ( this ) ; } return mShaderTemplate . getUniformDescriptor ( ) ; } | Gets the string describing the uniforms used by shaders of this type . | 75 | 15 |
148,353 | public GVRShader getTemplate ( GVRContext ctx ) { if ( mShaderTemplate == null ) { mShaderTemplate = makeTemplate ( ID , ctx ) ; ctx . getShaderManager ( ) . addShaderID ( this ) ; } return mShaderTemplate ; } | Gets the Java subclass of GVRShader which implements this shader type . | 65 | 16 |
148,354 | GVRShader makeTemplate ( Class < ? extends GVRShader > id , GVRContext ctx ) { try { Constructor < ? extends GVRShader > maker = id . getDeclaredConstructor ( GVRContext . class ) ; return maker . newInstance ( ctx ) ; } catch ( NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex ) { try { Constructor < ? extends GVRShader > maker = id . getDeclaredConstructor ( ) ; return maker . newInstance ( ) ; } catch ( NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException ex2 ) { ctx . getEventManager ( ) . sendEvent ( ctx , IErrorEvents . class , "onError" , new Object [ ] { ex2 . getMessage ( ) , this } ) ; return null ; } } } | Instantiates an instance of input Java shader class which must be derived from GVRShader or GVRShaderTemplate . | 192 | 26 |
148,355 | public void start ( GVRAccessibilitySpeechListener speechListener ) { mTts . setSpeechListener ( speechListener ) ; mTts . getSpeechRecognizer ( ) . startListening ( mTts . getSpeechRecognizerIntent ( ) ) ; } | Start speech recognizer . | 63 | 5 |
148,356 | public void setVertexBuffer ( GVRVertexBuffer vbuf ) { if ( vbuf == null ) { throw new IllegalArgumentException ( "Vertex buffer cannot be null" ) ; } mVertices = vbuf ; NativeMesh . setVertexBuffer ( getNative ( ) , vbuf . getNative ( ) ) ; } | Changes the vertex buffer associated with this mesh . | 72 | 9 |
148,357 | public void setIndexBuffer ( GVRIndexBuffer ibuf ) { mIndices = ibuf ; NativeMesh . setIndexBuffer ( getNative ( ) , ( ibuf != null ) ? ibuf . getNative ( ) : 0L ) ; } | Changes the index buffer associated with this mesh . | 53 | 9 |
148,358 | public static void rebuild ( final MODE newMode ) { if ( mode != newMode ) { mode = newMode ; TYPE type ; switch ( mode ) { case DEBUG : type = TYPE . ANDROID ; Log . startFullLog ( ) ; break ; case DEVELOPER : type = TYPE . PERSISTENT ; Log . stopFullLog ( ) ; break ; case USER : type = TYPE . ANDROID ; break ; default : type = DEFAULT_TYPE ; Log . stopFullLog ( ) ; break ; } currentLog = getLog ( type ) ; } } | Rebuild logging systems with updated mode | 123 | 7 |
148,359 | public static int e ( ISubsystem subsystem , String tag , String msg ) { return isEnabled ( subsystem ) ? currentLog . e ( tag , getMsg ( subsystem , msg ) ) : 0 ; } | Send an ERROR log message with specified subsystem . If subsystem is not enabled the message will not be logged | 42 | 20 |
148,360 | public static void d ( ISubsystem subsystem , String tag , String pattern , Object ... parameters ) { if ( ! isEnabled ( subsystem ) ) return ; d ( subsystem , tag , format ( pattern , parameters ) ) ; } | Send a DEBUG log message with specified subsystem . If subsystem is not enabled the message will not be logged | 46 | 20 |
148,361 | private static void deleteOldAndEmptyFiles ( ) { File dir = LOG_FILE_DIR ; if ( dir . exists ( ) ) { File [ ] files = dir . listFiles ( ) ; for ( File f : files ) { if ( f . length ( ) == 0 || f . lastModified ( ) + MAXFILEAGE < System . currentTimeMillis ( ) ) { f . delete ( ) ; } } } } | delete of files more than 1 day old | 91 | 8 |
148,362 | public boolean load ( GVRScene scene ) { GVRAssetLoader loader = getGVRContext ( ) . getAssetLoader ( ) ; if ( scene == null ) { scene = getGVRContext ( ) . getMainScene ( ) ; } if ( mReplaceScene ) { loader . loadScene ( getOwnerObject ( ) , mVolume , mImportSettings , scene , null ) ; } else { loader . loadModel ( getOwnerObject ( ) , mVolume , mImportSettings , scene ) ; } return true ; } | Loads the asset referenced by the file name under the owner of this component . If this component was constructed to replace the scene with the asset the scene will contain only the owner of this component upon return . Otherwise the loaded asset is a child of this component s owner . | 114 | 54 |
148,363 | public void load ( IAssetEvents handler ) { GVRAssetLoader loader = getGVRContext ( ) . getAssetLoader ( ) ; if ( mReplaceScene ) { loader . loadScene ( getOwnerObject ( ) , mVolume , mImportSettings , getGVRContext ( ) . getMainScene ( ) , handler ) ; } else { loader . loadModel ( mVolume , getOwnerObject ( ) , mImportSettings , true , handler ) ; } } | Loads the asset referenced by the file name under the owner of this component . If this component was constructed to replace the scene with the asset the main scene of the current context will contain only the owner of this component upon return . Otherwise the loaded asset is a child of this component s owner . | 101 | 59 |
148,364 | public String [ ] parseMFString ( String mfString ) { Vector < String > strings = new Vector < String > ( ) ; StringReader sr = new StringReader ( mfString ) ; StreamTokenizer st = new StreamTokenizer ( sr ) ; st . quoteChar ( ' ' ) ; st . quoteChar ( ' ' ) ; String [ ] mfStrings = null ; int tokenType ; try { while ( ( tokenType = st . nextToken ( ) ) != StreamTokenizer . TT_EOF ) { strings . add ( st . sval ) ; } } catch ( IOException e ) { Log . d ( TAG , "String parsing Error: " + e ) ; e . printStackTrace ( ) ; } mfStrings = new String [ strings . size ( ) ] ; for ( int i = 0 ; i < strings . size ( ) ; i ++ ) { mfStrings [ i ] = strings . get ( i ) ; } return mfStrings ; } | multi - field string | 214 | 4 |
148,365 | private static Point getScreenSize ( Context context , Point p ) { if ( p == null ) { p = new Point ( ) ; } WindowManager windowManager = ( WindowManager ) context . getSystemService ( Context . WINDOW_SERVICE ) ; Display display = windowManager . getDefaultDisplay ( ) ; display . getSize ( p ) ; return p ; } | Returns screen height and width | 78 | 5 |
148,366 | public float get ( int row , int col ) { if ( row < 0 || row > 3 ) { throw new IndexOutOfBoundsException ( "Index: " + row + ", Size: 4" ) ; } if ( col < 0 || col > 3 ) { throw new IndexOutOfBoundsException ( "Index: " + col + ", Size: 4" ) ; } return m_data [ row * 4 + col ] ; } | Gets an element of the matrix . | 94 | 8 |
148,367 | public PeriodicEvent runAfter ( Runnable task , float delay ) { validateDelay ( delay ) ; return new Event ( task , delay ) ; } | Run a task once after a delay . | 33 | 8 |
148,368 | public PeriodicEvent runEvery ( Runnable task , float delay , float period ) { return runEvery ( task , delay , period , null ) ; } | Run a task periodically and indefinitely . | 33 | 7 |
148,369 | public PeriodicEvent runEvery ( Runnable task , float delay , float period , int repetitions ) { if ( repetitions < 1 ) { return null ; } else if ( repetitions == 1 ) { // Better to burn a handful of CPU cycles than to churn memory by // creating a new callback return runAfter ( task , delay ) ; } else { return runEvery ( task , delay , period , new RunFor ( repetitions ) ) ; } } | Run a task periodically for a set number of times . | 96 | 11 |
148,370 | public PeriodicEvent runEvery ( Runnable task , float delay , float period , KeepRunning callback ) { validateDelay ( delay ) ; validatePeriod ( period ) ; return new Event ( task , delay , period , callback ) ; } | Run a task periodically with a callback . | 51 | 8 |
148,371 | @ SuppressWarnings ( "unchecked" ) public < V3 , M4 , C , N , Q > N getSceneRoot ( AiWrapperProvider < V3 , M4 , C , N , Q > wrapperProvider ) { return ( N ) m_sceneRoot ; } | Returns the scene graph root . | 62 | 6 |
148,372 | public void enableClipRegion ( ) { if ( mClippingEnabled ) { Log . w ( TAG , "Clipping has been enabled already for %s!" , getName ( ) ) ; return ; } Log . d ( Log . SUBSYSTEM . WIDGET , TAG , "enableClipping for %s [%f, %f, %f]" , getName ( ) , getViewPortWidth ( ) , getViewPortHeight ( ) , getViewPortDepth ( ) ) ; mClippingEnabled = true ; GVRTexture texture = WidgetLib . getTextureHelper ( ) . getSolidColorTexture ( Color . YELLOW ) ; GVRSceneObject clippingObj = new GVRSceneObject ( mContext , getViewPortWidth ( ) , getViewPortHeight ( ) , texture ) ; clippingObj . setName ( "clippingObj" ) ; clippingObj . getRenderData ( ) . setRenderingOrder ( GVRRenderData . GVRRenderingOrder . STENCIL ) . setStencilTest ( true ) . setStencilFunc ( GLES30 . GL_ALWAYS , 1 , 0xFF ) . setStencilOp ( GLES30 . GL_KEEP , GLES30 . GL_KEEP , GLES30 . GL_REPLACE ) . setStencilMask ( 0xFF ) ; mSceneObject . addChildObject ( clippingObj ) ; for ( Widget child : getChildren ( ) ) { setObjectClipped ( child ) ; } } | Enable clipping for the Widget . Widget content including its children will be clipped by a rectangular View Port . By default clipping is disabled . | 330 | 28 |
148,373 | public float getLayoutSize ( final Layout . Axis axis ) { float size = 0 ; for ( Layout layout : mLayouts ) { size = Math . max ( size , layout . getSize ( axis ) ) ; } Log . d ( Log . SUBSYSTEM . LAYOUT , TAG , "getLayoutSize [%s] axis [%s] size [%f]" , getName ( ) , axis , size ) ; return size ; } | Gets Widget layout dimension | 96 | 6 |
148,374 | public float getBoundsWidth ( ) { if ( mSceneObject != null ) { GVRSceneObject . BoundingVolume v = mSceneObject . getBoundingVolume ( ) ; return v . maxCorner . x - v . minCorner . x ; } return 0f ; } | Gets Widget bounds width | 62 | 6 |
148,375 | public float getBoundsHeight ( ) { if ( mSceneObject != null ) { GVRSceneObject . BoundingVolume v = mSceneObject . getBoundingVolume ( ) ; return v . maxCorner . y - v . minCorner . y ; } return 0f ; } | Gets Widget bounds height | 62 | 6 |
148,376 | public float getBoundsDepth ( ) { if ( mSceneObject != null ) { GVRSceneObject . BoundingVolume v = mSceneObject . getBoundingVolume ( ) ; return v . maxCorner . z - v . minCorner . z ; } return 0f ; } | Gets Widget bounds depth | 62 | 6 |
148,377 | public void rotateWithPivot ( float w , float x , float y , float z , float pivotX , float pivotY , float pivotZ ) { getTransform ( ) . rotateWithPivot ( w , x , y , z , pivotX , pivotY , pivotZ ) ; if ( mTransformCache . rotateWithPivot ( w , x , y , z , pivotX , pivotY , pivotZ ) ) { onTransformChanged ( ) ; } } | Modify the tranform s current rotation in quaternion terms around a pivot other than the origin . | 98 | 22 |
148,378 | public boolean setVisibility ( final Visibility visibility ) { if ( visibility != mVisibility ) { Log . d ( Log . SUBSYSTEM . WIDGET , TAG , "setVisibility(%s) for %s" , visibility , getName ( ) ) ; updateVisibility ( visibility ) ; mVisibility = visibility ; return true ; } return false ; } | Set the visibility of the object . | 80 | 7 |
148,379 | public boolean setViewPortVisibility ( final ViewPortVisibility viewportVisibility ) { boolean visibilityIsChanged = viewportVisibility != mIsVisibleInViewPort ; if ( visibilityIsChanged ) { Visibility visibility = mVisibility ; switch ( viewportVisibility ) { case FULLY_VISIBLE : case PARTIALLY_VISIBLE : break ; case INVISIBLE : visibility = Visibility . HIDDEN ; break ; } mIsVisibleInViewPort = viewportVisibility ; updateVisibility ( visibility ) ; } return visibilityIsChanged ; } | Set ViewPort visibility of the object . | 121 | 8 |
148,380 | public Widget findChildByName ( final String name ) { final List < Widget > groups = new ArrayList <> ( ) ; groups . add ( this ) ; return findChildByNameInAllGroups ( name , groups ) ; } | Finds the Widget in hierarchy | 52 | 7 |
148,381 | protected final boolean isGLThread ( ) { final Thread glThread = sGLThread . get ( ) ; return glThread != null && glThread . equals ( Thread . currentThread ( ) ) ; } | Determine whether the calling thread is the GL thread . | 42 | 12 |
148,382 | protected void update ( float scale ) { // Updates only when the plane is in the scene GVRSceneObject owner = getOwnerObject ( ) ; if ( ( owner != null ) && isEnabled ( ) && owner . isEnabled ( ) ) { convertFromARtoVRSpace ( scale ) ; } } | Update the anchor based on arcore best knowledge of the world | 61 | 12 |
148,383 | public void setCastShadow ( boolean enableFlag ) { GVRSceneObject owner = getOwnerObject ( ) ; if ( owner != null ) { GVRShadowMap shadowMap = ( GVRShadowMap ) getComponent ( GVRRenderTarget . getComponentType ( ) ) ; if ( enableFlag ) { if ( shadowMap != null ) { shadowMap . setEnable ( true ) ; } else { GVRCamera shadowCam = GVRShadowMap . makeOrthoShadowCamera ( getGVRContext ( ) . getMainScene ( ) . getMainCameraRig ( ) . getCenterCamera ( ) ) ; shadowMap = new GVRShadowMap ( getGVRContext ( ) , shadowCam ) ; owner . attachComponent ( shadowMap ) ; } } else if ( shadowMap != null ) { shadowMap . setEnable ( false ) ; } } mCastShadow = enableFlag ; } | Enables or disabled shadow casting for a direct light . Enabling shadows attaches a GVRShadowMap component to the GVRSceneObject which owns the light and provides the component with an orthographic camera for shadow casting . | 190 | 44 |
148,384 | public synchronized void delete ( String name ) { if ( isEmpty ( name ) ) { indexedProps . remove ( name ) ; } else { synchronized ( context ) { int scope = context . getAttributesScope ( name ) ; if ( scope != - 1 ) { context . removeAttribute ( name , scope ) ; } } } } | Removes a named property from the object . | 69 | 9 |
148,385 | public synchronized Object [ ] getIds ( ) { String [ ] keys = getAllKeys ( ) ; int size = keys . length + indexedProps . size ( ) ; Object [ ] res = new Object [ size ] ; System . arraycopy ( keys , 0 , res , 0 , keys . length ) ; int i = keys . length ; // now add all indexed properties for ( Object index : indexedProps . keySet ( ) ) { res [ i ++ ] = index ; } return res ; } | Get an array of property ids . | 107 | 8 |
148,386 | public boolean hasInstance ( Scriptable instance ) { // Default for JS objects (other than Function) is to do prototype // chasing. Scriptable proto = instance . getPrototype ( ) ; while ( proto != null ) { if ( proto . equals ( this ) ) return true ; proto = proto . getPrototype ( ) ; } return false ; } | Implements the instanceof operator . | 73 | 8 |
148,387 | public void setLoop ( boolean doLoop , GVRContext gvrContext ) { if ( this . loop != doLoop ) { // a change in the loop for ( GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations ) { if ( doLoop ) gvrKeyFrameAnimation . setRepeatMode ( GVRRepeatMode . REPEATED ) ; else gvrKeyFrameAnimation . setRepeatMode ( GVRRepeatMode . ONCE ) ; } // be sure to start the animations if loop is true if ( doLoop ) { for ( GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations ) { gvrKeyFrameAnimation . start ( gvrContext . getAnimationEngine ( ) ) ; } } this . loop = doLoop ; } } | SetLoop will either set the GVRNodeAnimation s Repeat Mode to REPEATED if loop is true . or it will set the GVRNodeAnimation s Repeat Mode to ONCE if loop is false if loop is set to TRUE when it was previously FALSE then start the Animation . | 166 | 57 |
148,388 | public void setCycleInterval ( float newCycleInterval ) { if ( ( this . cycleInterval != newCycleInterval ) && ( newCycleInterval > 0 ) ) { for ( GVRNodeAnimation gvrKeyFrameAnimation : gvrKeyFrameAnimations ) { //TODO Cannot easily change the GVRAnimation's GVRChannel once set. } this . cycleInterval = newCycleInterval ; } } | Set the TimeSensor s cycleInterval property Currently this does not change the duration of the animation . | 96 | 20 |
148,389 | public ExecutionChain setErrorCallback ( ErrorCallback callback ) { if ( state . get ( ) == State . RUNNING ) { throw new IllegalStateException ( "Invalid while ExecutionChain is running" ) ; } errorCallback = callback ; return this ; } | Set a callback to handle any exceptions in the chain of execution . | 52 | 13 |
148,390 | public void execute ( ) { State currentState = state . getAndSet ( State . RUNNING ) ; if ( currentState == State . RUNNING ) { throw new IllegalStateException ( "ExecutionChain is already running!" ) ; } executeRunnable = new ExecuteRunnable ( ) ; } | Start the chain of execution running . | 65 | 7 |
148,391 | public boolean isHomeKeyPresent ( ) { final GVRApplication application = mApplication . get ( ) ; if ( null != application ) { final String model = getHmtModel ( ) ; if ( null != model && model . contains ( "R323" ) ) { return true ; } } return false ; } | Does the headset the device is docked into have a dedicated home key | 68 | 14 |
148,392 | public void addAuxHandler ( Object handler , String prefix ) { if ( handler == null ) { throw new NullPointerException ( ) ; } auxHandlers . put ( prefix , handler ) ; allHandlers . add ( handler ) ; addDeclaredMethods ( handler , prefix ) ; inputConverter . addDeclaredConverters ( handler ) ; outputConverter . addDeclaredConverters ( handler ) ; if ( handler instanceof ShellDependent ) { ( ( ShellDependent ) handler ) . cliSetShell ( this ) ; } } | This method is very similar to addMainHandler except ShellFactory will pass all handlers registered with this method to all this shell s subshells . | 120 | 29 |
148,393 | public void commandLoop ( ) throws IOException { for ( Object handler : allHandlers ) { if ( handler instanceof ShellManageable ) { ( ( ShellManageable ) handler ) . cliEnterLoop ( ) ; } } output . output ( appName , outputConverter ) ; String command = "" ; while ( true ) { try { command = input . readCommand ( path ) ; if ( command . trim ( ) . equals ( "exit" ) ) { if ( lineProcessor == null ) break ; else { path = savedPath ; lineProcessor = null ; } } processLine ( command ) ; } catch ( TokenException te ) { lastException = te ; output . outputException ( command , te ) ; } catch ( CLIException clie ) { lastException = clie ; if ( ! command . trim ( ) . equals ( "exit" ) ) { output . outputException ( clie ) ; } } } for ( Object handler : allHandlers ) { if ( handler instanceof ShellManageable ) { ( ( ShellManageable ) handler ) . cliLeaveLoop ( ) ; } } } | Runs the command session . Create the Shell then run this method to listen to the user and the Shell will invoke Handler s methods . | 240 | 27 |
148,394 | @ Override public void addVariable ( String varName , Object value ) { synchronized ( mGlobalVariables ) { mGlobalVariables . put ( varName , value ) ; } refreshGlobalBindings ( ) ; } | Add a variable to the scripting context . | 46 | 8 |
148,395 | @ Override public void attachScriptFile ( IScriptable target , IScriptFile scriptFile ) { mScriptMap . put ( target , scriptFile ) ; scriptFile . invokeFunction ( "onAttach" , new Object [ ] { target } ) ; } | Attach a script file to a scriptable target . | 54 | 10 |
148,396 | @ Override public void detachScriptFile ( IScriptable target ) { IScriptFile scriptFile = mScriptMap . remove ( target ) ; if ( scriptFile != null ) { scriptFile . invokeFunction ( "onDetach" , new Object [ ] { target } ) ; } } | Detach any script file from a scriptable target . | 61 | 11 |
148,397 | public void bindScriptBundleToScene ( GVRScriptBundle scriptBundle , GVRScene scene ) throws IOException , GVRScriptException { for ( GVRSceneObject sceneObject : scene . getSceneObjects ( ) ) { bindBundleToSceneObject ( scriptBundle , sceneObject ) ; } } | Binds a script bundle to a scene . | 68 | 9 |
148,398 | public void bindBundleToSceneObject ( GVRScriptBundle scriptBundle , GVRSceneObject rootSceneObject ) throws IOException , GVRScriptException { bindHelper ( scriptBundle , rootSceneObject , BIND_MASK_SCENE_OBJECTS ) ; } | Binds a script bundle to scene graph rooted at a scene object . | 62 | 14 |
148,399 | protected void bindHelper ( GVRScriptBundle scriptBundle , GVRSceneObject rootSceneObject , int bindMask ) throws IOException , GVRScriptException { for ( GVRScriptBindingEntry entry : scriptBundle . file . binding ) { GVRAndroidResource rc ; if ( entry . volumeType == null || entry . volumeType . isEmpty ( ) ) { rc = scriptBundle . volume . openResource ( entry . script ) ; } else { GVRResourceVolume . VolumeType volumeType = GVRResourceVolume . VolumeType . fromString ( entry . volumeType ) ; if ( volumeType == null ) { throw new GVRScriptException ( String . format ( "Volume type %s is not recognized, script=%s" , entry . volumeType , entry . script ) ) ; } rc = new GVRResourceVolume ( mGvrContext , volumeType ) . openResource ( entry . script ) ; } GVRScriptFile scriptFile = ( GVRScriptFile ) loadScript ( rc , entry . language ) ; String targetName = entry . target ; if ( targetName . startsWith ( TARGET_PREFIX ) ) { TargetResolver resolver = sBuiltinTargetMap . get ( targetName ) ; IScriptable target = resolver . getTarget ( mGvrContext , targetName ) ; // Apply mask boolean toBind = false ; if ( ( bindMask & BIND_MASK_GVRSCRIPT ) != 0 && targetName . equalsIgnoreCase ( TARGET_GVRMAIN ) ) { toBind = true ; } if ( ( bindMask & BIND_MASK_GVRACTIVITY ) != 0 && targetName . equalsIgnoreCase ( TARGET_GVRAPPLICATION ) ) { toBind = true ; } if ( toBind ) { attachScriptFile ( target , scriptFile ) ; } } else { if ( ( bindMask & BIND_MASK_SCENE_OBJECTS ) != 0 ) { if ( targetName . equals ( rootSceneObject . getName ( ) ) ) { attachScriptFile ( rootSceneObject , scriptFile ) ; } // Search in children GVRSceneObject [ ] sceneObjects = rootSceneObject . getSceneObjectsByName ( targetName ) ; if ( sceneObjects != null ) { for ( GVRSceneObject sceneObject : sceneObjects ) { GVRScriptBehavior b = new GVRScriptBehavior ( sceneObject . getGVRContext ( ) ) ; b . setScriptFile ( scriptFile ) ; sceneObject . attachComponent ( b ) ; } } } } } } | Helper function to bind script bundler to various targets | 560 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.