48 lines
No EOL
1.5 KiB
JavaScript
48 lines
No EOL
1.5 KiB
JavaScript
//
|
|
// Sandbox/spawnOrangeCube.js
|
|
//
|
|
// Author: Liv Erickson
|
|
// Copyright High Fidelity 2018
|
|
//
|
|
// Licensed under the Apache 2.0 License
|
|
// See accompanying license file or http://apache.org/
|
|
//
|
|
(function(){
|
|
var LIFETIME = 30; // seconds
|
|
var _entityID;
|
|
//var SPAWN_POSITION = Entities.getEntityProperties(_entityID, "position").position;
|
|
var CHECK_INTERVAL = LIFETIME * 100;
|
|
|
|
var cubeProperties;
|
|
var spawnCubeInterval;
|
|
|
|
var OrangeCubeSpawner = function(){
|
|
|
|
};
|
|
|
|
OrangeCubeSpawner.prototype = {
|
|
preload: function(entityID) {
|
|
_entityID = entityID;
|
|
cubeProperties = {
|
|
type: "Box",
|
|
shape: "Cube",
|
|
collisionsWillMove: true,
|
|
color : {"red" : 255, "green" : 128, "blue" : 0},
|
|
dimensions : {x: 0.3092, y: 0.3092, z: 0.3092},
|
|
gravity : {x: 0, y: -4, z: 0},
|
|
lifetime: LIFETIME,
|
|
position: Entities.getEntityProperties(entityID, "position").position,
|
|
dynamic: true,
|
|
"userData" : "{\"grabbableKey\":{\"grabbable\":true}}"
|
|
};
|
|
spawnCubeInterval = Script.setInterval(function() {
|
|
Entities.addEntity(cubeProperties);
|
|
}, CHECK_INTERVAL);
|
|
},
|
|
unload: function() {
|
|
Script.clearInterval(spawnCubeInterval);
|
|
}
|
|
};
|
|
|
|
return new OrangeCubeSpawner();
|
|
}); |