Przeglądaj źródła

Updating mesh.rotate to take in account parent
Moving axis and math to /math

David Catuhe 11 lat temu
rodzic
commit
004ceb976f

Babylon/Mesh/babylon.axis.js → Babylon/Math/babylon.axis.js


Plik diff jest za duży
+ 1961 - 1961
Babylon/Tools/babylon.math.js


+ 8 - 13
Babylon/Mesh/babylon.mesh.js

@@ -37,7 +37,6 @@ var BABYLON = BABYLON || {};
 
         this._localScaling = BABYLON.Matrix.Zero();
         this._localRotation = BABYLON.Matrix.Zero();
-        this._localWorldRotation = BABYLON.Matrix.Zero();
         this._localTranslation = BABYLON.Matrix.Zero();
         this._localBillboard = BABYLON.Matrix.Zero();
         this._localPivotScaling = BABYLON.Matrix.Zero();
@@ -98,17 +97,23 @@ var BABYLON = BABYLON || {};
     };
 
     BABYLON.Mesh.prototype.rotate = function (axis, amount, space) {
-        var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
-
         if (!this.rotationQuaternion) {
             this.rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
             this.rotation = BABYLON.Vector3.Zero();
         }
 
         if (space == BABYLON.Space.LOCAL) {
+            var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
             this.rotationQuaternion = this.rotationQuaternion.multiply(rotationQuaternion);
         }
         else {
+            if (this.parent) {
+                var invertParentWorldMatrix = this.parent.getWorldMatrix().clone();
+                invertParentWorldMatrix.invert();
+
+                axis = BABYLON.Vector3.TransformNormal(axis, invertParentWorldMatrix);
+            }
+            var rotationQuaternion = BABYLON.Quaternion.RotationAxis(axis, amount);
             this.rotationQuaternion = rotationQuaternion.multiply(this.rotationQuaternion);
         }
     };
@@ -248,14 +253,6 @@ var BABYLON = BABYLON || {};
                 return false;
         }
 
-        if (this.worldRotationQuaternion) {
-            if (!this._cache.worldRotationQuaternion.equals(this.worldRotationQuaternion))
-                return false;
-        } else {
-            if (!this._cache.worldRotation.equals(this.worldRotation))
-                return false;
-        }
-
         if (!this._cache.scaling.equals(this.scaling))
             return false;
 
@@ -281,8 +278,6 @@ var BABYLON = BABYLON || {};
         this._cache.scaling = BABYLON.Vector3.Zero();
         this._cache.rotation = BABYLON.Vector3.Zero();
         this._cache.rotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 0);
-        this._cache.worldRotation = BABYLON.Vector3.Zero();
-        this._cache.worldRotationQuaternion = new BABYLON.Quaternion(0, 0, 0, 0);
     };
 
     BABYLON.Mesh.prototype.markAsDirty = function (property) {

+ 0 - 505
Babylon/Shaders/iedefault.fragment.fx

@@ -1,505 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-#define MAP_PROJECTION	4.
-
-// Constants
-uniform vec3 vEyePosition;
-uniform vec3 vAmbientColor;
-uniform vec4 vDiffuseColor;
-uniform vec4 vSpecularColor;
-uniform vec3 vEmissiveColor;
-
-// Input
-varying vec3 vPositionW;
-varying vec3 vNormalW;
-
-#ifdef VERTEXCOLOR
-varying vec3 vColor;
-#endif
-
-// Lights
-#ifdef LIGHT0
-uniform vec4 vLightData0;
-uniform vec3 vLightDiffuse0;
-uniform vec3 vLightSpecular0;
-#ifdef SHADOW0
-varying vec4 vPositionFromLight0;
-uniform sampler2D shadowSampler0;
-#endif
-#ifdef SPOTLIGHT0
-uniform vec4 vLightDirection0;
-#endif
-#ifdef HEMILIGHT0
-uniform vec3 vLightGround0;
-#endif
-#endif
-
-#ifdef LIGHT1
-uniform vec4 vLightData1;
-uniform vec3 vLightDiffuse1;
-uniform vec3 vLightSpecular1;
-#ifdef SHADOW1
-varying vec4 vPositionFromLight1;
-uniform sampler2D shadowSampler1;
-#endif
-#ifdef SPOTLIGHT1
-uniform vec4 vLightDirection1;
-#endif
-#ifdef HEMILIGHT1
-uniform vec3 vLightGround1;
-#endif
-#endif
-
-#ifdef LIGHT2
-uniform vec4 vLightData2;
-uniform vec3 vLightDiffuse2;
-uniform vec3 vLightSpecular2;
-#ifdef SHADOW2
-varying vec4 vPositionFromLight2;
-uniform sampler2D shadowSampler2;
-#endif
-#ifdef SPOTLIGHT2
-uniform vec4 vLightDirection2;
-#endif
-#ifdef HEMILIGHT2
-uniform vec3 vLightGround2;
-#endif
-#endif
-
-#ifdef LIGHT3
-uniform vec4 vLightData3;
-uniform vec3 vLightDiffuse3;
-uniform vec3 vLightSpecular3;
-#ifdef SHADOW3
-varying vec4 vPositionFromLight3;
-uniform sampler2D shadowSampler3;
-#endif
-#ifdef SPOTLIGHT3
-uniform vec4 vLightDirection3;
-#endif
-#ifdef HEMILIGHT3
-uniform vec3 vLightGround3;
-#endif
-#endif
-
-// Samplers
-#ifdef DIFFUSE
-varying vec2 vDiffuseUV;
-uniform sampler2D diffuseSampler;
-uniform vec2 vDiffuseInfos;
-#endif
-
-#ifdef AMBIENT
-varying vec2 vAmbientUV;
-uniform sampler2D ambientSampler;
-uniform vec2 vAmbientInfos;
-#endif
-
-#ifdef OPACITY	
-varying vec2 vOpacityUV;
-uniform sampler2D opacitySampler;
-uniform vec2 vOpacityInfos;
-#endif
-
-#ifdef REFLECTION
-varying vec3 vReflectionUVW;
-uniform samplerCube reflectionCubeSampler;
-uniform sampler2D reflection2DSampler;
-uniform vec3 vReflectionInfos;
-#endif
-
-#ifdef EMISSIVE
-varying vec2 vEmissiveUV;
-uniform vec2 vEmissiveInfos;
-uniform sampler2D emissiveSampler;
-#endif
-
-#ifdef SPECULAR
-varying vec2 vSpecularUV;
-uniform vec2 vSpecularInfos;
-uniform sampler2D specularSampler;
-#endif
-
-// Shadows
-#ifdef SHADOWS
-
-float unpack(vec4 color)
-{
-	const vec4 bitShift = vec4(1. / (255. * 255. * 255.), 1. / (255. * 255.), 1. / 255., 1.);
-	return dot(color, bitShift);
-}
-
-float unpackHalf(vec2 color)
-{
-	return color.x + (color.y / 255.0);
-}
-
-float computeShadow(vec4 vPositionFromLight, sampler2D shadowSampler)
-{
-	vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;
-	vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);
-
-	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)
-	{
-		return 1.0;
-	}
-
-	float shadow = unpack(texture2D(shadowSampler, uv));
-
-	if (depth.z > shadow)
-	{
-		return 0.;
-	}
-	return 1.;
-}
-
-// Thanks to http://devmaster.net/
-float ChebychevInequality(vec2 moments, float t)
-{
-	if (t <= moments.x)
-	{
-		return 1.0;
-	}
-
-	float variance = moments.y - (moments.x * moments.x);
-	variance = max(variance, 0.);
-
-	float d = t - moments.x;
-	return variance / (variance + d * d);
-}
-
-float computeShadowWithVSM(vec4 vPositionFromLight, sampler2D shadowSampler)
-{
-	vec3 depth = vPositionFromLight.xyz / vPositionFromLight.w;
-	vec2 uv = 0.5 * depth.xy + vec2(0.5, 0.5);
-
-	if (uv.x < 0. || uv.x > 1.0 || uv.y < 0. || uv.y > 1.0)
-	{
-		return 1.0;
-	}
-
-	vec4 texel = texture2D(shadowSampler, uv);
-
-	vec2 moments = vec2(unpackHalf(texel.xy), unpackHalf(texel.zw));
-	return clamp(1.3 - ChebychevInequality(moments, depth.z), 0., 1.0);
-}
-#endif
-
-#ifdef CLIPPLANE
-varying float fClipDistance;
-#endif
-
-// Fog
-#ifdef FOG
-
-#define FOGMODE_NONE    0.
-#define FOGMODE_EXP     1.
-#define FOGMODE_EXP2    2.
-#define FOGMODE_LINEAR  3.
-#define E 2.71828
-
-uniform vec4 vFogInfos;
-uniform vec3 vFogColor;
-varying float fFogDistance;
-
-float CalcFogFactor()
-{
-	float fogCoeff = 1.0;
-	float fogStart = vFogInfos.y;
-	float fogEnd = vFogInfos.z;
-	float fogDensity = vFogInfos.w;
-
-	if (FOGMODE_LINEAR == vFogInfos.x)
-	{
-		fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);
-	}
-	else if (FOGMODE_EXP == vFogInfos.x)
-	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);
-	}
-	else if (FOGMODE_EXP2 == vFogInfos.x)
-	{
-		fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);
-	}
-
-	return clamp(fogCoeff, 0.0, 1.0);
-}
-#endif
-
-// Light Computing
-mat3 computeLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor) {
-	mat3 result;
-
-	vec3 lightVectorW;
-	if (lightData.w == 0.)
-	{
-		lightVectorW = normalize(lightData.xyz - vPositionW);
-	}
-	else
-	{
-		lightVectorW = normalize(-lightData.xyz);
-	}
-
-	// diffuse
-	float ndl = max(0., dot(vNormal, lightVectorW));
-
-	// Specular
-	vec3 angleW = normalize(viewDirectionW + lightVectorW);
-	float specComp = max(0., dot(vNormal, angleW));
-	specComp = max(0., pow(specComp, max(1.0, vSpecularColor.a)));
-
-	result[0] = ndl * diffuseColor;
-	result[1] = specComp * specularColor;
-	result[2] = vec3(0.);
-
-	return result;
-}
-
-mat3 computeSpotLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec4 lightDirection, vec3 diffuseColor, vec3 specularColor) {
-	mat3 result;
-
-	vec3 lightVectorW = normalize(lightData.xyz - vPositionW);
-
-	// diffuse
-	float cosAngle = max(0., dot(-lightDirection.xyz, lightVectorW));
-	float spotAtten = 0.0;
-
-	if (cosAngle >= lightDirection.w)
-	{
-		cosAngle = max(0., pow(cosAngle, lightData.w));
-		spotAtten = max(0., (cosAngle - lightDirection.w) / (1. - cosAngle));
-
-		// Diffuse
-		float ndl = max(0., dot(vNormal, -lightDirection.xyz));
-
-		// Specular
-		vec3 angleW = normalize(viewDirectionW - lightDirection.xyz);
-		float specComp = max(0., dot(vNormal, angleW));
-		specComp = pow(specComp, vSpecularColor.a);
-
-		result[0] = ndl * spotAtten * diffuseColor;
-		result[1] = specComp * specularColor * spotAtten;
-		result[2] = vec3(0.);
-
-		return result;
-	}
-
-	result[0] = vec3(0.);
-	result[1] = vec3(0.);
-	result[2] = vec3(0.);
-
-	return result;
-}
-
-mat3 computeHemisphericLighting(vec3 viewDirectionW, vec3 vNormal, vec4 lightData, vec3 diffuseColor, vec3 specularColor, vec3 groundColor) {
-	mat3 result;
-
-	// Diffuse
-	float ndl = dot(vNormal, lightData.xyz) * 0.5 + 0.5;
-
-	// Specular
-	vec3 angleW = normalize(viewDirectionW + lightData.xyz);
-	float specComp = max(0., dot(vNormal, angleW));
-	specComp = pow(specComp, vSpecularColor.a);
-
-	result[0] = mix(groundColor, diffuseColor, ndl);
-	result[1] = specComp * specularColor;
-	result[2] = vec3(0.);
-
-	return result;
-}
-
-void main(void) {
-	// Clip plane
-#ifdef CLIPPLANE
-	if (fClipDistance > 0.0)
-		discard;
-#endif
-
-	vec3 viewDirectionW = normalize(vEyePosition - vPositionW);
-
-	// Base color
-	vec4 baseColor = vec4(1., 1., 1., 1.);
-	vec3 diffuseColor = vDiffuseColor.rgb;
-
-#ifdef VERTEXCOLOR
-	diffuseColor *= vColor;
-#endif
-
-#ifdef DIFFUSE
-	baseColor = texture2D(diffuseSampler, vDiffuseUV);
-
-#ifdef ALPHATEST
-	if (baseColor.a < 0.4)
-		discard;
-#endif
-
-	baseColor.rgb *= vDiffuseInfos.y;
-#endif
-
-	// Bump
-	vec3 normalW = vNormalW;
-
-	// Ambient color
-	vec3 baseAmbientColor = vec3(1., 1., 1.);
-
-#ifdef AMBIENT
-	baseAmbientColor = texture2D(ambientSampler, vAmbientUV).rgb * vAmbientInfos.y;
-#endif
-
-	// Lighting
-	vec3 diffuseBase = vec3(0., 0., 0.);
-	vec3 specularBase = vec3(0., 0., 0.);
-	float shadow = 1.;
-
-#ifdef LIGHT0
-#ifdef SPOTLIGHT0
-	mat3 info = computeSpotLighting(viewDirectionW, normalW, vLightData0, vLightDirection0, vLightDiffuse0, vLightSpecular0);
-#endif
-#ifdef HEMILIGHT0
-	mat3 info = computeHemisphericLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0, vLightGround0);
-#endif
-#ifdef POINTDIRLIGHT0
-	mat3 info = computeLighting(viewDirectionW, normalW, vLightData0, vLightDiffuse0, vLightSpecular0);
-#endif
-#ifdef SHADOW0
-#ifdef SHADOWVSM0
-	shadow = computeShadowWithVSM(vPositionFromLight0, shadowSampler0);
-#else
-	shadow = computeShadow(vPositionFromLight0, shadowSampler0);
-#endif
-#else
-	shadow = 1.;
-#endif
-	diffuseBase += info[0] * shadow;
-	specularBase += info[1] * shadow;
-#endif
-
-#ifdef LIGHT1
-#ifdef SPOTLIGHT1
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData1, vLightDirection1, vLightDiffuse1, vLightSpecular1);
-#endif
-#ifdef HEMILIGHT1
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1, vLightGround1);
-#endif
-#ifdef POINTDIRLIGHT1
-	info = computeLighting(viewDirectionW, normalW, vLightData1, vLightDiffuse1, vLightSpecular1);
-#endif
-#ifdef SHADOW1
-#ifdef SHADOWVSM1
-	shadow = computeShadowWithVSM(vPositionFromLight1, shadowSampler1);
-#else
-	shadow = computeShadow(vPositionFromLight1, shadowSampler1);
-#endif
-#else
-	shadow = 1.;
-#endif
-	diffuseBase += info[0] * shadow;
-	specularBase += info[1] * shadow;
-#endif
-
-#ifdef LIGHT2
-#ifdef SPOTLIGHT2
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData2, vLightDirection2, vLightDiffuse2, vLightSpecular2);
-#endif
-#ifdef HEMILIGHT2
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2, vLightGround2);
-#endif
-#ifdef POINTDIRLIGHT2
-	info = computeLighting(viewDirectionW, normalW, vLightData2, vLightDiffuse2, vLightSpecular2);
-#endif
-#ifdef SHADOW2
-#ifdef SHADOWVSM2
-	shadow = computeShadowWithVSM(vPositionFromLight2, shadowSampler2);
-#else
-	shadow = computeShadow(vPositionFromLight2, shadowSampler2);
-#endif	
-#else
-	shadow = 1.;
-#endif
-	diffuseBase += info[0] * shadow;
-	specularBase += info[1] * shadow;
-#endif
-
-#ifdef LIGHT3
-#ifdef SPOTLIGHT3
-	info = computeSpotLighting(viewDirectionW, normalW, vLightData3, vLightDirection3, vLightDiffuse3, vLightSpecular3);
-#endif
-#ifdef HEMILIGHT3
-	info = computeHemisphericLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3, vLightGround3);
-#endif
-#ifdef POINTDIRLIGHT3
-	info = computeLighting(viewDirectionW, normalW, vLightData3, vLightDiffuse3, vLightSpecular3);
-#endif
-#ifdef SHADOW3
-#ifdef SHADOWVSM3
-	shadow = computeShadowWithVSM(vPositionFromLight3, shadowSampler3);
-#else
-	shadow = computeShadow(vPositionFromLight3, shadowSampler3);
-#endif	
-#else
-	shadow = 1.;
-#endif
-	diffuseBase += info[0] * shadow;
-	specularBase += info[1] * shadow;
-#endif
-
-	// Reflection
-	vec3 reflectionColor = vec3(0., 0., 0.);
-
-#ifdef REFLECTION
-	if (vReflectionInfos.z != 0.0)
-	{
-		reflectionColor = textureCube(reflectionCubeSampler, vReflectionUVW).rgb * vReflectionInfos.y;
-	}
-	else
-	{
-		vec2 coords = vReflectionUVW.xy;
-
-		if (vReflectionInfos.x == MAP_PROJECTION)
-		{
-			coords /= vReflectionUVW.z;
-		}
-
-		coords.y = 1.0 - coords.y;
-
-		reflectionColor = texture2D(reflection2DSampler, coords).rgb * vReflectionInfos.y;
-	}
-#endif
-
-	// Alpha
-	float alpha = vDiffuseColor.a;
-
-#ifdef OPACITY
-	vec4 opacityMap = texture2D(opacitySampler, vOpacityUV);
-	opacityMap.rgb = opacityMap.rgb * vec3(0.3, 0.59, 0.11) * opacityMap.a;
-	alpha *= (opacityMap.x + opacityMap.y + opacityMap.z)* vOpacityInfos.y;
-#endif
-
-	// Emissive
-	vec3 emissiveColor = vEmissiveColor;
-#ifdef EMISSIVE
-	emissiveColor += texture2D(emissiveSampler, vEmissiveUV).rgb * vEmissiveInfos.y;
-#endif
-
-	// Specular map
-	vec3 specularColor = vSpecularColor.rgb;
-#ifdef SPECULAR
-	specularColor = texture2D(specularSampler, vSpecularUV).rgb * vSpecularInfos.y;
-#endif
-
-	// Composition
-	vec3 finalDiffuse = clamp(diffuseBase * diffuseColor + emissiveColor + vAmbientColor, 0.0, 1.0) * baseColor.rgb;
-	vec3 finalSpecular = specularBase * specularColor;
-
-	vec4 color = vec4(finalDiffuse * baseAmbientColor + finalSpecular + reflectionColor, alpha);
-
-#ifdef FOG
-	float fog = CalcFogFactor();
-	color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;
-#endif
-
-	gl_FragColor = color;
-}

+ 0 - 286
Babylon/Shaders/iedefault.vertex.fx

@@ -1,286 +0,0 @@
-#ifdef GL_ES
-precision mediump float;
-#endif
-
-#define MAP_EXPLICIT	0.
-#define MAP_SPHERICAL	1.
-#define MAP_PLANAR		2.
-#define MAP_CUBIC		3.
-#define MAP_PROJECTION	4.
-#define MAP_SKYBOX		5.
-
-// Attributes
-attribute vec3 position;
-attribute vec3 normal;
-#ifdef UV1
-attribute vec2 uv;
-#endif
-#ifdef UV2
-attribute vec2 uv2;
-#endif
-#ifdef VERTEXCOLOR
-attribute vec3 color;
-#endif
-#ifdef BONES
-attribute vec4 matricesIndices;
-attribute vec4 matricesWeights;
-#endif
-
-// Uniforms
-uniform mat4 world;
-uniform mat4 view;
-uniform mat4 viewProjection;
-
-#ifdef DIFFUSE
-varying vec2 vDiffuseUV;
-uniform mat4 diffuseMatrix;
-uniform vec2 vDiffuseInfos;
-#endif
-
-#ifdef AMBIENT
-varying vec2 vAmbientUV;
-uniform mat4 ambientMatrix;
-uniform vec2 vAmbientInfos;
-#endif
-
-#ifdef OPACITY
-varying vec2 vOpacityUV;
-uniform mat4 opacityMatrix;
-uniform vec2 vOpacityInfos;
-#endif
-
-#ifdef REFLECTION
-uniform vec3 vEyePosition;
-varying vec3 vReflectionUVW;
-uniform vec3 vReflectionInfos;
-uniform mat4 reflectionMatrix;
-#endif
-
-#ifdef EMISSIVE
-varying vec2 vEmissiveUV;
-uniform vec2 vEmissiveInfos;
-uniform mat4 emissiveMatrix;
-#endif
-
-#ifdef SPECULAR
-varying vec2 vSpecularUV;
-uniform vec2 vSpecularInfos;
-uniform mat4 specularMatrix;
-#endif
-
-#ifdef BUMP
-varying vec2 vBumpUV;
-uniform vec2 vBumpInfos;
-uniform mat4 bumpMatrix;
-#endif
-
-#ifdef BONES
-uniform mat4 mBones[BonesPerMesh];
-#endif
-
-// Output
-varying vec3 vPositionW;
-varying vec3 vNormalW;
-
-#ifdef VERTEXCOLOR
-varying vec3 vColor;
-#endif
-
-#ifdef CLIPPLANE
-uniform vec4 vClipPlane;
-varying float fClipDistance;
-#endif
-
-#ifdef FOG
-varying float fFogDistance;
-#endif
-
-#ifdef SHADOWS
-#ifdef LIGHT0
-uniform mat4 lightMatrix0;
-varying vec4 vPositionFromLight0;
-#endif
-#ifdef LIGHT1
-uniform mat4 lightMatrix1;
-varying vec4 vPositionFromLight1;
-#endif
-#ifdef LIGHT2
-uniform mat4 lightMatrix2;
-varying vec4 vPositionFromLight2;
-#endif
-#ifdef LIGHT3
-uniform mat4 lightMatrix3;
-varying vec4 vPositionFromLight3;
-#endif
-#endif
-
-#ifdef REFLECTION
-vec3 computeReflectionCoords(float mode, vec4 worldPos, vec3 worldNormal)
-{
-	if (mode == MAP_SPHERICAL)
-	{
-		vec3 coords = vec3(view * vec4(worldNormal, 0.0));
-
-		return vec3(reflectionMatrix * vec4(coords, 1.0));
-	}
-	else if (mode == MAP_PLANAR)
-	{
-		vec3 viewDir = worldPos.xyz - vEyePosition;
-		vec3 coords = normalize(reflect(viewDir, worldNormal));
-
-		return vec3(reflectionMatrix * vec4(coords, 1));
-	}
-	else if (mode == MAP_CUBIC)
-	{
-		vec3 viewDir = worldPos.xyz - vEyePosition;
-		vec3 coords = reflect(viewDir, worldNormal);
-
-		return vec3(reflectionMatrix * vec4(coords, 0));
-	}
-	else if (mode == MAP_PROJECTION)
-	{
-		return vec3(reflectionMatrix * (view * worldPos));
-	}
-	else if (mode == MAP_SKYBOX)
-	{
-		return position;
-	}
-
-	return vec3(0, 0, 0);
-}
-#endif
-
-void main(void) {
-	mat4 finalWorld;
-
-#ifdef BONES
-	mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
-	mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
-	mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
-
-#ifdef BONES4
-	mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
-	finalWorld = world * (m0 + m1 + m2 + m3);
-#else
-	finalWorld = world * (m0 + m1 + m2);
-#endif 
-
-#else
-	finalWorld = world;
-#endif
-
-	gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
-
-	vec4 worldPos = finalWorld * vec4(position, 1.0);
-	vPositionW = vec3(worldPos);
-	vNormalW = normalize(vec3(finalWorld * vec4(normal, 0.0)));
-
-	// Texture coordinates
-#ifndef UV1
-	vec2 uv = vec2(0., 0.);
-#endif
-#ifndef UV2
-	vec2 uv2 = vec2(0., 0.);
-#endif
-
-#ifdef DIFFUSE
-	if (vDiffuseInfos.x == 0.)
-	{
-		vDiffuseUV = vec2(diffuseMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vDiffuseUV = vec2(diffuseMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-#ifdef AMBIENT
-	if (vAmbientInfos.x == 0.)
-	{
-		vAmbientUV = vec2(ambientMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vAmbientUV = vec2(ambientMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-#ifdef OPACITY
-	if (vOpacityInfos.x == 0.)
-	{
-		vOpacityUV = vec2(opacityMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vOpacityUV = vec2(opacityMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-#ifdef REFLECTION
-	vReflectionUVW = computeReflectionCoords(vReflectionInfos.x, vec4(vPositionW, 1.0), vNormalW);
-#endif
-
-#ifdef EMISSIVE
-	if (vEmissiveInfos.x == 0.)
-	{
-		vEmissiveUV = vec2(emissiveMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vEmissiveUV = vec2(emissiveMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-#ifdef SPECULAR
-	if (vSpecularInfos.x == 0.)
-	{
-		vSpecularUV = vec2(specularMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vSpecularUV = vec2(specularMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-#ifdef BUMP
-	if (vBumpInfos.x == 0.)
-	{
-		vBumpUV = vec2(bumpMatrix * vec4(uv, 1.0, 0.0));
-	}
-	else
-	{
-		vBumpUV = vec2(bumpMatrix * vec4(uv2, 1.0, 0.0));
-	}
-#endif
-
-	// Clip plane
-#ifdef CLIPPLANE
-	fClipDistance = dot(worldPos, vClipPlane);
-#endif
-
-	// Fog
-#ifdef FOG
-	fFogDistance = (view * worldPos).z;
-#endif
-
-	// Shadows
-#ifdef SHADOWS
-#ifdef LIGHT0
-	vPositionFromLight0 = lightMatrix0 * vec4(position, 1.0);
-#endif
-#ifdef LIGHT1
-	vPositionFromLight1 = lightMatrix1 * vec4(position, 1.0);
-#endif
-#ifdef LIGHT2
-	vPositionFromLight2 = lightMatrix2 * vec4(position, 1.0);
-#endif
-#ifdef LIGHT3
-	vPositionFromLight3 = lightMatrix3 * vec4(position, 1.0);
-#endif
-#endif
-
-	// Vertex color
-#ifdef VERTEXCOLOR
-	vColor = color;
-#endif
-}

+ 0 - 754
Babylon/Tools/babylon.sceneLoader.js

@@ -1,754 +0,0 @@
-"use strict";
-
-var BABYLON = BABYLON || {};
-
-(function () {
-    var loadCubeTexture = function (rootUrl, parsedTexture, scene) {
-        var texture = new BABYLON.CubeTexture(rootUrl + parsedTexture.name, scene);
-
-        texture.name = parsedTexture.name;
-        texture.hasAlpha = parsedTexture.hasAlpha;
-        texture.level = parsedTexture.level;
-        texture.coordinatesMode = parsedTexture.coordinatesMode;
-
-        return texture;
-    };
-
-    var loadTexture = function (rootUrl, parsedTexture, scene) {
-        if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
-            return null;
-        }
-
-        if (parsedTexture.isCube) {
-            return loadCubeTexture(rootUrl, parsedTexture, scene);
-        }
-
-        var texture;
-
-        if (parsedTexture.mirrorPlane) {
-            texture = new BABYLON.MirrorTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-            texture._waitingRenderList = parsedTexture.renderList;
-            texture.mirrorPlane = BABYLON.Plane.FromArray(parsedTexture.mirrorPlane);
-        } else if (parsedTexture.isRenderTarget) {
-            texture = new BABYLON.RenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene);
-            texture._waitingRenderList = parsedTexture.renderList;
-        } else {
-            texture = new BABYLON.Texture(rootUrl + parsedTexture.name, scene);
-        }
-
-        texture.name = parsedTexture.name;
-        texture.hasAlpha = parsedTexture.hasAlpha;
-        texture.level = parsedTexture.level;
-
-        texture.coordinatesIndex = parsedTexture.coordinatesIndex;
-        texture.coordinatesMode = parsedTexture.coordinatesMode;
-        texture.uOffset = parsedTexture.uOffset;
-        texture.vOffset = parsedTexture.vOffset;
-        texture.uScale = parsedTexture.uScale;
-        texture.vScale = parsedTexture.vScale;
-        texture.uAng = parsedTexture.uAng;
-        texture.vAng = parsedTexture.vAng;
-        texture.wAng = parsedTexture.wAng;
-
-        texture.wrapU = parsedTexture.wrapU;
-        texture.wrapV = parsedTexture.wrapV;
-
-        // Animations
-        if (parsedTexture.animations) {
-            for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
-                var parsedAnimation = parsedTexture.animations[animationIndex];
-
-                texture.animations.push(parseAnimation(parsedAnimation));
-            }
-        }
-
-        return texture;
-    };
-
-    var parseSkeleton = function (parsedSkeleton, scene) {
-        var skeleton = new BABYLON.Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
-
-        for (var index = 0; index < parsedSkeleton.bones.length; index++) {
-            var parsedBone = parsedSkeleton.bones[index];
-
-            var parentBone = null;
-            if (parsedBone.parentBoneIndex > -1) {
-                parentBone = skeleton.bones[parsedBone.parentBoneIndex];
-            }
-
-            var bone = new BABYLON.Bone(parsedBone.name, skeleton, parentBone, BABYLON.Matrix.FromArray(parsedBone.matrix));
-
-            if (parsedBone.animation) {
-                bone.animations.push(parseAnimation(parsedBone.animation));
-            }
-        }
-
-        return skeleton;
-    };
-
-    var parseMaterial = function (parsedMaterial, scene, rootUrl) {
-        var material;
-        material = new BABYLON.StandardMaterial(parsedMaterial.name, scene);
-
-        material.ambientColor = BABYLON.Color3.FromArray(parsedMaterial.ambient);
-        material.diffuseColor = BABYLON.Color3.FromArray(parsedMaterial.diffuse);
-        material.specularColor = BABYLON.Color3.FromArray(parsedMaterial.specular);
-        material.specularPower = parsedMaterial.specularPower;
-        material.emissiveColor = BABYLON.Color3.FromArray(parsedMaterial.emissive);
-
-        material.alpha = parsedMaterial.alpha;
-
-        material.id = parsedMaterial.id;
-        material.backFaceCulling = parsedMaterial.backFaceCulling;
-
-        if (parsedMaterial.diffuseTexture) {
-            material.diffuseTexture = loadTexture(rootUrl, parsedMaterial.diffuseTexture, scene);
-        }
-
-        if (parsedMaterial.ambientTexture) {
-            material.ambientTexture = loadTexture(rootUrl, parsedMaterial.ambientTexture, scene);
-        }
-
-        if (parsedMaterial.opacityTexture) {
-            material.opacityTexture = loadTexture(rootUrl, parsedMaterial.opacityTexture, scene);
-        }
-
-        if (parsedMaterial.reflectionTexture) {
-            material.reflectionTexture = loadTexture(rootUrl, parsedMaterial.reflectionTexture, scene);
-        }
-
-        if (parsedMaterial.emissiveTexture) {
-            material.emissiveTexture = loadTexture(rootUrl, parsedMaterial.emissiveTexture, scene);
-        }
-
-        if (parsedMaterial.specularTexture) {
-            material.specularTexture = loadTexture(rootUrl, parsedMaterial.specularTexture, scene);
-        }
-
-        if (parsedMaterial.bumpTexture) {
-            material.bumpTexture = loadTexture(rootUrl, parsedMaterial.bumpTexture, scene);
-        }
-
-        return material;
-    };
-
-    var parseMaterialById = function (id, parsedData, scene, rootUrl) {
-        for (var index = 0; index < parsedData.materials.length; index++) {
-            var parsedMaterial = parsedData.materials[index];
-            if (parsedMaterial.id === id) {
-                return parseMaterial(parsedMaterial, scene, rootUrl);
-            }
-        }
-
-        return null;
-    };
-
-    var parseMultiMaterial = function (parsedMultiMaterial, scene) {
-        var multiMaterial = new BABYLON.MultiMaterial(parsedMultiMaterial.name, scene);
-
-        multiMaterial.id = parsedMultiMaterial.id;
-
-        for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
-            var subMatId = parsedMultiMaterial.materials[matIndex];
-
-            if (subMatId) {
-                multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
-            } else {
-                multiMaterial.subMaterials.push(null);
-            }
-        }
-
-        return multiMaterial;
-    };
-
-    var parseLensFlareSystem = function (parsedLensFlareSystem, scene, rootUrl) {
-        var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
-
-        var lensFlareSystem = new BABYLON.LensFlareSystem("lensFlareSystem#" + parsedLensFlareSystem.emitterId, emitter, scene);
-        lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
-
-        for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
-            var parsedFlare = parsedLensFlareSystem.flares[index];
-            var flare = new BABYLON.LensFlare(parsedFlare.size, parsedFlare.position, BABYLON.Color3.FromArray(parsedFlare.color), rootUrl + parsedFlare.textureName, lensFlareSystem);
-        }
-
-        return lensFlareSystem;
-    };
-
-    var parseParticleSystem = function (parsedParticleSystem, scene, rootUrl) {
-        var emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
-
-        var particleSystem = new BABYLON.ParticleSystem("particles#" + emitter.name, parsedParticleSystem.capacity, scene);
-        if (parsedParticleSystem.textureName) {
-            particleSystem.particleTexture = new BABYLON.Texture(rootUrl + parsedParticleSystem.textureName, scene);
-            particleSystem.particleTexture.name = parsedParticleSystem.textureName;
-        }
-        particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
-        particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
-        particleSystem.minSize = parsedParticleSystem.minSize;
-        particleSystem.maxSize = parsedParticleSystem.maxSize;
-        particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
-        particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
-        particleSystem.emitter = emitter;
-        particleSystem.emitRate = parsedParticleSystem.emitRate;
-        particleSystem.minEmitBox = BABYLON.Vector3.FromArray(parsedParticleSystem.minEmitBox);
-        particleSystem.maxEmitBox = BABYLON.Vector3.FromArray(parsedParticleSystem.maxEmitBox);
-        particleSystem.gravity = BABYLON.Vector3.FromArray(parsedParticleSystem.gravity);
-        particleSystem.direction1 = BABYLON.Vector3.FromArray(parsedParticleSystem.direction1);
-        particleSystem.direction2 = BABYLON.Vector3.FromArray(parsedParticleSystem.direction2);
-        particleSystem.color1 = BABYLON.Color4.FromArray(parsedParticleSystem.color1);
-        particleSystem.color2 = BABYLON.Color4.FromArray(parsedParticleSystem.color2);
-        particleSystem.colorDead = BABYLON.Color4.FromArray(parsedParticleSystem.colorDead);
-        particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
-        particleSystem.targetStopDuration = parsedParticleSystem.targetStopFrame;
-        particleSystem.textureMask = BABYLON.Color4.FromArray(parsedParticleSystem.textureMask);
-        particleSystem.blendMode = parsedParticleSystem.blendMode;
-        particleSystem.start();
-
-        return particleSystem;
-    };
-
-    var parseShadowGenerator = function (parsedShadowGenerator, scene) {
-        var light = scene.getLightByID(parsedShadowGenerator.lightId);
-        var shadowGenerator = new BABYLON.ShadowGenerator(parsedShadowGenerator.mapSize, light);
-
-        for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
-            var mesh = scene.getMeshByID(parsedShadowGenerator.renderList[meshIndex]);
-
-            shadowGenerator.getShadowMap().renderList.push(mesh);
-        }
-
-        shadowGenerator.useVarianceShadowMap = parsedShadowGenerator.useVarianceShadowMap;
-
-        return shadowGenerator;
-    };
-
-    var parseAnimation = function (parsedAnimation) {
-        var animation = new BABYLON.Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
-
-        var dataType = parsedAnimation.dataType;
-        var keys = [];
-        for (var index = 0; index < parsedAnimation.keys.length; index++) {
-            var key = parsedAnimation.keys[index];
-
-            var data;
-
-            switch (dataType) {
-                case BABYLON.Animation.ANIMATIONTYPE_FLOAT:
-                    data = key.values[0];
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_QUATERNION:
-                    data = BABYLON.Quaternion.FromArray(key.values);
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_MATRIX:
-                    data = BABYLON.Matrix.FromArray(key.values);
-                    break;
-                case BABYLON.Animation.ANIMATIONTYPE_VECTOR3:
-                default:
-                    data = BABYLON.Vector3.FromArray(key.values);
-                    break;
-            }
-
-            keys.push({
-                frame: key.frame,
-                value: data
-            });
-        }
-
-        animation.setKeys(keys);
-
-        return animation;
-    };
-
-    var parseLight = function (parsedLight, scene) {
-        var light;
-
-        switch (parsedLight.type) {
-            case 0:
-                light = new BABYLON.PointLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.position), scene);
-                break;
-            case 1:
-                light = new BABYLON.DirectionalLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.direction), scene);
-                light.position = BABYLON.Vector3.FromArray(parsedLight.position);
-                break;
-            case 2:
-                light = new BABYLON.SpotLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.position), BABYLON.Vector3.FromArray(parsedLight.direction), parsedLight.angle, parsedLight.exponent, scene);
-                break;
-            case 3:
-                light = new BABYLON.HemisphericLight(parsedLight.name, BABYLON.Vector3.FromArray(parsedLight.direction), scene);
-                light.groundColor = BABYLON.Color3.FromArray(parsedLight.groundColor);
-                break;
-        }
-
-        light.id = parsedLight.id;
-
-        if (parsedLight.intensity) {
-            light.intensity = parsedLight.intensity;
-        }
-        light.diffuse = BABYLON.Color3.FromArray(parsedLight.diffuse);
-        light.specular = BABYLON.Color3.FromArray(parsedLight.specular);
-    };
-
-    var parseCamera = function (parsedCamera, scene) {
-        var camera = new BABYLON.FreeCamera(parsedCamera.name, BABYLON.Vector3.FromArray(parsedCamera.position), scene);
-        camera.id = parsedCamera.id;
-
-        // Parent
-        if (parsedCamera.parentId) {
-            camera._waitingParentId = parsedCamera.parentId;
-        }
-
-        // Target
-        if (parsedCamera.target) {
-            camera.setTarget(BABYLON.Vector3.FromArray(parsedCamera.target));
-        } else {
-            camera.rotation = BABYLON.Vector3.FromArray(parsedCamera.rotation);
-        }
-
-        // Locked target
-        if (parsedCamera.lockedTargetId) {
-            camera._waitingLockedTargetId = parsedCamera.lockedTargetId;
-        }
-
-        camera.fov = parsedCamera.fov;
-        camera.minZ = parsedCamera.minZ;
-        camera.maxZ = parsedCamera.maxZ;
-
-        camera.speed = parsedCamera.speed;
-        camera.inertia = parsedCamera.inertia;
-
-        camera.checkCollisions = parsedCamera.checkCollisions;
-        camera.applyGravity = parsedCamera.applyGravity;
-        if (parsedCamera.ellipsoid) {
-            camera.ellipsoid = BABYLON.Vector3.FromArray(parsedCamera.ellipsoid);
-        }
-
-        // Animations
-        if (parsedCamera.animations) {
-            for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
-                var parsedAnimation = parsedCamera.animations[animationIndex];
-
-                camera.animations.push(parseAnimation(parsedAnimation));
-            }
-        }
-
-        if (parsedCamera.autoAnimate) {
-            scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, 1.0);
-        }
-
-        return camera;
-    };
-
-    var parseMesh = function (parsedMesh, scene, rootUrl) {
-        var mesh = new BABYLON.Mesh(parsedMesh.name, scene);
-        mesh.id = parsedMesh.id;
-
-        mesh.position = BABYLON.Vector3.FromArray(parsedMesh.position);
-        if (parsedMesh.rotation) {
-            mesh.rotation = BABYLON.Vector3.FromArray(parsedMesh.rotation);
-        } else if (parsedMesh.rotationQuaternion) {
-            mesh.rotationQuaternion = BABYLON.Quaternion.FromArray(parsedMesh.rotationQuaternion);
-        }
-        mesh.scaling = BABYLON.Vector3.FromArray(parsedMesh.scaling);
-
-        if (parsedMesh.localMatrix) {
-            mesh.setPivotMatrix(BABYLON.Matrix.FromArray(parsedMesh.localMatrix));
-        }
-
-        mesh.setEnabled(parsedMesh.isEnabled);
-        mesh.isVisible = parsedMesh.isVisible;
-        mesh.infiniteDistance = parsedMesh.infiniteDistance;
-
-        mesh.receiveShadows = parsedMesh.receiveShadows;
-
-        mesh.billboardMode = parsedMesh.billboardMode;
-
-        if (parsedMesh.visibility !== undefined) {
-            mesh.visibility = parsedMesh.visibility;
-        }
-
-        mesh.checkCollisions = parsedMesh.checkCollisions;
-        mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
-
-        // Parent
-        if (parsedMesh.parentId) {
-            mesh.parent = scene.getLastEntryByID(parsedMesh.parentId);
-        }
-
-        // Geometry
-        if (parsedMesh.delayLoadingFile) {
-            mesh.delayLoadState = BABYLON.Engine.DELAYLOADSTATE_NOTLOADED;
-            mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
-            mesh._boundingInfo = new BABYLON.BoundingInfo(BABYLON.Vector3.FromArray(parsedMesh.boundingBoxMinimum), BABYLON.Vector3.FromArray(parsedMesh.boundingBoxMaximum));
-
-            mesh._delayInfo = [];
-            if (parsedMesh.hasUVs) {
-                mesh._delayInfo.push(BABYLON.VertexBuffer.UVKind);
-            }
-
-            if (parsedMesh.hasUVs2) {
-                mesh._delayInfo.push(BABYLON.VertexBuffer.UV2Kind);
-            }
-
-            if (parsedMesh.hasColors) {
-                mesh._delayInfo.push(BABYLON.VertexBuffer.ColorKind);
-            }
-
-            if (parsedMesh.hasMatricesIndices) {
-                mesh._delayInfo.push(BABYLON.VertexBuffer.MatricesIndicesKind);
-            }
-
-            if (parsedMesh.hasMatricesWeights) {
-                mesh._delayInfo.push(BABYLON.VertexBuffer.MatricesWeightsKind);
-            }
-
-        } else {
-            BABYLON.SceneLoader._ImportGeometry(parsedMesh, mesh);
-        }
-
-        // Material
-        if (parsedMesh.materialId) {
-            mesh.setMaterialByID(parsedMesh.materialId);
-        } else {
-            mesh.material = null;
-        }
-
-        // Skeleton
-        if (parsedMesh.skeletonId > -1) {
-            mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
-        }
-
-        // Physics
-        if (parsedMesh.physicsImpostor) {
-            if (!scene.isPhysicsEnabled()) {
-                scene.enablePhysics();
-            }
-
-            switch (parsedMesh.physicsImpostor) {
-                case 1: // BOX
-                    mesh.setPhysicsState({ impostor: BABYLON.PhysicsEngine.BoxImpostor, mass: parsedMesh.physicsMass, friction: parsedMesh.physicsFriction, restitution: parsedMesh.physicsRestitution });
-                    break;
-                case 2: // SPHERE
-                    mesh.setPhysicsState({ impostor: BABYLON.PhysicsEngine.SphereImpostor, mass: parsedMesh.physicsMass, friction: parsedMesh.physicsFriction, restitution: parsedMesh.physicsRestitution });
-                    break;
-            }
-        }
-
-        // Animations
-        if (parsedMesh.animations) {
-            for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
-                var parsedAnimation = parsedMesh.animations[animationIndex];
-
-                mesh.animations.push(parseAnimation(parsedAnimation));
-            }
-        }
-
-        if (parsedMesh.autoAnimate) {
-            scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, 1.0);
-        }
-
-        return mesh;
-    };
-
-
-    var isDescendantOf = function (mesh, names, hierarchyIds) {
-        names = (names instanceof Array) ? names : [names];
-        for (var i in names) {
-            if (mesh.name === names[i]) {
-                hierarchyIds.push(mesh.id);
-                return true;
-            }
-        }
-
-        if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
-            hierarchyIds.push(mesh.id);
-            return true;
-        }
-
-        return false;
-    };
-
-    BABYLON.SceneLoader = {
-        _ImportGeometry: function (parsedGeometry, mesh) {
-            // Geometry
-            if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
-                mesh.setVerticesData(parsedGeometry.positions, BABYLON.VertexBuffer.PositionKind, false);
-                mesh.setVerticesData(parsedGeometry.normals, BABYLON.VertexBuffer.NormalKind, false);
-
-                if (parsedGeometry.uvs) {
-                    mesh.setVerticesData(parsedGeometry.uvs, BABYLON.VertexBuffer.UVKind, false);
-                }
-
-                if (parsedGeometry.uvs2) {
-                    mesh.setVerticesData(parsedGeometry.uvs2, BABYLON.VertexBuffer.UV2Kind, false);
-                }
-
-                if (parsedGeometry.colors) {
-                    mesh.setVerticesData(parsedGeometry.colors, BABYLON.VertexBuffer.ColorKind, false);
-                }
-
-                if (parsedGeometry.matricesIndices) {
-                    if (!parsedGeometry.matricesIndices._isExpanded) {
-                        var floatIndices = [];
-
-                        for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
-                            var matricesIndex = parsedGeometry.matricesIndices[i];
-
-                            floatIndices.push(matricesIndex & 0x000000FF);
-                            floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
-                            floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
-                            floatIndices.push(matricesIndex >> 24);
-                        }
-
-                        mesh.setVerticesData(floatIndices, BABYLON.VertexBuffer.MatricesIndicesKind, false);
-                    } else {
-                        delete parsedGeometry.matricesIndices._isExpanded;
-                        mesh.setVerticesData(parsedGeometry.matricesIndices, BABYLON.VertexBuffer.MatricesIndicesKind, false);
-                    }
-                }
-
-                if (parsedGeometry.matricesWeights) {
-                    mesh.setVerticesData(parsedGeometry.matricesWeights, BABYLON.VertexBuffer.MatricesWeightsKind, false);
-                }
-
-                mesh.setIndices(parsedGeometry.indices);
-            }
-
-            // SubMeshes
-            if (parsedGeometry.subMeshes) {
-                mesh.subMeshes = [];
-                for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
-                    var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
-
-                    var subMesh = new BABYLON.SubMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
-                }
-            }
-
-            // Update
-            mesh.computeWorldMatrix(true);
-
-            // Flat shading
-            if (mesh._shouldGenerateFlatShading) {
-                mesh.convertToFlatShadedMesh();
-                delete mesh._shouldGenerateFlatShading;
-            }
-
-            var scene = mesh.getScene();
-            if (scene._selectionOctree) {
-                scene._selectionOctree.addMesh(mesh);
-            }
-        },
-        ImportMesh: function (meshesNames, rootUrl, sceneFilename, scene, then, progressCallBack) {
-            // Checking if a manifest file has been set for this scene and if offline mode has been requested
-            var database = new BABYLON.Database(rootUrl + sceneFilename);
-            scene.database = database;
-
-            BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {
-                var parsedData = JSON.parse(data);
-
-                // Meshes
-                var meshes = [];
-                var particleSystems = [];
-                var skeletons = [];
-                var loadedSkeletonsIds = [];
-                var loadedMaterialsIds = [];
-                var hierarchyIds = [];
-                for (var index = 0; index < parsedData.meshes.length; index++) {
-                    var parsedMesh = parsedData.meshes[index];
-
-                    if (!meshesNames || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
-                        if (meshesNames instanceof Array) {
-                            // Remove found mesh name from list.
-                            delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
-                        }
-
-                        // Material ?
-                        if (parsedMesh.materialId) {
-                            var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
-
-                            if (!materialFound) {
-                                for (var multimatIndex = 0; multimatIndex < parsedData.multiMaterials.length; multimatIndex++) {
-                                    var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
-                                    if (parsedMultiMaterial.id == parsedMesh.materialId) {
-                                        for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
-                                            var subMatId = parsedMultiMaterial.materials[matIndex];
-                                            loadedMaterialsIds.push(subMatId);
-                                            parseMaterialById(subMatId, parsedData, scene, rootUrl);
-                                        }
-
-                                        loadedMaterialsIds.push(parsedMultiMaterial.id);
-                                        parseMultiMaterial(parsedMultiMaterial, scene);
-                                        materialFound = true;
-                                        break;
-                                    }
-                                }
-                            }
-
-                            if (!materialFound) {
-                                loadedMaterialsIds.push(parsedMesh.materialId);
-                                parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
-                            }
-                        }
-
-                        // Skeleton ?
-                        if (parsedMesh.skeletonId > -1 && scene.skeletons) {
-                            var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
-
-                            if (!skeletonAlreadyLoaded) {
-                                for (var skeletonIndex = 0; skeletonIndex < parsedData.skeletons.length; skeletonIndex++) {
-                                    var parsedSkeleton = parsedData.skeletons[skeletonIndex];
-
-                                    if (parsedSkeleton.id === parsedMesh.skeletonId) {
-                                        skeletons.push(parseSkeleton(parsedSkeleton, scene));
-                                        loadedSkeletonsIds.push(parsedSkeleton.id);
-                                    }
-                                }
-                            }
-                        }
-
-                        var mesh = parseMesh(parsedMesh, scene, rootUrl);
-                        meshes.push(mesh);
-                    }
-                }
-
-                // Particles
-                if (parsedData.particleSystems) {
-                    for (var index = 0; index < parsedData.particleSystems.length; index++) {
-                        var parsedParticleSystem = parsedData.particleSystems[index];
-
-                        if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
-                            particleSystems.push(parseParticleSystem(parsedParticleSystem, scene, rootUrl));
-                        }
-                    }
-                }
-
-                if (then) {
-                    then(meshes, particleSystems, skeletons);
-                }
-            }, progressCallBack, database);
-        },
-        Load: function (rootUrl, sceneFilename, engine, then, progressCallBack) {
-            function loadSceneFromData(data) {
-                var parsedData = JSON.parse(data);
-                var scene = new BABYLON.Scene(engine);
-                scene.database = database;
-
-                // Scene
-                scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading;
-                scene.autoClear = parsedData.autoClear;
-                scene.clearColor = BABYLON.Color3.FromArray(parsedData.clearColor);
-                scene.ambientColor = BABYLON.Color3.FromArray(parsedData.ambientColor);
-                scene.gravity = BABYLON.Vector3.FromArray(parsedData.gravity);
-
-                // Fog
-                if (parsedData.fogMode && parsedData.fogMode !== 0) {
-                    scene.fogMode = parsedData.fogMode;
-                    scene.fogColor = BABYLON.Color3.FromArray(parsedData.fogColor);
-                    scene.fogStart = parsedData.fogStart;
-                    scene.fogEnd = parsedData.fogEnd;
-                    scene.fogDensity = parsedData.fogDensity;
-                }
-
-                // Lights
-                for (var index = 0; index < parsedData.lights.length; index++) {
-                    var parsedLight = parsedData.lights[index];
-                    parseLight(parsedLight, scene);
-                }
-
-                // Cameras
-                for (var index = 0; index < parsedData.cameras.length; index++) {
-                    var parsedCamera = parsedData.cameras[index];
-                    parseCamera(parsedCamera, scene);
-                }
-
-                if (parsedData.activeCameraID) {
-                    scene.activeCameraByID(parsedData.activeCameraID);
-                }
-
-                // Materials
-                if (parsedData.materials) {
-                    for (var index = 0; index < parsedData.materials.length; index++) {
-                        var parsedMaterial = parsedData.materials[index];
-                        parseMaterial(parsedMaterial, scene, rootUrl);
-                    }
-                }
-
-                if (parsedData.multiMaterials) {
-                    for (var index = 0; index < parsedData.multiMaterials.length; index++) {
-                        var parsedMultiMaterial = parsedData.multiMaterials[index];
-                        parseMultiMaterial(parsedMultiMaterial, scene);
-                    }
-                }
-
-                // Skeletons
-                if (parsedData.skeletons) {
-                    for (var index = 0; index < parsedData.skeletons.length; index++) {
-                        var parsedSkeleton = parsedData.skeletons[index];
-                        parseSkeleton(parsedSkeleton, scene);
-                    }
-                }
-
-                // Meshes
-                for (var index = 0; index < parsedData.meshes.length; index++) {
-                    var parsedMesh = parsedData.meshes[index];
-                    parseMesh(parsedMesh, scene, rootUrl);
-                }
-
-                // Connecting cameras parents and locked target
-                for (var index = 0; index < scene.cameras.length; index++) {
-                    var camera = scene.cameras[index];
-                    if (camera._waitingParentId) {
-                        camera.parent = scene.getLastEntryByID(camera._waitingParentId);
-                        delete camera._waitingParentId;
-                    }
-
-                    if (camera._waitingLockedTargetId) {
-                        camera.lockedTarget = scene.getLastEntryByID(camera._waitingLockedTargetId);
-                        delete camera._waitingLockedTargetId;
-                    }
-                }
-
-                // Particles Systems
-                if (parsedData.particleSystems) {
-                    for (var index = 0; index < parsedData.particleSystems.length; index++) {
-                        var parsedParticleSystem = parsedData.particleSystems[index];
-                        parseParticleSystem(parsedParticleSystem, scene, rootUrl);
-                    }
-                }
-
-                // Lens flares
-                if (parsedData.lensFlareSystems) {
-                    for (var index = 0; index < parsedData.lensFlareSystems.length; index++) {
-                        var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
-                        parseLensFlareSystem(parsedLensFlareSystem, scene, rootUrl);
-                    }
-                }
-
-                // Shadows
-                if (parsedData.shadowGenerators) {
-                    for (var index = 0; index < parsedData.shadowGenerators.length; index++) {
-                        var parsedShadowGenerator = parsedData.shadowGenerators[index];
-
-                        parseShadowGenerator(parsedShadowGenerator, scene);
-                    }
-                }
-
-                // Finish
-                if (then) {
-                    then(scene);
-                }
-            };
-
-            if (rootUrl.indexOf("file:") === -1) {
-                // Checking if a manifest file has been set for this scene and if offline mode has been requested
-                var database = new BABYLON.Database(rootUrl + sceneFilename);
-
-                BABYLON.Tools.LoadFile(rootUrl + sceneFilename, loadSceneFromData, progressCallBack, database);
-            }
-                // Loading file from disk via input file or drag'n'drop
-            else {
-                BABYLON.Tools.ReadFile(sceneFilename, loadSceneFromData, progressCallBack);
-            }
-        }
-    };
-})();

+ 2 - 2
Tools/BuildOurOwnBabylonJS/BuildOurOwnBabylonJS/babylonJS.xml

@@ -59,10 +59,10 @@
   <script src="Babylon/Culling/babylon.boundingBox.js"></script>
   <script src="Babylon/Culling/babylon.boundingSphere.js"></script>
   <script src="Babylon/babylon.engine.js"></script>
-  <script src="Babylon/Tools/babylon.tools.js"></script>
+  <script src="Babylon/Math/babylon.tools.js"></script>
   <script src="Babylon/Tools/babylon.math.js"></script>
   <script src="Babylon/babylon.node.js"></script>
   <script src="Babylon/Tools/babylon.sceneSerializer.js"></script>
-  <script src="Babylon/Mesh/babylon.axis.js"></script>
+  <script src="Babylon/Math/babylon.axis.js"></script>
   <script src="Babylon/Loading/Plugins/babylon.babylonFileLoader.js"></script>
 </files>

Plik diff jest za duży
+ 1 - 1
babylon.1.9.0.js