This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > VRML > December 2004 > Another interesting scripting problem....





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Another interesting scripting problem....
bensmyth

2004-12-21, 12:16 pm

Anyone care to try to put together ANY constructive arguments for why this
won't work!?! I'm completely baffled......!!

I've coded the same thing in x3d and vrml (.wrl), they both use the SAME
script. The vrml file works as expected (outputs 7) the x3d file outputs
'undefined'..... ?!?!

The only solution I have that sounds viable is 'browser problem'


### VRML CODE ###

#VRML V2.0 utf8

Script {
url "s1.js"
}


### X3D CODE ###

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN"
"http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile="Immersive">
<Scene>
<Script url="s1.js"/>
</Scene>
</X3D>


### s1.js (Javascript code) ###
function initialize() {
var i1 = new Item(1,2,3);
var i2 = new Item(4,5,6);
var i3 = new Item(7,8,9);

var itemArray = new ItemArray();
itemArray.addItem(i1);
itemArray.addItem(i2);
itemArray.addItem(i3);

print(i3.x); //outputs 7 in X3D and VRML
print(itemArray.getItem().x); //Should output 7! Only VRML manages it
}


function Item(x, y, z) {
this.x = x;
this.y = y;
this.z = z;
}


function ItemArray() {
this.items = Array(5);

this.addItem = addItem;
this.getItem = getItem;
}

function addItem(item) {
this.items.push(item);
}

function getItem() {
return this.items.pop();
}


Any help will be much appreciated - and may keep me sane!!


Regards,

Ben


bensmyth

2004-12-21, 12:16 pm

> The only solution I have that sounds viable is 'browser problem'


It is a browser issue! (ANOTHER ONE!)

I tried opening the wrl file with Octaga and it produced the same output.
Cortona on the other hand handles the wrl file with not problems!


Regards,

Ben


Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews