浏览代码

- Use if instead of shortcircuiting operator
- Undo changes to duck

Steven Wittens 8 年之前
父节点
当前提交
01d5d9342e

+ 12 - 6
examples/js/loaders/GLTFLoader.js

@@ -1153,7 +1153,8 @@ THREE.GLTFLoader = ( function () {
 
 				var group = new THREE.Object3D();
 				group.name = mesh.name;
-				group.userData = mesh.extras || {};
+
+				if ( mesh.extras ) group.userData = mesh.extras;
 
 				var primitives = mesh.primitives;
 
@@ -1226,7 +1227,8 @@ THREE.GLTFLoader = ( function () {
 
 						var meshNode = new THREE.Mesh( geometry, material );
 						meshNode.castShadow = true;
-						meshNode.userData = primitive.extras || {};
+
+						if ( primitive.extras ) meshNode.userData = primitive.extras;
 
 						group.add( meshNode );
 
@@ -1268,7 +1270,8 @@ THREE.GLTFLoader = ( function () {
 
 				var _camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspect_ratio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6 );
 				_camera.name = camera.name;
-				_camera.userData = camera.extras || {};
+
+				if ( camera.extras ) _camera.userData = camera.extras;
 
 				return _camera;
 
@@ -1276,7 +1279,8 @@ THREE.GLTFLoader = ( function () {
 
 				var _camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, camera.orthographic.znear, camera.orthographic.zfar );
 				_camera.name = camera.name;
-				_camera.userData = camera.extras || {};
+
+				if ( camera.extras ) _camera.userData = camera.extras;
 
 				return _camera;
 
@@ -1393,7 +1397,8 @@ THREE.GLTFLoader = ( function () {
 			}
 
 			_node.name = node.name;
-			_node.userData = node.extras || {};
+
+			if ( node.extras ) _node.userData = node.extras;
 
 			_node.matrixAutoUpdate = false;
 
@@ -1674,7 +1679,8 @@ THREE.GLTFLoader = ( function () {
 
 				var _scene = new THREE.Scene();
 				_scene.name = scene.name;
-				_scene.userData = scene.extras || {};
+
+				if ( scene.extras ) _scene.userData = scene.extras;
 
 				var nodes = scene.nodes;
 

+ 6 - 24
examples/models/gltf/duck/glTF-MaterialsCommon/duck.gltf

@@ -177,15 +177,9 @@
                     },
                     "indices": "accessor_21",
                     "material": "blinn3-fx",
-                    "mode": 4,
-                    "extras": {
-                      "foo": "primitive"
-                    }
+                    "mode": 4
                 }
-            ],
-            "extras": {
-              "foo": "mesh"
-            }
+            ]
         }
     },
     "nodes": {
@@ -212,10 +206,7 @@
             "meshes": [
                 "LOD3spShape-lib"
             ],
-            "name": "LOD3sp",
-            "extras": {
-              "foo": "node"
-            }
+            "name": "LOD3sp"
         },
         "camera1": {
             "camera": "cameraShape1",
@@ -238,10 +229,7 @@
                 -4.31078,
                 1
             ],
-            "name": "camera1",
-            "extras": {
-              "foo": "camera"
-            }
+            "name": "camera1"
         },
         "directionalLight1": {
             "children": [],
@@ -268,10 +256,7 @@
                 -2.92179,
                 1
             ],
-            "name": "directionalLight1",
-            "extras": {
-              "foo": "light"
-            }
+            "name": "directionalLight1"
         }
     },
     "samplers": {
@@ -289,10 +274,7 @@
                 "LOD3sp",
                 "camera1",
                 "directionalLight1"
-            ],
-            "extras": {
-              "foo": "scene"
-            }
+            ]
         }
     },
     "skins": {},

+ 6 - 24
examples/models/gltf/duck/glTF/duck.gltf

@@ -150,15 +150,9 @@
                     },
                     "indices": "accessor_21",
                     "material": "blinn3-fx",
-                    "mode": 4,
-                    "extras": {
-                      "foo": "primitive"
-                    }
+                    "mode": 4
                 }
-            ],
-            "extras": {
-              "foo": "mesh"
-            }
+            ]
         }
     },
     "nodes": {
@@ -185,10 +179,7 @@
             "meshes": [
                 "LOD3spShape-lib"
             ],
-            "name": "LOD3sp",
-            "extras": {
-              "foo": "node"
-            }
+            "name": "LOD3sp"
         },
         "camera1": {
             "camera": "cameraShape1",
@@ -211,10 +202,7 @@
                 -4.31078,
                 1
             ],
-            "name": "camera1",
-            "extras": {
-              "foo": "camera"
-            }
+            "name": "camera1"
         },
         "directionalLight1": {
             "children": [],
@@ -236,10 +224,7 @@
                 -2.92179,
                 1
             ],
-            "name": "directionalLight1",
-            "extras": {
-              "foo": "light"
-            }
+            "name": "directionalLight1"
         }
     },
     "programs": {
@@ -268,10 +253,7 @@
                 "LOD3sp",
                 "camera1",
                 "directionalLight1"
-            ],
-            "extras": {
-              "foo": "scene"
-            }
+            ]
         }
     },
     "shaders": {