From 2a08c803bf637452d09f92ad99a8c4e9327868aa Mon Sep 17 00:00:00 2001 From: Giovane Cardoso Date: Thu, 24 Mar 2022 00:09:54 -0300 Subject: [PATCH] fix(landing): get messages for text geometry --- packages/better-write-app/src/use/defines.ts | 26 ------------------- packages/better-write-app/src/use/webgl.ts | 24 ++++++++++------- .../src/pt-BR/landing.ts | 9 +++++++ 3 files changed, 24 insertions(+), 35 deletions(-) diff --git a/packages/better-write-app/src/use/defines.ts b/packages/better-write-app/src/use/defines.ts index 8b8437be8..cb5a88f74 100644 --- a/packages/better-write-app/src/use/defines.ts +++ b/packages/better-write-app/src/use/defines.ts @@ -4,31 +4,6 @@ import i18n from '@/lang' export const useDefines = () => { const { t } = i18n.global - const landing = () => { - const name = () => { - // vue-i18n limitation zzzzzzzzzzzzzzz - const arr = [ - t('landing.first.paragraphs[0]'), - t('landing.first.paragraphs[1]'), - t('landing.first.paragraphs[3]'), - t('landing.first.paragraphs[4]'), - t('landing.first.paragraphs[5]'), - t('landing.first.paragraphs[6]'), - t('landing.first.paragraphs[7]'), - t('landing.first.paragraphs[8]'), - t('landing.first.paragraphs[9]'), - t('landing.first.paragraphs[10]'), - t('landing.first.paragraphs[11]'), - t('landing.first.paragraphs[12]'), - t('landing.first.paragraphs[13]'), - ] - - return arr[Math.floor(Math.random() * arr.length)] - } - - return { name } - } - const pdf = () => { const fixFonts = () => { return ['EB Garamond', 'Cormorant Garamond'] @@ -240,6 +215,5 @@ export const useDefines = () => { return { pdf, themes, - landing, } } diff --git a/packages/better-write-app/src/use/webgl.ts b/packages/better-write-app/src/use/webgl.ts index bee4ffbe6..e977c2e82 100644 --- a/packages/better-write-app/src/use/webgl.ts +++ b/packages/better-write-app/src/use/webgl.ts @@ -4,7 +4,7 @@ import { FontLoader } from 'three/examples/jsm/loaders/FontLoader.js' import { TextGeometry } from 'three/examples/jsm/geometries/TextGeometry.js' import WebGL from 'three/examples/jsm/capabilities/WebGL.js' import { onBeforeUnmount, onMounted, ref } from 'vue' -import { useDefines } from './defines' +import { useI18n } from 'vue-i18n' export const useWebGL = () => { const isLoaded = ref(false) @@ -19,6 +19,8 @@ export const useWebGL = () => { const _cloudParticles: any = [] const meshArray: any = [] + const { t, getLocaleMessage, locale } = useI18n() + const init = () => { onMounted(() => { if (!WebGL.isWebGLAvailable()) { @@ -106,24 +108,28 @@ export const useWebGL = () => { } const createNodes = () => { - for (let i = -1000; i < 1000; i += 50) { - const paragraph = new TextGeometry(useDefines().landing().name(), { + const { landing }: any = getLocaleMessage(locale.value) + + const paragraphs = landing.first.paragraphs + + paragraphs.forEach((paragraph) => { + const geometry = new TextGeometry(paragraph, { font: _font, size: Math.floor(Math.random() * 8) + 8, height: 1, }) - const mesh = new THREE.Mesh(paragraph) - mesh.position.x = Math.random() * 2000 - 1000 + i - mesh.position.y = 650 - Math.random() * 170 - mesh.position.z = Math.random() * 2000 - 1000 + i + const mesh = new THREE.Mesh(geometry) + mesh.position.x = Math.random() * 2500 - 1000 + mesh.position.y = 650 - Math.random() * 10 + mesh.position.z = Math.random() * 2500 - 1000 mesh.rotation.x = 1.16 mesh.rotation.y = -0.12 mesh.rotation.z = 0.57 meshArray.push(mesh) scene.add(mesh) - } + }) } const render = () => { @@ -165,10 +171,10 @@ export const useWebGL = () => { cameraCreate() rendererCreate() loaderSmoke() + createNodes() contextResize() createLight() contextResize() - createNodes() render().then(() => { isLoaded.value = true }) diff --git a/packages/better-write-localisation/src/pt-BR/landing.ts b/packages/better-write-localisation/src/pt-BR/landing.ts index cc991d6c0..62078972c 100644 --- a/packages/better-write-localisation/src/pt-BR/landing.ts +++ b/packages/better-write-localisation/src/pt-BR/landing.ts @@ -41,6 +41,15 @@ Recebendo o amor doloroso, Aceitei a dormência.`, ` Clima tenso. Correndo contra tudo, a virtude não teve dúvidas de quem realmente está do lado certo.`, + ` — Aparentemente, está vazio. Cadê... tudo?`, + ` A chave foi inserida. + Nada acontece. + Pullio percebe que a chave está do lado +inverso. Acontece + A porta abre.`, + ` — Enganação... quem esgana quem?`, + ` — Positividade sempre.`, + ` — Questionar nunca será problemático.`, ], }, }