UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

56 lines (55 loc) 1.88 kB
"use strict"; import { BaseSopOperation } from "./_Base"; import { InputCloneMode } from "../../../engine/poly/InputCloneMode"; import { Vector3 } from "three"; import { SopType } from "../../poly/registers/nodes/types/Sop"; import { CoreMask } from "../../../core/geometry/Mask"; import { DEFAULT_POSITIONS, cubeLatticeDeform } from "../../../core/geometry/operation/CubeLatticeDeform"; const cubeLatticeDeformPoints = [ new Vector3(), new Vector3(), new Vector3(), new Vector3(), new Vector3(), new Vector3(), new Vector3(), new Vector3() ]; export class LatticeSopOperation extends BaseSopOperation { static type() { return SopType.LATTICE; } cook(inputCoreGroups, params) { const coreGroup = inputCoreGroups[0]; cubeLatticeDeformPoints[0].copy(params.p0); cubeLatticeDeformPoints[1].copy(params.p1); cubeLatticeDeformPoints[2].copy(params.p2); cubeLatticeDeformPoints[3].copy(params.p3); cubeLatticeDeformPoints[4].copy(params.p4); cubeLatticeDeformPoints[5].copy(params.p5); cubeLatticeDeformPoints[6].copy(params.p6); cubeLatticeDeformPoints[7].copy(params.p7); const objects = CoreMask.filterThreejsObjects(coreGroup, params); for (const object of objects) { const geometry = object.geometry; if (geometry) { cubeLatticeDeform(object, cubeLatticeDeformPoints, params); } } return coreGroup; } } LatticeSopOperation.DEFAULT_PARAMS = { group: "", p0: DEFAULT_POSITIONS[0].clone(), p1: DEFAULT_POSITIONS[1].clone(), p2: DEFAULT_POSITIONS[2].clone(), p3: DEFAULT_POSITIONS[3].clone(), p4: DEFAULT_POSITIONS[4].clone(), p5: DEFAULT_POSITIONS[5].clone(), p6: DEFAULT_POSITIONS[6].clone(), p7: DEFAULT_POSITIONS[7].clone(), offset: new Vector3(0, 0, 0), moveObjectPosition: true }; LatticeSopOperation.INPUT_CLONED_STATE = InputCloneMode.FROM_NODE;