SimonN

BJS 4.0.0-alpha.9 : fresnel.js:356 Uncaught TypeError: billboard.setPhysicsState is not a function

Recommended Posts

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:

image.thumb.png.91b1a344c2573dab6230291efddcfdbe.png

here's the offending code in  Chrome

image.thumb.png.bd2a715916cce2353069fe1686864a53.png

… and here's the earlier place where billboard gets defined

image.thumb.png.db9b26e74239aa66335b717fe63a5a28.png

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.

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites
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

 

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.