• Content Count

  • Joined

  • Last visited

About garidan

  • Rank

Recent Profile Visitors

701 profile views
  1. Thank you I knew I was missing something obvious. Anyway your solution is the one to use as example fo picking, it's complete.
  2. I'm missing something simple here ... I want to get the point on a rotated plane that was clicked on a screen. I modified the example in the plaground adding only a rotation to the plane and it does work no more. What am I doing wrong or miss? Thanks
  3. OK, I did it this way: var createScene = function() { BABYLON.Scene.prototype._updatePointerPosition = function (evt) { var canvasRect = this._engine.getRenderingCanvasClientRect(); this._pointerX = evt.clientX - canvasRect.left; this._pointerY = evt.clientY -; this.cameraToUseForPointers=getViewportCamera(this._pointerX, this._pointerY); }......var getViewportCamera = function(x0,y0) { var canvas = engine.getRenderingCanvas(); // reverse y axis, apply scale -> xy origin in lower left corner y = (perspectiveGlobalView.height - y0/engine.getHardwareScalingLevel()); x = x0/engine.getHardwareScalingLevel(); // logic hereafter depends on your cameras layout, code could be generalized here // default camera res = sideCamera; if (x > perspectiveGlobalView.x && x < (perspectiveGlobalView.x+perspectiveGlobalView.width)) { if (y > perspectiveGlobalView.y && y < (perspectiveGlobalView.y+perspectiveGlobalView.height)) { res = camera; } } else if (x > topGlobalView.x && x < (topGlobalView.x+topGlobalView.width)) { if (y > topGlobalView.y && y < (topGlobalView.y+topGlobalView.height)) { res = topCamera; } } return res;}
  4. I had to spend a lot of time to understand where my working code got ... working no more. It came out that this line: var worldVector2 = BABYLON.Vector3.Unproject( screenVector2, ViewportWidth, ViewportHeight, wMCamera, vMScene, pMScene );modifies the vector "screenVector2". Reading the documentation it's not apparent, and seeing the function returns a Vector3 lend me to expect it to be the only result. Instead the passed vector3 instance screenVector2 is modified too. I think it should not behave like that .... is it for performance reasons or a bug ? If it is not a bug, can the documentation report which params and how are modified ?
  5. I think the right place where I could override and change behaviour is _updatePointerPosition: Scene.prototype._updatePointerPosition = function (evt) { var canvasRect = this._engine.getRenderingCanvasClientRect(); this._pointerX = evt.clientX - canvasRect.left; this._pointerY = evt.clientY -; if (this.cameraToUseForPointers) { this._pointerX = this._pointerX - this.cameraToUseForPointers.viewport.x * this._engine.getRenderWidth(); this._pointerY = this._pointerY - this.cameraToUseForPointers.viewport.y * this._engine.getRenderHeight(); } };Here I could change cameraToUseForPointers dynamically, with no side effects (?) right ?
  6. OK, I see "cameraToUseForPointers" in source code of scene..... this.cameraToUseForPointers = null; // Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer positionUsing multiviews, and perhaps in other multi camera usecases, this cameraToUseForPointers should be dynamically determined, in my case based on pointer coordinates. Any clue, or any idea for a patch/future enhancements ?
  7. The "working" camera is the last one pushed as active
  8. I have a multiview, 3 cameras and viewports, and switching from "old way" to manage actions to the actionmanager one. I use ExecuteCodeAction with trigger OnLeftPickTrigger and it does activate an event only on one of the views, so one camera only. RegisterAction has no camera parameter thus I would expect babylon manages the right camera for picking meshes, based on viewports and mouse coordinates, but it does not seem the case. Any clue or suggestion? Thanks
  9. I think it is interesting to know Microsoft has released a preview of a new Visual Studio product, free, expecially because it is for Linux, OSX and Windows supports Typescript and things like Intellisense Look at
  10. Documentation is good, I agree with the node->abstractMesh->Mesh ... problem .... I cannot find a post saying or a link directing me where to issue a bug, how do you manage this ? A forum post for each small bug seems overkill to me. Thanks for all your hard work
  11. The general question is: what if I need to remove an action from an actionManager ? I looked for a unregisterAction/deregisterAction on ActionManager class, or a dispose method on the action class but it's not available, am I missing something or it's a feature to implement ? My usecase: I use thin cylinder meshes to draw wires, in order to use mesh collision actions. Wires can be set longer or shorter at runtime, so I dispose and recreate those meshes, but what happens to the actions registered on the actionManagers of the other meshes (OnIntersectionEnterTrigger,OnIntersectionExitTrigger) to check for object-wire collisions ? I'm afraid they remain even if they can no more be called, being the mesh disposed now. Thanks
  12. OK, I think I need a Bounding Volume Hierarchy (BVH) If ever I do this, I'll let you know :-)
  13. I need to perform a precise mesh collision detection: meshes have strange shapes but are very few and the scene is almost static, only one mesh at a time is drag and dropped in the scene, so there's no computational resources problem. I already tried with "usePreciseIntersection: true" but calling it precise ..... it's not: meshes[0].actionManager.registerAction(new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnIntersectionEnterTrigger, parameter: { mesh:meshes[1], usePreciseIntersection: true } }, function () { meshesMaterial[0].diffuseColor=BABYLON.Color3.Red(); })); Reading at the link below, I need a sort of "mesh collider". Any idea ? Any external library or "trick" ? Thanks
  14. I updated my code: it didn't work on smartphones because hardwareScaling was not considered. I added an HTML div where to write debug info while dragging. Now it's ok in iPhone and Android phone. On my Android 4.4 Moto G it's too small and you can only move the blue cube, on Iphone it is small the same but you can drag and drop the other solids too, don't know why ... I noticed in the playground now there is babylon.js built on 20 november which in this example has a bug, not found in build of 16 november: when 2 meshes are one over the other, it's picked the lower one and not the visible one, when picking from the top view viewport (upper right). In my local 16 november build it works correctly. Do I have to file a issue ?