我有一个要转换为 X3D 的 VRML 代码。代码应定义具有不同半径和颜色的球体,以便稍后通过将坐标作为参数进行实例化。
首先,我使用了另一个问题中建议的在线转换器,然后在搅拌机中打开它进行检查,但它只显示一个球体而不是它应该显示的 4 个球体。我将它与通过谷歌搜索发现的其他类似示例进行了比较,我看不出它为什么这样做有任何区别或线索。我尝试更改一些字段,使其看起来更像示例:to ,内部信息to 。我也尝试像在 VRML 中一样放置在里面,但在所有情况下它只显示一个球体。field accessType
initializeOnly
<X3D ...>
profile="Interchange" version="3.2" xmlns:xsd="http://www.w3.org/2001/XMLSchema-instance" xsd:noNamespaceSchemaLocation="http://www.web3d.org/specifications/x3d-3.2.xsd"
<Shape>
<children>
这是我要转换为 x3d 的 VRML 代码的简化版本:
#VRML 2.0 utf8
PROTO Copper [ exposedField SFVec3f xyz 0 0 0 ] {
Transform {
translation IS xyz
children [
Shape {
appearance Appearance {
material Material { diffuseColor 0.78 0.5 0.2 }
}
geometry Sphere { radius 1.32 }
}
]
}
}
Copper { xyz 0.0 0.0 0.0 } # 0
Copper { xyz 0.0 1.8 1.8 } # 1
Copper { xyz 1.8 0.0 1.8 } # 2
Copper { xyz 1.8 1.8 0.0 } # 3
这是我从转换器中得到的:
<?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 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' profile='Full' version='3.0' xsd:noNamespaceSchemaLocation='http://www.web3d.org/specifications/x3d-3.0.xsd'>
<Scene DEF='scene'>
<ProtoDeclare name='Copper'>
<ProtoInterface>
<field accessType='inputOutput' name='xyz' type='SFVec3f' value='0 0 0'/>
</ProtoInterface>
<ProtoBody>
<Transform>
<Shape>
<Appearance>
<Material diffuseColor='0.78 0.5 0.2'/>
</Appearance>
<Sphere radius='1.32'/>
</Shape>
<IS>
<connect nodeField='translation' protoField='xyz'/>
</IS>
</Transform>
</ProtoBody>
</ProtoDeclare>
<Copper xyz='0.0 0.0 0.0'/>
<Copper xyz='0.0 1.8 1.8'/>
<Copper xyz='1.8 0.0 1.8'/>
<Copper xyz='1.8 1.8 0.0'/>
</Scene>
</X3D>