Add browser-only editor export and 2.5D runtime presentation

This commit is contained in:
emil28092005
2026-09-12 00:05:19 +03:00
parent a25ed40805
commit 1a0bf725fa
16 changed files with 883 additions and 53 deletions
+31 -1
View File
@@ -58,6 +58,16 @@ export interface Project {
ambient: number;
shadows: boolean;
renderScale: number;
rendering?: { toneMapping?: boolean; exposure?: number; contrast?: number };
controls?: Partial<
Record<"attack" | "jump" | "dash" | "sprint" | "reset", string[]>
>;
presentation?: {
title?: string;
instructions?: string;
start?: { title: string; body: string };
accent?: string;
};
};
}
export interface Command {
@@ -259,6 +269,20 @@ export function validateProject(p: Project) {
throw Error("Не найден скрипт " + c.script.scriptId);
if (c.material?.color && !color(c.material.color))
throw Error("Цвет должен быть #RRGGBB");
if (
c.material?.alpha !== undefined &&
(!Number.isFinite(c.material.alpha) ||
c.material.alpha < 0 ||
c.material.alpha > 1)
)
throw Error("Прозрачность материала должна быть от 0 до 1");
if (
c.camera?.projection === "orthographic" &&
(!Number.isFinite(c.camera.orthoWidth) || c.camera.orthoWidth <= 0)
)
throw Error("Ширина ортографической камеры должна быть положительной");
if (c.camera?.lookAt && !vector(c.camera.lookAt))
throw Error("Некорректная цель камеры");
if (m?.size && (!vector(m.size) || m.size.some((v: number) => v <= 0)))
throw Error("Размеры должны быть положительными");
if (
@@ -338,7 +362,13 @@ export function remapEntityReferences(
}
export const componentDefaults: Record<string, Component> = {
mesh: { type: "box", size: [1, 1, 1] },
material: { color: "#91a697", roughness: 0.8, metallic: 0 },
material: {
color: "#91a697",
roughness: 0.8,
metallic: 0,
alpha: 1,
unlit: false,
},
collider: { shape: "box", size: [1, 1, 1], radius: 0.4 },
rigidbody: { type: "fixed", mass: 1, restitution: 0.1 },
character: { gravity: 24, autostep: 0.25 },