• Content Count

  • Joined

  • Last visited

About logunov

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thank you for the tip, I will try to figure out what's happening during linear transformations with camera. About mesh rotation, the snake on the sphere surface is not a mesh but dynamically changing object, because of some game triggers, so there is no possibility to follow it with camera (in my view, maybe it is possible). If I am trying to use pseudo-mesh, wich moves from points to points, that target camera or follow camera do not move around sphere surface, but in angle to it. ArcRotateCamera and ArcFollowCamera both dying in certain positions, maybe I did something wrong with it, I will check it better.
  2. @Deltakosh maybe video will explain better, than words After movement, starting on 0:20 to 0:23 camera changes angle of view, and there is much of this points on the sphere. I can't find a reason, why it happens. And I have no idea how to prevent this rotation.
  3. Thank you, @Deltakosh, for the advice and answer. There is isolated code, and there is no custom math: good result: https://www.babylonjs-playground.com/#AI1MQC#7 bad result: https://www.babylonjs-playground.com/#AI1MQC#6 One method, but different arguments. I added some comments and removed unnecessary code. 1) Setting pivot 2) Setting camera parent to pivot 3) Pivot looks at startPoint on sphere surface 4) Cloning pivot, making clone lookAt end point 5) Passing pivot.RotationQuaternion and cloned pivot.RotatingQuaternion (after lookAt method) to animator 6) Getting camera rotation around itself If I pas another two points on the same sphere, it works perfectly. I would be glad to use another points, but It is impossible in real code. More detail explanation: Points - is just a points on sphere surface, which I am moving my player, and camera should look perpendicular to tile under player. Camera moving from tile to tile, but follows player. It is turn-based game, so my player moving asynchronous to camera movement and camera moving on her own around sphere surface, but I can not use ArcRotateCamera, because it have gimbal lock and the same issue. In this playground camera rotates around itself and change angle of view. For example, camera was perpendicular to the player, and there was some stone behind him. When I moving through BABYLON.Animation, it rotates around itself and stone now in the upper part of screen. In the playground you can see it like light reflection drawing arcus, but if I change Again, thx everyone who spent time to read.
  4. https://www.babylonjs-playground.com/#X66D1S#2 here is additional demonstration, why I can not use ArcRotateСamera or Euler angles. In this example I changed method to use rotation instead of rotationQuaternion and when animation finishing camera immediately dying (I don't know how to call this phenomenon, gimbal lock probably ========== Upd: https://www.babylonjs-playground.com/#X66D1S#6 I though problem was in pivot method, but when I changed method to position from quaternions (not effective, but better, than nothing), it's still flip in certain points. I have no idea why camera is flipping. ===== Upd: Well, some time passed, so I need to say sorry for my manners of question. I hadn't time to make some etiquette. Thanks to everyone, who spent time to read this, I will be glad and happy to hear any advices or notes about this issue.
  5. Good day, Sir. First, I want to say Thanks to everyone, who spent time to read this, I will be glad and happy to hear any advices or notes about this issue. Here is a PG: https://www.babylonjs-playground.com/#AI1MQC#2 Please, hide the SetEnviroment(), getPointsArray() and cameraMoveAnimation() functions bodies to make code more readable, I specially out them from main code. As you can see, there is 2 important lines: 82 and 83. Each points from "points" array is a real data from real project, that is not random numbers. So, the camera should move from: point1 to point2, then point2 to point3, then point3 to point4, and so on. There is no problems in start points, it's moving smoothly, but at point7 to point8 (and some others) camera rotates around itself. (Playground setted by default to reproduce this). It look like... flipping possible. I am using pivot method to create camera, and I can not use ArcRotateCamera in real project, because in some points it's broken because of gimbal look, for example, at point8 as I remember, it will dispose, and then appear, ArcRotateCamera was first, what I tried. So, the question is: how to prevent camera flipping around itself? ===================== upd: I tested a little more, if I am using lookAt method without animation and just setting new quaternion, it reproduces the same problem, but I don't have any idea why it happens and why it's changing rotation angle. ======================= upd2: I made additional example, which shows problem from outside: https://www.babylonjs-playground.com/#X66D1S#1 As you can see, big red sphere doing strange movement but if you change animation arguments in lines 82 and 83 from points[7], points[8] to points[6], points[7], sphere will do exactly what I needed, so what is it? Why it happens? How can I prevent this?
  6. Thanks for the reply, but No, that's not what I need. I want to parametrically move in a circle (2D) in 3D space. And I cannot understand why, if I give 2 points as parameters of the lookAt rotary method, it leaves a circle. I say a circle, because I use quaternion mathematics, so 2 points must define an arc on the surface of a sphere, and if there are 3 points in the same plane of 3D space, they must define half of the circle.
  7. https://www.babylonjs-playground.com/#PP962K#13 I tried to make rotation from point1 to point2 to point3 in Oxy plane as you can see by coordinates, but after point2 the camera starts to choose a strange path out of Oxy. Why it happens?
  8. Well, normally I adding rigidbody component to the hairs, that makes them ragdollable. After that, each hat have a collider component, so, when they contact, collider of a hat pushing the ragdoll of hairs some in, and physic engine holds them under hat. But, the problem is I do not know, can babylon do this or not, and how ragdolls and rigidbody works here. The big minus of this approach is performance, but you can make pseudo ragdolling or something like that, if babylon provide this. =============== Well, the second solution, you can create mask layer over hat, which will over-ride anything under it in some pixels to nothing, but, again, I do not know about babylon solution here
  9. Good day everyone, I have a simple question: where I am using transformNode.lookAt method, wich is parent of all lookAt methods, how can I understand where is the face? For example, I put the cube on the scene, and used lookAt of cube at some point, which side of cube will face this point? (which side of cube will look at this point) ?
  10. Thank you, @entropy, I finally made a solution, take a look: https://www.babylonjs-playground.com/#PP962K#8 And the real camera example: https://www.babylonjs-playground.com/#PP962K#9 Answers on my questions in order: 1) To provide quaternion rotation you need use transformNode as pivot, putted in the center of the rotation. In the problem of mine it will be origin between point1, point2 and normal (green, red and blue lines) 2) Babylon animation component slerping quaternions on it's own, just need to put ANIMATIONTYPE_QUATERNION and "rotationQuaternion" parameters, as shown below 3) Before use quaternions, you should overwrite defaul transformNode.rotation via traformNode.rotationQuaternion, by default transformNode.rotationQuaternion is equals to null, so you need to put any quaternion to this before game starts or any calculations, this will need to make transformNode.lookAt(target:vector3) returning quaternions instead of vector3s (note: do not do that: transformNode.rotation = someQuaternion, just put transformNode.rotationQuaternion = someQuaternion); 4) Then just create keys with start Quaternion and End quaternion, due to javascript compilator, you can not transformNode.lookAt(point1) start = transformNode.rotationQuaternion transformNode.lookAt(point2) end = transformNode.rotationQuaternion transformNode.lookAt(point1) Because it will simplify this (I tested), so just make a copy as in example above, and then dispose copy of this object 5) Create animation object and put arguments. All works, gimble lock should be **** up. Thank you, @entropy, you really help me a lot! Note to descendants: this will work only for sphere, this is spherical mathematics, and this will work only for sphere with constant radius for animation time.
  11. Well, I have some experience in development, so there is some choices: First: Visual Studio huge community huge possibilities much of addons multi-language support much of space to install much of good addons is paid much of requirement to performance workspace Second: Visual Studio code portable small performance requirements, good performance small community no addons This probably should support intellisense, but I don't tested it Third: WebStorm from jetBrains company This is my favorite, it is specially developed to code on java script extremely better performance much of syntaxes support community version is not worse than licensed only javascript This probably contains intellesense, I looked at google a bit, and found some topics, so it may be, but I don't tested on my own; Additional tips: For the better code reading, take a look on the typescript, coffescript or dart languages ( https://www.dartlang.org/faq ), they are fully compiled to javascript without errors and making code better to look. Take a look at the babylon editor, http://editor.babylonjs.com , it looks pretty cool, but in beta-test probably and I do not know his performance. This is not only on the website, you can download this tool on your pc (but it will work in browser, internet connection not needed).
  12. Yes, you understand correctly. Box emulates (simulates) the camera movement, I need to move camera around sphere surface, but any of the given BABYLON camera going in gimble lock in pi/2 so I can not use default babylon camera, so I choosed 2 points on sphere, and want to rotate camera with quaternion to prevent gimble lock, but the problem camera rotates around itself or do not rotating. This two points will be exactly on the same sphere. var point1 = new BABYLON.Vector3.One() var point2 = new BABYLON.Vector3(3/2,0.5,0.70710678118654752440084436210485); More clearly explanation: Purple line - how camera\mesh should move, looking at origin (center of the sphere) Green line - point1 Red line - point2 Blue line - perpendicular (same as normal) to both OP and PQ where O is origin point, Blue line defines that I can rotate around it though Quaternion. Edit: I need to note, if I change camera.position property with new data, it does not resolve the problem, because now in my project camera.position = parameter produce this problem, so I need to change camera.rotationQuaternion, to change it position around sphere surface to prevent any gimble locks as description of this property said.
  13. Thx a lot, @entropy, your reseach was extremly useful to understand BABYLON API better, but I found a two more problems, because of this understanding: 1) This should work only for meshes, because, as example, camera have no method to convert vertices, so, if I need to move camera by this idea, it is impossible, because it have no verices and method (it is just note, your method is good) 2) This do not work, if I choose arbitrary axis. Here is playground, demonstrating #2 on your code: https://www.babylonjs-playground.com/#H22U9B#2 Look at lines #32, and #49 and #59 - I change axis, because I want to rotate around blue axis, and change start position + drawed all lines on the scene to make example more visible. My goal is to rotate around blue axis from end of red line (point1) to end of green line (point2), this is possible, because blue line is perpendicular to both green and red, so green and red forming surface (plane, I do not know termin on english). And I am shocked a bit, because, logically, your solution should work for any kind of axis, but it doesnt, and I can not understand why. Maybe, I missing some mathematical transformations, to make it work, but I do not know which math here should be used. p.s A simple question about math: why you multiplying quaternions? Where can I read about geometry transformations, which quaternion-multiplying produces? I simply can not understand why it needed and what it's doing. Again, my big thank for your help, you really make me progress a lot.
  14. Thank you for notes, @entropy, it very useful and interesting. I want to formalize my question a bit deeper. so the question is: " Is babylon animation doing slerp with quaternions on their own, and which property I should pas to babylon animation to make movements with quaternions. or this stuff is not supported and I should code method, which will produce array of points, and pass this though keys to babylon animation with "position" property". This question is a little bit confusing me, because I don't find any clear explanation in API how to do something like that. Edit: I got additional question, if I passing "rotationQuaternion" parameter in animation constructor, then will it rotate around local axes or world? If I need to rotate object around some world axis, which parameter I should pas? For example: I put some object on sphere surface, with base rotation, how could I get his rotationQuaternion around origin (0,0,0)? Or around some axe? Let's have 2 points on surface, p1 - start, p2 - finish. Then, cross(p1,p2) gives me normal, and I can rotate around normal to go from p1 to p2, but I need to get rotationQuaternion of object in p1 point, provided normal-axes from cross product, this should be startQuaternion for slerp function, and then, I can make second quaternion with rule: let angle = BABYLON.Vector3.GetAngleBetweenVectors(p1,p2,normal) //normal is cross(p1,p2) let cos = Math.cos(angle/2) let sin = Math.sin(angle/2) let rotationAxis = normal //normal is croos (p1,p2) normal.scale(sin/2) let endQuaternion = new BABYLON.Quaternion(normal.x, normal.y, normal.z, cos) Then, I should provide something with this 2 quaternions: let quaternionsArray = function(q1, q2, a) { let result = []; let step = 1/a; for (let i = 0; i<a; i++){ result.push(BABYLON.Quaternion.Slerp(q1,q2, step*i) //q1 - startQuat, q2 - endQuat } return result } And then make keys array for each quaternion of result array, but if I pas "rotationQuaternion" as parameter of animation constructor, it will rotate around local axes, am I right? So, there is two unclear points: how to get rotationQuaternion in global coordinates, and how to provide animation constructor to use rotationQuaternion in worldSpace, not local.