@hology/core 0.0.211 → 0.0.213

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/dist/effects/sequence/index.d.ts +1 -0
  2. package/dist/effects/sequence/index.js +1 -1
  3. package/dist/effects/sequence/sequence-action.d.ts +5 -0
  4. package/dist/effects/sequence/sequence-actor.d.ts +7 -0
  5. package/dist/effects/sequence/sequence-actor.js +1 -1
  6. package/dist/effects/sequence/sequence-animation-retiming.js +1 -1
  7. package/dist/effects/sequence/sequence-data.d.ts +9 -0
  8. package/dist/effects/sequence/sequence-data.js +1 -1
  9. package/dist/effects/sequence/sequence-player.d.ts +12 -1
  10. package/dist/effects/sequence/sequence-player.js +1 -1
  11. package/dist/effects/sequence/sequence-transform.d.ts +10 -0
  12. package/dist/effects/sequence/sequence-transform.js +4 -0
  13. package/dist/effects/sequence/sequence-value-lane.d.ts +2 -0
  14. package/dist/effects/sequence/sequence-value-lane.js +1 -1
  15. package/dist/effects/vfx/initializsers.d.ts +8 -1
  16. package/dist/effects/vfx/initializsers.js +1 -1
  17. package/dist/effects/vfx/vfx-actor.d.ts +5 -0
  18. package/dist/effects/vfx/vfx-actor.js +1 -1
  19. package/dist/effects/vfx/vfx-asset.d.ts +2 -1
  20. package/dist/effects/vfx/vfx-asset.js +1 -1
  21. package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
  22. package/dist/effects/vfx/vfx-defs.d.ts +10 -1
  23. package/dist/effects/vfx/vfx-defs.js +1 -1
  24. package/dist/effects/vfx/vfx-materializer.js +1 -1
  25. package/dist/effects/vfx/vfx-renderers.d.ts +2 -0
  26. package/dist/effects/vfx/vfx-renderers.js +1 -1
  27. package/dist/gameplay/actors/actor.d.ts +21 -1
  28. package/dist/gameplay/actors/actor.js +1 -1
  29. package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
  30. package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
  31. package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +25 -0
  32. package/dist/gameplay/actors/builtin/components/character/character-movement-like.js +4 -0
  33. package/dist/gameplay/actors/builtin/components/character/character-movement-policy.d.ts +26 -0
  34. package/dist/gameplay/actors/builtin/components/character/character-movement-policy.js +4 -0
  35. package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +158 -55
  36. package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
  37. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +128 -0
  38. package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +4 -0
  39. package/dist/gameplay/actors/builtin/components/character/old-character-movement.d.ts +100 -0
  40. package/dist/gameplay/actors/builtin/components/character/old-character-movement.js +4 -0
  41. package/dist/gameplay/actors/builtin/components/index.d.ts +2 -0
  42. package/dist/gameplay/actors/builtin/components/index.js +1 -1
  43. package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
  44. package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
  45. package/dist/gameplay/actors/builtin/components/tween-component.js +1 -1
  46. package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +2 -0
  47. package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
  48. package/dist/gameplay/actors/builtin/trigger-volume.d.ts +3 -3
  49. package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
  50. package/dist/gameplay/actors/camera/camera-component.d.ts +1 -3
  51. package/dist/gameplay/actors/camera/camera-component.js +1 -1
  52. package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +3 -0
  53. package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
  54. package/dist/gameplay/actors/component.d.ts +3 -0
  55. package/dist/gameplay/actors/component.js +1 -1
  56. package/dist/gameplay/actors/controller/actor-controller.d.ts +16 -0
  57. package/dist/gameplay/actors/controller/actor-controller.js +4 -0
  58. package/dist/gameplay/actors/factory.d.ts +3 -0
  59. package/dist/gameplay/actors/factory.js +1 -1
  60. package/dist/gameplay/actors/index.d.ts +4 -0
  61. package/dist/gameplay/actors/index.js +1 -1
  62. package/dist/gameplay/actors/internal/component-init.js +1 -1
  63. package/dist/gameplay/actors/type-registry.d.ts +10 -0
  64. package/dist/gameplay/actors/type-registry.js +4 -0
  65. package/dist/gameplay/ai/behavior-tree/move.d.ts +2 -2
  66. package/dist/gameplay/animation/retarget.d.ts +50 -0
  67. package/dist/gameplay/animation/retarget.js +4 -0
  68. package/dist/gameplay/animation/root-motion.js +1 -1
  69. package/dist/gameplay/event-graph/actor-transform-properties.d.ts +6 -0
  70. package/dist/gameplay/event-graph/actor-transform-properties.js +4 -0
  71. package/dist/gameplay/event-graph/asset-actor-types.d.ts +3 -0
  72. package/dist/gameplay/event-graph/asset-actor-types.js +4 -0
  73. package/dist/gameplay/event-graph/asset-references.d.ts +12 -0
  74. package/dist/gameplay/event-graph/asset-references.js +4 -0
  75. package/dist/gameplay/event-graph/compiler.d.ts +107 -0
  76. package/dist/gameplay/event-graph/compiler.js +4 -0
  77. package/dist/gameplay/event-graph/decorators.d.ts +74 -0
  78. package/dist/gameplay/event-graph/decorators.js +4 -0
  79. package/dist/gameplay/event-graph/document-compiler.d.ts +107 -0
  80. package/dist/gameplay/event-graph/document-compiler.js +4 -0
  81. package/dist/gameplay/event-graph/event-graph-demo.d.ts +2 -0
  82. package/dist/gameplay/event-graph/event-graph-demo.js +4 -0
  83. package/dist/gameplay/event-graph/graph.d.ts +106 -0
  84. package/dist/gameplay/event-graph/graph.js +4 -0
  85. package/dist/gameplay/event-graph/index.d.ts +13 -0
  86. package/dist/gameplay/event-graph/index.js +4 -0
  87. package/dist/gameplay/event-graph/model.d.ts +71 -0
  88. package/dist/gameplay/event-graph/model.js +4 -0
  89. package/dist/gameplay/event-graph/nodes/execution-nodes.d.ts +115 -0
  90. package/dist/gameplay/event-graph/nodes/execution-nodes.js +4 -0
  91. package/dist/gameplay/event-graph/nodes/gameplay-nodes.d.ts +208 -0
  92. package/dist/gameplay/event-graph/nodes/gameplay-nodes.js +4 -0
  93. package/dist/gameplay/event-graph/nodes/index.d.ts +4 -0
  94. package/dist/gameplay/event-graph/nodes/index.js +4 -0
  95. package/dist/gameplay/event-graph/nodes/value-nodes.d.ts +53 -0
  96. package/dist/gameplay/event-graph/nodes/value-nodes.js +4 -0
  97. package/dist/gameplay/event-graph/registry.d.ts +33 -0
  98. package/dist/gameplay/event-graph/registry.js +4 -0
  99. package/dist/gameplay/event-graph/runtime-assets.d.ts +21 -0
  100. package/dist/gameplay/event-graph/runtime-assets.js +4 -0
  101. package/dist/gameplay/event-graph/runtime.d.ts +160 -0
  102. package/dist/gameplay/event-graph/runtime.js +4 -0
  103. package/dist/gameplay/event-graph/type-inference.d.ts +41 -0
  104. package/dist/gameplay/event-graph/type-inference.js +4 -0
  105. package/dist/gameplay/event-graph/types.d.ts +77 -0
  106. package/dist/gameplay/event-graph/types.js +4 -0
  107. package/dist/gameplay/index.d.ts +17 -2
  108. package/dist/gameplay/index.js +1 -1
  109. package/dist/gameplay/initiate.d.ts +4 -0
  110. package/dist/gameplay/initiate.js +1 -1
  111. package/dist/gameplay/input/input.d.ts +22 -17
  112. package/dist/gameplay/input/input.js +1 -1
  113. package/dist/gameplay/net/browser/index.d.ts +147 -0
  114. package/dist/gameplay/net/browser/index.js +4 -0
  115. package/dist/gameplay/net/index.d.ts +7 -0
  116. package/dist/gameplay/net/index.js +4 -0
  117. package/dist/gameplay/net/net-connection.d.ts +25 -0
  118. package/dist/gameplay/net/net-connection.js +4 -0
  119. package/dist/gameplay/net/net-session.d.ts +70 -0
  120. package/dist/gameplay/net/net-session.js +4 -0
  121. package/dist/gameplay/net/service/net-actor-role.d.ts +12 -0
  122. package/dist/gameplay/net/service/net-actor-role.js +4 -0
  123. package/dist/gameplay/net/service/net-decorator.d.ts +29 -0
  124. package/dist/gameplay/net/service/net-decorator.js +4 -0
  125. package/dist/gameplay/net/service/net-serializer.d.ts +15 -0
  126. package/dist/gameplay/net/service/net-serializer.js +4 -0
  127. package/dist/gameplay/net/service/net-service.d.ts +171 -0
  128. package/dist/gameplay/net/service/net-service.js +4 -0
  129. package/dist/gameplay/net/service/net-utils.d.ts +8 -0
  130. package/dist/gameplay/net/service/net-utils.js +4 -0
  131. package/dist/gameplay/net/service/replication.d.ts +31 -0
  132. package/dist/gameplay/net/service/replication.js +4 -0
  133. package/dist/gameplay/net/service/rpc-decorator.d.ts +21 -0
  134. package/dist/gameplay/net/service/rpc-decorator.js +4 -0
  135. package/dist/gameplay/net/service/rpc.d.ts +35 -0
  136. package/dist/gameplay/net/service/rpc.js +4 -0
  137. package/dist/gameplay/services/asset-loader.d.ts +10 -2
  138. package/dist/gameplay/services/asset-loader.js +1 -1
  139. package/dist/gameplay/services/physics/physics-system.d.ts +16 -1
  140. package/dist/gameplay/services/physics/physics-system.js +1 -1
  141. package/dist/gameplay/services/world.d.ts +25 -2
  142. package/dist/gameplay/services/world.js +1 -1
  143. package/dist/rendering/color-pass.js +1 -1
  144. package/dist/rendering.d.ts +2 -0
  145. package/dist/rendering.js +1 -1
  146. package/dist/scene/asset-resource-loader.d.ts +7 -1
  147. package/dist/scene/asset-resource-loader.js +1 -1
  148. package/dist/scene/batched-mesh-2.d.ts +9 -0
  149. package/dist/scene/batched-mesh-2.js +1 -1
  150. package/dist/scene/bootstrap.d.ts +2 -0
  151. package/dist/scene/bootstrap.js +1 -1
  152. package/dist/scene/custom-param-deserialize.js +1 -1
  153. package/dist/scene/custom-param-runtime-types.js +1 -1
  154. package/dist/scene/materializer.d.ts +29 -0
  155. package/dist/scene/materializer.js +1 -1
  156. package/dist/scene/model.d.ts +114 -2
  157. package/dist/scene/model.js +1 -1
  158. package/dist/scene/objects/prefab.js +1 -1
  159. package/dist/scene/storage/storage.d.ts +1 -1
  160. package/dist/scene/storage/storage.js +1 -1
  161. package/dist/shader/builtin/standard-shader.js +1 -1
  162. package/dist/shader/builtin/toon-shader.js +1 -1
  163. package/dist/shader/builtin/unlit-shader.js +1 -1
  164. package/dist/shader/color-layer.js +1 -1
  165. package/dist/shader/graph/compiler.d.ts +3 -0
  166. package/dist/shader/graph/compiler.js +1 -1
  167. package/dist/shader/graph/model.d.ts +1 -1
  168. package/dist/shader/graph/registry.js +1 -1
  169. package/dist/shader/parameter.d.ts +1 -1
  170. package/dist/shader/parameter.js +1 -1
  171. package/dist/shader-nodes/depth.js +1 -1
  172. package/dist/shader-nodes/scene-sample.js +1 -1
  173. package/dist/test/animation-retarget.test.d.ts +2 -0
  174. package/dist/test/animation-retarget.test.js +4 -0
  175. package/dist/test/batched-mesh-2.test.d.ts +2 -0
  176. package/dist/test/batched-mesh-2.test.js +4 -0
  177. package/dist/test/browser-net-session.test.d.ts +2 -0
  178. package/dist/test/browser-net-session.test.js +4 -0
  179. package/dist/test/event-graph-generated-code.test.d.ts +2 -0
  180. package/dist/test/event-graph-generated-code.test.js +4 -0
  181. package/dist/test/event-graph-types.test.d.ts +2 -0
  182. package/dist/test/event-graph-types.test.js +4 -0
  183. package/dist/test/event-graph.test.d.ts +2 -0
  184. package/dist/test/event-graph.test.js +4 -0
  185. package/dist/test/first-person-camera-component.test.js +1 -1
  186. package/dist/test/input.test.d.ts +2 -0
  187. package/dist/test/input.test.js +4 -0
  188. package/dist/test/net-character-movement.test.d.ts +2 -0
  189. package/dist/test/net-character-movement.test.js +4 -0
  190. package/dist/test/net-property-snapshot.test.d.ts +2 -0
  191. package/dist/test/net-property-snapshot.test.js +4 -0
  192. package/dist/test/prefab-instance-params.test.js +1 -1
  193. package/dist/test/sequence-animation-retiming.test.js +1 -1
  194. package/dist/test/sequence-camera-control.test.js +1 -1
  195. package/dist/test/sequence-scene-binding.test.d.ts +2 -0
  196. package/dist/test/sequence-scene-binding.test.js +4 -0
  197. package/dist/test/sequence-transform.test.d.ts +2 -0
  198. package/dist/test/sequence-transform.test.js +4 -0
  199. package/dist/test/shader-graph.test.js +1 -1
  200. package/dist/test/vfx-random-color-initializer.test.d.ts +2 -0
  201. package/dist/test/vfx-random-color-initializer.test.js +4 -0
  202. package/dist/test/world-prefab-spawn.test.d.ts +2 -0
  203. package/dist/test/world-prefab-spawn.test.js +4 -0
  204. package/dist/utils/three/placeholder-texture.d.ts +3 -0
  205. package/dist/utils/three/placeholder-texture.js +4 -0
  206. package/package.json +18 -2
  207. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,128 @@
1
+ import { CharacterMovementMode } from "./modes.js";
2
+ export declare const NET_CHARACTER_MOVEMENT_VERSION = 3;
3
+ export declare const MOVE_PACKET_KIND = 1;
4
+ export declare const OWNER_ACK_PACKET_KIND = 2;
5
+ export declare const OWNER_CORRECTION_PACKET_KIND = 3;
6
+ export declare const SIMULATED_STATE_PACKET_KIND = 4;
7
+ export declare const DEFAULT_MOVE_SEND_INTERVAL: number;
8
+ export declare const DEFAULT_SIMULATED_STATE_INTERVAL: number;
9
+ export declare const DEFAULT_MAX_SAVED_MOVES = 128;
10
+ export declare const DEFAULT_MAX_REPLAYED_MOVES = 64;
11
+ export declare const DEFAULT_MAX_SERVER_MOVES_PER_TICK = 4;
12
+ export declare const DEFAULT_MAX_MOVES_PER_PACKET = 16;
13
+ export declare const DEFAULT_MAX_MOVE_DELTA_TIME: number;
14
+ export declare const DEFAULT_MAX_COMBINED_MOVE_DELTA_TIME: number;
15
+ export declare const DEFAULT_MAX_SUBSTEP_DELTA_TIME: number;
16
+ export declare const DEFAULT_MAX_SERVER_MOVE_DELTA_TIME_SCALAR = 1.75;
17
+ export declare const DEFAULT_MAX_CLIENT_TIME_AHEAD = 0.1;
18
+ export declare const DEFAULT_MAX_SERVER_MOVE_TIME_BUDGET = 0.25;
19
+ export declare const DEFAULT_SMALL_CORRECTION_TOLERANCE = 0.08;
20
+ export declare const DEFAULT_LARGE_CORRECTION_THRESHOLD = 1;
21
+ export declare const DEFAULT_TELEPORT_SNAP_THRESHOLD = 5;
22
+ export declare const DEFAULT_SIMULATED_INTERPOLATION_DELAY = 0.1;
23
+ export declare const MOVE_FLAG_JUMP: number;
24
+ export declare const MOVE_FLAG_SPRINT: number;
25
+ export declare const MOVE_FLAG_ROOT_MOTION: number;
26
+ export declare const MOVE_FLAG_SPRINT_START: number;
27
+ export declare const MOVE_FLAG_CROUCH: number;
28
+ export declare const SNAPSHOT_FLAG_CROUCHING: number;
29
+ export type NetCharacterMove = {
30
+ sequence: number;
31
+ clientTime: number;
32
+ dt: number;
33
+ inputX: number;
34
+ inputY: number;
35
+ yaw: number;
36
+ flags: number;
37
+ clientX: number;
38
+ clientY: number;
39
+ clientZ: number;
40
+ rootMotionX: number;
41
+ rootMotionY: number;
42
+ rootMotionZ: number;
43
+ };
44
+ export type NetCharacterMoveBatch = {
45
+ moves: NetCharacterMove[];
46
+ };
47
+ export type NetCharacterMovementSnapshot = {
48
+ sequence: number;
49
+ x: number;
50
+ y: number;
51
+ z: number;
52
+ velocityX: number;
53
+ velocityY: number;
54
+ velocityZ: number;
55
+ yaw: number;
56
+ mode: CharacterMovementMode;
57
+ flags: number;
58
+ horizontalSpeed: number;
59
+ };
60
+ export type NetCharacterOwnerAck = {
61
+ sequence: number;
62
+ };
63
+ export type NetCharacterOwnerCorrection = {
64
+ snapshot: NetCharacterMovementSnapshot;
65
+ };
66
+ export type NetCharacterDecodedPacket<T> = {
67
+ ok: true;
68
+ value: T;
69
+ } | {
70
+ ok: false;
71
+ reason: "malformed" | "unsupported-version" | "wrong-kind";
72
+ };
73
+ export type NetCharacterServerMoveTimingState = {
74
+ lastClientTime: number;
75
+ serverTimeBudget: number;
76
+ };
77
+ export type NetCharacterServerMoveTimingOptions = {
78
+ maxMoveDeltaTime?: number;
79
+ maxServerMoveDeltaTimeScalar?: number;
80
+ maxClientTimeAhead?: number;
81
+ };
82
+ export declare class NetCharacterSavedMoveBuffer {
83
+ capacity: number;
84
+ maxCombinedDeltaTime: number;
85
+ private readonly moves;
86
+ private readonly freeMoves;
87
+ private readonly sendScratch;
88
+ private readonly replayScratch;
89
+ private pending?;
90
+ constructor(capacity?: number, maxCombinedDeltaTime?: number);
91
+ get length(): number;
92
+ push(move: NetCharacterMove): void;
93
+ ack(sequence: number): void;
94
+ clear(): void;
95
+ getMovesForSend(maxCount: number): readonly NetCharacterMove[];
96
+ replayAfter(sequence: number, simulator: (move: NetCharacterMove) => void, maxCount?: number): void;
97
+ private commitPending;
98
+ private trimToCapacity;
99
+ private acquireMove;
100
+ private releaseMove;
101
+ }
102
+ export declare class NetCharacterProxySmoother {
103
+ private readonly interpolationDelay;
104
+ private readonly snapDistance;
105
+ private readonly maxSnapshots;
106
+ private readonly snapshots;
107
+ constructor(interpolationDelay?: number, snapDistance?: number, maxSnapshots?: number);
108
+ push(snapshot: NetCharacterMovementSnapshot, localTime: number): void;
109
+ reset(snapshot?: NetCharacterMovementSnapshot, localTime?: number): void;
110
+ sample(localTime: number, out: NetCharacterMovementSnapshot): boolean;
111
+ }
112
+ export declare function validateNetCharacterMove(move: NetCharacterMove, lastSequence: number, maxDeltaTime?: number): boolean;
113
+ export declare function encodeNetCharacterMoveBatch(moves: readonly NetCharacterMove[]): Uint8Array;
114
+ export declare function decodeNetCharacterMoveBatch(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMoveBatch>;
115
+ export declare function encodeNetCharacterOwnerAck(sequence: number): Uint8Array;
116
+ export declare function decodeNetCharacterOwnerAck(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerAck>;
117
+ export declare function encodeNetCharacterOwnerCorrection(snapshot: NetCharacterMovementSnapshot): Uint8Array;
118
+ export declare function decodeNetCharacterOwnerCorrection(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerCorrection>;
119
+ export declare function encodeNetCharacterSimulatedState(snapshot: NetCharacterMovementSnapshot): Uint8Array;
120
+ export declare function decodeNetCharacterSimulatedState(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMovementSnapshot>;
121
+ export declare function replayNetCharacterSavedMoves<TState>(baseState: TState, moves: readonly NetCharacterMove[], simulator: (state: TState, move: NetCharacterMove) => TState, maxMoves?: number): TState;
122
+ export declare function createNetCharacterServerMoveTimingState(): NetCharacterServerMoveTimingState;
123
+ export declare function accrueNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, serverDeltaTime: number, maxServerMoveTimeBudget?: number): void;
124
+ export declare function consumeNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, move: NetCharacterMove, options?: NetCharacterServerMoveTimingOptions): number;
125
+ export declare function createNetCharacterMovementSnapshot(overrides?: Partial<NetCharacterMovementSnapshot>): NetCharacterMovementSnapshot;
126
+ export declare function isSequenceGreater(a: number, b: number): boolean;
127
+ export declare function isSequenceLessOrEqual(a: number, b: number): boolean;
128
+ //# sourceMappingURL=net-character-movement-protocol.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{MathUtils as t}from"three";import{CharacterMovementMode as e}from"./modes.js";export const NET_CHARACTER_MOVEMENT_VERSION=3;export const MOVE_PACKET_KIND=1;export const OWNER_ACK_PACKET_KIND=2;export const OWNER_CORRECTION_PACKET_KIND=3;export const SIMULATED_STATE_PACKET_KIND=4;export const DEFAULT_MOVE_SEND_INTERVAL=1/30;export const DEFAULT_SIMULATED_STATE_INTERVAL=.05;export const DEFAULT_MAX_SAVED_MOVES=128;export const DEFAULT_MAX_REPLAYED_MOVES=64;export const DEFAULT_MAX_SERVER_MOVES_PER_TICK=4;export const DEFAULT_MAX_MOVES_PER_PACKET=16;export const DEFAULT_MAX_MOVE_DELTA_TIME=1/15;export const DEFAULT_MAX_COMBINED_MOVE_DELTA_TIME=1/15;export const DEFAULT_MAX_SUBSTEP_DELTA_TIME=.017;export const DEFAULT_MAX_SERVER_MOVE_DELTA_TIME_SCALAR=1.75;export const DEFAULT_MAX_CLIENT_TIME_AHEAD=.1;export const DEFAULT_MAX_SERVER_MOVE_TIME_BUDGET=.25;export const DEFAULT_SMALL_CORRECTION_TOLERANCE=.08;export const DEFAULT_LARGE_CORRECTION_THRESHOLD=1;export const DEFAULT_TELEPORT_SNAP_THRESHOLD=5;export const DEFAULT_SIMULATED_INTERPOLATION_DELAY=.1;export const MOVE_FLAG_JUMP=1;export const MOVE_FLAG_SPRINT=2;export const MOVE_FLAG_ROOT_MOTION=4;export const MOVE_FLAG_SPRINT_START=8;export const MOVE_FLAG_CROUCH=16;export const SNAPSHOT_FLAG_CROUCHING=1;const n=.001;export class NetCharacterSavedMoveBuffer{constructor(t=128,e=.06666666666666667){this.capacity=t,this.maxCombinedDeltaTime=e,this.moves=[],this.freeMoves=[],this.sendScratch=[],this.replayScratch={sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0}}get length(){return this.moves.length+(null==this.pending?0:1)}push(e){if(null!=this.pending){if(function(e,o,i=.06666666666666667){if(i<0)return!1;if(s=e.sequence,r=o.sequence,(s>>>0)+1>>>0!=r>>>0)return!1;var s,r;if(e.flags!==o.flags||13&e.flags)return!1;const a=e.clientTime-e.dt,c=o.clientTime-o.dt,h=o.clientTime-a,u=i;if(h<=0||h>u+n)return!1;if(Math.abs(e.clientTime-c)>n)return!1;if(l(e.inputX)!==l(o.inputX)||l(e.inputY)!==l(o.inputY))return!1;return function(e,n){return Math.abs(t.euclideanModulo(n-e+Math.PI,2*Math.PI)-Math.PI)}(e.yaw,o.yaw)<=.001}(this.pending,e,this.maxCombinedDeltaTime))return void function(t,e){const n=t.clientTime-t.dt;t.sequence=e.sequence,t.clientTime=e.clientTime,t.dt=Math.max(.001,e.clientTime-n),t.inputX=e.inputX,t.inputY=e.inputY,t.yaw=e.yaw,t.flags=e.flags,t.clientX=e.clientX,t.clientY=e.clientY,t.clientZ=e.clientZ,t.rootMotionX+=e.rootMotionX,t.rootMotionY+=e.rootMotionY,t.rootMotionZ+=e.rootMotionZ}(this.pending,e);this.commitPending()}this.pending=this.acquireMove(e),this.trimToCapacity()}ack(t){let e=0;for(let n=0;n<this.moves.length;n++)isSequenceLessOrEqual(this.moves[n].sequence,t)&&(e=n+1);if(e>0){for(let t=0;t<e;t++)this.releaseMove(this.moves[t]);this.moves.splice(0,e)}null!=this.pending&&isSequenceLessOrEqual(this.pending.sequence,t)&&(this.releaseMove(this.pending),this.pending=void 0)}clear(){for(let t=0;t<this.moves.length;t++)this.releaseMove(this.moves[t]);this.moves.length=0,null!=this.pending&&this.releaseMove(this.pending),this.pending=void 0,this.sendScratch.length=0}getMovesForSend(t){if(this.commitPending(),this.sendScratch.length=0,t<=0||0===this.moves.length)return this.sendScratch;if(1===t||this.moves.length<=t){for(let e=1===t?this.moves.length-1:0;e<this.moves.length;e++)this.sendScratch.push(this.moves[e]);return this.sendScratch}this.sendScratch.push(this.moves[0]);const e=t-1;for(let t=Math.max(1,this.moves.length-e);t<this.moves.length;t++)this.sendScratch.push(this.moves[t]);return this.sendScratch}replayAfter(t,e,n=64){let o=0;for(let i=0;i<this.moves.length&&o<n;i++){const n=this.moves[i];isSequenceGreater(n.sequence,t)&&(e(s(n,this.replayScratch)),o++)}null!=this.pending&&isSequenceGreater(this.pending.sequence,t)&&o<n&&e(s(this.pending,this.replayScratch))}commitPending(){null!=this.pending&&(this.moves.push(this.pending),this.pending=void 0,this.trimToCapacity())}trimToCapacity(){const t=Math.max(1,Math.floor(this.capacity)),e=this.length-t;if(e>0){for(let t=0;t<e;t++)this.releaseMove(this.moves[t]);this.moves.splice(0,e)}}acquireMove(t){return s(t,this.freeMoves.pop()??{sequence:0,clientTime:0,dt:0,inputX:0,inputY:0,yaw:0,flags:0,clientX:0,clientY:0,clientZ:0,rootMotionX:0,rootMotionY:0,rootMotionZ:0})}releaseMove(t){this.freeMoves.length<Math.max(1,Math.floor(this.capacity))&&this.freeMoves.push(t)}}export class NetCharacterProxySmoother{constructor(t=.1,e=5,n=32){this.interpolationDelay=t,this.snapDistance=e,this.maxSnapshots=n,this.snapshots=[]}push(t,e){const n=function(t){return{...t}}(t);this.snapshots.push({time:e,snapshot:n}),this.snapshots.sort((t,e)=>t.time-e.time),this.snapshots.length>this.maxSnapshots&&this.snapshots.splice(0,this.snapshots.length-this.maxSnapshots)}reset(t,e=0){this.snapshots.length=0,null!=t&&this.push(t,e)}sample(e,n){if(0===this.snapshots.length)return!1;const o=e-this.interpolationDelay,i=this.snapshots[0],s=this.snapshots[this.snapshots.length-1];if(null==i||null==s)return!1;if(o<=i.time||1===this.snapshots.length)return r(i.snapshot,n),!0;if(o>=s.time)return r(s.snapshot,n),!0;for(let e=1;e<this.snapshots.length;e++){const i=this.snapshots[e-1],s=this.snapshots[e];if(null==i||null==s||o>s.time)continue;if(c(i.snapshot,s.snapshot)>this.snapDistance*this.snapDistance)return r(s.snapshot,n),!0;const l=s.time-i.time,h=l>0?t.clamp((o-i.time)/l,0,1):1;return a(i.snapshot,s.snapshot,h,n),!0}return r(s.snapshot,n),!0}}export function validateNetCharacterMove(t,e,n=.06666666666666667){return!!isSequenceGreater(t.sequence,e)&&(!(!Number.isFinite(t.clientTime)||t.clientTime<=0)&&(!(!Number.isFinite(t.dt)||t.dt<=0||t.dt>n)&&(!(!Number.isFinite(t.inputX)||!Number.isFinite(t.inputY))&&(!(t.inputX*t.inputX+t.inputY*t.inputY>1.0001)&&(!(!Number.isInteger(t.flags)||t.flags<0||-32&t.flags)&&(Number.isFinite(t.yaw)&&Number.isFinite(t.clientX)&&Number.isFinite(t.clientY)&&Number.isFinite(t.clientZ)))))))}export function encodeNetCharacterMoveBatch(e){const n=Math.min(65535,e.length),o=new Uint8Array(4+43*n),i=new DataView(o.buffer);let s=0;i.setUint8(s++,3),i.setUint8(s++,1),i.setUint16(s,n,!0),s+=2;for(let o=0;o<n;o++){const n=e[o];i.setUint32(s,n.sequence>>>0,!0),s+=4,i.setUint32(s,t.clamp(Math.round(1e3*n.clientTime),0,4294967295),!0),s+=4,i.setUint16(s,t.clamp(Math.round(1e3*n.dt),1,65535),!0),s+=2,i.setInt16(s,l(n.inputX),!0),s+=2,i.setInt16(s,l(n.inputY),!0),s+=2,i.setFloat32(s,n.yaw,!0),s+=4,i.setUint8(s++,255&n.flags),i.setFloat32(s,n.clientX,!0),s+=4,i.setFloat32(s,n.clientY,!0),s+=4,i.setFloat32(s,n.clientZ,!0),s+=4,i.setFloat32(s,n.rootMotionX,!0),s+=4,i.setFloat32(s,n.rootMotionY,!0),s+=4,i.setFloat32(s,n.rootMotionZ,!0),s+=4}return o}export function decodeNetCharacterMoveBatch(t){if(t.byteLength<4)return{ok:!1,reason:"malformed"};const e=u(t);let n=0;if(3!==e.getUint8(n++))return{ok:!1,reason:"unsupported-version"};if(1!==e.getUint8(n++))return{ok:!1,reason:"wrong-kind"};const o=e.getUint16(n,!0);if(n+=2,t.byteLength!==4+43*o)return{ok:!1,reason:"malformed"};const i=[];for(let t=0;t<o;t++){const t=e.getUint32(n,!0);n+=4;const o=e.getUint32(n,!0)/1e3;n+=4;const s=e.getUint16(n,!0)/1e3;n+=2;const r=h(e.getInt16(n,!0));n+=2;const a=h(e.getInt16(n,!0));n+=2;const c=e.getFloat32(n,!0);n+=4;const l=e.getUint8(n++),u=e.getFloat32(n,!0);n+=4;const p=e.getFloat32(n,!0);n+=4;const m=e.getFloat32(n,!0);n+=4;const g=e.getFloat32(n,!0);n+=4;const f=e.getFloat32(n,!0);n+=4;const M=e.getFloat32(n,!0);n+=4,i.push({sequence:t,clientTime:o,dt:s,inputX:r,inputY:a,yaw:c,flags:l,clientX:u,clientY:p,clientZ:m,rootMotionX:g,rootMotionY:f,rootMotionZ:M})}return{ok:!0,value:{moves:i}}}export function encodeNetCharacterOwnerAck(t){const e=new Uint8Array(6),n=new DataView(e.buffer);return n.setUint8(0,3),n.setUint8(1,2),n.setUint32(2,t>>>0,!0),e}export function decodeNetCharacterOwnerAck(t){if(6!==t.byteLength)return{ok:!1,reason:"malformed"};const e=u(t);return 3!==e.getUint8(0)?{ok:!1,reason:"unsupported-version"}:2!==e.getUint8(1)?{ok:!1,reason:"wrong-kind"}:{ok:!0,value:{sequence:e.getUint32(2,!0)}}}export function encodeNetCharacterOwnerCorrection(t){return o(3,t)}export function decodeNetCharacterOwnerCorrection(t){const e=i(t,3);return!1===e.ok?{ok:!1,reason:e.reason}:{ok:!0,value:{snapshot:e.value}}}export function encodeNetCharacterSimulatedState(t){return o(4,t)}export function decodeNetCharacterSimulatedState(t){return i(t,4)}export function replayNetCharacterSavedMoves(t,e,n,o=64){let i=t;const s=Math.min(o,e.length);for(let t=0;t<s;t++)i=n(i,e[t]);return i}export function createNetCharacterServerMoveTimingState(){return{lastClientTime:0,serverTimeBudget:0}}export function accrueNetCharacterServerMoveTime(t,e,n=.25){!Number.isFinite(e)||e<=0||(t.serverTimeBudget=Math.min(n,t.serverTimeBudget+e))}export function consumeNetCharacterServerMoveTime(t,e,n={}){if(!Number.isFinite(e.clientTime))return-1;const o=e.clientTime-t.lastClientTime;if(!Number.isFinite(o)||o<=0)return-1;const i=n.maxMoveDeltaTime??.06666666666666667,s=Math.max(1,n.maxServerMoveDeltaTimeScalar??1.75),r=n.maxClientTimeAhead??.1,a=Math.max(.001,i*s),c=Math.min(o,a),l=t.serverTimeBudget-c;return l<-r?-1:(t.serverTimeBudget=l,t.lastClientTime=e.clientTime,Math.max(.001,c))}export function createNetCharacterMovementSnapshot(t={}){return{sequence:0,x:0,y:0,z:0,velocityX:0,velocityY:0,velocityZ:0,yaw:0,mode:e.walking,flags:0,horizontalSpeed:0,...t}}export function isSequenceGreater(t,e){return t-e>>>0<2147483648&&t!==e}export function isSequenceLessOrEqual(t,e){return t===e||!isSequenceGreater(t,e)}function o(t,e){const n=new Uint8Array(41),o=new DataView(n.buffer);let i=0;return o.setUint8(i++,3),o.setUint8(i++,t),o.setUint32(i,e.sequence>>>0,!0),i+=4,o.setFloat32(i,e.x,!0),i+=4,o.setFloat32(i,e.y,!0),i+=4,o.setFloat32(i,e.z,!0),i+=4,o.setFloat32(i,e.velocityX,!0),i+=4,o.setFloat32(i,e.velocityY,!0),i+=4,o.setFloat32(i,e.velocityZ,!0),i+=4,o.setFloat32(i,e.yaw,!0),i+=4,o.setUint8(i++,e.mode),o.setUint8(i++,255&e.flags),o.setFloat32(i,e.horizontalSpeed,!0),n}function i(t,e){if(41!==t.byteLength)return{ok:!1,reason:"malformed"};const n=u(t);let o=0;if(3!==n.getUint8(o++))return{ok:!1,reason:"unsupported-version"};if(n.getUint8(o++)!==e)return{ok:!1,reason:"wrong-kind"};const i=n.getUint32(o,!0);o+=4;const s=n.getFloat32(o,!0);o+=4;const r=n.getFloat32(o,!0);o+=4;const a=n.getFloat32(o,!0);o+=4;const c=n.getFloat32(o,!0);o+=4;const l=n.getFloat32(o,!0);o+=4;const h=n.getFloat32(o,!0);o+=4;const p=n.getFloat32(o,!0);o+=4;return{ok:!0,value:{sequence:i,x:s,y:r,z:a,velocityX:c,velocityY:l,velocityZ:h,yaw:p,mode:n.getUint8(o++),flags:n.getUint8(o++),horizontalSpeed:n.getFloat32(o,!0)}}}function s(t,e){return e.sequence=t.sequence,e.clientTime=t.clientTime,e.dt=t.dt,e.inputX=t.inputX,e.inputY=t.inputY,e.yaw=t.yaw,e.flags=t.flags,e.clientX=t.clientX,e.clientY=t.clientY,e.clientZ=t.clientZ,e.rootMotionX=t.rootMotionX,e.rootMotionY=t.rootMotionY,e.rootMotionZ=t.rootMotionZ,e}function r(t,e){e.sequence=t.sequence,e.x=t.x,e.y=t.y,e.z=t.z,e.velocityX=t.velocityX,e.velocityY=t.velocityY,e.velocityZ=t.velocityZ,e.yaw=t.yaw,e.mode=t.mode,e.flags=t.flags,e.horizontalSpeed=t.horizontalSpeed}function a(e,n,o,i){i.sequence=n.sequence,i.x=t.lerp(e.x,n.x,o),i.y=t.lerp(e.y,n.y,o),i.z=t.lerp(e.z,n.z,o),i.velocityX=t.lerp(e.velocityX,n.velocityX,o),i.velocityY=t.lerp(e.velocityY,n.velocityY,o),i.velocityZ=t.lerp(e.velocityZ,n.velocityZ,o),i.yaw=e.yaw+(t.euclideanModulo(n.yaw-e.yaw+Math.PI,2*Math.PI)-Math.PI)*o,i.mode=o<1?e.mode:n.mode,i.flags=o<1?e.flags:n.flags,i.horizontalSpeed=t.lerp(e.horizontalSpeed,n.horizontalSpeed,o)}function c(t,e){const n=t.x-e.x,o=t.y-e.y,i=t.z-e.z;return n*n+o*o+i*i}function l(e){return t.clamp(Math.round(32767*t.clamp(e,-1,1)),-32767,32767)}function h(e){return t.clamp(e/32767,-1,1)}function u(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}/*
2
+ * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
+ * See the LICENSE.md file for details.
4
+ */
@@ -0,0 +1,100 @@
1
+ import * as THREE from 'three';
2
+ import { AnimationAction, Vector3 } from 'three';
3
+ import { ActionInput, AxisInput, RotationInput } from '../../../../../gameplay/input/index.js';
4
+ import { ActorComponent } from '../../../component.js';
5
+ import { CharacterMovementMode } from './modes.js';
6
+ export declare class OldCharacterMovementComponent extends ActorComponent {
7
+ readonly directionInput: AxisInput;
8
+ readonly jumpInput: ActionInput;
9
+ readonly sprintInput: ActionInput;
10
+ readonly rotationInput: RotationInput;
11
+ horizontalSpeed: number;
12
+ maxSpeed: number;
13
+ maxSpeedBackwards: number;
14
+ maxSpeedSprint: number;
15
+ jumpVelocity: number;
16
+ fallingMovementControl: number;
17
+ fallingReorientation: boolean;
18
+ gravityOverride: number;
19
+ colliderHeight: number;
20
+ colliderRadius: number;
21
+ jumpInAir: boolean;
22
+ mass: number;
23
+ allowSliding: boolean;
24
+ minSlopeSlideAngle: number;
25
+ maxSlopeClimbAngle: number;
26
+ applyImpulsesToDynamicBodies: boolean;
27
+ normalizedDirection: boolean;
28
+ /** Collide with other characters */
29
+ characterCollision: boolean;
30
+ allowRootMotionJumpCancel: boolean;
31
+ get autoStepMinWidth(): number;
32
+ set autoStepMinWidth(minWidth: number);
33
+ get autoStepDynamicObjects(): boolean;
34
+ set autoStepDynamicObjects(enabled: boolean);
35
+ get autoStepMaxHeight(): number;
36
+ set autoStepMaxHeight(maxHeight: number);
37
+ get snapToGround(): number;
38
+ set snapToGround(distance: number);
39
+ set offset(distance: number);
40
+ get offset(): number;
41
+ set normalNudgeFactor(factor: number);
42
+ get normalNudgeFactor(): number;
43
+ /**
44
+ * Flag for if it should be moving the character.
45
+ * Can be useful to turn of if under certain circumstances the all
46
+ * inputs should be ignored.
47
+ */
48
+ enabled: boolean;
49
+ readonly velocity: THREE.Vector3;
50
+ mode: CharacterMovementMode;
51
+ isSprinting: boolean;
52
+ pressedJump: boolean;
53
+ private cc;
54
+ private rayTestResult;
55
+ private physicsSystem;
56
+ constructor();
57
+ private resetRootMotion;
58
+ private rootMotionInterpolant;
59
+ private rootMotionRootBone;
60
+ private rootMotionOptions;
61
+ /**
62
+ * Makes the character rotate to the direction of movement input instead
63
+ * of strafing or walking backwards
64
+ */
65
+ rotateToMovementDirection: boolean;
66
+ /** Makes the character rotate smoothly to the desired direction */
67
+ smoothRotation: boolean;
68
+ rotationSpeed: number;
69
+ maxRotationSpeed: number;
70
+ private impulse;
71
+ /**
72
+ * The damping factor used to slow down impulses over time
73
+ */
74
+ impulseDamping: number;
75
+ onInit(): void | Promise<void>;
76
+ /**
77
+ * Add an instant velocity to the character which can be used to
78
+ * launch the character or push it.
79
+ * @param impulse
80
+ */
81
+ applyImpulse(impulse: Vector3): void;
82
+ private debugDirection;
83
+ private rootMotionAction;
84
+ setRootMotionAction(action: AnimationAction, options?: RootMotionActionOptions): void;
85
+ private clearRootMotionAction;
86
+ private getWallDirection;
87
+ private moveTo;
88
+ getEffectiveGravity(): number;
89
+ private checkGrounded;
90
+ get isGrounded(): boolean;
91
+ private createCollisionShape;
92
+ private step;
93
+ private performMovement;
94
+ private arrowHelper;
95
+ }
96
+ export type RootMotionActionOptions = {
97
+ cancelWithJump?: boolean;
98
+ onJumpCancel?: () => void;
99
+ };
100
+ //# sourceMappingURL=old-character-movement.d.ts.map
@@ -0,0 +1,4 @@
1
+ import{__decorate as t,__metadata as o}from"tslib";import i from"@dimforge/rapier3d-simd-compat";import{takeUntil as e}from"rxjs";import*as s from"three";import{ArrowHelper as n,MathUtils as r,Vector3 as a}from"three";import{RootMotionClip as c}from"../../../../../gameplay/animation/root-motion.js";import{ActionInput as h,AxisInput as l,RotationInput as p}from"../../../../../gameplay/input/index.js";import{PhysicsSystem as m,RayTestResult as u}from"../../../../../gameplay/services/physics/physics-system.js";import{CapsuleCollisionShape as d}from"../../../../../scene/collision/collision-shape.js";import{PhysicsBodyType as y}from"../../../../services/physics/physics-system.js";import{ActorComponent as g,Component as f}from"../../../component.js";import{CharacterMovementMode as M}from"./modes.js";import{inject as S}from"../../../../../gameplay/inject.js";import{Parameter as v}from"../../../../../shader/parameter.js";const w=new a,x=new a,A=1/30,b=131070;let I=class extends g{get autoStepMinWidth(){return this.cc.autostepMinWidth()}set autoStepMinWidth(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),t,this.cc.autostepIncludesDynamicBodies())}get autoStepDynamicObjects(){return this.cc.autostepIncludesDynamicBodies()}set autoStepDynamicObjects(t){this.cc.enableAutostep(this.cc.autostepMaxHeight(),this.cc.autostepMinWidth(),t)}get autoStepMaxHeight(){return this.cc.autostepMaxHeight()}set autoStepMaxHeight(t){this.cc.enableAutostep(t,this.cc.autostepMinWidth(),this.cc.autostepIncludesDynamicBodies())}get snapToGround(){return this.cc.snapToGroundDistance()}set snapToGround(t){this.cc.enableSnapToGround(t)}set offset(t){this.cc.setOffset(t)}get offset(){return this.cc.offset()}set normalNudgeFactor(t){this.cc.setNormalNudgeFactor(t)}get normalNudgeFactor(){return this.cc.normalNudgeFactor()}constructor(){super(),this.directionInput=new l,this.jumpInput=new h,this.sprintInput=new h,this.rotationInput=new p,this.horizontalSpeed=0,this.maxSpeed=8,this.maxSpeedBackwards=8,this.maxSpeedSprint=12,this.jumpVelocity=7,this.fallingMovementControl=.5,this.fallingReorientation=!1,this.gravityOverride=null,this.colliderHeight=2,this.colliderRadius=.5,this.jumpInAir=!1,this.mass=50,this.allowSliding=!0,this.minSlopeSlideAngle=r.degToRad(70),this.maxSlopeClimbAngle=r.degToRad(70),this.applyImpulsesToDynamicBodies=!0,this.normalizedDirection=!0,this.characterCollision=!1,this.allowRootMotionJumpCancel=!1,this.enabled=!0,this.velocity=new a,this.mode=M.walking,this.isSprinting=!1,this.pressedJump=!1,this.rayTestResult=new u,this.physicsSystem=S(m),this.resetRootMotion=!1,this.rootMotionOptions={},this.rotateToMovementDirection=!1,this.smoothRotation=!0,this.rotationSpeed=40,this.maxRotationSpeed=100,this.impulse=new a,this.impulseDamping=2;const t=this.cc=this.physicsSystem.getCharacterController(.1);t.enableSnapToGround(.1),t.enableAutostep(0,.1,!1)}onInit(){const t=this.cc;t.setApplyImpulsesToDynamicBodies(this.applyImpulsesToDynamicBodies),t.setMinSlopeSlideAngle(this.minSlopeSlideAngle),t.setMaxSlopeClimbAngle(this.maxSlopeClimbAngle),t.setCharacterMass(this.mass),t.setSlideEnabled(this.allowSliding),this.physicsSystem.addActor(this.actor,[this.createCollisionShape()],{mass:0,type:y.kinematic,continousCollisionDetection:!1,friction:0,restitution:.5,ignoreForNavMesh:!0}),this.rotationInput.rotation.copy(this.actor.rotation);let o=this.rotationInput.rotation.y;const i=new a,n=new a,h=new a,l=new a,p=new a,m=new a,u=new a;let d=0,g=null;const f=new a,S=new a,v=new a,I=new a,R=new a,z=new a,C=new a,D=this.characterCollision?null:b;let E=this.rotateToMovementDirection;this.physicsSystem.beforeStep.pipe(e(this.disposed)).subscribe(e=>{if(this.checkGrounded(e),!this.enabled)return;if(S.set(0,0,0),null==this.rootMotionAction||this.rootMotionAction.isRunning()||this.clearRootMotionAction(this.rootMotionAction),null!=this.rootMotionAction&&this.rootMotionOptions.cancelWithJump&&this.jumpInput.activated&&(this.isGrounded||this.jumpInAir)){const t=this.rootMotionAction,o=this.rootMotionOptions.onJumpCancel;this.clearRootMotionAction(t),t.stop(),o?.()}if(null!=this.rootMotionAction){if(this.rootMotionAction.getClip()instanceof c){const t=this.rootMotionInterpolant;this.resetRootMotion&&(f.fromArray(t.evaluate(0)),this.resetRootMotion=!1),z.fromArray(t.evaluate(this.rootMotionAction.time)),S.subVectors(z,f),f.copy(z);(this.rootMotionRootBone??this.rootMotionAction.getRoot()).getWorldScale(R),S.multiply(R)}}e>A&&(e=A);const y=null!=this.rootMotionAction&&this.rootMotionAction.enabled,b=y&&0!==S.lengthSq();this.pressedJump=!y&&this.jumpInput.activated,this.isSprinting=!y&&this.sprintInput.activated;const H=E!==this.rotateToMovementDirection;let B=r.euclideanModulo(this.rotationInput.rotation.y-o+Math.PI,2*Math.PI)-Math.PI;H&&(this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)),E?this.actor.object.quaternion.setFromEuler(F.set(0,this.rotationInput.rotation.y,0)):(B=0,o=this.rotationInput.rotation.y),E=this.rotateToMovementDirection),h.copy(this.actor.position),l.set(-this.directionInput.vector.x,0,this.directionInput.vector.y).normalize();const N=!this.rotateToMovementDirection&&l.z<0?this.maxSpeedBackwards:(this.isSprinting?this.maxSpeedSprint:this.maxSpeed)*(this.normalizedDirection?1:Math.min(1,this.directionInput.vector.length()));if(u.set(0,0,0),y)o=this.rotationInput.rotation.y;else if(this.rotateToMovementDirection&&!y){if(l.lengthSq()>0&&this.mode!=M.falling){const t=this.smoothRotation,i=F.setFromQuaternion(this.actor.object.quaternion,"YXZ").y,s=Math.atan2(l.x,l.z),n=.99*this.rotationInput.rotation.y+s;if(t){r.clamp(.5*l.dot(p)+.5,.001,1);const t=r.euclideanModulo(n-i+Math.PI,2*Math.PI)-Math.PI;let o=r.clamp(t*this.rotationSpeed*e,-this.maxRotationSpeed*e,this.maxRotationSpeed*e);Math.abs(o)>Math.abs(t)&&(o=t),this.actor.object.quaternion.setFromEuler(F.set(0,i+o,0))}else this.actor.object.quaternion.setFromEuler(F.set(0,n,0));p.lerp(l,e*this.rotationSpeed),o+=B,u.copy(this.actor.object.getWorldDirection(k).normalize())}}else b||(o+=B,this.actor.object.quaternion.multiply(q.setFromEuler(F.set(0,B,0))),l.lengthSq()>0&&u.copy(l).applyQuaternion(this.actor.object.quaternion).normalize());if(C.set(0,0,0),this.rayTestResult.hasHit&&null!=this.rayTestResult.actor&&this.physicsSystem.getLinearVelocity(this.rayTestResult.actor,C),this.mode===M.walking?(0!==u.lengthSq()?(d=Math.min(N,d),d=r.lerp(d,N,4*e)):d=0,m.copy(u).multiplyScalar(d),this.pressedJump&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),m.y=e*this.getEffectiveGravity(),m.add(C)):this.mode===M.falling&&(this.pressedJump&&this.jumpInAir&&(this.mode=M.falling,this.velocity.copy(m),this.velocity.y=this.jumpVelocity),this.velocity.y+=e*this.getEffectiveGravity(),m.copy(this.velocity),m.addScaledVector(u,this.fallingMovementControl),this.fallingReorientation&&m.applyAxisAngle(new a(0,1,0),B)),b&&(v.copy(S).applyQuaternion(this.actor.quaternion),I.copy(v).divideScalar(e),this.mode===M.walking?(m.x=I.x+C.x,m.z=I.z+C.z):(m.x=I.x,m.z=I.z),l.lengthSq()>0)){const t=Math.sqrt(I.x*I.x+I.z*I.z);t>.4&&(d=t)}if(this.impulse.lengthSq()>.1){const t=Math.min(1,this.impulse.length()/5);m.x=r.lerp(m.x,this.impulse.x,t),m.z=r.lerp(m.z,this.impulse.z,t),m.y+=this.impulse.y;const o=Math.exp(-this.impulseDamping*e);this.impulse.x*=o,this.impulse.y>0?this.impulse.y+=e*this.getEffectiveGravity():this.impulse.y*=o,this.impulse.z*=o}else this.impulse.set(0,0,0);if(n.copy(m).normalize(),i.copy(m),m.length()>0||!this.isGrounded){if(w.copy(m).multiplyScalar(e),this.isGrounded&&this.mode===M.walking&&(this.rayTestResult.distance>t.offset()||(w.y=Math.max(0,C.y*e)),this.physicsSystem.getActorComputedMovement(this.actor,t,w,D),t.computedCollision(0,G),null!=G&&null!=G.normal1)){const o=(new s.Vector3).copy(G.normal1);Math.acos(o.dot(T))>t.maxSlopeClimbAngle()&&(w.y=.016*this.getEffectiveGravity()*.5)}x.copy(this.physicsSystem.getActorComputedMovement(this.actor,t,w,D))}else x.set(0,0,0);this.physicsSystem.setNextKinematicTranslation(this.actor,x);let O=function(t){if(t.numComputedCollisions()>0){const o=t.computedCollision(0);j.x=o.normal2.x,j.y=o.normal2.y,j.z=o.normal2.z;const i=j.angleTo(T);j.x=o.normal1.x,j.y=o.normal1.y,j.z=o.normal1.z;const e=j.angleTo(T);return!(i<100)&&e>t.minSlopeSlideAngle()}return!1}(t);this.isGrounded&&!O||this.mode!==M.falling&&(null==g?g=performance.now():performance.now()-g>100&&(this.mode=M.falling,this.velocity.copy(i))),this.isGrounded&&this.velocity.y<=0&&(this.mode,M.falling,this.mode=M.walking,this.velocity.y=0,g=null),this.mode,M.walking,this.horizontalSpeed=d})}applyImpulse(t){this.impulse.add(t)}debugDirection(){const t=new n(w,this.actor.position,1,65280);this.actor.object.parent.add(t),setTimeout(()=>{t.removeFromParent()},30);const o=new n(x,this.actor.position,1,16711680);this.actor.object.parent.add(o),setTimeout(()=>{o.removeFromParent()},30)}setRootMotionAction(t,o={}){const i=t?.getClip();if(i instanceof c){this.rootMotionAction=t,this.rootMotionOptions=o,this.resetRootMotion=!0;const e=[];this.rootMotionInterpolant=i.motionTrack.InterpolantFactoryMethodSmooth(e);const n=s.PropertyBinding.parseTrackName(i.motionTrack.name);this.rootMotionRootBone=this.actor.object.getObjectByName(n.nodeName)}}clearRootMotionAction(t){null!=t&&this.rootMotionAction!==t||(this.rootMotionAction=null,this.rootMotionOptions={},this.resetRootMotion=!1)}getWallDirection(t,o){const i=t.clone().negate().cross(T);return i.dot(o)<0?i.negate():i}moveTo(t){this.actor.position.copy(t),this.physicsSystem.updateActorTransform(this.actor)}getEffectiveGravity(){return this.gravityOverride??this.physicsSystem.getGravity().y}checkGrounded(t){this.colliderHeight,this.colliderRadius;D.y=-.05,this.physicsSystem.rayTest(R.addVectors(this.actor.position,C.set(0,this.offset,0)),z.addVectors(this.actor.position,D),this.rayTestResult,{excludeActor:this.actor,excludeTriggers:!0})}get isGrounded(){return this.rayTestResult.hasHit||this.cc.computedGrounded()}createCollisionShape(){const t=new d(this.colliderHeight,this.colliderRadius);return t.offset.y=this.colliderRadius+this.colliderHeight/2+this.offset,t.collisionGroup=b,t}step(t){}performMovement(t){}arrowHelper(t,o,i){const e=new n(t.clone().normalize(),o,1,i);this.actor.object.parent.add(e),setTimeout(()=>{e.removeFromParent()},30)}};t([v(),o("design:type",Number)],I.prototype,"colliderHeight",void 0),t([v(),o("design:type",Number)],I.prototype,"colliderRadius",void 0),I=t([f({inEditor:!1}),o("design:paramtypes",[])],I);export{I as OldCharacterMovementComponent};const T=new a(0,1,0),j=new a;const R=new a,z=new a,C=new a(0,1,0),D=new a(0,-.1,0),G=(new a(0,-1,0),new i.CharacterCollision),q=new s.Quaternion,F=new s.Euler,k=new s.Vector3;/*
2
+ * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
+ * See the LICENSE.md file for details.
4
+ */
@@ -1,4 +1,5 @@
1
1
  import { MeshComponent } from './mesh-component.js';
2
+ import { OldCharacterMovementComponent } from './character/old-character-movement.js';
2
3
  import { CharacterMovementComponent } from './character/character-movement.js';
3
4
  import { CharacterAnimationComponent } from './character/character-animation.js';
4
5
  import { TweenComponent } from './tween-component.js';
@@ -10,6 +11,7 @@ import { ThirdPersonCameraComponent } from '../../camera/third-person-camera-com
10
11
  export declare const builtInComponents: {
11
12
  MeshComponent: typeof MeshComponent;
12
13
  TweenComponent: typeof TweenComponent;
14
+ OldCharacterMovementComponent: typeof OldCharacterMovementComponent;
13
15
  CharacterMovementComponent: typeof CharacterMovementComponent;
14
16
  CharacterAnimationComponent: typeof CharacterAnimationComponent;
15
17
  TriggerVolumeComponent: typeof TriggerVolumeComponent;
@@ -1,4 +1,4 @@
1
- import{MeshComponent as o}from"./mesh-component.js";import{CharacterMovementComponent as r}from"./character/character-movement.js";import{CharacterAnimationComponent as e}from"./character/character-animation.js";import{TweenComponent as m}from"./tween-component.js";import{TriggerVolumeComponent as n}from"../trigger-volume.js";import{PositionalAudioComponent as t}from"../positional-audio-actor.js";import{CameraComponent as a}from"../../camera/camera-component.js";import{FirstPersonCameraComponent as p}from"../../camera/first-person-camera-component.js";import{ThirdPersonCameraComponent as i}from"../../camera/third-person-camera-component.js";export const builtInComponents={MeshComponent:o,TweenComponent:m,CharacterMovementComponent:r,CharacterAnimationComponent:e,TriggerVolumeComponent:n,PositionalAudioComponent:t,CameraComponent:a,FirstPersonCameraComponent:p,ThirdPersonCameraComponent:i};export default builtInComponents;/*
1
+ import{MeshComponent as o}from"./mesh-component.js";import{OldCharacterMovementComponent as r}from"./character/old-character-movement.js";import{CharacterMovementComponent as e}from"./character/character-movement.js";import{CharacterAnimationComponent as m}from"./character/character-animation.js";import{TweenComponent as t}from"./tween-component.js";import{TriggerVolumeComponent as n}from"../trigger-volume.js";import{PositionalAudioComponent as a}from"../positional-audio-actor.js";import{CameraComponent as p}from"../../camera/camera-component.js";import{FirstPersonCameraComponent as c}from"../../camera/first-person-camera-component.js";import{ThirdPersonCameraComponent as i}from"../../camera/third-person-camera-component.js";export const builtInComponents={MeshComponent:o,TweenComponent:t,OldCharacterMovementComponent:r,CharacterMovementComponent:e,CharacterAnimationComponent:m,TriggerVolumeComponent:n,PositionalAudioComponent:a,CameraComponent:p,FirstPersonCameraComponent:c,ThirdPersonCameraComponent:i};export default builtInComponents;/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -16,6 +16,7 @@ export declare class MeshComponent<TObj extends Object3D = Object3D> extends Act
16
16
  private currentMesh;
17
17
  private physicsSystem;
18
18
  onInit(): void | Promise<void>;
19
+ applySceneParameters(parameters: Record<string, unknown>, changedParameters: ReadonlySet<string>): boolean;
19
20
  setObject(replacement: TObj): void;
20
21
  private updateMesh;
21
22
  private getCollisionShapes;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as i}from"tslib";import{PhysicsBodyType as e,PhysicsSystem as o}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as s}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as r}from"../../../../scene/collision/collision-shape.js";import{Parameter as n}from"../../../../shader/parameter.js";import{Euler as h,Object3D as c,Vector3 as l}from"three";import{ActorComponent as p,Component as a}from"../../component.js";import{firstValueFrom as y}from"rxjs";import{inject as u}from"../../../../gameplay/inject.js";let d=null;let m=class extends p{constructor(){super(...arguments),this.position=new l,this.rotation=new h,this.scale=new l(1,1,1),this.collision=!0,this.bodyType=2,this.mass=0,this.friction=.1,this.restitution=1,this.isTrigger=!1,this.continousCollisionDetection=!1,this.physicsSystem=u(o)}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();this.collision&&t.length>0&&this.physicsSystem.addActor(this.actor,t,{...(null===d&&(d={friction:.1,mass:0,restitution:1,bodyType:e.static,continousCollisionDetection:!1}),d),isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection,restitution:this.restitution}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof s?this.currentMesh.collisionShapes:this.currentMesh instanceof r?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([n({type:c,label:"Model"}),i("design:type",Object)],m.prototype,"object",void 0),t([n(),i("design:type",l)],m.prototype,"position",void 0),t([n(),i("design:type",h)],m.prototype,"rotation",void 0),t([n(),i("design:type",l)],m.prototype,"scale",void 0),t([n({help:"Whether this mesh should have collision and/or physics simulation"}),i("design:type",Boolean)],m.prototype,"collision",void 0),t([n({requires:{collision:!0},options:[{name:"Static",value:2},{name:"Kinematic",value:4},{name:"Dynamic",value:1}]}),i("design:type",Number)],m.prototype,"bodyType",void 0),t([n({help:"Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],m.prototype,"mass",void 0),t([n({help:"How much it slows down when touching other objects. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],m.prototype,"friction",void 0),t([n({help:"Control how much to bounce. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],m.prototype,"restitution",void 0),t([n({requires:{collision:!0}}),i("design:type",Boolean)],m.prototype,"isTrigger",void 0),m=t([a({inEditor:!0})],m);export{m as MeshComponent};/*
1
+ import{__decorate as t,__metadata as i}from"tslib";import{PhysicsBodyType as e,PhysicsSystem as o}from"../../../../gameplay/services/physics/physics-system.js";import{AssetMeshInstance as s}from"../../../../scene/asset-resource-loader.js";import{PhysicalShapeMesh as n}from"../../../../scene/collision/collision-shape.js";import{Parameter as r}from"../../../../shader/parameter.js";import{Euler as c,Object3D as h,Vector3 as p}from"three";import{ActorComponent as l,Component as a}from"../../component.js";import{firstValueFrom as y}from"rxjs";import{inject as u}from"../../../../gameplay/inject.js";let m=null;let d=class extends l{constructor(){super(...arguments),this.position=new p,this.rotation=new c,this.scale=new p(1,1,1),this.collision=!0,this.bodyType=2,this.mass=0,this.friction=.1,this.restitution=1,this.isTrigger=!1,this.continousCollisionDetection=!1,this.physicsSystem=u(o)}onInit(){null!=this.object&&(this.currentMesh=this.object,this.updateMesh()),y(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}applySceneParameters(t,i){return!(!this.currentMesh||1!==i.size)&&(i.has("position")&&t.position instanceof p?(this.currentMesh.position.copy(t.position),!0):i.has("rotation")&&t.rotation instanceof c?(this.currentMesh.rotation.copy(t.rotation),!0):!!(i.has("scale")&&t.scale instanceof p)&&(this.currentMesh.scale.copy(t.scale),!0))}setObject(t){null!=this.currentMesh&&this.actor.object.remove(this.currentMesh),this.object=this.currentMesh=t,this.updateMesh()}updateMesh(){this.currentMesh.position.copy(this.position),this.currentMesh.rotation.copy(this.rotation),this.currentMesh.scale.copy(this.scale);const t=this.getCollisionShapes();this.collision&&t.length>0&&this.physicsSystem.addActor(this.actor,t,{...(null===m&&(m={friction:.1,mass:0,restitution:1,bodyType:e.static,continousCollisionDetection:!1}),m),isTrigger:this.isTrigger??!1,mass:this.mass,friction:this.friction,type:this.bodyType,continousCollisionDetection:this.continousCollisionDetection,restitution:this.restitution}),this.actor.object.add(this.currentMesh)}getCollisionShapes(){return this.currentMesh instanceof s?this.currentMesh.collisionShapes:this.currentMesh instanceof n?[this.currentMesh.collisionShape]:"collisionShape"in this.currentMesh?(console.error("Could not understand wehre to get collision shapes from. This is likely due to an import issue"),[this.currentMesh.collisionShape]):[]}};t([r({type:h,label:"Model"}),i("design:type",Object)],d.prototype,"object",void 0),t([r(),i("design:type",p)],d.prototype,"position",void 0),t([r(),i("design:type",c)],d.prototype,"rotation",void 0),t([r(),i("design:type",p)],d.prototype,"scale",void 0),t([r({help:"Whether this mesh should have collision and/or physics simulation"}),i("design:type",Boolean)],d.prototype,"collision",void 0),t([r({requires:{collision:!0},options:[{name:"Static",value:2},{name:"Kinematic",value:4},{name:"Dynamic",value:1}]}),i("design:type",Number)],d.prototype,"bodyType",void 0),t([r({help:"Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"mass",void 0),t([r({help:"How much it slows down when touching other objects. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"friction",void 0),t([r({help:"Control how much to bounce. Only for dynamic objects.",requires:{collision:!0,bodyType:1}}),i("design:type",Number)],d.prototype,"restitution",void 0),t([r({requires:{collision:!0}}),i("design:type",Boolean)],d.prototype,"isTrigger",void 0),d=t([a({inEditor:!0})],d);export{d as MeshComponent};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as i}from"tslib";import{Euler as e,Vector3 as o}from"three";import{Subject as s}from"rxjs";import{ActorComponent as a,Component as n}from"../../component.js";import{Parameter as h}from"../../../../shader/parameter.js";import{Curve2 as r}from"../../../../utils/curve.js";import{inject as l}from"../../../../gameplay/inject.js";import{PhysicsSystem as p}from"../../../../gameplay/services/physics/physics-system.js";let d=class extends a{constructor(){super(...arguments),this.animatePosition=!1,this.targetPosition=new o(0,1,0),this.animateRotation=!1,this.targetRotation=new o(0,0,0),this.animateScale=!1,this.targetScale=new o(1,1,1),this.duration=1,this.delay=0,this.easing=r.linear(),this.relative=!0,this.loop=!1,this.pingPong=!1,this.autoPlay=!0,this.inEditor=!1,this.onComplete=new s,this.onLoop=new s,this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.delayRemaining=0,this.direction=1,this.loopCount=0,this.startPosition=new o,this.startRotation=new e,this.startScale=new o,this.endPosition=new o,this.endRotation=new e,this.endScale=new o,this.physics=l(p)}onInit(){this.autoPlay&&this.inEditor&&this.play()}onBeginPlay(){this.autoPlay&&!this.inEditor&&this.play()}onEndPlay(){this.onComplete.complete(),this.onLoop.complete()}play(){this.isPlaying&&!this.isPaused||(this.isPlaying||(this.captureStartValues(),this.computeEndValues(),this.elapsed=0,this.delayRemaining=this.delay,this.direction=1,this.loopCount=0),this.isPlaying=!0,this.isPaused=!1,this.physics.updateActorTransform(this.actor))}pause(){this.isPaused=!0}stop(){this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.applyValues(0)}reverse(){this.direction*=-1}restart(){this.stop(),this.play()}get progress(){return this.duration>0?this.elapsed/this.duration:0}get playing(){return this.isPlaying&&!this.isPaused}onUpdate(t){if(!this.isPlaying||this.isPaused)return;if(this.delayRemaining>0)return void(this.delayRemaining-=t);this.elapsed+=t*this.direction,this.elapsed>=this.duration?(this.elapsed=this.duration,this.handleComplete()):this.elapsed<=0&&(this.elapsed=0,this.handleComplete());const i=this.elapsed/this.duration,e=this.easing.getY(i);this.applyValues(e)}captureStartValues(){this.startPosition.copy(this.actor.position),this.startRotation.copy(this.actor.rotation),this.startScale.copy(this.actor.object.scale)}computeEndValues(){if(this.animatePosition&&(this.relative?this.endPosition.copy(this.startPosition).add(this.targetPosition):this.endPosition.copy(this.targetPosition)),this.animateRotation){const t=new o(this.targetRotation.x*Math.PI/180,this.targetRotation.y*Math.PI/180,this.targetRotation.z*Math.PI/180);this.relative?this.endRotation.set(this.startRotation.x+t.x,this.startRotation.y+t.y,this.startRotation.z+t.z):this.endRotation.set(t.x,t.y,t.z)}this.animateScale&&(this.relative?this.endScale.set(this.startScale.x*this.targetScale.x,this.startScale.y*this.targetScale.y,this.startScale.z*this.targetScale.z):this.endScale.copy(this.targetScale))}applyValues(t){this.animatePosition&&this.actor.position.lerpVectors(this.startPosition,this.endPosition,t),this.animateRotation&&this.actor.rotation.set(this.startRotation.x+(this.endRotation.x-this.startRotation.x)*t,this.startRotation.y+(this.endRotation.y-this.startRotation.y)*t,this.startRotation.z+(this.endRotation.z-this.startRotation.z)*t),this.animateScale&&this.actor.object.scale.lerpVectors(this.startScale,this.endScale,t)}handleComplete(){this.loopCount++,this.onLoop.next(this.loopCount),this.loop?this.pingPong?this.direction*=-1:this.elapsed=0:(this.isPlaying=!1,this.onComplete.next())}};t([h({help:"Enable position animation"}),i("design:type",Boolean)],d.prototype,"animatePosition",void 0),t([h({help:"The position to animate to (relative offset or absolute world position)",requires:{animatePosition:!0}}),i("design:type",o)],d.prototype,"targetPosition",void 0),t([h({help:"Enable rotation animation"}),i("design:type",Boolean)],d.prototype,"animateRotation",void 0),t([h({help:"The rotation to animate to in degrees (relative offset or absolute)",requires:{animateRotation:!0}}),i("design:type",o)],d.prototype,"targetRotation",void 0),t([h({label:"Animate Scale",help:"Enable scale animation"}),i("design:type",Boolean)],d.prototype,"animateScale",void 0),t([h({help:"The scale to animate to (relative multiplier or absolute)",requires:{animateScale:!0}}),i("design:type",o)],d.prototype,"targetScale",void 0),t([h({help:"Animation duration in seconds",range:[.01,60],precision:2}),i("design:type",Number)],d.prototype,"duration",void 0),t([h({help:"Delay before animation starts in seconds",range:[0,60],precision:2}),i("design:type",Number)],d.prototype,"delay",void 0),t([h({help:"The easing curve for the animation"}),i("design:type",r)],d.prototype,"easing",void 0),t([h({help:"If true, targets are offsets from initial values. If false, targets are absolute values."}),i("design:type",Boolean)],d.prototype,"relative",void 0),t([h({help:"Repeat the animation forever"}),i("design:type",Boolean)],d.prototype,"loop",void 0),t([h({help:"Reverse direction each loop (yo-yo effect)",requires:{loop:!0}}),i("design:type",Boolean)],d.prototype,"pingPong",void 0),t([h({help:"Start animation automatically when the actor spawns"}),i("design:type",Boolean)],d.prototype,"autoPlay",void 0),t([h({help:"Play the animation in the editor. Useful for testing."}),i("design:type",Boolean)],d.prototype,"inEditor",void 0),d=t([n({inEditor:!0})],d);export{d as TweenComponent};/*
1
+ import{__decorate as t,__metadata as i}from"tslib";import{Euler as e,Vector3 as o}from"three";import{Subject as s}from"rxjs";import{ActorComponent as a,Component as n}from"../../component.js";import{Parameter as h}from"../../../../shader/parameter.js";import{Curve2 as r}from"../../../../utils/curve.js";import{inject as l}from"../../../../gameplay/inject.js";import{PhysicsSystem as p}from"../../../../gameplay/services/physics/physics-system.js";let d=class extends a{constructor(){super(...arguments),this.animatePosition=!1,this.targetPosition=new o(0,1,0),this.animateRotation=!1,this.targetRotation=new o(0,0,0),this.animateScale=!1,this.targetScale=new o(1,1,1),this.duration=1,this.delay=0,this.easing=r.linear(),this.relative=!0,this.loop=!1,this.pingPong=!1,this.autoPlay=!0,this.inEditor=!1,this.onComplete=new s,this.onLoop=new s,this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.delayRemaining=0,this.direction=1,this.loopCount=0,this.startPosition=new o,this.startRotation=new e,this.startScale=new o,this.endPosition=new o,this.endRotation=new e,this.endScale=new o,this.physics=l(p)}onInit(){this.autoPlay&&this.inEditor&&this.play()}onBeginPlay(){this.autoPlay&&!this.inEditor&&this.play()}onEndPlay(){this.onComplete.complete(),this.onLoop.complete()}play(){this.isPlaying&&!this.isPaused||(this.isPlaying||(this.captureStartValues(),this.computeEndValues(),this.elapsed=0,this.delayRemaining=this.delay,this.direction=1,this.loopCount=0),this.isPlaying=!0,this.isPaused=!1)}pause(){this.isPaused=!0}stop(){this.isPlaying=!1,this.isPaused=!1,this.elapsed=0,this.applyValues(0)}reverse(){this.direction*=-1}restart(){this.stop(),this.play()}get progress(){return this.duration>0?this.elapsed/this.duration:0}get playing(){return this.isPlaying&&!this.isPaused}onUpdate(t){if(!this.isPlaying||this.isPaused)return;if(this.delayRemaining>0)return void(this.delayRemaining-=t);this.elapsed+=t*this.direction,this.elapsed>=this.duration?(this.elapsed=this.duration,this.handleComplete()):this.elapsed<=0&&(this.elapsed=0,this.handleComplete());const i=this.elapsed/this.duration,e=this.easing.getY(i);this.applyValues(e)}captureStartValues(){this.startPosition.copy(this.actor.position),this.startRotation.copy(this.actor.rotation),this.startScale.copy(this.actor.object.scale)}computeEndValues(){if(this.animatePosition&&(this.relative?this.endPosition.copy(this.startPosition).add(this.targetPosition):this.endPosition.copy(this.targetPosition)),this.animateRotation){const t=new o(this.targetRotation.x*Math.PI/180,this.targetRotation.y*Math.PI/180,this.targetRotation.z*Math.PI/180);this.relative?this.endRotation.set(this.startRotation.x+t.x,this.startRotation.y+t.y,this.startRotation.z+t.z):this.endRotation.set(t.x,t.y,t.z)}this.animateScale&&(this.relative?this.endScale.set(this.startScale.x*this.targetScale.x,this.startScale.y*this.targetScale.y,this.startScale.z*this.targetScale.z):this.endScale.copy(this.targetScale))}applyValues(t){let i=!1;this.animatePosition&&(this.actor.position.lerpVectors(this.startPosition,this.endPosition,t),i=!0),this.animateRotation&&(this.actor.rotation.set(this.startRotation.x+(this.endRotation.x-this.startRotation.x)*t,this.startRotation.y+(this.endRotation.y-this.startRotation.y)*t,this.startRotation.z+(this.endRotation.z-this.startRotation.z)*t),i=!0),this.animateScale&&this.actor.object.scale.lerpVectors(this.startScale,this.endScale,t),i&&this.physics.updateActorTransform(this.actor)}handleComplete(){this.loopCount++,this.onLoop.next(this.loopCount),this.loop?this.pingPong?this.direction*=-1:this.elapsed=0:(this.isPlaying=!1,this.onComplete.next())}};t([h({help:"Enable position animation"}),i("design:type",Boolean)],d.prototype,"animatePosition",void 0),t([h({help:"The position to animate to (relative offset or absolute world position)",requires:{animatePosition:!0}}),i("design:type",o)],d.prototype,"targetPosition",void 0),t([h({help:"Enable rotation animation"}),i("design:type",Boolean)],d.prototype,"animateRotation",void 0),t([h({help:"The rotation to animate to in degrees (relative offset or absolute)",requires:{animateRotation:!0}}),i("design:type",o)],d.prototype,"targetRotation",void 0),t([h({label:"Animate Scale",help:"Enable scale animation"}),i("design:type",Boolean)],d.prototype,"animateScale",void 0),t([h({help:"The scale to animate to (relative multiplier or absolute)",requires:{animateScale:!0}}),i("design:type",o)],d.prototype,"targetScale",void 0),t([h({help:"Animation duration in seconds",range:[.01,60],precision:2}),i("design:type",Number)],d.prototype,"duration",void 0),t([h({help:"Delay before animation starts in seconds",range:[0,60],precision:2}),i("design:type",Number)],d.prototype,"delay",void 0),t([h({help:"The easing curve for the animation"}),i("design:type",r)],d.prototype,"easing",void 0),t([h({help:"If true, targets are offsets from initial values. If false, targets are absolute values."}),i("design:type",Boolean)],d.prototype,"relative",void 0),t([h({help:"Repeat the animation forever"}),i("design:type",Boolean)],d.prototype,"loop",void 0),t([h({help:"Reverse direction each loop (yo-yo effect)",requires:{loop:!0}}),i("design:type",Boolean)],d.prototype,"pingPong",void 0),t([h({help:"Start animation automatically when the actor spawns"}),i("design:type",Boolean)],d.prototype,"autoPlay",void 0),t([h({help:"Play the animation in the editor. Useful for testing."}),i("design:type",Boolean)],d.prototype,"inEditor",void 0),d=t([n({inEditor:!0})],d);export{d as TweenComponent};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -17,10 +17,12 @@ declare class NavMeshActor extends BaseActor {
17
17
  walkableHeight: number;
18
18
  cellSize: number;
19
19
  navMesh: NavMesh;
20
+ private debugDrawer;
20
21
  private bounds;
21
22
  private recreateInterval;
22
23
  onInit(): Promise<void>;
23
24
  onEndPlay(): void;
25
+ applySceneParameters(parameters: Record<string, unknown>, changedParameters: ReadonlySet<string>): boolean;
24
26
  private init;
25
27
  }
26
28
  export default NavMeshActor;
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as s,Cone as o,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-simd-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as k,World as C,attach as j,inject as F}from"../../";import{sleepDelay as I}from"../../../utils/async";import{hasSharedArrayBufferSupport as P,toSharedFloat32Array as V,toSharedUint32Array as G}from"../../../utils/buffer";import{DynamicTiledNavMesh as N}from"../../ai/dynamic-tiled-navmesh";import{TriggerVolumeMesh as H}from"./components/volume-editor-component";var D;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(D||(D={}));let E=D.none,T=new m(!1);export async function safeRecastInit(){return E===D.none?(E=D.starting,p().then(()=>{T.next(!0),E=D.started})):g(T.pipe(b(e=>e)))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const R=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=F(A),this.view=F(k),this.world=F(C),this.editorVisualisation=j(H),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.walkableHeight=2,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout(()=>{this.init()},10),this.recreateInterval=setInterval(()=>{if("_hology_transform_group"===this.object.parent?.name)return;$.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())},2e3)}onEndPlay(){clearInterval(this.recreateInterval)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale);const e=this.bounds.max.x-this.bounds.min.x,t=this.bounds.max.z-this.bounds.min.z,n=Math.max(1,Math.min(e,t)),s=Math.min(400,Math.max(50,Math.ceil(n/2))),o=Math.max(this.cellSize,.01),i={tileSize:Math.max(32,Math.floor(s/o)),walkableClimb:this.walkableClimb/o,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:this.walkableHeight/o,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:o,ch:o,maxSimplificationError:1.3,maxEdgeLen:200},r=new N({navMeshBounds:this.bounds,recastConfig:i,maxTiles:1024,workers:R,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=r.navMesh;const a=this.tileSize*i.cs*2,l=performance.now(),c=new Map,h=new u;h.userData.isDebugDrawer=!0;r.navMesh;const p=this.bounds,m=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(a),(new x.Vector3).copy(e).addScalar(a)),n=[],s=this.physics.world.bodies;if(null==s)return[];const o=new x.Box3;for(const e of s.getAll())for(let s=0,i=e.numColliders();s<i;s++){const i=e.collider(s);if(i.isSensor()||null!=i.parent().userData&&!0===i.parent().userData.ignoreForNavMesh)continue;const r=e.handle+","+s,a=c.get(r)?.mesh,l=a??L(i);if(X(i,l),null!=l){o.copy(l.geometry.boundingBox),o.min.add(l.position),o.max.add(l.position);const e=o.intersectsBox(t)||!0,s=o.intersectsBox(this.bounds);c.set(r,{pos:i.translation(),mesh:l}),e&&s&&n.push(l)}}return n},f=new x.Box3,b=new Map,g=new Map;let v=!0,M=performance.now(),B=!1;const S=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await I(t)})(),()=>{n=!0}}(async()=>{if(B)return;const e=new x.Box3,t=m();for(const n of t){const t=b.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),b.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=r.getTilesForBounds(e);n.length>500&&console.warn("Too many tiles to update. Consider increasing tile size");const s=n.slice(0,500);if(0!=s.length){const n=[];for(const s of t)f.setFromObject(s),f.intersectsBox(e)&&n.push(s);let[o,i]=d(n);i=function(e,t,n){const s=new x.Vector3,o=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let o=0;o<3;o++){const a=3*t[i+o];if(s.fromArray(e,a),!n.containsPoint(s)){r=!1;break}}r&&o.push(t[i],t[i+1],t[i+2])}return new Uint32Array(o)}(o,i,p),P&&(o=V(o),i=G(i));const a=v;v=!1,await Promise.all(s.map(e=>(M=performance.now(),r.buildTile(o,i,e,a).then(()=>{const t=e[0]+","+e[1];g.set(t,(g.get(t)??0)+1),this.debug})))).then(()=>{this.debug,B=!1})}else B=!1},this.refreshMs??1e4);this.disposed.subscribe(()=>S()),r.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe(()=>{h.clear(),h.drawNavMesh(r.navMesh)}),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(h)),this.disposed.subscribe(()=>{r?.destroy(),h.removeFromParent(),h.dispose()});const z=performance.now()-l;z>1e3&&console.warn(`NavMesh update took ${z} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableHeight",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([B()],q);export default q;const O=new Map,W=new WeakMap;function _(e){if(e.shape instanceof l)return function(e){const t=e.shape;if(t.type!==c.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const s=t,o=s.heights,i=s.nrows,r=s.ncols,a=s.scale.x,l=s.scale.z,h=s.scale.y,p=i+1,u=new x.PlaneGeometry(l,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=o[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,l,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i){const t=function(e){const t=W.get(e);if(void 0!==t)return t;const n=new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>>2);let s=2166136261;for(let e=0;e<n.length;e++)s=Math.imul(s^n[e],16777619)>>>0;return W.set(e,s),s}(e.shape.vertices);let n=O.get(t);return n||(n=function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new M).setFromPoints(t),s=[];n.faces.forEach(e=>{const t=e.edge.head().point,n=e.edge.next.head().point,o=e.edge.next.next.head().point;s.push(t.x,t.y,t.z),s.push(n.x,n.y,n.z),s.push(o.x,o.y,o.z)});const o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(s,3)),o}(e.shape.vertices),O.set(t,n)),n}if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?s.setIndex(new x.Uint16BufferAttribute(n,1)):s=v.mergeVertices(s),s.computeVertexNormals(),s}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function L(e){const t=_(e);if(null==t)return null;const n=J,s=new x.Mesh(t,n);return s.geometry.computeBoundingBox(),s.geometry.scale(1.01,1.01,1.01),s}function X(e,t){const n=e.translation(),s=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(s.x,s.y,s.z,s.w)}const $=new x.Box3,J=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{Ball as n,Capsule as s,Cone as o,ConvexPolyhedron as i,Cuboid as r,Cylinder as a,Heightfield as l,ShapeType as c,TriMesh as h}from"@dimforge/rapier3d-simd-compat";import{init as p}from"@recast-navigation/core";import{DebugDrawer as u,getPositionsAndIndices as d}from"@recast-navigation/three";import{BehaviorSubject as m,Subject as f,debounceTime as w,filter as b,firstValueFrom as g,takeUntil as y}from"rxjs";import*as x from"three";import{BufferGeometryUtils as v,ConvexHull as M}from"three/examples/jsm/Addons.js";import{Actor as B,BaseActor as S,Parameter as z,PhysicsSystem as A,ViewController as k,World as C,attach as j,inject as P}from"../../";import{sleepDelay as F}from"../../../utils/async";import{hasSharedArrayBufferSupport as I,toSharedFloat32Array as D,toSharedUint32Array as V}from"../../../utils/buffer";import{DynamicTiledNavMesh as G}from"../../ai/dynamic-tiled-navmesh";import{TriggerVolumeMesh as N}from"./components/volume-editor-component";var H;!function(e){e[e.none=0]="none",e[e.starting=1]="starting",e[e.started=2]="started"}(H||(H={}));let E=H.none,T=new m(!1);export async function safeRecastInit(){return E===H.none?(E=H.starting,p().then(()=>{T.next(!0),E=H.started})):g(T.pipe(b(e=>e)))}new x.Box3(new x.Vector3(-100,-100,-100),new x.Vector3(100,100,100));const R=navigator.hardwareConcurrency??1;let U=!1,q=class extends S{constructor(){super(...arguments),this.physics=P(A),this.view=P(k),this.world=P(C),this.editorVisualisation=j(N),this.debug=!0,this.refreshMs=4e3,this.tileSize=50,this.walkableClimb=.3,this.walkableSlopeAngle=45,this.walkableHeight=2,this.cellSize=.2,this.bounds=new x.Box3}async onInit(){U||(await safeRecastInit(),U=!0),setTimeout(()=>{this.init()},10),this.recreateInterval=setInterval(()=>{if("_hology_transform_group"===this.object.parent?.name)return;$.setFromCenterAndSize(this.position,this.object.scale).equals(this.bounds)||(this.disposed.next(!0),this.disposed=new f,this.init())},2e3)}onEndPlay(){clearInterval(this.recreateInterval)}applySceneParameters(e,t){return!(null==this.debugDrawer||!t.has("debug")||"boolean"!=typeof e.debug)&&(this.debugDrawer.visible=e.debug,!0)}init(){this.bounds.setFromCenterAndSize(this.position,this.object.scale);const e=this.bounds.max.x-this.bounds.min.x,t=this.bounds.max.z-this.bounds.min.z,n=Math.max(1,Math.min(e,t)),s=Math.min(400,Math.max(50,Math.ceil(n/2))),o=Math.max(this.cellSize,.01),i={tileSize:Math.max(32,Math.floor(s/o)),walkableClimb:this.walkableClimb/o,walkableSlopeAngle:this.walkableSlopeAngle,walkableRadius:2,walkableHeight:this.walkableHeight/o,detailSampleDist:1,minRegionArea:6,mergeRegionArea:400,cs:o,ch:o,maxSimplificationError:1.3,maxEdgeLen:200},r=new G({navMeshBounds:this.bounds,recastConfig:i,maxTiles:1024,workers:R,cacheId:"nav"+this.object.userData?.src?.id});this.navMesh=r.navMesh;const a=this.tileSize*i.cs*2,l=performance.now(),c=new Map,h=new u;h.userData.isDebugDrawer=!0,this.debugDrawer=h;r.navMesh;const p=this.bounds,m=()=>{const e=this.view.getCamera().getWorldPosition(new x.Vector3),t=new x.Box3((new x.Vector3).copy(e).subScalar(a),(new x.Vector3).copy(e).addScalar(a)),n=[],s=this.physics.world.bodies;if(null==s)return[];const o=new x.Box3;for(const e of s.getAll())for(let s=0,i=e.numColliders();s<i;s++){const i=e.collider(s);if(i.isSensor()||null!=i.parent().userData&&!0===i.parent().userData.ignoreForNavMesh)continue;const r=e.handle+","+s,a=c.get(r)?.mesh,l=a??L(i);if(X(i,l),null!=l){o.copy(l.geometry.boundingBox),o.min.add(l.position),o.max.add(l.position);const e=o.intersectsBox(t)||!0,s=o.intersectsBox(this.bounds);c.set(r,{pos:i.translation(),mesh:l}),e&&s&&n.push(l)}}return n},f=new x.Box3,b=new Map,g=new Map;let v=!0,M=performance.now(),B=!1;const S=function(e,t){let n=!1;return(async()=>{for(;!n;)await e(),await F(t)})(),()=>{n=!0}}(async()=>{if(B)return;const e=new x.Box3,t=m();for(const n of t){const t=b.get(n);!0!==t?.equals(n.position)&&(null!=t&&e.expandByPoint(t),e.expandByObject(n),b.set(n,n.position.clone()))}e.min.subScalar(50),e.max.addScalar(50);const n=r.getTilesForBounds(e);n.length>500&&console.warn("Too many tiles to update. Consider increasing tile size");const s=n.slice(0,500);if(0!=s.length){const n=[];for(const s of t)f.setFromObject(s),f.intersectsBox(e)&&n.push(s);let[o,i]=d(n);i=function(e,t,n){const s=new x.Vector3,o=[];for(let i=0;i<t.length;i+=3){let r=!0;for(let o=0;o<3;o++){const a=3*t[i+o];if(s.fromArray(e,a),!n.containsPoint(s)){r=!1;break}}r&&o.push(t[i],t[i+1],t[i+2])}return new Uint32Array(o)}(o,i,p),I&&(o=D(o),i=V(i));const a=v;v=!1,await Promise.all(s.map(e=>(M=performance.now(),r.buildTile(o,i,e,a).then(()=>{const t=e[0]+","+e[1];g.set(t,(g.get(t)??0)+1),this.debug})))).then(()=>{this.debug,B=!1})}else B=!1},this.refreshMs??1e4);this.disposed.subscribe(()=>S()),r.onNavMeshUpdate.pipe(y(this.disposed),w(200)).subscribe(()=>{h.clear(),h.drawNavMesh(r.navMesh)}),console.log("Create navmesh with debug",this.debug),this.debug&&(this.object.rotation.set(0,0,0),this.object.updateMatrix(),this.object.updateMatrixWorld(),this.object.parent.add(h)),this.disposed.subscribe(()=>{r?.destroy(),h.removeFromParent(),h.dispose()});const z=performance.now()-l;z>1e3&&console.warn(`NavMesh update took ${z} ms. Consider changing tileSize or other parameter that may affect performance`)}};e([z(),t("design:type",Boolean)],q.prototype,"debug",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableClimb",void 0),e([z({range:[0,89]}),t("design:type",Number)],q.prototype,"walkableSlopeAngle",void 0),e([z(),t("design:type",Number)],q.prototype,"walkableHeight",void 0),e([z({range:[.01,10]}),t("design:type",Number)],q.prototype,"cellSize",void 0),q=e([B()],q);export default q;const O=new Map,W=new WeakMap;function _(e){if(e.shape instanceof l)return function(e){const t=e.shape;if(t.type!==c.HeightField)throw new Error("The provided collider is not a height field.");let n=!1;const s=t,o=s.heights,i=s.nrows,r=s.ncols,a=s.scale.x,l=s.scale.z,h=s.scale.y,p=i+1,u=new x.PlaneGeometry(l,a,r,i);u.rotateX(-Math.PI/2);const d=u.attributes.position.array;let m=0;for(let e=0;e<p;e++)for(let t=0;t<p;t++)d[m+1]=o[t*p+e]*h,m+=3,0!=d[m+1]&&(n=!0);if(!n){const e=new x.PlaneGeometry(a,l,2,2);return e.rotateX(-Math.PI/2),e}return u}(e);if(e.shape instanceof n)return new x.SphereGeometry(e.shape.radius);if(e.shape instanceof r){const t=e.shape.halfExtents;return new x.BoxGeometry(2*t.x,2*t.y,2*t.z)}if(e.shape instanceof i){const t=function(e){const t=W.get(e);if(void 0!==t)return t;const n=new Uint32Array(e.buffer,e.byteOffset,e.byteLength>>>2);let s=2166136261;for(let e=0;e<n.length;e++)s=Math.imul(s^n[e],16777619)>>>0;return W.set(e,s),s}(e.shape.vertices);let n=O.get(t);return n||(n=function(e){const t=[];for(let n=0;n<e.length;n+=3)t.push(new x.Vector3(e[n],e[n+1],e[n+2]));const n=(new M).setFromPoints(t),s=[];n.faces.forEach(e=>{const t=e.edge.head().point,n=e.edge.next.head().point,o=e.edge.next.next.head().point;s.push(t.x,t.y,t.z),s.push(n.x,n.y,n.z),s.push(o.x,o.y,o.z)});const o=new x.BufferGeometry;return o.setAttribute("position",new x.Float32BufferAttribute(s,3)),o}(e.shape.vertices),O.set(t,n)),n}if(e.shape instanceof h){const t=e.shape.vertices,n=e.shape.indices;let s=new x.BufferGeometry;return s.setAttribute("position",new x.Float32BufferAttribute(t,3)),null!=n?s.setIndex(new x.Uint16BufferAttribute(n,1)):s=v.mergeVertices(s),s.computeVertexNormals(),s}if(e.shape instanceof a){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CylinderGeometry(n,n,2*t)}if(e.shape instanceof o){const t=e.shape.halfHeight,n=e.shape.radius;return new x.ConeGeometry(n,2*t)}if(e.shape instanceof s){const t=e.shape.halfHeight,n=e.shape.radius;return new x.CapsuleGeometry(n,2*t)}return console.warn("Unsupported shape",e.shape.type,e),null}function L(e){const t=_(e);if(null==t)return null;const n=J,s=new x.Mesh(t,n);return s.geometry.computeBoundingBox(),s.geometry.scale(1.01,1.01,1.01),s}function X(e,t){const n=e.translation(),s=e.rotation();t.position.set(n.x,n.y,n.z),t.quaternion.set(s.x,s.y,s.z,s.w)}const $=new x.Box3,J=new x.MeshBasicMaterial({wireframe:!1,color:16711680,side:x.FrontSide});/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,7 +1,6 @@
1
1
  import { Vector3, Color } from "three";
2
2
  import { BaseActor } from '../actor.js';
3
3
  import { ActorComponent } from '../component.js';
4
- import { PhysicsSystem } from '../../services/physics/physics-system.js';
5
4
  import { Observable } from "rxjs";
6
5
  import { Type } from '../../../utils/type.js';
7
6
  export declare class TriggerVolumeMesh extends ActorComponent {
@@ -10,12 +9,13 @@ export declare class TriggerVolumeMesh extends ActorComponent {
10
9
  onInit(): void | Promise<void>;
11
10
  }
12
11
  export declare class TriggerVolumeComponent extends ActorComponent {
13
- private physicsSystem;
14
12
  readonly dimensions: Vector3;
15
13
  readonly offset: Vector3;
16
14
  private editorMesh;
17
- constructor(physicsSystem: PhysicsSystem);
15
+ private physicsSystem;
18
16
  onInit(): Promise<void> | void;
17
+ onBeginOverlap(): Observable<BaseActor>;
18
+ onEndOverlap(): Observable<BaseActor>;
19
19
  onBeginOverlapWithActor<A extends BaseActor>(actor: A): Observable<A>;
20
20
  onEndOverlapWithActor<A extends BaseActor>(actor: A): Observable<A>;
21
21
  onBeginOverlapWithActorType<A extends BaseActor>(actorType: Type<A>): Observable<A>;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as s}from"tslib";import{EdgesGeometry as i,LineSegments as e,LineBasicMaterial as o,Vector3 as r,BoxGeometry as n,Mesh as h,MeshBasicMaterial as c,Group as p,Color as m}from"three";import{Actor as d,BaseActor as a}from"../actor.js";import{Component as y,ActorComponent as l,attach as f}from"../component.js";import{PhysicsSystem as v}from"../../services/physics/physics-system.js";import{BoxCollisionShape as w}from"../../../scene/collision/collision-shape.js";import{Parameter as g}from"../../../shader/parameter.js";import{firstValueFrom as O}from"rxjs";let u=class extends l{constructor(){super(...arguments),this.color=new m(16777215),this.dimensions=new r(1,1,1)}onInit(){const t=new n(this.dimensions.x,this.dimensions.y,this.dimensions.z),s=new i(t),r=new e(s,new o({color:this.color})),m=(new h(t,new c({color:this.color,transparent:!0,opacity:.3,visible:!1})),new p);m.add(r),this.actor.object.add(m)}};t([g(),s("design:type",m)],u.prototype,"color",void 0),t([g(),s("design:type",r)],u.prototype,"dimensions",void 0),u=t([y({inEditor:!0,editorOnly:!0})],u);export{u as TriggerVolumeMesh};let A=class extends l{constructor(t){super(),this.physicsSystem=t,this.dimensions=new r(1,1,1),this.offset=new r(0,0,0),this.editorMesh=f(u)}onInit(){this.physicsSystem.addActor(this.actor,[new w(this.dimensions).withOffset(this.offset)],{isTrigger:!0}),O(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}onBeginOverlapWithActor(t){return this.physicsSystem.onBeginOverlapWithActor(this.actor,t)}onEndOverlapWithActor(t){return this.physicsSystem.onEndOverlapWithActor(this.actor,t)}onBeginOverlapWithActorType(t){return this.physicsSystem.onBeginOverlapWithActorType(this.actor,t)}onEndOverlapWithActorType(t){return this.physicsSystem.onEndOverlapWithActorType(this.actor,t)}};A=t([y({inEditor:!0,editorOnly:!1}),s("design:paramtypes",[v])],A);export{A as TriggerVolumeComponent};let x=class extends a{constructor(){super(...arguments),this.trigger=f(A)}};x=t([d()],x);export{x as TriggerVolume};/*
1
+ var e,t;import{__decorate as r,__metadata as i}from"tslib";import{EdgesGeometry as n,LineSegments as o,LineBasicMaterial as s,Vector3 as p,BoxGeometry as a,Mesh as c,MeshBasicMaterial as l,Group as y,Color as h}from"three";import{Actor as d,BaseActor as m}from"../actor.js";import{Component as g,ActorComponent as O,attach as u}from"../component.js";import{PhysicsSystem as v}from"../../services/physics/physics-system.js";import{BoxCollisionShape as f}from"../../../scene/collision/collision-shape.js";import{Parameter as b}from"../../../shader/parameter.js";import{firstValueFrom as j,Observable as W}from"rxjs";import{inject as w}from"../../../gameplay/inject.js";import{EventGraphEventSource as E,EventGraphProperty as B}from"../../event-graph/decorators.js";import{EVENT_GRAPH_ACTOR_CLASS_TYPE as T,EVENT_GRAPH_ACTOR_TYPE as S}from"../../event-graph/types.js";let x=class extends O{constructor(){super(...arguments),this.color=new h(16777215),this.dimensions=new p(1,1,1)}onInit(){const e=new a(this.dimensions.x,this.dimensions.y,this.dimensions.z),t=new n(e),r=new o(t,new s({color:this.color})),i=(new c(e,new l({color:this.color,transparent:!0,opacity:.3,visible:!1})),new y);i.add(r),this.actor.object.add(i)}};r([b(),i("design:type",h)],x.prototype,"color",void 0),r([b(),i("design:type",p)],x.prototype,"dimensions",void 0),x=r([g({inEditor:!0,editorOnly:!0})],x);export{x as TriggerVolumeMesh};let F=class extends O{constructor(){super(...arguments),this.dimensions=new p(1,1,1),this.offset=new p(0,0,0),this.editorMesh=u(x),this.physicsSystem=w(v)}onInit(){this.physicsSystem.addActor(this.actor,[new f(this.dimensions).withOffset(this.offset)],{isTrigger:!0}),j(this.disposed).then(()=>{this.physicsSystem.removeActor(this.actor)})}onBeginOverlap(){return this.physicsSystem.onBeginOverlap(this.actor)}onEndOverlap(){return this.physicsSystem.onEndOverlap(this.actor)}onBeginOverlapWithActor(e){return this.physicsSystem.onBeginOverlapWithActor(this.actor,e)}onEndOverlapWithActor(e){return this.physicsSystem.onEndOverlapWithActor(this.actor,e)}onBeginOverlapWithActorType(e){return this.physicsSystem.onBeginOverlapWithActorType(this.actor,e)}onEndOverlapWithActorType(e){return this.physicsSystem.onEndOverlapWithActorType(this.actor,e)}};r([E({label:"On Begin Overlap",emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",W)],F.prototype,"onBeginOverlap",null),r([E({label:"On End Overlap",emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",[]),i("design:returntype",W)],F.prototype,"onEndOverlap",null),r([E({label:"On Begin Overlap With Actor",parameters:[{name:"actor",type:S}],emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",["function"==typeof(e="undefined"!=typeof A&&A)?e:Object]),i("design:returntype",W)],F.prototype,"onBeginOverlapWithActor",null),r([E({label:"On End Overlap With Actor",parameters:[{name:"actor",type:S}],emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",["function"==typeof(t="undefined"!=typeof A&&A)?t:Object]),i("design:returntype",W)],F.prototype,"onEndOverlapWithActor",null),r([E({label:"On Begin Overlap With Actor Type",parameters:[{name:"actorType",type:T}],emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",W)],F.prototype,"onBeginOverlapWithActorType",null),r([E({label:"On End Overlap With Actor Type",parameters:[{name:"actorType",type:T}],emits:S,valueLabel:"Other Actor"}),i("design:type",Function),i("design:paramtypes",[Object]),i("design:returntype",W)],F.prototype,"onEndOverlapWithActorType",null),F=r([g({inEditor:!0,editorOnly:!1})],F);export{F as TriggerVolumeComponent};let L=class extends m{constructor(){super(...arguments),this.trigger=u(F)}};r([B({type:F,writable:!1}),i("design:type",Object)],L.prototype,"trigger",void 0),L=r([d({typeId:"TriggerVolume"})],L);export{L as TriggerVolume};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,15 +1,13 @@
1
1
  import { PerspectiveCamera } from 'three';
2
- import { ViewController } from '../../services/render.js';
3
2
  import { ActorComponent } from '../component.js';
4
3
  export declare class CameraComponent extends ActorComponent {
5
- private viewController;
6
4
  near: number;
7
5
  far: number;
8
6
  viewAngle: number;
7
+ private viewController;
9
8
  private debugMesh;
10
9
  private aspect;
11
10
  instance: PerspectiveCamera;
12
- constructor(viewController: ViewController);
13
11
  onInit(): void | Promise<void>;
14
12
  }
15
13
  export declare class CameraMesh extends ActorComponent {
@@ -1,4 +1,4 @@
1
- import{__decorate as e,__metadata as t}from"tslib";import{ArrowHelper as r,ConeGeometry as i,EdgesGeometry as s,LineBasicMaterial as o,LineSegments as n,MeshStandardMaterial as a,PerspectiveCamera as l,Vector3 as h}from"three";import{Parameter as d}from"../../../shader/parameter.js";import{ViewController as c}from"../../services/render.js";import{ActorComponent as p,attach as w,Component as m}from"../component.js";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let b=class extends p{constructor(e){super(),this.viewController=e,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.debugMesh=w(y),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.instance=new l(this.viewAngle,this.aspect,this.near,this.far)}onInit(){this.actor.object.add(this.instance),this.instance.near=this.near,this.instance.far=this.far,this.instance.fov=this.viewAngle}};e([d(),t("design:type",Number)],b.prototype,"near",void 0),e([d(),t("design:type",Number)],b.prototype,"far",void 0),e([d(),t("design:type",Number)],b.prototype,"viewAngle",void 0),b=e([m({inEditor:!0}),t("design:paramtypes",[c])],b);export{b as CameraComponent};let y=class extends p{constructor(){super(...arguments),this.arrowColor=16101442}onInit(){const e=new i(1,1,4);e.rotateX(Math.PI/2),e.rotateZ(Math.PI/4),e.scale(1,9/16,1);const t=new s(e),l=(new a({color:3355443}),new n(t,new o({color:16777215}))),d=new r(new h(0,0,-1),new h(0,0,0),1.2,this.arrowColor,.15,.2);l.add(d),d.layers.disableAll(),d.layers.enable(19),d.traverse(e=>{e.layers.disableAll(),e.layers.enable(19)}),this.actor.object.add(l)}};y=e([m({inEditor:!0,editorOnly:!0})],y);export{y as CameraMesh};/*
1
+ import{__decorate as e,__metadata as t}from"tslib";import{ArrowHelper as r,ConeGeometry as i,EdgesGeometry as o,LineBasicMaterial as s,LineSegments as n,MeshStandardMaterial as a,PerspectiveCamera as l,Vector3 as h}from"three";import{Parameter as c}from"../../../shader/parameter.js";import{ViewController as d}from"../../services/render.js";import{ActorComponent as p,attach as m,Component as w}from"../component.js";import{inject as v}from"../../../gameplay/inject.js";const b=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let y=class extends p{constructor(){super(...arguments),this.near=.5,this.far=500,this.viewAngle=b?30:45,this.viewController=v(d),this.debugMesh=m(f),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.instance=new l(this.viewAngle,this.aspect,this.near,this.far)}onInit(){this.actor.object.add(this.instance),this.instance.near=this.near,this.instance.far=this.far,this.instance.fov=this.viewAngle}};e([c(),t("design:type",Number)],y.prototype,"near",void 0),e([c(),t("design:type",Number)],y.prototype,"far",void 0),e([c(),t("design:type",Number)],y.prototype,"viewAngle",void 0),y=e([w({inEditor:!0})],y);export{y as CameraComponent};let f=class extends p{constructor(){super(...arguments),this.arrowColor=16101442}onInit(){const e=new i(1,1,4);e.rotateX(Math.PI/2),e.rotateZ(Math.PI/4),e.scale(1,9/16,1);const t=new o(e),l=(new a({color:3355443}),new n(t,new s({color:16777215}))),c=new r(new h(0,0,-1),new h(0,0,0),1.2,this.arrowColor,.15,.2);l.add(c),c.layers.disableAll(),c.layers.enable(19),c.traverse(e=>{e.layers.disableAll(),e.layers.enable(19)}),this.actor.object.add(l)}};f=e([w({inEditor:!0,editorOnly:!0})],f);export{f as CameraMesh};/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -16,6 +16,7 @@ export declare class ThirdPersonCameraComponent extends ActorComponent {
16
16
  collisionSphereRadius: number;
17
17
  smoothCamera: boolean;
18
18
  smoothSpeed: number;
19
+ teleportSnapDistance: number;
19
20
  camera: PerspectiveCamera;
20
21
  distance: number;
21
22
  minDistance: number;
@@ -58,6 +59,8 @@ export declare class ThirdPersonCameraComponent extends ActorComponent {
58
59
  private updateCameraPosition;
59
60
  private prevLookAt;
60
61
  private smoothedLookAt;
62
+ private previousTargetLookAt;
63
+ private hasSmoothedLookAt;
61
64
  private smoothedRotX;
62
65
  private smoothedRotY;
63
66
  private smoothZoom;
@@ -1,4 +1,4 @@
1
- import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as i,Component as o}from"../component.js";import{Vector3 as s,MathUtils as n,PerspectiveCamera as h,Object3D as r}from"three";import{ViewController as a}from"../../services/render.js";import{DecimalInput as c,RestrictedRotationInput as d}from"../../input/index.js";import{PhysicsSystem as m}from"../../services/physics/physics-system.js";import{Parameter as l}from"../../../shader/parameter.js";import{World as p}from"../../services/world.js";import{inject as u}from"../../inject.js";import{ease as f}from"@hology/nebula";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let k=class extends i{constructor(){super(),this.viewController=u(a),this.physicsSystem=u(m),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.collision=!0,this.collisionSphereRadius=.25,this.smoothCamera=!1,this.smoothSpeed=10,this.camera=new h(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=3,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new d(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new c(1,0,1),this.offset=new s,this.lookAtOffset=new s(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(p),this.activated=!1,this.isMouseLocked=!1,this.prevFixedBehind=!1,this.blendDurationLeft=0,this.pointerEventsRegistered=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.isMouseLocked||(this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default")},this.prevLookAt=new s,this.smoothedLookAt=new s,this.smoothedRotX=0,this.smoothedRotY=0,this.smoothZoom=0}async onInit(){this.prevFixedBehind=this.fixedBehind,this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.smoothedRotX=this.rotationInput.rotation.x,this.smoothedRotY=this.rotationInput.rotation.y,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.smoothZoom=this.zoomInput.value,this.autoActivate&&this.activate(),this.disposed.subscribe(()=>{this.unregisterPointerEvents()})}activate(){this.activated=!0,this.viewController.setCamera(this.camera),this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.registerPointerEvents()}deactivate(){this.activated=!1,this.isMouseLocked=!1,this.unregisterPointerEvents()}registerPointerEvents(){if(this.pointerEventsRegistered||null==document.body.requestPointerLock)return;const t=this.element;t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!0}unregisterPointerEvents(){if(!this.pointerEventsRegistered)return;const t=this.element;t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!1}onLateUpdate(t){this.activated&&this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&this.canvas.requestPointerLock&&(this.canvas.requestPointerLock({unadjustedMovement:!0}),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",null==document.pointerLockElement&&null==document.mozPointerLockElement||window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.fixedBehind!==this.prevFixedBehind?(this.blendDurationLeft=1,this.prevFixedBehind=this.fixedBehind):this.blendDurationLeft>0&&(this.blendDurationLeft-=t),this.collision&&this.checkForCollision(t);let e=this.zoomInput.value,i=this.rotationInput.rotation.x,o=this.rotationInput.rotation.y;if(this.smoothCamera){const s=1-Math.exp(-this.smoothSpeed*t*2);this.smoothedRotX=n.lerp(this.smoothedRotX,i,s),this.smoothedRotY=n.lerp(this.smoothedRotY,o,s),i=this.smoothedRotX,o=this.smoothedRotY,this.smoothZoom=n.lerp(this.smoothZoom,e,.4*s),e=this.smoothZoom}else this.smoothedRotX=i,this.smoothedRotY=o;const s=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*e,this.minDistance)),h=Math.cos(i)*s,r=this.fixedBehind?0:o;this.offset.x=Math.sin(-r)*h,this.offset.y=Math.sin(i)*s+2,this.offset.z=Math.cos(-r)*-h,this.fixedBehind&&this.offset.add(this.lookAtOffset),this.updateCameraPosition(t)}checkForCollision(t){const e=this.getLookAtPosition(),i=this.camera.getWorldPosition(x),o=g.subVectors(i,e),s=o.length();if(s<.001)return;o.divideScalar(s);const h=this.physicsSystem.sphereCast(e,this.collisionSphereRadius,o,this.distance,void 0,{excludeActor:this.actor,excludeTriggers:!0,collisionFilter:-2});if(h.hasHit){const e=Math.max(this.minDistance,h.distance-.05);e<this.restrictedDistance?this.restrictedDistance=e:this.restrictedDistance=n.lerp(this.restrictedDistance,e,n.clamp(this.bounceBackSpeed*t,0,1))}else this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1))}getLookAtPosition(){const t=y;return t.set(0,0,0),t.y=this.height,this.fixedBehind&&t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(t){this.actor.object.updateWorldMatrix(!0,!1),this.fixedBehind?(L.position.set(this.offset.x,this.offset.y,this.offset.z),L.rotation.set(0,0,0),L.scale.set(1,1,1),L.applyMatrix4(this.actor.object.matrix)):L.position.copy(this.actor.position).add(this.offset);const e=f.easeInOutCubic(1-this.blendDurationLeft);if(this.blendDurationLeft>0){const t=this.getLookAtPosition();this.prevLookAt.lerp(t,e),this.camera.lookAt(this.prevLookAt),this.camera.position.lerp(L.position,e),this.smoothedLookAt.copy(this.prevLookAt)}else{const e=this.getLookAtPosition();if(this.smoothCamera){const i=1-Math.exp(-this.smoothSpeed*t);this.smoothedLookAt.distanceToSquared(e)>1?this.smoothedLookAt.copy(e):this.smoothedLookAt.lerp(e,i)}else this.smoothedLookAt.copy(e);w.subVectors(L.position,e),this.camera.position.copy(this.smoothedLookAt).add(w),this.camera.lookAt(this.smoothedLookAt),this.prevLookAt.copy(this.smoothedLookAt)}}};t([l(),e("design:type",Number)],k.prototype,"near",void 0),t([l(),e("design:type",Number)],k.prototype,"far",void 0),t([l(),e("design:type",Number)],k.prototype,"viewAngle",void 0),t([l(),e("design:type",Boolean)],k.prototype,"collision",void 0),t([l(),e("design:type",Number)],k.prototype,"collisionSphereRadius",void 0),t([l(),e("design:type",Boolean)],k.prototype,"smoothCamera",void 0),t([l(),e("design:type",Number)],k.prototype,"smoothSpeed",void 0),k=t([o(),e("design:paramtypes",[])],k);export{k as ThirdPersonCameraComponent};const L=new r,y=new s,w=new s,g=new s,x=(new s,new s);export class ThirdPartyCameraComponent extends k{}/*
1
+ import{__decorate as t,__metadata as e}from"tslib";import{ActorComponent as o,Component as i}from"../component.js";import{Vector3 as s,MathUtils as n,PerspectiveCamera as h,Object3D as r}from"three";import{ViewController as a}from"../../services/render.js";import{DecimalInput as c,RestrictedRotationInput as d}from"../../input/index.js";import{PhysicsSystem as m}from"../../services/physics/physics-system.js";import{Parameter as p}from"../../../shader/parameter.js";import{World as l}from"../../services/world.js";import{inject as u}from"../../inject.js";import{ease as f}from"@hology/nebula";const v=void 0!==window&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);let k=class extends o{constructor(){super(),this.viewController=u(a),this.physicsSystem=u(m),this.aspect=this.viewController.htmlElement.clientWidth/this.viewController.htmlElement.clientHeight,this.near=.5,this.far=500,this.viewAngle=v?30:45,this.collision=!0,this.collisionSphereRadius=.25,this.smoothCamera=!1,this.smoothSpeed=10,this.teleportSnapDistance=5,this.camera=new h(this.viewAngle,this.aspect,this.near,this.far),this.distance=9,this.minDistance=1.5,this.maxDistance=this.distance,this.height=3,this.offsetX=-1,this.offsetZ=1.5,this.autoActivate=!0,this.bounceBackSpeed=3,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.rotationInput=new d(-Math.PI/4,Math.PI/2-.7),this.zoomInput=new c(1,0,1),this.offset=new s,this.lookAtOffset=new s(this.offsetX,0,this.offsetZ),this.fixedBehind=!0,this.world=u(l),this.activated=!1,this.isMouseLocked=!1,this.prevFixedBehind=!1,this.blendDurationLeft=0,this.pointerEventsRegistered=!1,this.canvas=null,this.pointerLockInactivatedAt=null,this.onMouseDown=t=>{this.isMouseLocked||"mouse"!==t.pointerType||this.hideCursor()},this.onKeyDown=t=>{"Escape"===t.key&&this.showCursor()},this.onPointerLockChange=()=>{this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.isMouseLocked||(this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default")},this.prevLookAt=new s,this.smoothedLookAt=new s,this.previousTargetLookAt=new s,this.hasSmoothedLookAt=!1,this.smoothedRotX=0,this.smoothedRotY=0,this.smoothZoom=0}async onInit(){this.prevFixedBehind=this.fixedBehind,this.world.scene.add(this.camera),this.rotationInput.rotation.copy(this.actor.rotation),this.smoothedRotX=this.rotationInput.rotation.x,this.smoothedRotY=this.rotationInput.rotation.y,this.restrictedDistance=Math.max(this.distance,this.maxDistance),this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.smoothZoom=this.zoomInput.value,this.autoActivate&&this.activate(),this.disposed.subscribe(()=>{this.unregisterPointerEvents()})}activate(){this.activated=!0,this.hasSmoothedLookAt=!1,this.viewController.setCamera(this.camera),this.isMouseLocked=null!=document.pointerLockElement||null!=document.mozPointerLockElement,this.registerPointerEvents()}deactivate(){this.activated=!1,this.isMouseLocked=!1,this.unregisterPointerEvents()}registerPointerEvents(){if(this.pointerEventsRegistered||null==document.body.requestPointerLock)return;const t=this.element;t.addEventListener("pointerdown",this.onMouseDown),t.addEventListener("keydown",this.onKeyDown),document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!0}unregisterPointerEvents(){if(!this.pointerEventsRegistered)return;const t=this.element;t.removeEventListener("pointerdown",this.onMouseDown),t.removeEventListener("keydown",this.onKeyDown),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),this.pointerEventsRegistered=!1}onLateUpdate(t){this.activated&&this.setFromRotation(t)}get element(){return this.viewController.htmlElement}hideCursor(){null!=this.pointerLockInactivatedAt&&performance.now()-this.pointerLockInactivatedAt<1600||(this.element.style.cursor="none",null==this.canvas&&(this.canvas=this.element.getElementsByTagName("canvas")[0]),this.canvas&&this.canvas.requestPointerLock&&(this.canvas.requestPointerLock({unadjustedMovement:!0}),this.isMouseLocked=!0))}showCursor(){this.pointerLockInactivatedAt=performance.now(),this.element.style.cursor="default",null==document.pointerLockElement&&null==document.mozPointerLockElement||window.document.exitPointerLock(),this.isMouseLocked=!1}setFromRotation(t){this.lookAtOffset.set(this.offsetX,0,this.offsetZ),this.fixedBehind!==this.prevFixedBehind?(this.blendDurationLeft=1,this.prevFixedBehind=this.fixedBehind):this.blendDurationLeft>0&&(this.blendDurationLeft-=t),this.collision&&this.checkForCollision(t);let e=this.zoomInput.value,o=this.rotationInput.rotation.x,i=this.rotationInput.rotation.y;if(this.smoothCamera){const s=1-Math.exp(-this.smoothSpeed*t*2);this.smoothedRotX=n.lerp(this.smoothedRotX,o,s),this.smoothedRotY=n.lerp(this.smoothedRotY,i,s),o=this.smoothedRotX,i=this.smoothedRotY,this.smoothZoom=n.lerp(this.smoothZoom,e,.4*s),e=this.smoothZoom}else this.smoothedRotX=o,this.smoothedRotY=i;const s=n.clamp(Math.min(this.restrictedDistance,this.distance),Math.min(this.minDistance,this.restrictedDistance),Math.max(this.distance*e,this.minDistance)),h=Math.cos(o)*s,r=this.fixedBehind?0:i;this.offset.x=Math.sin(-r)*h,this.offset.y=Math.sin(o)*s+2,this.offset.z=Math.cos(-r)*-h,this.fixedBehind&&this.offset.add(this.lookAtOffset),this.updateCameraPosition(t)}checkForCollision(t){const e=this.getLookAtPosition(),o=this.camera.getWorldPosition(w),i=A.subVectors(o,e),s=i.length();if(s<.001)return;i.divideScalar(s);const h=this.physicsSystem.sphereCast(e,this.collisionSphereRadius,i,this.distance,void 0,{excludeActor:this.actor,excludeTriggers:!0,collisionFilter:-2});if(h.hasHit){const e=Math.max(this.minDistance,h.distance-.05);e<this.restrictedDistance?this.restrictedDistance=e:this.restrictedDistance=n.lerp(this.restrictedDistance,e,n.clamp(this.bounceBackSpeed*t,0,1))}else this.restrictedDistance=n.lerp(this.restrictedDistance,this.distance,n.clamp(this.bounceBackSpeed*t,0,1))}getLookAtPosition(){const t=y;return t.set(0,0,0),t.y=this.height,this.fixedBehind&&t.add(this.lookAtOffset),t.applyMatrix4(this.actor.object.matrixWorld),t}updateCameraPosition(t){this.actor.object.updateWorldMatrix(!0,!1),this.fixedBehind?(L.position.set(this.offset.x,this.offset.y,this.offset.z),L.rotation.set(0,0,0),L.scale.set(1,1,1),L.applyMatrix4(this.actor.object.matrix)):L.position.copy(this.actor.position).add(this.offset);const e=f.easeInOutCubic(1-this.blendDurationLeft);if(this.blendDurationLeft>0){const t=this.getLookAtPosition();this.prevLookAt.lerp(t,e),this.camera.lookAt(this.prevLookAt),this.camera.position.lerp(L.position,e),this.smoothedLookAt.copy(this.prevLookAt),this.previousTargetLookAt.copy(t),this.hasSmoothedLookAt=!0}else{const e=this.getLookAtPosition();if(this.smoothCamera){const o=1-Math.exp(-this.smoothSpeed*t),i=Math.max(0,this.teleportSnapDistance);!this.hasSmoothedLookAt||this.previousTargetLookAt.distanceToSquared(e)>i*i?this.smoothedLookAt.copy(e):this.smoothedLookAt.lerp(e,o)}else this.smoothedLookAt.copy(e);this.previousTargetLookAt.copy(e),this.hasSmoothedLookAt=!0,g.subVectors(L.position,e),this.camera.position.copy(this.smoothedLookAt).add(g),this.camera.lookAt(this.smoothedLookAt),this.prevLookAt.copy(this.smoothedLookAt)}}};t([p(),e("design:type",Number)],k.prototype,"near",void 0),t([p(),e("design:type",Number)],k.prototype,"far",void 0),t([p(),e("design:type",Number)],k.prototype,"viewAngle",void 0),t([p(),e("design:type",Boolean)],k.prototype,"collision",void 0),t([p(),e("design:type",Number)],k.prototype,"collisionSphereRadius",void 0),t([p(),e("design:type",Boolean)],k.prototype,"smoothCamera",void 0),t([p(),e("design:type",Number)],k.prototype,"smoothSpeed",void 0),t([p(),e("design:type",Number)],k.prototype,"teleportSnapDistance",void 0),k=t([i(),e("design:paramtypes",[])],k);export{k as ThirdPersonCameraComponent};const L=new r,y=new s,g=new s,A=new s,w=(new s,new s);export class ThirdPartyCameraComponent extends k{}/*
2
2
  * Copyright (©) 2026 Hology Interactive AB. All rights reserved.
3
3
  * See the LICENSE.md file for details.
4
4
  */
@@ -1,5 +1,6 @@
1
1
  import { Constructable } from 'typedi';
2
2
  import { BaseActor } from './actor.js';
3
+ export { getComponentClassById, getComponentClassId, getRegisteredComponentClasses, } from './type-registry.js';
3
4
  export declare abstract class ActorComponent<ActorType extends BaseActor = BaseActor> {
4
5
  actor: ActorType;
5
6
  constructor();
@@ -22,6 +23,8 @@ export declare abstract class ActorComponent<ActorType extends BaseActor = BaseA
22
23
  protected attach<T extends ActorComponent>(type: Constructable<T>, props?: ComponentAttachProps<T>): T;
23
24
  }
24
25
  export type ComponentOptions = {
26
+ /** Stable serialized identity. Defaults to the class name for backwards compatibility. */
27
+ typeId?: string;
25
28
  /**
26
29
  * While in the editor, only components explicitly set to be used in the editor should be initiated.
27
30
  * This is because other components may fail as there will be many things that are not