Jump to content

mouse events not working


Jazvec
 Share

Recommended Posts

Is there a custom way of defining mouse events in babylon-3.1.0?

In babylon.3.0.0 adding mouse events works fine, but in babylon-3.1.0 I can't add mouse down event. Mousewheel still works.

Example code: (just switch between the libraries)

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            <style>
        html, body {
            overflow: hidden;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }     
    </style>

	    <script src="/js/babylon-3.0.0.min.js"></script>
   </head>

   <body>

 		<canvas id="renderCanvas" style="width: 100%;height: 100%;" touch-action="none"></canvas>
    <script>
    
	  window.addEventListener("mousedown", md);
	  window.addEventListener("mousewheel", mw);
	  //vv.utils.setVVMapView();
	function md() {
	    console.log("mousedown");
	}
	function mw() {
	    console.log("mousewheel");
	}
	
	var canvas = document.getElementById("renderCanvas"); // Get the canvas element 

    var engine = new BABYLON.Engine(canvas, true); // Generate the BABYLON 3D engine


    /******* Add the create scene function ******/
    var createScene = function () {

                // Create the scene space
                var scene = new BABYLON.Scene(engine);

                // Add a camera to the scene and attach it to the canvas
                var camera = new BABYLON.ArcRotateCamera("Camera", Math.PI / 2, Math.PI / 2, 2, BABYLON.Vector3.Zero(), scene);
                camera.attachControl(canvas, true);

                // Add lights to the scene
                var light1 = new BABYLON.HemisphericLight("light1", new BABYLON.Vector3(1, 1, 0), scene);
                var light2 = new BABYLON.PointLight("light2", new BABYLON.Vector3(0, 1, -1), scene);


                // Add and manipulate meshes in the scene
                var sphere = BABYLON.MeshBuilder.CreateSphere("sphere", {diameter:2}, scene);

                return scene;
        };

        /******* End of the create scene function ******/    

        var scene = createScene(); //Call the createScene function

    engine.runRenderLoop(function () { // Register a render loop to repeatedly render the scene
            scene.render();
    });
      
    </script>
    

   </body>

</html>

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...