From 8b3b32c70d502d4ef0df46f7b2b8e74759fb6857 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Mon, 4 May 2015 17:21:50 -0700 Subject: [PATCH] add example --- .../example/entities/zoneAtmosphereExample.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 examples/example/entities/zoneAtmosphereExample.js diff --git a/examples/example/entities/zoneAtmosphereExample.js b/examples/example/entities/zoneAtmosphereExample.js new file mode 100644 index 0000000000..57d71a53b6 --- /dev/null +++ b/examples/example/entities/zoneAtmosphereExample.js @@ -0,0 +1,73 @@ +// +// zoneAtmosphereExample.js +// examples +// +// Created by Brad Hefta-Gaub on 4/16/15. +// Copyright 2015 High Fidelity, Inc. +// +// This is an example script that demonstrates creating a zone using the atmosphere features +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; + +var count = 0; +var stopAfter = 10000; + +var zoneEntityA = Entities.addEntity({ + type: "Zone", + position: { x: 1000, y: 1000, z: 1000}, + dimensions: { x: 2000, y: 2000, z: 2000 }, + keyLightColor: { red: 255, green: 0, blue: 0 }, + stageSunModelEnabled: false, + shapeType: "sphere", + skyboxMode: "atmosphere", + atmosphere: { + center: { x: 1000, y: 0, z: 1000}, + innerRadius: 1000.0, + outerRadius: 1025.0, + rayleighScattering: 0.0025, + mieScattering: 0.0010, + scatteringWavelengths: { x: 0.650, y: 0.570, z: 0.475 }, + hasStars: false + }, + stageLatitude: 37.777, + stageLongitude: 122.407, + stageAltitude: 0.03, + stageDay: 60, + stageHour: 0, + stageSunModelEnabled: true +}); + + +// register the call back so it fires before each data send +Script.update.connect(function(deltaTime) { + // stop it... + if (count >= stopAfter) { + print("calling Script.stop()"); + Script.stop(); + } + count++; + var newHour = (count / 10) % 24; + var newIntensity = ((count / 10) % 24) / 24; + print("newHour:" + newHour); + print("newIntensity:" + newIntensity); + + Entities.editEntity(zoneEntityA, { + skyboxMode: "atmosphere", + atmosphere: { + center: { x: 1000, y: 0, z: 1000}, + innerRadius: 1000.0, + outerRadius: 1025.0, + rayleighScattering: 0.0025, + mieScattering: 0.0010, + scatteringWavelengths: { x: 0.650, y: 0.570, z: 0.475 }, + hasStars: false + }, + stageHour: newHour, + keyLightIntensity: newIntensity + }); +}); +