123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- import { TaggingPosition } from "@/api";
- import { custom, showTaggingPositionsStack } from "@/env";
- import { currentModel, fuseModel, loadModel } from "@/model";
- import { sdk, getTaggingPosNode, setPose, getSceneMeasure, playSceneGuide, pauseSceneGuide, activeModel } from "@/sdk";
- import { getPathNode, pauseScenePath, playScenePath } from "@/sdk/association/path";
- import {
- getFuseModel,
- getFuseModelShowVariable,
- getTaggingPositions,
- Measure,
- Tagging,
- Path,
- View,
- viewToModelType,
- Guide,
- getGuidePaths,
- FuseModel,
- } from "@/store";
- import { nextTick, ref } from "vue";
- let stopFly: (() => void) | null = null;
- export const flyTagging = (tagging: Tagging, callback?: () => void) => {
- stopFly && stopFly();
- const positions = getTaggingPositions(tagging);
- console.error('fly tagging')
- let timeout: any
- let isStop = false;
- const flyIndex = (i: number) => {
- if (isStop || i >= positions.length) {
- callback && nextTick(callback);
- return;
- }
- const position = positions[i];
- const model = getFuseModel(position.modelId);
- if (!model || !getFuseModelShowVariable(model).value) {
- flyIndex(i + 1);
- return;
- }
- const pop = showTaggingPositionsStack.push(ref(new WeakSet([position])));
- flyTaggingPosition(position);
- timeout = setTimeout(() => {
- pop();
- flyIndex(i + 1);
- }, 2000);
- };
- flyIndex(0);
- stopFly = () => {
- clearTimeout(timeout)
- isStop = true;
- stopFly = null;
- };
- return stopFly;
- };
- export const flyTaggingPosition = (position: TaggingPosition) => {
- if (position.pose) {
- setPose({
- modelId: position.modelId,
- dur: 300,
- // distance: 3,
- maxDis: 15,
- isFlyToTag: true,
- focusPos: getTaggingPosNode(position)!.getImageCenter(),
- ...position.pose
- } as any, sdk, false);
- } else {
- sdk.comeTo({
- position: getTaggingPosNode(position)!.getImageCenter(),
- modelId: position.modelId,
- dur: 300,
- // distance: 3,
- maxDis: 15,
- isFlyToTag: true,
- });
- }
- };
- export const flyMeasure = (data: Measure) => {
- stopFly && stopFly();
- getSceneMeasure(data)?.fly();
- };
- export const flyPath = (path: Path) => {
- stopFly && stopFly();
- getPathNode(path.id)?.fly();
- getPathNode(path.id)?.focus(true);
- };
- export const flyView = (view: View) => {
- stopFly && stopFly();
- let isStop = false;
- stopFly = () => {
- isStop = true;
- stopFly = null
- };
- const modelType = viewToModelType(view);
- loadModel(modelType).then((sdk) => {
- if (!isStop) {
- custom.currentView = view;
- sdk.setView(view.flyData);
- }
- });
- return stopFly;
- };
- export const flyPlayGuide = (guide: Guide) => {
- stopFly && stopFly()
- stopFly = () => {
- stopFly = null
- pauseSceneGuide()
- }
- playSceneGuide(getGuidePaths(guide), undefined, true, guide)
- return stopFly
- }
- export const flyPlayPath = (path: Path) => {
- stopFly && stopFly()
- stopFly = () => {
- stopFly = null
- pauseScenePath()
- }
- playScenePath(path, true);
- return stopFly
- }
- export const flyLatLng = (latlng: number[]) => {
- stopFly && stopFly();
- sdk.comeToByLatLng(latlng)
- }
- export const flyModel = (model: FuseModel, mode: "pano" | "fuse", f = false) => {
- stopFly && stopFly();
- if (getFuseModelShowVariable(model).value) {
- if (custom.currentModel === model && mode === custom.showMode) {
- if (!f) return;
- activeModel({ showMode: "fuse", active: undefined, fore: f });
- } else {
- activeModel({ showMode: mode, active: model, fore: f });
- }
- }
- if (currentModel.value !== fuseModel) {
- loadModel(fuseModel);
- }
- };
|