mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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 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;
|
||||
}
|
||||
float brightness = (angle * 20./ (TWO_PI)) + 0.5;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// growingPlantEntityScript.js
|
||||
// examples/homeContent/
|
||||
// examples/homeContent/plant
|
||||
//
|
||||
// Created by Eric Levin on 2/10/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
|
@ -10,15 +10,23 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
||||
|
||||
(function() {
|
||||
Script.include("../../libraries/tween.js");
|
||||
|
||||
var _this;
|
||||
var TWEEN = loadTween();
|
||||
GrowingPlant = function() {
|
||||
_this = this;
|
||||
this.startingFlowerDimensions = {
|
||||
x: 0.3,
|
||||
y: 0.001,
|
||||
z: 0.3
|
||||
};
|
||||
};
|
||||
|
||||
GrowingPlant.prototype = {
|
||||
|
||||
|
||||
createLeaf: function() {
|
||||
var userData = JSON.stringify({
|
||||
ProceduralEntity: {
|
||||
|
@ -26,13 +34,35 @@
|
|||
// shaderUrl: "file:///C:/Users/Eric/hifi/examples/shaders/shaderToyWrapper.fs",
|
||||
}
|
||||
});
|
||||
this.leaf = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: Vec3.sum(this.position, {x: 0, y: this.dimensions.y/2, z: 0 }),
|
||||
color: {red: 100, green: 10, blue: 100},
|
||||
dimensions: {x: 0.3, y: 0.001, z: 0.3},
|
||||
_this.leafPosition = Vec3.sum(this.position, {
|
||||
x: 0,
|
||||
y: this.dimensions.y/2,
|
||||
z: 0
|
||||
});
|
||||
_this.leaf = Entities.addEntity({
|
||||
type: "Sphere",
|
||||
position: _this.leafPosition,
|
||||
color: {
|
||||
red: 100,
|
||||
green: 10,
|
||||
blue: 100
|
||||
},
|
||||
dimensions: _this.startingFlowerDimensions,
|
||||
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) {
|
||||
|
@ -43,6 +73,10 @@
|
|||
this.createLeaf();
|
||||
},
|
||||
|
||||
update: function() {
|
||||
|
||||
},
|
||||
|
||||
unload: function() {
|
||||
Entities.deleteEntity(this.leaf);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//
|
||||
// growingPlantSpawner.js
|
||||
// examples/homeContent/
|
||||
// examples/homeContent/plant
|
||||
//
|
||||
// Created by Eric Levin on 2/10/16.
|
||||
// Copyright 2016 High Fidelity, Inc.
|
||||
|
@ -32,7 +32,7 @@ function initializePlant() {
|
|||
Script.setTimeout(function() {
|
||||
var naturalDimensions = Entities.getEntityProperties(pot, "naturalDimensions").naturalDimensions;
|
||||
Entities.editEntity(pot, {dimensions: naturalDimensions, script: SCRIPT_URL});
|
||||
}, 2000);
|
||||
}, 100);
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue