Skip to content

Instantly share code, notes, and snippets.

@andreasplesch
Last active October 15, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreasplesch/8ded7b7ffb598a63c44318f5810b260d to your computer and use it in GitHub Desktop.
Save andreasplesch/8ded7b7ffb598a63c44318f5810b260d to your computer and use it in GitHub Desktop.
x_ite test
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile='Full' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd'>
<Scene>
<Transform DEF='Ball'>
<Shape>
<Appearance>
<Material
ambientIntensity='0.5'
diffuseColor='1 1 1'
specularColor='0.7 0.7 0.7'
shininess='0.4'/>
</Appearance>
<Sphere/>
</Shape>
</Transform>
<TimeSensor DEF='Clock'
cycleInterval='2'
loop='true'
startTime='1'/>
<Script DEF='Bouncer'>
<field accessType='initializeOnly' type='SFFloat' name='bounceHeight' value='3'/>
<field accessType='inputOnly' type='SFFloat' name='set_fraction'/>
<field accessType='outputOnly' type='SFVec3f' name='value_changed'/>
<field accessType='inputOutput' type='SFBool' name='enabled' value='true'/>
<![CDATA[ecmascript:
function set_fraction (fraction, time)
{
if (!enabled)
return;
var y = 4.0 * bounceHeight * fraction * (1.0 - fraction);
value_changed [0] = 0.0;
value_changed [1] = y;
value_changed [2] = 0.0;
}
]]>
</Script>
<ROUTE fromNode='Clock' fromField='fraction_changed' toNode='Bouncer' toField='set_fraction'/>
<ROUTE fromNode='Bouncer' fromField='value_changed' toNode='Ball' toField='set_translation'/>
</Scene>
</X3D>
<?xml version="1.0" encoding="UTF-8"?>
<X3D profile='Full' version='3.3' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.3.xsd'>
<Scene>
<Transform DEF='Ball'>
<Shape>
<Appearance>
<Material
ambientIntensity='0.5'
diffuseColor='1 1 1'
specularColor='0.7 0.7 0.7'
shininess='0.4'/>
</Appearance>
<Sphere/>
</Shape>
</Transform>
<TimeSensor DEF='Clock'
cycleInterval='2'
loop='true'
startTime='1'/>
<Script DEF='Bouncer'>
<field accessType='initializeOnly' type='SFFloat' name='bounceHeight' value='3'/>
<field accessType='inputOnly' type='SFFloat' name='set_fraction'/>
<field accessType='outputOnly' type='SFVec3f' name='value_changed'/>
<field accessType='inputOutput' type='SFBool' name='enabled' value='true'/>
<![CDATA[ecmascript:
console.log("Script main scope. ", this);
alert("What Now ? Disabling.");
Browser.canvas[0].remove();
document.body.innerHTML="Sorry, might have stolen all."
//debugger;
function set_fraction (fraction, time)
{
if (!enabled)
return;
var y = 4.0 * bounceHeight * fraction * (1.0 - fraction);
value_changed [0] = 0.0;
value_changed [1] = y;
value_changed [2] = 0.0;
}
]]>
</Script>
<ROUTE fromNode='Clock' fromField='fraction_changed' toNode='Bouncer' toField='set_fraction'/>
<ROUTE fromNode='Bouncer' fromField='value_changed' toNode='Ball' toField='set_translation'/>
</Scene>
</X3D>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="https://code.create3000.de/x_ite/latest/dist/x_ite.css"/>
<script type="text/javascript" src="https://code.create3000.de/x_ite/latest/dist/x_ite.min.js"></script>
<style type="text/css">
X3DCanvas {
width: 768px;
height: 432px;
}
</style>
</head>
<body>
<X3DCanvas src="BouncerSafe.x3d">
<p>Your browser may not support all features required by X_ITE.
For a better experience, keep your browser up to date.
<a href="http://outdatedbrowser.com">Check here for latest versions.</a></p>
</X3DCanvas>
</body>
</html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="https://code.create3000.de/x_ite/latest/dist/x_ite.css"/>
<script type="text/javascript" src="https://code.create3000.de/x_ite/latest/dist/x_ite.min.js"></script>
<style type="text/css">
X3DCanvas {
width: 768px;
height: 432px;
}
</style>
</head>
<body>
<X3DCanvas src="BouncerUnsafe.x3d">
<p>Your browser may not support all features required by X_ITE.
For a better experience, keep your browser up to date.
<a href="http://outdatedbrowser.com">Check here for latest versions.</a></p>
</X3DCanvas>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment