123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815 |
- /**
- * @author mr.doob / http://mrdoob.com/
- */
- THREE.CanvasRenderer = function () {
- var _renderList = null,
- _projector = new THREE.Projector(),
- _canvas = document.createElement( 'canvas' ),
- _context = _canvas.getContext( '2d' ),
- _width, _height, _widthHalf, _heightHalf,
- _clipRect = new THREE.Rectangle(),
- _clearRect = new THREE.Rectangle(),
- _bboxRect = new THREE.Rectangle(),
- _enableLighting = false,
- _color = new THREE.Color( 0xffffffff ),
- _light = new THREE.Color( 0xffffffff ),
- _ambientLight = new THREE.Color( 0xffffffff ),
- _vector2 = new THREE.Vector2(), // Needed for expand
- _vector3 = new THREE.Vector3(), // Needed for PointLight
- v5 = new THREE.Vector2(), v6 = new THREE.Vector2(), // Needed for latter splitting tris to quads
- uv1 = new THREE.UV(), uv2 = new THREE.UV(), uv3 = new THREE.UV(), uv4 = new THREE.UV();
- this.domElement = _canvas;
- this.autoClear = true;
- this.setSize = function ( width, height ) {
- _width = width; _height = height;
- _widthHalf = _width / 2; _heightHalf = _height / 2;
- _canvas.width = _width;
- _canvas.height = _height;
- _clipRect.set( - _widthHalf, - _heightHalf, _widthHalf, _heightHalf );
- };
- this.clear = function () {
- if ( !_clearRect.isEmpty() ) {
- _clearRect.inflate( 1 );
- _clearRect.minSelf( _clipRect );
- _context.setTransform( 1, 0, 0, - 1, _widthHalf, _heightHalf );
- _context.clearRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
- /*
- // Opera workaround
- _context.setTransform( 1, 0, 0, 1, _widthHalf, _heightHalf );
- _context.clearRect( _clearRect.getX(), - ( _clearRect.getHeight() + _clearRect.getY() ), _clearRect.getWidth(), _clearRect.getHeight() );
- */
- _clearRect.empty();
- }
- };
- this.render = function ( scene, camera ) {
- var e, el, element, m, ml, material, pi2 = Math.PI * 2,
- v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y,
- width, height, scaleX, scaleY, offsetX, offsetY,
- bitmap, bitmapWidth, bitmapHeight;
- if ( this.autoClear ) {
- this.clear();
- }
- _renderList = _projector.projectScene( scene, camera );
- _context.setTransform( 1, 0, 0, - 1, _widthHalf, _heightHalf );
- /* DEBUG
- _context.fillStyle = 'rgba(0, 255, 255, 0.5)';
- _context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
- */
- _enableLighting = scene.lights.length > 0;
- if ( _enableLighting ) {
- calculateAmbientLight( scene, _ambientLight );
- }
- for ( e = 0, el = _renderList.length; e < el; e++ ) {
- element = _renderList[ e ];
- _bboxRect.empty();
- if ( element instanceof THREE.RenderableParticle ) {
- v1x = element.x * _widthHalf; v1y = element.y * _heightHalf;
- for ( m = 0, ml = element.material.length; m < ml; m++ ) {
- material = element.material[ m ];
- if ( material instanceof THREE.ParticleCircleMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- width = element.scale.x * _widthHalf;
- height = element.scale.y * _heightHalf;
- _bboxRect.set( v1x - width, v1y - height, v1x + width, v1y + height );
- if ( !_clipRect.instersects( _bboxRect ) ) {
- continue;
- }
- _context.save();
- _context.translate( v1x, v1y );
- _context.rotate( - element.rotation );
- _context.scale( width, height );
- _context.beginPath();
- _context.arc( 0, 0, 1, 0, pi2, true );
- _context.closePath();
- _context.fillStyle = _color.__styleString;
- _context.fill();
- _context.restore();
- } else if ( material instanceof THREE.ParticleBitmapMaterial ) {
- bitmap = material.bitmap;
- bitmapWidth = bitmap.width / 2;
- bitmapHeight = bitmap.height / 2;
- scaleX = element.scale.x * _widthHalf;
- scaleY = element.scale.y * _heightHalf;
- width = scaleX * bitmapWidth;
- height = scaleY * bitmapHeight;
- offsetX = material.offset.x * scaleX;
- offsetY = material.offset.y * scaleY;
- // TODO: Rotations break this...
- _bboxRect.set( v1x + offsetX - width, v1y + offsetY - height, v1x + offsetX + width, v1y + offsetY + height );
- if ( !_clipRect.instersects( _bboxRect ) ) {
- continue;
- }
- _context.save();
- _context.translate( v1x, v1y );
- _context.rotate( - element.rotation );
- _context.scale( scaleX, - scaleY );
- _context.translate( - bitmapWidth + material.offset.x, - bitmapHeight - material.offset.y );
- _context.drawImage( bitmap, 0, 0 );
- _context.restore();
- /* DEBUG
- _context.beginPath();
- _context.moveTo( v1x - 10, v1y );
- _context.lineTo( v1x + 10, v1y );
- _context.moveTo( v1x, v1y - 10 );
- _context.lineTo( v1x, v1y + 10 );
- _context.closePath();
- _context.strokeStyle = 'rgb(255,255,0)';
- _context.stroke();
- */
- }
- }
- } else if ( element instanceof THREE.RenderableLine ) {
- v1x = element.v1.x * _widthHalf; v1y = element.v1.y * _heightHalf;
- v2x = element.v2.x * _widthHalf; v2y = element.v2.y * _heightHalf;
- _bboxRect.addPoint( v1x, v1y );
- _bboxRect.addPoint( v2x, v2y );
- if ( !_clipRect.instersects( _bboxRect ) ) {
- continue;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.closePath();
- for ( m = 0, ml = element.material.length; m < ml; m++ ) {
- material = element.material[ m ];
- if ( material instanceof THREE.LineColorMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- _context.lineWidth = material.lineWidth;
- _context.lineJoin = "round";
- _context.lineCap = "round";
- _context.strokeStyle = _color.__styleString;
- _context.stroke();
- _bboxRect.inflate( _context.lineWidth );
- }
- }
- } else if ( element instanceof THREE.RenderableFace3 ) {
- element.v1.x *= _widthHalf; element.v1.y *= _heightHalf;
- element.v2.x *= _widthHalf; element.v2.y *= _heightHalf;
- element.v3.x *= _widthHalf; element.v3.y *= _heightHalf;
- if ( element.overdraw ) {
- expand( element.v1, element.v2 );
- expand( element.v2, element.v3 );
- expand( element.v3, element.v1 );
- }
- v1x = element.v1.x; v1y = element.v1.y;
- v2x = element.v2.x; v2y = element.v2.y;
- v3x = element.v3.x; v3y = element.v3.y;
- _bboxRect.addPoint( v1x, v1y );
- _bboxRect.addPoint( v2x, v2y );
- _bboxRect.addPoint( v3x, v3y );
- if ( !_clipRect.instersects( _bboxRect ) ) {
- continue;
- }
- for ( m = 0, ml = element.material.length; m < ml; m++ ) {
- material = element.material[ m ];
- if ( material instanceof THREE.MeshColorFillMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = _color.__styleString;
- _context.fill();
- } else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.lineWidth = material.lineWidth;
- _context.lineJoin = "round";
- _context.lineCap = "round";
- _context.strokeStyle = _color.__styleString;
- _context.stroke();
- _bboxRect.inflate( _context.lineWidth );
- } else if ( material instanceof THREE.MeshFaceColorFillMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( element.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = element.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = _color.__styleString;
- _context.fill();
- } else if ( material instanceof THREE.MeshFaceColorStrokeMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( element.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = element.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.lineWidth = material.lineWidth;
- _context.lineJoin = "round";
- _context.lineCap = "round";
- _context.strokeStyle = _color.__styleString;
- _context.stroke();
- _bboxRect.inflate( _context.lineWidth );
- } else if ( material instanceof THREE.MeshBitmapUVMappingMaterial ) {
- bitmap = material.bitmap;
- bitmapWidth = bitmap.width - 1;
- bitmapHeight = bitmap.height - 1;
- /* DEBUG
- if ( !element.uvs[ 0 ] || !element.uvs[ 1 ] || !element.uvs[ 2 ]) {
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = 'rgb(0, 255, 0)';
- _context.fill();
- continue;
- }
- */
- uv1.copy( element.uvs[ 0 ] );
- uv2.copy( element.uvs[ 1 ] );
- uv3.copy( element.uvs[ 2 ] );
- uv1.u *= bitmapWidth; uv1.v *= bitmapHeight;
- uv2.u *= bitmapWidth; uv2.v *= bitmapHeight;
- uv3.u *= bitmapWidth; uv3.v *= bitmapHeight;
- drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, uv1.u, uv1.v, uv2.u, uv2.v, uv3.u, uv3.v );
- }
- }
- } else if ( element instanceof THREE.RenderableFace4 ) {
- element.v1.x *= _widthHalf; element.v1.y *= _heightHalf;
- element.v2.x *= _widthHalf; element.v2.y *= _heightHalf;
- element.v3.x *= _widthHalf; element.v3.y *= _heightHalf;
- element.v4.x *= _widthHalf; element.v4.y *= _heightHalf;
- v5.copy( element.v2 ); v6.copy( element.v4 );
- if ( element.overdraw ) {
- expand( element.v1, element.v2 );
- expand( element.v2, element.v4 );
- expand( element.v4, element.v1 );
- }
- v1x = element.v1.x; v1y = element.v1.y;
- v2x = element.v2.x; v2y = element.v2.y;
- v4x = element.v4.x; v4y = element.v4.y;
- if ( element.overdraw ) {
- expand( element.v3, v5 );
- expand( element.v3, v6 );
- }
- v3x = element.v3.x; v3y = element.v3.y;
- v5x = v5.x; v5y = v5.y;
- v6x = v6.x; v6y = v6.y;
- _bboxRect.addPoint( v1x, v1y );
- _bboxRect.addPoint( v2x, v2y );
- _bboxRect.addPoint( v3x, v3y );
- _bboxRect.addPoint( v4x, v4y );
- if ( !_clipRect.instersects( _bboxRect ) ) {
- continue;
- }
- for ( m = 0, ml = element.material.length; m < ml; m++ ) {
- material = element.material[ m ];
- if ( material instanceof THREE.MeshColorFillMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v4x, v4y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = _color.__styleString;
- _context.fill();
- } else if ( material instanceof THREE.MeshColorStrokeMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( material.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = material.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v4x, v4y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.lineWidth = material.lineWidth;
- _context.lineJoin = "round";
- _context.lineCap = "round";
- _context.strokeStyle = _color.__styleString;
- _context.stroke();
- _bboxRect.inflate( _context.lineWidth );
- } else if ( material instanceof THREE.MeshFaceColorFillMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( element.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = element.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v4x, v4y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = _color.__styleString;
- _context.fill();
- } else if ( material instanceof THREE.MeshFaceColorStrokeMaterial ) {
- if ( _enableLighting ) {
- _light.copyRGB( _ambientLight );
- calculateFaceLight( scene, element, _light );
- _color.copyRGBA( element.color );
- _color.multiplySelfRGB( _light );
- _color.updateStyleString();
- } else {
- _color = element.color;
- }
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v4x, v4y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.lineWidth = material.lineWidth;
- _context.lineJoin = "round";
- _context.lineCap = "round";
- _context.strokeStyle = _color.__styleString;
- _context.stroke();
- _bboxRect.inflate( _context.lineWidth );
- } else if ( material instanceof THREE.MeshBitmapUVMappingMaterial ) {
- bitmap = material.bitmap;
- bitmapWidth = bitmap.width - 1;
- bitmapHeight = bitmap.height - 1;
- /* DEBUG
- if ( !element.uvs[ 0 ] || !element.uvs[ 1 ] || !element.uvs[ 2 ] || !element.uvs[ 3 ]) {
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v4x, v4y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.fillStyle = 'rgb(255, 0, 255)';
- _context.fill();
- continue;
- }
- */
- uv1.copy( element.uvs[ 0 ] );
- uv2.copy( element.uvs[ 1 ] );
- uv3.copy( element.uvs[ 2 ] );
- uv4.copy( element.uvs[ 3 ] );
- uv1.u *= bitmapWidth; uv1.v *= bitmapHeight;
- uv2.u *= bitmapWidth; uv2.v *= bitmapHeight;
- uv3.u *= bitmapWidth; uv3.v *= bitmapHeight;
- uv4.u *= bitmapWidth; uv4.v *= bitmapHeight;
- drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v4x, v4y, uv1.u, uv1.v, uv2.u, uv2.v, uv4.u, uv4.v );
- drawTexturedTriangle( bitmap, v5x, v5y, v3x, v3y, v6x, v6y, uv2.u, uv2.v, uv3.u, uv3.v, uv4.u, uv4.v );
- }
- }
- }
- /*
- _context.lineWidth = 1;
- _context.strokeStyle = 'rgba( 0, 255, 0, 0.5 )';
- _context.strokeRect( _bboxRect.getX(), _bboxRect.getY(), _bboxRect.getWidth(), _bboxRect.getHeight() );
- */
- _clearRect.addRectangle( _bboxRect );
- }
- /* DEBUG
- _context.lineWidth = 1;
- _context.strokeStyle = 'rgba( 255, 0, 0, 0.5 )';
- _context.strokeRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
- */
- _context.setTransform( 1, 0, 0, 1, 0, 0 );
- };
- function calculateAmbientLight( scene, color ) {
- var l, ll, light;
- color.setRGBA( 1, 1, 1, 1 );
- for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
- light = scene.lights[ l ];
- if ( light instanceof THREE.AmbientLight ) {
- color.r *= light.color.r;
- color.g *= light.color.g;
- color.b *= light.color.b;
- }
- }
- }
- function calculateLight( scene, element, color ) {
- var l, ll, light;
- for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
- light = scene.lights[ l ];
- if ( light instanceof THREE.DirectionalLight ) {
- color.r += light.color.r;
- color.g += light.color.g;
- color.b += light.color.b;
- } else if ( light instanceof THREE.PointLight ) {
- color.r += light.color.r;
- color.g += light.color.g;
- color.b += light.color.b;
- }
- }
- }
- function calculateFaceLight( scene, element, color ) {
- var l, ll, light, amount;
- for ( l = 0, ll = scene.lights.length; l < ll; l++ ) {
- light = scene.lights[ l ];
- if ( light instanceof THREE.DirectionalLight ) {
- amount = element.normalWorld.dot( light.position ) * light.intensity;
- if ( amount > 0 ) {
- color.r += light.color.r * amount;
- color.g += light.color.g * amount;
- color.b += light.color.b * amount;
- }
- } else if ( light instanceof THREE.PointLight ) {
- _vector3.sub( light.position, element.centroidWorld );
- _vector3.normalize();
- amount = element.normalWorld.dot( _vector3 ) * light.intensity;
- if ( amount > 0 ) {
- color.r += light.color.r * amount;
- color.g += light.color.g * amount;
- color.b += light.color.b * amount;
- }
- }
- }
- }
- function drawTexturedTriangle( bitmap, v1x, v1y, v2x, v2y, v3x, v3y, uv1u, uv1v, uv2u, uv2v, uv3u, uv3v ) {
- // Textured triangle drawing by Thatcher Ulrich.
- // http://tulrich.com/geekstuff/canvas/jsgl.js
- var denom, m11, m12, m21, m22, dx, dy;
- _context.beginPath();
- _context.moveTo( v1x, v1y );
- _context.lineTo( v2x, v2y );
- _context.lineTo( v3x, v3y );
- _context.lineTo( v1x, v1y );
- _context.closePath();
- _context.save();
- _context.clip();
- denom = uv1u * ( uv3v - uv2v ) - uv2u * uv3v + uv3u * uv2v + ( uv2u - uv3u ) * uv1v;
- m11 = - ( uv1v * (v3x - v2x ) - uv2v * v3x + uv3v * v2x + ( uv2v - uv3v ) * v1x ) / denom;
- m12 = ( uv2v * v3y + uv1v * ( v2y - v3y ) - uv3v * v2y + ( uv3v - uv2v) * v1y ) / denom;
- m21 = ( uv1u * ( v3x - v2x ) - uv2u * v3x + uv3u * v2x + ( uv2u - uv3u ) * v1x ) / denom;
- m22 = - ( uv2u * v3y + uv1u * ( v2y - v3y ) - uv3u * v2y + ( uv3u - uv2u ) * v1y ) / denom;
- dx = ( uv1u * ( uv3v * v2x - uv2v * v3x ) + uv1v * ( uv2u * v3x - uv3u * v2x ) + ( uv3u * uv2v - uv2u * uv3v ) * v1x ) / denom;
- dy = ( uv1u * ( uv3v * v2y - uv2v * v3y ) + uv1v * ( uv2u * v3y - uv3u * v2y ) + ( uv3u * uv2v - uv2u * uv3v ) * v1y ) / denom;
- _context.transform( m11, m12, m21, m22, dx, dy );
- _context.drawImage( bitmap, 0, 0 );
- _context.restore();
- }
- // Hide anti-alias gaps
- function expand( a, b ) {
- _vector2.sub( b, a );
- _vector2.unit();
- _vector2.multiplyScalar( 0.75 );
- b.addSelf( _vector2 );
- a.subSelf( _vector2 );
- }
- };
|