From 24b2e3315386cd3c364e625d1836e9d365d028e5 Mon Sep 17 00:00:00 2001 From: Vitaly Date: Thu, 4 Jan 2024 05:31:43 +0530 Subject: [PATCH 1/4] [skip ci] update pipelines from next --- .github/workflows/preview.yml | 2 ++ .github/workflows/publish.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 52824004..cbd2f1a2 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -29,6 +29,8 @@ jobs: run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - name: Copy playground files run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js + - name: Download Generated Sounds map + run: node scripts/downloadSoundsMap.mjs - name: Deploy Project Artifacts to Vercel uses: mathiasvr/command-output@v2.0.0 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2b84b90c..a52e6ab9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,6 +21,8 @@ jobs: - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} --prod - name: Copy playground files run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js + - name: Download Generated Sounds map + run: node scripts/downloadSoundsMap.mjs - name: Deploy Project to Vercel uses: mathiasvr/command-output@v2.0.0 with: From fd64dac2c020e584abed8e5727aa3a169c5f86a5 Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sun, 18 Feb 2024 13:43:15 +0300 Subject: [PATCH 2/4] add storybook to preview deploys --- .github/workflows/preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index f3722d3a..1db1bb9e 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -27,6 +27,7 @@ jobs: run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - name: Build Project Artifacts run: vercel build --token=${{ secrets.VERCEL_TOKEN }} + - run: pnpm build-storybook - name: Copy playground files run: node prismarine-viewer/esbuild.mjs && cp prismarine-viewer/public/index.html .vercel/output/static/playground.html && cp prismarine-viewer/public/playground.js .vercel/output/static/playground.js - name: Download Generated Sounds map From 96010e940b4a9b5066bc3894c43dbee8379d481e Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Sat, 27 Apr 2024 23:18:27 +0300 Subject: [PATCH 3/4] Merge branch 'next' into release --- prismarine-viewer/examples/playground.ts | 2 +- prismarine-viewer/viewer/lib/entities.js | 38 ++++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/prismarine-viewer/examples/playground.ts b/prismarine-viewer/examples/playground.ts index bc9294ac..295cc47d 100644 --- a/prismarine-viewer/examples/playground.ts +++ b/prismarine-viewer/examples/playground.ts @@ -132,7 +132,7 @@ async function main () { document.body.appendChild(renderer.domElement) // Create viewer - const viewer = new Viewer(renderer, 1) + const viewer = new Viewer(renderer, { numWorkers: 1, showChunkBorders: false }) viewer.entities.setDebugMode('basic') viewer.setVersion(version) viewer.entities.onSkinUpdate = () => { diff --git a/prismarine-viewer/viewer/lib/entities.js b/prismarine-viewer/viewer/lib/entities.js index 350dc53e..290c3932 100644 --- a/prismarine-viewer/viewer/lib/entities.js +++ b/prismarine-viewer/viewer/lib/entities.js @@ -17,7 +17,7 @@ import externalTexturesJson from './entity/externalTextures.json' export const TWEEN_DURATION = 50 // todo should be 100 -function getUsernameTexture (username, { fontFamily = 'sans-serif' }) { +function getUsernameTexture(username, { fontFamily = 'sans-serif' }) { const canvas = document.createElement('canvas') const ctx = canvas.getContext('2d') if (!ctx) throw new Error('Could not get 2d context') @@ -58,7 +58,10 @@ const addNametag = (entity, options, mesh) => { } } -function getEntityMesh (entity, scene, options, overrides) { +// todo cleanup +const nametags = {} + +function getEntityMesh(entity, scene, options, overrides) { if (entity.name) { try { // https://github.com/PrismarineJS/prismarine-viewer/pull/410 @@ -78,10 +81,13 @@ function getEntityMesh (entity, scene, options, overrides) { geometry.translate(0, entity.height / 2, 0) const material = new THREE.MeshBasicMaterial({ color: 0xff_00_ff }) const cube = new THREE.Mesh(geometry, material) - addNametag({ - username: entity.name, - height: entity.height, - }, options, cube) + const nametagCount = (nametags[entity.name] = (nametags[entity.name] || 0) + 1) + if (nametagCount < 6) { + addNametag({ + username: entity.name, + height: entity.height, + }, options, cube) + } return cube } @@ -99,7 +105,7 @@ export class Entities extends EventEmitter { this.getItemUv = undefined } - clear () { + clear() { for (const mesh of Object.values(this.entities)) { this.scene.remove(mesh) dispose3(mesh) @@ -107,7 +113,7 @@ export class Entities extends EventEmitter { this.entities = {} } - setDebugMode (mode, /** @type {THREE.Object3D?} */entity = null) { + setDebugMode(mode, /** @type {THREE.Object3D?} */entity = null) { this.debugMode = mode for (const mesh of entity ? [entity] : Object.values(this.entities)) { const boxHelper = mesh.children.find(c => c.name === 'debug') @@ -119,14 +125,14 @@ export class Entities extends EventEmitter { } } - setVisible (visible, /** @type {THREE.Object3D?} */entity = null) { + setVisible(visible, /** @type {THREE.Object3D?} */entity = null) { this.visible = visible for (const mesh of entity ? [entity] : Object.values(this.entities)) { mesh.visible = visible } } - render () { + render() { const dt = this.clock.getDelta() for (const entityId of Object.keys(this.entities)) { const playerObject = this.getPlayerObject(entityId) @@ -136,7 +142,7 @@ export class Entities extends EventEmitter { } } - getPlayerObject (entityId) { + getPlayerObject(entityId) { /** @type {(PlayerObject & { animation?: PlayerAnimation }) | undefined} */ const playerObject = this.entities[entityId]?.playerObject return playerObject @@ -146,7 +152,7 @@ export class Entities extends EventEmitter { defaultSteveTexture // true means use default skin url - updatePlayerSkin (entityId, username, /** @type {string | true} */skinUrl, /** @type {string | true | undefined} */capeUrl = undefined) { + updatePlayerSkin(entityId, username, /** @type {string | true} */skinUrl, /** @type {string | true | undefined} */capeUrl = undefined) { let playerObject = this.getPlayerObject(entityId) if (!playerObject) return // const username = this.entities[entityId].username @@ -229,14 +235,14 @@ export class Entities extends EventEmitter { playerObject.cape.map = null } - function isCanvasBlank (canvas) { + function isCanvasBlank(canvas) { return !canvas.getContext('2d') .getImageData(0, 0, canvas.width, canvas.height).data .some(channel => channel !== 0) } } - playAnimation (entityPlayerId, /** @type {'walking' | 'running' | 'oneSwing' | 'idle'} */animation) { + playAnimation(entityPlayerId, /** @type {'walking' | 'running' | 'oneSwing' | 'idle'} */animation) { const playerObject = this.getPlayerObject(entityPlayerId) if (!playerObject) return @@ -256,14 +262,14 @@ export class Entities extends EventEmitter { } - displaySimpleText (jsonLike) { + displaySimpleText(jsonLike) { if (!jsonLike) return const parsed = mojangson.simplify(mojangson.parse(jsonLike)) const text = flat(parsed).map(x => x.text) return text.join('') } - update (/** @type {import('prismarine-entity').Entity & {delete?, pos}} */entity, overrides) { + update(/** @type {import('prismarine-entity').Entity & {delete?, pos}} */entity, overrides) { let isPlayerModel = entity.name === 'player' if (entity.name === 'zombie' || entity.name === 'zombie_villager' || entity.name === 'husk') { isPlayerModel = true From ad275ae7d17a9c1016307b51e21e50d4444cc85b Mon Sep 17 00:00:00 2001 From: Vitaly Turovsky Date: Fri, 5 Sep 2025 01:05:05 +0300 Subject: [PATCH 4/4] up splash --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index 940fb738..729450a0 100644 --- a/config.json +++ b/config.json @@ -27,7 +27,7 @@ } ], "rightSideText": "A Minecraft client clone in the browser!", - "splashText": "The sunset is coming!", + "splashText": "We are back!", "splashTextFallback": "Welcome!", "pauseLinks": [ [