Jump to content

Camera Mesh using beta help..


chicagobob123
 Share

Recommended Posts

So I added the DynamicGround and thought I would add a containers as well. So I created a container and a FreeCamera added so far so good but as I go forward or backward up or down the container moves with the camera? The ground is fine the container I created moves with the camera. It stays the same distance away? So container moves without me changing position like it's attached to camera with a string. I will come up with a pg project this morning. This is something basic but not obvious.

 

 

 

Link to comment
Share on other sites

Hi again, @chicagobob123... did you get it figured-out successfully?  I see no PG, so maybe that is good news.

"Container" is a rarely-used term/word around here.  ("Group" is rare, too.)  Neither of these terms are used in BabylonJS.  Around here, it's mostly just "parent". 

But if you parent one or many meshes to an "invisible gizmo mesh", then you have simulated a grouping or container.  And yes, mesh who have their .parent set to another mesh... will automatically "follow" that mesh, rotation-wise, position-wise, and scale-wise.  (It's "The Big Three" parent-passed-down properties.)

So, yes, mesh who have a parent mesh...

 - Get their .position, .rotation, and .scaling... "summed" with the parent's .position, .rotation, and .scaling.
 - Use their .position, .rotation, and .scaling values... to set an "offset"-from the parent .position, .rotation, and .scaling.
 - Get changed (auto-updated) .position, .rotation, and .scaling whenever their parent changes .position, .rotation, and .scaling.
 - Cannot change their parent's .position, .rotation, and .scaling (unless done with a method that has been added to the child mesh)

Boy, I hope I said that correctly and understandably.  :)  I'm no pro... I'm just a talker.  But these are the loose "rules" that I keep in my mind... when working with parenting, and these rules have treated me well.

Warning:  Parenting a mesh to a camera or light... can have results that are different than parenting to a mesh.  For example, have you ever heard of anyone .scaling a camera?  Noooo.  So, if you expect to inherit scaling from a camera or light parent, that won't give expected results.

SOME people never parent to a camera or light.  Sometimes, they parent cameras, lights, and mesh... to one or more previously-mentioned "invisible gizmo mesh".  And some use the bare-bones Babylon.Mesh as their "gizmo":

var gizmo = new BABYLON.Mesh("grouper", scene);

Basic mesh like this... are invisible by default, and are light-weight, resources-wise.  Yet they have "The Big Three" properties on-board... and so they are excellent parents.  Here is a playground that does it all, and uses the cool .bakeCurrentTransformIntoVertices() feature, which is a GOOD friend of parenting.  :)  Hope this helps.

Link to comment
Share on other sites

Sorry if I knew what worked how.. Can't wait to get to the point where I am comfortable bumping my head so often, well let's just say I hate being a pain. High Pressure to display and complete. You know the drill. While preping the entire thing for PG it works properly while cutting and pasting code? Ughh not my best day

Link to comment
Share on other sites

OK OK just in case someone is ever going to do this. All of models have real world sizes. In my cutting and pasting examples I did not see and understand this one line 

BABYLON.Mesh.CreateGround("ground1", 6, 6, 2, scene);

This means create ground that is 6  x 6 in size. I was 

Well it turns out I was inside a container thats 40 feet by 8.5 feet. I did not see this until I got a small mesh box to show up that was a size of 1x1x1 

Altering this to the real size of ground to 

BABYLON.Mesh.CreateGround("ground1", 8192,8192, 2, scene); 

(8192x8192 is the size I scaled the real world positions to because thats the size of my Dynamic texture )

Changing this fixed most everything. Finally all the numbers started making sense I can put models in correct location etc. 

 

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...