> For the complete documentation index, see [llms.txt](https://tomaspietravallo.gitbook.io/sparkar-volts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tomaspietravallo.gitbook.io/sparkar-volts/extra-utils/transformacrossspaces.md).

# transformAcrossSpaces

{% hint style="warning" %}
Keep in mind that this is an advanced function that works with coordinate spaces
{% endhint %}

## Parameters

1. `vec`: a Vector signal representing the position of the object to "follow"
2. `vecParentSpace`: The parent space in which `vec` is located
3. `targetParentSpace`: A TransformSignal representing the "target space", which in the absolute frame of reference

```typescript
function transformAcrossSpaces(
  vec: VectorSignal,
  vecParentSpace: TransformSignal,
  targetParentSpace: TransformSignal,
): VectorSignal
```

## Example

With the code example below, the two objects will be placed on top of each other no matter what happens in the rest of the scene

{% hint style="info" %}
Note: sometimes a reload is required after changing the Scene hierarchy
{% endhint %}

```typescript
import { transformAcrossSpaces } from './volts';

// define two SceneObjects
let firstObj: SceneObjectBase, secondarySceneObj: SceneObjectBase;

// make both objects be in the same position
// obj2 is placed on top of obj1
secondarySceneObj.transform.position =
  transformAcrossSpaces(
    firstObj.transform.position,
    firstObj.parentWorldTransform,
    secondarySceneObj.parentWorldTransform
  );
```

>
