Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions texture-animator.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,18 @@ AFRAME.registerComponent('texture-animator', {
this.tilesVertical = this.data.vtiles;
// how many images does this spritesheet contain?
// usually equals tilesHoriz * tilesVert, but not necessarily,
// if there at blank tiles at the bottom of the spritesheet.
// if there at blank tiles at the bottom of the spritesheet.

this.numberOfTiles = this.data.tiles;
this.texture = new THREE.ImageUtils.loadTexture( this.data.src ); // Gets the texture from the element
var loader = new THREE.TextureLoader();
this.texture = loader.load( this.data.src ); // Gets the texture from the element
//this.texture = this.el.getObject3D('mesh').material.map;

// Set image to doubleSide:
this.el.object3DMap.mesh.material.map = this.texture;
this.el.object3DMap.mesh.material.side = THREE.DoubleSide;

this.texture.wrapS = this.texture.wrapT = THREE.RepeatWrapping;
this.texture.wrapS = this.texture.wrapT = THREE.RepeatWrapping;
this.texture.repeat.set( 1 / this.tilesHorizontal, 1 / this.tilesVertical );

// how long should each image be displayed?
Expand Down