add reset userdata to everything

This commit is contained in:
James B. Pollack 2016-03-17 22:19:20 -07:00
parent c072cd323e
commit 0f17d1f12e
22 changed files with 504 additions and 338 deletions

View file

@ -188,7 +188,12 @@
},
color: INTERSECT_COLOR,
position: position,
collisionless: true
collisionless: true,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
_this.debugSphere = Entities.addEntity(sphereProperties);
},
@ -640,7 +645,12 @@
red: 0,
green: 255,
blue: 255
},
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
})
);

View file

@ -11,6 +11,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
var TANK_SCRIPT = Script.resolvePath('tank.js?' + Math.random());
FishTank = function(spawnPosition, spawnRotation) {
@ -38,8 +40,6 @@ FishTank = function(spawnPosition, spawnRotation) {
var TANK_POSITION = spawnPosition;
var TANK_MODEL_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquariumTank.fbx";
var TANK_BASE_MODEL_URL = 'http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/aquariumBase.fbx';
@ -124,7 +124,12 @@ FishTank = function(spawnPosition, spawnRotation) {
color: DEBUG_COLOR,
collisionless: true,
script: TANK_SCRIPT,
visible: true
visible: true,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
if (spawnRotation !== undefined) {
@ -179,13 +184,20 @@ FishTank = function(spawnPosition, spawnRotation) {
"alphaStart": 0.3,
"alphaFinish": 0,
"emitterShouldTrail": 0,
"textures": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/bubble-white.png"
"textures": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/fishTank/bubble-white.png",
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
bubbleProperties.type = "ParticleEffect";
bubbleProperties.parentID = fishTank;
bubbleProperties.dimensions = BUBBLE_SYSTEM_DIMENSIONS;
var finalOffset = getOffsetFromTankCenter(BUBBLE_SYSTEM_VERTICAL_OFFSET, BUBBLE_SYSTEM_FORWARD_OFFSET, BUBBLE_SYSTEM_LATERAL_OFFSET);
bubbleProperties.position = finalOffset;
@ -246,7 +258,12 @@ FishTank = function(spawnPosition, spawnRotation) {
position: tankProperties.position,
visible: false,
collisionless: true,
dynamic: false
dynamic: false,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
innerContainer = Entities.addEntity(containerProps);
@ -271,7 +288,12 @@ FishTank = function(spawnPosition, spawnRotation) {
},
collisionless: true,
position: getOffsetFromTankCenter(LOWER_CORNER_VERTICAL_OFFSET, LOWER_CORNER_FORWARD_OFFSET, LOWER_CORNER_LATERAL_OFFSET),
visible: true
visible: true,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
var upperProps = {
@ -290,7 +312,12 @@ FishTank = function(spawnPosition, spawnRotation) {
},
collisionless: true,
position: getOffsetFromTankCenter(UPPER_CORNER_VERTICAL_OFFSET, UPPER_CORNER_FORWARD_OFFSET, UPPER_CORNER_LATERAL_OFFSET),
visible: true
visible: true,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
lowerCorner = Entities.addEntity(lowerProps);
@ -307,7 +334,12 @@ FishTank = function(spawnPosition, spawnRotation) {
parentID: fishTank,
modelURL: ROCK_MODEL_URL,
position: finalPosition,
dimensions: ROCK_DIMENSIONS
dimensions: ROCK_DIMENSIONS,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
rocks = Entities.addEntity(properties);
@ -323,7 +355,12 @@ FishTank = function(spawnPosition, spawnRotation) {
modelURL: URCHIN_MODEL_URL,
position: finalPosition,
shapeType: 'Sphere',
dimensions: URCHIN_DIMENSIONS
dimensions: URCHIN_DIMENSIONS,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
urchin = Entities.addEntity(properties);
@ -340,7 +377,12 @@ FishTank = function(spawnPosition, spawnRotation) {
modelURL: TREASURE_MODEL_URL,
position: finalPosition,
dimensions: TREASURE_DIMENSIONS,
rotation: Quat.fromPitchYawRollDegrees(10, -45, 10)
rotation: Quat.fromPitchYawRollDegrees(10, -45, 10),
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
treasure = Entities.addEntity(properties);
@ -359,7 +401,12 @@ FishTank = function(spawnPosition, spawnRotation) {
y: TANK_POSITION.y - BASE_VERTICAL_OFFSET,
z: TANK_POSITION.z
},
dimensions: TANK_BASE_DIMENSIONS
dimensions: TANK_BASE_DIMENSIONS,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
tankBase = Entities.addEntity(properties);

View file

@ -105,7 +105,11 @@
hslColor: Math.random() < 0.5 ? _this.flowerHSLColors[0] : _this.flowerHSLColors[1],
growthRate: growthRate
};
flower.userData = {
'hifiHomeKey': {
'reset': true
}
ProceduralEntity: {
shaderUrl: _this.SHADER_URL,
uniforms: {

View file

@ -15,6 +15,7 @@
Script.include('../utils.js');
var _this;
function WaterSpout() {
_this = this;
_this.waterSound = SoundCache.getSound("https://s3-us-west-1.amazonaws.com/hifi-content/eric/Sounds/shower.wav");
@ -187,6 +188,11 @@
alphaFinish: 1.0,
emitterShouldTrail: true,
textures: "https://s3-us-west-1.amazonaws.com/hifi-content/eric/images/raindrop.png",
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
},

View file

@ -32,7 +32,12 @@ Plant = function(spawnPosition, spawnRotation) {
modelURL: BOWL_MODEL_URL,
dimensions: bowlDimensions,
name: "plant bowl",
position: bowlPosition
position: bowlPosition,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
@ -55,7 +60,12 @@ Plant = function(spawnPosition, spawnRotation) {
dimensions: plantDimensions,
position: plantPosition,
script: PLANT_SCRIPT_URL,
parentID: bowl
parentID: bowl,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
@ -84,6 +94,9 @@ Plant = function(spawnPosition, spawnRotation) {
},
rotation: waterCanRotation,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
},
wearable: {
joints: {
RightHand: [{
@ -130,7 +143,12 @@ Plant = function(spawnPosition, spawnRotation) {
position: waterSpoutPosition,
rotation: waterSpoutRotation,
parentID: waterCan,
visible: false
visible: false,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
function cleanup() {

View file

@ -1,5 +1,6 @@
{
"Entities": [{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-15T21:26:11Z",
"dimensions": {
@ -30,6 +31,7 @@
},
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-07T21:07:29Z",
"dimensions": {
@ -61,6 +63,7 @@
"shapeType": "box",
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"created": "2016-03-15T21:26:11Z",
"dimensions": {
"x": 0.23445942997932434,
@ -91,6 +94,7 @@
"shapeType": "box",
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-07T21:07:29Z",
"dimensions": {
@ -122,6 +126,7 @@
"shapeType": "box",
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-07T21:07:29Z",
"dimensions": {
@ -152,6 +157,7 @@
"shapeType": "box",
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-07T21:07:29Z",
"dimensions": {
@ -183,6 +189,7 @@
"shapeType": "box",
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-15T21:26:11Z",
"dimensions": {
@ -212,6 +219,7 @@
},
"type": "Model"
}, {
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"collisionSoundURL": "http://hifi-content.s3.amazonaws.com/DomainContent/Home/Sounds/book_fall.L.wav",
"created": "2016-03-07T21:07:29Z",
"dimensions": {

View file

@ -1,5 +1,6 @@
{
"Entities": [{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/simple-chair2.obj",
"created": "2016-03-07T21:07:29Z",
"dimensions": {
@ -28,8 +29,7 @@
"z": 0.0002593994140625
},
"shapeType": "compound",
"type": "Model",
"userData": "{}"
"type": "Model"
}],
"Version": 57
}

View file

@ -1,6 +1,5 @@
{
"Entities": [
{
"Entities": [{
"collisionsWillMove": 1,
"compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Fruit-Bowl.obj",
"created": "2016-03-15T23:11:03Z",
@ -36,9 +35,8 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}, {
"collisionsWillMove": 1,
"created": "2016-03-15T21:26:11Z",
"dimensions": {
@ -75,9 +73,8 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
} {
"collisionsWillMove": 1,
"created": "2016-03-15T21:26:11Z",
"dimensions": {
@ -114,9 +111,8 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"grabbableKey\":{\"grabbable\":true}}"
}, {
"collisionsWillMove": 1,
"created": "2016-03-16T00:27:30Z",
"dimensions": {
@ -153,9 +149,8 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}, {
"collisionsWillMove": 1,
"created": "2016-03-16T00:27:30Z",
"dimensions": {
@ -192,9 +187,9 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"grabbableKey\":{\"grabbable\":true}}"
}, {
"collisionsWillMove": 1,
"created": "2016-03-16T00:27:30Z",
"dimensions": {
@ -231,9 +226,8 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{}"
},
{
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"grabbableKey\":{\"grabbable\":true}}"
}, {
"collisionsWillMove": 1,
"created": "2016-03-16T00:27:30Z",
"dimensions": {
@ -270,8 +264,7 @@
},
"shapeType": "sphere",
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":true}}"
}
],
"userData": "{\"hifiHomeKey\":{\"reset\":true},\"grabbableKey\":{\"grabbable\":true}}"
}],
"Version": 57
}

View file

@ -1,5 +1,6 @@
{
"Entities": [{
"userData": "{\"hifiHomeKey\":{\"reset\":true}}",
"compoundShapeURL": "http://hifi-content.s3.amazonaws.com/alan/dev/Little-Lamp.obj",
"created": "2016-03-16T01:00:16Z",
"dimensions": {
@ -29,7 +30,6 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":true,\"wantsTrigger\":true}}"
}],
"Version": 57
}

View file

@ -29,7 +29,7 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}],
"Version": 57
}

View file

@ -29,7 +29,7 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{\"grabbableKey\":{\"grabbable\":true,\"wantsTrigger\":true}}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}],
"Version": 57
}

View file

@ -26,7 +26,7 @@
"z": -0.88293278217315674
},
"type": "Box",
"userData": "{}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}],
"Version": 57
}

View file

@ -29,7 +29,7 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}],
"Version": 57
}

View file

@ -31,7 +31,7 @@
},
"shapeType": "compound",
"type": "Model",
"userData": "{}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}
],
"Version": 57

View file

@ -26,7 +26,7 @@
"z": -0.88293278217315674
},
"type": "Box",
"userData": "{}"
"userData": "{\"hifiHomeKey\":{\"reset\":true}}"
}],
"Version": 57
}

View file

@ -109,7 +109,12 @@
rotation: gunProperties.rotation,
position: this.getGunTipPosition(gunProperties),
velocity: forwardVec,
lifetime: 10
lifetime: 10,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
Entities.addEntity(properties);

View file

@ -35,6 +35,9 @@ _PingPongGun = function(spawnPosition, spawnRotation) {
grabbableKey: {
invertSolidWhileHeld: true
},
'hifiHomeKey': {
'reset': true
},
wearable: {
joints: {
RightHand: [{

View file

@ -79,8 +79,10 @@
_this.tidying = true;
_this.showTidyingButton();
_this.playTidyingSound();
_this.cleanupDynamicEntities();
_this.cleanupKineticEntities();
_this.findAndDeleteHomeEntities();
// _this.cleanupDynamicEntities();
// _this.cleanupKineticEntities();
Script.setTimeout(function() {
_this.showTidyButton();
_this.tidying = false;
@ -158,22 +160,19 @@
z: 89.9698
});
dynamicEntities.push(fishTank);
dynamicEntities.push(tiltMaze);
dynamicEntities.push(whiteboard);
dynamicEntities.push(pingPongGun);
dynamicEntities.push(myPlant);
//v2.0
print('DYNAMIC ENTITIES AFTER CREATE:::' + dynamicEntities.length)
// var musicBox = new MusicBox();
// var cuckooClock = new CuckooClock();
// var doppelganger = new Doppelganger();
// dynamicEntities.push(fishTank);
// dynamicEntities.push(tiltMaze);
// dynamicEntities.push(whiteboard);
// dynamicEntities.push(pingPongGun);
// dynamicEntities.push(myPlant);
// print('DYNAMIC ENTITIES AFTER CREATE:::' + dynamicEntities.length)
},
@ -245,15 +244,15 @@
z: -80.4890
});
kineticEntities.push(fruitBowl);
kineticEntities.push(livingRoomLamp);
kineticEntities.push(upperBookShelf);
kineticEntities.push(lowerBookShelf);
kineticEntities.push(rightDeskDrawer);
kineticEntities.push(leftDeskDrawer);
kineticEntities.push(chair);
kineticEntities.push(trashcan);
kineticEntities.push(books);
// kineticEntities.push(fruitBowl);
// kineticEntities.push(livingRoomLamp);
// kineticEntities.push(upperBookShelf);
// kineticEntities.push(lowerBookShelf);
// kineticEntities.push(rightDeskDrawer);
// kineticEntities.push(leftDeskDrawer);
// kineticEntities.push(chair);
// kineticEntities.push(trashcan);
// kineticEntities.push(books);
},
cleanupKineticEntities: function() {
@ -265,9 +264,29 @@
kineticEntity.cleanup();
})
},
findAndDeleteHomeEntities: function() {
var results = Entities.findEntities(_this.position, 1000);
var found = [];
results.forEach(function(result) {
var properties = Entities.getEntityProperties(result);
var userData = null;
try {
userData = JSON.parse(properties.userData);
} catch (err) {
// print('error parsing json');
// print('properties are:' + properties.userData);
return;
}
if (userData.hifiHomeKey.reset === true) {
Entities.deleteEntity(result);
}
})
},
unload: function() {
this.cleanupDynamicEntities();
this.cleanupKineticEntities();
this.findAndDeleteHomeEntities();
// this.cleanupDynamicEntities();
// this.cleanupKineticEntities();
}
}

View file

@ -113,7 +113,12 @@
gravity: BALL_GRAVITY,
density: BALL_DENSITY,
color: BALL_COLOR,
dimensions: BALL_DIMENSIONS
dimensions: BALL_DIMENSIONS,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
this.ball = Entities.addEntity(properties);

View file

@ -154,6 +154,9 @@ TiltMaze = function(spawnPosition, spawnRotation) {
color: BALL_COLOR,
dimensions: BALL_DIMENSIONS,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
},
grabbableKey: {
grabbable: false
}
@ -175,6 +178,11 @@ TiltMaze = function(spawnPosition, spawnRotation) {
position: getBallStartLocation(),
collisionless: true,
visible: false,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
ballSpawningAnchor = Entities.addEntity(properties);
@ -194,6 +202,12 @@ TiltMaze = function(spawnPosition, spawnRotation) {
collisionless: true,
dynamic: false,
visible: false,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
ballDetector = Entities.addEntity(properties);
@ -214,7 +228,12 @@ TiltMaze = function(spawnPosition, spawnRotation) {
angularDamping: MAZE_ANGULAR_DAMPING,
dynamic: true,
density: MAZE_DENSITY,
script: MAZE_SCRIPT
script: MAZE_SCRIPT,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
if (spawnRotation !== undefined) {
@ -246,7 +265,12 @@ TiltMaze = function(spawnPosition, spawnRotation) {
cutoff: END_LIGHT_CUTOFF,
lifetime: -1,
position: position,
rotation: emitOrientation
rotation: emitOrientation,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
};
lightAtTheEnd = Entities.addEntity(lightProperties);
@ -260,6 +284,9 @@ TiltMaze = function(spawnPosition, spawnRotation) {
createLightAtTheEnd();
Entities.editEntity(tiltMaze, {
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
},
tiltMaze: {
firstBall: ball,
ballSpawner: ballSpawningAnchor,

View file

@ -142,6 +142,11 @@
textures: _this.MARKER_TEXTURE_URL,
color: _this.markerColor,
lifetime: 5000,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
_this.linePoints = [];

View file

@ -36,6 +36,11 @@ Whiteboard = function(spawnPosition, spawnRotation) {
y: 2.7,
z: 0.4636
},
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
});
@ -64,7 +69,12 @@ Whiteboard = function(spawnPosition, spawnRotation) {
position: whiteboardFrontSurfacePosition,
rotation: whiteboardRotation,
visible: false,
parentID: whiteboard
parentID: whiteboard,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
}
}),
}
var whiteboardFrontDrawingSurface = Entities.addEntity(whiteboardSurfaceSettings);
@ -107,6 +117,9 @@ Whiteboard = function(spawnPosition, spawnRotation) {
z: 0
},
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
},
originalPosition: eraserPosition,
originalRotation: eraserRotation,
wearable: {
@ -196,6 +209,9 @@ Whiteboard = function(spawnPosition, spawnRotation) {
name: "marker",
script: MARKER_SCRIPT_URL,
userData: JSON.stringify({
'hifiHomeKey': {
'reset': true
},
originalPosition: markerPosition,
originalRotation: markerRotation,
markerColor: markerColor,