mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-15 11:29:38 +02:00
modularizing flow art tools
This commit is contained in:
parent
fcfa396912
commit
b29a6b16a9
2 changed files with 194 additions and 122 deletions
77
examples/flowArts/flowArtsHutSpawner.js
Normal file
77
examples/flowArts/flowArtsHutSpawner.js
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
//
|
||||||
|
// flowArtsHutSpawner.js
|
||||||
|
// examples
|
||||||
|
//
|
||||||
|
// Created by Eric Levin on 5/14/15.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This script creates a special flow arts hut with a numch of flow art toys people can go in and play with
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
|
Script.include("lightBall/lightBallSpawner.js");
|
||||||
|
|
||||||
|
var basePosition = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||||
|
basePosition.y = MyAvatar.position.y + 1
|
||||||
|
var lightBall = LightBallSpawner(basePosition);
|
||||||
|
var modelURL = "file:///C:/Users/Eric/Desktop/RaveRoom.fbx?v1" + Math.random();
|
||||||
|
|
||||||
|
var roomDimensions = {x: 30.58, y: 15.29, z: 30.58};
|
||||||
|
|
||||||
|
var raveRoom = Entities.addEntity({
|
||||||
|
type: "Model",
|
||||||
|
modelURL: modelURL,
|
||||||
|
position: basePosition,
|
||||||
|
dimensions:roomDimensions,
|
||||||
|
visible: true
|
||||||
|
});
|
||||||
|
|
||||||
|
var floor = Entities.addEntity({
|
||||||
|
type: "Box",
|
||||||
|
position: Vec3.sum(basePosition, {x: 0, y: -1.5, z: 0}),
|
||||||
|
dimensions: {x: roomDimensions.x, y: 0.6, z: roomDimensions.z},
|
||||||
|
color: {red: 50, green: 10, blue: 100},
|
||||||
|
shapeType: 'box'
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var lightZone = Entities.addEntity({
|
||||||
|
type: "Zone",
|
||||||
|
shapeType: 'box',
|
||||||
|
keyLightIntensity: 0.2,
|
||||||
|
keyLightColor: {
|
||||||
|
red: 50,
|
||||||
|
green: 0,
|
||||||
|
blue: 50
|
||||||
|
},
|
||||||
|
keyLightAmbientIntensity: .2,
|
||||||
|
position: MyAvatar.position,
|
||||||
|
dimensions: {
|
||||||
|
x: 100,
|
||||||
|
y: 100,
|
||||||
|
z: 100
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
|
||||||
|
Entities.deleteEntity(raveRoom);
|
||||||
|
Entities.deleteEntity(lightZone)
|
||||||
|
Entities.deleteEntity(floor);
|
||||||
|
lightBall.cleanup();
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
|
@ -1,28 +1,32 @@
|
||||||
|
Script.include("../../libraries/utils.js");
|
||||||
|
|
||||||
Script.include("../../libraries/utils.js");
|
LightBallSpawner = function(basePosition) {
|
||||||
|
|
||||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
var modelURL = "file:///C:/Users/Eric/Desktop/RaveRoom.fbx?v1" + Math.random();
|
||||||
var modelURL = "file:///C:/Users/Eric/Desktop/RaveRoom.fbx?v1" + Math.random();
|
var colorPalette = [{
|
||||||
|
|
||||||
var raveRoom = Entities.addEntity({
|
|
||||||
type: "Model",
|
|
||||||
modelURL: modelURL,
|
|
||||||
position: center,
|
|
||||||
visible:false
|
|
||||||
});
|
|
||||||
|
|
||||||
var colorPalette = [{
|
|
||||||
red: 25,
|
red: 25,
|
||||||
green: 20,
|
green: 20,
|
||||||
blue: 162
|
blue: 162
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|
||||||
var containerBall = Entities.addEntity({
|
var containerBall = Entities.addEntity({
|
||||||
type: "Sphere",
|
type: "Sphere",
|
||||||
position: center,
|
position: Vec3.sum(basePosition, {
|
||||||
dimensions: {x: .1, y: .1, z: .1},
|
x: 0,
|
||||||
color: {red: 15, green: 10, blue: 150},
|
y: .5,
|
||||||
|
z: 0
|
||||||
|
}),
|
||||||
|
dimensions: {
|
||||||
|
x: .1,
|
||||||
|
y: .1,
|
||||||
|
z: .1
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 15,
|
||||||
|
green: 10,
|
||||||
|
blue: 150
|
||||||
|
},
|
||||||
collisionsWillMove: true,
|
collisionsWillMove: true,
|
||||||
userData: JSON.stringify({
|
userData: JSON.stringify({
|
||||||
grabbableKey: {
|
grabbableKey: {
|
||||||
|
@ -36,30 +40,11 @@ var containerBall = Entities.addEntity({
|
||||||
invertSolidWhileHeld: true
|
invertSolidWhileHeld: true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// gravity: {x: 0, y: -.1, z: 0}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
var lightZone = Entities.addEntity({
|
|
||||||
type: "Zone",
|
|
||||||
shapeType: 'box',
|
|
||||||
keyLightIntensity: 0.2,
|
|
||||||
keyLightColor: {
|
|
||||||
red: 50,
|
|
||||||
green: 0,
|
|
||||||
blue: 50
|
|
||||||
},
|
|
||||||
keyLightAmbientIntensity: .2,
|
|
||||||
position: MyAvatar.position,
|
|
||||||
dimensions: {
|
|
||||||
x: 100,
|
|
||||||
y: 100,
|
|
||||||
z: 100
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var light = Entities.addEntity({
|
var light = Entities.addEntity({
|
||||||
type: 'Light',
|
type: 'Light',
|
||||||
position: center,
|
|
||||||
parentID: containerBall,
|
parentID: containerBall,
|
||||||
dimensions: {
|
dimensions: {
|
||||||
x: 30,
|
x: 30,
|
||||||
|
@ -71,15 +56,26 @@ var light = Entities.addEntity({
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var lightBall = Entities.addEntity({
|
var lightBall = Entities.addEntity({
|
||||||
position: center,
|
|
||||||
type: "ParticleEffect",
|
type: "ParticleEffect",
|
||||||
parentID: containerBall,
|
parentID: containerBall,
|
||||||
isEmitting: true,
|
isEmitting: true,
|
||||||
"name": "ParticlesTest Emitter",
|
"name": "ParticlesTest Emitter",
|
||||||
"colorStart": {red: 200, green: 20, blue: 40},
|
"colorStart": {
|
||||||
color: {red: 200, green: 200, blue: 255},
|
red: 200,
|
||||||
"colorFinish": {red: 25, green: 20, blue:255},
|
green: 20,
|
||||||
|
blue: 40
|
||||||
|
},
|
||||||
|
color: {
|
||||||
|
red: 200,
|
||||||
|
green: 200,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
|
"colorFinish": {
|
||||||
|
red: 25,
|
||||||
|
green: 20,
|
||||||
|
blue: 255
|
||||||
|
},
|
||||||
"maxParticles": 100000,
|
"maxParticles": 100000,
|
||||||
"lifespan": 5,
|
"lifespan": 5,
|
||||||
"emitRate": 5000,
|
"emitRate": 5000,
|
||||||
|
@ -114,16 +110,15 @@ var lightBall = Entities.addEntity({
|
||||||
"alphaFinish": 0.5,
|
"alphaFinish": 0.5,
|
||||||
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
"textures": "https://hifi-public.s3.amazonaws.com/alan/Particles/Particle-Sprite-Smoke-1.png",
|
||||||
emitterShouldTrail: true
|
emitterShouldTrail: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function cleanup() {
|
function cleanup() {
|
||||||
Entities.deleteEntity(lightBall);
|
Entities.deleteEntity(lightBall);
|
||||||
Entities.deleteEntity(containerBall);
|
Entities.deleteEntity(containerBall);
|
||||||
Entities.deleteEntity(raveRoom);
|
|
||||||
Entities.deleteEntity(lightZone)
|
|
||||||
Entities.deleteEntity(light);
|
Entities.deleteEntity(light);
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(cleanup);
|
this.cleanup = cleanup;
|
||||||
|
}
|
Loading…
Reference in a new issue