<script language="JavaScript" src="/js/Kribi3DPlayer.js" type="text/javascript"></script>

<script language="JavaScript" src="/js/gFunct.js" type="text/javascript"></script>

   

    <script language="JavaScript" type="text/javascript">

   

        var arrIstance = new Array(0);

        var loadok = false;

        var opening = false;

 

        /* ------------------------------------------------------------ */

        /* This function is invoked when the page is loaded.

        *Allows the loading of plugins*/

        window.onload = function() {

            loadok = true;

        }

 

        /* ------------------------------------------------------------ */

        /* This function is invoked every time the player sends a message to the

        * browser, we use it to intercept the Ready event which is sent when

        * the player is ready to accept commands and the ModelOpened event which is

        * sent when the model has been loaded. */

        function KribiPlayer_Tell(msg) {

            var player = document.getElementById("KribiPlayer");

            if (loadok) {

                if (msg == "ModelOpened") {

                    // initialize the camera.

                    DefaultView_init();

                    //store the initial position of scene's element

                    var count = player.Do("Instance GetCount ");

                    arrIstance = Array(count);

                    for (i = 0; i < count ; i++) {

                        arrIstance[i] = player.Do('Instance[' + i + '] Position');

                    }

                } else if (msg == "Refresh") {

                    if (!opening) {

                        // Wait for all the controls to be opened, make sure that this will run only once.

                        opening = true;

                        player.Do("Model OpenAsync '" + FullModelsPath() + "single_chessV02_OP.kmo'");

                    }

                }

            }

        }

 

        /* ------------------------------------------------------------ */

        // Set default

        function DefaultView_init(reset) {

            var player = document.getElementById("KribiPlayer");

            // Set the camera to its initial position.

            player.Do("Camera Position 3249.96,-5535.08,6355.66");

            player.Do("Camera Orientation -60.5903,38.2449,0");

            player.Do("Camera FieldOfView 71.00");

            // Enable realistic rendering.

            player.Do("Renderer Shading Realistic");

            // Set tool

            InstanceHorizontalPlaneMove();

            if (reset) {

                /* Reset every instance in the scene to its original position,

                * orientation and size. */

                var count = player.Do("Instance GetCount ");

                for (var i = 0; i < count; i++) {

                    player.Do('Instance[' + i + '] Position ' + arrIstance[i]);

                }

            }

        }

 

        /* ------------------------------------------------------------ */

        // Tools

        function InstanceHorizontalPlaneMove() {

            // Set Tool InstanceHorizontalPlaneMove

            var player = document.getElementById("KribiPlayer");

            player.Do("Tool SetCurrent 'InstanceHorizontalPlaneMove'");

        }