提交 ce4cae51 编写于 作者: A alteredq

Another batch of examples resizing handling.

上级 42d67983
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
font-family: Monospace; font-family: Monospace;
background-color: #f0f0f0; background-color: #f0f0f0;
margin: 0px; margin: 0px;
overflow: hidden; overflow: hidden;
} }
</style> </style>
</head> </head>
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<script src="../build/Three.js"></script> <script src="../build/Three.js"></script>
<script src="js/effects/AsciiEffect.js"></script> <script src="js/effects/AsciiEffect.js"></script>
<script src="js/Stats.js"></script> <script src="js/Stats.js"></script>
<script> <script>
var container, stats; var container, stats;
...@@ -34,6 +35,9 @@ ...@@ -34,6 +35,9 @@
function init() { function init() {
var width = window.innerWidth || 2;
var height = window.innerHeight || 2;
container = document.createElement( 'div' ); container = document.createElement( 'div' );
document.body.appendChild( container ); document.body.appendChild( container );
...@@ -47,7 +51,7 @@ ...@@ -47,7 +51,7 @@
scene = new THREE.Scene(); scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 ); camera = new THREE.PerspectiveCamera( 70, width / height, 1, 1000 );
camera.position.y = 150; camera.position.y = 150;
camera.position.z = 500; camera.position.z = 500;
scene.add( camera ); scene.add( camera );
...@@ -72,10 +76,11 @@ ...@@ -72,10 +76,11 @@
scene.add( plane ); scene.add( plane );
renderer = new THREE.CanvasRenderer(); renderer = new THREE.CanvasRenderer();
renderer.setSize( width, height );
// container.appendChild( renderer.domElement ); // container.appendChild( renderer.domElement );
effect = new THREE.AsciiEffect( renderer ); effect = new THREE.AsciiEffect( renderer );
effect.setSize( window.innerWidth, window.innerHeight ); effect.setSize( width, height );
container.appendChild( effect.domElement ); container.appendChild( effect.domElement );
stats = new Stats(); stats = new Stats();
...@@ -83,6 +88,20 @@ ...@@ -83,6 +88,20 @@
stats.domElement.style.top = '0px'; stats.domElement.style.top = '0px';
container.appendChild( stats.domElement ); container.appendChild( stats.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
effect.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
cube.position.y = ( cube.scale.y * 50 ) / 2; cube.position.y = ( cube.scale.y * 50 ) / 2;
cube.position.z = Math.floor( ( Math.random() * 1000 - 500 ) / 50 ) * 50 + 25; cube.position.z = Math.floor( ( Math.random() * 1000 - 500 ) / 50 ) * 50 + 25;
scene.add(cube); scene.add( cube );
} }
...@@ -117,6 +117,23 @@ ...@@ -117,6 +117,23 @@
stats.domElement.style.top = '0px'; stats.domElement.style.top = '0px';
container.appendChild( stats.domElement ); container.appendChild( stats.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.left = window.innerWidth / - 2;
camera.right = window.innerWidth / 2;
camera.top = window.innerHeight / 2;
camera.bottom = window.innerHeight / - 2;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -383,6 +383,19 @@ ...@@ -383,6 +383,19 @@
document.getElementById( 'container' ).appendChild(stats.domElement); document.getElementById( 'container' ).appendChild(stats.domElement);
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
......
...@@ -91,6 +91,23 @@ ...@@ -91,6 +91,23 @@
document.addEventListener( 'mousedown', onDocumentMouseDown, false ); document.addEventListener( 'mousedown', onDocumentMouseDown, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
...@@ -105,6 +122,7 @@ ...@@ -105,6 +122,7 @@
mouseXOnMouseDown = event.clientX - windowHalfX; mouseXOnMouseDown = event.clientX - windowHalfX;
targetRotationOnMouseDown = targetRotation; targetRotationOnMouseDown = targetRotation;
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
...@@ -112,6 +130,7 @@ ...@@ -112,6 +130,7 @@
mouseX = event.clientX - windowHalfX; mouseX = event.clientX - windowHalfX;
targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02; targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
} }
function onDocumentMouseUp( event ) { function onDocumentMouseUp( event ) {
...@@ -119,6 +138,7 @@ ...@@ -119,6 +138,7 @@
document.removeEventListener( 'mousemove', onDocumentMouseMove, false ); document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
document.removeEventListener( 'mouseup', onDocumentMouseUp, false ); document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
document.removeEventListener( 'mouseout', onDocumentMouseOut, false ); document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
} }
function onDocumentMouseOut( event ) { function onDocumentMouseOut( event ) {
...@@ -126,11 +146,12 @@ ...@@ -126,11 +146,12 @@
document.removeEventListener( 'mousemove', onDocumentMouseMove, false ); document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
document.removeEventListener( 'mouseup', onDocumentMouseUp, false ); document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
document.removeEventListener( 'mouseout', onDocumentMouseOut, false ); document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
} }
function onDocumentTouchStart( event ) { function onDocumentTouchStart( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
...@@ -138,11 +159,12 @@ ...@@ -138,11 +159,12 @@
targetRotationOnMouseDown = targetRotation; targetRotationOnMouseDown = targetRotation;
} }
} }
function onDocumentTouchMove( event ) { function onDocumentTouchMove( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
...@@ -150,6 +172,7 @@ ...@@ -150,6 +172,7 @@
targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.05; targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.05;
} }
} }
// //
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
scene.add( group ); scene.add( group );
// earth // earth
var earthTexture = new THREE.Texture(); var earthTexture = new THREE.Texture();
var loader = new THREE.ImageLoader(); var loader = new THREE.ImageLoader();
...@@ -84,12 +84,12 @@ ...@@ -84,12 +84,12 @@
group.add( mesh ); group.add( mesh );
// shadow // shadow
var shadowTexture = new THREE.Texture(); var shadowTexture = new THREE.Texture();
var loader = new THREE.ImageLoader(); var loader = new THREE.ImageLoader();
loader.addEventListener( 'load', function ( event ) { loader.addEventListener( 'load', function ( event ) {
shadowTexture.image = event.content; shadowTexture.image = event.content;
shadowTexture.needsUpdate = true; shadowTexture.needsUpdate = true;
...@@ -116,6 +116,22 @@ ...@@ -116,6 +116,22 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
......
...@@ -82,6 +82,22 @@ ...@@ -82,6 +82,22 @@
stats.domElement.style.zIndex = 100; stats.domElement.style.zIndex = 100;
container.appendChild( stats.domElement ); container.appendChild( stats.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove(event) { function onDocumentMouseMove(event) {
......
...@@ -96,6 +96,21 @@ ...@@ -96,6 +96,21 @@
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
render();
} }
function loadTexture( path ) { function loadTexture( path ) {
...@@ -141,6 +156,7 @@ ...@@ -141,6 +156,7 @@
render(); render();
} }
} }
function onDocumentMouseUp( event ) { function onDocumentMouseUp( event ) {
......
...@@ -106,6 +106,21 @@ ...@@ -106,6 +106,21 @@
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
render();
} }
function loadTexture( path ) { function loadTexture( path ) {
......
...@@ -98,6 +98,22 @@ ...@@ -98,6 +98,22 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function generateHeight( width, height ) { function generateHeight( width, height ) {
......
...@@ -120,6 +120,22 @@ ...@@ -120,6 +120,22 @@
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -102,6 +102,19 @@ ...@@ -102,6 +102,19 @@
document.addEventListener( 'mousedown', onDocumentMouseDown, false ); document.addEventListener( 'mousedown', onDocumentMouseDown, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseDown( event ) { function onDocumentMouseDown( event ) {
......
...@@ -81,6 +81,19 @@ ...@@ -81,6 +81,19 @@
document.addEventListener( 'mousedown', onDocumentMouseDown, false ); document.addEventListener( 'mousedown', onDocumentMouseDown, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseDown( event ) { function onDocumentMouseDown( event ) {
......
...@@ -95,6 +95,19 @@ ...@@ -95,6 +95,19 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
......
...@@ -115,6 +115,19 @@ ...@@ -115,6 +115,19 @@
document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keydown', onDocumentKeyDown, false );
document.addEventListener( 'keyup', onDocumentKeyUp, false ); document.addEventListener( 'keyup', onDocumentKeyUp, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
......
...@@ -106,6 +106,19 @@ ...@@ -106,6 +106,19 @@
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement ); container.appendChild( renderer.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -108,6 +108,19 @@ ...@@ -108,6 +108,19 @@
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement ); container.appendChild( renderer.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -97,6 +97,23 @@ ...@@ -97,6 +97,23 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
...@@ -105,6 +122,7 @@ ...@@ -105,6 +122,7 @@
mouseX = event.clientX - windowHalfX; mouseX = event.clientX - windowHalfX;
mouseY = event.clientY - windowHalfY; mouseY = event.clientY - windowHalfY;
} }
function onDocumentTouchStart( event ) { function onDocumentTouchStart( event ) {
......
...@@ -111,6 +111,23 @@ ...@@ -111,6 +111,23 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -162,6 +162,19 @@ ...@@ -162,6 +162,19 @@
stats.domElement.style.top = '0px'; stats.domElement.style.top = '0px';
container.appendChild(stats.domElement); container.appendChild(stats.domElement);
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function loadImage( path ) { function loadImage( path ) {
......
...@@ -33,9 +33,6 @@ ...@@ -33,9 +33,6 @@
var mouseX = 0; var mouseX = 0;
var mouseXOnMouseDown = 0; var mouseXOnMouseDown = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var moveForward = false; var moveForward = false;
var moveBackwards = false; var moveBackwards = false;
var moveLeft = false; var moveLeft = false;
...@@ -121,6 +118,20 @@ ...@@ -121,6 +118,20 @@
document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keydown', onDocumentKeyDown, false );
document.addEventListener( 'keyup', onDocumentKeyUp, false ); document.addEventListener( 'keyup', onDocumentKeyUp, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentKeyDown( event ) { function onDocumentKeyDown( event ) {
......
...@@ -72,6 +72,19 @@ ...@@ -72,6 +72,19 @@
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement ); container.appendChild( renderer.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -75,6 +75,19 @@ ...@@ -75,6 +75,19 @@
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement ); container.appendChild( renderer.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
scene.add( particle ); scene.add( particle );
} }
} }
renderer = new THREE.CanvasRenderer(); renderer = new THREE.CanvasRenderer();
...@@ -165,9 +166,25 @@ ...@@ -165,9 +166,25 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove(event) { function onDocumentMouseMove( event ) {
mouseX = ( event.clientX - windowHalfX ); mouseX = ( event.clientX - windowHalfX );
mouseY = ( event.clientY - windowHalfY ) * 0.2; mouseY = ( event.clientY - windowHalfY ) * 0.2;
......
...@@ -88,11 +88,28 @@ ...@@ -88,11 +88,28 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
function onDocumentMouseMove(event) { function onDocumentMouseMove( event ) {
mouseX = event.clientX - windowHalfX; mouseX = event.clientX - windowHalfX;
mouseY = event.clientY - windowHalfY; mouseY = event.clientY - windowHalfY;
...@@ -118,6 +135,7 @@ ...@@ -118,6 +135,7 @@
mouseX = event.touches[ 0 ].pageX - windowHalfX; mouseX = event.touches[ 0 ].pageX - windowHalfX;
mouseY = event.touches[ 0 ].pageY - windowHalfY; mouseY = event.touches[ 0 ].pageY - windowHalfY;
} }
} }
// //
......
...@@ -81,6 +81,23 @@ ...@@ -81,6 +81,23 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
...@@ -93,24 +110,28 @@ ...@@ -93,24 +110,28 @@
function onDocumentTouchStart( event ) { function onDocumentTouchStart( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
mouseX = event.touches[ 0 ].pageX - windowHalfX; mouseX = event.touches[ 0 ].pageX - windowHalfX;
mouseY = event.touches[ 0 ].pageY - windowHalfY; mouseY = event.touches[ 0 ].pageY - windowHalfY;
} }
} }
function onDocumentTouchMove( event ) { function onDocumentTouchMove( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
mouseX = event.touches[ 0 ].pageX - windowHalfX; mouseX = event.touches[ 0 ].pageX - windowHalfX;
mouseY = event.touches[ 0 ].pageY - windowHalfY; mouseY = event.touches[ 0 ].pageY - windowHalfY;
} }
} }
// //
......
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
heartShape.bezierCurveTo( x + 35, y, x + 25, y + 25, x + 25, y + 25 ); heartShape.bezierCurveTo( x + 35, y, x + 25, y + 25, x + 25, y + 25 );
var circleLines = function ( context ) { var circleLines = function ( context ) {
context.lineWidth = 0.05; context.lineWidth = 0.05;
context.beginPath(); context.beginPath();
context.arc( 0, 0, 1, 0, Math.PI*2, true ); context.arc( 0, 0, 1, 0, Math.PI*2, true );
...@@ -146,11 +147,13 @@ ...@@ -146,11 +147,13 @@
context.globalAlpha = 0.2; context.globalAlpha = 0.2;
context.fill(); context.fill();
} }
var hue = 0; var hue = 0;
var hearts = function ( context ) { var hearts = function ( context ) {
context.globalAlpha = 0.5; context.globalAlpha = 0.5;
var x = 0, y = 0; var x = 0, y = 0;
context.scale(0.1, -0.1); // Scale so canvas render can redraw within bounds context.scale(0.1, -0.1); // Scale so canvas render can redraw within bounds
...@@ -166,6 +169,7 @@ ...@@ -166,6 +169,7 @@
context.fill(); context.fill();
context.lineWidth = 0.5; //0.05 context.lineWidth = 0.5; //0.05
context.stroke(); context.stroke();
} }
var setTargetParticle = function() { var setTargetParticle = function() {
...@@ -183,6 +187,7 @@ ...@@ -183,6 +187,7 @@
particleCloud.add( particle ); particleCloud.add( particle );
return particle; return particle;
}; };
var onParticleCreated = function(p) { var onParticleCreated = function(p) {
...@@ -233,6 +238,22 @@ ...@@ -233,6 +238,22 @@
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
...@@ -246,10 +267,14 @@ ...@@ -246,10 +267,14 @@
mouseXOnMouseDown = event.clientX - windowHalfX; mouseXOnMouseDown = event.clientX - windowHalfX;
targetRotationOnMouseDown = targetRotation; targetRotationOnMouseDown = targetRotation;
if (sparksEmitter.isRunning()) { if ( sparksEmitter.isRunning() ) {
sparksEmitter.stop(); sparksEmitter.stop();
} else { } else {
sparksEmitter.start(); sparksEmitter.start();
} }
} }
......
...@@ -72,8 +72,24 @@ ...@@ -72,8 +72,24 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
} }
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function generateSprite() { function generateSprite() {
......
...@@ -93,6 +93,23 @@ ...@@ -93,6 +93,23 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false ); document.addEventListener( 'touchstart', onDocumentTouchStart, false );
document.addEventListener( 'touchmove', onDocumentTouchMove, false ); document.addEventListener( 'touchmove', onDocumentTouchMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
...@@ -106,7 +123,7 @@ ...@@ -106,7 +123,7 @@
function onDocumentTouchStart( event ) { function onDocumentTouchStart( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
...@@ -119,7 +136,7 @@ ...@@ -119,7 +136,7 @@
function onDocumentTouchMove( event ) { function onDocumentTouchMove( event ) {
if ( event.touches.length == 1 ) { if ( event.touches.length === 1 ) {
event.preventDefault(); event.preventDefault();
...@@ -158,6 +175,7 @@ ...@@ -158,6 +175,7 @@
particle.scale.x = particle.scale.y = ( Math.sin( ( ix + count ) * 0.3 ) + 1 ) * 2 + ( Math.sin( ( iy + count ) * 0.5 ) + 1 ) * 2; particle.scale.x = particle.scale.y = ( Math.sin( ( ix + count ) * 0.3 ) + 1 ) * 2 + ( Math.sin( ( iy + count ) * 0.5 ) + 1 ) * 2;
} }
} }
renderer.render( scene, camera ); renderer.render( scene, camera );
......
...@@ -27,15 +27,6 @@ ...@@ -27,15 +27,6 @@
var sphere, plane; var sphere, plane;
var targetRotation = 0;
var targetRotationOnMouseDown = 0;
var mouseX = 0;
var mouseXOnMouseDown = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
init(); init();
animate(); animate();
...@@ -112,6 +103,19 @@ ...@@ -112,6 +103,19 @@
stats.domElement.style.top = '0px'; stats.domElement.style.top = '0px';
container.appendChild(stats.domElement); container.appendChild(stats.domElement);
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
// //
......
...@@ -155,6 +155,23 @@ ...@@ -155,6 +155,23 @@
document.addEventListener( 'keydown', onDocumentKeyDown, false ); document.addEventListener( 'keydown', onDocumentKeyDown, false );
document.addEventListener( 'keyup', onDocumentKeyUp, false ); document.addEventListener( 'keyup', onDocumentKeyUp, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentKeyDown( event ) { function onDocumentKeyDown( event ) {
......
/* /*
* @author zz85 / https://github.com/zz85 * @author zz85 / https://github.com/zz85
* *
* Ascii generation is based on http://www.nihilogic.dk/labs/jsascii/ * Ascii generation is based on http://www.nihilogic.dk/labs/jsascii/
* Maybe more about this later with a blog post at http://lab4games.net/zz85/blog * Maybe more about this later with a blog post at http://lab4games.net/zz85/blog
* *
* 16 April 2012 - @blurspline * 16 April 2012 - @blurspline
*/ */
THREE.AsciiEffect = function ( renderer, charSet, options ) { THREE.AsciiEffect = function ( renderer, charSet, options ) {
// its fun to create one your own! // its fun to create one your own!
charSet = (charSet === undefined) ? ' .:-=+*#%@' : charSet;
charSet = ( charSet === undefined ) ? ' .:-=+*#%@' : charSet;
// ' .,:;=|iI+hHOE#`$';
// ' .,:;=|iI+hHOE#`$';
// darker bolder character set from https://github.com/saw/Canvas-ASCII-Art/ // darker bolder character set from https://github.com/saw/Canvas-ASCII-Art/
// ' .\'`^",:;Il!i~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'.split(''); // ' .\'`^",:;Il!i~+_-?][}{1)(|/tfjrxnuvczXYUJCLQ0OZmwqpdbkhao*#MW&8%B@$'.split('');
if (!options) options = {}; if ( !options ) options = {};
// Some ASCII settings // Some ASCII settings
var bResolution = !options['resolution'] ? 0.15 : options['resolution']; // Higher for more details var bResolution = !options['resolution'] ? 0.15 : options['resolution']; // Higher for more details
var iScale = !options['scale'] ? 1 : options['scale']; var iScale = !options['scale'] ? 1 : options['scale'];
var bColor = !options['color'] ? false : options['color']; // nice but slows down rendering! var bColor = !options['color'] ? false : options['color']; // nice but slows down rendering!
var bAlpha = !options['alpha'] ? false : options['alpha']; // Transparency var bAlpha = !options['alpha'] ? false : options['alpha']; // Transparency
var bBlock = !options['block'] ? false : options['block']; // blocked characters. like good O dos var bBlock = !options['block'] ? false : options['block']; // blocked characters. like good O dos
var bInvert = !options['invert'] ? false : options['invert']; // black is white, white is black var bInvert = !options['invert'] ? false : options['invert']; // black is white, white is black
var strResolution = 'low'; var strResolution = 'low';
var width, height; var width, height;
...@@ -33,7 +36,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -33,7 +36,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
domElement.style.cursor = 'default'; domElement.style.cursor = 'default';
var oAscii = document.createElement("table"); var oAscii = document.createElement("table");
domElement.appendChild(oAscii); domElement.appendChild( oAscii );
var iWidth, iHeight; var iWidth, iHeight;
var oImg; var oImg;
...@@ -61,6 +64,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -61,6 +64,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// Throw in ascii library from http://www.nihilogic.dk/labs/jsascii/jsascii.js // Throw in ascii library from http://www.nihilogic.dk/labs/jsascii/jsascii.js
/* /*
* jsAscii 0.1 * jsAscii 0.1
* Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
...@@ -68,8 +72,9 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -68,8 +72,9 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
*/ */
function initAsciiSize() { function initAsciiSize() {
iWidth = Math.round(width * fResolution);
iHeight = Math.round(height * fResolution); iWidth = Math.round( width * fResolution );
iHeight = Math.round( height * fResolution );
oCanvas.width = iWidth; oCanvas.width = iWidth;
oCanvas.height = iHeight; oCanvas.height = iHeight;
...@@ -78,9 +83,12 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -78,9 +83,12 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// oCanvas.style.height = iHeight; // oCanvas.style.height = iHeight;
oImg = renderer.domElement; oImg = renderer.domElement;
if (oImg.style.backgroundColor) {
if ( oImg.style.backgroundColor ) {
oAscii.rows[0].cells[0].style.backgroundColor = oImg.style.backgroundColor; oAscii.rows[0].cells[0].style.backgroundColor = oImg.style.backgroundColor;
oAscii.rows[0].cells[0].style.color = oImg.style.color; oAscii.rows[0].cells[0].style.color = oImg.style.color;
} }
oAscii.cellSpacing = 0; oAscii.cellSpacing = 0;
...@@ -112,6 +120,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -112,6 +120,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
if (!oCanvas.getContext) { if (!oCanvas.getContext) {
return; return;
} }
var oCtx = oCanvas.getContext("2d"); var oCtx = oCanvas.getContext("2d");
if (!oCtx.getImageData) { if (!oCtx.getImageData) {
return; return;
...@@ -119,49 +128,63 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -119,49 +128,63 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
var aCharList = (bColor ? aDefaultColorCharList : aDefaultCharList); var aCharList = (bColor ? aDefaultColorCharList : aDefaultCharList);
if (charSet) aCharList = charSet; if (charSet) aCharList = charSet;
var fResolution = 0.5; var fResolution = 0.5;
switch (strResolution) {
switch ( strResolution ) {
case "low" : fResolution = 0.25; break; case "low" : fResolution = 0.25; break;
case "medium" : fResolution = 0.5; break; case "medium" : fResolution = 0.5; break;
case "high" : fResolution = 1; break; case "high" : fResolution = 1; break;
} }
if (bResolution) fResolution = bResolution; if ( bResolution ) fResolution = bResolution;
// Setup dom // Setup dom
var fFontSize = (2/fResolution)*iScale; var fFontSize = (2/fResolution)*iScale;
var fLineHeight = (2/fResolution)*iScale; var fLineHeight = (2/fResolution)*iScale;
// adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width. // adjust letter-spacing for all combinations of scale and resolution to get it to fit the image width.
var fLetterSpacing = 0; var fLetterSpacing = 0;
if (strResolution == "low") {
if ( strResolution == "low" ) {
switch (iScale) { switch (iScale) {
case 1 : fLetterSpacing = -1; break; case 1 : fLetterSpacing = -1; break;
case 2 : case 2 :
case 3 : fLetterSpacing = -2.1; break; case 3 : fLetterSpacing = -2.1; break;
case 4 : fLetterSpacing = -3.1; break; case 4 : fLetterSpacing = -3.1; break;
case 5 : fLetterSpacing = -4.15; break; case 5 : fLetterSpacing = -4.15; break;
} }
} }
if (strResolution == "medium") {
if ( strResolution == "medium" ) {
switch (iScale) { switch (iScale) {
case 1 : fLetterSpacing = 0; break; case 1 : fLetterSpacing = 0; break;
case 2 : fLetterSpacing = -1; break; case 2 : fLetterSpacing = -1; break;
case 3 : fLetterSpacing = -1.04; break; case 3 : fLetterSpacing = -1.04; break;
case 4 : case 4 :
case 5 : fLetterSpacing = -2.1; break; case 5 : fLetterSpacing = -2.1; break;
} }
} }
if (strResolution == "high") {
if ( strResolution == "high" ) {
switch (iScale) { switch (iScale) {
case 1 : case 1 :
case 2 : fLetterSpacing = 0; break; case 2 : fLetterSpacing = 0; break;
case 3 : case 3 :
case 4 : case 4 :
case 5 : fLetterSpacing = -1; break; case 5 : fLetterSpacing = -1; break;
} }
} }
...@@ -169,10 +192,11 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -169,10 +192,11 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
// convert img element to ascii // convert img element to ascii
function asciifyImage(canvasRenderer, oAscii) {
oCtx.clearRect(0, 0, iWidth, iHeight); function asciifyImage( canvasRenderer, oAscii ) {
oCtx.drawImage(oCanvasImg, 0, 0, iWidth, iHeight);
oCtx.clearRect( 0, 0, iWidth, iHeight );
oCtx.drawImage( oCanvasImg, 0, 0, iWidth, iHeight );
var oImgData = oCtx.getImageData(0, 0, iWidth, iHeight).data; var oImgData = oCtx.getImageData(0, 0, iWidth, iHeight).data;
// Coloring loop starts now // Coloring loop starts now
...@@ -183,7 +207,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -183,7 +207,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
for (var y=0;y<iHeight;y+=2) { for (var y=0;y<iHeight;y+=2) {
for (var x=0;x<iWidth;x++) { for (var x=0;x<iWidth;x++) {
var iOffset = (y*iWidth + x) * 4; var iOffset = (y*iWidth + x) * 4;
var iRed = oImgData[iOffset]; var iRed = oImgData[iOffset];
var iGreen = oImgData[iOffset + 1]; var iGreen = oImgData[iOffset + 1];
var iBlue = oImgData[iOffset + 2]; var iBlue = oImgData[iOffset + 2];
...@@ -194,14 +218,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -194,14 +218,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
fBrightness = (0.3*iRed + 0.59*iGreen + 0.11*iBlue) / 255; fBrightness = (0.3*iRed + 0.59*iGreen + 0.11*iBlue) / 255;
// fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255; // fBrightness = (0.3*iRed + 0.5*iGreen + 0.3*iBlue) / 255;
if (iAlpha == 0) { if (iAlpha == 0) {
// should calculate alpha instead, but quick hack :) // should calculate alpha instead, but quick hack :)
//fBrightness *= (iAlpha / 255); //fBrightness *= (iAlpha / 255);
fBrightness = 1; fBrightness = 1;
} }
iCharIdx = Math.floor((1-fBrightness) * (aCharList.length-1)); iCharIdx = Math.floor((1-fBrightness) * (aCharList.length-1));
if (bInvert) { if (bInvert) {
...@@ -212,7 +236,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -212,7 +236,7 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
//fBrightness = Math.floor(fBrightness * 10); //fBrightness = Math.floor(fBrightness * 10);
//strThisChar = fBrightness; //strThisChar = fBrightness;
var strThisChar = aCharList[iCharIdx]; var strThisChar = aCharList[iCharIdx];
if (strThisChar===undefined || strThisChar == " ") if (strThisChar===undefined || strThisChar == " ")
strThisChar = "&nbsp;"; strThisChar = "&nbsp;";
...@@ -229,14 +253,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) { ...@@ -229,14 +253,14 @@ THREE.AsciiEffect = function ( renderer, charSet, options ) {
} }
strChars += "<br/>"; strChars += "<br/>";
} }
oAscii.innerHTML = "<tr><td>" + strChars + "</td></tr>"; oAscii.innerHTML = "<tr><td>" + strChars + "</td></tr>";
// console.timeEnd('rendering'); // console.timeEnd('rendering');
// return oAscii; // return oAscii;
} }
// end modified asciifyImage block // end modified asciifyImage block
}; };
...@@ -178,8 +178,8 @@ ...@@ -178,8 +178,8 @@
camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT; camera.aspect = SCREEN_WIDTH / SCREEN_HEIGHT;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
if ( render_canvas ) canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); if ( canvasRenderer ) canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
if ( render_gl && has_gl ) webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); if ( webglRenderer ) webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
} }
......
...@@ -205,8 +205,8 @@ ...@@ -205,8 +205,8 @@
camera.aspect = window.innerWidth / window.innerHeight; camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
if ( render_gl && has_gl ) webglRenderer.setSize( window.innerWidth, window.innerHeight ); if ( webglRenderer ) webglRenderer.setSize( window.innerWidth, window.innerHeight );
if ( render_canvas ) canvasRenderer.setSize( window.innerWidth, window.innerHeight ); if ( canvasRenderer ) canvasRenderer.setSize( window.innerWidth, window.innerHeight );
} }
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
var windowHalfX = window.innerWidth / 2; var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2; var windowHalfY = window.innerHeight / 2;
init(); init();
animate(); animate();
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
}); });
loader.load( 'obj/male02/male02.obj' ); loader.load( 'obj/male02/male02.obj' );
// //
renderer = new THREE.WebGLRenderer(); renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setSize( window.innerWidth, window.innerHeight );
...@@ -112,6 +112,22 @@ ...@@ -112,6 +112,22 @@
document.addEventListener( 'mousemove', onDocumentMouseMove, false ); document.addEventListener( 'mousemove', onDocumentMouseMove, false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function onDocumentMouseMove( event ) { function onDocumentMouseMove( event ) {
......
...@@ -311,6 +311,22 @@ ...@@ -311,6 +311,22 @@
$( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false ); $( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function setButtonActive( id ) { function setButtonActive( id ) {
......
...@@ -278,6 +278,22 @@ ...@@ -278,6 +278,22 @@
$( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false ); $( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function setButtonActive( id ) { function setButtonActive( id ) {
......
...@@ -125,6 +125,22 @@ ...@@ -125,6 +125,22 @@
}, { scale: 0.707192, offsetX: -0.109362, offsetY: -0.006435, offsetZ: -0.268751 } ); }, { scale: 0.707192, offsetX: -0.109362, offsetY: -0.006435, offsetZ: -0.268751 } );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2,
windowHalfY = window.innerHeight / 2,
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
} }
function callbackModel( geometry, s, color, x, y, z ) { function callbackModel( geometry, s, color, x, y, z ) {
......
...@@ -110,6 +110,21 @@ ...@@ -110,6 +110,21 @@
stats.domElement.style.top = '0px'; stats.domElement.style.top = '0px';
container.appendChild( stats.domElement ); container.appendChild( stats.domElement );
//
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize( window.innerWidth, window.innerHeight );
controls.handleResize();
} }
function animate() { function animate() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册