UNPKG

@polygonjs/polygonjs

Version:

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

35 lines (34 loc) 1.22 kB
"use strict"; import { TypedSopNode } from "./_Base"; import { NodeParamsConfig } from "../utils/params/ParamsConfig"; import { InputCloneMode } from "../../poly/InputCloneMode"; import { SopType } from "../../poly/registers/nodes/types/Sop"; class AnimationCopySopParamsConfig extends NodeParamsConfig { } const ParamsConfig = new AnimationCopySopParamsConfig(); export class AnimationCopySopNode extends TypedSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopType.ANIMATION_COPY; } initializeNode() { this.io.inputs.setCount(2); this.io.inputs.initInputsClonedState([InputCloneMode.FROM_NODE, InputCloneMode.NEVER]); } cook(input_contents) { const core_group_target = input_contents[0]; const core_group_src = input_contents[1]; const src_object = core_group_src.threejsObjects()[0]; const target_object = core_group_target.threejsObjects()[0]; const src_animations = src_object.animations; if (src_animations) { target_object.animations = src_animations.map((a) => a.clone()); this.setCoreGroup(core_group_target); } else { this.states.error.set("no animation found"); } } }