Переглянути джерело

Merge pull request #2977 from BabylonJS/master

nightly
David Catuhe 8 роки тому
батько
коміт
e483523025
37 змінених файлів з 18550 додано та 19371 видалено
  1. 2 0
      Playground/zipContent/index.html
  2. 0 6
      Tools/ConvertToBinary/App.config
  3. 0 67
      Tools/ConvertToBinary/ConvertToBinary.csproj
  4. 0 447
      Tools/ConvertToBinary/Program.cs
  5. 0 36
      Tools/ConvertToBinary/Properties/AssemblyInfo.cs
  6. 0 6
      Tools/MakeIncremental/App.config
  7. 0 105
      Tools/MakeIncremental/MakeIncremental.csproj
  8. 0 282
      Tools/MakeIncremental/Program.cs
  9. 0 36
      Tools/MakeIncremental/Properties/AssemblyInfo.cs
  10. BIN
      assets/meshes/controllers/microsoft/045E-065D/left.glb
  11. BIN
      assets/meshes/controllers/microsoft/045E-065D/right.glb
  12. 4216 4214
      dist/preview release/babylon.d.ts
  13. 38 38
      dist/preview release/babylon.js
  14. 78 32
      dist/preview release/babylon.max.js
  15. 4216 4214
      dist/preview release/babylon.module.d.ts
  16. 38 38
      dist/preview release/babylon.worker.js
  17. 4854 4852
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts
  18. 47 47
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js
  19. 79 33
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js
  20. 4854 4852
      dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts
  21. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  22. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  23. 1 1
      dist/preview release/loaders/babylon.glTFFileLoader.js
  24. 1 1
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  25. 1 1
      dist/preview release/loaders/babylonjs.loaders.js
  26. 1 1
      dist/preview release/loaders/babylonjs.loaders.min.js
  27. 1 0
      dist/preview release/what's new.md
  28. 1 1
      loaders/src/glTF/2.0/babylon.glTFLoader.ts
  29. 32 6
      src/Animations/babylon.animation.ts
  30. 2 2
      src/Cameras/babylon.targetCamera.ts
  31. 6 0
      src/Engine/babylon.engine.ts
  32. 11 3
      src/Gamepad/babylon.gamepadManager.ts
  33. 1 1
      src/Materials/PBR/babylon.pbrBaseMaterial.ts
  34. 1 1
      src/Materials/babylon.standardMaterial.ts
  35. 4 2
      src/Mesh/babylon.mesh.vertexData.ts
  36. 28 19
      src/Particles/babylon.solidParticleSystem.ts
  37. 35 25
      tests/nullEngine/app.js

+ 2 - 0
Playground/zipContent/index.html

@@ -6,9 +6,11 @@
         <title>Babylon.js sample code</title>
         <!-- Babylon.js -->
         <script src="https://www.babylonjs.com/hand.minified-1.2.js"></script>
+        <script src="https://preview.babylonjs.com/gui/babylon.gui.min.js"></script>
         <script src="https://preview.babylonjs.com/cannon.js"></script>
         <script src="https://preview.babylonjs.com/oimo.js"></script>
         <script src="https://preview.babylonjs.com/babylon.js"></script>
+        
         <style>
             html, body {
                 overflow: hidden;

+ 0 - 6
Tools/ConvertToBinary/App.config

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
-    </startup>
-</configuration>

+ 0 - 67
Tools/ConvertToBinary/ConvertToBinary.csproj

@@ -1,67 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{6A8A02E3-324F-4807-8AF9-AAD3CAF86376}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>ConvertToBinary</RootNamespace>
-    <AssemblyName>ConvertToBinary</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SccProjectName>SAK</SccProjectName>
-    <SccLocalPath>SAK</SccLocalPath>
-    <SccAuxPath>SAK</SccAuxPath>
-    <SccProvider>SAK</SccProvider>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Web" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 0 - 447
Tools/ConvertToBinary/Program.cs

@@ -1,447 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using System.Web;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System.Collections.Generic;
-using System.Net;
-
-namespace ConvertToBinary
-{
-    public enum DataType { Int32, Float };
-
-    class Program
-    {
-        static void Main(string[] args)
-        {
-            if (args.Length < 1)
-            {
-                DisplayUsage();
-                return;
-            }
-
-            // Parsing arguments
-            string srcFilename = "";
-            string dstPath = "";
-
-            foreach (var arg in args)
-            {
-                var order = arg.Substring(0, 3);
-
-                switch (order)
-                {
-                    case "/i:":
-                        srcFilename = arg.Substring(3);
-                        break;
-                    case "/o:":
-                        dstPath = arg.Substring(3);
-                        break;
-                    default:
-                        DisplayUsage();
-                        return;
-                }
-            }
-
-            if (string.IsNullOrEmpty(srcFilename) || string.IsNullOrEmpty(dstPath))
-            {
-                DisplayUsage();
-                return;
-            }
-
-            ProcessSourceFile(srcFilename, dstPath);
-        }
-
-        static void ProcessSourceFile(string srcFilename, string dstPath)
-        {
-            try
-            {
-                if (!Directory.Exists(dstPath))
-                    Directory.CreateDirectory(dstPath);
-
-                string srcPath = Path.GetDirectoryName(srcFilename);
-                string dstFilename = Path.Combine(dstPath, Path.GetFileNameWithoutExtension(srcFilename) + ".binary.babylon");
-
-                dynamic scene;
-
-                // Loading
-                Console.ForegroundColor = ConsoleColor.Green;
-                Console.WriteLine("Loading " + srcFilename);
-                Console.WriteLine();
-                Console.ResetColor();
-
-                using (var streamReader = new StreamReader(srcFilename))
-                {
-                    using (var reader = new JsonTextReader(streamReader))
-                    {
-                        scene = JObject.Load(reader);
-                    }
-                }
-
-                // Marking scene
-                string objName = scene.name;
-
-                if(string.IsNullOrEmpty(objName))
-                    objName = Path.GetFileNameWithoutExtension(srcFilename);
-
-                int atDot = objName.IndexOf(".incremental");
-                if(atDot > 0)
-                    objName = objName.Substring(0, atDot);
-
-                scene["autoClear"] = true;
-                scene["useDelayedTextureLoading"] = true;
-
-                var doNotDelayLoadingForGeometries = new List<string>();
-
-                // Parsing meshes
-                bool isMesh = true;
-                var meshes = (JArray)scene.meshes;
-                foreach (dynamic mesh in meshes)
-                {
-                    if (mesh.checkCollisions.Value) // Do not delay load collisions object
-                    {
-                        if (mesh.geometryId != null)
-                            doNotDelayLoadingForGeometries.Add(mesh.geometryId.Value);
-                        continue;
-                    }
-
-                    isMesh = true;
-
-                    Extract(srcPath, dstPath, objName, mesh, isMesh);
-                }
-
-
-                // Parsing vertexData
-                var geometries = scene.geometries;
-                if (geometries != null)
-                {
-                    var vertexData = (JArray)geometries.vertexData;
-                    foreach (dynamic geometry in vertexData)
-                    {
-                        var id = geometry.id.Value;
-
-                        if (doNotDelayLoadingForGeometries.Any(g => g == id))
-                            continue;
-
-                        isMesh = false;
-
-                        Extract(srcPath, dstPath, objName, geometry, isMesh);
-                    }
-                }
-
-                // Saving
-                Console.ForegroundColor = ConsoleColor.Green;
-                Console.WriteLine("Saving " + dstFilename);
-                string json = scene.ToString(Formatting.Indented);
-
-                using (var writer = new StreamWriter(WebUtility.UrlDecode(dstFilename)))
-                {
-                    writer.Write(json);
-                }
-
-                Console.WriteLine();
-                Console.ResetColor();
-            }
-            catch (Exception ex)
-            {
-                Console.ForegroundColor = ConsoleColor.Red;
-                Console.WriteLine("Fatal error encountered:");
-                Console.WriteLine(ex.Message);
-                Console.ResetColor();
-            }
-        }
-
-        
-        static void Extract(string srcPath, string dstPath, string objName, dynamic meshObj, bool isMesh)
-        {
-            try
-            {
-                string dstFilename = meshObj.delayLoadingFile;
-                string dstExt = (isMesh ? ".babylonbinarymeshdata" : ".babylonbinarygeometrydata");
-                
-                if(!string.IsNullOrEmpty(dstFilename))
-                {
-                    string filename = WebUtility.UrlDecode(Path.Combine(srcPath, (string)meshObj.delayLoadingFile));
-
-                    using (var streamReader = new StreamReader(filename))
-                    {
-                        using (var reader = new JsonTextReader(streamReader))
-                        {
-                            var meshData = JObject.Load(reader);
-                            meshObj.positions = meshData["positions"];
-                            meshObj.normals = meshData["normals"];
-                            meshObj.indices = meshData["indices"];
-                            meshObj.uvs = meshData["uvs"];
-                            meshObj.uvs2 = meshData["uvs2"];
-                            meshObj.colors = meshData["colors"];
-                            meshObj.matricesIndices = meshData["matricesIndices"];
-                            meshObj.matricesWeights = meshData["matricesWeights"];
-                            meshObj.subMeshes = meshData["subMeshes"];
-                        }
-                    }
-                }
-
-                if (meshObj.positions == null || meshObj.normals == null || meshObj.indices == null)
-                    return;
-
-                Console.WriteLine("Extracting " + (isMesh ? meshObj.name : meshObj.id));
-
-                ComputeBoundingBox(meshObj);
-
-                string meshName = meshObj.name.ToString();
-                meshName = meshName.Trim();
-                if (meshName.Length > 40)
-                    meshName = meshName.Substring(0, 40);
-
-                if (isMesh && !string.IsNullOrEmpty(meshName))
-                    dstFilename = objName + "." + meshName + "." + meshObj.id.ToString() + dstExt;
-                else
-                    dstFilename = objName + meshObj.id.ToString() + dstExt;
-
-                dstFilename = dstFilename.Replace("+", "_").Replace(" ", "_").Replace("/", "_").Replace("\\", "_");
-
-                meshObj.delayLoadingFile = WebUtility.UrlEncode(dstFilename);
-                Console.WriteLine("Creating delayLoadingFile: " + meshObj.delayLoadingFile);
-
-
-                var binaryInfo = new JObject();
-
-                using (var stream = File.Open(WebUtility.UrlDecode(Path.Combine(dstPath, dstFilename)), FileMode.Create))
-                {
-                    BinaryWriter writer = new BinaryWriter(stream);
-
-                    if (meshObj.positions != null && meshObj.positions.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.positions.Count;
-                        attrData["stride"] = 3;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["positionsAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.positions.Count; x++)
-                            writer.Write((float)meshObj.positions[x]);
-
-                        meshObj.positions = null;
-                    }
-
-
-                    if (meshObj.colors != null && meshObj.colors.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.colors.Count;
-                        attrData["stride"] = 3;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["colorsAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.colors.Count; x++)
-                            writer.Write((float)meshObj.colors[x]);
-
-                        meshObj["hasColors"] = true;
-                        meshObj.colors = null;
-                    }
-
-
-                    if (meshObj.normals != null && meshObj.normals.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.normals.Count;
-                        attrData["stride"] = 3;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["normalsAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.normals.Count; x++)
-                            writer.Write((float)meshObj.normals[x]);
-
-                        meshObj.normals = null;
-                    }
-
-
-                    if (meshObj.uvs != null && meshObj.uvs.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.uvs.Count;
-                        attrData["stride"] = 2;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["uvsAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.uvs.Count; x++)
-                            writer.Write((float)meshObj.uvs[x]);
-
-                        meshObj["hasUVs"] = true;
-                        meshObj.uvs = null;
-                    }
-
-
-                    if (meshObj.uvs2 != null && meshObj.uvs2.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.uvs2.Count;
-                        attrData["stride"] = 2;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["uvs2AttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.uvs2.Count; x++)
-                            writer.Write((float)meshObj.uvs2[x]);
-
-                        meshObj["hasUVs2"] = true;
-                        meshObj.uvs2 = null;
-                    }
-
-
-                    if (meshObj.indices != null && meshObj.indices.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.indices.Count;
-                        attrData["stride"] = 1;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Int32;
-
-                        binaryInfo["indicesAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.indices.Count; x++)
-                            writer.Write((int)meshObj.indices[x]);
-
-                        meshObj.indices = null;
-                    }
-
-
-                    if (meshObj.matricesIndices != null && meshObj.matricesIndices.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.matricesIndices.Count;
-                        attrData["stride"] = 1;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Int32;
-
-                        binaryInfo["matricesIndicesAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.matricesIndices.Count; x++)
-                            writer.Write((int)meshObj.matricesIndices[x]);
-
-                        meshObj["hasMatricesIndices"] = true;
-                        meshObj.matricesIndices = null;
-                    }
-
-
-                    if (meshObj.matricesWeights != null && meshObj.matricesWeights.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.matricesWeights.Count;
-                        attrData["stride"] = 2;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Float;
-
-                        binaryInfo["matricesWeightsAttrDesc"] = attrData;
-
-                        for (int x = 0; x < meshObj.matricesWeights.Count; x++)
-                            writer.Write((float)meshObj.matricesWeights[x]);
-
-                        meshObj["hasMatricesWeights"] = true;
-                        meshObj.matricesWeights = null;
-                    }
-
-
-                    if (isMesh && meshObj.subMeshes != null && meshObj.subMeshes.Count > 0)
-                    {
-                        var attrData = new JObject();
-                        attrData["count"] = meshObj.subMeshes.Count;
-                        attrData["stride"] = 5;
-                        attrData["offset"] = stream.Length;
-                        attrData["dataType"] = (int)DataType.Int32;
-
-                        binaryInfo["subMeshesAttrDesc"] = attrData;
-
-                        int[] smData = new int[5];
-
-                        for (int x = 0; x < meshObj.subMeshes.Count; x++)
-                        {
-                            smData[0] = meshObj.subMeshes[x].materialIndex;
-                            smData[1] = meshObj.subMeshes[x].verticesStart;
-                            smData[2] = meshObj.subMeshes[x].verticesCount;
-                            smData[3] = meshObj.subMeshes[x].indexStart;
-                            smData[4] = meshObj.subMeshes[x].indexCount;
-
-                            for (int y = 0; y < smData.Length; y++)
-                                writer.Write((int)smData[y]);
-                        }
-
-                        meshObj.subMeshes = null;
-                    }
-                }
-
-                meshObj["_binaryInfo"] = binaryInfo;
-            }
-            catch (Exception ex)
-            {
-                Console.ForegroundColor = ConsoleColor.Red;
-                Console.WriteLine();
-                Console.WriteLine(ex.Message);
-                Console.ForegroundColor = ConsoleColor.DarkCyan;
-                Console.WriteLine(ex);
-                Console.ResetColor();
-            }
-        }
-        
-        
-        static void ComputeBoundingBox(dynamic meshOrGeometry)
-        {
-            // Compute bounding boxes
-            var positions = ((JArray)meshOrGeometry.positions).Select(v => v.Value<float>()).ToArray();
-            var minimum = new[] { float.MaxValue, float.MaxValue, float.MaxValue };
-            var maximum = new[] { float.MinValue, float.MinValue, float.MinValue };
-
-            for (var index = 0; index < positions.Length; index += 3)
-            {
-                var x = positions[index];
-                var y = positions[index + 1];
-                var z = positions[index + 2];
-
-                if (x < minimum[0])
-                {
-                    minimum[0] = x;
-                }
-                if (x > maximum[0])
-                {
-                    maximum[0] = x;
-                }
-
-                if (y < minimum[1])
-                {
-                    minimum[1] = y;
-                }
-                if (y > maximum[1])
-                {
-                    maximum[1] = y;
-                }
-
-                if (z < minimum[2])
-                {
-                    minimum[2] = z;
-                }
-                if (z > maximum[2])
-                {
-                    maximum[2] = z;
-                }
-            }
-
-            meshOrGeometry["boundingBoxMinimum"] = new JArray(minimum);
-            meshOrGeometry["boundingBoxMaximum"] = new JArray(maximum);
-        }
-
-
-        static void DisplayUsage()
-        {
-            Console.WriteLine("ConvertToBinary usage: ConvertToBinary.exe /i:\"sourceFilename\" /o:\"dstinationFolder\"");
-        }
-    }
-}

+ 0 - 36
Tools/ConvertToBinary/Properties/AssemblyInfo.cs

@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("ConvertToBinary")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("ConvertToBinary")]
-[assembly: AssemblyCopyright("Copyright ©  2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("4e8c456c-1bd6-43fb-b67b-0dfbee0c468d")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

+ 0 - 6
Tools/MakeIncremental/App.config

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<configuration>
-    <startup> 
-        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
-    </startup>
-</configuration>

+ 0 - 105
Tools/MakeIncremental/MakeIncremental.csproj

@@ -1,105 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{E0855FC6-7205-4621-A975-7A8F2886B738}</ProjectGuid>
-    <OutputType>Exe</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>MakeIncremental</RootNamespace>
-    <AssemblyName>MakeIncremental</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SccProjectName>SAK</SccProjectName>
-    <SccLocalPath>SAK</SccLocalPath>
-    <SccAuxPath>SAK</SccAuxPath>
-    <SccProvider>SAK</SccProvider>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <PlatformTarget>AnyCPU</PlatformTarget>
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>bin\x64\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-    <OutputPath>bin\x64\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>x64</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
-    <DebugSymbols>true</DebugSymbols>
-    <OutputPath>bin\x86\Debug\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <DebugType>full</DebugType>
-    <PlatformTarget>x86</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
-    <OutputPath>bin\x86\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <Optimize>true</Optimize>
-    <DebugType>pdbonly</DebugType>
-    <PlatformTarget>x86</PlatformTarget>
-    <ErrorReport>prompt</ErrorReport>
-    <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
-    <Prefer32Bit>true</Prefer32Bit>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL" />
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Web" />
-    <Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
-    <Reference Include="System.Xml.Linq" />
-    <Reference Include="System.Data.DataSetExtensions" />
-    <Reference Include="Microsoft.CSharp" />
-    <Reference Include="System.Data" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="Program.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="App.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 0 - 282
Tools/MakeIncremental/Program.cs

@@ -1,282 +0,0 @@
-using System;
-using System.IO;
-using System.Linq;
-using System.Web;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System.Collections.Generic;
-
-namespace MakeIncremental
-{
-    class Program
-    {
-        static void Main(string[] args)
-        {
-            if (args.Length < 1)
-            {
-                DisplayUsage();
-                return;
-            }
-
-            // Parsing arguments
-            string input = "";
-            foreach (var arg in args)
-            {
-                var order = arg.Substring(0, 3);
-
-                switch (order)
-                {
-                    case "/i:":
-                        input = arg.Substring(3);
-                        break;
-                    default:
-                        DisplayUsage();
-                        return;
-                }
-            }
-
-            if (string.IsNullOrEmpty(input))
-            {
-                DisplayUsage();
-                return;
-            }
-
-            ProcessSourceFile(input);
-        }
-
-        static void Extract(dynamic meshOrGeometry, string outputDir, string rootFilename, bool mesh = true)
-        {
-            Console.WriteLine("Extracting " + (mesh ? meshOrGeometry.name : meshOrGeometry.id));
-
-            if (meshOrGeometry.positions != null && meshOrGeometry.normals != null && meshOrGeometry.indices != null)
-            {
-                meshOrGeometry.delayLoadingFile = CreateDelayLoadingFile(meshOrGeometry, outputDir, rootFilename, mesh);
-                Console.WriteLine("Delay loading file: " + meshOrGeometry.delayLoadingFile);
-
-                // Compute bounding boxes
-                var positions = ((JArray)meshOrGeometry.positions).Select(v => v.Value<float>()).ToArray();
-                var minimum = new[] { float.MaxValue, float.MaxValue, float.MaxValue };
-                var maximum = new[] { float.MinValue, float.MinValue, float.MinValue };
-
-                for (var index = 0; index < positions.Length; index += 3)
-                {
-                    var x = positions[index];
-                    var y = positions[index + 1];
-                    var z = positions[index + 2];
-
-                    if (x < minimum[0])
-                    {
-                        minimum[0] = x;
-                    }
-                    if (x > maximum[0])
-                    {
-                        maximum[0] = x;
-                    }
-
-                    if (y < minimum[1])
-                    {
-                        minimum[1] = y;
-                    }
-                    if (y > maximum[1])
-                    {
-                        maximum[1] = y;
-                    }
-
-                    if (z < minimum[2])
-                    {
-                        minimum[2] = z;
-                    }
-                    if (z > maximum[2])
-                    {
-                        maximum[2] = z;
-                    }
-                }
-
-                meshOrGeometry["boundingBoxMinimum"] = new JArray(minimum);
-                meshOrGeometry["boundingBoxMaximum"] = new JArray(maximum);
-
-                // Erasing infos
-                meshOrGeometry.positions = null;
-                meshOrGeometry.normals = null;
-                meshOrGeometry.indices = null;
-
-                if (meshOrGeometry.uvs != null)
-                {
-                    meshOrGeometry["hasUVs"] = true;
-                    meshOrGeometry.uvs = null;
-                }
-
-                if (meshOrGeometry.uvs2 != null)
-                {
-                    meshOrGeometry["hasUVs2"] = true;
-                    meshOrGeometry.uvs2 = null;
-                }
-
-                if (meshOrGeometry.colors != null)
-                {
-                    meshOrGeometry["hasColors"] = true;
-                    meshOrGeometry.colors = null;
-                }
-
-                if (meshOrGeometry.matricesIndices != null)
-                {
-                    meshOrGeometry["hasMatricesIndices"] = true;
-                    meshOrGeometry.matricesIndices = null;
-                }
-
-                if (meshOrGeometry.matricesWeights != null)
-                {
-                    meshOrGeometry["hasMatricesWeights"] = true;
-                    meshOrGeometry.matricesWeights = null;
-                }
-
-                if (mesh && meshOrGeometry.subMeshes != null)
-                {
-                    meshOrGeometry.subMeshes = null;
-                }
-            }
-        }
-
-        static string CreateDelayLoadingFile(dynamic meshOrGeometry, string outputDir, string rootFilename, bool mesh = true)
-        {
-            string encodedName;
-            if(mesh)
-                encodedName = meshOrGeometry.name.ToString();
-            else
-                encodedName = meshOrGeometry.id.ToString();
-
-            encodedName = encodedName.Replace("+", "_").Replace(" ", "_");
-            var outputPath = Path.Combine(outputDir, rootFilename + "." + encodedName + (mesh ? ".babylonmeshdata" : ".babylongeometrydata"));
-
-            var result = new JObject();
-            result["positions"] = meshOrGeometry.positions;
-            result["indices"] = meshOrGeometry.indices;
-            result["normals"] = meshOrGeometry.normals;
-
-            if (meshOrGeometry.uvs != null)
-            {
-                result["uvs"] = meshOrGeometry.uvs;
-            }
-
-            if (meshOrGeometry.uvs2 != null)
-            {
-                result["uvs2"] = meshOrGeometry.uvs2;
-            }
-
-            if (meshOrGeometry.colors != null)
-            {
-                result["colors"] = meshOrGeometry.colors;
-            }
-
-            if (meshOrGeometry.matricesIndices != null)
-            {
-                result["matricesIndices"] = meshOrGeometry.matricesIndices;
-            }
-
-            if (meshOrGeometry.matricesWeights != null)
-            {
-                result["matricesWeights"] = meshOrGeometry.matricesWeights;
-            }
-
-            if (mesh && meshOrGeometry.subMeshes != null)
-            {
-                result["subMeshes"] = meshOrGeometry.subMeshes;
-            }
-
-            string json = result.ToString(Formatting.None);
-
-            using (var writer = new StreamWriter(outputPath))
-            {
-                writer.Write(json);
-            }
-
-            return HttpUtility.UrlEncode(Path.GetFileName(outputPath));
-        }
-
-        static void ProcessSourceFile(string input)
-        {
-            try
-            {
-                dynamic scene;
-                var outputDir = Path.GetDirectoryName(input);
-                var rootFilename = Path.GetFileNameWithoutExtension(input);
-
-                // Loading
-                Console.ForegroundColor = ConsoleColor.Green;
-                Console.WriteLine("Loading " + input);
-                Console.WriteLine();
-                Console.ResetColor();
-                using (var streamReader = new StreamReader(input))
-                {
-                    using (var reader = new JsonTextReader(streamReader))
-                    {
-                        scene = JObject.Load(reader);
-                    }
-                }
-
-                // Marking scene
-                scene["autoClear"] = true;
-                scene["useDelayedTextureLoading"] = true;
-
-                var doNotDelayLoadingForGeometries = new List<string>();
-
-                // Parsing meshes
-                var meshes = (JArray)scene.meshes;
-                foreach (dynamic mesh in meshes)
-                {
-                    if (mesh.checkCollisions.Value) // Do not delay load collisions object
-                    {
-                        if (mesh.geometryId != null)
-                            doNotDelayLoadingForGeometries.Add(mesh.geometryId.Value);
-                        continue;
-                    }
-
-                    Extract(mesh, outputDir, rootFilename);
-                }
-
-                // Parsing vertexData
-                var geometries = scene.geometries;
-                if (geometries != null)
-                {
-                    var vertexData = (JArray)geometries.vertexData;
-                    foreach (dynamic geometry in vertexData)
-                    {
-                        var id = geometry.id.Value;
-
-                        if (doNotDelayLoadingForGeometries.Any(g => g == id))
-                            continue;
-
-                        Extract(geometry, outputDir, rootFilename, false);
-                    }
-                }
-
-                // Saving
-                var outputPath = Path.Combine(outputDir, rootFilename + ".incremental.babylon");
-                Console.ForegroundColor = ConsoleColor.Green;
-                Console.WriteLine("Saving " + outputPath);
-                string json = scene.ToString(Formatting.None);
-
-                using (var writer = new StreamWriter(outputPath))
-                {
-                    writer.Write(json);
-                }
-
-                Console.WriteLine();
-                Console.ResetColor();
-
-            }
-            catch (Exception ex)
-            {
-                Console.ForegroundColor = ConsoleColor.Red;
-                Console.WriteLine("Fatal error encountered:");
-                Console.WriteLine(ex.Message);
-                Console.ResetColor();
-            }
-        }
-
-        static void DisplayUsage()
-        {
-            Console.WriteLine("MakeIncremental usage: MakeIncremental.exe /i:\"source file\" [/textures]");
-        }
-    }
-}

+ 0 - 36
Tools/MakeIncremental/Properties/AssemblyInfo.cs

@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following 
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("MakeIncremental")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("MakeIncremental")]
-[assembly: AssemblyCopyright("Copyright ©  2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible 
-// to COM components.  If you need to access a type in this assembly from 
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("863a000d-e69f-4e3b-a150-1e75094c9024")]
-
-// Version information for an assembly consists of the following four values:
-//
-//      Major Version
-//      Minor Version 
-//      Build Number
-//      Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers 
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

BIN
assets/meshes/controllers/microsoft/045E-065D/left.glb


BIN
assets/meshes/controllers/microsoft/045E-065D/right.glb


Різницю між файлами не показано, бо вона завелика
+ 4216 - 4214
dist/preview release/babylon.d.ts


Різницю між файлами не показано, бо вона завелика
+ 38 - 38
dist/preview release/babylon.js


+ 78 - 32
dist/preview release/babylon.max.js

@@ -11352,12 +11352,18 @@ var BABYLON;
         };
         // Loading screen
         Engine.prototype.displayLoadingUI = function () {
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                return;
+            }
             var loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.displayLoadingUI();
             }
         };
         Engine.prototype.hideLoadingUI = function () {
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                return;
+            }
             var loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.hideLoadingUI();
@@ -27325,7 +27331,8 @@ var BABYLON;
          * Merges the passed VertexData into the current one.
          * Returns the modified VertexData.
          */
-        VertexData.prototype.merge = function (other) {
+        VertexData.prototype.merge = function (other, options) {
+            options = options || {};
             if (other.indices) {
                 if (!this.indices) {
                     this.indices = [];
@@ -27339,7 +27346,7 @@ var BABYLON;
             this.positions = this._mergeElement(this.positions, other.positions);
             var count = this.positions.length / 3;
             this.normals = this._mergeElement(this.normals, other.normals, count * 3);
-            this.tangents = this._mergeElement(this.tangents, other.tangents, count * 4);
+            this.tangents = this._mergeElement(this.tangents, other.tangents, count * (options.tangentLength || 4));
             this.uvs = this._mergeElement(this.uvs, other.uvs, count * 2);
             this.uvs2 = this._mergeElement(this.uvs2, other.uvs2, count * 2);
             this.uvs3 = this._mergeElement(this.uvs3, other.uvs3, count * 2);
@@ -32537,7 +32544,7 @@ var BABYLON;
          * Child classes can use it to update shaders
          */
         StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady && subMesh.effect) {
                     return true;
                 }
@@ -33997,7 +34004,7 @@ var BABYLON;
         };
         PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             var _this = this;
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady) {
                     return true;
                 }
@@ -36510,12 +36517,12 @@ var BABYLON;
         TargetCamera.prototype._updateCameraRotationMatrix = function () {
             if (this.rotationQuaternion) {
                 this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
-                //update the up vector!
-                BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
             }
             else {
                 BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
             }
+            //update the up vector!
+            BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
         };
         TargetCamera.prototype._getViewMatrix = function () {
             if (!this.lockedTarget) {
@@ -39355,12 +39362,32 @@ var BABYLON;
             }
             for (index = 0; index < parsedAnimation.keys.length; index++) {
                 var key = parsedAnimation.keys[index];
+                var inTangent;
+                var outTangent;
                 switch (dataType) {
                     case Animation.ANIMATIONTYPE_FLOAT:
                         data = key.values[0];
+                        if (key.values.length >= 1) {
+                            inTangent = key.values[1];
+                        }
+                        if (key.values.length >= 2) {
+                            outTangent = key.values[2];
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_QUATERNION:
                         data = BABYLON.Quaternion.FromArray(key.values);
+                        if (key.values.length >= 8) {
+                            var _inTangent = BABYLON.Quaternion.FromArray(key.values.slice(4, 8));
+                            if (!_inTangent.equals(BABYLON.Quaternion.Zero())) {
+                                inTangent = _inTangent;
+                            }
+                        }
+                        if (key.values.length >= 12) {
+                            var _outTangent = BABYLON.Quaternion.FromArray(key.values.slice(8, 12));
+                            if (!_outTangent.equals(BABYLON.Quaternion.Zero())) {
+                                outTangent = _outTangent;
+                            }
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_MATRIX:
                         data = BABYLON.Matrix.FromArray(key.values);
@@ -39373,10 +39400,16 @@ var BABYLON;
                         data = BABYLON.Vector3.FromArray(key.values);
                         break;
                 }
-                keys.push({
-                    frame: key.frame,
-                    value: data
-                });
+                var keyData = {};
+                keyData.frame = key.frame;
+                keyData.value = data;
+                if (inTangent != undefined) {
+                    keyData.inTangent = inTangent;
+                }
+                if (outTangent != undefined) {
+                    keyData.outTangent = outTangent;
+                }
+                keys.push(keyData);
             }
             animation.setKeys(keys);
             if (parsedAnimation.ranges) {
@@ -43682,6 +43715,7 @@ var BABYLON;
             this._cam_axisX = BABYLON.Vector3.Zero();
             this._axisZ = BABYLON.Axis.Z;
             this._camDir = BABYLON.Vector3.Zero();
+            this._camInvertedPosition = BABYLON.Vector3.Zero();
             this._rotMatrix = new BABYLON.Matrix();
             this._invertMatrix = new BABYLON.Matrix();
             this._rotated = BABYLON.Vector3.Zero();
@@ -43703,14 +43737,13 @@ var BABYLON;
             this._mustUnrotateFixedNormals = false;
             this._minimum = BABYLON.Tmp.Vector3[0];
             this._maximum = BABYLON.Tmp.Vector3[1];
-            this._scale = BABYLON.Tmp.Vector3[2];
-            this._translation = BABYLON.Tmp.Vector3[3];
             this._minBbox = BABYLON.Tmp.Vector3[4];
             this._maxBbox = BABYLON.Tmp.Vector3[5];
             this._particlesIntersect = false;
             this._depthSortFunction = function (p1, p2) {
                 return (p2.sqDistance - p1.sqDistance);
             };
+            this._needs32Bits = false;
             this._bSphereOnly = false;
             this._bSphereRadiusFactor = 1.0;
             this.name = name;
@@ -43757,7 +43790,7 @@ var BABYLON;
             }
             var vertexData = new BABYLON.VertexData();
             if (this._depthSort) {
-                this._depthSortedIndices = this._indices.slice();
+                this._depthSortedIndices = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
                 vertexData.indices = this._depthSortedIndices;
             }
             else {
@@ -43989,7 +44022,11 @@ var BABYLON;
                 }
             }
             for (i = 0; i < meshInd.length; i++) {
-                indices.push(p + meshInd[i]);
+                var current_ind = p + meshInd[i];
+                indices.push(current_ind);
+                if (current_ind > 65535) {
+                    this._needs32Bits = true;
+                }
             }
             if (this._pickable) {
                 var nbfaces = meshInd.length / 3;
@@ -44157,23 +44194,27 @@ var BABYLON;
             this._cam_axisZ.x = 0.0;
             this._cam_axisZ.y = 0.0;
             this._cam_axisZ.z = 1.0;
+            // cases when the World Matrix is to be computed first
+            if (this.billboard || this._depthSort) {
+                this.mesh.computeWorldMatrix(true);
+                this.mesh._worldMatrix.invertToRef(this._invertMatrix);
+            }
             // if the particles will always face the camera
             if (this.billboard) {
-                this.mesh.computeWorldMatrix(true);
                 // compute the camera position and un-rotate it by the current mesh rotation
-                if (this.mesh._worldMatrix.decompose(this._scale, this._quaternion, this._translation)) {
-                    this._quaternionToRotationMatrix();
-                    this._rotMatrix.invertToRef(this._invertMatrix);
-                    this._camera.getDirectionToRef(this._axisZ, this._camDir);
-                    BABYLON.Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
-                    this._cam_axisZ.normalize();
-                    // same for camera up vector extracted from the cam view matrix
-                    var view = this._camera.getViewMatrix(true);
-                    BABYLON.Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
-                    BABYLON.Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
-                    this._cam_axisY.normalize();
-                    this._cam_axisX.normalize();
-                }
+                this._camera.getDirectionToRef(this._axisZ, this._camDir);
+                BABYLON.Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
+                this._cam_axisZ.normalize();
+                // same for camera up vector extracted from the cam view matrix
+                var view = this._camera.getViewMatrix(true);
+                BABYLON.Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
+                BABYLON.Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
+                this._cam_axisY.normalize();
+                this._cam_axisX.normalize();
+            }
+            // if depthSort, compute the camera global position in the mesh local system
+            if (this._depthSort) {
+                BABYLON.Vector3.TransformCoordinatesToRef(this._camera.globalPosition, this._invertMatrix, this._camInvertedPosition); // then un-rotate the camera
             }
             BABYLON.Matrix.IdentityToRef(this._rotMatrix);
             var idx = 0; // current position index in the global array positions32
@@ -44241,7 +44282,7 @@ var BABYLON;
                         var dsp = this.depthSortedParticles[p];
                         dsp.ind = this._particle._ind;
                         dsp.indicesLength = this._particle._model._indicesLength;
-                        dsp.sqDistance = BABYLON.Vector3.DistanceSquared(this._particle.position, this._camera.position);
+                        dsp.sqDistance = BABYLON.Vector3.DistanceSquared(this._particle.position, this._camInvertedPosition);
                     }
                     // particle vertex loop
                     for (pt = 0; pt < this._shape.length; pt++) {
@@ -53586,10 +53627,15 @@ var BABYLON;
             this._babylonGamepads = [];
             this._oneGamepadConnected = false;
             this._isMonitoring = false;
-            this._gamepadEventSupported = 'GamepadEvent' in window;
-            this._gamepadSupport = (navigator.getGamepads ||
-                navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
             this.onGamepadDisconnectedObservable = new BABYLON.Observable();
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                this._gamepadEventSupported = false;
+            }
+            else {
+                this._gamepadEventSupported = 'GamepadEvent' in window;
+                this._gamepadSupport = (navigator.getGamepads ||
+                    navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
+            }
             this.onGamepadConnectedObservable = new BABYLON.Observable(function (observer) {
                 // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
                 for (var i in _this._babylonGamepads) {

Різницю між файлами не показано, бо вона завелика
+ 4216 - 4214
dist/preview release/babylon.module.d.ts


Різницю між файлами не показано, бо вона завелика
+ 38 - 38
dist/preview release/babylon.worker.js


Різницю між файлами не показано, бо вона завелика
+ 4854 - 4852
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.d.ts


Різницю між файлами не показано, бо вона завелика
+ 47 - 47
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.js


+ 79 - 33
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.max.js

@@ -11352,12 +11352,18 @@ var BABYLON;
         };
         // Loading screen
         Engine.prototype.displayLoadingUI = function () {
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                return;
+            }
             var loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.displayLoadingUI();
             }
         };
         Engine.prototype.hideLoadingUI = function () {
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                return;
+            }
             var loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.hideLoadingUI();
@@ -27325,7 +27331,8 @@ var BABYLON;
          * Merges the passed VertexData into the current one.
          * Returns the modified VertexData.
          */
-        VertexData.prototype.merge = function (other) {
+        VertexData.prototype.merge = function (other, options) {
+            options = options || {};
             if (other.indices) {
                 if (!this.indices) {
                     this.indices = [];
@@ -27339,7 +27346,7 @@ var BABYLON;
             this.positions = this._mergeElement(this.positions, other.positions);
             var count = this.positions.length / 3;
             this.normals = this._mergeElement(this.normals, other.normals, count * 3);
-            this.tangents = this._mergeElement(this.tangents, other.tangents, count * 4);
+            this.tangents = this._mergeElement(this.tangents, other.tangents, count * (options.tangentLength || 4));
             this.uvs = this._mergeElement(this.uvs, other.uvs, count * 2);
             this.uvs2 = this._mergeElement(this.uvs2, other.uvs2, count * 2);
             this.uvs3 = this._mergeElement(this.uvs3, other.uvs3, count * 2);
@@ -32537,7 +32544,7 @@ var BABYLON;
          * Child classes can use it to update shaders
          */
         StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady && subMesh.effect) {
                     return true;
                 }
@@ -33997,7 +34004,7 @@ var BABYLON;
         };
         PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
             var _this = this;
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady) {
                     return true;
                 }
@@ -36510,12 +36517,12 @@ var BABYLON;
         TargetCamera.prototype._updateCameraRotationMatrix = function () {
             if (this.rotationQuaternion) {
                 this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
-                //update the up vector!
-                BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
             }
             else {
                 BABYLON.Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
             }
+            //update the up vector!
+            BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
         };
         TargetCamera.prototype._getViewMatrix = function () {
             if (!this.lockedTarget) {
@@ -39355,12 +39362,32 @@ var BABYLON;
             }
             for (index = 0; index < parsedAnimation.keys.length; index++) {
                 var key = parsedAnimation.keys[index];
+                var inTangent;
+                var outTangent;
                 switch (dataType) {
                     case Animation.ANIMATIONTYPE_FLOAT:
                         data = key.values[0];
+                        if (key.values.length >= 1) {
+                            inTangent = key.values[1];
+                        }
+                        if (key.values.length >= 2) {
+                            outTangent = key.values[2];
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_QUATERNION:
                         data = BABYLON.Quaternion.FromArray(key.values);
+                        if (key.values.length >= 8) {
+                            var _inTangent = BABYLON.Quaternion.FromArray(key.values.slice(4, 8));
+                            if (!_inTangent.equals(BABYLON.Quaternion.Zero())) {
+                                inTangent = _inTangent;
+                            }
+                        }
+                        if (key.values.length >= 12) {
+                            var _outTangent = BABYLON.Quaternion.FromArray(key.values.slice(8, 12));
+                            if (!_outTangent.equals(BABYLON.Quaternion.Zero())) {
+                                outTangent = _outTangent;
+                            }
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_MATRIX:
                         data = BABYLON.Matrix.FromArray(key.values);
@@ -39373,10 +39400,16 @@ var BABYLON;
                         data = BABYLON.Vector3.FromArray(key.values);
                         break;
                 }
-                keys.push({
-                    frame: key.frame,
-                    value: data
-                });
+                var keyData = {};
+                keyData.frame = key.frame;
+                keyData.value = data;
+                if (inTangent != undefined) {
+                    keyData.inTangent = inTangent;
+                }
+                if (outTangent != undefined) {
+                    keyData.outTangent = outTangent;
+                }
+                keys.push(keyData);
             }
             animation.setKeys(keys);
             if (parsedAnimation.ranges) {
@@ -43682,6 +43715,7 @@ var BABYLON;
             this._cam_axisX = BABYLON.Vector3.Zero();
             this._axisZ = BABYLON.Axis.Z;
             this._camDir = BABYLON.Vector3.Zero();
+            this._camInvertedPosition = BABYLON.Vector3.Zero();
             this._rotMatrix = new BABYLON.Matrix();
             this._invertMatrix = new BABYLON.Matrix();
             this._rotated = BABYLON.Vector3.Zero();
@@ -43703,14 +43737,13 @@ var BABYLON;
             this._mustUnrotateFixedNormals = false;
             this._minimum = BABYLON.Tmp.Vector3[0];
             this._maximum = BABYLON.Tmp.Vector3[1];
-            this._scale = BABYLON.Tmp.Vector3[2];
-            this._translation = BABYLON.Tmp.Vector3[3];
             this._minBbox = BABYLON.Tmp.Vector3[4];
             this._maxBbox = BABYLON.Tmp.Vector3[5];
             this._particlesIntersect = false;
             this._depthSortFunction = function (p1, p2) {
                 return (p2.sqDistance - p1.sqDistance);
             };
+            this._needs32Bits = false;
             this._bSphereOnly = false;
             this._bSphereRadiusFactor = 1.0;
             this.name = name;
@@ -43757,7 +43790,7 @@ var BABYLON;
             }
             var vertexData = new BABYLON.VertexData();
             if (this._depthSort) {
-                this._depthSortedIndices = this._indices.slice();
+                this._depthSortedIndices = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
                 vertexData.indices = this._depthSortedIndices;
             }
             else {
@@ -43989,7 +44022,11 @@ var BABYLON;
                 }
             }
             for (i = 0; i < meshInd.length; i++) {
-                indices.push(p + meshInd[i]);
+                var current_ind = p + meshInd[i];
+                indices.push(current_ind);
+                if (current_ind > 65535) {
+                    this._needs32Bits = true;
+                }
             }
             if (this._pickable) {
                 var nbfaces = meshInd.length / 3;
@@ -44157,23 +44194,27 @@ var BABYLON;
             this._cam_axisZ.x = 0.0;
             this._cam_axisZ.y = 0.0;
             this._cam_axisZ.z = 1.0;
+            // cases when the World Matrix is to be computed first
+            if (this.billboard || this._depthSort) {
+                this.mesh.computeWorldMatrix(true);
+                this.mesh._worldMatrix.invertToRef(this._invertMatrix);
+            }
             // if the particles will always face the camera
             if (this.billboard) {
-                this.mesh.computeWorldMatrix(true);
                 // compute the camera position and un-rotate it by the current mesh rotation
-                if (this.mesh._worldMatrix.decompose(this._scale, this._quaternion, this._translation)) {
-                    this._quaternionToRotationMatrix();
-                    this._rotMatrix.invertToRef(this._invertMatrix);
-                    this._camera.getDirectionToRef(this._axisZ, this._camDir);
-                    BABYLON.Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
-                    this._cam_axisZ.normalize();
-                    // same for camera up vector extracted from the cam view matrix
-                    var view = this._camera.getViewMatrix(true);
-                    BABYLON.Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
-                    BABYLON.Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
-                    this._cam_axisY.normalize();
-                    this._cam_axisX.normalize();
-                }
+                this._camera.getDirectionToRef(this._axisZ, this._camDir);
+                BABYLON.Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);
+                this._cam_axisZ.normalize();
+                // same for camera up vector extracted from the cam view matrix
+                var view = this._camera.getViewMatrix(true);
+                BABYLON.Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
+                BABYLON.Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
+                this._cam_axisY.normalize();
+                this._cam_axisX.normalize();
+            }
+            // if depthSort, compute the camera global position in the mesh local system
+            if (this._depthSort) {
+                BABYLON.Vector3.TransformCoordinatesToRef(this._camera.globalPosition, this._invertMatrix, this._camInvertedPosition); // then un-rotate the camera
             }
             BABYLON.Matrix.IdentityToRef(this._rotMatrix);
             var idx = 0; // current position index in the global array positions32
@@ -44241,7 +44282,7 @@ var BABYLON;
                         var dsp = this.depthSortedParticles[p];
                         dsp.ind = this._particle._ind;
                         dsp.indicesLength = this._particle._model._indicesLength;
-                        dsp.sqDistance = BABYLON.Vector3.DistanceSquared(this._particle.position, this._camera.position);
+                        dsp.sqDistance = BABYLON.Vector3.DistanceSquared(this._particle.position, this._camInvertedPosition);
                     }
                     // particle vertex loop
                     for (pt = 0; pt < this._shape.length; pt++) {
@@ -53586,10 +53627,15 @@ var BABYLON;
             this._babylonGamepads = [];
             this._oneGamepadConnected = false;
             this._isMonitoring = false;
-            this._gamepadEventSupported = 'GamepadEvent' in window;
-            this._gamepadSupport = (navigator.getGamepads ||
-                navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
             this.onGamepadDisconnectedObservable = new BABYLON.Observable();
+            if (!BABYLON.Tools.IsWindowObjectExist()) {
+                this._gamepadEventSupported = false;
+            }
+            else {
+                this._gamepadEventSupported = 'GamepadEvent' in window;
+                this._gamepadSupport = (navigator.getGamepads ||
+                    navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
+            }
             this.onGamepadConnectedObservable = new BABYLON.Observable(function (observer) {
                 // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
                 for (var i in _this._babylonGamepads) {
@@ -76537,7 +76583,7 @@ var BABYLON;
                         var vertexData = new BABYLON.VertexData();
                         for (var _i = 0, _a = mesh.primitives; _i < _a.length; _i++) {
                             var primitive = _a[_i];
-                            vertexData.merge(primitive.targetsVertexData[index]);
+                            vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                         }
                         var target = morphTargetManager.getTarget(index);
                         target.setNormals(vertexData.normals);

Різницю між файлами не показано, бо вона завелика
+ 4854 - 4852
dist/preview release/customConfigurations/minimalGLTFViewer/babylon.module.d.ts


+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -771,7 +771,7 @@ var BABYLON;
                         var vertexData = new BABYLON.VertexData();
                         for (var _i = 0, _a = mesh.primitives; _i < _a.length; _i++) {
                             var primitive = _a[_i];
-                            vertexData.merge(primitive.targetsVertexData[index]);
+                            vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                         }
                         var target = morphTargetManager.getTarget(index);
                         target.setNormals(vertexData.normals);

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2877,7 +2877,7 @@ var BABYLON;
                         var vertexData = new BABYLON.VertexData();
                         for (var _i = 0, _a = mesh.primitives; _i < _a.length; _i++) {
                             var primitive = _a[_i];
-                            vertexData.merge(primitive.targetsVertexData[index]);
+                            vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                         }
                         var target = morphTargetManager.getTarget(index);
                         target.setNormals(vertexData.normals);

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/loaders/babylon.glTFFileLoader.min.js


+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.js

@@ -3830,7 +3830,7 @@ var BABYLON;
                         var vertexData = new BABYLON.VertexData();
                         for (var _i = 0, _a = mesh.primitives; _i < _a.length; _i++) {
                             var primitive = _a[_i];
-                            vertexData.merge(primitive.targetsVertexData[index]);
+                            vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                         }
                         var target = morphTargetManager.getTarget(index);
                         target.setNormals(vertexData.normals);

Різницю між файлами не показано, бо вона завелика
+ 1 - 1
dist/preview release/loaders/babylonjs.loaders.min.js


+ 1 - 0
dist/preview release/what's new.md

@@ -36,6 +36,7 @@
 - Normals are generated automatically by StandardMaterial if meshes do not have normals ([deltakosh](https://github.com/deltakosh))
 - Added `mesh.onMaterialChangedObservable` to notify when a new material is set ([deltakosh](https://github.com/deltakosh))
 - Improved the SPS perfs for dead or invisible solid particles ([jerome](https://github.com/jbousquie))  
+- Added `enableDepthSort` parameter to the SPS in order to sort the particles from the camera position ([jerome](https://github.com/jbousquie)) 
 
 ## Bug fixes
 - Fixed a bug with PBR on iOS ([sebavan](https://github.com/sebavan))

+ 1 - 1
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -568,7 +568,7 @@ module BABYLON.GLTF2 {
                 for (var index = 0; index < numTargets; index++) {
                     var vertexData = new VertexData();
                     for (var primitive of mesh.primitives) {
-                        vertexData.merge(primitive.targetsVertexData[index]);
+                        vertexData.merge(primitive.targetsVertexData[index], { tangentLength: 3 });
                     }
 
                     var target = morphTargetManager.getTarget(index);

+ 32 - 6
src/Animations/babylon.animation.ts

@@ -508,7 +508,7 @@
             var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
 
             var dataType = parsedAnimation.dataType;
-            var keys: Array<{ frame: number, value: any }> = [];
+            var keys: Array<{ frame: number, value: any, inTangent:any, outTangent:any }> = [];
             var data;
             var index: number;
 
@@ -522,14 +522,33 @@
 
             for (index = 0; index < parsedAnimation.keys.length; index++) {
                 var key = parsedAnimation.keys[index];
-
+                var inTangent:any;
+                var outTangent:any;
 
                 switch (dataType) {
                     case Animation.ANIMATIONTYPE_FLOAT:
                         data = key.values[0];
+                        if (key.values.length >= 1) {
+                            inTangent = key.values[1];
+                        }
+                        if (key.values.length >= 2) {
+                            outTangent = key.values[2];
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_QUATERNION:
                         data = Quaternion.FromArray(key.values);
+                        if (key.values.length >= 8) {
+                            var _inTangent = Quaternion.FromArray(key.values.slice(4, 8));
+                            if (!_inTangent.equals(Quaternion.Zero())) {
+                                inTangent = _inTangent;
+                            }
+                        }
+                        if (key.values.length >= 12) {
+                            var _outTangent = Quaternion.FromArray(key.values.slice(8, 12));
+                            if (!_outTangent.equals(Quaternion.Zero())) {
+                                outTangent = _outTangent;
+                            }
+                        }
                         break;
                     case Animation.ANIMATIONTYPE_MATRIX:
                         data = Matrix.FromArray(key.values);
@@ -543,10 +562,17 @@
                         break;
                 }
 
-                keys.push({
-                    frame: key.frame,
-                    value: data
-                });
+                var keyData:any = {};
+                keyData.frame = key.frame;
+                keyData.value = data;
+
+                if (inTangent != undefined) {
+                    keyData.inTangent = inTangent;
+                }
+                if (outTangent != undefined) {
+                    keyData.outTangent = outTangent;
+                }
+                keys.push(keyData)
             }
 
             animation.setKeys(keys);

+ 2 - 2
src/Cameras/babylon.targetCamera.ts

@@ -270,11 +270,11 @@ module BABYLON {
         protected _updateCameraRotationMatrix() {
             if (this.rotationQuaternion) {
                 this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
-                //update the up vector!
-                BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
             } else {
                 Matrix.RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
             }
+            //update the up vector!
+            BABYLON.Vector3.TransformNormalToRef(this._defaultUpVector, this._cameraRotationMatrix, this.upVector);
         }
 
         public _getViewMatrix(): Matrix {

+ 6 - 0
src/Engine/babylon.engine.ts

@@ -4523,6 +4523,9 @@
 
         // Loading screen
         public displayLoadingUI(): void {
+            if (!Tools.IsWindowObjectExist()) {
+                return;
+            }
             const loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.displayLoadingUI();
@@ -4530,6 +4533,9 @@
         }
 
         public hideLoadingUI(): void {
+            if (!Tools.IsWindowObjectExist()) {
+                return;
+            }            
             const loadingScreen = this.loadingScreen;
             if (loadingScreen) {
                 loadingScreen.hideLoadingUI();

+ 11 - 3
src/Gamepad/babylon.gamepadManager.ts

@@ -4,9 +4,8 @@
         private _oneGamepadConnected: boolean = false;
 
         private _isMonitoring: boolean = false;
-        private _gamepadEventSupported: boolean = 'GamepadEvent' in window;
-        private _gamepadSupport: () => Array<any> = (navigator.getGamepads ||
-            navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
+        private _gamepadEventSupported: boolean;
+        private _gamepadSupport: () => Array<any>;
 
         public onGamepadConnectedObservable: Observable<Gamepad>;
         public onGamepadDisconnectedObservable = new Observable<Gamepad>();
@@ -15,6 +14,15 @@
         private _onGamepadDisconnectedEvent: (evt: any) => void;
 
         constructor() {
+            if (!Tools.IsWindowObjectExist()) {
+                this._gamepadEventSupported = false;
+            } else  {
+                this._gamepadEventSupported = 'GamepadEvent' in window;
+                this._gamepadSupport = (navigator.getGamepads ||
+                    navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
+            }
+
+
             this.onGamepadConnectedObservable = new Observable<Gamepad>((observer) => {
                 // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
                 for (var i in this._babylonGamepads) {

+ 1 - 1
src/Materials/PBR/babylon.pbrBaseMaterial.ts

@@ -519,7 +519,7 @@
         private static _scaledReflectivity = new Color3();
 
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean { 
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady) {
                     return true;
                 }

+ 1 - 1
src/Materials/babylon.standardMaterial.ts

@@ -511,7 +511,7 @@ module BABYLON {
          * Child classes can use it to update shaders
          */
         public isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean {            
-            if (this.isFrozen) {
+            if (subMesh.effect && this.isFrozen) {
                 if (this._wasPreviouslyReady && subMesh.effect) {
                     return true;
                 }

+ 4 - 2
src/Mesh/babylon.mesh.vertexData.ts

@@ -294,7 +294,9 @@
          * Merges the passed VertexData into the current one.  
          * Returns the modified VertexData.  
          */
-        public merge(other: VertexData): VertexData {
+        public merge(other: VertexData, options?: { tangentLength?: number }): VertexData {
+            options = options || {};
+
             if (other.indices) {
                 if (!this.indices) {
                     this.indices = [];
@@ -312,7 +314,7 @@
             var count = this.positions.length / 3;
 
             this.normals = this._mergeElement(this.normals, other.normals, count * 3);
-            this.tangents = this._mergeElement(this.tangents, other.tangents, count * 4);
+            this.tangents = this._mergeElement(this.tangents, other.tangents, count * (options.tangentLength || 4));
             this.uvs = this._mergeElement(this.uvs, other.uvs, count * 2);
             this.uvs2 = this._mergeElement(this.uvs2, other.uvs2, count * 2);
             this.uvs3 = this._mergeElement(this.uvs3, other.uvs3, count * 2);

+ 28 - 19
src/Particles/babylon.solidParticleSystem.ts

@@ -90,6 +90,7 @@
             private _camera: TargetCamera;
             private _particle: SolidParticle;
             private _camDir: Vector3 = Vector3.Zero();
+            private _camInvertedPosition: Vector3 = Vector3.Zero();
             private _rotMatrix: Matrix = new Matrix();
             private _invertMatrix: Matrix = new Matrix();
             private _rotated: Vector3 = Vector3.Zero();
@@ -111,8 +112,6 @@
             private _mustUnrotateFixedNormals = false;
             private _minimum: Vector3 = Tmp.Vector3[0];
             private _maximum: Vector3 = Tmp.Vector3[1];
-            private _scale: Vector3 = Tmp.Vector3[2];
-            private _translation: Vector3 = Tmp.Vector3[3];
             private _minBbox: Vector3 = Tmp.Vector3[4];
             private _maxBbox: Vector3 = Tmp.Vector3[5];
             private _particlesIntersect: boolean = false;
@@ -121,6 +120,7 @@
                     return (p2.sqDistance - p1.sqDistance);
                 };
             private _depthSortedIndices: IndicesArray;
+            private _needs32Bits: boolean = false;
             public _bSphereOnly: boolean = false;
             public _bSphereRadiusFactor: number = 1.0;
     
@@ -182,7 +182,7 @@
                 }
                 var vertexData = new VertexData();
                 if (this._depthSort) {
-                    this._depthSortedIndices = this._indices.slice();
+                    this._depthSortedIndices = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
                     vertexData.indices = this._depthSortedIndices;
                 }
                 else {
@@ -436,7 +436,11 @@
                 }
     
                 for (i = 0; i < meshInd.length; i++) {
-                    indices.push(p + meshInd[i]);
+                    var current_ind = p + meshInd[i];
+                    indices.push(current_ind);
+                    if (current_ind > 65535) {
+                        this._needs32Bits = true;
+                    }
                 }
     
                 if (this._pickable) {
@@ -626,25 +630,30 @@
                 this._cam_axisZ.y = 0.0;
                 this._cam_axisZ.z = 1.0;
     
+                // cases when the World Matrix is to be computed first
+                if (this.billboard || this._depthSort) {
+                    this.mesh.computeWorldMatrix(true);
+                    this.mesh._worldMatrix.invertToRef(this._invertMatrix);
+                }
                 // if the particles will always face the camera
                 if (this.billboard) {
-                    this.mesh.computeWorldMatrix(true);
                     // compute the camera position and un-rotate it by the current mesh rotation
-                    if (this.mesh._worldMatrix.decompose(this._scale, this._quaternion, this._translation)) {
-                        this._quaternionToRotationMatrix();
-                        this._rotMatrix.invertToRef(this._invertMatrix);
-                        this._camera.getDirectionToRef(this._axisZ, this._camDir);
-                        Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);                  
-                        this._cam_axisZ.normalize();
-                        // same for camera up vector extracted from the cam view matrix
-                        var view = this._camera.getViewMatrix(true);
-                        Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
-                        Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
-                        this._cam_axisY.normalize();
-                        this._cam_axisX.normalize();
-                    }             
+                    this._camera.getDirectionToRef(this._axisZ, this._camDir);
+                    Vector3.TransformNormalToRef(this._camDir, this._invertMatrix, this._cam_axisZ);                  
+                    this._cam_axisZ.normalize();
+                    // same for camera up vector extracted from the cam view matrix
+                    var view = this._camera.getViewMatrix(true);
+                    Vector3.TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], this._invertMatrix, this._cam_axisY);
+                    Vector3.CrossToRef(this._cam_axisY, this._cam_axisZ, this._cam_axisX);
+                    this._cam_axisY.normalize();
+                    this._cam_axisX.normalize();
                 }
     
+                // if depthSort, compute the camera global position in the mesh local system
+                if (this._depthSort) {
+                    Vector3.TransformCoordinatesToRef(this._camera.globalPosition, this._invertMatrix, this._camInvertedPosition); // then un-rotate the camera
+                }
+
                 Matrix.IdentityToRef(this._rotMatrix);
                 var idx = 0;            // current position index in the global array positions32
                 var index = 0;          // position start index in the global array positions32 of the current particle
@@ -718,7 +727,7 @@
                             var dsp = this.depthSortedParticles[p];
                             dsp.ind = this._particle._ind;
                             dsp.indicesLength = this._particle._model._indicesLength;
-                            dsp.sqDistance = Vector3.DistanceSquared(this._particle.position, this._camera.position);
+                            dsp.sqDistance = Vector3.DistanceSquared(this._particle.position, this._camInvertedPosition);
                         }
     
                         // particle vertex loop

+ 35 - 25
tests/nullEngine/app.js

@@ -3,7 +3,6 @@ var LOADERS = require("../../dist/preview release/loaders/babylonjs.loaders");
 global.XMLHttpRequest = require('xhr2').XMLHttpRequest;
 
 var engine = new BABYLON.NullEngine();
-var scene = new BABYLON.Scene(engine);
 
 // //Adding a light
 // var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
@@ -99,33 +98,44 @@ var scene = new BABYLON.Scene(engine);
 //     alpha += 0.01;
 
 // });
-	//Adding a light
-	var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
+// 	//Adding a light
+// 	var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(20, 20, 100), scene);
     
-        //Adding an Arc Rotate Camera
-        var camera = new BABYLON.ArcRotateCamera("Camera", -0.5, 2.2, 100, BABYLON.Vector3.Zero(), scene);
+//         //Adding an Arc Rotate Camera
+//         var camera = new BABYLON.ArcRotateCamera("Camera", -0.5, 2.2, 100, BABYLON.Vector3.Zero(), scene);
     
-        // The first parameter can be used to specify which mesh to import. Here we import all meshes
-        BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs-playground.com/scenes/", "skull.babylon", scene, function (newMeshes) {
-            // Set the target of the camera to the first imported mesh
-            camera.target = newMeshes[0];
+//         // The first parameter can be used to specify which mesh to import. Here we import all meshes
+//         BABYLON.SceneLoader.ImportMesh("", "https://www.babylonjs-playground.com/scenes/", "skull.babylon", scene, function (newMeshes) {
+//             // Set the target of the camera to the first imported mesh
+//             camera.target = newMeshes[0];
     
-            newMeshes[0].material = new BABYLON.StandardMaterial("skull", scene);
-            newMeshes[0].material.emissiveColor = new BABYLON.Color3(0.2, 0.2, 0.2);
-        });
+//             newMeshes[0].material = new BABYLON.StandardMaterial("skull", scene);
+//             newMeshes[0].material.emissiveColor = new BABYLON.Color3(0.2, 0.2, 0.2);
+//         });
     
-        // Create the "God Rays" effect (volumetric light scattering)
-        var godrays = new BABYLON.VolumetricLightScatteringPostProcess('godrays', 1.0, camera, null, 100, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false);
+//         // Create the "God Rays" effect (volumetric light scattering)
+//         var godrays = new BABYLON.VolumetricLightScatteringPostProcess('godrays', 1.0, camera, null, 100, BABYLON.Texture.BILINEAR_SAMPLINGMODE, engine, false);
     
-        // By default it uses a billboard to render the sun, just apply the desired texture
-        // position and scale
-        godrays.mesh.material.diffuseTexture = new BABYLON.Texture('https://www.babylonjs-playground.com/textures/sun.png', scene, true, false, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
-        godrays.mesh.material.diffuseTexture.hasAlpha = true;
-        godrays.mesh.position = new BABYLON.Vector3(-150, 150, 150);
-        godrays.mesh.scaling = new BABYLON.Vector3(350, 350, 350);
+//         // By default it uses a billboard to render the sun, just apply the desired texture
+//         // position and scale
+//         godrays.mesh.material.diffuseTexture = new BABYLON.Texture('https://www.babylonjs-playground.com/textures/sun.png', scene, true, false, BABYLON.Texture.BILINEAR_SAMPLINGMODE);
+//         godrays.mesh.material.diffuseTexture.hasAlpha = true;
+//         godrays.mesh.position = new BABYLON.Vector3(-150, 150, 150);
+//         godrays.mesh.scaling = new BABYLON.Vector3(350, 350, 350);
     
-        light.position = godrays.mesh.position;
-
-engine.runRenderLoop(function() {
-    scene.render();
-})
+//         light.position = godrays.mesh.position;
+
+// engine.runRenderLoop(function() {
+//     scene.render();
+// })
+
+BABYLON.SceneLoader.Load("https://playground.babylonjs.com/scenes/", "skull.babylon", engine, (scene) => {
+    console.log('scene loaded!');
+    for (var index = 0; index < scene.meshes.length; index++) {
+        console.log(scene.meshes[index].name);
+    }    
+    engine.runRenderLoop(function() {
+        scene.render();
+    });
+  
+  }, progress => {}, (scene, err) => console.error('error:', err));