@polygonjs/polygonjs
Version:
node-based WebGL 3D engine https://polygonjs.com
47 lines (46 loc) • 1.27 kB
JavaScript
;
import { ExporterSopNode, BaseExporterSopParamsConfig } from "./_BaseExporter";
import { GLTFExporter } from "three/examples/jsm/exporters/GLTFExporter";
import { SopExporter } from "../../poly/registers/nodes/types/Sop";
class ExporterGLTFSopParamsConfig extends BaseExporterSopParamsConfig {
}
const ParamsConfig = new ExporterGLTFSopParamsConfig();
export class ExporterGLTFSopNode extends ExporterSopNode {
constructor() {
super(...arguments);
this.paramsConfig = ParamsConfig;
}
static type() {
return SopExporter.EXPORTER_GLTF;
}
fileExtension() {
return "glb";
}
createBlob() {
return new Promise(async (resolve) => {
const sceneData = await this._prepareScene();
if (!sceneData) {
return;
}
const { scene, objects } = sceneData;
const options = {
embedImages: true,
// trs: true,
// onlyVisible: true,
// truncateDrawRange: false,
binary: true
// maxTextureSize: Infinity
};
const exporter = new GLTFExporter();
exporter.parse(
scene,
async (result) => {
this._handleResult(result, objects, resolve);
},
(err) => {
},
options
);
});
}
}