我目前正在玩VRML,而不是通过选择诚实,但是对于Web 3D的项目而言。

我正在尝试在VRML中制作一个触摸传感器,该传感器将在网页上显示并隐藏DIV。我尝试使用编写WEE脚本

browser.loadul('javascript:somefunction()');

尝试测试。

javascript从未调用,但是我知道我的触摸传感器可以像我尝试使用的某些功能一样好(例如,如果我拼写'浏览器'错误)它会抛出错误。

也许这只是现代浏览器的支持?

任何援助和建议都将非常感谢。

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


ROUTE touchBack.touchTime TO alertScript.make_alert
.

有帮助吗?

解决方案

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 :-)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top