react-three-game 0.0.83 → 0.0.85
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/README.md +72 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -1
- package/dist/tools/prefabeditor/PrefabRoot.js +64 -54
- package/dist/tools/prefabeditor/components/BufferGeometryComponent.d.ts +3 -0
- package/dist/tools/prefabeditor/components/BufferGeometryComponent.js +96 -0
- package/dist/tools/prefabeditor/components/CameraComponent.js +1 -2
- package/dist/tools/prefabeditor/components/ClickComponent.js +1 -1
- package/dist/tools/prefabeditor/components/ComponentRegistry.d.ts +3 -5
- package/dist/tools/prefabeditor/components/DirectionalLightComponent.js +3 -9
- package/dist/tools/prefabeditor/components/EnvironmentComponent.js +1 -1
- package/dist/tools/prefabeditor/components/MaterialComponent.d.ts +10 -0
- package/dist/tools/prefabeditor/components/MaterialComponent.js +63 -28
- package/dist/tools/prefabeditor/components/ModelComponent.js +1 -1
- package/dist/tools/prefabeditor/components/PhysicsComponent.js +1 -1
- package/dist/tools/prefabeditor/components/PointLightComponent.js +1 -1
- package/dist/tools/prefabeditor/components/SoundComponent.js +1 -2
- package/dist/tools/prefabeditor/components/SpotLightComponent.js +1 -1
- package/dist/tools/prefabeditor/components/index.js +8 -6
- package/dist/tools/prefabeditor/runtime.d.ts +61 -0
- package/dist/tools/prefabeditor/runtime.js +184 -0
- package/dist/tools/prefabeditor/scene.d.ts +8 -0
- package/dist/tools/prefabeditor/scene.js +45 -8
- package/package.json +2 -2
- package/dist/tools/prefabeditor/runtimeContext.d.ts +0 -40
- package/dist/tools/prefabeditor/runtimeContext.js +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-three-game",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
4
4
|
"description": "high performance 3D game engine built in React",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"concurrently": "^9.2.1",
|
|
44
44
|
"react": "^19.2.4",
|
|
45
45
|
"react-dom": "^19.2.4",
|
|
46
|
-
"three": "^0.
|
|
46
|
+
"three": "^0.184.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vite": "^7.3.1"
|
|
49
49
|
},
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
2
|
-
import { Object3D, Texture } from "three";
|
|
3
|
-
type RuntimeScopeProps = {
|
|
4
|
-
nodeId: string;
|
|
5
|
-
editMode?: boolean;
|
|
6
|
-
isSelected?: boolean;
|
|
7
|
-
children: ReactNode;
|
|
8
|
-
};
|
|
9
|
-
export interface AssetRuntime {
|
|
10
|
-
registerRigidBodyRef: (id: string, rb: any) => void;
|
|
11
|
-
getModel: (path: string) => Object3D | null;
|
|
12
|
-
getTexture: (path: string) => Texture | null;
|
|
13
|
-
getSound: (path: string) => AudioBuffer | null;
|
|
14
|
-
getAssetRevision: () => string;
|
|
15
|
-
getObject: (id: string) => Object3D | null;
|
|
16
|
-
getRigidBody: (id: string) => any;
|
|
17
|
-
}
|
|
18
|
-
export interface AssetRuntimeContextValue extends AssetRuntime {
|
|
19
|
-
}
|
|
20
|
-
export interface EntityRuntime {
|
|
21
|
-
nodeId: string;
|
|
22
|
-
editMode?: boolean;
|
|
23
|
-
isSelected?: boolean;
|
|
24
|
-
getObject: <T extends Object3D = Object3D>() => T | null;
|
|
25
|
-
getRigidBody: <T = any>() => T | null;
|
|
26
|
-
}
|
|
27
|
-
export interface LiveObjectRef<T extends Object3D = Object3D> {
|
|
28
|
-
readonly current: T | null;
|
|
29
|
-
}
|
|
30
|
-
export interface LiveRigidBodyRef<T = any> {
|
|
31
|
-
readonly current: T | null;
|
|
32
|
-
}
|
|
33
|
-
export declare const AssetRuntimeContext: import("react").Context<AssetRuntimeContextValue | null>;
|
|
34
|
-
export declare const EntityRuntimeContext: import("react").Context<EntityRuntime | null>;
|
|
35
|
-
export declare function useAssetRuntime(): AssetRuntime;
|
|
36
|
-
export declare function useEntityRuntime(): EntityRuntime;
|
|
37
|
-
export declare function useEntityObjectRef<T extends Object3D = Object3D>(): LiveObjectRef<T>;
|
|
38
|
-
export declare function useEntityRigidBodyRef<T = any>(): LiveRigidBodyRef<T>;
|
|
39
|
-
export declare function EntityRuntimeScope({ nodeId, editMode, isSelected, children, }: RuntimeScopeProps): import("react/jsx-runtime").JSX.Element;
|
|
40
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext, useMemo } from "react";
|
|
3
|
-
function createLiveRef(getCurrent) {
|
|
4
|
-
return {
|
|
5
|
-
get current() {
|
|
6
|
-
return getCurrent();
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export const AssetRuntimeContext = createContext(null);
|
|
11
|
-
export const EntityRuntimeContext = createContext(null);
|
|
12
|
-
export function useAssetRuntime() {
|
|
13
|
-
const ctx = useContext(AssetRuntimeContext);
|
|
14
|
-
if (!ctx)
|
|
15
|
-
throw new Error("useAssetRuntime must be used inside <PrefabRoot>");
|
|
16
|
-
return ctx;
|
|
17
|
-
}
|
|
18
|
-
export function useEntityRuntime() {
|
|
19
|
-
const ctx = useContext(EntityRuntimeContext);
|
|
20
|
-
if (!ctx)
|
|
21
|
-
throw new Error("useEntityRuntime must be used inside a component View rendered by <PrefabRoot>");
|
|
22
|
-
return ctx;
|
|
23
|
-
}
|
|
24
|
-
export function useEntityObjectRef() {
|
|
25
|
-
const { getObject } = useEntityRuntime();
|
|
26
|
-
return useMemo(() => createLiveRef(() => getObject()), [getObject]);
|
|
27
|
-
}
|
|
28
|
-
export function useEntityRigidBodyRef() {
|
|
29
|
-
const { getRigidBody } = useEntityRuntime();
|
|
30
|
-
return useMemo(() => createLiveRef(() => getRigidBody()), [getRigidBody]);
|
|
31
|
-
}
|
|
32
|
-
export function EntityRuntimeScope({ nodeId, editMode, isSelected, children, }) {
|
|
33
|
-
const assetRuntime = useContext(AssetRuntimeContext);
|
|
34
|
-
if (!assetRuntime)
|
|
35
|
-
throw new Error("EntityRuntimeScope must be used inside <PrefabRoot>");
|
|
36
|
-
const { getObject, getRigidBody } = assetRuntime;
|
|
37
|
-
const value = useMemo(() => ({
|
|
38
|
-
nodeId,
|
|
39
|
-
editMode,
|
|
40
|
-
isSelected,
|
|
41
|
-
getObject: () => getObject(nodeId),
|
|
42
|
-
getRigidBody: () => getRigidBody(nodeId),
|
|
43
|
-
}), [editMode, getObject, getRigidBody, isSelected, nodeId]);
|
|
44
|
-
return _jsx(EntityRuntimeContext.Provider, { value: value, children: children });
|
|
45
|
-
}
|