Add all entities and skybox

This commit is contained in:
Zach Pomerantz 2016-03-09 18:35:03 -08:00
parent 170dd418f8
commit d89d89fd08

View file

@ -3,8 +3,13 @@
//
// Created by Eric Levin on 3/9/2016.
// Copyright 2016 High Fidelity, Inc.
// This test creates a primitive with a fragment shader and rapidly updates its uniform values
// For the test to pass, the uniform should update at rate of update loop without the client crashing
//
// This test creates primitives with fragment shaders and rapidly updates its uniforms, as well as a skybox.
// For the test to pass:
// - The primitives (cube and sphere) should update at rate of update loop, cycling through red values.
// - The skymap should do the same, although its periodicity may be different.
//
// Under the hood, the primitives are driven by a uniform, while the skymap is driven by a timer.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -14,28 +19,38 @@ var orientation = Camera.getOrientation();
orientation = Quat.safeEulerAngles(orientation);
orientation.x = 0;
orientation = Quat.fromVec3Degrees(orientation);
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
var centerUp = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
centerUp.y += 0.5;
var centerDown = Vec3.sum(MyAvatar.position, Vec3.multiply(3, Quat.getFront(orientation)));
centerDown.y -= 0.5;
var SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/rapidUniformChangeTest.fs";
var userData = {
ProceduralEntity: {
shaderUrl: SHADER_URL,
uniforms: {
red: 0.0
}
uniforms: { red: 0.0 }
}
}
var testEntity = Entities.addEntity({
var edit = JSON.stringify(userData);
var testBox = Entities.addEntity({
type: "Box",
dimensions: {
x: 0.5,
y: 0.5,
z: 0.5
},
position: center,
userData: JSON.stringify(userData)
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
position: centerUp,
userData: edit
});
var testSphere = Entities.addEntity({
type: "Sphere",
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
position: centerDown,
userData: edit
});
var testZone = Entities.addEntity({
type: "Zone",
dimensions: { x: 3, y: 3, z: 3 },
position: MyAvatar.position,
userData: edit
});
@ -44,7 +59,11 @@ var currentTime = 0;
function update(deltaTime) {
var red = (Math.sin(currentTime) + 1) / 2;
userData.ProceduralEntity.uniforms.red = red;
Entities.editEntity(testEntity, {userData: JSON.stringify(userData)});
edit = { userData: JSON.stringify(userData) };
Entities.editEntity(testBox, edit);
Entities.editEntity(testSphere, edit);
Entities.editEntity(testZone, edit);
currentTime += deltaTime;
}
@ -53,5 +72,8 @@ Script.update.connect(update);
Script.scriptEnding.connect(cleanup);
function cleanup() {
Entities.deleteEntity(testEntity);
}
Entities.deleteEntity(testBox);
Entities.deleteEntity(testSphere);
Entities.deleteEntity(testZone);
}