Created
July 13, 2013 16:10
-
-
Save jobez/5991194 to your computer and use it in GitHub Desktop.
voodoojs 3d text object issue
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
| iView = voodoo.View.extend({ | |
| load: function() { | |
| /* | |
| TODO: Create your THREE.js objects here and | |
| add them to the scene. | |
| */ | |
| this.geometry = new THREE.OctahedronGeometry(200, 2); | |
| this.material = new THREE.MeshBasicMaterial({ | |
| wireframe: true | |
| }); | |
| this.textMaterial = new THREE.MeshNormalMaterial({ | |
| color: 0xFF0000 | |
| }); | |
| this.textGeom = new THREE.TextGeometry("3D Text", { | |
| size: 100, | |
| font: "helvetiker" | |
| }); | |
| /* errors occur when the text object is added to scene | |
| this.text = new THREE.Mesh(this.textGeometry, this.material); | |
| this.text.position.set(-250, 300, -500); | |
| */ | |
| this.octagon = new THREE.Mesh(this.geometry, this.material); | |
| this.octagon.doubleSided = true; | |
| this.octagon.position.set(500, 500, -30); | |
| this.octagon.rotation.y = Math.PI / 2; | |
| /* | |
| Add the octagon to the scene. | |
| this.scene is a property provided by View. | |
| */ | |
| this.scene.add(this.octagon); | |
| this.scene.add(this.text); | |
| return this.speed = 5; | |
| }, | |
| unload: function() { | |
| this.scene.remove(this.octagon); | |
| return this.scene.remove(this.text); | |
| /* | |
| Here we define a couple functions that the model will call. | |
| */ | |
| }, | |
| setColor: function(color) { | |
| return this.material.color.copy(voodoo.utility.convertCssColorToThreeJsColor(color)); | |
| }, | |
| move: function(deltaTime) { | |
| this.octagon.position.x += deltaTime * Session.get('x'); | |
| if (this.octagon.position.x > 800) { | |
| this.speed = -Math.abs(this.speed); | |
| return this.octagon.position.x = 800; | |
| } else if (this.octagon.position.x < 0) { | |
| this.speed = Math.abs(this.speed); | |
| return this.octagon.position.x = 0; | |
| } | |
| }, | |
| rotate: function(amount) { | |
| return this.octagon.rotation.x += 0.001; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment