[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[x3d-public] NullPointerException when loading scene with script node
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
url "javascript: function test(value) { }"
}
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"});
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();
A few more details, the Xj3D Browser application also cannot load the file
and outputs the following:
Exception parsing file at line: 10 col: 15
Encountered "eventIn SFTime test" at line 11, column 9.
Was expecting one of:
"inputOnly" ...
"outputOnly" ...
"initializeOnly" ...
"inputOutput" ...
<ID> <ID> "{" ...
<ID> "Script" ...
<ID> "DEF" ...
<ID> "USE" ...
<ID> "NULL" ...
<ID> "TRUE" ...
<ID> "FALSE" ...
<ID> <NUMBER_LITERAL> ...
<ID> <STRING_LITERAL> ...
<ID> "[" ...
<ID> "IS" ...
"ROUTE" ...
"PROTO" ...
"EXTERNPROTO" ...
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.
I guess I must be doing something really stupid here but I can't figure out
what. Any help?
George
-------------------------------------------------------------------------
for list subscription/unsubscription,
go to http://www.web3d.org/cgi-bin/public_list_signup/lwgate/listsavail.html