How can i using ObjExporter with javascript?

hi, i try to use objLoader to load the obj file, scale and resize in (php javascript), everything is working as example html, but when im using ObjExporter
import { OBJExporter } from 'three/addons/exporters/OBJExporter.js'; this line cause the blank screen

this is the import js from objLoader example, how can i get it to work?

Any errors in the console?

3 Likes

++ three.js docs OBJExporter is pretty straight forward to use from the docs, is this the same as your setup? Are you using dataTextures or FBO on your materials?

Another option is to use GLTFExporter which you can export as binary also, not sure if OBJExporter from three would preserve quads if that’s the reason for using bulky file formats…

no error just blank,
this is the code im using

<!DOCTYPE html>
<html lang="en">
	<head>
		<title>three.js webgl - exporter - obj</title>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
		<link type="text/css" rel="stylesheet" href="main.css">
	</head>
	<body>
		<div id="info">
			<a href="https://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - exporter - obj
		</div>

		<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@v0.168.0
/build/three.module.js",
      "three/addons/": "https://cdn.jsdelivr.net/npm/three@v0.168.0/examples/jsm/"
    }
  }
</script>

		<script type="module">

			import * as THREE from 'three';

			import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
			import { OBJExporter } from 'three/addons/exporters/OBJExporter.js';
			import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

is that different if im using php and javascript?

You may need to provide the rest of your code + the usage of the exporter, there would be not much reason for a blank screen in three.js it should just download to the browser, however, this may be seeing failures if your sending the resulting Obj string to php, you may need to .encode() and then .decode() back where you are saving the file…