Recursos X3D

Documentação

Modelos

Os modelos abaixo funcionam assumindo que:

  1. Fez o download recomendado;
  2. O arquivo zip foi descompactado para a pasta lib/ da sua diretoria de trabalho;

Isto é, deve obter a seguinte àrvore:

(directoria de trabalho)/
    lib/
        x3dom/
            doc/
                (vários ficheiros)
            (vários ficheiros)
            x3dom.js
            x3dom-full.js
            x3dom.css
    (os seus ficheiros de trabalho)

Um documento «standalone»

<!DOCTYPE html>
<html lang="pt">
<head>
    <meta charset="utf8">
    <title>Standalone X3D</title>
    <script 
        type='application/javascript' 
        src='./lib/x3dom/x3dom-full.js'>
    </script>
    <link 
        rel='stylesheet' 
        type='text/css' 
        href='./lib/x3dom/x3dom.css' />
</head>

<body>
    <x3d>
        <scene>
            <shape>
                <appearance>
                    <material 
                        diffuseColor="crimson">
                    </material>
                </appearance>
                <cylinder></cylinder>
            </shape>
        </scene>
    </x3d>
</body>
</html>

Modelo e Documento separados

Parte HTML (Documento)

Ficheiro documento.html:

<!DOCTYPE html>
<html lang="pt">
<head>
    <meta charset="utf8">
    <title>Modelo + Documento X3D</title>
    <script 
        type='application/javascript' 
        src='./lib/x3dom/x3dom-full.js'>
    </script>
    <link 
        rel='stylesheet' 
        type='text/css' 
        href='./lib/x3dom/x3dom.css' />
</head>

<body>
    <div>
        <x3d width="512px" height="512px">
            <scene>
              <inline url="modelo.x3d"></inline>
            </scene>
        </x3d>
    </div>
</body>
</html>

Parte X3D (Modelo)

Ficheiro modelo.x3d:

<x3d>
    <scene>
        <shape>
            <appearance>
                <material diffuseColor="crimson">
                </material>
            </appearance>
            <cylinder></cylinder>
        </shape>
    </scene>
</x3d>

Geometria por Faces com mapa UV

Veja como obter mapas de reflexos e de normais em NormalMap-Online.

<shape>
    <appearance>
        <commonsurfaceshader>
            <imagetexture
                containerField="diffuseTexture" 
                url="[mapa de DIFUSÃO]"></imagetexture>
            <imagetexture
                containerField="specularTexture"
                url="[mapa de REFLEXOS]"></imagetexture>
            <imagetexture
                containerField="normalTexture"
                url="[mapa de NORMAIS]"></imagetexture>
        </commonsurfaceshader>
    </appearance>
    <indexedfaceset coordindex="
        [ FACES: indices dos VÉRTICES seguido de -1 para 'terminar' cada face  ]
        "
        texcoordindex="        
        [ SETORES: indices dos PONTOS seguido de -1 para 'terminar' cada setor ]
        ">
        <coordinate point="
            [ VÉRTICES: coordenadas XYZ ]
            ">
        </coordinate>
        <texturecoordinate point="
            [ PONTOS: coordenadas UV ]
            ">
        </texturecoordinate>
    </indexedfaceset>
</shape>

Atalhos de teclado

FunçãoAtalho
Camera mode
ExamineActivate this mode by pressing the "e" key.
FunctionMouse Button
RotateLeft / Left + Shift
PanMid / Left + Ctrl
ZoomRight / Wheel / Left + Alt
Set center of rotationDouble-click left
Camera mode
WalkActivate this mode by pressing the "w" key.
FunctionMouse Button
Move forwardLeft
Move backwardRight
Camera mode
FlyActivate this mode by pressing the "f" key.
FunctionMouse Button
Move forwardLeft
Move backwardRight
Camera mode
HelicopterActivate this mode by pressing the "h" key.
FunctionKeys
look downwards/upwards8 / 9
move higher/lower use the keys6 / 7
FunctionMouse Button
Move forwardLeft
Camera mode
Look atActivate this mode by pressing the "l" key.
FunctionMouse Button
Move inLeft
Move outRight
Camera mode
GameActivate this mode by pressing the "g" key.
look around (rotate view)move the mouse.
FunctionKey
Move forwardCursor up
Move backwardsCursor down
Strafe leftCursor left
Strafe rightCursor right
Non-interactive camera mode
FunctionKey
Reset viewr
Show alla
Uprightu
Debugd
Viewpoint (debug)v