|
@@ -20,10 +20,7 @@
|
|
:in-full="true"
|
|
:in-full="true"
|
|
@pull="(index) => (pullIndex = index)"
|
|
@pull="(index) => (pullIndex = index)"
|
|
/>
|
|
/>
|
|
- <div
|
|
|
|
- class="edit-hot"
|
|
|
|
- v-if="router.currentRoute.value.name === RoutesName.tagging"
|
|
|
|
- >
|
|
|
|
|
|
+ <div class="edit-hot" v-if="showDelete">
|
|
<span @click="$emit('delete')" class="fun-ctrl">
|
|
<span @click="$emit('delete')" class="fun-ctrl">
|
|
<ui-icon type="del" />
|
|
<ui-icon type="del" />
|
|
删除
|
|
删除
|
|
@@ -42,19 +39,19 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
-import { computed, onUnmounted, ref, watch, watchEffect } from "vue";
|
|
|
|
-import { router, RoutesName } from "@/router";
|
|
|
|
|
|
+import { computed, markRaw, onUnmounted, ref, watch, watchEffect } from "vue";
|
|
import UIBubble from "bill/components/bubble/index.vue";
|
|
import UIBubble from "bill/components/bubble/index.vue";
|
|
import Images from "@/views/tagging/images.vue";
|
|
import Images from "@/views/tagging/images.vue";
|
|
-import Preview, { MediaType } from "../static-preview/index.vue";
|
|
|
|
|
|
+import Preview from "../static-preview/index.vue";
|
|
import { getTaggingStyle } from "@/store";
|
|
import { getTaggingStyle } from "@/store";
|
|
import { getFileUrl } from "@/utils";
|
|
import { getFileUrl } from "@/utils";
|
|
-import { sdk } from "@/sdk";
|
|
|
|
|
|
+import { sdk, TaggingPositionNode } from "@/sdk";
|
|
import { custom, getResource } from "@/env";
|
|
import { custom, getResource } from "@/env";
|
|
|
|
|
|
import type { Tagging, TaggingPosition } from "@/store";
|
|
import type { Tagging, TaggingPosition } from "@/store";
|
|
import { useCameraChange, usePixel } from "@/hook/use-pixel";
|
|
import { useCameraChange, usePixel } from "@/hook/use-pixel";
|
|
import { useViewStack } from "@/hook";
|
|
import { useViewStack } from "@/hook";
|
|
|
|
+import { inRevise } from "bill/utils";
|
|
|
|
|
|
export type SignProps = { tagging: Tagging; scenePos: TaggingPosition; show?: boolean };
|
|
export type SignProps = { tagging: Tagging; scenePos: TaggingPosition; show?: boolean };
|
|
|
|
|
|
@@ -63,7 +60,7 @@ const emit = defineEmits<{
|
|
(e: "delete"): void;
|
|
(e: "delete"): void;
|
|
(
|
|
(
|
|
e: "changePosition",
|
|
e: "changePosition",
|
|
- val: { pos: SceneLocalPos; modelId: string; normal: SceneLocalPos }
|
|
|
|
|
|
+ val: { position: SceneLocalPos; modelId: string; normal: SceneLocalPos }
|
|
): void;
|
|
): void;
|
|
}>();
|
|
}>();
|
|
|
|
|
|
@@ -75,22 +72,27 @@ const queryItems = computed(() =>
|
|
}))
|
|
}))
|
|
);
|
|
);
|
|
const taggingStyle = computed(() => getTaggingStyle(props.tagging.styleId));
|
|
const taggingStyle = computed(() => getTaggingStyle(props.tagging.styleId));
|
|
-const tag = sdk.createTagging({
|
|
|
|
- ...props.scenePos,
|
|
|
|
- title: props.tagging.title,
|
|
|
|
- position: props.scenePos.localPos,
|
|
|
|
- canMove: false,
|
|
|
|
- image: getFileUrl(taggingStyle.value!.icon),
|
|
|
|
-});
|
|
|
|
|
|
+const tag = markRaw(
|
|
|
|
+ sdk.createTagging({
|
|
|
|
+ ...props.scenePos,
|
|
|
|
+ title: props.tagging.title,
|
|
|
|
+ position: props.scenePos.localPos,
|
|
|
|
+ canMove: false,
|
|
|
|
+ image: getFileUrl(taggingStyle.value!.icon),
|
|
|
|
+ })
|
|
|
|
+) as TaggingPositionNode;
|
|
|
|
+const showDelete = ref(false);
|
|
|
|
+tag.showDelete = (show) => {
|
|
|
|
+ showDelete.value = show;
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+tag.changeCanMove(false);
|
|
|
|
|
|
const changePos = () => {
|
|
const changePos = () => {
|
|
pos.value = { localPos: tag.getImageCenter(), modelId: props.scenePos.modelId };
|
|
pos.value = { localPos: tag.getImageCenter(), modelId: props.scenePos.modelId };
|
|
};
|
|
};
|
|
|
|
|
|
watch(taggingStyle, (icon) => icon && tag.changeImage(getFileUrl(icon.icon)));
|
|
watch(taggingStyle, (icon) => icon && tag.changeImage(getFileUrl(icon.icon)));
|
|
-watchEffect(() => {
|
|
|
|
- tag.changeCanMove(router.currentRoute.value.name === RoutesName.tagging);
|
|
|
|
-});
|
|
|
|
watchEffect(() => tag.changeMat(props.scenePos.mat));
|
|
watchEffect(() => tag.changeMat(props.scenePos.mat));
|
|
watchEffect(() => tag.changeFontSize(props.scenePos.fontSize));
|
|
watchEffect(() => tag.changeFontSize(props.scenePos.fontSize));
|
|
watchEffect(() => {
|
|
watchEffect(() => {
|
|
@@ -103,6 +105,35 @@ watchEffect(() => {
|
|
tag.changeType(props.scenePos.type);
|
|
tag.changeType(props.scenePos.type);
|
|
changePos();
|
|
changePos();
|
|
});
|
|
});
|
|
|
|
+const getPosition = () => ({
|
|
|
|
+ position: props.scenePos.localPos,
|
|
|
|
+ normal: props.scenePos.normal,
|
|
|
|
+ modelId: props.scenePos.modelId,
|
|
|
|
+});
|
|
|
|
+let currentPosition = getPosition();
|
|
|
|
+let changeTimeout: any;
|
|
|
|
+tag.bus.on("changePosition", (data) => {
|
|
|
|
+ clearTimeout(changeTimeout);
|
|
|
|
+ emit(
|
|
|
|
+ "changePosition",
|
|
|
|
+ (currentPosition = {
|
|
|
|
+ position: { ...data.pos },
|
|
|
|
+ normal: { ...data.normal },
|
|
|
|
+ modelId: data.modelId,
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+ changePos();
|
|
|
|
+});
|
|
|
|
+
|
|
|
|
+watch(getPosition, (p) => {
|
|
|
|
+ changeTimeout = setTimeout(() => {
|
|
|
|
+ if (inRevise(p, currentPosition)) {
|
|
|
|
+ console.log("更改当前位置");
|
|
|
|
+ tag.changePosition(p);
|
|
|
|
+ currentPosition = p;
|
|
|
|
+ }
|
|
|
|
+ }, 16);
|
|
|
|
+});
|
|
|
|
|
|
const [toCameraDistance] = useCameraChange(() => {
|
|
const [toCameraDistance] = useCameraChange(() => {
|
|
return tag.getCameraDisSquared && tag.getCameraDisSquared();
|
|
return tag.getCameraDisSquared && tag.getCameraDisSquared();
|
|
@@ -114,11 +145,6 @@ const show = computed(
|
|
);
|
|
);
|
|
watchEffect(() => tag.visibility(show.value));
|
|
watchEffect(() => tag.visibility(show.value));
|
|
|
|
|
|
-tag.bus.on("changePosition", (data) => {
|
|
|
|
- emit("changePosition", data);
|
|
|
|
- changePos();
|
|
|
|
-});
|
|
|
|
-
|
|
|
|
const isHover = ref(false);
|
|
const isHover = ref(false);
|
|
tag.bus.on("enter", () => {
|
|
tag.bus.on("enter", () => {
|
|
isHover.value = true;
|
|
isHover.value = true;
|
|
@@ -165,6 +191,8 @@ const iconClickHandler = () => {
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
tag.destory();
|
|
tag.destory();
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+defineExpose(tag);
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|