Skip to content

Commit

Permalink
Updated snapshot to 1.2.4
Browse files Browse the repository at this point in the history
* Up to 20% faster decoding
* Added support for integer attributes to our Javascript Encoder
* Fixed issues with THREE.DracoLoader not releasing memory associated
with the Draco module
* OBJ decoder can now be used to parse pure point clouds
* Added Unity plugins to support runtime loading and design-time
importing of encoded Draco files
  • Loading branch information
ondys committed Dec 13, 2017
1 parent 451b56f commit 5186ec2
Show file tree
Hide file tree
Showing 72 changed files with 2,612 additions and 832 deletions.
45 changes: 42 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(ENABLE_WASM "" OFF)
option(ENABLE_WERROR "" OFF)
option(ENABLE_WEXTRA "" OFF)
option(IGNORE_EMPTY_BUILD_TYPE "" OFF)
option(BUILD_UNITY_PLUGIN "Build plugin library for Unity" OFF)
option(BUILD_FOR_GLTF "" OFF)

if (BUILD_FOR_GLTF)
Expand Down Expand Up @@ -100,6 +101,10 @@ endif ()
if (ENABLE_GOMA)
set_compiler_launcher(ENABLE_GOMA gomacc)
endif ()
if (BUILD_UNITY_PLUGIN)
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library for unity plugin.")
add_cxx_preproc_definition("BUILD_UNITY_PLUGIN")
endif ()

if(ENABLE_EXTRA_SPEED)
if(MSVC)
Expand Down Expand Up @@ -467,7 +472,6 @@ set(draco_io_sources
set(draco_mesh_sources
"${draco_src_root}/mesh/corner_table.cc"
"${draco_src_root}/mesh/corner_table.h"
"${draco_src_root}/mesh/corner_table_indices.h"
"${draco_src_root}/mesh/corner_table_iterators.h"
"${draco_src_root}/mesh/corner_table_traversal_processor.h"
"${draco_src_root}/mesh/edgebreaker_observer.h"
Expand All @@ -480,7 +484,6 @@ set(draco_mesh_sources
"${draco_src_root}/mesh/mesh_attribute_corner_table.h"
"${draco_src_root}/mesh/mesh_cleanup.cc"
"${draco_src_root}/mesh/mesh_cleanup.h"
"${draco_src_root}/mesh/mesh_indices.h"
"${draco_src_root}/mesh/mesh_misc_functions.cc"
"${draco_src_root}/mesh/mesh_misc_functions.h"
"${draco_src_root}/mesh/mesh_stripifier.cc"
Expand Down Expand Up @@ -573,6 +576,10 @@ set(draco_version_sources
"${draco_build_dir}/draco_version.cc"
"${draco_build_dir}/draco_version.h")

set(draco_unity_plug_sources
"${draco_src_root}/unity/draco_unity_plugin.cc"
"${draco_src_root}/unity/draco_unity_plugin.h")

include_directories("${draco_root}/src")

#
Expand Down Expand Up @@ -758,6 +765,8 @@ else ()
add_library(draco_points_enc OBJECT
${draco_points_common_sources}
${draco_points_enc_sources})
add_library(draco_unity_plugin OBJECT
${draco_unity_plug_sources})

# Library targets that consume the object collections.
add_library(dracodec
Expand Down Expand Up @@ -817,7 +826,30 @@ else ()
$<TARGET_OBJECTS:draco_point_cloud>
$<TARGET_OBJECTS:draco_points_dec>
$<TARGET_OBJECTS:draco_points_enc>)

if (BUILD_UNITY_PLUGIN)
add_library(dracodec_unity
MODULE
${draco_version_sources}
$<TARGET_OBJECTS:draco_unity_plugin>
$<TARGET_OBJECTS:draco_attributes>
$<TARGET_OBJECTS:draco_compression_attributes_dec>
$<TARGET_OBJECTS:draco_compression_decode>
$<TARGET_OBJECTS:draco_compression_mesh_dec>
$<TARGET_OBJECTS:draco_compression_point_cloud_dec>
$<TARGET_OBJECTS:draco_core>
$<TARGET_OBJECTS:draco_core_bit_coders>
$<TARGET_OBJECTS:draco_dec_config>
$<TARGET_OBJECTS:draco_io>
$<TARGET_OBJECTS:draco_mesh>
$<TARGET_OBJECTS:draco_metadata>
$<TARGET_OBJECTS:draco_metadata_dec>
$<TARGET_OBJECTS:draco_point_cloud>
$<TARGET_OBJECTS:draco_points_dec>)
# For Mac, we need to build a .bundle for plugin.
if (APPLE)
set_target_properties(dracodec_unity PROPERTIES BUNDLE true)
endif ()
endif ()
set(draco_header_only_targets
draco_compression_attributes_pred_schemes_dec
draco_dec_config
Expand All @@ -832,6 +864,9 @@ else ()
set_target_properties(dracodec PROPERTIES SOVERSION 1)
set_target_properties(dracoenc PROPERTIES SOVERSION 1)
set_target_properties(draco PROPERTIES SOVERSION 1)
if (BUILD_UNITY_PLUGIN)
set_target_properties(dracodec_unity PROPERTIES SOVERSION 1)
endif ()
endif ()

extract_version_string("${draco_src_root}/core/draco_version.h" draco_version)
Expand Down Expand Up @@ -886,6 +921,10 @@ else ()
# Add install rules for lib and executable targets.
install(TARGETS dracodec dracoenc draco
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
if (BUILD_UNITY_PLUGIN)
install(TARGETS dracodec_unity
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
endif ()
install(TARGETS draco_decoder draco_encoder DESTINATION
"${CMAKE_INSTALL_PREFIX}/bin")

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@

News
=======
### Version 1.2.4 release
* Up to 20% faster decoding
* Added support for integer attributes to our Javascript Encoder
* Fixed issues with THREE.DracoLoader not releasing memory associated with the Draco module
* OBJ decoder can now be used to parse pure point clouds
* Added Unity plugins to support runtime loading and design-time importing of encoded Draco files

### Version 1.2.3 release
* Fixed Visual Studio building issue

Expand Down
20 changes: 11 additions & 9 deletions javascript/draco_decoder.js

Large diffs are not rendered by default.

Binary file modified javascript/draco_decoder.wasm
Binary file not shown.
19 changes: 10 additions & 9 deletions javascript/draco_decoder_gltf.js

Large diffs are not rendered by default.

Binary file modified javascript/draco_decoder_gltf.wasm
Binary file not shown.
22 changes: 12 additions & 10 deletions javascript/draco_encoder.js

Large diffs are not rendered by default.

238 changes: 113 additions & 125 deletions javascript/draco_wasm_wrapper.js

Large diffs are not rendered by default.

237 changes: 113 additions & 124 deletions javascript/draco_wasm_wrapper_gltf.js

Large diffs are not rendered by default.

44 changes: 30 additions & 14 deletions javascript/example/DRACOLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ THREE.DRACOLoader.prototype = {
var scope = this;
this.attributeUniqueIdMap = (attributeUniqueIdMap !== undefined) ?
attributeUniqueIdMap : {};
THREE.DRACOLoader.getDecoder(this,
THREE.DRACOLoader.getDecoderModule(
function(dracoDecoder) {
scope.decodeDracoFileInternal(rawBuffer, dracoDecoder, callback);
});
Expand Down Expand Up @@ -333,7 +333,7 @@ THREE.DRACOLoader.prototype = {
},

isVersionSupported: function(version, callback) {
THREE.DRACOLoader.getDecoder(this,
THREE.DRACOLoader.getDecoderModule(
function(decoder) {
callback(decoder.isVersionSupported(version));
});
Expand Down Expand Up @@ -405,21 +405,20 @@ THREE.DRACOLoader.loadDracoDecoder = function(dracoDecoder) {
}
}

THREE.DRACOLoader.decoderCreationCalled = false;

/**
* Creates and returns a singleton instance of the DracoDecoderModule.
* The module loading is done asynchronously for WebAssembly. Initialized module
* can be accessed through the callback function
* |onDracoDecoderModuleLoadedCallback|.
*/
THREE.DRACOLoader.getDecoder = (function() {
var decoder;
var decoderCreationCalled = false;

return function(dracoDecoder, onDracoDecoderModuleLoadedCallback) {
if (typeof decoder !== 'undefined') {
THREE.DRACOLoader.getDecoderModule = (function() {
return function(onDracoDecoderModuleLoadedCallback) {
if (typeof THREE.DRACOLoader.decoderModule !== 'undefined') {
// Module already initialized.
if (typeof onDracoDecoderModuleLoadedCallback !== 'undefined') {
onDracoDecoderModuleLoadedCallback(decoder);
onDracoDecoderModuleLoadedCallback(THREE.DRACOLoader.decoderModule);
}
} else {
if (typeof DracoDecoderModule === 'undefined') {
Expand All @@ -438,23 +437,40 @@ THREE.DRACOLoader.getDecoder = (function() {
}
}
} else {
if (!decoderCreationCalled) {
decoderCreationCalled = true;
if (!THREE.DRACOLoader.decoderCreationCalled) {
THREE.DRACOLoader.decoderCreationCalled = true;
THREE.DRACOLoader.dracoDecoderType['onModuleLoaded'] =
function(module) {
decoder = module;
THREE.DRACOLoader.decoderModule = module;
};
DracoDecoderModule(THREE.DRACOLoader.dracoDecoderType);
}
}

// Either the DracoDecoderModule has not been defined or the decoder
// has not been created yet. Call getDecoder() again.
// has not been created yet. Call getDecoderModule() again.
setTimeout(function() {
THREE.DRACOLoader.getDecoder(dracoDecoder,
THREE.DRACOLoader.getDecoderModule(
onDracoDecoderModuleLoadedCallback);
}, 10);
}
};

})();

// Releases the DracoDecoderModule instance associated with the draco loader.
// The module will be automatically re-created the next time a new geometry is
// loaded by THREE.DRACOLoader.
THREE.DRACOLoader.releaseDecoderModule = function() {
THREE.DRACOLoader.decoderModule = undefined;
THREE.DRACOLoader.decoderCreationCalled = false;
if (THREE.DRACOLoader.dracoDecoderType !== undefined &&
THREE.DRACOLoader.dracoDecoderType.wasmBinary !== undefined) {
// For WASM build we need to preserve the wasmBinary for future use.
var wasmBinary = THREE.DRACOLoader.dracoDecoderType.wasmBinary;
THREE.DRACOLoader.dracoDecoderType = {};
THREE.DRACOLoader.dracoDecoderType.wasmBinary = wasmBinary;
} else {
THREE.DRACOLoader.dracoDecoderType = {};
}
}
Loading

0 comments on commit 5186ec2

Please sign in to comment.