@hology/core 0.0.212 → 0.0.214
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/index.d.ts +1 -0
- package/dist/effects/sequence/index.js +1 -1
- package/dist/effects/sequence/sequence-action.d.ts +5 -0
- package/dist/effects/sequence/sequence-actor.d.ts +7 -0
- package/dist/effects/sequence/sequence-actor.js +1 -1
- package/dist/effects/sequence/sequence-animation-retiming.js +1 -1
- package/dist/effects/sequence/sequence-data.d.ts +9 -0
- package/dist/effects/sequence/sequence-data.js +1 -1
- package/dist/effects/sequence/sequence-player.d.ts +12 -1
- package/dist/effects/sequence/sequence-player.js +1 -1
- package/dist/effects/sequence/sequence-transform.d.ts +10 -0
- package/dist/effects/sequence/sequence-transform.js +4 -0
- package/dist/effects/sequence/sequence-value-lane.d.ts +2 -0
- package/dist/effects/sequence/sequence-value-lane.js +1 -1
- package/dist/effects/vfx/initializsers.d.ts +4 -0
- package/dist/effects/vfx/initializsers.js +1 -1
- package/dist/effects/vfx/vfx-actor.d.ts +5 -0
- package/dist/effects/vfx/vfx-actor.js +1 -1
- package/dist/effects/vfx/vfx-asset.d.ts +2 -1
- package/dist/effects/vfx/vfx-asset.js +1 -1
- package/dist/effects/vfx/vfx-materializer.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 +9 -5
- package/dist/gameplay/actors/actor.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-animation.d.ts +3 -0
- package/dist/gameplay/actors/builtin/components/character/character-animation.js +1 -1
- package/dist/gameplay/actors/builtin/components/character/character-movement-like.d.ts +2 -0
- package/dist/gameplay/actors/builtin/components/character/character-movement.d.ts +13 -0
- 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 +4 -1
- package/dist/gameplay/actors/builtin/components/character/net-character-movement-protocol.js +1 -1
- package/dist/gameplay/actors/builtin/components/mesh-component.d.ts +1 -0
- package/dist/gameplay/actors/builtin/components/mesh-component.js +1 -1
- package/dist/gameplay/actors/builtin/components/tween-component.js +1 -1
- package/dist/gameplay/actors/builtin/navmesh-actor.d.ts +2 -0
- package/dist/gameplay/actors/builtin/navmesh-actor.js +1 -1
- package/dist/gameplay/actors/builtin/trigger-volume.d.ts +3 -3
- package/dist/gameplay/actors/builtin/trigger-volume.js +1 -1
- package/dist/gameplay/actors/camera/camera-component.d.ts +1 -3
- package/dist/gameplay/actors/camera/camera-component.js +1 -1
- package/dist/gameplay/actors/component.d.ts +9 -0
- package/dist/gameplay/actors/component.js +1 -1
- package/dist/gameplay/actors/type-registry.d.ts +10 -0
- package/dist/gameplay/actors/type-registry.js +4 -0
- package/dist/gameplay/animation/retarget.d.ts +50 -0
- package/dist/gameplay/animation/retarget.js +4 -0
- package/dist/gameplay/animation/root-motion.js +1 -1
- package/dist/gameplay/event-graph/actor-transform-properties.d.ts +6 -0
- package/dist/gameplay/event-graph/actor-transform-properties.js +4 -0
- package/dist/gameplay/event-graph/asset-actor-types.d.ts +3 -0
- package/dist/gameplay/event-graph/asset-actor-types.js +4 -0
- package/dist/gameplay/event-graph/asset-references.d.ts +12 -0
- package/dist/gameplay/event-graph/asset-references.js +4 -0
- package/dist/gameplay/event-graph/compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/compiler.js +4 -0
- package/dist/gameplay/event-graph/decorators.d.ts +74 -0
- package/dist/gameplay/event-graph/decorators.js +4 -0
- package/dist/gameplay/event-graph/document-compiler.d.ts +107 -0
- package/dist/gameplay/event-graph/document-compiler.js +4 -0
- package/dist/gameplay/event-graph/event-graph-demo.d.ts +2 -0
- package/dist/gameplay/event-graph/event-graph-demo.js +4 -0
- package/dist/gameplay/event-graph/graph.d.ts +106 -0
- package/dist/gameplay/event-graph/graph.js +4 -0
- package/dist/gameplay/event-graph/index.d.ts +13 -0
- package/dist/gameplay/event-graph/index.js +4 -0
- package/dist/gameplay/event-graph/model.d.ts +71 -0
- package/dist/gameplay/event-graph/model.js +4 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.d.ts +115 -0
- package/dist/gameplay/event-graph/nodes/execution-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.d.ts +208 -0
- package/dist/gameplay/event-graph/nodes/gameplay-nodes.js +4 -0
- package/dist/gameplay/event-graph/nodes/index.d.ts +4 -0
- package/dist/gameplay/event-graph/nodes/index.js +4 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.d.ts +53 -0
- package/dist/gameplay/event-graph/nodes/value-nodes.js +4 -0
- package/dist/gameplay/event-graph/registry.d.ts +33 -0
- package/dist/gameplay/event-graph/registry.js +4 -0
- package/dist/gameplay/event-graph/runtime-assets.d.ts +21 -0
- package/dist/gameplay/event-graph/runtime-assets.js +4 -0
- package/dist/gameplay/event-graph/runtime.d.ts +160 -0
- package/dist/gameplay/event-graph/runtime.js +4 -0
- package/dist/gameplay/event-graph/type-inference.d.ts +41 -0
- package/dist/gameplay/event-graph/type-inference.js +4 -0
- package/dist/gameplay/event-graph/types.d.ts +77 -0
- package/dist/gameplay/event-graph/types.js +4 -0
- package/dist/gameplay/index.d.ts +15 -2
- package/dist/gameplay/index.js +1 -1
- package/dist/gameplay/initiate.js +1 -1
- package/dist/gameplay/input/input.d.ts +22 -17
- package/dist/gameplay/input/input.js +1 -1
- package/dist/gameplay/net/service/net-decorator.d.ts +1 -1
- package/dist/gameplay/net/service/net-decorator.js +1 -1
- package/dist/gameplay/net/service/net-serializer.js +1 -1
- package/dist/gameplay/net/service/net-service.d.ts +6 -6
- package/dist/gameplay/net/service/net-service.js +1 -1
- package/dist/gameplay/net/service/rpc-decorator.js +1 -1
- package/dist/gameplay/services/asset-loader.d.ts +7 -0
- package/dist/gameplay/services/asset-loader.js +1 -1
- package/dist/gameplay/services/physics/physics-system.d.ts +14 -0
- package/dist/gameplay/services/physics/physics-system.js +1 -1
- package/dist/gameplay/services/world.d.ts +12 -0
- package/dist/gameplay/services/world.js +1 -1
- package/dist/rendering.js +1 -1
- package/dist/scene/asset-resource-loader.d.ts +7 -1
- package/dist/scene/asset-resource-loader.js +1 -1
- package/dist/scene/assets-provider.d.ts +1 -0
- package/dist/scene/assets-provider.js +1 -1
- package/dist/scene/custom-param-deserialize.js +1 -1
- package/dist/scene/custom-param-runtime-types.js +1 -1
- package/dist/scene/materializer.d.ts +32 -0
- package/dist/scene/materializer.js +1 -1
- package/dist/scene/model.d.ts +114 -2
- package/dist/scene/model.js +1 -1
- package/dist/scene/objects/prefab.js +1 -1
- package/dist/scene/runtime-asset-service.d.ts +7 -1
- package/dist/scene/runtime-asset-service.js +1 -1
- package/dist/shader/graph/compiler.d.ts +3 -0
- package/dist/shader/graph/compiler.js +1 -1
- package/dist/shader/graph/model.d.ts +1 -1
- package/dist/shader/graph/registry.js +1 -1
- package/dist/test/animation-retarget.test.d.ts +2 -0
- package/dist/test/animation-retarget.test.js +4 -0
- package/dist/test/event-graph-generated-code.test.d.ts +2 -0
- package/dist/test/event-graph-generated-code.test.js +4 -0
- package/dist/test/event-graph-types.test.d.ts +2 -0
- package/dist/test/event-graph-types.test.js +4 -0
- package/dist/test/event-graph.test.d.ts +2 -0
- package/dist/test/event-graph.test.js +4 -0
- package/dist/test/input.test.d.ts +2 -0
- package/dist/test/input.test.js +4 -0
- package/dist/test/net-character-movement.test.js +1 -1
- package/dist/test/prefab-instance-params.test.js +1 -1
- package/dist/test/runtime-asset-service.test.js +1 -1
- package/dist/test/sequence-camera-control.test.js +1 -1
- package/dist/test/sequence-scene-binding.test.d.ts +2 -0
- package/dist/test/sequence-scene-binding.test.js +4 -0
- package/dist/test/sequence-transform.test.d.ts +2 -0
- package/dist/test/sequence-transform.test.js +4 -0
- package/dist/test/shader-graph.test.js +1 -1
- package/dist/test/vfx-world-space-emitter-rotation.test.d.ts +2 -0
- package/dist/test/vfx-world-space-emitter-rotation.test.js +4 -0
- package/dist/test/world-prefab-spawn.test.js +1 -1
- package/package.json +10 -2
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
*/
|
|
@@ -1,11 +1,18 @@
|
|
|
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();
|
|
6
7
|
onInit(): Promise<void> | void;
|
|
7
8
|
onBeginPlay(): void;
|
|
8
9
|
onEndPlay(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Applies saved authoring parameter changes without recreating the owning
|
|
12
|
+
* actor. Return true only when every supplied change was applied. Returning
|
|
13
|
+
* false means unsupported and must leave the component unchanged.
|
|
14
|
+
*/
|
|
15
|
+
applySceneParameters(parameters: Record<string, unknown>, changedParameters: ReadonlySet<string>): boolean | Promise<boolean>;
|
|
9
16
|
/**
|
|
10
17
|
* Code that has to run before every rendered frame. This will run after the
|
|
11
18
|
* actor's onInit method has run.
|
|
@@ -22,6 +29,8 @@ export declare abstract class ActorComponent<ActorType extends BaseActor = BaseA
|
|
|
22
29
|
protected attach<T extends ActorComponent>(type: Constructable<T>, props?: ComponentAttachProps<T>): T;
|
|
23
30
|
}
|
|
24
31
|
export type ComponentOptions = {
|
|
32
|
+
/** Stable serialized identity. Defaults to the class name for backwards compatibility. */
|
|
33
|
+
typeId?: string;
|
|
25
34
|
/**
|
|
26
35
|
* While in the editor, only components explicitly set to be used in the editor should be initiated.
|
|
27
36
|
* This is because other components may fail as there will be many things that are not
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Container as t,Service as o,Inject as
|
|
1
|
+
import{Container as t,Service as o,Inject as e}from"typedi";import{_setupActorUpdateEventHandlers as n}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";import{registerComponentClass as s}from"./type-registry.js";export{getComponentClassById,getComponentClassId,getRegisteredComponentClasses}from"./type-registry.js";export class ActorComponent{constructor(){this.actor=a.actor,n.call(this)}onInit(){}onBeginPlay(){}onEndPlay(){}applySceneParameters(t,o){return!1}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 e=o({transient:!0});return function(o){const n=arguments[1],r=t.typeId??n?.name?.toString()??o.name,i=s(r,o);null!=i&&i!==o&&console.warn(`Duplicate component class id ${r}`),o.__componentId=r,o.__inEditor=t.inEditor,o.__onlyEditor=t.editorOnly,e(o)}}export function Attach(o={},n){return function(r,i,a){if(null==r)return void Reflect.defineMetadata("design:type",n,n.prototype,i);const s=n??Reflect.getMetadata("design:type",r,i);e(()=>s)(r,i,a);const c=t.handlers.find(t=>t.object===r&&t.propertyName===i&&t.index===a),p=c.value;c.value=t=>{const e=p(t);return Object.assign(e,o)}}}export function attach(o,e){const n=r.value??t.of("default"),a=i();n.set({id:a,type:o,transient:!0});const s=n.get(a);if(null!=e)for(const t of Object.keys(e))s[t]=e[t];return s}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Type } from '../../utils/type.js';
|
|
2
|
+
import type { BaseActor } from './actor.js';
|
|
3
|
+
import type { ActorComponent } from './component.js';
|
|
4
|
+
export declare function getActorClassById(id: string): Type<BaseActor> | undefined;
|
|
5
|
+
export declare function getActorClassId(type: Function): string | undefined;
|
|
6
|
+
export declare function getRegisteredActorClasses(): ReadonlyMap<string, Type<BaseActor>>;
|
|
7
|
+
export declare function getComponentClassById(id: string): Type<ActorComponent> | undefined;
|
|
8
|
+
export declare function getComponentClassId(type: Function): string | undefined;
|
|
9
|
+
export declare function getRegisteredComponentClasses(): ReadonlyMap<string, Type<ActorComponent>>;
|
|
10
|
+
//# sourceMappingURL=type-registry.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const t=new Map,e=new Map;export function getActorClassById(e){return t.get(e)}export function getActorClassId(t){return t.__actorId}export function getRegisteredActorClasses(){return t}export function registerActorClass(e,n){const r=t.get(e);return t.set(e,n),r}export function getComponentClassById(t){return e.get(t)}export function getComponentClassId(t){return t.__componentId}export function getRegisteredComponentClasses(){return e}export function registerComponentClass(t,n){const r=e.get(t);return e.set(t,n),r}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AnimationClip, Object3D, Quaternion } from 'three';
|
|
2
|
+
import type { AnimationRetargetPose, AnimationRetargeterData, AnimationRigChain, AnimationRigData, Asset, AssetId } from '../../scene/model.js';
|
|
3
|
+
export declare const ANIMATION_RETARGET_GENERATOR_VERSION = 9;
|
|
4
|
+
export type ExtractedAnimationRig = Omit<AnimationRigData, 'previewMeshId'>;
|
|
5
|
+
export type AnimationRigExtractionResult = {
|
|
6
|
+
rigs: ExtractedAnimationRig[];
|
|
7
|
+
skinnedMeshNames: string[];
|
|
8
|
+
};
|
|
9
|
+
export type AnimationRetargetDiagnostic = {
|
|
10
|
+
severity: 'warning' | 'error';
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export type BakeRetargetedAnimationOptions = {
|
|
15
|
+
sourceRig: AnimationRigData;
|
|
16
|
+
targetRig: AnimationRigData;
|
|
17
|
+
retargeter: AnimationRetargeterData;
|
|
18
|
+
sourceObject: Object3D;
|
|
19
|
+
targetObject: Object3D;
|
|
20
|
+
clip: AnimationClip;
|
|
21
|
+
};
|
|
22
|
+
export declare function resolveAnimationRigBasisRotation(rig: AnimationRigData): Quaternion;
|
|
23
|
+
export declare function detectAnimationRigBasisRotation(rig: Pick<AnimationRigData, 'bones' | 'pelvisBoneId' | 'chains'>): Quaternion;
|
|
24
|
+
/**
|
|
25
|
+
* Extracts every distinct skeleton used by skinned meshes or represented by a
|
|
26
|
+
* standalone bone hierarchy below an object. Meshes sharing the same Skeleton
|
|
27
|
+
* instance are represented once.
|
|
28
|
+
*/
|
|
29
|
+
export declare function extractAnimationRigs(object: Object3D): AnimationRigExtractionResult;
|
|
30
|
+
export declare function areAnimationRigsCompatible(a: AnimationRigData, b: AnimationRigData): boolean;
|
|
31
|
+
export declare function validateAnimationRig(rig: AnimationRigData): AnimationRetargetDiagnostic[];
|
|
32
|
+
export declare function validateAnimationRetargeter(retargeter: AnimationRetargeterData, sourceRig: AnimationRigData, targetRig: AnimationRigData): AnimationRetargetDiagnostic[];
|
|
33
|
+
export declare function createDefaultAnimationRetargeter(sourceRigId: AssetId, targetRigId: AssetId, sourceRig: AnimationRigData, targetRig: AnimationRigData): AnimationRetargeterData;
|
|
34
|
+
export declare function createAutoAlignedRetargetPose(sourceRig: AnimationRigData, targetRig: AnimationRigData, retargeter: AnimationRetargeterData, id?: string, name?: string): AnimationRetargetPose;
|
|
35
|
+
/**
|
|
36
|
+
* Bakes a target-specific clip. The saved rig/retargeter model is Hology-owned;
|
|
37
|
+
* SkeletonUtils is intentionally isolated here so the solver can be replaced
|
|
38
|
+
* without migrating authored assets.
|
|
39
|
+
*/
|
|
40
|
+
export declare function bakeRetargetedAnimationClip(options: BakeRetargetedAnimationOptions): AnimationClip;
|
|
41
|
+
export declare function getAnimationRigIdFromObject(object: Object3D | null | undefined): AssetId | undefined;
|
|
42
|
+
export declare function getAnimationRigDataFromObject(object: Object3D | null | undefined): AnimationRigData | undefined;
|
|
43
|
+
export declare function getAnimationRigChainBoneNames(rig: AnimationRigData | null | undefined, role: AnimationRigChain['role']): string[];
|
|
44
|
+
export declare function getAnimationClipBoneNames(clip: AnimationClip): string[];
|
|
45
|
+
export declare function isAnimationClipCompatibleWithRig(clip: AnimationClip, rig: AnimationRigData): boolean;
|
|
46
|
+
export declare function getAnimationClipRigId(clip: AnimationClip | null | undefined): AssetId | undefined;
|
|
47
|
+
export declare function setAnimationClipRigId(clip: AnimationClip, rigId: AssetId | undefined): void;
|
|
48
|
+
export declare function findGeneratedAnimationOutput(assets: readonly Asset[], sourceClipId: AssetId, targetRigId: AssetId): Asset | undefined;
|
|
49
|
+
export declare function resolveAnimationClipAssetForTarget(source: Asset, assets: readonly Asset[], targetRigId?: AssetId): Asset;
|
|
50
|
+
//# sourceMappingURL=retarget.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{AnimationClip as e,AnimationMixer as n,Bone as t,LoopOnce as o,Matrix4 as r,Quaternion as i,QuaternionKeyframeTrack as a,Skeleton as s,SkinnedMesh as l,Vector3 as u,VectorKeyframeTrack as c}from"three";import*as d from"three/addons/utils/SkeletonUtils.js";export const ANIMATION_RETARGET_GENERATOR_VERSION=9;export function resolveAnimationRigBasisRotation(e){const n=e.basisPreset??"yUp";let t;t="custom"===n&&null!=e.basisRotation?(new i).fromArray(e.basisRotation).normalize():"yUp"===n?new i:"unrealZUp"===n?(new i).setFromAxisAngle(new u(1,0,0),-Math.PI/2):detectAnimationRigBasisRotation(e);const o=(e.basisYawDegrees??0)*Math.PI/180;return(new i).setFromAxisAngle(new u(0,1,0),o).multiply(t).normalize()}export function detectAnimationRigBasisRotation(e){const n=R(e,{}),t=e.bones.findIndex(n=>n.id===e.pelvisBoneId),o=e.bones.findIndex(n=>n.id===e.chains.find(e=>"neck"===e.role)?.endBoneId),r=e.chains.filter(e=>"leftLeg"===e.role||"rightLeg"===e.role).map(n=>e.bones.findIndex(e=>e.id===n.endBoneId)).filter(e=>e>=0);let a=new u;if(o>=0&&r.length>0){const e=r.reduce((e,t)=>e.add(n.worldPositions[t]),new u).multiplyScalar(1/r.length);a.copy(n.worldPositions[o]).sub(e)}else t>=0&&o>=0&&a.copy(n.worldPositions[o]).sub(n.worldPositions[t]);if(a.lengthSq()<1e-8)return new i;a.normalize();const s=[new u(Math.sign(a.x)||1,0,0),new u(0,Math.sign(a.y)||1,0),new u(0,0,Math.sign(a.z)||1)].sort((e,n)=>Math.abs(n.dot(a))-Math.abs(e.dot(a)))[0];return(new i).setFromUnitVectors(s,new u(0,1,0))}export function extractAnimationRigs(e){const n=[],o=new Set,r=new Set;e.updateMatrixWorld(!0),e.traverse(e=>{if(O(e)){for(const n of e.skeleton.bones)r.add(n);o.has(e.skeleton)||(o.add(e.skeleton),n.push({name:e.name,mesh:e,skeleton:e.skeleton}))}}),e.traverse(e=>{if(!(e instanceof t)||e.parent instanceof t)return;const o=[];e.traverse(e=>{e instanceof t&&!r.has(e)&&o.push(e)}),0!==o.length&&n.push({name:e.name,skeleton:new s(o)})});const i=new Map;for(const e of n){const n=f(e.skeleton),t=m(e.skeleton);i.set(n,Math.min(i.get(n)??Number.POSITIVE_INFINITY,t))}const a=[],l=[],u=[];for(const{name:e,mesh:t,skeleton:o}of n){const n=m(o);if(n>(i.get(f(o))??n))continue;const r=g(t,o),s=a.findIndex(e=>e.topologyFingerprint===r.topologyFingerprint&&e.bindPoseFingerprint===r.bindPoseFingerprint);s>=0?n<u[s]&&(a[s]=r,l[s]=e,u[s]=n):(a.push(r),l.push(e),u.push(n))}return{rigs:a,skinnedMeshNames:l}}export function areAnimationRigsCompatible(e,n){return e.topologyFingerprint===n.topologyFingerprint&&e.bindPoseFingerprint===n.bindPoseFingerprint}export function validateAnimationRig(e){const n=[],t=new Set(e.bones.map(e=>e.id)),o=new Map;for(const n of e.bones)o.set(n.name,(o.get(n.name)??0)+1);const r=[...o].filter(([,e])=>e>1).map(([e])=>e);r.length>0&&n.push({severity:"error",code:"duplicate-bone-names",message:`Bone names must be unique for animation tracks. Duplicates: ${r.join(", ")}`});for(const o of e.chains)t.has(o.startBoneId)&&t.has(o.endBoneId)?0===v(e,o).length&&n.push({severity:"error",code:"invalid-chain-hierarchy",message:`Chain "${o.name}" does not follow a parent-to-child hierarchy.`}):n.push({severity:"error",code:"invalid-chain-bone",message:`Chain "${o.name}" references a missing start or end bone.`});return null!=e.retargetRootBoneId&&t.has(e.retargetRootBoneId)||n.push({severity:"error",code:"missing-retarget-root",message:"Select a valid retarget root bone."}),null!=e.pelvisBoneId&&t.has(e.pelvisBoneId)||n.push({severity:"warning",code:"missing-pelvis",message:"Select a pelvis bone for reliable root-motion and height scaling."}),n}export function validateAnimationRetargeter(e,n,t){const o=[...validateAnimationRig(n).map(e=>({...e,message:`Source rig: ${e.message}`})),...validateAnimationRig(t).map(e=>({...e,message:`Target rig: ${e.message}`}))];e.sourceRigFingerprint?.topology===n.topologyFingerprint&&e.sourceRigFingerprint?.bindPose===n.bindPoseFingerprint||o.push({severity:"error",code:"source-rig-changed",message:"The source rig hierarchy or bind pose changed. Review mappings and explicitly accept the new fingerprints."}),e.targetRigFingerprint?.topology===t.topologyFingerprint&&e.targetRigFingerprint?.bindPose===t.bindPoseFingerprint||o.push({severity:"error",code:"target-rig-changed",message:"The target rig hierarchy or bind pose changed. Review mappings and explicitly accept the new fingerprints."});for(const r of e.chainMappings)!1!==r.enabled&&(n.chains.some(e=>e.id===r.sourceChainId)||o.push({severity:"error",code:"missing-source-chain",message:`Mapped source chain "${r.sourceChainId}" no longer exists.`}),t.chains.some(e=>e.id===r.targetChainId)||o.push({severity:"error",code:"missing-target-chain",message:`Mapped target chain "${r.targetChainId}" no longer exists.`}));return o}export function createDefaultAnimationRetargeter(e,n,t,o){const r=new Map(o.chains.map(e=>[e.role,e])),i=t.chains.flatMap(e=>{const n=r.get(e.role);return null==n?[]:[{sourceChainId:e.id,targetChainId:n.id,enabled:!0,rotationMode:"interpolated",translationMode:"root"===e.role?"scaled":"none"}]});return{version:1,solverVersion:9,sourceRigId:e,targetRigId:n,sourceRigFingerprint:{topology:t.topologyFingerprint,bindPose:t.bindPoseFingerprint},targetRigFingerprint:{topology:o.topologyFingerprint,bindPose:o.bindPoseFingerprint},sourcePoseId:t.defaultPoseId,targetPoseId:o.defaultPoseId,chainMappings:i,rootSettings:{scaleTranslation:!0,translationAxes:[!0,!0,!0],translationAxisMap:[1,2,3],scaleMultiplier:1},bakeSettings:{framesPerSecond:60},generatedOutputs:{}}}export function createAutoAlignedRetargetPose(e,n,t,o="auto-aligned",r="Auto Aligned"){const a=P(e,t.sourcePoseId),s=P(n,t.targetPoseId),l={...s?.rotationOffsets??{}},u=x(e,a?.rotationOffsets??{}),c=h(e,n,t),d=new Map(e.bones.map((e,n)=>[e.name,n]));new Map(n.bones.map((e,n)=>[e.name,n]));let p=x(n,l);for(let e=0;e<n.bones.length;e++){const t=n.bones[e],o=c[t.name],r=null==o?null:d.get(o);if(null==r)continue;const a=n.bones.map((e,n)=>({bone:e,index:n})).filter(n=>n.bone.parentIndex===e&&null!=c[n.bone.name]);if(1!==a.length)continue;const s=a[0],g=c[s.bone.name],m=null==g?null:d.get(g);if(null==m)continue;const f=u.worldPositions[m].clone().sub(u.worldPositions[r]),h=p.worldPositions[s.index].clone().sub(p.worldPositions[e]);if(f.lengthSq()<1e-8||h.lengthSq()<1e-8)continue;f.normalize(),h.normalize();const w=(new i).setFromUnitVectors(h,f).multiply(p.worldQuaternions[e]),b=p.parentWorldQuaternions[e].clone().invert().multiply(w);l[t.id]=(new i).fromArray(t.quaternion).invert().multiply(b).normalize().toArray(),p=x(n,l)}return{id:o,name:r,rotationOffsets:l,rootOffset:null==s?.rootOffset?void 0:[...s.rootOffset]}}export function bakeRetargetedAnimationClip(r){const p=validateAnimationRetargeter(r.retargeter,r.sourceRig,r.targetRig).filter(e=>"error"===e.severity);if(p.length>0)throw new Error(p.map(e=>e.message).join(" "));const g=S(r.sourceObject,r.sourceRig);if(null==S(r.targetObject,r.targetRig))throw new Error("The target model does not contain a skinned mesh.");r.sourceObject.updateMatrixWorld(!0);const m=F(r.sourceRig,r.sourceRig.retargetRootBoneId)??g?.skeleton.bones[0]?.name??r.sourceRig.bones.find(e=>e.parentIndex<0)?.name;if(null==m)throw new Error("The source rig has no retarget root.");const f=g?.skeleton.getBoneByName(m)??function(e,n,o){const r=[];if(e.traverse(e=>{e instanceof t&&e.name===o&&r.push(e)}),r.length<=1)return r[0];const i=new Set(n.bones.map(e=>e.name));return r.sort((e,n)=>$(n,i)-$(e,i))[0]}(r.sourceObject,r.sourceRig,m),w=f?.parent?.getWorldQuaternion(new i)??new i,b=function(e){const n=new l;n.name="RetargetSourceRig";const o=e.bones.map(e=>{const n=new t;return n.name=e.name,n.position.fromArray(e.position),n.quaternion.fromArray(e.quaternion),n.scale.fromArray(e.scale),n});for(let t=0;t<o.length;t++){const r=e.bones[t].parentIndex;r>=0?o[r].add(o[t]):n.add(o[t])}return n.bind(new s(o)),n}(r.sourceRig),y=b,I=d.clone(r.targetObject);y.quaternion.copy(resolveAnimationRigBasisRotation(r.sourceRig)).multiply(w),I.quaternion.premultiply(resolveAnimationRigBasisRotation(r.targetRig)),y.updateMatrixWorld(!0),I.updateMatrixWorld(!0);const R=S(I,r.targetRig);if(null==R)throw new Error("Failed to clone the target skeleton.");A(b,r.sourceRig,P(r.sourceRig,r.retargeter.sourcePoseId)),A(R,r.targetRig,P(r.targetRig,r.retargeter.targetPoseId));const x=h(r.sourceRig,r.targetRig,r.retargeter),v=function(t,r,s,l,u,c,d){const p=P(s,u.sourcePoseId),g=P(l,u.targetPoseId),m=new Map(t.skeleton.bones.map(e=>[e.name,e]));A(t,s,p),A(r,l,g);const f=new Map;for(const e of t.skeleton.bones)f.set(e.name,e.getWorldQuaternion(new i));const h=new Map,w=new Map;for(const e of r.skeleton.bones)h.set(e.name,e.getWorldQuaternion(new i)),w.set(e.name,{position:e.position.clone(),quaternion:e.quaternion.clone(),scale:e.scale.clone()});const b=r.skeleton.bones.flatMap(e=>{const n=d[e.name],t=null==n?null:m.get(n),o=null==n?null:f.get(n),r=h.get(e.name);return null==t||null==o||null==r?[]:[{targetBone:e,sourceBone:t,sourceReference:o,targetReference:r,times:[],values:[],previous:null}]}),y=Math.max(60,u.bakeSettings.framesPerSecond),I=Math.max(1,Math.ceil(c.duration*y)),R=I+1,x=new n(t),v=x.clipAction(c);v.setLoop(o,1),v.clampWhenFinished=!0,v.play();const k=new i,F=new i,S=new i,$=new i,O=new i;for(let e=0;e<R;e++){const n=c.duration*e/I;M(t,s),x.setTime(n),B(t,s,p),t.updateMatrixWorld(!0);for(const e of r.skeleton.bones){const n=w.get(e.name);null!=n&&(e.position.copy(n.position),e.quaternion.copy(n.quaternion),e.scale.copy(n.scale))}r.updateMatrixWorld(!0);for(const e of b)e.sourceBone.getWorldQuaternion(F),k.copy(F).multiply($.copy(e.sourceReference).invert()),S.copy(k).multiply(e.targetReference),null!=e.targetBone.parent?(e.targetBone.parent.getWorldQuaternion($).invert(),O.copy($).multiply(S)):O.copy(S),O.normalize(),null!=e.previous&&e.previous.dot(O)<0&&O.set(-O.x,-O.y,-O.z,-O.w),e.targetBone.quaternion.copy(O),e.targetBone.updateMatrixWorld(!0),e.times.push(n),e.values.push(O.x,O.y,O.z,O.w),e.previous??(e.previous=new i),e.previous.copy(O)}return x.stopAllAction(),x.uncacheRoot(t),new e(c.name,c.duration,b.map(e=>new a(`.bones[${e.targetBone.name}].quaternion`,e.times,e.values)))}(b,R,r.sourceRig,r.targetRig,r.retargeter,r.clip,x),O=F(r.targetRig,r.targetRig.retargetRootBoneId);return null!=O&&function(e,n,t,o,r,a,s,l,d){const p=e.tracks.find(e=>e instanceof c&&Q(e.name,t)),g=F(r,r.pelvisBoneId),m=F(a,a.pelvisBoneId),f=null==g||g===t?void 0:e.tracks.find(e=>e instanceof c&&Q(e.name,g));if(null==p&&null==f)return;const h=k(r),w=k(a),b=s.rootSettings.scaleTranslation&&h>0?w/h*s.rootSettings.scaleMultiplier:s.rootSettings.scaleMultiplier,y=Math.max(60,s.bakeSettings.framesPerSecond),I=Math.max(2,Math.ceil(e.duration*y)+1),R=new Float32Array(I),x=p?.createInterpolant(),v=null==x?null:Float32Array.from(x.evaluate(0)),M=f?.createInterpolant();A(l,r,P(r,s.sourcePoseId)),A(d,a,P(a,s.targetPoseId));const B=l.skeleton.getBoneByName(t),S=d.skeleton.getBoneByName(o),$=B?.parent?.getWorldQuaternion(new i)??new i,O=(S?.parent?.getWorldQuaternion(new i)??new i).invert(),q=null==g?void 0:l.skeleton.getBoneByName(g),C=null==m?void 0:d.skeleton.getBoneByName(m),W=q?.parent?.getWorldQuaternion(new i)??new i,N=(C?.parent?.getWorldQuaternion(new i)??new i).invert(),z=P(a,s.targetPoseId)?.rootOffset??[0,0,0],T=a.bones.find(e=>e.name===o),j=(T?.position??[0,0,0]).map((e,n)=>e+z[n]),E=null==m?void 0:a.bones.find(e=>e.name===m),D=m===o?j:E?.position??[0,0,0],L=null!=p||null!=f&&m===o?new Float32Array(3*I):null,_=null!=f&&null!=m&&m!==o?new Float32Array(3*I):null,U=new u,G=new u,H=new u,V=new u,Y=(e,n,t)=>{G.copy(e).applyQuaternion(n),H.set(0,0,0);for(let e=0;e<3;e++)if(s.rootSettings.translationAxes[e]){const n=s.rootSettings.translationAxisMap?.[e]??e+1,t=Math.max(0,Math.min(2,Math.abs(n)-1));H.setComponent(e,G.getComponent(t)*Math.sign(n||1))}return V.copy(H).applyQuaternion(t).multiplyScalar(b)};for(let n=0;n<I;n++){const t=Math.min(e.duration,n/y);if(R[n]=t,null!=L&&(L.set(j,3*n),null!=x&&null!=v)){const e=x.evaluate(t);U.set(e[0]-v[0],e[1]-v[1],e[2]-v[2]);const o=Y(U,$,O);L[3*n]+=o.x,L[3*n+1]+=o.y,L[3*n+2]+=o.z}if(null!=M&&null!=q&&null!=m){const e=M.evaluate(t);U.set(e[0]-q.position.x,e[1]-q.position.y,e[2]-q.position.z);const r=m===o,i=Y(U,W,r?O:N),a=r?L:_;null!=a&&(r||a.set(D,3*n),a[3*n]+=i.x,a[3*n+1]+=i.y,a[3*n+2]+=i.z)}}const Z=new Set([null==L?null:o,null==_?null:m].filter(e=>null!=e));n.tracks=n.tracks.filter(e=>!(e instanceof c&&[...Z].some(n=>Q(e.name,n)))),null!=L&&n.tracks.push(new c(`.bones[${o}].position`,R,L));null!=_&&null!=m&&n.tracks.push(new c(`.bones[${m}].position`,R,_))}(r.clip,v,m,O,r.sourceRig,r.targetRig,r.retargeter,b,R),v.name=r.clip.name,v.optimize(),v}export function getAnimationRigIdFromObject(e){if(null==e)return;let n=e.userData?.animationRigId;return null!=n||e.traverse(e=>{n??(n=e.userData?.animationRigId)}),n}export function getAnimationRigDataFromObject(e){if(null==e)return;let n=e.userData?.animationRig;return null!=n||e.traverse(e=>{n??(n=e.userData?.animationRig)}),n}export function getAnimationRigChainBoneNames(e,n){if(null==e)return[];const t=e.chains.find(e=>e.role===n);return null==t?[]:v(e,t).map(e=>e.name)}export function getAnimationClipBoneNames(e){const n=new Set;for(const t of e.tracks){const e=t.name.match(/\.bones\[([^\]]+)\]\./);if(null!=e?.[1]){n.add(e[1]);continue}const o=t.name.lastIndexOf(".");o>0&&n.add(t.name.slice(0,o))}return[...n]}export function isAnimationClipCompatibleWithRig(e,n){const t=new Set(n.bones.map(e=>e.name));return getAnimationClipBoneNames(e).some(e=>t.has(e))}export function getAnimationClipRigId(e){return null==e?void 0:j.get(e)}export function setAnimationClipRigId(e,n){null==n?j.delete(e):j.set(e,n)}export function findGeneratedAnimationOutput(e,n,t){for(const o of e){const r=o.animationRetargeter;if("animationRetargeter"===o.type&&r?.targetRigId===t&&null!=r.generatedOutputs[n]){const t=r.generatedOutputs[n];return e.find(e=>e.id===t)}}}export function resolveAnimationClipAssetForTarget(e,n,t){if(null==t||e.anim?.rigId===t)return e;if(null==e.anim?.rigId){const n=`${e.id}|${t}`;return p.has(n)||(p.add(n),console.warn(`Animation clip "${e.name}" (${e.id}) has no rig assigned, while the target uses rig ${t}. Playing the legacy source clip without rig compatibility validation.`)),e}const o=findGeneratedAnimationOutput(n,e.id,t);if(null==o)throw new Error(`Animation clip "${e.name}" (${e.id}) targets rig ${e.anim?.rigId??"unassigned"}, but the bound sequence actor uses rig ${t}. Generate this source/target output in an Animation Retargeter before playback.`);if(o.anim?.rigId!==t)throw new Error(`Generated animation clip "${o.name}" (${o.id}) is indexed for rig ${t}, but its clip metadata targets ${o.anim?.rigId??"no rig"}. Regenerate the output.`);return o}const p=new Set;function g(e,n){const o=new Map(n.bones.map((e,n)=>[e,n])),a=new Set(n.bones.filter(e=>function(e,n,o){const r=e.parent;if(!(r instanceof t&&r.name===e.name&&o.has(r)))return!1;if(e.position.lengthSq()>1e-12||Math.abs(e.quaternion.x)>1e-6||Math.abs(e.quaternion.y)>1e-6||Math.abs(e.quaternion.z)>1e-6||Math.abs(Math.abs(e.quaternion.w)-1)>1e-6||e.scale.distanceTo(new u(1,1,1))>1e-6)return!1;const i=n.boneInverses[o.get(e)],a=n.boneInverses[o.get(r)];return null!=i&&null!=a&&(s=i,l=a,s.elements.every((e,n)=>Math.abs(e-l.elements[n])<=1e-6));var s,l}(e,n,o))),s=n.bones.filter(e=>!a.has(e)),l=new Map(s.map((e,n)=>[e,n])),c=[];for(let e=0;e<s.length;e++){const a=s[e],d=o.get(a)??e;let p=a.parent;for(;p instanceof t&&!l.has(p);)p=p.parent;const g=p instanceof t?l.get(p)??-1:-1,m=a.name||`bone_${e}`,f=g<0?m:`${c[g].id}/${m}`,h=new u,w=new i,b=new u;a.matrix.decompose(h,w,b),c.push({id:f,name:m,parentIndex:g,position:h.toArray(),quaternion:w.toArray(),scale:b.toArray(),inverseBindMatrix:(n.boneInverses[d]??new r).toArray()})}const d=T(c.map(e=>[e.name,e.parentIndex])),p=T(c.map(e=>[e.name,e.parentIndex,...z(e.position),...z(e.quaternion),...z(e.scale),...z(e.inverseBindMatrix)])),g=function(e){const n=[{role:"spine",start:["spine"],end:["chest","spine2","spine_02","spine3"]},{role:"neck",start:["neck"],end:["head"]},{role:"leftArm",side:"left",start:["upperarm","arm"],end:["hand","wrist"]},{role:"rightArm",side:"right",start:["upperarm","arm"],end:["hand","wrist"]},{role:"leftLeg",side:"left",start:["upleg","thigh","upperleg"],end:["foot","ankle"]},{role:"rightLeg",side:"right",start:["upleg","thigh","upperleg"],end:["foot","ankle"]}],t=[];for(const o of n){const n=o.side?C(e,o.side,o.start):q(e,o.start),r=o.side?C(e,o.side,o.end):q(e,o.end);null!=n&&null!=r&&t.push({id:o.role,name:N(o.role),role:o.role,startBoneId:n.id,endBoneId:r.id})}return t}(c),m=q(c,["root","armature"]),f=q(c,["hips","hip","pelvis"]),h=C(c,"left",["hand","wrist"]),w=C(c,"right",["hand","wrist"]);return{version:1,basisPreset:"auto",basisYawDegrees:0,skinnedMeshName:e?.name||void 0,bones:c,topologyFingerprint:d,bindPoseFingerprint:p,retargetRootBoneId:m?.id??f?.id??c[0]?.id,pelvisBoneId:f?.id,leftHandBoneId:h?.id,rightHandBoneId:w?.id,chains:g,poses:[{id:"default",name:"Default",rotationOffsets:{}}],defaultPoseId:"default"}}function m(e){const n=new Set(e.bones);return e.bones.filter(e=>e.parent instanceof t&&!n.has(e.parent)).length}function f(e){return[...new Set(e.bones.map(e=>e.name))].sort().join("\n")}function h(e,n,t){const o={};for(const r of t.chainMappings){if(!1===r.enabled)continue;const t=e.chains.find(e=>e.id===r.sourceChainId),i=n.chains.find(e=>e.id===r.targetChainId);if(null==t||null==i)continue;const a=v(e,t),s=v(n,i);if(0!==a.length&&0!==s.length)for(let e=0;e<s.length;e++){const n=1===s.length?0:e/(s.length-1),t=Math.round(n*(a.length-1));o[s[e].name]=a[t].name}}return w(o,e,n,"retargetRootBoneId"),w(o,e,n,"pelvisBoneId"),w(o,e,n,"leftHandBoneId"),w(o,e,n,"rightHandBoneId"),b(o,e,n,"leftHandBoneId"),b(o,e,n,"rightHandBoneId"),o}function w(e,n,t,o){const r=F(n,n[o]),i=F(t,t[o]);null!=r&&null!=i&&(e[i]=r)}function b(e,n,t,o){const r=n.bones.findIndex(e=>e.id===n[o]),i=t.bones.findIndex(e=>e.id===t[o]);if(r<0||i<0)return;const a=new Map;for(const e of y(n,r)){const n=I(e.name);null!=n&&a.set(n,e)}for(const n of y(t,i)){const t=I(n.name),o=null==t?null:a.get(t);null!=o&&(e[n.name]=o.name)}}function y(e,n){return e.bones.filter((t,o)=>{let r=e.bones[o].parentIndex;for(;r>=0;){if(r===n)return!0;r=e.bones[r].parentIndex}return!1})}function I(e){const n=e.toLowerCase();if(n.includes("base"))return null;const t=["thumb","index","middle","ring","pinky"].find(e=>n.includes(e));if(null==t)return null;const o=n.slice(n.indexOf(t)+t.length),r=o.match(/\d+/)?.[0];return null==r?null:`${t}:${Number(r)}`}function R(e,n){const t=[],o=[],a=[],s=[];for(let l=0;l<e.bones.length;l++){const c=e.bones[l],d=(new i).fromArray(c.quaternion),p=d.clone(),g=n[c.id];null!=g&&p.multiply((new i).fromArray(g)).normalize();const m=(new r).compose((new u).fromArray(c.position),p,(new u).fromArray(c.scale));let f;if(c.parentIndex>=0)f=t[c.parentIndex],m.premultiply(f);else{const e=(new r).compose((new u).fromArray(c.position),d,(new u).fromArray(c.scale));f=(new r).fromArray(c.inverseBindMatrix).invert().multiply(e.invert()),m.premultiply(f)}t.push(m),o.push((new u).setFromMatrixPosition(m)),a.push((new i).setFromRotationMatrix(m)),s.push((new i).setFromRotationMatrix(f))}return{worldPositions:o,worldQuaternions:a,parentWorldQuaternions:s}}function x(e,n){const t=R(e,n),o=resolveAnimationRigBasisRotation(e);for(const e of t.worldPositions)e.applyQuaternion(o);for(const e of t.worldQuaternions)e.premultiply(o);for(const e of t.parentWorldQuaternions)e.premultiply(o);return t}function v(e,n){const t=e.bones.findIndex(e=>e.id===n.startBoneId),o=e.bones.findIndex(e=>e.id===n.endBoneId);if(t<0||o<0)return[];const r=[];let i=o;for(;i>=0;){if(r.push(e.bones[i]),i===t)return r.reverse();i=e.bones[i].parentIndex}return[]}function A(e,n,t){M(e,n),B(e,n,t),e.updateMatrixWorld(!0)}function M(e,n){const t=new Map(e.skeleton.bones.map(e=>[e.name,e]));for(const e of n.bones){const n=t.get(e.name);null!=n&&(n.position.fromArray(e.position),n.quaternion.fromArray(e.quaternion),n.scale.fromArray(e.scale))}}function B(e,n,t){if(null==t)return;const o=new Map(e.skeleton.bones.map(e=>[e.name,e]));for(const[e,r]of Object.entries(t.rotationOffsets)){const t=n.bones.find(n=>n.id===e),a=null==t?void 0:o.get(t.name);null!=a&&a.quaternion.multiply((new i).fromArray(r)).normalize()}const r=F(n,n.retargetRootBoneId),a=null==r?void 0:o.get(r);null!=a&&null!=t.rootOffset&&a.position.add((new u).fromArray(t.rootOffset))}function k(e){const n=e.bones.map(()=>new r),t=e.bones.map(()=>new u);for(let o=0;o<e.bones.length;o++){const r=e.bones[o];n[o].compose((new u).fromArray(r.position),(new i).fromArray(r.quaternion),(new u).fromArray(r.scale)),r.parentIndex>=0&&n[o].premultiply(n[r.parentIndex]),t[o].setFromMatrixPosition(n[o])}const o=e.bones.findIndex(n=>n.id===e.pelvisBoneId),a=e.bones.findIndex(n=>n.id===e.chains.find(e=>"neck"===e.role)?.endBoneId),s=e.chains.filter(e=>"leftLeg"===e.role||"rightLeg"===e.role).map(n=>e.bones.findIndex(e=>e.id===n.endBoneId)).filter(e=>e>=0);if(o>=0&&a>=0&&s.length>0){const e=t[o].distanceTo(t[a]),n=Math.max(...s.map(e=>t[o].distanceTo(t[e])));if(e+n>1e-4)return e+n}let l=0;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)l=Math.max(l,t[e].distanceTo(t[n]));return Math.max(1e-4,l)}function P(e,n){return e.poses.find(e=>e.id===n)}function F(e,n){return null==n?void 0:e.bones.find(e=>e.id===n)?.name}function S(e,n){const t=[];if(e.traverse(e=>{O(e)&&t.push(e)}),null==n)return t[0];const o=null==n.skinnedMeshName?void 0:t.find(e=>e.name===n.skinnedMeshName);if(null!=o)return o;const r=t.map(e=>({candidate:e,rig:g(e,e.skeleton)}));return r.find(e=>e.rig.topologyFingerprint===n.topologyFingerprint&&e.rig.bindPoseFingerprint===n.bindPoseFingerprint)?.candidate??r.find(e=>e.rig.topologyFingerprint===n.topologyFingerprint)?.candidate??t[0]}function $(e,n){let o=0;return e.traverse(e=>{e instanceof t&&n.has(e.name)&&o++}),o}function O(e){return e instanceof l||!0===e.isSkinnedMesh}function q(e,n){return e.find(e=>n.some(n=>W(e.name)===W(n)))??e.find(e=>n.some(n=>W(e.name).includes(W(n))))}function C(e,n,t){const o="left"===n?["left","_l",".l"]:["right","_r",".r"];return e.find(e=>{const n=e.name.toLowerCase(),r=W(n);return o.some(e=>n.includes(e))&&t.some(e=>r.includes(W(e)))})}function W(e){return e.toLowerCase().replace(/^mixamorig[:_]?/,"").replace(/^bip0*1[_:]?/,"").replace(/[^a-z0-9]/g,"")}function N(e){return e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/^./,e=>e.toUpperCase())}function z(e){return e.map(e=>Math.round(1e5*e)/1e5)}function T(e){const n=JSON.stringify(e);let t=2166136261;for(let e=0;e<n.length;e++)t^=n.charCodeAt(e),t=Math.imul(t,16777619);return(t>>>0).toString(16).padStart(8,"0")}function Q(e,n){return e===`${n}.position`||e===`.bones[${n}].position`||e.endsWith(`[${n}].position`)}const j=new WeakMap;/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{AnimationClip as o,Vector3 as t}from"three";export class RootMotionClip extends o{constructor(){super(...arguments),this.displacement=0,this.fixedInPlace=!1}static fromClip(o,
|
|
1
|
+
import{AnimationClip as o,Vector3 as t}from"three";import{getAnimationClipRigId as e,setAnimationClipRigId as n}from"./retarget.js";export class RootMotionClip extends o{constructor(){super(...arguments),this.displacement=0,this.fixedInPlace=!1}static fromClip(o,i=!1,r){const s=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);if(s.fixedInPlace=i,s.rootBone=r,s.source=o,s.uuid=o.uuid,n(s,e(o)),s.motionTrack=null!=r?o.tracks.find(o=>o.name===`${r.name}.position`):o.tracks.find(o=>o.name.endsWith(".position")),s.motionTrack){s.tracks.splice(s.tracks.indexOf(s.motionTrack),1);const o=(new t).fromArray(s.motionTrack.values,0),e=(new t).fromArray(s.motionTrack.values,s.motionTrack.values.length-3),n=s.motionTrack.clone();for(let o=0;o<s.motionTrack.values.length;o+=3)n.values[o+0]=0,n.values[o+2]=0;s.tracks.push(n),s.displacement=e.distanceTo(o)}else console.error("Could not find root motion track",o,r);return s}static fromClipWithDistance(o,t){const i=new RootMotionClip(o.name,o.duration,o.tracks.slice(),o.blendMode);return i.fixedInPlace=!0,i.source=o,i.uuid=o.uuid,n(i,e(o)),i.displacement=t,i}clone(){const o=RootMotionClip.fromClip(this.source.clone(),this.fixedInPlace,this.rootBone);return o.displacement=this.displacement,o}}let i=53912381;export class BoneLayer{constructor(){this.uuid=i++,this.order=0,this.boneMask=[]}}/*
|
|
2
2
|
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
3
|
* See the LICENSE.md file for details.
|
|
4
4
|
*/
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { EventGraphPropertyInfo } from './decorators.js';
|
|
2
|
+
export type EventGraphActorTransformProperty = 'position' | 'rotation' | 'scale';
|
|
3
|
+
export declare const EVENT_GRAPH_ACTOR_TRANSFORM_PROPERTIES: readonly EventGraphPropertyInfo[];
|
|
4
|
+
export declare function getEventGraphActorTransformPropertyInfo(property: string): EventGraphPropertyInfo | undefined;
|
|
5
|
+
export declare function isEventGraphActorTransformProperty(property: string): property is EventGraphActorTransformProperty;
|
|
6
|
+
//# sourceMappingURL=actor-transform-properties.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{EVENT_GRAPH_ROTATION_TYPE as e,EVENT_GRAPH_VECTOR3_TYPE as t}from"./types.js";export const EVENT_GRAPH_ACTOR_TRANSFORM_PROPERTIES=Object.freeze([Object.freeze({propertyName:"position",label:"Position",type:t,writable:!0}),Object.freeze({propertyName:"rotation",label:"Rotation",type:e,writable:!0}),Object.freeze({propertyName:"scale",label:"Scale",type:t,writable:!0})]);export function getEventGraphActorTransformPropertyInfo(e){return EVENT_GRAPH_ACTOR_TRANSFORM_PROPERTIES.find(t=>t.propertyName===e)}export function isEventGraphActorTransformProperty(e){return"position"===e||"rotation"===e||"scale"===e}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EventGraphAssetReference, EventGraphDocument } from './model.js';
|
|
2
|
+
export interface EventGraphAssetReferenceLocation {
|
|
3
|
+
reference: EventGraphAssetReference;
|
|
4
|
+
path: readonly (string | number)[];
|
|
5
|
+
nodeId?: string;
|
|
6
|
+
portId?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Visits every tagged asset reference persisted in an event graph. */
|
|
9
|
+
export declare function visitEventGraphAssetReferences(graph: EventGraphDocument, visit: (location: EventGraphAssetReferenceLocation) => void): void;
|
|
10
|
+
export declare function collectEventGraphAssetReferences(graph: EventGraphDocument): EventGraphAssetReferenceLocation[];
|
|
11
|
+
export declare function isEventGraphAssetReference(value: unknown): value is EventGraphAssetReference;
|
|
12
|
+
//# sourceMappingURL=asset-references.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export function visitEventGraphAssetReferences(s,t){for(let n=0;n<(s.variables?.length??0);n++){const r=s.variables[n].defaultValue;void 0!==r&&e(r,["variables",n,"defaultValue"],t)}for(const n of s.nodes){null!=n.params&&e(n.params,["nodes",n.id,"params"],e=>t({...e,nodeId:n.id}));for(const[s,r]of Object.entries(n.inputs??{}))"value"in r&&e(r.value,["nodes",n.id,"inputs",s,"value"],e=>{t({...e,nodeId:n.id,portId:s})})}}export function collectEventGraphAssetReferences(e){const s=[];return visitEventGraphAssetReferences(e,e=>s.push(e)),s}export function isEventGraphAssetReference(e){if(null==e||Array.isArray(e)||"object"!=typeof e)return!1;const s=e;return"string"==typeof s.assetId&&s.assetId.length>0&&("prefab"===s.assetType||"vfx"===s.assetType||"sequence"===s.assetType)}function e(s,t,n){if(isEventGraphAssetReference(s))n({reference:s,path:t});else if(Array.isArray(s))s.forEach((s,r)=>e(s,[...t,r],n));else if(null!=s&&"object"==typeof s)for(const[r,a]of Object.entries(s))e(a,[...t,r],n)}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { DataOutput, ExecutionNode, PureNode, type DataCompileResult, type ValueInput } from './graph.js';
|
|
2
|
+
export type CompiledStatement = {
|
|
3
|
+
kind: 'code';
|
|
4
|
+
code: string;
|
|
5
|
+
} | {
|
|
6
|
+
kind: 'if';
|
|
7
|
+
condition: string;
|
|
8
|
+
whenTrue: CompileBlock;
|
|
9
|
+
whenFalse: CompileBlock;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'switch';
|
|
12
|
+
expression: string;
|
|
13
|
+
cases: ReadonlyArray<{
|
|
14
|
+
match: string;
|
|
15
|
+
block: CompileBlock;
|
|
16
|
+
}>;
|
|
17
|
+
defaultCase?: CompileBlock;
|
|
18
|
+
} | {
|
|
19
|
+
kind: 'parallel';
|
|
20
|
+
branches: ReadonlyArray<CompileBlock>;
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'forEach';
|
|
23
|
+
arrayExpression: string;
|
|
24
|
+
arrayVariable: string;
|
|
25
|
+
indexVariable: string;
|
|
26
|
+
elementOutput: string;
|
|
27
|
+
indexOutput: string;
|
|
28
|
+
body: CompileBlock;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'forLoop';
|
|
31
|
+
firstIndexExpression: string;
|
|
32
|
+
lastIndexExpression: string;
|
|
33
|
+
firstIndexVariable: string;
|
|
34
|
+
lastIndexVariable: string;
|
|
35
|
+
indexVariable: string;
|
|
36
|
+
indexOutput: string;
|
|
37
|
+
body: CompileBlock;
|
|
38
|
+
} | {
|
|
39
|
+
kind: 'try';
|
|
40
|
+
attempt: string;
|
|
41
|
+
catchVariable: string;
|
|
42
|
+
recover?: string;
|
|
43
|
+
succeeded: string;
|
|
44
|
+
success: CompileBlock;
|
|
45
|
+
error: CompileBlock;
|
|
46
|
+
} | {
|
|
47
|
+
kind: 'completion';
|
|
48
|
+
actorExpression: string;
|
|
49
|
+
eventNodeId: string;
|
|
50
|
+
body: CompileBlock;
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'runtimeCallback';
|
|
53
|
+
callee: string;
|
|
54
|
+
arguments: readonly string[];
|
|
55
|
+
eventNodeId: string;
|
|
56
|
+
body: CompileBlock;
|
|
57
|
+
callbackValueOutput?: string;
|
|
58
|
+
returnValueOutput?: string;
|
|
59
|
+
};
|
|
60
|
+
export interface CompiledExecution {
|
|
61
|
+
source: string;
|
|
62
|
+
async: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare class CompileBlock {
|
|
65
|
+
readonly statements: CompiledStatement[];
|
|
66
|
+
readonly resolving: Set<PureNode>;
|
|
67
|
+
private values;
|
|
68
|
+
constructor(parent?: CompileBlock);
|
|
69
|
+
emit(code: string): void;
|
|
70
|
+
getValue(node: PureNode): DataCompileResult | undefined;
|
|
71
|
+
setValue(node: PureNode, result: DataCompileResult): void;
|
|
72
|
+
invalidateValues(): void;
|
|
73
|
+
fork(): CompileBlock;
|
|
74
|
+
}
|
|
75
|
+
export declare class CompilationContext {
|
|
76
|
+
private readonly compiler;
|
|
77
|
+
readonly block: CompileBlock;
|
|
78
|
+
constructor(compiler: Compiler, block: CompileBlock);
|
|
79
|
+
get(value: ValueInput): string;
|
|
80
|
+
getOutputVariable(output: DataOutput): string;
|
|
81
|
+
getVariableName(variable: string): string;
|
|
82
|
+
variable(): number;
|
|
83
|
+
}
|
|
84
|
+
export declare class Compiler {
|
|
85
|
+
private outputVariables;
|
|
86
|
+
private variableDeclarations;
|
|
87
|
+
private variableNumber;
|
|
88
|
+
private requiresAsync;
|
|
89
|
+
resolveValue(value: ValueInput, block: CompileBlock): string;
|
|
90
|
+
private getPureOutput;
|
|
91
|
+
getOutputVariable(output: DataOutput): string;
|
|
92
|
+
/** Get the generated local that can be assigned to for a graph variable. */
|
|
93
|
+
getVariableName(variable: string): string;
|
|
94
|
+
build(start: ExecutionNode): string;
|
|
95
|
+
compile(start: ExecutionNode): CompiledExecution;
|
|
96
|
+
private compileExecutionNode;
|
|
97
|
+
private compileRoute;
|
|
98
|
+
private compileContinuation;
|
|
99
|
+
private compilePort;
|
|
100
|
+
private emitBlock;
|
|
101
|
+
private emitStatement;
|
|
102
|
+
private indent;
|
|
103
|
+
private identifier;
|
|
104
|
+
private reset;
|
|
105
|
+
variable(): number;
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{DataOutput as e,ExecutionNode as t,PureNode as i}from"./graph.js";export class CompileBlock{constructor(e){this.statements=[],this.resolving=new Set,this.values=new Map(e?.values)}emit(e){e.length>0&&this.statements.push({kind:"code",code:e})}getValue(e){return this.values.get(e)}setValue(e,t){this.values.set(e,t)}invalidateValues(){this.values.clear()}fork(){return new CompileBlock(this)}}export class CompilationContext{constructor(e,t){this.compiler=e,this.block=t}get(e){return this.compiler.resolveValue(e,this.block)}getOutputVariable(e){return this.compiler.getOutputVariable(e)}getVariableName(e){return this.compiler.getVariableName(e)}variable(){return this.compiler.variable()}}export class Compiler{constructor(){this.outputVariables=new Map,this.variableDeclarations=new Map,this.variableNumber=0,this.requiresAsync=!1}resolveValue(n,r){if(n instanceof e){if(n.node instanceof i)return this.getPureOutput(n.node,n.name,r);if(n.node instanceof t)return this.getOutputVariable(n);throw new Error(`Unsupported output owner for ${JSON.stringify(n.name)}`)}if(n instanceof i)return this.getPureOutput(n,"value",r);const o=JSON.stringify(n);if(null==o)throw new Error("Event graph value cannot be serialized to JavaScript");return o}getPureOutput(e,t,i){let n=i.getValue(e);if(null==n){if(i.resolving.has(e))throw new Error(`Circular data dependency at ${e.constructor.name}`);i.resolving.add(e);try{n=e.compileData(new CompilationContext(this,i)),null!=n.setup&&i.emit(n.setup),i.setValue(e,n)}finally{i.resolving.delete(e)}}const r=n.outputs[t];if(null==r)throw new Error(`${e.constructor.name} did not compile an output named ${JSON.stringify(t)}`);return r}getOutputVariable(e){if(!(e.node instanceof t))throw new Error("Only execution nodes need storage for their data outputs");let i=this.outputVariables.get(e);return null==i&&(i=`out_${this.identifier(e.name)}_${this.variable()}`,this.outputVariables.set(e,i)),i}getVariableName(e){let t=this.variableDeclarations.get(e);return null==t&&(t=`v_${this.identifier(e)}_${this.variable()}`,this.variableDeclarations.set(e,t)),t}build(e){return this.compile(e).source}compile(e){this.reset();const t=new CompileBlock;this.compileExecutionNode(e,new Set,t);const i=this.emitBlock(t),n=[...this.variableDeclarations.values(),...this.outputVariables.values()];return{source:(n.length>0?`let ${n.join(", ")}\n`:"")+i,async:this.requiresAsync}}compileExecutionNode(e,t,i){if(t.has(e)){const t=e.id??e.constructor.name;throw new Error(`Unstructured execution cycle at ${JSON.stringify(t)}. Use a loop node that compiles to native JavaScript control flow.`)}t.add(e);try{const n=new CompilationContext(this,i),r=e.compileExecution(n);if(null!=r.chunk&&i.emit(r.chunk),null!=r.done&&(i.emit(`await ${r.done}`),this.requiresAsync=!0,i.invalidateValues()),!0===r.requiresAsync&&(this.requiresAsync=!0),!0===r.invalidatesValues&&i.invalidateValues(),null==r.route){const n=[...e.getExecutionOutputs().keys()].filter(e=>"then"!==e);if(n.length>0)throw new Error(`${e.constructor.name} connects named execution outputs ${n.map(e=>JSON.stringify(e)).join(", ")} but does not compile a route for them.`);this.compilePort(e,"then",t,i)}else this.compileRoute(e,r.route,t,i)}finally{t.delete(e)}}compileRoute(e,t,i,n){if("branch"===t.kind){const r=n.fork(),o=n.fork();return this.compilePort(e,t.truePort,i,r),this.compilePort(e,t.falsePort,i,o),n.statements.push({kind:"if",condition:t.condition,whenTrue:r,whenFalse:o}),void this.compileContinuation(e,t.continuationPort,i,n)}if("select"===t.kind){const r=t.cases.map(({match:t,port:r})=>{const o=n.fork();return this.compilePort(e,r,i,o),{match:t,block:o}});let o;return null!=t.defaultPort&&(o=n.fork(),this.compilePort(e,t.defaultPort,i,o)),n.statements.push({kind:"switch",expression:t.expression,cases:r,defaultCase:o}),void this.compileContinuation(e,t.continuationPort,i,n)}if("parallel"===t.kind){this.requiresAsync=!0;const r=t.ports.map(t=>{const r=n.fork();return this.compilePort(e,t,i,r),r}).filter(e=>e.statements.length>0);return r.length>0&&(n.statements.push({kind:"parallel",branches:r}),n.invalidateValues()),void this.compilePort(e,t.continuationPort,i,n)}if("sequence"===t.kind){for(const r of t.ports)n.invalidateValues(),this.compilePort(e,r,i,n);return void this.compileContinuation(e,t.continuationPort,i,n)}if("forEach"===t.kind){const r=n.fork();return r.invalidateValues(),this.compilePort(e,t.bodyPort,i,r),n.statements.push({kind:"forEach",arrayExpression:t.arrayExpression,arrayVariable:`array_${this.variable()}`,indexVariable:`index_${this.variable()}`,elementOutput:t.elementOutput,indexOutput:t.indexOutput,body:r}),n.invalidateValues(),void this.compilePort(e,t.continuationPort,i,n)}if("forLoop"===t.kind){const r=n.fork();return r.invalidateValues(),this.compilePort(e,t.bodyPort,i,r),n.statements.push({kind:"forLoop",firstIndexExpression:t.firstIndexExpression,lastIndexExpression:t.lastIndexExpression,firstIndexVariable:`firstIndex_${this.variable()}`,lastIndexVariable:`lastIndex_${this.variable()}`,indexVariable:`index_${this.variable()}`,indexOutput:t.indexOutput,body:r}),n.invalidateValues(),void this.compilePort(e,t.continuationPort,i,n)}if("completion"===t.kind){const r=n.fork();return r.invalidateValues(),this.compilePort(e,t.completedPort,i,r),r.statements.length>0&&n.statements.push({kind:"completion",actorExpression:t.actorExpression,eventNodeId:e.id??e.constructor.name,body:r}),void this.compilePort(e,t.continuationPort,i,n)}if("runtimeCallback"===t.kind){const r=n.fork();return r.invalidateValues(),this.compilePort(e,t.completedPort,i,r),n.statements.push({kind:"runtimeCallback",callee:t.callee,arguments:t.arguments,eventNodeId:e.id??e.constructor.name,body:r,callbackValueOutput:t.callbackValueOutput,returnValueOutput:t.returnValueOutput}),n.invalidateValues(),void this.compilePort(e,t.continuationPort,i,n)}const r=`succeeded_${this.variable()}`,o=n.fork(),a=n.fork();this.compilePort(e,t.successPort,i,o),this.compilePort(e,t.errorPort,i,a),n.statements.push({kind:"try",attempt:t.attempt,catchVariable:t.catchVariable,recover:t.recover,succeeded:r,success:o,error:a}),this.compileContinuation(e,t.continuationPort,i,n)}compileContinuation(e,t,i,n){null!=t&&(n.invalidateValues(),this.compilePort(e,t,i,n))}compilePort(e,t,i,n){const r=e.getExecutionOutputs().get(t);null!=r&&this.compileExecutionNode(r,i,n)}emitBlock(e){return e.statements.map(e=>this.emitStatement(e)).filter(e=>e.length>0).join("\n")}emitStatement(e){if("code"===e.kind)return e.code;if("if"===e.kind){const t=this.emitBlock(e.whenTrue),i=this.emitBlock(e.whenFalse);return 0===t.length&&0===i.length?"":0===i.length?`if (${e.condition}) {\n${this.indent(t)}\n}`:0===t.length?`if (!(${e.condition})) {\n${this.indent(i)}\n}`:[`if (${e.condition}) {`,this.indent(t),"} else {",this.indent(i),"}"].join("\n")}if("switch"===e.kind){const t=e.cases.map(({match:e,block:t})=>{const i=this.emitBlock(t),n=i.length>0?`${i}\nbreak`:"break";return[`case ${e}: {`,this.indent(n),"}"].join("\n")});if(null!=e.defaultCase){const i=this.emitBlock(e.defaultCase);t.push(["default: {",this.indent(i),"}"].join("\n"))}return[`switch (${e.expression}) {`,this.indent(t.join("\n")),"}"].join("\n")}if("parallel"===e.kind){const t=e.branches.map(e=>["(async () => {",this.indent(this.emitBlock(e)),"})()"].join("\n"));return["await Promise.all([",this.indent(t.join(",\n")),"])"].join("\n")}if("forEach"===e.kind){const t=[`${e.indexOutput} = ${e.indexVariable}`,`${e.elementOutput} = ${e.arrayVariable}[${e.indexVariable}]`,this.emitBlock(e.body)].filter(e=>e.length>0).join("\n");return[`const ${e.arrayVariable} = ${e.arrayExpression}`,`if (!Array.isArray(${e.arrayVariable})) throw new Error("For Each requires an array")`,`for (let ${e.indexVariable} = 0; ${e.indexVariable} < ${e.arrayVariable}.length; ${e.indexVariable}++) {`,this.indent(t),"}"].join("\n")}if("forLoop"===e.kind){const t=[`${e.indexOutput} = ${e.indexVariable}`,this.emitBlock(e.body)].filter(e=>e.length>0).join("\n");return[`const ${e.firstIndexVariable} = ${e.firstIndexExpression}`,`const ${e.lastIndexVariable} = ${e.lastIndexExpression}`,`if (!Number.isSafeInteger(${e.firstIndexVariable}) || !Number.isSafeInteger(${e.lastIndexVariable})) throw new Error("For Loop indices must be safe integers")`,`if (${e.lastIndexVariable} - ${e.firstIndexVariable} > 100000) throw new Error("For Loop exceeds the 100000 iteration safety limit")`,`for (let ${e.indexVariable} = ${e.firstIndexVariable}; ${e.indexVariable} <= ${e.lastIndexVariable}; ${e.indexVariable}++) {`,this.indent(t),"}"].join("\n")}if("completion"===e.kind)return[`runtime.onActorCompleted(${e.actorExpression}, async () => {`,this.indent(this.emitBlock(e.body)),`}, ${JSON.stringify(e.eventNodeId)})`].join("\n");if("runtimeCallback"===e.kind){const t=this.emitBlock(e.body),i=null!=e.callbackValueOutput?`callbackValue_${this.variable()}`:void 0,n=[...null!=i?[`${e.callbackValueOutput} = ${i}`]:[],...t.length>0?[t]:[]].join("\n"),r=0===t.length?"undefined":[`async (${i??""}) => {`,this.indent(n),"}"].join("\n"),o=[`${e.callee}(`,this.indent([...e.arguments,r,JSON.stringify(e.eventNodeId)].join(",\n")),")"].join("\n");return null!=e.returnValueOutput?`${e.returnValueOutput} = ${o}`:o}const t=this.emitBlock(e.success),i=this.emitBlock(e.error),n=null==e.recover?"":`\n${this.indent(e.recover)}`,r=[`let ${e.succeeded} = false`,"try {",this.indent(e.attempt),` ${e.succeeded} = true`,`} catch (${e.catchVariable}) {${n}`,"}"];return t.length>0&&i.length>0?r.push(`if (${e.succeeded}) {`,this.indent(t),"} else {",this.indent(i),"}"):t.length>0?r.push(`if (${e.succeeded}) {\n${this.indent(t)}\n}`):i.length>0&&r.push(`if (!${e.succeeded}) {\n${this.indent(i)}\n}`),r.join("\n")}indent(e,t=1){const i=" ".repeat(t);return e.split("\n").map(e=>`${i}${e}`).join("\n")}identifier(e){const t=e.replace(/[^a-zA-Z0-9_$]/g,"_");return t.length>0?t:"value"}reset(){this.outputVariables=new Map,this.variableDeclarations=new Map,this.variableNumber=0,this.requiresAsync=!1}variable(){return++this.variableNumber}}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type EventGraphType, type EventGraphTypeSource } from './types.js';
|
|
2
|
+
export interface EventGraphParameterInfo {
|
|
3
|
+
name: string;
|
|
4
|
+
type: EventGraphType;
|
|
5
|
+
optional?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface EventGraphCallableInfo {
|
|
8
|
+
methodName: string;
|
|
9
|
+
label: string;
|
|
10
|
+
parameters: EventGraphParameterInfo[];
|
|
11
|
+
/** False when decorator metadata was unavailable and no explicit signature was supplied. */
|
|
12
|
+
parametersKnown: boolean;
|
|
13
|
+
returnType: EventGraphType;
|
|
14
|
+
awaitResult: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface EventGraphEventSourceInfo {
|
|
17
|
+
methodName: string;
|
|
18
|
+
label: string;
|
|
19
|
+
parameters: EventGraphParameterInfo[];
|
|
20
|
+
/** False when decorator metadata was unavailable and no explicit signature was supplied. */
|
|
21
|
+
parametersKnown: boolean;
|
|
22
|
+
valueType: EventGraphType;
|
|
23
|
+
valueLabel: string;
|
|
24
|
+
}
|
|
25
|
+
export type EventGraphParameterOptions = EventGraphTypeSource | {
|
|
26
|
+
name?: string;
|
|
27
|
+
type: EventGraphTypeSource;
|
|
28
|
+
optional?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export interface EventGraphCallableOptions {
|
|
31
|
+
label?: string;
|
|
32
|
+
parameters?: EventGraphParameterOptions[];
|
|
33
|
+
returns?: EventGraphTypeSource;
|
|
34
|
+
awaitResult?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface EventGraphEventSourceOptions {
|
|
37
|
+
label?: string;
|
|
38
|
+
parameters?: EventGraphParameterOptions[];
|
|
39
|
+
/** Payload type emitted by the returned Observable. */
|
|
40
|
+
emits?: EventGraphTypeSource;
|
|
41
|
+
valueLabel?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface EventGraphPropertyInfo {
|
|
44
|
+
propertyName: string;
|
|
45
|
+
label: string;
|
|
46
|
+
type: EventGraphType;
|
|
47
|
+
writable: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface EventGraphPropertyOptions {
|
|
50
|
+
label?: string;
|
|
51
|
+
type?: EventGraphTypeSource;
|
|
52
|
+
writable?: boolean;
|
|
53
|
+
/** Required to preserve the generic value type erased from Observable<T> at runtime. */
|
|
54
|
+
observableValueType?: EventGraphTypeSource;
|
|
55
|
+
}
|
|
56
|
+
/** Marks an actor or component method as callable by event graphs. */
|
|
57
|
+
export declare function EventGraphCallable(...args: any[]): any;
|
|
58
|
+
/** Marks an actor or component property as readable and optionally writable/subscribable. */
|
|
59
|
+
export declare function EventGraphProperty(...args: any[]): any;
|
|
60
|
+
/** Marks an Observable-returning actor or component method as an event source. */
|
|
61
|
+
export declare function EventGraphEventSource(...args: any[]): any;
|
|
62
|
+
export declare function isEventGraphCallable(target: object, method: string): boolean;
|
|
63
|
+
export declare function isEventGraphEventSource(target: object, method: string): boolean;
|
|
64
|
+
export declare function isEventGraphProperty(target: object, property: string): boolean;
|
|
65
|
+
export declare function getEventGraphCallableMethods(target: object): string[];
|
|
66
|
+
export declare function getEventGraphEventSourceMethods(target: object): string[];
|
|
67
|
+
export declare function getEventGraphProperties(target: object): string[];
|
|
68
|
+
export declare function getEventGraphCallableInfo(target: object, method: string): EventGraphCallableInfo | undefined;
|
|
69
|
+
export declare function getEventGraphCallableInfos(target: object): EventGraphCallableInfo[];
|
|
70
|
+
export declare function getEventGraphEventSourceInfo(target: object, method: string): EventGraphEventSourceInfo | undefined;
|
|
71
|
+
export declare function getEventGraphEventSourceInfos(target: object): EventGraphEventSourceInfo[];
|
|
72
|
+
export declare function getEventGraphPropertyInfo(target: object, property: string): EventGraphPropertyInfo | undefined;
|
|
73
|
+
export declare function getEventGraphPropertyInfos(target: object): EventGraphPropertyInfo[];
|
|
74
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{EVENT_GRAPH_ANY_TYPE as e,EVENT_GRAPH_VOID_TYPE as t,resolveEventGraphType as n}from"./types.js";const r=new WeakMap,o=new WeakMap,a=new WeakMap;export function EventGraphCallable(...e){if(m(e))return l({},e);const t=e[0]??{};return(...e)=>l(t,e)}export function EventGraphProperty(...e){if(m(e))return p({},e);const t=e[0]??{};return(...e)=>p(t,e)}export function EventGraphEventSource(...e){if(m(e))return u({},e);const t=e[0]??{};return(...e)=>u(t,e)}export function isEventGraphCallable(e,t){return null!=getEventGraphCallableInfo(e,t)}export function isEventGraphEventSource(e,t){return null!=getEventGraphEventSourceInfo(e,t)}export function isEventGraphProperty(e,t){return null!=getEventGraphPropertyInfo(e,t)}export function getEventGraphCallableMethods(e){return getEventGraphCallableInfos(e).map(e=>e.methodName)}export function getEventGraphEventSourceMethods(e){return getEventGraphEventSourceInfos(e).map(e=>e.methodName)}export function getEventGraphProperties(e){return getEventGraphPropertyInfos(e).map(e=>e.propertyName)}export function getEventGraphCallableInfo(e,t){return h(r,e).get(t)}export function getEventGraphCallableInfos(e){return[...h(r,e).values()]}export function getEventGraphEventSourceInfo(e,t){return h(o,e).get(t)}export function getEventGraphEventSourceInfos(e){return[...h(o,e).values()]}export function getEventGraphPropertyInfo(e,t){return h(a,e).get(t)}export function getEventGraphPropertyInfos(e){return[...h(a,e).values()]}function l(e,t){if(y(t)){const[n,o,a]=t,l=String(o),u=Reflect.getMetadata("design:paramtypes",n,o),p=Reflect.getMetadata("design:returntype",n,o),i=Reflect.hasMetadata("design:returntype",n,o);return g(r,n,l,c(l,e,u,p,i)),a}if(d(t,"method")){const[n,o]=t,a=String(o.name);return o.addInitializer(function(){g(r,Object.getPrototypeOf(this),a,c(a,e))}),n}throw new Error("@EventGraphCallable can only decorate methods")}function u(e,t){if(y(t)){const[n,r,a]=t,l=String(r),u=Reflect.getMetadata("design:paramtypes",n,r);return g(o,n,l,s(l,e,u)),a}if(d(t,"method")){const[n,r]=t,a=String(r.name);return r.addInitializer(function(){g(o,Object.getPrototypeOf(this),a,s(a,e))}),n}throw new Error("@EventGraphEventSource can only decorate methods")}function p(e,t){if(y(t)){const[n,r,o]=t,l=String(r),u=Reflect.getMetadata("design:type",n,r);return g(a,n,l,f(l,e,u,o)),o}if(d(t,"field")||d(t,"accessor")){const[n,r]=t,o=String(r.name);return r.addInitializer(function(){g(a,Object.getPrototypeOf(this),o,f(o,e))}),n}throw new Error("@EventGraphProperty can only decorate fields or accessors")}function i(e){return e.map((e,t)=>"object"!=typeof e||null==e||"kind"in e?{name:`arg${t}`,type:n(e)}:{name:e.name??`arg${t}`,type:n(e.type),...!0===e.optional?{optional:!0}:{}})}function c(r,o,a,l,u=!1){const p=o.parameters??a??[];return{methodName:r,label:o.label??v(r),parameters:i(p),parametersKnown:null!=o.parameters||null!=a,returnType:null!=o.returns?n(o.returns):null!=l?n(l):u?t:e,awaitResult:!0===o.awaitResult||l===Promise}}function s(e,t,r){const o=t.parameters??r??[];return{methodName:e,label:t.label??v(e),parameters:i(o),parametersKnown:null!=t.parameters||null!=r,valueType:n(t.emits),valueLabel:t.valueLabel??"Value"}}function f(e,t,r,o){const a=null==t.observableValueType?n(t.type??r):{kind:"observable",value:n(t.observableValueType)};return{propertyName:e,label:t.label??v(e),type:a,writable:t.writable??(null!=o?.set||null==o)}}function g(e,t,n,r){let o=e.get(t);null==o&&(o=new Map,e.set(t,o)),o.set(n,r)}function h(e,t){const n=new Map;let r="function"==typeof t?t.prototype:t;for(;null!=r;){for(const[t,o]of e.get(r)??[])n.has(t)||n.set(t,o);r=Object.getPrototypeOf(r)}return n}function v(e){const t=e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ");return t.length>0?t[0].toUpperCase()+t.slice(1):e}function m(e){return y(e)||2===e.length&&"string"==typeof e[1]?.kind}function y(e){return e.length>=2&&("string"==typeof e[1]||"symbol"==typeof e[1])}function d(e,t){return 2===e.length&&e[1]?.kind===t}/*
|
|
2
|
+
* Copyright (©) 2026 Hology Interactive AB. All rights reserved.
|
|
3
|
+
* See the LICENSE.md file for details.
|
|
4
|
+
*/
|