Help!! How do you make models appear and dissappear ...."
Hi, Bob,
if you are interested in a working example of code, we can provide you also
with a
second one which we hope demonstrate what you need in your world.
Maybe someone can help us to program proper the TimerSensor?
Klaudius Grzondziel
Just look and see, how a new element appear in the same place as the
preceeding one:
#VRML V2.0 utf8
WorldInfo {title "VRML97 Test" info ["(C) Copyright 2000 APS GmbH"
DEF WORLD Transform { children [
DEF TIMER TimeSensor {loop TRUE cycleInterval 6}
]}
DEF SCRIPT Script {
eventOut MFNode newNode
eventOut MFNode killNode
eventOut SFBool newLoop
eventIn SFBool exchangeNode
eventIn SFFloat isNewLoop
field SFInt32 NodeNo 0
url "javascript:
function isNewLoop (time) {
if (time < .015) {newLoop = TRUE;}
}
function exchangeNode () {
if (NodeNo < 4) {NodeNo = NodeNo + 1;}
else {NodeNo = 1;}
killNode = newNode;
if (NodeNo == 1) {
var String;
String = 'Transform {children [ Shape {appearance Appearance {material
Material {diffuseColor .8 .3 .5}} geometry Box {}}]}';
newNode = Browser.createVrmlFromString(String);
}
else if (NodeNo == 2) {
var String;
String = 'Transform {children [ Shape {appearance Appearance {material
Material {diffuseColor 0 .5 .7}} geometry Cone {}}]}';
newNode = Browser.createVrmlFromString(String);
}
else if (NodeNo == 3) {
var String;
String = 'Transform {children [ Shape {appearance Appearance {material
Material {diffuseColor 0 .6 .5}} geometry Cylinder {}}]}';
newNode = Browser.createVrmlFromString(String);
}
else if (NodeNo == 4) {
var String;
String = 'Transform {children [ Shape {appearance Appearance {material
Material {diffuseColor .7 0 .9}} geometry Sphere {}}]}';
newNode = Browser.createVrmlFromString(String);
}
}"}
ROUTE TIMER.fraction_changed TO SCRIPT.isNewLoop
ROUTE SCRIPT.newLoop TO SCRIPT.exchangeNode
ROUTE SCRIPT.newNode TO WORLD.addChildren
ROUTE SCRIPT.killNode TO WORLD.removeChildren
Quote:
> Hi everyone!!
> I have just a simple question.. how do you make a models in VRML scene
> appear and dissappear, with the consideration of ACTUALLY taking out the
> model when it is dissappeared..?eg. I am trying to make some models that
> appear when TIME sensor detects
> that the object has "live" for 5 second.. after 5 second.. the object is
> "taken out" of the scene,
> and a new one will appear in the 6th second.my Real question is.. how do I
> "take out" the model that I don't want to appear in the scene when it is
> not needed? what script/Switch do I have to use?
> Many Thanks in Advance
> -Bob