History

move from examples/ to scripts/developer/

Andrew Meadows committed 10 years ago

Commit 0cc12fd1 parent 582b20273 files · +-2 −-2Browse files

Showing the changes to scripts/developer/tests/basicEntityTest (2 of 73 files). Show all

Unified · Split

2 files
  1. scripts/developer/tests/basicEntityTest/entitySpawner.js +31 −0
  2. scripts/developer/tests/basicEntityTest/myEntityScript.js +24 −0
scripts/developer/tests/basicEntityTest/entitySpawner.js+31−0
@@ -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);
scripts/developer/tests/basicEntityTest/myEntityScript.js+24−0
@@ -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+});

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t