Browse Source

JSComponentFields example

Josh Engebretson 10 years ago
parent
commit
bbf5525577

+ 9 - 0
JSComponentFields/JSComponentFields.atomic

@@ -0,0 +1,9 @@
+{
+   "version": 1,
+   "project": {
+      "version": "1.0.0"
+   },
+   "platforms": [
+      "mac", "windows"
+   ]
+}

+ 6 - 0
JSComponentFields/Resources/Components.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "7f36439132474379a380efcdaa72fce1",
+	"timestamp": 1436725403,
+	"FolderImporter": {}
+}

+ 20 - 0
JSComponentFields/Resources/Components/Spinner.js

@@ -0,0 +1,20 @@
+
+exports.fields = {
+  speed: 1.0
+}
+
+exports.component = function(self) {
+
+  var node = self.node;
+
+  self.start = function() {
+
+  }
+
+  self.update = function(timeStep) {
+
+    node.yaw(timeStep * 75 * self.speed);
+
+  }
+
+}

+ 8 - 0
JSComponentFields/Resources/Components/Spinner.js.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "06495d0f70cbdebc91113550acbfda49",
+	"timestamp": 1436726427,
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 6 - 0
JSComponentFields/Resources/Models.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "2455f05ca34213df84302fd34086600a",
+	"timestamp": 1436725636,
+	"FolderImporter": {}
+}

BIN
JSComponentFields/Resources/Models/Chest.fbx


+ 10 - 0
JSComponentFields/Resources/Models/Chest.fbx.asset

@@ -0,0 +1,10 @@
+{
+	"version": 1,
+	"guid": "8646c0f492bf9bd8b34d8c27e67b7d3c",
+	"timestamp": 1350729011,
+	"ModelImporter": {
+		"scale": 0.01,
+		"importAnimations": false,
+		"animInfo": []
+	}
+}

+ 6 - 0
JSComponentFields/Resources/Models/Materials.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "69f33ac142a5ef7d284c274274536526",
+	"timestamp": 1436725636,
+	"FolderImporter": {}
+}

+ 5 - 0
JSComponentFields/Resources/Models/Materials/DefaultMaterial.material

@@ -0,0 +1,5 @@
+<material>
+    <technique name="Techniques/Diff.xml" quality="0" />
+    <texture unit="diffuse" name="Textures/chest.png" />
+    <parameter name="MatSpecColor" value="0.3 0.3 0.3 16" />
+</material>

+ 6 - 0
JSComponentFields/Resources/Models/Materials/DefaultMaterial.material.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "4bbe945750a46d19c97246dbe0a9f68b",
+	"timestamp": 1436725628,
+	"MaterialImporter": {}
+}

+ 6 - 0
JSComponentFields/Resources/Scenes.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "7adf19467409e3c2c70da12ef96c9199",
+	"timestamp": 1436725695,
+	"FolderImporter": {}
+}

+ 98 - 0
JSComponentFields/Resources/Scenes/TheScene.scene

@@ -0,0 +1,98 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="0" />
+	<attribute name="Next Replicated Node ID" value="366" />
+	<attribute name="Next Replicated Component ID" value="1981" />
+	<attribute name="Next Local Node ID" value="16778496" />
+	<attribute name="Next Local Component ID" value="16777216" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="PhysicsWorld" id="1" />
+	<component type="Octree" id="2" />
+	<component type="DebugRenderer" id="3" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="4">
+			<attribute name="Bounding Box Min" value="-10000 -10000 -10000" />
+			<attribute name="Bounding Box Max" value="10000 10000 10000" />
+			<attribute name="Ambient Color" value="0.4 0.4 0.4 1" />
+		</component>
+	</node>
+	<node id="3">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="GlobalLight" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="0.888074 0.325058 -0.325058 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Light" id="5">
+			<attribute name="Light Type" value="Directional" />
+			<attribute name="Cast Shadows" value="true" />
+			<attribute name="CSM Splits" value="10 20 50 0" />
+			<attribute name="View Size Quantize" value="1" />
+			<attribute name="View Size Minimum" value="5" />
+			<attribute name="Depth Constant Bias" value="0.00025" />
+			<attribute name="Depth Slope Bias" value="0.001" />
+		</component>
+	</node>
+	<node id="361">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Chest" />
+		<attribute name="Position" value="0 -0.220452 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="1973">
+			<attribute name="Model" value="Model;Cache/8646c0f492bf9bd8b34d8c27e67b7d3c.mdl" />
+			<attribute name="Material" value="Material;Models/Materials/DefaultMaterial.material" />
+		</component>
+		<component type="JSComponent" id="1978">
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="2" />
+			</attribute>
+			<attribute name="ComponentFile" value="JSComponentFile;Components/Spinner.js" />
+		</component>
+	</node>
+	<node id="362">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Chest" />
+		<attribute name="Position" value="0 0.510768 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="1974">
+			<attribute name="Model" value="Model;Cache/8646c0f492bf9bd8b34d8c27e67b7d3c.mdl" />
+			<attribute name="Material" value="Material;Models/Materials/DefaultMaterial.material" />
+		</component>
+		<component type="JSComponent" id="1977">
+			<attribute name="ComponentFile" value="JSComponentFile;Components/Spinner.js" />
+		</component>
+	</node>
+	<node id="363">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Chest" />
+		<attribute name="Position" value="0 -0.998081 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="1975">
+			<attribute name="Model" value="Model;Cache/8646c0f492bf9bd8b34d8c27e67b7d3c.mdl" />
+			<attribute name="Material" value="Material;Models/Materials/DefaultMaterial.material" />
+		</component>
+		<component type="JSComponent" id="1979">
+			<attribute name="FieldValues">
+				<variant hash="273365031" type="Float" value="3" />
+			</attribute>
+			<attribute name="ComponentFile" value="JSComponentFile;Components/Spinner.js" />
+		</component>
+	</node>
+</scene>

+ 6 - 0
JSComponentFields/Resources/Scenes/TheScene.scene.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "c5c4f189efd61b5a9fae1d9a15775ea6",
+	"timestamp": 1436726378,
+	"SceneImporter": {}
+}

+ 6 - 0
JSComponentFields/Resources/Scripts.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "2c62ec70d098ab568c5817cc2f6cef24",
+	"timestamp": 1436725403,
+	"FolderImporter": {}
+}

+ 23 - 0
JSComponentFields/Resources/Scripts/main.js

@@ -0,0 +1,23 @@
+
+// This script is the main entry point of the game
+
+require("AtomicGame");
+
+Atomic.game.init(start, update);
+
+// called at the start of play
+function start() {
+
+	var game = Atomic.game;
+
+	game.createScene3D("Scenes/TheScene.scene");
+
+	game.cameraNode.position = [0, 0, -3];
+
+}
+
+// called per frame
+function update(timeStep) {
+
+
+}

+ 8 - 0
JSComponentFields/Resources/Scripts/main.js.asset

@@ -0,0 +1,8 @@
+{
+	"version": 1,
+	"guid": "c8ef552a2cb24304739e8c048fdaa986",
+	"timestamp": 1436725995,
+	"JavascriptImporter": {
+		"IsComponentFile": false
+	}
+}

+ 6 - 0
JSComponentFields/Resources/Textures.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "f07fe552ccd956393028c378dff3e49e",
+	"timestamp": 1436725403,
+	"FolderImporter": {}
+}

BIN
JSComponentFields/Resources/Textures/chest.png


+ 6 - 0
JSComponentFields/Resources/Textures/chest.png.asset

@@ -0,0 +1,6 @@
+{
+	"version": 1,
+	"guid": "57f1f04e5fb407a5293d2c0587d7d3fc",
+	"timestamp": 1423243327,
+	"TextureImporter": {}
+}