SimonN Posted November 21, 2018 Share Posted November 21, 2018 Trying to upgrade a working game I wrote on an earlier version of BabylonJs. The code below uses 4.0.0-alpha.9 (having struggled somewhat to get the latest 3.3 to work with Oimo.js). I get an error in Chrome: here's the offending code in Chrome … and here's the earlier place where billboard gets defined If I comment out the 7 lines where I setPhysicsState and the 6 lines where I setLinearVelocity, the scene loads ok. If I comment out line 356 I get a similar error from 357. I'm thinking that my BABYLON.Mesh.CreatePlane doesn't have a setPhysicsState method any more and setLinearVelocity could have disappeared too. Thanks so much. Simon P.S. Great to see all the recent babylonjs activity, it's a fantastic creation, I didn't realize that this was happening from my use of Nuget Package Manager within Visual Studio until I started to dig deeper. Quote Link to comment Share on other sites More sharing options...
Sebavan Posted November 21, 2018 Share Posted November 21, 2018 Ping @trevordev Quote Link to comment Share on other sites More sharing options...
trevordev Posted November 22, 2018 Share Posted November 22, 2018 @SimonN Hey Simon, based on this thread http://www.html5gamedevs.com/topic/29006-depreciated-set-physics-state-missing/ it looks like those methods were deprecated and removed, replaced with new PhysicsImpostor, getPhysicsImpostor().getParam("mass"); . Likely any physics methods you were using that no longer work have been replaced. Hopefully the porting effort is minimal. Sebavan 1 Quote Link to comment Share on other sites More sharing options...
SimonN Posted November 23, 2018 Author Share Posted November 23, 2018 Quote Thanks. I now have it all working but have one additional question. You can see the old working version at http://bnieinsurance.com. There are a number of spheres and for each sphere there's a text label and a ghost that renders an animation if the sphere is clicked. With the new code prior to the fix below, the label and ghost don't move, only the sphere and the imposter. The workaround I used to make the code work again is to move the label and ghost in each render loop, which I've added in the else part of the code snippet below: //if any sphere is too high, make it invisible (and the code above will at some point restart it var yLimit = 35; for (var counter3 = 1; counter3 <= 6; counter3++) { if (scene.meshes[counter3 + 1].position.y >= yLimit) { scene.meshes[counter3 + 1].visibility = false; scene.meshes[counter3 + 7].visibility = false; } else { //11/23/2018 expensive operation inside render loop to set the position of the text labels (+7) //and the ghost centers inside (+13) that become visible when a sphere is clicked. scene.meshes[counter3 + 7].position.x = scene.meshes[counter3 + 1].position.x; scene.meshes[counter3 + 7].position.y = scene.meshes[counter3 + 1].position.y; scene.meshes[counter3 + 7].position.z = scene.meshes[counter3 + 1].position.z; scene.meshes[counter3 + 13].position.x = scene.meshes[counter3 + 1].position.x; scene.meshes[counter3 + 13].position.y = scene.meshes[counter3 + 1].position.y; scene.meshes[counter3 + 13].position.z = scene.meshes[counter3 + 1].position.z; } } The Oimo physics engine moves the sphere using the imposter: iSphereBnie[0] = new BABYLON.PhysicsImpostor(sphere1, BABYLON.PhysicsImpostor.BoxImpostor); iSphereBnie[0].mass = 10; iSphereBnie[0].friction = 0.0001; iSphereBnie[0].restitution = 0.99; … but the old code somehow managed to move the label and the ghost along with the sphere. I've looked thoroughly and can't find anything that effects this, the only thing I can think of is that there were some similarities in the names of the trio of sphere, label and ghost that made this happen under the covers and with the new code that is no longer the case, or my changing the name of the imposter and making the imposters a global array broke it. In general terms, I need one imposter to move 3 meshes in unison, is there some easy way of doing this that is more efficient than using the render loop above? It looks like there are joints to constrain two imposters, but I don't see anything to constrain 3 meshes to all be controlled by the same imposter? Thanks again! Quote Quote Link to comment Share on other sites More sharing options...
trevordev Posted November 26, 2018 Share Posted November 26, 2018 Do you have a playground (https://playground.babylonjs.com/#7149G4#0) showing it not working that I can take a look at? If you attach a mesh as a child of the mesh with the impostor attached I would expect it to work. Quote Link to comment Share on other sites More sharing options...
SimonN Posted November 26, 2018 Author Share Posted November 26, 2018 Thanks, somewhat embarrassingly I managed to get this far without realizing that you can explicitly define parent/child relationships between meshes, so after writing code like: mesh1.parent = mesh2; and removing all the code where I set the position of the child meshes it worked fine. Interestingly, where the child mesh is there to display text, using the parent child relationship works well when the objects move gently and having the text be readable only some of the time provides a good visual experience as the text moves and rotates with the parent mesh. When you want the text on a BABYLON.Mesh.CreatePlane to be more readable, the original approach works better. Appreciate everything. Sebavan 1 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.