0

你能告诉我如何在 X3d 字段转换的字段值中使用变量吗?我喜欢以 mm 为单位处理场景中的对象,因为我有来自 autocad 的对象,所以我的想法是指定我的计算平均值,例如var mm = 0.0010236666666667然后像 setAttribute('translation','(mm*1000) 0 0'); 非常感谢大家 ;)

<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”&gt;</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>

4

1 回答 1

0

Solved.Right 句子是:

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

当然,最好分配另一个变量,例如输入的毫米数。

于 2014-11-18T10:06:44.990 回答