├── module ├── renderers │ ├── shaders │ │ ├── ShaderChunk │ │ │ ├── begin_vertex.glsl.js │ │ │ ├── beginnormal_vertex.glsl.js │ │ │ ├── encodings_fragment.glsl.js │ │ │ ├── color_pars_vertex.glsl.js │ │ │ ├── color_vertex.glsl.js │ │ │ ├── fog_pars_vertex.glsl.js │ │ │ ├── fog_vertex.glsl.js │ │ │ ├── map_pars_fragment.glsl.js │ │ │ ├── color_fragment.glsl.js │ │ │ ├── color_pars_fragment.glsl.js │ │ │ ├── alphamap_pars_fragment.glsl.js │ │ │ ├── uv2_vertex.glsl.js │ │ │ ├── alphatest_fragment.glsl.js │ │ │ ├── emissivemap_pars_fragment.glsl.js │ │ │ ├── specularmap_pars_fragment.glsl.js │ │ │ ├── alphamap_fragment.glsl.js │ │ │ ├── metalnessmap_pars_fragment.glsl.js │ │ │ ├── roughnessmap_pars_fragment.glsl.js │ │ │ ├── uv2_pars_fragment.glsl.js │ │ │ ├── dithering_fragment.glsl.js │ │ │ ├── map_particle_pars_fragment.glsl.js │ │ │ ├── aomap_pars_fragment.glsl.js │ │ │ ├── project_vertex.glsl.js │ │ │ ├── tonemapping_fragment.glsl.js │ │ │ ├── lightmap_pars_fragment.glsl.js │ │ │ ├── uv2_pars_vertex.glsl.js │ │ │ ├── clipping_planes_pars_vertex.glsl.js │ │ │ ├── clipping_planes_vertex.glsl.js │ │ │ ├── logdepthbuf_fragment.glsl.js │ │ │ ├── logdepthbuf_pars_fragment.glsl.js │ │ │ ├── defaultnormal_vertex.glsl.js │ │ │ ├── worldpos_vertex.glsl.js │ │ │ ├── map_fragment.glsl.js │ │ │ ├── displacementmap_pars_vertex.glsl.js │ │ │ ├── displacementmap_vertex.glsl.js │ │ │ ├── logdepthbuf_pars_vertex.glsl.js │ │ │ ├── lightmap_fragment.glsl.js │ │ │ ├── lights_phong_fragment.glsl.js │ │ │ ├── premultiplied_alpha_fragment.glsl.js │ │ │ ├── map_particle_fragment.glsl.js │ │ │ ├── morphtarget_pars_vertex.glsl.js │ │ │ ├── specularmap_fragment.glsl.js │ │ │ ├── emissivemap_fragment.glsl.js │ │ │ ├── skinbase_vertex.glsl.js │ │ │ ├── clipping_planes_pars_fragment.glsl.js │ │ │ ├── uv_pars_fragment.glsl.js │ │ │ ├── fog_pars_fragment.glsl.js │ │ │ ├── envmap_pars_vertex.glsl.js │ │ │ ├── uv_vertex.glsl.js │ │ │ ├── uv_pars_vertex.glsl.js │ │ │ ├── lights_fragment_end.glsl.js │ │ │ ├── metalnessmap_fragment.glsl.js │ │ │ ├── roughnessmap_fragment.glsl.js │ │ │ ├── logdepthbuf_vertex.glsl.js │ │ │ ├── fog_fragment.glsl.js │ │ │ ├── morphnormal_vertex.glsl.js │ │ │ ├── skinnormal_vertex.glsl.js │ │ │ ├── skinning_vertex.glsl.js │ │ │ ├── gradientmap_pars_fragment.glsl.js │ │ │ ├── aomap_fragment.glsl.js │ │ │ ├── normal_fragment_begin.glsl.js │ │ │ ├── envmap_vertex.glsl.js │ │ │ ├── lights_physical_fragment.glsl.js │ │ │ ├── dithering_pars_fragment.glsl.js │ │ │ ├── clipping_planes_fragment.glsl.js │ │ │ ├── normal_fragment_maps.glsl.js │ │ │ ├── shadowmap_pars_vertex.glsl.js │ │ │ ├── envmap_pars_fragment.glsl.js │ │ │ ├── morphtarget_vertex.glsl.js │ │ │ ├── shadowmap_vertex.glsl.js │ │ │ ├── lights_fragment_maps.glsl.js │ │ │ ├── skinning_pars_vertex.glsl.js │ │ │ ├── normalmap_pars_fragment.glsl.js │ │ │ ├── bumpmap_pars_fragment.glsl.js │ │ │ ├── packing.glsl.js │ │ │ ├── shadowmask_pars_fragment.glsl.js │ │ │ ├── lights_phong_pars_fragment.glsl.js │ │ │ ├── tonemapping_pars_fragment.glsl.js │ │ │ └── envmap_fragment.glsl.js │ │ ├── ShaderLib │ │ │ ├── background_vert.glsl.js │ │ │ ├── equirect_vert.glsl.js │ │ │ ├── shadow_vert.glsl.js │ │ │ ├── background_frag.glsl.js │ │ │ ├── cube_vert.glsl.js │ │ │ ├── shadow_frag.glsl.js │ │ │ ├── cube_frag.glsl.js │ │ │ ├── equirect_frag.glsl.js │ │ │ ├── linedashed_vert.glsl.js │ │ │ ├── normal_frag.glsl.js │ │ │ ├── sprite_frag.glsl.js │ │ │ ├── depth_vert.glsl.js │ │ │ ├── points_vert.glsl.js │ │ │ ├── distanceRGBA_frag.glsl.js │ │ │ ├── distanceRGBA_vert.glsl.js │ │ │ ├── points_frag.glsl.js │ │ │ ├── depth_frag.glsl.js │ │ │ ├── linedashed_frag.glsl.js │ │ │ ├── meshbasic_vert.glsl.js │ │ │ ├── meshmatcap_vert.glsl.js │ │ │ ├── meshlambert_vert.glsl.js │ │ │ ├── normal_vert.glsl.js │ │ │ ├── sprite_vert.glsl.js │ │ │ ├── meshphysical_vert.glsl.js │ │ │ ├── meshphong_vert.glsl.js │ │ │ ├── meshmatcap_frag.glsl.js │ │ │ ├── meshbasic_frag.glsl.js │ │ │ └── meshphong_frag.glsl.js │ │ └── UniformsUtils.js │ ├── WebGLRenderTargetCube.js │ ├── WebGLMultisampleRenderTarget.js │ └── webgl │ │ ├── WebGLProperties.js │ │ ├── WebGLObjects.js │ │ ├── WebGLAnimation.js │ │ ├── WebGLShader.js │ │ ├── WebGLBufferRenderer.js │ │ ├── WebGLIndexedBufferRenderer.js │ │ ├── WebGLInfo.js │ │ ├── WebGLExtensions.js │ │ └── WebGLRenderStates.js ├── objects │ ├── Group.js │ ├── LineLoop.js │ ├── Bone.js │ └── LineSegments.js ├── audio │ ├── AudioContext.js │ └── AudioAnalyser.js ├── cameras │ ├── ArrayCamera.js │ └── Camera.js ├── extras │ ├── curves │ │ ├── ArcCurve.js │ │ ├── Curves.js │ │ ├── LineCurve3.js │ │ ├── QuadraticBezierCurve.js │ │ ├── QuadraticBezierCurve3.js │ │ ├── LineCurve.js │ │ ├── CubicBezierCurve.js │ │ └── CubicBezierCurve3.js │ ├── objects │ │ └── ImmediateRenderObject.js │ ├── ImageUtils.js │ ├── core │ │ └── Interpolations.js │ └── ShapeUtils.js ├── core │ ├── Uniform.js │ ├── Layers.js │ ├── InstancedInterleavedBuffer.js │ ├── InstancedBufferGeometry.js │ ├── InstancedBufferAttribute.js │ ├── Clock.js │ ├── Face3.js │ ├── EventDispatcher.js │ └── InterleavedBuffer.js ├── lights │ ├── AmbientLight.js │ ├── DirectionalLightShadow.js │ ├── HemisphereLight.js │ ├── RectAreaLight.js │ ├── DirectionalLight.js │ ├── SpotLightShadow.js │ ├── LightShadow.js │ ├── Light.js │ ├── PointLight.js │ └── SpotLight.js ├── materials │ ├── RawShaderMaterial.js │ ├── ShadowMaterial.js │ ├── MeshToonMaterial.js │ ├── Materials.js │ ├── LineDashedMaterial.js │ ├── MeshPhysicalMaterial.js │ ├── SpriteMaterial.js │ ├── LineBasicMaterial.js │ ├── PointsMaterial.js │ ├── MeshDistanceMaterial.js │ └── MeshDepthMaterial.js ├── textures │ ├── CanvasTexture.js │ ├── CfxTexture.js │ ├── DataTexture.js │ ├── DataTexture3D.js │ ├── CompressedTexture.js │ ├── CubeTexture.js │ ├── VideoTexture.js │ └── DepthTexture.js ├── utils.js ├── scenes │ ├── FogExp2.js │ ├── Fog.js │ └── Scene.js ├── loaders │ ├── Cache.js │ ├── LoaderUtils.js │ ├── AnimationLoader.js │ ├── AudioLoader.js │ ├── FontLoader.js │ ├── CubeTextureLoader.js │ ├── TextureLoader.js │ └── LoadingManager.js ├── animation │ └── tracks │ │ ├── NumberKeyframeTrack.js │ │ ├── VectorKeyframeTrack.js │ │ ├── ColorKeyframeTrack.js │ │ ├── StringKeyframeTrack.js │ │ ├── BooleanKeyframeTrack.js │ │ └── QuaternionKeyframeTrack.js ├── math │ ├── interpolants │ │ ├── DiscreteInterpolant.js │ │ ├── LinearInterpolant.js │ │ └── QuaternionLinearInterpolant.js │ ├── Cylindrical.js │ └── Spherical.js ├── helpers │ ├── AxesHelper.js │ ├── Box3Helper.js │ ├── GridHelper.js │ ├── PointLightHelper.js │ └── PlaneHelper.js ├── geometries │ ├── TetrahedronGeometry.js │ ├── OctahedronGeometry.js │ ├── ConeGeometry.js │ ├── Geometries.js │ └── IcosahedronGeometry.js ├── polyfills.js └── crop.js └── fxmanifest.lua /module/renderers/shaders/ShaderChunk/begin_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 transformed = vec3( position ); 3 | `; 4 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 objectNormal = vec3( normal ); 3 | `; 4 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | gl_FragColor = linearToOutputTexel( gl_FragColor ); 3 | `; 4 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_COLOR 3 | 4 | varying vec3 vColor; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/color_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_COLOR 3 | 4 | vColor.xyz = color.xyz; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | varying float fogDepth; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/fog_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | fogDepth = -mvPosition.z; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | uniform sampler2D map; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/color_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_COLOR 3 | 4 | diffuseColor.rgb *= vColor; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_COLOR 3 | 4 | varying vec3 vColor; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHAMAP 3 | 4 | uniform sampler2D alphaMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) 3 | 4 | vUv2 = uv2; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef ALPHATEST 3 | 4 | if ( diffuseColor.a < ALPHATEST ) discard; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_EMISSIVEMAP 3 | 4 | uniform sampler2D emissiveMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SPECULARMAP 3 | 4 | uniform sampler2D specularMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ALPHAMAP 3 | 4 | diffuseColor.a *= texture2D( alphaMap, vUv ).g; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_METALNESSMAP 3 | 4 | uniform sampler2D metalnessMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ROUGHNESSMAP 3 | 4 | uniform sampler2D roughnessMap; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) 3 | 4 | varying vec2 vUv2; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( DITHERING ) 3 | 4 | gl_FragColor.rgb = dithering( gl_FragColor.rgb ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | uniform mat3 uvTransform; 5 | uniform sampler2D map; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_AOMAP 3 | 4 | uniform sampler2D aoMap; 5 | uniform float aoMapIntensity; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/project_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 ); 3 | 4 | gl_Position = projectionMatrix * mvPosition; 5 | `; 6 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( TONE_MAPPING ) 3 | 4 | gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LIGHTMAP 3 | 4 | uniform sampler2D lightMap; 5 | uniform float lightMapIntensity; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LIGHTMAP ) || defined( USE_AOMAP ) 3 | 4 | attribute vec2 uv2; 5 | varying vec2 vUv2; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP ) 3 | varying vec3 vViewPosition; 4 | #endif 5 | `; 6 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP ) 3 | vViewPosition = - mvPosition.xyz; 4 | #endif 5 | `; 6 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) 3 | 4 | gl_FragDepthEXT = log2( vFragDepth ) * logDepthBufFC * 0.5; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT ) 3 | 4 | uniform float logDepthBufFC; 5 | varying float vFragDepth; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 transformedNormal = normalMatrix * objectNormal; 3 | 4 | #ifdef FLIP_SIDED 5 | 6 | transformedNormal = - transformedNormal; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) 3 | 4 | vec4 worldPosition = modelMatrix * vec4( transformed, 1.0 ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/map_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | vec4 texelColor = texture2D( map, vUv ); 5 | 6 | texelColor = mapTexelToLinear( texelColor ); 7 | diffuseColor *= texelColor; 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_DISPLACEMENTMAP 3 | 4 | uniform sampler2D displacementMap; 5 | uniform float displacementScale; 6 | uniform float displacementBias; 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_DISPLACEMENTMAP 3 | 4 | transformed += normalize( objectNormal ) * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias ); 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/background_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec2 vUv; 3 | uniform mat3 uvTransform; 4 | 5 | void main() { 6 | 7 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 8 | 9 | gl_Position = vec4( position.xy, 1.0, 1.0 ); 10 | 11 | } 12 | `; 13 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LOGDEPTHBUF 3 | 4 | #ifdef USE_LOGDEPTHBUF_EXT 5 | 6 | varying float vFragDepth; 7 | 8 | #else 9 | 10 | uniform float logDepthBufFC; 11 | 12 | #endif 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LIGHTMAP 3 | 4 | reflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | BlinnPhongMaterial material; 3 | material.diffuseColor = diffuseColor.rgb; 4 | material.specularColor = specular; 5 | material.specularShininess = shininess; 6 | material.specularStrength = specularStrength; 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef PREMULTIPLIED_ALPHA 3 | 4 | // Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation. 5 | gl_FragColor.rgb *= gl_FragColor.a; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MAP 3 | 4 | vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; 5 | vec4 mapTexel = texture2D( map, uv ); 6 | diffuseColor *= mapTexelToLinear( mapTexel ); 7 | 8 | #endif 9 | `; 10 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHTARGETS 3 | 4 | #ifndef USE_MORPHNORMALS 5 | 6 | uniform float morphTargetInfluences[ 8 ]; 7 | 8 | #else 9 | 10 | uniform float morphTargetInfluences[ 4 ]; 11 | 12 | #endif 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/equirect_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vWorldDirection; 3 | 4 | #include 5 | 6 | void main() { 7 | 8 | vWorldDirection = transformDirection( position, modelMatrix ); 9 | 10 | #include 11 | #include 12 | 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float specularStrength; 3 | 4 | #ifdef USE_SPECULARMAP 5 | 6 | vec4 texelSpecular = texture2D( specularMap, vUv ); 7 | specularStrength = texelSpecular.r; 8 | 9 | #else 10 | 11 | specularStrength = 1.0; 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_EMISSIVEMAP 3 | 4 | vec4 emissiveColor = texture2D( emissiveMap, vUv ); 5 | 6 | emissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb; 7 | 8 | totalEmissiveRadiance *= emissiveColor.rgb; 9 | 10 | #endif 11 | `; 12 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | mat4 boneMatX = getBoneMatrix( skinIndex.x ); 5 | mat4 boneMatY = getBoneMatrix( skinIndex.y ); 6 | mat4 boneMatZ = getBoneMatrix( skinIndex.z ); 7 | mat4 boneMatW = getBoneMatrix( skinIndex.w ); 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | #if ! defined( PHYSICAL ) && ! defined( PHONG ) && ! defined( MATCAP ) 5 | varying vec3 vViewPosition; 6 | #endif 7 | 8 | uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; 9 | 10 | #endif 11 | `; 12 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/shadow_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #include 3 | #include 4 | 5 | void main() { 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | } 14 | `; 15 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) 3 | 4 | varying vec2 vUv; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | uniform vec3 fogColor; 5 | varying float fogDepth; 6 | 7 | #ifdef FOG_EXP2 8 | 9 | uniform float fogDensity; 10 | 11 | #else 12 | 13 | uniform float fogNear; 14 | uniform float fogFar; 15 | 16 | #endif 17 | 18 | #endif 19 | `; 20 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) 5 | varying vec3 vWorldPosition; 6 | 7 | #else 8 | 9 | varying vec3 vReflect; 10 | uniform float refractionRatio; 11 | 12 | #endif 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/background_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform sampler2D t2D; 3 | 4 | varying vec2 vUv; 5 | 6 | void main() { 7 | 8 | vec4 texColor = texture2D( t2D, vUv ); 9 | 10 | gl_FragColor = mapTexelToLinear( texColor ); 11 | 12 | #include 13 | #include 14 | 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) 3 | 4 | vUv = ( uvTransform * vec3( uv, 1 ) ).xy; 5 | 6 | #endif 7 | `; 8 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP ) 3 | 4 | varying vec2 vUv; 5 | uniform mat3 uvTransform; 6 | 7 | #endif 8 | `; 9 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( RE_IndirectDiffuse ) 3 | 4 | RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight ); 5 | 6 | #endif 7 | 8 | #if defined( RE_IndirectSpecular ) 9 | 10 | RE_IndirectSpecular( radiance, clearCoatRadiance, geometry, material, reflectedLight ); 11 | 12 | #endif 13 | `; 14 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/cube_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vWorldDirection; 3 | 4 | #include 5 | 6 | void main() { 7 | 8 | vWorldDirection = transformDirection( position, modelMatrix ); 9 | 10 | #include 11 | #include 12 | 13 | gl_Position.z = gl_Position.w; // set z to camera.far 14 | 15 | } 16 | `; 17 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float metalnessFactor = metalness; 3 | 4 | #ifdef USE_METALNESSMAP 5 | 6 | vec4 texelMetalness = texture2D( metalnessMap, vUv ); 7 | 8 | // reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 9 | metalnessFactor *= texelMetalness.b; 10 | 11 | #endif 12 | `; 13 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float roughnessFactor = roughness; 3 | 4 | #ifdef USE_ROUGHNESSMAP 5 | 6 | vec4 texelRoughness = texture2D( roughnessMap, vUv ); 7 | 8 | // reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 9 | roughnessFactor *= texelRoughness.g; 10 | 11 | #endif 12 | `; 13 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_LOGDEPTHBUF 3 | 4 | #ifdef USE_LOGDEPTHBUF_EXT 5 | 6 | vFragDepth = 1.0 + gl_Position.w; 7 | 8 | #else 9 | 10 | gl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0; 11 | 12 | gl_Position.z *= gl_Position.w; 13 | 14 | #endif 15 | 16 | #endif 17 | `; 18 | -------------------------------------------------------------------------------- /module/objects/Group.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | */ 6 | 7 | function Group() { 8 | 9 | Object3D.call( this ); 10 | 11 | this.type = 'Group'; 12 | 13 | } 14 | 15 | Group.prototype = Object.assign( Object.create( Object3D.prototype ), { 16 | 17 | constructor: Group, 18 | 19 | isGroup: true 20 | 21 | } ); 22 | 23 | 24 | export { Group }; 25 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/fog_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_FOG 3 | 4 | #ifdef FOG_EXP2 5 | 6 | float fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * fogDepth * fogDepth * LOG2 ) ); 7 | 8 | #else 9 | 10 | float fogFactor = smoothstep( fogNear, fogFar, fogDepth ); 11 | 12 | #endif 13 | 14 | gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor ); 15 | 16 | #endif 17 | `; 18 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHNORMALS 3 | 4 | objectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ]; 5 | objectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ]; 6 | objectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ]; 7 | objectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ]; 8 | 9 | #endif 10 | `; 11 | -------------------------------------------------------------------------------- /module/objects/LineLoop.js: -------------------------------------------------------------------------------- 1 | import { Line } from './Line.js'; 2 | 3 | /** 4 | * @author mgreter / http://github.com/mgreter 5 | */ 6 | 7 | function LineLoop( geometry, material ) { 8 | 9 | Line.call( this, geometry, material ); 10 | 11 | this.type = 'LineLoop'; 12 | 13 | } 14 | 15 | LineLoop.prototype = Object.assign( Object.create( Line.prototype ), { 16 | 17 | constructor: LineLoop, 18 | 19 | isLineLoop: true, 20 | 21 | } ); 22 | 23 | 24 | export { LineLoop }; 25 | -------------------------------------------------------------------------------- /module/audio/AudioContext.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | var context; 6 | 7 | var AudioContext = { 8 | 9 | getContext: function () { 10 | 11 | if ( context === undefined ) { 12 | 13 | context = new ( window.AudioContext || window.webkitAudioContext )(); 14 | 15 | } 16 | 17 | return context; 18 | 19 | }, 20 | 21 | setContext: function ( value ) { 22 | 23 | context = value; 24 | 25 | } 26 | 27 | }; 28 | 29 | export { AudioContext }; 30 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | mat4 skinMatrix = mat4( 0.0 ); 5 | skinMatrix += skinWeight.x * boneMatX; 6 | skinMatrix += skinWeight.y * boneMatY; 7 | skinMatrix += skinWeight.z * boneMatZ; 8 | skinMatrix += skinWeight.w * boneMatW; 9 | skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; 10 | 11 | objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; 12 | 13 | #endif 14 | `; 15 | -------------------------------------------------------------------------------- /module/cameras/ArrayCamera.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { PerspectiveCamera } from './PerspectiveCamera.js'; 6 | 7 | function ArrayCamera( array ) { 8 | 9 | PerspectiveCamera.call( this ); 10 | 11 | this.cameras = array || []; 12 | 13 | } 14 | 15 | ArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), { 16 | 17 | constructor: ArrayCamera, 18 | 19 | isArrayCamera: true 20 | 21 | } ); 22 | 23 | 24 | export { ArrayCamera }; 25 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/shadow_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform vec3 color; 3 | uniform float opacity; 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void main() { 14 | 15 | gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); 16 | 17 | #include 18 | 19 | } 20 | `; 21 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/cube_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform samplerCube tCube; 3 | uniform float tFlip; 4 | uniform float opacity; 5 | 6 | varying vec3 vWorldDirection; 7 | 8 | void main() { 9 | 10 | vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); 11 | 12 | gl_FragColor = mapTexelToLinear( texColor ); 13 | gl_FragColor.a *= opacity; 14 | 15 | #include 16 | #include 17 | 18 | } 19 | `; 20 | -------------------------------------------------------------------------------- /module/extras/curves/ArcCurve.js: -------------------------------------------------------------------------------- 1 | import { EllipseCurve } from './EllipseCurve.js'; 2 | 3 | 4 | function ArcCurve( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) { 5 | 6 | EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise ); 7 | 8 | this.type = 'ArcCurve'; 9 | 10 | } 11 | 12 | ArcCurve.prototype = Object.create( EllipseCurve.prototype ); 13 | ArcCurve.prototype.constructor = ArcCurve; 14 | 15 | ArcCurve.prototype.isArcCurve = true; 16 | 17 | 18 | export { ArcCurve }; 19 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); 5 | 6 | vec4 skinned = vec4( 0.0 ); 7 | skinned += boneMatX * skinVertex * skinWeight.x; 8 | skinned += boneMatY * skinVertex * skinWeight.y; 9 | skinned += boneMatZ * skinVertex * skinWeight.z; 10 | skinned += boneMatW * skinVertex * skinWeight.w; 11 | 12 | transformed = ( bindMatrixInverse * skinned ).xyz; 13 | 14 | #endif 15 | `; 16 | -------------------------------------------------------------------------------- /module/core/Uniform.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function Uniform( value ) { 6 | 7 | if ( typeof value === 'string' ) { 8 | 9 | console.warn( 'THREE.Uniform: Type parameter is no longer needed.' ); 10 | value = arguments[ 1 ]; 11 | 12 | } 13 | 14 | this.value = value; 15 | 16 | } 17 | 18 | Uniform.prototype.clone = function () { 19 | 20 | return new Uniform( this.value.clone === undefined ? this.value : this.value.clone() ); 21 | 22 | }; 23 | 24 | export { Uniform }; 25 | -------------------------------------------------------------------------------- /module/objects/Bone.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | /** 4 | * @author mikael emtinger / http://gomo.se/ 5 | * @author alteredq / http://alteredqualia.com/ 6 | * @author ikerr / http://verold.com 7 | */ 8 | 9 | function Bone() { 10 | 11 | Object3D.call( this ); 12 | 13 | this.type = 'Bone'; 14 | 15 | } 16 | 17 | Bone.prototype = Object.assign( Object.create( Object3D.prototype ), { 18 | 19 | constructor: Bone, 20 | 21 | isBone: true 22 | 23 | } ); 24 | 25 | 26 | export { Bone }; 27 | -------------------------------------------------------------------------------- /module/lights/AmbientLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | */ 6 | 7 | function AmbientLight( color, intensity ) { 8 | 9 | Light.call( this, color, intensity ); 10 | 11 | this.type = 'AmbientLight'; 12 | 13 | this.castShadow = undefined; 14 | 15 | } 16 | 17 | AmbientLight.prototype = Object.assign( Object.create( Light.prototype ), { 18 | 19 | constructor: AmbientLight, 20 | 21 | isAmbientLight: true 22 | 23 | } ); 24 | 25 | 26 | export { AmbientLight }; 27 | -------------------------------------------------------------------------------- /module/materials/RawShaderMaterial.js: -------------------------------------------------------------------------------- 1 | import { ShaderMaterial } from './ShaderMaterial.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | */ 6 | 7 | function RawShaderMaterial( parameters ) { 8 | 9 | ShaderMaterial.call( this, parameters ); 10 | 11 | this.type = 'RawShaderMaterial'; 12 | 13 | } 14 | 15 | RawShaderMaterial.prototype = Object.create( ShaderMaterial.prototype ); 16 | RawShaderMaterial.prototype.constructor = RawShaderMaterial; 17 | 18 | RawShaderMaterial.prototype.isRawShaderMaterial = true; 19 | 20 | 21 | export { RawShaderMaterial }; 22 | -------------------------------------------------------------------------------- /module/lights/DirectionalLightShadow.js: -------------------------------------------------------------------------------- 1 | import { LightShadow } from './LightShadow.js'; 2 | import { OrthographicCamera } from '../cameras/OrthographicCamera.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | */ 7 | 8 | function DirectionalLightShadow( ) { 9 | 10 | LightShadow.call( this, new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) ); 11 | 12 | } 13 | 14 | DirectionalLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), { 15 | 16 | constructor: DirectionalLightShadow 17 | 18 | } ); 19 | 20 | 21 | export { DirectionalLightShadow }; 22 | -------------------------------------------------------------------------------- /module/extras/curves/Curves.js: -------------------------------------------------------------------------------- 1 | export { ArcCurve } from './ArcCurve.js'; 2 | export { CatmullRomCurve3 } from './CatmullRomCurve3.js'; 3 | export { CubicBezierCurve } from './CubicBezierCurve.js'; 4 | export { CubicBezierCurve3 } from './CubicBezierCurve3.js'; 5 | export { EllipseCurve } from './EllipseCurve.js'; 6 | export { LineCurve } from './LineCurve.js'; 7 | export { LineCurve3 } from './LineCurve3.js'; 8 | export { QuadraticBezierCurve } from './QuadraticBezierCurve.js'; 9 | export { QuadraticBezierCurve3 } from './QuadraticBezierCurve3.js'; 10 | export { SplineCurve } from './SplineCurve.js'; 11 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef TOON 3 | 4 | uniform sampler2D gradientMap; 5 | 6 | vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { 7 | 8 | // dotNL will be from -1.0 to 1.0 9 | float dotNL = dot( normal, lightDirection ); 10 | vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); 11 | 12 | #ifdef USE_GRADIENTMAP 13 | 14 | return texture2D( gradientMap, coord ).rgb; 15 | 16 | #else 17 | 18 | return ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 ); 19 | 20 | #endif 21 | 22 | 23 | } 24 | 25 | #endif 26 | `; 27 | -------------------------------------------------------------------------------- /module/textures/CanvasTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | 7 | function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { 8 | 9 | Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 10 | 11 | this.needsUpdate = true; 12 | 13 | } 14 | 15 | CanvasTexture.prototype = Object.create( Texture.prototype ); 16 | CanvasTexture.prototype.constructor = CanvasTexture; 17 | CanvasTexture.prototype.isCanvasTexture = true; 18 | 19 | export { CanvasTexture }; 20 | -------------------------------------------------------------------------------- /module/extras/objects/ImmediateRenderObject.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../../core/Object3D.js'; 2 | 3 | /** 4 | * @author alteredq / http://alteredqualia.com/ 5 | */ 6 | 7 | function ImmediateRenderObject( material ) { 8 | 9 | Object3D.call( this ); 10 | 11 | this.material = material; 12 | this.render = function ( /* renderCallback */ ) {}; 13 | 14 | } 15 | 16 | ImmediateRenderObject.prototype = Object.create( Object3D.prototype ); 17 | ImmediateRenderObject.prototype.constructor = ImmediateRenderObject; 18 | 19 | ImmediateRenderObject.prototype.isImmediateRenderObject = true; 20 | 21 | 22 | export { ImmediateRenderObject }; 23 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_AOMAP 3 | 4 | // reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture 5 | float ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0; 6 | 7 | reflectedLight.indirectDiffuse *= ambientOcclusion; 8 | 9 | #if defined( USE_ENVMAP ) && defined( PHYSICAL ) 10 | 11 | float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) ); 12 | 13 | reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness ); 14 | 15 | #endif 16 | 17 | #endif 18 | `; 19 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef FLAT_SHADED 3 | 4 | // Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ... 5 | 6 | vec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) ); 7 | vec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) ); 8 | vec3 normal = normalize( cross( fdx, fdy ) ); 9 | 10 | #else 11 | 12 | vec3 normal = normalize( vNormal ); 13 | 14 | #ifdef DOUBLE_SIDED 15 | 16 | normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); 17 | 18 | #endif 19 | 20 | #endif 21 | `; 22 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/equirect_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform sampler2D tEquirect; 3 | 4 | varying vec3 vWorldDirection; 5 | 6 | #include 7 | 8 | void main() { 9 | 10 | vec3 direction = normalize( vWorldDirection ); 11 | 12 | vec2 sampleUV; 13 | 14 | sampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 15 | 16 | sampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5; 17 | 18 | vec4 texColor = texture2D( tEquirect, sampleUV ); 19 | 20 | gl_FragColor = mapTexelToLinear( texColor ); 21 | 22 | #include 23 | #include 24 | 25 | } 26 | `; 27 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) 5 | 6 | vWorldPosition = worldPosition.xyz; 7 | 8 | #else 9 | 10 | vec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); 11 | 12 | vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix ); 13 | 14 | #ifdef ENVMAP_MODE_REFLECTION 15 | 16 | vReflect = reflect( cameraToVertex, worldNormal ); 17 | 18 | #else 19 | 20 | vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); 21 | 22 | #endif 23 | 24 | #endif 25 | 26 | #endif 27 | `; 28 | -------------------------------------------------------------------------------- /module/utils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function arrayMin( array ) { 6 | 7 | if ( array.length === 0 ) return Infinity; 8 | 9 | var min = array[ 0 ]; 10 | 11 | for ( var i = 1, l = array.length; i < l; ++ i ) { 12 | 13 | if ( array[ i ] < min ) min = array[ i ]; 14 | 15 | } 16 | 17 | return min; 18 | 19 | } 20 | 21 | function arrayMax( array ) { 22 | 23 | if ( array.length === 0 ) return - Infinity; 24 | 25 | var max = array[ 0 ]; 26 | 27 | for ( var i = 1, l = array.length; i < l; ++ i ) { 28 | 29 | if ( array[ i ] > max ) max = array[ i ]; 30 | 31 | } 32 | 33 | return max; 34 | 35 | } 36 | 37 | export { arrayMin, arrayMax }; 38 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | PhysicalMaterial material; 3 | material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor ); 4 | material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 ); 5 | #ifdef STANDARD 6 | material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor ); 7 | #else 8 | material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor ); 9 | material.clearCoat = saturate( clearCoat ); // Burley clearcoat model 10 | material.clearCoatRoughness = clamp( clearCoatRoughness, 0.04, 1.0 ); 11 | #endif 12 | `; 13 | -------------------------------------------------------------------------------- /module/renderers/WebGLRenderTargetCube.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderTarget } from './WebGLRenderTarget.js'; 2 | 3 | /** 4 | * @author alteredq / http://alteredqualia.com 5 | */ 6 | 7 | function WebGLRenderTargetCube( width, height, options ) { 8 | 9 | WebGLRenderTarget.call( this, width, height, options ); 10 | 11 | this.activeCubeFace = 0; // PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5 12 | this.activeMipMapLevel = 0; 13 | 14 | } 15 | 16 | WebGLRenderTargetCube.prototype = Object.create( WebGLRenderTarget.prototype ); 17 | WebGLRenderTargetCube.prototype.constructor = WebGLRenderTargetCube; 18 | 19 | WebGLRenderTargetCube.prototype.isWebGLRenderTargetCube = true; 20 | 21 | 22 | export { WebGLRenderTargetCube }; 23 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/linedashed_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform float scale; 3 | attribute float lineDistance; 4 | 5 | varying float vLineDistance; 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void main() { 14 | 15 | #include 16 | 17 | vLineDistance = scale * lineDistance; 18 | 19 | vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); 20 | gl_Position = projectionMatrix * mvPosition; 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | } 27 | `; 28 | -------------------------------------------------------------------------------- /module/core/Layers.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function Layers() { 6 | 7 | this.mask = 1 | 0; 8 | 9 | } 10 | 11 | Object.assign( Layers.prototype, { 12 | 13 | set: function ( channel ) { 14 | 15 | this.mask = 1 << channel | 0; 16 | 17 | }, 18 | 19 | enable: function ( channel ) { 20 | 21 | this.mask |= 1 << channel | 0; 22 | 23 | }, 24 | 25 | toggle: function ( channel ) { 26 | 27 | this.mask ^= 1 << channel | 0; 28 | 29 | }, 30 | 31 | disable: function ( channel ) { 32 | 33 | this.mask &= ~ ( 1 << channel | 0 ); 34 | 35 | }, 36 | 37 | test: function ( layers ) { 38 | 39 | return ( this.mask & layers.mask ) !== 0; 40 | 41 | } 42 | 43 | } ); 44 | 45 | 46 | export { Layers }; 47 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( DITHERING ) 3 | 4 | // based on https://www.shadertoy.com/view/MslGR8 5 | vec3 dithering( vec3 color ) { 6 | //Calculate grid position 7 | float grid_position = rand( gl_FragCoord.xy ); 8 | 9 | //Shift the individual colors differently, thus making it even harder to see the dithering pattern 10 | vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 ); 11 | 12 | //modify shift acording to grid position. 13 | dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position ); 14 | 15 | //shift the color by dither_shift 16 | return color + dither_shift_RGB; 17 | } 18 | 19 | #endif 20 | `; 21 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if NUM_CLIPPING_PLANES > 0 3 | 4 | vec4 plane; 5 | 6 | #pragma unroll_loop 7 | for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { 8 | 9 | plane = clippingPlanes[ i ]; 10 | if ( dot( vViewPosition, plane.xyz ) > plane.w ) discard; 11 | 12 | } 13 | 14 | #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES 15 | 16 | bool clipped = true; 17 | 18 | #pragma unroll_loop 19 | for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { 20 | 21 | plane = clippingPlanes[ i ]; 22 | clipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped; 23 | 24 | } 25 | 26 | if ( clipped ) discard; 27 | 28 | #endif 29 | 30 | #endif 31 | `; 32 | -------------------------------------------------------------------------------- /module/scenes/FogExp2.js: -------------------------------------------------------------------------------- 1 | import { Color } from '../math/Color.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | * @author alteredq / http://alteredqualia.com/ 6 | */ 7 | 8 | function FogExp2( color, density ) { 9 | 10 | this.name = ''; 11 | 12 | this.color = new Color( color ); 13 | this.density = ( density !== undefined ) ? density : 0.00025; 14 | 15 | } 16 | 17 | FogExp2.prototype.isFogExp2 = true; 18 | 19 | FogExp2.prototype.clone = function () { 20 | 21 | return new FogExp2( this.color, this.density ); 22 | 23 | }; 24 | 25 | FogExp2.prototype.toJSON = function ( /* meta */ ) { 26 | 27 | return { 28 | type: 'FogExp2', 29 | color: this.color.getHex(), 30 | density: this.density 31 | }; 32 | 33 | }; 34 | 35 | export { FogExp2 }; 36 | -------------------------------------------------------------------------------- /module/loaders/Cache.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | var Cache = { 6 | 7 | enabled: false, 8 | 9 | files: {}, 10 | 11 | add: function ( key, file ) { 12 | 13 | if ( this.enabled === false ) return; 14 | 15 | // console.log( 'THREE.Cache', 'Adding key:', key ); 16 | 17 | this.files[ key ] = file; 18 | 19 | }, 20 | 21 | get: function ( key ) { 22 | 23 | if ( this.enabled === false ) return; 24 | 25 | // console.log( 'THREE.Cache', 'Checking key:', key ); 26 | 27 | return this.files[ key ]; 28 | 29 | }, 30 | 31 | remove: function ( key ) { 32 | 33 | delete this.files[ key ]; 34 | 35 | }, 36 | 37 | clear: function () { 38 | 39 | this.files = {}; 40 | 41 | } 42 | 43 | }; 44 | 45 | 46 | export { Cache }; 47 | -------------------------------------------------------------------------------- /module/animation/tracks/NumberKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * 5 | * A Track of numeric keyframe values. 6 | * 7 | * @author Ben Houston / http://clara.io/ 8 | * @author David Sarno / http://lighthaus.us/ 9 | * @author tschw 10 | */ 11 | 12 | function NumberKeyframeTrack( name, times, values, interpolation ) { 13 | 14 | KeyframeTrack.call( this, name, times, values, interpolation ); 15 | 16 | } 17 | 18 | NumberKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 19 | 20 | constructor: NumberKeyframeTrack, 21 | 22 | ValueTypeName: 'number' 23 | 24 | // ValueBufferType is inherited 25 | 26 | // DefaultInterpolation is inherited 27 | 28 | } ); 29 | 30 | export { NumberKeyframeTrack }; 31 | -------------------------------------------------------------------------------- /module/animation/tracks/VectorKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * 5 | * A Track of vectored keyframe values. 6 | * 7 | * 8 | * @author Ben Houston / http://clara.io/ 9 | * @author David Sarno / http://lighthaus.us/ 10 | * @author tschw 11 | */ 12 | 13 | function VectorKeyframeTrack( name, times, values, interpolation ) { 14 | 15 | KeyframeTrack.call( this, name, times, values, interpolation ); 16 | 17 | } 18 | 19 | VectorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 20 | 21 | constructor: VectorKeyframeTrack, 22 | 23 | ValueTypeName: 'vector' 24 | 25 | // ValueBufferType is inherited 26 | 27 | // DefaultInterpolation is inherited 28 | 29 | } ); 30 | 31 | export { VectorKeyframeTrack }; 32 | -------------------------------------------------------------------------------- /module/math/interpolants/DiscreteInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | 3 | /** 4 | * 5 | * Interpolant that evaluates to the sample value at the position preceeding 6 | * the parameter. 7 | * 8 | * @author tschw 9 | */ 10 | 11 | function DiscreteInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 12 | 13 | Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); 14 | 15 | } 16 | 17 | DiscreteInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), { 18 | 19 | constructor: DiscreteInterpolant, 20 | 21 | interpolate_: function ( i1 /*, t0, t, t1 */ ) { 22 | 23 | return this.copySampleValue_( i1 - 1 ); 24 | 25 | } 26 | 27 | } ); 28 | 29 | 30 | export { DiscreteInterpolant }; 31 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_NORMALMAP 3 | 4 | #ifdef OBJECTSPACE_NORMALMAP 5 | 6 | normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals 7 | 8 | #ifdef FLIP_SIDED 9 | 10 | normal = - normal; 11 | 12 | #endif 13 | 14 | #ifdef DOUBLE_SIDED 15 | 16 | normal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 ); 17 | 18 | #endif 19 | 20 | normal = normalize( normalMatrix * normal ); 21 | 22 | #else // tangent-space normal map 23 | 24 | normal = perturbNormal2Arb( -vViewPosition, normal ); 25 | 26 | #endif 27 | 28 | #elif defined( USE_BUMPMAP ) 29 | 30 | normal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() ); 31 | 32 | #endif 33 | `; 34 | -------------------------------------------------------------------------------- /module/scenes/Fog.js: -------------------------------------------------------------------------------- 1 | import { Color } from '../math/Color.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | * @author alteredq / http://alteredqualia.com/ 6 | */ 7 | 8 | function Fog( color, near, far ) { 9 | 10 | this.name = ''; 11 | 12 | this.color = new Color( color ); 13 | 14 | this.near = ( near !== undefined ) ? near : 1; 15 | this.far = ( far !== undefined ) ? far : 1000; 16 | 17 | } 18 | 19 | Fog.prototype.isFog = true; 20 | 21 | Fog.prototype.clone = function () { 22 | 23 | return new Fog( this.color, this.near, this.far ); 24 | 25 | }; 26 | 27 | Fog.prototype.toJSON = function ( /* meta */ ) { 28 | 29 | return { 30 | type: 'Fog', 31 | color: this.color.getHex(), 32 | near: this.near, 33 | far: this.far 34 | }; 35 | 36 | }; 37 | 38 | export { Fog }; 39 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SHADOWMAP 3 | 4 | #if NUM_DIR_LIGHTS > 0 5 | 6 | uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ]; 7 | varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ]; 8 | 9 | #endif 10 | 11 | #if NUM_SPOT_LIGHTS > 0 12 | 13 | uniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ]; 14 | varying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ]; 15 | 16 | #endif 17 | 18 | #if NUM_POINT_LIGHTS > 0 19 | 20 | uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ]; 21 | varying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ]; 22 | 23 | #endif 24 | 25 | /* 26 | #if NUM_RECT_AREA_LIGHTS > 0 27 | 28 | // TODO (abelnation): uniforms for area light shadows 29 | 30 | #endif 31 | */ 32 | 33 | #endif 34 | `; 35 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/normal_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define NORMAL 3 | 4 | uniform float opacity; 5 | 6 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) 7 | 8 | varying vec3 vViewPosition; 9 | 10 | #endif 11 | 12 | #ifndef FLAT_SHADED 13 | 14 | varying vec3 vNormal; 15 | 16 | #endif 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | void main() { 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | gl_FragColor = vec4( packNormalToRGB( normal ), opacity ); 31 | 32 | } 33 | `; 34 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( USE_ENVMAP ) || defined( PHYSICAL ) 3 | uniform float reflectivity; 4 | uniform float envMapIntensity; 5 | #endif 6 | 7 | #ifdef USE_ENVMAP 8 | 9 | #if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) ) 10 | varying vec3 vWorldPosition; 11 | #endif 12 | 13 | #ifdef ENVMAP_TYPE_CUBE 14 | uniform samplerCube envMap; 15 | #else 16 | uniform sampler2D envMap; 17 | #endif 18 | uniform float flipEnvMap; 19 | uniform int maxMipLevel; 20 | 21 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL ) 22 | uniform float refractionRatio; 23 | #else 24 | varying vec3 vReflect; 25 | #endif 26 | 27 | #endif 28 | `; 29 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_MORPHTARGETS 3 | 4 | transformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ]; 5 | transformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ]; 6 | transformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ]; 7 | transformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ]; 8 | 9 | #ifndef USE_MORPHNORMALS 10 | 11 | transformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ]; 12 | transformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ]; 13 | transformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ]; 14 | transformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ]; 15 | 16 | #endif 17 | 18 | #endif 19 | `; 20 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/sprite_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform vec3 diffuse; 3 | uniform float opacity; 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void main() { 13 | 14 | #include 15 | 16 | vec3 outgoingLight = vec3( 0.0 ); 17 | vec4 diffuseColor = vec4( diffuse, opacity ); 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | outgoingLight = diffuseColor.rgb; 24 | 25 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | } 32 | `; 33 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/depth_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | void main() { 11 | 12 | #include 13 | 14 | #include 15 | 16 | #ifdef USE_DISPLACEMENTMAP 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #endif 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | } 33 | `; 34 | -------------------------------------------------------------------------------- /module/core/InstancedInterleavedBuffer.js: -------------------------------------------------------------------------------- 1 | import { InterleavedBuffer } from './InterleavedBuffer.js'; 2 | 3 | /** 4 | * @author benaadams / https://twitter.com/ben_a_adams 5 | */ 6 | 7 | function InstancedInterleavedBuffer( array, stride, meshPerAttribute ) { 8 | 9 | InterleavedBuffer.call( this, array, stride ); 10 | 11 | this.meshPerAttribute = meshPerAttribute || 1; 12 | 13 | } 14 | 15 | InstancedInterleavedBuffer.prototype = Object.assign( Object.create( InterleavedBuffer.prototype ), { 16 | 17 | constructor: InstancedInterleavedBuffer, 18 | 19 | isInstancedInterleavedBuffer: true, 20 | 21 | copy: function ( source ) { 22 | 23 | InterleavedBuffer.prototype.copy.call( this, source ); 24 | 25 | this.meshPerAttribute = source.meshPerAttribute; 26 | 27 | return this; 28 | 29 | } 30 | 31 | } ); 32 | 33 | export { InstancedInterleavedBuffer }; 34 | -------------------------------------------------------------------------------- /module/renderers/WebGLMultisampleRenderTarget.js: -------------------------------------------------------------------------------- 1 | import { WebGLRenderTarget } from './WebGLRenderTarget.js'; 2 | 3 | /** 4 | * @author Mugen87 / https://github.com/Mugen87 5 | * @author Matt DesLauriers / @mattdesl 6 | */ 7 | 8 | function WebGLMultisampleRenderTarget( width, height, options ) { 9 | 10 | WebGLRenderTarget.call( this, width, height, options ); 11 | 12 | this.samples = 4; 13 | 14 | } 15 | 16 | WebGLMultisampleRenderTarget.prototype = Object.assign( Object.create( WebGLRenderTarget.prototype ), { 17 | 18 | constructor: WebGLMultisampleRenderTarget, 19 | 20 | isWebGLMultisampleRenderTarget: true, 21 | 22 | copy: function ( source ) { 23 | 24 | WebGLRenderTarget.prototype.copy.call( this, source ); 25 | 26 | this.samples = source.samples; 27 | 28 | return this; 29 | 30 | } 31 | 32 | } ); 33 | 34 | 35 | export { WebGLMultisampleRenderTarget }; 36 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLProperties.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author fordacious / fordacious.github.io 3 | */ 4 | 5 | function WebGLProperties() { 6 | 7 | var properties = new WeakMap(); 8 | 9 | function get( object ) { 10 | 11 | var map = properties.get( object ); 12 | 13 | if ( map === undefined ) { 14 | 15 | map = {}; 16 | properties.set( object, map ); 17 | 18 | } 19 | 20 | return map; 21 | 22 | } 23 | 24 | function remove( object ) { 25 | 26 | properties.delete( object ); 27 | 28 | } 29 | 30 | function update( object, key, value ) { 31 | 32 | properties.get( object )[ key ] = value; 33 | 34 | } 35 | 36 | function dispose() { 37 | 38 | properties = new WeakMap(); 39 | 40 | } 41 | 42 | return { 43 | get: get, 44 | remove: remove, 45 | update: update, 46 | dispose: dispose 47 | }; 48 | 49 | } 50 | 51 | 52 | export { WebGLProperties }; 53 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/points_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform float size; 3 | uniform float scale; 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void main() { 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | gl_PointSize = size; 20 | 21 | #ifdef USE_SIZEATTENUATION 22 | 23 | bool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); 24 | 25 | if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); 26 | 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | } 35 | `; 36 | -------------------------------------------------------------------------------- /module/audio/AudioAnalyser.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function AudioAnalyser( audio, fftSize ) { 6 | 7 | this.analyser = audio.context.createAnalyser(); 8 | this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048; 9 | 10 | this.data = new Uint8Array( this.analyser.frequencyBinCount ); 11 | 12 | audio.getOutput().connect( this.analyser ); 13 | 14 | } 15 | 16 | Object.assign( AudioAnalyser.prototype, { 17 | 18 | getFrequencyData: function () { 19 | 20 | this.analyser.getByteFrequencyData( this.data ); 21 | 22 | return this.data; 23 | 24 | }, 25 | 26 | getAverageFrequency: function () { 27 | 28 | var value = 0, data = this.getFrequencyData(); 29 | 30 | for ( var i = 0; i < data.length; i ++ ) { 31 | 32 | value += data[ i ]; 33 | 34 | } 35 | 36 | return value / data.length; 37 | 38 | } 39 | 40 | } ); 41 | 42 | export { AudioAnalyser }; 43 | -------------------------------------------------------------------------------- /module/core/InstancedBufferGeometry.js: -------------------------------------------------------------------------------- 1 | import { BufferGeometry } from './BufferGeometry.js'; 2 | 3 | /** 4 | * @author benaadams / https://twitter.com/ben_a_adams 5 | */ 6 | 7 | function InstancedBufferGeometry() { 8 | 9 | BufferGeometry.call( this ); 10 | 11 | this.type = 'InstancedBufferGeometry'; 12 | this.maxInstancedCount = undefined; 13 | 14 | } 15 | 16 | InstancedBufferGeometry.prototype = Object.assign( Object.create( BufferGeometry.prototype ), { 17 | 18 | constructor: InstancedBufferGeometry, 19 | 20 | isInstancedBufferGeometry: true, 21 | 22 | copy: function ( source ) { 23 | 24 | BufferGeometry.prototype.copy.call( this, source ); 25 | 26 | this.maxInstancedCount = source.maxInstancedCount; 27 | 28 | return this; 29 | 30 | }, 31 | 32 | clone: function () { 33 | 34 | return new this.constructor().copy( this ); 35 | 36 | } 37 | 38 | } ); 39 | 40 | export { InstancedBufferGeometry }; 41 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/distanceRGBA_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define DISTANCE 3 | 4 | uniform vec3 referencePosition; 5 | uniform float nearDistance; 6 | uniform float farDistance; 7 | varying vec3 vWorldPosition; 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void main () { 17 | 18 | #include 19 | 20 | vec4 diffuseColor = vec4( 1.0 ); 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | float dist = length( vWorldPosition - referencePosition ); 27 | dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); 28 | dist = saturate( dist ); // clamp to [ 0, 1 ] 29 | 30 | gl_FragColor = packDepthToRGBA( dist ); 31 | 32 | } 33 | `; 34 | -------------------------------------------------------------------------------- /module/animation/tracks/ColorKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { KeyframeTrack } from '../KeyframeTrack.js'; 2 | 3 | /** 4 | * 5 | * A Track of keyframe values that represent color. 6 | * 7 | * 8 | * @author Ben Houston / http://clara.io/ 9 | * @author David Sarno / http://lighthaus.us/ 10 | * @author tschw 11 | */ 12 | 13 | function ColorKeyframeTrack( name, times, values, interpolation ) { 14 | 15 | KeyframeTrack.call( this, name, times, values, interpolation ); 16 | 17 | } 18 | 19 | ColorKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 20 | 21 | constructor: ColorKeyframeTrack, 22 | 23 | ValueTypeName: 'color' 24 | 25 | // ValueBufferType is inherited 26 | 27 | // DefaultInterpolation is inherited 28 | 29 | // Note: Very basic implementation and nothing special yet. 30 | // However, this is the place for color space parameterization. 31 | 32 | } ); 33 | 34 | export { ColorKeyframeTrack }; 35 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/distanceRGBA_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define DISTANCE 3 | 4 | varying vec3 vWorldPosition; 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void main() { 14 | 15 | #include 16 | 17 | #include 18 | 19 | #ifdef USE_DISPLACEMENTMAP 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #endif 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | vWorldPosition = worldPosition.xyz; 36 | 37 | } 38 | `; 39 | -------------------------------------------------------------------------------- /module/materials/ShadowMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * 4 | * parameters = { 5 | * color: 6 | * } 7 | */ 8 | 9 | import { Material } from './Material.js'; 10 | import { Color } from '../math/Color.js'; 11 | 12 | function ShadowMaterial( parameters ) { 13 | 14 | Material.call( this ); 15 | 16 | this.type = 'ShadowMaterial'; 17 | 18 | this.color = new Color( 0x000000 ); 19 | this.transparent = true; 20 | 21 | this.setValues( parameters ); 22 | 23 | } 24 | 25 | ShadowMaterial.prototype = Object.create( Material.prototype ); 26 | ShadowMaterial.prototype.constructor = ShadowMaterial; 27 | 28 | ShadowMaterial.prototype.isShadowMaterial = true; 29 | 30 | ShadowMaterial.prototype.copy = function ( source ) { 31 | 32 | Material.prototype.copy.call( this, source ); 33 | 34 | this.color.copy( source.color ); 35 | 36 | return this; 37 | 38 | }; 39 | 40 | 41 | export { ShadowMaterial }; 42 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/points_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform vec3 diffuse; 3 | uniform float opacity; 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | void main() { 13 | 14 | #include 15 | 16 | vec3 outgoingLight = vec3( 0.0 ); 17 | vec4 diffuseColor = vec4( diffuse, opacity ); 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | outgoingLight = diffuseColor.rgb; 25 | 26 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | } 34 | `; 35 | -------------------------------------------------------------------------------- /module/animation/tracks/StringKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateDiscrete } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | 4 | /** 5 | * 6 | * A Track that interpolates Strings 7 | * 8 | * 9 | * @author Ben Houston / http://clara.io/ 10 | * @author David Sarno / http://lighthaus.us/ 11 | * @author tschw 12 | */ 13 | 14 | function StringKeyframeTrack( name, times, values, interpolation ) { 15 | 16 | KeyframeTrack.call( this, name, times, values, interpolation ); 17 | 18 | } 19 | 20 | StringKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 21 | 22 | constructor: StringKeyframeTrack, 23 | 24 | ValueTypeName: 'string', 25 | ValueBufferType: Array, 26 | 27 | DefaultInterpolation: InterpolateDiscrete, 28 | 29 | InterpolantFactoryMethodLinear: undefined, 30 | 31 | InterpolantFactoryMethodSmooth: undefined 32 | 33 | } ); 34 | 35 | export { StringKeyframeTrack }; 36 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLObjects.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function WebGLObjects( geometries, info ) { 6 | 7 | var updateList = {}; 8 | 9 | function update( object ) { 10 | 11 | var frame = info.render.frame; 12 | 13 | var geometry = object.geometry; 14 | var buffergeometry = geometries.get( object, geometry ); 15 | 16 | // Update once per frame 17 | 18 | if ( updateList[ buffergeometry.id ] !== frame ) { 19 | 20 | if ( geometry.isGeometry ) { 21 | 22 | buffergeometry.updateFromObject( object ); 23 | 24 | } 25 | 26 | geometries.update( buffergeometry ); 27 | 28 | updateList[ buffergeometry.id ] = frame; 29 | 30 | } 31 | 32 | return buffergeometry; 33 | 34 | } 35 | 36 | function dispose() { 37 | 38 | updateList = {}; 39 | 40 | } 41 | 42 | return { 43 | 44 | update: update, 45 | dispose: dispose 46 | 47 | }; 48 | 49 | } 50 | 51 | 52 | export { WebGLObjects }; 53 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SHADOWMAP 3 | 4 | #if NUM_DIR_LIGHTS > 0 5 | 6 | #pragma unroll_loop 7 | for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 8 | 9 | vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition; 10 | 11 | } 12 | 13 | #endif 14 | 15 | #if NUM_SPOT_LIGHTS > 0 16 | 17 | #pragma unroll_loop 18 | for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 19 | 20 | vSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition; 21 | 22 | } 23 | 24 | #endif 25 | 26 | #if NUM_POINT_LIGHTS > 0 27 | 28 | #pragma unroll_loop 29 | for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 30 | 31 | vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition; 32 | 33 | } 34 | 35 | #endif 36 | 37 | /* 38 | #if NUM_RECT_AREA_LIGHTS > 0 39 | 40 | // TODO (abelnation): update vAreaShadowCoord with area light info 41 | 42 | #endif 43 | */ 44 | 45 | #endif 46 | `; 47 | -------------------------------------------------------------------------------- /module/textures/CfxTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author citizenfx 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | import { NearestFilter, RGBFormat } from '../constants.js'; 7 | 8 | function CfxTexture( ) { 9 | 10 | var data = new Uint8Array( 3 ); 11 | var width = 1; 12 | var height = 1; 13 | 14 | var format = RGBFormat; 15 | 16 | Texture.call( this, null, undefined, undefined, undefined, undefined, undefined, format, undefined, undefined, undefined ); 17 | 18 | this.image = { data: data, width: width, height: height }; 19 | 20 | this.magFilter = NearestFilter; 21 | this.minFilter = NearestFilter; 22 | 23 | this.generateMipmaps = false; 24 | this.flipY = false; 25 | this.unpackAlignment = 1; 26 | 27 | } 28 | 29 | CfxTexture.prototype = Object.create( Texture.prototype ); 30 | CfxTexture.prototype.constructor = CfxTexture; 31 | 32 | CfxTexture.prototype.isDataTexture = true; 33 | CfxTexture.prototype.isCfxTexture = true; 34 | 35 | 36 | export { CfxTexture }; 37 | -------------------------------------------------------------------------------- /module/textures/DataTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | import { NearestFilter } from '../constants.js'; 7 | 8 | function DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { 9 | 10 | Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); 11 | 12 | this.image = { data: data, width: width, height: height }; 13 | 14 | this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; 15 | this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; 16 | 17 | this.generateMipmaps = false; 18 | this.flipY = false; 19 | this.unpackAlignment = 1; 20 | 21 | } 22 | 23 | DataTexture.prototype = Object.create( Texture.prototype ); 24 | DataTexture.prototype.constructor = DataTexture; 25 | 26 | DataTexture.prototype.isDataTexture = true; 27 | 28 | 29 | export { DataTexture }; 30 | -------------------------------------------------------------------------------- /module/lights/HemisphereLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { Color } from '../math/Color.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | /** 6 | * @author alteredq / http://alteredqualia.com/ 7 | */ 8 | 9 | function HemisphereLight( skyColor, groundColor, intensity ) { 10 | 11 | Light.call( this, skyColor, intensity ); 12 | 13 | this.type = 'HemisphereLight'; 14 | 15 | this.castShadow = undefined; 16 | 17 | this.position.copy( Object3D.DefaultUp ); 18 | this.updateMatrix(); 19 | 20 | this.groundColor = new Color( groundColor ); 21 | 22 | } 23 | 24 | HemisphereLight.prototype = Object.assign( Object.create( Light.prototype ), { 25 | 26 | constructor: HemisphereLight, 27 | 28 | isHemisphereLight: true, 29 | 30 | copy: function ( source ) { 31 | 32 | Light.prototype.copy.call( this, source ); 33 | 34 | this.groundColor.copy( source.groundColor ); 35 | 36 | return this; 37 | 38 | } 39 | 40 | } ); 41 | 42 | 43 | export { HemisphereLight }; 44 | -------------------------------------------------------------------------------- /module/materials/MeshToonMaterial.js: -------------------------------------------------------------------------------- 1 | import { MeshPhongMaterial } from './MeshPhongMaterial.js'; 2 | 3 | /** 4 | * @author takahirox / http://github.com/takahirox 5 | * 6 | * parameters = { 7 | * gradientMap: new THREE.Texture( ) 8 | * } 9 | */ 10 | 11 | function MeshToonMaterial( parameters ) { 12 | 13 | MeshPhongMaterial.call( this ); 14 | 15 | this.defines = { 'TOON': '' }; 16 | 17 | this.type = 'MeshToonMaterial'; 18 | 19 | this.gradientMap = null; 20 | 21 | this.setValues( parameters ); 22 | 23 | } 24 | 25 | MeshToonMaterial.prototype = Object.create( MeshPhongMaterial.prototype ); 26 | MeshToonMaterial.prototype.constructor = MeshToonMaterial; 27 | 28 | MeshToonMaterial.prototype.isMeshToonMaterial = true; 29 | 30 | MeshToonMaterial.prototype.copy = function ( source ) { 31 | 32 | MeshPhongMaterial.prototype.copy.call( this, source ); 33 | 34 | this.gradientMap = source.gradientMap; 35 | 36 | return this; 37 | 38 | }; 39 | 40 | 41 | export { MeshToonMaterial }; 42 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/depth_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if DEPTH_PACKING == 3200 3 | 4 | uniform float opacity; 5 | 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void main() { 17 | 18 | #include 19 | 20 | vec4 diffuseColor = vec4( 1.0 ); 21 | 22 | #if DEPTH_PACKING == 3200 23 | 24 | diffuseColor.a = opacity; 25 | 26 | #endif 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | 34 | #if DEPTH_PACKING == 3200 35 | 36 | gl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity ); 37 | 38 | #elif DEPTH_PACKING == 3201 39 | 40 | gl_FragColor = packDepthToRGBA( gl_FragCoord.z ); 41 | 42 | #endif 43 | 44 | } 45 | `; 46 | -------------------------------------------------------------------------------- /module/loaders/LoaderUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Don McCurdy / https://www.donmccurdy.com 3 | */ 4 | 5 | var LoaderUtils = { 6 | 7 | decodeText: function ( array ) { 8 | 9 | if ( typeof TextDecoder !== 'undefined' ) { 10 | 11 | return new TextDecoder().decode( array ); 12 | 13 | } 14 | 15 | // Avoid the String.fromCharCode.apply(null, array) shortcut, which 16 | // throws a "maximum call stack size exceeded" error for large arrays. 17 | 18 | var s = ''; 19 | 20 | for ( var i = 0, il = array.length; i < il; i ++ ) { 21 | 22 | // Implicitly assumes little-endian. 23 | s += String.fromCharCode( array[ i ] ); 24 | 25 | } 26 | 27 | // Merges multi-byte utf-8 characters. 28 | return decodeURIComponent( escape( s ) ); 29 | 30 | }, 31 | 32 | extractUrlBase: function ( url ) { 33 | 34 | var index = url.lastIndexOf( '/' ); 35 | 36 | if ( index === - 1 ) return './'; 37 | 38 | return url.substr( 0, index + 1 ); 39 | 40 | } 41 | 42 | }; 43 | 44 | export { LoaderUtils }; 45 | -------------------------------------------------------------------------------- /module/textures/DataTexture3D.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Artur Trzesiok 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | import { NearestFilter } from '../constants.js'; 7 | 8 | function DataTexture3D( data, width, height, depth ) { 9 | 10 | // We're going to add .setXXX() methods for setting properties later. 11 | // Users can still set in DataTexture3D directly. 12 | // 13 | // var texture = new THREE.DataTexture3D( data, width, height, depth ); 14 | // texture.anisotropy = 16; 15 | // 16 | // See #14839 17 | 18 | Texture.call( this, null ); 19 | 20 | this.image = { data: data, width: width, height: height, depth: depth }; 21 | 22 | this.magFilter = NearestFilter; 23 | this.minFilter = NearestFilter; 24 | 25 | this.generateMipmaps = false; 26 | this.flipY = false; 27 | 28 | } 29 | 30 | DataTexture3D.prototype = Object.create( Texture.prototype ); 31 | DataTexture3D.prototype.constructor = DataTexture3D; 32 | DataTexture3D.prototype.isDataTexture3D = true; 33 | 34 | export { DataTexture3D }; 35 | -------------------------------------------------------------------------------- /module/textures/CompressedTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | 7 | function CompressedTexture( mipmaps, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) { 8 | 9 | Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); 10 | 11 | this.image = { width: width, height: height }; 12 | this.mipmaps = mipmaps; 13 | 14 | // no flipping for cube textures 15 | // (also flipping doesn't work for compressed textures ) 16 | 17 | this.flipY = false; 18 | 19 | // can't generate mipmaps for compressed textures 20 | // mips must be embedded in DDS files 21 | 22 | this.generateMipmaps = false; 23 | 24 | } 25 | 26 | CompressedTexture.prototype = Object.create( Texture.prototype ); 27 | CompressedTexture.prototype.constructor = CompressedTexture; 28 | 29 | CompressedTexture.prototype.isCompressedTexture = true; 30 | 31 | 32 | export { CompressedTexture }; 33 | -------------------------------------------------------------------------------- /fxmanifest.lua: -------------------------------------------------------------------------------- 1 | fx_version "cerulean" 2 | 3 | game "common" 4 | 5 | files { 6 | "module/*.js", 7 | "module/animation/tracks/*.js", 8 | "module/animation/*.js", 9 | "module/audio/*js", 10 | "module/cameras/*.js", 11 | "module/core/*.js", 12 | "module/extras/core/*.js", 13 | "module/extras/curves/*.js", 14 | "module/extras/objects/*.js", 15 | "module/extras/*.js", 16 | "module/geometries/*.js", 17 | "module/helpers/*.js", 18 | "module/lights/*.js", 19 | "module/loaders/*.js", 20 | "module/materials/*.js", 21 | "module/math/interpolants/*.js", 22 | "module/math/*.js", 23 | "module/objects/*.js", 24 | "module/renderers/shaders/*.js", 25 | "module/renderers/shaders/ShaderChunk/*.js", 26 | "module/renderers/shaders/ShaderLib/*.js", 27 | "module/renderers/webgl/*.js", 28 | "module/renderers/webxr/*.js", 29 | "module/renderers/webvr/*.js", 30 | "module/renderers/*.js", 31 | "module/scenes/*.js", 32 | "module/textures/*.js", 33 | "script.js" 34 | } 35 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLAnimation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function WebGLAnimation() { 6 | 7 | var context = null; 8 | var isAnimating = false; 9 | var animationLoop = null; 10 | 11 | function onAnimationFrame( time, frame ) { 12 | 13 | if ( isAnimating === false ) return; 14 | 15 | animationLoop( time, frame ); 16 | 17 | context.requestAnimationFrame( onAnimationFrame ); 18 | 19 | } 20 | 21 | return { 22 | 23 | start: function () { 24 | 25 | if ( isAnimating === true ) return; 26 | if ( animationLoop === null ) return; 27 | 28 | context.requestAnimationFrame( onAnimationFrame ); 29 | 30 | isAnimating = true; 31 | 32 | }, 33 | 34 | stop: function () { 35 | 36 | isAnimating = false; 37 | 38 | }, 39 | 40 | setAnimationLoop: function ( callback ) { 41 | 42 | animationLoop = callback; 43 | 44 | }, 45 | 46 | setContext: function ( value ) { 47 | 48 | context = value; 49 | 50 | } 51 | 52 | }; 53 | 54 | } 55 | 56 | export { WebGLAnimation }; 57 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/linedashed_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform vec3 diffuse; 3 | uniform float opacity; 4 | 5 | uniform float dashSize; 6 | uniform float totalSize; 7 | 8 | varying float vLineDistance; 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | void main() { 17 | 18 | #include 19 | 20 | if ( mod( vLineDistance, totalSize ) > dashSize ) { 21 | 22 | discard; 23 | 24 | } 25 | 26 | vec3 outgoingLight = vec3( 0.0 ); 27 | vec4 diffuseColor = vec4( diffuse, opacity ); 28 | 29 | #include 30 | #include 31 | 32 | outgoingLight = diffuseColor.rgb; // simple shader 33 | 34 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | } 42 | `; 43 | -------------------------------------------------------------------------------- /module/textures/CubeTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { Texture } from './Texture.js'; 6 | import { CubeReflectionMapping } from '../constants.js'; 7 | 8 | function CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) { 9 | 10 | images = images !== undefined ? images : []; 11 | mapping = mapping !== undefined ? mapping : CubeReflectionMapping; 12 | 13 | Texture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ); 14 | 15 | this.flipY = false; 16 | 17 | } 18 | 19 | CubeTexture.prototype = Object.create( Texture.prototype ); 20 | CubeTexture.prototype.constructor = CubeTexture; 21 | 22 | CubeTexture.prototype.isCubeTexture = true; 23 | 24 | Object.defineProperty( CubeTexture.prototype, 'images', { 25 | 26 | get: function () { 27 | 28 | return this.image; 29 | 30 | }, 31 | 32 | set: function ( value ) { 33 | 34 | this.image = value; 35 | 36 | } 37 | 38 | } ); 39 | 40 | 41 | export { CubeTexture }; 42 | -------------------------------------------------------------------------------- /module/math/interpolants/LinearInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | 3 | /** 4 | * @author tschw 5 | */ 6 | 7 | function LinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 8 | 9 | Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); 10 | 11 | } 12 | 13 | LinearInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), { 14 | 15 | constructor: LinearInterpolant, 16 | 17 | interpolate_: function ( i1, t0, t, t1 ) { 18 | 19 | var result = this.resultBuffer, 20 | values = this.sampleValues, 21 | stride = this.valueSize, 22 | 23 | offset1 = i1 * stride, 24 | offset0 = offset1 - stride, 25 | 26 | weight1 = ( t - t0 ) / ( t1 - t0 ), 27 | weight0 = 1 - weight1; 28 | 29 | for ( var i = 0; i !== stride; ++ i ) { 30 | 31 | result[ i ] = 32 | values[ offset0 + i ] * weight0 + 33 | values[ offset1 + i ] * weight1; 34 | 35 | } 36 | 37 | return result; 38 | 39 | } 40 | 41 | } ); 42 | 43 | 44 | export { LinearInterpolant }; 45 | -------------------------------------------------------------------------------- /module/lights/RectAreaLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | 3 | /** 4 | * @author abelnation / http://github.com/abelnation 5 | */ 6 | 7 | function RectAreaLight( color, intensity, width, height ) { 8 | 9 | Light.call( this, color, intensity ); 10 | 11 | this.type = 'RectAreaLight'; 12 | 13 | this.width = ( width !== undefined ) ? width : 10; 14 | this.height = ( height !== undefined ) ? height : 10; 15 | 16 | } 17 | 18 | RectAreaLight.prototype = Object.assign( Object.create( Light.prototype ), { 19 | 20 | constructor: RectAreaLight, 21 | 22 | isRectAreaLight: true, 23 | 24 | copy: function ( source ) { 25 | 26 | Light.prototype.copy.call( this, source ); 27 | 28 | this.width = source.width; 29 | this.height = source.height; 30 | 31 | return this; 32 | 33 | }, 34 | 35 | toJSON: function ( meta ) { 36 | 37 | var data = Light.prototype.toJSON.call( this, meta ); 38 | 39 | data.object.width = this.width; 40 | data.object.height = this.height; 41 | 42 | return data; 43 | 44 | } 45 | 46 | } ); 47 | 48 | export { RectAreaLight }; 49 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshbasic_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | void main() { 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #ifdef USE_ENVMAP 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #endif 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | } 41 | `; 42 | -------------------------------------------------------------------------------- /module/lights/DirectionalLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { DirectionalLightShadow } from './DirectionalLightShadow.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | /** 6 | * @author mrdoob / http://mrdoob.com/ 7 | * @author alteredq / http://alteredqualia.com/ 8 | */ 9 | 10 | function DirectionalLight( color, intensity ) { 11 | 12 | Light.call( this, color, intensity ); 13 | 14 | this.type = 'DirectionalLight'; 15 | 16 | this.position.copy( Object3D.DefaultUp ); 17 | this.updateMatrix(); 18 | 19 | this.target = new Object3D(); 20 | 21 | this.shadow = new DirectionalLightShadow(); 22 | 23 | } 24 | 25 | DirectionalLight.prototype = Object.assign( Object.create( Light.prototype ), { 26 | 27 | constructor: DirectionalLight, 28 | 29 | isDirectionalLight: true, 30 | 31 | copy: function ( source ) { 32 | 33 | Light.prototype.copy.call( this, source ); 34 | 35 | this.target = source.target.clone(); 36 | 37 | this.shadow = source.shadow.clone(); 38 | 39 | return this; 40 | 41 | } 42 | 43 | } ); 44 | 45 | 46 | export { DirectionalLight }; 47 | -------------------------------------------------------------------------------- /module/lights/SpotLightShadow.js: -------------------------------------------------------------------------------- 1 | import { LightShadow } from './LightShadow.js'; 2 | import { _Math } from '../math/Math.js'; 3 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; 4 | 5 | /** 6 | * @author mrdoob / http://mrdoob.com/ 7 | */ 8 | 9 | function SpotLightShadow() { 10 | 11 | LightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) ); 12 | 13 | } 14 | 15 | SpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), { 16 | 17 | constructor: SpotLightShadow, 18 | 19 | isSpotLightShadow: true, 20 | 21 | update: function ( light ) { 22 | 23 | var camera = this.camera; 24 | 25 | var fov = _Math.RAD2DEG * 2 * light.angle; 26 | var aspect = this.mapSize.width / this.mapSize.height; 27 | var far = light.distance || camera.far; 28 | 29 | if ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) { 30 | 31 | camera.fov = fov; 32 | camera.aspect = aspect; 33 | camera.far = far; 34 | camera.updateProjectionMatrix(); 35 | 36 | } 37 | 38 | } 39 | 40 | } ); 41 | 42 | 43 | export { SpotLightShadow }; 44 | -------------------------------------------------------------------------------- /module/textures/VideoTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { RGBFormat, LinearFilter } from '../constants.js'; 6 | import { Texture } from './Texture.js'; 7 | 8 | function VideoTexture( video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) { 9 | 10 | Texture.call( this, video, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 11 | 12 | this.format = format !== undefined ? format : RGBFormat; 13 | 14 | this.minFilter = minFilter !== undefined ? minFilter : LinearFilter; 15 | this.magFilter = magFilter !== undefined ? magFilter : LinearFilter; 16 | 17 | this.generateMipmaps = false; 18 | 19 | } 20 | 21 | VideoTexture.prototype = Object.assign( Object.create( Texture.prototype ), { 22 | 23 | constructor: VideoTexture, 24 | 25 | isVideoTexture: true, 26 | 27 | update: function () { 28 | 29 | var video = this.image; 30 | 31 | if ( video.readyState >= video.HAVE_CURRENT_DATA ) { 32 | 33 | this.needsUpdate = true; 34 | 35 | } 36 | 37 | } 38 | 39 | } ); 40 | 41 | 42 | export { VideoTexture }; 43 | -------------------------------------------------------------------------------- /module/animation/tracks/BooleanKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateDiscrete } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | 4 | /** 5 | * 6 | * A Track of Boolean keyframe values. 7 | * 8 | * 9 | * @author Ben Houston / http://clara.io/ 10 | * @author David Sarno / http://lighthaus.us/ 11 | * @author tschw 12 | */ 13 | 14 | function BooleanKeyframeTrack( name, times, values ) { 15 | 16 | KeyframeTrack.call( this, name, times, values ); 17 | 18 | } 19 | 20 | BooleanKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 21 | 22 | constructor: BooleanKeyframeTrack, 23 | 24 | ValueTypeName: 'bool', 25 | ValueBufferType: Array, 26 | 27 | DefaultInterpolation: InterpolateDiscrete, 28 | 29 | InterpolantFactoryMethodLinear: undefined, 30 | InterpolantFactoryMethodSmooth: undefined 31 | 32 | // Note: Actually this track could have a optimized / compressed 33 | // representation of a single value and a custom interpolant that 34 | // computes "firstValue ^ isOdd( index )". 35 | 36 | } ); 37 | 38 | export { BooleanKeyframeTrack }; 39 | -------------------------------------------------------------------------------- /module/core/InstancedBufferAttribute.js: -------------------------------------------------------------------------------- 1 | import { BufferAttribute } from './BufferAttribute.js'; 2 | 3 | /** 4 | * @author benaadams / https://twitter.com/ben_a_adams 5 | */ 6 | 7 | function InstancedBufferAttribute( array, itemSize, normalized, meshPerAttribute ) { 8 | 9 | if ( typeof ( normalized ) === 'number' ) { 10 | 11 | meshPerAttribute = normalized; 12 | 13 | normalized = false; 14 | 15 | console.error( 'THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument.' ); 16 | 17 | } 18 | 19 | BufferAttribute.call( this, array, itemSize, normalized ); 20 | 21 | this.meshPerAttribute = meshPerAttribute || 1; 22 | 23 | } 24 | 25 | InstancedBufferAttribute.prototype = Object.assign( Object.create( BufferAttribute.prototype ), { 26 | 27 | constructor: InstancedBufferAttribute, 28 | 29 | isInstancedBufferAttribute: true, 30 | 31 | copy: function ( source ) { 32 | 33 | BufferAttribute.prototype.copy.call( this, source ); 34 | 35 | this.meshPerAttribute = source.meshPerAttribute; 36 | 37 | return this; 38 | 39 | } 40 | 41 | } ); 42 | 43 | 44 | 45 | export { InstancedBufferAttribute }; 46 | -------------------------------------------------------------------------------- /module/materials/Materials.js: -------------------------------------------------------------------------------- 1 | export { ShadowMaterial } from './ShadowMaterial.js'; 2 | export { SpriteMaterial } from './SpriteMaterial.js'; 3 | export { RawShaderMaterial } from './RawShaderMaterial.js'; 4 | export { ShaderMaterial } from './ShaderMaterial.js'; 5 | export { PointsMaterial } from './PointsMaterial.js'; 6 | export { MeshPhysicalMaterial } from './MeshPhysicalMaterial.js'; 7 | export { MeshStandardMaterial } from './MeshStandardMaterial.js'; 8 | export { MeshPhongMaterial } from './MeshPhongMaterial.js'; 9 | export { MeshToonMaterial } from './MeshToonMaterial.js'; 10 | export { MeshNormalMaterial } from './MeshNormalMaterial.js'; 11 | export { MeshLambertMaterial } from './MeshLambertMaterial.js'; 12 | export { MeshDepthMaterial } from './MeshDepthMaterial.js'; 13 | export { MeshDistanceMaterial } from './MeshDistanceMaterial.js'; 14 | export { MeshBasicMaterial } from './MeshBasicMaterial.js'; 15 | export { MeshMatcapMaterial } from './MeshMatcapMaterial.js'; 16 | export { LineDashedMaterial } from './LineDashedMaterial.js'; 17 | export { LineBasicMaterial } from './LineBasicMaterial.js'; 18 | export { Material } from './Material.js'; 19 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #if defined( RE_IndirectDiffuse ) 3 | 4 | #ifdef USE_LIGHTMAP 5 | 6 | vec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; 7 | 8 | #ifndef PHYSICALLY_CORRECT_LIGHTS 9 | 10 | lightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage 11 | 12 | #endif 13 | 14 | irradiance += lightMapIrradiance; 15 | 16 | #endif 17 | 18 | #if defined( USE_ENVMAP ) && defined( PHYSICAL ) && defined( ENVMAP_TYPE_CUBE_UV ) 19 | 20 | irradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel ); 21 | 22 | #endif 23 | 24 | #endif 25 | 26 | #if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) 27 | 28 | radiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_BlinnShininessExponent( material ), maxMipLevel ); 29 | 30 | #ifndef STANDARD 31 | clearCoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry, Material_ClearCoat_BlinnShininessExponent( material ), maxMipLevel ); 32 | #endif 33 | 34 | #endif 35 | `; 36 | -------------------------------------------------------------------------------- /module/math/interpolants/QuaternionLinearInterpolant.js: -------------------------------------------------------------------------------- 1 | import { Interpolant } from '../Interpolant.js'; 2 | import { Quaternion } from '../Quaternion.js'; 3 | 4 | /** 5 | * Spherical linear unit quaternion interpolant. 6 | * 7 | * @author tschw 8 | */ 9 | 10 | function QuaternionLinearInterpolant( parameterPositions, sampleValues, sampleSize, resultBuffer ) { 11 | 12 | Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); 13 | 14 | } 15 | 16 | QuaternionLinearInterpolant.prototype = Object.assign( Object.create( Interpolant.prototype ), { 17 | 18 | constructor: QuaternionLinearInterpolant, 19 | 20 | interpolate_: function ( i1, t0, t, t1 ) { 21 | 22 | var result = this.resultBuffer, 23 | values = this.sampleValues, 24 | stride = this.valueSize, 25 | 26 | offset = i1 * stride, 27 | 28 | alpha = ( t - t0 ) / ( t1 - t0 ); 29 | 30 | for ( var end = offset + stride; offset !== end; offset += 4 ) { 31 | 32 | Quaternion.slerpFlat( result, 0, values, offset - stride, values, offset, alpha ); 33 | 34 | } 35 | 36 | return result; 37 | 38 | } 39 | 40 | } ); 41 | 42 | 43 | export { QuaternionLinearInterpolant }; 44 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLShader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function addLineNumbers( string ) { 6 | 7 | var lines = string.split( '\n' ); 8 | 9 | for ( var i = 0; i < lines.length; i ++ ) { 10 | 11 | lines[ i ] = ( i + 1 ) + ': ' + lines[ i ]; 12 | 13 | } 14 | 15 | return lines.join( '\n' ); 16 | 17 | } 18 | 19 | function WebGLShader( gl, type, string ) { 20 | 21 | var shader = gl.createShader( type ); 22 | 23 | gl.shaderSource( shader, string ); 24 | gl.compileShader( shader ); 25 | 26 | if ( gl.getShaderParameter( shader, gl.COMPILE_STATUS ) === false ) { 27 | 28 | console.error( 'THREE.WebGLShader: Shader couldn\'t compile.' ); 29 | 30 | } 31 | 32 | if ( gl.getShaderInfoLog( shader ) !== '' ) { 33 | 34 | console.warn( 'THREE.WebGLShader: gl.getShaderInfoLog()', type === gl.VERTEX_SHADER ? 'vertex' : 'fragment', gl.getShaderInfoLog( shader ), addLineNumbers( string ) ); 35 | 36 | } 37 | 38 | // --enable-privileged-webgl-extension 39 | // console.log( type, gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) ); 40 | 41 | return shader; 42 | 43 | } 44 | 45 | 46 | export { WebGLShader }; 47 | -------------------------------------------------------------------------------- /module/materials/LineDashedMaterial.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * 4 | * parameters = { 5 | * color: , 6 | * opacity: , 7 | * 8 | * linewidth: , 9 | * 10 | * scale: , 11 | * dashSize: , 12 | * gapSize: 13 | * } 14 | */ 15 | 16 | import { LineBasicMaterial } from './LineBasicMaterial.js'; 17 | 18 | function LineDashedMaterial( parameters ) { 19 | 20 | LineBasicMaterial.call( this ); 21 | 22 | this.type = 'LineDashedMaterial'; 23 | 24 | this.scale = 1; 25 | this.dashSize = 3; 26 | this.gapSize = 1; 27 | 28 | this.setValues( parameters ); 29 | 30 | } 31 | 32 | LineDashedMaterial.prototype = Object.create( LineBasicMaterial.prototype ); 33 | LineDashedMaterial.prototype.constructor = LineDashedMaterial; 34 | 35 | LineDashedMaterial.prototype.isLineDashedMaterial = true; 36 | 37 | LineDashedMaterial.prototype.copy = function ( source ) { 38 | 39 | LineBasicMaterial.prototype.copy.call( this, source ); 40 | 41 | this.scale = source.scale; 42 | this.dashSize = source.dashSize; 43 | this.gapSize = source.gapSize; 44 | 45 | return this; 46 | 47 | }; 48 | 49 | 50 | export { LineDashedMaterial }; 51 | -------------------------------------------------------------------------------- /module/animation/tracks/QuaternionKeyframeTrack.js: -------------------------------------------------------------------------------- 1 | import { InterpolateLinear } from '../../constants.js'; 2 | import { KeyframeTrack } from '../KeyframeTrack.js'; 3 | import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant.js'; 4 | 5 | /** 6 | * 7 | * A Track of quaternion keyframe values. 8 | * 9 | * @author Ben Houston / http://clara.io/ 10 | * @author David Sarno / http://lighthaus.us/ 11 | * @author tschw 12 | */ 13 | 14 | function QuaternionKeyframeTrack( name, times, values, interpolation ) { 15 | 16 | KeyframeTrack.call( this, name, times, values, interpolation ); 17 | 18 | } 19 | 20 | QuaternionKeyframeTrack.prototype = Object.assign( Object.create( KeyframeTrack.prototype ), { 21 | 22 | constructor: QuaternionKeyframeTrack, 23 | 24 | ValueTypeName: 'quaternion', 25 | 26 | // ValueBufferType is inherited 27 | 28 | DefaultInterpolation: InterpolateLinear, 29 | 30 | InterpolantFactoryMethodLinear: function ( result ) { 31 | 32 | return new QuaternionLinearInterpolant( this.times, this.values, this.getValueSize(), result ); 33 | 34 | }, 35 | 36 | InterpolantFactoryMethodSmooth: undefined // not yet implemented 37 | 38 | } ); 39 | 40 | export { QuaternionKeyframeTrack }; 41 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define MATCAP 3 | 4 | varying vec3 vViewPosition; 5 | 6 | #ifndef FLAT_SHADED 7 | 8 | varying vec3 vNormal; 9 | 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | void main() { 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED 33 | 34 | vNormal = normalize( transformedNormal ); 35 | 36 | #endif 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | vViewPosition = - mvPosition.xyz; 49 | 50 | } 51 | `; 52 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_SKINNING 3 | 4 | uniform mat4 bindMatrix; 5 | uniform mat4 bindMatrixInverse; 6 | 7 | #ifdef BONE_TEXTURE 8 | 9 | uniform sampler2D boneTexture; 10 | uniform int boneTextureSize; 11 | 12 | mat4 getBoneMatrix( const in float i ) { 13 | 14 | float j = i * 4.0; 15 | float x = mod( j, float( boneTextureSize ) ); 16 | float y = floor( j / float( boneTextureSize ) ); 17 | 18 | float dx = 1.0 / float( boneTextureSize ); 19 | float dy = 1.0 / float( boneTextureSize ); 20 | 21 | y = dy * ( y + 0.5 ); 22 | 23 | vec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) ); 24 | vec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) ); 25 | vec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) ); 26 | vec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) ); 27 | 28 | mat4 bone = mat4( v1, v2, v3, v4 ); 29 | 30 | return bone; 31 | 32 | } 33 | 34 | #else 35 | 36 | uniform mat4 boneMatrices[ MAX_BONES ]; 37 | 38 | mat4 getBoneMatrix( const in float i ) { 39 | 40 | mat4 bone = boneMatrices[ int(i) ]; 41 | return bone; 42 | 43 | } 44 | 45 | #endif 46 | 47 | #endif 48 | `; 49 | -------------------------------------------------------------------------------- /module/renderers/shaders/UniformsUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Uniform Utilities 3 | */ 4 | 5 | export function cloneUniforms( src ) { 6 | 7 | var dst = {}; 8 | 9 | for ( var u in src ) { 10 | 11 | dst[ u ] = {}; 12 | 13 | for ( var p in src[ u ] ) { 14 | 15 | var property = src[ u ][ p ]; 16 | 17 | if ( property && ( property.isColor || 18 | property.isMatrix3 || property.isMatrix4 || 19 | property.isVector2 || property.isVector3 || property.isVector4 || 20 | property.isTexture ) ) { 21 | 22 | dst[ u ][ p ] = property.clone(); 23 | 24 | } else if ( Array.isArray( property ) ) { 25 | 26 | dst[ u ][ p ] = property.slice(); 27 | 28 | } else { 29 | 30 | dst[ u ][ p ] = property; 31 | 32 | } 33 | 34 | } 35 | 36 | } 37 | 38 | return dst; 39 | 40 | } 41 | 42 | export function mergeUniforms( uniforms ) { 43 | 44 | var merged = {}; 45 | 46 | for ( var u = 0; u < uniforms.length; u ++ ) { 47 | 48 | var tmp = cloneUniforms( uniforms[ u ] ); 49 | 50 | for ( var p in tmp ) { 51 | 52 | merged[ p ] = tmp[ p ]; 53 | 54 | } 55 | 56 | } 57 | 58 | return merged; 59 | 60 | } 61 | 62 | // Legacy 63 | 64 | var UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms }; 65 | 66 | export { UniformsUtils }; 67 | -------------------------------------------------------------------------------- /module/loaders/AnimationLoader.js: -------------------------------------------------------------------------------- 1 | import { AnimationClip } from '../animation/AnimationClip.js'; 2 | import { FileLoader } from './FileLoader.js'; 3 | import { DefaultLoadingManager } from './LoadingManager.js'; 4 | 5 | /** 6 | * @author bhouston / http://clara.io/ 7 | */ 8 | 9 | function AnimationLoader( manager ) { 10 | 11 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 12 | 13 | } 14 | 15 | Object.assign( AnimationLoader.prototype, { 16 | 17 | load: function ( url, onLoad, onProgress, onError ) { 18 | 19 | var scope = this; 20 | 21 | var loader = new FileLoader( scope.manager ); 22 | loader.setPath( scope.path ); 23 | loader.load( url, function ( text ) { 24 | 25 | onLoad( scope.parse( JSON.parse( text ) ) ); 26 | 27 | }, onProgress, onError ); 28 | 29 | }, 30 | 31 | parse: function ( json, onLoad ) { 32 | 33 | var animations = []; 34 | 35 | for ( var i = 0; i < json.length; i ++ ) { 36 | 37 | var clip = AnimationClip.parse( json[ i ] ); 38 | 39 | animations.push( clip ); 40 | 41 | } 42 | 43 | onLoad( animations ); 44 | 45 | }, 46 | 47 | setPath: function ( value ) { 48 | 49 | this.path = value; 50 | return this; 51 | 52 | } 53 | 54 | } ); 55 | 56 | 57 | export { AnimationLoader }; 58 | -------------------------------------------------------------------------------- /module/helpers/AxesHelper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author sroucheray / http://sroucheray.org/ 3 | * @author mrdoob / http://mrdoob.com/ 4 | */ 5 | 6 | import { LineSegments } from '../objects/LineSegments.js'; 7 | import { VertexColors } from '../constants.js'; 8 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 9 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 10 | import { BufferGeometry } from '../core/BufferGeometry.js'; 11 | 12 | function AxesHelper( size ) { 13 | 14 | size = size || 1; 15 | 16 | var vertices = [ 17 | 0, 0, 0, size, 0, 0, 18 | 0, 0, 0, 0, size, 0, 19 | 0, 0, 0, 0, 0, size 20 | ]; 21 | 22 | var colors = [ 23 | 1, 0, 0, 1, 0.6, 0, 24 | 0, 1, 0, 0.6, 1, 0, 25 | 0, 0, 1, 0, 0.6, 1 26 | ]; 27 | 28 | var geometry = new BufferGeometry(); 29 | geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); 30 | geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); 31 | 32 | var material = new LineBasicMaterial( { vertexColors: VertexColors } ); 33 | 34 | LineSegments.call( this, geometry, material ); 35 | 36 | } 37 | 38 | AxesHelper.prototype = Object.create( LineSegments.prototype ); 39 | AxesHelper.prototype.constructor = AxesHelper; 40 | 41 | 42 | export { AxesHelper }; 43 | -------------------------------------------------------------------------------- /module/materials/MeshPhysicalMaterial.js: -------------------------------------------------------------------------------- 1 | import { MeshStandardMaterial } from './MeshStandardMaterial.js'; 2 | 3 | /** 4 | * @author WestLangley / http://github.com/WestLangley 5 | * 6 | * parameters = { 7 | * reflectivity: 8 | * } 9 | */ 10 | 11 | function MeshPhysicalMaterial( parameters ) { 12 | 13 | MeshStandardMaterial.call( this ); 14 | 15 | this.defines = { 'PHYSICAL': '' }; 16 | 17 | this.type = 'MeshPhysicalMaterial'; 18 | 19 | this.reflectivity = 0.5; // maps to F0 = 0.04 20 | 21 | this.clearCoat = 0.0; 22 | this.clearCoatRoughness = 0.0; 23 | 24 | this.setValues( parameters ); 25 | 26 | } 27 | 28 | MeshPhysicalMaterial.prototype = Object.create( MeshStandardMaterial.prototype ); 29 | MeshPhysicalMaterial.prototype.constructor = MeshPhysicalMaterial; 30 | 31 | MeshPhysicalMaterial.prototype.isMeshPhysicalMaterial = true; 32 | 33 | MeshPhysicalMaterial.prototype.copy = function ( source ) { 34 | 35 | MeshStandardMaterial.prototype.copy.call( this, source ); 36 | 37 | this.defines = { 'PHYSICAL': '' }; 38 | 39 | this.reflectivity = source.reflectivity; 40 | 41 | this.clearCoat = source.clearCoat; 42 | this.clearCoatRoughness = source.clearCoatRoughness; 43 | 44 | return this; 45 | 46 | }; 47 | 48 | 49 | export { MeshPhysicalMaterial }; 50 | -------------------------------------------------------------------------------- /module/extras/ImageUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author alteredq / http://alteredqualia.com/ 4 | * @author szimek / https://github.com/szimek/ 5 | */ 6 | 7 | var _canvas; 8 | 9 | var ImageUtils = { 10 | 11 | getDataURL: function ( image ) { 12 | 13 | var canvas; 14 | 15 | if ( typeof HTMLCanvasElement == 'undefined' ) { 16 | 17 | return image.src; 18 | 19 | } else if ( image instanceof HTMLCanvasElement ) { 20 | 21 | canvas = image; 22 | 23 | } else { 24 | 25 | if ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ); 26 | 27 | _canvas.width = image.width; 28 | _canvas.height = image.height; 29 | 30 | var context = _canvas.getContext( '2d' ); 31 | 32 | if ( image instanceof ImageData ) { 33 | 34 | context.putImageData( image, 0, 0 ); 35 | 36 | } else { 37 | 38 | context.drawImage( image, 0, 0, image.width, image.height ); 39 | 40 | } 41 | 42 | canvas = _canvas; 43 | 44 | } 45 | 46 | if ( canvas.width > 2048 || canvas.height > 2048 ) { 47 | 48 | return canvas.toDataURL( 'image/jpeg', 0.6 ); 49 | 50 | } else { 51 | 52 | return canvas.toDataURL( 'image/png' ); 53 | 54 | } 55 | 56 | } 57 | 58 | }; 59 | 60 | export { ImageUtils }; 61 | -------------------------------------------------------------------------------- /module/loaders/AudioLoader.js: -------------------------------------------------------------------------------- 1 | import { AudioContext } from '../audio/AudioContext.js'; 2 | import { FileLoader } from './FileLoader.js'; 3 | import { DefaultLoadingManager } from './LoadingManager.js'; 4 | 5 | /** 6 | * @author Reece Aaron Lecrivain / http://reecenotes.com/ 7 | */ 8 | 9 | function AudioLoader( manager ) { 10 | 11 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 12 | 13 | } 14 | 15 | Object.assign( AudioLoader.prototype, { 16 | 17 | load: function ( url, onLoad, onProgress, onError ) { 18 | 19 | var loader = new FileLoader( this.manager ); 20 | loader.setResponseType( 'arraybuffer' ); 21 | loader.setPath( this.path ); 22 | loader.load( url, function ( buffer ) { 23 | 24 | // Create a copy of the buffer. The `decodeAudioData` method 25 | // detaches the buffer when complete, preventing reuse. 26 | var bufferCopy = buffer.slice( 0 ); 27 | 28 | var context = AudioContext.getContext(); 29 | context.decodeAudioData( bufferCopy, function ( audioBuffer ) { 30 | 31 | onLoad( audioBuffer ); 32 | 33 | } ); 34 | 35 | }, onProgress, onError ); 36 | 37 | }, 38 | 39 | setPath: function ( value ) { 40 | 41 | this.path = value; 42 | return this; 43 | 44 | } 45 | 46 | } ); 47 | 48 | 49 | export { AudioLoader }; 50 | -------------------------------------------------------------------------------- /module/materials/SpriteMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | /** 5 | * @author alteredq / http://alteredqualia.com/ 6 | * 7 | * parameters = { 8 | * color: , 9 | * map: new THREE.Texture( ), 10 | * rotation: , 11 | * sizeAttenuation: 12 | * } 13 | */ 14 | 15 | function SpriteMaterial( parameters ) { 16 | 17 | Material.call( this ); 18 | 19 | this.type = 'SpriteMaterial'; 20 | 21 | this.color = new Color( 0xffffff ); 22 | this.map = null; 23 | 24 | this.rotation = 0; 25 | 26 | this.sizeAttenuation = true; 27 | 28 | this.lights = false; 29 | this.transparent = true; 30 | 31 | this.setValues( parameters ); 32 | 33 | } 34 | 35 | SpriteMaterial.prototype = Object.create( Material.prototype ); 36 | SpriteMaterial.prototype.constructor = SpriteMaterial; 37 | SpriteMaterial.prototype.isSpriteMaterial = true; 38 | 39 | SpriteMaterial.prototype.copy = function ( source ) { 40 | 41 | Material.prototype.copy.call( this, source ); 42 | 43 | this.color.copy( source.color ); 44 | this.map = source.map; 45 | 46 | this.rotation = source.rotation; 47 | 48 | this.sizeAttenuation = source.sizeAttenuation; 49 | 50 | return this; 51 | 52 | }; 53 | 54 | 55 | export { SpriteMaterial }; 56 | -------------------------------------------------------------------------------- /module/lights/LightShadow.js: -------------------------------------------------------------------------------- 1 | import { Matrix4 } from '../math/Matrix4.js'; 2 | import { Vector2 } from '../math/Vector2.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | */ 7 | 8 | function LightShadow( camera ) { 9 | 10 | this.camera = camera; 11 | 12 | this.bias = 0; 13 | this.radius = 1; 14 | 15 | this.mapSize = new Vector2( 512, 512 ); 16 | 17 | this.map = null; 18 | this.matrix = new Matrix4(); 19 | 20 | } 21 | 22 | Object.assign( LightShadow.prototype, { 23 | 24 | copy: function ( source ) { 25 | 26 | this.camera = source.camera.clone(); 27 | 28 | this.bias = source.bias; 29 | this.radius = source.radius; 30 | 31 | this.mapSize.copy( source.mapSize ); 32 | 33 | return this; 34 | 35 | }, 36 | 37 | clone: function () { 38 | 39 | return new this.constructor().copy( this ); 40 | 41 | }, 42 | 43 | toJSON: function () { 44 | 45 | var object = {}; 46 | 47 | if ( this.bias !== 0 ) object.bias = this.bias; 48 | if ( this.radius !== 1 ) object.radius = this.radius; 49 | if ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray(); 50 | 51 | object.camera = this.camera.toJSON( false ).object; 52 | delete object.camera.matrix; 53 | 54 | return object; 55 | 56 | } 57 | 58 | } ); 59 | 60 | 61 | export { LightShadow }; 62 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLBufferRenderer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function WebGLBufferRenderer( gl, extensions, info, capabilities ) { 6 | 7 | var mode; 8 | 9 | function setMode( value ) { 10 | 11 | mode = value; 12 | 13 | } 14 | 15 | function render( start, count ) { 16 | 17 | gl.drawArrays( mode, start, count ); 18 | 19 | info.update( count, mode ); 20 | 21 | } 22 | 23 | function renderInstances( geometry, start, count ) { 24 | 25 | var extension; 26 | 27 | if ( capabilities.isWebGL2 ) { 28 | 29 | extension = gl; 30 | 31 | } else { 32 | 33 | extension = extensions.get( 'ANGLE_instanced_arrays' ); 34 | 35 | if ( extension === null ) { 36 | 37 | console.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); 38 | return; 39 | 40 | } 41 | 42 | } 43 | 44 | extension[ capabilities.isWebGL2 ? 'drawArraysInstanced' : 'drawArraysInstancedANGLE' ]( mode, start, count, geometry.maxInstancedCount ); 45 | 46 | info.update( count, mode, geometry.maxInstancedCount ); 47 | 48 | } 49 | 50 | // 51 | 52 | this.setMode = setMode; 53 | this.render = render; 54 | this.renderInstances = renderInstances; 55 | 56 | } 57 | 58 | 59 | export { WebGLBufferRenderer }; 60 | -------------------------------------------------------------------------------- /module/materials/LineBasicMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author alteredq / http://alteredqualia.com/ 7 | * 8 | * parameters = { 9 | * color: , 10 | * opacity: , 11 | * 12 | * linewidth: , 13 | * linecap: "round", 14 | * linejoin: "round" 15 | * } 16 | */ 17 | 18 | function LineBasicMaterial( parameters ) { 19 | 20 | Material.call( this ); 21 | 22 | this.type = 'LineBasicMaterial'; 23 | 24 | this.color = new Color( 0xffffff ); 25 | 26 | this.linewidth = 1; 27 | this.linecap = 'round'; 28 | this.linejoin = 'round'; 29 | 30 | this.lights = false; 31 | 32 | this.setValues( parameters ); 33 | 34 | } 35 | 36 | LineBasicMaterial.prototype = Object.create( Material.prototype ); 37 | LineBasicMaterial.prototype.constructor = LineBasicMaterial; 38 | 39 | LineBasicMaterial.prototype.isLineBasicMaterial = true; 40 | 41 | LineBasicMaterial.prototype.copy = function ( source ) { 42 | 43 | Material.prototype.copy.call( this, source ); 44 | 45 | this.color.copy( source.color ); 46 | 47 | this.linewidth = source.linewidth; 48 | this.linecap = source.linecap; 49 | this.linejoin = source.linejoin; 50 | 51 | return this; 52 | 53 | }; 54 | 55 | 56 | export { LineBasicMaterial }; 57 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define LAMBERT 3 | 4 | varying vec3 vLightFront; 5 | 6 | #ifdef DOUBLE_SIDED 7 | 8 | varying vec3 vLightBack; 9 | 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | void main() { 27 | 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | } 52 | `; 53 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/normal_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define NORMAL 3 | 4 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) 5 | 6 | varying vec3 vViewPosition; 7 | 8 | #endif 9 | 10 | #ifndef FLAT_SHADED 11 | 12 | varying vec3 vNormal; 13 | 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | void main() { 23 | 24 | #include 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED 33 | 34 | vNormal = normalize( transformedNormal ); 35 | 36 | #endif 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || ( defined( USE_NORMALMAP ) && ! defined( OBJECTSPACE_NORMALMAP ) ) 46 | 47 | vViewPosition = - mvPosition.xyz; 48 | 49 | #endif 50 | 51 | } 52 | `; 53 | -------------------------------------------------------------------------------- /module/loaders/FontLoader.js: -------------------------------------------------------------------------------- 1 | import { Font } from '../extras/core/Font.js'; 2 | import { FileLoader } from './FileLoader.js'; 3 | import { DefaultLoadingManager } from './LoadingManager.js'; 4 | 5 | /** 6 | * @author mrdoob / http://mrdoob.com/ 7 | */ 8 | 9 | function FontLoader( manager ) { 10 | 11 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 12 | 13 | } 14 | 15 | Object.assign( FontLoader.prototype, { 16 | 17 | load: function ( url, onLoad, onProgress, onError ) { 18 | 19 | var scope = this; 20 | 21 | var loader = new FileLoader( this.manager ); 22 | loader.setPath( this.path ); 23 | loader.load( url, function ( text ) { 24 | 25 | var json; 26 | 27 | try { 28 | 29 | json = JSON.parse( text ); 30 | 31 | } catch ( e ) { 32 | 33 | console.warn( 'THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead.' ); 34 | json = JSON.parse( text.substring( 65, text.length - 2 ) ); 35 | 36 | } 37 | 38 | var font = scope.parse( json ); 39 | 40 | if ( onLoad ) onLoad( font ); 41 | 42 | }, onProgress, onError ); 43 | 44 | }, 45 | 46 | parse: function ( json ) { 47 | 48 | return new Font( json ); 49 | 50 | }, 51 | 52 | setPath: function ( value ) { 53 | 54 | this.path = value; 55 | return this; 56 | 57 | } 58 | 59 | } ); 60 | 61 | 62 | export { FontLoader }; 63 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/sprite_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform float rotation; 3 | uniform vec2 center; 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | void main() { 12 | 13 | #include 14 | 15 | vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 ); 16 | 17 | vec2 scale; 18 | scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) ); 19 | scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) ); 20 | 21 | #ifndef USE_SIZEATTENUATION 22 | 23 | bool isPerspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); 24 | 25 | if ( isPerspective ) scale *= - mvPosition.z; 26 | 27 | #endif 28 | 29 | vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; 30 | 31 | vec2 rotatedPosition; 32 | rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; 33 | rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; 34 | 35 | mvPosition.xy += rotatedPosition; 36 | 37 | gl_Position = projectionMatrix * mvPosition; 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | } 44 | `; 45 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_NORMALMAP 3 | 4 | uniform sampler2D normalMap; 5 | uniform vec2 normalScale; 6 | 7 | #ifdef OBJECTSPACE_NORMALMAP 8 | 9 | uniform mat3 normalMatrix; 10 | 11 | #else 12 | 13 | // Per-Pixel Tangent Space Normal Mapping 14 | // http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html 15 | 16 | vec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) { 17 | 18 | // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 19 | 20 | vec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) ); 21 | vec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) ); 22 | vec2 st0 = dFdx( vUv.st ); 23 | vec2 st1 = dFdy( vUv.st ); 24 | 25 | float scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude 26 | 27 | vec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale ); 28 | vec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale ); 29 | vec3 N = normalize( surf_norm ); 30 | mat3 tsn = mat3( S, T, N ); 31 | 32 | vec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; 33 | 34 | mapN.xy *= normalScale; 35 | mapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); 36 | 37 | return normalize( tsn * mapN ); 38 | 39 | } 40 | 41 | #endif 42 | 43 | #endif 44 | `; 45 | -------------------------------------------------------------------------------- /module/core/Clock.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | */ 4 | 5 | function Clock( autoStart ) { 6 | 7 | this.autoStart = ( autoStart !== undefined ) ? autoStart : true; 8 | 9 | this.startTime = 0; 10 | this.oldTime = 0; 11 | this.elapsedTime = 0; 12 | 13 | this.running = false; 14 | 15 | } 16 | 17 | Object.assign( Clock.prototype, { 18 | 19 | start: function () { 20 | 21 | this.startTime = ( typeof performance === 'undefined' ? Date : performance ).now(); // see #10732 22 | 23 | this.oldTime = this.startTime; 24 | this.elapsedTime = 0; 25 | this.running = true; 26 | 27 | }, 28 | 29 | stop: function () { 30 | 31 | this.getElapsedTime(); 32 | this.running = false; 33 | this.autoStart = false; 34 | 35 | }, 36 | 37 | getElapsedTime: function () { 38 | 39 | this.getDelta(); 40 | return this.elapsedTime; 41 | 42 | }, 43 | 44 | getDelta: function () { 45 | 46 | var diff = 0; 47 | 48 | if ( this.autoStart && ! this.running ) { 49 | 50 | this.start(); 51 | return 0; 52 | 53 | } 54 | 55 | if ( this.running ) { 56 | 57 | var newTime = ( typeof performance === 'undefined' ? Date : performance ).now(); 58 | 59 | diff = ( newTime - this.oldTime ) / 1000; 60 | this.oldTime = newTime; 61 | 62 | this.elapsedTime += diff; 63 | 64 | } 65 | 66 | return diff; 67 | 68 | } 69 | 70 | } ); 71 | 72 | 73 | export { Clock }; 74 | -------------------------------------------------------------------------------- /module/materials/PointsMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author alteredq / http://alteredqualia.com/ 7 | * 8 | * parameters = { 9 | * color: , 10 | * opacity: , 11 | * map: new THREE.Texture( ), 12 | * 13 | * size: , 14 | * sizeAttenuation: 15 | * 16 | * morphTargets: 17 | * } 18 | */ 19 | 20 | function PointsMaterial( parameters ) { 21 | 22 | Material.call( this ); 23 | 24 | this.type = 'PointsMaterial'; 25 | 26 | this.color = new Color( 0xffffff ); 27 | 28 | this.map = null; 29 | 30 | this.size = 1; 31 | this.sizeAttenuation = true; 32 | 33 | this.morphTargets = false; 34 | 35 | this.lights = false; 36 | 37 | this.setValues( parameters ); 38 | 39 | } 40 | 41 | PointsMaterial.prototype = Object.create( Material.prototype ); 42 | PointsMaterial.prototype.constructor = PointsMaterial; 43 | 44 | PointsMaterial.prototype.isPointsMaterial = true; 45 | 46 | PointsMaterial.prototype.copy = function ( source ) { 47 | 48 | Material.prototype.copy.call( this, source ); 49 | 50 | this.color.copy( source.color ); 51 | 52 | this.map = source.map; 53 | 54 | this.size = source.size; 55 | this.sizeAttenuation = source.sizeAttenuation; 56 | 57 | this.morphTargets = source.morphTargets; 58 | 59 | return this; 60 | 61 | }; 62 | 63 | 64 | export { PointsMaterial }; 65 | -------------------------------------------------------------------------------- /module/textures/DepthTexture.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Matt DesLauriers / @mattdesl 3 | * @author atix / arthursilber.de 4 | */ 5 | 6 | import { Texture } from './Texture.js'; 7 | import { NearestFilter, UnsignedShortType, UnsignedInt248Type, DepthFormat, DepthStencilFormat } from '../constants.js'; 8 | 9 | function DepthTexture( width, height, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, format ) { 10 | 11 | format = format !== undefined ? format : DepthFormat; 12 | 13 | if ( format !== DepthFormat && format !== DepthStencilFormat ) { 14 | 15 | throw new Error( 'DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat' ); 16 | 17 | } 18 | 19 | if ( type === undefined && format === DepthFormat ) type = UnsignedShortType; 20 | if ( type === undefined && format === DepthStencilFormat ) type = UnsignedInt248Type; 21 | 22 | Texture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ); 23 | 24 | this.image = { width: width, height: height }; 25 | 26 | this.magFilter = magFilter !== undefined ? magFilter : NearestFilter; 27 | this.minFilter = minFilter !== undefined ? minFilter : NearestFilter; 28 | 29 | this.flipY = false; 30 | this.generateMipmaps = false; 31 | 32 | } 33 | 34 | DepthTexture.prototype = Object.create( Texture.prototype ); 35 | DepthTexture.prototype.constructor = DepthTexture; 36 | DepthTexture.prototype.isDepthTexture = true; 37 | 38 | export { DepthTexture }; 39 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define PHYSICAL 3 | 4 | varying vec3 vViewPosition; 5 | 6 | #ifndef FLAT_SHADED 7 | 8 | varying vec3 vNormal; 9 | 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | void main() { 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED 37 | 38 | vNormal = normalize( transformedNormal ); 39 | 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | vViewPosition = - mvPosition.xyz; 51 | 52 | #include 53 | #include 54 | #include 55 | 56 | } 57 | `; 58 | -------------------------------------------------------------------------------- /module/math/Cylindrical.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Mugen87 / https://github.com/Mugen87 3 | * 4 | * Ref: https://en.wikipedia.org/wiki/Cylindrical_coordinate_system 5 | * 6 | */ 7 | 8 | function Cylindrical( radius, theta, y ) { 9 | 10 | this.radius = ( radius !== undefined ) ? radius : 1.0; // distance from the origin to a point in the x-z plane 11 | this.theta = ( theta !== undefined ) ? theta : 0; // counterclockwise angle in the x-z plane measured in radians from the positive z-axis 12 | this.y = ( y !== undefined ) ? y : 0; // height above the x-z plane 13 | 14 | return this; 15 | 16 | } 17 | 18 | Object.assign( Cylindrical.prototype, { 19 | 20 | set: function ( radius, theta, y ) { 21 | 22 | this.radius = radius; 23 | this.theta = theta; 24 | this.y = y; 25 | 26 | return this; 27 | 28 | }, 29 | 30 | clone: function () { 31 | 32 | return new this.constructor().copy( this ); 33 | 34 | }, 35 | 36 | copy: function ( other ) { 37 | 38 | this.radius = other.radius; 39 | this.theta = other.theta; 40 | this.y = other.y; 41 | 42 | return this; 43 | 44 | }, 45 | 46 | setFromVector3: function ( v ) { 47 | 48 | return this.setFromCartesianCoords( v.x, v.y, v.z ); 49 | 50 | }, 51 | 52 | setFromCartesianCoords: function ( x, y, z ) { 53 | 54 | this.radius = Math.sqrt( x * x + z * z ); 55 | this.theta = Math.atan2( x, z ); 56 | this.y = y; 57 | 58 | return this; 59 | 60 | } 61 | 62 | } ); 63 | 64 | 65 | export { Cylindrical }; 66 | -------------------------------------------------------------------------------- /module/scenes/Scene.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | 3 | /** 4 | * @author mrdoob / http://mrdoob.com/ 5 | */ 6 | 7 | function Scene() { 8 | 9 | Object3D.call( this ); 10 | 11 | this.type = 'Scene'; 12 | 13 | this.background = null; 14 | this.fog = null; 15 | this.overrideMaterial = null; 16 | 17 | this.autoUpdate = true; // checked by the renderer 18 | 19 | } 20 | 21 | Scene.prototype = Object.assign( Object.create( Object3D.prototype ), { 22 | 23 | constructor: Scene, 24 | 25 | copy: function ( source, recursive ) { 26 | 27 | Object3D.prototype.copy.call( this, source, recursive ); 28 | 29 | if ( source.background !== null ) this.background = source.background.clone(); 30 | if ( source.fog !== null ) this.fog = source.fog.clone(); 31 | if ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone(); 32 | 33 | this.autoUpdate = source.autoUpdate; 34 | this.matrixAutoUpdate = source.matrixAutoUpdate; 35 | 36 | return this; 37 | 38 | }, 39 | 40 | toJSON: function ( meta ) { 41 | 42 | var data = Object3D.prototype.toJSON.call( this, meta ); 43 | 44 | if ( this.background !== null ) data.object.background = this.background.toJSON( meta ); 45 | if ( this.fog !== null ) data.object.fog = this.fog.toJSON(); 46 | 47 | return data; 48 | 49 | }, 50 | 51 | dispose: function () { 52 | 53 | this.dispatchEvent( { type: 'dispose' } ); 54 | 55 | } 56 | 57 | } ); 58 | 59 | 60 | 61 | export { Scene }; 62 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshphong_vert.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define PHONG 3 | 4 | varying vec3 vViewPosition; 5 | 6 | #ifndef FLAT_SHADED 7 | 8 | varying vec3 vNormal; 9 | 10 | #endif 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void main() { 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED 38 | 39 | vNormal = normalize( transformedNormal ); 40 | 41 | #endif 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | vViewPosition = - mvPosition.xyz; 52 | 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | } 59 | `; 60 | -------------------------------------------------------------------------------- /module/core/Face3.js: -------------------------------------------------------------------------------- 1 | import { Color } from '../math/Color.js'; 2 | import { Vector3 } from '../math/Vector3.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author alteredq / http://alteredqualia.com/ 7 | */ 8 | 9 | function Face3( a, b, c, normal, color, materialIndex ) { 10 | 11 | this.a = a; 12 | this.b = b; 13 | this.c = c; 14 | 15 | this.normal = ( normal && normal.isVector3 ) ? normal : new Vector3(); 16 | this.vertexNormals = Array.isArray( normal ) ? normal : []; 17 | 18 | this.color = ( color && color.isColor ) ? color : new Color(); 19 | this.vertexColors = Array.isArray( color ) ? color : []; 20 | 21 | this.materialIndex = materialIndex !== undefined ? materialIndex : 0; 22 | 23 | } 24 | 25 | Object.assign( Face3.prototype, { 26 | 27 | clone: function () { 28 | 29 | return new this.constructor().copy( this ); 30 | 31 | }, 32 | 33 | copy: function ( source ) { 34 | 35 | this.a = source.a; 36 | this.b = source.b; 37 | this.c = source.c; 38 | 39 | this.normal.copy( source.normal ); 40 | this.color.copy( source.color ); 41 | 42 | this.materialIndex = source.materialIndex; 43 | 44 | for ( var i = 0, il = source.vertexNormals.length; i < il; i ++ ) { 45 | 46 | this.vertexNormals[ i ] = source.vertexNormals[ i ].clone(); 47 | 48 | } 49 | 50 | for ( var i = 0, il = source.vertexColors.length; i < il; i ++ ) { 51 | 52 | this.vertexColors[ i ] = source.vertexColors[ i ].clone(); 53 | 54 | } 55 | 56 | return this; 57 | 58 | } 59 | 60 | } ); 61 | 62 | 63 | export { Face3 }; 64 | -------------------------------------------------------------------------------- /module/geometries/TetrahedronGeometry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author timothypratley / https://github.com/timothypratley 3 | * @author Mugen87 / https://github.com/Mugen87 4 | */ 5 | 6 | import { Geometry } from '../core/Geometry.js'; 7 | import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js'; 8 | 9 | // TetrahedronGeometry 10 | 11 | function TetrahedronGeometry( radius, detail ) { 12 | 13 | Geometry.call( this ); 14 | 15 | this.type = 'TetrahedronGeometry'; 16 | 17 | this.parameters = { 18 | radius: radius, 19 | detail: detail 20 | }; 21 | 22 | this.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) ); 23 | this.mergeVertices(); 24 | 25 | } 26 | 27 | TetrahedronGeometry.prototype = Object.create( Geometry.prototype ); 28 | TetrahedronGeometry.prototype.constructor = TetrahedronGeometry; 29 | 30 | // TetrahedronBufferGeometry 31 | 32 | function TetrahedronBufferGeometry( radius, detail ) { 33 | 34 | var vertices = [ 35 | 1, 1, 1, - 1, - 1, 1, - 1, 1, - 1, 1, - 1, - 1 36 | ]; 37 | 38 | var indices = [ 39 | 2, 1, 0, 0, 3, 2, 1, 3, 0, 2, 3, 1 40 | ]; 41 | 42 | PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail ); 43 | 44 | this.type = 'TetrahedronBufferGeometry'; 45 | 46 | this.parameters = { 47 | radius: radius, 48 | detail: detail 49 | }; 50 | 51 | } 52 | 53 | TetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype ); 54 | TetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry; 55 | 56 | 57 | export { TetrahedronGeometry, TetrahedronBufferGeometry }; 58 | -------------------------------------------------------------------------------- /module/loaders/CubeTextureLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { ImageLoader } from './ImageLoader.js'; 6 | import { CubeTexture } from '../textures/CubeTexture.js'; 7 | import { DefaultLoadingManager } from './LoadingManager.js'; 8 | 9 | 10 | function CubeTextureLoader( manager ) { 11 | 12 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 13 | 14 | } 15 | 16 | Object.assign( CubeTextureLoader.prototype, { 17 | 18 | crossOrigin: 'anonymous', 19 | 20 | load: function ( urls, onLoad, onProgress, onError ) { 21 | 22 | var texture = new CubeTexture(); 23 | 24 | var loader = new ImageLoader( this.manager ); 25 | loader.setCrossOrigin( this.crossOrigin ); 26 | loader.setPath( this.path ); 27 | 28 | var loaded = 0; 29 | 30 | function loadTexture( i ) { 31 | 32 | loader.load( urls[ i ], function ( image ) { 33 | 34 | texture.images[ i ] = image; 35 | 36 | loaded ++; 37 | 38 | if ( loaded === 6 ) { 39 | 40 | texture.needsUpdate = true; 41 | 42 | if ( onLoad ) onLoad( texture ); 43 | 44 | } 45 | 46 | }, undefined, onError ); 47 | 48 | } 49 | 50 | for ( var i = 0; i < urls.length; ++ i ) { 51 | 52 | loadTexture( i ); 53 | 54 | } 55 | 56 | return texture; 57 | 58 | }, 59 | 60 | setCrossOrigin: function ( value ) { 61 | 62 | this.crossOrigin = value; 63 | return this; 64 | 65 | }, 66 | 67 | setPath: function ( value ) { 68 | 69 | this.path = value; 70 | return this; 71 | 72 | } 73 | 74 | } ); 75 | 76 | 77 | export { CubeTextureLoader }; 78 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_BUMPMAP 3 | 4 | uniform sampler2D bumpMap; 5 | uniform float bumpScale; 6 | 7 | // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen 8 | // http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf 9 | 10 | // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) 11 | 12 | vec2 dHdxy_fwd() { 13 | 14 | vec2 dSTdx = dFdx( vUv ); 15 | vec2 dSTdy = dFdy( vUv ); 16 | 17 | float Hll = bumpScale * texture2D( bumpMap, vUv ).x; 18 | float dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll; 19 | float dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll; 20 | 21 | return vec2( dBx, dBy ); 22 | 23 | } 24 | 25 | vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) { 26 | 27 | // Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988 28 | 29 | vec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) ); 30 | vec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) ); 31 | vec3 vN = surf_norm; // normalized 32 | 33 | vec3 R1 = cross( vSigmaY, vN ); 34 | vec3 R2 = cross( vN, vSigmaX ); 35 | 36 | float fDet = dot( vSigmaX, R1 ); 37 | 38 | fDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 ); 39 | 40 | vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); 41 | return normalize( abs( fDet ) * surf_norm - vGrad ); 42 | 43 | } 44 | 45 | #endif 46 | `; 47 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLIndexedBufferRenderer.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) { 6 | 7 | var mode; 8 | 9 | function setMode( value ) { 10 | 11 | mode = value; 12 | 13 | } 14 | 15 | var type, bytesPerElement; 16 | 17 | function setIndex( value ) { 18 | 19 | type = value.type; 20 | bytesPerElement = value.bytesPerElement; 21 | 22 | } 23 | 24 | function render( start, count ) { 25 | 26 | gl.drawElements( mode, count, type, start * bytesPerElement ); 27 | 28 | info.update( count, mode ); 29 | 30 | } 31 | 32 | function renderInstances( geometry, start, count ) { 33 | 34 | var extension; 35 | 36 | if ( capabilities.isWebGL2 ) { 37 | 38 | extension = gl; 39 | 40 | } else { 41 | 42 | var extension = extensions.get( 'ANGLE_instanced_arrays' ); 43 | 44 | if ( extension === null ) { 45 | 46 | console.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' ); 47 | return; 48 | 49 | } 50 | 51 | } 52 | 53 | extension[ capabilities.isWebGL2 ? 'drawElementsInstanced' : 'drawElementsInstancedANGLE' ]( mode, count, type, start * bytesPerElement, geometry.maxInstancedCount ); 54 | 55 | info.update( count, mode, geometry.maxInstancedCount ); 56 | 57 | } 58 | 59 | // 60 | 61 | this.setMode = setMode; 62 | this.setIndex = setIndex; 63 | this.render = render; 64 | this.renderInstances = renderInstances; 65 | 66 | } 67 | 68 | 69 | export { WebGLIndexedBufferRenderer }; 70 | -------------------------------------------------------------------------------- /module/geometries/OctahedronGeometry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author timothypratley / https://github.com/timothypratley 3 | * @author Mugen87 / https://github.com/Mugen87 4 | */ 5 | 6 | import { Geometry } from '../core/Geometry.js'; 7 | import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js'; 8 | 9 | // OctahedronGeometry 10 | 11 | function OctahedronGeometry( radius, detail ) { 12 | 13 | Geometry.call( this ); 14 | 15 | this.type = 'OctahedronGeometry'; 16 | 17 | this.parameters = { 18 | radius: radius, 19 | detail: detail 20 | }; 21 | 22 | this.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) ); 23 | this.mergeVertices(); 24 | 25 | } 26 | 27 | OctahedronGeometry.prototype = Object.create( Geometry.prototype ); 28 | OctahedronGeometry.prototype.constructor = OctahedronGeometry; 29 | 30 | // OctahedronBufferGeometry 31 | 32 | function OctahedronBufferGeometry( radius, detail ) { 33 | 34 | var vertices = [ 35 | 1, 0, 0, - 1, 0, 0, 0, 1, 0, 36 | 0, - 1, 0, 0, 0, 1, 0, 0, - 1 37 | ]; 38 | 39 | var indices = [ 40 | 0, 2, 4, 0, 4, 3, 0, 3, 5, 41 | 0, 5, 2, 1, 2, 5, 1, 5, 3, 42 | 1, 3, 4, 1, 4, 2 43 | ]; 44 | 45 | PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail ); 46 | 47 | this.type = 'OctahedronBufferGeometry'; 48 | 49 | this.parameters = { 50 | radius: radius, 51 | detail: detail 52 | }; 53 | 54 | } 55 | 56 | OctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype ); 57 | OctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry; 58 | 59 | 60 | export { OctahedronGeometry, OctahedronBufferGeometry }; 61 | -------------------------------------------------------------------------------- /module/loaders/TextureLoader.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { RGBAFormat, RGBFormat } from '../constants.js'; 6 | import { ImageLoader } from './ImageLoader.js'; 7 | import { Texture } from '../textures/Texture.js'; 8 | import { DefaultLoadingManager } from './LoadingManager.js'; 9 | 10 | 11 | function TextureLoader( manager ) { 12 | 13 | this.manager = ( manager !== undefined ) ? manager : DefaultLoadingManager; 14 | 15 | } 16 | 17 | Object.assign( TextureLoader.prototype, { 18 | 19 | crossOrigin: 'anonymous', 20 | 21 | load: function ( url, onLoad, onProgress, onError ) { 22 | 23 | var texture = new Texture(); 24 | 25 | var loader = new ImageLoader( this.manager ); 26 | loader.setCrossOrigin( this.crossOrigin ); 27 | loader.setPath( this.path ); 28 | 29 | loader.load( url, function ( image ) { 30 | 31 | texture.image = image; 32 | 33 | // JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB. 34 | var isJPEG = url.search( /\.jpe?g($|\?)/i ) > 0 || url.search( /^data\:image\/jpeg/ ) === 0; 35 | 36 | texture.format = isJPEG ? RGBFormat : RGBAFormat; 37 | texture.needsUpdate = true; 38 | 39 | if ( onLoad !== undefined ) { 40 | 41 | onLoad( texture ); 42 | 43 | } 44 | 45 | }, onProgress, onError ); 46 | 47 | return texture; 48 | 49 | }, 50 | 51 | setCrossOrigin: function ( value ) { 52 | 53 | this.crossOrigin = value; 54 | return this; 55 | 56 | }, 57 | 58 | setPath: function ( value ) { 59 | 60 | this.path = value; 61 | return this; 62 | 63 | } 64 | 65 | } ); 66 | 67 | 68 | export { TextureLoader }; 69 | -------------------------------------------------------------------------------- /module/extras/core/Interpolations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | * 4 | * Bezier Curves formulas obtained from 5 | * http://en.wikipedia.org/wiki/Bézier_curve 6 | */ 7 | 8 | function CatmullRom( t, p0, p1, p2, p3 ) { 9 | 10 | var v0 = ( p2 - p0 ) * 0.5; 11 | var v1 = ( p3 - p1 ) * 0.5; 12 | var t2 = t * t; 13 | var t3 = t * t2; 14 | return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1; 15 | 16 | } 17 | 18 | // 19 | 20 | function QuadraticBezierP0( t, p ) { 21 | 22 | var k = 1 - t; 23 | return k * k * p; 24 | 25 | } 26 | 27 | function QuadraticBezierP1( t, p ) { 28 | 29 | return 2 * ( 1 - t ) * t * p; 30 | 31 | } 32 | 33 | function QuadraticBezierP2( t, p ) { 34 | 35 | return t * t * p; 36 | 37 | } 38 | 39 | function QuadraticBezier( t, p0, p1, p2 ) { 40 | 41 | return QuadraticBezierP0( t, p0 ) + QuadraticBezierP1( t, p1 ) + 42 | QuadraticBezierP2( t, p2 ); 43 | 44 | } 45 | 46 | // 47 | 48 | function CubicBezierP0( t, p ) { 49 | 50 | var k = 1 - t; 51 | return k * k * k * p; 52 | 53 | } 54 | 55 | function CubicBezierP1( t, p ) { 56 | 57 | var k = 1 - t; 58 | return 3 * k * k * t * p; 59 | 60 | } 61 | 62 | function CubicBezierP2( t, p ) { 63 | 64 | return 3 * ( 1 - t ) * t * t * p; 65 | 66 | } 67 | 68 | function CubicBezierP3( t, p ) { 69 | 70 | return t * t * t * p; 71 | 72 | } 73 | 74 | function CubicBezier( t, p0, p1, p2, p3 ) { 75 | 76 | return CubicBezierP0( t, p0 ) + CubicBezierP1( t, p1 ) + CubicBezierP2( t, p2 ) + 77 | CubicBezierP3( t, p3 ); 78 | 79 | } 80 | 81 | export { CatmullRom, QuadraticBezier, CubicBezier }; 82 | -------------------------------------------------------------------------------- /module/lights/Light.js: -------------------------------------------------------------------------------- 1 | import { Object3D } from '../core/Object3D.js'; 2 | import { Color } from '../math/Color.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author alteredq / http://alteredqualia.com/ 7 | */ 8 | 9 | function Light( color, intensity ) { 10 | 11 | Object3D.call( this ); 12 | 13 | this.type = 'Light'; 14 | 15 | this.color = new Color( color ); 16 | this.intensity = intensity !== undefined ? intensity : 1; 17 | 18 | this.receiveShadow = undefined; 19 | 20 | } 21 | 22 | Light.prototype = Object.assign( Object.create( Object3D.prototype ), { 23 | 24 | constructor: Light, 25 | 26 | isLight: true, 27 | 28 | copy: function ( source ) { 29 | 30 | Object3D.prototype.copy.call( this, source ); 31 | 32 | this.color.copy( source.color ); 33 | this.intensity = source.intensity; 34 | 35 | return this; 36 | 37 | }, 38 | 39 | toJSON: function ( meta ) { 40 | 41 | var data = Object3D.prototype.toJSON.call( this, meta ); 42 | 43 | data.object.color = this.color.getHex(); 44 | data.object.intensity = this.intensity; 45 | 46 | if ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex(); 47 | 48 | if ( this.distance !== undefined ) data.object.distance = this.distance; 49 | if ( this.angle !== undefined ) data.object.angle = this.angle; 50 | if ( this.decay !== undefined ) data.object.decay = this.decay; 51 | if ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra; 52 | 53 | if ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON(); 54 | 55 | return data; 56 | 57 | } 58 | 59 | } ); 60 | 61 | 62 | export { Light }; 63 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLInfo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Mugen87 / https://github.com/Mugen87 3 | */ 4 | 5 | function WebGLInfo( gl ) { 6 | 7 | var memory = { 8 | geometries: 0, 9 | textures: 0 10 | }; 11 | 12 | var render = { 13 | frame: 0, 14 | calls: 0, 15 | triangles: 0, 16 | points: 0, 17 | lines: 0 18 | }; 19 | 20 | function update( count, mode, instanceCount ) { 21 | 22 | instanceCount = instanceCount || 1; 23 | 24 | render.calls ++; 25 | 26 | switch ( mode ) { 27 | 28 | case gl.TRIANGLES: 29 | render.triangles += instanceCount * ( count / 3 ); 30 | break; 31 | 32 | case gl.TRIANGLE_STRIP: 33 | case gl.TRIANGLE_FAN: 34 | render.triangles += instanceCount * ( count - 2 ); 35 | break; 36 | 37 | case gl.LINES: 38 | render.lines += instanceCount * ( count / 2 ); 39 | break; 40 | 41 | case gl.LINE_STRIP: 42 | render.lines += instanceCount * ( count - 1 ); 43 | break; 44 | 45 | case gl.LINE_LOOP: 46 | render.lines += instanceCount * count; 47 | break; 48 | 49 | case gl.POINTS: 50 | render.points += instanceCount * count; 51 | break; 52 | 53 | default: 54 | console.error( 'THREE.WebGLInfo: Unknown draw mode:', mode ); 55 | break; 56 | 57 | } 58 | 59 | } 60 | 61 | function reset() { 62 | 63 | render.frame ++; 64 | render.calls = 0; 65 | render.triangles = 0; 66 | render.points = 0; 67 | render.lines = 0; 68 | 69 | } 70 | 71 | return { 72 | memory: memory, 73 | render: render, 74 | programs: null, 75 | autoReset: true, 76 | reset: reset, 77 | update: update 78 | }; 79 | 80 | } 81 | 82 | 83 | export { WebGLInfo }; 84 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/packing.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | vec3 packNormalToRGB( const in vec3 normal ) { 3 | return normalize( normal ) * 0.5 + 0.5; 4 | } 5 | 6 | vec3 unpackRGBToNormal( const in vec3 rgb ) { 7 | return 2.0 * rgb.xyz - 1.0; 8 | } 9 | 10 | const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1) 11 | const float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1) 12 | 13 | const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. ); 14 | const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. ); 15 | 16 | const float ShiftRight8 = 1. / 256.; 17 | 18 | vec4 packDepthToRGBA( const in float v ) { 19 | vec4 r = vec4( fract( v * PackFactors ), v ); 20 | r.yzw -= r.xyz * ShiftRight8; // tidy overflow 21 | return r * PackUpscale; 22 | } 23 | 24 | float unpackRGBAToDepth( const in vec4 v ) { 25 | return dot( v, UnpackFactors ); 26 | } 27 | 28 | // NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions 29 | 30 | float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { 31 | return ( viewZ + near ) / ( near - far ); 32 | } 33 | float orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) { 34 | return linearClipZ * ( near - far ) - near; 35 | } 36 | 37 | float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { 38 | return (( near + viewZ ) * far ) / (( far - near ) * viewZ ); 39 | } 40 | float perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) { 41 | return ( near * far ) / ( ( far - near ) * invClipZ - far ); 42 | } 43 | `; 44 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | float getShadowMask() { 3 | 4 | float shadow = 1.0; 5 | 6 | #ifdef USE_SHADOWMAP 7 | 8 | #if NUM_DIR_LIGHTS > 0 9 | 10 | DirectionalLight directionalLight; 11 | 12 | #pragma unroll_loop 13 | for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { 14 | 15 | directionalLight = directionalLights[ i ]; 16 | shadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; 17 | 18 | } 19 | 20 | #endif 21 | 22 | #if NUM_SPOT_LIGHTS > 0 23 | 24 | SpotLight spotLight; 25 | 26 | #pragma unroll_loop 27 | for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { 28 | 29 | spotLight = spotLights[ i ]; 30 | shadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0; 31 | 32 | } 33 | 34 | #endif 35 | 36 | #if NUM_POINT_LIGHTS > 0 37 | 38 | PointLight pointLight; 39 | 40 | #pragma unroll_loop 41 | for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { 42 | 43 | pointLight = pointLights[ i ]; 44 | shadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; 45 | 46 | } 47 | 48 | #endif 49 | 50 | /* 51 | #if NUM_RECT_AREA_LIGHTS > 0 52 | 53 | // TODO (abelnation): update shadow for Area light 54 | 55 | #endif 56 | */ 57 | 58 | #endif 59 | 60 | return shadow; 61 | 62 | } 63 | `; 64 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLExtensions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function WebGLExtensions( gl ) { 6 | 7 | var extensions = {}; 8 | 9 | return { 10 | 11 | get: function ( name ) { 12 | 13 | if ( extensions[ name ] !== undefined ) { 14 | 15 | return extensions[ name ]; 16 | 17 | } 18 | 19 | var extension; 20 | 21 | switch ( name ) { 22 | 23 | case 'WEBGL_depth_texture': 24 | extension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' ); 25 | break; 26 | 27 | case 'EXT_texture_filter_anisotropic': 28 | extension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' ); 29 | break; 30 | 31 | case 'WEBGL_compressed_texture_s3tc': 32 | extension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' ); 33 | break; 34 | 35 | case 'WEBGL_compressed_texture_pvrtc': 36 | extension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' ); 37 | break; 38 | 39 | default: 40 | extension = gl.getExtension( name ); 41 | 42 | } 43 | 44 | if ( extension === null ) { 45 | 46 | console.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' ); 47 | 48 | } 49 | 50 | extensions[ name ] = extension; 51 | 52 | return extension; 53 | 54 | } 55 | 56 | }; 57 | 58 | } 59 | 60 | 61 | export { WebGLExtensions }; 62 | -------------------------------------------------------------------------------- /module/lights/PointLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { PerspectiveCamera } from '../cameras/PerspectiveCamera.js'; 3 | import { LightShadow } from './LightShadow.js'; 4 | 5 | /** 6 | * @author mrdoob / http://mrdoob.com/ 7 | */ 8 | 9 | 10 | function PointLight( color, intensity, distance, decay ) { 11 | 12 | Light.call( this, color, intensity ); 13 | 14 | this.type = 'PointLight'; 15 | 16 | Object.defineProperty( this, 'power', { 17 | get: function () { 18 | 19 | // intensity = power per solid angle. 20 | // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 21 | return this.intensity * 4 * Math.PI; 22 | 23 | }, 24 | set: function ( power ) { 25 | 26 | // intensity = power per solid angle. 27 | // ref: equation (15) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 28 | this.intensity = power / ( 4 * Math.PI ); 29 | 30 | } 31 | } ); 32 | 33 | this.distance = ( distance !== undefined ) ? distance : 0; 34 | this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2. 35 | 36 | this.shadow = new LightShadow( new PerspectiveCamera( 90, 1, 0.5, 500 ) ); 37 | 38 | } 39 | 40 | PointLight.prototype = Object.assign( Object.create( Light.prototype ), { 41 | 42 | constructor: PointLight, 43 | 44 | isPointLight: true, 45 | 46 | copy: function ( source ) { 47 | 48 | Light.prototype.copy.call( this, source ); 49 | 50 | this.distance = source.distance; 51 | this.decay = source.decay; 52 | 53 | this.shadow = source.shadow.clone(); 54 | 55 | return this; 56 | 57 | } 58 | 59 | } ); 60 | 61 | 62 | export { PointLight }; 63 | -------------------------------------------------------------------------------- /module/geometries/ConeGeometry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author abelnation / http://github.com/abelnation 3 | */ 4 | 5 | import { CylinderGeometry } from './CylinderGeometry.js'; 6 | import { CylinderBufferGeometry } from './CylinderGeometry.js'; 7 | 8 | // ConeGeometry 9 | 10 | function ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) { 11 | 12 | CylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ); 13 | 14 | this.type = 'ConeGeometry'; 15 | 16 | this.parameters = { 17 | radius: radius, 18 | height: height, 19 | radialSegments: radialSegments, 20 | heightSegments: heightSegments, 21 | openEnded: openEnded, 22 | thetaStart: thetaStart, 23 | thetaLength: thetaLength 24 | }; 25 | 26 | } 27 | 28 | ConeGeometry.prototype = Object.create( CylinderGeometry.prototype ); 29 | ConeGeometry.prototype.constructor = ConeGeometry; 30 | 31 | // ConeBufferGeometry 32 | 33 | function ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) { 34 | 35 | CylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ); 36 | 37 | this.type = 'ConeBufferGeometry'; 38 | 39 | this.parameters = { 40 | radius: radius, 41 | height: height, 42 | radialSegments: radialSegments, 43 | heightSegments: heightSegments, 44 | openEnded: openEnded, 45 | thetaStart: thetaStart, 46 | thetaLength: thetaLength 47 | }; 48 | 49 | } 50 | 51 | ConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype ); 52 | ConeBufferGeometry.prototype.constructor = ConeBufferGeometry; 53 | 54 | 55 | export { ConeGeometry, ConeBufferGeometry }; 56 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | varying vec3 vViewPosition; 3 | 4 | #ifndef FLAT_SHADED 5 | 6 | varying vec3 vNormal; 7 | 8 | #endif 9 | 10 | 11 | struct BlinnPhongMaterial { 12 | 13 | vec3 diffuseColor; 14 | vec3 specularColor; 15 | float specularShininess; 16 | float specularStrength; 17 | 18 | }; 19 | 20 | void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 21 | 22 | #ifdef TOON 23 | 24 | vec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color; 25 | 26 | #else 27 | 28 | float dotNL = saturate( dot( geometry.normal, directLight.direction ) ); 29 | vec3 irradiance = dotNL * directLight.color; 30 | 31 | #endif 32 | 33 | #ifndef PHYSICALLY_CORRECT_LIGHTS 34 | 35 | irradiance *= PI; // punctual light 36 | 37 | #endif 38 | 39 | reflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); 40 | 41 | reflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength; 42 | 43 | } 44 | 45 | void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { 46 | 47 | reflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor ); 48 | 49 | } 50 | 51 | #define RE_Direct RE_Direct_BlinnPhong 52 | #define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong 53 | 54 | #define Material_LightProbeLOD( material ) (0) 55 | `; 56 | -------------------------------------------------------------------------------- /module/helpers/Box3Helper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author WestLangley / http://github.com/WestLangley 3 | */ 4 | 5 | import { LineSegments } from '../objects/LineSegments.js'; 6 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 7 | import { BufferAttribute } from '../core/BufferAttribute.js'; 8 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 9 | import { BufferGeometry } from '../core/BufferGeometry.js'; 10 | import { Object3D } from '../core/Object3D.js'; 11 | 12 | function Box3Helper( box, hex ) { 13 | 14 | this.type = 'Box3Helper'; 15 | 16 | this.box = box; 17 | 18 | var color = ( hex !== undefined ) ? hex : 0xffff00; 19 | 20 | var indices = 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 ] ); 21 | 22 | var positions = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, - 1, - 1, 1, - 1, - 1, - 1, - 1, 1, - 1, - 1 ]; 23 | 24 | var geometry = new BufferGeometry(); 25 | 26 | geometry.setIndex( new BufferAttribute( indices, 1 ) ); 27 | 28 | geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); 29 | 30 | LineSegments.call( this, geometry, new LineBasicMaterial( { color: color } ) ); 31 | 32 | this.geometry.computeBoundingSphere(); 33 | 34 | } 35 | 36 | Box3Helper.prototype = Object.create( LineSegments.prototype ); 37 | Box3Helper.prototype.constructor = Box3Helper; 38 | 39 | Box3Helper.prototype.updateMatrixWorld = function ( force ) { 40 | 41 | var box = this.box; 42 | 43 | if ( box.isEmpty() ) return; 44 | 45 | box.getCenter( this.position ); 46 | 47 | box.getSize( this.scale ); 48 | 49 | this.scale.multiplyScalar( 0.5 ); 50 | 51 | Object3D.prototype.updateMatrixWorld.call( this, force ); 52 | 53 | }; 54 | 55 | export { Box3Helper }; 56 | -------------------------------------------------------------------------------- /module/geometries/Geometries.js: -------------------------------------------------------------------------------- 1 | export { WireframeGeometry } from './WireframeGeometry.js'; 2 | export { ParametricGeometry, ParametricBufferGeometry } from './ParametricGeometry.js'; 3 | export { TetrahedronGeometry, TetrahedronBufferGeometry } from './TetrahedronGeometry.js'; 4 | export { OctahedronGeometry, OctahedronBufferGeometry } from './OctahedronGeometry.js'; 5 | export { IcosahedronGeometry, IcosahedronBufferGeometry } from './IcosahedronGeometry.js'; 6 | export { DodecahedronGeometry, DodecahedronBufferGeometry } from './DodecahedronGeometry.js'; 7 | export { PolyhedronGeometry, PolyhedronBufferGeometry } from './PolyhedronGeometry.js'; 8 | export { TubeGeometry, TubeBufferGeometry } from './TubeGeometry.js'; 9 | export { TorusKnotGeometry, TorusKnotBufferGeometry } from './TorusKnotGeometry.js'; 10 | export { TorusGeometry, TorusBufferGeometry } from './TorusGeometry.js'; 11 | export { TextGeometry, TextBufferGeometry } from './TextGeometry.js'; 12 | export { SphereGeometry, SphereBufferGeometry } from './SphereGeometry.js'; 13 | export { RingGeometry, RingBufferGeometry } from './RingGeometry.js'; 14 | export { PlaneGeometry, PlaneBufferGeometry } from './PlaneGeometry.js'; 15 | export { LatheGeometry, LatheBufferGeometry } from './LatheGeometry.js'; 16 | export { ShapeGeometry, ShapeBufferGeometry } from './ShapeGeometry.js'; 17 | export { ExtrudeGeometry, ExtrudeBufferGeometry } from './ExtrudeGeometry.js'; 18 | export { EdgesGeometry } from './EdgesGeometry.js'; 19 | export { ConeGeometry, ConeBufferGeometry } from './ConeGeometry.js'; 20 | export { CylinderGeometry, CylinderBufferGeometry } from './CylinderGeometry.js'; 21 | export { CircleGeometry, CircleBufferGeometry } from './CircleGeometry.js'; 22 | export { BoxGeometry, BoxBufferGeometry } from './BoxGeometry.js'; 23 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifndef saturate 3 | #define saturate(a) clamp( a, 0.0, 1.0 ) 4 | #endif 5 | 6 | uniform float toneMappingExposure; 7 | uniform float toneMappingWhitePoint; 8 | 9 | // exposure only 10 | vec3 LinearToneMapping( vec3 color ) { 11 | 12 | return toneMappingExposure * color; 13 | 14 | } 15 | 16 | // source: https://www.cs.utah.edu/~reinhard/cdrom/ 17 | vec3 ReinhardToneMapping( vec3 color ) { 18 | 19 | color *= toneMappingExposure; 20 | return saturate( color / ( vec3( 1.0 ) + color ) ); 21 | 22 | } 23 | 24 | // source: http://filmicgames.com/archives/75 25 | #define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) ) 26 | vec3 Uncharted2ToneMapping( vec3 color ) { 27 | 28 | // John Hable's filmic operator from Uncharted 2 video game 29 | color *= toneMappingExposure; 30 | return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) ); 31 | 32 | } 33 | 34 | // source: http://filmicgames.com/archives/75 35 | vec3 OptimizedCineonToneMapping( vec3 color ) { 36 | 37 | // optimized filmic operator by Jim Hejl and Richard Burgess-Dawson 38 | color *= toneMappingExposure; 39 | color = max( vec3( 0.0 ), color - 0.004 ); 40 | return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); 41 | 42 | } 43 | 44 | // source: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ 45 | vec3 ACESFilmicToneMapping( vec3 color ) { 46 | 47 | color *= toneMappingExposure; 48 | return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) ); 49 | 50 | } 51 | `; 52 | -------------------------------------------------------------------------------- /module/extras/curves/LineCurve3.js: -------------------------------------------------------------------------------- 1 | import { Vector3 } from '../../math/Vector3.js'; 2 | import { Curve } from '../core/Curve.js'; 3 | 4 | 5 | function LineCurve3( v1, v2 ) { 6 | 7 | Curve.call( this ); 8 | 9 | this.type = 'LineCurve3'; 10 | 11 | this.v1 = v1 || new Vector3(); 12 | this.v2 = v2 || new Vector3(); 13 | 14 | } 15 | 16 | LineCurve3.prototype = Object.create( Curve.prototype ); 17 | LineCurve3.prototype.constructor = LineCurve3; 18 | 19 | LineCurve3.prototype.isLineCurve3 = true; 20 | 21 | LineCurve3.prototype.getPoint = function ( t, optionalTarget ) { 22 | 23 | var point = optionalTarget || new Vector3(); 24 | 25 | if ( t === 1 ) { 26 | 27 | point.copy( this.v2 ); 28 | 29 | } else { 30 | 31 | point.copy( this.v2 ).sub( this.v1 ); 32 | point.multiplyScalar( t ).add( this.v1 ); 33 | 34 | } 35 | 36 | return point; 37 | 38 | }; 39 | 40 | // Line curve is linear, so we can overwrite default getPointAt 41 | 42 | LineCurve3.prototype.getPointAt = function ( u, optionalTarget ) { 43 | 44 | return this.getPoint( u, optionalTarget ); 45 | 46 | }; 47 | 48 | LineCurve3.prototype.copy = function ( source ) { 49 | 50 | Curve.prototype.copy.call( this, source ); 51 | 52 | this.v1.copy( source.v1 ); 53 | this.v2.copy( source.v2 ); 54 | 55 | return this; 56 | 57 | }; 58 | 59 | LineCurve3.prototype.toJSON = function () { 60 | 61 | var data = Curve.prototype.toJSON.call( this ); 62 | 63 | data.v1 = this.v1.toArray(); 64 | data.v2 = this.v2.toArray(); 65 | 66 | return data; 67 | 68 | }; 69 | 70 | LineCurve3.prototype.fromJSON = function ( json ) { 71 | 72 | Curve.prototype.fromJSON.call( this, json ); 73 | 74 | this.v1.fromArray( json.v1 ); 75 | this.v2.fromArray( json.v2 ); 76 | 77 | return this; 78 | 79 | }; 80 | 81 | 82 | export { LineCurve3 }; 83 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define MATCAP 3 | 4 | uniform vec3 diffuse; 5 | uniform float opacity; 6 | uniform sampler2D matcap; 7 | 8 | varying vec3 vViewPosition; 9 | 10 | #ifndef FLAT_SHADED 11 | 12 | varying vec3 vNormal; 13 | 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | void main() { 28 | 29 | #include 30 | 31 | vec4 diffuseColor = vec4( diffuse, opacity ); 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | vec3 viewDir = normalize( vViewPosition ); 41 | vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); 42 | vec3 y = cross( viewDir, x ); 43 | vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks 44 | 45 | #ifdef USE_MATCAP 46 | 47 | vec4 matcapColor = texture2D( matcap, uv ); 48 | matcapColor = matcapTexelToLinear( matcapColor ); 49 | 50 | #else 51 | 52 | vec4 matcapColor = vec4( 1.0 ); 53 | 54 | #endif 55 | 56 | vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; 57 | 58 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 59 | 60 | #include 61 | #include 62 | #include 63 | #include 64 | 65 | } 66 | `; 67 | -------------------------------------------------------------------------------- /module/loaders/LoadingManager.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | function LoadingManager( onLoad, onProgress, onError ) { 6 | 7 | var scope = this; 8 | 9 | var isLoading = false; 10 | var itemsLoaded = 0; 11 | var itemsTotal = 0; 12 | var urlModifier = undefined; 13 | 14 | // Refer to #5689 for the reason why we don't set .onStart 15 | // in the constructor 16 | 17 | this.onStart = undefined; 18 | this.onLoad = onLoad; 19 | this.onProgress = onProgress; 20 | this.onError = onError; 21 | 22 | this.itemStart = function ( url ) { 23 | 24 | itemsTotal ++; 25 | 26 | if ( isLoading === false ) { 27 | 28 | if ( scope.onStart !== undefined ) { 29 | 30 | scope.onStart( url, itemsLoaded, itemsTotal ); 31 | 32 | } 33 | 34 | } 35 | 36 | isLoading = true; 37 | 38 | }; 39 | 40 | this.itemEnd = function ( url ) { 41 | 42 | itemsLoaded ++; 43 | 44 | if ( scope.onProgress !== undefined ) { 45 | 46 | scope.onProgress( url, itemsLoaded, itemsTotal ); 47 | 48 | } 49 | 50 | if ( itemsLoaded === itemsTotal ) { 51 | 52 | isLoading = false; 53 | 54 | if ( scope.onLoad !== undefined ) { 55 | 56 | scope.onLoad(); 57 | 58 | } 59 | 60 | } 61 | 62 | }; 63 | 64 | this.itemError = function ( url ) { 65 | 66 | if ( scope.onError !== undefined ) { 67 | 68 | scope.onError( url ); 69 | 70 | } 71 | 72 | }; 73 | 74 | this.resolveURL = function ( url ) { 75 | 76 | if ( urlModifier ) { 77 | 78 | return urlModifier( url ); 79 | 80 | } 81 | 82 | return url; 83 | 84 | }; 85 | 86 | this.setURLModifier = function ( transform ) { 87 | 88 | urlModifier = transform; 89 | return this; 90 | 91 | }; 92 | 93 | } 94 | 95 | var DefaultLoadingManager = new LoadingManager(); 96 | 97 | 98 | export { DefaultLoadingManager, LoadingManager }; 99 | -------------------------------------------------------------------------------- /module/helpers/GridHelper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | */ 4 | 5 | import { LineSegments } from '../objects/LineSegments.js'; 6 | import { VertexColors } from '../constants.js'; 7 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 8 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 9 | import { BufferGeometry } from '../core/BufferGeometry.js'; 10 | import { Color } from '../math/Color.js'; 11 | 12 | function GridHelper( size, divisions, color1, color2 ) { 13 | 14 | size = size || 10; 15 | divisions = divisions || 10; 16 | color1 = new Color( color1 !== undefined ? color1 : 0x444444 ); 17 | color2 = new Color( color2 !== undefined ? color2 : 0x888888 ); 18 | 19 | var center = divisions / 2; 20 | var step = size / divisions; 21 | var halfSize = size / 2; 22 | 23 | var vertices = [], colors = []; 24 | 25 | for ( var i = 0, j = 0, k = - halfSize; i <= divisions; i ++, k += step ) { 26 | 27 | vertices.push( - halfSize, 0, k, halfSize, 0, k ); 28 | vertices.push( k, 0, - halfSize, k, 0, halfSize ); 29 | 30 | var color = i === center ? color1 : color2; 31 | 32 | color.toArray( colors, j ); j += 3; 33 | color.toArray( colors, j ); j += 3; 34 | color.toArray( colors, j ); j += 3; 35 | color.toArray( colors, j ); j += 3; 36 | 37 | } 38 | 39 | var geometry = new BufferGeometry(); 40 | geometry.addAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) ); 41 | geometry.addAttribute( 'color', new Float32BufferAttribute( colors, 3 ) ); 42 | 43 | var material = new LineBasicMaterial( { vertexColors: VertexColors } ); 44 | 45 | LineSegments.call( this, geometry, material ); 46 | 47 | } 48 | 49 | GridHelper.prototype = Object.create( LineSegments.prototype ); 50 | GridHelper.prototype.constructor = GridHelper; 51 | 52 | export { GridHelper }; 53 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | uniform vec3 diffuse; 3 | uniform float opacity; 4 | 5 | #ifndef FLAT_SHADED 6 | 7 | varying vec3 vNormal; 8 | 9 | #endif 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | void main() { 26 | 27 | #include 28 | 29 | vec4 diffuseColor = vec4( diffuse, opacity ); 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 39 | 40 | // accumulation (baked indirect lighting only) 41 | #ifdef USE_LIGHTMAP 42 | 43 | reflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity; 44 | 45 | #else 46 | 47 | reflectedLight.indirectDiffuse += vec3( 1.0 ); 48 | 49 | #endif 50 | 51 | // modulation 52 | #include 53 | 54 | reflectedLight.indirectDiffuse *= diffuseColor.rgb; 55 | 56 | vec3 outgoingLight = reflectedLight.indirectDiffuse; 57 | 58 | #include 59 | 60 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 61 | 62 | #include 63 | #include 64 | #include 65 | #include 66 | 67 | } 68 | `; 69 | -------------------------------------------------------------------------------- /module/cameras/Camera.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author mrdoob / http://mrdoob.com/ 3 | * @author mikael emtinger / http://gomo.se/ 4 | * @author WestLangley / http://github.com/WestLangley 5 | */ 6 | 7 | import { Matrix4 } from '../math/Matrix4.js'; 8 | import { Object3D } from '../core/Object3D.js'; 9 | import { Vector3 } from '../math/Vector3.js'; 10 | 11 | function Camera() { 12 | 13 | Object3D.call( this ); 14 | 15 | this.type = 'Camera'; 16 | 17 | this.matrixWorldInverse = new Matrix4(); 18 | 19 | this.projectionMatrix = new Matrix4(); 20 | this.projectionMatrixInverse = new Matrix4(); 21 | 22 | } 23 | 24 | Camera.prototype = Object.assign( Object.create( Object3D.prototype ), { 25 | 26 | constructor: Camera, 27 | 28 | isCamera: true, 29 | 30 | copy: function ( source, recursive ) { 31 | 32 | Object3D.prototype.copy.call( this, source, recursive ); 33 | 34 | this.matrixWorldInverse.copy( source.matrixWorldInverse ); 35 | 36 | this.projectionMatrix.copy( source.projectionMatrix ); 37 | this.projectionMatrixInverse.copy( source.projectionMatrixInverse ); 38 | 39 | return this; 40 | 41 | }, 42 | 43 | getWorldDirection: function ( target ) { 44 | 45 | if ( target === undefined ) { 46 | 47 | console.warn( 'THREE.Camera: .getWorldDirection() target is now required' ); 48 | target = new Vector3(); 49 | 50 | } 51 | 52 | this.updateMatrixWorld( true ); 53 | 54 | var e = this.matrixWorld.elements; 55 | 56 | return target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize(); 57 | 58 | }, 59 | 60 | updateMatrixWorld: function ( force ) { 61 | 62 | Object3D.prototype.updateMatrixWorld.call( this, force ); 63 | 64 | this.matrixWorldInverse.getInverse( this.matrixWorld ); 65 | 66 | }, 67 | 68 | clone: function () { 69 | 70 | return new this.constructor().copy( this ); 71 | 72 | } 73 | 74 | } ); 75 | 76 | export { Camera }; 77 | -------------------------------------------------------------------------------- /module/core/EventDispatcher.js: -------------------------------------------------------------------------------- 1 | /** 2 | * https://github.com/mrdoob/eventdispatcher.js/ 3 | */ 4 | 5 | function EventDispatcher() {} 6 | 7 | Object.assign( EventDispatcher.prototype, { 8 | 9 | addEventListener: function ( type, listener ) { 10 | 11 | if ( this._listeners === undefined ) this._listeners = {}; 12 | 13 | var listeners = this._listeners; 14 | 15 | if ( listeners[ type ] === undefined ) { 16 | 17 | listeners[ type ] = []; 18 | 19 | } 20 | 21 | if ( listeners[ type ].indexOf( listener ) === - 1 ) { 22 | 23 | listeners[ type ].push( listener ); 24 | 25 | } 26 | 27 | }, 28 | 29 | hasEventListener: function ( type, listener ) { 30 | 31 | if ( this._listeners === undefined ) return false; 32 | 33 | var listeners = this._listeners; 34 | 35 | return listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1; 36 | 37 | }, 38 | 39 | removeEventListener: function ( type, listener ) { 40 | 41 | if ( this._listeners === undefined ) return; 42 | 43 | var listeners = this._listeners; 44 | var listenerArray = listeners[ type ]; 45 | 46 | if ( listenerArray !== undefined ) { 47 | 48 | var index = listenerArray.indexOf( listener ); 49 | 50 | if ( index !== - 1 ) { 51 | 52 | listenerArray.splice( index, 1 ); 53 | 54 | } 55 | 56 | } 57 | 58 | }, 59 | 60 | dispatchEvent: function ( event ) { 61 | 62 | if ( this._listeners === undefined ) return; 63 | 64 | var listeners = this._listeners; 65 | var listenerArray = listeners[ event.type ]; 66 | 67 | if ( listenerArray !== undefined ) { 68 | 69 | event.target = this; 70 | 71 | var array = listenerArray.slice( 0 ); 72 | 73 | for ( var i = 0, l = array.length; i < l; i ++ ) { 74 | 75 | array[ i ].call( this, event ); 76 | 77 | } 78 | 79 | } 80 | 81 | } 82 | 83 | } ); 84 | 85 | 86 | export { EventDispatcher }; 87 | -------------------------------------------------------------------------------- /module/extras/curves/QuadraticBezierCurve.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { QuadraticBezier } from '../core/Interpolations.js'; 3 | import { Vector2 } from '../../math/Vector2.js'; 4 | 5 | 6 | function QuadraticBezierCurve( v0, v1, v2 ) { 7 | 8 | Curve.call( this ); 9 | 10 | this.type = 'QuadraticBezierCurve'; 11 | 12 | this.v0 = v0 || new Vector2(); 13 | this.v1 = v1 || new Vector2(); 14 | this.v2 = v2 || new Vector2(); 15 | 16 | } 17 | 18 | QuadraticBezierCurve.prototype = Object.create( Curve.prototype ); 19 | QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve; 20 | 21 | QuadraticBezierCurve.prototype.isQuadraticBezierCurve = true; 22 | 23 | QuadraticBezierCurve.prototype.getPoint = function ( t, optionalTarget ) { 24 | 25 | var point = optionalTarget || new Vector2(); 26 | 27 | var v0 = this.v0, v1 = this.v1, v2 = this.v2; 28 | 29 | point.set( 30 | QuadraticBezier( t, v0.x, v1.x, v2.x ), 31 | QuadraticBezier( t, v0.y, v1.y, v2.y ) 32 | ); 33 | 34 | return point; 35 | 36 | }; 37 | 38 | QuadraticBezierCurve.prototype.copy = function ( source ) { 39 | 40 | Curve.prototype.copy.call( this, source ); 41 | 42 | this.v0.copy( source.v0 ); 43 | this.v1.copy( source.v1 ); 44 | this.v2.copy( source.v2 ); 45 | 46 | return this; 47 | 48 | }; 49 | 50 | QuadraticBezierCurve.prototype.toJSON = function () { 51 | 52 | var data = Curve.prototype.toJSON.call( this ); 53 | 54 | data.v0 = this.v0.toArray(); 55 | data.v1 = this.v1.toArray(); 56 | data.v2 = this.v2.toArray(); 57 | 58 | return data; 59 | 60 | }; 61 | 62 | QuadraticBezierCurve.prototype.fromJSON = function ( json ) { 63 | 64 | Curve.prototype.fromJSON.call( this, json ); 65 | 66 | this.v0.fromArray( json.v0 ); 67 | this.v1.fromArray( json.v1 ); 68 | this.v2.fromArray( json.v2 ); 69 | 70 | return this; 71 | 72 | }; 73 | 74 | 75 | export { QuadraticBezierCurve }; 76 | -------------------------------------------------------------------------------- /module/geometries/IcosahedronGeometry.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author timothypratley / https://github.com/timothypratley 3 | * @author Mugen87 / https://github.com/Mugen87 4 | */ 5 | 6 | import { Geometry } from '../core/Geometry.js'; 7 | import { PolyhedronBufferGeometry } from './PolyhedronGeometry.js'; 8 | 9 | // IcosahedronGeometry 10 | 11 | function IcosahedronGeometry( radius, detail ) { 12 | 13 | Geometry.call( this ); 14 | 15 | this.type = 'IcosahedronGeometry'; 16 | 17 | this.parameters = { 18 | radius: radius, 19 | detail: detail 20 | }; 21 | 22 | this.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) ); 23 | this.mergeVertices(); 24 | 25 | } 26 | 27 | IcosahedronGeometry.prototype = Object.create( Geometry.prototype ); 28 | IcosahedronGeometry.prototype.constructor = IcosahedronGeometry; 29 | 30 | // IcosahedronBufferGeometry 31 | 32 | function IcosahedronBufferGeometry( radius, detail ) { 33 | 34 | var t = ( 1 + Math.sqrt( 5 ) ) / 2; 35 | 36 | var vertices = [ 37 | - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0, 38 | 0, - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 39 | t, 0, - 1, t, 0, 1, - t, 0, - 1, - t, 0, 1 40 | ]; 41 | 42 | var indices = [ 43 | 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 0, 10, 11, 44 | 1, 5, 9, 5, 11, 4, 11, 10, 2, 10, 7, 6, 7, 1, 8, 45 | 3, 9, 4, 3, 4, 2, 3, 2, 6, 3, 6, 8, 3, 8, 9, 46 | 4, 9, 5, 2, 4, 11, 6, 2, 10, 8, 6, 7, 9, 8, 1 47 | ]; 48 | 49 | PolyhedronBufferGeometry.call( this, vertices, indices, radius, detail ); 50 | 51 | this.type = 'IcosahedronBufferGeometry'; 52 | 53 | this.parameters = { 54 | radius: radius, 55 | detail: detail 56 | }; 57 | 58 | } 59 | 60 | IcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype ); 61 | IcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry; 62 | 63 | 64 | export { IcosahedronGeometry, IcosahedronBufferGeometry }; 65 | -------------------------------------------------------------------------------- /module/extras/curves/QuadraticBezierCurve3.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { QuadraticBezier } from '../core/Interpolations.js'; 3 | import { Vector3 } from '../../math/Vector3.js'; 4 | 5 | 6 | function QuadraticBezierCurve3( v0, v1, v2 ) { 7 | 8 | Curve.call( this ); 9 | 10 | this.type = 'QuadraticBezierCurve3'; 11 | 12 | this.v0 = v0 || new Vector3(); 13 | this.v1 = v1 || new Vector3(); 14 | this.v2 = v2 || new Vector3(); 15 | 16 | } 17 | 18 | QuadraticBezierCurve3.prototype = Object.create( Curve.prototype ); 19 | QuadraticBezierCurve3.prototype.constructor = QuadraticBezierCurve3; 20 | 21 | QuadraticBezierCurve3.prototype.isQuadraticBezierCurve3 = true; 22 | 23 | QuadraticBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) { 24 | 25 | var point = optionalTarget || new Vector3(); 26 | 27 | var v0 = this.v0, v1 = this.v1, v2 = this.v2; 28 | 29 | point.set( 30 | QuadraticBezier( t, v0.x, v1.x, v2.x ), 31 | QuadraticBezier( t, v0.y, v1.y, v2.y ), 32 | QuadraticBezier( t, v0.z, v1.z, v2.z ) 33 | ); 34 | 35 | return point; 36 | 37 | }; 38 | 39 | QuadraticBezierCurve3.prototype.copy = function ( source ) { 40 | 41 | Curve.prototype.copy.call( this, source ); 42 | 43 | this.v0.copy( source.v0 ); 44 | this.v1.copy( source.v1 ); 45 | this.v2.copy( source.v2 ); 46 | 47 | return this; 48 | 49 | }; 50 | 51 | QuadraticBezierCurve3.prototype.toJSON = function () { 52 | 53 | var data = Curve.prototype.toJSON.call( this ); 54 | 55 | data.v0 = this.v0.toArray(); 56 | data.v1 = this.v1.toArray(); 57 | data.v2 = this.v2.toArray(); 58 | 59 | return data; 60 | 61 | }; 62 | 63 | QuadraticBezierCurve3.prototype.fromJSON = function ( json ) { 64 | 65 | Curve.prototype.fromJSON.call( this, json ); 66 | 67 | this.v0.fromArray( json.v0 ); 68 | this.v1.fromArray( json.v1 ); 69 | this.v2.fromArray( json.v2 ); 70 | 71 | return this; 72 | 73 | }; 74 | 75 | 76 | export { QuadraticBezierCurve3 }; 77 | -------------------------------------------------------------------------------- /module/extras/curves/LineCurve.js: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../../math/Vector2.js'; 2 | import { Curve } from '../core/Curve.js'; 3 | 4 | 5 | function LineCurve( v1, v2 ) { 6 | 7 | Curve.call( this ); 8 | 9 | this.type = 'LineCurve'; 10 | 11 | this.v1 = v1 || new Vector2(); 12 | this.v2 = v2 || new Vector2(); 13 | 14 | } 15 | 16 | LineCurve.prototype = Object.create( Curve.prototype ); 17 | LineCurve.prototype.constructor = LineCurve; 18 | 19 | LineCurve.prototype.isLineCurve = true; 20 | 21 | LineCurve.prototype.getPoint = function ( t, optionalTarget ) { 22 | 23 | var point = optionalTarget || new Vector2(); 24 | 25 | if ( t === 1 ) { 26 | 27 | point.copy( this.v2 ); 28 | 29 | } else { 30 | 31 | point.copy( this.v2 ).sub( this.v1 ); 32 | point.multiplyScalar( t ).add( this.v1 ); 33 | 34 | } 35 | 36 | return point; 37 | 38 | }; 39 | 40 | // Line curve is linear, so we can overwrite default getPointAt 41 | 42 | LineCurve.prototype.getPointAt = function ( u, optionalTarget ) { 43 | 44 | return this.getPoint( u, optionalTarget ); 45 | 46 | }; 47 | 48 | LineCurve.prototype.getTangent = function ( /* t */ ) { 49 | 50 | var tangent = this.v2.clone().sub( this.v1 ); 51 | 52 | return tangent.normalize(); 53 | 54 | }; 55 | 56 | LineCurve.prototype.copy = function ( source ) { 57 | 58 | Curve.prototype.copy.call( this, source ); 59 | 60 | this.v1.copy( source.v1 ); 61 | this.v2.copy( source.v2 ); 62 | 63 | return this; 64 | 65 | }; 66 | 67 | LineCurve.prototype.toJSON = function () { 68 | 69 | var data = Curve.prototype.toJSON.call( this ); 70 | 71 | data.v1 = this.v1.toArray(); 72 | data.v2 = this.v2.toArray(); 73 | 74 | return data; 75 | 76 | }; 77 | 78 | LineCurve.prototype.fromJSON = function ( json ) { 79 | 80 | Curve.prototype.fromJSON.call( this, json ); 81 | 82 | this.v1.fromArray( json.v1 ); 83 | this.v2.fromArray( json.v2 ); 84 | 85 | return this; 86 | 87 | }; 88 | 89 | 90 | export { LineCurve }; 91 | -------------------------------------------------------------------------------- /module/extras/curves/CubicBezierCurve.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { CubicBezier } from '../core/Interpolations.js'; 3 | import { Vector2 } from '../../math/Vector2.js'; 4 | 5 | 6 | function CubicBezierCurve( v0, v1, v2, v3 ) { 7 | 8 | Curve.call( this ); 9 | 10 | this.type = 'CubicBezierCurve'; 11 | 12 | this.v0 = v0 || new Vector2(); 13 | this.v1 = v1 || new Vector2(); 14 | this.v2 = v2 || new Vector2(); 15 | this.v3 = v3 || new Vector2(); 16 | 17 | } 18 | 19 | CubicBezierCurve.prototype = Object.create( Curve.prototype ); 20 | CubicBezierCurve.prototype.constructor = CubicBezierCurve; 21 | 22 | CubicBezierCurve.prototype.isCubicBezierCurve = true; 23 | 24 | CubicBezierCurve.prototype.getPoint = function ( t, optionalTarget ) { 25 | 26 | var point = optionalTarget || new Vector2(); 27 | 28 | var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; 29 | 30 | point.set( 31 | CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), 32 | CubicBezier( t, v0.y, v1.y, v2.y, v3.y ) 33 | ); 34 | 35 | return point; 36 | 37 | }; 38 | 39 | CubicBezierCurve.prototype.copy = function ( source ) { 40 | 41 | Curve.prototype.copy.call( this, source ); 42 | 43 | this.v0.copy( source.v0 ); 44 | this.v1.copy( source.v1 ); 45 | this.v2.copy( source.v2 ); 46 | this.v3.copy( source.v3 ); 47 | 48 | return this; 49 | 50 | }; 51 | 52 | CubicBezierCurve.prototype.toJSON = function () { 53 | 54 | var data = Curve.prototype.toJSON.call( this ); 55 | 56 | data.v0 = this.v0.toArray(); 57 | data.v1 = this.v1.toArray(); 58 | data.v2 = this.v2.toArray(); 59 | data.v3 = this.v3.toArray(); 60 | 61 | return data; 62 | 63 | }; 64 | 65 | CubicBezierCurve.prototype.fromJSON = function ( json ) { 66 | 67 | Curve.prototype.fromJSON.call( this, json ); 68 | 69 | this.v0.fromArray( json.v0 ); 70 | this.v1.fromArray( json.v1 ); 71 | this.v2.fromArray( json.v2 ); 72 | this.v3.fromArray( json.v3 ); 73 | 74 | return this; 75 | 76 | }; 77 | 78 | 79 | export { CubicBezierCurve }; 80 | -------------------------------------------------------------------------------- /module/math/Spherical.js: -------------------------------------------------------------------------------- 1 | import { _Math } from './Math.js'; 2 | 3 | /** 4 | * @author bhouston / http://clara.io 5 | * @author WestLangley / http://github.com/WestLangley 6 | * 7 | * Ref: https://en.wikipedia.org/wiki/Spherical_coordinate_system 8 | * 9 | * The polar angle (phi) is measured from the positive y-axis. The positive y-axis is up. 10 | * The azimuthal angle (theta) is measured from the positive z-axiz. 11 | */ 12 | 13 | function Spherical( radius, phi, theta ) { 14 | 15 | this.radius = ( radius !== undefined ) ? radius : 1.0; 16 | this.phi = ( phi !== undefined ) ? phi : 0; // polar angle 17 | this.theta = ( theta !== undefined ) ? theta : 0; // azimuthal angle 18 | 19 | return this; 20 | 21 | } 22 | 23 | Object.assign( Spherical.prototype, { 24 | 25 | set: function ( radius, phi, theta ) { 26 | 27 | this.radius = radius; 28 | this.phi = phi; 29 | this.theta = theta; 30 | 31 | return this; 32 | 33 | }, 34 | 35 | clone: function () { 36 | 37 | return new this.constructor().copy( this ); 38 | 39 | }, 40 | 41 | copy: function ( other ) { 42 | 43 | this.radius = other.radius; 44 | this.phi = other.phi; 45 | this.theta = other.theta; 46 | 47 | return this; 48 | 49 | }, 50 | 51 | // restrict phi to be betwee EPS and PI-EPS 52 | makeSafe: function () { 53 | 54 | var EPS = 0.000001; 55 | this.phi = Math.max( EPS, Math.min( Math.PI - EPS, this.phi ) ); 56 | 57 | return this; 58 | 59 | }, 60 | 61 | setFromVector3: function ( v ) { 62 | 63 | return this.setFromCartesianCoords( v.x, v.y, v.z ); 64 | 65 | }, 66 | 67 | setFromCartesianCoords: function ( x, y, z ) { 68 | 69 | this.radius = Math.sqrt( x * x + y * y + z * z ); 70 | 71 | if ( this.radius === 0 ) { 72 | 73 | this.theta = 0; 74 | this.phi = 0; 75 | 76 | } else { 77 | 78 | this.theta = Math.atan2( x, z ); 79 | this.phi = Math.acos( _Math.clamp( y / this.radius, - 1, 1 ) ); 80 | 81 | } 82 | 83 | return this; 84 | 85 | } 86 | 87 | } ); 88 | 89 | 90 | export { Spherical }; 91 | -------------------------------------------------------------------------------- /module/extras/ShapeUtils.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author zz85 / http://www.lab4games.net/zz85/blog 3 | */ 4 | 5 | import { Earcut } from './Earcut.js'; 6 | 7 | var ShapeUtils = { 8 | 9 | // calculate area of the contour polygon 10 | 11 | area: function ( contour ) { 12 | 13 | var n = contour.length; 14 | var a = 0.0; 15 | 16 | for ( var p = n - 1, q = 0; q < n; p = q ++ ) { 17 | 18 | a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; 19 | 20 | } 21 | 22 | return a * 0.5; 23 | 24 | }, 25 | 26 | isClockWise: function ( pts ) { 27 | 28 | return ShapeUtils.area( pts ) < 0; 29 | 30 | }, 31 | 32 | triangulateShape: function ( contour, holes ) { 33 | 34 | var vertices = []; // flat array of vertices like [ x0,y0, x1,y1, x2,y2, ... ] 35 | var holeIndices = []; // array of hole indices 36 | var faces = []; // final array of vertex indices like [ [ a,b,d ], [ b,c,d ] ] 37 | 38 | removeDupEndPts( contour ); 39 | addContour( vertices, contour ); 40 | 41 | // 42 | 43 | var holeIndex = contour.length; 44 | 45 | holes.forEach( removeDupEndPts ); 46 | 47 | for ( var i = 0; i < holes.length; i ++ ) { 48 | 49 | holeIndices.push( holeIndex ); 50 | holeIndex += holes[ i ].length; 51 | addContour( vertices, holes[ i ] ); 52 | 53 | } 54 | 55 | // 56 | 57 | var triangles = Earcut.triangulate( vertices, holeIndices ); 58 | 59 | // 60 | 61 | for ( var i = 0; i < triangles.length; i += 3 ) { 62 | 63 | faces.push( triangles.slice( i, i + 3 ) ); 64 | 65 | } 66 | 67 | return faces; 68 | 69 | } 70 | 71 | }; 72 | 73 | function removeDupEndPts( points ) { 74 | 75 | var l = points.length; 76 | 77 | if ( l > 2 && points[ l - 1 ].equals( points[ 0 ] ) ) { 78 | 79 | points.pop(); 80 | 81 | } 82 | 83 | } 84 | 85 | function addContour( vertices, contour ) { 86 | 87 | for ( var i = 0; i < contour.length; i ++ ) { 88 | 89 | vertices.push( contour[ i ].x ); 90 | vertices.push( contour[ i ].y ); 91 | 92 | } 93 | 94 | } 95 | 96 | export { ShapeUtils }; 97 | -------------------------------------------------------------------------------- /module/lights/SpotLight.js: -------------------------------------------------------------------------------- 1 | import { Light } from './Light.js'; 2 | import { SpotLightShadow } from './SpotLightShadow.js'; 3 | import { Object3D } from '../core/Object3D.js'; 4 | 5 | /** 6 | * @author alteredq / http://alteredqualia.com/ 7 | */ 8 | 9 | function SpotLight( color, intensity, distance, angle, penumbra, decay ) { 10 | 11 | Light.call( this, color, intensity ); 12 | 13 | this.type = 'SpotLight'; 14 | 15 | this.position.copy( Object3D.DefaultUp ); 16 | this.updateMatrix(); 17 | 18 | this.target = new Object3D(); 19 | 20 | Object.defineProperty( this, 'power', { 21 | get: function () { 22 | 23 | // intensity = power per solid angle. 24 | // ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 25 | return this.intensity * Math.PI; 26 | 27 | }, 28 | set: function ( power ) { 29 | 30 | // intensity = power per solid angle. 31 | // ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf 32 | this.intensity = power / Math.PI; 33 | 34 | } 35 | } ); 36 | 37 | this.distance = ( distance !== undefined ) ? distance : 0; 38 | this.angle = ( angle !== undefined ) ? angle : Math.PI / 3; 39 | this.penumbra = ( penumbra !== undefined ) ? penumbra : 0; 40 | this.decay = ( decay !== undefined ) ? decay : 1; // for physically correct lights, should be 2. 41 | 42 | this.shadow = new SpotLightShadow(); 43 | 44 | } 45 | 46 | SpotLight.prototype = Object.assign( Object.create( Light.prototype ), { 47 | 48 | constructor: SpotLight, 49 | 50 | isSpotLight: true, 51 | 52 | copy: function ( source ) { 53 | 54 | Light.prototype.copy.call( this, source ); 55 | 56 | this.distance = source.distance; 57 | this.angle = source.angle; 58 | this.penumbra = source.penumbra; 59 | this.decay = source.decay; 60 | 61 | this.target = source.target.clone(); 62 | 63 | this.shadow = source.shadow.clone(); 64 | 65 | return this; 66 | 67 | } 68 | 69 | } ); 70 | 71 | 72 | export { SpotLight }; 73 | -------------------------------------------------------------------------------- /module/extras/curves/CubicBezierCurve3.js: -------------------------------------------------------------------------------- 1 | import { Curve } from '../core/Curve.js'; 2 | import { CubicBezier } from '../core/Interpolations.js'; 3 | import { Vector3 } from '../../math/Vector3.js'; 4 | 5 | 6 | function CubicBezierCurve3( v0, v1, v2, v3 ) { 7 | 8 | Curve.call( this ); 9 | 10 | this.type = 'CubicBezierCurve3'; 11 | 12 | this.v0 = v0 || new Vector3(); 13 | this.v1 = v1 || new Vector3(); 14 | this.v2 = v2 || new Vector3(); 15 | this.v3 = v3 || new Vector3(); 16 | 17 | } 18 | 19 | CubicBezierCurve3.prototype = Object.create( Curve.prototype ); 20 | CubicBezierCurve3.prototype.constructor = CubicBezierCurve3; 21 | 22 | CubicBezierCurve3.prototype.isCubicBezierCurve3 = true; 23 | 24 | CubicBezierCurve3.prototype.getPoint = function ( t, optionalTarget ) { 25 | 26 | var point = optionalTarget || new Vector3(); 27 | 28 | var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3; 29 | 30 | point.set( 31 | CubicBezier( t, v0.x, v1.x, v2.x, v3.x ), 32 | CubicBezier( t, v0.y, v1.y, v2.y, v3.y ), 33 | CubicBezier( t, v0.z, v1.z, v2.z, v3.z ) 34 | ); 35 | 36 | return point; 37 | 38 | }; 39 | 40 | CubicBezierCurve3.prototype.copy = function ( source ) { 41 | 42 | Curve.prototype.copy.call( this, source ); 43 | 44 | this.v0.copy( source.v0 ); 45 | this.v1.copy( source.v1 ); 46 | this.v2.copy( source.v2 ); 47 | this.v3.copy( source.v3 ); 48 | 49 | return this; 50 | 51 | }; 52 | 53 | CubicBezierCurve3.prototype.toJSON = function () { 54 | 55 | var data = Curve.prototype.toJSON.call( this ); 56 | 57 | data.v0 = this.v0.toArray(); 58 | data.v1 = this.v1.toArray(); 59 | data.v2 = this.v2.toArray(); 60 | data.v3 = this.v3.toArray(); 61 | 62 | return data; 63 | 64 | }; 65 | 66 | CubicBezierCurve3.prototype.fromJSON = function ( json ) { 67 | 68 | Curve.prototype.fromJSON.call( this, json ); 69 | 70 | this.v0.fromArray( json.v0 ); 71 | this.v1.fromArray( json.v1 ); 72 | this.v2.fromArray( json.v2 ); 73 | this.v3.fromArray( json.v3 ); 74 | 75 | return this; 76 | 77 | }; 78 | 79 | 80 | export { CubicBezierCurve3 }; 81 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #ifdef USE_ENVMAP 3 | 4 | #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) 5 | 6 | vec3 cameraToVertex = normalize( vWorldPosition - cameraPosition ); 7 | 8 | // Transforming Normal Vectors with the Inverse Transformation 9 | vec3 worldNormal = inverseTransformDirection( normal, viewMatrix ); 10 | 11 | #ifdef ENVMAP_MODE_REFLECTION 12 | 13 | vec3 reflectVec = reflect( cameraToVertex, worldNormal ); 14 | 15 | #else 16 | 17 | vec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio ); 18 | 19 | #endif 20 | 21 | #else 22 | 23 | vec3 reflectVec = vReflect; 24 | 25 | #endif 26 | 27 | #ifdef ENVMAP_TYPE_CUBE 28 | 29 | vec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) ); 30 | 31 | #elif defined( ENVMAP_TYPE_EQUIREC ) 32 | 33 | vec2 sampleUV; 34 | 35 | reflectVec = normalize( reflectVec ); 36 | 37 | sampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; 38 | 39 | sampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5; 40 | 41 | vec4 envColor = texture2D( envMap, sampleUV ); 42 | 43 | #elif defined( ENVMAP_TYPE_SPHERE ) 44 | 45 | reflectVec = normalize( reflectVec ); 46 | 47 | vec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ); 48 | 49 | vec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 ); 50 | 51 | #else 52 | 53 | vec4 envColor = vec4( 0.0 ); 54 | 55 | #endif 56 | 57 | envColor = envMapTexelToLinear( envColor ); 58 | 59 | #ifdef ENVMAP_BLENDING_MULTIPLY 60 | 61 | outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); 62 | 63 | #elif defined( ENVMAP_BLENDING_MIX ) 64 | 65 | outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); 66 | 67 | #elif defined( ENVMAP_BLENDING_ADD ) 68 | 69 | outgoingLight += envColor.xyz * specularStrength * reflectivity; 70 | 71 | #endif 72 | 73 | #endif 74 | `; 75 | -------------------------------------------------------------------------------- /module/materials/MeshDistanceMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { Vector3 } from '../math/Vector3.js'; 3 | 4 | /** 5 | * @author WestLangley / http://github.com/WestLangley 6 | * 7 | * parameters = { 8 | * 9 | * referencePosition: , 10 | * nearDistance: , 11 | * farDistance: , 12 | * 13 | * skinning: , 14 | * morphTargets: , 15 | * 16 | * map: new THREE.Texture( ), 17 | * 18 | * alphaMap: new THREE.Texture( ), 19 | * 20 | * displacementMap: new THREE.Texture( ), 21 | * displacementScale: , 22 | * displacementBias: 23 | * 24 | * } 25 | */ 26 | 27 | function MeshDistanceMaterial( parameters ) { 28 | 29 | Material.call( this ); 30 | 31 | this.type = 'MeshDistanceMaterial'; 32 | 33 | this.referencePosition = new Vector3(); 34 | this.nearDistance = 1; 35 | this.farDistance = 1000; 36 | 37 | this.skinning = false; 38 | this.morphTargets = false; 39 | 40 | this.map = null; 41 | 42 | this.alphaMap = null; 43 | 44 | this.displacementMap = null; 45 | this.displacementScale = 1; 46 | this.displacementBias = 0; 47 | 48 | this.fog = false; 49 | this.lights = false; 50 | 51 | this.setValues( parameters ); 52 | 53 | } 54 | 55 | MeshDistanceMaterial.prototype = Object.create( Material.prototype ); 56 | MeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial; 57 | 58 | MeshDistanceMaterial.prototype.isMeshDistanceMaterial = true; 59 | 60 | MeshDistanceMaterial.prototype.copy = function ( source ) { 61 | 62 | Material.prototype.copy.call( this, source ); 63 | 64 | this.referencePosition.copy( source.referencePosition ); 65 | this.nearDistance = source.nearDistance; 66 | this.farDistance = source.farDistance; 67 | 68 | this.skinning = source.skinning; 69 | this.morphTargets = source.morphTargets; 70 | 71 | this.map = source.map; 72 | 73 | this.alphaMap = source.alphaMap; 74 | 75 | this.displacementMap = source.displacementMap; 76 | this.displacementScale = source.displacementScale; 77 | this.displacementBias = source.displacementBias; 78 | 79 | return this; 80 | 81 | }; 82 | 83 | 84 | export { MeshDistanceMaterial }; 85 | -------------------------------------------------------------------------------- /module/polyfills.js: -------------------------------------------------------------------------------- 1 | // Polyfills 2 | 3 | if ( Number.EPSILON === undefined ) { 4 | 5 | Number.EPSILON = Math.pow( 2, - 52 ); 6 | 7 | } 8 | 9 | if ( Number.isInteger === undefined ) { 10 | 11 | // Missing in IE 12 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger 13 | 14 | Number.isInteger = function ( value ) { 15 | 16 | return typeof value === 'number' && isFinite( value ) && Math.floor( value ) === value; 17 | 18 | }; 19 | 20 | } 21 | 22 | // 23 | 24 | if ( Math.sign === undefined ) { 25 | 26 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign 27 | 28 | Math.sign = function ( x ) { 29 | 30 | return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x; 31 | 32 | }; 33 | 34 | } 35 | 36 | if ( 'name' in Function.prototype === false ) { 37 | 38 | // Missing in IE 39 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name 40 | 41 | Object.defineProperty( Function.prototype, 'name', { 42 | 43 | get: function () { 44 | 45 | return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ]; 46 | 47 | } 48 | 49 | } ); 50 | 51 | } 52 | 53 | if ( Object.assign === undefined ) { 54 | 55 | // Missing in IE 56 | // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign 57 | 58 | ( function () { 59 | 60 | Object.assign = function ( target ) { 61 | 62 | 'use strict'; 63 | 64 | if ( target === undefined || target === null ) { 65 | 66 | throw new TypeError( 'Cannot convert undefined or null to object' ); 67 | 68 | } 69 | 70 | var output = Object( target ); 71 | 72 | for ( var index = 1; index < arguments.length; index ++ ) { 73 | 74 | var source = arguments[ index ]; 75 | 76 | if ( source !== undefined && source !== null ) { 77 | 78 | for ( var nextKey in source ) { 79 | 80 | if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) { 81 | 82 | output[ nextKey ] = source[ nextKey ]; 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | } 91 | 92 | return output; 93 | 94 | }; 95 | 96 | } )(); 97 | 98 | } 99 | -------------------------------------------------------------------------------- /module/materials/MeshDepthMaterial.js: -------------------------------------------------------------------------------- 1 | import { Material } from './Material.js'; 2 | import { BasicDepthPacking } from '../constants.js'; 3 | 4 | /** 5 | * @author mrdoob / http://mrdoob.com/ 6 | * @author alteredq / http://alteredqualia.com/ 7 | * @author bhouston / https://clara.io 8 | * @author WestLangley / http://github.com/WestLangley 9 | * 10 | * parameters = { 11 | * 12 | * opacity: , 13 | * 14 | * map: new THREE.Texture( ), 15 | * 16 | * alphaMap: new THREE.Texture( ), 17 | * 18 | * displacementMap: new THREE.Texture( ), 19 | * displacementScale: , 20 | * displacementBias: , 21 | * 22 | * wireframe: , 23 | * wireframeLinewidth: 24 | * } 25 | */ 26 | 27 | function MeshDepthMaterial( parameters ) { 28 | 29 | Material.call( this ); 30 | 31 | this.type = 'MeshDepthMaterial'; 32 | 33 | this.depthPacking = BasicDepthPacking; 34 | 35 | this.skinning = false; 36 | this.morphTargets = false; 37 | 38 | this.map = null; 39 | 40 | this.alphaMap = null; 41 | 42 | this.displacementMap = null; 43 | this.displacementScale = 1; 44 | this.displacementBias = 0; 45 | 46 | this.wireframe = false; 47 | this.wireframeLinewidth = 1; 48 | 49 | this.fog = false; 50 | this.lights = false; 51 | 52 | this.setValues( parameters ); 53 | 54 | } 55 | 56 | MeshDepthMaterial.prototype = Object.create( Material.prototype ); 57 | MeshDepthMaterial.prototype.constructor = MeshDepthMaterial; 58 | 59 | MeshDepthMaterial.prototype.isMeshDepthMaterial = true; 60 | 61 | MeshDepthMaterial.prototype.copy = function ( source ) { 62 | 63 | Material.prototype.copy.call( this, source ); 64 | 65 | this.depthPacking = source.depthPacking; 66 | 67 | this.skinning = source.skinning; 68 | this.morphTargets = source.morphTargets; 69 | 70 | this.map = source.map; 71 | 72 | this.alphaMap = source.alphaMap; 73 | 74 | this.displacementMap = source.displacementMap; 75 | this.displacementScale = source.displacementScale; 76 | this.displacementBias = source.displacementBias; 77 | 78 | this.wireframe = source.wireframe; 79 | this.wireframeLinewidth = source.wireframeLinewidth; 80 | 81 | return this; 82 | 83 | }; 84 | 85 | 86 | export { MeshDepthMaterial }; 87 | -------------------------------------------------------------------------------- /module/crop.js: -------------------------------------------------------------------------------- 1 | function cropX(imageData, { left = 0, right = 0 }) { 2 | const { data, width, height } = imageData; 3 | const dataLength = data.length; 4 | const newWidth = width - left - right; 5 | const rowLength = width * 4; 6 | const newRowLength = newWidth * 4; 7 | const leftCrop = left * 4; 8 | const newData = []; 9 | // loop through each row 10 | for (let x = 0; x < dataLength; x += rowLength) { 11 | const newRowStart = x + leftCrop; 12 | const newRowEnd = newRowStart + newRowLength; 13 | for (let i = newRowStart; i < newRowEnd; i += 4) { 14 | newData.push(data[i], data[i + 1], data[i + 2], data[i + 3]); 15 | } 16 | } 17 | return { data: newData, height, width: newWidth }; 18 | } 19 | function cropY(imageData, { top = 0, bottom = 0 }) { 20 | const { data, width, height } = imageData; 21 | const rowLength = width * 4; 22 | const topIndex = top * rowLength; 23 | const bottomIndex = bottom * rowLength; 24 | const newHeight = height - top - bottom; 25 | const newDataEnd = data.length - bottomIndex; 26 | const newData = []; 27 | // save each index within the cropped area (avoid .slice() for performance) 28 | for (let i = topIndex; i < newDataEnd; i++) { 29 | newData.push(data[i]); 30 | } 31 | return { data: newData, height: newHeight, width }; 32 | } 33 | function toNumber(options) { 34 | return Object.fromEntries(Object.entries(options).map(([key, value]) => [key, Number(value || 0)])); 35 | } 36 | export default function cropImageData(imageData, cropOptions) { 37 | const { top, right, bottom, left } = toNumber(cropOptions); 38 | if (imageData.height < top + bottom || imageData.width < left + right) { 39 | return new ImageData(1, 1); 40 | } 41 | let newImageData = { 42 | data: imageData.data, 43 | width: imageData.width, 44 | height: imageData.height, 45 | }; 46 | if (top || bottom) { 47 | newImageData = cropY(newImageData, { top, bottom }); 48 | } 49 | if (left || right) { 50 | newImageData = cropX(newImageData, { left, right }); 51 | } 52 | const { data, height, width } = newImageData; 53 | return new ImageData(Uint8ClampedArray.from(data), width, height); 54 | } 55 | -------------------------------------------------------------------------------- /module/objects/LineSegments.js: -------------------------------------------------------------------------------- 1 | import { Line } from './Line.js'; 2 | import { Vector3 } from '../math/Vector3.js'; 3 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 4 | 5 | /** 6 | * @author mrdoob / http://mrdoob.com/ 7 | */ 8 | 9 | function LineSegments( geometry, material ) { 10 | 11 | Line.call( this, geometry, material ); 12 | 13 | this.type = 'LineSegments'; 14 | 15 | } 16 | 17 | LineSegments.prototype = Object.assign( Object.create( Line.prototype ), { 18 | 19 | constructor: LineSegments, 20 | 21 | isLineSegments: true, 22 | 23 | computeLineDistances: ( function () { 24 | 25 | var start = new Vector3(); 26 | var end = new Vector3(); 27 | 28 | return function computeLineDistances() { 29 | 30 | var geometry = this.geometry; 31 | 32 | if ( geometry.isBufferGeometry ) { 33 | 34 | // we assume non-indexed geometry 35 | 36 | if ( geometry.index === null ) { 37 | 38 | var positionAttribute = geometry.attributes.position; 39 | var lineDistances = []; 40 | 41 | for ( var i = 0, l = positionAttribute.count; i < l; i += 2 ) { 42 | 43 | start.fromBufferAttribute( positionAttribute, i ); 44 | end.fromBufferAttribute( positionAttribute, i + 1 ); 45 | 46 | lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ]; 47 | lineDistances[ i + 1 ] = lineDistances[ i ] + start.distanceTo( end ); 48 | 49 | } 50 | 51 | geometry.addAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) ); 52 | 53 | } else { 54 | 55 | console.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' ); 56 | 57 | } 58 | 59 | } else if ( geometry.isGeometry ) { 60 | 61 | var vertices = geometry.vertices; 62 | var lineDistances = geometry.lineDistances; 63 | 64 | for ( var i = 0, l = vertices.length; i < l; i += 2 ) { 65 | 66 | start.copy( vertices[ i ] ); 67 | end.copy( vertices[ i + 1 ] ); 68 | 69 | lineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ]; 70 | lineDistances[ i + 1 ] = lineDistances[ i ] + start.distanceTo( end ); 71 | 72 | } 73 | 74 | } 75 | 76 | return this; 77 | 78 | }; 79 | 80 | }() ) 81 | 82 | } ); 83 | 84 | 85 | export { LineSegments }; 86 | -------------------------------------------------------------------------------- /module/helpers/PointLightHelper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author alteredq / http://alteredqualia.com/ 3 | * @author mrdoob / http://mrdoob.com/ 4 | */ 5 | 6 | import { Mesh } from '../objects/Mesh.js'; 7 | import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; 8 | import { SphereBufferGeometry } from '../geometries/SphereGeometry.js'; 9 | 10 | function PointLightHelper( light, sphereSize, color ) { 11 | 12 | this.light = light; 13 | this.light.updateMatrixWorld(); 14 | 15 | this.color = color; 16 | 17 | var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); 18 | var material = new MeshBasicMaterial( { wireframe: true, fog: false } ); 19 | 20 | Mesh.call( this, geometry, material ); 21 | 22 | this.matrix = this.light.matrixWorld; 23 | this.matrixAutoUpdate = false; 24 | 25 | this.update(); 26 | 27 | 28 | /* 29 | var distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 ); 30 | var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } ); 31 | 32 | this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial ); 33 | this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial ); 34 | 35 | var d = light.distance; 36 | 37 | if ( d === 0.0 ) { 38 | 39 | this.lightDistance.visible = false; 40 | 41 | } else { 42 | 43 | this.lightDistance.scale.set( d, d, d ); 44 | 45 | } 46 | 47 | this.add( this.lightDistance ); 48 | */ 49 | 50 | } 51 | 52 | PointLightHelper.prototype = Object.create( Mesh.prototype ); 53 | PointLightHelper.prototype.constructor = PointLightHelper; 54 | 55 | PointLightHelper.prototype.dispose = function () { 56 | 57 | this.geometry.dispose(); 58 | this.material.dispose(); 59 | 60 | }; 61 | 62 | PointLightHelper.prototype.update = function () { 63 | 64 | if ( this.color !== undefined ) { 65 | 66 | this.material.color.set( this.color ); 67 | 68 | } else { 69 | 70 | this.material.color.copy( this.light.color ); 71 | 72 | } 73 | 74 | /* 75 | var d = this.light.distance; 76 | 77 | if ( d === 0.0 ) { 78 | 79 | this.lightDistance.visible = false; 80 | 81 | } else { 82 | 83 | this.lightDistance.visible = true; 84 | this.lightDistance.scale.set( d, d, d ); 85 | 86 | } 87 | */ 88 | 89 | }; 90 | 91 | 92 | export { PointLightHelper }; 93 | -------------------------------------------------------------------------------- /module/core/InterleavedBuffer.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * @author benaadams / https://twitter.com/ben_a_adams 4 | */ 5 | 6 | function InterleavedBuffer( array, stride ) { 7 | 8 | this.array = array; 9 | this.stride = stride; 10 | this.count = array !== undefined ? array.length / stride : 0; 11 | 12 | this.dynamic = false; 13 | this.updateRange = { offset: 0, count: - 1 }; 14 | 15 | this.version = 0; 16 | 17 | } 18 | 19 | Object.defineProperty( InterleavedBuffer.prototype, 'needsUpdate', { 20 | 21 | set: function ( value ) { 22 | 23 | if ( value === true ) this.version ++; 24 | 25 | } 26 | 27 | } ); 28 | 29 | Object.assign( InterleavedBuffer.prototype, { 30 | 31 | isInterleavedBuffer: true, 32 | 33 | onUploadCallback: function () {}, 34 | 35 | setArray: function ( array ) { 36 | 37 | if ( Array.isArray( array ) ) { 38 | 39 | throw new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' ); 40 | 41 | } 42 | 43 | this.count = array !== undefined ? array.length / this.stride : 0; 44 | this.array = array; 45 | 46 | return this; 47 | 48 | }, 49 | 50 | setDynamic: function ( value ) { 51 | 52 | this.dynamic = value; 53 | 54 | return this; 55 | 56 | }, 57 | 58 | copy: function ( source ) { 59 | 60 | this.array = new source.array.constructor( source.array ); 61 | this.count = source.count; 62 | this.stride = source.stride; 63 | this.dynamic = source.dynamic; 64 | 65 | return this; 66 | 67 | }, 68 | 69 | copyAt: function ( index1, attribute, index2 ) { 70 | 71 | index1 *= this.stride; 72 | index2 *= attribute.stride; 73 | 74 | for ( var i = 0, l = this.stride; i < l; i ++ ) { 75 | 76 | this.array[ index1 + i ] = attribute.array[ index2 + i ]; 77 | 78 | } 79 | 80 | return this; 81 | 82 | }, 83 | 84 | set: function ( value, offset ) { 85 | 86 | if ( offset === undefined ) offset = 0; 87 | 88 | this.array.set( value, offset ); 89 | 90 | return this; 91 | 92 | }, 93 | 94 | clone: function () { 95 | 96 | return new this.constructor().copy( this ); 97 | 98 | }, 99 | 100 | onUpload: function ( callback ) { 101 | 102 | this.onUploadCallback = callback; 103 | 104 | return this; 105 | 106 | } 107 | 108 | } ); 109 | 110 | 111 | export { InterleavedBuffer }; 112 | -------------------------------------------------------------------------------- /module/helpers/PlaneHelper.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author WestLangley / http://github.com/WestLangley 3 | */ 4 | 5 | import { Line } from '../objects/Line.js'; 6 | import { Mesh } from '../objects/Mesh.js'; 7 | import { LineBasicMaterial } from '../materials/LineBasicMaterial.js'; 8 | import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js'; 9 | import { Float32BufferAttribute } from '../core/BufferAttribute.js'; 10 | import { BufferGeometry } from '../core/BufferGeometry.js'; 11 | import { Object3D } from '../core/Object3D.js'; 12 | import { FrontSide, BackSide } from '../constants.js'; 13 | 14 | function PlaneHelper( plane, size, hex ) { 15 | 16 | this.type = 'PlaneHelper'; 17 | 18 | this.plane = plane; 19 | 20 | this.size = ( size === undefined ) ? 1 : size; 21 | 22 | var color = ( hex !== undefined ) ? hex : 0xffff00; 23 | 24 | var positions = [ 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, 0, 1, 0, 0, 0 ]; 25 | 26 | var geometry = new BufferGeometry(); 27 | geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); 28 | geometry.computeBoundingSphere(); 29 | 30 | Line.call( this, geometry, new LineBasicMaterial( { color: color } ) ); 31 | 32 | // 33 | 34 | var positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ]; 35 | 36 | var geometry2 = new BufferGeometry(); 37 | geometry2.addAttribute( 'position', new Float32BufferAttribute( positions2, 3 ) ); 38 | geometry2.computeBoundingSphere(); 39 | 40 | this.add( new Mesh( geometry2, new MeshBasicMaterial( { color: color, opacity: 0.2, transparent: true, depthWrite: false } ) ) ); 41 | 42 | } 43 | 44 | PlaneHelper.prototype = Object.create( Line.prototype ); 45 | PlaneHelper.prototype.constructor = PlaneHelper; 46 | 47 | PlaneHelper.prototype.updateMatrixWorld = function ( force ) { 48 | 49 | var scale = - this.plane.constant; 50 | 51 | if ( Math.abs( scale ) < 1e-8 ) scale = 1e-8; // sign does not matter 52 | 53 | this.scale.set( 0.5 * this.size, 0.5 * this.size, scale ); 54 | 55 | this.children[ 0 ].material.side = ( scale < 0 ) ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here 56 | 57 | this.lookAt( this.plane.normal ); 58 | 59 | Object3D.prototype.updateMatrixWorld.call( this, force ); 60 | 61 | }; 62 | 63 | export { PlaneHelper }; 64 | -------------------------------------------------------------------------------- /module/renderers/webgl/WebGLRenderStates.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Mugen87 / https://github.com/Mugen87 3 | */ 4 | 5 | import { WebGLLights } from './WebGLLights.js'; 6 | 7 | function WebGLRenderState() { 8 | 9 | var lights = new WebGLLights(); 10 | 11 | var lightsArray = []; 12 | var shadowsArray = []; 13 | 14 | function init() { 15 | 16 | lightsArray.length = 0; 17 | shadowsArray.length = 0; 18 | 19 | } 20 | 21 | function pushLight( light ) { 22 | 23 | lightsArray.push( light ); 24 | 25 | } 26 | 27 | function pushShadow( shadowLight ) { 28 | 29 | shadowsArray.push( shadowLight ); 30 | 31 | } 32 | 33 | function setupLights( camera ) { 34 | 35 | lights.setup( lightsArray, shadowsArray, camera ); 36 | 37 | } 38 | 39 | var state = { 40 | lightsArray: lightsArray, 41 | shadowsArray: shadowsArray, 42 | 43 | lights: lights 44 | }; 45 | 46 | return { 47 | init: init, 48 | state: state, 49 | setupLights: setupLights, 50 | 51 | pushLight: pushLight, 52 | pushShadow: pushShadow 53 | }; 54 | 55 | } 56 | 57 | function WebGLRenderStates() { 58 | 59 | var renderStates = {}; 60 | 61 | function onSceneDispose( event ) { 62 | 63 | var scene = event.target; 64 | 65 | scene.removeEventListener( 'dispose', onSceneDispose ); 66 | 67 | delete renderStates[ scene.id ]; 68 | 69 | } 70 | 71 | function get( scene, camera ) { 72 | 73 | var renderState; 74 | 75 | if ( renderStates[ scene.id ] === undefined ) { 76 | 77 | renderState = new WebGLRenderState(); 78 | renderStates[ scene.id ] = {}; 79 | renderStates[ scene.id ][ camera.id ] = renderState; 80 | 81 | scene.addEventListener( 'dispose', onSceneDispose ); 82 | 83 | } else { 84 | 85 | if ( renderStates[ scene.id ][ camera.id ] === undefined ) { 86 | 87 | renderState = new WebGLRenderState(); 88 | renderStates[ scene.id ][ camera.id ] = renderState; 89 | 90 | } else { 91 | 92 | renderState = renderStates[ scene.id ][ camera.id ]; 93 | 94 | } 95 | 96 | } 97 | 98 | return renderState; 99 | 100 | } 101 | 102 | function dispose() { 103 | 104 | renderStates = {}; 105 | 106 | } 107 | 108 | return { 109 | get: get, 110 | dispose: dispose 111 | }; 112 | 113 | } 114 | 115 | 116 | export { WebGLRenderStates }; 117 | -------------------------------------------------------------------------------- /module/renderers/shaders/ShaderLib/meshphong_frag.glsl.js: -------------------------------------------------------------------------------- 1 | export default /* glsl */` 2 | #define PHONG 3 | 4 | uniform vec3 diffuse; 5 | uniform vec3 emissive; 6 | uniform vec3 specular; 7 | uniform float shininess; 8 | uniform float opacity; 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | void main() { 35 | 36 | #include 37 | 38 | vec4 diffuseColor = vec4( diffuse, opacity ); 39 | ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); 40 | vec3 totalEmissiveRadiance = emissive; 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | 52 | // accumulation 53 | #include 54 | #include 55 | #include 56 | #include 57 | 58 | // modulation 59 | #include 60 | 61 | vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; 62 | 63 | #include 64 | 65 | gl_FragColor = vec4( outgoingLight, diffuseColor.a ); 66 | 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | 73 | } 74 | `; 75 | --------------------------------------------------------------------------------