您能告诉我如何在X3d字段翻译的字段值中使用变量吗?我喜欢用mm处理场景中的对象,因为我有autocad中的对象,所以我的想法是指定我的计算平均值,比如var mm = 0.0010236666666667,然后是setAttribute(‘’,(mm*1000)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”></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>
发布于 2014-11-18 10:06:44
用于此的Solved.Right语句是:
{
var mm = 0.0010236666666667;
document.getElementById("test").setAttribute('translation',(mm*1500) + '0 0');
}
当然,更好的方法是给另一个变量赋值,比如毫米的输入数。
https://stackoverflow.com/questions/26985145
复制相似问题