@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
60 lines (59 loc) • 1.72 kB
JavaScript
;
import { NamedFunction2, ObjectNamedFunction0, ObjectNamedFunction1 } from "./_Base";
import { removeFromParent, addToParent } from "../poly/PolyOnObjectsAddRemoveHooksController";
import { dummyReadRefVal } from "./_Param";
import { getOrCreateNodeRef } from "../../core/reactivity/NodeReactivity";
import { NodeContext } from "../poly/NodeContext";
export class getGeometryNodeObjects extends NamedFunction2 {
constructor() {
super(...arguments);
this.async = true;
}
static type() {
return "getGeometryNodeObjects";
}
async func(node, objects) {
var _a;
dummyReadRefVal(getOrCreateNodeRef(node.path()).value);
dummyReadRefVal(this.scene.timeController.timeUniform().value);
if (node && node.context() == NodeContext.SOP) {
const geometryNode = node;
const container = await geometryNode.compute();
const nodeObjects = ((_a = container.coreContent()) == null ? void 0 : _a.threejsObjects()) || [];
objects.length = 0;
for (let object of nodeObjects) {
objects.push(object);
}
}
}
}
export class createObject extends ObjectNamedFunction1 {
static type() {
return "createObject";
}
func(parent, child) {
if (child) {
addToParent(this.scene, parent, child);
}
}
}
export class createObjects extends ObjectNamedFunction1 {
static type() {
return "createObjects";
}
func(parent, children) {
for (let child of children) {
if (child) {
addToParent(this.scene, parent, child);
}
}
}
}
export class objectDelete extends ObjectNamedFunction0 {
static type() {
return "objectDelete";
}
func(object3D) {
removeFromParent(this.scene, object3D);
}
}