sebavan 6 년 전
부모
커밋
18aca41eac
39개의 변경된 파일58379개의 추가작업 그리고 5384개의 파일을 삭제
  1. 51684 0
      Playground/babylon.d.txt
  2. 5258 5237
      dist/preview release/babylon.d.ts
  3. 1 1
      dist/preview release/babylon.js
  4. 85 15
      dist/preview release/babylon.max.js
  5. 1 1
      dist/preview release/glTF2Interface/package.json
  6. 1 1
      dist/preview release/gui/babylon.gui.js
  7. 1 1
      dist/preview release/gui/babylon.gui.min.js
  8. 2 2
      dist/preview release/gui/package.json
  9. 8 8
      dist/preview release/inspector/babylon.inspector.bundle.js
  10. 1 1
      dist/preview release/inspector/babylon.inspector.d.ts
  11. 2 2
      dist/preview release/inspector/babylon.inspector.module.d.ts
  12. 6 6
      dist/preview release/inspector/package.json
  13. 1 1
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  14. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  15. 1 1
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  16. 85 32
      dist/preview release/loaders/babylon.objFileLoader.js
  17. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  18. 16 4
      dist/preview release/loaders/babylonjs.loaders.d.ts
  19. 85 32
      dist/preview release/loaders/babylonjs.loaders.js
  20. 1 1
      dist/preview release/loaders/babylonjs.loaders.min.js
  21. 16 4
      dist/preview release/loaders/babylonjs.loaders.module.d.ts
  22. 3 3
      dist/preview release/loaders/package.json
  23. 2 2
      dist/preview release/materialsLibrary/package.json
  24. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  25. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  26. 1 1
      dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js
  27. 2 2
      dist/preview release/postProcessesLibrary/package.json
  28. 2 2
      dist/preview release/proceduralTexturesLibrary/package.json
  29. 1 1
      dist/preview release/serializers/babylon.glTF2Serializer.min.js
  30. 1 1
      dist/preview release/serializers/babylonjs.serializers.min.js
  31. 3 3
      dist/preview release/serializers/package.json
  32. 2 2
      dist/preview release/viewer/babylon.viewer.d.ts
  33. 3 3
      dist/preview release/viewer/babylon.viewer.js
  34. 6 6
      dist/preview release/viewer/babylon.viewer.max.js
  35. 2 2
      dist/preview release/viewer/babylon.viewer.module.d.ts
  36. 1087 0
      gui/src/2D/controls/colorpicker.ts
  37. 1 1
      package.json
  38. 3 0
      readme.md
  39. 1 1
      src/Engines/engine.ts

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 51684 - 0
Playground/babylon.d.txt


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 5258 - 5237
dist/preview release/babylon.d.ts


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/babylon.js


+ 85 - 15
dist/preview release/babylon.max.js

@@ -5414,6 +5414,27 @@ var BABYLON;
             }
             return this;
         };
+        /**
+         * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
+         * Check if is non uniform within a certain amount of decimal places to account for this
+         * @param epsilon the amount the values can differ
+         * @returns if the the vector is non uniform to a certain number of decimal places
+         */
+        Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
+            var absX = Math.abs(this.x);
+            var absY = Math.abs(this.y);
+            if (!BABYLON.Scalar.WithinEpsilon(absX, absY, epsilon)) {
+                return true;
+            }
+            var absZ = Math.abs(this.z);
+            if (!BABYLON.Scalar.WithinEpsilon(absX, absZ, epsilon)) {
+                return true;
+            }
+            if (!BABYLON.Scalar.WithinEpsilon(absY, absZ, epsilon)) {
+                return true;
+            }
+            return false;
+        };
         Object.defineProperty(Vector3.prototype, "isNonUniform", {
             /**
              * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
@@ -12988,7 +13009,7 @@ var BABYLON;
              * Returns the current version of the framework
              */
             get: function () {
-                return "4.0.0-alpha.16";
+                return "4.0.0-alpha.17";
             },
             enumerable: true,
             configurable: true
@@ -20304,7 +20325,7 @@ var BABYLON;
         });
         Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
             /**
-             * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (null by default).
+             * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
              * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
              */
             get: function () {
@@ -28122,6 +28143,13 @@ var BABYLON;
                 group.stop();
             }
         };
+        /**
+         * Resets the last animation time frame.
+         * Useful to override when animations start running when loading a scene for the first time.
+         */
+        Scene.prototype.resetLastAnimationTimeFrame = function () {
+            this._animationTimeLast = BABYLON.Tools.Now;
+        };
         Scene.prototype._animate = function () {
             if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
                 return;
@@ -52036,7 +52064,7 @@ var BABYLON;
              * Maximum allowed angle on the latitudinal axis.
              * This can help limiting how the Camera is able to move in the scene.
              */
-            _this.upperBetaLimit = Math.PI;
+            _this.upperBetaLimit = Math.PI - 0.01;
             /**
              * Minimum allowed distance of the camera to the target (The camera can not get closer).
              * This can help limiting how the Camera is able to move in the scene.
@@ -99718,7 +99746,7 @@ var BABYLON;
                 case BABYLON.PhysicsJoint.PointToPointJoint:
                 case BABYLON.PhysicsJoint.BallAndSocketJoint:
                 default:
-                    constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotA, constraintData.maxForce);
+                    constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
                     break;
             }
             //set the collideConnected flag after the creation, since DistanceJoint ignores it.
@@ -100344,9 +100372,10 @@ var BABYLON;
                 if (impostor.type == BABYLON.PhysicsImpostor.NoImpostor && !colShape.getChildShape) {
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
                 }
-                body.setRestitution(impostor.getParam("restitution"));
                 this.world.addRigidBody(body);
                 impostor.physicsBody = body;
+                this.setBodyRestitution(impostor, impostor.getParam("restitution"));
+                this.setBodyFriction(impostor, impostor.getParam("friction"));
                 impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
             }
         };
@@ -100409,7 +100438,7 @@ var BABYLON;
                     joint = new Ammo.btPoint2PointConstraint(mainBody, connectedBody, new Ammo.btVector3(jointData.mainPivot.x, jointData.mainPivot.y, jointData.mainPivot.z), new Ammo.btVector3(jointData.connectedPivot.x, jointData.connectedPivot.y, jointData.connectedPivot.z));
                     break;
             }
-            this.world.addConstraint(joint, true);
+            this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
             impostorJoint.joint.physicsJoint = joint;
         };
         /**
@@ -100666,7 +100695,7 @@ var BABYLON;
          * @returns friction value
          */
         AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
-            return impostor.physicsBody.getFriction();
+            return impostor._pluginData.friction;
         };
         /**
          * Sets friction of the impostor
@@ -100675,6 +100704,7 @@ var BABYLON;
          */
         AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
             impostor.physicsBody.setFriction(friction);
+            impostor._pluginData.friction = friction;
         };
         /**
          * Gets restitution of the impostor
@@ -100682,7 +100712,7 @@ var BABYLON;
          * @returns restitution value
          */
         AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
-            return impostor.physicsBody.getRestitution();
+            return impostor._pluginData.restitution;
         };
         /**
          * Sets resitution of the impostor
@@ -100691,6 +100721,7 @@ var BABYLON;
          */
         AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
             impostor.physicsBody.setRestitution(restitution);
+            impostor._pluginData.restitution = restitution;
         };
         /**
          * Sleeps the physics body and stops it from being active
@@ -104099,11 +104130,14 @@ var BABYLON;
                         tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
                         // Slowly move mesh to avoid jitter
                         var oldParent = pickedMesh.parent;
-                        pickedMesh.setParent(null);
-                        BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
-                        pickedMesh.setParent(oldParent);
-                        BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
+                        // Only rotate the mesh if it's parent has uniform scaling
+                        if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
+                            pickedMesh.setParent(null);
+                            BABYLON.Quaternion.SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
+                            pickedMesh.setParent(oldParent);
+                        }
                     }
+                    BABYLON.BoundingBoxGizmo._RestorePivotPoint(pickedMesh);
                 }
             });
         };
@@ -104761,7 +104795,10 @@ var BABYLON;
                     else {
                         currentSnapDragDistance += event.dragDistance;
                         if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
-                            dragSteps = Math.floor(currentSnapDragDistance / _this.snapDistance);
+                            dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
+                            if (currentSnapDragDistance < 0) {
+                                dragSteps *= -1;
+                            }
                             currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
                             tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
                             snapped = true;
@@ -104942,7 +104979,10 @@ var BABYLON;
                     if (_this.snapDistance != 0) {
                         currentSnapDragDistance += angle;
                         if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
-                            var dragSteps = Math.floor(currentSnapDragDistance / _this.snapDistance);
+                            var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
+                            if (currentSnapDragDistance < 0) {
+                                dragSteps *= -1;
+                            }
                             currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
                             angle = _this.snapDistance * dragSteps;
                             snapped = true;
@@ -105511,6 +105551,11 @@ var BABYLON;
                 _dragBehavior.onDragObservable.add(function (event) {
                     _this.onRotationSphereDragObservable.notifyObservers({});
                     if (_this.attachedMesh) {
+                        var originalParent = _this.attachedMesh.parent;
+                        if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
+                            BABYLON.Tools.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
+                            return;
+                        }
                         BoundingBoxGizmo._RemoveAndStorePivotPoint(_this.attachedMesh);
                         var worldDragDirection = startingTurnDirection;
                         // Project the world right on to the drag plane
@@ -105543,6 +105588,7 @@ var BABYLON;
                             _this._anchorMesh.addChild(_this.attachedMesh);
                             _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
                             _this._anchorMesh.removeChild(_this.attachedMesh);
+                            _this.attachedMesh.setParent(originalParent);
                         }
                         _this.updateBoundingBox();
                         BoundingBoxGizmo._RestorePivotPoint(_this.attachedMesh);
@@ -105582,6 +105628,11 @@ var BABYLON;
                         _dragBehavior.onDragObservable.add(function (event) {
                             _this.onScaleBoxDragObservable.notifyObservers({});
                             if (_this.attachedMesh) {
+                                var originalParent = _this.attachedMesh.parent;
+                                if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
+                                    BABYLON.Tools.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
+                                    return;
+                                }
                                 BoundingBoxGizmo._RemoveAndStorePivotPoint(_this.attachedMesh);
                                 var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
                                 var deltaScale = new BABYLON.Vector3(relativeDragDistance, relativeDragDistance, relativeDragDistance);
@@ -105608,6 +105659,7 @@ var BABYLON;
                                     _this._anchorMesh.scaling.subtractInPlace(deltaScale);
                                 }
                                 _this._anchorMesh.removeChild(_this.attachedMesh);
+                                _this.attachedMesh.setParent(originalParent);
                                 BoundingBoxGizmo._RestorePivotPoint(_this.attachedMesh);
                             }
                             _this._updateDummy();
@@ -105701,10 +105753,15 @@ var BABYLON;
                 // Reset anchor mesh to match attached mesh's scale
                 // This is needed to avoid invalid box/sphere position on first drag
                 BoundingBoxGizmo._RemoveAndStorePivotPoint(value);
+                var originalParent = value.parent;
                 this._anchorMesh.addChild(value);
                 this._anchorMesh.removeChild(value);
+                value.setParent(originalParent);
                 BoundingBoxGizmo._RestorePivotPoint(value);
                 this.updateBoundingBox();
+                value.getChildMeshes(false).forEach(function (m) {
+                    m.markAsDirty("scaling");
+                });
                 this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
                     _this._updateDummy();
                 });
@@ -105722,6 +105779,8 @@ var BABYLON;
         BoundingBoxGizmo.prototype.updateBoundingBox = function () {
             if (this.attachedMesh) {
                 BoundingBoxGizmo._RemoveAndStorePivotPoint(this.attachedMesh);
+                var originalParent = this.attachedMesh.parent;
+                this.attachedMesh.setParent(null);
                 this._update();
                 // Rotate based on axis
                 if (!this.attachedMesh.rotationQuaternion) {
@@ -105749,6 +105808,7 @@ var BABYLON;
                 // restore position/rotation values
                 this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
                 this.attachedMesh.position.copyFrom(this._tmpVector);
+                this.attachedMesh.setParent(originalParent);
             }
             this._updateRotationSpheres();
             this._updateScaleBoxes();
@@ -105829,6 +105889,15 @@ var BABYLON;
                 }
             });
         };
+        /**
+         * Enables/disables scaling
+         * @param enable if scaling should be enabled
+         */
+        BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
+            this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
+                m.setEnabled(enable);
+            });
+        };
         BoundingBoxGizmo.prototype._updateDummy = function () {
             if (this._dragMesh) {
                 this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
@@ -115919,10 +115988,11 @@ var BABYLON;
          */
         MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
             var _this = this;
-            BABYLON.SceneLoader.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons) {
+            BABYLON.SceneLoader.ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
                 _this.loadedMeshes = meshes;
                 _this.loadedParticleSystems = particleSystems;
                 _this.loadedSkeletons = skeletons;
+                _this.loadedAnimationGroups = animationGroups;
                 onSuccess();
             }, null, function (scene, message, exception) {
                 onError(message, exception);

+ 1 - 1
dist/preview release/glTF2Interface/package.json

@@ -1,7 +1,7 @@
 {
     "name": "babylonjs-gltf2interface",
     "description": "A typescript declaration of babylon's gltf2 inteface.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/gui/babylon.gui.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/gui/babylon.gui.min.js


+ 2 - 2
dist/preview release/gui/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-gui",
     "description": "The Babylon.js GUI library is an extension you can use to generate interactive user interface. It is build on top of the DynamicTexture.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 8 - 8
dist/preview release/inspector/babylon.inspector.bundle.js


+ 1 - 1
dist/preview release/inspector/babylon.inspector.d.ts

@@ -1,6 +1,6 @@
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 declare module INSPECTOR {
 }
 declare module INSPECTOR {

+ 2 - 2
dist/preview release/inspector/babylon.inspector.module.d.ts

@@ -1,6 +1,6 @@
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 
 declare module 'babylonjs-inspector' {
     export * from "babylonjs-inspector/inspector";
@@ -31,7 +31,7 @@ declare module 'babylonjs-inspector/components/propertyChangedEvent' {
 
 /*Babylon.js Inspector*/
 // Dependencies for this module:
-//   ../../../../Tools/Gulp/babylonjs
+//   ../../../../tools/gulp/babylonjs
 declare module INSPECTOR {
 }
 declare module INSPECTOR {

+ 6 - 6
dist/preview release/inspector/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-inspector",
     "description": "The Babylon.js inspector.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -31,11 +31,11 @@
     "dependencies": {
         "@types/react": "~16.7.3",
         "@types/react-dom": "~16.0.9",
-        "babylonjs": "4.0.0-alpha.16",
-        "babylonjs-gui": "4.0.0-alpha.16",
-        "babylonjs-loaders": "4.0.0-alpha.16",
-        "babylonjs-serializers": "4.0.0-alpha.16",
-        "babylonjs-gltf2interface": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17",
+        "babylonjs-gui": "4.0.0-alpha.17",
+        "babylonjs-loaders": "4.0.0-alpha.17",
+        "babylonjs-serializers": "4.0.0-alpha.17",
+        "babylonjs-gltf2interface": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 85 - 32
dist/preview release/loaders/babylon.objFileLoader.js

@@ -218,7 +218,7 @@ var BABYLON;
             this.mtllib = /^mtllib /;
             this.usemtl = /^usemtl /;
             this.smooth = /^s /;
-            this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
+            this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+){3,7}/;
             // vn float float float
             this.normalPattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
             // vt float float
@@ -252,10 +252,10 @@ var BABYLON;
             BABYLON.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function () { console.warn("Error - Unable to load " + pathOfFile); });
         };
         /**
-         * Imports one or more meshes from the loaded glTF data and adds them to the scene
+         * Imports one or more meshes from the loaded OBJ data and adds them to the scene
          * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
          * @param scene the scene the meshes should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -273,9 +273,10 @@ var BABYLON;
             });
         };
         /**
-         * Imports all objects from the loaded glTF data and adds them to the scene
+         * Imports all objects from the loaded OBJ data and adds them to the scene
+         *
          * @param scene the scene the objects should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -321,16 +322,19 @@ var BABYLON;
             var positions = []; //values for the positions of vertices
             var normals = []; //Values for the normals
             var uvs = []; //Values for the textures
+            var colors = [];
             var meshesFromObj = []; //[mesh] Contains all the obj meshes
             var handledMesh; //The current mesh of meshes array
             var indicesForBabylon = []; //The list of indices for VertexData
             var wrappedPositionForBabylon = []; //The list of position in vectors
+            var wrappedColorsForBabylon = []; // Array with all color values to match with the indices
             var wrappedUvsForBabylon = []; //Array with all value of uvs to match with the indices
             var wrappedNormalsForBabylon = []; //Array with all value of normals to match with the indices
             var tuplePosNorm = []; //Create a tuple with indice of Position, Normal, UV  [pos, norm, uvs]
             var curPositionInIndices = 0;
             var hasMeshes = false; //Meshes are defined in the file
             var unwrappedPositionsForBabylon = []; //Value of positionForBabylon w/o Vector3() [x,y,z]
+            var unwrappedColorsForBabylon = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]
             var unwrappedNormalsForBabylon = []; //Value of normalsForBabylon w/o Vector3()  [x,y,z]
             var unwrappedUVForBabylon = []; //Value of uvsForBabylon w/o Vector3()      [x,y,z]
             var triangles = []; //Indices from new triangles coming from polygons
@@ -340,11 +344,12 @@ var BABYLON;
             var objMeshName = ""; //The name of the current obj mesh
             var increment = 1; //Id for meshes created by the multimaterial
             var isFirstMaterial = true;
+            var grayColor = new BABYLON.Color4(0.5, 0.5, 0.5, 1);
             /**
              * Search for obj in the given array.
              * This function is called to check if a couple of data already exists in an array.
              *
-             * If found, returns the index of the founded tuple index. Returns -1 if not found
+             * If found, returns the index of the found tuple index. Returns -1 if not found
              * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
              * @param obj Array<number>
              * @returns {boolean}
@@ -379,7 +384,7 @@ var BABYLON;
              * @param textureVectorFromOBJ Vector3 The value of uvs
              * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
              */
-            var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ) {
+            var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ, positionColorsFromOBJ) {
                 //Check if this tuple already exists in the list of tuples
                 var _index;
                 if (OBJFileLoader.OPTIMIZE_WITH_UV) {
@@ -410,6 +415,11 @@ var BABYLON;
                     //Push the normals for Babylon
                     //Each element is a BABYLON.Vector3(x,y,z)
                     wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
+                    if (positionColorsFromOBJ !== undefined) {
+                        //Push the colors for Babylon
+                        //Each element is a BABYLON.Color4(r,g,b,a)
+                        wrappedColorsForBabylon.push(positionColorsFromOBJ);
+                    }
                     //Add the tuple in the comparison list
                     tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
                     tuplePosNorm[indicePositionFromObj].idx.push(curPositionInIndices++);
@@ -420,12 +430,12 @@ var BABYLON;
                 else {
                     //The tuple already exists
                     //Add the index of the already existing tuple
-                    //At this index we can get the value of position, normal and uvs of vertex
+                    //At this index we can get the value of position, normal, color and uvs of vertex
                     indicesForBabylon.push(_index);
                 }
             };
             /**
-             * Transform BABYLON.Vector() object onto 3 digits in an array
+             * Transform BABYLON.Vector() and BABYLON.Color() objects into numbers in an array
              */
             var unwrapData = function () {
                 //Every array has the same length
@@ -434,11 +444,16 @@ var BABYLON;
                     unwrappedPositionsForBabylon.push(wrappedPositionForBabylon[l].x, wrappedPositionForBabylon[l].y, wrappedPositionForBabylon[l].z);
                     unwrappedNormalsForBabylon.push(wrappedNormalsForBabylon[l].x, wrappedNormalsForBabylon[l].y, wrappedNormalsForBabylon[l].z);
                     unwrappedUVForBabylon.push(wrappedUvsForBabylon[l].x, wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        //Push the r, g, b, a values of each element in the unwrapped array
+                        unwrappedColorsForBabylon.push(wrappedColorsForBabylon[l].r, wrappedColorsForBabylon[l].g, wrappedColorsForBabylon[l].b, wrappedColorsForBabylon[l].a);
+                    }
                 }
                 // Reset arrays for the next new meshes
                 wrappedPositionForBabylon = [];
                 wrappedNormalsForBabylon = [];
                 wrappedUvsForBabylon = [];
+                wrappedColorsForBabylon = [];
                 tuplePosNorm = [];
                 curPositionInIndices = 0;
             };
@@ -489,8 +504,8 @@ var BABYLON;
                     var indicePositionFromObj = parseInt(triangles[k]) - 1;
                     setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
                     positions[indicePositionFromObj], //Get the vectors data
-                    BABYLON.Vector2.Zero(), BABYLON.Vector3.Up() //Create default vectors
-                    );
+                    BABYLON.Vector2.Zero(), BABYLON.Vector3.Up(), //Create default vectors
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -514,8 +529,8 @@ var BABYLON;
                     var indiceUvsFromObj = parseInt(point[1]) - 1;
                     setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
                     positions[indicePositionFromObj], //Get the values for each element
-                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
-                    );
+                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up(), //Default value for normals
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -539,8 +554,8 @@ var BABYLON;
                     var indiceUvsFromObj = parseInt(point[1]) - 1;
                     // Set normal indice
                     var indiceNormalFromObj = parseInt(point[2]) - 1;
-                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
-                    );
+                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj], //Set the vector for each component
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -562,7 +577,7 @@ var BABYLON;
                     var indiceNormalFromObj = parseInt(point[1]) - 1;
                     setData(indicePositionFromObj, 1, //Default value for uv
                     indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
-                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
+                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj], OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -586,8 +601,8 @@ var BABYLON;
                     var indiceUvsFromObj = uvs.length + parseInt(point[1]);
                     // Set normal indice
                     var indiceNormalFromObj = normals.length + parseInt(point[2]);
-                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
-                    );
+                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj], //Set the vector for each component
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -608,9 +623,13 @@ var BABYLON;
                     handledMesh.positions = unwrappedPositionsForBabylon.slice();
                     handledMesh.normals = unwrappedNormalsForBabylon.slice();
                     handledMesh.uvs = unwrappedUVForBabylon.slice();
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        handledMesh.colors = unwrappedColorsForBabylon.slice();
+                    }
                     //Reset the array for the next mesh
                     indicesForBabylon = [];
                     unwrappedPositionsForBabylon = [];
+                    unwrappedColorsForBabylon = [];
                     unwrappedNormalsForBabylon = [];
                     unwrappedUVForBabylon = [];
                 }
@@ -627,12 +646,23 @@ var BABYLON;
                     continue;
                     //Get information about one position possible for the vertices
                 }
-                else if ((result = this.vertexPattern.exec(line)) !== null) {
+                else if (this.vertexPattern.test(line)) {
+                    result = line.split(' ');
+                    //Value of result with line: "v 1.0 2.0 3.0"
+                    // ["v", "1.0", "2.0", "3.0"]
                     //Create a Vector3 with the position x, y, z
-                    //Value of result:
-                    // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
                     //Add the Vector in the list of positions
                     positions.push(new BABYLON.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        if (result.length >= 7) {
+                            // TODO: if these numbers are > 1 we can use Color4.FromInts(r,g,b,a)
+                            colors.push(new BABYLON.Color4(parseFloat(result[4]), parseFloat(result[5]), parseFloat(result[6]), (result.length === 7 || result[7] === undefined) ? 1 : parseFloat(result[7])));
+                        }
+                        else {
+                            // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).
+                            colors.push(grayColor);
+                        }
+                    }
                 }
                 else if ((result = this.normalPattern.exec(line)) !== null) {
                     //Create a Vector3 with the normals x, y, z
@@ -690,13 +720,12 @@ var BABYLON;
                 else if (this.group.test(line) || this.obj.test(line)) {
                     //Create a new mesh corresponding to the name of the group.
                     //Definition of the mesh
-                    var objMesh = 
-                    //Set the name of the current obj mesh
-                    {
+                    var objMesh = {
                         name: line.substring(2).trim(),
                         indices: undefined,
                         positions: undefined,
                         normals: undefined,
+                        colors: undefined,
                         uvs: undefined,
                         materialName: ""
                     };
@@ -717,13 +746,12 @@ var BABYLON;
                         //Set the data for the previous mesh
                         addPreviousObjMesh();
                         //Create a new mesh
-                        var objMesh = 
-                        //Set the name of the current obj mesh
-                        {
+                        var objMesh = {
                             name: objMeshName + "_mm" + increment.toString(),
                             indices: undefined,
                             positions: undefined,
                             normals: undefined,
+                            colors: undefined,
                             uvs: undefined,
                             materialName: materialNameFromObj
                         };
@@ -758,7 +786,7 @@ var BABYLON;
             if (hasMeshes) {
                 //Set the data for the last mesh
                 handledMesh = meshesFromObj[meshesFromObj.length - 1];
-                //Reverse indices for displaying faces in the good sens
+                //Reverse indices for displaying faces in the good sense
                 indicesForBabylon.reverse();
                 //Get the good array
                 unwrapData();
@@ -767,8 +795,11 @@ var BABYLON;
                 handledMesh.positions = unwrappedPositionsForBabylon;
                 handledMesh.normals = unwrappedNormalsForBabylon;
                 handledMesh.uvs = unwrappedUVForBabylon;
+                if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                    handledMesh.colors = unwrappedColorsForBabylon;
+                }
             }
-            //If any o or g keyword found, create a mesj with a random id
+            //If any o or g keyword found, create a mesh with a random id
             if (!hasMeshes) {
                 // reverse tab of indices
                 indicesForBabylon.reverse();
@@ -779,6 +810,7 @@ var BABYLON;
                     name: BABYLON.Geometry.RandomId(),
                     indices: indicesForBabylon,
                     positions: unwrappedPositionsForBabylon,
+                    colors: unwrappedColorsForBabylon,
                     normals: unwrappedNormalsForBabylon,
                     uvs: unwrappedUVForBabylon,
                     materialName: materialNameFromObj
@@ -811,11 +843,21 @@ var BABYLON;
                 //This is indispensable for the importMesh function
                 materialToUse.push(meshesFromObj[j].materialName);
                 var vertexData = new BABYLON.VertexData(); //The container for the values
-                //Set the data for the babylonMesh
-                vertexData.positions = handledMesh.positions;
-                vertexData.normals = handledMesh.normals;
+                //Set the vertex data for the babylonMesh
                 vertexData.uvs = handledMesh.uvs;
                 vertexData.indices = handledMesh.indices;
+                vertexData.positions = handledMesh.positions;
+                if (OBJFileLoader.COMPUTE_NORMALS === true) {
+                    var normals_1 = new Array();
+                    BABYLON.VertexData.ComputeNormals(handledMesh.positions, handledMesh.indices, normals_1);
+                    vertexData.normals = normals_1;
+                }
+                else {
+                    vertexData.normals = handledMesh.normals;
+                }
+                if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                    vertexData.colors = handledMesh.colors;
+                }
                 //Set the data from the VertexBuffer to the current BABYLON.Mesh
                 vertexData.applyToMesh(babylonMesh);
                 if (OBJFileLoader.INVERT_Y) {
@@ -873,7 +915,18 @@ var BABYLON;
             });
         };
         OBJFileLoader.OPTIMIZE_WITH_UV = false;
+        /**
+         * Invert model on y-axis (does a model scaling inversion)
+         */
         OBJFileLoader.INVERT_Y = false;
+        /**
+         * Include in meshes the vertex colors available in some OBJ files.  This is not part of OBJ standard.
+         */
+        OBJFileLoader.IMPORT_VERTEX_COLORS = false;
+        /**
+         * Compute the normals for the model, even if normals are present in the file
+         */
+        OBJFileLoader.COMPUTE_NORMALS = false;
         return OBJFileLoader;
     }());
     BABYLON.OBJFileLoader = OBJFileLoader;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 16 - 4
dist/preview release/loaders/babylonjs.loaders.d.ts

@@ -48,7 +48,18 @@ declare module BABYLON {
     }
     class OBJFileLoader implements ISceneLoaderPluginAsync {
         static OPTIMIZE_WITH_UV: boolean;
+        /**
+         * Invert model on y-axis (does a model scaling inversion)
+         */
         static INVERT_Y: boolean;
+        /**
+         * Include in meshes the vertex colors available in some OBJ files.  This is not part of OBJ standard.
+         */
+        static IMPORT_VERTEX_COLORS: boolean;
+        /**
+         * Compute the normals for the model, even if normals are present in the file
+         */
+        static COMPUTE_NORMALS: boolean;
         name: string;
         extensions: string;
         obj: RegExp;
@@ -77,10 +88,10 @@ declare module BABYLON {
          */
         private _loadMTL;
         /**
-         * Imports one or more meshes from the loaded glTF data and adds them to the scene
+         * Imports one or more meshes from the loaded OBJ data and adds them to the scene
          * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
          * @param scene the scene the meshes should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -93,9 +104,10 @@ declare module BABYLON {
             animationGroups: AnimationGroup[];
         }>;
         /**
-         * Imports all objects from the loaded glTF data and adds them to the scene
+         * Imports all objects from the loaded OBJ data and adds them to the scene
+         *
          * @param scene the scene the objects should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load

+ 85 - 32
dist/preview release/loaders/babylonjs.loaders.js

@@ -417,7 +417,7 @@ var BABYLON;
             this.mtllib = /^mtllib /;
             this.usemtl = /^usemtl /;
             this.smooth = /^s /;
-            this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
+            this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+){3,7}/;
             // vn float float float
             this.normalPattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
             // vt float float
@@ -451,10 +451,10 @@ var BABYLON;
             BABYLON.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function () { console.warn("Error - Unable to load " + pathOfFile); });
         };
         /**
-         * Imports one or more meshes from the loaded glTF data and adds them to the scene
+         * Imports one or more meshes from the loaded OBJ data and adds them to the scene
          * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
          * @param scene the scene the meshes should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -472,9 +472,10 @@ var BABYLON;
             });
         };
         /**
-         * Imports all objects from the loaded glTF data and adds them to the scene
+         * Imports all objects from the loaded OBJ data and adds them to the scene
+         *
          * @param scene the scene the objects should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -520,16 +521,19 @@ var BABYLON;
             var positions = []; //values for the positions of vertices
             var normals = []; //Values for the normals
             var uvs = []; //Values for the textures
+            var colors = [];
             var meshesFromObj = []; //[mesh] Contains all the obj meshes
             var handledMesh; //The current mesh of meshes array
             var indicesForBabylon = []; //The list of indices for VertexData
             var wrappedPositionForBabylon = []; //The list of position in vectors
+            var wrappedColorsForBabylon = []; // Array with all color values to match with the indices
             var wrappedUvsForBabylon = []; //Array with all value of uvs to match with the indices
             var wrappedNormalsForBabylon = []; //Array with all value of normals to match with the indices
             var tuplePosNorm = []; //Create a tuple with indice of Position, Normal, UV  [pos, norm, uvs]
             var curPositionInIndices = 0;
             var hasMeshes = false; //Meshes are defined in the file
             var unwrappedPositionsForBabylon = []; //Value of positionForBabylon w/o Vector3() [x,y,z]
+            var unwrappedColorsForBabylon = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]
             var unwrappedNormalsForBabylon = []; //Value of normalsForBabylon w/o Vector3()  [x,y,z]
             var unwrappedUVForBabylon = []; //Value of uvsForBabylon w/o Vector3()      [x,y,z]
             var triangles = []; //Indices from new triangles coming from polygons
@@ -539,11 +543,12 @@ var BABYLON;
             var objMeshName = ""; //The name of the current obj mesh
             var increment = 1; //Id for meshes created by the multimaterial
             var isFirstMaterial = true;
+            var grayColor = new BABYLON.Color4(0.5, 0.5, 0.5, 1);
             /**
              * Search for obj in the given array.
              * This function is called to check if a couple of data already exists in an array.
              *
-             * If found, returns the index of the founded tuple index. Returns -1 if not found
+             * If found, returns the index of the found tuple index. Returns -1 if not found
              * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
              * @param obj Array<number>
              * @returns {boolean}
@@ -578,7 +583,7 @@ var BABYLON;
              * @param textureVectorFromOBJ Vector3 The value of uvs
              * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
              */
-            var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ) {
+            var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ, positionColorsFromOBJ) {
                 //Check if this tuple already exists in the list of tuples
                 var _index;
                 if (OBJFileLoader.OPTIMIZE_WITH_UV) {
@@ -609,6 +614,11 @@ var BABYLON;
                     //Push the normals for Babylon
                     //Each element is a BABYLON.Vector3(x,y,z)
                     wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
+                    if (positionColorsFromOBJ !== undefined) {
+                        //Push the colors for Babylon
+                        //Each element is a BABYLON.Color4(r,g,b,a)
+                        wrappedColorsForBabylon.push(positionColorsFromOBJ);
+                    }
                     //Add the tuple in the comparison list
                     tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
                     tuplePosNorm[indicePositionFromObj].idx.push(curPositionInIndices++);
@@ -619,12 +629,12 @@ var BABYLON;
                 else {
                     //The tuple already exists
                     //Add the index of the already existing tuple
-                    //At this index we can get the value of position, normal and uvs of vertex
+                    //At this index we can get the value of position, normal, color and uvs of vertex
                     indicesForBabylon.push(_index);
                 }
             };
             /**
-             * Transform BABYLON.Vector() object onto 3 digits in an array
+             * Transform BABYLON.Vector() and BABYLON.Color() objects into numbers in an array
              */
             var unwrapData = function () {
                 //Every array has the same length
@@ -633,11 +643,16 @@ var BABYLON;
                     unwrappedPositionsForBabylon.push(wrappedPositionForBabylon[l].x, wrappedPositionForBabylon[l].y, wrappedPositionForBabylon[l].z);
                     unwrappedNormalsForBabylon.push(wrappedNormalsForBabylon[l].x, wrappedNormalsForBabylon[l].y, wrappedNormalsForBabylon[l].z);
                     unwrappedUVForBabylon.push(wrappedUvsForBabylon[l].x, wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        //Push the r, g, b, a values of each element in the unwrapped array
+                        unwrappedColorsForBabylon.push(wrappedColorsForBabylon[l].r, wrappedColorsForBabylon[l].g, wrappedColorsForBabylon[l].b, wrappedColorsForBabylon[l].a);
+                    }
                 }
                 // Reset arrays for the next new meshes
                 wrappedPositionForBabylon = [];
                 wrappedNormalsForBabylon = [];
                 wrappedUvsForBabylon = [];
+                wrappedColorsForBabylon = [];
                 tuplePosNorm = [];
                 curPositionInIndices = 0;
             };
@@ -688,8 +703,8 @@ var BABYLON;
                     var indicePositionFromObj = parseInt(triangles[k]) - 1;
                     setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
                     positions[indicePositionFromObj], //Get the vectors data
-                    BABYLON.Vector2.Zero(), BABYLON.Vector3.Up() //Create default vectors
-                    );
+                    BABYLON.Vector2.Zero(), BABYLON.Vector3.Up(), //Create default vectors
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -713,8 +728,8 @@ var BABYLON;
                     var indiceUvsFromObj = parseInt(point[1]) - 1;
                     setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
                     positions[indicePositionFromObj], //Get the values for each element
-                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
-                    );
+                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up(), //Default value for normals
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -738,8 +753,8 @@ var BABYLON;
                     var indiceUvsFromObj = parseInt(point[1]) - 1;
                     // Set normal indice
                     var indiceNormalFromObj = parseInt(point[2]) - 1;
-                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
-                    );
+                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj], //Set the vector for each component
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -761,7 +776,7 @@ var BABYLON;
                     var indiceNormalFromObj = parseInt(point[1]) - 1;
                     setData(indicePositionFromObj, 1, //Default value for uv
                     indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
-                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
+                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj], OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -785,8 +800,8 @@ var BABYLON;
                     var indiceUvsFromObj = uvs.length + parseInt(point[1]);
                     // Set normal indice
                     var indiceNormalFromObj = normals.length + parseInt(point[2]);
-                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
-                    );
+                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj], //Set the vector for each component
+                    OBJFileLoader.IMPORT_VERTEX_COLORS === true ? colors[indicePositionFromObj] : undefined);
                 }
                 //Reset variable for the next line
                 triangles = [];
@@ -807,9 +822,13 @@ var BABYLON;
                     handledMesh.positions = unwrappedPositionsForBabylon.slice();
                     handledMesh.normals = unwrappedNormalsForBabylon.slice();
                     handledMesh.uvs = unwrappedUVForBabylon.slice();
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        handledMesh.colors = unwrappedColorsForBabylon.slice();
+                    }
                     //Reset the array for the next mesh
                     indicesForBabylon = [];
                     unwrappedPositionsForBabylon = [];
+                    unwrappedColorsForBabylon = [];
                     unwrappedNormalsForBabylon = [];
                     unwrappedUVForBabylon = [];
                 }
@@ -826,12 +845,23 @@ var BABYLON;
                     continue;
                     //Get information about one position possible for the vertices
                 }
-                else if ((result = this.vertexPattern.exec(line)) !== null) {
+                else if (this.vertexPattern.test(line)) {
+                    result = line.split(' ');
+                    //Value of result with line: "v 1.0 2.0 3.0"
+                    // ["v", "1.0", "2.0", "3.0"]
                     //Create a Vector3 with the position x, y, z
-                    //Value of result:
-                    // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
                     //Add the Vector in the list of positions
                     positions.push(new BABYLON.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
+                    if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                        if (result.length >= 7) {
+                            // TODO: if these numbers are > 1 we can use Color4.FromInts(r,g,b,a)
+                            colors.push(new BABYLON.Color4(parseFloat(result[4]), parseFloat(result[5]), parseFloat(result[6]), (result.length === 7 || result[7] === undefined) ? 1 : parseFloat(result[7])));
+                        }
+                        else {
+                            // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).
+                            colors.push(grayColor);
+                        }
+                    }
                 }
                 else if ((result = this.normalPattern.exec(line)) !== null) {
                     //Create a Vector3 with the normals x, y, z
@@ -889,13 +919,12 @@ var BABYLON;
                 else if (this.group.test(line) || this.obj.test(line)) {
                     //Create a new mesh corresponding to the name of the group.
                     //Definition of the mesh
-                    var objMesh = 
-                    //Set the name of the current obj mesh
-                    {
+                    var objMesh = {
                         name: line.substring(2).trim(),
                         indices: undefined,
                         positions: undefined,
                         normals: undefined,
+                        colors: undefined,
                         uvs: undefined,
                         materialName: ""
                     };
@@ -916,13 +945,12 @@ var BABYLON;
                         //Set the data for the previous mesh
                         addPreviousObjMesh();
                         //Create a new mesh
-                        var objMesh = 
-                        //Set the name of the current obj mesh
-                        {
+                        var objMesh = {
                             name: objMeshName + "_mm" + increment.toString(),
                             indices: undefined,
                             positions: undefined,
                             normals: undefined,
+                            colors: undefined,
                             uvs: undefined,
                             materialName: materialNameFromObj
                         };
@@ -957,7 +985,7 @@ var BABYLON;
             if (hasMeshes) {
                 //Set the data for the last mesh
                 handledMesh = meshesFromObj[meshesFromObj.length - 1];
-                //Reverse indices for displaying faces in the good sens
+                //Reverse indices for displaying faces in the good sense
                 indicesForBabylon.reverse();
                 //Get the good array
                 unwrapData();
@@ -966,8 +994,11 @@ var BABYLON;
                 handledMesh.positions = unwrappedPositionsForBabylon;
                 handledMesh.normals = unwrappedNormalsForBabylon;
                 handledMesh.uvs = unwrappedUVForBabylon;
+                if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                    handledMesh.colors = unwrappedColorsForBabylon;
+                }
             }
-            //If any o or g keyword found, create a mesj with a random id
+            //If any o or g keyword found, create a mesh with a random id
             if (!hasMeshes) {
                 // reverse tab of indices
                 indicesForBabylon.reverse();
@@ -978,6 +1009,7 @@ var BABYLON;
                     name: BABYLON.Geometry.RandomId(),
                     indices: indicesForBabylon,
                     positions: unwrappedPositionsForBabylon,
+                    colors: unwrappedColorsForBabylon,
                     normals: unwrappedNormalsForBabylon,
                     uvs: unwrappedUVForBabylon,
                     materialName: materialNameFromObj
@@ -1010,11 +1042,21 @@ var BABYLON;
                 //This is indispensable for the importMesh function
                 materialToUse.push(meshesFromObj[j].materialName);
                 var vertexData = new BABYLON.VertexData(); //The container for the values
-                //Set the data for the babylonMesh
-                vertexData.positions = handledMesh.positions;
-                vertexData.normals = handledMesh.normals;
+                //Set the vertex data for the babylonMesh
                 vertexData.uvs = handledMesh.uvs;
                 vertexData.indices = handledMesh.indices;
+                vertexData.positions = handledMesh.positions;
+                if (OBJFileLoader.COMPUTE_NORMALS === true) {
+                    var normals_1 = new Array();
+                    BABYLON.VertexData.ComputeNormals(handledMesh.positions, handledMesh.indices, normals_1);
+                    vertexData.normals = normals_1;
+                }
+                else {
+                    vertexData.normals = handledMesh.normals;
+                }
+                if (OBJFileLoader.IMPORT_VERTEX_COLORS === true) {
+                    vertexData.colors = handledMesh.colors;
+                }
                 //Set the data from the VertexBuffer to the current BABYLON.Mesh
                 vertexData.applyToMesh(babylonMesh);
                 if (OBJFileLoader.INVERT_Y) {
@@ -1072,7 +1114,18 @@ var BABYLON;
             });
         };
         OBJFileLoader.OPTIMIZE_WITH_UV = false;
+        /**
+         * Invert model on y-axis (does a model scaling inversion)
+         */
         OBJFileLoader.INVERT_Y = false;
+        /**
+         * Include in meshes the vertex colors available in some OBJ files.  This is not part of OBJ standard.
+         */
+        OBJFileLoader.IMPORT_VERTEX_COLORS = false;
+        /**
+         * Compute the normals for the model, even if normals are present in the file
+         */
+        OBJFileLoader.COMPUTE_NORMALS = false;
         return OBJFileLoader;
     }());
     BABYLON.OBJFileLoader = OBJFileLoader;

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.min.js


+ 16 - 4
dist/preview release/loaders/babylonjs.loaders.module.d.ts

@@ -55,7 +55,18 @@ declare module BABYLON {
     }
     class OBJFileLoader implements ISceneLoaderPluginAsync {
         static OPTIMIZE_WITH_UV: boolean;
+        /**
+         * Invert model on y-axis (does a model scaling inversion)
+         */
         static INVERT_Y: boolean;
+        /**
+         * Include in meshes the vertex colors available in some OBJ files.  This is not part of OBJ standard.
+         */
+        static IMPORT_VERTEX_COLORS: boolean;
+        /**
+         * Compute the normals for the model, even if normals are present in the file
+         */
+        static COMPUTE_NORMALS: boolean;
         name: string;
         extensions: string;
         obj: RegExp;
@@ -84,10 +95,10 @@ declare module BABYLON {
          */
         private _loadMTL;
         /**
-         * Imports one or more meshes from the loaded glTF data and adds them to the scene
+         * Imports one or more meshes from the loaded OBJ data and adds them to the scene
          * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
          * @param scene the scene the meshes should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load
@@ -100,9 +111,10 @@ declare module BABYLON {
             animationGroups: AnimationGroup[];
         }>;
         /**
-         * Imports all objects from the loaded glTF data and adds them to the scene
+         * Imports all objects from the loaded OBJ data and adds them to the scene
+         *
          * @param scene the scene the objects should be added to
-         * @param data the glTF data to load
+         * @param data the OBJ data to load
          * @param rootUrl root url to load from
          * @param onProgress event that fires when loading progress has occured
          * @param fileName Defines the name of the file to load

+ 3 - 3
dist/preview release/loaders/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-loaders",
     "description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,8 +28,8 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs-gltf2interface": "4.0.0-alpha.16",
-        "babylonjs": "4.0.0-alpha.16"
+        "babylonjs-gltf2interface": "4.0.0-alpha.17",
+        "babylonjs": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

+ 2 - 2
dist/preview release/materialsLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-materials",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/postProcessesLibrary/babylonjs.postProcess.min.js


+ 2 - 2
dist/preview release/postProcessesLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-post-process",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

+ 2 - 2
dist/preview release/proceduralTexturesLibrary/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-procedural-textures",
     "description": "The Babylon.js materials library is a collection of advanced materials to be used in a Babylon.js scene.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,7 +28,7 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/serializers/babylon.glTF2Serializer.min.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 1
dist/preview release/serializers/babylonjs.serializers.min.js


+ 3 - 3
dist/preview release/serializers/package.json

@@ -4,7 +4,7 @@
     },
     "name": "babylonjs-serializers",
     "description": "The Babylon.js serializers library is an extension you can use to serialize Babylon scenes.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -28,8 +28,8 @@
     ],
     "license": "Apache-2.0",
     "dependencies": {
-        "babylonjs": "4.0.0-alpha.16",
-        "babylonjs-gltf2interface": "4.0.0-alpha.16"
+        "babylonjs": "4.0.0-alpha.17",
+        "babylonjs-gltf2interface": "4.0.0-alpha.17"
     },
     "engines": {
         "node": "*"

+ 2 - 2
dist/preview release/viewer/babylon.viewer.d.ts

@@ -4,8 +4,8 @@
 declare module "babylonjs-loaders"{ export=BABYLON;}
 // Generated by dts-bundle v0.7.3
 // Dependencies for this module:
-//   ../../../../../Tools/Gulp/babylonjs
-//   ../../../../../Tools/Gulp/babylonjs-loaders
+//   ../../../../../tools/gulp/babylonjs
+//   ../../../../../tools/gulp/babylonjs-loaders
 declare module BabylonViewer {
     /**
         * BabylonJS Viewer

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 3 - 3
dist/preview release/viewer/babylon.viewer.js


파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 6 - 6
dist/preview release/viewer/babylon.viewer.max.js


+ 2 - 2
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -5,8 +5,8 @@ declare module "babylonjs-loaders"{ export=BABYLON;}
 
 // Generated by dts-bundle v0.7.3
 // Dependencies for this module:
-//   ../../../../../Tools/Gulp/babylonjs
-//   ../../../../../Tools/Gulp/babylonjs-loaders
+//   ../../../../../tools/gulp/babylonjs
+//   ../../../../../tools/gulp/babylonjs-loaders
 
 declare module 'babylonjs-viewer' {
     import { mapperManager } from 'babylonjs-viewer/configuration/mappers';

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1087 - 0
gui/src/2D/controls/colorpicker.ts


+ 1 - 1
package.json

@@ -9,7 +9,7 @@
     ],
     "name": "babylonjs",
     "description": "Babylon.js is a JavaScript 3D engine based on webgl.",
-    "version": "4.0.0-alpha.16",
+    "version": "4.0.0-alpha.17",
     "repository": {
         "type": "git",
         "url": "https://github.com/BabylonJS/Babylon.js.git"

+ 3 - 0
readme.md

@@ -110,6 +110,9 @@ If you want to contribute, please read our [contribution guidelines](https://git
 - [Documentation](https://doc.babylonjs.com)
 - [Examples](https://doc.babylonjs.com/examples)
 
+## Contributing
+Please see the [Contributing Guidelines](./contributing.md)
+
 ## Useful links
 
 - Official web site: [www.babylonjs.com](https://www.babylonjs.com/)

+ 1 - 1
src/Engines/engine.ts

@@ -490,7 +490,7 @@ declare type RenderTargetTexture = import("../Materials/Textures/renderTargetTex
          * Returns the current version of the framework
          */
         public static get Version(): string {
-            return "4.0.0-alpha.16";
+            return "4.0.0-alpha.17";
         }
 
         /**