[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [x3d-public] NullPointerException when loading scene with script node



Thanx to all for so many replies in such little time. Indeed, after correcting eventIn and ecmascript I was able to load the x3d file (I guess I must read the x3d spec a bit more thoroughly).

Still, I can't load the vrml version of the file using the code I posted in my previous message, which is not a big deal but it would be good to know why. The file would, in that case, be:

#VRML V2.0 utf8
DEF s Shape {
appearance Appearance { }
geometry Box { }
}
DEF sc Script {
eventIn SFTime test
url "javascript: function test(value) { }"
}

A NullPointerException is generated by line 299 of ScriptContentLoader.java:

ScriptEngine engine = (ScriptEngine)engineMap.get(mime_type);

Any ideas? Just a reminder that Xj3D Browser can indeed load the above file without any errors.

George

----- Original Message ----- From: "Alan Hudson" <giles@yumetech.com>
To: "George Anastassakis" <anastas@unipi.gr>
Cc: <x3d-public@web3d.org>
Sent: Wednesday, March 22, 2006 9:54 PM
Subject: Re: [x3d-public] NullPointerException when loading scene with script node



George Anastassakis wrote:
Hello all

I'm trying to load a scene with a Shape and a Script node but I cannot get it right. The file is:

#X3D V3.0 utf8
PROFILE Immersive
DEF s Shape {
appearance Appearance { }
geometry Box { }
}
DEF sc Script {
eventIn SFTime test
this is not valid X3D.  it must be inputOnly

url "javascript: function test(value) { }"
}

this should be ecmascript:

Of course, the Script node does nothing but I'm just trying to get it to load. The code I use is the following:

Properties props = new Properties();
x3dComp = BrowserFactory.createX3DComponent(props);
Browser browser = x3dComp.getBrowser();
contentPane.add((JPanel) x3dComp.getImplementation());
X3DScene scene = browser.createX3DFromURL(new String[] {"test.wrl"});
this needs to be an X3D file, not a VRML file.

browser.replaceWorld(scene);

The createX3DFromURL call generates a NullPointerException, which seems to be caused by line 302 in SAIBrowser.java (scene is null?):

301: VRMLScene scene=theBrowserImpl.createX3DFromURL(url);
302: VRMLExecutionSpace space = (VRMLExecutionSpace)scene.getRootNode();

However, if I change the header to "#VRML V2.0 utf8" and remove the PROFILE statement, Xj3D Browser does load the file but my code does not.

your mixing specs.  make sure you either do things completely VRML or X3D.

I guess I must be doing something really stupid here but I can't figure out what. Any help?



--
Alan Hudson

President Yumetech, Inc. www.yumetech.com
President Web3D Consortium www.web3d.org
206 340 8900
-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html




------------------------------------------------------------------------- for list subscription/unsubscription, go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html