three.js

glsify - error 'You may need an appropriate loader to handle this file type'?

无人久伴 提交于 2019-12-24 07:29:30
问题 Ok Im following https://tympanus.net/codrops/2019/01/17/interactive-particles-with-three-js/ just trying to get his custom shader to work. I brought in the .frag and .vert files (included in the link) and copied how his setup. When I run I get the error Module parse failed: Unexpected token (3:10) You may need an appropriate loader to handle this file type. Here: const material = new THREE.RawShaderMaterial({ uniforms, vertexShader: glslify(require('./vendor/shaders/particle.vert')), //HERE!!

how to calculate area and volume using svf file in forge viewer

最后都变了- 提交于 2019-12-24 07:28:36
问题 I need to calculate volume and area of surfaces of 3D file. Since forge api can convert all kinds of 3D file to svf format, so If I can calculate area and volume from svf format file , then my program can handle all format 3D file that forge api support. But forge viewer doesn't have the api to calculate area and volume. Because forge viewer is based on THREE.js, so I guess if I can use THREE.js's api to calculate volume and area. I read the api of forge viewer, but there is no api to get

Disposing objects and restoring them

落花浮王杯 提交于 2019-12-24 07:27:47
问题 I am working on a three.js project that allows the user to switch through scenes that hold different mesh objects. They're all loaded into the project at the same time when the page has loaded, and all of these objects have textures which weigh heavily on the performance. So to fix this, I want to temporarily remove all the objects in all of the scenes that the user has not selected. So, with 10 scenes, should the user for example select to see what's in scene 4 (which would be the

Trying to get the point of intersection of a raycaster

走远了吗. 提交于 2019-12-24 07:21:53
问题 QUESTION: I load frontObject onto the scene. I get the centre of said object. Then I move beyond the object by setting a new point that reuses all the object's centre coordinates except the Z axis (the z coordinate becomes 100), so that I can trace a raycaster from the outside of the character (frontObject) towards it and get the intersection point on the back of the character so that I may place a shield on that point. Sadly, I get the following output: CODE: let box = new THREE.Box3()

Point surface of mesh towards another object

浪尽此生 提交于 2019-12-24 07:21:28
问题 As a continuation to: Point one object to face a distant object I'm trying to get a mesh's surface to point to another object. I want a far away object to point to a close object, whenever the far object moves. Here is a sample of what is happening: http://jsfiddle.net/UsVUv/ 1) I create 2 mesh objects. 2) Since the far mesh is facing up, I rotate it so that it can be seen from the camera. -> farMesh.rotation = new THREE.Vector3(Math.PI/2, 0, 0); 3) When the far mesh is moved, I call the

Trying to get the point of intersection of a raycaster

China☆狼群 提交于 2019-12-24 07:21:02
问题 QUESTION: I load frontObject onto the scene. I get the centre of said object. Then I move beyond the object by setting a new point that reuses all the object's centre coordinates except the Z axis (the z coordinate becomes 100), so that I can trace a raycaster from the outside of the character (frontObject) towards it and get the intersection point on the back of the character so that I may place a shield on that point. Sadly, I get the following output: CODE: let box = new THREE.Box3()

Point surface of mesh towards another object

假装没事ソ 提交于 2019-12-24 07:20:56
问题 As a continuation to: Point one object to face a distant object I'm trying to get a mesh's surface to point to another object. I want a far away object to point to a close object, whenever the far object moves. Here is a sample of what is happening: http://jsfiddle.net/UsVUv/ 1) I create 2 mesh objects. 2) Since the far mesh is facing up, I rotate it so that it can be seen from the camera. -> farMesh.rotation = new THREE.Vector3(Math.PI/2, 0, 0); 3) When the far mesh is moved, I call the

three.js lookAt function does not work correctly

↘锁芯ラ 提交于 2019-12-24 07:19:50
问题 I want to align one child object (the cylinder) to another object (cube2). I used the lookAt Function, but the alignment is not correct. Where is my mistake? I have the following code: //cube 1 var cube=new THREE.BoxGeometry(2,2,2); var material=new THREE.MeshBasicMaterial ({ color: 0xffffff }); mesh1=new THREE.Mesh(cube,material); mesh1.position.set(-2,2,0); scene.add(mesh1); //cube 2 var cube2=new THREE.BoxGeometry(2,2,2); var material=new THREE.MeshBasicMaterial ({ color:0x000000 }); mesh2

Custom shader material taking forever to initialize?

[亡魂溺海] 提交于 2019-12-24 07:15:10
问题 I've been working on a raymarched project in three.js for a little over a year now and as the complexity has increased so has the initialization time. It can now take over 40 seconds to load the project in browser however once loaded runs at +60fps. I've tracked down the culprit function through performance tests and it seems to get hung up on the InitMaterial function within three's library. Does anyone have any idea as to what could be causing this hangup? Personally I believe it could be

Threejs - Mouse interaction with large resolutions

被刻印的时光 ゝ 提交于 2019-12-24 07:14:35
问题 I am running into an issue with mouse interaction/detection with objects in threejs on large resolutions monitors. I was able to follow the examples on threejs example site and everything works well on most resolutions (1920x1080). The code I am using to detect an interesection: mouse.x = ( ( event.offsetX ) / CANVAS_WIDTH ) * 2 - 1; mouse.y = - ( ( event.offsetY) / CANVAS_HEIGHT ) * 2 + 1; var vector = new THREE.Vector3( mouse.x, mouse.y, 1); projector.unprojectVector( vector, camera ); var