# SDFs in the scene - raymarching

**URL:** <https://discourse.threejs.org/t/sdfs-in-the-scene-raymarching/78355>\
**Category:** Resources\
**Tags:** raymarching, sdf\
**Created:** [February 19, 2025, 7:23pm UTC](https://discourse.threejs.org/t/sdfs-in-the-scene-raymarching/78355 "2025-02-19T19:23:50Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![hofk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/hofk/32/44944_2.png) [@hofk](https://discourse.threejs.org/u/hofk)\
**Post date:** [February 28, 2025, 7:02pm UTC](https://discourse.threejs.org/t/sdfs-in-the-scene-raymarching/78355/14 "2025-02-28T19:02:16Z")

</div>

In example 3, there is a very simple movement using sin/cos.

I now wanted to realize a movement like in my example [FlightRouteQuaternion](https://hofk.de/main/discourse.threejs/2021/CarRacing/FlightRouteQuaternion.html) .

However, I was only partially successful. The movement on the space curve works, but the alignment of the capsule obviously does not. Also, the whole curve should appear as a yellow line (similar to [Shader - Shadertoy BETA](https://www.shadertoy.com/view/tsKyzc)), but only a blinking point on the capsule is the result of my efforts. My knowledge and experience with shaders is still too poor.

To integrate the movement, I added the files quaternions.js and curveMovement.js to the BasicFiles and added them to shaderParts.js.

For the quaternions I use as in the source [Shader - Shadertoy BETA](https://www.shadertoy.com/view/fdtfWM) @author jt  
justified

```javascript

struct quat
{
    float s;
    vec3 v;
};

```

The addition is a modification of [Quaternion - method .setFromBasis( e1, e2, e3 )](https://discourse.threejs.org/t/quaternion-method-setfrombasis-e1-e2-e3/27407)

If you only want to achieve a fixed alignment with` rotate(quat q, vec3 p)`, you can convert the values there, for example, and try them out visually: [Quaternion - Axis, Angle Visualization](https://discourse.threejs.org/t/quaternion-axis-angle-visualization/1358)

---

_[View the full topic](https://discourse.threejs.org/t/sdfs-in-the-scene-raymarching/78355)._
