diff --git a/assignment-client/src/metavoxels/MetavoxelServer.cpp b/assignment-client/src/metavoxels/MetavoxelServer.cpp index 314ffb28e4..89b3102391 100644 --- a/assignment-client/src/metavoxels/MetavoxelServer.cpp +++ b/assignment-client/src/metavoxels/MetavoxelServer.cpp @@ -311,7 +311,7 @@ MetavoxelPersister::MetavoxelPersister(MetavoxelServer* server) : const char* SAVE_FILE = "/resources/metavoxels.dat"; const int FILE_MAGIC = 0xDADAFACE; -const int FILE_VERSION = 1; +const int FILE_VERSION = 2; void MetavoxelPersister::load() { QString path = QCoreApplication::applicationDirPath() + SAVE_FILE; diff --git a/examples/butterflies.js b/examples/butterflies.js index 8055e5b7d9..edc33f7625 100644 --- a/examples/butterflies.js +++ b/examples/butterflies.js @@ -13,18 +13,13 @@ // -var numButterflies = 20; +var numButterflies = 25; function getRandomFloat(min, max) { return Math.random() * (max - min) + min; } -// Multiply vector by scalar -function vScalarMult(v, s) { - var rval = { x: v.x * s, y: v.y * s, z: v.z * s }; - return rval; -} // Create a random vector with individual lengths between a,b function randVector(a, b) { @@ -32,50 +27,36 @@ function randVector(a, b) { return rval; } -// Returns a vector which is fraction of the way between a and b -function vInterpolate(a, b, fraction) { - var rval = { x: a.x + (b.x - a.x) * fraction, y: a.y + (b.y - a.y) * fraction, z: a.z + (b.z - a.z) * fraction }; - return rval; -} - var startTimeInSeconds = new Date().getTime() / 1000; -var NATURAL_SIZE_OF_BUTTERFLY = { x: 1.76, y: 0.825, z: 0.20 }; -var lifeTime = 600; // lifetime of the butterflies in seconds -var range = 3.0; // Over what distance in meters do you want the flock to fly around +var NATURAL_SIZE_OF_BUTTERFLY = { x: 1.0, y: 0.4, z: 0.2 }; + +var lifeTime = 3600; // One hour lifespan +var range = 7.0; // Over what distance in meters do you want the flock to fly around var frame = 0; -var CHANCE_OF_MOVING = 0.9; -var BUTTERFLY_GRAVITY = 0; -var BUTTERFLY_FLAP_SPEED = 0.5; -var BUTTERFLY_VELOCITY = 0.55; var DISTANCE_IN_FRONT_OF_ME = 1.5; var DISTANCE_ABOVE_ME = 1.5; -var flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum( +var FIXED_LOCATION = false; + +if (!FIXED_LOCATION) { + var flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum( Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_ABOVE_ME), Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME))); - +} else { + var flockPosition = { x: 4999.6, y: 4986.5, z: 5003.5 }; +} -// set these pitch, yaw, roll to the needed values to orient the model as you want it -var pitchInDegrees = 270.0; -var yawInDegrees = 0.0; -var rollInDegrees = 0.0; -var pitchInRadians = pitchInDegrees / 180.0 * Math.PI; -var yawInRadians = yawInDegrees / 180.0 * Math.PI; -var rollInRadians = rollInDegrees / 180.0 * Math.PI; - -var rotation = Quat.fromPitchYawRollDegrees(pitchInDegrees, yawInDegrees, rollInDegrees);//experimental // This is our butterfly object function defineButterfly(entityID, targetPosition) { this.entityID = entityID; - this.previousFlapOffset = 0; this.targetPosition = targetPosition; - this.moving = false; } // Array of butterflies var butterflies = []; + function addButterfly() { // Decide the size of butterfly var color = { red: 100, green: 100, blue: 100 }; @@ -88,26 +69,24 @@ function addButterfly() { size = MINSIZE + Math.random() * RANGESIZE; var dimensions = Vec3.multiply(NATURAL_SIZE_OF_BUTTERFLY, (size / maxSize)); - - flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum( - Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_ABOVE_ME), - Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME))); - + + var GRAVITY = -0.2; + var newFrameRate = 20 + Math.random() * 30; var properties = { type: "Model", lifetime: lifeTime, position: Vec3.sum(randVector(-range, range), flockPosition), - velocity: { x: 0, y: 0.0, z: 0 }, - gravity: { x: 0, y: 1.0, z: 0 }, - damping: 0.1, + rotation: Quat.fromPitchYawRollDegrees(-80 + Math.random() * 20, Math.random() * 360.0, 0.0), + velocity: { x: 0, y: 0, z: 0 }, + gravity: { x: 0, y: GRAVITY, z: 0 }, + damping: 0.9999, dimensions: dimensions, color: color, - rotation: rotation, animationURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/content/butterfly/butterfly.fbx", - animationIsPlaying: true, + animationSettings: "{\"firstFrame\":0,\"fps\":" + newFrameRate + ",\"frameIndex\":0,\"hold\":false,\"lastFrame\":10000,\"loop\":true,\"running\":true,\"startAutomatically\":false}", modelURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/models/content/butterfly/butterfly.fbx" }; - butterflies.push(new defineButterfly(Entities.addEntity(properties), properties.position)); + butterflies.push(Entities.addEntity(properties)); } // Generate the butterflies @@ -116,117 +95,37 @@ for (var i = 0; i < numButterflies; i++) { } // Main update function -function updateButterflies(deltaTime) { - // Check to see if we've been running long enough that our butterflies are dead - var nowTimeInSeconds = new Date().getTime() / 1000; - if ((nowTimeInSeconds - startTimeInSeconds) >= lifeTime) { - Script.stop(); - return; - } - +function updateButterflies(deltaTime) { frame++; // Only update every third frame because we don't need to do it too quickly if ((frame % 3) == 0) { - flockPosition = Vec3.sum(MyAvatar.position,Vec3.sum(Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_ABOVE_ME), - Vec3.multiply(Quat.getFront(MyAvatar.orientation), DISTANCE_IN_FRONT_OF_ME))); - // Update all the butterflies + var CHANCE_OF_IMPULSE = 0.04; for (var i = 0; i < numButterflies; i++) { - entityID = Entities.identifyEntity(butterflies[i].entityID); - butterflies[i].entityID = entityID; - var properties = Entities.getEntityProperties(entityID); - - if (properties.position.y > flockPosition.y + getRandomFloat(0.0,0.3)){ //0.3 //ceiling - properties.gravity.y = - 3.0; - properties.damping.y = 1.0; - properties.velocity.y = 0; - properties.velocity.x = properties.velocity.x; - properties.velocity.z = properties.velocity.z; - if (properties.velocity.x < 0.5){ - butterflies[i].moving = false; + if (Math.random() < CHANCE_OF_IMPULSE) { + if (!butterflies[i].isKnownID) { + butterflies[i] = Entities.identifyEntity(butterflies[i]); } - if (properties.velocity.z < 0.5){ - butterflies[i].moving = false; - } - } - - if (properties.velocity.y <= -0.2) { - properties.velocity.y = 0.22; - properties.velocity.x = properties.velocity.x; - properties.velocity.z = properties.velocity.z; - } - - if (properties.position.y < flockPosition.y - getRandomFloat(0.0,0.3)) { //-0.3 // floor - properties.velocity.y = 0.9; - properties.gravity.y = - 4.0; - properties.velocity.x = properties.velocity.x; - properties.velocity.z = properties.velocity.z; - if (properties.velocity.x < 0.5){ - butterflies[i].moving = false; - } - if (properties.velocity.z < 0.5){ - butterflies[i].moving = false; - } - } - - - // Begin movement by getting a target - if (butterflies[i].moving == false) { - if (Math.random() < CHANCE_OF_MOVING) { - var targetPosition = Vec3.sum(randVector(-range, range), flockPosition); - if (targetPosition.x < 0) { - targetPosition.x = 0; - } - if (targetPosition.y < 0) { - targetPosition.y = 0; - } - if (targetPosition.z < 0) { - targetPosition.z = 0; - } - if (targetPosition.x > TREE_SCALE) { - targetPosition.x = TREE_SCALE; - } - if (targetPosition.y > TREE_SCALE) { - targetPosition.y = TREE_SCALE; - } - if (targetPosition.z > TREE_SCALE) { - targetPosition.z = TREE_SCALE; - } - butterflies[i].targetPosition = targetPosition; - butterflies[i].moving = true; + var properties = Entities.getEntityProperties(butterflies[i]); + if (Vec3.length(Vec3.subtract(properties.position, flockPosition)) > range) { + Entities.editEntity(butterflies[i], { position: flockPosition } ); + } else if (properties.velocity.y < 0.0) { + // If falling, Create a new direction and impulse + var HORIZ_SCALE = 0.50; + var VERT_SCALE = 0.50; + var newHeading = Math.random() * 360.0; + var newVelocity = Vec3.multiply(HORIZ_SCALE, Quat.getFront(Quat.fromPitchYawRollDegrees(0.0, newHeading, 0.0))); + newVelocity.y = (Math.random() + 0.5) * VERT_SCALE; + Entities.editEntity(butterflies[i], { rotation: Quat.fromPitchYawRollDegrees(-80 + Math.random() * 20, newHeading, (Math.random() - 0.5) * 10), + velocity: newVelocity } ); } } - - // If we are moving, move towards the target - if (butterflies[i].moving) { - - var holding = properties.velocity.y; - - var desiredVelocity = Vec3.subtract(butterflies[i].targetPosition, properties.position); - desiredVelocity = vScalarMult(Vec3.normalize(desiredVelocity), BUTTERFLY_VELOCITY); - - properties.velocity = vInterpolate(properties.velocity, desiredVelocity, 0.5); - properties.velocity.y = holding ; - - - // If we are near the target, we should get a new target - var halfLargestDimension = Vec3.length(properties.dimensions) / 2.0; - if (Vec3.length(Vec3.subtract(properties.position, butterflies[i].targetPosition)) < (halfLargestDimension)) { - butterflies[i].moving = false; - } - - var yawRads = Math.atan2(properties.velocity.z, properties.velocity.x); - yawRads = yawRads + Math.PI / 2.0; - var newOrientation = Quat.fromPitchYawRollRadians(pitchInRadians, yawRads, rollInRadians); - properties.rotation = newOrientation; - } - - // Use a cosine wave offset to make it look like its flapping. - var offset = Math.cos(nowTimeInSeconds * BUTTERFLY_FLAP_SPEED) * (halfLargestDimension); - properties.position.y = properties.position.y + (offset - butterflies[i].previousFlapOffset); - // Change position relative to previous offset. - butterflies[i].previousFlapOffset = offset; - Entities.editEntity(entityID, properties); + } + // Check to see if we've been running long enough that our butterflies are dead + var nowTimeInSeconds = new Date().getTime() / 1000; + if ((nowTimeInSeconds - startTimeInSeconds) >= lifeTime) { + Script.stop(); + return; } } } @@ -237,6 +136,6 @@ Script.update.connect(updateButterflies); // Delete our little friends if script is stopped Script.scriptEnding.connect(function() { for (var i = 0; i < numButterflies; i++) { - Entities.deleteEntity(butterflies[i].entityID); + Entities.deleteEntity(butterflies[i]); } }); \ No newline at end of file diff --git a/examples/developerMenuItems.js b/examples/developerMenuItems.js index 221975c9c8..34bd3b3a75 100644 --- a/examples/developerMenuItems.js +++ b/examples/developerMenuItems.js @@ -19,14 +19,17 @@ function setupMenus() { if (!Menu.menuExists("Developer > Entities")) { Menu.addMenu("Developer > Entities"); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Bounds", isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Triangles", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Bounds", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Display Model Element Children", isCheckable: true, isChecked: false }); - Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Disable Light Entities", isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt to Reduce Material Switches", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Attempt Render Entities as Scene", isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Don't Do Precision Picking", isCheckable: true, isChecked: false }); Menu.addMenu("Developer > Entities > Culling"); Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Out Of View Mesh Parts", isCheckable: true, isChecked: false }); Menu.addMenuItem({ menuName: "Developer > Entities > Culling", menuItemName: "Don't Cull Too Small Mesh Parts", isCheckable: true, isChecked: false }); + Menu.addMenuItem({ menuName: "Developer > Entities", menuItemName: "Disable Light Entities", isCheckable: true, isChecked: false }); } } diff --git a/examples/editModels.js b/examples/editModels.js index 8e3503b9b2..60ca9b6ca6 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -2554,7 +2554,7 @@ function mousePressEvent(event) { var pickRay = Camera.computePickRay(event.x, event.y); Vec3.print("[Mouse] Looking at: ", pickRay.origin); - var foundIntersection = Entities.findRayIntersection(pickRay); + var foundIntersection = Entities.findRayIntersection(pickRay, true); // we want precision picking here if(!foundIntersection.accurate) { return; diff --git a/examples/headMove.js b/examples/headMove.js index 4d2e4ded07..943664b70f 100644 --- a/examples/headMove.js +++ b/examples/headMove.js @@ -11,6 +11,8 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +var gamepads = {}; + var debug = false; var willMove = false; @@ -19,7 +21,6 @@ var warpPosition = { x: 0, y: 0, z: 0 }; var hipsToEyes; var restoreCountdownTimer; -var headTurningTimer = 0.0; // Overlays to show target location @@ -62,13 +63,6 @@ function restoreCameraState() { Camera.mode = oldMode; } -function activateWarp() { - if (warpActive) return; - warpActive = true; - - updateWarp(); -} - var WATCH_AVATAR_DISTANCE = 2.5; var sound = SoundCache.getSound("http://public.highfidelity.io/sounds/Footsteps/FootstepW2Right-12db.wav"); @@ -132,6 +126,22 @@ function updateWarp() { }); } +function activateWarp() { + if (warpActive) return; + warpActive = true; + movingWithHead = true; + hipsToEyes = MyAvatar.getEyePosition().y - MyAvatar.position.y; + headStartPosition = MyAvatar.getTrackedHeadPosition(); + headStartDeltaPitch = MyAvatar.getHeadDeltaPitch(); + headStartFinalPitch = MyAvatar.getHeadFinalPitch(); + headStartRoll = MyAvatar.getHeadFinalRoll(); + headStartYaw = MyAvatar.getHeadFinalYaw(); + deltaYaw = 0.0; + warpPosition = MyAvatar.position; + warpPosition.y += hipsToEyes; + updateWarp(); +} + function finishWarp() { if (!warpActive) return; warpActive = false; @@ -152,6 +162,9 @@ function finishWarp() { cameraPosition = Vec3.subtract(MyAvatar.position, Vec3.multiplyQbyV(Camera.getOrientation(), { x: 0, y: -hipsToEyes, z: -hipsToEyes * WATCH_AVATAR_DISTANCE })); Camera.setPosition(cameraPosition); playSound(); + if (watchAvatar) { + restoreCountdownTimer = RESTORE_TIME; + } } } @@ -169,35 +182,11 @@ function update(deltaTime) { restoreCountDownTimer = 0.0; } } - var HEAD_TURN_TIME = 0.10; - var HEAD_TURN_DEGREES = 4.0; - var HEAD_TURN_START_ANGLE = 45.0; - var currentYaw = MyAvatar.getHeadFinalYaw(); - if (Math.abs(currentYaw) > HEAD_TURN_START_ANGLE) { - headTurningTimer += deltaTime; - if (headTurningTimer > HEAD_TURN_TIME) { - headTurningTimer = 0.0; - MyAvatar.orientation = Quat.multiply(Quat.fromPitchYawRollDegrees(0, (currentYaw > 0) ? HEAD_TURN_DEGREES: -HEAD_TURN_DEGREES, 0), - MyAvatar.orientation); - } - } else { - headTurningTimer = 0.0; - } } Controller.keyPressEvent.connect(function(event) { if (event.text == "SPACE" && !event.isAutoRepeat && !movingWithHead) { keyDownTime = 0.0; - movingWithHead = true; - hipsToEyes = MyAvatar.getEyePosition().y - MyAvatar.position.y; - headStartPosition = MyAvatar.getTrackedHeadPosition(); - headStartDeltaPitch = MyAvatar.getHeadDeltaPitch(); - headStartFinalPitch = MyAvatar.getHeadFinalPitch(); - headStartRoll = MyAvatar.getHeadFinalRoll(); - headStartYaw = MyAvatar.getHeadFinalYaw(); - deltaYaw = 0.0; - warpPosition = MyAvatar.position; - warpPosition.y += hipsToEyes; activateWarp(); } }); @@ -223,11 +212,40 @@ Controller.keyReleaseEvent.connect(function(event) { } timeSinceLastUp = 0.0; finishWarp(); - if (watchAvatar) { - restoreCountdownTimer = RESTORE_TIME; - } } }); +function reportButtonValue(button, newValue, oldValue) { + if (button == Joysticks.BUTTON_FACE_RIGHT) { + if (newValue) { + activateWarp(); + } else { + finishWarp(); + } + } +} + Script.update.connect(update); +function addJoystick(gamepad) { + gamepad.buttonStateChanged.connect(reportButtonValue); + + gamepads[gamepad.instanceId] = gamepad; + + print("Added gamepad: " + gamepad.name + " (" + gamepad.instanceId + ")"); +} + +function removeJoystick(gamepad) { + delete gamepads[gamepad.instanceId] + + print("Removed gamepad: " + gamepad.name + " (" + gamepad.instanceId + ")"); +} + +var allJoysticks = Joysticks.getAllJoysticks(); +for (var i = 0; i < allJoysticks.length; i++) { + addJoystick(allJoysticks[i]); +} + +Joysticks.joystickAdded.connect(addJoystick); +Joysticks.joystickRemoved.connect(removeJoystick); + diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index a79edfb181..17eb0ad88f 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -103,13 +103,14 @@ var elIgnoreForCollisions = document.getElementById("property-ignore-for-collisions"); var elCollisionsWillMove = document.getElementById("property-collisions-will-move"); var elLifetime = document.getElementById("property-lifetime"); + var elScriptURL = document.getElementById("property-script-url"); - var elBoxSection = document.getElementById("box-section"); + var elBoxSections = document.querySelectorAll(".box-section"); var elBoxColorRed = document.getElementById("property-box-red"); var elBoxColorGreen = document.getElementById("property-box-green"); var elBoxColorBlue = document.getElementById("property-box-blue"); - var elLightSection = document.getElementById('light-section'); + var elLightSections = document.querySelectorAll(".light-section"); var elLightSpotLight = document.getElementById("property-light-spot-light"); var elLightDiffuseRed = document.getElementById("property-light-diffuse-red"); var elLightDiffuseGreen = document.getElementById("property-light-diffuse-green"); @@ -129,14 +130,14 @@ var elLightExponent = document.getElementById("property-light-exponent"); var elLightCutoff = document.getElementById("property-light-cutoff"); - var elModelSection = document.getElementById("model-section"); + var elModelSections = document.querySelectorAll(".model-section"); var elModelURL = document.getElementById("property-model-url"); var elModelAnimationURL = document.getElementById("property-model-animation-url"); var elModelAnimationPlaying = document.getElementById("property-model-animation-playing"); var elModelAnimationFPS = document.getElementById("property-model-animation-fps"); var elModelAnimationFrame = document.getElementById("property-model-animation-frame"); - var elTextSection = document.getElementById("text-section"); + var elTextSections = document.querySelectorAll(".text-section"); var elTextText = document.getElementById("property-text-text"); var elTextLineHeight = document.getElementById("property-text-line-height"); var elTextTextColorRed = document.getElementById("property-text-text-color-red"); @@ -160,102 +161,120 @@ elLocked.checked = properties.locked; if (properties.locked) { - disableChildren(document.getElementById("properties"), 'input'); + disableChildren(document.getElementById("properties-table"), 'input'); elLocked.removeAttribute('disabled'); } else { - enableChildren(document.getElementById("properties"), 'input'); + enableChildren(document.getElementById("properties-table"), 'input'); + } - elVisible.checked = properties.visible; + elVisible.checked = properties.visible; - elPositionX.value = properties.position.x.toFixed(2); - elPositionY.value = properties.position.y.toFixed(2); - elPositionZ.value = properties.position.z.toFixed(2); + elPositionX.value = properties.position.x.toFixed(2); + elPositionY.value = properties.position.y.toFixed(2); + elPositionZ.value = properties.position.z.toFixed(2); - elDimensionsX.value = properties.dimensions.x.toFixed(2); - elDimensionsY.value = properties.dimensions.y.toFixed(2); - elDimensionsZ.value = properties.dimensions.z.toFixed(2); + elDimensionsX.value = properties.dimensions.x.toFixed(2); + elDimensionsY.value = properties.dimensions.y.toFixed(2); + elDimensionsZ.value = properties.dimensions.z.toFixed(2); - elRegistrationX.value = properties.registrationPoint.x.toFixed(2); - elRegistrationY.value = properties.registrationPoint.y.toFixed(2); - elRegistrationZ.value = properties.registrationPoint.z.toFixed(2); + elRegistrationX.value = properties.registrationPoint.x.toFixed(2); + elRegistrationY.value = properties.registrationPoint.y.toFixed(2); + elRegistrationZ.value = properties.registrationPoint.z.toFixed(2); - elLinearVelocityX.value = properties.velocity.x.toFixed(2); - elLinearVelocityY.value = properties.velocity.y.toFixed(2); - elLinearVelocityZ.value = properties.velocity.z.toFixed(2); - elLinearDamping.value = properties.damping.toFixed(2); + elLinearVelocityX.value = properties.velocity.x.toFixed(2); + elLinearVelocityY.value = properties.velocity.y.toFixed(2); + elLinearVelocityZ.value = properties.velocity.z.toFixed(2); + elLinearDamping.value = properties.damping.toFixed(2); - elAngularVelocityX.value = properties.angularVelocity.x.toFixed(2); - elAngularVelocityY.value = properties.angularVelocity.y.toFixed(2); - elAngularVelocityZ.value = properties.angularVelocity.z.toFixed(2); - elAngularDamping.value = properties.angularDamping.toFixed(2); + elAngularVelocityX.value = properties.angularVelocity.x.toFixed(2); + elAngularVelocityY.value = properties.angularVelocity.y.toFixed(2); + elAngularVelocityZ.value = properties.angularVelocity.z.toFixed(2); + elAngularDamping.value = properties.angularDamping.toFixed(2); - elGravityX.value = properties.gravity.x.toFixed(2); - elGravityY.value = properties.gravity.y.toFixed(2); - elGravityZ.value = properties.gravity.z.toFixed(2); + elGravityX.value = properties.gravity.x.toFixed(2); + elGravityY.value = properties.gravity.y.toFixed(2); + elGravityZ.value = properties.gravity.z.toFixed(2); - elMass.value = properties.mass.toFixed(2); - elIgnoreForCollisions.checked = properties.ignoreForCollisions; - elCollisionsWillMove.checked = properties.collisionsWillMove; - elLifetime.value = properties.lifetime; + elMass.value = properties.mass.toFixed(2); + elIgnoreForCollisions.checked = properties.ignoreForCollisions; + elCollisionsWillMove.checked = properties.collisionsWillMove; + elLifetime.value = properties.lifetime; + elScriptURL.value = properties.script; - if (properties.type != "Box") { - elBoxSection.style.display = 'none'; - } else { - elBoxSection.style.display = 'block'; - - elBoxColorRed.value = properties.color.red; - elBoxColorGreen.value = properties.color.green; - elBoxColorBlue.value = properties.color.blue; + if (properties.type != "Box") { + for (var i = 0; i < elBoxSections.length; i++) { + elBoxSections[i].style.display = 'none'; + } + } else { + for (var i = 0; i < elBoxSections.length; i++) { + elBoxSections[i].style.display = 'table-row'; } - if (properties.type != "Model") { - elModelSection.style.display = 'none'; - } else { - elModelSection.style.display = 'block'; - elModelURL.value = properties.modelURL; - elModelAnimationURL.value = properties.animationURL; - elModelAnimationPlaying.checked = properties.animationIsPlaying; - elModelAnimationFPS.value = properties.animationFPS; + elBoxColorRed.value = properties.color.red; + elBoxColorGreen.value = properties.color.green; + elBoxColorBlue.value = properties.color.blue; + } + + if (properties.type != "Model") { + for (var i = 0; i < elModelSections.length; i++) { + elModelSections[i].style.display = 'none'; + } + } else { + for (var i = 0; i < elModelSections.length; i++) { + elModelSections[i].style.display = 'table-row'; } - if (properties.type != "Text") { - elTextSection.style.display = 'none'; - } else { - elTextSection.style.display = 'block'; + elModelURL.value = properties.modelURL; + elModelAnimationURL.value = properties.animationURL; + elModelAnimationPlaying.checked = properties.animationIsPlaying; + elModelAnimationFPS.value = properties.animationFPS; + } - elTextText.value = properties.text; - elTextLineHeight.value = properties.lineHeight; - elTextTextColorRed.value = properties.textColor.red; - elTextTextColorGreen.value = properties.textColor.green; - elTextTextColorBlue.value = properties.textColor.blue; - elTextBackgroundColorRed.value = properties.backgroundColor.red; - elTextBackgroundColorGreen.value = properties.backgroundColor.green; - elTextBackgroundColorBlue.value = properties.backgroundColor.blue; + if (properties.type != "Text") { + for (var i = 0; i < elTextSections.length; i++) { + elTextSections[i].style.display = 'none'; + } + } else { + for (var i = 0; i < elTextSections.length; i++) { + elTextSections[i].style.display = 'table-row'; } - if (properties.type != "Light") { - elLightSection.style.display = 'none'; - } else { - elLightSection.style.display = 'block'; + elTextText.value = properties.text; + elTextLineHeight.value = properties.lineHeight; + elTextTextColorRed.value = properties.textColor.red; + elTextTextColorGreen.value = properties.textColor.green; + elTextTextColorBlue.value = properties.textColor.blue; + elTextBackgroundColorRed.value = properties.backgroundColor.red; + elTextBackgroundColorGreen.value = properties.backgroundColor.green; + elTextBackgroundColorBlue.value = properties.backgroundColor.blue; + } - elLightDiffuseRed.value = properties.diffuseColor.red; - elLightDiffuseGreen.value = properties.diffuseColor.green; - elLightDiffuseBlue.value = properties.diffuseColor.blue; - - elLightAmbientRed.value = properties.ambientColor.red; - elLightAmbientGreen.value = properties.ambientColor.green; - elLightAmbientBlue.value = properties.ambientColor.blue; - - elLightSpecularRed.value = properties.specularColor.red; - elLightSpecularGreen.value = properties.specularColor.green; - elLightSpecularBlue.value = properties.specularColor.blue; - - elLightConstantAttenuation.value = properties.constantAttenuation; - elLightLinearAttenuation.value = properties.linearAttenuation; - elLightQuadraticAttenuation.value = properties.quadraticAttenuation; - elLightExponent.value = properties.exponent; - elLightCutoff.value = properties.cutoff; + if (properties.type != "Light") { + for (var i = 0; i < elLightSections.length; i++) { + elLightSections[i].style.display = 'none'; } + } else { + for (var i = 0; i < elLightSections.length; i++) { + elLightSections[i].style.display = 'table-row'; + } + + elLightDiffuseRed.value = properties.diffuseColor.red; + elLightDiffuseGreen.value = properties.diffuseColor.green; + elLightDiffuseBlue.value = properties.diffuseColor.blue; + + elLightAmbientRed.value = properties.ambientColor.red; + elLightAmbientGreen.value = properties.ambientColor.green; + elLightAmbientBlue.value = properties.ambientColor.blue; + + elLightSpecularRed.value = properties.specularColor.red; + elLightSpecularGreen.value = properties.specularColor.green; + elLightSpecularBlue.value = properties.specularColor.blue; + + elLightConstantAttenuation.value = properties.constantAttenuation; + elLightLinearAttenuation.value = properties.linearAttenuation; + elLightQuadraticAttenuation.value = properties.quadraticAttenuation; + elLightExponent.value = properties.exponent; + elLightCutoff.value = properties.cutoff; } } } @@ -307,6 +326,7 @@ elIgnoreForCollisions.addEventListener('change', createEmitCheckedPropertyUpdateFunction('ignoreForCollisions')); elCollisionsWillMove.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionsWillMove')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); + elScriptURL.addEventListener('change', createEmitTextPropertyUpdateFunction('script')); var boxColorChangeFunction = createEmitColorPropertyUpdateFunction( 'color', elBoxColorRed, elBoxColorGreen, elBoxColorBlue); @@ -345,7 +365,7 @@ elModelAnimationPlaying.addEventListener('change', createEmitCheckedPropertyUpdateFunction('animationIsPlaying')); elModelAnimationFPS.addEventListener('change', createEmitNumberPropertyUpdateFunction('animationFPS')); elModelAnimationFrame.addEventListener('change', createEmitNumberPropertyUpdateFunction('animationFrameIndex')); - + elTextText.addEventListener('change', createEmitTextPropertyUpdateFunction('text')); elTextLineHeight.addEventListener('change', createEmitNumberPropertyUpdateFunction('lineHeight')); @@ -361,6 +381,50 @@ elTextBackgroundColorGreen.addEventListener('change', textBackgroundColorChangeFunction); elTextBackgroundColorBlue.addEventListener('change', textBackgroundColorChangeFunction); + + var resizing = false; + var startX = 0; + var originalWidth = 0; + var resizeHandleWidth = 10; + + var col1 = document.querySelector("#col-label"); + + document.body.addEventListener('mousemove', function(event) { + if (resizing) { + var dX = event.x - startX; + col1.style.width = (originalWidth + dX) + "px"; + } + }); + document.body.addEventListener('mouseup', function(event) { + resizing = false; + }); + document.body.addEventListener('mouseleave', function(event) { + resizing = false; + }); + var els = document.querySelectorAll("#properties-table td"); + for (var i = 0; i < els.length; i++) { + var el = els[i]; + el.addEventListener('mousemove', function(event) { + if (!resizing) { + var distance = this.offsetWidth - event.offsetX; + if (distance < resizeHandleWidth) { + document.body.style.cursor = "ew-resize"; + } else { + document.body.style.cursor = "initial"; + } + } + }); + el.addEventListener('mousedown', function(event) { + var distance = this.offsetWidth - event.offsetX; + if (distance < resizeHandleWidth) { + startX = event.x; + originalWidth = this.offsetWidth; + resizing = true; + target = this; + } + }); + } + } @@ -368,272 +432,267 @@
+ Type + | ++ + | +
Locked | +- - + | +
Visible | +- - + | +
Position | +
+ X
+ Y
+ Z
+ |
+
Registration | +
+ X
+ Y
+ Z
+ |
+
Dimensions | +
+ X
+ Y
+ Z
+ |
+
Linear Velocity | +
+ X
+ Y
+ Z
+ |
+
Linear Damping | +
-
-
-
-
-
- Pitch
- Roll
- Yaw
-
-
-
-
-
+ |
+
Angular Velocity | +
+ Pitch
+ Yaw
+ Roll
+ |
+
Angular Damping | +- - + | +
Gravity | +
+ X
+ Y
+ Z
+ |
+
Mass | +- - + | +
Ignore For Collisions | +- - + | +
Collisions Will Move | +- - + | +
Lifetime | +- - + | +
Script URL | ++ + | +
Color | +
+ R
+ G
+ B
+ |
+
Model URL | ++ + | +
Animation URL | ++ + | +
Animation Playing | ++ + | +
Animation FPS | ++ + | +
Animation Frame | ++ + | +
Text | ++ + | +
Line Height | ++ + | +
Text Color | +
+ R
+ G
+ B
+ |
+
Background Color | +
+ R
+ G
+ B
+ |
+
Spot Light | ++ + | +
Diffuse | +
+ R
+ G
+ B
+ |
+
Ambient | +
+ R
+ G
+ B
+ |
+
Specular | +
+ R
+ G
+ B
+ |
+
Constant Attenuation | ++ + | +
Linear Attenuation | ++ + | +
Quadratic Attenuation | ++ + | +
Exponent | ++ + | +
Cutoff (degrees) | ++ + | +