diff --git a/prismarine-viewer/viewer/lib/entity/EntityMesh.js b/prismarine-viewer/viewer/lib/entity/EntityMesh.js index 1387d2ccf..a518171ff 100644 --- a/prismarine-viewer/viewer/lib/entity/EntityMesh.js +++ b/prismarine-viewer/viewer/lib/entity/EntityMesh.js @@ -2,6 +2,7 @@ import * as THREE from 'three' import { OBJLoader } from 'three-stdlib' import huskPng from 'mc-assets/dist/other-textures/latest/entity/zombie/husk.png' +import { Vec3 } from 'vec3' import entities from './entities.json' import { externalModels } from './objModels' import externalTexturesJson from './externalTextures.json' @@ -292,9 +293,15 @@ const getEntity = (name) => { // } const scaleEntity = { - zombie: 1.9, - husk: 1.9 + zombie: 1.85, + husk: 1.85 } +const offsetEntity = { + zombie: new Vec3(0, 1, 0), + husk: new Vec3(0, 1, 0), + boat: new Vec3(0, -1, 0), +} + // eslint-disable-next-line @typescript-eslint/no-extraneous-class export class EntityMesh { constructor(version, type, scene, /** @type {{textures?, rotation?: Record}} */overrides = {}) { @@ -335,7 +342,8 @@ export class EntityMesh { const obj = objLoader.parse(externalModels[type]) const scale = scaleEntity[originalType] if (scale) obj.scale.set(scale, scale, scale) - if (type === 'boat') obj.position.y = -1 // todo, should not be hardcoded + const offset = offsetEntity[originalType] + if (offset) obj.position.set(offset.x, offset.y, offset.z) obj.traverse((child) => { if (child instanceof THREE.Mesh) { child.material = material diff --git a/prismarine-viewer/viewer/lib/entity/models/zombie.obj b/prismarine-viewer/viewer/lib/entity/models/zombie.obj index 42f1e7227..fa5d8f4d5 100644 --- a/prismarine-viewer/viewer/lib/entity/models/zombie.obj +++ b/prismarine-viewer/viewer/lib/entity/models/zombie.obj @@ -2,14 +2,14 @@ mtllib materials.mtl o /head -v 0.125 1 0.125 -v 0.125 1 -0.125 -v 0.125 0.75 0.125 -v 0.125 0.75 -0.125 -v -0.125 1 -0.125 -v -0.125 1 0.125 -v -0.125 0.75 -0.125 -v -0.125 0.75 0.125 +v 0.125 0.5 0.125 +v 0.125 0.5 -0.125 +v 0.125 0.25 0.125 +v 0.125 0.25 -0.125 +v -0.125 0.5 -0.125 +v -0.125 0.5 0.125 +v -0.125 0.25 -0.125 +v -0.125 0.25 0.125 vt 0.125 0.875 vt 0.25 0.875 vt 0.25 0.75 @@ -48,38 +48,38 @@ f 7/16/4 8/15/4 6/14/4 5/13/4 f 6/20/5 1/19/5 2/18/5 5/17/5 f 7/24/6 4/23/6 3/22/6 8/21/6 o /right_arm -v -0.125 0.75 0.0625 -v -0.125 0.75 -0.0625 -v -0.125 0.375 0.0625 -v -0.125 0.375 -0.0625 -v -0.25 0.75 -0.0625 -v -0.25 0.75 0.0625 -v -0.25 0.375 -0.0625 -v -0.25 0.375 0.0625 -vt 0.6875 0.6875 +v -0.125 0.25 0.0625 +v -0.125 0.25 -0.3125 +v -0.125 0.125 0.0625 +v -0.125 0.125 -0.3125 +v -0.25 0.25 -0.3125 +v -0.25 0.25 0.0625 +v -0.25 0.125 -0.3125 +v -0.25 0.125 0.0625 +vt 0.8125 0.6875 vt 0.75 0.6875 -vt 0.75 0.5 -vt 0.6875 0.5 -vt 0.625 0.6875 +vt 0.75 0.75 +vt 0.8125 0.75 vt 0.6875 0.6875 vt 0.6875 0.5 vt 0.625 0.5 -vt 0.8125 0.6875 -vt 0.875 0.6875 -vt 0.875 0.5 -vt 0.8125 0.5 -vt 0.75 0.6875 -vt 0.8125 0.6875 -vt 0.8125 0.5 -vt 0.75 0.5 +vt 0.625 0.6875 vt 0.75 0.6875 vt 0.6875 0.6875 vt 0.6875 0.75 vt 0.75 0.75 -vt 0.75 0.75 -vt 0.8125 0.75 +vt 0.75 0.5 +vt 0.75 0.6875 vt 0.8125 0.6875 +vt 0.8125 0.5 +vt 0.75 0.5 +vt 0.6875 0.5 +vt 0.6875 0.6875 vt 0.75 0.6875 +vt 0.8125 0.6875 +vt 0.875 0.6875 +vt 0.875 0.5 +vt 0.8125 0.5 vn 0 0 -1 vn 1 0 0 vn 0 0 1 @@ -94,14 +94,14 @@ f 15/40/10 16/39/10 14/38/10 13/37/10 f 14/44/11 9/43/11 10/42/11 13/41/11 f 15/48/12 12/47/12 11/46/12 16/45/12 o /left_leg -v 0.12187499999999996 0.375 0.0625 -v 0.12187499999999996 0.375 -0.0625 -v 0.12187499999999996 0 0.0625 -v 0.12187499999999996 0 -0.0625 -v -0.003124999999999989 0.375 -0.0625 -v -0.003124999999999989 0.375 0.0625 -v -0.003124999999999989 0 -0.0625 -v -0.003124999999999989 0 0.0625 +v 0.12187499999999996 -0.125 0.0625 +v 0.12187499999999996 -0.125 -0.0625 +v 0.12187499999999996 -0.5 0.0625 +v 0.12187499999999996 -0.5 -0.0625 +v -0.0031250000000000444 -0.125 -0.0625 +v -0.0031250000000000444 -0.125 0.0625 +v -0.0031250000000000444 -0.5 -0.0625 +v -0.0031250000000000444 -0.5 0.0625 vt 0.0625 0.6875 vt 0.125 0.6875 vt 0.125 0.5 @@ -140,38 +140,38 @@ f 23/64/16 24/63/16 22/62/16 21/61/16 f 22/68/17 17/67/17 18/66/17 21/65/17 f 23/72/18 20/71/18 19/70/18 24/69/18 o /left_arm -v 0.25 0.75 0.0625 -v 0.25 0.75 -0.0625 -v 0.25 0.375 0.0625 -v 0.25 0.375 -0.0625 -v 0.125 0.75 -0.0625 -v 0.125 0.75 0.0625 -v 0.125 0.375 -0.0625 -v 0.125 0.375 0.0625 -vt 0.6875 0.6875 +v 0.25 0.25 0.0625 +v 0.25 0.25 -0.3125 +v 0.25 0.125 0.0625 +v 0.25 0.125 -0.3125 +v 0.125 0.25 -0.3125 +v 0.125 0.25 0.0625 +v 0.125 0.125 -0.3125 +v 0.125 0.125 0.0625 +vt 0.8125 0.6875 vt 0.75 0.6875 -vt 0.75 0.5 -vt 0.6875 0.5 -vt 0.625 0.6875 +vt 0.75 0.75 +vt 0.8125 0.75 vt 0.6875 0.6875 vt 0.6875 0.5 vt 0.625 0.5 -vt 0.8125 0.6875 -vt 0.875 0.6875 -vt 0.875 0.5 -vt 0.8125 0.5 -vt 0.75 0.6875 -vt 0.8125 0.6875 -vt 0.8125 0.5 -vt 0.75 0.5 +vt 0.625 0.6875 vt 0.75 0.6875 vt 0.6875 0.6875 vt 0.6875 0.75 vt 0.75 0.75 -vt 0.75 0.75 -vt 0.8125 0.75 +vt 0.75 0.5 +vt 0.75 0.6875 vt 0.8125 0.6875 +vt 0.8125 0.5 +vt 0.75 0.5 +vt 0.6875 0.5 +vt 0.6875 0.6875 vt 0.75 0.6875 +vt 0.8125 0.6875 +vt 0.875 0.6875 +vt 0.875 0.5 +vt 0.8125 0.5 vn 0 0 -1 vn 1 0 0 vn 0 0 1 @@ -186,14 +186,14 @@ f 31/88/22 32/87/22 30/86/22 29/85/22 f 30/92/23 25/91/23 26/90/23 29/89/23 f 31/96/24 28/95/24 27/94/24 32/93/24 o /right_leg -v 0.0031250000000000444 0.375 0.0625 -v 0.0031250000000000444 0.375 -0.0625 -v 0.0031250000000000444 0 0.0625 -v 0.0031250000000000444 0 -0.0625 -v -0.12187500000000001 0.375 -0.0625 -v -0.12187500000000001 0.375 0.0625 -v -0.12187500000000001 0 -0.0625 -v -0.12187500000000001 0 0.0625 +v 0.0031250000000000444 -0.125 0.0625 +v 0.0031250000000000444 -0.125 -0.0625 +v 0.0031250000000000444 -0.5 0.0625 +v 0.0031250000000000444 -0.5 -0.0625 +v -0.12187499999999996 -0.125 -0.0625 +v -0.12187499999999996 -0.125 0.0625 +v -0.12187499999999996 -0.5 -0.0625 +v -0.12187499999999996 -0.5 0.0625 vt 0.0625 0.6875 vt 0.125 0.6875 vt 0.125 0.5 @@ -232,14 +232,14 @@ f 39/112/28 40/111/28 38/110/28 37/109/28 f 38/116/29 33/115/29 34/114/29 37/113/29 f 39/120/30 36/119/30 35/118/30 40/117/30 o /hat -v 0.140625 1.015625 0.140625 -v 0.140625 1.015625 -0.140625 -v 0.140625 0.734375 0.140625 -v 0.140625 0.734375 -0.140625 -v -0.140625 1.015625 -0.140625 -v -0.140625 1.015625 0.140625 -v -0.140625 0.734375 -0.140625 -v -0.140625 0.734375 0.140625 +v 0.140625 0.515625 0.140625 +v 0.140625 0.515625 -0.140625 +v 0.140625 0.234375 0.140625 +v 0.140625 0.234375 -0.140625 +v -0.140625 0.515625 -0.140625 +v -0.140625 0.515625 0.140625 +v -0.140625 0.234375 -0.140625 +v -0.140625 0.234375 0.140625 vt 0.625 0.875 vt 0.75 0.875 vt 0.75 0.75 @@ -278,14 +278,14 @@ f 47/136/34 48/135/34 46/134/34 45/133/34 f 46/140/35 41/139/35 42/138/35 45/137/35 f 47/144/36 44/143/36 43/142/36 48/141/36 o /body -v 0.125 0.75 0.0625 -v 0.125 0.75 -0.0625 -v 0.125 0.375 0.0625 -v 0.125 0.375 -0.0625 -v -0.125 0.75 -0.0625 -v -0.125 0.75 0.0625 -v -0.125 0.375 -0.0625 -v -0.125 0.375 0.0625 +v 0.125 0.25 0.0625 +v 0.125 0.25 -0.0625 +v 0.125 -0.125 0.0625 +v 0.125 -0.125 -0.0625 +v -0.125 0.25 -0.0625 +v -0.125 0.25 0.0625 +v -0.125 -0.125 -0.0625 +v -0.125 -0.125 0.0625 vt 0.3125 0.6875 vt 0.4375 0.6875 vt 0.4375 0.5 @@ -322,4 +322,4 @@ f 51/152/38 52/151/38 50/150/38 49/149/38 f 56/156/39 51/155/39 49/154/39 54/153/39 f 55/160/40 56/159/40 54/158/40 53/157/40 f 54/164/41 49/163/41 50/162/41 53/161/41 -f 55/168/42 52/167/42 51/166/42 56/165/42 \ No newline at end of file +f 55/168/42 52/167/42 51/166/42 56/165/42