mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 10:07:58 +02:00
more Particles to Entities migration
This commit is contained in:
parent
0ff6c491d4
commit
a1ecad683a
1 changed files with 13 additions and 14 deletions
|
@ -1,12 +1,10 @@
|
||||||
//
|
//
|
||||||
// rideAlongWithAParticleExample.js
|
// rideAlongWithAEntityExample.js
|
||||||
// examples
|
// examples
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 1/24/14.
|
// Created by Brad Hefta-Gaub on 1/24/14.
|
||||||
// Copyright 2014 High Fidelity, Inc.
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
//
|
//
|
||||||
// This is an example script that demonstrates "finding" particles
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
@ -14,31 +12,32 @@
|
||||||
var iteration = 0;
|
var iteration = 0;
|
||||||
var lengthOfRide = 2000; // in iterations
|
var lengthOfRide = 2000; // in iterations
|
||||||
|
|
||||||
var particleA = Particles.addParticle(
|
var entityA = Entities.addEntity(
|
||||||
{
|
{
|
||||||
|
type: "Sphere",
|
||||||
position: { x: 10, y: 0, z: 10 },
|
position: { x: 10, y: 0, z: 10 },
|
||||||
velocity: { x: 5, y: 0, z: 5 },
|
velocity: { x: 5, y: 0, z: 5 },
|
||||||
gravity: { x: 0, y: 0, z: 0 },
|
gravity: { x: 0, y: 0, z: 0 },
|
||||||
radius : 0.1,
|
dimensions: { x: 1, y: 1, z: 1 },
|
||||||
color: { red: 0, green: 255, blue: 0 },
|
color: { red: 0, green: 255, blue: 0 },
|
||||||
damping: 0,
|
damping: 0,
|
||||||
lifetime: (lengthOfRide * 60) + 1
|
lifetime: (lengthOfRide * 60) + 1
|
||||||
});
|
});
|
||||||
|
|
||||||
function rideWithParticle(deltaTime) {
|
function rideWithEntity(deltaTime) {
|
||||||
|
|
||||||
if (iteration <= lengthOfRide) {
|
if (iteration <= lengthOfRide) {
|
||||||
|
|
||||||
// Check to see if we've been notified of the actual identity of the particles we created
|
// Check to see if we've been notified of the actual identity of the entities we created
|
||||||
if (!particleA.isKnownID) {
|
if (!entityA.isKnownID) {
|
||||||
particleA = Particles.identifyParticle(particleA);
|
entityA = Entities.identifyEntity(entityA);
|
||||||
}
|
}
|
||||||
|
|
||||||
var propertiesA = Particles.getParticleProperties(particleA);
|
var propertiesA = Entities.getEntityProperties(entityA);
|
||||||
var newPosition = propertiesA.position;
|
var newPosition = propertiesA.position;
|
||||||
MyAvatar.position = { x: propertiesA.position.x,
|
MyAvatar.position = { x: propertiesA.position.x - 1,
|
||||||
y: propertiesA.position.y + 2,
|
y: propertiesA.position.y + 0,
|
||||||
z: propertiesA.position.z };
|
z: propertiesA.position.z - 1 };
|
||||||
} else {
|
} else {
|
||||||
Script.stop();
|
Script.stop();
|
||||||
}
|
}
|
||||||
|
@ -49,5 +48,5 @@ function rideWithParticle(deltaTime) {
|
||||||
|
|
||||||
|
|
||||||
// register the call back so it fires before each data send
|
// register the call back so it fires before each data send
|
||||||
Script.update.connect(rideWithParticle);
|
Script.update.connect(rideWithEntity);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue