|
@@ -76,3 +76,33 @@ viewer.destroy()
|
|
|
clock = 999
|
|
clock = 999
|
|
|
assert.equal(frames.length, 0)
|
|
assert.equal(frames.length, 0)
|
|
|
console.log('PASS 镜头定位为逐帧缓动飞行:受理不瞬移/半程插值/到期正对设备/拖拽接管取消/销毁停止')
|
|
console.log('PASS 镜头定位为逐帧缓动飞行:受理不瞬移/半程插值/到期正对设备/拖拽接管取消/销毁停止')
|
|
|
|
|
+
|
|
|
|
|
+// ---- 生产默认路径(不注入 scheduleFrame/now,用真实计时器)----
|
|
|
|
|
+// 注入接缝只能证明「插值逻辑对」,还要证明**默认路径真的会跑**:用户看到的就是这条。
|
|
|
|
|
+{
|
|
|
|
|
+ const plan2 = planPipeEnhancement({ selected: { kind: 'pipe', code: 'P' }, visiblePipes: [
|
|
|
|
|
+ { code: 'P', industry: 'WATER_SUPPLY', diameter: 400, positions: [[110, 28], [110.001, 28]] },
|
|
|
|
|
+ ] })
|
|
|
|
|
+ Object.assign(plan2, planEnhancementDevices(plan2, [
|
|
|
|
|
+ { code: 'D', name: '测试流量计', industry: 'WATER_SUPPLY', pointCode: 'MP', longitude: 110.0005, latitude: 28, coordinate: { renderable: true } },
|
|
|
|
|
+ ]))
|
|
|
|
|
+ let sc2, cam2
|
|
|
|
|
+ const v2 = mountPipeEnhancement(host, plan2, {
|
|
|
|
|
+ rendererFactory: () => ({ domElement: canvas, setSize() {}, dispose() {}, render(s2, c2) { sc2 = s2; cam2 = c2 } }),
|
|
|
|
|
+ iconResolver: async (d) => ({ url: 'mock://' + d.code, width: 26.7, height: 33.5 }),
|
|
|
|
|
+ loadTexture: (url, onLoad) => { const t = new THREE.Texture(); t.image = { data: new Uint8Array([255, 255, 255, 255]), width: 1, height: 1 }; onLoad(t) },
|
|
|
|
|
+ })
|
|
|
|
|
+ sc2.updateMatrixWorld(true)
|
|
|
|
|
+ const body2 = sc2.getObjectByName('device:D').getObjectByName('device-body')
|
|
|
|
|
+ const before2 = cam2.position.clone()
|
|
|
|
|
+ assert.equal(v2.focusDevice('D'), true)
|
|
|
|
|
+ // 真实计时器推进:等待超过动画时长。
|
|
|
|
|
+ await new Promise((r) => setTimeout(r, 900))
|
|
|
|
|
+ const moved = cam2.position.distanceTo(before2)
|
|
|
|
|
+ assert.ok(moved > 1e-3, '生产默认路径(真实 rAF/timer)必须真的移动相机')
|
|
|
|
|
+ const dir = new THREE.Vector3(0, 0, -1).applyQuaternion(cam2.quaternion)
|
|
|
|
|
+ const toTarget = body2.getWorldPosition(new THREE.Vector3()).sub(cam2.position).normalize()
|
|
|
|
|
+ assert.ok(dir.dot(toTarget) > 0.99, '真实计时器下飞行结束也应正对设备')
|
|
|
|
|
+ v2.destroy()
|
|
|
|
|
+ console.log('PASS 生产默认路径(真实计时器)下镜头确实飞行并正对设备')
|
|
|
|
|
+}
|