mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:17:01 +02:00
...spaces?
This commit is contained in:
parent
8d5834475a
commit
16bebc437b
1 changed files with 151 additions and 151 deletions
|
@ -19,45 +19,45 @@ var MAZE_SCRIPT = Script.resolvePath('maze.js?' + Math.random());
|
||||||
var SCALE = 0.5;
|
var SCALE = 0.5;
|
||||||
|
|
||||||
var MAZE_DIMENSIONS = Vec3.multiply(SCALE, {
|
var MAZE_DIMENSIONS = Vec3.multiply(SCALE, {
|
||||||
x: 1,
|
x: 1,
|
||||||
y: 0.15,
|
y: 0.15,
|
||||||
z: 1
|
z: 1
|
||||||
});
|
});
|
||||||
|
|
||||||
var BALL_DIMENSIONS = Vec3.multiply(SCALE, {
|
var BALL_DIMENSIONS = Vec3.multiply(SCALE, {
|
||||||
x: 0.035,
|
x: 0.035,
|
||||||
y: 0.035,
|
y: 0.035,
|
||||||
z: 0.035
|
z: 0.035
|
||||||
});
|
});
|
||||||
|
|
||||||
var BALL_SPAWNER_DIMENSIONS = Vec3.multiply(SCALE, {
|
var BALL_SPAWNER_DIMENSIONS = Vec3.multiply(SCALE, {
|
||||||
x: 0.05,
|
x: 0.05,
|
||||||
y: 0.05,
|
y: 0.05,
|
||||||
z: 0.05
|
z: 0.05
|
||||||
});
|
});
|
||||||
|
|
||||||
var BALL_DETECTOR_DIMENSIONS = Vec3.multiply(SCALE, {
|
var BALL_DETECTOR_DIMENSIONS = Vec3.multiply(SCALE, {
|
||||||
x: 0.1,
|
x: 0.1,
|
||||||
y: 0.1,
|
y: 0.1,
|
||||||
z: 0.1
|
z: 0.1
|
||||||
});
|
});
|
||||||
|
|
||||||
var BALL_COLOR = {
|
var BALL_COLOR = {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 0,
|
green: 0,
|
||||||
blue: 0
|
blue: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var DEBUG_COLOR = {
|
var DEBUG_COLOR = {
|
||||||
red: 0,
|
red: 0,
|
||||||
green: 255,
|
green: 255,
|
||||||
blue: 0
|
blue: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
var center = Vec3.sum(Vec3.sum(MyAvatar.position, {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0.5,
|
y: 0.5,
|
||||||
z: 0
|
z: 0
|
||||||
}), Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation())));
|
}), Vec3.multiply(1.5, Quat.getFront(Camera.getOrientation())));
|
||||||
|
|
||||||
var CLEANUP = true;
|
var CLEANUP = true;
|
||||||
|
@ -72,9 +72,9 @@ var BALL_DAMPING = 0.6;
|
||||||
var BALL_ANGULAR_DAMPING = 0.2;
|
var BALL_ANGULAR_DAMPING = 0.2;
|
||||||
var BALL_DENSITY = 1000;
|
var BALL_DENSITY = 1000;
|
||||||
var BALL_GRAVITY = {
|
var BALL_GRAVITY = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: -9.8,
|
y: -9.8,
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var MAZE_DENSITY = 1000;
|
var MAZE_DENSITY = 1000;
|
||||||
|
@ -87,15 +87,15 @@ var DETECTOR_FORWARD_OFFSET = 0.35 * SCALE;
|
||||||
var DETECTOR_RIGHT_OFFSET = 0.35 * SCALE;
|
var DETECTOR_RIGHT_OFFSET = 0.35 * SCALE;
|
||||||
|
|
||||||
var END_LIGHT_COLOR = {
|
var END_LIGHT_COLOR = {
|
||||||
red: 255,
|
red: 255,
|
||||||
green: 0,
|
green: 0,
|
||||||
blue: 0
|
blue: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var END_LIGHT_DIMENSIONS = {
|
var END_LIGHT_DIMENSIONS = {
|
||||||
x: 0.2,
|
x: 0.2,
|
||||||
y: 0.2,
|
y: 0.2,
|
||||||
z: 0.8
|
z: 0.8
|
||||||
};
|
};
|
||||||
|
|
||||||
var END_LIGHT_INTENSITY = 0.035;
|
var END_LIGHT_INTENSITY = 0.035;
|
||||||
|
@ -103,170 +103,170 @@ var END_LIGHT_CUTOFF = 30;
|
||||||
var END_LIGHT_EXPONENT = 1;
|
var END_LIGHT_EXPONENT = 1;
|
||||||
|
|
||||||
var getBallStartLocation = function() {
|
var getBallStartLocation = function() {
|
||||||
var mazeProps = Entities.getEntityProperties(tiltMaze);
|
var mazeProps = Entities.getEntityProperties(tiltMaze);
|
||||||
var right = Quat.getRight(mazeProps.rotation);
|
var right = Quat.getRight(mazeProps.rotation);
|
||||||
var front = Quat.getFront(mazeProps.rotation);
|
var front = Quat.getFront(mazeProps.rotation);
|
||||||
var vertical = {
|
var vertical = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: BALL_VERTICAL_OFFSET,
|
y: BALL_VERTICAL_OFFSET,
|
||||||
z: 0
|
z: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
var finalOffset = Vec3.sum(vertical, Vec3.multiply(right, BALL_RIGHT_OFFSET));
|
var finalOffset = Vec3.sum(vertical, Vec3.multiply(right, BALL_RIGHT_OFFSET));
|
||||||
finalOffset = Vec3.sum(finalOffset, Vec3.multiply(front, BALL_FORWARD_OFFSET));
|
finalOffset = Vec3.sum(finalOffset, Vec3.multiply(front, BALL_FORWARD_OFFSET));
|
||||||
var location = Vec3.sum(mazeProps.position, finalOffset);
|
var location = Vec3.sum(mazeProps.position, finalOffset);
|
||||||
return location;
|
return location;
|
||||||
};
|
};
|
||||||
|
|
||||||
var getBallFinishLocation = function() {
|
var getBallFinishLocation = function() {
|
||||||
var mazeProps = Entities.getEntityProperties(tiltMaze);
|
var mazeProps = Entities.getEntityProperties(tiltMaze);
|
||||||
var right = Quat.getRight(mazeProps.rotation);
|
var right = Quat.getRight(mazeProps.rotation);
|
||||||
var forward = Quat.getFront(mazeProps.rotation);
|
var forward = Quat.getFront(mazeProps.rotation);
|
||||||
var up = Quat.getUp(mazeProps.rotation);
|
var up = Quat.getUp(mazeProps.rotation);
|
||||||
|
|
||||||
var position = Vec3.sum(mazeProps.position, Vec3.multiply(up, DETECTOR_VERTICAL_OFFSET));
|
var position = Vec3.sum(mazeProps.position, Vec3.multiply(up, DETECTOR_VERTICAL_OFFSET));
|
||||||
position = Vec3.sum(position, Vec3.multiply(right, DETECTOR_RIGHT_OFFSET));
|
position = Vec3.sum(position, Vec3.multiply(right, DETECTOR_RIGHT_OFFSET));
|
||||||
position = Vec3.sum(position, Vec3.multiply(forward, DETECTOR_FORWARD_OFFSET));
|
position = Vec3.sum(position, Vec3.multiply(forward, DETECTOR_FORWARD_OFFSET));
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var createBall = function(position) {
|
var createBall = function(position) {
|
||||||
var properties = {
|
var properties = {
|
||||||
name: 'Hifi Tilt Maze Ball',
|
name: 'Hifi Tilt Maze Ball',
|
||||||
type: 'Sphere',
|
type: 'Sphere',
|
||||||
position: getBallStartLocation(),
|
position: getBallStartLocation(),
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
collisionless: false,
|
collisionless: false,
|
||||||
friction: BALL_FRICTION,
|
friction: BALL_FRICTION,
|
||||||
restitution: BALL_RESTITUTION,
|
restitution: BALL_RESTITUTION,
|
||||||
angularDamping: BALL_ANGULAR_DAMPING,
|
angularDamping: BALL_ANGULAR_DAMPING,
|
||||||
damping: BALL_DAMPING,
|
damping: BALL_DAMPING,
|
||||||
gravity: BALL_GRAVITY,
|
gravity: BALL_GRAVITY,
|
||||||
density: BALL_DENSITY,
|
density: BALL_DENSITY,
|
||||||
color: BALL_COLOR,
|
color: BALL_COLOR,
|
||||||
dimensions: BALL_DIMENSIONS,
|
dimensions: BALL_DIMENSIONS,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
grabbable: false
|
grabbable: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ball = Entities.addEntity(properties);
|
ball = Entities.addEntity(properties);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var createBallSpawningAnchor = function() {
|
var createBallSpawningAnchor = function() {
|
||||||
var properties = {
|
var properties = {
|
||||||
name: 'Hifi Tilt Maze Ball Detector',
|
name: 'Hifi Tilt Maze Ball Detector',
|
||||||
parentID: tiltMaze,
|
parentID: tiltMaze,
|
||||||
type: 'Box',
|
type: 'Box',
|
||||||
color: DEBUG_COLOR,
|
color: DEBUG_COLOR,
|
||||||
dimensions: BALL_SPAWNER_DIMENSIONS,
|
dimensions: BALL_SPAWNER_DIMENSIONS,
|
||||||
position: getBallStartLocation(),
|
position: getBallStartLocation(),
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
visible: false,
|
visible: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
ballSpawningAnchor = Entities.addEntity(properties);
|
ballSpawningAnchor = Entities.addEntity(properties);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var createBallDetector = function() {
|
var createBallDetector = function() {
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
name: 'Hifi Tilt Maze Ball Detector',
|
name: 'Hifi Tilt Maze Ball Detector',
|
||||||
parentID: tiltMaze,
|
parentID: tiltMaze,
|
||||||
type: 'Box',
|
type: 'Box',
|
||||||
color: DEBUG_COLOR,
|
color: DEBUG_COLOR,
|
||||||
shapeType: 'none',
|
shapeType: 'none',
|
||||||
dimensions: BALL_DETECTOR_DIMENSIONS,
|
dimensions: BALL_DETECTOR_DIMENSIONS,
|
||||||
position: getBallFinishLocation(),
|
position: getBallFinishLocation(),
|
||||||
collisionless: true,
|
collisionless: true,
|
||||||
dynamic: false,
|
dynamic: false,
|
||||||
visible: false,
|
visible: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
ballDetector = Entities.addEntity(properties);
|
ballDetector = Entities.addEntity(properties);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var createTiltMaze = function(position) {
|
var createTiltMaze = function(position) {
|
||||||
var properties = {
|
var properties = {
|
||||||
name: 'Hifi Tilt Maze',
|
name: 'Hifi Tilt Maze',
|
||||||
type: 'Model',
|
type: 'Model',
|
||||||
modelURL: MAZE_MODEL_URL,
|
modelURL: MAZE_MODEL_URL,
|
||||||
compoundShapeURL: MAZE_COLLISION_HULL,
|
compoundShapeURL: MAZE_COLLISION_HULL,
|
||||||
dimensions: MAZE_DIMENSIONS,
|
dimensions: MAZE_DIMENSIONS,
|
||||||
position: position,
|
position: position,
|
||||||
restitution: MAZE_RESTITUTION,
|
restitution: MAZE_RESTITUTION,
|
||||||
damping: MAZE_DAMPING,
|
damping: MAZE_DAMPING,
|
||||||
angularDamping: MAZE_ANGULAR_DAMPING,
|
angularDamping: MAZE_ANGULAR_DAMPING,
|
||||||
dynamic: true,
|
dynamic: true,
|
||||||
density: MAZE_DENSITY,
|
density: MAZE_DENSITY,
|
||||||
script: MAZE_SCRIPT
|
script: MAZE_SCRIPT
|
||||||
}
|
}
|
||||||
|
|
||||||
tiltMaze = Entities.addEntity(properties);
|
tiltMaze = Entities.addEntity(properties);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var createLightAtTheEnd = function() {
|
var createLightAtTheEnd = function() {
|
||||||
|
|
||||||
var mazeProps = Entities.getEntityProperties(tiltMaze, 'position');
|
var mazeProps = Entities.getEntityProperties(tiltMaze, 'position');
|
||||||
|
|
||||||
var up = Quat.getUp(mazeProps.rotation);
|
var up = Quat.getUp(mazeProps.rotation);
|
||||||
var down = Vec3.multiply(-1, up);
|
var down = Vec3.multiply(-1, up);
|
||||||
|
|
||||||
var emitOrientation = Quat.rotationBetween(Vec3.UNIT_NEG_Z, down);
|
var emitOrientation = Quat.rotationBetween(Vec3.UNIT_NEG_Z, down);
|
||||||
|
|
||||||
var position = getBallFinishLocation();
|
var position = getBallFinishLocation();
|
||||||
var lightProperties = {
|
var lightProperties = {
|
||||||
parentID: tiltMaze,
|
parentID: tiltMaze,
|
||||||
name: 'Hifi Tilt Maze End Light',
|
name: 'Hifi Tilt Maze End Light',
|
||||||
type: "Light",
|
type: "Light",
|
||||||
isSpotlight: true,
|
isSpotlight: true,
|
||||||
dimensions: END_LIGHT_DIMENSIONS,
|
dimensions: END_LIGHT_DIMENSIONS,
|
||||||
color: END_LIGHT_COLOR,
|
color: END_LIGHT_COLOR,
|
||||||
intensity: END_LIGHT_INTENSITY,
|
intensity: END_LIGHT_INTENSITY,
|
||||||
exponent: END_LIGHT_EXPONENT,
|
exponent: END_LIGHT_EXPONENT,
|
||||||
cutoff: END_LIGHT_CUTOFF,
|
cutoff: END_LIGHT_CUTOFF,
|
||||||
lifetime: -1,
|
lifetime: -1,
|
||||||
position: position,
|
position: position,
|
||||||
rotation: emitOrientation
|
rotation: emitOrientation
|
||||||
};
|
};
|
||||||
|
|
||||||
lightAtTheEnd = Entities.addEntity(lightProperties);
|
lightAtTheEnd = Entities.addEntity(lightProperties);
|
||||||
};
|
};
|
||||||
|
|
||||||
var createAll = function() {
|
var createAll = function() {
|
||||||
createTiltMaze(center);
|
createTiltMaze(center);
|
||||||
createBallSpawningAnchor();
|
createBallSpawningAnchor();
|
||||||
createBallDetector(center);
|
createBallDetector(center);
|
||||||
createBall(center);
|
createBall(center);
|
||||||
createLightAtTheEnd();
|
createLightAtTheEnd();
|
||||||
Entities.editEntity(tiltMaze, {
|
Entities.editEntity(tiltMaze, {
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
tiltMaze: {
|
tiltMaze: {
|
||||||
firstBall: ball,
|
firstBall: ball,
|
||||||
ballSpawner: ballSpawningAnchor,
|
ballSpawner: ballSpawningAnchor,
|
||||||
detector: ballDetector,
|
detector: ballDetector,
|
||||||
lightAtTheEnd: lightAtTheEnd
|
lightAtTheEnd: lightAtTheEnd
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
createAll();
|
createAll();
|
||||||
|
|
||||||
if (CLEANUP === true) {
|
if (CLEANUP === true) {
|
||||||
Script.scriptEnding.connect(function() {
|
Script.scriptEnding.connect(function() {
|
||||||
Entities.deleteEntity(tiltMaze);
|
Entities.deleteEntity(tiltMaze);
|
||||||
Entities.deleteEntity(ball);
|
Entities.deleteEntity(ball);
|
||||||
Entities.deleteEntity(ballSpawningAnchor);
|
Entities.deleteEntity(ballSpawningAnchor);
|
||||||
Entities.deleteEntity(lightAtTheEnd);
|
Entities.deleteEntity(lightAtTheEnd);
|
||||||
});
|
});
|
||||||
};
|
};
|
Loading…
Reference in a new issue