three.js

Change parent of component and keep position

℡╲_俬逩灬. 提交于 2021-01-05 11:00:22
问题 I am using AR.js and have a sphere positioned in the marker component. <body style="margin : 0px; overflow: hidden;"> <a-scene vr-mode-ui="enabled: false" embedded="" arjs="sourceType: webcam; debugUIEnabled: false;"> <a-marker markerhandler id="marker" emitevents="true" cursor="rayOrigin: mouse" preset="hiro"> <a-sphere id="sphere" color="green" radius="0.3" position="0 1 0" ></a-sphere> </a-marker> <!-- use this <a-entity camera> to support multiple-markers, otherwise use <a-marker-camera>

Change parent of component and keep position

南楼画角 提交于 2021-01-05 11:00:12
问题 I am using AR.js and have a sphere positioned in the marker component. <body style="margin : 0px; overflow: hidden;"> <a-scene vr-mode-ui="enabled: false" embedded="" arjs="sourceType: webcam; debugUIEnabled: false;"> <a-marker markerhandler id="marker" emitevents="true" cursor="rayOrigin: mouse" preset="hiro"> <a-sphere id="sphere" color="green" radius="0.3" position="0 1 0" ></a-sphere> </a-marker> <!-- use this <a-entity camera> to support multiple-markers, otherwise use <a-marker-camera>

Three.js之照相机Camera

a 夏天 提交于 2021-01-05 10:39:42
1、背景介绍 在网页显示出三维的效果,就要借助于视觉效果来实现,比如阴影、光照等。这里的Camera相当于人的眼睛,从坐标的那个视点去观察目标,相当于投影出立体感。这里首先说一下坐标。如下图所示: z轴正方向指向屏幕外,x,y平面在屏幕上。坐标原点(0,0,0)默认为场景中心。照相机就是在这个坐标系中定义的。有两种投影方式:正交投影和透视投影。对于这两种投影具体介绍, 请点击这里了解更多 。 透视投影图 正交投影图 2、正交投影照相机和透视投影照相机 2.1正交投影照相机 正交投影照相机(Orthographic Camera),构造函数: OrthographicCamera( left, right, top, bottom, near, far ) left — Camera frustum left plane. right — Camera frustum right plane. top — Camera frustum top plane. bottom — Camera frustum bottom plane. near — Camera frustum near plane. far — Camera frustum far plane. 实例演示: //创建场景 var scene=new THREE.Scene(); //创建相机 var camera_Or

深入理解Three.js中正交摄像机OrthographicCamera

只愿长相守 提交于 2021-01-05 10:25:43
前言 在 深入理解Three.js中透视投影照相机PerspectiveCamera 那篇文章中讲解了透视投影摄像机的工作原理以及对应一些参数的解答,那篇文章中也说了会单独讲解 Three.js 中另一种常用的摄像机正交摄像机 OrthographicCamera ,这篇文章将会详细的讲解正交摄像机的工作原理和其对应参数的用法,当然,为了能够让读者更加直观的理解正交摄像机,我会制作一个与正交摄像机相关的 demo 来直观的让读者感受正交摄像机的魅力。 原理说明 深入理解Three.js中透视投影照相机PerspectiveCamera 文章中提到过正交摄像机和透视投影摄像机最大的区别是投影到的物体大小不受距离的影响,说直白点就是透视投影摄像机投影物体是通过点(下图a),相当于我们的眼睛,距离越远,能够看到的部分也就越小。正交摄像机投影物体是通过平面(下图b),无论距离有多远,投射到二维平面的线始终的是平行的,所以看上去就会感觉物体的大小没有受到任何影响。 正交摄像机参数说明 实现一个简单正交摄像机的代码如下: 1 var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); 2 scene.add( camera ); new THREE

Cannot Import from Three.js Examples (Script error for “three/examples/jsm/loaders/OBJLoader2”)

跟風遠走 提交于 2021-01-05 08:07:45
问题 I have an Angular application with a basic Three.js setup. I use Bazel build and run the app. Everything works fine until I try to import the OBJLoader2 from three/examples/jsm/loaders/OBJLoader2 . const module = await import('three/examples/jsm/loaders/OBJLoader2') const loader = new module.OBJLoader2() The code snippet above doesn't work with the ts_devserver. I get this error in the browser console: GET http://localhost:4200/three/examples/jsm/loaders/OBJLoader2.js net::ERR_ABORTED 404

Angular component with requestAnimationFrame issue

半城伤御伤魂 提交于 2021-01-05 07:38:56
问题 im using Angular 9 together with THREE.Js. The app lets you switch between a 2D html component and a 3D ThreeJs component via button click. The 3D component creates all needed for threejs on ngAfterViewInit and calls a loop function with requestAnimationFrame . private loop() { this.AFID = requestAnimationFrame(this.loop.bind(this)) this.renderer.render(this.scene, this.camera) } The loop gets canceled as soon as all models of my scene are loaded and the onLoad callback is fired or when

upgrade three js version in autodesk forge viewer

泪湿孤枕 提交于 2021-01-04 05:41:08
问题 I was looking to upgrade the three js which is used in autodesk forge behind the scene and reason for upgrade is I am trying to use this library and this need three js r71 and above and inside forge viewer it seems they are using r33. I found a blog where it showed me how can I take the advantage of later three js. I followed it but seems like its not working. There forge viewer now have 2 references of three js and it gets confused which one to use and hence some of code behave weird here is

upgrade three js version in autodesk forge viewer

痴心易碎 提交于 2021-01-04 05:40:46
问题 I was looking to upgrade the three js which is used in autodesk forge behind the scene and reason for upgrade is I am trying to use this library and this need three js r71 and above and inside forge viewer it seems they are using r33. I found a blog where it showed me how can I take the advantage of later three js. I followed it but seems like its not working. There forge viewer now have 2 references of three js and it gets confused which one to use and hence some of code behave weird here is

ThreeJS Stop Rendering

ぐ巨炮叔叔 提交于 2020-12-29 04:38:04
问题 I am working with ThreeJS on a basic 3d scene that has OrbitControls. Everything works great, except it causes my entire site to lag, as it is looping itself even when the user is not looking at it. I want a function that I can call to start and stop the rendering when certain conditions are met (in this case, the user isn't viewing the canvas). I have a start function that works just fine, but the stop function does not seem to be working, as my site goes unbearably slow after ThreeJS has

Clean up Threejs WebGl contexts

冷暖自知 提交于 2020-12-28 13:11:06
问题 I have a problem while cleaning up my WebGl-Scenes. I'm using Three.js with a WebGlRenderer. In my application I have to change the views quite often and therefore need to render new scenes all the time. Uptil now I destroy and reinitialize the entire Threejs scene. After switching the scenes about 15 - 20 times I get following warning: WARNING: Too many active WebGL contexts. Oldest context will be lost. After switching a couple of times more the context is lost completly and the application