instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 17, 2018, 08:24:42 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: delete dynamic route  (Read 5224 times)
kulberg
Newbie
*
Posts: 7


View Profile
« on: April 29, 2011, 03:03:15 pm »

Please

I need to write a script for adding and deleting dynamic routes.
I can add but not can delete.

In the console, indicating ECMASpt 46 FATAL: Error: First argument to ExecutionContext.deleteRoute () must be a Route object (scene.deleteRoute (TIMER, 'fraction_changed', this, 'set_fraction')Wink

Here is the code:

<Script DEF='Rota' directOutput='true'><![CDATA[javascript:
   
   scene = Browser.currentScene;
 
    function initialize()
   {
       TIMER = scene.getNamedNode('TIMER');
      HUMANOIDROOT_POSITION_ANIMATOR = scene.getNamedNode('HUMANOIDROOT_POSITION_ANIMATOR');
      
      scene.addRoute( TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction' );

    
      scene.deleteRoute( TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction' );
      
    }
 
   ]]>
    </Script>

Somebody can help me?
Logged
Peter_Pig
Newbie
*
Posts: 23


View Profile
« Reply #1 on: April 29, 2011, 08:37:16 pm »

Hi Kulberg.

My guessing : In your example code you are trying to add and delete a route during the same "frame".

That means : the route you are trying to delete does not yet exist when you try to delete it.

I hope I'm not totally wrong.

Regards

Peter

Logged
Peter_Pig
Newbie
*
Posts: 23


View Profile
« Reply #2 on: April 30, 2011, 06:32:33 am »

Code:

<Script DEF='Rota' directOutput='true'><![CDATA[javascript:

   scene = Browser.currentScene;
    function kill_route(){
          
               TIMER = scene.getNamedNode('TIMER');
               HUMANOIDROOT_POSITION_ANIMATOR = scene.getNamedNode('HUMANOIDROOT_POSITION_ANIMATOR');

               scene.deleteRoute( TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction' );
    }
    function initialize()
{
      
  HUMANOIDROOT_POSITION_ANIMATOR = scene.getNamedNode('HUMANOIDROOT_POSITION_ANIMATOR');
 
  scene.addRoute( TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction' );

 
  setTimeout('kill_route()',300);
 
    }
 
]]>
    </Script>


This one should do. But best would probably be to trigger "kill_route()" by a routed event.

The main idea is to go sure that the route to be deleted is already existing.

Anyway, I guess that there must be an easier way for achieving your final goal, instead of adding and deleting a route in such a short lapse of time.

Have you tried enabling and disabling the TimeSensor? Or setting a pause_time?

Regards,

Peter
« Last Edit: April 30, 2011, 06:34:31 am by Peter_Pig » Logged
pdaehne
Administrator
Sr. Member
*****
Posts: 250


View Profile
« Reply #3 on: April 30, 2011, 12:00:09 pm »

Old VRML API:

http://doc.instantreality.org/apidocs/scripting/javascript/classBrowser.html

Code:
Browser.addRoute(TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction');
Browser.deleteRoute(TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction');

New X3D API:

http://doc.instantreality.org/apidocs/scripting/javascript/classExecutionContext.html

Code:
var route = Browser.currentScene.addRoute(TIMER, 'fraction_changed', HUMANOIDROOT_POSITION_ANIMATOR, 'set_fraction');
Browser.currentScene.deleteRoute(route);
Logged
kulberg
Newbie
*
Posts: 7


View Profile
« Reply #4 on: May 01, 2011, 03:51:54 pm »

I wrote the commands in the initialize function just to check the operation.

Thank you very much for help, and especially to pdaehne. Your solution was exactly what I needed.

Thanks everyone!
Logged
timpane
Newbie
*
Posts: 1


View Profile
« Reply #5 on: September 17, 2013, 10:51:50 am »

That means : the route you are trying to delete does not yet exist when you try to delete it.
Logged

X
anaergorn
Newbie
*
Posts: 1


View Profile WWW
« Reply #6 on: March 06, 2016, 04:07:04 am »

All routes that are created when a user is not logged are not associated with any specific user.  It is not possible to "claim ownership" of a route and delete it.

Routes that are created while logged in are owned by the user creating the routes.  The user creating the route can delete any of their routes from the "My Routes" page.

runninggirlcg

Click here!
Logged

h
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines