@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
56 lines (55 loc) • 2.06 kB
JavaScript
;
import { File3DSSopOperation } from "../../operations/sop/File3DS";
import { SopTypeFile } from "../../poly/registers/nodes/types/Sop";
import { EXTENSIONS_BY_NODE_TYPE_BY_CONTEXT } from "../../../core/loader/FileExtensionRegister";
import { NodeContext } from "../../poly/NodeContext";
import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig";
import { Poly } from "../../Poly";
import { TypedSopNode } from "./_Base";
import { ParamEvent } from "../../poly/ParamEvent";
const DEFAULT = File3DSSopOperation.DEFAULT_PARAMS;
class File3DSParamsConfig extends NodeParamsConfig {
constructor() {
super(...arguments);
/** @param url to load the geometry from */
this.url = ParamConfig.STRING(DEFAULT.url, {
fileBrowse: { extensions: EXTENSIONS_BY_NODE_TYPE_BY_CONTEXT[NodeContext.SOP][SopTypeFile.FILE_3DS] }
});
/** @param texture folder url */
this.resourceUrl = ParamConfig.STRING(DEFAULT.resourceUrl);
/** @param sets the matrixAutoUpdate attribute for the objects loaded */
this.matrixAutoUpdate = ParamConfig.BOOLEAN(DEFAULT.matrixAutoUpdate);
/** @param reload the geometry */
this.reload = ParamConfig.BUTTON(null, {
callback: (node) => {
File3DSSopNode.PARAM_CALLBACK_reload(node);
}
});
}
}
const ParamsConfig = new File3DSParamsConfig();
export class File3DSSopNode extends TypedSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopTypeFile.FILE_3DS;
}
dispose() {
super.dispose();
Poly.blobs.clearBlobsForNode(this);
}
async cook(inputCoreGroups) {
this._operation = this._operation || new File3DSSopOperation(this.scene(), this.states, this);
const coreGroup = await this._operation.cook(inputCoreGroups, this.pv);
this.setCoreGroup(coreGroup);
}
static PARAM_CALLBACK_reload(node) {
node._paramCallbackReload();
}
_paramCallbackReload() {
this.p.url.setDirty();
this.p.url.emit(ParamEvent.ASSET_RELOAD_REQUEST);
}
}