Created
March 15, 2021 06:36
-
-
Save yosun/d77343fd6ddbe9374e852b90b5e17703 to your computer and use it in GitHub Desktop.
#SundayHackDay realityScript Snippet for ChakrAR
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* realityScript is a high-level language I created for rapidly prototyping AR apps in | |
high-pressure time constraint settings such as hackathons. Due to sleep-loss, I think | |
in stream of consciousness and so daisy-chaining is key (but I am also very oldskool and love jQuery)...*/ | |
// 0) prepare an Object3D called "ChakraSet" that has the 7 chakras named "red", "orange," | |
$("#ChakraSet").AddTags(this.each(),"Chakra"); | |
// 1a) Define chakra symbol textures | |
var dicChakra = {}; | |
dicChakra["red"]="muladhara.png"; | |
dicChakra["orange"]="swadhisthana.png"; | |
dicChakra["yellow"]="manipura.png"; | |
dicChakra["green"]="anahata.png"; | |
dicChakra["blue"]="vishuddha.png"; | |
dicChakra["indigo"]="ajna.png"; | |
dicChakra["violet"]="sahasrara.png"; | |
// 1b) Define the bones to attach each to | |
var dicBones = {}; | |
dicBones["red"]="Hips="; | |
dicBones["orange"]="Spine4"; | |
dicBones["yellow"]="Spine6"; | |
dicBones["green"]="Spine7"; | |
dicBones["blue"]="Neck1"; | |
dicBones["indigo"]="Head"; | |
dicBones["violet"]="Nose"; | |
// 2) When body is found, attach each chakra to the right bone name | |
$(".Trackable .HumanBody3D").Mesh("#DefaultBody").AttachChild("ChakraSet",dicBones,MatchKey.Bones); | |
// 3) loops thru each element of ChakraSet to create a sphere collider | |
$("#ChakraSet").CreateColliders(this.each(),Colliders.Sphere); | |
function Update(){ | |
RaycastHit hit = new RaycastHit(Input.mousePosition); | |
if(hit.transform.tag == "Chakra"){ | |
DisplaySymbol(hit.transform.name); | |
} | |
} | |
function DisplaySymbol(chakra){ | |
$("#UIButton_ChakraSymbol").AssignSprite(dicChakra[chakra]); | |
$("#Animation_Glow").AttachChild(dicBones[chakra]).SetLocalPos(Vector3.zero); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment