WebGL

WebGL – Use mesh as mask for background image

浪尽此生 提交于 2019-12-11 08:48:13
问题 I have the following problem to solve with WebGL: Imagine a mesh in front of the camera. The mesh is not actually shaded but its "silhouette" as a whole is used to reveal a background image as some sort of mask or stencil if you will. So e.g. you would have an output image with a white background and a silhouette-shape filled with a texture/image being the background at that position. (The meshes I want to use are obviously more complex than a sphere) What is the best way to achieve such an

基于 HTML5 WebGL 的科幻风机

守給你的承諾、 提交于 2019-12-11 08:36:46
前言   许多世纪以来,风力机同水力机械一样,作为动力源替代人力、畜力,对生产力的发展发挥过重要作用。近代机电动力的广泛应用以及二十世纪50年代中东油田的发现,使风机发电机的发展缓慢下来。 70年代初期,由于“石油危机”,出现了能源紧张的问题,人们认识到常规矿物能源供应的不稳定性和有限性,于是寻求清洁的可再生能源遂成为现代世界的一个重要课题。风能作为可再生的、无污染的自然能源又重新引起了人们重视。 现在我希望可以通过这个风机 demo 使风力发电机的各个功能近距离的展示给大家,使大家能更了解风力发电机。 本 demo 使用 HT for Web 产品轻量化 HTML5/WebGL 建模的方案。 HT 官网链接: http://www.hightopo.com/cn-index.html demo 链接: https://hightopo.com/demo/fan3d-magic/ 风机主要功能介绍 效果:    周围环境功能:   一. 风速值。   虚拟一个风速值,风速值会影响风机的发电效率和变桨系统的变化。    二. 数据统计 。      环境温度、机舱温度、齿轮箱温度、风速的图形百分比会随着时间发生改变。    三. 环境监测 。      左边对风机的各个参数实施了监测,右面是风速变化的折线图。    四. 数据监测 。         风机在发电的过程中发生的异常情况

three.js: rendering 3d text with custom texture

时间秒杀一切 提交于 2019-12-11 08:15:34
问题 I've been wondering is it possible to do skinning to the 3d text with loaded images as texture? I knew you could do it with cubes and others since most of the sample were showing tutorials how to do it. What did I tried was map it with THREE. ImageUtils.loadTexture directed from the path but what did i get is some transparency object. I wonder how to use the same concept such as: CubeGeometry(width, height, depth, widthSegments, heightSegments, depthSegments, listofmaterials) in TextGeometry

How to draw mesh edges with Threejs

﹥>﹥吖頭↗ 提交于 2019-12-11 07:58:12
问题 I'm looking at drawing the edges of a mesh like on the following picture: I tried to use THREE.EdgesHelper however it only groups the triangles that are in the same plane and therefore it looks like the wireframe on curved areas which I want to avoid. Ideally it would be some sort of helper that I could display/hide/change colour. I'm not exactly sure about what to look at for a starting point and your help would be much appreciated. Thank you! 来源: https://stackoverflow.com/questions/24566247

How can I draw a fullscreen background image in WebGL like sketchfab?

泪湿孤枕 提交于 2019-12-11 07:29:01
问题 I know how to draw models, but I don't know how to draw a fullscreen background image. I think I should draw it at the zfar of the camera. But I have no idea how to calculate its size... In sketchfab, it seems the background image can implement the css property background-size: cover . And I notice sketchfab do not implement it by css. I really want to know how to implement this! 回答1: How can I draw a fullscreen background image in WebGL like like style background-size: cover ? Create a

WebGL heightmap using vertex shader, using 32 bits instead of 8 bits

元气小坏坏 提交于 2019-12-11 07:03:56
问题 I'm using the following vertex shader (courtesy http://stemkoski.github.io/Three.js/Shader-Heightmap-Textures.html) to generate terrain from a grayscale height map: uniform sampler2D bumpTexture; uniform float bumpScale; varying float vAmount; varying vec2 vUV; void main() { vUV = uv; vec4 bumpData = texture2D( bumpTexture, uv ); vAmount = bumpData.r; // assuming map is grayscale it doesn't matter if you use r, g, or b. // move the position along the normal vec3 newPosition = position +

Detect software vs hardware webGL render mode

半腔热情 提交于 2019-12-11 06:57:20
问题 I've got an error I'm trying to catch with MapboxGL that doesn't handle when a version of IE switches the webGL render modes from hardware to software. I've been pouring over documentation and console logging pretty much everything I can, but can't find any documented way to find out if webGL is using hardware or software render modes. Any ideas? 回答1: You can check whether or not a browser can run GL JS in a hardware render mode using the mapbox-gl-supported library <script src='mapbox-gl

Webgl animated texture performance versus canvas drawImage performance

六眼飞鱼酱① 提交于 2019-12-11 06:54:00
问题 I'm beginning a project where I would like to slice sections from a single video and redraw those sections onto different objects on the screen. I know I can do this by using drawImage to redraw the sections of the video onto a canvas element. In doing research, it appears that it would be possible to do the same thing with an animated texture in WebGL. Does anyone know if there would be any performance gains by using a WebGL animated texture to do this rather than drawImage? 回答1: WebGL has

Texture not being rendered by OBJMTLLoader

五迷三道 提交于 2019-12-11 06:19:43
问题 I have a 3d model with texture that comes from Blender in OBJ/MTL/JPG format. But I cannot get this to render correctly with Three,js. The viewer code is identical to the example on the three.js website. I have only changed the paths to the OBJ and MTL files. I'm pretty sure all files are in the correct place. The OBJ and MTL files are loaded, and the path to the JPG in the MTL file is the correct path relative to the MTL file (there is a 404 if I change it). Yet the result is a black model.

How to get the 2d dimensions of the object being drawn for hit test on canvas 2d after canvas transformations?

走远了吗. 提交于 2019-12-11 06:08:19
问题 I draw simple shapes on 2d canvas, while applying transformations on shapes like so: const rect = ({ x, y, width, height }) => { ctx.fillStyle = 'black'; ctx.fillRect(x, y, width, height); }; const transform = ({ translate, rotate, scale }, f) => { // ctx is a 2d canvas context ctx.save(); if (translate) { ctx.translate(translate[0], translate[1]); } if (rotate) { ctx.rotate(rotate); } if (scale) { ctx.scale(scale[0], scale[1]); } f(ctx); ctx.restore(); }; const draw = () => { transform({