Stage and seat rows builder


#1

Hi,

wanted to share a script for building a stage with amfitheater like seats

http://vkislichenko.github.io/hifi/scripts/stage/loader.js

How to use it:

  • on load it will search for existing stage (base entity)
  • if there is none in 10m radius You can press a “create icon” (on bottom right)
  • it will create a ground box (the stage) 4x4 with random color
  • now You can configure how Your seat rows will be build

Levels - how many  floors it will contain
Radius - of the circle
Rotation - from 0 to 360, rotation of the circle
Limit - from 0 to 360, controls how much of a circle to build
Blocks - how many entities will one row contain
Block Height - height of a block (y)
Block Depth - depth of block (z)
Block Gap Fix - overlap for blocks  
Block Color is Random - each row will have random color
Base Block Color - if not You can set base color in hex, it will be dimmed slightly with each level
Block Script - script that will be attached to each block, You can use this one probably http://public.highfidelity.io/scripts/entityScripts/sitOnEntity.js, but I was not able to make it work (seems like onHover event not firing)

Next, You can click on “Preview” - this will calc all blocks and draw them as a preview

if it seems ok, click on “Apply”

  • it will create all those blocks
  • save them inside stage as part of userData
  • and will stretch stage entity on Radius * 2

“Clear” will use userData of the stage to find and exterminate all blocks,
it may glitch, so I also mark each block, and by clicking Ctrl+RightMouseBtn on delete icon - You will launch extra clear (without deleting stage) - it wont look inside stage, but will search for all marked blocks in 10m radius.


#2

@dofer

This is really nice work. I love it!


#3

Hi Dofer,
This script is awesome!! I just tested a simple entity script with hoverEnterEntity and hoverOverEntity, and both events were firing correctly- I’m not sure why it wouldn’t be working for you.

I’m working on a seat manager script myself- check out https://hifi-public.s3.amazonaws.com/eric/scripts/seatManager2.js. It uses the clickReleaseOnEntity event. You might be able to use something from it.


#4

thanks,
most headache I got from figuring out how to translate real 360deg in hf 0…180…-180…0
answer is as always - as simple as it gets

Quat.fromPitchYawRollRadians(0, -1*block.rotation, 0)

@ericrius1
thanks for the script, I’ll try to make it work as default “Block Script”.

I did not debug what’s wrong with sitOnEntity.js, just that  I did not get a hover icon over the entity (might be nothing, just my PC is too slow, or something else)

One essential thing to finish - handling entity creation, seems like I need some sort of checker to wait until all new entities are identified, and only then save them inside userData.


#5

Yeah that makes sense- you know about Script.setTimeout? Works very similarly to browser’s window.setTimeout- you just pass in a callback function as first argument and time in milliseconds until that function is called as second argument. So you could do Script.setTimeout(checker, 1000) and in your checker, if all the entities are identified, save them inside userData, and if not, just set another timeout and pass ins same function as first argument again.


#6

Hi, committed updates for the script

  • added wrapper for Entity, it adds callbacks for identification, adding and loading events, and makes JSON.stringify for userData automatic
  • added Entity Identifier, to wait until all entities are identified
  • added identification progress bar inside web window
  • some other small stuff I forgot about :smile:

For known bugs - when script finds base entity, it removes data about built blocks - so You still will have to hold Ctrl + click on delete icon to clear them (if script is reloaded in any point). Will definitely fix it - not sure when thou.

Also some time some entities seems to be unable to identify, and progress bar jut hangs - don’t know reason for it, if any one have an idea, please share.

GitHub: https://github.com/vkislichenko/vkislichenko.github.io/tree/master/hifi/scripts/stage

loader script for interface: http://vkislichenko.github.io/hifi/scripts/stage/loader.js


#7

@dofer This is awesome! I love the preview in the WebView. It’s great to see someone else using WebViews + the EventBridge - it’s not documented anywhere so it’s doubly impressive.

I’m looking forward to seeing what you do next!