three.js

Three.js: add light to camera

情到浓时终转凉″ 提交于 2019-12-23 10:15:55
问题 I want to move and rotate the camera but keep a PointLight on the same position relative to the camera. I've read a bunch of threads saying that you can add the light object to the camera instead of the scene. Like so: pointLight = new THREE.PointLight( 0xffffff ); pointLight.position.set(1,1,2); camera.add(pointLight); However this does not seem to work for me. Instead I now when the camera changes set the light's position by applying the cameras matrixWorld to my desired relative light

Three.js how to fade out audio?

此生再无相见时 提交于 2019-12-23 09:38:21
问题 A want to make crossfade effect between two audio. I try Tween.JS for that, but it's not do it smoothly, how I want... var sound_b_1 = new THREE.PositionalAudio( listener ); sound_b_1.load('mysound.ogg'); sound_b_1.setRefDistance(20); sound_b_1.setVolume(1); sound_b_1.autoplay = true; scene.add(sound_b_1); var volume = {x : 1}; // tweens not work without object // using Tween.js new TWEEN.Tween(volume).to({ x: 0 }, 1000).onUpdate(function() { sound_b_1.setVolume(this.x); }).onComplete

Objects with Mesh lambert material not being generated while rendering graphics with three.js

你离开我真会死。 提交于 2019-12-23 09:17:30
问题 Well I just started learning three.js which is totally totally totally new to me. So I am writing these series of hello world kinda scrips.Well I wrote the script below to generate a cube with MeshBasicMaterial (Well this is just an exact copy of a tutorial given in a blog) var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera(75, 640/340, 0.1, 1000); var renderer = new THREE.WebGLRenderer(); renderer.setSize(640, 340); document.body.appendChild(renderer.domElement); var

Morph Targets Three.js

若如初见. 提交于 2019-12-23 08:00:07
问题 I'm trying to get started with morph targets and three.js. However, there doesn't seem to be much documentation on this subject. As I'm looking at the source code: morphTargetInfluences[] seems to be the magic...how does this work? How do I use this? Is a value of 1 full strength? How can I differentiate between different morph targets on the same model? I'm just trying to understand: morphTargetInfluences[]. Thanks in advance 回答1: http://threejs.org/examples/webgl_morphtargets.html Morph

How to make ShadowCamera visible in three.js r73?

亡梦爱人 提交于 2019-12-23 07:55:39
问题 Light.shadowCameraVisible = true; gives a warning THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow ) instead. on adding Scene.add(new THREE.CameraHelper(Light.shadow )); gives an error Uncaught TypeError: this.camera.updateProjectionMatrix is not a function (three.js :35002) 回答1: The CameraHelper constructor takes a Camera object: var light = new THREE.SpotLight( 0xFFAA55 ); light.castShadow = true; var helper = new THREE.CameraHelper( light.shadow

(A-Frame) local gltf wont load; Cannot read property 'slice' of undefined

谁都会走 提交于 2019-12-23 07:52:08
问题 I took the code from the A-Frame School in which a gltf model is loaded. Then I loaded the Sample Models from Khronos, this box and tried to load it, but I get this error (several times) GLTFLoader.js:979 Uncaught (in promise) TypeError: Cannot read property 'slice' of undefined at GLTFLoader.js:979 at i (GLTFLoader.js:570) at GLTFLoader.js:975 at <anonymous> I can load .obj models and tried the several versions of the model, but get always the error. The sample code does work locally,

Three.js picking is not working correctly with custom geometry

白昼怎懂夜的黑 提交于 2019-12-23 05:59:52
问题 I have a problem with picking implementation. I found a number of different examples doing what I want, but I really cannot make it work as it should. I mainly followed this example Basically, I have some meshes in my scene and, double clicking any of them, I'd like to change the color of the chosen one. In the scene there are 3 small cubes that are always selected and some more complex meshes that often aren't. I'd like to know if anybody can help me figuring why, if the cubes can be

Three.js picking is not working correctly with custom geometry

北慕城南 提交于 2019-12-23 05:59:30
问题 I have a problem with picking implementation. I found a number of different examples doing what I want, but I really cannot make it work as it should. I mainly followed this example Basically, I have some meshes in my scene and, double clicking any of them, I'd like to change the color of the chosen one. In the scene there are 3 small cubes that are always selected and some more complex meshes that often aren't. I'd like to know if anybody can help me figuring why, if the cubes can be

Three.js: Fresnel Shader - Color changing or env map blending

百般思念 提交于 2019-12-23 05:31:01
问题 I'm not a shader specialist, but I'd like to pass the color value to the shader that could maybe blended with the env map color. var shader = THREE.FresnelShader; // Thank you WestLangley for that trick var uniforms = THREE.UniformsUtils.merge( [ THREE.UniformsLib[ "lights" ], shader.uniforms ] ); uniforms[ "tCube" ].value = textureCube; var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights : true }; shaderMaterial = new THREE

THREEJS: Matrix from Z-Up Coordinate System to Y-Up Coordinate System

做~自己de王妃 提交于 2019-12-23 05:28:03
问题 I am trying to export a series of Transformation Matrices to animate objects in ThreeJS. These transformation are extracted from Rhino, a Z-Up Modeler and need to be placed into ThreeJS, which is Y-Up. I've found a similar question on this site, but the answer does not appear to be correct because my transformations don't carry over. Can anyone translate the generic 4x4 matrix below from a Z-Up coordinate system to a Y-Up Coordinate System? { a, b, c, d } { e, f, g, h } { i, j, k, l } { m, n,