Feat: Add terrain gluing and offset support to path scheduling
This commit is contained in:
@@ -72,6 +72,8 @@ export interface RuntimeProjectSchedulePathDefinition {
|
|||||||
loop: boolean;
|
loop: boolean;
|
||||||
curveMode?: ScenePathCurveMode;
|
curveMode?: ScenePathCurveMode;
|
||||||
sampledResolution?: number;
|
sampledResolution?: number;
|
||||||
|
glueToTerrain?: boolean;
|
||||||
|
terrainOffset?: number;
|
||||||
points: RuntimeProjectSchedulePathPoint[];
|
points: RuntimeProjectSchedulePathPoint[];
|
||||||
segments: RuntimeProjectSchedulePathSegment[];
|
segments: RuntimeProjectSchedulePathSegment[];
|
||||||
totalLength: number;
|
totalLength: number;
|
||||||
|
|||||||
@@ -1998,7 +1998,7 @@ export function buildRuntimeSceneFromDocument(
|
|||||||
const modelInstances = enabledModelInstances.map(buildRuntimeModelInstance);
|
const modelInstances = enabledModelInstances.map(buildRuntimeModelInstance);
|
||||||
const paths = getScenePaths(document.paths)
|
const paths = getScenePaths(document.paths)
|
||||||
.filter((path) => path.enabled)
|
.filter((path) => path.enabled)
|
||||||
.map(buildRuntimePath);
|
.map((path) => buildRuntimePath(path, enabledTerrains));
|
||||||
const collections = buildRuntimeSceneCollections(
|
const collections = buildRuntimeSceneCollections(
|
||||||
document,
|
document,
|
||||||
options.runtimeClock ?? null,
|
options.runtimeClock ?? null,
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ describe("Path inspector", () => {
|
|||||||
expect(screen.getByTestId("path-loop")).not.toBeChecked();
|
expect(screen.getByTestId("path-loop")).not.toBeChecked();
|
||||||
expect(screen.getByTestId("path-curve-mode")).toHaveValue("linear");
|
expect(screen.getByTestId("path-curve-mode")).toHaveValue("linear");
|
||||||
expect(screen.getByTestId("path-sampled-resolution")).toHaveValue(12);
|
expect(screen.getByTestId("path-sampled-resolution")).toHaveValue(12);
|
||||||
|
expect(screen.getByTestId("path-glue-to-terrain")).not.toBeChecked();
|
||||||
|
expect(screen.getByTestId("path-terrain-offset")).toHaveValue(0);
|
||||||
expect(screen.getByTestId("path-point-0-x")).toHaveValue(-1);
|
expect(screen.getByTestId("path-point-0-x")).toHaveValue(-1);
|
||||||
expect(screen.getByTestId("path-point-1-x")).toHaveValue(1);
|
expect(screen.getByTestId("path-point-1-x")).toHaveValue(1);
|
||||||
|
|
||||||
@@ -154,6 +156,12 @@ describe("Path inspector", () => {
|
|||||||
value: "16"
|
value: "16"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
fireEvent.click(screen.getByTestId("path-glue-to-terrain"));
|
||||||
|
fireEvent.change(screen.getByTestId("path-terrain-offset"), {
|
||||||
|
target: {
|
||||||
|
value: "0.25"
|
||||||
|
}
|
||||||
|
});
|
||||||
fireEvent.change(screen.getByTestId("path-point-1-z"), {
|
fireEvent.change(screen.getByTestId("path-point-1-z"), {
|
||||||
target: {
|
target: {
|
||||||
value: "2"
|
value: "2"
|
||||||
@@ -169,7 +177,9 @@ describe("Path inspector", () => {
|
|||||||
name: "Patrol Route",
|
name: "Patrol Route",
|
||||||
loop: true,
|
loop: true,
|
||||||
curveMode: "catmullRom",
|
curveMode: "catmullRom",
|
||||||
sampledResolution: 16
|
sampledResolution: 16,
|
||||||
|
glueToTerrain: true,
|
||||||
|
terrainOffset: 0.25
|
||||||
});
|
});
|
||||||
expect(updatedPath?.points).toHaveLength(3);
|
expect(updatedPath?.points).toHaveLength(3);
|
||||||
expect(updatedPath?.points[1]?.position).toEqual({
|
expect(updatedPath?.points[1]?.position).toEqual({
|
||||||
|
|||||||
Reference in New Issue
Block a user