Going the Distance with Babylon.js by Josh Elster

Going the Distance with Babylon.js by Josh Elster

Author:Josh Elster
Language: eng
Format: epub, pdf
Publisher: Packt
Published: 2022-12-15T00:00:00+00:00


Figure 8.6 – The Alien.gltf model. The Scene Inspector window shows the __root__ transform node. From https://playground.babylonjs.com/#8IMNBM#1

The Alien geometry is what we’re interested in working with, but because it is parented to the __root__ node, any changes to the position, rotation, or scaling of Alien are evaluated in a coordinate space relative to that root node, resulting in undesired and unpredictable results. The solution to this is simple and answers our earlier question regarding what was up with our loadAssets code – unparent the desired mesh and dispose of the root. Once that’s accomplished, the rest of the code in our truck loading method is all housekeeping setup for the model – with some important considerations to keep in mind:

Order of operations is important, but not in the way you might think. Changes to a TransformNode (which Mesh is a descendent of) over a given frame are applied in the fixed order of Transform, Rotate, Scale (TRS).

Use setParent(null) rather than the alternative of setting mesh.parent = null. The setParent function preserves positional and rotational values, whereas setting the parent to null does not. This results in any root transformations being removed from the mesh, which is why we need to reset the position and rotation vectors.

Once the transformations have been cleared and the scaling has been set to world-appropriate values, the mesh geometry will need to have new bounding information generated. Otherwise, collisions won’t work properly. The solution to this is the two-step process of calling mesh.bakeCurrentTransformIntoVertices() before calling mesh.refreshBoundingInfo().



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Deep Learning with Python by François Chollet(12525)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7748)
Autodesk Civil 3D 2024 from Start to Finish by Stephen Walz Tony Sabat(6187)
Mathematics for Game Programming and Computer Graphics by Penny de Byl(6080)
Taking Blender to the Next Level by Ruan Lotter(5839)
Express Your Creativity with Adobe Express by Rosie Sue(5693)
Hands-On Unity 2022 Game Development - Third Edition by Nicolas Alejandro Borromeo(5296)
Hands-On Unity 2022 Game Development by Nicolas Alejandro Borromeo(4580)
Adobe Illustrator for Creative Professionals by Clint Balsar(3662)
Unreal Engine 5 Character Creation, Animation, and Cinematics by Henk Venter & Wilhelm Ogterop(3442)
Going the Distance with Babylon.js by Josh Elster(3415)
Mastering Graphics Programming with Vulkan by Marco Castorina & Gabriel Sassone(3320)
Squeaky Clean Topology in Blender by Michael Steppig(3252)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2890)
Unreal Engine 5 Character Creation, Animation, and Cinematics by Henk Venter
 Wilhelm Ogterop(2865)
Rapid Viz: A New Method for the Rapid Visualization of Ideas by Kurt Hanks & Larry Belliston(2674)
The 46 Rules of Genius: An Innovator's Guide to Creativity (Voices That Matter) by Marty Neumeier(2630)
Learn Qt 5: Build modern, responsive cross-platform desktop applications with Qt, C++, and QML by Nicholas Sherriff(2356)
Fusion 360 for Makers by Lydia Sloan Cline(2209)
Hands-On Neural Networks with Keras by Niloy Purkait(2155)