Domanda

Sto giocando con VRML al momento, non attraverso la scelta per essere onesti ma per un progetto sul web 3D.

Sto cercando di fare un sensore tattile in VRML che mostrerà e nasconderà un div in una pagina web.Ho provato a scrivere uno script wee usando

Browser.loadurl ('JavaScript: Somefunction ()');

Per provare a testare questo.

Il JavaScript non viene mai chiamato, tuttavia so che il mio sensore touch è OK come determinate funzioni che ho provato ad usare (ad esempio se scrivo "Browser" errato) Thrack Up un errore.

Forse questo non è solo supportato dai moderni browser?

Qualsiasi assistenza e consiglio sarebbero molto apprezzati.

    DEF alertScript Script {
    eventIn SFTime make_alert
    url [ "javascript:
    function make_alert (value) {
      Browser.loadURL('javascript:alert()');
    }
    " ]
}


ROUTE touchBack.touchTime TO alertScript.make_alert
.

È stato utile?

Soluzione

Do they only want classic VRML or is X3D allowed ? (X3D is the name of the current version of VRML).

If you are allowed to use X3D (I don't see why not), you could use X3DOM which is a WebGL engine, you may even get extra points on your assignment :)


Here's an example that hides a div when you click on a 3D sphere:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Touchsensor in X3DOM</title>

    <link href="x3dom.css" rel="stylesheet" />
    <style>
    #myDiv {
        color: blue;
        margin: 20px 0;
    }
    x3d {
        display: block;
        width: 600px;
        height: 400px;
        background: #EEEEEE;
        border: none;
    }
    </style>
</head>
<body>


    <div id="myDiv">
        Click the sphere to hide this div
    </div>

    <x3d>
        <Scene>
            <Shape id="mySphere">
                <Appearance>
                    <Material diffuseColor="0 1 0" />
                </Appearance>
                <Sphere/>
            </Shape>
        </Scene>
    </x3d>


    <script src="x3dom.js"></script>
    <script>
    (function() {

        document.getElementById('mySphere').onclick = function(){
            document.getElementById('myDiv').style.display = "none";
        };

    })();
    </script>


</body>
</html>

And by the way, X3D is the recommended 3D technology by the HTML5 spec, it isn't dead at all :-)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top