Browse Source

Refactored CSS3D billboard implementation.

Mr.doob 12 years ago
parent
commit
0fe4a8737b
2 changed files with 10 additions and 5 deletions
  1. 1 2
      examples/css3d_molecules.html
  2. 9 3
      examples/js/renderers/CSS3DRenderer.js

+ 1 - 2
examples/css3d_molecules.html

@@ -261,10 +261,9 @@
 						var atom = document.createElement( 'img' );
 						var atom = document.createElement( 'img' );
 						atom.src = colorSprite;
 						atom.src = colorSprite;
 
 
-						var object = new THREE.CSS3DObject( atom );
+						var object = new THREE.CSS3DSprite( atom );
 						object.position.copy( position );
 						object.position.copy( position );
 						object.position.multiplyScalar( 50 );
 						object.position.multiplyScalar( 50 );
-						object.billboard = true;
 						root.add( object );
 						root.add( object );
 
 
 						objects.push( object );
 						objects.push( object );

+ 9 - 3
examples/js/renderers/CSS3DRenderer.js

@@ -7,8 +7,6 @@ THREE.CSS3DObject = function ( element ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
 
 
-	this.billboard = false;
-
 	this.element = element;
 	this.element = element;
 	this.element.style.position = "absolute";
 	this.element.style.position = "absolute";
 	this.element.style.WebkitTransformStyle = 'preserve-3d';
 	this.element.style.WebkitTransformStyle = 'preserve-3d';
@@ -20,6 +18,14 @@ THREE.CSS3DObject = function ( element ) {
 
 
 THREE.CSS3DObject.prototype = Object.create( THREE.Object3D.prototype );
 THREE.CSS3DObject.prototype = Object.create( THREE.Object3D.prototype );
 
 
+THREE.CSS3DSprite = function ( element ) {
+
+	THREE.CSS3DObject.call( this, element );
+
+};
+
+THREE.CSS3DSprite.prototype = Object.create( THREE.CSS3DObject.prototype );
+
 //
 //
 
 
 THREE.CSS3DRenderer = function () {
 THREE.CSS3DRenderer = function () {
@@ -157,7 +163,7 @@ THREE.CSS3DRenderer = function () {
 
 
 				var element = object.element;
 				var element = object.element;
 
 
-				if ( object.billboard )	{
+				if ( object instanceof THREE.CSS3DSprite ) {
 
 
 					// http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
 					// http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/