mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 19:55:07 +02:00
second hand moving based on actual time
This commit is contained in:
parent
360407dd83
commit
e9d3246809
3 changed files with 155 additions and 9 deletions
|
@ -0,0 +1,27 @@
|
|||
(function() {
|
||||
|
||||
var _this;
|
||||
|
||||
var d = new Date();
|
||||
var h = d.getHours();
|
||||
h = h % 12;
|
||||
|
||||
CuckooClock = function() {
|
||||
_this = this;
|
||||
|
||||
};
|
||||
|
||||
CuckooClock.prototype = {
|
||||
|
||||
|
||||
preload: function(entityID) {
|
||||
_this.entityID = entityID; // this.animation.isRunning = true;
|
||||
print("PRELOAD ENTITY SCRIPT!!!")
|
||||
},
|
||||
|
||||
|
||||
};
|
||||
|
||||
// entity scripts always need to return a newly constructed object of our type
|
||||
return new CuckooClock();
|
||||
});
|
112
unpublishedScripts/DomainContent/Home/cuckooClock/wrapper.js
Normal file
112
unpublishedScripts/DomainContent/Home/cuckooClock/wrapper.js
Normal file
|
@ -0,0 +1,112 @@
|
|||
//
|
||||
// wrapper.js
|
||||
// For cuckooClock
|
||||
//
|
||||
// Created by Eric Levin on 3/15/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
//
|
||||
// This entity script handles the logic for growing a plant when it has water poured on it
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var SCRIPT_URL = Script.resolvePath("cuckooClockEntityScript.js?v1" + Math.random())
|
||||
var CLOCK_BODY_URL = "http://hifi-content.s3.amazonaws.com/DomainContent/Home/cuckooClock/cuckoo2_BODY.fbx";
|
||||
var CLOCK_FACE_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/cuckooClock2_FACE.fbx";
|
||||
var CLOCK_HOUR_HAND_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/cuckooClock2_HOUR_HAND.fbx";
|
||||
var CLOCK_MINUTE_HAND_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/models/cuckooClock2_MINUTE_HAND.fbx";
|
||||
|
||||
MyCuckooClock = function(spawnPosition, spawnRotation) {
|
||||
var clockBody, clockFace, clockHourHand;
|
||||
|
||||
function createClockBody() {
|
||||
|
||||
clockBody = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: CLOCK_BODY_URL,
|
||||
animation: {
|
||||
url: CLOCK_BODY_URL,
|
||||
running: true,
|
||||
currentFrame: 100,
|
||||
loop: true
|
||||
},
|
||||
position: spawnPosition,
|
||||
dimensions: {
|
||||
x: 0.8181,
|
||||
y: 1.3662,
|
||||
z: 0.8181
|
||||
},
|
||||
script: SCRIPT_URL
|
||||
})
|
||||
|
||||
var clockFaceOffset = {x: -0.0345, y: 0.2587, z: 0.1255};
|
||||
clockFace = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: CLOCK_FACE_URL,
|
||||
animation: {
|
||||
url: CLOCK_FACE_URL,
|
||||
running: true,
|
||||
currentFrame: 0,
|
||||
loop: true
|
||||
},
|
||||
position: Vec3.sum(spawnPosition, clockFaceOffset),
|
||||
dimensions: {
|
||||
x: 0.2397,
|
||||
y: 0.2402,
|
||||
z: 0.0212
|
||||
},
|
||||
// script: SCRIPT_URL
|
||||
})
|
||||
|
||||
var clockHourHandOffset = {x: -0.0199, y: 0.3004, z: 0.147};
|
||||
|
||||
clockHourHand = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: CLOCK_HOUR_HAND_URL,
|
||||
position: Vec3.sum(spawnPosition, clockHourHandOffset),
|
||||
dimensions: {
|
||||
x: 0.0263,
|
||||
y: 0.0982,
|
||||
z: 0.0024
|
||||
},
|
||||
// script: SCRIPT_URL
|
||||
});
|
||||
|
||||
|
||||
var myDate = new Date()
|
||||
var seconds = myDate.getSeconds();
|
||||
|
||||
print("EBL SECONDS " + seconds)
|
||||
var rollDegrees = -seconds * 6;
|
||||
clockMinuteHand = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: CLOCK_MINUTE_HAND_URL,
|
||||
position: Vec3.sum(spawnPosition, clockHourHandOffset),
|
||||
dimensions: {
|
||||
x: 0.0263,
|
||||
y: 0.0982,
|
||||
z: 0.0024
|
||||
},
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, rollDegrees),
|
||||
angularDamping: 0,
|
||||
angularVelocity: {x: 0, y: 0, z: -0.10472}
|
||||
// script: SCRIPT_URL
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
print("EBL IM A CUCKOO CLOCK");
|
||||
|
||||
createClockBody();
|
||||
|
||||
function cleanup() {
|
||||
print('cuckoo cleanup')
|
||||
// Entities.deleteEntity(clockBody);
|
||||
// Entities.deleteEntity(clockFace);
|
||||
// Entities.deleteEntity(clockHourHand);
|
||||
// Entities.deleteEntity(clockMinuteHand);
|
||||
|
||||
}
|
||||
|
||||
this.cleanup = cleanup;
|
||||
return this
|
||||
}
|
|
@ -30,6 +30,15 @@
|
|||
|
||||
var plantPath = Script.resolvePath("growingPlant/wrapper.js?" + Math.random());
|
||||
|
||||
var cuckooClockPath = Script.resolvePath("cuckooClock/wrapper.js?" + Math.random());
|
||||
|
||||
Script.include(utilsPath);
|
||||
Script.include(fishTankPath);
|
||||
Script.include(tiltMazePath);
|
||||
Script.include(whiteboardPath);
|
||||
Script.include(plantPath);
|
||||
Script.include(cuckooClockPath);
|
||||
|
||||
Reset.prototype = {
|
||||
preload: function(entityID) {
|
||||
_this.entityID = entityID;
|
||||
|
@ -92,27 +101,24 @@
|
|||
z: 0
|
||||
}), Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||
|
||||
Script.include(utilsPath);
|
||||
Script.include(fishTankPath);
|
||||
Script.include(tiltMazePath);
|
||||
Script.include(whiteboardPath);
|
||||
Script.include(plantPath);
|
||||
|
||||
|
||||
// var fishTank = new FishTank(center);
|
||||
// var tiltMaze = new TiltMaze(center);
|
||||
// var whiteboard = new Whiteboard(center);
|
||||
var myPlant = new Plant(center);
|
||||
|
||||
// var myPlant = new Plant(center);
|
||||
|
||||
// dynamicEntities.push(fishTank);
|
||||
// dynamicEntities.push(tiltMaze);
|
||||
// dynamicEntities.push(whiteboard);
|
||||
dynamicEntities.push(myPlant);
|
||||
// dynamicEntities.push(myPlant);
|
||||
|
||||
//v2.0
|
||||
// var musicBox = new MusicBox();
|
||||
// var cuckooClock = new CuckooClock();
|
||||
var cuckooClock = new MyCuckooClock(center);
|
||||
// var doppelganger = new Doppelganger();
|
||||
|
||||
dynamicEntities.push(cuckooClock);
|
||||
},
|
||||
|
||||
cleanupDynamicEntities: function() {
|
||||
|
@ -120,6 +126,7 @@
|
|||
return;
|
||||
}
|
||||
dynamicEntities.forEach(function(dynamicEntity) {
|
||||
print('dynamicEntity is:: '+JSON.stringify(dynamicEntity))
|
||||
dynamicEntity.cleanup();
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue