UNPKG

polygonjs-engine

Version:

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

36 lines (35 loc) 978 B
import {BaseMethod} from "./_Base"; export class CopResExpression extends BaseMethod { constructor() { super(...arguments); this._require_dependency = true; } static required_arguments() { return [ ["string", "path to node"], ["string", "component_name: x or y"] ]; } find_dependency(index_or_path) { return this.create_dependency_from_index_or_path(index_or_path); } async process_arguments(args) { let value = 0; if (args.length == 2) { const index_or_path = args[0]; const component_name = args[1]; const container = await this.get_referenced_node_container(index_or_path); if (container) { const resolution = container.resolution(); if ([0, "0", "x"].includes(component_name)) { value = resolution[0]; } else { if ([1, "1", "y"].includes(component_name)) { value = resolution[1]; } } } } return value; } }