From f7a0316ea5a6d7234ff6eda0058050a1ada34e2c Mon Sep 17 00:00:00 2001 From: www-data Date: Mon, 28 Oct 2019 11:41:45 +0100 Subject: [PATCH] Initial Commit: 3D Project - 1 - Code - Before Render (yzoxle7tzb.js) --- yzoxle7tzb.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 yzoxle7tzb.js diff --git a/yzoxle7tzb.js b/yzoxle7tzb.js new file mode 100644 index 0000000..12daf79 --- /dev/null +++ b/yzoxle7tzb.js @@ -0,0 +1,41 @@ +var project = data; + +if (!project.loaded) { + return; +} + +/** + * Only respond to before_render events for my parent project + */ +if (project !== this.getParentProject()) { + return; +} + +if (!this.initialized) { + + /** + * Set some initialization code here + */ + this.totalTime = 0; + project.cameras[1].position.y = 10; + + this.initialized = true; +} + +if (project.applicationMode === R3.API.Project.APPLICATION_MODE_RUN) { + + this.totalTime += project.clock.delta; + + project.cameras[1].position.x = 15 * Math.sin(this.totalTime * 0.1); + project.cameras[1].position.z = 15 * Math.cos(this.totalTime * 0.1); + project.cameras[1].lookAt.x = 0; + project.cameras[1].lookAt.y = 0; + project.cameras[1].lookAt.z = 0; + + project.cameras[1].updateInstance('position'); + project.cameras[1].updateInstance('lookAt'); +} + +return null; + +//@ sourceURL=3d_project_1_code_before_render.js \ No newline at end of file