@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
104 lines (103 loc) • 3.09 kB
JavaScript
;
import {
ObjectNamedFunction0,
ObjectNamedFunction1,
ObjectNamedFunction2,
ObjectNamedFunction3,
ObjectNamedFunction4
} from "./_Base";
import { dummyReadRefVal } from "../../core/reactivity/CoreReactivity";
import { Attribute } from "../../core/geometry/Attribute";
import { getObjectPtnumRef } from "../../core/reactivity/PointPropertyReactivity";
export class getPointIndex extends ObjectNamedFunction0 {
static type() {
return "getPointIndex";
}
func(object3D) {
const ref = getObjectPtnumRef(object3D);
return ref.value;
}
}
export class setPointIndex extends ObjectNamedFunction1 {
static type() {
return "setPointIndex";
}
func(object3D, ptnum) {
const ref = getObjectPtnumRef(object3D);
ref.value = ptnum;
return ptnum;
}
}
export class getPointPosition extends ObjectNamedFunction2 {
static type() {
return "getPointPosition";
}
func(object3D, ptnum, target) {
dummyReadRefVal(this.timeController.timeUniform().value);
if (!object3D.geometry) {
target.set(0, 0, 0);
return target;
}
const positionAttribute = object3D.geometry.getAttribute(Attribute.POSITION);
target.fromBufferAttribute(positionAttribute, ptnum);
return target;
}
}
export class getPointAttributeNumber extends ObjectNamedFunction3 {
static type() {
return "getPointAttributeNumber";
}
func(object3D, ptnum, attribName, defaultValue) {
dummyReadRefVal(this.timeController.timeUniform().value);
const attribute = object3D.geometry.getAttribute(attribName);
if (!attribute) {
return defaultValue;
}
return attribute.array[ptnum];
}
}
export class getPointAttributeVector2 extends ObjectNamedFunction4 {
static type() {
return "getPointAttributeVector2";
}
func(object3D, ptnum, attribName, defaultValue, target) {
dummyReadRefVal(this.timeController.timeUniform().value);
const attribute = object3D.geometry.getAttribute(attribName);
if (!attribute) {
target.copy(defaultValue);
return target;
}
target.fromArray(attribute.array, ptnum * 2);
return target;
}
}
export class getPointAttributeVector3 extends ObjectNamedFunction4 {
static type() {
return "getPointAttributeVector3";
}
func(object3D, ptnum, attribName, defaultValue, target) {
dummyReadRefVal(this.timeController.timeUniform().value);
const attribute = object3D.geometry.getAttribute(attribName);
if (!attribute) {
target.copy(defaultValue);
return target;
}
target.fromArray(attribute.array, ptnum * 3);
return target;
}
}
export class getPointAttributeVector4 extends ObjectNamedFunction4 {
static type() {
return "getPointAttributeVector4";
}
func(object3D, ptnum, attribName, defaultValue, target) {
dummyReadRefVal(this.timeController.timeUniform().value);
const attribute = object3D.geometry.getAttribute(attribName);
if (!attribute) {
target.copy(defaultValue);
return target;
}
target.fromArray(attribute.array, ptnum * 4);
return target;
}
}