diff --git a/src/model.js b/src/model.js index 012c630..6536fe5 100644 --- a/src/model.js +++ b/src/model.js @@ -36,9 +36,11 @@ function addVertices(box, top, bottom, left, front, right, back) { const esp = 0.002; class SkinObject extends THREE.Group { - constructor(isSlim, layer1Material, layer2Material) { + constructor(slim, layer1Material, layer2Material) { super(); + this.slim = slim; + // Head this.head = new THREE.Group(); @@ -105,8 +107,8 @@ class SkinObject extends THREE.Group { this.rightArm = new THREE.Group(); let rightArmPivot = new THREE.Group(); - let rightArmBox = new THREE.BoxGeometry((isSlim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0); - if (isSlim) { + let rightArmBox = new THREE.BoxGeometry((slim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0); + if (slim) { addVertices(rightArmBox, toSkinVertices(44, 16, 47, 20), toSkinVertices(47, 16, 50, 20), @@ -128,8 +130,8 @@ class SkinObject extends THREE.Group { let rightArmMesh = new THREE.Mesh(rightArmBox, layer1Material); rightArmPivot.add(rightArmMesh); - let rightArm2Box = new THREE.BoxGeometry((isSlim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0); - if (isSlim) { + let rightArm2Box = new THREE.BoxGeometry((slim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0); + if (slim) { addVertices(rightArm2Box, toSkinVertices(44, 32, 47, 36), toSkinVertices(47, 32, 50, 36), @@ -155,7 +157,7 @@ class SkinObject extends THREE.Group { rightArmPivot.position.y = -6; this.rightArm.add(rightArmPivot); this.rightArm.position.y = -4; - this.rightArm.position.x = isSlim ? -5.5 : -6; + this.rightArm.position.x = slim ? -5.5 : -6; this.add(this.rightArm); @@ -163,8 +165,8 @@ class SkinObject extends THREE.Group { this.leftArm = new THREE.Group(); let leftArmPivot = new THREE.Group(); - let leftArmBox = new THREE.BoxGeometry((isSlim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0); - if (isSlim) { + let leftArmBox = new THREE.BoxGeometry((slim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0); + if (slim) { addVertices(leftArmBox, toSkinVertices(36, 48, 39, 52), toSkinVertices(39, 48, 42, 52), @@ -186,8 +188,8 @@ class SkinObject extends THREE.Group { let leftArmMesh = new THREE.Mesh(leftArmBox, layer1Material); leftArmPivot.add(leftArmMesh); - let leftArm2Box = new THREE.BoxGeometry((isSlim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0); - if (isSlim) { + let leftArm2Box = new THREE.BoxGeometry((slim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0); + if (slim) { addVertices(leftArm2Box, toSkinVertices(52, 48, 55, 52), toSkinVertices(55, 48, 58, 52), @@ -213,7 +215,7 @@ class SkinObject extends THREE.Group { leftArmPivot.position.y = -6; this.leftArm.add(leftArmPivot); this.leftArm.position.y = -4; - this.leftArm.position.x = isSlim ? 5.5 : 6; + this.leftArm.position.x = slim ? 5.5 : 6; this.add(this.leftArm); @@ -315,8 +317,6 @@ class PlayerObject extends THREE.Group { constructor(slim, layer1Material, layer2Material, capeMaterial) { super(); - this.slim = slim; - this.skin = new SkinObject(slim, layer1Material, layer2Material); this.skin.visible = false; this.add(this.skin); diff --git a/types/model.d.ts b/types/model.d.ts index 9f9b875..0119498 100644 --- a/types/model.d.ts +++ b/types/model.d.ts @@ -1,6 +1,7 @@ import * as THREE from "three"; export class SkinObject extends THREE.Group { + readonly slim: boolean; readonly head: THREE.Group; readonly body: THREE.Group; readonly rightArm: THREE.Group; @@ -9,7 +10,7 @@ export class SkinObject extends THREE.Group { readonly leftLeg: THREE.Group; constructor( - isSlim: boolean, + slim: boolean, layer1Material: THREE.Material, layer2Material: THREE.Material, ); @@ -22,12 +23,11 @@ export class CapeObject extends THREE.Group { } export class PlayerObject extends THREE.Group { - readonly slim: boolean; readonly skin: SkinObject; readonly cape: CapeObject; constructor( - isSlim: boolean, + slim: boolean, layer1Material: THREE.Material, layer2Material: THREE.Material, capeMaterial: THREE.Material,