Refactor
This commit is contained in:
parent
3b445af6fc
commit
01e692b353
@ -441,7 +441,7 @@ export class Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public applyCustomColor(model: THREE.Object3D) {
|
private applyCustomColor(model: THREE.Object3D) {
|
||||||
const furniture = this.furnitures.find(furniture => furniture.id === model.name);
|
const furniture = this.furnitures.find(furniture => furniture.id === model.name);
|
||||||
const def = furnitureDefs.find(d => d.id === furniture.type);
|
const def = furnitureDefs.find(d => d.id === furniture.type);
|
||||||
if (def.color == null) return;
|
if (def.color == null) return;
|
||||||
@ -465,7 +465,7 @@ export class Room {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
public applyCustomTexture(model: THREE.Object3D) {
|
private applyCustomTexture(model: THREE.Object3D) {
|
||||||
const furniture = this.furnitures.find(furniture => furniture.id === model.name);
|
const furniture = this.furnitures.find(furniture => furniture.id === model.name);
|
||||||
const def = furnitureDefs.find(d => d.id === furniture.type);
|
const def = furnitureDefs.find(d => d.id === furniture.type);
|
||||||
if (def.texture == null) return;
|
if (def.texture == null) return;
|
||||||
@ -619,6 +619,10 @@ export class Room {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 家具の移動/回転モードにします
|
||||||
|
* @param type 移動か回転か
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public enterTransformMode(type: 'translate' | 'rotate') {
|
public enterTransformMode(type: 'translate' | 'rotate') {
|
||||||
this.isTransformMode = true;
|
this.isTransformMode = true;
|
||||||
@ -626,12 +630,20 @@ export class Room {
|
|||||||
this.furnitureControl.attach(this.selectedObject);
|
this.furnitureControl.attach(this.selectedObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 家具の移動/回転モードを終了します
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public exitTransformMode() {
|
public exitTransformMode() {
|
||||||
this.isTransformMode = false;
|
this.isTransformMode = false;
|
||||||
this.furnitureControl.detach();
|
this.furnitureControl.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 家具プロパティを更新します
|
||||||
|
* @param key プロパティ名
|
||||||
|
* @param value 値
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public updateProp(key: string, value: any) {
|
public updateProp(key: string, value: any) {
|
||||||
const furniture = this.furnitures.find(furniture => furniture.id === this.selectedObject.name);
|
const furniture = this.furnitures.find(furniture => furniture.id === this.selectedObject.name);
|
||||||
@ -641,6 +653,10 @@ export class Room {
|
|||||||
this.applyCustomTexture(this.selectedObject);
|
this.applyCustomTexture(this.selectedObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部屋に家具を追加します
|
||||||
|
* @param type 家具の種類
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public addFurniture(type: string) {
|
public addFurniture(type: string) {
|
||||||
const furniture = {
|
const furniture = {
|
||||||
@ -666,6 +682,9 @@ export class Room {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 現在選択されている家具を部屋から削除します
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public removeFurniture() {
|
public removeFurniture() {
|
||||||
this.exitTransformMode();
|
this.exitTransformMode();
|
||||||
@ -677,12 +696,20 @@ export class Room {
|
|||||||
this.onChangeSelect(null);
|
this.onChangeSelect(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部屋の床の色を変更します
|
||||||
|
* @param color 色
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public updateCarpetColor(color: string) {
|
public updateCarpetColor(color: string) {
|
||||||
this.roomInfo.carpetColor = color;
|
this.roomInfo.carpetColor = color;
|
||||||
this.applyCarpetColor();
|
this.applyCarpetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部屋の種類を変更します
|
||||||
|
* @param type 種類
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public changeRoomType(type: string) {
|
public changeRoomType(type: string) {
|
||||||
this.roomInfo.roomType = type;
|
this.roomInfo.roomType = type;
|
||||||
@ -690,6 +717,9 @@ export class Room {
|
|||||||
this.loadRoom();
|
this.loadRoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部屋データを取得します
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public getRoomInfo() {
|
public getRoomInfo() {
|
||||||
for (const obj of this.objects) {
|
for (const obj of this.objects) {
|
||||||
@ -705,6 +735,9 @@ export class Room {
|
|||||||
return this.roomInfo;
|
return this.roomInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 選択されている家具を取得します
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public getSelectedObject() {
|
public getSelectedObject() {
|
||||||
return this.selectedObject;
|
return this.selectedObject;
|
||||||
@ -715,6 +748,9 @@ export class Room {
|
|||||||
return this.furnitures.find(furniture => furniture.id === id);
|
return this.furnitures.find(furniture => furniture.id === id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* レンダリングを終了します
|
||||||
|
*/
|
||||||
@autobind
|
@autobind
|
||||||
public destroy() {
|
public destroy() {
|
||||||
// Stop render loop
|
// Stop render loop
|
||||||
|
Loading…
Reference in New Issue
Block a user