List of usage examples for com.google.gwt.user.client Timer Timer
Timer
From source file:com.akjava.gwt.threetest.client.AngleDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { super.start(renderer, width, height, panel); final Scene scene = THREE.Scene(); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); camera.getPosition().set(0, 0, 100); scene.add(camera);//from w ww. j a v a 2s . c o m Light pointLight = THREE.PointLight(0xffffff); pointLight.setPosition(0, 10, 300); scene.add(pointLight); root = THREE.Object3D(); scene.add(root); rootMesh = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(0x0000ff).build()); root.add(rootMesh); Mesh mesh1 = THREE.Mesh(THREE.CubeGeometry(1, 1, 1), THREE.MeshBasicMaterial().color(0x00ff00).build()); mesh1.setPosition(targetPos); root.add(mesh1); root.add(GWTGeometryUtils.createLineMesh(root.getPosition(), targetPos, 0xcccccc)); Mesh mesh2 = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(0xff0000).build()); mesh2.setPosition(jointPos); root.add(mesh2); root.add(GWTGeometryUtils.createLineMesh(root.getPosition(), jointPos, 0xcccccc)); log("joint-angle:" + ThreeLog.get(posToDegreeAngle(jointPos))); log("target-angle:" + ThreeLog.get(posToDegreeAngle(targetPos))); //DO-X double angleXJoint = Math.atan2(jointPos.getZ(), jointPos.getY()); double angleXTarget = Math.atan2(targetPos.getZ(), targetPos.getY()); log("target-angle:" + Math.toDegrees(angleXTarget)); double diffX = angleXTarget - angleXJoint; Matrix4 mxX = GWTThreeUtils.rotationToMatrix4(THREE.Vector3(diffX, 0, 0)); Vector3 newPosX = jointPos.clone(); mxX.multiplyVector3(newPosX); Mesh meshX = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(0x00ffff).build()); meshX.setPosition(newPosX); double angleXMovec = Math.atan2(newPosX.getZ(), newPosX.getY()); log("newpos-angle:" + Math.toDegrees(angleXMovec)); root.add(meshX); //root.add(GWTGeometryUtils.createLineMesh(root.getPosition(), newPosX, 0xcccccc)); log("angleX-moved:" + ThreeLog.get(posToDegreeAngle(newPosX))); //DO-Y double angleYJoint = Math.atan2(newPosX.getX(), newPosX.getZ()); double angleYTarget = Math.atan2(targetPos.getX(), targetPos.getZ()); log("target-angleY:" + Math.toDegrees(angleYTarget)); double diffY = angleYTarget - angleYJoint; Matrix4 mxY = GWTThreeUtils.rotationToMatrix4(THREE.Vector3(0, diffY, 0)); Vector3 newPosY = newPosX.clone(); mxY.multiplyVector3(newPosY); Mesh meshY = THREE.Mesh(THREE.CubeGeometry(.75, .75, .75), THREE.MeshBasicMaterial().color(0x00ffff).build()); meshY.setPosition(newPosY); double angleYMoved = Math.atan2(newPosY.getX(), newPosY.getZ()); log("newpos-angle:" + Math.toDegrees(angleYMoved)); root.add(meshY); //root.add(GWTGeometryUtils.createLineMesh(root.getPosition(), newPosY, 0xcccccc)); log("angleY-moved:" + ThreeLog.get(posToDegreeAngle(newPosY))); //DO-Z double angleJoint = Math.atan2(newPosY.getY(), newPosY.getX()); double angleTarget = Math.atan2(targetPos.getY(), targetPos.getX()); log("target-angle:Z" + Math.toDegrees(angleTarget)); double diff = angleTarget - angleJoint; Matrix4 mx = GWTThreeUtils.rotationToMatrix4(THREE.Vector3(0, 0, diff)); Vector3 newPosZ = newPosY.clone(); mx.multiplyVector3(newPosZ); Mesh meshZ = THREE.Mesh(THREE.CubeGeometry(1, 1, 1), THREE.MeshBasicMaterial().color(0x00ffff).build()); meshZ.setPosition(newPosZ); double angleZNew = Math.atan2(newPosZ.getY(), newPosZ.getX()); log("newpos-angle:" + Math.toDegrees(angleZNew)); root.add(meshZ); root.add(GWTGeometryUtils.createLineMesh(root.getPosition(), newPosZ, 0xcccccc)); log("angleZ-moved:" + ThreeLog.get(posToDegreeAngle(newPosZ))); Vector3 diffAngle = getTwoPointAngle(jointPos, targetPos); log("diff-angle:" + ThreeLog.get(GWTThreeUtils.radiantToDegree(diffAngle))); Mesh meshFinal = THREE.Mesh(THREE.CubeGeometry(1, 1, 1), THREE.MeshBasicMaterial().color(0x333333).build()); Vector3 jAngle = getPointAngle(jointPos); log("jAngle:" + ThreeLog.get(GWTThreeUtils.radiantToDegree(jAngle))); Vector3 finalPos = jointPos.clone(); log("final-pos:" + ThreeLog.get(finalPos)); Vector3 jointAngle = GWTThreeUtils.degreeToRagiant(posToDegreeAngle(jointPos)); log("jposAngle:" + ThreeLog.get(GWTThreeUtils.radiantToDegree(jointAngle))); diffAngle.addSelf(jAngle); Matrix4 finalMatrix = GWTThreeUtils.rotationToMatrix4(diffAngle); log(GWTThreeUtils.rotationToMatrix4(diffAngle)); /* Matrix4 mX=GWTThreeUtils.rotationToMatrix4(THREE.Vector3(diffAngle.getX(), 0, 0)); Matrix4 mY=GWTThreeUtils.rotationToMatrix4(THREE.Vector3(0, diffAngle.getY(), 0)); Matrix4 mZ=GWTThreeUtils.rotationToMatrix4(THREE.Vector3(0, 0, diffAngle.getZ())); mX.multiplySelf(mY); mX.multiplySelf(mZ); log(mX); */ //Vector3 atanAngle=getAtanAngle(jointPos,targetPos); //log("atanAngle:"+ThreeLog.get(GWTThreeUtils.radiantToDegree(atanAngle))); //Matrix4 atanMatrix=GWTThreeUtils.rotationToMatrix4(atanAngle); finalMatrix.multiplyVector3(finalPos); meshFinal.setPosition(finalPos); //meshFinal.setRotation(GWTThreeUtils.degreeToRagiant(newAngle)); root.add(meshFinal); Vector3 mAngle = getPointAngle(targetPos); Matrix4 mmx = GWTThreeUtils.rotationToMatrix4(mAngle); Vector3 line = THREE.Vector3(0, 15, 0); mmx.multiplyVector3(line); Mesh mm = THREE.Mesh(THREE.CubeGeometry(1, 1, 1), THREE.MeshBasicMaterial().color(0x888888).build()); root.add(mm); mm.setPosition(line); timer = new Timer() { public void run() { root.setRotation(Math.toRadians(angleX), Math.toRadians(angleY), Math.toRadians(0)); renderer.render(scene, camera); } }; timer.scheduleRepeating(1000 / 60); }
From source file:com.akjava.gwt.threetest.client.BoneDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { super.start(renderer, width, height, panel); final Scene scene = THREE.Scene(); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); cameraControle.setPositionZ(50);//from w w w. j a v a 2s .co m scene.add(camera); Light pointLight = THREE.PointLight(0xffffff); pointLight.setPosition(0, 10, 300); scene.add(pointLight); root = THREE.Object3D(); scene.add(root); targetMesh = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(0x0000ff).build()); root.add(targetMesh); targetMesh.setPosition(targetPos); joints = new ArrayList<Object3D>(); Object3D parent = THREE.Object3D(); joints.add(parent); root.add(parent); for (int i = 0; i < 4; i++) { int color = 0xff0000; if (i == 3) { color = 0x00ff00; } if (i == 3) { hand = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(color).build()); parent.add(hand); Vector3 pos = THREE.Vector3(2, 0, 0); hand.setPosition(pos); parent.add(GWTGeometryUtils.createLineMesh(THREE.Vector3(), pos, 0x888888)); } else { final Mesh mesh = THREE.Mesh(THREE.CubeGeometry(.5, .5, .5), THREE.MeshBasicMaterial().color(color).build()); parent.add(mesh); Vector3 pos = THREE.Vector3(2, 0, 0); mesh.setPosition(pos); parent.add(GWTGeometryUtils.createLineMesh(THREE.Vector3(), pos, 0x888888)); Object3D joint = THREE.Object3D(); joint.setPosition(pos); joints.add(joint); parent.add(joint); parent = joint; } } panel.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (!steping) { Vector3 tpos = GWTThreeUtils.toWebGLXY(event.getX(), event.getY(), camera, width, height); tpos.setZ(0); targetPos = tpos; targetMesh.setPosition(targetPos); //log(ret); steped = 0; steping = true; } } }); /* */ last = System.currentTimeMillis(); Timer timer = new Timer() { public void run() { MainWidget.stats.update(); camera.setPosition(cameraControle.getPositionX(), cameraControle.getPositionY(), cameraControle.getPositionZ()); //not allow rotation.this version not good at rotation. //root.setRotation(cameraControle.getRagiantRotattionX(), cameraControle.getRagiantRotattionY(), cameraControle.getRagiantRotattionZ()); renderer.render(scene, camera); if (steping) { long c = System.currentTimeMillis(); if (last + 100 < c) { doStep(); steped++; if (steped == 20) { steping = false; } last = c; } } } }; startTimer(timer); }
From source file:com.akjava.gwt.threetest.client.BoxDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { super.start(renderer, width, height, panel); final Scene scene = THREE.Scene(); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); scene.add(camera);//from w ww. jav a2s. c o m cameraControle.setPositionZ(20); final Mesh mesh = THREE.Mesh(THREE.CubeGeometry(5, 5, 5), THREE.MeshLambertMaterial().color(0xff0000).build()); scene.add(mesh); final Light light = THREE.PointLight(0xffffff); light.setPosition(10, 0, 10); scene.add(light); Timer timer = new Timer() { public void run() { MainWidget.stats.update(); camera.setPosition(cameraControle.getPositionX(), cameraControle.getPositionY(), cameraControle.getPositionZ()); mesh.setRotation(cameraControle.getRadiantRotationX(), cameraControle.getRadiantRotationY(), cameraControle.getRadiantRotationZ()); renderer.render(scene, camera); } }; startTimer(timer); }
From source file:com.akjava.gwt.threetest.client.CanvasDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { super.start(renderer, width, height, panel); canvas = Canvas.createIfSupported(); canvas.setCoordinateSpaceWidth(100); canvas.setCoordinateSpaceHeight(100); canvas.getContext2d().setFillStyle("#cccccc"); canvas.getContext2d().fillRect(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight()); canvas.getContext2d().strokeText("Hello World", 25, 25); String url = canvas.toDataUrl(); Image img = new Image(url); ImageElement imageElement = ImageElement.as(img.getElement()); Texture texture = THREE.Texture(imageElement); texture.setNeedsUpdate(true);// w w w. ja v a 2 s.c o m final Scene scene = THREE.Scene(); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); scene.add(camera); cameraControle.setPositionZ(20); final Mesh mesh = THREE.Mesh(THREE.CubeGeometry(5, 5, 5), THREE.MeshLambertMaterial().map(texture).build()); scene.add(mesh); final Light light = THREE.PointLight(0xffffff); light.setPosition(10, 0, 10); scene.add(light); Timer timer = new Timer() { public void run() { MainWidget.stats.update(); camera.setPosition(cameraControle.getPositionX(), cameraControle.getPositionY(), cameraControle.getPositionZ()); mesh.setRotation(cameraControle.getRadiantRotationX(), cameraControle.getRadiantRotationY(), cameraControle.getRadiantRotationZ()); renderer.render(scene, camera); } }; startTimer(timer); }
From source file:com.akjava.gwt.threetest.client.CylinderDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { if (timer != null) { timer.cancel();/* ww w .j a v a 2 s .c o m*/ timer = null; } //renderer.setClearColorHex(0xff0000, 0.5); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); camera.getPosition().set(0, 0, 50); final Scene scene = THREE.Scene(); final Mesh mesh = THREE.Mesh(THREE.CylinderGeometry(5, 5, 5, 6), THREE.MeshLambertMaterial(0xff0000, false)); scene.add(mesh); final Mesh mesh2 = THREE.Mesh(THREE.CylinderGeometry(5, 5, 5, 15), THREE.MeshLambertMaterial(0x00ff00, false)); mesh2.setPosition(0, 10, 0); scene.add(mesh2); final Mesh mesh3 = THREE.Mesh(THREE.CylinderGeometry(5, 1, 5, 15), THREE.MeshLambertMaterial(0x0000ff, false)); mesh3.setPosition(0, -10, 0); scene.add(mesh3); final Mesh mesh4 = THREE.Mesh(THREE.CylinderGeometry(5, 4.5, 5, 5), THREE.MeshLambertMaterial(0xffffff, false)); mesh4.setPosition(-10, 0, 0); scene.add(mesh4); final Light light = THREE.PointLight(0xffffff); light.setPosition(10, 0, 10); scene.add(light); scene.add(THREE.AmbientLight(0x330000)); timer = new Timer() { public void run() { mesh.getRotation().incrementX(0.02); mesh.getRotation().incrementY(0.02); renderer.render(scene, camera); } }; timer.scheduleRepeating(1000 / 60); }
From source file:com.akjava.gwt.threetest.client.DragDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { super.start(renderer, width, height, panel); scene = THREE.Scene();/* w ww. ja v a 2s.c o m*/ camera = THREE.PerspectiveCamera(70, (double) width / height, 1, 10000); scene.add(camera); root = THREE.Object3D(); scene.add(root); root.add(GWTGeometryUtils.createLineMesh(THREE.Vector3(0, -2000, 0), THREE.Vector3(0, 2000, 0), 0x00ff00)); Mesh ground = THREE.Mesh(THREE.PlaneGeometry(100, 100, 50, 50), THREE.MeshBasicMaterial().color(0x888888).wireFrame().build()); ground.setRotation(Math.toRadians(-90), 0, 0); ground.setPosition(0, -5, 0); root.add(ground); Light pointLight = THREE.PointLight(0xffffff); pointLight.setPosition(0, 100, 100); root.add(pointLight); dragObjectControler = new GWTDragObjectControler(scene, projector); Object3D mesh = THREE.Mesh(THREE.CubeGeometry(10, 10, 10), THREE.MeshLambertMaterial().color(0x00ff00).build()); root.add(mesh); meshs.push(mesh); Timer timer = new Timer() { public void run() { MainWidget.stats.update(); camera.setPosition(cameraControle.getPositionX(), cameraControle.getPositionY(), cameraControle.getPositionZ()); root.setRotation(cameraControle.getRadiantRotationX(), cameraControle.getRadiantRotationY(), cameraControle.getRadiantRotationZ()); renderer.render(scene, camera); } }; startTimer(timer); }
From source file:com.akjava.gwt.threetest.client.ExplotionDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { if (timer != null) { timer.cancel();//from ww w . j a v a 2 s . co m timer = null; } renderer.setClearColorHex(0x333333, 1); renderer.setShadowMapEnabled(true); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); camera.getPosition().set(0, 0, 0); final Scene scene = THREE.Scene(); final Light light = THREE.SpotLight(0xffffff); light.setPosition(100, 200, 150);//light.setPosition(5,5, 5); light.setCastShadow(true); scene.add(light); //scene.add(THREE.AmbientLight(0x888888)); final Mesh root = THREE.Mesh(THREE.PlaneGeometry(36, 36), THREE.MeshLambertMaterial().color(0x00ee88).build()); scene.add(root); mesh = root; final List<Block> blocks = new ArrayList<Block>(); for (int i = 0; i < 100; i++) { Block block = new Block(root); blocks.add(block); } root.setRotation(Math.toDegrees(45), Math.toDegrees(45), Math.toDegrees(-45)); MainWidget.cameraRotation.setX(-45); MainWidget.cameraRotation.setZ(45); // MainWidget.cameraMove.setZ(-20); MainWidget.cameraMove.setZ(75); // MainWidget.cameraRotation.setX(-90); timer = new Timer() { public void run() { MainWidget.stats.update(); try { for (Block block : blocks) { block.update(); } camera.setPosition(MainWidget.cameraMove.getX(), MainWidget.cameraMove.getY(), MainWidget.cameraMove.getZ()); mesh.setRotation(Math.toRadians(MainWidget.cameraRotation.getX()), Math.toRadians(MainWidget.cameraRotation.getY()), Math.toRadians(MainWidget.cameraRotation.getZ())); //cancel(); if (mesh != null) { //mesh.getRotation().incrementZ(0.02); //mesh.getRotation().incrementZ(0.02); } renderer.render(scene, camera); } catch (Exception e) { GWT.log(e.getMessage()); } } }; //timer.schedule(2000); timer.scheduleRepeating(1000 / 60); }
From source file:com.akjava.gwt.threetest.client.ExplotionDemo2.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { if (timer != null) { timer.cancel();/*w w w . j a v a2 s. c o m*/ timer = null; } renderer.setClearColorHex(0x333333, 1); renderer.setShadowMapEnabled(true); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); camera.getPosition().set(0, 0, 0); final Scene scene = THREE.Scene(); final Light light = THREE.SpotLight(0xffffff); light.setPosition(100, 200, 150);//light.setPosition(5,5, 5); light.setCastShadow(true); scene.add(light); //scene.add(THREE.AmbientLight(0x888888)); final Mesh root = THREE.Mesh(THREE.PlaneGeometry(36, 36), THREE.MeshLambertMaterial().color(0x00ee88).build()); scene.add(root); mesh = root; final Geometry particles = THREE.Geometry(); final List<Block> blocks = new ArrayList<Block>(); for (int i = 0; i < 3000; i++) { Block block = new Block(particles); blocks.add(block); } Material material = THREE.ParticleBasicMaterial().color(0xff0000).size(2) .map(ImageUtils.loadTexture("img/particle.png")).blending(THREE.AdditiveBlending).transparent(true) .build(); final ParticleSystem particleSystem = THREE.ParticleSystem(particles, material); particleSystem.setSortParticles(true); root.add(particleSystem); root.setRotation(Math.toDegrees(45), Math.toDegrees(45), Math.toDegrees(-45)); MainWidget.cameraRotation.setX(-45); MainWidget.cameraRotation.setZ(45); // MainWidget.cameraMove.setZ(-20); MainWidget.cameraMove.setZ(75); // MainWidget.cameraRotation.setX(-90); timer = new Timer() { public void run() { MainWidget.stats.update(); try { for (Block block : blocks) { block.update(); } camera.setPosition(MainWidget.cameraMove.getX(), MainWidget.cameraMove.getY(), MainWidget.cameraMove.getZ()); mesh.setRotation(Math.toRadians(MainWidget.cameraRotation.getX()), Math.toRadians(MainWidget.cameraRotation.getY()), Math.toRadians(MainWidget.cameraRotation.getZ())); particles.setDirtyVertices(true); //cancel(); if (mesh != null) { //mesh.getRotation().incrementZ(0.02); //mesh.getRotation().incrementZ(0.02); } renderer.render(scene, camera); } catch (Exception e) { GWT.log(e.getMessage()); } } }; //timer.schedule(2000); timer.scheduleRepeating(1000 / 60); }
From source file:com.akjava.gwt.threetest.client.ExplotionDemo3.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { if (timer != null) { timer.cancel();/*ww w . ja v a 2 s .c om*/ timer = null; } renderer.setClearColorHex(0x333333, 1); renderer.setShadowMapEnabled(true); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); camera.getPosition().set(0, 0, 0); final Scene scene = THREE.Scene(); final Light light = THREE.SpotLight(0xffffff); light.setPosition(100, 200, 150);//light.setPosition(5,5, 5); //light.setCastShadow(true); scene.add(light); //scene.add(THREE.AmbientLight(0x888888)); final Mesh root = THREE.Mesh(THREE.PlaneGeometry(36, 36), THREE.MeshLambertMaterial().color(0x00ee88).build()); scene.add(root); mesh = root; final Geometry particles = THREE.Geometry(); final List<Block> blocks = new ArrayList<Block>(); for (int i = 0; i < 100; i++) { Block block = new Block(root); blocks.add(block); } final List<Block2> blocks2 = new ArrayList<Block2>(); for (int i = 0; i < 3200; i++) { Block2 block = new Block2(particles); blocks2.add(block); } //*factor //color //size //particle-size //blending //transparent? //sort //texture Material material = THREE.ParticleBasicMaterial().color(0x888888).size(15) .map(ImageUtils.loadTexture("img/particle7.png")).blending(THREE.NormalBlending).transparent(true) .build(); final ParticleSystem particleSystem = THREE.ParticleSystem(particles, material); particleSystem.setSortParticles(true); root.add(particleSystem); root.setRotation(Math.toDegrees(45), Math.toDegrees(45), Math.toDegrees(-45)); MainWidget.cameraRotation.setX(-45); MainWidget.cameraRotation.setZ(45); // MainWidget.cameraMove.setZ(-20); MainWidget.cameraMove.setZ(75); // MainWidget.cameraRotation.setX(-90); timer = new Timer() { public void run() { MainWidget.stats.update(); try { for (Block block : blocks) { block.update(); } for (Block2 block : blocks2) { block.update(); } camera.setPosition(MainWidget.cameraMove.getX(), MainWidget.cameraMove.getY(), MainWidget.cameraMove.getZ()); mesh.setRotation(Math.toRadians(MainWidget.cameraRotation.getX()), Math.toRadians(MainWidget.cameraRotation.getY()), Math.toRadians(MainWidget.cameraRotation.getZ())); particles.setDirtyVertices(true); //cancel(); if (mesh != null) { //mesh.getRotation().incrementZ(0.02); //mesh.getRotation().incrementZ(0.02); } renderer.render(scene, camera); } catch (Exception e) { GWT.log(e.getMessage()); } } }; //timer.schedule(2000); timer.scheduleRepeating(1000 / 60); }
From source file:com.akjava.gwt.threetest.client.LoadObjDemo.java
License:Apache License
@Override public void start(final WebGLRenderer renderer, final int width, final int height, FocusPanel panel) { if (timer != null) { timer.cancel();/*w w w.j av a 2s . c om*/ timer = null; } renderer.setClearColorHex(0xcccccc, 1); final Scene scene = THREE.Scene(); final Camera camera = THREE.PerspectiveCamera(35, (double) width / height, .1, 10000); scene.add(camera); JSONLoader loader = THREE.JSONLoader(); loader.load("models/animation.js", new LoadHandler() { @Override public void loaded(Geometry geometry) { mesh = THREE.Mesh(geometry, THREE.MeshLambertMaterial().color(0xff0000).build()); mesh.setPosition(0, 0, 0); mesh.setRotation(0, 0, 0); mesh.setScale(5, 5, 5); scene.add(mesh); } }); final Light light = THREE.PointLight(0xffffff); light.setPosition(10, 0, 10); scene.add(light); scene.add(THREE.AmbientLight(0xcccccc)); //default camera position MainWidget.cameraMove.setX(30); MainWidget.cameraMove.setY(70); MainWidget.cameraMove.setZ(200); timer = new Timer() { public void run() { try { camera.setPosition(MainWidget.cameraMove.getX(), MainWidget.cameraMove.getY(), MainWidget.cameraMove.getZ()); //TODO change ui mesh.setRotation(Math.toRadians(MainWidget.cameraRotation.getX()), Math.toRadians(MainWidget.cameraRotation.getY()), Math.toRadians(MainWidget.cameraRotation.getZ())); renderer.render(scene, camera); } catch (Exception e) { GWT.log(e.getMessage()); } } }; timer.scheduleRepeating(1000 / 60); }