@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
28 lines (27 loc) • 1.01 kB
JavaScript
;
import { Group } from "three";
import { CoreWFCRuleAttribute } from "./WFCAttributes";
export function validRuleObject(object) {
const id0 = CoreWFCRuleAttribute.getId0(object);
const id1 = CoreWFCRuleAttribute.getId1(object);
const side0 = CoreWFCRuleAttribute.getSide0(object);
const side1 = CoreWFCRuleAttribute.getSide1(object);
return id0 != void 0 && id1 != void 0 && side0 != void 0 && side1 != void 0;
}
export function wfcRuleFromObject(object) {
const connection = {
id0: CoreWFCRuleAttribute.getId0(object),
id1: CoreWFCRuleAttribute.getId1(object),
side0: CoreWFCRuleAttribute.getSide0(object),
side1: CoreWFCRuleAttribute.getSide1(object)
};
return connection;
}
export function createRuleObject(rule) {
const group = new Group();
CoreWFCRuleAttribute.setId0(group, rule.id0);
CoreWFCRuleAttribute.setId1(group, rule.id1);
CoreWFCRuleAttribute.setSide0(group, rule.side0);
CoreWFCRuleAttribute.setSide1(group, rule.side1);
return group;
}