• Content count

  • Joined

  • Last visited

About yuccai

  • Rank
  • Birthday 07/30/1993

Profile Information

  • Gender
  • Location

Recent Profile Visitors

478 profile views
  1. Hi, I can't figure out how to set the clear color of my scene when I set my camera to VR rig mode. The clear color seems to be black but in my point of view it's only a layer under my clear color. Here is a PG to see my issue : http://www.babylonjs-playground.com/#R7PKMT. You can toggle rig mode by pressing 'T' on your keyboard. By default the clear color is transparent. You can change the clear color to see what happens. Thanks,
  2. Nice job ! The fact is that I wrote my piece of code a long time ago and I've never seen that you wrote this one in bjs. I will have a look on it ;). BTW I still undergo FPS drop after a random time. Sometime I don't and sometime it increases back. This must be due to my computer and it doesn't matter since I know it is specific to me. Thanks for your help, this topic can be closed.
  3. What do you mean by trying different settings on my webcam ? I only have one webcam on my computer and I can't change its property. Maybe I can change the dimensions of the video before passing it to the videoTexture. I tried this and it increased a little bit my fps. My computer is 10yo. I tried this PG on other laptop and I didn't detect any FPS drop. I guess I can't do anything but I understood why, thanks
  4. Hi, I want to display my webcam content on my scene. In order to do this, I tried to create a layer set in background on which I apply a video texture. I passed a video DOM element to this texture. This video has a stream for source that is obtained from the getUserMedia promise. It works but rapidly the FPS drop and I don't know why. Maybe the size of the video is too large, maybe I provided the wrong parameters to the texture. I don't have any idea but it causes an issue. Here is a PG for testing : https://www.babylonjs-playground.com/#FF3BPV Thanks,
  5. Maybe if the position your pointer is beyond your canvas dimension. If your canvas is WxH, your callback associated to your onpointerup is : function(evt) { if(evt.clientX > W || evt.clientY > H) { //you're out your canvas } } You may be sure that you click origin was on the canvas. Here are some informations related to pointers event.
  6. Thanks for this fast answer. I'm glad your solution is working even if it's still tricky. I'll use it temporarily. I think that this behavior is not expected and Babylon need a fix. What's your point of view @Deltakosh ? From the few I know, the camera position is correct before this line. The new position is computed here and especially here. Then it becomes more complicated, it mainly uses Collider class.
  7. Hi, I would like to understand a strange behavior of my camera and how to prevent it. Let me explain. I have a mesh that I like to see from different point of views with an ArcRotateCamera. If collisions are enabled, if the camera move from viewpoint1 to viewpoint2 and the translation between these 2 points intersects the mesh, the new camera position is not the expected one. If collisions are disabled, it works. If the translation doesn't intersect the mesh, it also works. Here is a PG to illustrate my issue : you can change viewpoints by pressing keys '1', '2', '3', '4', '5' or '6' to see respectively the cube from front, left, back, right, top or bottom viewpoint you can toggle collision by pressing 'c' If collisions are enabled, my issue happens when : switching from opposite viewpoints (1 -> 3, 2 -> 4, 5 -> 6), you obviously intersect the cube if you are close enough of the cube, moving to any viewpoint will intersect the cube and pressing consecutively the same key will not have the same result until the camera is not in the intended position If collisions are disabled, camera's behavior is the expected one. I don't know why my camera moves like this. I assume that the camera is not teleported from a viewpoint to another but it is translated which implies a collision with my mesh. Can it be fix in Babylon.js ? Do I misuse the library ? How can I prevent this behavior ? I succeed to avoid it but I have to use window.setTimeout twice to disable collisions, then move my camera and enable collisions. function setViewpoint(viewpoint) { camera.checkCollisions = false; window.setTimeout(function() { camera.alpha = viewpoint.alpha; camera.beta = viewpoint.beta; window.setTimeout(function() { camera.checkCollisions = true; }, 100); }, 100); } It is a bit tricky and I'd like to find another way to do it. Thanks
  8. Hello, I find that the Observable class is useful to handle events. However the ActionManager class offers more types of events such as long press for instance but we can only use it on meshes. I would like to know the fundamental difference between these two classes. Does one depend on the other ? How can I reproduce the events from ActionManager for the Observable ? Thanks
  9. In fact it was not as difficult as I thought, I just added my predicate (which consists in checking the sign of the face normal with the intersecting ray) for each faces intersected. I had to patch the following function of Babylon.js : SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) { var intersectInfo = null; // LineMesh first as it's also a Mesh... if (this._mesh instanceof BABYLON.LinesMesh) { var lineMesh = this._mesh; // Line test for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) { var p0 = positions[indices[index]]; var p1 = positions[indices[index + 1]]; var length = ray.intersectionSegment(p0, p1, lineMesh.intersectionThreshold); if (length < 0) { continue; } if (fastCheck || !intersectInfo || length < intersectInfo.distance) { intersectInfo = new BABYLON.IntersectionInfo(null, null, length); if (fastCheck) { break; } } } } else { // Triangles test for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) { var p0 = positions[indices[index]]; var p1 = positions[indices[index + 1]]; var p2 = positions[indices[index + 2]]; var p0p1 = p0.subtract(p1); var p2p1 = p2.subtract(p1); var normal = BABYLON.Vector3.Cross(p0p1, p2p1); if(BABYLON.Vector3.Dot(ray.direction, normal) < 0 ) { var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2); if (currentIntersectInfo) { if (currentIntersectInfo.distance < 0) { continue; } if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) { intersectInfo = currentIntersectInfo; intersectInfo.faceId = index / 3; if (fastCheck) { break; } } } } } } return intersectInfo; }; The changes are effected on triangles test side. From the 3 vertices of the face, I calculate the normal and then I check the dot sign of this normal with the ray direction. If it is positive (the ray and the face are oriented in the same way), it means that the face is back to camera, thus invisible in a back face culling mesh. So I keep only negative dot product.
  10. Hi, I would like to pick a mesh and moving it around a room which is a simple cube with backside orientation. Basically, it consists on 3 functions called on 3 distinct events onPointerDown : I select the mesh I want to move (main mesh) when I click on the mouse onPointerMove : I select a different mesh in order to move the main mesh when I drag the mouse onPointerUp : I deselect the main mesh when I release the click of the mouse The behavior I want to produce is to dragndrop the main mesh on visible faces only and keeping each face belonging to the same mesh (I don't want to create as many meshes as faces). For instance, when my camera is above the room, the ceiling is transparent and we can see the floor due to the backside orientation of the room. But on step 2, I can't figure out how to pick the face which corresponds to the floor. I only succeed to pick the ceiling. I tried to build a predicate (pickInfo = scene.pick(x,y,predicate)) based on faces normales but once a mesh has been evicted from the predicate, it is not recalled, even if more than one face which is intersected. So I would like to know if there is a way to do what I'm expecting to do. When a mesh has succeed the predicate, how the returned pickInfo is built ? The selected face (pickInfo.pickedPoint) is always the nearest from the camera ? Is is possible the return an array of valid meshes with an another array containing its corresponding faces intersected ? Here is a PG relating my issue : http://www.babylonjs-playground.com/#1V3CAT#185 Thanks
  11. Hi, You need to compute the world matrix of the mesh before checking collisions. In this way you're sure that the good registered positions are correct. Here is the PG : http://www.babylonjs-playground.com/#11JY4O#10
  12. I know this possibility to set the worldMatrix but in this case I lost informations : I have the matrix to set A I compute the the scaling, rotation, position from A thanks to decompose I get a new matrix B but B is similar to A but not exactly the same. I found a solution for this case : Define a parent mesh that I call handler Use handler.setPivotMatrix(A) The visual result is exactly the same as if I had set A to the worldMatrix of the mesh I want to move but I can't find this kind of solution to set the projectionMatrix of a camera. I can retrieve fov/znear/zfar/aspectRatio from the original matrix, then set these values to the corresponding properties of the camera but then the projection matrix is still different of the original.
  13. Hi, I know that the worldMatrix and projectionMatrix are computed from other properties (like position/rotation/rotationQuaternion/scaling for worldMatrix and fieldOfView/ZNear/ZFar for projectionMatrix). I would like to know if I can proceed the inverse way. I mean I want to set these 2 matrices and automatically update the other properties which depend on it. Thanks for your help,
  14. Hi, I'm trying to figure out how to rotate a FreeCamera on Z axis without using a handler. In this example http://www.babylonjs-playground.com/#1CEZ5W#0, I only can rotate the camera using the handler. You can comment/uncomment the rotation lines in the renderLoop in order to see the difference. Do you understand what I want to show ?
  15. Hi, You forgot to bind and reattach the inputs to the camera. camera.inputs.attached.VRDeviceOrientation._deviceOrientationHandler = onOrientationEvent.bind(camera.inputs.attached.VRDeviceOrientation); camera.inputs.attached.VRDeviceOrientation.attachControl(canvas); Here is you playground updated : http://www.babylonjs-playground.com/#IGIJC#3 I hope you will see your cube moving