rl-loadout-lib
Version:
Load Rocket League assets into three.js
81 lines • 3.05 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const body_model_1 = require("./body-model");
const color_1 = require("../../utils/color");
const object_1 = require("../object");
const util_1 = require("../../utils/util");
/**
* Class for the 3D model of Ecto-1. Needed because paints cannot be applied to this body.
*/
class SlimeModel extends body_model_1.BodyModel {
constructor(body, decal, bodyAssets, decalAssets, paints) {
super(body, decal, bodyAssets, decalAssets, paints);
this.bodyDataOrange = util_1.htmlImageToTexture(bodyAssets.bodyOrange);
this.bodyDataBlue = util_1.htmlImageToTexture(bodyAssets.bodyBlue);
this.chassisDataOrange = util_1.htmlImageToTexture(bodyAssets.chassisOrange);
this.chassisDataBlue = util_1.htmlImageToTexture(bodyAssets.chassisBlue);
this.bodyMaterial.map = this.bodyDataBlue;
this.chassisMaterial.map = this.chassisDataBlue;
this.lensMaterial.color.setRGB(0, 0, 0.8);
this.applyTextures();
}
applyAssets() {
this.chassisMaterial.normalMap = util_1.htmlImageToTexture(this.bodyAssets.chassisN);
this.chassisMaterial.normalMap.needsUpdate = true;
}
dispose() {
super.dispose();
util_1.disposeIfExists(this.bodyDataOrange);
util_1.disposeIfExists(this.bodyDataBlue);
util_1.disposeIfExists(this.chassisDataOrange);
util_1.disposeIfExists(this.chassisDataBlue);
}
handleModel(scene) {
super.handleModel(scene);
object_1.traverseMaterials(scene, material => {
if (material.name === 'MAT_Slime_HeadlightLens_VertColor') {
this.lensMaterial = material;
}
});
}
applyTextures() {
this.bodyMaterial.needsUpdate = true;
this.chassisMaterial.needsUpdate = true;
this.lensMaterial.needsUpdate = true;
}
setPaintColor(color) {
}
changeDecal(decalAssets, paints) {
}
setPrimaryColor(color) {
if (`#${color.getHexString()}` === color_1.COLOR_MAPLE_ORANGE) {
this.bodyMaterial.map = this.bodyDataOrange;
this.chassisMaterial.map = this.chassisDataOrange;
this.lensMaterial.color.setRGB(0.8, 0, 0);
}
else {
this.bodyMaterial.map = this.bodyDataBlue;
this.chassisMaterial.map = this.chassisDataBlue;
this.lensMaterial.color.setRGB(0, 0, 0.8);
}
this.applyTextures();
}
setAccentColor(color) {
}
setDecalPaintColor(color) {
}
copy(other) {
super.copy(other);
this.bodyDataBlue = other.bodyDataBlue.clone();
this.bodyDataOrange = other.bodyDataOrange.clone();
this.chassisDataOrange = other.chassisDataOrange.clone();
this.chassisDataBlue = other.chassisDataBlue.clone();
}
clone() {
const m = new SlimeModel();
m.copy(this);
return m;
}
}
exports.SlimeModel = SlimeModel;
//# sourceMappingURL=slime-model.js.map