Jazvec Posted April 23, 2018 Share Posted April 23, 2018 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> Quote Link to comment Share on other sites More sharing options...
Sebavan Posted April 23, 2018 Share Posted April 23, 2018 Could you rely on pointer instead and use the scene: onPointerDown This would work well cross plat and you won t need to rely on the mouse events natively Quote Link to comment Share on other sites More sharing options...
Jazvec Posted April 23, 2018 Author Share Posted April 23, 2018 Thank you, that works. I will use that instead. Also I found another threat that mentioned that: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.