From ad8285db7486a81cae4776e642aae07937033984 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Thu, 28 May 2015 16:10:47 +0200 Subject: [PATCH] Fixed some transparency issue --- js/Makefile | 2 ++ js/compiler.sh | 6 +++++- js/prototype/initScene.js | 16 ++++++++++------ js/prototype/tutorial.js | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/js/Makefile b/js/Makefile index c26d48b..94a06ff 100644 --- a/js/Makefile +++ b/js/Makefile @@ -10,6 +10,8 @@ all: Three Stats ThreeTools Bouncing Multisphere StreamingSimulator PrototypeToo Three: cp three/three.min.js ../static/js/ + $(CLOSURE) $(OPT) \ + --js three/threex.transparency.js >> ../static/js/three.min.js Stats: cp three/stats.min.js ../static/js/ diff --git a/js/compiler.sh b/js/compiler.sh index de38a0a..665c19e 100755 --- a/js/compiler.sh +++ b/js/compiler.sh @@ -19,4 +19,8 @@ while [[ $# > 0 ]]; do done -cat $args > $output +if [ -z "$output" ]; then + cat $args +else + cat $args > $output +fi diff --git a/js/prototype/initScene.js b/js/prototype/initScene.js index 22ba442..8c26c3a 100644 --- a/js/prototype/initScene.js +++ b/js/prototype/initScene.js @@ -26,12 +26,16 @@ function initPeachCastle(scene, collidableObjects, loader, static_path) { object.material.side = THREE.DoubleSide; object.raycastable = true; if (object.material.name === 'Material.103_princess_peaches_cast') { - object.material.transparent = true; + THREEx.Transparency.push(object); } else if (object.material.name === 'Material.136_princess_peaches_cast') { - object.material.transparent = true; + THREEx.Transparency.push(object); object.material.opacity = 0.5; + object.material.side = THREE.FrontSide; object.raycastable = false; - + var newObj = object.clone(); + newObj.material = object.material.clone(); + newObj.material.side = THREE.BackSide; + scene.add(newObj); } } }); @@ -60,7 +64,7 @@ function initPeachCastle(scene, collidableObjects, loader, static_path) { object.raycastable = true; if (object.material.name === 'Material.054_777F0E0B_c.bmp' || object.material.name === 'Material.061_5C3492AB_c.bmp' ) { - object.material.transparent = true; + THREEx.Transparency.push(object); } } }); @@ -100,7 +104,7 @@ function initZeldaScene(scene, collidableObjects, loader, static_path) { object.material.side = THREE.DoubleSide; object.raycastable = true; if (object.material.name === 'm0') { - object.material.transparent = true; + THREEx.Transparency.push(object); } } }); @@ -223,7 +227,7 @@ function initBobombScene(scene, collidableObjects, loader, static_path) { object.geometry.computeVertexNormals(); if (object.material.name === 'Material.071_574B138E_c.bmp' || object.material.name === 'Material.070_41A41EE3_c.bmp') { - object.material.transparent = true; + THREEx.Transparency.push(object); } } diff --git a/js/prototype/tutorial.js b/js/prototype/tutorial.js index 3d9e356..15f893a 100644 --- a/js/prototype/tutorial.js +++ b/js/prototype/tutorial.js @@ -237,6 +237,7 @@ function render() { renderer.setScissor(left, bottom, width, height); renderer.enableScissorTest(true); renderer.setViewport(left, bottom, width, height); + THREEx.Transparency.update(cameras.mainCamera()); renderer.render(scene, cameras.mainCamera()); // Remove borders of preview