#codevember - [wasd]
How do I make an #codevember - [wasd]?
Created by XORXOR for 2016 codevember. www.xorxor.hu. What is a #codevember - [wasd]? How do you make a #codevember - [wasd]? This script and codes were developed by XORXOR on 27 January 2023, Friday.
#codevember - [wasd] - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>#codevember - [wasd]</title>
</head>
<body> <html> <head> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <title>WASD</title> <style> body { margin: 0px; overflow: hidden; background-color: #FFB347; font-family: 'Arial'; } #help{ position: absolute; top: 1%; left: 1%; font-size: 30px; color: black; } </style> </head> <body> <div id="help">[WASD]</div> </body>
</html> <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/896175/three.min.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/896175/OrbitControls.js'></script> <script src="js/index.js"></script>
</body>
</html>
#codevember - [wasd] - Script Codes JS Codes
//Created by XORXOR, 2016
var contianer, renderer, camera, scene;
var char;
var chars = [];
var objects = [];
var cube;
var size, step;
var light;
var press=0;
var pivot;
var axis;
var target=0;
var i =0;
var k;
var width = window.innerWidth;
var height = window.innerHeight;
function init() { container = document.createElement('div'); document.body.appendChild(container); camera = new THREE.OrthographicCamera( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 700, 1000 ); camera.position.set(-115.3169216327164, 158.1889475862307, 242.72182073407618); scene = new THREE.Scene();
// Grid if (width > height) { size = window.innerHeight/2, step =window.innerHeight/2/6; } else { size = window.innerWidth/2, step =window.innerWidth/2/6; } var geometry = new THREE.Geometry(); for ( var i = - size; i <= size; i += step ) { geometry.vertices.push( new THREE.Vector3( - size, 0, i ) ); geometry.vertices.push( new THREE.Vector3( size, 0, i ) ); geometry.vertices.push( new THREE.Vector3( i, 0, - size ) ); geometry.vertices.push( new THREE.Vector3( i, 0, size ) ); } var material = new THREE.LineBasicMaterial( { color: 0xdfdfdf} ); var line = new THREE.LineSegments( geometry, material ); line.position.y=2.5; scene.add(line);
//plane var geometry = new THREE.BoxGeometry( size*2, 5, size*2 ); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, opacity: 1} ); // material.transparent = true; plane = new THREE.Mesh( geometry, material ); plane.receiveShadow = true; scene.add(plane);
//cube var geometry = new THREE.BoxGeometry(step, step, step); var material = new THREE.MeshLambertMaterial({color: 0xdddddd}); var mat = new THREE.MeshLambertMaterial({color: 0xff0000}); var mat2 = new THREE.MeshLambertMaterial({color: 0x00ff00}); pivot = new THREE.Object3D(); cube = new THREE.Mesh(geometry, material); pivot.add(cube); scene.add(pivot); cube.position.x = step/2; cube.position.y = step/2; cube.position.z = step/2; cube.castShadow = true;
// LIGHTS var ambient = new THREE.AmbientLight( 0x444444 ); scene.add( ambient ); light = new THREE.SpotLight( 0xffffff, 1, 0, Math.PI / 2 ); light.position.set( 600, 1500, 1000 ); light.target.position.set( 0, 0, 0 ); light.castShadow = true; light.shadow = new THREE.LightShadow(new THREE.PerspectiveCamera( 50, 1, 1200, 2500 )); light.shadow.bias = 0.0001; light.shadow.mapSize.width = 1024; light.shadow.mapSize.height = 1024; scene.add( light ); renderer = new THREE.WebGLRenderer({ antialias: true }); renderer.setSize(window.innerWidth, window.innerHeight); renderer.shadowMap.enabled = true; renderer.shadowMap.type = THREE.PCFShadowMap; renderer.setClearColor(0xFFB347); camera.lookAt(cube.position); controls = new THREE.OrbitControls(camera, renderer.domElement); controls.enabled = false; container.appendChild(renderer.domElement); window.addEventListener('keydown', keyPressed, false); window.addEventListener('resize', onWindowResize, false);
}
function keyPressed(e){ var key = event.keyCode ; switch (key) { case 87: /*w*/ target = -90; k='w'; axis = 'x'; break; case 65: /*a*/ target = 90; axis = 'z'; k='a'; break; case 83: /*s*/ k = 's'; axis='x' target = 90; pivot.rotation.y = Math.radians(180) pivot.position.z += step; pivot.position.x += step; break; case 68: /*d*/ k = 'd'; target = 90; axis = 'z'; pivot.rotation.y = Math.radians(180) pivot.position.x += step; pivot.position.z += step; break; }
}
function animate() { var time = performance.now() * 0.0001; if (target != 0) { window.removeEventListener('keydown', keyPressed, false); i += 5; var top = 0 ; var bottom = target; var distance = bottom - top; var rot = top + ((i / target) * distance); if (target>0) { pivot.rotation[axis] = Math.radians(rot); } else { pivot.rotation[axis] = Math.radians(-rot); } if (rot == (Math.abs(target))) { i = 0; pivot.rotation.set(0,0,0); //reset if (axis == "x") { if (k =='s') { pivot.position.x -= step; } if (k == "w") { pivot.position.z -= step; } } if (axis == "z") { if (k == 'a') { pivot.position.x -= step; } if (k == "d") { pivot.position.z -= step; } } if (pivot.position.x>size-step) { pivot.position.x *= -1; } if (pivot.position.x<-size) { pivot.position.x *= -1; pivot.position.x -= step*2; } if (pivot.position.z<-size) { pivot.position.z *= -1; pivot.position.z -= step*2; } if (pivot.position.z>size-step) { pivot.position.z *= -1; } target=0; window.addEventListener('keydown', keyPressed, false); } } requestAnimationFrame(animate); renderer.render(scene, camera);
}
Math.radians = function(degrees) { return degrees * Math.PI / 180;
};
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 );
}
init();
animate();
Developer | XORXOR |
Username | xorxor_hu |
Uploaded | January 27, 2023 |
Rating | 4 |
Size | 3,440 Kb |
Views | 4,048 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Morphing Tubes | 3,406 Kb |
Complex Form with Black and White Spirals | 3,340 Kb |
The Walking Raymarcher | 7,934 Kb |
2050 | 3,612 Kb |
Cubic Tunnel | 4,791 Kb |
Pipes | 3,300 Kb |
Kaleidoscope | 3,536 Kb |
Birds | 5,934 Kb |
Grid of Birds | 3,512 Kb |
Pastel Pump | 3,763 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Twitch TV | Natester13 | 4,488 Kb |
Website Concept | Sagoza | 3,104 Kb |
Octopus Bar iPad App Interactions | Davidkpiano | 6,735 Kb |
Minimal Material Design Form Input | Koenigsegg1 | 3,076 Kb |
Box Shadow Effects | Retrofuturistic | 2,143 Kb |
Material design buttons | Fischaela | 4,381 Kb |
Off Canvas | Mariamarica | 1,870 Kb |
A Pen by Final Boss tommyb9 | FBtommyb9 | 55,354 Kb |
Find The Penguin | Lelder | 2,212 Kb |
CSS Chat Bubbles | Boylett | 2,094 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!