Skip to content

Commit

Permalink
✨ feat: control grid
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhUyU1997 committed Apr 15, 2023
1 parent 547cc02 commit d52fa7d
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 12 deletions.
15 changes: 15 additions & 0 deletions src/components/Menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,21 @@ const MenubarDemo: React.FC<{
</Menubar.ItemIndicator>
{i18n.t('Show Preview')}
</Menubar.CheckboxItem>
<Menubar.CheckboxItem
className={classNames(MenubarCheckboxItem, inset)}
checked={editor.EnableHelper}
onCheckedChange={() => {
editor.EnableHelper = !editor.EnableHelper
forceUpdate()
}}
>
<Menubar.ItemIndicator
className={MenubarItemIndicator}
>
<CheckIcon />
</Menubar.ItemIndicator>
{i18n.t('Show Grid')}
</Menubar.CheckboxItem>
</Menubar.Content>
</Menubar.Portal>
</Menubar.Menu>
Expand Down
29 changes: 25 additions & 4 deletions src/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ export class BodyEditor {
effectSobel?: ShaderPass
enableComposer = false
enablePreview = true
enableHelper = true

paused = false

parentElem: ParentElement
Expand Down Expand Up @@ -1152,11 +1154,23 @@ export class BodyEditor {
// eslint-disable-next-line @typescript-eslint/no-empty-function
return () => {}
}
changeHelper() {
const old = {
axesHelper: this.axesHelper.visible,
gridHelper: this.gridHelper.visible,
}
this.axesHelper.visible = false
this.gridHelper.visible = false

return () => {
this.axesHelper.visible = old.axesHelper
this.gridHelper.visible = old.gridHelper
}
}
MakeImages() {
this.renderer.setClearColor(0x000000)

this.axesHelper.visible = false
this.gridHelper.visible = false
const restoreHelper = this.changeHelper()

const restoreTransfromControl = this.changeTransformControl()
const restoreView = this.changeView()
Expand All @@ -1172,8 +1186,7 @@ export class BodyEditor {
/// end

this.renderer.setClearColor(0x000000, 0)
this.axesHelper.visible = true
this.gridHelper.visible = true
restoreHelper()

restoreTransfromControl()
restoreView()
Expand Down Expand Up @@ -1377,6 +1390,14 @@ export class BodyEditor {
this.setFootVisible(!this.onlyHand)
}

get EnableHelper() {
return this.enableHelper
}
set EnableHelper(value: boolean) {
this.enableHelper = value
this.gridHelper.visible = value
this.axesHelper.visible = value
}
setFootVisible(value: boolean) {
this.traverseExtremities((o) => {
if (IsFoot(o.name)) {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "Geste laden",
"Save Gesture": "Geste speichern",
"Please select a hand!!": "Bitte wählen Sie eine Hand aus!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "Bei dem Versuch, Anime-Charaktere zu erkennen, kann es zu einem Fehler kommen. Bitte versuchen Sie es erneut mit Fotos."
"If you try to detect anime characters, you may get an error. Please try again with photos.": "Bei dem Versuch, Anime-Charaktere zu erkennen, kann es zu einem Fehler kommen. Bitte versuchen Sie es erneut mit Fotos.",
"Show Grid": "Gitter anzeigen"
}
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "Load Gesture",
"Save Gesture": "Save Gesture",
"Please select a hand!!": "Please select a hand!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "If you try to detect anime characters, you may get an error. Please try again with photos."
"If you try to detect anime characters, you may get an error. Please try again with photos.": "If you try to detect anime characters, you may get an error. Please try again with photos.",
"Show Grid": "Show Grid"
}
3 changes: 2 additions & 1 deletion src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "ジェスチャーを読み込む",
"Save Gesture": "ジェスチャーを保存する",
"Please select a hand!!": "手を選択してください!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "アニメキャラクターを検出しようとするとエラーが発生する場合があります。写真で再度お試しください。"
"If you try to detect anime characters, you may get an error. Please try again with photos.": "アニメキャラクターを検出しようとするとエラーが発生する場合があります。写真で再度お試しください。",
"Show Grid": "グリッドを表示"
}
3 changes: 2 additions & 1 deletion src/locales/sp.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "Cargar gesto",
"Save Gesture": "Guardar gesto",
"Please select a hand!!": "¡¡Por favor, seleccione una mano!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "Si intenta detectar personajes de anime, es posible que obtenga un error. Por favor, inténtelo de nuevo con fotos."
"If you try to detect anime characters, you may get an error. Please try again with photos.": "Si intenta detectar personajes de anime, es posible que obtenga un error. Por favor, inténtelo de nuevo con fotos.",
"Show Grid": "Mostrar cuadrícula"
}
3 changes: 2 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "加载手势",
"Save Gesture": "保存手势",
"Please select a hand!!": "请选择一只手!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您尝试检测动漫角色,可能会出现错误。请使用照片再试一次。"
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您尝试检测动漫角色,可能会出现错误。请使用照片再试一次。",
"Show Grid": "显示网格"
}
3 changes: 2 additions & 1 deletion src/locales/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "載入手勢",
"Save Gesture": "儲存手勢",
"Please select a hand!!": "請選擇一隻手!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您嘗試檢測動漫角色,可能會出現錯誤。請使用照片再試一次。"
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您嘗試檢測動漫角色,可能會出現錯誤。請使用照片再試一次。",
"Show Grid": "顯示網格"
}
3 changes: 2 additions & 1 deletion src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
"Load Gesture": "載入手勢",
"Save Gesture": "儲存手勢",
"Please select a hand!!": "請選擇一隻手!!",
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您嘗試檢測動漫角色,可能會出現錯誤。請使用照片再試一次。"
"If you try to detect anime characters, you may get an error. Please try again with photos.": "如果您嘗試檢測動漫角色,可能會出現錯誤。請使用照片再試一次。",
"Show Grid": "顯示網格"
}
2 changes: 1 addition & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const config: UserConfigFn = ({ command, mode, ssrBuild }) => {
base: mode === 'singlefile' ? './' : '/open-pose-editor/',
define: {
global: {},
__APP_VERSION__: JSON.stringify('0.1.17'),
__APP_VERSION__: JSON.stringify('0.1.18'),
__APP_BUILD_TIME__: Date.now(),
},
build: {
Expand Down

0 comments on commit d52fa7d

Please sign in to comment.