Update scene document version and add input bindings support
This commit is contained in:
@@ -14,7 +14,8 @@ import {
|
|||||||
type WorldSettings
|
type WorldSettings
|
||||||
} from "./world-settings";
|
} from "./world-settings";
|
||||||
|
|
||||||
export const SCENE_DOCUMENT_VERSION = 25 as const;
|
export const SCENE_DOCUMENT_VERSION = 26 as const;
|
||||||
|
export const PLAYER_START_INPUT_BINDINGS_SCENE_DOCUMENT_VERSION = 26 as const;
|
||||||
export const PLAYER_START_NAVIGATION_MODE_SCENE_DOCUMENT_VERSION = 25 as const;
|
export const PLAYER_START_NAVIGATION_MODE_SCENE_DOCUMENT_VERSION = 25 as const;
|
||||||
export const SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION = 24 as const;
|
export const SCENE_TRANSITION_ENTITIES_SCENE_DOCUMENT_VERSION = 24 as const;
|
||||||
export const MULTI_SCENE_FOUNDATION_SCENE_DOCUMENT_VERSION = 22 as const;
|
export const MULTI_SCENE_FOUNDATION_SCENE_DOCUMENT_VERSION = 22 as const;
|
||||||
|
|||||||
@@ -14,9 +14,12 @@ import {
|
|||||||
import type { SceneDocument } from "../document/scene-document";
|
import type { SceneDocument } from "../document/scene-document";
|
||||||
import { cloneWorldSettings, type WorldSettings } from "../document/world-settings";
|
import { cloneWorldSettings, type WorldSettings } from "../document/world-settings";
|
||||||
import {
|
import {
|
||||||
|
clonePlayerStartInputBindings,
|
||||||
|
createPlayerStartInputBindings,
|
||||||
getEntityInstances,
|
getEntityInstances,
|
||||||
getPrimaryPlayerStartEntity,
|
getPrimaryPlayerStartEntity,
|
||||||
type EntityInstance
|
type EntityInstance,
|
||||||
|
type PlayerStartInputBindings
|
||||||
} from "../entities/entity-instances";
|
} from "../entities/entity-instances";
|
||||||
import { getBoxBrushBounds } from "../geometry/box-brush";
|
import { getBoxBrushBounds } from "../geometry/box-brush";
|
||||||
import { buildBoxBrushDerivedMeshData } from "../geometry/box-brush-mesh";
|
import { buildBoxBrushDerivedMeshData } from "../geometry/box-brush-mesh";
|
||||||
@@ -98,6 +101,7 @@ export interface RuntimePlayerStart {
|
|||||||
position: Vec3;
|
position: Vec3;
|
||||||
yawDegrees: number;
|
yawDegrees: number;
|
||||||
navigationMode: RuntimeNavigationMode;
|
navigationMode: RuntimeNavigationMode;
|
||||||
|
inputBindings: PlayerStartInputBindings;
|
||||||
collider: FirstPersonPlayerShape;
|
collider: FirstPersonPlayerShape;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +217,7 @@ export interface RuntimeSceneDefinition {
|
|||||||
interactionLinks: InteractionLink[];
|
interactionLinks: InteractionLink[];
|
||||||
playerStart: RuntimePlayerStart | null;
|
playerStart: RuntimePlayerStart | null;
|
||||||
playerCollider: FirstPersonPlayerShape;
|
playerCollider: FirstPersonPlayerShape;
|
||||||
|
playerInputBindings: PlayerStartInputBindings;
|
||||||
navigationMode: RuntimeNavigationMode;
|
navigationMode: RuntimeNavigationMode;
|
||||||
spawn: RuntimeSpawnPoint;
|
spawn: RuntimeSpawnPoint;
|
||||||
}
|
}
|
||||||
@@ -487,6 +492,7 @@ function buildRuntimeSceneCollections(document: SceneDocument): RuntimeSceneColl
|
|||||||
position: cloneVec3(entity.position),
|
position: cloneVec3(entity.position),
|
||||||
yawDegrees: entity.yawDegrees,
|
yawDegrees: entity.yawDegrees,
|
||||||
navigationMode: entity.navigationMode,
|
navigationMode: entity.navigationMode,
|
||||||
|
inputBindings: clonePlayerStartInputBindings(entity.inputBindings),
|
||||||
collider: buildRuntimePlayerShape(entity)
|
collider: buildRuntimePlayerShape(entity)
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -666,6 +672,9 @@ export function buildRuntimeSceneFromDocument(document: SceneDocument, options:
|
|||||||
const collections = buildRuntimeSceneCollections(document);
|
const collections = buildRuntimeSceneCollections(document);
|
||||||
const interactionLinks = getInteractionLinks(document.interactionLinks).map((link) => cloneInteractionLink(link));
|
const interactionLinks = getInteractionLinks(document.interactionLinks).map((link) => cloneInteractionLink(link));
|
||||||
const playerCollider = buildRuntimePlayerShape(playerStartEntity);
|
const playerCollider = buildRuntimePlayerShape(playerStartEntity);
|
||||||
|
const playerInputBindings = createPlayerStartInputBindings(
|
||||||
|
playerStartEntity?.inputBindings
|
||||||
|
);
|
||||||
|
|
||||||
for (const modelInstance of getModelInstances(document.modelInstances)) {
|
for (const modelInstance of getModelInstances(document.modelInstances)) {
|
||||||
const asset = document.assets[modelInstance.assetId];
|
const asset = document.assets[modelInstance.assetId];
|
||||||
@@ -690,6 +699,7 @@ export function buildRuntimeSceneFromDocument(document: SceneDocument, options:
|
|||||||
position: cloneVec3(playerStartEntity.position),
|
position: cloneVec3(playerStartEntity.position),
|
||||||
yawDegrees: playerStartEntity.yawDegrees,
|
yawDegrees: playerStartEntity.yawDegrees,
|
||||||
navigationMode,
|
navigationMode,
|
||||||
|
inputBindings: clonePlayerStartInputBindings(playerInputBindings),
|
||||||
collider: playerCollider
|
collider: playerCollider
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -705,6 +715,7 @@ export function buildRuntimeSceneFromDocument(document: SceneDocument, options:
|
|||||||
interactionLinks,
|
interactionLinks,
|
||||||
playerStart,
|
playerStart,
|
||||||
playerCollider,
|
playerCollider,
|
||||||
|
playerInputBindings,
|
||||||
navigationMode,
|
navigationMode,
|
||||||
spawn: resolveRuntimeSpawn(
|
spawn: resolveRuntimeSpawn(
|
||||||
playerStart,
|
playerStart,
|
||||||
|
|||||||
Reference in New Issue
Block a user