instantreality forum
news: Welcome to the instantreality forums!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
January 17, 2018, 08:17:08 am


Login with username, password and session length


Pages: [1]
  Print  
Author Topic: manipulation with X3D Transform Translation by variable  (Read 2974 times)
goliathX
Newbie
*
Posts: 2


View Profile
« on: November 18, 2014, 04:07:17 am »

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 Wink

my code looks like this :

<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>
Logged
mlimper
Administrator
Newbie
*****
Posts: 7


View Profile
« Reply #1 on: November 18, 2014, 10:33:31 am »

Hi,

thanks for your interest in X3DOM.

Please use the X3DOM mailing list "x3dom-users" for this kind of questions:
http://doc.x3dom.org/

It looks like you need to do a basic string concatenation in JavaScript (using the "+" operator). Please check a basic introduction to JavaScript for more information on this topic.

For your particular problem, this might work:

setAttribute('translation', (mm*1000) + ' 0 0');

Regards,

Max
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.15 | SMF © 2011, Simple Machines