Drag an object along a bezier curve using ThreeJs - three.js

Using threesJs. I'm trying to move an object along a bezier curve (idealy beziercurve3).
My purpose is to move a little point by mouse and then after use this point to cut this curve in two,
or start an other curve3 attached to this point.
From what I search before I suppose I should use something like clamp_to_curve function.
I saw that Line3 got closestPointTPoint Is it a good idea to do the same with a bezier curve?
Maybe getPoint and getPointAt from curve can help but I don't know how to use them. After searching for a while I fill a little bite lost.
What is the best way to start this ?

Related

Three.js: Make raycaster's direction the same as object's

all!
I'm currently making a game in THREE.js and while I've got the 'vertical' collision with the ground sorted with a raycaster, I am having trouble with horizontal collision. I've consulted a few tutorials, but they don't do what I want them to.
Basically, I've got a load of cubes. I've given them a random y-axis rotation and used translate to make them move 'forward' - pretty basic stuff. How do I get a raycaster to point the same direction as the cube, almost like a line sticking out of its 'nose'? i.e. how do I get a raycaster's direction to copy that of an object?
It's been a while since I've been on here, but kind regards anyway,
Matthew

Triangulate surface in 3D-space

I have a set of points(x,y,z) in space and from them i need to create a surface and triangulate it. In theory it should be something like parametric-generated surface.
I have tried projecting points on 2d, triangulate it and put it back in 3D, but this doesn't work for me, also tried few algoritms but main problem, that i have is all of them gives back polyhedron-shaped object, but my goal surface-shaped triangulated object. I need some help with algorithms/different approach to problem
You need to implement BallPivoting, give a look to: http://www.research.ibm.com/vistechnology/pdf/bpa_tvcg.pdf

Is there a common technique for drawing a "stretchy" line

I'm trying to figure out how to draw an stretchy/elastic line between two points in openGL/Cocos2d on iPhone. Something like this
Where the "band" get's thinner as the line gets longer. iOS uses the same technique I'm aiming for in the Mail.app, pull to refresh.
First of all, is there a name for this kind of thing?
My first thought was to plot a point on the radius of the starting and ending circles based on the angle between to the two, and draw a quadratic bezier curve using the distance/2 as a control point. But I'm not a maths whizz so I'm struggling to figure out how to place the control point which will adjust the thickness of the path.
But a bigger problem is that I need to fill the shape with a colour, and that doesn't seem to be possible with OpenGL bezier curves as far as I can tell since curves don't seem to form part of a shape that can be filled.
So I looked at using a spline created using a point array, but that opens up a whole new world of mathematical pain as I'd have to figure out where all the points along the edge of the path are.
So before I go down that rabbit hole, I'm wondering wether there's something simpler that I'm overlooking, or if anyone can point me towards the most effective technique.
I'm not sure about a "common" technique that people use, other than calculating it mathematically, but this project, SlimeyRefresh, is a good example of how to accomplish this.

Is it possible to cut parts of the shape 'Geometry' away in Three.js?

Is it possible to remove or cut away sections of shapes in Three.js?
For example, if I made a CylinderGeometry and wanted to "shave" the front of it away, so that the front was flat and the back was curved, like a half cylinder. Is this possible?
I need to be able to do it to the front and back of a cylinder, so just the sides are curved.
It is possible. You can deal with triangles yourself, or use Boolean operations with a library like constructive solid geometry to do mesh subtraction.
Have a look here and here for some suggestions related to manipulating geometry.
There are other algorithms to slice a mesh that could be ported over, but it depends on how simple or complex you need this thing to be.

OpenGL : Line jittering with large scene and small values

I'm currently drawing a 3D solar system and I'm trying to draw the path of the orbits of the planets. The calculated data is correct in 3D space but when I go towards Pluto, the orbit line shakes all over the place until the camera has come to a complete stop. I don't think this is unique to this particular planet but given the distance the camera has to travel I think its more visible at this range.
I suspect its something to do with the frustum but I've been plugging values into each of the components and I can't seem to find a solution. To see anything I'm having to use very small numbers (E-5 magnitude) for the planet and nearby orbit points but then up to E+2 magnitude for the further regions (maybe I need to draw it twice with different frustums?)
Any help greatly appreciated...
Thanks all for answering but my solution to this was to draw it with the same matrices that were drawing the planet since it wasn't bouncing around as well. So the solution really is to code better really, sorry.

Resources