threejs论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 28139|回复: 0

Threejs的demo实例

[复制链接]

227

主题

203

帖子

589

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
589
发表于 2022-7-20 15:13:09 | 显示全部楼层 |阅读模式


三.js示例


此集合的目标是提供一组基本且具有指导意义的示例,以介绍 Three.js 中的各种功能。每个页面的源代码都包含详细的注释。
托管在GitHub 上。示例总数:83。最后更新时间:2013 年 8 月 23 日。与 Three.js 版本 60 兼容。

基本示例Hello World模板信息框材料 - 实体颜色资源管理器线框线和虚线助手轮廓效果面/顶点颜色形状拉伸Text3D
纹理示例纹理纹理 - 重复纹理 - Text3D半透明阴影细分修改器 - 立方体天空盒反射折射气泡来自画布的纹理 •纹理动画
精灵示例精灵精灵文本标签标记几何
鼠标和键盘示例鼠标精灵鼠标点击鼠标悬停鼠标工具提示键盘事件
相机/渲染器示例网格移动 •追逐相机多个相机相机到纹理视口 - 双视口 - 四嵌入式 HTML红/蓝立体图
着色器示例着色器 - 简单着色器 - 资源管理器着色器 - 球体展开着色器 - 属性着色器 - 动画材质着色器 - 动画火球着色器 - 发光效果简单发光(非着色器)
粒子系统示例粒子粒子系统 - 静态粒子系统 - 着色器粒子系统 - 属性粒子系统 - 动态粒子系统 - 路径运动粒子引擎
视频/网络摄像头示例视频到纹理网络摄像头测试网络摄像头到纹理运动检测运动检测和场景许多相机
图形用户界面示例GUIGUI 控制器
游戏手柄和 Leapmotion 控制器示例•游戏手柄测试网格移动 - 游戏手柄LeapMotion 可视化
模型示例模型动画模型带控件的动画模型
碰撞检测示例Collision Detection
行进立方体示例Marching Cubes 算法MetaballsMetabubbles
数学例子构造实体几何球体投影拓扑数据拓扑数据 2多面体查看器函数图示器 •参数曲面图示器 •参数曲线图示器
其他例子体素画家



你好世界
一个被大量评论但基本的场景。说明场景、相机、渲染器、事件处理程序(用于调整窗口大小和全屏,由 THREEx 库提供)、用于旋转/缩放/平移场景的鼠标控件、用于 FPS 统计的迷你显示以及设置基本几何图形的设置:具有照明效果的球体、多色立方体、应用了图像纹理的平面以及用于渲染远离相机的对象的天空盒/雾选项。
在下面的示例中更详细地描述了这些特征中的许多。


模板
删除了大部分注释和网格的“Hello World”代码。


信息框
添加了最小 jQuery 的模板代码以创建一个显示信息对话框的按钮。


材料 - 固体
说明 Basic、Lambert 和 Phong 材料之间的区别。


颜色浏览器
说明更改颜色(漫反射颜色)、环境颜色、发射颜色、镜面反射颜色、光泽量和不透明度量的效果。


线框
演示如何创建和应用线框材质。


线和虚线
演示如何创建实线、虚线,并包含将几何图形转换为线型对象的函数。


帮手
演示如何使用 AxisHelper、GridHelper 和 ArrowHelper 轻松创建基于行的对象。


轮廓效果
演示在网格周围显示实心轮廓的效果。


面/顶点颜色
为渐变效果的面和顶点分配颜色。


形状
使用一些内置几何构造函数来创建以下三维形状(和变体):立方体、二十面体、八面体、四面体、球体、圆顶、圆柱体、棱柱体、圆锥体、棱锥体、平截头体(截锥体和截锥体),圆环,圆环结。


挤压
创建一个 2D 点数组,创建一个 2D 形状,然后创建一个拉伸(横截面为给定 2D 形状的 3D 形状)。


文本3D
创建一个 3D 文本对象(呈现为 2D 图像的文本的突出版本)。


纹理
展示具有纹理(基于图像的材料)的表面,包括阴影和着色效果。


纹理 - 重复
在表面上重复(平铺)纹理。


纹理 - Text3D
将纹理应用于 3D 文本。(需要在表面上重复纹理。)


半透明
说明使用基本和 phong 着色半透明材料,使图像纹理半透明,使用添加混合以获得类似发光的效果,以及使用已经具有 alpha 透明度的图像纹理。


阴影
使用聚光灯在场景中创建阴影效果。


细分修改器 - 立方体
演示将附加点插值到几何图形的函数,从而创建“平滑”效果。此示例将修改器应用于各种立方体几何形状,从而生成球形和斜面立方体。


天空盒
使用纹理创建“SkyBox”:将背景图像投影到渲染区域周围的立方体上,从而产生远处 3D 环境的错觉。


反射
通过将周围环境的图像投影到物体上来创建类似镜子的材料。


折射
通过将周围环境的折射图像投影到物体上来创建类似玻璃的材料。


气泡
使用菲涅耳着色器创建类似气泡的材质(包含反射、折射和色差)。


来自画布的纹理
通过 JavaScript 创建一个画布元素,在其上绘制文本或图像,然后将其用作网格的纹理。


纹理动画
在表面上为 spritesheet 图像纹理设置动画。


精灵
精灵是显示在场景中的图像(不附加到几何体/表面),始终与相机正交。它们既可以出现在 3D 场景中(用作粒子效果的一部分),也可以使用屏幕坐标进行渲染(用作图形用户界面 (GUI) 或平视显示器 (HUD) 的一部分)。


精灵文本标签
结合 Sprite 演示中的技术和 Canvas 演示中的纹理,引入了一个可以轻松制作可自定义文本标签的功能。


标记几何
使用 Sprite Text Labels 演示使用索引号标记几何体的所有顶点和边缘。


鼠标精灵
在鼠标的当前位置显示一个精灵。(可能对定位图标或鼠标指针图标很有用。)


鼠标点击
单击时更改网格上面的颜色。


鼠标悬停
当鼠标悬停在场景中的对象上时,更改其颜色。


鼠标工具提示
创建工具提示样式效果以在鼠标悬停时显示网格名称。(使用示例中的想法:鼠标精灵、鼠标悬停和画布中的纹理。)


键盘事件
演示使用 KeyboardState.js 来响应按键按下/按下/按下事件。


网格运动
使用 THREEx.Keyboard 提供的功能,平移和旋转网格,具有以下控件:
W/S/Q/E:向前/向后/向左/向右(本地)平移。
A/D/R/F:左/右/上/下旋转(本地)。
上/下/左/右:平移 Z-/Z+/X-/X+(全局)。


追逐相机
创建一个“追逐凸轮”——将相机与网格一起移动。(与“网格移动”示例中的控件相同。)


多台摄像机
在多台摄像机之间切换:追逐摄像机(按“1”)和固定顶视图(按“2”)。(否则,与“网格移动”示例中的控件相同。)


相机到纹理
在相机周围移动并将它看到的东西投影到纹理上。(与“网格移动”示例中的控件相同。)


视口 - 双
同时将两个不同的相机视图渲染到同一个画布元素上。(与“网格移动”示例中的控件相同。)


视口 - 四边形
同时将四个不同的相机视图渲染到同一个画布元素上:一个透视相机和三个沿轴方向的正交相机(类似于许多 3D 建模软件配置)。(与“网格移动”示例中的控件相同。)


嵌入式 HTML
在 Three.js 场景中显示交互式网页。基于 Jerome Etienne 的工作:http://learningthreejs.com/blog/ ... een-html-and-webgl/


浮雕
显示使用浮雕效果渲染的场景;使用红色/蓝色 3D 眼镜观看。


着色器 - 简单
演示如何设置简单的预定义着色器(棕褐色着色)。


着色器 - 资源管理器
Illustrates the effects of changing the parameters in different shaders (sepia, vignette, dot screen).


Shader - Sphere Unwrapping
Demonstrates using a vertex shader to animate vertices, changing their positions according to their UV-coordinates; the result is a sphere that "flattens" into a plane.


Shader - Attributes
Demonstrates using a vertex shader to animate vertices, using "attributes": a set of values associated to each vertex.


Shader - Animated Materials
Demonstrates the animation of materials using shaders, featuring a lava effect and a water effect.


Shader - Animated Fireball
Builds upon the "Shader - Animated Materials" demo: a second image is randomly distorted and blended with the first, and the positions of the vertices are randomly distorted. These effects are combined to create an animated fireball.


Shader - Glow Effect
Create a glow effect using shaders. Includes GUI to adjust shader parameters. Using front-face rendering can create glow or shell style effects; using back-face rendering can create halo or atmosphere style effects (see information in-demo for corresponding parameter values).


Simple Glow (non-shader)
Create a glow effect *without* using custom shader material -- uses a additively blended sprite. (Only works well with spherical objects.)


Particles
Create a particle effect using a group of sprites and alpha blending (or transparency).


Particle System - Static
Create a group of particles using the ParticleSystem object (for faster rendering). Each vertex in a given geometry corresponds to the position of a particle.


Particle System - Shader
The "Particle System - Static" demo rewritten using a shader-based material; will be useful in subsequent demos.


Particle System - Attributes
Builds upon "Particle System - Shader" demo, incorporating shader attributes, enabling each particle to have customized properties - in this case, each particle is assigned a different color.


Particle System - Dynamic
Builds upon "Particle System - Attributes" demo, incorporating animation: particle sizes oscillate at different frequencies over time.


Particle System - Path Movement
A particle system with particles moving along a path.


Particle Engine
A complete particle engine for controlling a particle system to create special effects such as fire, smoke, stars, snow, and fireworks. Includes 11 example effects. Customizable particle properties include particle image, rotation, size, color, and opacity.


Video to Texture
Display a video as a texture. Keyboard controls: "P" to play/resume, "SPACE" to pause, "R" to rewind, "S" to stop.



Webcam Test
Displays user webcam image on this webpage. Requires Webcam, user needs to accept permissions to run, requires WebRTC compatible browser (see http://www.webrtc.org/). (No Three.js code required; this example is a lead-in to the following example.)


Webcam Texture
Displays user webcam image as a texture on a mesh. Requires Webcam, user needs to accept permissions to run, requires WebRTC compatible browser (see http://www.webrtc.org/). Press P to pause webcam (image freezes) and R to resume webcam.


Many Cameras
Displays user webcam image as a texture on a moveable mesh (W/A/S/D/Q/E). Incorporates code from examples: Webcam Texture, Mesh Movement, Reflection, Skybox, and Viewports - Dual. Requires Webcam, user needs to accept permissions to run, requires WebRTC compatible browser (see http://www.webrtc.org/).


Motion Detection
Displays user webcam image on webpage. Requires WebRTC compatible browser (see http://www.webrtc.org/). Detects motion occuring within given regions; see http://www.youtube.com/watch?v=ehkqgaGwGcw for demo. Based on http://www.adobe.com/devnet/html ... ion-detection.html. (No Three.js code required; this example is a lead-in to the following example.)


Motion Detection and Scene
Displays user webcam image on webpage. Requires Webcam, user needs to accept permissions to run, requires WebRTC compatible browser (see http://www.webrtc.org/). Detects motion occuring over graphics regions, and changes texture on spinning cube accordingly.


GUI
Create a graphical user interface (using the DAT.GUI library).


GUI Controller
Create a graphical user interface (using the DAT.GUI library) that controls the appearance of a cube mesh.


Gamepad Test
Uses a Gamepad (e.g. XBox controller) to move a square image around a canvas. Requires Chrome browser and connected gamepad to run. Uses gamepad.js library (patched) from http://github.com/inequation/gamepad.js. Analog sticks and directional pad move square up/down/left/right. A/B/X/Y buttons change colors of square. Start/select buttons reset square to original position. [Note: You may need to press one of A/B/X/Y buttons for controller to be recognized by the web browser.] (No Three.js code required; this example is a lead-in to the following example.)


Mesh Movement - Gamepad
Uses a Gamepad (e.g. XBox controller) to move a cube around a Three.js scene, similar to Mesh-Movement example above. Requires Chrome browser and connected gamepad to run. Left analog stick moves cube forward/backward and turns left/right. Directional pad moves cube forward/backward/left/right. Right analog stick only turns cube left/right. Right shoulder buttons double speed of movement/turns. Start/select buttons reset cube to original position and rotation.


LeapMotion - Visualization
Visualize hand/finger position data from LeapMotion device.
LeapMotion website


Model
Loading a static 3D model (exported from Blender to JavaScript).


Animated Model
Loading an animated 3D model (exported from Blender to JavaScript).


Animated Model with Controls
Loading an animated 3D model (exported from Blender to JavaScript). Model moves with arrow keys; model animates when moving and stops animating when not moving.


Collision Detection
Detect when the vertices of a mesh intersect with another object. (Move the wireframe cube with the arrow keys and rotate with W/A/S/D; the text "Hit" will appear at the top of the screen once for every vertex intersection.)


Marching Cubes Algorithm
An illustration of the "Marching Cubes" algorithm for triangulating a level surface ("isosurface") of an implicitly defined function f(x,y,z) = c. See the websites:
http://en.wikipedia.org/wiki/Marching_cubes/
http://paulbourke.net/geometry/polygonise/


Metaballs
A effect where spheres move around and their surfaces merge and split; the surfaces are calculated by implicit functions and drawn using the "Marching Cubes" algorithm. For more information, see the websites:
http://en.wikipedia.org/wiki/Metaballs
http://www.geisswerks.com/ryan/BLOBS/blobs.html


Metabubbles
Metaballs demo + Bubble demo = Metabubbles demo!


Constructive Solid Geometry
Create a new mesh from the union, intersection, or subtraction of two meshes. Uses the library at http://github.com/chandlerprall/ThreeCSG/


Sphere Projection
Projects a wireframe cube onto a sphere. Includes a method for drawing the arc between two points on a sphere.


Topology Data
From a THREE.Geometry, creates a topological data structure consisting of vertices, edges, and faces, with incidence data for each. For this example, the corresponding geometry is labeled (including edges) and the data can be manually verified from the browser console. (Builds on Lebeled Geometry demo.)


Topology Data 2
Builds upon Topology Data demo; illustrates edge and face subdivision and retriangulation functions and proper face coloring function.


Polyhedra Viewer
Interactive viewer of polyhedra (Platonic, Archimedean, Prisms, Antiprisms, Johnson Solids).


Function Grapher
Graph a function of the form z = f( x, y ).


Parametric Surface Grapher
Graph a parametric surface of the form x = f( u, v ), y = g( u, v ), z = h( u, v ).


Parametric Curve Grapher
Graph a parametric curve of the form x = f( t ), y = g( t ), z = h( t ).


Voxel Painter
Paint with voxels, Minecraft-style! (Think: 3D pixel editor.)


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|threejs论坛 ( 京ICP备18014583号 )

GMT+8, 2023-3-20 20:49 , Processed in 0.024154 second(s), 17 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表