Search the Community
Showing results for tags 'abstractmesh'.
Found 2 results
solved Mesh vs AbstractMesh
Art Vandelay posted a topic in Questions & AnswersHi everyone, What's the difference between Mesh and AbstractMesh? I understand the Mesh extends AbstractMesh but I am trying to understand when I should use one and when I should use the other. An example would be great as well. Thanks!
Hi all, Update - 17 / 02 mesh.collisionGroup = maskNumber; have been added to AbstractMesh. Two new properties, collisionGroup and collisionMask, have been added to AbstractMesh, collisionMask have been added to FreeCamera, and is coming with 2.6. Why? What do they do? The collisionGroup & collisionMask checks whether a camera Vs mesh or mesh Vs mesh collision should happen. Thus, it allows us to customize collisions, enabling us to decide what meshes should collide with each other and which meshes should collide with the camera An example could be to have collisions between the camera and a box aswell as the camera and a sphere, but no collision between the sphere and the box all at the same time. Once it's live, it will work like this; var group1 = 1; // x to the power of 2, starting from 1. var group2 = 2; // 1*2 = 2 var group3 = 4; // 2*2 = 4 var group4 = 8; // 4*2 = 8, and so on. // This mesh is part of the group1 collisionGroup, camera's and other (moving) meshes with group1 in their collisionMask will collide with this mesh. mesh.collisionGroup = group1; // While moving, this mesh will collide with other meshes which has either group1 or group2 as their collisionGroup mesh.collisionMask = group1 + group2; // While moving, the camera will collide with meshes which has either group1 or group2 as their collisionGroup camera.collisionMask = group1 | group2; // doing group1 | group2 has the same effect as, but is less dynamic than, group1 + group2 You can also do; camera.collisionMask = group1; // Set mask to collide with group1. camera.collisionMask += group2; // Set mask to also collide with group2. camera.collisionMask -= group1; // Remove group1 from mask so we only collide with group2. // Take careful note before using this method, to avoid issues, you must first override the default mask (-1) by doing cameraOrMesh.collisionMask = your_group_x_variable; It is currently not available for webworkers. Backwards compatibility, If this isn't something that interests you, you're all good, nothing has changed. Masks Masks are numbers to the power of 2, starting from 1. Special masks -1 ; Always collides. 0 ; Never collides, overrides mask -1. // not recommended to use on camera with standard gravity applied. Standard masks , x to the power of 2; 1 | 1*2 = 2 | 2*2 = 4 | 4*2 = 8 | 8*2 = 16 | etc. 1 2 4 8 16 Etc PG Example; The camera collides with the ground & box, but not with the sphere and the sphere and box doesn't collide with each other either. http://www.babylonjs-playground.com/#20PQBI#43 Cheers. If you have any questions, ideas or thoughts, please do continue the discussion below.