Skip to content

Commit

Permalink
Add option to export scene and modify alphaMode since all gui created…
Browse files Browse the repository at this point in the history
… meterials are default transparent
  • Loading branch information
aymanhab committed Jan 4, 2024
1 parent 4d25e77 commit a3e7f9e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
27 changes: 24 additions & 3 deletions editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<!--<script src="../examples/js/libs/draco/draco_encoder.js"></script>-->
<script src="../examples/js/libs/dat.gui.min.js"></script>

<script src="../examples/js/exporters/GLTFExporter.js"></script>

<link rel="stylesheet" href="js/libs/codemirror/codemirror.css">
<link rel="stylesheet" href="js/libs/codemirror/theme/monokai.css">
Expand Down Expand Up @@ -71,7 +71,7 @@
//import { VRButton } from '../examples/jsm/webxr/VRButton.js';
import { OpenSimToolbar } from './js/OpenSimToolbar.js';
import { websocket } from './websocket.js';

import { GLTFExporter } from '../examples/jsm/exporters/GLTFExporter.js';

function getParameterByName(name, url) {
if (!url) url = window.location.href;
Expand Down Expand Up @@ -134,7 +134,27 @@
elem.style.bottom="20px";
window.dispatchEvent(new Event('resize'));
}
// Screen Capture
// Export
this.exportGLtf = function () {
var hasGround = editor.groundPlane !== null;
var saveGround = (hasGround?editor.groundPlane.visible:null);
if (hasGround)
editor.groundPlane.visible = false;
var scene = editor.scene;
// create exporter
var exporter = new GLTFExporter();
exporter.parse( scene, function ( result ) {
var jsonGltf = JSON.stringify( result, null, 2 );
var blob = new Blob( [ jsonGltf ], { type: 'text/plain' } );
var link = document.createElement( 'a' );
link.href = URL.createObjectURL( blob );
link.download = 'scene.gltf';
link.dispatchEvent( new MouseEvent( 'click' ) );
}, {});
if (hasGround)
groundPlane.visible = saveGround;
}
// Screen Capture
this.screenCaptureDPI = editor.config.getKey('settings/captureDPI');
if (this.screenCaptureDPI === undefined){
editor.config.setKey('settings/captureDPI', 2);
Expand Down Expand Up @@ -177,6 +197,7 @@
modelLightIntensity.name('Model Light').onChange(function(value){
editor.updateModelLightIntensity(value);
});
gui.add(knobs, 'exportGLtf').name('Export scene');
if (getParameterByName('expert') === "1"){
gui.add(knobs, 'expertModeSelect').name('Expert Mode');
gui.add(knobs, 'showStats').name('FPS');
Expand Down
2 changes: 1 addition & 1 deletion examples/js/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ THREE.GLTFExporter = ( function () {
// alphaMode
if ( material.transparent ) {

materialDef.alphaMode = 'BLEND';
materialDef.alphaMode = 'OPAQUE';

} else {

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/exporters/GLTFExporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ var GLTFExporter = ( function () {
// alphaMode
if ( material.transparent ) {

materialDef.alphaMode = 'BLEND';
materialDef.alphaMode = 'OPAQUE';

} else {

Expand Down

0 comments on commit a3e7f9e

Please sign in to comment.