UNPKG

@gmetrixr/rjson

Version:
32 lines (31 loc) 1.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const r_1 = require("../../../r"); /** * Update billboarding from boolean to string. * Default billboarding => xy * If current billboarding is true => setting the value as xyz for the older projects to remain in sync * If current billboarding is false => setting value as none so as not to show any billboarding. */ class Migration { execute(projectJson) { const pJson = projectJson; const projectF = r_1.r.project(pJson); for (const element of projectF.getAllDeepChildren(r_1.RT.element)) { const isBillBoardingSupported = r_1.rUtils.ElementUtils.getElementDefinition(element.props.element_type).properties.includes(r_1.rtp.element.billboarding); const elementF = r_1.r.element(element); const currentValue = elementF.get(r_1.rtp.element.billboarding); // * If billboarding is supported by this element only then process it else set the default to null. // * Why null? Because getValueOrDefault will start to give out the new value as default for existing elements too if (isBillBoardingSupported && currentValue) { elementF.set(r_1.rtp.element.billboarding, r_1.en.BillboardingTypes.xyz); } else { elementF.set(r_1.rtp.element.billboarding, null); } } projectF.set(r_1.rtp.project.version, 132); } } const migration = new Migration(); exports.default = migration;