@@ -8579,6 +8579,7 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
8579
8579
8580
8580
scene: new THREE.Scene(),
8581
8581
geometries: {},
8582
+ face_materials: {},
8582
8583
materials: {},
8583
8584
textures: {},
8584
8585
objects: {},
@@ -8726,9 +8727,22 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
8726
8727
8727
8728
q = 0;
8728
8729
8730
+ // use materials from the model file
8731
+ // if there is no material specified in the object
8732
+
8729
8733
if ( ! o.material ) {
8730
8734
8731
- material = new THREE.MeshFaceMaterial();
8735
+ material = new THREE.MeshFaceMaterial( result.face_materials[ o.geometry ] );
8736
+
8737
+ }
8738
+
8739
+ // use materials from the model file
8740
+ // if there is just empty face material
8741
+ // (must create new material as each model has its own face material)
8742
+
8743
+ if ( ( material instanceof THREE.MeshFaceMaterial ) && material.materials.length === 0 ) {
8744
+
8745
+ material = new THREE.MeshFaceMaterial( result.face_materials[ o.geometry ] );
8732
8746
8733
8747
}
8734
8748
@@ -8943,9 +8957,10 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
8943
8957
8944
8958
};
8945
8959
8946
- function handle_mesh( geo, id ) {
8960
+ function handle_mesh( geo, mat, id ) {
8947
8961
8948
8962
result.geometries[ id ] = geo;
8963
+ result.face_materials[ id ] = mat;
8949
8964
handle_objects();
8950
8965
8951
8966
};
@@ -8991,9 +9006,9 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
8991
9006
8992
9007
function create_callback_geometry( id ) {
8993
9008
8994
- return function( geo ) {
9009
+ return function( geo, mat ) {
8995
9010
8996
- handle_mesh( geo, id );
9011
+ handle_mesh( geo, mat, id );
8997
9012
8998
9013
counter_models -= 1;
8999
9014
@@ -9046,9 +9061,10 @@ THREE.SceneLoader.prototype.parse = function ( json, callbackFinished, url ) {
9046
9061
9047
9062
function create_callback_embed( id ) {
9048
9063
9049
- return function( geo ) {
9064
+ return function( geo, mat ) {
9050
9065
9051
9066
result.geometries[ id ] = geo;
9067
+ result.face_materials[ id ] = mat;
9052
9068
9053
9069
}
9054
9070
0 commit comments