Why is the mousedown event not recognized in javascript (with THREE)? - javascript

I have a simple THREE.js and I want to click on the round object, but when I click anywhere in the browser nothing happens. I followed this suggestion without success. The complete, full code is here:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Test</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
color: #808080;
font-family:Monospace;
font-size:13px;
text-align:center;
background-color: #ffffff;
margin: 0px;
overflow: hidden;
}
#info {
position: absolute;
top: 0px; width: 100%;
padding: 5px;
}
a {
color: #0080ff;
}
</style>
</head>
<body>
<div id="container"></div>
<script src="js/build/three.min.js"></script>
<script>
var container, stats;
var camera, scene, renderer;
var group1;
var mouseX = 0, mouseY = 0;
var map_width = 512;
var map_height = 512;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
init();
animate();
function createMesh(filename) {
var geometry = new THREE.SphereGeometry( 70, 40, 40 );
geometry.addEventListener('onclick', onDocumentMouseDown);
var loader = new THREE.TextureLoader();
var texture = loader.load(filename);
var material = new THREE.MeshBasicMaterial( { map: texture, overdraw: 0.5 } );
var mesh = new THREE.Mesh( geometry, material );
return mesh;
}
function init() {
container = document.getElementById( 'container' );
camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 500;
scene = new THREE.Scene();
group1 = new THREE.Group();
var mesh = createMesh("textures/canvas1.png");
group1.add( mesh );
scene.add( group1 );
renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setClearColor( 0xffffff, 0 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
document.addEventListener( 'onclick', onDocumentMouseDown, false);
}
function onDocumentMouseDown( event) {
//event.preventDefault();
console.log("test");
window.alert("clicked");
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
</script>
</body>
</html>
To reproduce this example you just need some random image and the THREE.js library. I do neither see any error in the console (related to this problem), nor any other console output during clicking on the browser...
I tried to add a method to one of the THREE.js objects as described in the documentation (geometry.addEventListener), but this also does not do anything.

document.addEventListener( 'click', onDocumentMouseDown, false);

Related

No shadows even when shadow is enabled

I have written the following code to get the shadow of the stanford dragon on a plane. But I am not getting it. I have enabled shadow by object and plane to receive shadow. My code is:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #000;
color: #fff;
margin: 0px;
overflow: hidden;
}
#info {
color: #fff;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
#info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
</style>
</head>
<body>
<script src="http://mrdoob.github.com/three.js/build/three.min.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/shaders/CopyShader.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/shaders/SSAOShader.js"></script>
<script type="text/javascript" src="http://mrdoob.github.com/three.js/examples/js/shaders/ConvolutionShader.js"></script>
<script type="text/javascript" src="http://mrdoob.github.com/three.js/examples/js/shaders/FXAAShader.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/postprocessing/EffectComposer.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/postprocessing/RenderPass.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/postprocessing/MaskPass.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/postprocessing/ShaderPass.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/loaders/DDSLoader.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/loaders/MTLLoader.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/loaders/OBJMTLLoader.js"></script>
<script type="text/javascript" src="http://mrdoob.github.com/three.js/examples/js/postprocessing/BloomPass.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/Detector.js"></script>
<script src="http://mrdoob.github.com/three.js/examples/js/libs/stats.min.js"></script>
<script>
if ( window.innerWidth === 0 ) { window.innerWidth = parent.innerWidth; window.innerHeight = parent.innerHeight; }
var camera, scene, renderer;
var group;
var depthMaterial, depthTarget, composer;
var object;
init();
animate();
function init() {
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setClearColor(new THREE.Color(0x000000,0.1));
renderer.shadowMapType = THREE.PCFSoftShadowMap;
renderer.shadowMapEnabled = true;
renderer.shadowMapSoft = true;
document.body.appendChild( renderer.domElement );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
//camera.position.x = 100;
camera.position.y = 100;
camera.position.z = 100;
// scene
scene = new THREE.Scene();
var planeGeometry = new THREE.PlaneGeometry(150,150);
var planeMaterial = new THREE.MeshLambertMaterial({color: 0xaaaaaa});
var plane = new THREE.Mesh(planeGeometry,planeMaterial);
plane.receiveShadow = true;
plane.rotation.x=-0.5*Math.PI;
plane.position.x=0;
plane.position.y=0;
plane.position.z=0;
// add the plane to the scene
scene.add(plane);
var ambient = new THREE.AmbientLight( 0xffffff );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.set( 0, 0, 1 ).normalize();
scene.add( directionalLight );
var spotLight = new THREE.SpotLight( 0xffffff );
spotLight.position.set( -80, 60, -10 );
spotLight.shadowMapWidth =2048;
spotLight.shadowMapHeight = 2048;
spotLight.castShadow = true;
spotLight.shadowMapEnabled = true;
scene.add( spotLight );
//Camera
// model
var onProgress = function ( xhr ) {
if ( xhr.lengthComputable ) {
var percentComplete = xhr.loaded / xhr.total * 100;
console.log( Math.round(percentComplete, 2) + '% downloaded' );
}
};
var onError = function ( xhr ) {
};
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
var loader = new THREE.OBJMTLLoader();
loader.load( 'dragon.obj', 'dragon.mtl', function ( object ) {
object.position.y = 0;
object.position.x = 0;
object.position.z = 10;
object.castShadow=true;
object.receiveShadow= true;
object.scale.set(4,4,4);
scene.add( object );
}, onProgress, onError );
//
var depthShader = THREE.ShaderLib[ "normal" ];
var depthUniforms = THREE.UniformsUtils.clone( depthShader.uniforms );
depthMaterial = new THREE.ShaderMaterial( { fragmentShader: depthShader.fragmentShader, vertexShader: depthShader.vertexShader, uniforms: depthUniforms } );
depthMaterial.blending = THREE.NoBlending;
// postprocessing
composer = new THREE.EffectComposer( renderer );
composer.addPass( new THREE.RenderPass( scene, camera ));
depthTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, { minFilter: THREE.NearestFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat } );
var effect = new THREE.ShaderPass( THREE.SSAOShader );
effect.uniforms[ 'tDepth' ].value = depthTarget;
effect.uniforms[ 'size' ].value.set( window.innerWidth, window.innerHeight );
effect.uniforms[ 'cameraNear' ].value = camera.near;
effect.uniforms[ 'cameraFar' ].value = camera.far;
effect.uniforms[ 'aoClamp' ].value = 0.9;
effect.uniforms[ 'onlyAO' ].value=0;
effect.renderToScreen = true;
composer.addPass( effect );
camera.lookAt( scene.position );
}
function animate() {
requestAnimationFrame( animate );
scene.overrideMaterial = depthMaterial;
renderer.render( scene, camera, depthTarget );
scene.overrideMaterial = null;
composer.render();
}
</script>
</body>
</html>
Please help me in finding out in what I have done wrongly. I am comparatively new to JavaScript also.
Another thing I wanted to add to the information above is that it works only with firefox and not chrome.
Thanks in advance.

Syntax Error JSONLoader

I am trying to import my models from c4d into three.js.
I know there is a OBJLoader which works fine for me. If I want to use my exported wavefront (.obj) and convert it with convert_obj_three.py it doesn't return any errors and the json-file looks fine.
But if I want to load the generated .js-file in my three.js-script, it returns:
Uncaught SyntaxError: Unexpected token ;
This is what I've tried:
var loader2 = new THREE.JSONLoader();
loader2.load('assets/models/test.js', createScene);
function createScene(){
mesh = new THREE.Mesh();
scene.add(mesh);
}
test.js: http://www.file-upload.net/download-7296129/test.js.html
error: http://www.file-upload.net/download-7296139/screenie.png.html
here is the whole code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - loaders - OBJ loader</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: gray;
color: #fff;
margin: 0px;
overflow: hidden;
}
#info {
color: #fff;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
#info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
</style>
</head>
<body>
<div id="info">
three.js - OBJLoader test
</div>
<script src="assets/three.min.js"></script>
<script src="assets/OBJLoader.js"></script>
<script src="assets/TrackballControls.js"></script>
<script src="assets/Detector.js"></script>
<script src="assets/stats.min.js"></script>
<script>
var container, stats;
var camera, scene, controls, renderer;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 900;
// controls
controls = new THREE.TrackballControls( camera );
controls.rotateSpeed = 5.0;
controls.zoomSpeed = 5;
controls.panSpeed = 2;
controls.noZoom = false;
controls.noPan = false;
controls.staticMoving = true;
controls.dynamicDampingFactor = 0.3;
// scene
scene = new THREE.Scene();
var ambient = new THREE.AmbientLight( 0xfff3dd );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.set( 0, 0, 1 ).normalize();
scene.add( directionalLight );
// model
var loader2 = new THREE.JSONLoader();
loader2.load('assets/models/test.js', function (geometry, materials){
mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
scene.add(mesh);
});
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
window.addEventListener( 'resize', onWindowResize, false );
}
function onWindowResize() {
windowHalfX = window.innerWidth / 2;
windowHalfY = window.innerHeight / 2;
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
controls.handleResize();
renderer.setSize( window.innerWidth, window.innerHeight );
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
controls.update();
renderer.render( scene, camera );
}
</script>
</body>
</html>
Function to load json file:
THREE.JSONLoader.prototype.load = function ( url, callback, texturePath )
loader2.load('assets/models/test.js', function(geometry, materials){
mesh = new THREE.Mesh(geometry, new THREE.MeshFaceMaterial(materials));
scene.add(mesh);
});

Three.js Mesh not animated with AnimationHandler

I haven't been able to get my blender exported mesh to animate. Not even the included buffalo one that I can clearly see animated in the example. (which I've been trying to reproduce to no avail.
Here's the code, I suspect it's a really simple missing thing, but I have no idea. I doubt it's a blender issue since I haven't even been able to animate the included meshes.
<!DOCTYPE html>
<html lang="en">
<head>
<title>three.js webgl - blender</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #000000;
margin: 0px;
overflow: hidden;
}
#info {
color: #fff;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
a { color: red }
#stats { position: absolute; top:0; left: 0 }
#stats #fps { background: transparent !important }
#stats #fps #fpsText { color: #aaa !important }
#stats #fps #fpsGraph { display: none }
</style>
</head>
<body>
<div id="info">
025 Valgany
</div>
<script src="/js/three.min.js"></script>
<script src="/js/Detector.js"></script>
<script src="/js/libs/stats.min.js"></script>
<script>
if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var modelBB={"min":new THREE.Vector3(),"max":new THREE.Vector3() };
var crewon, animation;
var container, stats;
var camera, scene, renderer, objects;
var particleLight, pointLight;
var skin;
var clock = new THREE.Clock();
init();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 10000 );
camera.position.set( 2, 4, 5 );
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x00FF00, 0.035 );
var loader = new THREE.JSONLoader(true);
loader.load("buffalo.js", function(geometry, materials) {
geometry.computeBoundingBox();
var faceMaterial = new THREE.MeshFaceMaterial( materials );
faceMaterial.skinning = true;
THREE.AnimationHandler.add( geometry.animation );
crewon = new THREE.SkinnedMesh(geometry,faceMaterial, false);
modelBB=geometry.boundingBox;
crewon.position.set(0,0,0);
scene.add(crewon);
renderer.render(scene, camera);
animation = new THREE.Animation( crewon, geometry.animation.name );
animation.play( true, 0.5 );
});
// Lights
scene.add( new THREE.AmbientLight( 0xcccccc ) );
pointLight = new THREE.PointLight( 0xffffff, 1, 30 );
pointLight.position.set( 5, 0, 0 );
scene.add( pointLight );
// Renderer
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
// Stats
stats = new Stats();
container.appendChild( stats.domElement );
// Events
window.addEventListener( 'resize', onWindowResize, false );
animate();
}
function onWindowResize( event ) {
renderer.setSize( window.innerWidth, window.innerHeight );
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
}
function animate() {
requestAnimationFrame( animate, renderer.domElement );
var delta = clock.getDelta();
THREE.AnimationHandler.update( delta );
render();
stats.update();
}
function render() {
if ( crewon ){
crewon.rotation.y+=0.01;
}
if( typeof animation != 'undefined' && animation!=null){
animation.update(0.1);
}
if( typeof modelBB != 'undefined' && modelBB!=null){
camera.position.x = 0;
camera.position.y = (modelBB.max.y-modelBB.min.y)/2;
camera.position.z = (modelBB.max.z-modelBB.min.z)*2;
camera.lookAt( new THREE.Vector3(
0,
(modelBB.max.y-modelBB.min.y)/2,
0) );
}
renderer.render( scene, camera );
}
</script>
</body>
</html>
The problem may be here:
var faceMaterial = new THREE.MeshFaceMaterial( materials );
faceMaterial.skinning = true;
The meshFaceMaterial is just like a container of other materials - it isn't itself a real material. Try iterating over its collection of materials:
var materials = faceMaterial.materials;
for (var i = 0,length = materials.length; i < length; i++) {
var material = materials[i];
material.skinning = true;
}

Picking selected mesh from an OBJ file

I'm using the OBJLoader to load a large 3D model (described in a .obj file) but it loads the whole file as a single Object3D object. Using scene.add(object) it adds the whole object to the scene.
I need to pick the selected mesh and change some of its properties, but when I add mouse function and use Ray.intersectObjects try to get the selected mesh it never works. I can not find where I made mistakes.
Would love some help with trying to get this working. Thanks!
It confused me for couples of days. The following is all my codeļ¼š
<!doctype html>
<html lang="en">
<head>
<title>three.js webgl - loaders - OBJ loader</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #000;
color: #fff;
margin: 0px;
overflow: hidden;
}
#info {
color: #fff;
position: absolute;
top: 10px;
width: 100%;
text-align: center;
z-index: 100;
display:block;
}
#info a, .button { color: #f00; font-weight: bold; text-decoration: underline; cursor: pointer }
</style>
</head>
<body>
<div id="info">
three.js - OBJLoader test
</div>
<script src="../build/Three.js"></script>
<script src="js/loaders/OBJLoader.js"></script>
<script src="js/Detector.js"></script>
<script src="js/Stats.js"></script>
<script>
var container, stats;
var camera, scene, renderer;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var _mouse = { x: 0, y: 0 },
objects = [],
_projector = new THREE.Projector();
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 2000 );
camera.position.z = 100;
scene.add( camera );
var ambient = new THREE.AmbientLight( 0x101030 );
scene.add( ambient );
var directionalLight = new THREE.DirectionalLight( 0xffeedd );
directionalLight.position.set( 0, 0, 1 ).normalize();
scene.add( directionalLight );
var texture = THREE.ImageUtils.loadTexture( 'textures/ash_uvgrid01.jpg' );
var loader = new THREE.OBJLoader();
loader.load( "obj/male02/male02.obj", function ( object ) {
for ( var i = 0, l = object.children.length; i < l; i ++ ) {
object.children[ i ].material.map = texture;
}
object.position.y = - 80;
object.position.z = - 160;
scene.add( object );
objects.push( object );
} );
// RENDERER
renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
}
function onDocumentMouseDown( event ) {
event.preventDefault();
// find intersections
_mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
_mouse.y = - (event.clientY / window.innerHeight) * 2 + 1;
var vector = new THREE.Vector3( _mouse.x, _mouse.y, 1 );
var ray = _projector.pickingRay( vector, camera );
var intersects = ray.intersectObjects( scene.children );
if ( intersects.length > 0 ) {
alert("selected!");
_SELECTED_DOWN = true;
}
}
function animate() {
requestAnimationFrame( animate );
render();
}
function render() {
renderer.render( scene, camera );
}
</script>
</body>
</html>
ray.intersectObjects() is not recursive. You need to pass a list of the objects you want to test.

ThreeJS Rotation Animation

I have a cube in ThreeJS and I would like to rotate it 90 degrees clockwise every time I press a button. I think I have the basic gist of it: create a Three.Animation instance, bind it to the cube, and then have the animation begin every time I press the correct button. However, I'm having a difficult time understanding ThreeJS's API, because it doesn't seem to contain any examples for its methods.
This is THREE.js's Animation constructor: ( root, data, interpolationType, JITCompile ) I don't understand what goes into the fields. I'm guessing root would be where I put my cube, but what about the rest?
Also can I just call animation.play() to cause the animation whenever I want? And how does the animationHandler work?
I think for for rotating an object 90 degrees clockwise, using the TWEEN class will do. I think the Animation class is handy for heavier stuff (like bones/skin morphs/etc.)
To use the tween class there are 3 basic steps:
include the class in your file (<script src="js/Tween.js"></script>)
add your tween for the event you need (new TWEEN.Tween( cube.rotation ).to( { y:Math.random()}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();)
update the tween in your render loop (TWEEN.update();)
You can have a have a look at the cubes tween example for a start.
I've modified the default cube example to have the tween in:
<!doctype html>
<html lang="en">
<head>
<title>three.js canvas - geometry - cube</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<style>
body {
font-family: Monospace;
background-color: #f0f0f0;
margin: 0px;
overflow: hidden;
}
</style>
</head>
<body>
<script src="../build/Three.js"></script>
<script src="js/Tween.js"></script>
<script src="js/RequestAnimationFrame.js"></script>
<script src="js/Stats.js"></script>
<script>
var container, stats;
var camera, scene, renderer;
var cube, plane;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
var rad90 = Math.PI * .5;
init();
animate();
function init() {
container = document.createElement( 'div' );
document.body.appendChild( container );
var info = document.createElement( 'div' );
info.style.position = 'absolute';
info.style.top = '10px';
info.style.width = '100%';
info.style.textAlign = 'center';
info.innerHTML = 'click to tween';
container.appendChild( info );
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
camera.position.y = 150;
camera.position.z = 500;
scene = new THREE.Scene();
// Cube
var materials = [];
for ( var i = 0; i < 6; i ++ ) {
materials.push( [ new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ] );
}
cube = new THREE.Mesh( new THREE.CubeGeometry( 200, 200, 200, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() );
cube.position.y = 150;
cube.overdraw = true;
scene.add( cube );
// Plane
plane = new THREE.Mesh( new THREE.PlaneGeometry( 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0 } ) );
plane.rotation.x = - 90 * ( Math.PI / 180 );
plane.overdraw = true;
scene.add( plane );
renderer = new THREE.CanvasRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
container.appendChild( renderer.domElement );
stats = new Stats();
stats.domElement.style.position = 'absolute';
stats.domElement.style.top = '0px';
container.appendChild( stats.domElement );
document.addEventListener( 'mousedown', onDocumentMouseDown, false );
}
//
function onDocumentMouseDown( event ) {
event.preventDefault();
new TWEEN.Tween( cube.rotation ).to( { y: cube.rotation.y + rad90}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();
new TWEEN.Tween( plane.rotation ).to( { z: plane.rotation.z + rad90}, 1000 ).easing( TWEEN.Easing.Quadratic.EaseOut).start();
console.log("click");
}
//
function animate() {
requestAnimationFrame( animate );
render();
stats.update();
}
function render() {
TWEEN.update();
renderer.render( scene, camera );
}
</script>
</body>
</html>

Categories