Search the Community
Showing results for tags 'sphere'.
-
Hey, In my project I need to create a sphere with a height map, but I only found the function "CreateGroundFromHeightMap" in the babylonjs docs. It seems like there is not a function for spheres. Can anybody help me with that? Basicly I need the function "CreateSphereFromHeightMap".
-
I am sure the problem is already solved somewhere and well known but I can't find a working solution. I have a sphere with planes around it and I need those planes to be tangent to the sphere depending on its position. I have made a playground with my basic setup: https://www.babylonjs-playground.com/#VDG184#2 You will see 2 solutions I tried but which are not working, one using path3D and one with basic math. Thank you, Pichou
-
solved Drawing an Arc on a Sphere from Point A to point B
distraub posted a topic in Questions & Answers
Hey guys, I have been trying to do this for awhile, and feel like I am almost there. I had been using Bezier Curves but it wasn't quite doing what I needed. I need to draw an arc made with lines between 2 points on the sphere, following the curve of the sphere. I think I am close on this playground but some of my math isn't right in the drawArcFromPoints function Anyone think they can take a look and tell me where I am going wrong? https://www.babylonjs-playground.com/#2I0VXX#28 -
Hi, Here's an example of what I am trying to do: http://www.babylonjs-playground.com/#N9MYJN#2 I should see my four corners appear around the sphere on the 2D canvas, but for whatever reason they do not show up in the correct spot. Thanks, -StarToaster
- 3 replies
-
- sphere
- boundingbox
-
(and 1 more)
Tagged with:
-
Hi everyone, Here's my last BabylonJS project. It's a port of a previous one I had made with Unity. The concept is about Spherical Voxels. A sphere is divided in degenerated-squares, allowing to create a minecraft-like voxel terrain on it. You may try it here : http://svenfrankson.github.io/PlanetBuilderWeb/index.html And source code is available here : https://github.com/SvenFrankson/planet-builder-web Have a nice day !
-
I have recently started on a Babylon project, and I have been wanting to create a capsule physics impostor for my game. I found a test demo for Oimo.js that basically achieves what I want: compound test (capsule). There are two problems: 1. due to some shortcomings in Oimo, I have had to switch to Cannon.js. 2. the demo uses Three.js and I'm sure how to exactly translate that into Babylon. I basically want to be able to combine two sphere impostors with a cylinder impostor. I'm not sure what is the best method for this, there are only a few examples that I have found, and I haven't found anything in the docs. So I created an example to show what I am talking about: capsule sandbox. I have created the capsule mesh, but I just need to figure out how to add a capsule impostor. Thanks.
-
Why ? var rawVerts = object.getVerticesData ? object.getVerticesData(BABYLON.VertexBuffer.PositionKind) : []; var rawFaces = object.getIndices ? object.getIndices() : []; BABYLON.Tools.Warn("MeshImpostor only collides against spheres."); returnValue = new CANNON.Trimesh(rawVerts, rawFaces); Even tho CannonJS supports mesh/plane collision ? : Demo : https://schteppe.github.io/cannon.js/demos/bunny.html Source : https://github.com/schteppe/cannon.js/blob/master/demos/bunny.html // ground plane var groundShape = new CANNON.Plane(); var groundBody = new CANNON.Body({ mass: 0, position: new CANNON.Vec3(0,0,-5) }); groundBody.addShape(groundShape); world.addBody(groundBody); demo.addVisual(groundBody); Edit: Ok, I overlooked the fact that the Mesh impostor is infact a Trimesh shape (https://schteppe.github.io/cannon.js/demos/trimesh.html). So can you add ConvexPolyhedron shapes in the next release please ?
-
Hi guys, i tried to use the update function from an older forum post to edit the size of my bounding box. Somehow the bounding box didn't change. Link: http://www.babylonjs-playground.com/#WXK2X#2 Any ideas?
-
Hi All, I'm working on something I'd like for my project; specifically I want to nest one mesh inside another and have collision detection (e.g. like the dice in a dome in the trouble board game http://www.boardgamescritic.com/wp-content/uploads/2010/10/trouble-board-game-board.jpg ). I've read all the physics related tutorials for cannon and Oimo, seemed to get further (not far) with Oimo; so sticking with that so far. Have also looked at all of the relevant demos I could find. I have a playground which illustrates the efforts I've made so far: http://www.babylonjs-playground.com/#1SZYKZ#2 As you'll see; gravity affects the cube. However I'd like the cube to stop when it collides with the sphere; so it never leaves the sphere. I'd like the sphere to remain static (or at least not move) which is why i've set its mass to 0 per the tutorials. Eventually if I shake the sphere, the cube would bounce around inside the sphere (first things first). Any advice would be greatly appreciated!
-
Please find my multi texture sphere implementation at http://www.babylonjs.com/playground/#KDRY0. Now I would like add actions to each of the colors in the sphere, or simply adding event handler with each sub meshes. But its not working. for(i=0;i<data.length;i++){ var currentRowSize = Math.round(data[i] * individualOffset) * rowSize; // Just adding remaing space to last item if(i == data.length-1){ currentRowSize = rowCount*rowSize - prevRowSize; } submeshes[i] = new BABYLON.SubMesh(i+1, 0, verticesCount, prevRowSize,currentRowSize , sphere); prevRowSize+= currentRowSize; sphere.subMeshes.push(submeshes[i]); submeshes[i].actionManager = new BABYLON.ActionManager(scene); submeshes[i].actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickTrigger, function(e){ console.log(e); })); }How can this can be implemented ? Please let us know your thoughts
-
- Babylon Action Manager
- Babylon
-
(and 1 more)
Tagged with:
-
The testscene simulate the situation, where the ball never stop!? I think we can solve it with the Brownian Motion in intensity and tween or easing type http://easings.net/en, http://www.greensock.com/gsap-js/ 3dDemo More infos: http://de.wikipedia.org/wiki/1/f%C2%B2-Rauschen http://en.wikipedia.org/wiki/Brownian_noise http://en.wikipedia.org/wiki/Brownian_motion Testscene: <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>BABYLON - physics</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <link rel="stylesheet" href="lib/css/babylon.css"> <script src="lib/js/babylon.1.9.0.js"></script> <script src="lib/js/hand.js"></script> <script src="lib/js/stats.js"></script> <script src="lib/js/cannon.js"></script> <script type="text/javascript">window.onload=function(){ this.canvas = document.getElementById("webgl"); if (!BABYLON.Engine.isSupported()){window.alert('Your browser do not support WebGL'); }else{ var engine = new BABYLON.Engine(canvas,true); scene = createScene(engine); scene.activeCamera.attachControl(canvas); engine.runRenderLoop(function(){ scene.render(); stats(scene,"stats"); // call the statistics }); this.addEventListener("resize", function () { engine.resize(); }); } };var createScene= function (engine){ var scene = new BABYLON.Scene(engine); var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 3, -40), scene); camera.position.y = -12; camera.checkCollisions = true; camera.applyGravity = true; var light = new BABYLON.DirectionalLight("dir02", new BABYLON.Vector3(0.2, -1, 0), scene); light.position = new BABYLON.Vector3(0, 80, 0); var materialAmiga = new BABYLON.StandardMaterial("amiga", scene); materialAmiga.diffuseTexture = new BABYLON.Texture("lib/media/amiga.jpg", scene); materialAmiga.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5); materialAmiga.diffuseTexture.uScale = 5; materialAmiga.diffuseTexture.vScale = 5; var materialAmiga2 = new BABYLON.StandardMaterial("amiga", scene); materialAmiga2.diffuseTexture = new BABYLON.Texture("lib/media/ground.jpg", scene); materialAmiga2.emissiveColor = new BABYLON.Color3(0.5, 0.5, 0.5); var box = BABYLON.Mesh.CreateBox("Box", 10, scene); box.position.x = -8; box.material = materialAmiga2; box.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(0, .21, .43); var sphere = BABYLON.Mesh.CreateSphere("Sphere", 9, 10.0, scene); sphere.position.x = 6; sphere.material = materialAmiga; var ground = BABYLON.Mesh.CreatePlane("Plane", 164.0, scene); ground.material = materialAmiga2; ground.position.y = -30; ground.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(0, Math.PI/2, 0); // Physics scene.enablePhysics(); scene.setGravity(new BABYLON.Vector3(0, -98.1, 0)); sphere.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: 1, }); box.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 5 }); ground.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: 0, friction: 1, restitution: 0.1 }) return scene; };</script></head><body> <canvas id="webgl"></canvas></body></html>
- 3 replies
-
- Brownian noise
- ~ 1/f²
-
(and 5 more)
Tagged with: