UNPKG

@polygonjs/polygonjs

Version:

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

25 lines (24 loc) 981 B
"use strict"; import { Mesh } from "three"; import { ClothIdAttribute } from "./ClothAttribute"; import { ClothController } from "./ClothController"; import { coreObjectClassFactory } from "../geometry/CoreObjectFactory"; const clothControllerByGraphNodeId = /* @__PURE__ */ new Map(); export function createOrFindClothController(scene, node, clothObject) { let controller = clothControllerByGraphNodeId.get(clothObject.uuid); if (!controller) { if (!(clothObject instanceof Mesh)) { return; } controller = new ClothController(scene, node, clothObject); clothControllerByGraphNodeId.set(clothObject.uuid, controller); } return { controller }; } export function clothControllerNodeIdFromObject(clothObject) { const nodeId = coreObjectClassFactory(clothObject).attribValue(clothObject, ClothIdAttribute.OBJECT); return nodeId; } export function clothControllerFromObject(clothObject) { return clothControllerByGraphNodeId.get(clothObject.uuid); }