@hology/core 0.0.211 → 0.0.212
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.
- package/dist/effects/sequence/sequence-player.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +8 -1
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-collision-behaviour.js +1 -1
- package/dist/effects/vfx/vfx-defs.d.ts +10 -1
- package/dist/effects/vfx/vfx-defs.js +1 -1
- package/dist/effects/vfx/vfx-renderers.d.ts +1 -0
- package/dist/effects/vfx/vfx-renderers.js +1 -1
- package/dist/gameplay/actors/actor.d.ts +23 -1
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +23 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.d.ts +26 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement-policy.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +145 -55
- package/dist/gameplay/actors/builtin/components/character/character-movement.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts +125 -0
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +4 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.d.ts +100 -0
- package/dist/gameplay/actors/builtin/components/character/old-character-movement.js +4 -0
- package/dist/gameplay/actors/builtin/components/index.d.ts +2 -0
- package/dist/gameplay/actors/builtin/components/index.js +1 -1
- package/dist/gameplay/actors/camera/third-person-camera-component.d.ts +3 -0
- package/dist/gameplay/actors/camera/third-person-camera-component.js +1 -1
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/controller/actor-controller.d.ts +16 -0
- package/dist/gameplay/actors/controller/actor-controller.js +4 -0
- package/dist/gameplay/actors/factory.d.ts +3 -0
- package/dist/gameplay/actors/factory.js +1 -1
- package/dist/gameplay/actors/index.d.ts +4 -0
- package/dist/gameplay/actors/index.js +1 -1
- package/dist/gameplay/actors/internal/component-init.js +1 -1
- package/dist/gameplay/ai/behavior-tree/move.d.ts +2 -2
- package/dist/gameplay/index.d.ts +3 -1
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.d.ts +4 -0
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/net/browser/index.d.ts +147 -0
- package/dist/gameplay/net/browser/index.js +4 -0
- package/dist/gameplay/net/index.d.ts +7 -0
- package/dist/gameplay/net/index.js +4 -0
- package/dist/gameplay/net/net-connection.d.ts +25 -0
- package/dist/gameplay/net/net-connection.js +4 -0
- package/dist/gameplay/net/net-session.d.ts +70 -0
- package/dist/gameplay/net/net-session.js +4 -0
- package/dist/gameplay/net/service/net-actor-role.d.ts +12 -0
- package/dist/gameplay/net/service/net-actor-role.js +4 -0
- package/dist/gameplay/net/service/net-decorator.d.ts +29 -0
- package/dist/gameplay/net/service/net-decorator.js +4 -0
- package/dist/gameplay/net/service/net-serializer.d.ts +15 -0
- package/dist/gameplay/net/service/net-serializer.js +4 -0
- package/dist/gameplay/net/service/net-service.d.ts +171 -0
- package/dist/gameplay/net/service/net-service.js +4 -0
- package/dist/gameplay/net/service/net-utils.d.ts +8 -0
- package/dist/gameplay/net/service/net-utils.js +4 -0
- package/dist/gameplay/net/service/replication.d.ts +31 -0
- package/dist/gameplay/net/service/replication.js +4 -0
- package/dist/gameplay/net/service/rpc-decorator.d.ts +21 -0
- package/dist/gameplay/net/service/rpc-decorator.js +4 -0
- package/dist/gameplay/net/service/rpc.d.ts +35 -0
- package/dist/gameplay/net/service/rpc.js +4 -0
- package/dist/gameplay/services/asset-loader.d.ts +3 -2
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +2 -1
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/world.d.ts +13 -2
- package/dist/gameplay/services/world.js +1 -1
- package/dist/rendering/color-pass.js +1 -1
- package/dist/rendering.d.ts +2 -0
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/batched-mesh-2.d.ts +9 -0
- package/dist/scene/batched-mesh-2.js +1 -1
- package/dist/scene/bootstrap.d.ts +2 -0
- package/dist/scene/bootstrap.js +1 -1
- package/dist/scene/materializer.d.ts +4 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/storage/storage.d.ts +1 -1
- package/dist/scene/storage/storage.js +1 -1
- package/dist/shader/builtin/standard-shader.js +1 -1
- package/dist/shader/builtin/toon-shader.js +1 -1
- package/dist/shader/builtin/unlit-shader.js +1 -1
- package/dist/shader/color-layer.js +1 -1
- package/dist/shader/parameter.d.ts +1 -1
- package/dist/shader/parameter.js +1 -1
- package/dist/shader-nodes/depth.js +1 -1
- package/dist/shader-nodes/scene-sample.js +1 -1
- package/dist/test/batched-mesh-2.test.d.ts +2 -0
- package/dist/test/batched-mesh-2.test.js +4 -0
- package/dist/test/browser-net-session.test.d.ts +2 -0
- package/dist/test/browser-net-session.test.js +4 -0
- package/dist/test/first-person-camera-component.test.js +1 -1
- package/dist/test/net-character-movement.test.d.ts +2 -0
- package/dist/test/net-character-movement.test.js +4 -0
- package/dist/test/net-property-snapshot.test.d.ts +2 -0
- package/dist/test/net-property-snapshot.test.js +4 -0
- package/dist/test/sequence-animation-retiming.test.js +1 -1
- package/dist/test/vfx-random-color-initializer.test.d.ts +2 -0
- package/dist/test/vfx-random-color-initializer.test.js +4 -0
- package/dist/test/world-prefab-spawn.test.d.ts +2 -0
- package/dist/test/world-prefab-spawn.test.js +4 -0
- package/dist/utils/three/placeholder-texture.d.ts +3 -0
- package/dist/utils/three/placeholder-texture.js +4 -0
- package/package.json +9 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { CharacterMovementMode } from "./modes.js";
|
|
2
|
+
export declare const NET_CHARACTER_MOVEMENT_VERSION = 2;
|
|
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 type NetCharacterMove = {
|
|
28
|
+
sequence: number;
|
|
29
|
+
clientTime: number;
|
|
30
|
+
dt: number;
|
|
31
|
+
inputX: number;
|
|
32
|
+
inputY: number;
|
|
33
|
+
yaw: number;
|
|
34
|
+
flags: number;
|
|
35
|
+
clientX: number;
|
|
36
|
+
clientY: number;
|
|
37
|
+
clientZ: number;
|
|
38
|
+
rootMotionX: number;
|
|
39
|
+
rootMotionY: number;
|
|
40
|
+
rootMotionZ: number;
|
|
41
|
+
};
|
|
42
|
+
export type NetCharacterMoveBatch = {
|
|
43
|
+
moves: NetCharacterMove[];
|
|
44
|
+
};
|
|
45
|
+
export type NetCharacterMovementSnapshot = {
|
|
46
|
+
sequence: number;
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
z: number;
|
|
50
|
+
velocityX: number;
|
|
51
|
+
velocityY: number;
|
|
52
|
+
velocityZ: number;
|
|
53
|
+
yaw: number;
|
|
54
|
+
mode: CharacterMovementMode;
|
|
55
|
+
horizontalSpeed: number;
|
|
56
|
+
};
|
|
57
|
+
export type NetCharacterOwnerAck = {
|
|
58
|
+
sequence: number;
|
|
59
|
+
};
|
|
60
|
+
export type NetCharacterOwnerCorrection = {
|
|
61
|
+
snapshot: NetCharacterMovementSnapshot;
|
|
62
|
+
};
|
|
63
|
+
export type NetCharacterDecodedPacket<T> = {
|
|
64
|
+
ok: true;
|
|
65
|
+
value: T;
|
|
66
|
+
} | {
|
|
67
|
+
ok: false;
|
|
68
|
+
reason: "malformed" | "unsupported-version" | "wrong-kind";
|
|
69
|
+
};
|
|
70
|
+
export type NetCharacterServerMoveTimingState = {
|
|
71
|
+
lastClientTime: number;
|
|
72
|
+
serverTimeBudget: number;
|
|
73
|
+
};
|
|
74
|
+
export type NetCharacterServerMoveTimingOptions = {
|
|
75
|
+
maxMoveDeltaTime?: number;
|
|
76
|
+
maxServerMoveDeltaTimeScalar?: number;
|
|
77
|
+
maxClientTimeAhead?: number;
|
|
78
|
+
};
|
|
79
|
+
export declare class NetCharacterSavedMoveBuffer {
|
|
80
|
+
capacity: number;
|
|
81
|
+
maxCombinedDeltaTime: number;
|
|
82
|
+
private readonly moves;
|
|
83
|
+
private readonly freeMoves;
|
|
84
|
+
private readonly sendScratch;
|
|
85
|
+
private readonly replayScratch;
|
|
86
|
+
private pending?;
|
|
87
|
+
constructor(capacity?: number, maxCombinedDeltaTime?: number);
|
|
88
|
+
get length(): number;
|
|
89
|
+
push(move: NetCharacterMove): void;
|
|
90
|
+
ack(sequence: number): void;
|
|
91
|
+
clear(): void;
|
|
92
|
+
getMovesForSend(maxCount: number): readonly NetCharacterMove[];
|
|
93
|
+
replayAfter(sequence: number, simulator: (move: NetCharacterMove) => void, maxCount?: number): void;
|
|
94
|
+
private commitPending;
|
|
95
|
+
private trimToCapacity;
|
|
96
|
+
private acquireMove;
|
|
97
|
+
private releaseMove;
|
|
98
|
+
}
|
|
99
|
+
export declare class NetCharacterProxySmoother {
|
|
100
|
+
private readonly interpolationDelay;
|
|
101
|
+
private readonly snapDistance;
|
|
102
|
+
private readonly maxSnapshots;
|
|
103
|
+
private readonly snapshots;
|
|
104
|
+
constructor(interpolationDelay?: number, snapDistance?: number, maxSnapshots?: number);
|
|
105
|
+
push(snapshot: NetCharacterMovementSnapshot, localTime: number): void;
|
|
106
|
+
reset(snapshot?: NetCharacterMovementSnapshot, localTime?: number): void;
|
|
107
|
+
sample(localTime: number, out: NetCharacterMovementSnapshot): boolean;
|
|
108
|
+
}
|
|
109
|
+
export declare function validateNetCharacterMove(move: NetCharacterMove, lastSequence: number, maxDeltaTime?: number): boolean;
|
|
110
|
+
export declare function encodeNetCharacterMoveBatch(moves: readonly NetCharacterMove[]): Uint8Array;
|
|
111
|
+
export declare function decodeNetCharacterMoveBatch(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMoveBatch>;
|
|
112
|
+
export declare function encodeNetCharacterOwnerAck(sequence: number): Uint8Array;
|
|
113
|
+
export declare function decodeNetCharacterOwnerAck(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerAck>;
|
|
114
|
+
export declare function encodeNetCharacterOwnerCorrection(snapshot: NetCharacterMovementSnapshot): Uint8Array;
|
|
115
|
+
export declare function decodeNetCharacterOwnerCorrection(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterOwnerCorrection>;
|
|
116
|
+
export declare function encodeNetCharacterSimulatedState(snapshot: NetCharacterMovementSnapshot): Uint8Array;
|
|
117
|
+
export declare function decodeNetCharacterSimulatedState(payload: Uint8Array): NetCharacterDecodedPacket<NetCharacterMovementSnapshot>;
|
|
118
|
+
export declare function replayNetCharacterSavedMoves<TState>(baseState: TState, moves: readonly NetCharacterMove[], simulator: (state: TState, move: NetCharacterMove) => TState, maxMoves?: number): TState;
|
|
119
|
+
export declare function createNetCharacterServerMoveTimingState(): NetCharacterServerMoveTimingState;
|
|
120
|
+
export declare function accrueNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, serverDeltaTime: number, maxServerMoveTimeBudget?: number): void;
|
|
121
|
+
export declare function consumeNetCharacterServerMoveTime(state: NetCharacterServerMoveTimingState, move: NetCharacterMove, options?: NetCharacterServerMoveTimingOptions): number;
|
|
122
|
+
export declare function createNetCharacterMovementSnapshot(overrides?: Partial<NetCharacterMovementSnapshot>): NetCharacterMovementSnapshot;
|
|
123
|
+
export declare function isSequenceGreater(a: number, b: number): boolean;
|
|
124
|
+
export declare function isSequenceLessOrEqual(a: number, b: number): boolean;
|
|
125
|
+
//# 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=2;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;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.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++,2),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(2!==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 M=e.getFloat32(n,!0);n+=4;const d=e.getFloat32(n,!0);n+=4;const g=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:M,rootMotionY:d,rootMotionZ:g})}return{ok:!0,value:{moves:i}}}export function encodeNetCharacterOwnerAck(t){const e=new Uint8Array(6),n=new DataView(e.buffer);return n.setUint8(0,2),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 2!==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,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(40),o=new DataView(n.buffer);let i=0;return o.setUint8(i++,2),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.setFloat32(i,e.horizontalSpeed,!0),n}function i(t,e){if(40!==t.byteLength)return{ok:!1,reason:"malformed"};const n=u(t);let o=0;if(2!==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++),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.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.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{
|
|
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 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
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import{Container as t,Service as
|
|
1
|
+
import{Container as t,Service as o,Inject as n}from"typedi";import{_setupActorUpdateEventHandlers as e}from"./actor.js";import{activeContainerInstance as r}from"./internal/container-map.js";import{randomString as i}from"../../utils/math.js";import{actorConstructContext as a}from"./factory.js";export class ActorComponent{constructor(){this.actor=a.actor,e.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}onUpdate(t){}onLateUpdate(t){}get disposed(){return this.actor.disposed}attach(t,o){return this.actor.attach(t,o)}}ActorComponent.__isActorComponent=!0;export function Component(t={inEditor:!1,editorOnly:!1}){const n=o({transient:!0});return function(o){o.__inEditor=t.inEditor,o.__onlyEditor=t.editorOnly,n(o)}}export function Attach(o={},e){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",e,e.prototype,i);const c=e??Reflect.getMetadata("design:type",r,i);n(()=>c)(r,i,a);const s=t.handlers.find(t=>t.object===r&&t.propertyName===i&&t.index===a),p=s.value;s.value=t=>{const n=p(t);return Object.assign(n,o)}}}export function attach(o,n){const e=r.value??t.of("default"),a=i();e.set({id:a,type:o,transient:!0});const c=e.get(a);if(null!=n)for(const t of Object.keys(n))c[t]=n[t];return c}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseActor } from "../actor";
|
|
2
|
+
export declare abstract class ActorController extends BaseActor {
|
|
3
|
+
isLocallyControlled: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class BasePlayerController extends ActorController {
|
|
6
|
+
/**
|
|
7
|
+
* Whether this player controller is controlled by the local player.
|
|
8
|
+
* This is set when spawned as the local player controller on server (listend and standalone)
|
|
9
|
+
* or when the player controller is replicated to clients.
|
|
10
|
+
*/
|
|
11
|
+
isLocallyControlled: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare class BaseAIController extends ActorController {
|
|
14
|
+
readonly isLocallyControlled = false;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=actor-controller.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{BaseActor as o}from"../actor";export class ActorController extends o{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BasePlayerController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}export class BaseAIController extends ActorController{constructor(){super(...arguments),this.isLocallyControlled=!1}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -3,6 +3,9 @@ import { BaseActor } from './actor.js';
|
|
|
3
3
|
import { type EngineEnvironment } from '../env.js';
|
|
4
4
|
import { ActorProvider } from '../../scene/materializer.js';
|
|
5
5
|
import { Vector3, Euler } from "three";
|
|
6
|
+
export declare let actorConstructContext: {
|
|
7
|
+
actor: BaseActor;
|
|
8
|
+
};
|
|
6
9
|
export declare class ActorFactory implements ActorProvider<BaseActor> {
|
|
7
10
|
private container;
|
|
8
11
|
private env;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as
|
|
1
|
+
import{__decorate as t,__metadata as i}from"tslib";import{ContainerInstance as n}from"typedi";import{Service as o}from"typedi";import{initComponents as r,initComponentsSync as e}from"./internal/component-init.js";import{activeContainerInstance as c,containerRefMap as s}from"./internal/container-map.js";export let actorConstructContext={actor:null};let a=class{constructor(t,i){this.container=t,this.env=i,this.classes={}}get inEditor(){return this.env.inEditor??!1}async create(t,i,n,o){const r=this._createActor(t,i,n);return!0!==o&&await this.initActor(r),r}createSync(t,i,n,o){const r=this._createActor(t,i,n);return!0!==o&&this.initActorSync(r),r}_createActor(t,i,n){const o=this.container;c.value=o;const r=(1e4*Math.random()).toString();o.set({id:r,type:t,transient:!0});const e=o.get(r);return actorConstructContext.actor=null,c.value=null,o.remove(t),s.set(e,o),i&&e.object.position.copy(i),n&&e.object.rotation.copy(n),e}async initActor(t){await r(t,t,this.env.inEditor??!1),await t.onInit(),t.__isInitialised=!0}initActorSync(t){e(t,t,this.env.inEditor??!1),t.onInit(),t.__isInitialised=!0}};a=t([o(),i("design:paramtypes",[n,Object])],a);export{a as ActorFactory};/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -7,7 +7,11 @@ export { TriggerVolume, TriggerVolumeComponent } from './builtin/trigger-volume.
|
|
|
7
7
|
export { PositionalAudioActor, PositionalAudioComponent } from './builtin/positional-audio-actor.js';
|
|
8
8
|
export * from './builtin/components/mesh-component.js';
|
|
9
9
|
export * from './builtin/components/character/character-movement.js';
|
|
10
|
+
export * from './builtin/components/character/character-movement-policy.js';
|
|
11
|
+
export * from './builtin/components/character/old-character-movement.js';
|
|
12
|
+
export * from './builtin/components/character/character-movement-like.js';
|
|
10
13
|
export * from './builtin/components/character/modes.js';
|
|
11
14
|
export * from './builtin/components/character/character-animation.js';
|
|
15
|
+
export * from './controller/actor-controller.js';
|
|
12
16
|
export { builtInComponents } from './builtin/components/index.js';
|
|
13
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{FirstPersonCameraComponent}from"./camera/first-person-camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";export{builtInComponents}from"./builtin/components/index.js";/*
|
|
1
|
+
export{CameraActor}from"./builtin/camera-actor.js";export{CameraComponent}from"./camera/camera-component.js";export{FirstPersonCameraComponent}from"./camera/first-person-camera-component.js";export{ThirdPersonCameraComponent,ThirdPartyCameraComponent}from"./camera/third-person-camera-component.js";export{SpawnPoint}from"./builtin/spawn-point.js";export{TriggerVolume,TriggerVolumeComponent}from"./builtin/trigger-volume.js";export{PositionalAudioActor,PositionalAudioComponent}from"./builtin/positional-audio-actor.js";export*from"./builtin/components/mesh-component.js";export*from"./builtin/components/character/character-movement.js";export*from"./builtin/components/character/character-movement-policy.js";export*from"./builtin/components/character/old-character-movement.js";export*from"./builtin/components/character/character-movement-like.js";export*from"./builtin/components/character/modes.js";export*from"./builtin/components/character/character-animation.js";export*from"./controller/actor-controller.js";export{builtInComponents}from"./builtin/components/index.js";/*
|
|
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{ActorComponent as n}from"../component.js";const o=new WeakMap;export async function initComponents(n,
|
|
1
|
+
import{ActorComponent as n}from"../component.js";const o=new WeakMap;export const $actorComponents=Symbol("actor_components");export async function initComponents(n,s,e=!1){const r=[];for(const i of c(n,s,e)){if(o.has(i))continue;t(s,i),o.set(i,!0);const n=(async()=>{await i.onInit(),await initComponents(i,s,e)})();r.push(n)}return Promise.all(r)}export function initComponentsSync(n,s,e=!1){for(const r of c(n,s,e))o.has(r)||(t(s,r),o.set(r,!0),r.onInit(),initComponentsSync(r,s,e))}function t(n,o){null==n[$actorComponents]&&(n[$actorComponents]=[]),n[$actorComponents].push(o),o.__netid=n[$actorComponents].length}function c(o,t,c=!1){const s=[...Object.values(o)];o===t&&t.attachedComponents.forEach(n=>s.push(n));const e=[];for(const o of s)if(o instanceof n||null!=o?.constructor&&!0===o.constructor.__isActorComponent){const n=o;if(!isComponentEnabledInEnvironment(n,c))continue;n.actor=t,e.push(n)}return e}export function isComponentEnabledInEnvironment(n,o=!1){return!(o&&!n.constructor.__inEditor)&&!(!o&&n.constructor.__onlyEditor)}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Vector3 } from "three";
|
|
2
|
-
import {
|
|
2
|
+
import type { CharacterMovementLike } from "../../../gameplay/actors";
|
|
3
3
|
import { Navigation } from "../navigation";
|
|
4
4
|
import { LeafNode, NodeState } from "./bt";
|
|
5
5
|
export declare class CharacterMoveToNode extends LeafNode {
|
|
@@ -8,7 +8,7 @@ export declare class CharacterMoveToNode extends LeafNode {
|
|
|
8
8
|
/** At what distance from the target movement should stop */
|
|
9
9
|
distanceFrom: number;
|
|
10
10
|
target: () => Vector3 | null | undefined;
|
|
11
|
-
constructor(navigation: Navigation, movement:
|
|
11
|
+
constructor(navigation: Navigation, movement: CharacterMovementLike);
|
|
12
12
|
tick(dt: number): NodeState;
|
|
13
13
|
}
|
|
14
14
|
//# sourceMappingURL=move.d.ts.map
|
package/dist/gameplay/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from './initiate.js';
|
|
|
4
4
|
export * from './inject.js';
|
|
5
5
|
export { Service, Inject } from 'typedi';
|
|
6
6
|
export { ActorFactory } from './actors/factory.js';
|
|
7
|
-
export { Actor, BaseActor } from './actors/actor.js';
|
|
7
|
+
export { Actor, BaseActor, getActorClassById } from './actors/actor.js';
|
|
8
8
|
export { Component, ActorComponent, type ComponentOptions, attach, Attach } from './actors/component.js';
|
|
9
9
|
export * from './services/world.js';
|
|
10
10
|
export * from './services/game-time-scheduler.js';
|
|
@@ -21,4 +21,6 @@ export * from '../shader/parameter.js';
|
|
|
21
21
|
export * from './ai/index.js';
|
|
22
22
|
export * from '../effects/vfx/index.js';
|
|
23
23
|
export * from './services/shader-provider.js';
|
|
24
|
+
export * from './net/net-connection.js';
|
|
25
|
+
export * from './net/net-session.js';
|
|
24
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/gameplay/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import"reflect-metadata";export{Container as DIContainer}from"typedi";export*from"./initiate.js";export*from"./inject.js";export{Service,Inject}from"typedi";export{ActorFactory}from"./actors/factory.js";export{Actor,BaseActor}from"./actors/actor.js";export{Component,ActorComponent,attach,Attach}from"./actors/component.js";export*from"./services/world.js";export*from"./services/game-time-scheduler.js";export*from"./services/camera-shake.js";export*from"./services/render.js";export*from"./services/physics/physics-system.js";export*from"./animation/anim-sm.js";export*from"./animation/root-motion.js";export*from"./services/asset-loader.js";export*from"./services/pointer-events.js";export{VisualEffect}from"../effects/vfx/vfx-param.js";export{DataAssetRef}from"../scene/objects/data-asset.js";export*from"../shader/parameter.js";export*from"./ai/index.js";export*from"../effects/vfx/index.js";export*from"./services/shader-provider.js";/*
|
|
1
|
+
import"reflect-metadata";export{Container as DIContainer}from"typedi";export*from"./initiate.js";export*from"./inject.js";export{Service,Inject}from"typedi";export{ActorFactory}from"./actors/factory.js";export{Actor,BaseActor,getActorClassById}from"./actors/actor.js";export{Component,ActorComponent,attach,Attach}from"./actors/component.js";export*from"./services/world.js";export*from"./services/game-time-scheduler.js";export*from"./services/camera-shake.js";export*from"./services/render.js";export*from"./services/physics/physics-system.js";export*from"./animation/anim-sm.js";export*from"./animation/root-motion.js";export*from"./services/asset-loader.js";export*from"./services/pointer-events.js";export{VisualEffect}from"../effects/vfx/vfx-param.js";export{DataAssetRef}from"../scene/objects/data-asset.js";export*from"../shader/parameter.js";export*from"./ai/index.js";export*from"../effects/vfx/index.js";export*from"./services/shader-provider.js";export*from"./net/net-connection.js";export*from"./net/net-session.js";/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -4,6 +4,7 @@ import { World } from './services/world.js';
|
|
|
4
4
|
import { type DynamicResolutionOptions, type UpscalingOptions } from '../rendering.js';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
6
|
import { DetailTier } from "../scene/model.js";
|
|
7
|
+
import { NetSession } from "./net/net-session.js";
|
|
7
8
|
import type { ParameterType } from "../shader/parameter.js";
|
|
8
9
|
type GameClass<T> = Constructable<T>;
|
|
9
10
|
export type InitiateGameConfig = {
|
|
@@ -51,6 +52,9 @@ export type InitiateGameConfig = {
|
|
|
51
52
|
enabled?: boolean;
|
|
52
53
|
};
|
|
53
54
|
}>;
|
|
55
|
+
multi?: {
|
|
56
|
+
session: NetSession;
|
|
57
|
+
};
|
|
54
58
|
};
|
|
55
59
|
export declare function initiateGame<T_Game>(gameClass: GameClass<T_Game>, config: InitiateGameConfig): HologyRuntime<T_Game>;
|
|
56
60
|
export declare abstract class GameInstance {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as s}from"./actors/factory.js";import{World as n}from"./services/world.js";import{SceneMaterializer as
|
|
1
|
+
import e from"typedi";import{loadScene as t}from"../scene/bootstrap.js";import{ActorFactory as s}from"./actors/factory.js";import{World as n}from"./services/world.js";import{SceneMaterializer as o}from"../scene/materializer.js";import{ViewController as r}from"./services/render.js";import{RenderingView as i}from"../rendering.js";import{PhysicsSystem as a}from"./services/physics/physics-system.js";import{MeshComponent as c}from"./actors/builtin/components/mesh-component.js";import{builtInComponents as d}from"./actors/builtin/components/index.js";import{activeContainerInstance as m}from"./actors/internal/container-map.js";import{InputService as l}from"./input/index.js";import{RuntimeAssetsService as p}from"../scene/runtime-asset-service.js";import{AssetResourceLoader as h}from"../scene/asset-resource-loader.js";import{AssetLoader as u}from"./services/asset-loader.js";import{polyfillClient as f}from"./polyfill.js";import{Subject as g}from"rxjs";import{PointerEvents as w}from"./services/pointer-events.js";import{RuntimeBundledBackendService as b}from"../scene/runtime-bundled-backend-service.js";import{Scene as j}from"three";import{ShaderProvider as v}from"./services/shader-provider.js";import{SceneDataService as S}from"../scene/scene-data-service.js";import{NetMode as y}from"./net/net-session.js";import{AssetsProvider as x}from"../scene/assets-provider.js";export function initiateGame(g,I){if(f(),0!=I.element.childNodes.length)return console.error("Can not initialize the game with a non-empty html element"),null;e.has(r);const R=e.of("default"),P=new HologyRuntime(R),D=new s(R,{inEditor:!1});var E;D.classes=I.actors,e.set(s,D),E=I.element,Object.assign(E.style,{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",overflow:"hidden"});const M=new i(I.element,{enableXR:!0===I.xr?.enabled,maxPixelRatio:I.rendering?.maxPixelRatio,resolutionScale:I.rendering?.resolutionScale,dynamicResolution:I.rendering?.dynamicResolution,upscaling:I.rendering?.upscaling,msaa:I.rendering?.msaa,fpsCap:I.rendering?.fpsCap,depthPrepass:{enabled:!0===I.rendering?.depthPrepass?.enabled},bloom:{enabled:!1!==I?.rendering?.bloom?.enabled},reflection:{enabled:!1!==I?.rendering?.reflection?.enabled},shadows:{cascadeUpdateIntervals:[22,40,60,120]}});M.renderer.shadowMap.enabled=I.rendering?.shadows?.enabled??!0,M.renderer.shadowMap.autoUpdate=I.rendering?.shadows?.autoUpdate??!0,M.renderer.debug.checkShaderErrors=!1,e.set(i,M);const A=new r(M);e.set(r,A);const G=new b,O=new p(G),z=new h;z.setDataDir(I.dataDir),z.initKtx2(M.renderer);const C=Object.entries(I.shaders).map(([e,t])=>({name:e,type:t})),H=Object.entries(I.actors).map(([e,t])=>({name:e,type:t})),N={...d,...I.components??{}},T=Object.entries(N).map(([e,t])=>({name:e,type:t})),U=new v(C);e.set(v,U);const W=new u(z,O,C);e.set(x,O),e.set(h,z),e.set(u,W);const k=new j,F=new o(k,new S,O,z,M,C,H,D,T);F.inEditor=!1,F.netMode=I.multi?.session?.mode??y.none,e.set(o,F);const _=e.get(n);return e.set(n,_),_.materializer=F,(async()=>{const s=e.get(a);if(await s.start(),P.isShutdown)return;if(await G.preloadData(),P.isShutdown)return;if(_.scene=k,null!=I.multi?.session){const{NetService:e}=await import("./net/service/net-service.js"),t=R.get(e);t.session=I.multi.session,t.start(),P.shutdownStarted.subscribe(()=>t.stop())}const{scene:n,actors:o}=await t(M,I.sceneName,I.dataDir,I.shaders,I.actors,N,D,G,O,z,{detailTier:I.detailTier,nodeMode:I.multi?.session?.mode??y.none});_.scene=n,s.scene=_.scene;for(const e of k.children)_.scene.add(e);if(P.isShutdown)return void M.stop();e.import([c]);for(const e of o)_.addActor(e);s.addFromScene(n),console.log("Start compile shaders"),console.time("compile shaders"),await M.compileAsync(),console.timeEnd("compile shaders"),console.log("Finished compile shaders. Programs: ",M.renderer.info.programs?.length??0),console.log("Start init scene textures"),console.time("init scene textures"),M.initTextures(),console.timeEnd("init scene textures");const r=R.get(l);M.loop(e=>{r.update(e)}),P.status=5,P.shutdownStarted.subscribe(()=>{z.disposeAll()}),m.value=R,R.remove(g),R.set({id:g,type:g});const i=R.get(g);m.value=null,P.gameInstance=i,R.get(w).start(),i instanceof GameInstance&&await i.onStart(),P._resolver(!0)})(),P}export class GameInstance{onStart(){}onShutdown(){}}export function createHologyScene(){}export class HologyRuntime{constructor(e){this.containerInstance=e,this.status=0,this.isShutdown=!1,this.shutdownStarted=new g,this.ready=new Promise(e=>{this._resolver=e})}getWorld(){return this.containerInstance.get(n)}getService(e){return this.containerInstance.get(e)}shutdown(){this.isShutdown=!0;const e=this.shutdownStarted;e.next(),e.complete(),this.gameInstance instanceof GameInstance&&this.gameInstance.onShutdown(),this.containerInstance.get(l).stop();const t=this.containerInstance.get(i);t?.stop();const s=this.containerInstance.get(r);s.setMuted(!0),s.dispose();for(const e of this.getWorld().actors)this.getWorld().removeActor(e);this.containerInstance.get(a).stop(),this.containerInstance.get(o).dispose(),this.containerInstance.get(w).stop(),this.containerInstance.reset(),this.shutdownStarted.complete()}}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|