diff --git a/index.html b/index.html index 8182f783e..304ee0a6c 100644 --- a/index.html +++ b/index.html @@ -1,6 +1,7 @@
+ diff --git a/package.json b/package.json index 5337cebfb..bd18bc038 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "esbuild-plugin-polyfill-node": "^0.3.0", "express": "^4.18.2", "filesize": "^10.0.12", - "flying-squid": "npm:@zardoy/flying-squid@^0.0.36", + "flying-squid": "npm:@zardoy/flying-squid@^0.0.38", "fs-extra": "^11.1.1", "google-drive-browserfs": "github:zardoy/browserfs#google-drive", "jszip": "^3.10.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8075be60e..77810ab07 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -117,8 +117,8 @@ importers: specifier: ^10.0.12 version: 10.0.12 flying-squid: - specifier: npm:@zardoy/flying-squid@^0.0.36 - version: '@zardoy/flying-squid@0.0.36(encoding@0.1.13)' + specifier: npm:@zardoy/flying-squid@^0.0.38 + version: '@zardoy/flying-squid@0.0.38(encoding@0.1.13)' fs-extra: specifier: ^11.1.1 version: 11.1.1 @@ -3390,8 +3390,8 @@ packages: resolution: {integrity: sha512-6xm38yGVIa6mKm/DUCF2zFFJhERh/QWp1ufm4cNUvxsONBmfPg8uZ9pZBdOmF6qFGr/HlT6ABBkCSx/dlEtvWg==} engines: {node: '>=12 <14 || 14.2 - 14.9 || >14.10.0'} - '@zardoy/flying-squid@0.0.36': - resolution: {integrity: sha512-d4clMPDpw723SDF5P2mMVNfbthUFLX6OT+vTCECAMshX8/M7CyMq/q9BfBQoeJcBL0H9nplhwtFbnx3Edb2fzA==} + '@zardoy/flying-squid@0.0.38': + resolution: {integrity: sha512-xz/ZuWmva3mlT1cigOudOMqa5iQF2sWsUUVeBNUoqfHscXoXl0TIOXnRScBeEGZjY2fD7meJ24nlcInewgNfZg==} engines: {node: '>=8'} hasBin: true @@ -13366,7 +13366,7 @@ snapshots: '@types/emscripten': 1.39.8 tslib: 1.14.1 - '@zardoy/flying-squid@0.0.36(encoding@0.1.13)': + '@zardoy/flying-squid@0.0.38(encoding@0.1.13)': dependencies: '@tootallnate/once': 2.0.0 change-case: 4.1.2 diff --git a/prismarine-viewer/viewer/lib/entities.js b/prismarine-viewer/viewer/lib/entities.ts similarity index 87% rename from prismarine-viewer/viewer/lib/entities.js rename to prismarine-viewer/viewer/lib/entities.ts index 59d1164a4..281a442e5 100644 --- a/prismarine-viewer/viewer/lib/entities.js +++ b/prismarine-viewer/viewer/lib/entities.ts @@ -17,10 +17,9 @@ import { disposeObject } from './threeJsUtils' export const TWEEN_DURATION = 120 -/** - * @param {string} username - */ -function getUsernameTexture(username, { fontFamily = 'sans-serif' }) { +type PlayerObjectType = PlayerObject & { animation?: PlayerAnimation } + +function getUsernameTexture (username: string, { fontFamily = 'sans-serif' }: any) { const canvas = document.createElement('canvas') const ctx = canvas.getContext('2d') if (!ctx) throw new Error('Could not get 2d context') @@ -64,7 +63,7 @@ const addNametag = (entity, options, mesh) => { // todo cleanup const nametags = {} -function getEntityMesh(entity, scene, options, overrides) { +function getEntityMesh (entity, scene, options, overrides) { if (entity.name) { try { // https://github.com/PrismarineJS/prismarine-viewer/pull/410 @@ -94,23 +93,41 @@ function getEntityMesh(entity, scene, options, overrides) { return cube } +export type SceneEntity = THREE.Object3D & { + playerObject?: PlayerObject & { + animation?: PlayerAnimation + } + username?: string + additionalCleanup?: () => void +} + export class Entities extends EventEmitter { - constructor(scene) { + entities = {} as Record