rl-loadout-lib
Version:
Load Rocket League assets into three.js
50 lines • 1.85 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const body_model_1 = require("./body-model");
const object_1 = require("../object");
const util_1 = require("../../utils/util");
/**
* Class for the 3D model of McLaren 570S. Needed because of custom textures.
*/
class RonModel extends body_model_1.BodyModel {
constructor(body, decal, bodyAssets, decalAssets, paints) {
super(body, decal, bodyAssets, decalAssets, paints);
this.init();
}
init() {
const bodyAssets = this.bodyAssets;
this.carbonFibreMaterial.normalMap = util_1.htmlImageToTexture(bodyAssets.carbonFibre);
this.decalsMaterial.map = util_1.htmlImageToTexture(bodyAssets.decalsD);
this.decalsMaterial.normalMap = util_1.htmlImageToTexture(bodyAssets.decalsN);
this.tilingMaterial.map = util_1.htmlImageToTexture(bodyAssets.hexD);
this.tilingMaterial.normalMap = util_1.htmlImageToTexture(bodyAssets.hexN);
this.carbonFibreMaterial.normalMap.offset.y = -20;
this.carbonFibreMaterial.normalMap.repeat.x = 20;
this.carbonFibreMaterial.normalMap.repeat.y = 20;
}
handleModel(scene) {
super.handleModel(scene);
object_1.traverseMaterials(scene, mat => {
if (mat.name === 'CarbonFibre') {
this.carbonFibreMaterial = mat;
}
else if (mat.name === 'Decals') {
this.decalsMaterial = mat;
}
else if (mat.name === 'MAT_Ron_Detail_Tiling') {
this.tilingMaterial = mat;
}
});
}
copy(other) {
super.copy(other);
this.init();
}
clone() {
const m = new RonModel();
m.copy(this);
return m;
}
}
exports.RonModel = RonModel;
//# sourceMappingURL=ron-model.js.map