started to add grabbable psuedo properties to edit.js

This commit is contained in:
Seth Alves 2016-03-12 10:13:13 -08:00
parent 8420e67b54
commit f1992af38e
3 changed files with 56 additions and 13 deletions

View file

@ -213,7 +213,6 @@ function AttachedEntitiesManager() {
var props = Entities.getEntityProperties(entityID); var props = Entities.getEntityProperties(entityID);
if (props.parentID == MyAvatar.sessionUUID) { if (props.parentID == MyAvatar.sessionUUID) {
grabData = getEntityCustomData('grabKey', entityID, {}); grabData = getEntityCustomData('grabKey', entityID, {});
grabbableData = getEntityCustomData('grabbableKey', entityID, {});
var wearableData = getEntityCustomData('wearable', entityID, DEFAULT_WEARABLE_DATA); var wearableData = getEntityCustomData('wearable', entityID, DEFAULT_WEARABLE_DATA);
var currentJointName = MyAvatar.getJointNames()[props.parentJointIndex]; var currentJointName = MyAvatar.getJointNames()[props.parentJointIndex];
wearableData.joints[currentJointName] = [props.localPosition, props.localRotation]; wearableData.joints[currentJointName] = [props.localPosition, props.localRotation];

View file

@ -1006,7 +1006,7 @@ function MyController(hand) {
// else this thing isn't physical. grab it by reparenting it (but not if we've already // else this thing isn't physical. grab it by reparenting it (but not if we've already
// grabbed it). // grabbed it).
if (grabbableData.refCount < 1) { if (refCount < 1) {
this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP); this.setState(this.state == STATE_SEARCHING ? STATE_NEAR_GRABBING : STATE_EQUIP);
return; return;
} else { } else {
@ -1120,7 +1120,6 @@ function MyController(hand) {
var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation); var controllerRotation = Quat.multiply(MyAvatar.orientation, avatarControllerPose.rotation);
var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES); var grabbedProperties = Entities.getEntityProperties(this.grabbedEntity, GRABBABLE_PROPERTIES);
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
if (this.state == STATE_CONTINUE_DISTANCE_HOLDING && this.bumperSqueezed() && if (this.state == STATE_CONTINUE_DISTANCE_HOLDING && this.bumperSqueezed() &&
this.hasPresetOffsets()) { this.hasPresetOffsets()) {
@ -1307,7 +1306,6 @@ function MyController(hand) {
this.nearGrabbing = function() { this.nearGrabbing = function() {
var now = Date.now(); var now = Date.now();
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) { if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) {
this.setState(STATE_RELEASE); this.setState(STATE_RELEASE);
@ -1330,10 +1328,9 @@ function MyController(hand) {
var handRotation = (this.hand === RIGHT_HAND) ? MyAvatar.getRightPalmRotation() : MyAvatar.getLeftPalmRotation(); var handRotation = (this.hand === RIGHT_HAND) ? MyAvatar.getRightPalmRotation() : MyAvatar.getLeftPalmRotation();
var handPosition = this.getHandPosition(); var handPosition = this.getHandPosition();
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
var hasPresetPosition = false; var hasPresetPosition = false;
if (this.state != STATE_NEAR_GRABBING && this.hasPresetOffsets()) { if (this.state != STATE_NEAR_GRABBING && this.hasPresetOffsets()) {
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA);
// if an object is "equipped" and has a predefined offset, use it. // if an object is "equipped" and has a predefined offset, use it.
this.ignoreIK = grabbableData.ignoreIK ? grabbableData.ignoreIK : false; this.ignoreIK = grabbableData.ignoreIK ? grabbableData.ignoreIK : false;
this.offsetPosition = this.getPresetPosition(); this.offsetPosition = this.getPresetPosition();
@ -1676,7 +1673,6 @@ function MyController(hand) {
}; };
this.activateEntity = function(entityID, grabbedProperties, wasLoaded) { this.activateEntity = function(entityID, grabbedProperties, wasLoaded) {
var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, entityID, DEFAULT_GRABBABLE_DATA);
var data = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, {}); var data = getEntityCustomData(GRAB_USER_DATA_KEY, entityID, {});
var now = Date.now(); var now = Date.now();

View file

@ -243,6 +243,21 @@
} }
function createUserDataChanger(groupName, keyName, propertyElement, userData) {
return function() {
var properties = {};
// // this.checked
// properties['userData'] = ... JSON.stringify (...)
// EventBridge.emitWebEvent(
// JSON.stringify({
// type: "update",
// properties: properties,
// })
// );
}
};
function loaded() { function loaded() {
openEventBridge(function() { openEventBridge(function() {
var allSections = []; var allSections = [];
@ -305,6 +320,11 @@
var elCollideMyAvatar = document.getElementById("property-collide-myAvatar"); var elCollideMyAvatar = document.getElementById("property-collide-myAvatar");
var elCollideOtherAvatar = document.getElementById("property-collide-otherAvatar"); var elCollideOtherAvatar = document.getElementById("property-collide-otherAvatar");
var elCollisionSoundURL = document.getElementById("property-collision-sound-url"); var elCollisionSoundURL = document.getElementById("property-collision-sound-url");
var elGrabbable = document.getElementById("property-grabbable" );
var elWantsTrigger = document.getElementById("property-wants-trigger" );
var elIgnoreIK = document.getElementById("property-ignore-ik" );
var elLifetime = document.getElementById("property-lifetime"); var elLifetime = document.getElementById("property-lifetime");
var elScriptURL = document.getElementById("property-script-url"); var elScriptURL = document.getElementById("property-script-url");
var elScriptTimestamp = document.getElementById("property-script-timestamp"); var elScriptTimestamp = document.getElementById("property-script-timestamp");
@ -408,7 +428,7 @@
var elXTextureURL = document.getElementById("property-x-texture-url"); var elXTextureURL = document.getElementById("property-x-texture-url");
var elYTextureURL = document.getElementById("property-y-texture-url"); var elYTextureURL = document.getElementById("property-y-texture-url");
var elZTextureURL = document.getElementById("property-z-texture-url"); var elZTextureURL = document.getElementById("property-z-texture-url");
var elPreviewCameraButton = document.getElementById("preview-camera-button"); var elPreviewCameraButton = document.getElementById("preview-camera-button");
if (window.EventBridge !== undefined) { if (window.EventBridge !== undefined) {
@ -518,13 +538,15 @@
elCollisionless.checked = properties.collisionless; elCollisionless.checked = properties.collisionless;
elDynamic.checked = properties.dynamic; elDynamic.checked = properties.dynamic;
elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1; elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1;
elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1; elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1;
elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1; elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1;
elCollideMyAvatar.checked = properties.collidesWith.indexOf("myAvatar") > -1; elCollideMyAvatar.checked = properties.collidesWith.indexOf("myAvatar") > -1;
elCollideOtherAvatar.checked = properties.collidesWith.indexOf("otherAvatar") > -1; elCollideOtherAvatar.checked = properties.collidesWith.indexOf("otherAvatar") > -1;
elGrabbable.checked = properties.collidesWith.indexOf("grabbable") > -1;
elWantsTrigger.checked = properties.collidesWith.indexOf("wantsTrigger") > -1;
elIgnoreIK.checked = properties.collidesWith.indexOf("ignoreIK") > -1;
elCollisionSoundURL.value = properties.collisionSoundURL; elCollisionSoundURL.value = properties.collisionSoundURL;
elLifetime.value = properties.lifetime; elLifetime.value = properties.lifetime;
@ -737,9 +759,6 @@
elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless'));
elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic'));
elCollideDynamic.addEventListener('change', function() { elCollideDynamic.addEventListener('change', function() {
updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic'); updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic');
}); });
@ -758,6 +777,12 @@
updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideOtherAvatar, 'otherAvatar'); updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideOtherAvatar, 'otherAvatar');
}); });
elGrabbable.addEventListener('change', createUserDataChanger("grabbableKey", "grabbable",
elGrabbable, properties.userData));
elWantsTrigger.addEventListener('change', createUserDataChanger("grabbableKey", "wantsTrigger",
elWantsTrigger, properties.userData));
elIgnoreIK.addEventListener('change', createUserDataChanger("grabbableKey", "ignoreIK",
elIgnoreIK, properties.userData));
elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL'));
@ -954,7 +979,7 @@
action: "previewCamera" action: "previewCamera"
})); }));
}); });
window.onblur = function() { window.onblur = function() {
// Fake a change event // Fake a change event
var ev = document.createEvent("HTMLEvents"); var ev = document.createEvent("HTMLEvents");
@ -1476,6 +1501,29 @@
</div> </div>
</div> </div>
<div class = "sub-section-header"> Grabbable: </div>
<div class = "sub-props-checkbox-group">
<div class="property">
<span class="label">grabbable</span>
<span class="value">
<input type='checkbox' id="property-grabbable">
</span>
</div>
<div class="property">
<span class="label">triggerable</span>
<span class="value">
<input type='checkbox' id="property-wants-trigger">
</span>
</div>
<div class="property">
<span class="label">ignore inverse-kinematics</span>
<span class="value">
<input type='checkbox' id="property-ignore-ik">
</span>
</div>
</div>
</div> </div>