UNPKG

@haiku/player

Version:

Haiku Player is a JavaScript library for building user interfaces

50 lines 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Layout3D_1 = require("../Layout3D"); var mat4_decompose_1 = require("../vendor/mat4-decompose"); var math3d_1 = require("../vendor/math3d"); var MathUtils_1 = require("./MathUtils"); function composedTransformsToTimelineProperties(out, matrices) { var decomposed = mat4_decompose_1.default(Layout3D_1.default.multiplyArrayOfMatrices(matrices.reverse())); if (decomposed === false) { return out; } var _a = decomposed, translation = _a.translation, scale = _a.scale, quaternion = _a.quaternion; if (scale.indexOf(0) !== -1) { return { 'scale.x': 0, }; } var rotation = math3d_1.default.getEulerAngles.apply(undefined, quaternion) .map(function (degrees) { return Number(MathUtils_1.default.degreesToRadians(degrees).toFixed(2)); }); if (translation[0] !== 0) { out['translation.x'] = translation[0]; } if (translation[1] !== 0) { out['translation.y'] = translation[1]; } if (translation[2] !== 0) { out['translation.z'] = translation[2]; } if (rotation[0] !== 0) { out['rotation.x'] = rotation[0]; } if (rotation[1] !== 0) { out['rotation.y'] = rotation[1]; } if (rotation[2] !== 0) { out['rotation.z'] = rotation[2]; } if (scale[0] !== 1) { out['scale.x'] = scale[0]; } if (scale[1] !== 1) { out['scale.y'] = scale[1]; } if (scale[2] !== 1) { out['scale.z'] = scale[2]; } return out; } exports.default = composedTransformsToTimelineProperties; //# sourceMappingURL=composedTransformsToTimelineProperties.js.map