参考网页:https://www.x3dom.org/x3dom/example/x3dom_texture.xhtml
核心代码:
<ImageTexture url='"texture/lorsch/7718008.jpg"'/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Texture: Model with multiple external textures</title>
<script type='text/javascript' src='https://www.x3dom.org/download/x3dom.js'> </script>
<link rel="stylesheet" type="text/css" href="x3dom.css" />
</head>
<body style="background-color:#E0E0E0;">
<h1>Texture: Model with multiple external textures</h1>
<p class="case">
<!-- Use the same "x", "y", "width" and "height" attributes as SVG.
Optionally support the "viewBox" and "preserveAspectRatio" just like SVG -->
<X3D xmlns="http://www.web3d.org/specifications/x3d-namespace" id="spheres" showStat="true" x="0px" y="10px" width="400px" height="400px">
<Scene DEF='scene'>
<Viewpoint orientation='-0.106063 0.993933 0.0291173 1.09435' position='4.40218 1.28291 2.10823'/>
<Background skyColor='1 1 1'/>
<Shape>
<Appearance>
<Material diffuseColor='0.7 0.7 0.7'/>
</Appearance>
<Box size='2.5 0.05 2.5'/>
</Shape>
<Transform DEF='VIFS12' translation='3.429 -0.2252 0.7462'>
<Shape>
<Appearance>
<ImageTexture url='"texture/lorsch/8262856.jpg"'/>
<Material diffuseColor='0.7 0.7 0.7' specularColor='0.4 0.4 0.4' />
</Appearance>
<IndexedFaceSet DEF='VIFS12-FACES' coordIndex='0 1 2 -1 2 3 0 -1'>
<Coordinate DEF='VIFS12-COORD' point='-3.359 1.558 -0.2427 -3.36 1.617 -0.2416 -3.37 1.617 -0.2412 -3.371 1.558 -0.2436'/>
<TextureCoordinate DEF='VIFS12-TEXCOORD' point='0.8333 0.03846 0.8333 0.9615 0.1667 1 0 0.07692'/>
</IndexedFaceSet>
</Shape>
</Transform>
<Transform DEF='VIFS11' translation='3.429 -0.2252 0.7462'>
<Shape>
<Appearance>
<ImageTexture url='"texture/lorsch/7739464.jpg"'/>
<Material diffuseColor='0.7 0.7 0.7' specularColor='0.4 0.4 0.4' />
</Appearance>
<IndexedFaceSet DEF='VIFS11-FACES' coordIndex='0 1 2 -1 2 1 3 -1 4 5 1 -1 1 0 4 -1 6 7 8 -1 8 9 6 -1 8 10 11 -1 11 9 8 -1 10 12 13 -1 13 11 10 -1 12 14 13 -1'>
<Coordinate DEF='VIFS11-COORD' point='-3.083 1.241 -0.8712 -3.151 1.374 -0.8229 -3.086 1.328 -0.8612 -3.097 1.369 -0.8248 -3.094 1.235 -1.52 -3.427 1.844 -1.532 -3.413 1.976 -0.414 -3.43 1.982 -0.421 -3.42 2.042 -0.4674 -3.346 2.041 -0.4162 -3.416 2.174 -0.4107 -3.403 2.17 -0.3858 -3.424 2.224 -0.4194 -3.397 2.225 -0.398 -3.422 2.364 -0.391'/>
<TextureCoordinate DEF=