Spaces:
Running
Running
Vanishing crack fixed
Browse files
js/scenarios/scenario-vanishing-crack.js
CHANGED
|
@@ -11,22 +11,16 @@ import {
|
|
| 11 |
createReportDefectEvent,
|
| 12 |
createDismantleEvent
|
| 13 |
} from '../smrm/actions.js';
|
| 14 |
-
import { setPerspective } from '../state.js';
|
| 15 |
|
| 16 |
-
/**
|
| 17 |
-
* Highlights specified UI elements by IDs with a temporary glowing effect.
|
| 18 |
-
*
|
| 19 |
-
* @param {string[]} elementIds - Array of DOM element IDs to highlight.
|
| 20 |
-
* @param {number} [duration=1200] - Duration of the highlight effect in milliseconds.
|
| 21 |
-
*/
|
| 22 |
export function highlightUI(elementIds, duration = 1200) {
|
| 23 |
if (typeof document === 'undefined' || !Array.isArray(elementIds)) return;
|
| 24 |
elementIds.forEach(id => {
|
| 25 |
const el = document.getElementById(id);
|
| 26 |
if (el) {
|
| 27 |
-
el.classList.add('
|
| 28 |
setTimeout(() => {
|
| 29 |
-
el.classList.remove('
|
| 30 |
}, duration);
|
| 31 |
}
|
| 32 |
});
|
|
@@ -74,9 +68,12 @@ const subtitles = [
|
|
| 74 |
];
|
| 75 |
|
| 76 |
export const vanishingCrackScenario = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
subtitles,
|
| 78 |
timeline: [
|
| 79 |
-
// 1. t = 1.0: Initialize Naive Node mode, Logical (SMIM) perspective so slot & mounted_in edge are visible
|
| 80 |
{
|
| 81 |
id: 'step_1_0_init_naive',
|
| 82 |
time: 1.0,
|
|
@@ -87,8 +84,6 @@ export const vanishingCrackScenario = {
|
|
| 87 |
state.graphEngine = 'MERMAID';
|
| 88 |
}
|
| 89 |
},
|
| 90 |
-
|
| 91 |
-
// 2. t = 15.5: Register Vehicle System_A
|
| 92 |
{
|
| 93 |
id: 'step_15_5_reg_vehicle',
|
| 94 |
time: 15.5,
|
|
@@ -96,12 +91,10 @@ export const vanishingCrackScenario = {
|
|
| 96 |
action(state) {
|
| 97 |
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 98 |
state.currentTime = 15.5;
|
| 99 |
-
const event = createRegisterPartEvent('System_A', state.currentTime, 'Vehicle');
|
| 100 |
if (event) state.eventLog.push(event);
|
| 101 |
}
|
| 102 |
},
|
| 103 |
-
|
| 104 |
-
// 3. t = 18.0: Register Part_M01 and install in System_A (creates Slot_System_A_Part_M01)
|
| 105 |
{
|
| 106 |
id: 'step_18_0_reg_part_install',
|
| 107 |
time: 18.0,
|
|
@@ -109,14 +102,12 @@ export const vanishingCrackScenario = {
|
|
| 109 |
action(state) {
|
| 110 |
highlightUI(['biz-reg-id', 'biz-inst-btn']);
|
| 111 |
state.currentTime = 18.0;
|
| 112 |
-
const regEvent = createRegisterPartEvent('Part_M01', state.currentTime, 'Part');
|
| 113 |
if (regEvent) state.eventLog.push(regEvent);
|
| 114 |
-
const asmEvent = createAssembleEvent('System_A', 'Part_M01', 'mounted_in', state.currentTime);
|
| 115 |
if (asmEvent) state.eventLog.push(asmEvent);
|
| 116 |
}
|
| 117 |
},
|
| 118 |
-
|
| 119 |
-
// 4. t = 43.0: Report Defect crack=2mm on Part_M01 (attached to NODE)
|
| 120 |
{
|
| 121 |
id: 'step_43_0_attach_crack_node',
|
| 122 |
time: 43.0,
|
|
@@ -124,12 +115,10 @@ export const vanishingCrackScenario = {
|
|
| 124 |
action(state) {
|
| 125 |
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 126 |
state.currentTime = 43.0;
|
| 127 |
-
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime);
|
| 128 |
if (event) state.eventLog.push(event);
|
| 129 |
}
|
| 130 |
},
|
| 131 |
-
|
| 132 |
-
// 5. t = 56.5: Rewind thought-experiment defect before switching strategy to NAIVE_EDGE
|
| 133 |
{
|
| 134 |
id: 'step_56_5_revoke_crack_node',
|
| 135 |
time: 56.5,
|
|
@@ -141,8 +130,6 @@ export const vanishingCrackScenario = {
|
|
| 141 |
if (idx !== -1) state.eventLog.splice(idx, 1);
|
| 142 |
}
|
| 143 |
},
|
| 144 |
-
|
| 145 |
-
// 6. t = 58.5: Switch to NAIVE_EDGE
|
| 146 |
{
|
| 147 |
id: 'step_58_5_switch_strategy_edge',
|
| 148 |
time: 58.5,
|
|
@@ -152,8 +139,6 @@ export const vanishingCrackScenario = {
|
|
| 152 |
state.ontology = 'NAIVE_EDGE';
|
| 153 |
}
|
| 154 |
},
|
| 155 |
-
|
| 156 |
-
// 7. t = 61.0: Report Defect crack=2mm on Part_M01 (attached to mounted_in EDGE)
|
| 157 |
{
|
| 158 |
id: 'step_61_0_attach_crack_edge',
|
| 159 |
time: 61.0,
|
|
@@ -161,12 +146,10 @@ export const vanishingCrackScenario = {
|
|
| 161 |
action(state) {
|
| 162 |
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 163 |
state.currentTime = 61.0;
|
| 164 |
-
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime);
|
| 165 |
if (event) state.eventLog.push(event);
|
| 166 |
}
|
| 167 |
},
|
| 168 |
-
|
| 169 |
-
// 8. t = 78.0: Dismantle Part_M01
|
| 170 |
{
|
| 171 |
id: 'step_78_0_dismantle_part',
|
| 172 |
time: 78.0,
|
|
@@ -174,12 +157,10 @@ export const vanishingCrackScenario = {
|
|
| 174 |
action(state) {
|
| 175 |
highlightUI(['biz-dism-part', 'biz-dism-btn']);
|
| 176 |
state.currentTime = 78.0;
|
| 177 |
-
const event = createDismantleEvent('Part_M01', state.currentTime);
|
| 178 |
if (event) state.eventLog.push(event);
|
| 179 |
}
|
| 180 |
},
|
| 181 |
-
|
| 182 |
-
// 9. t = 82.0: Register Warehouse_1
|
| 183 |
{
|
| 184 |
id: 'step_82_0_reg_warehouse',
|
| 185 |
time: 82.0,
|
|
@@ -187,12 +168,10 @@ export const vanishingCrackScenario = {
|
|
| 187 |
action(state) {
|
| 188 |
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 189 |
state.currentTime = 82.0;
|
| 190 |
-
const event = createRegisterPartEvent('Warehouse_1', state.currentTime, 'Warehouse');
|
| 191 |
if (event) state.eventLog.push(event);
|
| 192 |
}
|
| 193 |
},
|
| 194 |
-
|
| 195 |
-
// 10. t = 84.0: Move Part_M01 to Warehouse_1
|
| 196 |
{
|
| 197 |
id: 'step_84_0_store_part',
|
| 198 |
time: 84.0,
|
|
@@ -200,12 +179,10 @@ export const vanishingCrackScenario = {
|
|
| 200 |
action(state) {
|
| 201 |
highlightUI(['biz-store-part', 'biz-store-target', 'biz-store-btn']);
|
| 202 |
state.currentTime = 84.0;
|
| 203 |
-
const event = createAssembleEvent('Warehouse_1', 'Part_M01', 'stored_at', state.currentTime);
|
| 204 |
if (event) state.eventLog.push(event);
|
| 205 |
}
|
| 206 |
},
|
| 207 |
-
|
| 208 |
-
// 11. t = 122.0: Switch to ISO 15926 (4D) in Logical (SMIM) Perspective
|
| 209 |
{
|
| 210 |
id: 'step_122_0_switch_iso',
|
| 211 |
time: 122.0,
|
|
@@ -219,9 +196,6 @@ export const vanishingCrackScenario = {
|
|
| 219 |
]
|
| 220 |
};
|
| 221 |
|
| 222 |
-
/**
|
| 223 |
-
* Dispatches pending timeline actions based on current playback time.
|
| 224 |
-
*/
|
| 225 |
export function onTimeUpdate(currentTime, state, renderGraph) {
|
| 226 |
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 227 |
|
|
@@ -239,9 +213,6 @@ export function onTimeUpdate(currentTime, state, renderGraph) {
|
|
| 239 |
});
|
| 240 |
}
|
| 241 |
|
| 242 |
-
/**
|
| 243 |
-
* Resets execution flags on timeline steps when seeking, stopping, or rewinding.
|
| 244 |
-
*/
|
| 245 |
export function resetTimeline(targetTime = 0) {
|
| 246 |
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 247 |
vanishingCrackScenario.timeline.forEach(step => {
|
|
|
|
| 11 |
createReportDefectEvent,
|
| 12 |
createDismantleEvent
|
| 13 |
} from '../smrm/actions.js';
|
| 14 |
+
import { setPerspective, nextSequence } from '../state.js';
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
export function highlightUI(elementIds, duration = 1200) {
|
| 17 |
if (typeof document === 'undefined' || !Array.isArray(elementIds)) return;
|
| 18 |
elementIds.forEach(id => {
|
| 19 |
const el = document.getElementById(id);
|
| 20 |
if (el) {
|
| 21 |
+
el.classList.add('tour-pulse-highlight'); // Используем тот же CSS класс, что и в QDIKW
|
| 22 |
setTimeout(() => {
|
| 23 |
+
el.classList.remove('tour-pulse-highlight');
|
| 24 |
}, duration);
|
| 25 |
}
|
| 26 |
});
|
|
|
|
| 68 |
];
|
| 69 |
|
| 70 |
export const vanishingCrackScenario = {
|
| 71 |
+
id: 'VANISHING_CRACK',
|
| 72 |
+
title: 'Scenario: The Vanishing Crack',
|
| 73 |
+
audioSrc: './narratives/Ontologies_-_Disappearing_Crack.mp3',
|
| 74 |
+
fallbackDuration: 148,
|
| 75 |
subtitles,
|
| 76 |
timeline: [
|
|
|
|
| 77 |
{
|
| 78 |
id: 'step_1_0_init_naive',
|
| 79 |
time: 1.0,
|
|
|
|
| 84 |
state.graphEngine = 'MERMAID';
|
| 85 |
}
|
| 86 |
},
|
|
|
|
|
|
|
| 87 |
{
|
| 88 |
id: 'step_15_5_reg_vehicle',
|
| 89 |
time: 15.5,
|
|
|
|
| 91 |
action(state) {
|
| 92 |
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 93 |
state.currentTime = 15.5;
|
| 94 |
+
const event = createRegisterPartEvent('System_A', state.currentTime, 'Vehicle', nextSequence());
|
| 95 |
if (event) state.eventLog.push(event);
|
| 96 |
}
|
| 97 |
},
|
|
|
|
|
|
|
| 98 |
{
|
| 99 |
id: 'step_18_0_reg_part_install',
|
| 100 |
time: 18.0,
|
|
|
|
| 102 |
action(state) {
|
| 103 |
highlightUI(['biz-reg-id', 'biz-inst-btn']);
|
| 104 |
state.currentTime = 18.0;
|
| 105 |
+
const regEvent = createRegisterPartEvent('Part_M01', state.currentTime, 'Part', nextSequence());
|
| 106 |
if (regEvent) state.eventLog.push(regEvent);
|
| 107 |
+
const asmEvent = createAssembleEvent('System_A', 'Part_M01', 'mounted_in', state.currentTime, nextSequence());
|
| 108 |
if (asmEvent) state.eventLog.push(asmEvent);
|
| 109 |
}
|
| 110 |
},
|
|
|
|
|
|
|
| 111 |
{
|
| 112 |
id: 'step_43_0_attach_crack_node',
|
| 113 |
time: 43.0,
|
|
|
|
| 115 |
action(state) {
|
| 116 |
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 117 |
state.currentTime = 43.0;
|
| 118 |
+
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime, nextSequence());
|
| 119 |
if (event) state.eventLog.push(event);
|
| 120 |
}
|
| 121 |
},
|
|
|
|
|
|
|
| 122 |
{
|
| 123 |
id: 'step_56_5_revoke_crack_node',
|
| 124 |
time: 56.5,
|
|
|
|
| 130 |
if (idx !== -1) state.eventLog.splice(idx, 1);
|
| 131 |
}
|
| 132 |
},
|
|
|
|
|
|
|
| 133 |
{
|
| 134 |
id: 'step_58_5_switch_strategy_edge',
|
| 135 |
time: 58.5,
|
|
|
|
| 139 |
state.ontology = 'NAIVE_EDGE';
|
| 140 |
}
|
| 141 |
},
|
|
|
|
|
|
|
| 142 |
{
|
| 143 |
id: 'step_61_0_attach_crack_edge',
|
| 144 |
time: 61.0,
|
|
|
|
| 146 |
action(state) {
|
| 147 |
highlightUI(['biz-def-target', 'biz-def-btn']);
|
| 148 |
state.currentTime = 61.0;
|
| 149 |
+
const event = createReportDefectEvent('Part_M01', 'crack', '2mm', state.currentTime, nextSequence());
|
| 150 |
if (event) state.eventLog.push(event);
|
| 151 |
}
|
| 152 |
},
|
|
|
|
|
|
|
| 153 |
{
|
| 154 |
id: 'step_78_0_dismantle_part',
|
| 155 |
time: 78.0,
|
|
|
|
| 157 |
action(state) {
|
| 158 |
highlightUI(['biz-dism-part', 'biz-dism-btn']);
|
| 159 |
state.currentTime = 78.0;
|
| 160 |
+
const event = createDismantleEvent('Part_M01', state.currentTime, nextSequence());
|
| 161 |
if (event) state.eventLog.push(event);
|
| 162 |
}
|
| 163 |
},
|
|
|
|
|
|
|
| 164 |
{
|
| 165 |
id: 'step_82_0_reg_warehouse',
|
| 166 |
time: 82.0,
|
|
|
|
| 168 |
action(state) {
|
| 169 |
highlightUI(['biz-reg-id', 'biz-reg-btn']);
|
| 170 |
state.currentTime = 82.0;
|
| 171 |
+
const event = createRegisterPartEvent('Warehouse_1', state.currentTime, 'Warehouse', nextSequence());
|
| 172 |
if (event) state.eventLog.push(event);
|
| 173 |
}
|
| 174 |
},
|
|
|
|
|
|
|
| 175 |
{
|
| 176 |
id: 'step_84_0_store_part',
|
| 177 |
time: 84.0,
|
|
|
|
| 179 |
action(state) {
|
| 180 |
highlightUI(['biz-store-part', 'biz-store-target', 'biz-store-btn']);
|
| 181 |
state.currentTime = 84.0;
|
| 182 |
+
const event = createAssembleEvent('Warehouse_1', 'Part_M01', 'stored_at', state.currentTime, nextSequence());
|
| 183 |
if (event) state.eventLog.push(event);
|
| 184 |
}
|
| 185 |
},
|
|
|
|
|
|
|
| 186 |
{
|
| 187 |
id: 'step_122_0_switch_iso',
|
| 188 |
time: 122.0,
|
|
|
|
| 196 |
]
|
| 197 |
};
|
| 198 |
|
|
|
|
|
|
|
|
|
|
| 199 |
export function onTimeUpdate(currentTime, state, renderGraph) {
|
| 200 |
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 201 |
|
|
|
|
| 213 |
});
|
| 214 |
}
|
| 215 |
|
|
|
|
|
|
|
|
|
|
| 216 |
export function resetTimeline(targetTime = 0) {
|
| 217 |
if (!Array.isArray(vanishingCrackScenario.timeline)) return;
|
| 218 |
vanishingCrackScenario.timeline.forEach(step => {
|