mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-04 12:58:46 +02:00
Remove stopwatch source in favor of using source in hifi-content repo
This commit is contained in:
parent
0c9184566e
commit
7cb6bae1e6
10 changed files with 0 additions and 266 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,89 +0,0 @@
|
||||||
//
|
|
||||||
// spawnStopwatch.js
|
|
||||||
//
|
|
||||||
// Created by Ryan Huffman on 1/20/17.
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
var forward = Quat.getFront(MyAvatar.orientation);
|
|
||||||
Vec3.print("Forward: ", forward);
|
|
||||||
var positionToSpawn = Vec3.sum(MyAvatar.position, Vec3.multiply(3, forward));
|
|
||||||
var scale = 0.5;
|
|
||||||
positionToSpawn.y += 0.5;
|
|
||||||
|
|
||||||
var stopwatchID = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
name: "stopwatch/base",
|
|
||||||
position: positionToSpawn,
|
|
||||||
modelURL: Script.resolvePath("models/Stopwatch.fbx"),
|
|
||||||
dimensions: Vec3.multiply(scale, {"x":4.129462242126465,"y":1.058512806892395,"z":5.773681640625}),
|
|
||||||
rotation: Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollDegrees(90, 0, 0))
|
|
||||||
});
|
|
||||||
|
|
||||||
var secondHandID = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
name: "stopwatch/seconds",
|
|
||||||
parentID: stopwatchID,
|
|
||||||
localPosition: Vec3.multiply(scale, {"x":-0.004985813982784748,"y":0.39391064643859863,"z":0.8312804698944092}),
|
|
||||||
dimensions: Vec3.multiply(scale, {"x":0.14095762372016907,"y":0.02546107769012451,"z":1.6077008247375488}),
|
|
||||||
registrationPoint: {"x":0.5,"y":0.5,"z":1},
|
|
||||||
modelURL: Script.resolvePath("models/Stopwatch-sec-hand.fbx"),
|
|
||||||
});
|
|
||||||
|
|
||||||
var minuteHandID = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
name: "stopwatch/minutes",
|
|
||||||
parentID: stopwatchID,
|
|
||||||
localPosition: Vec3.multiply(scale, {"x":-0.0023056098725646734,"y":0.3308190703392029,"z":0.21810021996498108}),
|
|
||||||
dimensions: Vec3.multiply(scale, {"x":0.045471154153347015,"y":0.015412690117955208,"z":0.22930574417114258}),
|
|
||||||
registrationPoint: {"x":0.5,"y":0.5,"z":1},
|
|
||||||
modelURL: Script.resolvePath("models/Stopwatch-min-hand.fbx"),
|
|
||||||
});
|
|
||||||
|
|
||||||
var startStopButtonID = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
name: "stopwatch/startStop",
|
|
||||||
parentID: stopwatchID,
|
|
||||||
dimensions: Vec3.multiply(scale, { x: 0.8, y: 0.8, z: 1.0 }),
|
|
||||||
localPosition: Vec3.multiply(scale, { x: 0, y: -0.1, z: -2.06 }),
|
|
||||||
modelURL: Script.resolvePath("models/transparent-box.fbx")
|
|
||||||
});
|
|
||||||
|
|
||||||
var resetButtonID = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
name: "stopwatch/startStop",
|
|
||||||
parentID: stopwatchID,
|
|
||||||
dimensions: Vec3.multiply(scale, { x: 0.6, y: 0.6, z: 0.8 }),
|
|
||||||
localPosition: Vec3.multiply(scale, { x: -1.5, y: -0.1, z: -1.2 }),
|
|
||||||
localRotation: Quat.fromVec3Degrees({ x: 0, y: 36, z: 0 }),
|
|
||||||
modelURL: Script.resolvePath("models/transparent-box.fbx")
|
|
||||||
});
|
|
||||||
|
|
||||||
Entities.editEntity(stopwatchID, {
|
|
||||||
userData: JSON.stringify({
|
|
||||||
secondHandID: secondHandID,
|
|
||||||
minuteHandID: minuteHandID
|
|
||||||
}),
|
|
||||||
serverScripts: Script.resolvePath("stopwatchServer.js")
|
|
||||||
});
|
|
||||||
|
|
||||||
Entities.editEntity(startStopButtonID, {
|
|
||||||
userData: JSON.stringify({
|
|
||||||
stopwatchID: stopwatchID,
|
|
||||||
grabbableKey: { wantsTrigger: true }
|
|
||||||
}),
|
|
||||||
script: Script.resolvePath("stopwatchStartStop.js")
|
|
||||||
});
|
|
||||||
|
|
||||||
Entities.editEntity(resetButtonID, {
|
|
||||||
userData: JSON.stringify({
|
|
||||||
stopwatchID: stopwatchID,
|
|
||||||
grabbableKey: { wantsTrigger: true }
|
|
||||||
}),
|
|
||||||
script: Script.resolvePath("stopwatchReset.js")
|
|
||||||
});
|
|
||||||
|
|
||||||
Script.stop()
|
|
|
@ -1,22 +0,0 @@
|
||||||
//
|
|
||||||
// stopwatchReset.js
|
|
||||||
//
|
|
||||||
// Created by David Rowe on 26 May 2017.
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
this.preload = function (entityID) {
|
|
||||||
var properties = Entities.getEntityProperties(entityID, "userData");
|
|
||||||
this.messageChannel = "STOPWATCH-" + JSON.parse(properties.userData).stopwatchID;
|
|
||||||
};
|
|
||||||
function click() {
|
|
||||||
Messages.sendMessage(this.messageChannel, "reset");
|
|
||||||
}
|
|
||||||
this.startNearTrigger = click;
|
|
||||||
this.startFarTrigger = click;
|
|
||||||
this.clickDownOnEntity = click;
|
|
||||||
});
|
|
|
@ -1,132 +0,0 @@
|
||||||
//
|
|
||||||
// stopwatchServer.js
|
|
||||||
//
|
|
||||||
// Created by Ryan Huffman on 1/20/17.
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
self.equipped = false;
|
|
||||||
self.isActive = false;
|
|
||||||
self.seconds = 0;
|
|
||||||
|
|
||||||
self.secondHandID = null;
|
|
||||||
self.minuteHandID = null;
|
|
||||||
|
|
||||||
self.tickSound = SoundCache.getSound(Script.resolvePath("sounds/tick.wav"));
|
|
||||||
self.tickInjector = null;
|
|
||||||
self.tickIntervalID = null;
|
|
||||||
|
|
||||||
self.chimeSound = SoundCache.getSound(Script.resolvePath("sounds/chime.wav"));
|
|
||||||
|
|
||||||
self.preload = function(entityID) {
|
|
||||||
print("Preloading stopwatch: ", entityID);
|
|
||||||
self.entityID = entityID;
|
|
||||||
self.messageChannel = "STOPWATCH-" + entityID;
|
|
||||||
|
|
||||||
var userData = Entities.getEntityProperties(self.entityID, 'userData').userData;
|
|
||||||
var data = JSON.parse(userData);
|
|
||||||
self.secondHandID = data.secondHandID;
|
|
||||||
self.minuteHandID = data.minuteHandID;
|
|
||||||
|
|
||||||
self.resetTimer();
|
|
||||||
|
|
||||||
Messages.subscribe(self.messageChannel);
|
|
||||||
Messages.messageReceived.connect(this, self.messageReceived);
|
|
||||||
};
|
|
||||||
self.unload = function() {
|
|
||||||
print("Unloading stopwatch:", self.entityID);
|
|
||||||
self.resetTimer();
|
|
||||||
Messages.unsubscribe(self.messageChannel);
|
|
||||||
Messages.messageReceived.disconnect(this, self.messageReceived);
|
|
||||||
};
|
|
||||||
self.messageReceived = function(channel, message, sender) {
|
|
||||||
print("Message received", channel, sender, message);
|
|
||||||
if (channel === self.messageChannel) {
|
|
||||||
switch (message) {
|
|
||||||
case "startStop":
|
|
||||||
if (self.isActive) {
|
|
||||||
self.stopTimer();
|
|
||||||
} else {
|
|
||||||
self.startTimer();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "reset":
|
|
||||||
self.stopTimer();
|
|
||||||
self.resetTimer();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
self.getStopwatchPosition = function() {
|
|
||||||
return Entities.getEntityProperties(self.entityID, "position").position;
|
|
||||||
};
|
|
||||||
self.resetTimer = function() {
|
|
||||||
print("Resetting stopwatch");
|
|
||||||
Entities.editEntity(self.secondHandID, {
|
|
||||||
localRotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
|
|
||||||
angularVelocity: { x: 0, y: 0, z: 0 },
|
|
||||||
});
|
|
||||||
Entities.editEntity(self.minuteHandID, {
|
|
||||||
localRotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
|
|
||||||
angularVelocity: { x: 0, y: 0, z: 0 },
|
|
||||||
});
|
|
||||||
self.seconds = 0;
|
|
||||||
};
|
|
||||||
self.startTimer = function() {
|
|
||||||
print("Starting stopwatch");
|
|
||||||
if (!self.tickInjector) {
|
|
||||||
self.tickInjector = Audio.playSound(self.tickSound, {
|
|
||||||
position: self.getStopwatchPosition(),
|
|
||||||
volume: 0.7,
|
|
||||||
loop: true
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
self.tickInjector.restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.tickIntervalID = Script.setInterval(function() {
|
|
||||||
if (self.tickInjector) {
|
|
||||||
self.tickInjector.setOptions({
|
|
||||||
position: self.getStopwatchPosition(),
|
|
||||||
volume: 0.7,
|
|
||||||
loop: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
self.seconds++;
|
|
||||||
const degreesPerTick = -360 / 60;
|
|
||||||
Entities.editEntity(self.secondHandID, {
|
|
||||||
localRotation: Quat.fromPitchYawRollDegrees(0, self.seconds * degreesPerTick, 0),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (self.seconds % 60 == 0) {
|
|
||||||
Entities.editEntity(self.minuteHandID, {
|
|
||||||
localRotation: Quat.fromPitchYawRollDegrees(0, (self.seconds / 60) * degreesPerTick, 0),
|
|
||||||
});
|
|
||||||
Audio.playSound(self.chimeSound, {
|
|
||||||
position: self.getStopwatchPosition(),
|
|
||||||
volume: 1.0,
|
|
||||||
loop: false
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
|
|
||||||
self.isActive = true;
|
|
||||||
};
|
|
||||||
self.stopTimer = function () {
|
|
||||||
print("Stopping stopwatch");
|
|
||||||
if (self.tickInjector) {
|
|
||||||
self.tickInjector.stop();
|
|
||||||
}
|
|
||||||
if (self.tickIntervalID !== null) {
|
|
||||||
Script.clearInterval(self.tickIntervalID);
|
|
||||||
self.tickIntervalID = null;
|
|
||||||
}
|
|
||||||
self.isActive = false;
|
|
||||||
};
|
|
||||||
});
|
|
|
@ -1,23 +0,0 @@
|
||||||
//
|
|
||||||
// stopwatchStartStop.js
|
|
||||||
//
|
|
||||||
// Created by David Rowe on 26 May 2017.
|
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
|
||||||
//
|
|
||||||
// Distributed under the Apache License, Version 2.0.
|
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
||||||
//
|
|
||||||
|
|
||||||
(function () {
|
|
||||||
var messageChannel;
|
|
||||||
this.preload = function (entityID) {
|
|
||||||
var properties = Entities.getEntityProperties(entityID, "userData");
|
|
||||||
this.messageChannel = "STOPWATCH-" + JSON.parse(properties.userData).stopwatchID;
|
|
||||||
};
|
|
||||||
function click() {
|
|
||||||
Messages.sendMessage(this.messageChannel, "startStop");
|
|
||||||
}
|
|
||||||
this.startNearTrigger = click;
|
|
||||||
this.startFarTrigger = click;
|
|
||||||
this.clickDownOnEntity = click;
|
|
||||||
});
|
|
Loading…
Reference in a new issue