UNPKG

@polygonjs/polygonjs

Version:

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

29 lines (28 loc) 1.28 kB
"use strict"; import { ThreejsCoreObject } from "../../core/geometry/modules/three/ThreejsCoreObject"; import { ObjectNamedFunction3 } from "./_Base"; import { _dummyReadAttributeRefVal } from "../../core/reactivity/ObjectAttributeReactivity"; import { getOrCreateObjectAttributeRef } from "../../core/reactivity/ObjectAttributeReactivityCreateRef"; import { _matchArrayLengthWithType } from "./_ArrayUtils"; import { getObjectChildrenCountRef } from "../../core/reactivity/ObjectHierarchyReactivity"; import { dummyReadRefVal } from "./_Param"; export class getChildrenAttributes extends ObjectNamedFunction3 { static type() { return "getChildrenAttributes"; } func(object3D, attribName, type, values) { 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); const currentValue = ThreejsCoreObject.attribValue(child, attribName); const value = currentValue != null ? currentValue : _refs.current.value; _dummyReadAttributeRefVal(_refs.current.value); values[i] = value; i++; } return values; } }