@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
41 lines (40 loc) • 1.19 kB
JavaScript
;
import { NamedFunction1 } from "./_Base";
import { NodeContext } from "../poly/NodeContext";
import { isFunction } from "../../core/Type";
import { getOrCreateNodeRef } from "../../core/reactivity/NodeReactivity";
import { dummyReadRefVal } from "../../core/reactivity/CoreReactivity";
export class getTexture extends NamedFunction1 {
static type() {
return "getTexture";
}
func(nodePath) {
dummyReadRefVal(getOrCreateNodeRef(nodePath).value);
const node = this.scene.node(nodePath);
if (node && node.context() == NodeContext.COP) {
if (isFunction(node.__textureSync__)) {
if (node.isDirty()) {
node.compute();
}
return node.__textureSync__();
}
}
}
}
export class getMaterial extends NamedFunction1 {
static type() {
return "getMaterial";
}
func(nodePath) {
dummyReadRefVal(getOrCreateNodeRef(nodePath).value);
const node = this.scene.node(nodePath);
if (node && node.context() == NodeContext.MAT) {
if (node && isFunction(node.__materialSync__)) {
if (node.isDirty()) {
node.compute();
}
return node.__materialSync__();
}
}
}
}