Browse Source

Editor: Added File/Export DRC

Mr.doob 5 năm trước cách đây
mục cha
commit
47a9abc014
4 tập tin đã thay đổi với 35 bổ sung3 xóa
  1. 1 0
      editor/index.html
  2. 26 0
      editor/js/Menubar.File.js
  3. 6 3
      editor/js/Strings.js
  4. 2 0
      editor/sw.js

+ 1 - 0
editor/index.html

@@ -12,6 +12,7 @@
 		<link rel="stylesheet" href="css/main.css">
 
 		<script src="../examples/js/libs/jszip.min.js"></script>
+		<script src="../examples/js/libs/draco/draco_encoder.js"></script>
 
 		<link rel="stylesheet" href="js/libs/codemirror/codemirror.css">
 		<link rel="stylesheet" href="js/libs/codemirror/theme/monokai.css">

+ 26 - 0
editor/js/Menubar.File.js

@@ -5,6 +5,7 @@
 import * as THREE from '../../build/three.module.js';
 
 import { ColladaExporter } from '../../examples/jsm/exporters/ColladaExporter.js';
+import { DRACOExporter } from '../../examples/jsm/exporters/DRACOExporter.js';
 import { GLTFExporter } from '../../examples/jsm/exporters/GLTFExporter.js';
 import { OBJExporter } from '../../examples/jsm/exporters/OBJExporter.js';
 import { PLYExporter } from '../../examples/jsm/exporters/PLYExporter.js';
@@ -214,6 +215,31 @@ var MenubarFile = function ( editor ) {
 	} );
 	options.add( option );
 
+	// Export DRC
+
+	var option = new UIRow();
+	option.setClass( 'option' );
+	option.setTextContent( strings.getKey( 'menubar/file/export/drc' ) );
+	option.onClick( function () {
+
+		var object = editor.selected;
+
+		if ( object === null || object.isMesh === undefined ) {
+
+			alert( 'No mesh selected' );
+			return;
+
+		}
+
+		var exporter = new DRACOExporter();
+
+		// TODO: Change to DRACOExporter's parse( geometry, onParse )?
+		var result = exporter.parse( object.geometry );
+		saveArrayBuffer( result, 'model.drc' );
+
+	} );
+	options.add( option );
+
 	// Export GLB
 
 	var option = new UIRow();

+ 6 - 3
editor/js/Strings.js

@@ -17,6 +17,7 @@ var Strings = function ( config ) {
 			'menubar/file/export/object': 'Export Object',
 			'menubar/file/export/scene': 'Export Scene',
 			'menubar/file/export/dae': 'Export DAE',
+			'menubar/file/export/drc': 'Export DRC',
 			'menubar/file/export/glb': 'Export GLB',
 			'menubar/file/export/gltf': 'Export GLTF',
 			'menubar/file/export/obj': 'Export OBJ',
@@ -327,6 +328,7 @@ var Strings = function ( config ) {
 			'menubar/file/export/object': 'Exporter Objet',
 			'menubar/file/export/scene': 'Exporter Scene',
 			'menubar/file/export/dae': 'Exporter DAE',
+			'menubar/file/export/drc': 'Exporter DRC',
 			'menubar/file/export/glb': 'Exporter GLB',
 			'menubar/file/export/gltf': 'Exporter GLTF',
 			'menubar/file/export/obj': 'Exporter OBJ',
@@ -602,11 +604,11 @@ var Strings = function ( config ) {
 			'sidebar/project/toneMappingWhitePoint': 'Point Blanc',
 			'sidebar/project/materials': 'Materiels',
 			'sidebar/project/Assign': 'Attribuer',
-			
+
 			'sidebar/settings': 'Paramètres',
 			'sidebar/settings/language': 'Langue',
 			'sidebar/settings/exportPrecision': 'Précision d\'exportation',
-			
+
 			'sidebar/settings/shortcuts/translate': 'Traduire',
 			'sidebar/settings/shortcuts/rotate': 'Rotation',
 			'sidebar/settings/shortcuts/scale': 'Échelle',
@@ -629,7 +631,7 @@ var Strings = function ( config ) {
 			'viewport/info/frametime': 'Temps de trame'
 		},
 		zh: {
-			
+
 			'menubar/file': '文件',
 			'menubar/file/new': '新建',
 			'menubar/file/import': '导入',
@@ -637,6 +639,7 @@ var Strings = function ( config ) {
 			'menubar/file/export/object': '导出物体',
 			'menubar/file/export/scene': '导出场景',
 			'menubar/file/export/dae': '导出DAE',
+			'menubar/file/export/drc': '导出DRC',
 			'menubar/file/export/glb': '导出GLB',
 			'menubar/file/export/gltf': '导出GLTF',
 			'menubar/file/export/obj': '导出OBJ',

+ 2 - 0
editor/sw.js

@@ -15,6 +15,7 @@ const assets = [
 	'../examples/js/libs/jszip.min.js',
 	'../examples/js/libs/draco/draco_decoder.js',
 	'../examples/js/libs/draco/draco_decoder.wasm',
+	'../examples/js/libs/draco/draco_encoder.js',
 	'../examples/js/libs/draco/draco_wasm_wrapper.js',
 
 	'../examples/jsm/loaders/AMFLoader.js',
@@ -39,6 +40,7 @@ const assets = [
 	'../examples/jsm/curves/NURBSUtils.js',
 
 	'../examples/jsm/exporters/ColladaExporter.js',
+	'../examples/jsm/exporters/DRACOExporter.js',
 	'../examples/jsm/exporters/GLTFExporter.js',
 	'../examples/jsm/exporters/OBJExporter.js',
 	'../examples/jsm/exporters/PLYExporter.js',