UNPKG

rl-loadout-lib

Version:

Load Rocket League assets into three.js

65 lines 2.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const object_1 = require("../object"); const util_1 = require("../../utils/util"); const texture_factory_1 = require("./texture-factory"); class WheelModelInternal { } exports.WheelModelInternal = WheelModelInternal; /** * Class that handles loading the 3D model of the car wheels. */ class WheelsModel extends object_1.AbstractObject { constructor(assets, wheel, paints) { super(assets); this.assets = assets; if (assets != undefined) { this.rimMaterial = texture_factory_1.getRimMaterial(wheel, assets, paints); this.rimMesh.material = this.rimMaterial; if (this.tireMesh != undefined) { this.tireMaterial = texture_factory_1.getTireMaterial(wheel, assets, paints); this.tireMesh.material = this.tireMaterial; } } } dispose() { super.dispose(); util_1.disposeIfExists(this.rimMaterial); } handleModel(scene) { scene.traverse(object => { if (object['isMesh']) { const mat = object.material; if (mat.name.includes('rim')) { this.rimMesh = object; } else if (mat.name.includes('tire')) { this.tireMesh = object; } } }); } setPaintColor(paint) { this.rimMaterial.paintColor = paint; if (this.tireMaterial != undefined) { this.tireMaterial.paintColor = paint; } } /** * Animate the wheels. This is a safe no-op if the wheels are not animated. * @param t time in milliseconds * @param wheel the thing containing the wheel to animate * @param roll of the wheel */ animate(t, wheel, roll) { var _a; (_a = this.rimMaterial) === null || _a === void 0 ? void 0 : _a.animate(t); } clone() { const m = new WheelsModel(); m.copy(this); return m; } } exports.WheelsModel = WheelsModel; //# sourceMappingURL=wheels-model.js.map