Skip to content

Commit

Permalink
Merge pull request #11561 from sunag/86dev
Browse files Browse the repository at this point in the history
fix transform in SpriteNodeMaterial and example
  • Loading branch information
mrdoob authored Jun 19, 2017
2 parents 62d7d2f + 7df5d41 commit 304440c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 2 additions & 9 deletions examples/js/nodes/materials/SpriteNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ THREE.SpriteNode.prototype.build = function ( builder ) {
}

output.push(

"#include <project_vertex>",
"#include <fog_vertex>",

Expand All @@ -66,9 +65,7 @@ THREE.SpriteNode.prototype.build = function ( builder ) {
if ( ! this.spherical ) {

output.push(

'modelMtx[1][1] = 1.0;'

'modelMtx[1][1] = 1.0;'
);

}
Expand All @@ -79,31 +76,27 @@ THREE.SpriteNode.prototype.build = function ( builder ) {
'modelViewMtx[0][0] = 1.0;',
'modelViewMtx[0][1] = 0.0;',
'modelViewMtx[0][2] = 0.0;'

);

if ( this.spherical ) {

output.push(

// Second colunm.
'modelViewMtx[1][0] = 0.0;',
'modelViewMtx[1][1] = 1.0;',
'modelViewMtx[1][2] = 0.0;'

);

}

output.push(

// Thrid colunm.
'modelViewMtx[2][0] = 0.0;',
'modelViewMtx[2][1] = 0.0;',
'modelViewMtx[2][2] = 1.0;',

// apply
'gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( position, 1.0 );'
'gl_Position = projectionMatrix * modelViewMtx * modelMtx * vec4( transformed, 1.0 );'
);

} else {
Expand Down
10 changes: 10 additions & 0 deletions examples/webgl_sprites_nodes.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@
sprite2.material.color.coord = createHorizontalSpriteSheetNode( 8, 30 );
sprite2.material.color = new THREE.Math1Node( sprite2.material.color, THREE.Math1Node.INVERT );
sprite2.material.spherical = false; // look at camera horizontally only, very used to vegetation
// horizontal zigzag sprite
sprite2.material.transform = new THREE.OperatorNode(
new THREE.OperatorNode(
new THREE.Math1Node( new THREE.TimerNode( 0, 3 ), THREE.Math1Node.SIN ), // 3 is speed (time scale)
new THREE.Vector2Node( .3, 0 ), // horizontal scale (position)
THREE.OperatorNode.MUL
),
new THREE.PositionNode(),
THREE.OperatorNode.ADD
);
sprite2.material.build();

var sineWaveFunction = new THREE.FunctionNode( [
Expand Down

0 comments on commit 304440c

Please sign in to comment.