IEWebGL插件Three.js

时间:2013-04-15 19:47:35

标签: javascript html css internet-explorer three.js

我已经使用three.js库和webgl创建了使用轨迹球旋转立方体的代码。它在chrome和firefox中工作得很完美,但是需要它在Internet Explorer 10上工作,我下载了IeWebgl,据说它可以帮助它在IE10上工作,但它什么也没做,但是说webgl没有被互联网支持,在他们的网站上有一些说明,但我做不理解他们。这是我的代码..

1 个答案:

答案 0 :(得分:1)

可以制作ie + ieWebGL兼容场景。

要执行此操作,您可以从demos' sources on ieWebGL site开始。 场景必须由另一个结构构建(必须由require.js加载一些three.js脚本)。

这个似乎有效:

<script src="http://iewebgl.com/scripts/webglhelper.js" type="text/javascript"></script>
<script src="path/require.js"></script>

<script src="other_three.js-scripts"></script>

<script>

    // stub for "console" object, because IE does not have it, when page is not under debugger.
    var console = console || {
        'warn': function (msg) { },
        'log': function (msg) { },
        'error': function (msg) { }
    };

    var container, camera, controls, scene, renderer;

    function start()
    {
        require
        (
            ["path/build/three.min.js", "path/examples/js/controls/your_controls.js"],
            function ()
            {
                init();
                animate();
            }
        );
    }

    function init() 
    {
        container = document.getElementById('renderCanvas');

        // renderer
        renderer = new THREE.WebGLRenderer({ 'canvas': container });
        renderer.setSize(window.innerWidth, window.innerHeight);

        scene = new THREE.Scene();
        ...
    }
    ...
</script>

<!-- create proper element (native canvas element or IEWebGL plugin object element) depending on web browser and WebGL support -->
<script id="WebGLCanvasCreationScript"type="text/javascript">WebGLHelper.CreateGLCanvasInline('renderCanvas', start)</script>