UNPKG

@polygonjs/polygonjs

Version:

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

45 lines (44 loc) 1.42 kB
"use strict"; import { Vector3, Matrix4 } from "three"; import { GetObjectPropertyJsNodeInputName, touchObjectProperties } from "../../core/reactivity/ObjectPropertyReactivity"; import { NamedFunction5, ObjectNamedFunction4 } from "./_Base"; import { CorePolarTransform } from "../../core/PolarTransform"; const fullMatrix = new Matrix4(); const params = { center: new Vector3(), longitude: 0, latitude: 0, depth: 0 }; const PROPERTIES = [ GetObjectPropertyJsNodeInputName.position, GetObjectPropertyJsNodeInputName.quaternion, GetObjectPropertyJsNodeInputName.matrix ]; export class setObjectPolarTransform extends ObjectNamedFunction4 { static type() { return "setObjectPolarTransform"; } func(object3D, center, longitude, latitude, depth) { params.center.copy(center); params.longitude = longitude; params.latitude = latitude; params.depth = depth; CorePolarTransform.matrix(params, fullMatrix); CorePolarTransform.applyMatrixToObject(object3D, fullMatrix); touchObjectProperties(object3D, PROPERTIES); } } export class polarTransform extends NamedFunction5 { static type() { return "polarTransform"; } func(center, longitude, latitude, depth, target) { params.center.copy(center); params.longitude = longitude; params.latitude = latitude; params.depth = depth; CorePolarTransform.matrix(params, target); return target; } }