UNPKG

rl-loadout-lib

Version:

Load Rocket League assets into three.js

117 lines 4.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("../../utils/util"); const three_1 = require("three"); const ids_1 = require("../../utils/ids"); const rim_material_1 = require("../../webgl/rim-material"); const tire_material_1 = require("../../webgl/tire-material"); const light_wheel_model_1 = require("./light-wheel-model"); const chewy_model_1 = require("./chewy-model"); const shaded_paintable_material_1 = require("../../webgl/shaded-paintable-material"); function getRimMaterial(wheel, wheelAssets, paints) { let material; switch (wheel.id) { case ids_1.ProductID.WHEEL_LIGHT_WHEEL: material = new light_wheel_model_1.LightWheelRimMaterial(); break; case ids_1.ProductID.WHEEL_LONE_WOLF: case ids_1.ProductID.WHEEL_EXOTIC: case ids_1.ProductID.WHEEL_7SPOKE: case ids_1.ProductID.WHEEL_GLASSY: case ids_1.ProductID.WHEEL_PUMPERNICKEL: case ids_1.ProductID.WHEEL_DAISUKE: material = new rim_material_1.RimMaterial('r'); break; case ids_1.ProductID.WHEEL_GETSI: case ids_1.ProductID.WHEEL_RAZZLEMADOO: case ids_1.ProductID.WHEEL_FOLLIN: case ids_1.ProductID.WHEEL_REAPER: case ids_1.ProductID.WHEEL_LEAN: case ids_1.ProductID.WHEEL_TREBLE_MEGA: case ids_1.ProductID.WHEEL_OBSCURE: case ids_1.ProductID.WHEEL_CHEWY: case ids_1.ProductID.WHEEL_INN: case ids_1.ProductID.WHEEL_FORK: case ids_1.ProductID.WHEEL_CHIEF: case ids_1.ProductID.WHEEL_ENSPIER: case ids_1.ProductID.WHEEL_SPECTRAL: case ids_1.ProductID.WHEEL_IGTYJR: material = new rim_material_1.RimMaterial('a', true); break; case ids_1.ProductID.WHEEL_DONUT: material = new shaded_paintable_material_1.ShadedPaintableMaterial(); break; case ids_1.ProductID.WHEEL_STORMDRAIN: case ids_1.ProductID.WHEEL_ALLSPARK: material = new rim_material_1.RimMaterial('a', false); break; default: if (!util_1.StringUtil.nullOrEmpty(wheel.rim_rgb_map)) { material = new rim_material_1.RimMaterial('r', true); } break; } if (material != undefined) { material.map = util_1.htmlImageToTexture(wheelAssets.rimD); material.rgbaMap = util_1.htmlImageToTexture(wheelAssets.rimRgba); material.normalMap = util_1.htmlImageToTexture(wheelAssets.rimN); material.paintColor = paints.wheel; material.needsUpdate = true; } return material; } exports.getRimMaterial = getRimMaterial; function getTireMaterial(wheel, wheelAssets, paints) { let material; switch (wheel.id) { case ids_1.ProductID.WHEEL_EXOTIC: case ids_1.ProductID.WHEEL_7SPOKE: case ids_1.ProductID.WHEEL_GLASSY: case ids_1.ProductID.WHEEL_GETSI: case ids_1.ProductID.WHEEL_RAZZLEMADOO: case ids_1.ProductID.WHEEL_FOLLIN: case ids_1.ProductID.WHEEL_REAPER: case ids_1.ProductID.WHEEL_ZTEIGHTEEN: case ids_1.ProductID.WHEEL_INN: material = new tire_material_1.TireMaterial('r', true, true); break; case ids_1.ProductID.WHEEL_SEASTAR: case ids_1.ProductID.WHEEL_OBSCURE: material = new tire_material_1.TireMaterial('a'); material.colorOnly = true; material.color = new three_1.Color('#141414'); break; case ids_1.ProductID.WHEEL_PEPPERMINT: case ids_1.ProductID.WHEEL_LEAN: case ids_1.ProductID.WHEEL_TREBLE_MEGA: case ids_1.ProductID.WHEEL_SPECTRAL: case ids_1.ProductID.WHEEL_BLENDER: case ids_1.ProductID.WHEEL_GS: case ids_1.ProductID.WHEEL_FR01: material = new tire_material_1.TireMaterial('r', true, false); break; case ids_1.ProductID.WHEEL_CHEWY: material = new chewy_model_1.ChewyTireMaterial(true); break; case ids_1.ProductID.WHEEL_ENSPIER: material = new chewy_model_1.ChewyTireMaterial(false); break; case ids_1.ProductID.WHEEL_SHURIKEN: material = new tire_material_1.UnpaintableTireMaterial(); break; default: if (!util_1.StringUtil.nullOrEmpty(wheel.tire_base)) { material = new tire_material_1.TireMaterial('a', false, true); } break; } if (material != undefined) { material.normalMap = util_1.htmlImageToTexture(wheelAssets.tireN); material.map = util_1.htmlImageToTexture(wheelAssets.tireD); material.paintColor = paints.wheel; material.needsUpdate = true; } return material; } exports.getTireMaterial = getTireMaterial; //# sourceMappingURL=texture-factory.js.map