1
0
Fork 0
mirror of https://github.com/haselkern/Minecraft-ArmorStand.git synced 2025-05-18 05:55:35 +00:00

Editor Working + Command Partially Generating

This commit is contained in:
haselkern 2014-08-18 18:32:50 +02:00
parent 2e32466b71
commit d7ea813432
3 changed files with 81 additions and 25 deletions

View file

@ -17,11 +17,6 @@
<h1>MINECRAFT ARMOR STAND<br>Please note:</h1> <h1>MINECRAFT ARMOR STAND<br>Please note:</h1>
This thing is nowhere near complete, I just wanted to upload it so I don't lose my work if my local copy messes up. This thing is nowhere near complete, I just wanted to upload it so I don't lose my work if my local copy messes up.
<br>
Notes to myself:
<ul>
<li>Y and Z rotation axis are okay, but the value has to be multiplied by -1</li>
</ul>
<div id="inputsection"> <div id="inputsection">
@ -50,6 +45,8 @@
</div> </div>
<div id="code"></div>
</div> </div>
</body> </body>
</html> </html>

92
main.js
View file

@ -31,12 +31,14 @@ var noBasePlate = false;
var noGravity = false; var noGravity = false;
var showArms = false; var showArms = false;
var small = false; var small = false;
//The rotation values are all in degrees.
var head = new THREE.Vector3(0,0,0); var head = new THREE.Vector3(0,0,0);
var body = new THREE.Vector3(0,0,0); var body = new THREE.Vector3(0,0,0);
var leftLeg = new THREE.Vector3(0,0,0); var leftLeg = new THREE.Vector3(0,0,0);
var rightLeg = new THREE.Vector3(0,0,0); var rightLeg = new THREE.Vector3(0,0,0);
var leftArm = new THREE.Vector3(0,0,0); var leftArm = new THREE.Vector3(0,0,0);
var rightarm = new THREE.Vector3(0,0,0); var rightArm = new THREE.Vector3(0,0,0);
var rotation = 0;
//Stuff for mouse movements //Stuff for mouse movements
var mouseDownX; var mouseDownX;
@ -90,21 +92,24 @@ function setup(){
scene = new THREE.Scene(); scene = new THREE.Scene();
armorstand = new THREE.Object3D(); armorstand = new THREE.Object3D();
//Add an armorstandWrapper to the scene, so the armorstand can be rotated naturally.
armorstandWrapper = new THREE.Object3D();
armorstand.position.set(0,-0.5,0);
armorstandWrapper.add(armorstand);
//BasePlate //BasePlate
mBasePlate = new THREE.Mesh( mBasePlate = new THREE.Mesh(
new THREE.CubeGeometry(12/16, 1/16, 12/16), new THREE.CubeGeometry(12/16, 1/16, 12/16),
matStone); matStone);
mBasePlate.position.y = -1/32; mBasePlate.position.y = - (1/32 - armorstand.position.y);
//Add a little dot to the BasePlate, so the user knows which way is forward armorstandWrapper.add(mBasePlate);
mmBaseDot = new THREE.Mesh( //Add a little dot, so the user knows which way is forward
new THREE.CubeGeometry(4/16, 1/16, 4/16), var mmBaseDot = new THREE.Mesh(
new THREE.CubeGeometry(2/16, 1/16, 4/16),
matStone); matStone);
mmBaseDot.position.set(0,0,8/16); mmBaseDot.position.set(0,mBasePlate.position.y,10/16);
mBasePlate.add(mmBaseDot); armorstandWrapper.add(mmBaseDot);
armorstand.add(mBasePlate);
// To Generate the other body parts, we will use a mesh to display, // To Generate the other body parts, we will use a mesh to display,
// and add it as a child to the object that serves as a pivot. // and add it as a child to the object that serves as a pivot.
@ -191,10 +196,7 @@ function setup(){
mHead.add(mmNeck); mHead.add(mmNeck);
armorstand.add(mHead); armorstand.add(mHead);
//Add an armorstandwrapper to the scene, so the armorstand can be rotated naturally.
armorstandWrapper = new THREE.Object3D();
armorstand.position.set(0,-0.5,0);
armorstandWrapper.add(armorstand);
scene.add(armorstandWrapper); scene.add(armorstandWrapper);
camera = new THREE.PerspectiveCamera(45, width/height, 0.1, 1000); camera = new THREE.PerspectiveCamera(45, width/height, 0.1, 1000);
@ -211,19 +213,30 @@ function setup(){
function handleInput(){ function handleInput(){
invisible = getCheckBox("invisible"); invisible = getCheckBoxInput("invisible");
invulnerable = getCheckBox("invulnerable"); invulnerable = getCheckBoxInput("invulnerable");
noBasePlate = getCheckBox("nobaseplate"); noBasePlate = getCheckBoxInput("nobaseplate");
noGravity = getCheckBox("nogravity"); noGravity = getCheckBoxInput("nogravity");
showArms = getCheckBox("showarms"); showArms = getCheckBoxInput("showarms");
small = getCheckBox("small"); small = getCheckBoxInput("small");
body.set(getRangeInput("bodyX"), getRangeInput("bodyY"), getRangeInput("bodyZ"));
head.set(getRangeInput("headX"), getRangeInput("headY"), getRangeInput("headZ"));
leftLeg.set(getRangeInput("leftLegX"), getRangeInput("leftLegY"), getRangeInput("leftLegZ"));
rightLeg.set(getRangeInput("rightLegX"), getRangeInput("rightLegY"), getRangeInput("rightLegZ"));
leftArm.set(getRangeInput("leftArmX"), getRangeInput("leftArmY"), getRangeInput("leftArmZ"));
rightArm.set(getRangeInput("rightArmX"), getRangeInput("rightArmY"), getRangeInput("rightArmZ"));
rotation = getRangeInput("rotation");
updateUI(); updateUI();
} }
function getCheckBox(name){ function getCheckBoxInput(name){
return $("input[name="+name+"]").prop("checked"); return $("input[name="+name+"]").prop("checked");
} }
function getRangeInput(name){
return $("input[name="+name+"]").val();
}
/** Changes stuff according to our input values */ /** Changes stuff according to our input values */
function updateUI(){ function updateUI(){
@ -232,6 +245,45 @@ function updateUI(){
$("#inputarms").show(); $("#inputarms").show();
else else
$("#inputarms").hide(); $("#inputarms").hide();
$("#code").text(generateCode());
// Rotate 3D Stuff
// y and z rotation needs to be inverted
mBody.rotation.set(body.x * DEG2RAD, -body.y * DEG2RAD, -body.z * DEG2RAD);
mHead.rotation.set(head.x * DEG2RAD, -head.y * DEG2RAD, -head.z * DEG2RAD);
mLegLeft.rotation.set(leftLeg.x * DEG2RAD, -leftLeg.y * DEG2RAD, -leftLeg.z * DEG2RAD);
mLegRight.rotation.set(rightLeg.x * DEG2RAD, -rightLeg.y * DEG2RAD, -rightLeg.z * DEG2RAD);
mArmLeft.rotation.set(leftArm.x * DEG2RAD, -leftArm.y * DEG2RAD, -leftArm.z * DEG2RAD);
mArmRight.rotation.set(rightArm.x * DEG2RAD, -rightArm.y * DEG2RAD, -rightArm.z * DEG2RAD);
armorstand.rotation.y = -rotation * DEG2RAD;
//Set Visibility
mArmRight.visible = mArmLeft.visible = showArms;
mBasePlate.visible = !noBasePlate;
}
function generateCode(){
var code = "/summon ArmorStand ~ ~ ~ {";
var tags = [];
if(invisible)
tags.push("Invisible:1b");
if(invulnerable)
tags.push("Invulnerable:1b");
if(noBasePlate)
tags.push("NoBasePlate:1b");
if(noGravity)
tags.push("NoGravity:1b");
if(showArms)
tags.push("ShowArms:1b");
if(small)
tags.push("Small:1b");
code += tags.join(",");
code += "}";
return code;
} }
function getMouseDeltaX(){ function getMouseDeltaX(){

View file

@ -32,6 +32,13 @@ body{
margin: 0.5em; margin: 0.5em;
} }
#code{
margin: 0.5em;
padding: 0.5em;
font-style: italic;
word-wrap: break-word;
}
h1{ h1{
text-align: center; text-align: center;
font-family: "Oswald", sans-serif; font-family: "Oswald", sans-serif;