UNPKG

@polygonjs/polygonjs

Version:

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

20 lines (19 loc) 576 B
"use strict"; import { mod } from "../../core/math/_Module"; import { ObjectNamedFunction1 } from "./_Base"; export class getSibbling extends ObjectNamedFunction1 { static type() { return "getSibbling"; } func(object3D, offset) { const parent = object3D.parent || object3D; const children = parent.children; const currentIndex = children.indexOf(object3D); if (currentIndex < 0) { return object3D; } const index = mod(currentIndex + offset, children.length); const sibbling = children[index] || object3D; return sibbling; } }