Skip to content

Commit

Permalink
- ParticleBitmapMaterial.offset clearRect fixed
Browse files Browse the repository at this point in the history
- Face4 with MeshBitmapMaterial gap fixed
  • Loading branch information
mrdoob committed Jul 23, 2010
1 parent 217b150 commit 5fe1f2a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 191 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ Thanks to the power of the internets (and github <3) these people have kindly he

### Change Log ###

2010 07 23 - **r15** (32.440 kb)

* Using new object `UV` instead of `Vector2` where it should be used
* Added `Mesh.flipSided` boolean (false by default)
* `CanvasRenderer` was handling UVs at 1,1 as bitmapWidth, bitmapHeight (instead of bitmapWidth - 1, bitmapHeight - 1)
* `ParticleBitmapMaterial.offset` added
* Fixed gap when rendering `Face4` with `MeshBitmapUVMappingMaterial`


2010 07 17 - **r14** (32.144 kb)

* Refactored `CanvasRenderer` (more duplicated code, but easier to handle)
Expand All @@ -141,8 +150,6 @@ Thanks to the power of the internets (and github <3) these people have kindly he
* `FaceColorStrokeMaterial` > `MeshFaceColorStrokeMaterial`
* `ColorStrokeMaterial` > `LineColorMaterial`
* `Rectangle.instersects` returned false with rectangles with 0px witdh or height
* Using new object `UV` instead of `Vector2` where it should be used
* Added Mesh.flipSided boolean (false by default)


2010 07 12 - **r13** (29.492 kb)
Expand Down
2 changes: 1 addition & 1 deletion build/three.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/three_debug.js

Large diffs are not rendered by default.

177 changes: 0 additions & 177 deletions examples/particles.html

This file was deleted.

36 changes: 26 additions & 10 deletions src/renderers/CanvasRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ THREE.CanvasRenderer = function () {
_clipRect = new THREE.Rectangle(),
_clearRect = new THREE.Rectangle( 0, 0, 0, 0 ),
_bboxRect = new THREE.Rectangle(),
_vector2 = new THREE.Vector2();
_vector2 = new THREE.Vector2(),

v5 = new THREE.Vector2(), v6 = new THREE.Vector2(),
uv1 = new THREE.UV(), uv2 = new THREE.UV(), uv3 = new THREE.UV(), uv4 = new THREE.UV();

this.domElement = _canvas;
this.autoClear = true;
Expand Down Expand Up @@ -43,9 +46,8 @@ THREE.CanvasRenderer = function () {
this.render = function ( scene, camera ) {

var e, el, m, ml, element, material, pi2 = Math.PI * 2,
v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, width, height, scaleX, scaleY,

uv1 = new THREE.UV(), uv2 = new THREE.UV(), uv3 = new THREE.UV(), uv4 = new THREE.UV(),
v1x, v1y, v2x, v2y, v3x, v3y, v4x, v4y, v5x, v5y, v6x, v6y,
width, height, scaleX, scaleY, offsetX, offsetY,
bitmap, bitmapWidth, bitmapHeight;

if ( this.autoClear ) {
Expand Down Expand Up @@ -114,9 +116,12 @@ THREE.CanvasRenderer = function () {
width = scaleX * bitmapWidth;
height = scaleY * bitmapHeight;

// TODO: Rotations, offset break this...
offsetX = material.offset.x * scaleX;
offsetY = material.offset.y * scaleY;

_bboxRect.set( v1x - width, v1y - height, v1x + width, v1y + height );
// TODO: Rotations break this...

_bboxRect.set( v1x + offsetX - width, v1y + offsetY - height, v1x + offsetX + width, v1y + offsetY + height );

if ( !_clipRect.instersects( _bboxRect ) ) {

Expand Down Expand Up @@ -326,20 +331,31 @@ THREE.CanvasRenderer = function () {
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.v3 );
expand( element.v3, element.v4 );
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;
v3x = element.v3.x; v3y = element.v3.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 );
Expand Down Expand Up @@ -456,7 +472,7 @@ THREE.CanvasRenderer = function () {
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, v2x, v2y, v3x, v3y, v4x, v4y, uv2.u, uv2.v, uv3.u, uv3.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 );

}

Expand Down

0 comments on commit 5fe1f2a

Please sign in to comment.