Вращающиеся объекты в x3d
Так что последние пару часов я пытался заставить эту модель дивана, которую я получил отсюда, повернуть на 360* вокруг своей оси х, но безуспешно. Код, который я использовал, ниже. Сама модель дивана содержит несколько разных предметов. Как руки, ноги, и woodarm, и я пытаюсь заставить все объекты в модели вращаться по оси X.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "http://www.web3d.org/specifications/x3d-3.0.dtd">
<X3D profile='Interchange' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation=' http://www.web3d.org/specifications/x3d-3.0.xsd '>
<head>
<meta name='title' content='Sofa.x3d' />
<meta name='description' content='Sofa' />
<meta name='creator' content='Seksit Siripala' />
<meta name='created' content='September 10, 2002' />
<meta name='modified' content='October 11, 2002' />
<meta name='identifier' content=' https://savage.nps.edu/Savage/Buildings/HouseSeksitSiripala/Sofa.x3d ' />
<meta name='generator' content='X3D-Edit 3.2, https://savage.nps.edu/X3D-Edit' />
<meta name='license' content='../../license.html' />
</head>
<!--a
Index for DEF nodes:Aarm, leg, woodarm
-->
<Scene>
<Transform DEF='Sofa'>
<Transform translation='0.0 0.0 3.0'>
<Shape DEF='leg'>
<Appearance>
<Material diffuseColor='0.2 0.1 0.0' />
</Appearance>
<Cylinder height='0.5' radius='0.2' />
</Shape>
</Transform>
<Transform translation='0.0 0.0 -3.0'>
<Shape USE='leg' />
</Transform>
<Transform translation='-2.0 0.0 -3.0'>
<Shape USE='leg' />
</Transform>
<Transform translation='-2.0 0.0 3.0'>
<Shape USE='leg' />
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.3 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Box size='2.5 0.5 7.0' />
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.5 3.5'>
<Group DEF='arm'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Box size='2.5 0.3 0.3' />
</Shape>
<Transform rotation='0.0 0.0 1.0 -1.5' translation='0.0 0.2 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Cylinder height='3.0' radius='0.2' />
</Shape>
</Transform>
</Group>
</Transform>
<Transform rotation='0.0 0.0 1.0 -1.4' translation='-1.0 0.7 3.5'>
<Shape DEF='woodarm'>
<Appearance>
<Material diffuseColor='0.2 0.1 0.0' />
</Appearance>
<Cylinder height='3.2' radius='0.1' />
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 -1.4' translation='-1.0 0.7 -3.5'>
<Shape USE='woodarm' />
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.5 -3.5'>
<Group USE='arm' />
</Transform>
<Transform rotation='0.0 0.0 1.0 0.4' translation='-2.2 0.8 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Box size='0.3 1.5 6.5' />
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.4 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Box size='2.5 0.5 6.5' />
</Shape>
<Transform rotation='1.0 0.0 0.0 1.5707964' translation='1.15 0.0 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5' />
</Appearance>
<Cylinder height='6.5' radius='0.25' />
</Shape>
</Transform>
</Transform>
</Transform>
<timeSensor DEF="clock" cycleInterval='5' loop='true'></timeSensor>
<OrientationInterpolator DEF='moveSofa' key='0 .25 .5 .75 1' keyValue='0 1 0 0 0 1 0 1.57079 0 1 0 3.14159 0 1 0 4.71239 0 1 0 6 '>
</orientationInterpolator>
<ROUTE fromNode="clock" fromField='fraction_changed' toNode='moveSofa' toField='set_fraction'></ROUTE>
<ROUTE fromNode='moveSofa' fromField='value_changed' toNode='Sofa' toField='set_rotation'></ROUTE>
</Scene>
</X3D>
<!--
Index for DEF nodes: arm, leg, woodarm
-->
<!-- Tag color codes (X3D, XML terminology): <Node DEF='idName' field='value'/> <Element DEF='idName' attribute='value'/> -->
1 ответ
Я в конечном итоге выяснить, как повернуть его.
<html>
<head>
<meta http-equiv="Content-Type"/>
<title>Rotate Object</title>
<link rel="stylesheet" type="text/css" href="http://www.x3dom.org/x3dom/src/x3dom.css"/>
<script type="text/javascript" src="http://www.x3dom.org/x3dom/src/x3dom.js"></script>
</head>
<body>
<X3D width="500px" height="500px">
<scene>
<transform DEF='couch'>
<Transform translation='0.0 0.0 3.0'>
<Shape DEF='leg'>
<Appearance>
<Material diffuseColor='0.2 0.1 0.0'/>
</Appearance>
<Cylinder height='0.5' radius='0.2'/>
</Shape>
</Transform>
<Transform translation='0.0 0.0 -3.0'>
<Shape USE='leg'/>
</Transform>
<Transform translation='-2.0 0.0 -3.0'>
<Shape USE='leg'/>
</Transform>
<Transform translation='-2.0 0.0 3.0'>
<Shape USE='leg'/>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.3 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Box size='2.5 0.5 7.0'/>
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.5 3.5'>
<Group DEF='arm'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Box size='2.5 0.3 0.3'/>
</Shape>
<Transform rotation='0.0 0.0 1.0 -1.5' translation='0.0 0.2 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Cylinder height='3.0' radius='0.2'/>
</Shape>
</Transform>
</Group>
</Transform>
<Transform rotation='0.0 0.0 1.0 -1.4' translation='-1.0 0.7 3.5'>
<Shape DEF='woodarm'>
<Appearance>
<Material diffuseColor='0.2 0.1 0.0'/>
</Appearance>
<Cylinder height='3.2' radius='0.1'/>
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 -1.4' translation='-1.0 0.7 -3.5'>
<Shape USE='woodarm'/>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.5 -3.5'>
<Group USE='arm'/>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.4' translation='-2.2 0.8 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Box size='0.3 1.5 6.5'/>
</Shape>
</Transform>
<Transform rotation='0.0 0.0 1.0 0.1' translation='-1.0 0.4 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Box size='2.5 0.5 6.5'/>
</Shape>
<Transform rotation='1.0 0.0 0.0 1.5707964' translation='1.15 0.0 0.0'>
<Shape>
<Appearance>
<Material diffuseColor='0.1 0.2 0.5'/>
</Appearance>
<Cylinder height='6.5' radius='0.25'/>
</Shape>
</Transform>
</Transform>
<timeSensor DEF='clock' cycleInterval='8' loop='true'></timeSensor>
<orientationInterpolator DEF='spinThings' key='0 0.25 0.5 0.75 1' keyValue='0 1 0 0 0 1 0 1.57079 0 1 0 3.14159 0 1 0 4.71239 0 1 0 6.28317'></orientationInterpolator>
<ROUTE fromNode='clock' fromField='fraction_changed' toNode='spinThings' toField='set_fraction'></ROUTE>
<ROUTE fromNode='spinThings' fromField='value_changed' toNode='couch' toField='set_rotation'></ROUTE>
</scene>
</X3D>
</body>
</html>