@xrift/world-components 0.25.1 → 0.26.0
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/contexts/TeleportContext.d.ts +34 -0
- package/dist/contexts/TeleportContext.d.ts.map +1 -0
- package/dist/contexts/TeleportContext.js +32 -0
- package/dist/contexts/TeleportContext.js.map +1 -0
- package/dist/hooks/useTeleport.d.ts +20 -0
- package/dist/hooks/useTeleport.d.ts.map +1 -0
- package/dist/hooks/useTeleport.js +25 -0
- package/dist/hooks/useTeleport.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
export interface TeleportDestination {
|
|
3
|
+
position: [number, number, number];
|
|
4
|
+
/** 度数法(0-360)省略時は現在の向きを維持 */
|
|
5
|
+
yaw?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TeleportContextValue {
|
|
8
|
+
teleport: (destination: TeleportDestination) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 開発環境用のデフォルト実装(console.log のみ)
|
|
12
|
+
* プラットフォーム側が実装を注入しない場合に使用される
|
|
13
|
+
*/
|
|
14
|
+
export declare const createDefaultTeleportImplementation: () => TeleportContextValue;
|
|
15
|
+
/**
|
|
16
|
+
* テレポート機能を提供する Context
|
|
17
|
+
* xrift-frontend 側で実装を注入し、ワールド側で利用できる
|
|
18
|
+
*/
|
|
19
|
+
export declare const TeleportContext: import("react").Context<TeleportContextValue | null>;
|
|
20
|
+
interface Props {
|
|
21
|
+
value: TeleportContextValue;
|
|
22
|
+
children: ReactNode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* テレポート機能を提供する ContextProvider
|
|
26
|
+
*/
|
|
27
|
+
export declare const TeleportProvider: ({ value, children }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
/**
|
|
29
|
+
* テレポートの Context を取得する hook
|
|
30
|
+
* @throws {Error} TeleportProvider の外で呼び出された場合
|
|
31
|
+
*/
|
|
32
|
+
export declare const useTeleportContext: () => TeleportContextValue;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=TeleportContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TeleportContext.d.ts","sourceRoot":"","sources":["../../src/contexts/TeleportContext.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,SAAS,EAAc,MAAM,OAAO,CAAA;AAEjE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAA;CACrD;AAED;;;GAGG;AACH,eAAO,MAAM,mCAAmC,QAAO,oBAGrD,CAAA;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,sDAAmD,CAAA;AAE/E,UAAU,KAAK;IACb,KAAK,EAAE,oBAAoB,CAAA;IAC3B,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,GAAI,qBAAqB,KAAK,4CAE1D,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAO,oBAMrC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* 開発環境用のデフォルト実装(console.log のみ)
|
|
5
|
+
* プラットフォーム側が実装を注入しない場合に使用される
|
|
6
|
+
*/
|
|
7
|
+
export const createDefaultTeleportImplementation = () => ({
|
|
8
|
+
teleport: (destination) => console.log('[Teleport] teleport called', destination),
|
|
9
|
+
});
|
|
10
|
+
/**
|
|
11
|
+
* テレポート機能を提供する Context
|
|
12
|
+
* xrift-frontend 側で実装を注入し、ワールド側で利用できる
|
|
13
|
+
*/
|
|
14
|
+
export const TeleportContext = createContext(null);
|
|
15
|
+
/**
|
|
16
|
+
* テレポート機能を提供する ContextProvider
|
|
17
|
+
*/
|
|
18
|
+
export const TeleportProvider = ({ value, children }) => {
|
|
19
|
+
return _jsx(TeleportContext.Provider, { value: value, children: children });
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* テレポートの Context を取得する hook
|
|
23
|
+
* @throws {Error} TeleportProvider の外で呼び出された場合
|
|
24
|
+
*/
|
|
25
|
+
export const useTeleportContext = () => {
|
|
26
|
+
const context = useContext(TeleportContext);
|
|
27
|
+
if (!context) {
|
|
28
|
+
throw new Error('useTeleportContext must be used within TeleportProvider');
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=TeleportContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TeleportContext.js","sourceRoot":"","sources":["../../src/contexts/TeleportContext.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,MAAM,OAAO,CAAA;AAYjE;;;GAGG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,GAAyB,EAAE,CAAC,CAAC;IAC9E,QAAQ,EAAE,CAAC,WAAW,EAAE,EAAE,CACxB,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,WAAW,CAAC;CACzD,CAAC,CAAA;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAA8B,IAAI,CAAC,CAAA;AAO/E;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAS,EAAE,EAAE;IAC7D,OAAO,KAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAA4B,CAAA;AACtF,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAyB,EAAE;IAC3D,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC,CAAA;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type TeleportDestination } from '../contexts/TeleportContext';
|
|
2
|
+
/**
|
|
3
|
+
* テレポート機能を使用するhook
|
|
4
|
+
* ワールド作成者がプレイヤーを瞬間移動させるために使用
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const { teleport } = useTeleport()
|
|
8
|
+
*
|
|
9
|
+
* // 位置と向きを指定してテレポート
|
|
10
|
+
* teleport({ position: [50, 0, 30], yaw: 180 })
|
|
11
|
+
*
|
|
12
|
+
* // 向きは省略可能(現在の向きを維持)
|
|
13
|
+
* teleport({ position: [50, 0, 30] })
|
|
14
|
+
*
|
|
15
|
+
* @returns {{ teleport: (destination: TeleportDestination) => void }}
|
|
16
|
+
*/
|
|
17
|
+
export declare const useTeleport: () => {
|
|
18
|
+
teleport: (destination: TeleportDestination) => void;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useTeleport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTeleport.d.ts","sourceRoot":"","sources":["../../src/hooks/useTeleport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAAsB,MAAM,6BAA6B,CAAA;AAE1F;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,QAAO;IAAE,QAAQ,EAAE,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAA;CAWpF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useTeleportContext } from '../contexts/TeleportContext';
|
|
3
|
+
/**
|
|
4
|
+
* テレポート機能を使用するhook
|
|
5
|
+
* ワールド作成者がプレイヤーを瞬間移動させるために使用
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const { teleport } = useTeleport()
|
|
9
|
+
*
|
|
10
|
+
* // 位置と向きを指定してテレポート
|
|
11
|
+
* teleport({ position: [50, 0, 30], yaw: 180 })
|
|
12
|
+
*
|
|
13
|
+
* // 向きは省略可能(現在の向きを維持)
|
|
14
|
+
* teleport({ position: [50, 0, 30] })
|
|
15
|
+
*
|
|
16
|
+
* @returns {{ teleport: (destination: TeleportDestination) => void }}
|
|
17
|
+
*/
|
|
18
|
+
export const useTeleport = () => {
|
|
19
|
+
const { teleport } = useTeleportContext();
|
|
20
|
+
const stableTeleport = useCallback((destination) => {
|
|
21
|
+
teleport(destination);
|
|
22
|
+
}, [teleport]);
|
|
23
|
+
return { teleport: stableTeleport };
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=useTeleport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTeleport.js","sourceRoot":"","sources":["../../src/hooks/useTeleport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AACnC,OAAO,EAA4B,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAE1F;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAA6D,EAAE;IACxF,MAAM,EAAE,QAAQ,EAAE,GAAG,kBAAkB,EAAE,CAAA;IAEzC,MAAM,cAAc,GAAG,WAAW,CAChC,CAAC,WAAgC,EAAE,EAAE;QACnC,QAAQ,CAAC,WAAW,CAAC,CAAA;IACvB,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAA;AACrC,CAAC,CAAA"}
|