Place G1 safely in physical templates
This commit is contained in:
parent
1af796d371
commit
6dc0a5a367
@ -285,7 +285,7 @@ Representative product gate baseline for the current thresholds:
|
||||
(`strategy=canvas`; exact bytes and sha256 are in the evidence manifest)
|
||||
- Debug PNG capture:
|
||||
`test-results/product-readiness/product-readiness-debug-capture.png`
|
||||
(`strategy=debug-capture`; latest representative gate recorded `194 KiB`
|
||||
(`strategy=debug-capture`; latest representative gate recorded `172 KiB`
|
||||
`image/png`)
|
||||
- Mobile screenshot:
|
||||
`test-results/product-readiness/product-readiness-mobile.jpg`
|
||||
@ -296,8 +296,8 @@ Representative product gate baseline for the current thresholds:
|
||||
control endpoint are parsed by the gate)
|
||||
- UI-downloaded builder config:
|
||||
`test-results/product-readiness/product-readiness-builder-config.json`
|
||||
(`version=1`, `sceneId=g1-store-blocks-physics`, `props=4`; parsed and
|
||||
re-imported by the gate)
|
||||
(`version=1`, `sceneId=g1-store-blocks-physics`,
|
||||
`robotPose=1.85,-0.95,0`, `props=4`; parsed and re-imported by the gate)
|
||||
- UI-downloaded HTML acceptance report:
|
||||
`test-results/product-readiness/product-readiness-acceptance-report.html`
|
||||
(the gate checks for backend physics and `/control` evidence in the report)
|
||||
@ -395,26 +395,31 @@ Scene evidence:
|
||||
- Manual root matrices: every manifest object root disables automatic matrix
|
||||
recomputation after construction. Runtime state, drag, and robot-offset
|
||||
changes explicitly update only the roots that actually move.
|
||||
- Safe physical template pose: `/compose` applies the builder `robotPose` to
|
||||
the included G1 MJCF before loading MotrixSim, and the default physical
|
||||
template exports `robotPose=1.85,-0.95,0`. The backend editing gate checks
|
||||
the live `pelvis` pose after compose, so the default robot cannot silently
|
||||
return to the shelf interior.
|
||||
|
||||
Bundle evidence:
|
||||
|
||||
- JavaScript chunks: `4`
|
||||
- App entry chunk: `195.96 kB raw / 50.85 kB gzip`
|
||||
- App entry chunk: `196.18 kB raw / 50.91 kB gzip`
|
||||
- Largest JavaScript gzip chunk: `140.96 KiB / 170.00 KiB`
|
||||
- Total JavaScript gzip: `214.48 KiB / 230.00 KiB`
|
||||
- Total JavaScript gzip: `214.53 KiB / 230.00 KiB`
|
||||
- Large-scene performance mode: `large-scene`, target `45 fps`,
|
||||
actual idle render rate `0.7 fps`, DPR cap observed at `1.00` in release
|
||||
actual idle render rate `0.9 fps`, DPR cap observed at `1.00` in release
|
||||
gate, `preserveDrawingBuffer=false`, `1` explicit readback render, shadows
|
||||
`off`, hover picking throttled to `32ms`, `26` empty frames
|
||||
`off`, hover picking throttled to `32ms`, `29` empty frames
|
||||
skipped, `703` static visual nodes frozen, `59` remaining mesh clones using
|
||||
pre-frozen source state, `627` repeated spin scans skipped, `568` repeated
|
||||
fixed mesh objects rendered as `16` instanced batches with `16` instanced
|
||||
draw units and `568` matrix uploads, `7` primitive geometry shapes cached,
|
||||
`51` mesh source assets retained, `24/51` mesh cache hit/miss in the primary
|
||||
large scene, `636` cached object bounds, `627` fast pick-proxy bounds from
|
||||
large scene, `636` cached object bounds, `627` fast pick-target bounds from
|
||||
`51` cached source bounds, real hover proof `hoverProxy 1` with cached bounds
|
||||
and `fallback 0`, with `0` camera-fit traversals, `1/84`
|
||||
scene root batch insertion under the computed `84` root cap, `343`
|
||||
scene root batch insertion under the computed `84` root cap, `344`
|
||||
partial render frames
|
||||
suppressed during the primary load, `26` browser event-loop yields during
|
||||
scene construction, active state payload `34/602` with `3` reduced frames and
|
||||
@ -436,12 +441,16 @@ Bundle evidence:
|
||||
proving active-state frames are not rebuilt by full body-map spreading.
|
||||
- WebGL readback gate: `browser-large-scene-performance-mode` now checks
|
||||
`buffer=false` and `readback=1`, and `browser-debug-capture-png` checks the
|
||||
exported PNG path (`194 KiB image/png`) so debug screenshot export remains
|
||||
exported PNG path (`172 KiB image/png`) so debug screenshot export remains
|
||||
covered after removing the persistent drawing buffer.
|
||||
- Body-state cache gate: `browser-body-state-cache` waits for the paused scene
|
||||
to use a reduced active payload and still skip unchanged active poses. The
|
||||
current run passed with `state apply 4/skip 63`, `statePayload=34/602`, and
|
||||
`incremental=3`.
|
||||
- Robot safe-pose gate: `verify-real-backend-editing` now checks
|
||||
`robot-safe-initial-pose`, with the latest composed scene reporting
|
||||
`pelvis=1.866,-0.935,0.767`, proving the default G1 starts outside the shelf
|
||||
interior after MotrixSim loads the generated MJCF.
|
||||
- Camera-fit traversal gate: `browser-large-scene-performance-mode` now checks
|
||||
`bounds cache 636` and `camera traversals 0`.
|
||||
- Pick-proxy bounds gate: `browser-large-scene-performance-mode` now checks
|
||||
@ -474,33 +483,33 @@ Control evidence:
|
||||
- Active state endpoint: full `/state` returned `602` bodies; active
|
||||
`/state?bodies=active` returned `34` bodies in `64ms`, filtered `568` fixed
|
||||
bodies, and retained `4/4` composed dynamic bodies.
|
||||
- Scene Builder UI compose: representative run `4485ms` end to end with real
|
||||
- Scene Builder UI compose: representative run `4470ms` end to end with real
|
||||
backend diagnostics.
|
||||
- Share-link restore: representative full browser restore `6492ms`.
|
||||
- Config import restore: representative full browser restore `6886ms`.
|
||||
- Composed object body edit: `57ms`.
|
||||
- Fixed inventory edit rejection: `58ms`.
|
||||
- Share-link restore: representative full browser restore `6282ms`.
|
||||
- Config import restore: representative full browser restore `7805ms`.
|
||||
- Composed object body edit: `46ms`.
|
||||
- Fixed inventory edit rejection: `56ms`.
|
||||
- Dynamic composed object drop: `0.48012m`.
|
||||
- Static shelf anchor stability: `max drift 0.00000m` after a 2500 ms resume
|
||||
window.
|
||||
- Resume backend state: `58ms paused=false`
|
||||
- Resume visible UI state: `60ms`
|
||||
- Pause backend state: `241ms paused=true`
|
||||
- Pause visible UI state: `59ms`
|
||||
- Pause backend state: `53ms paused=true`
|
||||
- Pause visible UI state: `53ms`
|
||||
- Desktop acceptance wait: `1243ms` total, product telemetry `0ms`
|
||||
- Mobile acceptance wait: `277ms` total, product telemetry `0ms`
|
||||
- Runtime diagnostics panel:
|
||||
`state=http://127.0.0.1:18090/state`,
|
||||
`control=http://127.0.0.1:18090/control`,
|
||||
`latency=响应 34 ms / 确认 35 ms / 可见 35 ms`,
|
||||
`latency=响应 53 ms / 确认 53 ms / 可见 53 ms`,
|
||||
`acceptanceLatency=0 ms / 11-0-0`,
|
||||
`binding=635/636; 4/568`,
|
||||
`builderPhysics=已添加物体 4: 后端动态 4 / 仅视觉 0`,
|
||||
`renderPerformance=large-scene; target 45 fps; actual 0.7 fps; dpr 1.00; buffer preserved false; readback renders 1; shadows off; skipped 26; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568; manual roots 636 updates 67; primitive geometries 7; mesh cache 51 sources 24/51 hit/miss retained 51g/17m; bounds cache 636 fast 627 source 51 hoverProxy 1 cached 1/fallback 0 camera traversals 0; scene batches 1/84 suppressed 343 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 30/3 builder 33/1; pick targets 636; state apply 0/skip 67; unchanged frames 1; released 0g/0m/0t`.
|
||||
`renderPerformance=large-scene; target 45 fps; actual 0.9 fps; dpr 1.00; buffer preserved false; readback renders 1; shadows off; skipped 29; hover 32ms; frozen 703 prefrozen 59 spinSkip 627; instanced 568/16/16 matrices 568; manual roots 636 updates 67; primitive geometries 7; mesh cache 51 sources 24/51 hit/miss retained 51g/17m; bounds cache 636 fast 627 source 51 hoverProxy 1 cached 1/fallback 0 camera traversals 0; scene batches 1/84 suppressed 344 yields 26; state payload 34/602 reduced 3 incremental 4; ui cache physics 30/3 builder 33/1; pick targets 636; state apply 0/skip 67; unchanged frames 1; released 0g/0m/0t`.
|
||||
- Evidence screenshot artifacts:
|
||||
`builder page; share page; import page; visual-only boundary canvas; desktop canvas; debug PNG; mobile canvas`
|
||||
- Evidence export artifacts:
|
||||
`config 1 KiB v1; package 10 KiB motrixsim-web.acceptance-package.v1; report 10 KiB; rendered screenshot recorded`
|
||||
`config 1 KiB v1; package 12 KiB motrixsim-web.acceptance-package.v1; report 13 KiB; rendered screenshot recorded`
|
||||
|
||||
Visible UI control sync is the product interaction SLA and must stay under the
|
||||
current `3000ms` target. Backend state polling can take longer when the remote
|
||||
|
||||
@ -14,6 +14,7 @@ const frontendMode = process.env.MOTRIXSIM_PRODUCT_FRONTEND_MODE === "preview" ?
|
||||
const failOnWarn = process.env.MOTRIXSIM_PRODUCT_FAIL_ON_WARN === "1";
|
||||
const defaultFrontendPort = process.env.MOTRIXSIM_PRODUCT_FRONTEND_PORT ?? (frontendMode === "preview" ? "4173" : "5173");
|
||||
const explicitFrontendUrl = process.argv[2] ?? process.env.MOTRIXSIM_WEB_URL;
|
||||
const expectedPhysicalRobotPose = [1.85, -0.95, 0];
|
||||
function defaultFrontendUrl(port = defaultFrontendPort) {
|
||||
return `http://127.0.0.1:${port}/?manifest=${encodeURIComponent(defaultManifestUrl)}&v=product-readiness`;
|
||||
}
|
||||
@ -467,6 +468,7 @@ async function collectEvidenceArtifacts(browserEvidence) {
|
||||
version: builderConfigExport.version,
|
||||
sceneId: builderConfigExport.sceneId,
|
||||
robotId: builderConfigExport.robotId,
|
||||
robotPose: builderConfigExport.robotPose,
|
||||
propCount: builderConfigExport.propCount,
|
||||
physics: builderConfigExport.physics,
|
||||
workspaceStatus: builderConfigExport.workspaceStatus,
|
||||
@ -527,6 +529,7 @@ async function collectEvidenceArtifacts(browserEvidence) {
|
||||
&& builderConfig.sha256.length === 64
|
||||
&& builderConfig.version === 1
|
||||
&& builderConfig.sceneId === "g1-store-blocks-physics"
|
||||
&& vec3Near(builderConfig.robotPose, expectedPhysicalRobotPose)
|
||||
&& builderConfig.propCount >= 4
|
||||
&& builderConfig.physics?.ready === true
|
||||
&& Number(builderConfig.physics?.backendDynamic ?? 0) >= 4
|
||||
@ -1158,6 +1161,14 @@ function sameBuilderConfig(left, right) {
|
||||
return JSON.stringify(left) === JSON.stringify(right);
|
||||
}
|
||||
|
||||
function vec3Near(left, right, epsilon = 1e-6) {
|
||||
return Array.isArray(left)
|
||||
&& Array.isArray(right)
|
||||
&& left.length >= 3
|
||||
&& right.length >= 3
|
||||
&& left.slice(0, 3).every((value, index) => Math.abs(Number(value) - Number(right[index])) <= epsilon);
|
||||
}
|
||||
|
||||
async function copyBuilderShareLink(page) {
|
||||
const originalConfig = await readBuilderConfig(page);
|
||||
const clickMs = await clickButton(page, "#workspace-copy-link");
|
||||
@ -1213,6 +1224,7 @@ async function exportBuilderConfigArtifact(page) {
|
||||
const exportOk = sameBuilderConfig(config, originalConfig)
|
||||
&& config?.version === 1
|
||||
&& config?.sceneId === "g1-store-blocks-physics"
|
||||
&& vec3Near(config?.robotPose, expectedPhysicalRobotPose)
|
||||
&& Array.isArray(config?.props)
|
||||
&& config.props.length >= 4
|
||||
&& config?.physics?.ready === true
|
||||
@ -1223,7 +1235,7 @@ async function exportBuilderConfigArtifact(page) {
|
||||
check(
|
||||
"browser-builder-config-export",
|
||||
exportOk,
|
||||
`${download.suggestedFilename}; props=${config?.props?.length ?? "-"}; scene=${config?.sceneId ?? "-"}; builderDynamic=${config?.physics?.backendDynamic ?? "-"}; builderVisual=${config?.physics?.visualOnly ?? "-"}; status=${workspaceStatus}`,
|
||||
`${download.suggestedFilename}; props=${config?.props?.length ?? "-"}; scene=${config?.sceneId ?? "-"}; robotPose=${Array.isArray(config?.robotPose) ? config.robotPose.join(",") : "-"}; builderDynamic=${config?.physics?.backendDynamic ?? "-"}; builderVisual=${config?.physics?.visualOnly ?? "-"}; status=${workspaceStatus}`,
|
||||
);
|
||||
return {
|
||||
...download,
|
||||
@ -1231,6 +1243,7 @@ async function exportBuilderConfigArtifact(page) {
|
||||
version: config?.version,
|
||||
sceneId: config?.sceneId,
|
||||
robotId: config?.robotId,
|
||||
robotPose: config?.robotPose,
|
||||
propCount: config?.props?.length,
|
||||
physics: config?.physics,
|
||||
workspaceStatus,
|
||||
|
||||
@ -16,6 +16,7 @@ const minAnchors = Number(process.env.MIN_EDITABLE_ANCHORS ?? "1");
|
||||
const minMembers = Number(process.env.MIN_EDITABLE_MEMBERS ?? "1");
|
||||
const stabilityRunMs = Number(process.env.STABILITY_RUN_MS ?? "2500");
|
||||
const maxStaticAnchorDrift = Number(process.env.MAX_STATIC_ANCHOR_DRIFT ?? "0.01");
|
||||
const expectedPhysicalRobotPose = [1.85, -0.95, 0];
|
||||
const composeObjects = [
|
||||
{ id: "product_gate_red_cube", presetId: "red-cube", position: [0.72, -0.48, 0.08] },
|
||||
{ id: "product_gate_blue_crate", presetId: "blue-crate", position: [1, -0.48, 0.08] },
|
||||
@ -23,6 +24,14 @@ const composeObjects = [
|
||||
{ id: "product_gate_yellow_capsule", presetId: "yellow-capsule", position: [1.56, -0.48, 0.08] },
|
||||
];
|
||||
|
||||
function vec3Near(left, right, epsilon = 0.05) {
|
||||
return Array.isArray(left)
|
||||
&& Array.isArray(right)
|
||||
&& left.length >= 3
|
||||
&& right.length >= 3
|
||||
&& left.slice(0, 3).every((value, index) => Math.abs(Number(value) - Number(right[index])) <= epsilon);
|
||||
}
|
||||
|
||||
function nowIso() {
|
||||
return new Date().toISOString();
|
||||
}
|
||||
@ -133,6 +142,7 @@ try {
|
||||
const physicalComposePayload = {
|
||||
scene: "g1-store-blocks-physics",
|
||||
robot: "g1",
|
||||
robotPose: expectedPhysicalRobotPose,
|
||||
paused: true,
|
||||
objects: composeObjects,
|
||||
};
|
||||
@ -221,6 +231,12 @@ try {
|
||||
const bodyCount = Object.keys(initialState?.bodies ?? {}).length;
|
||||
checks.push(check("state", stateResponse.ok && bodyCount > 0, `${bodyCount} bodies in ${stateResponse.elapsedMs}ms`));
|
||||
checks.push(check("state-paused", initialState?.paused === true, `paused=${initialState?.paused}`));
|
||||
const pelvisPose = initialState?.bodies?.pelvis?.pos;
|
||||
checks.push(check(
|
||||
"robot-safe-initial-pose",
|
||||
vec3Near(pelvisPose, [expectedPhysicalRobotPose[0], expectedPhysicalRobotPose[1], 0.793], 0.08),
|
||||
`pelvis=${Array.isArray(pelvisPose) ? pelvisPose.map((value) => Number(value).toFixed(3)).join(",") : "missing"}`,
|
||||
));
|
||||
const activeStateUrl = new URL(stateUrl);
|
||||
activeStateUrl.searchParams.set("bodies", "active");
|
||||
activeStateResponse = await fetchJson(activeStateUrl.href, {}, stateTimeoutMs);
|
||||
|
||||
@ -37,6 +37,7 @@ from export_mjcf_manifest import collect_manifest # noqa: E402
|
||||
DEFAULT_ASSET_ROOT = Path("/opt/Motphys/motrixsim-docs/examples/assets")
|
||||
DEFAULT_G1_SCENE = DEFAULT_ASSET_ROOT / "g1/g1_mjx_feetonly.xml"
|
||||
DEFAULT_STORE_SCENE = DEFAULT_ASSET_ROOT / "store/store.xml"
|
||||
DEFAULT_G1_COMPOSE_POSE = [1.85, -0.95, 0.0]
|
||||
|
||||
COMPOSE_PROP_SPECS: dict[str, dict[str, Any]] = {
|
||||
"red-cube": {
|
||||
@ -380,6 +381,21 @@ def prop_position(index: int, payload: dict[str, Any], spec: dict[str, Any]) ->
|
||||
return [0.72 + col * 0.28, -0.48 - row * 0.26, float(spec["z"])]
|
||||
|
||||
|
||||
def vec3_from_payload(value: Any, default: list[float]) -> list[float]:
|
||||
if isinstance(value, list) and len(value) >= 3:
|
||||
return [float(value[0]), float(value[1]), float(value[2])]
|
||||
return [float(default[0]), float(default[1]), float(default[2])]
|
||||
|
||||
|
||||
def parse_float_list(raw: str | None, default: list[float]) -> list[float]:
|
||||
if not raw:
|
||||
return [*default]
|
||||
try:
|
||||
return [float(item) for item in raw.replace(",", " ").split()]
|
||||
except ValueError:
|
||||
return [*default]
|
||||
|
||||
|
||||
def normalize_compose_request(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
scene_id = str(payload.get("scene") or payload.get("scenePreset") or "g1-store-blocks-physics")
|
||||
robot_id = str(payload.get("robot") or payload.get("robotPreset") or "none")
|
||||
@ -412,6 +428,7 @@ def normalize_compose_request(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
return {
|
||||
"scene": scene_id,
|
||||
"robot": robot_id,
|
||||
"robotPose": vec3_from_payload(payload.get("robotPose"), DEFAULT_G1_COMPOSE_POSE),
|
||||
"freezeInventory": stock_physics not in {"dynamic", "free", "movable"},
|
||||
"objects": objects,
|
||||
}
|
||||
@ -421,6 +438,7 @@ def compose_request_key(request: dict[str, Any]) -> str:
|
||||
identity = {
|
||||
"scene": request["scene"],
|
||||
"robot": request["robot"],
|
||||
"robotPose": [round(float(value), 6) for value in request["robotPose"]],
|
||||
"freezeInventory": request["freezeInventory"],
|
||||
"objects": [
|
||||
{
|
||||
@ -435,6 +453,34 @@ def compose_request_key(request: dict[str, Any]) -> str:
|
||||
return hashlib.sha256(body).hexdigest()
|
||||
|
||||
|
||||
def write_pose_adjusted_mjcf(source_path: Path, target_path: Path, pose: list[float]) -> Path:
|
||||
tree = ET.parse(source_path)
|
||||
root = tree.getroot()
|
||||
source_dir = source_path.parent
|
||||
for element in root.iter():
|
||||
file_attr = element.attrib.get("file")
|
||||
if not file_attr:
|
||||
continue
|
||||
file_path = Path(file_attr)
|
||||
if not file_path.is_absolute():
|
||||
element.set("file", (source_dir / file_path).as_posix())
|
||||
|
||||
worldbody = root.find("worldbody")
|
||||
if worldbody is None:
|
||||
raise ValueError(f"robot scene has no worldbody: {source_path}")
|
||||
robot_body = worldbody.find("body")
|
||||
if robot_body is None:
|
||||
raise ValueError(f"robot scene has no root body: {source_path}")
|
||||
base_pos = parse_float_list(robot_body.attrib.get("pos"), [0.0, 0.0, 0.0])
|
||||
while len(base_pos) < 3:
|
||||
base_pos.append(0.0)
|
||||
robot_body.set("pos", " ".join(f"{base_pos[index] + float(pose[index]):.6g}" for index in range(3)))
|
||||
|
||||
ET.indent(tree, space=" ")
|
||||
tree.write(target_path, encoding="unicode")
|
||||
return target_path
|
||||
|
||||
|
||||
def compose_physical_scene(payload: dict[str, Any], compose_dir: Path, request: dict[str, Any] | None = None) -> Path:
|
||||
request = request or normalize_compose_request(payload)
|
||||
if not DEFAULT_G1_SCENE.is_file():
|
||||
@ -448,11 +494,16 @@ def compose_physical_scene(payload: dict[str, Any], compose_dir: Path, request:
|
||||
compose_dir / "store_namespaced.xml",
|
||||
freeze_inventory=bool(request["freezeInventory"]),
|
||||
)
|
||||
g1_scene = write_pose_adjusted_mjcf(
|
||||
DEFAULT_G1_SCENE,
|
||||
compose_dir / "g1_pose_adjusted.xml",
|
||||
request["robotPose"],
|
||||
)
|
||||
scene_path = compose_dir / "active_g1_store_scene.xml"
|
||||
|
||||
mujoco = ET.Element("mujoco", {"model": "motrixsim_web_composed"})
|
||||
ET.SubElement(mujoco, "compiler", {"angle": "radian", "autolimits": "true"})
|
||||
ET.SubElement(mujoco, "include", {"file": DEFAULT_G1_SCENE.as_posix()})
|
||||
ET.SubElement(mujoco, "include", {"file": g1_scene.as_posix()})
|
||||
ET.SubElement(mujoco, "include", {"file": store_scene.as_posix()})
|
||||
ET.SubElement(mujoco, "option", {"gravity": "0 0 -9.8", "timestep": "0.005"})
|
||||
ET.SubElement(mujoco, "statistic", {"center": "0.35 0.45 0.85", "extent": "2.6", "meansize": "0.04"})
|
||||
|
||||
20
src/main.ts
20
src/main.ts
@ -24,6 +24,7 @@ const LARGE_SCENE_POLL_INTERVAL_MS = 2000;
|
||||
const STATS_REFRESH_MS = 1000;
|
||||
const CONTROL_POLL_SUSPEND_MS = 8000;
|
||||
const CONTROL_RENDER_SUSPEND_MS = 8000;
|
||||
const PHYSICAL_G1_SAFE_POSE: Vec3 = [1.85, -0.95, 0];
|
||||
const initialManifestUrl = new URLSearchParams(window.location.search).get("manifest") ?? DEFAULT_MANIFEST;
|
||||
const initialBuilderConfigParam = new URLSearchParams(window.location.search).get("builder");
|
||||
let currentLocale: Locale = initialLocale();
|
||||
@ -377,7 +378,7 @@ const SCENE_TEMPLATES: SceneTemplate[] = [
|
||||
version: 1,
|
||||
sceneId: "g1-store-blocks-physics",
|
||||
robotId: "none",
|
||||
robotPose: [0, 0, 0],
|
||||
robotPose: [...PHYSICAL_G1_SAFE_POSE],
|
||||
props: [
|
||||
{ presetId: "red-cube", position: [0.72, -0.48, 0.08] },
|
||||
{ presetId: "blue-crate", position: [1, -0.48, 0.08] },
|
||||
@ -782,7 +783,7 @@ const pressedInputKeys = new Set<string>();
|
||||
let lastCommand: [number, number, number] = [0, 0, 0];
|
||||
let builderPropSerial = 0;
|
||||
let builderRebuildTimer: number | undefined;
|
||||
let builderRobotPose: Vec3 = [0, 0, 0];
|
||||
let builderRobotPose: Vec3 = [...PHYSICAL_G1_SAFE_POSE];
|
||||
const builderProps: BuilderProp[] = [];
|
||||
let builderHistory: BuilderConfig[] = [];
|
||||
let builderHistoryIndex = -1;
|
||||
@ -1835,6 +1836,7 @@ function renderBuilderOptions(resetSelection = true): void {
|
||||
robotSelect.value = robotValue;
|
||||
propSelect.value = propValue || (allPropPresets()[0]?.id ?? "");
|
||||
if (resetSelection) {
|
||||
builderRobotPose = defaultRobotPoseForScene(sceneSelect.value);
|
||||
seedBuilderPropsForSelectedScene();
|
||||
} else {
|
||||
renderBuilderProps();
|
||||
@ -3175,6 +3177,10 @@ function isVec3(value: unknown): value is Vec3 {
|
||||
&& value.every((item) => typeof item === "number" && Number.isFinite(item));
|
||||
}
|
||||
|
||||
function defaultRobotPoseForScene(sceneId: string): Vec3 {
|
||||
return sceneId === "g1-store-blocks-physics" ? [...PHYSICAL_G1_SAFE_POSE] : [0, 0, 0];
|
||||
}
|
||||
|
||||
function parseBuilderConfig(raw: string | null): BuilderConfig | undefined {
|
||||
if (!raw) {
|
||||
return undefined;
|
||||
@ -3188,7 +3194,9 @@ function parseBuilderConfig(raw: string | null): BuilderConfig | undefined {
|
||||
version: 1,
|
||||
sceneId: parsed.sceneId,
|
||||
robotId: parsed.robotId,
|
||||
robotPose: isVec3(parsed.robotPose) ? [...parsed.robotPose] as Vec3 : [0, 0, 0],
|
||||
robotPose: isVec3(parsed.robotPose)
|
||||
? [...parsed.robotPose] as Vec3
|
||||
: defaultRobotPoseForScene(parsed.sceneId),
|
||||
props: parsed.props
|
||||
.filter((item) => typeof item?.presetId === "string" && isVec3(item.position))
|
||||
.map((item) => ({ presetId: item.presetId, position: [...item.position] as Vec3 })),
|
||||
@ -3219,7 +3227,7 @@ function applyBuilderConfig(config: BuilderConfig, recordHistory = true): void {
|
||||
const robotSelect = document.querySelector<HTMLSelectElement>("#builder-robot")!;
|
||||
sceneSelect.value = isScenePresetIdKnown(config.sceneId) ? config.sceneId : allScenePresets()[0]?.id ?? SCENE_PRESETS[0].id;
|
||||
robotSelect.value = ROBOT_PRESETS.some((preset) => preset.id === config.robotId) ? config.robotId : ROBOT_PRESETS[0].id;
|
||||
builderRobotPose = isVec3(config.robotPose) ? [...config.robotPose] : [0, 0, 0];
|
||||
builderRobotPose = isVec3(config.robotPose) ? [...config.robotPose] : defaultRobotPoseForScene(config.sceneId);
|
||||
builderProps.length = 0;
|
||||
for (const item of config.props) {
|
||||
if (propPresetById(item.presetId)) {
|
||||
@ -4261,6 +4269,7 @@ setupUploadDropZone("#scene-upload-zone", (files) => {
|
||||
void uploadSceneFileSet(files).catch(() => setWorkspaceStatus("status.workspace.importFailed"));
|
||||
});
|
||||
document.querySelector<HTMLSelectElement>("#builder-scene")!.addEventListener("change", () => {
|
||||
builderRobotPose = defaultRobotPoseForScene(document.querySelector<HTMLSelectElement>("#builder-scene")!.value);
|
||||
seedBuilderPropsForSelectedScene();
|
||||
renderBuilderPhysicsGuard();
|
||||
recordBuilderHistory();
|
||||
@ -4270,7 +4279,7 @@ document.querySelector<HTMLSelectElement>("#builder-robot")!.addEventListener("c
|
||||
const previousRobotId = builderConfig().robotId;
|
||||
const nextRobotId = document.querySelector<HTMLSelectElement>("#builder-robot")!.value;
|
||||
if (previousRobotId !== nextRobotId) {
|
||||
builderRobotPose = [0, 0, 0];
|
||||
builderRobotPose = defaultRobotPoseForScene(document.querySelector<HTMLSelectElement>("#builder-scene")!.value);
|
||||
}
|
||||
recordBuilderHistory();
|
||||
saveBuilderDraft();
|
||||
@ -4279,6 +4288,7 @@ document.querySelector<HTMLSelectElement>("#builder-robot")!.addEventListener("c
|
||||
document.querySelector<HTMLButtonElement>("#builder-load-physical")!.addEventListener("click", () => {
|
||||
document.querySelector<HTMLSelectElement>("#builder-scene")!.value = "g1-store-blocks-physics";
|
||||
document.querySelector<HTMLSelectElement>("#builder-robot")!.value = "none";
|
||||
builderRobotPose = [...PHYSICAL_G1_SAFE_POSE];
|
||||
seedBuilderPropsForSelectedScene();
|
||||
renderBuilderPhysicsGuard();
|
||||
recordBuilderHistory();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user