three.js

Clean up Threejs WebGl contexts

筅森魡賤 提交于 2020-12-28 13:10:52
问题 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

5分钟回顾苹果发布会

痞子三分冷 提交于 2020-12-25 17:20:59
往期精选文章 ES6中一些超级好用的内置方法 浅谈web自适应 使用Three.js制作酷炫无比的无穷隧道特效 一个治愈JavaScript疲劳的学习计划 全栈工程师技能大全 WEB前端性能优化常见方法 一小时内搭建一个全栈Web应用框架 干货:CSS 专业技巧 四步实现React页面过渡动画效果 让你分分钟理解 JavaScript 闭包 小手一抖,资料全有。长按二维码关注 京程一灯 ,阅读更多技术文章和业界动态。 本文分享自微信公众号 - 前端先锋(jingchengyideng)。 如有侵权,请联系 support@oschina.cn 删除。 本文参与“ OSC源创计划 ”,欢迎正在阅读的你也加入,一起分享。 来源: oschina 链接: https://my.oschina.net/u/4581713/blog/4594725

基于WebGL无插件虚拟场景漫游关键技术(完整版)ThingJS

巧了我就是萌 提交于 2020-12-16 19:40:19
#三维可视化##3D开发# WebGL, ThingJS及3DSMAX 虚拟场馆漫游技术构建 基础组件 加载三维模型 实现虚拟漫游 渲染优化 如果要构建一个具有交互性和拓展性的沉浸式漫游场景,常用到3DSMAX、three.js等软件技术,学习门槛较高;ThingJS可视化组件更加轻量化,B/S架构下的3D可视化应用构建更轻松,为不少企业客户降低了项目开发成本。 WebGL、ThingJS及3DSMAX技术实现 WebGL是一种浏览器支持的3D绘图技术,无需下载插件,有跨平台跨终端的特性。如今广泛应用到三维可视化项目中,包括虚拟校园、全景看房、可视化大屏应用等。 ThingJS平台简化了在线开发步骤,本文总结一种更通用、更合理的实现方法,全程提供3D源码,保证了统一的基础架构,加速3D项目开发: 在 CampusBuilder客户端 可以搭建3D场景,并利用模型扩展库,避免过多的建模压力; 如果有精模需求,则可以在3DSMAX中完成建模,利用3D插件将模型导入3D场景中,不重要的场景则可以隐藏或者优化掉。 3D场景应该作为一个整体来看,但是若干部件(如墙体、展柜、门等)都是独立导出的,比如门设置了动画属性,则可以在平台上进行交互开发。 CampusBuilder有自带的保存格式,数据和ThingJS技术引擎是共享的,可读取的主流三维文件格式如下: JSON, OBJ或MTL,

How do I load GLTFLoader from a cdn THREE.js

╄→尐↘猪︶ㄣ 提交于 2020-12-15 06:30:49
问题 I'm having some issues figuring out how to get GLTFLoader to work in THREE.js. I don't understand how to use a cdn site to host the file. I have tried using links from examples around the web but that hasn't done the job for me. I read on another post that the GLTFLoader file had to be the same versions the core THREE file I'm using (r121). I thought I could go to mrdoob github (not familiar with how to use github) and click raw file then use that link on a site like githack to generate a cdn

Unexpected token { when importing a module

倖福魔咒の 提交于 2020-12-15 05:18:07
问题 Here's a codepen with this import I get the error(10 line index.vue): import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js"; so what's going on here? The other ES6 imports are fine. 回答1: I don't know the structure of the file where you want to import from, but are you trying to import a default or just a module? Because the default syntax does not have {} . Much like your first import. If what you're trying to import is set as a default export, you need to

Unexpected token { when importing a module

故事扮演 提交于 2020-12-15 05:17:56
问题 Here's a codepen with this import I get the error(10 line index.vue): import { EffectComposer } from "three/examples/jsm/postprocessing/EffectComposer.js"; so what's going on here? The other ES6 imports are fine. 回答1: I don't know the structure of the file where you want to import from, but are you trying to import a default or just a module? Because the default syntax does not have {} . Much like your first import. If what you're trying to import is set as a default export, you need to

Importing with curly braces inside a Nuxt component

一笑奈何 提交于 2020-12-13 04:54:10
问题 I'm trying to import Three.js in a Nuxt component. <script> import * as THREE from "three"; import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls' .. While the first line works, the second one gives me an "Unexpected token {" - syntax error , so does const { OrbitControls } = require('three/examples/jsm/controls/OrbitControls') The syntax of the import (the first version) is per Three.js documentation. 回答1: I'm answering my own question by copying an answer I gave in

Three.js don't strecht mesh texture (image) - make it cover its container

北城余情 提交于 2020-12-13 03:22:49
问题 I have a container which i apply an image to using a three.js and mesh. That's how I apply my mesh to the scene: this.$els = { el: el, image: el.querySelector('.ch__image') <-- size of container image is being applied to }; this.loader = new THREE.TextureLoader(); this.image = this.loader.load(this.$els.image.dataset.src); this.sizes = new THREE.Vector2(0, 0); this.offset = new THREE.Vector2(0, 0); getSizes() { const { width, height, top, left } = this.$els.image.getBoundingClientRect(); this

Three.js don't strecht mesh texture (image) - make it cover its container

你。 提交于 2020-12-13 03:22:24
问题 I have a container which i apply an image to using a three.js and mesh. That's how I apply my mesh to the scene: this.$els = { el: el, image: el.querySelector('.ch__image') <-- size of container image is being applied to }; this.loader = new THREE.TextureLoader(); this.image = this.loader.load(this.$els.image.dataset.src); this.sizes = new THREE.Vector2(0, 0); this.offset = new THREE.Vector2(0, 0); getSizes() { const { width, height, top, left } = this.$els.image.getBoundingClientRect(); this

Three.JS: Weird shadow artifacts from a spotlight, but only in Android

穿精又带淫゛_ 提交于 2020-12-12 10:49:29
问题 Using Three.js v0.113.2 I'm rendering this scene of a mug on a plane with two spotlights (one behind, one in front), and an ambient light. The front spotlight casts shadows, the mug is set to cast shadows (but not receive them), and the plane is set to receive shadows. I'm using a shadow radius of 20 (iirc). The shadow mapSize is 1024x1024. On Android, and only on Android (this renders correctly on iPhones, Windows, and Mac desktops) I see these weird banding artifacts from the lighting on