固定热端熔融区剖面视角并保留工艺动画

This commit is contained in:
xuans 2026-09-18 22:29:55 +08:00
parent bac023c047
commit a44559dcda
3 changed files with 23 additions and 4 deletions

View File

@ -27,7 +27,7 @@ try {
await page.goto(url); await page.goto(url);
await page.waitForSelector("#loading[hidden]", { await page.waitForSelector("#loading[hidden]", {
state: "attached", state: "attached",
timeout: 60000, timeout: 180000,
}); });
await page.locator('[data-technology="thermal"]').click(); await page.locator('[data-technology="thermal"]').click();
const signal = () => const signal = () =>
@ -49,6 +49,19 @@ try {
report.changedPixels = after.filter((v, i) => v !== before[i]).length; report.changedPixels = after.filter((v, i) => v !== before[i]).length;
assert.ok(report.changedPixels > 50); assert.ok(report.changedPixels > 50);
assert.notEqual((await signal()).fanAngle, start.fanAngle); assert.notEqual((await signal()).fanAngle, start.fanAngle);
assert.deepEqual((await signal()).cameraPosition, start.cameraPosition);
assert.deepEqual((await signal()).cameraQuaternion, start.cameraQuaternion);
const sceneBounds = await page.locator('#scene').boundingBox();
await page.mouse.move(sceneBounds.x + sceneBounds.width / 2, sceneBounds.y + sceneBounds.height / 2);
await page.mouse.down();
await page.mouse.move(sceneBounds.x + sceneBounds.width / 2 + 100, sceneBounds.y + sceneBounds.height / 2 + 60, { steps: 12 });
await page.mouse.up();
await page.mouse.wheel(0, 300);
await page.waitForTimeout(500);
assert.deepEqual((await signal()).cameraPosition, start.cameraPosition);
assert.deepEqual((await signal()).cameraQuaternion, start.cameraQuaternion);
assert.ok((await signal()).travel > start.travel);
report.fixedSectionCamera = true;
await page.screenshot({ path: "artifacts/thermal-animation.png" }); await page.screenshot({ path: "artifacts/thermal-animation.png" });
await page.locator("#fan-target").fill("0"); await page.locator("#fan-target").fill("0");
await page.waitForTimeout(300); await page.waitForTimeout(300);

View File

@ -169,6 +169,11 @@ export class MonitorScene extends PrintScene {
} }
setTechnology(mode) { setTechnology(mode) {
this.controls.autoRotate = false;
this.controls.enableDamping = false;
this.controls.update();
this.controls.enableDamping = true;
this.controls.enabled = mode !== 'thermal';
this.mode = mode; this.mode = mode;
this.releaseGroup.visible = mode === "nozzle"; this.releaseGroup.visible = mode === "nozzle";
this.nozzleScene.overlay.hidden = mode !== "nozzle"; this.nozzleScene.overlay.hidden = mode !== "nozzle";
@ -178,11 +183,11 @@ export class MonitorScene extends PrintScene {
if (mode === "nozzle") { if (mode === "nozzle") {
this.nozzleScene.focus(); this.nozzleScene.focus();
} else if (mode === "thermal") { } else if (mode === "thermal") {
const direction = new THREE.Vector3(25, 55, 125); const direction = new THREE.Vector3(0, 28, 125);
direction.multiplyScalar(1 / Math.min(1, this.camera.aspect)); direction.multiplyScalar(1 / Math.min(1, this.camera.aspect));
if (this.camera.aspect < 1) direction.multiplyScalar(1.25); if (this.camera.aspect < 1) direction.multiplyScalar(1.25);
this.camera.position.copy(direction);
this.controls.target.set(-9, 27, 0); this.controls.target.set(-9, 27, 0);
this.camera.position.copy(this.controls.target).add(direction);
this.controls.update(); this.controls.update();
} else this.setView("perspective"); } else this.setView("perspective");
} }
@ -196,7 +201,6 @@ export class MonitorScene extends PrintScene {
this.workflow.group.visible = false; this.workflow.group.visible = false;
this.thermalScene.update(options.thermalSignal); this.thermalScene.update(options.thermalSignal);
this.controls.autoRotate = false; this.controls.autoRotate = false;
this.controls.update();
this.renderer.render(this.scene, this.camera); this.renderer.render(this.scene, this.camera);
return; return;
} }

View File

@ -237,6 +237,8 @@ export class ThermalScene {
}); });
this.filament.position.y = 52 + Math.sin(this.time * 5) * 0.7; this.filament.position.y = 52 + Math.sin(this.time * 5) * 0.7;
this.host.container.dataset.thermal = JSON.stringify({ this.host.container.dataset.thermal = JSON.stringify({
cameraPosition: this.host.camera.position.toArray(),
cameraQuaternion: this.host.camera.quaternion.toArray(),
fanAngle: this.fan.rotation.z, fanAngle: this.fan.rotation.z,
travel: this.travel, travel: this.travel,
power: signal.power, power: signal.power,