docs: private Object[] SetJavaScriptArguments(InteractiveObject interactiveObj,
                                              Object argument0, Object argument1, Object argument2, Object argument3, boolean stateChanged) {
          ArrayList<Object> scriptParameters = new ArrayList<Object>();
  
          ScriptObject scriptObject = interactiveObj.getScriptObject();
  
          // Get the parameters/values passed to the Script/JavaScript
          for (ScriptObject.Field field : scriptObject.getFieldsArrayList()) {
              if ((scriptObject.getFieldAccessType(field) == ScriptObject.AccessType.INPUT_OUTPUT) ||
                      (scriptObject.getFieldAccessType(field) == ScriptObject.AccessType.INPUT_ONLY)) {
                  String fieldType = scriptObject.getFieldType(field);
                  DefinedItem definedItem = scriptObject.getFromDefinedItem(field);
                  EventUtility eventUtility = scriptObject.getFromEventUtility(field);
                  TimeSensor timeSensor = scriptObject.getFromTimeSensor(field);
  
  
                  if (fieldType.equalsIgnoreCase("SFBool")) {
                      if (definedItem != null) {
                          if (definedItem.getGVRSceneObject() != null) {
                              GVRComponent gvrComponent = definedItem.getGVRSceneObject().getComponent(
                                      GVRLight.getComponentType());
                              if (gvrComponent != null) {
                                  scriptParameters.add(gvrComponent.isEnabled());
                              }
                          }
                      }
                      else if (eventUtility != null) {
                          scriptParameters.add( eventUtility.getToggle() );
                      }
                      else if (interactiveObj.getSensorFromField() != null) {
                          if (interactiveObj.getSensorFromField().equals(Sensor.IS_OVER)) {
                              scriptParameters.add(argument0);
                          }
                          else if (interactiveObj.getSensorFromField().equals(Sensor.IS_ACTIVE)) {
                              scriptParameters.add(!stateChanged);
                          }
                      }
                      else if ( interactiveObj.getEventUtility() != null) {
                          scriptParameters.add( interactiveObj.getEventUtility().getToggle() );
                      }
                  }  // end if SFBool
                  else if ((fieldType.equalsIgnoreCase("SFVec2f")) && (definedItem == null)) {
                      // data from a Plane Sensor
                      if (interactiveObj.getSensorFromField() != null) {
                          if (interactiveObj.getSensor().getSensorType() == Sensor.Type.PLANE) {
                              scriptParameters.add( argument0 );
                              scriptParameters.add( argument1 );
                          }
                      }
                  }
                  else if ((fieldType.equalsIgnoreCase("SFFloat")) && (definedItem == null)) {
                      if (timeSensor != null) {
                          scriptParameters.add( timeSensor.getCycleInterval() );
                      }
                      else scriptParameters.add(argument0); // the time passed in from an SFTime node
                  }
                  else if ((fieldType.equalsIgnoreCase("SFRotation")) && (definedItem == null)) {
                      // data from a Cylinder or Sphere Sensor
                      if (interactiveObj.getSensorFromField() != null) {
                          if (interactiveObj.getSensor().getSensorType() == Sensor.Type.CYLINDER) {
                              scriptParameters.add(argument0);
                              scriptParameters.add(argument1);
                              scriptParameters.add(argument2);
                              scriptParameters.add(argument3);
                          }
                          else if (interactiveObj.getSensor().getSensorType() == Sensor.Type.SPHERE) {
                              scriptParameters.add(argument0);
                              scriptParameters.add(argument1);
                              scriptParameters.add(argument2);
                              scriptParameters.add(argument3);
                          }
                      }
                  }
                  else if (scriptObject.getFromDefinedItem(field) != null) {
                      if (fieldType.equalsIgnoreCase("SFColor")) {
                          float[] color = {0, 0, 0};
                          if (definedItem.getGVRMaterial() != null) {
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "diffuseColor") ) {
                                  float[] diffuseColor = definedItem.getGVRMaterial().getVec4("diffuse_color");
                                  for (int i = 0; i < 3; i++) {
                                      color[i] = diffuseColor[i]; // only get the first 3 values, not the alpha value
                                  }
                              } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "emissiveColor") ) {
                                  float[] emissiveColor = definedItem.getGVRMaterial().getVec4("emissive_color");
                                  for (int i = 0; i < 3; i++) {
                                      color[i] = emissiveColor[i]; // only get the first 3 values, not the alpha value
                                  }
                              } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "specularColor") ) {
                                  float[] specularColor = definedItem.getGVRMaterial().getVec4("specular_color");
                                  for (int i = 0; i < 3; i++) {
                                      color[i] = specularColor[i]; // only get the first 3 values, not the alpha value
                                  }
                              }
                          } else if (definedItem.getGVRSceneObject() != null) {
                              // likely a light object so get its properties
                              GVRComponent gvrComponent = definedItem.getGVRSceneObject().getComponent(
                                      GVRLight.getComponentType());
                              if (gvrComponent != null) {
                                  float[] lightColor = {0, 0, 0, 0};
                                  if (gvrComponent instanceof GVRSpotLight) {
                                      GVRSpotLight gvrSpotLightBase = (GVRSpotLight) gvrComponent;
                                      lightColor = gvrSpotLightBase.getDiffuseIntensity();
                                  } else if (gvrComponent instanceof GVRPointLight) {
                                      GVRPointLight gvrPointLightBase = (GVRPointLight) gvrComponent;
                                      lightColor = gvrPointLightBase.getDiffuseIntensity();
                                  } else if (gvrComponent instanceof GVRDirectLight) {
                                      GVRDirectLight gvrDirectLightBase = (GVRDirectLight) gvrComponent;
                                      lightColor = gvrDirectLightBase.getDiffuseIntensity();
                                  }
                                  for (int i = 0; i < 3; i++) {
                                      color[i] = lightColor[i]; // only get the first 3 values, not the alpha value
                                  }
                              }
                          }
                          // append the parameters of the SFColor passed to the SCRIPT's javascript code
                          for (int i = 0; i < color.length; i++) {
                              scriptParameters.add(color[i]);
                          }
                      }  // end if SFColor
  
                      else if (fieldType.equalsIgnoreCase("SFRotation")) {
                          if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "rotation") ) {
                              if (definedItem.getGVRSceneObject() != null) {
                                  // Likely the rotation in a Transform / GVRTransform
                                  // GearVRf saves rotations as quaternions, but X3D scripting uses AxisAngle
                                  // So, these values were saved as AxisAngle in the DefinedItem object
                                  scriptParameters.add(definedItem.getAxisAngle().x);
                                  scriptParameters.add(definedItem.getAxisAngle().y);
                                  scriptParameters.add(definedItem.getAxisAngle().z);
                                  scriptParameters.add(definedItem.getAxisAngle().angle);
                              }
                          }  // rotation parameter
                          else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "orientation") ) {
                              if ( definedItem.getViewpoint() != null ) {
                                  // have a Viewpoint which for the time-being means get the current direction of the camera
                                  float[] lookAt = gvrContext.getMainScene().getMainCameraRig().getLookAt();
                                  Vector3f cameraDir = new Vector3f(lookAt[0], lookAt[1], lookAt[2]);
                                  Quaternionf q = ConvertDirectionalVectorToQuaternion(cameraDir);
                                  AxisAngle4f cameraAxisAngle = new AxisAngle4f();
                                  q.get(cameraAxisAngle);
                                  scriptParameters.add( cameraAxisAngle.x );
                                  scriptParameters.add( cameraAxisAngle.y );
                                  scriptParameters.add( cameraAxisAngle.z );
                                  scriptParameters.add( cameraAxisAngle.angle );
                              }
                          }  // orientation parameter
                      }  // end if SFRotation
                      else if (fieldType.equalsIgnoreCase("SFVec3f")) {
                          if (definedItem.getGVRSceneObject() != null) {
                              GVRComponent gvrComponent = definedItem.getGVRSceneObject().getComponent(
                                      GVRLight.getComponentType());
                              if (gvrComponent != null) {
                                  // it's a light
                                  float[] parameter = {0, 0, 0};
                                  if (gvrComponent instanceof GVRSpotLight) {
                                      GVRSpotLight gvrSpotLightBase = (GVRSpotLight) gvrComponent;
                                      if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "attenuation") ) {
                                          parameter[0] = gvrSpotLightBase.getAttenuationConstant();
                                          parameter[1] = gvrSpotLightBase.getAttenuationLinear();
                                          parameter[2] = gvrSpotLightBase.getAttenuationQuadratic();
                                      } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "location") ) {
                                          parameter[0] = definedItem.getGVRSceneObject().getTransform().getPositionX();
                                          parameter[1] = definedItem.getGVRSceneObject().getTransform().getPositionY();
                                          parameter[2] = definedItem.getGVRSceneObject().getTransform().getPositionZ();
                                      } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "direction") ) {
                                          parameter[0] = definedItem.getDirection().x;
                                          parameter[1] = definedItem.getDirection().y;
                                          parameter[2] = definedItem.getDirection().z;
                                      }
                                  } else if (gvrComponent instanceof GVRPointLight) {
                                      GVRPointLight gvrPointLightBase = (GVRPointLight) gvrComponent;
                                      if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "attenuation") ) {
                                          parameter[0] = gvrPointLightBase.getAttenuationConstant();
                                          parameter[1] = gvrPointLightBase.getAttenuationLinear();
                                          parameter[2] = gvrPointLightBase.getAttenuationQuadratic();
                                      } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "location") ) {
                                          parameter[0] = definedItem.getGVRSceneObject().getTransform().getPositionX();
                                          parameter[1] = definedItem.getGVRSceneObject().getTransform().getPositionY();
                                          parameter[2] = definedItem.getGVRSceneObject().getTransform().getPositionZ();
                                      }
                                  } else if (gvrComponent instanceof GVRDirectLight) {
                                      GVRDirectLight gvrDirectLightBase = (GVRDirectLight) gvrComponent;
                                      if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "direction") ) {
                                          parameter[0] = definedItem.getDirection().x;
                                          parameter[1] = definedItem.getDirection().y;
                                          parameter[2] = definedItem.getDirection().z;
                                      }
                                  }  // end GVRDirectLight
                                  // append the parameters of the lights passed to the SCRIPT's javascript code
                                  for (int i = 0; i < parameter.length; i++) {
                                      scriptParameters.add(parameter[i]);
                                  }
                              }  //  end gvrComponent != null. it's a light
                              else {
                                  if (definedItem.getGVRSceneObject() != null) {
                                      if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "translation") ) {
                                          GVRSceneObject gvrSceneObjectTranslation = root
                                                  .getSceneObjectByName((definedItem.getGVRSceneObject().getName() + x3dObject.TRANSFORM_TRANSLATION_));
                                          scriptParameters.add(gvrSceneObjectTranslation.getTransform().getPositionX());
                                          scriptParameters.add(gvrSceneObjectTranslation.getTransform().getPositionY());
                                          scriptParameters.add(gvrSceneObjectTranslation.getTransform().getPositionZ());
                                      } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "scale") ) {
                                          GVRSceneObject gvrSceneObjectScale = root
                                                  .getSceneObjectByName((definedItem.getGVRSceneObject().getName() + x3dObject.TRANSFORM_SCALE_));
                                          scriptParameters.add(gvrSceneObjectScale.getTransform().getScaleX());
                                          scriptParameters.add(gvrSceneObjectScale.getTransform().getScaleY());
                                          scriptParameters.add(gvrSceneObjectScale.getTransform().getScaleZ());
                                      }
                                  }
                              }
                          }  // end SFVec3f GVRSceneObject
                      }  // end if SFVec3f
  
                      else if (fieldType.equalsIgnoreCase("SFVec2f")) {
                          float[] parameter = {0, 0};
                          if (definedItem.getGVRMaterial() != null) {
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "translation") ) {
                                  parameter[0] = definedItem.getTextureTranslation().getX();
                                  parameter[1] = -definedItem.getTextureTranslation().getY();
                              }
                              else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "scale") ) {
                                  parameter[0] = definedItem.getTextureScale().getX();
                                  parameter[1] = definedItem.getTextureScale().getY();
                              }
                              else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "center") ) {
                                  parameter[0] = -definedItem.getTextureCenter().getX();
                                  parameter[1] = definedItem.getTextureCenter().getY();
                              }
                              // append the parameters of the lights passed to the SCRIPT's javascript code
                              for (int i = 0; i < parameter.length; i++) {
                                  scriptParameters.add(parameter[i]);
                              }
                          }  // end SFVec3f GVRMaterial
                      }  // end if SFVec2f
  
                      else if (fieldType.equalsIgnoreCase("SFFloat")) {
                          if (definedItem.getGVRMaterial() != null) {
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "shininess") ) {
                                  scriptParameters.add(
                                          definedItem.getGVRMaterial().getFloat("specular_exponent")
                                  );
                              }
                              else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "transparency") ) {
                                  scriptParameters.add(definedItem.getGVRMaterial().getOpacity());
                              }
  
                              else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "rotation") ) {
                                  scriptParameters.add(definedItem.getTextureRotation().getValue());
                              }
  
                          } else if (definedItem.getGVRSceneObject() != null) {
                              // checking if it's a light
                              GVRComponent gvrComponent = definedItem.getGVRSceneObject().getComponent(
                                      GVRLight.getComponentType());
                              if (gvrComponent != null) {
                                  float parameter = 0;
                                  if (gvrComponent instanceof GVRSpotLight) {
                                      GVRSpotLight gvrSpotLightBase = (GVRSpotLight) gvrComponent;
                                      if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "beamWidth") ) {
                                          parameter = gvrSpotLightBase.getInnerConeAngle() * (float) Math.PI / 180;
                                      } else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "cutOffAngle") ) {
                                          parameter = gvrSpotLightBase.getOuterConeAngle() * (float) Math.PI / 180;
                                      }
                                  } else if (gvrComponent instanceof GVRPointLight) {
                                      GVRPointLight gvrPointLightBase = (GVRPointLight) gvrComponent;
  
                                  } else if (gvrComponent instanceof GVRDirectLight) {
                                      GVRDirectLight gvrDirectLightBase = (GVRDirectLight) gvrComponent;
  
                                  }
                                  scriptParameters.add(parameter);
                              }
                          }
                          else if (definedItem.getGVRVideoSceneObject() != null) {
                              GVRVideoSceneObjectPlayer gvrVideoSceneObjectPlayer = definedItem.getGVRVideoSceneObject().getMediaPlayer();
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field),"speed") ) {
                                  if ( gvrVideoSceneObjectPlayer == null) {
                                      // special case upon initialization of the movie texture, so the speed is init to 1
                                      scriptParameters.add( 1 );
                                  }
                                  else if ( gvrVideoSceneObjectPlayer.getPlayer() == null) {
                                      ; // could occur prior to movie engine is setup
                                  }
                                  else {
                                      ExoPlayer exoPlayer = (ExoPlayer) gvrVideoSceneObjectPlayer.getPlayer();
                                      PlaybackParameters currPlaybackParamters = exoPlayer.getPlaybackParameters();
                                      scriptParameters.add( currPlaybackParamters.speed );
                                  }
                              } // end check for speed
                          }  // end if SFFloat GVRVideoSceneObject
                      }  // end if SFFloat
                      else if (fieldType.equalsIgnoreCase("SFTime")) {
                          if (definedItem.getGVRVideoSceneObject() != null) {
                              GVRVideoSceneObjectPlayer gvrVideoSceneObjectPlayer = definedItem.getGVRVideoSceneObject().getMediaPlayer();
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field),"duration") ) {
                                  if ( gvrVideoSceneObjectPlayer == null) {
                                      // special case upon initialization of the movie texture, so the speed is init to 1
                                      scriptParameters.add( 1 );
                                  }
                                  else if ( gvrVideoSceneObjectPlayer.getPlayer() == null) {
                                      ; // could occur prior to movie engine is setup
                                  }
                                  else {
                                      ExoPlayer exoPlayer = (ExoPlayer) gvrVideoSceneObjectPlayer.getPlayer();
                                      scriptParameters.add( exoPlayer.getDuration() );
                                  }
                              } // end check for duration
                              else if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field),"elapsedTime") ) {
                                  if ( gvrVideoSceneObjectPlayer == null) {
                                      // special case upon initialization of the movie texture, so the elapsedTime is init to 0
                                      scriptParameters.add( 0 );
                                  }
                                  else if ( gvrVideoSceneObjectPlayer.getPlayer() == null) {
                                      ; // could occur prior to movie engine is setup
                                  }
                                  else {
                                      ExoPlayer exoPlayer = (ExoPlayer) gvrVideoSceneObjectPlayer.getPlayer();
                                      // getContentPosition is for possible advertisements, and returns the same
                                      // value as getCurrentPosition if no ads.
                                      scriptParameters.add( exoPlayer.getContentPosition() );
                                  }
                              } // end check for elapsedTime
                          }  // end if SFTime GVRVideoSceneObject
                      } // end if SFTime
                      else if (fieldType.equalsIgnoreCase("SFInt32")) {
                          int parameter = 0;
                          if (definedItem.getGVRSceneObject() != null) {
                              GVRComponent gvrComponent = definedItem.getGVRSceneObject().getComponent(GVRSwitch.getComponentType());
                              if (gvrComponent != null) {
                                  if (gvrComponent instanceof GVRSwitch) {
                                      // We have a Switch node
                                      GVRSwitch gvrSwitch = (GVRSwitch) gvrComponent;
                                      parameter = gvrSwitch.getSwitchIndex();
                                  }
                              }
                          }
                          scriptParameters.add(parameter);
                      }
                      else if (fieldType.equalsIgnoreCase("SFString")) {
                          if ( definedItem.getGVRTextViewSceneObject() != null) {
                              if (scriptObject.getFromDefinedItemField(field).equalsIgnoreCase("style")) {
                                  GVRTextViewSceneObject.fontStyleTypes styleType =
                                          definedItem.getGVRTextViewSceneObject().getStyleType();
                                  String fontStyle = "";
                                  if (styleType == GVRTextViewSceneObject.fontStyleTypes.PLAIN)
                                      fontStyle = "PLAIN";
                                  else if (styleType == GVRTextViewSceneObject.fontStyleTypes.BOLD)
                                      fontStyle = "BOLD";
                                  else if (styleType == GVRTextViewSceneObject.fontStyleTypes.BOLDITALIC)
                                      fontStyle = "BOLDITALIC";
                                  else if (styleType == GVRTextViewSceneObject.fontStyleTypes.ITALIC)
                                      fontStyle = "ITALIC";
                                  if (fontStyle != "") scriptParameters.add("\'" + fontStyle + "\'");
                                  else Log.e(TAG, "style in ROUTE not recognized.");
                              }
                          }
                      }  //  end SFString
                      else if (fieldType.equalsIgnoreCase("MFString")) {
                          //TODO: will need to handle multiple strings particularly for Text node
                          GVRTexture gvrTexture = definedItem.getGVRTexture();
                          if (gvrTexture != null) {
                              // have a url containting a texture map
                              if ( StringFieldMatch( scriptObject.getFromDefinedItemField(field), "url") ) {
                                  GVRImage gvrImage = gvrTexture.getImage();
                                  if ( gvrImage != null ) {
                                      if ( gvrImage.getFileName() != null) {
                                          scriptParameters.add("\'" + gvrImage.getFileName() + "\'");
                                      }
                                  }
                                  else Log.e(TAG, "ImageTexture name not DEFined");
                              }
                              else Log.e(TAG, "ImageTexture SCRIPT node url field not found");
                          }
                          else Log.e(TAG, "Unable to set MFString in SCRIPT node");
                      } // end MFString
                  }  //  end if definedItem != null
              }  //  end INPUT_ONLY, INPUT_OUTPUT (only ways to pass parameters to JS parser
          }  // for loop checking for parameters passed to the JavaScript parser
  
          // create the parameters array
          if (scriptObject.getTimeStampParameter())
              scriptParameters.add(1, 0); // insert the timeStamp parameter if it's used
          Object[] parameters = new Object[scriptParameters.size()];
          for (int i = 0; i < scriptParameters.size(); i++) {
              parameters[i] = scriptParameters.get(i);
          }
          return parameters;
      }