content/hifi-public/cozza13/scripts/example/entityModelExample.js
Dale Glass 0d14e5a379 Initial data.
Needs a lot of cleanup. Data has been de-duplicated, and where identical copies existed, one of them
has been replaced with a symlink.

Some files have been excluded, such as binaries, installers and debug dumps. Some of that may still
be present.
2022-02-13 18:59:11 +01:00

67 lines
1.6 KiB
JavaScript

//
// entityModelExample.js
// examples
//
// Created by Brad Hefta-Gaub on 1/28/14.
// Copyright 2014 High Fidelity, Inc.
//
// This is an example script that demonstrates creating and editing a entity
//
// 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/globals.js");
var count = 0;
var stopAfter = 100;
var modelPropertiesA = {
type: "Model",
position: { x: 1, y: 1, z: 1 },
velocity: { x: 0.5, y: 0, z: 0.5 },
damping: 0,
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
modelURL: HIFI_PUBLIC_BUCKET + "meshes/Feisar_Ship.FBX",
lifetime: 20
};
var modelPropertiesB = {
type: "Model",
position: { x: 1, y: 1.5, z: 1 },
velocity: { x: 0.5, y: 0, z: 0.5 },
damping: 0,
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
modelURL: HIFI_PUBLIC_BUCKET + "meshes/orc.fbx",
lifetime: 20
};
var ballProperties = {
type: "Sphere",
position: { x: 1, y: 0.5, z: 1 },
velocity: { x: 0.5, y: 0, z: 0.5 },
damping: 0,
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
color: { red: 255, green: 0, blue: 0 },
lifetime: 20
};
var modelAEntityID = Entities.addEntity(modelPropertiesA);
var modelBEntityID = Entities.addEntity(modelPropertiesB);
var ballEntityID = Entities.addEntity(ballProperties);
function endAfterAWhile(deltaTime) {
// stop it...
if (count >= stopAfter) {
print("calling Script.stop()");
Script.stop();
}
print("count =" + count);
count++;
}
// register the call back so it fires before each data send
Script.update.connect(endAfterAWhile);