playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
49 lines (48 loc) • 1.99 kB
JavaScript
import { Component } from "../component.js";
import { ComponentSystem } from "../system.js";
import { LayoutChildComponent } from "./component.js";
import { LayoutChildComponentData } from "./data.js";
const _schema = ["enabled"];
class LayoutChildComponentSystem extends ComponentSystem {
/**
* Create a new LayoutChildComponentSystem instance.
*
* @param {AppBase} app - The application.
* @ignore
*/
constructor(app) {
super(app);
this.id = "layoutchild";
this.ComponentType = LayoutChildComponent;
this.DataType = LayoutChildComponentData;
this.schema = _schema;
}
initializeComponentData(component, data, properties) {
if (data.enabled !== void 0) component.enabled = data.enabled;
if (data.minWidth !== void 0) component.minWidth = data.minWidth;
if (data.minHeight !== void 0) component.minHeight = data.minHeight;
if (data.maxWidth !== void 0) component.maxWidth = data.maxWidth;
if (data.maxHeight !== void 0) component.maxHeight = data.maxHeight;
if (data.fitWidthProportion !== void 0) component.fitWidthProportion = data.fitWidthProportion;
if (data.fitHeightProportion !== void 0) component.fitHeightProportion = data.fitHeightProportion;
if (data.excludeFromLayout !== void 0) component.excludeFromLayout = data.excludeFromLayout;
super.initializeComponentData(component, data, properties);
}
cloneComponent(entity, clone) {
const layoutChild = entity.layoutchild;
return this.addComponent(clone, {
enabled: layoutChild.enabled,
minWidth: layoutChild.minWidth,
minHeight: layoutChild.minHeight,
maxWidth: layoutChild.maxWidth,
maxHeight: layoutChild.maxHeight,
fitWidthProportion: layoutChild.fitWidthProportion,
fitHeightProportion: layoutChild.fitHeightProportion,
excludeFromLayout: layoutChild.excludeFromLayout
});
}
}
Component._buildAccessors(LayoutChildComponent.prototype, _schema);
export {
LayoutChildComponentSystem
};