Skip to content

Commit

Permalink
fix(landing): get messages for text geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Mar 24, 2022
1 parent 05874eb commit 2a08c80
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 35 deletions.
26 changes: 0 additions & 26 deletions packages/better-write-app/src/use/defines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -240,6 +215,5 @@ export const useDefines = () => {
return {
pdf,
themes,
landing,
}
}
24 changes: 15 additions & 9 deletions packages/better-write-app/src/use/webgl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,6 +19,8 @@ export const useWebGL = () => {
const _cloudParticles: any = []
const meshArray: any = []

const { t, getLocaleMessage, locale } = useI18n()

const init = () => {
onMounted(() => {
if (!WebGL.isWebGLAvailable()) {
Expand Down Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -165,10 +171,10 @@ export const useWebGL = () => {
cameraCreate()
rendererCreate()
loaderSmoke()
createNodes()
contextResize()
createLight()
contextResize()
createNodes()
render().then(() => {
isLoaded.value = true
})
Expand Down
9 changes: 9 additions & 0 deletions packages/better-write-localisation/src/pt-BR/landing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
],
},
}

0 comments on commit 2a08c80

Please sign in to comment.