UNPKG

@polygonjs/polygonjs

Version:

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

70 lines (69 loc) 2.08 kB
"use strict"; import { OrthographicCamera, PerspectiveCamera } from "three"; import { NamedFunction2, NamedFunction3 } from "./_Base"; import { dummyReadRefVal } from "../../core/reactivity/CoreReactivity"; import { getDefaultCamera } from "./_Camera"; export class vector3AngleTo extends NamedFunction2 { static type() { return "vector3AngleTo"; } func(v1, v2) { return v1.angleTo(v2); } } export class vector3ProjectOnPlane extends NamedFunction3 { static type() { return "vector3ProjectOnPlane"; } func(src, planeNormal, target) { target.copy(src); target.projectOnPlane(planeNormal); return target; } } export class vector3Project extends NamedFunction3 { static type() { return "vector3Project"; } func(src, object3D, target) { if (object3D == null) { this._getDefaultCamera = this._getDefaultCamera || new getDefaultCamera(this.node, this.shadersCollectionController); object3D = this._getDefaultCamera.func(); } if (!(object3D instanceof PerspectiveCamera || object3D instanceof OrthographicCamera)) { return target; } dummyReadRefVal(this.timeController.timeUniform().value); target.copy(src); target.project(object3D); return target; } } export class vector3Unproject extends NamedFunction3 { static type() { return "vector3Unproject"; } func(src, object3D, target) { if (object3D == null) { this._getDefaultCamera = this._getDefaultCamera || new getDefaultCamera(this.node, this.shadersCollectionController); object3D = this._getDefaultCamera.func(); } if (!(object3D instanceof PerspectiveCamera || object3D instanceof OrthographicCamera)) { return target; } dummyReadRefVal(this.timeController.timeUniform().value); target.copy(src); target.unproject(object3D); return target; } } export class vector3ApplyMatrix4 extends NamedFunction3 { static type() { return "vector3ApplyMatrix4"; } func(src, matrix4, target) { target.copy(src); target.applyMatrix4(matrix4); return target; } }