diff --git a/build/three.js b/build/three.js index b5e07e922012b53b4fa1f814e7e6474d8e87a3c5..0351e08dac83087cf551079a2853a478edeb580a 100644 --- a/build/three.js +++ b/build/three.js @@ -1,7 +1,7 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.THREE = global.THREE || {}))); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.THREE = global.THREE || {}))); }(this, (function (exports) { 'use strict'; // Polyfills @@ -35,7 +35,7 @@ get: function () { - return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ]; + return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ]; } @@ -446,13 +446,6 @@ }, - random16: function () { - - console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' ); - return Math.random(); - - }, - // Random integer from interval randInt: function ( low, high ) { @@ -1007,9 +1000,11 @@ * @author szimek / https://github.com/szimek/ */ + var textureId = 0; + function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - Object.defineProperty( this, 'id', { value: TextureIdCount() } ); + Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = _Math.generateUUID(); @@ -1044,7 +1039,7 @@ // // Also changing the encoding after already used by a Material will not automatically make the Material // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. - this.encoding = encoding !== undefined ? encoding : LinearEncoding; + this.encoding = encoding !== undefined ? encoding : LinearEncoding; this.version = 0; this.onUpdate = null; @@ -1099,10 +1094,6 @@ this.unpackAlignment = source.unpackAlignment; this.encoding = source.encoding; - // TODO (abelnation): this was added as something causes texture constants to be "copied" before they are properly uploaded to GPU - this.needsUpdate = source.needsUpdate; - this.version = source.version; - return this; }, @@ -1207,7 +1198,7 @@ transformUv: function ( uv ) { - if ( this.mapping !== UVMapping ) return; + if ( this.mapping !== UVMapping ) return; uv.multiply( this.repeat ); uv.add( this.offset ); @@ -1286,9 +1277,6 @@ Object.assign( Texture.prototype, EventDispatcher.prototype ); - var count = 0; - function TextureIdCount() { return count++; } - /** * @author supereggbert / http://www.paulbrunt.co.uk/ * @author philogb / http://blog.thejit.org/ @@ -3940,30 +3928,6 @@ }, - flattenToArrayOffset: function ( array, offset ) { - - console.warn( "THREE.Matrix3: .flattenToArrayOffset is deprecated " + - "- just use .toArray instead." ); - - return this.toArray( array, offset ); - - }, - - getPosition: function () { - - var v1; - - return function getPosition() { - - if ( v1 === undefined ) v1 = new Vector3(); - console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); - - return v1.setFromMatrixColumn( this, 3 ); - - }; - - }(), - setPosition: function ( v ) { var te = this.elements; @@ -4977,7 +4941,7 @@ var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; - var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nfloat gaussianPdf(in float x, in float sigma) {\n\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n}\nmat3 transpose( const in mat3 v ) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\n"; + var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n"; var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n"; @@ -5007,6 +4971,8 @@ var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; + var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n"; + var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n"; var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; @@ -5017,7 +4983,7 @@ var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n"; - var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n"; + var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n"; var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n"; @@ -5133,7 +5099,7 @@ var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; - var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; + var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n"; @@ -5186,6 +5152,7 @@ envmap_vertex: envmap_vertex, fog_fragment: fog_fragment, fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, lightmap_fragment: lightmap_fragment, lightmap_pars_fragment: lightmap_pars_fragment, lights_lambert_vertex: lights_lambert_vertex, @@ -5885,6 +5852,12 @@ }, + gradientmap: { + + gradientMap: { value: null } + + }, + fog: { fogDensity: { value: 0.00025 }, @@ -5951,19 +5924,12 @@ } }, // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src - rectAreaLights: { type: "sa", value: [], properties: { - color: { type: "c" }, - position: { type: "v3" }, - width: { type: "v3" }, - height: { type: "v3" }, + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {}, } } - // rectAreaLights: { type: "sa", value: [], properties: { - // color: { type: "c" }, - // position: { type: "v3" }, - // width: { type: "1f" }, - // height: { type: "1f" }, - // rotationMatrix: { type: "m4" } - // } }, }, @@ -6031,6 +5997,7 @@ UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, + UniformsLib.gradientmap, UniformsLib.fog, UniformsLib.lights, { @@ -7184,9 +7151,11 @@ * @author alteredq / http://alteredqualia.com/ */ + var materialId = 0; + function Material() { - Object.defineProperty( this, 'id', { value: MaterialIdCount() } ); + Object.defineProperty( this, 'id', { value: materialId ++ } ); this.uuid = _Math.generateUUID(); @@ -7377,6 +7346,12 @@ } + if ( this.gradientMap && this.gradientMap.isTexture ) { + + data.gradientMap = this.gradientMap.toJSON( meta ).uuid; + + } + if ( this.size !== undefined ) data.size = this.size; if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; @@ -7519,9 +7494,6 @@ Object.assign( Material.prototype, EventDispatcher.prototype ); - var count$1 = 0; - function MaterialIdCount() { return count$1++; } - /** * @author alteredq / http://alteredqualia.com/ * @@ -8616,15 +8588,6 @@ }, - flattenToArrayOffset: function ( array, offset ) { - - console.warn( "THREE.Matrix3: .flattenToArrayOffset is deprecated " + - "- just use .toArray instead." ); - - return this.toArray( array, offset ); - - }, - getNormalMatrix: function ( matrix4 ) { return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); @@ -10494,9 +10457,11 @@ * @author elephantatwork / www.elephantatwork.ch */ + var object3DId = 0; + function Object3D() { - Object.defineProperty( this, 'id', { value: Object3DIdCount() } ); + Object.defineProperty( this, 'id', { value: object3DId ++ } ); this.uuid = _Math.generateUUID(); @@ -10570,7 +10535,7 @@ this.userData = {}; - this.onBeforeRender = function(){}; + this.onBeforeRender = function(){}; this.onAfterRender = function(){}; } @@ -11206,9 +11171,6 @@ } ); - var count$2 = 0; - function Object3DIdCount() { return count$2++; } - /** * @author bhouston / http://clara.io */ @@ -12191,6 +12153,265 @@ Float64BufferAttribute.prototype = Object.create( BufferAttribute.prototype ); Float64BufferAttribute.prototype.constructor = Float64BufferAttribute; + /** + * @author mrdoob / http://mrdoob.com/ + */ + + function DirectGeometry() { + + this.indices = []; + this.vertices = []; + this.normals = []; + this.colors = []; + this.uvs = []; + this.uvs2 = []; + + this.groups = []; + + this.morphTargets = {}; + + this.skinWeights = []; + this.skinIndices = []; + + // this.lineDistances = []; + + this.boundingBox = null; + this.boundingSphere = null; + + // update flags + + this.verticesNeedUpdate = false; + this.normalsNeedUpdate = false; + this.colorsNeedUpdate = false; + this.uvsNeedUpdate = false; + this.groupsNeedUpdate = false; + + } + + Object.assign( DirectGeometry.prototype, { + + computeGroups: function ( geometry ) { + + var group; + var groups = []; + var materialIndex; + + var faces = geometry.faces; + + for ( var i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + + // materials + + if ( face.materialIndex !== materialIndex ) { + + materialIndex = face.materialIndex; + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + group = { + start: i * 3, + materialIndex: materialIndex + }; + + } + + } + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + this.groups = groups; + + }, + + fromGeometry: function ( geometry ) { + + var faces = geometry.faces; + var vertices = geometry.vertices; + var faceVertexUvs = geometry.faceVertexUvs; + + var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0; + var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0; + + // morphs + + var morphTargets = geometry.morphTargets; + var morphTargetsLength = morphTargets.length; + + var morphTargetsPosition; + + if ( morphTargetsLength > 0 ) { + + morphTargetsPosition = []; + + for ( var i = 0; i < morphTargetsLength; i ++ ) { + + morphTargetsPosition[ i ] = []; + + } + + this.morphTargets.position = morphTargetsPosition; + + } + + var morphNormals = geometry.morphNormals; + var morphNormalsLength = morphNormals.length; + + var morphTargetsNormal; + + if ( morphNormalsLength > 0 ) { + + morphTargetsNormal = []; + + for ( var i = 0; i < morphNormalsLength; i ++ ) { + + morphTargetsNormal[ i ] = []; + + } + + this.morphTargets.normal = morphTargetsNormal; + + } + + // skins + + var skinIndices = geometry.skinIndices; + var skinWeights = geometry.skinWeights; + + var hasSkinIndices = skinIndices.length === vertices.length; + var hasSkinWeights = skinWeights.length === vertices.length; + + // + + for ( var i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + + this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); + + var vertexNormals = face.vertexNormals; + + if ( vertexNormals.length === 3 ) { + + this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); + + } else { + + var normal = face.normal; + + this.normals.push( normal, normal, normal ); + + } + + var vertexColors = face.vertexColors; + + if ( vertexColors.length === 3 ) { + + this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); + + } else { + + var color = face.color; + + this.colors.push( color, color, color ); + + } + + if ( hasFaceVertexUv === true ) { + + var vertexUvs = faceVertexUvs[ 0 ][ i ]; + + if ( vertexUvs !== undefined ) { + + this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + + } else { + + console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); + + this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); + + } + + } + + if ( hasFaceVertexUv2 === true ) { + + var vertexUvs = faceVertexUvs[ 1 ][ i ]; + + if ( vertexUvs !== undefined ) { + + this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + + } else { + + console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); + + this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); + + } + + } + + // morphs + + for ( var j = 0; j < morphTargetsLength; j ++ ) { + + var morphTarget = morphTargets[ j ].vertices; + + morphTargetsPosition[ j ].push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] ); + + } + + for ( var j = 0; j < morphNormalsLength; j ++ ) { + + var morphNormal = morphNormals[ j ].vertexNormals[ i ]; + + morphTargetsNormal[ j ].push( morphNormal.a, morphNormal.b, morphNormal.c ); + + } + + // skins + + if ( hasSkinIndices ) { + + this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); + + } + + if ( hasSkinWeights ) { + + this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); + + } + + } + + this.computeGroups( geometry ); + + this.verticesNeedUpdate = geometry.verticesNeedUpdate; + this.normalsNeedUpdate = geometry.normalsNeedUpdate; + this.colorsNeedUpdate = geometry.colorsNeedUpdate; + this.uvsNeedUpdate = geometry.uvsNeedUpdate; + this.groupsNeedUpdate = geometry.groupsNeedUpdate; + + return this; + + } + + } ); + /** * @author mrdoob / http://mrdoob.com/ * @author kile / http://kile.stravaganza.org/ @@ -12837,12 +13058,6 @@ }, - computeTangents: function () { - - console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); - - }, - computeLineDistances: function () { var d = 0; @@ -13454,295 +13669,8 @@ } ); - var count$3 = 0; - function GeometryIdCount() { return count$3++; } - - /** - * @author mrdoob / http://mrdoob.com/ - */ - - function DirectGeometry() { - - Object.defineProperty( this, 'id', { value: GeometryIdCount() } ); - - this.uuid = _Math.generateUUID(); - - this.name = ''; - this.type = 'DirectGeometry'; - - this.indices = []; - this.vertices = []; - this.normals = []; - this.colors = []; - this.uvs = []; - this.uvs2 = []; - - this.groups = []; - - this.morphTargets = {}; - - this.skinWeights = []; - this.skinIndices = []; - - // this.lineDistances = []; - - this.boundingBox = null; - this.boundingSphere = null; - - // update flags - - this.verticesNeedUpdate = false; - this.normalsNeedUpdate = false; - this.colorsNeedUpdate = false; - this.uvsNeedUpdate = false; - this.groupsNeedUpdate = false; - - } - - Object.assign( DirectGeometry.prototype, EventDispatcher.prototype, { - - computeBoundingBox: Geometry.prototype.computeBoundingBox, - computeBoundingSphere: Geometry.prototype.computeBoundingSphere, - - computeFaceNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.' ); - - }, - - computeVertexNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.' ); - - }, - - computeGroups: function ( geometry ) { - - var group; - var groups = []; - var materialIndex; - - var faces = geometry.faces; - - for ( var i = 0; i < faces.length; i ++ ) { - - var face = faces[ i ]; - - // materials - - if ( face.materialIndex !== materialIndex ) { - - materialIndex = face.materialIndex; - - if ( group !== undefined ) { - - group.count = ( i * 3 ) - group.start; - groups.push( group ); - - } - - group = { - start: i * 3, - materialIndex: materialIndex - }; - - } - - } - - if ( group !== undefined ) { - - group.count = ( i * 3 ) - group.start; - groups.push( group ); - - } - - this.groups = groups; - - }, - - fromGeometry: function ( geometry ) { - - var faces = geometry.faces; - var vertices = geometry.vertices; - var faceVertexUvs = geometry.faceVertexUvs; - - var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0; - var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0; - - // morphs - - var morphTargets = geometry.morphTargets; - var morphTargetsLength = morphTargets.length; - - var morphTargetsPosition; - - if ( morphTargetsLength > 0 ) { - - morphTargetsPosition = []; - - for ( var i = 0; i < morphTargetsLength; i ++ ) { - - morphTargetsPosition[ i ] = []; - - } - - this.morphTargets.position = morphTargetsPosition; - - } - - var morphNormals = geometry.morphNormals; - var morphNormalsLength = morphNormals.length; - - var morphTargetsNormal; - - if ( morphNormalsLength > 0 ) { - - morphTargetsNormal = []; - - for ( var i = 0; i < morphNormalsLength; i ++ ) { - - morphTargetsNormal[ i ] = []; - - } - - this.morphTargets.normal = morphTargetsNormal; - - } - - // skins - - var skinIndices = geometry.skinIndices; - var skinWeights = geometry.skinWeights; - - var hasSkinIndices = skinIndices.length === vertices.length; - var hasSkinWeights = skinWeights.length === vertices.length; - - // - - for ( var i = 0; i < faces.length; i ++ ) { - - var face = faces[ i ]; - - this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); - - var vertexNormals = face.vertexNormals; - - if ( vertexNormals.length === 3 ) { - - this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); - - } else { - - var normal = face.normal; - - this.normals.push( normal, normal, normal ); - - } - - var vertexColors = face.vertexColors; - - if ( vertexColors.length === 3 ) { - - this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); - - } else { - - var color = face.color; - - this.colors.push( color, color, color ); - - } - - if ( hasFaceVertexUv === true ) { - - var vertexUvs = faceVertexUvs[ 0 ][ i ]; - - if ( vertexUvs !== undefined ) { - - this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); - - } else { - - console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); - - this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); - - } - - } - - if ( hasFaceVertexUv2 === true ) { - - var vertexUvs = faceVertexUvs[ 1 ][ i ]; - - if ( vertexUvs !== undefined ) { - - this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); - - } else { - - console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); - - this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); - - } - - } - - // morphs - - for ( var j = 0; j < morphTargetsLength; j ++ ) { - - var morphTarget = morphTargets[ j ].vertices; - - morphTargetsPosition[ j ].push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] ); - - } - - for ( var j = 0; j < morphNormalsLength; j ++ ) { - - var morphNormal = morphNormals[ j ].vertexNormals[ i ]; - - morphTargetsNormal[ j ].push( morphNormal.a, morphNormal.b, morphNormal.c ); - - } - - // skins - - if ( hasSkinIndices ) { - - this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); - - } - - if ( hasSkinWeights ) { - - this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); - - } - - } - - this.computeGroups( geometry ); - - this.verticesNeedUpdate = geometry.verticesNeedUpdate; - this.normalsNeedUpdate = geometry.normalsNeedUpdate; - this.colorsNeedUpdate = geometry.colorsNeedUpdate; - this.uvsNeedUpdate = geometry.uvsNeedUpdate; - this.groupsNeedUpdate = geometry.groupsNeedUpdate; - - return this; - - }, - - dispose: function () { - - this.dispatchEvent( { type: 'dispose' } ); - - } - - } ); + var count = 0; + function GeometryIdCount() { return count++; } /** * @author alteredq / http://alteredqualia.com/ @@ -13790,7 +13718,7 @@ addAttribute: function ( name, attribute ) { - if ( (attribute && attribute.isBufferAttribute) === false && (attribute && attribute.isInterleavedBufferAttribute) === false ) { + if ( ( attribute && attribute.isBufferAttribute ) === false && ( attribute && attribute.isInterleavedBufferAttribute ) === false ) { console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' ); @@ -14418,14 +14346,9 @@ var normals = attributes.normal.array; - var vA, vB, vC, - - pA = new Vector3(), - pB = new Vector3(), - pC = new Vector3(), - - cb = new Vector3(), - ab = new Vector3(); + var vA, vB, vC; + var pA = new Vector3(), pB = new Vector3(), pC = new Vector3(); + var cb = new Vector3(), ab = new Vector3(); // indexed elements @@ -14516,7 +14439,7 @@ merge: function ( geometry, offset ) { - if ( (geometry && geometry.isBufferGeometry) === false ) { + if ( ( geometry && geometry.isBufferGeometry ) === false ) { console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry ); return; @@ -16547,6 +16470,8 @@ parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', @@ -16780,6 +16705,7 @@ MeshBasicMaterial: 'basic', MeshLambertMaterial: 'lambert', MeshPhongMaterial: 'phong', + MeshToonMaterial: 'phong', MeshStandardMaterial: 'physical', MeshPhysicalMaterial: 'physical', LineBasicMaterial: 'basic', @@ -16790,7 +16716,7 @@ var parameterNames = [ "precision", "supportsVertexTextures", "map", "mapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "displacementMap", "specularMap", - "roughnessMap", "metalnessMap", + "roughnessMap", "metalnessMap", "gradientMap", "alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", @@ -16918,6 +16844,8 @@ specularMap: !! material.specularMap, alphaMap: !! material.alphaMap, + gradientMap: !! material.gradientMap, + combine: material.combine, vertexColors: material.vertexColors, @@ -17906,12 +17834,40 @@ } + if ( texture.format === DepthFormat && internalFormat === _gl.DEPTH_COMPONENT ) { + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' ); + + texture.type = UnsignedShortType; + glType = paramThreeToGL( texture.type ); + + } + + } + // Depth stencil textures need the DEPTH_STENCIL internal format // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) if ( texture.format === DepthStencilFormat ) { internalFormat = _gl.DEPTH_STENCIL; + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL. + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedInt248Type ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' ); + + texture.type = UnsignedInt248Type; + glType = paramThreeToGL( texture.type ); + + } + } state.texImage2D( _gl.TEXTURE_2D, 0, internalFormat, image.width, image.height, 0, glFormat, glType, null ); @@ -21417,6 +21373,10 @@ refreshUniformsLambert( m_uniforms, material ); + } else if ( material.isMeshToonMaterial ) { + + refreshUniformsToon( m_uniforms, material ); + } else if ( material.isMeshPhongMaterial ) { refreshUniformsPhong( m_uniforms, material ); @@ -21667,6 +21627,18 @@ } + function refreshUniformsToon( uniforms, material ) { + + refreshUniformsPhong( uniforms, material ); + + if ( material.gradientMap ) { + + uniforms.gradientMap.value = material.gradientMap; + + } + + } + function refreshUniformsStandard( uniforms, material ) { uniforms.roughness.value = material.roughness; @@ -22348,184 +22320,6 @@ } - /** - * @author mrdoob / http://mrdoob.com/ - */ - - function WebGL2Renderer( parameters ) { - - console.log( 'THREE.WebGL2Renderer', REVISION ); - - parameters = parameters || {}; - - var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ), - _context = parameters.context !== undefined ? parameters.context : null, - - _alpha = parameters.alpha !== undefined ? parameters.alpha : false, - _depth = parameters.depth !== undefined ? parameters.depth : true, - _stencil = parameters.stencil !== undefined ? parameters.stencil : true, - _antialias = parameters.antialias !== undefined ? parameters.antialias : false, - _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, - _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false; - - // initialize - - var gl; - - try { - - var attributes = { - alpha: _alpha, - depth: _depth, - stencil: _stencil, - antialias: _antialias, - premultipliedAlpha: _premultipliedAlpha, - preserveDrawingBuffer: _preserveDrawingBuffer - }; - - gl = _context || _canvas.getContext( 'webgl2', attributes ); - - if ( gl === null ) { - - if ( _canvas.getContext( 'webgl2' ) !== null ) { - - throw 'Error creating WebGL2 context with your selected attributes.'; - - } else { - - throw 'Error creating WebGL2 context.'; - - } - - } - - _canvas.addEventListener( 'webglcontextlost', onContextLost, false ); - - } catch ( error ) { - - console.error( 'THREE.WebGL2Renderer: ' + error ); - - } - - // - - var _this = this, - - _autoClear = true, - _autoClearColor = true, - _autoClearDepth = true, - _autoClearStencil = true, - - _clearColor = new Color( 0x000000 ), - _clearAlpha = 0, - - _width = _canvas.width, - _height = _canvas.height, - - _pixelRatio = 1, - - _viewport = new Vector4( 0, 0, _width, _height ); - - var extensions = new WebGLExtensions( gl ); - var state = new WebGLState( gl, extensions, function () {} ); - - // - - function clear( color, depth, stencil ) { - - var bits = 0; - - if ( color === undefined || color ) bits |= gl.COLOR_BUFFER_BIT; - if ( depth === undefined || depth ) bits |= gl.DEPTH_BUFFER_BIT; - if ( stencil === undefined || stencil ) bits |= gl.STENCIL_BUFFER_BIT; - - gl.clear( bits ); - - } - - function setPixelRatio( value ) { - - if ( value === undefined ) return; - - _pixelRatio = value; - - setSize( _viewport.z, _viewport.w, false ); - - } - - function setSize( width, height, updateStyle ) { - - _width = width; - _height = height; - - _canvas.width = width * _pixelRatio; - _canvas.height = height * _pixelRatio; - - if ( updateStyle !== false ) { - - _canvas.style.width = width + 'px'; - _canvas.style.height = height + 'px'; - - } - - setViewport( 0, 0, width, height ); - - } - - function setViewport( x, y, width, height ) { - - state.viewport( _viewport.set( x, y, width, height ) ); - - } - - function render( scene, camera ) { - - if ( camera !== undefined && camera.isCamera !== true ) { - - console.error( 'THREE.WebGL2Renderer.render: camera is not an instance of THREE.Camera.' ); - return; - - } - - var background = scene.background; - var forceClear = false; - - if ( background === null ) { - - state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); - - } else if ( background && background.isColor ) { - - state.buffers.color.setClear( background.r, background.g, background.b, 1, _premultipliedAlpha ); - forceClear = true; - - } - - if ( _autoClear || forceClear ) { - - this.clear( _autoClearColor, _autoClearDepth, _autoClearStencil ); - - } - - } - - function onContextLost( event ) { - - event.preventDefault(); - - } - - return { - domElement: _canvas, - - clear: clear, - setPixelRatio: setPixelRatio, - setSize: setSize, - render: render - } - - } - /** * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ @@ -23953,12 +23747,13 @@ } + if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; + if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; + Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); this.image = { width: width, height: height }; - this.type = type !== undefined ? type : UnsignedShortType; - this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; @@ -28737,6 +28532,43 @@ }; + /** + * @author takahirox / http://github.com/takahirox + * + * parameters = { + * gradientMap: new THREE.Texture( ) + * } + */ + + function MeshToonMaterial( parameters ) { + + MeshPhongMaterial.call( this ); + + this.defines = { 'TOON': '' }; + + this.type = 'MeshToonMaterial'; + + this.gradientMap = null; + + this.setValues( parameters ); + + } + + MeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype ); + MeshToonMaterial.prototype.constructor = MeshToonMaterial; + + MeshToonMaterial.prototype.isMeshToonMaterial = true; + + MeshToonMaterial.prototype.copy = function ( source ) { + + MeshPhongMaterial.prototype.copy.call( this, source ); + + this.gradientMap = source.gradientMap; + + return this; + + }; + /** * @author mrdoob / http://mrdoob.com/ * @@ -28974,6 +28806,7 @@ MeshPhysicalMaterial: MeshPhysicalMaterial, MeshStandardMaterial: MeshStandardMaterial, MeshPhongMaterial: MeshPhongMaterial, + MeshToonMaterial: MeshToonMaterial, MeshNormalMaterial: MeshNormalMaterial, MeshLambertMaterial: MeshLambertMaterial, MeshDepthMaterial: MeshDepthMaterial, @@ -29143,15 +28976,13 @@ // Safari can not handle Data URIs through XMLHttpRequest so process manually if ( dataUriRegexResult ) { - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; + var mimeType = dataUriRegexResult[ 1 ]; + var isBase64 = !! dataUriRegexResult[ 2 ]; + var data = dataUriRegexResult[ 3 ]; - data = window.decodeURIComponent(data); + data = window.decodeURIComponent( data ); - if( isBase64 ) { - data = window.atob(data); - } + if ( isBase64 ) data = window.atob( data ); try { @@ -29164,16 +28995,18 @@ case 'blob': response = new ArrayBuffer( data.length ); + var view = new Uint8Array( response ); + for ( var i = 0; i < data.length; i ++ ) { - view[ i ] = data.charCodeAt( i ); + view[ i ] = data.charCodeAt( i ); } if ( responseType === 'blob' ) { - response = new Blob( [ response ], { "type" : mimeType } ); + response = new Blob( [ response ], { type: mimeType } ); } @@ -29201,24 +29034,24 @@ } // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onLoad ) onLoad( response ); scope.manager.itemEnd( url ); - }, 0); + }, 0 ); } catch ( error ) { // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onError ) onError( error ); scope.manager.itemError( url ); - }, 0); + }, 0 ); } @@ -29580,6 +29413,13 @@ image.src = url; + } else if ( this.crossOrigin !== undefined ) { + + // crossOrigin doesn't work with URL.createObjectURL()? + + image.crossOrigin = this.crossOrigin; + image.src = url; + } else { var loader = new FileLoader(); @@ -32034,6 +31874,8 @@ if ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap ); if ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity; + if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + // MultiMaterial if ( json.materials !== undefined ) { @@ -33016,7 +32858,7 @@ * @author mrdoob / http://mrdoob.com/ */ - function ObjectLoader ( manager ) { + function ObjectLoader( manager ) { this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; this.texturePath = ''; @@ -33088,7 +32930,7 @@ } ); - var textures = this.parseTextures( json.textures, images ); + var textures = this.parseTextures( json.textures, images ); var materials = this.parseMaterials( json.materials, textures ); var object = this.parseObject( json.object, geometries, materials ); @@ -35680,8 +35522,24 @@ orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion ); - listener.setPosition( position.x, position.y, position.z ); - listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + if ( listener.positionX ) { + + listener.positionX.setValueAtTime( position.x, this.context.currentTime ); + listener.positionY.setValueAtTime( position.y, this.context.currentTime ); + listener.positionZ.setValueAtTime( position.z, this.context.currentTime ); + listener.forwardX.setValueAtTime( orientation.x, this.context.currentTime ); + listener.forwardY.setValueAtTime( orientation.y, this.context.currentTime ); + listener.forwardZ.setValueAtTime( orientation.z, this.context.currentTime ); + listener.upX.setValueAtTime( up.x, this.context.currentTime ); + listener.upY.setValueAtTime( up.y, this.context.currentTime ); + listener.upZ.setValueAtTime( up.z, this.context.currentTime ); + + } else { + + listener.setPosition( position.x, position.y, position.z ); + listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + + } }; @@ -35701,14 +35559,14 @@ this.type = 'Audio'; this.context = listener.context; - this.source = this.context.createBufferSource(); - this.source.onended = this.onEnded.bind( this ); this.gain = this.context.createGain(); this.gain.connect( listener.getInput() ); this.autoplay = false; + this.buffer = null; + this.loop = false; this.startTime = 0; this.playbackRate = 1; this.isPlaying = false; @@ -35742,7 +35600,7 @@ setBuffer: function ( audioBuffer ) { - this.source.buffer = audioBuffer; + this.buffer = audioBuffer; this.sourceType = 'buffer'; if ( this.autoplay ) this.play(); @@ -35769,11 +35627,11 @@ var source = this.context.createBufferSource(); - source.buffer = this.source.buffer; - source.loop = this.source.loop; - source.onended = this.source.onended; + source.buffer = this.buffer; + source.loop = this.loop; + source.onended = this.onEnded.bind( this ); + source.playbackRate.setValueAtTime( this.playbackRate, this.startTime ); source.start( 0, this.startTime ); - source.playbackRate.value = this.playbackRate; this.isPlaying = true; @@ -35916,7 +35774,7 @@ if ( this.isPlaying === true ) { - this.source.playbackRate.value = this.playbackRate; + this.source.playbackRate.setValueAtTime( this.playbackRate, this.context.currentTime ); } @@ -35945,7 +35803,7 @@ } - return this.source.loop; + return this.loop; }, @@ -35958,7 +35816,15 @@ } - this.source.loop = value; + this.loop = value; + + if ( this.isPlaying === true ) { + + this.source.loop = this.loop; + + } + + return this; }, @@ -38741,6 +38607,12 @@ } + Uniform.prototype.clone = function () { + + return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); + + }; + /** * @author benaadams / https://twitter.com/ben_a_adams */ @@ -38947,6 +38819,8 @@ this.dynamic = false; this.updateRange = { offset: 0, count: - 1 }; + this.onUploadCallback = function () {}; + this.version = 0; } @@ -39024,6 +38898,14 @@ return new this.constructor().copy( this ); + }, + + onUpload: function ( callback ) { + + this.onUploadCallback = callback; + + return this; + } }; @@ -40111,13 +39993,20 @@ * @author Michael Guerrero / http://realitymeltdown.com * @author mrdoob / http://mrdoob.com/ * @author ikerr / http://verold.com + * @author Mugen87 / https://github.com/Mugen87 */ function SkeletonHelper( object ) { this.bones = this.getBoneList( object ); - var geometry = new Geometry(); + var geometry = new BufferGeometry(); + + var vertices = []; + var colors = []; + + var color1 = new Color( 0, 0, 1 ); + var color2 = new Color( 0, 1, 0 ); for ( var i = 0; i < this.bones.length; i ++ ) { @@ -40125,16 +40014,17 @@ if ( bone.parent && bone.parent.isBone ) { - geometry.vertices.push( new Vector3() ); - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( 0, 0, 1 ) ); - geometry.colors.push( new Color( 0, 1, 0 ) ); + vertices.push( 0, 0, 0 ); + vertices.push( 0, 0, 0 ); + colors.push( color1.r, color1.g, color1.b ); + colors.push( color2.r, color2.g, color2.b ); } } - geometry.dynamic = true; + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } ); @@ -40175,37 +40065,41 @@ SkeletonHelper.prototype.update = function () { - var geometry = this.geometry; - - var matrixWorldInv = new Matrix4().getInverse( this.root.matrixWorld ); + var vector = new Vector3(); var boneMatrix = new Matrix4(); + var matrixWorldInv = new Matrix4(); - var j = 0; + return function update() { - for ( var i = 0; i < this.bones.length; i ++ ) { + var geometry = this.geometry; + var position = geometry.getAttribute( 'position' ); - var bone = this.bones[ i ]; + matrixWorldInv.getInverse( this.root.matrixWorld ); - if ( bone.parent && bone.parent.isBone ) { + for ( var i = 0, j = 0; i < this.bones.length; i ++, j += 2 ) { - boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); - geometry.vertices[ j ].setFromMatrixPosition( boneMatrix ); + var bone = this.bones[ i ]; - boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); - geometry.vertices[ j + 1 ].setFromMatrixPosition( boneMatrix ); + if ( bone.parent && bone.parent.isBone ) { - j += 2; + boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j, vector.x, vector.y, vector.z ); - } + boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j + 1, vector.x, vector.y, vector.z ); - } + } - geometry.verticesNeedUpdate = true; + } - geometry.computeBoundingSphere(); + geometry.getAttribute( 'position' ).needsUpdate = true; - }; + }; + + }(); /** * @author alteredq / http://alteredqualia.com/ @@ -40285,100 +40179,97 @@ * @author abelnation / http://github.com/abelnation */ - function RectAreaLightHelper(light) { + function RectAreaLightHelper( light ) { + + Object3D.call( this ); + + this.light = light; + this.light.updateMatrixWorld(); + + this.lightMat = new MeshBasicMaterial( { + color: light.color, + fog: false + } ); - Object3D.call(this); + this.lightWireMat = new MeshBasicMaterial( { + color: light.color, + fog: false, + wireframe: true + } ); - this.light = light; - this.light.updateMatrixWorld(); + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - // this.matrix = light.matrixWorld; - // this.matrixAutoUpdate = false; + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - this.lightMat = new MeshBasicMaterial({ - color: light.color, - fog: false - }); + // shows the "front" of the light, e.g. where light comes from - this.lightWireMat = new MeshBasicMaterial({ - color: light.color, - fog: false, - wireframe: true - }); + this.lightMesh = new Mesh( this.lightShape, this.lightMat ); - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + // shows the "back" of the light, which does not emit light - // shows the "front" of the light, e.g. where light comes from - this.lightMesh = new Mesh(this.lightShape, this.lightMat); - // shows the "back" of the light, which does not emit light - this.lightWireMesh = new Mesh(this.lightShape, this.lightWireMat); + this.lightWireMesh = new Mesh( this.lightShape, this.lightWireMat ); - this.add(this.lightMesh); - this.add(this.lightWireMesh); + this.add( this.lightMesh ); + this.add( this.lightWireMesh ); - this.update(); + this.update(); } - RectAreaLightHelper.prototype = Object.create(Object3D.prototype); + RectAreaLightHelper.prototype = Object.create( Object3D.prototype ); RectAreaLightHelper.prototype.constructor = RectAreaLightHelper; RectAreaLightHelper.prototype.dispose = function () { - this.lightMesh.geometry.dispose(); - this.lightMesh.material.dispose(); - this.lightWireMesh.geometry.dispose(); - this.lightWireMesh.material.dispose(); + this.lightMesh.geometry.dispose(); + this.lightMesh.material.dispose(); + this.lightWireMesh.geometry.dispose(); + this.lightWireMesh.material.dispose(); }; RectAreaLightHelper.prototype.update = function () { - var vector = new Vector3(); - var vector2 = new Vector3(); + var vector = new Vector3(); + var vector2 = new Vector3(); - // TODO (abelnation) why not just make light helpers a child of the light object? - if (this.light.target) { + // TODO (abelnation) why not just make light helpers a child of the light object? + if ( this.light.target ) { - vector.setFromMatrixPosition(this.light.matrixWorld); - vector2.setFromMatrixPosition(this.light.target.matrixWorld); + vector.setFromMatrixPosition( this.light.matrixWorld ); + vector2.setFromMatrixPosition( this.light.target.matrixWorld ); - var lookVec = vector2.clone().sub(vector); - this.lightMesh.lookAt(lookVec); - this.lightWireMesh.lookAt(lookVec); + var lookVec = vector2.clone().sub( vector ); + this.lightMesh.lookAt( lookVec ); + this.lightWireMesh.lookAt( lookVec ); - } + } - this.lightMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + this.lightMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); + this.lightWireMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); - this.lightWireMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + var oldShape = this.lightShape; - var oldShape = this.lightShape; + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - this.lightMesh.geometry = this.lightShape; - this.lightWireMesh.geometry = this.lightShape; + this.lightMesh.geometry = this.lightShape; + this.lightWireMesh.geometry = this.lightShape; - oldShape.dispose(); + oldShape.dispose(); }; @@ -40449,7 +40340,8 @@ function GridHelper( size, divisions, color1, color2 ) { - divisions = divisions || 1; + size = size || 10; + divisions = divisions || 10; color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); @@ -40484,11 +40376,92 @@ GridHelper.prototype = Object.create( LineSegments.prototype ); GridHelper.prototype.constructor = GridHelper; - GridHelper.prototype.setColors = function () { + /** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / http://github.com/Mugen87 + * @author Hectate / http://www.github.com/Hectate + */ - console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); + function PolarGridHelper( radius, radials, circles, divisions, color1, color2 ) { - }; + radius = radius || 10; + radials = radials || 16; + circles = circles || 8; + divisions = divisions || 64; + color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); + color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); + + var vertices = []; + var colors = []; + + var x, z; + var v, i, j, r, color; + + // create the radials + + for ( i = 0; i <= radials; i ++ ) { + + v = ( i / radials ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * radius; + z = Math.cos( v ) * radius; + + vertices.push( 0, 0, 0 ); + vertices.push( x, 0, z ); + + color = ( i & 1 ) ? color1 : color2; + + colors.push( color.r, color.g, color.b ); + colors.push( color.r, color.g, color.b ); + + } + + // create the circles + + for ( i = 0; i <= circles; i ++ ) { + + color = ( i & 1 ) ? color1 : color2; + + r = radius - ( radius / circles * i ); + + for ( j = 0; j < divisions; j ++ ) { + + // first vertex + + v = ( j / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + // second vertex + + v = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + } + + } + + var geometry = new BufferGeometry(); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + + LineSegments.call( this, geometry, material ); + + } + + PolarGridHelper.prototype = Object.create( LineSegments.prototype ); + PolarGridHelper.prototype.constructor = PolarGridHelper; /** * @author mrdoob / http://mrdoob.com/ @@ -40683,6 +40656,7 @@ /** * @author alteredq / http://alteredqualia.com/ + * @author Mugen87 / https://github.com/Mugen87 * * - shows frustum, line of sight and up of the camera * - suitable for fast updates @@ -40692,77 +40666,80 @@ function CameraHelper( camera ) { - var geometry = new Geometry(); + var geometry = new BufferGeometry(); var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } ); + var vertices = []; + var colors = []; + var pointMap = {}; // colors - var hexFrustum = 0xffaa00; - var hexCone = 0xff0000; - var hexUp = 0x00aaff; - var hexTarget = 0xffffff; - var hexCross = 0x333333; + var colorFrustum = new Color( 0xffaa00 ); + var colorCone = new Color( 0xff0000 ); + var colorUp = new Color( 0x00aaff ); + var colorTarget = new Color( 0xffffff ); + var colorCross = new Color( 0x333333 ); // near - addLine( "n1", "n2", hexFrustum ); - addLine( "n2", "n4", hexFrustum ); - addLine( "n4", "n3", hexFrustum ); - addLine( "n3", "n1", hexFrustum ); + addLine( "n1", "n2", colorFrustum ); + addLine( "n2", "n4", colorFrustum ); + addLine( "n4", "n3", colorFrustum ); + addLine( "n3", "n1", colorFrustum ); // far - addLine( "f1", "f2", hexFrustum ); - addLine( "f2", "f4", hexFrustum ); - addLine( "f4", "f3", hexFrustum ); - addLine( "f3", "f1", hexFrustum ); + addLine( "f1", "f2", colorFrustum ); + addLine( "f2", "f4", colorFrustum ); + addLine( "f4", "f3", colorFrustum ); + addLine( "f3", "f1", colorFrustum ); // sides - addLine( "n1", "f1", hexFrustum ); - addLine( "n2", "f2", hexFrustum ); - addLine( "n3", "f3", hexFrustum ); - addLine( "n4", "f4", hexFrustum ); + addLine( "n1", "f1", colorFrustum ); + addLine( "n2", "f2", colorFrustum ); + addLine( "n3", "f3", colorFrustum ); + addLine( "n4", "f4", colorFrustum ); // cone - addLine( "p", "n1", hexCone ); - addLine( "p", "n2", hexCone ); - addLine( "p", "n3", hexCone ); - addLine( "p", "n4", hexCone ); + addLine( "p", "n1", colorCone ); + addLine( "p", "n2", colorCone ); + addLine( "p", "n3", colorCone ); + addLine( "p", "n4", colorCone ); // up - addLine( "u1", "u2", hexUp ); - addLine( "u2", "u3", hexUp ); - addLine( "u3", "u1", hexUp ); + addLine( "u1", "u2", colorUp ); + addLine( "u2", "u3", colorUp ); + addLine( "u3", "u1", colorUp ); // target - addLine( "c", "t", hexTarget ); - addLine( "p", "c", hexCross ); + addLine( "c", "t", colorTarget ); + addLine( "p", "c", colorCross ); // cross - addLine( "cn1", "cn2", hexCross ); - addLine( "cn3", "cn4", hexCross ); + addLine( "cn1", "cn2", colorCross ); + addLine( "cn3", "cn4", colorCross ); - addLine( "cf1", "cf2", hexCross ); - addLine( "cf3", "cf4", hexCross ); + addLine( "cf1", "cf2", colorCross ); + addLine( "cf3", "cf4", colorCross ); - function addLine( a, b, hex ) { + function addLine( a, b, color ) { - addPoint( a, hex ); - addPoint( b, hex ); + addPoint( a, color ); + addPoint( b, color ); } - function addPoint( id, hex ) { + function addPoint( id, color ) { - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( hex ) ); + vertices.push( 0, 0, 0 ); + colors.push( color.r, color.g, color.b ); if ( pointMap[ id ] === undefined ) { @@ -40770,14 +40747,17 @@ } - pointMap[ id ].push( geometry.vertices.length - 1 ); + pointMap[ id ].push( ( vertices.length / 3 ) - 1 ); } + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + LineSegments.call( this, geometry, material ); this.camera = camera; - if( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); + if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); this.matrix = camera.matrixWorld; this.matrixAutoUpdate = false; @@ -40806,9 +40786,11 @@ if ( points !== undefined ) { - for ( var i = 0, il = points.length; i < il; i ++ ) { + var position = geometry.getAttribute( 'position' ); - geometry.vertices[ points[ i ] ].copy( vector ); + for ( var i = 0, l = points.length; i < l; i ++ ) { + + position.setXYZ( points[ i ], vector.x, vector.y, vector.z ); } @@ -40865,43 +40847,12 @@ setPoint( "cn3", 0, - h, - 1 ); setPoint( "cn4", 0, h, - 1 ); - geometry.verticesNeedUpdate = true; + geometry.getAttribute( 'position' ).needsUpdate = true; }; }(); - /** - * @author WestLangley / http://github.com/WestLangley - */ - - // a helper to show the world-axis-aligned bounding box for an object - - function BoundingBoxHelper( object, hex ) { - - var color = ( hex !== undefined ) ? hex : 0x888888; - - this.object = object; - - this.box = new Box3(); - - Mesh.call( this, new BoxGeometry( 1, 1, 1 ), new MeshBasicMaterial( { color: color, wireframe: true } ) ); - - } - - BoundingBoxHelper.prototype = Object.create( Mesh.prototype ); - BoundingBoxHelper.prototype.constructor = BoundingBoxHelper; - - BoundingBoxHelper.prototype.update = function () { - - this.box.setFromObject( this.object ); - - this.box.getSize( this.scale ); - - this.box.getCenter( this.position ); - - }; - /** * @author mrdoob / http://mrdoob.com/ */ @@ -41099,21 +41050,21 @@ size = size || 1; - var vertices = new Float32Array( [ + var vertices = [ 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size - ] ); + ]; - var colors = new Float32Array( [ + var colors = [ 1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1 - ] ); + ]; var geometry = new BufferGeometry(); - geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) ); - geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) ); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors } ); @@ -41305,23 +41256,6 @@ } )(); - /************************************************************** - * Closed Spline 3D curve - **************************************************************/ - - - function ClosedSplineCurve3( points ) { - - console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.' ); - - CatmullRomCurve3.call( this, points ); - this.type = 'catmullrom'; - this.closed = true; - - } - - ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype ); - /************************************************************** * Spline 3D curve **************************************************************/ @@ -41509,329 +41443,548 @@ * @author mrdoob / http://mrdoob.com/ */ - function Face4 ( a, b, c, d, normal, color, materialIndex ) { + function Face4( a, b, c, d, normal, color, materialIndex ) { + console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); return new Face3( a, b, c, normal, color, materialIndex ); + } var LineStrip = 0; var LinePieces = 1; - function PointCloud ( geometry, material ) { + function MeshFaceMaterial( materials ) { + + console.warn( 'THREE.MeshFaceMaterial has been renamed to THREE.MultiMaterial.' ); + return new MultiMaterial( materials ); + + } + + function PointCloud( geometry, material ) { + console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); return new Points( geometry, material ); + + } + + function Particle( material ) { + + console.warn( 'THREE.Particle has been renamed to THREE.Sprite.' ); + return new Sprite( material ); + } - function ParticleSystem ( geometry, material ) { + function ParticleSystem( geometry, material ) { + console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); return new Points( geometry, material ); + } - function PointCloudMaterial ( parameters ) { + function PointCloudMaterial( parameters ) { + console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } - function ParticleBasicMaterial ( parameters ) { + function ParticleBasicMaterial( parameters ) { + console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } - function ParticleSystemMaterial ( parameters ) { + function ParticleSystemMaterial( parameters ) { + console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } - function Vertex ( x, y, z ) { + function Vertex( x, y, z ) { + console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); return new Vector3( x, y, z ); + } // function DynamicBufferAttribute( array, itemSize ) { + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' ); return new BufferAttribute( array, itemSize ).setDynamic( true ); + } function Int8Attribute( array, itemSize ) { + console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' ); return new Int8BufferAttribute( array, itemSize ); + } function Uint8Attribute( array, itemSize ) { + console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' ); return new Uint8BufferAttribute( array, itemSize ); + } function Uint8ClampedAttribute( array, itemSize ) { + console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' ); return new Uint8ClampedBufferAttribute( array, itemSize ); + } function Int16Attribute( array, itemSize ) { + console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' ); return new Int16BufferAttribute( array, itemSize ); + } function Uint16Attribute( array, itemSize ) { + console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' ); return new Uint16BufferAttribute( array, itemSize ); + } function Int32Attribute( array, itemSize ) { + console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' ); return new Int32BufferAttribute( array, itemSize ); + } function Uint32Attribute( array, itemSize ) { + console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' ); return new Uint32BufferAttribute( array, itemSize ); + } function Float32Attribute( array, itemSize ) { + console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' ); return new Float32BufferAttribute( array, itemSize ); + } function Float64Attribute( array, itemSize ) { + console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' ); return new Float64BufferAttribute( array, itemSize ); + + } + + // + + function ClosedSplineCurve3( points ) { + + console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' ); + + CatmullRomCurve3.call( this, points ); + this.type = 'catmullrom'; + this.closed = true; + } + ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype ); + + // + function BoundingBoxHelper( object, color ) { + + console.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' ); + return new BoxHelper( object, color ); + + } function EdgesHelper( object, hex ) { + console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' ); return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } + GridHelper.prototype.setColors = function () { + + console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); + + }; + function WireframeHelper( object, hex ) { + console.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' ); return new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } // function XHRLoader( manager ) { + console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' ); return new FileLoader( manager ); + } // Object.assign( Box2.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); + } } ); Object.assign( Box3.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); - } - } ); - Object.assign( Line3.prototype, { - center: function ( optionalTarget ) { - console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); - return this.getCenter( optionalTarget ); } } ); + Line3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + + }; + + _Math.random16 = function () { + + console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' ); + return Math.random(); + + }; + Object.assign( Matrix3.prototype, { + + flattenToArrayOffset: function ( array, offset ) { + + console.warn( "THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + return this.toArray( array, offset ); + + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); return vector.applyMatrix3( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + } + } ); Object.assign( Matrix4.prototype, { + extractPosition: function ( m ) { + console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); return this.copyPosition( m ); + + }, + flattenToArrayOffset: function ( array, offset ) { + + console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + return this.toArray( array, offset ); + }, + getPosition: function () { + + var v1; + + return function getPosition() { + + if ( v1 === undefined ) v1 = new Vector3(); + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return v1.setFromMatrixColumn( this, 3 ); + + }; + + }(), setRotationFromQuaternion: function ( q ) { + console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); return this.makeRotationFromQuaternion( q ); + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.' ); return vector.applyProjection( this ); + }, multiplyVector4: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + }, rotateAxis: function ( v ) { + console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' ); v.transformDirection( this ); + }, crossVector: function ( vector ) { + console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, - translate: function ( v ) { + translate: function () { + console.error( 'THREE.Matrix4: .translate() has been removed.' ); + }, - rotateX: function ( angle ) { + rotateX: function () { + console.error( 'THREE.Matrix4: .rotateX() has been removed.' ); + }, - rotateY: function ( angle ) { + rotateY: function () { + console.error( 'THREE.Matrix4: .rotateY() has been removed.' ); + }, - rotateZ: function ( angle ) { + rotateZ: function () { + console.error( 'THREE.Matrix4: .rotateZ() has been removed.' ); + }, - rotateByAxis: function ( axis, angle ) { + rotateByAxis: function () { + console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); - } - } ); - Object.assign( Plane.prototype, { - isIntersectionLine: function ( line ) { - console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); - return this.intersectsLine( line ); } - } ); - Object.assign( Quaternion.prototype, { - multiplyVector3: function ( vector ) { - console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); - return vector.applyQuaternion( this ); - } } ); + Plane.prototype.isIntersectionLine = function ( line ) { + + console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); + return this.intersectsLine( line ); + + }; + + Quaternion.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); + return vector.applyQuaternion( this ); + + }; + Object.assign( Ray.prototype, { + isIntersectionBox: function ( box ) { + console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionPlane: function ( plane ) { + console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' ); return this.intersectsPlane( plane ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + } + } ); Object.assign( Shape.prototype, { + extrude: function ( options ) { + console.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' ); return new ExtrudeGeometry( this, options ); + }, makeGeometry: function ( options ) { + console.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' ); return new ShapeGeometry( this, options ); + } + } ); Object.assign( Vector3.prototype, { + setEulerFromRotationMatrix: function () { + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + }, setEulerFromQuaternion: function () { + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + }, getPositionFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); return this.setFromMatrixPosition( m ); + }, getScaleFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); return this.setFromMatrixScale( m ); + }, getColumnFromMatrix: function ( index, matrix ) { + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); return this.setFromMatrixColumn( matrix, index ); + } + } ); // + Geometry.prototype.computeTangents = function () { + + console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); + + }; + Object.assign( Object3D.prototype, { + getChildByName: function ( name ) { + console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); return this.getObjectByName( name ); + }, - renderDepth: function ( value ) { + renderDepth: function () { + console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' ); + }, translate: function ( distance, axis ) { + console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' ); return this.translateOnAxis( axis, distance ); + } + } ); Object.defineProperties( Object3D.prototype, { + eulerOrder: { get: function () { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); return this.rotation.order; + }, set: function ( value ) { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); this.rotation.order = value; + } }, useQuaternion: { get: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + } } + } ); Object.defineProperties( LOD.prototype, { + objects: { get: function () { + console.warn( 'THREE.LOD: .objects has been renamed to .levels.' ); return this.levels; + } } + } ); // @@ -41850,78 +42003,104 @@ Object.defineProperties( Light.prototype, { onlyShadow: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .onlyShadow has been removed.' ); + } }, shadowCameraFov: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' ); this.shadow.camera.fov = value; + } }, shadowCameraLeft: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' ); this.shadow.camera.left = value; + } }, shadowCameraRight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' ); this.shadow.camera.right = value; + } }, shadowCameraTop: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' ); this.shadow.camera.top = value; + } }, shadowCameraBottom: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' ); this.shadow.camera.bottom = value; + } }, shadowCameraNear: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' ); this.shadow.camera.near = value; + } }, shadowCameraFar: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' ); this.shadow.camera.far = value; + } }, shadowCameraVisible: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' ); + } }, shadowBias: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' ); this.shadow.bias = value; + } }, shadowDarkness: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowDarkness has been removed.' ); + } }, shadowMapWidth: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' ); this.shadow.mapSize.width = value; + } }, shadowMapHeight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' ); this.shadow.mapSize.height = value; + } } } ); @@ -41929,111 +42108,161 @@ // Object.defineProperties( BufferAttribute.prototype, { + length: { get: function () { - console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' ); + + console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' ); return this.array.length; + } } + } ); Object.assign( BufferGeometry.prototype, { + addIndex: function ( index ) { + console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); this.setIndex( index ); + }, addDrawCall: function ( start, count, indexOffset ) { + if ( indexOffset !== undefined ) { + console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); + } console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); this.addGroup( start, count ); + }, clearDrawCalls: function () { + console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' ); this.clearGroups(); + }, computeTangents: function () { + console.warn( 'THREE.BufferGeometry: .computeTangents() has been removed.' ); + }, computeOffsets: function () { + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); + } + } ); Object.defineProperties( BufferGeometry.prototype, { + drawcalls: { get: function () { + console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); return this.groups; + } }, offsets: { get: function () { + console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' ); return this.groups; + } } + } ); // Object.defineProperties( Uniform.prototype, { + dynamic: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.' ); + } }, onUpdate: { value: function () { + console.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' ); return this; + } } + } ); // Object.defineProperties( Material.prototype, { + wrapAround: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + } }, wrapRGB: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapRGB has been removed.' ); return new Color(); + } } + } ); Object.defineProperties( MeshPhongMaterial.prototype, { + metal: { get: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' ); return false; + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead' ); + } } + } ); Object.defineProperties( ShaderMaterial.prototype, { + derivatives: { get: function () { + console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); return this.extensions.derivatives; + }, set: function ( value ) { + console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); this.extensions.derivatives = value; + } } + } ); // @@ -42058,224 +42287,315 @@ // Object.assign( WebGLRenderer.prototype, { + supportsFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); return this.extensions.get( 'OES_texture_float' ); + }, supportsHalfFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' ); return this.extensions.get( 'OES_texture_half_float' ); + }, supportsStandardDerivatives: function () { + console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' ); return this.extensions.get( 'OES_standard_derivatives' ); + }, supportsCompressedTextureS3TC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_s3tc' ); + }, supportsCompressedTexturePVRTC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + }, supportsBlendMinMax: function () { + console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' ); return this.extensions.get( 'EXT_blend_minmax' ); + }, supportsVertexTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' ); return this.capabilities.vertexTextures; + }, supportsInstancedArrays: function () { + console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' ); return this.extensions.get( 'ANGLE_instanced_arrays' ); + }, enableScissorTest: function ( boolean ) { + console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' ); this.setScissorTest( boolean ); + }, initMaterial: function () { + console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' ); + }, addPrePlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' ); + }, addPostPlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' ); + }, updateShadowMap: function () { + console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' ); + } + } ); Object.defineProperties( WebGLRenderer.prototype, { + shadowMapEnabled: { get: function () { + return this.shadowMap.enabled; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); this.shadowMap.enabled = value; + } }, shadowMapType: { get: function () { + return this.shadowMap.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); this.shadowMap.type = value; + } }, shadowMapCullFace: { get: function () { + return this.shadowMap.cullFace; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.' ); this.shadowMap.cullFace = value; + } } } ); Object.defineProperties( WebGLShadowMap.prototype, { + cullFace: { get: function () { + return this.renderReverseSided ? CullFaceFront : CullFaceBack; + }, set: function ( cullFace ) { + var value = ( cullFace !== CullFaceBack ); console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." ); this.renderReverseSided = value; + } } + } ); // Object.defineProperties( WebGLRenderTarget.prototype, { + wrapS: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); return this.texture.wrapS; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); this.texture.wrapS = value; + } }, wrapT: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); return this.texture.wrapT; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); this.texture.wrapT = value; + } }, magFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); return this.texture.magFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); this.texture.magFilter = value; + } }, minFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); return this.texture.minFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); this.texture.minFilter = value; + } }, anisotropy: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); return this.texture.anisotropy; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); this.texture.anisotropy = value; + } }, offset: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); return this.texture.offset; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); this.texture.offset = value; + } }, repeat: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); return this.texture.repeat; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); this.texture.repeat = value; + } }, format: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); return this.texture.format; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); this.texture.format = value; + } }, type: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); return this.texture.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); this.texture.type = value; + } }, generateMipmaps: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); return this.texture.generateMipmaps; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); this.texture.generateMipmaps = value; + } } + } ); // - Object.assign( Audio.prototype, { - load: function ( file ) { - console.warn( 'THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.' ); - var scope = this; - var audioLoader = new AudioLoader(); - audioLoader.load( file, function ( buffer ) { - scope.setBuffer( buffer ); - } ); - return this; - } - } ); + Audio.prototype.load = function ( file ) { - Object.assign( AudioAnalyser.prototype, { - getData: function ( file ) { - console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); - return this.getFrequencyData(); - } - } ); + console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' ); + var scope = this; + var audioLoader = new AudioLoader(); + audioLoader.load( file, function ( buffer ) { + + scope.setBuffer( buffer ); + + } ); + return this; + + }; + + AudioAnalyser.prototype.getData = function () { + + console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); + return this.getFrequencyData(); + + }; // @@ -42284,7 +42604,6 @@ merge: function ( geometry1, geometry2, materialIndexOffset ) { console.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' ); - var matrix; if ( geometry2.isMesh ) { @@ -42424,7 +42743,7 @@ // - function Projector () { + function Projector() { console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' ); @@ -42442,7 +42761,7 @@ }; - this.pickingRay = function ( vector, camera ) { + this.pickingRay = function () { console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' ); @@ -42452,7 +42771,7 @@ // - function CanvasRenderer () { + function CanvasRenderer() { console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' ); @@ -42467,7 +42786,6 @@ exports.WebGLRenderTargetCube = WebGLRenderTargetCube; exports.WebGLRenderTarget = WebGLRenderTarget; exports.WebGLRenderer = WebGLRenderer; - exports.WebGL2Renderer = WebGL2Renderer; exports.ShaderLib = ShaderLib; exports.UniformsLib = UniformsLib; exports.ShaderChunk = ShaderChunk; @@ -42491,9 +42809,7 @@ exports.CubeTexture = CubeTexture; exports.CanvasTexture = CanvasTexture; exports.DepthTexture = DepthTexture; - exports.TextureIdCount = TextureIdCount; exports.Texture = Texture; - exports.MaterialIdCount = MaterialIdCount; exports.CompressedTextureLoader = CompressedTextureLoader; exports.BinaryTextureLoader = BinaryTextureLoader; exports.DataTextureLoader = DataTextureLoader; @@ -42553,18 +42869,7 @@ exports.InstancedInterleavedBuffer = InstancedInterleavedBuffer; exports.InterleavedBuffer = InterleavedBuffer; exports.InstancedBufferAttribute = InstancedBufferAttribute; - exports.Float64BufferAttribute = Float64BufferAttribute; - exports.Float32BufferAttribute = Float32BufferAttribute; - exports.Uint32BufferAttribute = Uint32BufferAttribute; - exports.Int32BufferAttribute = Int32BufferAttribute; - exports.Uint16BufferAttribute = Uint16BufferAttribute; - exports.Int16BufferAttribute = Int16BufferAttribute; - exports.Uint8ClampedBufferAttribute = Uint8ClampedBufferAttribute; - exports.Uint8BufferAttribute = Uint8BufferAttribute; - exports.Int8BufferAttribute = Int8BufferAttribute; - exports.BufferAttribute = BufferAttribute; exports.Face3 = Face3; - exports.Object3DIdCount = Object3DIdCount; exports.Object3D = Object3D; exports.Raycaster = Raycaster; exports.Layers = Layers; @@ -42603,14 +42908,13 @@ exports.RectAreaLightHelper = RectAreaLightHelper; exports.HemisphereLightHelper = HemisphereLightHelper; exports.GridHelper = GridHelper; + exports.PolarGridHelper = PolarGridHelper; exports.FaceNormalsHelper = FaceNormalsHelper; exports.DirectionalLightHelper = DirectionalLightHelper; exports.CameraHelper = CameraHelper; - exports.BoundingBoxHelper = BoundingBoxHelper; exports.BoxHelper = BoxHelper; exports.ArrowHelper = ArrowHelper; exports.AxisHelper = AxisHelper; - exports.ClosedSplineCurve3 = ClosedSplineCurve3; exports.CatmullRomCurve3 = CatmullRomCurve3; exports.SplineCurve3 = SplineCurve3; exports.CubicBezierCurve3 = CubicBezierCurve3; @@ -42680,6 +42984,7 @@ exports.MeshPhysicalMaterial = MeshPhysicalMaterial; exports.MeshStandardMaterial = MeshStandardMaterial; exports.MeshPhongMaterial = MeshPhongMaterial; + exports.MeshToonMaterial = MeshToonMaterial; exports.MeshNormalMaterial = MeshNormalMaterial; exports.MeshLambertMaterial = MeshLambertMaterial; exports.MeshDepthMaterial = MeshDepthMaterial; @@ -42687,6 +42992,16 @@ exports.LineDashedMaterial = LineDashedMaterial; exports.LineBasicMaterial = LineBasicMaterial; exports.Material = Material; + exports.Float64BufferAttribute = Float64BufferAttribute; + exports.Float32BufferAttribute = Float32BufferAttribute; + exports.Uint32BufferAttribute = Uint32BufferAttribute; + exports.Int32BufferAttribute = Int32BufferAttribute; + exports.Uint16BufferAttribute = Uint16BufferAttribute; + exports.Int16BufferAttribute = Int16BufferAttribute; + exports.Uint8ClampedBufferAttribute = Uint8ClampedBufferAttribute; + exports.Uint8BufferAttribute = Uint8BufferAttribute; + exports.Int8BufferAttribute = Int8BufferAttribute; + exports.BufferAttribute = BufferAttribute; exports.REVISION = REVISION; exports.MOUSE = MOUSE; exports.CullFaceNone = CullFaceNone; @@ -42820,9 +43135,9 @@ exports.Face4 = Face4; exports.LineStrip = LineStrip; exports.LinePieces = LinePieces; - exports.MeshFaceMaterial = MultiMaterial; + exports.MeshFaceMaterial = MeshFaceMaterial; exports.PointCloud = PointCloud; - exports.Particle = Sprite; + exports.Particle = Particle; exports.ParticleSystem = ParticleSystem; exports.PointCloudMaterial = PointCloudMaterial; exports.ParticleBasicMaterial = ParticleBasicMaterial; @@ -42838,6 +43153,8 @@ exports.Uint32Attribute = Uint32Attribute; exports.Float32Attribute = Float32Attribute; exports.Float64Attribute = Float64Attribute; + exports.ClosedSplineCurve3 = ClosedSplineCurve3; + exports.BoundingBoxHelper = BoundingBoxHelper; exports.EdgesHelper = EdgesHelper; exports.WireframeHelper = WireframeHelper; exports.XHRLoader = XHRLoader; diff --git a/build/three.min.js b/build/three.min.js index a84a59eae5438253b84629953e80dc4af0841ce3..a5aaa29f4f46ca15bd30f9a0288f6d5e38366e11 100644 --- a/build/three.min.js +++ b/build/three.min.js @@ -1,352 +1,354 @@ // threejs.org/license -(function(l,ra){"object"===typeof exports&&"undefined"!==typeof module?ra(exports):"function"===typeof define&&define.amd?define(["exports"],ra):ra(l.THREE=l.THREE||{})})(this,function(l){function ra(){}function D(a,b){this.x=a||0;this.y=b||0}function ea(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:ke++});this.uuid=S.generateUUID();this.name="";this.image=void 0!==a?a:ea.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:ea.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT= -void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new D(0,0);this.repeat=new D(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function fa(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Cb(a,b,c){this.uuid=S.generateUUID();this.width= -a;this.height=b;this.scissor=new fa(0,0,a,b);this.scissorTest=!1;this.viewport=new fa(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new ea(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Db(a,b,c){Cb.call(this,a,b,c);this.activeMipMapLevel= -this.activeCubeFace=0}function la(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function H(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0= -d||0 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); -z.compileShader(P);z.compileShader(M);z.attachShader(O,P);z.attachShader(O,M);z.linkProgram(O);A=O;u=z.getAttribLocation(A,"position");v=z.getAttribLocation(A,"uv");c=z.getUniformLocation(A,"uvOffset");d=z.getUniformLocation(A,"uvScale");e=z.getUniformLocation(A,"rotation");f=z.getUniformLocation(A,"scale");g=z.getUniformLocation(A,"color");h=z.getUniformLocation(A,"map");k=z.getUniformLocation(A,"opacity");m=z.getUniformLocation(A,"modelViewMatrix");y=z.getUniformLocation(A,"projectionMatrix");p= -z.getUniformLocation(A,"fogType");n=z.getUniformLocation(A,"fogDensity");r=z.getUniformLocation(A,"fogNear");x=z.getUniformLocation(A,"fogFar");l=z.getUniformLocation(A,"fogColor");F=z.getUniformLocation(A,"alphaTest");O=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");O.width=8;O.height=8;P=O.getContext("2d");P.fillStyle="white";P.fillRect(0,0,8,8);ma=new ea(O);ma.needsUpdate=!0}z.useProgram(A);N.initAttributes();N.enableAttribute(u);N.enableAttribute(v);N.disableUnusedAttributes(); -N.disable(z.CULL_FACE);N.enable(z.BLEND);z.bindBuffer(z.ARRAY_BUFFER,G);z.vertexAttribPointer(u,2,z.FLOAT,!1,16,0);z.vertexAttribPointer(v,2,z.FLOAT,!1,16,8);z.bindBuffer(z.ELEMENT_ARRAY_BUFFER,E);z.uniformMatrix4fv(y,!1,U.projectionMatrix.elements);N.activeTexture(z.TEXTURE0);z.uniform1i(h,0);P=O=0;(M=q.fog)?(z.uniform3f(l,M.color.r,M.color.g,M.color.b),M.isFog?(z.uniform1f(r,M.near),z.uniform1f(x,M.far),z.uniform1i(p,1),P=O=1):M.isFogExp2&&(z.uniform1f(n,M.density),z.uniform1i(p,2),P=O=2)):(z.uniform1i(p, -0),P=O=0);for(var M=0,T=b.length;M/g,function(a,c){var d=X[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return Id(d)})}function Be(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);c< -parseInt(d);c++)a+=e.replace(/\[ i \]/g,"[ "+c+" ]");return a})}function xf(a,b,c,d){var e=a.context,f=c.extensions,g=c.defines,h=c.__webglShader.vertexShader,k=c.__webglShader.fragmentShader,m="SHADOWMAP_TYPE_BASIC";1===d.shadowMapType?m="SHADOWMAP_TYPE_PCF":2===d.shadowMapType&&(m="SHADOWMAP_TYPE_PCF_SOFT");var y="ENVMAP_TYPE_CUBE",p="ENVMAP_MODE_REFLECTION",n="ENVMAP_BLENDING_MULTIPLY";if(d.envMap){switch(c.envMap.mapping){case 301:case 302:y="ENVMAP_TYPE_CUBE";break;case 306:case 307:y="ENVMAP_TYPE_CUBE_UV"; -break;case 303:case 304:y="ENVMAP_TYPE_EQUIREC";break;case 305:y="ENVMAP_TYPE_SPHERE"}switch(c.envMap.mapping){case 302:case 304:p="ENVMAP_MODE_REFRACTION"}switch(c.combine){case 0:n="ENVMAP_BLENDING_MULTIPLY";break;case 1:n="ENVMAP_BLENDING_MIX";break;case 2:n="ENVMAP_BLENDING_ADD"}}var r=0b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+ -a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function k(a){return S.isPowerOfTwo(a.width)&&S.isPowerOfTwo(a.height)}function m(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function y(b){b=b.target;b.removeEventListener("dispose",y);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d["delete"](b)}q.textures--}function p(b){b=b.target; +(function(l,oa){"object"===typeof exports&&"undefined"!==typeof module?oa(exports):"function"===typeof define&&define.amd?define(["exports"],oa):oa(l.THREE=l.THREE||{})})(this,function(l){function oa(){}function F(a,b){this.x=a||0;this.y=b||0}function ea(a,b,c,d,e,f,g,h,k,m){Object.defineProperty(this,"id",{value:Ne++});this.uuid=S.generateUUID();this.name="";this.image=void 0!==a?a:ea.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:ea.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT= +void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new F(0,0);this.repeat=new F(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function ha(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function Db(a,b,c){this.uuid=S.generateUUID();this.width= +a;this.height=b;this.scissor=new ha(0,0,a,b);this.scissorTest=!1;this.viewport=new ha(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=1006);this.texture=new ea(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,c.encoding);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Eb(a,b,c){Db.call(this,a,b,c);this.activeMipMapLevel= +this.activeCubeFace=0}function da(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function q(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function P(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0= +d||0 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n")); +y.compileShader(O);y.compileShader(Q);y.attachShader(N,O);y.attachShader(N,Q);y.linkProgram(N);K=N;t=y.getAttribLocation(K,"position");v=y.getAttribLocation(K,"uv");c=y.getUniformLocation(K,"uvOffset");d=y.getUniformLocation(K,"uvScale");e=y.getUniformLocation(K,"rotation");f=y.getUniformLocation(K,"scale");g=y.getUniformLocation(K,"color");h=y.getUniformLocation(K,"map");k=y.getUniformLocation(K,"opacity");m=y.getUniformLocation(K,"modelViewMatrix");x=y.getUniformLocation(K,"projectionMatrix");p= +y.getUniformLocation(K,"fogType");n=y.getUniformLocation(K,"fogDensity");r=y.getUniformLocation(K,"fogNear");w=y.getUniformLocation(K,"fogFar");l=y.getUniformLocation(K,"fogColor");z=y.getUniformLocation(K,"alphaTest");N=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");N.width=8;N.height=8;O=N.getContext("2d");O.fillStyle="white";O.fillRect(0,0,8,8);fa=new ea(N);fa.needsUpdate=!0}y.useProgram(K);C.initAttributes();C.enableAttribute(t);C.enableAttribute(v);C.disableUnusedAttributes(); +C.disable(y.CULL_FACE);C.enable(y.BLEND);y.bindBuffer(y.ARRAY_BUFFER,H);y.vertexAttribPointer(t,2,y.FLOAT,!1,16,0);y.vertexAttribPointer(v,2,y.FLOAT,!1,16,8);y.bindBuffer(y.ELEMENT_ARRAY_BUFFER,E);y.uniformMatrix4fv(x,!1,Gb.projectionMatrix.elements);C.activeTexture(y.TEXTURE0);y.uniform1i(h,0);O=N=0;(Q=q.fog)?(y.uniform3f(l,Q.color.r,Q.color.g,Q.color.b),Q.isFog?(y.uniform1f(r,Q.near),y.uniform1f(w,Q.far),y.uniform1i(p,1),O=N=1):Q.isFogExp2&&(y.uniform1f(n,Q.density),y.uniform1i(p,2),O=N=2)):(y.uniform1i(p, +0),O=N=0);for(var Q=0,T=b.length;Q/g,function(a,c){var d=Z[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return Md(d)})}function Ce(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,c,d,e){a="";for(c=parseInt(c);cb||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElementNS("http://www.w3.org/1999/xhtml","canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+ +a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function k(a){return S.isPowerOfTwo(a.width)&&S.isPowerOfTwo(a.height)}function m(b){return 1003===b||1004===b||1005===b?a.NEAREST:a.LINEAR}function x(b){b=b.target;b.removeEventListener("dispose",x);a:{var c=d.get(b);if(b.image&&c.__image__webglTextureCube)a.deleteTexture(c.__image__webglTextureCube);else{if(void 0===c.__webglInit)break a;a.deleteTexture(c.__webglTexture)}d["delete"](b)}q.textures--}function p(b){b=b.target; b.removeEventListener("dispose",p);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);d["delete"](b.texture);d["delete"](b)}q.textures--}function n(b, -g){var m=d.get(b);if(0x;x++)l[x]=n||p?p?b.image[x].image:b.image[x]:h(b.image[x],e.maxCubemapSize);var t=k(l[0]),u=f(b.format),w=f(b.type);r(a.TEXTURE_CUBE_MAP, -b,t);for(x=0;6>x;x++)if(n)for(var D,C=l[x].mipmaps,U=0,O=C.length;Um;m++)e.__webglFramebuffer[m]=a.createFramebuffer()}else e.__webglFramebuffer=a.createFramebuffer();if(g){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);r(a.TEXTURE_CUBE_MAP,b.texture,h);for(m=0;6>m;m++)l(e.__webglFramebuffer[m],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m);b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_CUBE_MAP);c.bindTexture(a.TEXTURE_CUBE_MAP, -null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),r(a.TEXTURE_2D,b.texture,h),l(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_2D),c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!");a.bindFramebuffer(a.FRAMEBUFFER, -e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&&b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);n(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER, -a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format");}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),t(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),t(e.__webglDepthbuffer, -b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture;e.generateMipmaps&&k(b)&&1003!==e.minFilter&&1006!==e.minFilter&&(b=b&&b.isWebGLRenderTargetCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,e=d.get(e).__webglTexture,c.bindTexture(b,e),a.generateMipmap(b),c.bindTexture(b,null))}}function Df(){var a={};return{get:function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c},"delete":function(b){delete a[b.uuid]},clear:function(){a={}}}}function Ce(a,b,c){function d(b, -c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b=ka.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ka.maxTextures);ba+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&& -(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);va.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);va.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."), -a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?va.setTextureCube(b,c):va.setTextureCubeDynamic(b,c)}}();this.getCurrentRenderTarget=function(){return ua};this.setRenderTarget=function(a){(ua=a)&&void 0===ha.get(a).__webglFramebuffer&&va.setupRenderTarget(a);var b=a&&a.isWebGLRenderTargetCube,c;a?(c=ha.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,W.copy(a.scissor),Z=a.scissorTest,Qa.copy(a.viewport)):(c=null,W.copy(ea).multiplyScalar(Ta), -Z=ja,Qa.copy(ga).multiplyScalar(Ta));V!==c&&(B.bindFramebuffer(B.FRAMEBUFFER,c),V=c);Y.scissor(W);Y.setScissorTest(Z);Y.viewport(Qa);b&&(b=ha.get(a.texture),B.framebufferTexture2D(B.FRAMEBUFFER,B.COLOR_ATTACHMENT0,B.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===(a&&a.isWebGLRenderTarget))console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g= -ha.get(a).__webglFramebuffer;if(g){var h=!1;g!==V&&(B.bindFramebuffer(B.FRAMEBUFFER,g),h=!0);try{var k=a.texture,m=k.format,n=k.type;1023!==m&&F(m)!==B.getParameter(B.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===n||F(n)===B.getParameter(B.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n&&(ia.get("OES_texture_float")||ia.get("WEBGL_color_buffer_float"))||1016===n&&ia.get("EXT_color_buffer_half_float")? -B.checkFramebufferStatus(B.FRAMEBUFFER)===B.FRAMEBUFFER_COMPLETE?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&B.readPixels(b,c,d,e,F(m),F(n),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&B.bindFramebuffer(B.FRAMEBUFFER,V)}}}}}function Hb(a,b){this.name="";this.color=new Q(a);this.density= -void 0!==b?b:2.5E-4}function Ib(a,b,c){this.name="";this.color=new Q(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function kb(){C.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function Kd(a,b,c,d,e){C.call(this);this.lensFlares=[];this.positionScreen=new q;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)}function lb(a){W.call(this);this.type="SpriteMaterial";this.color=new Q(16777215);this.map=null;this.rotation=0;this.lights= -this.fog=!1;this.setValues(a)}function xc(a){C.call(this);this.type="Sprite";this.material=void 0!==a?a:new lb}function yc(){C.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function hd(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new H;a=a||[];this.bones=a.slice(0);this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=S.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth* -this.boneTextureHeight*4),this.boneTexture=new gb(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,1023,1015)):this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b=0,a=this.bones.length;b=a.HAVE_CURRENT_DATA&&(y.needsUpdate=!0)}ea.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var y=this;m()}function Kb(a,b,c,d,e,f,g,h,k,m,y,p){ea.call(this,null,f,g,h,k,m,d,e,y,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function ld(a,b,c,d,e,f,g,h,k){ea.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function Ac(a,b,c,d,e,f,g,h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!== -m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");ea.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.type=void 0!==c?c:1012;this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Lb(a){function b(a,b){return a-b}J.call(this);var c=[0,0],d={},e=["a","b","c"];if(a&&a.isGeometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length);a=0;for(var m=g.length;ap;p++){c[0]=y[e[p]];c[1]=y[e[(p+1)%3]];c.sort(b);var n=c.toString();void 0===d[n]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[n]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;ap;p++)d=f[k[2*a+p]],h=6*a+3*p,c[h+0]=d.x,c[h+1]=d.y,c[h+2]=d.z;this.addAttribute("position",new w(c,3))}else if(a&&a.isBufferGeometry){if(null!==a.index){m=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,m.length);k=new Uint32Array(2*m.length);g=0;for(y=e.length;gp;p++)c[0]=m[a+p],c[1]=m[a+(p+1)%3],c.sort(b),n=c.toString(),void 0===d[n]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[n]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;ap;p++)h=6*a+3*p,d=k[2*a+p],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,m=k;ap;p++)h=18*a+6*p,k=9*a+3*p,c[h+0]=f[k],c[h+1]=f[k+1],c[h+2]=f[k+2],d=9*a+(p+1)%3*3,c[h+3]= -f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new w(c,3))}}function Mb(a,b,c){J.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f,g,h,k,m,y=b+1;for(f=0;f<=c;f++)for(m=f/c,g=0;g<=b;g++)k=g/b,h=a(k,m),d.push(h.x,h.y,h.z),e.push(k,m);a=[];var p;for(f=0;fd&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}J.call(this);this.type="PolyhedronBufferGeometry";this.parameters= -{vertices:a,indices:b,radius:c,detail:d};c=c||1;var h=[],k=[];(function(a){for(var c=new q,d=new q,g=new q,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",new ba(h,3));this.addAttribute("normal",new ba(h.slice(),3));this.addAttribute("uv",new ba(k,2));this.normalizeNormals();this.boundingSphere= -new Ha(new q,c)}function Nb(a,b){pa.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Cc(a,b){R.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Nb(a,b));this.mergeVertices()}function Ob(a,b){pa.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry"; -this.parameters={radius:a,detail:b}}function Dc(a,b){R.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Ob(a,b));this.mergeVertices()}function Pb(a,b){var c=(1+Math.sqrt(5))/2;pa.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry"; -this.parameters={radius:a,detail:b}}function Ec(a,b){R.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Pb(a,b));this.mergeVertices()}function Qb(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;pa.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18, -0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Fc(a,b){R.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qb(a,b));this.mergeVertices()}function Gc(a,b,c,d){R.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b, -radius:c,detail:d};this.fromBufferGeometry(new pa(a,b,c,d));this.mergeVertices()}function Rb(a,b,c,d,e){function f(e){var f=a.getPointAt(e/b),m=g.normals[e];e=g.binormals[e];for(p=0;p<=d;p++){var y=p/d*Math.PI*2,l=Math.sin(y),y=-Math.cos(y);k.x=y*m.x+l*e.x;k.y=y*m.y+l*e.y;k.z=y*m.z+l*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=f.x+c*k.x;h.y=f.y+c*k.y;h.z=f.z+c*k.z;n.push(h.x,h.y,h.z)}}J.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e}; -b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new q,k=new q,m=new D,y,p,n=[],r=[],l=[],t=[];for(y=0;yn;n++){e[0]=p[g[n]];e[1]=p[g[(n+1)%3]];e.sort(c);var r=e.toString();void 0===f[r]?f[r]={vert1:e[0],vert2:e[1],face1:m,face2:void 0}:f[r].face2=m}e=[];for(r in f)if(g=f[r],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)m=k[g.vert1],e.push(m.x),e.push(m.y),e.push(m.z),m=k[g.vert2],e.push(m.x),e.push(m.y),e.push(m.z);this.addAttribute("position",new w(new Float32Array(e),3))}function Wa(a,b,c,d,e,f,g,h){function k(c){var e,f,k,n=new D, -p=new q,l=0,y=!0===c?a:b,L=!0===c?1:-1;f=u;for(e=1;e<=d;e++)x.setXYZ(u,0,z*L,0),t.setXYZ(u,0,L,0),n.x=.5,n.y=.5,F.setXY(u,n.x,n.y),u++;k=u;for(e=0;e<=d;e++){var w=e/d*h+g,C=Math.cos(w),w=Math.sin(w);p.x=y*w;p.y=z*L;p.z=y*C;x.setXYZ(u,p.x,p.y,p.z);t.setXYZ(u,0,L,0);n.x=.5*C+.5;n.y=.5*w*L+.5;F.setXY(u,n.x,n.y);u++}for(e=0;ethis.duration&&this.resetDuration();this.optimize()}function Ad(a){this.manager=void 0!==a?a:sa;this.textures={}}function Od(a){this.manager=void 0!==a?a:sa}function wb(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}function Pd(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!== -a?a:sa;this.withCredentials=!1}function Fe(a){this.manager=void 0!==a?a:sa;this.texturePath=""}function ta(){}function Ra(a,b){this.v1=a;this.v2=b}function Vc(){this.curves=[];this.autoClose=!1}function Xa(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0}function xb(a){this.points=void 0===a?[]:a}function yb(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d}function zb(a,b,c){this.v0=a;this.v1=b;this.v2=c}function Ya(){Wc.apply(this, -arguments);this.holes=[]}function Wc(a){Vc.call(this);this.currentPoint=new D;a&&this.fromPoints(a)}function Qd(){this.subPaths=[];this.currentPath=null}function Rd(a){this.data=a}function Ge(a){this.manager=void 0!==a?a:sa}function Sd(a){this.manager=void 0!==a?a:sa}function Td(a,b,c,d){oa.call(this,a,b);this.type="RectAreaLight";this.position.set(0,1,0);this.updateMatrix();this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function He(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064; -this.cameraL=new Ia;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Ia;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function Bd(a,b,c){C.call(this);this.type="CubeCamera";var d=new Ia(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new q(1,0,0));this.add(d);var e=new Ia(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new q(-1,0,0));this.add(e);var f=new Ia(90,1,a,b);f.up.set(0,0,1);f.lookAt(new q(0,1,0));this.add(f);var g=new Ia(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new q(0, --1,0));this.add(g);var h=new Ia(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new q(0,0,1));this.add(h);var k=new Ia(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new q(0,0,-1));this.add(k);this.renderTarget=new Db(c,c,{format:1022,magFilter:1006,minFilter:1006});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,n=c.texture.generateMipmaps;c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b, -f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=n;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}}function Ud(){C.call(this);this.type="AudioListener";this.context=Vd.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function dc(a){C.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this); -this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function Wd(a){dc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function Xd(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)} -function Cd(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function ga(a,b,c){this.path=b;this.parsedPath=c||ga.parseTrackName(b);this.node=ga.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function Yd(a){this.uuid=S.generateUUID();this._objects=Array.prototype.slice.call(arguments); -this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}function Zd(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400, -endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd= -this.zeroSlopeAtStart=!0}function $d(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Ie(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Ab(){J.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function ae(a,b,c,d){this.uuid=S.generateUUID();this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function ec(a,b){this.uuid=S.generateUUID();this.array= -a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function fc(a,b,c){ec.call(this,a,b);this.meshPerAttribute=c||1}function gc(a,b,c){w.call(this,a,b);this.meshPerAttribute=c||1}function be(a,b,c,d){this.ray=new cb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points."); -return this.Points}}})}function Je(a,b){return a.distance-b.distance}function ce(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new ba(b,3));b=new da({fog:!1});this.cone=new ja(a,b);this.add(this.cone);this.update()}function ic(a){this.bones=this.getBoneList(a);for(var b=new R, -c=0;cd;d++)c.faces[d].color=this.colors[4>d?0:1];d=new Ka({vertexColors:1,wireframe:!0});this.lightSphere=new wa(c,d);this.add(this.lightSphere);this.update()}function Zc(a,b,c,d){b=b||1;c=new Q(void 0!==c?c:4473924);d=new Q(void 0!== -d?d:8947848);for(var e=b/2,f=2*a/b,g=[],h=[],k=0,m=0,l=-a;k<=b;k++,l+=f){g.push(-a,0,l,a,0,l);g.push(l,0,-a,l,0,a);var p=k===e?c:d;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3}a=new J;a.addAttribute("position",new ba(g,3));a.addAttribute("color",new ba(h,3));g=new da({vertexColors:2});ja.call(this,a,g)}function $c(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead."); -c=new J;b=new ba(6*b,3);c.addAttribute("position",b);ja.call(this,c,new da({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function mc(a,b){C.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;void 0===b&&(b=1);var c=new J;c.addAttribute("position",new ba([-b,b,0,b,b,0,b,-b,0,-b,-b,0,-b,b,0],3));var d=new da({fog:!1});this.add(new Va(c,d));c=new J;c.addAttribute("position",new ba([0,0,0,0,0,1],3));this.add(new Va(c,d));this.update()} -function ad(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new q);d.colors.push(new Q(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new R,e=new da({color:16777215,vertexColors:1}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680); -b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);ja.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()}function bd(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box= -new Ba;wa.call(this,new ob(1,1,1),new Ka({color:c,wireframe:!0}))}function cd(a,b){void 0===b&&(b=16776960);var c=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),d=new Float32Array(24),e=new J;e.setIndex(new w(c,1));e.addAttribute("position",new w(d,3));ja.call(this,e,new da({color:b}));void 0!==a&&this.update(a)}function Bb(a,b,c,d,e,f){C.call(this);void 0===d&&(d=16776960);void 0===c&&(c=1);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);this.position.copy(b);this.line=new Va(Ke,new da({color:d})); -this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new wa(Le,new Ka({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function Dd(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new J;a.addAttribute("position",new w(b,3));a.addAttribute("color",new w(c,3));b=new da({vertexColors:2});ja.call(this,a,b)}function Me(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3."); -fe.call(this,a);this.type="catmullrom";this.closed=!0}function Ed(a,b,c,d,e,f){Xa.call(this,a,b,c,c,d,e,f)}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a, -b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a* -S.DEG2RAD},radToDeg:function(a){return a*S.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};D.prototype={constructor:D,isVector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x= -a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!== -b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."), -this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y, -a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new D,b=new D);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y= -Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.multiplyScalar(a/ -this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+ -1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};ea.DEFAULT_IMAGE=void 0;ea.DEFAULT_MAPPING=300;ea.prototype={constructor:ea,isTexture:!0,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter= -a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;this.needsUpdate=a.needsUpdate;this.version=a.version;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"}, -uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var c=this.image;void 0===c.uuid&&(c.uuid=S.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),g.width=c.width, -g.height=c.height,g.getContext("2d").drawImage(c,0,0,c.width,c.height));g=2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)% -2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};Object.assign(ea.prototype,ra.prototype);var ke=0;fa.prototype={constructor:fa,isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x= -a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x, -this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this}, -addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)? -(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y= -0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var m=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+m-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;m=(m+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>m?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b): -h>m?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>m?(c=b=.707106781,d=0):(d=Math.sqrt(m),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x); -this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new fa,b=new fa);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y); -this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z); -this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w= -a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};Object.assign(Cb.prototype,ra.prototype,{isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0, -0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Db.prototype=Object.create(Cb.prototype);Db.prototype.constructor=Db;Db.prototype.isWebGLRenderTargetCube=!0;la.prototype={constructor:la,get x(){return this._x}, -set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback(); -return this},setFromEuler:function(a,b){if(!1===(a&&a.isEuler))throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x= -f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w= -Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+ -h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new q);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x* -a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."), -this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,m=b._w;this._x=c*m+f*g+d*k-e*h;this._y=d*m+f*h+e*g-c*k;this._z=e*m+f*k+c*h-d*g;this._w=f*m-c*g-d*h-e*k;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z; -0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x=== -this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Object.assign(la,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a, -b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==p){f=1-g;var n=h*d+k*l+m*p+c*e,r=0<=n?1:-1,x=1-n*n;x>Number.EPSILON&&(x=Math.sqrt(x),n=Math.atan2(x,n*r),f=Math.sin(f*n)/x,g=Math.sin(g*n)/x);r*=g;h=h*f+d*r;k=k*f+l*r;m=m*f+p*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});q.prototype={constructor:q,isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this}, -setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x, -this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+= -a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."), -this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===(b&&b.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new la);return this.applyQuaternion(a.setFromEuler(b))}}(), -applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new la);return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b= -this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new H); -a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new H);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c, -d){void 0===a&&(a=new q,b=new q);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this}, -roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+ -Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a, -b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new q);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0=== -a&&(a=new q);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(S.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius; -this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."); -var c=a;a=b;b=c}return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};H.prototype={constructor:H,isMatrix4:!0, -set:function(a,b,c,d,e,f,g,h,k,m,l,p,n,r,x,t){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=m;q[10]=l;q[14]=p;q[3]=n;q[7]=r;q[11]=x;q[15]=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new H).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a, -b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new q);var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]* -f;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;return this}}(),makeRotationFromEuler:function(a){!1===(a&&a.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,l=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-l*d;b[9]=-c*g;b[2]=l-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"=== -a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a+l*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=l+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a-l*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=l-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,l=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+l,b[1]=g*e,b[5]=l*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=l-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k* -e+m,b[10]=a-l*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+l,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=l*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var m=c*h,c=c*k,l=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(l+e);b[4]=m-f;b[8]=c+h;b[1]=m+f;b[5]=1-(a+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]= -0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new q,b=new q,c=new q);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.z+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."), -this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],l=c[5],p=c[9],n=c[13],r=c[2],x=c[6],t=c[10],q=c[14],u=c[3],v=c[7],L=c[11],c=c[15],z=d[0],N=d[4],G=d[8],E=d[12],A=d[1],w=d[5],I=d[9],D=d[13],C=d[2],H=d[6],U=d[10],O=d[14],P=d[3],M=d[7],T=d[11],d=d[15];e[0]=f*z+g*A+h*C+k*P;e[4]=f*N+g*w+h*H+k*M;e[8]=f*G+g*I+h*U+k*T;e[12]= -f*E+g*D+h*O+k*d;e[1]=m*z+l*A+p*C+n*P;e[5]=m*N+l*w+p*H+n*M;e[9]=m*G+l*I+p*U+n*T;e[13]=m*E+l*D+p*O+n*d;e[2]=r*z+x*A+t*C+q*P;e[6]=r*N+x*w+t*H+q*M;e[10]=r*G+x*I+t*U+q*T;e[14]=r*E+x*D+t*O+q*d;e[3]=u*z+v*A+L*C+c*P;e[7]=u*N+v*w+L*H+c*M;e[11]=u*G+v*I+L*U+c*T;e[15]=u*E+v*D+L*O+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12]; -c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ew;w++)l[w]=n||p?p?b.image[w].image:b.image[w]:h(b.image[w],e.maxCubemapSize);var u=k(l[0]),t=f(b.format),ca=f(b.type);r(a.TEXTURE_CUBE_MAP,b,u);for(w=0;6>w;w++)if(n)for(var F,B=l[w].mipmaps,A=0,N=B.length;Am;m++)e.__webglFramebuffer[m]=a.createFramebuffer()}else e.__webglFramebuffer= +a.createFramebuffer();if(g){c.bindTexture(a.TEXTURE_CUBE_MAP,f.__webglTexture);r(a.TEXTURE_CUBE_MAP,b.texture,h);for(m=0;6>m;m++)l(e.__webglFramebuffer[m],b,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+m);b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_CUBE_MAP);c.bindTexture(a.TEXTURE_CUBE_MAP,null)}else c.bindTexture(a.TEXTURE_2D,f.__webglTexture),r(a.TEXTURE_2D,b.texture,h),l(e.__webglFramebuffer,b,a.COLOR_ATTACHMENT0,a.TEXTURE_2D),b.texture.generateMipmaps&&h&&a.generateMipmap(a.TEXTURE_2D), +c.bindTexture(a.TEXTURE_2D,null);if(b.depthBuffer){e=d.get(b);f=!0===b.isWebGLRenderTargetCube;if(b.depthTexture){if(f)throw Error("target.depthTexture not supported in Cube render targets");if(b&&b.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!");a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer);if(!b.depthTexture||!b.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(b.depthTexture).__webglTexture&& +b.depthTexture.image.width===b.width&&b.depthTexture.image.height===b.height||(b.depthTexture.image.width=b.width,b.depthTexture.image.height=b.height,b.depthTexture.needsUpdate=!0);n(b.depthTexture,0);e=d.get(b.depthTexture).__webglTexture;if(1026===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_2D,e,0);else if(1027===b.depthTexture.format)a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_2D,e,0);else throw Error("Unknown depthTexture format"); +}else if(f)for(e.__webglDepthbuffer=[],f=0;6>f;f++)a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer[f]),e.__webglDepthbuffer[f]=a.createRenderbuffer(),u(e.__webglDepthbuffer[f],b);else a.bindFramebuffer(a.FRAMEBUFFER,e.__webglFramebuffer),e.__webglDepthbuffer=a.createRenderbuffer(),u(e.__webglDepthbuffer,b);a.bindFramebuffer(a.FRAMEBUFFER,null)}};this.updateRenderTargetMipmap=function(b){var e=b.texture;e.generateMipmaps&&k(b)&&1003!==e.minFilter&&1006!==e.minFilter&&(b=b&&b.isWebGLRenderTargetCube? +a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,e=d.get(e).__webglTexture,c.bindTexture(b,e),a.generateMipmap(b),c.bindTexture(b,null))}}function Ef(){var a={};return{get:function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c},"delete":function(b){delete a[b.uuid]},clear:function(){a={}}}}function Ff(a,b,c){function d(b,c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,a.TEXTURE_MIN_FILTER,a.NEAREST);a.texParameteri(b,a.TEXTURE_MAG_FILTER,a.NEAREST);for(b=0;b=ma.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+ma.maxTextures);Z+=1;return a};this.setTexture2D=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTarget&& +(a||(console.warn("THREE.WebGLRenderer.setTexture2D: don't use render targets as textures. Use their .texture property instead."),a=!0),b=b.texture);wa.setTexture2D(b,c)}}();this.setTexture=function(){var a=!1;return function(b,c){a||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),a=!0);wa.setTexture2D(b,c)}}();this.setTextureCube=function(){var a=!1;return function(b,c){b&&b.isWebGLRenderTargetCube&&(a||(console.warn("THREE.WebGLRenderer.setTextureCube: don't use cube render targets as textures. Use their .texture property instead."), +a=!0),b=b.texture);b&&b.isCubeTexture||Array.isArray(b.image)&&6===b.image.length?wa.setTextureCube(b,c):wa.setTextureCubeDynamic(b,c)}}();this.getCurrentRenderTarget=function(){return V};this.setRenderTarget=function(a){(V=a)&&void 0===ia.get(a).__webglFramebuffer&&wa.setupRenderTarget(a);var b=a&&a.isWebGLRenderTargetCube,c;a?(c=ia.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:c.__webglFramebuffer,X.copy(a.scissor),Ta=a.scissorTest,W.copy(a.viewport)):(c=null,X.copy(ga).multiplyScalar(Sa),Ta= +la,W.copy(ja).multiplyScalar(Sa));R!==c&&(D.bindFramebuffer(D.FRAMEBUFFER,c),R=c);Y.scissor(X);Y.setScissorTest(Ta);Y.viewport(W);b&&(b=ia.get(a.texture),D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,b,c,d,e,f){if(!1===(a&&a.isWebGLRenderTarget))console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=ia.get(a).__webglFramebuffer; +if(g){var h=!1;g!==R&&(D.bindFramebuffer(D.FRAMEBUFFER,g),h=!0);try{var k=a.texture,m=k.format,n=k.type;1023!==m&&t(m)!==D.getParameter(D.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===n||t(n)===D.getParameter(D.IMPLEMENTATION_COLOR_READ_TYPE)||1015===n&&(ka.get("OES_texture_float")||ka.get("WEBGL_color_buffer_float"))||1016===n&&ka.get("EXT_color_buffer_half_float")?D.checkFramebufferStatus(D.FRAMEBUFFER)=== +D.FRAMEBUFFER_COMPLETE?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&D.readPixels(b,c,d,e,t(m),t(n),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&D.bindFramebuffer(D.FRAMEBUFFER,R)}}}}}function Jb(a,b){this.name="";this.color=new G(a);this.density=void 0!==b?b:2.5E-4}function Kb(a, +b,c){this.name="";this.color=new G(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function lb(){A.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0}function Od(a,b,c,d,e){A.call(this);this.lensFlares=[];this.positionScreen=new q;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)}function mb(a){U.call(this);this.type="SpriteMaterial";this.color=new G(16777215);this.map=null;this.rotation=0;this.lights=this.fog=!1;this.setValues(a)} +function Bc(a){A.call(this);this.type="Sprite";this.material=void 0!==a?a:new mb}function Cc(){A.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}})}function hd(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new P;a=a||[];this.bones=a.slice(0);this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=S.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth* +this.boneTextureHeight*4),this.boneTexture=new fb(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,1023,1015)):this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b=0,a=this.bones.length;b=a.HAVE_CURRENT_DATA&&(x.needsUpdate=!0)}ea.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var x=this;m()}function Mb(a,b,c,d,e,f,g,h,k,m,x,p){ea.call(this,null,f,g,h,k,m,d,e,x,p);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function ld(a,b,c,d,e,f,g,h,k){ea.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0}function Ec(a,b,c,d,e,f,g,h,k,m){m=void 0!==m?m:1026;if(1026!==m&&1027!== +m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);ea.call(this,null,d,e,f,g,h,m,c,k);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=this.flipY=!1}function Nb(a){function b(a,b){return a-b}I.call(this);var c=[0,0],d={},e=["a","b","c"];if(a&&a.isGeometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length);a=0;for(var m= +g.length;ap;p++){c[0]=x[e[p]];c[1]=x[e[(p+1)%3]];c.sort(b);var n=c.toString();void 0===d[n]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[n]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;ap;p++)d=f[k[2*a+p]],h=6*a+3*p,c[h+0]=d.x,c[h+1]=d.y,c[h+2]=d.z;this.addAttribute("position",new B(c,3))}else if(a&&a.isBufferGeometry){if(null!==a.index){m=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,m.length);k=new Uint32Array(2*m.length);g=0;for(x= +e.length;gp;p++)c[0]=m[a+p],c[1]=m[a+(p+1)%3],c.sort(b),n=c.toString(),void 0===d[n]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[n]=!0,h++)}c=new Float32Array(6*h);a=0;for(m=h;ap;p++)h=6*a+3*p,d=k[2*a+p],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,m=k;ap;p++)h=18*a+6*p,k=9*a+3*p,c[h+0]=f[k],c[h+1]=f[k+1],c[h+2]=f[k+ +2],d=9*a+(p+1)%3*3,c[h+3]=f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new B(c,3))}}function Ob(a,b,c){I.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f,g,h,k,m,x=b+1;for(f=0;f<=c;f++)for(m=f/c,g=0;g<=b;g++)k=g/b,h=a(k,m),d.push(h.x,h.y,h.z),e.push(k,m);a=[];var p;for(f=0;fd&&1===a.x&&(k[b]=a.x-1);0===c.x&&0===c.z&&(k[b]=d/2/Math.PI+.5)}I.call(this);this.type="PolyhedronBufferGeometry";this.parameters= +{vertices:a,indices:b,radius:c,detail:d};c=c||1;var h=[],k=[];(function(a){for(var c=new q,d=new q,g=new q,h=0;he&&(.2>b&&(k[a+0]+=1),.2>c&&(k[a+2]+=1),.2>d&&(k[a+4]+=1))})();this.addAttribute("position",new W(h,3));this.addAttribute("normal",new W(h.slice(),3));this.addAttribute("uv",new W(k,2));this.normalizeNormals();this.boundingSphere= +new Ha(new q,c)}function Pb(a,b){za.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Gc(a,b){R.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Pb(a,b));this.mergeVertices()}function Qb(a,b){za.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry"; +this.parameters={radius:a,detail:b}}function Hc(a,b){R.call(this);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qb(a,b));this.mergeVertices()}function Rb(a,b){var c=(1+Math.sqrt(5))/2;za.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry"; +this.parameters={radius:a,detail:b}}function Ic(a,b){R.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Rb(a,b));this.mergeVertices()}function Sb(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;za.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18, +0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Jc(a,b){R.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Sb(a,b));this.mergeVertices()}function Kc(a,b,c,d){R.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b, +radius:c,detail:d};this.fromBufferGeometry(new za(a,b,c,d));this.mergeVertices()}function Tb(a,b,c,d,e){function f(e){var f=a.getPointAt(e/b),m=g.normals[e];e=g.binormals[e];for(p=0;p<=d;p++){var x=p/d*Math.PI*2,l=Math.sin(x),x=-Math.cos(x);k.x=x*m.x+l*e.x;k.y=x*m.y+l*e.y;k.z=x*m.z+l*e.z;k.normalize();r.push(k.x,k.y,k.z);h.x=f.x+c*k.x;h.y=f.y+c*k.y;h.z=f.z+c*k.z;n.push(h.x,h.y,h.z)}}I.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e}; +b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new q,k=new q,m=new F,x,p,n=[],r=[],l=[],u=[];for(x=0;xn;n++){e[0]=p[g[n]];e[1]=p[g[(n+1)%3]];e.sort(c);var r=e.toString();void 0===f[r]?f[r]={vert1:e[0],vert2:e[1],face1:m,face2:void 0}:f[r].face2=m}e=[];for(r in f)if(g=f[r],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)m=k[g.vert1],e.push(m.x),e.push(m.y),e.push(m.z),m=k[g.vert2],e.push(m.x),e.push(m.y),e.push(m.z);this.addAttribute("position",new B(new Float32Array(e),3))}function Wa(a,b,c,d,e,f,g,h){function k(c){var e,f,k,n=new F, +p=new q,l=0,x=!0===c?a:b,M=!0===c?1:-1;f=t;for(e=1;e<=d;e++)w.setXYZ(t,0,y*M,0),u.setXYZ(t,0,M,0),n.x=.5,n.y=.5,z.setXY(t,n.x,n.y),t++;k=t;for(e=0;e<=d;e++){var B=e/d*h+g,A=Math.cos(B),B=Math.sin(B);p.x=x*B;p.y=y*M;p.z=x*A;w.setXYZ(t,p.x,p.y,p.z);u.setXYZ(t,0,M,0);n.x=.5*A+.5;n.y=.5*B*M+.5;z.setXY(t,n.x,n.y);t++}for(e=0;ethis.duration&&this.resetDuration();this.optimize()}function Ad(a){this.manager=void 0!==a?a:wa;this.textures={}}function Sd(a){this.manager=void 0!==a?a:wa}function xb(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}}function Td(a){"boolean"=== +typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:wa;this.withCredentials=!1}function Ee(a){this.manager=void 0!==a?a:wa;this.texturePath=""}function xa(){}function Qa(a,b){this.v1=a;this.v2=b}function Zc(){this.curves=[];this.autoClose=!1}function Xa(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0}function yb(a){this.points= +void 0===a?[]:a}function zb(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d}function Ab(a,b,c){this.v0=a;this.v1=b;this.v2=c}function Ya(){$c.apply(this,arguments);this.holes=[]}function $c(a){Zc.call(this);this.currentPoint=new F;a&&this.fromPoints(a)}function Ud(){this.subPaths=[];this.currentPath=null}function Vd(a){this.data=a}function Fe(a){this.manager=void 0!==a?a:wa}function Wd(a){this.manager=void 0!==a?a:wa}function Xd(a,b,c,d){na.call(this,a,b);this.type="RectAreaLight";this.position.set(0, +1,0);this.updateMatrix();this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function Ge(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new Ia;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new Ia;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1}function Bd(a,b,c){A.call(this);this.type="CubeCamera";var d=new Ia(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new q(1,0,0));this.add(d);var e=new Ia(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new q(-1, +0,0));this.add(e);var f=new Ia(90,1,a,b);f.up.set(0,0,1);f.lookAt(new q(0,1,0));this.add(f);var g=new Ia(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new q(0,-1,0));this.add(g);var h=new Ia(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new q(0,0,1));this.add(h);var k=new Ia(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new q(0,0,-1));this.add(k);this.renderTarget=new Eb(c,c,{format:1022,magFilter:1006,minFilter:1006});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,n=c.texture.generateMipmaps; +c.texture.generateMipmaps=!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=n;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}}function Yd(){A.call(this);this.type="AudioListener";this.context=Zd.getContext();this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null}function gc(a){A.call(this);this.type= +"Audio";this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.loop=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}function $d(a){gc.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)}function ae(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount); +a.getOutput().connect(this.analyser)}function Cd(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function la(a,b,c){this.path=b;this.parsedPath=c||la.parseTrackName(b);this.node=la.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function be(a){this.uuid=S.generateUUID(); +this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}}function ce(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks; +b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled= +!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function de(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1}function Dd(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Bb(){I.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function ee(a,b,c,d){this.uuid=S.generateUUID();this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0=== +d}function hc(a,b){this.uuid=S.generateUUID();this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.onUploadCallback=function(){};this.version=0}function ic(a,b,c){hc.call(this,a,b);this.meshPerAttribute=c||1}function jc(a,b,c){B.call(this,a,b);this.meshPerAttribute=c||1}function fe(a,b,c,d){this.ray=new cb(a,b);this.near=c||0;this.far=d||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params, +{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})}function He(a,b){return a.distance-b.distance}function ge(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;dc;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new W(b,3));b= +new ja({fog:!1});this.cone=new ga(a,b);this.add(this.cone);this.update()}function lc(a){this.bones=this.getBoneList(a);for(var b=new I,c=[],d=[],e=new G(0,0,1),f=new G(0,1,0),g=0;gd;d++)c.faces[d].color=this.colors[4>d?0:1];d=new La({vertexColors:1,wireframe:!0});this.lightSphere=new Ea(c,d);this.add(this.lightSphere);this.update()}function cd(a,b,c,d){a=a||10;b=b||10;c=new G(void 0!==c?c:4473924);d=new G(void 0!==d?d:8947848);for(var e=b/2,f=2*a/b,g=[],h=[],k=0,m=0,l=-a;k<=b;k++,l+=f){g.push(-a,0,l,a,0,l);g.push(l,0,-a,l,0,a);var p=k===e?c:d;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3;p.toArray(h,m);m+=3}a=new I;a.addAttribute("position",new W(g,3));a.addAttribute("color", +new W(h,3));g=new ja({vertexColors:2});ga.call(this,a,g)}function Ed(a,b,c,d,e,f){a=a||10;b=b||16;c=c||8;d=d||64;e=new G(void 0!==e?e:4473924);f=new G(void 0!==f?f:8947848);var g=[],h=[],k,m,l,p,n;for(l=0;l<=b;l++)m=l/b*2*Math.PI,k=Math.sin(m)*a,m=Math.cos(m)*a,g.push(0,0,0),g.push(k,0,m),n=l&1?e:f,h.push(n.r,n.g,n.b),h.push(n.r,n.g,n.b);for(l=0;l<=c;l++)for(n=l&1?e:f,p=a-a/c*l,b=0;ba?-1:0e;e++)8===e||13===e||18===e||23=== +e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c- +b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*S.DEG2RAD},radToDeg:function(a){return a*S.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++; +return a}};F.prototype={constructor:F,isVector2:!0,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x; +case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this}, +addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a, +this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0=== +a&&(a=new F,b=new F);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a,Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0> +this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))}, +distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+ +1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};var Ne=0;ea.DEFAULT_IMAGE=void 0;ea.DEFAULT_MAPPING=300;ea.prototype={constructor:ea,isTexture:!0,set needsUpdate(a){!0===a&&this.version++}, +clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding= +a.encoding;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY};if(void 0!==this.image){var c=this.image;void 0===c.uuid&&(c.uuid=S.generateUUID()); +if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c,0,0,c.width,c.height));g=2048a.x||1a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};Object.assign(ea.prototype,oa.prototype);ha.prototype={constructor:ha,isVector4:!0, +set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x; +case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this}, +addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-= +a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this}, +divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var m=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+ +h+m-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;m=(m+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>m?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>m?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>m?(c=b=.707106781,d=0):(d=Math.sqrt(m),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+m-1)/2);return this},min:function(a){this.x= +Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c, +d){void 0===a&&(a=new ha,b=new ha);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x= +0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x* +this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x=== +this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};Object.assign(Db.prototype,oa.prototype,{isWebGLRenderTarget:!0, +setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}}); +Eb.prototype=Object.create(Db.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isWebGLRenderTargetCube=!0;da.prototype={constructor:da,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this}, +clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!1===(a&&a.isEuler))throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h, +this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e, +this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],m=c+f+b;0f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y= +(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new q);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;return this.normalize()}}(), +inverse:function(){return this.conjugate().normalize()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w= +1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,m=b._w;this._x=c*m+f*g+d*k-e*h; +this._y=d*m+f*h+e*g-c*k;this._z=e*m+f*k+c*h-d*g;this._w=f*m-c*g-d*h-e*k;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+ +this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0=== +b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Object.assign(da,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var l=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==l||m!==p){f=1-g;var n=h*d+k*l+m*p+c*e,r=0<=n?1:-1,w=1-n*n;w>Number.EPSILON&&(w=Math.sqrt(w),n=Math.atan2(w,n*r),f=Math.sin(f*n)/w, +g=Math.sin(g*n)/w);r*=g;h=h*f+d*r;k=k*f+l*r;m=m*f+p*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+k*k+m*m+c*c),h*=g,k*=g,m*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=m;a[b+3]=c}});q.prototype={constructor:q,isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y= +b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."), +this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z; +return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a, +b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===(b&&b.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new da);return this.applyQuaternion(a.setFromEuler(b))}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new da);return this.applyQuaternion(a.setFromAxisAngle(b,c))}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z; +a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]* +c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,m=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-m*-f;this.y=k*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new P);a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new P); +a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z, +a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new q,b=new q);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();return this.multiplyScalar(Math.max(a, +Math.min(b,c))/c)},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z): +Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/ +this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c= +a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new q);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===a&&(a=new q);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()* +a.lengthSq());return Math.acos(S.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},distanceToManhattan:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){var b=Math.sin(a.phi)*a.radius;this.x=b*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=b*Math.cos(a.theta);return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a, +3)},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){if("number"===typeof a){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var c=a;a=b;b=c}return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&& +(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};P.prototype={constructor:P,isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,k,m,l,p,n,r,w,u){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=k;q[6]=m;q[10]=l;q[14]=p;q[3]= +n;q[7]=r;q[11]=w;q[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new P).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x, +b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new q);var c=this.elements,d=b.elements,e=1/a.setFromMatrixColumn(b,0).length(),f=1/a.setFromMatrixColumn(b,1).length();b=1/a.setFromMatrixColumn(b,2).length();c[0]=d[0]*e;c[1]=d[1]*e;c[2]=d[2]*e;c[4]=d[4]*f;c[5]=d[5]*f;c[6]=d[6]*f;c[8]=d[8]*b;c[9]=d[9]*b;c[10]=d[10]*b;return this}}(),makeRotationFromEuler:function(a){!1===(a&&a.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order."); +var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,m=c*h,l=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=k+m*d;b[5]=a-l*d;b[9]=-c*g;b[2]=l-a*d;b[6]=m+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a+l*c,b[4]=m*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-m,b[6]=l+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,m=d*h,l=d*e,b[0]=a-l*c,b[4]=-f*e,b[8]=m+k*c,b[1]=k+m*c,b[5]=f*h,b[9]=l-a*c,b[2]= +-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,m=c*h,l=c*e,b[0]=g*h,b[4]=m*d-k,b[8]=a*d+l,b[1]=g*e,b[5]=l*d+a,b[9]=k*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=l-a*e,b[8]=m*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+m,b[10]=a-l*e):"XZY"===a.order&&(a=f*g,k=f*d,m=c*g,l=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+l,b[5]=f*h,b[9]=k*e-m,b[2]=m*e-k,b[6]=c*h,b[10]=l*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b= +this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var m=c*h,c=c*k,l=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(l+e);b[4]=m-f;b[8]=c+h;b[1]=m+f;b[5]=1-(a+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+l);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new q,b=new q,c=new q);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.z+=1E-4, +a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements, +f=c[0],g=c[4],h=c[8],k=c[12],m=c[1],l=c[5],p=c[9],n=c[13],r=c[2],w=c[6],q=c[10],z=c[14],t=c[3],v=c[7],M=c[11],c=c[15],y=d[0],C=d[4],H=d[8],E=d[12],K=d[1],B=d[5],J=d[9],F=d[13],A=d[2],G=d[6],I=d[10],N=d[14],O=d[3],Q=d[7],T=d[11],d=d[15];e[0]=f*y+g*K+h*A+k*O;e[4]=f*C+g*B+h*G+k*Q;e[8]=f*H+g*J+h*I+k*T;e[12]=f*E+g*F+h*N+k*d;e[1]=m*y+l*K+p*A+n*O;e[5]=m*C+l*B+p*G+n*Q;e[9]=m*H+l*J+p*I+n*T;e[13]=m*E+l*F+p*N+n*d;e[2]=r*y+w*K+q*A+z*O;e[6]=r*C+w*B+q*G+z*Q;e[10]=r*H+w*J+q*I+z*T;e[14]=r*E+w*F+q*N+z*d;e[3]=t*y+ +v*K+M*A+c*O;e[7]=t*C+v*B+M*G+c*Q;e[11]=t*H+v*J+M*I+c*T;e[15]=t*E+v*F+M*N+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a; +b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ethis.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g= +new q,b=new P);var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);c=1/g;var f=1/h,m=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=m;b.elements[9]*=m;b.elements[10]*=m;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g= this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,b,c,d){a=c*Math.tan(S.DEG2RAD*a*.5);var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),k=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*k;g[9]=0;g[13]=-((c+d)*k);g[2]=0;g[6]=0; g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11]; -a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}};$a.prototype=Object.create(ea.prototype);$a.prototype.constructor=$a;$a.prototype.isCubeTexture=!0;Object.defineProperty($a.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var oe=new ea,pe=new $a,le=[],ne=[];te.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a,b[f.id])}};var Gd=/([\w\d_]+)(\])?(\[|\.)?/g;ab.prototype.setValue=function(a,b,c){b= -this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};ab.prototype.set=function(a,b,c){var d=this.map[c];void 0!==d&&d.setValue(a,b[c],this.renderer)};ab.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};ab.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};ab.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var X={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n", +a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}};$a.prototype=Object.create(ea.prototype);$a.prototype.constructor=$a;$a.prototype.isCubeTexture=!0;Object.defineProperty($a.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});var re=new ea,se=new $a,oe=[],qe=[];we.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a,b[f.id])}};var Id=/([\w\d_]+)(\])?(\[|\.)?/g;ab.prototype.setValue=function(a,b,c){b= +this.map[b];void 0!==b&&b.setValue(a,c,this.renderer)};ab.prototype.set=function(a,b,c){var d=this.map[c];void 0!==d&&d.setValue(a,b[c],this.renderer)};ab.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};ab.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};ab.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};var Z={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n", alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n", aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"\nvec3 transformed = vec3( position );\n",beginnormal_vertex:"\nvec3 objectNormal = vec3( normal );\n",bsdfs:"float punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 ltcTextureCoords( const in GeometricContext geometry, const in float roughness ) {\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = (LUT_SIZE - 1.0)/LUT_SIZE;\n\tconst float LUT_BIAS = 0.5/LUT_SIZE;\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tfloat theta = acos( dot( N, V ) );\n\tvec2 uv = vec2(\n\t\tsqrt( saturate( roughness ) ),\n\t\tsaturate( theta / ( 0.5 * PI ) ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nvoid clipQuadToHorizon( inout vec3 L[5], out int n ) {\n\tint config = 0;\n\tif ( L[0].z > 0.0 ) config += 1;\n\tif ( L[1].z > 0.0 ) config += 2;\n\tif ( L[2].z > 0.0 ) config += 4;\n\tif ( L[3].z > 0.0 ) config += 8;\n\tn = 0;\n\tif ( config == 0 ) {\n\t} else if ( config == 1 ) {\n\t\tn = 3;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 2 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 3 ) {\n\t\tn = 4;\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t\tL[3] = -L[3].z * L[0] + L[0].z * L[3];\n\t} else if ( config == 4 ) {\n\t\tn = 3;\n\t\tL[0] = -L[3].z * L[2] + L[2].z * L[3];\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t} else if ( config == 5 ) {\n\t\tn = 0;\n\t} else if ( config == 6 ) {\n\t\tn = 4;\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 7 ) {\n\t\tn = 5;\n\t\tL[4] = -L[3].z * L[0] + L[0].z * L[3];\n\t\tL[3] = -L[3].z * L[2] + L[2].z * L[3];\n\t} else if ( config == 8 ) {\n\t\tn = 3;\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[1] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = L[3];\n\t} else if ( config == 9 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t\tL[2] = -L[2].z * L[3] + L[3].z * L[2];\n\t} else if ( config == 10 ) {\n\t\tn = 0;\n\t} else if ( config == 11 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = -L[2].z * L[3] + L[3].z * L[2];\n\t\tL[2] = -L[2].z * L[1] + L[1].z * L[2];\n\t} else if ( config == 12 ) {\n\t\tn = 4;\n\t\tL[1] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[0] = -L[0].z * L[3] + L[3].z * L[0];\n\t} else if ( config == 13 ) {\n\t\tn = 5;\n\t\tL[4] = L[3];\n\t\tL[3] = L[2];\n\t\tL[2] = -L[1].z * L[2] + L[2].z * L[1];\n\t\tL[1] = -L[1].z * L[0] + L[0].z * L[1];\n\t} else if ( config == 14 ) {\n\t\tn = 5;\n\t\tL[4] = -L[0].z * L[3] + L[3].z * L[0];\n\t\tL[0] = -L[0].z * L[1] + L[1].z * L[0];\n\t} else if ( config == 15 ) {\n\t\tn = 4;\n\t}\n\tif ( n == 3 )\n\t\tL[3] = L[0];\n\tif ( n == 4 )\n\t\tL[4] = L[0];\n}\nfloat integrateLtcBrdfOverRectEdge( vec3 v1, vec3 v2 ) {\n\tfloat cosTheta = dot( v1, v2 );\n\tfloat theta = acos( cosTheta );\n\tfloat res = cross( v1, v2 ).z * ( ( theta > 0.001 ) ? theta / sin( theta ) : 1.0 );\n\treturn res;\n}\nvoid initRectPoints( const in vec3 pos, const in vec3 halfWidth, const in vec3 halfHeight, out vec3 rectPoints[4] ) {\n\trectPoints[0] = pos - halfWidth - halfHeight;\n\trectPoints[1] = pos + halfWidth - halfHeight;\n\trectPoints[2] = pos + halfWidth + halfHeight;\n\trectPoints[3] = pos - halfWidth + halfHeight;\n}\nvec3 integrateLtcBrdfOverRect( const in GeometricContext geometry, const in mat3 brdfMat, const in vec3 rectPoints[4] ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 P = geometry.position;\n\tvec3 T1, T2;\n\tT1 = normalize(V - N * dot( V, N ));\n\tT2 = - cross( N, T1 );\n\tmat3 brdfWrtSurface = brdfMat * transpose( mat3( T1, T2, N ) );\n\tvec3 clippedRect[5];\n\tclippedRect[0] = brdfWrtSurface * ( rectPoints[0] - P );\n\tclippedRect[1] = brdfWrtSurface * ( rectPoints[1] - P );\n\tclippedRect[2] = brdfWrtSurface * ( rectPoints[2] - P );\n\tclippedRect[3] = brdfWrtSurface * ( rectPoints[3] - P );\n\tint n;\n\tclipQuadToHorizon(clippedRect, n);\n\tif ( n == 0 )\n\t\treturn vec3( 0, 0, 0 );\n\tclippedRect[0] = normalize( clippedRect[0] );\n\tclippedRect[1] = normalize( clippedRect[1] );\n\tclippedRect[2] = normalize( clippedRect[2] );\n\tclippedRect[3] = normalize( clippedRect[3] );\n\tclippedRect[4] = normalize( clippedRect[4] );\n\tfloat sum = 0.0;\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[0], clippedRect[1] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[1], clippedRect[2] );\n\tsum += integrateLtcBrdfOverRectEdge( clippedRect[2], clippedRect[3] );\n\tif (n >= 4)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[3], clippedRect[4] );\n\tif (n == 5)\n\t\tsum += integrateLtcBrdfOverRectEdge( clippedRect[4], clippedRect[0] );\n\tsum = max( 0.0, sum );\n\tvec3 Lo_i = vec3( sum, sum, sum );\n\treturn Lo_i;\n}\nvec3 Rect_Area_Light_Specular_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight,\n\t\tconst in float roughness,\n\t\tconst in sampler2D ltcMat, const in sampler2D ltcMag ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tvec2 uv = ltcTextureCoords( geometry, roughness );\n\tvec4 brdfLtcApproxParams, t;\n\tbrdfLtcApproxParams = texture2D( ltcMat, uv );\n\tt = texture2D( ltcMat, uv );\n\tfloat brdfLtcScalar = texture2D( ltcMag, uv ).a;\n\tmat3 brdfLtcApproxMat = mat3(\n\t\tvec3( 1, 0, t.y ),\n\t\tvec3( 0, t.z, 0 ),\n\t\tvec3( t.w, 0, t.x )\n\t);\n\tvec3 specularReflectance = integrateLtcBrdfOverRect( geometry, brdfLtcApproxMat, rectPoints );\n\tspecularReflectance *= brdfLtcScalar;\n\treturn specularReflectance;\n}\nvec3 Rect_Area_Light_Diffuse_Reflectance(\n\t\tconst in GeometricContext geometry,\n\t\tconst in vec3 lightPos, const in vec3 lightHalfWidth, const in vec3 lightHalfHeight ) {\n\tvec3 rectPoints[4];\n\tinitRectPoints( lightPos, lightHalfWidth, lightHalfHeight, rectPoints );\n\tmat3 diffuseBrdfMat = mat3(1);\n\tvec3 diffuseReflectance = integrateLtcBrdfOverRect( geometry, diffuseBrdfMat, rectPoints );\n\treturn diffuseReflectance;\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n", bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n", clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t\t\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\t\tvec4 plane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t\n\t#endif\n#endif\n", clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n", -color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nfloat gaussianPdf(in float x, in float sigma) {\n\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n}\nmat3 transpose( const in mat3 v ) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\n", +color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n", cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n", defaultnormal_vertex:"#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n", emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n",encodings_fragment:" gl_FragColor = linearToOutputTexel( gl_FragColor );\n",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n", @@ -354,9 +356,10 @@ envmap_fragment:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE envmap_pars_fragment:"#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n", envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n",envmap_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n", fog_fragment:"#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n", +gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n", +lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n", lights_pars:"uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltcMat;\tuniform sampler2D ltcMag;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#include \n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#include \n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n", -lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n", +lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n", lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n", lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\t#ifndef STANDARD\n\t\tfloat clearCoat;\n\t\tfloat clearCoatRoughness;\n\t#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearCoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = material.specularRoughness;\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff;\n }\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifndef STANDARD\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.directSpecular += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n\treflectedLight.directDiffuse += ( 1.0 - clearCoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t#ifndef STANDARD\n\t\treflectedLight.directSpecular += irradiance * material.clearCoat * BRDF_Specular_GGX( directLight, geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 clearCoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifndef STANDARD\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\tfloat dotNL = dotNV;\n\t\tfloat clearCoatDHR = material.clearCoat * clearCoatDHRApprox( material.clearCoatRoughness, dotNL );\n\t#else\n\t\tfloat clearCoatDHR = 0.0;\n\t#endif\n\treflectedLight.indirectSpecular += ( 1.0 - clearCoatDHR ) * radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n\t#ifndef STANDARD\n\t\treflectedLight.indirectSpecular += clearCoatRadiance * material.clearCoat * BRDF_Specular_GGX_Environment( geometry, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearCoatRoughness );\n\t#endif\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.specularRoughness )\n#define Material_ClearCoat_BlinnShininessExponent( material ) GGXRoughnessToBlinnExponent( material.clearCoatRoughness )\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}\n", lights_template:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t \tirradiance += getLightProbeIndirectIrradiance( geometry, 8 );\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\t#ifndef STANDARD\n\t\tvec3 clearCoatRadiance = getLightProbeIndirectRadiance( geometry, Material_ClearCoat_BlinnShininessExponent( material ), 8 );\n\t#else\n\t\tvec3 clearCoatRadiance = vec3( 0.0 );\n\t#endif\n\t\t\n\tRE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight );\n#endif\n", @@ -387,351 +390,352 @@ linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying fl meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#ifdef USE_ENVMAP\n\t#include \n\t#include \n\t#include \n\t#include \n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include \n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include \n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", +meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n", meshphysical_frag:"#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifndef STANDARD\n\tuniform float clearCoat;\n\tuniform float clearCoatRoughness;\n#endif\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", meshphysical_vert:"#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n}\n", normal_frag:"uniform float opacity;\nvarying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include \n}\n",normal_vert:"varying vec3 vNormal;\n#include \n#include \n#include \n#include \nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n", points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include \n\t#include \n\t#include \n\t#include \n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include \n\t#include \n\t#include \n\t#include \n}\n", -shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};Q.prototype={constructor:Q, +shadow_frag:"uniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\tgl_FragColor = vec4( 0.0, 0.0, 0.0, opacity * ( 1.0 - getShadowMask() ) );\n}\n",shadow_vert:"#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"};G.prototype={constructor:G, isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b, c,d){b=S.euclideanModulo(b,1);c=S.clamp(c,0,1);d=S.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r= Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=parseFloat(c[1])/ -360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0=h?k/(e+f): k/(2-e-f);switch(e){case b:g=(c-d)/k+(cthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new D).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y- -this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){return(b||new D).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new D;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a); -this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};W.prototype={constructor:W,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."): +silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};fb.prototype=Object.create(ea.prototype);fb.prototype.constructor=fb;fb.prototype.isDataTexture=!0;var X={common:{diffuse:{value:new G(15658734)},opacity:{value:1},map:{value:null},offsetRepeat:{value:new ha(0, +0,1,1)},specularMap:{value:null},alphaMap:{value:null},envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new F(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}}, +roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new G(16777215)}},lights:{ambientLightColor:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{}, +direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{}, +width:{},height:{}}}},points:{diffuse:{value:new G(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},offsetRepeat:{value:new ha(0,0,1,1)}}},Hb={basic:{uniforms:Object.assign({},X.common,X.aomap,X.lightmap,X.fog),vertexShader:Z.meshbasic_vert,fragmentShader:Z.meshbasic_frag},lambert:{uniforms:Object.assign({},X.common,X.aomap,X.lightmap,X.emissivemap,X.fog,X.lights,{emissive:{value:new G(0)}}),vertexShader:Z.meshlambert_vert,fragmentShader:Z.meshlambert_frag},phong:{uniforms:Object.assign({}, +X.common,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.gradientmap,X.fog,X.lights,{emissive:{value:new G(0)},specular:{value:new G(1118481)},shininess:{value:30}}),vertexShader:Z.meshphong_vert,fragmentShader:Z.meshphong_frag},standard:{uniforms:Object.assign({},X.common,X.aomap,X.lightmap,X.emissivemap,X.bumpmap,X.normalmap,X.displacementmap,X.roughnessmap,X.metalnessmap,X.fog,X.lights,{emissive:{value:new G(0)},roughness:{value:.5},metalness:{value:0},envMapIntensity:{value:1}}), +vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag},points:{uniforms:Object.assign({},X.points,X.fog),vertexShader:Z.points_vert,fragmentShader:Z.points_frag},dashed:{uniforms:Object.assign({},X.common,X.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}),vertexShader:Z.linedashed_vert,fragmentShader:Z.linedashed_frag},depth:{uniforms:Object.assign({},X.common,X.displacementmap),vertexShader:Z.depth_vert,fragmentShader:Z.depth_frag},normal:{uniforms:{opacity:{value:1}}, +vertexShader:Z.normal_vert,fragmentShader:Z.normal_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Z.cube_vert,fragmentShader:Z.cube_frag},equirect:{uniforms:{tEquirect:{value:null},tFlip:{value:-1}},vertexShader:Z.equirect_vert,fragmentShader:Z.equirect_frag},distanceRGBA:{uniforms:{lightPos:{value:new q}},vertexShader:Z.distanceRGBA_vert,fragmentShader:Z.distanceRGBA_frag}};Hb.physical={uniforms:Object.assign({},Hb.standard.uniforms,{clearCoat:{value:0}, +clearCoatRoughness:{value:0}}),vertexShader:Z.meshphysical_vert,fragmentShader:Z.meshphysical_frag};rc.prototype={constructor:rc,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new F).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y- +this.min.y))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y?!1:!0},clampPoint:function(a,b){return(b||new F).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new F;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a); +this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};var of=0;U.prototype={constructor:U,isMaterial:!0,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."): d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness); void 0!==this.metalness&&(d.metalness=this.metalness);this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);void 0!==this.clearCoat&&(d.clearCoat=this.clearCoat);void 0!==this.clearCoatRoughness&&(d.clearCoatRoughness=this.clearCoatRoughness);this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap= this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,d.displacementBias= this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity); -void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);2!==this.shading&&(d.shading=this.shading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0e&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new q).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.ythis.max.y||a.max.zthis.max.z? -!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new q);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,c;0=a.constant},clampPoint:function(a,b){return(b||new q).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new q;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new q;return function(b){b=b||new Ha;this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&& -this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new q,new q,new q,new q,new q,new q,new q,new q];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b); -a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};Ha.prototype={constructor:Ha,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new Ba;return function(b, -c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)- -this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new q;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a= -a||new Ba;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}};Ca.prototype={constructor:Ca,isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=k;return this},identity:function(){this.set(1, -0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;ec;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}};ha.prototype={constructor:ha,set:function(a,b){this.normal.copy(a); -this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new q,b=new q;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal); -this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b|| -new q).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new q;return function(b,c){var d=c||new q,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],p=c[9],n=c[10],r=c[11],q=c[12],t=c[13],F=c[14],c=c[15]; -b[0].setComponents(f-a,m-g,r-l,c-q).normalize();b[1].setComponents(f+a,m+g,r+l,c+q).normalize();b[2].setComponents(f+d,m+h,r+p,c+t).normalize();b[3].setComponents(f-d,m-h,r-p,c-t).normalize();b[4].setComponents(f-e,m-k,r-n,c-F).normalize();b[5].setComponents(f+e,m+k,r+n,c+F).normalize();return this},intersectsObject:function(){var a=new Ha;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(), -intersectsSprite:function(){var a=new Ha;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};cb.prototype={constructor:cb,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin); -this.direction.copy(a.direction);return this},at:function(a,b){return(b||new q).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(){var a=new q;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new q;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)}, -distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new q;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new q,b=new q,c=new q;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a); -var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),n=Math.abs(1-k*k),r;0=-r?e<=r?(h=1/n,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+p):(e=h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):e<=-r?(d=Math.max(0,-(-k*h+m)),e=0f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<= -a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z; -var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new q;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a= -new q,b=new q,c=new q,d=new q;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a); -this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};db.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");db.DefaultOrder="XYZ";db.prototype={constructor:db,isEuler:!0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order}, -set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=S.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],p=e[6],e=e[10];b=b|| -this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999> -Math.abs(l)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback(); -return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new H);a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a,c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new la;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1]; -this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new q(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};fd.prototype={constructor:fd,set:function(a){this.mask=1<=b.x+b.y}}();La.prototype={constructor:La,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c); -return this},area:function(){var a=new q,b=new q;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new q).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return La.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new ha).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return La.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return La.containsPoint(a, -this.a,this.b,this.c)},closestPointToPoint:function(){var a,b,c,d;return function(e,f){void 0===a&&(a=new ha,b=[new hb,new hb,new hb],c=new q,d=new q);var g=f||new q,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var k=0;kd;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e, -1),c=0,g=this.faceVertexUvs.length;cb.far?null:{distance:c,point:u.clone(),object:a}}function c(c,d,e,f,m,l,p,q){g.fromArray(f,3*l);h.fromArray(f,3*p);k.fromArray(f, -3*q);if(c=b(c,d,e,g,h,k,F))m&&(n.fromArray(m,2*l),r.fromArray(m,2*p),x.fromArray(m,2*q),c.uv=a(F,g,h,k,n,r,x)),c.face=new va(l,p,q,La.normal(g,h,k)),c.faceIndex=l;return c}var d=new H,e=new cb,f=new Ha,g=new q,h=new q,k=new q,m=new q,l=new q,p=new q,n=new D,r=new D,x=new D,t=new q,F=new q,u=new q;return function(q,t){var u=this.geometry,N=this.material,G=this.matrixWorld;if(void 0!==N&&(null===u.boundingSphere&&u.computeBoundingSphere(),f.copy(u.boundingSphere),f.applyMatrix4(G),!1!==q.ray.intersectsSphere(f)&& -(d.getInverse(G),e.copy(q.ray).applyMatrix4(d),null===u.boundingBox||!1!==e.intersectsBox(u.boundingBox)))){var E,A;if(u.isBufferGeometry){var w,I,N=u.index,G=u.attributes,u=G.position.array;void 0!==G.uv&&(E=G.uv.array);if(null!==N)for(var G=N.array,D=0,C=G.length;Dthis.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position, -face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});yc.prototype=Object.assign(Object.create(C.prototype),{constructor:yc,copy:function(a){C.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e- -1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld), -t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,x=r.length/3-1;gf||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices, -m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),t=d.ray.origin.distanceTo(l),td.far||e.push({distance:t,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});ja.prototype=Object.assign(Object.create(Va.prototype),{constructor:ja,isLineSegments:!0});Ga.prototype=Object.create(W.prototype);Ga.prototype.constructor= -Ga;Ga.prototype.isPointsMaterial=!0;Ga.prototype.copy=function(a){W.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;return this};Jb.prototype=Object.assign(Object.create(C.prototype),{constructor:Jb,isPoints:!0,raycast:function(){var a=new H,b=new cb,c=new Ha;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(fd.far||e.push({distance:m,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var m=m/((this.scale.x+this.scale.y+this.scale.z)/3),l=m*m,m=new q;if(h.isBufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var n= -p.array,p=0,r=n.length;pc)return null;var d=[],e=[],f=[],g,h,k;if(0=m--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var l;a:{var p,n,r,q,t,F,u,v;p=a[e[g]].x;n=a[e[g]].y;r=a[e[h]].x;q=a[e[h]].y;t=a[e[k]].x;F=a[e[k]].y;if(0>=(r- -p)*(F-n)-(q-n)*(t-p))l=!1;else{var L,z,w,G,E,A,D,I,C,H;L=t-r;z=F-q;w=p-t;G=n-F;E=r-p;A=q-n;for(l=0;l=-Number.EPSILON&&I>=-Number.EPSILON&&D>=-Number.EPSILON)){l=!1;break a}l=!0}}if(l){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;kNumber.EPSILON){if(0q||q>p)return[];k=m*l-k*n;if(0>k||k>p)return[]}else{if(0c?[]:k===c?f?[]:[g]:a<=c?[g,h]:[g,m]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0e&&(e=d);var g=a+1;g>d&&(g=0);d=f(h[a],h[e],h[g],k[b]);if(!d)return!1;d=k.length-1;e=b-1;0>e&&(e=d);g=b+1;g>d&&(g=0);return(d=f(k[b],k[e],k[g],h[a]))?!0:!1}function d(a,b){var c,f;for(c=0;cO){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(n=D;nk;k++)l=m[k].x+":"+m[k].y,l=p[l],void 0!==l&&(m[k]=l);return n.concat()},isClockWise:function(a){return 0>na.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};Ma.prototype=Object.create(R.prototype);Ma.prototype.constructor=Ma;Ma.prototype.addShapeList=function(a,b){for(var c=a.length, -d=0;dNumber.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(d*d+g*g),h=b.x-f/k;b=b.y+e/k;g=((c.x-g/m-h)*g-(c.y+d/m-b)*d)/(e*g-f*d);d=h+e*g-a.x;e=b+f*g-a.y;f=d*d+e*e;if(2>=f)return new D(d,e);f=Math.sqrt(f/2)}else a=!1, -e>Number.EPSILON?d>Number.EPSILON&&(a=!0):e<-Number.EPSILON?d<-Number.EPSILON&&(a=!0):Math.sign(f)===Math.sign(g)&&(a=!0),a?(d=-f,f=Math.sqrt(h)):(d=e,e=f,f=Math.sqrt(h/2));return new D(d/f,e/f)}function e(a,b){var c,d;for(K=a.length;0<=--K;){c=K;d=K-1;0>d&&(d=a.length-1);var e,f=r+2*l;for(e=0;eMath.abs(b.y-c.y)?[new D(b.x,1-b.z),new D(c.x,1-c.z),new D(d.x,1-d.z),new D(e.x,1-e.z)]:[new D(b.y,1-b.z),new D(c.y,1-c.z),new D(d.y,1-d.z),new D(e.y,1-e.z)]}};Kc.prototype=Object.create(Ma.prototype);Kc.prototype.constructor= -Kc;mb.prototype=Object.create(J.prototype);mb.prototype.constructor=mb;Ub.prototype=Object.create(R.prototype);Ub.prototype.constructor=Ub;Vb.prototype=Object.create(J.prototype);Vb.prototype.constructor=Vb;Lc.prototype=Object.create(R.prototype);Lc.prototype.constructor=Lc;Mc.prototype=Object.create(R.prototype);Mc.prototype.constructor=Mc;Wb.prototype=Object.create(J.prototype);Wb.prototype.constructor=Wb;Nc.prototype=Object.create(R.prototype);Nc.prototype.constructor=Nc;Xb.prototype=Object.create(J.prototype); -Xb.prototype.constructor=Xb;eb.prototype=Object.create(R.prototype);eb.prototype.constructor=eb;Yb.prototype=Object.create(J.prototype);Yb.prototype.constructor=Yb;Wa.prototype=Object.create(J.prototype);Wa.prototype.constructor=Wa;nb.prototype=Object.create(R.prototype);nb.prototype.constructor=nb;Oc.prototype=Object.create(nb.prototype);Oc.prototype.constructor=Oc;Pc.prototype=Object.create(Wa.prototype);Pc.prototype.constructor=Pc;Zb.prototype=Object.create(J.prototype);Zb.prototype.constructor= -Zb;Qc.prototype=Object.create(R.prototype);Qc.prototype.constructor=Qc;ob.prototype=Object.create(R.prototype);ob.prototype.constructor=ob;var Aa=Object.freeze({WireframeGeometry:Lb,ParametricGeometry:Bc,ParametricBufferGeometry:Mb,TetrahedronGeometry:Cc,TetrahedronBufferGeometry:Nb,OctahedronGeometry:Dc,OctahedronBufferGeometry:Ob,IcosahedronGeometry:Ec,IcosahedronBufferGeometry:Pb,DodecahedronGeometry:Fc,DodecahedronBufferGeometry:Qb,PolyhedronGeometry:Gc,PolyhedronBufferGeometry:pa,TubeGeometry:Hc, -TubeBufferGeometry:Rb,TorusKnotGeometry:Ic,TorusKnotBufferGeometry:Sb,TorusGeometry:Jc,TorusBufferGeometry:Tb,TextGeometry:Kc,SphereBufferGeometry:mb,SphereGeometry:Ub,RingGeometry:Lc,RingBufferGeometry:Vb,PlaneBufferGeometry:jb,PlaneGeometry:Mc,LatheGeometry:Nc,LatheBufferGeometry:Wb,ShapeGeometry:eb,ShapeBufferGeometry:Xb,ExtrudeGeometry:Ma,EdgesGeometry:Yb,ConeGeometry:Oc,ConeBufferGeometry:Pc,CylinderGeometry:nb,CylinderBufferGeometry:Wa,CircleBufferGeometry:Zb,CircleGeometry:Qc,BoxBufferGeometry:ib, -BoxGeometry:ob});$b.prototype=Object.create(Ja.prototype);$b.prototype.constructor=$b;$b.prototype.isShadowMaterial=!0;ac.prototype=Object.create(Ja.prototype);ac.prototype.constructor=ac;ac.prototype.isRawShaderMaterial=!0;Rc.prototype={constructor:Rc,isMultiMaterial:!0,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,athis.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc; +d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;0e&&(e=m);l>f&&(f=l);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;bthis.max.x||a.ythis.max.y||a.zthis.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,b){return(b||new q).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.xthis.max.x||a.max.y< +this.min.y||a.min.y>this.max.y||a.max.zthis.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new q);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,c;0=a.constant},clampPoint:function(a,b){return(b||new q).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new q;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new q;return function(b){b=b||new Ha;this.getCenter(b.center);b.radius=.5*this.getSize(a).length();return b}}(),intersect:function(a){this.min.max(a.min); +this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new q,new q,new q,new q,new q,new q,new q,new q];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b); +a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};Ha.prototype={constructor:Ha,set:function(a,b){this.center.copy(a);this.radius=b;return this}, +setFromPoints:function(){var a=new Aa;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).getCenter(d);for(var e=0,f=0,g=b.length;f=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius* +this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a),d=b||new q;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center)); +return d},getBoundingBox:function(a){a=a||new Aa;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}};Ba.prototype={constructor:Ba,isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,k){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]= +f;m[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;e< +d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix3(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new q);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;ec;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a}};ma.prototype={constructor:ma,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this}, +setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new q,b=new q;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a); +this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new q).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new q;return function(b,c){var d=c||new q,e= +b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1b&&0a&&0c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],m=c[7],l=c[8],p=c[9],n=c[10],r=c[11],q=c[12],u=c[13],z=c[14],c=c[15];b[0].setComponents(f-a,m-g,r-l,c-q).normalize();b[1].setComponents(f+a,m+g,r+l,c+q).normalize();b[2].setComponents(f+d,m+h,r+p,c+u).normalize();b[3].setComponents(f- +d,m-h,r-p,c-u).normalize();b[4].setComponents(f-e,m-k,r-n,c-z).normalize();b[5].setComponents(f+e,m+k,r+n,c+z).normalize();return this},intersectsObject:function(){var a=new Ha;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere).applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSprite:function(){var a=new Ha;return function(b){a.center.set(0,0,0);a.radius=.7071067811865476;a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(), +intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)e;e++){var f=d[e];a.x=0 +g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};cb.prototype={constructor:cb,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new q).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize(); +return this},recast:function(){var a=new q;return function(b){this.origin.copy(this.at(b,a));return this}}(),closestPointToPoint:function(a,b){var c=b||new q;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new q;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b); +a.copy(this.direction).multiplyScalar(c).add(this.origin);return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new q,b=new q,c=new q;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),m=c.dot(this.direction),l=-c.dot(b),p=c.lengthSq(),n=Math.abs(1-k*k),r;0=-r?e<=r?(h=1/n,d*=h,e*=h,k=d*(d+k*e+2*m)+e*(k*d+e+2*l)+p):(e=h,d=Math.max(0,-(k* +e+m)),k=-d*d+e*(e+2*l)+p):(e=-h,d=Math.max(0,-(k*e+m)),k=-d*d+e*(e+2*l)+p):e<=-r?(d=Math.max(0,-(-k*h+m)),e=0f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a, +b){var c=this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e; +if(fg||e>d)return null;if(e>c||c!==c)c=e;if(gd?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new q;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new q,b=new q,c=new q,d=new q;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);if(0f)h= +-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};db.RotationOrders= +"XYZ YZX ZXY XZY YXZ ZYX".split(" ");db.DefaultOrder="XYZ";db.prototype={constructor:db,isEuler:!0,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this}, +clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=S.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],m=e[9],l=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"=== +b?(this._x=Math.asin(-d(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-l,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-l,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x= +Math.atan2(-m,k),this._y=Math.atan2(-l,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new P);a.makeRotationFromQuaternion(b);return this.setFromRotationMatrix(a, +c,d)}}(),setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new da;return function(b){a.setFromEuler(this);return this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]= +this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new q(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};gd.prototype={constructor:gd,set:function(a){this.mask=1<=b.x+b.y}}();Da.prototype={constructor:Da,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new q,b=new q;return function(){a.subVectors(this.c, +this.b);b.subVectors(this.a,this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new q).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return Da.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new ma).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return Da.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return Da.containsPoint(a,this.a,this.b,this.c)},closestPointToPoint:function(){var a, +b,c,d;return function(e,f){void 0===a&&(a=new ma,b=[new ib,new ib,new ib],c=new q,d=new q);var g=f||new q,h=Infinity;a.setFromCoplanarPoints(this.a,this.b,this.c);a.projectPoint(e,c);if(!0===this.containsPoint(c))g.copy(c);else{b[0].set(this.a,this.b);b[1].set(this.b,this.c);b[2].set(this.c,this.a);for(var k=0;kd;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,1),c=0,g=this.faceVertexUvs.length;cb.far?null:{distance:c,point:t.clone(),object:a}}function c(c,d,e,f,m,l,p,q){g.fromArray(f,3*l);h.fromArray(f,3*p);k.fromArray(f,3*q);if(c=b(c,d,e,g,h,k,z))m&&(n.fromArray(m,2*l),r.fromArray(m,2*p),w.fromArray(m,2*q),c.uv=a(z,g,h,k,n,r,w)),c.face=new ia(l,p,q,Da.normal(g,h,k)),c.faceIndex=l;return c}var d=new P,e=new cb,f=new Ha,g=new q,h=new q,k=new q,m=new q,l=new q,p=new q,n=new F,r=new F,w= +new F,u=new q,z=new q,t=new q;return function(q,u){var t=this.geometry,C=this.material,H=this.matrixWorld;if(void 0!==C&&(null===t.boundingSphere&&t.computeBoundingSphere(),f.copy(t.boundingSphere),f.applyMatrix4(H),!1!==q.ray.intersectsSphere(f)&&(d.getInverse(H),e.copy(q.ray).applyMatrix4(d),null===t.boundingBox||!1!==e.intersectsBox(t.boundingBox)))){var E,K;if(t.isBufferGeometry){var B,J,C=t.index,H=t.attributes,t=H.position.array;void 0!==H.uv&&(E=H.uv.array);if(null!==C)for(var H=C.array,F= +0,A=H.length;Fthis.scale.x*this.scale.y/4||c.push({distance:Math.sqrt(d),point:this.position,face:null,object:this})}}(),clone:function(){return(new this.constructor(this.material)).copy(this)}});Cc.prototype=Object.assign(Object.create(A.prototype),{constructor:Cc,copy:function(a){A.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;ef||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,w=r.length/3-1;gf||(l.applyMatrix4(this.matrixWorld), +u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g.isGeometry)for(k=g.vertices,m=k.length,g=0;gf||(l.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(l),ud.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}(),clone:function(){return(new this.constructor(this.geometry, +this.material)).copy(this)}});ga.prototype=Object.assign(Object.create(Va.prototype),{constructor:ga,isLineSegments:!0});Oa.prototype=Object.create(U.prototype);Oa.prototype.constructor=Oa;Oa.prototype.isPointsMaterial=!0;Oa.prototype.copy=function(a){U.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;return this};Lb.prototype=Object.assign(Object.create(A.prototype),{constructor:Lb,isPoints:!0,raycast:function(){var a=new P, +b=new cb,c=new Ha;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(fd.far||e.push({distance:m,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,m=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k); +b.copy(d.ray).applyMatrix4(a);var m=m/((this.scale.x+this.scale.y+this.scale.z)/3),l=m*m,m=new q;if(h.isBufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var n=p.array,p=0,r=n.length;pc)return null;var d=[],e=[],f=[],g,h,k;if(0=m--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()"); +break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var l;a:{var p,n,r,q,u,z,t,v;p=a[e[g]].x;n=a[e[g]].y;r=a[e[h]].x;q=a[e[h]].y;u=a[e[k]].x;z=a[e[k]].y;if(0>=(r-p)*(z-n)-(q-n)*(u-p))l=!1;else{var M,y,C,H,E,K,F,B,A,G;M=u-r;y=z-q;C=p-u;H=n-z;E=r-p;K=q-n;for(l=0;l=-Number.EPSILON&&B>=-Number.EPSILON&&F>=-Number.EPSILON)){l=!1;break a}l=!0}}if(l){d.push([a[e[g]], +a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;kNumber.EPSILON){if(0q||q>p)return[];k=m*l-k* +n;if(0>k||k>p)return[]}else{if(0c?[]:k===c?f?[]:[g]:a<=c?[g,h]:[g,m]}function f(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0e&&(e=d);var g=a+1;g>d&&(g=0);d=f(h[a],h[e],h[g],k[b]);if(!d)return!1;d=k.length-1;e=b-1;0>e&&(e=d);g=b+1;g>d&&(g=0);return(d=f(k[b],k[e],k[g],h[a]))?!0:!1}function d(a,b){var c,f;for(c=0;cN){console.log("Infinite Loop! Holes left:"+m.length+", Probably Hole outside Shape!");break}for(n=B;nk;k++)l=m[k].x+":"+m[k].y,l=p[l],void 0!==l&&(m[k]=l);return n.concat()},isClockWise:function(a){return 0>qa.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f* +b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};Ma.prototype=Object.create(R.prototype);Ma.prototype.constructor=Ma;Ma.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;dNumber.EPSILON){var k=Math.sqrt(h),m=Math.sqrt(d* +d+g*g),h=b.x-f/k;b=b.y+e/k;g=((c.x-g/m-h)*g-(c.y+d/m-b)*d)/(e*g-f*d);d=h+e*g-a.x;e=b+f*g-a.y;f=d*d+e*e;if(2>=f)return new F(d,e);f=Math.sqrt(f/2)}else a=!1,e>Number.EPSILON?d>Number.EPSILON&&(a=!0):e<-Number.EPSILON?d<-Number.EPSILON&&(a=!0):Math.sign(f)===Math.sign(g)&&(a=!0),a?(d=-f,f=Math.sqrt(h)):(d=e,e=f,f=Math.sqrt(h/2));return new F(d/f,e/f)}function e(a,b){var c,d;for(L=a.length;0<=--L;){c=L;d=L-1;0>d&&(d=a.length-1);var e,f=r+2*l;for(e=0;eMath.abs(b.y-c.y)?[new F(b.x,1-b.z),new F(c.x,1-c.z),new F(d.x,1-d.z), +new F(e.x,1-e.z)]:[new F(b.y,1-b.z),new F(c.y,1-c.z),new F(d.y,1-d.z),new F(e.y,1-e.z)]}};Oc.prototype=Object.create(Ma.prototype);Oc.prototype.constructor=Oc;nb.prototype=Object.create(I.prototype);nb.prototype.constructor=nb;Wb.prototype=Object.create(R.prototype);Wb.prototype.constructor=Wb;Xb.prototype=Object.create(I.prototype);Xb.prototype.constructor=Xb;Pc.prototype=Object.create(R.prototype);Pc.prototype.constructor=Pc;Qc.prototype=Object.create(R.prototype);Qc.prototype.constructor=Qc;Yb.prototype= +Object.create(I.prototype);Yb.prototype.constructor=Yb;Rc.prototype=Object.create(R.prototype);Rc.prototype.constructor=Rc;eb.prototype=Object.create(I.prototype);eb.prototype.constructor=eb;Zb.prototype=Object.create(R.prototype);Zb.prototype.constructor=Zb;$b.prototype=Object.create(I.prototype);$b.prototype.constructor=$b;Wa.prototype=Object.create(I.prototype);Wa.prototype.constructor=Wa;ob.prototype=Object.create(R.prototype);ob.prototype.constructor=ob;Sc.prototype=Object.create(ob.prototype); +Sc.prototype.constructor=Sc;Tc.prototype=Object.create(Wa.prototype);Tc.prototype.constructor=Tc;ac.prototype=Object.create(I.prototype);ac.prototype.constructor=ac;Uc.prototype=Object.create(R.prototype);Uc.prototype.constructor=Uc;bc.prototype=Object.create(R.prototype);bc.prototype.constructor=bc;var Ga=Object.freeze({WireframeGeometry:Nb,ParametricGeometry:Fc,ParametricBufferGeometry:Ob,TetrahedronGeometry:Gc,TetrahedronBufferGeometry:Pb,OctahedronGeometry:Hc,OctahedronBufferGeometry:Qb,IcosahedronGeometry:Ic, +IcosahedronBufferGeometry:Rb,DodecahedronGeometry:Jc,DodecahedronBufferGeometry:Sb,PolyhedronGeometry:Kc,PolyhedronBufferGeometry:za,TubeGeometry:Lc,TubeBufferGeometry:Tb,TorusKnotGeometry:Mc,TorusKnotBufferGeometry:Ub,TorusGeometry:Nc,TorusBufferGeometry:Vb,TextGeometry:Oc,SphereBufferGeometry:nb,SphereGeometry:Wb,RingGeometry:Pc,RingBufferGeometry:Xb,PlaneBufferGeometry:kb,PlaneGeometry:Qc,LatheGeometry:Rc,LatheBufferGeometry:Yb,ShapeGeometry:Zb,ShapeBufferGeometry:eb,ExtrudeGeometry:Ma,EdgesGeometry:$b, +ConeGeometry:Sc,ConeBufferGeometry:Tc,CylinderGeometry:ob,CylinderBufferGeometry:Wa,CircleBufferGeometry:ac,CircleGeometry:Uc,BoxBufferGeometry:jb,BoxGeometry:bc});cc.prototype=Object.create(Ja.prototype);cc.prototype.constructor=cc;cc.prototype.isShadowMaterial=!0;dc.prototype=Object.create(Ja.prototype);dc.prototype.constructor=dc;dc.prototype.isRawShaderMaterial=!0;Vc.prototype={constructor:Vc,isMultiMaterial:!0,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"}, +uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d=e)break a;else{f=b[1];a=e)break b}d=c;c=0}}for(;c>>1,ab;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=xa.arraySlice(c,e,f),this.values=xa.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty", -this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&xa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1, -f=a.length-1,g=1;gb;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=ba.arraySlice(c,e,f),this.values=ba.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty", +this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&ba.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1, +f=a.length-1,g=1;gk.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};wb.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;ck.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};xb.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;cg;g++)n=v[k++],u=F[2*n],n=F[2*n+1],u=new D(u,n),2!==g&&c.faceVertexUvs[d][h].push(u),0!==g&&c.faceVertexUvs[d][h+1].push(u);p&&(p=3*v[k++],r.normal.set(w[p++],w[p++],w[p]),t.normal.copy(r.normal));if(x)for(d=0;4>d;d++)p=3*v[k++],x=new q(w[p++],w[p++],w[p]),2!==d&&r.vertexNormals.push(x),0!==d&&t.vertexNormals.push(x);l&&(l=v[k++], -l=z[l],r.color.setHex(l),t.color.setHex(l));if(b)for(d=0;4>d;d++)l=v[k++],l=z[l],2!==d&&r.vertexColors.push(new Q(l)),0!==d&&t.vertexColors.push(new Q(l));c.faces.push(r);c.faces.push(t)}else{r=new va;r.a=v[k++];r.b=v[k++];r.c=v[k++];h&&(h=v[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)n=v[k++],u=F[2*n],n=F[2*n+1],u=new D(u,n),c.faceVertexUvs[d][h].push(u);p&&(p=3*v[k++],r.normal.set(w[p++],w[p++],w[p]));if(x)for(d=0;3>d;d++)p=3* -v[k++],x=new q(w[p++],w[p++],w[p]),r.vertexNormals.push(x);l&&(l=v[k++],r.color.setHex(z[l]));if(b)for(d=0;3>d;d++)l=v[k++],r.vertexColors.push(new Q(z[l]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dg;g++)n=v[k++],t=z[2*n],n=z[2*n+1],t=new F(t,n),2!==g&&c.faceVertexUvs[d][h].push(t),0!==g&&c.faceVertexUvs[d][h+1].push(t);p&&(p=3*v[k++],r.normal.set(A[p++],A[p++],A[p]),u.normal.copy(r.normal));if(w)for(d=0;4>d;d++)p=3*v[k++],w=new q(A[p++],A[p++],A[p]),2!==d&&r.vertexNormals.push(w),0!==d&&u.vertexNormals.push(w);l&&(l=v[k++], +l=y[l],r.color.setHex(l),u.color.setHex(l));if(b)for(d=0;4>d;d++)l=v[k++],l=y[l],2!==d&&r.vertexColors.push(new G(l)),0!==d&&u.vertexColors.push(new G(l));c.faces.push(r);c.faces.push(u)}else{r=new ia;r.a=v[k++];r.b=v[k++];r.c=v[k++];h&&(h=v[k++],r.materialIndex=h);h=c.faces.length;if(d)for(d=0;dg;g++)n=v[k++],t=z[2*n],n=z[2*n+1],t=new F(t,n),c.faceVertexUvs[d][h].push(t);p&&(p=3*v[k++],r.normal.set(A[p++],A[p++],A[p]));if(w)for(d=0;3>d;d++)p=3* +v[k++],w=new q(A[p++],A[p++],A[p]),r.vertexNormals.push(w);l&&(l=v[k++],r.color.setHex(y[l]));if(b)for(d=0;3>d;d++)l=v[k++],r.vertexColors.push(new G(y[l]));c.faces.push(r)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;dk)g=d+1;else if(0b&&(b=0);1Number.EPSILON&&(g.normalize(),c=Math.acos(S.clamp(d[k-1].dot(d[k]), --1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(S.clamp(e[0].dot(e[a]),-1,1)),c/=a,0=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths; +new q,h=new P,k,m;for(k=0;k<=a;k++)m=k/a,d[k]=this.getTangentAt(m),d[k].normalize();e[0]=new q;f[0]=new q;k=Number.MAX_VALUE;m=Math.abs(d[0].x);var l=Math.abs(d[0].y),p=Math.abs(d[0].z);m<=k&&(k=m,c.set(1,0,0));l<=k&&(k=l,c.set(0,1,0));p<=k&&c.set(0,0,1);g.crossVectors(d[0],c).normalize();e[0].crossVectors(d[0],g);f[0].crossVectors(d[0],e[0]);for(k=1;k<=a;k++)e[k]=e[k-1].clone(),f[k]=f[k-1].clone(),g.crossVectors(d[k-1],d[k]),g.length()>Number.EPSILON&&(g.normalize(),c=Math.acos(S.clamp(d[k-1].dot(d[k]), +-1,1)),e[k].applyMatrix4(h.makeRotationAxis(g,c))),f[k].crossVectors(d[k],e[k]);if(!0===b)for(c=Math.acos(S.clamp(e[0].dot(e[a]),-1,1)),c/=a,0=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths; for(var a=[],b=0,c=0,d=this.curves.length;cc;)c+=b;for(;c>b;)c-=b;cb.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=dd.interpolate;return new D(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};yb.prototype=Object.create(ta.prototype);yb.prototype.constructor=yb;yb.prototype.getPoint=function(a){var b=na.b3;return new D(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};yb.prototype.getTangent=function(a){var b=dd.tangentCubicBezier;return(new D(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y, -this.v1.y,this.v2.y,this.v3.y))).normalize()};zb.prototype=Object.create(ta.prototype);zb.prototype.constructor=zb;zb.prototype.getPoint=function(a){var b=na.b2;return new D(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};zb.prototype.getTangent=function(a){var b=dd.tangentQuadraticBezier;return(new D(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};var je=Object.assign(Object.create(Vc.prototype),{fromPoints:function(a){this.moveTo(a[0].x, -a[0].y);for(var b=1,c=a.length;bNumber.EPSILON){if(0>m&&(g=b[f],k=-k,h=b[e],m=-m),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=m*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=na.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,m=[];if(1===f.length)return h=f[0],k=new Ya,k.curves= -h.curves,m.push(k),m;var l=!e(f[0].getPoints()),l=a?!l:l;k=[];var p=[],n=[],q=0,x;p[q]=void 0;n[q]=[];for(var t=0,w=f.length;tc;)c+=b;for(;c>b;)c-=b;cb.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=fd.interpolate;return new F(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};zb.prototype=Object.create(xa.prototype);zb.prototype.constructor=zb;zb.prototype.getPoint=function(a){var b=qa.b3;return new F(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};zb.prototype.getTangent=function(a){var b=fd.tangentCubicBezier;return(new F(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y, +this.v1.y,this.v2.y,this.v3.y))).normalize()};Ab.prototype=Object.create(xa.prototype);Ab.prototype.constructor=Ab;Ab.prototype.getPoint=function(a){var b=qa.b2;return new F(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};Ab.prototype.getTangent=function(a){var b=fd.tangentQuadraticBezier;return(new F(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};var ne=Object.assign(Object.create(Zc.prototype),{fromPoints:function(a){this.moveTo(a[0].x, +a[0].y);for(var b=1,c=a.length;bNumber.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.yh.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=qa.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,m=[];if(1===f.length)return h=f[0],k=new Ya,k.curves= +h.curves,m.push(k),m;var l=!e(f[0].getPoints()),l=a?!l:l;k=[];var p=[],n=[],q=0,w;p[q]=void 0;n[q]=[];for(var u=0,z=f.length;ud&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d= -b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){la.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};ga.prototype={constructor:ga,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a= -this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=ga.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error(" can not bind to material as node does not have a material",this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array", +a},updateMatrixWorld:function(){var a=new q,b=new da,c=new q,d=new q;return function(e){A.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);e.positionX?(e.positionX.setValueAtTime(a.x,this.context.currentTime),e.positionY.setValueAtTime(a.y,this.context.currentTime),e.positionZ.setValueAtTime(a.z,this.context.currentTime),e.forwardX.setValueAtTime(d.x,this.context.currentTime),e.forwardY.setValueAtTime(d.y, +this.context.currentTime),e.forwardZ.setValueAtTime(d.z,this.context.currentTime),e.upX.setValueAtTime(f.x,this.context.currentTime),e.upY.setValueAtTime(f.y,this.context.currentTime),e.upZ.setValueAtTime(f.z,this.context.currentTime)):(e.setPosition(a.x,a.y,a.z),e.setOrientation(d.x,d.y,d.z,f.x,f.y,f.z))}}()});gc.prototype=Object.assign(Object.create(A.prototype),{constructor:gc,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode"; +this.source=a;this.connect();return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.loop=this.loop;a.onended=this.onEnded.bind(this);a.playbackRate.setValueAtTime(this.playbackRate, +this.startTime);a.start(0,this.startTime);this.isPlaying=!0;this.source=a;return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.startTime=this.context.currentTime,this.isPlaying=!1,this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.source.stop(),this.startTime=0,this.isPlaying=!1,this},connect:function(){if(0< +this.filters.length){this.source.connect(this.filters[0]);for(var a=1,b=this.filters.length;ad&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}}, +saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){da.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};la.prototype={constructor:la,getValue:function(a, +b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=la.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error(" can not bind to material as node does not have a material",this);return}if(!a.material.materials){console.error(" can not bind to material.materials as node.material does not have a materials array", this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error(" can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;c=c){var p=c++,n=b[p];d[n.uuid]=q;b[q]=n;d[l]=p;b[p]=k;k=0;for(l=f;k!==l;++k){var n=e[k],r=n[q];n[q]=n[p];n[p]=r}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,q=e[l];if(void 0!== -q)if(delete e[l],qc.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount;if(2200===d)a:{if(-1===e&&(this.loopCount= 0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else break a;this.clampWhenFinished?this.paused=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{d=2202===d;-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,d)):this._setEndings(0===this.repetitions,!0,d));if(b>=c||0>b){var f=Math.floor(b/c),b=b-c*f,e=e+Math.abs(f),g=this.repetitions-e;0>g?(this.clampWhenFinished?this.paused=!0:this.enabled=!1,b=0a,this._setEndings(a,!a,d)):this._setEndings(!1,!1,d),this._loopCount=e,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:f}))}if(d&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time, -f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};Object.assign($d.prototype,ra.prototype,{clipAction:function(a,b){var c=b||this._root,d=c.uuid,e="string"===typeof a?za.findByName(c,a):a,c=null!==e?e.uuid:a,f=this._actionsByClip[c],g=null;if(void 0!==f){g=f.actionByRoot[d];if(void 0!==g)return g;g=f.knownActions[0];null===e&&(e=g._clip)}if(null===e)return null;e=new Zd(this, -e,b);this._bindAction(e,g);this._addInactiveAction(e,c,d);return e},existingAction:function(a,b){var c=b||this._root,d=c.uuid,c="string"===typeof a?za.findByName(c,a):a,c=this._actionsByClip[c?c.uuid:a];return void 0!==c?c.actionByRoot[d]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*= +f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};Object.assign(de.prototype,oa.prototype,{clipAction:function(a,b){var c=b||this._root,d=c.uuid,e="string"===typeof a?ua.findByName(c,a):a,c=null!==e?e.uuid:a,f=this._actionsByClip[c],g=null;if(void 0!==f){g=f.actionByRoot[d];if(void 0!==g)return g;g=f.knownActions[0];null===e&&(e=g._clip)}if(null===e)return null;e=new ce(this, +e,b);this._bindAction(e,g);this._addInactiveAction(e,c,d);return e},existingAction:function(a,b){var c=b||this._root,d=c.uuid,c="string"===typeof a?ua.findByName(c,a):a,c=this._actionsByClip[c?c.uuid:a];return void 0!==c?c.actionByRoot[d]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*= this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex, k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b); -null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}});Object.assign($d.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var q=d[k],p=q.name,n=l[p];if(void 0===n){n=f[k];if(void 0!==n){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,h,p));continue}n=new Cd(ga.create(c,p,b&&b._propertyBindings[k].binding.parsedPath), +null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}});Object.assign(de.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var q=d[k],p=q.name,n=l[p];if(void 0===n){n=f[k];if(void 0!==n){null===n._cacheIndex&&(++n.referenceCount,this._addInactiveBinding(n,h,p));continue}n=new Cd(la.create(c,p,b&&b._propertyBindings[k].binding.parsedPath), q.ValueTypeName,q.getValueSize());++n.referenceCount;this._addInactiveBinding(n,h,p)}f[k]=n;g[k].resultBuffer=n.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}}, _deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length}, get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&ah.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};qa.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};qa.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};qa.prototype.setAnimationFPS=function(a,b){var c= -this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};qa.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};qa.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};qa.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};qa.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};qa.prototype.getAnimationDuration= -function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};qa.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};qa.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};qa.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b -d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+S.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!== -d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};Xc.prototype=Object.create(C.prototype);Xc.prototype.constructor=Xc;Xc.prototype.isImmediateRenderObject=!0;Yc.prototype=Object.create(ja.prototype);Yc.prototype.constructor=Yc;Yc.prototype.update=function(){var a=new q,b=new q,c=new Ca;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld); -var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,q=k.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Bb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Bb.prototype.setColor= -function(a){this.line.material.color.copy(a);this.cone.material.color.copy(a)};Dd.prototype=Object.create(ja.prototype);Dd.prototype.constructor=Dd;var fe=function(){function a(){}var b=new q,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,l,p){this.init(b,c,((b-a)/e-(c-a)/(e+l)+(c-b)/l)*l,((c-b)/l-(d-b)/(l+p)+(d-c)/p)*l)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b, -c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*b*a};return ta.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0h&&(h=1);1E-4>k&&(k=h);1E-4>n&&(n=h);c.initNonuniformCatmullRom(l.x,y.x,p.x,g.x,k,h,n);d.initNonuniformCatmullRom(l.y,y.y,p.y,g.y,k,h,n);e.initNonuniformCatmullRom(l.z,y.z,p.z,g.z,k,h,n)}else"catmullrom"=== -this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,y.x,p.x,g.x,k),d.initCatmullRom(l.y,y.y,p.y,g.y,k),e.initCatmullRom(l.z,y.z,p.z,g.z,k));return new q(c.calc(a),d.calc(a),e.calc(a))})}();Me.prototype=Object.create(fe.prototype);var Jf=ta.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=void 0===a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length- -2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=dd.interpolate;return new q(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))}),Kf=ta.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=na.b3;return new q(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),Lf=ta.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=na.b2;return new q(b(a,this.v0.x, -this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))}),Mf=ta.create(function(a,b){this.v1=a;this.v2=b},function(a){if(1===a)return this.v2.clone();var b=new q;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});Ed.prototype=Object.create(Xa.prototype);Ed.prototype.constructor=Ed;Object.assign(nc.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty()."); -return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Ba.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty()."); -return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(hb.prototype,{center:function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter()."); -return this.getCenter(a)}});Object.assign(Ca.prototype,{multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}});Object.assign(H.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition()."); -return this.copyPosition(a)},setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.");return a.applyProjection(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead."); -return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead."); -return a.applyMatrix4(this)},translate:function(a){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(a){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(a){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(a){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(a,b){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}});Object.assign(ha.prototype,{isIntersectionLine:function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine()."); -return this.intersectsLine(a)}});Object.assign(la.prototype,{multiplyVector3:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)}});Object.assign(cb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane()."); -return this.intersectsPlane(a)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(Ya.prototype,{extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new Ma(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new eb(this,a)}});Object.assign(q.prototype, -{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale()."); -return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)}});Object.assign(C.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(a){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a, -b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}});Object.defineProperties(C.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}, -set:function(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.defineProperties(yc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Ia.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(oa.prototype, -{onlyShadow:{set:function(a){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}}, -shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far."); -this.shadow.camera.far=a}},shadowCameraVisible:{set:function(a){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(a){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width."); -this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(w.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length}}});Object.assign(J.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a, -b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}); -Object.defineProperties(J.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}}});Object.defineProperties(Ie.prototype,{dynamic:{set:function(a){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."); -return this}}});Object.defineProperties(W.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(a){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new Q}}});Object.defineProperties(fb.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."); -return!1},set:function(a){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(Ja.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});ra.prototype=Object.assign(Object.create({constructor:ra, -apply:function(a){console.warn("THREE.EventDispatcher: .apply is deprecated, just inherit or Object.assign the prototype to mix-in.");Object.assign(a,this)}}),ra.prototype);Object.assign(Jd.prototype,{supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."); +this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,c=a[b];void 0===c&&(c=new Xc(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,e=b[d];a.__cacheIndex= +d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1)});Dd.prototype.clone=function(){return new Dd(void 0===this.value.clone?this.value:this.value.clone())};Bb.prototype=Object.create(I.prototype);Bb.prototype.constructor=Bb;Bb.prototype.isInstancedBufferGeometry=!0;Bb.prototype.addGroup=function(a,b,c){this.groups.push({start:a,count:b,materialIndex:c})};Bb.prototype.copy=function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c, +b[c].clone());a=a.groups;c=0;for(b=a.length;ch.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};va.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards= +!1};va.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};va.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};va.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};va.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};va.prototype.setAnimationTime=function(a, +b){var c=this.animationsMap[a];c&&(c.time=b)};va.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};va.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};va.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};va.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1}; +va.prototype.update=function(a){for(var b=0,c=this.animationsList.length;bd.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+S.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&(this.morphTargetInfluences[d.lastFrame]= +0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!==d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};ad.prototype=Object.create(A.prototype);ad.prototype.constructor=ad;ad.prototype.isImmediateRenderObject=!0;bd.prototype=Object.create(ga.prototype);bd.prototype.constructor= +bd;bd.prototype.update=function(){var a=new q,b=new q,c=new Ba;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g&&g.isGeometry)for(var h=g.vertices,k=g.faces,l=g=0,q=k.length;lc.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();Cb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};Cb.prototype.setColor=function(a){this.line.material.color.copy(a); +this.cone.material.color.copy(a)};Fd.prototype=Object.create(ga.prototype);Fd.prototype.constructor=Fd;var je=function(){function a(){}var b=new q,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,l,p){this.init(b,c,((b-a)/e-(c-a)/(e+l)+(c-b)/l)*l,((c-b)/l-(d-b)/(l+p)+(d-c)/p)*l)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc= +function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*b*a};return xa.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0h&&(h=1);1E-4>k&&(k=h);1E-4>n&&(n=h);c.initNonuniformCatmullRom(l.x,x.x,p.x,g.x,k,h,n);d.initNonuniformCatmullRom(l.y,x.y,p.y,g.y,k,h,n);e.initNonuniformCatmullRom(l.z,x.z,p.z,g.z,k,h,n)}else"catmullrom"===this.type&&(k=void 0!==this.tension? +this.tension:.5,c.initCatmullRom(l.x,x.x,p.x,g.x,k),d.initCatmullRom(l.y,x.y,p.y,g.y,k),e.initCatmullRom(l.z,x.z,p.z,g.z,k));return new q(c.calc(a),d.calc(a),e.calc(a))})}(),Mf=xa.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=void 0===a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=fd.interpolate;return new q(c(d.x, +e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))}),Nf=xa.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=qa.b3;return new q(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z))}),Of=xa.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=qa.b2;return new q(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))}), +Pf=xa.create(function(a,b){this.v1=a;this.v2=b},function(a){if(1===a)return this.v2.clone();var b=new q;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});Gd.prototype=Object.create(Xa.prototype);Gd.prototype.constructor=Gd;Ke.prototype=Object.create(je.prototype);cd.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};Object.assign(rc.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter()."); +return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(Aa.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter()."); +return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize()."); +return this.getSize(a)}});ib.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)};S.random16=function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()};Object.assign(Ba.prototype,{flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead."); +return a.applyMatrix3(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}});Object.assign(P.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead."); +return this.toArray(a,b)},getPosition:function(){var a;return function(){void 0===a&&(a=new q);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return a.setFromMatrixColumn(this,3)}}(),setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead."); +return a.applyProjection(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)},rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead."); +a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")}, +rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}});ma.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};da.prototype.multiplyVector3=function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)};Object.assign(cb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox()."); +return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(Ya.prototype,{extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");return new Ma(this,a)}, +makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new Zb(this,a)}});Object.assign(q.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition()."); +return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)}});R.prototype.computeTangents=function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")};Object.assign(A.prototype, +{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}});Object.defineProperties(A.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order."); +return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});Object.defineProperties(Cc.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels."); +return this.levels}}});Ia.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(na.prototype,{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left."); +this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near."); +this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}}, +shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(B.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");return this.array.length}}});Object.assign(I.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex()."); +this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}); +Object.defineProperties(I.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}}});Object.defineProperties(Dd.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead."); +return this}}});Object.defineProperties(U.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new G}}});Object.defineProperties(Fa.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead."); +return!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(Ja.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});oa.prototype=Object.assign(Object.create({constructor:oa, +apply:function(a){console.warn("THREE.EventDispatcher: .apply is deprecated, just inherit or Object.assign the prototype to mix-in.");Object.assign(a,this)}}),oa.prototype);Object.assign(Nd.prototype,{supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' )."); return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");return this.extensions.get("WEBGL_compressed_texture_s3tc")}, supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures."); return this.capabilities.vertexTextures},supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}, -addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}});Object.defineProperties(Jd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."); -this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});Object.defineProperties(ve.prototype,{cullFace:{get:function(){return this.renderReverseSided?2:1},set:function(a){a=1!==a;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+a+".");this.renderReverseSided=a}}});Object.defineProperties(Cb.prototype, +addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}});Object.defineProperties(Nd.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type."); +this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});Object.defineProperties(xe.prototype,{cullFace:{get:function(){return this.renderReverseSided?2:1},set:function(a){a=1!==a;console.warn("WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to "+a+".");this.renderReverseSided=a}}});Object.defineProperties(Db.prototype, {wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter."); return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy."); return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat}, set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type."); -this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.assign(dc.prototype,{load:function(a){console.warn("THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.");var b=this;(new Sd).load(a,function(a){b.setBuffer(a)}); -return this}});Object.assign(Xd.prototype,{getData:function(a){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()}});l.WebGLRenderTargetCube=Db;l.WebGLRenderTarget=Cb;l.WebGLRenderer=Jd;l.WebGL2Renderer=function(a){function b(a,b,c){n=a;r=b;d.width=a*x;d.height=b*x;!1!==c&&(d.style.width=a+"px",d.style.height=b+"px");w.viewport(t.set(0,0,a,b))}function c(a){a.preventDefault()}console.log("THREE.WebGL2Renderer","83dev");a=a||{};var d=void 0!== -a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),e=void 0!==a.context?a.context:null,f=void 0!==a.alpha?a.alpha:!1,g=void 0!==a.depth?a.depth:!0,h=void 0!==a.stencil?a.stencil:!0,k=void 0!==a.antialias?a.antialias:!1,l=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0;a=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1;var q;try{f={alpha:f,depth:g,stencil:h,antialias:k,premultipliedAlpha:l,preserveDrawingBuffer:a};q=e||d.getContext("webgl2",f);if(null=== -q){if(null!==d.getContext("webgl2"))throw"Error creating WebGL2 context with your selected attributes.";throw"Error creating WebGL2 context.";}d.addEventListener("webglcontextlost",c,!1)}catch(u){console.error("THREE.WebGL2Renderer: "+u)}var p=new Q(0),n=d.width,r=d.height,x=1,t=new fa(0,0,n,r),e=new De(q),w=new Ce(q,e,function(){});return{domElement:d,clear:function(a,b,c){var d=0;if(void 0===a||a)d|=q.COLOR_BUFFER_BIT;if(void 0===b||b)d|=q.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=q.STENCIL_BUFFER_BIT; -q.clear(d)},setPixelRatio:function(a){void 0!==a&&(x=a,b(t.z,t.w,!1))},setSize:b,render:function(a,b){if(void 0!==b&&!0!==b.isCamera)console.error("THREE.WebGL2Renderer.render: camera is not an instance of THREE.Camera.");else{var c=a.background;null===c?w.buffers.color.setClear(p.r,p.g,p.b,0,l):c&&c.isColor&&w.buffers.color.setClear(c.r,c.g,c.b,1,l);this.clear(!0,!0,!0)}}}};l.ShaderLib=Fb;l.UniformsLib=Z;l.ShaderChunk=X;l.FogExp2=Hb;l.Fog=Ib;l.Scene=kb;l.LensFlare=Kd;l.Sprite=xc;l.LOD=yc;l.SkinnedMesh= -jd;l.Skeleton=hd;l.Bone=id;l.Mesh=wa;l.LineSegments=ja;l.Line=Va;l.Points=Jb;l.Group=zc;l.VideoTexture=kd;l.DataTexture=gb;l.CompressedTexture=Kb;l.CubeTexture=$a;l.CanvasTexture=ld;l.DepthTexture=Ac;l.TextureIdCount=function(){return ke++};l.Texture=ea;l.MaterialIdCount=function(){return ue++};l.CompressedTextureLoader=Ee;l.BinaryTextureLoader=Md;l.DataTextureLoader=Md;l.CubeTextureLoader=Nd;l.TextureLoader=md;l.ObjectLoader=Fe;l.MaterialLoader=Ad;l.BufferGeometryLoader=Od;l.DefaultLoadingManager= -sa;l.LoadingManager=Ld;l.JSONLoader=Pd;l.ImageLoader=Sc;l.FontLoader=Ge;l.FileLoader=Na;l.Loader=wb;l.Cache=ie;l.AudioLoader=Sd;l.SpotLightShadow=od;l.SpotLight=pd;l.PointLight=qd;l.RectAreaLight=Td;l.HemisphereLight=nd;l.DirectionalLightShadow=rd;l.DirectionalLight=sd;l.AmbientLight=td;l.LightShadow=tb;l.Light=oa;l.StereoCamera=He;l.PerspectiveCamera=Ia;l.OrthographicCamera=Gb;l.CubeCamera=Bd;l.Camera=ca;l.AudioListener=Ud;l.PositionalAudio=Wd;l.AudioContext=Vd;l.AudioAnalyser=Xd;l.Audio=dc;l.VectorKeyframeTrack= -bc;l.StringKeyframeTrack=xd;l.QuaternionKeyframeTrack=Uc;l.NumberKeyframeTrack=cc;l.ColorKeyframeTrack=zd;l.BooleanKeyframeTrack=yd;l.PropertyMixer=Cd;l.PropertyBinding=ga;l.KeyframeTrack=vb;l.AnimationUtils=xa;l.AnimationObjectGroup=Yd;l.AnimationMixer=$d;l.AnimationClip=za;l.Uniform=Ie;l.InstancedBufferGeometry=Ab;l.BufferGeometry=J;l.GeometryIdCount=function(){return gd++};l.Geometry=R;l.InterleavedBufferAttribute=ae;l.InstancedInterleavedBuffer=fc;l.InterleavedBuffer=ec;l.InstancedBufferAttribute= -gc;l.Float64BufferAttribute=vc;l.Float32BufferAttribute=ba;l.Uint32BufferAttribute=Ua;l.Int32BufferAttribute=uc;l.Uint16BufferAttribute=Sa;l.Int16BufferAttribute=tc;l.Uint8ClampedBufferAttribute=sc;l.Uint8BufferAttribute=rc;l.Int8BufferAttribute=qc;l.BufferAttribute=w;l.Face3=va;l.Object3DIdCount=function(){return we++};l.Object3D=C;l.Raycaster=be;l.Layers=fd;l.EventDispatcher=ra;l.Clock=de;l.QuaternionLinearInterpolant=wd;l.LinearInterpolant=Tc;l.DiscreteInterpolant=vd;l.CubicInterpolant=ud;l.Interpolant= -ka;l.Triangle=La;l.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,w,p,n;this.initFromArray=function(a){this.points=[];for(var b=0;bthis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length- -1:f+2;l=this.points[c[0]];w=this.points[c[1]];p=this.points[c[2]];n=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,w.x,p.x,n.x,g,h,k);d.y=b(l.y,w.y,p.y,n.y,g,h,k);d.z=b(l.z,w.z,p.z,n.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+2;l=this.points[c[0]]; +x=this.points[c[1]];p=this.points[c[2]];n=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,x.x,p.x,n.x,g,h,k);d.y=b(l.y,x.y,p.y,n.y,g,h,k);d.z=b(l.z,x.z,p.z,n.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a interval randInt: function ( low, high ) { @@ -1001,9 +994,11 @@ Vector2.prototype = { * @author szimek / https://github.com/szimek/ */ +var textureId = 0; + function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - Object.defineProperty( this, 'id', { value: TextureIdCount() } ); + Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = _Math.generateUUID(); @@ -1038,7 +1033,7 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty // // Also changing the encoding after already used by a Material will not automatically make the Material // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. - this.encoding = encoding !== undefined ? encoding : LinearEncoding; + this.encoding = encoding !== undefined ? encoding : LinearEncoding; this.version = 0; this.onUpdate = null; @@ -1093,10 +1088,6 @@ Texture.prototype = { this.unpackAlignment = source.unpackAlignment; this.encoding = source.encoding; - // TODO (abelnation): this was added as something causes texture constants to be "copied" before they are properly uploaded to GPU - this.needsUpdate = source.needsUpdate; - this.version = source.version; - return this; }, @@ -1201,7 +1192,7 @@ Texture.prototype = { transformUv: function ( uv ) { - if ( this.mapping !== UVMapping ) return; + if ( this.mapping !== UVMapping ) return; uv.multiply( this.repeat ); uv.add( this.offset ); @@ -1280,9 +1271,6 @@ Texture.prototype = { Object.assign( Texture.prototype, EventDispatcher.prototype ); -var count = 0; -function TextureIdCount() { return count++; } - /** * @author supereggbert / http://www.paulbrunt.co.uk/ * @author philogb / http://blog.thejit.org/ @@ -3934,30 +3922,6 @@ Matrix4.prototype = { }, - flattenToArrayOffset: function ( array, offset ) { - - console.warn( "THREE.Matrix3: .flattenToArrayOffset is deprecated " + - "- just use .toArray instead." ); - - return this.toArray( array, offset ); - - }, - - getPosition: function () { - - var v1; - - return function getPosition() { - - if ( v1 === undefined ) v1 = new Vector3(); - console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); - - return v1.setFromMatrixColumn( this, 3 ); - - }; - - }(), - setPosition: function ( v ) { var te = this.elements; @@ -4971,7 +4935,7 @@ var color_pars_vertex = "#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif"; var color_vertex = "#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif"; -var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nfloat gaussianPdf(in float x, in float sigma) {\n\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\n}\nmat3 transpose( const in mat3 v ) {\n mat3 tmp;\n tmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n tmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n tmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n return tmp;\n}\n"; +var common = "#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transpose( const in mat3 v ) {\n\tmat3 tmp;\n\ttmp[0] = vec3(v[0].x, v[1].x, v[2].x);\n\ttmp[1] = vec3(v[0].y, v[1].y, v[2].y);\n\ttmp[2] = vec3(v[0].z, v[1].z, v[2].z);\n\treturn tmp;\n}\n"; var cube_uv_reflection_fragment = "#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1 (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale = bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV(vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif\n"; @@ -5001,6 +4965,8 @@ var fog_fragment = "#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat dept var fog_pars_fragment = "#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif"; +var gradientmap_pars_fragment = "#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif\n"; + var lightmap_fragment = "#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n"; var lightmap_pars_fragment = "#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif"; @@ -5011,7 +4977,7 @@ var lights_pars = "uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradian var lights_phong_fragment = "BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n"; -var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n"; +var lights_phong_pars_fragment = "varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\n#if NUM_RECT_AREA_LIGHTS > 0\n void RE_Direct_RectArea_BlinnPhong( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n vec3 matDiffColor = material.diffuseColor;\n vec3 matSpecColor = material.specularColor;\n vec3 lightColor = rectAreaLight.color;\n float roughness = BlinnExponentToGGXRoughness( material.specularShininess );\n vec3 spec = Rect_Area_Light_Specular_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight,\n roughness,\n ltcMat, ltcMag );\n vec3 diff = Rect_Area_Light_Diffuse_Reflectance(\n geometry,\n rectAreaLight.position, rectAreaLight.halfWidth, rectAreaLight.halfHeight );\n reflectedLight.directSpecular += lightColor * matSpecColor * spec / PI2;\n reflectedLight.directDiffuse += lightColor * matDiffColor * diff / PI2;\n }\n#endif\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n"; var lights_physical_fragment = "PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef STANDARD\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\tmaterial.clearCoat = saturate( clearCoat );\tmaterial.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 );\n#endif\n"; @@ -5127,7 +5093,7 @@ var meshlambert_frag = "uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform f var meshlambert_vert = "#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; -var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; +var meshphong_frag = "#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include \n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include \n\t#include \n\t#include \n\t#include \n}\n"; var meshphong_vert = "#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\tvViewPosition = - mvPosition.xyz;\n\t#include \n\t#include \n\t#include \n}\n"; @@ -5180,6 +5146,7 @@ var ShaderChunk = { envmap_vertex: envmap_vertex, fog_fragment: fog_fragment, fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, lightmap_fragment: lightmap_fragment, lightmap_pars_fragment: lightmap_pars_fragment, lights_lambert_vertex: lights_lambert_vertex, @@ -5879,6 +5846,12 @@ var UniformsLib = { }, + gradientmap: { + + gradientMap: { value: null } + + }, + fog: { fogDensity: { value: 0.00025 }, @@ -5945,19 +5918,12 @@ var UniformsLib = { } }, // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src - rectAreaLights: { type: "sa", value: [], properties: { - color: { type: "c" }, - position: { type: "v3" }, - width: { type: "v3" }, - height: { type: "v3" }, + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {}, } } - // rectAreaLights: { type: "sa", value: [], properties: { - // color: { type: "c" }, - // position: { type: "v3" }, - // width: { type: "1f" }, - // height: { type: "1f" }, - // rotationMatrix: { type: "m4" } - // } }, }, @@ -6025,6 +5991,7 @@ var ShaderLib = { UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, + UniformsLib.gradientmap, UniformsLib.fog, UniformsLib.lights, { @@ -7178,9 +7145,11 @@ function SpritePlugin( renderer, sprites ) { * @author alteredq / http://alteredqualia.com/ */ +var materialId = 0; + function Material() { - Object.defineProperty( this, 'id', { value: MaterialIdCount() } ); + Object.defineProperty( this, 'id', { value: materialId ++ } ); this.uuid = _Math.generateUUID(); @@ -7371,6 +7340,12 @@ Material.prototype = { } + if ( this.gradientMap && this.gradientMap.isTexture ) { + + data.gradientMap = this.gradientMap.toJSON( meta ).uuid; + + } + if ( this.size !== undefined ) data.size = this.size; if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; @@ -7513,9 +7488,6 @@ Material.prototype = { Object.assign( Material.prototype, EventDispatcher.prototype ); -var count$1 = 0; -function MaterialIdCount() { return count$1++; } - /** * @author alteredq / http://alteredqualia.com/ * @@ -8610,15 +8582,6 @@ Matrix3.prototype = { }, - flattenToArrayOffset: function ( array, offset ) { - - console.warn( "THREE.Matrix3: .flattenToArrayOffset is deprecated " + - "- just use .toArray instead." ); - - return this.toArray( array, offset ); - - }, - getNormalMatrix: function ( matrix4 ) { return this.setFromMatrix4( matrix4 ).getInverse( this ).transpose(); @@ -10488,9 +10451,11 @@ Layers.prototype = { * @author elephantatwork / www.elephantatwork.ch */ +var object3DId = 0; + function Object3D() { - Object.defineProperty( this, 'id', { value: Object3DIdCount() } ); + Object.defineProperty( this, 'id', { value: object3DId ++ } ); this.uuid = _Math.generateUUID(); @@ -10564,7 +10529,7 @@ function Object3D() { this.userData = {}; - this.onBeforeRender = function(){}; + this.onBeforeRender = function(){}; this.onAfterRender = function(){}; } @@ -11200,9 +11165,6 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { } ); -var count$2 = 0; -function Object3DIdCount() { return count$2++; } - /** * @author bhouston / http://clara.io */ @@ -12185,6 +12147,265 @@ function Float64BufferAttribute( array, itemSize ) { Float64BufferAttribute.prototype = Object.create( BufferAttribute.prototype ); Float64BufferAttribute.prototype.constructor = Float64BufferAttribute; +/** + * @author mrdoob / http://mrdoob.com/ + */ + +function DirectGeometry() { + + this.indices = []; + this.vertices = []; + this.normals = []; + this.colors = []; + this.uvs = []; + this.uvs2 = []; + + this.groups = []; + + this.morphTargets = {}; + + this.skinWeights = []; + this.skinIndices = []; + + // this.lineDistances = []; + + this.boundingBox = null; + this.boundingSphere = null; + + // update flags + + this.verticesNeedUpdate = false; + this.normalsNeedUpdate = false; + this.colorsNeedUpdate = false; + this.uvsNeedUpdate = false; + this.groupsNeedUpdate = false; + +} + +Object.assign( DirectGeometry.prototype, { + + computeGroups: function ( geometry ) { + + var group; + var groups = []; + var materialIndex; + + var faces = geometry.faces; + + for ( var i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + + // materials + + if ( face.materialIndex !== materialIndex ) { + + materialIndex = face.materialIndex; + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + group = { + start: i * 3, + materialIndex: materialIndex + }; + + } + + } + + if ( group !== undefined ) { + + group.count = ( i * 3 ) - group.start; + groups.push( group ); + + } + + this.groups = groups; + + }, + + fromGeometry: function ( geometry ) { + + var faces = geometry.faces; + var vertices = geometry.vertices; + var faceVertexUvs = geometry.faceVertexUvs; + + var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0; + var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0; + + // morphs + + var morphTargets = geometry.morphTargets; + var morphTargetsLength = morphTargets.length; + + var morphTargetsPosition; + + if ( morphTargetsLength > 0 ) { + + morphTargetsPosition = []; + + for ( var i = 0; i < morphTargetsLength; i ++ ) { + + morphTargetsPosition[ i ] = []; + + } + + this.morphTargets.position = morphTargetsPosition; + + } + + var morphNormals = geometry.morphNormals; + var morphNormalsLength = morphNormals.length; + + var morphTargetsNormal; + + if ( morphNormalsLength > 0 ) { + + morphTargetsNormal = []; + + for ( var i = 0; i < morphNormalsLength; i ++ ) { + + morphTargetsNormal[ i ] = []; + + } + + this.morphTargets.normal = morphTargetsNormal; + + } + + // skins + + var skinIndices = geometry.skinIndices; + var skinWeights = geometry.skinWeights; + + var hasSkinIndices = skinIndices.length === vertices.length; + var hasSkinWeights = skinWeights.length === vertices.length; + + // + + for ( var i = 0; i < faces.length; i ++ ) { + + var face = faces[ i ]; + + this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); + + var vertexNormals = face.vertexNormals; + + if ( vertexNormals.length === 3 ) { + + this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); + + } else { + + var normal = face.normal; + + this.normals.push( normal, normal, normal ); + + } + + var vertexColors = face.vertexColors; + + if ( vertexColors.length === 3 ) { + + this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); + + } else { + + var color = face.color; + + this.colors.push( color, color, color ); + + } + + if ( hasFaceVertexUv === true ) { + + var vertexUvs = faceVertexUvs[ 0 ][ i ]; + + if ( vertexUvs !== undefined ) { + + this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + + } else { + + console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); + + this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); + + } + + } + + if ( hasFaceVertexUv2 === true ) { + + var vertexUvs = faceVertexUvs[ 1 ][ i ]; + + if ( vertexUvs !== undefined ) { + + this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); + + } else { + + console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); + + this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); + + } + + } + + // morphs + + for ( var j = 0; j < morphTargetsLength; j ++ ) { + + var morphTarget = morphTargets[ j ].vertices; + + morphTargetsPosition[ j ].push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] ); + + } + + for ( var j = 0; j < morphNormalsLength; j ++ ) { + + var morphNormal = morphNormals[ j ].vertexNormals[ i ]; + + morphTargetsNormal[ j ].push( morphNormal.a, morphNormal.b, morphNormal.c ); + + } + + // skins + + if ( hasSkinIndices ) { + + this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); + + } + + if ( hasSkinWeights ) { + + this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); + + } + + } + + this.computeGroups( geometry ); + + this.verticesNeedUpdate = geometry.verticesNeedUpdate; + this.normalsNeedUpdate = geometry.normalsNeedUpdate; + this.colorsNeedUpdate = geometry.colorsNeedUpdate; + this.uvsNeedUpdate = geometry.uvsNeedUpdate; + this.groupsNeedUpdate = geometry.groupsNeedUpdate; + + return this; + + } + +} ); + /** * @author mrdoob / http://mrdoob.com/ * @author kile / http://kile.stravaganza.org/ @@ -12831,12 +13052,6 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { }, - computeTangents: function () { - - console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); - - }, - computeLineDistances: function () { var d = 0; @@ -13448,295 +13663,8 @@ Object.assign( Geometry.prototype, EventDispatcher.prototype, { } ); -var count$3 = 0; -function GeometryIdCount() { return count$3++; } - -/** - * @author mrdoob / http://mrdoob.com/ - */ - -function DirectGeometry() { - - Object.defineProperty( this, 'id', { value: GeometryIdCount() } ); - - this.uuid = _Math.generateUUID(); - - this.name = ''; - this.type = 'DirectGeometry'; - - this.indices = []; - this.vertices = []; - this.normals = []; - this.colors = []; - this.uvs = []; - this.uvs2 = []; - - this.groups = []; - - this.morphTargets = {}; - - this.skinWeights = []; - this.skinIndices = []; - - // this.lineDistances = []; - - this.boundingBox = null; - this.boundingSphere = null; - - // update flags - - this.verticesNeedUpdate = false; - this.normalsNeedUpdate = false; - this.colorsNeedUpdate = false; - this.uvsNeedUpdate = false; - this.groupsNeedUpdate = false; - -} - -Object.assign( DirectGeometry.prototype, EventDispatcher.prototype, { - - computeBoundingBox: Geometry.prototype.computeBoundingBox, - computeBoundingSphere: Geometry.prototype.computeBoundingSphere, - - computeFaceNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.' ); - - }, - - computeVertexNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.' ); - - }, - - computeGroups: function ( geometry ) { - - var group; - var groups = []; - var materialIndex; - - var faces = geometry.faces; - - for ( var i = 0; i < faces.length; i ++ ) { - - var face = faces[ i ]; - - // materials - - if ( face.materialIndex !== materialIndex ) { - - materialIndex = face.materialIndex; - - if ( group !== undefined ) { - - group.count = ( i * 3 ) - group.start; - groups.push( group ); - - } - - group = { - start: i * 3, - materialIndex: materialIndex - }; - - } - - } - - if ( group !== undefined ) { - - group.count = ( i * 3 ) - group.start; - groups.push( group ); - - } - - this.groups = groups; - - }, - - fromGeometry: function ( geometry ) { - - var faces = geometry.faces; - var vertices = geometry.vertices; - var faceVertexUvs = geometry.faceVertexUvs; - - var hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0; - var hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0; - - // morphs - - var morphTargets = geometry.morphTargets; - var morphTargetsLength = morphTargets.length; - - var morphTargetsPosition; - - if ( morphTargetsLength > 0 ) { - - morphTargetsPosition = []; - - for ( var i = 0; i < morphTargetsLength; i ++ ) { - - morphTargetsPosition[ i ] = []; - - } - - this.morphTargets.position = morphTargetsPosition; - - } - - var morphNormals = geometry.morphNormals; - var morphNormalsLength = morphNormals.length; - - var morphTargetsNormal; - - if ( morphNormalsLength > 0 ) { - - morphTargetsNormal = []; - - for ( var i = 0; i < morphNormalsLength; i ++ ) { - - morphTargetsNormal[ i ] = []; - - } - - this.morphTargets.normal = morphTargetsNormal; - - } - - // skins - - var skinIndices = geometry.skinIndices; - var skinWeights = geometry.skinWeights; - - var hasSkinIndices = skinIndices.length === vertices.length; - var hasSkinWeights = skinWeights.length === vertices.length; - - // - - for ( var i = 0; i < faces.length; i ++ ) { - - var face = faces[ i ]; - - this.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] ); - - var vertexNormals = face.vertexNormals; - - if ( vertexNormals.length === 3 ) { - - this.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] ); - - } else { - - var normal = face.normal; - - this.normals.push( normal, normal, normal ); - - } - - var vertexColors = face.vertexColors; - - if ( vertexColors.length === 3 ) { - - this.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] ); - - } else { - - var color = face.color; - - this.colors.push( color, color, color ); - - } - - if ( hasFaceVertexUv === true ) { - - var vertexUvs = faceVertexUvs[ 0 ][ i ]; - - if ( vertexUvs !== undefined ) { - - this.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); - - } else { - - console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i ); - - this.uvs.push( new Vector2(), new Vector2(), new Vector2() ); - - } - - } - - if ( hasFaceVertexUv2 === true ) { - - var vertexUvs = faceVertexUvs[ 1 ][ i ]; - - if ( vertexUvs !== undefined ) { - - this.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] ); - - } else { - - console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i ); - - this.uvs2.push( new Vector2(), new Vector2(), new Vector2() ); - - } - - } - - // morphs - - for ( var j = 0; j < morphTargetsLength; j ++ ) { - - var morphTarget = morphTargets[ j ].vertices; - - morphTargetsPosition[ j ].push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] ); - - } - - for ( var j = 0; j < morphNormalsLength; j ++ ) { - - var morphNormal = morphNormals[ j ].vertexNormals[ i ]; - - morphTargetsNormal[ j ].push( morphNormal.a, morphNormal.b, morphNormal.c ); - - } - - // skins - - if ( hasSkinIndices ) { - - this.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] ); - - } - - if ( hasSkinWeights ) { - - this.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] ); - - } - - } - - this.computeGroups( geometry ); - - this.verticesNeedUpdate = geometry.verticesNeedUpdate; - this.normalsNeedUpdate = geometry.normalsNeedUpdate; - this.colorsNeedUpdate = geometry.colorsNeedUpdate; - this.uvsNeedUpdate = geometry.uvsNeedUpdate; - this.groupsNeedUpdate = geometry.groupsNeedUpdate; - - return this; - - }, - - dispose: function () { - - this.dispatchEvent( { type: 'dispose' } ); - - } - -} ); +var count = 0; +function GeometryIdCount() { return count++; } /** * @author alteredq / http://alteredqualia.com/ @@ -13784,7 +13712,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { addAttribute: function ( name, attribute ) { - if ( (attribute && attribute.isBufferAttribute) === false && (attribute && attribute.isInterleavedBufferAttribute) === false ) { + if ( ( attribute && attribute.isBufferAttribute ) === false && ( attribute && attribute.isInterleavedBufferAttribute ) === false ) { console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' ); @@ -14412,14 +14340,9 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { var normals = attributes.normal.array; - var vA, vB, vC, - - pA = new Vector3(), - pB = new Vector3(), - pC = new Vector3(), - - cb = new Vector3(), - ab = new Vector3(); + var vA, vB, vC; + var pA = new Vector3(), pB = new Vector3(), pC = new Vector3(); + var cb = new Vector3(), ab = new Vector3(); // indexed elements @@ -14510,7 +14433,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { merge: function ( geometry, offset ) { - if ( (geometry && geometry.isBufferGeometry) === false ) { + if ( ( geometry && geometry.isBufferGeometry ) === false ) { console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry ); return; @@ -16541,6 +16464,8 @@ function WebGLProgram( renderer, code, material, parameters ) { parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', @@ -16774,6 +16699,7 @@ function WebGLPrograms( renderer, capabilities ) { MeshBasicMaterial: 'basic', MeshLambertMaterial: 'lambert', MeshPhongMaterial: 'phong', + MeshToonMaterial: 'phong', MeshStandardMaterial: 'physical', MeshPhysicalMaterial: 'physical', LineBasicMaterial: 'basic', @@ -16784,7 +16710,7 @@ function WebGLPrograms( renderer, capabilities ) { var parameterNames = [ "precision", "supportsVertexTextures", "map", "mapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "displacementMap", "specularMap", - "roughnessMap", "metalnessMap", + "roughnessMap", "metalnessMap", "gradientMap", "alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", @@ -16912,6 +16838,8 @@ function WebGLPrograms( renderer, capabilities ) { specularMap: !! material.specularMap, alphaMap: !! material.alphaMap, + gradientMap: !! material.gradientMap, + combine: material.combine, vertexColors: material.vertexColors, @@ -17900,12 +17828,40 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, paramT } + if ( texture.format === DepthFormat && internalFormat === _gl.DEPTH_COMPONENT ) { + + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' ); + + texture.type = UnsignedShortType; + glType = paramThreeToGL( texture.type ); + + } + + } + // Depth stencil textures need the DEPTH_STENCIL internal format // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) if ( texture.format === DepthStencilFormat ) { internalFormat = _gl.DEPTH_STENCIL; + // The error INVALID_OPERATION is generated by texImage2D if format and internalformat are + // DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL. + // (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/) + if ( texture.type !== UnsignedInt248Type ) { + + console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' ); + + texture.type = UnsignedInt248Type; + glType = paramThreeToGL( texture.type ); + + } + } state.texImage2D( _gl.TEXTURE_2D, 0, internalFormat, image.width, image.height, 0, glFormat, glType, null ); @@ -21411,6 +21367,10 @@ function WebGLRenderer( parameters ) { refreshUniformsLambert( m_uniforms, material ); + } else if ( material.isMeshToonMaterial ) { + + refreshUniformsToon( m_uniforms, material ); + } else if ( material.isMeshPhongMaterial ) { refreshUniformsPhong( m_uniforms, material ); @@ -21661,6 +21621,18 @@ function WebGLRenderer( parameters ) { } + function refreshUniformsToon( uniforms, material ) { + + refreshUniformsPhong( uniforms, material ); + + if ( material.gradientMap ) { + + uniforms.gradientMap.value = material.gradientMap; + + } + + } + function refreshUniformsStandard( uniforms, material ) { uniforms.roughness.value = material.roughness; @@ -22342,184 +22314,6 @@ function WebGLRenderer( parameters ) { } -/** - * @author mrdoob / http://mrdoob.com/ - */ - -function WebGL2Renderer( parameters ) { - - console.log( 'THREE.WebGL2Renderer', REVISION ); - - parameters = parameters || {}; - - var _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ), - _context = parameters.context !== undefined ? parameters.context : null, - - _alpha = parameters.alpha !== undefined ? parameters.alpha : false, - _depth = parameters.depth !== undefined ? parameters.depth : true, - _stencil = parameters.stencil !== undefined ? parameters.stencil : true, - _antialias = parameters.antialias !== undefined ? parameters.antialias : false, - _premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true, - _preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false; - - // initialize - - var gl; - - try { - - var attributes = { - alpha: _alpha, - depth: _depth, - stencil: _stencil, - antialias: _antialias, - premultipliedAlpha: _premultipliedAlpha, - preserveDrawingBuffer: _preserveDrawingBuffer - }; - - gl = _context || _canvas.getContext( 'webgl2', attributes ); - - if ( gl === null ) { - - if ( _canvas.getContext( 'webgl2' ) !== null ) { - - throw 'Error creating WebGL2 context with your selected attributes.'; - - } else { - - throw 'Error creating WebGL2 context.'; - - } - - } - - _canvas.addEventListener( 'webglcontextlost', onContextLost, false ); - - } catch ( error ) { - - console.error( 'THREE.WebGL2Renderer: ' + error ); - - } - - // - - var _this = this, - - _autoClear = true, - _autoClearColor = true, - _autoClearDepth = true, - _autoClearStencil = true, - - _clearColor = new Color( 0x000000 ), - _clearAlpha = 0, - - _width = _canvas.width, - _height = _canvas.height, - - _pixelRatio = 1, - - _viewport = new Vector4( 0, 0, _width, _height ); - - var extensions = new WebGLExtensions( gl ); - var state = new WebGLState( gl, extensions, function () {} ); - - // - - function clear( color, depth, stencil ) { - - var bits = 0; - - if ( color === undefined || color ) bits |= gl.COLOR_BUFFER_BIT; - if ( depth === undefined || depth ) bits |= gl.DEPTH_BUFFER_BIT; - if ( stencil === undefined || stencil ) bits |= gl.STENCIL_BUFFER_BIT; - - gl.clear( bits ); - - } - - function setPixelRatio( value ) { - - if ( value === undefined ) return; - - _pixelRatio = value; - - setSize( _viewport.z, _viewport.w, false ); - - } - - function setSize( width, height, updateStyle ) { - - _width = width; - _height = height; - - _canvas.width = width * _pixelRatio; - _canvas.height = height * _pixelRatio; - - if ( updateStyle !== false ) { - - _canvas.style.width = width + 'px'; - _canvas.style.height = height + 'px'; - - } - - setViewport( 0, 0, width, height ); - - } - - function setViewport( x, y, width, height ) { - - state.viewport( _viewport.set( x, y, width, height ) ); - - } - - function render( scene, camera ) { - - if ( camera !== undefined && camera.isCamera !== true ) { - - console.error( 'THREE.WebGL2Renderer.render: camera is not an instance of THREE.Camera.' ); - return; - - } - - var background = scene.background; - var forceClear = false; - - if ( background === null ) { - - state.buffers.color.setClear( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha, _premultipliedAlpha ); - - } else if ( background && background.isColor ) { - - state.buffers.color.setClear( background.r, background.g, background.b, 1, _premultipliedAlpha ); - forceClear = true; - - } - - if ( _autoClear || forceClear ) { - - this.clear( _autoClearColor, _autoClearDepth, _autoClearStencil ); - - } - - } - - function onContextLost( event ) { - - event.preventDefault(); - - } - - return { - domElement: _canvas, - - clear: clear, - setPixelRatio: setPixelRatio, - setSize: setSize, - render: render - } - -} - /** * @author mrdoob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ @@ -23947,12 +23741,13 @@ function DepthTexture( width, height, type, mapping, wrapS, wrapT, magFilter, mi } + if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; + if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; + Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); this.image = { width: width, height: height }; - this.type = type !== undefined ? type : UnsignedShortType; - this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; @@ -28731,6 +28526,43 @@ MeshPhongMaterial.prototype.copy = function ( source ) { }; +/** + * @author takahirox / http://github.com/takahirox + * + * parameters = { + * gradientMap: new THREE.Texture( ) + * } + */ + +function MeshToonMaterial( parameters ) { + + MeshPhongMaterial.call( this ); + + this.defines = { 'TOON': '' }; + + this.type = 'MeshToonMaterial'; + + this.gradientMap = null; + + this.setValues( parameters ); + +} + +MeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype ); +MeshToonMaterial.prototype.constructor = MeshToonMaterial; + +MeshToonMaterial.prototype.isMeshToonMaterial = true; + +MeshToonMaterial.prototype.copy = function ( source ) { + + MeshPhongMaterial.prototype.copy.call( this, source ); + + this.gradientMap = source.gradientMap; + + return this; + +}; + /** * @author mrdoob / http://mrdoob.com/ * @@ -28968,6 +28800,7 @@ var Materials = Object.freeze({ MeshPhysicalMaterial: MeshPhysicalMaterial, MeshStandardMaterial: MeshStandardMaterial, MeshPhongMaterial: MeshPhongMaterial, + MeshToonMaterial: MeshToonMaterial, MeshNormalMaterial: MeshNormalMaterial, MeshLambertMaterial: MeshLambertMaterial, MeshDepthMaterial: MeshDepthMaterial, @@ -29137,15 +28970,13 @@ Object.assign( FileLoader.prototype, { // Safari can not handle Data URIs through XMLHttpRequest so process manually if ( dataUriRegexResult ) { - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; + var mimeType = dataUriRegexResult[ 1 ]; + var isBase64 = !! dataUriRegexResult[ 2 ]; + var data = dataUriRegexResult[ 3 ]; - data = window.decodeURIComponent(data); + data = window.decodeURIComponent( data ); - if( isBase64 ) { - data = window.atob(data); - } + if ( isBase64 ) data = window.atob( data ); try { @@ -29158,16 +28989,18 @@ Object.assign( FileLoader.prototype, { case 'blob': response = new ArrayBuffer( data.length ); + var view = new Uint8Array( response ); + for ( var i = 0; i < data.length; i ++ ) { - view[ i ] = data.charCodeAt( i ); + view[ i ] = data.charCodeAt( i ); } if ( responseType === 'blob' ) { - response = new Blob( [ response ], { "type" : mimeType } ); + response = new Blob( [ response ], { type: mimeType } ); } @@ -29195,24 +29028,24 @@ Object.assign( FileLoader.prototype, { } // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onLoad ) onLoad( response ); scope.manager.itemEnd( url ); - }, 0); + }, 0 ); } catch ( error ) { // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onError ) onError( error ); scope.manager.itemError( url ); - }, 0); + }, 0 ); } @@ -29574,6 +29407,13 @@ Object.assign( ImageLoader.prototype, { image.src = url; + } else if ( this.crossOrigin !== undefined ) { + + // crossOrigin doesn't work with URL.createObjectURL()? + + image.crossOrigin = this.crossOrigin; + image.src = url; + } else { var loader = new FileLoader(); @@ -32028,6 +31868,8 @@ Object.assign( MaterialLoader.prototype, { if ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap ); if ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity; + if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + // MultiMaterial if ( json.materials !== undefined ) { @@ -33010,7 +32852,7 @@ Object.assign( JSONLoader.prototype, { * @author mrdoob / http://mrdoob.com/ */ -function ObjectLoader ( manager ) { +function ObjectLoader( manager ) { this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; this.texturePath = ''; @@ -33082,7 +32924,7 @@ Object.assign( ObjectLoader.prototype, { } ); - var textures = this.parseTextures( json.textures, images ); + var textures = this.parseTextures( json.textures, images ); var materials = this.parseMaterials( json.materials, textures ); var object = this.parseObject( json.object, geometries, materials ); @@ -35674,8 +35516,24 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion ); - listener.setPosition( position.x, position.y, position.z ); - listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + if ( listener.positionX ) { + + listener.positionX.setValueAtTime( position.x, this.context.currentTime ); + listener.positionY.setValueAtTime( position.y, this.context.currentTime ); + listener.positionZ.setValueAtTime( position.z, this.context.currentTime ); + listener.forwardX.setValueAtTime( orientation.x, this.context.currentTime ); + listener.forwardY.setValueAtTime( orientation.y, this.context.currentTime ); + listener.forwardZ.setValueAtTime( orientation.z, this.context.currentTime ); + listener.upX.setValueAtTime( up.x, this.context.currentTime ); + listener.upY.setValueAtTime( up.y, this.context.currentTime ); + listener.upZ.setValueAtTime( up.z, this.context.currentTime ); + + } else { + + listener.setPosition( position.x, position.y, position.z ); + listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + + } }; @@ -35695,14 +35553,14 @@ function Audio( listener ) { this.type = 'Audio'; this.context = listener.context; - this.source = this.context.createBufferSource(); - this.source.onended = this.onEnded.bind( this ); this.gain = this.context.createGain(); this.gain.connect( listener.getInput() ); this.autoplay = false; + this.buffer = null; + this.loop = false; this.startTime = 0; this.playbackRate = 1; this.isPlaying = false; @@ -35736,7 +35594,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { setBuffer: function ( audioBuffer ) { - this.source.buffer = audioBuffer; + this.buffer = audioBuffer; this.sourceType = 'buffer'; if ( this.autoplay ) this.play(); @@ -35763,11 +35621,11 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { var source = this.context.createBufferSource(); - source.buffer = this.source.buffer; - source.loop = this.source.loop; - source.onended = this.source.onended; + source.buffer = this.buffer; + source.loop = this.loop; + source.onended = this.onEnded.bind( this ); + source.playbackRate.setValueAtTime( this.playbackRate, this.startTime ); source.start( 0, this.startTime ); - source.playbackRate.value = this.playbackRate; this.isPlaying = true; @@ -35910,7 +35768,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( this.isPlaying === true ) { - this.source.playbackRate.value = this.playbackRate; + this.source.playbackRate.setValueAtTime( this.playbackRate, this.context.currentTime ); } @@ -35939,7 +35797,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { } - return this.source.loop; + return this.loop; }, @@ -35952,7 +35810,15 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { } - this.source.loop = value; + this.loop = value; + + if ( this.isPlaying === true ) { + + this.source.loop = this.loop; + + } + + return this; }, @@ -38735,6 +38601,12 @@ function Uniform( value ) { } +Uniform.prototype.clone = function () { + + return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); + +}; + /** * @author benaadams / https://twitter.com/ben_a_adams */ @@ -38941,6 +38813,8 @@ function InterleavedBuffer( array, stride ) { this.dynamic = false; this.updateRange = { offset: 0, count: - 1 }; + this.onUploadCallback = function () {}; + this.version = 0; } @@ -39018,6 +38892,14 @@ InterleavedBuffer.prototype = { return new this.constructor().copy( this ); + }, + + onUpload: function ( callback ) { + + this.onUploadCallback = callback; + + return this; + } }; @@ -40105,13 +39987,20 @@ SpotLightHelper.prototype.update = function () { * @author Michael Guerrero / http://realitymeltdown.com * @author mrdoob / http://mrdoob.com/ * @author ikerr / http://verold.com + * @author Mugen87 / https://github.com/Mugen87 */ function SkeletonHelper( object ) { this.bones = this.getBoneList( object ); - var geometry = new Geometry(); + var geometry = new BufferGeometry(); + + var vertices = []; + var colors = []; + + var color1 = new Color( 0, 0, 1 ); + var color2 = new Color( 0, 1, 0 ); for ( var i = 0; i < this.bones.length; i ++ ) { @@ -40119,16 +40008,17 @@ function SkeletonHelper( object ) { if ( bone.parent && bone.parent.isBone ) { - geometry.vertices.push( new Vector3() ); - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( 0, 0, 1 ) ); - geometry.colors.push( new Color( 0, 1, 0 ) ); + vertices.push( 0, 0, 0 ); + vertices.push( 0, 0, 0 ); + colors.push( color1.r, color1.g, color1.b ); + colors.push( color2.r, color2.g, color2.b ); } } - geometry.dynamic = true; + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } ); @@ -40169,37 +40059,41 @@ SkeletonHelper.prototype.getBoneList = function( object ) { SkeletonHelper.prototype.update = function () { - var geometry = this.geometry; - - var matrixWorldInv = new Matrix4().getInverse( this.root.matrixWorld ); + var vector = new Vector3(); var boneMatrix = new Matrix4(); + var matrixWorldInv = new Matrix4(); - var j = 0; + return function update() { - for ( var i = 0; i < this.bones.length; i ++ ) { + var geometry = this.geometry; + var position = geometry.getAttribute( 'position' ); - var bone = this.bones[ i ]; + matrixWorldInv.getInverse( this.root.matrixWorld ); - if ( bone.parent && bone.parent.isBone ) { + for ( var i = 0, j = 0; i < this.bones.length; i ++, j += 2 ) { - boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); - geometry.vertices[ j ].setFromMatrixPosition( boneMatrix ); + var bone = this.bones[ i ]; - boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); - geometry.vertices[ j + 1 ].setFromMatrixPosition( boneMatrix ); + if ( bone.parent && bone.parent.isBone ) { - j += 2; + boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j, vector.x, vector.y, vector.z ); - } + boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j + 1, vector.x, vector.y, vector.z ); - } + } - geometry.verticesNeedUpdate = true; + } - geometry.computeBoundingSphere(); + geometry.getAttribute( 'position' ).needsUpdate = true; -}; + }; + +}(); /** * @author alteredq / http://alteredqualia.com/ @@ -40279,100 +40173,97 @@ PointLightHelper.prototype.update = function () { * @author abelnation / http://github.com/abelnation */ -function RectAreaLightHelper(light) { +function RectAreaLightHelper( light ) { + + Object3D.call( this ); + + this.light = light; + this.light.updateMatrixWorld(); + + this.lightMat = new MeshBasicMaterial( { + color: light.color, + fog: false + } ); - Object3D.call(this); + this.lightWireMat = new MeshBasicMaterial( { + color: light.color, + fog: false, + wireframe: true + } ); - this.light = light; - this.light.updateMatrixWorld(); + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - // this.matrix = light.matrixWorld; - // this.matrixAutoUpdate = false; + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - this.lightMat = new MeshBasicMaterial({ - color: light.color, - fog: false - }); + // shows the "front" of the light, e.g. where light comes from - this.lightWireMat = new MeshBasicMaterial({ - color: light.color, - fog: false, - wireframe: true - }); + this.lightMesh = new Mesh( this.lightShape, this.lightMat ); - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + // shows the "back" of the light, which does not emit light - // shows the "front" of the light, e.g. where light comes from - this.lightMesh = new Mesh(this.lightShape, this.lightMat); - // shows the "back" of the light, which does not emit light - this.lightWireMesh = new Mesh(this.lightShape, this.lightWireMat); + this.lightWireMesh = new Mesh( this.lightShape, this.lightWireMat ); - this.add(this.lightMesh); - this.add(this.lightWireMesh); + this.add( this.lightMesh ); + this.add( this.lightWireMesh ); - this.update(); + this.update(); } -RectAreaLightHelper.prototype = Object.create(Object3D.prototype); +RectAreaLightHelper.prototype = Object.create( Object3D.prototype ); RectAreaLightHelper.prototype.constructor = RectAreaLightHelper; RectAreaLightHelper.prototype.dispose = function () { - this.lightMesh.geometry.dispose(); - this.lightMesh.material.dispose(); - this.lightWireMesh.geometry.dispose(); - this.lightWireMesh.material.dispose(); + this.lightMesh.geometry.dispose(); + this.lightMesh.material.dispose(); + this.lightWireMesh.geometry.dispose(); + this.lightWireMesh.material.dispose(); }; RectAreaLightHelper.prototype.update = function () { - var vector = new Vector3(); - var vector2 = new Vector3(); + var vector = new Vector3(); + var vector2 = new Vector3(); - // TODO (abelnation) why not just make light helpers a child of the light object? - if (this.light.target) { + // TODO (abelnation) why not just make light helpers a child of the light object? + if ( this.light.target ) { - vector.setFromMatrixPosition(this.light.matrixWorld); - vector2.setFromMatrixPosition(this.light.target.matrixWorld); + vector.setFromMatrixPosition( this.light.matrixWorld ); + vector2.setFromMatrixPosition( this.light.target.matrixWorld ); - var lookVec = vector2.clone().sub(vector); - this.lightMesh.lookAt(lookVec); - this.lightWireMesh.lookAt(lookVec); + var lookVec = vector2.clone().sub( vector ); + this.lightMesh.lookAt( lookVec ); + this.lightWireMesh.lookAt( lookVec ); - } + } - this.lightMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + this.lightMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); + this.lightWireMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); - this.lightWireMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + var oldShape = this.lightShape; - var oldShape = this.lightShape; + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - this.lightMesh.geometry = this.lightShape; - this.lightWireMesh.geometry = this.lightShape; + this.lightMesh.geometry = this.lightShape; + this.lightWireMesh.geometry = this.lightShape; - oldShape.dispose(); + oldShape.dispose(); }; @@ -40443,7 +40334,8 @@ HemisphereLightHelper.prototype.update = function () { function GridHelper( size, divisions, color1, color2 ) { - divisions = divisions || 1; + size = size || 10; + divisions = divisions || 10; color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); @@ -40478,11 +40370,92 @@ function GridHelper( size, divisions, color1, color2 ) { GridHelper.prototype = Object.create( LineSegments.prototype ); GridHelper.prototype.constructor = GridHelper; -GridHelper.prototype.setColors = function () { +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / http://github.com/Mugen87 + * @author Hectate / http://www.github.com/Hectate + */ - console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); +function PolarGridHelper( radius, radials, circles, divisions, color1, color2 ) { -}; + radius = radius || 10; + radials = radials || 16; + circles = circles || 8; + divisions = divisions || 64; + color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); + color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); + + var vertices = []; + var colors = []; + + var x, z; + var v, i, j, r, color; + + // create the radials + + for ( i = 0; i <= radials; i ++ ) { + + v = ( i / radials ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * radius; + z = Math.cos( v ) * radius; + + vertices.push( 0, 0, 0 ); + vertices.push( x, 0, z ); + + color = ( i & 1 ) ? color1 : color2; + + colors.push( color.r, color.g, color.b ); + colors.push( color.r, color.g, color.b ); + + } + + // create the circles + + for ( i = 0; i <= circles; i ++ ) { + + color = ( i & 1 ) ? color1 : color2; + + r = radius - ( radius / circles * i ); + + for ( j = 0; j < divisions; j ++ ) { + + // first vertex + + v = ( j / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + // second vertex + + v = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + } + + } + + var geometry = new BufferGeometry(); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + + LineSegments.call( this, geometry, material ); + +} + +PolarGridHelper.prototype = Object.create( LineSegments.prototype ); +PolarGridHelper.prototype.constructor = PolarGridHelper; /** * @author mrdoob / http://mrdoob.com/ @@ -40677,6 +40650,7 @@ DirectionalLightHelper.prototype.update = function () { /** * @author alteredq / http://alteredqualia.com/ + * @author Mugen87 / https://github.com/Mugen87 * * - shows frustum, line of sight and up of the camera * - suitable for fast updates @@ -40686,77 +40660,80 @@ DirectionalLightHelper.prototype.update = function () { function CameraHelper( camera ) { - var geometry = new Geometry(); + var geometry = new BufferGeometry(); var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } ); + var vertices = []; + var colors = []; + var pointMap = {}; // colors - var hexFrustum = 0xffaa00; - var hexCone = 0xff0000; - var hexUp = 0x00aaff; - var hexTarget = 0xffffff; - var hexCross = 0x333333; + var colorFrustum = new Color( 0xffaa00 ); + var colorCone = new Color( 0xff0000 ); + var colorUp = new Color( 0x00aaff ); + var colorTarget = new Color( 0xffffff ); + var colorCross = new Color( 0x333333 ); // near - addLine( "n1", "n2", hexFrustum ); - addLine( "n2", "n4", hexFrustum ); - addLine( "n4", "n3", hexFrustum ); - addLine( "n3", "n1", hexFrustum ); + addLine( "n1", "n2", colorFrustum ); + addLine( "n2", "n4", colorFrustum ); + addLine( "n4", "n3", colorFrustum ); + addLine( "n3", "n1", colorFrustum ); // far - addLine( "f1", "f2", hexFrustum ); - addLine( "f2", "f4", hexFrustum ); - addLine( "f4", "f3", hexFrustum ); - addLine( "f3", "f1", hexFrustum ); + addLine( "f1", "f2", colorFrustum ); + addLine( "f2", "f4", colorFrustum ); + addLine( "f4", "f3", colorFrustum ); + addLine( "f3", "f1", colorFrustum ); // sides - addLine( "n1", "f1", hexFrustum ); - addLine( "n2", "f2", hexFrustum ); - addLine( "n3", "f3", hexFrustum ); - addLine( "n4", "f4", hexFrustum ); + addLine( "n1", "f1", colorFrustum ); + addLine( "n2", "f2", colorFrustum ); + addLine( "n3", "f3", colorFrustum ); + addLine( "n4", "f4", colorFrustum ); // cone - addLine( "p", "n1", hexCone ); - addLine( "p", "n2", hexCone ); - addLine( "p", "n3", hexCone ); - addLine( "p", "n4", hexCone ); + addLine( "p", "n1", colorCone ); + addLine( "p", "n2", colorCone ); + addLine( "p", "n3", colorCone ); + addLine( "p", "n4", colorCone ); // up - addLine( "u1", "u2", hexUp ); - addLine( "u2", "u3", hexUp ); - addLine( "u3", "u1", hexUp ); + addLine( "u1", "u2", colorUp ); + addLine( "u2", "u3", colorUp ); + addLine( "u3", "u1", colorUp ); // target - addLine( "c", "t", hexTarget ); - addLine( "p", "c", hexCross ); + addLine( "c", "t", colorTarget ); + addLine( "p", "c", colorCross ); // cross - addLine( "cn1", "cn2", hexCross ); - addLine( "cn3", "cn4", hexCross ); + addLine( "cn1", "cn2", colorCross ); + addLine( "cn3", "cn4", colorCross ); - addLine( "cf1", "cf2", hexCross ); - addLine( "cf3", "cf4", hexCross ); + addLine( "cf1", "cf2", colorCross ); + addLine( "cf3", "cf4", colorCross ); - function addLine( a, b, hex ) { + function addLine( a, b, color ) { - addPoint( a, hex ); - addPoint( b, hex ); + addPoint( a, color ); + addPoint( b, color ); } - function addPoint( id, hex ) { + function addPoint( id, color ) { - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( hex ) ); + vertices.push( 0, 0, 0 ); + colors.push( color.r, color.g, color.b ); if ( pointMap[ id ] === undefined ) { @@ -40764,14 +40741,17 @@ function CameraHelper( camera ) { } - pointMap[ id ].push( geometry.vertices.length - 1 ); + pointMap[ id ].push( ( vertices.length / 3 ) - 1 ); } + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + LineSegments.call( this, geometry, material ); this.camera = camera; - if( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); + if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); this.matrix = camera.matrixWorld; this.matrixAutoUpdate = false; @@ -40800,9 +40780,11 @@ CameraHelper.prototype.update = function () { if ( points !== undefined ) { - for ( var i = 0, il = points.length; i < il; i ++ ) { + var position = geometry.getAttribute( 'position' ); + + for ( var i = 0, l = points.length; i < l; i ++ ) { - geometry.vertices[ points[ i ] ].copy( vector ); + position.setXYZ( points[ i ], vector.x, vector.y, vector.z ); } @@ -40859,43 +40841,12 @@ CameraHelper.prototype.update = function () { setPoint( "cn3", 0, - h, - 1 ); setPoint( "cn4", 0, h, - 1 ); - geometry.verticesNeedUpdate = true; + geometry.getAttribute( 'position' ).needsUpdate = true; }; }(); -/** - * @author WestLangley / http://github.com/WestLangley - */ - -// a helper to show the world-axis-aligned bounding box for an object - -function BoundingBoxHelper( object, hex ) { - - var color = ( hex !== undefined ) ? hex : 0x888888; - - this.object = object; - - this.box = new Box3(); - - Mesh.call( this, new BoxGeometry( 1, 1, 1 ), new MeshBasicMaterial( { color: color, wireframe: true } ) ); - -} - -BoundingBoxHelper.prototype = Object.create( Mesh.prototype ); -BoundingBoxHelper.prototype.constructor = BoundingBoxHelper; - -BoundingBoxHelper.prototype.update = function () { - - this.box.setFromObject( this.object ); - - this.box.getSize( this.scale ); - - this.box.getCenter( this.position ); - -}; - /** * @author mrdoob / http://mrdoob.com/ */ @@ -41093,21 +41044,21 @@ function AxisHelper( size ) { size = size || 1; - var vertices = new Float32Array( [ + var vertices = [ 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size - ] ); + ]; - var colors = new Float32Array( [ + var colors = [ 1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1 - ] ); + ]; var geometry = new BufferGeometry(); - geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) ); - geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) ); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors } ); @@ -41299,23 +41250,6 @@ var CatmullRomCurve3 = ( function() { } )(); -/************************************************************** - * Closed Spline 3D curve - **************************************************************/ - - -function ClosedSplineCurve3( points ) { - - console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.' ); - - CatmullRomCurve3.call( this, points ); - this.type = 'catmullrom'; - this.closed = true; - -} - -ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype ); - /************************************************************** * Spline 3D curve **************************************************************/ @@ -41503,329 +41437,548 @@ var SceneUtils = { * @author mrdoob / http://mrdoob.com/ */ -function Face4 ( a, b, c, d, normal, color, materialIndex ) { +function Face4( a, b, c, d, normal, color, materialIndex ) { + console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); return new Face3( a, b, c, normal, color, materialIndex ); + } var LineStrip = 0; var LinePieces = 1; -function PointCloud ( geometry, material ) { +function MeshFaceMaterial( materials ) { + + console.warn( 'THREE.MeshFaceMaterial has been renamed to THREE.MultiMaterial.' ); + return new MultiMaterial( materials ); + +} + +function PointCloud( geometry, material ) { + console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); return new Points( geometry, material ); + +} + +function Particle( material ) { + + console.warn( 'THREE.Particle has been renamed to THREE.Sprite.' ); + return new Sprite( material ); + } -function ParticleSystem ( geometry, material ) { +function ParticleSystem( geometry, material ) { + console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); return new Points( geometry, material ); + } -function PointCloudMaterial ( parameters ) { +function PointCloudMaterial( parameters ) { + console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -function ParticleBasicMaterial ( parameters ) { +function ParticleBasicMaterial( parameters ) { + console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -function ParticleSystemMaterial ( parameters ) { +function ParticleSystemMaterial( parameters ) { + console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -function Vertex ( x, y, z ) { +function Vertex( x, y, z ) { + console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); return new Vector3( x, y, z ); + } // function DynamicBufferAttribute( array, itemSize ) { + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' ); return new BufferAttribute( array, itemSize ).setDynamic( true ); + } function Int8Attribute( array, itemSize ) { + console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' ); return new Int8BufferAttribute( array, itemSize ); + } function Uint8Attribute( array, itemSize ) { + console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' ); return new Uint8BufferAttribute( array, itemSize ); + } function Uint8ClampedAttribute( array, itemSize ) { + console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' ); return new Uint8ClampedBufferAttribute( array, itemSize ); + } function Int16Attribute( array, itemSize ) { + console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' ); return new Int16BufferAttribute( array, itemSize ); + } function Uint16Attribute( array, itemSize ) { + console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' ); return new Uint16BufferAttribute( array, itemSize ); + } function Int32Attribute( array, itemSize ) { + console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' ); return new Int32BufferAttribute( array, itemSize ); + } function Uint32Attribute( array, itemSize ) { + console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' ); return new Uint32BufferAttribute( array, itemSize ); + } function Float32Attribute( array, itemSize ) { + console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' ); return new Float32BufferAttribute( array, itemSize ); + } function Float64Attribute( array, itemSize ) { + console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' ); return new Float64BufferAttribute( array, itemSize ); + } // +function ClosedSplineCurve3( points ) { + + console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' ); + + CatmullRomCurve3.call( this, points ); + this.type = 'catmullrom'; + this.closed = true; + +} + +ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype ); + + +// +function BoundingBoxHelper( object, color ) { + + console.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' ); + return new BoxHelper( object, color ); + +} + function EdgesHelper( object, hex ) { + console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' ); return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } +GridHelper.prototype.setColors = function () { + + console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); + +}; + function WireframeHelper( object, hex ) { + console.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' ); return new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } // function XHRLoader( manager ) { + console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' ); return new FileLoader( manager ); + } // Object.assign( Box2.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); + } } ); Object.assign( Box3.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); - } -} ); -Object.assign( Line3.prototype, { - center: function ( optionalTarget ) { - console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); - return this.getCenter( optionalTarget ); } } ); +Line3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +_Math.random16 = function () { + + console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' ); + return Math.random(); + +}; + Object.assign( Matrix3.prototype, { + + flattenToArrayOffset: function ( array, offset ) { + + console.warn( "THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + return this.toArray( array, offset ); + + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); return vector.applyMatrix3( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + } + } ); Object.assign( Matrix4.prototype, { + extractPosition: function ( m ) { + console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); return this.copyPosition( m ); + + }, + flattenToArrayOffset: function ( array, offset ) { + + console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + return this.toArray( array, offset ); + }, + getPosition: function () { + + var v1; + + return function getPosition() { + + if ( v1 === undefined ) v1 = new Vector3(); + console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); + return v1.setFromMatrixColumn( this, 3 ); + + }; + + }(), setRotationFromQuaternion: function ( q ) { + console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); return this.makeRotationFromQuaternion( q ); + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.' ); return vector.applyProjection( this ); + }, multiplyVector4: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + }, rotateAxis: function ( v ) { + console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' ); v.transformDirection( this ); + }, crossVector: function ( vector ) { + console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, - translate: function ( v ) { + translate: function () { + console.error( 'THREE.Matrix4: .translate() has been removed.' ); + }, - rotateX: function ( angle ) { + rotateX: function () { + console.error( 'THREE.Matrix4: .rotateX() has been removed.' ); + }, - rotateY: function ( angle ) { + rotateY: function () { + console.error( 'THREE.Matrix4: .rotateY() has been removed.' ); + }, - rotateZ: function ( angle ) { + rotateZ: function () { + console.error( 'THREE.Matrix4: .rotateZ() has been removed.' ); + }, - rotateByAxis: function ( axis, angle ) { + rotateByAxis: function () { + console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); - } -} ); -Object.assign( Plane.prototype, { - isIntersectionLine: function ( line ) { - console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); - return this.intersectsLine( line ); } -} ); -Object.assign( Quaternion.prototype, { - multiplyVector3: function ( vector ) { - console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); - return vector.applyQuaternion( this ); - } } ); +Plane.prototype.isIntersectionLine = function ( line ) { + + console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); + return this.intersectsLine( line ); + +}; + +Quaternion.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); + return vector.applyQuaternion( this ); + +}; + Object.assign( Ray.prototype, { + isIntersectionBox: function ( box ) { + console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionPlane: function ( plane ) { + console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' ); return this.intersectsPlane( plane ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + } + } ); Object.assign( Shape.prototype, { + extrude: function ( options ) { + console.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' ); return new ExtrudeGeometry( this, options ); + }, makeGeometry: function ( options ) { + console.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' ); return new ShapeGeometry( this, options ); + } + } ); Object.assign( Vector3.prototype, { + setEulerFromRotationMatrix: function () { + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + }, setEulerFromQuaternion: function () { + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + }, getPositionFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); return this.setFromMatrixPosition( m ); + }, getScaleFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); return this.setFromMatrixScale( m ); + }, getColumnFromMatrix: function ( index, matrix ) { + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); return this.setFromMatrixColumn( matrix, index ); + } + } ); // +Geometry.prototype.computeTangents = function () { + + console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); + +}; + Object.assign( Object3D.prototype, { + getChildByName: function ( name ) { + console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); return this.getObjectByName( name ); + }, - renderDepth: function ( value ) { + renderDepth: function () { + console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' ); + }, translate: function ( distance, axis ) { + console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' ); return this.translateOnAxis( axis, distance ); + } + } ); Object.defineProperties( Object3D.prototype, { + eulerOrder: { get: function () { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); return this.rotation.order; + }, set: function ( value ) { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); this.rotation.order = value; + } }, useQuaternion: { get: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + } } + } ); Object.defineProperties( LOD.prototype, { + objects: { get: function () { + console.warn( 'THREE.LOD: .objects has been renamed to .levels.' ); return this.levels; + } } + } ); // @@ -41844,78 +41997,104 @@ PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { Object.defineProperties( Light.prototype, { onlyShadow: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .onlyShadow has been removed.' ); + } }, shadowCameraFov: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' ); this.shadow.camera.fov = value; + } }, shadowCameraLeft: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' ); this.shadow.camera.left = value; + } }, shadowCameraRight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' ); this.shadow.camera.right = value; + } }, shadowCameraTop: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' ); this.shadow.camera.top = value; + } }, shadowCameraBottom: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' ); this.shadow.camera.bottom = value; + } }, shadowCameraNear: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' ); this.shadow.camera.near = value; + } }, shadowCameraFar: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' ); this.shadow.camera.far = value; + } }, shadowCameraVisible: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' ); + } }, shadowBias: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' ); this.shadow.bias = value; + } }, shadowDarkness: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowDarkness has been removed.' ); + } }, shadowMapWidth: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' ); this.shadow.mapSize.width = value; + } }, shadowMapHeight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' ); this.shadow.mapSize.height = value; + } } } ); @@ -41923,111 +42102,161 @@ Object.defineProperties( Light.prototype, { // Object.defineProperties( BufferAttribute.prototype, { + length: { get: function () { - console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' ); + + console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' ); return this.array.length; + } } + } ); Object.assign( BufferGeometry.prototype, { + addIndex: function ( index ) { + console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); this.setIndex( index ); + }, addDrawCall: function ( start, count, indexOffset ) { + if ( indexOffset !== undefined ) { + console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); + } console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); this.addGroup( start, count ); + }, clearDrawCalls: function () { + console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' ); this.clearGroups(); + }, computeTangents: function () { + console.warn( 'THREE.BufferGeometry: .computeTangents() has been removed.' ); + }, computeOffsets: function () { + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); + } + } ); Object.defineProperties( BufferGeometry.prototype, { + drawcalls: { get: function () { + console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); return this.groups; + } }, offsets: { get: function () { + console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' ); return this.groups; + } } + } ); // Object.defineProperties( Uniform.prototype, { + dynamic: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.' ); + } }, onUpdate: { value: function () { + console.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' ); return this; + } } + } ); // Object.defineProperties( Material.prototype, { + wrapAround: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + } }, wrapRGB: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapRGB has been removed.' ); return new Color(); + } } + } ); Object.defineProperties( MeshPhongMaterial.prototype, { + metal: { get: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' ); return false; + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead' ); + } } + } ); Object.defineProperties( ShaderMaterial.prototype, { + derivatives: { get: function () { + console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); return this.extensions.derivatives; + }, set: function ( value ) { + console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); this.extensions.derivatives = value; + } } + } ); // @@ -42052,224 +42281,315 @@ EventDispatcher.prototype = Object.assign( Object.create( { // Object.assign( WebGLRenderer.prototype, { + supportsFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); return this.extensions.get( 'OES_texture_float' ); + }, supportsHalfFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' ); return this.extensions.get( 'OES_texture_half_float' ); + }, supportsStandardDerivatives: function () { + console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' ); return this.extensions.get( 'OES_standard_derivatives' ); + }, supportsCompressedTextureS3TC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_s3tc' ); + }, supportsCompressedTexturePVRTC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + }, supportsBlendMinMax: function () { + console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' ); return this.extensions.get( 'EXT_blend_minmax' ); + }, supportsVertexTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' ); return this.capabilities.vertexTextures; + }, supportsInstancedArrays: function () { + console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' ); return this.extensions.get( 'ANGLE_instanced_arrays' ); + }, enableScissorTest: function ( boolean ) { + console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' ); this.setScissorTest( boolean ); + }, initMaterial: function () { + console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' ); + }, addPrePlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' ); + }, addPostPlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' ); + }, updateShadowMap: function () { + console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' ); + } + } ); Object.defineProperties( WebGLRenderer.prototype, { + shadowMapEnabled: { get: function () { + return this.shadowMap.enabled; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); this.shadowMap.enabled = value; + } }, shadowMapType: { get: function () { + return this.shadowMap.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); this.shadowMap.type = value; + } }, shadowMapCullFace: { get: function () { + return this.shadowMap.cullFace; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.' ); this.shadowMap.cullFace = value; + } } } ); Object.defineProperties( WebGLShadowMap.prototype, { + cullFace: { get: function () { + return this.renderReverseSided ? CullFaceFront : CullFaceBack; + }, set: function ( cullFace ) { + var value = ( cullFace !== CullFaceBack ); console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." ); this.renderReverseSided = value; + } } + } ); // Object.defineProperties( WebGLRenderTarget.prototype, { + wrapS: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); return this.texture.wrapS; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); this.texture.wrapS = value; + } }, wrapT: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); return this.texture.wrapT; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); this.texture.wrapT = value; + } }, magFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); return this.texture.magFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); this.texture.magFilter = value; + } }, minFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); return this.texture.minFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); this.texture.minFilter = value; + } }, anisotropy: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); return this.texture.anisotropy; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); this.texture.anisotropy = value; + } }, offset: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); return this.texture.offset; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); this.texture.offset = value; + } }, repeat: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); return this.texture.repeat; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); this.texture.repeat = value; + } }, format: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); return this.texture.format; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); this.texture.format = value; + } }, type: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); return this.texture.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); this.texture.type = value; + } }, generateMipmaps: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); return this.texture.generateMipmaps; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); this.texture.generateMipmaps = value; + } } + } ); // -Object.assign( Audio.prototype, { - load: function ( file ) { - console.warn( 'THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.' ); - var scope = this; - var audioLoader = new AudioLoader(); - audioLoader.load( file, function ( buffer ) { - scope.setBuffer( buffer ); - } ); - return this; - } -} ); +Audio.prototype.load = function ( file ) { -Object.assign( AudioAnalyser.prototype, { - getData: function ( file ) { - console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); - return this.getFrequencyData(); - } -} ); + console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' ); + var scope = this; + var audioLoader = new AudioLoader(); + audioLoader.load( file, function ( buffer ) { + + scope.setBuffer( buffer ); + + } ); + return this; + +}; + +AudioAnalyser.prototype.getData = function () { + + console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); + return this.getFrequencyData(); + +}; // @@ -42278,7 +42598,6 @@ var GeometryUtils = { merge: function ( geometry1, geometry2, materialIndexOffset ) { console.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' ); - var matrix; if ( geometry2.isMesh ) { @@ -42418,7 +42737,7 @@ var UniformsUtils = { // -function Projector () { +function Projector() { console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' ); @@ -42436,7 +42755,7 @@ function Projector () { }; - this.pickingRay = function ( vector, camera ) { + this.pickingRay = function () { console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' ); @@ -42446,7 +42765,7 @@ function Projector () { // -function CanvasRenderer () { +function CanvasRenderer() { console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' ); @@ -42458,4 +42777,4 @@ function CanvasRenderer () { } -export { WebGLRenderTargetCube, WebGLRenderTarget, WebGLRenderer, WebGL2Renderer, ShaderLib, UniformsLib, ShaderChunk, FogExp2, Fog, Scene, LensFlare, Sprite, LOD, SkinnedMesh, Skeleton, Bone, Mesh, LineSegments, Line, Points, Group, VideoTexture, DataTexture, CompressedTexture, CubeTexture, CanvasTexture, DepthTexture, TextureIdCount, Texture, MaterialIdCount, CompressedTextureLoader, BinaryTextureLoader, DataTextureLoader, CubeTextureLoader, TextureLoader, ObjectLoader, MaterialLoader, BufferGeometryLoader, DefaultLoadingManager, LoadingManager, JSONLoader, ImageLoader, FontLoader, FileLoader, Loader, Cache, AudioLoader, SpotLightShadow, SpotLight, PointLight, RectAreaLight, HemisphereLight, DirectionalLightShadow, DirectionalLight, AmbientLight, LightShadow, Light, StereoCamera, PerspectiveCamera, OrthographicCamera, CubeCamera, Camera, AudioListener, PositionalAudio, AudioContext, AudioAnalyser, Audio, VectorKeyframeTrack, StringKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, ColorKeyframeTrack, BooleanKeyframeTrack, PropertyMixer, PropertyBinding, KeyframeTrack, AnimationUtils, AnimationObjectGroup, AnimationMixer, AnimationClip, Uniform, InstancedBufferGeometry, BufferGeometry, GeometryIdCount, Geometry, InterleavedBufferAttribute, InstancedInterleavedBuffer, InterleavedBuffer, InstancedBufferAttribute, Float64BufferAttribute, Float32BufferAttribute, Uint32BufferAttribute, Int32BufferAttribute, Uint16BufferAttribute, Int16BufferAttribute, Uint8ClampedBufferAttribute, Uint8BufferAttribute, Int8BufferAttribute, BufferAttribute, Face3, Object3DIdCount, Object3D, Raycaster, Layers, EventDispatcher, Clock, QuaternionLinearInterpolant, LinearInterpolant, DiscreteInterpolant, CubicInterpolant, Interpolant, Triangle, Spline, _Math as Math, Spherical, Plane, Frustum, Sphere, Ray, Matrix4, Matrix3, Box3, Box2, Line3, Euler, Vector4, Vector3, Vector2, Quaternion, Color, MorphBlendMesh, ImmediateRenderObject, VertexNormalsHelper, SpotLightHelper, SkeletonHelper, PointLightHelper, RectAreaLightHelper, HemisphereLightHelper, GridHelper, FaceNormalsHelper, DirectionalLightHelper, CameraHelper, BoundingBoxHelper, BoxHelper, ArrowHelper, AxisHelper, ClosedSplineCurve3, CatmullRomCurve3, SplineCurve3, CubicBezierCurve3, QuadraticBezierCurve3, LineCurve3, ArcCurve, EllipseCurve, SplineCurve, CubicBezierCurve, QuadraticBezierCurve, LineCurve, Shape, ShapePath, Path, Font, CurvePath, Curve, ShapeUtils, SceneUtils, CurveUtils, WireframeGeometry, ParametricGeometry, ParametricBufferGeometry, TetrahedronGeometry, TetrahedronBufferGeometry, OctahedronGeometry, OctahedronBufferGeometry, IcosahedronGeometry, IcosahedronBufferGeometry, DodecahedronGeometry, DodecahedronBufferGeometry, PolyhedronGeometry, PolyhedronBufferGeometry, TubeGeometry, TubeBufferGeometry, TorusKnotGeometry, TorusKnotBufferGeometry, TorusGeometry, TorusBufferGeometry, TextGeometry, SphereBufferGeometry, SphereGeometry, RingGeometry, RingBufferGeometry, PlaneBufferGeometry, PlaneGeometry, LatheGeometry, LatheBufferGeometry, ShapeGeometry, ShapeBufferGeometry, ExtrudeGeometry, EdgesGeometry, ConeGeometry, ConeBufferGeometry, CylinderGeometry, CylinderBufferGeometry, CircleBufferGeometry, CircleGeometry, BoxBufferGeometry, BoxGeometry, ShadowMaterial, SpriteMaterial, RawShaderMaterial, ShaderMaterial, PointsMaterial, MultiMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshPhongMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshBasicMaterial, LineDashedMaterial, LineBasicMaterial, Material, REVISION, MOUSE, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, FrontFaceDirectionCW, FrontFaceDirectionCCW, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, FrontSide, BackSide, DoubleSide, FlatShading, SmoothShading, NoColors, FaceColors, VertexColors, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, BlendingMode, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, Uncharted2ToneMapping, CineonToneMapping, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, SphericalReflectionMapping, CubeUVReflectionMapping, CubeUVRefractionMapping, TextureMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, TextureWrapping, NearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipMapNearestFilter, LinearMipMapLinearFilter, TextureFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedInt248Type, AlphaFormat, RGBFormat, RGBAFormat, LuminanceFormat, LuminanceAlphaFormat, RGBEFormat, DepthFormat, DepthStencilFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, LinearEncoding, sRGBEncoding, GammaEncoding, RGBEEncoding, LogLuvEncoding, RGBM7Encoding, RGBM16Encoding, RGBDEncoding, BasicDepthPacking, RGBADepthPacking, BoxGeometry as CubeGeometry, Face4, LineStrip, LinePieces, MultiMaterial as MeshFaceMaterial, PointCloud, Sprite as Particle, ParticleSystem, PointCloudMaterial, ParticleBasicMaterial, ParticleSystemMaterial, Vertex, DynamicBufferAttribute, Int8Attribute, Uint8Attribute, Uint8ClampedAttribute, Int16Attribute, Uint16Attribute, Int32Attribute, Uint32Attribute, Float32Attribute, Float64Attribute, EdgesHelper, WireframeHelper, XHRLoader, GeometryUtils, ImageUtils, UniformsUtils, Projector, CanvasRenderer }; +export { WebGLRenderTargetCube, WebGLRenderTarget, WebGLRenderer, ShaderLib, UniformsLib, ShaderChunk, FogExp2, Fog, Scene, LensFlare, Sprite, LOD, SkinnedMesh, Skeleton, Bone, Mesh, LineSegments, Line, Points, Group, VideoTexture, DataTexture, CompressedTexture, CubeTexture, CanvasTexture, DepthTexture, Texture, CompressedTextureLoader, BinaryTextureLoader, DataTextureLoader, CubeTextureLoader, TextureLoader, ObjectLoader, MaterialLoader, BufferGeometryLoader, DefaultLoadingManager, LoadingManager, JSONLoader, ImageLoader, FontLoader, FileLoader, Loader, Cache, AudioLoader, SpotLightShadow, SpotLight, PointLight, RectAreaLight, HemisphereLight, DirectionalLightShadow, DirectionalLight, AmbientLight, LightShadow, Light, StereoCamera, PerspectiveCamera, OrthographicCamera, CubeCamera, Camera, AudioListener, PositionalAudio, AudioContext, AudioAnalyser, Audio, VectorKeyframeTrack, StringKeyframeTrack, QuaternionKeyframeTrack, NumberKeyframeTrack, ColorKeyframeTrack, BooleanKeyframeTrack, PropertyMixer, PropertyBinding, KeyframeTrack, AnimationUtils, AnimationObjectGroup, AnimationMixer, AnimationClip, Uniform, InstancedBufferGeometry, BufferGeometry, GeometryIdCount, Geometry, InterleavedBufferAttribute, InstancedInterleavedBuffer, InterleavedBuffer, InstancedBufferAttribute, Face3, Object3D, Raycaster, Layers, EventDispatcher, Clock, QuaternionLinearInterpolant, LinearInterpolant, DiscreteInterpolant, CubicInterpolant, Interpolant, Triangle, Spline, _Math as Math, Spherical, Plane, Frustum, Sphere, Ray, Matrix4, Matrix3, Box3, Box2, Line3, Euler, Vector4, Vector3, Vector2, Quaternion, Color, MorphBlendMesh, ImmediateRenderObject, VertexNormalsHelper, SpotLightHelper, SkeletonHelper, PointLightHelper, RectAreaLightHelper, HemisphereLightHelper, GridHelper, PolarGridHelper, FaceNormalsHelper, DirectionalLightHelper, CameraHelper, BoxHelper, ArrowHelper, AxisHelper, CatmullRomCurve3, SplineCurve3, CubicBezierCurve3, QuadraticBezierCurve3, LineCurve3, ArcCurve, EllipseCurve, SplineCurve, CubicBezierCurve, QuadraticBezierCurve, LineCurve, Shape, ShapePath, Path, Font, CurvePath, Curve, ShapeUtils, SceneUtils, CurveUtils, WireframeGeometry, ParametricGeometry, ParametricBufferGeometry, TetrahedronGeometry, TetrahedronBufferGeometry, OctahedronGeometry, OctahedronBufferGeometry, IcosahedronGeometry, IcosahedronBufferGeometry, DodecahedronGeometry, DodecahedronBufferGeometry, PolyhedronGeometry, PolyhedronBufferGeometry, TubeGeometry, TubeBufferGeometry, TorusKnotGeometry, TorusKnotBufferGeometry, TorusGeometry, TorusBufferGeometry, TextGeometry, SphereBufferGeometry, SphereGeometry, RingGeometry, RingBufferGeometry, PlaneBufferGeometry, PlaneGeometry, LatheGeometry, LatheBufferGeometry, ShapeGeometry, ShapeBufferGeometry, ExtrudeGeometry, EdgesGeometry, ConeGeometry, ConeBufferGeometry, CylinderGeometry, CylinderBufferGeometry, CircleBufferGeometry, CircleGeometry, BoxBufferGeometry, BoxGeometry, ShadowMaterial, SpriteMaterial, RawShaderMaterial, ShaderMaterial, PointsMaterial, MultiMaterial, MeshPhysicalMaterial, MeshStandardMaterial, MeshPhongMaterial, MeshToonMaterial, MeshNormalMaterial, MeshLambertMaterial, MeshDepthMaterial, MeshBasicMaterial, LineDashedMaterial, LineBasicMaterial, Material, Float64BufferAttribute, Float32BufferAttribute, Uint32BufferAttribute, Int32BufferAttribute, Uint16BufferAttribute, Int16BufferAttribute, Uint8ClampedBufferAttribute, Uint8BufferAttribute, Int8BufferAttribute, BufferAttribute, REVISION, MOUSE, CullFaceNone, CullFaceBack, CullFaceFront, CullFaceFrontBack, FrontFaceDirectionCW, FrontFaceDirectionCCW, BasicShadowMap, PCFShadowMap, PCFSoftShadowMap, FrontSide, BackSide, DoubleSide, FlatShading, SmoothShading, NoColors, FaceColors, VertexColors, NoBlending, NormalBlending, AdditiveBlending, SubtractiveBlending, MultiplyBlending, CustomBlending, BlendingMode, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, OneMinusSrcColorFactor, SrcAlphaFactor, OneMinusSrcAlphaFactor, DstAlphaFactor, OneMinusDstAlphaFactor, DstColorFactor, OneMinusDstColorFactor, SrcAlphaSaturateFactor, NeverDepth, AlwaysDepth, LessDepth, LessEqualDepth, EqualDepth, GreaterEqualDepth, GreaterDepth, NotEqualDepth, MultiplyOperation, MixOperation, AddOperation, NoToneMapping, LinearToneMapping, ReinhardToneMapping, Uncharted2ToneMapping, CineonToneMapping, UVMapping, CubeReflectionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, SphericalReflectionMapping, CubeUVReflectionMapping, CubeUVRefractionMapping, TextureMapping, RepeatWrapping, ClampToEdgeWrapping, MirroredRepeatWrapping, TextureWrapping, NearestFilter, NearestMipMapNearestFilter, NearestMipMapLinearFilter, LinearFilter, LinearMipMapNearestFilter, LinearMipMapLinearFilter, TextureFilter, UnsignedByteType, ByteType, ShortType, UnsignedShortType, IntType, UnsignedIntType, FloatType, HalfFloatType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShort565Type, UnsignedInt248Type, AlphaFormat, RGBFormat, RGBAFormat, LuminanceFormat, LuminanceAlphaFormat, RGBEFormat, DepthFormat, DepthStencilFormat, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, LoopOnce, LoopRepeat, LoopPingPong, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, ZeroCurvatureEnding, ZeroSlopeEnding, WrapAroundEnding, TrianglesDrawMode, TriangleStripDrawMode, TriangleFanDrawMode, LinearEncoding, sRGBEncoding, GammaEncoding, RGBEEncoding, LogLuvEncoding, RGBM7Encoding, RGBM16Encoding, RGBDEncoding, BasicDepthPacking, RGBADepthPacking, BoxGeometry as CubeGeometry, Face4, LineStrip, LinePieces, MeshFaceMaterial, PointCloud, Particle, ParticleSystem, PointCloudMaterial, ParticleBasicMaterial, ParticleSystemMaterial, Vertex, DynamicBufferAttribute, Int8Attribute, Uint8Attribute, Uint8ClampedAttribute, Int16Attribute, Uint16Attribute, Int32Attribute, Uint32Attribute, Float32Attribute, Float64Attribute, ClosedSplineCurve3, BoundingBoxHelper, EdgesHelper, WireframeHelper, XHRLoader, GeometryUtils, ImageUtils, UniformsUtils, Projector, CanvasRenderer }; diff --git a/docs/api/core/BufferAttribute.html b/docs/api/core/BufferAttribute.html index b5851a5735e98724f713a49bbc3bb109eb4f2113..9b0ad9c7f76ee42e94c7fb5fe51605ede48c6ce5 100644 --- a/docs/api/core/BufferAttribute.html +++ b/docs/api/core/BufferAttribute.html @@ -11,47 +11,86 @@

[name]

- This class stores data for an attribute associated with a [page:BufferGeometry]. See that page for details and a usage example. This class is used to store builtin attributes such as vertex position, normals, color, etc., but can also be used in your code to store custom attributes in a [page:BufferGeometry]. + This class stores data for an attribute (such as vertex positions, face indices, normals, + colors, UVs, and any custom attributes ) associated with a [page:BufferGeometry], which allows + for more efficient passing of data to the GPU. See that page for details and a usage example.

+ + Data is stored as vectors of any length (defined by [page:BufferAttribute.itemSize itemSize]), + and in general in the methods outlined below if passing in an index, this is automatically + multiplied by the vector length.

Constructor

[name]( [page:TypedArray array], [page:Integer itemSize], [page:Boolean normalized] )

- Instantiates this attribute with data from the associated buffer. - itemSize gives the number of values of the array that should be associated with a particular vertex. normalized indicates how the underlying data in the buffer maps to the values in the GLSL shader code. + [page:TypedArray array] -- Must be a [link:https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/TypedArray TypedArray]. + Used to instantiate the buffer.
+ This array should have + itemSize * numVertices + elements, where numVertices is the number of vertices in the associated [page:BufferGeometry BufferGeometry].

+ + + [page:Integer itemSize] -- the number of values of the array that should be associated with + a particular vertex. For instance, if this + attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3. +

+ + [page:Boolean normalized] -- (optional) Indicates how the underlying data in the buffer maps + to the values in the GLSL code. For instance, if [page:TypedArray array] is an instance of + UInt16Array, and [page:Boolean normalized] is true, the values 0 - +65535 in the array + data will be mapped to 0.0f - +1.0f in the GLSL attribute. An Int16Array (signed) would map + from -32767 - +32767 to -1.0f - +1.0f. If [page:Boolean normalized] is false, the values + will be converted to floats which contain the exact value, i.e. 32767 becomes 32767.0f.

Properties

[property:TypedArray array]

- Stores the data associated with this attribute. This element should have itemSize * numVertices elements, where numVertices is the number of vertices in the associated [page:BufferGeometry geometry]. [page:TypedArray array] can be an instance of UInt8Array, Int8Array, UInt16Array, Int16Array, or Float32Array. + The [page:TypedArray array] holding data stored in the buffer.
-

[property:Integer itemSize]

+

[property:Integer count]

- Records how many items of the array are associated with a particular vertex. For instance, if this - attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3. + Stores the [page:BufferAttribute.array array]'s length divided by the [page:BufferAttribute.itemSize itemSize].

+ + If the buffer is storing a 3-component vector (such as a position, normal, or color), + then this will count the number of such vectors stored.
-

[property:Integer count]

+

[property:Boolean dynamic]

- Gives the total number of elements in the array. + Whether the buffer is dynamic or not. Default is *false*.
+ + If false, the GPU is informed that contents of the buffer are likely to be used often and not change often. + This corresponds to the [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.STATIC_DRAW] flag.
+ if true, the GPU is informed that contents of the buffer are likely to be used often and change often. + This corresponds to the [link:https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData gl.DYNAMIC_DRAW] flag.
-

[property:Boolean needsUpdate]

+

[property:Boolean isBufferAttribute]

- Flag to indicate that this attribute has changed and should be re-send to the GPU. Set this to true when you modify the value of the array. + Used to check whether this or derived classes are BufferAttributes. Default is *true*.

+ + You should not change this, as it used internally for optimisation.
-

[property:Boolean normalized]

+

[property:Integer itemSize]

+
The length of vectors that are being stored in the [page:BufferAttribute.array array].
+ + +

[property:Boolean needsUpdate]

- Indicates how the underlying data in the buffer maps to the values in the GLSL code. For instance, if [page:TypedArray array] is an instance of UInt16Array, and [page:Boolean normalized] is true, the values 0 - +65535 in the array data will be mapped to 0.0f - +1.0f in the GLSL attribute. An Int16Array (signed) would map from -32767 - +32767 to -1.0f - +1.0f. If [page:Boolean normalized] is false, the values will be converted to floats which contain the exact value, i.e. 32767 becomes 32767.0f. + Flag to indicate that this attribute has changed and should be re-sent to the GPU. + Set this to true when you modify the value of the array.

+ + Setting this to true also increments the [page:BufferAttribute.version version].
-

[property:Integer version]

+

[property:Boolean normalized]

- A version number, incremented every time the needsUpdate property is set to true. + Indicates how the underlying data in the buffer maps to the values in the GLSL shader code. + See the constructor above for details.

[property:Function onUploadCallback]

@@ -59,64 +98,120 @@ A callback function that is executed after the Renderer has transfered the attribute array data to the GPU. -

Methods

+

[property:Object updateRange]

+
Object containing:
+ [page:Integer offset]: Default is *0*. Position at whcih to start update.
+ [page:Integer count]: Default is *-1*, which means don't use update ranges.

-

[method:null copyAt] ( [page:Integer index1], attribute, [page:Integer index2] )

-
- Copies itemSize values in the array from the vertex at index2 to the vertex at index1. + This can be used to only update some components of stored vectors (for example, just the component + related to color).
-

[method:null set] ( [page:Array value] )

+

[property:String uuid]

- Sets the associated array with values from the passed array. + [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. + This gets automatically assigned and this shouldn't be edited.
-

[method:null setX]( index, x )

-
- Sets the value of the array at index * itemSize to x +

[property:Integer version]

+
A version number, incremented every time the [page:BufferAttribute.needsUpdate needsUpdate] property is set to true.
+ + +

Methods

+ +

[method:BufferAttribute clone]()

+
Return a copy of this bufferAttribute.
+ +

[method:BufferAttribute copyArray]( array )

+
Copy the array given here (which can be a normal array or TypedArray) into + [page:BufferAttribute.array array].

+ + See [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set] + for notes on requirements if copying a TypedArray.
-

[method:null setY]( index, y )

+

[method:null copyAt] ( [page:Integer index1], [page:BufferAttribute bufferAttribute], [page:Integer index2] )

+
Copy a vector from bufferAttribute[index2] to [page:BufferAttribute.array array][index1].
+ +

[method:BufferAttribute copyColorsArray]( colors )

+
Copy an array representing RGB color values into [page:BufferAttribute.array array].
+ +

[method:BufferAttribute copyIndicesArray]( indices )

+
Copy an array representing [page:Face3] indices into [page:BufferAttribute.array array].
+ +

[method:BufferAttribute copyVector2sArray]( vectors )

+
Copy an array representing [page:Vector2]s into [page:BufferAttribute.array array].
+ +

[method:BufferAttribute copyVector3sArray]( vectors )

+
Copy an array representing [page:Vector3]s into [page:BufferAttribute.array array].
+ +

[method:BufferAttribute copyVector4sArray]( vectors )

+
Copy an array representing [page:Vector4]s into [page:BufferAttribute.array array].
+ +

[method:Number getX]( index )

+
Returns the x component of the vector at the given index.
+ +

[method:Number getY]( index )

+
Returns the y component of the vector at the given index.
+ +

[method:Number getZ]( index )

+
Returns the z component of the vector at the given index.
+ +

[method:Number getW]( index )

+
Returns the w component of the vector at the given index.
+ +

[method:null onUpload]( [page:Function callback] )

- Sets the value of the array at index * itemSize + 1 to y + Sets the value of the onUploadCallback property.

+ + In the [example:webgl_buffergeometry WebGL / Buffergeometry] this is used to free memory + after the buffer has been transfered to the GPU.
-

[method:null setZ]( index, z )

+

[method:null set] ( [page:Array value], [page:Integer offset] )

- Sets the value of the array at index * itemSize + 2 to z + value -- an [page:Array] or [page:TypedArray] from which to copy values.
+ offset -- (optional) index of the [page:BufferAttribute.array array] at which to start copying.

+ + Calls [link:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set TypedArray.set]( [page:Array value], [page:Integer offset] ) + on the [page:BufferAttribute.array array].

+ + In particular, see that page for requirements on [page:Array value] + being a [page:TypedArray].
-

[method:null setXY]( index, x, y )

+

[method:null setArray] ( [page:TypedArray array] )

- Sets the value of the array at index * itemSize to x and - sets the value of the array at index * itemSize + 1 to y + [page:BufferAttribute.array array] to the TypedArray passed in here.

+ + After setting the array, [page:BufferAttribute.needsUpdate needsUpdate] should be set to true.
+

[method:BufferAttribute setDynamic] ( [page:Boolean value] )

+
Set [page:BufferAttribute.dynamic dynamic] to value.
+ +

[method:null setX]( index, x )

+
Sets the x component of the vector at the given index.
+ +

[method:null setY]( index, y )

+
Sets the y component of the vector at the given index.
+ +

[method:null setZ]( index, z )

+
Sets the z component of the vector at the given index.
+ +

[method:null setW]( index, w )

+
Sets the w component of the vector at the given index.
+ +

[method:null setXY]( index, x, y )

+
Sets the x and y components of the vector at the given index.
+

[method:null setXYZ]( index, x, y, z )

-
- Sets the value of the array at index * itemSize to x, - the value of the array at index * itemSize + 1 to y, and - the value of the array at index * itemSize + 2 to z. -
+
Sets the x, y and z components of the vector at the given index.

[method:null setXYZW]( index, x, y, z, w )

-
- Sets the value of the array at index * itemSize to x, - the value of the array at index * itemSize + 1 to y, - the value of the array at index * itemSize + 2 to z, and - the value of the array at index * itemSize + 3 to w. -
+
Sets the x, y, z and w components of the vector at the given index.
-

[method:null onUpload]( [page:Function callback] )

-
- Sets the value of the onUploadCallback property. -
-
Example: [example:webgl_buffergeometry used to free memory after the buffer has been transfered to GPU].
-

[method:BufferAttribute clone]()

-
- Copies this attribute. -

Source

diff --git a/docs/api/core/BufferGeometry.html b/docs/api/core/BufferGeometry.html index f05a29b1a611357e11a6102309fc99d42b1b3840..75c9226b26807eaab529460f3cf9adf298da2fe4 100644 --- a/docs/api/core/BufferGeometry.html +++ b/docs/api/core/BufferGeometry.html @@ -14,15 +14,15 @@

This class is an efficient alternative to [page:Geometry], because it stores all data, including vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers; this - reduces the cost of passing all this data to the GPU. + reduces the cost of passing all this data to the GPU.
This also makes BufferGeometry harder to work with than [page:Geometry]; rather than accessing position data as [page:Vector3] objects, color data as [page:Color] objects, and so on, you have to - access the raw data from the appropriate [page:BufferAttribute attribute] buffer. This makes + access the raw data from the appropriate [page:BufferAttribute attribute buffer]. This makes BufferGeometry best-suited for static objects where you don't need to manipulate the geometry much after instantiating it.

-

Example

+

Example

var geometry = new THREE.BufferGeometry(); // create a simple square shape. We duplicate the top left and bottom right @@ -42,16 +42,23 @@ var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); var mesh = new THREE.Mesh( geometry, material ); -

More examples: [example:webgl_buffergeometry Complex mesh with non-indexed faces], [example:webgl_buffergeometry_uint Complex mesh with indexed faces], [example:webgl_buffergeometry_lines Lines], [example:webgl_buffergeometry_lines_indexed Indexed Lines], [example:webgl_buffergeometry_custom_attributes_particles Particles], and [example:webgl_buffergeometry_rawshader Raw Shaders].

+
+ [example:webgl_buffergeometry Complex mesh with non-indexed faces]
+ [example:webgl_buffergeometry_uint Complex mesh with indexed faces]
+ [example:webgl_buffergeometry_lines Lines]
+ [example:webgl_buffergeometry_lines_indexed Indexed Lines]
+ [example:webgl_buffergeometry_custom_attributes_particles Particles]
+ [example:webgl_buffergeometry_rawshader Raw Shaders] +
-

Accessing attributes

+

Accessing Attributes

WebGL stores data associated with individual vertices of a geometry in attributes. Examples include the position of the vertex, the normal vector for the vertex, the vertex color, and so on. When using [page:Geometry], the [page:WebGLRenderer renderer] takes care of wrapping up this information into typed array buffers and sending this data to the shader. With - BufferGeometry, all of this data is stored in buffers associated with an individual attributes. + BufferGeometry, all of this data is stored in buffers associated with individual attributes. This means that to get the position data associated with a vertex (for instance), you must call [page:.getAttribute] to access the 'position' [page:BufferAttribute attribute], then access the individual x, y, and z coordinates of the position. @@ -59,27 +66,30 @@

The following attributes are set by various members of this class:

-

[page:BufferAttribute position] (itemSize: 3)

+

[page:BufferAttribute position] (itemSize: 3)

Stores the x, y, and z coordinates of each vertex in this geometry. Set by [page:.fromGeometry]().
-

[page:BufferAttribute normal] (itemSize: 3)

+

[page:BufferAttribute normal] (itemSize: 3)

Stores the x, y, and z components of the face or vertex normal vector of each vertex in this geometry. Set by [page:.fromGeometry]().
-

[page:BufferAttribute color] (itemSize: 3)

+

[page:BufferAttribute color] (itemSize: 3)

Stores the red, green, and blue channels of vertex color of each vertex in this geometry. Set by [page:.fromGeometry]().
-

[page:BufferAttribute index] (itemSize: 1)

- Allows for vertices to be re-used across multiple triangles; this is called using "indexed triangles," and works much the same as it does in [page:Geometry]: each triangle is associated with the index of three vertices. This attribute therefore stores the index of each vertex for each triangular face. +

[page:BufferAttribute index] (itemSize: 1)

+ Allows for vertices to be re-used across multiple triangles; this is called using "indexed triangles" and + works much the same as it does in [page:Geometry]: each triangle is associated with the indices of three vertices. + This attribute therefore stores the index of each vertex for each triangular face. - If this attribute is not set, the [page:WebGLRenderer renderer] assumes that each three contiguous positions represent a single triangle. + If this attribute is not set, the [page:WebGLRenderer renderer] assumes that each three contiguous + positions represent a single triangle.

In addition to the the built-in attributes, you can set your own custom attributes using the addAttribute method. With [page:Geometry], these attributes are set and stored on the [page:Material]. In BufferGeometry, the attributes are stored with the geometry itself. Note that you still need to set the attributes information on the material as well, but the value of each attribute is stored in the BufferGeometry. @@ -97,141 +107,141 @@

Properties

-

[property:Integer id]

-
- Unique number for this buffergeometry instance. -
-

[property:Hashmap attributes]

This hashmap has as id the name of the attribute to be set and as value the [page:BufferAttribute buffer] to set it to. Rather than accessing this property directly, use addAttribute and getAttribute to access attributes of this geometry.
- + Bounding box for the bufferGeometry, which can be calculated with + [page:.computeBoundingBox](). Default is *null*. +
-

[property:Array drawcalls] (previously [property:Array offsets])

+

[property:Sphere boundingSphere]

- For geometries that use indexed triangles, this Array can be used to split the object into multiple WebGL draw calls. Each draw call will draw some subset of the vertices in this geometry using the configured [page:Material shader]. This may be necessary if, for instance, you have more than 65535 vertices in your object. - Each element is an object of the form: - { start: Integer, count: Integer, index: Integer } - where start specifies the index of the first vertex in this draw call, count specifies how many vertices are included, and index specifies an optional offset. - - Use addDrawCall to add draw calls, rather than modifying this array directly. + Bounding sphere for the bufferGeometry, which can be calculated with + [page:.computeBoundingSphere](). Default is *null*.
-

[property:Box3 boundingBox]

+

[property:Object drawRange]

- Bounding box. - { min: new THREE.Vector3(), max: new THREE.Vector3() } + Used to determine what part of the geometry should be rendered. This should not + be set directly, instead use [page:.setDrawRange].
+ Default is + + { start: 0, count: Infinity } +
-

[property:Sphere boundingSphere]

+

[property:Array groups]

- Bounding sphere. - { radius: float } + Split the geometry into groups, each of which will be rendered in a separate WebGL draw call. + This allows a [page:MultiMaterial] to be used with the bufferGeometry.

+ + Each group is an object of the form: + { start: Integer, count: Integer, materialIndex: Integer } + where start specifies the index of the first vertex in this draw call, count specifies + how many vertices are included, and materialIndex specifies the [page:MultiMaterial] index to use.

+ + Use [page:.addGroup] to add groups, rather than modifying this array directly.
-

Methods

-

[page:EventDispatcher EventDispatcher] methods are available on this class.

+ -

[method:null addDrawCall]( [page:Integer start], [page:Integer count], [page:Integer indexOffset] )

-
- Adds a draw call to this geometry; see the [page:BufferGeometry.drawcalls drawcalls] property for details. -
-

[method:null clearDrawCalls]( )

-
- Clears all draw calls. -
+

[property:Integer id]

+
Unique number for this bufferGeometry instance.
-

[method:null applyMatrix]( [page:Matrix4 matrix] )

+

[property:BufferAttribute index]

- Bakes matrix transform directly into vertex coordinates. + See "Accessing Attributes" section above for a description of this property. + Default is *null*.
-

[method:null center] ()

+

[property:Boolean isBufferGeometry]

- Center the geometry based on the bounding box. -
+ Used to check whether this or derived classes are BufferGeometries. Default is *true*.

-

[method:BufferGeometry rotateX] ( [page:Float radians] )

-
- Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. + You should not change this, as it used internally for optimisation.
-

[method:BufferGeometry rotateY] ( [page:Float radians] )

-
- Rotate the geometry about the Y axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. -
+

[property:Integer MaxIndex]

+
Maximum number of vertices allowed, set to *65535*.
-

[method:BufferGeometry rotateZ] ( [page:Float radians] )

+

[property:Object morphAttributes]

- Rotate the geometry about the Z axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. + Hashmap of [page:BufferAttribute]s holding details of the geometry's [page:Geometry.morphTargets morphTargets].
-

[method:BufferGeometry translate] ( [page:Float x], [page:Float y], [page:Float z] )

+

[property:String name]

- Translate the geometry. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.position] for typical real-time mesh translation. + Optional name for this bufferGeometry instance. Default is an empty string.
-

[method:BufferGeometry scale] ( [page:Float x], [page:Float y], [page:Float z] )

+

[property:String uuid]

- Scale the geometry data. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.scale] for typical real-time mesh scaling. + [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. + This gets automatically assigned and shouldn't be edited.
-

[method:BufferGeometry lookAt] ( [page:Vector3 vector] )

-
- vector - A world vector to look at.
-
-
- Rotates the geometry to face point in space. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.lookAt] for typical real-time mesh usage. -
+

Methods

-

[method:BufferGeometry setFromObject] ( [page:Object3D object] )

+

[page:EventDispatcher EventDispatcher] methods are available on this class.

+ +

[property:null addAttribute]( [page:String name], [page:BufferAttribute attribute] )

- Sets the attributes for this BufferGeometry from an [page:Object3D]. + Adds an attribute to this geometry. Use this rather than the attributes property, + because an internal hashmap of [page:.attributes] is maintained to speed up iterating over + attributes.
-

[method:null computeVertexNormals]()

+

[method:null addGroup]( [page:Integer start], [page:Integer count], [page:Integer materialIndex] )

- Computes vertex normals by averaging face normals.
+ Adds a group to this geometry; see the [page:BufferGeometry.groups groups] + property for details.
+ +

[method:null applyMatrix]( [page:Matrix4 matrix] )

+
Bakes matrix transform directly into vertex coordinates.
+ +

[method:null center] ()

+
Center the geometry based on the bounding box.
+ +

[method:BufferGeometry clone]()

+
Creates a clone of this BufferGeometry.
+ +

[method:BufferGeometry copy]( [page:BufferGeometry bufferGeometry] )

+
Copies another BufferGeometry to this BufferGeometry.
+ +

[method:null clearGroups]( )

+
Clears all groups.
+

[method:null computeBoundingBox]()

- Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
+ Computes bounding box of the geometry, updating [page:.boundingBox] attribute.
Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are *null*.

[method:null computeBoundingSphere]()

- Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
+ Computes bounding sphere of the geometry, updating [page:.boundingSphere] attribute.
Bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are *null*.
-

[method:null merge]( [page:BufferGeometry bufferGeometry], [page:Integer offset] )

-
- Merge in another BufferGeometry with an optional offset of where to start merging in. -
+

[method:null computeVertexNormals]()

+
Computes vertex normals by averaging face normals.

[method:null dispose]()

@@ -239,42 +249,105 @@ You need to call this when you want the bufferGeometry removed while the application is running.
-

[method:BufferGeometry fromGeometry]( [page:Geometry] )

+

[method:BufferGeometry fromDirectGeometry]( [page:Geometry] )

- Populates this BufferGeometry with data from a [page:Geometry] object. + Populates this BufferGeometry with data from a [page:DirectGeometry] object.

+ + Note: [page:DirectGeometry] is mainly used as an intermediary object for converting between [page:Geometry] + and BufferGeometry.
+

[method:BufferGeometry fromGeometry]( [page:Geometry] )

+
Populates this BufferGeometry with data from a [page:Geometry] object.
+

[method:BufferAttribute getAttribute]( [page:String name] )

-
- Returns the [page:BufferAttribute attribute] with the specified name. -
+
Returns the [page:BufferAttribute attribute] with the specified name.
-

[method:BufferAttribute removeAttribute]( [page:String name] )

+

[method:BufferAttribute getIndex] ()

+
Return the [page:.index] buffer.
+ +

[method:BufferGeometry lookAt] ( [page:Vector3 vector] )

- Removes the [page:BufferAttribute attribute] with the specified name. + vector - A world vector to look at.

+ + Rotates the geometry to face a point in space. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.lookAt] for typical real-time mesh usage.
+

[method:null merge]( [page:BufferGeometry bufferGeometry], [page:Integer offset] )

+
Merge in another BufferGeometry with an optional offset of where to start merging in.
+

[method:null normalizeNormals]()

Every normal vector in a geometry will have a magnitude of 1. This will correct lighting on the geometry surfaces.
-

[method:Object toJSON]()

+

[method:BufferAttribute removeAttribute]( [page:String name] )

+
Removes the [page:BufferAttribute attribute] with the specified name.
+ +

[method:BufferGeometry rotateX] ( [page:Float radians] )

- Returns a raw object representation of the BufferGeometry. + Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.rotation] for typical real-time mesh rotation.
-

[method:BufferGeometry clone]()

+

[method:BufferGeometry rotateY] ( [page:Float radians] )

- Creates a clone of this BufferGeometry. + Rotate the geometry about the Y axis. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.rotation] for typical real-time mesh rotation.
-

[method:BufferGeometry copy]( [page:BufferGeometry bufferGeometry] )

+

[method:BufferGeometry rotateZ] ( [page:Float radians] )

+
+ Rotate the geometry about the Z axis. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.rotation] for typical real-time mesh rotation. +
+ +

[method:BufferGeometry scale] ( [page:Float x], [page:Float y], [page:Float z] )

- Copies another BufferGeometry to this BufferGeometry. + Scale the geometry data. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.scale] for typical real-time mesh scaling.
+

[method:null setIndex] ( [page:BufferAttribute index] )

+
Set the [page:.index] buffer.
+ +

[method:null setDrawRange] ( [page:Integer start], [page:Integer count] )

+
Set the [page:.drawRange] buffer. See that property for details.
+ +

[method:BufferGeometry setFromObject] ( [page:Object3D object] )

+
Sets the attributes for this BufferGeometry from an [page:Object3D].
+ +

[method:Object toJSON]()

+
Returns a JSON object representation of the BufferGeometry.
+ +

[method:BufferGeometry toNonIndexed]()

+
Return a non-index version of an indexed BufferGeometry.
+ +

[method:BufferGeometry translate] ( [page:Float x], [page:Float y], [page:Float z] )

+
+ Translate the geometry. This is typically done as a one time operation, and not during a loop. + Use [page:Object3D.position] for typical real-time mesh translation. +
+ +

[method:BufferGeometry updateFromObject] ( [page:Object3D object] )

+
Updates the attributes for this BufferGeometry from an [page:Object3D].
+ + + + + + + + + + + + + + +

Source

diff --git a/docs/api/core/DirectGeometry.html b/docs/api/core/DirectGeometry.html index b56deeb94fe58d431b266b4beb84646f8457c38a..e6dcdb07048b759146e235721a9c8f762c49829d 100644 --- a/docs/api/core/DirectGeometry.html +++ b/docs/api/core/DirectGeometry.html @@ -10,7 +10,9 @@

[name]

-
This class is mainly used internally to convert from [page:Geometry] to [page:BufferGeometry].
+
+ This class is used internally to convert from [page:Geometry] to [page:BufferGeometry]. +
@@ -18,117 +20,79 @@

[name]()

-
- This creates a new [name]. -
+
This creates a new [name].

Properties

[property:Integer id]

-
- Unique number for this [name] instance. -
+
Unique number for this [name] instance.

[property:String name]

-
- Optional name. Default is the empty string. -
+
Optional name. Default is the empty string.

[property:Array type]

-
- String 'DirectGeometry'. -
+
String 'DirectGeometry'.

[property:Array indices]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array vertices]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array normals]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array colors]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array uvs]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array uvs2]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array groups]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array morphTargets]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array skinWeights]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().

[property:Array skinIndices]

-
- Default is empty array. -
+
Initialiased as an empty array, this is populated by [page:.fromGeometry]().
-

[property:Box boundingBox]

+

[property:Box3 boundingBox]

- Default is null. + Bounding box for the bufferGeometry, which can be calculated with + [page:.computeBoundingBox](). Default is *null*.
-

[property:Box boundingSphere]

+

[property:Sphere boundingSphere]

- Default is null. + Bounding sphere for the bufferGeometry, which can be calculated with + [page:.computeBoundingSphere](). Default is *null*.

[property:Boolean verticesNeedUpdate]

-
- Default is false. -
+
Default is false.

[property:Boolean normalsNeedUpdate]

-
- Default is false. -
+
Default is false.

[property:Boolean verticesNeedUpdate]

-
- Default is false. -
+
Default is false.

[property:Boolean colorsNeedUpdate]

-
- Default is false. -
+
Default is false.

[property:Boolean uvsNeedUpdate]

-
- Default is false. -
+
Default is false.

[property:Boolean groupsNeedUpdate]

-
- Default is false. -
+
Default is false.

Methods

@@ -145,17 +109,20 @@ See [page:Geometry.computeBoundingSphere]. -

[property:null computeGroups]( page:Geometry geometry] )

+

[property:null computeGroups]( [page:Geometry geometry] )

+ Compute the parts of the geometry that have different materialIndex. + See [page:BufferGeometry.groups].
-

[property:null fromGeometry]( page:Geometry geometry] )

+

[method:null dispose]()

+ Disposes the object from memory.
+ You need to call this when you want the directGeometry removed while the application is running.
-

[property:null dispose]( )

-
-
+

[property:null fromGeometry]( [page:Geometry geometry] )

+
Pass in a [page:Geometry] instance for conversion.

Source

diff --git a/docs/api/core/EventDispatcher.html b/docs/api/core/EventDispatcher.html index 1e94b42922a8175ce47929d96043fcd87d8e50af..98715728cf2269ce11a5fc5fdb0d853494ac7191 100644 --- a/docs/api/core/EventDispatcher.html +++ b/docs/api/core/EventDispatcher.html @@ -10,11 +10,44 @@

[name]

-
JavaScript events for custom objects.
- https://github.com/mrdoob/eventdispatcher.js
+
+ JavaScript events for custom objects.
+ [link:https://github.com/mrdoob/eventdispatcher.js Eventdispatcher on GitHub] +
-

Constructor

+

Example

+ + +// Adding events to a custom object + +var Car = function () { + + this.start = function () { + + this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } ); + + }; + +}; + +// Mixin the EventDispatcher.prototype with the custom object prototype +Object.assign( Car.prototype, EventDispatcher.prototype ); + +// Using events with the custom object + +var car = new Car(); + +car.addEventListener( 'start', function ( event ) { + + alert( event.message ); + +} ); + +car.start(); + + +

Constructor

[name]()

diff --git a/docs/api/core/Face3.html b/docs/api/core/Face3.html index 403bb4ca654b6978ded3a6c03a1f11b2a38aaa33..f2f2ef0e1a2a3e72c61345c9f4c36083f9242770 100644 --- a/docs/api/core/Face3.html +++ b/docs/api/core/Face3.html @@ -11,15 +11,44 @@

[name]

- Triangle face. + Triangular face used in [page:Geometry]. These are created automatically for all + standard geometry types, however if you are building a custom geometry you will have to + create them manually.
-

Example

+

Examples

- var normal = new THREE.Vector3( 0, 1, 0 ); - var color = new THREE.Color( 0xffaa00 ); - var face = new THREE.Face3( 0, 1, 2, normal, color, 0 ); +
[example:misc_ubiquity_test ubiquity / test ]
+
[example:svg_sandbox svg / sandbox ]
+
[example:webgl_exporter_obj WebGL / exporter / obj ]
+
[example:webgl_shaders_vector WebGL / shaders / vector ]
+ + + +var material = new THREE.MeshStandardMaterial( { color : 0x00cc00 } ); + +//create a triangular geometry +var geometry = new THREE.Geometry(); +geometry.vertices.push( new THREE.Vector3( -50, -50, 0 ) ); +geometry.vertices.push( new THREE.Vector3( 50, -50, 0 ) ); +geometry.vertices.push( new THREE.Vector3( 50, 50, 0 ) ); + +//create a new face using vertices 0, 1, 2 +var normal = new THREE.Vector3( 0, 1, 0 ); //optional +var color = new THREE.Color( 0xffaa00 ); //optional +var materialIndex = 0; //optional +var face = new THREE.Face3( 0, 1, 2, normal, color, materialIndex ); + +//add the face to the geometry's faces array +geometry.faces.push( face ); + +//the face normals and vertex normals can be calculated automatically if not supplied above +geometry.computeFaceNormals(); +geometry.computeVertexNormals(); + +scene.add( new THREE.Mesh( geometry, material ) ); +

Constructor

@@ -28,10 +57,18 @@
a — Vertex A index.
b — Vertex B index.
- c — Vertex C index.
- normal — Face normal or array of vertex normals.
- color — Face color or array of vertex colors.
- materialIndex — Material index. + c — Vertex C index.

+ + normal — (optional) Face normal ([page:Vector3 Vector3]) or array of vertex normals. + If a single vector is passed in, this sets [page:.normal], otherwise if an array of three + vectors is passed in this sets [page:.vertexNormals]

+ + color — (optional) Face [page:Color color] or array of vertex [page:Color colors]. + If a single vector is passed in, this sets [page:.color], otherwise if an array of three + vectors is passed in this sets [page:.vertexColors]

+ + materialIndex — (optional) which index of a [page:MultiMaterial] to associate + with the face.

Properties

@@ -53,36 +90,41 @@

[property:Vector3 normal]

- Face normal. + Face normal - vector showing the direction of the Face3. If calculated automatically + (using [page:Geometry.computeFaceNormals]), this is the normalized cross product of two edges of the + triangle. Default is *(0, 0, 0)*.

[property:Color color]

- Face color. + Face color - for this to be used a material's [page:Material.vertexColors vertexColors] property + must be set to [page:Materials THREE.FaceColors].

[property:Array vertexNormals]

- Array of 3 vertex normals. + Array of 3 [page:Vector3 vertex normals].

[property:Array vertexColors]

- Array of 3 vertex colors. + Array of 3 vertex colors - for these to be used a material's [page:Material.vertexColors vertexColors] property + must be set to [page:Materials THREE.VertexColors].

[property:Integer materialIndex]

- Material index (points to [page:MultiMaterial MultiMaterial.materials]). + Material index (points to [page:MultiMaterial MultiMaterial.materials]). Default is *0*.

Methods

[method:Face3 clone]()

-
- Creates a new clone of the Face3 object. -
+
Creates a new clone of the Face3 object.
+ +

[method:Face3 copy]( [page:Face3 face3] )

+
Copy the paramaters of another Face3 into this.

Source

diff --git a/docs/api/core/Geometry.html b/docs/api/core/Geometry.html index db2ccfe701021adeb93ed52de0729e1507a66656..cad5ab31dca8512f0f8557e6fb24e74107c1763b 100644 --- a/docs/api/core/Geometry.html +++ b/docs/api/core/Geometry.html @@ -11,13 +11,28 @@

[name]

- Base class for geometries.
- A geometry holds all data necessary to describe a 3D model. + Base class for all geometries (but not for [page:BufferGeometry BufferGeometries]).
+ This can also be used directly for building custom geometries.

+ + Geometries are easier to work with than [page:BufferGeometry BufferGeometries] as they store + attributes such as vertices, faces, colors and so on directly (rather than in [page:BufferAttribute buffers]), + however they are generally slower.

Example

+
[example:webgl_geometry_minecraft WebGL / geometry / minecraft ]
+
[example:webgl_geometry_minecraft_ao WebGL / geometry / minecraft / ao ]
+
[example:webgl_geometry_nurbs WebGL / geometry / nurbs ]
+
[example:webgl_geometry_spline_editor WebGL / geometry / spline / editor ]
+
[example:webgl_interactive_cubes_gpu WebGL / interactive / cubes / gpu ]
+
[example:webgl_interactive_lines WebGL / interactive / lines ]
+
[example:webgl_interactive_raycasting_points WebGL / interactive / raycasting / points ]
+
[example:webgl_interactive_voxelpainter WebGL / interactive / voxelpainter ]
+
[example:webgl_morphnormals WebGL / morphNormals ]
+ + var geometry = new THREE.Geometry(); geometry.vertices.push( @@ -42,48 +57,63 @@

Properties

-

[property:Integer id]

+

[property:Box3 boundingBox]

- Unique number for this geometry instance. + Bounding box for the Geometry, which can be calculated with + [page:.computeBoundingBox](). Default is *null*.
-

[property:String name]

+

[property:Sphere boundingSphere]

- Name for this geometry. Default is an empty string. -
- -

[property:Array vertices]

-
- Array of [page:Vector3 vertices].
- The array of vertices holds every position of points in the model.
- To signal an update in this array, [page:Geometry Geometry.verticesNeedUpdate] needs to be set to true. + Bounding sphere for the Geometry, which can be calculated with + [page:.computeBoundingSphere](). Default is *null*.

[property:Array colors]

- Array of vertex [page:Color colors], matching number and order of vertices.
- Used in [page:Points] and [page:Line].
- [page:Mesh Meshes] use per-face-use-of-vertex colors embedded directly in faces.
+ Array of vertex [page:Color colors], matching number and order of vertices.

+ + This is used by [page:Points] and [page:Line] and any classes derived from those such as [page:LineSegments] and various helpers. + [page:Mesh Meshes] use [page:Face3.vertexColors] instead of this.

+ To signal an update in this array, [page:Geometry Geometry.colorsNeedUpdate] needs to be set to true.

[property:Array faces]

- Array of [page:Face3 triangles].
- The array of faces describe how each vertex in the model is connected with each other.
+ Array of [page:Face3 faces].
+ The array of faces describe how each vertex in the model is connected to form faces. + Additionally it holds information about face and vertex normals and colors.

To signal an update in this array, [page:Geometry Geometry.elementsNeedUpdate] needs to be set to true.

[property:Array faceVertexUvs]

- Array of face [page:UV] layers.
- Each UV layer is an array of [page:UV]s matching the order and number of vertices in faces.
+ Array of face [link:https://en.wikipedia.org/wiki/UV_mapping UV] layers, used for mapping textures onto the geometry.
+ Each UV layer is an array of [page:UV]s matching the order and number of vertices in faces.

To signal an update in this array, [page:Geometry Geometry.uvsNeedUpdate] needs to be set to true.
+

[property:Integer id]

+
Unique number for this geometry instance.
+ +

[property:Boolean isGeometry]

+
+ Used to check whether this or derived classes are Geometries. Default is *true*.

+ + You should not change this, as it used internally for optimisation. +
+ +

[property:array lineDistances]

+
+ An array containing distances between vertices for Line geometries. + This is required for [page:LineSegments] / [page:LineDashedMaterial] to render correctly. + Line distances can be generated automatically with [page:.computeLineDistances]. +
+

[property:Array morphTargets]

- Array of morph targets. Each morph target is a Javascript object: + Array of [link:https://en.wikipedia.org/wiki/Morph_target_animation morph targets]. Each morph target is a Javascript object: { name: "targetName", vertices: [ new THREE.Vector3(), ... ] } Morph vertices match number and order of primary vertices.
@@ -92,8 +122,13 @@
Array of morph normals. Morph normals have similar structure as morph targets, each normal set is a Javascript object: morphNormal = { name: "NormalName", normals: [ new THREE.Vector3(), ... ] } + + See the [example:webgl_morphnormals WebGL / morphNormals] example.
+

[property:String name]

+
Optional name for this geometry. Default is an empty string.
+

[property:Array skinWeights]

When working with a [page:SkinnedMesh], each vertex can have up to 4 [page:Bone bones] affecting it. @@ -138,151 +173,118 @@
-

[property:Object boundingBox]

+

[property:String uuid]

- Bounding box. - { min: new THREE.Vector3(), max: new THREE.Vector3() } + [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. + This gets automatically assigned and shouldn't be edited.
-

[property:Object boundingSphere]

+

[property:Array vertices]

- Bounding sphere. - { radius: float } + Array of [page:Vector3 vertices].
+ The array of vertices holds the position of every vertex in the model.
+ To signal an update in this array, [page:.verticesNeedUpdate] needs to be set to true.

[property:Boolean verticesNeedUpdate]

-
- Set to *true* if the vertices array has been updated. -
+
Set to *true* if the vertices array has been updated.

[property:Boolean elementsNeedUpdate]

-
- Set to *true* if the faces array has been updated. -
+
Set to *true* if the faces array has been updated.

[property:Boolean uvsNeedUpdate]

-
- Set to *true* if the uvs array has been updated. -
+
Set to *true* if the uvs array has been updated.

[property:Boolean normalsNeedUpdate]

-
- Set to *true* if the normals array has been updated. -
+
Set to *true* if the normals array has been updated.

[property:Boolean colorsNeedUpdate]

-
- Set to *true* if the colors array or a face3 color has been updated. -
+
Set to *true* if the colors array or a face3 color has been updated.

[property:Boolean groupsNeedUpdate]

-
- Set to *true* if a face3 materialIndex has been updated. -
+
Set to *true* if a face3 materialIndex has been updated.

[property:Boolean lineDistancesNeedUpdate]

-
- Set to *true* if the linedistances array has been updated. -
+
Set to *true* if the linedistances array has been updated.
-

[property:array lineDistances]

-
- An array containing distances between vertices for Line geometries. - This is required for LinePieces/LineDashedMaterial to render correctly. - Line distances can also be generated with computeLineDistances. -

Methods

[page:EventDispatcher EventDispatcher] methods are available on this class.

[method:null applyMatrix]( [page:Matrix4 matrix] )

-
- Bakes matrix transform directly into vertex coordinates. -
+
Bakes matrix transform directly into vertex coordinates.

[method:null center] ()

-
- Center the geometry based on the bounding box. -
- -

[method:Geometry rotateX] ( [page:Float radians] )

-
- Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. -
+
Center the geometry based on the bounding box.
-

[method:Geometry rotateY] ( [page:Float radians] )

+

[method:Geometry clone]()

- Rotate the geometry about the Y axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. -
+ Creates a new clone of the Geometry.

-

[method:Geometry rotateZ] ( [page:Float radians] )

-
- Rotate the geometry about the Z axis. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.rotation] for typical real-time mesh rotation. + This method copies only vertices, faces and uvs. It does not copy any other properties of the geometry.
-

[method:Geometry translate] ( [page:Float x], [page:Float y], [page:Float z] )

-
- Translate the geometry. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.position] for typical real-time mesh translation. -
+

[method:null computeBoundingBox]()

+
Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute.
-

[method:Geometry scale] ( [page:Float x], [page:Float y], [page:Float z] )

-
- Scale the geometry data. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.scale] for typical real-time mesh scaling. -
+

[method:null computeBoundingSphere]()

+
Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute.
-

[method:Geometry lookAt] ( [page:Vector3 vector] )

- vector - A world vector to look at.
-
-
- Rotates the geometry to face point in space. This is typically done as a one time operation, and not during a loop - Use [page:Object3D.lookAt] for typical real-time mesh usage. + Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, + otherwise they are *null*.

[method:null computeFaceNormals]()

-
- Computes face normals. -
+
Computes [page:Face3.normal face normals].
+ +

[method:null computeFlatVertexNormals]()

+
Computes flat [page:Face3.vertexNormals vertex normals]. Sets the vertex normal of each vertex of each face to be the same as the face's normal.
+ +

[method:null computeLineDistances]()

+
Compute [page:.lineDistances].
+ +

[method:null computeMorphNormals]()

+
Computes [page:.morphNormals].

[method:null computeVertexNormals]( [page:Boolean areaWeighted] )

- areaWeighted - If true the contribution of each face normal to the vertex normal is weighted by the area of the face. Default is true. -
-
- Computes vertex normals by averaging face normals.
-
+ areaWeighted - If true the contribution of each face normal to the vertex normal is + weighted by the area of the face. Default is true.

-

[method:null computeFlatVertexNormals]()

-
- Computes flat vertex normals. Sets the vertex normal of each vertex of each face to be the same as the face's normal.
+ Computes vertex normals by averaging face normals.
-

[method:null computeMorphNormals]()

+

[method:Geometry copy]( [page:Geometry geometry] )

- Computes morph normals. + Copies vertices, faces and uvs into this geometry. It does not copy any other properties of the geometry.
-

[method:null computeBoundingBox]()

+

[method:null dispose]()

- Computes bounding box of the geometry, updating [page:Geometry Geometry.boundingBox] attribute. + Removes The object from memory.
+ Don't forget to call this method when you remove a geometry because it can cause memory leaks.
-

[method:null computeBoundingSphere]()

+

[method:Geometry fromBufferGeometry]( [page:BufferGeometry geometry] )

+
Convert a [page:BufferGeometry] to a Geometry.
+ +

[method:Geometry lookAt] ( [page:Vector3 vector] )

- Computes bounding sphere of the geometry, updating [page:Geometry Geometry.boundingSphere] attribute. -
+ vector - A world vector to look at.

-
Neither bounding boxes or bounding spheres are computed by default. They need to be explicitly computed, otherwise they are *null*.
+ Rotates the geometry to face point in space. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.lookAt] for typical real-time mesh usage. +

[method:null merge]( [page:Geometry geometry], [page:Matrix4 matrix], [page:Integer materialIndexOffset] )

Merge two geometries or geometry and geometry from object (using object's transform)
+

[method:null mergeMesh]( [page:Mesh mesh] )

+
Merge the mesh's geometry with this, also applying the mesh's transform.
+ +

[method:null mergeVertices]()

Checks for duplicate vertices using hashmap.
@@ -292,25 +294,46 @@

[method:null normalize]()

Normalize the geometry.
- Make the geometry centered and has a bounding sphere whose radius equals to 1.0. + Make the geometry centered and have a bounding sphere of radius *1.0*.
-

[method:Geometry clone]()

+

[method:Geometry rotateX] ( [page:Float radians] )

- Creates a new clone of the Geometry. + Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.rotation] for typical real-time mesh rotation.
- -
This method copies only vertices, faces and uvs. It does not copy any other properties of the geometry.
-

[method:null dispose]()

+

[method:Geometry rotateY] ( [page:Float radians] )

- Removes The object from memory.
- Don't forget to call this method when you remove a geometry because it can cause memory leaks. + Rotate the geometry about the Y axis. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.rotation] for typical real-time mesh rotation.
-

[method:null computeLineDistances]()

+

[method:Geometry rotateZ] ( [page:Float radians] )

- Compute distances between vertices for Line geometries. + Rotate the geometry about the Z axis. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.rotation] for typical real-time mesh rotation. +
+ +

[method:null sortFacesByMaterialIndex] ( )

+
+ Sorts the faces array according to material index. For complex geometries with several materials, + this can result in reduced draw call and improved performance. +
+ +

[method:Geometry scale] ( [page:Float x], [page:Float y], [page:Float z] )

+
+ Scale the geometry data. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.scale] for typical real-time mesh scaling. +
+ +

[method:JSON toJSON] ( )

+
Convert the geometry to JSON format.
+ +

[method:Geometry translate] ( [page:Float x], [page:Float y], [page:Float z] )

+
+ Translate the geometry. This is typically done as a one time operation, and not during a loop + Use [page:Object3D.position] for typical real-time mesh translation.
diff --git a/docs/api/core/InstancedBufferAttribute.html b/docs/api/core/InstancedBufferAttribute.html new file mode 100644 index 0000000000000000000000000000000000000000..e450178a345aba31093c48f960ad21bba0b41f95 --- /dev/null +++ b/docs/api/core/InstancedBufferAttribute.html @@ -0,0 +1,44 @@ + + + + + + + + + + + [page:BufferAttribute] → + +

[name]

+ +
+ An instanced version of [page:BufferAttribute]. +
+ +

Constructor

+

[name]( [page:TypedArray array], [page:Integer itemSize], [page:Number meshPerAttribute] )

+
+
+ +

Properties

+ See [page:BufferAttribute] for inherited properties. + +

[property:Number meshPerAttribute]

+
+ Default is *1*. +
+ +

[property:Boolean isInstancedBufferAttribute]

+
+ Default is *true*. +
+ +

Methods

+ See [page:BufferAttribute] for inherited methods. + +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/core/InstancedBufferGeometry.html b/docs/api/core/InstancedBufferGeometry.html new file mode 100644 index 0000000000000000000000000000000000000000..2d12d9ba322ccf4da91da38737cadbf399706930 --- /dev/null +++ b/docs/api/core/InstancedBufferGeometry.html @@ -0,0 +1,50 @@ + + + + + + + + + + + [page:BufferGeometry] → + +

[name]

+ +
+ An instanced version of [page:BufferGeometry]. +
+ +

Constructor

+

[name]( )

+
+
+ +

Properties

+ See [page:BufferGeometry] for inherited properties. + +

[property:Number maxInstancedCount]

+
+ Default is *undefined*. +
+ +

[property:Boolean isInstancedBufferGeometry]

+
+ Default is *true*. +
+ +

Methods

+ See [page:BufferAttribute] for inherited methods. + +

[property:Number addGroup]( start, count, materialIndex )

+
+ +
+ + +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/core/InstancedInterleavedBuffer.html b/docs/api/core/InstancedInterleavedBuffer.html new file mode 100644 index 0000000000000000000000000000000000000000..87b4b496f862fcd7ee810b85a0d071cf81e1077b --- /dev/null +++ b/docs/api/core/InstancedInterleavedBuffer.html @@ -0,0 +1,44 @@ + + + + + + + + + + + [page:InterleavedBuffer] → + +

[name]

+ +
+ An instanced version of [page:InterleavedBuffer]. +
+ +

Constructor

+

[name]( [page:TypedArray array], [page:Integer itemSize], [page:Number meshPerAttribute] )

+
+
+ +

Properties

+ See [page:InterleavedBuffer] for inherited properties. + +

[property:Number meshPerAttribute]

+
+ Default is *1*. +
+ +

[property:Boolean isInstancedInterleavedBuffer]

+
+ Default is *true*. +
+ +

Methods

+ See [page:InterleavedBuffer] for inherited methods. + +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/core/InterleavedBuffer.html b/docs/api/core/InterleavedBuffer.html new file mode 100644 index 0000000000000000000000000000000000000000..ad619a580aa2611795acda464d44894b1340197e --- /dev/null +++ b/docs/api/core/InterleavedBuffer.html @@ -0,0 +1,104 @@ + + + + + + + + + + +

[name]

+ +
+
+ +

Constructor

+

[name]( [page:TypedArray array], [page:Integer stride] )

+
+
+ +

Properties

+ +

[property:Array array]

+
+
+ +

[property:Integer stride]

+
+
+ +

[property:Integer count]

+
+ Gives the total number of elements in the array. +
+ +

[property:Boolean dynamic]

+
+ Default is *false*. +
+ +

[property:Object updateRange]

+
+ Object containing offset and count. +
+ +

[property:Number updateRange.offset]

+
+ DEfault is *0*. +
+ +

[property:Number updateRange.count]

+
+ Default is *-1*. +
+ +

[property:Integer version]

+
+ A version number, incremented every time the needsUpdate property is set to true. +
+ +

[property:Integer isInterleavedBuffer]

+
+ Default is *true*. +
+ +

[property:Integer needsUpdate]

+
+ Default is *false*. Setting this to true increments [page:InterleavedBuffer.version version]. +
+ +

Methods

+ +

[method:null setArray] ( [page:TypedArray array] )

+
+ array - must be a Typed Array. +
+ +

[method:InterleavedBuffer setDynamic] ( [page:Boolean value] )

+
+ Set [page:InterleavedBuffer.dynamic dynamic] to value. +
+ +

[method:InterleavedBuffer copy]( source )

+
+ Copy the array, count, stride and value of dynamic to this. +
+ +

[method:InterleavedBuffer copyAt]( index1, attribute, index2 )

+
+
+ +

[method:InterleavedBuffer set]( value, offset )

+
+
+ +

[method:InterleavedBuffer clone]( index, x, y )

+
+
+ +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/core/InterleavedBufferAttribute.html b/docs/api/core/InterleavedBufferAttribute.html new file mode 100644 index 0000000000000000000000000000000000000000..88f398b9966aac0b45302a7a3e80ae04b1b67917 --- /dev/null +++ b/docs/api/core/InterleavedBufferAttribute.html @@ -0,0 +1,116 @@ + + + + + + + + + + + +

[name]

+ +
+ +
+ +

Constructor

+

[name]( [page:InterleavedBuffer interleavedBuffer], [page:Integer itemSize], [page:Integer offset], [page:Boolean normalized] )

+
+
+ +

Properties

+ +

[property:InterleavedBuffer data]

+
+ The [page:InterleavedBuffer InterleavedBuffer] instance passed in the constructor. +
+ +

[property:Integer itemSize]

+
+
+ +

[property:Integer offset]

+
+
+ +

[property:Boolean normalized]

+
+ Default is *true*. +
+ +

[property:Boolean isInterleavedBufferAttribute]

+
+ Default is *true*. +
+ +

Methods

+ +

[method:Integer count]()

+
+ The value of [page:InterleavedBufferAttribute.data data].count. +
+ +

[method:Array array]()

+
+ The value of [page:InterleavedBufferAttribute.data data].array. +
+ +

[method:null getX]( index )

+
+ +
+ +

[method:null getY]( index )

+
+ +
+ +

[method:null getZ]( index )

+
+ +
+ +

[method:null getW]( index )

+
+ +
+ +

[method:null setX]( index, x )

+
+ +
+ +

[method:null setY]( index, y )

+
+ +
+ +

[method:null setZ]( index, z )

+
+ +
+ +

[method:null setXY]( index, x, y )

+
+ +
+ +

[method:null setXYZ]( index, x, y, z )

+
+ +
+ +

[method:null setXYZW]( index, x, y, z, w )

+
+ +
+ + + +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/core/Layers.html b/docs/api/core/Layers.html index 2cb2a9f4fa3528a459373aff831f695744bbd63a..9b73b9b6213dc4a4ae866c82d5cfb88ecd8efd8f 100644 --- a/docs/api/core/Layers.html +++ b/docs/api/core/Layers.html @@ -11,8 +11,15 @@

[name]

- An object providing a bit mask and accessor method used to control an [page:Object3D]'s visibility. - A [page:Layers] object assigns an [page:Object3D] to 0 or more of 32 layers numbered 0 to 31. + An object providing a [link:https://en.wikipedia.org/wiki/Mask_(computing) bit mask] and accessor methods + used to control an [page:Object3D]'s visibility. + A [page:Layers] object assigns an [page:Object3D] to 0 or more of 32 layers numbered 0 to 31.

+ + This is used to control visibility - an object must share a layer with a [page:Camera camera] + to be visible when that camera's view is renderered.

+ + All classes that inherit from [page:Object3D] have a [property:layers] property which is an instance + of this class.
@@ -34,44 +41,39 @@

Methods

-

[method:null set]( [page:Integer layer] )

-
- layer - an integer from 0 to 31. -
+

[method:null disable]( [page:Integer layer] )

- Set the layer mask to the value *layer*. + layer - an integer from 0 to 31.

+ + Remove *layer* from the mask.

[method:null enable]( [page:Integer layer] )

- layer - an integer from 0 to 31. -
-
+ layer - an integer from 0 to 31.

+ Add *layer* to the mask.
-

[method:null disable]( [page:Integer layer] )

-
- layer - an integer from 0 to 31. -
+

[method:null set]( [page:Integer layer] )

- Remove *layer* from the mask. -
+ layer - an integer from 0 to 31.

-

[method:null toggle]( [page:Integer layer] )

-
- layer - an integer from 0 to 31. -
-
- Toggle the *layer* value in the mask. + Set the layer mask to the value *layer*.

[method:Boolean test]( [page:Integer layers] )

- layers - a 32bit bit mask of layer numbers. + layers - a 32bit bit mask of layer numbers.

+ + Returns true if *layers* and [page:.mask] have any bits set in common.
+ +

[method:null toggle]( [page:Integer layer] )

- Returns true if *layers* and .mask have any bits set in common. + layer - an integer from 0 to 31.

+ + Toggle the *layer* value in the mask.

Source

diff --git a/docs/api/core/Object3D.html b/docs/api/core/Object3D.html index d6dd64bf1792e971c323482f6e6fe3f098afccb6..7ba4188b5100e7ef8653d1aaa2dc663e09f130aa 100644 --- a/docs/api/core/Object3D.html +++ b/docs/api/core/Object3D.html @@ -10,7 +10,13 @@

[name]

-
Base class for scene graph objects.
+
+ This is the base class for most objects in Three and provides a set of properties and methods + for manipulating objects in 3D space.

+ + Note that this can be used for grouping objects via the [page:.add]( object ) method + which adds the object as a child, however it is better to use [page:Group] for this. +

Constructor

@@ -24,361 +30,366 @@

Properties

-

[property:Integer id]

-
- readonly – Unique number for this object instance. -
+

[property:Boolean castShadow]

+
Whether the object gets rendered into shadow map. Default is *false*.
-

[property:String uuid]

-
- [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. - This gets automatically assigned, so this shouldn't be edited. -
+

[property:Object3D children]

+
Array with object's children. See [page:Group] for info on manually grouping objects.
-

[property:String name]

+

[property:Boolean frustumCulled]

- Optional name of the object (doesn't need to be unique). + When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object. + Otherwise the object gets renderered every frame even if it isn't visible. Default is *true*.
-

[property:Object3D parent]

-
- Object's parent in the scene graph. -
+

[property:Integer id]

+
readonly – Unique number for this object instance.
-

[property:Object3D children]

+

[property:Boolean isObject]

- Array with object's children. -
+ Used to check whether this or derived classes are Object3Ds. Default is *true*.

-

[property:Vector3 position]

-
- Object's local position. + You should not change this, as it used internally for optimisation.
-

[property:Euler rotation]

+

[property:Layers layers]

- Object's local rotation (Euler angles), in radians. + The layer membership of the object. The object is only visible if it has at least one + layer in common with the [page:Camera] in use.
-

[property:Vector3 scale]

-
- Object's local scale. -
+

[property:Matrix4 matrix]

+
The local transform matrix.
-

[property:Vector3 up]

+

[property:Boolean matrixAutoUpdate]

- Up direction. Default is THREE.Vector3( 0, 1, 0 ). + When this is set, it calculates the matrix of position, (rotation or quaternion) and + scale every frame and also recalculates the matrixWorld property. Default is *true*.
-

[property:Matrix4 matrix]

+

[property:Matrix4 matrixWorld]

- Local transform. + The global transform of the object. If the Object3d has no parent, then it's identical to + the local transform [page:.matrix].
-

[property:Quaternion quaternion]

+

[property:Boolean matrixWorldNeedsUpdate]

- Object's local rotation as [page:Quaternion Quaternion]. + When this is set, it calculates the matrixWorld in that frame and resets this property + to false. Default is *false*.
-

[property:Boolean visible]

-
- Object gets rendered if *true*. -
-
- default – true -
+

[property:Matrix4 modelViewMatrix]

+
This is passed to the shader and used to calculate the position of the object.
-

[property:Boolean castShadow]

+

[property:String name]

+
Optional name of the object (doesn't need to be unique). Default is an empty string.
+ +

[property:Matrix3 normalMatrix]

+
This is passed to the shader and used to calculate lighting for the object.
+ +

[property:function onAfterRender]

- Gets rendered into shadow map. + An optional callback that is executed immediately after the Object3D is rendered. + This function is called with the following parameters: renderer, scene, camera, geometry, + material, group.
+ +

[property:function onBeforeRender]

- default – false + An optional callback that is executed immediately before the Object3D is rendered. + This function is called with the following parameters: renderer, scene, camera, geometry, + material, group.
+

[property:Object3D parent]

+
Object's parent in the [link:https://en.wikipedia.org/wiki/Scene_graph scene graph].
+ +

[property:Vector3 position]

+
The object's local position.
+ +

[property:Quaternion quaternion]

+
Object's local rotation as a [page:Quaternion Quaternion].
+

[property:Boolean receiveShadow]

-
- Material gets baked in shadow receiving. -
-
- default – false -
+
Whether the material receives shadows. Default is *false*.
-

[property:Boolean frustumCulled]

-
- When this is set, it checks every frame if the object is in the frustum of the camera. Otherwise the object gets drawn every frame even if it isn't visible. -
+

[property:Number renderOrder]

- default – true + This value allows the default rendering order of [link:https://en.wikipedia.org/wiki/Scene_graph scene graph] + objects to be overridden although opaque and transparent objects remain sorted independently. + Sorting is from lowest to highest renderOrder. Default value is *0*.
-

[property:Boolean matrixAutoUpdate]

-
- When this is set, it calculates the matrix of position, (rotation or quaternion) and scale every frame and also recalculates the matrixWorld property. -
+

[property:Euler rotation]

- default – true + Object's local rotation (see [link:https://en.wikipedia.org/wiki/Euler_angles Euler angles]), in radians.
-

[property:Boolean matrixWorldNeedsUpdate]

-
- When this is set, it calculates the matrixWorld in that frame and resets this property to false. -
+

[property:Vector3 scale]

- default – false + The object's local [property:Vector3 scale]. Default is [page:Vector3]( 1, 1, 1 ).
+

[property:Vector3 up]

+
Up direction. Default is [page:Vector3]( 0, 1, 0 ).
+

[property:object userData]

- An object that can be used to store custom data about the Object3d. It should not hold references to functions as these will not be cloned. + An object that can be used to store custom data about the Object3d. It should not hold + references to functions as these will not be cloned.
-

[property:Matrix4 matrixWorld]

+

[property:String uuid]

- The global transform of the object. If the Object3d has no parent, then it's identical to the local transform. + [link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. + This gets automatically assigned, so this shouldn't be edited.
-

[property:function onBeforeRender]

-
- An optional callback that is executed immediately before the Object3D is rendered. This function is called with the following parameters: renderer, scene, camera, geometry, material, group. -
+

[property:Boolean visible]

+
Object gets rendered if *true*. Default is *true*.
+ + + -

[property:function onAfterRender]

-
- An optional callback that is executed immediately after the Object3D is rendered. This function is called with the following parameters: renderer, scene, camera, geometry, material, group. -
-

[property:Number renderOrder]

-
- This value allows the default rendering order of scene graph objects to be overridden although opaque and transparent objects remain sorted independently. Sorting is from lowest to highest renderOrder. Default value is 0. -
-

[property:Layers layers]

-
- The layer membership of the object. The object is only visible if it has at least one layer in common with the [page:Camera] in use. -

Methods

[page:EventDispatcher EventDispatcher] methods are available on this class.

-

[method:null applyMatrix]( [page:Matrix4 matrix] )

-
- matrix - matrix -
+

[method:null add]( [page:Object3D object], ... )

- This updates the position, rotation and scale with the matrix. -
+ Adds *object* as child of this object. An arbitrary number of objects may be added.

-

[method:null translateX]( [page:Float distance] )

-
- distance - Distance.
-
-
- Translates object along x axis by distance. + See [page:Group] for info on manually grouping objects.
-

[method:null translateY]( [page:Float distance] )

+

[method:null applyMatrix]( [page:Matrix4 matrix] )

+
This updates the position, rotation and scale with the matrix.
+ +

[method:Object3D clone]( [page:Boolean recursive] )

- distance - Distance.
+ recursive -- if true, descendants of the object are also cloned. Default is true.

+ + Returns a clone of this object and optionaly all descendants.
+ +

[method:Object3D copy]( [page:Object3D object], [page:Boolean recursive] )

- Translates object along y axis by distance. + recursive -- if true, descendants of the object are also copied. Default is true.

+ + Copy the given object into this object.
-

[method:null translateZ]( [page:Float distance] )

+

[method:Object3D getObjectById]( [page:Integer id] )

- distance - Distance.
+ id -- Unique number of the object instance

+ + Searches through the object's children and returns the first with a matching id.
+ Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
+ +

[method:Object3D getObjectByName]( [page:String name] )

- Translates object along z axis by distance. + name -- String to match to the children's Object3d.name property.

+ + Searches through the object's children and returns the first with a matching name.
+ Note that for most objects the [property:name] is an empty string by default. You will + have to set it manually to make use of this method.
-

[method:null rotateX]( [page:Float rad] )

+

[method:Object3D getObjectByProperty]( [page:String name], [page:Float value] )

- rad - the angle to rotate in radians.
+ name -- the property name to search for.
+ value -- value of the given property.

+ + Searches through the object's children and returns the first with a property that matches the aclue given.
+ +

[method:Vector3 getWorldPosition]( [page:Vector3 optionalTarget] )

- Rotates the object around x axis in local space. + optionalTarget — (optional) target to set the result. Otherwise, a new [page:Vector3] is instantiated.

+ + Returns a vector representing the position of the object in world space.
-

[method:null rotateY]( [page:Float rad] )

+

[method:Quaternion getWorldQuaternion]( [page:Quaternion optionalTarget] )

- rad - the angle to rotate in radians.
+ optionalTarget — (optional) target to set the result. Otherwise, a new [page:Quaternion] is + instantiated.

+ + Returns a quaternion representing the rotation of the object in world space.
+ +

[method:Euler getWorldRotation]( [page:Euler optionalTarget] )

- Rotates the object around y axis in local space. + optionalTarget — (optional) target to set the result. Otherwise, a new [page:Euler] is instantiated.

+ + Returns the euler angles representing the rotation of the object in world space.
-

[method:null rotateZ]( [page:Float rad] )

+

[method:Vector3 getWorldScale]( [page:Vector3 optionalTarget] )

- rad - the angle to rotate in radians.
+ optionalTarget — (optional) target to set the result. Otherwise, a new [page:Vector3] is instantiated.

+ + Returns a vector of the scaling factors applied to the object for each axis in world space.
+ +

[method:Vector3 getWorldDirection]( [page:Vector3 optionalTarget] )

- Rotates the object around z axis in local space. + optionalTarget — (optional) target to set the result. Otherwise, a new [page:Vector3] is instantiated.

+ + Returns a vector representing the direction of object's positive z-axis in world space.
+

[method:Vector3 localToWorld]( [page:Vector3 vector] )

- vector - A local vector.
-
-
- Updates the vector from local space to world space. -
+ vector - A vector representing a position in local (object) spave.

-

[method:Vector3 worldToLocal]( [page:Vector3 vector] )

-
- vector - A world vector.
-
-
- Updates the vector from world space to local space. + Converts the vector from local space to world space.

[method:null lookAt]( [page:Vector3 vector] )

- vector - A world vector to look at.
-
-
- Rotates object to face point in space. -
+ vector - A vector representing a position in world space.

-

[method:null add]( [page:Object3D object], ... )

-
- object - An object.
+ Rotates the object to face a point in world space.
+ +

[method:Array raycast]( [page:Raycaster raycaster], [page:Array intersects] )

- Adds *object* as child of this object. An arbitrary number of objects may be added. + Abstract (empty) method to get intersections between a casted ray and this object. + Subclasses such as [page:Mesh], [page:Line], and [page:Points] implement this method in order + to use raycasting.

[method:null remove]( [page:Object3D object], ... )

- object - An object.
-
-
Removes *object* as child of this object. An arbitrary number of objects may be removed.
-

[method:null traverse]( [page:Function callback] )

-
- callback - A function with as first argument an object3D object.
-
+

[method:Object3D rotateOnAxis]( [page:Vector3 axis], [page:Float angle] )

- Executes the callback on this object and all descendants. -
+ axis -- A normalized vector in object space.
+ angle -- The angle in radians.

-

[method:null traverseVisible]( [page:Function callback] )

-
- callback - A function with as first argument an object3D object.
-
-
- Like traverse, but the callback will only be executed for visible objects. - Descendants of invisible objects are not traversed. + Rotate an object along an axis in object space. The axis is assumed to be normalized.
-

[method:null traverseAncestors]( [page:Function callback] )

-
- callback - A function with as first argument an object3D object.
-
+

[method:null rotateX]( [page:Float rad] )

- Executes the callback on all ancestors. -
+ rad - the angle to rotate in radians.

-

[method:null updateMatrix]()

-
- Updates local transform. + Rotates the object around x axis in local space.
-

[method:null updateMatrixWorld]( [page:Boolean force] )

+

[method:null rotateY]( [page:Float rad] )

- Updates global transform of the object and its children. -
+ rad - the angle to rotate in radians.

-

[method:Object3D clone]( [page:Boolean recursive] )

-
- recursive -- if true, descendants of the object are also cloned. Default is true. -
-
- Returns a clone of this object and optionaly all descendants. + Rotates the object around y axis in local space.
- -

[method:Object3D getObjectByName]( [page:String name] )

-
- name -- String to match to the children's Object3d.name property.
-
+

[method:null rotateZ]( [page:Float rad] )

- Searches through the object's children and returns the first with a matching name. -
+ rad - the angle to rotate in radians.

-

[method:Object3D getObjectById]( [page:Integer id] )

-
- id -- Unique number of the object instance
-
-
- Searches through the object's children and returns the first with a matching id. + Rotates the object around z axis in local space.
-

[method:Vector3 getWorldPosition]( [page:Vector3 optionalTarget] )

-
- optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)
-
+

[method:null setRotationFromAxisAngle]( [page:Vector3 axis], [page:Float angle] )

- Returns a vector representing the position of the object in world space. -
+ axis -- A normalized vector in object space.
+ angle -- angle in radians

-

[method:Quaternion getWorldQuaternion]( [page:Quaternion optionalTarget] )

-
- optionalTarget — Optional target to set the result. Otherwise, a new `Quaternion` is instantiated. (optional)
-
-
- Returns a quaternion representing the rotation of the object in world space. + Calls [page:Quaternion.setFromAxisAngle setFromAxisAngle]( [page:Float axis], [page:Float angle] ) + on the [page:.quaternion].
-

[method:Euler getWorldRotation]( [page:Euler optionalTarget] )

-
- optionalTarget — Optional target to set the result. Otherwise, a new `Euler` is instantiated. (optional)
-
+

[method:null setRotationFromEuler]( [page:Euler euler] )

- Returns the euler angles representing the rotation of the object in world space. -
+ euler -- Euler angle specifying rotation amount.
-

[method:Vector3 getWorldScale]( [page:Vector3 optionalTarget] )

-
- optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)
+ Calls [page:Quaternion.setRotationFromEuler setRotationFromEuler]( [page:Euler euler]) + on the [page:.quaternion].
+ +

[method:null setRotationFromMatrix]( [page:Matrix4 m] )

- Returns a vector of the scaling factors applied to the object for each axis in world space. + m -- rotate the quaternion by the rotation component of the matrix.
+ + Calls [page:Quaternion.setFromRotationMatrix setFromRotationMatrix]( [page:Matrix4 m]) + on the [page:.quaternion].

+ + Note that this assumes that the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
-

[method:Vector3 getWorldDirection]( [page:Vector3 optionalTarget] )

+

[method:null setRotationFromQuaternion]( [page:Quaternion q] )

- optionalTarget — Optional target to set the result. Otherwise, a new `Vector3` is instantiated. (optional)
+ q -- normalized Quaternion.

+ + Copy the given quaternion into [page:.quaternion].
+ +

[method:null toJSON]( [page:Quaternion q] )

- Returns a vector representing the direction of object's positive z-axis in world space. + Convert the object to JSON format.

[method:Object3D translateOnAxis]( [page:Vector3 axis], [page:Float distance] )

axis -- A normalized vector in object space.
- distance -- The distance to translate. + distance -- The distance to translate.

+ + Translate an object by distance along an axis in object space. The axis is assumed to be normalized.
+ +

[method:null translateX]( [page:Float distance] )

+
Translates object along x axis by *distance* units.
+ +

[method:null translateY]( [page:Float distance] )

+
Translates object along y axis by *distance* units.
+ +

[method:null translateZ]( [page:Float distance] )

+
Translates object along z axis by *distance* units.
+ +

[method:null traverse]( [page:Function callback] )

- Translate an object by distance along an axis in object space. The axis is assumed to be normalized. + callback - A function with as first argument an object3D object.

+ + Executes the callback on this object and all descendants.
-

[method:Object3D rotateOnAxis]( [page:Vector3 axis], [page:Float angle] )

+

[method:null traverseVisible]( [page:Function callback] )

- axis -- A normalized vector in object space.
- angle -- The angle in radians. + callback - A function with as first argument an object3D object.

+ + Like traverse, but the callback will only be executed for visible objects. + Descendants of invisible objects are not traversed.
+ +

[method:null traverseAncestors]( [page:Function callback] )

- Rotate an object along an axis in object space. The axis is assumed to be normalized. + callback - A function with as first argument an object3D object.

+ + Executes the callback on all ancestors.
-

[method:Array raycast]( [page:Raycaster raycaster], [page:Array intersects] )

+

[method:null updateMatrix]()

+
Update the local transform.
+ +

[method:null updateMatrixWorld]( [page:Boolean force] )

+
Update the global transform of the object and its children.
+ + +

[method:Vector3 worldToLocal]( [page:Vector3 vector] )

- Abstract method to get intersections between a casted ray and this object. Subclasses such as [page:Mesh], [page:Line], and [page:Points] implement this method in order to participate in raycasting. + vector - A world vector.

+ + Updates the vector from world space to local space.

Source

diff --git a/docs/api/core/Raycaster.html b/docs/api/core/Raycaster.html index 798dea4f5823d5fd6e090b9401eb7edaca1fd3ff..76fddd81a79c99a2d3f4e28b6a92b9e46bf0e97c 100644 --- a/docs/api/core/Raycaster.html +++ b/docs/api/core/Raycaster.html @@ -11,7 +11,9 @@

[name]

- This class makes raycasting easier. Raycasting is used for picking and more. + This class is designed to assist with [link:https://en.wikipedia.org/wiki/Ray_casting raycasting]. + Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst + other things.

Example

@@ -25,14 +27,14 @@ // (-1 to +1) for both components mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1; - mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; - + mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1; + } function render() { - // update the picking ray with the camera and mouse position - raycaster.setFromCamera( mouse, camera ); + // update the picking ray with the camera and mouse position + raycaster.setFromCamera( mouse, camera ); // calculate objects intersecting the picking ray var intersects = raycaster.intersectObjects( scene.children ); @@ -40,9 +42,9 @@ for ( var i = 0; i < intersects.length; i++ ) { intersects[ i ].object.material.color.set( 0xff0000 ); - + } - + renderer.render( scene, camera ); } @@ -52,15 +54,17 @@ window.requestAnimationFrame(render); -
Examples: [example:webgl_interactive_cubes Raycasting to a Mesh], - [example:webgl_interactive_cubes_ortho Raycasting to a Mesh in using an OrthographicCamera], - [example:webgl_interactive_buffergeometry Raycasting to a Mesh with BufferGeometry], - [example:webgl_interactive_lines Raycasting to a Line], - [example:webgl_interactive_raycasting_points Raycasting to Points], - [example:webgl_geometry_terrain_raycast Terrain raycasting], - [example:webgl_octree_raycasting Raycasting using an octree], - [example:webgl_interactive_voxelpainter Raycasting to paint voxels], - [example:webgl_raycast_texture Raycast to a Texture]
+
+ Examples: [example:webgl_interactive_cubes Raycasting to a Mesh]
+ [example:webgl_interactive_cubes_ortho Raycasting to a Mesh in using an OrthographicCamera]
+ [example:webgl_interactive_buffergeometry Raycasting to a Mesh with BufferGeometry]
+ [example:webgl_interactive_lines Raycasting to a Line]
+ [example:webgl_interactive_raycasting_points Raycasting to Points]
+ [example:webgl_geometry_terrain_raycast Terrain raycasting]
+ [example:webgl_octree_raycasting Raycasting using an octree]
+ [example:webgl_interactive_voxelpainter Raycasting to paint voxels]
+ [example:webgl_raycast_texture Raycast to a Texture] +
@@ -83,28 +87,43 @@

Properties

-

[property:Ray ray]

+

[property:float far]

- The Ray used for the raycasting. + The far factor of the raycaster. This value indicates which objects can be discarded based on the distance.
+ This value shouldn't be negative and should be larger than the near property.
-

[property:float near]

+

[property:float linePrecision]

- The near factor of the raycaster. This value indicates which objects can be discarded based on the distance.
- This value shouldn't be negative and should be smaller than the far property. + The precision factor of the raycaster when intersecting [page:Line] objects.
-

[property:float far]

+

[property:float near]

- The far factor of the raycaster. This value indicates which objects can be discarded based on the distance.
- This value shouldn't be negative and should be larger than the near property. + The near factor of the raycaster. This value indicates which objects can be discarded based on the distance.
+ This value shouldn't be negative and should be smaller than the far property.
-

[property:float linePrecision]

+

[property:Object params]

- The precision factor of the raycaster when intersecting [page:Line] objects. + An object with the following properties: + + +{ + Mesh: {}, + Line: {}, + LOD: {}, + Points: { threshold: 1 }, + Sprite: {} +} + +
+

[property:Ray ray]

+
The [Page:Ray] used for the raycasting.
+ +

Methods

[method:null set]( [page:Vector3 origin], [page:Vector3 direction] )

@@ -148,13 +167,13 @@ [page:Vector2 uv] - U,V coordinates at point of intersection

- When intersecting a [page:Mesh] with a [page:BufferGeometry], the *faceIndex* will be *undefined*, and *indices* will be set; when intersecting a [page:Mesh] with a [page:Geometry], *indices* will be *undefined*. + When intersecting a [page:Mesh] with a [page:BufferGeometry], the *faceIndex* will be *undefined*, and *indices* will be set; when intersecting a [page:Mesh] with a [page:Geometry], *indices* will be *undefined*.

*Raycaster* delegates to the [page:Object3D.raycast raycast] method of the passed object, when evaluating whether the ray intersects the object or not. This allows [page:Mesh meshes] to respond differently to ray casting than [page:Line lines] and [page:Points pointclouds].

- *Note* that for meshes, faces must be pointed towards the origin of the [page:.ray ray] in order to be detected; intersections of the ray passing through the back of a face will not be detected. To raycast against both faces of an object, you'll want to set the [page:Mesh.material material]'s [page:Material.side side] property to *THREE.DoubleSide*. + *Note* that for meshes, faces must be pointed towards the origin of the [page:.ray ray] in order to be detected; intersections of the ray passing through the back of a face will not be detected. To raycast against both faces of an object, you'll want to set the [page:Mesh.material material]'s [page:Material.side side] property to *THREE.DoubleSide*.

diff --git a/docs/api/core/Uniform.html b/docs/api/core/Uniform.html index 55bdc29ffe7d2938be0169aa29e216370ef91a5f..5322b2eb2036b68d915ce9c17b8582edc2b010e5 100644 --- a/docs/api/core/Uniform.html +++ b/docs/api/core/Uniform.html @@ -27,7 +27,14 @@

Uniform types

- Each uniform must have a *value* property. The type of the value must correspond to the type of the uniform variable in the GLSL code as specified for the primitive GLSL types in the table below. Uniform structures and arrays are also supported. GLSL arrays of primitive type must either be specified as an array of the corresponding THREE objects or as a flat array containing the data of all the objects. In other words; GLSL primitives in arrays must not be represented by arrays. This rule does not apply transitively. An array of *vec2* arrays, each with a length of five vectors, must be an array of arrays, of either five *THREE.Vector2* objects or ten *number*s. + Each uniform must have a *value* property. The type of the value must correspond to the + type of the uniform variable in the GLSL code as specified for the primitive GLSL types + in the table below. Uniform structures and arrays are also supported. GLSL arrays of primitive + type must either be specified as an array of the corresponding THREE objects or as a flat + array containing the data of all the objects. In other words; GLSL primitives in arrays + must not be represented by arrays. This rule does not apply transitively. + An array of *vec2* arrays, each with a length of five vectors, must be an array of arrays, + of either five [page:Vector2] objects or ten *number*s.

@@ -189,6 +196,16 @@ Current value of the uniform. +

Methods

+ +

[method:Uniform clone]()

+
+ Returns a clone of this uniform.
+ If the uniform's value property is an [page:Object] with a clone() method, this is used, otherwise the value is copied by assigment. + Array values are shared between cloned [page:Uniform]s.

+ See [example:webgldeferred_animation WebGL deferred animation] for an example of this method in use. +
+

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/deprecated/DeprecatedList.html b/docs/api/deprecated/DeprecatedList.html index e1184211c176e7376c8ad1bc2b6601229d26ae05..e1c9d0f6a58a7edff31ba8f191d356ce6ae5377e 100644 --- a/docs/api/deprecated/DeprecatedList.html +++ b/docs/api/deprecated/DeprecatedList.html @@ -194,6 +194,9 @@

Helpers

+

[page:BoundingBoxHelper]

+
BoundingBoxHelper has been deprecated. Use [page:BoxHelper] instead.
+

[page:EdgesHelper]

EdgesHelper has been removed. Use [page:EdgesGeometry] instead.
@@ -300,7 +303,7 @@

[page:Matrix4]

Matrix4.flattenToArrayOffset is deprecated. Use [page:Matrix4.toArray]() instead.

- + Matrix4.extractPosition() has been renamed to [page:Matrix4.copyPosition]( matrix ).

Matrix4.getPosition() has been removed. Use [page:Vector3.setFromMatrixPosition]( matrix ) instead.

diff --git a/docs/api/extras/core/Curve.html b/docs/api/extras/core/Curve.html index 178fd7f582fdcf181d121e8053571bf657368c17..495eda41fb983ea36019afdfe84028b517b46475 100644 --- a/docs/api/extras/core/Curve.html +++ b/docs/api/extras/core/Curve.html @@ -30,35 +30,57 @@

Methods

-

[method:Vector getPoint]( t )

+

[method:Vector getPoint]( [page:Number t] )

Returns a vector for point t of the curve where t is between 0 and 1. Must be implemented in the extending class.
-

[method:Vector getPointAt]( u )

-
Returns a vector for point at relative position in curve according to arc length
+

[method:Vector getPointAt]( [page:Number u] )

+
+ Returns a vector for point at a relative position in curve according to arc length. + u is in the range [0, 1]. +
-

[method:Array getPoints]( divisions )

-
Get sequence of points using getPoint( t )
+

[method:Array getPoints]( [page:integer divisions] )

+
+ divisions -- number of pieces to divide the curve into. Default is *5*.

+ + Returns a set of divisions + 1 points using getPoint( t ). +

[method:Array getSpacedPoints]( divisions )

-
Get sequence of equi-spaced points using getPointAt( u )
+
+ divisions -- number of pieces to divide the curve into. Default is *5*.

+ + Returns a set of divisions + 1 equi-spaced points using getPointAt( u ). +

[method:Float getLength]()

-
Get total curve arc length
+
Get total curve arc length.

[method:Array getLengths]( divisions )

-
Get list of cumulative segment lengths
+
Get list of cumulative segment lengths.

[method:null updateArcLengths]()

-
Update the cumlative segment distance cache
+
Update the cumlative segment distance cache.
-

[method:Float getUtoTmapping]( u, distance )

-
Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equidistant
+

[method:Float getUtoTmapping]( [page:Number u], distance )

+
+ Given u in the range ( 0 .. 1 ), returns [page:Number t] also in the range ( 0 .. 1 ). + u and t can then be used to give you points which are equidistant from the ends of the curve, + using [page:.getPoint]. +
-

[method:Vector getTangent]( t )

-
Returns a unit vector tangent at t. If the subclassed curve do not implement its tangent derivation, 2 points a small delta apart will be used to find its gradient which seems to give a reasonable approximation
+

[method:Vector getTangent]( [page:Number t] )

+
+ Returns a unit vector tangent at t. If the subclassed curve do not implement its + tangent derivation, 2 points a small delta apart will be used to find its gradient + which seems to give a reasonable approximation +
-

[method:Vector getTangentAt]( u )

-
Returns tangent at equidistant point u on the curve
+

[method:Vector getTangentAt]( [page:Number u] )

+
+ Returns tangent at a point which is equidistant to the ends of the curve from the + point given in [page:.getTangent]. +

[method:Object computeFrenetFrames]( segments, closed )

diff --git a/docs/api/extras/core/CurvePath.html b/docs/api/extras/core/CurvePath.html index 75538c64dd2745517932651a8abf03235f0107de..216d5227f9bfaefabddc67de10b741388d665c1d 100644 --- a/docs/api/extras/core/CurvePath.html +++ b/docs/api/extras/core/CurvePath.html @@ -13,7 +13,7 @@

[name]

- An abstract base class further extending [page:Curve]. A CurvePath is simply an array of connected curves, + An abstract base class extending [page:Curve]. A CurvePath is simply an array of connected curves, but retains the api of a curve.
@@ -28,112 +28,53 @@

Properties

- +
See the base [page:Curve] class for common properties.

[property:array curves]

-
- The array of [page:Curve]s -
- -

[property:array bends]

-
- An array of [page:Curve]s used to transform and bend the curve using [page:CurvePath.getWrapPoints]. -
+
The array of [page:Curve Curves].

[property:boolean autoClose]

-
- Whether or not to automatically close the path. -
+
Whether or not to automatically close the path.
-

Methods

-

[method:Array getWrapPoints]( [page:Array vertices], [page:Curve curve] )

-
- vertices -- An array of [page:Vector2]s to modify
- curve -- An array of 2d [page:Curve]s -
-
- Modifies the array of vertices by warping it by the curve. The curve parameter also accepts objects with similar - interfaces such as [page:CurvePath], [page:Path], [page:SplineCurve], etc. Returns the original vertices after - modification. -
-

[method:null addWrapPath]( [page:Curve curve] )

-
- curve -- A [page:Curve] or object with a similar interface. -
-
- Pushes a curve onto the bends array. -
+ +

Methods

+
See the base [page:Curve] class for common methods.
+ +

[method:null add]( [page:Curve curve] )

+
Add a curve to the [page:.curves] array.
+ +

[method:null closePath]()

+
Adds a [page:LineCurve lineCurve] to close the path.

[method:Geometry createGeometry]( [page:Vector3 points] )

- points -- An array of [page:Vector3]s -
-
+ points -- An array of [page:Vector3 Vector3s]

+ Creates a geometry from points

[method:Geometry createPointsGeometry]( [page:Integer divisions] )

- divisions -- How many segments to create with [page:Vector3]s. Defaults to 12. -
-
- Creates a [page:Geometry] object comprised of [page:Vector3]s -
+ divisions -- How many segments to create. Defaults to *12*.

-

[method:Geometry createSpacedPointsGeometry]( [page:Integer divisions] )

-
- divisions -- How many segments to create with [page:Vector3]s. Defaults to 12. + Creates a [page:Geometry] object comprised of [page:Vector3 Vector3s], for example + to be used with [page:Line] or [page:Points]. Uses [page:Curve.getPoints]() for the division.
-
- Creates a [page:Geometry] object comprised of [page:Vector3]s that are equidistant. -
- -

[method:null add]( [page:Curve curve] )

-
- curve -- The [page:Curve curve] to add -
+

[method:Geometry createSpacedPointsGeometry]( [page:Integer divisions] )

- Pushes a curve onto the curves array. -
+ divisions -- How many segments to create. Defaults to *12*.

-

[method:null closePath]()

-
- Adds a curve to close the path. -
- -

[method:Object getBoundingBox]()

-
- Returns an object with the keys minX, minY, maxX, maxY, (if 3d: maxZ, minZ) + Creates a [page:Geometry] object comprised of [page:Vector3]s that are equidistant, for example + to be used with [page:Line] or [page:Points]. Uses [page:Curve.getSpacedPoints]() for the division.

[method:Float getCurveLengths]()

-
- Adds together the length of the curves -
+
Adds together the lengths of the curves in the [page:.curves] array.
-

[method:Array getTransformedPoints]( [page:Integer segments], [page:Array bends] )

-
- segments -- The number of segments to create using the getPoints()
- bends -- (optional) An array of [page:Curve]s used to transform the points. Defaults to this.bends if blank. -
-
- Uses this CurvePath to generate a series of points transformed by the curves in the bends array. Returns an - array of [page:Vector2]s. -
- -

[method:Array getTransformedSpacedPoints]( [page:Integer segments], [page:Array bends] )

-
- segments -- The number of segments to create using the getPoints()
- bends -- (optional) Defaults to this.bends if blank. An array of [page:Curve]s used to transform the points. -
-
- Uses this CurvePath to generate a series equidistant points that are then transformed by the curves in the bends. - Returns an array of [page:Vector2]s. -

Source

diff --git a/docs/api/extras/core/Font.html b/docs/api/extras/core/Font.html index ef217e1c767d429a43edbe69f0d230d8eaf147e5..5be52f1485069290cc3168f6973611dc623ae48d 100644 --- a/docs/api/extras/core/Font.html +++ b/docs/api/extras/core/Font.html @@ -11,9 +11,9 @@

[name]

- Create a set of [page:Shape Shape]s representing a font loaded in JSON format.

+ Create a set of [page:Shape Shapes] representing a font loaded in JSON format.

- Used internally by the [page:FontLoader]. + This is used internally by the [page:FontLoader].

Constructor

@@ -22,7 +22,30 @@
data -- JSON data representing the font.

- This constructor creates a new [name], which is an array of [page:Shape Shape]s. + This constructor creates a new [name], which is an array of [page:Shape Shapes]. +
+ +

Properties

+ +

[property:array data]

+
The JSON data passed in the constructor.
+ +

[property:Boolean isFont]

+
+ Used to check whether this or derived classes are fonts. Default is *true*.

+ + You should not change this, as it used internally by the renderer for optimisation. +
+ +

Methods

+ +

[method:null generateShapes]( [page:String text], [page:Float size], [page:Integer divisions] )

+
+ [page:String text] -- string of text.
+ [page:Float size] -- (optional) scale for the [page:Shape Shapes]. Default is *100*.
+ [page:Integer divisions] -- (optional) fineness of the [page:Shape Shapes]. Default is *5*.
+ + Creates an array of [page:Shape Shapes] representing the text in the font.

Source

diff --git a/docs/api/extras/core/Path.html b/docs/api/extras/core/Path.html index 4205bf359fe6cf3f9221804c0c330ef1f8e388f5..0a6dbe1440569b922133302387b2644ea7f055e1 100644 --- a/docs/api/extras/core/Path.html +++ b/docs/api/extras/core/Path.html @@ -13,111 +13,126 @@

[name]

- A 2d path representation, comprising of points, lines, and cubes, similar to the html5 2d canvas api. + A 2d path representation, comprising of points, lines, and cubes, similar to the 2D Canvas API. It extends [page:CurvePath].
+

Example

+ + +var v1 = new THREE.Vector3(); +var v2 = new THREE.Vector3(1, 45, 6); +var v3 = new THREE.Vector3(34, 34, 676); + +var vectors = [v1, v2, v3]; + +var path = new THREE.Path(vectors); + +

Constructor

[name]( [page:Array points] )

- points -- array of Vector2 -
-
- Creates a Path from the points. The first vector defines the offset. After that the lines get defined. + points -- (optional) array of [page:Vector2 Vector2s].

+ + Creates a Path from the points. The first point defines the offset, then successive points + are added to the [page:CurvePath.curves curves] array as [page:LineCurve LineCurves].

+ + If no points are specified, an empty path is created and the [page:.currentPoint] is set to + the origin.

Properties

+
See the base [page:CurvePath] class for common properties.
+

[property:array currentPoint]

+
The current offset of the path. Any new [page:Curve] added will start here.
-

[property:array actions]

-
- The possible actions that define the path. -

Methods

+
See the base [page:CurvePath] class for common methods.
-

[method:null fromPoints]( [page:Array vector2s] )

+

[method:null absarc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )

- Adds to the Path from the points. The first vector defines the offset. After that the lines get defined. + x, y -- The absolute center of the arc.
+ radius -- The radius of the arc.
+ startAngle -- The start angle in radians.
+ endAngle -- The end angle in radians.
+ clockwise -- Sweep the arc clockwise. Defaults to *false*.

+ + Adds an absolutely positioned [page:EllipseCurve EllipseCurve] to the path.
-

[method:null moveTo]( [page:Float x], [page:Float y] )

-
This moves the offset to x and y
+

[method:null absellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise], [page:Float rotation] )

+
+ x, y -- The absolute center of the ellipse.
+ xRadius -- The radius of the ellipse in the x axis.
+ yRadius -- The radius of the ellipse in the y axis.
+ startAngle -- The start angle in radians.
+ endAngle -- The end angle in radians.
+ clockwise -- Sweep the ellipse clockwise. Defaults to false.
+ rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0.

+ + Adds an absolutely positioned [page:EllipseCurve EllipseCurve] to the path. +
-

[method:null lineTo]( [page:Float x], [page:Float y] )

-
This creates a line from the offset to X and Y and updates the offset to X and Y.
+

[method:null arc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )

+
+ x, y -- The center of the arc offset from the last call.
+ radius -- The radius of the arc.
+ startAngle -- The start angle in radians.
+ endAngle -- The end angle in radians.
+ clockwise -- Sweep the arc clockwise. Defaults to *false*.

-

[method:null quadraticCurveTo]( [page:Float cpX], [page:Float cpY], [page:Float x], [page:Float y] )

-
This creates a quadratic curve from the offset to x and y with cpX and cpY as control point and updates the offset to x and y.
+ Adds an [page:EllipseCurve EllipseCurve] to the path, positioned relative to [page:.currentPoint]. +
-

[method:null bezierCurveTo]( [page:Float cp1X], [page:Float cp1Y], [page:Float cp2X], [page:Float cp2Y], [page:Float x], [page:Float y] )

-
This creates a bezier curve from the last offset to x and y with cp1X, cp1Y and cp1X, cp1Y as control points and updates the offset to x and y.
-

[method:null splineThru] ( [page:Array points] )

-
points - An array of [page:Vector2]s
-
Connects a new [page:SplineCurve] onto the path.
+

[method:null bezierCurveTo]( [page:Float cp1X], [page:Float cp1Y], [page:Float cp2X], [page:Float cp2Y], [page:Float x], [page:Float y] )

+
This creates a bezier curve from [page:.currentPoint] with cp1X, cp1Y and cp1X, cp1Y as control points and updates [page:.currentPoint] to x and y.
-

[method:null arc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )

+

[method:null fromPoints]( [page:Array vector2s] )

- x, y -- The center of the arc offset from the last call - radius -- The radius of the arc - startAngle -- The start angle in radians - endAngle -- The end angle in radians - clockwise -- Sweep the arc clockwise. Defaults to false -
-
Draw an arc offset from the last call
+ points -- array of [page:Vector2 Vector2s].

-

[method:null absarc]( [page:Float x], [page:Float y], [page:Float radius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise] )

-
- x, y -- The absolute center of the arc - radius -- The radius of the arc - startAngle -- The start angle in radians - endAngle -- The end angle in radians - clockwise -- Sweep the arc clockwise. Defaults to false + Adds to the from the points. Points are added to the [page:CurvePath.curves curves] + array as [page:LineCurve LineCurves].
-
Draw an arc absolutely positioned

[method:null ellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise], [page:Float rotation] )

- x, y -- The center of the ellipse offset from the last call - xRadius -- The radius of the ellipse in the x axis - yRadius -- The radius of the ellipse in the y axis - startAngle -- The start angle in radians - endAngle -- The end angle in radians - clockwise -- Sweep the ellipse clockwise. Defaults to false - rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0 + x, y -- The center of the ellipse offset from the last call.
+ xRadius -- The radius of the ellipse in the x axis.
+ yRadius -- The radius of the ellipse in the y axis.
+ startAngle -- The start angle in radians.
+ endAngle -- The end angle in radians.
+ clockwise -- Sweep the ellipse clockwise. Defaults to *false*.
+ rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to *0*.

+ + Adds an [page:EllipseCurve EllipseCurve] to the path, positioned relative to [page:.currentPoint].
-
Draw an ellipse offset from the last call
-

[method:null absellipse]( [page:Float x], [page:Float y], [page:Float xRadius], [page:Float yRadius], [page:Float startAngle], [page:Float endAngle], [page:Float clockwise], [page:Float rotation] )

-
- x, y -- The absolute center of the ellipse - xRadius -- The radius of the ellipse in the x axis - yRadius -- The radius of the ellipse in the y axis - startAngle -- The start angle in radians - endAngle -- The end angle in radians - clockwise -- Sweep the ellipse clockwise. Defaults to false - rotation -- The rotation angle of the ellipse in radians, counterclockwise from the positive X axis. Optional, defaults to 0 -
-
Draw an ellipse absolutely positioned
+

[method:null lineTo]( [page:Float x], [page:Float y] )

+
Connects a [page:LineCurve] from [page:.currentPoint] to x, y onto the path.
-

[method:Array toShapes]( [page:Boolean isCCW], [page:Boolean noHoles] )

-
- isCCW -- Changes how solids and holes are generated
- noHoles -- Whether or not to generate holes -
+ +

[method:null moveTo]( [page:Float x], [page:Float y] )

+
Move the [page:.currentPoint] to x, y.
+ + +

[method:null quadraticCurveTo]( [page:Float cpX], [page:Float cpY], [page:Float x], [page:Float y] )

+
Creates a quadratic curve from [page:.currentPoint] with cpX and cpY as control point and updates [page:.currentPoint] to x and y.
+ +

[method:null splineThru] ( [page:Array points] )

- Converts the Path into an array of Shapes. By default solid shapes are defined clockwise (CW) and holes are defined counterclockwise (CCW). If isCCW is set to true, - then those are flipped. If the paramater noHoles is set to true then all paths are set as solid shapes and isCCW is ignored. -
+ points - An array of [page:Vector2 Vector2s]

+ Connects a new [page:SplineCurve] onto the path.
-

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/extras/core/Shape.html b/docs/api/extras/core/Shape.html index 47602d78414e1426a8205fd5dbb9d8d8236f2109..f067ebe87b4b8f8f4a01fb3267fc4c52b3dfebf2 100644 --- a/docs/api/extras/core/Shape.html +++ b/docs/api/extras/core/Shape.html @@ -52,71 +52,37 @@

Properties

- +
See the base [page:Path] class for common properties.

[property:array holes]

-
- An array of [page:Path paths] that define the holes in the shape. -
+
An array of [page:Path paths] that define the holes in the shape.

Methods

- - -

[method:ShapeGeometry makeGeometry]( [page:Object options] )

-
- options -- This is passed as the second argument to [page:ShapeGeometry ShapeGeometry] -
-
- Convenience method to return ShapeGeometry -
+
See the base [page:Path] class for common methods.

[method:Array extractAllPoints]( [page:Integer divisions] )

- divisions -- The number of divisions to create on the shape -
-
- Get points of shape and holes (keypoints based on segments parameter) -
+ divisions -- The fineness of the result.

-

[method:ExtrudeGeometry extrude]( [page:Object options] )

-
- options -- This is passed as the second argument to [page:ExtrudeGeometry ExtrudeGeometry] -
-
- Convenience method to return ExtrudeGeometry + Call [page:Curve.getPoints getPoints] on the shape and the [page:.holes] array, and return an object of the form: + +{ + shape + holes +} + + where shape and holes are arrays of [page:Vector2 Vector2s].

[method:Object extractPoints]( [page:Integer divisions] )

-
- divisions -- The number of divisions to create on the shape -
-
- Returns an object with a *shape* and *holes* property that each reference an array of [page:Vector2 Vector2s]. -
+
This is identical to [page:.extractAllPoints].
-

[method:Object extractAllSpacedPoints]( [page:Integer divisions] )

-
- divisions -- The number of divisions to create on the shape -
-
- Returns an object with a *shape* and *holes* property that each reference an array of [page:Vector2 Vector2s]. The - points will all be equally spaced along the shape. -

[method:Array getPointsHoles]( [page:Integer divisions] )

- divisions -- The number of divisions to create on the shape -
-
- Get an array of [page Vector2 Vector2s] that represent the holes in the shape. -
+ divisions -- The fineness of the result.

-

[method:Array getSpacedPointsHoles]( [page:Integer divisions] )

-
- divisions -- The number of divisions to create on the shape -
-
- Get an array of equally spaced [page Vector2 Vector2s] that represent the holes in the shape. + Get an array of [page:Vector2 Vector2s] that represent the holes in the shape.

Source

diff --git a/docs/api/extras/curves/CatmullRomCurve3.html b/docs/api/extras/curves/CatmullRomCurve3.html index 930e09be0b5e542d09a99be8315782a03179648d..d09d7da9e3ea89a9b763b332207331f2dcbf8de9 100644 --- a/docs/api/extras/curves/CatmullRomCurve3.html +++ b/docs/api/extras/curves/CatmullRomCurve3.html @@ -12,7 +12,8 @@

[name]

-
Create a smooth 3d spline curve from a series of points using the Catmull-Rom algorithm
+
Create a smooth 3d spline curve from a series of points using the + [link:https://en.wikipedia.org/wiki/Centripetal_Catmull-Rom_spline Catmull-Rom] algorithm.

Example

@@ -30,6 +31,9 @@ var geometry = new THREE.Geometry(); geometry.vertices = curve.getPoints( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); + +// Create the final object to add to the scene +var curveObject = new THREE.Line( geometry, material );

[example:webgl_geometry_extrude_splines geometry / extrude / splines]

@@ -37,23 +41,30 @@ var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );

Constructor

-

[name]( [page:Array points] )

points – An array of [page:Vector3] points
+ + +

Properties

+
See the base [page:Curve] class for common properties.

[property:Array points]

- -

[property:Boolean closed] – curve loops back onto itself when true. False by default.

- -

[property:String type] - possible values are `centripetal` (default), `chordal` and `catmullrom`

- -

[property:float tension] - when type is `catmullrom`, defines catmullrom's tension. Defaults to 0.5

+
The array of array of [page:Vector3] points that define the curve.
-

Methods

+

[property:Boolean closed]

+
The curve will loop back onto itself when this is true. False by default
+ +

[property:String type]

+
Possible values are `centripetal` (default), `chordal` and `catmullrom`.
+ +

[property:float tension]

+
When [page:.type] is `catmullrom`, defines catmullrom's tension. Defaults is *0.5*.
-

See [page:Curve] for inherited methods

+ +

Methods

+
See the base [page:Curve] class for common methods.
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/extras/curves/ClosedSplineCurve3.html b/docs/api/extras/curves/ClosedSplineCurve3.html deleted file mode 100644 index d3944ea232aa4e499f4dd852536f215e4f103103..0000000000000000000000000000000000000000 --- a/docs/api/extras/curves/ClosedSplineCurve3.html +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - [page:Curve] → - -

[name]

- -
Create a smooth 3d spline curve from a series of points that loops back onto itself. THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3
- -

Example

- - -//Create a closed wavey loop -var curve = new THREE.ClosedSplineCurve3( [ - new THREE.Vector3( -10, 0, 10 ), - new THREE.Vector3( -5, 5, 5 ), - new THREE.Vector3( 0, 0, 0 ), - new THREE.Vector3( 5, -5, 5 ), - new THREE.Vector3( 10, 0, 10 ) -] ); - -var geometry = new THREE.Geometry(); -geometry.vertices = curve.getPoints( 50 ); - -var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); - - -

[example:webgl_geometry_extrude_splines geometry / extrude / splines] (choose SampleClosedSpline)

- - -

Constructor

- - -

[name]( [page:Array points] )

-
points – An array of [page:Vector3] points
- - -

Properties

- -

[property:Array points]

- -

Methods

- -

See [page:Curve] for inherited methods

- - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] - - diff --git a/docs/api/extras/curves/CubicBezierCurve.html b/docs/api/extras/curves/CubicBezierCurve.html index 3b556fd6d59ae649ec71f1d163210c667574d0d8..59e7dc854c2a2f99ec20f261cf4afff79b663a72 100644 --- a/docs/api/extras/curves/CubicBezierCurve.html +++ b/docs/api/extras/curves/CubicBezierCurve.html @@ -13,17 +13,19 @@

[name]

- Create a smooth 2d cubic bezier curve. + Create a smooth 2d + cubic bezier curve, + defined by a start point, endpoint and two control points.

Example

var curve = new THREE.CubicBezierCurve( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( -5, 15, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) + new THREE.Vector2( -10, 0, 0 ), + new THREE.Vector2( -5, 15, 0 ), + new THREE.Vector2( 20, 15, 0 ), + new THREE.Vector2( 10, 0, 0 ) ); var path = new THREE.Path( curve.getPoints( 50 ) ); @@ -31,7 +33,7 @@ var path = new THREE.Path( curve.getPoints( 50 ) ); var geometry = path.createPointsGeometry( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final Object3d to add to the scene +// Create the final object to add to the scene var curveObject = new THREE.Line( geometry, material ); @@ -40,26 +42,30 @@ var curveObject = new THREE.Line( geometry, material );

[name] ( [page:Vector2 v0], [page:Vector2 v1], [page:Vector2 v2], [page:Vector2 v3] )

- [page:Vector2 v0] – The starting point
- [page:Vector2 v1] – The first control point
- [page:Vector2 v2] – The second control point
- [page:Vector2 v3] – The ending point
+ [page:Vector2 v0] – The starting point.
+ [page:Vector2 v1] – The first control point.
+ [page:Vector2 v2] – The second control point.
+ [page:Vector2 v3] – The ending point.

Properties

+
See the base [page:Curve] class for common properties.

[property:Vector2 v0]

+
The starting point.

[property:Vector2 v1]

+
The first control point.

[property:Vector2 v2]

+
The second control point.

[property:Vector2 v3]

+
The ending point.

Methods

- -

See [page:Curve] for inherited methods

+
See the base [page:Curve] class for common Methods.

Source

diff --git a/docs/api/extras/curves/CubicBezierCurve3.html b/docs/api/extras/curves/CubicBezierCurve3.html index a8cd63ed603073d92ae19cde8e686bec4ec08c6b..37414cff23044255a9b97d81db5a170edf6ed896 100644 --- a/docs/api/extras/curves/CubicBezierCurve3.html +++ b/docs/api/extras/curves/CubicBezierCurve3.html @@ -13,7 +13,9 @@

[name]

- Create a smooth 3d cubic bezier curve. + Create a smooth 3d + cubic bezier curve, + defined by a start point, endpoint and two control points.

Example

@@ -31,7 +33,7 @@ geometry.vertices = curve.getPoints( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final Object3d to add to the scene +// Create the final object to add to the scene var curveObject = new THREE.Line( geometry, material ); @@ -41,26 +43,31 @@ var curveObject = new THREE.Line( geometry, material );

[name]( [page:Vector3 v0], [page:Vector3 v1], [page:Vector3 v2], [page:Vector3 v3] )

- [page:Vector3 v0] – The starting point
- [page:Vector3 v1] – The first control point
- [page:Vector3 v2] – The second control point
- [page:Vector3 v3] – The ending point
+ [page:Vector3 v0] – The starting point.
+ [page:Vector3 v1] – The first control point.
+ [page:Vector3 v2] – The second control point.
+ [page:Vector3 v3] – The ending point.

Properties

+
See the base [page:Curve] class for common properties.
-

[property:Vector3 v0]

+

[property:Vector2 v0]

+
The starting point.
-

[property:Vector3 v1]

+

[property:Vector2 v1]

+
The first control point.
-

[property:Vector3 v2]

+

[property:Vector2 v2]

+
The second control point.
-

[property:Vector3 v3]

+

[property:Vector2 v3]

+
The ending point.

Methods

+
See the base [page:Curve] class for common Methods.
-

See [page:Curve] for inherited methods

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/extras/curves/EllipseCurve.html b/docs/api/extras/curves/EllipseCurve.html index 09fa7464d07ee7af1a9c2b5956bfb0e5beb4d9e2..3d27c0a8d68532931f3763069ad96e5ccd62bd57 100644 --- a/docs/api/extras/curves/EllipseCurve.html +++ b/docs/api/extras/curves/EllipseCurve.html @@ -12,7 +12,10 @@

[name]

-
Creates a 2d curve in the shape of an ellipse.
+
+ Creates a 2d curve in the shape of an ellipse. Setting the + [page:Number xRadius] equal to the [page:Number yRadius] will result in a circle. +

Example

@@ -22,14 +25,14 @@ var curve = new THREE.EllipseCurve( 10, 10, // xRadius, yRadius 0, 2 * Math.PI, // aStartAngle, aEndAngle false, // aClockwise - 0 // aRotation + 0 // aRotation ); var path = new THREE.Path( curve.getPoints( 50 ) ); var geometry = path.createPointsGeometry( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final Object3d to add to the scene +// Create the final object to add to the scene var ellipse = new THREE.Line( geometry, material ); @@ -38,33 +41,54 @@ var ellipse = new THREE.Line( geometry, material );

[name]( [page:Float aX], [page:Float aY], [page:Float xRadius], [page:Float yRadius], [page:Radians aStartAngle], [page:Radians aEndAngle], [page:Boolean aClockwise], [page:Radians aRotation] )

- aX – The X center of the ellipse
- aY – The Y center of the ellipse
- xRadius – The radius of the ellipse in the x direction
- yRadius – The radius of the ellipse in the y direction
- aStartAngle – The start angle of the curve in radians starting from the middle right side
- aEndAngle – The end angle of the curve in radians starting from the middle right side
- aClockwise – Whether the ellipse is clockwise
- aRotation – The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional)

- - Note: When going clockwise it's best to set the start angle to (Math.PI * 2) and then work towards lower numbers. + [page:Float aX] – The X center of the ellipse.
+ [page:Float aY] – The Y center of the ellipse.
+ [page:Float xRadius] – The radius of the ellipse in the x direction.
+ [page:Float yRadius] – The radius of the ellipse in the y direction.
+ [page:Radians aStartAngle] – The start angle of the curve in radians starting from the middle right side.
+ [page:Radians aEndAngle] – The end angle of the curve in radians starting from the middle right side.
+ [page:Boolean aClockwise] – Whether the ellipse is drawn clockwise.
+ [page:Radians aRotation] – The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional). Default is *0*.

+ + Note: When going clockwise it's best to set the start angle to (Math.PI * 2) and then work towards lower numbers.
-

Properties

+
See the base [page:Curve] class for common properties.

[property:Float aX]

+
The X center of the ellipse.
+

[property:Float aY]

+
The Y center of the ellipse.
+

[property:Radians xRadius]

+
The radius of the ellipse in the x direction.
+

[property:Radians yRadius]

+
The radius of the ellipse in the y direction.
+

[property:Float aStartAngle]

+
The start angle of the curve in radians starting from the middle right side.
+

[property:Float aEndAngle]

+
The end angle of the curve in radians starting from the middle right side.
+

[property:Boolean aClockwise]

+
Whether the ellipse is drawn clockwise.
+

[property:Float aRotation]

+
The rotation angle of the ellipse in radians, counterclockwise from the positive X axis (optional). Default is *0*.
-

Methods

+

[property:Boolean isEllipseCurve]

+
+ Used to check whether this or derived classes are ellipses. Default is *true*.

-

See [page:Curve] for inherited methods

+ You should not change this, as it used internally for optimisation. +
+ +

Methods

+
See the base [page:Curve] class for common methods.

Source

diff --git a/docs/api/extras/curves/LineCurve.html b/docs/api/extras/curves/LineCurve.html index a913822c5b837aba18a3740dd751898a5a9845e4..c77806d049f81e35cfc13a2d1fe94d9379fd1fb6 100644 --- a/docs/api/extras/curves/LineCurve.html +++ b/docs/api/extras/curves/LineCurve.html @@ -12,27 +12,36 @@

[name]

-
A curve representing a 2d line segment
+
A curve representing a 2d line segment.

Constructor

[name]( [page:Vector2 v1], [page:Vector2 v2] )

- v1 – The start point
- v2 - The end point + [page:Vector2 v1] – The start point.
+ [page:Vector2 v2] - The end point.

Properties

+
See the base [page:Curve] class for common properties.
+ +

[property:Boolean isLineCurve]

+
+ Used to check whether this or derived classes are LineCurves. Default is *true*.

+ + You should not change this, as it used internally for optimisation. +

[property:Vector2 v1]

-

[property:Vector2 v2]

+
The start point.
+

[property:Vector2 v2]

+
The end point

Methods

- -

See [page:Curve] for inherited methods

+
See the base [page:Curve] class for common methods.

Source

diff --git a/docs/api/extras/curves/LineCurve3.html b/docs/api/extras/curves/LineCurve3.html index 061baee15cee84657b2c57674e67430a682e2006..e9c5b4bc045ddc9320011f52dab3de7e73ff3cd1 100644 --- a/docs/api/extras/curves/LineCurve3.html +++ b/docs/api/extras/curves/LineCurve3.html @@ -12,27 +12,29 @@

[name]

-
A curve representing a 3d line segment
+
A curve representing a 3d line segment.

Constructor

[name]( [page:Vector3 v1], [page:Vector3 v2] )

- v1 – The start point
- v2 - The end point + [page:Vector3 v1] – The start point.
+ [page:Vector3 v2] - The end point.

Properties

+
See the base [page:Curve] class for common properties.

[property:Vector3 v1]

-

[property:Vector3 v2]

+
The start point.
+

[property:Vector3 v2]

+
The end point.

Methods

- -

See [page:Curve] for inherited methods

+
See the base [page:Curve] class for common methods.

Source

diff --git a/docs/api/extras/curves/QuadraticBezierCurve.html b/docs/api/extras/curves/QuadraticBezierCurve.html index a93db6d2dfb581b5966645698ef3c64625e6fea4..3d60080ba00200639e5a30d73d5d43145f072254 100644 --- a/docs/api/extras/curves/QuadraticBezierCurve.html +++ b/docs/api/extras/curves/QuadraticBezierCurve.html @@ -13,16 +13,18 @@

[name]

- Create a smooth 2d quadratic bezier curve. + Create a smooth 2d + quadratic bezier curve, + defined by a startpoint, endpoint and a single control point.

Example

var curve = new THREE.QuadraticBezierCurve( - new THREE.Vector3( -10, 0, 0 ), - new THREE.Vector3( 20, 15, 0 ), - new THREE.Vector3( 10, 0, 0 ) + new THREE.Vector2( -10, 0 ), + new THREE.Vector2( 20, 15 ), + new THREE.Vector2( 10, 0 ) ); var path = new THREE.Path( curve.getPoints( 50 ) ); @@ -30,7 +32,7 @@ var path = new THREE.Path( curve.getPoints( 50 ) ); var geometry = path.createPointsGeometry( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -//Create the final Object3d to add to the scene +//Create the final object to add to the scene var curveObject = new THREE.Line( geometry, material ); @@ -39,26 +41,27 @@ var curveObject = new THREE.Line( geometry, material );

[name]( [page:Vector2 v0], [page:Vector2 v1], [page:Vector2 v2] )

- [page:Vector2 v0] – The starting point
- [page:Vector2 v1] – The middle control point
- [page:Vector2 v2] – The ending point
+ [page:Vector2 v0] – The startpoint.
+ [page:Vector2 v1] – The control point.
+ [page:Vector2 v2] – The endpoint.

Properties

+
See the base [page:Curve] class for common properties.

[property:Vector2 v0]

+
The startpoint.

[property:Vector2 v1]

+
The control point.

[property:Vector2 v2]

- +
The endpoint.

Methods

- - -

See [page:Curve] for inherited methods

+
See the base [page:Curve] class for common methods.

Source

diff --git a/docs/api/extras/curves/QuadraticBezierCurve3.html b/docs/api/extras/curves/QuadraticBezierCurve3.html index 90bfe81d843d12ac2253c69ecfb25f8aeb40c1ee..85ed095eb1918962d010b180e30f24ace5475a43 100644 --- a/docs/api/extras/curves/QuadraticBezierCurve3.html +++ b/docs/api/extras/curves/QuadraticBezierCurve3.html @@ -13,7 +13,9 @@

[name]

- Create a smooth 3d quadratic bezier curve. + Create a smooth 3d + quadratic bezier curve, + defined by a startpoint, endpoint and a single control point.

Example

@@ -30,7 +32,7 @@ geometry.vertices = curve.getPoints( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final Object3d to add to the scene +// Create the final object to add to the scene var curveObject = new THREE.Line( geometry, material ); @@ -47,18 +49,20 @@ var curveObject = new THREE.Line( geometry, material );

Properties

+
See the base [page:Curve] class for common properties.
+

[property:Vector3 v0]

+
The startpoint.

[property:Vector3 v1]

+
The control point.

[property:Vector3 v2]

- +
The endpoint.

Methods

- - -

See [page:Curve] for inherited methods

+
See the base [page:Curve] class for common methods.

Source

diff --git a/docs/api/extras/curves/SplineCurve.html b/docs/api/extras/curves/SplineCurve.html index aafde97d76d1f27991aac9cd699e994df1f5dc58..63371dd03c66249a0facaca3e247adb30a9cc582 100644 --- a/docs/api/extras/curves/SplineCurve.html +++ b/docs/api/extras/curves/SplineCurve.html @@ -12,7 +12,10 @@

[name]

-
Create a smooth 2d spline curve from a series of points
+
+ Create a smooth 2d spline curve from a series of points. Internally this uses + [page:CurveUtils.interpolate] to create the curve. +

Example

@@ -31,7 +34,7 @@ var path = new THREE.Path( curve.getPoints( 50 ) ); var geometry = path.createPointsGeometry( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -// Create the final Object3d to add to the scene +// Create the final object to add to the scene var splineObject = new THREE.Line( geometry, material ); @@ -39,16 +42,21 @@ var splineObject = new THREE.Line( geometry, material );

[name]( [page:Array points] )

-
points – An array of [page:Vector2] points
+
points – An array of [page:Vector2] points that define the curve.

Properties

+
See the base [page:Curve] class for common properties.

[property:Array points]

+
The array of [page:Vector3] points that define the curve.
+ +

Methods

+
See the base [page:Curve] class for common methods.
+ -

See [page:Curve] for inherited methods

Source

diff --git a/docs/api/extras/curves/SplineCurve3.html b/docs/api/extras/curves/SplineCurve3.html index 4bbb3a4dd474ad3cac23547f03870e82fb97c7cd..479da41f6f5861395ef4e46453c76b6c8d12cde4 100644 --- a/docs/api/extras/curves/SplineCurve3.html +++ b/docs/api/extras/curves/SplineCurve3.html @@ -12,11 +12,19 @@

[name]

-
Create a smooth 3d spline curve from a series of points
+
+ Create a smooth 3d spline curve from a series of points. Internally this uses + [page:CurveUtils.interpolate] to create the curve.

+ + Note that this will be deprecated. Please use a [page:CatmullRomCurve3] instead. + +

Example

- +
[example:webgl_geometry_extrude_splines geometry / extrude / splines ] (choose PipeSpline)
+ + //Create a closed bent a sine-like wave var curve = new THREE.SplineCurve3( [ new THREE.Vector3( -10, 0, 10 ), @@ -31,18 +39,18 @@ geometry.vertices = curve.getPoints( 50 ); var material = new THREE.LineBasicMaterial( { color : 0xff0000 } ); -//Create the final Object3d to add to the scene +//Create the final object to add to the scene var splineObject = new THREE.Line( geometry, material ); - +
+ -

[example:webgl_geometry_extrude_splines geometry / extrude / splines ] (choose PipeSpline)

Constructor

[name]( [page:Array points] )

-
points – An array of [page:Vector3] points
+
points – An array of [page:Vector3] points that define the curve.

Properties

diff --git a/docs/api/extras/helpers/ArrowHelper.html b/docs/api/extras/helpers/ArrowHelper.html index 93cb1220c9f7e87306f8af1003ccc4afc1817cf4..34cca76ba32d010ef93e2d1b8aa02ced980558ea 100644 --- a/docs/api/extras/helpers/ArrowHelper.html +++ b/docs/api/extras/helpers/ArrowHelper.html @@ -12,12 +12,21 @@

[name]

-
An 3D arrow Object.
+
An 3D arrow object for visualizing directions.

Example

- var dir = new THREE.Vector3( 1, 0, 0 ); +
[example:webgl_geometries WebGL / geometries]
+
[example:webgl_geometry_normals WebGL / geometry / normals]
+
[example:webgl_shadowmesh WebGL / shadowmesh]
+ + + var dir = new THREE.Vector3( 1, 2, 0 ); + + //normalize the direction vector (convert to vector of length 1) + dir.normalize(); + var origin = new THREE.Vector3( 0, 0, 0 ); var length = 1; var hex = 0xffff00; @@ -33,59 +42,52 @@

[name]([page:Vector3 dir], [page:Vector3 origin], [page:Number length], [page:Number hex], [page:Number headLength], [page:Number headWidth] )

- dir -- Vector3 -- direction from origin. Must be a unit vector.
- origin -- Vector3
- length -- scalar
- hex -- hexadecimal value to define color ex:0xffff00
- headLength -- The length of the head of the arrow
- headWidth -- The length of the width of the arrow + [page:Vector3 dir] -- direction from origin. Must be a unit vector.
+ [page:Vector3 origin] -- Point at which the arrow starts.
+ [page:Number length] -- length of the arrow. Default is *1*.
+ [page:Number hex] -- hexadecimal value to define color. Default is 0xffff00.
+ [page:Number headLength] -- The length of the head of the arrow. Default is 0.2 * length.
+ [page:Number headWidth] -- The length of the width of the arrow. Default is 0.2 * headLength.
-
- This creates an arrow starting in origin in the direction dir for a certain length. It is also possible to change color. -
-

Properties

- +
See the base [page:Object3D] class for common properties.

[property:Line line]

-
- Contains the line part of the arrowHelper. -
+
Contains the line part of the arrowHelper.

[property:Mesh cone]

-
- Contains the cone part of the arrowHelper. -
+
Contains the cone part of the arrowHelper.
+ + +

Methods

+
See the base [page:Object3D] class for common methods.

[method:null setColor]([page:Number hex])

- hex -- The hexadicmal value of the color -
-
+ hex -- The hexadicmal value of the color.

+ Sets the color of the arrowHelper.

[method:null setLength]([page:Number length], [page:Number headLength], [page:Number headWidth])

- length -- The desired length
- headLength -- The length of the head of the arrow
- headWidth -- The length of the width of the arrow -
-
+ length -- The desired length.
+ headLength -- The length of the head of the arrow.
+ headWidth -- The length of the width of the arrow.

+ Sets the length of the arrowhelper.

[method:null setDirection]([page:Vector3 dir])

- dir -- The desired direction. Must be a unit vector. -
-
+ dir -- The desired direction. Must be a unit vector.

+ Sets the direction of the arrowhelper.
diff --git a/docs/api/extras/helpers/AxisHelper.html b/docs/api/extras/helpers/AxisHelper.html index de68893e09c6b2d3c3bf29b97e27d82a75734d30..43c74f202bc186252f3bb41cd088534f5f720a1d 100644 --- a/docs/api/extras/helpers/AxisHelper.html +++ b/docs/api/extras/helpers/AxisHelper.html @@ -8,7 +8,7 @@ - [page:Line] → + [page:LineSegments] →

[name]

@@ -18,21 +18,32 @@

Example

- var axisHelper = new THREE.AxisHelper( 5 ); - scene.add( axisHelper ); - +
[example:webgl_geometries WebGL / geometries]
+
[example:webgl_geometries2 WebGL / geometries2]
+
[example:webgl_geometry_convex WebGL / geometry / convex]
+
[example:webgl_geometry_spline_editor WebGL / geometry / spline / editor]
+ + + + +var axisHelper = new THREE.AxisHelper( 5 ); +scene.add( axisHelper ); +

Constructor

-

[name]([page:Number size])

+

[name]( [page:Number size] )

- size -- Define the size of the line representing the axes. -
-
- Creates an axisHelper with lines of length size. + [page:Number size] -- (optional )size of the lines representing the axes. Default is *1*.
+

Properties

+
See the base [page:LineSegments] class for common properties.
+ +

Methods

+
See the base [page:LineSegments] class for common methods.
+

Source

[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] diff --git a/docs/api/extras/helpers/BoundingBoxHelper.html b/docs/api/extras/helpers/BoundingBoxHelper.html deleted file mode 100644 index 428063fae2aa73b93c8edb1e676dc2d75589f097..0000000000000000000000000000000000000000 --- a/docs/api/extras/helpers/BoundingBoxHelper.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - [page:Mesh] → - -

[name]

- -
A helper object to show the world-axis-aligned bounding box for an object.
- - -

Example

- - var hex = 0xff0000; - - var sphereMaterial = new THREE.MeshLambertMaterial( {color: 0x00ff00} ); - var sphere = new THREE.Mesh( new THREE.SphereGeometry( 30, 12, 12), sphereMaterial ); - scene.add( sphere ); - - var bbox = new THREE.BoundingBoxHelper( sphere, hex ); - bbox.update(); - scene.add( bbox ); - -
Note that this helper will create a wireframe [page:Mesh] object with a [page:BoxGeometry]; the resulting bounding box object will therefore have face diagonals. You may want to use [page:BoxHelper], which generates a [page:Line] object without face diagonals.
- - -

Constructor

- - -

[name]([page:Object3D object], [page:Number hex])

-
- object -- Object3D -- the object3D to show the world-axis-aligned boundingbox.
- hex -- hexadecimal value to define color ex:0x888888 -
-
- This creates an line object to the boundingbox. -
- - -

Properties

- - - -

[property:Object3D object]

-
- Contains the object3D to show the world-axis-aligned boundingbox. -
- -

[property:Box3 box]

-
- Contains the bounding box of the object. -
- -

Methods

- -

[method:null update]()

-
- Updates the BoundingBoxHelper based on the object property. -
- - -

Source

- - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] - - diff --git a/docs/api/extras/helpers/BoxHelper.html b/docs/api/extras/helpers/BoxHelper.html index 01b605a114ffcc748f3ad12c099b40378e4c87f0..29173c808d57322ba7d73e0e393d83d8f7ff9a57 100644 --- a/docs/api/extras/helpers/BoxHelper.html +++ b/docs/api/extras/helpers/BoxHelper.html @@ -8,39 +8,57 @@ - [page:Line] → + [page:LineSegments] →

[name]

-
Helper object to show a wireframe box (with no face diagonals) around an object
+
+ Helper object to show the world-axis-aligned bounding box around an object. + + Note that the object must have a [page:Geometry] or [page:BufferGeometry] for this to work, + so it won't work with [page:Sprite Sprites]. +

Example

- var sphere = new THREE.SphereGeometry(); +
[example:webgl_helpers WebGL / helpers]
+
[example:webgl_loader_nrrd WebGL / loader / nrrd]
+
[example:webgl_buffergeometry_drawcalls advanced / buffergeometry / drawcalls]
+ + + + var sphere = new THREE.SphereGeometry(); var object = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( 0xff0000 ) ); - var box = new THREE.BoxHelper( object ); + var box = new THREE.BoxHelper( object, 0xffff00 ); scene.add( box );

Constructor

+

[name]( [page:Object3D object], [page:Color color] )

- object -- Object3D -- the object3D to show the world-axis-aligned boundingbox.
- color -- The color of the helper. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0xffff00 + [page:Object3D object] -- the object3D to show the world-axis-aligned boundingbox.
+ [page:Color color] -- (optional) hexadecimal value that defines the box's color. Default is 0xffff00.

+ + Creates a new wireframe box that bounds the passed object. Internally this uses [page:Box3.setFromObject] + to calculate the dimensions. Note that this includes any children.
-
Creates a new wireframe box matching the size of the passed box.

Properties

+
See the base [page:LineSegments] class for common properties.
-
(none)

Methods

+
See the base [page:LineSegments] class for common methods.

[method:null update]( [page:Object3D object] )

-
Updates the helper's geometry to match the dimensions of the [page:Geometry.boundingBox bounding box] of the passed object's geometry.
+
+ Updates the helper's geometry to match the dimensions of the + of the passed object, including any children. See [page:Box3.setFromObject]. +

Source

diff --git a/docs/api/extras/helpers/CameraHelper.html b/docs/api/extras/helpers/CameraHelper.html index 3ed9ddd6be259e4aefe360e7004918d5e10c8442..02d4fc51175d767bbd3f1b78cac974583de6ba1c 100644 --- a/docs/api/extras/helpers/CameraHelper.html +++ b/docs/api/extras/helpers/CameraHelper.html @@ -8,48 +8,70 @@ - [page:Line] → + [page:LineSegments] →

[name]

- The camera Helper is an Object3D which helps visualizing what a camera contains in its frustum.
- It visualizes the frustum with an line Geometry. + This helps with visualizing what a camera contains in its frustum.
+ It visualizes the frustum of a camera using a [page:LineSegments].
+

Example

+ +
[example:webgl_camera WebGL / camera]
+
[example:webgl_geometry_extrude_splines WebGL / extrude / splines]
+ + +var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); + +var helper = new THREE.CameraHelper( cameraPerspective ); +scene.add( helper ); + +

Constructor

-

[name]([page:Camera camera])

-
- camera -- The camera to visualize. -
+

[name]( [page:Camera camera] )

+ [page:Camera camera] -- The camera to visualize.

+ This create a new [Name] for the specified camera.
+

Properties

+
See the base [page:LineSegments] class for common properties.
-

[property:object pointMap]

-
- This contains the points to viualize the cameraHelper -

[property:Camera camera]

+
The camera being visualized.
+ +

[property:object pointMap]

+
This contains the points used to visualize the camera.
+ +

[property:object matrix]

+
Reference to the [page:Object3D.matrixWorld camera.matrixWorld].
+ +

[property:object matrixAutoUpdate]

- The camera to visualize. + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + camera's [page:Object3D.matrixWorld matrixWorld].
+ + + +

Methods

+
See the base [page:LineSegments] class for common methods.

[method:null update]()

-
- Updates the helper based on the projectionMatrix of the camera. -
+
Updates the helper based on the projectionMatrix of the camera.

Source

diff --git a/docs/api/extras/helpers/DirectionalLightHelper.html b/docs/api/extras/helpers/DirectionalLightHelper.html index 77aeab7bc470c31d06e25e1f369bf1b8b552bf1e..bd8c2032adcc510f3f46cf9730e925afa1d6b317 100644 --- a/docs/api/extras/helpers/DirectionalLightHelper.html +++ b/docs/api/extras/helpers/DirectionalLightHelper.html @@ -12,47 +12,63 @@

[name]

-
Visualize a [page:DirectionalLight]'s effect on the scene
+
+ Helper object to assist with visualizing a [page:DirectionalLight]'s effect on the scene. + + This consists of plane and a line representing the light's position and direction. +
+ +

Example

+ + + var light = new THREE.DirectionalLight( 0xFFFFFF ); + + var helper = new THREE.DirectionalLightHelper( light, 5 ); + + scene.add( helper ); +

Constructor

-

[name]([page:DirectionalLight light], [page:Number size])

-
- light -- [page:DirectionalLight] -- Light to visualize
- size -- dimensions of the plane -
+

[name]( [page:DirectionalLight light], [page:Number size] )

- Creates a line and plane to visualize the light's position and direction + [page:DirectionalLight light]-- The light to be visualized.
+ [page:Number size] -- (optional) dimensions of the plane. Default is *1*.

Properties

+
See the base [page:Object3D] class for common properties.

[property:Line lightPlane]

-
- Contains the line mesh showing the location of the directional light. -
+
Contains the line mesh showing the location of the directional light.

[property:DirectionalLight light]

-
- Contains the directionalLight. -
+
Reference to the [page:DirectionalLight directionalLight] being visualized.
-

[property:Line targetLine]

+

[property:object matrix]

+
Reference to the light's [page:Object3D.matrixWorld matrixWorld].
+ +

[property:object matrixAutoUpdate]

- Contains the line mesh that shows the direction of the light. + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + light's [page:Object3D.matrixWorld matrixWorld].
+ +

Methods

+
See the base [page:Object3D] class for common properties.
+

[method:null dispose]()

+
Dispose of the directionalLightHelper.
-

.[method:null update]()

-
- Updates the helper to match the position and direction of the [page:.light]. -
+ +

[method:null update]()

+
Updates the helper to match the position and direction of the [page:.light directionalLight] being visualized.

Source

diff --git a/docs/api/extras/helpers/FaceNormalsHelper.html b/docs/api/extras/helpers/FaceNormalsHelper.html index 7678d878019028c859a0ac244fdb7c2067d96540..7e0dd8a07fc0ad9fe4daf2e1fc211c1bb9f80927 100644 --- a/docs/api/extras/helpers/FaceNormalsHelper.html +++ b/docs/api/extras/helpers/FaceNormalsHelper.html @@ -8,47 +8,65 @@ - [page:Line] → + [page:LineSegments] →

[name]

-
Renders [page:ArrowHelper arrows] to visualize an object's [page:Face3 face] normals. Requires that the object's geometry be an instance of [page:Geometry] (does not work with [page:BufferGeometry]), and that face normals have been specified on all [page:Face3 faces] or calculated with [page:Geometry.computeFaceNormals computeFaceNormals].
+
+ Renders [page:ArrowHelper arrows] to visualize an object's [page:Face3 face] normals. + Requires that face normals have been specified on all [page:Face3 faces] or calculated with [page:Geometry.computeFaceNormals computeFaceNormals].
+ + Note that this only works with the objects whose geometry is an instance of [page:Geometry]. + For [page:BufferGeometry] use a [page:VertexNormalsHelper] instead. +
+

Example

+
[example:webgl_helpers WebGL / helpers]
+ geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); - object = new THREE.Mesh( geometry, material ); + box = new THREE.Mesh( geometry, material ); - edges = new THREE.FaceNormalsHelper( object, 2, 0x00ff00, 1 ); + helper = new THREE.FaceNormalsHelper( box, 2, 0x00ff00, 1 ); scene.add( object ); - scene.add( edges ); + scene.add( helper ); - [example:webgl_helpers Example using various helpers]

Constructor

[name]( [page:Object3D object], [page:Number size], [page:Color color], [page:Number linewidth] )

- object -- object for which to render face normals
- size -- size (length) of the arrows
- color -- color of the arrows
- linewidth -- width of the arrow lines + [page:Object3D object] -- object for which to render face normals.
+ [page:Number size] -- (optional) length of the arrows. Default is *1*.
+ [page:Hex color] -- (optional) hex color of the arrows. Default is *0xffff00*.
+ [page:Number linewidth] -- (optional) width of the arrow lines. Default is *1*.

Properties

+
See the base [page:LineSegments] class for common properties.
-

[property:Object3D object]

+

[property:object matrixAutoUpdate]

- The attached object + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + objects's [page:Object3D.matrixWorld matrixWorld].
+

[property:Object3D object]

+
The object for which the face normals are being visualized.
+ +

[property:Number size]

+
Length of the arrows. Default is *1*.
+ +

Methods

+
See the base [page:LineSegments] class for common methods.

[method:null update]()

diff --git a/docs/api/extras/helpers/GridHelper.html b/docs/api/extras/helpers/GridHelper.html index 308f187f703644e84b2d450050c49ee314eae9fc..bdf21be62156e2085699fc6d7fe5e91a88a6069d 100644 --- a/docs/api/extras/helpers/GridHelper.html +++ b/docs/api/extras/helpers/GridHelper.html @@ -18,9 +18,9 @@

Example

var size = 10; - var step = 1; + var divisions = 10; - var gridHelper = new THREE.GridHelper( size, step ); + var gridHelper = new THREE.GridHelper( size, divisions ); scene.add( gridHelper ); [example:webgl_helpers Example using various helpers] @@ -28,15 +28,15 @@

Constructor

-

[name]( [page:number size], [page:Number step], [page:Color colorCenterLine], [page:Color colorGrid] )

+

[name]( [page:number size], [page:Number divisions], [page:Color colorCenterLine], [page:Color colorGrid] )

- size -- The size of the grid
- step -- The size of the step between 2 lines
+ size -- The size of the grid. Default is 10.
+ divisions -- The number of divisions across the grid. Default is 10.
colorCenterLine -- The color of the centerline. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x444444
colorGrid -- The color of the lines of the grid. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888
- Creates a new [name] of size 'size' and with steps of size 'step'. Colors are optional. + Creates a new [name] of size 'size' and divided into 'divisions' segments per side. Colors are optional.

Source

diff --git a/docs/api/extras/helpers/HemisphereLightHelper.html b/docs/api/extras/helpers/HemisphereLightHelper.html index 48ec86789624f7e4e491ed73e90ea74362a7c31e..356e668ef0d9bc2740acf4e17e84f5fadd2029eb 100644 --- a/docs/api/extras/helpers/HemisphereLightHelper.html +++ b/docs/api/extras/helpers/HemisphereLightHelper.html @@ -12,40 +12,57 @@

[name]

-
Creates a visual aid for a [page:HemisphereLight HemisphereLight].
+
+ Creates a visual aid consisting of a spherical [page:Mesh] for a [page:HemisphereLight HemisphereLight]. +
+ +

Example

+ + +var light = new THREE.HemisphereLight( 0xffffbb, 0x080820, 1 ); + +var helper = new THREE.HemisphereLightHelper( light, 5 ); + +scene.add( helper ); +

Constructor

[name]([page:HemisphereLight light], [page:Number sphereSize])

- light -- The HemisphereLight.
- sphereSize -- The size of the sphere that shows the location. -
-
- Creates an helper for the hemispherelight. + [page:HemisphereLight light] -- The light being visualized.
+ [page:Number sphereSize] -- The size of the sphere used to visualize te light.

Properties

+
See the base [page:Object3D] class for common properties.
+ +

[property:HemisphereLight light]

+
Reference to the HemisphereLight being visualized.

[property:Mesh lightSphere]

-
- The sphere mesh that shows the location of the hemispherelight. -
+
The sphere mesh that shows the location of the hemispherelight.
-

[property:HemisphereLight light]

+

[property:object matrix]

+
Reference to the hemisphereLight's [page:Object3D.matrixWorld matrixWorld].
+ +

[property:object matrixAutoUpdate]

- Contains the HemisphereLight. + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + hemisphereLight's [page:Object3D.matrixWorld matrixWorld].

Methods

+
See the base [page:Object3D] class for common methods.
+ +

[method:null dispose]()

+
Dispose of the hemisphereLightHelper.

[method:null update]()

-
- Updates the helper to match the position and direction of the [page:.light]. -
+
Updates the helper to match the position and direction of the [page:.light].

Source

diff --git a/docs/api/extras/helpers/PointLightHelper.html b/docs/api/extras/helpers/PointLightHelper.html index 23b933bd0b46ea80c88e8b1e710b8775715e1899..6d430275edfb7363c61adbc0ff3a802bebf4c3d6 100644 --- a/docs/api/extras/helpers/PointLightHelper.html +++ b/docs/api/extras/helpers/PointLightHelper.html @@ -12,12 +12,18 @@

[name]

-
This displays a helper object for a [page:PointLight]
+
+ This displays a helper object consisting of a spherical [page:Mesh] for visualizing + a [page:PointLight]. +

Example

- var pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); + [example:webgl_helpers WebGL / helpers] + + + var pointLight = new THREE.PointLight( 0xff0000, 1, 100 ); pointLight.position.set( 10, 10, 10 ); scene.add( pointLight ); @@ -25,32 +31,44 @@ var pointLightHelper = new THREE.PointLightHelper( pointLight, sphereSize ); scene.add( pointLightHelper ); - [example:webgl_helpers Example using various helpers] + +

Constructor

-

[name]([page:PointLight light], [page:Float sphereSize])

+

[name]( [page:PointLight light], [page:Float sphereSize] )

- light -- The [page:PointLight] to display.
- sphereSize -- The size of the sphere helper + [page:PointLight light] -- The light to be visualized.
+ [page:Float sphereSize] -- (optional) The size of the sphere helper. Default is *1*.

Properties

+
See the base [page:Mesh] class for common properties.

[property:PointLight light]

+
The [page:PointLight] that is being visualized.
+ +

[property:object matrix]

+
Reference to the pointLight's [page:Object3D.matrixWorld matrixWorld].
+ +

[property:object matrixAutoUpdate]

- The [page:PointLight] that is being represented. + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + pointLight's [page:Object3D.matrixWorld matrixWorld].

Methods

+
See the base [page:Mesh] class for common methods.
+ +

[method:null dispose]()

+
Dispose of the pointLightHelper.
+

[method:null update]()

-
- Updates the light helper. -
+
Updates the helper to match the position of the [page:.light].

Source

diff --git a/docs/api/extras/helpers/PolarGridHelper.html b/docs/api/extras/helpers/PolarGridHelper.html new file mode 100644 index 0000000000000000000000000000000000000000..71755e5370bccc66e4ee970899ac16cb7d0e5e70 --- /dev/null +++ b/docs/api/extras/helpers/PolarGridHelper.html @@ -0,0 +1,50 @@ + + + + + + + + + + + [page:Line] → + +

[name]

+ +
The PolarGridHelper is an object to define polar grids. Grids are two-dimensional arrays of lines.
+ + +

Example

+ + var radius = 10; + var radials = 16; + var circles = 8; + var divisions = 64; + + var helper = new THREE.PolarGridHelper( radius, radials, circles, divisions ); + scene.add( helper ); + + [example:webgl_helpers Example using various helpers] + + +

Constructor

+ +

[name]( [page:Number radius], [page:Number radials], [page:Number circles], [page:Number divisions], [page:Color color1], [page:Color color2] )

+
+ radius -- The radius of the polar grid. This can be any positive number. Default is 10.
+ radials -- The number of radial lines. This can be any positive integer. Default is 16.
+ circles -- The number of circles. This can be any positive integer. Default is 8.
+ divisions -- The number of line segments used for each circle. This can be any positive integer that is 3 or greater. Default is 64.
+ color1 -- The first color used for grid elements. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x444444
+ color2 -- The second color used for grid elements. This can be a [page:Color], a hexadecimal value and an CSS-Color name. Default is 0x888888 +
+
+ Creates a new [name] of radius 'radius' with 'radials' number of radials and 'circles' number of circles, where each circle is smoothed into 'divisions' number of line segments. Colors are optional. +
+ +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/extras/helpers/RectAreaLightHelper.html b/docs/api/extras/helpers/RectAreaLightHelper.html new file mode 100644 index 0000000000000000000000000000000000000000..2eb611aae1c7ee1166a0701a4126f043f66dcaf0 --- /dev/null +++ b/docs/api/extras/helpers/RectAreaLightHelper.html @@ -0,0 +1,73 @@ + + + + + + + + + + + [page:Object3D] → + +

[name]

+ +
+ Creates a visual aid for a [page:RectAreaLight]. +
+ +

Example

+ + +var light = new THREE.RectAreaLight( 0xffffbb, 1.0, 5, 5 ); + +var helper = new THREE.RectAreaLightHelper( light ); + +scene.add( helper ); + + + +

Constructor

+ +

[name]( [page:HemisphereLight light] )

+
[page:HemisphereLight light] -- The light being visualized.
+ + +

Properties

+
See the base [page:Object3D] class for common properties.
+ +

[property:HemisphereLight light]

+
Reference to the RectAreaLight being visualized.
+ +

[property:Mesh lightMat]

+
[page:MeshBasicMaterial] used to visualize the light. This be be rendered the same color as the [page:.light]
+ +

[property:Mesh lightMesh]

+
[page:Mesh] used to visualize the light. Used to show the front (light-emitting side) of the light.
+ +

[property:Mesh lightShape]

+
[page:ShapeGeometry] used to create the mesh's that visualize the light.
+ +

[property:Mesh lightWireMat]

+
[page:MeshBasicMaterial] used to visualize the light's outline. This be be rendered the same color as the [page:.light]
+ +

[property:Mesh lightWireMesh]

+
[page:Mesh] used to visualize the light's outline. Used to show the back (non light-emitting side) of the light.
+ + + +

Methods

+
See the base [page:Object3D] class for common methods.
+ +

[method:null dispose]()

+
Dispose of the rectAreaLightHelper.
+ +

[method:null update]()

+
Updates the helper to match the position and direction of the [page:.light].
+ + +

Source

+ + [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + + diff --git a/docs/api/extras/helpers/SkeletonHelper.html b/docs/api/extras/helpers/SkeletonHelper.html index f382034244ad5d33b41bdad84a7ae556730046d4..1e38cfe87fe53b5a29bde3122668d5570d8cbf86 100644 --- a/docs/api/extras/helpers/SkeletonHelper.html +++ b/docs/api/extras/helpers/SkeletonHelper.html @@ -46,7 +46,7 @@ scene.add( helper );

[property:Array bones]

- The list of bones that the helper renders as [page:Line Line]s. + The list of bones that the helper renders as [page:Line Lines].

[property:Object root]

diff --git a/docs/api/extras/helpers/SpotLightHelper.html b/docs/api/extras/helpers/SpotLightHelper.html index f427137d3f81c5afd4316016b87db5ef6178b406..f493e5aa2cd1f26172f2cce4bd7951637be4c539 100644 --- a/docs/api/extras/helpers/SpotLightHelper.html +++ b/docs/api/extras/helpers/SpotLightHelper.html @@ -12,7 +12,7 @@

[name]

-
This displays a cylinder helper object for a [page:SpotLight]
+
This displays a cone shaped helper object for a [page:SpotLight].

Example

@@ -36,27 +36,37 @@

[name]([page:SpotLight light])

-
- light -- The [page:SpotLight] to display -
+
light -- The [page:SpotLight] to be visualized.

Properties

+
See the base [page:Object3D] class for common properties.
+ +

[property:LineSegments cone]

+
[page:LineSegments] used to visualize the light.

[property:SpotLight light]

+
Reference to the [page:SpotLight] being visualized.
+ +

[property:object matrix]

+
Reference to the spotLight's [page:Object3D.matrixWorld matrixWorld].
+ +

[property:object matrixAutoUpdate]

- The [page:SpotLight] + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + spotLight's [page:Object3D.matrixWorld matrixWorld].

Methods

+
See the base [page:Object3D] class for common methods.
+

[method:null update]()

+
Disposes of the light helper.

[method:null update]()

-
- Updates the light helper. -
+
Updates the light helper.

Source

diff --git a/docs/api/extras/helpers/VertexNormalsHelper.html b/docs/api/extras/helpers/VertexNormalsHelper.html index 7ab097ef73999d0042605471b23a8df166a72b09..875a380087095cbefcb3f9f0f2cce3cc98b8f245 100644 --- a/docs/api/extras/helpers/VertexNormalsHelper.html +++ b/docs/api/extras/helpers/VertexNormalsHelper.html @@ -12,42 +12,60 @@

[name]

-
Renders [page:ArrowHelper arrows] to visualize an object's vertex normal vectors. Requires that normals have been specified in a [page:BufferAttribute custom attribute] or have been calculated using [page:Geometry.computeVertexNormals computeVertexNormals].
+
+ Renders [page:ArrowHelper arrows] to visualize an object's vertex normal vectors. + Requires that normals have been specified in a [page:BufferAttribute custom attribute] or + have been calculated using [page:Geometry.computeVertexNormals computeVertexNormals].

+ + Unline [page:FaceNormalsHelper], this works with [page:BufferGeometry]. +

Example

+ [example:webgl_helpers WebGL / helpers] + - geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); - material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); - object = new THREE.Mesh( geometry, material ); + var geometry = new THREE.BoxGeometry( 10, 10, 10, 2, 2, 2 ); + var material = new THREE.MeshBasicMaterial( { color: 0xff0000 } ); + var box = new THREE.Mesh( geometry, material ); - edges = new THREE.VertexNormalsHelper( object, 2, 0x00ff00, 1 ); + var helper = new THREE.VertexNormalsHelper( box, 2, 0x00ff00, 1 ); - scene.add( object ); - scene.add( edges ); + scene.add( box ); + scene.add( helper ); - [example:webgl_helpers Example using various helpers] +

Constructor

-

[name]( [page:Object3D object], [page:Number size], [page:Color color], [page:Number linewidth] )

-
object -- object for which to render vertex normals - size -- size (length) of the arrows - color -- color of the arrows - linewidth -- width of the arrow lines +

[name]( [page:Object3D object], [page:Number size], [page:Hex color], [page:Number linewidth] )

+
+ [page:Object3D object] -- object for which to render vertex normals.
+ [page:Number size] -- (optional) length of the arrows. Default is 1.
+ [page:Hex color] -- hex color of the arrows. Default is 0xff0000.
+ [page:Number linewidth] -- (optional) width of the arrow lines. Default is 1.

Properties

+
See the base [page:LineSegments] class for common properties.
-

[property:Object3D object]

+

[property:object matrixAutoUpdate]

- The attached object + See [page:Object3D.matrixAutoUpdate]. Set to *false* here as the helper is using the + objects's [page:Object3D.matrixWorld matrixWorld].
+

[property:Object3D object]

+
The object for which the vertex normals are being visualized.
+ +

[property:Number size]

+
Length of the arrows. Default is *1*.
+

Methods

+
See the base [page:LineSegments] class for common methods.

[method:null update]()

diff --git a/docs/examples/loaders/PDBLoader.html b/docs/examples/loaders/PDBLoader.html index 98b54e8b8deb74f0a5a0f58a18bab784439fb99f..4b19bf1bb0730a09219b668325471193c2afd62a 100644 --- a/docs/examples/loaders/PDBLoader.html +++ b/docs/examples/loaders/PDBLoader.html @@ -63,7 +63,7 @@

[method:null load]( [page:String url], [page:Function onLoad], [page:Function onProgress], [page:Function onError] )

[page:String url] — required. URL to the .pdb file
- [page:Function onLoad] — Will be called when load completes. The arguments will be an [page:Geometry geometryAtoms], [page:Geometry geometryBonds] and the [page:Object JSON] structure.
+ [page:Function onLoad] — Will be called when load completes. The arguments will be an [page:BufferGeometry geometryAtoms], [page:BufferGeometry geometryBonds] and the [page:Object JSON] structure.
[page:Function onProgress] — Will be called while load progresses. The argument will be the XmlHttpRequest instance, that contain .[page:Integer total] and .[page:Integer loaded] bytes.
[page:Function onError] — Will be called when load errors.
@@ -82,10 +82,10 @@

[method:null createModel]( [page:Object json], [page:Function callback] )

[page:Object json] — The (JSON) pdb structure to parse.
- [page:Function callback] — Will be called when parse completes, with three arguments: [page:Geometry geometryAtoms], [page:Geometry geometryBonds] and the original [page:Object json].
+ [page:Function callback] — Will be called when parse completes, with three arguments: [page:BufferGeometry geometryAtoms], [page:BufferGeometry geometryBonds] and the original [page:Object json].
- Parse a (JSON) pdb structure and return two [page:Geometry]: one for atoms, one for bonds.
+ Parse a (JSON) pdb structure and return two [page:BufferGeometry]: one for atoms, one for bonds.
diff --git a/docs/list.js b/docs/list.js index c62337a6316480c73bc170c80c46e0768fd250e3..292c2b801c066e1aa2fddd14fbfa197b66639af9 100644 --- a/docs/list.js +++ b/docs/list.js @@ -63,6 +63,11 @@ var list = { [ "EventDispatcher", "api/core/EventDispatcher" ], [ "Face3", "api/core/Face3" ], [ "Geometry", "api/core/Geometry" ], + [ "InstancedBufferAttribute", "api/core/InstancedBufferAttribute" ], + [ "InstancedBufferGeometry", "api/core/InstancedBufferGeometry" ], + [ "InstancedInterleavedBuffer", "api/core/InstancedInterleavedBuffer" ], + [ "InterleavedBuffer", "api/core/InterleavedBuffer" ], + [ "InterleavedBufferAttribute", "api/core/InterleavedBufferAttribute" ], [ "Layers", "api/core/Layers" ], [ "Object3D", "api/core/Object3D" ], [ "Raycaster", "api/core/Raycaster" ], @@ -95,7 +100,6 @@ var list = { "Extras / Curves": [ [ "ArcCurve", "api/extras/curves/ArcCurve" ], [ "CatmullRomCurve3", "api/extras/curves/CatmullRomCurve3" ], - [ "ClosedSplineCurve3", "api/extras/curves/ClosedSplineCurve3" ], [ "CubicBezierCurve", "api/extras/curves/CubicBezierCurve" ], [ "CubicBezierCurve3", "api/extras/curves/CubicBezierCurve3" ], [ "EllipseCurve", "api/extras/curves/EllipseCurve" ], @@ -110,14 +114,15 @@ var list = { "Extras / Helpers": [ [ "ArrowHelper", "api/extras/helpers/ArrowHelper" ], [ "AxisHelper", "api/extras/helpers/AxisHelper" ], - [ "BoundingBoxHelper", "api/extras/helpers/BoundingBoxHelper" ], [ "BoxHelper", "api/extras/helpers/BoxHelper" ], [ "CameraHelper", "api/extras/helpers/CameraHelper" ], [ "DirectionalLightHelper", "api/extras/helpers/DirectionalLightHelper" ], [ "FaceNormalsHelper", "api/extras/helpers/FaceNormalsHelper" ], [ "GridHelper", "api/extras/helpers/GridHelper" ], + [ "PolarGridHelper", "api/extras/helpers/PolarGridHelper"], [ "HemisphereLightHelper", "api/extras/helpers/HemisphereLightHelper" ], [ "PointLightHelper", "api/extras/helpers/PointLightHelper" ], + [ "RectAreaLightHelper", "api/extras/helpers/RectAreaLightHelper" ], [ "SkeletonHelper", "api/extras/helpers/SkeletonHelper" ], [ "SpotLightHelper", "api/extras/helpers/SpotLightHelper" ], [ "VertexNormalsHelper", "api/extras/helpers/VertexNormalsHelper" ] diff --git a/editor/examples/arkanoid.app.json b/editor/examples/arkanoid.app.json old mode 100755 new mode 100644 diff --git a/editor/examples/camera.app.json b/editor/examples/camera.app.json old mode 100755 new mode 100644 diff --git a/editor/examples/particles.app.json b/editor/examples/particles.app.json old mode 100755 new mode 100644 diff --git a/editor/examples/pong.app.json b/editor/examples/pong.app.json old mode 100755 new mode 100644 diff --git a/editor/js/Command.js b/editor/js/Command.js old mode 100755 new mode 100644 diff --git a/editor/js/Sidebar.History.js b/editor/js/Sidebar.History.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/AddObjectCommand.js b/editor/js/commands/AddObjectCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/AddScriptCommand.js b/editor/js/commands/AddScriptCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/MoveObjectCommand.js b/editor/js/commands/MoveObjectCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/MultiCmdsCommand.js b/editor/js/commands/MultiCmdsCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/RemoveObjectCommand.js b/editor/js/commands/RemoveObjectCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/RemoveScriptCommand.js b/editor/js/commands/RemoveScriptCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetColorCommand.js b/editor/js/commands/SetColorCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetGeometryCommand.js b/editor/js/commands/SetGeometryCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetGeometryValueCommand.js b/editor/js/commands/SetGeometryValueCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetMaterialColorCommand.js b/editor/js/commands/SetMaterialColorCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetMaterialCommand.js b/editor/js/commands/SetMaterialCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetMaterialMapCommand.js b/editor/js/commands/SetMaterialMapCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetMaterialValueCommand.js b/editor/js/commands/SetMaterialValueCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetPositionCommand.js b/editor/js/commands/SetPositionCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetRotationCommand.js b/editor/js/commands/SetRotationCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetScaleCommand.js b/editor/js/commands/SetScaleCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetSceneCommand.js b/editor/js/commands/SetSceneCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetScriptValueCommand.js b/editor/js/commands/SetScriptValueCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetUuidCommand.js b/editor/js/commands/SetUuidCommand.js old mode 100755 new mode 100644 diff --git a/editor/js/commands/SetValueCommand.js b/editor/js/commands/SetValueCommand.js old mode 100755 new mode 100644 diff --git a/examples/css3d_molecules.html b/examples/css3d_molecules.html index 846ae482d0fb873a92c8f600df53209f180fa477..98f23519b4d0905485807b792ef6cc2e013c39f7 100644 --- a/examples/css3d_molecules.html +++ b/examples/css3d_molecules.html @@ -349,10 +349,22 @@ var offset = geometry.center(); geometryBonds.translate( offset.x, offset.y, offset.z ); - for ( var i = 0; i < geometry.vertices.length; i ++ ) { + var positions = geometry.getAttribute( 'position' ); + var colors = geometry.getAttribute( 'color' ); + + var position = new THREE.Vector3(); + var color = new THREE.Color(); + + for ( var i = 0; i < positions.count; i ++ ) { + + position.x = positions.getX( i ); + position.y = positions.getY( i ); + position.z = positions.getZ( i ); + + color.r = colors.getX( i ); + color.g = colors.getY( i ); + color.b = colors.getZ( i ); - var position = geometry.vertices[ i ]; - var color = geometry.colors[ i ]; var element = geometry.elements[ i ]; if ( ! colorSpriteMap[ element ] ) { @@ -368,7 +380,7 @@ } - colorSprite = colorSpriteMap[ element ]; + var colorSprite = colorSpriteMap[ element ]; var atom = document.createElement( 'img' ); atom.src = colorSprite; @@ -386,10 +398,20 @@ } - for ( var i = 0; i < geometryBonds.vertices.length; i += 2 ) { + positions = geometryBonds.getAttribute( 'position' ); - var start = geometryBonds.vertices[ i ]; - var end = geometryBonds.vertices[ i + 1 ]; + var start = new THREE.Vector3(); + var end = new THREE.Vector3(); + + for ( var i = 0; i < positions.count; i += 2 ) { + + start.x = positions.getX( i ); + start.y = positions.getY( i ); + start.z = positions.getZ( i ); + + end.x = positions.getX( i + 1 ); + end.y = positions.getY( i + 1 ); + end.z = positions.getZ( i + 1 ); start.multiplyScalar( 75 ); end.multiplyScalar( 75 ); @@ -397,7 +419,6 @@ tmpVec1.subVectors( end, start ); var bondLength = tmpVec1.length() - 50; - // var bond = document.createElement( 'div' ); diff --git a/examples/files.js b/examples/files.js index cd520861a706c811b07ec1a30d402a1243f97374..991d6bd14dcdaf41ee5a4d932bde715c93ffe3fc 100644 --- a/examples/files.js +++ b/examples/files.js @@ -155,6 +155,7 @@ var files = { "webgl_materials_variations_phong", "webgl_materials_variations_standard", "webgl_materials_variations_physical", + "webgl_materials_variations_toon", "webgl_materials_video", "webgl_materials_wireframe", "webgl_math_spherical_distribution", diff --git a/examples/fonts/droid/droid_sans_bold.typeface.json b/examples/fonts/droid/droid_sans_bold.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/droid/droid_sans_mono_regular.typeface.json b/examples/fonts/droid/droid_sans_mono_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/droid/droid_sans_regular.typeface.json b/examples/fonts/droid/droid_sans_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/droid/droid_serif_bold.typeface.json b/examples/fonts/droid/droid_serif_bold.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/droid/droid_serif_regular.typeface.json b/examples/fonts/droid/droid_serif_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/gentilis_bold.typeface.json b/examples/fonts/gentilis_bold.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/gentilis_regular.typeface.json b/examples/fonts/gentilis_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/helvetiker_bold.typeface.json b/examples/fonts/helvetiker_bold.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/helvetiker_regular.typeface.json b/examples/fonts/helvetiker_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/optimer_bold.typeface.json b/examples/fonts/optimer_bold.typeface.json old mode 100755 new mode 100644 diff --git a/examples/fonts/optimer_regular.typeface.json b/examples/fonts/optimer_regular.typeface.json old mode 100755 new mode 100644 diff --git a/examples/index.html b/examples/index.html index 4eecae14659892c64481d5d837e9db433ffd10e2..1a7091cd90a69940f5666d443f65f9a8727860d4 100644 --- a/examples/index.html +++ b/examples/index.html @@ -244,7 +244,7 @@ diff --git a/examples/js/BlendCharacter.js b/examples/js/BlendCharacter.js index 28d3b073e4ebbabd01c5dbe0369082f4598eb1ba..db564949d2b0b87dac911c7a7b4c760dfbc7c845 100644 --- a/examples/js/BlendCharacter.js +++ b/examples/js/BlendCharacter.js @@ -39,7 +39,6 @@ THREE.BlendCharacter = function () { scope.material.skinning = true; scope.mixer = new THREE.AnimationMixer( scope ); - scope.mixer = scope.mixer; // Create the animations for ( var i = 0; i < scope.geometry.animations.length; ++ i ) { @@ -129,7 +128,7 @@ THREE.BlendCharacter = function () { return this.mixer.clipAction( animName ).getEffectiveWeight(); - } + }; this.pauseAll = function() { @@ -154,7 +153,7 @@ THREE.BlendCharacter = function () { this.visible = boolean; - } + }; }; diff --git a/examples/js/Encodings.js b/examples/js/Encodings.js index 21c43d20008f62bf770389e34e7293c382ceb245..86d1c985947e4b3d12cd05f214df82c6249736f3 100644 --- a/examples/js/Encodings.js +++ b/examples/js/Encodings.js @@ -5,7 +5,7 @@ THREE.Encodings = function() { if( THREE.toHalf === undefined ) throw new Error("THREE.Encodings is required for HDRCubeMapLoader when loading half data."); -} +}; THREE.Encodings.RGBEByteToRGBFloat = function( sourceArray, sourceOffset, destArray, destOffset ) { var e = sourceArray[sourceOffset+3]; @@ -14,7 +14,7 @@ THREE.Encodings.RGBEByteToRGBFloat = function( sourceArray, sourceOffset, destAr destArray[destOffset+0] = sourceArray[sourceOffset+0] * scale; destArray[destOffset+1] = sourceArray[sourceOffset+1] * scale; destArray[destOffset+2] = sourceArray[sourceOffset+2] * scale; -} +}; THREE.Encodings.RGBEByteToRGBHalf = function( sourceArray, sourceOffset, destArray, destOffset ) { var e = sourceArray[sourceOffset+3]; @@ -23,4 +23,4 @@ THREE.Encodings.RGBEByteToRGBHalf = function( sourceArray, sourceOffset, destArr destArray[destOffset+0] = THREE.toHalf( sourceArray[sourceOffset+0] * scale ); destArray[destOffset+1] = THREE.toHalf( sourceArray[sourceOffset+1] * scale ); destArray[destOffset+2] = THREE.toHalf( sourceArray[sourceOffset+2] * scale ); -} +}; diff --git a/examples/js/GPUComputationRenderer.js b/examples/js/GPUComputationRenderer.js index ed578e77bb0a33cbf11e38fc11f86272713b72d3..3c64d7c7c7bb0683d76ab0547621434f2cc2994e 100644 --- a/examples/js/GPUComputationRenderer.js +++ b/examples/js/GPUComputationRenderer.js @@ -258,7 +258,7 @@ function GPUComputationRenderer( sizeX, sizeY, renderer ) { materialShader.defines.resolution = 'vec2( ' + sizeX.toFixed( 1 ) + ', ' + sizeY.toFixed( 1 ) + " )"; - }; + } this.addResolutionDefine = addResolutionDefine; @@ -277,7 +277,7 @@ function GPUComputationRenderer( sizeX, sizeY, renderer ) { addResolutionDefine( material ); return material; - }; + } this.createShaderMaterial = createShaderMaterial; this.createRenderTarget = function( sizeXTexture, sizeYTexture, wrapS, wrapT, minFilter, magFilter ) { @@ -367,4 +367,4 @@ function GPUComputationRenderer( sizeX, sizeY, renderer ) { } -} \ No newline at end of file +} diff --git a/examples/js/GPUParticleSystem.js b/examples/js/GPUParticleSystem.js index c775f0e9f0a87a0d0fcea493a2ee692b373564c0..b88373fb46b4ba3cffede9ddc8c63cdc22f1a6c9 100644 --- a/examples/js/GPUParticleSystem.js +++ b/examples/js/GPUParticleSystem.js @@ -200,7 +200,7 @@ THREE.GPUParticleSystem = function(options) { self.random = function() { return ++i >= self.rand.length ? self.rand[i = 1] : self.rand[i]; - } + }; var textureLoader = new THREE.TextureLoader(); @@ -252,7 +252,7 @@ THREE.GPUParticleSystem = function(options) { } - } + }; this.spawnParticle = function(options) { @@ -265,7 +265,7 @@ THREE.GPUParticleSystem = function(options) { currentContainer.spawnParticle(options); - } + }; this.update = function(time) { for (var i = 0; i < self.PARTICLE_CONTAINERS; i++) { @@ -277,7 +277,7 @@ THREE.GPUParticleSystem = function(options) { this.init(); -} +}; THREE.GPUParticleSystem.prototype = Object.create(THREE.Object3D.prototype); THREE.GPUParticleSystem.prototype.constructor = THREE.GPUParticleSystem; @@ -299,14 +299,14 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { THREE.Object3D.apply(this, arguments); // construct a couple small arrays used for packing variables into floats etc - var UINT8_VIEW = new Uint8Array(4) - var FLOAT_VIEW = new Float32Array(UINT8_VIEW.buffer) + var UINT8_VIEW = new Uint8Array(4); + var FLOAT_VIEW = new Float32Array(UINT8_VIEW.buffer); function decodeFloat(x, y, z, w) { - UINT8_VIEW[0] = Math.floor(w) - UINT8_VIEW[1] = Math.floor(z) - UINT8_VIEW[2] = Math.floor(y) - UINT8_VIEW[3] = Math.floor(x) + UINT8_VIEW[0] = Math.floor(w); + UINT8_VIEW[1] = Math.floor(z); + UINT8_VIEW[2] = Math.floor(y); + UINT8_VIEW[3] = Math.floor(x); return FLOAT_VIEW[0] } @@ -329,7 +329,7 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { if (b > 0) b--; return [r, g, b]; - }; + } self.particles = []; self.deadParticles = []; @@ -366,7 +366,7 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { self.particleShaderGeo.addAttribute('particlePositionsStartTime', new THREE.BufferAttribute(self.particlePositionsStartTime, 4).setDynamic(true)); self.particleShaderGeo.addAttribute('particleVelColSizeLife', new THREE.BufferAttribute(self.particleVelColSizeLife, 4).setDynamic(true)); - self.posStart = self.particleShaderGeo.getAttribute('particlePositionsStartTime') + self.posStart = self.particleShaderGeo.getAttribute('particlePositionsStartTime'); self.velCol = self.particleShaderGeo.getAttribute('particleVelColSizeLife'); self.particleShaderMat = self.GPUParticleSystem.particleShaderMat; @@ -388,6 +388,7 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { lifetime = 0., size = 0., sizeRandomness = 0., + smoothPosition = false, i; var maxVel = 2; @@ -409,8 +410,8 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { turbulence = options.turbulence !== undefined ? options.turbulence : 1.0; lifetime = options.lifetime !== undefined ? options.lifetime : 5.0; size = options.size !== undefined ? options.size : 10; - sizeRandomness = options.sizeRandomness !== undefined ? options.sizeRandomness : 0.0, - smoothPosition = options.smoothPosition !== undefined ? options.smoothPosition : false; + sizeRandomness = options.sizeRandomness !== undefined ? options.sizeRandomness : 0.0; + smoothPosition = options.smoothPosition !== undefined ? options.smoothPosition : false; if (self.DPR !== undefined) size *= self.DPR; @@ -467,7 +468,7 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { self.particleUpdate = true; - } + }; this.update = function(time) { @@ -497,11 +498,11 @@ THREE.GPUParticleContainer = function(maxParticles, particleSystem) { self.offset = 0; self.count = 0; } - } + }; this.init(); -} +}; THREE.GPUParticleContainer.prototype = Object.create(THREE.Object3D.prototype); THREE.GPUParticleContainer.prototype.constructor = THREE.GPUParticleContainer; diff --git a/examples/js/MarchingCubes.js b/examples/js/MarchingCubes.js index 751674161c34ac921da28d1fd1bce758c9206abf..4b40518b5cab44dce1ac62c4844f74083fb125e1 100644 --- a/examples/js/MarchingCubes.js +++ b/examples/js/MarchingCubes.js @@ -412,7 +412,7 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors ) } - }; + } this.begin = function () { @@ -493,8 +493,8 @@ THREE.MarchingCubes = function ( resolution, material, enableUvs, enableColors ) for ( z = min_z; z < max_z; z ++ ) { - z_offset = this.size2 * z, - fz = z / this.size - ballz, + z_offset = this.size2 * z; + fz = z / this.size - ballz; fz2 = fz * fz; for ( y = min_y; y < max_y; y ++ ) { diff --git a/examples/js/Mirror.js b/examples/js/Mirror.js index 1616e109d48079d5c1c991acb04fcf9df610f0ae..b6435690f50bc63ceee1604ab38b98c3030f3e3c 100644 --- a/examples/js/Mirror.js +++ b/examples/js/Mirror.js @@ -119,7 +119,7 @@ THREE.Mirror = function ( renderer, camera, options ) { this.renderTarget2 = new THREE.WebGLRenderTarget( width, height, parameters ); var mirrorShader = THREE.ShaderLib[ "mirror" ]; - var mirrorUniforms = THREE.UniformsUtils.clone( mirrorShader.uniforms ); + var mirrorUniforms = Object.assign( {}, mirrorShader.uniforms ); this.material = new THREE.ShaderMaterial( { diff --git a/examples/js/Ocean.js b/examples/js/Ocean.js index cd2730e2dfeb8f49e2d3e2449e4790abbb3dfd1b..0fa2d6f4706cf80e721dd9aa9de1c01a9ad046ee 100644 --- a/examples/js/Ocean.js +++ b/examples/js/Ocean.js @@ -31,9 +31,9 @@ this.geometrySize = optionalParameter( options.GEOMETRY_SIZE, 2000 ); this.resolution = optionalParameter( options.RESOLUTION, 64 ); this.floatSize = optionalParameter( options.SIZE_OF_FLOAT, 4 ); - this.windX = optionalParameter( options.INITIAL_WIND[ 0 ], 10.0 ), - this.windY = optionalParameter( options.INITIAL_WIND[ 1 ], 10.0 ), - this.size = optionalParameter( options.INITIAL_SIZE, 250.0 ), + this.windX = optionalParameter( options.INITIAL_WIND[ 0 ], 10.0 ); + this.windY = optionalParameter( options.INITIAL_WIND[ 1 ], 10.0 ); + this.size = optionalParameter( options.INITIAL_SIZE, 250.0 ); this.choppiness = optionalParameter( options.INITIAL_CHOPPINESS, 1.5 ); // @@ -91,7 +91,7 @@ // 1 - Horizontal wave vertices used for FFT var oceanHorizontalShader = THREE.ShaderLib[ "ocean_subtransform" ]; - var oceanHorizontalUniforms = THREE.UniformsUtils.clone( oceanHorizontalShader.uniforms ); + var oceanHorizontalUniforms = Object.assign( {}, oceanHorizontalShader.uniforms ); this.materialOceanHorizontal = new THREE.ShaderMaterial( { uniforms: oceanHorizontalUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -104,7 +104,7 @@ // 2 - Vertical wave vertices used for FFT var oceanVerticalShader = THREE.ShaderLib[ "ocean_subtransform" ]; - var oceanVerticalUniforms = THREE.UniformsUtils.clone( oceanVerticalShader.uniforms ); + var oceanVerticalUniforms = Object.assign( {}, oceanVerticalShader.uniforms ); this.materialOceanVertical = new THREE.ShaderMaterial( { uniforms: oceanVerticalUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -117,7 +117,7 @@ // 3 - Initial spectrum used to generate height map var initialSpectrumShader = THREE.ShaderLib[ "ocean_initial_spectrum" ]; - var initialSpectrumUniforms = THREE.UniformsUtils.clone( initialSpectrumShader.uniforms ); + var initialSpectrumUniforms = Object.assign( {}, initialSpectrumShader.uniforms ); this.materialInitialSpectrum = new THREE.ShaderMaterial( { uniforms: initialSpectrumUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -129,7 +129,7 @@ // 4 - Phases used to animate heightmap var phaseShader = THREE.ShaderLib[ "ocean_phase" ]; - var phaseUniforms = THREE.UniformsUtils.clone( phaseShader.uniforms ); + var phaseUniforms = Object.assign( {}, phaseShader.uniforms ); this.materialPhase = new THREE.ShaderMaterial( { uniforms: phaseUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -140,7 +140,7 @@ // 5 - Shader used to update spectrum var spectrumShader = THREE.ShaderLib[ "ocean_spectrum" ]; - var spectrumUniforms = THREE.UniformsUtils.clone( spectrumShader.uniforms ); + var spectrumUniforms = Object.assign( {}, spectrumShader.uniforms ); this.materialSpectrum = new THREE.ShaderMaterial( { uniforms: spectrumUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -152,7 +152,7 @@ // 6 - Shader used to update spectrum normals var normalShader = THREE.ShaderLib[ "ocean_normals" ]; - var normalUniforms = THREE.UniformsUtils.clone( normalShader.uniforms ); + var normalUniforms = Object.assign( {}, normalShader.uniforms ); this.materialNormal = new THREE.ShaderMaterial( { uniforms: normalUniforms, vertexShader: fullscreeenVertexShader.vertexShader, @@ -164,7 +164,7 @@ // 7 - Shader used to update normals var oceanShader = THREE.ShaderLib[ "ocean_main" ]; - var oceanUniforms = THREE.UniformsUtils.clone( oceanShader.uniforms ); + var oceanUniforms = Object.assign( {}, oceanShader.uniforms ); this.materialOcean = new THREE.ShaderMaterial( { uniforms: oceanUniforms, vertexShader: oceanShader.vertexShader, diff --git a/examples/js/RollerCoaster.js b/examples/js/RollerCoaster.js index b9a280ea4bdbd7e4652293f73b5d401f1246c268..bfe11d0445443f57da0eace3ce63e405f31d0321 100644 --- a/examples/js/RollerCoaster.js +++ b/examples/js/RollerCoaster.js @@ -265,19 +265,19 @@ var RollerCoasterLiftersGeometry = function ( curve, size ) { var point1 = shape[ j ]; var point2 = shape[ ( j + 1 ) % jl ]; - vector1.copy( point1 ) + vector1.copy( point1 ); vector1.applyQuaternion( quaternion ); vector1.add( fromPoint ); - vector2.copy( point2 ) + vector2.copy( point2 ); vector2.applyQuaternion( quaternion ); vector2.add( fromPoint ); - vector3.copy( point2 ) + vector3.copy( point2 ); vector3.applyQuaternion( quaternion ); vector3.add( toPoint ); - vector4.copy( point1 ) + vector4.copy( point1 ); vector4.applyQuaternion( quaternion ); vector4.add( toPoint ); diff --git a/examples/js/ShaderSkin.js b/examples/js/ShaderSkin.js index bf6ac422a9e6985c33e9af0e1c45866a8460be07..e6331b80634dee8b065c5040732dbd25fc2ceda8 100644 --- a/examples/js/ShaderSkin.js +++ b/examples/js/ShaderSkin.js @@ -22,10 +22,7 @@ THREE.ShaderSkin = { 'skinSimple' : { - uniforms: THREE.UniformsUtils.merge( [ - - THREE.UniformsLib[ "fog" ], - THREE.UniformsLib[ "lights" ], + uniforms: Object.assign( { @@ -51,9 +48,12 @@ THREE.ShaderSkin = { "uWrapRGB": { value: new THREE.Vector3( 0.75, 0.375, 0.1875 ) } - } + }, + + THREE.UniformsLib[ "fog" ], + THREE.UniformsLib[ "lights" ] - ] ), + ), fragmentShader: [ @@ -305,10 +305,7 @@ THREE.ShaderSkin = { 'skin' : { - uniforms: THREE.UniformsUtils.merge( [ - - THREE.UniformsLib[ "fog" ], - THREE.UniformsLib[ "lights" ], + uniforms: Object.assign( { @@ -333,9 +330,12 @@ THREE.ShaderSkin = { "uRoughness": { value: 0.15 }, "uSpecularBrightness": { value: 0.75 } - } + }, + + THREE.UniformsLib[ "fog" ], + THREE.UniformsLib[ "lights" ] - ] ), + ), fragmentShader: [ diff --git a/examples/js/ShaderTerrain.js b/examples/js/ShaderTerrain.js index aa19d24b9c261e548d0620c54a196467944c5197..53410dcc118cfe927a1169a61de2d589a6906b3d 100644 --- a/examples/js/ShaderTerrain.js +++ b/examples/js/ShaderTerrain.js @@ -15,10 +15,8 @@ THREE.ShaderTerrain = { 'terrain' : { - uniforms: THREE.UniformsUtils.merge( [ + uniforms: Object.assign( - THREE.UniformsLib[ "fog" ], - THREE.UniformsLib[ "lights" ], { @@ -49,9 +47,12 @@ THREE.ShaderTerrain = { "uOffset": { value: new THREE.Vector2( 0, 0 ) } - } + }, + + THREE.UniformsLib[ "fog" ], + THREE.UniformsLib[ "lights" ] - ] ), + ), fragmentShader: [ diff --git a/examples/js/SkyShader.js b/examples/js/SkyShader.js index 8a7050a99bfada8ee0a7672aff808926fc40528f..66d110e222ef581711e682e4746c18a726992589 100644 --- a/examples/js/SkyShader.js +++ b/examples/js/SkyShader.js @@ -98,7 +98,7 @@ THREE.ShaderLib[ 'sky' ] = { // mie coefficients "vBetaM = totalMie(lambda, turbidity) * mieCoefficient;", - "}", + "}" ].join( "\n" ), @@ -201,7 +201,7 @@ THREE.ShaderLib[ 'sky' ] = { "gl_FragColor.rgb = retColor;", "gl_FragColor.a = 1.0;", - "}", + "}" ].join( "\n" ) @@ -210,7 +210,7 @@ THREE.ShaderLib[ 'sky' ] = { THREE.Sky = function () { var skyShader = THREE.ShaderLib[ "sky" ]; - var skyUniforms = THREE.UniformsUtils.clone( skyShader.uniforms ); + var skyUniforms = Object.assign( {}, skyShader.uniforms ); var skyMat = new THREE.ShaderMaterial( { fragmentShader: skyShader.fragmentShader, diff --git a/examples/js/UCSCharacter.js b/examples/js/UCSCharacter.js index 84b4eae77803a359137017cf4241898fd949963d..a4691fa990a7c92d9c94077db2b619bd06e67013 100644 --- a/examples/js/UCSCharacter.js +++ b/examples/js/UCSCharacter.js @@ -8,8 +8,8 @@ THREE.UCSCharacter = function() { this.root = new THREE.Object3D(); - this.numSkins; - this.numMorphs; + this.numSkins = undefined; + this.numMorphs = undefined; this.skins = []; this.materials = []; diff --git a/examples/js/Volume.js b/examples/js/Volume.js index 4152c3202ac4d58b995ac2ec45d6ddeca50a7b07..4b0d17527022c18f293056bfd17b1871aba642a1 100644 --- a/examples/js/Volume.js +++ b/examples/js/Volume.js @@ -75,7 +75,6 @@ THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) { case 'uint32' : case 'uint' : case 'unsigned int' : - case 'uint32' : case 'uint32_t' : this.data = new Uint32Array( arrayBuffer ); break; @@ -188,7 +187,7 @@ THREE.Volume = function( xLength, yLength, zLength, type, arrayBuffer ) { * @member {Array} RASDimensions This array holds the dimensions of the volume in the RAS space */ -} +}; THREE.Volume.prototype = { @@ -445,4 +444,4 @@ THREE.Volume.prototype = { } -} +}; diff --git a/examples/js/VolumeSlice.js b/examples/js/VolumeSlice.js index 1975a6d8f02cbb7a3c99a18cbf55507f10fb3e34..bd554eb20870ca385c31909466f8c91c498a0c70 100644 --- a/examples/js/VolumeSlice.js +++ b/examples/js/VolumeSlice.js @@ -85,7 +85,7 @@ THREE.VolumeSlice = function( volume, index, axis ) { */ -} +}; THREE.VolumeSlice.prototype = { @@ -214,4 +214,4 @@ THREE.VolumeSlice.prototype = { } -} +}; diff --git a/examples/js/WaterShader.js b/examples/js/WaterShader.js index 9bdbfeece9e38dccf020641c5cac88bd62632ed7..f78c8a68c5fbddc861e9ab97b88a4d06ecb33dbc 100644 --- a/examples/js/WaterShader.js +++ b/examples/js/WaterShader.js @@ -9,8 +9,8 @@ THREE.ShaderLib[ 'water' ] = { - uniforms: THREE.UniformsUtils.merge( [ - THREE.UniformsLib[ "fog" ], { + uniforms: Object.assign( + { "normalSampler": { value: null }, "mirrorSampler": { value: null }, "alpha": { value: 1.0 }, @@ -22,8 +22,9 @@ THREE.ShaderLib[ 'water' ] = { "sunDirection": { value: new THREE.Vector3( 0.70707, 0.70707, 0 ) }, "eye": { value: new THREE.Vector3() }, "waterColor": { value: new THREE.Color( 0x555555 ) } - } - ] ), + }, + THREE.UniformsLib[ "fog" ] + ), vertexShader: [ 'uniform mat4 textureMatrix;', @@ -169,7 +170,7 @@ THREE.Water = function ( renderer, camera, scene, options ) { this.renderTarget2 = new THREE.WebGLRenderTarget( width, height ); var mirrorShader = THREE.ShaderLib[ "water" ]; - var mirrorUniforms = THREE.UniformsUtils.clone( mirrorShader.uniforms ); + var mirrorUniforms = Object.assign( {}, mirrorShader.uniforms ); this.material = new THREE.ShaderMaterial( { fragmentShader: mirrorShader.fragmentShader, diff --git a/examples/js/animation/CCDIKSolver.js b/examples/js/animation/CCDIKSolver.js index 96184630e958162c721f013fa5bcbef05f692e03..3ae6140e5fb9fab5f79abe25a884d993bf68941c 100644 --- a/examples/js/animation/CCDIKSolver.js +++ b/examples/js/animation/CCDIKSolver.js @@ -69,7 +69,27 @@ THREE.CCDIKSolver.prototype = { }, - update: function () { + /* + * save the bone matrices before solving IK. + * they're used for generating VMD and VPD. + */ + _saveOriginalBonesInfo: function () { + + var bones = this.mesh.skeleton.bones; + + for ( var i = 0, il = bones.length; i < il; i ++ ) { + + var bone = bones[ i ]; + + if ( bone.userData.ik === undefined ) bone.userData.ik = {}; + + bone.userData.ik.originalMatrix = bone.matrix.toArray(); + + } + + }, + + update: function ( saveOriginalBones ) { var q = new THREE.Quaternion(); @@ -91,6 +111,8 @@ THREE.CCDIKSolver.prototype = { this.mesh.updateMatrixWorld( true ); + if ( saveOriginalBones === true ) this._saveOriginalBonesInfo(); + for ( var i = 0, il = iks.length; i < il; i++ ) { var ik = iks[ i ]; diff --git a/examples/js/animation/MMDPhysics.js b/examples/js/animation/MMDPhysics.js index 8b9ea6b4393473f704c59412ff7ad10f1a2cbce8..36013663f4ab28a7f9291a6782a94729bdde499e 100644 --- a/examples/js/animation/MMDPhysics.js +++ b/examples/js/animation/MMDPhysics.js @@ -35,7 +35,7 @@ THREE.MMDPhysics = function ( mesh, params ) { this.unitStep = ( params.unitStep !== undefined ) ? params.unitStep : 1 / 65; this.maxStepNum = ( params.maxStepNum !== undefined ) ? params.maxStepNum : 3; - this.world = null; + this.world = params.world !== undefined ? params.world : null; this.bodies = []; this.constraints = []; @@ -67,7 +67,7 @@ THREE.MMDPhysics.prototype = { mesh.updateMatrixWorld( true ); - this.initWorld(); + if ( this.world === null ) this.initWorld(); this.initRigidBodies(); this.initConstraints(); @@ -131,6 +131,14 @@ THREE.MMDPhysics.prototype = { update: function ( delta ) { + this.updateRigidBodies(); + this.stepSimulation( delta ); + this.updateBones(); + + }, + + stepSimulation: function ( delta ) { + var unitStep = this.unitStep; var stepTime = delta; var maxStepNum = ( ( delta / unitStep ) | 0 ) + 1; @@ -148,9 +156,7 @@ THREE.MMDPhysics.prototype = { } - this.updateRigidBodies(); this.world.stepSimulation( stepTime, maxStepNum, unitStep ); - this.updateBones(); }, @@ -634,7 +640,7 @@ THREE.MMDPhysics.ResourceHelper.prototype = { q.setW( w ); return q; - }, + } }; @@ -678,7 +684,7 @@ THREE.MMDPhysics.RigidBody.prototype = { } - }; + } var helper = this.helper; var params = this.params; @@ -871,7 +877,7 @@ THREE.MMDPhysics.RigidBody.prototype = { thQ.set( q.x(), q.y(), q.z(), q.w() ); thQ2.setFromRotationMatrix( this.bone.matrixWorld ); - thQ2.conjugate() + thQ2.conjugate(); thQ2.multiply( thQ ); //this.bone.quaternion.multiply( thQ2 ); diff --git a/examples/js/cameras/CinematicCamera.js b/examples/js/cameras/CinematicCamera.js index fd11c5d2131fd233a90df27dd67e948a30ef6601..a6e0ee3e708eea75f279c29650b07e3c39294fba 100644 --- a/examples/js/cameras/CinematicCamera.js +++ b/examples/js/cameras/CinematicCamera.js @@ -121,7 +121,7 @@ THREE.CinematicCamera.prototype.initPostProcessing = function () { var bokeh_shader = THREE.BokehShader; - this.postprocessing.bokeh_uniforms = THREE.UniformsUtils.clone( bokeh_shader.uniforms ); + this.postprocessing.bokeh_uniforms = Object.assign( {}, bokeh_shader.uniforms ); this.postprocessing.bokeh_uniforms[ "tColor" ].value = this.postprocessing.rtTextureColor.texture; this.postprocessing.bokeh_uniforms[ "tDepth" ].value = this.postprocessing.rtTextureDepth.texture; diff --git a/examples/js/controls/DragControls.js b/examples/js/controls/DragControls.js index 01f6486abbffc8ed60d3dd0123bb8fe606301125..4a658852c4baae92dd9e653d23fc8d81fd2d02ad 100644 --- a/examples/js/controls/DragControls.js +++ b/examples/js/controls/DragControls.js @@ -232,4 +232,4 @@ THREE.DragControls = function( _camera, _objects, _domElement ) { } -} +}; diff --git a/examples/js/controls/EditorControls.js b/examples/js/controls/EditorControls.js index 9842247fecff686f820d3b46cd452b3b7a583993..f7850a5600e2c02ab06fb132026c653df97a4652 100644 --- a/examples/js/controls/EditorControls.js +++ b/examples/js/controls/EditorControls.js @@ -13,9 +13,9 @@ THREE.EditorControls = function ( object, domElement ) { this.enabled = true; this.center = new THREE.Vector3(); - this.panSpeed = 0.001 - this.zoomSpeed = 0.001 - this.rotationSpeed = 0.005 + this.panSpeed = 0.001; + this.zoomSpeed = 0.001; + this.rotationSpeed = 0.005; // internals diff --git a/examples/js/controls/FirstPersonControls.js b/examples/js/controls/FirstPersonControls.js index c754ea69d245d7f5600c3e502d499e016b7b6605..51e0c3907e3ec0bb5942333807a91bc48a266f70 100644 --- a/examples/js/controls/FirstPersonControls.js +++ b/examples/js/controls/FirstPersonControls.js @@ -269,7 +269,7 @@ THREE.FirstPersonControls = function ( object, domElement ) { window.removeEventListener( 'keydown', _onKeyDown, false ); window.removeEventListener( 'keyup', _onKeyUp, false ); - } + }; var _onMouseMove = bind( this, this.onMouseMove ); var _onMouseDown = bind( this, this.onMouseDown ); diff --git a/examples/js/controls/FlyControls.js b/examples/js/controls/FlyControls.js index 2b24f7cf1bc6c2ff7dcc30d0b9970ef88872efba..e55ff699ec4284f806221da8ee55fdc38ab97632 100644 --- a/examples/js/controls/FlyControls.js +++ b/examples/js/controls/FlyControls.js @@ -270,7 +270,7 @@ THREE.FlyControls = function ( object, domElement ) { window.removeEventListener( 'keydown', _keydown, false ); window.removeEventListener( 'keyup', _keyup, false ); - } + }; var _mousemove = bind( this, this.mousemove ); var _mousedown = bind( this, this.mousedown ); diff --git a/examples/js/controls/MouseControls.js b/examples/js/controls/MouseControls.js index 994917f85b7ddd2fb82303afab2cdccafc8090e6..7297b76c091f301e7f513e6844a2229e481ca546 100644 --- a/examples/js/controls/MouseControls.js +++ b/examples/js/controls/MouseControls.js @@ -36,7 +36,7 @@ THREE.MouseControls = function ( object ) { this.orientation = { x: 0, - y: 0, + y: 0 }; this.update = function() { @@ -46,7 +46,6 @@ THREE.MouseControls = function ( object ) { mouseQuat.x.setFromAxisAngle( xVector, this.orientation.x ); mouseQuat.y.setFromAxisAngle( yVector, this.orientation.y ); object.quaternion.copy( mouseQuat.y ).multiply( mouseQuat.x ); - return; }; @@ -54,7 +53,7 @@ THREE.MouseControls = function ( object ) { document.removeEventListener( 'mousemove', onMouseMove, false ); - } + }; document.addEventListener( 'mousemove', onMouseMove, false ); diff --git a/examples/js/controls/OrbitControls.js b/examples/js/controls/OrbitControls.js index 436aa1b4ccc85ef62aedb575a48dd369de812fc0..4d75aac9ce5c40266d02d20b69e1be247dcffc7e 100644 --- a/examples/js/controls/OrbitControls.js +++ b/examples/js/controls/OrbitControls.js @@ -112,7 +112,7 @@ THREE.OrbitControls = function ( object, domElement ) { }; // this method is exposed, but perhaps it would be better if we can make it private... - this.update = function() { + this.update = function () { var offset = new THREE.Vector3(); @@ -123,7 +123,7 @@ THREE.OrbitControls = function ( object, domElement ) { var lastPosition = new THREE.Vector3(); var lastQuaternion = new THREE.Quaternion(); - return function update () { + return function update() { var position = scope.object.position; @@ -208,7 +208,7 @@ THREE.OrbitControls = function ( object, domElement ) { }(); - this.dispose = function() { + this.dispose = function () { scope.domElement.removeEventListener( 'contextmenu', onContextMenu, false ); scope.domElement.removeEventListener( 'mousedown', onMouseDown, false ); @@ -237,7 +237,7 @@ THREE.OrbitControls = function ( object, domElement ) { var startEvent = { type: 'start' }; var endEvent = { type: 'end' }; - var STATE = { NONE : - 1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 }; + var STATE = { NONE: - 1, ROTATE: 0, DOLLY: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_DOLLY: 4, TOUCH_PAN: 5 }; var state = STATE.NONE; @@ -287,7 +287,7 @@ THREE.OrbitControls = function ( object, domElement ) { } - var panLeft = function() { + var panLeft = function () { var v = new THREE.Vector3(); @@ -302,7 +302,7 @@ THREE.OrbitControls = function ( object, domElement ) { }(); - var panUp = function() { + var panUp = function () { var v = new THREE.Vector3(); @@ -318,11 +318,11 @@ THREE.OrbitControls = function ( object, domElement ) { }(); // deltaX and deltaY are in pixels; right and down are positive - var pan = function() { + var pan = function () { var offset = new THREE.Vector3(); - return function pan ( deltaX, deltaY ) { + return function pan( deltaX, deltaY ) { var element = scope.domElement === document ? scope.domElement.body : scope.domElement; @@ -491,13 +491,13 @@ THREE.OrbitControls = function ( object, domElement ) { function handleMouseUp( event ) { - //console.log( 'handleMouseUp' ); + // console.log( 'handleMouseUp' ); } function handleMouseWheel( event ) { - //console.log( 'handleMouseWheel' ); + // console.log( 'handleMouseWheel' ); if ( event.deltaY < 0 ) { @@ -977,7 +977,7 @@ Object.defineProperties( THREE.OrbitControls.prototype, { }, - staticMoving : { + staticMoving: { get: function () { @@ -995,7 +995,7 @@ Object.defineProperties( THREE.OrbitControls.prototype, { }, - dynamicDampingFactor : { + dynamicDampingFactor: { get: function () { diff --git a/examples/js/controls/TrackballControls.js b/examples/js/controls/TrackballControls.js index 22f52e198e9de385baad05aaedb3516ee60de859..d3e6aeb4f9b805c9737faf88f9c8f0e2d60ec079 100644 --- a/examples/js/controls/TrackballControls.js +++ b/examples/js/controls/TrackballControls.js @@ -218,7 +218,7 @@ THREE.TrackballControls = function ( object, domElement ) { if ( factor !== 1.0 && factor > 0.0 ) { _eye.multiplyScalar( factor ); - + } if ( _this.staticMoving ) { @@ -473,7 +473,24 @@ THREE.TrackballControls = function ( object, domElement ) { event.preventDefault(); event.stopPropagation(); - _zoomStart.y -= event.deltaY * 0.01; + switch ( event.deltaMode ) { + + case 2: + // Zoom in pages + _zoomStart.y -= event.deltaY * 0.025; + break; + + case 1: + // Zoom in lines + _zoomStart.y -= event.deltaY * 0.01; + break; + + default: + // undefined, 0, assume pixels + _zoomStart.y -= event.deltaY * 0.00025; + break; + + } _this.dispatchEvent( startEvent ); _this.dispatchEvent( endEvent ); diff --git a/examples/js/controls/TransformControls.js b/examples/js/controls/TransformControls.js index 00c367115be7376d91de6d432445d69a7de0e883..ba9e3c5e36a0d93cdd75aa3e3f8b9f6d7e9b870e 100644 --- a/examples/js/controls/TransformControls.js +++ b/examples/js/controls/TransformControls.js @@ -444,7 +444,7 @@ var group = { handles: this[ "handles" ], - pickers: this[ "pickers" ], + pickers: this[ "pickers" ] }; diff --git a/examples/js/controls/VRControls.js b/examples/js/controls/VRControls.js old mode 100755 new mode 100644 diff --git a/examples/js/effects/OutlineEffect.js b/examples/js/effects/OutlineEffect.js index 6e5cdb9f1ba7565d4efd1a941b4508ba39591a23..6a7d8e116cc281a386886e22948d1304054b9282 100644 --- a/examples/js/effects/OutlineEffect.js +++ b/examples/js/effects/OutlineEffect.js @@ -26,11 +26,9 @@ THREE.OutlineEffect = function ( renderer, parameters ) { - var _this = this; - parameters = parameters || {}; - this.autoClear = parameters.autoClear !== undefined ? parameters.autoClear : true; + this.enabled = true; var defaultThickness = parameters.defaultThickness !== undefined ? parameters.defaultThickness : 0.003; var defaultColor = parameters.defaultColor !== undefined ? parameters.defaultColor : new THREE.Color( 0x000000 ); @@ -64,6 +62,7 @@ THREE.OutlineEffect = function ( renderer, parameters ) { MeshBasicMaterial: 'basic', MeshLambertMaterial: 'lambert', MeshPhongMaterial: 'phong', + MeshToonMaterial: 'phong', MeshStandardMaterial: 'physical', MeshPhysicalMaterial: 'physical' }; @@ -87,13 +86,13 @@ THREE.OutlineEffect = function ( renderer, parameters ) { " vec4 norm = normalize( pos - pos2 );", " return pos + norm * thickness * pos.w * ratio;", - "}", + "}" ].join( "\n" ); var vertexShaderChunk2 = [ - "#if ! defined( LAMBERT ) && ! defined( PHONG ) && ! defined( PHYSICAL )", + "#if ! defined( LAMBERT ) && ! defined( PHONG ) && ! defined( TOON ) && ! defined( PHYSICAL )", " #ifndef USE_ENVMAP", " vec3 objectNormal = normalize( normal );", @@ -110,7 +109,7 @@ THREE.OutlineEffect = function ( renderer, parameters ) { " gl_Position = calculateOutline( gl_Position, objectNormal, skinned );", "#else", " gl_Position = calculateOutline( gl_Position, objectNormal, vec4( transformed, 1.0 ) );", - "#endif", + "#endif" ].join( "\n" ); @@ -128,7 +127,7 @@ THREE.OutlineEffect = function ( renderer, parameters ) { " #include ", - "}", + "}" ].join( "\n" ); @@ -256,11 +255,11 @@ THREE.OutlineEffect = function ( renderer, parameters ) { if ( object.material === undefined ) return; - var originalMaterial = originalMaterials[ object.material.uuid ] + var originalMaterial = originalMaterials[ object.material.uuid ]; if ( originalMaterial === undefined ) { - originalMaterial = originalMaterials[ object.uuid ] + originalMaterial = originalMaterials[ object.uuid ]; if ( originalMaterial === undefined ) return; @@ -426,13 +425,14 @@ THREE.OutlineEffect = function ( renderer, parameters ) { } - this.setSize = function ( width, height ) { + this.render = function ( scene, camera, renderTarget, forceClear ) { - renderer.setSize( width, height ); + if ( this.enabled === false ) { - }; + renderer.render( scene, camera, renderTarget, forceClear ); + return; - this.render = function ( scene, camera, renderTarget, forceClear ) { + } var currentAutoClear = renderer.autoClear; renderer.autoClear = this.autoClear; @@ -465,4 +465,76 @@ THREE.OutlineEffect = function ( renderer, parameters ) { }; + /* + * See #9918 + * + * The following property copies and wrapper methods enable + * THREE.OutlineEffect to be called from other *Effect, like + * + * effect = new THREE.VREffect( new THREE.OutlineEffect( renderer ) ); + * + * function render () { + * + * effect.render( scene, camera ); + * + * } + */ + this.autoClear = renderer.autoClear; + this.domElement = renderer.domElement; + this.shadowMap = renderer.shadowMap; + + this.clear = function ( color, depth, stencil ) { + + renderer.clear( color, depth, stencil ); + + }; + + this.getPixelRatio = function () { + + return renderer.getPixelRatio(); + + }; + + this.setPixelRatio = function ( value ) { + + renderer.setPixelRatio( value ); + + }; + + this.getSize = function () { + + return renderer.getSize(); + + }; + + this.setSize = function ( width, height, updateStyle ) { + + renderer.setSize( width, height, updateStyle ); + + }; + + this.setViewport = function ( x, y, width, height ) { + + renderer.setViewport( x, y, width, height ); + + }; + + this.setScissor = function ( x, y, width, height ) { + + renderer.setScissor( x, y, width, height ); + + }; + + this.setScissorTest = function ( boolean ) { + + renderer.setScissorTest( boolean ); + + }; + + this.setRenderTarget = function ( renderTarget ) { + + renderer.setRenderTarget( renderTarget ); + + }; + }; diff --git a/examples/js/exporters/MMDExporter.js b/examples/js/exporters/MMDExporter.js new file mode 100644 index 0000000000000000000000000000000000000000..2e4120f432cba016a7d9e352519927793b9ee1ee --- /dev/null +++ b/examples/js/exporters/MMDExporter.js @@ -0,0 +1,211 @@ +/** + * @author takahiro / http://github.com/takahirox + * + * Dependencies + * - mmd-parser https://github.com/takahirox/mmd-parser + */ + +THREE.MMDExporter = function () { + + // Unicode to Shift_JIS table + var u2sTable; + + function unicodeToShiftjis( str ) { + + if ( u2sTable === undefined ) { + + var encoder = new MMDParser.CharsetEncoder(); + var table = encoder.s2uTable; + u2sTable = {}; + + var keys = Object.keys( table ); + + for ( var i = 0, il = keys.length; i < il; i ++ ) { + + var key = keys[ i ]; + + var value = table[ key ]; + key = parseInt( key ); + + u2sTable[ value ] = key; + + } + + } + + var array = []; + + for ( var i = 0, il = str.length; i < il; i ++ ) { + + var code = str.charCodeAt( i ) + + var value = u2sTable[ code ]; + + if ( value === undefined ) { + + throw 'cannot convert charcode 0x' + code.toString( 16 ); + + } else if ( value > 0xff ) { + + array.push( ( value >> 8 ) & 0xff ); + array.push( value & 0xff ); + + } else { + + array.push( value & 0xff ); + + } + + } + + return new Uint8Array( array ); + + } + + function getBindBones( skin ) { + + // any more efficient ways? + var poseSkin = skin.clone(); + poseSkin.pose(); + return poseSkin.skeleton.bones; + + } + + /* TODO: implement + // mesh -> pmd + this.parsePmd = function ( object ) { + + }; + */ + + /* TODO: implement + // mesh -> pmx + this.parsePmx = function ( object ) { + + }; + */ + + /* + * skeleton -> vpd + * Returns Shift_JIS encoded Uint8Array. Otherwise return strings. + */ + this.parseVpd = function ( skin, outputShiftJis, useOriginalBones ) { + + if ( skin.isSkinnedMesh !== true ) { + + console.warn( 'THREE.MMDExporter: parseVpd() requires SkinnedMesh instance.' ); + return null; + + } + + function toStringsFromNumber( num ) { + + if ( Math.abs( num ) < 1e-6 ) num = 0; + + var a = num.toString(); + + if ( a.indexOf( '.' ) === -1 ) { + + a += '.'; + + } + + a += '000000'; + + var index = a.indexOf( '.' ); + + var d = a.slice( 0, index ); + var p = a.slice( index + 1, index + 7 ); + + return d + '.' + p; + + } + + function toStringsFromArray( array ) { + + var a = []; + + for ( var i = 0, il = array.length; i < il; i ++ ) { + + a.push( toStringsFromNumber( array[ i ] ) ); + + } + + return a.join( ',' ); + + } + + skin.updateMatrixWorld( true ); + + var bones = skin.skeleton.bones; + var bones2 = getBindBones( skin ); + + var position = new THREE.Vector3(); + var quaternion = new THREE.Quaternion(); + var quaternion2 = new THREE.Quaternion(); + var matrix = new THREE.Matrix4(); + + var array = []; + array.push( 'Vocaloid Pose Data file' ); + array.push( '' ); + array.push( ( skin.name !== '' ? skin.name.replace( /\s/g, '_' ) : 'skin' ) + '.osm;' ); + array.push( bones.length + ';' ); + array.push( '' ); + + for ( var i = 0, il = bones.length; i < il; i ++ ) { + + var bone = bones[ i ]; + var bone2 = bones2[ i ]; + + /* + * use the bone matrix saved before solving IK. + * see CCDIKSolver for the detail. + */ + if ( useOriginalBones === true && + bone.userData.ik !== undefined && + bone.userData.ik.originalMatrix !== undefined ) { + + matrix.fromArray( bone.userData.ik.originalMatrix ); + + } else { + + matrix.copy( bone.matrix ); + + } + + position.setFromMatrixPosition( matrix ); + quaternion.setFromRotationMatrix( matrix ); + + var pArray = position.sub( bone2.position ).toArray(); + var qArray = quaternion2.copy( bone2.quaternion ).conjugate().multiply( quaternion ).toArray(); + + // right to left + pArray[ 2 ] = -pArray[ 2 ]; + qArray[ 0 ] = -qArray[ 0 ]; + qArray[ 1 ] = -qArray[ 1 ]; + + array.push( 'Bone' + i + '{' + bone.name ); + array.push( ' ' + toStringsFromArray( pArray ) + ';' ); + array.push( ' ' + toStringsFromArray( qArray ) + ';' ); + array.push( '}' ); + array.push( '' ); + + } + + array.push( '' ); + + var lines = array.join( '\n' ); + + return ( outputShiftJis === true ) ? unicodeToShiftjis( lines ) : lines; + + }; + + /* TODO: implement + // animation + skeleton -> vmd + this.parseVmd = function ( object ) { + + }; + */ + +}; + diff --git a/examples/js/geometries/DecalGeometry.js b/examples/js/geometries/DecalGeometry.js index 3c155217646125f250a9ed61ea0d1cbe993b675e..c5553c705b3541b035f2d06946ce9a6785f3afc1 100644 --- a/examples/js/geometries/DecalGeometry.js +++ b/examples/js/geometries/DecalGeometry.js @@ -88,7 +88,7 @@ THREE.DecalGeometry = function( mesh, position, rotation, dimensions, check ) { } case 1: { - var nV1, nV2, nV3; + var nV1, nV2, nV3, nV4; if ( v1Out ) { nV1 = inVertices[ j + 1 ]; diff --git a/examples/js/geometries/TeapotBufferGeometry.js b/examples/js/geometries/TeapotBufferGeometry.js index e1fa4941a4a255f66d81f5dfe2060fba3116fa99..296327346791ffe1e9d172f1e26434275a28b821 100644 --- a/examples/js/geometries/TeapotBufferGeometry.js +++ b/examples/js/geometries/TeapotBufferGeometry.js @@ -481,7 +481,9 @@ THREE.TeapotBufferGeometry = function ( size, segments, bottom, lid, body, fitLi var sstep, tstep; var vertPerRow, eps; - var s, t, sval, tval, p, dsval, dtval; + var s, t, sval, tval, p; + var dsval = 0; + var dtval = 0; var normOut = new THREE.Vector3(); var v1, v2, v3, v4; diff --git a/examples/js/libs/dat.gui.min.js b/examples/js/libs/dat.gui.min.js old mode 100755 new mode 100644 diff --git a/examples/js/libs/mmdparser.min.js b/examples/js/libs/mmdparser.min.js index 23fe75746ed391d123cc00a9b2019a1bd9fb3dbf..f17cd9f8e9d2f9d6efa2b50da098c548b9d2c949 100644 --- a/examples/js/libs/mmdparser.min.js +++ b/examples/js/libs/mmdparser.min.js @@ -3,4 +3,4 @@ 37574:27084,37575:36861,37576:37786,37577:30171,37578:36890,37579:22618,37580:26626,37581:25524,37582:27131,37583:20291,37584:28460,37585:26584,37586:36795,37587:34086,37588:32180,37589:37716,37590:26943,37591:28528,37592:22378,37593:22775,37594:23340,37595:32044,37596:29226,37597:21514,37598:37347,37599:40372,37600:20141,37601:20302,37602:20572,37603:20597,37604:21059,37605:35998,37606:21576,37607:22564,37608:23450,37609:24093,37610:24213,37611:24237,37612:24311,37613:24351,37614:24716,37615:25269,37616:25402,37617:25552,37618:26799,37619:27712,37620:30855,37621:31118,37622:31243,37623:32224,37624:33351,37625:35330,37626:35558,37627:36420,37628:36883,37696:37048,37697:37165,37698:37336,37699:40718,37700:27877,37701:25688,37702:25826,37703:25973,37704:28404,37705:30340,37706:31515,37707:36969,37708:37841,37709:28346,37710:21746,37711:24505,37712:25764,37713:36685,37714:36845,37715:37444,37716:20856,37717:22635,37718:22825,37719:23637,37720:24215,37721:28155,37722:32399,37723:29980,37724:36028,37725:36578,37726:39003,37727:28857,37728:20253,37729:27583,37730:28593,37731:3e4,37732:38651,37733:20814,37734:21520,37735:22581,37736:22615,37737:22956,37738:23648,37739:24466,37740:26007,37741:26460,37742:28193,37743:30331,37744:33759,37745:36077,37746:36884,37747:37117,37748:37709,37749:30757,37750:30778,37751:21162,37752:24230,37753:22303,37754:22900,37755:24594,37756:20498,37757:20826,37758:20908,37760:20941,37761:20992,37762:21776,37763:22612,37764:22616,37765:22871,37766:23445,37767:23798,37768:23947,37769:24764,37770:25237,37771:25645,37772:26481,37773:26691,37774:26812,37775:26847,37776:30423,37777:28120,37778:28271,37779:28059,37780:28783,37781:29128,37782:24403,37783:30168,37784:31095,37785:31561,37786:31572,37787:31570,37788:31958,37789:32113,37790:21040,37791:33891,37792:34153,37793:34276,37794:35342,37795:35588,37796:35910,37797:36367,37798:36867,37799:36879,37800:37913,37801:38518,37802:38957,37803:39472,37804:38360,37805:20685,37806:21205,37807:21516,37808:22530,37809:23566,37810:24999,37811:25758,37812:27934,37813:30643,37814:31461,37815:33012,37816:33796,37817:36947,37818:37509,37819:23776,37820:40199,37821:21311,37822:24471,37823:24499,37824:28060,37825:29305,37826:30563,37827:31167,37828:31716,37829:27602,37830:29420,37831:35501,37832:26627,37833:27233,37834:20984,37835:31361,37836:26932,37837:23626,37838:40182,37839:33515,37840:23493,37841:37193,37842:28702,37843:22136,37844:23663,37845:24775,37846:25958,37847:27788,37848:35930,37849:36929,37850:38931,37851:21585,37852:26311,37853:37389,37854:22856,37855:37027,37856:20869,37857:20045,37858:20970,37859:34201,37860:35598,37861:28760,37862:25466,37863:37707,37864:26978,37865:39348,37866:32260,37867:30071,37868:21335,37869:26976,37870:36575,37871:38627,37872:27741,37873:20108,37874:23612,37875:24336,37876:36841,37877:21250,37878:36049,37879:32905,37880:34425,37881:24319,37882:26085,37883:20083,37884:20837,37952:22914,37953:23615,37954:38894,37955:20219,37956:22922,37957:24525,37958:35469,37959:28641,37960:31152,37961:31074,37962:23527,37963:33905,37964:29483,37965:29105,37966:24180,37967:24565,37968:25467,37969:25754,37970:29123,37971:31896,37972:20035,37973:24316,37974:20043,37975:22492,37976:22178,37977:24745,37978:28611,37979:32013,37980:33021,37981:33075,37982:33215,37983:36786,37984:35223,37985:34468,37986:24052,37987:25226,37988:25773,37989:35207,37990:26487,37991:27874,37992:27966,37993:29750,37994:30772,37995:23110,37996:32629,37997:33453,37998:39340,37999:20467,38e3:24259,38001:25309,38002:25490,38003:25943,38004:26479,38005:30403,38006:29260,38007:32972,38008:32954,38009:36649,38010:37197,38011:20493,38012:22521,38013:23186,38014:26757,38016:26995,38017:29028,38018:29437,38019:36023,38020:22770,38021:36064,38022:38506,38023:36889,38024:34687,38025:31204,38026:30695,38027:33833,38028:20271,38029:21093,38030:21338,38031:25293,38032:26575,38033:27850,38034:30333,38035:31636,38036:31893,38037:33334,38038:34180,38039:36843,38040:26333,38041:28448,38042:29190,38043:32283,38044:33707,38045:39361,38046:40614,38047:20989,38048:31665,38049:30834,38050:31672,38051:32903,38052:31560,38053:27368,38054:24161,38055:32908,38056:30033,38057:30048,38058:20843,38059:37474,38060:28300,38061:30330,38062:37271,38063:39658,38064:20240,38065:32624,38066:25244,38067:31567,38068:38309,38069:40169,38070:22138,38071:22617,38072:34532,38073:38588,38074:20276,38075:21028,38076:21322,38077:21453,38078:21467,38079:24070,38080:25644,38081:26001,38082:26495,38083:27710,38084:27726,38085:29256,38086:29359,38087:29677,38088:30036,38089:32321,38090:33324,38091:34281,38092:36009,38093:31684,38094:37318,38095:29033,38096:38930,38097:39151,38098:25405,38099:26217,38100:30058,38101:30436,38102:30928,38103:34115,38104:34542,38105:21290,38106:21329,38107:21542,38108:22915,38109:24199,38110:24444,38111:24754,38112:25161,38113:25209,38114:25259,38115:26e3,38116:27604,38117:27852,38118:30130,38119:30382,38120:30865,38121:31192,38122:32203,38123:32631,38124:32933,38125:34987,38126:35513,38127:36027,38128:36991,38129:38750,38130:39131,38131:27147,38132:31800,38133:20633,38134:23614,38135:24494,38136:26503,38137:27608,38138:29749,38139:30473,38140:32654,38208:40763,38209:26570,38210:31255,38211:21305,38212:30091,38213:39661,38214:24422,38215:33181,38216:33777,38217:32920,38218:24380,38219:24517,38220:30050,38221:31558,38222:36924,38223:26727,38224:23019,38225:23195,38226:32016,38227:30334,38228:35628,38229:20469,38230:24426,38231:27161,38232:27703,38233:28418,38234:29922,38235:31080,38236:34920,38237:35413,38238:35961,38239:24287,38240:25551,38241:30149,38242:31186,38243:33495,38244:37672,38245:37618,38246:33948,38247:34541,38248:39981,38249:21697,38250:24428,38251:25996,38252:27996,38253:28693,38254:36007,38255:36051,38256:38971,38257:25935,38258:29942,38259:19981,38260:20184,38261:22496,38262:22827,38263:23142,38264:23500,38265:20904,38266:24067,38267:24220,38268:24598,38269:25206,38270:25975,38272:26023,38273:26222,38274:28014,38275:29238,38276:31526,38277:33104,38278:33178,38279:33433,38280:35676,38281:36e3,38282:36070,38283:36212,38284:38428,38285:38468,38286:20398,38287:25771,38288:27494,38289:33310,38290:33889,38291:34154,38292:37096,38293:23553,38294:26963,38295:39080,38296:33914,38297:34135,38298:20239,38299:21103,38300:24489,38301:24133,38302:26381,38303:31119,38304:33145,38305:35079,38306:35206,38307:28149,38308:24343,38309:25173,38310:27832,38311:20175,38312:29289,38313:39826,38314:20998,38315:21563,38316:22132,38317:22707,38318:24996,38319:25198,38320:28954,38321:22894,38322:31881,38323:31966,38324:32027,38325:38640,38326:25991,38327:32862,38328:19993,38329:20341,38330:20853,38331:22592,38332:24163,38333:24179,38334:24330,38335:26564,38336:20006,38337:34109,38338:38281,38339:38491,38340:31859,38341:38913,38342:20731,38343:22721,38344:30294,38345:30887,38346:21029,38347:30629,38348:34065,38349:31622,38350:20559,38351:22793,38352:29255,38353:31687,38354:32232,38355:36794,38356:36820,38357:36941,38358:20415,38359:21193,38360:23081,38361:24321,38362:38829,38363:20445,38364:33303,38365:37610,38366:22275,38367:25429,38368:27497,38369:29995,38370:35036,38371:36628,38372:31298,38373:21215,38374:22675,38375:24917,38376:25098,38377:26286,38378:27597,38379:31807,38380:33769,38381:20515,38382:20472,38383:21253,38384:21574,38385:22577,38386:22857,38387:23453,38388:23792,38389:23791,38390:23849,38391:24214,38392:25265,38393:25447,38394:25918,38395:26041,38396:26379,38464:27861,38465:27873,38466:28921,38467:30770,38468:32299,38469:32990,38470:33459,38471:33804,38472:34028,38473:34562,38474:35090,38475:35370,38476:35914,38477:37030,38478:37586,38479:39165,38480:40179,38481:40300,38482:20047,38483:20129,38484:20621,38485:21078,38486:22346,38487:22952,38488:24125,38489:24536,38490:24537,38491:25151,38492:26292,38493:26395,38494:26576,38495:26834,38496:20882,38497:32033,38498:32938,38499:33192,38500:35584,38501:35980,38502:36031,38503:37502,38504:38450,38505:21536,38506:38956,38507:21271,38508:20693,38509:21340,38510:22696,38511:25778,38512:26420,38513:29287,38514:30566,38515:31302,38516:37350,38517:21187,38518:27809,38519:27526,38520:22528,38521:24140,38522:22868,38523:26412,38524:32763,38525:20961,38526:30406,38528:25705,38529:30952,38530:39764,38531:40635,38532:22475,38533:22969,38534:26151,38535:26522,38536:27598,38537:21737,38538:27097,38539:24149,38540:33180,38541:26517,38542:39850,38543:26622,38544:40018,38545:26717,38546:20134,38547:20451,38548:21448,38549:25273,38550:26411,38551:27819,38552:36804,38553:20397,38554:32365,38555:40639,38556:19975,38557:24930,38558:28288,38559:28459,38560:34067,38561:21619,38562:26410,38563:39749,38564:24051,38565:31637,38566:23724,38567:23494,38568:34588,38569:28234,38570:34001,38571:31252,38572:33032,38573:22937,38574:31885,38575:27665,38576:30496,38577:21209,38578:22818,38579:28961,38580:29279,38581:30683,38582:38695,38583:40289,38584:26891,38585:23167,38586:23064,38587:20901,38588:21517,38589:21629,38590:26126,38591:30431,38592:36855,38593:37528,38594:40180,38595:23018,38596:29277,38597:28357,38598:20813,38599:26825,38600:32191,38601:32236,38602:38754,38603:40634,38604:25720,38605:27169,38606:33538,38607:22916,38608:23391,38609:27611,38610:29467,38611:30450,38612:32178,38613:32791,38614:33945,38615:20786,38616:26408,38617:40665,38618:30446,38619:26466,38620:21247,38621:39173,38622:23588,38623:25147,38624:31870,38625:36016,38626:21839,38627:24758,38628:32011,38629:38272,38630:21249,38631:20063,38632:20918,38633:22812,38634:29242,38635:32822,38636:37326,38637:24357,38638:30690,38639:21380,38640:24441,38641:32004,38642:34220,38643:35379,38644:36493,38645:38742,38646:26611,38647:34222,38648:37971,38649:24841,38650:24840,38651:27833,38652:30290,38720:35565,38721:36664,38722:21807,38723:20305,38724:20778,38725:21191,38726:21451,38727:23461,38728:24189,38729:24736,38730:24962,38731:25558,38732:26377,38733:26586,38734:28263,38735:28044,38736:29494,38737:29495,38738:30001,38739:31056,38740:35029,38741:35480,38742:36938,38743:37009,38744:37109,38745:38596,38746:34701,38747:22805,38748:20104,38749:20313,38750:19982,38751:35465,38752:36671,38753:38928,38754:20653,38755:24188,38756:22934,38757:23481,38758:24248,38759:25562,38760:25594,38761:25793,38762:26332,38763:26954,38764:27096,38765:27915,38766:28342,38767:29076,38768:29992,38769:31407,38770:32650,38771:32768,38772:33865,38773:33993,38774:35201,38775:35617,38776:36362,38777:36965,38778:38525,38779:39178,38780:24958,38781:25233,38782:27442,38784:27779,38785:28020,38786:32716,38787:32764,38788:28096,38789:32645,38790:34746,38791:35064,38792:26469,38793:33713,38794:38972,38795:38647,38796:27931,38797:32097,38798:33853,38799:37226,38800:20081,38801:21365,38802:23888,38803:27396,38804:28651,38805:34253,38806:34349,38807:35239,38808:21033,38809:21519,38810:23653,38811:26446,38812:26792,38813:29702,38814:29827,38815:30178,38816:35023,38817:35041,38818:37324,38819:38626,38820:38520,38821:24459,38822:29575,38823:31435,38824:33870,38825:25504,38826:30053,38827:21129,38828:27969,38829:28316,38830:29705,38831:30041,38832:30827,38833:31890,38834:38534,38835:31452,38836:40845,38837:20406,38838:24942,38839:26053,38840:34396,38841:20102,38842:20142,38843:20698,38844:20001,38845:20940,38846:23534,38847:26009,38848:26753,38849:28092,38850:29471,38851:30274,38852:30637,38853:31260,38854:31975,38855:33391,38856:35538,38857:36988,38858:37327,38859:38517,38860:38936,38861:21147,38862:32209,38863:20523,38864:21400,38865:26519,38866:28107,38867:29136,38868:29747,38869:33256,38870:36650,38871:38563,38872:40023,38873:40607,38874:29792,38875:22593,38876:28057,38877:32047,38878:39006,38879:20196,38880:20278,38881:20363,38882:20919,38883:21169,38884:23994,38885:24604,38886:29618,38887:31036,38888:33491,38889:37428,38890:38583,38891:38646,38892:38666,38893:40599,38894:40802,38895:26278,38896:27508,38897:21015,38898:21155,38899:28872,38900:35010,38901:24265,38902:24651,38903:24976,38904:28451,38905:29001,38906:31806,38907:32244,38908:32879,38976:34030,38977:36899,38978:37676,38979:21570,38980:39791,38981:27347,38982:28809,38983:36034,38984:36335,38985:38706,38986:21172,38987:23105,38988:24266,38989:24324,38990:26391,38991:27004,38992:27028,38993:28010,38994:28431,38995:29282,38996:29436,38997:31725,38998:32769,38999:32894,39e3:34635,39001:37070,39002:20845,39003:40595,39004:31108,39005:32907,39006:37682,39007:35542,39008:20525,39009:21644,39010:35441,39011:27498,39012:36036,39013:33031,39014:24785,39015:26528,39016:40434,39017:20121,39018:20120,39019:39952,39020:35435,39021:34241,39022:34152,39023:26880,39024:28286,39025:30871,39026:33109,39071:24332,39072:19984,39073:19989,39074:20010,39075:20017,39076:20022,39077:20028,39078:20031,39079:20034,39080:20054,39081:20056,39082:20098,39083:20101,39084:35947,39085:20106,39086:33298,39087:24333,39088:20110,39089:20126,39090:20127,39091:20128,39092:20130,39093:20144,39094:20147,39095:20150,39096:20174,39097:20173,39098:20164,39099:20166,39100:20162,39101:20183,39102:20190,39103:20205,39104:20191,39105:20215,39106:20233,39107:20314,39108:20272,39109:20315,39110:20317,39111:20311,39112:20295,39113:20342,39114:20360,39115:20367,39116:20376,39117:20347,39118:20329,39119:20336,39120:20369,39121:20335,39122:20358,39123:20374,39124:20760,39125:20436,39126:20447,39127:20430,39128:20440,39129:20443,39130:20433,39131:20442,39132:20432,39133:20452,39134:20453,39135:20506,39136:20520,39137:20500,39138:20522,39139:20517,39140:20485,39141:20252,39142:20470,39143:20513,39144:20521,39145:20524,39146:20478,39147:20463,39148:20497,39149:20486,39150:20547,39151:20551,39152:26371,39153:20565,39154:20560,39155:20552,39156:20570,39157:20566,39158:20588,39159:20600,39160:20608,39161:20634,39162:20613,39163:20660,39164:20658,39232:20681,39233:20682,39234:20659,39235:20674,39236:20694,39237:20702,39238:20709,39239:20717,39240:20707,39241:20718,39242:20729,39243:20725,39244:20745,39245:20737,39246:20738,39247:20758,39248:20757,39249:20756,39250:20762,39251:20769,39252:20794,39253:20791,39254:20796,39255:20795,39256:20799,39257:20800,39258:20818,39259:20812,39260:20820,39261:20834,39262:31480,39263:20841,39264:20842,39265:20846,39266:20864,39267:20866,39268:22232,39269:20876,39270:20873,39271:20879,39272:20881,39273:20883,39274:20885,39275:20886,39276:20900,39277:20902,39278:20898,39279:20905,39280:20906,39281:20907,39282:20915,39283:20913,39284:20914,39285:20912,39286:20917,39287:20925,39288:20933,39289:20937,39290:20955,39291:20960,39292:34389,39293:20969,39294:20973,39296:20976,39297:20981,39298:20990,39299:20996,39300:21003,39301:21012,39302:21006,39303:21031,39304:21034,39305:21038,39306:21043,39307:21049,39308:21071,39309:21060,39310:21067,39311:21068,39312:21086,39313:21076,39314:21098,39315:21108,39316:21097,39317:21107,39318:21119,39319:21117,39320:21133,39321:21140,39322:21138,39323:21105,39324:21128,39325:21137,39326:36776,39327:36775,39328:21164,39329:21165,39330:21180,39331:21173,39332:21185,39333:21197,39334:21207,39335:21214,39336:21219,39337:21222,39338:39149,39339:21216,39340:21235,39341:21237,39342:21240,39343:21241,39344:21254,39345:21256,39346:30008,39347:21261,39348:21264,39349:21263,39350:21269,39351:21274,39352:21283,39353:21295,39354:21297,39355:21299,39356:21304,39357:21312,39358:21318,39359:21317,39360:19991,39361:21321,39362:21325,39363:20950,39364:21342,39365:21353,39366:21358,39367:22808,39368:21371,39369:21367,39370:21378,39371:21398,39372:21408,39373:21414,39374:21413,39375:21422,39376:21424,39377:21430,39378:21443,39379:31762,39380:38617,39381:21471,39382:26364,39383:29166,39384:21486,39385:21480,39386:21485,39387:21498,39388:21505,39389:21565,39390:21568,39391:21548,39392:21549,39393:21564,39394:21550,39395:21558,39396:21545,39397:21533,39398:21582,39399:21647,39400:21621,39401:21646,39402:21599,39403:21617,39404:21623,39405:21616,39406:21650,39407:21627,39408:21632,39409:21622,39410:21636,39411:21648,39412:21638,39413:21703,39414:21666,39415:21688,39416:21669,39417:21676,39418:21700,39419:21704,39420:21672,39488:21675,39489:21698,39490:21668,39491:21694,39492:21692,39493:21720,39494:21733,39495:21734,39496:21775,39497:21780,39498:21757,39499:21742,39500:21741,39501:21754,39502:21730,39503:21817,39504:21824,39505:21859,39506:21836,39507:21806,39508:21852,39509:21829,39510:21846,39511:21847,39512:21816,39513:21811,39514:21853,39515:21913,39516:21888,39517:21679,39518:21898,39519:21919,39520:21883,39521:21886,39522:21912,39523:21918,39524:21934,39525:21884,39526:21891,39527:21929,39528:21895,39529:21928,39530:21978,39531:21957,39532:21983,39533:21956,39534:21980,39535:21988,39536:21972,39537:22036,39538:22007,39539:22038,39540:22014,39541:22013,39542:22043,39543:22009,39544:22094,39545:22096,39546:29151,39547:22068,39548:22070,39549:22066,39550:22072,39552:22123,39553:22116,39554:22063,39555:22124,39556:22122,39557:22150,39558:22144,39559:22154,39560:22176,39561:22164,39562:22159,39563:22181,39564:22190,39565:22198,39566:22196,39567:22210,39568:22204,39569:22209,39570:22211,39571:22208,39572:22216,39573:22222,39574:22225,39575:22227,39576:22231,39577:22254,39578:22265,39579:22272,39580:22271,39581:22276,39582:22281,39583:22280,39584:22283,39585:22285,39586:22291,39587:22296,39588:22294,39589:21959,39590:22300,39591:22310,39592:22327,39593:22328,39594:22350,39595:22331,39596:22336,39597:22351,39598:22377,39599:22464,39600:22408,39601:22369,39602:22399,39603:22409,39604:22419,39605:22432,39606:22451,39607:22436,39608:22442,39609:22448,39610:22467,39611:22470,39612:22484,39613:22482,39614:22483,39615:22538,39616:22486,39617:22499,39618:22539,39619:22553,39620:22557,39621:22642,39622:22561,39623:22626,39624:22603,39625:22640,39626:27584,39627:22610,39628:22589,39629:22649,39630:22661,39631:22713,39632:22687,39633:22699,39634:22714,39635:22750,39636:22715,39637:22712,39638:22702,39639:22725,39640:22739,39641:22737,39642:22743,39643:22745,39644:22744,39645:22757,39646:22748,39647:22756,39648:22751,39649:22767,39650:22778,39651:22777,39652:22779,39653:22780,39654:22781,39655:22786,39656:22794,39657:22800,39658:22811,39659:26790,39660:22821,39661:22828,39662:22829,39663:22834,39664:22840,39665:22846,39666:31442,39667:22869,39668:22864,39669:22862,39670:22874,39671:22872,39672:22882,39673:22880,39674:22887,39675:22892,39676:22889,39744:22904,39745:22913,39746:22941,39747:20318,39748:20395,39749:22947,39750:22962,39751:22982,39752:23016,39753:23004,39754:22925,39755:23001,39756:23002,39757:23077,39758:23071,39759:23057,39760:23068,39761:23049,39762:23066,39763:23104,39764:23148,39765:23113,39766:23093,39767:23094,39768:23138,39769:23146,39770:23194,39771:23228,39772:23230,39773:23243,39774:23234,39775:23229,39776:23267,39777:23255,39778:23270,39779:23273,39780:23254,39781:23290,39782:23291,39783:23308,39784:23307,39785:23318,39786:23346,39787:23248,39788:23338,39789:23350,39790:23358,39791:23363,39792:23365,39793:23360,39794:23377,39795:23381,39796:23386,39797:23387,39798:23397,39799:23401,39800:23408,39801:23411,39802:23413,39803:23416,39804:25992,39805:23418,39806:23424,39808:23427,39809:23462,39810:23480,39811:23491,39812:23495,39813:23497,39814:23508,39815:23504,39816:23524,39817:23526,39818:23522,39819:23518,39820:23525,39821:23531,39822:23536,39823:23542,39824:23539,39825:23557,39826:23559,39827:23560,39828:23565,39829:23571,39830:23584,39831:23586,39832:23592,39833:23608,39834:23609,39835:23617,39836:23622,39837:23630,39838:23635,39839:23632,39840:23631,39841:23409,39842:23660,39843:23662,39844:20066,39845:23670,39846:23673,39847:23692,39848:23697,39849:23700,39850:22939,39851:23723,39852:23739,39853:23734,39854:23740,39855:23735,39856:23749,39857:23742,39858:23751,39859:23769,39860:23785,39861:23805,39862:23802,39863:23789,39864:23948,39865:23786,39866:23819,39867:23829,39868:23831,39869:23900,39870:23839,39871:23835,39872:23825,39873:23828,39874:23842,39875:23834,39876:23833,39877:23832,39878:23884,39879:23890,39880:23886,39881:23883,39882:23916,39883:23923,39884:23926,39885:23943,39886:23940,39887:23938,39888:23970,39889:23965,39890:23980,39891:23982,39892:23997,39893:23952,39894:23991,39895:23996,39896:24009,39897:24013,39898:24019,39899:24018,39900:24022,39901:24027,39902:24043,39903:24050,39904:24053,39905:24075,39906:24090,39907:24089,39908:24081,39909:24091,39910:24118,39911:24119,39912:24132,39913:24131,39914:24128,39915:24142,39916:24151,39917:24148,39918:24159,39919:24162,39920:24164,39921:24135,39922:24181,39923:24182,39924:24186,39925:40636,39926:24191,39927:24224,39928:24257,39929:24258,39930:24264,39931:24272,39932:24271,4e4:24278,40001:24291,40002:24285,40003:24282,40004:24283,40005:24290,40006:24289,40007:24296,40008:24297,40009:24300,40010:24305,40011:24307,40012:24304,40013:24308,40014:24312,40015:24318,40016:24323,40017:24329,40018:24413,40019:24412,40020:24331,40021:24337,40022:24342,40023:24361,40024:24365,40025:24376,40026:24385,40027:24392,40028:24396,40029:24398,40030:24367,40031:24401,40032:24406,40033:24407,40034:24409,40035:24417,40036:24429,40037:24435,40038:24439,40039:24451,40040:24450,40041:24447,40042:24458,40043:24456,40044:24465,40045:24455,40046:24478,40047:24473,40048:24472,40049:24480,40050:24488,40051:24493,40052:24508,40053:24534,40054:24571,40055:24548,40056:24568,40057:24561,40058:24541,40059:24755,40060:24575,40061:24609,40062:24672,40064:24601,40065:24592,40066:24617,40067:24590,40068:24625,40069:24603,40070:24597,40071:24619,40072:24614,40073:24591,40074:24634,40075:24666,40076:24641,40077:24682,40078:24695,40079:24671,40080:24650,40081:24646,40082:24653,40083:24675,40084:24643,40085:24676,40086:24642,40087:24684,40088:24683,40089:24665,40090:24705,40091:24717,40092:24807,40093:24707,40094:24730,40095:24708,40096:24731,40097:24726,40098:24727,40099:24722,40100:24743,40101:24715,40102:24801,40103:24760,40104:24800,40105:24787,40106:24756,40107:24560,40108:24765,40109:24774,40110:24757,40111:24792,40112:24909,40113:24853,40114:24838,40115:24822,40116:24823,40117:24832,40118:24820,40119:24826,40120:24835,40121:24865,40122:24827,40123:24817,40124:24845,40125:24846,40126:24903,40127:24894,40128:24872,40129:24871,40130:24906,40131:24895,40132:24892,40133:24876,40134:24884,40135:24893,40136:24898,40137:24900,40138:24947,40139:24951,40140:24920,40141:24921,40142:24922,40143:24939,40144:24948,40145:24943,40146:24933,40147:24945,40148:24927,40149:24925,40150:24915,40151:24949,40152:24985,40153:24982,40154:24967,40155:25004,40156:24980,40157:24986,40158:24970,40159:24977,40160:25003,40161:25006,40162:25036,40163:25034,40164:25033,40165:25079,40166:25032,40167:25027,40168:25030,40169:25018,40170:25035,40171:32633,40172:25037,40173:25062,40174:25059,40175:25078,40176:25082,40177:25076,40178:25087,40179:25085,40180:25084,40181:25086,40182:25088,40183:25096,40184:25097,40185:25101,40186:25100,40187:25108,40188:25115,40256:25118,40257:25121,40258:25130,40259:25134,40260:25136,40261:25138,40262:25139,40263:25153,40264:25166,40265:25182,40266:25187,40267:25179,40268:25184,40269:25192,40270:25212,40271:25218,40272:25225,40273:25214,40274:25234,40275:25235,40276:25238,40277:25300,40278:25219,40279:25236,40280:25303,40281:25297,40282:25275,40283:25295,40284:25343,40285:25286,40286:25812,40287:25288,40288:25308,40289:25292,40290:25290,40291:25282,40292:25287,40293:25243,40294:25289,40295:25356,40296:25326,40297:25329,40298:25383,40299:25346,40300:25352,40301:25327,40302:25333,40303:25424,40304:25406,40305:25421,40306:25628,40307:25423,40308:25494,40309:25486,40310:25472,40311:25515,40312:25462,40313:25507,40314:25487,40315:25481,40316:25503,40317:25525,40318:25451,40320:25449,40321:25534,40322:25577,40323:25536,40324:25542,40325:25571,40326:25545,40327:25554,40328:25590,40329:25540,40330:25622,40331:25652,40332:25606,40333:25619,40334:25638,40335:25654,40336:25885,40337:25623,40338:25640,40339:25615,40340:25703,40341:25711,40342:25718,40343:25678,40344:25898,40345:25749,40346:25747,40347:25765,40348:25769,40349:25736,40350:25788,40351:25818,40352:25810,40353:25797,40354:25799,40355:25787,40356:25816,40357:25794,40358:25841,40359:25831,40360:33289,40361:25824,40362:25825,40363:25260,40364:25827,40365:25839,40366:25900,40367:25846,40368:25844,40369:25842,40370:25850,40371:25856,40372:25853,40373:25880,40374:25884,40375:25861,40376:25892,40377:25891,40378:25899,40379:25908,40380:25909,40381:25911,40382:25910,40383:25912,40384:30027,40385:25928,40386:25942,40387:25941,40388:25933,40389:25944,40390:25950,40391:25949,40392:25970,40393:25976,40394:25986,40395:25987,40396:35722,40397:26011,40398:26015,40399:26027,40400:26039,40401:26051,40402:26054,40403:26049,40404:26052,40405:26060,40406:26066,40407:26075,40408:26073,40409:26080,40410:26081,40411:26097,40412:26482,40413:26122,40414:26115,40415:26107,40416:26483,40417:26165,40418:26166,40419:26164,40420:26140,40421:26191,40422:26180,40423:26185,40424:26177,40425:26206,40426:26205,40427:26212,40428:26215,40429:26216,40430:26207,40431:26210,40432:26224,40433:26243,40434:26248,40435:26254,40436:26249,40437:26244,40438:26264,40439:26269,40440:26305,40441:26297,40442:26313,40443:26302,40444:26300,40512:26308,40513:26296,40514:26326,40515:26330,40516:26336,40517:26175,40518:26342,40519:26345,40520:26352,40521:26357,40522:26359,40523:26383,40524:26390,40525:26398,40526:26406,40527:26407,40528:38712,40529:26414,40530:26431,40531:26422,40532:26433,40533:26424,40534:26423,40535:26438,40536:26462,40537:26464,40538:26457,40539:26467,40540:26468,40541:26505,40542:26480,40543:26537,40544:26492,40545:26474,40546:26508,40547:26507,40548:26534,40549:26529,40550:26501,40551:26551,40552:26607,40553:26548,40554:26604,40555:26547,40556:26601,40557:26552,40558:26596,40559:26590,40560:26589,40561:26594,40562:26606,40563:26553,40564:26574,40565:26566,40566:26599,40567:27292,40568:26654,40569:26694,40570:26665,40571:26688,40572:26701,40573:26674,40574:26702,40576:26803,40577:26667,40578:26713,40579:26723,40580:26743,40581:26751,40582:26783,40583:26767,40584:26797,40585:26772,40586:26781,40587:26779,40588:26755,40589:27310,40590:26809,40591:26740,40592:26805,40593:26784,40594:26810,40595:26895,40596:26765,40597:26750,40598:26881,40599:26826,40600:26888,40601:26840,40602:26914,40603:26918,40604:26849,40605:26892,40606:26829,40607:26836,40608:26855,40609:26837,40610:26934,40611:26898,40612:26884,40613:26839,40614:26851,40615:26917,40616:26873,40617:26848,40618:26863,40619:26920,40620:26922,40621:26906,40622:26915,40623:26913,40624:26822,40625:27001,40626:26999,40627:26972,40628:27e3,40629:26987,40630:26964,40631:27006,40632:26990,40633:26937,40634:26996,40635:26941,40636:26969,40637:26928,40638:26977,40639:26974,40640:26973,40641:27009,40642:26986,40643:27058,40644:27054,40645:27088,40646:27071,40647:27073,40648:27091,40649:27070,40650:27086,40651:23528,40652:27082,40653:27101,40654:27067,40655:27075,40656:27047,40657:27182,40658:27025,40659:27040,40660:27036,40661:27029,40662:27060,40663:27102,40664:27112,40665:27138,40666:27163,40667:27135,40668:27402,40669:27129,40670:27122,40671:27111,40672:27141,40673:27057,40674:27166,40675:27117,40676:27156,40677:27115,40678:27146,40679:27154,40680:27329,40681:27171,40682:27155,40683:27204,40684:27148,40685:27250,40686:27190,40687:27256,40688:27207,40689:27234,40690:27225,40691:27238,40692:27208,40693:27192,40694:27170,40695:27280,40696:27277,40697:27296,40698:27268,40699:27298,40700:27299,40768:27287,40769:34327,40770:27323,40771:27331,40772:27330,40773:27320,40774:27315,40775:27308,40776:27358,40777:27345,40778:27359,40779:27306,40780:27354,40781:27370,40782:27387,40783:27397,40784:34326,40785:27386,40786:27410,40787:27414,40788:39729,40789:27423,40790:27448,40791:27447,40792:30428,40793:27449,40794:39150,40795:27463,40796:27459,40797:27465,40798:27472,40799:27481,40800:27476,40801:27483,40802:27487,40803:27489,40804:27512,40805:27513,40806:27519,40807:27520,40808:27524,40809:27523,40810:27533,40811:27544,40812:27541,40813:27550,40814:27556,40815:27562,40816:27563,40817:27567,40818:27570,40819:27569,40820:27571,40821:27575,40822:27580,40823:27590,40824:27595,40825:27603,40826:27615,40827:27628,40828:27627,40829:27635,40830:27631,40832:40638,40833:27656,40834:27667,40835:27668,40836:27675,40837:27684,40838:27683,40839:27742,40840:27733,40841:27746,40842:27754,40843:27778,40844:27789,40845:27802,40846:27777,40847:27803,40848:27774,40849:27752,40850:27763,40851:27794,40852:27792,40853:27844,40854:27889,40855:27859,40856:27837,40857:27863,40858:27845,40859:27869,40860:27822,40861:27825,40862:27838,40863:27834,40864:27867,40865:27887,40866:27865,40867:27882,40868:27935,40869:34893,40870:27958,40871:27947,40872:27965,40873:27960,40874:27929,40875:27957,40876:27955,40877:27922,40878:27916,40879:28003,40880:28051,40881:28004,40882:27994,40883:28025,40884:27993,40885:28046,40886:28053,40887:28644,40888:28037,40889:28153,40890:28181,40891:28170,40892:28085,40893:28103,40894:28134,40895:28088,40896:28102,40897:28140,40898:28126,40899:28108,40900:28136,40901:28114,40902:28101,40903:28154,40904:28121,40905:28132,40906:28117,40907:28138,40908:28142,40909:28205,40910:28270,40911:28206,40912:28185,40913:28274,40914:28255,40915:28222,40916:28195,40917:28267,40918:28203,40919:28278,40920:28237,40921:28191,40922:28227,40923:28218,40924:28238,40925:28196,40926:28415,40927:28189,40928:28216,40929:28290,40930:28330,40931:28312,40932:28361,40933:28343,40934:28371,40935:28349,40936:28335,40937:28356,40938:28338,40939:28372,40940:28373,40941:28303,40942:28325,40943:28354,40944:28319,40945:28481,40946:28433,40947:28748,40948:28396,40949:28408,40950:28414,40951:28479,40952:28402,40953:28465,40954:28399,40955:28466,40956:28364,57408:28478,57409:28435,57410:28407,57411:28550,57412:28538,57413:28536,57414:28545,57415:28544,57416:28527,57417:28507,57418:28659,57419:28525,57420:28546,57421:28540,57422:28504,57423:28558,57424:28561,57425:28610,57426:28518,57427:28595,57428:28579,57429:28577,57430:28580,57431:28601,57432:28614,57433:28586,57434:28639,57435:28629,57436:28652,57437:28628,57438:28632,57439:28657,57440:28654,57441:28635,57442:28681,57443:28683,57444:28666,57445:28689,57446:28673,57447:28687,57448:28670,57449:28699,57450:28698,57451:28532,57452:28701,57453:28696,57454:28703,57455:28720,57456:28734,57457:28722,57458:28753,57459:28771,57460:28825,57461:28818,57462:28847,57463:28913,57464:28844,57465:28856,57466:28851,57467:28846,57468:28895,57469:28875,57470:28893,57472:28889,57473:28937,57474:28925,57475:28956,57476:28953,57477:29029,57478:29013,57479:29064,57480:29030,57481:29026,57482:29004,57483:29014,57484:29036,57485:29071,57486:29179,57487:29060,57488:29077,57489:29096,57490:29100,57491:29143,57492:29113,57493:29118,57494:29138,57495:29129,57496:29140,57497:29134,57498:29152,57499:29164,57500:29159,57501:29173,57502:29180,57503:29177,57504:29183,57505:29197,57506:29200,57507:29211,57508:29224,57509:29229,57510:29228,57511:29232,57512:29234,57513:29243,57514:29244,57515:29247,57516:29248,57517:29254,57518:29259,57519:29272,57520:29300,57521:29310,57522:29314,57523:29313,57524:29319,57525:29330,57526:29334,57527:29346,57528:29351,57529:29369,57530:29362,57531:29379,57532:29382,57533:29380,57534:29390,57535:29394,57536:29410,57537:29408,57538:29409,57539:29433,57540:29431,57541:20495,57542:29463,57543:29450,57544:29468,57545:29462,57546:29469,57547:29492,57548:29487,57549:29481,57550:29477,57551:29502,57552:29518,57553:29519,57554:40664,57555:29527,57556:29546,57557:29544,57558:29552,57559:29560,57560:29557,57561:29563,57562:29562,57563:29640,57564:29619,57565:29646,57566:29627,57567:29632,57568:29669,57569:29678,57570:29662,57571:29858,57572:29701,57573:29807,57574:29733,57575:29688,57576:29746,57577:29754,57578:29781,57579:29759,57580:29791,57581:29785,57582:29761,57583:29788,57584:29801,57585:29808,57586:29795,57587:29802,57588:29814,57589:29822,57590:29835,57591:29854,57592:29863,57593:29898,57594:29903,57595:29908,57596:29681,57664:29920,57665:29923,57666:29927,57667:29929,57668:29934,57669:29938,57670:29936,57671:29937,57672:29944,57673:29943,57674:29956,57675:29955,57676:29957,57677:29964,57678:29966,57679:29965,57680:29973,57681:29971,57682:29982,57683:29990,57684:29996,57685:30012,57686:30020,57687:30029, 57688:30026,57689:30025,57690:30043,57691:30022,57692:30042,57693:30057,57694:30052,57695:30055,57696:30059,57697:30061,57698:30072,57699:30070,57700:30086,57701:30087,57702:30068,57703:30090,57704:30089,57705:30082,57706:30100,57707:30106,57708:30109,57709:30117,57710:30115,57711:30146,57712:30131,57713:30147,57714:30133,57715:30141,57716:30136,57717:30140,57718:30129,57719:30157,57720:30154,57721:30162,57722:30169,57723:30179,57724:30174,57725:30206,57726:30207,57728:30204,57729:30209,57730:30192,57731:30202,57732:30194,57733:30195,57734:30219,57735:30221,57736:30217,57737:30239,57738:30247,57739:30240,57740:30241,57741:30242,57742:30244,57743:30260,57744:30256,57745:30267,57746:30279,57747:30280,57748:30278,57749:30300,57750:30296,57751:30305,57752:30306,57753:30312,57754:30313,57755:30314,57756:30311,57757:30316,57758:30320,57759:30322,57760:30326,57761:30328,57762:30332,57763:30336,57764:30339,57765:30344,57766:30347,57767:30350,57768:30358,57769:30355,57770:30361,57771:30362,57772:30384,57773:30388,57774:30392,57775:30393,57776:30394,57777:30402,57778:30413,57779:30422,57780:30418,57781:30430,57782:30433,57783:30437,57784:30439,57785:30442,57786:34351,57787:30459,57788:30472,57789:30471,57790:30468,57791:30505,57792:30500,57793:30494,57794:30501,57795:30502,57796:30491,57797:30519,57798:30520,57799:30535,57800:30554,57801:30568,57802:30571,57803:30555,57804:30565,57805:30591,57806:30590,57807:30585,57808:30606,57809:30603,57810:30609,57811:30624,57812:30622,57813:30640,57814:30646,57815:30649,57816:30655,57817:30652,57818:30653,57819:30651,57820:30663,57821:30669,57822:30679,57823:30682,57824:30684,57825:30691,57826:30702,57827:30716,57828:30732,57829:30738,57830:31014,57831:30752,57832:31018,57833:30789,57834:30862,57835:30836,57836:30854,57837:30844,57838:30874,57839:30860,57840:30883,57841:30901,57842:30890,57843:30895,57844:30929,57845:30918,57846:30923,57847:30932,57848:30910,57849:30908,57850:30917,57851:30922,57852:30956,57920:30951,57921:30938,57922:30973,57923:30964,57924:30983,57925:30994,57926:30993,57927:31001,57928:31020,57929:31019,57930:31040,57931:31072,57932:31063,57933:31071,57934:31066,57935:31061,57936:31059,57937:31098,57938:31103,57939:31114,57940:31133,57941:31143,57942:40779,57943:31146,57944:31150,57945:31155,57946:31161,57947:31162,57948:31177,57949:31189,57950:31207,57951:31212,57952:31201,57953:31203,57954:31240,57955:31245,57956:31256,57957:31257,57958:31264,57959:31263,57960:31104,57961:31281,57962:31291,57963:31294,57964:31287,57965:31299,57966:31319,57967:31305,57968:31329,57969:31330,57970:31337,57971:40861,57972:31344,57973:31353,57974:31357,57975:31368,57976:31383,57977:31381,57978:31384,57979:31382,57980:31401,57981:31432,57982:31408,57984:31414,57985:31429,57986:31428,57987:31423,57988:36995,57989:31431,57990:31434,57991:31437,57992:31439,57993:31445,57994:31443,57995:31449,57996:31450,57997:31453,57998:31457,57999:31458,58e3:31462,58001:31469,58002:31472,58003:31490,58004:31503,58005:31498,58006:31494,58007:31539,58008:31512,58009:31513,58010:31518,58011:31541,58012:31528,58013:31542,58014:31568,58015:31610,58016:31492,58017:31565,58018:31499,58019:31564,58020:31557,58021:31605,58022:31589,58023:31604,58024:31591,58025:31600,58026:31601,58027:31596,58028:31598,58029:31645,58030:31640,58031:31647,58032:31629,58033:31644,58034:31642,58035:31627,58036:31634,58037:31631,58038:31581,58039:31641,58040:31691,58041:31681,58042:31692,58043:31695,58044:31668,58045:31686,58046:31709,58047:31721,58048:31761,58049:31764,58050:31718,58051:31717,58052:31840,58053:31744,58054:31751,58055:31763,58056:31731,58057:31735,58058:31767,58059:31757,58060:31734,58061:31779,58062:31783,58063:31786,58064:31775,58065:31799,58066:31787,58067:31805,58068:31820,58069:31811,58070:31828,58071:31823,58072:31808,58073:31824,58074:31832,58075:31839,58076:31844,58077:31830,58078:31845,58079:31852,58080:31861,58081:31875,58082:31888,58083:31908,58084:31917,58085:31906,58086:31915,58087:31905,58088:31912,58089:31923,58090:31922,58091:31921,58092:31918,58093:31929,58094:31933,58095:31936,58096:31941,58097:31938,58098:31960,58099:31954,58100:31964,58101:31970,58102:39739,58103:31983,58104:31986,58105:31988,58106:31990,58107:31994,58108:32006,58176:32002,58177:32028,58178:32021,58179:32010,58180:32069,58181:32075,58182:32046,58183:32050,58184:32063,58185:32053,58186:32070,58187:32115,58188:32086,58189:32078,58190:32114,58191:32104,58192:32110,58193:32079,58194:32099,58195:32147,58196:32137,58197:32091,58198:32143,58199:32125,58200:32155,58201:32186,58202:32174,58203:32163,58204:32181,58205:32199,58206:32189,58207:32171,58208:32317,58209:32162,58210:32175,58211:32220,58212:32184,58213:32159,58214:32176,58215:32216,58216:32221,58217:32228,58218:32222,58219:32251,58220:32242,58221:32225,58222:32261,58223:32266,58224:32291,58225:32289,58226:32274,58227:32305,58228:32287,58229:32265,58230:32267,58231:32290,58232:32326,58233:32358,58234:32315,58235:32309,58236:32313,58237:32323,58238:32311,58240:32306,58241:32314,58242:32359,58243:32349,58244:32342,58245:32350,58246:32345,58247:32346,58248:32377,58249:32362,58250:32361,58251:32380,58252:32379,58253:32387,58254:32213,58255:32381,58256:36782,58257:32383,58258:32392,58259:32393,58260:32396,58261:32402,58262:32400,58263:32403,58264:32404,58265:32406,58266:32398,58267:32411,58268:32412,58269:32568,58270:32570,58271:32581,58272:32588,58273:32589,58274:32590,58275:32592,58276:32593,58277:32597,58278:32596,58279:32600,58280:32607,58281:32608,58282:32616,58283:32617,58284:32615,58285:32632,58286:32642,58287:32646,58288:32643,58289:32648,58290:32647,58291:32652,58292:32660,58293:32670,58294:32669,58295:32666,58296:32675,58297:32687,58298:32690,58299:32697,58300:32686,58301:32694,58302:32696,58303:35697,58304:32709,58305:32710,58306:32714,58307:32725,58308:32724,58309:32737,58310:32742,58311:32745,58312:32755,58313:32761,58314:39132,58315:32774,58316:32772,58317:32779,58318:32786,58319:32792,58320:32793,58321:32796,58322:32801,58323:32808,58324:32831,58325:32827,58326:32842,58327:32838,58328:32850,58329:32856,58330:32858,58331:32863,58332:32866,58333:32872,58334:32883,58335:32882,58336:32880,58337:32886,58338:32889,58339:32893,58340:32895,58341:32900,58342:32902,58343:32901,58344:32923,58345:32915,58346:32922,58347:32941,58348:20880,58349:32940,58350:32987,58351:32997,58352:32985,58353:32989,58354:32964,58355:32986,58356:32982,58357:33033,58358:33007,58359:33009,58360:33051,58361:33065,58362:33059,58363:33071,58364:33099,58432:38539,58433:33094,58434:33086,58435:33107,58436:33105,58437:33020,58438:33137,58439:33134,58440:33125,58441:33126,58442:33140,58443:33155,58444:33160,58445:33162,58446:33152,58447:33154,58448:33184,58449:33173,58450:33188,58451:33187,58452:33119,58453:33171,58454:33193,58455:33200,58456:33205,58457:33214,58458:33208,58459:33213,58460:33216,58461:33218,58462:33210,58463:33225,58464:33229,58465:33233,58466:33241,58467:33240,58468:33224,58469:33242,58470:33247,58471:33248,58472:33255,58473:33274,58474:33275,58475:33278,58476:33281,58477:33282,58478:33285,58479:33287,58480:33290,58481:33293,58482:33296,58483:33302,58484:33321,58485:33323,58486:33336,58487:33331,58488:33344,58489:33369,58490:33368,58491:33373,58492:33370,58493:33375,58494:33380,58496:33378,58497:33384,58498:33386,58499:33387,58500:33326,58501:33393,58502:33399,58503:33400,58504:33406,58505:33421,58506:33426,58507:33451,58508:33439,58509:33467,58510:33452,58511:33505,58512:33507,58513:33503,58514:33490,58515:33524,58516:33523,58517:33530,58518:33683,58519:33539,58520:33531,58521:33529,58522:33502,58523:33542,58524:33500,58525:33545,58526:33497,58527:33589,58528:33588,58529:33558,58530:33586,58531:33585,58532:33600,58533:33593,58534:33616,58535:33605,58536:33583,58537:33579,58538:33559,58539:33560,58540:33669,58541:33690,58542:33706,58543:33695,58544:33698,58545:33686,58546:33571,58547:33678,58548:33671,58549:33674,58550:33660,58551:33717,58552:33651,58553:33653,58554:33696,58555:33673,58556:33704,58557:33780,58558:33811,58559:33771,58560:33742,58561:33789,58562:33795,58563:33752,58564:33803,58565:33729,58566:33783,58567:33799,58568:33760,58569:33778,58570:33805,58571:33826,58572:33824,58573:33725,58574:33848,58575:34054,58576:33787,58577:33901,58578:33834,58579:33852,58580:34138,58581:33924,58582:33911,58583:33899,58584:33965,58585:33902,58586:33922,58587:33897,58588:33862,58589:33836,58590:33903,58591:33913,58592:33845,58593:33994,58594:33890,58595:33977,58596:33983,58597:33951,58598:34009,58599:33997,58600:33979,58601:34010,58602:34e3,58603:33985,58604:33990,58605:34006,58606:33953,58607:34081,58608:34047,58609:34036,58610:34071,58611:34072,58612:34092,58613:34079,58614:34069,58615:34068,58616:34044,58617:34112,58618:34147,58619:34136,58620:34120,58688:34113,58689:34306,58690:34123,58691:34133,58692:34176,58693:34212,58694:34184,58695:34193,58696:34186,58697:34216,58698:34157,58699:34196,58700:34203,58701:34282,58702:34183,58703:34204,58704:34167,58705:34174,58706:34192,58707:34249,58708:34234,58709:34255,58710:34233,58711:34256,58712:34261,58713:34269,58714:34277,58715:34268,58716:34297,58717:34314,58718:34323,58719:34315,58720:34302,58721:34298,58722:34310,58723:34338,58724:34330,58725:34352,58726:34367,58727:34381,58728:20053,58729:34388,58730:34399,58731:34407,58732:34417,58733:34451,58734:34467,58735:34473,58736:34474,58737:34443,58738:34444,58739:34486,58740:34479,58741:34500,58742:34502,58743:34480,58744:34505,58745:34851,58746:34475,58747:34516,58748:34526,58749:34537,58750:34540,58752:34527,58753:34523,58754:34543,58755:34578,58756:34566,58757:34568,58758:34560,58759:34563,58760:34555,58761:34577,58762:34569,58763:34573,58764:34553,58765:34570,58766:34612,58767:34623,58768:34615,58769:34619,58770:34597,58771:34601,58772:34586,58773:34656,58774:34655,58775:34680,58776:34636,58777:34638,58778:34676,58779:34647,58780:34664,58781:34670,58782:34649,58783:34643,58784:34659,58785:34666,58786:34821,58787:34722,58788:34719,58789:34690,58790:34735,58791:34763,58792:34749,58793:34752,58794:34768,58795:38614,58796:34731,58797:34756,58798:34739,58799:34759,58800:34758,58801:34747,58802:34799,58803:34802,58804:34784,58805:34831,58806:34829,58807:34814,58808:34806,58809:34807,58810:34830,58811:34770,58812:34833,58813:34838,58814:34837,58815:34850,58816:34849,58817:34865,58818:34870,58819:34873,58820:34855,58821:34875,58822:34884,58823:34882,58824:34898,58825:34905,58826:34910,58827:34914,58828:34923,58829:34945,58830:34942,58831:34974,58832:34933,58833:34941,58834:34997,58835:34930,58836:34946,58837:34967,58838:34962,58839:34990,58840:34969,58841:34978,58842:34957,58843:34980,58844:34992,58845:35007,58846:34993,58847:35011,58848:35012,58849:35028,58850:35032,58851:35033,58852:35037,58853:35065,58854:35074,58855:35068,58856:35060,58857:35048,58858:35058,58859:35076,58860:35084,58861:35082,58862:35091,58863:35139,58864:35102,58865:35109,58866:35114,58867:35115,58868:35137,58869:35140,58870:35131,58871:35126,58872:35128,58873:35148,58874:35101,58875:35168,58876:35166,58944:35174,58945:35172,58946:35181,58947:35178,58948:35183,58949:35188,58950:35191,58951:35198,58952:35203,58953:35208,58954:35210,58955:35219,58956:35224,58957:35233,58958:35241,58959:35238,58960:35244,58961:35247,58962:35250,58963:35258,58964:35261,58965:35263,58966:35264,58967:35290,58968:35292,58969:35293,58970:35303,58971:35316,58972:35320,58973:35331,58974:35350,58975:35344,58976:35340,58977:35355,58978:35357,58979:35365,58980:35382,58981:35393,58982:35419,58983:35410,58984:35398,58985:35400,58986:35452,58987:35437,58988:35436,58989:35426,58990:35461,58991:35458,58992:35460,58993:35496,58994:35489,58995:35473,58996:35493,58997:35494,58998:35482,58999:35491,59e3:35524,59001:35533,59002:35522,59003:35546,59004:35563,59005:35571,59006:35559,59008:35556,59009:35569,59010:35604,59011:35552,59012:35554,59013:35575,59014:35550,59015:35547,59016:35596,59017:35591,59018:35610,59019:35553,59020:35606,59021:35600,59022:35607,59023:35616,59024:35635,59025:38827,59026:35622,59027:35627,59028:35646,59029:35624,59030:35649,59031:35660,59032:35663,59033:35662,59034:35657,59035:35670,59036:35675,59037:35674,59038:35691,59039:35679,59040:35692,59041:35695,59042:35700,59043:35709,59044:35712,59045:35724,59046:35726,59047:35730,59048:35731,59049:35734,59050:35737,59051:35738,59052:35898,59053:35905,59054:35903,59055:35912,59056:35916,59057:35918,59058:35920,59059:35925,59060:35938,59061:35948,59062:35960,59063:35962,59064:35970,59065:35977,59066:35973,59067:35978,59068:35981,59069:35982,59070:35988,59071:35964,59072:35992,59073:25117,59074:36013,59075:36010,59076:36029,59077:36018,59078:36019,59079:36014,59080:36022,59081:36040,59082:36033,59083:36068,59084:36067,59085:36058,59086:36093,59087:36090,59088:36091,59089:36100,59090:36101,59091:36106,59092:36103,59093:36111,59094:36109,59095:36112,59096:40782,59097:36115,59098:36045,59099:36116,59100:36118,59101:36199,59102:36205,59103:36209,59104:36211,59105:36225,59106:36249,59107:36290,59108:36286,59109:36282,59110:36303,59111:36314,59112:36310,59113:36300,59114:36315,59115:36299,59116:36330,59117:36331,59118:36319,59119:36323,59120:36348,59121:36360,59122:36361,59123:36351,59124:36381,59125:36382,59126:36368,59127:36383,59128:36418,59129:36405,59130:36400,59131:36404,59132:36426,59200:36423,59201:36425,59202:36428,59203:36432,59204:36424,59205:36441,59206:36452,59207:36448,59208:36394,59209:36451,59210:36437,59211:36470,59212:36466,59213:36476,59214:36481,59215:36487,59216:36485,59217:36484,59218:36491,59219:36490,59220:36499,59221:36497,59222:36500,59223:36505,59224:36522,59225:36513,59226:36524,59227:36528,59228:36550,59229:36529,59230:36542,59231:36549,59232:36552,59233:36555,59234:36571,59235:36579,59236:36604,59237:36603,59238:36587,59239:36606,59240:36618,59241:36613,59242:36629,59243:36626,59244:36633,59245:36627,59246:36636,59247:36639,59248:36635,59249:36620,59250:36646,59251:36659,59252:36667,59253:36665,59254:36677,59255:36674,59256:36670,59257:36684,59258:36681,59259:36678,59260:36686,59261:36695,59262:36700,59264:36706,59265:36707,59266:36708,59267:36764,59268:36767,59269:36771,59270:36781,59271:36783,59272:36791,59273:36826,59274:36837,59275:36834,59276:36842,59277:36847,59278:36999,59279:36852,59280:36869,59281:36857,59282:36858,59283:36881,59284:36885,59285:36897,59286:36877,59287:36894,59288:36886,59289:36875,59290:36903,59291:36918,59292:36917,59293:36921,59294:36856,59295:36943,59296:36944,59297:36945,59298:36946,59299:36878,59300:36937,59301:36926,59302:36950,59303:36952,59304:36958,59305:36968,59306:36975,59307:36982,59308:38568,59309:36978,59310:36994,59311:36989,59312:36993,59313:36992,59314:37002,59315:37001,59316:37007,59317:37032,59318:37039,59319:37041,59320:37045,59321:37090,59322:37092,59323:25160,59324:37083,59325:37122,59326:37138,59327:37145,59328:37170,59329:37168,59330:37194,59331:37206,59332:37208,59333:37219,59334:37221,59335:37225,59336:37235,59337:37234,59338:37259,59339:37257,59340:37250,59341:37282,59342:37291,59343:37295,59344:37290,59345:37301,59346:37300,59347:37306,59348:37312,59349:37313,59350:37321,59351:37323,59352:37328,59353:37334,59354:37343,59355:37345,59356:37339,59357:37372,59358:37365,59359:37366,59360:37406,59361:37375,59362:37396,59363:37420,59364:37397,59365:37393,59366:37470,59367:37463,59368:37445,59369:37449,59370:37476,59371:37448,59372:37525,59373:37439,59374:37451,59375:37456,59376:37532,59377:37526,59378:37523,59379:37531,59380:37466,59381:37583,59382:37561,59383:37559,59384:37609,59385:37647,59386:37626,59387:37700,59388:37678,59456:37657,59457:37666,59458:37658,59459:37667,59460:37690,59461:37685,59462:37691,59463:37724,59464:37728,59465:37756,59466:37742,59467:37718,59468:37808,59469:37804,59470:37805,59471:37780,59472:37817,59473:37846,59474:37847,59475:37864,59476:37861,59477:37848,59478:37827,59479:37853,59480:37840,59481:37832,59482:37860,59483:37914,59484:37908,59485:37907,59486:37891,59487:37895,59488:37904,59489:37942,59490:37931,59491:37941,59492:37921,59493:37946,59494:37953,59495:37970,59496:37956,59497:37979,59498:37984,59499:37986,59500:37982,59501:37994,59502:37417,59503:38e3,59504:38005,59505:38007,59506:38013,59507:37978,59508:38012,59509:38014,59510:38017,59511:38015,59512:38274,59513:38279,59514:38282,59515:38292,59516:38294,59517:38296,59518:38297,59520:38304,59521:38312,59522:38311,59523:38317,59524:38332,59525:38331,59526:38329,59527:38334,59528:38346,59529:28662,59530:38339,59531:38349,59532:38348,59533:38357,59534:38356,59535:38358,59536:38364,59537:38369,59538:38373,59539:38370,59540:38433,59541:38440,59542:38446,59543:38447,59544:38466,59545:38476,59546:38479,59547:38475,59548:38519,59549:38492,59550:38494,59551:38493,59552:38495,59553:38502,59554:38514,59555:38508,59556:38541,59557:38552,59558:38549,59559:38551,59560:38570,59561:38567,59562:38577,59563:38578,59564:38576,59565:38580,59566:38582,59567:38584,59568:38585,59569:38606,59570:38603,59571:38601,59572:38605,59573:35149,59574:38620,59575:38669,59576:38613,59577:38649,59578:38660,59579:38662,59580:38664,59581:38675,59582:38670,59583:38673,59584:38671,59585:38678,59586:38681,59587:38692,59588:38698,59589:38704,59590:38713,59591:38717,59592:38718,59593:38724,59594:38726,59595:38728,59596:38722,59597:38729,59598:38748,59599:38752,59600:38756,59601:38758,59602:38760,59603:21202,59604:38763,59605:38769,59606:38777,59607:38789,59608:38780,59609:38785,59610:38778,59611:38790,59612:38795,59613:38799,59614:38800,59615:38812,59616:38824,59617:38822,59618:38819,59619:38835,59620:38836,59621:38851,59622:38854,59623:38856,59624:38859,59625:38876,59626:38893,59627:40783,59628:38898,59629:31455,59630:38902,59631:38901,59632:38927,59633:38924,59634:38968,59635:38948,59636:38945,59637:38967,59638:38973,59639:38982,59640:38991,59641:38987,59642:39019,59643:39023,59644:39024,59712:39025,59713:39028,59714:39027,59715:39082,59716:39087,59717:39089,59718:39094,59719:39108,59720:39107,59721:39110,59722:39145,59723:39147,59724:39171,59725:39177,59726:39186,59727:39188,59728:39192,59729:39201,59730:39197,59731:39198,59732:39204,59733:39200,59734:39212,59735:39214,59736:39229,59737:39230,59738:39234,59739:39241,59740:39237,59741:39248,59742:39243,59743:39249,59744:39250,59745:39244,59746:39253,59747:39319,59748:39320,59749:39333,59750:39341,59751:39342,59752:39356,59753:39391,59754:39387,59755:39389,59756:39384,59757:39377,59758:39405,59759:39406,59760:39409,59761:39410,59762:39419,59763:39416,59764:39425,59765:39439,59766:39429,59767:39394,59768:39449,59769:39467,59770:39479,59771:39493,59772:39490,59773:39488,59774:39491,59776:39486,59777:39509,59778:39501,59779:39515,59780:39511,59781:39519,59782:39522,59783:39525,59784:39524,59785:39529,59786:39531,59787:39530,59788:39597,59789:39600,59790:39612,59791:39616,59792:39631,59793:39633,59794:39635,59795:39636,59796:39646,59797:39647,59798:39650,59799:39651,59800:39654,59801:39663,59802:39659,59803:39662,59804:39668,59805:39665,59806:39671,59807:39675,59808:39686,59809:39704,59810:39706,59811:39711,59812:39714,59813:39715,59814:39717,59815:39719,59816:39720,59817:39721,59818:39722,59819:39726,59820:39727,59821:39730,59822:39748,59823:39747,59824:39759,59825:39757,59826:39758,59827:39761,59828:39768,59829:39796,59830:39827,59831:39811,59832:39825,59833:39830,59834:39831,59835:39839,59836:39840,59837:39848,59838:39860,59839:39872,59840:39882,59841:39865,59842:39878,59843:39887,59844:39889,59845:39890,59846:39907,59847:39906,59848:39908,59849:39892,59850:39905,59851:39994,59852:39922,59853:39921,59854:39920,59855:39957,59856:39956,59857:39945,59858:39955,59859:39948,59860:39942,59861:39944,59862:39954,59863:39946,59864:39940,59865:39982,59866:39963,59867:39973,59868:39972,59869:39969,59870:39984,59871:40007,59872:39986,59873:40006,59874:39998,59875:40026,59876:40032,59877:40039,59878:40054,59879:40056,59880:40167,59881:40172,59882:40176,59883:40201,59884:40200,59885:40171,59886:40195,59887:40198,59888:40234,59889:40230,59890:40367,59891:40227,59892:40223,59893:40260,59894:40213,59895:40210,59896:40257,59897:40255,59898:40254,59899:40262,59900:40264,59968:40285,59969:40286,59970:40292,59971:40273,59972:40272,59973:40281,59974:40306,59975:40329,59976:40327,59977:40363,59978:40303,59979:40314,59980:40346,59981:40356,59982:40361,59983:40370,59984:40388,59985:40385,59986:40379,59987:40376,59988:40378,59989:40390,59990:40399,59991:40386,59992:40409,59993:40403,59994:40440,59995:40422,59996:40429,59997:40431,59998:40445,59999:40474,6e4:40475,60001:40478,60002:40565,60003:40569,60004:40573,60005:40577,60006:40584,60007:40587,60008:40588,60009:40594,60010:40597,60011:40593,60012:40605,60013:40613,60014:40617,60015:40632,60016:40618,60017:40621,60018:38753,60019:40652,60020:40654,60021:40655,60022:40656,60023:40660,60024:40668,60025:40670,60026:40669,60027:40672,60028:40677,60029:40680,60030:40687,60032:40692,60033:40694,60034:40695,60035:40697,60036:40699,60037:40700,60038:40701,60039:40711,60040:40712,60041:30391,60042:40725,60043:40737,60044:40748,60045:40766,60046:40778,60047:40786,60048:40788,60049:40803,60050:40799,60051:40800,60052:40801,60053:40806,60054:40807,60055:40812,60056:40810,60057:40823,60058:40818,60059:40822,60060:40853,60061:40860,60062:40864,60063:22575,60064:27079,60065:36953,60066:29796,60067:20956,60068:29081,60736:32394,60737:35100,60738:37704,60739:37512,60740:34012,60741:20425,60742:28859,60743:26161,60744:26824,60745:37625,60746:26363,60747:24389,60748:20008,60749:20193,60750:20220,60751:20224,60752:20227,60753:20281,60754:20310,60755:20370,60756:20362,60757:20378,60758:20372,60759:20429,60760:20544,60761:20514,60762:20479,60763:20510,60764:20550,60765:20592,60766:20546,60767:20628,60768:20724,60769:20696,60770:20810,60771:20836,60772:20893,60773:20926,60774:20972,60775:21013,60776:21148,60777:21158,60778:21184,60779:21211,60780:21248,60781:21255,60782:21284,60783:21362,60784:21395,60785:21426,60786:21469,60787:64014,60788:21660,60789:21642,60790:21673,60791:21759,60792:21894,60793:22361,60794:22373,60795:22444,60796:22472,60797:22471,60798:64015,60800:64016,60801:22686,60802:22706,60803:22795,60804:22867,60805:22875,60806:22877,60807:22883,60808:22948,60809:22970,60810:23382,60811:23488,60812:29999,60813:23512,60814:23532,60815:23582,60816:23718,60817:23738,60818:23797,60819:23847,60820:23891,60821:64017,60822:23874,60823:23917,60824:23992,60825:23993,60826:24016,60827:24353,60828:24372,60829:24423,60830:24503,60831:24542,60832:24669,60833:24709,60834:24714,60835:24798,60836:24789,60837:24864,60838:24818,60839:24849,60840:24887,60841:24880,60842:24984,60843:25107,60844:25254,60845:25589,60846:25696,60847:25757,60848:25806,60849:25934,60850:26112,60851:26133,60852:26171,60853:26121,60854:26158,60855:26142,60856:26148,60857:26213,60858:26199,60859:26201,60860:64018,60861:26227,60862:26265,60863:26272,60864:26290,60865:26303,60866:26362,60867:26382,60868:63785,60869:26470,60870:26555,60871:26706,60872:26560,60873:26625,60874:26692,60875:26831,60876:64019,60877:26984,60878:64020,60879:27032,60880:27106,60881:27184,60882:27243,60883:27206,60884:27251,60885:27262,60886:27362,60887:27364,60888:27606,60889:27711,60890:27740,60891:27782,60892:27759,60893:27866,60894:27908,60895:28039,60896:28015,60897:28054,60898:28076,60899:28111,60900:28152,60901:28146,60902:28156,60903:28217,60904:28252,60905:28199,60906:28220,60907:28351,60908:28552,60909:28597,60910:28661,60911:28677,60912:28679,60913:28712,60914:28805,60915:28843,60916:28943,60917:28932,60918:29020,60919:28998,60920:28999,60921:64021,60922:29121,60923:29182,60924:29361,60992:29374,60993:29476,60994:64022,60995:29559,60996:29629,60997:29641,60998:29654,60999:29667,61e3:29650,61001:29703,61002:29685,61003:29734,61004:29738,61005:29737,61006:29742,61007:29794,61008:29833,61009:29855,61010:29953,61011:30063,61012:30338,61013:30364,61014:30366,61015:30363,61016:30374,61017:64023,61018:30534,61019:21167,61020:30753,61021:30798,61022:30820,61023:30842,61024:31024,61025:64024,61026:64025,61027:64026,61028:31124,61029:64027,61030:31131,61031:31441,61032:31463,61033:64028,61034:31467,61035:31646,61036:64029,61037:32072,61038:32092,61039:32183,61040:32160,61041:32214,61042:32338,61043:32583,61044:32673,61045:64030,61046:33537,61047:33634,61048:33663,61049:33735,61050:33782,61051:33864,61052:33972,61053:34131,61054:34137,61056:34155,61057:64031,61058:34224,61059:64032,61060:64033,61061:34823,61062:35061,61063:35346,61064:35383,61065:35449,61066:35495,61067:35518,61068:35551,61069:64034,61070:35574,61071:35667,61072:35711,61073:36080,61074:36084,61075:36114,61076:36214,61077:64035,61078:36559,61079:64036,61080:64037,61081:36967,61082:37086,61083:64038,61084:37141,61085:37159,61086:37338,61087:37335,61088:37342,61089:37357,61090:37358,61091:37348,61092:37349,61093:37382,61094:37392,61095:37386,61096:37434,61097:37440,61098:37436,61099:37454,61100:37465,61101:37457,61102:37433,61103:37479,61104:37543,61105:37495,61106:37496,61107:37607,61108:37591,61109:37593,61110:37584,61111:64039,61112:37589,61113:37600,61114:37587,61115:37669,61116:37665,61117:37627,61118:64040,61119:37662,61120:37631,61121:37661,61122:37634,61123:37744,61124:37719,61125:37796,61126:37830,61127:37854,61128:37880,61129:37937,61130:37957,61131:37960,61132:38290,61133:63964,61134:64041,61135:38557,61136:38575,61137:38707,61138:38715,61139:38723,61140:38733,61141:38735,61142:38737,61143:38741,61144:38999,61145:39013,61146:64042,61147:64043,61148:39207,61149:64044,61150:39326,61151:39502,61152:39641,61153:39644,61154:39797,61155:39794,61156:39823,61157:39857,61158:39867,61159:39936,61160:40304,61161:40299,61162:64045,61163:40473,61164:40657,61167:8560,61168:8561,61169:8562,61170:8563,61171:8564,61172:8565,61173:8566,61174:8567,61175:8568,61176:8569,61177:65506,61178:65508,61179:65287,61180:65282,61504:57344,61505:57345,61506:57346,61507:57347,61508:57348,61509:57349,61510:57350,61511:57351,61512:57352,61513:57353,61514:57354,61515:57355,61516:57356,61517:57357,61518:57358,61519:57359,61520:57360,61521:57361,61522:57362,61523:57363,61524:57364,61525:57365,61526:57366,61527:57367,61528:57368,61529:57369,61530:57370,61531:57371,61532:57372,61533:57373,61534:57374,61535:57375,61536:57376,61537:57377,61538:57378,61539:57379,61540:57380,61541:57381,61542:57382,61543:57383,61544:57384,61545:57385,61546:57386,61547:57387,61548:57388,61549:57389,61550:57390,61551:57391,61552:57392,61553:57393,61554:57394,61555:57395,61556:57396,61557:57397,61558:57398,61559:57399,61560:57400,61561:57401,61562:57402,61563:57403,61564:57404,61565:57405,61566:57406,61568:57407,61569:57408,61570:57409,61571:57410,61572:57411,61573:57412,61574:57413,61575:57414,61576:57415,61577:57416,61578:57417,61579:57418,61580:57419,61581:57420,61582:57421,61583:57422,61584:57423,61585:57424,61586:57425,61587:57426,61588:57427,61589:57428,61590:57429,61591:57430,61592:57431,61593:57432,61594:57433,61595:57434,61596:57435,61597:57436,61598:57437,61599:57438,61600:57439,61601:57440,61602:57441,61603:57442,61604:57443,61605:57444,61606:57445,61607:57446,61608:57447,61609:57448,61610:57449,61611:57450,61612:57451,61613:57452,61614:57453,61615:57454,61616:57455,61617:57456,61618:57457,61619:57458,61620:57459,61621:57460,61622:57461,61623:57462,61624:57463,61625:57464,61626:57465,61627:57466,61628:57467,61629:57468,61630:57469,61631:57470,61632:57471,61633:57472,61634:57473,61635:57474,61636:57475,61637:57476,61638:57477,61639:57478,61640:57479,61641:57480,61642:57481,61643:57482,61644:57483,61645:57484,61646:57485,61647:57486,61648:57487,61649:57488,61650:57489,61651:57490,61652:57491,61653:57492,61654:57493,61655:57494,61656:57495,61657:57496,61658:57497,61659:57498,61660:57499,61661:57500,61662:57501,61663:57502,61664:57503,61665:57504,61666:57505,61667:57506,61668:57507,61669:57508,61670:57509,61671:57510,61672:57511,61673:57512,61674:57513,61675:57514,61676:57515,61677:57516,61678:57517,61679:57518,61680:57519,61681:57520,61682:57521,61683:57522,61684:57523,61685:57524,61686:57525,61687:57526,61688:57527,61689:57528,61690:57529,61691:57530,61692:57531,61760:57532,61761:57533,61762:57534,61763:57535,61764:57536,61765:57537,61766:57538,61767:57539,61768:57540,61769:57541,61770:57542,61771:57543,61772:57544,61773:57545,61774:57546,61775:57547,61776:57548,61777:57549,61778:57550,61779:57551,61780:57552,61781:57553,61782:57554,61783:57555,61784:57556,61785:57557,61786:57558,61787:57559,61788:57560,61789:57561,61790:57562,61791:57563,61792:57564,61793:57565,61794:57566,61795:57567,61796:57568,61797:57569,61798:57570,61799:57571,61800:57572,61801:57573,61802:57574,61803:57575,61804:57576,61805:57577,61806:57578,61807:57579,61808:57580,61809:57581,61810:57582,61811:57583,61812:57584,61813:57585,61814:57586,61815:57587,61816:57588,61817:57589,61818:57590,61819:57591,61820:57592,61821:57593,61822:57594,61824:57595,61825:57596,61826:57597,61827:57598,61828:57599,61829:57600,61830:57601,61831:57602,61832:57603,61833:57604,61834:57605,61835:57606,61836:57607,61837:57608,61838:57609,61839:57610,61840:57611,61841:57612,61842:57613,61843:57614,61844:57615,61845:57616,61846:57617,61847:57618,61848:57619,61849:57620,61850:57621,61851:57622,61852:57623,61853:57624,61854:57625,61855:57626,61856:57627,61857:57628,61858:57629,61859:57630,61860:57631,61861:57632,61862:57633,61863:57634,61864:57635,61865:57636,61866:57637,61867:57638,61868:57639,61869:57640,61870:57641,61871:57642,61872:57643,61873:57644,61874:57645,61875:57646,61876:57647,61877:57648,61878:57649,61879:57650,61880:57651,61881:57652,61882:57653,61883:57654,61884:57655,61885:57656,61886:57657,61887:57658,61888:57659,61889:57660,61890:57661,61891:57662,61892:57663,61893:57664,61894:57665,61895:57666,61896:57667,61897:57668,61898:57669,61899:57670,61900:57671,61901:57672,61902:57673,61903:57674,61904:57675,61905:57676,61906:57677,61907:57678,61908:57679,61909:57680,61910:57681,61911:57682,61912:57683,61913:57684,61914:57685,61915:57686,61916:57687,61917:57688,61918:57689,61919:57690,61920:57691,61921:57692,61922:57693,61923:57694,61924:57695,61925:57696,61926:57697,61927:57698,61928:57699,61929:57700,61930:57701,61931:57702,61932:57703,61933:57704,61934:57705,61935:57706,61936:57707,61937:57708,61938:57709,61939:57710,61940:57711,61941:57712,61942:57713,61943:57714,61944:57715,61945:57716,61946:57717,61947:57718,61948:57719,62016:57720,62017:57721,62018:57722,62019:57723,62020:57724,62021:57725,62022:57726,62023:57727,62024:57728,62025:57729,62026:57730,62027:57731,62028:57732,62029:57733,62030:57734,62031:57735,62032:57736,62033:57737,62034:57738,62035:57739,62036:57740,62037:57741,62038:57742,62039:57743,62040:57744,62041:57745,62042:57746,62043:57747,62044:57748,62045:57749,62046:57750,62047:57751,62048:57752,62049:57753,62050:57754,62051:57755,62052:57756,62053:57757,62054:57758,62055:57759,62056:57760,62057:57761,62058:57762,62059:57763,62060:57764,62061:57765,62062:57766,62063:57767,62064:57768,62065:57769,62066:57770,62067:57771,62068:57772,62069:57773,62070:57774,62071:57775,62072:57776,62073:57777,62074:57778,62075:57779,62076:57780,62077:57781,62078:57782,62080:57783,62081:57784,62082:57785,62083:57786,62084:57787,62085:57788,62086:57789,62087:57790,62088:57791,62089:57792,62090:57793,62091:57794,62092:57795,62093:57796,62094:57797,62095:57798,62096:57799,62097:57800,62098:57801,62099:57802,62100:57803,62101:57804,62102:57805,62103:57806,62104:57807,62105:57808,62106:57809,62107:57810,62108:57811,62109:57812,62110:57813,62111:57814,62112:57815,62113:57816,62114:57817,62115:57818,62116:57819,62117:57820,62118:57821,62119:57822,62120:57823,62121:57824,62122:57825,62123:57826,62124:57827,62125:57828,62126:57829,62127:57830,62128:57831,62129:57832,62130:57833,62131:57834,62132:57835,62133:57836,62134:57837,62135:57838,62136:57839,62137:57840,62138:57841,62139:57842,62140:57843,62141:57844,62142:57845,62143:57846,62144:57847,62145:57848,62146:57849,62147:57850,62148:57851,62149:57852,62150:57853,62151:57854,62152:57855,62153:57856,62154:57857,62155:57858,62156:57859,62157:57860,62158:57861,62159:57862,62160:57863,62161:57864,62162:57865,62163:57866,62164:57867,62165:57868,62166:57869,62167:57870, 62168:57871,62169:57872,62170:57873,62171:57874,62172:57875,62173:57876,62174:57877,62175:57878,62176:57879,62177:57880,62178:57881,62179:57882,62180:57883,62181:57884,62182:57885,62183:57886,62184:57887,62185:57888,62186:57889,62187:57890,62188:57891,62189:57892,62190:57893,62191:57894,62192:57895,62193:57896,62194:57897,62195:57898,62196:57899,62197:57900,62198:57901,62199:57902,62200:57903,62201:57904,62202:57905,62203:57906,62204:57907,62272:57908,62273:57909,62274:57910,62275:57911,62276:57912,62277:57913,62278:57914,62279:57915,62280:57916,62281:57917,62282:57918,62283:57919,62284:57920,62285:57921,62286:57922,62287:57923,62288:57924,62289:57925,62290:57926,62291:57927,62292:57928,62293:57929,62294:57930,62295:57931,62296:57932,62297:57933,62298:57934,62299:57935,62300:57936,62301:57937,62302:57938,62303:57939,62304:57940,62305:57941,62306:57942,62307:57943,62308:57944,62309:57945,62310:57946,62311:57947,62312:57948,62313:57949,62314:57950,62315:57951,62316:57952,62317:57953,62318:57954,62319:57955,62320:57956,62321:57957,62322:57958,62323:57959,62324:57960,62325:57961,62326:57962,62327:57963,62328:57964,62329:57965,62330:57966,62331:57967,62332:57968,62333:57969,62334:57970,62336:57971,62337:57972,62338:57973,62339:57974,62340:57975,62341:57976,62342:57977,62343:57978,62344:57979,62345:57980,62346:57981,62347:57982,62348:57983,62349:57984,62350:57985,62351:57986,62352:57987,62353:57988,62354:57989,62355:57990,62356:57991,62357:57992,62358:57993,62359:57994,62360:57995,62361:57996,62362:57997,62363:57998,62364:57999,62365:58e3,62366:58001,62367:58002,62368:58003,62369:58004,62370:58005,62371:58006,62372:58007,62373:58008,62374:58009,62375:58010,62376:58011,62377:58012,62378:58013,62379:58014,62380:58015,62381:58016,62382:58017,62383:58018,62384:58019,62385:58020,62386:58021,62387:58022,62388:58023,62389:58024,62390:58025,62391:58026,62392:58027,62393:58028,62394:58029,62395:58030,62396:58031,62397:58032,62398:58033,62399:58034,62400:58035,62401:58036,62402:58037,62403:58038,62404:58039,62405:58040,62406:58041,62407:58042,62408:58043,62409:58044,62410:58045,62411:58046,62412:58047,62413:58048,62414:58049,62415:58050,62416:58051,62417:58052,62418:58053,62419:58054,62420:58055,62421:58056,62422:58057,62423:58058,62424:58059,62425:58060,62426:58061,62427:58062,62428:58063,62429:58064,62430:58065,62431:58066,62432:58067,62433:58068,62434:58069,62435:58070,62436:58071,62437:58072,62438:58073,62439:58074,62440:58075,62441:58076,62442:58077,62443:58078,62444:58079,62445:58080,62446:58081,62447:58082,62448:58083,62449:58084,62450:58085,62451:58086,62452:58087,62453:58088,62454:58089,62455:58090,62456:58091,62457:58092,62458:58093,62459:58094,62460:58095,62528:58096,62529:58097,62530:58098,62531:58099,62532:58100,62533:58101,62534:58102,62535:58103,62536:58104,62537:58105,62538:58106,62539:58107,62540:58108,62541:58109,62542:58110,62543:58111,62544:58112,62545:58113,62546:58114,62547:58115,62548:58116,62549:58117,62550:58118,62551:58119,62552:58120,62553:58121,62554:58122,62555:58123,62556:58124,62557:58125,62558:58126,62559:58127,62560:58128,62561:58129,62562:58130,62563:58131,62564:58132,62565:58133,62566:58134,62567:58135,62568:58136,62569:58137,62570:58138,62571:58139,62572:58140,62573:58141,62574:58142,62575:58143,62576:58144,62577:58145,62578:58146,62579:58147,62580:58148,62581:58149,62582:58150,62583:58151,62584:58152,62585:58153,62586:58154,62587:58155,62588:58156,62589:58157,62590:58158,62592:58159,62593:58160,62594:58161,62595:58162,62596:58163,62597:58164,62598:58165,62599:58166,62600:58167,62601:58168,62602:58169,62603:58170,62604:58171,62605:58172,62606:58173,62607:58174,62608:58175,62609:58176,62610:58177,62611:58178,62612:58179,62613:58180,62614:58181,62615:58182,62616:58183,62617:58184,62618:58185,62619:58186,62620:58187,62621:58188,62622:58189,62623:58190,62624:58191,62625:58192,62626:58193,62627:58194,62628:58195,62629:58196,62630:58197,62631:58198,62632:58199,62633:58200,62634:58201,62635:58202,62636:58203,62637:58204,62638:58205,62639:58206,62640:58207,62641:58208,62642:58209,62643:58210,62644:58211,62645:58212,62646:58213,62647:58214,62648:58215,62649:58216,62650:58217,62651:58218,62652:58219,62653:58220,62654:58221,62655:58222,62656:58223,62657:58224,62658:58225,62659:58226,62660:58227,62661:58228,62662:58229,62663:58230,62664:58231,62665:58232,62666:58233,62667:58234,62668:58235,62669:58236,62670:58237,62671:58238,62672:58239,62673:58240,62674:58241,62675:58242,62676:58243,62677:58244,62678:58245,62679:58246,62680:58247,62681:58248,62682:58249,62683:58250,62684:58251,62685:58252,62686:58253,62687:58254,62688:58255,62689:58256,62690:58257,62691:58258,62692:58259,62693:58260,62694:58261,62695:58262,62696:58263,62697:58264,62698:58265,62699:58266,62700:58267,62701:58268,62702:58269,62703:58270,62704:58271,62705:58272,62706:58273,62707:58274,62708:58275,62709:58276,62710:58277,62711:58278,62712:58279,62713:58280,62714:58281,62715:58282,62716:58283,62784:58284,62785:58285,62786:58286,62787:58287,62788:58288,62789:58289,62790:58290,62791:58291,62792:58292,62793:58293,62794:58294,62795:58295,62796:58296,62797:58297,62798:58298,62799:58299,62800:58300,62801:58301,62802:58302,62803:58303,62804:58304,62805:58305,62806:58306,62807:58307,62808:58308,62809:58309,62810:58310,62811:58311,62812:58312,62813:58313,62814:58314,62815:58315,62816:58316,62817:58317,62818:58318,62819:58319,62820:58320,62821:58321,62822:58322,62823:58323,62824:58324,62825:58325,62826:58326,62827:58327,62828:58328,62829:58329,62830:58330,62831:58331,62832:58332,62833:58333,62834:58334,62835:58335,62836:58336,62837:58337,62838:58338,62839:58339,62840:58340,62841:58341,62842:58342,62843:58343,62844:58344,62845:58345,62846:58346,62848:58347,62849:58348,62850:58349,62851:58350,62852:58351,62853:58352,62854:58353,62855:58354,62856:58355,62857:58356,62858:58357,62859:58358,62860:58359,62861:58360,62862:58361,62863:58362,62864:58363,62865:58364,62866:58365,62867:58366,62868:58367,62869:58368,62870:58369,62871:58370,62872:58371,62873:58372,62874:58373,62875:58374,62876:58375,62877:58376,62878:58377,62879:58378,62880:58379,62881:58380,62882:58381,62883:58382,62884:58383,62885:58384,62886:58385,62887:58386,62888:58387,62889:58388,62890:58389,62891:58390,62892:58391,62893:58392,62894:58393,62895:58394,62896:58395,62897:58396,62898:58397,62899:58398,62900:58399,62901:58400,62902:58401,62903:58402,62904:58403,62905:58404,62906:58405,62907:58406,62908:58407,62909:58408,62910:58409,62911:58410,62912:58411,62913:58412,62914:58413,62915:58414,62916:58415,62917:58416,62918:58417,62919:58418,62920:58419,62921:58420,62922:58421,62923:58422,62924:58423,62925:58424,62926:58425,62927:58426,62928:58427,62929:58428,62930:58429,62931:58430,62932:58431,62933:58432,62934:58433,62935:58434,62936:58435,62937:58436,62938:58437,62939:58438,62940:58439,62941:58440,62942:58441,62943:58442,62944:58443,62945:58444,62946:58445,62947:58446,62948:58447,62949:58448,62950:58449,62951:58450,62952:58451,62953:58452,62954:58453,62955:58454,62956:58455,62957:58456,62958:58457,62959:58458,62960:58459,62961:58460,62962:58461,62963:58462,62964:58463,62965:58464,62966:58465,62967:58466,62968:58467,62969:58468,62970:58469,62971:58470,62972:58471,63040:58472,63041:58473,63042:58474,63043:58475,63044:58476,63045:58477,63046:58478,63047:58479,63048:58480,63049:58481,63050:58482,63051:58483,63052:58484,63053:58485,63054:58486,63055:58487,63056:58488,63057:58489,63058:58490,63059:58491,63060:58492,63061:58493,63062:58494,63063:58495,63064:58496,63065:58497,63066:58498,63067:58499,63068:58500,63069:58501,63070:58502,63071:58503,63072:58504,63073:58505,63074:58506,63075:58507,63076:58508,63077:58509,63078:58510,63079:58511,63080:58512,63081:58513,63082:58514,63083:58515,63084:58516,63085:58517,63086:58518,63087:58519,63088:58520,63089:58521,63090:58522,63091:58523,63092:58524,63093:58525,63094:58526,63095:58527,63096:58528,63097:58529,63098:58530,63099:58531,63100:58532,63101:58533,63102:58534,63104:58535,63105:58536,63106:58537,63107:58538,63108:58539,63109:58540,63110:58541,63111:58542,63112:58543,63113:58544,63114:58545,63115:58546,63116:58547,63117:58548,63118:58549,63119:58550,63120:58551,63121:58552,63122:58553,63123:58554,63124:58555,63125:58556,63126:58557,63127:58558,63128:58559,63129:58560,63130:58561,63131:58562,63132:58563,63133:58564,63134:58565,63135:58566,63136:58567,63137:58568,63138:58569,63139:58570,63140:58571,63141:58572,63142:58573,63143:58574,63144:58575,63145:58576,63146:58577,63147:58578,63148:58579,63149:58580,63150:58581,63151:58582,63152:58583,63153:58584,63154:58585,63155:58586,63156:58587,63157:58588,63158:58589,63159:58590,63160:58591,63161:58592,63162:58593,63163:58594,63164:58595,63165:58596,63166:58597,63167:58598,63168:58599,63169:58600,63170:58601,63171:58602,63172:58603,63173:58604,63174:58605,63175:58606,63176:58607,63177:58608,63178:58609,63179:58610,63180:58611,63181:58612,63182:58613,63183:58614,63184:58615,63185:58616,63186:58617,63187:58618,63188:58619,63189:58620,63190:58621,63191:58622,63192:58623,63193:58624,63194:58625,63195:58626,63196:58627,63197:58628,63198:58629,63199:58630,63200:58631,63201:58632,63202:58633,63203:58634,63204:58635,63205:58636,63206:58637,63207:58638,63208:58639,63209:58640,63210:58641,63211:58642,63212:58643,63213:58644,63214:58645,63215:58646,63216:58647,63217:58648,63218:58649,63219:58650,63220:58651,63221:58652,63222:58653,63223:58654,63224:58655,63225:58656,63226:58657,63227:58658,63228:58659,63296:58660,63297:58661,63298:58662,63299:58663,63300:58664,63301:58665,63302:58666,63303:58667,63304:58668,63305:58669,63306:58670,63307:58671,63308:58672,63309:58673,63310:58674,63311:58675,63312:58676,63313:58677,63314:58678,63315:58679,63316:58680,63317:58681,63318:58682,63319:58683,63320:58684,63321:58685,63322:58686,63323:58687,63324:58688,63325:58689,63326:58690,63327:58691,63328:58692,63329:58693,63330:58694,63331:58695,63332:58696,63333:58697,63334:58698,63335:58699,63336:58700,63337:58701,63338:58702,63339:58703,63340:58704,63341:58705,63342:58706,63343:58707,63344:58708,63345:58709,63346:58710,63347:58711,63348:58712,63349:58713,63350:58714,63351:58715,63352:58716,63353:58717,63354:58718,63355:58719,63356:58720,63357:58721,63358:58722,63360:58723,63361:58724,63362:58725,63363:58726,63364:58727,63365:58728,63366:58729,63367:58730,63368:58731,63369:58732,63370:58733,63371:58734,63372:58735,63373:58736,63374:58737,63375:58738,63376:58739,63377:58740,63378:58741,63379:58742,63380:58743,63381:58744,63382:58745,63383:58746,63384:58747,63385:58748,63386:58749,63387:58750,63388:58751,63389:58752,63390:58753,63391:58754,63392:58755,63393:58756,63394:58757,63395:58758,63396:58759,63397:58760,63398:58761,63399:58762,63400:58763,63401:58764,63402:58765,63403:58766,63404:58767,63405:58768,63406:58769,63407:58770,63408:58771,63409:58772,63410:58773,63411:58774,63412:58775,63413:58776,63414:58777,63415:58778,63416:58779,63417:58780,63418:58781,63419:58782,63420:58783,63421:58784,63422:58785,63423:58786,63424:58787,63425:58788,63426:58789,63427:58790,63428:58791,63429:58792,63430:58793,63431:58794,63432:58795,63433:58796,63434:58797,63435:58798,63436:58799,63437:58800,63438:58801,63439:58802,63440:58803,63441:58804,63442:58805,63443:58806,63444:58807,63445:58808,63446:58809,63447:58810,63448:58811,63449:58812,63450:58813,63451:58814,63452:58815,63453:58816,63454:58817,63455:58818,63456:58819,63457:58820,63458:58821,63459:58822,63460:58823,63461:58824,63462:58825,63463:58826,63464:58827,63465:58828,63466:58829,63467:58830,63468:58831,63469:58832,63470:58833,63471:58834,63472:58835,63473:58836,63474:58837,63475:58838,63476:58839,63477:58840,63478:58841,63479:58842,63480:58843,63481:58844,63482:58845,63483:58846,63484:58847,63552:58848,63553:58849,63554:58850,63555:58851,63556:58852,63557:58853,63558:58854,63559:58855,63560:58856,63561:58857,63562:58858,63563:58859,63564:58860,63565:58861,63566:58862,63567:58863,63568:58864,63569:58865,63570:58866,63571:58867,63572:58868,63573:58869,63574:58870,63575:58871,63576:58872,63577:58873,63578:58874,63579:58875,63580:58876,63581:58877,63582:58878,63583:58879,63584:58880,63585:58881,63586:58882,63587:58883,63588:58884,63589:58885,63590:58886,63591:58887,63592:58888,63593:58889,63594:58890,63595:58891,63596:58892,63597:58893,63598:58894,63599:58895,63600:58896,63601:58897,63602:58898,63603:58899,63604:58900,63605:58901,63606:58902,63607:58903,63608:58904,63609:58905,63610:58906,63611:58907,63612:58908,63613:58909,63614:58910,63616:58911,63617:58912,63618:58913,63619:58914,63620:58915,63621:58916,63622:58917,63623:58918,63624:58919,63625:58920,63626:58921,63627:58922,63628:58923,63629:58924,63630:58925,63631:58926,63632:58927,63633:58928,63634:58929,63635:58930,63636:58931,63637:58932,63638:58933,63639:58934,63640:58935,63641:58936,63642:58937,63643:58938,63644:58939,63645:58940,63646:58941,63647:58942,63648:58943,63649:58944,63650:58945,63651:58946,63652:58947,63653:58948,63654:58949,63655:58950,63656:58951,63657:58952,63658:58953,63659:58954,63660:58955,63661:58956,63662:58957,63663:58958,63664:58959,63665:58960,63666:58961,63667:58962,63668:58963,63669:58964,63670:58965,63671:58966,63672:58967,63673:58968,63674:58969,63675:58970,63676:58971,63677:58972,63678:58973,63679:58974,63680:58975,63681:58976,63682:58977,63683:58978,63684:58979,63685:58980,63686:58981,63687:58982,63688:58983,63689:58984,63690:58985,63691:58986,63692:58987,63693:58988,63694:58989,63695:58990,63696:58991,63697:58992,63698:58993,63699:58994,63700:58995,63701:58996,63702:58997,63703:58998,63704:58999,63705:59e3,63706:59001,63707:59002,63708:59003,63709:59004,63710:59005,63711:59006,63712:59007,63713:59008,63714:59009,63715:59010,63716:59011,63717:59012,63718:59013,63719:59014,63720:59015,63721:59016,63722:59017,63723:59018,63724:59019,63725:59020,63726:59021,63727:59022,63728:59023,63729:59024,63730:59025,63731:59026,63732:59027,63733:59028,63734:59029,63735:59030,63736:59031,63737:59032,63738:59033,63739:59034,63740:59035,64064:8560,64065:8561,64066:8562,64067:8563,64068:8564,64069:8565,64070:8566,64071:8567,64072:8568,64073:8569,64074:8544,64075:8545,64076:8546,64077:8547,64078:8548,64079:8549,64080:8550,64081:8551,64082:8552,64083:8553,64084:65506,64085:65508,64086:65287,64087:65282,64088:12849,64089:8470,64090:8481,64091:8757,64092:32394,64093:35100,64094:37704,64095:37512,64096:34012,64097:20425,64098:28859,64099:26161,64100:26824,64101:37625,64102:26363,64103:24389,64104:20008,64105:20193,64106:20220,64107:20224,64108:20227,64109:20281,64110:20310,64111:20370,64112:20362,64113:20378,64114:20372,64115:20429,64116:20544,64117:20514,64118:20479,64119:20510,64120:20550,64121:20592,64122:20546,64123:20628,64124:20724,64125:20696,64126:20810,64128:20836,64129:20893,64130:20926,64131:20972,64132:21013,64133:21148,64134:21158,64135:21184,64136:21211,64137:21248,64138:21255,64139:21284,64140:21362,64141:21395,64142:21426,64143:21469,64144:64014,64145:21660,64146:21642,64147:21673,64148:21759,64149:21894,64150:22361,64151:22373,64152:22444,64153:22472,64154:22471,64155:64015,64156:64016,64157:22686,64158:22706,64159:22795,64160:22867,64161:22875,64162:22877,64163:22883,64164:22948,64165:22970,64166:23382,64167:23488,64168:29999,64169:23512,64170:23532,64171:23582,64172:23718,64173:23738,64174:23797,64175:23847,64176:23891,64177:64017,64178:23874,64179:23917,64180:23992,64181:23993,64182:24016,64183:24353,64184:24372,64185:24423,64186:24503,64187:24542,64188:24669,64189:24709,64190:24714,64191:24798,64192:24789,64193:24864,64194:24818,64195:24849,64196:24887,64197:24880,64198:24984,64199:25107,64200:25254,64201:25589,64202:25696,64203:25757,64204:25806,64205:25934,64206:26112,64207:26133,64208:26171,64209:26121,64210:26158,64211:26142,64212:26148,64213:26213,64214:26199,64215:26201,64216:64018,64217:26227,64218:26265,64219:26272,64220:26290,64221:26303,64222:26362,64223:26382,64224:63785,64225:26470,64226:26555,64227:26706,64228:26560,64229:26625,64230:26692,64231:26831,64232:64019,64233:26984,64234:64020,64235:27032,64236:27106,64237:27184,64238:27243,64239:27206,64240:27251,64241:27262,64242:27362,64243:27364,64244:27606,64245:27711,64246:27740,64247:27782,64248:27759,64249:27866,64250:27908,64251:28039,64252:28015,64320:28054,64321:28076,64322:28111,64323:28152,64324:28146,64325:28156,64326:28217,64327:28252,64328:28199,64329:28220,64330:28351,64331:28552,64332:28597,64333:28661,64334:28677,64335:28679,64336:28712,64337:28805,64338:28843,64339:28943,64340:28932,64341:29020,64342:28998,64343:28999,64344:64021,64345:29121,64346:29182,64347:29361,64348:29374,64349:29476,64350:64022,64351:29559,64352:29629,64353:29641,64354:29654,64355:29667,64356:29650,64357:29703,64358:29685,64359:29734,64360:29738,64361:29737,64362:29742,64363:29794,64364:29833,64365:29855,64366:29953,64367:30063,64368:30338,64369:30364,64370:30366,64371:30363,64372:30374,64373:64023,64374:30534,64375:21167,64376:30753,64377:30798,64378:30820,64379:30842,64380:31024,64381:64024,64382:64025,64384:64026,64385:31124,64386:64027,64387:31131,64388:31441,64389:31463,64390:64028,64391:31467,64392:31646,64393:64029,64394:32072,64395:32092,64396:32183,64397:32160,64398:32214,64399:32338,64400:32583,64401:32673,64402:64030,64403:33537,64404:33634,64405:33663,64406:33735,64407:33782,64408:33864,64409:33972,64410:34131,64411:34137,64412:34155,64413:64031,64414:34224,64415:64032,64416:64033,64417:34823,64418:35061,64419:35346,64420:35383,64421:35449,64422:35495,64423:35518,64424:35551,64425:64034,64426:35574,64427:35667,64428:35711,64429:36080,64430:36084,64431:36114,64432:36214,64433:64035,64434:36559,64435:64036,64436:64037,64437:36967,64438:37086,64439:64038,64440:37141,64441:37159,64442:37338,64443:37335,64444:37342,64445:37357,64446:37358,64447:37348,64448:37349,64449:37382,64450:37392,64451:37386,64452:37434,64453:37440,64454:37436,64455:37454,64456:37465,64457:37457,64458:37433,64459:37479,64460:37543,64461:37495,64462:37496,64463:37607,64464:37591,64465:37593,64466:37584,64467:64039,64468:37589,64469:37600,64470:37587,64471:37669,64472:37665,64473:37627,64474:64040,64475:37662,64476:37631,64477:37661,64478:37634,64479:37744,64480:37719,64481:37796,64482:37830,64483:37854,64484:37880,64485:37937,64486:37957,64487:37960,64488:38290,64489:63964,64490:64041,64491:38557,64492:38575,64493:38707,64494:38715,64495:38723,64496:38733,64497:38735,64498:38737,64499:38741,64500:38999,64501:39013,64502:64042,64503:64043,64504:39207,64505:64044,64506:39326,64507:39502,64508:39641,64576:39644,64577:39797,64578:39794,64579:39823,64580:39857,64581:39867,64582:39936,64583:40304,64584:40299,64585:64045,64586:40473,64587:40657},n.prototype={constructor:n,getInt8:function(){var t=this.dv.getInt8(this.offset);return this.offset+=1,t},getInt8Array:function(t){for(var e=[],n=0;n0;){var n=this.getUint8();if(t--,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getSjisStringsAsUnicode:function(t){for(var e=[];t>0;){var n=this.getUint8();if(t--,0===n)break;e.push(n)}for(;t>0;)this.getUint8(),t--;return this.encoder.s2u(new Uint8Array(e))},getUnicodeStrings:function(t){for(var e="";t>0;){var n=this.getUint16();if(t-=2,0===n)break;e+=String.fromCharCode(n)}for(;t>0;)this.getUint8(),t--;return e},getTextBuffer:function(){var t=this.getUint32();return this.getUnicodeStrings(t)}},a.prototype={constructor:a,leftToRightVector3:function(t){t[2]=-t[2]},leftToRightQuaternion:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightEuler:function(t){t[0]=-t[0],t[1]=-t[1]},leftToRightIndexOrder:function(t){var e=t[2];t[2]=t[0],t[0]=e},leftToRightVector3Range:function(t,e){var n=-e[2];e[2]=-t[2],t[2]=n},leftToRightEulerRange:function(t,e){var n=-e[0],a=-e[1];e[0]=-t[0],e[1]=-t[1],t[0]=n,t[1]=a}},o.prototype.parsePmd=function(t,e){var a={},o=new n(t);a.metadata={},a.metadata.format="pmd",a.metadata.coordinateSystem="left";var i=function(){var t=a.metadata;if(t.magic=o.getChars(3),"Pmd"!==t.magic)throw"PMD file magic is not Pmd, but "+t.magic;t.version=o.getFloat32(),t.modelName=o.getSjisStringsAsUnicode(20),t.comment=o.getSjisStringsAsUnicode(256)},r=function(){var t=function(){var t={};return t.position=o.getFloat32Array(3),t.normal=o.getFloat32Array(3),t.uv=o.getFloat32Array(2),t.skinIndices=o.getUint16Array(2),t.skinWeights=[o.getUint8()/100],t.skinWeights.push(1-t.skinWeights[0]),t.edgeFlag=o.getUint8(),t},e=a.metadata;e.vertexCount=o.getUint32(),a.vertices=[];for(var n=0;n0&&(t.englishModelName=o.getSjisStringsAsUnicode(20),t.englishComment=o.getSjisStringsAsUnicode(256))},p=function(){var t=function(){var t={};return t.name=o.getSjisStringsAsUnicode(20),t},e=a.metadata;if(0!==e.englishCompatibility){a.englishBoneNames=[];for(var n=0;n>> 0) - 1; + local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1 = 6; + local.O3DGC_BINARY_STREAM_MAX_SYMBOL1 = 63; // ((1 << O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1) >>> 0) - 1; + local.O3DGC_BINARY_STREAM_NUM_SYMBOLS_UINT32 = 5; // Math.floor((32 + O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0 - 1) / O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0); + local.O3DGC_BIG_ENDIAN = 0; + local.O3DGC_LITTLE_ENDIAN = 1; + local.O3DGC_MAX_DOUBLE = 1.79769e+308; + local.O3DGC_MIN_LONG = -2147483647; + local.O3DGC_MAX_LONG = 2147483647; + local.O3DGC_MAX_UCHAR8 = 255; + local.O3DGC_MAX_TFAN_SIZE = 256; + local.O3DGC_MAX_ULONG = 4294967295; + local.O3DGC_SC3DMC_START_CODE = 0x00001F1; + local.O3DGC_DV_START_CODE = 0x00001F2; + local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES = 256; + local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES = 256; + local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES = 32; + local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS = 2; + local.O3DGC_SC3DMC_BINARIZATION_FL = 0; // Fixed Length (not supported) + local.O3DGC_SC3DMC_BINARIZATION_BP = 1; // BPC (not supported) + local.O3DGC_SC3DMC_BINARIZATION_FC = 2; // 4 bits Coding (not supported) + local.O3DGC_SC3DMC_BINARIZATION_AC = 3; // Arithmetic Coding (not supported) + local.O3DGC_SC3DMC_BINARIZATION_AC_EGC = 4; // Arithmetic Coding & EGCk + local.O3DGC_SC3DMC_BINARIZATION_ASCII = 5; // Arithmetic Coding & EGCk + local.O3DGC_STREAM_TYPE_UNKOWN = 0; + local.O3DGC_STREAM_TYPE_ASCII = 1; + local.O3DGC_STREAM_TYPE_BINARY = 2; + local.O3DGC_SC3DMC_NO_PREDICTION = 0; // supported + local.O3DGC_SC3DMC_DIFFERENTIAL_PREDICTION = 1; // supported + local.O3DGC_SC3DMC_XOR_PREDICTION = 2; // not supported + local.O3DGC_SC3DMC_ADAPTIVE_DIFFERENTIAL_PREDICTION = 3; // not supported + local.O3DGC_SC3DMC_CIRCULAR_DIFFERENTIAL_PREDICTION = 4; // not supported + local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION = 5; // supported + local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION = 6; // supported + local.O3DGC_SC3DMC_ENCODE_MODE_QBCR = 0; // not supported + local.O3DGC_SC3DMC_ENCODE_MODE_SVA = 1; // not supported + local.O3DGC_SC3DMC_ENCODE_MODE_TFAN = 2; // supported + local.O3DGC_DYNAMIC_VECTOR_ENCODE_MODE_LIFT = 0; + local.O3DGC_MIN_NEIGHBORS_SIZE = 128; + local.O3DGC_MIN_NUM_NEIGHBORS_SIZE = 16; + local.O3DGC_TFANS_MIN_SIZE_ALLOCATED_VERTICES_BUFFER = 128; + local.O3DGC_TFANS_MIN_SIZE_TFAN_SIZE_BUFFER = 8; + local.O3DGC_DEFAULT_VECTOR_SIZE = 32; + + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_UNKOWN = 0; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_POSITION = 1; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_NORMAL = 2; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_COLOR = 3; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_TEXCOORD = 4; + module.O3DGC_IFS_FLOAT_ATTRIBUTE_TYPE_WEIGHT = 5; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_UNKOWN = 0; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX = 1; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_JOINT_ID = 2; + module.O3DGC_IFS_INT_ATTRIBUTE_TYPE_INDEX_BUFFER_ID = 3; + + module.O3DGC_OK = 0; + module.O3DGC_ERROR_BUFFER_FULL = 1; + module.O3DGC_ERROR_CORRUPTED_STREAM = 5; + module.O3DGC_ERROR_NON_SUPPORTED_FEATURE = 6; + module.O3DGC_ERROR_AC = 7; + + function SystemEndianness() { + var a, b, c; + b = new ArrayBuffer(4); + a = new Uint32Array(b); + c = new Uint8Array(b); + a[0] = 1; + if (c[0] === 1) { + return local.O3DGC_LITTLE_ENDIAN; + } + return local.O3DGC_BIG_ENDIAN; + } + // SC3DMCStats class + module.SC3DMCStats = function () { + this.m_timeCoord = 0; + this.m_timeNormal = 0; + this.m_timeCoordIndex = 0; + this.m_timeFloatAttribute = new Float32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_timeIntAttribute = new Float32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_timeReorder = 0; + this.m_streamSizeCoord = 0; + this.m_streamSizeNormal = 0; + this.m_streamSizeCoordIndex = 0; + this.m_streamSizeFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_streamSizeIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + }; + // SC3DMCTriplet class + module.SC3DMCTriplet = function (a, b, c) { + this.m_a = a; + this.m_b = b; + this.m_c = c; + }; + module.SC3DMCTriplet.prototype.Less = function (rhs) { + var res; + if (this.m_c !== rhs.m_c) { + res = (this.m_c < rhs.m_c); + } else if (this.m_b !== rhs.m_b) { + res = (this.m_b < rhs.m_b); + } else { + res = (this.m_a < rhs.m_a); + } + return res; + }; + module.SC3DMCTriplet.prototype.Equal = function (rhs) { + return (this.m_c === rhs.m_c && this.m_b === rhs.m_b && this.m_a === rhs.m_a); + }; + // SC3DMCPredictor class + module.SC3DMCPredictor = function () { + this.m_id = new module.SC3DMCTriplet(-1, -1, -1); + this.m_pred = new Float32Array(local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + }; + // fix me: optimize this function (e.g., binary search) + function InsertPredictor(e, nPred, list, dimFloatArray) { + var pos, foundOrInserted, j, j1, j0, h, i; + pos = -1; + foundOrInserted = false; + j1 = nPred.m_value; + j0 = 0; + for (j = j0; j < j1; ++j) { + if (e.Equal(list[j].m_id)) { + foundOrInserted = true; + break; + } else if (e.Less(list[j].m_id)) { + if (nPred.m_value < local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS) { + ++nPred.m_value; + } + for (h = nPred.m_value - 1; h > j; --h) { + list[h].m_id.m_a = list[h - 1].m_id.m_a; + list[h].m_id.m_b = list[h - 1].m_id.m_b; + list[h].m_id.m_c = list[h - 1].m_id.m_c; + for (i = 0; i < dimFloatArray; ++i) { + list[h].m_pred[i] = list[h - 1].m_pred[i]; + } + } + list[j].m_id.m_a = e.m_a; + list[j].m_id.m_b = e.m_b; + list[j].m_id.m_c = e.m_c; + pos = j; + foundOrInserted = true; + break; + } + } + if (!foundOrInserted && nPred.m_value < local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS) { + pos = nPred.m_value++; + list[pos].m_id.m_a = e.m_a; + list[pos].m_id.m_b = e.m_b; + list[pos].m_id.m_c = e.m_c; + } + return pos; + } + // Timer class + if (typeof window.performance === 'undefined') { + window.performance = {}; + } + if (!window.performance.now) { + local.nowOffset = Date.now(); + if (performance.timing && performance.timing.navigationStart) { + local.nowOffset = performance.timing.navigationStart; + } + window.performance.now = function now() { + return Date.now() - local.nowOffset; + }; + } + module.Timer = function () { + this.m_start = 0; + this.m_end = 0; + }; + module.Timer.prototype.Tic = function () { + this.m_start = window.performance.now(); + }; + module.Timer.prototype.Toc = function () { + this.m_end = window.performance.now(); + }; + module.Timer.prototype.GetElapsedTime = function () { + return this.m_end - this.m_start; + }; + // Vec3 class + module.Vec3 = function (x, y, z) { + this.m_x = x; + this.m_y = y; + this.m_z = z; + }; + module.Vec3.prototype.Set = function (x, y, z) { + this.m_x = x; + this.m_y = y; + this.m_z = z; + }; + module.Vec3.prototype.Sub = function (lhs, rhs) { + this.m_x = lhs.m_x - rhs.m_x; + this.m_y = lhs.m_y - rhs.m_y; + this.m_z = lhs.m_z - rhs.m_z; + }; + module.Vec3.prototype.Add = function (lhs, rhs) { + this.m_x = lhs.m_x + rhs.m_x; + this.m_y = lhs.m_y + rhs.m_y; + this.m_z = lhs.m_z + rhs.m_z; + }; + module.Vec3.prototype.SelfAdd = function (v) { + this.m_x += v.m_x; + this.m_y += v.m_y; + this.m_z += v.m_z; + }; + module.Vec3.prototype.Cross = function (lhs, rhs) { + this.m_x = lhs.m_y * rhs.m_z - lhs.m_z * rhs.m_y; + this.m_y = lhs.m_z * rhs.m_x - lhs.m_x * rhs.m_z; + this.m_z = lhs.m_x * rhs.m_y - lhs.m_y * rhs.m_x; + }; + module.Vec3.prototype.GetNorm = function () { + return Math.sqrt(this.m_x * this.m_x + this.m_y * this.m_y + this.m_z * this.m_z); + }; + function SphereToCube(vin, vout) { + var ax, ay, az; + ax = Math.abs(vin.m_x); + ay = Math.abs(vin.m_y); + az = Math.abs(vin.m_z); + if (az >= ax && az >= ay) { + if (vin.m_z >= 0) { + vout.m_z = 0; + vout.m_x = vin.m_x; + vout.m_y = vin.m_y; + } else { + vout.m_z = 1; + vout.m_x = -vin.m_x; + vout.m_y = -vin.m_y; + } + } else if (ay >= ax && ay >= az) { + if (vin.m_y >= 0) { + vout.m_z = 2; + vout.m_x = vin.m_z; + vout.m_y = vin.m_x; + } else { + vout.m_z = 3; + vout.m_x = -vin.m_z; + vout.m_y = -vin.m_x; + } + } else { + if (vin.m_x >= 0) { + vout.m_z = 4; + vout.m_x = vin.m_y; + vout.m_y = vin.m_z; + } else { + vout.m_z = 5; + vout.m_x = -vin.m_y; + vout.m_y = -vin.m_z; + } + } + } + local.CubeToSphere = { + 0: function (vin, vout) { + vout.m_x = vin.m_x; + vout.m_y = vin.m_y; + vout.m_z = Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_y * vout.m_y)); + }, + 1: function (vin, vout) { + vout.m_x = -vin.m_x; + vout.m_y = -vin.m_y; + vout.m_z = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_y * vout.m_y)); + }, + 2: function (vin, vout) { + vout.m_z = vin.m_x; + vout.m_x = vin.m_y; + vout.m_y = Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_z * vout.m_z)); + }, + 3: function (vin, vout) { + vout.m_z = -vin.m_x; + vout.m_x = -vin.m_y; + vout.m_y = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_x * vout.m_x - vout.m_z * vout.m_z)); + }, + 4: function (vin, vout) { + vout.m_y = vin.m_x; + vout.m_z = vin.m_y; + vout.m_x = Math.sqrt(Math.max(0.0, 1.0 - vout.m_y * vout.m_y - vout.m_z * vout.m_z)); + }, + 5: function (vin, vout) { + vout.m_y = -vin.m_x; + vout.m_z = -vin.m_y; + vout.m_x = -Math.sqrt(Math.max(0.0, 1.0 - vout.m_y * vout.m_y - vout.m_z * vout.m_z)); + } + }; + function IntToUInt(value) { + return (value < 0) ? (-1 - (2 * value)) : (2 * value); + } + function UIntToInt(uiValue) { + return (uiValue & 1) ? -((uiValue + 1) >>> 1) : ((uiValue >>> 1)); + } + module.Iterator = function () { + this.m_count = 0; + }; + module.NumberRef = function () { + this.m_value = 0; + }; + // BinaryStream class + module.BinaryStream = function (buffer) { + this.m_endianness = SystemEndianness(); + this.m_buffer = buffer; + this.m_stream = new Uint8Array(this.m_buffer); + this.m_localBuffer = new ArrayBuffer(4); + this.m_localBufferViewUChar8 = new Uint8Array(this.m_localBuffer); + this.m_localBufferViewFloat32 = new Float32Array(this.m_localBuffer); + this.m_localBufferViewUInt32 = new Uint32Array(this.m_localBuffer); + }; + module.BinaryStream.prototype.ReadFloat32Bin = function (bsIterator) { + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + } else { + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + } + return this.m_localBufferViewFloat32[0]; + }; + module.BinaryStream.prototype.ReadUInt32Bin = function (bsIterator) { + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + } else { + this.m_localBufferViewUChar8[0] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[1] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[2] = this.m_stream[bsIterator.m_count++]; + this.m_localBufferViewUChar8[3] = this.m_stream[bsIterator.m_count++]; + } + return this.m_localBufferViewUInt32[0]; + }; + module.BinaryStream.prototype.ReadUChar8Bin = function (bsIterator) { + return this.m_stream[bsIterator.m_count++]; + }; + module.BinaryStream.prototype.ReadUInt32ASCII = function (bsIterator) { + var value, shift, i; + value = 0; + shift = 0; + for (i = 0; i < local.O3DGC_BINARY_STREAM_NUM_SYMBOLS_UINT32; ++i) { + value += (this.m_stream[bsIterator.m_count++] << shift) >>> 0; + shift += local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0; + } + return value; + }; + module.BinaryStream.prototype.ReadFloat32ASCII = function (bsIterator) { + var value = this.ReadUInt32ASCII(bsIterator); + if (this.m_endianness === local.O3DGC_BIG_ENDIAN) { + this.m_localBufferViewUChar8[3] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[2] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[1] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[0] = value & local.O3DGC_MAX_UCHAR8; + } else { + this.m_localBufferViewUChar8[0] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[1] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[2] = value & local.O3DGC_MAX_UCHAR8; + value >>>= 8; + this.m_localBufferViewUChar8[3] = value & local.O3DGC_MAX_UCHAR8; + } + return this.m_localBufferViewFloat32[0]; + }; + module.BinaryStream.prototype.ReadIntASCII = function (bsIterator) { + return UIntToInt(this.ReadUIntASCII(bsIterator)); + }; + module.BinaryStream.prototype.ReadUIntASCII = function (bsIterator) { + var i, x, value; + value = this.m_stream[bsIterator.m_count++]; + if (value === local.O3DGC_BINARY_STREAM_MAX_SYMBOL0) { + i = 0; + do { + x = this.m_stream[bsIterator.m_count++]; + value += ((x >>> 1) << i) >>> 0; + i += local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL1; + } while (x & 1); + } + return value; + }; + module.BinaryStream.prototype.ReadUCharASCII = function (bsIterator) { + return this.m_stream[bsIterator.m_count++]; + }; + module.BinaryStream.prototype.ReadFloat32 = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadFloat32ASCII(bsIterator); + } + return this.ReadFloat32Bin(bsIterator); + }; + module.BinaryStream.prototype.ReadUInt32 = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadUInt32ASCII(bsIterator); + } + return this.ReadUInt32Bin(bsIterator); + }; + module.BinaryStream.prototype.ReadUChar = function (bsIterator, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.ReadUCharASCII(bsIterator); + } + return this.ReadUChar8Bin(bsIterator); + }; + module.BinaryStream.prototype.GetBuffer = function (bsIterator, size) { + return new Uint8Array(this.m_buffer, bsIterator.m_count, size); + }; + + // Copyright (c) 2004 Amir Said (said@ieee.org) & William A. Pearlman (pearlw@ecse.rpi.edu) + // All rights reserved. + + local.O3DGC_AC_MIN_LENGTH = 0x01000000; // threshold for renormalization + local.O3DGC_AC_MAX_LENGTH = 0xFFFFFFFF; // maximum AC interval length + local.O3DGC_AC_BM_LENGTH_SHIFT = 13; // Maximum values for binary models length bits discarded before mult. + local.O3DGC_AC_BM_MAX_COUNT = (1 << local.O3DGC_AC_BM_LENGTH_SHIFT) >>> 0; // for adaptive models + local.O3DGC_AC_DM_LENGTH_SHIFT = 15; // Maximum values for general models length bits discarded before mult. + local.O3DGC_AC_DM_MAX_COUNT = (1 << local.O3DGC_AC_DM_LENGTH_SHIFT) >>> 0; // for adaptive models + // StaticBitModel class + module.StaticBitModel = function () { + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; // p0 = 0.5 + }; + module.StaticBitModel.prototype.SetProbability = function (p) { + this.m_bit0Prob = Math.floor(p * ((1 << local.O3DGC_AC_BM_LENGTH_SHIFT) >>> 0)); + }; + // AdaptiveBitModel class + module.AdaptiveBitModel = function () { + // initialization to equiprobable model + this.m_updateCycle = 4; + this.m_bitsUntilUpdate = 4; + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; + this.m_bit0Count = 1; + this.m_bitCount = 2; + }; + module.AdaptiveBitModel.prototype.Reset = function () { + this.m_updateCycle = 4; + this.m_bitsUntilUpdate = 4; + this.m_bit0Prob = (1 << (local.O3DGC_AC_BM_LENGTH_SHIFT - 1)) >>> 0; + this.m_bit0Count = 1; + this.m_bitCount = 2; + }; + module.AdaptiveBitModel.prototype.Update = function () { + // halve counts when a threshold is reached + if ((this.m_bitCount += this.m_updateCycle) > local.O3DGC_AC_BM_MAX_COUNT) { + this.m_bitCount = (this.m_bitCount + 1) >>> 1; + this.m_bit0Count = (this.m_bit0Count + 1) >>> 1; + if (this.m_bit0Count === this.m_bitCount) { + ++this.m_bitCount; + } + } + // compute scaled bit 0 probability + var scale = Math.floor(0x80000000 / this.m_bitCount); + this.m_bit0Prob = (this.m_bit0Count * scale) >>> (31 - local.O3DGC_AC_BM_LENGTH_SHIFT); + // set frequency of model updates + this.m_updateCycle = (5 * this.m_updateCycle) >>> 2; + if (this.m_updateCycle > 64) { + this.m_updateCycle = 64; + } + this.m_bitsUntilUpdate = this.m_updateCycle; + }; + // AdaptiveDataModel class + module.AdaptiveDataModel = function () { + this.m_buffer = {}; + this.m_distribution = {}; + this.m_symbolCount = {}; + this.m_decoderTable = {}; + this.m_totalCount = 0; + this.m_updateCycle = 0; + this.m_symbolsUntilUpdate = 0; + this.m_dataSymbols = 0; + this.m_lastSymbol = 0; + this.m_tableSize = 0; + this.m_tableShift = 0; + }; + module.AdaptiveDataModel.prototype.Update = function () { + var n, sum, s, scale, k, max_cycle, w; + // halve counts when a threshold is reached + if ((this.m_totalCount += this.m_updateCycle) > local.O3DGC_AC_DM_MAX_COUNT) { + this.m_totalCount = 0; + for (n = 0; n < this.m_dataSymbols; ++n) { + this.m_totalCount += (this.m_symbolCount[n] = (this.m_symbolCount[n] + 1) >>> 1); + } + } + // compute cumulative distribution, decoder table + sum = 0; + s = 0; + scale = Math.floor(0x80000000 / this.m_totalCount); + if (this.m_tableSize === 0) { + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_distribution[k] = (scale * sum) >>> (31 - local.O3DGC_AC_DM_LENGTH_SHIFT); + sum += this.m_symbolCount[k]; + } + } else { + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_distribution[k] = (scale * sum) >>> (31 - local.O3DGC_AC_DM_LENGTH_SHIFT); + sum += this.m_symbolCount[k]; + w = this.m_distribution[k] >>> this.m_tableShift; + while (s < w) { + this.m_decoderTable[++s] = k - 1; + } + } + this.m_decoderTable[0] = 0; + while (s <= this.m_tableSize) { + this.m_decoderTable[++s] = this.m_dataSymbols - 1; + } + } + // set frequency of model updates + this.m_updateCycle = (5 * this.m_updateCycle) >>> 2; + max_cycle = ((this.m_dataSymbols + 6) << 3) >>> 0; + if (this.m_updateCycle > max_cycle) { + this.m_updateCycle = max_cycle; + } + this.m_symbolsUntilUpdate = this.m_updateCycle; + }; + module.AdaptiveDataModel.prototype.Reset = function () { + var k; + if (this.m_dataSymbols === 0) { + return; + } + // restore probability estimates to uniform distribution + this.m_totalCount = 0; + this.m_updateCycle = this.m_dataSymbols; + for (k = 0; k < this.m_dataSymbols; ++k) { + this.m_symbolCount[k] = 1; + } + this.Update(); + this.m_symbolsUntilUpdate = this.m_updateCycle = (this.m_dataSymbols + 6) >>> 1; + }; + module.AdaptiveDataModel.prototype.SetAlphabet = function (number_of_symbols) { + if ((number_of_symbols < 2) || (number_of_symbols > (1 << 11))) { + Console.log("invalid number of data symbols"); + return module.O3DGC_ERROR_AC; + } + if (this.m_dataSymbols !== number_of_symbols) { // assign memory for data model + this.m_dataSymbols = number_of_symbols; + this.m_lastSymbol = this.m_dataSymbols - 1; + // define size of table for fast decoding + if (this.m_dataSymbols > 16) { + var table_bits = 3; + while (this.m_dataSymbols > ((1 << (table_bits + 2)) >>> 0)) { + ++table_bits; + } + this.m_tableSize = (1 << table_bits) >>> 0; + this.m_tableShift = local.O3DGC_AC_DM_LENGTH_SHIFT - table_bits; + this.m_buffer = new ArrayBuffer(4 * (2 * this.m_dataSymbols + this.m_tableSize + 2)); + this.m_distribution = new Uint32Array(this.m_buffer, 0, this.m_dataSymbols); + this.m_symbolCount = new Uint32Array(this.m_buffer, 4 * this.m_dataSymbols, this.m_dataSymbols); + this.m_decoderTable = new Uint32Array(this.m_buffer, 8 * this.m_dataSymbols, this.m_tableSize + 2); + } else {// small alphabet: no table needed + this.m_tableSize = this.m_tableShift = 0; + this.m_buffer = new ArrayBuffer(4 * 2 * this.m_dataSymbols); + this.m_distribution = new Uint32Array(this.m_buffer, 0, this.m_dataSymbols); + this.m_symbolCount = new Uint32Array(this.m_buffer, 4 * this.m_dataSymbols, this.m_dataSymbols); + this.m_decoderTable = {}; + } + } + this.Reset(); // initialize model + return module.O3DGC_OK; + }; + // ArithmeticDecoder class + module.ArithmeticDecoder = function () { + this.m_codeBuffer = {}; + this.m_acShift = 0; + this.m_base = 0; + this.m_value = 0; + this.m_length = 0; // arithmetic coding state + this.m_bufferSize = 0; + this.m_mode = 0; // mode: 0 = undef, 1 = encoder, 2 = decoder + }; + module.ArithmeticDecoder.prototype.SetBuffer = function (max_code_bytes, user_buffer) { + if (max_code_bytes === 0) { + Console.log("invalid codec buffer size"); + return module.O3DGC_ERROR_AC; + } + if (this.m_mode !== 0) { + Console.log("cannot set buffer while encoding or decoding"); + return module.O3DGC_ERROR_AC; + } + this.m_bufferSize = max_code_bytes; + this.m_codeBuffer = user_buffer; + }; + module.ArithmeticDecoder.prototype.StartDecoder = function () { + if (this.m_mode !== 0) { + Console.log("cannot start decoder"); + return module.O3DGC_ERROR_AC; + } + if (this.m_bufferSize === 0) { + Console.log("no code buffer set"); + return module.O3DGC_ERROR_AC; + } + // initialize decoder: interval, pointer, initial code value + this.m_mode = 2; + this.m_length = local.O3DGC_AC_MAX_LENGTH; + this.m_acShift = 3; + this.m_value = ((this.m_codeBuffer[0] << 24) | (this.m_codeBuffer[1] << 16) | (this.m_codeBuffer[2] << 8) | (this.m_codeBuffer[3])) >>> 0; + }; + module.ArithmeticDecoder.prototype.StopDecoder = function () { + if (this.m_mode !== 2) { + Console.log("invalid to stop decoder"); + return module.O3DGC_ERROR_AC; + } + this.m_mode = 0; + }; + module.ArithmeticDecoder.prototype.GetBit = function () { + this.m_length >>>= 1; // halve interval + var bit = (this.m_value >= this.m_length); // decode bit + if (bit) { + this.m_value -= this.m_length; // move base + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return bit; + }; + module.ArithmeticDecoder.prototype.GetBits = function (bits) { + var s = Math.floor(this.m_value / (this.m_length >>>= bits)); // decode symbol, change length + this.m_value -= this.m_length * s; // update interval + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return s; + }; + module.ArithmeticDecoder.prototype.DecodeStaticBitModel = function (M) { + var x, bit; + x = M.m_bit0Prob * (this.m_length >>> local.O3DGC_AC_BM_LENGTH_SHIFT); // product l x p0 + bit = (this.m_value >= x); // decision + // update & shift interval + if (!bit) { + this.m_length = x; + } else { + this.m_value -= x; // shifted interval base = 0 + this.m_length -= x; + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + return bit; // return data bit value + }; + module.ArithmeticDecoder.prototype.DecodeAdaptiveBitModel = function (M) { + var x, bit; + x = M.m_bit0Prob * (this.m_length >>> local.O3DGC_AC_BM_LENGTH_SHIFT); // product l x p0 + bit = (this.m_value >= x); // decision + // update interval + if (!bit) { + this.m_length = x; + ++M.m_bit0Count; + } else { + this.m_value -= x; + this.m_length -= x; + } + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + if (--M.m_bitsUntilUpdate === 0) { + M.Update(); // periodic model update + } + return bit; // return data bit value + }; + module.ArithmeticDecoder.prototype.DecodeAdaptiveDataModel = function (M) { + var n, s, x, y, t, dv, z, m; + y = this.m_length; + if (M.m_tableSize > 0) { // use table look-up for faster decoding + dv = Math.floor(this.m_value / (this.m_length >>>= local.O3DGC_AC_DM_LENGTH_SHIFT)); + t = dv >>> M.m_tableShift; + s = M.m_decoderTable[t]; // initial decision based on table look-up + n = M.m_decoderTable[t + 1] + 1; + while (n > s + 1) { // finish with bisection search + m = (s + n) >>> 1; + if (M.m_distribution[m] > dv) { + n = m; + } else { + s = m; + } + } + // compute products + x = M.m_distribution[s] * this.m_length; + if (s !== M.m_lastSymbol) { + y = M.m_distribution[s + 1] * this.m_length; + } + } else { // decode using only multiplications + x = s = 0; + this.m_length >>>= local.O3DGC_AC_DM_LENGTH_SHIFT; + m = (n = M.m_dataSymbols) >>> 1; + // decode via bisection search + do { + z = this.m_length * M.m_distribution[m]; + if (z > this.m_value) { + n = m; + y = z; // value is smaller + } else { + s = m; + x = z; // value is larger or equal + } + } while ((m = (s + n) >>> 1) !== s); + } + this.m_value -= x; // update interval + this.m_length = y - x; + if (this.m_length < local.O3DGC_AC_MIN_LENGTH) { + this.RenormDecInterval(); // renormalization + } + ++M.m_symbolCount[s]; + if (--M.m_symbolsUntilUpdate === 0) { + M.Update(false); // periodic model update + } + return s; + }; + module.ArithmeticDecoder.prototype.ExpGolombDecode = function (k, bModel0, bModel1) { + var symbol, binary_symbol, l; + symbol = 0; + binary_symbol = 0; + do { + l = this.DecodeAdaptiveBitModel(bModel1); + if (l) { + symbol += (1 << k) >>> 0; + k++; + } + } while (l); + while (k--) { //next binary part + if (this.DecodeStaticBitModel(bModel0)) { + binary_symbol = (binary_symbol | (1 << k)) >>> 0; + } + } + return (symbol + binary_symbol); + }; + module.ArithmeticDecoder.prototype.RenormDecInterval = function () { + do { // read least-significant byte + this.m_value = ((this.m_value << 8) | this.m_codeBuffer[++this.m_acShift]) >>> 0; + this.m_length = (this.m_length << 8) >>> 0; + } while (this.m_length < local.O3DGC_AC_MIN_LENGTH); // length multiplied by 256 + }; + module.ArithmeticDecoder.prototype.DecodeIntACEGC = function (mModelValues, bModel0, bModel1, exp_k, M) { + var uiValue = this.DecodeAdaptiveDataModel(mModelValues); + if (uiValue === M) { + uiValue += this.ExpGolombDecode(exp_k, bModel0, bModel1); + } + return UIntToInt(uiValue); + }; + module.ArithmeticDecoder.prototype.DecodeUIntACEGC = function (mModelValues, bModel0, bModel1, exp_k, M) { + var uiValue = this.DecodeAdaptiveDataModel(mModelValues); + if (uiValue === M) { + uiValue += this.ExpGolombDecode(exp_k, bModel0, bModel1); + } + return uiValue; + }; + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // FIFO class + module.FIFO = function () { + this.m_data = {}; + this.m_allocated = 0; + this.m_size = 0; + this.m_start = 0; + this.m_end = 0; + }; + module.FIFO.prototype.Clear = function () { + this.m_start = this.m_end = this.m_size = 0; + }; + module.FIFO.prototype.GetAllocatedSize = function () { + return this.m_allocated; + }; + module.FIFO.prototype.GetSize = function () { + return this.m_size; + }; + module.FIFO.prototype.Allocate = function (size) { + if (size > this.m_allocated) { + this.m_allocated = size; + this.m_data = new Int32Array(this.m_allocated); + } + this.Clear(); + return module.O3DGC_OK; + }; + module.FIFO.prototype.PopFirst = function () { + --this.m_size; + var current = this.m_start++; + if (this.m_start === this.m_allocated) { + this.m_end = 0; + } + return this.m_data[current]; + }; + module.FIFO.prototype.PushBack = function (value) { + --this.m_size; + this.m_data[this.m_end] = value; + ++this.m_size; + ++this.m_end; + if (this.m_end === this.m_allocated) { + this.m_end = 0; + } + }; + // IndexedFaceSet class + module.IndexedFaceSet = function () { + this.m_nCoordIndex = 0; + this.m_nCoord = 0; + this.m_nNormal = 0; + this.m_numFloatAttributes = 0; + this.m_numIntAttributes = 0; + this.m_creaseAngle = 30.0; + this.m_ccw = true; + this.m_solid = true; + this.m_convex = true; + this.m_isTriangularMesh = true; + this.m_coordMin = new Float32Array(3); + this.m_coordMax = new Float32Array(3); + this.m_normalMin = new Float32Array(3); + this.m_normalMax = new Float32Array(3); + this.m_nFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_nIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_dimFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_dimIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_typeFloatAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_typeIntAttribute = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_minFloatAttributeBuffer = new ArrayBuffer(4 * local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_minFloatAttribute = new Float32Array(this.m_minFloatAttributeBuffer); + this.m_maxFloatAttributeBuffer = new ArrayBuffer(4 * local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_maxFloatAttribute = new Float32Array(this.m_maxFloatAttributeBuffer); + this.m_coordIndex = {}; + this.m_coord = {}; + this.m_normal = {}; + this.m_floatAttribute = []; + this.m_intAttribute = []; + }; + module.IndexedFaceSet.prototype.GetNCoordIndex = function () { + return this.m_nCoordIndex; + }; + module.IndexedFaceSet.prototype.GetNCoordIndex = function () { + return this.m_nCoordIndex; + }; + module.IndexedFaceSet.prototype.GetNCoord = function () { + return this.m_nCoord; + }; + module.IndexedFaceSet.prototype.GetNNormal = function () { + return this.m_nNormal; + }; + module.IndexedFaceSet.prototype.GetNFloatAttribute = function (a) { + return this.m_nFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetNIntAttribute = function (a) { + return this.m_nIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetNumFloatAttributes = function () { + return this.m_numFloatAttributes; + }; + module.IndexedFaceSet.prototype.GetNumIntAttributes = function () { + return this.m_numIntAttributes; + }; + module.IndexedFaceSet.prototype.GetCoordMinArray = function () { + return this.m_coordMin; + }; + module.IndexedFaceSet.prototype.GetCoordMaxArray = function () { + return this.m_coordMax; + }; + module.IndexedFaceSet.prototype.GetNormalMinArray = function () { + return this.m_normalMin; + }; + module.IndexedFaceSet.prototype.GetNormalMaxArray = function () { + return this.m_normalMax; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMinArray = function (a) { + return (new Float32Array(this.m_minFloatAttributeBuffer, a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES * 4, this.GetFloatAttributeDim(a))); + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMaxArray = function (a) { + return (new Float32Array(this.m_maxFloatAttributeBuffer, a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES * 4, this.GetFloatAttributeDim(a))); + }; + module.IndexedFaceSet.prototype.GetFloatAttributeDim = function (a) { + return this.m_dimFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttributeDim = function (a) { + return this.m_dimIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeType = function (a) { + return this.m_typeFloatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttributeType = function (a) { + return this.m_typeIntAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetFloatAttributeMax = function (a, dim) { + return this.m_maxFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim]; + }; + module.IndexedFaceSet.prototype.GetCreaseAngle = function () { + return this.m_creaseAngle; + }; + module.IndexedFaceSet.prototype.GetCreaseAngle = function () { + return this.m_creaseAngle; + }; + module.IndexedFaceSet.prototype.GetCCW = function () { + return this.m_ccw; + }; + module.IndexedFaceSet.prototype.GetSolid = function () { + return this.m_solid; + }; + module.IndexedFaceSet.prototype.GetConvex = function () { + return this.m_convex; + }; + module.IndexedFaceSet.prototype.GetIsTriangularMesh = function () { + return this.m_isTriangularMesh; + }; + module.IndexedFaceSet.prototype.GetCoordIndex = function () { + return this.m_coordIndex; + }; + module.IndexedFaceSet.prototype.GetCoordIndex = function () { + return this.m_coordIndex; + }; + module.IndexedFaceSet.prototype.GetCoord = function () { + return this.m_coord; + }; + module.IndexedFaceSet.prototype.GetNormal = function () { + return this.m_normal; + }; + module.IndexedFaceSet.prototype.GetFloatAttribute = function (a) { + return this.m_floatAttribute[a]; + }; + module.IndexedFaceSet.prototype.GetIntAttribute = function (a) { + return this.m_intAttribute[a]; + }; + module.IndexedFaceSet.prototype.SetNCoordIndex = function (nCoordIndex) { + this.m_nCoordIndex = nCoordIndex; + }; + module.IndexedFaceSet.prototype.SetNNormalIndex = function (nNormalIndex) { + }; + module.IndexedFaceSet.prototype.SetNormalPerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetNFloatAttributeIndex = function (nFloatAttributeIndex) { + }; + module.IndexedFaceSet.prototype.SetNIntAttributeIndex = function (nIntAttributeIndex) { + }; + module.IndexedFaceSet.prototype.SetFloatAttributePerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetIntAttributePerVertex = function (perVertex) { + }; + module.IndexedFaceSet.prototype.SetNCoord = function (nCoord) { + this.m_nCoord = nCoord; + }; + module.IndexedFaceSet.prototype.SetNNormal = function (nNormal) { + this.m_nNormal = nNormal; + }; + module.IndexedFaceSet.prototype.SetNumFloatAttributes = function (numFloatAttributes) { + this.m_numFloatAttributes = numFloatAttributes; + }; + module.IndexedFaceSet.prototype.SetNumIntAttributes = function (numIntAttributes) { + this.m_numIntAttributes = numIntAttributes; + }; + module.IndexedFaceSet.prototype.SetCreaseAngle = function (creaseAngle) { + this.m_creaseAngle = creaseAngle; + }; + module.IndexedFaceSet.prototype.SetCCW = function (ccw) { + this.m_ccw = ccw; + }; + module.IndexedFaceSet.prototype.SetSolid = function (solid) { + this.m_solid = solid; + }; + module.IndexedFaceSet.prototype.SetConvex = function (convex) { + this.m_convex = convex; + }; + module.IndexedFaceSet.prototype.SetIsTriangularMesh = function (isTriangularMesh) { + this.m_isTriangularMesh = isTriangularMesh; + }; + module.IndexedFaceSet.prototype.SetCoordMin = function (j, min) { + this.m_coordMin[j] = min; + }; + module.IndexedFaceSet.prototype.SetCoordMax = function (j, max) { + this.m_coordMax[j] = max; + }; + module.IndexedFaceSet.prototype.SetNormalMin = function (j, min) { + this.m_normalMin[j] = min; + }; + module.IndexedFaceSet.prototype.SetNormalMax = function (j, max) { + this.m_normalMax[j] = max; + }; + module.IndexedFaceSet.prototype.SetNFloatAttribute = function (a, nFloatAttribute) { + this.m_nFloatAttribute[a] = nFloatAttribute; + }; + module.IndexedFaceSet.prototype.SetNIntAttribute = function (a, nIntAttribute) { + this.m_nIntAttribute[a] = nIntAttribute; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeDim = function (a, d) { + this.m_dimFloatAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetIntAttributeDim = function (a, d) { + this.m_dimIntAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeType = function (a, d) { + this.m_typeFloatAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetIntAttributeType = function (a, d) { + this.m_typeIntAttribute[a] = d; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeMin = function (a, dim, min) { + this.m_minFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = min; + }; + module.IndexedFaceSet.prototype.SetFloatAttributeMax = function (a, dim, max) { + this.m_maxFloatAttribute[a * local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES + dim] = max; + }; + module.IndexedFaceSet.prototype.SetCoordIndex = function (coordIndex) { + this.m_coordIndex = coordIndex; + }; + module.IndexedFaceSet.prototype.SetCoord = function (coord) { + this.m_coord = coord; + }; + module.IndexedFaceSet.prototype.SetNormal = function (normal) { + this.m_normal = normal; + }; + module.IndexedFaceSet.prototype.SetFloatAttribute = function (a, floatAttribute) { + this.m_floatAttribute[a] = floatAttribute; + }; + module.IndexedFaceSet.prototype.SetIntAttribute = function (a, intAttribute) { + this.m_intAttribute[a] = intAttribute; + }; + + // SC3DMCEncodeParams class + module.SC3DMCEncodeParams = function () { + var a; + this.m_numFloatAttributes = 0; + this.m_numIntAttributes = 0; + this.m_floatAttributeQuantBits = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_floatAttributePredMode = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES); + this.m_intAttributePredMode = new Uint32Array(local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES); + this.m_encodeMode = local.O3DGC_SC3DMC_ENCODE_MODE_TFAN; + this.m_streamTypeMode = local.O3DGC_STREAM_TYPE_ASCII; + this.m_coordQuantBits = 14; + this.m_normalQuantBits = 8; + this.m_coordPredMode = local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + this.m_normalPredMode = local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION; + for (a = 0; a < local.O3DGC_SC3DMC_MAX_NUM_FLOAT_ATTRIBUTES; ++a) { + this.m_floatAttributePredMode[a] = local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + } + for (a = 0; a < local.O3DGC_SC3DMC_MAX_NUM_INT_ATTRIBUTES; ++a) { + this.m_intAttributePredMode[a] = local.O3DGC_SC3DMC_DIFFERENTIAL_PREDICTION; + } + }; + module.SC3DMCEncodeParams.prototype.GetStreamType = function () { + return this.m_streamTypeMode; + }; + module.SC3DMCEncodeParams.prototype.GetEncodeMode = function () { + return this.m_encodeMode; + }; + module.SC3DMCEncodeParams.prototype.GetNumFloatAttributes = function () { + return this.m_numFloatAttributes; + }; + module.SC3DMCEncodeParams.prototype.GetNumIntAttributes = function () { + return this.m_numIntAttributes; + }; + module.SC3DMCEncodeParams.prototype.GetCoordQuantBits = function () { + return this.m_coordQuantBits; + }; + module.SC3DMCEncodeParams.prototype.GetNormalQuantBits = function () { + return this.m_normalQuantBits; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributeQuantBits = function (a) { + return this.m_floatAttributeQuantBits[a]; + }; + module.SC3DMCEncodeParams.prototype.GetCoordPredMode = function () { + return this.m_coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetNormalPredMode = function () { + return this.m_normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributePredMode = function (a) { + return this.m_floatAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetIntAttributePredMode = function (a) { + return this.m_intAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetCoordPredMode = function () { + return this.m_coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetNormalPredMode = function () { + return this.m_normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.GetFloatAttributePredMode = function (a) { + return this.m_floatAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.GetIntAttributePredMode = function (a) { + return this.m_intAttributePredMode[a]; + }; + module.SC3DMCEncodeParams.prototype.SetStreamType = function (streamTypeMode) { + this.m_streamTypeMode = streamTypeMode; + }; + module.SC3DMCEncodeParams.prototype.SetEncodeMode = function (encodeMode) { + this.m_encodeMode = encodeMode; + }; + module.SC3DMCEncodeParams.prototype.SetNumFloatAttributes = function (numFloatAttributes) { + this.m_numFloatAttributes = numFloatAttributes; + }; + module.SC3DMCEncodeParams.prototype.SetNumIntAttributes = function (numIntAttributes) { + this.m_numIntAttributes = numIntAttributes; + }; + module.SC3DMCEncodeParams.prototype.SetCoordQuantBits = function (coordQuantBits) { + this.m_coordQuantBits = coordQuantBits; + }; + module.SC3DMCEncodeParams.prototype.SetNormalQuantBits = function (normalQuantBits) { + this.m_normalQuantBits = normalQuantBits; + }; + module.SC3DMCEncodeParams.prototype.SetFloatAttributeQuantBits = function (a, q) { + this.m_floatAttributeQuantBits[a] = q; + }; + module.SC3DMCEncodeParams.prototype.SetCoordPredMode = function (coordPredMode) { + this.m_coordPredMode = coordPredMode; + }; + module.SC3DMCEncodeParams.prototype.SetNormalPredMode = function (normalPredMode) { + this.m_normalPredMode = normalPredMode; + }; + module.SC3DMCEncodeParams.prototype.SetFloatAttributePredMode = function (a, p) { + this.m_floatAttributePredMode[a] = p; + }; + module.SC3DMCEncodeParams.prototype.SetIntAttributePredMode = function (a, p) { + this.m_intAttributePredMode[a] = p; + }; + // AdjacencyInfo class + module.AdjacencyInfo = function () { + this.m_neighborsSize = 0; // actual allocated size for m_neighbors + this.m_numNeighborsSize = 0; // actual allocated size for m_numNeighbors + this.m_numElements = 0; // number of elements + this.m_neighbors = {}; + this.m_numNeighbors = {}; + }; + module.AdjacencyInfo.prototype.Allocate = function (numNeighborsSize, neighborsSize) { + this.m_numElements = numNeighborsSize; + if (neighborsSize > this.m_neighborsSize) { + this.m_neighborsSize = neighborsSize; + this.m_neighbors = new Int32Array(this.m_neighborsSize); + } + if (numNeighborsSize > this.m_numNeighborsSize) { + this.m_numNeighborsSize = numNeighborsSize; + this.m_numNeighbors = new Int32Array(this.m_numNeighborsSize); + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.AllocateNumNeighborsArray = function (numElements) { + if (numElements > this.m_numNeighborsSize) { + this.m_numNeighborsSize = numElements; + this.m_numNeighbors = new Int32Array(this.m_numNeighborsSize); + } + this.m_numElements = numElements; + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.AllocateNeighborsArray = function () { + var i; + for (i = 1; i < this.m_numElements; ++i) { + this.m_numNeighbors[i] += this.m_numNeighbors[i - 1]; + } + if (this.m_numNeighbors[this.m_numElements - 1] > this.m_neighborsSize) { + this.m_neighborsSize = this.m_numNeighbors[this.m_numElements - 1]; + this.m_neighbors = new Int32Array(this.m_neighborsSize); + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.ClearNumNeighborsArray = function () { + var i; + for (i = 0; i < this.m_numElements; ++i) { + this.m_numNeighbors[i] = 0; + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.ClearNeighborsArray = function () { + var i; + for (i = 0; i < this.m_neighborsSize; ++i) { + this.m_neighbors[i] = -1; + } + return module.O3DGC_OK; + }; + module.AdjacencyInfo.prototype.Begin = function (element) { + return (element > 0) ? this.m_numNeighbors[element - 1] : 0; + }; + module.AdjacencyInfo.prototype.End = function (element) { + return this.m_numNeighbors[element]; + }; + module.AdjacencyInfo.prototype.AddNeighbor = function (element, neighbor) { + var p, p0, p1; + p0 = this.Begin(element); + p1 = this.End(element); + for (p = p0; p < p1; ++p) { + if (this.m_neighbors[p] === -1) { + this.m_neighbors[p] = neighbor; + return module.O3DGC_OK; + } + } + return module.O3DGC_ERROR_BUFFER_FULL; + }; + module.AdjacencyInfo.prototype.GetNeighbor = function (element) { + return this.m_neighbors[element]; + }; + module.AdjacencyInfo.prototype.GetNumNeighbors = function (element) { + return this.End(element) - this.Begin(element); + }; + module.AdjacencyInfo.prototype.GetNumNeighborsBuffer = function () { + return this.m_numNeighbors; + }; + module.AdjacencyInfo.prototype.GetNeighborsBuffer = function () { + return this.m_neighbors; + }; + // Vector class + module.Vector = function () { + this.m_data = {}; + this.m_allocated = 0; + this.m_size = 0; + }; + module.Vector.prototype.Clear = function () { + this.m_size = 0; + }; + module.Vector.prototype.Get = function (i) { + return this.m_data[i]; + }; + module.Vector.prototype.GetAllocatedSize = function () { + return this.m_allocated; + }; + module.Vector.prototype.GetSize = function () { + return this.m_size; + }; + module.Vector.prototype.GetBuffer = function () { + return this.m_data; + }; + module.Vector.prototype.SetSize = function (size) { + this.m_size = size; + }; + module.Vector.prototype.Allocate = function (size) { + var i, tmp_data; + if (size > this.m_allocated) { + this.m_allocated = size; + tmp_data = new Int32Array(this.m_allocated); + if (this.m_size > 0) { + for (i = 0; i < this.m_size; ++i) { + tmp_data[i] = this.m_data[i]; + } + } + this.m_data = tmp_data; + } + }; + module.Vector.prototype.PushBack = function (value) { + var i, tmp_data; + if (this.m_size === this.m_allocated) { + this.m_allocated *= 2; + if (this.m_allocated < local.O3DGC_DEFAULT_VECTOR_SIZE) { + this.m_allocated = local.O3DGC_DEFAULT_VECTOR_SIZE; + } + tmp_data = new Int32Array(this.m_allocated); + if (this.m_size > 0) { + for (i = 0; i < this.m_size; ++i) { + tmp_data[i] = this.m_data[i]; + } + } + this.m_data = tmp_data; + } + this.m_data[this.m_size++] = value; + }; + // CompressedTriangleFans class + module.CompressedTriangleFans = function () { + this.m_numTFANs = new module.Vector(); + this.m_degrees = new module.Vector(); + this.m_configs = new module.Vector(); + this.m_operations = new module.Vector(); + this.m_indices = new module.Vector(); + this.m_trianglesOrder = new module.Vector(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + }; + module.CompressedTriangleFans.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.CompressedTriangleFans.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.CompressedTriangleFans.prototype.Clear = function () { + this.m_numTFANs.Clear(); + this.m_degrees.Clear(); + this.m_configs.Clear(); + this.m_operations.Clear(); + this.m_indices.Clear(); + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.Allocate = function (numVertices, numTriangles) { + this.m_numTFANs.Allocate(numVertices); + this.m_degrees.Allocate(2 * numVertices); + this.m_configs.Allocate(2 * numVertices); + this.m_operations.Allocate(2 * numVertices); + this.m_indices.Allocate(2 * numVertices); + this.m_trianglesOrder.Allocate(numTriangles); + this.Clear(); + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.PushNumTFans = function (numTFans) { + this.m_numTFANs.PushBack(numTFans); + }; + module.CompressedTriangleFans.prototype.ReadNumTFans = function (it) { + return this.m_numTFANs.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushDegree = function (degree) { + this.m_degrees.PushBack(degree); + }; + module.CompressedTriangleFans.prototype.ReadDegree = function (it) { + return this.m_degrees.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushConfig = function (config) { + this.m_configs.PushBack(config); + }; + module.CompressedTriangleFans.prototype.ReadConfig = function (it) { + return this.m_configs.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushOperation = function (op) { + this.m_operations.PushBack(op); + }; + module.CompressedTriangleFans.prototype.ReadOperation = function (it) { + return this.m_operations.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushIndex = function (index) { + this.m_indices.PushBack(index); + }; + module.CompressedTriangleFans.prototype.ReadIndex = function (it) { + return this.m_indices.Get(it.m_count++); + }; + module.CompressedTriangleFans.prototype.PushTriangleIndex = function (index) { + this.m_trianglesOrder.PushBack(IntToUInt(index)); + }; + module.CompressedTriangleFans.prototype.ReadTriangleIndex = function (it) { + return UIntToInt(this.m_trianglesOrder.Get(it.m_count++)); + }; + module.CompressedTriangleFans.prototype.LoadUIntData = function (data, bstream, it) { + var size, i; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size); + data.Clear(); + for (i = 0; i < size; ++i) { + data.PushBack(bstream.ReadUIntASCII(it)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadIntData = function (data, bstream, it) { + var size, i; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size); + data.Clear(); + for (i = 0; i < size; ++i) { + data.PushBack(bstream.ReadIntASCII(it)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadBinData = function (data, bstream, it) { + var size, symbol, i, h; + bstream.ReadUInt32ASCII(it); + size = bstream.ReadUInt32ASCII(it); + data.Allocate(size * local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0); + data.Clear(); + i = 0; + while (i < size) { + symbol = bstream.ReadUCharASCII(it); + for (h = 0; h < local.O3DGC_BINARY_STREAM_BITS_PER_SYMBOL0; ++h) { + data.PushBack(symbol & 1); + symbol >>>= 1; + ++i; + } + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadUIntAC = function (data, M, bstream, it) { + + var sizeSize, size, minValue, buffer, acd, mModelValues, i; + sizeSize = bstream.ReadUInt32Bin(it) - 12; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + minValue = bstream.ReadUInt32Bin(it); + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 1); + for (i = 0; i < size; ++i) { + data.PushBack(acd.DecodeAdaptiveDataModel(mModelValues) + minValue); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadIntACEGC = function (data, M, bstream, it) { + var sizeSize, size, minValue, buffer, acd, mModelValues, bModel0, bModel1, value, i; + sizeSize = bstream.ReadUInt32Bin(it) - 12; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + minValue = bstream.ReadUInt32Bin(it) - local.O3DGC_MAX_LONG; + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + for (i = 0; i < size; ++i) { + value = acd.DecodeAdaptiveDataModel(mModelValues); + if (value === M) { + value += acd.ExpGolombDecode(0, bModel0, bModel1); + } + data.PushBack(value + minValue); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.LoadBinAC = function (data, bstream, it) { + var sizeSize, size, buffer, acd, bModel, i; + sizeSize = bstream.ReadUInt32Bin(it) - 8; + size = bstream.ReadUInt32Bin(it); + if (size === 0) { + return module.O3DGC_OK; + } + buffer = bstream.GetBuffer(it, sizeSize); + it.m_count += sizeSize; + data.Allocate(size); + acd = new module.ArithmeticDecoder(); + acd.SetBuffer(sizeSize, buffer); + acd.StartDecoder(); + bModel = new module.AdaptiveBitModel(); + for (i = 0; i < size; ++i) { + data.PushBack(acd.DecodeAdaptiveBitModel(bModel)); + } + return module.O3DGC_OK; + }; + module.CompressedTriangleFans.prototype.Load = function (bstream, iterator, decodeTrianglesOrder, streamType) { + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + this.LoadUIntData(this.m_numTFANs, bstream, iterator); + this.LoadUIntData(this.m_degrees, bstream, iterator); + this.LoadUIntData(this.m_configs, bstream, iterator); + this.LoadBinData(this.m_operations, bstream, iterator); + this.LoadIntData(this.m_indices, bstream, iterator); + if (decodeTrianglesOrder) { + this.LoadUIntData(this.m_trianglesOrder, bstream, iterator); + } + } else { + this.LoadIntACEGC(this.m_numTFANs, 4, bstream, iterator); + this.LoadIntACEGC(this.m_degrees, 16, bstream, iterator); + this.LoadUIntAC(this.m_configs, 10, bstream, iterator); + this.LoadBinAC(this.m_operations, bstream, iterator); + this.LoadIntACEGC(this.m_indices, 8, bstream, iterator); + if (decodeTrianglesOrder) { + this.LoadIntACEGC(this.m_trianglesOrder, 16, bstream, iterator); + } + } + return module.O3DGC_OK; + }; + // TriangleFans class + module.TriangleFans = function () { + this.m_verticesAllocatedSize = 0; + this.m_sizeTFANAllocatedSize = 0; + this.m_numTFANs = 0; + this.m_numVertices = 0; + this.m_sizeTFAN = {}; + this.m_vertices = {}; + }; + module.TriangleFans.prototype.Allocate = function (sizeTFAN, verticesSize) { + this.m_numTFANs = 0; + this.m_numVertices = 0; + if (this.m_verticesAllocatedSize < verticesSize) { + this.m_verticesAllocatedSize = verticesSize; + this.m_vertices = new Int32Array(this.m_verticesAllocatedSize); + } + if (this.m_sizeTFANAllocatedSize < sizeTFAN) { + this.m_sizeTFANAllocatedSize = sizeTFAN; + this.m_sizeTFAN = new Int32Array(this.m_sizeTFANAllocatedSize); + } + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.Clear = function () { + this.m_numTFANs = 0; + this.m_numVertices = 0; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.AddVertex = function (vertex) { + var i, tmp_vertices; + ++this.m_numVertices; + if (this.m_numVertices > this.m_verticesAllocatedSize) { + this.m_verticesAllocatedSize *= 2; + tmp_vertices = new Int32Array(this.m_verticesAllocatedSize); + for (i = 0; i < this.m_numVertices; ++i) { + tmp_vertices[i] = this.m_vertices[i]; + } + this.m_vertices = tmp_vertices; + } + this.m_vertices[this.m_numVertices - 1] = vertex; + ++this.m_sizeTFAN[this.m_numTFANs - 1]; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.AddTFAN = function () { + var i, tmp_sizeTFAN; + ++this.m_numTFANs; + if (this.m_numTFANs > this.m_sizeTFANAllocatedSize) { + this.m_sizeTFANAllocatedSize *= 2; + tmp_sizeTFAN = new Int32Array(this.m_sizeTFANAllocatedSize); + for (i = 0; i < this.m_numTFANs; ++i) { + tmp_sizeTFAN[i] = this.m_sizeTFAN[i]; + } + this.m_sizeTFAN = tmp_sizeTFAN; + } + this.m_sizeTFAN[this.m_numTFANs - 1] = (this.m_numTFANs > 1) ? this.m_sizeTFAN[this.m_numTFANs - 2] : 0; + return module.O3DGC_OK; + }; + module.TriangleFans.prototype.Begin = function (tfan) { + return (tfan > 0) ? this.m_sizeTFAN[tfan - 1] : 0; + }; + module.TriangleFans.prototype.End = function (tfan) { + return this.m_sizeTFAN[tfan]; + }; + module.TriangleFans.prototype.GetVertex = function (vertex) { + return this.m_vertices[vertex]; + }; + module.TriangleFans.prototype.GetTFANSize = function (tfan) { + return this.End(tfan) - this.Begin(tfan); + }; + module.TriangleFans.prototype.GetNumTFANs = function () { + return this.m_numTFANs; + }; + module.TriangleFans.prototype.GetNumVertices = function () { + return this.m_numVertices; + }; + // TriangleListDecoder class + module.TriangleListDecoder = function () { + this.m_itNumTFans = new module.Iterator(); + this.m_itDegree = new module.Iterator(); + this.m_itConfig = new module.Iterator(); + this.m_itOperation = new module.Iterator(); + this.m_itIndex = new module.Iterator(); + this.m_maxNumVertices = 0; + this.m_maxNumTriangles = 0; + this.m_numTriangles = 0; + this.m_numVertices = 0; + this.m_tempTrianglesSize = 0; + this.m_vertexCount = 0; + this.m_triangleCount = 0; + this.m_numConqueredTriangles = 0; + this.m_numVisitedVertices = 0; + this.m_triangles = {}; + this.m_tempTriangles = {}; + this.m_visitedVertices = {}; + this.m_visitedVerticesValence = {}; + this.m_vertexToTriangle = new module.AdjacencyInfo(); + this.m_ctfans = new module.CompressedTriangleFans(); + this.m_tfans = new module.TriangleFans(); + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + this.m_decodeTrianglesOrder = false; + this.m_decodeVerticesOrder = false; + this.m_processConfig = { + 0: function (decoder, degree) { // ops: 1000001 vertices: -1 -2 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 1: function (decoder, degree, focusVertex) { // ops: 1xxxxxx1 vertices: -1 x x x x x -2 + var u, op, index; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree - 1; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 2: function (decoder, degree) { // ops: 00000001 vertices: -1 + var u; + for (u = 0; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 3: function (decoder, degree) { // ops: 00000001 vertices: -2 + var u; + for (u = 0; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + }, + 4: function (decoder, degree) {// ops: 10000000 vertices: -1 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + for (u = 1; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 5: function (decoder, degree) { // ops: 10000000 vertices: -2 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 6: function (decoder, degree) { // ops: 00000000 vertices: + var u; + for (u = 0; u < degree; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + }, + 7: function (decoder, degree) { // ops: 1000001 vertices: -2 -1 + var u; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree - 1; ++u) { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 8: function (decoder, degree, focusVertex) { // ops: 1xxxxxx1 vertices: -2 x x x x x -1 + var u, op, index; + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[1]); + for (u = 1; u < degree - 1; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[0]); + }, + 9: function (decoder, degree, focusVertex) { // general case + var u, op, index; + for (u = 0; u < degree; ++u) { + op = decoder.m_ctfans.ReadOperation(decoder.m_itOperation); + if (op === 1) { + index = decoder.m_ctfans.ReadIndex(decoder.m_itIndex); + if (index < 0) { + decoder.m_tfans.AddVertex(decoder.m_visitedVertices[-index - 1]); + } else { + decoder.m_tfans.AddVertex(index + focusVertex); + } + } else { + decoder.m_visitedVertices[decoder.m_numVisitedVertices++] = decoder.m_vertexCount; + decoder.m_tfans.AddVertex(decoder.m_vertexCount++); + } + } + } + }; + }; + module.TriangleListDecoder.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.TriangleListDecoder.prototype.GetReorderTriangles = function () { + return this.m_decodeTrianglesOrder; + }; + module.TriangleListDecoder.prototype.GetReorderVertices = function () { + return this.m_decodeVerticesOrder; + }; + module.TriangleListDecoder.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.TriangleListDecoder.prototype.GetVertexToTriangle = function () { + return this.m_vertexToTriangle; + }; + module.TriangleListDecoder.prototype.Reorder = function () { + var triangles, numTriangles, order, it, prevTriangleIndex, tempTriangles, t, i; + if (this.m_decodeTrianglesOrder) { + triangles = this.m_triangles; + numTriangles = this.m_numTriangles; + order = this.m_ctfans.m_trianglesOrder.m_data; + tempTriangles = this.m_tempTriangles; + tempTriangles.set(triangles); + it = 0; + prevTriangleIndex = 0; + for (i = 0; i < numTriangles; ++i) { + t = UIntToInt(order[it++]) + prevTriangleIndex; + triangles[3 * t] = tempTriangles[3 * i]; + triangles[3 * t + 1] = tempTriangles[3 * i + 1]; + triangles[3 * t + 2] = tempTriangles[3 * i + 2]; + prevTriangleIndex = t + 1; + } + } + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.CompueLocalConnectivityInfo = function (focusVertex) { + var visitedVertices, visitedVerticesValence, triangles, vertexToTriangle, beginV2T, endV2T, numConqueredTriangles, foundOrInserted, numVisitedVertices, tmp, i, j, k, h, x, y, t, p, v; + visitedVertices = this.m_visitedVertices; + visitedVerticesValence = this.m_visitedVerticesValence; + triangles = this.m_triangles; + vertexToTriangle = this.m_vertexToTriangle; + beginV2T = vertexToTriangle.Begin(focusVertex); + endV2T = vertexToTriangle.End(focusVertex); + numConqueredTriangles = 0; + numVisitedVertices = 0; + t = 0; + for (i = beginV2T; (t >= 0) && (i < endV2T); ++i) { + t = vertexToTriangle.GetNeighbor(i); + if (t >= 0) { + ++numConqueredTriangles; + p = 3 * t; + // extract visited vertices + for (k = 0; k < 3; ++k) { + v = triangles[p + k]; + if (v > focusVertex) { // vertices are insertices by increasing traversal order + foundOrInserted = false; + for (j = 0; j < numVisitedVertices; ++j) { + if (v === visitedVertices[j]) { + visitedVerticesValence[j]++; + foundOrInserted = true; + break; + } else if (v < visitedVertices[j]) { + ++numVisitedVertices; + for (h = numVisitedVertices - 1; h > j; --h) { + visitedVertices[h] = visitedVertices[h - 1]; + visitedVerticesValence[h] = visitedVerticesValence[h - 1]; + } + visitedVertices[j] = v; + visitedVerticesValence[j] = 1; + foundOrInserted = true; + break; + } + } + if (!foundOrInserted) { + visitedVertices[numVisitedVertices] = v; + visitedVerticesValence[numVisitedVertices] = 1; + numVisitedVertices++; + } + } + } + } + } + // re-order visited vertices by taking into account their valence (i.e., # of conquered triangles incident to each vertex) + // in order to avoid config. 9 + if (numVisitedVertices > 2) { + for (x = 1; x < numVisitedVertices; ++x) { + if (visitedVerticesValence[x] === 1) { + y = x; + while ((y > 0) && (visitedVerticesValence[y] < visitedVerticesValence[y - 1])) { + tmp = visitedVerticesValence[y]; + visitedVerticesValence[y] = visitedVerticesValence[y - 1]; + visitedVerticesValence[y - 1] = tmp; + tmp = visitedVertices[y]; + visitedVertices[y] = visitedVertices[y - 1]; + visitedVertices[y - 1] = tmp; + --y; + } + } + } + } + this.m_numConqueredTriangles = numConqueredTriangles; + this.m_numVisitedVertices = numVisitedVertices; + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.DecompressTFAN = function (focusVertex) { + var vertexToTriangle, triangles, itDegree, itConfig, tfans, ntfans, processConfig, ctfans, triangleCount, numConqueredTriangles, degree, config, k0, k1, b, c, t, f, k; + vertexToTriangle = this.m_vertexToTriangle; + triangles = this.m_triangles; + itDegree = this.m_itDegree; + itConfig = this.m_itConfig; + tfans = this.m_tfans; + processConfig = this.m_processConfig; + ctfans = this.m_ctfans; + triangleCount = this.m_triangleCount; + numConqueredTriangles = this.m_numConqueredTriangles; + ntfans = ctfans.ReadNumTFans(this.m_itNumTFans); + if (ntfans > 0) { + for (f = 0; f < ntfans; ++f) { + tfans.AddTFAN(); + degree = ctfans.ReadDegree(itDegree) + 2 - numConqueredTriangles; + config = ctfans.ReadConfig(itConfig); + k0 = tfans.GetNumVertices(); + tfans.AddVertex(focusVertex); + processConfig[config](this, degree, focusVertex); + k1 = tfans.GetNumVertices(); + b = tfans.GetVertex(k0 + 1); + for (k = k0 + 2; k < k1; ++k) { + c = tfans.GetVertex(k); + t = triangleCount * 3; + triangles[t++] = focusVertex; + triangles[t++] = b; + triangles[t] = c; + vertexToTriangle.AddNeighbor(focusVertex, triangleCount); + vertexToTriangle.AddNeighbor(b, triangleCount); + vertexToTriangle.AddNeighbor(c, triangleCount); + b = c; + triangleCount++; + } + } + } + this.m_triangleCount = triangleCount; + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Decompress = function () { + var focusVertex; + for (focusVertex = 0; focusVertex < this.m_numVertices; ++focusVertex) { + if (focusVertex === this.m_vertexCount) { + this.m_vertexCount++; // insert focusVertex + } + this.CompueLocalConnectivityInfo(focusVertex); + this.DecompressTFAN(focusVertex); + } + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Init = function (triangles, numTriangles, numVertices, maxSizeV2T) { + var i, numNeighbors; + this.m_numTriangles = numTriangles; + this.m_numVertices = numVertices; + this.m_triangles = triangles; + this.m_vertexCount = 0; + this.m_triangleCount = 0; + this.m_itNumTFans.m_count = 0; + this.m_itDegree.m_count = 0; + this.m_itConfig.m_count = 0; + this.m_itOperation.m_count = 0; + this.m_itIndex.m_count = 0; + if (this.m_numVertices > this.m_maxNumVertices) { + this.m_maxNumVertices = this.m_numVertices; + this.m_visitedVerticesValence = new Int32Array(this.m_numVertices); + this.m_visitedVertices = new Int32Array(this.m_numVertices); + } + if (this.m_decodeTrianglesOrder && this.m_tempTrianglesSize < this.m_numTriangles) { + this.m_tempTrianglesSize = this.m_numTriangles; + this.m_tempTriangles = new Int32Array(3 * this.m_tempTrianglesSize); + } + this.m_ctfans.SetStreamType(this.m_streamType); + this.m_ctfans.Allocate(this.m_numVertices, this.m_numTriangles); + this.m_tfans.Allocate(2 * this.m_numVertices, 8 * this.m_numVertices); + // compute vertex-to-triangle adjacency information + this.m_vertexToTriangle.AllocateNumNeighborsArray(numVertices); + numNeighbors = this.m_vertexToTriangle.GetNumNeighborsBuffer(); + for (i = 0; i < numVertices; ++i) { + numNeighbors[i] = maxSizeV2T; + } + this.m_vertexToTriangle.AllocateNeighborsArray(); + this.m_vertexToTriangle.ClearNeighborsArray(); + return module.O3DGC_OK; + }; + module.TriangleListDecoder.prototype.Decode = function (triangles, numTriangles, numVertices, bstream, it) { + var compressionMask, maxSizeV2T; + compressionMask = bstream.ReadUChar(it, this.m_streamType); + this.m_decodeTrianglesOrder = ((compressionMask & 2) !== 0); + this.m_decodeVerticesOrder = ((compressionMask & 1) !== 0); + if (this.m_decodeVerticesOrder) { // vertices reordering not supported + return module.O3DGC_ERROR_NON_SUPPORTED_FEATURE; + } + maxSizeV2T = bstream.ReadUInt32(it, this.m_streamType); + this.Init(triangles, numTriangles, numVertices, maxSizeV2T); + this.m_ctfans.Load(bstream, it, this.m_decodeTrianglesOrder, this.m_streamType); + this.Decompress(); + return module.O3DGC_OK; + }; + // SC3DMCDecoder class + module.SC3DMCDecoder = function () { + var i; + this.m_iterator = new module.Iterator(); + this.m_streamSize = 0; + this.m_params = new module.SC3DMCEncodeParams(); + this.m_triangleListDecoder = new module.TriangleListDecoder(); + this.m_quantFloatArray = {}; + this.m_orientation = {}; + this.m_normals = {}; + this.m_quantFloatArraySize = 0; + this.m_normalsSize = 0; + this.m_orientationSize = 0; + this.m_stats = new module.SC3DMCStats(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + this.m_neighbors = []; + this.m_idelta = new Float32Array(local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES); + this.m_minNormal = new Float32Array(2); + this.m_maxNormal = new Float32Array(2); + this.m_minNormal[0] = this.m_minNormal[1] = -2; + this.m_maxNormal[0] = this.m_maxNormal[1] = 2; + for (i = 0; i < local.O3DGC_SC3DMC_MAX_DIM_ATTRIBUTES; ++i) { + this.m_neighbors[i] = new module.SC3DMCPredictor(); + } + }; + module.SC3DMCDecoder.prototype.GetStats = function () { + return this.m_stats; + }; + module.SC3DMCDecoder.prototype.DecodeHeader = function (ifs, bstream) { + var c0, start_code, mask, j, a, d; + c0 = this.m_iterator.m_count; + start_code = bstream.ReadUInt32(this.m_iterator, local.O3DGC_STREAM_TYPE_BINARY); + if (start_code !== local.O3DGC_SC3DMC_START_CODE) { + this.m_iterator.m_count = c0; + start_code = bstream.ReadUInt32(this.m_iterator, local.O3DGC_STREAM_TYPE_ASCII); + if (start_code !== local.O3DGC_SC3DMC_START_CODE) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + } else { + this.m_streamType = local.O3DGC_STREAM_TYPE_BINARY; + } + this.m_streamSize = bstream.ReadUInt32(this.m_iterator, this.m_streamType); + this.m_params.SetEncodeMode(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + + ifs.SetCreaseAngle(bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + mask = bstream.ReadUChar(this.m_iterator, this.m_streamType); + ifs.SetCCW((mask & 1) === 1); + ifs.SetSolid((mask & 2) === 1); + ifs.SetConvex((mask & 4) === 1); + ifs.SetIsTriangularMesh((mask & 8) === 1); + + ifs.SetNCoord(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNNormal(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNumFloatAttributes(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetNumIntAttributes(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + + if (ifs.GetNCoord() > 0) { + ifs.SetNCoordIndex(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + for (j = 0; j < 3; ++j) { + ifs.SetCoordMin(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetCoordMax(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + this.m_params.SetCoordQuantBits(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + if (ifs.GetNNormal() > 0) { + ifs.SetNNormalIndex(bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + for (j = 0; j < 3; ++j) { + ifs.SetNormalMin(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetNormalMax(j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + ifs.SetNormalPerVertex(bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + this.m_params.SetNormalQuantBits(bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + for (a = 0; a < ifs.GetNumFloatAttributes(); ++a) { + ifs.SetNFloatAttribute(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + if (ifs.GetNFloatAttribute(a) > 0) { + ifs.SetNFloatAttributeIndex(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + d = bstream.ReadUChar(this.m_iterator, this.m_streamType); + ifs.SetFloatAttributeDim(a, d); + for (j = 0; j < d; ++j) { + ifs.SetFloatAttributeMin(a, j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + ifs.SetFloatAttributeMax(a, j, bstream.ReadFloat32(this.m_iterator, this.m_streamType)); + } + ifs.SetFloatAttributePerVertex(a, bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + ifs.SetFloatAttributeType(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + this.m_params.SetFloatAttributeQuantBits(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + } + for (a = 0; a < ifs.GetNumIntAttributes(); ++a) { + ifs.SetNIntAttribute(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + if (ifs.GetNIntAttribute(a) > 0) { + ifs.SetNIntAttributeIndex(a, bstream.ReadUInt32(this.m_iterator, this.m_streamType)); + ifs.SetIntAttributeDim(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + ifs.SetIntAttributePerVertex(a, bstream.ReadUChar(this.m_iterator, this.m_streamType) === 1); + ifs.SetIntAttributeType(a, bstream.ReadUChar(this.m_iterator, this.m_streamType)); + } + } + return module.O3DGC_OK; + }; + function DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride) { + var ws, k, p, w, i, id; + id = new module.SC3DMCTriplet(-1, -1, -1); + for (k = 0; k < 3; ++k) { + w = triangles[ta * 3 + k]; + if (w < v) { + id.m_a = -1; + id.m_b = -1; + id.m_c = w; + p = InsertPredictor(id, nPred, neighbors, dimFloatArray); + if (p !== -1) { + ws = w * stride; + for (i = 0; i < dimFloatArray; ++i) { + neighbors[p].m_pred[i] = quantFloatArray[ws + i]; + } + } + } + } + } + function ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors) { + var ta3, tb3, as, bs, cs, a, b, c, x, i, k, u1_begin, u1_end, u1, tb, foundB, p, id; + ta3 = ta * 3; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (triangles[ta3] === v) { + a = triangles[ta3 + 1]; + b = triangles[ta3 + 2]; + } else if (triangles[ta3 + 1] === v) { + a = triangles[ta3]; + b = triangles[ta3 + 2]; + } else { + a = triangles[ta3]; + b = triangles[ta3 + 1]; + } + if (a < v && b < v) { + u1_begin = v2T.Begin(a); + u1_end = v2T.End(a); + for (u1 = u1_begin; u1 < u1_end; ++u1) { + tb = v2TNeighbors[u1]; + if (tb < 0) { + break; + } + tb3 = tb * 3; + c = -1; + foundB = false; + for (k = 0; k < 3; ++k) { + x = triangles[tb3 + k]; + if (x === b) { + foundB = true; + } else if (x < v && x !== a) { + c = x; + } + } + if (c !== -1 && foundB) { + if (a < b) { + id.m_a = a; + id.m_b = b; + } else { + id.m_a = b; + id.m_b = a; + } + id.m_c = (-c - 1); + p = InsertPredictor(id, nPred, neighbors, dimFloatArray); + if (p !== -1) { + as = a * stride; + bs = b * stride; + cs = c * stride; + for (i = 0; i < dimFloatArray; ++i) { + neighbors[p].m_pred[i] = quantFloatArray[as + i] + quantFloatArray[bs + i] - quantFloatArray[cs + i]; + } + } + } + } + } + } + module.SC3DMCDecoder.prototype.DecodeIntArrayBinary = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + var testPredEnabled, bestPred, i, u, ta, u_begin, u_end, buffer, iterator, streamType, predResidual, acd, bModel0, bModel1, mModelPreds, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, exp_k, M, id, mModelValues, neighbors, normals, nPred, v; + iterator = this.m_iterator; + streamType = this.m_streamType; + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + mModelPreds = new module.AdaptiveDataModel(); + mModelPreds.SetAlphabet(local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS + 1); + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numIntArray * dimIntArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); // bitsream size + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + exp_k = 0; + M = 0; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_AC_EGC) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + for (v = 0; v < numIntArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimIntArray, intArray, stride); + } + } + if (nPred.m_value > 1) { + bestPred = acd.DecodeAdaptiveDataModel(mModelPreds); + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual + intArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimIntArray; ++i) { + predResidual = acd.DecodeUIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + intArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeIntArrayASCII = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + var testPredEnabled, iterator, streamType, predResidual, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, id, neighbors, normals, nPred, v, u_begin, u_end, u, ta, i, bestPred; + iterator = this.m_iterator; + streamType = this.m_streamType; + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numIntArray * dimIntArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); // bitsream size + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + id = new module.SC3DMCTriplet(-1, -1, -1); + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_ASCII) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + bstream.ReadUInt32(iteratorPred, streamType); // predictors bitsream size + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + for (v = 0; v < numIntArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimIntArray, intArray, stride); + } + } + if (nPred.m_value > 1) { + bestPred = bstream.ReadUCharASCII(iteratorPred); + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + intArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + intArray[v * stride + i] = predResidual + intArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimIntArray; ++i) { + predResidual = bstream.ReadUIntASCII(iterator); + intArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeIntArray = function (intArray, + numIntArray, + dimIntArray, + stride, + ifs, + predMode, + bstream) { + if (this.m_streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.DecodeIntArrayASCII(intArray, numIntArray, dimIntArray, stride, ifs, predMode, bstream); + } + return this.DecodeIntArrayBinary(intArray, numIntArray, dimIntArray, stride, ifs, predMode, bstream); + }; + function ComputeNormals(triangles, ntris, coords, nvert, normals) { + var t3, v, n, t, a, b, c, d1, d2, n0; + n0 = new module.Vec3(); + d1 = new module.Vec3(); + d2 = new module.Vec3(); + n = nvert * 3; + for (v = 0; v < n; ++v) { + normals[v] = 0; + } + for (t = 0; t < ntris; ++t) { + t3 = t * 3; + a = triangles[t3] * 3; + b = triangles[t3 + 1] * 3; + c = triangles[t3 + 2] * 3; + d1.m_x = coords[b] - coords[a]; + d1.m_y = coords[b + 1] - coords[a + 1]; + d1.m_z = coords[b + 2] - coords[a + 2]; + d2.m_x = coords[c] - coords[a]; + d2.m_y = coords[c + 1] - coords[a + 1]; + d2.m_z = coords[c + 2] - coords[a + 2]; + n0.m_x = d1.m_y * d2.m_z - d1.m_z * d2.m_y; + n0.m_y = d1.m_z * d2.m_x - d1.m_x * d2.m_z; + n0.m_z = d1.m_x * d2.m_y - d1.m_y * d2.m_x; + normals[a] += n0.m_x; + normals[a + 1] += n0.m_y; + normals[a + 2] += n0.m_z; + normals[b] += n0.m_x; + normals[b + 1] += n0.m_y; + normals[b + 2] += n0.m_z; + normals[c] += n0.m_x; + normals[c + 1] += n0.m_y; + normals[c + 2] += n0.m_z; + } + } + module.SC3DMCDecoder.prototype.ProcessNormals = function (ifs) { + var v3, v2, nvert, normalSize, normals, quantFloatArray, orientation, triangles, n0, n1, v, rna0, rnb0, ni1, norm0; + nvert = ifs.GetNNormal(); + + normalSize = ifs.GetNNormal() * 3; + if (this.m_normalsSize < normalSize) { + this.m_normalsSize = normalSize; + this.m_normals = new Float32Array(this.m_normalsSize); + } + normals = this.m_normals; + quantFloatArray = this.m_quantFloatArray; + orientation = this.m_orientation; + triangles = ifs.GetCoordIndex(); + ComputeNormals(triangles, ifs.GetNCoordIndex(), quantFloatArray, nvert, normals); + n0 = new module.Vec3(); + n1 = new module.Vec3(); + for (v = 0; v < nvert; ++v) { + v3 = 3 * v; + n0.m_x = normals[v3]; + n0.m_y = normals[v3 + 1]; + n0.m_z = normals[v3 + 2]; + norm0 = Math.sqrt(n0.m_x * n0.m_x + n0.m_y * n0.m_y + n0.m_z * n0.m_z); + if (norm0 === 0.0) { + norm0 = 1.0; + } + SphereToCube(n0, n1); + rna0 = n1.m_x / norm0; + rnb0 = n1.m_y / norm0; + ni1 = n1.m_z + orientation[v]; + orientation[v] = ni1; + if ((ni1 >>> 1) !== (n1.m_z >>> 1)) { + rna0 = 0.0; + rnb0 = 0.0; + } + v2 = v * 2; + normals[v2] = rna0; + normals[v2 + 1] = rnb0; + } + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.IQuantize = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + predMode) { + var v, nin, nout, orientation, normals, CubeToSphere; + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + CubeToSphere = local.CubeToSphere; + orientation = this.m_orientation; + normals = this.m_normals; + nin = new module.Vec3(0, 0, 0); + nout = new module.Vec3(0, 0, 0); + this.IQuantizeFloatArray(floatArray, numFloatArray, dimFloatArray, stride, this.m_minNormal, this.m_maxNormal, nQBits + 1); + for (v = 0; v < numFloatArray; ++v) { + nin.m_x = floatArray[stride * v] + normals[2 * v]; + nin.m_y = floatArray[stride * v + 1] + normals[2 * v + 1]; + nin.m_z = orientation[v]; + CubeToSphere[nin.m_z](nin, nout); + floatArray[stride * v] = nout.m_x; + floatArray[stride * v + 1] = nout.m_y; + floatArray[stride * v + 2] = nout.m_z; + } + } else { + this.IQuantizeFloatArray(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits); + } + }; + module.SC3DMCDecoder.prototype.DecodeFloatArrayBinary = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + var maxNPred, testPredEnabled, testParaPredEnabled, bestPred, dModel, buffer, quantFloatArray, neighbors, normals, nPred, ta, i, v, u, u_begin, u_end, iterator, orientation, streamType, predResidual, acd, bModel0, bModel1, mModelPreds, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, exp_k, M, mModelValues; + iterator = this.m_iterator; + orientation = this.m_orientation; + streamType = this.m_streamType; + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + mModelPreds = new module.AdaptiveDataModel(); + maxNPred = local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS; + mModelPreds.SetAlphabet(maxNPred + 1); + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numFloatArray * dimFloatArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + exp_k = 0; + M = 0; + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_AC_EGC) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + if (this.m_orientationSize < size) { + this.m_orientationSize = size; + this.m_orientation = new Int8Array(this.m_orientationSize); + orientation = this.m_orientation; + } + dModel = new module.AdaptiveDataModel(); + dModel.SetAlphabet(12); + for (i = 0; i < numFloatArray; ++i) { + orientation[i] = UIntToInt(acd.DecodeAdaptiveDataModel(dModel)); + } + this.ProcessNormals(ifs); + dimFloatArray = 2; + } + if (this.m_quantFloatArraySize < size) { + this.m_quantFloatArraySize = size; + this.m_quantFloatArray = new Int32Array(this.m_quantFloatArraySize); + } + quantFloatArray = this.m_quantFloatArray; + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + testParaPredEnabled = predMode.m_value === local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + for (v = 0; v < numFloatArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + if (testParaPredEnabled) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors); + } + } + if (nPred.m_value < maxNPred) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride); + } + } + } + if (nPred.m_value > 1) { + bestPred = acd.DecodeAdaptiveDataModel(mModelPreds); + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && testPredEnabled) { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual + quantFloatArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = acd.DecodeUIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + quantFloatArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + this.IQuantize(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, predMode); + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeFloatArrayASCII = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + var maxNPred, testPredEnabled, testParaPredEnabled, iterator, orientation, streamType, predResidual, v2T, v2TNeighbors, triangles, size, start, streamSize, mask, binarization, iteratorPred, quantFloatArray, neighbors, normals, nPred, v, u, u_begin, u_end, ta, i, bestPred; + maxNPred = local.O3DGC_SC3DMC_MAX_PREDICTION_NEIGHBORS; + iterator = this.m_iterator; + orientation = this.m_orientation; + streamType = this.m_streamType; + v2T = this.m_triangleListDecoder.GetVertexToTriangle(); + v2TNeighbors = v2T.m_neighbors; + triangles = ifs.GetCoordIndex(); + size = numFloatArray * dimFloatArray; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + mask = bstream.ReadUChar(iterator, streamType); + binarization = (mask >>> 4) & 7; + predMode.m_value = mask & 7; + streamSize -= (iterator.m_count - start); + iteratorPred = new module.Iterator(); + iteratorPred.m_count = iterator.m_count + streamSize; + if (binarization !== local.O3DGC_SC3DMC_BINARIZATION_ASCII) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + bstream.ReadUInt32(iteratorPred, streamType); + if (predMode.m_value === local.O3DGC_SC3DMC_SURF_NORMALS_PREDICTION) { + if (this.m_orientationSize < numFloatArray) { + this.m_orientationSize = numFloatArray; + this.m_orientation = new Int8Array(this.m_orientationSize); + orientation = this.m_orientation; + } + for (i = 0; i < numFloatArray; ++i) { + orientation[i] = bstream.ReadIntASCII(iterator); + } + this.ProcessNormals(ifs); + dimFloatArray = 2; + } + if (this.m_quantFloatArraySize < size) { + this.m_quantFloatArraySize = size; + this.m_quantFloatArray = new Int32Array(this.m_quantFloatArraySize); + } + quantFloatArray = this.m_quantFloatArray; + neighbors = this.m_neighbors; + normals = this.m_normals; + nPred = new module.NumberRef(); + testPredEnabled = predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION; + testParaPredEnabled = predMode.m_value === local.O3DGC_SC3DMC_PARALLELOGRAM_PREDICTION; + for (v = 0; v < numFloatArray; ++v) { + nPred.m_value = 0; + if (v2T.GetNumNeighbors(v) > 0 && testPredEnabled) { + u_begin = v2T.Begin(v); + u_end = v2T.End(v); + if (testParaPredEnabled) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + ParallelogramPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride, v2T, v2TNeighbors); + } + } + if (nPred.m_value < maxNPred) { + for (u = u_begin; u < u_end; ++u) { + ta = v2TNeighbors[u]; + if (ta < 0) { + break; + } + DeltaPredictors(triangles, ta, v, nPred, neighbors, dimFloatArray, quantFloatArray, stride); + } + } + } + if (nPred.m_value > 1) { + bestPred = bstream.ReadUCharASCII(iteratorPred); + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual + neighbors[bestPred].m_pred[i]; + } + } else if (v > 0 && predMode.m_value !== local.O3DGC_SC3DMC_NO_PREDICTION) { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual + quantFloatArray[(v - 1) * stride + i]; + } + } else { + for (i = 0; i < dimFloatArray; ++i) { + predResidual = bstream.ReadUIntASCII(iterator); + quantFloatArray[v * stride + i] = predResidual; + } + } + } + iterator.m_count = iteratorPred.m_count; + this.IQuantize(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, predMode); + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodeFloatArray = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits, + ifs, + predMode, + bstream) { + if (this.m_streamType === local.O3DGC_STREAM_TYPE_ASCII) { + return this.DecodeFloatArrayASCII(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, ifs, predMode, bstream); + } + return this.DecodeFloatArrayBinary(floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits, ifs, predMode, bstream); + }; + module.SC3DMCDecoder.prototype.IQuantizeFloatArray = function (floatArray, numFloatArray, dimFloatArray, stride, minFloatArray, maxFloatArray, nQBits) { + var idelta, quantFloatArray, d, r, v; + idelta = this.m_idelta; + quantFloatArray = this.m_quantFloatArray; + for (d = 0; d < dimFloatArray; ++d) { + r = maxFloatArray[d] - minFloatArray[d]; + if (r > 0.0) { + idelta[d] = r / (((1 << nQBits) >>> 0) - 1); + } else { + idelta[d] = 1.0; + } + } + for (v = 0; v < numFloatArray; ++v) { + for (d = 0; d < dimFloatArray; ++d) { + floatArray[v * stride + d] = quantFloatArray[v * stride + d] * idelta[d] + minFloatArray[d]; + } + } + return module.O3DGC_OK; + }; + module.SC3DMCDecoder.prototype.DecodePlayload = function (ifs, bstream) { + var params, iterator, stats, predMode, timer, ret, a; + params = this.m_params; + iterator = this.m_iterator; + stats = this.m_stats; + predMode = new module.NumberRef(); + timer = new module.Timer(); + ret = module.O3DGC_OK; + this.m_triangleListDecoder.SetStreamType(this.m_streamType); + stats.m_streamSizeCoordIndex = iterator.m_count; + timer.Tic(); + this.m_triangleListDecoder.Decode(ifs.GetCoordIndex(), ifs.GetNCoordIndex(), ifs.GetNCoord(), bstream, iterator); + timer.Toc(); + stats.m_timeCoordIndex = timer.GetElapsedTime(); + stats.m_streamSizeCoordIndex = iterator.m_count - stats.m_streamSizeCoordIndex; + // decode coord + stats.m_streamSizeCoord = iterator.m_count; + timer.Tic(); + if (ifs.GetNCoord() > 0) { + ret = this.DecodeFloatArray(ifs.GetCoord(), ifs.GetNCoord(), 3, 3, ifs.GetCoordMinArray(), ifs.GetCoordMaxArray(), params.GetCoordQuantBits(), ifs, predMode, bstream); + params.SetCoordPredMode(predMode.m_value); + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Toc(); + stats.m_timeCoord = timer.GetElapsedTime(); + stats.m_streamSizeCoord = iterator.m_count - stats.m_streamSizeCoord; + + // decode Normal + stats.m_streamSizeNormal = iterator.m_count; + timer.Tic(); + if (ifs.GetNNormal() > 0) { + ret = this.DecodeFloatArray(ifs.GetNormal(), ifs.GetNNormal(), 3, 3, ifs.GetNormalMinArray(), ifs.GetNormalMaxArray(), params.GetNormalQuantBits(), ifs, predMode, bstream); + params.SetNormalPredMode(predMode.m_value); + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Toc(); + stats.m_timeNormal = timer.GetElapsedTime(); + stats.m_streamSizeNormal = iterator.m_count - stats.m_streamSizeNormal; + + // decode FloatAttributes + for (a = 0; a < ifs.GetNumFloatAttributes(); ++a) { + stats.m_streamSizeFloatAttribute[a] = iterator.m_count; + timer.Tic(); + ret = this.DecodeFloatArray(ifs.GetFloatAttribute(a), ifs.GetNFloatAttribute(a), ifs.GetFloatAttributeDim(a), ifs.GetFloatAttributeDim(a), ifs.GetFloatAttributeMinArray(a), ifs.GetFloatAttributeMaxArray(a), params.GetFloatAttributeQuantBits(a), ifs, predMode, bstream); + params.SetFloatAttributePredMode(a, predMode.m_value); + timer.Toc(); + stats.m_timeFloatAttribute[a] = timer.GetElapsedTime(); + stats.m_streamSizeFloatAttribute[a] = iterator.m_count - stats.m_streamSizeFloatAttribute[a]; + } + if (ret !== module.O3DGC_OK) { + return ret; + } + // decode IntAttributes + for (a = 0; a < ifs.GetNumIntAttributes(); ++a) { + stats.m_streamSizeIntAttribute[a] = iterator.m_count; + timer.Tic(); + ret = this.DecodeIntArray(ifs.GetIntAttribute(a), ifs.GetNIntAttribute(a), ifs.GetIntAttributeDim(a), ifs.GetIntAttributeDim(a), ifs, predMode, bstream); + params.SetIntAttributePredMode(a, predMode.m_value); + timer.Toc(); + stats.m_timeIntAttribute[a] = timer.GetElapsedTime(); + stats.m_streamSizeIntAttribute[a] = iterator.m_count - stats.m_streamSizeIntAttribute[a]; + } + if (ret !== module.O3DGC_OK) { + return ret; + } + timer.Tic(); + this.m_triangleListDecoder.Reorder(); + timer.Toc(); + stats.m_timeReorder = timer.GetElapsedTime(); + return ret; + }; + // DVEncodeParams class + module.DVEncodeParams = function () { + this.m_encodeMode = local.O3DGC_DYNAMIC_VECTOR_ENCODE_MODE_LIFT; + this.m_streamTypeMode = local.O3DGC_STREAM_TYPE_ASCII; + this.m_quantBits = 10; + }; + module.DVEncodeParams.prototype.GetStreamType = function () { + return this.m_streamTypeMode; + }; + module.DVEncodeParams.prototype.GetEncodeMode = function () { + return this.m_encodeMode; + }; + module.DVEncodeParams.prototype.GetQuantBits = function () { + return this.m_quantBits; + }; + module.DVEncodeParams.prototype.SetStreamType = function (streamTypeMode) { + this.m_streamTypeMode = streamTypeMode; + }; + module.DVEncodeParams.prototype.SetEncodeMode = function (encodeMode) { + this.m_encodeMode = encodeMode; + }; + module.DVEncodeParams.prototype.SetQuantBits = function (quantBits) { + this.m_quantBits = quantBits; + }; + // DynamicVector class + module.DynamicVector = function () { + this.m_num = 0; + this.m_dim = 0; + this.m_stride = 0; + this.m_max = {}; + this.m_min = {}; + this.m_vectors = {}; + }; + module.DynamicVector.prototype.GetNVector = function () { + return this.m_num; + }; + module.DynamicVector.prototype.GetDimVector = function () { + return this.m_dim; + }; + module.DynamicVector.prototype.GetStride = function () { + return this.m_stride; + }; + module.DynamicVector.prototype.GetMinArray = function () { + return this.m_min; + }; + module.DynamicVector.prototype.GetMaxArray = function () { + return this.m_max; + }; + module.DynamicVector.prototype.GetVectors = function () { + return this.m_vectors; + }; + module.DynamicVector.prototype.GetMin = function (j) { + return this.m_min[j]; + }; + module.DynamicVector.prototype.GetMax = function (j) { + return this.m_max[j]; + }; + module.DynamicVector.prototype.SetNVector = function (num) { + this.m_num = num; + }; + module.DynamicVector.prototype.SetDimVector = function (dim) { + this.m_dim = dim; + }; + module.DynamicVector.prototype.SetStride = function (stride) { + this.m_stride = stride; + }; + module.DynamicVector.prototype.SetMinArray = function (min) { + this.m_min = min; + }; + module.DynamicVector.prototype.SetMaxArray = function (max) { + this.m_max = max; + }; + module.DynamicVector.prototype.SetMin = function (j, min) { + this.m_min[j] = min; + }; + module.DynamicVector.prototype.SetMax = function (j, max) { + this.m_max[j] = max; + }; + module.DynamicVector.prototype.SetVectors = function (vectors) { + this.m_vectors = vectors; + }; + // DynamicVectorDecoder class + module.DynamicVectorDecoder = function () { + this.m_streamSize = 0; + this.m_maxNumVectors = 0; + this.m_numVectors = 0; + this.m_dimVectors = 0; + this.m_quantVectors = {}; + this.m_iterator = new module.Iterator(); + this.m_streamType = local.O3DGC_STREAM_TYPE_UNKOWN; + this.m_params = new module.DVEncodeParams(); + }; + module.DynamicVectorDecoder.prototype.GetStreamType = function () { + return this.m_streamType; + }; + module.DynamicVectorDecoder.prototype.GetIterator = function () { + return this.m_iterator; + }; + module.DynamicVectorDecoder.prototype.SetStreamType = function (streamType) { + this.m_streamType = streamType; + }; + module.DynamicVectorDecoder.prototype.SetIterator = function (iterator) { + this.m_iterator = iterator; + }; + module.DynamicVectorDecoder.prototype.IUpdate = function (data, shift, size) { + var p, size1; + size1 = size - 1; + p = 2; + data[shift] -= data[shift + 1] >> 1; + while (p < size1) { + data[shift + p] -= (data[shift + p - 1] + data[shift + p + 1] + 2) >> 2; + p += 2; + } + if (p === size1) { + data[shift + p] -= data[shift + p - 1] >> 1; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.IPredict = function (data, shift, size) { + var p, size1; + size1 = size - 1; + p = 1; + while (p < size1) { + data[shift + p] += (data[shift + p - 1] + data[shift + p + 1] + 1) >> 1; + p += 2; + } + if (p === size1) { + data[shift + p] += data[shift + p - 1]; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.Merge = function (data, shift, size) { + var i, h, a, b, tmp; + h = (size >> 1) + (size & 1); + a = h - 1; + b = h; + while (a > 0) { + for (i = a; i < b; i += 2) { + tmp = data[shift + i]; + data[shift + i] = data[shift + i + 1]; + data[shift + i + 1] = tmp; + } + --a; + ++b; + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.ITransform = function (data, shift, size) { + var n, even, k, i; + n = size; + even = 0; + k = 0; + even += ((n & 1) << k++) >>> 0; + while (n > 1) { + n = (n >> 1) + ((n & 1) >>> 0); + even += ((n & 1) << k++) >>> 0; + } + for (i = k - 2; i >= 0; --i) { + n = ((n << 1) >>> 0) - (((even >>> i) & 1)) >>> 0; + this.Merge(data, shift, n); + this.IUpdate(data, shift, n); + this.IPredict(data, shift, n); + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.IQuantize = function (floatArray, + numFloatArray, + dimFloatArray, + stride, + minFloatArray, + maxFloatArray, + nQBits) { + var quantVectors, r, idelta, size, d, v; + quantVectors = this.m_quantVectors; + size = numFloatArray * dimFloatArray; + for (d = 0; d < dimFloatArray; ++d) { + r = maxFloatArray[d] - minFloatArray[d]; + if (r > 0.0) { + idelta = r / (((1 << nQBits) >>> 0) - 1); + } else { + idelta = 1.0; + } + for (v = 0; v < numFloatArray; ++v) { + floatArray[v * stride + d] = quantVectors[v + d * numFloatArray] * idelta + minFloatArray[d]; + } + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.DecodeHeader = function (dynamicVector, bstream) { + var iterator, c0, start_code, streamType; + iterator = this.m_iterator; + c0 = iterator.m_count; + start_code = bstream.ReadUInt32(iterator, local.O3DGC_STREAM_TYPE_BINARY); + if (start_code !== local.O3DGC_DV_START_CODE) { + iterator.m_count = c0; + start_code = bstream.ReadUInt32(iterator, local.O3DGC_STREAM_TYPE_ASCII); + if (start_code !== local.O3DGC_DV_START_CODE) { + return module.O3DGC_ERROR_CORRUPTED_STREAM; + } + this.m_streamType = local.O3DGC_STREAM_TYPE_ASCII; + } else { + this.m_streamType = local.O3DGC_STREAM_TYPE_BINARY; + } + streamType = this.m_streamType; + this.m_streamSize = bstream.ReadUInt32(iterator, streamType); + this.m_params.SetEncodeMode(bstream.ReadUChar(iterator, streamType)); + dynamicVector.SetNVector(bstream.ReadUInt32(iterator, streamType)); + if (dynamicVector.GetNVector() > 0) { + dynamicVector.SetDimVector(bstream.ReadUInt32(iterator, streamType)); + this.m_params.SetQuantBits(bstream.ReadUChar(iterator, streamType)); + } + return module.O3DGC_OK; + }; + module.DynamicVectorDecoder.prototype.DecodePlayload = function (dynamicVector, bstream) { + var size, iterator, streamType, ret, start, streamSize, dim, num, j, acd, bModel0, bModel1, exp_k, M, buffer, mModelValues, quantVectors, v, d; + iterator = this.m_iterator; + streamType = this.m_streamType; + ret = module.O3DGC_OK; + start = iterator.m_count; + streamSize = bstream.ReadUInt32(iterator, streamType); + dim = dynamicVector.GetDimVector(); + num = dynamicVector.GetNVector(); + size = dim * num; + for (j = 0; j < dynamicVector.GetDimVector(); ++j) { + dynamicVector.SetMin(j, bstream.ReadFloat32(iterator, streamType)); + dynamicVector.SetMax(j, bstream.ReadFloat32(iterator, streamType)); + } + acd = new module.ArithmeticDecoder(); + bModel0 = new module.StaticBitModel(); + bModel1 = new module.AdaptiveBitModel(); + streamSize -= (iterator.m_count - start); + exp_k = 0; + M = 0; + if (streamType === local.O3DGC_STREAM_TYPE_BINARY) { + buffer = bstream.GetBuffer(iterator, streamSize); + iterator.m_count += streamSize; + acd.SetBuffer(streamSize, buffer); + acd.StartDecoder(); + exp_k = acd.ExpGolombDecode(0, bModel0, bModel1); + M = acd.ExpGolombDecode(0, bModel0, bModel1); + } + mModelValues = new module.AdaptiveDataModel(); + mModelValues.SetAlphabet(M + 2); + if (this.m_maxNumVectors < size) { + this.m_maxNumVectors = size; + this.m_quantVectors = new Int32Array(this.m_maxNumVectors); + } + quantVectors = this.m_quantVectors; + if (streamType === local.O3DGC_STREAM_TYPE_ASCII) { + for (v = 0; v < num; ++v) { + for (d = 0; d < dim; ++d) { + quantVectors[d * num + v] = bstream.ReadIntASCII(iterator); + } + } + } else { + for (v = 0; v < num; ++v) { + for (d = 0; d < dim; ++d) { + quantVectors[d * num + v] = acd.DecodeIntACEGC(mModelValues, bModel0, bModel1, exp_k, M); + } + } + } + for (d = 0; d < dim; ++d) { + this.ITransform(quantVectors, d * num, num); + } + this.IQuantize(dynamicVector.GetVectors(), num, dim, + dynamicVector.GetStride(), dynamicVector.GetMinArray(), + dynamicVector.GetMaxArray(), this.m_params.GetQuantBits()); + return ret; + }; + + return module; +})(); + diff --git a/examples/js/lights/RectAreaLightUniformsLib.js b/examples/js/lights/RectAreaLightUniformsLib.js index 2eaccb9a514f98d6b7ed07dbdf79ce33f45f90ef..d2738a079c4fd8ae02a55b224636e79f0222cd97 100644 --- a/examples/js/lights/RectAreaLightUniformsLib.js +++ b/examples/js/lights/RectAreaLightUniformsLib.js @@ -45,7 +45,7 @@ Object.assign(THREE.UniformsLib, { ltc_brdf: { "ltcMat": { type: "t", value: THREE.UniformsLib.LTC_MAT_TEXTURE }, "ltcMag": { type: "t", value: THREE.UniformsLib.LTC_MAG_TEXTURE } - }, + } } ); @@ -99,7 +99,7 @@ Object.assign(THREE.ShaderLib, { "emissive" : { value: new THREE.Color( 0x000000 ) }, "roughness": { value: 0.5 }, "metalness": { value: 0 }, - "envMapIntensity" : { value: 1 }, // temporary + "envMapIntensity" : { value: 1 } // temporary } ), @@ -107,7 +107,7 @@ Object.assign(THREE.ShaderLib, { vertexShader: THREE.ShaderChunk.meshphysical_vert, fragmentShader: THREE.ShaderChunk.meshphysical_frag - }, + } } ); diff --git a/examples/js/loaders/3MFLoader.js b/examples/js/loaders/3MFLoader.js index dbe9d807197817d937c758db6bdf10079091bc1a..ee02a799776972db7c919de35d1eef5a7f6f2316 100644 --- a/examples/js/loaders/3MFLoader.js +++ b/examples/js/loaders/3MFLoader.js @@ -235,7 +235,7 @@ THREE.ThreeMFLoader.prototype = { for ( var i = 0; i < triangleNodes.length; i++ ) { - triangleNode = triangleNodes[ i ]; + var triangleNode = triangleNodes[ i ]; var v1 = triangleNode.getAttribute( 'v1' ); var v2 = triangleNode.getAttribute( 'v2' ); var v3 = triangleNode.getAttribute( 'v3' ); diff --git a/examples/js/loaders/AWDLoader.js b/examples/js/loaders/AWDLoader.js index 10f4a7844fa80ea4d7ea77b02a50eb334a476c30..93af0126df914afd678a504296e837c6db62825a 100644 --- a/examples/js/loaders/AWDLoader.js +++ b/examples/js/loaders/AWDLoader.js @@ -52,7 +52,7 @@ } - AWDProperties = function() {} + AWDProperties = function() {}; AWDProperties.prototype = { set : function( key, value ) { @@ -68,7 +68,7 @@ else return fallback; } - } + }; THREE.AWDLoader = function ( manager ) { @@ -81,7 +81,7 @@ this._url = ''; this._baseDir = ''; - this._data; + this._data = undefined; this._ptr = 0; this._version = []; diff --git a/examples/js/loaders/AssimpJSONLoader.js b/examples/js/loaders/AssimpJSONLoader.js index ea926dbb45e3b9a245341828c4e49388944ee28e..cec76c753e74ca1f69975e3b4eb8b318c7cb9307 100644 --- a/examples/js/loaders/AssimpJSONLoader.js +++ b/examples/js/loaders/AssimpJSONLoader.js @@ -105,112 +105,47 @@ THREE.AssimpJSONLoader.prototype = { parseMesh : function( json ) { - var vertex, geometry, i, e, in_data, src; + var geometry = new THREE.BufferGeometry(); + var i, l, face; - geometry = new THREE.Geometry(); + var indices = []; - // read vertex positions - for ( in_data = json.vertices, i = 0, e = in_data.length; i < e; ) { + var vertices = json.vertices || []; + var normals = json.normals || []; + var uvs = json.texturecoords || []; + var colors = json.colors || []; - geometry.vertices.push( new THREE.Vector3( in_data[ i ++ ], in_data[ i ++ ], in_data[ i ++ ] ) ); + uvs = uvs[ 0 ] || []; // only support for a single set of uvs - } - - // read faces - var cnt = 0; - for ( in_data = json.faces, i = 0, e = in_data.length; i < e; ++ i ) { + for ( i = 0, l = json.faces.length; i < l; i ++ ) { - src = in_data[ i ]; - face = new THREE.Face3( src[ 0 ], src[ 1 ], src[ 2 ] ); - geometry.faces.push( face ); + face = json.faces[ i ]; + indices.push( face[ 0 ], face[ 1 ], face[ 2 ] ); } - // read texture coordinates - three.js attaches them to its faces - json.texturecoords = json.texturecoords || []; - for ( i = 0, e = json.texturecoords.length; i < e; ++ i ) { - - function convertTextureCoords( in_uv, out_faces, out_vertex_uvs ) { - - var i, e, face, a, b, c; - - for ( i = 0, e = out_faces.length; i < e; ++ i ) { - - face = out_faces[ i ]; - a = face.a * 2; - b = face.b * 2; - c = face.c * 2; - out_vertex_uvs.push( [ - new THREE.Vector2( in_uv[ a ], in_uv[ a + 1 ] ), - new THREE.Vector2( in_uv[ b ], in_uv[ b + 1 ] ), - new THREE.Vector2( in_uv[ c ], in_uv[ c + 1 ] ) - ] ); - - } + geometry.setIndex( new ( indices.length > 65535 ? THREE.Uint32BufferAttribute : THREE.Uint16BufferAttribute )( indices, 1 ) ); + geometry.addAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) ); - } + if ( normals.length > 0 ) { - convertTextureCoords( json.texturecoords[ i ], geometry.faces, geometry.faceVertexUvs[ i ] ); + geometry.addAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) ); } - // read normals - three.js also attaches them to its faces - if ( json.normals ) { - - function convertNormals( in_nor, out_faces ) { - - var i, e, face, a, b, c; - - for ( i = 0, e = out_faces.length; i < e; ++ i ) { - - face = out_faces[ i ]; - a = face.a * 3; - b = face.b * 3; - c = face.c * 3; - face.vertexNormals = [ - new THREE.Vector3( in_nor[ a ], in_nor[ a + 1 ], in_nor[ a + 2 ] ), - new THREE.Vector3( in_nor[ b ], in_nor[ b + 1 ], in_nor[ b + 2 ] ), - new THREE.Vector3( in_nor[ c ], in_nor[ c + 1 ], in_nor[ c + 2 ] ) - ]; - - } - - } + if ( uvs.length > 0 ) { - convertNormals( json.normals, geometry.faces ); + geometry.addAttribute( 'uv', new THREE.Float32BufferAttribute( uvs, 2 ) ); } - // read vertex colors - three.js also attaches them to its faces - if ( json.colors && json.colors[ 0 ] ) { - - function convertColors( in_color, out_faces ) { - - for ( var i = 0, e = out_faces.length; i < e; ++ i ) { - - var face = out_faces[ i ]; - var a = face.a * 4; - var b = face.b * 4; - var c = face.c * 4; - - face.vertexColors = [ - new THREE.Color().fromArray( a ), - new THREE.Color().fromArray( b ), - new THREE.Color().fromArray( c ) - ]; + if ( colors.length > 0 ) { - } - - } - - convertColors( json.colors[ 0 ], geometry.faces ); + geometry.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); } - - //geometry.computeFaceNormals(); - //geometry.computeVertexNormals(); geometry.computeBoundingSphere(); return geometry; @@ -219,8 +154,9 @@ THREE.AssimpJSONLoader.prototype = { parseMaterial : function( json ) { - var mat = null, - scope = this, i, prop, has_textures = [], + var mat = null; + var scope = this; + var i, prop, has_textures = [], init_props = { shading : THREE.SmoothShading @@ -243,7 +179,7 @@ THREE.AssimpJSONLoader.prototype = { } - for ( var i in json.properties ) { + for ( i in json.properties ) { prop = json.properties[ i ]; @@ -357,10 +293,7 @@ THREE.AssimpJSONLoader.prototype = { parseObject : function( json, node, meshes, materials ) { - var obj = new THREE.Object3D() - , i - , idx - ; + var obj = new THREE.Object3D(), i, idx; obj.name = node.name || ""; obj.matrix = new THREE.Matrix4().fromArray( node.transformation ).transpose(); @@ -381,5 +314,5 @@ THREE.AssimpJSONLoader.prototype = { return obj; - }, + } }; diff --git a/examples/js/loaders/BVHLoader.js b/examples/js/loaders/BVHLoader.js index 75c3a5309d0b719ef3a7c80950be6863ed92ab17..c7f5ab61e0d9574052cda2e6f67649388d628cba 100644 --- a/examples/js/loaders/BVHLoader.js +++ b/examples/js/loaders/BVHLoader.js @@ -116,7 +116,7 @@ THREE.BVHLoader.prototype = { var keyframe = { time: frameTime, position: { x: 0, y: 0, z: 0 }, - rotation: new THREE.Quaternion(), + rotation: new THREE.Quaternion() }; bone.frames.push( keyframe ); diff --git a/examples/js/loaders/FBXLoader.js b/examples/js/loaders/FBXLoader.js index e3216f571f67ffdadd3588fdac1dc76891d6bb48..09165dc41d84da1d965b378ff42a3438524372f3 100644 --- a/examples/js/loaders/FBXLoader.js +++ b/examples/js/loaders/FBXLoader.js @@ -64,7 +64,7 @@ THREE.FBXLoader.prototype.isFbxFormatASCII = function ( body ) { - CORRECT = [ 'K', 'a', 'y', 'd', 'a', 'r', 'a', '\\', 'F', 'B', 'X', '\\', 'B', 'i', 'n', 'a', 'r', 'y', '\\', '\\' ]; + var CORRECT = [ 'K', 'a', 'y', 'd', 'a', 'r', 'a', '\\', 'F', 'B', 'X', '\\', 'B', 'i', 'n', 'a', 'r', 'y', '\\', '\\' ]; var cursor = 0; var read = function ( offset ) { @@ -78,7 +78,7 @@ for ( var i = 0; i < CORRECT.length; ++ i ) { - num = read( 1 ); + var num = read( 1 ); if ( num == CORRECT[ i ] ) { return false; @@ -94,7 +94,7 @@ THREE.FBXLoader.prototype.isFbxVersionSupported = function ( body ) { var versionExp = /FBXVersion: (\d+)/; - match = body.match( versionExp ); + var match = body.match( versionExp ); if ( match ) { var version = parseInt( match[ 1 ] ); @@ -124,7 +124,7 @@ console.timeEnd( 'FBXLoader: ObjectParser' ); console.time( 'FBXLoader: GeometryParser' ); - geometries = this.parseGeometries( nodes ); + var geometries = this.parseGeometries( nodes ); console.timeEnd( 'FBXLoader: GeometryParser' ); var container = new THREE.Group(); @@ -203,7 +203,7 @@ THREE.FBXLoader.prototype.parseGeometry = function ( node, nodes ) { - geo = ( new Geometry() ).parse( node ); + var geo = ( new Geometry() ).parse( node ); geo.addBones( this.hierarchy.hierarchy ); //* @@ -448,7 +448,7 @@ }; var bones = mesh.geometry.bones; - for ( frame = 0; frame < animations.frames; frame ++ ) { + for ( var frame = 0; frame < animations.frames; frame ++ ) { for ( i = 0; i < bones.length; i ++ ) { @@ -664,7 +664,7 @@ var key = id + ',' + to; // TODO: to hash if ( this.__cache_search_connection_type === undefined ) { - this.__cache_search_connection_type = ''; + this.__cache_search_connection_type = {}; } @@ -772,7 +772,7 @@ // beginning of node var beginningOfNodeExp = new RegExp( "^\\t{" + this.currentIndent + "}(\\w+):(.*){", '' ); - match = l.match( beginningOfNodeExp ); + var match = l.match( beginningOfNodeExp ); if ( match ) { var nodeName = match[ 1 ].trim().replace( /^"/, '' ).replace( /"$/, "" ); @@ -789,7 +789,7 @@ // node's property var propExp = new RegExp( "^\\t{" + ( this.currentIndent ) + "}(\\w+):[\\s\\t\\r\\n](.*)" ); - match = l.match( propExp ); + var match = l.match( propExp ); if ( match ) { var propName = match[ 1 ].replace( /^"/, '' ).replace( /"$/, "" ).trim(); @@ -2574,7 +2574,7 @@ // what want: normal per vertex, order vertice // i have: normal per polygon // i have: indice per polygon - parse_Data_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) { + var parse_Data_ByPolygonVertex_Direct = function ( node, indices, strides, itemSize ) { // *21204 > 3573 // Geometry: 690680816, "Geometry::", "Mesh" { @@ -2684,19 +2684,19 @@ }; - degToRad = function ( degrees ) { + var degToRad = function ( degrees ) { return degrees * Math.PI / 180; }; - radToDeg = function ( radians ) { + var radToDeg = function ( radians ) { return radians * 180 / Math.PI; }; - quatFromVec = function ( x, y, z ) { + var quatFromVec = function ( x, y, z ) { var euler = new THREE.Euler( x, y, z, 'ZYX' ); var quat = new THREE.Quaternion(); @@ -2708,7 +2708,7 @@ // extend Array.prototype ? ....uuuh - toInt = function ( arr ) { + var toInt = function ( arr ) { return arr.map( function ( element ) { @@ -2718,7 +2718,7 @@ }; - toFloat = function ( arr ) { + var toFloat = function ( arr ) { return arr.map( function ( element ) { @@ -2728,7 +2728,7 @@ }; - toRad = function ( arr ) { + var toRad = function ( arr ) { return arr.map( function ( element ) { @@ -2738,7 +2738,7 @@ }; - toMat44 = function ( arr ) { + var toMat44 = function ( arr ) { var mat = new THREE.Matrix4(); mat.set( diff --git a/examples/js/loaders/GLTFLoader.js b/examples/js/loaders/GLTFLoader.js index d8d385f5bf0f02bd38fc263cbcac21ab55b34824..90d31915ca4cd86be16bc852be37049714a60c58 100644 --- a/examples/js/loaders/GLTFLoader.js +++ b/examples/js/loaders/GLTFLoader.js @@ -4,444 +4,447 @@ * @author Tony Parisi / http://www.tonyparisi.com/ */ -(function() { +THREE.GLTFLoader = ( function () { -THREE.GLTFLoader = function( manager ) { + function GLTFLoader( manager ) { - this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; + this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; - this.parser = GLTFParser; + } -}; + GLTFLoader.prototype = { -THREE.GLTFLoader.prototype = { + constructor: GLTFLoader, - constructor: THREE.GLTFLoader, + load: function ( url, onLoad, onProgress, onError ) { - load: function( url, onLoad, onProgress, onError ) { + var scope = this; - var scope = this; + var path = this.path && ( typeof this.path === "string" ) ? this.path : THREE.Loader.prototype.extractUrlBase( url ); - var path = this.path && ( typeof this.path === "string" ) ? this.path : THREE.Loader.prototype.extractUrlBase( url ); + var loader = new THREE.FileLoader( scope.manager ); + loader.load( url, function ( text ) { - var loader = new THREE.FileLoader( scope.manager ); - loader.load( url, function( text ) { + scope.parse( JSON.parse( text ), onLoad, path ); - scope.parse( JSON.parse( text ), onLoad, path ); + }, onProgress, onError ); - }, onProgress, onError ); + }, - }, + setCrossOrigin: function ( value ) { - setCrossOrigin: function( value ) { + this.crossOrigin = value; - this.crossOrigin = value; + }, - }, + setPath: function ( value ) { - setPath: function( value ) { + this.path = value; - this.path = value; + }, - }, + parse: function ( json, callback, path ) { - parse: function( json, callback, path ) { + console.time( 'GLTFLoader' ); - console.time( 'GLTFLoader' ); + var parser = new GLTFParser( json, { - var glTFParser = new this.parser( json, { - path: path || this.path, - crossOrigin: !!this.crossOrigin - }); + path: path || this.path, + crossOrigin: !! this.crossOrigin - glTFParser.parse( function( scene, cameras, animations ) { + } ); - console.timeEnd( 'GLTFLoader' ); + parser.parse( function ( scene, cameras, animations ) { - var glTF = { - "scene": scene, - "cameras": cameras, - "animations": animations - }; + console.timeEnd( 'GLTFLoader' ); - callback( glTF ); + var glTF = { + "scene": scene, + "cameras": cameras, + "animations": animations + }; - }); + callback( glTF ); - // Developers should use `callback` argument for async notification on - // completion to prevent side effects. - // Function return is kept only for backward-compatability purposes. - return { - get scene() { + } ); - console.warn( "Synchronous glTF object access is deprecated." + - " Use the asynchronous 'callback' argument instead." ); - return scene; + } + + }; + + /* GLTFREGISTRY */ + + function GLTFRegistry() { + + var objects = {}; + + return { + + get: function ( key ) { + + return objects[ key ]; }, - set scene( value ) { - console.warn( "Synchronous glTF object access is deprecated." + - " Use the asynchronous 'callback' argument instead." ); - scene = value; + add: function ( key, object ) { - } + objects[ key ] = object; - }; + }, - } + remove: function ( key ) { -}; + delete objects[ key ]; -/* GLTFREGISTRY */ + }, -var GLTFRegistry = function() { + removeAll: function () { - var objects = {}; + objects = {}; - return { - get : function( key ) { + }, - return objects[ key ]; + update: function ( scene, camera ) { - }, + for ( var name in objects ) { - add : function( key, object ) { + var object = objects[ name ]; - objects[ key ] = object; + if ( object.update ) { - }, + object.update( scene, camera ); - remove: function( key ) { + } - delete objects[ key ]; + } - }, + } - removeAll: function() { + }; - objects = {}; + } - }, + /* GLTFSHADERS */ + + GLTFLoader.Shaders = new GLTFRegistry(); - update : function( scene, camera ) { + /* GLTFSHADER */ - _each( objects, function( object ) { + function GLTFShader( targetNode, allNodes ) { - if ( object.update ) { + var scope = this; - object.update( scene, camera ); + this.boundUniforms = {}; - } + // bind each uniform to its source node - }); + var uniforms = targetNode.material.uniforms; - } - }; -}; + for ( var uniformId in uniforms ) { -/* GLTFSHADERS */ + var uniform = uniforms[ uniformId ]; -THREE.GLTFLoader.Shaders = new GLTFRegistry(); + if ( uniform.semantic ) { -/* GLTFSHADER */ + var sourceNodeRef = uniform.node; -var GLTFShader = function( targetNode, allNodes ) { + var sourceNode = targetNode; - this.boundUniforms = {}; + if ( sourceNodeRef ) { - // bind each uniform to its source node - _each(targetNode.material.uniforms, function(uniform, uniformId) { + sourceNode = allNodes[ sourceNodeRef ]; - if (uniform.semantic) { + } - var sourceNodeRef = uniform.node; + scope.boundUniforms[ uniformId ] = { + semantic: uniform.semantic, + sourceNode: sourceNode, + targetNode: targetNode, + uniform: uniform + }; - var sourceNode = targetNode; - if ( sourceNodeRef ) { - sourceNode = allNodes[ sourceNodeRef ]; } - this.boundUniforms[ uniformId ] = { - semantic: uniform.semantic, - sourceNode: sourceNode, - targetNode: targetNode, - uniform: uniform - }; - } - }.bind( this )); + this._m4 = new THREE.Matrix4(); - this._m4 = new THREE.Matrix4(); + } -} + // Update - update all the uniform values + GLTFShader.prototype.update = function ( scene, camera ) { -// Update - update all the uniform values -GLTFShader.prototype.update = function( scene, camera ) { + // update scene graph - // update scene graph + scene.updateMatrixWorld(); - scene.updateMatrixWorld(); + // update camera matrices and frustum - // update camera matrices and frustum + camera.updateMatrixWorld(); + camera.matrixWorldInverse.getInverse( camera.matrixWorld ); - camera.updateMatrixWorld(); - camera.matrixWorldInverse.getInverse( camera.matrixWorld ); + var boundUniforms = this.boundUniforms; - _each( this.boundUniforms, function( boundUniform ) { + for ( var name in boundUniforms ) { - switch (boundUniform.semantic) { + var boundUniform = boundUniforms[ name ]; - case "MODELVIEW": + switch ( boundUniform.semantic ) { - var m4 = boundUniform.uniform.value; - m4.multiplyMatrices(camera.matrixWorldInverse, - boundUniform.sourceNode.matrixWorld); - break; + case "MODELVIEW": - case "MODELVIEWINVERSETRANSPOSE": + var m4 = boundUniform.uniform.value; + m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld ); + break; - var m3 = boundUniform.uniform.value; - this._m4.multiplyMatrices(camera.matrixWorldInverse, - boundUniform.sourceNode.matrixWorld); - m3.getNormalMatrix(this._m4); - break; + case "MODELVIEWINVERSETRANSPOSE": - case "PROJECTION": + var m3 = boundUniform.uniform.value; + this._m4.multiplyMatrices( camera.matrixWorldInverse, boundUniform.sourceNode.matrixWorld ); + m3.getNormalMatrix( this._m4 ); + break; - var m4 = boundUniform.uniform.value; - m4.copy(camera.projectionMatrix); - break; + case "PROJECTION": - case "JOINTMATRIX": - - var m4v = boundUniform.uniform.value; - for (var mi = 0; mi < m4v.length; mi++) { - // So it goes like this: - // SkinnedMesh world matrix is already baked into MODELVIEW; - // ransform joints to local space, - // then transform using joint's inverse - m4v[mi] - .getInverse(boundUniform.sourceNode.matrixWorld) - .multiply(boundUniform.targetNode.skeleton.bones[ mi ].matrixWorld) - .multiply(boundUniform.targetNode.skeleton.boneInverses[mi]); - } - break; + var m4 = boundUniform.uniform.value; + m4.copy( camera.projectionMatrix ); + break; - default : + case "JOINTMATRIX": - console.warn("Unhandled shader semantic: " + boundUniform.semantic); - break; + var m4v = boundUniform.uniform.value; + + for ( var mi = 0; mi < m4v.length; mi ++ ) { + + // So it goes like this: + // SkinnedMesh world matrix is already baked into MODELVIEW; + // ransform joints to local space, + // then transform using joint's inverse + m4v[ mi ] + .getInverse( boundUniform.sourceNode.matrixWorld ) + .multiply( boundUniform.targetNode.skeleton.bones[ mi ].matrixWorld ) + .multiply( boundUniform.targetNode.skeleton.boneInverses[ mi ] ); + + } + + break; + + default : + + console.warn( "Unhandled shader semantic: " + boundUniform.semantic ); + break; + + } } - }.bind( this )); + }; -}; + /* GLTFANIMATION */ -/* GLTFANIMATION */ + GLTFLoader.Animations = new GLTFRegistry(); -THREE.GLTFLoader.Animations = new GLTFRegistry(); + // Construction/initialization + function GLTFAnimation( interps ) { -// Construction/initialization -var GLTFAnimation = function( interps ) { + this.running = false; + this.loop = false; + this.duration = 0; + this.startTime = 0; + this.interps = []; - this.running = false; - this.loop = false; - this.duration = 0; - this.startTime = 0; - this.interps = []; + this.uuid = THREE.Math.generateUUID(); - this.uuid = THREE.Math.generateUUID(); + if ( interps ) { - if ( interps ) { + this.createInterpolators( interps ); - this.createInterpolators( interps ); + } } -}; + GLTFAnimation.prototype.createInterpolators = function ( interps ) { -GLTFAnimation.prototype.createInterpolators = function( interps ) { + for ( var i = 0, len = interps.length; i < len; i ++ ) { - for ( var i = 0, len = interps.length; i < len; i ++ ) { + var interp = new GLTFInterpolator( interps[ i ] ); + this.interps.push( interp ); + this.duration = Math.max( this.duration, interp.duration ); - var interp = new GLTFInterpolator( interps[ i ] ); - this.interps.push( interp ); - this.duration = Math.max( this.duration, interp.duration ); + } - } + }; -} + // Start/stop + GLTFAnimation.prototype.play = function () { -// Start/stop -GLTFAnimation.prototype.play = function() { + if ( this.running ) + return; - if ( this.running ) - return; + this.startTime = Date.now(); + this.running = true; + GLTFLoader.Animations.add( this.uuid, this ); - this.startTime = Date.now(); - this.running = true; - THREE.GLTFLoader.Animations.add( this.uuid, this ); + }; -}; + GLTFAnimation.prototype.stop = function () { -GLTFAnimation.prototype.stop = function() { + this.running = false; + GLTFLoader.Animations.remove( this.uuid ); - this.running = false; - THREE.GLTFLoader.Animations.remove( this.uuid ); + }; -}; + // Update - drive key frame evaluation + GLTFAnimation.prototype.update = function () { -// Update - drive key frame evaluation -GLTFAnimation.prototype.update = function() { + if ( ! this.running ) return; - if ( !this.running ) - return; + var now = Date.now(); + var deltat = ( now - this.startTime ) / 1000; + var t = deltat % this.duration; + var nCycles = Math.floor( deltat / this.duration ); + var interps = this.interps; - var now = Date.now(); - var deltat = ( now - this.startTime ) / 1000; - var t = deltat % this.duration; - var nCycles = Math.floor( deltat / this.duration ); + if ( nCycles >= 1 && ! this.loop ) { - if ( nCycles >= 1 && ! this.loop ) { + this.running = false; - this.running = false; - _each( this.interps, function( _, i ) { + for ( var i = 0, l = interps.length; i < l; i ++ ) { - this.interps[ i ].interp( this.duration ); + interps[ i ].interp( this.duration ); - }.bind( this )); - this.stop(); - return; + } - } else { + this.stop(); - _each( this.interps, function( _, i ) { + } else { - this.interps[ i ].interp( t ); + for ( var i = 0, l = interps.length; i < l; i ++ ) { - }.bind( this )); + interps[ i ].interp( t ); - } + } -}; + } -/* GLTFINTERPOLATOR */ + }; -var GLTFInterpolator = function( param ) { + /* GLTFINTERPOLATOR */ - this.keys = param.keys; - this.values = param.values; - this.count = param.count; - this.type = param.type; - this.path = param.path; - this.isRot = false; + function GLTFInterpolator( param ) { - var node = param.target; - node.updateMatrix(); - node.matrixAutoUpdate = true; - this.targetNode = node; + this.keys = param.keys; + this.values = param.values; + this.count = param.count; + this.type = param.type; + this.path = param.path; + this.isRot = false; - switch ( param.path ) { + var node = param.target; + node.updateMatrix(); + node.matrixAutoUpdate = true; + this.targetNode = node; - case "translation" : + switch ( param.path ) { - this.target = node.position; - this.originalValue = node.position.clone(); - break; + case "translation" : - case "rotation" : + this.target = node.position; + this.originalValue = node.position.clone(); + break; - this.target = node.quaternion; - this.originalValue = node.quaternion.clone(); - this.isRot = true; - break; + case "rotation" : - case "scale" : + this.target = node.quaternion; + this.originalValue = node.quaternion.clone(); + this.isRot = true; + break; - this.target = node.scale; - this.originalValue = node.scale.clone(); - break; + case "scale" : - } + this.target = node.scale; + this.originalValue = node.scale.clone(); + break; + + } - this.duration = this.keys[ this.count - 1 ]; + this.duration = this.keys[ this.count - 1 ]; - this.vec1 = new THREE.Vector3(); - this.vec2 = new THREE.Vector3(); - this.vec3 = new THREE.Vector3(); - this.quat1 = new THREE.Quaternion(); - this.quat2 = new THREE.Quaternion(); - this.quat3 = new THREE.Quaternion(); + this.vec1 = new THREE.Vector3(); + this.vec2 = new THREE.Vector3(); + this.vec3 = new THREE.Vector3(); + this.quat1 = new THREE.Quaternion(); + this.quat2 = new THREE.Quaternion(); + this.quat3 = new THREE.Quaternion(); -}; + } -//Interpolation and tweening methods -GLTFInterpolator.prototype.interp = function( t ) { + //Interpolation and tweening methods + GLTFInterpolator.prototype.interp = function ( t ) { - if ( t == this.keys[ 0 ] ) { + if ( t == this.keys[ 0 ] ) { - if ( this.isRot ) { + if ( this.isRot ) { - this.quat3.fromArray( this.values ); + this.quat3.fromArray( this.values ); - } else { + } else { - this.vec3.fromArray( this.values ); + this.vec3.fromArray( this.values ); - } + } - } else if ( t < this.keys[ 0 ] ) { + } else if ( t < this.keys[ 0 ] ) { - if ( this.isRot ) { + if ( this.isRot ) { - this.quat1.copy( this.originalValue ); - this.quat2.fromArray( this.values ); - THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, t / this.keys[ 0 ] ); + this.quat1.copy( this.originalValue ); + this.quat2.fromArray( this.values ); + THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, t / this.keys[ 0 ] ); - } else { + } else { - this.vec3.copy( this.originalValue ); - this.vec2.fromArray( this.values ); - this.vec3.lerp( this.vec2, t / this.keys[ 0 ] ); + this.vec3.copy( this.originalValue ); + this.vec2.fromArray( this.values ); + this.vec3.lerp( this.vec2, t / this.keys[ 0 ] ); - } + } - } else if ( t >= this.keys[ this.count - 1 ] ) { + } else if ( t >= this.keys[ this.count - 1 ] ) { - if ( this.isRot ) { + if ( this.isRot ) { - this.quat3.fromArray( this.values, ( this.count - 1 ) * 4 ); + this.quat3.fromArray( this.values, ( this.count - 1 ) * 4 ); - } else { + } else { - this.vec3.fromArray( this.values, ( this.count - 1 ) * 3 ); + this.vec3.fromArray( this.values, ( this.count - 1 ) * 3 ); - } + } - } else { + } else { - for ( var i = 0; i < this.count - 1; i ++ ) { + for ( var i = 0; i < this.count - 1; i ++ ) { - var key1 = this.keys[ i ]; - var key2 = this.keys[ i + 1 ]; + var key1 = this.keys[ i ]; + var key2 = this.keys[ i + 1 ]; - if ( t >= key1 && t <= key2 ) { + if ( t >= key1 && t <= key2 ) { - if ( this.isRot ) { + if ( this.isRot ) { - this.quat1.fromArray( this.values, i * 4 ); - this.quat2.fromArray( this.values, ( i + 1 ) * 4 ); - THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, ( t - key1 ) / ( key2 - key1 ) ); + this.quat1.fromArray( this.values, i * 4 ); + this.quat2.fromArray( this.values, ( i + 1 ) * 4 ); + THREE.Quaternion.slerp( this.quat1, this.quat2, this.quat3, ( t - key1 ) / ( key2 - key1 ) ); - } else { + } else { - this.vec3.fromArray( this.values, i * 3 ); - this.vec2.fromArray( this.values, ( i + 1 ) * 3 ); - this.vec3.lerp( this.vec2, ( t - key1 ) / ( key2 - key1 ) ); + this.vec3.fromArray( this.values, i * 3 ); + this.vec2.fromArray( this.values, ( i + 1 ) * 3 ); + this.vec3.lerp( this.vec2, ( t - key1 ) / ( key2 - key1 ) ); + + } } @@ -449,705 +452,683 @@ GLTFInterpolator.prototype.interp = function( t ) { } - } + if ( this.target ) { - if ( this.target ) { + if ( this.isRot ) { - if ( this.isRot ) { + this.target.copy( this.quat3 ); - this.target.copy( this.quat3 ); + } else { - } else { + this.target.copy( this.vec3 ); - this.target.copy( this.vec3 ); + } } - } + }; -}; - - -/*********************************/ -/********** INTERNALS ************/ -/*********************************/ - -/* CONSTANTS */ - -var WEBGL_CONSTANTS = { - FLOAT: 5126, - //FLOAT_MAT2: 35674, - FLOAT_MAT3: 35675, - FLOAT_MAT4: 35676, - FLOAT_VEC2: 35664, - FLOAT_VEC3: 35665, - FLOAT_VEC4: 35666, - LINEAR: 9729, - REPEAT: 10497, - SAMPLER_2D: 35678, - TRIANGLES: 4, - UNSIGNED_BYTE: 5121, - UNSIGNED_SHORT: 5123, - - VERTEX_SHADER: 35633, - FRAGMENT_SHADER: 35632 -}; - -var WEBGL_TYPE = { - 5126: Number, - //35674: THREE.Matrix2, - 35675: THREE.Matrix3, - 35676: THREE.Matrix4, - 35664: THREE.Vector2, - 35665: THREE.Vector3, - 35666: THREE.Vector4, - 35678: THREE.Texture -}; - -var WEBGL_COMPONENT_TYPES = { - 5120: Int8Array, - 5121: Uint8Array, - 5122: Int16Array, - 5123: Uint16Array, - 5125: Uint32Array, - 5126: Float32Array -}; - -var WEBGL_FILTERS = { - 9728: THREE.NearestFilter, - 9729: THREE.LinearFilter, - 9984: THREE.NearestMipMapNearestFilter, - 9985: THREE.LinearMipMapNearestFilter, - 9986: THREE.NearestMipMapLinearFilter, - 9987: THREE.LinearMipMapLinearFilter -}; - -var WEBGL_WRAPPINGS = { - 33071: THREE.ClampToEdgeWrapping, - 33648: THREE.MirroredRepeatWrapping, - 10497: THREE.RepeatWrapping -}; - -var WEBGL_TYPE_SIZES = { - 'SCALAR': 1, - 'VEC2': 2, - 'VEC3': 3, - 'VEC4': 4, - 'MAT2': 4, - 'MAT3': 9, - 'MAT4': 16 -}; - -/* UTILITY FUNCTIONS */ - -var _each = function( object, callback, thisObj ) { - - if ( !object ) { - return Promise.resolve(); - } - var results; - var fns = []; + /*********************************/ + /********** INTERNALS ************/ + /*********************************/ + + /* CONSTANTS */ + + var WEBGL_CONSTANTS = { + FLOAT: 5126, + //FLOAT_MAT2: 35674, + FLOAT_MAT3: 35675, + FLOAT_MAT4: 35676, + FLOAT_VEC2: 35664, + FLOAT_VEC3: 35665, + FLOAT_VEC4: 35666, + LINEAR: 9729, + REPEAT: 10497, + SAMPLER_2D: 35678, + TRIANGLES: 4, + UNSIGNED_BYTE: 5121, + UNSIGNED_SHORT: 5123, + + VERTEX_SHADER: 35633, + FRAGMENT_SHADER: 35632 + }; - if ( Object.prototype.toString.call( object ) === '[object Array]' ) { + var WEBGL_TYPE = { + 5126: Number, + //35674: THREE.Matrix2, + 35675: THREE.Matrix3, + 35676: THREE.Matrix4, + 35664: THREE.Vector2, + 35665: THREE.Vector3, + 35666: THREE.Vector4, + 35678: THREE.Texture + }; - results = []; + var WEBGL_COMPONENT_TYPES = { + 5120: Int8Array, + 5121: Uint8Array, + 5122: Int16Array, + 5123: Uint16Array, + 5125: Uint32Array, + 5126: Float32Array + }; - var length = object.length; - for ( var idx = 0; idx < length; idx ++ ) { - var value = callback.call( thisObj || this, object[ idx ], idx ); - if ( value ) { - fns.push( value ); - if ( value instanceof Promise ) { - value.then( function( key, value ) { - results[ idx ] = value; - }.bind( this, key )); - } else { - results[ idx ] = value; - } - } + var WEBGL_FILTERS = { + 9728: THREE.NearestFilter, + 9729: THREE.LinearFilter, + 9984: THREE.NearestMipMapNearestFilter, + 9985: THREE.LinearMipMapNearestFilter, + 9986: THREE.NearestMipMapLinearFilter, + 9987: THREE.LinearMipMapLinearFilter + }; + + var WEBGL_WRAPPINGS = { + 33071: THREE.ClampToEdgeWrapping, + 33648: THREE.MirroredRepeatWrapping, + 10497: THREE.RepeatWrapping + }; + + var WEBGL_TYPE_SIZES = { + 'SCALAR': 1, + 'VEC2': 2, + 'VEC3': 3, + 'VEC4': 4, + 'MAT2': 4, + 'MAT3': 9, + 'MAT4': 16 + }; + + /* UTILITY FUNCTIONS */ + + function _each( object, callback, thisObj ) { + + if ( !object ) { + return Promise.resolve(); } - } else { + var results; + var fns = []; + + if ( Object.prototype.toString.call( object ) === '[object Array]' ) { - results = {}; + results = []; - for ( var key in object ) { - if ( object.hasOwnProperty( key ) ) { - var value = callback.call( thisObj || this, object[ key ], key ); + var length = object.length; + for ( var idx = 0; idx < length; idx ++ ) { + var value = callback.call( thisObj || this, object[ idx ], idx ); if ( value ) { fns.push( value ); if ( value instanceof Promise ) { value.then( function( key, value ) { - results[ key ] = value; + results[ idx ] = value; }.bind( this, key )); } else { - results[ key ] = value; + results[ idx ] = value; } } } - } - } - - return Promise.all( fns ).then( function() { - return results; - }); - -}; - -var resolveURL = function( url, path ) { + } else { - // Invalid URL - if ( typeof url !== 'string' || url === '' ) - return ''; + results = {}; + + for ( var key in object ) { + if ( object.hasOwnProperty( key ) ) { + var value = callback.call( thisObj || this, object[ key ], key ); + if ( value ) { + fns.push( value ); + if ( value instanceof Promise ) { + value.then( function( key, value ) { + results[ key ] = value; + }.bind( this, key )); + } else { + results[ key ] = value; + } + } + } + } - // Absolute URL - if ( /^https?:\/\//i.test( url ) ) { + } - return url; + return Promise.all( fns ).then( function() { + return results; + }); } - // Data URI - if ( /^data:.*,.*$/i.test( url ) ) { + function resolveURL( url, path ) { - return url; + // Invalid URL + if ( typeof url !== 'string' || url === '' ) + return ''; - } + // Absolute URL + if ( /^https?:\/\//i.test( url ) ) { - // Relative URL - return (path || '') + url; + return url; -}; + } -// Three.js seems too dependent on attribute names so globally -// replace those in the shader code -var replaceTHREEShaderAttributes = function( shaderText, technique ) { + // Data URI + if ( /^data:.*,.*$/i.test( url ) ) { - // Expected technique attributes - var attributes = {}; + return url; - _each( technique.attributes, function( pname, attributeId ) { + } - var param = technique.parameters[ pname ]; - var atype = param.type; - var semantic = param.semantic; + // Relative URL + return ( path || '' ) + url; - attributes[ attributeId ] = { - type : atype, - semantic : semantic - }; + } - }); + // Three.js seems too dependent on attribute names so globally + // replace those in the shader code + function replaceTHREEShaderAttributes( shaderText, technique ) { - // Figure out which attributes to change in technique + // Expected technique attributes + var attributes = {}; - var shaderParams = technique.parameters; - var shaderAttributes = technique.attributes; - var params = {}; + for ( var attributeId in technique.attributes ) { - _each( attributes, function( _, attributeId ) { + var pname = technique.attributes[ attributeId ]; - var pname = shaderAttributes[ attributeId ]; - var shaderParam = shaderParams[ pname ]; - var semantic = shaderParam.semantic; - if ( semantic ) { + var param = technique.parameters[ pname ]; + var atype = param.type; + var semantic = param.semantic; - params[ attributeId ] = shaderParam; + attributes[ attributeId ] = { + type: atype, + semantic: semantic + }; } - }); + // Figure out which attributes to change in technique - _each( params, function( param, pname ) { + var shaderParams = technique.parameters; + var shaderAttributes = technique.attributes; + var params = {}; - var semantic = param.semantic; + for ( var attributeId in attributes ) { - var regEx = new RegExp( "\\b" + pname + "\\b", "g" ); + var pname = shaderAttributes[ attributeId ]; + var shaderParam = shaderParams[ pname ]; + var semantic = shaderParam.semantic; + if ( semantic ) { - switch ( semantic ) { + params[ attributeId ] = shaderParam; - case "POSITION": + } - shaderText = shaderText.replace( regEx, 'position' ); - break; + } - case "NORMAL": + for ( var pname in params ) { - shaderText = shaderText.replace( regEx, 'normal' ); - break; + var param = params[ pname ]; + var semantic = param.semantic; - case 'TEXCOORD_0': - case 'TEXCOORD0': - case 'TEXCOORD': + var regEx = new RegExp( "\\b" + pname + "\\b", "g" ); - shaderText = shaderText.replace( regEx, 'uv' ); - break; + switch ( semantic ) { - case "WEIGHT": + case "POSITION": - shaderText = shaderText.replace(regEx, 'skinWeight'); - break; + shaderText = shaderText.replace( regEx, 'position' ); + break; - case "JOINT": + case "NORMAL": - shaderText = shaderText.replace(regEx, 'skinIndex'); - break; + shaderText = shaderText.replace( regEx, 'normal' ); + break; - } + case 'TEXCOORD_0': + case 'TEXCOORD0': + case 'TEXCOORD': - }); + shaderText = shaderText.replace( regEx, 'uv' ); + break; - return shaderText; + case "WEIGHT": -}; + shaderText = shaderText.replace( regEx, 'skinWeight' ); + break; -// Deferred constructor for RawShaderMaterial types -var DeferredShaderMaterial = function( params ) { + case "JOINT": - this.isDeferredShaderMaterial = true; + shaderText = shaderText.replace( regEx, 'skinIndex' ); + break; - this.params = params; + } -}; + } -DeferredShaderMaterial.prototype.create = function() { + return shaderText; - var uniforms = THREE.UniformsUtils.clone( this.params.uniforms ); + } - _each( this.params.uniforms, function( originalUniform, uniformId ) { + // Deferred constructor for RawShaderMaterial types + function DeferredShaderMaterial( params ) { - if ( originalUniform.value instanceof THREE.Texture ) { + this.isDeferredShaderMaterial = true; - uniforms[ uniformId ].value = originalUniform.value; - uniforms[ uniformId ].value.needsUpdate = true; + this.params = params; - } + } - uniforms[ uniformId ].semantic = originalUniform.semantic; - uniforms[ uniformId ].node = originalUniform.node; + DeferredShaderMaterial.prototype.create = function () { - }); + var uniforms = THREE.UniformsUtils.clone( this.params.uniforms ); - this.params.uniforms = uniforms; + for ( var uniformId in this.params.uniforms ) { - return new THREE.RawShaderMaterial( this.params ); + var originalUniform = this.params.uniforms[ uniformId ]; -}; + if ( originalUniform.value instanceof THREE.Texture ) { -/* GLTF PARSER */ + uniforms[ uniformId ].value = originalUniform.value; + uniforms[ uniformId ].value.needsUpdate = true; -var GLTFParser = function(json, options) { + } - this.json = json || {}; - this.options = options || {}; + uniforms[ uniformId ].semantic = originalUniform.semantic; + uniforms[ uniformId ].node = originalUniform.node; - // loader object cache - this.cache = new GLTFRegistry(); + } -}; + this.params.uniforms = uniforms; -GLTFParser.prototype._withDependencies = function( dependencies ) { + return new THREE.RawShaderMaterial( this.params ); - var _dependencies = {}; + }; - for ( var i = 0; i < dependencies.length; i ++ ) { + /* GLTF PARSER */ - var dependency = dependencies[ i ]; - var fnName = "load" + dependency.charAt(0).toUpperCase() + dependency.slice(1); + function GLTFParser( json, options ) { - var cached = this.cache.get( dependency ); + this.json = json || {}; + this.options = options || {}; - if ( cached !== undefined ) { + // loader object cache + this.cache = new GLTFRegistry(); - _dependencies[ dependency ] = cached; + } - } else if ( this[ fnName ] ) { + GLTFParser.prototype._withDependencies = function ( dependencies ) { - var fn = this[ fnName ](); - this.cache.add( dependency, fn ); + var _dependencies = {}; - _dependencies[ dependency ] = fn; + for ( var i = 0; i < dependencies.length; i ++ ) { - } + var dependency = dependencies[ i ]; + var fnName = "load" + dependency.charAt( 0 ).toUpperCase() + dependency.slice( 1 ); - } + var cached = this.cache.get( dependency ); - return _each( _dependencies, function( dependency, dependencyId ) { + if ( cached !== undefined ) { - return dependency; + _dependencies[ dependency ] = cached; - }); + } else if ( this[ fnName ] ) { -}; + var fn = this[ fnName ](); + this.cache.add( dependency, fn ); -GLTFParser.prototype.parse = function( callback ) { + _dependencies[ dependency ] = fn; - // Clear the loader cache - this.cache.removeAll(); + } - // Fire the callback on complete - this._withDependencies([ - "scenes", - "cameras", - "animations" - ]).then(function( dependencies ) { + } - var scene = dependencies.scenes[ this.json.scene ]; + return _each( _dependencies, function ( dependency ) { - var cameras = []; - _each( dependencies.cameras, function( camera ) { + return dependency; - cameras.push( camera ); + } ); - }); + }; - var animations = []; - _each( dependencies.animations, function( animation ) { + GLTFParser.prototype.parse = function ( callback ) { - animations.push( animation ); + // Clear the loader cache + this.cache.removeAll(); - }); + // Fire the callback on complete + this._withDependencies( [ + + "scenes", + "cameras", + "animations" - callback( scene, cameras, animations ); + ] ).then( function ( dependencies ) { - }.bind( this )); + var scene = dependencies.scenes[ this.json.scene ]; -}; + var cameras = []; -GLTFParser.prototype.loadShaders = function() { + for ( var name in dependencies.cameras ) { - return _each( this.json.shaders, function( shader, shaderId ) { + var camera = dependencies.cameras[ name ]; + cameras.push( camera ); - return new Promise( function( resolve ) { + } - var loader = new THREE.FileLoader(); - loader.responseType = 'text'; - loader.load( resolveURL( shader.uri, this.options.path ), function( shaderText ) { + var animations = []; - resolve( shaderText ); + for ( var name in dependencies.animations ) { - }); + var animation = dependencies.animations[ name ]; + animations.push( animation ); - }.bind( this )); + } - }.bind( this )); + callback( scene, cameras, animations ); -}; + }.bind( this ) ); -GLTFParser.prototype.loadBuffers = function() { + }; - return _each( this.json.buffers, function( buffer, bufferId ) { + GLTFParser.prototype.loadShaders = function () { - if ( buffer.type === 'arraybuffer' ) { + return _each( this.json.shaders, function ( shader ) { - return new Promise( function( resolve ) { + return new Promise( function ( resolve ) { var loader = new THREE.FileLoader(); - loader.responseType = 'arraybuffer'; - loader.load( resolveURL( buffer.uri, this.options.path ), function( buffer ) { + loader.responseType = 'text'; + loader.load( resolveURL( shader.uri, this.options.path ), function ( shaderText ) { - resolve( buffer ); + resolve( shaderText ); } ); - }.bind( this )); + }.bind( this ) ); - } + }.bind( this ) ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadBuffers = function () { -GLTFParser.prototype.loadBufferViews = function() { + return _each( this.json.buffers, function ( buffer ) { - return this._withDependencies([ - "buffers" - ]).then( function( dependencies ) { + if ( buffer.type === 'arraybuffer' ) { - return _each( this.json.bufferViews, function( bufferView, bufferViewId ) { + return new Promise( function ( resolve ) { - var arraybuffer = dependencies.buffers[ bufferView.buffer ]; + var loader = new THREE.FileLoader(); + loader.responseType = 'arraybuffer'; + loader.load( resolveURL( buffer.uri, this.options.path ), function ( buffer ) { - return arraybuffer.slice( bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength ); + resolve( buffer ); - }); + } ); - }.bind( this )); + }.bind( this ) ); -}; + } -GLTFParser.prototype.loadAccessors = function() { + }.bind( this ) ); - return this._withDependencies([ - "bufferViews" - ]).then( function( dependencies ) { + }; - return _each( this.json.accessors, function( accessor, accessorId ) { + GLTFParser.prototype.loadBufferViews = function () { - var arraybuffer = dependencies.bufferViews[ accessor.bufferView ]; - var itemSize = WEBGL_TYPE_SIZES[ accessor.type ]; - var TypedArray = WEBGL_COMPONENT_TYPES[ accessor.componentType ]; + return this._withDependencies( [ - // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. - var elementBytes = TypedArray.BYTES_PER_ELEMENT; - var itemBytes = elementBytes * itemSize; + "buffers" - // The buffer is not interleaved if the stride is the item size in bytes. - if ( accessor.byteStride && accessor.byteStride !== itemBytes ) { + ] ).then( function ( dependencies ) { - // Use the full buffer if it's interleaved. - var array = new TypedArray( arraybuffer ); + return _each( this.json.bufferViews, function ( bufferView ) { - // Integer parameters to IB/IBA are in array elements, not bytes. - var ib = new THREE.InterleavedBuffer( array, accessor.byteStride / elementBytes ); + var arraybuffer = dependencies.buffers[ bufferView.buffer ]; - return new THREE.InterleavedBufferAttribute( ib, itemSize, accessor.byteOffset / elementBytes ); + return arraybuffer.slice( bufferView.byteOffset, bufferView.byteOffset + bufferView.byteLength ); - } else { + } ); - array = new TypedArray( arraybuffer, accessor.byteOffset, accessor.count * itemSize ); + }.bind( this ) ); - return new THREE.BufferAttribute( array, itemSize ); + }; - } + GLTFParser.prototype.loadAccessors = function () { - }); + return this._withDependencies( [ - }.bind( this )); + "bufferViews" -}; + ] ).then( function ( dependencies ) { -GLTFParser.prototype.loadTextures = function() { + return _each( this.json.accessors, function ( accessor ) { - return _each( this.json.textures, function( texture, textureId ) { + var arraybuffer = dependencies.bufferViews[ accessor.bufferView ]; + var itemSize = WEBGL_TYPE_SIZES[ accessor.type ]; + var TypedArray = WEBGL_COMPONENT_TYPES[ accessor.componentType ]; - if ( texture.source ) { + // For VEC3: itemSize is 3, elementBytes is 4, itemBytes is 12. + var elementBytes = TypedArray.BYTES_PER_ELEMENT; + var itemBytes = elementBytes * itemSize; - return new Promise( function( resolve ) { + // The buffer is not interleaved if the stride is the item size in bytes. + if ( accessor.byteStride && accessor.byteStride !== itemBytes ) { - var source = this.json.images[ texture.source ]; + // Use the full buffer if it's interleaved. + var array = new TypedArray( arraybuffer ); - var textureLoader = THREE.Loader.Handlers.get( source.uri ); - if ( textureLoader === null ) { + // Integer parameters to IB/IBA are in array elements, not bytes. + var ib = new THREE.InterleavedBuffer( array, accessor.byteStride / elementBytes ); - textureLoader = new THREE.TextureLoader(); + return new THREE.InterleavedBufferAttribute( ib, itemSize, accessor.byteOffset / elementBytes ); - } - textureLoader.crossOrigin = this.options.crossOrigin || false; + } else { - textureLoader.load( resolveURL( source.uri, this.options.path ), function( _texture ) { + array = new TypedArray( arraybuffer, accessor.byteOffset, accessor.count * itemSize ); - _texture.flipY = false; + return new THREE.BufferAttribute( array, itemSize ); - if ( texture.sampler ) { + } - var sampler = this.json.samplers[ texture.sampler ]; + } ); - _texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ]; - _texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ]; - _texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ]; - _texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ]; + }.bind( this ) ); - } + }; - resolve( _texture ); + GLTFParser.prototype.loadTextures = function () { - }.bind( this )); + return _each( this.json.textures, function ( texture ) { - }.bind( this )); + if ( texture.source ) { - } + return new Promise( function ( resolve ) { - }.bind( this )); + var source = this.json.images[ texture.source ]; -}; + var textureLoader = THREE.Loader.Handlers.get( source.uri ); -GLTFParser.prototype.loadMaterials = function() { + if ( textureLoader === null ) { - return this._withDependencies([ - "shaders", - "textures" - ]).then( function( dependencies ) { + textureLoader = new THREE.TextureLoader(); - return _each( this.json.materials, function( material, materialId ) { + } - var materialType; - var materialValues = {}; - var materialParams = {}; + textureLoader.crossOrigin = this.options.crossOrigin || false; - var khr_material; + textureLoader.load( resolveURL( source.uri, this.options.path ), function ( _texture ) { - if ( material.extensions && material.extensions.KHR_materials_common ) { + _texture.flipY = false; - khr_material = material.extensions.KHR_materials_common; + if ( texture.sampler ) { - } else if ( this.json.extensions && this.json.extensions.KHR_materials_common ) { + var sampler = this.json.samplers[ texture.sampler ]; - khr_material = this.json.extensions.KHR_materials_common; + _texture.magFilter = WEBGL_FILTERS[ sampler.magFilter ]; + _texture.minFilter = WEBGL_FILTERS[ sampler.minFilter ]; + _texture.wrapS = WEBGL_WRAPPINGS[ sampler.wrapS ]; + _texture.wrapT = WEBGL_WRAPPINGS[ sampler.wrapT ]; - } + } - if ( khr_material ) { + resolve( _texture ); - switch ( khr_material.technique ) - { - case 'BLINN' : - case 'PHONG' : - materialType = THREE.MeshPhongMaterial; - break; + }.bind( this ) ); - case 'LAMBERT' : - materialType = THREE.MeshLambertMaterial; - break; + }.bind( this ) ); - case 'CONSTANT' : - default : - materialType = THREE.MeshBasicMaterial; - break; - } + } - _each( khr_material.values, function( value, prop ) { + }.bind( this ) ); - materialValues[ prop ] = value; + }; - }); + GLTFParser.prototype.loadMaterials = function () { - if ( khr_material.doubleSided || materialValues.doubleSided ) { + return this._withDependencies( [ - materialParams.side = THREE.DoubleSide; + "shaders", + "textures" - } + ] ).then( function ( dependencies ) { - if ( khr_material.transparent || materialValues.transparent ) { + return _each( this.json.materials, function ( material ) { - materialParams.transparent = true; - materialParams.opacity = ( materialValues.transparency !== undefined ) ? materialValues.transparency : 1; + var materialType; + var materialValues = {}; + var materialParams = {}; - } + var khr_material; - } else if ( material.technique === undefined ) { + if ( material.extensions && material.extensions.KHR_materials_common ) { - materialType = THREE.MeshPhongMaterial; + khr_material = material.extensions.KHR_materials_common; - _each( material.values, function( value, prop ) { + } else if ( this.json.extensions && this.json.extensions.KHR_materials_common ) { - materialValues[ prop ] = value; + khr_material = this.json.extensions.KHR_materials_common; - }); + } - } else { + if ( khr_material ) { - materialType = DeferredShaderMaterial; + switch ( khr_material.technique ) { - var technique = this.json.techniques[ material.technique ]; + case 'BLINN' : + case 'PHONG' : + materialType = THREE.MeshPhongMaterial; + break; - materialParams.uniforms = {}; + case 'LAMBERT' : + materialType = THREE.MeshLambertMaterial; + break; - var program = this.json.programs[ technique.program ]; + case 'CONSTANT' : + default : + materialType = THREE.MeshBasicMaterial; + break; - if ( program ) { + } - materialParams.fragmentShader = dependencies.shaders[ program.fragmentShader ]; + Object.assign( materialValues, khr_material.values ); - if ( ! materialParams.fragmentShader ) { + if ( khr_material.doubleSided || materialValues.doubleSided ) { - console.warn( "ERROR: Missing fragment shader definition:", program.fragmentShader ); - materialType = THREE.MeshPhongMaterial; + materialParams.side = THREE.DoubleSide; } - var vertexShader = dependencies.shaders[ program.vertexShader ]; + if ( khr_material.transparent || materialValues.transparent ) { - if ( ! vertexShader ) { - - console.warn( "ERROR: Missing vertex shader definition:", program.vertexShader ); - materialType = THREE.MeshPhongMaterial; + materialParams.transparent = true; + materialParams.opacity = ( materialValues.transparency !== undefined ) ? materialValues.transparency : 1; } - // IMPORTANT: FIX VERTEX SHADER ATTRIBUTE DEFINITIONS - materialParams.vertexShader = replaceTHREEShaderAttributes( vertexShader, technique ); + } else if ( material.technique === undefined ) { - var uniforms = technique.uniforms; + materialType = THREE.MeshPhongMaterial; - _each( uniforms, function( pname, uniformId ) { + Object.assign( materialValues, material.values ); - var shaderParam = technique.parameters[ pname ]; + } else { - var ptype = shaderParam.type; + materialType = DeferredShaderMaterial; - if ( WEBGL_TYPE[ ptype ] ) { + var technique = this.json.techniques[ material.technique ]; - var pcount = shaderParam.count; - var value = material.values[ pname ]; + materialParams.uniforms = {}; - var uvalue = new WEBGL_TYPE[ ptype ](); - var usemantic = shaderParam.semantic; - var unode = shaderParam.node; + var program = this.json.programs[ technique.program ]; - switch ( ptype ) { + if ( program ) { - case WEBGL_CONSTANTS.FLOAT: + materialParams.fragmentShader = dependencies.shaders[ program.fragmentShader ]; - uvalue = shaderParam.value; + if ( ! materialParams.fragmentShader ) { - if ( pname == "transparency" ) { + console.warn( "ERROR: Missing fragment shader definition:", program.fragmentShader ); + materialType = THREE.MeshPhongMaterial; - materialParams.transparent = true; + } - } + var vertexShader = dependencies.shaders[ program.vertexShader ]; - if ( value !== undefined ) { + if ( ! vertexShader ) { - uvalue = value; + console.warn( "ERROR: Missing vertex shader definition:", program.vertexShader ); + materialType = THREE.MeshPhongMaterial; - } + } - break; + // IMPORTANT: FIX VERTEX SHADER ATTRIBUTE DEFINITIONS + materialParams.vertexShader = replaceTHREEShaderAttributes( vertexShader, technique ); - case WEBGL_CONSTANTS.FLOAT_VEC2: - case WEBGL_CONSTANTS.FLOAT_VEC3: - case WEBGL_CONSTANTS.FLOAT_VEC4: - case WEBGL_CONSTANTS.FLOAT_MAT3: + var uniforms = technique.uniforms; - if ( shaderParam && shaderParam.value ) { + for ( var uniformId in uniforms ) { - uvalue.fromArray( shaderParam.value ); + var pname = uniforms[ uniformId ]; + var shaderParam = technique.parameters[ pname ]; - } + var ptype = shaderParam.type; - if ( value ) { + if ( WEBGL_TYPE[ ptype ] ) { - uvalue.fromArray( value ); + var pcount = shaderParam.count; + var value = material.values[ pname ]; - } + var uvalue = new WEBGL_TYPE[ ptype ](); + var usemantic = shaderParam.semantic; + var unode = shaderParam.node; - break; + switch ( ptype ) { - case WEBGL_CONSTANTS.FLOAT_MAT2: + case WEBGL_CONSTANTS.FLOAT: - // what to do? - console.warn("FLOAT_MAT2 is not a supported uniform type"); - break; + uvalue = shaderParam.value; - case WEBGL_CONSTANTS.FLOAT_MAT4: + if ( pname == "transparency" ) { - if ( pcount ) { + materialParams.transparent = true; - uvalue = new Array( pcount ); + } - for ( var mi = 0; mi < pcount; mi ++ ) { + if ( value !== undefined ) { - uvalue[ mi ] = new WEBGL_TYPE[ ptype ](); + uvalue = value; } + break; + + case WEBGL_CONSTANTS.FLOAT_VEC2: + case WEBGL_CONSTANTS.FLOAT_VEC3: + case WEBGL_CONSTANTS.FLOAT_VEC4: + case WEBGL_CONSTANTS.FLOAT_MAT3: + if ( shaderParam && shaderParam.value ) { - var m4v = shaderParam.value; - uvalue.fromArray( m4v ); + uvalue.fromArray( shaderParam.value ); } @@ -1157,285 +1138,329 @@ GLTFParser.prototype.loadMaterials = function() { } - } else { + break; - if ( shaderParam && shaderParam.value ) { + case WEBGL_CONSTANTS.FLOAT_MAT2: - var m4 = shaderParam.value; - uvalue.fromArray( m4 ); + // what to do? + console.warn( "FLOAT_MAT2 is not a supported uniform type" ); + break; - } + case WEBGL_CONSTANTS.FLOAT_MAT4: - if ( value ) { + if ( pcount ) { - uvalue.fromArray( value ); + uvalue = new Array( pcount ); + + for ( var mi = 0; mi < pcount; mi ++ ) { + + uvalue[ mi ] = new WEBGL_TYPE[ ptype ](); + + } + + if ( shaderParam && shaderParam.value ) { + + var m4v = shaderParam.value; + uvalue.fromArray( m4v ); + + } + + if ( value ) { + + uvalue.fromArray( value ); + + } + + } else { + + if ( shaderParam && shaderParam.value ) { + + var m4 = shaderParam.value; + uvalue.fromArray( m4 ); + + } + + if ( value ) { + + uvalue.fromArray( value ); + + } } - } + break; - break; + case WEBGL_CONSTANTS.SAMPLER_2D: - case WEBGL_CONSTANTS.SAMPLER_2D: + uvalue = value ? dependencies.textures[ value ] : null; - uvalue = value ? dependencies.textures[ value ] : null; + break; - break; + } - } + materialParams.uniforms[ uniformId ] = { + value: uvalue, + semantic: usemantic, + node: unode + }; - materialParams.uniforms[ uniformId ] = { - value: uvalue, - semantic: usemantic, - node: unode - }; + } else { - } else { + throw new Error( "Unknown shader uniform param type: " + ptype ); - throw new Error( "Unknown shader uniform param type: " + ptype ); + } } - }); + } } - } + if ( Array.isArray( materialValues.diffuse ) ) { - if ( Array.isArray( materialValues.diffuse ) ) { + materialParams.color = new THREE.Color().fromArray( materialValues.diffuse ); - materialParams.color = new THREE.Color().fromArray( materialValues.diffuse ); + } else if ( typeof( materialValues.diffuse ) === 'string' ) { - } else if ( typeof( materialValues.diffuse ) === 'string' ) { + materialParams.map = dependencies.textures[ materialValues.diffuse ]; - materialParams.map = dependencies.textures[ materialValues.diffuse ]; + } - } + delete materialParams.diffuse; - delete materialParams.diffuse; + if ( typeof( materialValues.reflective ) === 'string' ) { - if ( typeof( materialValues.reflective ) === 'string' ) { + materialParams.envMap = dependencies.textures[ materialValues.reflective ]; - materialParams.envMap = dependencies.textures[ materialValues.reflective ]; + } - } + if ( typeof( materialValues.bump ) === 'string' ) { - if ( typeof( materialValues.bump ) === 'string' ) { + materialParams.bumpMap = dependencies.textures[ materialValues.bump ]; - materialParams.bumpMap = dependencies.textures[ materialValues.bump ]; + } - } + if ( Array.isArray( materialValues.emission ) ) { - if ( Array.isArray( materialValues.emission ) ) { + materialParams.emissive = new THREE.Color().fromArray( materialValues.emission ); - materialParams.emissive = new THREE.Color().fromArray( materialValues.emission ); + } - } + if ( Array.isArray( materialValues.specular ) ) { - if ( Array.isArray( materialValues.specular ) ) { + materialParams.specular = new THREE.Color().fromArray( materialValues.specular ); - materialParams.specular = new THREE.Color().fromArray( materialValues.specular ); + } - } + if ( materialValues.shininess !== undefined ) { - if ( materialValues.shininess !== undefined ) { + materialParams.shininess = materialValues.shininess; - materialParams.shininess = materialValues.shininess; + } - } + var _material = new materialType( materialParams ); + _material.name = material.name; - var _material = new materialType( materialParams ); - _material.name = material.name; + return _material; - return _material; + }.bind( this ) ); - }.bind( this )); + }.bind( this ) ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadMeshes = function () { -GLTFParser.prototype.loadMeshes = function() { + return this._withDependencies( [ - return this._withDependencies([ - "accessors", - "materials" - ]).then( function( dependencies ) { + "accessors", + "materials" - return _each( this.json.meshes, function( mesh, meshId ) { + ] ).then( function ( dependencies ) { - var group = new THREE.Object3D(); - group.name = mesh.name; + return _each( this.json.meshes, function ( mesh ) { - var primitives = mesh.primitives; + var group = new THREE.Object3D(); + group.name = mesh.name; - _each( primitives, function( primitive ) { + var primitives = mesh.primitives; - if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === undefined ) { + for ( var name in primitives ) { - var geometry = new THREE.BufferGeometry(); + var primitive = primitives[ name ]; - var attributes = primitive.attributes; + if ( primitive.mode === WEBGL_CONSTANTS.TRIANGLES || primitive.mode === undefined ) { - _each( attributes, function( attributeEntry, attributeId ) { + var geometry = new THREE.BufferGeometry(); - if ( !attributeEntry ) { + var attributes = primitive.attributes; - return; + for ( var attributeId in attributes ) { - } + var attributeEntry = attributes[ attributeId ]; - var bufferAttribute = dependencies.accessors[ attributeEntry ]; + if ( ! attributeEntry ) return; - switch ( attributeId ) { + var bufferAttribute = dependencies.accessors[ attributeEntry ]; - case 'POSITION': - geometry.addAttribute( 'position', bufferAttribute ); - break; + switch ( attributeId ) { - case 'NORMAL': - geometry.addAttribute( 'normal', bufferAttribute ); - break; + case 'POSITION': + geometry.addAttribute( 'position', bufferAttribute ); + break; - case 'TEXCOORD_0': - case 'TEXCOORD0': - case 'TEXCOORD': - geometry.addAttribute( 'uv', bufferAttribute ); - break; + case 'NORMAL': + geometry.addAttribute( 'normal', bufferAttribute ); + break; - case 'WEIGHT': - geometry.addAttribute( 'skinWeight', bufferAttribute ); - break; + case 'TEXCOORD_0': + case 'TEXCOORD0': + case 'TEXCOORD': + geometry.addAttribute( 'uv', bufferAttribute ); + break; - case 'JOINT': - geometry.addAttribute( 'skinIndex', bufferAttribute ); - break; + case 'WEIGHT': + geometry.addAttribute( 'skinWeight', bufferAttribute ); + break; - } + case 'JOINT': + geometry.addAttribute( 'skinIndex', bufferAttribute ); + break; - }); + } + + } - if ( primitive.indices ) { + if ( primitive.indices ) { - var indexArray = dependencies.accessors[ primitive.indices ]; + var indexArray = dependencies.accessors[ primitive.indices ]; - geometry.setIndex( indexArray ); + geometry.setIndex( indexArray ); - var offset = { + var offset = { start: 0, index: 0, count: indexArray.count }; - geometry.groups.push( offset ); + geometry.groups.push( offset ); - geometry.computeBoundingSphere(); + geometry.computeBoundingSphere(); - } + } - var material = dependencies.materials[ primitive.material ]; + var material = dependencies.materials[ primitive.material ]; - var meshNode = new THREE.Mesh( geometry, material ); - meshNode.castShadow = true; + var meshNode = new THREE.Mesh( geometry, material ); + meshNode.castShadow = true; - group.add( meshNode ); + group.add( meshNode ); - } else { + } else { + + console.warn( "Non-triangular primitives are not supported" ); - console.warn("Non-triangular primitives are not supported"); + } } - }); + return group; - return group; + } ); - }); + }.bind( this ) ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadCameras = function () { -GLTFParser.prototype.loadCameras = function() { + return _each( this.json.cameras, function ( camera ) { - return _each( this.json.cameras, function( camera, cameraId ) { + if ( camera.type == "perspective" && camera.perspective ) { - if ( camera.type == "perspective" && camera.perspective ) { + var yfov = camera.perspective.yfov; + var xfov = camera.perspective.xfov; + var aspect_ratio = camera.perspective.aspect_ratio || 1; - var yfov = camera.perspective.yfov; - var xfov = camera.perspective.xfov; - var aspect_ratio = camera.perspective.aspect_ratio || 1; + // According to COLLADA spec... + // aspect_ratio = xfov / yfov + xfov = ( xfov === undefined && yfov ) ? yfov * aspect_ratio : xfov; - // According to COLLADA spec... - // aspect_ratio = xfov / yfov - xfov = ( xfov === undefined && yfov ) ? yfov * aspect_ratio : xfov; + // According to COLLADA spec... + // aspect_ratio = xfov / yfov + // yfov = ( yfov === undefined && xfov ) ? xfov / aspect_ratio : yfov; - // According to COLLADA spec... - // aspect_ratio = xfov / yfov - // yfov = ( yfov === undefined && xfov ) ? xfov / aspect_ratio : yfov; + var _camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspect_ratio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6 ); + _camera.name = camera.name; - var _camera = new THREE.PerspectiveCamera( THREE.Math.radToDeg( xfov ), aspect_ratio, camera.perspective.znear || 1, camera.perspective.zfar || 2e6 ); - _camera.name = camera.name; + return _camera; - return _camera; + } else if ( camera.type == "orthographic" && camera.orthographic ) { - } else if ( camera.type == "orthographic" && camera.orthographic ) { + var _camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, camera.orthographic.znear, camera.orthographic.zfar ); + _camera.name = camera.name; - var _camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, camera.orthographic.znear, camera.orthographic.zfar ); - _camera.name = camera.name; + return _camera; - return _camera; + } - } + }.bind( this ) ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadSkins = function () { -GLTFParser.prototype.loadSkins = function() { + var scope = this; - return this._withDependencies([ - "accessors" - ]).then( function( dependencies ) { + return this._withDependencies( [ - return _each( this.json.skins, function( skin, skinId ) { + "accessors" - var _skin = { - bindShapeMatrix: new THREE.Matrix4().fromArray( skin.bindShapeMatrix ), - jointNames: skin.jointNames, - inverseBindMatrices: dependencies.accessors[ skin.inverseBindMatrices ] - }; + ] ).then( function ( dependencies ) { - return _skin; + return _each( scope.json.skins, function ( skin ) { - }); + var _skin = { + bindShapeMatrix: new THREE.Matrix4().fromArray( skin.bindShapeMatrix ), + jointNames: skin.jointNames, + inverseBindMatrices: dependencies.accessors[ skin.inverseBindMatrices ] + }; - }.bind( this )); + return _skin; -}; + } ); -GLTFParser.prototype.loadAnimations = function() { + } ); - return this._withDependencies([ - "accessors", - "nodes" - ]).then( function( dependencies ) { + }; + + GLTFParser.prototype.loadAnimations = function () { - return _each( this.json.animations, function( animation, animationId ) { + var scope = this; - var interps = []; + return this._withDependencies( [ - _each( animation.channels, function( channel ) { + "accessors", + "nodes" - var sampler = animation.samplers[ channel.sampler ]; + ] ).then( function ( dependencies ) { - if (sampler && animation.parameters) { + return _each( scope.json.animations, function ( animation, animationId ) { + + var interps = []; + + for ( var channelId in animation.channels ) { + + var channel = animation.channels[ channelId ]; + var sampler = animation.samplers[ channel.sampler ]; + + if ( sampler && animation.parameters ) { var target = channel.target; var name = target.id; - var input = animation.parameters[sampler.input]; - var output = animation.parameters[sampler.output]; + var input = animation.parameters[ sampler.input ]; + var output = animation.parameters[ sampler.output ]; var inputAccessor = dependencies.accessors[ input ]; var outputAccessor = dependencies.accessors[ output ]; @@ -1445,314 +1470,342 @@ GLTFParser.prototype.loadAnimations = function() { if ( node ) { var interp = { - keys : inputAccessor.array, - values : outputAccessor.array, - count : inputAccessor.count, - target : node, - path : target.path, - type : sampler.interpolation + keys: inputAccessor.array, + values: outputAccessor.array, + count: inputAccessor.count, + target: node, + path: target.path, + type: sampler.interpolation }; interps.push( interp ); } + } + } - }); + var _animation = new GLTFAnimation( interps ); + _animation.name = "animation_" + animationId; - var _animation = new GLTFAnimation(interps); - _animation.name = "animation_" + animationId; + return _animation; - return _animation; + } ); - }); + } ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadNodes = function () { -GLTFParser.prototype.loadNodes = function() { + return _each( this.json.nodes, function ( node ) { - return _each( this.json.nodes, function( node, nodeId ) { + var matrix = new THREE.Matrix4(); - var matrix = new THREE.Matrix4(); + var _node; - var _node; + if ( node.jointName ) { - if ( node.jointName ) { + _node = new THREE.Bone(); + _node.jointName = node.jointName; - _node = new THREE.Bone(); - _node.jointName = node.jointName; + } else { - } else { + _node = new THREE.Object3D(); - _node = new THREE.Object3D() + } - } + _node.name = node.name; - _node.name = node.name; + _node.matrixAutoUpdate = false; - _node.matrixAutoUpdate = false; + if ( node.matrix !== undefined ) { - if ( node.matrix !== undefined ) { + matrix.fromArray( node.matrix ); + _node.applyMatrix( matrix ); - matrix.fromArray( node.matrix ); - _node.applyMatrix( matrix ); + } else { - } else { + if ( node.translation !== undefined ) { - if ( node.translation !== undefined ) { + _node.position.fromArray( node.translation ); - _node.position.fromArray( node.translation ); + } - } + if ( node.rotation !== undefined ) { - if ( node.rotation !== undefined ) { + _node.quaternion.fromArray( node.rotation ); - _node.quaternion.fromArray( node.rotation ); + } - } + if ( node.scale !== undefined ) { - if ( node.scale !== undefined ) { + _node.scale.fromArray( node.scale ); - _node.scale.fromArray( node.scale ); + } } - } + return _node; - return _node; + }.bind( this ) ).then( function ( __nodes ) { - }.bind( this )).then( function( __nodes ) { + return this._withDependencies( [ - return this._withDependencies([ - "meshes", - "skins", - "cameras", - "extensions" - ]).then( function( dependencies ) { + "meshes", + "skins", + "cameras", + "extensions" - return _each( __nodes, function( _node, nodeId ) { + ] ).then( function ( dependencies ) { - var node = this.json.nodes[ nodeId ]; + return _each( __nodes, function ( _node, nodeId ) { - if ( node.meshes !== undefined ) { + var node = this.json.nodes[ nodeId ]; - _each( node.meshes, function( meshId ) { + if ( node.meshes !== undefined ) { - var group = dependencies.meshes[ meshId ]; + for ( var meshId in node.meshes ) { - _each( group.children, function( mesh ) { + var mesh = node.meshes[ meshId ]; + var group = dependencies.meshes[ mesh ]; - // clone Mesh to add to _node + for ( var childrenId in group.children ) { - var originalMaterial = mesh.material; - var originalGeometry = mesh.geometry; + var child = group.children[ childrenId ]; - var material; - if(originalMaterial.isDeferredShaderMaterial) { - originalMaterial = material = originalMaterial.create(); - } else { - material = originalMaterial; - } + // clone Mesh to add to _node - mesh = new THREE.Mesh( originalGeometry, material ); - mesh.castShadow = true; + var originalMaterial = child.material; + var originalGeometry = child.geometry; - var skinEntry; - if ( node.skin ) { + var material; - skinEntry = dependencies.skins[ node.skin ]; + if ( originalMaterial.isDeferredShaderMaterial ) { - } + originalMaterial = material = originalMaterial.create(); + + } else { + + material = originalMaterial; + + } - // Replace Mesh with SkinnedMesh in library - if (skinEntry) { + child = new THREE.Mesh( originalGeometry, material ); + child.castShadow = true; - var geometry = originalGeometry; - var material = originalMaterial; - material.skinning = true; + var skinEntry; - mesh = new THREE.SkinnedMesh( geometry, material, false ); - mesh.castShadow = true; + if ( node.skin ) { - var bones = []; - var boneInverses = []; + skinEntry = dependencies.skins[ node.skin ]; - _each( skinEntry.jointNames, function( jointId, i ) { + } - var jointNode = __nodes[ jointId ]; + // Replace Mesh with SkinnedMesh in library + if ( skinEntry ) { - if ( jointNode ) { + var geometry = originalGeometry; + var material = originalMaterial; + material.skinning = true; - jointNode.skin = mesh; - bones.push(jointNode); + child = new THREE.SkinnedMesh( geometry, material, false ); + child.castShadow = true; - var m = skinEntry.inverseBindMatrices.array; - var mat = new THREE.Matrix4().fromArray( m, i * 16 ); - boneInverses.push(mat); + var bones = []; + var boneInverses = []; + + for ( var i = 0, l = skinEntry.jointNames.length; i < l; i ++ ) { + + var jointId = skinEntry.jointNames[ i ]; + var jointNode = __nodes[ jointId ]; + + if ( jointNode ) { + + jointNode.skin = child; + bones.push( jointNode ); + + var m = skinEntry.inverseBindMatrices.array; + var mat = new THREE.Matrix4().fromArray( m, i * 16 ); + boneInverses.push( mat ); + + } else { + + console.warn( "WARNING: joint: ''" + jointId + "' could not be found" ); + + } - } else { - console.warn( "WARNING: joint: ''" + jointId + "' could not be found" ); } - }); + child.bind( new THREE.Skeleton( bones, boneInverses, false ), skinEntry.bindShapeMatrix ); - mesh.bind( new THREE.Skeleton( bones, boneInverses, false ), skinEntry.bindShapeMatrix ); + } - } + _node.add( child ); - _node.add( mesh ); + } - }); + } - }); + } - } + if ( node.camera !== undefined ) { - if ( node.camera !== undefined ) { + var camera = dependencies.cameras[ node.camera ]; - var camera = dependencies.cameras[ node.camera ]; + _node.add( camera ); - _node.add( camera ); + } - } + if ( node.extensions && node.extensions.KHR_materials_common && node.extensions.KHR_materials_common.light ) { - if (node.extensions && node.extensions.KHR_materials_common - && node.extensions.KHR_materials_common.light) { + var light = dependencies.extensions.KHR_materials_common.lights[ node.extensions.KHR_materials_common.light ]; - var light = dependencies.extensions.KHR_materials_common.lights[ node.extensions.KHR_materials_common.light ]; + _node.add( light ); - _node.add(light); + } - } + return _node; - return _node; + }.bind( this ) ); - }.bind( this )); + }.bind( this ) ); - }.bind( this )); + }.bind( this ) ); - }.bind( this )); + }; -}; + GLTFParser.prototype.loadExtensions = function () { -GLTFParser.prototype.loadExtensions = function() { + return _each( this.json.extensions, function ( extension, extensionId ) { - return _each( this.json.extensions, function( extension, extensionId ) { + switch ( extensionId ) { - switch ( extensionId ) { + case "KHR_materials_common": - case "KHR_materials_common": + var extensionNode = { + lights: {} + }; - var extensionNode = { - lights: {} - }; + var lights = extension.lights; - var lights = extension.lights; + for ( var lightId in lights ) { - _each( lights, function( light, lightID ) { + var light = lights[ lightId ]; + var lightNode; - var lightNode; + var lightParams = light[ light.type ]; + var color = new THREE.Color().fromArray( lightParams.color ); - var lightParams = light[light.type]; - var color = new THREE.Color().fromArray( lightParams.color ); + switch ( light.type ) { - switch ( light.type ) { + case "directional": + lightNode = new THREE.DirectionalLight( color ); + lightNode.position.set( 0, 0, 1 ); + break; - case "directional": - lightNode = new THREE.DirectionalLight( color ); - lightNode.position.set( 0, 0, 1 ); - break; + case "point": + lightNode = new THREE.PointLight( color ); + break; - case "point": - lightNode = new THREE.PointLight( color ); - break; + case "spot ": + lightNode = new THREE.SpotLight( color ); + lightNode.position.set( 0, 0, 1 ); + break; - case "spot ": - lightNode = new THREE.SpotLight( color ); - lightNode.position.set( 0, 0, 1 ); - break; + case "ambient": + lightNode = new THREE.AmbientLight( color ); + break; - case "ambient": - lightNode = new THREE.AmbientLight( color ); - break; + } - } + if ( lightNode ) { - if ( lightNode ) { + extensionNode.lights[ lightId ] = lightNode; - extensionNode.lights[ lightID ] = lightNode; + } } - }); + return extensionNode; - return extensionNode; + break; - break; + } - } + } ); + + }; - }.bind( this )); + GLTFParser.prototype.loadScenes = function () { + + var scope = this; -}; + // scene node hierachy builder -GLTFParser.prototype.loadScenes = function() { + function buildNodeHierachy( nodeId, parentObject, allNodes ) { - // scene node hierachy builder + var _node = allNodes[ nodeId ]; + parentObject.add( _node ); - var buildNodeHierachy = function( nodeId, parentObject, allNodes ) { + var node = scope.json.nodes[ nodeId ]; - var _node = allNodes[ nodeId ]; - parentObject.add( _node ); + if ( node.children ) { - var node = this.json.nodes[ nodeId ]; + var children = node.children; - if ( node.children ) { + for ( var i = 0, l = children.length; i < l; i ++ ) { - _each( node.children, function( child ) { + var child = children[ i ]; + buildNodeHierachy( child, _node, allNodes ); - buildNodeHierachy( child, _node, allNodes ); + } - }); + } } - }.bind( this ); + return this._withDependencies( [ - return this._withDependencies([ - "nodes" - ]).then( function( dependencies ) { + "nodes" - return _each( this.json.scenes, function( scene, sceneId ) { + ] ).then( function ( dependencies ) { - var _scene = new THREE.Scene(); - _scene.name = scene.name; + return _each( scope.json.scenes, function ( scene ) { - _each( scene.nodes, function( nodeId ) { + var _scene = new THREE.Scene(); + _scene.name = scene.name; - buildNodeHierachy( nodeId, _scene, dependencies.nodes ); + var nodes = scene.nodes; - }); + for ( var i = 0, l = nodes.length; i < l; i ++ ) { - _scene.traverse( function( child ) { + var nodeId = nodes[ i ]; + buildNodeHierachy( nodeId, _scene, dependencies.nodes ); - // Register raw material meshes with GLTFLoader.Shaders - if (child.material && child.material.isRawShaderMaterial) { - var xshader = new GLTFShader( child, dependencies.nodes ); - THREE.GLTFLoader.Shaders.add( child.uuid, xshader ); } - }); + _scene.traverse( function ( child ) { - return _scene; + // Register raw material meshes with GLTFLoader.Shaders + if ( child.material && child.material.isRawShaderMaterial ) { - }); + var xshader = new GLTFShader( child, dependencies.nodes ); + GLTFLoader.Shaders.add( child.uuid, xshader ); - }.bind( this )); + } + + } ); + + return _scene; + + } ); + + } ); + + }; -}; + return GLTFLoader; -})(); +} )(); diff --git a/examples/js/loaders/HDRCubeTextureLoader.js b/examples/js/loaders/HDRCubeTextureLoader.js index 7983464e34b08a3b16eeefe00e46e136ff25f0cc..02e1bea690209724c06dcc54c584c9819555ca31 100644 --- a/examples/js/loaders/HDRCubeTextureLoader.js +++ b/examples/js/loaders/HDRCubeTextureLoader.js @@ -9,7 +9,7 @@ THREE.HDRCubeTextureLoader = function (manager) { this.hdrLoader = new THREE.RGBELoader(); if( THREE.Encodings === undefined ) throw new Error( "HDRCubeMapLoader requires THREE.Encodings" ); -} +}; THREE.HDRCubeTextureLoader.prototype.load = function(type, urls, onLoad, onProgress, onError) { var texture = new THREE.CubeTexture(); diff --git a/examples/js/loaders/MD2Loader.js b/examples/js/loaders/MD2Loader.js index 0f0b19f946d9ed947ddfb1cdd4a5a85720d8a6cf..b6702bd6c2f8bd9c2a0b1e54b3cb6afba6515dfd 100644 --- a/examples/js/loaders/MD2Loader.js +++ b/examples/js/loaders/MD2Loader.js @@ -308,4 +308,4 @@ THREE.MD2Loader.prototype = { } )() -} +}; diff --git a/examples/js/loaders/MMDLoader.js b/examples/js/loaders/MMDLoader.js index c04d85b9a622457ecc8106c851dade61e954239a..12c741e78e951e56063dc7107727ec03f237b19a 100644 --- a/examples/js/loaders/MMDLoader.js +++ b/examples/js/loaders/MMDLoader.js @@ -42,6 +42,7 @@ THREE.MMDLoader = function ( manager ) { THREE.Loader.call( this ); this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; this.parser = new MMDParser.Parser(); + this.textureCrossOrigin = null; }; @@ -68,6 +69,17 @@ THREE.MMDLoader.prototype.defaultToonTextures = [ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAL0lEQVRYR+3QQREAAAzCsOFfNJPBJ1XQS9r2hsUAAQIECBAgQIAAAQIECBAgsBZ4MUx/ofm2I/kAAAAASUVORK5CYII=' ]; +/* + * Set 'anonymous' for the the texture image file in other domain + * even if server responds with "Access-Control-Allow-Origin: *" + * because some image operation fails in MMDLoader. + */ +THREE.MMDLoader.prototype.setTextureCrossOrigin = function ( value ) { + + this.textureCrossOrigin = value; + +}; + THREE.MMDLoader.prototype.load = function ( modelUrl, vmdUrls, callback, onProgress, onError ) { var scope = this; @@ -94,15 +106,15 @@ THREE.MMDLoader.prototype.loadModel = function ( url, callback, onProgress, onEr this.loadFileAsBuffer( url, function ( buffer ) { - callback( scope.createModel( buffer, modelExtension, texturePath ) ); + callback( scope.createModel( buffer, modelExtension, texturePath, onProgress, onError ) ); }, onProgress, onError ); }; -THREE.MMDLoader.prototype.createModel = function ( buffer, modelExtension, texturePath ) { +THREE.MMDLoader.prototype.createModel = function ( buffer, modelExtension, texturePath, onProgress, onError ) { - return this.createMesh( this.parseModel( buffer, modelExtension ), texturePath ); + return this.createMesh( this.parseModel( buffer, modelExtension ), texturePath, onProgress, onError ); }; @@ -123,6 +135,7 @@ THREE.MMDLoader.prototype.loadVmds = function ( urls, callback, onProgress, onEr var scope = this; var vmds = []; + urls = urls.slice(); function run () { @@ -144,7 +157,7 @@ THREE.MMDLoader.prototype.loadVmds = function ( urls, callback, onProgress, onEr }, onProgress, onError ); - }; + } run(); @@ -474,7 +487,7 @@ THREE.MMDLoader.prototype.loadFileAsText = function ( url, onLoad, onProgress, o THREE.MMDLoader.prototype.loadFileAsShiftJISText = function ( url, onLoad, onProgress, onError ) { - var request = this.loadFile( url, onLoad, onProgress, onError, 'text', 'text/plain; charset=shift_jis' ); + this.loadFile( url, onLoad, onProgress, onError, 'text', 'text/plain; charset=shift_jis' ); }; @@ -738,7 +751,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress attribute.array[ index * 3 + 1 ] += v.position[ 1 ] * ratio; attribute.array[ index * 3 + 2 ] += v.position[ 2 ] * ratio; - }; + } function updateVertices( attribute, m, ratio ) { @@ -762,7 +775,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } - }; + } var morphTargets = []; var attributes = []; @@ -857,12 +870,16 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress var initMaterials = function () { - var textures = []; - var textureLoader = new THREE.TextureLoader( this.manager ); - var tgaLoader = new THREE.TGALoader( this.manager ); + var textures = {}; + var textureLoader = new THREE.TextureLoader( scope.manager ); + var tgaLoader = new THREE.TGALoader( scope.manager ); + var canvas = document.createElement( 'canvas' ); + var context = canvas.getContext( '2d' ); var offset = 0; var materialParams = []; + if ( scope.textureCrossOrigin !== null ) textureLoader.setCrossOrigin( scope.textureCrossOrigin ); + function loadTexture ( filePath, params ) { if ( params === undefined ) { @@ -881,7 +898,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } catch ( e ) { - console.warn( 'THREE.MMDLoader: ' + filePath + ' seems like not right default texture path. Using toon00.bmp instead.' ) + console.warn( 'THREE.MMDLoader: ' + filePath + ' seems like not right default texture path. Using toon00.bmp instead.' ); fullPath = scope.defaultToonTextures[ 0 ]; } @@ -892,6 +909,8 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } + if ( textures[ fullPath ] !== undefined ) return fullPath; + var loader = THREE.Loader.Handlers.get( fullPath ); if ( loader === null ) { @@ -902,6 +921,28 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress var texture = loader.load( fullPath, function ( t ) { + // MMD toon texture is Axis-Y oriented + // but Three.js gradient map is Axis-X oriented. + // So here replaces the toon texture image with the rotated one. + if ( params.isToonTexture === true ) { + + var image = t.image; + var width = image.width; + var height = image.height; + + canvas.width = width; + canvas.height = height; + + context.clearRect( 0, 0, width, height ); + context.translate( width / 2.0, height / 2.0 ); + context.rotate( 0.5 * Math.PI ); // 90.0 * Math.PI / 180.0 + context.translate( -width / 2.0, -height / 2.0 ); + context.drawImage( image, 0, 0 ); + + t.image = context.getImageData( 0, 0, width, height ); + + } + t.flipY = false; t.wrapS = THREE.RepeatWrapping; t.wrapT = THREE.RepeatWrapping; @@ -920,17 +961,15 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress delete texture.readyCallbacks; - } ); + }, onProgress, onError ); texture.readyCallbacks = []; - var uuid = THREE.Math.generateUUID(); - - textures[ uuid ] = texture; + textures[ fullPath ] = texture; - return uuid; + return fullPath; - }; + } function getTexture( name, textures ) { @@ -942,7 +981,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress return textures[ name ]; - }; + } for ( var i = 0; i < model.metadata.materialCount; i++ ) { @@ -959,13 +998,13 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress /* * Color * - * MMD MeshPhongMaterial + * MMD MeshToonMaterial * diffuse - color * specular - specular * ambient - emissive * a * (a = 1.0 without map texture or 0.2 with map texture) * - * MeshPhongMaterial doesn't have ambient. Set it to emissive instead. + * MeshToonMaterial doesn't have ambient. Set it to emissive instead. * It'll be too bright if material has map texture so using coef 0.2. */ params.color = new THREE.Color( m.diffuse[ 0 ], m.diffuse[ 1 ], m.diffuse[ 2 ] ); @@ -1069,17 +1108,11 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } - var shader = THREE.ShaderLib[ 'mmd' ]; - for ( var i = 0; i < materialParams.length; i++ ) { var p = materialParams[ i ]; var p2 = model.materials[ i ]; - var m = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), - vertexShader: shader.vertexShader, - fragmentShader: shader.fragmentShader - } ); + var m = new THREE.MeshToonMaterial(); geometry.addGroup( p.faceOffset * 3, p.faceNum * 3, i ); @@ -1120,7 +1153,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress return ctx.getImageData( 0, 0, c.width, c.height ); - }; + } function detectTextureTransparency( image, uvs, indices ) { @@ -1168,7 +1201,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress return false; - }; + } /* * This method expects @@ -1201,7 +1234,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress return image.data[ index * 4 + 3 ]; - }; + } var imageData = t.image.data !== undefined ? t.image : createImageData( t.image ); var indices = geometry.index.array.slice( m.faceOffset * 3, m.faceOffset * 3 + m.faceNum * 3 ); @@ -1216,7 +1249,6 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } m.map = getTexture( p.map, textures ); - m.uniforms.map.value = m.map; checkTextureTransparency( m ); } @@ -1224,7 +1256,6 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress if ( p.envMap !== undefined ) { m.envMap = getTexture( p.envMap, textures ); - m.uniforms.envMap.value = m.envMap; m.combine = p.envMapType; // TODO: WebGLRenderer should automatically update? @@ -1236,17 +1267,17 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress } - m.uniforms.opacity.value = p.opacity; - m.uniforms.diffuse.value.copy( p.color ); + m.opacity = p.opacity; + m.color = p.color; if ( p.emissive !== undefined ) { - m.uniforms.emissive.value.copy( p.emissive ); + m.emissive = p.emissive; } - m.uniforms.specular.value.copy( p.specular ); - m.uniforms.shininess.value = Math.max( p.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 ) + m.specular = p.specular; + m.shininess = Math.max( p.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 ) if ( model.metadata.format === 'pmd' ) { @@ -1260,8 +1291,9 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress return n.match( /toon(10|0[0-9]).bmp/ ) === null ? false : true; - }; + } + // parameters for OutlineEffect m.outlineParameters = { thickness: p2.edgeFlag === 1 ? 0.003 : 0.0, color: new THREE.Color( 0.0, 0.0, 0.0 ), @@ -1270,24 +1302,13 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress if ( m.outlineParameters.thickness === 0.0 ) m.outlineParameters.visible = false; - m.uniforms.toonMap.value = textures[ p2.toonIndex ]; - m.uniforms.celShading.value = 1; - - if ( p2.toonIndex === -1 ) { - - m.uniforms.hasToonTexture.value = 0; - - } else { - - var n = model.toonTextures[ p2.toonIndex ].fileName; - var uuid = loadTexture( n, { defaultTexturePath: isDefaultToonTexture( n ) } ); - m.uniforms.toonMap.value = textures[ uuid ]; - m.uniforms.hasToonTexture.value = 1; - - } + var toonFileName = ( p2.toonIndex === -1 ) ? 'toon00.bmp' : model.toonTextures[ p2.toonIndex ].fileName; + var uuid = loadTexture( toonFileName, { isToonTexture: true, defaultTexturePath: isDefaultToonTexture( toonFileName ) } ); + m.gradientMap = getTexture( uuid, textures ); } else { + // parameters for OutlineEffect m.outlineParameters = { thickness: p2.edgeSize / 300, color: new THREE.Color( p2.edgeColor[ 0 ], p2.edgeColor[ 1 ], p2.edgeColor[ 2 ] ), @@ -1296,33 +1317,24 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress if ( ( p2.flag & 0x10 ) === 0 || m.outlineParameters.thickness === 0.0 ) m.outlineParameters.visible = false; - m.uniforms.celShading.value = 1; + var toonFileName, isDefaultToon; - if ( p2.toonIndex === -1 ) { + if ( p2.toonIndex === -1 || p2.toonFlag !== 0 ) { - m.uniforms.hasToonTexture.value = 0; + var num = p2.toonIndex + 1; + toonFileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp'; + isDefaultToon = true; } else { - if ( p2.toonFlag === 0 ) { - - var n = model.textures[ p2.toonIndex ]; - var uuid = loadTexture( n ); - m.uniforms.toonMap.value = textures[ uuid ]; - - } else { - - var num = p2.toonIndex + 1; - var fileName = 'toon' + ( num < 10 ? '0' + num : num ) + '.bmp'; - var uuid = loadTexture( fileName, { defaultTexturePath: true } ); - m.uniforms.toonMap.value = textures[ uuid ]; - - } - - m.uniforms.hasToonTexture.value = 1; + toonFileName = model.textures[ p2.toonIndex ]; + isDefaultToon = false; } + var uuid = loadTexture( toonFileName, { isToonTexture: true, defaultTexturePath: isDefaultToon } ); + m.gradientMap = getTexture( uuid, textures ); + } material.materials.push( m ); @@ -1351,7 +1363,7 @@ THREE.MMDLoader.prototype.createMesh = function ( model, texturePath, onProgress var m = material.materials[ e.index ]; - if ( m.uniforms.opacity.value !== e.diffuse[ 3 ] ) { + if ( m.opacity !== e.diffuse[ 3 ] ) { m.transparent = true; @@ -1977,74 +1989,6 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype._calculate = function( x1, x2 }; -/* - * Shaders are copied from MeshPhongMaterial and then MMD spcific codes are inserted. - * Keep shaders updated on MeshPhongMaterial. - */ -THREE.ShaderLib[ 'mmd' ] = { - - uniforms: THREE.UniformsUtils.merge( [ - - THREE.ShaderLib[ 'phong' ].uniforms, - - // MMD specific for toon mapping - { - "celShading" : { type: "i", value: 0 }, - "toonMap" : { type: "t", value: null }, - "hasToonTexture" : { type: "i", value: 0 } - } - - ] ), - - vertexShader: THREE.ShaderLib[ 'phong' ].vertexShader, - - // put toon mapping logic right before "void main() {...}" - fragmentShader: THREE.ShaderLib[ 'phong' ].fragmentShader.replace( /void\s+main\s*\(\s*\)/, [ - - " uniform bool celShading;", - " uniform sampler2D toonMap;", - " uniform bool hasToonTexture;", - - " vec3 toon ( vec3 lightDirection, vec3 norm ) {", - " if ( ! hasToonTexture ) {", - " return vec3( 1.0 );", - " }", - " vec2 coord = vec2( 0.0, 0.5 * ( 1.0 - dot( lightDirection, norm ) ) );", - " return texture2D( toonMap, coord ).rgb;", - " }", - - // redefine for MMD - "#undef RE_Direct", - "void RE_Direct_BlinnMMD( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {", - " float dotNL = saturate( dot( geometry.normal, directLight.direction ) );", - " vec3 irradiance = dotNL * directLight.color;", - - " #ifndef PHYSICALLY_CORRECT_LIGHTS", - - " irradiance *= PI; // punctual light", - - " #endif", - - // ---- MMD specific for toon mapping - " if ( celShading ) {", - " reflectedLight.directDiffuse += material.diffuseColor * directLight.color * toon( directLight.direction, geometry.normal );", - " } else {", - " reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );", - " }", - // ---- MMD specific for toon mapping - - " reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;", - "}", - // ---- MMD specific for toon mapping - "#define RE_Direct RE_Direct_BlinnMMD", - // ---- MMD specific for toon mapping - - "void main()", - - ].join( "\n" ) ) - -}; - THREE.MMDAudioManager = function ( audio, listener, p ) { var params = ( p === null || p === undefined ) ? {} : p; @@ -2056,7 +2000,7 @@ THREE.MMDAudioManager = function ( audio, listener, p ) { this.currentTime = 0.0; this.delayTime = params.delayTime !== undefined ? params.delayTime : 0.0; - this.audioDuration = this.audio.source.buffer.duration; + this.audioDuration = this.audio.buffer.duration; this.duration = this.audioDuration + this.delayTime; }; @@ -2189,15 +2133,7 @@ THREE.MMDGrantSolver.prototype = { }; -THREE.MMDHelper = function ( renderer ) { - - this.renderer = renderer; - - this.outlineEffect = null; - - this.effect = null; - - this.autoClear = true; +THREE.MMDHelper = function () { this.meshes = []; @@ -2205,29 +2141,20 @@ THREE.MMDHelper = function ( renderer ) { this.doIk = true; this.doGrant = true; this.doPhysics = true; - this.doOutlineDrawing = true; this.doCameraAnimation = true; + this.sharedPhysics = false; + this.masterPhysics = null; + this.audioManager = null; this.camera = null; - this.init(); - }; THREE.MMDHelper.prototype = { constructor: THREE.MMDHelper, - init: function () { - - this.outlineEffect = new THREE.OutlineEffect( this.renderer ); - - var size = this.renderer.getSize(); - this.setSize( size.width, size.height ); - - }, - add: function ( mesh ) { if ( ! ( mesh instanceof THREE.SkinnedMesh ) ) { @@ -2249,23 +2176,6 @@ THREE.MMDHelper.prototype = { }, - setSize: function ( width, height ) { - - this.outlineEffect.setSize( width, height ); - - }, - - /* - * Note: There may be a possibility that Outline wouldn't work well with Effect. - * In such a case, try to set doOutlineDrawing = false or - * manually comment out renderer.clear() in *Effect.render(). - */ - setEffect: function ( effect ) { - - this.effect = effect; - - }, - setAudio: function ( audio, listener, params ) { this.audioManager = new THREE.MMDAudioManager( audio, listener, params ); @@ -2291,13 +2201,21 @@ THREE.MMDHelper.prototype = { setPhysics: function ( mesh, params ) { - if ( params === undefined ) params = {}; + params = ( params === undefined ) ? {} : Object.assign( {}, params ); + + if ( params.world === undefined && this.sharedPhysics ) { + + var masterPhysics = this.getMasterPhysics(); + + if ( masterPhysics !== null ) params.world = masterPhysics.world; + + } var warmup = params.warmup !== undefined ? params.warmup : 60; var physics = new THREE.MMDPhysics( mesh, params ); - if ( mesh.mixer !== null && mesh.mixer !== undefined && this.doAnimation === true && params.preventAnimationWarmup !== false ) { + if ( mesh.mixer !== null && mesh.mixer !== undefined && params.preventAnimationWarmup !== false ) { this.animateOneMesh( 0, mesh ); physics.reset(); @@ -2312,6 +2230,26 @@ THREE.MMDHelper.prototype = { }, + getMasterPhysics: function () { + + if ( this.masterPhysics !== null ) return this.masterPhysics; + + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { + + var physics = this.meshes[ i ].physics; + + if ( physics !== undefined && physics !== null ) { + + this.masterPhysics = physics; + return this.masterPhysics; + + } + } + + return null; + + }, + enablePhysics: function ( enabled ) { if ( enabled === true ) { @@ -2574,6 +2512,8 @@ THREE.MMDHelper.prototype = { } + if ( this.sharedPhysics ) this.updateSharedPhysics( delta ); + this.animateCamera( delta ); }, @@ -2617,7 +2557,7 @@ THREE.MMDHelper.prototype = { } - if ( physics !== null && this.doPhysics === true ) { + if ( physics !== null && this.doPhysics && ! this.sharedPhysics) { physics.update( delta ); @@ -2625,170 +2565,72 @@ THREE.MMDHelper.prototype = { }, - animateCamera: function ( delta ) { - - if ( this.camera === null ) { - - return; - - } - - var mixer = this.camera.mixer; - - if ( mixer !== null && this.camera.center !== undefined && this.doCameraAnimation === true ) { - - mixer.update( delta ); - - // TODO: Let PerspectiveCamera automatically update? - this.camera.updateProjectionMatrix(); - - this.camera.up.set( 0, 1, 0 ); - this.camera.up.applyQuaternion( this.camera.quaternion ); - this.camera.lookAt( this.camera.center ); + updateSharedPhysics: function ( delta ) { - } - - }, + if ( this.meshes.length === 0 || ! this.doPhysics || ! this.sharedPhysics ) return; - render: function ( scene, camera ) { + var physics = this.getMasterPhysics(); - if ( this.effect === null ) { + if ( physics === null ) return; - if ( this.doOutlineDrawing ) { + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { - this.outlineEffect.autoClear = this.autoClear; - this.outlineEffect.render( scene, camera ); + var p = this.meshes[ i ].physics; - } else { + if ( p !== null && p !== undefined ) { - var currentAutoClear = this.renderer.autoClear; - this.renderer.autoClear = this.autoClear; - this.renderer.render( scene, camera ); - this.renderer.autoClear = currentAutoClear; + p.updateRigidBodies(); } - } else { + } - var currentAutoClear = this.renderer.autoClear; - this.renderer.autoClear = this.autoClear; + physics.stepSimulation( delta ); - if ( this.doOutlineDrawing ) { + for ( var i = 0, il = this.meshes.length; i < il; i ++ ) { - this.renderWithEffectAndOutline( scene, camera ); + var p = this.meshes[ i ].physics; - } else { + if ( p !== null && p !== undefined ) { - this.effect.render( scene, camera ); + p.updateBones(); } - this.renderer.autoClear = currentAutoClear; - } }, - /* - * Currently(r82 dev) there's no way to render with two Effects - * then attempt to get them to coordinately run by myself. - * - * What this method does - * 1. let OutlineEffect make outline materials (only once) - * 2. render normally with effect - * 3. set outline materials - * 4. render outline with effect - * 5. restore original materials - */ - renderWithEffectAndOutline: function ( scene, camera ) { - - var hasOutlineMaterial = false; - - function checkIfObjectHasOutlineMaterial ( object ) { - - if ( object.material === undefined ) return; - - if ( object.userData.outlineMaterial !== undefined ) hasOutlineMaterial = true; - - } - - function setOutlineMaterial ( object ) { - - if ( object.material === undefined ) return; - - if ( object.userData.outlineMaterial === undefined ) return; - - object.userData.originalMaterial = object.material; - - object.material = object.userData.outlineMaterial; - - } - - function restoreOriginalMaterial ( object ) { - - if ( object.material === undefined ) return; + animateCamera: function ( delta ) { - if ( object.userData.originalMaterial === undefined ) return; + if ( this.camera === null ) { - object.material = object.userData.originalMaterial; + return; } - return function renderWithEffectAndOutline( scene, camera ) { - - hasOutlineMaterial = false; - - var forceClear = false; - - scene.traverse( checkIfObjectHasOutlineMaterial ); - - if ( ! hasOutlineMaterial ) { - - this.outlineEffect.render( scene, camera ); - - forceClear = true; - - scene.traverse( checkIfObjectHasOutlineMaterial ); - - } - - if ( hasOutlineMaterial ) { - - this.renderer.autoClear = this.autoClear || forceClear; - - this.effect.render( scene, camera ); - - scene.traverse( setOutlineMaterial ); - - var currentShadowMapEnabled = this.renderer.shadowMap.enabled; - - this.renderer.autoClear = false; - this.renderer.shadowMap.enabled = false; - - this.effect.render( scene, camera ); - - this.renderer.shadowMap.enabled = currentShadowMapEnabled; + var mixer = this.camera.mixer; - scene.traverse( restoreOriginalMaterial ); + if ( mixer !== null && this.camera.center !== undefined && this.doCameraAnimation === true ) { - } else { + mixer.update( delta ); - this.outlineEffect.autoClear = this.autoClear || forceClear; - this.outlineEffect.render( scene, camera ); + // TODO: Let PerspectiveCamera automatically update? + this.camera.updateProjectionMatrix(); - } + this.camera.up.set( 0, 1, 0 ); + this.camera.up.applyQuaternion( this.camera.quaternion ); + this.camera.lookAt( this.camera.center ); } - }(), + }, poseAsVpd: function ( mesh, vpd, params ) { - if ( ! ( params && params.preventResetPose === true ) ) { + if ( params === undefined ) params = {}; - mesh.pose(); - - } + if ( params.preventResetPose !== true ) mesh.pose(); var bones = mesh.skeleton.bones; var bones2 = vpd.bones; @@ -2797,8 +2639,7 @@ THREE.MMDHelper.prototype = { for ( var i = 0; i < bones.length; i++ ) { - var b = bones[ i ]; - table[ b.name ] = i; + table[ bones[ i ].name ] = i; } @@ -2810,11 +2651,7 @@ THREE.MMDHelper.prototype = { var b = bones2[ i ]; var index = table[ b.name ]; - if ( index === undefined ) { - - continue; - - } + if ( index === undefined ) continue; var b2 = bones[ index ]; var t = b.translation; @@ -2826,25 +2663,21 @@ THREE.MMDHelper.prototype = { b2.position.add( thV ); b2.quaternion.multiply( thQ ); - b2.updateMatrixWorld( true ); - } - if ( params === undefined || params.preventIk !== true ) { + mesh.updateMatrixWorld( true ); + + if ( params.preventIk !== true ) { var solver = new THREE.CCDIKSolver( mesh ); - solver.update(); + solver.update( params.saveOriginalBonesBeforeIK ); } - if ( params === undefined || params.preventGrant !== true ) { - - if ( mesh.geometry.grants !== undefined ) { + if ( params.preventGrant !== true && mesh.geometry.grants !== undefined ) { - var solver = new THREE.MMDGrantSolver( mesh ); - solver.update(); - - } + var solver = new THREE.MMDGrantSolver( mesh ); + solver.update(); } diff --git a/examples/js/loaders/MTLLoader.js b/examples/js/loaders/MTLLoader.js index 0d93ce175a178c89529e90e7e103eb81c59b45a9..a02cfe214d0219ffef1992ea3a58d7d4a3fc40a5 100644 --- a/examples/js/loaders/MTLLoader.js +++ b/examples/js/loaders/MTLLoader.js @@ -473,7 +473,7 @@ THREE.MTLLoader.MaterialCreator.prototype = { var texParams = { scale: new THREE.Vector2( 1, 1 ), - offset: new THREE.Vector2( 0, 0 ), + offset: new THREE.Vector2( 0, 0 ) }; diff --git a/examples/js/loaders/PCDLoader.js b/examples/js/loaders/PCDLoader.js index 86f2a39872a4dfaf5338d0e91baa99bb0707c123..5e3802185bec35031a93a5d9d94abcfe368e692d 100644 --- a/examples/js/loaders/PCDLoader.js +++ b/examples/js/loaders/PCDLoader.js @@ -100,7 +100,7 @@ Object.assign( THREE.PCDLoader.prototype, THREE.EventDispatcher.prototype, { } - PCDheader.offset = {} + PCDheader.offset = {}; var sizeSum = 0; for ( var i = 0; i < PCDheader.fields.length; i ++ ) { diff --git a/examples/js/loaders/PDBLoader.js b/examples/js/loaders/PDBLoader.js index 75a6734a8d4ef132d6c4efb102928ee9abc5e3e9..1766a2dbac4be6d041f216901321e5f5d00a685c 100644 --- a/examples/js/loaders/PDBLoader.js +++ b/examples/js/loaders/PDBLoader.js @@ -1,5 +1,6 @@ /** * @author alteredq / http://alteredqualia.com/ + * @author Mugen87 / https://github.com/Mugen87 */ THREE.PDBLoader = function ( manager ) { @@ -56,7 +57,7 @@ THREE.PDBLoader.prototype = { var h = hash( satom, eatom ); - if ( bhash[ h ] == undefined ) { + if ( bhash[ h ] === undefined ) { bonds.push( [ satom - 1, eatom - 1, 1 ] ); bhash[ h ] = bonds.length - 1; @@ -88,7 +89,7 @@ THREE.PDBLoader.prototype = { var x, y, z, e; - for ( var i = 0, il = lines.length; i < il; ++ i ) { + for ( var i = 0, l = lines.length; i < l; ++ i ) { if ( lines[ i ].substr( 0, 4 ) == "ATOM" || lines[ i ].substr( 0, 6 ) == "HETATM" ) { @@ -98,10 +99,10 @@ THREE.PDBLoader.prototype = { e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase(); - if ( e == "" ) e = trim( lines[ i ].substr( 12, 2 ) ).toLowerCase(); + if ( e === "" ) e = trim( lines[ i ].substr( 12, 2 ) ).toLowerCase(); atoms.push( [ x, y, z, CPK[ e ], capitalize( e ) ] ); - if ( histogram[ e ] == undefined ) histogram[ e ] = 1; + if ( histogram[ e ] === undefined ) histogram[ e ] = 1; else histogram[ e ] += 1; } else if ( lines[ i ].substr( 0, 6 ) == "CONECT" ) { @@ -123,16 +124,21 @@ THREE.PDBLoader.prototype = { createModel: function ( json, callback ) { - var scope = this, - geometryAtoms = new THREE.Geometry(), - geometryBonds = new THREE.Geometry(); + var geometryAtoms = new THREE.BufferGeometry(); + var geometryBonds = new THREE.BufferGeometry(); + + var i, l; + + var verticesAtoms = []; + var colors = []; + var verticesBonds = []; geometryAtoms.elements = []; var atoms = json.atoms; var bonds = json.bonds; - for ( var i = 0; i < atoms.length; i ++ ) { + for ( i = 0, l = atoms.length; i < l; i ++ ) { var atom = atoms[ i ]; @@ -140,40 +146,42 @@ THREE.PDBLoader.prototype = { var y = atom[ 1 ]; var z = atom[ 2 ]; - var position = new THREE.Vector3( x, y, z ); - geometryAtoms.vertices.push( position ); + verticesAtoms.push( x, y, z ); var r = atom[ 3 ][ 0 ] / 255; var g = atom[ 3 ][ 1 ] / 255; var b = atom[ 3 ][ 2 ] / 255; - var color = new THREE.Color(); - color.setRGB( r, g, b ); - - geometryAtoms.colors.push( color ); + colors.push( r, g, b ); geometryAtoms.elements.push( atom[ 4 ] ); } - for ( var i = 0; i < bonds.length; i ++ ) { + for ( i = 0, l = bonds.length; i < l; i ++ ) { var bond = bonds[ i ]; var start = bond[ 0 ]; var end = bond[ 1 ]; - var vertex1 = geometryAtoms.vertices[ start ]; - var vertex2 = geometryAtoms.vertices[ end ]; + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 0 ] ); + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 1 ] ); + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 2 ] ); - geometryBonds.vertices.push( vertex1.clone() ); - geometryBonds.vertices.push( vertex2.clone() ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 0 ] ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 1 ] ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 2 ] ); } + geometryAtoms.addAttribute( 'position', new THREE.Float32BufferAttribute( verticesAtoms, 3 ) ); + geometryAtoms.addAttribute( 'color', new THREE.Float32BufferAttribute( colors, 3 ) ); + + geometryBonds.addAttribute( 'position', new THREE.Float32BufferAttribute( verticesBonds, 3 ) ); + callback( geometryAtoms, geometryBonds, json ); } }; - diff --git a/examples/js/loaders/VRMLLoader.js b/examples/js/loaders/VRMLLoader.js index 5282aa0dc09fbee74bf380256a45a7df10e2ceef..a8fd83548fa85a6c6a6bb7610b8b195c5f9ee8a9 100644 --- a/examples/js/loaders/VRMLLoader.js +++ b/examples/js/loaders/VRMLLoader.js @@ -415,7 +415,9 @@ THREE.VRMLLoader.prototype = { }; break; - + ++ case 'location': ++ case 'direction': case 'translation': case 'scale': case 'size': @@ -434,6 +436,8 @@ THREE.VRMLLoader.prototype = { break; + case 'intensity': + case 'cutOffAngle': case 'radius': case 'topRadius': case 'bottomRadius': @@ -468,7 +472,8 @@ THREE.VRMLLoader.prototype = { }; break; - + + case 'on': case 'ccw': case 'solid': case 'colorPerVertex': @@ -623,6 +628,85 @@ THREE.VRMLLoader.prototype = { var object = parent; + if(data.string.indexOf("AmbientLight")>-1 && data.nodeType=='PointLight'){ + //wenn im Namen "AmbientLight" vorkommt und es ein PointLight ist, + //diesen Typ in 'AmbientLight' ändern + data.nodeType='AmbientLight'; + } + + l_visible=data.on; + if(l_visible==undefined)l_visible=true; + l_intensity=data.intensity; + if(l_intensity==undefined)l_intensity=true; + if(data.color!=undefined) + l_color= new THREE.Color(data.color.r, data.color.g,data.color.b ); + else + l_color= new THREE.Color(0, 0,0); + + + + if('AmbientLight' === data.nodeType){ + object=new THREE.AmbientLight( + l_color.getHex(), + l_intensity + ); + object.visible=l_visible; + + parent.add( object ); + + } + else + if('PointLight' === data.nodeType){ + l_distance =0; //0="unendlich" ...1000 + l_decay=0; //-1.. ? + + if(data.radius!=undefined && data.radius<1000){ + //l_radius=data.radius; + l_distance=data.radius; + l_decay=1; + } + object=new THREE.PointLight( + l_color.getHex(), + l_intensity, + l_distance); + object.visible=l_visible; + + parent.add( object ); + } + else + if('SpotLight' === data.nodeType){ + l_intensity=1; + l_distance =0;//0="unendlich"=1000 + l_angle=Math.PI/3; + l_penumbra=0.0;//0..1 + l_decay=0;//-1.. ? + l_visible=true; + + if(data.radius!=undefined && data.radius<1000){ + //l_radius=data.radius; + l_distance=data.radius; + l_decay=1; + } + if(data.cutOffAngle!=undefined)l_angle=data.cutOffAngle; + + object = new THREE.SpotLight( + l_color.getHex(), + l_intensity, + l_distance, + l_angle, + l_penumbra, + l_decay + ); + object.visible=l_visible; + parent.add( object ); + /* + var lightHelper = new THREE.SpotLightHelper( object ); + parent.parent.add( lightHelper ); + lightHelper.update(); + */ + } + else + if ( 'Transform' === data.nodeType || 'Group' === data.nodeType ) { object = new THREE.Object3D(); diff --git a/examples/js/loaders/ctm/CTMLoader.js b/examples/js/loaders/ctm/CTMLoader.js old mode 100755 new mode 100644 diff --git a/examples/js/loaders/ctm/ctm.js b/examples/js/loaders/ctm/ctm.js old mode 100755 new mode 100644 diff --git a/examples/js/loaders/deprecated/gltf/glTF-parser.js b/examples/js/loaders/deprecated/gltf/glTF-parser.js deleted file mode 100755 index 0a0ac30482fa860073615ba0f87efc7aa7c76ec1..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/glTF-parser.js +++ /dev/null @@ -1,398 +0,0 @@ -// Copyright (c) 2013 Fabrice Robinet -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -/* - The Abstract Loader has two modes: - #1: [static] load all the JSON at once [as of now] - #2: [stream] stream and parse JSON progressively [not yet supported] - - Whatever is the mechanism used to parse the JSON (#1 or #2), - The loader starts by resolving the paths to binaries and referenced json files (by replace the value of the path property with an absolute path if it was relative). - - In case #1: it is guaranteed to call the concrete loader implementation methods in a order that solves the dependencies between the entries. - only the nodes requires an extra pass to set up the hirerarchy. - In case #2: the concrete implementation will have to solve the dependencies. no order is guaranteed. - - When case #1 is used the followed dependency order is: - - scenes -> nodes -> meshes -> materials -> techniques -> shaders - -> buffers - -> cameras - -> lights - - The readers starts with the leafs, i.e: - shaders, techniques, materials, meshes, buffers, cameras, lights, nodes, scenes - - For each called handle method called the client should return true if the next handle can be call right after returning, - or false if a callback on client side will notify the loader that the next handle method can be called. - -*/ -var global = window; -(function (root, factory) { - if (typeof exports === 'object') { - // Node. Does not work with strict CommonJS, but - // only CommonJS-like enviroments that support module.exports, - // like Node. - factory(module.exports); - } else if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define([], function () { - return factory(root); - }); - } else { - // Browser globals - factory(root); - } -}(this, function (root) { - "use strict"; - - var categoriesDepsOrder = ["extensions", "buffers", "bufferViews", "images", "videos", "samplers", "textures", "shaders", "programs", "techniques", "materials", "accessors", "meshes", "cameras", "lights", "skins", "nodes", "animations", "scenes"]; - - var glTFParser = Object.create(Object.prototype, { - - _rootDescription: { value: null, writable: true }, - - rootDescription: { - set: function(value) { - this._rootDescription = value; - }, - get: function() { - return this._rootDescription; - } - }, - - baseURL: { value: null, writable: true }, - - //detect absolute path following the same protocol than window.location - _isAbsolutePath: { - value: function(path) { - var isAbsolutePathRegExp = new RegExp("^"+window.location.protocol, "i"); - - return path.match(isAbsolutePathRegExp) ? true : false; - } - }, - - resolvePathIfNeeded: { - value: function(path) { - if (this._isAbsolutePath(path)) { - return path; - } - - var isDataUriRegex = /^data:/; - if (isDataUriRegex.test(path)) { - return path; - } - - return this.baseURL + path; - } - }, - - _resolvePathsForCategories: { - value: function(categories) { - categories.forEach( function(category) { - var descriptions = this.json[category]; - if (descriptions) { - var descriptionKeys = Object.keys(descriptions); - descriptionKeys.forEach( function(descriptionKey) { - var description = descriptions[descriptionKey]; - description.uri = this.resolvePathIfNeeded(description.uri); - }, this); - } - }, this); - } - }, - - _json: { - value: null, - writable: true - }, - - json: { - enumerable: true, - get: function() { - return this._json; - }, - set: function(value) { - if (this._json !== value) { - this._json = value; - this._resolvePathsForCategories(["buffers", "shaders", "images", "videos"]); - } - } - }, - - _path: { - value: null, - writable: true - }, - - getEntryDescription: { - value: function (entryID, entryType) { - var entries = null; - - var category = entryType; - entries = this.rootDescription[category]; - if (!entries) { - console.log("ERROR:CANNOT find expected category named:"+category); - return null; - } - - return entries ? entries[entryID] : null; - } - }, - - _stepToNextCategory: { - value: function() { - this._state.categoryIndex = this.getNextCategoryIndex(this._state.categoryIndex + 1); - if (this._state.categoryIndex !== -1) { - this._state.categoryState.index = 0; - return true; - } - - return false; - } - }, - - _stepToNextDescription: { - enumerable: false, - value: function() { - var categoryState = this._state.categoryState; - var keys = categoryState.keys; - if (!keys) { - console.log("INCONSISTENCY ERROR"); - return false; - } - - categoryState.index++; - categoryState.keys = null; - if (categoryState.index >= keys.length) { - return this._stepToNextCategory(); - } - return false; - } - }, - - hasCategory: { - value: function(category) { - return this.rootDescription[category] ? true : false; - } - }, - - _handleState: { - value: function() { - - var methodForType = { - "buffers" : this.handleBuffer, - "bufferViews" : this.handleBufferView, - "shaders" : this.handleShader, - "programs" : this.handleProgram, - "techniques" : this.handleTechnique, - "materials" : this.handleMaterial, - "meshes" : this.handleMesh, - "cameras" : this.handleCamera, - "lights" : this.handleLight, - "nodes" : this.handleNode, - "scenes" : this.handleScene, - "images" : this.handleImage, - "animations" : this.handleAnimation, - "accessors" : this.handleAccessor, - "skins" : this.handleSkin, - "samplers" : this.handleSampler, - "textures" : this.handleTexture, - "videos" : this.handleVideo, - "extensions" : this.handleExtension, - - }; - - var success = true; - while (this._state.categoryIndex !== -1) { - var category = categoriesDepsOrder[this._state.categoryIndex]; - var categoryState = this._state.categoryState; - var keys = categoryState.keys; - if (!keys) { - categoryState.keys = keys = Object.keys(this.rootDescription[category]); - if (keys) { - if (keys.length == 0) { - this._stepToNextDescription(); - continue; - } - } - } - - var type = category; - var entryID = keys[categoryState.index]; - var description = this.getEntryDescription(entryID, type); - if (!description) { - if (this.handleError) { - this.handleError("INCONSISTENCY ERROR: no description found for entry "+entryID); - success = false; - break; - } - } else { - - if (methodForType[type]) { - if (methodForType[type].call(this, entryID, description, this._state.userInfo) === false) { - success = false; - break; - } - } - - this._stepToNextDescription(); - } - } - - if (this.handleLoadCompleted) { - this.handleLoadCompleted(success); - } - - } - }, - - _loadJSONIfNeeded: { - enumerable: true, - value: function(callback) { - var self = this; - //FIXME: handle error - if (!this._json) { - var jsonPath = this._path; - var i = jsonPath.lastIndexOf("/"); - this.baseURL = (i !== 0) ? jsonPath.substring(0, i + 1) : ''; - var jsonfile = new XMLHttpRequest(); - jsonfile.open("GET", jsonPath, true); - jsonfile.onreadystatechange = function() { - if (jsonfile.readyState == 4) { - if (jsonfile.status == 200) { - self.json = JSON.parse(jsonfile.responseText); - if (callback) { - callback(self.json); - } - } - } - }; - jsonfile.send(null); - } else { - if (callback) { - callback(this.json); - } - } - } - }, - - /* load JSON and assign it as description to the reader */ - _buildLoader: { - value: function(callback) { - var self = this; - function JSONReady(json) { - self.rootDescription = json; - if (callback) - callback(this); - } - - this._loadJSONIfNeeded(JSONReady); - } - }, - - _state: { value: null, writable: true }, - - _getEntryType: { - value: function(entryID) { - var rootKeys = categoriesDepsOrder; - for (var i = 0 ; i < rootKeys.length ; i++) { - var rootValues = this.rootDescription[rootKeys[i]]; - if (rootValues) { - return rootKeys[i]; - } - } - return null; - } - }, - - getNextCategoryIndex: { - value: function(currentIndex) { - for (var i = currentIndex ; i < categoriesDepsOrder.length ; i++) { - if (this.hasCategory(categoriesDepsOrder[i])) { - return i; - } - } - - return -1; - } - }, - - load: { - enumerable: true, - value: function(userInfo, options) { - var self = this; - this._buildLoader(function loaderReady(reader) { - var startCategory = self.getNextCategoryIndex.call(self,0); - if (startCategory !== -1) { - self._state = { "userInfo" : userInfo, - "options" : options, - "categoryIndex" : startCategory, - "categoryState" : { "index" : "0" } }; - self._handleState(); - } - }); - } - }, - - initWithPath: { - value: function(path) { - this._path = path; - this._json = null; - return this; - } - }, - - //this is meant to be global and common for all instances - _knownURLs: { writable: true, value: {} }, - - //to be invoked by subclass, so that ids can be ensured to not overlap - loaderContext: { - value: function() { - if (typeof this._knownURLs[this._path] === "undefined") { - this._knownURLs[this._path] = Object.keys(this._knownURLs).length; - } - return "__" + this._knownURLs[this._path]; - } - }, - - initWithJSON: { - value: function(json, baseURL) { - this.json = json; - this.baseURL = baseURL; - if (!baseURL) { - console.log("WARNING: no base URL passed to Reader:initWithJSON"); - } - return this; - } - } - - }); - - if(root) { - root.glTFParser = glTFParser; - } - - return glTFParser; - -})); diff --git a/examples/js/loaders/deprecated/gltf/glTFAnimation.js b/examples/js/loaders/deprecated/gltf/glTFAnimation.js deleted file mode 100644 index 735e5f1e2a437201e0f68bbf03e6b75850973b68..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/glTFAnimation.js +++ /dev/null @@ -1,251 +0,0 @@ -/** - * @author Tony Parisi / http://www.tonyparisi.com/ - */ - -THREE.glTFAnimator = ( function () { - - var animators = []; - - return { - add : function(animator) - { - animators.push(animator); - }, - - remove: function(animator) - { - - var i = animators.indexOf(animator); - - if ( i !== -1 ) { - animators.splice( i, 1 ); - } - }, - - update : function() - { - for (i = 0; i < animators.length; i++) - { - animators[i].update(); - } - }, - }; -})(); - -// Construction/initialization -THREE.glTFAnimation = function(interps) -{ - this.running = false; - this.loop = false; - this.duration = 0; - this.startTime = 0; - this.interps = []; - - if (interps) - { - this.createInterpolators(interps); - } -} - -THREE.glTFAnimation.prototype.createInterpolators = function(interps) -{ - var i, len = interps.length; - for (i = 0; i < len; i++) - { - var interp = new THREE.glTFInterpolator(interps[i]); - this.interps.push(interp); - this.duration = Math.max(this.duration, interp.duration); - } -} - -// Start/stop -THREE.glTFAnimation.prototype.play = function() -{ - if (this.running) - return; - - this.startTime = Date.now(); - this.running = true; - THREE.glTFAnimator.add(this); -} - -THREE.glTFAnimation.prototype.stop = function() -{ - this.running = false; - THREE.glTFAnimator.remove(this); -} - -// Update - drive key frame evaluation -THREE.glTFAnimation.prototype.update = function() -{ - if (!this.running) - return; - - var now = Date.now(); - var deltat = (now - this.startTime) / 1000; - var t = deltat % this.duration; - var nCycles = Math.floor(deltat / this.duration); - - if (nCycles >= 1 && !this.loop) - { - this.running = false; - var i, len = this.interps.length; - for (i = 0; i < len; i++) - { - this.interps[i].interp(this.duration); - } - this.stop(); - return; - } - else - { - var i, len = this.interps.length; - for (i = 0; i < len; i++) - { - this.interps[i].interp(t); - } - } -} - -//Interpolator class -//Construction/initialization -THREE.glTFInterpolator = function(param) -{ - this.keys = param.keys; - this.values = param.values; - this.count = param.count; - this.type = param.type; - this.path = param.path; - this.isRot = false; - - var node = param.target; - node.updateMatrix(); - node.matrixAutoUpdate = true; - this.targetNode = node; - - switch (param.path) { - case "translation" : - this.target = node.position; - this.originalValue = node.position.clone(); - break; - case "rotation" : - this.target = node.quaternion; - this.originalValue = node.quaternion.clone(); - this.isRot = true; - break; - case "scale" : - this.target = node.scale; - this.originalValue = node.scale.clone(); - break; - } - - this.duration = this.keys[this.count - 1]; - - this.vec1 = new THREE.Vector3; - this.vec2 = new THREE.Vector3; - this.vec3 = new THREE.Vector3; - this.quat1 = new THREE.Quaternion; - this.quat2 = new THREE.Quaternion; - this.quat3 = new THREE.Quaternion; -} - -//Interpolation and tweening methods -THREE.glTFInterpolator.prototype.interp = function(t) -{ - var i, j; - if (t == this.keys[0]) - { - if (this.isRot) { - this.quat3.set(this.values[0], this.values[1], this.values[2], this.values[3]); - } - else { - this.vec3.set(this.values[0], this.values[1], this.values[2]); - } - } - else if (t < this.keys[0]) - { - if (this.isRot) { - this.quat1.set(this.originalValue.x, - this.originalValue.y, - this.originalValue.z, - this.originalValue.w); - this.quat2.set(this.values[0], - this.values[1], - this.values[2], - this.values[3]); - THREE.Quaternion.slerp(this.quat1, this.quat2, this.quat3, t / this.keys[0]); - } - else { - this.vec3.set(this.originalValue.x, - this.originalValue.y, - this.originalValue.z); - this.vec2.set(this.values[0], - this.values[1], - this.values[2]); - - this.vec3.lerp(this.vec2, t / this.keys[0]); - } - } - else if (t >= this.keys[this.count - 1]) - { - if (this.isRot) { - this.quat3.set(this.values[(this.count - 1) * 4], - this.values[(this.count - 1) * 4 + 1], - this.values[(this.count - 1) * 4 + 2], - this.values[(this.count - 1) * 4 + 3]); - } - else { - this.vec3.set(this.values[(this.count - 1) * 3], - this.values[(this.count - 1) * 3 + 1], - this.values[(this.count - 1) * 3 + 2]); - } - } - else - { - for (i = 0; i < this.count - 1; i++) - { - var key1 = this.keys[i]; - var key2 = this.keys[i + 1]; - - if (t >= key1 && t <= key2) - { - if (this.isRot) { - this.quat1.set(this.values[i * 4], - this.values[i * 4 + 1], - this.values[i * 4 + 2], - this.values[i * 4 + 3]); - this.quat2.set(this.values[(i + 1) * 4], - this.values[(i + 1) * 4 + 1], - this.values[(i + 1) * 4 + 2], - this.values[(i + 1) * 4 + 3]); - THREE.Quaternion.slerp(this.quat1, this.quat2, this.quat3, (t - key1) / (key2 - key1)); - } - else { - this.vec3.set(this.values[i * 3], - this.values[i * 3 + 1], - this.values[i * 3 + 2]); - this.vec2.set(this.values[(i + 1) * 3], - this.values[(i + 1) * 3 + 1], - this.values[(i + 1) * 3 + 2]); - - this.vec3.lerp(this.vec2, (t - key1) / (key2 - key1)); - } - } - } - } - - if (this.target) - { - this.copyValue(this.target); - } -} - -THREE.glTFInterpolator.prototype.copyValue = function(target) { - - if (this.isRot) { - target.copy(this.quat3); - } - else { - target.copy(this.vec3); - } -} diff --git a/examples/js/loaders/deprecated/gltf/glTFLoader.js b/examples/js/loaders/deprecated/gltf/glTFLoader.js deleted file mode 100644 index 6670028d4ad83d621bea940c911c4a68b98e90ed..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/glTFLoader.js +++ /dev/null @@ -1,1959 +0,0 @@ -/** - * @author Tony Parisi / http://www.tonyparisi.com/ - */ - - -THREE.glTFLoader = function () { - - this.meshesRequested = 0; - this.meshesLoaded = 0; - this.pendingMeshes = []; - this.animationsRequested = 0; - this.animationsLoaded = 0; - this.animations = []; - this.shadersRequested = 0; - this.shadersLoaded = 0; - this.shaders = {}; - this.loadRequests = []; - THREE.glTFShaders.removeAll(); - THREE.Loader.call( this ); -} - -THREE.glTFLoader.prototype = new THREE.Loader(); -THREE.glTFLoader.prototype.constructor = THREE.glTFLoader; - -THREE.glTFLoader.prototype.load = function( url, callback ) { - - var theLoader = this; - // Utilities - - function RgbArraytoHex(colorArray) { - if(!colorArray) return 0xFFFFFFFF; - var r = Math.floor(colorArray[0] * 255), - g = Math.floor(colorArray[1] * 255), - b = Math.floor(colorArray[2] * 255), - a = 255; - - var color = (a << 24) + (r << 16) + (g << 8) + b; - - return color; - } - - function componentsPerElementForGLType(type) { - switch(type) { - case "SCALAR" : - nElements = 1; - break; - case "VEC2" : - nElements = 2; - break; - case "VEC3" : - nElements = 3; - break; - case "VEC4" : - nElements = 4; - break; - case "MAT2" : - nElements = 4; - break; - case "MAT3" : - nElements = 9; - break; - case "MAT4" : - nElements = 16; - break; - default : - debugger; - break; - } - - return nElements; - } - - function replaceShaderDefinitions(shader, material) { - - // Three.js seems too dependent on attribute names so globally - // replace those in the shader code - var program = material.params.program; - var shaderParams = material.params.technique.parameters; - var shaderAttributes = material.params.technique.attributes; - var params = {}; - - for (var attribute in material.params.attributes) { - var pname = shaderAttributes[attribute]; - var shaderParam = shaderParams[pname]; - var semantic = shaderParam.semantic; - if (semantic) { - params[attribute] = shaderParam; - } - } - - - var s = shader; - var r = ""; - for (var pname in params) { - var param = params[pname]; - var semantic = param.semantic; - - r = eval("/" + pname + "/g"); - - switch (semantic) { - case "POSITION" : - s = s.replace(r, 'position'); - break; - case "NORMAL" : - s = s.replace(r, 'normal'); - break; - case "TEXCOORD_0" : - s = s.replace(r, 'uv'); - break; - case "WEIGHT" : - s = s.replace(r, 'skinWeight'); - break; - case "JOINT" : - s = s.replace(r, 'skinIndex'); - break; - default : - break; - } - - } - - return s; - } - - function replaceShaderSemantics(material) { - - var vertexShader = theLoader.shaders[material.params.vertexShader]; - if (vertexShader) { - vertexShader = replaceShaderDefinitions(vertexShader, material); - theLoader.shaders[material.params.vertexShader] = vertexShader; - } - - } - - function createShaderMaterial(material) { - - // replace named attributes and uniforms with Three.js built-ins - replaceShaderSemantics(material); - - var fragmentShader = theLoader.shaders[material.params.fragmentShader]; - if (!fragmentShader) { - console.log("ERROR: Missing fragment shader definition:", material.params.fragmentShader); - return new THREE.MeshPhongMaterial; - } - - var vertexShader = theLoader.shaders[material.params.vertexShader]; - if (!vertexShader) { - console.log("ERROR: Missing vertex shader definition:", material.params.vertexShader); - return new THREE.MeshPhongMaterial; - } - - // clone most uniforms but then clobber textures, we want them to - // be reused - var uniforms = THREE.UniformsUtils.clone(material.params.uniforms); - for (uniform in material.params.uniforms) { - var src = material.params.uniforms[uniform]; - var dst = uniforms[uniform]; - if (dst.type == "t") { - dst.value = src.value; - } - } - - var shaderMaterial = new THREE.RawShaderMaterial( { - - fragmentShader: fragmentShader, - vertexShader: vertexShader, - uniforms: uniforms, - transparent: material.params.transparent, - - } ); - -// console.log("New shader material") - return shaderMaterial; - } - - - function LoadTexture(src) { - if(!src) { return null; } - - var isDataUriRegex = /^data:/; - - var loadImage = function(url, success, error) { - var image = new Image(); - - image.onload = function() { - success(image); - }; - - if (typeof error !== 'undefined') { - image.onerror = error; - } - - image.src = url; - }; - - function loadImageFromTypedArray(uint8Array, format) { - //>>includeStart('debug', pragmas.debug); - if (!defined(uint8Array)) { - throw new DeveloperError('uint8Array is required.'); - } - - if (!defined(format)) { - throw new DeveloperError('format is required.'); - } - //>>includeEnd('debug'); - - var blob = new Blob([uint8Array], { - type : format - }); - - }; - - function decodeDataUriText(isBase64, data) { - var result = decodeURIComponent(data); - if (isBase64) { - return atob(result); - } - return result; - } - - function decodeDataUriArrayBuffer(isBase64, data) { - var byteString = decodeDataUriText(isBase64, data); - var buffer = new ArrayBuffer(byteString.length); - var view = new Uint8Array(buffer); - for (var i = 0; i < byteString.length; i++) { - view[i] = byteString.charCodeAt(i); - } - return buffer; - } - - function decodeDataUri(dataUriRegexResult, responseType) { - responseType = typeof responseType !== 'undefined' ? responseType : ''; - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; - - switch (responseType) { - case '': - case 'text': - return decodeDataUriText(isBase64, data); - case 'ArrayBuffer': - return decodeDataUriArrayBuffer(isBase64, data); - case 'blob': - var buffer = decodeDataUriArrayBuffer(isBase64, data); - return new Blob([buffer], { - type : mimeType - }); - case 'document': - var parser = new DOMParser(); - return parser.parseFromString(decodeDataUriText(isBase64, data), mimeType); - case 'json': - return JSON.parse(decodeDataUriText(isBase64, data)); - default: - throw 'Unhandled responseType: ' + responseType; - } - } - - var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/; - var dataUriRegexResult = dataUriRegex.exec(src); - if (dataUriRegexResult !== null) { - var texture = new THREE.Texture; - var blob = decodeDataUri(dataUriRegexResult, 'blob'); - var blobUrl = window.URL.createObjectURL(blob); - loadImage(blobUrl, function(img) { - texture.image = img; - texture.needsUpdate = true; - }); - return texture; - } - - var textureLoader = THREE.Loader.Handlers.get(src); - if ( textureLoader === null ) { - textureLoader = new THREE.TextureLoader(); - } - textureLoader.crossOrigin = true; - - return textureLoader.load(src); - } - - function CreateTexture(resources, resource) { - var texturePath = null; - var textureParams = null; - - if (resource) - { - var texture = resource; - if (texture) { - var textureEntry = resources.getEntry(texture); - if (textureEntry) { - { - var imageEntry = resources.getEntry(textureEntry.description.source); - if (imageEntry) { - texturePath = imageEntry.description.uri; - } - - var samplerEntry = resources.getEntry(textureEntry.description.sampler); - if (samplerEntry) { - textureParams = samplerEntry.description; - } - } - } - } - } - - var texture = LoadTexture(texturePath); - if (texture && textureParams) { - - if (textureParams.wrapS == THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.REPEAT) - texture.wrapS = THREE.RepeatWrapping; - - if (textureParams.wrapT == THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.REPEAT) - texture.wrapT = THREE.RepeatWrapping; - - if (textureParams.magFilter == THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.LINEAR) - texture.magFilter = THREE.LinearFilter; - -// if (textureParams.minFilter == "LINEAR") -// texture.minFilter = THREE.LinearFilter; - } - - return texture; - } - - // Geometry processing - - var ClassicGeometry = function() { - - this.geometry = new THREE.BufferGeometry; - this.totalAttributes = 0; - this.loadedAttributes = 0; - this.indicesLoaded = false; - this.finished = false; - - this.onload = null; - - this.uvs = null; - this.indexArray = null; - }; - - ClassicGeometry.prototype.constructor = ClassicGeometry; - - ClassicGeometry.prototype.buildBufferGeometry = function() { - // Build indexed mesh - var geometry = this.geometry; - geometry.setIndex(new THREE.BufferAttribute( this.indexArray, 1 ) ); - - var offset = { - start: 0, - index: 0, - count: this.indexArray.length - }; - - geometry.groups.push( offset ); - - geometry.computeBoundingSphere(); - } - - ClassicGeometry.prototype.checkFinished = function() { - if(this.indexArray && this.loadedAttributes === this.totalAttributes) { - - this.buildBufferGeometry(); - - this.finished = true; - - if(this.onload) { - this.onload(); - } - } - }; - - // Delegate for processing index buffers - var IndicesDelegate = function() {}; - - IndicesDelegate.prototype.handleError = function(errorCode, info) { - // FIXME: report error - console.log("ERROR(IndicesDelegate):"+errorCode+":"+info); - }; - - IndicesDelegate.prototype.convert = function(resource, ctx) { - return new Uint16Array(resource, 0, ctx.indices.count); - }; - - IndicesDelegate.prototype.resourceAvailable = function(glResource, ctx) { - var geometry = ctx.geometry; - geometry.indexArray = glResource; - geometry.checkFinished(); - return true; - }; - - var indicesDelegate = new IndicesDelegate(); - - var IndicesContext = function(indices, geometry) { - this.indices = indices; - this.geometry = geometry; - }; - - // Delegate for processing vertex attribute buffers - var VertexAttributeDelegate = function() {}; - - VertexAttributeDelegate.prototype.handleError = function(errorCode, info) { - // FIXME: report error - console.log("ERROR(VertexAttributeDelegate):"+errorCode+":"+info); - }; - - VertexAttributeDelegate.prototype.convert = function(resource, ctx) { - return resource; - }; - - - VertexAttributeDelegate.prototype.bufferResourceAvailable = function(glResource, ctx) { - var geom = ctx.geometry; - var attribute = ctx.attribute; - var semantic = ctx.semantic; - var floatArray; - var i, l; - var nComponents; - //FIXME: Float32 is assumed here, but should be checked. - - if (semantic == "POSITION") { - // TODO: Should be easy to take strides into account here - floatArray = new Float32Array(glResource, 0, attribute.count * componentsPerElementForGLType(attribute.type)); - geom.geometry.addAttribute( 'position', new THREE.BufferAttribute( floatArray, 3 ) ); - } else if (semantic == "NORMAL") { - nComponents = componentsPerElementForGLType(attribute.type); - floatArray = new Float32Array(glResource, 0, attribute.count * nComponents); - geom.geometry.addAttribute( 'normal', new THREE.BufferAttribute( floatArray, 3 ) ); - } else if ((semantic == "TEXCOORD_0") || (semantic == "TEXCOORD" )) { - - nComponents = componentsPerElementForGLType(attribute.type); - floatArray = new Float32Array(glResource, 0, attribute.count * nComponents); - // N.B.: flip Y value... should we just set texture.flipY everywhere? - for (i = 0; i < floatArray.length / 2; i++) { - floatArray[i*2+1] = 1.0 - floatArray[i*2+1]; - } - geom.geometry.addAttribute( 'uv', new THREE.BufferAttribute( floatArray, nComponents ) ); - } - else if (semantic == "WEIGHT") { - nComponents = componentsPerElementForGLType(attribute.type); - floatArray = new Float32Array(glResource, 0, attribute.count * nComponents); - geom.geometry.addAttribute( 'skinWeight', new THREE.BufferAttribute( floatArray, nComponents ) ); - } - else if (semantic == "JOINT") { - nComponents = componentsPerElementForGLType(attribute.type); - floatArray = new Float32Array(glResource, 0, attribute.count * nComponents); - geom.geometry.addAttribute( 'skinIndex', new THREE.BufferAttribute( floatArray, nComponents ) ); - } - } - - VertexAttributeDelegate.prototype.resourceAvailable = function(glResource, ctx) { - - this.bufferResourceAvailable(glResource, ctx); - - var geom = ctx.geometry; - geom.loadedAttributes++; - geom.checkFinished(); - return true; - }; - - var vertexAttributeDelegate = new VertexAttributeDelegate(); - - var VertexAttributeContext = function(attribute, semantic, geometry) { - this.attribute = attribute; - this.semantic = semantic; - this.geometry = geometry; - }; - - var Mesh = function() { - this.primitives = []; - this.materialsPending = []; - this.loadedGeometry = 0; - this.onCompleteCallbacks = []; - }; - - Mesh.prototype.addPrimitive = function(geometry, material) { - - var self = this; - geometry.onload = function() { - self.loadedGeometry++; - self.checkComplete(); - }; - - this.primitives.push({ - geometry: geometry, - material: material, - mesh: null - }); - }; - - Mesh.prototype.onComplete = function(callback) { - this.onCompleteCallbacks.push(callback); - //this.checkComplete(); - }; - - Mesh.prototype.checkComplete = function() { - var self = this; - if(this.onCompleteCallbacks.length && this.primitives.length == this.loadedGeometry) { - this.onCompleteCallbacks.forEach(function(callback) { - callback(self); - }); - this.onCompleteCallbacks = []; - } - }; - - Mesh.prototype.attachToNode = function(threeNode) { - // Assumes that the geometry is complete - var that = this; - this.primitives.forEach(function(primitive) { - /*if(!primitive.mesh) { - primitive.mesh = new THREE.Mesh(primitive.geometry, primitive.material); - }*/ - var material = primitive.material; - var materialParams = material.params; - if (!(material instanceof THREE.Material)) { - material = createShaderMaterial(material); - } - - if (!that.skin) { - // console.log ("New mesh") - var threeMesh = new THREE.Mesh(primitive.geometry.geometry, material); - threeMesh.castShadow = true; - threeNode.add(threeMesh); - - if (material instanceof THREE.ShaderMaterial) { - var glTFShader = new THREE.glTFShader(material, materialParams, threeMesh, theLoader.rootObj); - THREE.glTFShaders.add(glTFShader); - - } - } - }); - }; - - // Delayed-loaded material - var Material = function(params) { - this.params = params; - }; - - // Delegate for processing animation parameter buffers - var AnimationParameterDelegate = function() {}; - - AnimationParameterDelegate.prototype.handleError = function(errorCode, info) { - // FIXME: report error - console.log("ERROR(AnimationParameterDelegate):"+errorCode+":"+info); - }; - - AnimationParameterDelegate.prototype.convert = function(resource, ctx) { - var parameter = ctx.parameter; - - var glResource = null; - switch (parameter.type) { - case "SCALAR" : - case "VEC2" : - case "VEC3" : - case "VEC4" : - glResource = new Float32Array(resource, 0, parameter.count * componentsPerElementForGLType(parameter.type)); - break; - default: - break; - } - - return glResource; - }; - - AnimationParameterDelegate.prototype.resourceAvailable = function(glResource, ctx) { - var animation = ctx.animation; - var parameter = ctx.parameter; - parameter.data = glResource; - animation.handleParameterLoaded(parameter); - return true; - }; - - var animationParameterDelegate = new AnimationParameterDelegate(); - - var AnimationParameterContext = function(parameter, animation) { - this.parameter = parameter; - this.animation = animation; - }; - - // Animations - var Animation = function() { - - // create Three.js keyframe here - this.totalParameters = 0; - this.loadedParameters = 0; - this.parameters = {}; - this.finishedLoading = false; - this.onload = null; - - }; - - Animation.prototype.constructor = Animation; - - Animation.prototype.handleParameterLoaded = function(parameter) { - this.parameters[parameter.name] = parameter; - this.loadedParameters++; - this.checkFinished(); - }; - - Animation.prototype.checkFinished = function() { - if(this.loadedParameters === this.totalParameters) { - // Build animation - this.finishedLoading = true; - - if (this.onload) { - this.onload(); - } - } - }; - - // Delegate for processing inverse bind matrices buffer - var InverseBindMatricesDelegate = function() {}; - - InverseBindMatricesDelegate.prototype.handleError = function(errorCode, info) { - // FIXME: report error - console.log("ERROR(InverseBindMatricesDelegate):"+errorCode+":"+info); - }; - - InverseBindMatricesDelegate.prototype.convert = function(resource, ctx) { - var parameter = ctx.parameter; - - var glResource = null; - switch (parameter.type) { - case "MAT4" : - glResource = new Float32Array(resource, 0, parameter.count * componentsPerElementForGLType(parameter.type)); - break; - default: - break; - } - - return glResource; - }; - - InverseBindMatricesDelegate.prototype.resourceAvailable = function(glResource, ctx) { - var skin = ctx.skin; - skin.inverseBindMatrices = glResource; - return true; - }; - - var inverseBindMatricesDelegate = new InverseBindMatricesDelegate(); - - var InverseBindMatricesContext = function(param, skin) { - this.parameter = param; - this.skin = skin; - }; - - // Delegate for processing shaders from external files - var ShaderDelegate = function() {}; - - ShaderDelegate.prototype.handleError = function(errorCode, info) { - // FIXME: report error - console.log("ERROR(ShaderDelegate):"+errorCode+":"+info); - }; - - ShaderDelegate.prototype.convert = function(resource, ctx) { - return resource; - } - - ShaderDelegate.prototype.resourceAvailable = function(data, ctx) { - theLoader.shadersLoaded++; - theLoader.shaders[ctx.id] = data; - return true; - }; - - var shaderDelegate = new ShaderDelegate(); - - var ShaderContext = function(id, path) { - this.id = id; - this.uri = path; - }; - - // Resource management - - var ResourceEntry = function(entryID, object, description) { - this.entryID = entryID; - this.object = object; - this.description = description; - }; - - var Resources = function() { - this._entries = {}; - }; - - Resources.prototype.setEntry = function(entryID, object, description) { - if (!entryID) { - console.error("No EntryID provided, cannot store", description); - return; - } - - if (this._entries[entryID]) { - console.warn("entry["+entryID+"] is being overwritten"); - } - - this._entries[entryID] = new ResourceEntry(entryID, object, description ); - }; - - Resources.prototype.getEntry = function(entryID) { - return this._entries[entryID]; - }; - - Resources.prototype.clearEntries = function() { - this._entries = {}; - }; - - LoadDelegate = function() { - } - - LoadDelegate.prototype.loadCompleted = function(callback, obj) { - callback.call(Window, obj); - } - - // Loader - - var ThreeGLTFLoader = Object.create(glTFParser, { - - load: { - enumerable: true, - value: function(userInfo, options) { - this.resources = new Resources(); - this.cameras = []; - this.lights = []; - this.animations = []; - this.joints = {}; - THREE.GLTFLoaderUtils.init(); - glTFParser.load.call(this, userInfo, options); - } - }, - - cameras: { - enumerable: true, - writable: true, - value : [] - }, - - lights: { - enumerable: true, - writable: true, - value : [] - }, - - animations: { - enumerable: true, - writable: true, - value : [] - }, - - // Implement WebGLTFLoader handlers - - handleBuffer: { - value: function(entryID, description, userInfo) { - this.resources.setEntry(entryID, null, description); - description.type = "ArrayBuffer"; - return true; - } - }, - - handleBufferView: { - value: function(entryID, description, userInfo) { - this.resources.setEntry(entryID, null, description); - - var buffer = this.resources.getEntry(description.buffer); - description.type = "ArrayBufferView"; - - var bufferViewEntry = this.resources.getEntry(entryID); - bufferViewEntry.buffer = buffer; - return true; - } - }, - - handleShader: { - value: function(entryID, description, userInfo) { - this.resources.setEntry(entryID, null, description); - var shaderRequest = { - id : entryID, - uri : description.uri, - }; - - var shaderContext = new ShaderContext(entryID, description.uri); - - theLoader.shadersRequested++; - THREE.GLTFLoaderUtils.getFile(shaderRequest, shaderDelegate, shaderContext); - - return true; - } - }, - - handleProgram: { - value: function(entryID, description, userInfo) { - this.resources.setEntry(entryID, null, description); - return true; - } - }, - - handleTechnique: { - value: function(entryID, description, userInfo) { - description.refCount = 0; - this.resources.setEntry(entryID, null, description); - return true; - } - }, - - - createShaderParams : { - value: function(materialId, values, params, programID, technique) { - var program = this.resources.getEntry(programID); - - params.uniforms = {}; - params.attributes = {}; - params.program = program; - params.technique = technique; - if (program) { - params.fragmentShader = program.description.fragmentShader; - params.vertexShader = program.description.vertexShader; - for (var uniform in technique.uniforms) { - var pname = technique.uniforms[uniform]; - var shaderParam = technique.parameters[pname]; - var ptype = shaderParam.type; - var pcount = shaderParam.count; - var value = values[pname]; - var utype = ""; - var uvalue; - var ulength; - - // THIS: for (n in WebGLRenderingContext) { z = WebGLRenderingContext[n]; idx[z] = n; } - //console.log("shader uniform param type: ", ptype, "-", theLoader.idx[ptype]) - - - switch (ptype) { - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT : - utype = "f"; - uvalue = shaderParam.value; - if (pname == "transparency") { - var USE_A_ONE = true; // for now, hack because file format isn't telling us - var opacity = USE_A_ONE ? value : (1.0 - value); - uvalue = opacity; - params.transparent = true; - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_VEC2 : - utype = "v2"; - uvalue = new THREE.Vector2; - if (shaderParam && shaderParam.value) { - var v2 = shaderParam.value; - uvalue.fromArray(v2); - } - if (value) { - uvalue.fromArray(value); - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_VEC3 : - utype = "v3"; - uvalue = new THREE.Vector3; - if (shaderParam && shaderParam.value) { - var v3 = shaderParam.value; - uvalue.fromArray(v3); - } - if (value) { - uvalue.fromArray(value); - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_VEC4 : - utype = "v4"; - uvalue = new THREE.Vector4; - if (shaderParam && shaderParam.value) { - var v4 = shaderParam.value; - uvalue.fromArray(v4); - } - if (value) { - uvalue.fromArray(value); - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_MAT2 : - // what to do? - console.log("Warning: FLOAT_MAT2"); - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_MAT3 : - utype = "m3"; - uvalue = new THREE.Matrix3; - if (shaderParam && shaderParam.value) { - var m3 = shaderParam.value; - uvalue.fromArray(m3); - } - if (value) { - uvalue.fromArray(value); - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT_MAT4 : - if (pcount !== undefined) { - utype = "m4v"; - uvalue = new Array(pcount); - for (var mi = 0; mi < pcount; mi++) { - uvalue[mi] = new THREE.Matrix4; - } - ulength = pcount; - - if (shaderParam && shaderParam.value) { - var m4v = shaderParam.value; - uvalue.fromArray(m4v); - } - if (value) { - uvalue.fromArray(value); - - } - } - else { - utype = "m4"; - uvalue = new THREE.Matrix4; - - if (shaderParam && shaderParam.value) { - var m4 = shaderParam.value; - uvalue.fromArray(m4); - } - if (value) { - uvalue.fromArray(value); - - } - } - break; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.SAMPLER_2D : - utype = "t"; - uvalue = value ? CreateTexture(this.resources, value) : null; - break; - default : - throw new Error("Unknown shader uniform param type: " + ptype + " - " + theLoader.idx[ptype]); - - break; - } - - - var udecl = { type : utype, value : uvalue, length : ulength }; - - params.uniforms[uniform] = udecl; - } - - for (var attribute in technique.attributes) { - var pname = technique.attributes[attribute]; - var param = technique.parameters[pname]; - var atype = param.type; - var semantic = param.semantic; - var adecl = { type : atype, semantic : semantic }; - - params.attributes[attribute] = adecl; - } - - } - } - }, - - threeJSMaterialType : { - value: function(materialId, material, params) { - - var extensions = material.extensions; - var khr_material = extensions ? extensions.KHR_materials_common : null; - - var materialType = null; - var values; - - if (khr_material) { - - switch (khr_material.technique) - { - case 'BLINN' : - case 'PHONG' : - materialType = THREE.MeshPhongMaterial; - break; - - case 'LAMBERT' : - materialType = THREE.MeshLambertMaterial; - break; - - case 'CONSTANT' : - default : - materialType = THREE.MeshBasicMaterial; - break; - } - - if (khr_material.doubleSided) - { - params.side = THREE.DoubleSide; - } - - if (khr_material.transparent) - { - params.transparent = true; - } - - values = {}; - for (prop in khr_material.values) { - values[prop] = khr_material.values[prop]; - } - - } - else if (material.technique === undefined) { - - materialType = THREE.MeshPhongMaterial; - - if (material.doubleSided) - { - params.side = THREE.DoubleSide; - } - - if (material.transparent) - { - params.transparent = true; - } - - values = {}; - for (var prop in material.values) { - values[prop] = material.values[prop]; - } - - } - else { - - var technique = this.resources.getEntry(material.technique); - - values = {}; - for (var prop in material.values) { - values[prop] = material.values[prop]; - } - - var description = technique.description; - - if (++description.refCount > 1) { - //console.log("refcount", description.refCount); - } - - var programID = description.program; - this.createShaderParams(materialId, values, params, programID, description); - - var loadshaders = true; - - if (loadshaders) { - materialType = Material; - } - - } - - if (values.diffuse && typeof(values.diffuse) == 'string') { - params.map = CreateTexture(this.resources, values.diffuse); - } - if (values.reflective && typeof(values.reflective) == 'string') { - params.envMap = CreateTexture(this.resources, values.reflective); - } - - var shininess = values.shininesss || values.shininess; // N.B.: typo in converter! - if (shininess) - { - shininess = shininess; - } - - var diffuseColor = null; - if (!params.map) { - diffuseColor = values.diffuse; - } - var opacity = 1.0; - if (values.hasOwnProperty("transparency")) - { - var USE_A_ONE = true; // for now, hack because file format isn't telling us - opacity = USE_A_ONE ? values.transparency : (1.0 - values.transparency); - } - - // if (diffuseColor) diffuseColor = [0, 1, 0]; - - params.color = RgbArraytoHex(diffuseColor); - params.opacity = opacity; - params.transparent = opacity < 1.0; - - if (!(shininess === undefined)) - { - params.shininess = Math.max( shininess, 1e-4 ); - } - - delete params.ambient; - if (!(values.ambient === undefined) && !(typeof(values.ambient) == 'string')) - { - //params.ambient = RgbArraytoHex(values.ambient); - } - - if (!(values.emission === undefined)) - { - params.emissive = RgbArraytoHex(values.emission); - } - - if (!(values.specular === undefined)) - { - params.specular = RgbArraytoHex(values.specular); - } - - return materialType; - - } - }, - - handleMaterial: { - value: function(entryID, description, userInfo) { - var params = {}; - - var materialType = this.threeJSMaterialType(entryID, description, params); - - var material = new materialType(params); - - this.resources.setEntry(entryID, material, description); - - return true; - } - }, - - handleMesh: { - value: function(entryID, description, userInfo) { - var mesh = new Mesh(); - this.resources.setEntry(entryID, mesh, description); - var primitivesDescription = description.primitives; - if (!primitivesDescription) { - //FIXME: not implemented in delegate - console.log("MISSING_PRIMITIVES for mesh:"+ entryID); - return false; - } - - for (var i = 0 ; i < primitivesDescription.length ; i++) { - var primitiveDescription = primitivesDescription[i]; - - if (primitiveDescription.mode === THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.TRIANGLES) { - - var geometry = new ClassicGeometry(); - var materialEntry = this.resources.getEntry(primitiveDescription.material); - - mesh.addPrimitive(geometry, materialEntry.object); - - var allAttributes = Object.keys(primitiveDescription.attributes); - - // count them first, async issues otherwise - allAttributes.forEach( function(semantic) { - geometry.totalAttributes++; - }, this); - - var indices = this.resources.getEntry(primitiveDescription.indices); - var bufferEntry = this.resources.getEntry(indices.description.bufferView); - var indicesObject = { - bufferView : bufferEntry, - byteOffset : indices.description.byteOffset, - count : indices.description.count, - id : indices.entryID, - componentType : indices.description.componentType, - type : indices.description.type - }; - - var indicesContext = new IndicesContext(indicesObject, geometry); - var loaddata = { - indicesObject : indicesObject, - indicesDelegate : indicesDelegate, - indicesContext : indicesContext - }; - - theLoader.scheduleLoad(function(data) { - var alreadyProcessedIndices = - THREE.GLTFLoaderUtils.getBuffer(data.indicesObject, - data.indicesDelegate, data.indicesContext); - - if (alreadyProcessedIndices) { - data.indicesDelegate.resourceAvailable( - alreadyProcessedIndices, data.indicesContext); - } - - }, loaddata); - - // Load Vertex Attributes - allAttributes.forEach( function(semantic) { - - var attribute; - var attributeID = primitiveDescription.attributes[semantic]; - var attributeEntry = this.resources.getEntry(attributeID); - if (!attributeEntry) { - //let's just use an anonymous object for the attribute - attribute = description.attributes[attributeID]; - attribute.id = attributeID; - this.resources.setEntry(attributeID, attribute, attribute); - - var bufferEntry = this.resources.getEntry(attribute.bufferView); - attributeEntry = this.resources.getEntry(attributeID); - - } else { - attribute = attributeEntry.object; - attribute.id = attributeID; - var bufferEntry = this.resources.getEntry(attribute.bufferView); - } - - var attributeObject = { - bufferView : bufferEntry, - byteOffset : attribute.byteOffset, - byteStride : attribute.byteStride, - count : attribute.count, - max : attribute.max, - min : attribute.min, - componentType : attribute.componentType, - type : attribute.type, - id : attributeID - }; - - var attribContext = new VertexAttributeContext(attributeObject, semantic, geometry); - - var loaddata = { - attributeObject : attributeObject, - vertexAttributeDelegate : vertexAttributeDelegate, - attribContext : attribContext - }; - - theLoader.scheduleLoad(function(data) { - var alreadyProcessedAttribute = - THREE.GLTFLoaderUtils.getBuffer(data.attributeObject, - data.vertexAttributeDelegate, data.attribContext); - - if (alreadyProcessedAttribute) { - data.vertexAttributeDelegate.resourceAvailable( - alreadyProcessedAttribute, data.attribContext); - } - - }, loaddata); - - - }, this); - } - } - return true; - } - }, - - handleCamera: { - value: function(entryID, description, userInfo) { - var camera; - if (description.type == "perspective") - { - var znear = description.perspective.znear; - var zfar = description.perspective.zfar; - var yfov = description.perspective.yfov; - var xfov = description.perspective.xfov; - var aspect_ratio = description.perspective.aspect_ratio; - - if (!aspect_ratio) - aspect_ratio = 1; - - if (xfov === undefined) { - if (yfov) - { - // According to COLLADA spec... - // aspect_ratio = xfov / yfov - xfov = yfov * aspect_ratio; - } - } - - if (yfov === undefined) - { - if (xfov) - { - // According to COLLADA spec... - // aspect_ratio = xfov / yfov - yfov = xfov / aspect_ratio; - } - - } - - if (xfov) - { - xfov = THREE.Math.radToDeg(xfov); - - camera = new THREE.PerspectiveCamera(xfov, aspect_ratio, znear, zfar); - } - } - else - { - camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, znear, zfar ); - } - - if (camera) - { - this.resources.setEntry(entryID, camera, description); - } - - return true; - } - }, - - handleLight: { - value: function(entryID, description, userInfo) { - - var light = null; - var type = description.type; - if (type && description[type]) - { - var lparams = description[type]; - var color = RgbArraytoHex(lparams.color); - - switch (type) { - case "directional" : - light = new THREE.DirectionalLight(color); - light.position.set(0, 0, 1); - break; - - case "point" : - light = new THREE.PointLight(color); - break; - - case "spot " : - light = new THREE.SpotLight(color); - light.position.set(0, 0, 1); - break; - - case "ambient" : - light = new THREE.AmbientLight(color); - break; - } - } - - if (light) - { - this.resources.setEntry(entryID, light, description); - } - - return true; - } - }, - - addPendingMesh: { - value: function(mesh, threeNode) { - theLoader.pendingMeshes.push({ - mesh: mesh, - node: threeNode - }); - } - }, - - handleNode: { - value: function(entryID, description, userInfo) { - - var threeNode = null; - if (description.jointName) { - threeNode = new THREE.Bone(); - threeNode.jointName = description.jointName; - this.joints[description.jointName] = entryID; - } - else { - threeNode = new THREE.Object3D(); - } - - threeNode.name = description.name; - threeNode.glTFID = entryID; - threeNode.glTF = description; - - this.resources.setEntry(entryID, threeNode, description); - - var m = description.matrix; - if(m) { - threeNode.matrixAutoUpdate = false; - threeNode.applyMatrix(new THREE.Matrix4().set( - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15] - )); - } - else { - var t = description.translation; - var r = description.rotation; - var s = description.scale; - - var position = t ? new THREE.Vector3(t[0], t[1], t[2]) : - new THREE.Vector3; - - var rotation = r ? new THREE.Quaternion(r[0], r[1], r[2], r[3]) : - new THREE.Quaternion; - var scale = s ? new THREE.Vector3(s[0], s[1], s[2]) : - new THREE.Vector3(1, 1, 1); - - var matrix = new THREE.Matrix4; - matrix.compose(position, rotation, scale); - threeNode.matrixAutoUpdate = false; - threeNode.applyMatrix(matrix); - } - - var self = this; - - if (description.meshes) { - description.meshInstances = {}; - var skinEntry; - if (description.skin) { - skinEntry = this.resources.getEntry(description.skin); - } - - description.meshes.forEach( function(meshID) { - meshEntry = this.resources.getEntry(meshID); - theLoader.meshesRequested++; - meshEntry.object.onComplete(function(mesh) { - self.addPendingMesh(mesh, threeNode); - description.meshInstances[meshID] = meshEntry.object; - if (skinEntry) { - mesh.skin = skinEntry; - description.instanceSkin = skinEntry.object; - } - - theLoader.meshesLoaded++; - theLoader.checkComplete(); - }); - }, this); - } - - if (description.camera) { - var cameraEntry = this.resources.getEntry(description.camera); - if (cameraEntry) { - threeNode.add(cameraEntry.object); - this.cameras.push(cameraEntry.object); - } - } - - if (description.extensions && description.extensions.KHR_materials_common - && description.extensions.KHR_materials_common.light) { - var lightID = description.extensions.KHR_materials_common.light; - var lightEntry = this.resources.getEntry(lightID); - if (lightEntry) { - threeNode.add(lightEntry.object); - this.lights.push(lightEntry.object); - } - } - - return true; - } - }, - - handleExtension: { - value: function(entryID, description, userInfo) { - - // console.log("Extension", entryID, description); - - switch (entryID) { - case 'KHR_materials_common' : - var lights = description.lights; - for (lightID in lights) { - var light = lights[lightID]; - this.handleLight(lightID, light); - } - break; - } - - return true; - } - }, - - buildNodeHirerachy: { - value: function(nodeEntryId, parentThreeNode) { - var nodeEntry = this.resources.getEntry(nodeEntryId); - var threeNode = nodeEntry.object; - parentThreeNode.add(threeNode); - - var children = nodeEntry.description.children; - if (children) { - children.forEach( function(childID) { - this.buildNodeHirerachy(childID, threeNode); - }, this); - } - - return threeNode; - } - }, - - buildSkin: { - value: function(node) { - - var glTF = node.glTF; - var skin = glTF.instanceSkin; - var skeletons = glTF.skeletons; - if (skin) { - skeletons.forEach(function(skeleton) { - var nodeEntry = this.resources.getEntry(skeleton); - if (nodeEntry) { - - var rootSkeleton = nodeEntry.object; - node.add(rootSkeleton); - - var dobones = true; - - for (meshID in glTF.meshInstances) { - var mesh = glTF.meshInstances[meshID]; - var threeMesh = null; - mesh.primitives.forEach(function(primitive) { - - var material = primitive.material; - var materialParams = material.params; - if (!(material instanceof THREE.Material)) { - material = createShaderMaterial(material); - } - - threeMesh = new THREE.SkinnedMesh(primitive.geometry.geometry, material, false); - - var geometry = primitive.geometry.geometry; - var j; -/* if (geometry.vertices) { - for ( j = 0; j < geometry.vertices.length; j ++ ) { - geometry.vertices[j].applyMatrix4( skin.bindShapeMatrix ); - } - } - else if (geometry.attributes.position) { - var a = geometry.attributes.position.array; - var v = new THREE.Vector3; - for ( j = 0; j < a.length / 3; j++ ) { - v.set(a[j * 3], a[j * 3 + 1], a[j * 3 + 2]); - v.applyMatrix4( skin.bindShapeMatrix ); - a[j * 3] = v.x; - a[j * 3 + 1] = v.y; - a[j * 3 + 2] = v.z; - } - }*/ - - if (threeMesh && dobones) { - - material.skinning = true; - - var jointNames = skin.jointNames; - var joints = []; - var bones = []; - var boneInverses = []; - var i, len = jointNames.length; - for (i = 0; i < len; i++) { - var jointName = jointNames[i]; - var nodeForJoint = this.joints[jointName]; - var joint = this.resources.getEntry(nodeForJoint).object; - if (joint) { - - joint.skin = threeMesh; - joints.push(joint); - bones.push(joint); - - var m = skin.inverseBindMatrices; - var mat = new THREE.Matrix4().set( - m[i * 16 + 0], m[i * 16 + 4], m[i * 16 + 8], m[i * 16 + 12], - m[i * 16 + 1], m[i * 16 + 5], m[i * 16 + 9], m[i * 16 + 13], - m[i * 16 + 2], m[i * 16 + 6], m[i * 16 + 10], m[i * 16 + 14], - m[i * 16 + 3], m[i * 16 + 7], m[i * 16 + 11], m[i * 16 + 15] - ); - boneInverses.push(mat); - - } else { - console.log("WARNING: jointName:"+jointName+" cannot be found in skeleton:"+skeleton); - } - } - - threeMesh.bind( new THREE.Skeleton( bones, - boneInverses, false ), skin.bindShapeMatrix ); - - //threeMesh.bindMode = "detached"; - //threeMesh.normalizeSkinWeights(); - //threeMesh.pose(); - } - - if (threeMesh) { - threeMesh.castShadow = true; - node.add(threeMesh); - - if (material instanceof THREE.ShaderMaterial) { - materialParams.joints = joints; - var glTFShader = new THREE.glTFShader(material, materialParams, threeMesh, theLoader.rootObj); - THREE.glTFShaders.add(glTFShader); - - } - } - - }, this); - } - - } - - - }, this); - - } - } - }, - - buildSkins: { - value: function(node) { - - if (node.glTF && node.glTF.instanceSkin) - this.buildSkin(node); - - var children = node.children; - if (children) { - children.forEach( function(child) { - this.buildSkins(child); - }, this); - } - } - }, - - createMeshAnimations : { - value : function(root) { - this.buildSkins(root); - } - }, - - handleScene: { - value: function(entryID, description, userInfo) { - - if (!description.nodes) { - console.log("ERROR: invalid file required nodes property is missing from scene"); - return false; - } - - description.nodes.forEach( function(nodeUID) { - this.buildNodeHirerachy(nodeUID, userInfo.rootObj); - }, this); - - if (this.delegate) { - this.delegate.loadCompleted(userInfo.callback, userInfo.rootObj); - } - - theLoader.loadAllAssets(); - - return true; - } - }, - - handleImage: { - value: function(entryID, description, userInfo) { - this.resources.setEntry(entryID, null, description); - return true; - } - }, - - addNodeAnimationChannel : { - value : function(name, channel, interp) { - if (!this.nodeAnimationChannels) - this.nodeAnimationChannels = {}; - - if (!this.nodeAnimationChannels[name]) { - this.nodeAnimationChannels[name] = []; - } - - this.nodeAnimationChannels[name].push(interp); - }, - }, - - createAnimations : { - value : function() { - for (var name in this.nodeAnimationChannels) { - var nodeAnimationChannels = this.nodeAnimationChannels[name]; - var i, len = nodeAnimationChannels.length; - //console.log(" animation channels for node " + name); - //for (i = 0; i < len; i++) { - // console.log(nodeAnimationChannels[i]); - //} - var anim = new THREE.glTFAnimation(nodeAnimationChannels); - anim.name = "animation_" + name; - this.animations.push(anim); - } - } - }, - - buildAnimation: { - value : function(animation) { - - var interps = []; - var i, len = animation.channels.length; - for (i = 0; i < len; i++) { - - var channel = animation.channels[i]; - var sampler = animation.samplers[channel.sampler]; - if (sampler) { - - var input = animation.parameters[sampler.input]; - if (input && input.data) { - - var output = animation.parameters[sampler.output]; - if (output && output.data) { - - var target = channel.target; - var node = this.resources.getEntry(target.id); - if (node) { - - var path = target.path; - - var interp = { - keys : input.data, - values : output.data, - count : input.count, - target : node.object, - path : path, - type : sampler.interpolation - }; - - this.addNodeAnimationChannel(target.id, channel, interp); - interps.push(interp); - } - } - } - } - } - } - }, - - handleAnimation: { - value: function(entryID, description, userInfo) { - - var self = this; - theLoader.animationsRequested++; - var animation = new Animation(); - animation.name = entryID; - animation.onload = function() { - // self.buildAnimation(animation); - theLoader.animationsLoaded++; - theLoader.animations.push(animation); - theLoader.checkComplete(); - }; - - animation.channels = description.channels; - animation.samplers = description.samplers; - this.resources.setEntry(entryID, animation, description); - var parameters = description.parameters; - if (!parameters) { - //FIXME: not implemented in delegate - console.log("MISSING_PARAMETERS for animation:"+ entryID); - return false; - } - - // Load parameter buffers - var params = Object.keys(parameters); - params.forEach( function(param) { - - // async help - animation.totalParameters++; - - }, this); - - var params = Object.keys(parameters); - params.forEach( function(param) { - - var parameter = parameters[param]; - var accessor = this.resources.getEntry(parameter); - if (!accessor) - debugger; - accessor = accessor.object; - var bufferView = this.resources.getEntry(accessor.bufferView); - var paramObject = { - bufferView : bufferView, - byteOffset : accessor.byteOffset, - count : accessor.count, - componentType : accessor.componentType, - type : accessor.type, - id : accessor.bufferView, - name : param - }; - - var paramContext = new AnimationParameterContext(paramObject, animation); - - var loaddata = { - paramObject : paramObject, - animationParameterDelegate : animationParameterDelegate, - paramContext : paramContext - }; - - theLoader.scheduleLoad(function(data) { - - var alreadyProcessedAttribute = - THREE.GLTFLoaderUtils.getBuffer(data.paramObject, - data.animationParameterDelegate, data.paramContext); - - if (alreadyProcessedAttribute) { - data.animationParameterDelegate.resourceAvailable( - alreadyProcessedAttribute, data.paramContext); - } - - }, loaddata); - - - }, this); - - return true; - } - }, - - handleAccessor: { - value: function(entryID, description, userInfo) { - // Save attribute entry - this.resources.setEntry(entryID, description, description); - return true; - } - }, - - handleSkin: { - value: function(entryID, description, userInfo) { - // Save skin entry - - var skin = { - }; - - var m = description.bindShapeMatrix; - skin.bindShapeMatrix = new THREE.Matrix4().set( - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15] - ); - - skin.jointNames = description.jointNames; - var inverseBindMatricesDescription = this.resources.getEntry(description.inverseBindMatrices); - inverseBindMatricesDescription = inverseBindMatricesDescription.description; - skin.inverseBindMatricesDescription = inverseBindMatricesDescription; - skin.inverseBindMatricesDescription.id = description.inverseBindMatrices; - - var bufferEntry = this.resources.getEntry(inverseBindMatricesDescription.bufferView); - - var paramObject = { - bufferView : bufferEntry, - byteOffset : inverseBindMatricesDescription.byteOffset, - count : inverseBindMatricesDescription.count, - componentType : inverseBindMatricesDescription.componentType, - type : inverseBindMatricesDescription.type, - id : inverseBindMatricesDescription.bufferView, - name : skin.inverseBindMatricesDescription.id - }; - - var context = new InverseBindMatricesContext(paramObject, skin); - - var loaddata = { - paramObject : paramObject, - inverseBindMatricesDelegate : inverseBindMatricesDelegate, - context : context - }; - - theLoader.scheduleLoad(function(data) { - - var alreadyProcessedAttribute = - THREE.GLTFLoaderUtils.getBuffer(data.paramObject, - data.inverseBindMatricesDelegate, data.context); - - if (alreadyProcessedAttribute) { - data.inverseBindMatricesDelegate.resourceAvailable( - alreadyProcessedAttribute, data.context); - } - - }, loaddata); - - - - var bufferView = this.resources.getEntry(skin.inverseBindMatricesDescription.bufferView); - skin.inverseBindMatricesDescription.bufferView = - bufferView.object; - this.resources.setEntry(entryID, skin, description); - return true; - } - }, - - handleSampler: { - value: function(entryID, description, userInfo) { - // Save attribute entry - this.resources.setEntry(entryID, description, description); - return true; - } - }, - - handleTexture: { - value: function(entryID, description, userInfo) { - // Save attribute entry - this.resources.setEntry(entryID, null, description); - return true; - } - }, - - handleError: { - value: function(msg) { - - throw new Error(msg); - return true; - } - }, - - _delegate: { - value: new LoadDelegate, - writable: true - }, - - delegate: { - enumerable: true, - get: function() { - return this._delegate; - }, - set: function(value) { - this._delegate = value; - } - } - }); - - - // Loader - - var Context = function(rootObj, callback) { - this.rootObj = rootObj; - this.callback = callback; - }; - - var rootObj = new THREE.Object3D(); - - var self = this; - - this.callback = callback; - this.rootObj = rootObj; - - this.loader = Object.create(ThreeGLTFLoader); - this.loader.initWithPath(url); - this.loader.load(new Context(rootObj, - function(obj) { - }), - null); - - return rootObj; -} - - -THREE.glTFLoader.prototype.scheduleLoad = function(loadFn, data) { - - this.loadRequests.push({fn: loadFn, data:data}); -} - -THREE.glTFLoader.prototype.loadAllAssets = function() { - - for (var i = 0, len = this.loadRequests.length; i < len; i++) { - var request = this.loadRequests[i]; - request.fn(request.data); - } -} - -THREE.glTFLoader.prototype.callLoadedCallback = function() { - var result = { - scene : this.rootObj, - cameras : this.loader.cameras, - animations : this.loader.animations, - shaders : this.loader.shaders, - }; - - this.callback(result); -} - -THREE.glTFLoader.prototype.checkComplete = function() { - if (this.meshesLoaded == this.meshesRequested - && this.shadersLoaded == this.shadersRequested - && this.animationsLoaded == this.animationsRequested) - { - for (var i = 0; i < this.pendingMeshes.length; i++) { - var pending = this.pendingMeshes[i]; - pending.mesh.attachToNode(pending.node); - } - - for (var i = 0; i < this.animationsLoaded; i++) { - var animation = this.animations[i]; - this.loader.buildAnimation(animation); - } - - this.loader.createAnimations(); - this.loader.createMeshAnimations(this.rootObj); - THREE.glTFShaders.bindShaderParameters(this.rootObj); - - this.callLoadedCallback(); - } -} diff --git a/examples/js/loaders/deprecated/gltf/glTFLoaderUtils.js b/examples/js/loaders/deprecated/gltf/glTFLoaderUtils.js deleted file mode 100644 index 930639505daf872cd40eb8f9447a5fbf3a74fbf5..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/glTFLoaderUtils.js +++ /dev/null @@ -1,315 +0,0 @@ -/** - * @author Tony Parisi / http://www.tonyparisi.com/ - */ - -THREE.GLTFLoaderUtils = Object.create(Object, { - - // errors - INVALID_PATH_ERROR: { value: "INVALID_PATH" }, - INVALID_TYPE_ERROR: { value: "INVALID_TYPE" }, - XMLHTTPREQUEST_STATUS_ERROR: { value: "XMLHTTPREQUEST_STATUS_ERROR" }, - // misc constants - ARRAY_BUFFER: { value: "ArrayBuffer" }, - // webgl constants (from https://www.opengl.org/registry/api/GL/glcorearb.h) - WEBGL_CONSTANTS: { - value: { - FLOAT: 5126, - FLOAT_MAT2: 35674, - FLOAT_MAT3: 35675, - FLOAT_MAT4: 35676, - FLOAT_VEC2: 35664, - FLOAT_VEC3: 35665, - FLOAT_VEC4: 35666, - LINEAR: 9729, - REPEAT: 10497, - SAMPLER_2D: 35678, - TRIANGLES: 4, - UNSIGNED_BYTE: 5121, - UNSIGNED_SHORT: 5123 - } - }, - - _streams : { value:{}, writable: true }, - - _streamsStatus: { value: {}, writable: true }, - - _resources: { value: {}, writable: true }, - - _resourcesStatus: { value: {}, writable: true }, - - // initialization - init: { - value: function() { - this._streams = {}; - this._streamsStatus = {}; - this._resources = {}; - this._resourcesStatus = {}; - } - }, - - //manage entries - _containsResource: { - enumerable: false, - value: function(resourceID) { - return this._resources[resourceID] ? true : false; - } - }, - - _storeResource: { - enumerable: false, - value: function(resourceID, resource) { - if (!resourceID) { - console.log("ERROR: entry does not contain id, cannot store"); - return; - } - - if (this._containsResource[resourceID]) { - console.log("WARNING: resource:"+resourceID+" is already stored, overriding"); - } - - this._resources[resourceID] = resource; - } - }, - - _getResource: { - enumerable: false, - value: function(resourceID) { - return this._resources[resourceID]; - } - }, - - _loadStream: { - value: function(path, type, delegate) { - - - - var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/; - - function decodeDataUriText(isBase64, data) { - var result = decodeURIComponent(data); - if (isBase64) { - return atob(result); - } - return result; - } - - function decodeDataUriArrayBuffer(isBase64, data) { - var byteString = decodeDataUriText(isBase64, data); - var buffer = new ArrayBuffer(byteString.length); - var view = new Uint8Array(buffer); - for (var i = 0; i < byteString.length; i++) { - view[i] = byteString.charCodeAt(i); - } - return buffer; - } - - function decodeDataUri(dataUriRegexResult, responseType) { - responseType = typeof responseType !== 'undefined' ? responseType : ''; - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; - - switch (responseType) { - case '': - case 'text': - return decodeDataUriText(isBase64, data); - case 'ArrayBuffer': - return decodeDataUriArrayBuffer(isBase64, data); - case 'blob': - var buffer = decodeDataUriArrayBuffer(isBase64, data); - return new Blob([buffer], { - type : mimeType - }); - case 'document': - var parser = new DOMParser(); - return parser.parseFromString(decodeDataUriText(isBase64, data), mimeType); - case 'json': - return JSON.parse(decodeDataUriText(isBase64, data)); - default: - throw 'Unhandled responseType: ' + responseType; - } - } - - var dataUriRegexResult = dataUriRegex.exec(path); - if (dataUriRegexResult !== null) { - delegate.streamAvailable(path, decodeDataUri(dataUriRegexResult, type)); - return; - } - - var self = this; - - if (!type) { - delegate.handleError(THREE.GLTFLoaderUtils.INVALID_TYPE_ERROR, null); - return; - } - - if (!path) { - delegate.handleError(THREE.GLTFLoaderUtils.INVALID_PATH_ERROR); - return; - } - - var xhr = new XMLHttpRequest(); - xhr.open('GET', path, true); - xhr.responseType = (type === THREE.GLTFLoaderUtils.ARRAY_BUFFER) ? "arraybuffer" : "text"; - - //if this is not specified, 1 "big blob" scenes fails to load. - xhr.setRequestHeader("If-Modified-Since", "Sat, 01 Jan 1970 00:00:00 GMT"); - xhr.onload = function(e) { - if ((xhr.status == 200) || (xhr.status == 206)) { - - delegate.streamAvailable(path, xhr.response); - - } else { - delegate.handleError(THREE.GLTFLoaderUtils.XMLHTTPREQUEST_STATUS_ERROR, this.status); - } - }; - xhr.send(null); - } - }, - - send: { value: 0, writable: true }, - requested: { value: 0, writable: true }, - - _handleRequest: { - value: function(request) { - var resourceStatus = this._resourcesStatus[request.id]; - if (resourceStatus) - { - this._resourcesStatus[request.id]++; - } - else - { - this._resourcesStatus[request.id] = 1; - } - - var streamStatus = this._streamsStatus[request.uri]; - if (streamStatus && streamStatus.status === "loading" ) - { - streamStatus.requests.push(request); - return; - } - - this._streamsStatus[request.uri] = { status : "loading", requests : [request] }; - - var self = this; - var processResourceDelegate = {}; - - processResourceDelegate.streamAvailable = function(path, res_) { - var streamStatus = self._streamsStatus[path]; - var requests = streamStatus.requests; - requests.forEach( function(req_) { - var subArray = res_.slice(req_.range[0], req_.range[1]); - var convertedResource = req_.delegate.convert(subArray, req_.ctx); - self._storeResource(req_.id, convertedResource); - req_.delegate.resourceAvailable(convertedResource, req_.ctx); - --self._resourcesStatus[req_.id]; - - }, this); - - delete self._streamsStatus[path]; - - }; - - processResourceDelegate.handleError = function(errorCode, info) { - request.delegate.handleError(errorCode, info); - } - - this._loadStream(request.uri, request.type, processResourceDelegate); - } - }, - - - _elementSizeForGLType: { - value: function(componentType, type) { - - var nElements = 0; - switch(type) { - case "SCALAR" : - nElements = 1; - break; - case "VEC2" : - nElements = 2; - break; - case "VEC3" : - nElements = 3; - break; - case "VEC4" : - nElements = 4; - break; - case "MAT2" : - nElements = 4; - break; - case "MAT3" : - nElements = 9; - break; - case "MAT4" : - nElements = 16; - break; - default : - debugger; - break; - } - - switch (componentType) { - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.FLOAT : - return Float32Array.BYTES_PER_ELEMENT * nElements; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.UNSIGNED_BYTE : - return Uint8Array.BYTES_PER_ELEMENT * nElements; - case THREE.GLTFLoaderUtils.WEBGL_CONSTANTS.UNSIGNED_SHORT : - return Uint16Array.BYTES_PER_ELEMENT * nElements; - default : - debugger; - return null; - } - } - }, - - _handleWrappedBufferViewResourceLoading: { - value: function(wrappedBufferView, delegate, ctx) { - var bufferView = wrappedBufferView.bufferView; - var buffer = bufferView.buffer; - var byteOffset = wrappedBufferView.byteOffset + bufferView.description.byteOffset; - var range = [byteOffset , (this._elementSizeForGLType(wrappedBufferView.componentType, wrappedBufferView.type) * wrappedBufferView.count) + byteOffset]; - - this._handleRequest({ "id" : wrappedBufferView.id, - "range" : range, - "type" : buffer.description.type, - "uri" : buffer.description.uri, - "delegate" : delegate, - "ctx" : ctx }, null); - } - }, - - getBuffer: { - - value: function(wrappedBufferView, delegate, ctx) { - - var savedBuffer = this._getResource(wrappedBufferView.id); - if (false) { // savedBuffer) { - return savedBuffer; - } else { - this._handleWrappedBufferViewResourceLoading(wrappedBufferView, delegate, ctx); - } - - return null; - } - }, - - getFile: { - - value: function(request, delegate, ctx) { - - request.delegate = delegate; - request.ctx = ctx; - - this._handleRequest({ "id" : request.id, - "uri" : request.uri, - "range" : [0], - "type" : "text", - "delegate" : delegate, - "ctx" : ctx }, null); - - return null; - } - }, -}); diff --git a/examples/js/loaders/deprecated/gltf/glTFShaders.js b/examples/js/loaders/deprecated/gltf/glTFShaders.js deleted file mode 100644 index e5a3c632bea04af9f8169d5562f1b056003092e1..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/glTFShaders.js +++ /dev/null @@ -1,145 +0,0 @@ -/** - * @author Tony Parisi / http://www.tonyparisi.com/ - */ - -THREE.glTFShaders = ( function () { - - var shaders = []; - - return { - add : function(shader) { - shaders.push(shader); - }, - - remove: function(shader) { - - var i = shaders.indexOf(shader); - - if ( i !== -1 ) { - shaders.splice( i, 1 ); - } - }, - - removeAll: function(shader) { - - // probably want to clean up the shaders, too, but not for now - shaders = []; - }, - - bindShaderParameters: function(scene) { - for (i = 0; i < shaders.length; i++) - { - shaders[i].bindParameters(scene); - } - }, - - update : function(scene, camera) { - for (i = 0; i < shaders.length; i++) - { - shaders[i].update(scene, camera); - } - }, - }; -})(); - -// Construction/initialization -THREE.glTFShader = function(material, params, object, scene) { - this.material = material; - this.parameters = params.technique.parameters; - this.uniforms = params.technique.uniforms; - this.joints = params.joints; - this.object = object; - this.semantics = {}; - this.m4 = new THREE.Matrix4; -} - - -// bindParameters - connect the uniform values to their source parameters -THREE.glTFShader.prototype.bindParameters = function(scene) { - - function findObject(o, p) { - if (o.glTFID == param.node) { - p.sourceObject = o; - } - } - - for (var uniform in this.uniforms) { - var pname = this.uniforms[uniform]; - var param = this.parameters[pname]; - if (param.semantic) { - - var p = { - semantic : param.semantic, - uniform: this.material.uniforms[uniform] - }; - - if (param.node) { - scene.traverse(function(o) { findObject(o, p)}); - } - else { - p.sourceObject = this.object; - } - - this.semantics[pname] = p; - - } - } - -} - -// Update - update all the uniform values -THREE.glTFShader.prototype.update = function(scene, camera) { - - // update scene graph - - scene.updateMatrixWorld(); - - // update camera matrices and frustum - camera.updateMatrixWorld(); - camera.matrixWorldInverse.getInverse( camera.matrixWorld ); - - for (var sname in this.semantics) { - var semantic = this.semantics[sname]; - if (semantic) { - switch (semantic.semantic) { - case "MODELVIEW" : - var m4 = semantic.uniform.value; - m4.multiplyMatrices(camera.matrixWorldInverse, - semantic.sourceObject.matrixWorld); - break; - - case "MODELVIEWINVERSETRANSPOSE" : - var m3 = semantic.uniform.value; - this.m4.multiplyMatrices(camera.matrixWorldInverse, - semantic.sourceObject.matrixWorld); - m3.getNormalMatrix(this.m4); - break; - - case "PROJECTION" : - var m4 = semantic.uniform.value; - m4.copy(camera.projectionMatrix); - break; - - case "JOINTMATRIX" : - - var m4v = semantic.uniform.value; - for (var mi = 0; mi < m4v.length; mi++) { - // So it goes like this: - // SkinnedMesh world matrix is already baked into MODELVIEW; - // ransform joints to local space, - // then transform using joint's inverse - m4v[mi].getInverse(semantic.sourceObject.matrixWorld). - multiply(this.joints[mi].matrixWorld). - multiply(this.object.skeleton.boneInverses[mi]); - } - - //console.log("Joint:", semantic) - break; - - default : - throw new Error("Unhandled shader semantic" + semantic); - break; - } - } - } -} diff --git a/examples/js/loaders/deprecated/gltf/gltfUtilities.js b/examples/js/loaders/deprecated/gltf/gltfUtilities.js deleted file mode 100644 index f8db06647a74d482ef5c7535d175fc39c7779c10..0000000000000000000000000000000000000000 --- a/examples/js/loaders/deprecated/gltf/gltfUtilities.js +++ /dev/null @@ -1,204 +0,0 @@ -/** -gltfUtilities -@license -The MIT License (MIT) -Copyright (c) 2014 Analytical Graphics, Inc. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -*/ -(function(root, factory) { - "use strict"; - /*global define*/ - if (typeof define === 'function' && define.amd) { - // AMD. Register as an anonymous module. - define([], factory); - } else { - // Browser globals - root.gltfUtilities = factory(); - } -}(this, function() { - "use strict"; - - /** - * Given a URL, determine whether that URL is considered cross-origin to the current page. - */ - var isCrossOriginUrl = function(url) { - var location = window.location; - var a = document.createElement('a'); - - a.href = url; - - // host includes both hostname and port if the port is not standard - return location.protocol !== a.protocol || location.host !== a.host; - }; - - var isDataUriRegex = /^data:/; - - /** - * Asynchronously loads the given image URL. Attempts to load cross-origin images using CORS. - * - * @param {String} url The source of the image. - * @param {Function} success A function that will be called with an Image object - * once the image has loaded successfully. - * @param {Function} [error] A function that will be called if the request fails. - * - * @see Cross-Origin Resource Sharing - */ - var loadImage = function(url, success, error) { - var image = new Image(); - - image.onload = function() { - success(image); - }; - - if (typeof error !== 'undefined') { - image.onerror = error; - } - - var crossOrigin; - if (isDataUriRegex.test(url)) { - crossOrigin = false; - } else { - crossOrigin = isCrossOriginUrl(url); - } - - if (crossOrigin) { - image.crossOrigin = ''; - } - - image.src = url; - }; - - var dataUriRegex = /^data:(.*?)(;base64)?,(.*)$/; - - function decodeDataUriText(isBase64, data) { - var result = decodeURIComponent(data); - if (isBase64) { - return atob(result); - } - return result; - } - - function decodeDataUriArrayBuffer(isBase64, data) { - var byteString = decodeDataUriText(isBase64, data); - var buffer = new ArrayBuffer(byteString.length); - var view = new Uint8Array(buffer); - for (var i = 0; i < byteString.length; i++) { - view[i] = byteString.charCodeAt(i); - } - return buffer; - } - - function decodeDataUri(dataUriRegexResult, responseType) { - responseType = typeof responseType !== 'undefined' ? responseType : ''; - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; - - switch (responseType) { - case '': - case 'text': - return decodeDataUriText(isBase64, data); - case 'arraybuffer': - return decodeDataUriArrayBuffer(isBase64, data); - case 'blob': - var buffer = decodeDataUriArrayBuffer(isBase64, data); - return new Blob([buffer], { - type : mimeType - }); - case 'document': - var parser = new DOMParser(); - return parser.parseFromString(decodeDataUriText(isBase64, data), mimeType); - case 'json': - return JSON.parse(decodeDataUriText(isBase64, data)); - default: - throw 'Unhandled responseType: ' + responseType; - } - } - - var loadWithXhr = function(url, responseType, success, error) { - var dataUriRegexResult = dataUriRegex.exec(url); - if (dataUriRegexResult !== null) { - success(decodeDataUri(dataUriRegexResult, responseType)); - return; - } - - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - - if (typeof responseType !== 'undefined') { - xhr.responseType = responseType; - } - - xhr.onload = function(e) { - if (xhr.status === 200) { - success(xhr.response); - } else { - error(xhr); - } - }; - - xhr.onerror = function(e) { - error(xhr); - }; - - xhr.send(); - }; - - /** - * Asynchronously loads the given URL as raw binary data. The data is loaded - * using XMLHttpRequest, which means that in order to make requests to another origin, - * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. - * - * @param {String} url The URL of the binary data. - * @param {Function} success A function that will be called with an ArrayBuffer object - * once the data has loaded successfully. - * @param {Function} [error] A function that will be called with the XMLHttpRequest object - * if the request fails. - * - * @see XMLHttpRequest - * @see Cross-Origin Resource Sharing - */ - var loadArrayBuffer = function(url, success, error) { - loadWithXhr(url, 'arraybuffer', success, error); - }; - - /** - * Asynchronously loads the given URL as text. The data is loaded - * using XMLHttpRequest, which means that in order to make requests to another origin, - * the server must have Cross-Origin Resource Sharing (CORS) headers enabled. - * - * @param {String} url The URL to request. - * @param {Function} success A function that will be called with a String - * once the data has loaded successfully. - * @param {Function} [error] A function that will be called with the XMLHttpRequest object - * if the request fails. - * - * @see XMLHttpRequest - * @see Cross-Origin Resource Sharing - */ - var loadText = function(url, success, error) { - return loadWithXhr(url, undefined, success, error); - }; - - return { - loadImage : loadImage, - loadArrayBuffer : loadArrayBuffer, - loadText : loadText - }; -})); - - diff --git a/examples/js/loaders/sea3d/SEA3D.js b/examples/js/loaders/sea3d/SEA3D.js index 5fde2f8845149f44ec4f5796f594b3ed0a123398..55cab4b6e63e8095377152016c8875a048602668 100644 --- a/examples/js/loaders/sea3d/SEA3D.js +++ b/examples/js/loaders/sea3d/SEA3D.js @@ -5,9 +5,9 @@ 'use strict'; -var SEA3D = { VERSION : 18000 } +var SEA3D = { VERSION: 18100 }; -SEA3D.getVersion = function() { +SEA3D.getVersion = function () { // Max = 16777215 - VVSSBB | V = Version | S = Subversion | B = Buildversion var v = SEA3D.VERSION.toString(), l = v.length; @@ -21,7 +21,7 @@ console.log( 'SEA3D ' + SEA3D.getVersion() ); // STREAM : STANDARD DATA-IO ( LITTLE-ENDIAN ) // -SEA3D.Stream = function( buffer ) { +SEA3D.Stream = function ( buffer ) { this.position = 0; this.buffer = buffer || new ArrayBuffer(); @@ -87,7 +87,7 @@ SEA3D.Stream.INTERPOLATION_TABLE = [ "bounce.in", "bounce.out", "bounce.inout" ]; -SEA3D.Stream.sizeOf = function( kind ) { +SEA3D.Stream.sizeOf = function ( kind ) { if ( kind == 0 ) return 0; else if ( kind >= 1 && kind <= 31 ) return 1; @@ -101,7 +101,7 @@ SEA3D.Stream.sizeOf = function( kind ) { SEA3D.Stream.prototype = { constructor: SEA3D.Stream, - set buffer ( val ) { + set buffer( val ) { this.buf = val; this.length = val.byteLength; @@ -109,26 +109,26 @@ SEA3D.Stream.prototype = { }, - get buffer () { + get buffer() { return this.buf; }, - get bytesAvailable () { + get bytesAvailable() { return this.length - this.position; } }; -SEA3D.Stream.prototype.getByte = function( pos ) { +SEA3D.Stream.prototype.getByte = function ( pos ) { return this.data.getInt8( pos ); }; -SEA3D.Stream.prototype.readBytes = function( len ) { +SEA3D.Stream.prototype.readBytes = function ( len ) { var buf = this.buf.slice( this.position, this.position + len ); this.position += len; @@ -136,25 +136,25 @@ SEA3D.Stream.prototype.readBytes = function( len ) { }; -SEA3D.Stream.prototype.readByte = function() { +SEA3D.Stream.prototype.readByte = function () { return this.data.getInt8( this.position ++ ); }; -SEA3D.Stream.prototype.readUByte = function() { +SEA3D.Stream.prototype.readUByte = function () { return this.data.getUint8( this.position ++ ); }; -SEA3D.Stream.prototype.readBool = function() { +SEA3D.Stream.prototype.readBool = function () { return this.data.getInt8( this.position ++ ) != 0; }; -SEA3D.Stream.prototype.readShort = function() { +SEA3D.Stream.prototype.readShort = function () { var v = this.data.getInt16( this.position, true ); this.position += 2; @@ -162,7 +162,7 @@ SEA3D.Stream.prototype.readShort = function() { }; -SEA3D.Stream.prototype.readUShort = function() { +SEA3D.Stream.prototype.readUShort = function () { var v = this.data.getUint16( this.position, true ); this.position += 2; @@ -170,7 +170,7 @@ SEA3D.Stream.prototype.readUShort = function() { }; -SEA3D.Stream.prototype.readUInt24 = function() { +SEA3D.Stream.prototype.readUInt24 = function () { var v = this.data.getUint32( this.position, true ) & 0xFFFFFF; this.position += 3; @@ -178,13 +178,13 @@ SEA3D.Stream.prototype.readUInt24 = function() { }; -SEA3D.Stream.prototype.readUInt24F = function() { +SEA3D.Stream.prototype.readUInt24F = function () { return this.readUShort() | ( this.readUByte() << 16 ); }; -SEA3D.Stream.prototype.readInt = function() { +SEA3D.Stream.prototype.readInt = function () { var v = this.data.getInt32( this.position, true ); this.position += 4; @@ -192,7 +192,7 @@ SEA3D.Stream.prototype.readInt = function() { }; -SEA3D.Stream.prototype.readUInt = function() { +SEA3D.Stream.prototype.readUInt = function () { var v = this.data.getUint32( this.position, true ); this.position += 4; @@ -200,7 +200,7 @@ SEA3D.Stream.prototype.readUInt = function() { }; -SEA3D.Stream.prototype.readFloat = function() { +SEA3D.Stream.prototype.readFloat = function () { var v = this.data.getFloat32( this.position, true ); this.position += 4; @@ -208,7 +208,7 @@ SEA3D.Stream.prototype.readFloat = function() { }; -SEA3D.Stream.prototype.readUInteger = function() { +SEA3D.Stream.prototype.readUInteger = function () { var v = this.readUByte(), r = v & 0x7F; @@ -231,25 +231,25 @@ SEA3D.Stream.prototype.readUInteger = function() { }; -SEA3D.Stream.prototype.readVector2 = function() { +SEA3D.Stream.prototype.readVector2 = function () { - return { x: this.readFloat(), y: this.readFloat() } + return { x: this.readFloat(), y: this.readFloat() }; }; -SEA3D.Stream.prototype.readVector3 = function() { +SEA3D.Stream.prototype.readVector3 = function () { - return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() } + return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat() }; }; -SEA3D.Stream.prototype.readVector4 = function() { +SEA3D.Stream.prototype.readVector4 = function () { - return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), w: this.readFloat() } + return { x: this.readFloat(), y: this.readFloat(), z: this.readFloat(), w: this.readFloat() }; }; -SEA3D.Stream.prototype.readMatrix = function() { +SEA3D.Stream.prototype.readMatrix = function () { var mtx = new Float32Array( 16 ); @@ -274,37 +274,39 @@ SEA3D.Stream.prototype.readMatrix = function() { }; -SEA3D.Stream.prototype.readUTF = function( len ) { +SEA3D.Stream.prototype.readUTF8 = function ( len ) { - return String.fromCharCode.apply( undefined, new Uint16Array( new Uint8Array( this.readBytes( len ) ) ) ); + var buffer = this.readBytes( len ); + + return window.TextDecoder ? new TextDecoder().decode( buffer ) : String.fromCharCode.apply( undefined, new Uint16Array( new Uint8Array( buffer ) ) ); }; -SEA3D.Stream.prototype.readExt = function() { +SEA3D.Stream.prototype.readExt = function () { - return this.readUTF( 4 ).replace( /\0/g, "" ); + return this.readUTF8( 4 ).replace( /\0/g, "" ); }; -SEA3D.Stream.prototype.readUTF8 = function() { +SEA3D.Stream.prototype.readUTF8Tiny = function () { - return this.readUTF( this.readUByte() ); + return this.readUTF8( this.readUByte() ); }; -SEA3D.Stream.prototype.readUTF8Short = function() { +SEA3D.Stream.prototype.readUTF8Short = function () { - return this.readUTF( this.readUShort() ); + return this.readUTF8( this.readUShort() ); }; -SEA3D.Stream.prototype.readUTF8Long = function() { +SEA3D.Stream.prototype.readUTF8Long = function () { - return this.readUTF( this.readUInt() ); + return this.readUTF8( this.readUInt() ); }; -SEA3D.Stream.prototype.readUByteArray = function( length ) { +SEA3D.Stream.prototype.readUByteArray = function ( length ) { var v = new Uint8Array( length ); @@ -322,7 +324,7 @@ SEA3D.Stream.prototype.readUByteArray = function( length ) { }; -SEA3D.Stream.prototype.readUShortArray = function( length ) { +SEA3D.Stream.prototype.readUShortArray = function ( length ) { var v = new Uint16Array( length ), len = length * 2; @@ -342,7 +344,7 @@ SEA3D.Stream.prototype.readUShortArray = function( length ) { }; -SEA3D.Stream.prototype.readUInt24Array = function( length ) { +SEA3D.Stream.prototype.readUInt24Array = function ( length ) { var v = new Uint32Array( length ); @@ -357,7 +359,7 @@ SEA3D.Stream.prototype.readUInt24Array = function( length ) { }; -SEA3D.Stream.prototype.readUIntArray = function( length ) { +SEA3D.Stream.prototype.readUIntArray = function ( length ) { var v = new Uint32Array( length ), len = length * 4; @@ -376,7 +378,7 @@ SEA3D.Stream.prototype.readUIntArray = function( length ) { }; -SEA3D.Stream.prototype.readFloatArray = function( length ) { +SEA3D.Stream.prototype.readFloatArray = function ( length ) { var v = new Float32Array( length ), len = length * 4; @@ -396,19 +398,19 @@ SEA3D.Stream.prototype.readFloatArray = function( length ) { }; -SEA3D.Stream.prototype.readBlendMode = function() { +SEA3D.Stream.prototype.readBlendMode = function () { return SEA3D.Stream.BLEND_MODE[ this.readUByte() ]; }; -SEA3D.Stream.prototype.readInterpolation = function() { +SEA3D.Stream.prototype.readInterpolation = function () { return SEA3D.Stream.INTERPOLATION_TABLE[ this.readUByte() ]; }; -SEA3D.Stream.prototype.readTags = function( callback ) { +SEA3D.Stream.prototype.readTags = function ( callback ) { var numTag = this.readUByte(); @@ -418,7 +420,7 @@ SEA3D.Stream.prototype.readTags = function( callback ) { var size = this.readUInt(); var pos = this.position; - callback( kind, data, size ); + callback( kind, this, size ); this.position = pos += size; @@ -426,7 +428,7 @@ SEA3D.Stream.prototype.readTags = function( callback ) { }; -SEA3D.Stream.prototype.readProperties = function( sea3d ) { +SEA3D.Stream.prototype.readProperties = function ( sea3d ) { var count = this.readUByte(), props = {}, types = {}; @@ -435,11 +437,11 @@ SEA3D.Stream.prototype.readProperties = function( sea3d ) { for ( var i = 0; i < count; i ++ ) { - var name = this.readUTF8(), + var name = this.readUTF8Tiny(), type = this.readUByte(); - props[ name ] = this.readToken( type, sea3d ); types[ name ] = type; + props[ name ] = type == SEA3D.Stream.GROUP ? this.readProperties( sea3d ) : this.readToken( type, sea3d ); } @@ -447,7 +449,7 @@ SEA3D.Stream.prototype.readProperties = function( sea3d ) { }; -SEA3D.Stream.prototype.readAnimationList = function( sea3d ) { +SEA3D.Stream.prototype.readAnimationList = function ( sea3d ) { var list = [], count = this.readUByte(); @@ -472,7 +474,7 @@ SEA3D.Stream.prototype.readAnimationList = function( sea3d ) { }; -SEA3D.Stream.prototype.readScriptList = function( sea3d ) { +SEA3D.Stream.prototype.readScriptList = function ( sea3d ) { var list = [], count = this.readUByte(); @@ -493,7 +495,7 @@ SEA3D.Stream.prototype.readScriptList = function( sea3d ) { for ( var j = 0; j < numParams; j ++ ) { - var name = this.readUTF8(); + var name = this.readUTF8Tiny(); script.params[ name ] = this.readObject( sea3d ); @@ -503,7 +505,7 @@ SEA3D.Stream.prototype.readScriptList = function( sea3d ) { if ( attrib & 8 ) { - script.method = this.readUTF8(); + script.method = this.readUTF8Tiny(); } @@ -517,16 +519,16 @@ SEA3D.Stream.prototype.readScriptList = function( sea3d ) { }; -SEA3D.Stream.prototype.readObject = function( sea3d ) { +SEA3D.Stream.prototype.readObject = function ( sea3d ) { return this.readToken( this.readUByte(), sea3d ); }; -SEA3D.Stream.prototype.readToken = function( type, sea3d ) { +SEA3D.Stream.prototype.readToken = function ( type, sea3d ) { + + switch ( type ) { - switch ( type ) - { // 1D case SEA3D.Stream.BOOLEAN: return this.readBool(); @@ -568,7 +570,7 @@ SEA3D.Stream.prototype.readToken = function( type, sea3d ) { // Undefined Values case SEA3D.Stream.STRING_TINY: - return this.readUTF8(); + return this.readUTF8Tiny(); break; case SEA3D.Stream.STRING_SHORT: @@ -577,7 +579,7 @@ SEA3D.Stream.prototype.readToken = function( type, sea3d ) { case SEA3D.Stream.STRING_LONG: return this.readUTF8Long(); - break + break; case SEA3D.Stream.ASSET: var asset = this.readUInt(); @@ -586,21 +588,21 @@ SEA3D.Stream.prototype.readToken = function( type, sea3d ) { default: console.error( "DataType not found!" ); - break; + } return null; }; -SEA3D.Stream.prototype.readVector = function( type, length, offset ) { +SEA3D.Stream.prototype.readVector = function ( type, length, offset ) { var size = SEA3D.Stream.sizeOf( type ), i = offset * size, count = i + ( length * size ); - switch ( type ) - { + switch ( type ) { + // 1D case SEA3D.Stream.BOOLEAN: @@ -647,7 +649,7 @@ SEA3D.Stream.prototype.readVector = function( type, length, offset ) { }; -SEA3D.Stream.prototype.append = function( data ) { +SEA3D.Stream.prototype.append = function ( data ) { var tmp = new ArrayBuffer( this.data.byteLength + data.byteLength ); tmp.set( new ArrayBuffer( this.data ), 0 ); @@ -656,7 +658,7 @@ SEA3D.Stream.prototype.append = function( data ) { }; -SEA3D.Stream.prototype.concat = function( position, length ) { +SEA3D.Stream.prototype.concat = function ( position, length ) { return new SEA3D.Stream( this.buffer.slice( position, position + length ) ); @@ -666,7 +668,7 @@ SEA3D.Stream.prototype.concat = function( position, length ) { * @author DataStream.js */ -SEA3D.Stream.memcpy = function( dst, dstOffset, src, srcOffset, byteLength ) { +SEA3D.Stream.memcpy = function ( dst, dstOffset, src, srcOffset, byteLength ) { var dstU8 = new Uint8Array( dst, dstOffset, byteLength ); var srcU8 = new Uint8Array( src, srcOffset, byteLength ); @@ -679,7 +681,7 @@ SEA3D.Stream.memcpy = function( dst, dstOffset, src, srcOffset, byteLength ) { // UByteArray // -SEA3D.UByteArray = function() { +SEA3D.UByteArray = function () { this.ubytes = []; this.length = 0; @@ -689,14 +691,14 @@ SEA3D.UByteArray = function() { SEA3D.UByteArray.prototype = { constructor: SEA3D.UByteArray, - add : function( ubytes ) { + add: function ( ubytes ) { this.ubytes.push( ubytes ); this.length += ubytes.byteLength; }, - toBuffer : function() { + toBuffer: function () { var memcpy = new Uint8Array( this.length ); @@ -717,11 +719,11 @@ SEA3D.UByteArray.prototype = { // SEA3D.Math = { - DEGREES : 180 / Math.PI, - RADIANS : Math.PI / 180 + DEGREES: 180 / Math.PI, + RADIANS: Math.PI / 180 }; -SEA3D.Math.angle = function( val ) { +SEA3D.Math.angle = function ( val ) { var ang = 180, inv = val < 0; @@ -738,7 +740,7 @@ SEA3D.Math.angle = function( val ) { }; -SEA3D.Math.lerpAngle = function( val, tar, t ) { +SEA3D.Math.lerpAngle = function ( val, tar, t ) { if ( Math.abs( val - tar ) > 180 ) { @@ -746,8 +748,7 @@ SEA3D.Math.lerpAngle = function( val, tar, t ) { tar += 360; - } - else { + } else { tar -= 360; @@ -761,7 +762,7 @@ SEA3D.Math.lerpAngle = function( val, tar, t ) { }; -SEA3D.Math.lerpColor = function( val, tar, t ) { +SEA3D.Math.lerpColor = function ( val, tar, t ) { var a0 = val >> 24 & 0xff, r0 = val >> 16 & 0xff, @@ -782,19 +783,19 @@ SEA3D.Math.lerpColor = function( val, tar, t ) { }; -SEA3D.Math.lerp = function( val, tar, t ) { +SEA3D.Math.lerp = function ( val, tar, t ) { return val + ( ( tar - val ) * t ); }; -SEA3D.Math.lerp1x = function( val, tar, t ) { +SEA3D.Math.lerp1x = function ( val, tar, t ) { val[ 0 ] += ( tar[ 0 ] - val[ 0 ] ) * t; }; -SEA3D.Math.lerp3x = function( val, tar, t ) { +SEA3D.Math.lerp3x = function ( val, tar, t ) { val[ 0 ] += ( tar[ 0 ] - val[ 0 ] ) * t; val[ 1 ] += ( tar[ 1 ] - val[ 1 ] ) * t; @@ -802,19 +803,19 @@ SEA3D.Math.lerp3x = function( val, tar, t ) { }; -SEA3D.Math.lerpAng1x = function( val, tar, t ) { +SEA3D.Math.lerpAng1x = function ( val, tar, t ) { val[ 0 ] = SEA3D.Math.lerpAngle( val[ 0 ], tar[ 0 ], t ); }; -SEA3D.Math.lerpColor1x = function( val, tar, t ) { +SEA3D.Math.lerpColor1x = function ( val, tar, t ) { val[ 0 ] = SEA3D.Math.lerpColor( val[ 0 ], tar[ 0 ], t ); }; -SEA3D.Math.lerpQuat4x = function( val, tar, t ) { +SEA3D.Math.lerpQuat4x = function ( val, tar, t ) { var x1 = val[ 0 ], y1 = val[ 1 ], @@ -855,7 +856,7 @@ SEA3D.Math.lerpQuat4x = function( val, tar, t ) { // Timer // -SEA3D.Timer = function() { +SEA3D.Timer = function () { this.time = this.start = Date.now(); @@ -864,25 +865,25 @@ SEA3D.Timer = function() { SEA3D.Timer.prototype = { constructor: SEA3D.Timer, - get now () { + get now() { return Date.now(); }, - get deltaTime () { + get deltaTime() { return Date.now() - this.time; }, - get elapsedTime () { + get elapsedTime() { return Date.now() - this.start; }, - update: function() { + update: function () { this.time = Date.now(); @@ -893,7 +894,7 @@ SEA3D.Timer.prototype = { // Object // -SEA3D.Object = function( name, data, type, sea3d ) { +SEA3D.Object = function ( name, data, type, sea3d ) { this.name = name; this.data = data; @@ -906,7 +907,7 @@ SEA3D.Object = function( name, data, type, sea3d ) { // Geometry Base // -SEA3D.GeometryBase = function( name, data, sea3d ) { +SEA3D.GeometryBase = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -929,11 +930,11 @@ SEA3D.GeometryBase = function( name, data, sea3d ) { // Geometry // -SEA3D.Geometry = function( name, data, sea3d ) { +SEA3D.Geometry = function ( name, data, sea3d ) { SEA3D.GeometryBase.call( this, name, data, sea3d ); - var i, j, vec, len; + var i, j, len; // NORMAL if ( this.attrib & 4 ) { @@ -1012,8 +1013,8 @@ SEA3D.Geometry = function( name, data, sea3d ) { j = data.readVInt() * 3; this.groups.push( { - start : len, - count : j, + start: len, + count: j, } ); len += j; @@ -1033,8 +1034,8 @@ SEA3D.Geometry = function( name, data, sea3d ) { len = data.readVInt() * 3; this.groups.push( { - start : j, - count : len, + start: j, + count: len, } ); j += len; @@ -1054,325 +1055,11 @@ SEA3D.Geometry.prototype.constructor = SEA3D.Geometry; SEA3D.Geometry.prototype.type = "geo"; -// -// Geometry Delta Base -// - -SEA3D.GeometryDeltaBase = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.attrib = data.readUShort(); - - this.numVertex = data.readUInteger(); - - this.length = this.numVertex * 3; - - if ( this.attrib & 1 ) { - - data.readNumber = data.readByte; - this.numDiv = 0xFF / 2; - - } - else { - - data.readNumber = data.readShort; - numDiv = 0xFFFF / 2; - - } - -}; - -// -// Geometry Delta -// - -SEA3D.GeometryDelta = function( name, data, sea3d ) { - - SEA3D.GeometryDeltaBase.call( this, name, data, sea3d ); - - var i, j, start, delta, len, vec; - - // NORMAL - if ( this.attrib & 4 ) { - - delta = data.readFloat(); - - this.normal = new Float32Array( this.length ); - - i = 0; - while ( i < this.length ) { - - this.normal[ i ++ ] = ( data.readNumber() / this.numDiv ) * delta; - - } - - } - - // TANGENT - if ( this.attrib & 8 ) { - - delta = data.readFloat(); - - this.tangent = new Float32Array( this.length ); - - i = 0; - while ( i < this.length ) { - - this.tangent[ i ++ ] = ( data.readNumber() / this.numDiv ) * delta; - - } - - } - - // UV - if ( this.attrib & 32 ) { - - this.uv = []; - this.uv.length = data.readUByte(); - - var uvLen = this.numVertex * 2; - - i = 0; - while ( i < this.uv.length ) { - - // UV VERTEX DATA - delta = data.readFloat(); - this.uv[ i ++ ] = vec = new Float32Array( uvLen ); - - j = 0; - while ( j < uvLen ) { - - vec[ j ++ ] = ( data.readNumber() / this.numDiv ) * delta; - - } - - } - - } - - // JOINT-INDEXES / WEIGHTS - if ( this.attrib & 64 ) { - - this.jointPerVertex = data.readUByte(); - - var jntLen = this.numVertex * this.jointPerVertex; - - this.joint = new Uint16Array( jntLen ); - this.weight = new Float32Array( jntLen ); - - i = 0; - while ( i < jntLen ) { - - this.joint[ i ++ ] = data.readUInteger(); - - } - - i = 0; - while ( i < jntLen ) { - - this.weight[ i ++ ] = ( data.readNumber() / this.numDiv ) * 1; - - } - - } - - // VERTEX_COLOR - if ( this.attrib & 128 ) { - - var colorAttrib = data.readUByte(), - numColorData = ( ( ( colorAttrib & 64 ) >> 6 ) | ( ( colorAttrib & 128 ) >> 6 ) ) + 1, - colorCount = this.numVertex * 4; - - this.color = []; - this.color.length = colorAttrib & 15; - - this.numColor = 4; - - for ( i = 0; i < this.color.length; i ++ ) { - - var vColor = new Float32Array( colorCount ); - - switch ( numColorData ) - { - case 1: - j = 0; - while ( j < colorCount ) { - - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = 0; - vColor[ j ++ ] = 0; - vColor[ j ++ ] = 1; - - } - break; - - case 2: - j = 0; - while ( j < colorCount ) { - - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = 0; - vColor[ j ++ ] = 1; - - } - break; - - case 3: - j = 0; - while ( j < colorCount ) { - - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = 1; - - } - break; - - case 4: - j = 0; - while ( j < colorCount ) { - - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - vColor[ j ++ ] = data.readUByte() / 0xFF; - - } - break; - } - - this.color[ i ] = vColor; - - } - - } - - // VERTEX - delta = data.readFloat(); - - this.vertex = new Float32Array( this.length ); - - i = 0; - while ( i < this.length ) { - - this.vertex[ i ++ ] = ( data.readNumber() / this.numDiv ) * delta; - - } - - // SUB-MESHES - var count = data.readUByte(); - - this.indexes = vec = []; - this.groups = []; - - // INDEXES - j = 0; - for ( i = 0; i < count; i ++ ) { - - len = data.readVInt() * 3; - - this.groups.push( { - start : j, - count : len, - } ); - - len += j; - while ( j < len ) { - - vec[ j ++ ] = data.readVInt(); - - } - - } - - // SUB-MESHES - var count = data.readUByte(); - - this.indexes = vec = []; - this.groups = []; - - // INDEXES - if ( this.attrib & 2 ) { - - // POLYGON - for ( i = 0; i < count; i ++ ) { - - len = data.readUInteger(); - - start = vec.length; - - for ( j = 0; j < len; j ++ ) { - - var a = data.readUInteger(), - b = data.readUInteger(), - c = data.readUInteger(), - d = data.readUInteger(); - - - vec.push( a ); - vec.push( b ); - vec.push( c ); - - if ( d > 0 ) - { - - vec.push( c ); - vec.push( d + 1 ); - vec.push( a ); - - } - else continue; - - } - - this.groups.push( { - start : start, - count : vec.length - start, - } ); - - } - - } else { - - // TRIANGLE - j = 0; - for ( i = 0; i < count; i ++ ) { - - len = data.readUInteger() * 3; - - this.groups.push( { - start : j, - count : len, - } ); - - len += j; - while ( j < len ) { - - vec[ j ++ ] = data.readUInteger(); - - } - - } - - } - -}; - -SEA3D.GeometryDeltaBase.prototype = Object.create( SEA3D.GeometryDeltaBase.prototype ); -SEA3D.GeometryDeltaBase.prototype.constructor = SEA3D.GeometryDelta; - -SEA3D.GeometryDelta.prototype.type = "geDL"; - // // Object3D // -SEA3D.Object3D = function( name, data, sea3d ) { +SEA3D.Object3D = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1389,20 +1076,20 @@ SEA3D.Object3D = function( name, data, sea3d ) { if ( this.attrib & 4 ) this.scripts = data.readScriptList( sea3d ); - if ( this.attrib & 16 ) this.properties = sea3d.getObject( data.readUInt() ); + if ( this.attrib & 16 ) this.attributes = sea3d.getObject( data.readUInt() ); if ( this.attrib & 32 ) { var objectType = data.readUByte(); this.isStatic = ( objectType & 1 ) != 0; - this.visible = ( objectType & 2 ) != 0; + this.visible = ( objectType & 2 ) == 0; } }; -SEA3D.Object3D.prototype.readTag = function( kind, data, size ) { +SEA3D.Object3D.prototype.readTag = function ( kind, data, size ) { }; @@ -1410,7 +1097,7 @@ SEA3D.Object3D.prototype.readTag = function( kind, data, size ) { // Entity3D // -SEA3D.Entity3D = function( name, data, sea3d ) { +SEA3D.Entity3D = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1433,7 +1120,7 @@ SEA3D.Entity3D.prototype.constructor = SEA3D.Entity3D; // Sound3D // -SEA3D.Sound3D = function( name, data, sea3d ) { +SEA3D.Sound3D = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1453,7 +1140,7 @@ SEA3D.Sound3D.prototype.constructor = SEA3D.Sound3D; // Sound Point // -SEA3D.SoundPoint = function( name, data, sea3d ) { +SEA3D.SoundPoint = function ( name, data, sea3d ) { SEA3D.Sound3D.call( this, name, data, sea3d ); @@ -1473,7 +1160,7 @@ SEA3D.SoundPoint.prototype.type = "sp"; // Container3D // -SEA3D.Container3D = function( name, data, sea3d ) { +SEA3D.Container3D = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1488,27 +1175,65 @@ SEA3D.Container3D.prototype.constructor = SEA3D.Container3D; SEA3D.Container3D.prototype.type = "c3d"; +// +// Script URL +// + +SEA3D.ScriptURL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.url = data.readUTF8( data.length ); + +}; + +SEA3D.ScriptURL.prototype.type = "src"; + // // Texture URL // -SEA3D.TextureURL = function( name, data, sea3d ) { +SEA3D.TextureURL = function ( name, data, sea3d ) { this.name = name; this.data = data; this.sea3d = sea3d; - this.url = data.readUTF( data.length ); + this.url = data.readUTF8( data.length ); }; SEA3D.TextureURL.prototype.type = "urlT"; +// +// CubeMap URL +// + +SEA3D.CubeMapURL = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + this.faces = []; + + for ( var i = 0; i < 6; i ++ ) { + + this.faces[ i ] = data.readUTF8Tiny(); + + } + +}; + +SEA3D.CubeMapURL.prototype.type = "cURL"; + // // Actions // -SEA3D.Actions = function( name, data, sea3d ) { +SEA3D.Actions = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1551,8 +1276,7 @@ SEA3D.Actions = function( name, data, sea3d ) { act.intrplParam0 = data.readFloat(); - } - else if ( act.intrpl.indexOf( 'elastic.' ) == 0 ) { + } else if ( act.intrpl.indexOf( 'elastic.' ) == 0 ) { act.intrplParam0 = data.readFloat(); act.intrplParam1 = data.readFloat(); @@ -1562,6 +1286,7 @@ SEA3D.Actions = function( name, data, sea3d ) { } switch ( kind ) { + case SEA3D.Actions.RTT_TARGET: act.source = sea3d.getObject( data.readUInt() ); act.target = sea3d.getObject( data.readUInt() ); @@ -1579,7 +1304,7 @@ SEA3D.Actions = function( name, data, sea3d ) { case SEA3D.Actions.PLAY_ANIMATION: act.object = sea3d.getObject( data.readUInt() ); - act.name = data.readUTF8(); + act.name = data.readUTF8Tiny(); break; case SEA3D.Actions.FOG: @@ -1608,9 +1333,14 @@ SEA3D.Actions = function( name, data, sea3d ) { act.classof = sea3d.getObject( data.readUInt() ); break; + case SEA3D.Actions.ATTRIBUTES: + act.attributes = sea3d.getObject( data.readUInt() ); + break; + default: console.log( "Action \"" + kind + "\" not found." ); break; + } data.position = position + size; @@ -1631,6 +1361,7 @@ SEA3D.Actions.RTT_TARGET = 8; SEA3D.Actions.CAMERA = 9; SEA3D.Actions.SCRIPTS = 10; SEA3D.Actions.CLASS_OF = 11; +SEA3D.Actions.ATTRIBUTES = 12; SEA3D.Actions.prototype.type = "act"; @@ -1638,7 +1369,7 @@ SEA3D.Actions.prototype.type = "act"; // Properties // -SEA3D.Properties = function( name, data, sea3d ) { +SEA3D.Properties = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1655,7 +1386,7 @@ SEA3D.Properties.prototype.type = "prop"; // File Info // -SEA3D.FileInfo = function( name, data, sea3d ) { +SEA3D.FileInfo = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1674,13 +1405,13 @@ SEA3D.FileInfo.prototype.type = "info"; // Java Script // -SEA3D.JavaScript = function( name, data, sea3d ) { +SEA3D.JavaScript = function ( name, data, sea3d ) { this.name = name; this.data = data; this.sea3d = sea3d; - this.src = data.readUTF( data.length ); + this.src = data.readUTF8( data.length ); }; @@ -1690,7 +1421,7 @@ SEA3D.JavaScript.prototype.type = "js"; // Java Script Method // -SEA3D.JavaScriptMethod = function( name, data, sea3d ) { +SEA3D.JavaScriptMethod = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1703,11 +1434,11 @@ SEA3D.JavaScriptMethod = function( name, data, sea3d ) { for ( var i = 0; i < count; i ++ ) { var flag = data.readUByte(); - var method = data.readUTF8(); + var method = data.readUTF8Tiny(); this.methods[ method ] = { - src : data.readUTF8Long() - } + src: data.readUTF8Long() + }; } @@ -1719,13 +1450,13 @@ SEA3D.JavaScriptMethod.prototype.type = "jsm"; // GLSL // -SEA3D.GLSL = function( name, data, sea3d ) { +SEA3D.GLSL = function ( name, data, sea3d ) { this.name = name; this.data = data; this.sea3d = sea3d; - this.src = data.readUTF( data.length ); + this.src = data.readUTF8( data.length ); }; @@ -1735,7 +1466,7 @@ SEA3D.GLSL.prototype.type = "glsl"; // Dummy // -SEA3D.Dummy = function( name, data, sea3d ) { +SEA3D.Dummy = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1758,7 +1489,7 @@ SEA3D.Dummy.prototype.type = "dmy"; // Line // -SEA3D.Line = function( name, data, sea3d ) { +SEA3D.Line = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1788,7 +1519,7 @@ SEA3D.Line.prototype.type = "line"; // Sprite // -SEA3D.Sprite = function( name, data, sea3d ) { +SEA3D.Sprite = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -1816,7 +1547,7 @@ SEA3D.Sprite.prototype.type = "m2d"; // Mesh // -SEA3D.Mesh = function( name, data, sea3d ) { +SEA3D.Mesh = function ( name, data, sea3d ) { SEA3D.Entity3D.call( this, name, data, sea3d ); @@ -1861,8 +1592,8 @@ SEA3D.Mesh = function( name, data, sea3d ) { if ( this.attrib & 1024 ) { this.reference = { - type : data.readUByte(), - ref : sea3d.getObject( data.readUInt() ) + type: data.readUByte(), + ref: sea3d.getObject( data.readUInt() ) }; } @@ -1884,7 +1615,7 @@ SEA3D.Mesh.prototype.type = "m3d"; // Skeleton // -SEA3D.Skeleton = function( name, data, sea3d ) { +SEA3D.Skeleton = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1897,7 +1628,7 @@ SEA3D.Skeleton = function( name, data, sea3d ) { for ( var i = 0; i < length; i ++ ) { this.joint[ i ] = { - name: data.readUTF8(), + name: data.readUTF8Tiny(), parentIndex: data.readUShort() - 1, inverseBindMatrix: data.readMatrix() }; @@ -1912,7 +1643,7 @@ SEA3D.Skeleton.prototype.type = "skl"; // Skeleton Local // -SEA3D.SkeletonLocal = function( name, data, sea3d ) { +SEA3D.SkeletonLocal = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1925,7 +1656,7 @@ SEA3D.SkeletonLocal = function( name, data, sea3d ) { for ( var i = 0; i < length; i ++ ) { this.joint[ i ] = { - name: data.readUTF8(), + name: data.readUTF8Tiny(), parentIndex: data.readUShort() - 1, // POSITION XYZ x: data.readFloat(), @@ -1948,7 +1679,7 @@ SEA3D.SkeletonLocal.prototype.type = "sklq"; // Animation Base // -SEA3D.AnimationBase = function( name, data, sea3d ) { +SEA3D.AnimationBase = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -1967,7 +1698,7 @@ SEA3D.AnimationBase = function( name, data, sea3d ) { flag = data.readUByte(); this.sequence[ i ] = { - name: data.readUTF8(), + name: data.readUTF8Tiny(), start: data.readUInt(), count: data.readUInt(), repeat: ( flag & 1 ) != 0, @@ -1994,7 +1725,7 @@ SEA3D.AnimationBase = function( name, data, sea3d ) { // Animation // -SEA3D.Animation = function( name, data, sea3d ) { +SEA3D.Animation = function ( name, data, sea3d ) { SEA3D.AnimationBase.call( this, name, data, sea3d ); @@ -2061,7 +1792,7 @@ SEA3D.Animation.prototype.type = "anm"; // Skeleton Animation // -SEA3D.SkeletonAnimation = function( name, data, sea3d ) { +SEA3D.SkeletonAnimation = function ( name, data, sea3d ) { SEA3D.AnimationBase.call( this, name, data, sea3d ); @@ -2081,7 +1812,7 @@ SEA3D.SkeletonAnimation.prototype.type = "skla"; // Morph // -SEA3D.Morph = function( name, data, sea3d ) { +SEA3D.Morph = function ( name, data, sea3d ) { SEA3D.GeometryBase.call( this, name, data, sea3d ); @@ -2094,13 +1825,13 @@ SEA3D.Morph = function( name, data, sea3d ) { for ( var i = 0; i < nodeCount; i ++ ) { - var nodeName = data.readUTF8(), + var nodeName = data.readUTF8Tiny(), verts, norms; if ( useVertex ) verts = data.readFloatArray( this.length ); if ( useNormal ) norms = data.readFloatArray( this.length ); - this.node[ i ] = { vertex: verts, normal: norms, name: nodeName } + this.node[ i ] = { vertex: verts, normal: norms, name: nodeName }; } @@ -2115,7 +1846,7 @@ SEA3D.Morph.prototype.type = "mph"; // Vertex Animation // -SEA3D.VertexAnimation = function( name, data, sea3d ) { +SEA3D.VertexAnimation = function ( name, data, sea3d ) { SEA3D.AnimationBase.call( this, name, data, sea3d ); @@ -2141,7 +1872,7 @@ SEA3D.VertexAnimation = function( name, data, sea3d ) { if ( useVertex ) verts = data.readFloatArray( this.length ); if ( useNormal ) norms = data.readFloatArray( this.length ); - this.frame[ i ] = { vertex: verts, normal: norms } + this.frame[ i ] = { vertex: verts, normal: norms }; } @@ -2156,7 +1887,7 @@ SEA3D.VertexAnimation.prototype.type = "vtxa"; // Camera // -SEA3D.Camera = function( name, data, sea3d ) { +SEA3D.Camera = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -2186,7 +1917,7 @@ SEA3D.Camera.prototype.type = "cam"; // Orthographic Camera // -SEA3D.OrthographicCamera = function( name, data, sea3d ) { +SEA3D.OrthographicCamera = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -2207,7 +1938,7 @@ SEA3D.OrthographicCamera.prototype.type = "camo"; // Joint Object // -SEA3D.JointObject = function( name, data, sea3d ) { +SEA3D.JointObject = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -2227,7 +1958,7 @@ SEA3D.JointObject.prototype.type = "jnt"; // Light // -SEA3D.Light = function( name, data, sea3d ) { +SEA3D.Light = function ( name, data, sea3d ) { SEA3D.Object3D.call( this, name, data, sea3d ); @@ -2238,7 +1969,7 @@ SEA3D.Light = function( name, data, sea3d ) { var shadowHeader = data.readUByte(); - this.shadow = {} + this.shadow = {}; this.shadow.opacity = shadowHeader & 1 ? data.readFloat() : 1; this.shadow.color = shadowHeader & 2 ? data.readUInt24() : 0x000000; @@ -2264,7 +1995,7 @@ SEA3D.Light.prototype.constructor = SEA3D.Light; // Point Light // -SEA3D.PointLight = function( name, data, sea3d ) { +SEA3D.PointLight = function ( name, data, sea3d ) { SEA3D.Light.call( this, name, data, sea3d ); @@ -2273,7 +2004,7 @@ SEA3D.PointLight = function( name, data, sea3d ) { this.attenuation = { start: data.readFloat(), end: data.readFloat() - } + }; } @@ -2292,16 +2023,16 @@ SEA3D.PointLight.prototype.type = "plht"; // Hemisphere Light // -SEA3D.HemisphereLight = function( name, data, sea3d ) { +SEA3D.HemisphereLight = function ( name, data, sea3d ) { SEA3D.Light.call( this, name, data, sea3d ); if ( this.attrib & 128 ) { this.attenuation = { - start: data.readFloat(), - end: data.readFloat() - } + start: data.readFloat(), + end: data.readFloat() + }; } @@ -2320,7 +2051,7 @@ SEA3D.HemisphereLight.prototype.type = "hlht"; // Ambient Light // -SEA3D.AmbientLight = function( name, data, sea3d ) { +SEA3D.AmbientLight = function ( name, data, sea3d ) { SEA3D.Light.call( this, name, data, sea3d ); @@ -2337,7 +2068,7 @@ SEA3D.AmbientLight.prototype.type = "alht"; // Directional Light // -SEA3D.DirectionalLight = function( name, data, sea3d ) { +SEA3D.DirectionalLight = function ( name, data, sea3d ) { SEA3D.Light.call( this, name, data, sea3d ); @@ -2356,19 +2087,19 @@ SEA3D.DirectionalLight.prototype.type = "dlht"; // Material // -SEA3D.Material = function( name, data, sea3d ) { +SEA3D.Material = function ( name, data, sea3d ) { this.name = name; this.data = data; this.sea3d = sea3d; this.technique = []; + this.tecniquesDict = {}; this.attrib = data.readUShort(); this.alpha = 1; this.blendMode = "normal"; - this.alphaThreshold = .5; this.physical = false; this.anisotropy = false; @@ -2379,7 +2110,7 @@ SEA3D.Material = function( name, data, sea3d ) { this.receiveShadows = ( this.attrib & 4 ) == 0; this.receiveFog = ( this.attrib & 8 ) == 0; - this.smooth = ( this.attrib & 16 ) == 0; + this.repeat = ( this.attrib & 16 ) == 0; if ( this.attrib & 32 ) this.alpha = data.readFloat(); @@ -2403,6 +2134,7 @@ SEA3D.Material = function( name, data, sea3d ) { var tech, methodAttrib; switch ( kind ) { + case SEA3D.Material.PHONG: tech = { ambientColor: data.readUInt24(), @@ -2415,7 +2147,6 @@ SEA3D.Material = function( name, data, sea3d ) { break; case SEA3D.Material.PHYSICAL: - this.physical = true; tech = { color: data.readUInt24(), roughness: data.readFloat(), @@ -2424,7 +2155,6 @@ SEA3D.Material = function( name, data, sea3d ) { break; case SEA3D.Material.ANISOTROPIC: - this.anisotropy = true; break; case SEA3D.Material.COMPOSITE_TEXTURE: @@ -2532,11 +2262,10 @@ SEA3D.Material = function( name, data, sea3d ) { tech.offsetX1 = data.readFloat(); tech.offsetY1 = data.readFloat(); - } - else { + } else { tech.offsetX0 = tech.offsetY0 = - tech.offsetX1 = tech.offsetY1 = 0 + tech.offsetX1 = tech.offsetY1 = 0; } @@ -2552,8 +2281,8 @@ SEA3D.Material = function( name, data, sea3d ) { case SEA3D.Material.AMBIENT_MAP: tech = { - texture: sea3d.getObject( data.readUInt() ) - } + texture: sea3d.getObject( data.readUInt() ) + }; break; case SEA3D.Material.ALPHA_MAP: @@ -2589,9 +2318,9 @@ SEA3D.Material = function( name, data, sea3d ) { case SEA3D.Material.WRAP_LIGHTING: tech = { - color: data.readUInt24(), - strength: data.readFloat() - }; + color: data.readUInt24(), + strength: data.readFloat() + }; break; case SEA3D.Material.COLOR_REPLACE: @@ -2616,16 +2345,36 @@ SEA3D.Material = function( name, data, sea3d ) { }; break; + case SEA3D.Material.REFLECTIVITY: + methodAttrib = data.readUByte(); + + tech = { + strength: data.readFloat() + }; + + if ( methodAttrib & 1 ) tech.mask = sea3d.getObject( data.readUInt() ); + + break; + + case SEA3D.Material.CLEAR_COAT: + tech = { + strength: data.readFloat(), + roughness: data.readFloat() + }; + break; + default: console.warn( "SEA3D: MaterialTechnique not found:", kind.toString( 16 ) ); data.position = pos += size; continue; + } tech.kind = kind; this.technique.push( tech ); + this.tecniquesDict[ kind ] = tech; data.position = pos += size; @@ -2660,6 +2409,8 @@ SEA3D.Material.EMISSIVE = 23; SEA3D.Material.PHYSICAL = 24; SEA3D.Material.ROUGHNESS_MAP = 25; SEA3D.Material.METALNESS_MAP = 26; +SEA3D.Material.REFLECTIVITY = 27; +SEA3D.Material.CLEAR_COAT = 28; SEA3D.Material.prototype.type = "mat"; @@ -2667,7 +2418,7 @@ SEA3D.Material.prototype.type = "mat"; // Composite // -SEA3D.Composite = function( name, data, sea3d ) { +SEA3D.Composite = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -2685,7 +2436,7 @@ SEA3D.Composite = function( name, data, sea3d ) { }; -SEA3D.Composite.prototype.getLayerByName = function( name ) { +SEA3D.Composite.prototype.getLayerByName = function ( name ) { for ( var i = 0; i < this.layer.length; i ++ ) { @@ -2699,7 +2450,7 @@ SEA3D.Composite.prototype.getLayerByName = function( name ) { }; -SEA3D.Composite.prototype.Layer = function( data, sea3d ) { +SEA3D.Composite.prototype.Layer = function ( data, sea3d ) { var attrib = data.readUShort(); @@ -2714,7 +2465,7 @@ SEA3D.Composite.prototype.Layer = function( data, sea3d ) { if ( attrib & 4 ) { - this.name = data.readUTF8(); + this.name = data.readUTF8Tiny(); } @@ -2724,7 +2475,7 @@ SEA3D.Composite.prototype.Layer = function( data, sea3d ) { }; -SEA3D.Composite.LayerBitmap = function( data, sea3d ) { +SEA3D.Composite.LayerBitmap = function ( data, sea3d ) { this.map = sea3d.getObject( data.readUInt() ); @@ -2744,408 +2495,11 @@ SEA3D.Composite.LayerBitmap = function( data, sea3d ) { SEA3D.Composite.prototype.type = "ctex"; -// -// Sphere -// - -SEA3D.Sphere = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.radius = data.readFloat(); - -}; - -SEA3D.Sphere.prototype.type = "sph"; - -// -// Box -// - -SEA3D.Box = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.width = data.readFloat(); - this.height = data.readFloat(); - this.depth = data.readFloat(); - -}; - -SEA3D.Box.prototype.type = "box"; - -// -// Cone -// - -SEA3D.Cone = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.radius = data.readFloat(); - this.height = data.readFloat(); - -}; - -SEA3D.Cone.prototype.type = "cone"; - -// -// Capsule -// - -SEA3D.Capsule = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.radius = data.readFloat(); - this.height = data.readFloat(); - -}; - -SEA3D.Capsule.prototype.type = "cap"; - -// -// Cylinder -// - -SEA3D.Cylinder = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.radius = data.readFloat(); - this.height = data.readFloat(); - -}; - -SEA3D.Cylinder.prototype.type = "cyl"; - -// -// Convex Geometry -// - -SEA3D.ConvexGeometry = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.geometry = sea3d.getObject( data.readUInt() ); - this.subGeometryIndex = data.readUByte(); - -}; - -SEA3D.ConvexGeometry.prototype.type = "gs"; - -// -// Triangle Geometry -// - -SEA3D.TriangleGeometry = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.geometry = sea3d.getObject( data.readUInt() ); - this.subGeometryIndex = data.readUByte(); - -}; - -SEA3D.TriangleGeometry.prototype.type = "sgs"; - -// -// Compound -// - -SEA3D.Compound = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.compounds = []; - - var count = data.readUByte(); - - for ( var i = 0; i < count; i ++ ) { - - this.compounds.push( { - shape : sea3d.getObject( data.readUInt() ), - transform : data.readMatrix() - } ); - - } - -}; - -SEA3D.Compound.prototype.type = "cmps"; - -// -// Physics -// - -SEA3D.Physics = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.attrib = data.readUShort(); - - this.shape = sea3d.getObject( data.readUInt() ); - - if ( this.attrib & 1 ) this.target = sea3d.getObject( data.readUInt() ); - else this.transform = data.readMatrix(); - -}; - -SEA3D.Physics.prototype.readTag = function( kind, data, size ) { - -}; - -// -// Rigidy Body Base -// - -SEA3D.RigidBodyBase = function( name, data, sea3d ) { - - SEA3D.Physics.call( this, name, data, sea3d ); - - if ( this.attrib & 32 ) { - - this.linearDamping = data.readFloat(); - this.angularDamping = data.readFloat(); - - } else { - - this.linearDamping = 0; - this.angularDamping = 0; - - } - - this.mass = data.readFloat(); - this.friction = data.readFloat(); - this.restitution = data.readFloat(); - -}; - -SEA3D.RigidBodyBase.prototype = Object.create( SEA3D.Physics.prototype ); -SEA3D.RigidBodyBase.prototype.constructor = SEA3D.RigidBodyBase; - -// -// Rigidy Body -// - -SEA3D.RigidBody = function( name, data, sea3d ) { - - SEA3D.RigidBodyBase.call( this, name, data, sea3d ); - - data.readTags( this.readTag.bind( this ) ); - -}; - -SEA3D.RigidBody.prototype = Object.create( SEA3D.RigidBodyBase.prototype ); -SEA3D.RigidBody.prototype.constructor = SEA3D.RigidBody; - -SEA3D.RigidBody.prototype.type = "rb"; - -// -// Car Controller -// - -SEA3D.CarController = function( name, data, sea3d ) { - - SEA3D.RigidBodyBase.call( this, name, data, sea3d ); - - this.suspensionStiffness = data.readFloat(); - this.suspensionCompression = data.readFloat(); - this.suspensionDamping = data.readFloat(); - this.maxSuspensionTravelCm = data.readFloat(); - this.frictionSlip = data.readFloat(); - this.maxSuspensionForce = data.readFloat(); - - this.dampingCompression = data.readFloat(); - this.dampingRelaxation = data.readFloat(); - - var count = data.readUByte(); - - this.wheel = []; - - for ( var i = 0; i < count; i ++ ) { - - this.wheel[ i ] = new SEA3D.CarController.Wheel( data, sea3d ); - - } - - data.readTags( this.readTag.bind( this ) ); - -}; - -SEA3D.CarController.Wheel = function( data, sea3d ) { - - this.data = data; - this.sea3d = sea3d; - - var attrib = data.readUShort(); - - this.isFront = ( attrib & 1 ) != 0, - - this.target = sea3d.getObject( data.readUInt() ); - - this.pos = data.readVector3(); - this.dir = data.readVector3(); - this.axle = data.readVector3(); - - this.radius = data.readFloat(); - this.suspensionRestLength = data.readFloat(); - -}; - -SEA3D.CarController.prototype = Object.create( SEA3D.RigidBodyBase.prototype ); -SEA3D.CarController.prototype.constructor = SEA3D.CarController; - -SEA3D.CarController.prototype.type = "carc"; - -// -// Constraints -// - -SEA3D.Constraints = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - this.attrib = data.readUShort(); - - this.disableCollisionsBetweenBodies = this.attrib & 1 != 0; - - this.targetA = sea3d.getObject( data.readUInt() ); - this.pointA = data.readVector3(); - - if ( this.attrib & 2 ) { - - this.targetB = sea3d.getObject( data.readUInt() ); - this.pointB = data.readVector3(); - - } - -}; - -// -// P2P Constraint -// - -SEA3D.P2PConstraint = function( name, data, sea3d ) { - - this.name = name; - this.data = data; - this.sea3d = sea3d; - - SEA3D.Constraints.call( this, name, data, sea3d ); - -}; - -SEA3D.P2PConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); -SEA3D.P2PConstraint.prototype.constructor = SEA3D.P2PConstraint; - -SEA3D.P2PConstraint.prototype.type = "p2pc"; - -// -// Hinge Constraint -// - -SEA3D.HingeConstraint = function( name, data, sea3d ) { - - SEA3D.Constraints.call( this, name, data, sea3d ); - - this.axisA = data.readVector3(); - - if ( this.attrib & 1 ) { - - this.axisB = data.readVector3(); - - } - - if ( this.attrib & 4 ) { - - this.limit = { - low : data.readFloat(), - high : data.readFloat(), - softness : data.readFloat(), - biasFactor : data.readFloat(), - relaxationFactor : data.readFloat() - } - - } - - if ( this.attrib & 8 ) { - - this.angularMotor = { - velocity : data.readFloat(), - impulse : data.readFloat() - } - - } - -}; - -SEA3D.HingeConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); -SEA3D.HingeConstraint.prototype.constructor = SEA3D.HingeConstraint; - -SEA3D.HingeConstraint.prototype.type = "hnec"; - -// -// Cone Twist Constraint -// - -SEA3D.ConeTwistConstraint = function( name, data, sea3d ) { - - SEA3D.Constraints.call( this, name, data, sea3d ); - - this.axisA = data.readVector3(); - - if ( this.attrib & 1 ) { - - this.axisB = data.readVector3(); - - } - - if ( this.attrib & 4 ) { - - this.limit = { - swingSpan1 : data.readFloat(), - swingSpan2 : data.readFloat(), - twistSpan : data.readFloat(), - softness : data.readFloat(), - biasFactor : data.readFloat(), - relaxationFactor : data.readFloat() - }; - - } - -}; - -SEA3D.ConeTwistConstraint.prototype = Object.create( SEA3D.Constraints.prototype ); -SEA3D.ConeTwistConstraint.prototype.constructor = SEA3D.ConeTwistConstraint; - -SEA3D.ConeTwistConstraint.prototype.type = "ctwc"; - // // Planar Render // -SEA3D.PlanarRender = function( name, data, sea3d ) { +SEA3D.PlanarRender = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3164,7 +2518,7 @@ SEA3D.PlanarRender.prototype.type = "rttp"; // Cube Render // -SEA3D.CubeRender = function( name, data, sea3d ) { +SEA3D.CubeRender = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3183,7 +2537,7 @@ SEA3D.CubeRender.prototype.type = "rttc"; // Cube Maps // -SEA3D.CubeMap = function( name, data, sea3d ) { +SEA3D.CubeMap = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3213,7 +2567,7 @@ SEA3D.CubeMap.prototype.type = "cmap"; // JPEG // -SEA3D.JPEG = function( name, data, sea3d ) { +SEA3D.JPEG = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3229,7 +2583,7 @@ SEA3D.JPEG.prototype.type = "jpg"; // JPEG_XR // -SEA3D.JPEG_XR = function( name, data, sea3d ) { +SEA3D.JPEG_XR = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3245,7 +2599,7 @@ SEA3D.JPEG_XR.prototype.type = "wdp"; // PNG // -SEA3D.PNG = function( name, data, sea3d ) { +SEA3D.PNG = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3261,7 +2615,7 @@ SEA3D.PNG.prototype.type = "png"; // GIF // -SEA3D.GIF = function( name, data, sea3d ) { +SEA3D.GIF = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3277,7 +2631,7 @@ SEA3D.GIF.prototype.type = "gif"; // OGG // -SEA3D.OGG = function( name, data, sea3d ) { +SEA3D.OGG = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3291,7 +2645,7 @@ SEA3D.OGG.prototype.type = "ogg"; // MP3 // -SEA3D.MP3 = function( name, data, sea3d ) { +SEA3D.MP3 = function ( name, data, sea3d ) { this.name = name; this.data = data; @@ -3305,7 +2659,7 @@ SEA3D.MP3.prototype.type = "mp3"; // FILE FORMAT // -SEA3D.File = function( config ) { +SEA3D.File = function ( config ) { this.config = { streaming: true, @@ -3331,7 +2685,6 @@ SEA3D.File = function( config ) { // SEA3D this.addClass( SEA3D.FileInfo, true ); this.addClass( SEA3D.Geometry, true ); - this.addClass( SEA3D.GeometryDelta, true ); this.addClass( SEA3D.Mesh ); this.addClass( SEA3D.Sprite ); this.addClass( SEA3D.Material ); @@ -3359,23 +2712,10 @@ SEA3D.File = function( config ) { this.addClass( SEA3D.Container3D ); this.addClass( SEA3D.Properties ); - // URL + // URL BASED + this.addClass( SEA3D.ScriptURL, true ); this.addClass( SEA3D.TextureURL, true ); - - // PHYSICS - this.addClass( SEA3D.Sphere ); - this.addClass( SEA3D.Box ); - this.addClass( SEA3D.Cone ); - this.addClass( SEA3D.Capsule ); - this.addClass( SEA3D.Cylinder ); - this.addClass( SEA3D.ConvexGeometry ); - this.addClass( SEA3D.TriangleGeometry ); - this.addClass( SEA3D.Compound ); - this.addClass( SEA3D.RigidBody ); - this.addClass( SEA3D.P2PConstraint ); - this.addClass( SEA3D.HingeConstraint ); - this.addClass( SEA3D.ConeTwistConstraint ); - this.addClass( SEA3D.CarController ); + this.addClass( SEA3D.CubeMapURL, true ); // UNIVERSAL this.addClass( SEA3D.JPEG, true ); @@ -3388,34 +2728,51 @@ SEA3D.File = function( config ) { this.addClass( SEA3D.JavaScriptMethod, true ); this.addClass( SEA3D.GLSL, true ); + // Extensions + + var i = SEA3D.File.Extensions.length; + + while ( i -- ) { + + SEA3D.File.Extensions[ i ].call( this ); + + } + }; +SEA3D.File.Extensions = []; SEA3D.File.CompressionLibs = {}; -SEA3D.File.DecompressionMethod = {} +SEA3D.File.DecompressionMethod = {}; + +SEA3D.File.setExtension = function ( callback ) { -SEA3D.File.setDecompressionEngine = function( id, name, method ) { + SEA3D.File.Extensions.push( callback ); + +}; + +SEA3D.File.setDecompressionEngine = function ( id, name, method ) { SEA3D.File.CompressionLibs[ id ] = name; SEA3D.File.DecompressionMethod[ id ] = method; }; -SEA3D.File.prototype.addClass = function( clazz, unique ) { +SEA3D.File.prototype.addClass = function ( clazz, unique ) { this.typeClass[ clazz.prototype.type ] = clazz; this.typeUnique[ clazz.prototype.type ] = unique === true; }; -SEA3D.File.prototype.readHead = function() { +SEA3D.File.prototype.readHead = function () { if ( this.stream.bytesAvailable < 16 ) return false; - if ( this.stream.readUTF( 3 ) != "SEA" ) + if ( this.stream.readUTF8( 3 ) != "SEA" ) throw new Error( "Invalid SEA3D format." ); - this.sign = this.stream.readUTF( 3 ); + this.sign = this.stream.readUTF8( 3 ); this.version = this.stream.readUInt24(); @@ -3444,23 +2801,32 @@ SEA3D.File.prototype.readHead = function() { this.state = this.readBody; - if ( this.onHead ) + if ( this.onHead ) { + this.onHead( { file: this, sign: this.sign } ); + } + return true; }; -SEA3D.File.prototype.getObject = function( index ) { +SEA3D.File.prototype.getObject = function ( index ) { return this.objects[ index ]; }; -SEA3D.File.prototype.readSEAObject = function() { +SEA3D.File.prototype.getObjectByName = function ( name ) { + + return this.objects[ name ]; + +}; + +SEA3D.File.prototype.readSEAObject = function () { if ( this.stream.bytesAvailable < 4 ) return null; @@ -3475,7 +2841,7 @@ SEA3D.File.prototype.readSEAObject = function() { var type = this.stream.readExt(); var meta = null; - var name = flag & 1 ? this.stream.readUTF8() : "", + var name = flag & 1 ? this.stream.readUTF8Tiny() : "", compressed = ( flag & 2 ) != 0, streaming = ( flag & 4 ) != 0; @@ -3512,14 +2878,13 @@ SEA3D.File.prototype.readSEAObject = function() { obj = new this.typeClass[ type ]( name, data, this ); - if ( this.config.streaming && streaming && this.typeRead[ type ] ) { + if ( ( this.config.streaming && streaming || this.config.forceStreaming ) && this.typeRead[ type ] ) { this.typeRead[ type ].call( this.scope, obj ); } - } - else { + } else { obj = new SEA3D.Object( name, data, type, this ); @@ -3530,7 +2895,7 @@ SEA3D.File.prototype.readSEAObject = function() { obj.streaming = streaming; obj.metadata = meta; - this.objects.push( this.objects[ obj.type + "/" + obj.name ] = obj ); + this.objects.push( this.objects[ obj.name + "." + obj.type ] = obj ); this.dataPosition = position + size; @@ -3540,16 +2905,18 @@ SEA3D.File.prototype.readSEAObject = function() { }; -SEA3D.File.prototype.isDone = function() { +SEA3D.File.prototype.isDone = function () { return this.position == this.length; }; -SEA3D.File.prototype.readBody = function() { +SEA3D.File.prototype.readBody = function () { this.timer.update(); + if ( ! this.resume ) return false; + while ( this.position < this.length ) { if ( this.timer.deltaTime < this.config.timeLimit ) { @@ -3561,8 +2928,7 @@ SEA3D.File.prototype.readBody = function() { if ( sea ) this.dispatchCompleteObject( sea ); else return false; - } - else return false; + } else return false; } @@ -3572,17 +2938,24 @@ SEA3D.File.prototype.readBody = function() { }; -SEA3D.File.prototype.parse = function() { +SEA3D.File.prototype.initParse = function () { this.timer = new SEA3D.Timer(); this.position = 0; + this.resume = true; + +}; + +SEA3D.File.prototype.parse = function () { + + this.initParse(); if ( isFinite( this.config.timeLimit ) ) setTimeout( this.parseObject.bind( this ), 10 ); else this.parseObject(); }; -SEA3D.File.prototype.parseObject = function() { +SEA3D.File.prototype.parseObject = function () { this.timer.update(); @@ -3593,7 +2966,7 @@ SEA3D.File.prototype.parseObject = function() { if ( ! this.typeUnique[ type ] ) delete obj.tag; - if ( obj.streaming && this.typeRead[ type ] ) { + if ( ( obj.streaming || this.config.forceStreaming ) && this.typeRead[ type ] ) { if ( obj.tag == undefined ) { @@ -3627,8 +3000,7 @@ SEA3D.File.prototype.parseObject = function() { this.onParseProgress( { file: this, loaded: this.position, - total: this.length, - progress: this.position / this.length + total: this.length } ); } @@ -3639,7 +3011,7 @@ SEA3D.File.prototype.parseObject = function() { }; -SEA3D.File.prototype.readComplete = function() { +SEA3D.File.prototype.readComplete = function () { this.stream.position = this.dataPosition; @@ -3648,34 +3020,42 @@ SEA3D.File.prototype.readComplete = function() { delete this.state; - this.dispatchComplete(); + return false; }; -SEA3D.File.prototype.readState = function() { +SEA3D.File.prototype.readState = function () { - while ( this.state && this.state() ); + while ( this.state() ) continue; if ( this.state ) { - setTimeout( this.readState.bind( this ), 10 ); + requestAnimationFrame( this.readState.bind( this ) ); + this.dispatchProgress(); + } else { + + this.dispatchComplete(); + } }; -SEA3D.File.prototype.read = function( data ) { +SEA3D.File.prototype.read = function ( buffer ) { - this.stream = new SEA3D.Stream( data ); - this.timer = new SEA3D.Timer(); + if ( ! buffer ) throw new Error( "No data found." ); + + this.initParse(); + + this.stream = new SEA3D.Stream( buffer ); this.state = this.readHead; this.readState(); }; -SEA3D.File.prototype.dispatchCompleteObject = function( obj ) { +SEA3D.File.prototype.dispatchCompleteObject = function ( obj ) { if ( ! this.onCompleteObject ) return; @@ -3686,54 +3066,52 @@ SEA3D.File.prototype.dispatchCompleteObject = function( obj ) { }; -SEA3D.File.prototype.dispatchProgress = function() { +SEA3D.File.prototype.dispatchProgress = function () { if ( ! this.onProgress ) return; this.onProgress( { file: this, loaded: this.position, - total: this.length, - progress: this.position / this.length + total: this.length } ); }; -SEA3D.File.prototype.dispatchDownloadProgress = function( position, length ) { +SEA3D.File.prototype.dispatchDownloadProgress = function ( position, length ) { if ( ! this.onDownloadProgress ) return; this.onDownloadProgress( { file: this, loaded: position, - total: length, - progress: position / length + total: length } ); }; -SEA3D.File.prototype.dispatchComplete = function() { +SEA3D.File.prototype.dispatchComplete = function () { var elapsedTime = this.timer.elapsedTime; var message = elapsedTime + "ms, " + this.objects.length + " objects"; if ( this.onComplete ) this.onComplete( { - file: this, - timeTotal: elapsedTime, - message: message - } ); + file: this, + timeTotal: elapsedTime, + message: message + } ); else console.log( "SEA3D:", message ); }; -SEA3D.File.prototype.dispatchError = function( id, message ) { +SEA3D.File.prototype.dispatchError = function ( id, message ) { if ( this.onError ) this.onError( { file: this, id: id, message: message } ); else console.error( "SEA3D: #" + id, message ); }; -SEA3D.File.prototype.load = function( url ) { +SEA3D.File.prototype.load = function ( url ) { var file = this, xhr = new XMLHttpRequest(); @@ -3741,7 +3119,7 @@ SEA3D.File.prototype.load = function( url ) { xhr.open( "GET", url, true ); xhr.responseType = 'arraybuffer'; - xhr.onprogress = function( e ) { + xhr.onprogress = function ( e ) { if ( e.lengthComputable ) { @@ -3749,9 +3127,9 @@ SEA3D.File.prototype.load = function( url ) { } - } + }; - xhr.onreadystatechange = function() { + xhr.onreadystatechange = function () { if ( xhr.readyState === 2 ) { //xhr.getResponseHeader("Content-Length"); @@ -3772,7 +3150,7 @@ SEA3D.File.prototype.load = function( url ) { } - } + }; xhr.send(); diff --git a/examples/js/loaders/sea3d/SEA3DDeflate.js b/examples/js/loaders/sea3d/SEA3DDeflate.js index 97e9c5b9c981369eafb1272893e5b440f6655973..998861d64af08aca62a618ea73061b04d81ead82 100644 --- a/examples/js/loaders/sea3d/SEA3DDeflate.js +++ b/examples/js/loaders/sea3d/SEA3DDeflate.js @@ -7,760 +7,881 @@ * http://www.onicos.com/staff/iz/amuse/javascript/expert/inflate.txt */ -(function(ctx){ +'use strict'; + +SEA3D.Deflate = function () { + + /* Copyright (C) 1999 Masanao Izumo + * Version: 1.0.0.1 + * LastModified: Dec 25 1999 + */ + + /* Interface: + * data = zip_inflate(src); + */ + + /* constant parameters */ + var zip_WSIZE = 32768; // Sliding Window size + var zip_STORED_BLOCK = 0; + var zip_STATIC_TREES = 1; + var zip_DYN_TREES = 2; + + /* for inflate */ + var zip_lbits = 9; // bits in base literal/length lookup table + var zip_dbits = 6; // bits in base distance lookup table + var zip_INBUFSIZ = 32768; // Input buffer size + var zip_INBUF_EXTRA = 64; // Extra buffer + + /* variables (inflate) */ + var zip_slide; + var zip_wp; // current position in slide + var zip_fixed_tl = null; // inflate static + var zip_fixed_td; // inflate static + var zip_fixed_bl, fixed_bd, zip_fixed_bd; // inflate static + var zip_bit_buf; // bit buffer + var zip_bit_len; // bits in bit buffer + var zip_method; + var zip_eof; + var zip_copy_leng; + var zip_copy_dist; + var zip_tl, zip_td; // literal/length and distance decoder tables + var zip_bl, zip_bd; // number of bits decoded by tl and td + + var zip_inflate_data; + var zip_inflate_pos; + + + /* constant tables (inflate) */ + var zip_MASK_BITS = new Array( + 0x0000, + 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, + 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff ); + // Tables for deflate from PKZIP's appnote.txt. + var zip_cplens = new Array( // Copy lengths for literal codes 257..285 + 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, + 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 ); + /* note: see note #13 above about the 258 in this list. */ + var zip_cplext = new Array( // Extra bits for literal codes 257..285 + 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, + 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99 ); // 99==invalid + var zip_cpdist = new Array( // Copy offsets for distance codes 0..29 + 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, + 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, + 8193, 12289, 16385, 24577 ); + var zip_cpdext = new Array( // Extra bits for distance codes + 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, + 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, + 12, 12, 13, 13 ); + var zip_border = new Array( // Order of the bit length code lengths + 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ); + /* objects (inflate) */ + + var zip_HuftList = function () { + + this.next = null; + this.list = null; -/* Copyright (C) 1999 Masanao Izumo - * Version: 1.0.0.1 - * LastModified: Dec 25 1999 - */ + } -/* Interface: - * data = zip_inflate(src); - */ + var zip_HuftNode = function () { + + this.e = 0; // number of extra bits or operation + this.b = 0; // number of bits in this code or subcode + + // union + this.n = 0; // literal, length base, or distance base + this.t = null; // (zip_HuftNode) pointer to next level of table -/* constant parameters */ -var zip_WSIZE = 32768; // Sliding Window size -var zip_STORED_BLOCK = 0; -var zip_STATIC_TREES = 1; -var zip_DYN_TREES = 2; - -/* for inflate */ -var zip_lbits = 9; // bits in base literal/length lookup table -var zip_dbits = 6; // bits in base distance lookup table -var zip_INBUFSIZ = 32768; // Input buffer size -var zip_INBUF_EXTRA = 64; // Extra buffer - -/* variables (inflate) */ -var zip_slide; -var zip_wp; // current position in slide -var zip_fixed_tl = null; // inflate static -var zip_fixed_td; // inflate static -var zip_fixed_bl, fixed_bd; // inflate static -var zip_bit_buf; // bit buffer -var zip_bit_len; // bits in bit buffer -var zip_method; -var zip_eof; -var zip_copy_leng; -var zip_copy_dist; -var zip_tl, zip_td; // literal/length and distance decoder tables -var zip_bl, zip_bd; // number of bits decoded by tl and td - -var zip_inflate_data; -var zip_inflate_pos; - - -/* constant tables (inflate) */ -var zip_MASK_BITS = new Array( - 0x0000, - 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff, - 0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff); -// Tables for deflate from PKZIP's appnote.txt. -var zip_cplens = new Array( // Copy lengths for literal codes 257..285 - 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, - 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0); -/* note: see note #13 above about the 258 in this list. */ -var zip_cplext = new Array( // Extra bits for literal codes 257..285 - 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, - 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 99, 99); // 99==invalid -var zip_cpdist = new Array( // Copy offsets for distance codes 0..29 - 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, - 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, - 8193, 12289, 16385, 24577); -var zip_cpdext = new Array( // Extra bits for distance codes - 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, - 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, - 12, 12, 13, 13); -var zip_border = new Array( // Order of the bit length code lengths - 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15); -/* objects (inflate) */ - -var zip_HuftList = function() { - this.next = null; - this.list = null; -} - -var zip_HuftNode = function() { - this.e = 0; // number of extra bits or operation - this.b = 0; // number of bits in this code or subcode - - // union - this.n = 0; // literal, length base, or distance base - this.t = null; // (zip_HuftNode) pointer to next level of table -} - -var zip_HuftBuild = function(b, // code lengths in bits (all assumed <= BMAX) - n, // number of codes (assumed <= N_MAX) - s, // number of simple-valued codes (0..s-1) - d, // list of base values for non-simple codes - e, // list of extra bits for non-simple codes - mm // maximum lookup bits - ) { - this.BMAX = 16; // maximum bit length of any code - this.N_MAX = 288; // maximum number of codes in any set - this.status = 0; // 0: success, 1: incomplete table, 2: bad input - this.root = null; // (zip_HuftList) starting table - this.m = 0; // maximum lookup bits, returns actual - -/* Given a list of code lengths and a maximum table size, make a set of - tables to decode that set of codes. Return zero on success, one if - the given code set is incomplete (the tables are still built in this - case), two if the input is invalid (all zero length codes or an - oversubscribed set of lengths), and three if not enough memory. - The code with value 256 is special, and the tables are constructed - so that no bits beyond that code are fetched when that code is - decoded. */ - { - var a; // counter for codes of length k - var c = new Array(this.BMAX+1); // bit length count table - var el; // length of EOB code (value 256) - var f; // i repeats in table every f entries - var g; // maximum code length - var h; // table level - var i; // counter, current code - var j; // counter - var k; // number of bits in current code - var lx = new Array(this.BMAX+1); // stack of bits per table - var p; // pointer into c[], b[], or v[] - var pidx; // index of p - var q; // (zip_HuftNode) points to current table - var r = new zip_HuftNode(); // table entry for structure assignment - var u = new Array(this.BMAX); // zip_HuftNode[BMAX][] table stack - var v = new Array(this.N_MAX); // values in order of bit length - var w; - var x = new Array(this.BMAX+1);// bit offsets, then code stack - var xp; // pointer into x or c - var y; // number of dummy codes added - var z; // number of entries in current table - var o; - var tail; // (zip_HuftList) - - tail = this.root = null; - for(i = 0; i < c.length; i++) - c[i] = 0; - for(i = 0; i < lx.length; i++) - lx[i] = 0; - for(i = 0; i < u.length; i++) - u[i] = null; - for(i = 0; i < v.length; i++) - v[i] = 0; - for(i = 0; i < x.length; i++) - x[i] = 0; - - // Generate counts for each bit length - el = n > 256 ? b[256] : this.BMAX; // set length of EOB code, if any - p = b; pidx = 0; - i = n; - do { - c[p[pidx]]++; // assume all entries <= BMAX - pidx++; - } while(--i > 0); - if(c[0] == n) { // null input--all zero length codes - this.root = null; - this.m = 0; - this.status = 0; - return; } - // Find minimum and maximum length, bound *m by those - for(j = 1; j <= this.BMAX; j++) - if(c[j] != 0) - break; - k = j; // minimum code length - if(mm < j) - mm = j; - for(i = this.BMAX; i != 0; i--) - if(c[i] != 0) - break; - g = i; // maximum code length - if(mm > i) - mm = i; - - // Adjust last length count to fill out codes, if needed - for(y = 1 << j; j < i; j++, y <<= 1) - if((y -= c[j]) < 0) { + var zip_HuftBuild = function ( b, // code lengths in bits (all assumed <= BMAX) + n, // number of codes (assumed <= N_MAX) + s, // number of simple-valued codes (0..s-1) + d, // list of base values for non-simple codes + e, // list of extra bits for non-simple codes + mm // maximum lookup bits + ) { + + this.BMAX = 16; // maximum bit length of any code + this.N_MAX = 288; // maximum number of codes in any set + this.status = 0; // 0: success, 1: incomplete table, 2: bad input + this.root = null; // (zip_HuftList) starting table + this.m = 0; // maximum lookup bits, returns actual + + /* Given a list of code lengths and a maximum table size, make a set of + tables to decode that set of codes. Return zero on success, one if + the given code set is incomplete (the tables are still built in this + case), two if the input is invalid (all zero length codes or an + oversubscribed set of lengths), and three if not enough memory. + The code with value 256 is special, and the tables are constructed + so that no bits beyond that code are fetched when that code is + decoded. */ + { + + var a; // counter for codes of length k + var c = new Array( this.BMAX + 1 ); // bit length count table + var el; // length of EOB code (value 256) + var f; // i repeats in table every f entries + var g; // maximum code length + var h; // table level + var i; // counter, current code + var j; // counter + var k; // number of bits in current code + var lx = new Array( this.BMAX + 1 ); // stack of bits per table + var p; // pointer into c[], b[], or v[] + var pidx; // index of p + var q; // (zip_HuftNode) points to current table + var r = new zip_HuftNode(); // table entry for structure assignment + var u = new Array( this.BMAX ); // zip_HuftNode[BMAX][] table stack + var v = new Array( this.N_MAX ); // values in order of bit length + var w; + var x = new Array( this.BMAX + 1 );// bit offsets, then code stack + var xp; // pointer into x or c + var y; // number of dummy codes added + var z; // number of entries in current table + var o; + var tail; // (zip_HuftList) + + tail = this.root = null; + for ( i = 0; i < c.length; i ++ ) + c[ i ] = 0; + for ( i = 0; i < lx.length; i ++ ) + lx[ i ] = 0; + for ( i = 0; i < u.length; i ++ ) + u[ i ] = null; + for ( i = 0; i < v.length; i ++ ) + v[ i ] = 0; + for ( i = 0; i < x.length; i ++ ) + x[ i ] = 0; + + // Generate counts for each bit length + el = n > 256 ? b[ 256 ] : this.BMAX; // set length of EOB code, if any + p = b; pidx = 0; + i = n; + do { + + c[ p[ pidx ]] ++; // assume all entries <= BMAX + pidx ++; + + } while ( -- i > 0 ); + if ( c[ 0 ] == n ) { + + // null input--all zero length codes + this.root = null; + this.m = 0; + this.status = 0; + return; + + } + + // Find minimum and maximum length, bound *m by those + for ( j = 1; j <= this.BMAX; j ++ ) + if ( c[ j ] != 0 ) + break; + k = j; // minimum code length + if ( mm < j ) + mm = j; + for ( i = this.BMAX; i != 0; i -- ) + if ( c[ i ] != 0 ) + break; + g = i; // maximum code length + if ( mm > i ) + mm = i; + + // Adjust last length count to fill out codes, if needed + for ( y = 1 << j; j < i; j ++, y <<= 1 ) + if ( ( y -= c[ j ] ) < 0 ) { + this.status = 2; // bad input: more codes than bits this.m = mm; return; + } - if((y -= c[i]) < 0) { - this.status = 2; - this.m = mm; - return; - } - c[i] += y; - - // Generate starting offsets into the value table for each length - x[1] = j = 0; - p = c; - pidx = 1; - xp = 2; - while(--i > 0) // note that i == g from above - x[xp++] = (j += p[pidx++]); - - // Make a table of values in order of bit lengths - p = b; pidx = 0; - i = 0; - do { - if((j = p[pidx++]) != 0) - v[x[j]++] = i; - } while(++i < n); - n = x[g]; // set n to length of v - - // Generate the Huffman codes and for each, make the table entries - x[0] = i = 0; // first Huffman code is zero - p = v; pidx = 0; // grab values in bit order - h = -1; // no tables yet--level -1 - w = lx[0] = 0; // no bits decoded yet - q = null; // ditto - z = 0; // ditto - - // go through the bit lengths (k already is bits in shortest code) - for(; k <= g; k++) { - a = c[k]; - while(a-- > 0) { - // here i is the Huffman code of length k bits for value p[pidx] - // make tables up to required level - while(k > w + lx[1 + h]) { - w += lx[1 + h]; // add bits already decoded - h++; - - // compute minimum size table less than or equal to *m bits - z = (z = g - w) > mm ? mm : z; // upper limit - if((f = 1 << (j = k - w)) > a + 1) { // try a k-w bit table - // too few codes for k-w bit table - f -= a + 1; // deduct codes from patterns left - xp = k; - while(++j < z) { // try smaller tables up to z bits - if((f <<= 1) <= c[++xp]) - break; // enough codes to use up j bits - f -= c[xp]; // else deduct codes from patterns + if ( ( y -= c[ i ] ) < 0 ) { + + this.status = 2; + this.m = mm; + return; + } - } - if(w + j > el && w < el) - j = el - w; // make EOB code end at table - z = 1 << j; // table entries for j-bit table - lx[1 + h] = j; // set table size in stack - - // allocate and link in new table - q = new Array(z); - for(o = 0; o < z; o++) { - q[o] = new zip_HuftNode(); - } - - if(tail == null) - tail = this.root = new zip_HuftList(); - else - tail = tail.next = new zip_HuftList(); - tail.next = null; - tail.list = q; - u[h] = q; // table starts after link - - /* connect to last table, if there is one */ - if(h > 0) { - x[h] = i; // save pattern for backing up - r.b = lx[h]; // bits to dump before this table - r.e = 16 + j; // bits in this table - r.t = q; // pointer to this table - j = (i & ((1 << w) - 1)) >> (w - lx[h]); - u[h-1][j].e = r.e; - u[h-1][j].b = r.b; - u[h-1][j].n = r.n; - u[h-1][j].t = r.t; - } - } + c[ i ] += y; + + // Generate starting offsets into the value table for each length + x[ 1 ] = j = 0; + p = c; + pidx = 1; + xp = 2; + while ( -- i > 0 ) // note that i == g from above + x[ xp ++ ] = ( j += p[ pidx ++ ] ); + + // Make a table of values in order of bit lengths + p = b; pidx = 0; + i = 0; + do { - // set up table entry in r - r.b = k - w; - if(pidx >= n) - r.e = 99; // out of values--invalid code - else if(p[pidx] < s) { - r.e = (p[pidx] < 256 ? 16 : 15); // 256 is end-of-block code - r.n = p[pidx++]; // simple code is just the value - } else { - r.e = e[p[pidx] - s]; // non-simple--look up in lists - r.n = d[p[pidx++] - s]; - } + if ( ( j = p[ pidx ++ ] ) != 0 ) + v[ x[ j ] ++ ] = i; - // fill code-like entries with r // - f = 1 << (k - w); - for(j = i >> w; j < z; j += f) { - q[j].e = r.e; - q[j].b = r.b; - q[j].n = r.n; - q[j].t = r.t; - } + } while ( ++ i < n ); + n = x[ g ]; // set n to length of v + + // Generate the Huffman codes and for each, make the table entries + x[ 0 ] = i = 0; // first Huffman code is zero + p = v; pidx = 0; // grab values in bit order + h = - 1; // no tables yet--level -1 + w = lx[ 0 ] = 0; // no bits decoded yet + q = null; // ditto + z = 0; // ditto + + // go through the bit lengths (k already is bits in shortest code) + for ( ; k <= g; k ++ ) { + + a = c[ k ]; + while ( a -- > 0 ) { - // backwards increment the k-bit code i - for(j = 1 << (k - 1); (i & j) != 0; j >>= 1) - i ^= j; - i ^= j; + // here i is the Huffman code of length k bits for value p[pidx] + // make tables up to required level + while ( k > w + lx[ 1 + h ] ) { + + w += lx[ 1 + h ]; // add bits already decoded + h ++; + + // compute minimum size table less than or equal to *m bits + z = ( z = g - w ) > mm ? mm : z; // upper limit + if ( ( f = 1 << ( j = k - w ) ) > a + 1 ) { + + // try a k-w bit table + // too few codes for k-w bit table + f -= a + 1; // deduct codes from patterns left + xp = k; + while ( ++ j < z ) { + + // try smaller tables up to z bits + if ( ( f <<= 1 ) <= c[ ++ xp ] ) + break; // enough codes to use up j bits + f -= c[ xp ]; // else deduct codes from patterns + + } + + } + if ( w + j > el && w < el ) + j = el - w; // make EOB code end at table + z = 1 << j; // table entries for j-bit table + lx[ 1 + h ] = j; // set table size in stack + + // allocate and link in new table + q = new Array( z ); + for ( o = 0; o < z; o ++ ) { + + q[ o ] = new zip_HuftNode(); + + } + + if ( tail == null ) + tail = this.root = new zip_HuftList(); + else + tail = tail.next = new zip_HuftList(); + tail.next = null; + tail.list = q; + u[ h ] = q; // table starts after link + + /* connect to last table, if there is one */ + if ( h > 0 ) { + + x[ h ] = i; // save pattern for backing up + r.b = lx[ h ]; // bits to dump before this table + r.e = 16 + j; // bits in this table + r.t = q; // pointer to this table + j = ( i & ( ( 1 << w ) - 1 ) ) >> ( w - lx[ h ] ); + u[ h - 1 ][ j ].e = r.e; + u[ h - 1 ][ j ].b = r.b; + u[ h - 1 ][ j ].n = r.n; + u[ h - 1 ][ j ].t = r.t; + + } + + } + + // set up table entry in r + r.b = k - w; + if ( pidx >= n ) + r.e = 99; // out of values--invalid code + else if ( p[ pidx ] < s ) { + + r.e = ( p[ pidx ] < 256 ? 16 : 15 ); // 256 is end-of-block code + r.n = p[ pidx ++ ]; // simple code is just the value + + } else { + + r.e = e[ p[ pidx ] - s ]; // non-simple--look up in lists + r.n = d[ p[ pidx ++ ] - s ]; + + } + + // fill code-like entries with r // + f = 1 << ( k - w ); + for ( j = i >> w; j < z; j += f ) { + + q[ j ].e = r.e; + q[ j ].b = r.b; + q[ j ].n = r.n; + q[ j ].t = r.t; + + } + + // backwards increment the k-bit code i + for ( j = 1 << ( k - 1 ); ( i & j ) != 0; j >>= 1 ) + i ^= j; + i ^= j; + + // backup over finished tables + while ( ( i & ( ( 1 << w ) - 1 ) ) != x[ h ] ) { + + w -= lx[ h ]; // don't need to update q + h --; + + } + + } + + } + + /* return actual size of base table */ + this.m = lx[ 1 ]; + + /* Return true (1) if we were given an incomplete table */ + this.status = ( ( y != 0 && g != 1 ) ? 1 : 0 ); + + } /* end of constructor */ - // backup over finished tables - while((i & ((1 << w) - 1)) != x[h]) { - w -= lx[h]; // don't need to update q - h--; - } - } } - /* return actual size of base table */ - this.m = lx[1]; - - /* Return true (1) if we were given an incomplete table */ - this.status = ((y != 0 && g != 1) ? 1 : 0); - } /* end of constructor */ -} - - -/* routines (inflate) */ - -var zip_GET_BYTE = function() { - if(zip_inflate_data.length == zip_inflate_pos) - return -1; - return zip_inflate_data[zip_inflate_pos++]; -} - -var zip_NEEDBITS = function(n) { - while(zip_bit_len < n) { - zip_bit_buf |= zip_GET_BYTE() << zip_bit_len; - zip_bit_len += 8; - } -} - -var zip_GETBITS = function(n) { - return zip_bit_buf & zip_MASK_BITS[n]; -} - -var zip_DUMPBITS = function(n) { - zip_bit_buf >>= n; - zip_bit_len -= n; -} - -var zip_inflate_codes = function(buff, off, size) { - /* inflate (decompress) the codes in a deflated (compressed) block. - Return an error code or zero if it all goes ok. */ - var e; // table entry flag/number of extra bits - var t; // (zip_HuftNode) pointer to table entry - var n; - - if(size == 0) - return 0; - - // inflate the coded data - n = 0; - for(;;) { // do until end of block - zip_NEEDBITS(zip_bl); - t = zip_tl.list[zip_GETBITS(zip_bl)]; - e = t.e; - while(e > 16) { - if(e == 99) - return -1; - zip_DUMPBITS(t.b); - e -= 16; - zip_NEEDBITS(e); - t = t.t[zip_GETBITS(e)]; - e = t.e; + + /* routines (inflate) */ + + var zip_GET_BYTE = function () { + + if ( zip_inflate_data.length == zip_inflate_pos ) + return - 1; + return zip_inflate_data[ zip_inflate_pos ++ ]; + } - zip_DUMPBITS(t.b); - - if(e == 16) { // then it's a literal - zip_wp &= zip_WSIZE - 1; - buff[off + n++] = zip_slide[zip_wp++] = t.n; - if(n == size) - return size; - continue; + + var zip_NEEDBITS = function ( n ) { + + while ( zip_bit_len < n ) { + + zip_bit_buf |= zip_GET_BYTE() << zip_bit_len; + zip_bit_len += 8; + + } + } - // exit if end of block - if(e == 15) - break; - - // it's an EOB or a length - - // get length of block to copy - zip_NEEDBITS(e); - zip_copy_leng = t.n + zip_GETBITS(e); - zip_DUMPBITS(e); - - // decode distance of block to copy - zip_NEEDBITS(zip_bd); - t = zip_td.list[zip_GETBITS(zip_bd)]; - e = t.e; - - while(e > 16) { - if(e == 99) - return -1; - zip_DUMPBITS(t.b); - e -= 16; - zip_NEEDBITS(e); - t = t.t[zip_GETBITS(e)]; - e = t.e; + var zip_GETBITS = function ( n ) { + + return zip_bit_buf & zip_MASK_BITS[ n ]; + } - zip_DUMPBITS(t.b); - zip_NEEDBITS(e); - zip_copy_dist = zip_wp - t.n - zip_GETBITS(e); - zip_DUMPBITS(e); - - // do the copy - while(zip_copy_leng > 0 && n < size) { - zip_copy_leng--; - zip_copy_dist &= zip_WSIZE - 1; - zip_wp &= zip_WSIZE - 1; - buff[off + n++] = zip_slide[zip_wp++] - = zip_slide[zip_copy_dist++]; + + var zip_DUMPBITS = function ( n ) { + + zip_bit_buf >>= n; + zip_bit_len -= n; + } - if(n == size) - return size; - } - - zip_method = -1; // done - return n; -} - -var zip_inflate_stored = function(buff, off, size) { - /* "decompress" an inflated type 0 (stored) block. */ - var n; - - // go to byte boundary - n = zip_bit_len & 7; - zip_DUMPBITS(n); - - // get the length and its complement - zip_NEEDBITS(16); - n = zip_GETBITS(16); - zip_DUMPBITS(16); - zip_NEEDBITS(16); - if(n != ((~zip_bit_buf) & 0xffff)) - return -1; // error in compressed data - zip_DUMPBITS(16); - - // read and output the compressed data - zip_copy_leng = n; - - n = 0; - while(zip_copy_leng > 0 && n < size) { - zip_copy_leng--; - zip_wp &= zip_WSIZE - 1; - zip_NEEDBITS(8); - buff[off + n++] = zip_slide[zip_wp++] = - zip_GETBITS(8); - zip_DUMPBITS(8); - } - - if(zip_copy_leng == 0) - zip_method = -1; // done - return n; -} - -var zip_inflate_fixed = function(buff, off, size) { - /* decompress an inflated type 1 (fixed Huffman codes) block. We should - either replace this with a custom decoder, or at least precompute the - Huffman tables. */ - - // if first time, set up tables for fixed blocks - if(zip_fixed_tl == null) { - var i; // temporary variable - var l = new Array(288); // length list for huft_build - var h; // zip_HuftBuild - - // literal table - for(i = 0; i < 144; i++) - l[i] = 8; - for(; i < 256; i++) - l[i] = 9; - for(; i < 280; i++) - l[i] = 7; - for(; i < 288; i++) // make a complete, but wrong code set - l[i] = 8; - zip_fixed_bl = 7; - - h = new zip_HuftBuild(l, 288, 257, zip_cplens, zip_cplext, - zip_fixed_bl); - if(h.status != 0) { - alert("HufBuild error: "+h.status); - return -1; + var zip_inflate_codes = function ( buff, off, size ) { + + /* inflate (decompress) the codes in a deflated (compressed) block. + Return an error code or zero if it all goes ok. */ + var e; // table entry flag/number of extra bits + var t; // (zip_HuftNode) pointer to table entry + var n; + + if ( size == 0 ) + return 0; + + // inflate the coded data + n = 0; + for ( ;; ) { + + // do until end of block + zip_NEEDBITS( zip_bl ); + t = zip_tl.list[ zip_GETBITS( zip_bl ) ]; + e = t.e; + while ( e > 16 ) { + + if ( e == 99 ) + return - 1; + zip_DUMPBITS( t.b ); + e -= 16; + zip_NEEDBITS( e ); + t = t.t[ zip_GETBITS( e ) ]; + e = t.e; + + } + zip_DUMPBITS( t.b ); + + if ( e == 16 ) { + + // then it's a literal + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = t.n; + if ( n == size ) + return size; + continue; + + } + + // exit if end of block + if ( e == 15 ) + break; + + // it's an EOB or a length + + // get length of block to copy + zip_NEEDBITS( e ); + zip_copy_leng = t.n + zip_GETBITS( e ); + zip_DUMPBITS( e ); + + // decode distance of block to copy + zip_NEEDBITS( zip_bd ); + t = zip_td.list[ zip_GETBITS( zip_bd ) ]; + e = t.e; + + while ( e > 16 ) { + + if ( e == 99 ) + return - 1; + zip_DUMPBITS( t.b ); + e -= 16; + zip_NEEDBITS( e ); + t = t.t[ zip_GETBITS( e ) ]; + e = t.e; + + } + zip_DUMPBITS( t.b ); + zip_NEEDBITS( e ); + zip_copy_dist = zip_wp - t.n - zip_GETBITS( e ); + zip_DUMPBITS( e ); + + // do the copy + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_copy_dist &= zip_WSIZE - 1; + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] + = zip_slide[ zip_copy_dist ++ ]; + + } + + if ( n == size ) + return size; + + } + + zip_method = - 1; // done + return n; + } - zip_fixed_tl = h.root; - zip_fixed_bl = h.m; - - // distance table - for(i = 0; i < 30; i++) // make an incomplete code set - l[i] = 5; - zip_fixed_bd = 5; - - h = new zip_HuftBuild(l, 30, 0, zip_cpdist, zip_cpdext, zip_fixed_bd); - if(h.status > 1) { - zip_fixed_tl = null; - alert("HufBuild error: "+h.status); - return -1; + + var zip_inflate_stored = function ( buff, off, size ) { + + /* "decompress" an inflated type 0 (stored) block. */ + var n; + + // go to byte boundary + n = zip_bit_len & 7; + zip_DUMPBITS( n ); + + // get the length and its complement + zip_NEEDBITS( 16 ); + n = zip_GETBITS( 16 ); + zip_DUMPBITS( 16 ); + zip_NEEDBITS( 16 ); + if ( n != ( ( ~ zip_bit_buf ) & 0xffff ) ) + return - 1; // error in compressed data + zip_DUMPBITS( 16 ); + + // read and output the compressed data + zip_copy_leng = n; + + n = 0; + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_wp &= zip_WSIZE - 1; + zip_NEEDBITS( 8 ); + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = + zip_GETBITS( 8 ); + zip_DUMPBITS( 8 ); + + } + + if ( zip_copy_leng == 0 ) + zip_method = - 1; // done + return n; + } - zip_fixed_td = h.root; - zip_fixed_bd = h.m; - } - - zip_tl = zip_fixed_tl; - zip_td = zip_fixed_td; - zip_bl = zip_fixed_bl; - zip_bd = zip_fixed_bd; - return zip_inflate_codes(buff, off, size); -} - -var zip_inflate_dynamic = function(buff, off, size) { - // decompress an inflated type 2 (dynamic Huffman codes) block. - var i; // temporary variables - var j; - var l; // last length - var n; // number of lengths to get - var t; // (zip_HuftNode) literal/length code table - var nb; // number of bit length codes - var nl; // number of literal/length codes - var nd; // number of distance codes - var ll = new Array(286+30); // literal/length and distance code lengths - var h; // (zip_HuftBuild) - - for(i = 0; i < ll.length; i++) - ll[i] = 0; - - // read in table lengths - zip_NEEDBITS(5); - nl = 257 + zip_GETBITS(5); // number of literal/length codes - zip_DUMPBITS(5); - zip_NEEDBITS(5); - nd = 1 + zip_GETBITS(5); // number of distance codes - zip_DUMPBITS(5); - zip_NEEDBITS(4); - nb = 4 + zip_GETBITS(4); // number of bit length codes - zip_DUMPBITS(4); - if(nl > 286 || nd > 30) - return -1; // bad lengths - - // read in bit-length-code lengths - for(j = 0; j < nb; j++) - { - zip_NEEDBITS(3); - ll[zip_border[j]] = zip_GETBITS(3); - zip_DUMPBITS(3); - } - for(; j < 19; j++) - ll[zip_border[j]] = 0; - - // build decoding table for trees--single level, 7 bit lookup - zip_bl = 7; - h = new zip_HuftBuild(ll, 19, 19, null, null, zip_bl); - if(h.status != 0) - return -1; // incomplete code set - - zip_tl = h.root; - zip_bl = h.m; - - // read in literal and distance code lengths - n = nl + nd; - i = l = 0; - while(i < n) { - zip_NEEDBITS(zip_bl); - t = zip_tl.list[zip_GETBITS(zip_bl)]; - j = t.b; - zip_DUMPBITS(j); - j = t.n; - if(j < 16) // length of code in bits (0..15) - ll[i++] = l = j; // save last length in l - else if(j == 16) { // repeat last length 3 to 6 times - zip_NEEDBITS(2); - j = 3 + zip_GETBITS(2); - zip_DUMPBITS(2); - if(i + j > n) - return -1; - while(j-- > 0) - ll[i++] = l; - } else if(j == 17) { // 3 to 10 zero length codes - zip_NEEDBITS(3); - j = 3 + zip_GETBITS(3); - zip_DUMPBITS(3); - if(i + j > n) - return -1; - while(j-- > 0) - ll[i++] = 0; - l = 0; - } else { // j == 18: 11 to 138 zero length codes - zip_NEEDBITS(7); - j = 11 + zip_GETBITS(7); - zip_DUMPBITS(7); - if(i + j > n) - return -1; - while(j-- > 0) - ll[i++] = 0; - l = 0; + + var zip_inflate_fixed = function ( buff, off, size ) { + + /* decompress an inflated type 1 (fixed Huffman codes) block. We should + either replace this with a custom decoder, or at least precompute the + Huffman tables. */ + + // if first time, set up tables for fixed blocks + if ( zip_fixed_tl == null ) { + + var i; // temporary variable + var l = new Array( 288 ); // length list for huft_build + var h; // zip_HuftBuild + + // literal table + for ( i = 0; i < 144; i ++ ) + l[ i ] = 8; + for ( ; i < 256; i ++ ) + l[ i ] = 9; + for ( ; i < 280; i ++ ) + l[ i ] = 7; + for ( ; i < 288; i ++ ) // make a complete, but wrong code set + l[ i ] = 8; + zip_fixed_bl = 7; + + h = new zip_HuftBuild( l, 288, 257, zip_cplens, zip_cplext, + zip_fixed_bl ); + if ( h.status != 0 ) { + + alert( "HufBuild error: " + h.status ); + return - 1; + + } + zip_fixed_tl = h.root; + zip_fixed_bl = h.m; + + // distance table + for ( i = 0; i < 30; i ++ ) // make an incomplete code set + l[ i ] = 5; + zip_fixed_bd = 5; + + h = new zip_HuftBuild( l, 30, 0, zip_cpdist, zip_cpdext, zip_fixed_bd ); + if ( h.status > 1 ) { + + zip_fixed_tl = null; + alert( "HufBuild error: " + h.status ); + return - 1; + + } + zip_fixed_td = h.root; + zip_fixed_bd = h.m; + + } + + zip_tl = zip_fixed_tl; + zip_td = zip_fixed_td; + zip_bl = zip_fixed_bl; + zip_bd = zip_fixed_bd; + return zip_inflate_codes( buff, off, size ); + } - } - - // build the decoding tables for literal/length and distance codes - zip_bl = zip_lbits; - h = new zip_HuftBuild(ll, nl, 257, zip_cplens, zip_cplext, zip_bl); - if(zip_bl == 0) // no literals or lengths - h.status = 1; - if(h.status != 0) { - /*if(h.status == 1) - ;// **incomplete literal tree** */ - return -1; // incomplete code set - } - zip_tl = h.root; - zip_bl = h.m; - - for(i = 0; i < nd; i++) - ll[i] = ll[i + nl]; - zip_bd = zip_dbits; - h = new zip_HuftBuild(ll, nd, 0, zip_cpdist, zip_cpdext, zip_bd); - zip_td = h.root; - zip_bd = h.m; - - if(zip_bd == 0 && nl > 257) { // lengths but no distances - // **incomplete distance tree** - return -1; - } - - /*if(h.status == 1) { - ;// **incomplete distance tree** - }*/ - if(h.status != 0) - return -1; - - // decompress until an end-of-block code - return zip_inflate_codes(buff, off, size); -} - -var zip_inflate_start = function() { - var i; - - if(zip_slide == null) - zip_slide = new Array(2 * zip_WSIZE); - zip_wp = 0; - zip_bit_buf = 0; - zip_bit_len = 0; - zip_method = -1; - zip_eof = false; - zip_copy_leng = zip_copy_dist = 0; - zip_tl = null; -} - -var zip_inflate_internal = function(buff, off, size) { - // decompress an inflated entry - var n, i; - - n = 0; - while(n < size) { - if(zip_eof && zip_method == -1) - return n; - - if(zip_copy_leng > 0) { - if(zip_method != zip_STORED_BLOCK) { - // STATIC_TREES or DYN_TREES - while(zip_copy_leng > 0 && n < size) { - zip_copy_leng--; - zip_copy_dist &= zip_WSIZE - 1; - zip_wp &= zip_WSIZE - 1; - buff[off + n++] = zip_slide[zip_wp++] = - zip_slide[zip_copy_dist++]; + + var zip_inflate_dynamic = function ( buff, off, size ) { + + // decompress an inflated type 2 (dynamic Huffman codes) block. + var i; // temporary variables + var j; + var l; // last length + var n; // number of lengths to get + var t; // (zip_HuftNode) literal/length code table + var nb; // number of bit length codes + var nl; // number of literal/length codes + var nd; // number of distance codes + var ll = new Array( 286 + 30 ); // literal/length and distance code lengths + var h; // (zip_HuftBuild) + + for ( i = 0; i < ll.length; i ++ ) + ll[ i ] = 0; + + // read in table lengths + zip_NEEDBITS( 5 ); + nl = 257 + zip_GETBITS( 5 ); // number of literal/length codes + zip_DUMPBITS( 5 ); + zip_NEEDBITS( 5 ); + nd = 1 + zip_GETBITS( 5 ); // number of distance codes + zip_DUMPBITS( 5 ); + zip_NEEDBITS( 4 ); + nb = 4 + zip_GETBITS( 4 ); // number of bit length codes + zip_DUMPBITS( 4 ); + if ( nl > 286 || nd > 30 ) + return - 1; // bad lengths + + // read in bit-length-code lengths + for ( j = 0; j < nb; j ++ ) + { + + zip_NEEDBITS( 3 ); + ll[ zip_border[ j ]] = zip_GETBITS( 3 ); + zip_DUMPBITS( 3 ); + } - } else { - while(zip_copy_leng > 0 && n < size) { - zip_copy_leng--; - zip_wp &= zip_WSIZE - 1; - zip_NEEDBITS(8); - buff[off + n++] = zip_slide[zip_wp++] = zip_GETBITS(8); - zip_DUMPBITS(8); + for ( ; j < 19; j ++ ) + ll[ zip_border[ j ]] = 0; + + // build decoding table for trees--single level, 7 bit lookup + zip_bl = 7; + h = new zip_HuftBuild( ll, 19, 19, null, null, zip_bl ); + if ( h.status != 0 ) + return - 1; // incomplete code set + + zip_tl = h.root; + zip_bl = h.m; + + // read in literal and distance code lengths + n = nl + nd; + i = l = 0; + while ( i < n ) { + + zip_NEEDBITS( zip_bl ); + t = zip_tl.list[ zip_GETBITS( zip_bl ) ]; + j = t.b; + zip_DUMPBITS( j ); + j = t.n; + if ( j < 16 ) // length of code in bits (0..15) + ll[ i ++ ] = l = j; // save last length in l + else if ( j == 16 ) { + + // repeat last length 3 to 6 times + zip_NEEDBITS( 2 ); + j = 3 + zip_GETBITS( 2 ); + zip_DUMPBITS( 2 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = l; + + } else if ( j == 17 ) { + + // 3 to 10 zero length codes + zip_NEEDBITS( 3 ); + j = 3 + zip_GETBITS( 3 ); + zip_DUMPBITS( 3 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = 0; + l = 0; + + } else { + + // j == 18: 11 to 138 zero length codes + zip_NEEDBITS( 7 ); + j = 11 + zip_GETBITS( 7 ); + zip_DUMPBITS( 7 ); + if ( i + j > n ) + return - 1; + while ( j -- > 0 ) + ll[ i ++ ] = 0; + l = 0; + + } + } - if(zip_copy_leng == 0) - zip_method = -1; // done - } - if(n == size) - return n; + + // build the decoding tables for literal/length and distance codes + zip_bl = zip_lbits; + h = new zip_HuftBuild( ll, nl, 257, zip_cplens, zip_cplext, zip_bl ); + if ( zip_bl == 0 ) // no literals or lengths + h.status = 1; + if ( h.status != 0 ) { + + /*if(h.status == 1) + ;// **incomplete literal tree** */ + return - 1; // incomplete code set + + } + zip_tl = h.root; + zip_bl = h.m; + + for ( i = 0; i < nd; i ++ ) + ll[ i ] = ll[ i + nl ]; + zip_bd = zip_dbits; + h = new zip_HuftBuild( ll, nd, 0, zip_cpdist, zip_cpdext, zip_bd ); + zip_td = h.root; + zip_bd = h.m; + + if ( zip_bd == 0 && nl > 257 ) { + + // lengths but no distances + // **incomplete distance tree** + return - 1; + + } + + /*if(h.status == 1) { + ;// **incomplete distance tree** + }*/ + if ( h.status != 0 ) + return - 1; + + // decompress until an end-of-block code + return zip_inflate_codes( buff, off, size ); + } - if(zip_method == -1) { - if(zip_eof) - break; - - // read in last block bit - zip_NEEDBITS(1); - if(zip_GETBITS(1) != 0) - zip_eof = true; - zip_DUMPBITS(1); - - // read in block type - zip_NEEDBITS(2); - zip_method = zip_GETBITS(2); - zip_DUMPBITS(2); - zip_tl = null; - zip_copy_leng = 0; + var zip_inflate_start = function () { + + var i; + + if ( zip_slide == null ) + zip_slide = new Array( 2 * zip_WSIZE ); + zip_wp = 0; + zip_bit_buf = 0; + zip_bit_len = 0; + zip_method = - 1; + zip_eof = false; + zip_copy_leng = zip_copy_dist = 0; + zip_tl = null; + } - switch(zip_method) { - case 0: // zip_STORED_BLOCK - i = zip_inflate_stored(buff, off + n, size - n); - break; - - case 1: // zip_STATIC_TREES - if(zip_tl != null) - i = zip_inflate_codes(buff, off + n, size - n); - else - i = zip_inflate_fixed(buff, off + n, size - n); - break; - - case 2: // zip_DYN_TREES - if(zip_tl != null) - i = zip_inflate_codes(buff, off + n, size - n); - else - i = zip_inflate_dynamic(buff, off + n, size - n); - break; - - default: // error - i = -1; - break; + var zip_inflate_internal = function ( buff, off, size ) { + + // decompress an inflated entry + var n, i; + + n = 0; + while ( n < size ) { + + if ( zip_eof && zip_method == - 1 ) + return n; + + if ( zip_copy_leng > 0 ) { + + if ( zip_method != zip_STORED_BLOCK ) { + + // STATIC_TREES or DYN_TREES + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_copy_dist &= zip_WSIZE - 1; + zip_wp &= zip_WSIZE - 1; + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = + zip_slide[ zip_copy_dist ++ ]; + + } + + } else { + + while ( zip_copy_leng > 0 && n < size ) { + + zip_copy_leng --; + zip_wp &= zip_WSIZE - 1; + zip_NEEDBITS( 8 ); + buff[ off + n ++ ] = zip_slide[ zip_wp ++ ] = zip_GETBITS( 8 ); + zip_DUMPBITS( 8 ); + + } + if ( zip_copy_leng == 0 ) + zip_method = - 1; // done + + } + if ( n == size ) + return n; + + } + + if ( zip_method == - 1 ) { + + if ( zip_eof ) + break; + + // read in last block bit + zip_NEEDBITS( 1 ); + if ( zip_GETBITS( 1 ) != 0 ) + zip_eof = true; + zip_DUMPBITS( 1 ); + + // read in block type + zip_NEEDBITS( 2 ); + zip_method = zip_GETBITS( 2 ); + zip_DUMPBITS( 2 ); + zip_tl = null; + zip_copy_leng = 0; + + } + + switch ( zip_method ) { + case 0: // zip_STORED_BLOCK + i = zip_inflate_stored( buff, off + n, size - n ); + break; + + case 1: // zip_STATIC_TREES + if ( zip_tl != null ) + i = zip_inflate_codes( buff, off + n, size - n ); + else + i = zip_inflate_fixed( buff, off + n, size - n ); + break; + + case 2: // zip_DYN_TREES + if ( zip_tl != null ) + i = zip_inflate_codes( buff, off + n, size - n ); + else + i = zip_inflate_dynamic( buff, off + n, size - n ); + break; + + default: // error + i = - 1; + } + + if ( i == - 1 ) { + + if ( zip_eof ) + return 0; + return - 1; + + } + n += i; + + } + return n; + } - if(i == -1) { - if(zip_eof) - return 0; - return -1; + var zip_inflate = function ( data ) { + + var i, j, pos = 0; + + zip_inflate_start(); + zip_inflate_data = new Uint8Array( data ); + zip_inflate_pos = 0; + + var buff = new Uint8Array( 1024 ); + + var out = []; + while ( ( i = zip_inflate_internal( buff, 0, buff.length ) ) > 0 ) + for ( j = 0; j < i; j ++ ) + out[ pos ++ ] = buff[ j ]; + + zip_inflate_data = null; // G.C. + return new Uint8Array( out ).buffer; + } - n += i; - } - return n; -} - -var zip_inflate = function(data) { - var i, j, pos = 0; - - zip_inflate_start(); - zip_inflate_data = new Uint8Array(data); - zip_inflate_pos = 0; - - var buff = new Uint8Array(1024); - - var out = []; - while((i = zip_inflate_internal(buff, 0, buff.length)) > 0) - for(j = 0; j < i; j++) - out[pos++] = buff[j]; - - zip_inflate_data = null; // G.C. - return new Uint8Array(out).buffer; -} - -if (! ctx.RawDeflate) ctx.RawDeflate = {}; -ctx.RawDeflate.inflate = zip_inflate; - -})(this); + + return { inflate: zip_inflate }; + +}(); /** - * SEA3D DEFLATE + * SEA3D Deflate * @author Sunag / http://www.sunag.com.br/ */ -SEA3D.File.DeflateUncompress = function( data ) { +SEA3D.File.DeflateUncompress = function ( data ) { - return RawDeflate.inflate( data ); + return SEA3D.Deflate.inflate( data ); -} +}; -SEA3D.File.setDecompressionEngine( 1, "deflate", SEA3D.File.DeflateUncompress ); \ No newline at end of file +SEA3D.File.setDecompressionEngine( 1, "deflate", SEA3D.File.DeflateUncompress ); diff --git a/examples/js/loaders/sea3d/SEA3DGC.js b/examples/js/loaders/sea3d/SEA3DGC.js new file mode 100644 index 0000000000000000000000000000000000000000..062191c38e96a613a6fc3746909d3ab372b6f2b0 --- /dev/null +++ b/examples/js/loaders/sea3d/SEA3DGC.js @@ -0,0 +1,154 @@ +/** + * SEA3D - o3dgc + * @author Sunag / http://www.sunag.com.br/ + */ + +'use strict'; + +// +// Lossy Compression +// + +SEA3D.GeometryGC = function ( name, data, sea3d ) { + + this.name = name; + this.data = data; + this.sea3d = sea3d; + + var i; + var attrib = data.readUShort(); + var uvIDs = [], jointID, weightID; + + this.isBig = ( attrib & 1 ) != 0; + + data.readVInt = this.isBig ? data.readUInt : data.readUShort; + + // Geometry Flags + // .. + // 1 isBig + // 2 groups + // 4 uv + // 8 tangent + // 16 colors + // 32 joints + // 64 morph + // 128 vertex-animation + // .. + + if ( attrib & 2 ) { + + this.groups = []; + + var numGroups = data.readUByte(), + groupOffset = 0; + + for ( i = 0; i < numGroups; i ++ ) { + + var groupLength = data.readVInt() * 3; + + this.groups.push( { + start: groupOffset, + count: groupLength, + } ); + + groupOffset += groupLength; + + } + + } else { + + this.groups = []; + + } + + if ( attrib & 4 ) { + + this.uv = []; + + var uvCount = data.readUByte(); + + for ( i = 0; i < uvCount; i ++ ) { + + uvIDs[ i ] = data.readUByte(); + + } + + } + + if ( attrib & 32 ) { + + jointID = data.readUByte(); + weightID = data.readUByte(); + + } + + var size = data.readUInt(); + var bytes = data.concat( data.position, size ); + + var bstream = new o3dgc.BinaryStream( bytes.buffer ); + + var decoder = new o3dgc.SC3DMCDecoder(); + var ifs = new o3dgc.IndexedFaceSet(); + + decoder.DecodeHeader( ifs, bstream ); + + var numIndexes = ifs.GetNCoordIndex(); + var numVertex = ifs.GetNCoord(); + + if ( ! this.groups.length ) this.groups.push( { start: 0, count: numIndexes * 3 } ); + + this.indexes = this.isBig ? new Uint32Array( numIndexes * 3 ) : new Uint16Array( numIndexes * 3 ); + this.vertex = new Float32Array( numVertex * 3 ); + + ifs.SetCoordIndex( this.indexes ); + ifs.SetCoord( this.vertex ); + + if ( ifs.GetNNormal() > 0 ) { + + this.normal = new Float32Array( numVertex * 3 ); + ifs.SetNormal( this.normal ); + + } + + for ( i = 0; i < uvIDs.length; i ++ ) { + + this.uv[ i ] = new Float32Array( numVertex * 2 ); + ifs.SetFloatAttribute( uvIDs[ i ], this.uv[ i ] ); + + } + + if ( jointID !== undefined ) { + + this.jointPerVertex = ifs.GetIntAttributeDim( jointID ); + + this.joint = new Uint16Array( numVertex * this.jointPerVertex ); + this.weight = new Float32Array( numVertex * this.jointPerVertex ); + + ifs.SetIntAttribute( jointID, this.joint ); + ifs.SetFloatAttribute( weightID, this.weight ); + + } + + // decode mesh + + decoder.DecodePlayload( ifs, bstream ); + +}; + +SEA3D.GeometryGC.prototype.type = "s3D"; + +// +// Extension +// + +THREE.SEA3D.EXTENSIONS_LOADER.push( { + + setTypeRead: function () { + + this.file.addClass( SEA3D.GeometryGC, true ); + + this.file.typeRead[ SEA3D.GeometryGC.prototype.type ] = this.readGeometryBuffer; + + } + +} ); diff --git a/examples/js/loaders/sea3d/SEA3DLZMA.js b/examples/js/loaders/sea3d/SEA3DLZMA.js index af223be87cc2cb6968b09fd18b9676520a9bd7b9..f1e09eb2d691339d95ba8e1d8ddd8babd31d5722 100644 --- a/examples/js/loaders/sea3d/SEA3DLZMA.js +++ b/examples/js/loaders/sea3d/SEA3DLZMA.js @@ -26,573 +26,785 @@ References: http://www.7-zip.org/sdk.html */ -var LZMA = LZMA || {}; +'use strict'; -LZMA.OutWindow = function(){ - this._windowSize = 0; -}; +SEA3D.LZMA = function () { -LZMA.OutWindow.prototype.create = function(windowSize){ - if ( (!this._buffer) || (this._windowSize !== windowSize) ){ - this._buffer = []; - } - this._windowSize = windowSize; - this._pos = 0; - this._streamPos = 0; -}; + var LZMA = LZMA || {}; -LZMA.OutWindow.prototype.flush = function(){ - var size = this._pos - this._streamPos; - if (size !== 0){ - while(size --){ - this._stream.writeByte(this._buffer[this._streamPos ++]); - } - if (this._pos >= this._windowSize){ - this._pos = 0; - } - this._streamPos = this._pos; - } -}; + LZMA.OutWindow = function () { -LZMA.OutWindow.prototype.releaseStream = function(){ - this.flush(); - this._stream = null; -}; + this._windowSize = 0; -LZMA.OutWindow.prototype.setStream = function(stream){ - this.releaseStream(); - this._stream = stream; -}; + }; -LZMA.OutWindow.prototype.init = function(solid){ - if (!solid){ - this._streamPos = 0; - this._pos = 0; - } -}; + LZMA.OutWindow.prototype.create = function ( windowSize ) { -LZMA.OutWindow.prototype.copyBlock = function(distance, len){ - var pos = this._pos - distance - 1; - if (pos < 0){ - pos += this._windowSize; - } - while(len --){ - if (pos >= this._windowSize){ - pos = 0; - } - this._buffer[this._pos ++] = this._buffer[pos ++]; - if (this._pos >= this._windowSize){ - this.flush(); - } - } -}; + if ( ( ! this._buffer ) || ( this._windowSize !== windowSize ) ) { -LZMA.OutWindow.prototype.putByte = function(b){ - this._buffer[this._pos ++] = b; - if (this._pos >= this._windowSize){ - this.flush(); - } -}; + this._buffer = []; -LZMA.OutWindow.prototype.getByte = function(distance){ - var pos = this._pos - distance - 1; - if (pos < 0){ - pos += this._windowSize; - } - return this._buffer[pos]; -}; + } + this._windowSize = windowSize; + this._pos = 0; + this._streamPos = 0; -LZMA.RangeDecoder = function(){ -}; + }; -LZMA.RangeDecoder.prototype.setStream = function(stream){ - this._stream = stream; -}; + LZMA.OutWindow.prototype.flush = function () { -LZMA.RangeDecoder.prototype.releaseStream = function(){ - this._stream = null; -}; + var size = this._pos - this._streamPos; + if ( size !== 0 ) { -LZMA.RangeDecoder.prototype.init = function(){ - var i = 5; + while ( size -- ) { - this._code = 0; - this._range = -1; - - while(i --){ - this._code = (this._code << 8) | this._stream.readByte(); - } -}; + this._stream.writeByte( this._buffer[ this._streamPos ++ ] ); -LZMA.RangeDecoder.prototype.decodeDirectBits = function(numTotalBits){ - var result = 0, i = numTotalBits, t; + } + if ( this._pos >= this._windowSize ) { - while(i --){ - this._range >>>= 1; - t = (this._code - this._range) >>> 31; - this._code -= this._range & (t - 1); - result = (result << 1) | (1 - t); + this._pos = 0; - if ( (this._range & 0xff000000) === 0){ - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - } + } + this._streamPos = this._pos; - return result; -}; + } -LZMA.RangeDecoder.prototype.decodeBit = function(probs, index){ - var prob = probs[index], - newBound = (this._range >>> 11) * prob; - - if ( (this._code ^ 0x80000000) < (newBound ^ 0x80000000) ){ - this._range = newBound; - probs[index] += (2048 - prob) >>> 5; - if ( (this._range & 0xff000000) === 0){ - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - return 0; - } - - this._range -= newBound; - this._code -= newBound; - probs[index] -= prob >>> 5; - if ( (this._range & 0xff000000) === 0){ - this._code = (this._code << 8) | this._stream.readByte(); - this._range <<= 8; - } - return 1; -}; + }; -LZMA.initBitModels = function(probs, len){ - while(len --){ - probs[len] = 1024; - } -}; + LZMA.OutWindow.prototype.releaseStream = function () { -LZMA.BitTreeDecoder = function(numBitLevels){ - this._models = []; - this._numBitLevels = numBitLevels; -}; + this.flush(); + this._stream = null; -LZMA.BitTreeDecoder.prototype.init = function(){ - LZMA.initBitModels(this._models, 1 << this._numBitLevels); -}; + }; -LZMA.BitTreeDecoder.prototype.decode = function(rangeDecoder){ - var m = 1, i = this._numBitLevels; + LZMA.OutWindow.prototype.setStream = function ( stream ) { - while(i --){ - m = (m << 1) | rangeDecoder.decodeBit(this._models, m); - } - return m - (1 << this._numBitLevels); -}; + this.releaseStream(); + this._stream = stream; -LZMA.BitTreeDecoder.prototype.reverseDecode = function(rangeDecoder){ - var m = 1, symbol = 0, i = 0, bit; + }; - for (; i < this._numBitLevels; ++ i){ - bit = rangeDecoder.decodeBit(this._models, m); - m = (m << 1) | bit; - symbol |= bit << i; - } - return symbol; -}; + LZMA.OutWindow.prototype.init = function ( solid ) { -LZMA.reverseDecode2 = function(models, startIndex, rangeDecoder, numBitLevels){ - var m = 1, symbol = 0, i = 0, bit; + if ( ! solid ) { - for (; i < numBitLevels; ++ i){ - bit = rangeDecoder.decodeBit(models, startIndex + m); - m = (m << 1) | bit; - symbol |= bit << i; - } - return symbol; -}; + this._streamPos = 0; + this._pos = 0; -LZMA.LenDecoder = function(){ - this._choice = []; - this._lowCoder = []; - this._midCoder = []; - this._highCoder = new LZMA.BitTreeDecoder(8); - this._numPosStates = 0; -}; + } -LZMA.LenDecoder.prototype.create = function(numPosStates){ - for (; this._numPosStates < numPosStates; ++ this._numPosStates){ - this._lowCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); - this._midCoder[this._numPosStates] = new LZMA.BitTreeDecoder(3); - } -}; + }; -LZMA.LenDecoder.prototype.init = function(){ - var i = this._numPosStates; - LZMA.initBitModels(this._choice, 2); - while(i --){ - this._lowCoder[i].init(); - this._midCoder[i].init(); - } - this._highCoder.init(); -}; + LZMA.OutWindow.prototype.copyBlock = function ( distance, len ) { -LZMA.LenDecoder.prototype.decode = function(rangeDecoder, posState){ - if (rangeDecoder.decodeBit(this._choice, 0) === 0){ - return this._lowCoder[posState].decode(rangeDecoder); - } - if (rangeDecoder.decodeBit(this._choice, 1) === 0){ - return 8 + this._midCoder[posState].decode(rangeDecoder); - } - return 16 + this._highCoder.decode(rangeDecoder); -}; + var pos = this._pos - distance - 1; + if ( pos < 0 ) { -LZMA.Decoder2 = function(){ - this._decoders = []; -}; + pos += this._windowSize; -LZMA.Decoder2.prototype.init = function(){ - LZMA.initBitModels(this._decoders, 0x300); -}; + } + while ( len -- ) { -LZMA.Decoder2.prototype.decodeNormal = function(rangeDecoder){ - var symbol = 1; + if ( pos >= this._windowSize ) { - do{ - symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); - }while(symbol < 0x100); + pos = 0; - return symbol & 0xff; -}; + } + this._buffer[ this._pos ++ ] = this._buffer[ pos ++ ]; + if ( this._pos >= this._windowSize ) { -LZMA.Decoder2.prototype.decodeWithMatchByte = function(rangeDecoder, matchByte){ - var symbol = 1, matchBit, bit; - - do{ - matchBit = (matchByte >> 7) & 1; - matchByte <<= 1; - bit = rangeDecoder.decodeBit(this._decoders, ( (1 + matchBit) << 8) + symbol); - symbol = (symbol << 1) | bit; - if (matchBit !== bit){ - while(symbol < 0x100){ - symbol = (symbol << 1) | rangeDecoder.decodeBit(this._decoders, symbol); - } - break; - } - }while(symbol < 0x100); - - return symbol & 0xff; -}; + this.flush(); -LZMA.LiteralDecoder = function(){ -}; + } -LZMA.LiteralDecoder.prototype.create = function(numPosBits, numPrevBits){ - var i; + } - if (this._coders - && (this._numPrevBits === numPrevBits) - && (this._numPosBits === numPosBits) ){ - return; - } - this._numPosBits = numPosBits; - this._posMask = (1 << numPosBits) - 1; - this._numPrevBits = numPrevBits; + }; - this._coders = []; + LZMA.OutWindow.prototype.putByte = function ( b ) { - i = 1 << (this._numPrevBits + this._numPosBits); - while(i --){ - this._coders[i] = new LZMA.Decoder2(); - } -}; + this._buffer[ this._pos ++ ] = b; + if ( this._pos >= this._windowSize ) { -LZMA.LiteralDecoder.prototype.init = function(){ - var i = 1 << (this._numPrevBits + this._numPosBits); - while(i --){ - this._coders[i].init(); - } -}; + this.flush(); -LZMA.LiteralDecoder.prototype.getDecoder = function(pos, prevByte){ - return this._coders[( (pos & this._posMask) << this._numPrevBits) - + ( (prevByte & 0xff) >>> (8 - this._numPrevBits) )]; -}; + } -LZMA.Decoder = function(){ - this._outWindow = new LZMA.OutWindow(); - this._rangeDecoder = new LZMA.RangeDecoder(); - this._isMatchDecoders = []; - this._isRepDecoders = []; - this._isRepG0Decoders = []; - this._isRepG1Decoders = []; - this._isRepG2Decoders = []; - this._isRep0LongDecoders = []; - this._posSlotDecoder = []; - this._posDecoders = []; - this._posAlignDecoder = new LZMA.BitTreeDecoder(4); - this._lenDecoder = new LZMA.LenDecoder(); - this._repLenDecoder = new LZMA.LenDecoder(); - this._literalDecoder = new LZMA.LiteralDecoder(); - this._dictionarySize = -1; - this._dictionarySizeCheck = -1; - - this._posSlotDecoder[0] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[1] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[2] = new LZMA.BitTreeDecoder(6); - this._posSlotDecoder[3] = new LZMA.BitTreeDecoder(6); -}; + }; -LZMA.Decoder.prototype.setDictionarySize = function(dictionarySize){ - if (dictionarySize < 0){ - return false; - } - if (this._dictionarySize !== dictionarySize){ - this._dictionarySize = dictionarySize; - this._dictionarySizeCheck = Math.max(this._dictionarySize, 1); - this._outWindow.create( Math.max(this._dictionarySizeCheck, 4096) ); - } - return true; -}; + LZMA.OutWindow.prototype.getByte = function ( distance ) { -LZMA.Decoder.prototype.setLcLpPb = function(lc, lp, pb){ - var numPosStates = 1 << pb; + var pos = this._pos - distance - 1; + if ( pos < 0 ) { - if (lc > 8 || lp > 4 || pb > 4){ - return false; - } + pos += this._windowSize; - this._literalDecoder.create(lp, lc); + } + return this._buffer[ pos ]; - this._lenDecoder.create(numPosStates); - this._repLenDecoder.create(numPosStates); - this._posStateMask = numPosStates - 1; + }; - return true; -}; + LZMA.RangeDecoder = function () { + }; -LZMA.Decoder.prototype.init = function(){ - var i = 4; + LZMA.RangeDecoder.prototype.setStream = function ( stream ) { - this._outWindow.init(false); + this._stream = stream; - LZMA.initBitModels(this._isMatchDecoders, 192); - LZMA.initBitModels(this._isRep0LongDecoders, 192); - LZMA.initBitModels(this._isRepDecoders, 12); - LZMA.initBitModels(this._isRepG0Decoders, 12); - LZMA.initBitModels(this._isRepG1Decoders, 12); - LZMA.initBitModels(this._isRepG2Decoders, 12); - LZMA.initBitModels(this._posDecoders, 114); + }; - this._literalDecoder.init(); + LZMA.RangeDecoder.prototype.releaseStream = function () { - while(i --){ - this._posSlotDecoder[i].init(); - } + this._stream = null; - this._lenDecoder.init(); - this._repLenDecoder.init(); - this._posAlignDecoder.init(); - this._rangeDecoder.init(); -}; + }; -LZMA.Decoder.prototype.decode = function(inStream, outStream, outSize){ - var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0, - posState, decoder2, len, distance, posSlot, numDirectBits; - - this._rangeDecoder.setStream(inStream); - this._outWindow.setStream(outStream); - - this.init(); - - while(outSize < 0 || nowPos64 < outSize){ - posState = nowPos64 & this._posStateMask; - - if (this._rangeDecoder.decodeBit(this._isMatchDecoders, (state << 4) + posState) === 0){ - decoder2 = this._literalDecoder.getDecoder(nowPos64 ++, prevByte); - - if (state >= 7){ - prevByte = decoder2.decodeWithMatchByte(this._rangeDecoder, this._outWindow.getByte(rep0) ); - }else{ - prevByte = decoder2.decodeNormal(this._rangeDecoder); - } - this._outWindow.putByte(prevByte); - - state = state < 4? 0: state - (state < 10? 3: 6); - - }else{ - - if (this._rangeDecoder.decodeBit(this._isRepDecoders, state) === 1){ - len = 0; - if (this._rangeDecoder.decodeBit(this._isRepG0Decoders, state) === 0){ - if (this._rangeDecoder.decodeBit(this._isRep0LongDecoders, (state << 4) + posState) === 0){ - state = state < 7? 9: 11; - len = 1; - } - }else{ - if (this._rangeDecoder.decodeBit(this._isRepG1Decoders, state) === 0){ - distance = rep1; - }else{ - if (this._rangeDecoder.decodeBit(this._isRepG2Decoders, state) === 0){ - distance = rep2; - }else{ - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - if (len === 0){ - len = 2 + this._repLenDecoder.decode(this._rangeDecoder, posState); - state = state < 7? 8: 11; - } - }else{ - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - - len = 2 + this._lenDecoder.decode(this._rangeDecoder, posState); - state = state < 7? 7: 10; - - posSlot = this._posSlotDecoder[len <= 5? len - 2: 3].decode(this._rangeDecoder); - if (posSlot >= 4){ - - numDirectBits = (posSlot >> 1) - 1; - rep0 = (2 | (posSlot & 1) ) << numDirectBits; - - if (posSlot < 14){ - rep0 += LZMA.reverseDecode2(this._posDecoders, - rep0 - posSlot - 1, this._rangeDecoder, numDirectBits); - }else{ - rep0 += this._rangeDecoder.decodeDirectBits(numDirectBits - 4) << 4; - rep0 += this._posAlignDecoder.reverseDecode(this._rangeDecoder); - if (rep0 < 0){ - if (rep0 === -1){ - break; - } - return false; - } - } - }else{ - rep0 = posSlot; - } - } - - if (rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck){ - return false; - } - - this._outWindow.copyBlock(rep0, len); - nowPos64 += len; - prevByte = this._outWindow.getByte(0); - } - } - - this._outWindow.flush(); - this._outWindow.releaseStream(); - this._rangeDecoder.releaseStream(); - - return true; -}; + LZMA.RangeDecoder.prototype.init = function () { -LZMA.Decoder.prototype.setDecoderProperties = function(properties){ - var value, lc, lp, pb, dictionarySize; + var i = 5; - if (properties.size < 5){ - return false; - } + this._code = 0; + this._range = - 1; - value = properties.readByte(); - lc = value % 9; - value = ~~(value / 9); - lp = value % 5; - pb = ~~(value / 5); + while ( i -- ) { - if ( !this.setLcLpPb(lc, lp, pb) ){ - return false; - } + this._code = ( this._code << 8 ) | this._stream.readByte(); - dictionarySize = properties.readByte(); - dictionarySize |= properties.readByte() << 8; - dictionarySize |= properties.readByte() << 16; - dictionarySize += properties.readByte() * 16777216; + } - return this.setDictionarySize(dictionarySize); -}; + }; -LZMA.decompress = function(properties, inStream, outStream, outSize){ - var decoder = new LZMA.Decoder(); + LZMA.RangeDecoder.prototype.decodeDirectBits = function ( numTotalBits ) { - if ( !decoder.setDecoderProperties(properties) ){ - throw "Incorrect stream properties"; - } + var result = 0, i = numTotalBits, t; - if ( !decoder.decode(inStream, outStream, outSize) ){ - throw "Error in data stream"; - } + while ( i -- ) { - return true; -}; + this._range >>>= 1; + t = ( this._code - this._range ) >>> 31; + this._code -= this._range & ( t - 1 ); + result = ( result << 1 ) | ( 1 - t ); -LZMA.decompressFile = function(inStream, outStream){ - var decoder = new LZMA.Decoder(), outSize; + if ( ( this._range & 0xff000000 ) === 0 ) { - if ( !decoder.setDecoderProperties(inStream) ){ - throw "Incorrect stream properties"; - } + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; - outSize = inStream.readByte(); - outSize |= inStream.readByte() << 8; - outSize |= inStream.readByte() << 16; - outSize += inStream.readByte() * 16777216; + } - inStream.readByte(); - inStream.readByte(); - inStream.readByte(); - inStream.readByte(); + } - if ( !decoder.decode(inStream, outStream, outSize) ){ - throw "Error in data stream"; - } + return result; + + }; + + LZMA.RangeDecoder.prototype.decodeBit = function ( probs, index ) { + + var prob = probs[ index ], + newBound = ( this._range >>> 11 ) * prob; + + if ( ( this._code ^ 0x80000000 ) < ( newBound ^ 0x80000000 ) ) { + + this._range = newBound; + probs[ index ] += ( 2048 - prob ) >>> 5; + if ( ( this._range & 0xff000000 ) === 0 ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; + + } + return 0; + + } + + this._range -= newBound; + this._code -= newBound; + probs[ index ] -= prob >>> 5; + if ( ( this._range & 0xff000000 ) === 0 ) { + + this._code = ( this._code << 8 ) | this._stream.readByte(); + this._range <<= 8; + + } + return 1; + + }; + + LZMA.initBitModels = function ( probs, len ) { + + while ( len -- ) { + + probs[ len ] = 1024; + + } + + }; + + LZMA.BitTreeDecoder = function ( numBitLevels ) { + + this._models = []; + this._numBitLevels = numBitLevels; + + }; + + LZMA.BitTreeDecoder.prototype.init = function () { + + LZMA.initBitModels( this._models, 1 << this._numBitLevels ); + + }; + + LZMA.BitTreeDecoder.prototype.decode = function ( rangeDecoder ) { + + var m = 1, i = this._numBitLevels; + + while ( i -- ) { + + m = ( m << 1 ) | rangeDecoder.decodeBit( this._models, m ); + + } + return m - ( 1 << this._numBitLevels ); + + }; + + LZMA.BitTreeDecoder.prototype.reverseDecode = function ( rangeDecoder ) { + + var m = 1, symbol = 0, i = 0, bit; + + for ( ; i < this._numBitLevels; ++ i ) { + + bit = rangeDecoder.decodeBit( this._models, m ); + m = ( m << 1 ) | bit; + symbol |= bit << i; + + } + return symbol; + + }; + + LZMA.reverseDecode2 = function ( models, startIndex, rangeDecoder, numBitLevels ) { + + var m = 1, symbol = 0, i = 0, bit; + + for ( ; i < numBitLevels; ++ i ) { + + bit = rangeDecoder.decodeBit( models, startIndex + m ); + m = ( m << 1 ) | bit; + symbol |= bit << i; + + } + return symbol; + + }; + + LZMA.LenDecoder = function () { + + this._choice = []; + this._lowCoder = []; + this._midCoder = []; + this._highCoder = new LZMA.BitTreeDecoder( 8 ); + this._numPosStates = 0; + + }; + + LZMA.LenDecoder.prototype.create = function ( numPosStates ) { + + for ( ; this._numPosStates < numPosStates; ++ this._numPosStates ) { + + this._lowCoder[ this._numPosStates ] = new LZMA.BitTreeDecoder( 3 ); + this._midCoder[ this._numPosStates ] = new LZMA.BitTreeDecoder( 3 ); + + } + + }; + + LZMA.LenDecoder.prototype.init = function () { + + var i = this._numPosStates; + LZMA.initBitModels( this._choice, 2 ); + while ( i -- ) { + + this._lowCoder[ i ].init(); + this._midCoder[ i ].init(); + + } + this._highCoder.init(); + + }; + + LZMA.LenDecoder.prototype.decode = function ( rangeDecoder, posState ) { + + if ( rangeDecoder.decodeBit( this._choice, 0 ) === 0 ) { + + return this._lowCoder[ posState ].decode( rangeDecoder ); + + } + if ( rangeDecoder.decodeBit( this._choice, 1 ) === 0 ) { + + return 8 + this._midCoder[ posState ].decode( rangeDecoder ); + + } + return 16 + this._highCoder.decode( rangeDecoder ); + + }; + + LZMA.Decoder2 = function () { + + this._decoders = []; + + }; + + LZMA.Decoder2.prototype.init = function () { + + LZMA.initBitModels( this._decoders, 0x300 ); + + }; + + LZMA.Decoder2.prototype.decodeNormal = function ( rangeDecoder ) { + + var symbol = 1; + + do { + + symbol = ( symbol << 1 ) | rangeDecoder.decodeBit( this._decoders, symbol ); + + }while ( symbol < 0x100 ); + + return symbol & 0xff; + + }; + + LZMA.Decoder2.prototype.decodeWithMatchByte = function ( rangeDecoder, matchByte ) { + + var symbol = 1, matchBit, bit; + + do { + + matchBit = ( matchByte >> 7 ) & 1; + matchByte <<= 1; + bit = rangeDecoder.decodeBit( this._decoders, ( ( 1 + matchBit ) << 8 ) + symbol ); + symbol = ( symbol << 1 ) | bit; + if ( matchBit !== bit ) { + + while ( symbol < 0x100 ) { + + symbol = ( symbol << 1 ) | rangeDecoder.decodeBit( this._decoders, symbol ); + + } + break; + + } + + }while ( symbol < 0x100 ); + + return symbol & 0xff; + + }; + + LZMA.LiteralDecoder = function () { + }; + + LZMA.LiteralDecoder.prototype.create = function ( numPosBits, numPrevBits ) { + + var i; + + if ( this._coders + && ( this._numPrevBits === numPrevBits ) + && ( this._numPosBits === numPosBits ) ) { + + return; + + } + this._numPosBits = numPosBits; + this._posMask = ( 1 << numPosBits ) - 1; + this._numPrevBits = numPrevBits; + + this._coders = []; + + i = 1 << ( this._numPrevBits + this._numPosBits ); + while ( i -- ) { + + this._coders[ i ] = new LZMA.Decoder2(); + + } + + }; + + LZMA.LiteralDecoder.prototype.init = function () { + + var i = 1 << ( this._numPrevBits + this._numPosBits ); + while ( i -- ) { + + this._coders[ i ].init(); + + } + + }; + + LZMA.LiteralDecoder.prototype.getDecoder = function ( pos, prevByte ) { + + return this._coders[ ( ( pos & this._posMask ) << this._numPrevBits ) + + ( ( prevByte & 0xff ) >>> ( 8 - this._numPrevBits ) ) ]; + + }; + + LZMA.Decoder = function () { + + this._outWindow = new LZMA.OutWindow(); + this._rangeDecoder = new LZMA.RangeDecoder(); + this._isMatchDecoders = []; + this._isRepDecoders = []; + this._isRepG0Decoders = []; + this._isRepG1Decoders = []; + this._isRepG2Decoders = []; + this._isRep0LongDecoders = []; + this._posSlotDecoder = []; + this._posDecoders = []; + this._posAlignDecoder = new LZMA.BitTreeDecoder( 4 ); + this._lenDecoder = new LZMA.LenDecoder(); + this._repLenDecoder = new LZMA.LenDecoder(); + this._literalDecoder = new LZMA.LiteralDecoder(); + this._dictionarySize = - 1; + this._dictionarySizeCheck = - 1; + + this._posSlotDecoder[ 0 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 1 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 2 ] = new LZMA.BitTreeDecoder( 6 ); + this._posSlotDecoder[ 3 ] = new LZMA.BitTreeDecoder( 6 ); + + }; + + LZMA.Decoder.prototype.setDictionarySize = function ( dictionarySize ) { + + if ( dictionarySize < 0 ) { + + return false; + + } + if ( this._dictionarySize !== dictionarySize ) { + + this._dictionarySize = dictionarySize; + this._dictionarySizeCheck = Math.max( this._dictionarySize, 1 ); + this._outWindow.create( Math.max( this._dictionarySizeCheck, 4096 ) ); + + } + return true; + + }; + + LZMA.Decoder.prototype.setLcLpPb = function ( lc, lp, pb ) { + + var numPosStates = 1 << pb; + + if ( lc > 8 || lp > 4 || pb > 4 ) { + + return false; + + } + + this._literalDecoder.create( lp, lc ); + + this._lenDecoder.create( numPosStates ); + this._repLenDecoder.create( numPosStates ); + this._posStateMask = numPosStates - 1; + + return true; + + }; + + LZMA.Decoder.prototype.init = function () { + + var i = 4; + + this._outWindow.init( false ); + + LZMA.initBitModels( this._isMatchDecoders, 192 ); + LZMA.initBitModels( this._isRep0LongDecoders, 192 ); + LZMA.initBitModels( this._isRepDecoders, 12 ); + LZMA.initBitModels( this._isRepG0Decoders, 12 ); + LZMA.initBitModels( this._isRepG1Decoders, 12 ); + LZMA.initBitModels( this._isRepG2Decoders, 12 ); + LZMA.initBitModels( this._posDecoders, 114 ); + + this._literalDecoder.init(); + + while ( i -- ) { + + this._posSlotDecoder[ i ].init(); + + } + + this._lenDecoder.init(); + this._repLenDecoder.init(); + this._posAlignDecoder.init(); + this._rangeDecoder.init(); + + }; + + LZMA.Decoder.prototype.decode = function ( inStream, outStream, outSize ) { + + var state = 0, rep0 = 0, rep1 = 0, rep2 = 0, rep3 = 0, nowPos64 = 0, prevByte = 0, + posState, decoder2, len, distance, posSlot, numDirectBits; + + this._rangeDecoder.setStream( inStream ); + this._outWindow.setStream( outStream ); + + this.init(); + + while ( outSize < 0 || nowPos64 < outSize ) { + + posState = nowPos64 & this._posStateMask; + + if ( this._rangeDecoder.decodeBit( this._isMatchDecoders, ( state << 4 ) + posState ) === 0 ) { + + decoder2 = this._literalDecoder.getDecoder( nowPos64 ++, prevByte ); + + if ( state >= 7 ) { + + prevByte = decoder2.decodeWithMatchByte( this._rangeDecoder, this._outWindow.getByte( rep0 ) ); + + } else { + + prevByte = decoder2.decodeNormal( this._rangeDecoder ); + + } + this._outWindow.putByte( prevByte ); + + state = state < 4 ? 0 : state - ( state < 10 ? 3 : 6 ); + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepDecoders, state ) === 1 ) { + + len = 0; + if ( this._rangeDecoder.decodeBit( this._isRepG0Decoders, state ) === 0 ) { + + if ( this._rangeDecoder.decodeBit( this._isRep0LongDecoders, ( state << 4 ) + posState ) === 0 ) { + + state = state < 7 ? 9 : 11; + len = 1; + + } + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepG1Decoders, state ) === 0 ) { + + distance = rep1; + + } else { + + if ( this._rangeDecoder.decodeBit( this._isRepG2Decoders, state ) === 0 ) { + + distance = rep2; + + } else { + + distance = rep3; + rep3 = rep2; + + } + rep2 = rep1; + + } + rep1 = rep0; + rep0 = distance; + + } + if ( len === 0 ) { + + len = 2 + this._repLenDecoder.decode( this._rangeDecoder, posState ); + state = state < 7 ? 8 : 11; + + } + + } else { + + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + + len = 2 + this._lenDecoder.decode( this._rangeDecoder, posState ); + state = state < 7 ? 7 : 10; + + posSlot = this._posSlotDecoder[ len <= 5 ? len - 2 : 3 ].decode( this._rangeDecoder ); + if ( posSlot >= 4 ) { + + numDirectBits = ( posSlot >> 1 ) - 1; + rep0 = ( 2 | ( posSlot & 1 ) ) << numDirectBits; + + if ( posSlot < 14 ) { + + rep0 += LZMA.reverseDecode2( this._posDecoders, + rep0 - posSlot - 1, this._rangeDecoder, numDirectBits ); + + } else { + + rep0 += this._rangeDecoder.decodeDirectBits( numDirectBits - 4 ) << 4; + rep0 += this._posAlignDecoder.reverseDecode( this._rangeDecoder ); + if ( rep0 < 0 ) { + + if ( rep0 === - 1 ) { + + break; + + } + return false; + + } + + } + + } else { + + rep0 = posSlot; + + } + + } + + if ( rep0 >= nowPos64 || rep0 >= this._dictionarySizeCheck ) { + + return false; + + } + + this._outWindow.copyBlock( rep0, len ); + nowPos64 += len; + prevByte = this._outWindow.getByte( 0 ); + + } + + } + + this._outWindow.flush(); + this._outWindow.releaseStream(); + this._rangeDecoder.releaseStream(); + + return true; + + }; + + LZMA.Decoder.prototype.setDecoderProperties = function ( properties ) { + + var value, lc, lp, pb, dictionarySize; + + if ( properties.size < 5 ) { + + return false; + + } + + value = properties.readByte(); + lc = value % 9; + value = ~~ ( value / 9 ); + lp = value % 5; + pb = ~~ ( value / 5 ); + + if ( ! this.setLcLpPb( lc, lp, pb ) ) { + + return false; + + } + + dictionarySize = properties.readByte(); + dictionarySize |= properties.readByte() << 8; + dictionarySize |= properties.readByte() << 16; + dictionarySize += properties.readByte() * 16777216; + + return this.setDictionarySize( dictionarySize ); + + }; + + LZMA.decompress = function ( properties, inStream, outStream, outSize ) { + + var decoder = new LZMA.Decoder(); + + if ( ! decoder.setDecoderProperties( properties ) ) { + + throw "Incorrect stream properties"; + + } + + if ( ! decoder.decode( inStream, outStream, outSize ) ) { + + throw "Error in data stream"; + + } + + return true; + + }; + + LZMA.decompressFile = function ( inStream, outStream ) { + + var decoder = new LZMA.Decoder(), outSize; + + if ( ! decoder.setDecoderProperties( inStream ) ) { + + throw "Incorrect stream properties"; + + } + + outSize = inStream.readByte(); + outSize |= inStream.readByte() << 8; + outSize |= inStream.readByte() << 16; + outSize += inStream.readByte() * 16777216; + + inStream.readByte(); + inStream.readByte(); + inStream.readByte(); + inStream.readByte(); + + if ( ! decoder.decode( inStream, outStream, outSize ) ) { + + throw "Error in data stream"; + + } + + return true; + + }; + + return LZMA; + +}(); - return true; -}; /** * SEA3D LZMA * @author Sunag / http://www.sunag.com.br/ */ -SEA3D.File.LZMAUncompress = function( data ) { +SEA3D.File.LZMAUncompress = function ( data ) { data = new Uint8Array( data ); var inStream = { data: data, position: 0, - readByte: function() { + readByte: function () { return this.data[ this.position ++ ]; } - } + }; var outStream = { data: [], position: 0, - writeByte: function( value ) { + writeByte: function ( value ) { this.data[ this.position ++ ] = value; } - } + }; - LZMA.decompressFile( inStream, outStream ); + SEA3D.LZMA.decompressFile( inStream, outStream ); return new Uint8Array( outStream.data ).buffer; -} +}; SEA3D.File.setDecompressionEngine( 2, "lzma", SEA3D.File.LZMAUncompress ); diff --git a/examples/js/loaders/sea3d/SEA3DLegacy.js b/examples/js/loaders/sea3d/SEA3DLegacy.js index 3e3b4ffd284624852bd4c933569a0d597992d9ee..bccdabf72a69837f90933921668ba2e9e3cefee5 100644 --- a/examples/js/loaders/sea3d/SEA3DLegacy.js +++ b/examples/js/loaders/sea3d/SEA3DLegacy.js @@ -9,19 +9,23 @@ // Header // -THREE.SEA3D.prototype._onHead = THREE.SEA3D.prototype.onHead; -THREE.SEA3D.prototype._updateTransform = THREE.SEA3D.prototype.updateTransform; -THREE.SEA3D.prototype._readVertexAnimation = THREE.SEA3D.prototype.readVertexAnimation; -THREE.SEA3D.prototype._readGeometryBuffer = THREE.SEA3D.prototype.readGeometryBuffer; -THREE.SEA3D.prototype._readLine = THREE.SEA3D.prototype.readLine; -THREE.SEA3D.prototype._getSkeletonAnimation = THREE.SEA3D.prototype.getSkeletonAnimation; -THREE.SEA3D.prototype._applyDefaultAnimation = THREE.SEA3D.prototype.applyDefaultAnimation; +Object.assign( THREE.SEA3D.prototype, { + + _onHead: THREE.SEA3D.prototype.onHead, + _updateTransform: THREE.SEA3D.prototype.updateTransform, + _readVertexAnimation: THREE.SEA3D.prototype.readVertexAnimation, + _readGeometryBuffer: THREE.SEA3D.prototype.readGeometryBuffer, + _readLine: THREE.SEA3D.prototype.readLine, + _getSkeletonAnimation: THREE.SEA3D.prototype.getSkeletonAnimation, + _applyDefaultAnimation: THREE.SEA3D.prototype.applyDefaultAnimation + +} ); // // Utils // -THREE.SEA3D.prototype.isLegacy = function( sea ) { +THREE.SEA3D.prototype.isLegacy = function ( sea ) { var sea3d = sea.sea3d; @@ -37,7 +41,7 @@ THREE.SEA3D.prototype.isLegacy = function( sea ) { }; -THREE.SEA3D.prototype.flipZVec3 = function( v ) { +THREE.SEA3D.prototype.flipZVec3 = function ( v ) { if ( ! v ) return; @@ -55,7 +59,7 @@ THREE.SEA3D.prototype.flipZVec3 = function( v ) { }; -THREE.SEA3D.prototype.expandJoints = function( sea ) { +THREE.SEA3D.prototype.expandJoints = function ( sea ) { var numJoints = sea.numVertex * 4; @@ -92,7 +96,7 @@ THREE.SEA3D.prototype.expandJoints = function( sea ) { }; -THREE.SEA3D.prototype.compressJoints = function( sea ) { +THREE.SEA3D.prototype.compressJoints = function ( sea ) { var numJoints = sea.numVertex * 4; @@ -129,7 +133,7 @@ THREE.SEA3D.prototype.compressJoints = function( sea ) { }; -THREE.SEA3D.prototype.flipZIndex = function( v ) { +THREE.SEA3D.prototype.flipZIndex = function ( v ) { var i = 1; // y >-< z @@ -147,12 +151,12 @@ THREE.SEA3D.prototype.flipZIndex = function( v ) { }; -THREE.SEA3D.prototype.flipMatrixBone = function( mtx ) { +THREE.SEA3D.prototype.flipMatrixBone = function ( mtx ) { var zero = new THREE.Vector3(); var buf1 = new THREE.Matrix4(); - return function( mtx ) { + return function ( mtx ) { buf1.copy( mtx ); @@ -170,13 +174,13 @@ THREE.SEA3D.prototype.flipMatrixBone = function( mtx ) { }(); -THREE.SEA3D.prototype.flipMatrixScale = function( local, global, parent, parentGlobal ) { +THREE.SEA3D.prototype.flipMatrixScale = function ( local, global, parent, parentGlobal ) { var pos = new THREE.Vector3(); var qua = new THREE.Quaternion(); var slc = new THREE.Vector3(); - return function( local, global, parent, parentGlobal ) { + return function ( local, global, parent, parentGlobal ) { if ( parent ) local.multiplyMatrices( parent, local ); @@ -213,7 +217,7 @@ THREE.SEA3D.prototype.flipMatrixScale = function( local, global, parent, parentG // Legacy // -THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { +THREE.SEA3D.prototype.updateAnimationSet = function ( obj3d ) { var buf1 = new THREE.Matrix4(); var buf2 = new THREE.Matrix4(); @@ -226,7 +230,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { var to_qua = new THREE.Quaternion(); var to_slc = new THREE.Vector3(); - return function( obj3d ) { + return function ( obj3d ) { var anmSet = obj3d.animation.animationSet; var relative = obj3d.animation.relative; @@ -246,15 +250,17 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { var numFrames = raw.length / data.blockLength; switch ( kind ) { + case SEA3D.Animation.POSITION: case SEA3D.Animation.ROTATION: case SEA3D.Animation.SCALE: t_anm.push( { - kind : kind, - numFrames : numFrames, - raw : raw + kind: kind, + numFrames: numFrames, + raw: raw } ); break; + } } @@ -269,8 +275,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { buf1.identity(); parent = this.flipMatrixScale( buf2.copy( obj3d.matrixWorld ) ); - } - else { + } else { if ( obj3d.parent ) { @@ -292,6 +297,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { kind = t_anm[ t ].kind; switch ( kind ) { + case SEA3D.Animation.POSITION: c = f * 3; @@ -345,6 +351,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { kind = t_anm[ t ].kind; switch ( kind ) { + case SEA3D.Animation.POSITION: c = f * 3; @@ -375,6 +382,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { raw[ c + 2 ] = to_slc.z; break; + } } @@ -390,7 +398,7 @@ THREE.SEA3D.prototype.updateAnimationSet = function( obj3d ) { }(); -THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { +THREE.SEA3D.prototype.applyDefaultAnimation = function ( sea, animatorClass ) { this._applyDefaultAnimation( sea, animatorClass ); @@ -402,12 +410,12 @@ THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { }; -THREE.SEA3D.prototype.updateTransform = function( obj3d, sea ) { +THREE.SEA3D.prototype.updateTransform = function ( obj3d, sea ) { var buf1 = new THREE.Matrix4(); var identity = new THREE.Matrix4(); - return function( obj3d, sea ) { + return function ( obj3d, sea ) { if ( this.isLegacy( sea ) ) { @@ -430,8 +438,7 @@ THREE.SEA3D.prototype.updateTransform = function( obj3d, sea ) { obj3d.updateMatrixWorld(); - } - else { + } else { this._updateTransform( obj3d, sea ); @@ -441,7 +448,7 @@ THREE.SEA3D.prototype.updateTransform = function( obj3d, sea ) { }(); -THREE.SEA3D.prototype.readSkeleton = function( sea ) { +THREE.SEA3D.prototype.readSkeleton = function ( sea ) { var mtx_tmp_inv = new THREE.Matrix4(), mtx_local = new THREE.Matrix4(), @@ -449,14 +456,14 @@ THREE.SEA3D.prototype.readSkeleton = function( sea ) { pos = new THREE.Vector3(), qua = new THREE.Quaternion(); - return function( sea ) { + return function ( sea ) { var bones = [], isLegacy = sea.sea3d.config.legacy; for ( var i = 0; i < sea.joint.length; i ++ ) { - var bone = sea.joint[ i ] + var bone = sea.joint[ i ]; // get world inverse matrix @@ -509,21 +516,21 @@ THREE.SEA3D.prototype.readSkeleton = function( sea ) { }(); -THREE.SEA3D.prototype.getSkeletonAnimation = function( sea, skl ) { +THREE.SEA3D.prototype.getSkeletonAnimation = function ( sea, skl ) { if ( this.isLegacy( sea ) ) return this.getSkeletonAnimationLegacy( sea, skl ); else return this._getSkeletonAnimation( sea, skl ); }; -THREE.SEA3D.prototype.getSkeletonAnimationLegacy = function( sea, skl ) { +THREE.SEA3D.prototype.getSkeletonAnimationLegacy = function ( sea, skl ) { var mtx_tmp_inv = new THREE.Matrix4(), mtx_local = new THREE.Matrix4(), mtx_global = new THREE.Matrix4(), mtx_parent = new THREE.Matrix4(); - return function( sea, skl ) { + return function ( sea, skl ) { if ( sea.tag ) return sea.tag; @@ -588,8 +595,7 @@ THREE.SEA3D.prototype.getSkeletonAnimationLegacy = function( sea, skl ) { mtx_local.multiplyMatrices( mtx_parent, mtx_global ); - } - else { + } else { this.flipMatrixBone( mtx_local ); @@ -627,7 +633,7 @@ THREE.SEA3D.prototype.getSkeletonAnimationLegacy = function( sea, skl ) { }(); -THREE.SEA3D.prototype.readVertexAnimation = function( sea ) { +THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) { if ( this.isLegacy( sea ) ) { @@ -646,7 +652,7 @@ THREE.SEA3D.prototype.readVertexAnimation = function( sea ) { }; -THREE.SEA3D.prototype.readGeometryBuffer = function( sea ) { +THREE.SEA3D.prototype.readGeometryBuffer = function ( sea ) { if ( this.isLegacy( sea ) ) { @@ -664,7 +670,7 @@ THREE.SEA3D.prototype.readGeometryBuffer = function( sea ) { }; -THREE.SEA3D.prototype.readLines = function( sea ) { +THREE.SEA3D.prototype.readLines = function ( sea ) { if ( this.isLegacy( sea ) ) { @@ -676,13 +682,13 @@ THREE.SEA3D.prototype.readLines = function( sea ) { }; -THREE.SEA3D.prototype.onHead = function( args ) { +THREE.SEA3D.prototype.onHead = function ( args ) { // TODO: Ignore sign }; -THREE.SEA3D.EXTENSIONS_LOADER.push( { setTypeRead: function() { +THREE.SEA3D.EXTENSIONS_LOADER.push( { setTypeRead: function () { // CONFIG diff --git a/examples/js/loaders/sea3d/SEA3DLoader.js b/examples/js/loaders/sea3d/SEA3DLoader.js index ba14fe4ed2e336441813949ac4dcbf622b4cd8cb..99c933fd887b84d6a4d38d516a367de8d32c86d6 100644 --- a/examples/js/loaders/sea3d/SEA3DLoader.js +++ b/examples/js/loaders/sea3d/SEA3DLoader.js @@ -5,73 +5,110 @@ 'use strict'; +// +// Polyfills +// + +if ( THREE.Float32BufferAttribute === undefined ) { + + THREE.Float32BufferAttribute = THREE.Float32Attribute; + +} + +// // // SEA3D // -THREE.SEA3D = function( config ) { +THREE.SEA3D = function ( config ) { this.config = { - id : "", - scripts : true, - runScripts : true, - autoPlay : false, - dummys : true, - multiplier : 1, - bounding : true, - audioRolloffFactor : 10, - lights : true, - useVertexTexture : true, - forceStatic : false, - streaming : true, - timeLimit : 10, - stageWidth : window ? window.innerWidth : 1024, - stageHeight : window ? window.innerHeight : 1024 + id: "", + scripts: true, + runScripts: true, + autoPlay: false, + dummys: true, + multiplier: 1, + bounding: true, + audioRolloffFactor: 10, + lights: true, + useEnvironment: true, + useVertexTexture: true, + forceStatic: false, + forcePremultipliedAlpha: false, + streaming: true, + async: true, + paths: {}, + timeLimit: 10 }; if ( config ) this.loadConfig( config ); }; +// +// Config +// + +THREE.SEA3D.MTXBUF = new THREE.Matrix4(); +THREE.SEA3D.VECBUF = new THREE.Vector3(); +THREE.SEA3D.QUABUF = new THREE.Quaternion(); + +THREE.SEA3D.BACKGROUND_COLOR = 0x333333; +THREE.SEA3D.HELPER_COLOR = 0x9AB9E5; +THREE.SEA3D.RTT_SIZE = 512; + THREE.SEA3D.prototype = { constructor: THREE.SEA3D, - set container ( val ) { + set container( val ) { this.config.container = val; }, - get container () { + get container() { return this.config.container; + }, + + setShadowMap: function ( light ) { + + light.shadow.mapSize.width = 2048; + light.shadow.mapSize.height = 1024; + + light.castShadow = true; + + light.shadow.camera.left = - 200; + light.shadow.camera.right = 200; + light.shadow.camera.top = 200; + light.shadow.camera.bottom = - 200; + + light.shadow.camera.near = 1; + light.shadow.camera.far = 3000; + light.shadow.camera.fov = 45; + + light.shadow.bias = - 0.001; + } }; Object.assign( THREE.SEA3D.prototype, THREE.EventDispatcher.prototype ); -// -// Defaults -// - -THREE.SEA3D.BACKGROUND_COLOR = 0x333333; -THREE.SEA3D.HELPER_COLOR = 0x9AB9E5; -THREE.SEA3D.RTT_SIZE = 512; - // // Domain // -THREE.SEA3D.Domain = function( id, objects, container ) { +THREE.SEA3D.Domain = function ( id, objects, container ) { this.id = id; this.objects = objects; this.container = container; - this.scripts = []; + this.sources = []; this.global = {}; this.scriptTargets = []; @@ -80,58 +117,57 @@ THREE.SEA3D.Domain = function( id, objects, container ) { }; -THREE.SEA3D.Domain.prototype = { - constructor: THREE.SEA3D.Domain, +Object.assign( THREE.SEA3D.Domain.prototype, { - add : function( src ) { + add: function ( src ) { - this.scripts.push( src ); + this.sources.push( src ); }, - remove : function( src ) { + remove: function ( src ) { - this.scripts.splice( this.scripts.indexOf( src ), 1 ); + this.sources.splice( this.sources.indexOf( src ), 1 ); }, - contains : function( src ) { + contains: function ( src ) { - return this.scripts.indexOf( src ) != - 1; + return this.sources.indexOf( src ) != - 1; }, - addEvent : function( type, listener ) { + addEventListener: function ( type, listener ) { this.events.addEventListener( type, listener ); }, - hasEvent : function( type, listener ) { + hasEventListener: function ( type, listener ) { return this.events.hasEventListener( type, listener ); }, - removeEvent : function( type, listener ) { + removeEventListener: function ( type, listener ) { this.events.removeEventListener( type, listener ); }, - print : function() { + print: function () { console.log.apply( console, arguments ); }, - watch : function() { + watch: function () { console.log.apply( console, 'watch:', arguments ); }, - runScripts : function() { + runScripts: function () { for ( var i = 0; i < this.scriptTargets.length; i ++ ) { @@ -141,7 +177,7 @@ THREE.SEA3D.Domain.prototype = { }, - runJSMList : function( target ) { + runJSMList: function ( target ) { var scripts = target.scripts; @@ -155,16 +191,16 @@ THREE.SEA3D.Domain.prototype = { }, - runJSM : function( target, script ) { + runJSM: function ( target, script ) { if ( target.local == undefined ) target.local = {}; var include = { - print : this.print, - watch : this.watch, - sea3d : this, - scene : this.container, - source : new THREE.SEA3D.ScriptDomain( this, target instanceof THREE.SEA3D.Domain ) + print: this.print, + watch: this.watch, + sea3d: this, + scene: this.container, + source: new THREE.SEA3D.ScriptDomain( this, target instanceof THREE.SEA3D.Domain ) }; Object.freeze( include.source ); @@ -173,7 +209,7 @@ THREE.SEA3D.Domain.prototype = { try { - this.methods[ script.method ] ( + this.methods[ script.method ]( include, this.getReference, this.global, @@ -182,8 +218,7 @@ THREE.SEA3D.Domain.prototype = { script.params ); - } - catch ( e ) { + } catch ( e ) { console.error( 'SEA3D JavaScript: Error running method "' + script.method + '".' ); console.error( e ); @@ -192,13 +227,13 @@ THREE.SEA3D.Domain.prototype = { }, - getReference : function( ns ) { + getReference: function ( ns ) { return eval( ns ); }, - disposeList : function( list ) { + disposeList: function ( list ) { if ( ! list || ! list.length ) return; @@ -206,20 +241,24 @@ THREE.SEA3D.Domain.prototype = { var i = list.length; - while ( i -- ) list[ i ].dispose(); + while ( i -- ) { + + list[ i ].dispose(); + + } }, - dispatchEvent : function( event ) { + dispatchEvent: function ( event ) { event.domain = this; - var scripts = this.scripts.concat(), - i = scripts.length; + var sources = this.sources.concat(), + i = sources.length; while ( i -- ) { - scripts[ i ].dispatchEvent( event ); + sources[ i ].dispatchEvent( event ); } @@ -227,9 +266,9 @@ THREE.SEA3D.Domain.prototype = { }, - dispose : function() { + dispose: function () { - this.disposeList( this.scripts ); + this.disposeList( this.sources ); while ( this.container.children.length ) { @@ -250,26 +289,25 @@ THREE.SEA3D.Domain.prototype = { this.disposeList( this.materials ); this.disposeList( this.dummys ); - this.dispatchEvent( { type : "dispose" } ); + this.dispatchEvent( { type: "dispose" } ); } -}; +} ); // // Domain Manager // -THREE.SEA3D.DomainManager = function( autoDisposeRootDomain ) { +THREE.SEA3D.DomainManager = function ( autoDisposeRootDomain ) { this.domains = []; this.autoDisposeRootDomain = autoDisposeRootDomain == undefined ? true : false; }; -THREE.SEA3D.DomainManager.prototype = { - constructor: THREE.SEA3D.DomainManager, +Object.assign( THREE.SEA3D.DomainManager.prototype, { - onDisposeDomain : function( e ) { + onDisposeDomain: function ( e ) { this.remove( e.domain ); @@ -281,7 +319,7 @@ THREE.SEA3D.DomainManager.prototype = { }, - add : function( domain ) { + add: function ( domain ) { this._onDisposeDomain = this._onDisposeDomain || this.onDisposeDomain.bind( this ); @@ -295,7 +333,7 @@ THREE.SEA3D.DomainManager.prototype = { }, - remove : function( domain ) { + remove: function ( domain ) { domain.removeEvent( "dispose", this._onDisposeDomain ); @@ -303,13 +341,13 @@ THREE.SEA3D.DomainManager.prototype = { }, - contains : function( domain ) { + contains: function ( domain ) { return this.domains.indexOf( domain ) != - 1; }, - disposeList : function( list ) { + disposeList: function ( list ) { if ( ! list || ! list.length ) return; @@ -317,11 +355,15 @@ THREE.SEA3D.DomainManager.prototype = { var i = list.length; - while ( i -- ) list[ i ].dispose(); + while ( i -- ) { + + list[ i ].dispose(); + + } }, - dispose : function() { + dispose: function () { this.disposeList( this.domains ); this.disposeList( this.textures ); @@ -329,106 +371,107 @@ THREE.SEA3D.DomainManager.prototype = { this.disposeList( this.geometries ); } -}; + +} ); // -// Script +// Script ( closure for private functions ) // -THREE.SEA3D.ScriptDomain = function( domain, root ) { +THREE.SEA3D.ScriptDomain = function ( domain, root ) { domain = domain || new THREE.SEA3D.Domain(); domain.add( this ); var events = new THREE.EventDispatcher(); - this.getId = function() { + this.getId = function () { return domain.id; - } + }; - this.isRoot = function() { + this.isRoot = function () { return root; - } + }; - this.addEvent = function( type, listener ) { + this.addEventListener = function ( type, listener ) { events.addEventListener( type, listener ); - } + }; - this.hasEvent = function( type, listener ) { + this.hasEventListener = function ( type, listener ) { return events.hasEventListener( type, listener ); - } + }; - this.removeEvent = function( type, listener ) { + this.removeEventListener = function ( type, listener ) { events.removeEventListener( type, listener ); - } + }; - this.dispatchEvent = function( event ) { + this.dispatchEvent = function ( event ) { event.script = this; events.dispatchEvent( event ); - } + }; - this.dispose = function() { + this.dispose = function () { domain.remove( this ); if ( root ) domain.dispose(); - this.dispatchEvent( { type : "dispose" } ); + this.dispatchEvent( { type: "dispose" } ); - } + }; }; // -// Script Manager +// Script Manager ( closure for private functions ) // -THREE.SEA3D.ScriptManager = function() { +THREE.SEA3D.ScriptManager = function () { this.scripts = []; - var onDisposeScript = ( function( e ) { + var onDisposeScript = ( function ( e ) { this.remove( e.script ); } ).bind( this ); - this.add = function( src ) { + this.add = function ( src ) { - src.addEvent( "dispose", onDisposeScript ); + src.addEventListener( "dispose", onDisposeScript ); this.scripts.push( src ); - } + }; - this.remove = function( src ) { + this.remove = function ( src ) { - src.removeEvent( "dispose", onDisposeScript ); + src.removeEventListener( "dispose", onDisposeScript ); this.scripts.splice( this.scripts.indexOf( src ), 1 ); - } + }; - this.contains = function( src ) { + this.contains = function ( src ) { return this.scripts.indexOf( src ) > - 1; - } + }; - this.dispatchEvent = function( event ) { + this.dispatchEvent = function ( event ) { var scripts = this.scripts.concat(), i = scripts.length; @@ -439,7 +482,7 @@ THREE.SEA3D.ScriptManager = function() { } - } + }; }; @@ -449,11 +492,11 @@ THREE.SEA3D.ScriptManager = function() { THREE.SEA3D.ScriptHandler = new THREE.SEA3D.ScriptManager(); -THREE.SEA3D.ScriptHandler.dispatchUpdate = function( delta ) { +THREE.SEA3D.ScriptHandler.dispatchUpdate = function ( delta ) { this.dispatchEvent( { - type : "update", - delta : delta + type: "update", + delta: delta } ); }; @@ -462,7 +505,7 @@ THREE.SEA3D.ScriptHandler.dispatchUpdate = function( delta ) { // Animator // -THREE.SEA3D.Animator = function( clips, mixer ) { +THREE.SEA3D.Animator = function ( clips, mixer ) { this.clips = clips; @@ -470,206 +513,323 @@ THREE.SEA3D.Animator = function( clips, mixer ) { }; -THREE.SEA3D.Animator.prototype.update = function( dt ) { +Object.assign( THREE.SEA3D.Animator.prototype, { - this.mixer.update( dt || 0 ); + update: function ( dt ) { - if ( this.currentAnimationAction.paused ) { + this.mixer.update( dt || 0 ); - this.pause(); + if ( this.currentAnimationAction && this.currentAnimationAction.paused ) { - if ( this.currentAnimationData.onComplete ) this.currentAnimationData.onComplete( this ); + this.pause(); - } + if ( this.currentAnimationData && this.currentAnimationData.onComplete ) this.currentAnimationData.onComplete( this ); - return this; + } -}; + return this; -THREE.SEA3D.Animator.prototype.updateAnimations = function( mixer ) { + }, - if ( this.playing ) this.stop(); + updateAnimations: function ( mixer ) { - if ( this.mixer ) THREE.SEA3D.AnimationHandler.removeAnimator( this ); + if ( this.playing ) this.stop(); - this.mixer = mixer; + if ( this.mixer ) THREE.SEA3D.AnimationHandler.removeAnimator( this ); - this.relative = false; - this.playing = false; + this.mixer = mixer; - this.timeScale = 1; + this.relative = false; + this.playing = false; + this.paused = false; - this.animations = []; - this.animationsData = {}; + this.timeScale = 1; - this.clips = this instanceof THREE.SEA3D.Animator ? this.clips : this.geometry.animations; + this.animations = []; + this.animationsData = {}; + this.animationsDict = []; - for ( var i = 0, clips = this.clips; i < clips.length; i ++ ) { + this.clips = ( this instanceof THREE.SEA3D.Animator ? this.clips : this.geometry.animations ) || []; - var name = clips[ i ].name; + for ( var i = 0; i < this.clips.length; i ++ ) { - this.animations[ name ] = this.animations[ i ] = clips[ i ]; - this.animationsData[ name ] = this.animationsData[ i ] = {}; + this.addAnimation( this.clips[ i ] ); - } + } -}; + return this; -THREE.SEA3D.Animator.prototype.getStateByName = function( name ) { + }, - return this.animations.indexOf( this.animations[ name ] ); + addAnimation: function ( clip ) { -}; + var name = clip.name; -THREE.SEA3D.Animator.prototype.getStateNameByIndex = function( index ) { + this.animations.push( clip ); + this.animationsDict[ name ] = clip; + this.animationsData[ name ] = {}; - return this.animations[ index ].name; + this.mixer.clipAction( clip ); -}; + return this; -THREE.SEA3D.Animator.prototype.pause = function() { + }, - if ( this.playing && this.currentAnimation ) { + removeAnimation: function ( clip ) { - THREE.SEA3D.AnimationHandler.removeAnimator( this ); + var name = clip.name; - this.playing = false; + delete this.animationsDict[ name ]; + delete this.animationsData[ name ]; + this.animations.splice( this.animations.indexOf( clip ), 1 ); - } + this.mixer.uncacheClip( clip ); -}; + return this; -THREE.SEA3D.Animator.prototype.resume = function() { + }, - if ( ! this.playing && this.currentAnimation ) { + getAnimation: function ( name ) { - THREE.SEA3D.AnimationHandler.addAnimator( this ); + return this.animationsDict[ name ] || this.animations[ name ]; - this.playing = true; + }, - } + getAnimationData: function ( name ) { - return this; + return this.animationsData[ this.getAnimation( name ).name ]; -}; + }, -THREE.SEA3D.Animator.prototype.setTimeScale = function( val ) { + setAnimationWeight: function ( name, val ) { - this.timeScale = val; + this.mixer.clipAction( this.getAnimation( name ) ).setEffectiveWeight( val ); - if ( this.currentAnimationAction ) this.updateTimeScale(); + }, -}; + getAnimationWeight: function ( name ) { -THREE.SEA3D.Animator.prototype.getTimeScale = function() { + return this.mixer.clipAction( this.getAnimation( name ) ).getEffectiveWeight(); - return this.timeScale; + }, -}; + pause: function () { -THREE.SEA3D.Animator.prototype.updateTimeScale = function() { + if ( this.playing && this.currentAnimation ) { - this.mixer.timeScale = this.timeScale * ( this.currentAnimation ? this.currentAnimation.timeScale : 1 ); + THREE.SEA3D.AnimationHandler.removeAnimator( this ); -}; + this.playing = false; -THREE.SEA3D.Animator.prototype.play = function( name, crossfade, offset, weight ) { + } - var animation = this.animations[ name ]; + return this; - if ( animation == this.currentAnimation ) { + }, - if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : - ( this.mixer.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + resume: function () { - this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); - this.currentAnimationAction.paused = false; + if ( ! this.playing && this.currentAnimation ) { - return this.resume(); + THREE.SEA3D.AnimationHandler.addAnimator( this ); - } else { + this.playing = true; + + } + + return this; + + }, + + setTimeScale: function ( val ) { + + this.timeScale = val; + + if ( this.currentAnimationAction ) this.updateTimeScale(); + + return this; + + }, + + getTimeScale: function () { + + return this.timeScale; + + }, + + updateTimeScale: function () { + + this.currentAnimationAction.setEffectiveTimeScale( this.timeScale * ( this.currentAnimation ? this.currentAnimation.timeScale : 1 ) ); + + return this; + + }, + + play: function ( name, crossfade, offset, weight ) { + + var animation = this.getAnimation( name ); if ( ! animation ) throw new Error( 'Animation "' + name + '" not found.' ); - this.previousAnimation = this.currentAnimation; - this.currentAnimation = animation; + if ( animation == this.currentAnimation ) { + + if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : + ( this.currentAnimationAction.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + + this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); + this.currentAnimationAction.paused = false; + + return this.resume(); + + } else { + + this.previousAnimation = this.currentAnimation; + this.currentAnimation = animation; + + this.previousAnimationAction = this.currentAnimationAction; + this.currentAnimationAction = this.mixer.clipAction( animation ).setLoop( animation.loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset(); + this.currentAnimationAction.clampWhenFinished = ! animation.loop; + this.currentAnimationAction.paused = false; + + this.previousAnimationData = this.currentAnimationData; + this.currentAnimationData = this.animationsData[ animation.name ]; + + this.updateTimeScale(); + + if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : + ( this.currentAnimationAction.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + + this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); + + this.currentAnimationAction.play(); + + if ( ! this.playing ) this.mixer.update( 0 ); + + this.playing = true; + + if ( this.previousAnimation ) this.previousAnimationAction.crossFadeTo( this.currentAnimationAction, crossfade || 0, false ); + + THREE.SEA3D.AnimationHandler.addAnimator( this ); + + } + + return this; + + }, + + stop: function () { + + if ( this.playing ) THREE.SEA3D.AnimationHandler.removeAnimator( this ); + + if ( this.currentAnimation ) { - this.previousAnimationAction = this.currentAnimationAction; - this.currentAnimationAction = this.mixer.clipAction( animation ).setLoop( animation.loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset(); - this.currentAnimationAction.clampWhenFinished = ! animation.loop; - this.currentAnimationAction.paused = false; + this.currentAnimationAction.stop(); - this.previousAnimationData = this.currentAnimationData; - this.currentAnimationData = this.animationsData[ name ]; + this.previousAnimation = this.currentAnimation; + this.previousAnimationData = this.currentAnimationData; + this.previousAnimationAction = this.currentAnimationAction; - this.updateTimeScale(); + delete this.currentAnimationAction; + delete this.currentAnimationData; + delete this.currentAnimation; - if ( offset !== undefined || ! animation.loop ) this.currentAnimationAction.time = offset !== undefined ? offset : - ( this.mixer.timeScale >= 0 ? 0 : this.currentAnimation.duration ); + this.playing = false; - this.currentAnimationAction.setEffectiveWeight( weight !== undefined ? weight : 1 ); + } + + return this; + + }, - this.currentAnimationAction.play(); + playw: function ( name, weight ) { - if ( ! this.playing ) this.mixer.update( 0 ); + if ( ! this.playing && ! this.paused ) THREE.SEA3D.AnimationHandler.addAnimator( this ); + + var animation = this.getAnimation( name ); this.playing = true; - if ( this.previousAnimation ) this.previousAnimationAction.crossFadeTo( this.currentAnimationAction, crossfade || 0, true ); + var clip = this.mixer.clipAction( animation ); + clip.setLoop( animation.loop ? THREE.LoopRepeat : THREE.LoopOnce, Infinity ).reset(); + clip.clampWhenFinished = ! animation.loop; + clip.paused = false; - THREE.SEA3D.AnimationHandler.addAnimator( this ); + clip.setEffectiveWeight( weight ).play(); - } + return clip; - return this; + }, -}; + crossFade: function ( fromAnimName, toAnimName, duration, wrap ) { -THREE.SEA3D.Animator.prototype.stop = function() { + this.mixer.stopAllAction(); - if ( this.currentAnimation ) { + var fromAction = this.playw( fromAnimName, 1 ); + var toAction = this.playw( toAnimName, 1 ); - this.currentAnimationAction.stop(); + fromAction.crossFadeTo( toAction, duration, wrap !== undefined ? wrap : false ); - THREE.SEA3D.AnimationHandler.removeAnimator( this ); + return this; - this.previousAnimation = this.currentAnimation; - this.previousAnimationData = this.currentAnimationData; - this.previousAnimationAction = this.currentAnimationAction; + }, + + stopAll: function () { - delete this.currentAnimationAction; - delete this.currentAnimationData; - delete this.currentAnimation; + this.stop().mixer.stopAllAction(); this.playing = false; - } + return this; - return this; + }, -}; + unPauseAll: function () { -THREE.SEA3D.Animator.prototype.setRelative = function( val ) { + this.mixer.timeScale = 1; - if ( this.relative == val ) return; + this.playing = true; + this.paused = false; - this.stop(); + return this; - this.relative = val; + }, -}; + pauseAll: function () { -THREE.SEA3D.Animator.prototype.getRelative = function() { + this.mixer.timeScale = 0; - return this.relative; + this.playing = false; + this.paused = true; -}; + return this; + + }, + + setRelative: function ( val ) { + + if ( this.relative == val ) return; + + this.stop(); + + this.relative = val; + + return this; + + }, + + getRelative: function () { + + return this.relative; + + } + +} ); // // Object3D Animator // -THREE.SEA3D.Object3DAnimator = function( clips, object3d ) { +THREE.SEA3D.Object3DAnimator = function ( clips, object3d ) { this.object3d = object3d; @@ -677,165 +837,180 @@ THREE.SEA3D.Object3DAnimator = function( clips, object3d ) { }; -THREE.SEA3D.Object3DAnimator.prototype = Object.create( THREE.SEA3D.Animator.prototype ); -THREE.SEA3D.Object3DAnimator.prototype.constructor = THREE.SEA3D.Object3DAnimator; +THREE.SEA3D.Object3DAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Animator.prototype ), { + + constructor: THREE.SEA3D.Object3DAnimator, -THREE.SEA3D.Object3DAnimator.prototype.stop = function() { + stop: function () { - if ( this.currentAnimation ) { + if ( this.currentAnimation ) { - var animate = this.object3d.animate; + var animate = this.object3d.animate; - if ( animate && this instanceof THREE.SEA3D.Object3DAnimator ) { + if ( animate && this instanceof THREE.SEA3D.Object3DAnimator ) { - animate.position.set( 0, 0, 0 ); - animate.quaternion.set( 0, 0, 0, 1 ); - animate.scale.set( 1, 1, 1 ); + animate.position.set( 0, 0, 0 ); + animate.quaternion.set( 0, 0, 0, 1 ); + animate.scale.set( 1, 1, 1 ); + + } } - } + THREE.SEA3D.Animator.prototype.stop.call( this ); - THREE.SEA3D.Animator.prototype.stop.call( this ); + }, -}; + setRelative: function ( val ) { -THREE.SEA3D.Object3DAnimator.prototype.setRelative = function( val ) { + THREE.SEA3D.Animator.prototype.setRelative.call( this, val ); - THREE.SEA3D.Animator.prototype.setRelative.call( this, val ); + this.object3d.setAnimator( this.relative ); - this.object3d.setAnimator( this.relative ); + this.updateAnimations( new THREE.AnimationMixer( this.relative ? this.object3d.animate : this.object3d ) ); - this.updateAnimations( new THREE.AnimationMixer( this.relative ? this.object3d.animate : this.object3d ) ); + } -}; +} ); // // Camera Animator // -THREE.SEA3D.CameraAnimator = function( clips, object3d ) { +THREE.SEA3D.CameraAnimator = function ( clips, object3d ) { THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); }; -THREE.SEA3D.CameraAnimator.prototype = Object.create( THREE.SEA3D.Object3DAnimator.prototype ); -THREE.SEA3D.CameraAnimator.prototype.constructor = THREE.SEA3D.CameraAnimator; +THREE.SEA3D.CameraAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.CameraAnimator + +} ); // // Sound Animator // -THREE.SEA3D.SoundAnimator = function( clips, object3d ) { +THREE.SEA3D.SoundAnimator = function ( clips, object3d ) { THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); }; -THREE.SEA3D.SoundAnimator.prototype = Object.create( THREE.SEA3D.Object3DAnimator.prototype ); -THREE.SEA3D.SoundAnimator.prototype.constructor = THREE.SEA3D.SoundAnimator; +THREE.SEA3D.SoundAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.SoundAnimator + +} ); // // Light Animator // -THREE.SEA3D.LightAnimator = function( clips, object3d ) { +THREE.SEA3D.LightAnimator = function ( clips, object3d ) { THREE.SEA3D.Object3DAnimator.call( this, clips, object3d ); }; -THREE.SEA3D.LightAnimator.prototype = Object.create( THREE.SEA3D.Object3DAnimator.prototype ); -THREE.SEA3D.LightAnimator.prototype.constructor = THREE.SEA3D.LightAnimator; +THREE.SEA3D.LightAnimator.prototype = Object.assign( Object.create( THREE.SEA3D.Object3DAnimator.prototype ), { + + constructor: THREE.SEA3D.LightAnimator + +} ); // // Container // -THREE.SEA3D.Object3D = function( ) { +THREE.SEA3D.Object3D = function ( ) { THREE.Object3D.call( this ); }; -THREE.SEA3D.Object3D.prototype = Object.create( THREE.Object3D.prototype ); -THREE.SEA3D.Object3D.prototype.constructor = THREE.SEA3D.Object3D; +THREE.SEA3D.Object3D.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), { -// Relative Animation Extension ( Only used if relative animation is enabled ) -// TODO: It can be done with shader + constructor: THREE.SEA3D.Object3D, -THREE.SEA3D.Object3D.prototype.updateAnimateMatrix = function( force ) { + // Relative Animation Extension ( Only used if relative animation is enabled ) + // TODO: It can be done with shader - if ( this.matrixAutoUpdate === true ) this.updateMatrix(); + updateAnimateMatrix: function ( force ) { - if ( this.matrixWorldNeedsUpdate === true || force === true ) { + if ( this.matrixAutoUpdate === true ) this.updateMatrix(); - if ( this.parent === null ) { + if ( this.matrixWorldNeedsUpdate === true || force === true ) { - this.matrixWorld.copy( this.matrix ); + if ( this.parent === null ) { - } else { + this.matrixWorld.copy( this.matrix ); - this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); + } else { - } + this.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix ); - this.animate.updateMatrix(); + } - this.matrixWorld.multiplyMatrices( this.matrixWorld, this.animate.matrix ); + this.animate.updateMatrix(); - this.matrixWorldNeedsUpdate = false; + this.matrixWorld.multiplyMatrices( this.matrixWorld, this.animate.matrix ); - force = true; + this.matrixWorldNeedsUpdate = false; - } + force = true; - // update children + } - for ( var i = 0, l = this.children.length; i < l; i ++ ) { + // update children - this.children[ i ].updateMatrixWorld( force ); + for ( var i = 0, l = this.children.length; i < l; i ++ ) { - } + this.children[ i ].updateMatrixWorld( force ); -}; + } -THREE.SEA3D.Object3D.prototype.setAnimator = function( val ) { + }, - if ( this.getAnimator() == val ) - return; + setAnimator: function ( val ) { - if ( val ) { + if ( this.getAnimator() == val ) + return; - this.animate = new THREE.Object3D(); + if ( val ) { - this.updateMatrixWorld = THREE.SEA3D.Object3D.prototype.updateAnimateMatrix; + this.animate = new THREE.Object3D(); - } else { + this.updateMatrixWorld = THREE.SEA3D.Object3D.prototype.updateAnimateMatrix; - delete this.animate; + } else { - this.updateMatrixWorld = THREE.Object3D.prototype.updateMatrixWorld; + delete this.animate; - } + this.updateMatrixWorld = THREE.Object3D.prototype.updateMatrixWorld; - this.matrixWorldNeedsUpdate = true; + } -}; + this.matrixWorldNeedsUpdate = true; + + }, -THREE.SEA3D.Object3D.prototype.getAnimator = function() { + getAnimator: function () { - return this.animate != undefined; + return this.animate != undefined; -}; + } + +} ); // // Dummy // -THREE.SEA3D.Dummy = function( width, height, depth ) { +THREE.SEA3D.Dummy = function ( width, height, depth ) { this.width = width != undefined ? width : 100; this.height = height != undefined ? height : 100; @@ -843,81 +1018,86 @@ THREE.SEA3D.Dummy = function( width, height, depth ) { var geo = new THREE.BoxGeometry( this.width, this.height, this.depth, 1, 1, 1 ); + geo.computeBoundingBox(); + geo.computeBoundingSphere(); + THREE.Mesh.call( this, geo, THREE.SEA3D.Dummy.MATERIAL ); }; -THREE.SEA3D.Dummy.prototype = Object.create( THREE.Mesh.prototype ); -THREE.SEA3D.Dummy.prototype.constructor = THREE.SEA3D.Dummy; +THREE.SEA3D.Dummy.MATERIAL = new THREE.MeshBasicMaterial( { wireframe: true, color: THREE.SEA3D.HELPER_COLOR } ); -Object.assign( THREE.SEA3D.Dummy.prototype, THREE.SEA3D.Object3D.prototype ); +THREE.SEA3D.Dummy.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Object3D.prototype, { -THREE.SEA3D.Dummy.MATERIAL = new THREE.MeshBasicMaterial( { wireframe: true, color: THREE.SEA3D.HELPER_COLOR } ); + constructor: THREE.SEA3D.Dummy, -THREE.SEA3D.Dummy.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.Mesh.prototype.copy.call( this, source ); + THREE.Mesh.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + }, -THREE.SEA3D.Dummy.prototype.dispose = function() { + dispose: function () { - this.geometry.dispose(); + this.geometry.dispose(); -}; + } + +} ); // // Mesh // -THREE.SEA3D.Mesh = function( geometry, material ) { +THREE.SEA3D.Mesh = function ( geometry, material ) { THREE.Mesh.call( this, geometry, material ); }; -THREE.SEA3D.Mesh.prototype = Object.create( THREE.Mesh.prototype ); -THREE.SEA3D.Mesh.prototype.constructor = THREE.SEA3D.Mesh; +THREE.SEA3D.Mesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Object3D.prototype, { -Object.assign( THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Object3D.prototype ); + constructor: THREE.SEA3D.Mesh, -THREE.SEA3D.Mesh.prototype.setWeight = function( name, val ) { + setWeight: function ( name, val ) { - this.morphTargetInfluences[ this.morphTargetDictionary[ name ] ] = val; + this.morphTargetInfluences[ this.morphTargetDictionary[ name ] ] = val; -}; + }, -THREE.SEA3D.Mesh.prototype.getWeight = function( name ) { + getWeight: function ( name ) { - return this.morphTargetInfluences[ this.morphTargetDictionary[ name ] ]; + return this.morphTargetInfluences[ this.morphTargetDictionary[ name ] ]; -}; + }, -THREE.SEA3D.Mesh.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.Mesh.prototype.copy.call( this, source ); + THREE.Mesh.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + } + +} ); // // Skinning // -THREE.SEA3D.SkinnedMesh = function( geometry, material, useVertexTexture ) { +THREE.SEA3D.SkinnedMesh = function ( geometry, material, useVertexTexture ) { THREE.SkinnedMesh.call( this, geometry, material, useVertexTexture ); @@ -925,42 +1105,43 @@ THREE.SEA3D.SkinnedMesh = function( geometry, material, useVertexTexture ) { }; -THREE.SEA3D.SkinnedMesh.prototype = Object.create( THREE.SkinnedMesh.prototype ); -THREE.SEA3D.SkinnedMesh.prototype.constructor = THREE.SEA3D.SkinnedMesh; +THREE.SEA3D.SkinnedMesh.prototype = Object.assign( Object.create( THREE.SkinnedMesh.prototype ), THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype, { -Object.assign( THREE.SEA3D.SkinnedMesh.prototype, THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype ); + constructor: THREE.SEA3D.SkinnedMesh, -THREE.SEA3D.SkinnedMesh.prototype.boneByName = function( name ) { + boneByName: function ( name ) { - var bones = this.skeleton.bones; + var bones = this.skeleton.bones; - for ( var i = 0, bl = bones.length; i < bl; i ++ ) { + for ( var i = 0, bl = bones.length; i < bl; i ++ ) { - if ( name == bones[ i ].name ) - return bones[ i ]; + if ( name == bones[ i ].name ) + return bones[ i ]; - } + } -}; + }, -THREE.SEA3D.SkinnedMesh.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.SkinnedMesh.prototype.copy.call( this, source ); + THREE.SkinnedMesh.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + } + +} ); // // Vertex Animation // -THREE.SEA3D.VertexAnimationMesh = function( geometry, material ) { +THREE.SEA3D.VertexAnimationMesh = function ( geometry, material ) { THREE.Mesh.call( this, geometry, material ); @@ -970,117 +1151,150 @@ THREE.SEA3D.VertexAnimationMesh = function( geometry, material ) { }; -THREE.SEA3D.VertexAnimationMesh.prototype = Object.create( THREE.Mesh.prototype ); -THREE.SEA3D.VertexAnimationMesh.prototype.constructor = THREE.SEA3D.VertexAnimationMesh; +THREE.SEA3D.VertexAnimationMesh.prototype = Object.assign( Object.create( THREE.Mesh.prototype ), THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype, { -Object.assign( THREE.SEA3D.VertexAnimationMesh.prototype, THREE.SEA3D.Mesh.prototype, THREE.SEA3D.Animator.prototype ); + constructor: THREE.SEA3D.VertexAnimationMesh, -THREE.SEA3D.VertexAnimationMesh.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.Mesh.prototype.copy.call( this, source ); + THREE.Mesh.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + } + +} ); // // Camera // -THREE.SEA3D.Camera = function( fov, aspect, near, far ) { +THREE.SEA3D.Camera = function ( fov, aspect, near, far ) { THREE.PerspectiveCamera.call( this, fov, aspect, near, far ); }; -THREE.SEA3D.Camera.prototype = Object.create( THREE.PerspectiveCamera.prototype ); -THREE.SEA3D.Camera.prototype.constructor = THREE.SEA3D.Camera; +THREE.SEA3D.Camera.prototype = Object.assign( Object.create( THREE.PerspectiveCamera.prototype ), THREE.SEA3D.Object3D.prototype, { -Object.assign( THREE.SEA3D.Camera.prototype, THREE.SEA3D.Object3D.prototype ); + constructor: THREE.SEA3D.Camera, -THREE.SEA3D.Camera.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.PerspectiveCamera.prototype.copy.call( this, source ); + THREE.PerspectiveCamera.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + } + +} ); // // Orthographic Camera // -THREE.SEA3D.OrthographicCamera = function( left, right, top, bottom, near, far ) { +THREE.SEA3D.OrthographicCamera = function ( left, right, top, bottom, near, far ) { THREE.OrthographicCamera.call( this, left, right, top, bottom, near, far ); }; -THREE.SEA3D.OrthographicCamera.prototype = Object.create( THREE.OrthographicCamera.prototype ); -THREE.SEA3D.OrthographicCamera.prototype.constructor = THREE.SEA3D.OrthographicCamera; +THREE.SEA3D.OrthographicCamera.prototype = Object.assign( Object.create( THREE.OrthographicCamera.prototype ), THREE.SEA3D.Object3D.prototype, { -Object.assign( THREE.SEA3D.OrthographicCamera.prototype, THREE.SEA3D.Object3D.prototype ); + constructor: THREE.SEA3D.OrthographicCamera, -THREE.SEA3D.OrthographicCamera.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.OrthographicCamera.prototype.copy.call( this, source ); + THREE.OrthographicCamera.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; -}; + } + +} ); // // PointLight // -THREE.SEA3D.PointLight = function( hex, intensity, distance, decay ) { +THREE.SEA3D.PointLight = function ( hex, intensity, distance, decay ) { THREE.PointLight.call( this, hex, intensity, distance, decay ); }; -THREE.SEA3D.PointLight.prototype = Object.create( THREE.PointLight.prototype ); -THREE.SEA3D.PointLight.prototype.constructor = THREE.SEA3D.PointLight; +THREE.SEA3D.PointLight.prototype = Object.assign( Object.create( THREE.PointLight.prototype ), THREE.SEA3D.Object3D.prototype, { -Object.assign( THREE.SEA3D.PointLight.prototype, THREE.SEA3D.Object3D.prototype ); + constructor: THREE.SEA3D.PointLight, -THREE.SEA3D.PointLight.prototype.copy = function( source ) { + copy: function ( source ) { - THREE.PointLight.prototype.copy.call( this, source ); + THREE.PointLight.prototype.copy.call( this, source ); - this.props = source.props; - this.scripts = source.scripts; + this.attribs = source.attribs; + this.scripts = source.scripts; - if ( this.animator ) this.animator = source.animator.clone( this ); + if ( this.animator ) this.animator = source.animator.clone( this ); - return this; + return this; + + } + +} ); + +// +// Point Sound +// + +THREE.SEA3D.PointSound = function ( listener ) { + + THREE.PositionalAudio.call( this, listener ); }; +THREE.SEA3D.PointSound.prototype = Object.assign( Object.create( THREE.PositionalAudio.prototype ), THREE.SEA3D.Object3D.prototype, { + + constructor: THREE.SEA3D.PointSound, + + copy: function ( source ) { + + THREE.PositionalAudio.prototype.copy.call( this, source ); + + this.attribs = source.attribs; + this.scripts = source.scripts; + + if ( this.animator ) this.animator = source.animator.clone( this ); + + return this; + + } + +} ); + // // Animation Handler // THREE.SEA3D.AnimationHandler = { - animators : [], + animators: [], - update : function( dt ) { + update: function ( dt ) { var i = 0; @@ -1092,7 +1306,7 @@ THREE.SEA3D.AnimationHandler = { }, - addAnimator : function( animator ) { + addAnimator: function ( animator ) { var index = this.animators.indexOf( animator ); @@ -1100,7 +1314,7 @@ THREE.SEA3D.AnimationHandler = { }, - removeAnimator : function( animator ) { + removeAnimator: function ( animator ) { var index = this.animators.indexOf( animator ); @@ -1110,117 +1324,89 @@ THREE.SEA3D.AnimationHandler = { }; -// -// Config -// - -THREE.SEA3D.MTXBUF = new THREE.Matrix4(); -THREE.SEA3D.VECBUF = new THREE.Vector3(); -THREE.SEA3D.QUABUF = new THREE.Quaternion(); - -THREE.SEA3D.prototype.setShadowMap = function( light ) { - - light.shadow.mapSize.width = 2048 - light.shadow.mapSize.height = 1024; - - light.castShadow = true; - - light.shadow.camera.left = - 200; // CHANGED - light.shadow.camera.right = 200; // CHANGED - light.shadow.camera.top = 200; // CHANGED - light.shadow.camera.bottom = - 200; // CHANGED - - light.shadow.camera.near = 1; - light.shadow.camera.far = 3000; - light.shadow.camera.fov = 45; - - light.shadow.bias = - 0.001; - -}; - // // Output // -THREE.SEA3D.Domain.prototype.getMesh = THREE.SEA3D.prototype.getMesh = function( name ) { +THREE.SEA3D.Domain.prototype.getMesh = THREE.SEA3D.prototype.getMesh = function ( name ) { return this.objects[ "m3d/" + name ]; }; -THREE.SEA3D.Domain.prototype.getDummy = THREE.SEA3D.prototype.getDummy = function( name ) { +THREE.SEA3D.Domain.prototype.getDummy = THREE.SEA3D.prototype.getDummy = function ( name ) { return this.objects[ "dmy/" + name ]; }; -THREE.SEA3D.Domain.prototype.getLine = THREE.SEA3D.prototype.getLine = function( name ) { +THREE.SEA3D.Domain.prototype.getLine = THREE.SEA3D.prototype.getLine = function ( name ) { return this.objects[ "line/" + name ]; }; -THREE.SEA3D.Domain.prototype.getSound3D = THREE.SEA3D.prototype.getSound3D = function( name ) { +THREE.SEA3D.Domain.prototype.getSound3D = THREE.SEA3D.prototype.getSound3D = function ( name ) { return this.objects[ "sn3d/" + name ]; }; -THREE.SEA3D.Domain.prototype.getMaterial = THREE.SEA3D.prototype.getMaterial = function( name ) { +THREE.SEA3D.Domain.prototype.getMaterial = THREE.SEA3D.prototype.getMaterial = function ( name ) { return this.objects[ "mat/" + name ]; }; -THREE.SEA3D.Domain.prototype.getLight = THREE.SEA3D.prototype.getLight = function( name ) { +THREE.SEA3D.Domain.prototype.getLight = THREE.SEA3D.prototype.getLight = function ( name ) { return this.objects[ "lht/" + name ]; }; -THREE.SEA3D.Domain.prototype.getGLSL = THREE.SEA3D.prototype.getGLSL = function( name ) { +THREE.SEA3D.Domain.prototype.getGLSL = THREE.SEA3D.prototype.getGLSL = function ( name ) { return this.objects[ "glsl/" + name ]; }; -THREE.SEA3D.Domain.prototype.getCamera = THREE.SEA3D.prototype.getCamera = function( name ) { +THREE.SEA3D.Domain.prototype.getCamera = THREE.SEA3D.prototype.getCamera = function ( name ) { return this.objects[ "cam/" + name ]; }; -THREE.SEA3D.Domain.prototype.getTexture = THREE.SEA3D.prototype.getTexture = function( name ) { +THREE.SEA3D.Domain.prototype.getTexture = THREE.SEA3D.prototype.getTexture = function ( name ) { return this.objects[ "tex/" + name ]; }; -THREE.SEA3D.Domain.prototype.getCubeMap = THREE.SEA3D.prototype.getCubeMap = function( name ) { +THREE.SEA3D.Domain.prototype.getCubeMap = THREE.SEA3D.prototype.getCubeMap = function ( name ) { return this.objects[ "cmap/" + name ]; }; -THREE.SEA3D.Domain.prototype.getJointObject = THREE.SEA3D.prototype.getJointObject = function( name ) { +THREE.SEA3D.Domain.prototype.getJointObject = THREE.SEA3D.prototype.getJointObject = function ( name ) { return this.objects[ "jnt/" + name ]; }; -THREE.SEA3D.Domain.prototype.getContainer3D = THREE.SEA3D.prototype.getContainer3D = function( name ) { +THREE.SEA3D.Domain.prototype.getContainer3D = THREE.SEA3D.prototype.getContainer3D = function ( name ) { return this.objects[ "c3d/" + name ]; }; -THREE.SEA3D.Domain.prototype.getSprite = THREE.SEA3D.prototype.getSprite = function( name ) { +THREE.SEA3D.Domain.prototype.getSprite = THREE.SEA3D.prototype.getSprite = function ( name ) { return this.objects[ "m2d/" + name ]; }; -THREE.SEA3D.Domain.prototype.getProperties = THREE.SEA3D.prototype.getProperties = function( name ) { +THREE.SEA3D.Domain.prototype.getProperties = THREE.SEA3D.prototype.getProperties = function ( name ) { return this.objects[ "prop/" + name ]; @@ -1230,19 +1416,19 @@ THREE.SEA3D.Domain.prototype.getProperties = THREE.SEA3D.prototype.getProperties // Utils // -THREE.SEA3D.prototype.isPowerOfTwo = function( num ) { +THREE.SEA3D.prototype.isPowerOfTwo = function ( num ) { return num ? ( ( num & - num ) == num ) : false; }; -THREE.SEA3D.prototype.nearestPowerOfTwo = function( num ) { +THREE.SEA3D.prototype.nearestPowerOfTwo = function ( num ) { return Math.pow( 2, Math.round( Math.log( num ) / Math.LN2 ) ); }; -THREE.SEA3D.prototype.updateTransform = function( obj3d, sea ) { +THREE.SEA3D.prototype.updateTransform = function ( obj3d, sea ) { var mtx = THREE.SEA3D.MTXBUF, vec = THREE.SEA3D.VECBUF; @@ -1270,13 +1456,29 @@ THREE.SEA3D.prototype.updateTransform = function( obj3d, sea ) { }; -THREE.SEA3D.prototype.toVector3 = function( data ) { +THREE.SEA3D.prototype.toVector3 = function ( data ) { return new THREE.Vector3( data.x, data.y, data.z ); }; -THREE.SEA3D.prototype.updateScene = function() { +THREE.SEA3D.prototype.toFaces = function ( faces ) { + + // xyz(- / +) to xyz(+ / -) sequence + var f = []; + + f[ 0 ] = faces[ 1 ]; + f[ 1 ] = faces[ 0 ]; + f[ 2 ] = faces[ 3 ]; + f[ 3 ] = faces[ 2 ]; + f[ 4 ] = faces[ 5 ]; + f[ 5 ] = faces[ 4 ]; + + return f; + +}; + +THREE.SEA3D.prototype.updateScene = function () { if ( this.materials != undefined ) { @@ -1290,16 +1492,16 @@ THREE.SEA3D.prototype.updateScene = function() { }; -THREE.SEA3D.prototype.addSceneObject = function( sea ) { +THREE.SEA3D.prototype.addSceneObject = function ( sea, obj3d ) { - var obj3d = sea.tag; + obj3d = obj3d || sea.tag; obj3d.visible = sea.visible; if ( sea.parent ) sea.parent.tag.add( obj3d ); else if ( this.config.container ) this.config.container.add( obj3d ); - if ( sea.properties ) obj3d.props = sea.properties.tag; + if ( sea.attributes ) obj3d.attribs = sea.attributes.tag; if ( sea.scripts ) { @@ -1311,25 +1513,39 @@ THREE.SEA3D.prototype.addSceneObject = function( sea ) { }; -THREE.SEA3D.prototype.createObjectURL = function( raw, mime ) { +THREE.SEA3D.prototype.createObjectURL = function ( raw, mime ) { return ( window.URL || window.webkitURL ).createObjectURL( new Blob( [ raw ], { type: mime } ) ); }; -THREE.SEA3D.prototype.bufferToTexture = function( raw ) { +THREE.SEA3D.prototype.bufferToTexture = function ( raw ) { return this.createObjectURL( raw, "image" ); }; -THREE.SEA3D.prototype.bufferToSound = function( raw ) { +THREE.SEA3D.prototype.bufferToSound = function ( raw ) { return this.createObjectURL( raw, "audio" ); }; -THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { +THREE.SEA3D.prototype.parsePath = function ( url ) { + + var paths = this.config.paths; + + for ( var name in paths ) { + + url = url.replace( new RegExp( "%" + name + "%", "g" ), paths[ name ] ); + + } + + return url; + +}; + +THREE.SEA3D.prototype.applyDefaultAnimation = function ( sea, animatorClass ) { var obj = sea.tag; @@ -1338,6 +1554,7 @@ THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { var anm = sea.animations[ i ]; switch ( anm.tag.type ) { + case SEA3D.Animation.prototype.type: obj.animator = new animatorClass( anm.tag.tag, obj ); obj.animator.setRelative( anm.relative ); @@ -1350,6 +1567,7 @@ THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { return obj.animator; break; + } } @@ -1360,10 +1578,9 @@ THREE.SEA3D.prototype.applyDefaultAnimation = function( sea, animatorClass ) { // Animation // -THREE.SEA3D.prototype.readAnimation = function( sea ) { +THREE.SEA3D.prototype.readAnimation = function ( sea ) { - var clips = [], - delta = ( 1000 / sea.frameRate ) / 1000; + var clips = [], delta = ( 1000 / sea.frameRate ) / 1000; for ( var i = 0; i < sea.sequence.length; i ++ ) { @@ -1374,7 +1591,7 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { for ( var j = 0; j < sea.dataList.length; j ++ ) { var anm = sea.dataList[ j ], - t, times, + t, k, times, values, data = anm.data, start = seq.start * anm.blockSize, end = start + ( seq.count * anm.blockSize ), @@ -1382,6 +1599,7 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { name = null; switch ( anm.kind ) { + case SEA3D.Animation.POSITION: name = '.position'; break; @@ -1405,11 +1623,13 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { case SEA3D.Animation.FOV: name = '.fov'; break; + } if ( ! name ) continue; switch ( anm.type ) { + case SEA3D.Stream.BYTE: case SEA3D.Stream.UBYTE: case SEA3D.Stream.INT: @@ -1418,10 +1638,11 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { case SEA3D.Stream.DOUBLE: case SEA3D.Stream.DECIMAL: - var values = data.subarray( start, end ); - var times = new Float32Array( values.length ); + values = data.subarray( start, end ); + times = new Float32Array( values.length ); + t = 0; - for ( var k = 0, t = 0; k < times.length; k ++ ) { + for ( k = 0; k < times.length; k ++ ) { times[ k ] = t; t += delta; @@ -1434,10 +1655,11 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { case SEA3D.Stream.VECTOR3D: - var values = data.subarray( start, end ); - var times = new Float32Array( values.length / anm.blockSize ); + values = data.subarray( start, end ); + times = new Float32Array( values.length / anm.blockSize ); + t = 0; - for ( var k = 0, t = 0; k < times.length; k ++ ) { + for ( k = 0; k < times.length; k ++ ) { times[ k ] = t; t += delta; @@ -1450,10 +1672,11 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { case SEA3D.Stream.VECTOR4D: - var values = data.subarray( start, end ); - var times = new Float32Array( values.length / anm.blockSize ); + values = data.subarray( start, end ); + times = new Float32Array( values.length / anm.blockSize ); + t = 0; - for ( var k = 0, t = 0; k < times.length; k ++ ) { + for ( k = 0; k < times.length; k ++ ) { times[ k ] = t; t += delta; @@ -1467,10 +1690,11 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { case SEA3D.Stream.INT24: case SEA3D.Stream.UINT24: - var values = new Float32Array( ( end - start ) * 3 ); - var times = new Float32Array( values.length / 3 ); + values = new Float32Array( ( end - start ) * 3 ); + times = new Float32Array( values.length / 3 ); + t = 0; - for ( var k = 0, t = 0; k < times.length; k ++ ) { + for ( k = 0; k < times.length; k ++ ) { values[ ( k * 3 ) ] = ( ( data[ k ] >> 16 ) & 0xFF ) / 255; values[ ( k * 3 ) + 1 ] = ( ( data[ k ] >> 8 ) & 0xFF ) / 255; @@ -1483,6 +1707,7 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { tracks.push( new THREE.VectorKeyframeTrack( name, times, values, intrpl ) );//ColorKeyframeTrack break; + } } @@ -1504,9 +1729,9 @@ THREE.SEA3D.prototype.readAnimation = function( sea ) { // Geometry // -THREE.SEA3D.prototype.readGeometryBuffer = function( sea ) { +THREE.SEA3D.prototype.readGeometryBuffer = function ( sea ) { - var geo = new THREE.BufferGeometry(); + var geo = new THREE.BufferGeometry(); for ( var i = 0; i < sea.groups.length; i ++ ) { @@ -1558,7 +1783,7 @@ THREE.SEA3D.prototype.readGeometryBuffer = function( sea ) { // Dummy // -THREE.SEA3D.prototype.readDummy = function( sea ) { +THREE.SEA3D.prototype.readDummy = function ( sea ) { var dummy = new THREE.SEA3D.Dummy( sea.width, sea.height, sea.depth ); dummy.name = sea.name; @@ -1577,7 +1802,7 @@ THREE.SEA3D.prototype.readDummy = function( sea ) { // Line // -THREE.SEA3D.prototype.readLine = function( sea ) { +THREE.SEA3D.prototype.readLine = function ( sea ) { var geo = new THREE.BufferGeometry(); @@ -1603,7 +1828,7 @@ THREE.SEA3D.prototype.readLine = function( sea ) { // Container3D // -THREE.SEA3D.prototype.readContainer3D = function( sea ) { +THREE.SEA3D.prototype.readContainer3D = function ( sea ) { var container = new THREE.SEA3D.Object3D(); @@ -1621,7 +1846,7 @@ THREE.SEA3D.prototype.readContainer3D = function( sea ) { // Sprite // -THREE.SEA3D.prototype.readSprite = function( sea ) { +THREE.SEA3D.prototype.readSprite = function ( sea ) { var mat; @@ -1638,11 +1863,9 @@ THREE.SEA3D.prototype.readSprite = function( sea ) { mat.color.set( sea.material.tag.color ); mat.opacity = sea.material.tag.opacity; - mat.blending = sea.material.tag.blending; mat.fog = sea.material.receiveFog; - } - else mat = sea.material.tag.sprite; + } else mat = sea.material.tag.sprite; } @@ -1663,16 +1886,16 @@ THREE.SEA3D.prototype.readSprite = function( sea ) { // Mesh // -THREE.SEA3D.prototype.readMesh = function( sea ) { +THREE.SEA3D.prototype.readMesh = function ( sea ) { - var i, count, geo = sea.geometry.tag, - mesh, mat, skeleton, skeletonAnimation, vertexAnimation, morpher; + var i, count, geo = sea.geometry.tag, mesh, mat, skeleton, skeletonAnimation, vertexAnimation, morpher; for ( i = 0, count = sea.modifiers ? sea.modifiers.length : 0; i < count; i ++ ) { var mod = sea.modifiers[ i ]; switch ( mod.type ) { + case SEA3D.Skeleton.prototype.type: case SEA3D.SkeletonLocal.prototype.type: skeleton = mod; @@ -1686,6 +1909,7 @@ THREE.SEA3D.prototype.readMesh = function( sea ) { geo.morphAttributes = morpher.tag.attribs; geo.morphTargets = morpher.tag.targets; break; + } } @@ -1695,6 +1919,7 @@ THREE.SEA3D.prototype.readMesh = function( sea ) { var anm = sea.animations[ i ]; switch ( anm.tag.type ) { + case SEA3D.SkeletonAnimation.prototype.type: skeletonAnimation = anm.tag; @@ -1708,6 +1933,7 @@ THREE.SEA3D.prototype.readMesh = function( sea ) { geo.morphTargets = vertexAnimation.tag.targets; geo.animations = vertexAnimation.tag.animations; break; + } } @@ -1794,7 +2020,7 @@ THREE.SEA3D.prototype.readMesh = function( sea ) { // Sound Point // -THREE.SEA3D.prototype.readSoundPoint = function( sea ) { +THREE.SEA3D.prototype.readSoundPoint = function ( sea ) { if ( ! this.audioListener ) { @@ -1810,7 +2036,7 @@ THREE.SEA3D.prototype.readSoundPoint = function( sea ) { var sound3d = new THREE.SEA3D.PointSound( this.audioListener ); - new THREE.AudioLoader().load( sea.sound.tag, function( buffer ) { + new THREE.AudioLoader().load( sea.sound.tag, function ( buffer ) { sound3d.setBuffer( buffer ); @@ -1838,39 +2064,43 @@ THREE.SEA3D.prototype.readSoundPoint = function( sea ) { // Cube Render // -THREE.SEA3D.prototype.readCubeRender = function( sea ) { +THREE.SEA3D.prototype.readCubeRender = function ( sea ) { var cube = new THREE.CubeCamera( 0.1, 5000, THREE.SEA3D.RTT_SIZE ); cube.renderTarget.cubeCamera = cube; + sea.tag = cube.renderTarget; + this.domain.cubeRenderers = this.cubeRenderers = this.cubeRenderers || []; - this.cubeRenderers.push( this.objects[ "rttc/" + sea.name ] = sea.tag = cube.renderTarget ); + this.cubeRenderers.push( this.objects[ "rttc/" + sea.name ] = cube ); - this.addSceneObject( sea ); + this.addSceneObject( sea, cube ); this.updateTransform( cube, sea ); - this.applyDefaultAnimation( sea, THREE.SEA3D.Object3DAnimator ); - }; // // Images (WDP, JPEG, PNG and GIF) // -THREE.SEA3D.prototype.readImage = function( sea ) { +THREE.SEA3D.prototype.readTexture = function ( sea ) { - var image = new Image(), texture = new THREE.Texture(); + var image = new Image(), + texture = new THREE.Texture(); texture.name = sea.name; texture.wrapS = texture.wrapT = THREE.RepeatWrapping; texture.flipY = false; texture.image = image; - image.onload = function() { + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + + image.onload = function () { texture.needsUpdate = true; }; + image.src = this.bufferToTexture( sea.data.buffer ); this.domain.textures = this.textures = this.textures || []; @@ -1882,47 +2112,40 @@ THREE.SEA3D.prototype.readImage = function( sea ) { // Cube Map // -THREE.SEA3D.prototype.readCubeMap = function( sea ) { - - var images = [], - texture = new THREE.CubeTexture(); - - // xyz(- / +) to xyz(+ / -) sequence - var faces = []; +THREE.SEA3D.prototype.readCubeMap = function ( sea ) { - faces[ 0 ] = sea.faces[ 1 ]; - faces[ 1 ] = sea.faces[ 0 ]; - faces[ 2 ] = sea.faces[ 3 ]; - faces[ 3 ] = sea.faces[ 2 ]; - faces[ 4 ] = sea.faces[ 5 ]; - faces[ 5 ] = sea.faces[ 4 ]; + var faces = this.toFaces( sea.faces ), texture = new THREE.CubeTexture( [] ); - images.loadedCount = 0; + var loaded = 0; texture.name = sea.name; - texture.image = images; texture.flipY = false; + texture.format = THREE.RGBFormat; - for ( var i = 0, il = faces.length; i < il; ++ i ) { + var onLoaded = function () { - var cubeImage = new Image(); + if ( ++ loaded == 6 ) { - images[ i ] = cubeImage; + texture.needsUpdate = true; - cubeImage.onload = function() { + if ( ! this.config.async ) this.file.resume = true; - if ( ++ images.loadedCount == 6 ) { + } - texture.needsUpdate = true; + }.bind( this ); - } - - } + for ( var i = 0; i < faces.length; ++ i ) { + var cubeImage = new Image(); + cubeImage.onload = onLoaded; cubeImage.src = this.bufferToTexture( faces[ i ].buffer ); + texture.images[ i ] = cubeImage; + } + if ( ! this.config.async ) this.file.resume = false; + this.domain.cubemaps = this.cubemaps = this.cubemaps || []; this.cubemaps.push( this.objects[ "cmap/" + sea.name ] = sea.tag = texture ); @@ -1932,7 +2155,7 @@ THREE.SEA3D.prototype.readCubeMap = function( sea ) { // Sound (MP3, OGG) // -THREE.SEA3D.prototype.readSound = function( sea ) { +THREE.SEA3D.prototype.readSound = function ( sea ) { var sound = this.bufferToSound( sea.data.buffer ); @@ -1941,28 +2164,110 @@ THREE.SEA3D.prototype.readSound = function( sea ) { }; +// +// Script URL +// + +THREE.SEA3D.prototype.readScriptURL = function ( sea ) { + + this.file.resume = false; + + var loader = new THREE.FileLoader(); + + loader.setResponseType( "text" ).load( sea.url, function ( src ) { + + this.file.resume = true; + + this.domain.scripts = this.scripts = this.scripts || []; + this.scripts.push( this.objects[ "src/" + sea.name ] = sea.tag = src ); + + }.bind( this ) ); + +}; + // // Texture URL // -THREE.SEA3D.prototype.readTextureURL = function( sea ) { +THREE.SEA3D.prototype.readTextureURL = function ( sea ) { - var texture = new THREE.TextureLoader().load( sea.url ); + var texture = new THREE.TextureLoader().load( this.parsePath( sea.url ) ); texture.name = sea.name; texture.wrapS = texture.wrapT = THREE.RepeatWrapping; texture.flipY = false; + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + this.domain.textures = this.textures = this.textures || []; this.textures.push( this.objects[ "tex/" + sea.name ] = sea.tag = texture ); }; +// +// CubeMap URL +// + +THREE.SEA3D.prototype.readCubeMapURL = function ( sea ) { + + var faces = this.toFaces( sea.faces ); + + for ( var i = 0; i < faces.length; i ++ ) { + + faces[ i ] = this.parsePath( faces[ i ] ); + + } + + var texture, format = faces[ 0 ].substr( - 3 ); + + if ( format == "hdr" ) { + + var usePMREM = THREE.PMREMGenerator != null; + + this.file.resume = ! usePMREM; + + texture = new THREE.HDRCubeTextureLoader().load( THREE.UnsignedByteType, faces, function ( texture ) { + + if ( usePMREM ) { + + var pmremGenerator = new THREE.PMREMGenerator( texture ); + pmremGenerator.update( this.config.renderer ); + + var pmremCubeUVPacker = new THREE.PMREMCubeUVPacker( pmremGenerator.cubeLods ); + pmremCubeUVPacker.update( this.config.renderer ); + + texture.dispose(); + + this.objects[ "cmap/" + sea.name ] = sea.tag = pmremCubeUVPacker.CubeUVRenderTarget.texture; + + this.file.resume = true; + + } + + }.bind( this ) ); + + } else { + + texture = new THREE.CubeTextureLoader().load( faces ); + + } + + texture.name = sea.name; + texture.wrapS = texture.wrapT = THREE.RepeatWrapping; + texture.flipY = false; + + if ( this.config.anisotropy !== undefined ) texture.anisotropy = this.config.anisotropy; + + this.domain.cubemaps = this.cubemaps = this.cubemaps || []; + this.cubemaps.push( this.objects[ "cmap/" + sea.name ] = sea.tag = texture ); + +}; + // // Runtime // -THREE.SEA3D.prototype.getJSMList = function( target, scripts ) { +THREE.SEA3D.prototype.getJSMList = function ( target, scripts ) { var scriptTarget = []; @@ -1985,7 +2290,7 @@ THREE.SEA3D.prototype.getJSMList = function( target, scripts ) { }; -THREE.SEA3D.prototype.readJavaScriptMethod = function( sea ) { +THREE.SEA3D.prototype.readJavaScriptMethod = function ( sea ) { try { @@ -2002,11 +2307,11 @@ THREE.SEA3D.prototype.readJavaScriptMethod = function( sea ) { declare += 'var $SRC = $INC["source"],\n' + - 'addEvent = $SRC.addEvent.bind( $SRC ),\n' + - 'hasEvent = $SRC.hasEvent.bind( $SRC ),\n' + + 'addEventListener = $SRC.addEventListener.bind( $SRC ),\n' + + 'hasEventListener = $SRC.hasEventListener.bind( $SRC ),\n' + + 'removeEventListener = $SRC.removeEventListener.bind( $SRC ),\n' + 'dispatchEvent = $SRC.dispatchEvent.bind( $SRC ),\n' + - 'removeEvent = $SRC.removeEvent.bind( $SRC ),\n' + - 'dispose = $SRC.dispose.bind( $SRC );\n' + 'dispose = $SRC.dispose.bind( $SRC );\n'; for ( var name in sea.methods ) { @@ -2014,12 +2319,11 @@ THREE.SEA3D.prototype.readJavaScriptMethod = function( sea ) { } - src += 'return $METHOD; })' + src += 'return $METHOD; })'; this.domain.methods = eval( src )(); - } - catch ( e ) { + } catch ( e ) { console.error( 'SEA3D JavaScriptMethod: Error running "' + sea.name + '".' ); console.error( e ); @@ -2032,7 +2336,7 @@ THREE.SEA3D.prototype.readJavaScriptMethod = function( sea ) { // GLSL // -THREE.SEA3D.prototype.readGLSL = function( sea ) { +THREE.SEA3D.prototype.readGLSL = function ( sea ) { this.domain.glsl = this.glsl = this.glsl || []; this.glsl.push( this.objects[ "glsl/" + sea.name ] = sea.tag = sea.src ); @@ -2044,12 +2348,12 @@ THREE.SEA3D.prototype.readGLSL = function( sea ) { // THREE.SEA3D.prototype.materialTechnique = -( function() { +( function () { - var techniques = {} + var techniques = {}; // FINAL - techniques.onComplete = function( mat, sea ) { + techniques.onComplete = function ( mat, sea ) { if ( sea.alpha < 1 || mat.blending > THREE.NormalBlending ) { @@ -2062,7 +2366,7 @@ THREE.SEA3D.prototype.materialTechnique = // PHYSICAL techniques[ SEA3D.Material.PHYSICAL ] = - function( mat, tech ) { + function ( mat, tech ) { mat.color.setHex( tech.color ); mat.roughness = tech.roughness; @@ -2070,9 +2374,26 @@ THREE.SEA3D.prototype.materialTechnique = }; + // REFLECTIVITY + techniques[ SEA3D.Material.REFLECTIVITY ] = + function ( mat, tech ) { + + mat.reflectivity = tech.strength; + + }; + + // CLEAR_COAT + techniques[ SEA3D.Material.CLEAR_COAT ] = + function ( mat, tech ) { + + mat.clearCoat = tech.strength; + mat.clearCoatRoughness = tech.roughness; + + }; + // PHONG techniques[ SEA3D.Material.PHONG ] = - function( mat, tech ) { + function ( mat, tech ) { mat.color.setHex( tech.diffuseColor ); mat.specular.setHex( tech.specularColor ).multiplyScalar( tech.specular ); @@ -2082,15 +2403,16 @@ THREE.SEA3D.prototype.materialTechnique = // DIFFUSE_MAP techniques[ SEA3D.Material.DIFFUSE_MAP ] = - function( mat, tech, sea ) { + function ( mat, tech, sea ) { mat.map = tech.texture.tag; mat.color.setHex( 0xFFFFFF ); + mat.map.wrapS = mat.map.wrapT = sea.repeat ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + if ( tech.texture.transparent ) { mat.transparent = true; - mat.alphaTest = sea.alphaThreshold; } @@ -2098,7 +2420,7 @@ THREE.SEA3D.prototype.materialTechnique = // ROUGHNESS_MAP techniques[ SEA3D.Material.ROUGHNESS_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { mat.roughnessMap = tech.texture.tag; @@ -2106,7 +2428,7 @@ THREE.SEA3D.prototype.materialTechnique = // METALNESS_MAP techniques[ SEA3D.Material.METALNESS_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { mat.metalnessMap = tech.texture.tag; @@ -2114,7 +2436,7 @@ THREE.SEA3D.prototype.materialTechnique = // SPECULAR_MAP techniques[ SEA3D.Material.SPECULAR_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { if ( mat.specular ) { @@ -2127,7 +2449,7 @@ THREE.SEA3D.prototype.materialTechnique = // NORMAL_MAP techniques[ SEA3D.Material.NORMAL_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { mat.normalMap = tech.texture.tag; @@ -2136,7 +2458,7 @@ THREE.SEA3D.prototype.materialTechnique = // REFLECTION techniques[ SEA3D.Material.REFLECTION ] = techniques[ SEA3D.Material.FRESNEL_REFLECTION ] = - function( mat, tech ) { + function ( mat, tech ) { mat.envMap = tech.texture.tag; mat.envMap.mapping = THREE.CubeReflectionMapping; @@ -2148,7 +2470,7 @@ THREE.SEA3D.prototype.materialTechnique = // REFLECTION_SPHERICAL techniques[ SEA3D.Material.REFLECTION_SPHERICAL ] = - function( mat, tech ) { + function ( mat, tech ) { mat.envMap = tech.texture.tag; mat.envMap.mapping = THREE.SphericalReflectionMapping; @@ -2160,10 +2482,10 @@ THREE.SEA3D.prototype.materialTechnique = // REFRACTION techniques[ SEA3D.Material.REFRACTION_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { mat.envMap = tech.texture.tag; - mat.envMap.mapping = THREE.CubeRefractionMapping(); + mat.envMap.mapping = THREE.CubeRefractionMapping; mat.refractionRatio = tech.ior; mat.reflectivity = tech.alpha; @@ -2172,26 +2494,47 @@ THREE.SEA3D.prototype.materialTechnique = // LIGHT_MAP techniques[ SEA3D.Material.LIGHT_MAP ] = - function( mat, tech ) { + function ( mat, tech ) { if ( tech.blendMode == "multiply" ) mat.aoMap = tech.texture.tag; else mat.lightMap = tech.texture.tag; }; + // ALPHA_MAP + techniques[ SEA3D.Material.ALPHA_MAP ] = + function ( mat, tech, sea ) { + + mat.alphaMap = tech.texture.tag; + mat.transparent = true; + + mat.alphaMap.wrapS = mat.alphaMap.wrapT = sea.repeat ? THREE.RepeatWrapping : THREE.ClampToEdgeWrapping; + + }; + return techniques; } )(); -THREE.SEA3D.prototype.createMaterial = function( sea ) { +THREE.SEA3D.prototype.createMaterial = function ( sea ) { + + if ( sea.tecniquesDict[ SEA3D.Material.REFLECTIVITY ] || sea.tecniquesDict[ SEA3D.Material.CLEAR_COAT ] ) { + + return new THREE.MeshPhysicalMaterial(); + + } else if ( sea.tecniquesDict[ SEA3D.Material.PHYSICAL ] ) { + + return new THREE.MeshStandardMaterial(); + + } - return sea.physical ? new THREE.MeshStandardMaterial() : new THREE.MeshPhongMaterial(); + return new THREE.MeshPhongMaterial(); }; -THREE.SEA3D.prototype.setBlending = function( mat, blendMode ) { +THREE.SEA3D.prototype.setBlending = function ( mat, blendMode ) { - if ( blendMode == "normal" ) return; + if ( blendMode === "normal" ) return; switch ( blendMode ) { @@ -2216,15 +2559,17 @@ THREE.SEA3D.prototype.setBlending = function( mat, blendMode ) { } + mat.transparent = true; + }; -THREE.SEA3D.prototype.readMaterial = function( sea ) { +THREE.SEA3D.prototype.readMaterial = function ( sea ) { var mat = this.createMaterial( sea ); mat.name = sea.name; + mat.premultipliedAlpha = this.config.forcePremultipliedAlpha; mat.side = sea.bothSides ? THREE.DoubleSide : THREE.FrontSide; - mat.shading = sea.smooth ? THREE.SmoothShading : THREE.FlatShading; this.setBlending( mat, sea.blendMode ); @@ -2255,7 +2600,7 @@ THREE.SEA3D.prototype.readMaterial = function( sea ) { // Point Light // -THREE.SEA3D.prototype.readPointLight = function( sea ) { +THREE.SEA3D.prototype.readPointLight = function ( sea ) { var light = new THREE.SEA3D.PointLight( sea.color, sea.multiplier * this.config.multiplier ); light.name = sea.name; @@ -2285,9 +2630,10 @@ THREE.SEA3D.prototype.readPointLight = function( sea ) { // Hemisphere Light // -THREE.SEA3D.prototype.readHemisphereLight = function( sea ) { +THREE.SEA3D.prototype.readHemisphereLight = function ( sea ) { var light = new THREE.HemisphereLight( sea.color, sea.secondColor, sea.multiplier * this.config.multiplier ); + light.position.set( 0, 500, 0 ); light.name = sea.name; this.domain.lights = this.lights = this.lights || []; @@ -2305,7 +2651,7 @@ THREE.SEA3D.prototype.readHemisphereLight = function( sea ) { // Ambient Light // -THREE.SEA3D.prototype.readAmbientLight = function( sea ) { +THREE.SEA3D.prototype.readAmbientLight = function ( sea ) { var light = new THREE.AmbientLight( sea.color, sea.multiplier * this.config.multiplier ); light.name = sea.name; @@ -2325,7 +2671,7 @@ THREE.SEA3D.prototype.readAmbientLight = function( sea ) { // Directional Light // -THREE.SEA3D.prototype.readDirectionalLight = function( sea ) { +THREE.SEA3D.prototype.readDirectionalLight = function ( sea ) { var light = new THREE.DirectionalLight( sea.color, sea.multiplier * this.config.multiplier ); light.name = sea.name; @@ -2349,39 +2695,11 @@ THREE.SEA3D.prototype.readDirectionalLight = function( sea ) { }; -// -// Point Sound -// - -THREE.SEA3D.PointSound = function( listener ) { - - THREE.PositionalAudio.call( this, listener ); - -}; - -THREE.SEA3D.PointSound.prototype = Object.create( THREE.PositionalAudio.prototype ); -THREE.SEA3D.PointSound.prototype.constructor = THREE.SEA3D.PointSound; - -Object.assign( THREE.SEA3D.PointSound.prototype, THREE.SEA3D.Object3D.prototype ); - -THREE.SEA3D.PointSound.prototype.copy = function( source ) { - - THREE.PositionalAudio.prototype.copy.call( this, source ); - - this.props = source.props; - this.scripts = source.scripts; - - if ( this.animator ) this.animator = source.animator.clone( this ); - - return this; - -}; - // // Camera // -THREE.SEA3D.prototype.readCamera = function( sea ) { +THREE.SEA3D.prototype.readCamera = function ( sea ) { var camera = new THREE.SEA3D.Camera( sea.fov ); camera.name = sea.name; @@ -2400,20 +2718,23 @@ THREE.SEA3D.prototype.readCamera = function( sea ) { // Orthographic Camera // -THREE.SEA3D.prototype.readOrthographicCamera = function( sea ) { +THREE.SEA3D.prototype.readOrthographicCamera = function ( sea ) { var aspect, width, height; - if ( this.config.stageWidth > this.config.stageHeight ) { + var stageWidth = this.config.stageWidth !== undefined ? this.config.stageWidth : ( window ? window.innerWidth : 1024 ); + var stageHeight = this.config.stageHeight !== undefined ? this.config.stageHeight : ( window ? window.innerHeight : 1024 ); + + if ( stageWidth > stageHeight ) { - aspect = this.config.stageWidth / this.config.stageHeight; + aspect = stageWidth / stageHeight; width = sea.height * aspect; height = sea.height; } else { - aspect = this.config.stageHeight / this.config.stageWidth; + aspect = stageHeight / stageWidth; width = sea.height; height = sea.height * aspect; @@ -2437,7 +2758,7 @@ THREE.SEA3D.prototype.readOrthographicCamera = function( sea ) { // Skeleton // -THREE.SEA3D.prototype.readSkeletonLocal = function( sea ) { +THREE.SEA3D.prototype.readSkeletonLocal = function ( sea ) { var bones = []; @@ -2462,7 +2783,7 @@ THREE.SEA3D.prototype.readSkeletonLocal = function( sea ) { // Joint Object // -THREE.SEA3D.prototype.readJointObject = function( sea ) { +THREE.SEA3D.prototype.readJointObject = function ( sea ) { var mesh = sea.target.tag, bone = mesh.skeleton.bones[ sea.joint ]; @@ -2476,12 +2797,9 @@ THREE.SEA3D.prototype.readJointObject = function( sea ) { // Morpher // -THREE.SEA3D.prototype.readMorpher = function( sea ) { +THREE.SEA3D.prototype.readMorpher = function ( sea ) { - var attribs = { - position : [] - }, - targets = []; + var attribs = { position: [] }, targets = []; for ( var i = 0; i < sea.node.length; i ++ ) { @@ -2501,8 +2819,8 @@ THREE.SEA3D.prototype.readMorpher = function( sea ) { } sea.tag = { - attribs : attribs, - targets : targets + attribs: attribs, + targets: targets }; }; @@ -2511,12 +2829,11 @@ THREE.SEA3D.prototype.readMorpher = function( sea ) { // Skeleton Animation // -THREE.SEA3D.prototype.getSkeletonAnimation = function( sea, skl ) { +THREE.SEA3D.prototype.getSkeletonAnimation = function ( sea, skl ) { if ( sea.tag ) return sea.tag; - var animations = [], - delta = ( 1000 / sea.frameRate ) / 1000; + var animations = [], delta = ( 1000 / sea.frameRate ) / 1000; for ( var i = 0; i < sea.sequence.length; i ++ ) { @@ -2577,14 +2894,9 @@ THREE.SEA3D.prototype.getSkeletonAnimation = function( sea, skl ) { // Vertex Animation // -THREE.SEA3D.prototype.readVertexAnimation = function( sea ) { +THREE.SEA3D.prototype.readVertexAnimation = function ( sea ) { - var attribs = { - position : [] - }, - targets = [], - animations = [], - i, j, l; + var attribs = { position: [] }, targets = [], animations = [], i, j, l; for ( i = 0, l = sea.frame.length; i < l; i ++ ) { @@ -2623,9 +2935,9 @@ THREE.SEA3D.prototype.readVertexAnimation = function( sea ) { } sea.tag = { - attribs : attribs, - targets : targets, - animations : animations + attribs: attribs, + targets: targets, + animations: animations }; }; @@ -2634,7 +2946,28 @@ THREE.SEA3D.prototype.readVertexAnimation = function( sea ) { // Actions // -THREE.SEA3D.prototype.readActions = function( sea ) { +THREE.SEA3D.prototype.applyEnvironment = function ( envMap ) { + + for ( var j = 0, l = this.materials.length; j < l; ++ j ) { + + var mat = this.materials[ j ]; + + if ( mat instanceof THREE.MeshStandardMaterial ) { + + if ( mat.envMap ) continue; + + mat.envMap = envMap; + mat.envMap.mapping = THREE.CubeReflectionMapping; + + mat.needsUpdate = true; + + } + + } + +}; + +THREE.SEA3D.prototype.readActions = function ( sea ) { for ( var i = 0; i < sea.actions.length; i ++ ) { @@ -2642,11 +2975,39 @@ THREE.SEA3D.prototype.readActions = function( sea ) { switch ( act.kind ) { + case SEA3D.Actions.ATTRIBUTES: + + this.attribs = this.domain.attribs = act.attributes.tag; + + break; + case SEA3D.Actions.SCRIPTS: this.domain.scripts = this.getJSMList( this.domain, act.scripts ); - if ( this.config.runScripts ) this.domain.runJSMList( obj3d ); + if ( this.config.runScripts ) this.domain.runJSMList( this.domain ); + + break; + + case SEA3D.Actions.ENVIRONMENT_COLOR: + + this.domain.background = this.background = this.background || {}; + + this.background.color = new THREE.Color( act.color ); + + break; + + case SEA3D.Actions.ENVIRONMENT: + + this.domain.background = this.background = this.background || {}; + + this.background.texture = act.texture.tag; + + if ( this.config.useEnvironment && this.materials != undefined ) { + + this.applyEnvironment( act.texture.tag ); + + } break; @@ -2661,7 +3022,8 @@ THREE.SEA3D.prototype.readActions = function( sea ) { // THREE.SEA3D.Event = { - LOAD_PROGRESS: "sea3d_progress", + PROGRESS: "sea3d_progress", + LOAD_PROGRESS: "sea3d_load", DOWNLOAD_PROGRESS: "sea3d_download", COMPLETE: "sea3d_complete", OBJECT_COMPLETE: "sea3d_object", @@ -2670,56 +3032,66 @@ THREE.SEA3D.Event = { ERROR: "sea3d_error" }; -THREE.SEA3D.prototype.onProgress = undefined; +THREE.SEA3D.prototype.onProgress = function ( e ) { + + e.status = e.type; + e.progress = e.loaded / e.total; + e.type = THREE.SEA3D.Event.PROGRESS; + + this.dispatchEvent( e ); + +}; + +THREE.SEA3D.prototype.onLoadProgress = function ( e ) { -THREE.SEA3D.prototype.onComplete = function( args ) { + e.type = THREE.SEA3D.Event.LOAD_PROGRESS; + this.dispatchEvent( e ); - args.file = this.scope; args.type = THREE.SEA3D.Event.COMPLETE; - args.file.dispatchEvent( args ); + this.onProgress( e ); }; -THREE.SEA3D.prototype.onLoadProgress = function( args ) { +THREE.SEA3D.prototype.onDownloadProgress = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.LOAD_PROGRESS; - args.file.dispatchEvent( args ); - if ( args.file.onProgress ) args.file.onProgress( args ); + e.type = THREE.SEA3D.Event.DOWNLOAD_PROGRESS; + this.dispatchEvent( e ); + + this.onProgress( e ); }; -THREE.SEA3D.prototype.onDownloadProgress = function( args ) { +THREE.SEA3D.prototype.onComplete = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.DOWNLOAD_PROGRESS; - args.file.dispatchEvent( args ); - if ( args.file.onProgress ) args.file.onProgress( args ); + e.type = THREE.SEA3D.Event.COMPLETE; + this.dispatchEvent( e ); }; -THREE.SEA3D.prototype.onCompleteObject = function( args ) { +THREE.SEA3D.prototype.onCompleteObject = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.OBJECT_COMPLETE; - args.file.dispatchEvent( args ); + e.type = THREE.SEA3D.Event.OBJECT_COMPLETE; + this.dispatchEvent( e ); }; -THREE.SEA3D.prototype.onParseProgress = function( args ) { +THREE.SEA3D.prototype.onParseProgress = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.PARSE_PROGRESS; - args.file.dispatchEvent( args ); + e.type = THREE.SEA3D.Event.PARSE_PROGRESS; + this.dispatchEvent( e ); }; -THREE.SEA3D.prototype.onParseComplete = function( args ) { +THREE.SEA3D.prototype.onParseComplete = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.PARSE_COMPLETE; - args.file.dispatchEvent( args ); + e.type = THREE.SEA3D.Event.PARSE_COMPLETE; + this.dispatchEvent( e ); }; -THREE.SEA3D.prototype.onError = function( args ) { +THREE.SEA3D.prototype.onError = function ( e ) { - args.file = this.scope; args.type = THREE.SEA3D.Event.ERROR; - args.file.dispatchEvent( args ); + e.type = THREE.SEA3D.Event.ERROR; + this.dispatchEvent( e ); }; @@ -2727,7 +3099,7 @@ THREE.SEA3D.prototype.onError = function( args ) { // Loader // -THREE.SEA3D.prototype.createDomain = function() { +THREE.SEA3D.prototype.createDomain = function () { return this.domain = new THREE.SEA3D.Domain( this.config.id, @@ -2737,7 +3109,7 @@ THREE.SEA3D.prototype.createDomain = function() { }; -THREE.SEA3D.prototype.clone = function( config, onParseComplete, onParseProgress ) { +THREE.SEA3D.prototype.clone = function ( config, onParseComplete, onParseProgress ) { if ( ! this.file.isDone() ) throw new Error( "Previous parse is not completed." ); @@ -2757,7 +3129,7 @@ THREE.SEA3D.prototype.clone = function( config, onParseComplete, onParseProgress }; -THREE.SEA3D.prototype.loadConfig = function( config ) { +THREE.SEA3D.prototype.loadConfig = function ( config ) { for ( var name in config ) { @@ -2767,7 +3139,7 @@ THREE.SEA3D.prototype.loadConfig = function( config ) { }; -THREE.SEA3D.prototype.parse = function( onParseComplete, onParseProgress ) { +THREE.SEA3D.prototype.parse = function ( onParseComplete, onParseProgress ) { delete this.cameras; delete this.containers; @@ -2782,6 +3154,7 @@ THREE.SEA3D.prototype.parse = function( onParseComplete, onParseProgress ) { delete this.sounds; delete this.glsl; delete this.dummy; + delete this.background; delete this.domain; @@ -2789,11 +3162,11 @@ THREE.SEA3D.prototype.parse = function( onParseComplete, onParseProgress ) { this.setTypeRead(); - this.file.onParseComplete = ( function( e ) { + this.file.onParseComplete = ( function ( e ) { if ( this.config.manager ) this.config.manager.add( this.domain ); - ( onParseComplete || this.onParseComplete ).call( this.file, e ); + ( onParseComplete || this.onParseComplete ).call( this, e ); } ).bind( this ); @@ -2817,15 +3190,7 @@ THREE.SEA3D.prototype.parse = function( onParseComplete, onParseProgress ) { }; -THREE.SEA3D.prototype.load = function( url ) { - - this.loadBytes(); - - this.file.load( url ); - -}; - -THREE.SEA3D.prototype.onHead = function( args ) { +THREE.SEA3D.prototype.onHead = function ( args ) { if ( args.sign != 'TJS' ) { @@ -2838,12 +3203,11 @@ THREE.SEA3D.prototype.onHead = function( args ) { THREE.SEA3D.EXTENSIONS_LOADER = []; THREE.SEA3D.EXTENSIONS_DOMAIN = []; -THREE.SEA3D.prototype.setTypeRead = function() { +THREE.SEA3D.prototype.setTypeRead = function () { this.file.typeRead = {}; - this.file.typeRead[ SEA3D.Geometry.prototype.type ] = - this.file.typeRead[ SEA3D.GeometryDelta.prototype.type ] = this.readGeometryBuffer; + this.file.typeRead[ SEA3D.Geometry.prototype.type ] = this.readGeometryBuffer; this.file.typeRead[ SEA3D.Mesh.prototype.type ] = this.readMesh; this.file.typeRead[ SEA3D.Sprite.prototype.type ] = this.readSprite; this.file.typeRead[ SEA3D.Container3D.prototype.type ] = this.readContainer3D; @@ -2858,6 +3222,7 @@ THREE.SEA3D.prototype.setTypeRead = function() { this.file.typeRead[ SEA3D.Animation.prototype.type ] = this.readAnimation; this.file.typeRead[ SEA3D.SoundPoint.prototype.type ] = this.readSoundPoint; this.file.typeRead[ SEA3D.TextureURL.prototype.type ] = this.readTextureURL; + this.file.typeRead[ SEA3D.CubeMapURL.prototype.type ] = this.readCubeMapURL; this.file.typeRead[ SEA3D.Morph.prototype.type ] = this.readMorpher; this.file.typeRead[ SEA3D.VertexAnimation.prototype.type ] = this.readVertexAnimation; this.file.typeRead[ SEA3D.Actions.prototype.type ] = this.readActions; @@ -2870,6 +3235,7 @@ THREE.SEA3D.prototype.setTypeRead = function() { if ( this.config.scripts ) { + this.file.typeRead[ SEA3D.ScriptURL.prototype.type ] = this.readScriptURL; this.file.typeRead[ SEA3D.JavaScriptMethod.prototype.type ] = this.readJavaScriptMethod; } @@ -2888,7 +3254,7 @@ THREE.SEA3D.prototype.setTypeRead = function() { this.file.typeRead[ SEA3D.JPEG.prototype.type ] = this.file.typeRead[ SEA3D.JPEG_XR.prototype.type ] = this.file.typeRead[ SEA3D.PNG.prototype.type ] = - this.file.typeRead[ SEA3D.GIF.prototype.type ] = this.readImage; + this.file.typeRead[ SEA3D.GIF.prototype.type ] = this.readTexture; this.file.typeRead[ SEA3D.MP3.prototype.type ] = this.readSound; this.file.typeRead[ SEA3D.GLSL.prototype.type ] = this.readGLSL; @@ -2906,24 +3272,24 @@ THREE.SEA3D.prototype.setTypeRead = function() { }; -THREE.SEA3D.prototype.loadBytes = function( data ) { +THREE.SEA3D.prototype.load = function ( data ) { this.file = new SEA3D.File(); this.file.scope = this; this.file.config = this.config; - this.file.onProgress = this.onLoadProgress; - this.file.onCompleteObject = this.onCompleteObject; - this.file.onDownloadProgress = this.onDownloadProgress; - this.file.onParseProgress = this.onParseProgress; - this.file.onParseComplete = this.onParseComplete; - this.file.onError = this.onError; - this.file.onHead = this.onHead; + this.file.onProgress = this.onLoadProgress.bind( this ); + this.file.onCompleteObject = this.onCompleteObject.bind( this ); + this.file.onDownloadProgress = this.onDownloadProgress.bind( this ); + this.file.onParseProgress = this.onParseProgress.bind( this ); + this.file.onParseComplete = this.onParseComplete.bind( this ); + this.file.onError = this.onError.bind( this ); + this.file.onHead = this.onHead.bind( this ); - this.file.onComplete = ( function( e ) { + this.file.onComplete = ( function ( e ) { if ( this.config.manager ) this.config.manager.add( this.domain ); - this.onComplete.call( this.file, e ); + this.onComplete.call( this, e ); } ).bind( this ); @@ -2933,6 +3299,9 @@ THREE.SEA3D.prototype.loadBytes = function( data ) { this.setTypeRead(); - this.file.read( data ); + if ( data === undefined ) return; + + if ( typeof data == "string" ) this.file.load( data ); + else this.file.read( data ); }; diff --git a/examples/js/modifiers/SimplifyModifier.js b/examples/js/modifiers/SimplifyModifier.js index 806695423ae0299999572fb0c04fc212f08b0a5b..6125de62eae13513d3db34d22c45217c98690943 100644 --- a/examples/js/modifiers/SimplifyModifier.js +++ b/examples/js/modifiers/SimplifyModifier.js @@ -134,7 +134,7 @@ THREE.SimplifyModifier = function() { } // we average the cost of collapsing at this vertex - v.collapseCost = v.totalCost / v.costCount + v.collapseCost = v.totalCost / v.costCount; // v.collapseCost = v.minCost; } @@ -349,7 +349,7 @@ THREE.SimplifyModifier = function() { Vertex.prototype.addUniqueNeighbor = function( vertex ) { pushIfUnique(this.neighbors, vertex); - } + }; Vertex.prototype.removeIfNonNeighbor = function( n ) { @@ -365,7 +365,7 @@ THREE.SimplifyModifier = function() { } neighbors.splice( offset, 1 ); - } + }; THREE.SimplifyModifier.prototype.modify = function( geometry, count ) { @@ -458,4 +458,4 @@ THREE.SimplifyModifier = function() { return newGeo; }; -})() \ No newline at end of file +})(); diff --git a/examples/js/nodes/NodeBuilder.js b/examples/js/nodes/NodeBuilder.js index 973378f464e826396cceb811f2c0bf58da86ca1d..f1809e9219ad94e076da9672976ca066c5e1098a 100644 --- a/examples/js/nodes/NodeBuilder.js +++ b/examples/js/nodes/NodeBuilder.js @@ -67,7 +67,7 @@ THREE.NodeBuilder.prototype = { addSlot : function( name ) { this.slots.push( { - name : name || '', + name : name || '' } ); return this.update(); diff --git a/examples/js/nodes/NodeMaterial.js b/examples/js/nodes/NodeMaterial.js index 301fe31b0524f68fccfcb9692fefb1e64efbf9c7..7cf0a561c0e5b0dd8e9c2e86b8da76d94602d33a 100644 --- a/examples/js/nodes/NodeMaterial.js +++ b/examples/js/nodes/NodeMaterial.js @@ -41,7 +41,7 @@ THREE.NodeMaterial.addShortcuts = function( proto, prop, list ) { } }; - }; + } return ( function() { @@ -335,7 +335,7 @@ THREE.NodeMaterial.prototype.getVar = function( uuid, type, ns ) { var index = this.vars.length, name = ns ? ns : 'nVv' + index; - data = { name : name, type : type } + data = { name : name, type : type }; this.vars.push( data ); this.vars[ uuid ] = data; diff --git a/examples/js/nodes/materials/PhongNode.js b/examples/js/nodes/materials/PhongNode.js index 141b8c42f3a13fc3043c7ebf5c7e2f359d9304c9..dc0d12fed1bf7569dbd30a28f06da6ed33f784fb 100644 --- a/examples/js/nodes/materials/PhongNode.js +++ b/examples/js/nodes/materials/PhongNode.js @@ -29,13 +29,13 @@ THREE.PhongNode.prototype.build = function( builder ) { var transform = this.transform ? this.transform.parseAndBuildCode( builder, 'v3', { cache : 'transform' } ) : undefined; - material.mergeUniform( THREE.UniformsUtils.merge( [ + material.mergeUniform( Object.assign( {}, THREE.UniformsLib[ "fog" ], THREE.UniformsLib[ "ambient" ], THREE.UniformsLib[ "lights" ] - ] ) ); + ) ); material.addVertexPars( [ "varying vec3 vViewPosition;", diff --git a/examples/js/nodes/materials/StandardNode.js b/examples/js/nodes/materials/StandardNode.js index 45fbe4f3b0191a5379519a0f17e941d2c823d0dd..9e0eee56caa50b2ac417c1d27ad9ed4dfb9a1667 100644 --- a/examples/js/nodes/materials/StandardNode.js +++ b/examples/js/nodes/materials/StandardNode.js @@ -30,13 +30,13 @@ THREE.StandardNode.prototype.build = function( builder ) { var transform = this.transform ? this.transform.parseAndBuildCode( builder, 'v3', { cache : 'transform' } ) : undefined; - material.mergeUniform( THREE.UniformsUtils.merge( [ + material.mergeUniform( Object.assign( {}, THREE.UniformsLib[ "fog" ], THREE.UniformsLib[ "ambient" ], THREE.UniformsLib[ "lights" ] - ] ) ); + ) ); material.addVertexPars( [ "varying vec3 vViewPosition;", @@ -165,7 +165,7 @@ THREE.StandardNode.prototype.build = function( builder ) { THREE.ShaderChunk[ "lights_pars" ], THREE.ShaderChunk[ "lights_physical_pars_fragment" ], THREE.ShaderChunk[ "shadowmap_pars_fragment" ], - THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ], + THREE.ShaderChunk[ "logdepthbuf_pars_fragment" ] ].join( "\n" ) ); var output = [ diff --git a/examples/js/nodes/math/Math3Node.js b/examples/js/nodes/math/Math3Node.js index d8e894b893e5c2286630aea2da117a5446fccbba..fc0476d44318df9c47e3433898d1a57f630e562b 100644 --- a/examples/js/nodes/math/Math3Node.js +++ b/examples/js/nodes/math/Math3Node.js @@ -44,7 +44,7 @@ THREE.Math3Node.prototype.generate = function( builder, output ) { var a, b, c, al = builder.getFormatLength( this.a.getType( builder ) ), bl = builder.getFormatLength( this.b.getType( builder ) ), - cl = builder.getFormatLength( this.c.getType( builder ) ) + cl = builder.getFormatLength( this.c.getType( builder ) ); // optimzer diff --git a/examples/js/postprocessing/AdaptiveToneMappingPass.js b/examples/js/postprocessing/AdaptiveToneMappingPass.js index 02acfde79a966b3b77fe33541082040df9555a2f..d448487639c586a88011a30e513f7a72cf09bc18 100644 --- a/examples/js/postprocessing/AdaptiveToneMappingPass.js +++ b/examples/js/postprocessing/AdaptiveToneMappingPass.js @@ -24,7 +24,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { var copyShader = THREE.CopyShader; - this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms = Object.assign( {}, copyShader.uniforms ); this.materialCopy = new THREE.ShaderMaterial( { @@ -41,15 +41,15 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { this.materialLuminance = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( THREE.LuminosityShader.uniforms ), + uniforms: Object.assign( {}, THREE.LuminosityShader.uniforms ), vertexShader: THREE.LuminosityShader.vertexShader, fragmentShader: THREE.LuminosityShader.fragmentShader, - blending: THREE.NoBlending, + blending: THREE.NoBlending } ); this.adaptLuminanceShader = { defines: { - "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 ), + "MIP_LEVEL_1X1" : ( Math.log( this.resolution ) / Math.log( 2.0 ) ).toFixed( 1 ) }, uniforms: { "lastLum": { value: null }, @@ -91,13 +91,13 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { "float fAdaptedLum = fLastLum + (fCurrentLum - fLastLum) * (1.0 - exp(-delta * tau));", // "fAdaptedLum = sqrt(fAdaptedLum);", "gl_FragColor = vec4( vec3( fAdaptedLum ), 1.0 );", - "}", + "}" ].join( '\n' ) }; this.materialAdaptiveLum = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( this.adaptLuminanceShader.uniforms ), + uniforms: Object.assign( {}, this.adaptLuminanceShader.uniforms ), vertexShader: this.adaptLuminanceShader.vertexShader, fragmentShader: this.adaptLuminanceShader.fragmentShader, defines: this.adaptLuminanceShader.defines, @@ -109,7 +109,7 @@ THREE.AdaptiveToneMappingPass = function ( adaptive, resolution ) { this.materialToneMap = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( THREE.ToneMapShader.uniforms ), + uniforms: Object.assign( {}, THREE.ToneMapShader.uniforms ), vertexShader: THREE.ToneMapShader.vertexShader, fragmentShader: THREE.ToneMapShader.fragmentShader, blending: THREE.NoBlending diff --git a/examples/js/postprocessing/BloomPass.js b/examples/js/postprocessing/BloomPass.js index 57f79c04569da4fe2d18eb15440cd2bf89990118..d750bf48d353f30f19f81f8567b914f57d9e1b29 100644 --- a/examples/js/postprocessing/BloomPass.js +++ b/examples/js/postprocessing/BloomPass.js @@ -25,9 +25,9 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) { var copyShader = THREE.CopyShader; - this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms = Object.assign( {}, copyShader.uniforms ); - this.copyUniforms[ "opacity" ].value = strength; + this.copyUniforms[ "opacity" ] = new THREE.Uniform( strength ); this.materialCopy = new THREE.ShaderMaterial( { @@ -46,10 +46,10 @@ THREE.BloomPass = function ( strength, kernelSize, sigma, resolution ) { var convolutionShader = THREE.ConvolutionShader; - this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms ); + this.convolutionUniforms = Object.assign( {}, convolutionShader.uniforms ); - this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX; - this.convolutionUniforms[ "cKernel" ].value = THREE.ConvolutionShader.buildKernel( sigma ); + this.convolutionUniforms[ "uImageIncrement" ] = new THREE.Uniform( THREE.BloomPass.blurX ); + this.convolutionUniforms[ "cKernel" ] = new THREE.Uniform( THREE.ConvolutionShader.buildKernel( sigma ) ); this.materialConvolution = new THREE.ShaderMaterial( { @@ -85,16 +85,16 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) this.quad.material = this.materialConvolution; - this.convolutionUniforms[ "tDiffuse" ].value = readBuffer.texture; - this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX; + this.convolutionUniforms[ "tDiffuse" ] = new THREE.Uniform( readBuffer.texture ); + this.convolutionUniforms[ "uImageIncrement" ] = new THREE.Uniform( THREE.BloomPass.blurX ); renderer.render( this.scene, this.camera, this.renderTargetX, true ); // Render quad with blured scene into texture (convolution pass 2) - this.convolutionUniforms[ "tDiffuse" ].value = this.renderTargetX.texture; - this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurY; + this.convolutionUniforms[ "tDiffuse" ] = new THREE.Uniform( this.renderTargetX.texture ); + this.convolutionUniforms[ "uImageIncrement" ] = new THREE.Uniform( THREE.BloomPass.blurY ); renderer.render( this.scene, this.camera, this.renderTargetY, true ); @@ -102,7 +102,7 @@ THREE.BloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ) this.quad.material = this.materialCopy; - this.copyUniforms[ "tDiffuse" ].value = this.renderTargetY.texture; + this.copyUniforms[ "tDiffuse" ] = new THREE.Uniform( this.renderTargetY.texture ); if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST ); diff --git a/examples/js/postprocessing/BokehPass.js b/examples/js/postprocessing/BokehPass.js index 5e0aad2a899b1a2d1276a4eb54f39b0baef68b3c..3abf7fecf6823c708a9a31dbc7e979c54bc47ade 100644 --- a/examples/js/postprocessing/BokehPass.js +++ b/examples/js/postprocessing/BokehPass.js @@ -41,7 +41,7 @@ THREE.BokehPass = function ( scene, camera, params ) { } var bokehShader = THREE.BokehShader; - var bokehUniforms = THREE.UniformsUtils.clone( bokehShader.uniforms ); + var bokehUniforms = Object.assign( {}, bokehShader.uniforms ); bokehUniforms[ "tDepth" ].value = this.renderTargetDepth.texture; diff --git a/examples/js/postprocessing/DotScreenPass.js b/examples/js/postprocessing/DotScreenPass.js index 42a7752b3e83caa13a58cfa7394c7f5bb2d5996f..2fdfb7ae2b8fdb393c0f6dd94dbc6b6302d76ad4 100644 --- a/examples/js/postprocessing/DotScreenPass.js +++ b/examples/js/postprocessing/DotScreenPass.js @@ -11,7 +11,7 @@ THREE.DotScreenPass = function ( center, angle, scale ) { var shader = THREE.DotScreenShader; - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); if ( center !== undefined ) this.uniforms[ "center" ].value.copy( center ); if ( angle !== undefined ) this.uniforms[ "angle" ].value = angle; diff --git a/examples/js/postprocessing/FilmPass.js b/examples/js/postprocessing/FilmPass.js index 399872954c0f506c7b44fe9f0895d8f6082a5bc9..c72d540d8fe1bcac06af9668ffdc4664e6ddf4c7 100644 --- a/examples/js/postprocessing/FilmPass.js +++ b/examples/js/postprocessing/FilmPass.js @@ -11,7 +11,7 @@ THREE.FilmPass = function ( noiseIntensity, scanlinesIntensity, scanlinesCount, var shader = THREE.FilmShader; - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); this.material = new THREE.ShaderMaterial( { diff --git a/examples/js/postprocessing/GlitchPass.js b/examples/js/postprocessing/GlitchPass.js index 4f2a3d16b1ab1623de952bf9f046041dc6ff08df..4153330c3e58aee72cd0f3608d7dc03cb4b87b1f 100644 --- a/examples/js/postprocessing/GlitchPass.js +++ b/examples/js/postprocessing/GlitchPass.js @@ -9,7 +9,7 @@ THREE.GlitchPass = function ( dt_size ) { if ( THREE.DigitalGlitch === undefined ) console.error( "THREE.GlitchPass relies on THREE.DigitalGlitch" ); var shader = THREE.DigitalGlitch; - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); if ( dt_size == undefined ) dt_size = 64; diff --git a/examples/js/postprocessing/ManualMSAARenderPass.js b/examples/js/postprocessing/ManualMSAARenderPass.js index a9f1fb9e936bdef3dff965c6b4786ec1a3f988ac..673fd99858f298efb09c897603ef120ebcc5ddc0 100644 --- a/examples/js/postprocessing/ManualMSAARenderPass.js +++ b/examples/js/postprocessing/ManualMSAARenderPass.js @@ -27,7 +27,7 @@ THREE.ManualMSAARenderPass = function ( scene, camera, clearColor, clearAlpha ) if ( THREE.CopyShader === undefined ) console.error( "THREE.ManualMSAARenderPass relies on THREE.CopyShader" ); var copyShader = THREE.CopyShader; - this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms = Object.assign( {}, copyShader.uniforms ); this.copyMaterial = new THREE.ShaderMaterial( { uniforms: this.copyUniforms, diff --git a/examples/js/postprocessing/OutlinePass.js b/examples/js/postprocessing/OutlinePass.js index 34ef26ef59bdbc8a7ab1986e39332ea9f8320ab3..6fb392e90c63a1377bb303c655c25e05c5641c6d 100644 --- a/examples/js/postprocessing/OutlinePass.js +++ b/examples/js/postprocessing/OutlinePass.js @@ -74,7 +74,7 @@ THREE.OutlinePass = function ( resolution, scene, camera, selectedObjects ) { var copyShader = THREE.CopyShader; - this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms = Object.assign( {}, copyShader.uniforms ); this.copyUniforms[ "opacity" ].value = 1.0; this.materialCopy = new THREE.ShaderMaterial( { @@ -145,7 +145,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype if( object instanceof THREE.Mesh ) { object.visible = bVisible; } - } + }; for( var i=0; i 0 ) { - var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01/ this.pulsePeriod ) * ( 1.0 - 0.25 )/2 + var scalar = ( 1 + 0.25 ) / 2 + Math.cos( performance.now() * 0.01/ this.pulsePeriod ) * ( 1.0 - 0.25 )/2; this.tempPulseColor1.multiplyScalar( scalar ); this.tempPulseColor2.multiplyScalar( scalar ); } @@ -358,7 +358,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype "maskTexture": { value: null }, "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) }, "visibleEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) }, - "hiddenEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) }, + "hiddenEdgeColor": { value: new THREE.Vector3( 1.0, 1.0, 1.0 ) } }, vertexShader: @@ -399,7 +399,7 @@ THREE.OutlinePass.prototype = Object.assign( Object.create( THREE.Pass.prototype return new THREE.ShaderMaterial( { defines: { - "MAX_RADIUS" : maxRadius, + "MAX_RADIUS" : maxRadius }, uniforms: { diff --git a/examples/js/postprocessing/RenderPass.js b/examples/js/postprocessing/RenderPass.js index 180e6812312949479d2f233f4119bb2b4dcbb5df..2711be7b552514de61a2fb408c28ea3a06df7ce8 100644 --- a/examples/js/postprocessing/RenderPass.js +++ b/examples/js/postprocessing/RenderPass.js @@ -15,6 +15,7 @@ THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clear this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0; this.clear = true; + this.clearDepth = false; this.needsSwap = false; }; @@ -41,6 +42,12 @@ THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype } + if ( this.clearDepth ) { + + renderer.clearDepth(); + + } + renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); if ( this.clearColor ) { diff --git a/examples/js/postprocessing/SMAAPass.js b/examples/js/postprocessing/SMAAPass.js index 955117c58109b8edb308396acc3bd7ede828730b..1405e930610707ffc0f5f7c2c1a7b595e36622c9 100644 --- a/examples/js/postprocessing/SMAAPass.js +++ b/examples/js/postprocessing/SMAAPass.js @@ -54,7 +54,7 @@ THREE.SMAAPass = function ( width, height ) { console.error( "THREE.SMAAPass relies on THREE.SMAAShader" ); } - this.uniformsEdges = THREE.UniformsUtils.clone( THREE.SMAAShader[0].uniforms ); + this.uniformsEdges = Object.assign( {}, THREE.SMAAShader[0].uniforms ); this.uniformsEdges[ "resolution" ].value.set( 1 / width, 1 / height ); @@ -67,7 +67,7 @@ THREE.SMAAPass = function ( width, height ) { // materials - pass 2 - this.uniformsWeights = THREE.UniformsUtils.clone( THREE.SMAAShader[1].uniforms ); + this.uniformsWeights = Object.assign( {}, THREE.SMAAShader[1].uniforms ); this.uniformsWeights[ "resolution" ].value.set( 1 / width, 1 / height ); this.uniformsWeights[ "tDiffuse" ].value = this.edgesRT.texture; @@ -83,7 +83,7 @@ THREE.SMAAPass = function ( width, height ) { // materials - pass 3 - this.uniformsBlend = THREE.UniformsUtils.clone( THREE.SMAAShader[2].uniforms ); + this.uniformsBlend = Object.assign( {}, THREE.SMAAShader[2].uniforms ); this.uniformsBlend[ "resolution" ].value.set( 1 / width, 1 / height ); this.uniformsBlend[ "tDiffuse" ].value = this.weightsRT.texture; diff --git a/examples/js/postprocessing/SavePass.js b/examples/js/postprocessing/SavePass.js index 6480bd372d1b1d23b8b402a2eb9799044b3ec14f..9709f65c3ff6dab71b1d84110f3a916cfff62df8 100644 --- a/examples/js/postprocessing/SavePass.js +++ b/examples/js/postprocessing/SavePass.js @@ -13,7 +13,7 @@ THREE.SavePass = function ( renderTarget ) { this.textureID = "tDiffuse"; - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); this.material = new THREE.ShaderMaterial( { diff --git a/examples/js/postprocessing/ShaderPass.js b/examples/js/postprocessing/ShaderPass.js index 3c2f1a9b5a3bf9690dce13c39b5dbfe46c3a907d..4810e00f78ac8fa7afcbb1d658c166abf7645efd 100644 --- a/examples/js/postprocessing/ShaderPass.js +++ b/examples/js/postprocessing/ShaderPass.js @@ -16,7 +16,7 @@ THREE.ShaderPass = function ( shader, textureID ) { } else if ( shader ) { - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); this.material = new THREE.ShaderMaterial( { @@ -45,7 +45,7 @@ THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype if ( this.uniforms[ this.textureID ] ) { - this.uniforms[ this.textureID ].value = readBuffer.texture; + this.uniforms[ this.textureID ] = new THREE.Uniform( readBuffer.texture ); } diff --git a/examples/js/postprocessing/TexturePass.js b/examples/js/postprocessing/TexturePass.js index a73ff0cbd966dc5395aa2d1710f3e111af88c753..65e07b2f6704164e01ecbea5470fbfc76326f3df 100644 --- a/examples/js/postprocessing/TexturePass.js +++ b/examples/js/postprocessing/TexturePass.js @@ -14,7 +14,7 @@ THREE.TexturePass = function ( map, opacity ) { this.map = map; this.opacity = ( opacity !== undefined ) ? opacity : 1.0; - this.uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + this.uniforms = Object.assign( {}, shader.uniforms ); this.material = new THREE.ShaderMaterial( { @@ -47,8 +47,8 @@ THREE.TexturePass.prototype = Object.assign( Object.create( THREE.Pass.prototype this.quad.material = this.material; - this.uniforms[ "opacity" ].value = this.opacity; - this.uniforms[ "tDiffuse" ].value = this.map; + this.uniforms[ "opacity" ] = new THREE.Uniform( this.opacity ); + this.uniforms[ "tDiffuse" ] = new THREE.Uniform( this.map ); this.material.transparent = ( this.opacity < 1.0 ); renderer.render( this.scene, this.camera, this.renderToScreen ? null : readBuffer, this.clear ); diff --git a/examples/js/postprocessing/UnrealBloomPass.js b/examples/js/postprocessing/UnrealBloomPass.js index 90bdaf65dba0feb1eb002226f6c4af53779111a7..3a776cfaf3151ca398d22fafc576c32132639de4 100644 --- a/examples/js/postprocessing/UnrealBloomPass.js +++ b/examples/js/postprocessing/UnrealBloomPass.js @@ -49,7 +49,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) { console.error( "THREE.UnrealBloomPass relies on THREE.LuminosityHighPassShader" ); var highPassShader = THREE.LuminosityHighPassShader; - this.highPassUniforms = THREE.UniformsUtils.clone( highPassShader.uniforms ); + this.highPassUniforms = Object.assign( {}, highPassShader.uniforms ); this.highPassUniforms[ "luminosityThreshold" ].value = threshold; this.highPassUniforms[ "smoothWidth" ].value = 0.01; @@ -101,7 +101,7 @@ THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) { var copyShader = THREE.CopyShader; - this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms ); + this.copyUniforms = Object.assign( {}, copyShader.uniforms ); this.copyUniforms[ "opacity" ].value = 1.0; this.materialCopy = new THREE.ShaderMaterial( { @@ -231,7 +231,7 @@ THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.proto uniforms: { "colorTexture": { value: null }, "texSize": { value: new THREE.Vector2( 0.5, 0.5 ) }, - "direction": { value: new THREE.Vector2( 0.5, 0.5 ) }, + "direction": { value: new THREE.Vector2( 0.5, 0.5 ) } }, vertexShader: diff --git a/examples/js/renderers/RaytracingRenderer.js b/examples/js/renderers/RaytracingRenderer.js index 59a87de33fc4c30505eb57ca0baa8f4ee9d1c2fc..7c9edae03fd335fa3e7bf29e9cafa03df4ce36fc 100644 --- a/examples/js/renderers/RaytracingRenderer.js +++ b/examples/js/renderers/RaytracingRenderer.js @@ -74,7 +74,7 @@ THREE.RaytracingRenderer = function ( parameters ) { } - } + }; worker.color = new THREE.Color().setHSL( Math.random() , 0.8, 0.8 ).getHexString(); pool.push( worker ); @@ -195,7 +195,7 @@ THREE.RaytracingRenderer = function ( parameters ) { mirror: 1, reflectivity: 1, refractionRatio: 1, - glass: 1, + glass: 1 }; diff --git a/examples/js/renderers/WebGLDeferredRenderer.js b/examples/js/renderers/WebGLDeferredRenderer.js index 749c9b9d40036eae1f21e19ce8f7224872e07dd0..59f0abfaa9c6b3a695bbc829520603026b41fabb 100644 --- a/examples/js/renderers/WebGLDeferredRenderer.js +++ b/examples/js/renderers/WebGLDeferredRenderer.js @@ -69,8 +69,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { // external properties - this.renderer; - this.domElement; + this.renderer = undefined; + this.domElement = undefined; this.forwardRendering = false; // for debug @@ -115,7 +115,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { undefined, undefined, THREE.DepthStencilFormat - ) + ); } @@ -164,7 +164,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { _passLightFullscreen = new THREE.RenderPass(); _passLightFullscreen.clear = true; - _passLightFullscreen.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 ); + _passLightFullscreen.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 ); _passLight = new THREE.RenderPass(); _passLight.clear = false; @@ -345,12 +345,16 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var shader = ( isLightPrePass ) ? THREE.ShaderDeferred[ 'normalDepthShininess' ] : THREE.ShaderDeferred[ 'normalDepth' ]; var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + uniforms: Object.assign( {}, shader.uniforms ), fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, blending: THREE.NoBlending } ); + var uniforms = material.uniforms; + + if ( uniforms.shininess !== undefined ) uniforms.shininess = uniforms.shininess.clone(); + return material; } @@ -449,14 +453,23 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var shader = THREE.ShaderDeferred[ 'color' ]; var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + uniforms: Object.assign( {}, shader.uniforms ), fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, blending: THREE.NoBlending } ); + var uniforms = material.uniforms; + + uniforms.diffuse = uniforms.diffuse.clone(); + uniforms.emissive = uniforms.emissive.clone(); + uniforms.specular = uniforms.specular.clone(); + uniforms.shininess = uniforms.shininess.clone(); + if ( originalMaterial.map !== undefined ) material.map = originalMaterial.map; + uniforms.map = new THREE.Uniform(); + return material; } @@ -587,7 +600,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var shader = THREE.ShaderDeferred[ 'reconstruction' ]; var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + uniforms: Object.assign( {}, shader.uniforms ), fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, blending: THREE.NoBlending @@ -605,9 +618,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { updateDeferredColorMaterial( material, originalMaterial ); - material.uniforms.viewWidth.value = _width; - material.uniforms.viewHeight.value = _height; - } function setMaterialForwardRendering( object ) { @@ -660,7 +670,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { if ( originalMaterial.transparent === true && originalMaterial.visible === true ) { - return originalMaterial + return originalMaterial; } else { @@ -675,7 +685,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var shader = THREE.ShaderDeferred[ 'emissiveLight' ]; var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + uniforms: Object.assign( {}, shader.uniforms ), vertexShader: shader.vertexShader, fragmentShader: shader.fragmentShader, blending: THREE.NoBlending, @@ -691,15 +701,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { } - function updateDeferredEmissiveLight( light, camera ) { - - var uniforms = light.material.uniforms; - - uniforms.viewWidth.value = _width; - uniforms.viewHeight.value = _height; - - } - function initDeferredLight( light ) { var deferredLight; @@ -807,7 +808,7 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { function createDeferredLightMaterial( shader, isLightPrePass ) { var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.clone( shader.uniforms ), + uniforms: Object.assign( {}, shader.uniforms ), vertexShader: shader.vertexShader, fragmentShader: shader.fragmentShader, transparent: true, @@ -850,6 +851,13 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { material.side = THREE.BackSide; material.depthFunc = THREE.GreaterEqualDepth; + var uniforms = material.uniforms; + + uniforms.lightColor = uniforms.lightColor.clone(); + uniforms.lightRadius = uniforms.lightRadius.clone(); + uniforms.lightIntensity = uniforms.lightIntensity.clone(); + uniforms.lightPositionVS = uniforms.lightPositionVS.clone(); + return material; } @@ -860,9 +868,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var distance = originalLight.distance; var uniforms = light.material.uniforms; - uniforms.matProjInverse.value.getInverse( camera.projectionMatrix ); - uniforms.viewWidth.value = _width; - uniforms.viewHeight.value = _height; uniforms.lightColor.value.copy( originalLight.color ); if ( distance > 0 ) { @@ -895,6 +900,14 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { material.depthTest = false; + var uniforms = material.uniforms; + + uniforms.lightColor = uniforms.lightColor.clone(); + uniforms.lightAngle = uniforms.lightAngle.clone(); + uniforms.lightIntensity = uniforms.lightIntensity.clone(); + uniforms.lightPositionVS = uniforms.lightPositionVS.clone(); + uniforms.lightDirectionVS = uniforms.lightDirectionVS.clone(); + return material; } @@ -904,9 +917,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var originalLight = light.userData.originalLight; var uniforms = light.material.uniforms; - uniforms.matProjInverse.value.getInverse( camera.projectionMatrix ); - uniforms.viewWidth.value = _width; - uniforms.viewHeight.value = _height; uniforms.lightAngle.value = originalLight.angle; uniforms.lightColor.value.copy( originalLight.color ); uniforms.lightIntensity.value = originalLight.intensity; @@ -935,6 +945,12 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { material.depthTest = false; + var uniforms = material.uniforms; + + uniforms.lightColor = uniforms.lightColor.clone(); + uniforms.lightIntensity = uniforms.lightIntensity.clone(); + uniforms.lightDirectionVS = uniforms.lightDirectionVS.clone(); + return material; } @@ -944,9 +960,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { var originalLight = light.userData.originalLight; var uniforms = light.material.uniforms; - uniforms.matProjInverse.value.getInverse( camera.projectionMatrix ); - uniforms.viewWidth.value = _width; - uniforms.viewHeight.value = _height; uniforms.lightColor.value.copy( originalLight.color ); uniforms.lightIntensity.value = originalLight.intensity; @@ -1058,6 +1071,17 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { } + function updateDeferredCommonUniforms( camera ) { + + var uniforms = THREE.ShaderDeferredCommon[ 'commonUniforms' ]; + + uniforms.viewWidth.value = _width; + uniforms.viewHeight.value = _height; + + uniforms.matProjInverse.value.getInverse( camera.projectionMatrix ); + + } + function enableFinalPasses() { if ( _lightPrePass ) { @@ -1224,8 +1248,6 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { function renderLight( scene, camera ) { - updateDeferredEmissiveLight( _lightFullscreenScene.userData.emissiveLight, camera ); - scene.traverse( addDeferredLightsToLightScene ); updateDeferredLightsInLightScene( _lightScene, camera ); @@ -1403,6 +1425,8 @@ THREE.WebGLDeferredRenderer = function ( parameters ) { scene.traverse( saveOriginalMaterialAndCheckTransparency ); + updateDeferredCommonUniforms( camera ); + renderNormalDepth( scene, camera ); if ( _lightPrePass ) { @@ -1440,9 +1464,9 @@ THREE.DeferredShaderChunk = { "float vec3_to_float( vec3 data ) {", - "const float unit = 255.0/256.0;", - "highp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;", - "return compressed;", + " const float unit = 255.0/256.0;", + " highp float compressed = fract( data.x * unit ) + floor( data.y * unit * 255.0 ) + floor( data.z * unit * 255.0 ) * 255.0;", + " return compressed;", "}" @@ -1452,13 +1476,13 @@ THREE.DeferredShaderChunk = { "vec3 float_to_vec3( float data ) {", - "const float unit = 255.0;", - "vec3 uncompressed;", - "uncompressed.x = fract( data );", - "float zInt = floor( data / unit );", - "uncompressed.z = fract( zInt / unit );", - "uncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );", - "return uncompressed;", + " const float unit = 255.0;", + " vec3 uncompressed;", + " uncompressed.x = fract( data );", + " float zInt = floor( data / unit );", + " uncompressed.z = fract( zInt / unit );", + " uncompressed.y = fract( floor( data - ( zInt * unit ) ) / unit );", + " return uncompressed;", "}" @@ -1474,7 +1498,7 @@ THREE.DeferredShaderChunk = { "vec4 packedNormalDepth;", "packedNormalDepth.xyz = normal * 0.5 + 0.5;", - "packedNormalDepth.w = position.z / position.w;", + "packedNormalDepth.w = position.z / position.w;" ].join( "\n" ), @@ -1528,7 +1552,7 @@ THREE.DeferredShaderChunk = { "vec3 diffuseColor = float_to_vec3( colorMap.x );", "vec3 emissiveColor = float_to_vec3( colorMap.y );", "vec3 specularColor = float_to_vec3( colorMap.z );", - "float shininess = colorMap.w;", + "float shininess = colorMap.w;" ].join( "\n" ), @@ -1536,7 +1560,7 @@ THREE.DeferredShaderChunk = { "vec4 packedLight;", "packedLight.xyz = lightIntensity * lightColor * max( dot( lightVector, normal ), 0.0 ) * attenuation;", - "packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;", + "packedLight.w = lightIntensity * specular * max( dot( lightVector, normal ), 0.0 ) * attenuation;" ].join( "\n" ), @@ -1555,7 +1579,7 @@ THREE.DeferredShaderChunk = { "vec3 halfVector = normalize( lightVector - normalize( vertexPositionVS.xyz ) );", "float dotNormalHalf = max( dot( normal, halfVector ), 0.0 );", - "float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );", + "float specular = 0.31830988618 * ( shininess * 0.5 + 1.0 ) * pow( dotNormalHalf, shininess );" ].join( "\n" ), @@ -1567,6 +1591,19 @@ THREE.DeferredShaderChunk = { }; +THREE.ShaderDeferredCommon = { + + commonUniforms: { + + matProjInverse: new THREE.Uniform( new THREE.Matrix4() ), + + viewWidth: new THREE.Uniform( 800 ), + viewHeight: new THREE.Uniform( 600 ) + + } + +}; + THREE.ShaderDeferred = { normalDepth: { @@ -1583,17 +1620,17 @@ THREE.ShaderDeferred = { "void main() {", - THREE.ShaderChunk[ "begin_vertex" ], - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], + THREE.ShaderChunk[ "begin_vertex" ], + THREE.ShaderChunk[ "beginnormal_vertex" ], + THREE.ShaderChunk[ "skinbase_vertex" ], + THREE.ShaderChunk[ "skinnormal_vertex" ], + THREE.ShaderChunk[ "defaultnormal_vertex" ], + THREE.ShaderChunk[ "morphtarget_vertex" ], + THREE.ShaderChunk[ "skinning_vertex" ], + THREE.ShaderChunk[ "project_vertex" ], - "vNormal = normalize( normalMatrix * objectNormal );", - "vPosition = gl_Position;", + " vNormal = normalize( normalMatrix * objectNormal );", + " vPosition = gl_Position;", "}" @@ -1606,12 +1643,12 @@ THREE.ShaderDeferred = { "void main() {", - "vec3 normal = vNormal;", - "vec4 position = vPosition;", + " vec3 normal = vNormal;", + " vec4 position = vPosition;", - THREE.DeferredShaderChunk[ "packNormalDepth" ], + THREE.DeferredShaderChunk[ "packNormalDepth" ], - "gl_FragColor = packedNormalDepth;", + " gl_FragColor = packedNormalDepth;", "}" @@ -1623,13 +1660,13 @@ THREE.ShaderDeferred = { uniforms: { - map: { type: "t", value: null }, - offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }, + map: new THREE.Uniform( null ), + offsetRepeat: new THREE.Uniform( new THREE.Vector4( 0, 0, 1, 1 ) ), - diffuse: { type: "c", value: new THREE.Color( 0x000000 ) }, - emissive: { type: "c", value: new THREE.Color( 0x000000 ) }, - specular: { type: "c", value: new THREE.Color( 0x000000 ) }, - shininess: { type: "f", value: 30.0 } + diffuse: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + emissive: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + specular: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + shininess: new THREE.Uniform( 30.0 ) }, @@ -1641,15 +1678,15 @@ THREE.ShaderDeferred = { "void main() {", - THREE.ShaderChunk[ "uv_vertex" ], - THREE.ShaderChunk[ "begin_vertex" ], - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], + THREE.ShaderChunk[ "uv_vertex" ], + THREE.ShaderChunk[ "begin_vertex" ], + THREE.ShaderChunk[ "beginnormal_vertex" ], + THREE.ShaderChunk[ "skinbase_vertex" ], + THREE.ShaderChunk[ "skinnormal_vertex" ], + THREE.ShaderChunk[ "defaultnormal_vertex" ], + THREE.ShaderChunk[ "morphtarget_vertex" ], + THREE.ShaderChunk[ "skinning_vertex" ], + THREE.ShaderChunk[ "project_vertex" ], "}" @@ -1668,14 +1705,14 @@ THREE.ShaderDeferred = { "void main() {", - "vec4 diffuseColor = vec4( diffuse, 1.0 );", - "vec3 emissiveColor = emissive;", - "vec3 specularColor = specular;", + " vec4 diffuseColor = vec4( diffuse, 1.0 );", + " vec3 emissiveColor = emissive;", + " vec3 specularColor = specular;", - THREE.ShaderChunk[ "map_fragment" ], - THREE.DeferredShaderChunk[ "packColor" ], + THREE.ShaderChunk[ "map_fragment" ], + THREE.DeferredShaderChunk[ "packColor" ], - "gl_FragColor = packedColor;", + " gl_FragColor = packedColor;", "}" @@ -1685,19 +1722,23 @@ THREE.ShaderDeferred = { emissiveLight: { - uniforms: { + uniforms: Object.assign( - samplerColor: { type: "t", value: null }, - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 } + { - }, + samplerColor: new THREE.Uniform( null ) + + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ "void main() { ", - "gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", "}" @@ -1714,10 +1755,10 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackColor" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackColor" ], - "gl_FragColor = vec4( emissiveColor, 1.0 );", + " gl_FragColor = vec4( emissiveColor, 1.0 );", "}" @@ -1727,28 +1768,29 @@ THREE.ShaderDeferred = { pointLight: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ), + lightRadius: new THREE.Uniform( 1.0 ) - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 }, - lightRadius: { type: "f", value: 1.0 } + }, - }, + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ "void main() {", - "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}" @@ -1773,33 +1815,33 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepth" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - "vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", - "float distance = length( lightVector );", + " vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", + " float distance = length( lightVector );", - "if ( distance > lightRadius ) discard;", + " if ( distance > lightRadius ) discard;", - "lightVector = normalize( lightVector );", + " lightVector = normalize( lightVector );", - THREE.DeferredShaderChunk[ "unpackColor" ], - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "unpackColor" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "//float cutoff = 0.3;", - "//float denom = distance / lightRadius + 1.0;", - "//float attenuation = 1.0 / ( denom * denom );", - "//attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );", - "//attenuation = max( attenuation, 0.0 );", - "//attenuation *= attenuation;", + " //float cutoff = 0.3;", + " //float denom = distance / lightRadius + 1.0;", + " //float attenuation = 1.0 / ( denom * denom );", + " //attenuation = ( attenuation - cutoff ) / ( 1.0 - cutoff );", + " //attenuation = max( attenuation, 0.0 );", + " //attenuation *= attenuation;", - "//diffuseColor *= saturate( -distance / lightRadius + 1.0 );", - "//float attenuation = 1.0;", + " //diffuseColor *= saturate( -distance / lightRadius + 1.0 );", + " //float attenuation = 1.0;", - "float attenuation = saturate( -distance / lightRadius + 1.0 );", + " float attenuation = saturate( -distance / lightRadius + 1.0 );", - THREE.DeferredShaderChunk[ "combine" ], + THREE.DeferredShaderChunk[ "combine" ], "}" @@ -1809,29 +1851,30 @@ THREE.ShaderDeferred = { spotLight: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightAngle: new THREE.Uniform( 1.0 ), + lightIntensity: new THREE.Uniform( 1.0 ) - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightAngle: { type: "f", value: 1.0 }, - lightIntensity: { type: "f", value: 1.0 } + }, - }, + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ "void main() { ", - "gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", "}" @@ -1857,45 +1900,45 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepth" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - THREE.DeferredShaderChunk[ "unpackColor" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "unpackColor" ], - "vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", + " vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", - "float rho = dot( lightDirectionVS, lightVector );", - "float rhoMax = cos( lightAngle * 0.5 );", + " float rho = dot( lightDirectionVS, lightVector );", + " float rhoMax = cos( lightAngle * 0.5 );", - "if ( rho <= rhoMax ) discard;", + " if ( rho <= rhoMax ) discard;", - "float theta = rhoMax + 0.0001;", - "float phi = rhoMax + 0.05;", - "float falloff = 4.0;", + " float theta = rhoMax + 0.0001;", + " float phi = rhoMax + 0.05;", + " float falloff = 4.0;", - "float spot = 0.0;", + " float spot = 0.0;", - "if ( rho >= phi ) {", + " if ( rho >= phi ) {", - "spot = 1.0;", + " spot = 1.0;", - "} else if ( rho <= theta ) {", + " } else if ( rho <= theta ) {", - "spot = 0.0;", + " spot = 0.0;", - "} else { ", + " } else { ", - "spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", + " spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", - "}", + " }", - "diffuseColor *= spot;", + " diffuseColor *= spot;", - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "const float attenuation = 1.0;", + " const float attenuation = 1.0;", - THREE.DeferredShaderChunk[ "combine" ], + THREE.DeferredShaderChunk[ "combine" ], "}" @@ -1905,27 +1948,27 @@ THREE.ShaderDeferred = { directionalLight: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepth: { type: "t", value: null }, - samplerColor: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepth: new THREE.Uniform( null ), + samplerColor: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ) + }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS : { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 } + THREE.ShaderDeferredCommon[ 'commonUniforms' ] - }, + ), vertexShader: [ "void main() { ", - "gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", "}" @@ -1949,22 +1992,22 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepth" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - THREE.DeferredShaderChunk[ "unpackColor" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepth" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "unpackColor" ], - "vec3 lightVector = normalize( lightDirectionVS );", + " vec3 lightVector = normalize( lightDirectionVS );", - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "const float attenuation = 1.0;", + " const float attenuation = 1.0;", - THREE.DeferredShaderChunk[ "combine" ], + THREE.DeferredShaderChunk[ "combine" ], "}" - ].join( '\n' ), + ].join( '\n' ) }, @@ -1972,7 +2015,7 @@ THREE.ShaderDeferred = { uniforms: { - shininess: { type: "f", value: 30.0 } + shininess: new THREE.Uniform( 30.0 ) }, @@ -1986,17 +2029,17 @@ THREE.ShaderDeferred = { "void main() {", - THREE.ShaderChunk[ "begin_vertex" ], - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], + THREE.ShaderChunk[ "begin_vertex" ], + THREE.ShaderChunk[ "beginnormal_vertex" ], + THREE.ShaderChunk[ "skinbase_vertex" ], + THREE.ShaderChunk[ "skinnormal_vertex" ], + THREE.ShaderChunk[ "defaultnormal_vertex" ], + THREE.ShaderChunk[ "morphtarget_vertex" ], + THREE.ShaderChunk[ "skinning_vertex" ], + THREE.ShaderChunk[ "project_vertex" ], - "vNormal = normalize( normalMatrix * objectNormal );", - "vPosition = gl_Position;", + " vNormal = normalize( normalMatrix * objectNormal );", + " vPosition = gl_Position;", "}" @@ -2013,12 +2056,12 @@ THREE.ShaderDeferred = { "void main() {", - "vec3 normal = vNormal;", - "vec4 position = vPosition;", + " vec3 normal = vNormal;", + " vec4 position = vPosition;", - THREE.DeferredShaderChunk[ "packNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "packNormalDepthShininess" ], - "gl_FragColor = packedNormalDepthShininess;", + " gl_FragColor = packedNormalDepthShininess;", "}" @@ -2028,27 +2071,28 @@ THREE.ShaderDeferred = { pointLightPre: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepthShininess: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepthShininess: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ), + lightRadius: new THREE.Uniform( 1.0 ) + }, - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 }, - lightRadius: { type: "f", value: 1.0 } + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), - }, vertexShader: [ "void main() {", - "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + " gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", "}" @@ -2072,24 +2116,24 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - "vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", - "float distance = length( lightVector );", + " vec3 lightVector = lightPositionVS - vertexPositionVS.xyz;", + " float distance = length( lightVector );", - "if ( distance > lightRadius ) discard;", + " if ( distance > lightRadius ) discard;", - "lightVector = normalize( lightVector );", + " lightVector = normalize( lightVector );", - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "float attenuation = saturate( -distance / lightRadius + 1.0 );", + " float attenuation = saturate( -distance / lightRadius + 1.0 );", - THREE.DeferredShaderChunk[ "packLight" ], + THREE.DeferredShaderChunk[ "packLight" ], - "gl_FragColor = packedLight;", + " gl_FragColor = packedLight;", "}" @@ -2099,28 +2143,29 @@ THREE.ShaderDeferred = { spotLightPre: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepthShininess: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepthShininess: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightPositionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightAngle: new THREE.Uniform( 1.0 ), + lightIntensity: new THREE.Uniform( 1.0 ) - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightPositionVS: { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightAngle: { type: "f", value: 1.0 }, - lightIntensity: { type: "f", value: 1.0 } + }, - }, + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ "void main() { ", - "gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", "}" @@ -2145,44 +2190,44 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - "vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", + " vec3 lightVector = normalize( lightPositionVS.xyz - vertexPositionVS.xyz );", - "float rho = dot( lightDirectionVS, lightVector );", - "float rhoMax = cos( lightAngle * 0.5 );", + " float rho = dot( lightDirectionVS, lightVector );", + " float rhoMax = cos( lightAngle * 0.5 );", - "if ( rho <= rhoMax ) discard;", + " if ( rho <= rhoMax ) discard;", - "float theta = rhoMax + 0.0001;", - "float phi = rhoMax + 0.05;", - "float falloff = 4.0;", + " float theta = rhoMax + 0.0001;", + " float phi = rhoMax + 0.05;", + " float falloff = 4.0;", - "float spot = 0.0;", + " float spot = 0.0;", - "if ( rho >= phi ) {", + " if ( rho >= phi ) {", - "spot = 1.0;", + " spot = 1.0;", - "} else if ( rho <= theta ) {", + " } else if ( rho <= theta ) {", - "spot = 0.0;", + " spot = 0.0;", - "} else { ", + " } else { ", - "spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", + " spot = pow( ( rho - theta ) / ( phi - theta ), falloff );", - "}", + " }", - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "const float attenuation = 1.0;", + " const float attenuation = 1.0;", - THREE.DeferredShaderChunk[ "packLight" ], + THREE.DeferredShaderChunk[ "packLight" ], - "gl_FragColor = spot * packedLight;", + " gl_FragColor = spot * packedLight;", "}" @@ -2192,26 +2237,27 @@ THREE.ShaderDeferred = { directionalLightPre: { - uniforms: { + uniforms: Object.assign( - samplerNormalDepthShininess: { type: "t", value: null }, + { - matProjInverse: { type: "m4", value: new THREE.Matrix4() }, + samplerNormalDepthShininess: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + lightColor: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + lightDirectionVS: new THREE.Uniform( new THREE.Vector3( 0, 1, 0 ) ), + lightIntensity: new THREE.Uniform( 1.0 ) - lightColor: { type: "c", value: new THREE.Color( 0x000000 ) }, - lightDirectionVS : { type: "v3", value: new THREE.Vector3( 0, 1, 0 ) }, - lightIntensity: { type: "f", value: 1.0 } + }, - }, + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ "void main() { ", - "gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", + " gl_Position = vec4( sign( position.xy ), 0.0, 1.0 );", "}" @@ -2234,44 +2280,47 @@ THREE.ShaderDeferred = { "void main() {", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], - THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], - THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "unpackNormalDepthShininess" ], + THREE.DeferredShaderChunk[ "computeVertexPositionVS" ], - "vec3 lightVector = normalize( lightDirectionVS );", + " vec3 lightVector = normalize( lightDirectionVS );", - THREE.DeferredShaderChunk[ "computeSpecular" ], + THREE.DeferredShaderChunk[ "computeSpecular" ], - "const float attenuation = 1.0;", + " const float attenuation = 1.0;", - THREE.DeferredShaderChunk[ "packLight" ], + THREE.DeferredShaderChunk[ "packLight" ], - "gl_FragColor = packedLight;", + " gl_FragColor = packedLight;", "}" - ].join( '\n' ), + ].join( '\n' ) }, reconstruction: { - uniforms: { + uniforms: Object.assign( - samplerLight: { type: "t", value: null }, + { - map: { type: "t", value: null }, - offsetRepeat: { type: "v4", value: new THREE.Vector4( 0, 0, 1, 1 ) }, + samplerLight: new THREE.Uniform( null ), - viewWidth: { type: "f", value: 800 }, - viewHeight: { type: "f", value: 600 }, + map: new THREE.Uniform( null ), + offsetRepeat: new THREE.Uniform( new THREE.Vector4( 0, 0, 1, 1 ) ), - diffuse: { type: "c", value: new THREE.Color( 0x000000 ) }, - emissive: { type: "c", value: new THREE.Color( 0x000000 ) }, - specular: { type: "c", value: new THREE.Color( 0x000000 ) }, - shininess: { type: "f", value: 30.0 } + diffuse: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + emissive: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + specular: new THREE.Uniform( new THREE.Color( 0x000000 ) ), + shininess: new THREE.Uniform( 30.0 ) - }, + }, + + THREE.ShaderDeferredCommon[ 'commonUniforms' ] + + ), vertexShader: [ @@ -2281,15 +2330,15 @@ THREE.ShaderDeferred = { "void main() {", - THREE.ShaderChunk[ "uv_vertex" ], - THREE.ShaderChunk[ "begin_vertex" ], - THREE.ShaderChunk[ "beginnormal_vertex" ], - THREE.ShaderChunk[ "skinbase_vertex" ], - THREE.ShaderChunk[ "skinnormal_vertex" ], - THREE.ShaderChunk[ "defaultnormal_vertex" ], - THREE.ShaderChunk[ "morphtarget_vertex" ], - THREE.ShaderChunk[ "skinning_vertex" ], - THREE.ShaderChunk[ "project_vertex" ], + THREE.ShaderChunk[ "uv_vertex" ], + THREE.ShaderChunk[ "begin_vertex" ], + THREE.ShaderChunk[ "beginnormal_vertex" ], + THREE.ShaderChunk[ "skinbase_vertex" ], + THREE.ShaderChunk[ "skinnormal_vertex" ], + THREE.ShaderChunk[ "defaultnormal_vertex" ], + THREE.ShaderChunk[ "morphtarget_vertex" ], + THREE.ShaderChunk[ "skinning_vertex" ], + THREE.ShaderChunk[ "project_vertex" ], "}" @@ -2314,21 +2363,21 @@ THREE.ShaderDeferred = { "void main() {", - "vec4 diffuseColor = vec4( diffuse, 1.0 );", - "vec3 emissiveColor = emissive;", - "vec3 specularColor = specular;", + " vec4 diffuseColor = vec4( diffuse, 1.0 );", + " vec3 emissiveColor = emissive;", + " vec3 specularColor = specular;", - THREE.DeferredShaderChunk[ "computeTextureCoord" ], + THREE.DeferredShaderChunk[ "computeTextureCoord" ], - "vec4 light = texture2D( samplerLight, texCoord );", + " vec4 light = texture2D( samplerLight, texCoord );", - THREE.ShaderChunk[ "map_fragment" ], + THREE.ShaderChunk[ "map_fragment" ], - "vec3 diffuseFinal = diffuseColor.rgb * light.rgb;", - "vec3 emissiveFinal = emissiveColor;", - "vec3 specularFinal = specularColor * light.rgb * ( light.a / ( 0.2126 * light.r + 0.7152 * light.g + 0.0722 * light.b + 0.00001 ) );", + " vec3 diffuseFinal = diffuseColor.rgb * light.rgb;", + " vec3 emissiveFinal = emissiveColor;", + " vec3 specularFinal = specularColor * light.rgb * ( light.a / ( 0.2126 * light.r + 0.7152 * light.g + 0.0722 * light.b + 0.00001 ) );", - "gl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );", + " gl_FragColor = vec4( diffuseFinal + emissiveFinal + specularFinal, 1.0 );", "}" @@ -2341,7 +2390,7 @@ THREE.ShaderDeferred = { uniforms: { - samplerResult: { type: "t", value: null } + samplerResult: new THREE.Uniform( null ) }, @@ -2351,9 +2400,9 @@ THREE.ShaderDeferred = { "void main() {", - "vec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );", - "texCoord = pos.xy * vec2( 0.5 ) + 0.5;", - "gl_Position = pos;", + " vec4 pos = vec4( sign( position.xy ), 0.0, 1.0 );", + " texCoord = pos.xy * vec2( 0.5 ) + 0.5;", + " gl_Position = pos;", "}" @@ -2366,7 +2415,7 @@ THREE.ShaderDeferred = { "void main() {", - "gl_FragColor = texture2D( samplerResult, texCoord );", + " gl_FragColor = texture2D( samplerResult, texCoord );", "}" @@ -2374,4 +2423,4 @@ THREE.ShaderDeferred = { } -}; \ No newline at end of file +}; diff --git a/examples/js/shaders/BokehShader2.js b/examples/js/shaders/BokehShader2.js index 61c463f0114c771edb2ecd8522155ed6674223c8..5e3a1f0990590b13d106c7df8ea16d4103fffb27 100644 --- a/examples/js/shaders/BokehShader2.js +++ b/examples/js/shaders/BokehShader2.js @@ -44,7 +44,7 @@ THREE.BokehShader = { "pentagon": { value: 0 }, "shaderFocus": { value: 1 }, - "focusCoords": { value: new THREE.Vector2() }, + "focusCoords": { value: new THREE.Vector2() } }, diff --git a/examples/js/shaders/ConvolutionShader.js b/examples/js/shaders/ConvolutionShader.js index 822e2ea6136ba3aa1ad0f85a54a820c2830692b8..677f4d9a005ee610b7371bc65be4c9ff2501de48 100644 --- a/examples/js/shaders/ConvolutionShader.js +++ b/examples/js/shaders/ConvolutionShader.js @@ -11,7 +11,7 @@ THREE.ConvolutionShader = { defines: { "KERNEL_SIZE_FLOAT": "25.0", - "KERNEL_SIZE_INT": "25", + "KERNEL_SIZE_INT": "25" }, diff --git a/examples/js/shaders/EdgeShader.js b/examples/js/shaders/EdgeShader.js index 38e62d1b23624b9c0dfdcdaf5b565deed11013de..e2e878f3f7e6ab516f7e05556af84dec259da380 100644 --- a/examples/js/shaders/EdgeShader.js +++ b/examples/js/shaders/EdgeShader.js @@ -12,7 +12,7 @@ THREE.EdgeShader = { uniforms: { "tDiffuse": { value: null }, - "aspect": { value: new THREE.Vector2( 512, 512 ) }, + "aspect": { value: new THREE.Vector2( 512, 512 ) } }, vertexShader: [ @@ -87,7 +87,7 @@ THREE.EdgeShader = { "float S = (cnv[4] + cnv[5]) + (cnv[6] + cnv[7]) + (cnv[8] + M);", "gl_FragColor = vec4(vec3(sqrt(M/S)), 1.0);", - "}", + "}" ].join( "\n" ) }; diff --git a/examples/js/shaders/EdgeShader2.js b/examples/js/shaders/EdgeShader2.js index 549d531331d1df5813cca62f4f59270f9e7532bf..27f27883b012ba332c8b2098d08785e98ad99143 100644 --- a/examples/js/shaders/EdgeShader2.js +++ b/examples/js/shaders/EdgeShader2.js @@ -12,7 +12,7 @@ THREE.EdgeShader2 = { uniforms: { "tDiffuse": { value: null }, - "aspect": { value: new THREE.Vector2( 512, 512 ) }, + "aspect": { value: new THREE.Vector2( 512, 512 ) } }, vertexShader: [ @@ -66,7 +66,7 @@ THREE.EdgeShader2 = { "}", "gl_FragColor = vec4(0.5 * sqrt(cnv[0]*cnv[0]+cnv[1]*cnv[1]));", - "} ", + "} " ].join( "\n" ) diff --git a/examples/js/shaders/GammaCorrectionShader.js b/examples/js/shaders/GammaCorrectionShader.js index 890bdae9ddd9f6785c1a6888517e0b6d0334cc8e..4c2a373fba16b5702ce657f3130d634dcdeaafb5 100644 --- a/examples/js/shaders/GammaCorrectionShader.js +++ b/examples/js/shaders/GammaCorrectionShader.js @@ -9,7 +9,7 @@ THREE.GammaCorrectionShader = { uniforms: { - "tDiffuse": { value: null }, + "tDiffuse": { value: null } }, diff --git a/examples/js/shaders/LuminosityHighPassShader.js b/examples/js/shaders/LuminosityHighPassShader.js index b6b26af35d370ebfcb84eb7e5196d0f0ea044c7f..c5c436fbd2f82ce8d779ebd839ca499f87ed5105 100644 --- a/examples/js/shaders/LuminosityHighPassShader.js +++ b/examples/js/shaders/LuminosityHighPassShader.js @@ -15,7 +15,7 @@ THREE.LuminosityHighPassShader = { "luminosityThreshold": { type: "f", value: 1.0 }, "smoothWidth": { type: "f", value: 1.0 }, "defaultColor": { type: "c", value: new THREE.Color( 0x000000 ) }, - "defaultOpacity": { type: "f", value: 0.0 }, + "defaultOpacity": { type: "f", value: 0.0 } }, @@ -56,7 +56,7 @@ THREE.LuminosityHighPassShader = { "float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );", "gl_FragColor = mix( outputColor, texel, alpha );", - + "}" ].join("\n") diff --git a/examples/js/shaders/OceanShaders.js b/examples/js/shaders/OceanShaders.js index cfb7c343379ad9d6777928db7e3d02c25259d5a4..1f67a339d02de47225b4e669611b2f7fb75c6f6f 100644 --- a/examples/js/shaders/OceanShaders.js +++ b/examples/js/shaders/OceanShaders.js @@ -86,7 +86,7 @@ THREE.ShaderLib[ 'ocean_initial_spectrum' ] = { uniforms: { "u_wind": { value: new THREE.Vector2( 10.0, 10.0 ) }, "u_resolution": { value: 512.0 }, - "u_size": { value: 250.0 }, + "u_size": { value: 250.0 } }, fragmentShader: [ 'precision highp float;', @@ -163,7 +163,7 @@ THREE.ShaderLib[ 'ocean_phase' ] = { "u_phases": { value: null }, "u_deltaTime": { value: null }, "u_resolution": { value: null }, - "u_size": { value: null }, + "u_size": { value: null } }, fragmentShader: [ 'precision highp float;', @@ -204,7 +204,7 @@ THREE.ShaderLib[ 'ocean_spectrum' ] = { "u_resolution": { value: null }, "u_choppiness": { value: null }, "u_phases": { value: null }, - "u_initialSpectrum": { value: null }, + "u_initialSpectrum": { value: null } }, fragmentShader: [ 'precision highp float;', @@ -266,7 +266,7 @@ THREE.ShaderLib[ 'ocean_normals' ] = { uniforms: { "u_displacementMap": { value: null }, "u_resolution": { value: null }, - "u_size": { value: null }, + "u_size": { value: null } }, fragmentShader: [ 'precision highp float;', @@ -308,7 +308,7 @@ THREE.ShaderLib[ 'ocean_main' ] = { "u_skyColor": { value: null }, "u_oceanColor": { value: null }, "u_sunDirection": { value: null }, - "u_exposure": { value: null }, + "u_exposure": { value: null } }, vertexShader: [ 'precision highp float;', diff --git a/examples/js/shaders/ParallaxShader.js b/examples/js/shaders/ParallaxShader.js index 2b22097492564140c0b008ae8b2f2f0c202a3bc8..5b9531d70df5dc18ef2957c1c730ee64aff7c534 100644 --- a/examples/js/shaders/ParallaxShader.js +++ b/examples/js/shaders/ParallaxShader.js @@ -10,7 +10,7 @@ THREE.ParallaxShader = { basic: 'USE_BASIC_PARALLAX', steep: 'USE_STEEP_PARALLAX', occlusion: 'USE_OCLUSION_PARALLAX', // a.k.a. POM - relief: 'USE_RELIEF_PARALLAX', + relief: 'USE_RELIEF_PARALLAX' }, uniforms: { @@ -177,7 +177,7 @@ THREE.ParallaxShader = { "vec2 mapUv = perturbUv( -vViewPosition, normalize( vNormal ), normalize( vViewPosition ) );", "gl_FragColor = texture2D( map, mapUv );", - "}", + "}" ].join( "\n" ) diff --git a/examples/js/shaders/TechnicolorShader.js b/examples/js/shaders/TechnicolorShader.js index 12ab60e93ec93f7e841449dbb1326a74add5b259..ba1c8e7136a5d876d7b8db58e85d5b31caaa9bf5 100644 --- a/examples/js/shaders/TechnicolorShader.js +++ b/examples/js/shaders/TechnicolorShader.js @@ -11,7 +11,7 @@ THREE.TechnicolorShader = { uniforms: { - "tDiffuse": { value: null }, + "tDiffuse": { value: null } }, diff --git a/examples/js/utils/ShadowMapViewer.js b/examples/js/utils/ShadowMapViewer.js index 21b80eb83f19b502bbcc08e73dcf9ced974f1f5d..4f6e7857c3a9f9689bcf0742600231cd05667698 100644 --- a/examples/js/utils/ShadowMapViewer.js +++ b/examples/js/utils/ShadowMapViewer.js @@ -39,7 +39,7 @@ THREE.ShadowMapViewer = function ( light ) { x: 10, y: 10, width: 256, - height: 256, + height: 256 }; var camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, 1, 10 ); @@ -49,7 +49,7 @@ THREE.ShadowMapViewer = function ( light ) { //HUD for shadow map var shader = THREE.UnpackDepthRGBAShader; - var uniforms = new THREE.UniformsUtils.clone( shader.uniforms ); + var uniforms = Object.assign( {}, shader.uniforms ); var material = new THREE.ShaderMaterial( { uniforms: uniforms, vertexShader: shader.vertexShader, diff --git a/examples/js/vr/PaintViveController.js b/examples/js/vr/PaintViveController.js index 5674479d71871618b9d94b845542b20d3e6ff67d..f97c4d8afa0e34acef3c3705d3abe6f7c4976c61 100644 --- a/examples/js/vr/PaintViveController.js +++ b/examples/js/vr/PaintViveController.js @@ -52,7 +52,7 @@ THREE.PaintViveController = function ( id ) { mesh.position.set( 0, 0.005, 0.0495 ); mesh.rotation.x = - 1.45; mesh.scale.setScalar( 0.02 ); - this.add( mesh ) + this.add( mesh ); var geometry = new THREE.IcosahedronGeometry( 0.1, 2 ); var material = new THREE.MeshBasicMaterial(); diff --git a/examples/js/vr/WebVR.js b/examples/js/vr/WebVR.js old mode 100755 new mode 100644 diff --git a/examples/misc_controls_trackball.html b/examples/misc_controls_trackball.html index bc701ac2710d06bbad9ed62cc8810864b1c28754..4a2c0836d6a0c623a702f5f52893368235d26af9 100644 --- a/examples/misc_controls_trackball.html +++ b/examples/misc_controls_trackball.html @@ -34,7 +34,7 @@
- three.js - trackball controls example
+ three.js - trackball controls example
MOVE mouse & press LEFT/A: rotate, MIDDLE/S: zoom, RIGHT/D: pan
diff --git a/examples/misc_sound.html b/examples/misc_sound.html index 6b0a8b393dd9bfe9e1fa243a9b946f9e7a30d2d4..87e1eb915b4718feaa40e28ec03bf7341edbeb6c 100644 --- a/examples/misc_sound.html +++ b/examples/misc_sound.html @@ -171,7 +171,7 @@ var GeneratorControls = function() { this.frequency = oscillator.frequency.value; this.wavetype = oscillator.type; - } + }; var gui = new dat.GUI(); var soundControls = new SoundControls(); var generatorControls = new GeneratorControls(); diff --git a/examples/models/3mf/cube_gears.3mf b/examples/models/3mf/cube_gears.3mf old mode 100755 new mode 100644 diff --git a/examples/models/collada/pump/pump.dae b/examples/models/collada/pump/pump.dae old mode 100755 new mode 100644 diff --git a/examples/models/collada/pump/pump_body.jpg b/examples/models/collada/pump/pump_body.jpg old mode 100755 new mode 100644 diff --git a/examples/models/collada/pump/pump_gears.jpg b/examples/models/collada/pump/pump_gears.jpg old mode 100755 new mode 100644 diff --git a/examples/models/collada/pump/pump_metalreflect.jpg b/examples/models/collada/pump/pump_metalreflect.jpg old mode 100755 new mode 100644 diff --git a/examples/models/mmd/Readme.txt b/examples/models/mmd/Readme.txt index cfec00e19da57d2c6984216aecaed199339fe4d4..d78752fbb24696c7ce954bf73e28740bc326e6ac 100644 --- a/examples/models/mmd/Readme.txt +++ b/examples/models/mmd/Readme.txt @@ -1,6 +1,6 @@ The files under this directory are NOT under MIT license, but other licenses. -If you want to use them in your work, get original data, read readme, and follow -their licenses. +If you want to use them in your work, get original archive file, read readme, +and follow their licenses. 1. Vocaloid stuffs @@ -14,17 +14,17 @@ For detail, see http://piapro.net/en_for_creators.html 2. MMD stuffs -In MMD, there is no unified license. If you want to use MMD works (models, -songs, dances, and so on), read readme included in archive file and follow the -license the author set. +In MMD, there is no unified license. If you want to use MMD assets (models, +songs, dances, and so on), read readme included in the original archive file +and follow the license the author set. -If the works are fan works, you must follow the original work's license. (For +If the assets are fan works, you must follow the original work's license. (For example, you also need to follow the license set by Crypton, not only the -license the author set, to use a Miku MMD model) +license the author set, to use a fan Miku MMD model) -For your information, generally MMD works are very restricted to use. +For your information, generally MMD assets are very restricted to use. -Most MMD works are NOT allowed for +Most MMD assets are NOT allowed for - redistribution - porn use - commercial use diff --git a/examples/models/platform/platform.jpg b/examples/models/platform/platform.jpg old mode 100755 new mode 100644 diff --git a/examples/models/sea3d/robot.o3dgc.tjs.sea b/examples/models/sea3d/robot.o3dgc.tjs.sea new file mode 100644 index 0000000000000000000000000000000000000000..de8257dcd4aa625841fc1188a345100ee3ba2b0a Binary files /dev/null and b/examples/models/sea3d/robot.o3dgc.tjs.sea differ diff --git a/examples/models/vrml/house.wrl b/examples/models/vrml/house.wrl old mode 100755 new mode 100644 diff --git a/examples/raytracing_sandbox.html b/examples/raytracing_sandbox.html index 72376cf85c3aecf3a192fea84dafff5c97247c4a..958b1efd82c23ed13fab815f3fa087837bc5848f 100644 --- a/examples/raytracing_sandbox.html +++ b/examples/raytracing_sandbox.html @@ -247,7 +247,7 @@ info.style.textAlign = 'center'; container.appendChild( info ); - updateWorkers() + updateWorkers(); // diff --git a/examples/software_sandbox.html b/examples/software_sandbox.html index c3ccc0c86a43fa2785fd484fb162e4eacdc7c025..a672caec1dc87e12040a98b5b42c7d77201f4585 100644 --- a/examples/software_sandbox.html +++ b/examples/software_sandbox.html @@ -104,7 +104,7 @@ var points = hilbert3D( new THREE.Vector3( 0,0,0 ), 200.0, 1, 0, 1, 2, 3, 4, 5, 6, 7 ); var spline = new THREE.Spline( points ); var n_sub = 6, colors = [], line; - var lineGeometry = new THREE.Geometry() + var lineGeometry = new THREE.Geometry(); for ( i = 0; i < points.length * n_sub; i ++ ) { diff --git a/examples/webgl_animation_cloth.html b/examples/webgl_animation_cloth.html index 8a31649664ab97eb8446ef06caf2812ed07804ee..bb58c75e87fc6f905f3354844444f65a053f081c 100644 --- a/examples/webgl_animation_cloth.html +++ b/examples/webgl_animation_cloth.html @@ -295,7 +295,7 @@ window.addEventListener( 'resize', onWindowResize, false ); - sphere.visible = ! true + sphere.visible = ! true; } diff --git a/examples/webgl_animation_skinning_morph.html b/examples/webgl_animation_skinning_morph.html index 5f9112db4df43248ed6f583ef200fa912caffc0e..8a11f404f2e81154260ab293e35bb10175b51b1a 100644 --- a/examples/webgl_animation_skinning_morph.html +++ b/examples/webgl_animation_skinning_morph.html @@ -154,7 +154,7 @@ var loader = new THREE.JSONLoader(); loader.load( "models/skinned/knight.js", function ( geometry, materials ) { - createScene( geometry, materials, 0, FLOOR, -300, 60 ) + createScene( geometry, materials, 0, FLOOR, -300, 60 ); // GUI @@ -606,7 +606,7 @@ folder.add( API, 'uncache clip' ); folder.add( API, 'uncache action' ); - } + }; memoryControl( gui, mixer, [ bonesClip, facesClip ], [ mesh, mesh2 ] ); diff --git a/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html b/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html index 9e333274a5d2f49158efb69a65c6d81faf3afd77..e65578acc223c593b6bcbcb09e37500ffd7ceda3 100644 --- a/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html +++ b/examples/webgl_buffergeometry_instancing_interleaved_dynamic.html @@ -153,7 +153,7 @@ 1, -1, 1, 0, 1, 0, 0, 0, -1, -1, 1, 0, 0, 0, 0, 0, 1, -1, -1, 0, 1, 1, 0, 0, - -1, -1, -1, 0, 0, 1, 0, 0, + -1, -1, -1, 0, 0, 1, 0, 0 ] ), 8 ); // Use vertexBuffer, starting at offset 0, 3 items in position attribute diff --git a/examples/webgl_buffergeometry_lines_indexed.html b/examples/webgl_buffergeometry_lines_indexed.html index 601c3194190a8d65f8927e6cd66ee997e767efb5..0ce0ae4cffc8c36a48c5fbaf0f5ec69b75cdb348 100644 --- a/examples/webgl_buffergeometry_lines_indexed.html +++ b/examples/webgl_buffergeometry_lines_indexed.html @@ -158,7 +158,7 @@ new THREE.Vector3(0, y+0, 0), new THREE.Vector3(500, y, 0), new THREE.Vector3(500, y+500, 0), - new THREE.Vector3(0, y+500, 0), + new THREE.Vector3(0, y+500, 0) ], true, 600 ); @@ -175,7 +175,7 @@ new THREE.Vector3(0, y, 0), new THREE.Vector3(250, y+0, 0), new THREE.Vector3(250, y-250, 0), - new THREE.Vector3(250, y+0, 0), + new THREE.Vector3(250, y+0, 0) ], false, 600 ); diff --git a/examples/webgl_camera_logarithmicdepthbuffer.html b/examples/webgl_camera_logarithmicdepthbuffer.html index 53db381b2b1c97a4c9064214144494e5e9321175..60d74086b728402077abe94a6a492bb8a56b1e16 100644 --- a/examples/webgl_camera_logarithmicdepthbuffer.html +++ b/examples/webgl_camera_logarithmicdepthbuffer.html @@ -205,7 +205,7 @@ var labelgeo = new THREE.TextGeometry( labeldata[i].label, { font: font, size: labeldata[i].size, - height: labeldata[i].size / 2, + height: labeldata[i].size / 2 } ); labelgeo.computeBoundingSphere(); diff --git a/examples/webgl_clipping_advanced.html b/examples/webgl_clipping_advanced.html index 369df9d3e697f54e6af7639ce75d0660f4f76140..c83449e2eec3889780c97f38d0c9172408c478bd 100644 --- a/examples/webgl_clipping_advanced.html +++ b/examples/webgl_clipping_advanced.html @@ -134,10 +134,11 @@ ], Indices = [ - 0, 1, 2, 0, 2, 3, 0, 3, 1, 1, 3, 2 ], + 0, 1, 2, 0, 2, 3, 0, 3, 1, 1, 3, 2 + ], Planes = planesFromMesh( Vertices, Indices ), - PlaneMatrices = Planes.map( planeToMatrix ); + PlaneMatrices = Planes.map( planeToMatrix ), GlobalClippingPlanes = cylindricalPlanes( 5, 3.5 ), diff --git a/examples/webgl_custom_attributes.html b/examples/webgl_custom_attributes.html index c5b3b628e0c6e2f17b8dc7a0cd96102ede8972b4..1542344d497123b9759c3f0f191c45dcfae582de 100644 --- a/examples/webgl_custom_attributes.html +++ b/examples/webgl_custom_attributes.html @@ -106,7 +106,7 @@ amplitude: { value: 1.0 }, color: { value: new THREE.Color( 0xff2200 ) }, - texture: { value: new THREE.TextureLoader().load( "textures/water.jpg" ) }, + texture: { value: new THREE.TextureLoader().load( "textures/water.jpg" ) } }; diff --git a/examples/webgl_custom_attributes_lines.html b/examples/webgl_custom_attributes_lines.html index 5fac35bc9b98ff05aa592d187f9d97eeb09dc20c..ca605797b99d7a01f33ad2c68712dfd638f43cea 100644 --- a/examples/webgl_custom_attributes_lines.html +++ b/examples/webgl_custom_attributes_lines.html @@ -140,7 +140,7 @@ var buffergeometry = new THREE.BufferGeometry(); var position = new THREE.Float32BufferAttribute( vertices.length * 3, 3 ).copyVector3sArray( vertices ); - buffergeometry.addAttribute( 'position', position ) + buffergeometry.addAttribute( 'position', position ); var displacement = new THREE.Float32BufferAttribute( vertices.length * 3, 3 ); buffergeometry.addAttribute( 'displacement', displacement ); diff --git a/examples/webgl_custom_attributes_points3.html b/examples/webgl_custom_attributes_points3.html index 2db73d495f8c70cf8f35a3250ad7c9940cdbd48a..4d9feb5ce57151adcff7207f36d245c51413b09e 100644 --- a/examples/webgl_custom_attributes_points3.html +++ b/examples/webgl_custom_attributes_points3.html @@ -219,7 +219,7 @@ uniforms: { amplitude: { value: 1.0 }, color: { value: new THREE.Color( 0xffffff ) }, - texture: { value: texture }, + texture: { value: texture } }, vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent diff --git a/examples/webgl_decals.html b/examples/webgl_decals.html index 477a688f957f4f1464cc3224a358c21aa702ae79..c9437d8ffa22884cb6b1980ffca875fe1505fb3c 100644 --- a/examples/webgl_decals.html +++ b/examples/webgl_decals.html @@ -20,8 +20,10 @@
- Decal Splatter
- Click or tap to shoot.

+

+ Decal Splatter
+ Click or tap to shoot. +

diff --git a/examples/webgl_depth_texture.html b/examples/webgl_depth_texture.html index 21080cb7ccb2824b367af4158354d56794c0de2e..729e91be36e1e207bc9abbc68d5a96152b2ba126 100644 --- a/examples/webgl_depth_texture.html +++ b/examples/webgl_depth_texture.html @@ -196,7 +196,7 @@ // Setup some geometries var geometry = new THREE.TorusKnotGeometry(1, 0.3, 128, 64); - var material = new THREE.MeshBasicMaterial({ color: 'blue' }) + var material = new THREE.MeshBasicMaterial({ color: 'blue' }); var count = 50; var scale = 5; diff --git a/examples/webgl_effects_anaglyph.html b/examples/webgl_effects_anaglyph.html index 825798f69a5b36d8c3ecd09517c7a8522ea99e84..1cfbe959d3f1c1299f670f3c9aceab81cac92728 100644 --- a/examples/webgl_effects_anaglyph.html +++ b/examples/webgl_effects_anaglyph.html @@ -126,8 +126,8 @@ function onWindowResize() { - windowHalfX = window.innerWidth / 2, - windowHalfY = window.innerHeight / 2, + windowHalfX = window.innerWidth / 2; + windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); diff --git a/examples/webgl_effects_parallaxbarrier.html b/examples/webgl_effects_parallaxbarrier.html index c2e351b1ca80396b6668a9c31d6319d3324901cd..4b21a24810a0e0f0525e9c2117d426ca42616755 100644 --- a/examples/webgl_effects_parallaxbarrier.html +++ b/examples/webgl_effects_parallaxbarrier.html @@ -313,7 +313,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; @@ -354,7 +354,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; @@ -414,7 +414,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; diff --git a/examples/webgl_effects_stereo.html b/examples/webgl_effects_stereo.html index 7201a72e07f0a6aedd375a97b530b9825d6814cb..16d9acd50afc32ca47d4978eb681b851fd30c022 100644 --- a/examples/webgl_effects_stereo.html +++ b/examples/webgl_effects_stereo.html @@ -118,8 +118,8 @@ function onWindowResize() { - windowHalfX = window.innerWidth / 2, - windowHalfY = window.innerHeight / 2, + windowHalfX = window.innerWidth / 2; + windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); diff --git a/examples/webgl_geometry_colors_lookuptable.html b/examples/webgl_geometry_colors_lookuptable.html index a5f2ea119f7944d0d4c8c09181b18931a254a39c..2ddb433bd1fa71fa78fae866a21cf8fb16fb8cdd 100644 --- a/examples/webgl_geometry_colors_lookuptable.html +++ b/examples/webgl_geometry_colors_lookuptable.html @@ -34,8 +34,8 @@ -
three.js webgl - lookuptable - vertex color values from a range of data values.
- press A: change color map, press S: change numberOfColors, press D: toggle Legend on/off, press F: change Legend layout
+
three.js webgl - lookuptable - vertex color values from a range of data values.
+ press A: change color map, press S: change numberOfColors, press D: toggle Legend on/off, press F: change Legend layout
diff --git a/examples/webgl_geometry_extrude_shapes.html b/examples/webgl_geometry_extrude_shapes.html index f451d460accae5e00a8251ab322098e41ef47a48..eed3525faab0b2eefa3a69e41c0449026b5a4fbc 100644 --- a/examples/webgl_geometry_extrude_shapes.html +++ b/examples/webgl_geometry_extrude_shapes.html @@ -165,7 +165,7 @@ bevelEnabled : true, bevelThickness : 2, bevelSize : 4, - bevelSegments : 1, + bevelSegments : 1 }; var geometry = new THREE.ExtrudeGeometry( shape, extrudeSettings ); diff --git a/examples/webgl_geometry_extrude_shapes2.html b/examples/webgl_geometry_extrude_shapes2.html index 514cdc974a6e7e3a045abff0992767515f2fef98..84d183f26bb6a3e6137a64a27612ebaeea185f1b 100644 --- a/examples/webgl_geometry_extrude_shapes2.html +++ b/examples/webgl_geometry_extrude_shapes2.html @@ -292,7 +292,7 @@ var addGeoObject = function( group, svgObject ) { color = new THREE.Color( theColors[i] ); material = new THREE.MeshLambertMaterial({ color: color, - emissive: color, + emissive: color }); amount = theAmounts[i]; simpleShapes = path.toShapes(true); diff --git a/examples/webgl_geometry_extrude_splines.html b/examples/webgl_geometry_extrude_splines.html index e7dfd517b0385166a67e4ad6010eabf9d37abdad..727b62e63cd4e082c51d1b21f11a97b8c3d0dbb3 100644 --- a/examples/webgl_geometry_extrude_splines.html +++ b/examples/webgl_geometry_extrude_splines.html @@ -66,7 +66,7 @@ new THREE.Vector3( 0, 40, -40 ), new THREE.Vector3( 0, 140, -40 ), new THREE.Vector3( 0, 40, 40 ), - new THREE.Vector3( 0, -40, 40 ), + new THREE.Vector3( 0, -40, 40 ) ] ); sampleClosedSpline.type = 'catmullrom'; diff --git a/examples/webgl_geometry_spline_editor.html b/examples/webgl_geometry_spline_editor.html index 8c35696c6acf9f5fc94dcddaf2f3780798eaf503..ae0c310373f08fd2f6fcef27e805729f41514f06 100644 --- a/examples/webgl_geometry_spline_editor.html +++ b/examples/webgl_geometry_spline_editor.html @@ -34,7 +34,7 @@ } return str; - } + }; var container, stats; var camera, scene, renderer; @@ -172,13 +172,13 @@ transformControl.attach( e.object ); cancelHideTransorm(); // * - } ) + } ); dragcontrols.on( 'hoveroff', function( e ) { if ( e ) delayHideTransform(); - } ) + } ); controls.addEventListener( 'start', function() { @@ -304,7 +304,7 @@ } else { object.position.x = Math.random() * 1000 - 500; - object.position.y = Math.random() * 600 + object.position.y = Math.random() * 600; object.position.z = Math.random() * 800 - 400; } diff --git a/examples/webgl_gpgpu_water.html b/examples/webgl_gpgpu_water.html index d01f5a29038e593a53c9603414ab2cbef8b61737..87ce5f094caa7ba4f8d448b4f09104d8034c9690 100644 --- a/examples/webgl_gpgpu_water.html +++ b/examples/webgl_gpgpu_water.html @@ -339,12 +339,14 @@ // material: make a ShaderMaterial clone of MeshPhongMaterial, with customized vertex shader var material = new THREE.ShaderMaterial( { - uniforms: THREE.UniformsUtils.merge( [ - THREE.ShaderLib[ 'phong' ].uniforms, + uniforms: Object.assign( + { heightmap: { value: null } - } - ] ), + }, + + THREE.ShaderLib[ 'phong' ].uniforms + ), vertexShader: document.getElementById( 'waterVertexShader' ).textContent, fragmentShader: THREE.ShaderChunk[ 'meshphong_frag' ] diff --git a/examples/webgl_gpu_particle_system.html b/examples/webgl_gpu_particle_system.html index 1e18ffd014f875938a2f7e3c32e68148602ed09f..8c4d0b30282b47c7b2e07845e9b0d4c0b7790bca 100644 --- a/examples/webgl_gpu_particle_system.html +++ b/examples/webgl_gpu_particle_system.html @@ -80,7 +80,7 @@ horizontalSpeed: 1.5, verticalSpeed: 1.33, timeScale: 1 - } + }; gui.add(options, "velocityRandomness", 0, 3); gui.add(options, "positionRandomness", 0, 3); diff --git a/examples/webgl_helpers.html b/examples/webgl_helpers.html index de43e66aaae7dda4a0e5a7502b821b853afbdbbf..6da3424fd70bded54285f25865250fcea6acef4c 100644 --- a/examples/webgl_helpers.html +++ b/examples/webgl_helpers.html @@ -45,9 +45,15 @@ scene.add( new THREE.PointLightHelper( light, 5 ) ); - var helper = new THREE.GridHelper( 200, 40, 0x0000ff, 0x808080 ); - helper.position.y = - 150; - scene.add( helper ); + var gridHelper = new THREE.GridHelper( 200, 40, 0x0000ff, 0x808080 ); + gridHelper.position.y = - 150; + gridHelper.position.x = - 150; + scene.add( gridHelper ); + + var polarGridHelper = new THREE.PolarGridHelper( 200, 16, 8, 64, 0x0000ff, 0x808080 ); + polarGridHelper.position.y = - 150; + polarGridHelper.position.x = 200; + scene.add( polarGridHelper ); var loader = new THREE.JSONLoader(); loader.load( 'obj/leeperrysmith/LeePerrySmith.js', function ( geometry, materials ) { diff --git a/examples/webgl_interactive_instances_gpu.html b/examples/webgl_interactive_instances_gpu.html index 577f57f06046d75dca0818c5cb904a3a1dc5f9ab..4b4ad4f8e0ab45561dec19c3212e808111447f2b 100644 --- a/examples/webgl_interactive_instances_gpu.html +++ b/examples/webgl_interactive_instances_gpu.html @@ -551,7 +551,7 @@ fragmentShader: frag, uniforms: { color: { - value: new THREE.Color(), + value: new THREE.Color() } } } ); @@ -561,7 +561,7 @@ fragmentShader: "#define PICKING\n" + frag, uniforms: { pickingColor: { - value: new THREE.Color(), + value: new THREE.Color() } } } ); @@ -695,13 +695,13 @@ var material = new THREE.RawShaderMaterial( { vertexShader: vert, - fragmentShader: frag, + fragmentShader: frag } ); materialList.push( material ); var pickingMaterial = new THREE.RawShaderMaterial( { vertexShader: "#define PICKING\n" + vert, - fragmentShader: "#define PICKING\n" + frag, + fragmentShader: "#define PICKING\n" + frag } ); materialList.push( pickingMaterial ); @@ -794,7 +794,7 @@ var pickingMaterial = new THREE.RawShaderMaterial( { vertexShader: "#define PICKING\n" + vert, - fragmentShader: "#define PICKING\n" + frag, + fragmentShader: "#define PICKING\n" + frag } ); materialList.push( pickingMaterial ); diff --git a/examples/webgl_interactive_points.html b/examples/webgl_interactive_points.html index b56523d0fc1e952894210eeef2ca29d38df51300..be79a9bb4441ffb97c4aaad744a7371b9a038b05 100644 --- a/examples/webgl_interactive_points.html +++ b/examples/webgl_interactive_points.html @@ -119,7 +119,7 @@ vertex = vertices[ i ]; vertex.toArray( positions, i * 3 ); - color.setHSL( 0.01 + 0.1 * ( i / l ), 1.0, 0.5 ) + color.setHSL( 0.01 + 0.1 * ( i / l ), 1.0, 0.5 ); color.toArray( colors, i * 3 ); sizes[ i ] = PARTICLE_SIZE * 0.5; @@ -142,7 +142,7 @@ vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent, - alphaTest: 0.9, + alphaTest: 0.9 } ); diff --git a/examples/webgl_lights_arealight.html b/examples/webgl_lights_arealight.html index d8d6d9b5f46a62376b47ec21134b86841e14fa29..51dab9054148659e843838c0f528940dc0f0e0de 100644 --- a/examples/webgl_lights_arealight.html +++ b/examples/webgl_lights_arealight.html @@ -61,7 +61,7 @@ var matParams = { specular: 0xFFFFFF, shininess: 10000 - } + }; var matFloor = new THREE.MeshPhongMaterial( matParams ); var matBox = new THREE.MeshPhongMaterial( matParams ); @@ -263,7 +263,7 @@ intensity: rectLight.intensity, width: rectLight.width, height: rectLight.height, - shininess: matFloor.shininess, + shininess: matFloor.shininess // shape: shapeNames[0] }; diff --git a/examples/webgl_lights_physical.html b/examples/webgl_lights_physical.html index 1f4ed40f0bf12eda2a34fc49f05d5d84c6959832..1ac3a16e9b27e65726725bc72bdc365947b8af3b 100644 --- a/examples/webgl_lights_physical.html +++ b/examples/webgl_lights_physical.html @@ -80,7 +80,7 @@ "400 lx (Sunrise/Sunset)": 400, "1000 lx (Overcast)": 1000, "18000 lx (Daylight)": 18000, - "50000 lx (Direct Sun)": 50000, + "50000 lx (Direct Sun)": 50000 }; var params = { @@ -131,7 +131,7 @@ roughness: 0.8, color: 0xffffff, metalness: 0.2, - bumpScale: 0.0005, + bumpScale: 0.0005 }); var textureLoader = new THREE.TextureLoader(); textureLoader.load( "textures/hardwood2_diffuse.jpg", function( map ) { diff --git a/examples/webgl_lights_pointlights.html b/examples/webgl_lights_pointlights.html index 3cc4fb39fafe38c3f5fdd9f1f1cd9c7281d21bb3..810a5d1889843929883a7578a95a1c3d68d3468c 100644 --- a/examples/webgl_lights_pointlights.html +++ b/examples/webgl_lights_pointlights.html @@ -50,7 +50,7 @@ if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var camera, scene, renderer, - particle1, particle2, particle2, + particle1, particle2, light1, light2, light3, light4, object, loader; diff --git a/examples/webgl_lights_pointlights2.html b/examples/webgl_lights_pointlights2.html index e94526c4588493544cdaa6638e3d7ed9227204a2..a724390e936c069f4272cfd7570b11566ba4eedc 100644 --- a/examples/webgl_lights_pointlights2.html +++ b/examples/webgl_lights_pointlights2.html @@ -50,7 +50,7 @@ if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); var camera, scene, renderer, controls, - particle1, particle2, particle4, particle4, particle5, particle6, + particle1, particle2, particle4, particle5, particle6, light1, light2, light3, light4, light5, light6; var FAR = 300; diff --git a/examples/webgl_lines_cubes.html b/examples/webgl_lines_cubes.html index 9103d358c553003d412c9794b5258b43c1790170..876b96ec65a20ce0aaee28b70b9ab584e08e5bcb 100644 --- a/examples/webgl_lines_cubes.html +++ b/examples/webgl_lines_cubes.html @@ -104,7 +104,7 @@ [ m1, scale*0.5, [2*d, 0, 0], g1 ], [ m1, scale*0.5, [-2*d, 0, 0], g1 ], [ m1, scale*0.5, [2*d, d, 0], g1 ], [ m1, scale*0.5, [-2*d, d, 0], g1 ], - [ m1, scale*0.5, [2*d, -d, 0], g1 ], [ m1, scale*0.5, [-2*d, -d, 0], g1 ], + [ m1, scale*0.5, [2*d, -d, 0], g1 ], [ m1, scale*0.5, [-2*d, -d, 0], g1 ] ]; for ( i = 0; i < parameters.length; i ++ ) { diff --git a/examples/webgl_loader_bvh.html b/examples/webgl_loader_bvh.html index 9c6198ab6e61b0bde680393f3c0293b94bef41df..5c1cb4778031ef0ed93593ba46cc7b87d2158d15 100644 --- a/examples/webgl_loader_bvh.html +++ b/examples/webgl_loader_bvh.html @@ -21,7 +21,6 @@ text-align: center; color: #000000; } -} diff --git a/examples/webgl_loader_gltf.html b/examples/webgl_loader_gltf.html index 6b03bd7ed6496b52d85af09315dbf3a19c024cb1..52f7f703ba5a33eb37b266b5837e33d79f29d1c8 100644 --- a/examples/webgl_loader_gltf.html +++ b/examples/webgl_loader_gltf.html @@ -92,7 +92,7 @@
three.js - glTF loader - -

+
monster by 3drt - COLLADA duck by Sony - other models courtesy Cesium
@@ -212,7 +212,7 @@ if (sceneInfo.addGround) { var groundMaterial = new THREE.MeshPhongMaterial({ color: 0xFFFFFF, - shading: THREE.SmoothShading, + shading: THREE.SmoothShading }); ground = new THREE.Mesh( new THREE.PlaneBufferGeometry(512, 512), groundMaterial); diff --git a/examples/webgl_loader_mmd.html b/examples/webgl_loader_mmd.html index 33717a1660e21d5f3b66f242b45647787f2024d0..7d615a09b6c974b8a08a8664d14b809ffe1c2f49 100644 --- a/examples/webgl_loader_mmd.html +++ b/examples/webgl_loader_mmd.html @@ -18,7 +18,6 @@ top: 10px; width: 100%; text-align: center; - z-index: 100; display:block; } #info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } @@ -28,6 +27,7 @@
three.js - MMDLoader test
+ MMD Assets license
Copyright Model Data Dance Data @@ -54,7 +54,7 @@ var container, stats; - var mesh, camera, scene, renderer; + var mesh, camera, scene, renderer, effect; var helper, ikHelper, physicsHelper; var mouseX = 0, mouseY = 0; @@ -79,7 +79,7 @@ scene = new THREE.Scene(); - var gridHelper = new THREE.GridHelper( 100, 100 ) + var gridHelper = new THREE.PolarGridHelper( 30, 10 ); gridHelper.position.y = -10; scene.add( gridHelper ); @@ -98,6 +98,8 @@ renderer.setClearColor( new THREE.Color( 0xffffff ) ); container.appendChild( renderer.domElement ); + effect = new THREE.OutlineEffect( renderer ); + // STATS stats = new Stats(); @@ -118,7 +120,7 @@ var modelFile = 'models/mmd/miku/miku_v2.pmd'; var vmdFiles = [ 'models/mmd/vmds/wavefile_v2.vmd' ]; - helper = new THREE.MMDHelper( renderer ); + helper = new THREE.MMDHelper(); var loader = new THREE.MMDLoader(); @@ -158,6 +160,27 @@ window.addEventListener( 'resize', onWindowResize, false ); + var phongMaterials; + var originalMaterials; + + function makePhongMaterials ( materials ) { + + var array = []; + + for ( var i = 0, il = materials.length; i < il; i ++ ) { + + var m = new THREE.MeshPhongMaterial(); + m.copy( materials[ i ] ); + m.needsUpdate = true; + + array.push( m ); + + } + + phongMaterials = new THREE.MultiMaterial( array ); + + } + function initGui () { var api = { @@ -178,9 +201,16 @@ gui.add( api, 'gradient mapping' ).onChange( function () { - for ( var i = 0, il = mesh.material.materials.length; i < il; i ++ ) { + if ( originalMaterials === undefined ) originalMaterials = mesh.material; + if ( phongMaterials === undefined ) makePhongMaterials( mesh.material.materials ); + + if ( api[ 'gradient mapping' ] ) { + + mesh.material = originalMaterials; + + } else { - var material = mesh.material.materials[ i ].uniforms.celShading.value = api[ 'gradient mapping' ] ? 1 : 0; + mesh.material = phongMaterials; } @@ -191,7 +221,7 @@ } ); gui.add( api, 'outline' ).onChange( function () { - helper.doOutlineDrawing = api[ 'outline' ]; + effect.enabled = api[ 'outline' ]; } ); gui.add( api, 'physics' ).onChange( function () { @@ -218,7 +248,7 @@ camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); - helper.setSize( window.innerWidth, window.innerHeight ); + effect.setSize( window.innerWidth, window.innerHeight ); } @@ -236,18 +266,10 @@ function render() { - if ( mesh ) { - - helper.animate( clock.getDelta() ); - if ( physicsHelper.visible ) physicsHelper.update(); - if ( ikHelper.visible ) ikHelper.update(); - helper.render( scene, camera ); - - } else { - - renderer.render( scene, camera ); - - } + helper.animate( clock.getDelta() ); + if ( physicsHelper !== undefined && physicsHelper.visible ) physicsHelper.update(); + if ( ikHelper !== undefined && ikHelper.visible ) ikHelper.update(); + effect.render( scene, camera ); } diff --git a/examples/webgl_loader_mmd_audio.html b/examples/webgl_loader_mmd_audio.html index d40de4c18f0b53100df05c9243f4b44d68b1b5cf..c3a351e19b98d08000301e96c35185e23e2f89eb 100644 --- a/examples/webgl_loader_mmd_audio.html +++ b/examples/webgl_loader_mmd_audio.html @@ -18,7 +18,6 @@ top: 10px; width: 100%; text-align: center; - z-index: 100; display:block; } #info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } @@ -28,6 +27,7 @@
three.js - MMDLoader test
+ MMD Assets license
Copyright Model Data Dance Data @@ -53,7 +53,7 @@ var container, stats; - var mesh, camera, scene, renderer; + var mesh, camera, scene, renderer, effect; var helper; var ready = false; @@ -79,7 +79,7 @@ scene = new THREE.Scene(); - scene.add( new THREE.GridHelper( 100, 100 ) ); + scene.add( new THREE.PolarGridHelper( 30, 10 ) ); var ambient = new THREE.AmbientLight( 0x666666 ); scene.add( ambient ); @@ -96,6 +96,8 @@ renderer.setClearColor( new THREE.Color( 0xffffff ) ); container.appendChild( renderer.domElement ); + effect = new THREE.OutlineEffect( renderer ); + // model var onProgress = function ( xhr ) { @@ -114,7 +116,7 @@ var audioFile = 'models/mmd/audios/wavefile_short.mp3'; var audioParams = { delayTime: 160 * 1 / 30 }; - helper = new THREE.MMDHelper( renderer ); + helper = new THREE.MMDHelper(); var loader = new THREE.MMDLoader(); @@ -173,7 +175,7 @@ camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); - helper.setSize( window.innerWidth, window.innerHeight ); + effect.setSize( window.innerWidth, window.innerHeight ); } @@ -197,16 +199,12 @@ if ( ready ) { - var delta = clock.getDelta(); - helper.animate( delta ); - helper.render( scene, camera ); - - } else { - - renderer.render( scene, camera ); + helper.animate( clock.getDelta() ); } + effect.render( scene, camera ); + } diff --git a/examples/webgl_loader_mmd_pose.html b/examples/webgl_loader_mmd_pose.html index e43e9391570c12b2ca9de501ca0a412fef1a4cc7..8536d41b776aa32ce763833da634eb80b188654b 100644 --- a/examples/webgl_loader_mmd_pose.html +++ b/examples/webgl_loader_mmd_pose.html @@ -18,7 +18,6 @@ top: 10px; width: 100%; text-align: center; - z-index: 100; display:block; } #info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer } @@ -28,6 +27,7 @@
three.js - MMDLoader test
+ MMD Assets license
Copyright Model Data Pose Data @@ -52,7 +52,7 @@ var container, stats; - var camera, scene, renderer; + var camera, scene, renderer, effect; var helper; var vpds = []; @@ -96,6 +96,8 @@ renderer.setClearColor( new THREE.Color( 0xffffff ) ); container.appendChild( renderer.domElement ); + effect = new THREE.OutlineEffect( renderer ); + // model var onProgress = function ( xhr ) { @@ -123,7 +125,7 @@ 'models/mmd/vpds/11.vpd' ]; - helper = new THREE.MMDHelper( renderer ); + helper = new THREE.MMDHelper(); var loader = new THREE.MMDLoader(); @@ -133,8 +135,6 @@ mesh.position.y = -10; - helper.add( mesh ); - scene.add( mesh ); var vpdIndex = 0; @@ -161,7 +161,7 @@ }, onProgress, onError ); - }; + } loadVpd(); }, onProgress, onError ); @@ -188,7 +188,7 @@ return s.slice( s.lastIndexOf( '/' ) + 1 ); - }; + } function initControls () { @@ -206,7 +206,7 @@ } - }; + } function initKeys () { @@ -216,7 +216,7 @@ } - }; + } function initPoses () { @@ -230,7 +230,7 @@ poses.add( controls, 'pose', files ).onChange( onChangePose ); - }; + } function initMorphs () { @@ -240,7 +240,7 @@ } - }; + } function onChangeMorph () { @@ -252,7 +252,7 @@ } - }; + } function onChangePose () { @@ -268,7 +268,7 @@ } - }; + } initControls(); initKeys(); @@ -294,7 +294,7 @@ camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); - helper.setSize( window.innerWidth, window.innerHeight ); + effect.setSize( window.innerWidth, window.innerHeight ); } @@ -321,15 +321,7 @@ camera.lookAt( scene.position ); */ - if ( ready ) { - - helper.render( scene, camera ); - - } else { - - renderer.render( scene, camera ); - - } + effect.render( scene, camera ); } diff --git a/examples/webgl_loader_pcd.html b/examples/webgl_loader_pcd.html index 1aae3ebb13c5fb45f6bf4827ff3f43fd27f13bce..0777bece441ccedcc90dbd799856e11fdabad95e 100644 --- a/examples/webgl_loader_pcd.html +++ b/examples/webgl_loader_pcd.html @@ -41,8 +41,8 @@ three.js PCD File format
PCD loader test by Filipe Caixeta
-
+/-: Increase/Decrease point size
-
c: Toggle color
+
+/-: Increase/Decrease point size
+
c: Toggle color
diff --git a/examples/webgl_loader_pdb.html b/examples/webgl_loader_pdb.html index 47d510ab3fe930f07e33837b29cafadeb1becabe..08155b697be246d03ecde544a77fe8dc82e80d47 100644 --- a/examples/webgl_loader_pdb.html +++ b/examples/webgl_loader_pdb.html @@ -199,16 +199,28 @@ loader.load( url, function ( geometry, geometryBonds, json ) { - var boxGeometry = new THREE.BoxGeometry( 1, 1, 1 ); - var sphereGeometry = new THREE.IcosahedronGeometry( 1, 2 ); + var boxGeometry = new THREE.BoxBufferGeometry( 1, 1, 1 ); + var sphereGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 ); var offset = geometry.center(); geometryBonds.translate( offset.x, offset.y, offset.z ); - for ( var i = 0; i < geometry.vertices.length; i ++ ) { + var positions = geometry.getAttribute( 'position' ); + var colors = geometry.getAttribute( 'color' ); + + var position = new THREE.Vector3(); + var color = new THREE.Color(); + + for ( var i = 0; i < positions.count; i ++ ) { + + position.x = positions.getX( i ); + position.y = positions.getY( i ); + position.z = positions.getZ( i ); + + color.r = colors.getX( i ); + color.g = colors.getY( i ); + color.b = colors.getZ( i ); - var position = geometry.vertices[ i ]; - var color = geometry.colors[ i ]; var element = geometry.elements[ i ]; var material = new THREE.MeshPhongMaterial( { color: color } ); @@ -232,10 +244,20 @@ } - for ( var i = 0; i < geometryBonds.vertices.length; i += 2 ) { + positions = geometryBonds.getAttribute( 'position' ); + + var start = new THREE.Vector3(); + var end = new THREE.Vector3(); + + for ( var i = 0; i < positions.count; i += 2 ) { + + start.x = positions.getX( i ); + start.y = positions.getY( i ); + start.z = positions.getZ( i ); - var start = geometryBonds.vertices[ i ]; - var end = geometryBonds.vertices[ i + 1 ]; + end.x = positions.getX( i + 1 ); + end.y = positions.getY( i + 1 ); + end.z = positions.getZ( i + 1 ); start.multiplyScalar( 75 ); end.multiplyScalar( 75 ); diff --git a/examples/webgl_loader_sea3d.html b/examples/webgl_loader_sea3d.html index 4bcafd70cfe017ab305d0c8bdb161c237a442fbd..419e8b66f5f868675c1103443ad927f69150d02a 100644 --- a/examples/webgl_loader_sea3d.html +++ b/examples/webgl_loader_sea3d.html @@ -28,7 +28,7 @@
- three.js - asset by sea3d + Three.JS - Exported by SEA3D Exporter and edited by SEA3D Studio. Asset by Valdez Araujo
diff --git a/examples/webgl_loader_sea3d_hierarchy.html b/examples/webgl_loader_sea3d_hierarchy.html index 825f936a6437148ed3140219d027319d6812cc43..c56992e7eccde9a8ac4efd0d24c1a2c945cf4e41 100644 --- a/examples/webgl_loader_sea3d_hierarchy.html +++ b/examples/webgl_loader_sea3d_hierarchy.html @@ -28,7 +28,9 @@
- three.js - asset by sea3d + Three.JS - Exported by SEA3D Exporter and edited by SEA3D Studio. Asset by Valdez Araujo +
+
High geometry compression with Open3DGC and LZMA
@@ -46,6 +48,9 @@ + + + @@ -99,7 +104,8 @@ }; - loader.load( './models/sea3d/robot.tjs.sea' ); + // Open3DGC - Export by SEA3D Studio + loader.load( './models/sea3d/robot.o3dgc.tjs.sea' ); // diff --git a/examples/webgl_loader_sea3d_keyframe.html b/examples/webgl_loader_sea3d_keyframe.html index e3e635fe9755b40e8c8d21dbb89078c91b618f06..a2d1c7d1ebba06dafe68a80e361b1efd1a96cb8b 100644 --- a/examples/webgl_loader_sea3d_keyframe.html +++ b/examples/webgl_loader_sea3d_keyframe.html @@ -28,8 +28,9 @@
- three.js - asset by sea3d -
Click to play
+ Three.JS - Exported by SEA3D Exporter +
+
Click to play
diff --git a/examples/webgl_loader_sea3d_morph.html b/examples/webgl_loader_sea3d_morph.html index 1b714ae1e03969b2a004196e31c8b7f264156729..e1e2bf9cdce81fb79fcbe9402bcb53ff5a96bbaa 100644 --- a/examples/webgl_loader_sea3d_morph.html +++ b/examples/webgl_loader_sea3d_morph.html @@ -28,8 +28,9 @@
- three.js - asset by sea3d -
Flag is Vertex Animation / Teapot is Morpher
+ Three.JS - Exported by SEA3D Exporter +
+
Flag is Vertex Animation / Teapot is Morpher
diff --git a/examples/webgl_loader_sea3d_skinning.html b/examples/webgl_loader_sea3d_skinning.html index 3e454d33337d1be3591fdc00dc4013d0d5d4c3a5..e62cb1e695934cb747bd8698c14ddf62f102d91a 100644 --- a/examples/webgl_loader_sea3d_skinning.html +++ b/examples/webgl_loader_sea3d_skinning.html @@ -28,7 +28,8 @@
- three.js - asset by sea3d + Three.JS - Exported by SEA3D Exporter. Asset by Trivision +

BoneObject: Object3D attached in a Bone
Left Click to hidden/show the hat - Right click to run
@@ -101,7 +102,7 @@ console.log("Animation completed!"); - } + }; window.addEventListener( 'click', onMouseClick, false ); window.addEventListener( 'contextmenu', onRightClick, false ); diff --git a/examples/webgl_loader_sea3d_sound.html b/examples/webgl_loader_sea3d_sound.html index 81eeceaea2a3c2b4217b9f7b0e568c357ceb1270..f480bf762ac87570cf18112faa0e40761b628875 100644 --- a/examples/webgl_loader_sea3d_sound.html +++ b/examples/webgl_loader_sea3d_sound.html @@ -67,7 +67,7 @@
- three.js - asset by sea3d + Three.JS - Exported by SEA3D Exporter and edited by SEA3D Studio
@@ -108,9 +108,6 @@ var camera, scene, renderer, composer, controls, velocity; var blocker, instructions; var moveLeft, moveForward, moveBackward, moveRight; - - initKeyDown - var loader; var audioListener, soundFilter, soundAreaAnalyser, soundOutsideAnalyser; var soundArea, collisionArea, lightArea, lightOutside; @@ -290,7 +287,7 @@ } - }; + } function onKeyUp( event ) { @@ -318,7 +315,7 @@ } - }; + } document.addEventListener( 'keydown', onKeyDown, false ); document.addEventListener( 'keyup', onKeyUp, false ); diff --git a/examples/webgl_marchingcubes.html b/examples/webgl_marchingcubes.html index 0ba4707b558d4803b0f4f8687955be235562ac3d..2686786084de124beb1563ff99d2c07e6aa20d81 100644 --- a/examples/webgl_marchingcubes.html +++ b/examples/webgl_marchingcubes.html @@ -383,7 +383,7 @@ var shader = THREE.ShaderToon[ id ]; - var u = THREE.UniformsUtils.clone( shader.uniforms ); + var u = Object.assign( {}, shader.uniforms ); var vs = shader.vertexShader; var fs = shader.fragmentShader; @@ -421,25 +421,8 @@ m_s.setValue( mat.s ); m_l.setValue( mat.l ); - if ( current_material === "textured" ) { - - effect.enableUvs = true; - - } else { - - effect.enableUvs = false; - - } - - if ( current_material === "colors" ) { - - effect.enableColors = true; - - } else { - - effect.enableColors = false; - - } + effect.enableUvs = (current_material === "textured") ? true : false; + effect.enableColors = (current_material === "colors") ? true : false; }; diff --git a/examples/webgl_materials_bumpmap_skin.html b/examples/webgl_materials_bumpmap_skin.html index af8f9fc8d9cbbccb9d879d4d8c36a6eae2d0b1eb..223cab81e775f2c0bedee7e1d82af748b256f72c 100644 --- a/examples/webgl_materials_bumpmap_skin.html +++ b/examples/webgl_materials_bumpmap_skin.html @@ -211,7 +211,7 @@ var fragmentShader = shader.fragmentShader; var vertexShader = shader.vertexShader; - var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + var uniforms = Object.assign( {}, shader.uniforms ); uniforms[ "enableBump" ].value = true; uniforms[ "enableSpecular" ].value = true; diff --git a/examples/webgl_materials_cars.html b/examples/webgl_materials_cars.html index 0fa4a03bf164a09d0b44df3931560ba8b3a4eb31..1b9f08d7d0771a393bec0b0c8be839b88d515cc7 100644 --- a/examples/webgl_materials_cars.html +++ b/examples/webgl_materials_cars.html @@ -312,7 +312,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; @@ -353,7 +353,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; @@ -413,7 +413,7 @@ [ "Bronze", mlib[ "Bronze" ] ], [ "Chrome", mlib[ "Chrome" ] ] - ], + ] }; diff --git a/examples/webgl_materials_cubemap_balls_reflection.html b/examples/webgl_materials_cubemap_balls_reflection.html index 4026408a67be094a8dbafca0ba684eb9b4c36001..4b4360a5381131fe63120e9af5def0be0a8851fe 100644 --- a/examples/webgl_materials_cubemap_balls_reflection.html +++ b/examples/webgl_materials_cubemap_balls_reflection.html @@ -110,8 +110,8 @@ function onWindowResize() { - windowHalfX = window.innerWidth / 2, - windowHalfY = window.innerHeight / 2, + windowHalfX = window.innerWidth / 2; + windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); diff --git a/examples/webgl_materials_cubemap_balls_refraction.html b/examples/webgl_materials_cubemap_balls_refraction.html index 61606a31ee8186c9a1a87dae13f5a4068f9828bd..8b5e959b4337cfd18704de4c4e83a869adf018dc 100644 --- a/examples/webgl_materials_cubemap_balls_refraction.html +++ b/examples/webgl_materials_cubemap_balls_refraction.html @@ -115,8 +115,8 @@ function onWindowResize() { - windowHalfX = window.innerWidth / 2, - windowHalfY = window.innerHeight / 2, + windowHalfX = window.innerWidth / 2; + windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); diff --git a/examples/webgl_materials_cubemap_dynamic.html b/examples/webgl_materials_cubemap_dynamic.html index 970632091cd7d4959c001a211739e74f0c8c008c..e20c93710ecb02a9c5618894bd98a0ca16b7057b 100644 --- a/examples/webgl_materials_cubemap_dynamic.html +++ b/examples/webgl_materials_cubemap_dynamic.html @@ -319,11 +319,11 @@ var params = { - "a" : { map: flareA, useScreenCoordinates: false, color: 0xffffff, blending: THREE.AdditiveBlending }, - "b" : { map: flareB, useScreenCoordinates: false, color: 0xffffff, blending: THREE.AdditiveBlending }, + "a" : { map: flareA, color: 0xffffff, blending: THREE.AdditiveBlending }, + "b" : { map: flareB, color: 0xffffff, blending: THREE.AdditiveBlending }, - "ar" : { map: flareA, useScreenCoordinates: false, color: 0xff0000, blending: THREE.AdditiveBlending }, - "br" : { map: flareB, useScreenCoordinates: false, color: 0xff0000, blending: THREE.AdditiveBlending } + "ar" : { map: flareA, color: 0xff0000, blending: THREE.AdditiveBlending }, + "br" : { map: flareB, color: 0xff0000, blending: THREE.AdditiveBlending } }; diff --git a/examples/webgl_materials_cubemap_refraction.html b/examples/webgl_materials_cubemap_refraction.html index d7385511077a4ffb7bdf1576f4b92580cfd6fa14..b575d0f3dbc88ebf3173e3210a1a7c9b20a277b5 100644 --- a/examples/webgl_materials_cubemap_refraction.html +++ b/examples/webgl_materials_cubemap_refraction.html @@ -134,8 +134,8 @@ function onWindowResize() { - windowHalfX = window.innerWidth / 2, - windowHalfY = window.innerHeight / 2, + windowHalfX = window.innerWidth / 2; + windowHalfY = window.innerHeight / 2; camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); diff --git a/examples/webgl_materials_displacementmap.html b/examples/webgl_materials_displacementmap.html index 319f2f99cc8dc6360ee23edc1be2e837e1ac7d60..025635eb5bc7319dda8847e08218a09a04e002cb 100644 --- a/examples/webgl_materials_displacementmap.html +++ b/examples/webgl_materials_displacementmap.html @@ -240,9 +240,9 @@ // - var description = "normal + ao" + ( renderer.supportsVertexTextures() ? " + displacement + environment" : " + displacement" ); + var description = "normal + ao" + ( renderer.capabilities.vertexTextures ? " + displacement + environment" : " + displacement" ); document.getElementById( "description" ).innerHTML = description; - document.getElementById( "vt" ).style.display = renderer.supportsVertexTextures() ? "none" : "block"; + document.getElementById( "vt" ).style.display = renderer.capabilities.vertexTextures ? "none" : "block"; // diff --git a/examples/webgl_materials_envmaps_hdr.html b/examples/webgl_materials_envmaps_hdr.html index 3b4baf4b8e919fce602a7ba057067fe45434c6f3..f458e6c0d5eb11356c37378183a63b87da84f40e 100644 --- a/examples/webgl_materials_envmaps_hdr.html +++ b/examples/webgl_materials_envmaps_hdr.html @@ -65,7 +65,7 @@ roughness: 1.0, bumpScale: 0.3, background: false, - exposure: 1.0, + exposure: 1.0 }; var camera, scene, renderer, controls, objects = []; var hdrCubeMap; @@ -99,7 +99,7 @@ shading: THREE.SmoothShading } ); - var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 ); var torusMesh1 = new THREE.Mesh( geometry, standardMaterial ); torusMesh1.position.x = 0.0; torusMesh1.castShadow = true; @@ -193,7 +193,7 @@ var spotLight = new THREE.SpotLight( 0xffffff ); spotLight.position.set( 50, 100, 50 ); spotLight.angle = Math.PI / 7; - spotLight.penumbra = 0.8 + spotLight.penumbra = 0.8; spotLight.castShadow = true; scene.add( spotLight ); diff --git a/examples/webgl_materials_parallaxmap.html b/examples/webgl_materials_parallaxmap.html index 32cae234281b1fbc9d9044e217da48e81435c024..d55f68b02d239181e1ae6a92a9ba72a770957361 100644 --- a/examples/webgl_materials_parallaxmap.html +++ b/examples/webgl_materials_parallaxmap.html @@ -65,7 +65,7 @@ 'mode': 'relief', 'scale': 0.005, 'minLayers': 20, - 'maxLayers': 25, + 'maxLayers': 25 }; init(); @@ -138,7 +138,7 @@ function initScene() { var shader = THREE.ParallaxShader; - var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + var uniforms = Object.assign( {}, shader.uniforms ); var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, diff --git a/examples/webgl_materials_shaders_fresnel.html b/examples/webgl_materials_shaders_fresnel.html index 208468ac0cf321ac36557e3da3b76b77b31bae50..c00b117ea433e1f43518ff1d878d1e6fb2160829 100644 --- a/examples/webgl_materials_shaders_fresnel.html +++ b/examples/webgl_materials_shaders_fresnel.html @@ -92,7 +92,7 @@ var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var shader = THREE.FresnelShader; - var uniforms = THREE.UniformsUtils.clone( shader.uniforms ); + var uniforms = Object.assign( {}, shader.uniforms ); uniforms[ "tCube" ].value = textureCube; diff --git a/examples/webgl_materials_skin.html b/examples/webgl_materials_skin.html index ef8d2f498c9c674070fc493fd8aa1f0a129575c4..47086cf66023ffa12207a0c68ba041ef1da08647 100644 --- a/examples/webgl_materials_skin.html +++ b/examples/webgl_materials_skin.html @@ -115,7 +115,7 @@ var shader = THREE.ShaderSkin[ "skin" ]; - var uniformsUV = THREE.UniformsUtils.clone( shader.uniforms ); + var uniformsUV = Object.assign( {}, shader.uniforms ); var textureLoader = new THREE.TextureLoader(); @@ -133,11 +133,10 @@ uniformsUV[ "uSpecularBrightness" ].value = 0.7; - var uniforms = THREE.UniformsUtils.clone( uniformsUV ); - uniforms[ "tDiffuse" ].value = uniformsUV[ "tDiffuse" ].value; - uniforms[ "tNormal" ].value = uniformsUV[ "tNormal" ].value; - uniforms[ "passID" ].value = 1; - + var uniforms = Object.assign( {}, uniformsUV ); + uniforms[ "tDiffuse" ] = new THREE.Uniform( uniformsUV[ "tDiffuse" ].value ); + uniforms[ "tNormal" ] = new THREE.Uniform( uniformsUV[ "tNormal" ].value ); + uniforms[ "passID" ] = new THREE.Uniform( 1 ); var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true }; var parametersUV = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShaderUV, uniforms: uniformsUV, lights: true }; @@ -236,12 +235,12 @@ // - uniforms[ "tBlur1" ].value = composerScene.renderTarget2.texture; - uniforms[ "tBlur2" ].value = composerUV1.renderTarget2.texture; - uniforms[ "tBlur3" ].value = composerUV2.renderTarget2.texture; - uniforms[ "tBlur4" ].value = composerUV3.renderTarget2.texture; + uniforms[ "tBlur1" ] = new THREE.Uniform( composerScene.renderTarget2.texture ); + uniforms[ "tBlur2" ] = new THREE.Uniform( composerUV1.renderTarget2.texture ); + uniforms[ "tBlur3" ] = new THREE.Uniform( composerUV2.renderTarget2.texture ); + uniforms[ "tBlur4" ] = new THREE.Uniform( composerUV3.renderTarget2.texture ); - uniforms[ "tBeckmann" ].value = composerBeckmann.renderTarget1.texture; + uniforms[ "tBeckmann" ] = new THREE.Uniform( composerBeckmann.renderTarget1.texture ); // diff --git a/examples/webgl_materials_variations_standard.html b/examples/webgl_materials_variations_standard.html index 5a4550821aa8dfdc813eeeb78eb574153c8202dc..e0a27b8a3be6ae0d0350993be93e05e76c66cf46 100644 --- a/examples/webgl_materials_variations_standard.html +++ b/examples/webgl_materials_variations_standard.html @@ -105,7 +105,7 @@ roughness: 1.0 - alpha, shading: THREE.SmoothShading, envMap: alphaIndex % 2 === 0 ? null : reflectionCube - } ) + } ); var mesh = new THREE.Mesh( geometry, material ); diff --git a/examples/webgl_materials_variations_toon.html b/examples/webgl_materials_variations_toon.html new file mode 100644 index 0000000000000000000000000000000000000000..f77780e9589f2f228ff49738e672b2afa7b93e7c --- /dev/null +++ b/examples/webgl_materials_variations_toon.html @@ -0,0 +1,239 @@ + + + + three.js webgl - materials + + + + + + +
+
three.js - Toon Material Variantions w/ OutlineEffect by Ben Houston.
+ + + + + + + + + + + + + diff --git a/examples/webgl_modifier_simplifier.html b/examples/webgl_modifier_simplifier.html index 81928b4adb857309480d49ac42209bdd32d2e0dd..e1fbb20583b436901f6c371e8649891140690337 100644 --- a/examples/webgl_modifier_simplifier.html +++ b/examples/webgl_modifier_simplifier.html @@ -183,4 +183,4 @@ - \ No newline at end of file + diff --git a/examples/webgl_morphtargets_human.html b/examples/webgl_morphtargets_human.html index 34e0a54b4ac5bcba531196326445f6c9e2808be4..5bf37f38a24c4c7c37865026b1e684ec851db4e8 100644 --- a/examples/webgl_morphtargets_human.html +++ b/examples/webgl_morphtargets_human.html @@ -33,7 +33,7 @@
- three.js webgl - morph targets - human + three.js webgl - morph targets - human
diff --git a/examples/webgl_multiple_elements.html b/examples/webgl_multiple_elements.html index f9b1b46a4ab90504b8d7ddb140656a4986047f05..2a568f787257b7e66d7d90f56863cacf43cb491f 100644 --- a/examples/webgl_multiple_elements.html +++ b/examples/webgl_multiple_elements.html @@ -101,7 +101,7 @@ new THREE.BoxGeometry( 1, 1, 1 ), new THREE.SphereGeometry( 0.5, 12, 8 ), new THREE.DodecahedronGeometry( 0.5 ), - new THREE.CylinderGeometry( 0.5, 0.5, 1, 12 ), + new THREE.CylinderGeometry( 0.5, 0.5, 1, 12 ) ]; var template = document.getElementById( "template" ).text; diff --git a/examples/webgl_multiple_elements_text.html b/examples/webgl_multiple_elements_text.html index 08678bbf329bfcbc2a60955e4ea2b4533705e765..1ae3fd5281ac93cbc6649ab69c4a0299b015c359 100644 --- a/examples/webgl_multiple_elements_text.html +++ b/examples/webgl_multiple_elements_text.html @@ -426,7 +426,7 @@ sin(kr ± ωt) - r + r @@ -434,8 +434,6 @@
- -

Here is a cylindrical wave moving on a three-dimensional lattice of atoms:

@@ -461,7 +459,7 @@ } - } + }; parent.lattice = true; @@ -492,7 +490,7 @@ } - } + }; parent.lattice = false; @@ -598,7 +596,7 @@ } - } + }; parent.lattice = true; @@ -629,7 +627,7 @@ return new THREE.Vector3( 3 * Math.cos( phi ) * Math.sin( theta ) * Math.sin( r - t ) / r , 3 * Math.sin( phi ) * Math.sin( theta ) * Math.sin( r - t ) / r , 3 * Math.cos( theta ) * Math.sin( r - t ) / r ); } - } + }; parent.lattice = false; diff --git a/examples/webgl_nearestneighbour.html b/examples/webgl_nearestneighbour.html index 70bf95617e365012b59679cafbb515bf02db26de..fed15329073cb92b8fe371ca292f1e5dcf5c64b0 100644 --- a/examples/webgl_nearestneighbour.html +++ b/examples/webgl_nearestneighbour.html @@ -128,7 +128,7 @@ pointShaderMaterial = new THREE.ShaderMaterial( { uniforms: { tex1: { value: imagePreviewTexture }, - zoom: { value: 9.0 }, + zoom: { value: 9.0 } }, vertexShader: document.getElementById( 'vertexshader' ).textContent, fragmentShader: document.getElementById( 'fragmentshader' ).textContent, diff --git a/examples/webgl_physics_cloth.html b/examples/webgl_physics_cloth.html index 38b40429b38c76668266ef271e5f75136ef98679..247aa769fc8a4e55c62b5b2b3bd8c918752308ea 100644 --- a/examples/webgl_physics_cloth.html +++ b/examples/webgl_physics_cloth.html @@ -239,8 +239,8 @@ //var clothGeometry = new THREE.BufferGeometry(); var clothGeometry = new THREE.PlaneBufferGeometry( clothWidth, clothHeight, clothNumSegmentsZ, clothNumSegmentsY ); - clothGeometry.rotateY( Math.PI * 0.5 ) - clothGeometry.translate( clothPos.x, clothPos.y + clothHeight * 0.5, clothPos.z - clothWidth * 0.5 ) + clothGeometry.rotateY( Math.PI * 0.5 ); + clothGeometry.translate( clothPos.x, clothPos.y + clothHeight * 0.5, clothPos.z - clothWidth * 0.5 ); //var clothMaterial = new THREE.MeshLambertMaterial( { color: 0x0030A0, side: THREE.DoubleSide } ); var clothMaterial = new THREE.MeshLambertMaterial( { color: 0xFFFFFF, side: THREE.DoubleSide } ); cloth = new THREE.Mesh( clothGeometry, clothMaterial ); @@ -266,7 +266,7 @@ sbConfig.set_viterations( 10 ); sbConfig.set_piterations( 10 ); - clothSoftBody.setTotalMass( 0.9, false ) + clothSoftBody.setTotalMass( 0.9, false ); Ammo.castObject( clothSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin * 3 ); physicsWorld.addSoftBody( clothSoftBody, 1, -1 ); cloth.userData.physicsBody = clothSoftBody; diff --git a/examples/webgl_physics_rope.html b/examples/webgl_physics_rope.html index fdbc41e2bae8bf7f16002a6ff0fc4cd2fc1ba1d8..13b0eb61eb748f0226cc8e4b6ee66ddb69cb42c3 100644 --- a/examples/webgl_physics_rope.html +++ b/examples/webgl_physics_rope.html @@ -60,6 +60,7 @@ var dispatcher; var broadphase; var solver; + var softBodySolver; var physicsWorld; var rigidBodies = []; var margin = 0.05; @@ -281,7 +282,7 @@ var sbConfig = ropeSoftBody.get_m_cfg(); sbConfig.set_viterations( 10 ); sbConfig.set_piterations( 10 ); - ropeSoftBody.setTotalMass( ropeMass, false ) + ropeSoftBody.setTotalMass( ropeMass, false ); Ammo.castObject( ropeSoftBody, Ammo.btCollisionObject ).getCollisionShape().setMargin( margin * 3 ); physicsWorld.addSoftBody( ropeSoftBody, 1, -1 ); rope.userData.physicsBody = ropeSoftBody; diff --git a/examples/webgl_postprocessing_backgrounds.html b/examples/webgl_postprocessing_backgrounds.html index af907f5cb95be11c3480de0ba5c8e216e6bb54e8..7294752b3594a16420de05986c9caa0390382cd5 100644 --- a/examples/webgl_postprocessing_backgrounds.html +++ b/examples/webgl_postprocessing_backgrounds.html @@ -30,7 +30,8 @@
- three.js - Backgrounds: ClearPass, TexturePass and CubeTexturePass by Ben Houston
+ three.js - Backgrounds: ClearPass, TexturePass and CubeTexturePass by Ben Houston +
@@ -69,7 +70,7 @@ cubeTexturePass: true, cubeTexturePassOpacity: 1.0, - renderPass: true, + renderPass: true //autoRotate: true, @@ -279,6 +280,5 @@ } -
diff --git a/examples/webgl_postprocessing_dof2.html b/examples/webgl_postprocessing_dof2.html index b1ab4e124f04e09dd482f286dcf68ab35392a968..b8d181002f42e6e3d1b23230ace20a31261486db 100644 --- a/examples/webgl_postprocessing_dof2.html +++ b/examples/webgl_postprocessing_dof2.html @@ -402,7 +402,7 @@ Use WEBGL Depth buffer support? var bokeh_shader = THREE.BokehShader; - postprocessing.bokeh_uniforms = THREE.UniformsUtils.clone( bokeh_shader.uniforms ); + postprocessing.bokeh_uniforms = Object.assign( {}, bokeh_shader.uniforms ); postprocessing.bokeh_uniforms[ "tColor" ].value = postprocessing.rtTextureColor.texture; postprocessing.bokeh_uniforms[ "tDepth" ].value = postprocessing.rtTextureDepth.texture; diff --git a/examples/webgl_postprocessing_godrays.html b/examples/webgl_postprocessing_godrays.html index 1095554be4bd845e6ed3fc51e3e3c9e0e4e28c55..0a57eac17c86ead76fe736e75c92e4bf3b84195a 100644 --- a/examples/webgl_postprocessing_godrays.html +++ b/examples/webgl_postprocessing_godrays.html @@ -203,7 +203,7 @@ // god-ray shaders var godraysGenShader = THREE.ShaderGodRays[ "godrays_generate" ]; - postprocessing.godrayGenUniforms = THREE.UniformsUtils.clone( godraysGenShader.uniforms ); + postprocessing.godrayGenUniforms = Object.assign( {}, godraysGenShader.uniforms ); postprocessing.materialGodraysGenerate = new THREE.ShaderMaterial( { uniforms: postprocessing.godrayGenUniforms, @@ -213,7 +213,7 @@ } ); var godraysCombineShader = THREE.ShaderGodRays[ "godrays_combine" ]; - postprocessing.godrayCombineUniforms = THREE.UniformsUtils.clone( godraysCombineShader.uniforms ); + postprocessing.godrayCombineUniforms = Object.assign( {}, godraysCombineShader.uniforms ); postprocessing.materialGodraysCombine = new THREE.ShaderMaterial( { uniforms: postprocessing.godrayCombineUniforms, @@ -223,7 +223,7 @@ } ); var godraysFakeSunShader = THREE.ShaderGodRays[ "godrays_fake_sun" ]; - postprocessing.godraysFakeSunUniforms = THREE.UniformsUtils.clone( godraysFakeSunShader.uniforms ); + postprocessing.godraysFakeSunUniforms = Object.assign( {}, godraysFakeSunShader.uniforms ); postprocessing.materialGodraysFakeSun = new THREE.ShaderMaterial( { uniforms: postprocessing.godraysFakeSunUniforms, diff --git a/examples/webgl_postprocessing_msaa.html b/examples/webgl_postprocessing_msaa.html index 5a886f000e24e6e62385da6b6b1caf6c9ff92523..90df5a064e468a83e87bfd7721b89d29c50e56d4 100644 --- a/examples/webgl_postprocessing_msaa.html +++ b/examples/webgl_postprocessing_msaa.html @@ -177,6 +177,5 @@ } -
diff --git a/examples/webgl_postprocessing_msaa_unbiased.html b/examples/webgl_postprocessing_msaa_unbiased.html index 3ad8deaedf9c03057dc5afcdc756bd6d8e01fa6a..db3353506a87c0e5c0f888d368951995304036b9 100644 --- a/examples/webgl_postprocessing_msaa_unbiased.html +++ b/examples/webgl_postprocessing_msaa_unbiased.html @@ -258,6 +258,5 @@ } -
diff --git a/examples/webgl_postprocessing_outline.html b/examples/webgl_postprocessing_outline.html index 70500aa6222fa790f4b3f3a3b19e51535c05afb6..708cf8bd503abecaf43a7ca048657ec41104724b 100644 --- a/examples/webgl_postprocessing_outline.html +++ b/examples/webgl_postprocessing_outline.html @@ -79,71 +79,71 @@ pulsePeriod: 0, rotate: false, usePatternTexture: false - } + }; // Init gui var gui = new dat.GUI(); - gui.add( params, "edgeStrength", 0.01, 10 ).onChange( function(value) { - outlinePass.edgeStrength = Number(value); - }); - gui.add( params, "edgeGlow", 0.0, 1 ).onChange( function(value) { - outlinePass.edgeGlow = Number(value); - }) - gui.add( params, "edgeThickness", 1, 4 ).onChange( function(value) { - outlinePass.edgeThickness = Number(value); - }) - gui.add( params, "pulsePeriod", 0.0, 5 ).onChange( function(value) { - outlinePass.pulsePeriod = Number(value); - }) - gui.add( params, "rotate" ) - gui.add( params, "usePatternTexture" ).onChange( function(value) { + gui.add(params, "edgeStrength", 0.01, 10).onChange(function( value ) { + outlinePass.edgeStrength = Number(value); + }); + gui.add(params, "edgeGlow", 0.0, 1).onChange(function( value ) { + outlinePass.edgeGlow = Number(value); + }); + gui.add(params, "edgeThickness", 1, 4).onChange(function( value ) { + outlinePass.edgeThickness = Number(value); + }); + gui.add(params, "pulsePeriod", 0.0, 5).onChange(function( value ) { + outlinePass.pulsePeriod = Number(value); + }); + gui.add(params, "rotate"); + gui.add(params, "usePatternTexture").onChange(function( value ) { outlinePass.usePatternTexture = value; - }) - var Configuration=function(){ - this.visibleEdgeColor = "#ffffff"; - this.hiddenEdgeColor = "#190a05"; - }; - var conf = new Configuration(); - - var controladorVisible = gui.addColor( conf, 'visibleEdgeColor'); - var controladorHidden = gui.addColor( conf, 'hiddenEdgeColor'); - controladorVisible.onChange( function( colorValue ) - { - //the return value by the chooser is like as: #ffff - colorValue=colorValue.replace( '#','' ); - function hexToRgb(hex) { - var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); - return result ? { - r: parseInt(result[1], 16), - g: parseInt(result[2], 16), - b: parseInt(result[3], 16) - } : null; - } - var rgba = hexToRgb(colorValue); - var color = outlinePass.visibleEdgeColor; - color.r = rgba.r/255; - color.g = rgba.g/255; - color.b = rgba.b/255; - }); - - controladorHidden.onChange( function( colorValue ) - { - //the return value by the chooser is like as: #ffff - colorValue=colorValue.replace( '#','' ); - function hexToRgb(hex) { - var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); - return result ? { - r: parseInt(result[1], 16), - g: parseInt(result[2], 16), - b: parseInt(result[3], 16) - } : null; - } - var rgba = hexToRgb(colorValue); - var color = outlinePass.hiddenEdgeColor; - color.r = rgba.r/255; - color.g = rgba.g/255; - color.b = rgba.b/255; - }); + }); + var Configuration = function() { + this.visibleEdgeColor = "#ffffff"; + this.hiddenEdgeColor = "#190a05"; + }; + var conf = new Configuration(); + + var controladorVisible = gui.addColor( conf, 'visibleEdgeColor'); + var controladorHidden = gui.addColor( conf, 'hiddenEdgeColor'); + controladorVisible.onChange(function( colorValue ) { + //the return value by the chooser is like as: #ffff + colorValue = colorValue.replace('#', ''); + function hexToRgb( hex ) { + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + return result ? { + r: parseInt(result[ 1 ], 16), + g: parseInt(result[ 2 ], 16), + b: parseInt(result[ 3 ], 16) + } : null; + } + + var rgba = hexToRgb(colorValue); + var color = outlinePass.visibleEdgeColor; + color.r = rgba.r / 255; + color.g = rgba.g / 255; + color.b = rgba.b / 255; + }); + + controladorHidden.onChange(function( colorValue ) { + //the return value by the chooser is like as: #ffff + colorValue = colorValue.replace('#', ''); + function hexToRgb( hex ) { + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex); + return result ? { + r: parseInt(result[ 1 ], 16), + g: parseInt(result[ 2 ], 16), + b: parseInt(result[ 3 ], 16) + } : null; + } + + var rgba = hexToRgb(colorValue); + var color = outlinePass.hiddenEdgeColor; + color.r = rgba.r / 255; + color.g = rgba.g / 255; + color.b = rgba.b / 255; + }); init(); animate(); @@ -307,8 +307,8 @@ ); effectFXAA = new THREE.ShaderPass(THREE.FXAAShader); - effectFXAA.uniforms['resolution'].value.set(1 / window.innerWidth, 1 / window.innerHeight ); - effectFXAA.renderToScreen = true; + effectFXAA.uniforms['resolution'].value.set(1 / window.innerWidth, 1 / window.innerHeight ); + effectFXAA.renderToScreen = true; composer.addPass( effectFXAA ); window.addEventListener( 'resize', onWindowResize, false ); @@ -387,7 +387,7 @@ camera.updateProjectionMatrix(); renderer.setSize( width, height ); - composer.setSize( width, height ); + composer.setSize( width, height ); effectFXAA.uniforms['resolution'].value.set(1 / window.innerWidth, 1 / window.innerHeight ); } diff --git a/examples/webgl_postprocessing_procedural.html b/examples/webgl_postprocessing_procedural.html index 9a1ff981418267fd93e2299c31dc292ee9c908a6..66977852da8e1fe5762463e93bd7d10e8a399d31 100644 --- a/examples/webgl_postprocessing_procedural.html +++ b/examples/webgl_postprocessing_procedural.html @@ -117,15 +117,15 @@ postCamera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1); noiseRandom1DMaterial = new THREE.ShaderMaterial({ vertexShader: document.querySelector('#procedural-vert').textContent.trim(), - fragmentShader: document.querySelector('#noiseRandom1D-frag').textContent.trim(), + fragmentShader: document.querySelector('#noiseRandom1D-frag').textContent.trim() }); noiseRandom2DMaterial = new THREE.ShaderMaterial({ vertexShader: document.querySelector('#procedural-vert').textContent.trim(), - fragmentShader: document.querySelector('#noiseRandom2D-frag').textContent.trim(), + fragmentShader: document.querySelector('#noiseRandom2D-frag').textContent.trim() }); noiseRandom3DMaterial = new THREE.ShaderMaterial({ vertexShader: document.querySelector('#procedural-vert').textContent.trim(), - fragmentShader: document.querySelector('#noiseRandom3D-frag').textContent.trim(), + fragmentShader: document.querySelector('#noiseRandom3D-frag').textContent.trim() }); postMaterial = noiseRandom3DMaterial; var postPlane = new THREE.PlaneGeometry(2, 2); @@ -177,6 +177,5 @@ } -
diff --git a/examples/webgl_postprocessing_taa.html b/examples/webgl_postprocessing_taa.html index 55ad07a8c19273031083ca52bc9e7697957ad290..f2c6fc2e65ab0c5ad70439c587f6a7a8fd98a676 100644 --- a/examples/webgl_postprocessing_taa.html +++ b/examples/webgl_postprocessing_taa.html @@ -208,6 +208,5 @@ } -
diff --git a/examples/webgl_postprocessing_unreal_bloom.html b/examples/webgl_postprocessing_unreal_bloom.html index 36d06cdc44d5eef4d7c2f8d6f2d2e3d923d359fa..02ff0be7cc0bad3928f0457f14e0505531a34736 100644 --- a/examples/webgl_postprocessing_unreal_bloom.html +++ b/examples/webgl_postprocessing_unreal_bloom.html @@ -108,7 +108,7 @@ shading: THREE.SmoothShading } ); - var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 ); var torusMesh1 = new THREE.Mesh( geometry, standardMaterial ); torusMesh1.position.x = 0.0; torusMesh1.castShadow = true; @@ -154,7 +154,7 @@ var spotLight = new THREE.SpotLight( 0xffffff ); spotLight.position.set( 50, 100, 50 ); spotLight.angle = Math.PI / 7; - spotLight.penumbra = 0.8 + spotLight.penumbra = 0.8; spotLight.castShadow = true; scene.add( spotLight ); diff --git a/examples/webgl_raycast_texture.html b/examples/webgl_raycast_texture.html index c09ce016b588b96c3319742ce42f5d7c2c7a89d0..2e0fdd7810c851b7344bf761bdce9a506c6e01bd 100644 --- a/examples/webgl_raycast_texture.html +++ b/examples/webgl_raycast_texture.html @@ -103,7 +103,7 @@ this._draw(); - } + }; CanvasTexture.prototype = { @@ -146,7 +146,7 @@ if ( ! this._context2D ) return; - this._context2D.clearRect( 0, 0, this._canvas.width, this._canvas.height ) + this._context2D.clearRect( 0, 0, this._canvas.width, this._canvas.height ); // Background. this._context2D.drawImage( this._background, 0, 0 ); @@ -290,7 +290,7 @@ renderer.setSize( window.innerWidth, window.innerHeight ); - }; + } function onMouseMove( evt ) { @@ -309,7 +309,7 @@ } - }; + } var getMousePosition = function ( dom, x, y ) { @@ -333,45 +333,45 @@ requestAnimationFrame( render ); renderer.render( scene, camera ); - }; + } function setwrapS( that ) { circleTexture.wrapS = THREE[ that.value ]; circleTexture.needsUpdate = true; - }; + } function setwrapT( that ) { circleTexture.wrapT = THREE[ that.value ]; circleTexture.needsUpdate = true; - }; + } function setOffsetU( that ) { circleTexture.offset.x = parseFloat( that.value ); - }; + } function setOffsetV( that ) { circleTexture.offset.y = parseFloat( that.value ); - }; + } function setRepeatU( that ) { circleTexture.repeat.x = parseFloat( that.value ); - }; + } function setRepeatV( that ) { circleTexture.repeat.y = parseFloat( that.value ); - }; + } diff --git a/examples/webgl_raymarching_reflect.html b/examples/webgl_raymarching_reflect.html index 1cae109e0582d7f507e63749a44fa60d87910b46..63ef1a94162edf27937a61a7bf87ea1a5c43503e 100644 --- a/examples/webgl_raymarching_reflect.html +++ b/examples/webgl_raymarching_reflect.html @@ -266,7 +266,7 @@ }, freeCamera: false, - resolution: '512', + resolution: '512' }; init(); @@ -284,7 +284,7 @@ uniforms: { resolution: { value: new THREE.Vector2( 512, 512 ) }, cameraPos: { value: camera.getWorldPosition() }, - cameraDir: { value: camera.getWorldDirection() }, + cameraDir: { value: camera.getWorldDirection() } }, vertexShader: document.getElementById( 'vertex_shader' ).textContent, fragmentShader: document.getElementById( 'fragment_shader' ).textContent diff --git a/examples/webgl_shaders_ocean.html b/examples/webgl_shaders_ocean.html index 4f6145f5951848b0785bff1c57e9dfac72ca77c5..ca922bb9686ec800887997201e29b422636c2ab3 100644 --- a/examples/webgl_shaders_ocean.html +++ b/examples/webgl_shaders_ocean.html @@ -108,7 +108,7 @@ sunDirection: light.position.clone().normalize(), sunColor: 0xffffff, waterColor: 0x001e0f, - distortionScale: 50.0, + distortionScale: 50.0 } ); diff --git a/examples/webgl_shaders_sky.html b/examples/webgl_shaders_sky.html index dcdfcf99b8d1a076ce3ca769ebd4ac2371cde275..4658604b7973e6beb6535c433497de665f4388fe 100644 --- a/examples/webgl_shaders_sky.html +++ b/examples/webgl_shaders_sky.html @@ -16,7 +16,6 @@ background-color: #fff; margin: 0px; overflow: hidden; - text } #info { diff --git a/examples/webgl_shaders_tonemapping.html b/examples/webgl_shaders_tonemapping.html index 14c17577ae0bb9e13459e4809cbd28351e6492d5..5e3046dc6e5c7602736612615dca8afc5e276308 100644 --- a/examples/webgl_shaders_tonemapping.html +++ b/examples/webgl_shaders_tonemapping.html @@ -94,7 +94,7 @@ middleGrey: 0.04, maxLuminance: 16, - adaptionRate: 2.0, + adaptionRate: 2.0 }; container = document.createElement( 'div' ); @@ -135,12 +135,12 @@ // blending: THREE.AdditiveBlending, transparent: true, lights: true, - uniforms: THREE.UniformsUtils.merge( [ + uniforms: Object.assign( {}, THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "lights" ] - ] ), + ), vertexShader: [ "varying vec3 vViewPosition;", "varying vec3 vNormal;", @@ -190,7 +190,7 @@ "}" - ].join("\n"), + ].join("\n") }; var earthAtmoMat = new THREE.ShaderMaterial( atmoShader ); @@ -298,7 +298,7 @@ }, vertexShader: vBGShader, fragmentShader: pBGShader, - depthTest: false, + depthTest: false // color: 0xffffff // blending: THREE.NoBlending } ); diff --git a/examples/webgl_shaders_vector.html b/examples/webgl_shaders_vector.html index a59434bfa00976d10978cded704e6d282192a20a..a75cc5148b33ac3617f48bd0482d4d3f809602c8 100644 --- a/examples/webgl_shaders_vector.html +++ b/examples/webgl_shaders_vector.html @@ -125,9 +125,9 @@ wireframe: true } ); - textShapes = font.generateShapes( theText, 180, 2 ); + var textShapes = font.generateShapes( theText, 180, 2 ); - text3d = new THREE.ShapeGeometry( textShapes ); + var text3d = new THREE.ShapeGeometry( textShapes ); text3d.computeBoundingBox(); var centerOffset = -0.5 * ( text3d.boundingBox.max.x - text3d.boundingBox.min.x ); @@ -138,9 +138,9 @@ // - vA = new THREE.Vector2(); - vB = new THREE.Vector2(); - vDot = new THREE.Vector2(); + var vA = new THREE.Vector2(); + var vB = new THREE.Vector2(); + var vDot = new THREE.Vector2(); function processShape(path, reverse) { @@ -196,16 +196,21 @@ }; } + var pts, pts2; var subshape; + var convexhullShape; + var solidShape; var convexhullShapeGroup = []; var solidShapeGroup = []; var beziers = [], invert = []; + var process; + var hole; for (var s=0;s
- three.js - shadowmap - models by mirada from rome
- move camera with WASD / RF + mouse
- t: toggle HUD + three.js - shadowmap - models by mirada from rome
+ move camera with WASD / RF + mouse
+ t: toggle HUD
diff --git a/examples/webgl_shadowmap_performance.html b/examples/webgl_shadowmap_performance.html index 946fbc8f449efb4dabc036e35b7e9abd694a4a97..efcd9ab23bcded6a960c82850183a016b5f41fba 100644 --- a/examples/webgl_shadowmap_performance.html +++ b/examples/webgl_shadowmap_performance.html @@ -27,7 +27,7 @@
- three.js - shadowmap - models by mirada from rome
+ three.js - shadowmap - models by mirada from rome
move camera with WASD / RF + mouse
diff --git a/examples/webgl_shadowmap_pointlight.html b/examples/webgl_shadowmap_pointlight.html index 9e68a3496288a4245447714fcf8bb777339824c2..a56139956744305bfa3f91e192a45a2f1b52e4d7 100644 --- a/examples/webgl_shadowmap_pointlight.html +++ b/examples/webgl_shadowmap_pointlight.html @@ -95,7 +95,7 @@ shininess: 10, specular: 0x111111, side: THREE.BackSide - } ) + } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = 10; mesh.receiveShadow = true; diff --git a/examples/webgl_terrain_dynamic.html b/examples/webgl_terrain_dynamic.html index d83978ce22bf1038db95a79f918cc7abb13f71c7..d06e3e19a75ae8292f2ea039197683895abedec2 100644 --- a/examples/webgl_terrain_dynamic.html +++ b/examples/webgl_terrain_dynamic.html @@ -214,7 +214,7 @@ var camera, scene; var cameraOrtho, sceneRenderTarget; - var uniformsNoise, uniformsNormal, + var uniformsNoise, uniformsNormal, uniformsTerrain, heightMap, normalMap, quadTarget; @@ -304,7 +304,7 @@ }; - uniformsNormal = THREE.UniformsUtils.clone( normalShader.uniforms ); + uniformsNormal = Object.assign( {}, normalShader.uniforms ); uniformsNormal.height.value = 0.05; uniformsNormal.resolution.value.set( rx, ry ); @@ -335,7 +335,7 @@ var terrainShader = THREE.ShaderTerrain[ "terrain" ]; - uniformsTerrain = THREE.UniformsUtils.clone( terrainShader.uniforms ); + uniformsTerrain = Object.assign( {}, terrainShader.uniforms ); uniformsTerrain[ 'tNormal' ].value = normalMap.texture; uniformsTerrain[ 'uNormalScale' ].value = 3.5; diff --git a/examples/webgl_tonemapping.html b/examples/webgl_tonemapping.html index 28bdd70f46a8ba071b74ba8a49f14b83b6fe8f87..d8c14b1cfe52856dcbb65c8297defc54c441cbf9 100644 --- a/examples/webgl_tonemapping.html +++ b/examples/webgl_tonemapping.html @@ -132,7 +132,7 @@ group = new THREE.Group(); scene.add( group ); - var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 18, 8, 150, 20 ); var mesh = new THREE.Mesh( geometry, standardMaterial ); mesh.castShadow = true; mesh.receiveShadow = true; diff --git a/examples/webgl_video_panorama_equirectangular.html b/examples/webgl_video_panorama_equirectangular.html index bdb75459dcb9a443979919c7b2356c434ae6b91a..c524b5352aa56ff02007ab69eff6a33036a8cacd 100644 --- a/examples/webgl_video_panorama_equirectangular.html +++ b/examples/webgl_video_panorama_equirectangular.html @@ -43,7 +43,11 @@ lon = 0, onMouseDownLon = 0, lat = 0, onMouseDownLat = 0, phi = 0, theta = 0, - distance = 500; + distance = 500, + onPointerDownPointerX = 0, + onPointerDownPointerY = 0, + onPointerDownLon = 0, + onPointerDownLat = 0; init(); animate(); diff --git a/examples/webgldeferred_animation.html b/examples/webgldeferred_animation.html index c5f6628e5b614cc05de22a31bc6b430056fba27b..0d6b829978ab750d8f0a1cd9a9bcb2e77b692422 100644 --- a/examples/webgldeferred_animation.html +++ b/examples/webgldeferred_animation.html @@ -178,7 +178,7 @@ room.position.y = size / 2 - 30; // top - mesh = new THREE.Mesh( geometry, material ); + var mesh = new THREE.Mesh( geometry, material ); mesh.rotation.x = Math.PI/2; mesh.position.y = size / 2; room.add( mesh ); @@ -291,4 +291,4 @@ - \ No newline at end of file + diff --git a/examples/webvr_rollercoaster.html b/examples/webvr_rollercoaster.html index 983a38e710f08dd0f4652ddcc68b5b5e437ef629..9cd7a8e730d31644f92b43e5c19726bd77e30dee 100644 --- a/examples/webvr_rollercoaster.html +++ b/examples/webvr_rollercoaster.html @@ -241,7 +241,7 @@ effect.render( scene, camera ); - }; + } effect.requestAnimationFrame( animate ); diff --git a/examples/webvr_shadow.html b/examples/webvr_shadow.html index 6bfc1a952c5f0b3ffbb28c2b03009ef9fcd2f30f..0b6047e58e76990906b7c1860df49feccf079b84 100644 --- a/examples/webvr_shadow.html +++ b/examples/webvr_shadow.html @@ -47,7 +47,7 @@ camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 10 ); dummy.add( camera ); - var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 );; + var geometry = new THREE.TorusKnotGeometry( 0.4, 0.15, 150, 20 ); var material = new THREE.MeshStandardMaterial( { roughness: 0.01, metalness: 0.2 } ); var mesh = new THREE.Mesh( geometry, material ); mesh.position.y = 0.75; diff --git a/examples/webvr_vive.html b/examples/webvr_vive.html old mode 100755 new mode 100644 diff --git a/package.json b/package.json index 1ce01e6c2129f022297aba9f801966105b74f3d3..59e9892ea943fc4a2841a7a2847188e4d14a15a2 100644 --- a/package.json +++ b/package.json @@ -22,11 +22,15 @@ "example": "examples", "test": "test" }, + "eslintConfig": { + "extends": "mdcs" + }, "scripts": { "build": "rollup -c", "build-uglify": "rollup -c && uglifyjs build/three.js -cm --preamble \"// threejs.org/license\" > build/three.min.js", "build-closure": "rollup -c && java -jar utils/build/compiler/closure-compiler-v20160713.jar --warning_level=VERBOSE --jscomp_off=globalThis --jscomp_off=checkTypes --externs utils/build/externs.js --language_in=ECMASCRIPT5_STRICT --js build/three.js --js_output_file build/three.min.js", "dev": "rollup -c -w", + "lint": "eslint src", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ @@ -42,8 +46,8 @@ }, "homepage": "http://threejs.org/", "devDependencies": { - "argparse": "^1.0.3", - "jscs": "^1.13.1", + "eslint": "^3.10.1", + "eslint-config-mdcs": "^4.2.2", "rollup": "^0.36.3", "rollup-watch": "^2.5.0", "uglify-js": "^2.6.0" diff --git a/src/Three.Legacy.js b/src/Three.Legacy.js index aca2136ec0393c3a8c6b80943ead9a5d9f75cf3a..f121aca8a36286f7e27b8b68addc4c9216450bc5 100644 --- a/src/Three.Legacy.js +++ b/src/Three.Legacy.js @@ -25,6 +25,7 @@ import { Geometry } from './core/Geometry'; import { Object3D } from './core/Object3D.js'; import { Uniform } from './core/Uniform'; import { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js'; +import { BoxHelper } from './extras/helpers/BoxHelper'; import { GridHelper } from './extras/helpers/GridHelper.js'; import { BoxGeometry } from './geometries/BoxGeometry.js'; import { EdgesGeometry } from './geometries/EdgesGeometry.js'; @@ -64,106 +65,150 @@ import { Shape } from './extras/core/Shape.js'; export { BoxGeometry as CubeGeometry }; -export function Face4 ( a, b, c, d, normal, color, materialIndex ) { +export function Face4( a, b, c, d, normal, color, materialIndex ) { + console.warn( 'THREE.Face4 has been removed. A THREE.Face3 will be created instead.' ); return new Face3( a, b, c, normal, color, materialIndex ); + } export var LineStrip = 0; export var LinePieces = 1; -export { MultiMaterial as MeshFaceMaterial }; +export function MeshFaceMaterial( materials ) { + + console.warn( 'THREE.MeshFaceMaterial has been renamed to THREE.MultiMaterial.' ); + return new MultiMaterial( materials ); + +} + +export function PointCloud( geometry, material ) { -export function PointCloud ( geometry, material ) { console.warn( 'THREE.PointCloud has been renamed to THREE.Points.' ); return new Points( geometry, material ); + +} + +export function Particle( material ) { + + console.warn( 'THREE.Particle has been renamed to THREE.Sprite.' ); + return new Sprite( material ); + } -export { Sprite as Particle }; +export function ParticleSystem( geometry, material ) { -export function ParticleSystem ( geometry, material ) { console.warn( 'THREE.ParticleSystem has been renamed to THREE.Points.' ); return new Points( geometry, material ); + } -export function PointCloudMaterial ( parameters ) { +export function PointCloudMaterial( parameters ) { + console.warn( 'THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -export function ParticleBasicMaterial ( parameters ) { +export function ParticleBasicMaterial( parameters ) { + console.warn( 'THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -export function ParticleSystemMaterial ( parameters ) { +export function ParticleSystemMaterial( parameters ) { + console.warn( 'THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.' ); return new PointsMaterial( parameters ); + } -export function Vertex ( x, y, z ) { +export function Vertex( x, y, z ) { + console.warn( 'THREE.Vertex has been removed. Use THREE.Vector3 instead.' ); return new Vector3( x, y, z ); + } // export function DynamicBufferAttribute( array, itemSize ) { + console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' ); return new BufferAttribute( array, itemSize ).setDynamic( true ); + } export function Int8Attribute( array, itemSize ) { + console.warn( 'THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.' ); return new Int8BufferAttribute( array, itemSize ); + } export function Uint8Attribute( array, itemSize ) { + console.warn( 'THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.' ); return new Uint8BufferAttribute( array, itemSize ); + } export function Uint8ClampedAttribute( array, itemSize ) { + console.warn( 'THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.' ); return new Uint8ClampedBufferAttribute( array, itemSize ); + } export function Int16Attribute( array, itemSize ) { + console.warn( 'THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.' ); return new Int16BufferAttribute( array, itemSize ); + } export function Uint16Attribute( array, itemSize ) { + console.warn( 'THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.' ); return new Uint16BufferAttribute( array, itemSize ); + } export function Int32Attribute( array, itemSize ) { + console.warn( 'THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.' ); return new Int32BufferAttribute( array, itemSize ); + } export function Uint32Attribute( array, itemSize ) { + console.warn( 'THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.' ); return new Uint32BufferAttribute( array, itemSize ); + } export function Float32Attribute( array, itemSize ) { + console.warn( 'THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.' ); return new Float32BufferAttribute( array, itemSize ); + } export function Float64Attribute( array, itemSize ) { + console.warn( 'THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.' ); return new Float64BufferAttribute( array, itemSize ); + } // export function ClosedSplineCurve3( points ) { - console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.' ); + console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.' ); CatmullRomCurve3.call( this, points ); this.type = 'catmullrom'; @@ -175,277 +220,393 @@ ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype ); // +export function BoundingBoxHelper( object, color ) { + + console.warn( 'THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.' ); + return new BoxHelper( object, color ); + +} export function EdgesHelper( object, hex ) { + console.warn( 'THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.' ); return new LineSegments( new EdgesGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } -Object.assign( GridHelper.prototype, { - setColors: function () { - console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); - } -} ) +GridHelper.prototype.setColors = function () { + + console.error( 'THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.' ); + +}; export function WireframeHelper( object, hex ) { + console.warn( 'THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.' ); return new LineSegments( new WireframeGeometry( object.geometry ), new LineBasicMaterial( { color: hex !== undefined ? hex : 0xffffff } ) ); + } // export function XHRLoader( manager ) { + console.warn( 'THREE.XHRLoader has been renamed to THREE.FileLoader.' ); return new FileLoader( manager ); + } // Object.assign( Box2.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box2: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box2: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); + } } ); Object.assign( Box3.prototype, { + center: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .center() has been renamed to .getCenter().' ); return this.getCenter( optionalTarget ); + }, empty: function () { + console.warn( 'THREE.Box3: .empty() has been renamed to .isEmpty().' ); return this.isEmpty(); + }, isIntersectionBox: function ( box ) { + console.warn( 'THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + }, size: function ( optionalTarget ) { + console.warn( 'THREE.Box3: .size() has been renamed to .getSize().' ); return this.getSize( optionalTarget ); - } -} ); -Object.assign( Line3.prototype, { - center: function ( optionalTarget ) { - console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); - return this.getCenter( optionalTarget ); } } ); -Object.assign( _Math, { - random16: function () { - console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' ); - return Math.random(); - }, -} ); +Line3.prototype.center = function ( optionalTarget ) { + + console.warn( 'THREE.Line3: .center() has been renamed to .getCenter().' ); + return this.getCenter( optionalTarget ); + +}; + +_Math.random16 = function () { + + console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' ); + return Math.random(); + +}; Object.assign( Matrix3.prototype, { + flattenToArrayOffset: function ( array, offset ) { + console.warn( "THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); return this.toArray( array, offset ); + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.' ); return vector.applyMatrix3( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + } + } ); Object.assign( Matrix4.prototype, { + extractPosition: function ( m ) { + console.warn( 'THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().' ); return this.copyPosition( m ); + }, flattenToArrayOffset: function ( array, offset ) { - console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); + console.warn( "THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead." ); return this.toArray( array, offset ); + }, getPosition: function () { var v1; return function getPosition() { + if ( v1 === undefined ) v1 = new Vector3(); console.warn( 'THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.' ); return v1.setFromMatrixColumn( this, 3 ); + }; }(), setRotationFromQuaternion: function ( q ) { + console.warn( 'THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().' ); return this.makeRotationFromQuaternion( q ); + }, multiplyVector3: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.' ); return vector.applyProjection( this ); + }, multiplyVector4: function ( vector ) { + console.warn( 'THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, multiplyVector3Array: function ( a ) { + console.warn( 'THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.' ); return this.applyToVector3Array( a ); + }, rotateAxis: function ( v ) { + console.warn( 'THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.' ); v.transformDirection( this ); + }, crossVector: function ( vector ) { + console.warn( 'THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.' ); return vector.applyMatrix4( this ); + }, - translate: function ( v ) { + translate: function () { + console.error( 'THREE.Matrix4: .translate() has been removed.' ); + }, - rotateX: function ( angle ) { + rotateX: function () { + console.error( 'THREE.Matrix4: .rotateX() has been removed.' ); + }, - rotateY: function ( angle ) { + rotateY: function () { + console.error( 'THREE.Matrix4: .rotateY() has been removed.' ); + }, - rotateZ: function ( angle ) { + rotateZ: function () { + console.error( 'THREE.Matrix4: .rotateZ() has been removed.' ); + }, - rotateByAxis: function ( axis, angle ) { + rotateByAxis: function () { + console.error( 'THREE.Matrix4: .rotateByAxis() has been removed.' ); - } -} ); -Object.assign( Plane.prototype, { - isIntersectionLine: function ( line ) { - console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); - return this.intersectsLine( line ); } -} ); -Object.assign( Quaternion.prototype, { - multiplyVector3: function ( vector ) { - console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); - return vector.applyQuaternion( this ); - } } ); +Plane.prototype.isIntersectionLine = function ( line ) { + + console.warn( 'THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().' ); + return this.intersectsLine( line ); + +}; + +Quaternion.prototype.multiplyVector3 = function ( vector ) { + + console.warn( 'THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.' ); + return vector.applyQuaternion( this ); + +}; + Object.assign( Ray.prototype, { + isIntersectionBox: function ( box ) { + console.warn( 'THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().' ); return this.intersectsBox( box ); + }, isIntersectionPlane: function ( plane ) { + console.warn( 'THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().' ); return this.intersectsPlane( plane ); + }, isIntersectionSphere: function ( sphere ) { + console.warn( 'THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().' ); return this.intersectsSphere( sphere ); + } + } ); Object.assign( Shape.prototype, { + extrude: function ( options ) { + console.warn( 'THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.' ); return new ExtrudeGeometry( this, options ); + }, makeGeometry: function ( options ) { + console.warn( 'THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.' ); return new ShapeGeometry( this, options ); + } + } ); Object.assign( Vector3.prototype, { + setEulerFromRotationMatrix: function () { + console.error( 'THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.' ); + }, setEulerFromQuaternion: function () { + console.error( 'THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.' ); + }, getPositionFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().' ); return this.setFromMatrixPosition( m ); + }, getScaleFromMatrix: function ( m ) { + console.warn( 'THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().' ); return this.setFromMatrixScale( m ); + }, getColumnFromMatrix: function ( index, matrix ) { + console.warn( 'THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().' ); return this.setFromMatrixColumn( matrix, index ); + } + } ); // -Object.assign( Geometry.prototype, { - computeTangents: function () { - console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); - }, +Geometry.prototype.computeTangents = function () { -} ); + console.warn( 'THREE.Geometry: .computeTangents() has been removed.' ); + +}; Object.assign( Object3D.prototype, { + getChildByName: function ( name ) { + console.warn( 'THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().' ); return this.getObjectByName( name ); + }, - renderDepth: function ( value ) { + renderDepth: function () { + console.warn( 'THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.' ); + }, translate: function ( distance, axis ) { + console.warn( 'THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.' ); return this.translateOnAxis( axis, distance ); + } + } ); Object.defineProperties( Object3D.prototype, { + eulerOrder: { get: function () { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); return this.rotation.order; + }, set: function ( value ) { + console.warn( 'THREE.Object3D: .eulerOrder is now .rotation.order.' ); this.rotation.order = value; + } }, useQuaternion: { get: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.' ); + } } + } ); Object.defineProperties( LOD.prototype, { + objects: { get: function () { + console.warn( 'THREE.LOD: .objects has been renamed to .levels.' ); return this.levels; + } } + } ); // @@ -464,78 +625,104 @@ PerspectiveCamera.prototype.setLens = function ( focalLength, filmGauge ) { Object.defineProperties( Light.prototype, { onlyShadow: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .onlyShadow has been removed.' ); + } }, shadowCameraFov: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFov is now .shadow.camera.fov.' ); this.shadow.camera.fov = value; + } }, shadowCameraLeft: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraLeft is now .shadow.camera.left.' ); this.shadow.camera.left = value; + } }, shadowCameraRight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraRight is now .shadow.camera.right.' ); this.shadow.camera.right = value; + } }, shadowCameraTop: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraTop is now .shadow.camera.top.' ); this.shadow.camera.top = value; + } }, shadowCameraBottom: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.' ); this.shadow.camera.bottom = value; + } }, shadowCameraNear: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraNear is now .shadow.camera.near.' ); this.shadow.camera.near = value; + } }, shadowCameraFar: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowCameraFar is now .shadow.camera.far.' ); this.shadow.camera.far = value; + } }, shadowCameraVisible: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.' ); + } }, shadowBias: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowBias is now .shadow.bias.' ); this.shadow.bias = value; + } }, shadowDarkness: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Light: .shadowDarkness has been removed.' ); + } }, shadowMapWidth: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.' ); this.shadow.mapSize.width = value; + } }, shadowMapHeight: { set: function ( value ) { + console.warn( 'THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.' ); this.shadow.mapSize.height = value; + } } } ); @@ -543,111 +730,161 @@ Object.defineProperties( Light.prototype, { // Object.defineProperties( BufferAttribute.prototype, { + length: { get: function () { - console.warn( 'THREE.BufferAttribute: .length has been deprecated. Please use .count.' ); + + console.warn( 'THREE.BufferAttribute: .length has been deprecated. Use .count instead.' ); return this.array.length; + } } + } ); Object.assign( BufferGeometry.prototype, { + addIndex: function ( index ) { + console.warn( 'THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().' ); this.setIndex( index ); + }, addDrawCall: function ( start, count, indexOffset ) { + if ( indexOffset !== undefined ) { + console.warn( 'THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.' ); + } console.warn( 'THREE.BufferGeometry: .addDrawCall() is now .addGroup().' ); this.addGroup( start, count ); + }, clearDrawCalls: function () { + console.warn( 'THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().' ); this.clearGroups(); + }, computeTangents: function () { + console.warn( 'THREE.BufferGeometry: .computeTangents() has been removed.' ); + }, computeOffsets: function () { + console.warn( 'THREE.BufferGeometry: .computeOffsets() has been removed.' ); + } + } ); Object.defineProperties( BufferGeometry.prototype, { + drawcalls: { get: function () { + console.error( 'THREE.BufferGeometry: .drawcalls has been renamed to .groups.' ); return this.groups; + } }, offsets: { get: function () { + console.warn( 'THREE.BufferGeometry: .offsets has been renamed to .groups.' ); return this.groups; + } } + } ); // Object.defineProperties( Uniform.prototype, { + dynamic: { - set: function ( value ) { + set: function () { + console.warn( 'THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.' ); + } }, onUpdate: { value: function () { + console.warn( 'THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.' ); return this; + } } + } ); // Object.defineProperties( Material.prototype, { + wrapAround: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.' + this.type + ': .wrapAround has been removed.' ); + } }, wrapRGB: { get: function () { + console.warn( 'THREE.' + this.type + ': .wrapRGB has been removed.' ); return new Color(); + } } + } ); Object.defineProperties( MeshPhongMaterial.prototype, { + metal: { get: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.' ); return false; + }, - set: function ( value ) { + set: function () { + console.warn( 'THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead' ); + } } + } ); Object.defineProperties( ShaderMaterial.prototype, { + derivatives: { get: function () { + console.warn( 'THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); return this.extensions.derivatives; + }, set: function ( value ) { + console.warn( 'THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.' ); this.extensions.derivatives = value; + } } + } ); // @@ -672,224 +909,315 @@ EventDispatcher.prototype = Object.assign( Object.create( { // Object.assign( WebGLRenderer.prototype, { + supportsFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( \'OES_texture_float\' ).' ); return this.extensions.get( 'OES_texture_float' ); + }, supportsHalfFloatTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( \'OES_texture_half_float\' ).' ); return this.extensions.get( 'OES_texture_half_float' ); + }, supportsStandardDerivatives: function () { + console.warn( 'THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( \'OES_standard_derivatives\' ).' ); return this.extensions.get( 'OES_standard_derivatives' ); + }, supportsCompressedTextureS3TC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( \'WEBGL_compressed_texture_s3tc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_s3tc' ); + }, supportsCompressedTexturePVRTC: function () { + console.warn( 'THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( \'WEBGL_compressed_texture_pvrtc\' ).' ); return this.extensions.get( 'WEBGL_compressed_texture_pvrtc' ); + }, supportsBlendMinMax: function () { + console.warn( 'THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( \'EXT_blend_minmax\' ).' ); return this.extensions.get( 'EXT_blend_minmax' ); + }, supportsVertexTextures: function () { + console.warn( 'THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.' ); return this.capabilities.vertexTextures; + }, supportsInstancedArrays: function () { + console.warn( 'THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( \'ANGLE_instanced_arrays\' ).' ); return this.extensions.get( 'ANGLE_instanced_arrays' ); + }, enableScissorTest: function ( boolean ) { + console.warn( 'THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().' ); this.setScissorTest( boolean ); + }, initMaterial: function () { + console.warn( 'THREE.WebGLRenderer: .initMaterial() has been removed.' ); + }, addPrePlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPrePlugin() has been removed.' ); + }, addPostPlugin: function () { + console.warn( 'THREE.WebGLRenderer: .addPostPlugin() has been removed.' ); + }, updateShadowMap: function () { + console.warn( 'THREE.WebGLRenderer: .updateShadowMap() has been removed.' ); + } + } ); Object.defineProperties( WebGLRenderer.prototype, { + shadowMapEnabled: { get: function () { + return this.shadowMap.enabled; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.' ); this.shadowMap.enabled = value; + } }, shadowMapType: { get: function () { + return this.shadowMap.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.' ); this.shadowMap.type = value; + } }, shadowMapCullFace: { get: function () { + return this.shadowMap.cullFace; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.' ); this.shadowMap.cullFace = value; + } } } ); Object.defineProperties( WebGLShadowMap.prototype, { + cullFace: { get: function () { + return this.renderReverseSided ? CullFaceFront : CullFaceBack; + }, set: function ( cullFace ) { + var value = ( cullFace !== CullFaceBack ); console.warn( "WebGLRenderer: .shadowMap.cullFace is deprecated. Set .shadowMap.renderReverseSided to " + value + "." ); this.renderReverseSided = value; + } } + } ); // Object.defineProperties( WebGLRenderTarget.prototype, { + wrapS: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); return this.texture.wrapS; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.' ); this.texture.wrapS = value; + } }, wrapT: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); return this.texture.wrapT; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.' ); this.texture.wrapT = value; + } }, magFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); return this.texture.magFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.' ); this.texture.magFilter = value; + } }, minFilter: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); return this.texture.minFilter; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.' ); this.texture.minFilter = value; + } }, anisotropy: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); return this.texture.anisotropy; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.' ); this.texture.anisotropy = value; + } }, offset: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); return this.texture.offset; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .offset is now .texture.offset.' ); this.texture.offset = value; + } }, repeat: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); return this.texture.repeat; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .repeat is now .texture.repeat.' ); this.texture.repeat = value; + } }, format: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); return this.texture.format; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .format is now .texture.format.' ); this.texture.format = value; + } }, type: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); return this.texture.type; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .type is now .texture.type.' ); this.texture.type = value; + } }, generateMipmaps: { get: function () { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); return this.texture.generateMipmaps; + }, set: function ( value ) { + console.warn( 'THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.' ); this.texture.generateMipmaps = value; + } } + } ); // -Object.assign( Audio.prototype, { - load: function ( file ) { - console.warn( 'THREE.Audio: .load has been deprecated. Please use THREE.AudioLoader.' ); - var scope = this; - var audioLoader = new AudioLoader(); - audioLoader.load( file, function ( buffer ) { - scope.setBuffer( buffer ); - } ); - return this; - } -} ); +Audio.prototype.load = function ( file ) { -Object.assign( AudioAnalyser.prototype, { - getData: function ( file ) { - console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); - return this.getFrequencyData(); - } -} ); + console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' ); + var scope = this; + var audioLoader = new AudioLoader(); + audioLoader.load( file, function ( buffer ) { + + scope.setBuffer( buffer ); + + } ); + return this; + +}; + +AudioAnalyser.prototype.getData = function () { + + console.warn( 'THREE.AudioAnalyser: .getData() is now .getFrequencyData().' ); + return this.getFrequencyData(); + +}; // @@ -898,7 +1226,6 @@ export var GeometryUtils = { merge: function ( geometry1, geometry2, materialIndexOffset ) { console.warn( 'THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.' ); - var matrix; if ( geometry2.isMesh ) { @@ -1038,7 +1365,7 @@ export var UniformsUtils = { // -export function Projector () { +export function Projector() { console.error( 'THREE.Projector has been moved to /examples/js/renderers/Projector.js.' ); @@ -1056,7 +1383,7 @@ export function Projector () { }; - this.pickingRay = function ( vector, camera ) { + this.pickingRay = function () { console.error( 'THREE.Projector: .pickingRay() is now raycaster.setFromCamera().' ); @@ -1066,7 +1393,7 @@ export function Projector () { // -export function CanvasRenderer () { +export function CanvasRenderer() { console.error( 'THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js' ); diff --git a/src/Three.js b/src/Three.js index 4b0b34c11d6f3d007828a1f83f84290b902213dd..99a5e29b00e779cacf4a1ff7a70b17bf41f3f128 100644 --- a/src/Three.js +++ b/src/Three.js @@ -3,7 +3,7 @@ import './polyfills.js'; export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube.js'; export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js'; export { WebGLRenderer } from './renderers/WebGLRenderer.js'; -export { WebGL2Renderer } from './renderers/WebGL2Renderer.js'; +// export { WebGL2Renderer } from './renderers/WebGL2Renderer.js'; export { ShaderLib } from './renderers/shaders/ShaderLib.js'; export { UniformsLib } from './renderers/shaders/UniformsLib.js'; export { ShaderChunk } from './renderers/shaders/ShaderChunk.js'; @@ -27,10 +27,9 @@ export { CompressedTexture } from './textures/CompressedTexture.js'; export { CubeTexture } from './textures/CubeTexture.js'; export { CanvasTexture } from './textures/CanvasTexture.js'; export { DepthTexture } from './textures/DepthTexture.js'; -export { TextureIdCount, Texture } from './textures/Texture.js'; +export { Texture } from './textures/Texture.js'; export * from './geometries/Geometries.js'; export * from './materials/Materials.js'; -export { MaterialIdCount } from './materials/Material.js'; export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js'; export { BinaryTextureLoader, DataTextureLoader } from './loaders/BinaryTextureLoader.js'; export { CubeTextureLoader } from './loaders/CubeTextureLoader.js'; @@ -87,20 +86,9 @@ export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js'; export { InterleavedBuffer } from './core/InterleavedBuffer.js'; export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js'; -export { - Float64BufferAttribute, - Float32BufferAttribute, - Uint32BufferAttribute, - Int32BufferAttribute, - Uint16BufferAttribute, - Int16BufferAttribute, - Uint8ClampedBufferAttribute, - Uint8BufferAttribute, - Int8BufferAttribute, - BufferAttribute -} from './core/BufferAttribute.js'; +export * from './core/BufferAttribute.js'; export { Face3 } from './core/Face3.js'; -export { Object3DIdCount, Object3D } from './core/Object3D.js'; +export { Object3D } from './core/Object3D.js'; export { Raycaster } from './core/Raycaster.js'; export { Layers } from './core/Layers.js'; export { EventDispatcher } from './core/EventDispatcher.js'; @@ -138,10 +126,10 @@ export { PointLightHelper } from './extras/helpers/PointLightHelper.js'; export { RectAreaLightHelper } from './extras/helpers/RectAreaLightHelper.js'; export { HemisphereLightHelper } from './extras/helpers/HemisphereLightHelper.js'; export { GridHelper } from './extras/helpers/GridHelper.js'; +export { PolarGridHelper } from './extras/helpers/PolarGridHelper.js'; export { FaceNormalsHelper } from './extras/helpers/FaceNormalsHelper.js'; export { DirectionalLightHelper } from './extras/helpers/DirectionalLightHelper.js'; export { CameraHelper } from './extras/helpers/CameraHelper.js'; -export { BoundingBoxHelper } from './extras/helpers/BoundingBoxHelper.js'; export { BoxHelper } from './extras/helpers/BoxHelper.js'; export { ArrowHelper } from './extras/helpers/ArrowHelper.js'; export { AxisHelper } from './extras/helpers/AxisHelper.js'; diff --git a/src/audio/Audio.js b/src/audio/Audio.js index 9e5fd28e25ae10427924e5ba194cddbd5f206f6a..808b4a1b7f39bb4d12610981ea2509d84c91e77c 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -12,14 +12,14 @@ function Audio( listener ) { this.type = 'Audio'; this.context = listener.context; - this.source = this.context.createBufferSource(); - this.source.onended = this.onEnded.bind( this ); this.gain = this.context.createGain(); this.gain.connect( listener.getInput() ); this.autoplay = false; + this.buffer = null; + this.loop = false; this.startTime = 0; this.playbackRate = 1; this.isPlaying = false; @@ -53,7 +53,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { setBuffer: function ( audioBuffer ) { - this.source.buffer = audioBuffer; + this.buffer = audioBuffer; this.sourceType = 'buffer'; if ( this.autoplay ) this.play(); @@ -80,11 +80,11 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { var source = this.context.createBufferSource(); - source.buffer = this.source.buffer; - source.loop = this.source.loop; - source.onended = this.source.onended; + source.buffer = this.buffer; + source.loop = this.loop; + source.onended = this.onEnded.bind( this ); + source.playbackRate.setValueAtTime( this.playbackRate, this.startTime ); source.start( 0, this.startTime ); - source.playbackRate.value = this.playbackRate; this.isPlaying = true; @@ -227,7 +227,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { if ( this.isPlaying === true ) { - this.source.playbackRate.value = this.playbackRate; + this.source.playbackRate.setValueAtTime( this.playbackRate, this.context.currentTime ); } @@ -256,7 +256,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { } - return this.source.loop; + return this.loop; }, @@ -269,7 +269,15 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { } - this.source.loop = value; + this.loop = value; + + if ( this.isPlaying === true ) { + + this.source.loop = this.loop; + + } + + return this; }, diff --git a/src/audio/AudioListener.js b/src/audio/AudioListener.js index 0c0cfe1670b80f2a0de2fa5747f4df6ab667eb70..77df5400975bcac2936bb47e32802e46fe3796f5 100644 --- a/src/audio/AudioListener.js +++ b/src/audio/AudioListener.js @@ -101,8 +101,24 @@ AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), { orientation.set( 0, 0, - 1 ).applyQuaternion( quaternion ); - listener.setPosition( position.x, position.y, position.z ); - listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + if ( listener.positionX ) { + + listener.positionX.setValueAtTime( position.x, this.context.currentTime ); + listener.positionY.setValueAtTime( position.y, this.context.currentTime ); + listener.positionZ.setValueAtTime( position.z, this.context.currentTime ); + listener.forwardX.setValueAtTime( orientation.x, this.context.currentTime ); + listener.forwardY.setValueAtTime( orientation.y, this.context.currentTime ); + listener.forwardZ.setValueAtTime( orientation.z, this.context.currentTime ); + listener.upX.setValueAtTime( up.x, this.context.currentTime ); + listener.upY.setValueAtTime( up.y, this.context.currentTime ); + listener.upZ.setValueAtTime( up.z, this.context.currentTime ); + + } else { + + listener.setPosition( position.x, position.y, position.z ); + listener.setOrientation( orientation.x, orientation.y, orientation.z, up.x, up.y, up.z ); + + } }; diff --git a/src/core/BufferGeometry.js b/src/core/BufferGeometry.js index 645ce8fda1a13d8d45e5085adbdde72cb731be45..d428605b5c3c6ce92e334aefb1c9a3ace377db21 100644 --- a/src/core/BufferGeometry.js +++ b/src/core/BufferGeometry.js @@ -56,7 +56,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { addAttribute: function ( name, attribute ) { - if ( (attribute && attribute.isBufferAttribute) === false && (attribute && attribute.isInterleavedBufferAttribute) === false ) { + if ( ( attribute && attribute.isBufferAttribute ) === false && ( attribute && attribute.isInterleavedBufferAttribute ) === false ) { console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' ); @@ -684,14 +684,9 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { var normals = attributes.normal.array; - var vA, vB, vC, - - pA = new Vector3(), - pB = new Vector3(), - pC = new Vector3(), - - cb = new Vector3(), - ab = new Vector3(); + var vA, vB, vC; + var pA = new Vector3(), pB = new Vector3(), pC = new Vector3(); + var cb = new Vector3(), ab = new Vector3(); // indexed elements @@ -782,7 +777,7 @@ Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, { merge: function ( geometry, offset ) { - if ( (geometry && geometry.isBufferGeometry) === false ) { + if ( ( geometry && geometry.isBufferGeometry ) === false ) { console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry ); return; diff --git a/src/core/DirectGeometry.js b/src/core/DirectGeometry.js index 4da985ace595b10f9d84cc455c39ca7f6a3a29be..ce35e5a2cc17211f10eaa71be75a204adbc9cd17 100644 --- a/src/core/DirectGeometry.js +++ b/src/core/DirectGeometry.js @@ -1,21 +1,10 @@ -import { Geometry } from './Geometry'; -import { EventDispatcher } from './EventDispatcher'; -import { Vector2 } from '../math/Vector2'; -import { _Math } from '../math/Math'; -import { GeometryIdCount } from './Geometry'; - /** * @author mrdoob / http://mrdoob.com/ */ -function DirectGeometry() { - - Object.defineProperty( this, 'id', { value: GeometryIdCount() } ); - - this.uuid = _Math.generateUUID(); +import { Vector2 } from '../math/Vector2'; - this.name = ''; - this.type = 'DirectGeometry'; +function DirectGeometry() { this.indices = []; this.vertices = []; @@ -46,22 +35,7 @@ function DirectGeometry() { } -Object.assign( DirectGeometry.prototype, EventDispatcher.prototype, { - - computeBoundingBox: Geometry.prototype.computeBoundingBox, - computeBoundingSphere: Geometry.prototype.computeBoundingSphere, - - computeFaceNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.' ); - - }, - - computeVertexNormals: function () { - - console.warn( 'THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.' ); - - }, +Object.assign( DirectGeometry.prototype, { computeGroups: function ( geometry ) { @@ -281,12 +255,6 @@ Object.assign( DirectGeometry.prototype, EventDispatcher.prototype, { return this; - }, - - dispose: function () { - - this.dispatchEvent( { type: 'dispose' } ); - } } ); diff --git a/src/core/Object3D.js b/src/core/Object3D.js index e6aec4d5df57e5f78275c0bf0ae1d452b4265f1a..9d1c3ca712a0ef359c6db108ea9ab5e4e904e599 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -15,9 +15,11 @@ import { _Math } from '../math/Math'; * @author elephantatwork / www.elephantatwork.ch */ +var object3DId = 0; + function Object3D() { - Object.defineProperty( this, 'id', { value: Object3DIdCount() } ); + Object.defineProperty( this, 'id', { value: object3DId ++ } ); this.uuid = _Math.generateUUID(); @@ -91,7 +93,7 @@ function Object3D() { this.userData = {}; - this.onBeforeRender = function(){}; + this.onBeforeRender = function(){}; this.onAfterRender = function(){}; } @@ -727,8 +729,4 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { } ); -var count = 0; -function Object3DIdCount() { return count++; }; - - -export { Object3DIdCount, Object3D }; +export { Object3D }; diff --git a/src/core/Uniform.js b/src/core/Uniform.js index db77e88aba1401e408164d6e662de597fdf3a87d..8c53319d5bd4eaaf0c01b035345753af7fad14ae 100644 --- a/src/core/Uniform.js +++ b/src/core/Uniform.js @@ -15,4 +15,10 @@ function Uniform( value ) { } +Uniform.prototype.clone = function () { + + return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); + +}; + export { Uniform }; diff --git a/src/extras/helpers/AxisHelper.js b/src/extras/helpers/AxisHelper.js index e32fff8e5b29f2a9aaa780787165d5b113f7d747..d65d575b6c73274cc9f0fba03d442f5f1abff5af 100644 --- a/src/extras/helpers/AxisHelper.js +++ b/src/extras/helpers/AxisHelper.js @@ -1,7 +1,7 @@ import { LineSegments } from '../../objects/LineSegments'; import { VertexColors } from '../../constants'; import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; -import { BufferAttribute } from '../../core/BufferAttribute'; +import { Float32BufferAttribute } from '../../core/BufferAttribute'; import { BufferGeometry } from '../../core/BufferGeometry'; /** @@ -13,21 +13,21 @@ function AxisHelper( size ) { size = size || 1; - var vertices = new Float32Array( [ + var vertices = [ 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size, 0, 0, 0, 0, 0, 0, size - ] ); + ]; - var colors = new Float32Array( [ + var colors = [ 1, 0, 0, 1, 0.6, 0, 0, 1, 0, 0.6, 1, 0, 0, 0, 1, 0, 0.6, 1 - ] ); + ]; var geometry = new BufferGeometry(); - geometry.addAttribute( 'position', new BufferAttribute( vertices, 3 ) ); - geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) ); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors } ); diff --git a/src/extras/helpers/BoundingBoxHelper.js b/src/extras/helpers/BoundingBoxHelper.js deleted file mode 100644 index a979cee5af504a91cdfe5cbb2a095ea9c8fe7264..0000000000000000000000000000000000000000 --- a/src/extras/helpers/BoundingBoxHelper.js +++ /dev/null @@ -1,38 +0,0 @@ -import { Mesh } from '../../objects/Mesh'; -import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial'; -import { BoxGeometry } from '../../geometries/BoxGeometry'; -import { Box3 } from '../../math/Box3'; - -/** - * @author WestLangley / http://github.com/WestLangley - */ - -// a helper to show the world-axis-aligned bounding box for an object - -function BoundingBoxHelper( object, hex ) { - - var color = ( hex !== undefined ) ? hex : 0x888888; - - this.object = object; - - this.box = new Box3(); - - Mesh.call( this, new BoxGeometry( 1, 1, 1 ), new MeshBasicMaterial( { color: color, wireframe: true } ) ); - -} - -BoundingBoxHelper.prototype = Object.create( Mesh.prototype ); -BoundingBoxHelper.prototype.constructor = BoundingBoxHelper; - -BoundingBoxHelper.prototype.update = function () { - - this.box.setFromObject( this.object ); - - this.box.getSize( this.scale ); - - this.box.getCenter( this.position ); - -}; - - -export { BoundingBoxHelper }; diff --git a/src/extras/helpers/CameraHelper.js b/src/extras/helpers/CameraHelper.js index f0e560b7db11f6348a8d802b1bce09f5619d0825..ac2c890406fd2a90a66bba827256dead327d8979 100644 --- a/src/extras/helpers/CameraHelper.js +++ b/src/extras/helpers/CameraHelper.js @@ -4,10 +4,12 @@ import { LineSegments } from '../../objects/LineSegments'; import { Color } from '../../math/Color'; import { FaceColors } from '../../constants'; import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; -import { Geometry } from '../../core/Geometry'; +import { BufferGeometry } from '../../core/BufferGeometry'; +import { Float32BufferAttribute } from '../../core/BufferAttribute'; /** * @author alteredq / http://alteredqualia.com/ + * @author Mugen87 / https://github.com/Mugen87 * * - shows frustum, line of sight and up of the camera * - suitable for fast updates @@ -17,77 +19,80 @@ import { Geometry } from '../../core/Geometry'; function CameraHelper( camera ) { - var geometry = new Geometry(); + var geometry = new BufferGeometry(); var material = new LineBasicMaterial( { color: 0xffffff, vertexColors: FaceColors } ); + var vertices = []; + var colors = []; + var pointMap = {}; // colors - var hexFrustum = 0xffaa00; - var hexCone = 0xff0000; - var hexUp = 0x00aaff; - var hexTarget = 0xffffff; - var hexCross = 0x333333; + var colorFrustum = new Color( 0xffaa00 ); + var colorCone = new Color( 0xff0000 ); + var colorUp = new Color( 0x00aaff ); + var colorTarget = new Color( 0xffffff ); + var colorCross = new Color( 0x333333 ); // near - addLine( "n1", "n2", hexFrustum ); - addLine( "n2", "n4", hexFrustum ); - addLine( "n4", "n3", hexFrustum ); - addLine( "n3", "n1", hexFrustum ); + addLine( "n1", "n2", colorFrustum ); + addLine( "n2", "n4", colorFrustum ); + addLine( "n4", "n3", colorFrustum ); + addLine( "n3", "n1", colorFrustum ); // far - addLine( "f1", "f2", hexFrustum ); - addLine( "f2", "f4", hexFrustum ); - addLine( "f4", "f3", hexFrustum ); - addLine( "f3", "f1", hexFrustum ); + addLine( "f1", "f2", colorFrustum ); + addLine( "f2", "f4", colorFrustum ); + addLine( "f4", "f3", colorFrustum ); + addLine( "f3", "f1", colorFrustum ); // sides - addLine( "n1", "f1", hexFrustum ); - addLine( "n2", "f2", hexFrustum ); - addLine( "n3", "f3", hexFrustum ); - addLine( "n4", "f4", hexFrustum ); + addLine( "n1", "f1", colorFrustum ); + addLine( "n2", "f2", colorFrustum ); + addLine( "n3", "f3", colorFrustum ); + addLine( "n4", "f4", colorFrustum ); // cone - addLine( "p", "n1", hexCone ); - addLine( "p", "n2", hexCone ); - addLine( "p", "n3", hexCone ); - addLine( "p", "n4", hexCone ); + addLine( "p", "n1", colorCone ); + addLine( "p", "n2", colorCone ); + addLine( "p", "n3", colorCone ); + addLine( "p", "n4", colorCone ); // up - addLine( "u1", "u2", hexUp ); - addLine( "u2", "u3", hexUp ); - addLine( "u3", "u1", hexUp ); + addLine( "u1", "u2", colorUp ); + addLine( "u2", "u3", colorUp ); + addLine( "u3", "u1", colorUp ); // target - addLine( "c", "t", hexTarget ); - addLine( "p", "c", hexCross ); + addLine( "c", "t", colorTarget ); + addLine( "p", "c", colorCross ); // cross - addLine( "cn1", "cn2", hexCross ); - addLine( "cn3", "cn4", hexCross ); + addLine( "cn1", "cn2", colorCross ); + addLine( "cn3", "cn4", colorCross ); - addLine( "cf1", "cf2", hexCross ); - addLine( "cf3", "cf4", hexCross ); + addLine( "cf1", "cf2", colorCross ); + addLine( "cf3", "cf4", colorCross ); - function addLine( a, b, hex ) { + function addLine( a, b, color ) { - addPoint( a, hex ); - addPoint( b, hex ); + addPoint( a, color ); + addPoint( b, color ); } - function addPoint( id, hex ) { + function addPoint( id, color ) { - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( hex ) ); + vertices.push( 0, 0, 0 ); + colors.push( color.r, color.g, color.b ); if ( pointMap[ id ] === undefined ) { @@ -95,14 +100,17 @@ function CameraHelper( camera ) { } - pointMap[ id ].push( geometry.vertices.length - 1 ); + pointMap[ id ].push( ( vertices.length / 3 ) - 1 ); } + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + LineSegments.call( this, geometry, material ); this.camera = camera; - if( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); + if ( this.camera.updateProjectionMatrix ) this.camera.updateProjectionMatrix(); this.matrix = camera.matrixWorld; this.matrixAutoUpdate = false; @@ -131,9 +139,11 @@ CameraHelper.prototype.update = function () { if ( points !== undefined ) { - for ( var i = 0, il = points.length; i < il; i ++ ) { + var position = geometry.getAttribute( 'position' ); + + for ( var i = 0, l = points.length; i < l; i ++ ) { - geometry.vertices[ points[ i ] ].copy( vector ); + position.setXYZ( points[ i ], vector.x, vector.y, vector.z ); } @@ -190,7 +200,7 @@ CameraHelper.prototype.update = function () { setPoint( "cn3", 0, - h, - 1 ); setPoint( "cn4", 0, h, - 1 ); - geometry.verticesNeedUpdate = true; + geometry.getAttribute( 'position' ).needsUpdate = true; }; diff --git a/src/extras/helpers/GridHelper.js b/src/extras/helpers/GridHelper.js index b381afc7cd702f9135592b5f09e41657b5b671e0..e3496898f7bf90b0c60bac2fcdf839e32be4946b 100644 --- a/src/extras/helpers/GridHelper.js +++ b/src/extras/helpers/GridHelper.js @@ -11,7 +11,8 @@ import { Color } from '../../math/Color'; function GridHelper( size, divisions, color1, color2 ) { - divisions = divisions || 1; + size = size || 10; + divisions = divisions || 10; color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); diff --git a/src/extras/helpers/PolarGridHelper.js b/src/extras/helpers/PolarGridHelper.js new file mode 100644 index 0000000000000000000000000000000000000000..36f3787184d34a97a165e262e249f115ef502987 --- /dev/null +++ b/src/extras/helpers/PolarGridHelper.js @@ -0,0 +1,95 @@ +import { LineSegments } from '../../objects/LineSegments'; +import { VertexColors } from '../../constants'; +import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; +import { Float32BufferAttribute } from '../../core/BufferAttribute'; +import { BufferGeometry } from '../../core/BufferGeometry'; +import { Color } from '../../math/Color'; + +/** + * @author mrdoob / http://mrdoob.com/ + * @author Mugen87 / http://github.com/Mugen87 + * @author Hectate / http://www.github.com/Hectate + */ + +function PolarGridHelper( radius, radials, circles, divisions, color1, color2 ) { + + radius = radius || 10; + radials = radials || 16; + circles = circles || 8; + divisions = divisions || 64; + color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); + color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); + + var vertices = []; + var colors = []; + + var x, z; + var v, i, j, r, color; + + // create the radials + + for ( i = 0; i <= radials; i ++ ) { + + v = ( i / radials ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * radius; + z = Math.cos( v ) * radius; + + vertices.push( 0, 0, 0 ); + vertices.push( x, 0, z ); + + color = ( i & 1 ) ? color1 : color2; + + colors.push( color.r, color.g, color.b ); + colors.push( color.r, color.g, color.b ); + + } + + // create the circles + + for ( i = 0; i <= circles; i ++ ) { + + color = ( i & 1 ) ? color1 : color2; + + r = radius - ( radius / circles * i ); + + for ( j = 0; j < divisions; j ++ ) { + + // first vertex + + v = ( j / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + // second vertex + + v = ( ( j + 1 ) / divisions ) * ( Math.PI * 2 ); + + x = Math.sin( v ) * r; + z = Math.cos( v ) * r; + + vertices.push( x, 0, z ); + colors.push( color.r, color.g, color.b ); + + } + + } + + var geometry = new BufferGeometry(); + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); + + var material = new LineBasicMaterial( { vertexColors: VertexColors } ); + + LineSegments.call( this, geometry, material ); + +} + +PolarGridHelper.prototype = Object.create( LineSegments.prototype ); +PolarGridHelper.prototype.constructor = PolarGridHelper; + +export { PolarGridHelper }; diff --git a/src/extras/helpers/RectAreaLightHelper.js b/src/extras/helpers/RectAreaLightHelper.js index 129307feb8042d792ee61fee95e6e9ea2b0eca83..a9c5e6caf6a0ff515285e16fc8ae213505050a52 100644 --- a/src/extras/helpers/RectAreaLightHelper.js +++ b/src/extras/helpers/RectAreaLightHelper.js @@ -2,108 +2,105 @@ * @author abelnation / http://github.com/abelnation */ -import {Object3D} from '../../core/Object3D'; -import {Vector3} from '../../math/Vector3'; -import {Shape} from '../../extras/core/Shape'; -import {Mesh} from '../../objects/Mesh'; -import {MeshBasicMaterial} from '../../materials/MeshBasicMaterial'; -import {ShapeGeometry} from '../../geometries/ShapeGeometry'; +import { Object3D } from '../../core/Object3D'; +import { Vector3 } from '../../math/Vector3'; +import { Shape } from '../../extras/core/Shape'; +import { Mesh } from '../../objects/Mesh'; +import { MeshBasicMaterial } from '../../materials/MeshBasicMaterial'; +import { ShapeBufferGeometry } from '../../geometries/ShapeBufferGeometry'; -function RectAreaLightHelper(light) { +function RectAreaLightHelper( light ) { - Object3D.call(this); + Object3D.call( this ); - this.light = light; - this.light.updateMatrixWorld(); + this.light = light; + this.light.updateMatrixWorld(); - // this.matrix = light.matrixWorld; - // this.matrixAutoUpdate = false; + this.lightMat = new MeshBasicMaterial( { + color: light.color, + fog: false + } ); - this.lightMat = new MeshBasicMaterial({ - color: light.color, - fog: false - }); + this.lightWireMat = new MeshBasicMaterial( { + color: light.color, + fog: false, + wireframe: true + } ); - this.lightWireMat = new MeshBasicMaterial({ - color: light.color, - fog: false, - wireframe: true - }); + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - // shows the "front" of the light, e.g. where light comes from - this.lightMesh = new Mesh(this.lightShape, this.lightMat); - // shows the "back" of the light, which does not emit light - this.lightWireMesh = new Mesh(this.lightShape, this.lightWireMat); + // shows the "front" of the light, e.g. where light comes from - this.add(this.lightMesh); - this.add(this.lightWireMesh); + this.lightMesh = new Mesh( this.lightShape, this.lightMat ); - this.update(); + // shows the "back" of the light, which does not emit light + + this.lightWireMesh = new Mesh( this.lightShape, this.lightWireMat ); + + this.add( this.lightMesh ); + this.add( this.lightWireMesh ); + + this.update(); } -RectAreaLightHelper.prototype = Object.create(Object3D.prototype); +RectAreaLightHelper.prototype = Object.create( Object3D.prototype ); RectAreaLightHelper.prototype.constructor = RectAreaLightHelper; RectAreaLightHelper.prototype.dispose = function () { - this.lightMesh.geometry.dispose(); - this.lightMesh.material.dispose(); - this.lightWireMesh.geometry.dispose(); - this.lightWireMesh.material.dispose(); + this.lightMesh.geometry.dispose(); + this.lightMesh.material.dispose(); + this.lightWireMesh.geometry.dispose(); + this.lightWireMesh.material.dispose(); }; RectAreaLightHelper.prototype.update = function () { - var vector = new Vector3(); - var vector2 = new Vector3(); + var vector = new Vector3(); + var vector2 = new Vector3(); - // TODO (abelnation) why not just make light helpers a child of the light object? - if (this.light.target) { + // TODO (abelnation) why not just make light helpers a child of the light object? + if ( this.light.target ) { - vector.setFromMatrixPosition(this.light.matrixWorld); - vector2.setFromMatrixPosition(this.light.target.matrixWorld); + vector.setFromMatrixPosition( this.light.matrixWorld ); + vector2.setFromMatrixPosition( this.light.target.matrixWorld ); - var lookVec = vector2.clone().sub(vector); - this.lightMesh.lookAt(lookVec); - this.lightWireMesh.lookAt(lookVec); + var lookVec = vector2.clone().sub( vector ); + this.lightMesh.lookAt( lookVec ); + this.lightWireMesh.lookAt( lookVec ); - } + } - this.lightMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + this.lightMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); + this.lightWireMesh.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); - this.lightWireMesh.material.color - .copy(this.light.color) - .multiplyScalar(this.light.intensity); + var oldShape = this.lightShape; - var oldShape = this.lightShape; + var hx = this.light.width / 2.0; + var hy = this.light.height / 2.0; - var hx = this.light.width / 2.0; - var hy = this.light.height / 2.0; - this.lightShape = new ShapeGeometry(new Shape([ - new Vector3(-hx, hy, 0), - new Vector3(hx, hy, 0), - new Vector3(hx, -hy, 0), - new Vector3(-hx, -hy, 0) - ])); + this.lightShape = new ShapeBufferGeometry( new Shape( [ + new Vector3( - hx, hy, 0 ), + new Vector3( hx, hy, 0 ), + new Vector3( hx, - hy, 0 ), + new Vector3( - hx, - hy, 0 ) + ] ) ); - this.lightMesh.geometry = this.lightShape; - this.lightWireMesh.geometry = this.lightShape; + this.lightMesh.geometry = this.lightShape; + this.lightWireMesh.geometry = this.lightShape; - oldShape.dispose(); + oldShape.dispose(); }; -export {RectAreaLightHelper}; \ No newline at end of file +export { RectAreaLightHelper }; diff --git a/src/extras/helpers/SkeletonHelper.js b/src/extras/helpers/SkeletonHelper.js index 37daedac891cfd533e52613d6b13bb74171112a1..f5b3b6fbe34127df84b0d4c32ba6c9cfd902096d 100644 --- a/src/extras/helpers/SkeletonHelper.js +++ b/src/extras/helpers/SkeletonHelper.js @@ -4,20 +4,28 @@ import { VertexColors } from '../../constants'; import { LineBasicMaterial } from '../../materials/LineBasicMaterial'; import { Color } from '../../math/Color'; import { Vector3 } from '../../math/Vector3'; -import { Geometry } from '../../core/Geometry'; +import { BufferGeometry } from '../../core/BufferGeometry'; +import { Float32BufferAttribute } from '../../core/BufferAttribute'; /** * @author Sean Griffin / http://twitter.com/sgrif * @author Michael Guerrero / http://realitymeltdown.com * @author mrdoob / http://mrdoob.com/ * @author ikerr / http://verold.com + * @author Mugen87 / https://github.com/Mugen87 */ function SkeletonHelper( object ) { this.bones = this.getBoneList( object ); - var geometry = new Geometry(); + var geometry = new BufferGeometry(); + + var vertices = []; + var colors = []; + + var color1 = new Color( 0, 0, 1 ); + var color2 = new Color( 0, 1, 0 ); for ( var i = 0; i < this.bones.length; i ++ ) { @@ -25,16 +33,17 @@ function SkeletonHelper( object ) { if ( bone.parent && bone.parent.isBone ) { - geometry.vertices.push( new Vector3() ); - geometry.vertices.push( new Vector3() ); - geometry.colors.push( new Color( 0, 0, 1 ) ); - geometry.colors.push( new Color( 0, 1, 0 ) ); + vertices.push( 0, 0, 0 ); + vertices.push( 0, 0, 0 ); + colors.push( color1.r, color1.g, color1.b ); + colors.push( color2.r, color2.g, color2.b ); } } - geometry.dynamic = true; + geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); + geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); var material = new LineBasicMaterial( { vertexColors: VertexColors, depthTest: false, depthWrite: false, transparent: true } ); @@ -75,37 +84,41 @@ SkeletonHelper.prototype.getBoneList = function( object ) { SkeletonHelper.prototype.update = function () { - var geometry = this.geometry; - - var matrixWorldInv = new Matrix4().getInverse( this.root.matrixWorld ); + var vector = new Vector3(); var boneMatrix = new Matrix4(); + var matrixWorldInv = new Matrix4(); - var j = 0; + return function update() { - for ( var i = 0; i < this.bones.length; i ++ ) { + var geometry = this.geometry; + var position = geometry.getAttribute( 'position' ); - var bone = this.bones[ i ]; + matrixWorldInv.getInverse( this.root.matrixWorld ); - if ( bone.parent && bone.parent.isBone ) { + for ( var i = 0, j = 0; i < this.bones.length; i ++, j += 2 ) { - boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); - geometry.vertices[ j ].setFromMatrixPosition( boneMatrix ); + var bone = this.bones[ i ]; - boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); - geometry.vertices[ j + 1 ].setFromMatrixPosition( boneMatrix ); + if ( bone.parent && bone.parent.isBone ) { - j += 2; + boneMatrix.multiplyMatrices( matrixWorldInv, bone.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j, vector.x, vector.y, vector.z ); - } + boneMatrix.multiplyMatrices( matrixWorldInv, bone.parent.matrixWorld ); + vector.setFromMatrixPosition( boneMatrix ); + position.setXYZ( j + 1, vector.x, vector.y, vector.z ); - } + } - geometry.verticesNeedUpdate = true; + } - geometry.computeBoundingSphere(); + geometry.getAttribute( 'position' ).needsUpdate = true; -}; + }; + +}(); export { SkeletonHelper }; diff --git a/src/loaders/FileLoader.js b/src/loaders/FileLoader.js index 2fb06a8301e0acf22f6add3105915cc5dcf484ff..97cfa64e5d86590296bfa8f6966b4c4e6850462e 100644 --- a/src/loaders/FileLoader.js +++ b/src/loaders/FileLoader.js @@ -46,15 +46,13 @@ Object.assign( FileLoader.prototype, { // Safari can not handle Data URIs through XMLHttpRequest so process manually if ( dataUriRegexResult ) { - var mimeType = dataUriRegexResult[1]; - var isBase64 = !!dataUriRegexResult[2]; - var data = dataUriRegexResult[3]; + var mimeType = dataUriRegexResult[ 1 ]; + var isBase64 = !! dataUriRegexResult[ 2 ]; + var data = dataUriRegexResult[ 3 ]; - data = window.decodeURIComponent(data); + data = window.decodeURIComponent( data ); - if( isBase64 ) { - data = window.atob(data); - } + if ( isBase64 ) data = window.atob( data ); try { @@ -67,16 +65,18 @@ Object.assign( FileLoader.prototype, { case 'blob': response = new ArrayBuffer( data.length ); + var view = new Uint8Array( response ); + for ( var i = 0; i < data.length; i ++ ) { - view[ i ] = data.charCodeAt( i ); + view[ i ] = data.charCodeAt( i ); } if ( responseType === 'blob' ) { - response = new Blob( [ response ], { "type" : mimeType } ); + response = new Blob( [ response ], { type: mimeType } ); } @@ -104,24 +104,24 @@ Object.assign( FileLoader.prototype, { } // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onLoad ) onLoad( response ); scope.manager.itemEnd( url ); - }, 0); + }, 0 ); } catch ( error ) { // Wait for next browser tick - window.setTimeout( function() { + window.setTimeout( function () { if ( onError ) onError( error ); scope.manager.itemError( url ); - }, 0); + }, 0 ); } diff --git a/src/loaders/ImageLoader.js b/src/loaders/ImageLoader.js index 6af3cbe46d84a983d9f8bacc8596a7aafbd20ab7..0ae1a878c32d5b4fccb149a6ee7267189c9c9aa0 100644 --- a/src/loaders/ImageLoader.js +++ b/src/loaders/ImageLoader.js @@ -35,6 +35,13 @@ Object.assign( ImageLoader.prototype, { image.src = url; + } else if ( this.crossOrigin !== undefined ) { + + // crossOrigin doesn't work with URL.createObjectURL()? + + image.crossOrigin = this.crossOrigin; + image.src = url; + } else { var loader = new FileLoader(); diff --git a/src/loaders/MaterialLoader.js b/src/loaders/MaterialLoader.js index 5de682e1d66d7525222abfd5c699cad2a4d7efec..22dc9cc8019b2844495ff673523e48151f8a0007 100644 --- a/src/loaders/MaterialLoader.js +++ b/src/loaders/MaterialLoader.js @@ -142,6 +142,8 @@ Object.assign( MaterialLoader.prototype, { if ( json.aoMap !== undefined ) material.aoMap = getTexture( json.aoMap ); if ( json.aoMapIntensity !== undefined ) material.aoMapIntensity = json.aoMapIntensity; + if ( json.gradientMap !== undefined ) material.gradientMap = getTexture( json.gradientMap ); + // MultiMaterial if ( json.materials !== undefined ) { diff --git a/src/loaders/ObjectLoader.js b/src/loaders/ObjectLoader.js index 6a487c00c56adbfd5584f1171ff98be5cb04bdc4..3dd672e122f96fa470b24674400197404ab9415c 100644 --- a/src/loaders/ObjectLoader.js +++ b/src/loaders/ObjectLoader.js @@ -34,7 +34,7 @@ import * as Geometries from '../geometries/Geometries'; * @author mrdoob / http://mrdoob.com/ */ -function ObjectLoader ( manager ) { +function ObjectLoader( manager ) { this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; this.texturePath = ''; @@ -106,7 +106,7 @@ Object.assign( ObjectLoader.prototype, { } ); - var textures = this.parseTextures( json.textures, images ); + var textures = this.parseTextures( json.textures, images ); var materials = this.parseMaterials( json.materials, textures ); var object = this.parseObject( json.object, geometries, materials ); diff --git a/src/materials/Material.js b/src/materials/Material.js index 792897b7f81383168bd790a2dab0d85e73b05856..72bb555dbbef0b3a6bd061b3bd511b17fb93196a 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -7,9 +7,11 @@ import { _Math } from '../math/Math'; * @author alteredq / http://alteredqualia.com/ */ +var materialId = 0; + function Material() { - Object.defineProperty( this, 'id', { value: MaterialIdCount() } ); + Object.defineProperty( this, 'id', { value: materialId ++ } ); this.uuid = _Math.generateUUID(); @@ -200,6 +202,12 @@ Material.prototype = { } + if ( this.gradientMap && this.gradientMap.isTexture ) { + + data.gradientMap = this.gradientMap.toJSON( meta ).uuid; + + } + if ( this.size !== undefined ) data.size = this.size; if ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation; @@ -342,8 +350,4 @@ Material.prototype = { Object.assign( Material.prototype, EventDispatcher.prototype ); -var count = 0; -function MaterialIdCount() { return count++; }; - - -export { MaterialIdCount, Material }; +export { Material }; diff --git a/src/materials/Materials.js b/src/materials/Materials.js index 3ccf676bbdbbc10e94ee88bfb38a0dd8ceefd496..cc84dfe0ecb2e3566336ce623423ec63e6ff2d89 100644 --- a/src/materials/Materials.js +++ b/src/materials/Materials.js @@ -7,6 +7,7 @@ export { MultiMaterial } from './MultiMaterial.js'; export { MeshPhysicalMaterial } from './MeshPhysicalMaterial.js'; export { MeshStandardMaterial } from './MeshStandardMaterial.js'; export { MeshPhongMaterial } from './MeshPhongMaterial.js'; +export { MeshToonMaterial } from './MeshToonMaterial.js'; export { MeshNormalMaterial } from './MeshNormalMaterial.js'; export { MeshLambertMaterial } from './MeshLambertMaterial.js'; export { MeshDepthMaterial } from './MeshDepthMaterial.js'; diff --git a/src/materials/MeshToonMaterial.js b/src/materials/MeshToonMaterial.js new file mode 100644 index 0000000000000000000000000000000000000000..0ea26e0c7904e211d3864dd9a6e6dff6add56a5f --- /dev/null +++ b/src/materials/MeshToonMaterial.js @@ -0,0 +1,41 @@ +import { MeshPhongMaterial } from './MeshPhongMaterial'; + +/** + * @author takahirox / http://github.com/takahirox + * + * parameters = { + * gradientMap: new THREE.Texture( ) + * } + */ + +function MeshToonMaterial( parameters ) { + + MeshPhongMaterial.call( this ); + + this.defines = { 'TOON': '' }; + + this.type = 'MeshToonMaterial'; + + this.gradientMap = null; + + this.setValues( parameters ); + +} + +MeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype ); +MeshToonMaterial.prototype.constructor = MeshToonMaterial; + +MeshToonMaterial.prototype.isMeshToonMaterial = true; + +MeshToonMaterial.prototype.copy = function ( source ) { + + MeshPhongMaterial.prototype.copy.call( this, source ); + + this.gradientMap = source.gradientMap; + + return this; + +}; + + +export { MeshToonMaterial }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 6532161fb4f7ba790c2971f1fc58a3047657efc6..3b5f84d92e01ccb5c43fd8e42a190d1fb746ac49 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -1888,6 +1888,10 @@ function WebGLRenderer( parameters ) { refreshUniformsLambert( m_uniforms, material ); + } else if ( material.isMeshToonMaterial ) { + + refreshUniformsToon( m_uniforms, material ); + } else if ( material.isMeshPhongMaterial ) { refreshUniformsPhong( m_uniforms, material ); @@ -2138,6 +2142,18 @@ function WebGLRenderer( parameters ) { } + function refreshUniformsToon( uniforms, material ) { + + refreshUniformsPhong( uniforms, material ); + + if ( material.gradientMap ) { + + uniforms.gradientMap.value = material.gradientMap; + + } + + } + function refreshUniformsStandard( uniforms, material ) { uniforms.roughness.value = material.roughness; diff --git a/src/renderers/shaders/ShaderChunk.js b/src/renderers/shaders/ShaderChunk.js index 6475807142573289563bec2d65f59ef53d338b6f..f3f27c78c9deb6d9bdd13ace638dc5c1201dee41 100644 --- a/src/renderers/shaders/ShaderChunk.js +++ b/src/renderers/shaders/ShaderChunk.js @@ -30,6 +30,7 @@ import envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl'; import envmap_vertex from './ShaderChunk/envmap_vertex.glsl'; import fog_fragment from './ShaderChunk/fog_fragment.glsl'; import fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl'; +import gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl'; import lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl'; import lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl'; import lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl'; @@ -138,6 +139,7 @@ export var ShaderChunk = { envmap_vertex: envmap_vertex, fog_fragment: fog_fragment, fog_pars_fragment: fog_pars_fragment, + gradientmap_pars_fragment: gradientmap_pars_fragment, lightmap_fragment: lightmap_fragment, lightmap_pars_fragment: lightmap_pars_fragment, lights_lambert_vertex: lights_lambert_vertex, diff --git a/src/renderers/shaders/ShaderChunk/common.glsl b/src/renderers/shaders/ShaderChunk/common.glsl index 4556cdcb62c19709e01016dd6b4586108eb47075..20e7d3c9f13ddf708e62f3f801ec329c26f2882b 100644 --- a/src/renderers/shaders/ShaderChunk/common.glsl +++ b/src/renderers/shaders/ShaderChunk/common.glsl @@ -73,19 +73,13 @@ vec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 poi } -float gaussianPdf(in float x, in float sigma) { - - return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma; - -} - mat3 transpose( const in mat3 v ) { - mat3 tmp; - tmp[0] = vec3(v[0].x, v[1].x, v[2].x); - tmp[1] = vec3(v[0].y, v[1].y, v[2].y); - tmp[2] = vec3(v[0].z, v[1].z, v[2].z); + mat3 tmp; + tmp[0] = vec3(v[0].x, v[1].x, v[2].x); + tmp[1] = vec3(v[0].y, v[1].y, v[2].y); + tmp[2] = vec3(v[0].z, v[1].z, v[2].z); - return tmp; + return tmp; } diff --git a/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl b/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl new file mode 100644 index 0000000000000000000000000000000000000000..c8332bae36558f558927a26e8fdc8572dc4f92c6 --- /dev/null +++ b/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl @@ -0,0 +1,24 @@ +#ifdef TOON + + uniform sampler2D gradientMap; + + vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + + // dotNL will be from -1.0 to 1.0 + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + + #ifdef USE_GRADIENTMAP + + return texture2D( gradientMap, coord ).rgb; + + #else + + return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); + + #endif + + + } + +#endif diff --git a/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl b/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl index fa482b7a5ecf1e5895d652ea1aba9abc01652f56..b0675ede53de4c7dca8d9f2cb6f9ba3b0ec63be8 100644 --- a/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl +++ b/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl @@ -44,9 +44,16 @@ struct BlinnPhongMaterial { void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { - float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + #ifdef TOON - vec3 irradiance = dotNL * directLight.color; + vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; + + #else + + float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + + #endif #ifndef PHYSICALLY_CORRECT_LIGHTS diff --git a/src/renderers/shaders/ShaderLib.js b/src/renderers/shaders/ShaderLib.js index 9e072532b05e0ab754828e37e627b07c53ffbc39..99d7baf54723d183224939f56b9432888c324df0 100644 --- a/src/renderers/shaders/ShaderLib.js +++ b/src/renderers/shaders/ShaderLib.js @@ -54,6 +54,7 @@ var ShaderLib = { UniformsLib.bumpmap, UniformsLib.normalmap, UniformsLib.displacementmap, + UniformsLib.gradientmap, UniformsLib.fog, UniformsLib.lights, { diff --git a/src/renderers/shaders/ShaderLib/meshphong_frag.glsl b/src/renderers/shaders/ShaderLib/meshphong_frag.glsl index 5041e7a5f1949eaf701862414685e86c4b5742c5..4b909fc5de8f4e47532401c130429c5af75eea21 100644 --- a/src/renderers/shaders/ShaderLib/meshphong_frag.glsl +++ b/src/renderers/shaders/ShaderLib/meshphong_frag.glsl @@ -17,6 +17,7 @@ uniform float opacity; #include #include #include +#include #include #include #include diff --git a/src/renderers/shaders/UniformsLib.js b/src/renderers/shaders/UniformsLib.js index da13dcdc05417d4d80994865e01f582b971653ba..67bda13c7e57ba032b251084d1234e26803e6939 100644 --- a/src/renderers/shaders/UniformsLib.js +++ b/src/renderers/shaders/UniformsLib.js @@ -81,6 +81,12 @@ var UniformsLib = { }, + gradientmap: { + + gradientMap: { value: null } + + }, + fog: { fogDensity: { value: 0.00025 }, @@ -147,19 +153,12 @@ var UniformsLib = { } }, // TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src - rectAreaLights: { type: "sa", value: [], properties: { - color: { type: "c" }, - position: { type: "v3" }, - width: { type: "v3" }, - height: { type: "v3" }, + rectAreaLights: { value: [], properties: { + color: {}, + position: {}, + width: {}, + height: {}, } } - // rectAreaLights: { type: "sa", value: [], properties: { - // color: { type: "c" }, - // position: { type: "v3" }, - // width: { type: "1f" }, - // height: { type: "1f" }, - // rotationMatrix: { type: "m4" } - // } }, }, diff --git a/src/renderers/webgl/WebGLProgram.js b/src/renderers/webgl/WebGLProgram.js index 7c7283dc16c8f3dd2afbee23845808a9916f6dde..5084139b0084d6342732d201ba0020b7f064861c 100644 --- a/src/renderers/webgl/WebGLProgram.js +++ b/src/renderers/webgl/WebGLProgram.js @@ -446,6 +446,8 @@ function WebGLProgram( renderer, code, material, parameters ) { parameters.alphaMap ? '#define USE_ALPHAMAP' : '', parameters.vertexColors ? '#define USE_COLOR' : '', + parameters.gradientMap ? '#define USE_GRADIENTMAP' : '', + parameters.flatShading ? '#define FLAT_SHADED' : '', parameters.doubleSided ? '#define DOUBLE_SIDED' : '', diff --git a/src/renderers/webgl/WebGLPrograms.js b/src/renderers/webgl/WebGLPrograms.js index 065b7aeecfef80263a92f61836542744b3047126..f15d6d856cb98dba09b4e99b6e72160c3c1353c5 100644 --- a/src/renderers/webgl/WebGLPrograms.js +++ b/src/renderers/webgl/WebGLPrograms.js @@ -15,6 +15,7 @@ function WebGLPrograms( renderer, capabilities ) { MeshBasicMaterial: 'basic', MeshLambertMaterial: 'lambert', MeshPhongMaterial: 'phong', + MeshToonMaterial: 'phong', MeshStandardMaterial: 'physical', MeshPhysicalMaterial: 'physical', LineBasicMaterial: 'basic', @@ -25,7 +26,7 @@ function WebGLPrograms( renderer, capabilities ) { var parameterNames = [ "precision", "supportsVertexTextures", "map", "mapEncoding", "envMap", "envMapMode", "envMapEncoding", "lightMap", "aoMap", "emissiveMap", "emissiveMapEncoding", "bumpMap", "normalMap", "displacementMap", "specularMap", - "roughnessMap", "metalnessMap", + "roughnessMap", "metalnessMap", "gradientMap", "alphaMap", "combine", "vertexColors", "fog", "useFog", "fogExp", "flatShading", "sizeAttenuation", "logarithmicDepthBuffer", "skinning", "maxBones", "useVertexTexture", "morphTargets", "morphNormals", @@ -153,6 +154,8 @@ function WebGLPrograms( renderer, capabilities ) { specularMap: !! material.specularMap, alphaMap: !! material.alphaMap, + gradientMap: !! material.gradientMap, + combine: material.combine, vertexColors: material.vertexColors, diff --git a/src/textures/Texture.js b/src/textures/Texture.js index 09865d60c0d17b999d8a79f03cd1a9a3a416cc71..6ba19df225ac01c85dbef606a5bcf80398dfd851 100644 --- a/src/textures/Texture.js +++ b/src/textures/Texture.js @@ -10,9 +10,11 @@ import { Vector2 } from '../math/Vector2'; * @author szimek / https://github.com/szimek/ */ +var textureId = 0; + function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { - Object.defineProperty( this, 'id', { value: TextureIdCount() } ); + Object.defineProperty( this, 'id', { value: textureId ++ } ); this.uuid = _Math.generateUUID(); @@ -47,7 +49,7 @@ function Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, ty // // Also changing the encoding after already used by a Material will not automatically make the Material // update. You need to explicitly call Material.needsUpdate to trigger it to recompile. - this.encoding = encoding !== undefined ? encoding : LinearEncoding; + this.encoding = encoding !== undefined ? encoding : LinearEncoding; this.version = 0; this.onUpdate = null; @@ -102,10 +104,6 @@ Texture.prototype = { this.unpackAlignment = source.unpackAlignment; this.encoding = source.encoding; - // TODO (abelnation): this was added as something causes texture constants to be "copied" before they are properly uploaded to GPU - this.needsUpdate = source.needsUpdate; - this.version = source.version; - return this; }, @@ -210,7 +208,7 @@ Texture.prototype = { transformUv: function ( uv ) { - if ( this.mapping !== UVMapping ) return; + if ( this.mapping !== UVMapping ) return; uv.multiply( this.repeat ); uv.add( this.offset ); @@ -289,8 +287,4 @@ Texture.prototype = { Object.assign( Texture.prototype, EventDispatcher.prototype ); -var count = 0; -function TextureIdCount() { return count++; }; - - -export { TextureIdCount, Texture }; +export { Texture }; diff --git a/test/unit/editor/CommonUtilities.js b/test/unit/editor/CommonUtilities.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestAddObjectCommandAndRemoveObjectCommand.js b/test/unit/editor/TestAddObjectCommandAndRemoveObjectCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestAddScriptCommand.js b/test/unit/editor/TestAddScriptCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestMoveObjectCommand.js b/test/unit/editor/TestMoveObjectCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestNestedDoUndoRedo.js b/test/unit/editor/TestNestedDoUndoRedo.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestRemoveScriptCommand.js b/test/unit/editor/TestRemoveScriptCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSerialization.js b/test/unit/editor/TestSerialization.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetColorCommand.js b/test/unit/editor/TestSetColorCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetPositionCommand.js b/test/unit/editor/TestSetPositionCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetRotationCommand.js b/test/unit/editor/TestSetRotationCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetScaleCommand.js b/test/unit/editor/TestSetScaleCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetScriptValueCommand.js b/test/unit/editor/TestSetScriptValueCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetUuidCommand.js b/test/unit/editor/TestSetUuidCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/editor/TestSetValueCommand.js b/test/unit/editor/TestSetValueCommand.js old mode 100755 new mode 100644 diff --git a/test/unit/unittests_editor.html b/test/unit/unittests_editor.html old mode 100755 new mode 100644 diff --git a/utils/codestyle/codestyle.sh b/utils/codestyle/codestyle.sh deleted file mode 100755 index d907cf3a85a5e853a93b791154ad9144976e789c..0000000000000000000000000000000000000000 --- a/utils/codestyle/codestyle.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -jscs "../.." --fix --config=./config.json --max-errors=1000000 - diff --git a/utils/codestyle/config.json b/utils/codestyle/config.json deleted file mode 100644 index 5ba4377f2dfcf469376c353807927ce13de144a8..0000000000000000000000000000000000000000 --- a/utils/codestyle/config.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "preset": "mdcs", - "disallowSpaceAfterPrefixUnaryOperators": ["+", "-"], - "disallowNewlineBeforeBlockStatements": true, - "requireSpaceAfterBinaryOperators": [","], - "disallowKeywordsOnNewLine": ["else"], - "excludeFiles": [ - "../../.c9/", - "../../.c9version/", - "../../.git/", - "../../build/", - "../../docs/", - "../../editor/", - "../../node_modules/", - "../../test/", - "../../utils/", - "../../examples/files/", - "../../examples/fonts/", - "../../examples/models/", - "../../examples/obj/", - "../../examples/scenes/", - "../../examples/sounds/", - "../../examples/textures/", - "../../examples/js/libs/", - "../../examples/js/loaders/ctm/", - "../../examples/js/loaders/gltf/", - "../../examples/js/loaders/sea3d/", - "../../examples/js/ImprovedNoise.js", - "../../examples/js/SimplexNoise.js", - "../../examples/js/loaders/UTF8Loader.js" - ] -} diff --git a/utils/converters/fbx/LICENSE b/utils/converters/fbx/LICENSE old mode 100755 new mode 100644 diff --git a/utils/converters/fbx/README.md b/utils/converters/fbx/README.md old mode 100755 new mode 100644 diff --git a/utils/converters/fbx/convert_to_threejs.py b/utils/converters/fbx/convert_to_threejs.py old mode 100755 new mode 100644 diff --git a/utils/converters/msgpack/json2msgpack.py b/utils/converters/msgpack/json2msgpack.py old mode 100755 new mode 100644 diff --git a/utils/exporters/blender/addons/io_three/exporter/api/constants.py b/utils/exporters/blender/addons/io_three/exporter/api/constants.py index 4b6e0dd452363c27a8a60134140d3ee55cfe2dcd..76a4a46b2044c9062959888359051986b559ea80 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/constants.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/constants.py @@ -7,6 +7,7 @@ SPOT = 'SPOT' POINT = 'POINT' SUN = 'SUN' HEMI = 'HEMI' +AREA = 'AREA' NO_SHADOW = 'NOSHADOW' diff --git a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py index c82cd2556112629b09462c29db57f4a8601f32ca..5350d4dc5fce249a510037d09d24e3eedbab673c 100644 --- a/utils/exporters/blender/addons/io_three/exporter/api/mesh.py +++ b/utils/exporters/blender/addons/io_three/exporter/api/mesh.py @@ -616,7 +616,6 @@ def normals(mesh): normal_vectors = [] for vector in _normals(mesh): - vector = (vector[0], vector[2], -vector[1]) normal_vectors.extend(vector) return normal_vectors diff --git a/utils/exporters/blender/tests/scripts/exporter.py b/utils/exporters/blender/tests/scripts/exporter.py old mode 100755 new mode 100644 diff --git a/utils/exporters/max/annotate/README.md b/utils/exporters/max/annotate/README.md old mode 100755 new mode 100644 diff --git a/utils/exporters/max/annotate/annotate.py b/utils/exporters/max/annotate/annotate.py old mode 100755 new mode 100644 diff --git a/utils/exporters/maya/README.md b/utils/exporters/maya/README.md old mode 100755 new mode 100644 diff --git a/utils/exporters/maya/scripts/ThreeJsExportScript.mel b/utils/exporters/maya/scripts/ThreeJsExportScript.mel old mode 100755 new mode 100644
Uniform types