mirror of
https://github.com/JulianGro/overte.git
synced 2025-08-09 10:57:32 +02:00
programatically adjusting flower stretching on sphere
This commit is contained in:
parent
12561f8fcf
commit
f09dd81a14
3 changed files with 45 additions and 10 deletions
|
@ -28,7 +28,8 @@ void mainImage( out vec4 fragColor, in vec2 fragCoord ) {
|
||||||
float angle = atan(toCenter.y, toCenter.x);
|
float angle = atan(toCenter.y, toCenter.x);
|
||||||
float radius = length(toCenter) * 2.0;
|
float radius = length(toCenter) * 2.0;
|
||||||
|
|
||||||
if (radius > 0.8) {
|
// Second check is so we discard the top half of the sphere
|
||||||
|
if (radius > 0.8 || _position.y > 0) {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
float brightness = (angle * 20./ (TWO_PI)) + 0.5;
|
float brightness = (angle * 20./ (TWO_PI)) + 0.5;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// growingPlantEntityScript.js
|
// growingPlantEntityScript.js
|
||||||
// examples/homeContent/
|
// examples/homeContent/plant
|
||||||
//
|
//
|
||||||
// Created by Eric Levin on 2/10/16.
|
// Created by Eric Levin on 2/10/16.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
@ -10,15 +10,23 @@
|
||||||
// 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
Script.include("../../libraries/tween.js");
|
||||||
|
|
||||||
var _this;
|
var _this;
|
||||||
|
var TWEEN = loadTween();
|
||||||
GrowingPlant = function() {
|
GrowingPlant = function() {
|
||||||
_this = this;
|
_this = this;
|
||||||
|
this.startingFlowerDimensions = {
|
||||||
|
x: 0.3,
|
||||||
|
y: 0.001,
|
||||||
|
z: 0.3
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
GrowingPlant.prototype = {
|
GrowingPlant.prototype = {
|
||||||
|
|
||||||
createLeaf: function() {
|
createLeaf: function() {
|
||||||
var userData = JSON.stringify({
|
var userData = JSON.stringify({
|
||||||
ProceduralEntity: {
|
ProceduralEntity: {
|
||||||
|
@ -26,13 +34,35 @@
|
||||||
// shaderUrl: "file:///C:/Users/Eric/hifi/examples/shaders/shaderToyWrapper.fs",
|
// shaderUrl: "file:///C:/Users/Eric/hifi/examples/shaders/shaderToyWrapper.fs",
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.leaf = Entities.addEntity({
|
_this.leafPosition = Vec3.sum(this.position, {
|
||||||
type: "Box",
|
x: 0,
|
||||||
position: Vec3.sum(this.position, {x: 0, y: this.dimensions.y/2, z: 0 }),
|
y: this.dimensions.y/2,
|
||||||
color: {red: 100, green: 10, blue: 100},
|
z: 0
|
||||||
dimensions: {x: 0.3, y: 0.001, z: 0.3},
|
});
|
||||||
|
_this.leaf = Entities.addEntity({
|
||||||
|
type: "Sphere",
|
||||||
|
position: _this.leafPosition,
|
||||||
|
color: {
|
||||||
|
red: 100,
|
||||||
|
green: 10,
|
||||||
|
blue: 100
|
||||||
|
},
|
||||||
|
dimensions: _this.startingFlowerDimensions,
|
||||||
userData: userData
|
userData: userData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Script.setTimeout(function() {
|
||||||
|
var newDimensions = Vec3.sum(_this.startingFlowerDimensions, {
|
||||||
|
x: 0,
|
||||||
|
y: 1,
|
||||||
|
z: 0
|
||||||
|
});
|
||||||
|
var newPosition = Vec3.sum(_this.leafPosition, {x: 0, y: newDimensions.y/2, z: 0});
|
||||||
|
Entities.editEntity(_this.leaf, {
|
||||||
|
dimensions: newDimensions,
|
||||||
|
position: newPosition
|
||||||
|
});
|
||||||
|
}, 3000)
|
||||||
},
|
},
|
||||||
|
|
||||||
preload: function(entityID) {
|
preload: function(entityID) {
|
||||||
|
@ -43,6 +73,10 @@
|
||||||
this.createLeaf();
|
this.createLeaf();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update: function() {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
unload: function() {
|
unload: function() {
|
||||||
Entities.deleteEntity(this.leaf);
|
Entities.deleteEntity(this.leaf);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// growingPlantSpawner.js
|
// growingPlantSpawner.js
|
||||||
// examples/homeContent/
|
// examples/homeContent/plant
|
||||||
//
|
//
|
||||||
// Created by Eric Levin on 2/10/16.
|
// Created by Eric Levin on 2/10/16.
|
||||||
// Copyright 2016 High Fidelity, Inc.
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
@ -32,7 +32,7 @@ function initializePlant() {
|
||||||
Script.setTimeout(function() {
|
Script.setTimeout(function() {
|
||||||
var naturalDimensions = Entities.getEntityProperties(pot, "naturalDimensions").naturalDimensions;
|
var naturalDimensions = Entities.getEntityProperties(pot, "naturalDimensions").naturalDimensions;
|
||||||
Entities.editEntity(pot, {dimensions: naturalDimensions, script: SCRIPT_URL});
|
Entities.editEntity(pot, {dimensions: naturalDimensions, script: SCRIPT_URL});
|
||||||
}, 2000);
|
}, 100);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue