示例#1
0
  /**
   * Notification that the script has completed the setup and should go about its own internal
   * initialization.
   */
  public void initialize() {
    touchTime = (SFTime) fields.get("touchTime");

    // Listen to events on touchTime
    touchTime.addX3DEventListener(this);

    // Create nodes directly in the parent scene
    X3DScene scene = (X3DScene) browser.getExecutionContext();

    X3DShapeNode shape = (X3DShapeNode) scene.createNode("Shape");
    X3DGeometryNode box = (X3DGeometryNode) scene.createNode("Box");
    X3DNode touchSensor = scene.createNode("TouchSensor");

    shape.setGeometry(box);

    // Create a Group to hold the nodes
    X3DGroupingNode group = (X3DGroupingNode) scene.createNode("Group");

    // Add the shape and sensor to the group
    group.addChild(shape);
    group.addChild(touchSensor);

    // Add the nodes to the scene
    scene.addRootNode(group);

    // Get a handle to the toplevel execution context
    scene.addRoute(touchSensor, "touchTime", selfRef, "touchTime");
  }
 /**
  * Return the bindTime double value.
  *
  * @return The bindTime double value.
  */
 public double getBindTime() {
   if (bindTime == null) {
     bindTime = (SFTime) getField("bindTime");
   }
   return (bindTime.getValue());
 }