three.js

Javascript: Three.js JSON error on remote server, but not on local

血红的双手。 提交于 2019-12-13 03:44:45
问题 I'm writing a Three.js application. In part of it, I load a blender model exported as a JSON file using the Blender->JSON exporter for Three.js. I have WAMPServer 2.2 configured on my local computer (Windows 7) that I use to test my website before I FTP it to the remote server to show off to friends and such. Loading this JSON file works fine on the local test server, but when I upload it to the server, I get the following error in Firebug, Firefox 16.0.2: SyntaxError: JSON.parse: unexpected

Finding UV coordinates of a point on material rendered on 3D cube in threejs

天大地大妈咪最大 提交于 2019-12-13 03:44:18
问题 I want to calculate the UV co-ordinates of a single point of a material rendered on 3D cube. I am finding the mouse pointer intersection with the camera ray using THREE.Raycaster as: 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); vector.unproject(camera); var raycaster = new THREE.Raycaster(camera.position, vector.sub(camera.position).normalize()); var intersects = raycaster

three.js sizeAttenuation to Sprite material

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 03:39:59
问题 I want the sprite in the scene don't change the size when the camera zoom in or out. and the sprites use different canvas texture as the material. I found that the sizeAttenuation in ParticleBasicMatierial can work for me. But if I use the WenGLRenderer, I must use ParticleSystem instead of the Particle with the CanvasRenderer. I currently use ParticleSystem to contain only one vertex, and every vertex correspond to one ParticleSystem, so there are about 800+ ParticleSystem in my scene, this

Clone an Object3D model from a Collada load call

丶灬走出姿态 提交于 2019-12-13 03:38:00
问题 I'm trying to clone an ThreeJS Object3D model. I've found various code here and on GitHub and nothing is working for me. The code below comes in part from How to clone an object3d in Three.js? var loader = new THREE.ColladaLoader(); loader.load('../Model.dae', function (result) { var loadedMesh = // No sure where this comes from // Create X of these for ( var i = 0; i < 10; i ++ ) { var mesh = new THREE.Mesh( loadedMesh.geometry, loadedMesh.material ); mesh.position.set( i * 100, 0, 0 );

How to get the global position of a vertex of a skinned mesh in Three.js?

耗尽温柔 提交于 2019-12-13 03:32:09
问题 In Three.js, we are now able to get the global position of a vertex of a non-skinned mesh thanks to this question, but how can I get the global position of a vertex of a skinned mesh with bones and morph targets? For example, how can I print (2.5, 1.5, 0.5) in the following situation? mesh.geometry.vertices[0] is originally at (0.5, 0.5, 0.5) . Then, bones[1] moves the vertex to (2.5, 0.5, 0.5) . Finally, morphing moves the vertex to (2.5, 1.5, 0.5) . const scene = new THREE.Scene(); const

Is there a function to get the screenoutput as an array of colors instead?

泄露秘密 提交于 2019-12-13 03:29:52
问题 I want to get the output (ie what is displayed on the screen) as an array of colors. I tried googling 'three.js screen output as array' but couldnt find what I was looking for. Any advice or pointers in the right direction would be appreciated. 来源: https://stackoverflow.com/questions/52210856/is-there-a-function-to-get-the-screenoutput-as-an-array-of-colors-instead

Threejs Change image at runtime

橙三吉。 提交于 2019-12-13 03:29:13
问题 I'm showing a 3d obj and applying the texture as jpg. but I want to change this image when I click on a button, it is possible and how could I do that? var loader = new THREE.ImageLoader(manager); loader.load('models/obj/dla/dla.jpg', function(image) { texture.image = image; texture.repeat.set(1,1); texture.needsUpdate = true; }); // model var loader = new THREE.OBJLoader(manager); loader.load('models/obj/dla/dla.obj', function(object) { object.traverse(function(child) { if (child instanceof

three.js camera tween with switch statement

不问归期 提交于 2019-12-13 03:13:50
问题 I am trying to tween a camera in three.js. I have the following code in my init function. A switch statement i am passing through an iFrame. window.onmessage = function(evt) { switch (evt.data.cameraYpos) { case 'Ypos01': var from01 = { y: camera.position.y }; var to01 = { y: yPos01 }; TWEEN.removeAll(); var tween = new TWEEN.Tween(from01) .to(to01, 600) .easing(TWEEN.Easing.Linear.None) .onUpdate(function() { camera.position.set(this.y); camera.lookAt(new THREE.Vector3(0, 0, 0)); })

Play mixer animation at a specific time ( playAt() or skipTo() )

独自空忆成欢 提交于 2019-12-13 03:05:05
问题 I have a basic mesh animation in a .gltf that I want to play at a specific time in seconds. Here's the loader and mixer setup: GLTFLoader.load( 'myscene.gltf', function ( gltf ) { model = gltf.scene; scene.add( model ); mixer = new THREE.AnimationMixer( model ); mixer.clipAction(gltf.animations[0]) .setDuration( 60 ) //total of 1 min .play(); render(); }); In render() I have: function render() { var delta = clock.getDelta(); if (mixer != null) { mixer.update(delta); }; //console.log(delta); /

three.js - Creating mesh from .obj file using geometry.vertices and geometry.faces

点点圈 提交于 2019-12-13 03:01:58
问题 I am trying to create a mesh from an .obj file. I am doing this rather than using the obj loader because I meed to morph the shape using different sliders, select specific faces/vertices and draw a path between vertices. I am currently getting errors when I try to render the scene and it seems to be something to do with the faces from the obj file. When I manually enter the faces I can create a triangle no problem. Here is my code var camera, scene, renderer, geometry, material, mesh; init();