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 .