|
@@ -239,57 +239,63 @@ class CSS3DRenderer {
|
|
|
|
|
|
if ( object.isCSS3DObject ) {
|
|
|
|
|
|
- object.onBeforeRender( _this, scene, camera );
|
|
|
+ const visible = object.visible && object.layers.test( camera.layers );
|
|
|
+ object.element.style.display = visible ? '' : 'none';
|
|
|
|
|
|
- let style;
|
|
|
+ // only getObjectCSSMatrix when object.visible
|
|
|
+ if ( visible ) {
|
|
|
|
|
|
- if ( object.isCSS3DSprite ) {
|
|
|
+ object.onBeforeRender( _this, scene, camera );
|
|
|
|
|
|
- // http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
|
|
|
+ let style;
|
|
|
|
|
|
- _matrix.copy( camera.matrixWorldInverse );
|
|
|
- _matrix.transpose();
|
|
|
+ if ( object.isCSS3DSprite ) {
|
|
|
|
|
|
- if ( object.rotation2D !== 0 ) _matrix.multiply( _matrix2.makeRotationZ( object.rotation2D ) );
|
|
|
+ // http://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
|
|
|
|
|
|
- object.matrixWorld.decompose( _position, _quaternion, _scale );
|
|
|
- _matrix.setPosition( _position );
|
|
|
- _matrix.scale( _scale );
|
|
|
+ _matrix.copy( camera.matrixWorldInverse );
|
|
|
+ _matrix.transpose();
|
|
|
|
|
|
- _matrix.elements[ 3 ] = 0;
|
|
|
- _matrix.elements[ 7 ] = 0;
|
|
|
- _matrix.elements[ 11 ] = 0;
|
|
|
- _matrix.elements[ 15 ] = 1;
|
|
|
+ if ( object.rotation2D !== 0 ) _matrix.multiply( _matrix2.makeRotationZ( object.rotation2D ) );
|
|
|
|
|
|
- style = getObjectCSSMatrix( _matrix );
|
|
|
+ object.matrixWorld.decompose( _position, _quaternion, _scale );
|
|
|
+ _matrix.setPosition( _position );
|
|
|
+ _matrix.scale( _scale );
|
|
|
|
|
|
- } else {
|
|
|
+ _matrix.elements[ 3 ] = 0;
|
|
|
+ _matrix.elements[ 7 ] = 0;
|
|
|
+ _matrix.elements[ 11 ] = 0;
|
|
|
+ _matrix.elements[ 15 ] = 1;
|
|
|
|
|
|
- style = getObjectCSSMatrix( object.matrixWorld );
|
|
|
+ style = getObjectCSSMatrix( _matrix );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- const element = object.element;
|
|
|
- const cachedObject = cache.objects.get( object );
|
|
|
+ style = getObjectCSSMatrix( object.matrixWorld );
|
|
|
|
|
|
- if ( cachedObject === undefined || cachedObject.style !== style ) {
|
|
|
+ }
|
|
|
|
|
|
- element.style.transform = style;
|
|
|
+ const element = object.element;
|
|
|
+ const cachedObject = cache.objects.get( object );
|
|
|
|
|
|
- const objectData = { style: style };
|
|
|
- cache.objects.set( object, objectData );
|
|
|
+ if ( cachedObject === undefined || cachedObject.style !== style ) {
|
|
|
|
|
|
- }
|
|
|
+ element.style.transform = style;
|
|
|
|
|
|
- element.style.display = object.visible ? '' : 'none';
|
|
|
+ const objectData = { style: style };
|
|
|
+ cache.objects.set( object, objectData );
|
|
|
|
|
|
- if ( element.parentNode !== cameraElement ) {
|
|
|
+ }
|
|
|
|
|
|
- cameraElement.appendChild( element );
|
|
|
+ if ( element.parentNode !== cameraElement ) {
|
|
|
|
|
|
- }
|
|
|
+ cameraElement.appendChild( element );
|
|
|
|
|
|
- object.onAfterRender( _this, scene, camera );
|
|
|
+ }
|
|
|
+
|
|
|
+ object.onAfterRender( _this, scene, camera );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|