mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:09:24 +02:00
Remove nested bubble entities and related code
This commit is contained in:
parent
ccf125c047
commit
c2a2abe615
3 changed files with 12 additions and 142 deletions
|
@ -1,112 +0,0 @@
|
||||||
// bubble.js
|
|
||||||
// part of bubblewand
|
|
||||||
//
|
|
||||||
// Script Type: Entity
|
|
||||||
// Created by James B. Pollack @imgntn -- 09/03/2015
|
|
||||||
// Copyright 2015 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// example of a nested entity. plays a particle burst at the location where its deleted.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
Script.include("../../utilities.js");
|
|
||||||
Script.include("../../libraries/utils.js");
|
|
||||||
|
|
||||||
var BUBBLE_PARTICLE_TEXTURE = "http://hifi-public.s3.amazonaws.com/james/bubblewand/textures/bubble_particle.png"
|
|
||||||
|
|
||||||
var BUBBLE_USER_DATA_KEY = "BubbleKey";
|
|
||||||
|
|
||||||
var _this = this;
|
|
||||||
|
|
||||||
var properties;
|
|
||||||
|
|
||||||
this.preload = function(entityID) {
|
|
||||||
_this.entityID = entityID;
|
|
||||||
Script.update.connect(_this.update);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.update = function() {
|
|
||||||
// we want the position at unload but for some reason it keeps getting set to 0,0,0 -- so i just exclude that location. sorry origin bubbles.
|
|
||||||
var tmpProperties = Entities.getEntityProperties(_this.entityID);
|
|
||||||
if (tmpProperties.position.x !== 0 && tmpProperties.position.y !== 0 && tmpProperties.position.z !== 0) {
|
|
||||||
properties = tmpProperties;
|
|
||||||
}
|
|
||||||
|
|
||||||
//we want to play the particle burst exactly once, so we make sure that this is a bubble we own.
|
|
||||||
var entityData = getEntityCustomData(BUBBLE_USER_DATA_KEY, _this.entityID);
|
|
||||||
|
|
||||||
if (entityData && entityData.avatarID && entityData.avatarID === MyAvatar.sessionUUID) {
|
|
||||||
_this.bubbleCreator = true
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
this.unload = function(entityID) {
|
|
||||||
Script.update.disconnect(this.update);
|
|
||||||
|
|
||||||
//only play particle burst for our bubbles
|
|
||||||
if (this.bubbleCreator) {
|
|
||||||
this.createBurstParticles();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
this.createBurstParticles = function() {
|
|
||||||
//get the current position and dimensions of the bubble
|
|
||||||
var position = properties.position;
|
|
||||||
var dimensions = properties.dimensions;
|
|
||||||
|
|
||||||
|
|
||||||
var animationSettings = JSON.stringify({
|
|
||||||
fps: 30,
|
|
||||||
frameIndex: 0,
|
|
||||||
running: true,
|
|
||||||
firstFrame: 0,
|
|
||||||
lastFrame: 30,
|
|
||||||
loop: false
|
|
||||||
});
|
|
||||||
|
|
||||||
var particleBurst = Entities.addEntity({
|
|
||||||
type: "ParticleEffect",
|
|
||||||
animationSettings: animationSettings,
|
|
||||||
emitRate: 100,
|
|
||||||
animationIsPlaying: true,
|
|
||||||
position: position,
|
|
||||||
lifespan: 0.2,
|
|
||||||
dimensions: {
|
|
||||||
x: 1,
|
|
||||||
y: 1,
|
|
||||||
z: 1
|
|
||||||
},
|
|
||||||
emitVelocity: {
|
|
||||||
x: 1,
|
|
||||||
y: 1,
|
|
||||||
z: 1
|
|
||||||
},
|
|
||||||
velocitySpread: {
|
|
||||||
x: 1,
|
|
||||||
y: 1,
|
|
||||||
z: 1
|
|
||||||
},
|
|
||||||
emitAcceleration: {
|
|
||||||
x: 0.25,
|
|
||||||
y: 0.25,
|
|
||||||
z: 0.25
|
|
||||||
},
|
|
||||||
radiusSpread: 0.01,
|
|
||||||
particleRadius: 0.02,
|
|
||||||
alphaStart: 1.0,
|
|
||||||
alpha: 0.5,
|
|
||||||
alphaFinish: 0,
|
|
||||||
textures: BUBBLE_PARTICLE_TEXTURE,
|
|
||||||
visible: true,
|
|
||||||
locked: false
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
});
|
|
|
@ -11,31 +11,28 @@
|
||||||
|
|
||||||
var IN_TOYBOX = false;
|
var IN_TOYBOX = false;
|
||||||
|
|
||||||
Script.include("../../utilities.js");
|
Script.include("../../utilities.js");
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
|
|
||||||
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx';
|
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx';
|
||||||
var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj';
|
var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/collisionHull.obj';
|
||||||
var WAND_SCRIPT_URL = Script.resolvePath("wand.js");
|
var WAND_SCRIPT_URL = Script.resolvePath("wand.js");
|
||||||
//create the wand in front of the avatar blahy
|
|
||||||
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {x: 0, y: 0.5, z: 0}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
|
|
||||||
|
|
||||||
var tablePosition = {
|
//create the wand in front of the avatar
|
||||||
x:546.48,
|
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
||||||
y:495.63,
|
x: 0,
|
||||||
z:506.25
|
y: 0.5,
|
||||||
}
|
z: 0
|
||||||
|
}), Vec3.multiply(0.5, Quat.getFront(Camera.getOrientation())));
|
||||||
|
|
||||||
var wand = Entities.addEntity({
|
var wand = Entities.addEntity({
|
||||||
name:'Bubble Wand',
|
name: 'Bubble Wand',
|
||||||
type: "Model",
|
type: "Model",
|
||||||
modelURL: WAND_MODEL,
|
modelURL: WAND_MODEL,
|
||||||
position: IN_TOYBOX? tablePosition: center,
|
position: center,
|
||||||
gravity: {
|
gravity: {
|
||||||
x: 0,
|
x: 0,
|
||||||
y:0,
|
y: -9.8,
|
||||||
// y: -9.8,
|
|
||||||
z: 0,
|
z: 0,
|
||||||
},
|
},
|
||||||
dimensions: {
|
dimensions: {
|
||||||
|
|
|
@ -17,9 +17,7 @@
|
||||||
Script.include("../../libraries/utils.js");
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx";
|
var BUBBLE_MODEL = "http://hifi-public.s3.amazonaws.com/james/bubblewand/models/bubble/bubble.fbx";
|
||||||
var BUBBLE_SCRIPT = Script.resolvePath('bubble.js');
|
|
||||||
|
|
||||||
var BUBBLE_USER_DATA_KEY = "BubbleKey";
|
|
||||||
var BUBBLE_INITIAL_DIMENSIONS = {
|
var BUBBLE_INITIAL_DIMENSIONS = {
|
||||||
x: 0.01,
|
x: 0.01,
|
||||||
y: 0.01,
|
y: 0.01,
|
||||||
|
@ -47,7 +45,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
BubbleWand.prototype = {
|
BubbleWand.prototype = {
|
||||||
bubbles: [],
|
|
||||||
currentBubble: null,
|
currentBubble: null,
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
this.entityID = entityID;
|
this.entityID = entityID;
|
||||||
|
@ -129,11 +126,9 @@
|
||||||
var wandPosition = properties.position;
|
var wandPosition = properties.position;
|
||||||
var wandTipPosition = this.getWandTipPosition(properties)
|
var wandTipPosition = this.getWandTipPosition(properties)
|
||||||
|
|
||||||
|
|
||||||
var distance = Vec3.subtract(wandPosition, this.lastPosition);
|
var distance = Vec3.subtract(wandPosition, this.lastPosition);
|
||||||
var velocity = Vec3.multiply(distance, 1 / deltaTime);
|
var velocity = Vec3.multiply(distance, 1 / deltaTime);
|
||||||
|
|
||||||
|
|
||||||
var velocityStrength = Vec3.length(velocity);
|
var velocityStrength = Vec3.length(velocity);
|
||||||
velocityStrength = velocityStrength;
|
velocityStrength = velocityStrength;
|
||||||
|
|
||||||
|
@ -163,9 +158,6 @@
|
||||||
//wait to make the bubbles collidable, so that they dont hit each other and the wand
|
//wait to make the bubbles collidable, so that they dont hit each other and the wand
|
||||||
Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2);
|
Script.setTimeout(this.addCollisionsToBubbleAfterCreation(this.currentBubble), lifetime / 2);
|
||||||
|
|
||||||
//we want to pop the bubble for just one person
|
|
||||||
this.setBubbleOwner(this.currentBubble);
|
|
||||||
|
|
||||||
//release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble
|
//release the bubble -- when we create a new bubble, it will carry on and this update loop will affect the new bubble
|
||||||
this.createBubbleAtTipOfWand();
|
this.createBubbleAtTipOfWand();
|
||||||
return
|
return
|
||||||
|
@ -192,11 +184,6 @@
|
||||||
dimensions: dimensions
|
dimensions: dimensions
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
setBubbleOwner: function(bubble) {
|
|
||||||
setEntityCustomData(BUBBLE_USER_DATA_KEY, bubble, {
|
|
||||||
avatarID: MyAvatar.sessionUUID,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
createBubbleAtTipOfWand: function() {
|
createBubbleAtTipOfWand: function() {
|
||||||
|
|
||||||
//create a new bubble at the tip of the wand
|
//create a new bubble at the tip of the wand
|
||||||
|
@ -219,11 +206,9 @@
|
||||||
collisionsWillMove: false,
|
collisionsWillMove: false,
|
||||||
ignoreForCollisions: false,
|
ignoreForCollisions: false,
|
||||||
linearDamping: BUBBLE_LINEAR_DAMPING,
|
linearDamping: BUBBLE_LINEAR_DAMPING,
|
||||||
shapeType: "sphere",
|
shapeType: "sphere"
|
||||||
script: BUBBLE_SCRIPT,
|
|
||||||
});
|
});
|
||||||
//add this bubble to an array of bubbles so we can keep track of them
|
|
||||||
this.bubbles.push(this.currentBubble)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue