mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:16:58 +02:00
Add all entities and skybox
This commit is contained in:
parent
170dd418f8
commit
d89d89fd08
1 changed files with 40 additions and 18 deletions
|
@ -3,8 +3,13 @@
|
||||||
//
|
//
|
||||||
// Created by Eric Levin on 3/9/2016.
|
// Created by Eric Levin on 3/9/2016.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// 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.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// 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 = Quat.safeEulerAngles(orientation);
|
||||||
orientation.x = 0;
|
orientation.x = 0;
|
||||||
orientation = Quat.fromVec3Degrees(orientation);
|
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 SHADER_URL = "https://s3-us-west-1.amazonaws.com/hifi-content/eric/shaders/rapidUniformChangeTest.fs";
|
||||||
|
|
||||||
|
|
||||||
var userData = {
|
var userData = {
|
||||||
ProceduralEntity: {
|
ProceduralEntity: {
|
||||||
shaderUrl: SHADER_URL,
|
shaderUrl: SHADER_URL,
|
||||||
uniforms: {
|
uniforms: { red: 0.0 }
|
||||||
red: 0.0
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var testEntity = Entities.addEntity({
|
var edit = JSON.stringify(userData);
|
||||||
|
var testBox = Entities.addEntity({
|
||||||
type: "Box",
|
type: "Box",
|
||||||
dimensions: {
|
dimensions: { x: 0.5, y: 0.5, z: 0.5 },
|
||||||
x: 0.5,
|
position: centerUp,
|
||||||
y: 0.5,
|
userData: edit
|
||||||
z: 0.5
|
});
|
||||||
},
|
var testSphere = Entities.addEntity({
|
||||||
position: center,
|
type: "Sphere",
|
||||||
userData: JSON.stringify(userData)
|
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) {
|
function update(deltaTime) {
|
||||||
var red = (Math.sin(currentTime) + 1) / 2;
|
var red = (Math.sin(currentTime) + 1) / 2;
|
||||||
userData.ProceduralEntity.uniforms.red = red;
|
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;
|
currentTime += deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,5 +72,8 @@ Script.update.connect(update);
|
||||||
Script.scriptEnding.connect(cleanup);
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(testEntity);
|
Entities.deleteEntity(testBox);
|
||||||
}
|
Entities.deleteEntity(testSphere);
|
||||||
|
Entities.deleteEntity(testZone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue