mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
arc ball finds other balls
This commit is contained in:
parent
92f96cbb2f
commit
035ca25b48
4 changed files with 206 additions and 7 deletions
149
examples/flowArts/arcBall/arcBall.js
Normal file
149
examples/flowArts/arcBall/arcBall.js
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
//
|
||||||
|
// arcBall.js
|
||||||
|
// examples/arcBall
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 12/17/15.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This script creats a particle light ball which makes particle trails as you move it.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
|
|
||||||
|
var scriptURL = Script.resolvePath("arcBallEntityScript.js");
|
||||||
|
ArcBall = function(spawnPosition) {
|
||||||
|
|
||||||
|
var colorPalette = [{
|
||||||
|
red: 25,
|
||||||
|
green: 20,
|
||||||
|
blue: 162
|
||||||
|
}];
|
||||||
|
|
||||||
|
|
||||||
|
var containerBall = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
name: "Arc Ball",
|
||||||
|
script: scriptURL,
|
||||||
|
position: Vec3.sum(spawnPosition, {
|
||||||
|
x: 0,
|
||||||
|
y: .5,
|
||||||
|
z: 0
|
||||||
|
}),
|
||||||
|
dimensions: {
|
||||||
|
x: .1,
|
||||||
|
y: .1,
|
||||||
|
z: .1
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 15,
|
||||||
|
green: 10,
|
||||||
|
blue: 150
|
||||||
|
},
|
||||||
|
mass: 10,
|
||||||
|
collisionsWillMove: true,
|
||||||
|
// gravity: {
|
||||||
|
// x: 0,
|
||||||
|
// y: -0.5,
|
||||||
|
// z: 0
|
||||||
|
// },
|
||||||
|
userData: JSON.stringify({
|
||||||
|
grabbableKey: {
|
||||||
|
spatialKey: {
|
||||||
|
relativePosition: {
|
||||||
|
x: 0,
|
||||||
|
y: .1,
|
||||||
|
z: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
invertSolidWhileHeld: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var light = Entities.addEntity({
|
||||||
|
type: 'Light',
|
||||||
|
name: "ballLight",
|
||||||
|
parentID: containerBall,
|
||||||
|
dimensions: {
|
||||||
|
x: 30,
|
||||||
|
y: 30,
|
||||||
|
z: 30
|
||||||
|
},
|
||||||
|
color: colorPalette[randInt(0, colorPalette.length)],
|
||||||
|
intensity: 5
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var arcBall = Entities.addEntity({
|
||||||
|
type: "ParticleEffect",
|
||||||
|
parentID: containerBall,
|
||||||
|
isEmitting: true,
|
||||||
|
name: "Arc Ball Particle Effect",
|
||||||
|
colorStart: {
|
||||||
|
red: 200,
|
||||||
|
green: 20,
|
||||||
|
blue: 40
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 200,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
colorFinish: {
|
||||||
|
red: 25,
|
||||||
|
green: 20,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
maxParticles: 100000,
|
||||||
|
lifespan: 2,
|
||||||
|
emitRate: 10000,
|
||||||
|
emitSpeed: .1,
|
||||||
|
lifetime: -1,
|
||||||
|
speedSpread: 0.0,
|
||||||
|
emitDimensions: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
polarStart: 0,
|
||||||
|
polarFinish: Math.PI,
|
||||||
|
azimuthStart: -Math.PI,
|
||||||
|
azimuthFinish: Math.PI,
|
||||||
|
emitAcceleration: {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
z: 0
|
||||||
|
},
|
||||||
|
accelerationSpread: {
|
||||||
|
x: .00,
|
||||||
|
y: .00,
|
||||||
|
z: .00
|
||||||
|
},
|
||||||
|
particleRadius: 0.02,
|
||||||
|
radiusSpread: 0,
|
||||||
|
radiusStart: 0.03,
|
||||||
|
radiusFinish: 0.0003,
|
||||||
|
alpha: 0,
|
||||||
|
alphaSpread: .5,
|
||||||
|
alphaStart: 0,
|
||||||
|
alphaFinish: 0.5,
|
||||||
|
textures: "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
||||||
|
emitterShouldTrail: true
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
Entities.deleteEntity(arcBall);
|
||||||
|
Entities.deleteEntity(containerBall);
|
||||||
|
Entities.deleteEntity(light);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.cleanup = cleanup;
|
||||||
|
}
|
45
examples/flowArts/arcBall/arcBallEntityScript.js
Normal file
45
examples/flowArts/arcBall/arcBallEntityScript.js
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
// arcBallEntityScript.js
|
||||||
|
//
|
||||||
|
// Script Type: Entity
|
||||||
|
// Created by Eric Levin on 12/17/15.
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This entity script handles the logic for the arcBall rave toy
|
||||||
|
// 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("../../libraries/utils.js");
|
||||||
|
var _this;
|
||||||
|
var ArcBall = function() {
|
||||||
|
_this = this;
|
||||||
|
};
|
||||||
|
|
||||||
|
ArcBall.prototype = {
|
||||||
|
isGrabbed: false,
|
||||||
|
startNearGrab: function() {
|
||||||
|
//Search for nearby balls and create an arc to it if one is found
|
||||||
|
var position = Entities.getEntityProperties(this.entityID, "position").position
|
||||||
|
var entities = Entities.findEntities(position, 10);
|
||||||
|
entities.forEach(function(entity) {
|
||||||
|
var props = Entities.getEntityProperties(entity, ["position", "name"]);
|
||||||
|
if (props.name === "Arc Ball" && JSON.stringify(_this.entityID) !== JSON.stringify(entity)) {
|
||||||
|
print ("WE FOUND ANOTHER ARC BALL");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
continueNearGrab: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
releaseGrab: function() {
|
||||||
|
},
|
||||||
|
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return new ArcBall();
|
||||||
|
});
|
|
@ -17,6 +17,7 @@ Script.include("../../libraries/utils.js");
|
||||||
Script.include("lightBall/LightBall.js");
|
Script.include("lightBall/LightBall.js");
|
||||||
Script.include("raveStick/RaveStick.js");
|
Script.include("raveStick/RaveStick.js");
|
||||||
Script.include("lightSaber/LightSaber.js");
|
Script.include("lightSaber/LightSaber.js");
|
||||||
|
Script.include("arcBall/ArcBall.js");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,7 +25,10 @@ var basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Ca
|
||||||
basePosition.y = MyAvatar.position.y + 1;
|
basePosition.y = MyAvatar.position.y + 1;
|
||||||
|
|
||||||
// RAVE ITEMS
|
// RAVE ITEMS
|
||||||
var lightBall = new LightBall(basePosition);
|
//var lightBall = new LightBall(basePosition);
|
||||||
|
|
||||||
|
var arcBall = new ArcBall(basePosition);
|
||||||
|
var arcBall2 = new ArcBall(Vec3.sum(basePosition, {x: -1, y: 0, z: 0}));
|
||||||
var raveStick = new RaveStick(Vec3.sum(basePosition, {x: 1, y: 0.5, z: 1}));
|
var raveStick = new RaveStick(Vec3.sum(basePosition, {x: 1, y: 0.5, z: 1}));
|
||||||
var lightSaber = new LightSaber(Vec3.sum(basePosition, {x: 3, y: 0.5, z: 1}));
|
var lightSaber = new LightSaber(Vec3.sum(basePosition, {x: 3, y: 0.5, z: 1}));
|
||||||
|
|
||||||
|
@ -77,7 +81,8 @@ function cleanup() {
|
||||||
Entities.deleteEntity(raveRoom);
|
Entities.deleteEntity(raveRoom);
|
||||||
Entities.deleteEntity(lightZone)
|
Entities.deleteEntity(lightZone)
|
||||||
Entities.deleteEntity(floor);
|
Entities.deleteEntity(floor);
|
||||||
lightBall.cleanup();
|
arcBall.cleanup();
|
||||||
|
arcBall2.cleanup();
|
||||||
raveStick.cleanup();
|
raveStick.cleanup();
|
||||||
lightSaber.cleanup();
|
lightSaber.cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,11 @@ LightBall = function(spawnPosition) {
|
||||||
blue: 150
|
blue: 150
|
||||||
},
|
},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
gravity: {
|
// gravity: {
|
||||||
x: 0,
|
// x: 0,
|
||||||
y: -0.5,
|
// y: -0.5,
|
||||||
z: 0
|
// z: 0
|
||||||
},
|
// },
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
spatialKey: {
|
spatialKey: {
|
||||||
|
|
Loading…
Reference in a new issue