@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 1.43 kB
JavaScript
;
import { TypedNode } from "../_Base";
import { NodeContext } from "../../poly/NodeContext";
import { FlagsControllerBO } from "../utils/FlagsController";
import { DataTexture } from "three";
import { LuminanceFormat, HalfFloatType } from "three";
var size = 32;
var data = new Uint16Array(size);
for (var i = 0; i < size; i++) {
data[i] = 28898;
}
const EMPTY_DATA_TEXTURE = new DataTexture(data, size, 1, LuminanceFormat, HalfFloatType);
export class TypedCopNode extends TypedNode {
constructor() {
super(...arguments);
this.flags = new FlagsControllerBO(this);
}
static context() {
return NodeContext.COP;
}
initializeBaseNode() {
this.io.outputs.setHasOneOutput();
}
__textureSync__() {
return this.___textureSync;
}
setTexture(texture) {
this.___textureSync = texture;
texture.name = this.path();
this._setContainer(texture);
}
_clearTexture() {
this._setContainer(EMPTY_DATA_TEXTURE);
}
// this methods leads to webgl errors quite deep in threejs renderer
// private _copytexture(texture: Texture, target: Texture) {
// const newPropNames = Object.keys(texture) as Array<keyof Texture>;
// for (let newPropName of newPropNames) {
// (target as any)[newPropName] = texture[newPropName];
// console.log('prop', newPropName);
// }
// target.needsUpdate = true;
// }
}
export class BaseCopNodeClass extends TypedCopNode {
}