forked from phenom/healer-man
Release Healer Man 0.1.14
This commit is contained in:
1 parent
67d7a8ebe7
commit
7b41b102fa
147 files changed
+169892
-1342
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { Vector3, type Object3D } from "three";
|
||||
|
||||
const anchors = new Map<string, Object3D>();
|
||||
|
||||
export function registerCombatEffectAnchor(actorId: string, object: Object3D): () => void {
|
||||
anchors.set(actorId, object);
|
||||
return () => {
|
||||
if (anchors.get(actorId) === object) anchors.delete(actorId);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies an actor's current rendered world position into an effect's parent
|
||||
* space. This follows the scene object directly instead of a throttled combat
|
||||
* or network snapshot while deliberately avoiding inherited actor rotation.
|
||||
*/
|
||||
export function updateCombatEffectAnchorPosition(
|
||||
actorId: string | undefined,
|
||||
effect: Object3D,
|
||||
worldPosition: Vector3,
|
||||
): boolean {
|
||||
if (!actorId) return false;
|
||||
const anchor = anchors.get(actorId);
|
||||
if (!anchor) return false;
|
||||
anchor.getWorldPosition(worldPosition);
|
||||
effect.parent?.worldToLocal(worldPosition);
|
||||
effect.position.copy(worldPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
export function clearCombatEffectAnchorRegistry(): void {
|
||||
anchors.clear();
|
||||
}
|
||||
Reference in new issue
Block a user