Search the Community
Showing results for tags 'javascript'.
-
I want to know what actually the below line means. Is it a array or we are creating an Object. document.getElementById("status").options[1]=new Option("OPEN","open"); I used it for dynamic drop down list
-
I am attempting to write a nested if statement in JavaScript and it is not working. I am not sure what I am doing wrong and would like some assistance. The if statements are long and will only get longer. I choose to use if statements simply because I do not know how to create a VLOOKUP type function in JS. I have researched a way to accomplish this and found various codes, the problem is I do not understand them thus I cannot edit them to fit my needs. Any help will be greatly appreciated! /* The following vars are used to get the proposed kWh */ var apropkWh1; var apropkWh2; var apropkWh3; var apropkWh4; var apropkWh5; /* The following vars are used to get the proposed kWh */ var propkWh1 = if (document.getElementById("RbR5.1").value = document.getElementById("RN1.1").value) {apropkWh1 = document.getElementById("RN5.1").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.2").value) {apropkWh1 = document.getElementById("RN5.2").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.3").value) {apropkWh1 = document.getElementById("RN5.3").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.4").value) {apropkWh1 = document.getElementById("RN5.4").value * document.getElementById("burnHrs1").value;} else if (document.getElementById("RbR5.1").value = document.getElementById("RN1.5").value) {apropkWh1 = document.getElementById("RN5.5").value * document.getElementById("burnHrs1").value;} var propkWh2 = if (document.getElementById("RbR5.2").value = document.getElementById("RN1.1").value) {apropkWh2 = document.getElementById("RN5.1").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.2").value) {apropkWh2 = document.getElementById("RN5.2").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.3").value) {apropkWh2 = document.getElementById("RN5.3").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.4").value) {apropkWh2 = document.getElementById("RN5.4").value * document.getElementById("burnHrs2").value;} else if (document.getElementById("RbR5.2").value = document.getElementById("RN1.5").value) {apropkWh2 = document.getElementById("RN5.5").value * document.getElementById("burnHrs2").value;} var propkWh3 = if (document.getElementById("RbR5.3").value = document.getElementById("RN1.1").value) {apropkWh3 = document.getElementById("RN5.1").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.2").value) {apropkWh3 = document.getElementById("RN5.2").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.3").value) {apropkWh3 = document.getElementById("RN5.3").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.4").value) {apropkWh3 = document.getElementById("RN5.4").value * document.getElementById("burnHrs3").value;} else if (document.getElementById("RbR5.3").value = document.getElementById("RN1.5").value) {apropkWh3 = document.getElementById("RN5.5").value * document.getElementById("burnHrs3").value;} var propkWh4 = if (document.getElementById("RbR5.4").value = document.getElementById("RN1.1").value) {apropkWh4 = document.getElementById("RN5.1").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.2").value) {apropkWh4 = document.getElementById("RN5.2").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.3").value) {apropkWh4 = document.getElementById("RN5.3").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.4").value) {apropkWh4 = document.getElementById("RN5.4").value * document.getElementById("burnHrs4").value;} else if (document.getElementById("RbR5.4").value = document.getElementById("RN1.5").value) {apropkWh4 = document.getElementById("RN5.5").value * document.getElementById("burnHrs4").value;} var propkWh5 = if (document.getElementById("RbR5.5").value = document.getElementById("RN1.1").value) {apropkWh5 = document.getElementById("RN5.1").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.2").value) {apropkWh5 = document.getElementById("RN5.2").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.3").value) {apropkWh5 = document.getElementById("RN5.3").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.4").value) {apropkWh5 = document.getElementById("RN5.4").value * document.getElementById("burnHrs5").value;} else if (document.getElementById("RbR5.5").value = document.getElementById("RN1.5").value) {apropkWh5 = document.getElementById("RN5.5").value * document.getElementById("burnHrs5").value;}
- 9 replies
-
- javascript
- nested if
- (and 4 more)
-
I'd like to put a countdown to the death of Windows 7 Extended support in my signature, any way to do this, or any chance that this could be possible in the future?
-
Hi there, I've read upon how Google Sheets uses their servers to do the calculations instead of having your own personalized computer do it. My colleague says he recently found a button within Google Sheets to add Javascript functions and hopefully it would decrease the time/latency needed in order to calculate a specific cell, vlookup/hlookup from sheets to sheets and also refresh the sheets more quickly. My question is, would Javascript functions actually decrease the amount of time needed for Google's servers to calculate all the stuff on Sheets? FYI these sheets are for company use so there's a lot of stuff on each sheet and that there are more than 5 sheets. I've also found this one button specifically to change the refresh times into "Google Finance" but if the sheets had a formula that contained "Importrange", it would be different I think. My idea to him however is that we'd need better hardware in order to receive information quicker. Our internet is "decent" imo and I think we're lacking in hardware speeds. That being said though, it doesn't have much affect between personalized computers and Google's Servers I would hope to assume.
-
So, i want to write a program (preferably in csharp or java, maybe python but im more experienced in the former languages) that when run, will automatically go to a link, input the username and password, and then download the file off of a link that you can click on. For the one i have in mind, the link does not have a src when i looked in the dom (its like the one in the pic below that says save this bill(PDF) ) So, how in the world would i be able to do that with csharp or java. It can be very advanced or basic, i don't really care, Thanks in advance
-
Hi so recently i have been trying to learn javascript and python on codeacadamy and so far i have been stuck on this question for a while now and i don't know what im doing wrong. Can someone help me and explain what i did wrong in the script? I have tried using the hint button and it didn't really help me out that much. This is the question i have to answer. Complete the missing bits of code to construct the if / else statement. Make the condition evaluate to true. Finish the else statement by printing out the string "Error Error Error" to the console. here is my script. when i hit run it throws me a SyntaxError: Unexpected token ) if ("Jon".length * 2 / (2+1) === ) { { console.log("The answer makes sense!"); } } else } console.log("Error Error Error");
-
<html> <head> <title>Eksempel_2</title> <meta charset="utf-8" /> <script> function btnUtfor_onclick_tekst() { document.getElementById("pMelding").innerHTML = "DerpDerp"; document.getElementById("btnUtfor").onclick = "btnUtfor_onclick_blank()"; } function btnUtfor_onclick_blank() { document.getElementById("pMelding").innerHTML = "..."; document.getElementById("btnUtfor").onclick = "btnUtfor_onclick_tekst()"; } </script> </head> <body> <input id="btnUtfor" type="button" value="Trykk meg" onclick="btnUtfor_onclick_tekst()" /> <p id="pMelding"></p> </body> </html> can someone please explain why this doesn't work and how to fix it, I'm very (very) new to javascript and coding in general
- 15 replies
-
- javascript
- coding
-
(and 3 more)
Tagged with:
-
Hello everyone, I'm working on a website for uploading and viewing your skin for my minecraft server which uses a custom skin server from Mojangs (Skinport 1.7.10 for anyone that want's to use the mod, allows offline skins and 1.8+ skins to work in 1.7.10). So far I've got everything else set up and am using a script I found for viewing the skin however I can not get it to stay in the div section I made and it is HUGE on the webpage. Here is the code I'm using now <script type="text/javascript"> var scene, camera, renderer; var geometry, material, mesh; var rightLeg2Box, leftLeg2Box; var radius = 32; var alpha = 0; var sidebarWidth = 250; camera = new THREE.PerspectiveCamera(70, (window.innerWidth - sidebarWidth) / window.innerHeight, 1, 10000); camera.position.y = -12; scene = new THREE.Scene(); canvas = document.getElementById('canvas'); canvas.width = 64; canvas.height = 64; var context = canvas.getContext("2d"); var skinTexture = new THREE.Texture(canvas); skinTexture.magFilter = THREE.NearestFilter; skinTexture.minFilter = THREE.NearestMipMapNearestFilter; // Get the texture for the skin material = new THREE.MeshBasicMaterial({map: skinTexture, side: THREE.FrontSide}); material2 = new THREE.MeshBasicMaterial({map: skinTexture, transparent: true, opacity: 1, alphaTest: 0.5, side: THREE.DoubleSide}); var img = new Image(); img.crossOrigin = ''; var hasAnimate = false; img.onload = function() { console.log("Loaded Image"); // Erase what was on the canvas before context.clearRect(0, 0, 64, 64); // Draw the image to the canvas context.drawImage(img, 0, 0); // Convert the image if need be if(img.height == 32) Convert6432To6464(context); FixNonVisible(context); FixOverlay(context); skinTexture.needsUpdate = true; material.needsUpdate = true; material2.needsUpdate = true; if(!hasAnimate) { RenderSkin(); hasAnimate = true; Animate(); } } img.onerror = function() { console.log("Failed loading " + img.src); } img.src = 'http://www.cyberconnects2.com/games/updates/rcraft/skins/upload/AzureZhen.png'; function RenderSkin() { // Head Parts var headTop = [ new THREE.Vector2(0.125, 0.875), new THREE.Vector2(0.25, 0.875), new THREE.Vector2(0.25, 1), new THREE.Vector2(0.125, 1) ]; var headBottom = [ new THREE.Vector2(0.25, 0.875), new THREE.Vector2(0.375, 0.875), new THREE.Vector2(0.375, 1), new THREE.Vector2(0.25, 1) ]; var headLeft = [ new THREE.Vector2(0, 0.75), new THREE.Vector2(0.125, 0.75), new THREE.Vector2(0.125, 0.875), new THREE.Vector2(0, 0.875) ]; var headFront = [ new THREE.Vector2(0.125, 0.75), new THREE.Vector2(0.25, 0.75), new THREE.Vector2(0.25 ,0.875), new THREE.Vector2(0.125 ,0.875) ]; var headRight = [ new THREE.Vector2(0.25, 0.75), new THREE.Vector2(0.375, 0.75), new THREE.Vector2(0.375, 0.875), new THREE.Vector2(0.25, 0.875) ]; var headBack = [ new THREE.Vector2(0.375, 0.75), new THREE.Vector2(0.5, 0.75), new THREE.Vector2(0.5, 0.875), new THREE.Vector2(0.375, 0.875) ]; headBox = new THREE.BoxGeometry(8, 8, 8, 0, 0, 0); headBox.faceVertexUvs[0] = []; headBox.faceVertexUvs[0][0] = [headRight[3], headRight[0], headRight[2]]; headBox.faceVertexUvs[0][1] = [headRight[0], headRight[1], headRight[2]]; headBox.faceVertexUvs[0][2] = [headLeft[3], headLeft[0], headLeft[2]]; headBox.faceVertexUvs[0][3] = [headLeft[0], headLeft[1], headLeft[2]]; headBox.faceVertexUvs[0][4] = [headTop[3], headTop[0], headTop[2]]; headBox.faceVertexUvs[0][5] = [headTop[0], headTop[1], headTop[2]]; headBox.faceVertexUvs[0][6] = [headBottom[0], headBottom[3], headBottom[1]]; headBox.faceVertexUvs[0][7] = [headBottom[3], headBottom[2], headBottom[1]]; headBox.faceVertexUvs[0][8] = [headFront[3], headFront[0], headFront[2]]; headBox.faceVertexUvs[0][9] = [headFront[0], headFront[1], headFront[2]]; headBox.faceVertexUvs[0][10] = [headBack[3], headBack[0], headBack[2]]; headBox.faceVertexUvs[0][11] = [headBack[0], headBack[1], headBack[2]]; headMesh = new THREE.Mesh(headBox, material); headMesh.name = "head"; scene.add(headMesh); // Body Parts var bodyTop = [ new THREE.Vector2(0.3125, 0.6875), new THREE.Vector2(0.4375, 0.6875), new THREE.Vector2(0.4375, 0.75), new THREE.Vector2(0.3125, 0.75) ]; var bodyBottom = [ new THREE.Vector2(0.4375, 0.6875), new THREE.Vector2(0.5625, 0.6875), new THREE.Vector2(0.5625, 0.75), new THREE.Vector2(0.4375, 0.75) ]; var bodyLeft = [ new THREE.Vector2(0.25, 0.5), new THREE.Vector2(0.3125, 0.5), new THREE.Vector2(0.3125, 0.6875), new THREE.Vector2(0.25, 0.6875) ]; var bodyFront = [ new THREE.Vector2(0.3125, 0.5), new THREE.Vector2(0.4375, 0.5), new THREE.Vector2(0.4375, 0.6875), new THREE.Vector2(0.3125, 0.6875) ]; var bodyRight = [ new THREE.Vector2(0.4375, 0.5), new THREE.Vector2(0.5, 0.5), new THREE.Vector2(0.5, 0.6875), new THREE.Vector2(0.4375, 0.6875) ]; var bodyBack = [ new THREE.Vector2(0.5, 0.5), new THREE.Vector2(0.625, 0.5), new THREE.Vector2(0.625, 0.6875), new THREE.Vector2(0.5, 0.6875) ]; bodyBox = new THREE.BoxGeometry(8, 12, 4, 0, 0, 0); bodyBox.faceVertexUvs[0] = []; bodyBox.faceVertexUvs[0][0] = [bodyRight[3], bodyRight[0], bodyRight[2]]; bodyBox.faceVertexUvs[0][1] = [bodyRight[0], bodyRight[1], bodyRight[2]]; bodyBox.faceVertexUvs[0][2] = [bodyLeft[3], bodyLeft[0], bodyLeft[2]]; bodyBox.faceVertexUvs[0][3] = [bodyLeft[0], bodyLeft[1], bodyLeft[2]]; bodyBox.faceVertexUvs[0][4] = [bodyTop[3], bodyTop[0], bodyTop[2]]; bodyBox.faceVertexUvs[0][5] = [bodyTop[0], bodyTop[1], bodyTop[2]]; bodyBox.faceVertexUvs[0][6] = [bodyBottom[0], bodyBottom[3], bodyBottom[1]]; bodyBox.faceVertexUvs[0][7] = [bodyBottom[3], bodyBottom[2], bodyBottom[1]]; bodyBox.faceVertexUvs[0][8] = [bodyFront[3], bodyFront[0], bodyFront[2]]; bodyBox.faceVertexUvs[0][9] = [bodyFront[0], bodyFront[1], bodyFront[2]]; bodyBox.faceVertexUvs[0][10] = [bodyBack[3], bodyBack[0], bodyBack[2]]; bodyBox.faceVertexUvs[0][11] = [bodyBack[0], bodyBack[1], bodyBack[2]]; bodyMesh = new THREE.Mesh(bodyBox, material); bodyMesh.name = "body"; bodyMesh.position.y = -10; scene.add(bodyMesh); // Right Arm Parts var rightArmTop = [ new THREE.Vector2(0.6875, 0.6875), new THREE.Vector2(0.75, 0.6875), new THREE.Vector2(0.75, 0.75), new THREE.Vector2(0.6875, 0.75), ]; var rightArmBottom = [ new THREE.Vector2(0.75, 0.6875), new THREE.Vector2(0.8125, 0.6875), new THREE.Vector2(0.8125, 0.75), new THREE.Vector2(0.75, 0.75) ]; var rightArmLeft = [ new THREE.Vector2(0.625, 0.5), new THREE.Vector2(0.6875, 0.5), new THREE.Vector2(0.6875, 0.6875), new THREE.Vector2(0.625, 0.6875) ]; var rightArmFront = [ new THREE.Vector2(0.6875, 0.5), new THREE.Vector2(0.75, 0.5), new THREE.Vector2(0.75, 0.6875), new THREE.Vector2(0.6875, 0.6875) ]; var rightArmRight = [ new THREE.Vector2(0.75, 0.5), new THREE.Vector2(0.8125, 0.5), new THREE.Vector2(0.8125, 0.6875), new THREE.Vector2(0.75, 0.6875) ]; var rightArmBack = [ new THREE.Vector2(0.8125, 0.5), new THREE.Vector2(0.875, 0.5), new THREE.Vector2(0.875, 0.6875), new THREE.Vector2(0.8125, 0.6875) ]; rightArmBox = new THREE.BoxGeometry(4, 12, 4, 0, 0, 0); rightArmBox.faceVertexUvs[0] = []; rightArmBox.faceVertexUvs[0][0] = [rightArmRight[3], rightArmRight[0], rightArmRight[2]]; rightArmBox.faceVertexUvs[0][1] = [rightArmRight[0], rightArmRight[1], rightArmRight[2]]; rightArmBox.faceVertexUvs[0][2] = [rightArmLeft[3], rightArmLeft[0], rightArmLeft[2]]; rightArmBox.faceVertexUvs[0][3] = [rightArmLeft[0], rightArmLeft[1], rightArmLeft[2]]; rightArmBox.faceVertexUvs[0][4] = [rightArmTop[3], rightArmTop[0], rightArmTop[2]]; rightArmBox.faceVertexUvs[0][5] = [rightArmTop[0], rightArmTop[1], rightArmTop[2]]; rightArmBox.faceVertexUvs[0][6] = [rightArmBottom[0], rightArmBottom[3], rightArmBottom[1]]; rightArmBox.faceVertexUvs[0][7] = [rightArmBottom[3], rightArmBottom[2], rightArmBottom[1]]; rightArmBox.faceVertexUvs[0][8] = [rightArmFront[3], rightArmFront[0], rightArmFront[2]]; rightArmBox.faceVertexUvs[0][9] = [rightArmFront[0], rightArmFront[1], rightArmFront[2]]; rightArmBox.faceVertexUvs[0][10] = [rightArmBack[3], rightArmBack[0], rightArmBack[2]]; rightArmBox.faceVertexUvs[0][11] = [rightArmBack[0], rightArmBack[1], rightArmBack[2]]; rightArmMesh = new THREE.Mesh(rightArmBox, material); rightArmMesh.name = "rightArm"; rightArmMesh.position.y = -10; rightArmMesh.position.x = -6; scene.add(rightArmMesh); // Left Arm Parts var leftArmTop = [ new THREE.Vector2(0.5625, 0.1875), new THREE.Vector2(0.625, 0.1875), new THREE.Vector2(0.625, 0.25), new THREE.Vector2(0.5625, 0.25), ]; var leftArmBottom = [ new THREE.Vector2(0.625, 0.1875), new THREE.Vector2(0.6875, 0.1875), new THREE.Vector2(0.6875, 0.25), new THREE.Vector2(0.625, 0.25) ]; var leftArmLeft = [ new THREE.Vector2(0.5, 0), new THREE.Vector2(0.5625, 0), new THREE.Vector2(0.5625, 0.1875), new THREE.Vector2(0.5, 0.1875) ]; var leftArmFront = [ new THREE.Vector2(0.5625, 0), new THREE.Vector2(0.625, 0), new THREE.Vector2(0.625, 0.1875), new THREE.Vector2(0.5625, 0.1875) ]; var leftArmRight = [ new THREE.Vector2(0.625, 0), new THREE.Vector2(0.6875, 0), new THREE.Vector2(0.6875, 0.1875), new THREE.Vector2(0.625, 0.1875) ]; var leftArmBack = [ new THREE.Vector2(0.6875, 0), new THREE.Vector2(0.75, 0), new THREE.Vector2(0.75, 0.1875), new THREE.Vector2(0.6875, 0.1875) ]; leftArmBox = new THREE.BoxGeometry(4, 12, 4, 0, 0, 0); leftArmBox.faceVertexUvs[0] = []; leftArmBox.faceVertexUvs[0][0] = [leftArmRight[3], leftArmRight[0], leftArmRight[2]]; leftArmBox.faceVertexUvs[0][1] = [leftArmRight[0], leftArmRight[1], leftArmRight[2]]; leftArmBox.faceVertexUvs[0][2] = [leftArmLeft[3], leftArmLeft[0], leftArmLeft[2]]; leftArmBox.faceVertexUvs[0][3] = [leftArmLeft[0], leftArmLeft[1], leftArmLeft[2]]; leftArmBox.faceVertexUvs[0][4] = [leftArmTop[3], leftArmTop[0], leftArmTop[2]]; leftArmBox.faceVertexUvs[0][5] = [leftArmTop[0], leftArmTop[1], leftArmTop[2]]; leftArmBox.faceVertexUvs[0][6] = [leftArmBottom[0], leftArmBottom[3], leftArmBottom[1]]; leftArmBox.faceVertexUvs[0][7] = [leftArmBottom[3], leftArmBottom[2], leftArmBottom[1]]; leftArmBox.faceVertexUvs[0][8] = [leftArmFront[3], leftArmFront[0], leftArmFront[2]]; leftArmBox.faceVertexUvs[0][9] = [leftArmFront[0], leftArmFront[1], leftArmFront[2]]; leftArmBox.faceVertexUvs[0][10] = [leftArmBack[3], leftArmBack[0], leftArmBack[2]]; leftArmBox.faceVertexUvs[0][11] = [leftArmBack[0], leftArmBack[1], leftArmBack[2]]; leftArmMesh = new THREE.Mesh(leftArmBox, material); leftArmMesh.name = "leftArm"; leftArmMesh.position.y = -10; leftArmMesh.position.x = 6; scene.add(leftArmMesh); // Right Leg Parts var rightLegTop = [ new THREE.Vector2(0.0625, 0.6875), new THREE.Vector2(0.125, 0.6875), new THREE.Vector2(0.125, 0.75), new THREE.Vector2(0.0625, 0.75), ]; var rightLegBottom = [ new THREE.Vector2(0.125, 0.6875), new THREE.Vector2(0.1875, 0.6875), new THREE.Vector2(0.1875, 0.75), new THREE.Vector2(0.125, 0.75) ]; var rightLegLeft = [ new THREE.Vector2(0, 0.5), new THREE.Vector2(0.0625, 0.5), new THREE.Vector2(0.0625, 0.6875), new THREE.Vector2(0, 0.6875) ]; var rightLegFront = [ new THREE.Vector2(0.0625, 0.5), new THREE.Vector2(0.125, 0.5), new THREE.Vector2(0.125, 0.6875), new THREE.Vector2(0.0625, 0.6875) ]; var rightLegRight = [ new THREE.Vector2(0.125, 0.5), new THREE.Vector2(0.1875, 0.5), new THREE.Vector2(0.1875, 0.6875), new THREE.Vector2(0.125, 0.6875) ]; var rightLegBack = [ new THREE.Vector2(0.1875, 0.5), new THREE.Vector2(0.25, 0.5), new THREE.Vector2(0.25, 0.6875), new THREE.Vector2(0.1875, 0.6875) ]; rightLegBox = new THREE.BoxGeometry(4, 12, 4, 0, 0, 0); rightLegBox.faceVertexUvs[0] = []; rightLegBox.faceVertexUvs[0][0] = [rightLegRight[3], rightLegRight[0], rightLegRight[2]]; rightLegBox.faceVertexUvs[0][1] = [rightLegRight[0], rightLegRight[1], rightLegRight[2]]; rightLegBox.faceVertexUvs[0][2] = [rightLegLeft[3], rightLegLeft[0], rightLegLeft[2]]; rightLegBox.faceVertexUvs[0][3] = [rightLegLeft[0], rightLegLeft[1], rightLegLeft[2]]; rightLegBox.faceVertexUvs[0][4] = [rightLegTop[3], rightLegTop[0], rightLegTop[2]]; rightLegBox.faceVertexUvs[0][5] = [rightLegTop[0], rightLegTop[1], rightLegTop[2]]; rightLegBox.faceVertexUvs[0][6] = [rightLegBottom[0], rightLegBottom[3], rightLegBottom[1]]; rightLegBox.faceVertexUvs[0][7] = [rightLegBottom[3], rightLegBottom[2], rightLegBottom[1]]; rightLegBox.faceVertexUvs[0][8] = [rightLegFront[3], rightLegFront[0], rightLegFront[2]]; rightLegBox.faceVertexUvs[0][9] = [rightLegFront[0], rightLegFront[1], rightLegFront[2]]; rightLegBox.faceVertexUvs[0][10] = [rightLegBack[3], rightLegBack[0], rightLegBack[2]]; rightLegBox.faceVertexUvs[0][11] = [rightLegBack[0], rightLegBack[1], rightLegBack[2]]; rightLegMesh = new THREE.Mesh(rightLegBox, material); rightLegMesh.name = "rightLeg" rightLegMesh.position.y = -22; rightLegMesh.position.x = -2; scene.add(rightLegMesh); // Left Leg Parts var leftLegTop = [ new THREE.Vector2(0.3125, 0.1875), new THREE.Vector2(0.375, 0.1875), new THREE.Vector2(0.375, 0.25), new THREE.Vector2(0.3125, 0.25), ]; var leftLegBottom = [ new THREE.Vector2(0.375, 0.1875), new THREE.Vector2(0.4375, 0.1875), new THREE.Vector2(0.4375, 0.25), new THREE.Vector2(0.375, 0.25) ]; var leftLegLeft = [ new THREE.Vector2(0.25, 0), new THREE.Vector2(0.3125, 0), new THREE.Vector2(0.3125, 0.1875), new THREE.Vector2(0.25, 0.1875) ]; var leftLegFront = [ new THREE.Vector2(0.3125, 0), new THREE.Vector2(0.375, 0), new THREE.Vector2(0.375, 0.1875), new THREE.Vector2(0.3125, 0.1875) ]; var leftLegRight = [ new THREE.Vector2(0.375, 0), new THREE.Vector2(0.4375, 0), new THREE.Vector2(0.4375, 0.1875), new THREE.Vector2(0.375, 0.1875) ]; var leftLegBack = [ new THREE.Vector2(0.4375, 0), new THREE.Vector2(0.5, 0), new THREE.Vector2(0.5, 0.1875), new THREE.Vector2(0.4375, 0.1875) ]; leftLegBox = new THREE.BoxGeometry(4, 12, 4, 0, 0, 0); leftLegBox.faceVertexUvs[0] = []; leftLegBox.faceVertexUvs[0][0] = [leftLegRight[3], leftLegRight[0], leftLegRight[2]]; leftLegBox.faceVertexUvs[0][1] = [leftLegRight[0], leftLegRight[1], leftLegRight[2]]; leftLegBox.faceVertexUvs[0][2] = [leftLegLeft[3], leftLegLeft[0], leftLegLeft[2]]; leftLegBox.faceVertexUvs[0][3] = [leftLegLeft[0], leftLegLeft[1], leftLegLeft[2]]; leftLegBox.faceVertexUvs[0][4] = [leftLegTop[3], leftLegTop[0], leftLegTop[2]]; leftLegBox.faceVertexUvs[0][5] = [leftLegTop[0], leftLegTop[1], leftLegTop[2]]; leftLegBox.faceVertexUvs[0][6] = [leftLegBottom[0], leftLegBottom[3], leftLegBottom[1]]; leftLegBox.faceVertexUvs[0][7] = [leftLegBottom[3], leftLegBottom[2], leftLegBottom[1]]; leftLegBox.faceVertexUvs[0][8] = [leftLegFront[3], leftLegFront[0], leftLegFront[2]]; leftLegBox.faceVertexUvs[0][9] = [leftLegFront[0], leftLegFront[1], leftLegFront[2]]; leftLegBox.faceVertexUvs[0][10] = [leftLegBack[3], leftLegBack[0], leftLegBack[2]]; leftLegBox.faceVertexUvs[0][11] = [leftLegBack[0], leftLegBack[1], leftLegBack[2]]; leftLegMesh = new THREE.Mesh(leftLegBox, material); leftLegMesh.name = "leftLeg"; leftLegMesh.position.y = -22; leftLegMesh.position.x = 2; scene.add(leftLegMesh); // Head Overlay Parts var head2Top = [ new THREE.Vector2(0.625, 0.875), new THREE.Vector2(0.75, 0.875), new THREE.Vector2(0.75, 1), new THREE.Vector2(0.625, 1) ]; var head2Bottom = [ new THREE.Vector2(0.75, 0.875), new THREE.Vector2(0.875, 0.875), new THREE.Vector2(0.875, 1), new THREE.Vector2(0.75, 1) ]; var head2Left = [ new THREE.Vector2(0.5, 0.75), new THREE.Vector2(0.625, 0.75), new THREE.Vector2(0.625, 0.875), new THREE.Vector2(0.5, 0.875) ]; var head2Front = [ new THREE.Vector2(0.625, 0.75), new THREE.Vector2(0.75, 0.75), new THREE.Vector2(0.75, 0.875), new THREE.Vector2(0.625, 0.875) ]; var head2Right = [ new THREE.Vector2(0.75, 0.75), new THREE.Vector2(0.875, 0.75), new THREE.Vector2(0.875, 0.875), new THREE.Vector2(0.75, 0.875) ]; var head2Back = [ new THREE.Vector2(0.875, 0.75), new THREE.Vector2(1, 0.75), new THREE.Vector2(1, 0.875), new THREE.Vector2(0.875, 0.875) ]; head2Box = new THREE.BoxGeometry(9, 9, 9, 0, 0, 0); head2Box.faceVertexUvs[0] = []; head2Box.faceVertexUvs[0][0] = [head2Right[3], head2Right[0], head2Right[2]]; head2Box.faceVertexUvs[0][1] = [head2Right[0], head2Right[1], head2Right[2]]; head2Box.faceVertexUvs[0][2] = [head2Left[3], head2Left[0], head2Left[2]]; head2Box.faceVertexUvs[0][3] = [head2Left[0], head2Left[1], head2Left[2]]; head2Box.faceVertexUvs[0][4] = [head2Top[3], head2Top[0], head2Top[2]]; head2Box.faceVertexUvs[0][5] = [head2Top[0], head2Top[1], head2Top[2]]; head2Box.faceVertexUvs[0][6] = [head2Bottom[0], head2Bottom[3], head2Bottom[1]]; head2Box.faceVertexUvs[0][7] = [head2Bottom[3], head2Bottom[2], head2Bottom[1]]; head2Box.faceVertexUvs[0][8] = [head2Front[3], head2Front[0], head2Front[2]]; head2Box.faceVertexUvs[0][9] = [head2Front[0], head2Front[1], head2Front[2]]; head2Box.faceVertexUvs[0][10] = [head2Back[3], head2Back[0], head2Back[2]]; head2Box.faceVertexUvs[0][11] = [head2Back[0], head2Back[1], head2Back[2]]; head2Mesh = new THREE.Mesh(head2Box, material2); head2Mesh.name = "head2" scene.add(head2Mesh); // Body Overlay Parts var body2Top = [ new THREE.Vector2(0.3125, 0.4375), new THREE.Vector2(0.4375, 0.4375), new THREE.Vector2(0.4375, 0.5), new THREE.Vector2(0.3125, 0.5) ]; var body2Bottom = [ new THREE.Vector2(0.4375, 0.4375), new THREE.Vector2(0.5625, 0.4375), new THREE.Vector2(0.5625, 0.5), new THREE.Vector2(0.4375, 0.5) ]; var body2Left = [ new THREE.Vector2(0.25, 0.25), new THREE.Vector2(0.3125, 0.25), new THREE.Vector2(0.3125, 0.4375), new THREE.Vector2(0.25, 0.4375) ]; var body2Front = [ new THREE.Vector2(0.3125, 0.25), new THREE.Vector2(0.4375, 0.25), new THREE.Vector2(0.4375, 0.4375), new THREE.Vector2(0.3125, 0.4375) ]; var body2Right = [ new THREE.Vector2(0.4375, 0.25), new THREE.Vector2(0.5, 0.25), new THREE.Vector2(0.5, 0.4375), new THREE.Vector2(0.4375, 0.4375) ]; var body2Back = [ new THREE.Vector2(0.5, 0.25), new THREE.Vector2(0.625, 0.25), new THREE.Vector2(0.625, 0.4375), new THREE.Vector2(0.5, 0.4375) ]; body2Box = new THREE.BoxGeometry(9, 13.5, 4.5, 0, 0, 0); body2Box.faceVertexUvs[0] = []; body2Box.faceVertexUvs[0][0] = [body2Right[3], body2Right[0], body2Right[2]]; body2Box.faceVertexUvs[0][1] = [body2Right[0], body2Right[1], body2Right[2]]; body2Box.faceVertexUvs[0][2] = [body2Left[3], body2Left[0], body2Left[2]]; body2Box.faceVertexUvs[0][3] = [body2Left[0], body2Left[1], body2Left[2]]; body2Box.faceVertexUvs[0][4] = [body2Top[3], body2Top[0], body2Top[2]]; body2Box.faceVertexUvs[0][5] = [body2Top[0], body2Top[1], body2Top[2]]; body2Box.faceVertexUvs[0][6] = [body2Bottom[0], body2Bottom[3], body2Bottom[1]]; body2Box.faceVertexUvs[0][7] = [body2Bottom[3], body2Bottom[2], body2Bottom[1]]; body2Box.faceVertexUvs[0][8] = [body2Front[3], body2Front[0], body2Front[2]]; body2Box.faceVertexUvs[0][9] = [body2Front[0], body2Front[1], body2Front[2]]; body2Box.faceVertexUvs[0][10] = [body2Back[3], body2Back[0], body2Back[2]]; body2Box.faceVertexUvs[0][11] = [body2Back[0], body2Back[1], body2Back[2]]; body2Mesh = new THREE.Mesh(body2Box, material2); body2Mesh.name = "body2"; body2Mesh.position.y = -10; scene.add(body2Mesh); // Right Arm Overlay Parts var rightArm2Top = [ new THREE.Vector2(0.6875, 0.4375), new THREE.Vector2(0.75, 0.4375), new THREE.Vector2(0.75, 0.5), new THREE.Vector2(0.6875, 0.5), ]; var rightArm2Bottom = [ new THREE.Vector2(0.75, 0.4375), new THREE.Vector2(0.8125, 0.4375), new THREE.Vector2(0.8125, 0.5), new THREE.Vector2(0.75, 0.5) ]; var rightArm2Left = [ new THREE.Vector2(0.625, 0.25), new THREE.Vector2(0.6875, 0.25), new THREE.Vector2(0.6875, 0.4375), new THREE.Vector2(0.625, 0.4375) ]; var rightArm2Front = [ new THREE.Vector2(0.6875, 0.25), new THREE.Vector2(0.75, 0.25), new THREE.Vector2(0.75, 0.4375), new THREE.Vector2(0.6875, 0.4375) ]; var rightArm2Right = [ new THREE.Vector2(0.75, 0.25), new THREE.Vector2(0.8125, 0.25), new THREE.Vector2(0.8125, 0.4375), new THREE.Vector2(0.75, 0.4375) ]; var rightArm2Back = [ new THREE.Vector2(0.8125, 0.25), new THREE.Vector2(0.875, 0.25), new THREE.Vector2(0.875, 0.4375), new THREE.Vector2(0.8125, 0.4375) ]; rightArm2Box = new THREE.BoxGeometry(4.5, 13.5, 4.5, 0, 0, 0); rightArm2Box.faceVertexUvs[0] = []; rightArm2Box.faceVertexUvs[0][0] = [rightArm2Right[3], rightArm2Right[0], rightArm2Right[2]]; rightArm2Box.faceVertexUvs[0][1] = [rightArm2Right[0], rightArm2Right[1], rightArm2Right[2]]; rightArm2Box.faceVertexUvs[0][2] = [rightArm2Left[3], rightArm2Left[0], rightArm2Left[2]]; rightArm2Box.faceVertexUvs[0][3] = [rightArm2Left[0], rightArm2Left[1], rightArm2Left[2]]; rightArm2Box.faceVertexUvs[0][4] = [rightArm2Top[3], rightArm2Top[0], rightArm2Top[2]]; rightArm2Box.faceVertexUvs[0][5] = [rightArm2Top[0], rightArm2Top[1], rightArm2Top[2]]; rightArm2Box.faceVertexUvs[0][6] = [rightArm2Bottom[0], rightArm2Bottom[3], rightArm2Bottom[1]]; rightArm2Box.faceVertexUvs[0][7] = [rightArm2Bottom[3], rightArm2Bottom[2], rightArm2Bottom[1]]; rightArm2Box.faceVertexUvs[0][8] = [rightArm2Front[3], rightArm2Front[0], rightArm2Front[2]]; rightArm2Box.faceVertexUvs[0][9] = [rightArm2Front[0], rightArm2Front[1], rightArm2Front[2]]; rightArm2Box.faceVertexUvs[0][10] = [rightArm2Back[3], rightArm2Back[0], rightArm2Back[2]]; rightArm2Box.faceVertexUvs[0][11] = [rightArm2Back[0], rightArm2Back[1], rightArm2Back[2]]; rightArm2Mesh = new THREE.Mesh(rightArm2Box, material2); rightArm2Mesh.name = "rightArm2"; rightArm2Mesh.position.y = -10; rightArm2Mesh.position.x = -6; scene.add(rightArm2Mesh); // Left Arm Overlay Parts var leftArm2Top = [ new THREE.Vector2(0.8125, 0.1875), new THREE.Vector2(0.875, 0.1875), new THREE.Vector2(0.875, 0.25), new THREE.Vector2(0.8125, 0.25), ]; var leftArm2Bottom = [ new THREE.Vector2(0.875, 0.1875), new THREE.Vector2(0.9375, 0.1875), new THREE.Vector2(0.9375, 0.25), new THREE.Vector2(0.875, 0.25) ]; var leftArm2Left = [ new THREE.Vector2(0.75, 0), new THREE.Vector2(0.8125, 0), new THREE.Vector2(0.8125, 0.1875), new THREE.Vector2(0.75, 0.1875) ]; var leftArm2Front = [ new THREE.Vector2(0.8125, 0), new THREE.Vector2(0.875, 0), new THREE.Vector2(0.875, 0.1875), new THREE.Vector2(0.8125, 0.1875) ]; var leftArm2Right = [ new THREE.Vector2(0.875, 0), new THREE.Vector2(0.9375, 0), new THREE.Vector2(0.9375, 0.1875), new THREE.Vector2(0.875, 0.1875) ]; var leftArm2Back = [ new THREE.Vector2(0.9375, 0), new THREE.Vector2(1, 0), new THREE.Vector2(1, 0.1875), new THREE.Vector2(0.9375, 0.1875) ]; leftArm2Box = new THREE.BoxGeometry(4.5, 13.5, 4.5, 0, 0, 0); leftArm2Box.faceVertexUvs[0] = []; leftArm2Box.faceVertexUvs[0][0] = [leftArm2Right[3], leftArm2Right[0], leftArm2Right[2]]; leftArm2Box.faceVertexUvs[0][1] = [leftArm2Right[0], leftArm2Right[1], leftArm2Right[2]]; leftArm2Box.faceVertexUvs[0][2] = [leftArm2Left[3], leftArm2Left[0], leftArm2Left[2]]; leftArm2Box.faceVertexUvs[0][3] = [leftArm2Left[0], leftArm2Left[1], leftArm2Left[2]]; leftArm2Box.faceVertexUvs[0][4] = [leftArm2Top[3], leftArm2Top[0], leftArm2Top[2]]; leftArm2Box.faceVertexUvs[0][5] = [leftArm2Top[0], leftArm2Top[1], leftArm2Top[2]]; leftArm2Box.faceVertexUvs[0][6] = [leftArm2Bottom[0], leftArm2Bottom[3], leftArm2Bottom[1]]; leftArm2Box.faceVertexUvs[0][7] = [leftArm2Bottom[3], leftArm2Bottom[2], leftArm2Bottom[1]]; leftArm2Box.faceVertexUvs[0][8] = [leftArm2Front[3], leftArm2Front[0], leftArm2Front[2]]; leftArm2Box.faceVertexUvs[0][9] = [leftArm2Front[0], leftArm2Front[1], leftArm2Front[2]]; leftArm2Box.faceVertexUvs[0][10] = [leftArm2Back[3], leftArm2Back[0], leftArm2Back[2]]; leftArm2Box.faceVertexUvs[0][11] = [leftArm2Back[0], leftArm2Back[1], leftArm2Back[2]]; leftArm2Mesh = new THREE.Mesh(leftArm2Box, material2); leftArm2Mesh.name = "leftArm2"; leftArm2Mesh.position.y = -10; leftArm2Mesh.position.x = 6; scene.add(leftArm2Mesh); // Right Leg Overlay Parts var rightLeg2Top = [ new THREE.Vector2(0.0625, 0.4375), new THREE.Vector2(0.125, 0.4375), new THREE.Vector2(0.125, 0.5), new THREE.Vector2(0.0625, 0.5), ]; var rightLeg2Bottom = [ new THREE.Vector2(0.125, 0.4375), new THREE.Vector2(0.1875, 0.4375), new THREE.Vector2(0.1875, 0.5), new THREE.Vector2(0.125, 0.5) ]; var rightLeg2Left = [ new THREE.Vector2(0, 0.25), new THREE.Vector2(0.0625, 0.25), new THREE.Vector2(0.0625, 0.4375), new THREE.Vector2(0, 0.4375) ]; var rightLeg2Front = [ new THREE.Vector2(0.0625, 0.25), new THREE.Vector2(0.125, 0.25), new THREE.Vector2(0.125, 0.4375), new THREE.Vector2(0.0625, 0.4375) ]; var rightLeg2Right = [ new THREE.Vector2(0.125, 0.25), new THREE.Vector2(0.1875, 0.25), new THREE.Vector2(0.1875, 0.4375), new THREE.Vector2(0.125, 0.4375) ]; var rightLeg2Back = [ new THREE.Vector2(0.1875, 0.25), new THREE.Vector2(0.25, 0.25), new THREE.Vector2(0.25, 0.4375), new THREE.Vector2(0.1875, 0.4375) ]; rightLeg2Box = new THREE.BoxGeometry(4.5, 13.5, 4.5, 0, 0, 0); rightLeg2Box.faceVertexUvs[0] = []; rightLeg2Box.faceVertexUvs[0][0] = [rightLeg2Right[3], rightLeg2Right[0], rightLeg2Right[2]]; rightLeg2Box.faceVertexUvs[0][1] = [rightLeg2Right[0], rightLeg2Right[1], rightLeg2Right[2]]; rightLeg2Box.faceVertexUvs[0][2] = [rightLeg2Left[3], rightLeg2Left[0], rightLeg2Left[2]]; rightLeg2Box.faceVertexUvs[0][3] = [rightLeg2Left[0], rightLeg2Left[1], rightLeg2Left[2]]; rightLeg2Box.faceVertexUvs[0][4] = [rightLeg2Top[3], rightLeg2Top[0], rightLeg2Top[2]]; rightLeg2Box.faceVertexUvs[0][5] = [rightLeg2Top[0], rightLeg2Top[1], rightLeg2Top[2]]; rightLeg2Box.faceVertexUvs[0][6] = [rightLeg2Bottom[0], rightLeg2Bottom[3], rightLeg2Bottom[1]]; rightLeg2Box.faceVertexUvs[0][7] = [rightLeg2Bottom[3], rightLeg2Bottom[2], rightLeg2Bottom[1]]; rightLeg2Box.faceVertexUvs[0][8] = [rightLeg2Front[3], rightLeg2Front[0], rightLeg2Front[2]]; rightLeg2Box.faceVertexUvs[0][9] = [rightLeg2Front[0], rightLeg2Front[1], rightLeg2Front[2]]; rightLeg2Box.faceVertexUvs[0][10] = [rightLeg2Back[3], rightLeg2Back[0], rightLeg2Back[2]]; rightLeg2Box.faceVertexUvs[0][11] = [rightLeg2Back[0], rightLeg2Back[1], rightLeg2Back[2]]; rightLeg2Mesh = new THREE.Mesh(rightLeg2Box, material2); rightLeg2Mesh.name = "rightLeg2" rightLeg2Mesh.position.y = -22; rightLeg2Mesh.position.x = -2; scene.add(rightLeg2Mesh); // Left Leg Overlay Parts var leftLeg2Top = [ new THREE.Vector2(0.0625, 0.1875), new THREE.Vector2(0.125, 0.1875), new THREE.Vector2(0.125, 0.25), new THREE.Vector2(0.0625, 0.25), ]; var leftLeg2Bottom = [ new THREE.Vector2(0.125, 0.1875), new THREE.Vector2(0.1875, 0.1875), new THREE.Vector2(0.1875, 0.25), new THREE.Vector2(0.125, 0.25) ]; var leftLeg2Left = [ new THREE.Vector2(0, 0), new THREE.Vector2(0.0625, 0), new THREE.Vector2(0.0625, 0.1875), new THREE.Vector2(0, 0.1875) ]; var leftLeg2Front = [ new THREE.Vector2(0.0625, 0), new THREE.Vector2(0.125, 0), new THREE.Vector2(0.125, 0.1875), new THREE.Vector2(0.0625, 0.1875) ]; var leftLeg2Right = [ new THREE.Vector2(0.125, 0), new THREE.Vector2(0.1875, 0), new THREE.Vector2(0.1875, 0.1875), new THREE.Vector2(0.125, 0.1875) ]; var leftLeg2Back = [ new THREE.Vector2(0.1875, 0), new THREE.Vector2(0.25, 0), new THREE.Vector2(0.25, 0.1875), new THREE.Vector2(0.1875, 0.1875) ]; var leftLeg2Box = new THREE.BoxGeometry(4.5, 13.5, 4.5, 0, 0, 0); leftLeg2Box.faceVertexUvs[0] = []; leftLeg2Box.faceVertexUvs[0][0] = [leftLeg2Right[3], leftLeg2Right[0], leftLeg2Right[2]]; leftLeg2Box.faceVertexUvs[0][1] = [leftLeg2Right[0], leftLeg2Right[1], leftLeg2Right[2]]; leftLeg2Box.faceVertexUvs[0][2] = [leftLeg2Left[3], leftLeg2Left[0], leftLeg2Left[2]]; leftLeg2Box.faceVertexUvs[0][3] = [leftLeg2Left[0], leftLeg2Left[1], leftLeg2Left[2]]; leftLeg2Box.faceVertexUvs[0][4] = [leftLeg2Top[3], leftLeg2Top[0], leftLeg2Top[2]]; leftLeg2Box.faceVertexUvs[0][5] = [leftLeg2Top[0], leftLeg2Top[1], leftLeg2Top[2]]; leftLeg2Box.faceVertexUvs[0][6] = [leftLeg2Bottom[0], leftLeg2Bottom[3], leftLeg2Bottom[1]]; leftLeg2Box.faceVertexUvs[0][7] = [leftLeg2Bottom[3], leftLeg2Bottom[2], leftLeg2Bottom[1]]; leftLeg2Box.faceVertexUvs[0][8] = [leftLeg2Front[3], leftLeg2Front[0], leftLeg2Front[2]]; leftLeg2Box.faceVertexUvs[0][9] = [leftLeg2Front[0], leftLeg2Front[1], leftLeg2Front[2]]; leftLeg2Box.faceVertexUvs[0][10] = [leftLeg2Back[3], leftLeg2Back[0], leftLeg2Back[2]]; leftLeg2Box.faceVertexUvs[0][11] = [leftLeg2Back[0], leftLeg2Back[1], leftLeg2Back[2]]; leftLeg2Mesh = new THREE.Mesh(leftLeg2Box, material2); leftLeg2Mesh.name = "leftLeg2"; leftLeg2Mesh.position.y = -22; leftLeg2Mesh.position.x = 2; scene.add(leftLeg2Mesh); // Add to page container = document.getElementById('model'); renderer = new THREE.WebGLRenderer({alpha: true}); renderer.setSize(window.innerWidth, window.innerHeight); window.addEventListener('resize', onWindowResize, false); model.appendChild(renderer.domElement); } function onWindowResize() { camera.aspect = (window.innerWidth - sidebarWidth) / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth - sidebarWidth, window.innerHeight); } function Animate() { requestAnimationFrame(Animate); camera.rotation.y = alpha; //alpha = /*(Math.PI / 2)*/ + (Math.PI / 16); alpha += Math.PI / 320; camera.position.z = radius*Math.cos(alpha); camera.position.x = radius*Math.sin(alpha); //Leg Swing leftLeg2Mesh.rotation.x = leftLegMesh.rotation.x = Math.cos(alpha*4); leftLeg2Mesh.position.z = leftLegMesh.position.z = 0 - 6*Math.sin(leftLegMesh.rotation.x); leftLeg2Mesh.position.y = leftLegMesh.position.y = -16 - 6*Math.abs(Math.cos(leftLegMesh.rotation.x)); rightLeg2Mesh.rotation.x = rightLegMesh.rotation.x = Math.cos(alpha*4 + (Math.PI)); rightLeg2Mesh.position.z = rightLegMesh.position.z = 0 - 6*Math.sin(rightLegMesh.rotation.x); rightLeg2Mesh.position.y = rightLegMesh.position.y = -16 - 6*Math.abs(Math.cos(rightLegMesh.rotation.x)); //Arm Swing leftArm2Mesh.rotation.x = leftArmMesh.rotation.x = Math.cos(alpha*4 + (Math.PI)); leftArm2Mesh.position.z = leftArmMesh.position.z = 0 - 6*Math.sin(leftArmMesh.rotation.x); leftArm2Mesh.position.y = leftArmMesh.position.y = -4 - 6*Math.abs(Math.cos(leftArmMesh.rotation.x)); rightArm2Mesh.rotation.x = rightArmMesh.rotation.x = Math.cos(alpha*4); rightArm2Mesh.position.z = rightArmMesh.position.z = 0 - 6*Math.sin(rightArmMesh.rotation.x); rightArm2Mesh.position.y = rightArmMesh.position.y = -4 - 6*Math.abs(Math.cos(rightArmMesh.rotation.x)); renderer.render(scene, camera); } // Handle the sidebar input things // Make checkboxes toggle visibility headToggle = document.getElementById('headToggle'); headToggle.addEventListener("change", toggleHead, false); function toggleHead() { console.log("toggling head"); var head = scene.getObjectByName("head", false); head.visible = headToggle.checked; console.log(head); } leftArmToggle = document.getElementById('leftArmToggle'); leftArmToggle.addEventListener("change", toggleLeftArm, false); function toggleLeftArm() { var leftArm = scene.getObjectByName("leftArm", false); leftArm.visible = leftArmToggle.checked; } rightArmToggle = document.getElementById('rightArmToggle'); rightArmToggle.addEventListener("change", toggleRightArm, false); function toggleRightArm() { var rightArm = scene.getObjectByName("rightArm", false); rightArm.visible = rightArmToggle.checked; } bodyToggle = document.getElementById('bodyToggle'); bodyToggle.addEventListener("change", toggleBody, false); function toggleBody() { var body = scene.getObjectByName("body", false); body.visible = bodyToggle.checked; } leftLegToggle = document.getElementById('leftLegToggle'); leftLegToggle.addEventListener("change", toggleLeftLeg, false); function toggleLeftLeg() { var leftLeg = scene.getObjectByName("leftLeg", false); leftLeg.visible = leftLegToggle.checked; } rightLegToggle = document.getElementById('rightLegToggle'); rightLegToggle.addEventListener("change", toggleRightLeg, false); function toggleRightLeg() { var rightLeg = scene.getObjectByName("rightLeg", false); rightLeg.visible = rightLegToggle.checked; } head2Toggle = document.getElementById('head2Toggle'); head2Toggle.addEventListener("change", toggleHead2, false); function toggleHead2() { var head2 = scene.getObjectByName("head2", false); head2.visible = head2Toggle.checked; } leftArm2Toggle = document.getElementById('leftArm2Toggle'); leftArm2Toggle.addEventListener("change", toggleLeftArm2, false); function toggleLeftArm2() { var leftArm2 = scene.getObjectByName("leftArm2", false); leftArm2.visible = leftArm2Toggle.checked; } rightArm2Toggle = document.getElementById('rightArm2Toggle'); rightArm2Toggle.addEventListener("change", toggleRightArm2, false); function toggleRightArm2() { var rightArm2 = scene.getObjectByName("rightArm2", false); rightArm2.visible = rightArm2Toggle.checked; } body2Toggle = document.getElementById('body2Toggle'); body2Toggle.addEventListener("change", toggleBody2, false); function toggleBody2() { var body2 = scene.getObjectByName("body2", false); body2.visible = body2Toggle.checked; } leftLeg2Toggle = document.getElementById('leftLeg2Toggle'); leftLeg2Toggle.addEventListener("change", toggleLeftLeg2, false); function toggleLeftLeg2() { var leftLeg2 = scene.getObjectByName("leftLeg2", false); leftLeg2.visible = leftLeg2Toggle.checked; } rightLeg2Toggle = document.getElementById('rightLeg2Toggle'); rightLeg2Toggle.addEventListener("change", toggleRightLeg2, false); function toggleRightLeg2() { var rightLeg2 = scene.getObjectByName("rightLeg2", false); rightLeg2.visible = rightLeg2Toggle.checked; } // Change the username document.getElementById('username').onkeypress = function(e){ if (!e) e = window.event; var keyCode = e.keyCode || e.which; if (keyCode == '13'){ // Enter pressed, set new image img.src = 'http://www.cyberconnects2.com/games/updates/rcraft/skins/upload/' + document.getElementById('username').value; } } </script> I believe it's something to do with this bit of code but any time I try missing with, it's just messes up completely. renderer = new THREE.WebGLRenderer({alpha: true}); renderer.setSize(window.innerWidth, window.innerHeight); I can post up the html I have if it's needed. It's been bugging me a ton and if anyone could help, you'd be my savior haha
-
Hello All, does anyone have any idea why this doesn't work? I'm new to javascript and having a bit of trouble. <select id="myInput" name="Symptoms"> <option value="fears">Unshakable Feelings of Dread, Apprehension and Irrational Fears</option> <option value="fastHeart">Heart Palpitations</option> <option value="abnormalBreathing">Difficulty Breathing or Hyperventilating</option> <option value="dizziness">Dizziness or Feeling Faint</option> <option value="chestPain">Chest Pains, Tightness and other Symptoms like a Heart Attack</option> <option value="concentrate">Inability to Concentrate</option> <option value="insominia">Insominia</option> <option value="chills">Chills & Hot Flashes</option> <option value="dryMouth">Dry Mouth</option> <option value="doom">Sense of Impending Doom</option> <option value="stomach">Stomach Cramps, Diarrhea, Nausea and other Intestinal Problems</option> <option value="clamminess">Claminess</option> <option value="muscle">Muscle Tension, Aches & Pains</option> <option value="exhaustion">Exhaustion</option> <option value="pins">Pins & Needles</option> <option value="irritability">Irritability</option> <option value="sweating">Excessive Sweating</option> <option value="depersonalisation">Feelings of Depsonalisation or Unreality</option> <option value="headaches">Headaches</option> <option value="memory">Memory Problems</option> <option value="other">Other</option> </select> <button onclick="checkFruit()">Check Symptoms</button> <p id="demo"></p> <script> function checkFruit() { var text; var symptoms = document.getElementById("myInput").value; switch(symptoms) { case "fears"; text = "Unshakable Feelings of Dread, Apprehension and Irrational Fears are some of the most common anxiety symptoms and will often be followed by an acute period of anxiety when the preceived fears come to pass. These can be countered by relaxing."; break; case "fastHeart": text = "Heart Palpitations are a very common anxiety symptom and occur when your body goes in to fight or flight mode. This often occurs during a panic attack and at the same time as hyperventiliation. We recommend that you try breathing crisis message for this."; break; case "abnormalBreathing": text = "These are very common symptoms and our related to the fight or flight mechanism of the human body which is there to help you get ouot of danger. We recommend that you try breathing crisis message for this."; break; case "dizziness": text = "Dizziness and Feeling Faint are often caused by improper levels of oxygen and carbon dioxide in your body. This is a common symptom and we recommend that you try breathing crisis message for this."; break; case "chestPain": text = "Chest pain and chest tightness are caused when the muscles around the chet contract and stay in that position. The body often contracts a muscle when a person is tense. We suggest using the muscle relaxation for these symptoms."; break; case "concentrate": text = "The Inability to Concentrate symptom of anxiety is due to having so much of your available thinking resources being taken up by the anxiety that you are unable to devote the time in your head needed to another task. This is quite a common symptom and the best way to to distract yourself from those thoughts for a time. You can use both the crisis message and the relaxation technique for this."; break; case "insominia": text = "Insominia is often related to the inability to concentrate in the fact it is generally being so full of anxiety that you cannot switch off from the anxiety and it's thoughts. The best thing you can do for insominia on your own is to use the muscle relaxation before you go to bed. You can do this as many times as necessary to fall asleep."; break; case "chills": text = "Chills and hot flashes are similar in the face they are funcationally to do with vasodialation of the lood vessels. This is a normal thing the body does when it gets hot or is expecting to get hot due to exercise. So this would occur during the fight or flight mechanism, there because anxiety can trigger that you will experience these symptoms. You can try the muscle relaxation for this symptom but you can also just wait this out."; break; case "dryMouth": text = "Dry Mouth is a common symptom of anxiety and is caused by the body reducing water loss to feed the necessary parts fo the body during a fight or flight situation. To help with this you can drink more water and use the muscle relaxation technique."; break; case "doom": text = "A sense of impending doom is common to anxiety. The sense that soemthing is going to happen. Often this means mroe anxiety is going to happen. Th best thing you can do is to try the muscle relaxation technique."; break; case "stomach": text = "Gastro-intestinal problems are common with anxiety. Stress and anxiety can often cause the stomach to churn more than normal causing all types of problems. The best thing to do is take remedies for the individual problems as necessarya nd try to relax."; break; case "clamminess": text = "While stress and anxiety can often brin you down in such a way that it can cause cold like symptoms clamminess can also be caused by the same vasodialation functions as the chills. Try to relax when this happens and if you are coming down with a cold or other illness make sure you take the time to look after youself."; break; case "muscle": text = "Muscle tension, aches and pains are all caused by the tensing of the individual muscles. This when it goes on for too long causes pain and then aches when it releases. The best way to combat it is to use the mucle relaxation technique to relax those muscles."; break; case "exhaustion": text = "Anxiety can be exhausting, make sure you get enough sleep and rest. You will need more than a well person."; break; case "pins": text = "Pins \& needles can be casued by muscle tension. Relaxation is the best way to help this common symptom."; break; case "irritability;": text = "Being scared can make people irritable. Anxiety is also being scared on a longer term basis and can also make you irritable. The opposite of anxious is being relaxed so a relaxation technique can help you here."; break; case "sweating;": text = "When running or exercising you sweat. When your anxious your body reacts with the same sort of processes, so you increase your body temperature, increase energy production and release adrenaline. This causes an increase in heat so you sweat."; break; case "depersonalisation": text = "depersonalisation is best described as feeling like you aren't there or not connected to your body. This sensation will pass in it's own time, but the more you worry about it and focus on ti the more it will continue so any form of distraction will help you here."; break; case "headaches": text = "Anxiety or stress headaches are common with anxiety and come on when you need to relax. A Muscle relaxation will help you reduce your headaches, along with taking necessary pain killers."; break; case "memory": text = "Memory problems come on when you lack the ability to concentrate. If you forget where your keys are you weren't concentrating when you put them down. So this happens because you are full of anxiety and anxious thoughts. You can help those using a relaxation technique and distraction."; break; default: text = "There are many other anxiety symptoms not included in this checker so please send suggestions to head office for more inclusions."; } document.getElementById("demo").innerHTML = text; } </script>
-
Firstly apologies for my limited knowledge of javascript, I've only been using it for a couple of days so this may be an extremely straight forward issue which I'm missing. Nonetheless, I'm trying to make a YouTube video selector which will play the 6 most recent videos uploaded to a playlist when the appropriate thumbnail is clicked. Both parts of the javascript for this work seperatley: I have a working video selector (http://infiniti-games.co.uk/workingSelector.htm), and a working script which grabs the recent thumbnails and video IDs, and then places them into the body of the page (http://infiniti-games.co.uk/getData.htm). However when I make the script push the URLs into the body of the page (like in the second linked above), the selector no longer works, despite the fact that when inspecting the code, it is identical to the code of that in the working selector. Javascript for video selector: $(document).ready(function(){ $(".thumbnail").click(function() { $("#playvideo").html(play( $(this).find("a").attr("linkattr"))); return false; }); }); function play(id) { var html = ''; html += '<iframe width="671" height="495" src="'+id+'" frameborder="0" allowfullscreen></iframe>'; return html; }; Javascript for grabbing recent uploads and thumbnails: $.getJSON("https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=6&playlistId=PLBGzLPMsBXKZT8NVoYjAbPgB04ReJBdn5&key=AIzaSyC0vSzN0Cmm4cXPXfKD427jFc8MNkl52V4", function(data) { var items = []; data.items.forEach((item) => { var vidId = item.snippet.resourceId.videoId; var thumb = item.snippet.thumbnails.medium.url; console.log(vidId, thumb); items.push(vidId, thumb); $('#thumbContainer').append(` <div class="thumbnail"> <a linkattr="https://www.youtube.com/embed/${vidId}?list=PLBGzLPMsBXKZT8NVoYjAbPgB04ReJBdn5&autoplay=1" href="#"><img src="${thumb}"></a> </div> `) }) }); The rest of the code can obviously be found on the pages I listed above. Any help is much appreciated, thanks!!!
- 2 replies
-
- javascript
- youtube
-
(and 2 more)
Tagged with:
-
I'm trying to design a product page for a website but I don't know how to go about generating the product list as there are over a hundred thousand items from hundreds of different manufacturers. Right now, the only way I can think to make a product page is to divide everything into categories and then link the user to the manufacturer's page, but I would really like to have something a bit more elegant....something like how bestbuy/amazon does it where all the individual products themselves are actually listed. Is there some way to go about doing this? How does Amazon/best buy do it -- do they get some sort of API from the various manufacturers to access the manufacturer's databases? Or do they generate the website based on their (amazon/bestbuy/etc...) databases (and in that case how do they generate their databases)? Obviously this is a fairly difficult thing to do, and realistically I don't think it's a viable option, but I don't really know how else to list the products because I also really don't like the idea of just dividing the products into categories (cpu, gpu, mobo, etc...) and then linking to the manufacturers who produce each item.
- 16 replies
-
- html
- javascript
-
(and 2 more)
Tagged with:
-
I'm trying to have some sort of drop down menu in a website, and have drop down allow users to select a given option that changed the content of a box under that drop down (i.e. load a different piece of HTML based on what they select). I'm trying to achieve this using plain JavaScript without libraries, I'm using HTML5 and CSS3 along with it.
-
Hey guys so I'm working on animating my java script for a project, and being a newbie at java-script I have only figured out how to make my image move up and down in a set area. How can make my object "dank" also spin 360 infinitly whiles using the following code to move it up and down? Any help is appreciated! window.addEventListener("load", function() { function myMove() { var elem = document.getElementById("dank"); var pos = 100; var id = setInterval(frame, 10); function frame() { pos += 0.3; elem.style.top = pos + "px"; if (Math.abs(pos) >= 250){ pos = 100; } frame(); } }
- 1 reply
-
- javascript
- netbeans
-
(and 3 more)
Tagged with:
-
Hey guys, I was wondering if anyone knows of a good place to learn how to use websockets. Or can explain the basics of how to use them. I'm writing a client under an API that requires use of a Hybi Websocket Frame as a test to see the plausibility of converting some python code I have over to javascript.
-
Hello World! Me and my classmate are working with our bachelor thesis and are wondering if you have five minutes to answer our survey. The survey is about Javascript’s newest release Ecmascript 2015. The survey is a comparison between Ecmascript 5 and Ecmascript 2015 and no previous knowledge is required. https://olund.typeform.com/to/NjwSBu Thanks in advance
-
- javascript
- es6
-
(and 3 more)
Tagged with:
-
hey guys, im working on a website, and i need to create a web login, because some of the data people will be asking for is somewhat sensitive. are there any templates or anything like that on the market? Or will i have to build it from scratch? Oh, and it doesent need baller security, just decent security. its not super sensitive data.
-
Here's my code in PHP : if(isset($_POST['submit'])){ $uname = mysql_prep($_POST['uname']); $pass = mysql_prep($_POST['pass']); $name = mysql_prep($_POST['name']); $sql = "INSERT INTO tbl_users(username,password,name) VALUES('$uname','$pass','$name')"; if(mysql_query($sql)){ //codes here to display popup message for successfully added account. }else{ $result = "Something went wrong. Please contact your IT administrator if this issue persists."; } } $result variable is displayed after submitting the form. So if the query was not successful, it will display the error message on the form. Is it possible to do a javascript alert when the php code is successful? Can anyone help me. Thanks.
-
i want to bind the enter key to a function in java script instead of pressing the button,is there a way to do this in JavaScript ?
-
Hey guys, I am trying to program a gui interface under javascript, and in order to do this without the UI freezing whenever a large task is being processed, I need to use Cooperative multi-tasking techniques Does anyone have any experience or know where to guide me on how to do this effectively? If it helps I can share what I have so far
- 2 replies
-
- coding
- programing
-
(and 2 more)
Tagged with:
-
Javascript is not going way it is current and with everything going web it is more useful
-
I found an interesting challenge online where you are supposed to return the number of 0s at the end of a factorial calculation like 30!. Now according to my calculations 30! should be around 2.652528598121911e+32. Javascript can't display the number how I would like it with all 0s at the end but only in exponential notation. My understanding of exponential notation was that I take all numbers before "e" so in this case "2652528598121911" => 16 numbers and subtract that from my e+N like so: 32 - 16. This returns 16 which is wrong, the correct answer is 7. I've never been too amazing in Math so this is probably the wrong approach? How can I get the number of 0s at the end of a factorial number in Javascript? //returns the factorial of a given numberconst getFact = (n, acc = 1) => (n > 1) ? getFact(n - 1, n * acc) : acc;const zeros = n => { //get factorial of n let fact = getFact(n); //match numbers that are not exponential like 12300000, then extract the number of 0s at the end if(fact.toString().match(/e/) === null) return fact.toString().match(/0*$/)[0].split('').length; //match exp. numbers let matched = fact.toExponential().match(/\.(\d*).+(\+\d*)/); //calculate e+(X) - number of numbers before e => 1.22e+5 = 5 - 3 return Number(matched[2]) - (matched[1].length + 1); }
- 3 replies
-
- javascript
- programming
-
(and 3 more)
Tagged with:
-
So I am currently working on a project right now that needs support with Internet Explorer 11. In the register page, after you register, the page should reload, then set the registered data in their appropriate text fields. PROBLEM: After you registered, when the data are loaded on the page, this window always appears. There are console errors whatsoever. This only happens in IE11 and not in any other browser. Can anybody identify what is causing this dialog to appear?
-
Hello Guy, I have recently learned HTML, CSS, and starting on JavaScript. What dose it take to make it as a web developer and what should I learn to get a job. I expect it to take a year or so to get good at web development, I am starting college in spring for networking, I have been looking for a job involving computer for over 3 years and have been playing with languages like java and C for a few years never really mastering them, but in the last year I have found myself having fun making websites and designing them. What should I learn over the next few months that I am going to have to know to get a good job doing web development, what is normal pay for a web developer and is it enough to live off, have a nice life, I know I can google wages, but I would like to know about starting off, from someone who has done it. also are things like bootstrap, if I did get a job doing web development for a company do they normal frown on using that and, after you learn bootstrap are other libraries easy to learn? Thanks, PerkelatorZ
- 4 replies
-
- web development
- html
-
(and 3 more)
Tagged with:
-
I was looking up how to take a file with HTML markup and include it in a full HTML document. I got nowhere, so this is my guide on how to do it after a day of experimenting This is the file with our HTML markup (file.html): <h1>HELLO FROM THE OTHER FILE</h1> And this is our full html document: <html><head><title>Experiment</title></head><body><h1>Hello from this document</h1></body></html> This method will be using javascript so if your trying to avoid JS, this isn't the method for you. First, we need to add a div element. We're going to put it right below the header. <div id="container"></div> Now we need to create our script element: <script> </script> In the script, create a XMLHttpRequest var xhr = new XMLHttpRequest(); Open the XMLHttpRequest xhr.open("GET", "file.html", false); (You can set "false" to "true" if you want the request to run in async mode. I left it at false to keep this tutorial simple. Send the Request xhr.send(); Now, set the innerHTML attribute of the container div to the responseText attribute of the XMLHttpRequest document.getElementById("container").innerHTML = xhr.responseText; And that's it for the code, you should see this: Hello from this document HELLO FROM THE OTHER DOCUMENT And that's it. I know we probably could have used PHP, but I was trying to refrain from that in the project I'm doing. Thank you. EDIT: Also, if you want to manipulate elements in the file, you want to do it somewhere after you've set the innerHTML of the container.