Created
October 18, 2019 04:07
-
-
Save Sgeo/155fd3609d845f2c3c9db1ae0ab37c69 to your computer and use it in GitHub Desktop.
X_ITE SharedObjects
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
[ | |
{ | |
"name": "5000 EXP Trophy", | |
"id": "5000exp", | |
"url": "/dbobjects/5000/5000exp.wrl", | |
"position": {"x": 0.0, "y": 1.75, "z": 0.0}, | |
"rotation": {"x": 0.0, "y": 1.0, "z": 0.0, "angle": 0.0} | |
} | |
] |
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
(function() { | |
function addSO(browser, obj) { | |
let sharedObject = browser.currentScene.createProto("SharedObject"); | |
sharedObject.name = obj.name; | |
sharedObject.id = obj.id; | |
sharedObject.translation = new X3D.SFVec3f(obj.position.x, obj.position.y, obj.position.z); | |
sharedObject.rotation = new X3D.SFRotation(obj.rotation.x, obj.rotation.y, obj.rotation.z, obj.rotation.angle); | |
let inline = browser.currentScene.createNode("Inline"); | |
inline.url = new X3D.MFString(obj.url); | |
sharedObject.children[0] = inline; | |
browser.currentScene.addRootNode(sharedObject); | |
} | |
X3D(function() { | |
let browser = X3D.getBrowser(); | |
browser.addBrowserCallback(null, async function(eventType) { | |
console.log(eventType); | |
if(eventType === X3D.X3DConstants.INITIALIZED_EVENT) { | |
let SOs = await fetch("SOs.json").then(resp => resp.json()); | |
for(sharedObject of SOs) { | |
addSO(browser, sharedObject); | |
} | |
} | |
}); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment