Search the Community
Showing results for tags 'area'.
-
Hi I want to clone the Agario game. my canvas 1900x1900 px. My screen size is 1366x638 px. I want the player to move all over the canvas, moving on the canvas. However, the player can go from point (0,0) to point (1366,638). How can I solve this problem? Link Phaser2 | P2JS
- 2 replies
-
- agario
- agario clone
-
(and 2 more)
Tagged with:
-
https://www.babylonjs-playground.com/#X2F6KI#2 can any one help to find how can I get the intersected area of cubes. actually, I want to highlight the intersected area in between these two cubes. also, want to print into console how much points are intersected.
- 1 reply
-
- cubes
- intersection
-
(and 3 more)
Tagged with:
-
Hi people, As this has been requested from time to time on this forum, here is a simple and fast method for computing any mesh area : var area = function(mesh) { if (!mesh) { return 0.0; } var indices = mesh.getIndices(); var positions = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind); var v1x = 0.0; var v1y = 0.0; var v1z = 0.0; var v2x = 0.0; var v2y = 0.0; var v2z = 0.0; var crossx = 0.0; var crossy = 0.0; var crossz = 0.0; var ar = 0.0; var i1 = 0; var i2 = 0; var i3 = 0; var nbFaces = indices.length / 3; for (var i = 0; i < nbFaces; i++) { i1 = indices[i * 3]; i2 = indices[i * 3 + 1]; i3 = indices[i * 3 + 2]; v1x = positions[i1 * 3] - positions[i2 * 3]; v1y = positions[i1 * 3 + 1] - positions[i2 * 3 + 1]; v1z = positions[i1 * 3 + 2] - positions[i2 * 3 + 2]; v2x = positions[i3 * 3] - positions[i2 * 3]; v2y = positions[i3 * 3 + 1] - positions[i2 * 3 + 1]; v2z = positions[i3 * 3 + 2] - positions[i2 * 3 + 2]; crossx = v1y * v2z - v1z * v2y; crossy = v1z * v2x - v1x * v2z; crossz = v1x * v2y - v1y * v2x; ar = ar + Math.sqrt(crossx * crossx + crossy * crossy + crossz * crossz); } return ar * 0.5; }; As it doesn't allocate any object, nor calls external functions, it should be fast, GC friendly and it might be called within the render loop. Just let me know if you want it to be integrated in BJS as a method of the class Mesh or AbstractMesh. [EDIT] For experts, note that this computation could be shared and done in one line only within the method ComputeNormals() of the class VertexData just after this line : https://github.com/BabylonJS/Babylon.js/blob/master/src/Mesh/babylon.mesh.vertexData.ts#L2007 with something like : area += length * 0.5;
-
Hi, I'm developing my first web game and I have small problem. Uncaught TypeError: this.constrainBackground is not a function .... on line 50 I dont know what I'm doing wrong. Any ideas? Thx (This is about that the user can drag/drop background image only from left to right in the window (fix size window).
-
Hey! I was wondering if there's a way to define a clickable area on the screen without using buttons or sprites. Or to create this effect I would need to create an invisible sprite or something like that? Thanks