diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index b7240d43f7..fd98dcea2f 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -47,6 +47,17 @@ ); }; } + + function createEmitCheckedToStringPropertyUpdateFunction(checkboxElement, name, propertyName) { + var newString = ""; + if (checkboxElement.checked) { + newString += name + ""; + } else { + + } + + } + function createEmitGroupCheckedPropertyUpdateFunction(group, propertyName) { return function () { var properties = {}; @@ -207,6 +218,28 @@ } }; + function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElement, subPropertyString) { + if (subPropertyElement.checked) { + if (propertyValue.indexOf(subPropertyString)) { + propertyValue += subPropertyString + ','; + } + } else { + // We've unchecked, so remove + propertyValue = propertyValue.replace(subPropertyString + ",", ""); + } + + var _properties ={} + _properties[propertyName] = propertyValue; + + EventBridge.emitWebEvent( + JSON.stringify({ + type: "update", + properties: _properties + }) + ); + + } + function loaded() { openEventBridge(function() { var allSections = []; @@ -263,6 +296,11 @@ var elDensity = document.getElementById("property-density"); var elCollisionless = document.getElementById("property-collisionless"); var elDynamic = document.getElementById("property-dynamic" ); + var elCollideStatic = document.getElementById("property-collide-static"); + var elCollideDynamic = document.getElementById("property-collide-dynamic"); + var elCollideKinematic = document.getElementById("property-collide-kinematic"); + var elCollideMyAvatar = document.getElementById("property-collide-myAvatar"); + var elCollideOtherAvatar = document.getElementById("property-collide-otherAvatar"); var elCollisionSoundURL = document.getElementById("property-collision-sound-url"); var elLifetime = document.getElementById("property-lifetime"); var elScriptURL = document.getElementById("property-script-url"); @@ -370,6 +408,7 @@ var elPreviewCameraButton = document.getElementById("preview-camera-button"); if (window.EventBridge !== undefined) { + var properties; EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); if (data.type == "update") { @@ -411,7 +450,7 @@ var selected = false; } - var properties = data.selections[0].properties; + properties = data.selections[0].properties; elID.innerHTML = properties.id; @@ -425,6 +464,7 @@ } else { enableChildren(document.getElementById("properties-list"), 'input'); } + elName.value = properties.name; @@ -473,6 +513,15 @@ elDensity.value = properties.density.toFixed(4); elCollisionless.checked = properties.collisionless; elDynamic.checked = properties.dynamic; + + + elCollideStatic.checked = properties.collidesWith.indexOf("static") > -1; + elCollideKinematic.checked = properties.collidesWith.indexOf("kinematic") > -1; + elCollideDynamic.checked = properties.collidesWith.indexOf("dynamic") > -1; + elCollideMyAvatar.checked = properties.collidesWith.indexOf("myAvatar") > -1; + elCollideOtherAvatar.checked = properties.collidesWith.indexOf("otherAvatar") > -1; + + elCollisionSoundURL.value = properties.collisionSoundURL; elLifetime.value = properties.lifetime; elScriptURL.value = properties.script; @@ -682,6 +731,29 @@ elDensity.addEventListener('change', createEmitNumberPropertyUpdateFunction('density')); elCollisionless.addEventListener('change', createEmitCheckedPropertyUpdateFunction('collisionless')); elDynamic.addEventListener('change', createEmitCheckedPropertyUpdateFunction('dynamic')); + + + + + elCollideDynamic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideDynamic, 'dynamic'); + }); + + elCollideKinematic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideKinematic, 'kinematic'); + }); + + elCollideStatic.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideStatic, 'static'); + }); + elCollideMyAvatar.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideMyAvatar, 'myAvatar'); + }); + elCollideOtherAvatar.addEventListener('change', function() { + updateCheckedSubProperty("collidesWith", properties.collidesWith, elCollideOtherAvatar, 'otherAvatar'); + }); + + elCollisionSoundURL.addEventListener('change', createEmitTextPropertyUpdateFunction('collisionSoundURL')); elLifetime.addEventListener('change', createEmitNumberPropertyUpdateFunction('lifetime')); @@ -1357,6 +1429,48 @@ + + + +
Collides With:
+
+
+ static + + + +
+ +
+ dynamic + + + +
+ +
+ kinematic + + + +
+ +
+ myAvatar + + + +
+ +
+ otherAvatar + + + +
+
+ +
@@ -1512,4 +1626,4 @@
- \ No newline at end of file + diff --git a/examples/html/style.css b/examples/html/style.css index 5b794cbfec..83982dab15 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -263,6 +263,10 @@ table#properties-list { border-bottom: 0.75pt solid #e5e5e5; } +.sub-props-checkbox-group { + margin-left: 20px; +} + #properties-list .label { font-weight: bold; overflow: hidden;