• Content Count

  • Joined

  • Last visited

  1. Awesome, didn't dare to think the solution would be so simple. Thanks a lot, @adam!
  2. Hi Deltakosh. Here it is: As you can see, the scene has a point light and a spot light attached to the camera. The first right-click in the scene drops the point light at its current position. The second right-click is supposed to do the same for the spot light, but instead it shows the weirdest behavior, totally unpredictable. It only works if the camera wasn't moved at all.
  3. This seems like the most fitting thread I found for the problem I'm currently having, so here it goes: I'm currently building an object viewer with an ArcRotateCamera. I want the user to be able to position two of the light sources I have in the scene (one point light and one spot light) by attaching them to the camera and detaching them with a button click. Being the BabylonJS-Newbie that I am (actually this whole 3D stuff is quite new to me, I'm a web developer and this is my first project using any 3D engine at all) I assumed that simply assigning null to the parent would do the trick but of course that wasn't the case, as the light immediately jumped back to its initial position after it was detached from the camera. A quick google search led me here and the content of this thread helped me to achive what I wanted for the point light like this: var pos = myPointLight.getAbsolutePosition(); myPointLight.parent = null; myPointLight.position = pos; setAbsolutePosition wasn't available, by the way. I assumed that is the case because I'm working with a light here and not with a mesh, so I simply assiged it to position and it worked, the point light now gets correctly returned to the position it had when it was last attached. But when I tried it for the spot light, things got very weird, as I wasn't really sure what to do to correctly read and then restore its rotation. Normally, the spot light recieves a direction and not a rotation, but grabbing that before the null assignment and re-applying it didn't work. Same for rotation or rotationQuaternion. So apparently it won't work without doing some serious math. The last time I actually had to do those kind of calculations was 15 years ago at my university of applied sciences and I'm afraid I don't remember much of it. So, any help would be greatly appreciated. Oh, and I hope this is the correct place to ask this question. Most of the answers in this thread apply to problems with meshes in parent/child relations and I assume things work quite a bit different with lights, but since my problem still fits this thread's title, it didn't seem appropriate to open a new discussion for this...
  4. Thanks a lot for the quick reply and the work you put in this. I saw that the only change in the demo code (except for smooting out the animation as a bonus) was to disable collision. So if I understand you correctly, this means that the bug in the upsideDown model you mentioned was a fix for the actual Babylon engine you just implemented? Very cool. So, which version do I need to make it work? The latest nightly alpha of 3.0? This might be a bit risky, considering that I'm using a stable 2.5 release for my project. Or did you fix it for BJS 2 as well?
  5. Thanks for the reply. Upper and lower limit can be null because I explicitly set them to be null when a certain condition is met. Doing so results in the camera behavior I intended to achieve: Being able to rotate past the default stopping positions of the top-down and bottom-up view. And it works fine as long as I use the mouse for that. When I click the vertical rotation buttons, then the ugly flickering I described occurs. I was able reproduce it in the playground: As you can see there, the knot rotates around the beta axis. Every time it goes past the 0/360 degree point (which would normally be the top-down-view stopping point if I hadn't removed the limits) the camera has this ugly flicker effect where its view seems to be turned on the head for a split sec. I have no idea how to get rid of that and I definitely need a smooth rotation animation for my current project.
  6. Hello everyone, I'm currently building an object viewer with BJS that utilizes a single ArcRotateCamera. I had to create manual control buttons for the camera, because apparently it can't be expected of the average web user to know how the simple concept of drag and drop works. So, I built 6 button to rotate the camera up, down, left and right and zoom in and out. The beta axis needed some special attention, because the application's state machine can have a state where upperBetaLimit and lowerBetaLimit are null, so the user can rotate past the top / bottom. This works fine with the mouse, but when the button is used and the last rotation modification moves the beta value past zero/360 degrees, the camera's z-axis (which should be fixed and not even modifiable for ArcRotateCamera) flips upside down for a split second before some sort of internal correction seems to turn it back around to normal. But that moment is very irritating and I doubt that my client will approve the app with such an ugly display bug. Any idea what might be causing it and how to get rid of it? I already tried to prevent the beta value from ever reaching exactly zero, because I expected that this was the problem, but as it turned out, that was not it. Here is the code for the up button: $('#buttonRotateUp').on('mousedown touchstart', function (e) { e.preventDefault(); if (window.camBetaRotationInterval) { clearInterval(window.camBetaRotationInterval); } $('#buttonRotateDown').removeClass('limit-reached'); if (!$(this).hasClass('pressed') && !$(this).hasClass('limit-reached')) { $(this).addClass('pressed'); var rotateStep = 0.15; // checking if the limits are not null if ((scene.activeCamera.lowerBetaLimit || scene.activeCamera.lowerBetaLimit === 0) && scene.activeCamera.upperBetaLimit && (scene.activeCamera.beta + rotateStep) > scene.activeCamera.upperBetaLimit) { $('#buttonRotateUp').addClass('limit-reached'); scene.activeCamera.beta = scene.activeCamera.upperBetaLimit; } else { if ((scene.activeCamera.beta + rotateStep) == 0.0) { scene.activeCamera.beta += (rotateStep + 0.1); } else { scene.activeCamera.beta += rotateStep; } } window.camBetaRotationInterval = setInterval(function () { var $btn = $('#buttonRotateUp'); var rotateStep = 0.015; if ($btn.hasClass('limit-reached') || ((scene.activeCamera.lowerBetaLimit || scene.activeCamera.lowerBetaLimit === 0) && scene.activeCamera.upperBetaLimit && (scene.activeCamera.beta + rotateStep) > scene.activeCamera.upperBetaLimit)) { $btn.addClass('limit-reached'); scene.activeCamera.beta = scene.activeCamera.upperBetaLimit; } else { if ((scene.activeCamera.beta + rotateStep) == 0.0) { scene.activeCamera.beta += (rotateStep + 0.01); } else { scene.activeCamera.beta += rotateStep; } } }, 25); } }).on('mouseup touchend', function (e) { e.preventDefault(); $(this).removeClass('pressed'); if (window.camBetaRotationInterval) { clearInterval(window.camBetaRotationInterval); } });