Thank you to everyone who contributed to this wonderful R3F library.
I’m currently creating a project that leverages R3F.
So, using three-stdlib, I created a function to export an arbitrary Object3D model, but it is empty when output using std-lib.
I saw this bug report on Github.
I am choosing the module option in ESNext.
But this works fine with Imports like this:
With three/examples/jsm/exporters/GLTFExporter
import { GLTFExporter, GLTFExporterOptions } from "three/examples/jsm/exporters/GLTFExporter";
export const exportGLTF = async (scene: Scene): Promise<ArrayBuffer> => {
return new Promise<ArrayBuffer>((resolve, reject) => {
const exporter = new GLTFExporter();
const options: GLTFExporterOptions = {
binary: true,
animations: scene.animations,
includeCustomExtensions: true,
maxTextureSize: 4096
};
exporter.parse(
scene,
(gltfData) => {
if (gltfData instanceof ArrayBuffer) {
resolve(gltfData);
} else {
reject(new Error('GLTFExporter returned a non-binary result.'));
}
},
(error) => {
reject(error);
},
options
);
});
}
With three-stdlib
import { GLTFExporter, GLTFExporterOptions } from "three-stdlib";
export const exportGLTF = async (scene: Scene): Promise<ArrayBuffer> => {
return new Promise<ArrayBuffer>((resolve, reject) => {
const exporter = new GLTFExporter();
const options: GLTFExporterOptions = {
binary: true,
animations: scene.animations,
includeCustomExtensions: true,
// maxTextureSize: 4096
};
exporter.parse(
scene,
(gltfData) => {
if (gltfData instanceof ArrayBuffer) {
resolve(gltfData);
} else {
reject(new Error('GLTFExporter returned a non-binary result.'));
}
},
// (error) => {
// reject(error);
// },
options
);
});
}
result → In case with three-stdlib, the data is empty.
What is the cause of this?
three-stdlib: version 2.21.8