diff --git a/examples/tests/basicEntityTest/entityScript.js b/examples/tests/basicEntityTest/entityScript.js new file mode 100644 index 0000000000..0c459e17a7 --- /dev/null +++ b/examples/tests/basicEntityTest/entityScript.js @@ -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(); +}); \ No newline at end of file diff --git a/examples/tests/basicEntityTest/entitySpawner.js b/examples/tests/basicEntityTest/entitySpawner.js new file mode 100644 index 0000000000..1875d770e3 --- /dev/null +++ b/examples/tests/basicEntityTest/entitySpawner.js @@ -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); \ No newline at end of file