mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 21:29:33 +02:00
spawner
This commit is contained in:
parent
51508b467c
commit
efd56ac22a
2 changed files with 54 additions and 0 deletions
23
examples/tests/basicEntityTest/entityScript.js
Normal file
23
examples/tests/basicEntityTest/entityScript.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var _this;
|
||||||
|
MyEntity = function() {
|
||||||
|
_this = this;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
MyEntity.prototype = {
|
||||||
|
|
||||||
|
|
||||||
|
preload: function(entityID) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
print("EBL PRELOAD ENTITY SCRIPT!!!")
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// entity scripts always need to return a newly constructed object of our type
|
||||||
|
return new MyEntity();
|
||||||
|
});
|
31
examples/tests/basicEntityTest/entitySpawner.js
Normal file
31
examples/tests/basicEntityTest/entitySpawner.js
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
var orientation = Camera.getOrientation();
|
||||||
|
orientation = Quat.safeEulerAngles(orientation);
|
||||||
|
orientation.x = 0;
|
||||||
|
orientation = Quat.fromVec3Degrees(orientation);
|
||||||
|
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
|
||||||
|
|
||||||
|
// Math.random ensures no caching of script
|
||||||
|
var SCRIPT_URL = Script.resolvePath("myEntityScript.js?v1" + Math.random())
|
||||||
|
|
||||||
|
var myEntity = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 10,
|
||||||
|
blue: 200
|
||||||
|
},
|
||||||
|
position: center,
|
||||||
|
dimensions: {
|
||||||
|
x: 1,
|
||||||
|
y: 1,
|
||||||
|
z: 1
|
||||||
|
},
|
||||||
|
script: SCRIPT_URL
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
// Entities.deleteEntity(myEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
Loading…
Reference in a new issue