Showing the changes to scripts/developer/tests/basicEntityTest (2 of 73 files). Show all
Unified · Split
| @@ -0,0 +1,31 @@ | |||
| 1 | var orientation = Camera.getOrientation(); | ||
| 2 | orientation = Quat.safeEulerAngles(orientation); | ||
| 3 | orientation.x = 0; | ||
| 4 | orientation = Quat.fromVec3Degrees(orientation); | ||
| 5 | var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation))); | ||
| 6 | |||
| 7 | // Math.random ensures no caching of script | ||
| 8 | var SCRIPT_URL = Script.resolvePath("myEntityScript.js") | ||
| 9 | |||
| 10 | var myEntity = Entities.addEntity({ | ||
| 11 | type: "Sphere", | ||
| 12 | color: { | ||
| 13 | red: 200, | ||
| 14 | green: 10, | ||
| 15 | blue: 200 | ||
| 16 | }, | ||
| 17 | position: center, | ||
| 18 | dimensions: { | ||
| 19 | x: 1, | ||
| 20 | y: 1, | ||
| 21 | z: 1 | ||
| 22 | }, | ||
| 23 | script: SCRIPT_URL | ||
| 24 | }) | ||
| 25 | |||
| 26 | |||
| 27 | function cleanup() { | ||
| 28 | // Entities.deleteEntity(myEntity); | ||
| 29 | } | ||
| 30 | |||
| 31 | Script.scriptEnding.connect(cleanup); | ||
| @@ -0,0 +1,24 @@ | |||
| 1 | |||
| 2 | (function() { | ||
| 3 | var _this; | ||
| 4 | MyEntity = function() { | ||
| 5 | _this = this; | ||
| 6 | |||
| 7 | }; | ||
| 8 | |||
| 9 | MyEntity.prototype = { | ||
| 10 | |||
| 11 | |||
| 12 | preload: function(entityID) { | ||
| 13 | this.entityID = entityID; | ||
| 14 | var randNum = Math.random().toFixed(3); | ||
| 15 | print("EBL PRELOAD ENTITY SCRIPT!!!", randNum) | ||
| 16 | |||
| 17 | }, | ||
| 18 | |||
| 19 | |||
| 20 | }; | ||
| 21 | |||
| 22 | // entity scripts always need to return a newly constructed object of our type | ||
| 23 | return new MyEntity(); | ||
| 24 | }); | ||