UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

40 lines (39 loc) 1.57 kB
"use strict"; import { BaseFileMultiSopNode } from "./utils/file/_BaseSopFileMulti"; import { SopTypeFileMulti } from "../../poly/registers/nodes/types/Sop"; import { OBJLoaderHandler } from "../../../core/loader/geometry/OBJ"; import { NodeParamsConfig, ParamConfig } from "../utils/params/ParamsConfig"; import { ASSETS_ROOT } from "../../../core/loader/AssetsUtils"; import { EXTENSIONS_BY_NODE_TYPE_BY_CONTEXT } from "../../../core/loader/FileExtensionRegister"; import { NodeContext } from "../../poly/NodeContext"; class FileMultiOBJParamsConfig extends NodeParamsConfig { constructor() { super(...arguments); /** @param url to load the geometry from */ this.url = ParamConfig.STRING(`${ASSETS_ROOT}/models/\`@name\`.obj`, { fileBrowse: { extensions: EXTENSIONS_BY_NODE_TYPE_BY_CONTEXT[NodeContext.SOP][SopTypeFileMulti.FILE_OBJ] }, expression: { forEntities: true } }); /** @param sets the matrixAutoUpdate attribute for the objects loaded */ this.matrixAutoUpdate = ParamConfig.BOOLEAN(false); /** @param reload the geometry */ this.reload = ParamConfig.BUTTON(null, { callback: (node) => { BaseFileMultiSopNode.PARAM_CALLBACK_reload(node); } }); } } const ParamsConfig = new FileMultiOBJParamsConfig(); export class FileMultiOBJSopNode extends BaseFileMultiSopNode { constructor() { super(...arguments); this.paramsConfig = ParamsConfig; } static type() { return SopTypeFileMulti.FILE_OBJ; } _createLoader(url) { return new OBJLoaderHandler(url, this); } }