Last active
October 13, 2015 21:52
-
-
Save toto-castaldi/64e5dd9abed0a2140563 to your computer and use it in GitHub Desktop.
three.js mesh sphere scaling with a Math.sin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body></body> | |
<script src="http://gamingJS.com/Three.js"></script> | |
<script src="http://gamingJS.com/ChromeFixes.js"></script> | |
<script src="http://gamingJS.com/Tween.js"></script> | |
<script> | |
var scene = new THREE.Scene(); | |
var width = window.innerWidth - 20; | |
var height = window.innerHeight - 20; | |
var aspect_ratio = width / height; | |
var camera = new THREE.PerspectiveCamera(75, aspect_ratio, 1, 10000); | |
camera.position.z = 500; | |
scene.add(camera); | |
var renderer = new THREE.WebGLRenderer(); | |
renderer.shadowMapEnabled = true; | |
renderer.setSize(width, height); | |
document.body.appendChild(renderer.domElement); | |
//############################################## | |
var cover = new THREE.MeshNormalMaterial(); | |
var sphereShape = new THREE.SphereGeometry(100, 20, 15); | |
var sphereMesh = new THREE.Mesh(sphereShape, cover); | |
scene.add(sphereMesh); | |
var clock = new THREE.Clock(); | |
function animate() { | |
requestAnimationFrame(animate); | |
var t = clock.getElapsedTime(); | |
sphereMesh.scale.x = Math.sin(clock.getElapsedTime()*5) * 2;; | |
renderer.render(scene, camera); | |
} | |
animate(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment