move property `slim` from `PlayerObject` to `SkinObject`
This commit is contained in:
parent
42959b63d7
commit
d86cfa4c87
26
src/model.js
26
src/model.js
|
|
@ -36,9 +36,11 @@ function addVertices(box, top, bottom, left, front, right, back) {
|
||||||
const esp = 0.002;
|
const esp = 0.002;
|
||||||
|
|
||||||
class SkinObject extends THREE.Group {
|
class SkinObject extends THREE.Group {
|
||||||
constructor(isSlim, layer1Material, layer2Material) {
|
constructor(slim, layer1Material, layer2Material) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
this.slim = slim;
|
||||||
|
|
||||||
// Head
|
// Head
|
||||||
this.head = new THREE.Group();
|
this.head = new THREE.Group();
|
||||||
|
|
||||||
|
|
@ -105,8 +107,8 @@ class SkinObject extends THREE.Group {
|
||||||
this.rightArm = new THREE.Group();
|
this.rightArm = new THREE.Group();
|
||||||
let rightArmPivot = new THREE.Group();
|
let rightArmPivot = new THREE.Group();
|
||||||
|
|
||||||
let rightArmBox = new THREE.BoxGeometry((isSlim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0);
|
let rightArmBox = new THREE.BoxGeometry((slim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0);
|
||||||
if (isSlim) {
|
if (slim) {
|
||||||
addVertices(rightArmBox,
|
addVertices(rightArmBox,
|
||||||
toSkinVertices(44, 16, 47, 20),
|
toSkinVertices(44, 16, 47, 20),
|
||||||
toSkinVertices(47, 16, 50, 20),
|
toSkinVertices(47, 16, 50, 20),
|
||||||
|
|
@ -128,8 +130,8 @@ class SkinObject extends THREE.Group {
|
||||||
let rightArmMesh = new THREE.Mesh(rightArmBox, layer1Material);
|
let rightArmMesh = new THREE.Mesh(rightArmBox, layer1Material);
|
||||||
rightArmPivot.add(rightArmMesh);
|
rightArmPivot.add(rightArmMesh);
|
||||||
|
|
||||||
let rightArm2Box = new THREE.BoxGeometry((isSlim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0);
|
let rightArm2Box = new THREE.BoxGeometry((slim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0);
|
||||||
if (isSlim) {
|
if (slim) {
|
||||||
addVertices(rightArm2Box,
|
addVertices(rightArm2Box,
|
||||||
toSkinVertices(44, 32, 47, 36),
|
toSkinVertices(44, 32, 47, 36),
|
||||||
toSkinVertices(47, 32, 50, 36),
|
toSkinVertices(47, 32, 50, 36),
|
||||||
|
|
@ -155,7 +157,7 @@ class SkinObject extends THREE.Group {
|
||||||
rightArmPivot.position.y = -6;
|
rightArmPivot.position.y = -6;
|
||||||
this.rightArm.add(rightArmPivot);
|
this.rightArm.add(rightArmPivot);
|
||||||
this.rightArm.position.y = -4;
|
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);
|
this.add(this.rightArm);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -163,8 +165,8 @@ class SkinObject extends THREE.Group {
|
||||||
this.leftArm = new THREE.Group();
|
this.leftArm = new THREE.Group();
|
||||||
let leftArmPivot = new THREE.Group();
|
let leftArmPivot = new THREE.Group();
|
||||||
|
|
||||||
let leftArmBox = new THREE.BoxGeometry((isSlim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0);
|
let leftArmBox = new THREE.BoxGeometry((slim ? 3 : 4) - esp, 12 - esp, 4 - esp, 0, 0, 0);
|
||||||
if (isSlim) {
|
if (slim) {
|
||||||
addVertices(leftArmBox,
|
addVertices(leftArmBox,
|
||||||
toSkinVertices(36, 48, 39, 52),
|
toSkinVertices(36, 48, 39, 52),
|
||||||
toSkinVertices(39, 48, 42, 52),
|
toSkinVertices(39, 48, 42, 52),
|
||||||
|
|
@ -186,8 +188,8 @@ class SkinObject extends THREE.Group {
|
||||||
let leftArmMesh = new THREE.Mesh(leftArmBox, layer1Material);
|
let leftArmMesh = new THREE.Mesh(leftArmBox, layer1Material);
|
||||||
leftArmPivot.add(leftArmMesh);
|
leftArmPivot.add(leftArmMesh);
|
||||||
|
|
||||||
let leftArm2Box = new THREE.BoxGeometry((isSlim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0);
|
let leftArm2Box = new THREE.BoxGeometry((slim ? 3.375 : 4.5) - esp, 13.5 - esp, 4.5 - esp, 0, 0, 0);
|
||||||
if (isSlim) {
|
if (slim) {
|
||||||
addVertices(leftArm2Box,
|
addVertices(leftArm2Box,
|
||||||
toSkinVertices(52, 48, 55, 52),
|
toSkinVertices(52, 48, 55, 52),
|
||||||
toSkinVertices(55, 48, 58, 52),
|
toSkinVertices(55, 48, 58, 52),
|
||||||
|
|
@ -213,7 +215,7 @@ class SkinObject extends THREE.Group {
|
||||||
leftArmPivot.position.y = -6;
|
leftArmPivot.position.y = -6;
|
||||||
this.leftArm.add(leftArmPivot);
|
this.leftArm.add(leftArmPivot);
|
||||||
this.leftArm.position.y = -4;
|
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);
|
this.add(this.leftArm);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -315,8 +317,6 @@ class PlayerObject extends THREE.Group {
|
||||||
constructor(slim, layer1Material, layer2Material, capeMaterial) {
|
constructor(slim, layer1Material, layer2Material, capeMaterial) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.slim = slim;
|
|
||||||
|
|
||||||
this.skin = new SkinObject(slim, layer1Material, layer2Material);
|
this.skin = new SkinObject(slim, layer1Material, layer2Material);
|
||||||
this.skin.visible = false;
|
this.skin.visible = false;
|
||||||
this.add(this.skin);
|
this.add(this.skin);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import * as THREE from "three";
|
import * as THREE from "three";
|
||||||
|
|
||||||
export class SkinObject extends THREE.Group {
|
export class SkinObject extends THREE.Group {
|
||||||
|
readonly slim: boolean;
|
||||||
readonly head: THREE.Group;
|
readonly head: THREE.Group;
|
||||||
readonly body: THREE.Group;
|
readonly body: THREE.Group;
|
||||||
readonly rightArm: THREE.Group;
|
readonly rightArm: THREE.Group;
|
||||||
|
|
@ -9,7 +10,7 @@ export class SkinObject extends THREE.Group {
|
||||||
readonly leftLeg: THREE.Group;
|
readonly leftLeg: THREE.Group;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
isSlim: boolean,
|
slim: boolean,
|
||||||
layer1Material: THREE.Material,
|
layer1Material: THREE.Material,
|
||||||
layer2Material: THREE.Material,
|
layer2Material: THREE.Material,
|
||||||
);
|
);
|
||||||
|
|
@ -22,12 +23,11 @@ export class CapeObject extends THREE.Group {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PlayerObject extends THREE.Group {
|
export class PlayerObject extends THREE.Group {
|
||||||
readonly slim: boolean;
|
|
||||||
readonly skin: SkinObject;
|
readonly skin: SkinObject;
|
||||||
readonly cape: CapeObject;
|
readonly cape: CapeObject;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
isSlim: boolean,
|
slim: boolean,
|
||||||
layer1Material: THREE.Material,
|
layer1Material: THREE.Material,
|
||||||
layer2Material: THREE.Material,
|
layer2Material: THREE.Material,
|
||||||
capeMaterial: THREE.Material,
|
capeMaterial: THREE.Material,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue