UNPKG

@polygonjs/polygonjs

Version:

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

30 lines (26 loc) 1.26 kB
import {Object3D} from 'three'; import {ObjectNamedFunction3} from './_Base'; import {_dummyReadAttributeRefVal} from '../../core/reactivity/ObjectAttributeReactivity'; import {getOrCreateObjectAttributeRef} from '../../core/reactivity/ObjectAttributeReactivityCreateRef'; import {_matchArrayLength, _matchArrayLengthWithType} from './_ArrayUtils'; import {ParamConvertibleJsType} from '../nodes/utils/io/connections/Js'; import {AttribValue} from '../../types/GlobalTypes'; import {getObjectChildrenCountRef} from '../../core/reactivity/ObjectHierarchyReactivity'; import {dummyReadRefVal} from './_Param'; export class getChildrenAttributesPrevious extends ObjectNamedFunction3<[string, string, Array<AttribValue>]> { static override type() { return 'getChildrenAttributesPrevious'; } func(object3D: Object3D, attribName: string, type: ParamConvertibleJsType, values: AttribValue[]): AttribValue[] { dummyReadRefVal(getObjectChildrenCountRef(object3D).value); _matchArrayLengthWithType(object3D.children, values, type); let i = 0; const children = object3D.children; for (let child of children) { const _refs = getOrCreateObjectAttributeRef(child, attribName, type); values[i] = _refs.previous.value; i++; } return values; } }