Created
October 31, 2018 07:20
-
-
Save robertlugg/a5161200998092ddf69cb7393f7efcc0 to your computer and use it in GitHub Desktop.
Lens Studio scene object hierarchy
This file contains 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
// -----JS CODE----- | |
function showProps(obj, pre) { | |
pre = pre || '' | |
var result = ''; | |
result += pre + "Properties\n"; | |
for (var i in obj) { | |
if (obj.hasOwnProperty(i)) { | |
result += pre + ' .' + i + ' = ' + obj[i] + '\n'; | |
} | |
} | |
result += pre + "Inherited Properties\n"; | |
for (var i in obj) { | |
if (!obj.hasOwnProperty(i)) { | |
result += pre + ' .' + i + ' = ' + obj[i] + '\n'; | |
} | |
} | |
return result; | |
} | |
function showComponent(component, pre) { | |
pre = pre || '' | |
var out = ''; | |
out += pre + component.getTypeName() + "\n"; | |
out += showProps(component, pre + ' '); | |
return out; | |
} | |
function showSceneObject(obj, pre) { | |
pre = pre || '' | |
var out = ''; | |
out += pre + obj.name + " (" + obj.getTypeName() + ")\n"; | |
out += showProps(obj, pre + ' ') | |
var componentCount = obj.getComponentCount(''); | |
if (componentCount) { | |
out += pre + " Components:\n" | |
for(var i=0; i < componentCount; i++) { | |
var thisComponent = obj.getComponentByIndex('', i); | |
out += showComponent(thisComponent, pre + ' '); | |
} | |
} | |
var childCount = obj.getChildrenCount(); | |
if (childCount) { | |
out += pre + " Children:\n" | |
for(var i=0; i < childCount; i++) { | |
var thisChild = obj.getChild(i); | |
out += showSceneObject(thisChild, pre + ' '); | |
} | |
} | |
return out; | |
} | |
function showScene(scene) { | |
var out = '---\n'; | |
out += "core version: " + global.getCoreVersion().toString() + '\n'; | |
var childCount = scene.getRootObjectsCount() | |
for(var i = 0; i < childCount; i++) { | |
var obj = scene.getRootObject(i); | |
out += showSceneObject(obj, ''); | |
} | |
return out | |
} | |
print(showScene(scene)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm glad that this is useful. I'd encourage anyone reading this message to use @positlabs ' gist instead...better than mine in several ways.