jumpStart.addEventListener("precache", function()
{
var myModels = ["models/car", "models/explosion"];
jumpStart.loadModels(myModels).then(function()
{
// Indicate that precaching is complete.
jumpStart.doneCaching();
});
return false; // False indicates ASYNCHRONOUS precaching.
});
jumpStart.addEventListener("ready", function()
{
// Load in some last minute stuff
var imageElem = new Image();
imageElem.addEventListener("load", function()
{
// Alright, NOW we are ready to start the game.
jumpStart.run();
});
imageElem.src = "http://www.mydomain.com/picture.jpg";
return false; // False indicates we are not ready yet.
});
jumpStart.addEventListener("precache", function()
{
// Define all of the models we want to load.
var myModels = ["models/car", "models/explosion"];
// Load all of these models.
jumpStart.loadModels(myModels).then(function()
{
// All models are done loading.
jumpStart.doneCaching();
});
return false;
});
jumpStart.addEventListener("ready", function()
{
// Have a world-space position to test.
var pos = new THREE.Vector3(123.4, 567.9, 910.11);
// Test it.
if( jumpStart.isWorldPosInsideOfEnclosure(pos) )
console.log("Yes.");
else
console.log("No.");
return;
});
- world READONLY THREE.Group
- worldOffset READONLY THREE.Vector3
- scene READONLY THREE.Scene
- deltaTime READONLY Number
- elapsedTime READONLY Number
- clickedObject READONLY THREE.Object3D
- hoveredObject READONLY THREE.Object3D
- behaviors READONLY Object
- clock READONLY THREE.Clock
- camera READONLY (THREE.Camera || null)
- gamepads READONLY Array
- activeGamepadIndex READONLY Number
- rayCaster READONLY THREE.Raycaster
- audioContext READONLY webkitAudioContext
- enclosure READONLY Object
- innerDepth READONLY Number
- innerHeight READONLY Number
- innerWidth READONLY Number
- adjustedDepth READONLY Number
- adjustedHeight READONLY Number
- adjustedWidth READONLY Number
- scaledDepth READONLY Number
- scaledHeight READONLY Number
- scaledWidth READONLY Number
- localUser READONLY Object
- displayName READONLY String
- userID READONLY String
- lookHit READONLY THREE.Vector3
- object READONLY THREE.Object3D
- point READONLY THREE.Vector3
- scaledPoint READONLY THREE.Vector3
- options READONLY Object
- appID READONLY String
- multiuserOnly READONLY Bool
- enclosureOnly READONLY Bool
- sceneScale READONLY Number
- scaleWithEnclosure READONLY Bool
- webControls READONLY Bool
- camera READONLY Object
- position READONLY THREE.Vector3
- debug READONLY Object
- showCursorPlanes READONLY Bool
jumpStart.addEventListener("ready", function()
{
// Configure non-default options.
var myOptions =
{
"width": "auto",
"height": 12,
"text": "Hello World",
"fontSize": 12,
"color": "rgba(255,255,255,1.0)",
"background": "rgba(0,0,0,1.0)",
"backgroundImageElem": null
};
// Spawn the text plane
var myObject = jumpStart.spawnTextPlane(options);
return true;
});
jumpStart.addEventListener("ready", function()
{
// Configure non-default options.
var myOptions =
{
"width": "auto",
"height": 12,
"text": "Hello World",
"fontSize": 12,
"color": "rgba(255,255,255,1.0)",
"background": "rgba(0,0,0,1.0)",
"backgroundImageElem": null
};
// Spawn the text plane
var myObject = jumpStart.spawnTextPlane(options);
// Wait for an event to happen.
myObject.addEventListener("cursorenter", function()
{
// Use the same options as before, but new text.
myOptions.text = "How are you?";
// Update the text plane.
jumpStart.updateText(this, myOptions);
});
return true;
});
jumpStart.addEventListener("ready", function()
{
// Configure non-default options.
var myOptions =
{
"width": jumpStart.enclosure.scaledWidth,
"height": jumpStart.enclosure.scaledHeight,
"parent": jumpStart.world
};
// Spawn the text plane.
var myObject = jumpStart.spawnCursorPlane(options);
// Make it solid.
myObject.blocksLOS = true;
// Wait for an event to happen.
myObject.addEventListener("tick", function()
{
// Make sure we are being hovered.
if( jumpStart.localUser.cursorHit && jumpStart.localUser.cursorHit.object === this )
{
// Output the cursor position.
console.log(jumpStart.localUser.cursorHit.scaledPoint);
}
});
return true;
});
jumpStart.addEventListener("ready", function()
{
// BoundaryIDs: floor, ceiling, north, east, south, west
// Get (or create) a cursor plane for the floor of the enclosure.
var boundary = jumpStart.enclosureBoundary("floor");
// Add an event when somebody clicks on the floor.
boundary.addEventListener("cursordown", function()
{
console.log("You clicked the floor!");
});
return true;
});
jumpStart.addEventListener("precache", function()
{
// Start loading the sound.
// NOTE: The sound will not be ready to play right away.
jumpStart.precacheSound("sounds/explosion");
return true;
});
jumpStart.addEventListener("ready", function()
{
// Spawn a cursor plane to interact with.
var myObject = jumpStart.spawnCursorPlane();
// Make it solid.
myObject.blocksLOS = true;
// Wait for an event to happen.
myObject.addEventListener("cursordown", function()
{
// Either resume the loop, or start it up for the first time.
if( !!this.userData.mySound )
this.userData.sound.source.start(0);
else
this.userData.mySound = jumpStart.playSound("sounds/explosion", 1.0, true);
});
// Wait for a different event to happen.
myObject.addEventListener("cursorup", function()
{
// Stop the sound.
this.userData.mySound.source.stop(0);
});
return true;
});
jumpStart.addEventListener("precache", function()
{
// Start loading the sound.
// NOTE: The sound will not be ready to play right away.
jumpStart.precacheSound("sounds/explosion");
return true;
});
jumpStart.addEventListener("ready", function()
{
// Spawn a cursor plane to interact with.
var myObject = jumpStart.spawnCursorPlane();
// Make it solid.
myObject.blocksLOS = true;
// Wait for an event to happen.
myObject.addEventListener("cursordown", function()
{
// Either resume the loop, or start it up for the first time.
if( !!this.userData.mySound )
this.userData.sound.source.start(0);
else
this.userData.mySound = jumpStart.playSound("sounds/explosion", 1.0, true);
});
// Wait for a different event to happen.
myObject.addEventListener("cursorup", function()
{
// Stop the sound.
this.userData.mySound.source.stop(0);
});
return true;
});
jumpStart.addEventListener("ready", function()
{
// Load a model to use.
jumpStart.loadModels(["models/car"]).then(function()
{
// Configure non-default options.
var myOptions = {
"parent": jumpStart.world
};
// Spawn a car.
var myObject = jumpStart.spawnInstance("models/car", myOptions);
// We are ready now.
jumpStart.run();
});
return false;
});
jumpStart.addEventListener("ready", function()
{
// Load a model to use.
jumpStart.loadModels(["models/car"]).then(function()
{
// Configure non-default options.
var myOptions = {
"parent": jumpStart.world
};
// Spawn a car.
var myObject = jumpStart.spawnInstance("models/car", myOptions);
// Make it solid.
myObject.blocksLOS = true;
// Wait for an event to happen.
myObject.addEventListener("cursorup", function()
{
// Remove us.
jumpStart.removeInstance(this);
});
// We are ready now.
jumpStart.run();
});
return false;
});
// Game System Events: precache, initialize, ready, tick, cursordown, cursorup
// Wait for an event to happen.
jumpStart.addEventListener("cursordown", function()
{
console.log("Local user clicked on something!");
});
// Game System Events: precache, initialize, ready, tick, cursordown, cursorup
// Wait for an event to happen.
jumpStart.addEventListener("cursordown", function()
{
console.log("Local user clicked on something!");
// arguments.callee gives us the current function.
var selfFunc = arguments.callee;
// Stop listening for this event.
jumpStart.removeEventListener("cursordown", selfFunc);
});