Skip to content

Commit da21696

Browse files
committed
refactor: change props of realTime to mediaPipe
1 parent fd54024 commit da21696

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ import '@cloudgeek/vitar/dist/index.css'
6262
| Name | Type | Default | Description |
6363
| -------------- | :--------------: | :--------------: | -------------- |
6464
| model | boolean \| string| true | true: use default model of hiyori, false: don't show model, string: url of model.|
65-
| realTime | boolean | true | whether to use mediapipe for real-time avatar.|
65+
| mediaPipe | boolean | true | whether to use mediapipe for real-time avatar.|
6666
| showCam | boolean | false | whether to show camera view.|
6767
| showMesh | boolean | false | whether to show mesh view.|
6868
| zIndex | number | 9999 | z-index of avatar.|

lib/Live2D.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Renderer.registerPlugin('interaction', InteractionManager)
2020
const props = defineProps({
2121
model: [Boolean, String],
2222
cdn: Boolean,
23-
realTime: Boolean,
23+
mediaPipe: Boolean,
2424
showMesh: Boolean,
2525
showCam: Boolean,
2626
zIndex: Number,
@@ -234,7 +234,7 @@ const onResults = (results: f.Results) => {
234234
}
235235
236236
async function initMediapipe() {
237-
if (!props.realTime)
237+
if (!props.mediaPipe)
238238
return
239239
if (props.cdn) {
240240
mpFaceMesh = window as any
@@ -292,12 +292,12 @@ function fixPosition() {
292292
}
293293
294294
watch(() => props.showCam, () => {
295-
if (props.realTime)
295+
if (props.mediaPipe)
296296
camView.value!.style.visibility = props.showCam ? 'visible' : 'hidden'
297297
})
298298
299299
watch(() => props.showMesh, () => {
300-
if (props.realTime) {
300+
if (props.mediaPipe) {
301301
const canvasCtx = guideCanvas.value!.getContext('2d')
302302
canvasCtx!.clearRect(0, 0, guideCanvas.value!.width, guideCanvas.value!.height)
303303
guideCanvas.value!.style.visibility = props.showMesh ? 'inline' : 'none'
@@ -335,7 +335,7 @@ onMounted(async() => {
335335
:class="[handlerDown ? '!opacity-100' : '', loaded ? 'bg-green-500' : 'bg-red-500']"
336336
/>
337337
<div
338-
v-if="realTime"
338+
v-if="mediaPipe"
339339
class="absolute bottom-0"
340340
style="transform: rotateY(180deg);"
341341
:style="[frameStyle, {right: `${size}px`}]"

lib/Vitar.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const props = defineProps({
1818
type: [Boolean, String],
1919
default: true,
2020
},
21-
realTime: {
21+
mediaPipe: {
2222
type: Boolean,
2323
default: true,
2424
},
@@ -40,15 +40,15 @@ const isDev = import.meta.env.MODE === 'development'
4040
const vm = getCurrentInstance()!
4141
4242
async function create() {
43-
if (props.realTime || props.model)
43+
if (props.mediaPipe || props.model)
4444
import('./Live2D.vue').then(v => Live2DLayer.value = v.default)
4545
}
4646
47-
if (props.realTime && (window as any).FaceMesh && (window as any).Camera && (window as any).drawConnectors && (window as any).Live2D && (window as any).Live2DCubismCore) {
47+
if (props.mediaPipe && (window as any).FaceMesh && (window as any).Camera && (window as any).drawConnectors && (window as any).Live2D && (window as any).Live2DCubismCore) {
4848
onMounted(create)
4949
}
5050
else {
51-
if (props.realTime && !isDev && (!(window as any).FaceMesh || !(window as any).Camera || !(window as any).drawConnectors)) {
51+
if (props.mediaPipe && !isDev && (!(window as any).FaceMesh || !(window as any).Camera || !(window as any).drawConnectors)) {
5252
useScriptTag(
5353
'https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/face_mesh.js',
5454
() => {
@@ -111,6 +111,6 @@ watch([isLive2dLoad, isCubismLoad, isFaceMeshLoad, isCameraUtilsLoad, isDrawiing
111111

112112
<template>
113113
<template v-if="Live2DLayer">
114-
<Live2DLayer :model="model" :real-time="realTime" :show-cam="showCam" :show-mesh="showMesh" :cdn="!isDev" :z-index="zIndex" />
114+
<Live2DLayer :model="model" :media-pipe="mediaPipe" :show-cam="showCam" :show-mesh="showMesh" :cdn="!isDev" :z-index="zIndex" />
115115
</template>
116116
</template>

src/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import { Vitar } from '../lib/index'
33
const showCam = ref(false)
44
const showMesh = ref(true)
5-
const realTime = ref(true)
5+
const mediaPipe = ref(true)
66
const model = ref(true)
77
const zIndex = ref(100)
88
</script>
99
<template>
1010
<main font-sans p="x-4 y-10" text="center gray-700 dark:gray-200">
11-
<vitar :show-mesh="showMesh" :z-index="zIndex" :show-cam="showCam" :model="model" :real-time="realTime" />
11+
<vitar :show-mesh="showMesh" :z-index="zIndex" :show-cam="showCam" :model="model" :media-pipe="mediaPipe" />
1212
<button @click="showCam = !showCam">
1313
show camera
1414
</button>

0 commit comments

Comments
 (0)