manipulation with X3D Transform Translation by variable

540 views Asked by At

Can you please somebody tell me way to use a variable in field value of X3d field translation?Id like manipulate with objects on the scene in mm because i have objects from autocad so my idea is to specify my calculated average value like var mm = 0.0010236666666667 and then something like setAttribute('translation','(mm*1000) 0 0'); thanks a lot guys ;)

<html>

<head>

<style>

#x3d 
{
width:100%;height:100%;border-width:0px;
    }

</style>

<script type='text/javascript' src='x3dom.js'></script>
<link rel='stylesheet' type='text/css' href='x3dom.css'></link> 
<script>

function start() 

{
document.getElementById("test").setAttribute('translation','0 0 0');
}

</script>
</head>

<body>

<x3d style="border-width:0px" onclick="start()">
<scene > 
<Transform id="test" translation="-4.2 0 0" rotation="1 0 0 -1.4">
<inline url="celek.x3d"> </inline> 
</transform>
<SpotLight DEF='Lamp' beamWidth='4' color=white cutOffAngle='0.78' location='-1 2 3' radius='60'/> 
<viewpoint position="-1 0.9 9 "></viewpoint>     
<navigationInfo type=“none”></navigationInfo> 
<background  groundAngle=' 1.57079'  groundColor='1 0.8 0.6 , 0.6 0.4 0.2'  skyAngle='0.2 ,1.57079' skyColor='1 1 0,  1 1 1,  0.2 0.2 1'  ></background>
</scene> 
  </x3d> 

</body>

</html>

1

There are 1 answers

0
Goliath On

Solved.Right sentence for this is :

{
var mm = 0.0010236666666667;
document.getElementById("test").setAttribute('translation',(mm*1500) + '0 0');
}

of course its better to assign another variable like an input number of mm´s.