Преглед изворни кода

Modules (#9310)

* convert to ES modules

* rebuild

* move shaders back into glsl files

* reinstate polyfills
Rich Harris пре 9 година
родитељ
комит
f65e669af9
100 измењених фајлова са 7344 додато и 6917 уклоњено
  1. 4875 4707
      build/three.js
  2. 0 528
      build/three.min.js
  3. 5 3
      package.json
  4. 26 0
      rollup.config.js
  5. 239 335
      src/Three.js
  6. 21 15
      src/animation/AnimationAction.js
  7. 31 20
      src/animation/AnimationClip.js
  8. 21 11
      src/animation/AnimationMixer.js
  9. 14 7
      src/animation/AnimationObjectGroup.js
  10. 7 2
      src/animation/AnimationUtils.js
  11. 28 367
      src/animation/KeyframeTrack.js
  12. 26 0
      src/animation/KeyframeTrackConstructor.js
  13. 345 0
      src/animation/KeyframeTrackPrototype.js
  14. 23 19
      src/animation/PropertyBinding.js
  15. 10 4
      src/animation/PropertyMixer.js
  16. 14 6
      src/animation/tracks/BooleanKeyframeTrack.js
  17. 12 5
      src/animation/tracks/ColorKeyframeTrack.js
  18. 12 5
      src/animation/tracks/NumberKeyframeTrack.js
  19. 16 7
      src/animation/tracks/QuaternionKeyframeTrack.js
  20. 14 6
      src/animation/tracks/StringKeyframeTrack.js
  21. 12 5
      src/animation/tracks/VectorKeyframeTrack.js
  22. 10 4
      src/audio/Audio.js
  23. 6 2
      src/audio/AudioAnalyser.js
  24. 7 23
      src/audio/AudioContext.js
  25. 19 10
      src/audio/AudioListener.js
  26. 14 6
      src/audio/PositionalAudio.js
  27. 23 14
      src/cameras/Camera.js
  28. 28 18
      src/cameras/CubeCamera.js
  29. 13 6
      src/cameras/OrthographicCamera.js
  30. 19 11
      src/cameras/PerspectiveCamera.js
  31. 15 7
      src/cameras/StereoCamera.js
  32. 122 0
      src/constants.js
  33. 60 28
      src/core/BufferAttribute.js
  34. 61 45
      src/core/BufferGeometry.js
  35. 7 3
      src/core/Clock.js
  36. 18 8
      src/core/DirectGeometry.js
  37. 6 2
      src/core/EventDispatcher.js
  38. 12 5
      src/core/Face3.js
  39. 49 32
      src/core/Geometry.js
  40. 12 6
      src/core/InstancedBufferAttribute.js
  41. 12 6
      src/core/InstancedBufferGeometry.js
  42. 12 6
      src/core/InstancedInterleavedBuffer.js
  43. 10 4
      src/core/InterleavedBuffer.js
  44. 10 4
      src/core/InterleavedBufferAttribute.js
  45. 7 3
      src/core/Layers.js
  46. 54 40
      src/core/Object3D.js
  47. 76 74
      src/core/Raycaster.js
  48. 7 3
      src/core/Uniform.js
  49. 6 1
      src/extras/CurveUtils.js
  50. 13 4
      src/extras/SceneUtils.js
  51. 9 4
      src/extras/ShapeUtils.js
  52. 9 5
      src/extras/core/Curve.js
  53. 18 9
      src/extras/core/CurvePath.js
  54. 11 4
      src/extras/core/Font.js
  55. 23 133
      src/extras/core/Path.js
  56. 131 0
      src/extras/core/PathPrototype.js
  57. 15 6
      src/extras/core/Shape.js
  58. 10 4
      src/extras/curves/ArcCurve.js
  59. 12 4
      src/extras/curves/CatmullRomCurve3.js
  60. 9 3
      src/extras/curves/ClosedSplineCurve3.js
  61. 18 9
      src/extras/curves/CubicBezierCurve.js
  62. 12 3
      src/extras/curves/CubicBezierCurve3.js
  63. 12 5
      src/extras/curves/EllipseCurve.js
  64. 12 6
      src/extras/curves/LineCurve.js
  65. 10 2
      src/extras/curves/LineCurve3.js
  66. 18 9
      src/extras/curves/QuadraticBezierCurve.js
  67. 12 3
      src/extras/curves/QuadraticBezierCurve3.js
  68. 14 6
      src/extras/curves/SplineCurve.js
  69. 12 3
      src/extras/curves/SplineCurve3.js
  70. 17 9
      src/extras/geometries/BoxBufferGeometry.js
  71. 15 6
      src/extras/geometries/BoxGeometry.js
  72. 18 9
      src/extras/geometries/CircleBufferGeometry.js
  73. 12 5
      src/extras/geometries/CircleGeometry.js
  74. 11 4
      src/extras/geometries/ConeBufferGeometry.js
  75. 10 4
      src/extras/geometries/ConeGeometry.js
  76. 21 12
      src/extras/geometries/CylinderBufferGeometry.js
  77. 12 5
      src/extras/geometries/CylinderGeometry.js
  78. 10 4
      src/extras/geometries/DodecahedronGeometry.js
  79. 17 8
      src/extras/geometries/EdgesGeometry.js
  80. 43 32
      src/extras/geometries/ExtrudeGeometry.js
  81. 10 4
      src/extras/geometries/IcosahedronGeometry.js
  82. 23 13
      src/extras/geometries/LatheBufferGeometry.js
  83. 12 5
      src/extras/geometries/LatheGeometry.js
  84. 10 4
      src/extras/geometries/OctahedronGeometry.js
  85. 18 10
      src/extras/geometries/ParametricGeometry.js
  86. 15 8
      src/extras/geometries/PlaneBufferGeometry.js
  87. 12 5
      src/extras/geometries/PlaneGeometry.js
  88. 22 12
      src/extras/geometries/PolyhedronGeometry.js
  89. 19 10
      src/extras/geometries/RingBufferGeometry.js
  90. 12 5
      src/extras/geometries/RingGeometry.js
  91. 22 12
      src/extras/geometries/ShapeGeometry.js
  92. 19 10
      src/extras/geometries/SphereBufferGeometry.js
  93. 12 5
      src/extras/geometries/SphereGeometry.js
  94. 10 4
      src/extras/geometries/TetrahedronGeometry.js
  95. 13 6
      src/extras/geometries/TextGeometry.js
  96. 19 11
      src/extras/geometries/TorusBufferGeometry.js
  97. 12 5
      src/extras/geometries/TorusGeometry.js
  98. 25 16
      src/extras/geometries/TorusKnotBufferGeometry.js
  99. 12 5
      src/extras/geometries/TorusKnotGeometry.js
  100. 35 24
      src/extras/geometries/TubeGeometry.js

Разлика између датотеке није приказан због своје велике величине
+ 4875 - 4707
build/three.js


Разлика између датотеке није приказан због своје велике величине
+ 0 - 528
build/three.min.js


+ 5 - 3
package.json

@@ -20,9 +20,9 @@
     "test": "test"
     "test": "test"
   },
   },
   "scripts": {
   "scripts": {
-    "build": "node utils/build/build.js --include common --include extras",
-    "build-min": "node utils/build/build.js --include common --include extras --minify",
-    "dev": "chokidar \"./src/**/*.*\" \"./utils/build/includes/*.*\" --initial -c \"npm run build\"",
+    "build": "rollup -c",
+    "build-min": "rollup -c && uglifyjs build/three.js -cm > build/three.min.js",
+    "dev": "rollup -c -w",
     "test": "echo \"Error: no test specified\" && exit 1"
     "test": "echo \"Error: no test specified\" && exit 1"
   },
   },
   "repository": {
   "repository": {
@@ -45,6 +45,8 @@
     "argparse": "^1.0.3",
     "argparse": "^1.0.3",
     "chokidar-cli": "1.2.0",
     "chokidar-cli": "1.2.0",
     "jscs": "^1.13.1",
     "jscs": "^1.13.1",
+    "rollup": "^0.33.1",
+    "rollup-plugin-string": "^2.0.2",
     "uglify-js": "^2.6.0"
     "uglify-js": "^2.6.0"
   }
   }
 }
 }

+ 26 - 0
rollup.config.js

@@ -0,0 +1,26 @@
+import * as fs from 'fs';
+import string from 'rollup-plugin-string';
+
+var outro = `
+Object.defineProperty( exports, 'AudioContext', {
+	get: function () {
+		return exports.getAudioContext();
+	}
+});`;
+
+var footer = fs.readFileSync( 'src/Three.Legacy.js', 'utf-8' );
+
+export default {
+	entry: 'src/Three.js',
+	dest: 'build/three.js',
+	moduleName: 'THREE',
+	format: 'umd',
+	plugins: [
+		string({
+			include: '**/*.glsl'
+		})
+	],
+
+	outro: outro,
+	footer: footer
+};

+ 239 - 335
src/Three.js

@@ -1,335 +1,239 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
-
-var THREE = { REVISION: '79' };
-
-//
-
-if ( typeof define === 'function' && define.amd ) {
-
-	define( 'three', THREE );
-
-} else if ( 'undefined' !== typeof exports && 'undefined' !== typeof module ) {
-
-	module.exports = THREE;
-
-}
-
-// Polyfills
-
-if ( Number.EPSILON === undefined ) {
-
-	Number.EPSILON = Math.pow( 2, - 52 );
-
-}
-
-//
-
-if ( Math.sign === undefined ) {
-
-	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
-
-	Math.sign = function ( x ) {
-
-		return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
-
-	};
-
-}
-
-if ( Function.prototype.name === undefined ) {
-
-	// Missing in IE9-11.
-	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
-
-	Object.defineProperty( Function.prototype, 'name', {
-
-		get: function () {
-
-			return this.toString().match( /^\s*function\s*(\S*)\s*\(/ )[ 1 ];
-
-		}
-
-	} );
-
-}
-
-if ( Object.assign === undefined ) {
-
-	// Missing in IE.
-	// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
-
-	( function () {
-
-		Object.assign = function ( target ) {
-
-			'use strict';
-
-			if ( target === undefined || target === null ) {
-
-				throw new TypeError( 'Cannot convert undefined or null to object' );
-
-			}
-
-			var output = Object( target );
-
-			for ( var index = 1; index < arguments.length; index ++ ) {
-
-				var source = arguments[ index ];
-
-				if ( source !== undefined && source !== null ) {
-
-					for ( var nextKey in source ) {
-
-						if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
-
-							output[ nextKey ] = source[ nextKey ];
-
-						}
-
-					}
-
-				}
-
-			}
-
-			return output;
-
-		};
-
-	} )();
-
-}
-
-//
-
-Object.assign( THREE, {
-
-	// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent.button
-
-	MOUSE: { LEFT: 0, MIDDLE: 1, RIGHT: 2 },
-
-	// GL STATE CONSTANTS
-
-	CullFaceNone: 0,
-	CullFaceBack: 1,
-	CullFaceFront: 2,
-	CullFaceFrontBack: 3,
-
-	FrontFaceDirectionCW: 0,
-	FrontFaceDirectionCCW: 1,
-
-	// SHADOWING TYPES
-
-	BasicShadowMap: 0,
-	PCFShadowMap: 1,
-	PCFSoftShadowMap: 2,
-
-	// MATERIAL CONSTANTS
-
-	// side
-
-	FrontSide: 0,
-	BackSide: 1,
-	DoubleSide: 2,
-
-	// shading
-
-	FlatShading: 1,
-	SmoothShading: 2,
-
-	// colors
-
-	NoColors: 0,
-	FaceColors: 1,
-	VertexColors: 2,
-
-	// blending modes
-
-	NoBlending: 0,
-	NormalBlending: 1,
-	AdditiveBlending: 2,
-	SubtractiveBlending: 3,
-	MultiplyBlending: 4,
-	CustomBlending: 5,
-
-	// custom blending equations
-	// (numbers start from 100 not to clash with other
-	// mappings to OpenGL constants defined in Texture.js)
-
-	AddEquation: 100,
-	SubtractEquation: 101,
-	ReverseSubtractEquation: 102,
-	MinEquation: 103,
-	MaxEquation: 104,
-
-	// custom blending destination factors
-
-	ZeroFactor: 200,
-	OneFactor: 201,
-	SrcColorFactor: 202,
-	OneMinusSrcColorFactor: 203,
-	SrcAlphaFactor: 204,
-	OneMinusSrcAlphaFactor: 205,
-	DstAlphaFactor: 206,
-	OneMinusDstAlphaFactor: 207,
-
-	// custom blending source factors
-
-	//ZeroFactor: 200,
-	//OneFactor: 201,
-	//SrcAlphaFactor: 204,
-	//OneMinusSrcAlphaFactor: 205,
-	//DstAlphaFactor: 206,
-	//OneMinusDstAlphaFactor: 207,
-	DstColorFactor: 208,
-	OneMinusDstColorFactor: 209,
-	SrcAlphaSaturateFactor: 210,
-
-	// depth modes
-
-	NeverDepth: 0,
-	AlwaysDepth: 1,
-	LessDepth: 2,
-	LessEqualDepth: 3,
-	EqualDepth: 4,
-	GreaterEqualDepth: 5,
-	GreaterDepth: 6,
-	NotEqualDepth: 7,
-
-
-	// TEXTURE CONSTANTS
-
-	MultiplyOperation: 0,
-	MixOperation: 1,
-	AddOperation: 2,
-
-	// Tone Mapping modes
-
-	NoToneMapping: 0, // do not do any tone mapping, not even exposure (required for special purpose passes.)
-	LinearToneMapping: 1, // only apply exposure.
-	ReinhardToneMapping: 2,
-	Uncharted2ToneMapping: 3, // John Hable
-	CineonToneMapping: 4, // optimized filmic operator by Jim Hejl and Richard Burgess-Dawson
-
-	// Mapping modes
-
-	UVMapping: 300,
-
-	CubeReflectionMapping: 301,
-	CubeRefractionMapping: 302,
-
-	EquirectangularReflectionMapping: 303,
-	EquirectangularRefractionMapping: 304,
-
-	SphericalReflectionMapping: 305,
-	CubeUVReflectionMapping: 306,
-	CubeUVRefractionMapping: 307,
-
-	// Wrapping modes
-
-	RepeatWrapping: 1000,
-	ClampToEdgeWrapping: 1001,
-	MirroredRepeatWrapping: 1002,
-
-	// Filters
-
-	NearestFilter: 1003,
-	NearestMipMapNearestFilter: 1004,
-	NearestMipMapLinearFilter: 1005,
-	LinearFilter: 1006,
-	LinearMipMapNearestFilter: 1007,
-	LinearMipMapLinearFilter: 1008,
-
-	// Data types
-
-	UnsignedByteType: 1009,
-	ByteType: 1010,
-	ShortType: 1011,
-	UnsignedShortType: 1012,
-	IntType: 1013,
-	UnsignedIntType: 1014,
-	FloatType: 1015,
-	HalfFloatType: 1025,
-
-	// Pixel types
-
-	//UnsignedByteType: 1009,
-	UnsignedShort4444Type: 1016,
-	UnsignedShort5551Type: 1017,
-	UnsignedShort565Type: 1018,
-
-	// Pixel formats
-
-	AlphaFormat: 1019,
-	RGBFormat: 1020,
-	RGBAFormat: 1021,
-	LuminanceFormat: 1022,
-	LuminanceAlphaFormat: 1023,
-	// THREE.RGBEFormat handled as THREE.RGBAFormat in shaders
-	RGBEFormat: THREE.RGBAFormat, //1024;
-	DepthFormat: 1026,
-
-	// DDS / ST3C Compressed texture formats
-
-	RGB_S3TC_DXT1_Format: 2001,
-	RGBA_S3TC_DXT1_Format: 2002,
-	RGBA_S3TC_DXT3_Format: 2003,
-	RGBA_S3TC_DXT5_Format: 2004,
-
-	// PVRTC compressed texture formats
-
-	RGB_PVRTC_4BPPV1_Format: 2100,
-	RGB_PVRTC_2BPPV1_Format: 2101,
-	RGBA_PVRTC_4BPPV1_Format: 2102,
-	RGBA_PVRTC_2BPPV1_Format: 2103,
-
-	// ETC compressed texture formats
-
-	RGB_ETC1_Format: 2151,
-
-	// Loop styles for AnimationAction
-
-	LoopOnce: 2200,
-	LoopRepeat: 2201,
-	LoopPingPong: 2202,
-
-	// Interpolation
-
-	InterpolateDiscrete: 2300,
-	InterpolateLinear: 2301,
-	InterpolateSmooth: 2302,
-
-	// Interpolant ending modes
-
-	ZeroCurvatureEnding: 2400,
-	ZeroSlopeEnding: 2401,
-	WrapAroundEnding: 2402,
-
-	// Triangle Draw modes
-
-	TrianglesDrawMode: 0,
-	TriangleStripDrawMode: 1,
-	TriangleFanDrawMode: 2,
-
-	// Texture Encodings
-
-	LinearEncoding: 3000, // No encoding at all.
-	sRGBEncoding: 3001,
-	GammaEncoding: 3007, // uses GAMMA_FACTOR, for backwards compatibility with WebGLRenderer.gammaInput/gammaOutput
-
-	// The following Texture Encodings are for RGB-only (no alpha) HDR light emission sources.
-	// These encodings should not specified as output encodings except in rare situations.
-	RGBEEncoding: 3002, // AKA Radiance.
-	LogLuvEncoding: 3003,
-	RGBM7Encoding: 3004,
-	RGBM16Encoding: 3005,
-	RGBDEncoding: 3006, // MaxRange is 256.
-
-	// Depth packing strategies
-
-	BasicDepthPacking: 3200, // for writing to float textures for high precision or for visualizing results in RGB buffers
-	RGBADepthPacking: 3201 // for packing into RGBA buffers.
-
-} );
+import './polyfills.js';
+
+export { SpritePlugin } from './renderers/webgl/plugins/SpritePlugin.js';
+export { LensFlarePlugin } from './renderers/webgl/plugins/LensFlarePlugin.js';
+export { WebGLUniforms } from './renderers/webgl/WebGLUniforms.js';
+export { WebGLTextures } from './renderers/webgl/WebGLTextures.js';
+export {
+  WebGLStencilBuffer,
+  WebGLDepthBuffer,
+  WebGLColorBuffer,
+  WebGLState
+} from './renderers/webgl/WebGLState.js';
+export { WebGLShadowMap } from './renderers/webgl/WebGLShadowMap.js';
+export { WebGLShader } from './renderers/webgl/WebGLShader.js';
+export { WebGLProperties } from './renderers/webgl/WebGLProperties.js';
+export { WebGLPrograms } from './renderers/webgl/WebGLPrograms.js';
+export { WebGLProgram } from './renderers/webgl/WebGLProgram.js';
+export { WebGLObjects } from './renderers/webgl/WebGLObjects.js';
+export { WebGLLights } from './renderers/webgl/WebGLLights.js';
+export { WebGLGeometries } from './renderers/webgl/WebGLGeometries.js';
+export { WebGLCapabilities } from './renderers/webgl/WebGLCapabilities.js';
+export { WebGLExtensions } from './renderers/webgl/WebGLExtensions.js';
+export { WebGLIndexedBufferRenderer } from './renderers/webgl/WebGLIndexedBufferRenderer.js';
+export { WebGLClipping } from './renderers/webgl/WebGLClipping.js';
+export { WebGLBufferRenderer } from './renderers/webgl/WebGLBufferRenderer.js';
+export { WebGLRenderTargetCube } from './renderers/WebGLRenderTargetCube.js';
+export { WebGLRenderTarget } from './renderers/WebGLRenderTarget.js';
+export { WebGLRenderer } from './renderers/WebGLRenderer.js';
+export { ShaderLib } from './renderers/shaders/ShaderLib.js';
+export { UniformsLib } from './renderers/shaders/UniformsLib.js';
+export { UniformsUtils } from './renderers/shaders/UniformsUtils.js';
+export { ShaderChunk } from './renderers/shaders/ShaderChunk.js';
+export { FogExp2 } from './scenes/FogExp2.js';
+export { Fog } from './scenes/Fog.js';
+export { Scene } from './scenes/Scene.js';
+export { LensFlare } from './objects/LensFlare.js';
+export { Sprite } from './objects/Sprite.js';
+export { LOD } from './objects/LOD.js';
+export { SkinnedMesh } from './objects/SkinnedMesh.js';
+export { Skeleton } from './objects/Skeleton.js';
+export { Bone } from './objects/Bone.js';
+export { Mesh } from './objects/Mesh.js';
+export { LineSegments } from './objects/LineSegments.js';
+export { Line } from './objects/Line.js';
+export { Points } from './objects/Points.js';
+export { Group } from './objects/Group.js';
+export { VideoTexture } from './textures/VideoTexture.js';
+export { DataTexture } from './textures/DataTexture.js';
+export { CompressedTexture } from './textures/CompressedTexture.js';
+export { CubeTexture } from './textures/CubeTexture.js';
+export { CanvasTexture } from './textures/CanvasTexture.js';
+export { DepthTexture } from './textures/DepthTexture.js';
+export { TextureIdCount, Texture } from './textures/Texture.js';
+export { ShadowMaterial } from './materials/ShadowMaterial.js';
+export { SpriteMaterial } from './materials/SpriteMaterial.js';
+export { RawShaderMaterial } from './materials/RawShaderMaterial.js';
+export { ShaderMaterial } from './materials/ShaderMaterial.js';
+export { PointsMaterial } from './materials/PointsMaterial.js';
+export { MultiMaterial } from './materials/MultiMaterial.js';
+export { MeshPhysicalMaterial } from './materials/MeshPhysicalMaterial.js';
+export { MeshStandardMaterial } from './materials/MeshStandardMaterial.js';
+export { MeshPhongMaterial } from './materials/MeshPhongMaterial.js';
+export { MeshNormalMaterial } from './materials/MeshNormalMaterial.js';
+export { MeshLambertMaterial } from './materials/MeshLambertMaterial.js';
+export { MeshDepthMaterial } from './materials/MeshDepthMaterial.js';
+export { MeshBasicMaterial } from './materials/MeshBasicMaterial.js';
+export { LineDashedMaterial } from './materials/LineDashedMaterial.js';
+export { LineBasicMaterial } from './materials/LineBasicMaterial.js';
+export { MaterialIdCount, Material } from './materials/Material.js';
+export { CompressedTextureLoader } from './loaders/CompressedTextureLoader.js';
+export { BinaryTextureLoader, DataTextureLoader } from './loaders/BinaryTextureLoader.js';
+export { CubeTextureLoader } from './loaders/CubeTextureLoader.js';
+export { TextureLoader } from './loaders/TextureLoader.js';
+export { ObjectLoader } from './loaders/ObjectLoader.js';
+export { MaterialLoader } from './loaders/MaterialLoader.js';
+export { BufferGeometryLoader } from './loaders/BufferGeometryLoader.js';
+export { DefaultLoadingManager, LoadingManager } from './loaders/LoadingManager.js';
+export { JSONLoader } from './loaders/JSONLoader.js';
+export { ImageLoader } from './loaders/ImageLoader.js';
+export { FontLoader } from './loaders/FontLoader.js';
+export { XHRLoader } from './loaders/XHRLoader.js';
+export { Loader } from './loaders/Loader.js';
+export { Cache } from './loaders/Cache.js';
+export { AudioLoader } from './loaders/AudioLoader.js';
+export { SpotLightShadow } from './lights/SpotLightShadow.js';
+export { SpotLight } from './lights/SpotLight.js';
+export { PointLight } from './lights/PointLight.js';
+export { HemisphereLight } from './lights/HemisphereLight.js';
+export { DirectionalLightShadow } from './lights/DirectionalLightShadow.js';
+export { DirectionalLight } from './lights/DirectionalLight.js';
+export { AmbientLight } from './lights/AmbientLight.js';
+export { LightShadow } from './lights/LightShadow.js';
+export { Light } from './lights/Light.js';
+export { StereoCamera } from './cameras/StereoCamera.js';
+export { PerspectiveCamera } from './cameras/PerspectiveCamera.js';
+export { OrthographicCamera } from './cameras/OrthographicCamera.js';
+export { CubeCamera } from './cameras/CubeCamera.js';
+export { Camera } from './cameras/Camera.js';
+export { AudioListener } from './audio/AudioListener.js';
+export { PositionalAudio } from './audio/PositionalAudio.js';
+export { getAudioContext } from './audio/AudioContext.js';
+export { AudioAnalyser } from './audio/AudioAnalyser.js';
+export { Audio } from './audio/Audio.js';
+export { VectorKeyframeTrack } from './animation/tracks/VectorKeyframeTrack.js';
+export { StringKeyframeTrack } from './animation/tracks/StringKeyframeTrack.js';
+export { QuaternionKeyframeTrack } from './animation/tracks/QuaternionKeyframeTrack.js';
+export { NumberKeyframeTrack } from './animation/tracks/NumberKeyframeTrack.js';
+export { ColorKeyframeTrack } from './animation/tracks/ColorKeyframeTrack.js';
+export { BooleanKeyframeTrack } from './animation/tracks/BooleanKeyframeTrack.js';
+export { PropertyMixer } from './animation/PropertyMixer.js';
+export { PropertyBinding } from './animation/PropertyBinding.js';
+export { KeyframeTrack } from './animation/KeyframeTrack.js';
+export { AnimationUtils } from './animation/AnimationUtils.js';
+export { AnimationObjectGroup } from './animation/AnimationObjectGroup.js';
+export { AnimationMixer } from './animation/AnimationMixer.js';
+export { AnimationClip } from './animation/AnimationClip.js';
+export { AnimationAction } from './animation/AnimationAction.js';
+export { Uniform } from './core/Uniform.js';
+export { InstancedBufferGeometry } from './core/InstancedBufferGeometry.js';
+export { BufferGeometry } from './core/BufferGeometry.js';
+export { DirectGeometry } from './core/DirectGeometry.js';
+export { GeometryIdCount, Geometry } from './core/Geometry.js';
+export { InterleavedBufferAttribute } from './core/InterleavedBufferAttribute.js';
+export { InstancedInterleavedBuffer } from './core/InstancedInterleavedBuffer.js';
+export { InterleavedBuffer } from './core/InterleavedBuffer.js';
+export { InstancedBufferAttribute } from './core/InstancedBufferAttribute.js';
+export {
+  DynamicBufferAttribute,
+  Float64Attribute,
+  Float32Attribute,
+  Uint32Attribute,
+  Int32Attribute,
+  Uint16Attribute,
+  Int16Attribute,
+  Uint8ClampedAttribute,
+  Uint8Attribute,
+  Int8Attribute,
+  BufferAttribute
+} from './core/BufferAttribute.js';
+export { Face3 } from './core/Face3.js';
+export { Object3DIdCount, Object3D } from './core/Object3D.js';
+export { Raycaster } from './core/Raycaster.js';
+export { Layers } from './core/Layers.js';
+export { EventDispatcher } from './core/EventDispatcher.js';
+export { Clock } from './core/Clock.js';
+export { QuaternionLinearInterpolant } from './math/interpolants/QuaternionLinearInterpolant.js';
+export { LinearInterpolant } from './math/interpolants/LinearInterpolant.js';
+export { DiscreteInterpolant } from './math/interpolants/DiscreteInterpolant.js';
+export { CubicInterpolant } from './math/interpolants/CubicInterpolant.js';
+export { Interpolant } from './math/Interpolant.js';
+export { Triangle } from './math/Triangle.js';
+export { Spline } from './math/Spline.js';
+export { _Math as Math } from './math/Math.js';
+export { Spherical } from './math/Spherical.js';
+export { Plane } from './math/Plane.js';
+export { Frustum } from './math/Frustum.js';
+export { Sphere } from './math/Sphere.js';
+export { Ray } from './math/Ray.js';
+export { Matrix4 } from './math/Matrix4.js';
+export { Matrix3 } from './math/Matrix3.js';
+export { Box3 } from './math/Box3.js';
+export { Box2 } from './math/Box2.js';
+export { Line3 } from './math/Line3.js';
+export { Euler } from './math/Euler.js';
+export { Vector4 } from './math/Vector4.js';
+export { Vector3 } from './math/Vector3.js';
+export { Vector2 } from './math/Vector2.js';
+export { Quaternion } from './math/Quaternion.js';
+export { ColorKeywords, Color } from './math/Color.js';
+export { MorphBlendMesh } from './extras/objects/MorphBlendMesh.js';
+export { ImmediateRenderObject } from './extras/objects/ImmediateRenderObject.js';
+export { WireframeHelper } from './extras/helpers/WireframeHelper.js';
+export { VertexNormalsHelper } from './extras/helpers/VertexNormalsHelper.js';
+export { SpotLightHelper } from './extras/helpers/SpotLightHelper.js';
+export { SkeletonHelper } from './extras/helpers/SkeletonHelper.js';
+export { PointLightHelper } from './extras/helpers/PointLightHelper.js';
+export { HemisphereLightHelper } from './extras/helpers/HemisphereLightHelper.js';
+export { GridHelper } from './extras/helpers/GridHelper.js';
+export { FaceNormalsHelper } from './extras/helpers/FaceNormalsHelper.js';
+export { EdgesHelper } from './extras/helpers/EdgesHelper.js';
+export { DirectionalLightHelper } from './extras/helpers/DirectionalLightHelper.js';
+export { CameraHelper } from './extras/helpers/CameraHelper.js';
+export { BoundingBoxHelper } from './extras/helpers/BoundingBoxHelper.js';
+export { BoxHelper } from './extras/helpers/BoxHelper.js';
+export { ArrowHelper } from './extras/helpers/ArrowHelper.js';
+export { AxisHelper } from './extras/helpers/AxisHelper.js';
+export { WireframeGeometry } from './extras/geometries/WireframeGeometry.js';
+export { ParametricGeometry } from './extras/geometries/ParametricGeometry.js';
+export { TetrahedronGeometry } from './extras/geometries/TetrahedronGeometry.js';
+export { OctahedronGeometry } from './extras/geometries/OctahedronGeometry.js';
+export { IcosahedronGeometry } from './extras/geometries/IcosahedronGeometry.js';
+export { DodecahedronGeometry } from './extras/geometries/DodecahedronGeometry.js';
+export { PolyhedronGeometry } from './extras/geometries/PolyhedronGeometry.js';
+export { TubeGeometry } from './extras/geometries/TubeGeometry.js';
+export { TorusKnotGeometry } from './extras/geometries/TorusKnotGeometry.js';
+export { TorusKnotBufferGeometry } from './extras/geometries/TorusKnotBufferGeometry.js';
+export { TorusGeometry } from './extras/geometries/TorusGeometry.js';
+export { TorusBufferGeometry } from './extras/geometries/TorusBufferGeometry.js';
+export { TextGeometry } from './extras/geometries/TextGeometry.js';
+export { SphereBufferGeometry } from './extras/geometries/SphereBufferGeometry.js';
+export { SphereGeometry } from './extras/geometries/SphereGeometry.js';
+export { RingGeometry } from './extras/geometries/RingGeometry.js';
+export { RingBufferGeometry } from './extras/geometries/RingBufferGeometry.js';
+export { PlaneBufferGeometry } from './extras/geometries/PlaneBufferGeometry.js';
+export { PlaneGeometry } from './extras/geometries/PlaneGeometry.js';
+export { LatheGeometry } from './extras/geometries/LatheGeometry.js';
+export { LatheBufferGeometry } from './extras/geometries/LatheBufferGeometry.js';
+export { ShapeGeometry } from './extras/geometries/ShapeGeometry.js';
+export { ExtrudeGeometry } from './extras/geometries/ExtrudeGeometry.js';
+export { EdgesGeometry } from './extras/geometries/EdgesGeometry.js';
+export { ConeGeometry } from './extras/geometries/ConeGeometry.js';
+export { ConeBufferGeometry } from './extras/geometries/ConeBufferGeometry.js';
+export { CylinderGeometry } from './extras/geometries/CylinderGeometry.js';
+export { CylinderBufferGeometry } from './extras/geometries/CylinderBufferGeometry.js';
+export { CircleBufferGeometry } from './extras/geometries/CircleBufferGeometry.js';
+export { CircleGeometry } from './extras/geometries/CircleGeometry.js';
+export { BoxBufferGeometry } from './extras/geometries/BoxBufferGeometry.js';
+export { CubeGeometry, BoxGeometry } from './extras/geometries/BoxGeometry.js';
+export { ClosedSplineCurve3 } from './extras/curves/ClosedSplineCurve3.js';
+export { CatmullRomCurve3 } from './extras/curves/CatmullRomCurve3.js';
+export { SplineCurve3 } from './extras/curves/SplineCurve3.js';
+export { CubicBezierCurve3 } from './extras/curves/CubicBezierCurve3.js';
+export { QuadraticBezierCurve3 } from './extras/curves/QuadraticBezierCurve3.js';
+export { LineCurve3 } from './extras/curves/LineCurve3.js';
+export { ArcCurve } from './extras/curves/ArcCurve.js';
+export { EllipseCurve } from './extras/curves/EllipseCurve.js';
+export { SplineCurve } from './extras/curves/SplineCurve.js';
+export { CubicBezierCurve } from './extras/curves/CubicBezierCurve.js';
+export { QuadraticBezierCurve } from './extras/curves/QuadraticBezierCurve.js';
+export { LineCurve } from './extras/curves/LineCurve.js';
+export { Shape } from './extras/core/Shape.js';
+export { ShapePath, Path } from './extras/core/Path.js';
+export { Font } from './extras/core/Font.js';
+export { CurvePath } from './extras/core/CurvePath.js';
+export { Curve } from './extras/core/Curve.js';
+export { ShapeUtils } from './extras/ShapeUtils.js';
+export { SceneUtils } from './extras/SceneUtils.js';
+export { CurveUtils } from './extras/CurveUtils.js';
+export * from './constants.js';

+ 21 - 15
src/animation/AnimationAction.js

@@ -1,3 +1,5 @@
+import { WrapAroundEnding, ZeroCurvatureEnding, ZeroSlopeEnding, LoopPingPong, LoopOnce, LoopRepeat } from '../constants';
+
 /**
 /**
  *
  *
  * Action provided by AnimationMixer for scheduling clip playback on specific
  * Action provided by AnimationMixer for scheduling clip playback on specific
@@ -9,14 +11,15 @@
  *
  *
  */
  */
 
 
-THREE.AnimationAction = function() {
+function AnimationAction() {
+	this.isAnimationAction = true;
 
 
 	throw new Error( "THREE.AnimationAction: " +
 	throw new Error( "THREE.AnimationAction: " +
 			"Use mixer.clipAction for construction." );
 			"Use mixer.clipAction for construction." );
 
 
 };
 };
 
 
-THREE.AnimationAction._new =
+AnimationAction._new =
 		function AnimationAction( mixer, clip, localRoot ) {
 		function AnimationAction( mixer, clip, localRoot ) {
 
 
 	this._mixer = mixer;
 	this._mixer = mixer;
@@ -28,8 +31,8 @@ THREE.AnimationAction._new =
 		interpolants = new Array( nTracks );
 		interpolants = new Array( nTracks );
 
 
 	var interpolantSettings = {
 	var interpolantSettings = {
-			endingStart: 	THREE.ZeroCurvatureEnding,
-			endingEnd:		THREE.ZeroCurvatureEnding
+			endingStart: 	ZeroCurvatureEnding,
+			endingEnd:		ZeroCurvatureEnding
 	};
 	};
 
 
 	for ( var i = 0; i !== nTracks; ++ i ) {
 	for ( var i = 0; i !== nTracks; ++ i ) {
@@ -53,7 +56,7 @@ THREE.AnimationAction._new =
 	this._timeScaleInterpolant = null;
 	this._timeScaleInterpolant = null;
 	this._weightInterpolant = null;
 	this._weightInterpolant = null;
 
 
-	this.loop = THREE.LoopRepeat;
+	this.loop = LoopRepeat;
 	this._loopCount = -1;
 	this._loopCount = -1;
 
 
 	// global mixer time when the action is to be started
 	// global mixer time when the action is to be started
@@ -82,9 +85,9 @@ THREE.AnimationAction._new =
 
 
 };
 };
 
 
-THREE.AnimationAction._new.prototype = {
+AnimationAction._new.prototype = {
 
 
-	constructor: THREE.AnimationAction._new,
+	constructor: AnimationAction._new,
 
 
 	// State & Scheduling
 	// State & Scheduling
 
 
@@ -478,7 +481,7 @@ THREE.AnimationAction._new.prototype = {
 			loop = this.loop,
 			loop = this.loop,
 			loopCount = this._loopCount;
 			loopCount = this._loopCount;
 
 
-		if ( loop === THREE.LoopOnce ) {
+		if ( loop === LoopOnce ) {
 
 
 			if ( loopCount === -1 ) {
 			if ( loopCount === -1 ) {
 				// just started
 				// just started
@@ -512,7 +515,7 @@ THREE.AnimationAction._new.prototype = {
 
 
 		} else { // repetitive Repeat or PingPong
 		} else { // repetitive Repeat or PingPong
 
 
-			var pingPong = ( loop === THREE.LoopPingPong );
+			var pingPong = ( loop === LoopPingPong );
 
 
 			if ( loopCount === -1 ) {
 			if ( loopCount === -1 ) {
 				// just started
 				// just started
@@ -606,8 +609,8 @@ THREE.AnimationAction._new.prototype = {
 
 
 		if ( pingPong ) {
 		if ( pingPong ) {
 
 
-			settings.endingStart 	= THREE.ZeroSlopeEnding;
-			settings.endingEnd		= THREE.ZeroSlopeEnding;
+			settings.endingStart 	= ZeroSlopeEnding;
+			settings.endingEnd		= ZeroSlopeEnding;
 
 
 		} else {
 		} else {
 
 
@@ -616,22 +619,22 @@ THREE.AnimationAction._new.prototype = {
 			if ( atStart ) {
 			if ( atStart ) {
 
 
 				settings.endingStart = this.zeroSlopeAtStart ?
 				settings.endingStart = this.zeroSlopeAtStart ?
-						THREE.ZeroSlopeEnding : THREE.ZeroCurvatureEnding;
+						ZeroSlopeEnding : ZeroCurvatureEnding;
 
 
 			} else {
 			} else {
 
 
-				settings.endingStart = THREE.WrapAroundEnding;
+				settings.endingStart = WrapAroundEnding;
 
 
 			}
 			}
 
 
 			if ( atEnd ) {
 			if ( atEnd ) {
 
 
 				settings.endingEnd = this.zeroSlopeAtEnd ?
 				settings.endingEnd = this.zeroSlopeAtEnd ?
-						THREE.ZeroSlopeEnding : THREE.ZeroCurvatureEnding;
+						ZeroSlopeEnding : ZeroCurvatureEnding;
 
 
 			} else {
 			} else {
 
 
-				settings.endingEnd 	 = THREE.WrapAroundEnding;
+				settings.endingEnd 	 = WrapAroundEnding;
 
 
 			}
 			}
 
 
@@ -663,3 +666,6 @@ THREE.AnimationAction._new.prototype = {
 
 
 };
 };
 
 
+
+
+export { AnimationAction };

+ 31 - 20
src/animation/AnimationClip.js

@@ -1,3 +1,10 @@
+import { VectorKeyframeTrack } from './tracks/VectorKeyframeTrack';
+import { QuaternionKeyframeTrack } from './tracks/QuaternionKeyframeTrack';
+import { NumberKeyframeTrack } from './tracks/NumberKeyframeTrack';
+import { AnimationUtils } from './AnimationUtils';
+import { KeyframeTrack } from './KeyframeTrack';
+import { _Math } from '../math/Math';
+
 /**
 /**
  *
  *
  * Reusable set of Tracks that represent an animation.
  * Reusable set of Tracks that represent an animation.
@@ -6,13 +13,14 @@
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
 
 
-THREE.AnimationClip = function ( name, duration, tracks ) {
+function AnimationClip ( name, duration, tracks ) {
+	this.isAnimationClip = true;
 
 
 	this.name = name;
 	this.name = name;
 	this.tracks = tracks;
 	this.tracks = tracks;
 	this.duration = ( duration !== undefined ) ? duration : -1;
 	this.duration = ( duration !== undefined ) ? duration : -1;
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	// this means it should figure out its duration by scanning the tracks
 	// this means it should figure out its duration by scanning the tracks
 	if ( this.duration < 0 ) {
 	if ( this.duration < 0 ) {
@@ -28,9 +36,9 @@ THREE.AnimationClip = function ( name, duration, tracks ) {
 
 
 };
 };
 
 
-THREE.AnimationClip.prototype = {
+AnimationClip.prototype = {
 
 
-	constructor: THREE.AnimationClip,
+	constructor: AnimationClip,
 
 
 	resetDuration: function() {
 	resetDuration: function() {
 
 
@@ -78,7 +86,7 @@ THREE.AnimationClip.prototype = {
 
 
 // Static methods:
 // Static methods:
 
 
-Object.assign( THREE.AnimationClip, {
+Object.assign( AnimationClip, {
 
 
 	parse: function( json ) {
 	parse: function( json ) {
 
 
@@ -88,11 +96,11 @@ Object.assign( THREE.AnimationClip, {
 
 
 		for ( var i = 0, n = jsonTracks.length; i !== n; ++ i ) {
 		for ( var i = 0, n = jsonTracks.length; i !== n; ++ i ) {
 
 
-			tracks.push( THREE.KeyframeTrack.parse( jsonTracks[ i ] ).scale( frameTime ) );
+			tracks.push( KeyframeTrack.parse( jsonTracks[ i ] ).scale( frameTime ) );
 
 
 		}
 		}
 
 
-		return new THREE.AnimationClip( json.name, json.duration, tracks );
+		return new AnimationClip( json.name, json.duration, tracks );
 
 
 	},
 	},
 
 
@@ -112,7 +120,7 @@ Object.assign( THREE.AnimationClip, {
 
 
 		for ( var i = 0, n = clipTracks.length; i !== n; ++ i ) {
 		for ( var i = 0, n = clipTracks.length; i !== n; ++ i ) {
 
 
-			tracks.push( THREE.KeyframeTrack.toJSON( clipTracks[ i ] ) );
+			tracks.push( KeyframeTrack.toJSON( clipTracks[ i ] ) );
 
 
 		}
 		}
 
 
@@ -138,9 +146,9 @@ Object.assign( THREE.AnimationClip, {
 
 
 			values.push( 0, 1, 0 );
 			values.push( 0, 1, 0 );
 
 
-			var order = THREE.AnimationUtils.getKeyframeOrder( times );
-			times = THREE.AnimationUtils.sortedArray( times, 1, order );
-			values = THREE.AnimationUtils.sortedArray( values, 1, order );
+			var order = AnimationUtils.getKeyframeOrder( times );
+			times = AnimationUtils.sortedArray( times, 1, order );
+			values = AnimationUtils.sortedArray( values, 1, order );
 
 
 			// if there is a key at the first frame, duplicate it as the
 			// if there is a key at the first frame, duplicate it as the
 			// last frame as well for perfect loop.
 			// last frame as well for perfect loop.
@@ -152,13 +160,13 @@ Object.assign( THREE.AnimationClip, {
 			}
 			}
 
 
 			tracks.push(
 			tracks.push(
-					new THREE.NumberKeyframeTrack(
+					new NumberKeyframeTrack(
 						'.morphTargetInfluences[' + morphTargetSequence[ i ].name + ']',
 						'.morphTargetInfluences[' + morphTargetSequence[ i ].name + ']',
 						times, values
 						times, values
 					).scale( 1.0 / fps ) );
 					).scale( 1.0 / fps ) );
 		}
 		}
 
 
-		return new THREE.AnimationClip( name, -1, tracks );
+		return new AnimationClip( name, -1, tracks );
 
 
 	},
 	},
 
 
@@ -222,7 +230,7 @@ Object.assign( THREE.AnimationClip, {
 
 
 		for ( var name in animationToMorphTargets ) {
 		for ( var name in animationToMorphTargets ) {
 
 
-			clips.push( THREE.AnimationClip.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps, noLoop ) );
+			clips.push( AnimationClip.CreateFromMorphTargetSequence( name, animationToMorphTargets[ name ], fps, noLoop ) );
 
 
 		}
 		}
 
 
@@ -249,7 +257,7 @@ Object.assign( THREE.AnimationClip, {
 				var times = [];
 				var times = [];
 				var values = [];
 				var values = [];
 
 
-				THREE.AnimationUtils.flattenJSON(
+				AnimationUtils.flattenJSON(
 						animationKeys, times, values, propertyName );
 						animationKeys, times, values, propertyName );
 
 
 				// empty keys are filtered out, so check again
 				// empty keys are filtered out, so check again
@@ -316,7 +324,7 @@ Object.assign( THREE.AnimationClip, {
 
 
 					}
 					}
 
 
-					tracks.push( new THREE.NumberKeyframeTrack(
+					tracks.push( new NumberKeyframeTrack(
 							'.morphTargetInfluence[' + morphTargetName + ']', times, values ) );
 							'.morphTargetInfluence[' + morphTargetName + ']', times, values ) );
 
 
 				}
 				}
@@ -329,15 +337,15 @@ Object.assign( THREE.AnimationClip, {
 				var boneName = '.bones[' + bones[ h ].name + ']';
 				var boneName = '.bones[' + bones[ h ].name + ']';
 
 
 				addNonemptyTrack(
 				addNonemptyTrack(
-						THREE.VectorKeyframeTrack, boneName + '.position',
+						VectorKeyframeTrack, boneName + '.position',
 						animationKeys, 'pos', tracks );
 						animationKeys, 'pos', tracks );
 
 
 				addNonemptyTrack(
 				addNonemptyTrack(
-						THREE.QuaternionKeyframeTrack, boneName + '.quaternion',
+						QuaternionKeyframeTrack, boneName + '.quaternion',
 						animationKeys, 'rot', tracks );
 						animationKeys, 'rot', tracks );
 
 
 				addNonemptyTrack(
 				addNonemptyTrack(
-						THREE.VectorKeyframeTrack, boneName + '.scale',
+						VectorKeyframeTrack, boneName + '.scale',
 						animationKeys, 'scl', tracks );
 						animationKeys, 'scl', tracks );
 
 
 			}
 			}
@@ -350,10 +358,13 @@ Object.assign( THREE.AnimationClip, {
 
 
 		}
 		}
 
 
-		var clip = new THREE.AnimationClip( clipName, duration, tracks );
+		var clip = new AnimationClip( clipName, duration, tracks );
 
 
 		return clip;
 		return clip;
 
 
 	}
 	}
 
 
 } );
 } );
+
+
+export { AnimationClip };

+ 21 - 11
src/animation/AnimationMixer.js

@@ -1,3 +1,10 @@
+import { AnimationAction } from './AnimationAction';
+import { EventDispatcher } from '../core/EventDispatcher';
+import { LinearInterpolant } from '../math/interpolants/LinearInterpolant';
+import { PropertyBinding } from './PropertyBinding';
+import { PropertyMixer } from './PropertyMixer';
+import { AnimationClip } from './AnimationClip';
+
 /**
 /**
  *
  *
  * Player for AnimationClips.
  * Player for AnimationClips.
@@ -8,7 +15,8 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.AnimationMixer = function( root ) {
+function AnimationMixer( root ) {
+	this.isAnimationMixer = true;
 
 
 	this._root = root;
 	this._root = root;
 	this._initMemoryManager();
 	this._initMemoryManager();
@@ -20,7 +28,7 @@ THREE.AnimationMixer = function( root ) {
 
 
 };
 };
 
 
-Object.assign( THREE.AnimationMixer.prototype, THREE.EventDispatcher.prototype, {
+Object.assign( AnimationMixer.prototype, EventDispatcher.prototype, {
 
 
 	// return an action for a clip optionally using a custom root target
 	// return an action for a clip optionally using a custom root target
 	// object (this method allocates a lot of dynamic memory in case a
 	// object (this method allocates a lot of dynamic memory in case a
@@ -31,7 +39,7 @@ Object.assign( THREE.AnimationMixer.prototype, THREE.EventDispatcher.prototype,
 			rootUuid = root.uuid,
 			rootUuid = root.uuid,
 
 
 			clipObject = typeof clip === 'string' ?
 			clipObject = typeof clip === 'string' ?
-					THREE.AnimationClip.findByName( root, clip ) : clip,
+					AnimationClip.findByName( root, clip ) : clip,
 
 
 			clipUuid = clipObject !== null ? clipObject.uuid : clip,
 			clipUuid = clipObject !== null ? clipObject.uuid : clip,
 
 
@@ -63,8 +71,7 @@ Object.assign( THREE.AnimationMixer.prototype, THREE.EventDispatcher.prototype,
 		if ( clipObject === null ) return null;
 		if ( clipObject === null ) return null;
 
 
 		// allocate all resources required to run it
 		// allocate all resources required to run it
-		var newAction = new THREE.
-				AnimationMixer._Action( this, clipObject, optionalRoot );
+		var newAction = new AnimationMixer._Action( this, clipObject, optionalRoot );
 
 
 		this._bindAction( newAction, prototypeAction );
 		this._bindAction( newAction, prototypeAction );
 
 
@@ -82,7 +89,7 @@ Object.assign( THREE.AnimationMixer.prototype, THREE.EventDispatcher.prototype,
 			rootUuid = root.uuid,
 			rootUuid = root.uuid,
 
 
 			clipObject = typeof clip === 'string' ?
 			clipObject = typeof clip === 'string' ?
-					THREE.AnimationClip.findByName( root, clip ) : clip,
+					AnimationClip.findByName( root, clip ) : clip,
 
 
 			clipUuid = clipObject ? clipObject.uuid : clip,
 			clipUuid = clipObject ? clipObject.uuid : clip,
 
 
@@ -269,11 +276,11 @@ Object.assign( THREE.AnimationMixer.prototype, THREE.EventDispatcher.prototype,
 
 
 } );
 } );
 
 
-THREE.AnimationMixer._Action = THREE.AnimationAction._new;
+AnimationMixer._Action = AnimationAction._new;
 
 
 // Implementation details:
 // Implementation details:
 
 
-Object.assign( THREE.AnimationMixer.prototype, {
+Object.assign( AnimationMixer.prototype, {
 
 
 	_bindAction: function( action, prototypeAction ) {
 	_bindAction: function( action, prototypeAction ) {
 
 
@@ -325,8 +332,8 @@ Object.assign( THREE.AnimationMixer.prototype, {
 				var path = prototypeAction && prototypeAction.
 				var path = prototypeAction && prototypeAction.
 						_propertyBindings[ i ].binding.parsedPath;
 						_propertyBindings[ i ].binding.parsedPath;
 
 
-				binding = new THREE.PropertyMixer(
-						THREE.PropertyBinding.create( root, trackName, path ),
+				binding = new PropertyMixer(
+						PropertyBinding.create( root, trackName, path ),
 						track.ValueTypeName, track.getValueSize() );
 						track.ValueTypeName, track.getValueSize() );
 
 
 				++ binding.referenceCount;
 				++ binding.referenceCount;
@@ -703,7 +710,7 @@ Object.assign( THREE.AnimationMixer.prototype, {
 
 
 		if ( interpolant === undefined ) {
 		if ( interpolant === undefined ) {
 
 
-			interpolant = new THREE.LinearInterpolant(
+			interpolant = new LinearInterpolant(
 					new Float32Array( 2 ), new Float32Array( 2 ),
 					new Float32Array( 2 ), new Float32Array( 2 ),
 						1, this._controlInterpolantsResultBuffer );
 						1, this._controlInterpolantsResultBuffer );
 
 
@@ -736,3 +743,6 @@ Object.assign( THREE.AnimationMixer.prototype, {
 	_controlInterpolantsResultBuffer: new Float32Array( 1 )
 	_controlInterpolantsResultBuffer: new Float32Array( 1 )
 
 
 } );
 } );
+
+
+export { AnimationMixer };

+ 14 - 7
src/animation/AnimationObjectGroup.js

@@ -1,3 +1,6 @@
+import { PropertyBinding } from './PropertyBinding';
+import { _Math } from '../math/Math';
+
 /**
 /**
  *
  *
  * A group of objects that receives a shared animation state.
  * A group of objects that receives a shared animation state.
@@ -29,9 +32,10 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.AnimationObjectGroup = function( var_args ) {
+function AnimationObjectGroup( var_args ) {
+	this.isAnimationObjectGroup = true;
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	// cached objects followed by the active ones
 	// cached objects followed by the active ones
 	this._objects = Array.prototype.slice.call( arguments );
 	this._objects = Array.prototype.slice.call( arguments );
@@ -68,9 +72,9 @@ THREE.AnimationObjectGroup = function( var_args ) {
 
 
 };
 };
 
 
-THREE.AnimationObjectGroup.prototype = {
+AnimationObjectGroup.prototype = {
 
 
-	constructor: THREE.AnimationObjectGroup,
+	constructor: AnimationObjectGroup,
 
 
 	add: function( var_args ) {
 	add: function( var_args ) {
 
 
@@ -102,7 +106,7 @@ THREE.AnimationObjectGroup.prototype = {
 				for ( var j = 0, m = nBindings; j !== m; ++ j ) {
 				for ( var j = 0, m = nBindings; j !== m; ++ j ) {
 
 
 					bindings[ j ].push(
 					bindings[ j ].push(
-							new THREE.PropertyBinding(
+							new PropertyBinding(
 								object, paths[ j ], parsedPaths[ j ] ) );
 								object, paths[ j ], parsedPaths[ j ] ) );
 
 
 				}
 				}
@@ -138,7 +142,7 @@ THREE.AnimationObjectGroup.prototype = {
 						// for objects that are cached, the binding may
 						// for objects that are cached, the binding may
 						// or may not exist
 						// or may not exist
 
 
-						binding = new THREE.PropertyBinding(
+						binding = new PropertyBinding(
 								object, paths[ j ], parsedPaths[ j ] );
 								object, paths[ j ], parsedPaths[ j ] );
 
 
 					}
 					}
@@ -327,7 +331,7 @@ THREE.AnimationObjectGroup.prototype = {
 			var object = objects[ i ];
 			var object = objects[ i ];
 
 
 			bindingsForPath[ i ] =
 			bindingsForPath[ i ] =
-					new THREE.PropertyBinding( object, path, parsedPath );
+					new PropertyBinding( object, path, parsedPath );
 
 
 		}
 		}
 
 
@@ -368,3 +372,6 @@ THREE.AnimationObjectGroup.prototype = {
 
 
 };
 };
 
 
+
+
+export { AnimationObjectGroup };

+ 7 - 2
src/animation/AnimationUtils.js

@@ -1,15 +1,17 @@
+var AnimationUtils;
+
 /**
 /**
  * @author tschw
  * @author tschw
  * @author Ben Houston / http://clara.io/
  * @author Ben Houston / http://clara.io/
  * @author David Sarno / http://lighthaus.us/
  * @author David Sarno / http://lighthaus.us/
  */
  */
 
 
-THREE.AnimationUtils = {
+AnimationUtils = {
 
 
 	// same as Array.prototype.slice, but also works on typed arrays
 	// same as Array.prototype.slice, but also works on typed arrays
 	arraySlice: function( array, from, to ) {
 	arraySlice: function( array, from, to ) {
 
 
-		if ( THREE.AnimationUtils.isTypedArray( array ) ) {
+		if ( AnimationUtils.isTypedArray( array ) ) {
 
 
 			return new array.constructor( array.subarray( from, to ) );
 			return new array.constructor( array.subarray( from, to ) );
 
 
@@ -157,3 +159,6 @@ THREE.AnimationUtils = {
 	}
 	}
 
 
 };
 };
+
+
+export { AnimationUtils };

+ 28 - 367
src/animation/KeyframeTrack.js

@@ -1,3 +1,13 @@
+import { KeyframeTrackPrototype } from './KeyframeTrackPrototype';
+import { StringKeyframeTrack } from './tracks/StringKeyframeTrack';
+import { BooleanKeyframeTrack } from './tracks/BooleanKeyframeTrack';
+import { QuaternionKeyframeTrack } from './tracks/QuaternionKeyframeTrack';
+import { ColorKeyframeTrack } from './tracks/ColorKeyframeTrack';
+import { VectorKeyframeTrack } from './tracks/VectorKeyframeTrack';
+import { NumberKeyframeTrack } from './tracks/NumberKeyframeTrack';
+import { AnimationUtils } from './AnimationUtils';
+import { KeyframeTrackConstructor } from './KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A timed sequence of keyframes for a specific property.
  * A timed sequence of keyframes for a specific property.
@@ -8,368 +18,16 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.KeyframeTrack = function ( name, times, values, interpolation ) {
-
-	if( name === undefined ) throw new Error( "track name is undefined" );
-
-	if( times === undefined || times.length === 0 ) {
-
-		throw new Error( "no keyframes in track named " + name );
-
-	}
-
-	this.name = name;
-
-	this.times = THREE.AnimationUtils.convertArray( times, this.TimeBufferType );
-	this.values = THREE.AnimationUtils.convertArray( values, this.ValueBufferType );
-
-	this.setInterpolation( interpolation || this.DefaultInterpolation );
-
-	this.validate();
-	this.optimize();
-
+function KeyframeTrack ( name, times, values, interpolation ) {
+	KeyframeTrackConstructor.apply( this, arguments );
 };
 };
 
 
-THREE.KeyframeTrack.prototype = {
-
-	constructor: THREE.KeyframeTrack,
-
-	TimeBufferType: Float32Array,
-	ValueBufferType: Float32Array,
-
-	DefaultInterpolation: THREE.InterpolateLinear,
-
-	InterpolantFactoryMethodDiscrete: function( result ) {
-
-		return new THREE.DiscreteInterpolant(
-				this.times, this.values, this.getValueSize(), result );
-
-	},
-
-	InterpolantFactoryMethodLinear: function( result ) {
-
-		return new THREE.LinearInterpolant(
-				this.times, this.values, this.getValueSize(), result );
-
-	},
-
-	InterpolantFactoryMethodSmooth: function( result ) {
-
-		return new THREE.CubicInterpolant(
-				this.times, this.values, this.getValueSize(), result );
-
-	},
-
-	setInterpolation: function( interpolation ) {
-
-		var factoryMethod;
-
-		switch ( interpolation ) {
-
-			case THREE.InterpolateDiscrete:
-
-				factoryMethod = this.InterpolantFactoryMethodDiscrete;
-
-				break;
-
-			case THREE.InterpolateLinear:
-
-				factoryMethod = this.InterpolantFactoryMethodLinear;
-
-				break;
-
-			case THREE.InterpolateSmooth:
-
-				factoryMethod = this.InterpolantFactoryMethodSmooth;
-
-				break;
-
-		}
-
-		if ( factoryMethod === undefined ) {
-
-			var message = "unsupported interpolation for " +
-					this.ValueTypeName + " keyframe track named " + this.name;
-
-			if ( this.createInterpolant === undefined ) {
-
-				// fall back to default, unless the default itself is messed up
-				if ( interpolation !== this.DefaultInterpolation ) {
-
-					this.setInterpolation( this.DefaultInterpolation );
-
-				} else {
-
-					throw new Error( message ); // fatal, in this case
-
-				}
-
-			}
-
-			console.warn( message );
-			return;
-
-		}
-
-		this.createInterpolant = factoryMethod;
-
-	},
-
-	getInterpolation: function() {
-
-		switch ( this.createInterpolant ) {
-
-			case this.InterpolantFactoryMethodDiscrete:
-
-				return THREE.InterpolateDiscrete;
-
-			case this.InterpolantFactoryMethodLinear:
-
-				return THREE.InterpolateLinear;
-
-			case this.InterpolantFactoryMethodSmooth:
-
-				return THREE.InterpolateSmooth;
-
-		}
-
-	},
-
-	getValueSize: function() {
-
-		return this.values.length / this.times.length;
-
-	},
-
-	// move all keyframes either forwards or backwards in time
-	shift: function( timeOffset ) {
-
-		if( timeOffset !== 0.0 ) {
-
-			var times = this.times;
-
-			for( var i = 0, n = times.length; i !== n; ++ i ) {
-
-				times[ i ] += timeOffset;
-
-			}
-
-		}
-
-		return this;
-
-	},
-
-	// scale all keyframe times by a factor (useful for frame <-> seconds conversions)
-	scale: function( timeScale ) {
-
-		if( timeScale !== 1.0 ) {
-
-			var times = this.times;
-
-			for( var i = 0, n = times.length; i !== n; ++ i ) {
-
-				times[ i ] *= timeScale;
-
-			}
-
-		}
-
-		return this;
-
-	},
-
-	// removes keyframes before and after animation without changing any values within the range [startTime, endTime].
-	// IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values
-	trim: function( startTime, endTime ) {
-
-		var times = this.times,
-			nKeys = times.length,
-			from = 0,
-			to = nKeys - 1;
-
-		while ( from !== nKeys && times[ from ] < startTime ) ++ from;
-		while ( to !== -1 && times[ to ] > endTime ) -- to;
-
-		++ to; // inclusive -> exclusive bound
-
-		if( from !== 0 || to !== nKeys ) {
-
-			// empty tracks are forbidden, so keep at least one keyframe
-			if ( from >= to ) to = Math.max( to , 1 ), from = to - 1;
-
-			var stride = this.getValueSize();
-			this.times = THREE.AnimationUtils.arraySlice( times, from, to );
-			this.values = THREE.AnimationUtils.
-					arraySlice( this.values, from * stride, to * stride );
-
-		}
-
-		return this;
-
-	},
-
-	// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
-	validate: function() {
-
-		var valid = true;
-
-		var valueSize = this.getValueSize();
-		if ( valueSize - Math.floor( valueSize ) !== 0 ) {
-
-			console.error( "invalid value size in track", this );
-			valid = false;
-
-		}
-
-		var times = this.times,
-			values = this.values,
-
-			nKeys = times.length;
-
-		if( nKeys === 0 ) {
-
-			console.error( "track is empty", this );
-			valid = false;
-
-		}
-
-		var prevTime = null;
-
-		for( var i = 0; i !== nKeys; i ++ ) {
-
-			var currTime = times[ i ];
-
-			if ( typeof currTime === 'number' && isNaN( currTime ) ) {
-
-				console.error( "time is not a valid number", this, i, currTime );
-				valid = false;
-				break;
-
-			}
-
-			if( prevTime !== null && prevTime > currTime ) {
-
-				console.error( "out of order keys", this, i, currTime, prevTime );
-				valid = false;
-				break;
-
-			}
-
-			prevTime = currTime;
-
-		}
-
-		if ( values !== undefined ) {
-
-			if ( THREE.AnimationUtils.isTypedArray( values ) ) {
-
-				for ( var i = 0, n = values.length; i !== n; ++ i ) {
-
-					var value = values[ i ];
-
-					if ( isNaN( value ) ) {
-
-						console.error( "value is not a valid number", this, i, value );
-						valid = false;
-						break;
-
-					}
-
-				}
-
-			}
-
-		}
-
-		return valid;
-
-	},
-
-	// removes equivalent sequential keys as common in morph target sequences
-	// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
-	optimize: function() {
-
-		var times = this.times,
-			values = this.values,
-			stride = this.getValueSize(),
-
-			writeIndex = 1;
-
-		for( var i = 1, n = times.length - 1; i <= n; ++ i ) {
-
-			var keep = false;
-
-			var time = times[ i ];
-			var timeNext = times[ i + 1 ];
-
-			// remove adjacent keyframes scheduled at the same time
-
-			if ( time !== timeNext && ( i !== 1 || time !== time[ 0 ] ) ) {
-
-				// remove unnecessary keyframes same as their neighbors
-				var offset = i * stride,
-					offsetP = offset - stride,
-					offsetN = offset + stride;
-
-				for ( var j = 0; j !== stride; ++ j ) {
-
-					var value = values[ offset + j ];
-
-					if ( value !== values[ offsetP + j ] ||
-							value !== values[ offsetN + j ] ) {
-
-						keep = true;
-						break;
-
-					}
-
-				}
-
-			}
-
-			// in-place compaction
-
-			if ( keep ) {
-
-				if ( i !== writeIndex ) {
-
-					times[ writeIndex ] = times[ i ];
-
-					var readOffset = i * stride,
-						writeOffset = writeIndex * stride;
-
-					for ( var j = 0; j !== stride; ++ j ) {
-
-						values[ writeOffset + j ] = values[ readOffset + j ];
-
-					}
-
-
-				}
-
-				++ writeIndex;
-
-			}
-
-		}
-
-		if ( writeIndex !== times.length ) {
-
-			this.times = THREE.AnimationUtils.arraySlice( times, 0, writeIndex );
-			this.values = THREE.AnimationUtils.arraySlice( values, 0, writeIndex * stride );
-
-		}
-
-		return this;
-
-	}
-
-};
+KeyframeTrack.prototype = KeyframeTrackPrototype;
+KeyframeTrackPrototype.constructor = KeyframeTrack;
 
 
 // Static methods:
 // Static methods:
 
 
-Object.assign( THREE.KeyframeTrack, {
+Object.assign( KeyframeTrack, {
 
 
 	// Serialization (in static context, because of constructor invocation
 	// Serialization (in static context, because of constructor invocation
 	// and automatic invocation of .toJSON):
 	// and automatic invocation of .toJSON):
@@ -382,13 +40,13 @@ Object.assign( THREE.KeyframeTrack, {
 
 
 		}
 		}
 
 
-		var trackType = THREE.KeyframeTrack._getTrackTypeForValueTypeName( json.type );
+		var trackType = KeyframeTrack._getTrackTypeForValueTypeName( json.type );
 
 
 		if ( json.times === undefined ) {
 		if ( json.times === undefined ) {
 
 
 			var times = [], values = [];
 			var times = [], values = [];
 
 
-			THREE.AnimationUtils.flattenJSON( json.keys, times, values, 'value' );
+			AnimationUtils.flattenJSON( json.keys, times, values, 'value' );
 
 
 			json.times = times;
 			json.times = times;
 			json.values = values;
 			json.values = values;
@@ -427,8 +85,8 @@ Object.assign( THREE.KeyframeTrack, {
 			json = {
 			json = {
 
 
 				'name': track.name,
 				'name': track.name,
-				'times': THREE.AnimationUtils.convertArray( track.times, Array ),
-				'values': THREE.AnimationUtils.convertArray( track.values, Array )
+				'times': AnimationUtils.convertArray( track.times, Array ),
+				'values': AnimationUtils.convertArray( track.values, Array )
 
 
 			};
 			};
 
 
@@ -458,31 +116,31 @@ Object.assign( THREE.KeyframeTrack, {
 			case "number":
 			case "number":
 			case "integer":
 			case "integer":
 
 
-				return THREE.NumberKeyframeTrack;
+				return NumberKeyframeTrack;
 
 
 			case "vector":
 			case "vector":
 			case "vector2":
 			case "vector2":
 			case "vector3":
 			case "vector3":
 			case "vector4":
 			case "vector4":
 
 
-				return THREE.VectorKeyframeTrack;
+				return VectorKeyframeTrack;
 
 
 			case "color":
 			case "color":
 
 
-				return THREE.ColorKeyframeTrack;
+				return ColorKeyframeTrack;
 
 
 			case "quaternion":
 			case "quaternion":
 
 
-				return THREE.QuaternionKeyframeTrack;
+				return QuaternionKeyframeTrack;
 
 
 			case "bool":
 			case "bool":
 			case "boolean":
 			case "boolean":
 
 
-				return THREE.BooleanKeyframeTrack;
+				return BooleanKeyframeTrack;
 
 
 			case "string":
 			case "string":
 
 
-				return THREE.StringKeyframeTrack;
+				return StringKeyframeTrack;
 
 
 		}
 		}
 
 
@@ -491,3 +149,6 @@ Object.assign( THREE.KeyframeTrack, {
 	}
 	}
 
 
 } );
 } );
+
+
+export { KeyframeTrack };

+ 26 - 0
src/animation/KeyframeTrackConstructor.js

@@ -0,0 +1,26 @@
+import { AnimationUtils } from './AnimationUtils';
+
+function KeyframeTrackConstructor ( name, times, values, interpolation ) {
+	this.isKeyframeTrack = true;
+
+	if( name === undefined ) throw new Error( "track name is undefined" );
+
+	if( times === undefined || times.length === 0 ) {
+
+		throw new Error( "no keyframes in track named " + name );
+
+	}
+
+	this.name = name;
+
+	this.times = AnimationUtils.convertArray( times, this.TimeBufferType );
+	this.values = AnimationUtils.convertArray( values, this.ValueBufferType );
+
+	this.setInterpolation( interpolation || this.DefaultInterpolation );
+
+	this.validate();
+	this.optimize();
+
+}
+
+export { KeyframeTrackConstructor };

+ 345 - 0
src/animation/KeyframeTrackPrototype.js

@@ -0,0 +1,345 @@
+import { InterpolateLinear } from '../constants';
+import { AnimationUtils } from './AnimationUtils';
+import { InterpolateSmooth, InterpolateDiscrete } from '../constants';
+import { CubicInterpolant } from '../math/interpolants/CubicInterpolant';
+import { LinearInterpolant } from '../math/interpolants/LinearInterpolant';
+import { DiscreteInterpolant } from '../math/interpolants/DiscreteInterpolant';
+
+var KeyframeTrackPrototype;
+
+KeyframeTrackPrototype = {
+
+	TimeBufferType: Float32Array,
+	ValueBufferType: Float32Array,
+
+	DefaultInterpolation: InterpolateLinear,
+
+	InterpolantFactoryMethodDiscrete: function( result ) {
+
+		return new DiscreteInterpolant(
+				this.times, this.values, this.getValueSize(), result );
+
+	},
+
+	InterpolantFactoryMethodLinear: function( result ) {
+
+		return new LinearInterpolant(
+				this.times, this.values, this.getValueSize(), result );
+
+	},
+
+	InterpolantFactoryMethodSmooth: function( result ) {
+
+		return new CubicInterpolant(
+				this.times, this.values, this.getValueSize(), result );
+
+	},
+
+	setInterpolation: function( interpolation ) {
+
+		var factoryMethod;
+
+		switch ( interpolation ) {
+
+			case InterpolateDiscrete:
+
+				factoryMethod = this.InterpolantFactoryMethodDiscrete;
+
+				break;
+
+			case InterpolateLinear:
+
+				factoryMethod = this.InterpolantFactoryMethodLinear;
+
+				break;
+
+			case InterpolateSmooth:
+
+				factoryMethod = this.InterpolantFactoryMethodSmooth;
+
+				break;
+
+		}
+
+		if ( factoryMethod === undefined ) {
+
+			var message = "unsupported interpolation for " +
+					this.ValueTypeName + " keyframe track named " + this.name;
+
+			if ( this.createInterpolant === undefined ) {
+
+				// fall back to default, unless the default itself is messed up
+				if ( interpolation !== this.DefaultInterpolation ) {
+
+					this.setInterpolation( this.DefaultInterpolation );
+
+				} else {
+
+					throw new Error( message ); // fatal, in this case
+
+				}
+
+			}
+
+			console.warn( message );
+			return;
+
+		}
+
+		this.createInterpolant = factoryMethod;
+
+	},
+
+	getInterpolation: function() {
+
+		switch ( this.createInterpolant ) {
+
+			case this.InterpolantFactoryMethodDiscrete:
+
+				return InterpolateDiscrete;
+
+			case this.InterpolantFactoryMethodLinear:
+
+				return InterpolateLinear;
+
+			case this.InterpolantFactoryMethodSmooth:
+
+				return InterpolateSmooth;
+
+		}
+
+	},
+
+	getValueSize: function() {
+
+		return this.values.length / this.times.length;
+
+	},
+
+	// move all keyframes either forwards or backwards in time
+	shift: function( timeOffset ) {
+
+		if( timeOffset !== 0.0 ) {
+
+			var times = this.times;
+
+			for( var i = 0, n = times.length; i !== n; ++ i ) {
+
+				times[ i ] += timeOffset;
+
+			}
+
+		}
+
+		return this;
+
+	},
+
+	// scale all keyframe times by a factor (useful for frame <-> seconds conversions)
+	scale: function( timeScale ) {
+
+		if( timeScale !== 1.0 ) {
+
+			var times = this.times;
+
+			for( var i = 0, n = times.length; i !== n; ++ i ) {
+
+				times[ i ] *= timeScale;
+
+			}
+
+		}
+
+		return this;
+
+	},
+
+	// removes keyframes before and after animation without changing any values within the range [startTime, endTime].
+	// IMPORTANT: We do not shift around keys to the start of the track time, because for interpolated keys this will change their values
+	trim: function( startTime, endTime ) {
+
+		var times = this.times,
+			nKeys = times.length,
+			from = 0,
+			to = nKeys - 1;
+
+		while ( from !== nKeys && times[ from ] < startTime ) ++ from;
+		while ( to !== -1 && times[ to ] > endTime ) -- to;
+
+		++ to; // inclusive -> exclusive bound
+
+		if( from !== 0 || to !== nKeys ) {
+
+			// empty tracks are forbidden, so keep at least one keyframe
+			if ( from >= to ) to = Math.max( to , 1 ), from = to - 1;
+
+			var stride = this.getValueSize();
+			this.times = AnimationUtils.arraySlice( times, from, to );
+			this.values = AnimationUtils.
+					arraySlice( this.values, from * stride, to * stride );
+
+		}
+
+		return this;
+
+	},
+
+	// ensure we do not get a GarbageInGarbageOut situation, make sure tracks are at least minimally viable
+	validate: function() {
+
+		var valid = true;
+
+		var valueSize = this.getValueSize();
+		if ( valueSize - Math.floor( valueSize ) !== 0 ) {
+
+			console.error( "invalid value size in track", this );
+			valid = false;
+
+		}
+
+		var times = this.times,
+			values = this.values,
+
+			nKeys = times.length;
+
+		if( nKeys === 0 ) {
+
+			console.error( "track is empty", this );
+			valid = false;
+
+		}
+
+		var prevTime = null;
+
+		for( var i = 0; i !== nKeys; i ++ ) {
+
+			var currTime = times[ i ];
+
+			if ( typeof currTime === 'number' && isNaN( currTime ) ) {
+
+				console.error( "time is not a valid number", this, i, currTime );
+				valid = false;
+				break;
+
+			}
+
+			if( prevTime !== null && prevTime > currTime ) {
+
+				console.error( "out of order keys", this, i, currTime, prevTime );
+				valid = false;
+				break;
+
+			}
+
+			prevTime = currTime;
+
+		}
+
+		if ( values !== undefined ) {
+
+			if ( AnimationUtils.isTypedArray( values ) ) {
+
+				for ( var i = 0, n = values.length; i !== n; ++ i ) {
+
+					var value = values[ i ];
+
+					if ( isNaN( value ) ) {
+
+						console.error( "value is not a valid number", this, i, value );
+						valid = false;
+						break;
+
+					}
+
+				}
+
+			}
+
+		}
+
+		return valid;
+
+	},
+
+	// removes equivalent sequential keys as common in morph target sequences
+	// (0,0,0,0,1,1,1,0,0,0,0,0,0,0) --> (0,0,1,1,0,0)
+	optimize: function() {
+
+		var times = this.times,
+			values = this.values,
+			stride = this.getValueSize(),
+
+			writeIndex = 1;
+
+		for( var i = 1, n = times.length - 1; i <= n; ++ i ) {
+
+			var keep = false;
+
+			var time = times[ i ];
+			var timeNext = times[ i + 1 ];
+
+			// remove adjacent keyframes scheduled at the same time
+
+			if ( time !== timeNext && ( i !== 1 || time !== time[ 0 ] ) ) {
+
+				// remove unnecessary keyframes same as their neighbors
+				var offset = i * stride,
+					offsetP = offset - stride,
+					offsetN = offset + stride;
+
+				for ( var j = 0; j !== stride; ++ j ) {
+
+					var value = values[ offset + j ];
+
+					if ( value !== values[ offsetP + j ] ||
+							value !== values[ offsetN + j ] ) {
+
+						keep = true;
+						break;
+
+					}
+
+				}
+
+			}
+
+			// in-place compaction
+
+			if ( keep ) {
+
+				if ( i !== writeIndex ) {
+
+					times[ writeIndex ] = times[ i ];
+
+					var readOffset = i * stride,
+						writeOffset = writeIndex * stride;
+
+					for ( var j = 0; j !== stride; ++ j ) {
+
+						values[ writeOffset + j ] = values[ readOffset + j ];
+
+					}
+
+
+				}
+
+				++ writeIndex;
+
+			}
+
+		}
+
+		if ( writeIndex !== times.length ) {
+
+			this.times = AnimationUtils.arraySlice( times, 0, writeIndex );
+			this.values = AnimationUtils.arraySlice( values, 0, writeIndex * stride );
+
+		}
+
+		return this;
+
+	}
+
+}
+
+export { KeyframeTrackPrototype };

+ 23 - 19
src/animation/PropertyBinding.js

@@ -8,22 +8,23 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.PropertyBinding = function ( rootNode, path, parsedPath ) {
+function PropertyBinding ( rootNode, path, parsedPath ) {
+	this.isPropertyBinding = true;
 
 
 	this.path = path;
 	this.path = path;
 	this.parsedPath = parsedPath ||
 	this.parsedPath = parsedPath ||
-			THREE.PropertyBinding.parseTrackName( path );
+			PropertyBinding.parseTrackName( path );
 
 
-	this.node = THREE.PropertyBinding.findNode(
+	this.node = PropertyBinding.findNode(
 			rootNode, this.parsedPath.nodeName ) || rootNode;
 			rootNode, this.parsedPath.nodeName ) || rootNode;
 
 
 	this.rootNode = rootNode;
 	this.rootNode = rootNode;
 
 
 };
 };
 
 
-THREE.PropertyBinding.prototype = {
+PropertyBinding.prototype = {
 
 
-	constructor: THREE.PropertyBinding,
+	constructor: PropertyBinding,
 
 
 	getValue: function getValue_unbound( targetArray, offset ) {
 	getValue: function getValue_unbound( targetArray, offset ) {
 
 
@@ -57,7 +58,7 @@ THREE.PropertyBinding.prototype = {
 
 
 		if ( ! targetObject ) {
 		if ( ! targetObject ) {
 
 
-			targetObject = THREE.PropertyBinding.findNode(
+			targetObject = PropertyBinding.findNode(
 					this.rootNode, parsedPath.nodeName ) || this.rootNode;
 					this.rootNode, parsedPath.nodeName ) || this.rootNode;
 
 
 			this.node = targetObject;
 			this.node = targetObject;
@@ -268,15 +269,15 @@ THREE.PropertyBinding.prototype = {
 
 
 };
 };
 
 
-Object.assign( THREE.PropertyBinding.prototype, { // prototype, continued
+Object.assign( PropertyBinding.prototype, { // prototype, continued
 
 
 	// these are used to "bind" a nonexistent property
 	// these are used to "bind" a nonexistent property
 	_getValue_unavailable: function() {},
 	_getValue_unavailable: function() {},
 	_setValue_unavailable: function() {},
 	_setValue_unavailable: function() {},
 
 
 	// initial state of these methods that calls 'bind'
 	// initial state of these methods that calls 'bind'
-	_getValue_unbound: THREE.PropertyBinding.prototype.getValue,
-	_setValue_unbound: THREE.PropertyBinding.prototype.setValue,
+	_getValue_unbound: PropertyBinding.prototype.getValue,
+	_setValue_unbound: PropertyBinding.prototype.setValue,
 
 
 	BindingType: {
 	BindingType: {
 		Direct: 0,
 		Direct: 0,
@@ -448,20 +449,20 @@ Object.assign( THREE.PropertyBinding.prototype, { // prototype, continued
 
 
 } );
 } );
 
 
-THREE.PropertyBinding.Composite =
+PropertyBinding.Composite =
 		function( targetGroup, path, optionalParsedPath ) {
 		function( targetGroup, path, optionalParsedPath ) {
 
 
 	var parsedPath = optionalParsedPath ||
 	var parsedPath = optionalParsedPath ||
-			THREE.PropertyBinding.parseTrackName( path );
+			PropertyBinding.parseTrackName( path );
 
 
 	this._targetGroup = targetGroup;
 	this._targetGroup = targetGroup;
 	this._bindings = targetGroup.subscribe_( path, parsedPath );
 	this._bindings = targetGroup.subscribe_( path, parsedPath );
 
 
 };
 };
 
 
-THREE.PropertyBinding.Composite.prototype = {
+PropertyBinding.Composite.prototype = {
 
 
-	constructor: THREE.PropertyBinding.Composite,
+	constructor: PropertyBinding.Composite,
 
 
 	getValue: function( array, offset ) {
 	getValue: function( array, offset ) {
 
 
@@ -516,21 +517,21 @@ THREE.PropertyBinding.Composite.prototype = {
 
 
 };
 };
 
 
-THREE.PropertyBinding.create = function( root, path, parsedPath ) {
+PropertyBinding.create = function( root, path, parsedPath ) {
 
 
-	if ( ! ( root instanceof THREE.AnimationObjectGroup ) ) {
+	if ( ! ( (root && root.isAnimationObjectGroup) ) ) {
 
 
-		return new THREE.PropertyBinding( root, path, parsedPath );
+		return new PropertyBinding( root, path, parsedPath );
 
 
 	} else {
 	} else {
 
 
-		return new THREE.PropertyBinding.Composite( root, path, parsedPath );
+		return new PropertyBinding.Composite( root, path, parsedPath );
 
 
 	}
 	}
 
 
 };
 };
 
 
-THREE.PropertyBinding.parseTrackName = function( trackName ) {
+PropertyBinding.parseTrackName = function( trackName ) {
 
 
 	// matches strings in the form of:
 	// matches strings in the form of:
 	//    nodeName.property
 	//    nodeName.property
@@ -577,7 +578,7 @@ THREE.PropertyBinding.parseTrackName = function( trackName ) {
 
 
 };
 };
 
 
-THREE.PropertyBinding.findNode = function( root, nodeName ) {
+PropertyBinding.findNode = function( root, nodeName ) {
 
 
 	if ( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
 	if ( ! nodeName || nodeName === "" || nodeName === "root" || nodeName === "." || nodeName === -1 || nodeName === root.name || nodeName === root.uuid ) {
 
 
@@ -652,3 +653,6 @@ THREE.PropertyBinding.findNode = function( root, nodeName ) {
 	return null;
 	return null;
 
 
 };
 };
+
+
+export { PropertyBinding };

+ 10 - 4
src/animation/PropertyMixer.js

@@ -1,3 +1,5 @@
+import { Quaternion } from '../math/Quaternion';
+
 /**
 /**
  *
  *
  * Buffered scene graph property that allows weighted accumulation.
  * Buffered scene graph property that allows weighted accumulation.
@@ -8,7 +10,8 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.PropertyMixer = function ( binding, typeName, valueSize ) {
+function PropertyMixer ( binding, typeName, valueSize ) {
+	this.isPropertyMixer = true;
 
 
 	this.binding = binding;
 	this.binding = binding;
 	this.valueSize = valueSize;
 	this.valueSize = valueSize;
@@ -50,9 +53,9 @@ THREE.PropertyMixer = function ( binding, typeName, valueSize ) {
 
 
 };
 };
 
 
-THREE.PropertyMixer.prototype = {
+PropertyMixer.prototype = {
 
 
-	constructor: THREE.PropertyMixer,
+	constructor: PropertyMixer,
 
 
 	// accumulate data in the 'incoming' region into 'accu<i>'
 	// accumulate data in the 'incoming' region into 'accu<i>'
 	accumulate: function( accuIndex, weight ) {
 	accumulate: function( accuIndex, weight ) {
@@ -181,7 +184,7 @@ THREE.PropertyMixer.prototype = {
 
 
 	_slerp: function( buffer, dstOffset, srcOffset, t, stride ) {
 	_slerp: function( buffer, dstOffset, srcOffset, t, stride ) {
 
 
-		THREE.Quaternion.slerpFlat( buffer, dstOffset,
+		Quaternion.slerpFlat( buffer, dstOffset,
 				buffer, dstOffset, buffer, srcOffset, t );
 				buffer, dstOffset, buffer, srcOffset, t );
 
 
 	},
 	},
@@ -201,3 +204,6 @@ THREE.PropertyMixer.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { PropertyMixer };

+ 14 - 6
src/animation/tracks/BooleanKeyframeTrack.js

@@ -1,3 +1,7 @@
+import { InterpolateDiscrete } from '../../constants';
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track of Boolean keyframe values.
  * A Track of Boolean keyframe values.
@@ -8,21 +12,22 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.BooleanKeyframeTrack = function ( name, times, values ) {
+function BooleanKeyframeTrack ( name, times, values ) {
+	this.isBooleanKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values );
+	KeyframeTrackConstructor.call( this, name, times, values );
 
 
 };
 };
 
 
-THREE.BooleanKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+BooleanKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.BooleanKeyframeTrack,
+	constructor: BooleanKeyframeTrack,
 
 
 	ValueTypeName: 'bool',
 	ValueTypeName: 'bool',
 	ValueBufferType: Array,
 	ValueBufferType: Array,
 
 
-	DefaultInterpolation: THREE.InterpolateDiscrete,
+	DefaultInterpolation: InterpolateDiscrete,
 
 
 	InterpolantFactoryMethodLinear: undefined,
 	InterpolantFactoryMethodLinear: undefined,
 	InterpolantFactoryMethodSmooth: undefined
 	InterpolantFactoryMethodSmooth: undefined
@@ -32,3 +37,6 @@ THREE.BooleanKeyframeTrack.prototype =
 	// computes "firstValue ^ isOdd( index )".
 	// computes "firstValue ^ isOdd( index )".
 
 
 } );
 } );
+
+
+export { BooleanKeyframeTrack };

+ 12 - 5
src/animation/tracks/ColorKeyframeTrack.js

@@ -1,3 +1,6 @@
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track of keyframe values that represent color.
  * A Track of keyframe values that represent color.
@@ -8,16 +11,17 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.ColorKeyframeTrack = function ( name, times, values, interpolation ) {
+function ColorKeyframeTrack ( name, times, values, interpolation ) {
+	this.isColorKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values, interpolation );
+	KeyframeTrackConstructor.call( this, name, times, values, interpolation );
 
 
 };
 };
 
 
-THREE.ColorKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+ColorKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.ColorKeyframeTrack,
+	constructor: ColorKeyframeTrack,
 
 
 	ValueTypeName: 'color'
 	ValueTypeName: 'color'
 
 
@@ -30,3 +34,6 @@ THREE.ColorKeyframeTrack.prototype =
 	// However, this is the place for color space parameterization.
 	// However, this is the place for color space parameterization.
 
 
 } );
 } );
+
+
+export { ColorKeyframeTrack };

+ 12 - 5
src/animation/tracks/NumberKeyframeTrack.js

@@ -1,3 +1,6 @@
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track of numeric keyframe values.
  * A Track of numeric keyframe values.
@@ -7,16 +10,17 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.NumberKeyframeTrack = function ( name, times, values, interpolation ) {
+function NumberKeyframeTrack ( name, times, values, interpolation ) {
+	this.isNumberKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values, interpolation );
+	KeyframeTrackConstructor.call( this, name, times, values, interpolation );
 
 
 };
 };
 
 
-THREE.NumberKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+NumberKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.NumberKeyframeTrack,
+	constructor: NumberKeyframeTrack,
 
 
 	ValueTypeName: 'number',
 	ValueTypeName: 'number',
 
 
@@ -25,3 +29,6 @@ THREE.NumberKeyframeTrack.prototype =
 	// DefaultInterpolation is inherited
 	// DefaultInterpolation is inherited
 
 
 } );
 } );
+
+
+export { NumberKeyframeTrack };

+ 16 - 7
src/animation/tracks/QuaternionKeyframeTrack.js

@@ -1,3 +1,8 @@
+import { InterpolateLinear } from '../../constants';
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { QuaternionLinearInterpolant } from '../../math/interpolants/QuaternionLinearInterpolant';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track of quaternion keyframe values.
  * A Track of quaternion keyframe values.
@@ -7,26 +12,27 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.QuaternionKeyframeTrack = function ( name, times, values, interpolation ) {
+function QuaternionKeyframeTrack ( name, times, values, interpolation ) {
+	this.isQuaternionKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values, interpolation );
+	KeyframeTrackConstructor.call( this, name, times, values, interpolation );
 
 
 };
 };
 
 
-THREE.QuaternionKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+QuaternionKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.QuaternionKeyframeTrack,
+	constructor: QuaternionKeyframeTrack,
 
 
 	ValueTypeName: 'quaternion',
 	ValueTypeName: 'quaternion',
 
 
 	// ValueBufferType is inherited
 	// ValueBufferType is inherited
 
 
-	DefaultInterpolation: THREE.InterpolateLinear,
+	DefaultInterpolation: InterpolateLinear,
 
 
 	InterpolantFactoryMethodLinear: function( result ) {
 	InterpolantFactoryMethodLinear: function( result ) {
 
 
-		return new THREE.QuaternionLinearInterpolant(
+		return new QuaternionLinearInterpolant(
 				this.times, this.values, this.getValueSize(), result );
 				this.times, this.values, this.getValueSize(), result );
 
 
 	},
 	},
@@ -34,3 +40,6 @@ THREE.QuaternionKeyframeTrack.prototype =
 	InterpolantFactoryMethodSmooth: undefined // not yet implemented
 	InterpolantFactoryMethodSmooth: undefined // not yet implemented
 
 
 } );
 } );
+
+
+export { QuaternionKeyframeTrack };

+ 14 - 6
src/animation/tracks/StringKeyframeTrack.js

@@ -1,3 +1,7 @@
+import { InterpolateDiscrete } from '../../constants';
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track that interpolates Strings
  * A Track that interpolates Strings
@@ -8,24 +12,28 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.StringKeyframeTrack = function ( name, times, values, interpolation ) {
+function StringKeyframeTrack ( name, times, values, interpolation ) {
+	this.isStringKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values, interpolation );
+	KeyframeTrackConstructor.call( this, name, times, values, interpolation );
 
 
 };
 };
 
 
-THREE.StringKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+StringKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.StringKeyframeTrack,
+	constructor: StringKeyframeTrack,
 
 
 	ValueTypeName: 'string',
 	ValueTypeName: 'string',
 	ValueBufferType: Array,
 	ValueBufferType: Array,
 
 
-	DefaultInterpolation: THREE.InterpolateDiscrete,
+	DefaultInterpolation: InterpolateDiscrete,
 
 
 	InterpolantFactoryMethodLinear: undefined,
 	InterpolantFactoryMethodLinear: undefined,
 
 
 	InterpolantFactoryMethodSmooth: undefined
 	InterpolantFactoryMethodSmooth: undefined
 
 
 } );
 } );
+
+
+export { StringKeyframeTrack };

+ 12 - 5
src/animation/tracks/VectorKeyframeTrack.js

@@ -1,3 +1,6 @@
+import { KeyframeTrackPrototype } from '../KeyframeTrackPrototype';
+import { KeyframeTrackConstructor } from '../KeyframeTrackConstructor';
+
 /**
 /**
  *
  *
  * A Track of vectored keyframe values.
  * A Track of vectored keyframe values.
@@ -8,16 +11,17 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.VectorKeyframeTrack = function ( name, times, values, interpolation ) {
+function VectorKeyframeTrack ( name, times, values, interpolation ) {
+	this.isVectorKeyframeTrack = true;
 
 
-	THREE.KeyframeTrack.call( this, name, times, values, interpolation );
+	KeyframeTrackConstructor.call( this, name, times, values, interpolation );
 
 
 };
 };
 
 
-THREE.VectorKeyframeTrack.prototype =
-		Object.assign( Object.create( THREE.KeyframeTrack.prototype ), {
+VectorKeyframeTrack.prototype =
+		Object.assign( Object.create( KeyframeTrackPrototype ), {
 
 
-	constructor: THREE.VectorKeyframeTrack,
+	constructor: VectorKeyframeTrack,
 
 
 	ValueTypeName: 'vector'
 	ValueTypeName: 'vector'
 
 
@@ -26,3 +30,6 @@ THREE.VectorKeyframeTrack.prototype =
 	// DefaultInterpolation is inherited
 	// DefaultInterpolation is inherited
 
 
 } );
 } );
+
+
+export { VectorKeyframeTrack };

+ 10 - 4
src/audio/Audio.js

@@ -1,11 +1,14 @@
+import { Object3D } from '../core/Object3D';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author Reece Aaron Lecrivain / http://reecenotes.com/
  * @author Reece Aaron Lecrivain / http://reecenotes.com/
  */
  */
 
 
-THREE.Audio = function ( listener ) {
+function Audio ( listener ) {
+	this.isAudio = true;
 
 
-	THREE.Object3D.call( this );
+	Object3D.call( this );
 
 
 	this.type = 'Audio';
 	this.type = 'Audio';
 
 
@@ -28,9 +31,9 @@ THREE.Audio = function ( listener ) {
 
 
 };
 };
 
 
-THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
+Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 
-	constructor: THREE.Audio,
+	constructor: Audio,
 
 
 	getOutput: function () {
 	getOutput: function () {
 
 
@@ -287,3 +290,6 @@ THREE.Audio.prototype = Object.assign( Object.create( THREE.Object3D.prototype )
 	}
 	}
 
 
 } );
 } );
+
+
+export { Audio };

+ 6 - 2
src/audio/AudioAnalyser.js

@@ -2,7 +2,8 @@
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.AudioAnalyser = function ( audio, fftSize ) {
+function AudioAnalyser ( audio, fftSize ) {
+	this.isAudioAnalyser = true;
 
 
 	this.analyser = audio.context.createAnalyser();
 	this.analyser = audio.context.createAnalyser();
 	this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
 	this.analyser.fftSize = fftSize !== undefined ? fftSize : 2048;
@@ -13,7 +14,7 @@ THREE.AudioAnalyser = function ( audio, fftSize ) {
 
 
 };
 };
 
 
-Object.assign( THREE.AudioAnalyser.prototype, {
+Object.assign( AudioAnalyser.prototype, {
 
 
 	getFrequencyData: function () {
 	getFrequencyData: function () {
 
 
@@ -38,3 +39,6 @@ Object.assign( THREE.AudioAnalyser.prototype, {
 	}
 	}
 
 
 } );
 } );
+
+
+export { AudioAnalyser };

+ 7 - 23
src/audio/AudioContext.js

@@ -1,25 +1,9 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- */
+var context;
 
 
-Object.defineProperty( THREE, 'AudioContext', {
+export function getAudioContext () {
+	if ( context === undefined ) {
+		context = new ( window.AudioContext || window.webkitAudioContext )();
+	}
 
 
-	get: ( function () {
-
-		var context;
-
-		return function get() {
-
-			if ( context === undefined ) {
-
-				context = new ( window.AudioContext || window.webkitAudioContext )();
-
-			}
-
-			return context;
-
-		};
-
-	} )()
-
-} );
+	return context;
+}

+ 19 - 10
src/audio/AudioListener.js

@@ -1,14 +1,20 @@
+import { Vector3 } from '../math/Vector3';
+import { Quaternion } from '../math/Quaternion';
+import { Object3D } from '../core/Object3D';
+import { getAudioContext } from './AudioContext';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.AudioListener = function () {
+function AudioListener () {
+	this.isAudioListener = true;
 
 
-	THREE.Object3D.call( this );
+	Object3D.call( this );
 
 
 	this.type = 'AudioListener';
 	this.type = 'AudioListener';
 
 
-	this.context = THREE.AudioContext;
+	this.context = getAudioContext();
 
 
 	this.gain = this.context.createGain();
 	this.gain = this.context.createGain();
 	this.gain.connect( this.context.destination );
 	this.gain.connect( this.context.destination );
@@ -17,9 +23,9 @@ THREE.AudioListener = function () {
 
 
 };
 };
 
 
-THREE.AudioListener.prototype = Object.assign( Object.create( THREE.Object3D.prototype ), {
+AudioListener.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 
-	constructor: THREE.AudioListener,
+	constructor: AudioListener,
 
 
 	getInput: function () {
 	getInput: function () {
 
 
@@ -79,15 +85,15 @@ THREE.AudioListener.prototype = Object.assign( Object.create( THREE.Object3D.pro
 
 
 	updateMatrixWorld: ( function () {
 	updateMatrixWorld: ( function () {
 
 
-		var position = new THREE.Vector3();
-		var quaternion = new THREE.Quaternion();
-		var scale = new THREE.Vector3();
+		var position = new Vector3();
+		var quaternion = new Quaternion();
+		var scale = new Vector3();
 
 
-		var orientation = new THREE.Vector3();
+		var orientation = new Vector3();
 
 
 		return function updateMatrixWorld( force ) {
 		return function updateMatrixWorld( force ) {
 
 
-			THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
+			Object3D.prototype.updateMatrixWorld.call( this, force );
 
 
 			var listener = this.context.listener;
 			var listener = this.context.listener;
 			var up = this.up;
 			var up = this.up;
@@ -104,3 +110,6 @@ THREE.AudioListener.prototype = Object.assign( Object.create( THREE.Object3D.pro
 	} )()
 	} )()
 
 
 } );
 } );
+
+
+export { AudioListener };

+ 14 - 6
src/audio/PositionalAudio.js

@@ -1,19 +1,24 @@
+import { Vector3 } from '../math/Vector3';
+import { Audio } from './Audio';
+import { Object3D } from '../core/Object3D';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.PositionalAudio = function ( listener ) {
+function PositionalAudio ( listener ) {
+	this.isPositionalAudio = true;
 
 
-	THREE.Audio.call( this, listener );
+	Audio.call( this, listener );
 
 
 	this.panner = this.context.createPanner();
 	this.panner = this.context.createPanner();
 	this.panner.connect( this.gain );
 	this.panner.connect( this.gain );
 
 
 };
 };
 
 
-THREE.PositionalAudio.prototype = Object.assign( Object.create( THREE.Audio.prototype ), {
+PositionalAudio.prototype = Object.assign( Object.create( Audio.prototype ), {
 
 
-	constructor: THREE.PositionalAudio,
+	constructor: PositionalAudio,
 
 
 	getOutput: function () {
 	getOutput: function () {
 
 
@@ -71,11 +76,11 @@ THREE.PositionalAudio.prototype = Object.assign( Object.create( THREE.Audio.prot
 
 
 	updateMatrixWorld: ( function () {
 	updateMatrixWorld: ( function () {
 
 
-		var position = new THREE.Vector3();
+		var position = new Vector3();
 
 
 		return function updateMatrixWorld( force ) {
 		return function updateMatrixWorld( force ) {
 
 
-			THREE.Object3D.prototype.updateMatrixWorld.call( this, force );
+			Object3D.prototype.updateMatrixWorld.call( this, force );
 
 
 			position.setFromMatrixPosition( this.matrixWorld );
 			position.setFromMatrixPosition( this.matrixWorld );
 
 
@@ -87,3 +92,6 @@ THREE.PositionalAudio.prototype = Object.assign( Object.create( THREE.Audio.prot
 
 
 
 
 } );
 } );
+
+
+export { PositionalAudio };

+ 23 - 14
src/cameras/Camera.js

@@ -1,30 +1,36 @@
+import { Matrix4 } from '../math/Matrix4';
+import { Quaternion } from '../math/Quaternion';
+import { Object3D } from '../core/Object3D';
+import { Vector3 } from '../math/Vector3';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
  * @author WestLangley / http://github.com/WestLangley
  * @author WestLangley / http://github.com/WestLangley
 */
 */
 
 
-THREE.Camera = function () {
+function Camera () {
+	this.isCamera = this.isObject3D = true;
 
 
-	THREE.Object3D.call( this );
+	Object3D.call( this );
 
 
 	this.type = 'Camera';
 	this.type = 'Camera';
 
 
-	this.matrixWorldInverse = new THREE.Matrix4();
-	this.projectionMatrix = new THREE.Matrix4();
+	this.matrixWorldInverse = new Matrix4();
+	this.projectionMatrix = new Matrix4();
 
 
 };
 };
 
 
-THREE.Camera.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Camera.prototype.constructor = THREE.Camera;
+Camera.prototype = Object.create( Object3D.prototype );
+Camera.prototype.constructor = Camera;
 
 
-THREE.Camera.prototype.getWorldDirection = function () {
+Camera.prototype.getWorldDirection = function () {
 
 
-	var quaternion = new THREE.Quaternion();
+	var quaternion = new Quaternion();
 
 
 	return function getWorldDirection( optionalTarget ) {
 	return function getWorldDirection( optionalTarget ) {
 
 
-		var result = optionalTarget || new THREE.Vector3();
+		var result = optionalTarget || new Vector3();
 
 
 		this.getWorldQuaternion( quaternion );
 		this.getWorldQuaternion( quaternion );
 
 
@@ -34,11 +40,11 @@ THREE.Camera.prototype.getWorldDirection = function () {
 
 
 }();
 }();
 
 
-THREE.Camera.prototype.lookAt = function () {
+Camera.prototype.lookAt = function () {
 
 
 	// This routine does not support cameras with rotated and/or translated parent(s)
 	// This routine does not support cameras with rotated and/or translated parent(s)
 
 
-	var m1 = new THREE.Matrix4();
+	var m1 = new Matrix4();
 
 
 	return function lookAt( vector ) {
 	return function lookAt( vector ) {
 
 
@@ -50,15 +56,15 @@ THREE.Camera.prototype.lookAt = function () {
 
 
 }();
 }();
 
 
-THREE.Camera.prototype.clone = function () {
+Camera.prototype.clone = function () {
 
 
 	return new this.constructor().copy( this );
 	return new this.constructor().copy( this );
 
 
 };
 };
 
 
-THREE.Camera.prototype.copy = function ( source ) {
+Camera.prototype.copy = function ( source ) {
 
 
-	THREE.Object3D.prototype.copy.call( this, source );
+	Object3D.prototype.copy.call( this, source );
 
 
 	this.matrixWorldInverse.copy( source.matrixWorldInverse );
 	this.matrixWorldInverse.copy( source.matrixWorldInverse );
 	this.projectionMatrix.copy( source.projectionMatrix );
 	this.projectionMatrix.copy( source.projectionMatrix );
@@ -66,3 +72,6 @@ THREE.Camera.prototype.copy = function ( source ) {
 	return this;
 	return this;
 
 
 };
 };
+
+
+export { Camera };

+ 28 - 18
src/cameras/CubeCamera.js

@@ -1,3 +1,9 @@
+import { Object3D } from '../core/Object3D';
+import { WebGLRenderTargetCube } from '../renderers/WebGLRenderTargetCube';
+import { LinearFilter, RGBFormat } from '../constants';
+import { Vector3 } from '../math/Vector3';
+import { PerspectiveCamera } from './PerspectiveCamera';
+
 /**
 /**
  * Camera for rendering cube maps
  * Camera for rendering cube maps
  *	- renders scene into axis-aligned cube
  *	- renders scene into axis-aligned cube
@@ -5,47 +11,48 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.CubeCamera = function ( near, far, cubeResolution ) {
+function CubeCamera ( near, far, cubeResolution ) {
+	this.isCubeCamera = this.isObject3D = true;
 
 
-	THREE.Object3D.call( this );
+	Object3D.call( this );
 
 
 	this.type = 'CubeCamera';
 	this.type = 'CubeCamera';
 
 
 	var fov = 90, aspect = 1;
 	var fov = 90, aspect = 1;
 
 
-	var cameraPX = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraPX = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPX.up.set( 0, - 1, 0 );
 	cameraPX.up.set( 0, - 1, 0 );
-	cameraPX.lookAt( new THREE.Vector3( 1, 0, 0 ) );
+	cameraPX.lookAt( new Vector3( 1, 0, 0 ) );
 	this.add( cameraPX );
 	this.add( cameraPX );
 
 
-	var cameraNX = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraNX = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNX.up.set( 0, - 1, 0 );
 	cameraNX.up.set( 0, - 1, 0 );
-	cameraNX.lookAt( new THREE.Vector3( - 1, 0, 0 ) );
+	cameraNX.lookAt( new Vector3( - 1, 0, 0 ) );
 	this.add( cameraNX );
 	this.add( cameraNX );
 
 
-	var cameraPY = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraPY = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPY.up.set( 0, 0, 1 );
 	cameraPY.up.set( 0, 0, 1 );
-	cameraPY.lookAt( new THREE.Vector3( 0, 1, 0 ) );
+	cameraPY.lookAt( new Vector3( 0, 1, 0 ) );
 	this.add( cameraPY );
 	this.add( cameraPY );
 
 
-	var cameraNY = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraNY = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNY.up.set( 0, 0, - 1 );
 	cameraNY.up.set( 0, 0, - 1 );
-	cameraNY.lookAt( new THREE.Vector3( 0, - 1, 0 ) );
+	cameraNY.lookAt( new Vector3( 0, - 1, 0 ) );
 	this.add( cameraNY );
 	this.add( cameraNY );
 
 
-	var cameraPZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraPZ = new PerspectiveCamera( fov, aspect, near, far );
 	cameraPZ.up.set( 0, - 1, 0 );
 	cameraPZ.up.set( 0, - 1, 0 );
-	cameraPZ.lookAt( new THREE.Vector3( 0, 0, 1 ) );
+	cameraPZ.lookAt( new Vector3( 0, 0, 1 ) );
 	this.add( cameraPZ );
 	this.add( cameraPZ );
 
 
-	var cameraNZ = new THREE.PerspectiveCamera( fov, aspect, near, far );
+	var cameraNZ = new PerspectiveCamera( fov, aspect, near, far );
 	cameraNZ.up.set( 0, - 1, 0 );
 	cameraNZ.up.set( 0, - 1, 0 );
-	cameraNZ.lookAt( new THREE.Vector3( 0, 0, - 1 ) );
+	cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) );
 	this.add( cameraNZ );
 	this.add( cameraNZ );
 
 
-	var options = { format: THREE.RGBFormat, magFilter: THREE.LinearFilter, minFilter: THREE.LinearFilter };
+	var options = { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter };
 
 
-	this.renderTarget = new THREE.WebGLRenderTargetCube( cubeResolution, cubeResolution, options );
+	this.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options );
 
 
 	this.updateCubeMap = function ( renderer, scene ) {
 	this.updateCubeMap = function ( renderer, scene ) {
 
 
@@ -82,5 +89,8 @@ THREE.CubeCamera = function ( near, far, cubeResolution ) {
 
 
 };
 };
 
 
-THREE.CubeCamera.prototype = Object.create( THREE.Object3D.prototype );
-THREE.CubeCamera.prototype.constructor = THREE.CubeCamera;
+CubeCamera.prototype = Object.create( Object3D.prototype );
+CubeCamera.prototype.constructor = CubeCamera;
+
+
+export { CubeCamera };

+ 13 - 6
src/cameras/OrthographicCamera.js

@@ -1,11 +1,15 @@
+import { Camera } from './Camera';
+import { Object3D } from '../core/Object3D';
+
 /**
 /**
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  * @author arose / http://github.com/arose
  * @author arose / http://github.com/arose
  */
  */
 
 
-THREE.OrthographicCamera = function ( left, right, top, bottom, near, far ) {
+function OrthographicCamera ( left, right, top, bottom, near, far ) {
+	this.isOrthographicCamera = true;
 
 
-	THREE.Camera.call( this );
+	Camera.call( this );
 
 
 	this.type = 'OrthographicCamera';
 	this.type = 'OrthographicCamera';
 
 
@@ -24,13 +28,13 @@ THREE.OrthographicCamera = function ( left, right, top, bottom, near, far ) {
 
 
 };
 };
 
 
-THREE.OrthographicCamera.prototype = Object.assign( Object.create( THREE.Camera.prototype ), {
+OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {
 
 
-	constructor: THREE.OrthographicCamera,
+	constructor: OrthographicCamera,
 
 
 	copy: function ( source ) {
 	copy: function ( source ) {
 
 
-		THREE.Camera.prototype.copy.call( this, source );
+		Camera.prototype.copy.call( this, source );
 
 
 		this.left = source.left;
 		this.left = source.left;
 		this.right = source.right;
 		this.right = source.right;
@@ -100,7 +104,7 @@ THREE.OrthographicCamera.prototype = Object.assign( Object.create( THREE.Camera.
 
 
 	toJSON: function ( meta ) {
 	toJSON: function ( meta ) {
 
 
-		var data = THREE.Object3D.prototype.toJSON.call( this, meta );
+		var data = Object3D.prototype.toJSON.call( this, meta );
 
 
 		data.object.zoom = this.zoom;
 		data.object.zoom = this.zoom;
 		data.object.left = this.left;
 		data.object.left = this.left;
@@ -117,3 +121,6 @@ THREE.OrthographicCamera.prototype = Object.assign( Object.create( THREE.Camera.
 	}
 	}
 
 
 } );
 } );
+
+
+export { OrthographicCamera };

+ 19 - 11
src/cameras/PerspectiveCamera.js

@@ -1,3 +1,7 @@
+import { Camera } from './Camera';
+import { Object3D } from '../core/Object3D';
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author greggman / http://games.greggman.com/
  * @author greggman / http://games.greggman.com/
@@ -5,9 +9,10 @@
  * @author tschw
  * @author tschw
  */
  */
 
 
-THREE.PerspectiveCamera = function ( fov, aspect, near, far ) {
+function PerspectiveCamera ( fov, aspect, near, far ) {
+	this.isPerspectiveCamera = true;
 
 
-	THREE.Camera.call( this );
+	Camera.call( this );
 
 
 	this.type = 'PerspectiveCamera';
 	this.type = 'PerspectiveCamera';
 
 
@@ -28,13 +33,13 @@ THREE.PerspectiveCamera = function ( fov, aspect, near, far ) {
 
 
 };
 };
 
 
-THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.prototype ), {
+PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {
 
 
-	constructor: THREE.PerspectiveCamera,
+	constructor: PerspectiveCamera,
 
 
 	copy: function ( source ) {
 	copy: function ( source ) {
 
 
-		THREE.Camera.prototype.copy.call( this, source );
+		Camera.prototype.copy.call( this, source );
 
 
 		this.fov = source.fov;
 		this.fov = source.fov;
 		this.zoom = source.zoom;
 		this.zoom = source.zoom;
@@ -66,7 +71,7 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 		// see http://www.bobatkins.com/photography/technical/field_of_view.html
 		// see http://www.bobatkins.com/photography/technical/field_of_view.html
 		var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
 		var vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;
 
 
-		this.fov = THREE.Math.RAD2DEG * 2 * Math.atan( vExtentSlope );
+		this.fov = _Math.RAD2DEG * 2 * Math.atan( vExtentSlope );
 		this.updateProjectionMatrix();
 		this.updateProjectionMatrix();
 
 
 	},
 	},
@@ -76,7 +81,7 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 	 */
 	 */
 	getFocalLength: function () {
 	getFocalLength: function () {
 
 
-		var vExtentSlope = Math.tan( THREE.Math.DEG2RAD * 0.5 * this.fov );
+		var vExtentSlope = Math.tan( _Math.DEG2RAD * 0.5 * this.fov );
 
 
 		return 0.5 * this.getFilmHeight() / vExtentSlope;
 		return 0.5 * this.getFilmHeight() / vExtentSlope;
 
 
@@ -84,8 +89,8 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 
 
 	getEffectiveFOV: function () {
 	getEffectiveFOV: function () {
 
 
-		return THREE.Math.RAD2DEG * 2 * Math.atan(
-				Math.tan( THREE.Math.DEG2RAD * 0.5 * this.fov ) / this.zoom );
+		return _Math.RAD2DEG * 2 * Math.atan(
+				Math.tan( _Math.DEG2RAD * 0.5 * this.fov ) / this.zoom );
 
 
 	},
 	},
 
 
@@ -166,7 +171,7 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 
 
 		var near = this.near,
 		var near = this.near,
 			top = near * Math.tan(
 			top = near * Math.tan(
-					THREE.Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,
+					_Math.DEG2RAD * 0.5 * this.fov ) / this.zoom,
 			height = 2 * top,
 			height = 2 * top,
 			width = this.aspect * height,
 			width = this.aspect * height,
 			left = - 0.5 * width,
 			left = - 0.5 * width,
@@ -194,7 +199,7 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 
 
 	toJSON: function ( meta ) {
 	toJSON: function ( meta ) {
 
 
-		var data = THREE.Object3D.prototype.toJSON.call( this, meta );
+		var data = Object3D.prototype.toJSON.call( this, meta );
 
 
 		data.object.fov = this.fov;
 		data.object.fov = this.fov;
 		data.object.zoom = this.zoom;
 		data.object.zoom = this.zoom;
@@ -215,3 +220,6 @@ THREE.PerspectiveCamera.prototype = Object.assign( Object.create( THREE.Camera.p
 	}
 	}
 
 
 } );
 } );
+
+
+export { PerspectiveCamera };

+ 15 - 7
src/cameras/StereoCamera.js

@@ -1,31 +1,36 @@
+import { Matrix4 } from '../math/Matrix4';
+import { _Math } from '../math/Math';
+import { PerspectiveCamera } from './PerspectiveCamera';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.StereoCamera = function () {
+function StereoCamera () {
+	this.isStereoCamera = true;
 
 
 	this.type = 'StereoCamera';
 	this.type = 'StereoCamera';
 
 
 	this.aspect = 1;
 	this.aspect = 1;
 
 
-	this.cameraL = new THREE.PerspectiveCamera();
+	this.cameraL = new PerspectiveCamera();
 	this.cameraL.layers.enable( 1 );
 	this.cameraL.layers.enable( 1 );
 	this.cameraL.matrixAutoUpdate = false;
 	this.cameraL.matrixAutoUpdate = false;
 
 
-	this.cameraR = new THREE.PerspectiveCamera();
+	this.cameraR = new PerspectiveCamera();
 	this.cameraR.layers.enable( 2 );
 	this.cameraR.layers.enable( 2 );
 	this.cameraR.matrixAutoUpdate = false;
 	this.cameraR.matrixAutoUpdate = false;
 
 
 };
 };
 
 
-Object.assign( THREE.StereoCamera.prototype, {
+Object.assign( StereoCamera.prototype, {
 
 
 	update: ( function () {
 	update: ( function () {
 
 
 		var focus, fov, aspect, near, far;
 		var focus, fov, aspect, near, far;
 
 
-		var eyeRight = new THREE.Matrix4();
-		var eyeLeft = new THREE.Matrix4();
+		var eyeRight = new Matrix4();
+		var eyeLeft = new Matrix4();
 
 
 		return function update( camera ) {
 		return function update( camera ) {
 
 
@@ -47,7 +52,7 @@ Object.assign( THREE.StereoCamera.prototype, {
 				var projectionMatrix = camera.projectionMatrix.clone();
 				var projectionMatrix = camera.projectionMatrix.clone();
 				var eyeSep = 0.064 / 2;
 				var eyeSep = 0.064 / 2;
 				var eyeSepOnProjection = eyeSep * near / focus;
 				var eyeSepOnProjection = eyeSep * near / focus;
-				var ymax = near * Math.tan( THREE.Math.DEG2RAD * fov * 0.5 );
+				var ymax = near * Math.tan( _Math.DEG2RAD * fov * 0.5 );
 				var xmin, xmax;
 				var xmin, xmax;
 
 
 				// translate xOffset
 				// translate xOffset
@@ -85,3 +90,6 @@ Object.assign( THREE.StereoCamera.prototype, {
 	} )()
 	} )()
 
 
 } );
 } );
+
+
+export { StereoCamera };

+ 122 - 0
src/constants.js

@@ -0,0 +1,122 @@
+export var MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2 };
+export var CullFaceNone = 0;
+export var CullFaceBack = 1;
+export var CullFaceFront = 2;
+export var CullFaceFrontBack = 3;
+export var FrontFaceDirectionCW = 0;
+export var FrontFaceDirectionCCW = 1;
+export var BasicShadowMap = 0;
+export var PCFShadowMap = 1;
+export var PCFSoftShadowMap = 2;
+export var FrontSide = 0;
+export var BackSide = 1;
+export var DoubleSide = 2;
+export var FlatShading = 1;
+export var SmoothShading = 2;
+export var NoColors = 0;
+export var FaceColors = 1;
+export var VertexColors = 2;
+export var NoBlending = 0;
+export var NormalBlending = 1;
+export var AdditiveBlending = 2;
+export var SubtractiveBlending = 3;
+export var MultiplyBlending = 4;
+export var CustomBlending = 5;
+export var AddEquation = 100;
+export var SubtractEquation = 101;
+export var ReverseSubtractEquation = 102;
+export var MinEquation = 103;
+export var MaxEquation = 104;
+export var ZeroFactor = 200;
+export var OneFactor = 201;
+export var SrcColorFactor = 202;
+export var OneMinusSrcColorFactor = 203;
+export var SrcAlphaFactor = 204;
+export var OneMinusSrcAlphaFactor = 205;
+export var DstAlphaFactor = 206;
+export var OneMinusDstAlphaFactor = 207;
+export var DstColorFactor = 208;
+export var OneMinusDstColorFactor = 209;
+export var SrcAlphaSaturateFactor = 210;
+export var NeverDepth = 0;
+export var AlwaysDepth = 1;
+export var LessDepth = 2;
+export var LessEqualDepth = 3;
+export var EqualDepth = 4;
+export var GreaterEqualDepth = 5;
+export var GreaterDepth = 6;
+export var NotEqualDepth = 7;
+export var MultiplyOperation = 0;
+export var MixOperation = 1;
+export var AddOperation = 2;
+export var NoToneMapping = 0;
+export var LinearToneMapping = 1;
+export var ReinhardToneMapping = 2;
+export var Uncharted2ToneMapping = 3;
+export var CineonToneMapping = 4;
+export var UVMapping = 300;
+export var CubeReflectionMapping = 301;
+export var CubeRefractionMapping = 302;
+export var EquirectangularReflectionMapping = 303;
+export var EquirectangularRefractionMapping = 304;
+export var SphericalReflectionMapping = 305;
+export var CubeUVReflectionMapping = 306;
+export var CubeUVRefractionMapping = 307;
+export var RepeatWrapping = 1000;
+export var ClampToEdgeWrapping = 1001;
+export var MirroredRepeatWrapping = 1002;
+export var NearestFilter = 1003;
+export var NearestMipMapNearestFilter = 1004;
+export var NearestMipMapLinearFilter = 1005;
+export var LinearFilter = 1006;
+export var LinearMipMapNearestFilter = 1007;
+export var LinearMipMapLinearFilter = 1008;
+export var UnsignedByteType = 1009;
+export var ByteType = 1010;
+export var ShortType = 1011;
+export var UnsignedShortType = 1012;
+export var IntType = 1013;
+export var UnsignedIntType = 1014;
+export var FloatType = 1015;
+export var HalfFloatType = 1025;
+export var UnsignedShort4444Type = 1016;
+export var UnsignedShort5551Type = 1017;
+export var UnsignedShort565Type = 1018;
+export var AlphaFormat = 1019;
+export var RGBFormat = 1020;
+export var RGBAFormat = 1021;
+export var LuminanceFormat = 1022;
+export var LuminanceAlphaFormat = 1023;
+export var RGBEFormat = RGBAFormat;
+export var DepthFormat = 1026;
+export var RGB_S3TC_DXT1_Format = 2001;
+export var RGBA_S3TC_DXT1_Format = 2002;
+export var RGBA_S3TC_DXT3_Format = 2003;
+export var RGBA_S3TC_DXT5_Format = 2004;
+export var RGB_PVRTC_4BPPV1_Format = 2100;
+export var RGB_PVRTC_2BPPV1_Format = 2101;
+export var RGBA_PVRTC_4BPPV1_Format = 2102;
+export var RGBA_PVRTC_2BPPV1_Format = 2103;
+export var RGB_ETC1_Format = 2151;
+export var LoopOnce = 2200;
+export var LoopRepeat = 2201;
+export var LoopPingPong = 2202;
+export var InterpolateDiscrete = 2300;
+export var InterpolateLinear = 2301;
+export var InterpolateSmooth = 2302;
+export var ZeroCurvatureEnding = 2400;
+export var ZeroSlopeEnding = 2401;
+export var WrapAroundEnding = 2402;
+export var TrianglesDrawMode = 0;
+export var TriangleStripDrawMode = 1;
+export var TriangleFanDrawMode = 2;
+export var LinearEncoding = 3000;
+export var sRGBEncoding = 3001;
+export var GammaEncoding = 3007;
+export var RGBEEncoding = 3002;
+export var LogLuvEncoding = 3003;
+export var RGBM7Encoding = 3004;
+export var RGBM16Encoding = 3005;
+export var RGBDEncoding = 3006;
+export var BasicDepthPacking = 3200;
+export var RGBADepthPacking = 3201;

+ 60 - 28
src/core/BufferAttribute.js

@@ -1,10 +1,17 @@
+import { Vector4 } from '../math/Vector4';
+import { Vector3 } from '../math/Vector3';
+import { Vector2 } from '../math/Vector2';
+import { Color } from '../math/Color';
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.BufferAttribute = function ( array, itemSize, normalized ) {
+function BufferAttribute ( array, itemSize, normalized ) {
+	this.isBufferAttribute = true;
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.array = array;
 	this.array = array;
 	this.itemSize = itemSize;
 	this.itemSize = itemSize;
@@ -17,9 +24,9 @@ THREE.BufferAttribute = function ( array, itemSize, normalized ) {
 
 
 };
 };
 
 
-THREE.BufferAttribute.prototype = {
+BufferAttribute.prototype = {
 
 
-	constructor: THREE.BufferAttribute,
+	constructor: BufferAttribute,
 
 
 	get count() {
 	get count() {
 
 
@@ -86,7 +93,7 @@ THREE.BufferAttribute.prototype = {
 			if ( color === undefined ) {
 			if ( color === undefined ) {
 
 
 				console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );
 				console.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );
-				color = new THREE.Color();
+				color = new Color();
 
 
 			}
 			}
 
 
@@ -129,7 +136,7 @@ THREE.BufferAttribute.prototype = {
 			if ( vector === undefined ) {
 			if ( vector === undefined ) {
 
 
 				console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );
 				console.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );
-				vector = new THREE.Vector2();
+				vector = new Vector2();
 
 
 			}
 			}
 
 
@@ -153,7 +160,7 @@ THREE.BufferAttribute.prototype = {
 			if ( vector === undefined ) {
 			if ( vector === undefined ) {
 
 
 				console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );
 				console.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );
-				vector = new THREE.Vector3();
+				vector = new Vector3();
 
 
 			}
 			}
 
 
@@ -178,7 +185,7 @@ THREE.BufferAttribute.prototype = {
 			if ( vector === undefined ) {
 			if ( vector === undefined ) {
 
 
 				console.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );
 				console.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );
-				vector = new THREE.Vector4();
+				vector = new Vector4();
 
 
 			}
 			}
 
 
@@ -305,66 +312,91 @@ THREE.BufferAttribute.prototype = {
 
 
 //
 //
 
 
-THREE.Int8Attribute = function ( array, itemSize ) {
+function Int8Attribute ( array, itemSize ) {
+	this.isInt8Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Int8Array( array ), itemSize );
+	return new BufferAttribute( new Int8Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Uint8Attribute = function ( array, itemSize ) {
+function Uint8Attribute ( array, itemSize ) {
+	this.isUint8Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Uint8Array( array ), itemSize );
+	return new BufferAttribute( new Uint8Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Uint8ClampedAttribute = function ( array, itemSize ) {
+function Uint8ClampedAttribute ( array, itemSize ) {
+	this.isUint8ClampedAttribute = true;
 
 
-	return new THREE.BufferAttribute( new Uint8ClampedArray( array ), itemSize );
+	return new BufferAttribute( new Uint8ClampedArray( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Int16Attribute = function ( array, itemSize ) {
+function Int16Attribute ( array, itemSize ) {
+	this.isInt16Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Int16Array( array ), itemSize );
+	return new BufferAttribute( new Int16Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Uint16Attribute = function ( array, itemSize ) {
+function Uint16Attribute ( array, itemSize ) {
+	this.isUint16Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Uint16Array( array ), itemSize );
+	return new BufferAttribute( new Uint16Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Int32Attribute = function ( array, itemSize ) {
+function Int32Attribute ( array, itemSize ) {
+	this.isInt32Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Int32Array( array ), itemSize );
+	return new BufferAttribute( new Int32Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Uint32Attribute = function ( array, itemSize ) {
+function Uint32Attribute ( array, itemSize ) {
+	this.isUint32Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Uint32Array( array ), itemSize );
+	return new BufferAttribute( new Uint32Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Float32Attribute = function ( array, itemSize ) {
+function Float32Attribute ( array, itemSize ) {
+	this.isFloat32Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Float32Array( array ), itemSize );
+	return new BufferAttribute( new Float32Array( array ), itemSize );
 
 
 };
 };
 
 
-THREE.Float64Attribute = function ( array, itemSize ) {
+function Float64Attribute ( array, itemSize ) {
+	this.isFloat64Attribute = true;
 
 
-	return new THREE.BufferAttribute( new Float64Array( array ), itemSize );
+	return new BufferAttribute( new Float64Array( array ), itemSize );
 
 
 };
 };
 
 
 
 
 // Deprecated
 // Deprecated
 
 
-THREE.DynamicBufferAttribute = function ( array, itemSize ) {
+function DynamicBufferAttribute ( array, itemSize ) {
+	this.isDynamicBufferAttribute = true;
 
 
 	console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );
 	console.warn( 'THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.' );
-	return new THREE.BufferAttribute( array, itemSize ).setDynamic( true );
+	return new BufferAttribute( array, itemSize ).setDynamic( true );
 
 
 };
 };
+
+
+export {
+  DynamicBufferAttribute,
+  Float64Attribute,
+  Float32Attribute,
+  Uint32Attribute,
+  Int32Attribute,
+  Uint16Attribute,
+  Int16Attribute,
+  Uint8ClampedAttribute,
+  Uint8Attribute,
+  Int8Attribute,
+  BufferAttribute
+};

+ 61 - 45
src/core/BufferGeometry.js

@@ -1,13 +1,26 @@
+import { Vector3 } from '../math/Vector3';
+import { Box3 } from '../math/Box3';
+import { EventDispatcher } from './EventDispatcher';
+import { BufferAttribute, Float32Attribute } from './BufferAttribute';
+import { Sphere } from '../math/Sphere';
+import { DirectGeometry } from './DirectGeometry';
+import { Object3D } from './Object3D';
+import { Matrix4 } from '../math/Matrix4';
+import { Matrix3 } from '../math/Matrix3';
+import { _Math } from '../math/Math';
+import { GeometryIdCount } from './Geometry';
+
 /**
 /**
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.BufferGeometry = function () {
+function BufferGeometry () {
+	this.isBufferGeometry = true;
 
 
-	Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
+	Object.defineProperty( this, 'id', { value: GeometryIdCount() } );
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.name = '';
 	this.name = '';
 	this.type = 'BufferGeometry';
 	this.type = 'BufferGeometry';
@@ -26,7 +39,7 @@ THREE.BufferGeometry = function () {
 
 
 };
 };
 
 
-Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype, {
+Object.assign( BufferGeometry.prototype, EventDispatcher.prototype, {
 
 
 	getIndex: function () {
 	getIndex: function () {
 
 
@@ -42,11 +55,11 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 	addAttribute: function ( name, attribute ) {
 	addAttribute: function ( name, attribute ) {
 
 
-		if ( attribute instanceof THREE.BufferAttribute === false && attribute instanceof THREE.InterleavedBufferAttribute === false ) {
+		if ( (attribute && attribute.isBufferAttribute) === false && (attribute && attribute.isInterleavedBufferAttribute) === false ) {
 
 
 			console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' );
 			console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' );
 
 
-			this.addAttribute( name, new THREE.BufferAttribute( arguments[ 1 ], arguments[ 2 ] ) );
+			this.addAttribute( name, new BufferAttribute( arguments[ 1 ], arguments[ 2 ] ) );
 
 
 			return;
 			return;
 
 
@@ -121,7 +134,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		if ( normal !== undefined ) {
 		if ( normal !== undefined ) {
 
 
-			var normalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
+			var normalMatrix = new Matrix3().getNormalMatrix( matrix );
 
 
 			normalMatrix.applyToVector3Array( normal.array );
 			normalMatrix.applyToVector3Array( normal.array );
 			normal.needsUpdate = true;
 			normal.needsUpdate = true;
@@ -152,7 +165,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function rotateX( angle ) {
 		return function rotateX( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationX( angle );
 			m1.makeRotationX( angle );
 
 
@@ -172,7 +185,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function rotateY( angle ) {
 		return function rotateY( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationY( angle );
 			m1.makeRotationY( angle );
 
 
@@ -192,7 +205,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function rotateZ( angle ) {
 		return function rotateZ( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationZ( angle );
 			m1.makeRotationZ( angle );
 
 
@@ -212,7 +225,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function translate( x, y, z ) {
 		return function translate( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeTranslation( x, y, z );
 			m1.makeTranslation( x, y, z );
 
 
@@ -232,7 +245,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function scale( x, y, z ) {
 		return function scale( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeScale( x, y, z );
 			m1.makeScale( x, y, z );
 
 
@@ -250,7 +263,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		return function lookAt( vector ) {
 		return function lookAt( vector ) {
 
 
-			if ( obj === undefined ) obj = new THREE.Object3D();
+			if ( obj === undefined ) obj = new Object3D();
 
 
 			obj.lookAt( vector );
 			obj.lookAt( vector );
 
 
@@ -280,17 +293,17 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		var geometry = object.geometry;
 		var geometry = object.geometry;
 
 
-		if ( object instanceof THREE.Points || object instanceof THREE.Line ) {
+		if ( (object && object.isPoints) || (object && object.isLine) ) {
 
 
-			var positions = new THREE.Float32Attribute( geometry.vertices.length * 3, 3 );
-			var colors = new THREE.Float32Attribute( geometry.colors.length * 3, 3 );
+			var positions = new Float32Attribute( geometry.vertices.length * 3, 3 );
+			var colors = new Float32Attribute( geometry.colors.length * 3, 3 );
 
 
 			this.addAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
 			this.addAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );
 			this.addAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
 			this.addAttribute( 'color', colors.copyColorsArray( geometry.colors ) );
 
 
 			if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
 			if ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {
 
 
-				var lineDistances = new THREE.Float32Attribute( geometry.lineDistances.length, 1 );
+				var lineDistances = new Float32Attribute( geometry.lineDistances.length, 1 );
 
 
 				this.addAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );
 				this.addAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );
 
 
@@ -308,9 +321,9 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 			}
 			}
 
 
-		} else if ( object instanceof THREE.Mesh ) {
+		} else if ( (object && object.isMesh) ) {
 
 
-			if ( geometry instanceof THREE.Geometry ) {
+			if ( (geometry && geometry.isGeometry) ) {
 
 
 				this.fromGeometry( geometry );
 				this.fromGeometry( geometry );
 
 
@@ -326,7 +339,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		var geometry = object.geometry;
 		var geometry = object.geometry;
 
 
-		if ( object instanceof THREE.Mesh ) {
+		if ( (object && object.isMesh) ) {
 
 
 			var direct = geometry.__directGeometry;
 			var direct = geometry.__directGeometry;
 
 
@@ -445,7 +458,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 	fromGeometry: function ( geometry ) {
 	fromGeometry: function ( geometry ) {
 
 
-		geometry.__directGeometry = new THREE.DirectGeometry().fromGeometry( geometry );
+		geometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );
 
 
 		return this.fromDirectGeometry( geometry.__directGeometry );
 		return this.fromDirectGeometry( geometry.__directGeometry );
 
 
@@ -454,33 +467,33 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 	fromDirectGeometry: function ( geometry ) {
 	fromDirectGeometry: function ( geometry ) {
 
 
 		var positions = new Float32Array( geometry.vertices.length * 3 );
 		var positions = new Float32Array( geometry.vertices.length * 3 );
-		this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
+		this.addAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );
 
 
 		if ( geometry.normals.length > 0 ) {
 		if ( geometry.normals.length > 0 ) {
 
 
 			var normals = new Float32Array( geometry.normals.length * 3 );
 			var normals = new Float32Array( geometry.normals.length * 3 );
-			this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );
+			this.addAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );
 
 
 		}
 		}
 
 
 		if ( geometry.colors.length > 0 ) {
 		if ( geometry.colors.length > 0 ) {
 
 
 			var colors = new Float32Array( geometry.colors.length * 3 );
 			var colors = new Float32Array( geometry.colors.length * 3 );
-			this.addAttribute( 'color', new THREE.BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );
+			this.addAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );
 
 
 		}
 		}
 
 
 		if ( geometry.uvs.length > 0 ) {
 		if ( geometry.uvs.length > 0 ) {
 
 
 			var uvs = new Float32Array( geometry.uvs.length * 2 );
 			var uvs = new Float32Array( geometry.uvs.length * 2 );
-			this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );
+			this.addAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );
 
 
 		}
 		}
 
 
 		if ( geometry.uvs2.length > 0 ) {
 		if ( geometry.uvs2.length > 0 ) {
 
 
 			var uvs2 = new Float32Array( geometry.uvs2.length * 2 );
 			var uvs2 = new Float32Array( geometry.uvs2.length * 2 );
-			this.addAttribute( 'uv2', new THREE.BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );
+			this.addAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );
 
 
 		}
 		}
 
 
@@ -488,7 +501,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 			var TypeArray = geometry.vertices.length > 65535 ? Uint32Array : Uint16Array;
 			var TypeArray = geometry.vertices.length > 65535 ? Uint32Array : Uint16Array;
 			var indices = new TypeArray( geometry.indices.length * 3 );
 			var indices = new TypeArray( geometry.indices.length * 3 );
-			this.setIndex( new THREE.BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
+			this.setIndex( new BufferAttribute( indices, 1 ).copyIndicesArray( geometry.indices ) );
 
 
 		}
 		}
 
 
@@ -507,7 +520,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 				var morphTarget = morphTargets[ i ];
 				var morphTarget = morphTargets[ i ];
 
 
-				var attribute = new THREE.Float32Attribute( morphTarget.length * 3, 3 );
+				var attribute = new Float32Attribute( morphTarget.length * 3, 3 );
 
 
 				array.push( attribute.copyVector3sArray( morphTarget ) );
 				array.push( attribute.copyVector3sArray( morphTarget ) );
 
 
@@ -521,14 +534,14 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		if ( geometry.skinIndices.length > 0 ) {
 		if ( geometry.skinIndices.length > 0 ) {
 
 
-			var skinIndices = new THREE.Float32Attribute( geometry.skinIndices.length * 4, 4 );
+			var skinIndices = new Float32Attribute( geometry.skinIndices.length * 4, 4 );
 			this.addAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
 			this.addAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );
 
 
 		}
 		}
 
 
 		if ( geometry.skinWeights.length > 0 ) {
 		if ( geometry.skinWeights.length > 0 ) {
 
 
-			var skinWeights = new THREE.Float32Attribute( geometry.skinWeights.length * 4, 4 );
+			var skinWeights = new Float32Attribute( geometry.skinWeights.length * 4, 4 );
 			this.addAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
 			this.addAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );
 
 
 		}
 		}
@@ -555,7 +568,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		if ( this.boundingBox === null ) {
 		if ( this.boundingBox === null ) {
 
 
-			this.boundingBox = new THREE.Box3();
+			this.boundingBox = new Box3();
 
 
 		}
 		}
 
 
@@ -581,14 +594,14 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 	computeBoundingSphere: function () {
 	computeBoundingSphere: function () {
 
 
-		var box = new THREE.Box3();
-		var vector = new THREE.Vector3();
+		var box = new Box3();
+		var vector = new Vector3();
 
 
 		return function computeBoundingSphere() {
 		return function computeBoundingSphere() {
 
 
 			if ( this.boundingSphere === null ) {
 			if ( this.boundingSphere === null ) {
 
 
-				this.boundingSphere = new THREE.Sphere();
+				this.boundingSphere = new Sphere();
 
 
 			}
 			}
 
 
@@ -646,7 +659,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 			if ( attributes.normal === undefined ) {
 			if ( attributes.normal === undefined ) {
 
 
-				this.addAttribute( 'normal', new THREE.BufferAttribute( new Float32Array( positions.length ), 3 ) );
+				this.addAttribute( 'normal', new BufferAttribute( new Float32Array( positions.length ), 3 ) );
 
 
 			} else {
 			} else {
 
 
@@ -666,12 +679,12 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 			var vA, vB, vC,
 			var vA, vB, vC,
 
 
-			pA = new THREE.Vector3(),
-			pB = new THREE.Vector3(),
-			pC = new THREE.Vector3(),
+			pA = new Vector3(),
+			pB = new Vector3(),
+			pC = new Vector3(),
 
 
-			cb = new THREE.Vector3(),
-			ab = new THREE.Vector3();
+			cb = new Vector3(),
+			ab = new Vector3();
 
 
 			// indexed elements
 			// indexed elements
 
 
@@ -762,7 +775,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 	merge: function ( geometry, offset ) {
 	merge: function ( geometry, offset ) {
 
 
-		if ( geometry instanceof THREE.BufferGeometry === false ) {
+		if ( (geometry && geometry.isBufferGeometry) === false ) {
 
 
 			console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );
 			console.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );
 			return;
 			return;
@@ -828,7 +841,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 		}
 		}
 
 
-		var geometry2 = new THREE.BufferGeometry();
+		var geometry2 = new BufferGeometry();
 
 
 		var indices = this.index.array;
 		var indices = this.index.array;
 		var attributes = this.attributes;
 		var attributes = this.attributes;
@@ -856,7 +869,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 			}
 			}
 
 
-			geometry2.addAttribute( name, new THREE.BufferAttribute( array2, itemSize ) );
+			geometry2.addAttribute( name, new BufferAttribute( array2, itemSize ) );
 
 
 		}
 		}
 
 
@@ -975,7 +988,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 		return new this.constructor().copy( this );
 		return new this.constructor().copy( this );
 		*/
 		*/
 
 
-		return new THREE.BufferGeometry().copy( this );
+		return new BufferGeometry().copy( this );
 
 
 	},
 	},
 
 
@@ -1019,4 +1032,7 @@ Object.assign( THREE.BufferGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 } );
 } );
 
 
-THREE.BufferGeometry.MaxIndex = 65535;
+BufferGeometry.MaxIndex = 65535;
+
+
+export { BufferGeometry };

+ 7 - 3
src/core/Clock.js

@@ -2,7 +2,8 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.Clock = function ( autoStart ) {
+function Clock ( autoStart ) {
+	this.isClock = true;
 
 
 	this.autoStart = ( autoStart !== undefined ) ? autoStart : true;
 	this.autoStart = ( autoStart !== undefined ) ? autoStart : true;
 
 
@@ -14,9 +15,9 @@ THREE.Clock = function ( autoStart ) {
 
 
 };
 };
 
 
-THREE.Clock.prototype = {
+Clock.prototype = {
 
 
-	constructor: THREE.Clock,
+	constructor: Clock,
 
 
 	start: function () {
 	start: function () {
 
 
@@ -67,3 +68,6 @@ THREE.Clock.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { Clock };

+ 18 - 8
src/core/DirectGeometry.js

@@ -1,12 +1,19 @@
+import { Geometry } from './Geometry';
+import { EventDispatcher } from './EventDispatcher';
+import { Vector2 } from '../math/Vector2';
+import { _Math } from '../math/Math';
+import { GeometryIdCount } from './Geometry';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.DirectGeometry = function () {
+function DirectGeometry () {
+	this.isDirectGeometry = true;
 
 
-	Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
+	Object.defineProperty( this, 'id', { value: GeometryIdCount() } );
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.name = '';
 	this.name = '';
 	this.type = 'DirectGeometry';
 	this.type = 'DirectGeometry';
@@ -40,10 +47,10 @@ THREE.DirectGeometry = function () {
 
 
 };
 };
 
 
-Object.assign( THREE.DirectGeometry.prototype, THREE.EventDispatcher.prototype, {
+Object.assign( DirectGeometry.prototype, EventDispatcher.prototype, {
 
 
-	computeBoundingBox: THREE.Geometry.prototype.computeBoundingBox,
-	computeBoundingSphere: THREE.Geometry.prototype.computeBoundingSphere,
+	computeBoundingBox: Geometry.prototype.computeBoundingBox,
+	computeBoundingSphere: Geometry.prototype.computeBoundingSphere,
 
 
 	computeFaceNormals: function () {
 	computeFaceNormals: function () {
 
 
@@ -207,7 +214,7 @@ Object.assign( THREE.DirectGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );
 					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );
 
 
-					this.uvs.push( new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2() );
+					this.uvs.push( new Vector2(), new Vector2(), new Vector2() );
 
 
 				}
 				}
 
 
@@ -225,7 +232,7 @@ Object.assign( THREE.DirectGeometry.prototype, THREE.EventDispatcher.prototype,
 
 
 					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );
 					console.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );
 
 
-					this.uvs2.push( new THREE.Vector2(), new THREE.Vector2(), new THREE.Vector2() );
+					this.uvs2.push( new Vector2(), new Vector2(), new Vector2() );
 
 
 				}
 				}
 
 
@@ -284,3 +291,6 @@ Object.assign( THREE.DirectGeometry.prototype, THREE.EventDispatcher.prototype,
 	}
 	}
 
 
 } );
 } );
+
+
+export { DirectGeometry };

+ 6 - 2
src/core/EventDispatcher.js

@@ -2,9 +2,10 @@
  * https://github.com/mrdoob/eventdispatcher.js/
  * https://github.com/mrdoob/eventdispatcher.js/
  */
  */
 
 
-THREE.EventDispatcher = function () {};
+function EventDispatcher () {
+	this.isEventDispatcher = true;};
 
 
-Object.assign( THREE.EventDispatcher.prototype, {
+Object.assign( EventDispatcher.prototype, {
 
 
 	addEventListener: function ( type, listener ) {
 	addEventListener: function ( type, listener ) {
 
 
@@ -94,3 +95,6 @@ Object.assign( THREE.EventDispatcher.prototype, {
 	}
 	}
 
 
 } );
 } );
+
+
+export { EventDispatcher };

+ 12 - 5
src/core/Face3.js

@@ -1,27 +1,31 @@
+import { Color } from '../math/Color';
+import { Vector3 } from '../math/Vector3';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.Face3 = function ( a, b, c, normal, color, materialIndex ) {
+function Face3 ( a, b, c, normal, color, materialIndex ) {
+	this.isFace3 = true;
 
 
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
 	this.c = c;
 	this.c = c;
 
 
-	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
+	this.normal = (normal && normal.isVector3) ? normal : new Vector3();
 	this.vertexNormals = Array.isArray( normal ) ? normal : [];
 	this.vertexNormals = Array.isArray( normal ) ? normal : [];
 
 
-	this.color = color instanceof THREE.Color ? color : new THREE.Color();
+	this.color = (color && color.isColor) ? color : new Color();
 	this.vertexColors = Array.isArray( color ) ? color : [];
 	this.vertexColors = Array.isArray( color ) ? color : [];
 
 
 	this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
 	this.materialIndex = materialIndex !== undefined ? materialIndex : 0;
 
 
 };
 };
 
 
-THREE.Face3.prototype = {
+Face3.prototype = {
 
 
-	constructor: THREE.Face3,
+	constructor: Face3,
 
 
 	clone: function () {
 	clone: function () {
 
 
@@ -57,3 +61,6 @@ THREE.Face3.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { Face3 };

+ 49 - 32
src/core/Geometry.js

@@ -1,3 +1,15 @@
+import { EventDispatcher } from './EventDispatcher';
+import { Face3 } from './Face3';
+import { Matrix3 } from '../math/Matrix3';
+import { Sphere } from '../math/Sphere';
+import { Box3 } from '../math/Box3';
+import { Vector3 } from '../math/Vector3';
+import { Matrix4 } from '../math/Matrix4';
+import { Vector2 } from '../math/Vector2';
+import { Color } from '../math/Color';
+import { Object3D } from './Object3D';
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author kile / http://kile.stravaganza.org/
  * @author kile / http://kile.stravaganza.org/
@@ -7,11 +19,12 @@
  * @author bhouston / http://clara.io
  * @author bhouston / http://clara.io
  */
  */
 
 
-THREE.Geometry = function () {
+function Geometry () {
+	this.isGeometry = true;
 
 
-	Object.defineProperty( this, 'id', { value: THREE.GeometryIdCount ++ } );
+	Object.defineProperty( this, 'id', { value: GeometryIdCount() } );
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.name = '';
 	this.name = '';
 	this.type = 'Geometry';
 	this.type = 'Geometry';
@@ -44,11 +57,11 @@ THREE.Geometry = function () {
 
 
 };
 };
 
 
-Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
+Object.assign( Geometry.prototype, EventDispatcher.prototype, {
 
 
 	applyMatrix: function ( matrix ) {
 	applyMatrix: function ( matrix ) {
 
 
-		var normalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
+		var normalMatrix = new Matrix3().getNormalMatrix( matrix );
 
 
 		for ( var i = 0, il = this.vertices.length; i < il; i ++ ) {
 		for ( var i = 0, il = this.vertices.length; i < il; i ++ ) {
 
 
@@ -97,7 +110,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function rotateX( angle ) {
 		return function rotateX( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationX( angle );
 			m1.makeRotationX( angle );
 
 
@@ -117,7 +130,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function rotateY( angle ) {
 		return function rotateY( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationY( angle );
 			m1.makeRotationY( angle );
 
 
@@ -137,7 +150,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function rotateZ( angle ) {
 		return function rotateZ( angle ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeRotationZ( angle );
 			m1.makeRotationZ( angle );
 
 
@@ -157,7 +170,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function translate( x, y, z ) {
 		return function translate( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeTranslation( x, y, z );
 			m1.makeTranslation( x, y, z );
 
 
@@ -177,7 +190,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function scale( x, y, z ) {
 		return function scale( x, y, z ) {
 
 
-			if ( m1 === undefined ) m1 = new THREE.Matrix4();
+			if ( m1 === undefined ) m1 = new Matrix4();
 
 
 			m1.makeScale( x, y, z );
 			m1.makeScale( x, y, z );
 
 
@@ -195,7 +208,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		return function lookAt( vector ) {
 		return function lookAt( vector ) {
 
 
-			if ( obj === undefined ) obj = new THREE.Object3D();
+			if ( obj === undefined ) obj = new Object3D();
 
 
 			obj.lookAt( vector );
 			obj.lookAt( vector );
 
 
@@ -228,29 +241,29 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		for ( var i = 0, j = 0; i < positions.length; i += 3, j += 2 ) {
 		for ( var i = 0, j = 0; i < positions.length; i += 3, j += 2 ) {
 
 
-			scope.vertices.push( new THREE.Vector3( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] ) );
+			scope.vertices.push( new Vector3( positions[ i ], positions[ i + 1 ], positions[ i + 2 ] ) );
 
 
 			if ( normals !== undefined ) {
 			if ( normals !== undefined ) {
 
 
-				tempNormals.push( new THREE.Vector3( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] ) );
+				tempNormals.push( new Vector3( normals[ i ], normals[ i + 1 ], normals[ i + 2 ] ) );
 
 
 			}
 			}
 
 
 			if ( colors !== undefined ) {
 			if ( colors !== undefined ) {
 
 
-				scope.colors.push( new THREE.Color( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ) );
+				scope.colors.push( new Color( colors[ i ], colors[ i + 1 ], colors[ i + 2 ] ) );
 
 
 			}
 			}
 
 
 			if ( uvs !== undefined ) {
 			if ( uvs !== undefined ) {
 
 
-				tempUVs.push( new THREE.Vector2( uvs[ j ], uvs[ j + 1 ] ) );
+				tempUVs.push( new Vector2( uvs[ j ], uvs[ j + 1 ] ) );
 
 
 			}
 			}
 
 
 			if ( uvs2 !== undefined ) {
 			if ( uvs2 !== undefined ) {
 
 
-				tempUVs2.push( new THREE.Vector2( uvs2[ j ], uvs2[ j + 1 ] ) );
+				tempUVs2.push( new Vector2( uvs2[ j ], uvs2[ j + 1 ] ) );
 
 
 			}
 			}
 
 
@@ -261,7 +274,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 			var vertexNormals = normals !== undefined ? [ tempNormals[ a ].clone(), tempNormals[ b ].clone(), tempNormals[ c ].clone() ] : [];
 			var vertexNormals = normals !== undefined ? [ tempNormals[ a ].clone(), tempNormals[ b ].clone(), tempNormals[ c ].clone() ] : [];
 			var vertexColors = colors !== undefined ? [ scope.colors[ a ].clone(), scope.colors[ b ].clone(), scope.colors[ c ].clone() ] : [];
 			var vertexColors = colors !== undefined ? [ scope.colors[ a ].clone(), scope.colors[ b ].clone(), scope.colors[ c ].clone() ] : [];
 
 
-			var face = new THREE.Face3( a, b, c, vertexNormals, vertexColors, materialIndex );
+			var face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );
 
 
 			scope.faces.push( face );
 			scope.faces.push( face );
 
 
@@ -359,7 +372,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		var s = radius === 0 ? 1 : 1.0 / radius;
 		var s = radius === 0 ? 1 : 1.0 / radius;
 
 
-		var matrix = new THREE.Matrix4();
+		var matrix = new Matrix4();
 		matrix.set(
 		matrix.set(
 			s, 0, 0, - s * center.x,
 			s, 0, 0, - s * center.x,
 			0, s, 0, - s * center.y,
 			0, s, 0, - s * center.y,
@@ -375,7 +388,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 	computeFaceNormals: function () {
 	computeFaceNormals: function () {
 
 
-		var cb = new THREE.Vector3(), ab = new THREE.Vector3();
+		var cb = new Vector3(), ab = new Vector3();
 
 
 		for ( var f = 0, fl = this.faces.length; f < fl; f ++ ) {
 		for ( var f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 
@@ -407,7 +420,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 		for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 
 
-			vertices[ v ] = new THREE.Vector3();
+			vertices[ v ] = new Vector3();
 
 
 		}
 		}
 
 
@@ -417,7 +430,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 			// http://www.iquilezles.org/www/articles/normals/normals.htm
 			// http://www.iquilezles.org/www/articles/normals/normals.htm
 
 
 			var vA, vB, vC;
 			var vA, vB, vC;
-			var cb = new THREE.Vector3(), ab = new THREE.Vector3();
+			var cb = new Vector3(), ab = new Vector3();
 
 
 			for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 			for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 
@@ -529,7 +542,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		// use temp geometry to compute face and vertex normals for each morph
 		// use temp geometry to compute face and vertex normals for each morph
 
 
-		var tmpGeo = new THREE.Geometry();
+		var tmpGeo = new Geometry();
 		tmpGeo.faces = this.faces;
 		tmpGeo.faces = this.faces;
 
 
 		for ( i = 0, il = this.morphTargets.length; i < il; i ++ ) {
 		for ( i = 0, il = this.morphTargets.length; i < il; i ++ ) {
@@ -549,8 +562,8 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 				for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 				for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 
-					faceNormal = new THREE.Vector3();
-					vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
+					faceNormal = new Vector3();
+					vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };
 
 
 					dstNormalsFace.push( faceNormal );
 					dstNormalsFace.push( faceNormal );
 					dstNormalsVertex.push( vertexNormals );
 					dstNormalsVertex.push( vertexNormals );
@@ -633,7 +646,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		if ( this.boundingBox === null ) {
 		if ( this.boundingBox === null ) {
 
 
-			this.boundingBox = new THREE.Box3();
+			this.boundingBox = new Box3();
 
 
 		}
 		}
 
 
@@ -645,7 +658,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		if ( this.boundingSphere === null ) {
 		if ( this.boundingSphere === null ) {
 
 
-			this.boundingSphere = new THREE.Sphere();
+			this.boundingSphere = new Sphere();
 
 
 		}
 		}
 
 
@@ -655,7 +668,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 	merge: function ( geometry, matrix, materialIndexOffset ) {
 	merge: function ( geometry, matrix, materialIndexOffset ) {
 
 
-		if ( geometry instanceof THREE.Geometry === false ) {
+		if ( (geometry && geometry.isGeometry) === false ) {
 
 
 			console.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );
 			console.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );
 			return;
 			return;
@@ -675,7 +688,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 		if ( matrix !== undefined ) {
 		if ( matrix !== undefined ) {
 
 
-			normalMatrix = new THREE.Matrix3().getNormalMatrix( matrix );
+			normalMatrix = new Matrix3().getNormalMatrix( matrix );
 
 
 		}
 		}
 
 
@@ -701,7 +714,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 			faceVertexNormals = face.vertexNormals,
 			faceVertexNormals = face.vertexNormals,
 			faceVertexColors = face.vertexColors;
 			faceVertexColors = face.vertexColors;
 
 
-			faceCopy = new THREE.Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );
+			faceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );
 			faceCopy.normal.copy( face.normal );
 			faceCopy.normal.copy( face.normal );
 
 
 			if ( normalMatrix !== undefined ) {
 			if ( normalMatrix !== undefined ) {
@@ -765,7 +778,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 	mergeMesh: function ( mesh ) {
 	mergeMesh: function ( mesh ) {
 
 
-		if ( mesh instanceof THREE.Mesh === false ) {
+		if ( (mesh && mesh.isMesh) === false ) {
 
 
 			console.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );
 			console.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );
 			return;
 			return;
@@ -1136,7 +1149,7 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 		return new this.constructor().copy( this );
 		return new this.constructor().copy( this );
 		*/
 		*/
 
 
-		return new THREE.Geometry().copy( this );
+		return new Geometry().copy( this );
 
 
 	},
 	},
 
 
@@ -1202,4 +1215,8 @@ Object.assign( THREE.Geometry.prototype, THREE.EventDispatcher.prototype, {
 
 
 } );
 } );
 
 
-THREE.GeometryIdCount = 0;
+var count = 0;
+function GeometryIdCount () { return count++; };
+
+
+export { GeometryIdCount, Geometry };

+ 12 - 6
src/core/InstancedBufferAttribute.js

@@ -1,24 +1,30 @@
+import { BufferAttribute } from './BufferAttribute';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.InstancedBufferAttribute = function ( array, itemSize, meshPerAttribute ) {
+function InstancedBufferAttribute ( array, itemSize, meshPerAttribute ) {
+	this.isInstancedBufferAttribute = this.isBufferAttribute = true;
 
 
-	THREE.BufferAttribute.call( this, array, itemSize );
+	BufferAttribute.call( this, array, itemSize );
 
 
 	this.meshPerAttribute = meshPerAttribute || 1;
 	this.meshPerAttribute = meshPerAttribute || 1;
 
 
 };
 };
 
 
-THREE.InstancedBufferAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
-THREE.InstancedBufferAttribute.prototype.constructor = THREE.InstancedBufferAttribute;
+InstancedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );
+InstancedBufferAttribute.prototype.constructor = InstancedBufferAttribute;
 
 
-THREE.InstancedBufferAttribute.prototype.copy = function ( source ) {
+InstancedBufferAttribute.prototype.copy = function ( source ) {
 
 
-	THREE.BufferAttribute.prototype.copy.call( this, source );
+	BufferAttribute.prototype.copy.call( this, source );
 
 
 	this.meshPerAttribute = source.meshPerAttribute;
 	this.meshPerAttribute = source.meshPerAttribute;
 
 
 	return this;
 	return this;
 
 
 };
 };
+
+
+export { InstancedBufferAttribute };

+ 12 - 6
src/core/InstancedBufferGeometry.js

@@ -1,20 +1,23 @@
+import { BufferGeometry } from './BufferGeometry';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.InstancedBufferGeometry = function () {
+function InstancedBufferGeometry () {
+	this.isInstancedBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'InstancedBufferGeometry';
 	this.type = 'InstancedBufferGeometry';
 	this.maxInstancedCount = undefined;
 	this.maxInstancedCount = undefined;
 
 
 };
 };
 
 
-THREE.InstancedBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.InstancedBufferGeometry.prototype.constructor = THREE.InstancedBufferGeometry;
+InstancedBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+InstancedBufferGeometry.prototype.constructor = InstancedBufferGeometry;
 
 
-THREE.InstancedBufferGeometry.prototype.addGroup = function ( start, count, instances ) {
+InstancedBufferGeometry.prototype.addGroup = function ( start, count, instances ) {
 
 
 	this.groups.push( {
 	this.groups.push( {
 
 
@@ -26,7 +29,7 @@ THREE.InstancedBufferGeometry.prototype.addGroup = function ( start, count, inst
 
 
 };
 };
 
 
-THREE.InstancedBufferGeometry.prototype.copy = function ( source ) {
+InstancedBufferGeometry.prototype.copy = function ( source ) {
 
 
 	var index = source.index;
 	var index = source.index;
 
 
@@ -57,3 +60,6 @@ THREE.InstancedBufferGeometry.prototype.copy = function ( source ) {
 	return this;
 	return this;
 
 
 };
 };
+
+
+export { InstancedBufferGeometry };

+ 12 - 6
src/core/InstancedInterleavedBuffer.js

@@ -1,24 +1,30 @@
+import { InterleavedBuffer } from './InterleavedBuffer';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.InstancedInterleavedBuffer = function ( array, stride, meshPerAttribute ) {
+function InstancedInterleavedBuffer ( array, stride, meshPerAttribute ) {
+	this.isInstancedInterleavedBuffer = this.isInterleavedBuffer = true;
 
 
-	THREE.InterleavedBuffer.call( this, array, stride );
+	InterleavedBuffer.call( this, array, stride );
 
 
 	this.meshPerAttribute = meshPerAttribute || 1;
 	this.meshPerAttribute = meshPerAttribute || 1;
 
 
 };
 };
 
 
-THREE.InstancedInterleavedBuffer.prototype = Object.create( THREE.InterleavedBuffer.prototype );
-THREE.InstancedInterleavedBuffer.prototype.constructor = THREE.InstancedInterleavedBuffer;
+InstancedInterleavedBuffer.prototype = Object.create( InterleavedBuffer.prototype );
+InstancedInterleavedBuffer.prototype.constructor = InstancedInterleavedBuffer;
 
 
-THREE.InstancedInterleavedBuffer.prototype.copy = function ( source ) {
+InstancedInterleavedBuffer.prototype.copy = function ( source ) {
 
 
-	THREE.InterleavedBuffer.prototype.copy.call( this, source );
+	InterleavedBuffer.prototype.copy.call( this, source );
 
 
 	this.meshPerAttribute = source.meshPerAttribute;
 	this.meshPerAttribute = source.meshPerAttribute;
 
 
 	return this;
 	return this;
 
 
 };
 };
+
+
+export { InstancedInterleavedBuffer };

+ 10 - 4
src/core/InterleavedBuffer.js

@@ -1,10 +1,13 @@
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.InterleavedBuffer = function ( array, stride ) {
+function InterleavedBuffer ( array, stride ) {
+	this.isInterleavedBuffer = true;
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.array = array;
 	this.array = array;
 	this.stride = stride;
 	this.stride = stride;
@@ -16,9 +19,9 @@ THREE.InterleavedBuffer = function ( array, stride ) {
 
 
 };
 };
 
 
-THREE.InterleavedBuffer.prototype = {
+InterleavedBuffer.prototype = {
 
 
-	constructor: THREE.InterleavedBuffer,
+	constructor: InterleavedBuffer,
 
 
 	get length () {
 	get length () {
 
 
@@ -88,3 +91,6 @@ THREE.InterleavedBuffer.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { InterleavedBuffer };

+ 10 - 4
src/core/InterleavedBufferAttribute.js

@@ -1,10 +1,13 @@
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.InterleavedBufferAttribute = function ( interleavedBuffer, itemSize, offset, normalized ) {
+function InterleavedBufferAttribute ( interleavedBuffer, itemSize, offset, normalized ) {
+	this.isInterleavedBufferAttribute = true;
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.data = interleavedBuffer;
 	this.data = interleavedBuffer;
 	this.itemSize = itemSize;
 	this.itemSize = itemSize;
@@ -15,9 +18,9 @@ THREE.InterleavedBufferAttribute = function ( interleavedBuffer, itemSize, offse
 };
 };
 
 
 
 
-THREE.InterleavedBufferAttribute.prototype = {
+InterleavedBufferAttribute.prototype = {
 
 
-	constructor: THREE.InterleavedBufferAttribute,
+	constructor: InterleavedBufferAttribute,
 
 
 	get length() {
 	get length() {
 
 
@@ -131,3 +134,6 @@ THREE.InterleavedBufferAttribute.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { InterleavedBufferAttribute };

+ 7 - 3
src/core/Layers.js

@@ -2,15 +2,16 @@
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.Layers = function () {
+function Layers () {
+	this.isLayers = true;
 
 
 	this.mask = 1;
 	this.mask = 1;
 
 
 };
 };
 
 
-THREE.Layers.prototype = {
+Layers.prototype = {
 
 
-	constructor: THREE.Layers,
+	constructor: Layers,
 
 
 	set: function ( channel ) {
 	set: function ( channel ) {
 
 
@@ -43,3 +44,6 @@ THREE.Layers.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { Layers };

+ 54 - 40
src/core/Object3D.js

@@ -1,3 +1,12 @@
+import { Quaternion } from '../math/Quaternion';
+import { Vector3 } from '../math/Vector3';
+import { Matrix4 } from '../math/Matrix4';
+import { EventDispatcher } from './EventDispatcher';
+import { Euler } from '../math/Euler';
+import { Layers } from './Layers';
+import { Matrix3 } from '../math/Matrix3';
+import { _Math } from '../math/Math';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
@@ -6,11 +15,12 @@
  * @author elephantatwork / www.elephantatwork.ch
  * @author elephantatwork / www.elephantatwork.ch
  */
  */
 
 
-THREE.Object3D = function () {
+function Object3D () {
+	this.isObject3D = true;
 
 
-	Object.defineProperty( this, 'id', { value: THREE.Object3DIdCount ++ } );
+	Object.defineProperty( this, 'id', { value: Object3DIdCount() } );
 
 
-	this.uuid = THREE.Math.generateUUID();
+	this.uuid = _Math.generateUUID();
 
 
 	this.name = '';
 	this.name = '';
 	this.type = 'Object3D';
 	this.type = 'Object3D';
@@ -18,12 +28,12 @@ THREE.Object3D = function () {
 	this.parent = null;
 	this.parent = null;
 	this.children = [];
 	this.children = [];
 
 
-	this.up = THREE.Object3D.DefaultUp.clone();
+	this.up = Object3D.DefaultUp.clone();
 
 
-	var position = new THREE.Vector3();
-	var rotation = new THREE.Euler();
-	var quaternion = new THREE.Quaternion();
-	var scale = new THREE.Vector3( 1, 1, 1 );
+	var position = new Vector3();
+	var rotation = new Euler();
+	var quaternion = new Quaternion();
+	var scale = new Vector3( 1, 1, 1 );
 
 
 	function onRotationChange() {
 	function onRotationChange() {
 
 
@@ -58,20 +68,20 @@ THREE.Object3D = function () {
 			value: scale
 			value: scale
 		},
 		},
 		modelViewMatrix: {
 		modelViewMatrix: {
-			value: new THREE.Matrix4()
+			value: new Matrix4()
 		},
 		},
 		normalMatrix: {
 		normalMatrix: {
-			value: new THREE.Matrix3()
+			value: new Matrix3()
 		}
 		}
 	} );
 	} );
 
 
-	this.matrix = new THREE.Matrix4();
-	this.matrixWorld = new THREE.Matrix4();
+	this.matrix = new Matrix4();
+	this.matrixWorld = new Matrix4();
 
 
-	this.matrixAutoUpdate = THREE.Object3D.DefaultMatrixAutoUpdate;
+	this.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;
 	this.matrixWorldNeedsUpdate = false;
 	this.matrixWorldNeedsUpdate = false;
 
 
-	this.layers = new THREE.Layers();
+	this.layers = new Layers();
 	this.visible = true;
 	this.visible = true;
 
 
 	this.castShadow = false;
 	this.castShadow = false;
@@ -84,10 +94,10 @@ THREE.Object3D = function () {
 
 
 };
 };
 
 
-THREE.Object3D.DefaultUp = new THREE.Vector3( 0, 1, 0 );
-THREE.Object3D.DefaultMatrixAutoUpdate = true;
+Object3D.DefaultUp = new Vector3( 0, 1, 0 );
+Object3D.DefaultMatrixAutoUpdate = true;
 
 
-Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
+Object.assign( Object3D.prototype, EventDispatcher.prototype, {
 
 
 	applyMatrix: function ( matrix ) {
 	applyMatrix: function ( matrix ) {
 
 
@@ -132,7 +142,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 		// rotate object on axis in object space
 		// rotate object on axis in object space
 		// axis is assumed to be normalized
 		// axis is assumed to be normalized
 
 
-		var q1 = new THREE.Quaternion();
+		var q1 = new Quaternion();
 
 
 		return function rotateOnAxis( axis, angle ) {
 		return function rotateOnAxis( axis, angle ) {
 
 
@@ -148,7 +158,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	rotateX: function () {
 	rotateX: function () {
 
 
-		var v1 = new THREE.Vector3( 1, 0, 0 );
+		var v1 = new Vector3( 1, 0, 0 );
 
 
 		return function rotateX( angle ) {
 		return function rotateX( angle ) {
 
 
@@ -160,7 +170,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	rotateY: function () {
 	rotateY: function () {
 
 
-		var v1 = new THREE.Vector3( 0, 1, 0 );
+		var v1 = new Vector3( 0, 1, 0 );
 
 
 		return function rotateY( angle ) {
 		return function rotateY( angle ) {
 
 
@@ -172,7 +182,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	rotateZ: function () {
 	rotateZ: function () {
 
 
-		var v1 = new THREE.Vector3( 0, 0, 1 );
+		var v1 = new Vector3( 0, 0, 1 );
 
 
 		return function rotateZ( angle ) {
 		return function rotateZ( angle ) {
 
 
@@ -187,7 +197,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 		// translate object by distance along axis in object space
 		// translate object by distance along axis in object space
 		// axis is assumed to be normalized
 		// axis is assumed to be normalized
 
 
-		var v1 = new THREE.Vector3();
+		var v1 = new Vector3();
 
 
 		return function translateOnAxis( axis, distance ) {
 		return function translateOnAxis( axis, distance ) {
 
 
@@ -203,7 +213,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	translateX: function () {
 	translateX: function () {
 
 
-		var v1 = new THREE.Vector3( 1, 0, 0 );
+		var v1 = new Vector3( 1, 0, 0 );
 
 
 		return function translateX( distance ) {
 		return function translateX( distance ) {
 
 
@@ -215,7 +225,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	translateY: function () {
 	translateY: function () {
 
 
-		var v1 = new THREE.Vector3( 0, 1, 0 );
+		var v1 = new Vector3( 0, 1, 0 );
 
 
 		return function translateY( distance ) {
 		return function translateY( distance ) {
 
 
@@ -227,7 +237,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	translateZ: function () {
 	translateZ: function () {
 
 
-		var v1 = new THREE.Vector3( 0, 0, 1 );
+		var v1 = new Vector3( 0, 0, 1 );
 
 
 		return function translateZ( distance ) {
 		return function translateZ( distance ) {
 
 
@@ -245,7 +255,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	worldToLocal: function () {
 	worldToLocal: function () {
 
 
-		var m1 = new THREE.Matrix4();
+		var m1 = new Matrix4();
 
 
 		return function worldToLocal( vector ) {
 		return function worldToLocal( vector ) {
 
 
@@ -259,7 +269,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 		// This routine does not support objects with rotated and/or translated parent(s)
 		// This routine does not support objects with rotated and/or translated parent(s)
 
 
-		var m1 = new THREE.Matrix4();
+		var m1 = new Matrix4();
 
 
 		return function lookAt( vector ) {
 		return function lookAt( vector ) {
 
 
@@ -292,7 +302,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 		}
 		}
 
 
-		if ( object instanceof THREE.Object3D ) {
+		if ( (object && object.isObject3D) ) {
 
 
 			if ( object.parent !== null ) {
 			if ( object.parent !== null ) {
 
 
@@ -376,7 +386,7 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	getWorldPosition: function ( optionalTarget ) {
 	getWorldPosition: function ( optionalTarget ) {
 
 
-		var result = optionalTarget || new THREE.Vector3();
+		var result = optionalTarget || new Vector3();
 
 
 		this.updateMatrixWorld( true );
 		this.updateMatrixWorld( true );
 
 
@@ -386,12 +396,12 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	getWorldQuaternion: function () {
 	getWorldQuaternion: function () {
 
 
-		var position = new THREE.Vector3();
-		var scale = new THREE.Vector3();
+		var position = new Vector3();
+		var scale = new Vector3();
 
 
 		return function getWorldQuaternion( optionalTarget ) {
 		return function getWorldQuaternion( optionalTarget ) {
 
 
-			var result = optionalTarget || new THREE.Quaternion();
+			var result = optionalTarget || new Quaternion();
 
 
 			this.updateMatrixWorld( true );
 			this.updateMatrixWorld( true );
 
 
@@ -405,11 +415,11 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	getWorldRotation: function () {
 	getWorldRotation: function () {
 
 
-		var quaternion = new THREE.Quaternion();
+		var quaternion = new Quaternion();
 
 
 		return function getWorldRotation( optionalTarget ) {
 		return function getWorldRotation( optionalTarget ) {
 
 
-			var result = optionalTarget || new THREE.Euler();
+			var result = optionalTarget || new Euler();
 
 
 			this.getWorldQuaternion( quaternion );
 			this.getWorldQuaternion( quaternion );
 
 
@@ -421,12 +431,12 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	getWorldScale: function () {
 	getWorldScale: function () {
 
 
-		var position = new THREE.Vector3();
-		var quaternion = new THREE.Quaternion();
+		var position = new Vector3();
+		var quaternion = new Quaternion();
 
 
 		return function getWorldScale( optionalTarget ) {
 		return function getWorldScale( optionalTarget ) {
 
 
-			var result = optionalTarget || new THREE.Vector3();
+			var result = optionalTarget || new Vector3();
 
 
 			this.updateMatrixWorld( true );
 			this.updateMatrixWorld( true );
 
 
@@ -440,11 +450,11 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 	getWorldDirection: function () {
 	getWorldDirection: function () {
 
 
-		var quaternion = new THREE.Quaternion();
+		var quaternion = new Quaternion();
 
 
 		return function getWorldDirection( optionalTarget ) {
 		return function getWorldDirection( optionalTarget ) {
 
 
-			var result = optionalTarget || new THREE.Vector3();
+			var result = optionalTarget || new Vector3();
 
 
 			this.getWorldQuaternion( quaternion );
 			this.getWorldQuaternion( quaternion );
 
 
@@ -711,4 +721,8 @@ Object.assign( THREE.Object3D.prototype, THREE.EventDispatcher.prototype, {
 
 
 } );
 } );
 
 
-THREE.Object3DIdCount = 0;
+var count = 0;
+function Object3DIdCount () { return count++; };
+
+
+export { Object3DIdCount, Object3D };

+ 76 - 74
src/core/Raycaster.js

@@ -1,135 +1,137 @@
+import { Ray } from '../math/Ray';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * @author bhouston / http://clara.io/
  * @author bhouston / http://clara.io/
  * @author stephomi / http://stephaneginier.com/
  * @author stephomi / http://stephaneginier.com/
  */
  */
 
 
-( function ( THREE ) {
-
-	THREE.Raycaster = function ( origin, direction, near, far ) {
+function Raycaster ( origin, direction, near, far ) {
+	this.isRaycaster = true;
 
 
-		this.ray = new THREE.Ray( origin, direction );
-		// direction is assumed to be normalized (for accurate distance calculations)
+	this.ray = new Ray( origin, direction );
+	// direction is assumed to be normalized (for accurate distance calculations)
 
 
-		this.near = near || 0;
-		this.far = far || Infinity;
-
-		this.params = {
-			Mesh: {},
-			Line: {},
-			LOD: {},
-			Points: { threshold: 1 },
-			Sprite: {}
-		};
-
-		Object.defineProperties( this.params, {
-			PointCloud: {
-				get: function () {
-					console.warn( 'THREE.Raycaster: params.PointCloud has been renamed to params.Points.' );
-					return this.Points;
-				}
-			}
-		} );
+	this.near = near || 0;
+	this.far = far || Infinity;
 
 
+	this.params = {
+		Mesh: {},
+		Line: {},
+		LOD: {},
+		Points: { threshold: 1 },
+		Sprite: {}
 	};
 	};
 
 
-	function ascSort( a, b ) {
+	Object.defineProperties( this.params, {
+		PointCloud: {
+			get: function () {
+				console.warn( 'THREE.Raycaster: params.PointCloud has been renamed to params.Points.' );
+				return this.Points;
+			}
+		}
+	} );
+
+};
 
 
-		return a.distance - b.distance;
+function ascSort( a, b ) {
 
 
-	}
+	return a.distance - b.distance;
 
 
-	function intersectObject( object, raycaster, intersects, recursive ) {
+}
 
 
-		if ( object.visible === false ) return;
+function intersectObject( object, raycaster, intersects, recursive ) {
 
 
-		object.raycast( raycaster, intersects );
+	if ( object.visible === false ) return;
 
 
-		if ( recursive === true ) {
+	object.raycast( raycaster, intersects );
 
 
-			var children = object.children;
+	if ( recursive === true ) {
 
 
-			for ( var i = 0, l = children.length; i < l; i ++ ) {
+		var children = object.children;
 
 
-				intersectObject( children[ i ], raycaster, intersects, true );
+		for ( var i = 0, l = children.length; i < l; i ++ ) {
 
 
-			}
+			intersectObject( children[ i ], raycaster, intersects, true );
 
 
 		}
 		}
 
 
 	}
 	}
 
 
-	//
+}
 
 
-	THREE.Raycaster.prototype = {
+//
 
 
-		constructor: THREE.Raycaster,
+Raycaster.prototype = {
 
 
-		linePrecision: 1,
+	constructor: Raycaster,
 
 
-		set: function ( origin, direction ) {
+	linePrecision: 1,
 
 
-			// direction is assumed to be normalized (for accurate distance calculations)
+	set: function ( origin, direction ) {
 
 
-			this.ray.set( origin, direction );
+		// direction is assumed to be normalized (for accurate distance calculations)
 
 
-		},
+		this.ray.set( origin, direction );
 
 
-		setFromCamera: function ( coords, camera ) {
+	},
 
 
-			if ( camera instanceof THREE.PerspectiveCamera ) {
+	setFromCamera: function ( coords, camera ) {
 
 
-				this.ray.origin.setFromMatrixPosition( camera.matrixWorld );
-				this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();
+		if ( (camera && camera.isPerspectiveCamera) ) {
 
 
-			} else if ( camera instanceof THREE.OrthographicCamera ) {
+			this.ray.origin.setFromMatrixPosition( camera.matrixWorld );
+			this.ray.direction.set( coords.x, coords.y, 0.5 ).unproject( camera ).sub( this.ray.origin ).normalize();
 
 
-				this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
-				this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
+		} else if ( (camera && camera.isOrthographicCamera) ) {
 
 
-			} else {
+			this.ray.origin.set( coords.x, coords.y, ( camera.near + camera.far ) / ( camera.near - camera.far ) ).unproject( camera ); // set origin in plane of camera
+			this.ray.direction.set( 0, 0, - 1 ).transformDirection( camera.matrixWorld );
 
 
-				console.error( 'THREE.Raycaster: Unsupported camera type.' );
+		} else {
 
 
-			}
+			console.error( 'THREE.Raycaster: Unsupported camera type.' );
+
+		}
 
 
-		},
+	},
 
 
-		intersectObject: function ( object, recursive ) {
+	intersectObject: function ( object, recursive ) {
 
 
-			var intersects = [];
+		var intersects = [];
 
 
-			intersectObject( object, this, intersects, recursive );
+		intersectObject( object, this, intersects, recursive );
 
 
-			intersects.sort( ascSort );
+		intersects.sort( ascSort );
 
 
-			return intersects;
+		return intersects;
 
 
-		},
+	},
 
 
-		intersectObjects: function ( objects, recursive ) {
+	intersectObjects: function ( objects, recursive ) {
 
 
-			var intersects = [];
+		var intersects = [];
 
 
-			if ( Array.isArray( objects ) === false ) {
+		if ( Array.isArray( objects ) === false ) {
 
 
-				console.warn( 'THREE.Raycaster.intersectObjects: objects is not an Array.' );
-				return intersects;
+			console.warn( 'THREE.Raycaster.intersectObjects: objects is not an Array.' );
+			return intersects;
 
 
-			}
+		}
 
 
-			for ( var i = 0, l = objects.length; i < l; i ++ ) {
+		for ( var i = 0, l = objects.length; i < l; i ++ ) {
 
 
-				intersectObject( objects[ i ], this, intersects, recursive );
+			intersectObject( objects[ i ], this, intersects, recursive );
 
 
-			}
+		}
 
 
-			intersects.sort( ascSort );
+		intersects.sort( ascSort );
 
 
-			return intersects;
+		return intersects;
 
 
-		}
+	}
+
+};
 
 
-	};
 
 
-}( THREE ) );
+export { Raycaster };

+ 7 - 3
src/core/Uniform.js

@@ -2,7 +2,8 @@
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.Uniform = function ( value ) {
+function Uniform ( value ) {
+	this.isUniform = true;
 
 
 	if ( typeof value === 'string' ) {
 	if ( typeof value === 'string' ) {
 
 
@@ -17,9 +18,9 @@ THREE.Uniform = function ( value ) {
 
 
 };
 };
 
 
-THREE.Uniform.prototype = {
+Uniform.prototype = {
 
 
-	constructor: THREE.Uniform,
+	constructor: Uniform,
 
 
 	onUpdate: function ( callback ) {
 	onUpdate: function ( callback ) {
 
 
@@ -31,3 +32,6 @@ THREE.Uniform.prototype = {
 	}
 	}
 
 
 };
 };
+
+
+export { Uniform };

+ 6 - 1
src/extras/CurveUtils.js

@@ -1,8 +1,10 @@
+var CurveUtils;
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  */
  */
 
 
-THREE.CurveUtils = {
+CurveUtils = {
 
 
 	tangentQuadraticBezier: function ( t, p0, p1, p2 ) {
 	tangentQuadraticBezier: function ( t, p0, p1, p2 ) {
 
 
@@ -47,3 +49,6 @@ THREE.CurveUtils = {
 	}
 	}
 
 
 };
 };
+
+
+export { CurveUtils };

+ 13 - 4
src/extras/SceneUtils.js

@@ -1,16 +1,22 @@
+import { Matrix4 } from '../math/Matrix4';
+import { Mesh } from '../objects/Mesh';
+import { Group } from '../objects/Group';
+
+var SceneUtils;
+
 /**
 /**
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.SceneUtils = {
+SceneUtils = {
 
 
 	createMultiMaterialObject: function ( geometry, materials ) {
 	createMultiMaterialObject: function ( geometry, materials ) {
 
 
-		var group = new THREE.Group();
+		var group = new Group();
 
 
 		for ( var i = 0, l = materials.length; i < l; i ++ ) {
 		for ( var i = 0, l = materials.length; i < l; i ++ ) {
 
 
-			group.add( new THREE.Mesh( geometry, materials[ i ] ) );
+			group.add( new Mesh( geometry, materials[ i ] ) );
 
 
 		}
 		}
 
 
@@ -28,7 +34,7 @@ THREE.SceneUtils = {
 
 
 	attach: function ( child, scene, parent ) {
 	attach: function ( child, scene, parent ) {
 
 
-		var matrixWorldInverse = new THREE.Matrix4();
+		var matrixWorldInverse = new Matrix4();
 		matrixWorldInverse.getInverse( parent.matrixWorld );
 		matrixWorldInverse.getInverse( parent.matrixWorld );
 		child.applyMatrix( matrixWorldInverse );
 		child.applyMatrix( matrixWorldInverse );
 
 
@@ -38,3 +44,6 @@ THREE.SceneUtils = {
 	}
 	}
 
 
 };
 };
+
+
+export { SceneUtils };

+ 9 - 4
src/extras/ShapeUtils.js

@@ -1,8 +1,10 @@
+var ShapeUtils;
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  */
  */
 
 
-THREE.ShapeUtils = {
+ShapeUtils = {
 
 
 	// calculate area of the contour polygon
 	// calculate area of the contour polygon
 
 
@@ -105,7 +107,7 @@ THREE.ShapeUtils = {
 
 
 			var u, v, w;
 			var u, v, w;
 
 
-			if ( THREE.ShapeUtils.area( contour ) > 0.0 ) {
+			if ( ShapeUtils.area( contour ) > 0.0 ) {
 
 
 				for ( v = 0; v < n; v ++ ) verts[ v ] = v;
 				for ( v = 0; v < n; v ++ ) verts[ v ] = v;
 
 
@@ -654,7 +656,7 @@ THREE.ShapeUtils = {
 		// remove holes by cutting paths to holes and adding them to the shape
 		// remove holes by cutting paths to holes and adding them to the shape
 		var shapeWithoutHoles = removeHoles( contour, holes );
 		var shapeWithoutHoles = removeHoles( contour, holes );
 
 
-		var triangles = THREE.ShapeUtils.triangulate( shapeWithoutHoles, false ); // True returns indices for points of spooled shape
+		var triangles = ShapeUtils.triangulate( shapeWithoutHoles, false ); // True returns indices for points of spooled shape
 		//console.log( "triangles",triangles, triangles.length );
 		//console.log( "triangles",triangles, triangles.length );
 
 
 		// check all face vertices against all points map
 		// check all face vertices against all points map
@@ -685,7 +687,7 @@ THREE.ShapeUtils = {
 
 
 	isClockWise: function ( pts ) {
 	isClockWise: function ( pts ) {
 
 
-		return THREE.ShapeUtils.area( pts ) < 0;
+		return ShapeUtils.area( pts ) < 0;
 
 
 	},
 	},
 
 
@@ -763,3 +765,6 @@ THREE.ShapeUtils = {
 	} )()
 	} )()
 
 
 };
 };
+
+
+export { ShapeUtils };

+ 9 - 5
src/extras/core/Curve.js

@@ -33,13 +33,14 @@
  *	Abstract Curve base class
  *	Abstract Curve base class
  **************************************************************/
  **************************************************************/
 
 
-THREE.Curve = function () {
+function Curve () {
+	this.isCurve = true;
 
 
 };
 };
 
 
-THREE.Curve.prototype = {
+Curve.prototype = {
 
 
-	constructor: THREE.Curve,
+	constructor: Curve,
 
 
 	// Virtual base class method to overwrite and implement in subclasses
 	// Virtual base class method to overwrite and implement in subclasses
 	//	- t [0 .. 1]
 	//	- t [0 .. 1]
@@ -273,12 +274,15 @@ THREE.Curve.prototype = {
 
 
 // A Factory method for creating new curve subclasses
 // A Factory method for creating new curve subclasses
 
 
-THREE.Curve.create = function ( constructor, getPointFunc ) {
+Curve.create = function ( constructor, getPointFunc ) {
 
 
-	constructor.prototype = Object.create( THREE.Curve.prototype );
+	constructor.prototype = Object.create( Curve.prototype );
 	constructor.prototype.constructor = constructor;
 	constructor.prototype.constructor = constructor;
 	constructor.prototype.getPoint = getPointFunc;
 	constructor.prototype.getPoint = getPointFunc;
 
 
 	return constructor;
 	return constructor;
 
 
 };
 };
+
+
+export { Curve };

+ 18 - 9
src/extras/core/CurvePath.js

@@ -1,3 +1,8 @@
+import { Curve } from './Curve';
+import { Vector3 } from '../../math/Vector3';
+import { Geometry } from '../../core/Geometry';
+import { LineCurve } from '../curves/LineCurve';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  *
  *
@@ -8,7 +13,8 @@
  *  curves, but retains the api of a curve
  *  curves, but retains the api of a curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.CurvePath = function () {
+function CurvePath () {
+	this.isCurvePath = true;
 
 
 	this.curves = [];
 	this.curves = [];
 
 
@@ -16,9 +22,9 @@ THREE.CurvePath = function () {
 
 
 };
 };
 
 
-THREE.CurvePath.prototype = Object.assign( Object.create( THREE.Curve.prototype ), {
+CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 
-	constructor: THREE.CurvePath,
+	constructor: CurvePath,
 
 
 	add: function ( curve ) {
 	add: function ( curve ) {
 
 
@@ -34,7 +40,7 @@ THREE.CurvePath.prototype = Object.assign( Object.create( THREE.Curve.prototype
 
 
 		if ( ! startPoint.equals( endPoint ) ) {
 		if ( ! startPoint.equals( endPoint ) ) {
 
 
-			this.curves.push( new THREE.LineCurve( endPoint, startPoint ) );
+			this.curves.push( new LineCurve( endPoint, startPoint ) );
 
 
 		}
 		}
 
 
@@ -163,9 +169,9 @@ THREE.CurvePath.prototype = Object.assign( Object.create( THREE.Curve.prototype
 		for ( var i = 0, curves = this.curves; i < curves.length; i ++ ) {
 		for ( var i = 0, curves = this.curves; i < curves.length; i ++ ) {
 
 
 			var curve = curves[ i ];
 			var curve = curves[ i ];
-			var resolution = curve instanceof THREE.EllipseCurve ? divisions * 2
-				: curve instanceof THREE.LineCurve ? 1
-				: curve instanceof THREE.SplineCurve ? divisions * curve.points.length
+			var resolution = (curve && curve.isEllipseCurve) ? divisions * 2
+				: (curve && curve.isLineCurve) ? 1
+				: (curve && curve.isSplineCurve) ? divisions * curve.points.length
 				: divisions;
 				: divisions;
 
 
 			var pts = curve.getPoints( resolution );
 			var pts = curve.getPoints( resolution );
@@ -217,12 +223,12 @@ THREE.CurvePath.prototype = Object.assign( Object.create( THREE.Curve.prototype
 
 
 	createGeometry: function ( points ) {
 	createGeometry: function ( points ) {
 
 
-		var geometry = new THREE.Geometry();
+		var geometry = new Geometry();
 
 
 		for ( var i = 0, l = points.length; i < l; i ++ ) {
 		for ( var i = 0, l = points.length; i < l; i ++ ) {
 
 
 			var point = points[ i ];
 			var point = points[ i ];
-			geometry.vertices.push( new THREE.Vector3( point.x, point.y, point.z || 0 ) );
+			geometry.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );
 
 
 		}
 		}
 
 
@@ -231,3 +237,6 @@ THREE.CurvePath.prototype = Object.assign( Object.create( THREE.Curve.prototype
 	}
 	}
 
 
 } );
 } );
+
+
+export { CurvePath };

+ 11 - 4
src/extras/core/Font.js

@@ -1,15 +1,19 @@
+import { ShapeUtils } from '../ShapeUtils';
+import { ShapePath } from './Path';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.Font = function ( data ) {
+function Font ( data ) {
+	this.isFont = true;
 
 
 	this.data = data;
 	this.data = data;
 
 
 };
 };
 
 
-Object.assign( THREE.Font.prototype, {
+Object.assign( Font.prototype, {
 
 
 	generateShapes: function ( text, size, divisions ) {
 	generateShapes: function ( text, size, divisions ) {
 
 
@@ -40,9 +44,9 @@ Object.assign( THREE.Font.prototype, {
 
 
 			if ( ! glyph ) return;
 			if ( ! glyph ) return;
 
 
-			var path = new THREE.ShapePath();
+			var path = new ShapePath();
 
 
-			var pts = [], b2 = THREE.ShapeUtils.b2, b3 = THREE.ShapeUtils.b3;
+			var pts = [], b2 = ShapeUtils.b2, b3 = ShapeUtils.b3;
 			var x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, laste;
 			var x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, laste;
 
 
 			if ( glyph.o ) {
 			if ( glyph.o ) {
@@ -162,3 +166,6 @@ Object.assign( THREE.Font.prototype, {
 	}
 	}
 
 
 } );
 } );
+
+
+export { Font };

+ 23 - 133
src/extras/core/Path.js

@@ -1,13 +1,20 @@
+import { PathPrototype } from './PathPrototype';
+import { Shape } from './Shape';
+import { ShapeUtils } from '../ShapeUtils';
+import { Vector2 } from '../../math/Vector2';
+import { CurvePath } from './CurvePath';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * Creates free form 2d path using series of points, lines or curves.
  * Creates free form 2d path using series of points, lines or curves.
  *
  *
  **/
  **/
 
 
-THREE.Path = function ( points ) {
+function Path ( points ) {
+	this.isPath = true;
 
 
-	THREE.CurvePath.call( this );
-	this.currentPoint = new THREE.Vector2();
+	CurvePath.call( this );
+	this.currentPoint = new Vector2();
 
 
 	if ( points ) {
 	if ( points ) {
 
 
@@ -17,140 +24,20 @@ THREE.Path = function ( points ) {
 
 
 };
 };
 
 
-THREE.Path.prototype = Object.assign( Object.create( THREE.CurvePath.prototype ), {
-
-	constructor: THREE.Path,
-
-	// Create path using straight lines to connect all points
-	// - vectors: array of Vector2
-	fromPoints: function ( vectors ) {
-
-		this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
-
-		for ( var i = 1, l = vectors.length; i < l; i ++ ) {
-
-			this.lineTo( vectors[ i ].x, vectors[ i ].y );
-
-		}
-
-	},
-
-	moveTo: function ( x, y ) {
-
-		this.currentPoint.set( x, y ); // TODO consider referencing vectors instead of copying?
-
-	},
-
-	lineTo: function ( x, y ) {
-
-		var curve = new THREE.LineCurve( this.currentPoint.clone(), new THREE.Vector2( x, y ) );
-		this.curves.push( curve );
-
-		this.currentPoint.set( x, y );
-
-	},
-
-	quadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {
-
-		var curve = new THREE.QuadraticBezierCurve(
-			this.currentPoint.clone(),
-			new THREE.Vector2( aCPx, aCPy ),
-			new THREE.Vector2( aX, aY )
-		);
-
-		this.curves.push( curve );
-
-		this.currentPoint.set( aX, aY );
-
-	},
-
-	bezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {
-
-		var curve = new THREE.CubicBezierCurve(
-			this.currentPoint.clone(),
-			new THREE.Vector2( aCP1x, aCP1y ),
-			new THREE.Vector2( aCP2x, aCP2y ),
-			new THREE.Vector2( aX, aY )
-		);
-
-		this.curves.push( curve );
-
-		this.currentPoint.set( aX, aY );
-
-	},
-
-	splineThru: function ( pts /*Array of Vector*/ ) {
-
-		var npts = [ this.currentPoint.clone() ].concat( pts );
-
-		var curve = new THREE.SplineCurve( npts );
-		this.curves.push( curve );
-
-		this.currentPoint.copy( pts[ pts.length - 1 ] );
-
-	},
-
-	arc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
-
-		var x0 = this.currentPoint.x;
-		var y0 = this.currentPoint.y;
-
-		this.absarc( aX + x0, aY + y0, aRadius,
-			aStartAngle, aEndAngle, aClockwise );
-
-	},
-
-	absarc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
-
-		this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
-
-	},
-
-	ellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
-
-		var x0 = this.currentPoint.x;
-		var y0 = this.currentPoint.y;
-
-		this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
-
-	},
-
-	absellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
-
-		var curve = new THREE.EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
-
-		if ( this.curves.length > 0 ) {
-
-			// if a previous curve is present, attempt to join
-			var firstPoint = curve.getPoint( 0 );
-
-			if ( ! firstPoint.equals( this.currentPoint ) ) {
-
-				this.lineTo( firstPoint.x, firstPoint.y );
-
-			}
-
-		}
-
-		this.curves.push( curve );
-
-		var lastPoint = curve.getPoint( 1 );
-		this.currentPoint.copy( lastPoint );
-
-	}
-
-} );
+Path.prototype = PathPrototype;
+PathPrototype.constructor = Path;
 
 
 
 
 // minimal class for proxing functions to Path. Replaces old "extractSubpaths()"
 // minimal class for proxing functions to Path. Replaces old "extractSubpaths()"
-THREE.ShapePath = function() {
+function ShapePath() {
+	this.isShapePath = true;
 	this.subPaths = [];
 	this.subPaths = [];
 	this.currentPath = null;
 	this.currentPath = null;
 }
 }
 
 
-THREE.ShapePath.prototype = {
+ShapePath.prototype = {
 	moveTo: function ( x, y ) {
 	moveTo: function ( x, y ) {
-		this.currentPath = new THREE.Path();
+		this.currentPath = new Path();
 		this.subPaths.push(this.currentPath);
 		this.subPaths.push(this.currentPath);
 		this.currentPath.moveTo( x, y );
 		this.currentPath.moveTo( x, y );
 	},
 	},
@@ -177,7 +64,7 @@ THREE.ShapePath.prototype = {
 
 
 				var tmpPath = inSubpaths[ i ];
 				var tmpPath = inSubpaths[ i ];
 
 
-				var tmpShape = new THREE.Shape();
+				var tmpShape = new Shape();
 				tmpShape.curves = tmpPath.curves;
 				tmpShape.curves = tmpPath.curves;
 
 
 				shapes.push( tmpShape );
 				shapes.push( tmpShape );
@@ -247,7 +134,7 @@ THREE.ShapePath.prototype = {
 
 
 		}
 		}
 
 
-		var isClockWise = THREE.ShapeUtils.isClockWise;
+		var isClockWise = ShapeUtils.isClockWise;
 
 
 		var subPaths = this.subPaths;
 		var subPaths = this.subPaths;
 		if ( subPaths.length === 0 ) return [];
 		if ( subPaths.length === 0 ) return [];
@@ -260,7 +147,7 @@ THREE.ShapePath.prototype = {
 		if ( subPaths.length === 1 ) {
 		if ( subPaths.length === 1 ) {
 
 
 			tmpPath = subPaths[ 0 ];
 			tmpPath = subPaths[ 0 ];
-			tmpShape = new THREE.Shape();
+			tmpShape = new Shape();
 			tmpShape.curves = tmpPath.curves;
 			tmpShape.curves = tmpPath.curves;
 			shapes.push( tmpShape );
 			shapes.push( tmpShape );
 			return shapes;
 			return shapes;
@@ -292,7 +179,7 @@ THREE.ShapePath.prototype = {
 
 
 				if ( ( ! holesFirst ) && ( newShapes[ mainIdx ] ) )	mainIdx ++;
 				if ( ( ! holesFirst ) && ( newShapes[ mainIdx ] ) )	mainIdx ++;
 
 
-				newShapes[ mainIdx ] = { s: new THREE.Shape(), p: tmpPoints };
+				newShapes[ mainIdx ] = { s: new Shape(), p: tmpPoints };
 				newShapes[ mainIdx ].s.curves = tmpPath.curves;
 				newShapes[ mainIdx ].s.curves = tmpPath.curves;
 
 
 				if ( holesFirst )	mainIdx ++;
 				if ( holesFirst )	mainIdx ++;
@@ -394,3 +281,6 @@ THREE.ShapePath.prototype = {
 
 
 	}
 	}
 }
 }
+
+
+export { ShapePath, Path };

+ 131 - 0
src/extras/core/PathPrototype.js

@@ -0,0 +1,131 @@
+import { CurvePath } from './CurvePath';
+import { EllipseCurve } from '../curves/EllipseCurve';
+import { SplineCurve } from '../curves/SplineCurve';
+import { Vector2 } from '../../math/Vector2';
+import { CubicBezierCurve } from '../curves/CubicBezierCurve';
+import { QuadraticBezierCurve } from '../curves/QuadraticBezierCurve';
+import { LineCurve } from '../curves/LineCurve';
+
+var PathPrototype;
+
+PathPrototype = Object.assign( Object.create( CurvePath.prototype ), {
+
+	fromPoints: function ( vectors ) {
+
+		this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
+
+		for ( var i = 1, l = vectors.length; i < l; i ++ ) {
+
+			this.lineTo( vectors[ i ].x, vectors[ i ].y );
+
+		}
+
+	},
+
+	moveTo: function ( x, y ) {
+
+		this.currentPoint.set( x, y ); // TODO consider referencing vectors instead of copying?
+
+	},
+
+	lineTo: function ( x, y ) {
+
+		var curve = new LineCurve( this.currentPoint.clone(), new Vector2( x, y ) );
+		this.curves.push( curve );
+
+		this.currentPoint.set( x, y );
+
+	},
+
+	quadraticCurveTo: function ( aCPx, aCPy, aX, aY ) {
+
+		var curve = new QuadraticBezierCurve(
+			this.currentPoint.clone(),
+			new Vector2( aCPx, aCPy ),
+			new Vector2( aX, aY )
+		);
+
+		this.curves.push( curve );
+
+		this.currentPoint.set( aX, aY );
+
+	},
+
+	bezierCurveTo: function ( aCP1x, aCP1y, aCP2x, aCP2y, aX, aY ) {
+
+		var curve = new CubicBezierCurve(
+			this.currentPoint.clone(),
+			new Vector2( aCP1x, aCP1y ),
+			new Vector2( aCP2x, aCP2y ),
+			new Vector2( aX, aY )
+		);
+
+		this.curves.push( curve );
+
+		this.currentPoint.set( aX, aY );
+
+	},
+
+	splineThru: function ( pts /*Array of Vector*/ ) {
+
+		var npts = [ this.currentPoint.clone() ].concat( pts );
+
+		var curve = new SplineCurve( npts );
+		this.curves.push( curve );
+
+		this.currentPoint.copy( pts[ pts.length - 1 ] );
+
+	},
+
+	arc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
+
+		var x0 = this.currentPoint.x;
+		var y0 = this.currentPoint.y;
+
+		this.absarc( aX + x0, aY + y0, aRadius,
+			aStartAngle, aEndAngle, aClockwise );
+
+	},
+
+	absarc: function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
+
+		this.absellipse( aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
+
+	},
+
+	ellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
+
+		var x0 = this.currentPoint.x;
+		var y0 = this.currentPoint.y;
+
+		this.absellipse( aX + x0, aY + y0, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
+
+	},
+
+	absellipse: function ( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
+
+		var curve = new EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation );
+
+		if ( this.curves.length > 0 ) {
+
+			// if a previous curve is present, attempt to join
+			var firstPoint = curve.getPoint( 0 );
+
+			if ( ! firstPoint.equals( this.currentPoint ) ) {
+
+				this.lineTo( firstPoint.x, firstPoint.y );
+
+			}
+
+		}
+
+		this.curves.push( curve );
+
+		var lastPoint = curve.getPoint( 1 );
+		this.currentPoint.copy( lastPoint );
+
+	}
+
+} )
+
+export { PathPrototype };

+ 15 - 6
src/extras/core/Shape.js

@@ -1,3 +1,8 @@
+import { PathPrototype } from './PathPrototype';
+import { ShapeGeometry } from '../geometries/ShapeGeometry';
+import { ExtrudeGeometry } from '../geometries/ExtrudeGeometry';
+import { Path } from './Path';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * Defines a 2d shape plane using paths.
  * Defines a 2d shape plane using paths.
@@ -9,23 +14,24 @@
 // STEP 3a - Extract points from each shape, turn to vertices
 // STEP 3a - Extract points from each shape, turn to vertices
 // STEP 3b - Triangulate each shape, add faces.
 // STEP 3b - Triangulate each shape, add faces.
 
 
-THREE.Shape = function () {
+function Shape () {
+	this.isShape = true;
 
 
-	THREE.Path.apply( this, arguments );
+	Path.apply( this, arguments );
 
 
 	this.holes = [];
 	this.holes = [];
 
 
 };
 };
 
 
-THREE.Shape.prototype = Object.assign( Object.create( THREE.Path.prototype ), {
+Shape.prototype = Object.assign( Object.create( PathPrototype ), {
 
 
-	constructor: THREE.Shape,
+	constructor: Shape,
 
 
 	// Convenience method to return ExtrudeGeometry
 	// Convenience method to return ExtrudeGeometry
 
 
 	extrude: function ( options ) {
 	extrude: function ( options ) {
 
 
-		return new THREE.ExtrudeGeometry( this, options );
+		return new ExtrudeGeometry( this, options );
 
 
 	},
 	},
 
 
@@ -33,7 +39,7 @@ THREE.Shape.prototype = Object.assign( Object.create( THREE.Path.prototype ), {
 
 
 	makeGeometry: function ( options ) {
 	makeGeometry: function ( options ) {
 
 
-		return new THREE.ShapeGeometry( this, options );
+		return new ShapeGeometry( this, options );
 
 
 	},
 	},
 
 
@@ -71,3 +77,6 @@ THREE.Shape.prototype = Object.assign( Object.create( THREE.Path.prototype ), {
 	}
 	}
 
 
 } );
 } );
+
+
+export { Shape };

+ 10 - 4
src/extras/curves/ArcCurve.js

@@ -1,12 +1,18 @@
+import { EllipseCurve } from './EllipseCurve';
+
 /**************************************************************
 /**************************************************************
  *	Arc curve
  *	Arc curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.ArcCurve = function ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
+function ArcCurve ( aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise ) {
+	this.isArcCurve = this.isEllipseCurve = this.isCurve = true;
 
 
-	THREE.EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
+	EllipseCurve.call( this, aX, aY, aRadius, aRadius, aStartAngle, aEndAngle, aClockwise );
 
 
 };
 };
 
 
-THREE.ArcCurve.prototype = Object.create( THREE.EllipseCurve.prototype );
-THREE.ArcCurve.prototype.constructor = THREE.ArcCurve;
+ArcCurve.prototype = Object.create( EllipseCurve.prototype );
+ArcCurve.prototype.constructor = ArcCurve;
+
+
+export { ArcCurve };

+ 12 - 4
src/extras/curves/CatmullRomCurve3.js

@@ -1,3 +1,8 @@
+import { Vector3 } from '../../math/Vector3';
+import { Curve } from '../core/Curve';
+
+var CatmullRomCurve3;
+
 /**
 /**
  * @author zz85 https://github.com/zz85
  * @author zz85 https://github.com/zz85
  *
  *
@@ -9,10 +14,10 @@
  * curve.tension is used for catmullrom which defaults to 0.5
  * curve.tension is used for catmullrom which defaults to 0.5
  */
  */
 
 
-THREE.CatmullRomCurve3 = ( function() {
+CatmullRomCurve3 = ( function() {
 
 
 	var
 	var
-		tmp = new THREE.Vector3(),
+		tmp = new Vector3(),
 		px = new CubicPoly(),
 		px = new CubicPoly(),
 		py = new CubicPoly(),
 		py = new CubicPoly(),
 		pz = new CubicPoly();
 		pz = new CubicPoly();
@@ -79,7 +84,7 @@ THREE.CatmullRomCurve3 = ( function() {
 	};
 	};
 
 
 	// Subclass Three.js curve
 	// Subclass Three.js curve
-	return THREE.Curve.create(
+	return Curve.create(
 
 
 		function ( p /* array of Vector3 */ ) {
 		function ( p /* array of Vector3 */ ) {
 
 
@@ -167,7 +172,7 @@ THREE.CatmullRomCurve3 = ( function() {
 
 
 			}
 			}
 
 
-			var v = new THREE.Vector3(
+			var v = new Vector3(
 				px.calc( weight ),
 				px.calc( weight ),
 				py.calc( weight ),
 				py.calc( weight ),
 				pz.calc( weight )
 				pz.calc( weight )
@@ -180,3 +185,6 @@ THREE.CatmullRomCurve3 = ( function() {
 	);
 	);
 
 
 } )();
 } )();
+
+
+export { CatmullRomCurve3 };

+ 9 - 3
src/extras/curves/ClosedSplineCurve3.js

@@ -1,16 +1,22 @@
+import { CatmullRomCurve3 } from './CatmullRomCurve3';
+
 /**************************************************************
 /**************************************************************
  *	Closed Spline 3D curve
  *	Closed Spline 3D curve
  **************************************************************/
  **************************************************************/
 
 
 
 
-THREE.ClosedSplineCurve3 = function ( points ) {
+function ClosedSplineCurve3 ( points ) {
+	this.isClosedSplineCurve3 = this.isCatmullRomCurve3 = true;
 
 
 	console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.' );
 	console.warn( 'THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.' );
 
 
-	THREE.CatmullRomCurve3.call( this, points );
+	CatmullRomCurve3.call( this, points );
 	this.type = 'catmullrom';
 	this.type = 'catmullrom';
 	this.closed = true;
 	this.closed = true;
 
 
 };
 };
 
 
-THREE.ClosedSplineCurve3.prototype = Object.create( THREE.CatmullRomCurve3.prototype );
+ClosedSplineCurve3.prototype = Object.create( CatmullRomCurve3.prototype );
+
+
+export { ClosedSplineCurve3 };

+ 18 - 9
src/extras/curves/CubicBezierCurve.js

@@ -1,8 +1,14 @@
+import { Curve } from '../core/Curve';
+import { Vector2 } from '../../math/Vector2';
+import { CurveUtils } from '../CurveUtils';
+import { ShapeUtils } from '../ShapeUtils';
+
 /**************************************************************
 /**************************************************************
  *	Cubic Bezier curve
  *	Cubic Bezier curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.CubicBezierCurve = function ( v0, v1, v2, v3 ) {
+function CubicBezierCurve ( v0, v1, v2, v3 ) {
+	this.isCubicBezierCurve = this.isCurve = true;
 
 
 	this.v0 = v0;
 	this.v0 = v0;
 	this.v1 = v1;
 	this.v1 = v1;
@@ -11,27 +17,30 @@ THREE.CubicBezierCurve = function ( v0, v1, v2, v3 ) {
 
 
 };
 };
 
 
-THREE.CubicBezierCurve.prototype = Object.create( THREE.Curve.prototype );
-THREE.CubicBezierCurve.prototype.constructor = THREE.CubicBezierCurve;
+CubicBezierCurve.prototype = Object.create( Curve.prototype );
+CubicBezierCurve.prototype.constructor = CubicBezierCurve;
 
 
-THREE.CubicBezierCurve.prototype.getPoint = function ( t ) {
+CubicBezierCurve.prototype.getPoint = function ( t ) {
 
 
-	var b3 = THREE.ShapeUtils.b3;
+	var b3 = ShapeUtils.b3;
 
 
-	return new THREE.Vector2( 
+	return new Vector2( 
 		b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 		b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 		b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 		b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 	);
 	);
 
 
 };
 };
 
 
-THREE.CubicBezierCurve.prototype.getTangent = function( t ) {
+CubicBezierCurve.prototype.getTangent = function( t ) {
 
 
-	var tangentCubicBezier = THREE.CurveUtils.tangentCubicBezier;
+	var tangentCubicBezier = CurveUtils.tangentCubicBezier;
 
 
-	return new THREE.Vector2( 
+	return new Vector2( 
 		tangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 		tangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 		tangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 		tangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 	).normalize();
 	).normalize();
 
 
 };
 };
+
+
+export { CubicBezierCurve };

+ 12 - 3
src/extras/curves/CubicBezierCurve3.js

@@ -1,8 +1,14 @@
+import { Vector3 } from '../../math/Vector3';
+import { ShapeUtils } from '../ShapeUtils';
+import { Curve } from '../core/Curve';
+
+var CubicBezierCurve3;
+
 /**************************************************************
 /**************************************************************
  *	Cubic Bezier 3D curve
  *	Cubic Bezier 3D curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.CubicBezierCurve3 = THREE.Curve.create(
+CubicBezierCurve3 = Curve.create(
 
 
 	function ( v0, v1, v2, v3 ) {
 	function ( v0, v1, v2, v3 ) {
 
 
@@ -15,9 +21,9 @@ THREE.CubicBezierCurve3 = THREE.Curve.create(
 
 
 	function ( t ) {
 	function ( t ) {
 
 
-		var b3 = THREE.ShapeUtils.b3;
+		var b3 = ShapeUtils.b3;
 
 
-		return new THREE.Vector3(
+		return new Vector3(
 			b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 			b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
 			b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ),
 			b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ),
 			b3( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z )
 			b3( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z )
@@ -26,3 +32,6 @@ THREE.CubicBezierCurve3 = THREE.Curve.create(
 	}
 	}
 
 
 );
 );
+
+
+export { CubicBezierCurve3 };

+ 12 - 5
src/extras/curves/EllipseCurve.js

@@ -1,8 +1,12 @@
+import { Curve } from '../core/Curve';
+import { Vector2 } from '../../math/Vector2';
+
 /**************************************************************
 /**************************************************************
  *	Ellipse curve
  *	Ellipse curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.EllipseCurve = function( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
+function EllipseCurve( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle, aClockwise, aRotation ) {
+	this.isEllipseCurve = this.isCurve = true;
 
 
 	this.aX = aX;
 	this.aX = aX;
 	this.aY = aY;
 	this.aY = aY;
@@ -19,10 +23,10 @@ THREE.EllipseCurve = function( aX, aY, xRadius, yRadius, aStartAngle, aEndAngle,
 
 
 };
 };
 
 
-THREE.EllipseCurve.prototype = Object.create( THREE.Curve.prototype );
-THREE.EllipseCurve.prototype.constructor = THREE.EllipseCurve;
+EllipseCurve.prototype = Object.create( Curve.prototype );
+EllipseCurve.prototype.constructor = EllipseCurve;
 
 
-THREE.EllipseCurve.prototype.getPoint = function( t ) {
+EllipseCurve.prototype.getPoint = function( t ) {
 
 
 	var twoPi = Math.PI * 2;
 	var twoPi = Math.PI * 2;
 	var deltaAngle = this.aEndAngle - this.aStartAngle;
 	var deltaAngle = this.aEndAngle - this.aStartAngle;
@@ -78,6 +82,9 @@ THREE.EllipseCurve.prototype.getPoint = function( t ) {
 
 
 	}
 	}
 
 
-	return new THREE.Vector2( x, y );
+	return new Vector2( x, y );
 
 
 };
 };
+
+
+export { EllipseCurve };

+ 12 - 6
src/extras/curves/LineCurve.js

@@ -1,18 +1,21 @@
+import { Curve } from '../core/Curve';
+
 /**************************************************************
 /**************************************************************
  *	Line
  *	Line
  **************************************************************/
  **************************************************************/
 
 
-THREE.LineCurve = function ( v1, v2 ) {
+function LineCurve ( v1, v2 ) {
+	this.isLineCurve = this.isCurve = true;
 
 
 	this.v1 = v1;
 	this.v1 = v1;
 	this.v2 = v2;
 	this.v2 = v2;
 
 
 };
 };
 
 
-THREE.LineCurve.prototype = Object.create( THREE.Curve.prototype );
-THREE.LineCurve.prototype.constructor = THREE.LineCurve;
+LineCurve.prototype = Object.create( Curve.prototype );
+LineCurve.prototype.constructor = LineCurve;
 
 
-THREE.LineCurve.prototype.getPoint = function ( t ) {
+LineCurve.prototype.getPoint = function ( t ) {
 
 
 	if ( t === 1 ) {
 	if ( t === 1 ) {
 
 
@@ -29,16 +32,19 @@ THREE.LineCurve.prototype.getPoint = function ( t ) {
 
 
 // Line curve is linear, so we can overwrite default getPointAt
 // Line curve is linear, so we can overwrite default getPointAt
 
 
-THREE.LineCurve.prototype.getPointAt = function ( u ) {
+LineCurve.prototype.getPointAt = function ( u ) {
 
 
 	return this.getPoint( u );
 	return this.getPoint( u );
 
 
 };
 };
 
 
-THREE.LineCurve.prototype.getTangent = function( t ) {
+LineCurve.prototype.getTangent = function( t ) {
 
 
 	var tangent = this.v2.clone().sub( this.v1 );
 	var tangent = this.v2.clone().sub( this.v1 );
 
 
 	return tangent.normalize();
 	return tangent.normalize();
 
 
 };
 };
+
+
+export { LineCurve };

+ 10 - 2
src/extras/curves/LineCurve3.js

@@ -1,8 +1,13 @@
+import { Vector3 } from '../../math/Vector3';
+import { Curve } from '../core/Curve';
+
+var LineCurve3;
+
 /**************************************************************
 /**************************************************************
  *	Line3D
  *	Line3D
  **************************************************************/
  **************************************************************/
 
 
-THREE.LineCurve3 = THREE.Curve.create(
+LineCurve3 = Curve.create(
 
 
 	function ( v1, v2 ) {
 	function ( v1, v2 ) {
 
 
@@ -19,7 +24,7 @@ THREE.LineCurve3 = THREE.Curve.create(
 
 
 		}
 		}
 
 
-		var vector = new THREE.Vector3();
+		var vector = new Vector3();
 
 
 		vector.subVectors( this.v2, this.v1 ); // diff
 		vector.subVectors( this.v2, this.v1 ); // diff
 		vector.multiplyScalar( t );
 		vector.multiplyScalar( t );
@@ -30,3 +35,6 @@ THREE.LineCurve3 = THREE.Curve.create(
 	}
 	}
 
 
 );
 );
+
+
+export { LineCurve3 };

+ 18 - 9
src/extras/curves/QuadraticBezierCurve.js

@@ -1,9 +1,15 @@
+import { Curve } from '../core/Curve';
+import { Vector2 } from '../../math/Vector2';
+import { CurveUtils } from '../CurveUtils';
+import { ShapeUtils } from '../ShapeUtils';
+
 /**************************************************************
 /**************************************************************
  *	Quadratic Bezier curve
  *	Quadratic Bezier curve
  **************************************************************/
  **************************************************************/
 
 
 
 
-THREE.QuadraticBezierCurve = function ( v0, v1, v2 ) {
+function QuadraticBezierCurve ( v0, v1, v2 ) {
+	this.isQuadraticBezierCurve = this.isCurve = true;
 
 
 	this.v0 = v0;
 	this.v0 = v0;
 	this.v1 = v1;
 	this.v1 = v1;
@@ -11,15 +17,15 @@ THREE.QuadraticBezierCurve = function ( v0, v1, v2 ) {
 
 
 };
 };
 
 
-THREE.QuadraticBezierCurve.prototype = Object.create( THREE.Curve.prototype );
-THREE.QuadraticBezierCurve.prototype.constructor = THREE.QuadraticBezierCurve;
+QuadraticBezierCurve.prototype = Object.create( Curve.prototype );
+QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
 
 
 
 
-THREE.QuadraticBezierCurve.prototype.getPoint = function ( t ) {
+QuadraticBezierCurve.prototype.getPoint = function ( t ) {
 
 
-	var b2 = THREE.ShapeUtils.b2;
+	var b2 = ShapeUtils.b2;
 
 
-	return new THREE.Vector2(
+	return new Vector2(
 		b2( t, this.v0.x, this.v1.x, this.v2.x ),
 		b2( t, this.v0.x, this.v1.x, this.v2.x ),
 		b2( t, this.v0.y, this.v1.y, this.v2.y )
 		b2( t, this.v0.y, this.v1.y, this.v2.y )
 	);
 	);
@@ -27,13 +33,16 @@ THREE.QuadraticBezierCurve.prototype.getPoint = function ( t ) {
 };
 };
 
 
 
 
-THREE.QuadraticBezierCurve.prototype.getTangent = function( t ) {
+QuadraticBezierCurve.prototype.getTangent = function( t ) {
 
 
-	var tangentQuadraticBezier = THREE.CurveUtils.tangentQuadraticBezier;
+	var tangentQuadraticBezier = CurveUtils.tangentQuadraticBezier;
 
 
-	return new THREE.Vector2(
+	return new Vector2(
 		tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
 		tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
 		tangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y )
 		tangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y )
 	).normalize();
 	).normalize();
 
 
 };
 };
+
+
+export { QuadraticBezierCurve };

+ 12 - 3
src/extras/curves/QuadraticBezierCurve3.js

@@ -1,8 +1,14 @@
+import { Vector3 } from '../../math/Vector3';
+import { ShapeUtils } from '../ShapeUtils';
+import { Curve } from '../core/Curve';
+
+var QuadraticBezierCurve3;
+
 /**************************************************************
 /**************************************************************
  *	Quadratic Bezier 3D curve
  *	Quadratic Bezier 3D curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.QuadraticBezierCurve3 = THREE.Curve.create(
+QuadraticBezierCurve3 = Curve.create(
 
 
 	function ( v0, v1, v2 ) {
 	function ( v0, v1, v2 ) {
 
 
@@ -14,9 +20,9 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create(
 
 
 	function ( t ) {
 	function ( t ) {
 
 
-		var b2 = THREE.ShapeUtils.b2;		
+		var b2 = ShapeUtils.b2;		
 
 
-		return new THREE.Vector3(
+		return new Vector3(
 			b2( t, this.v0.x, this.v1.x, this.v2.x ),
 			b2( t, this.v0.x, this.v1.x, this.v2.x ),
 			b2( t, this.v0.y, this.v1.y, this.v2.y ),
 			b2( t, this.v0.y, this.v1.y, this.v2.y ),
 			b2( t, this.v0.z, this.v1.z, this.v2.z )
 			b2( t, this.v0.z, this.v1.z, this.v2.z )
@@ -25,3 +31,6 @@ THREE.QuadraticBezierCurve3 = THREE.Curve.create(
 	}
 	}
 
 
 );
 );
+
+
+export { QuadraticBezierCurve3 };

+ 14 - 6
src/extras/curves/SplineCurve.js

@@ -1,17 +1,22 @@
+import { Curve } from '../core/Curve';
+import { Vector2 } from '../../math/Vector2';
+import { CurveUtils } from '../CurveUtils';
+
 /**************************************************************
 /**************************************************************
  *	Spline curve
  *	Spline curve
  **************************************************************/
  **************************************************************/
 
 
-THREE.SplineCurve = function ( points /* array of Vector2 */ ) {
+function SplineCurve ( points /* array of Vector2 */ ) {
+	this.isSplineCurve = this.isCurve = true;
 
 
 	this.points = ( points == undefined ) ? [] : points;
 	this.points = ( points == undefined ) ? [] : points;
 
 
 };
 };
 
 
-THREE.SplineCurve.prototype = Object.create( THREE.Curve.prototype );
-THREE.SplineCurve.prototype.constructor = THREE.SplineCurve;
+SplineCurve.prototype = Object.create( Curve.prototype );
+SplineCurve.prototype.constructor = SplineCurve;
 
 
-THREE.SplineCurve.prototype.getPoint = function ( t ) {
+SplineCurve.prototype.getPoint = function ( t ) {
 
 
 	var points = this.points;
 	var points = this.points;
 	var point = ( points.length - 1 ) * t;
 	var point = ( points.length - 1 ) * t;
@@ -24,11 +29,14 @@ THREE.SplineCurve.prototype.getPoint = function ( t ) {
 	var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
 	var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
 	var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
 	var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
 
 
-	var interpolate = THREE.CurveUtils.interpolate;
+	var interpolate = CurveUtils.interpolate;
 
 
-	return new THREE.Vector2(
+	return new Vector2(
 		interpolate( point0.x, point1.x, point2.x, point3.x, weight ),
 		interpolate( point0.x, point1.x, point2.x, point3.x, weight ),
 		interpolate( point0.y, point1.y, point2.y, point3.y, weight )
 		interpolate( point0.y, point1.y, point2.y, point3.y, weight )
 	);
 	);
 
 
 };
 };
+
+
+export { SplineCurve };

+ 12 - 3
src/extras/curves/SplineCurve3.js

@@ -1,9 +1,15 @@
+import { Vector3 } from '../../math/Vector3';
+import { CurveUtils } from '../CurveUtils';
+import { Curve } from '../core/Curve';
+
+var SplineCurve3;
+
 /**************************************************************
 /**************************************************************
  *	Spline 3D curve
  *	Spline 3D curve
  **************************************************************/
  **************************************************************/
 
 
 
 
-THREE.SplineCurve3 = THREE.Curve.create(
+SplineCurve3 = Curve.create(
 
 
 	function ( points /* array of Vector3 */ ) {
 	function ( points /* array of Vector3 */ ) {
 
 
@@ -25,9 +31,9 @@ THREE.SplineCurve3 = THREE.Curve.create(
 		var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
 		var point2 = points[ intPoint > points.length - 2 ? points.length - 1 : intPoint + 1 ];
 		var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
 		var point3 = points[ intPoint > points.length - 3 ? points.length - 1 : intPoint + 2 ];
 
 
-		var interpolate = THREE.CurveUtils.interpolate;
+		var interpolate = CurveUtils.interpolate;
 
 
-		return new THREE.Vector3(
+		return new Vector3(
 			interpolate( point0.x, point1.x, point2.x, point3.x, weight ),
 			interpolate( point0.x, point1.x, point2.x, point3.x, weight ),
 			interpolate( point0.y, point1.y, point2.y, point3.y, weight ),
 			interpolate( point0.y, point1.y, point2.y, point3.y, weight ),
 			interpolate( point0.z, point1.z, point2.z, point3.z, weight )
 			interpolate( point0.z, point1.z, point2.z, point3.z, weight )
@@ -36,3 +42,6 @@ THREE.SplineCurve3 = THREE.Curve.create(
 	}
 	}
 
 
 );
 );
+
+
+export { SplineCurve3 };

+ 17 - 9
src/extras/geometries/BoxBufferGeometry.js

@@ -1,10 +1,15 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-THREE.BoxBufferGeometry = function ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
+function BoxBufferGeometry ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
+	this.isBoxBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'BoxBufferGeometry';
 	this.type = 'BoxBufferGeometry';
 
 
@@ -52,10 +57,10 @@ THREE.BoxBufferGeometry = function ( width, height, depth, widthSegments, height
 	buildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth,  widthSegments, heightSegments, 5 ); // nz
 	buildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth,  widthSegments, heightSegments, 5 ); // nz
 
 
 	// build geometry
 	// build geometry
-	this.setIndex( new THREE.BufferAttribute( indices, 1 ) );
-	this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-	this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
-	this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+	this.setIndex( new BufferAttribute( indices, 1 ) );
+	this.addAttribute( 'position', new BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'normal', new BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new BufferAttribute( uvs, 2 ) );
 
 
 	// helper functions
 	// helper functions
 
 
@@ -100,7 +105,7 @@ THREE.BoxBufferGeometry = function ( width, height, depth, widthSegments, height
 		var vertexCounter = 0;
 		var vertexCounter = 0;
 		var groupCount = 0;
 		var groupCount = 0;
 
 
-		var vector = new THREE.Vector3();
+		var vector = new Vector3();
 
 
 		// generate vertices, normals and uvs
 		// generate vertices, normals and uvs
 
 
@@ -190,5 +195,8 @@ THREE.BoxBufferGeometry = function ( width, height, depth, widthSegments, height
 
 
 };
 };
 
 
-THREE.BoxBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.BoxBufferGeometry.prototype.constructor = THREE.BoxBufferGeometry;
+BoxBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+BoxBufferGeometry.prototype.constructor = BoxBufferGeometry;
+
+
+export { BoxBufferGeometry };

+ 15 - 6
src/extras/geometries/BoxGeometry.js

@@ -1,11 +1,17 @@
+import { Geometry } from '../../core/Geometry';
+import { BoxBufferGeometry } from './BoxBufferGeometry';
+
+var CubeGeometry;
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
  */
  */
 
 
-THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
+function BoxGeometry ( width, height, depth, widthSegments, heightSegments, depthSegments ) {
+	this.isBoxGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'BoxGeometry';
 	this.type = 'BoxGeometry';
 
 
@@ -18,12 +24,15 @@ THREE.BoxGeometry = function ( width, height, depth, widthSegments, heightSegmen
 		depthSegments: depthSegments
 		depthSegments: depthSegments
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );
+	this.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );
 	this.mergeVertices();
 	this.mergeVertices();
 
 
 };
 };
 
 
-THREE.BoxGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.BoxGeometry.prototype.constructor = THREE.BoxGeometry;
+BoxGeometry.prototype = Object.create( Geometry.prototype );
+BoxGeometry.prototype.constructor = BoxGeometry;
+
+CubeGeometry = BoxGeometry;
+
 
 
-THREE.CubeGeometry = THREE.BoxGeometry;
+export { CubeGeometry, BoxGeometry };

+ 18 - 9
src/extras/geometries/CircleBufferGeometry.js

@@ -1,10 +1,16 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { Sphere } from '../../math/Sphere';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  */
  */
 
 
-THREE.CircleBufferGeometry = function ( radius, segments, thetaStart, thetaLength ) {
+function CircleBufferGeometry ( radius, segments, thetaStart, thetaLength ) {
+	this.isCircleBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'CircleBufferGeometry';
 	this.type = 'CircleBufferGeometry';
 
 
@@ -54,14 +60,17 @@ THREE.CircleBufferGeometry = function ( radius, segments, thetaStart, thetaLengt
 
 
 	}
 	}
 
 
-	this.setIndex( new THREE.BufferAttribute( new Uint16Array( indices ), 1 ) );
-	this.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
-	this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
-	this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+	this.setIndex( new BufferAttribute( new Uint16Array( indices ), 1 ) );
+	this.addAttribute( 'position', new BufferAttribute( positions, 3 ) );
+	this.addAttribute( 'normal', new BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new BufferAttribute( uvs, 2 ) );
 
 
-	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
+	this.boundingSphere = new Sphere( new Vector3(), radius );
 
 
 };
 };
 
 
-THREE.CircleBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.CircleBufferGeometry.prototype.constructor = THREE.CircleBufferGeometry;
+CircleBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+CircleBufferGeometry.prototype.constructor = CircleBufferGeometry;
+
+
+export { CircleBufferGeometry };

+ 12 - 5
src/extras/geometries/CircleGeometry.js

@@ -1,10 +1,14 @@
+import { Geometry } from '../../core/Geometry';
+import { CircleBufferGeometry } from './CircleBufferGeometry';
+
 /**
 /**
  * @author hughes
  * @author hughes
  */
  */
 
 
-THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
+function CircleGeometry ( radius, segments, thetaStart, thetaLength ) {
+	this.isCircleGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'CircleGeometry';
 	this.type = 'CircleGeometry';
 
 
@@ -15,9 +19,12 @@ THREE.CircleGeometry = function ( radius, segments, thetaStart, thetaLength ) {
 		thetaLength: thetaLength
 		thetaLength: thetaLength
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
+	this.fromBufferGeometry( new CircleBufferGeometry( radius, segments, thetaStart, thetaLength ) );
 
 
 };
 };
 
 
-THREE.CircleGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.CircleGeometry.prototype.constructor = THREE.CircleGeometry;
+CircleGeometry.prototype = Object.create( Geometry.prototype );
+CircleGeometry.prototype.constructor = CircleGeometry;
+
+
+export { CircleGeometry };

+ 11 - 4
src/extras/geometries/ConeBufferGeometry.js

@@ -1,13 +1,17 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { CylinderBufferGeometry } from './CylinderBufferGeometry';
+
 /*
 /*
  * @author: abelnation / http://github.com/abelnation
  * @author: abelnation / http://github.com/abelnation
  */
  */
 
 
-THREE.ConeBufferGeometry = function (
+function ConeBufferGeometry (
 	radius, height,
 	radius, height,
 	radialSegments, heightSegments,
 	radialSegments, heightSegments,
 	openEnded, thetaStart, thetaLength ) {
 	openEnded, thetaStart, thetaLength ) {
+	this.isConeBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.CylinderBufferGeometry.call( this,
+	CylinderBufferGeometry.call( this,
 		0, radius, height,
 		0, radius, height,
 		radialSegments, heightSegments,
 		radialSegments, heightSegments,
 		openEnded, thetaStart, thetaLength );
 		openEnded, thetaStart, thetaLength );
@@ -25,5 +29,8 @@ THREE.ConeBufferGeometry = function (
 
 
 };
 };
 
 
-THREE.ConeBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.ConeBufferGeometry.prototype.constructor = THREE.ConeBufferGeometry;
+ConeBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+ConeBufferGeometry.prototype.constructor = ConeBufferGeometry;
+
+
+export { ConeBufferGeometry };

+ 10 - 4
src/extras/geometries/ConeGeometry.js

@@ -1,13 +1,16 @@
+import { CylinderGeometry } from './CylinderGeometry';
+
 /**
 /**
  * @author abelnation / http://github.com/abelnation
  * @author abelnation / http://github.com/abelnation
  */
  */
 
 
-THREE.ConeGeometry = function (
+function ConeGeometry (
 	radius, height,
 	radius, height,
 	radialSegments, heightSegments,
 	radialSegments, heightSegments,
 	openEnded, thetaStart, thetaLength ) {
 	openEnded, thetaStart, thetaLength ) {
+	this.isConeGeometry = this.isCylinderGeometry = this.isGeometry = true;
 
 
-	THREE.CylinderGeometry.call( this,
+	CylinderGeometry.call( this,
 		0, radius, height,
 		0, radius, height,
 		radialSegments, heightSegments,
 		radialSegments, heightSegments,
 		openEnded, thetaStart, thetaLength );
 		openEnded, thetaStart, thetaLength );
@@ -26,5 +29,8 @@ THREE.ConeGeometry = function (
 
 
 };
 };
 
 
-THREE.ConeGeometry.prototype = Object.create( THREE.CylinderGeometry.prototype );
-THREE.ConeGeometry.prototype.constructor = THREE.ConeGeometry;
+ConeGeometry.prototype = Object.create( CylinderGeometry.prototype );
+ConeGeometry.prototype.constructor = ConeGeometry;
+
+
+export { ConeGeometry };

+ 21 - 12
src/extras/geometries/CylinderBufferGeometry.js

@@ -1,10 +1,16 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { Vector2 } from '../../math/Vector2';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+function CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+	this.isCylinderBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'CylinderBufferGeometry';
 	this.type = 'CylinderBufferGeometry';
 
 
@@ -48,10 +54,10 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
 
 
 	// buffers
 	// buffers
 
 
-	var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ), 1 );
-	var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+	var indices = new BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ), 1 );
+	var vertices = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var normals = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
 	// helper variables
 	// helper variables
 
 
@@ -114,8 +120,8 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
 	function generateTorso() {
 	function generateTorso() {
 
 
 		var x, y;
 		var x, y;
-		var normal = new THREE.Vector3();
-		var vertex = new THREE.Vector3();
+		var normal = new Vector3();
+		var vertex = new Vector3();
 
 
 		var groupCount = 0;
 		var groupCount = 0;
 
 
@@ -215,8 +221,8 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
 
 
 		var x, centerIndexStart, centerIndexEnd;
 		var x, centerIndexStart, centerIndexEnd;
 
 
-		var uv = new THREE.Vector2();
-		var vertex = new THREE.Vector3();
+		var uv = new Vector2();
+		var vertex = new Vector3();
 
 
 		var groupCount = 0;
 		var groupCount = 0;
 
 
@@ -319,5 +325,8 @@ THREE.CylinderBufferGeometry = function( radiusTop, radiusBottom, height, radial
 
 
 };
 };
 
 
-THREE.CylinderBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.CylinderBufferGeometry.prototype.constructor = THREE.CylinderBufferGeometry;
+CylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+CylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;
+
+
+export { CylinderBufferGeometry };

+ 12 - 5
src/extras/geometries/CylinderGeometry.js

@@ -1,10 +1,14 @@
+import { Geometry } from '../../core/Geometry';
+import { CylinderBufferGeometry } from './CylinderBufferGeometry';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+function CylinderGeometry ( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {
+	this.isCylinderGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'CylinderGeometry';
 	this.type = 'CylinderGeometry';
 
 
@@ -19,10 +23,13 @@ THREE.CylinderGeometry = function ( radiusTop, radiusBottom, height, radialSegme
 		thetaLength: thetaLength
 		thetaLength: thetaLength
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );
+	this.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );
 	this.mergeVertices();
 	this.mergeVertices();
 
 
 };
 };
 
 
-THREE.CylinderGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.CylinderGeometry.prototype.constructor = THREE.CylinderGeometry;
+CylinderGeometry.prototype = Object.create( Geometry.prototype );
+CylinderGeometry.prototype.constructor = CylinderGeometry;
+
+
+export { CylinderGeometry };

+ 10 - 4
src/extras/geometries/DodecahedronGeometry.js

@@ -1,8 +1,11 @@
+import { PolyhedronGeometry } from './PolyhedronGeometry';
+
 /**
 /**
  * @author Abe Pazos / https://hamoid.com
  * @author Abe Pazos / https://hamoid.com
  */
  */
 
 
-THREE.DodecahedronGeometry = function ( radius, detail ) {
+function DodecahedronGeometry ( radius, detail ) {
+	this.isDodecahedronGeometry = this.isPolyhedronGeometry = this.isGeometry = true;
 
 
 	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
 	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
 	var r = 1 / t;
 	var r = 1 / t;
@@ -43,7 +46,7 @@ THREE.DodecahedronGeometry = function ( radius, detail ) {
 		 1, 12, 14,      1, 14,  5,      1,  5,  9
 		 1, 12, 14,      1, 14,  5,      1,  5,  9
 	];
 	];
 
 
-	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
+	PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
 
 	this.type = 'DodecahedronGeometry';
 	this.type = 'DodecahedronGeometry';
 
 
@@ -54,5 +57,8 @@ THREE.DodecahedronGeometry = function ( radius, detail ) {
 
 
 };
 };
 
 
-THREE.DodecahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype );
-THREE.DodecahedronGeometry.prototype.constructor = THREE.DodecahedronGeometry;
+DodecahedronGeometry.prototype = Object.create( PolyhedronGeometry.prototype );
+DodecahedronGeometry.prototype.constructor = DodecahedronGeometry;
+
+
+export { DodecahedronGeometry };

+ 17 - 8
src/extras/geometries/EdgesGeometry.js

@@ -1,14 +1,20 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { BufferAttribute } from '../../core/BufferAttribute';
+import { Geometry } from '../../core/Geometry';
+import { _Math } from '../../math/Math';
+
 /**
 /**
  * @author WestLangley / http://github.com/WestLangley
  * @author WestLangley / http://github.com/WestLangley
  */
  */
 
 
-THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
+function EdgesGeometry ( geometry, thresholdAngle ) {
+	this.isEdgesGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	thresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;
 	thresholdAngle = ( thresholdAngle !== undefined ) ? thresholdAngle : 1;
 
 
-	var thresholdDot = Math.cos( THREE.Math.DEG2RAD * thresholdAngle );
+	var thresholdDot = Math.cos( _Math.DEG2RAD * thresholdAngle );
 
 
 	var edge = [ 0, 0 ], hash = {};
 	var edge = [ 0, 0 ], hash = {};
 
 
@@ -22,9 +28,9 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 
 	var geometry2;
 	var geometry2;
 
 
-	if ( geometry instanceof THREE.BufferGeometry ) {
+	if ( (geometry && geometry.isBufferGeometry) ) {
 
 
-		geometry2 = new THREE.Geometry();
+		geometry2 = new Geometry();
 		geometry2.fromBufferGeometry( geometry );
 		geometry2.fromBufferGeometry( geometry );
 
 
 	} else {
 	} else {
@@ -87,9 +93,12 @@ THREE.EdgesGeometry = function ( geometry, thresholdAngle ) {
 
 
 	}
 	}
 
 
-	this.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( coords ), 3 ) );
+	this.addAttribute( 'position', new BufferAttribute( new Float32Array( coords ), 3 ) );
 
 
 };
 };
 
 
-THREE.EdgesGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.EdgesGeometry.prototype.constructor = THREE.EdgesGeometry;
+EdgesGeometry.prototype = Object.create( BufferGeometry.prototype );
+EdgesGeometry.prototype.constructor = EdgesGeometry;
+
+
+export { EdgesGeometry };

+ 43 - 32
src/extras/geometries/ExtrudeGeometry.js

@@ -1,3 +1,10 @@
+import { Geometry } from '../../core/Geometry';
+import { Vector2 } from '../../math/Vector2';
+import { Face3 } from '../../core/Face3';
+import { Vector3 } from '../../math/Vector3';
+import { ShapeUtils } from '../ShapeUtils';
+import { TubeGeometry } from './TubeGeometry';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  *
  *
@@ -22,7 +29,8 @@
  * }
  * }
  **/
  **/
 
 
-THREE.ExtrudeGeometry = function ( shapes, options ) {
+function ExtrudeGeometry ( shapes, options ) {
+	this.isExtrudeGeometry = this.isGeometry = true;
 
 
 	if ( typeof( shapes ) === "undefined" ) {
 	if ( typeof( shapes ) === "undefined" ) {
 
 
@@ -31,7 +39,7 @@ THREE.ExtrudeGeometry = function ( shapes, options ) {
 
 
 	}
 	}
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'ExtrudeGeometry';
 	this.type = 'ExtrudeGeometry';
 
 
@@ -51,10 +59,10 @@ THREE.ExtrudeGeometry = function ( shapes, options ) {
 
 
 };
 };
 
 
-THREE.ExtrudeGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.ExtrudeGeometry.prototype.constructor = THREE.ExtrudeGeometry;
+ExtrudeGeometry.prototype = Object.create( Geometry.prototype );
+ExtrudeGeometry.prototype.constructor = ExtrudeGeometry;
 
 
-THREE.ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) {
+ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) {
 
 
 	var sl = shapes.length;
 	var sl = shapes.length;
 
 
@@ -67,7 +75,7 @@ THREE.ExtrudeGeometry.prototype.addShapeList = function ( shapes, options ) {
 
 
 };
 };
 
 
-THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
+ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 	var amount = options.amount !== undefined ? options.amount : 100;
 	var amount = options.amount !== undefined ? options.amount : 100;
 
 
@@ -85,7 +93,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 	var extrudePts, extrudeByPath = false;
 	var extrudePts, extrudeByPath = false;
 
 
 	// Use default WorldUVGenerator if no UV generators are specified.
 	// Use default WorldUVGenerator if no UV generators are specified.
-	var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : THREE.ExtrudeGeometry.WorldUVGenerator;
+	var uvgen = options.UVGenerator !== undefined ? options.UVGenerator : ExtrudeGeometry.WorldUVGenerator;
 
 
 	var splineTube, binormal, normal, position2;
 	var splineTube, binormal, normal, position2;
 	if ( extrudePath ) {
 	if ( extrudePath ) {
@@ -100,13 +108,13 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		// Reuse TNB from TubeGeomtry for now.
 		// Reuse TNB from TubeGeomtry for now.
 		// TODO1 - have a .isClosed in spline?
 		// TODO1 - have a .isClosed in spline?
 
 
-		splineTube = options.frames !== undefined ? options.frames : new THREE.TubeGeometry.FrenetFrames( extrudePath, steps, false );
+		splineTube = options.frames !== undefined ? options.frames : new TubeGeometry.FrenetFrames( extrudePath, steps, false );
 
 
 		// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
 		// console.log(splineTube, 'splineTube', splineTube.normals.length, 'steps', steps, 'extrudePts', extrudePts.length);
 
 
-		binormal = new THREE.Vector3();
-		normal = new THREE.Vector3();
-		position2 = new THREE.Vector3();
+		binormal = new Vector3();
+		normal = new Vector3();
+		position2 = new Vector3();
 
 
 	}
 	}
 
 
@@ -132,7 +140,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 	var vertices = shapePoints.shape;
 	var vertices = shapePoints.shape;
 	var holes = shapePoints.holes;
 	var holes = shapePoints.holes;
 
 
-	var reverse = ! THREE.ShapeUtils.isClockWise( vertices );
+	var reverse = ! ShapeUtils.isClockWise( vertices );
 
 
 	if ( reverse ) {
 	if ( reverse ) {
 
 
@@ -144,7 +152,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 			ahole = holes[ h ];
 			ahole = holes[ h ];
 
 
-			if ( THREE.ShapeUtils.isClockWise( ahole ) ) {
+			if ( ShapeUtils.isClockWise( ahole ) ) {
 
 
 				holes[ h ] = ahole.reverse();
 				holes[ h ] = ahole.reverse();
 
 
@@ -157,7 +165,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 	}
 	}
 
 
 
 
-	var faces = THREE.ShapeUtils.triangulateShape( vertices, holes );
+	var faces = ShapeUtils.triangulateShape( vertices, holes );
 
 
 	/* Vertices */
 	/* Vertices */
 
 
@@ -243,7 +251,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 			var v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y );
 			var v_trans_lensq = ( v_trans_x * v_trans_x + v_trans_y * v_trans_y );
 			if ( v_trans_lensq <= 2 ) {
 			if ( v_trans_lensq <= 2 ) {
 
 
-				return	new THREE.Vector2( v_trans_x, v_trans_y );
+				return	new Vector2( v_trans_x, v_trans_y );
 
 
 			} else {
 			} else {
 
 
@@ -304,7 +312,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 		}
 		}
 
 
-		return	new THREE.Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by );
+		return	new Vector2( v_trans_x / shrink_by, v_trans_y / shrink_by );
 
 
 	}
 	}
 
 
@@ -616,7 +624,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 	function v( x, y, z ) {
 	function v( x, y, z ) {
 
 
-		scope.vertices.push( new THREE.Vector3( x, y, z ) );
+		scope.vertices.push( new Vector3( x, y, z ) );
 
 
 	}
 	}
 
 
@@ -626,7 +634,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		b += shapesOffset;
 		b += shapesOffset;
 		c += shapesOffset;
 		c += shapesOffset;
 
 
-		scope.faces.push( new THREE.Face3( a, b, c, null, null, 0 ) );
+		scope.faces.push( new Face3( a, b, c, null, null, 0 ) );
 
 
 		var uvs = uvgen.generateTopUV( scope, a, b, c );
 		var uvs = uvgen.generateTopUV( scope, a, b, c );
 
 
@@ -641,8 +649,8 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 		c += shapesOffset;
 		c += shapesOffset;
 		d += shapesOffset;
 		d += shapesOffset;
 
 
-		scope.faces.push( new THREE.Face3( a, b, d, null, null, 1 ) );
-		scope.faces.push( new THREE.Face3( b, c, d, null, null, 1 ) );
+		scope.faces.push( new Face3( a, b, d, null, null, 1 ) );
+		scope.faces.push( new Face3( b, c, d, null, null, 1 ) );
 
 
 		var uvs = uvgen.generateSideWallUV( scope, a, b, c, d );
 		var uvs = uvgen.generateSideWallUV( scope, a, b, c, d );
 
 
@@ -653,7 +661,7 @@ THREE.ExtrudeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 };
 };
 
 
-THREE.ExtrudeGeometry.WorldUVGenerator = {
+ExtrudeGeometry.WorldUVGenerator = {
 
 
 	generateTopUV: function ( geometry, indexA, indexB, indexC ) {
 	generateTopUV: function ( geometry, indexA, indexB, indexC ) {
 
 
@@ -664,9 +672,9 @@ THREE.ExtrudeGeometry.WorldUVGenerator = {
 		var c = vertices[ indexC ];
 		var c = vertices[ indexC ];
 
 
 		return [
 		return [
-			new THREE.Vector2( a.x, a.y ),
-			new THREE.Vector2( b.x, b.y ),
-			new THREE.Vector2( c.x, c.y )
+			new Vector2( a.x, a.y ),
+			new Vector2( b.x, b.y ),
+			new Vector2( c.x, c.y )
 		];
 		];
 
 
 	},
 	},
@@ -683,22 +691,25 @@ THREE.ExtrudeGeometry.WorldUVGenerator = {
 		if ( Math.abs( a.y - b.y ) < 0.01 ) {
 		if ( Math.abs( a.y - b.y ) < 0.01 ) {
 
 
 			return [
 			return [
-				new THREE.Vector2( a.x, 1 - a.z ),
-				new THREE.Vector2( b.x, 1 - b.z ),
-				new THREE.Vector2( c.x, 1 - c.z ),
-				new THREE.Vector2( d.x, 1 - d.z )
+				new Vector2( a.x, 1 - a.z ),
+				new Vector2( b.x, 1 - b.z ),
+				new Vector2( c.x, 1 - c.z ),
+				new Vector2( d.x, 1 - d.z )
 			];
 			];
 
 
 		} else {
 		} else {
 
 
 			return [
 			return [
-				new THREE.Vector2( a.y, 1 - a.z ),
-				new THREE.Vector2( b.y, 1 - b.z ),
-				new THREE.Vector2( c.y, 1 - c.z ),
-				new THREE.Vector2( d.y, 1 - d.z )
+				new Vector2( a.y, 1 - a.z ),
+				new Vector2( b.y, 1 - b.z ),
+				new Vector2( c.y, 1 - c.z ),
+				new Vector2( d.y, 1 - d.z )
 			];
 			];
 
 
 		}
 		}
 
 
 	}
 	}
 };
 };
+
+
+export { ExtrudeGeometry };

+ 10 - 4
src/extras/geometries/IcosahedronGeometry.js

@@ -1,8 +1,11 @@
+import { PolyhedronGeometry } from './PolyhedronGeometry';
+
 /**
 /**
  * @author timothypratley / https://github.com/timothypratley
  * @author timothypratley / https://github.com/timothypratley
  */
  */
 
 
-THREE.IcosahedronGeometry = function ( radius, detail ) {
+function IcosahedronGeometry ( radius, detail ) {
+	this.isIcosahedronGeometry = this.isPolyhedronGeometry = this.isGeometry = true;
 
 
 	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
 	var t = ( 1 + Math.sqrt( 5 ) ) / 2;
 
 
@@ -19,7 +22,7 @@ THREE.IcosahedronGeometry = function ( radius, detail ) {
 		 4,  9,  5,    2,  4, 11,    6,  2, 10,    8,  6,  7,    9,  8,  1
 		 4,  9,  5,    2,  4, 11,    6,  2, 10,    8,  6,  7,    9,  8,  1
 	];
 	];
 
 
-	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
+	PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
 
 	this.type = 'IcosahedronGeometry';
 	this.type = 'IcosahedronGeometry';
 
 
@@ -30,5 +33,8 @@ THREE.IcosahedronGeometry = function ( radius, detail ) {
 
 
 };
 };
 
 
-THREE.IcosahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype );
-THREE.IcosahedronGeometry.prototype.constructor = THREE.IcosahedronGeometry;
+IcosahedronGeometry.prototype = Object.create( PolyhedronGeometry.prototype );
+IcosahedronGeometry.prototype.constructor = IcosahedronGeometry;
+
+
+export { IcosahedronGeometry };

+ 23 - 13
src/extras/geometries/LatheBufferGeometry.js

@@ -1,3 +1,9 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { Vector2 } from '../../math/Vector2';
+import { BufferAttribute } from '../../core/BufferAttribute';
+import { _Math } from '../../math/Math';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
@@ -9,9 +15,10 @@
  // phiLength - the radian (0 to 2PI) range of the lathed section
  // phiLength - the radian (0 to 2PI) range of the lathed section
  //    2PI is a closed lathe, less than 2PI is a portion.
  //    2PI is a closed lathe, less than 2PI is a portion.
 
 
-THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
+function LatheBufferGeometry ( points, segments, phiStart, phiLength ) {
+	this.isLatheBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'LatheBufferGeometry';
 	this.type = 'LatheBufferGeometry';
 
 
@@ -27,23 +34,23 @@ THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
 	phiLength = phiLength || Math.PI * 2;
 	phiLength = phiLength || Math.PI * 2;
 
 
 	// clamp phiLength so it's in range of [ 0, 2PI ]
 	// clamp phiLength so it's in range of [ 0, 2PI ]
-	phiLength = THREE.Math.clamp( phiLength, 0, Math.PI * 2 );
+	phiLength = _Math.clamp( phiLength, 0, Math.PI * 2 );
 
 
 	// these are used to calculate buffer length
 	// these are used to calculate buffer length
 	var vertexCount = ( segments + 1 ) * points.length;
 	var vertexCount = ( segments + 1 ) * points.length;
 	var indexCount = segments * points.length * 2 * 3;
 	var indexCount = segments * points.length * 2 * 3;
 
 
 	// buffers
 	// buffers
-	var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
-	var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+	var indices = new BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
+	var vertices = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
 	// helper variables
 	// helper variables
 	var index = 0, indexOffset = 0, base;
 	var index = 0, indexOffset = 0, base;
 	var inversePointLength = 1.0 / ( points.length - 1 );
 	var inversePointLength = 1.0 / ( points.length - 1 );
 	var inverseSegments = 1.0 / segments;
 	var inverseSegments = 1.0 / segments;
-	var vertex = new THREE.Vector3();
-	var uv = new THREE.Vector2();
+	var vertex = new Vector3();
+	var uv = new Vector2();
 	var i, j;
 	var i, j;
 
 
 	// generate vertices and uvs
 	// generate vertices and uvs
@@ -119,9 +126,9 @@ THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
 	if( phiLength === Math.PI * 2 ) {
 	if( phiLength === Math.PI * 2 ) {
 
 
 		var normals = this.attributes.normal.array;
 		var normals = this.attributes.normal.array;
-		var n1 = new THREE.Vector3();
-		var n2 = new THREE.Vector3();
-		var n = new THREE.Vector3();
+		var n1 = new Vector3();
+		var n2 = new Vector3();
+		var n = new Vector3();
 
 
 		// this is the buffer offset for the last line of vertices
 		// this is the buffer offset for the last line of vertices
 		base = segments * points.length * 3;
 		base = segments * points.length * 3;
@@ -152,5 +159,8 @@ THREE.LatheBufferGeometry = function ( points, segments, phiStart, phiLength ) {
 
 
 };
 };
 
 
-THREE.LatheBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.LatheBufferGeometry.prototype.constructor = THREE.LatheBufferGeometry;
+LatheBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+LatheBufferGeometry.prototype.constructor = LatheBufferGeometry;
+
+
+export { LatheBufferGeometry };

+ 12 - 5
src/extras/geometries/LatheGeometry.js

@@ -1,3 +1,6 @@
+import { Geometry } from '../../core/Geometry';
+import { LatheBufferGeometry } from './LatheBufferGeometry';
+
 /**
 /**
  * @author astrodud / http://astrodud.isgreat.org/
  * @author astrodud / http://astrodud.isgreat.org/
  * @author zz85 / https://github.com/zz85
  * @author zz85 / https://github.com/zz85
@@ -11,9 +14,10 @@
 // phiLength - the radian (0 to 2PI) range of the lathed section
 // phiLength - the radian (0 to 2PI) range of the lathed section
 //    2PI is a closed lathe, less than 2PI is a portion.
 //    2PI is a closed lathe, less than 2PI is a portion.
 
 
-THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
+function LatheGeometry ( points, segments, phiStart, phiLength ) {
+	this.isLatheGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'LatheGeometry';
 	this.type = 'LatheGeometry';
 
 
@@ -24,10 +28,13 @@ THREE.LatheGeometry = function ( points, segments, phiStart, phiLength ) {
 		phiLength: phiLength
 		phiLength: phiLength
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.LatheBufferGeometry( points, segments, phiStart, phiLength ) );
+	this.fromBufferGeometry( new LatheBufferGeometry( points, segments, phiStart, phiLength ) );
 	this.mergeVertices();
 	this.mergeVertices();
 
 
 };
 };
 
 
-THREE.LatheGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.LatheGeometry.prototype.constructor = THREE.LatheGeometry;
+LatheGeometry.prototype = Object.create( Geometry.prototype );
+LatheGeometry.prototype.constructor = LatheGeometry;
+
+
+export { LatheGeometry };

+ 10 - 4
src/extras/geometries/OctahedronGeometry.js

@@ -1,8 +1,11 @@
+import { PolyhedronGeometry } from './PolyhedronGeometry';
+
 /**
 /**
  * @author timothypratley / https://github.com/timothypratley
  * @author timothypratley / https://github.com/timothypratley
  */
  */
 
 
-THREE.OctahedronGeometry = function ( radius, detail ) {
+function OctahedronGeometry ( radius, detail ) {
+	this.isOctahedronGeometry = this.isPolyhedronGeometry = this.isGeometry = true;
 
 
 	var vertices = [
 	var vertices = [
 		1, 0, 0,   - 1, 0, 0,    0, 1, 0,    0, - 1, 0,    0, 0, 1,    0, 0, - 1
 		1, 0, 0,   - 1, 0, 0,    0, 1, 0,    0, - 1, 0,    0, 0, 1,    0, 0, - 1
@@ -12,7 +15,7 @@ THREE.OctahedronGeometry = function ( radius, detail ) {
 		0, 2, 4,    0, 4, 3,    0, 3, 5,    0, 5, 2,    1, 2, 5,    1, 5, 3,    1, 3, 4,    1, 4, 2
 		0, 2, 4,    0, 4, 3,    0, 3, 5,    0, 5, 2,    1, 2, 5,    1, 5, 3,    1, 3, 4,    1, 4, 2
 	];
 	];
 
 
-	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
+	PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
 
 	this.type = 'OctahedronGeometry';
 	this.type = 'OctahedronGeometry';
 
 
@@ -23,5 +26,8 @@ THREE.OctahedronGeometry = function ( radius, detail ) {
 
 
 };
 };
 
 
-THREE.OctahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype );
-THREE.OctahedronGeometry.prototype.constructor = THREE.OctahedronGeometry;
+OctahedronGeometry.prototype = Object.create( PolyhedronGeometry.prototype );
+OctahedronGeometry.prototype.constructor = OctahedronGeometry;
+
+
+export { OctahedronGeometry };

+ 18 - 10
src/extras/geometries/ParametricGeometry.js

@@ -1,3 +1,7 @@
+import { Geometry } from '../../core/Geometry';
+import { Face3 } from '../../core/Face3';
+import { Vector2 } from '../../math/Vector2';
+
 /**
 /**
  * @author zz85 / https://github.com/zz85
  * @author zz85 / https://github.com/zz85
  * Parametric Surfaces Geometry
  * Parametric Surfaces Geometry
@@ -7,9 +11,10 @@
  *
  *
  */
  */
 
 
-THREE.ParametricGeometry = function ( func, slices, stacks ) {
+function ParametricGeometry ( func, slices, stacks ) {
+	this.isParametricGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'ParametricGeometry';
 	this.type = 'ParametricGeometry';
 
 
@@ -55,15 +60,15 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) {
 			c = ( i + 1 ) * sliceCount + j + 1;
 			c = ( i + 1 ) * sliceCount + j + 1;
 			d = ( i + 1 ) * sliceCount + j;
 			d = ( i + 1 ) * sliceCount + j;
 
 
-			uva = new THREE.Vector2( j / slices, i / stacks );
-			uvb = new THREE.Vector2( ( j + 1 ) / slices, i / stacks );
-			uvc = new THREE.Vector2( ( j + 1 ) / slices, ( i + 1 ) / stacks );
-			uvd = new THREE.Vector2( j / slices, ( i + 1 ) / stacks );
+			uva = new Vector2( j / slices, i / stacks );
+			uvb = new Vector2( ( j + 1 ) / slices, i / stacks );
+			uvc = new Vector2( ( j + 1 ) / slices, ( i + 1 ) / stacks );
+			uvd = new Vector2( j / slices, ( i + 1 ) / stacks );
 
 
-			faces.push( new THREE.Face3( a, b, d ) );
+			faces.push( new Face3( a, b, d ) );
 			uvs.push( [ uva, uvb, uvd ] );
 			uvs.push( [ uva, uvb, uvd ] );
 
 
-			faces.push( new THREE.Face3( b, c, d ) );
+			faces.push( new Face3( b, c, d ) );
 			uvs.push( [ uvb.clone(), uvc, uvd.clone() ] );
 			uvs.push( [ uvb.clone(), uvc, uvd.clone() ] );
 
 
 		}
 		}
@@ -81,5 +86,8 @@ THREE.ParametricGeometry = function ( func, slices, stacks ) {
 
 
 };
 };
 
 
-THREE.ParametricGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.ParametricGeometry.prototype.constructor = THREE.ParametricGeometry;
+ParametricGeometry.prototype = Object.create( Geometry.prototype );
+ParametricGeometry.prototype.constructor = ParametricGeometry;
+
+
+export { ParametricGeometry };

+ 15 - 8
src/extras/geometries/PlaneBufferGeometry.js

@@ -1,11 +1,15 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  */
  */
 
 
-THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegments ) {
+function PlaneBufferGeometry ( width, height, widthSegments, heightSegments ) {
+	this.isPlaneBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'PlaneBufferGeometry';
 	this.type = 'PlaneBufferGeometry';
 
 
@@ -85,12 +89,15 @@ THREE.PlaneBufferGeometry = function ( width, height, widthSegments, heightSegme
 
 
 	}
 	}
 
 
-	this.setIndex( new THREE.BufferAttribute( indices, 1 ) );
-	this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-	this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
-	this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+	this.setIndex( new BufferAttribute( indices, 1 ) );
+	this.addAttribute( 'position', new BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'normal', new BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new BufferAttribute( uvs, 2 ) );
 
 
 };
 };
 
 
-THREE.PlaneBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.PlaneBufferGeometry.prototype.constructor = THREE.PlaneBufferGeometry;
+PlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+PlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;
+
+
+export { PlaneBufferGeometry };

+ 12 - 5
src/extras/geometries/PlaneGeometry.js

@@ -1,11 +1,15 @@
+import { Geometry } from '../../core/Geometry';
+import { PlaneBufferGeometry } from './PlaneBufferGeometry';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  */
  */
 
 
-THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments ) {
+function PlaneGeometry ( width, height, widthSegments, heightSegments ) {
+	this.isPlaneGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'PlaneGeometry';
 	this.type = 'PlaneGeometry';
 
 
@@ -16,9 +20,12 @@ THREE.PlaneGeometry = function ( width, height, widthSegments, heightSegments )
 		heightSegments: heightSegments
 		heightSegments: heightSegments
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
+	this.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );
 
 
 };
 };
 
 
-THREE.PlaneGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.PlaneGeometry.prototype.constructor = THREE.PlaneGeometry;
+PlaneGeometry.prototype = Object.create( Geometry.prototype );
+PlaneGeometry.prototype.constructor = PlaneGeometry;
+
+
+export { PlaneGeometry };

+ 22 - 12
src/extras/geometries/PolyhedronGeometry.js

@@ -1,12 +1,19 @@
+import { Geometry } from '../../core/Geometry';
+import { Vector2 } from '../../math/Vector2';
+import { Face3 } from '../../core/Face3';
+import { Vector3 } from '../../math/Vector3';
+import { Sphere } from '../../math/Sphere';
+
 /**
 /**
  * @author clockworkgeek / https://github.com/clockworkgeek
  * @author clockworkgeek / https://github.com/clockworkgeek
  * @author timothypratley / https://github.com/timothypratley
  * @author timothypratley / https://github.com/timothypratley
  * @author WestLangley / http://github.com/WestLangley
  * @author WestLangley / http://github.com/WestLangley
 */
 */
 
 
-THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
+function PolyhedronGeometry ( vertices, indices, radius, detail ) {
+	this.isPolyhedronGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'PolyhedronGeometry';
 	this.type = 'PolyhedronGeometry';
 
 
@@ -24,7 +31,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 	for ( var i = 0, l = vertices.length; i < l; i += 3 ) {
 	for ( var i = 0, l = vertices.length; i < l; i += 3 ) {
 
 
-		prepare( new THREE.Vector3( vertices[ i ], vertices[ i + 1 ], vertices[ i + 2 ] ) );
+		prepare( new Vector3( vertices[ i ], vertices[ i + 1 ], vertices[ i + 2 ] ) );
 
 
 	}
 	}
 
 
@@ -38,11 +45,11 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 		var v2 = p[ indices[ i + 1 ] ];
 		var v2 = p[ indices[ i + 1 ] ];
 		var v3 = p[ indices[ i + 2 ] ];
 		var v3 = p[ indices[ i + 2 ] ];
 
 
-		faces[ j ] = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
+		faces[ j ] = new Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
 
 
 	}
 	}
 
 
-	var centroid = new THREE.Vector3();
+	var centroid = new Vector3();
 
 
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 	for ( var i = 0, l = faces.length; i < l; i ++ ) {
 
 
@@ -92,7 +99,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 	this.computeFaceNormals();
 	this.computeFaceNormals();
 
 
-	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
+	this.boundingSphere = new Sphere( new Vector3(), radius );
 
 
 
 
 	// Project vector onto sphere's surface
 	// Project vector onto sphere's surface
@@ -106,7 +113,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 		var u = azimuth( vector ) / 2 / Math.PI + 0.5;
 		var u = azimuth( vector ) / 2 / Math.PI + 0.5;
 		var v = inclination( vector ) / Math.PI + 0.5;
 		var v = inclination( vector ) / Math.PI + 0.5;
-		vertex.uv = new THREE.Vector2( u, 1 - v );
+		vertex.uv = new Vector2( u, 1 - v );
 
 
 		return vertex;
 		return vertex;
 
 
@@ -117,7 +124,7 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 	function make( v1, v2, v3 ) {
 	function make( v1, v2, v3 ) {
 
 
-		var face = new THREE.Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
+		var face = new Face3( v1.index, v2.index, v3.index, [ v1.clone(), v2.clone(), v3.clone() ] );
 		that.faces.push( face );
 		that.faces.push( face );
 
 
 		centroid.copy( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
 		centroid.copy( v1 ).add( v2 ).add( v3 ).divideScalar( 3 );
@@ -224,8 +231,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 	function correctUV( uv, vector, azimuth ) {
 	function correctUV( uv, vector, azimuth ) {
 
 
-		if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) uv = new THREE.Vector2( uv.x - 1, uv.y );
-		if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) uv = new THREE.Vector2( azimuth / 2 / Math.PI + 0.5, uv.y );
+		if ( ( azimuth < 0 ) && ( uv.x === 1 ) ) uv = new Vector2( uv.x - 1, uv.y );
+		if ( ( vector.x === 0 ) && ( vector.z === 0 ) ) uv = new Vector2( azimuth / 2 / Math.PI + 0.5, uv.y );
 		return uv.clone();
 		return uv.clone();
 
 
 	}
 	}
@@ -233,5 +240,8 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 
 
 };
 };
 
 
-THREE.PolyhedronGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.PolyhedronGeometry.prototype.constructor = THREE.PolyhedronGeometry;
+PolyhedronGeometry.prototype = Object.create( Geometry.prototype );
+PolyhedronGeometry.prototype.constructor = PolyhedronGeometry;
+
+
+export { PolyhedronGeometry };

+ 19 - 10
src/extras/geometries/RingBufferGeometry.js

@@ -1,10 +1,16 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector2 } from '../../math/Vector2';
+import { Vector3 } from '../../math/Vector3';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-THREE.RingBufferGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+function RingBufferGeometry ( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+	this.isRingBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'RingBufferGeometry';
 	this.type = 'RingBufferGeometry';
 
 
@@ -31,17 +37,17 @@ THREE.RingBufferGeometry = function ( innerRadius, outerRadius, thetaSegments, p
 	var indexCount = thetaSegments * phiSegments * 2 * 3;
 	var indexCount = thetaSegments * phiSegments * 2 * 3;
 
 
 	// buffers
 	// buffers
-	var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
-	var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+	var indices = new BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
+	var vertices = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var normals = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
 	// some helper variables
 	// some helper variables
 	var index = 0, indexOffset = 0, segment;
 	var index = 0, indexOffset = 0, segment;
 	var radius = innerRadius;
 	var radius = innerRadius;
 	var radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
 	var radiusStep = ( ( outerRadius - innerRadius ) / phiSegments );
-	var vertex = new THREE.Vector3();
-	var uv = new THREE.Vector2();
+	var vertex = new Vector3();
+	var uv = new Vector2();
 	var j, i;
 	var j, i;
 
 
 	// generate vertices, normals and uvs
 	// generate vertices, normals and uvs
@@ -116,5 +122,8 @@ THREE.RingBufferGeometry = function ( innerRadius, outerRadius, thetaSegments, p
 
 
 };
 };
 
 
-THREE.RingBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.RingBufferGeometry.prototype.constructor = THREE.RingBufferGeometry;
+RingBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+RingBufferGeometry.prototype.constructor = RingBufferGeometry;
+
+
+export { RingBufferGeometry };

+ 12 - 5
src/extras/geometries/RingGeometry.js

@@ -1,10 +1,14 @@
+import { Geometry } from '../../core/Geometry';
+import { RingBufferGeometry } from './RingBufferGeometry';
+
 /**
 /**
  * @author Kaleb Murphy
  * @author Kaleb Murphy
  */
  */
 
 
-THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+function RingGeometry ( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) {
+	this.isRingGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'RingGeometry';
 	this.type = 'RingGeometry';
 
 
@@ -17,9 +21,12 @@ THREE.RingGeometry = function ( innerRadius, outerRadius, thetaSegments, phiSegm
 		thetaLength: thetaLength
 		thetaLength: thetaLength
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
+	this.fromBufferGeometry( new RingBufferGeometry( innerRadius, outerRadius, thetaSegments, phiSegments, thetaStart, thetaLength ) );
 
 
 };
 };
 
 
-THREE.RingGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.RingGeometry.prototype.constructor = THREE.RingGeometry;
+RingGeometry.prototype = Object.create( Geometry.prototype );
+RingGeometry.prototype.constructor = RingGeometry;
+
+
+export { RingGeometry };

+ 22 - 12
src/extras/geometries/ShapeGeometry.js

@@ -1,3 +1,9 @@
+import { Geometry } from '../../core/Geometry';
+import { Face3 } from '../../core/Face3';
+import { Vector3 } from '../../math/Vector3';
+import { ShapeUtils } from '../ShapeUtils';
+import { ExtrudeGeometry } from './ExtrudeGeometry';
+
 /**
 /**
  * @author jonobr1 / http://jonobr1.com
  * @author jonobr1 / http://jonobr1.com
  *
  *
@@ -14,9 +20,10 @@
  * }
  * }
  **/
  **/
 
 
-THREE.ShapeGeometry = function ( shapes, options ) {
+function ShapeGeometry ( shapes, options ) {
+	this.isShapeGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'ShapeGeometry';
 	this.type = 'ShapeGeometry';
 
 
@@ -28,13 +35,13 @@ THREE.ShapeGeometry = function ( shapes, options ) {
 
 
 };
 };
 
 
-THREE.ShapeGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.ShapeGeometry.prototype.constructor = THREE.ShapeGeometry;
+ShapeGeometry.prototype = Object.create( Geometry.prototype );
+ShapeGeometry.prototype.constructor = ShapeGeometry;
 
 
 /**
 /**
  * Add an array of shapes to THREE.ShapeGeometry.
  * Add an array of shapes to THREE.ShapeGeometry.
  */
  */
-THREE.ShapeGeometry.prototype.addShapeList = function ( shapes, options ) {
+ShapeGeometry.prototype.addShapeList = function ( shapes, options ) {
 
 
 	for ( var i = 0, l = shapes.length; i < l; i ++ ) {
 	for ( var i = 0, l = shapes.length; i < l; i ++ ) {
 
 
@@ -49,13 +56,13 @@ THREE.ShapeGeometry.prototype.addShapeList = function ( shapes, options ) {
 /**
 /**
  * Adds a shape to THREE.ShapeGeometry, based on THREE.ExtrudeGeometry.
  * Adds a shape to THREE.ShapeGeometry, based on THREE.ExtrudeGeometry.
  */
  */
-THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
+ShapeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 	if ( options === undefined ) options = {};
 	if ( options === undefined ) options = {};
 	var curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;
 	var curveSegments = options.curveSegments !== undefined ? options.curveSegments : 12;
 
 
 	var material = options.material;
 	var material = options.material;
-	var uvgen = options.UVGenerator === undefined ? THREE.ExtrudeGeometry.WorldUVGenerator : options.UVGenerator;
+	var uvgen = options.UVGenerator === undefined ? ExtrudeGeometry.WorldUVGenerator : options.UVGenerator;
 
 
 	//
 	//
 
 
@@ -67,7 +74,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 	var vertices = shapePoints.shape;
 	var vertices = shapePoints.shape;
 	var holes = shapePoints.holes;
 	var holes = shapePoints.holes;
 
 
-	var reverse = ! THREE.ShapeUtils.isClockWise( vertices );
+	var reverse = ! ShapeUtils.isClockWise( vertices );
 
 
 	if ( reverse ) {
 	if ( reverse ) {
 
 
@@ -79,7 +86,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 			hole = holes[ i ];
 			hole = holes[ i ];
 
 
-			if ( THREE.ShapeUtils.isClockWise( hole ) ) {
+			if ( ShapeUtils.isClockWise( hole ) ) {
 
 
 				holes[ i ] = hole.reverse();
 				holes[ i ] = hole.reverse();
 
 
@@ -91,7 +98,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 	}
 	}
 
 
-	var faces = THREE.ShapeUtils.triangulateShape( vertices, holes );
+	var faces = ShapeUtils.triangulateShape( vertices, holes );
 
 
 	// Vertices
 	// Vertices
 
 
@@ -111,7 +118,7 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 
 
 		vert = vertices[ i ];
 		vert = vertices[ i ];
 
 
-		this.vertices.push( new THREE.Vector3( vert.x, vert.y, 0 ) );
+		this.vertices.push( new Vector3( vert.x, vert.y, 0 ) );
 
 
 	}
 	}
 
 
@@ -123,9 +130,12 @@ THREE.ShapeGeometry.prototype.addShape = function ( shape, options ) {
 		var b = face[ 1 ] + shapesOffset;
 		var b = face[ 1 ] + shapesOffset;
 		var c = face[ 2 ] + shapesOffset;
 		var c = face[ 2 ] + shapesOffset;
 
 
-		this.faces.push( new THREE.Face3( a, b, c, null, null, material ) );
+		this.faces.push( new Face3( a, b, c, null, null, material ) );
 		this.faceVertexUvs[ 0 ].push( uvgen.generateTopUV( this, a, b, c ) );
 		this.faceVertexUvs[ 0 ].push( uvgen.generateTopUV( this, a, b, c ) );
 
 
 	}
 	}
 
 
 };
 };
+
+
+export { ShapeGeometry };

+ 19 - 10
src/extras/geometries/SphereBufferGeometry.js

@@ -1,11 +1,17 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { Sphere } from '../../math/Sphere';
+import { Uint16Attribute, Uint32Attribute, BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author benaadams / https://twitter.com/ben_a_adams
  * @author benaadams / https://twitter.com/ben_a_adams
  * based on THREE.SphereGeometry
  * based on THREE.SphereGeometry
  */
  */
 
 
-THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+function SphereBufferGeometry ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+	this.isSphereBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'SphereBufferGeometry';
 	this.type = 'SphereBufferGeometry';
 
 
@@ -34,11 +40,11 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
 
 
 	var vertexCount = ( ( widthSegments + 1 ) * ( heightSegments + 1 ) );
 	var vertexCount = ( ( widthSegments + 1 ) * ( heightSegments + 1 ) );
 
 
-	var positions = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+	var positions = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var normals = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
-	var index = 0, vertices = [], normal = new THREE.Vector3();
+	var index = 0, vertices = [], normal = new Vector3();
 
 
 	for ( var y = 0; y <= heightSegments; y ++ ) {
 	for ( var y = 0; y <= heightSegments; y ++ ) {
 
 
@@ -88,14 +94,17 @@ THREE.SphereBufferGeometry = function ( radius, widthSegments, heightSegments, p
 
 
 	}
 	}
 
 
-	this.setIndex( new ( positions.count > 65535 ? THREE.Uint32Attribute : THREE.Uint16Attribute )( indices, 1 ) );
+	this.setIndex( new ( positions.count > 65535 ? Uint32Attribute : Uint16Attribute )( indices, 1 ) );
 	this.addAttribute( 'position', positions );
 	this.addAttribute( 'position', positions );
 	this.addAttribute( 'normal', normals );
 	this.addAttribute( 'normal', normals );
 	this.addAttribute( 'uv', uvs );
 	this.addAttribute( 'uv', uvs );
 
 
-	this.boundingSphere = new THREE.Sphere( new THREE.Vector3(), radius );
+	this.boundingSphere = new Sphere( new Vector3(), radius );
 
 
 };
 };
 
 
-THREE.SphereBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.SphereBufferGeometry.prototype.constructor = THREE.SphereBufferGeometry;
+SphereBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+SphereBufferGeometry.prototype.constructor = SphereBufferGeometry;
+
+
+export { SphereBufferGeometry };

+ 12 - 5
src/extras/geometries/SphereGeometry.js

@@ -1,10 +1,14 @@
+import { Geometry } from '../../core/Geometry';
+import { SphereBufferGeometry } from './SphereBufferGeometry';
+
 /**
 /**
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  */
  */
 
 
-THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+function SphereGeometry ( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) {
+	this.isSphereGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'SphereGeometry';
 	this.type = 'SphereGeometry';
 
 
@@ -18,9 +22,12 @@ THREE.SphereGeometry = function ( radius, widthSegments, heightSegments, phiStar
 		thetaLength: thetaLength
 		thetaLength: thetaLength
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
+	this.fromBufferGeometry( new SphereBufferGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength ) );
 
 
 };
 };
 
 
-THREE.SphereGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.SphereGeometry.prototype.constructor = THREE.SphereGeometry;
+SphereGeometry.prototype = Object.create( Geometry.prototype );
+SphereGeometry.prototype.constructor = SphereGeometry;
+
+
+export { SphereGeometry };

+ 10 - 4
src/extras/geometries/TetrahedronGeometry.js

@@ -1,8 +1,11 @@
+import { PolyhedronGeometry } from './PolyhedronGeometry';
+
 /**
 /**
  * @author timothypratley / https://github.com/timothypratley
  * @author timothypratley / https://github.com/timothypratley
  */
  */
 
 
-THREE.TetrahedronGeometry = function ( radius, detail ) {
+function TetrahedronGeometry ( radius, detail ) {
+	this.isTetrahedronGeometry = this.isPolyhedronGeometry = this.isGeometry = true;
 
 
 	var vertices = [
 	var vertices = [
 		 1,  1,  1,   - 1, - 1,  1,   - 1,  1, - 1,    1, - 1, - 1
 		 1,  1,  1,   - 1, - 1,  1,   - 1,  1, - 1,    1, - 1, - 1
@@ -12,7 +15,7 @@ THREE.TetrahedronGeometry = function ( radius, detail ) {
 		 2,  1,  0,    0,  3,  2,    1,  3,  0,    2,  3,  1
 		 2,  1,  0,    0,  3,  2,    1,  3,  0,    2,  3,  1
 	];
 	];
 
 
-	THREE.PolyhedronGeometry.call( this, vertices, indices, radius, detail );
+	PolyhedronGeometry.call( this, vertices, indices, radius, detail );
 
 
 	this.type = 'TetrahedronGeometry';
 	this.type = 'TetrahedronGeometry';
 
 
@@ -23,5 +26,8 @@ THREE.TetrahedronGeometry = function ( radius, detail ) {
 
 
 };
 };
 
 
-THREE.TetrahedronGeometry.prototype = Object.create( THREE.PolyhedronGeometry.prototype );
-THREE.TetrahedronGeometry.prototype.constructor = THREE.TetrahedronGeometry;
+TetrahedronGeometry.prototype = Object.create( PolyhedronGeometry.prototype );
+TetrahedronGeometry.prototype.constructor = TetrahedronGeometry;
+
+
+export { TetrahedronGeometry };

+ 13 - 6
src/extras/geometries/TextGeometry.js

@@ -1,3 +1,6 @@
+import { ExtrudeGeometry } from './ExtrudeGeometry';
+import { Geometry } from '../../core/Geometry';
+
 /**
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author zz85 / http://www.lab4games.net/zz85/blog
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
@@ -17,16 +20,17 @@
  * }
  * }
  */
  */
 
 
-THREE.TextGeometry = function ( text, parameters ) {
+function TextGeometry ( text, parameters ) {
+	this.isTextGeometry = this.isExtrudeGeometry = this.isGeometry = true;
 
 
 	parameters = parameters || {};
 	parameters = parameters || {};
 
 
 	var font = parameters.font;
 	var font = parameters.font;
 
 
-	if ( font instanceof THREE.Font === false ) {
+	if ( (font && font.isFont) === false ) {
 
 
 		console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
 		console.error( 'THREE.TextGeometry: font parameter is not an instance of THREE.Font.' );
-		return new THREE.Geometry();
+		return new Geometry();
 
 
 	}
 	}
 
 
@@ -42,11 +46,14 @@ THREE.TextGeometry = function ( text, parameters ) {
 	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
 	if ( parameters.bevelSize === undefined ) parameters.bevelSize = 8;
 	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
 	if ( parameters.bevelEnabled === undefined ) parameters.bevelEnabled = false;
 
 
-	THREE.ExtrudeGeometry.call( this, shapes, parameters );
+	ExtrudeGeometry.call( this, shapes, parameters );
 
 
 	this.type = 'TextGeometry';
 	this.type = 'TextGeometry';
 
 
 };
 };
 
 
-THREE.TextGeometry.prototype = Object.create( THREE.ExtrudeGeometry.prototype );
-THREE.TextGeometry.prototype.constructor = THREE.TextGeometry;
+TextGeometry.prototype = Object.create( ExtrudeGeometry.prototype );
+TextGeometry.prototype.constructor = TextGeometry;
+
+
+export { TextGeometry };

+ 19 - 11
src/extras/geometries/TorusBufferGeometry.js

@@ -1,10 +1,15 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { BufferAttribute } from '../../core/BufferAttribute';
+import { Vector3 } from '../../math/Vector3';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  */
  */
 
 
-THREE.TorusBufferGeometry = function ( radius, tube, radialSegments, tubularSegments, arc ) {
+function TorusBufferGeometry ( radius, tube, radialSegments, tubularSegments, arc ) {
+	this.isTorusBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'TorusBufferGeometry';
 	this.type = 'TorusBufferGeometry';
 
 
@@ -38,9 +43,9 @@ THREE.TorusBufferGeometry = function ( radius, tube, radialSegments, tubularSegm
 	var indexBufferOffset = 0;
 	var indexBufferOffset = 0;
 
 
 	// helper variables
 	// helper variables
-	var center = new THREE.Vector3();
-	var vertex = new THREE.Vector3();
-	var normal = new THREE.Vector3();
+	var center = new Vector3();
+	var vertex = new Vector3();
+	var normal = new Vector3();
 
 
 	var j, i;
 	var j, i;
 
 
@@ -115,12 +120,15 @@ THREE.TorusBufferGeometry = function ( radius, tube, radialSegments, tubularSegm
 	}
 	}
 
 
 	// build geometry
 	// build geometry
-	this.setIndex( new THREE.BufferAttribute( indices, 1 ) );
-	this.addAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
-	this.addAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
-	this.addAttribute( 'uv', new THREE.BufferAttribute( uvs, 2 ) );
+	this.setIndex( new BufferAttribute( indices, 1 ) );
+	this.addAttribute( 'position', new BufferAttribute( vertices, 3 ) );
+	this.addAttribute( 'normal', new BufferAttribute( normals, 3 ) );
+	this.addAttribute( 'uv', new BufferAttribute( uvs, 2 ) );
 
 
 };
 };
 
 
-THREE.TorusBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.TorusBufferGeometry.prototype.constructor = THREE.TorusBufferGeometry;
+TorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+TorusBufferGeometry.prototype.constructor = TorusBufferGeometry;
+
+
+export { TorusBufferGeometry };

+ 12 - 5
src/extras/geometries/TorusGeometry.js

@@ -1,12 +1,16 @@
+import { Geometry } from '../../core/Geometry';
+import { TorusBufferGeometry } from './TorusBufferGeometry';
+
 /**
 /**
  * @author oosmoxiecode
  * @author oosmoxiecode
  * @author mrdoob / http://mrdoob.com/
  * @author mrdoob / http://mrdoob.com/
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888
  */
  */
 
 
-THREE.TorusGeometry = function ( radius, tube, radialSegments, tubularSegments, arc ) {
+function TorusGeometry ( radius, tube, radialSegments, tubularSegments, arc ) {
+	this.isTorusGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'TorusGeometry';
 	this.type = 'TorusGeometry';
 
 
@@ -18,9 +22,12 @@ THREE.TorusGeometry = function ( radius, tube, radialSegments, tubularSegments,
 		arc: arc
 		arc: arc
 	};
 	};
 
 
-	this.fromBufferGeometry( new THREE.TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
+	this.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );
 
 
 };
 };
 
 
-THREE.TorusGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.TorusGeometry.prototype.constructor = THREE.TorusGeometry;
+TorusGeometry.prototype = Object.create( Geometry.prototype );
+TorusGeometry.prototype.constructor = TorusGeometry;
+
+
+export { TorusGeometry };

+ 25 - 16
src/extras/geometries/TorusKnotBufferGeometry.js

@@ -1,11 +1,17 @@
+import { BufferGeometry } from '../../core/BufferGeometry';
+import { Vector3 } from '../../math/Vector3';
+import { Vector2 } from '../../math/Vector2';
+import { BufferAttribute } from '../../core/BufferAttribute';
+
 /**
 /**
  * @author Mugen87 / https://github.com/Mugen87
  * @author Mugen87 / https://github.com/Mugen87
  *
  *
  * see: http://www.blackpawn.com/texts/pqtorus/
  * see: http://www.blackpawn.com/texts/pqtorus/
  */
  */
-THREE.TorusKnotBufferGeometry = function ( radius, tube, tubularSegments, radialSegments, p, q ) {
+function TorusKnotBufferGeometry ( radius, tube, tubularSegments, radialSegments, p, q ) {
+	this.isTorusKnotBufferGeometry = this.isBufferGeometry = true;
 
 
-	THREE.BufferGeometry.call( this );
+	BufferGeometry.call( this );
 
 
 	this.type = 'TorusKnotBufferGeometry';
 	this.type = 'TorusKnotBufferGeometry';
 
 
@@ -30,24 +36,24 @@ THREE.TorusKnotBufferGeometry = function ( radius, tube, tubularSegments, radial
 	var indexCount = radialSegments * tubularSegments * 2 * 3;
 	var indexCount = radialSegments * tubularSegments * 2 * 3;
 
 
 	// buffers
 	// buffers
-	var indices = new THREE.BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
-	var vertices = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var normals = new THREE.BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
-	var uvs = new THREE.BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
+	var indices = new BufferAttribute( new ( indexCount > 65535 ? Uint32Array : Uint16Array )( indexCount ) , 1 );
+	var vertices = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var normals = new BufferAttribute( new Float32Array( vertexCount * 3 ), 3 );
+	var uvs = new BufferAttribute( new Float32Array( vertexCount * 2 ), 2 );
 
 
 	// helper variables
 	// helper variables
 	var i, j, index = 0, indexOffset = 0;
 	var i, j, index = 0, indexOffset = 0;
 
 
-	var vertex = new THREE.Vector3();
-	var normal = new THREE.Vector3();
-	var uv = new THREE.Vector2();
+	var vertex = new Vector3();
+	var normal = new Vector3();
+	var uv = new Vector2();
 
 
-	var P1 = new THREE.Vector3();
-	var P2 = new THREE.Vector3();
+	var P1 = new Vector3();
+	var P2 = new Vector3();
 
 
-	var B = new THREE.Vector3();
-	var T = new THREE.Vector3();
-	var N = new THREE.Vector3();
+	var B = new Vector3();
+	var T = new Vector3();
+	var N = new Vector3();
 
 
 	// generate vertices, normals and uvs
 	// generate vertices, normals and uvs
 
 
@@ -160,5 +166,8 @@ THREE.TorusKnotBufferGeometry = function ( radius, tube, tubularSegments, radial
 
 
 };
 };
 
 
-THREE.TorusKnotBufferGeometry.prototype = Object.create( THREE.BufferGeometry.prototype );
-THREE.TorusKnotBufferGeometry.prototype.constructor = THREE.TorusKnotBufferGeometry;
+TorusKnotBufferGeometry.prototype = Object.create( BufferGeometry.prototype );
+TorusKnotBufferGeometry.prototype.constructor = TorusKnotBufferGeometry;
+
+
+export { TorusKnotBufferGeometry };

+ 12 - 5
src/extras/geometries/TorusKnotGeometry.js

@@ -1,10 +1,14 @@
+import { Geometry } from '../../core/Geometry';
+import { TorusKnotBufferGeometry } from './TorusKnotBufferGeometry';
+
 /**
 /**
  * @author oosmoxiecode
  * @author oosmoxiecode
  */
  */
 
 
-THREE.TorusKnotGeometry = function ( radius, tube, tubularSegments, radialSegments, p, q, heightScale ) {
+function TorusKnotGeometry ( radius, tube, tubularSegments, radialSegments, p, q, heightScale ) {
+	this.isTorusKnotGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'TorusKnotGeometry';
 	this.type = 'TorusKnotGeometry';
 
 
@@ -19,10 +23,13 @@ THREE.TorusKnotGeometry = function ( radius, tube, tubularSegments, radialSegmen
 
 
 	if( heightScale !== undefined ) console.warn( 'THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.' );
 	if( heightScale !== undefined ) console.warn( 'THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.' );
 
 
-	this.fromBufferGeometry( new THREE.TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) );
+	this.fromBufferGeometry( new TorusKnotBufferGeometry( radius, tube, tubularSegments, radialSegments, p, q ) );
 	this.mergeVertices();
 	this.mergeVertices();
 
 
 };
 };
 
 
-THREE.TorusKnotGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.TorusKnotGeometry.prototype.constructor = THREE.TorusKnotGeometry;
+TorusKnotGeometry.prototype = Object.create( Geometry.prototype );
+TorusKnotGeometry.prototype.constructor = TorusKnotGeometry;
+
+
+export { TorusKnotGeometry };

+ 35 - 24
src/extras/geometries/TubeGeometry.js

@@ -1,3 +1,10 @@
+import { Geometry } from '../../core/Geometry';
+import { _Math } from '../../math/Math';
+import { Vector3 } from '../../math/Vector3';
+import { Matrix4 } from '../../math/Matrix4';
+import { Face3 } from '../../core/Face3';
+import { Vector2 } from '../../math/Vector2';
+
 /**
 /**
  * @author WestLangley / https://github.com/WestLangley
  * @author WestLangley / https://github.com/WestLangley
  * @author zz85 / https://github.com/zz85
  * @author zz85 / https://github.com/zz85
@@ -12,9 +19,10 @@
  * http://www.cs.indiana.edu/pub/techreports/TR425.pdf
  * http://www.cs.indiana.edu/pub/techreports/TR425.pdf
  */
  */
 
 
-THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed, taper ) {
+function TubeGeometry ( path, segments, radius, radialSegments, closed, taper ) {
+	this.isTubeGeometry = this.isGeometry = true;
 
 
-	THREE.Geometry.call( this );
+	Geometry.call( this );
 
 
 	this.type = 'TubeGeometry';
 	this.type = 'TubeGeometry';
 
 
@@ -31,7 +39,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 	radius = radius || 1;
 	radius = radius || 1;
 	radialSegments = radialSegments || 8;
 	radialSegments = radialSegments || 8;
 	closed = closed || false;
 	closed = closed || false;
-	taper = taper || THREE.TubeGeometry.NoTaper;
+	taper = taper || TubeGeometry.NoTaper;
 
 
 	var grid = [];
 	var grid = [];
 
 
@@ -46,13 +54,13 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 		u, v, r,
 		u, v, r,
 
 
 		cx, cy,
 		cx, cy,
-		pos, pos2 = new THREE.Vector3(),
+		pos, pos2 = new Vector3(),
 		i, j,
 		i, j,
 		ip, jp,
 		ip, jp,
 		a, b, c, d,
 		a, b, c, d,
 		uva, uvb, uvc, uvd;
 		uva, uvb, uvc, uvd;
 
 
-	var frames = new THREE.TubeGeometry.FrenetFrames( path, segments, closed ),
+	var frames = new TubeGeometry.FrenetFrames( path, segments, closed ),
 		tangents = frames.tangents,
 		tangents = frames.tangents,
 		normals = frames.normals,
 		normals = frames.normals,
 		binormals = frames.binormals;
 		binormals = frames.binormals;
@@ -64,7 +72,7 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 
 
 	function vert( x, y, z ) {
 	function vert( x, y, z ) {
 
 
-		return scope.vertices.push( new THREE.Vector3( x, y, z ) ) - 1;
+		return scope.vertices.push( new Vector3( x, y, z ) ) - 1;
 
 
 	}
 	}
 
 
@@ -117,15 +125,15 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 			c = grid[ ip ][ jp ];
 			c = grid[ ip ][ jp ];
 			d = grid[ i ][ jp ];
 			d = grid[ i ][ jp ];
 
 
-			uva = new THREE.Vector2( i / segments, j / radialSegments );
-			uvb = new THREE.Vector2( ( i + 1 ) / segments, j / radialSegments );
-			uvc = new THREE.Vector2( ( i + 1 ) / segments, ( j + 1 ) / radialSegments );
-			uvd = new THREE.Vector2( i / segments, ( j + 1 ) / radialSegments );
+			uva = new Vector2( i / segments, j / radialSegments );
+			uvb = new Vector2( ( i + 1 ) / segments, j / radialSegments );
+			uvc = new Vector2( ( i + 1 ) / segments, ( j + 1 ) / radialSegments );
+			uvd = new Vector2( i / segments, ( j + 1 ) / radialSegments );
 
 
-			this.faces.push( new THREE.Face3( a, b, d ) );
+			this.faces.push( new Face3( a, b, d ) );
 			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 			this.faceVertexUvs[ 0 ].push( [ uva, uvb, uvd ] );
 
 
-			this.faces.push( new THREE.Face3( b, c, d ) );
+			this.faces.push( new Face3( b, c, d ) );
 			this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] );
 			this.faceVertexUvs[ 0 ].push( [ uvb.clone(), uvc, uvd.clone() ] );
 
 
 		}
 		}
@@ -137,32 +145,32 @@ THREE.TubeGeometry = function ( path, segments, radius, radialSegments, closed,
 
 
 };
 };
 
 
-THREE.TubeGeometry.prototype = Object.create( THREE.Geometry.prototype );
-THREE.TubeGeometry.prototype.constructor = THREE.TubeGeometry;
+TubeGeometry.prototype = Object.create( Geometry.prototype );
+TubeGeometry.prototype.constructor = TubeGeometry;
 
 
-THREE.TubeGeometry.NoTaper = function ( u ) {
+TubeGeometry.NoTaper = function ( u ) {
 
 
 	return 1;
 	return 1;
 
 
 };
 };
 
 
-THREE.TubeGeometry.SinusoidalTaper = function ( u ) {
+TubeGeometry.SinusoidalTaper = function ( u ) {
 
 
 	return Math.sin( Math.PI * u );
 	return Math.sin( Math.PI * u );
 
 
 };
 };
 
 
 // For computing of Frenet frames, exposing the tangents, normals and binormals the spline
 // For computing of Frenet frames, exposing the tangents, normals and binormals the spline
-THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
+TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 
 
-	var	normal = new THREE.Vector3(),
+	var	normal = new Vector3(),
 
 
 		tangents = [],
 		tangents = [],
 		normals = [],
 		normals = [],
 		binormals = [],
 		binormals = [],
 
 
-		vec = new THREE.Vector3(),
-		mat = new THREE.Matrix4(),
+		vec = new Vector3(),
+		mat = new Matrix4(),
 
 
 		numpoints = segments + 1,
 		numpoints = segments + 1,
 		theta,
 		theta,
@@ -219,8 +227,8 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 		// select an initial normal vector perpendicular to the first tangent vector,
 		// select an initial normal vector perpendicular to the first tangent vector,
 		// and in the direction of the smallest tangent xyz component
 		// and in the direction of the smallest tangent xyz component
 
 
-		normals[ 0 ] = new THREE.Vector3();
-		binormals[ 0 ] = new THREE.Vector3();
+		normals[ 0 ] = new Vector3();
+		binormals[ 0 ] = new Vector3();
 		smallest = Number.MAX_VALUE;
 		smallest = Number.MAX_VALUE;
 		tx = Math.abs( tangents[ 0 ].x );
 		tx = Math.abs( tangents[ 0 ].x );
 		ty = Math.abs( tangents[ 0 ].y );
 		ty = Math.abs( tangents[ 0 ].y );
@@ -268,7 +276,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 
 
 			vec.normalize();
 			vec.normalize();
 
 
-			theta = Math.acos( THREE.Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
+			theta = Math.acos( _Math.clamp( tangents[ i - 1 ].dot( tangents[ i ] ), - 1, 1 ) ); // clamp for floating pt errors
 
 
 			normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
 			normals[ i ].applyMatrix4( mat.makeRotationAxis( vec, theta ) );
 
 
@@ -283,7 +291,7 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 
 
 	if ( closed ) {
 	if ( closed ) {
 
 
-		theta = Math.acos( THREE.Math.clamp( normals[ 0 ].dot( normals[ numpoints - 1 ] ), - 1, 1 ) );
+		theta = Math.acos( _Math.clamp( normals[ 0 ].dot( normals[ numpoints - 1 ] ), - 1, 1 ) );
 		theta /= ( numpoints - 1 );
 		theta /= ( numpoints - 1 );
 
 
 		if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints - 1 ] ) ) > 0 ) {
 		if ( tangents[ 0 ].dot( vec.crossVectors( normals[ 0 ], normals[ numpoints - 1 ] ) ) > 0 ) {
@@ -303,3 +311,6 @@ THREE.TubeGeometry.FrenetFrames = function ( path, segments, closed ) {
 	}
 	}
 
 
 };
 };
+
+
+export { TubeGeometry };

Неке датотеке нису приказане због велике количине промена