From dac392c5c269c38ec30f2e8f58a6f82b5049c138 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Fri, 14 Sep 2012 15:53:43 +0200 Subject: [PATCH] CSS3DRenderer doesn't need the appendChild hack anymore. However, it's not handling object removal yet. But I think I've an idea to handle all this stuff nicely... --- examples/js/renderers/CSS3DRenderer.js | 6 ++++ examples/misc_css3d.html | 39 +++++++++++++------------- utils/build_all.bat | 1 + utils/build_all.sh | 1 + 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/examples/js/renderers/CSS3DRenderer.js b/examples/js/renderers/CSS3DRenderer.js index a13c13551c..6f1b0ddb8c 100644 --- a/examples/js/renderers/CSS3DRenderer.js +++ b/examples/js/renderers/CSS3DRenderer.js @@ -146,6 +146,12 @@ THREE.CSS3DRenderer = function () { element.style.MozTransform = style; element.style.oTransform = style; + if ( element.parentNode !== this.cameraElement ) { + + this.cameraElement.appendChild( element ); + + } + } }; diff --git a/examples/misc_css3d.html b/examples/misc_css3d.html index f57f3f77c3..1667acf4f6 100644 --- a/examples/misc_css3d.html +++ b/examples/misc_css3d.html @@ -30,6 +30,20 @@ camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1000 ); camera.position.set( 200, 200, 200 ); + controls = new THREE.TrackballControls( camera ); + + controls.rotateSpeed = 1.0; + controls.zoomSpeed = 1.2; + controls.panSpeed = 0.8; + + controls.noZoom = false; + controls.noPan = false; + + controls.staticMoving = false; + controls.dynamicDampingFactor = 0.3; + + controls.keys = [ 65, 83, 68 ]; + scene = new THREE.Scene(); geometry = new THREE.CubeGeometry( 200, 200, 200 ); @@ -46,19 +60,12 @@ scene2 = new THREE.Scene(); - renderer2 = new THREE.CSS3DRenderer(); - renderer2.setSize( window.innerWidth, window.innerHeight ); - renderer2.domElement.style.position = 'absolute'; - renderer2.domElement.style.top = 0; - document.body.appendChild( renderer2.domElement ); - for ( var i = 0; i < 20; i ++ ) { var element = document.createElement( 'div' ); element.style.width = '100px'; element.style.height = '100px'; element.style.background = new THREE.Color( Math.random() * 0xffffff ).getContextStyle(); - renderer2.cameraElement.appendChild( element ); var object = new THREE.CSS3DObject( element ); object.position.x = Math.random() * 200 - 100; @@ -70,19 +77,13 @@ } - controls = new THREE.TrackballControls( camera ); - - controls.rotateSpeed = 1.0; - controls.zoomSpeed = 1.2; - controls.panSpeed = 0.8; - - controls.noZoom = false; - controls.noPan = false; - - controls.staticMoving = false; - controls.dynamicDampingFactor = 0.3; + // - controls.keys = [ 65, 83, 68 ]; + renderer2 = new THREE.CSS3DRenderer(); + renderer2.setSize( window.innerWidth, window.innerHeight ); + renderer2.domElement.style.position = 'absolute'; + renderer2.domElement.style.top = 0; + document.body.appendChild( renderer2.domElement ); } diff --git a/utils/build_all.bat b/utils/build_all.bat index 16b00984fd..36e14e7029 100644 --- a/utils/build_all.bat +++ b/utils/build_all.bat @@ -1,4 +1,5 @@ python build.py --include common --include extras --minify --output ../build/three.min.js python build.py --include canvas --minify --output ../build/three-canvas.min.js +python build.py --include css3d --minify --output ../build/three-css3d.min.js python build.py --include webgl --minify --output ../build/three-webgl.min.js python build.py --include extras --externs externs/extras.js --minify --output ../build/three-extras.min.js diff --git a/utils/build_all.sh b/utils/build_all.sh index 617d333758..26a656e237 100755 --- a/utils/build_all.sh +++ b/utils/build_all.sh @@ -2,5 +2,6 @@ python build.py --include common --include extras --minify --output ../build/three.min.js python build.py --include canvas --minify --output ../build/three-canvas.min.js +python build.py --include css3d --minify --output ../build/three-css3d.min.js python build.py --include webgl --minify --output ../build/three-webgl.min.js python build.py --include extras --externs externs/extras.js --minify --output ../build/three-extras.min.js -- GitLab