未验证 提交 59f2cad6 编写于 作者: M Mr.doob 提交者: GitHub

Merge branch 'dev' into pmrem

......@@ -17,7 +17,7 @@ Please also include a live example if possible. You can start from these templat
##### Three.js version
- [ ] Dev
- [ ] r110
- [ ] r111
- [ ] ...
##### Browser
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -8,11 +8,11 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Material] &rarr; [page:MeshPhongMaterial] &rarr;
[page:Material] &rarr;
<h1>[name]</h1>
<div class="desc">An extension of the [page:MeshPhongMaterial] with toon shading.</div>
<div class="desc">A material implementing toon shading.</div>
<iframe id="scene" src="scenes/material-browser.html#MeshToonMaterial"></iframe>
......@@ -33,46 +33,193 @@
</script>
<h2>Examples</h2>
[example:webgl_materials_variations_toon materials / variations / toon]<br />
<p>
[example:webgl_materials_variations_toon materials / variations / toon]
</p>
<h2>Constructor</h2>
<h3>[name]( [param:Object parameters] )</h3>
<p>
[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance.
Any property of the material (including any property inherited from [page:Material] and [page:MeshStandardMaterial]) can be passed in here.<br /><br />
[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance.
Any property of the material (including any property inherited from [page:Material]) can be passed in here.<br /><br />
The exception is the property [page:Hexadecimal color], which can be passed in as a hexadecimal
string and is *0xffffff* (white) by default. [page:Color.set]( color ) is called internally.
The exception is the property [page:Hexadecimal color], which can be passed in as a hexadecimal
string and is *0xffffff* (white) by default. [page:Color.set]( color ) is called internally.
</p>
<h2>Properties</h2>
<p>See the base [page:Material] and [page:MeshPhongMaterial] classes for common properties.</p>
<p>See the base [page:Material] class for common properties.</p>
<h3>[property:Texture gradientMap]</h3>
<p>Gradient map for the toon shading. Default is *null*.</p>
<h3>[property:Texture alphaMap]</h3>
<p>The alpha map is a grayscale texture that controls the opacity across the surface
(black: fully transparent; white: fully opaque). Default is null.<br /><br />
Only the color of the texture is used, ignoring the alpha channel if one exists.
For RGB and RGBA textures, the [page:WebGLRenderer WebGL] renderer will use the
green channel when sampling this texture due to the extra bit of precision provided
for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and
luminance/alpha textures will also still work as expected.
</p>
<h3>[property:Texture aoMap]</h3>
<p>The red channel of this texture is used as the ambient occlusion map. Default is null.
The aoMap requires a second set of UVs, and consequently will ignore the [page:Texture repeat]
and [page:Texture offset] Texture properties.</p>
<h3>[property:Float aoMapIntensity]</h3>
<p>Intensity of the ambient occlusion effect. Default is 1. Zero is no occlusion effect.</p>
<h3>[property:Texture bumpMap]</h3>
<p>
The texture to create a bump map. The black and white values map to the perceived depth in relation to the lights.
Bump doesn't actually affect the geometry of the object, only the lighting. If a normal map is defined this will
be ignored.
</p>
<h3>[property:Float bumpScale]</h3>
<p>How much the bump map affects the material. Typical ranges are 0-1. Default is 1.</p>
<h3>[property:Color color]</h3>
<p>[page:Color] of the material, by default set to white (0xffffff).</p>
<h3>[property:Texture displacementMap]</h3>
<p>
The displacement map affects the position of the mesh's vertices. Unlike other maps
which only affect the light and shade of the material the displaced vertices can cast shadows,
block other objects, and otherwise act as real geometry. The displacement texture is
an image where the value of each pixel (white being the highest) is mapped against,
and repositions, the vertices of the mesh.
</p>
<h3>[property:Float displacementScale]</h3>
<p>
How much the displacement map affects the mesh (where black is no displacement,
and white is maximum displacement). Without a displacement map set, this value is not applied.
Default is 1.
</p>
<h3>[property:Float displacementBias]</h3>
<p>
The offset of the displacement map's values on the mesh's vertices.
Without a displacement map set, this value is not applied. Default is 0.
</p>
<h3>[property:Color emissive]</h3>
<p>
Emissive (light) color of the material, essentially a solid color unaffected by other lighting.
Default is black.
</p>
<h3>[property:Texture emissiveMap]</h3>
<p>
Set emisssive (glow) map. Default is null. The emissive map color is modulated by
the emissive color and the emissive intensity. If you have an emissive map, be sure to
set the emissive color to something other than black.
</p>
<h3>[property:Float emissiveIntensity]</h3>
<p>Intensity of the emissive light. Modulates the emissive color. Default is 1.</p>
<h3>[property:Boolean isMeshToonMaterial]</h3>
<p>
Used to check whether this or derived classes are mesh toon materials. Default is *true*.<br /><br />
Used to check whether this or derived classes are [name]. Default is *true*.<br /><br />
You should not change this, as it used internally for optimisation.
</p>
<h3>[property:Object defines]</h3>
<p>An object of the form:
<code>
{ 'TOON': '' };
</code>
<h3>[property:Texture gradientMap]</h3>
<p>Gradient map for toon shading. Default is *null*.</p>
<h3>[property:Texture lightMap]</h3>
<p>The light map. Default is null. The lightMap requires a second set of UVs,
and consequently will ignore the [page:Texture repeat] and [page:Texture offset]
Texture properties.</p>
<h3>[property:Float lightMapIntensity]</h3>
<p>Intensity of the baked light. Default is 1.</p>
<h3>[property:Texture map]</h3>
<p>The color map. Default is null. The texture map color is modulated by the diffuse [page:.color].</p>
<h3>[property:boolean morphNormals]</h3>
<p>
Defines whether the material uses morphNormals. Set as true to pass morphNormal
attributes from the [page:Geometry] to the shader. Default is *false*.
</p>
<h3>[property:Boolean morphTargets]</h3>
<p>Define whether the material uses morphTargets. Default is false.</p>
This is used by the [page:WebGLRenderer] for selecting shaders.
<h3>[property:Texture normalMap]</h3>
<p>
The texture to create a normal map. The RGB values affect the surface normal for each pixel fragment and change
the way the color is lit. Normal maps do not change the actual shape of the surface, only the lighting.
</p>
<h3>[property:Integer normalMapType]</h3>
<p>
The type of normal map.<br /><br />
<h2>Methods</h2>
<p>See the base [page:Material] and [page:MeshPhongMaterial] classes for common methods.</p>
Options are [page:constant THREE.TangentSpaceNormalMap] (default), and [page:constant THREE.ObjectSpaceNormalMap].
</p>
<h3>[property:Vector2 normalScale]</h3>
<p>
How much the normal map affects the material. Typical ranges are 0-1.
Default is a [page:Vector2] set to (1,1).
</p>
<h3>[property:Float shininess]</h3>
<p>How shiny the [page:.specular] highlight is; a higher value gives a sharper highlight. Default is *30*.</p>
<h3>[property:Boolean skinning]</h3>
<p>Define whether the material uses skinning. Default is false.</p>
<h3>[property:Color specular]</h3>
<p>
Specular color of the material. Default is a [page:Color] set to *0x111111* (very dark grey).<br /><br />
This defines how shiny the material is and the color of its shine.
</p>
<h3>[property:Texture specularMap]</h3>
<p>
The specular map value affects both how much the specular surface highlight
contributes and how much of the environment map affects the surface. Default is null.
</p>
<h3>[property:Boolean wireframe]</h3>
<p>Render geometry as wireframe. Default is *false* (i.e. render as flat polygons).</p>
<h3>[property:String wireframeLinecap]</h3>
<p>
Define appearance of line ends. Possible values are "butt", "round" and "square". Default is 'round'.<br /><br />
This corresponds to the [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap 2D Canvas lineCap]
property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
</p>
<h3>[property:String wireframeLinejoin]</h3>
<p>
Define appearance of line joints. Possible values are "round", "bevel" and "miter". Default is 'round'.<br /><br />
This corresponds to the [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineJoin 2D Canvas lineJoin]
property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
</p>
<h3>[property:Float wireframeLinewidth]</h3>
<p>Controls wireframe thickness. Default is 1.<br /><br />
Due to limitations of the [link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile]
with the [page:WebGLRenderer WebGL] renderer on most platforms linewidth will
always be 1 regardless of the set value.
</p>
<h2>Methods</h2>
<p>See the base [page:Material] class for common methods.</p>
<h2>Source</h2>
......
......@@ -25,7 +25,7 @@
<p>
[page:Vector3 origin] - (optional) the origin of the [page:Ray]. Default is a [page:Vector3] at (0, 0, 0).<br />
[page:Vector3 direction] - [page:Vector3] The direction of the [page:Ray]. This must be normalized
(with [page:Vector3.normalize]) for the methods to operate properly. Default is a [page:Vector3] at (0, 0, 0).<br /><br />
(with [page:Vector3.normalize]) for the methods to operate properly. Default is a [page:Vector3] at (0, 0, -1).<br /><br />
Creates a new [name].
</p>
......@@ -38,7 +38,7 @@
<h3>[property:Vector3 direction]</h3>
<p>
The direction of the [page:Ray]. This must be normalized (with [page:Vector3.normalize])
for the methods to operate properly. Default is a [page:Vector3] at (0, 0, 0).
for the methods to operate properly. Default is a [page:Vector3] at (0, 0, -1).
</p>
......
......@@ -113,6 +113,9 @@ var d = a.distanceTo( b );
Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective.
</p>
<h3>[method:this applyNormalMatrix]( [param:Matrix3 m] )</h3>
<p>Multiplies this vector by normal matrix [page:Matrix3 m] and normalizes the result.</p>
<h3>[method:this applyQuaternion]( [param:Quaternion quaternion] )</h3>
<p>
Applies a [page:Quaternion] transform to this vector.
......
......@@ -8,11 +8,11 @@
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
[page:Material] &rarr; [page:MeshPhongMaterial] &rarr;
[page:Material] &rarr;
<h1>卡通网格材质([name])</h1>
<h1>[name]</h1>
<div class="desc">[page:MeshPhongMaterial]卡通着色的扩展。</div>
<div class="desc">A material implementing toon shading.</div>
<iframe id="scene" src="scenes/material-browser.html#MeshToonMaterial"></iframe>
......@@ -32,45 +32,196 @@
</script>
<h2>例子(Examples)</h2>
[example:webgl_materials_variations_toon materials / variations / toon]<br />
<h2>Examples</h2>
<p>
[example:webgl_materials_variations_toon materials / variations / toon]
</p>
<h2>构造函数(Constructor)</h2>
<h2>Constructor</h2>
<h3>[name]( [param:Object parameters] )</h3>
<p> [page:Object parameters] - (可选)用于定义材质外观的对象,具有一个或多个属性。
材质的任何属性都可以从此处传入(包括从[page:Material]和[page:MeshStandardMaterial]继承的任何属性)。<br /><br />
属性[page:Hexadecimal color]例外,其可以作为十六进制字符串传递,默认情况下为 *0xffffff*(白色),内部调用[page:Color.set](color)。
<p>
[page:Object parameters] - (optional) an object with one or more properties defining the material's appearance.
Any property of the material (including any property inherited from [page:Material]) can be passed in here.<br /><br />
The exception is the property [page:Hexadecimal color], which can be passed in as a hexadecimal
string and is *0xffffff* (white) by default. [page:Color.set]( color ) is called internally.
</p>
<h2>Properties</h2>
<p>See the base [page:Material] class for common properties.</p>
<h2>属性(Properties)</h2>
<p>共有属性请参见其基类[page:Material]和[page:MeshPhongMaterial]。</p>
<h3>[property:Texture alphaMap]</h3>
<p>The alpha map is a grayscale texture that controls the opacity across the surface
(black: fully transparent; white: fully opaque). Default is null.<br /><br />
<h3>[property:Texture gradientMap]</h3>
<p> 卡通着色的渐变贴图,默认值为*null*。</p>
Only the color of the texture is used, ignoring the alpha channel if one exists.
For RGB and RGBA textures, the [page:WebGLRenderer WebGL] renderer will use the
green channel when sampling this texture due to the extra bit of precision provided
for green in DXT-compressed and uncompressed RGB 565 formats. Luminance-only and
luminance/alpha textures will also still work as expected.
</p>
<h3>[property:Texture aoMap]</h3>
<p>The red channel of this texture is used as the ambient occlusion map. Default is null.
The aoMap requires a second set of UVs, and consequently will ignore the [page:Texture repeat]
and [page:Texture offset] Texture properties.</p>
<h3>[property:Float aoMapIntensity]</h3>
<p>Intensity of the ambient occlusion effect. Default is 1. Zero is no occlusion effect.</p>
<h3>[property:Texture bumpMap]</h3>
<p>
The texture to create a bump map. The black and white values map to the perceived depth in relation to the lights.
Bump doesn't actually affect the geometry of the object, only the lighting. If a normal map is defined this will
be ignored.
</p>
<h3>[property:Float bumpScale]</h3>
<p>How much the bump map affects the material. Typical ranges are 0-1. Default is 1.</p>
<h3>[property:Color color]</h3>
<p>[page:Color] of the material, by default set to white (0xffffff).</p>
<h3>[property:Texture displacementMap]</h3>
<p>
The displacement map affects the position of the mesh's vertices. Unlike other maps
which only affect the light and shade of the material the displaced vertices can cast shadows,
block other objects, and otherwise act as real geometry. The displacement texture is
an image where the value of each pixel (white being the highest) is mapped against,
and repositions, the vertices of the mesh.
</p>
<h3>[property:Float displacementScale]</h3>
<p>
How much the displacement map affects the mesh (where black is no displacement,
and white is maximum displacement). Without a displacement map set, this value is not applied.
Default is 1.
</p>
<h3>[property:Float displacementBias]</h3>
<p>
The offset of the displacement map's values on the mesh's vertices.
Without a displacement map set, this value is not applied. Default is 0.
</p>
<h3>[property:Color emissive]</h3>
<p>
Emissive (light) color of the material, essentially a solid color unaffected by other lighting.
Default is black.
</p>
<h3>[property:Texture emissiveMap]</h3>
<p>
Set emisssive (glow) map. Default is null. The emissive map color is modulated by
the emissive color and the emissive intensity. If you have an emissive map, be sure to
set the emissive color to something other than black.
</p>
<h3>[property:Float emissiveIntensity]</h3>
<p>Intensity of the emissive light. Modulates the emissive color. Default is 1.</p>
<h3>[property:Boolean isMeshToonMaterial]</h3>
<p> 用于检查此类或派生类是否为卡通网格材质。默认值为 *true*。<br /><br />
<p>
Used to check whether this or derived classes are [name]. Default is *true*.<br /><br />
因为其通常用在内部优化,所以不应该更改该属性值。
You should not change this, as it used internally for optimisation.
</p>
<h3>[property:Object defines]</h3>
<p>如下形式的对象:
<code>
{ 'TOON': '' };
</code>
<h3>[property:Texture gradientMap]</h3>
<p>Gradient map for toon shading. Default is *null*.</p>
<h3>[property:Texture lightMap]</h3>
<p>The light map. Default is null. The lightMap requires a second set of UVs,
and consequently will ignore the [page:Texture repeat] and [page:Texture offset]
Texture properties.</p>
<h3>[property:Float lightMapIntensity]</h3>
<p>Intensity of the baked light. Default is 1.</p>
[page:WebGLRenderer]使用它来选择shaders。
<h3>[property:Texture map]</h3>
<p>The color map. Default is null. The texture map color is modulated by the diffuse [page:.color].</p>
<h3>[property:boolean morphNormals]</h3>
<p>
Defines whether the material uses morphNormals. Set as true to pass morphNormal
attributes from the [page:Geometry] to the shader. Default is *false*.
</p>
<h3>[property:Boolean morphTargets]</h3>
<p>Define whether the material uses morphTargets. Default is false.</p>
<h3>[property:Texture normalMap]</h3>
<p>
The texture to create a normal map. The RGB values affect the surface normal for each pixel fragment and change
the way the color is lit. Normal maps do not change the actual shape of the surface, only the lighting.
</p>
<h3>[property:Integer normalMapType]</h3>
<p>
The type of normal map.<br /><br />
Options are [page:constant THREE.TangentSpaceNormalMap] (default), and [page:constant THREE.ObjectSpaceNormalMap].
</p>
<h3>[property:Vector2 normalScale]</h3>
<p>
How much the normal map affects the material. Typical ranges are 0-1.
Default is a [page:Vector2] set to (1,1).
</p>
<h3>[property:Float shininess]</h3>
<p>How shiny the [page:.specular] highlight is; a higher value gives a sharper highlight. Default is *30*.</p>
<h3>[property:Boolean skinning]</h3>
<p>Define whether the material uses skinning. Default is false.</p>
<h3>[property:Color specular]</h3>
<p>
Specular color of the material. Default is a [page:Color] set to *0x111111* (very dark grey).<br /><br />
<h2>方法(Methods)</h2>
<p>共有方法请参见其基类[page:Material]和[page:MeshPhongMaterial]。</p>
This defines how shiny the material is and the color of its shine.
</p>
<h3>[property:Texture specularMap]</h3>
<p>
The specular map value affects both how much the specular surface highlight
contributes and how much of the environment map affects the surface. Default is null.
</p>
<h3>[property:Boolean wireframe]</h3>
<p>Render geometry as wireframe. Default is *false* (i.e. render as flat polygons).</p>
<h3>[property:String wireframeLinecap]</h3>
<p>
Define appearance of line ends. Possible values are "butt", "round" and "square". Default is 'round'.<br /><br />
This corresponds to the [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineCap 2D Canvas lineCap]
property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
</p>
<h3>[property:String wireframeLinejoin]</h3>
<p>
Define appearance of line joints. Possible values are "round", "bevel" and "miter". Default is 'round'.<br /><br />
This corresponds to the [link:https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D/lineJoin 2D Canvas lineJoin]
property and it is ignored by the [page:WebGLRenderer WebGL] renderer.
</p>
<h3>[property:Float wireframeLinewidth]</h3>
<p>Controls wireframe thickness. Default is 1.<br /><br />
Due to limitations of the [link:https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf OpenGL Core Profile]
with the [page:WebGLRenderer WebGL] renderer on most platforms linewidth will
always be 1 regardless of the set value.
</p>
<h2>Methods</h2>
<p>See the base [page:Material] class for common methods.</p>
<h2>源码(Source)</h2>
<h2>Source</h2>
<p>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
......
......@@ -24,7 +24,7 @@
<p>
[page:Vector3 origin] - (可选)[page:Ray](射线)的原点,默认值是一个位于(0, 0, 0)的[page:Vector3]。<br />
[page:Vector3 direction] - [page:Vector3] [page:Ray](射线)的方向。该向量必须经过标准化(使用[page:Vector3.normalize]),这样才能使方法正常运行。
默认值是一个位于(0, 0, 0)的[page:Vector3]。<br /><br />
默认值是一个位于(0, 0, -1)的[page:Vector3]。<br /><br />
创建一个新的[name]。
</p>
......@@ -37,7 +37,7 @@
<h3>[property:Vector3 direction]</h3>
<p>
[page:Ray](射线)的方向。该向量必须经过标准化(使用[page:Vector3.normalize]),这样才能使方法正常运行。
默认值是一个位于(0, 0, 0)的[page:Vector3]。
默认值是一个位于(0, 0, -1)的[page:Vector3]。
</p>
......@@ -190,7 +190,7 @@
<p>
[page:Vector3 origin] - [page:Ray](射线)的[page:.origin origin](原点)。<br />
[page:Vector3 origin] - [page:Ray](射线)的[page:.direction direction](方向)。
该向量必须经过标准化(使用[page:Vector3.normalize]),这样才能使方法正常运行。
<br /><br />
......
......@@ -20,22 +20,22 @@
<h2>Workflow</h2>
<p>
First, you have to include [link:https://github.com/mrdoob/three.js/blob/master/examples/js/vr/WebVR.js WebVR.js]
First, you have to include [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/VRButton.js VRButton.js]
into your project.
</p>
<code>
import { WEBVR } from 'three/examples/jsm/vr/WebVR.js';
import { VRButton } from 'three/examples/jsm/webxr/VRButton.js';
</code>
<p>
*WEBVR.createButton()* does two important things: It creates a button which indicates
*VRButton.createButton()* does two important things: It creates a button which indicates
VR compatibility. Besides, it initiates a VR session if the user activates the button. The only thing you have
to do is to add the following line of code to your app.
</p>
<code>
document.body.appendChild( WEBVR.createButton( renderer ) );
document.body.appendChild( VRButton.createButton( renderer ) );
</code>
<p>
......@@ -65,17 +65,18 @@ renderer.setAnimationLoop( function () {
<p>
Have a look at one of the official WebVR examples to see this workflow in action.<br /><br />
[example:webvr_ballshooter WebVR / ballshoter]<br />
[example:webvr_cubes WebVR / cubes]<br />
[example:webvr_dragging WebVR / dragging]<br />
[example:webvr_lorenzattractor WebVR / lorenzattractor]<br />
[example:webvr_panorama WebVR / panorama]<br />
[example:webvr_paint WebVR / paint]<br />
[example:webvr_rollercoaster WebVR / rollercoaster]<br />
[example:webvr_sandbox WebVR / sandbox]<br />
[example:webvr_sculpt WebVR / sculpt]<br />
[example:webvr_vive_paint WebVR / vive / paint]<br />
[example:webvr_vive_sculpt WebVR / vive / sculpt]<br />
[example:webxr_vr_ballshooter WebXR / VR / ballshoter]<br />
[example:webxr_vr_cubes WebXR / VR / cubes]<br />
[example:webxr_vr_dragging WebXR / VR / dragging]<br />
[example:webxr_vr_lorenzattractor WebXR / VR / lorenzattractor]<br />
[example:webxr_vr_multiview WebXR / VR / multiview]<br />
[example:webxr_vr_paint WebXR / VR / paint]<br />
[example:webxr_vr_panorama_depth WebXR / VR / panorama_depth]<br />
[example:webxr_vr_panorama WebXR / VR / panorama]<br />
[example:webxr_vr_rollercoaster WebXR / VR / rollercoaster]<br />
[example:webxr_vr_sandbox WebXR / VR / sandbox]<br />
[example:webxr_vr_sculpt WebXR / VR / sculpt]<br />
[example:webxr_vr_video WebXR / VR / video]
</p>
</body>
......
......@@ -19,21 +19,21 @@
<h2>工作流程</h2>
<p>
首先,你需要将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/vr/WebVR.js WebVR.js]
首先,你需要将[link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/VRButton.js VRButton.js]
包含到你的项目中。
</p>
<code>
import { WEBVR } from 'three/examples/jsm/vr/WebVR.js';
import { VRButton } from 'three/examples/jsm/webxr/VRButton.js';
</code>
<p>*WEBVR.createButton()*做了两件重要的事情:首先,它创建了一个按钮,指示了VR的兼容性;
<p>*VRButton.createButton()*做了两件重要的事情:首先,它创建了一个按钮,指示了VR的兼容性;
此外,若用户激活了这个按钮,则它将开启一个VR会话。
你所要做的唯一一件事情,便是把下面的这一行代码加入到你的应用程序里。
</p>
<code>
document.body.appendChild( WEBVR.createButton( renderer ) );
document.body.appendChild( VRButton.createButton( renderer ) );
</code>
<p>
......@@ -65,17 +65,18 @@ renderer.setAnimationLoop( function () {
请查看官方示例中与WebVR相关的示例,了解这一工作流程的实际使用、运行情况。
<br /><br />
[example:webvr_ballshooter WebVR / ballshoter]<br />
[example:webvr_cubes WebVR / cubes]<br />
[example:webvr_dragging WebVR / dragging]<br />
[example:webvr_lorenzattractor WebVR / lorenzattractor]<br />
[example:webvr_panorama WebVR / panorama]<br />
[example:webvr_paint WebVR / paint]<br />
[example:webvr_rollercoaster WebVR / rollercoaster]<br />
[example:webvr_sandbox WebVR / sandbox]<br />
[example:webvr_sculpt WebVR / sculpt]<br />
[example:webvr_vive_paint WebVR / vive / paint]<br />
[example:webvr_vive_sculpt WebVR / vive / sculpt]<br />
[example:webxr_vr_ballshooter WebXR / VR / ballshoter]<br />
[example:webxr_vr_cubes WebXR / VR / cubes]<br />
[example:webxr_vr_dragging WebXR / VR / dragging]<br />
[example:webxr_vr_lorenzattractor WebXR / VR / lorenzattractor]<br />
[example:webxr_vr_multiview WebXR / VR / multiview]<br />
[example:webxr_vr_paint WebXR / VR / paint]<br />
[example:webxr_vr_panorama_depth WebXR / VR / panorama_depth]<br />
[example:webxr_vr_panorama WebXR / VR / panorama]<br />
[example:webxr_vr_rollercoaster WebXR / VR / rollercoaster]<br />
[example:webxr_vr_sandbox WebXR / VR / sandbox]<br />
[example:webxr_vr_sculpt WebXR / VR / sculpt]<br />
[example:webxr_vr_video WebXR / VR / video]
</p>
</body>
......
......@@ -7,8 +7,6 @@
<link rel="apple-touch-icon" href="images/icon.png">
<link rel="manifest" href="manifest.json">
<link rel="shortcut icon" href="../files/favicon.ico" />
<!-- WebXR Device API (For Chrome M76+), expires 12/04/2019 -->
<meta http-equiv="origin-trial" content="Aq9LklhCLNUveuCr7QTpGpqwCPG817cYHdVyQuJPOZYk47iRB390lUKa5edVmgS1pZSl8HPspElEC/91Fz55dwIAAABTeyJvcmlnaW4iOiJodHRwczovL3RocmVlanMub3JnOjQ0MyIsImZlYXR1cmUiOiJXZWJYUkRldmljZU03NiIsImV4cGlyeSI6MTU3NTQxNzU5OX0=">
</head>
<body ontouchstart="">
<link rel="stylesheet" href="css/main.css">
......@@ -26,7 +24,6 @@
<script src="../examples/js/loaders/DRACOLoader.js"></script>
<script src="../examples/js/loaders/FBXLoader.js"></script>
<script src="../examples/js/loaders/GLTFLoader.js"></script>
<script src="../examples/js/loaders/deprecated/LegacyGLTFLoader.js"></script>
<script src="../examples/js/loaders/KMZLoader.js"></script>
<script src="../examples/js/loaders/MD2Loader.js"></script>
<script src="../examples/js/loaders/OBJLoader.js"></script>
......
......@@ -158,7 +158,7 @@ var Loader = function ( editor ) {
if ( isGLTF1( contents ) ) {
loader = new THREE.LegacyGLTFLoader( manager );
alert( 'Import of glTF asset not possible. Only versions >= 2.0 are supported. Please try to upgrade the file to glTF 2.0 using glTF-Pipeline.' );
} else {
......
// r110
// r111
const assets = [
'./',
......@@ -18,7 +18,6 @@ const assets = [
'../examples/js/loaders/DRACOLoader.js',
'../examples/js/loaders/FBXLoader.js',
'../examples/js/loaders/GLTFLoader.js',
'../examples/js/loaders/deprecated/LegacyGLTFLoader.js',
'../examples/js/loaders/KMZLoader.js',
'../examples/js/loaders/MD2Loader.js',
'../examples/js/loaders/OBJLoader.js',
......
......@@ -7,6 +7,12 @@
<link type="text/css" rel="stylesheet" href="main.css">
</head>
<body>
<div id="overlay">
<div>
<button id="startButton">Start Demo</button>
<p>Using device orientation might require a user interaction.</p>
</div>
</div>
<div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> css3d - panorama - device orientation.<br/>cubemap by <a href="http://www.humus.name/index.php?page=Textures" target="_blank" rel="noopener">Humus</a>.</div>
<script type="module">
......@@ -19,11 +25,19 @@
var camera, scene, renderer;
var controls;
init();
animate();
var startButton = document.getElementById( 'startButton' );
startButton.addEventListener( 'click', function () {
init();
animate();
}, false );
function init() {
var overlay = document.getElementById( 'overlay' );
overlay.remove();
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 1000 );
controls = new DeviceOrientationControls( camera );
......
......@@ -47,8 +47,8 @@ var files = {
"webgl_geometry_text_shapes",
"webgl_geometry_text_stroke",
"webgl_helpers",
"webgl_instancing_suzanne",
"webgl_instancing_raycast",
"webgl_instancing_suzanne",
"webgl_interactive_buffergeometry",
"webgl_interactive_cubes",
"webgl_interactive_cubes_gpu",
......@@ -322,21 +322,20 @@ var files = {
"webaudio_timing",
"webaudio_visualizer"
],
"webvr": [
"webvr_ballshooter",
"webvr_cubes",
"webvr_dragging",
"webvr_lorenzattractor",
"webvr_multiview",
"webvr_panorama",
"webvr_panorama_depth",
"webvr_paint",
"webvr_rollercoaster",
"webvr_sandbox",
"webvr_sculpt",
"webvr_video",
"webvr_vive_paint",
"webvr_vive_sculpt"
"webxr": [
"webxr_ar_paint",
"webxr_vr_ballshooter",
"webxr_vr_cubes",
"webxr_vr_dragging",
"webxr_vr_lorenzattractor",
"webxr_vr_multiview",
"webxr_vr_panorama",
"webxr_vr_panorama_depth",
"webxr_vr_paint",
"webxr_vr_rollercoaster",
"webxr_vr_sandbox",
"webxr_vr_sculpt",
"webxr_vr_video"
],
"physics": [
"webgl_physics_cloth",
......
......@@ -246,7 +246,9 @@ THREE.LineMaterial = function ( parameters ) {
uniforms: THREE.UniformsUtils.clone( THREE.ShaderLib[ 'line' ].uniforms ),
vertexShader: THREE.ShaderLib[ 'line' ].vertexShader,
fragmentShader: THREE.ShaderLib[ 'line' ].fragmentShader
fragmentShader: THREE.ShaderLib[ 'line' ].fragmentShader,
clipping: true // required for clipping support
} );
......
......@@ -150,7 +150,7 @@ THREE.GLTFLoader = ( function () {
if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.' ) );
if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
return;
}
......@@ -433,7 +433,7 @@ THREE.GLTFLoader = ( function () {
} else if ( this.header.version < 2.0 ) {
throw new Error( 'THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.' );
throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
}
......
/**
* @author mrdoob / http://mrdoob.com
*/
THREE.PaintViveController = function ( id ) {
THREE.ViveController.call( this, id );
var PI2 = Math.PI * 2;
var MODES = { COLOR: 0, SIZE: 1 };
var mode = MODES.COLOR;
var color = new THREE.Color( 1, 1, 1 );
var size = 1.0;
//
function generateHueTexture() {
var canvas = document.createElement( 'canvas' );
canvas.width = 256;
canvas.height = 256;
var context = canvas.getContext( '2d' );
var imageData = context.getImageData( 0, 0, 256, 256 );
var data = imageData.data;
var swatchColor = new THREE.Color();
for ( var i = 0, j = 0; i < data.length; i += 4, j ++ ) {
var x = ( ( j % 256 ) / 256 ) - 0.5;
var y = ( Math.floor( j / 256 ) / 256 ) - 0.5;
swatchColor.setHSL( Math.atan2( y, x ) / PI2, 1, ( 0.5 - Math.sqrt( x * x + y * y ) ) * 2.0 );
data[ i + 0 ] = swatchColor.r * 256;
data[ i + 1 ] = swatchColor.g * 256;
data[ i + 2 ] = swatchColor.b * 256;
data[ i + 3 ] = 256;
}
context.putImageData( imageData, 0, 0 );
return new THREE.CanvasTexture( canvas );
}
// COLOR UI
var geometry = new THREE.CircleBufferGeometry( 1, 32 );
var material = new THREE.MeshBasicMaterial( { map: generateHueTexture() } );
var colorUI = new THREE.Mesh( geometry, material );
colorUI.position.set( 0, 0.005, 0.0495 );
colorUI.rotation.x = - 1.45;
colorUI.scale.setScalar( 0.02 );
this.add( colorUI );
var geometry = new THREE.IcosahedronBufferGeometry( 0.1, 2 );
var material = new THREE.MeshBasicMaterial();
material.color = color;
var ball = new THREE.Mesh( geometry, material );
colorUI.add( ball );
// SIZE UI
var sizeUI = new THREE.Group();
sizeUI.position.set( 0, 0.005, 0.0495 );
sizeUI.rotation.x = - 1.45;
sizeUI.scale.setScalar( 0.02 );
this.add( sizeUI );
var triangleShape = new THREE.Shape();
triangleShape.moveTo( 0, - 1 );
triangleShape.lineTo( 1, 1 );
triangleShape.lineTo( - 1, 1 );
var geometry = new THREE.ShapeBufferGeometry( triangleShape );
var material = new THREE.MeshBasicMaterial( { color: 0x222222, wireframe: true } );
var sizeUIOutline = new THREE.Mesh( geometry, material );
sizeUIOutline.position.z = 0.001;
resizeTriangleGeometry( sizeUIOutline.geometry, 1.0 );
sizeUI.add( sizeUIOutline );
var geometry = new THREE.ShapeBufferGeometry( triangleShape );
var material = new THREE.MeshBasicMaterial( { side: THREE.DoubleSide } );
material.color = color;
var sizeUIFill = new THREE.Mesh( geometry, material );
sizeUIFill.position.z = 0.0011;
resizeTriangleGeometry( sizeUIFill.geometry, 0.5 );
sizeUI.add( sizeUIFill );
sizeUI.visible = false;
function onAxisChanged( event ) {
if ( this.getButtonState( 'thumbpad' ) === false ) return;
var x = event.axes[ 0 ] / 2.0;
var y = - event.axes[ 1 ] / 2.0;
if ( mode === MODES.COLOR ) {
color.setHSL( Math.atan2( y, x ) / PI2, 1, ( 0.5 - Math.sqrt( x * x + y * y ) ) * 2.0 );
ball.position.set( event.axes[ 0 ], event.axes[ 1 ], 0 );
}
if ( mode === MODES.SIZE ) {
var ratio = 0.5 - y;
size = ratio * 2;
resizeTriangleGeometry( sizeUIFill.geometry, ratio );
}
}
function resizeTriangleGeometry( geometry, ratio ) {
var x = 0, y = 0;
var fullWidth = 0.75, fullHeight = 1.5;
var angle = Math.atan( ( fullWidth / 2 ) / fullHeight );
var bottomY = y - fullHeight / 2;
var height = fullHeight * ratio;
var width = ( Math.tan( angle ) * height ) * 2;
var position = geometry.attributes.position;
position.setXYZ( 0, x, bottomY, 0 );
position.setXYZ( 1, x + width / 2, bottomY + height, 0 );
position.setXYZ( 2, x - width / 2, bottomY + height, 0 );
position.needsUpdate = true;
}
function onGripsDown() {
if ( mode === MODES.COLOR ) {
mode = MODES.SIZE;
colorUI.visible = false;
sizeUI.visible = true;
return;
}
if ( mode === MODES.SIZE ) {
mode = MODES.COLOR;
colorUI.visible = true;
sizeUI.visible = false;
return;
}
}
this.getColor = function () {
return color;
};
this.getSize = function () {
return size;
};
this.addEventListener( 'axischanged', onAxisChanged );
this.addEventListener( 'gripsdown', onGripsDown );
};
THREE.PaintViveController.prototype = Object.create( THREE.ViveController.prototype );
THREE.PaintViveController.prototype.constructor = THREE.PaintViveController;
此差异已折叠。
......@@ -9,6 +9,8 @@ THREE.WEBVR = {
createButton: function ( renderer, options ) {
console.warn( 'WEBVR.js has been deprecated. Use VRButton.js instead.' );
if ( options && options.referenceSpaceType ) {
renderer.vr.setReferenceSpaceType( options.referenceSpaceType );
......
此差异已折叠。
declare interface Stats {
REVISION: number;
dom: HTMLDivElement;
addPanel(panel: Stats.Panel): Stats.Panel;
showPanel(id: number): void;
begin(): void;
end(): void;
update(): void;
domElement: HTMLDivElement;
setMode(id: number): void;
}
declare function Stats(): Stats;
declare namespace Stats {
interface Panel {
dom: HTMLCanvasElement;
update(value: number, maxValue: number): void;
}
function Panel(): Panel;
}
export default Stats
......@@ -254,7 +254,9 @@ var LineMaterial = function ( parameters ) {
uniforms: UniformsUtils.clone( ShaderLib[ 'line' ].uniforms ),
vertexShader: ShaderLib[ 'line' ].vertexShader,
fragmentShader: ShaderLib[ 'line' ].fragmentShader
fragmentShader: ShaderLib[ 'line' ].fragmentShader,
clipping: true // required for clipping support
} );
......
......@@ -217,7 +217,7 @@ var GLTFLoader = ( function () {
if ( json.asset === undefined || json.asset.version[ 0 ] < 2 ) {
if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported. Use LegacyGLTFLoader instead.' ) );
if ( onError ) onError( new Error( 'THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.' ) );
return;
}
......@@ -500,7 +500,7 @@ var GLTFLoader = ( function () {
} else if ( this.header.version < 2.0 ) {
throw new Error( 'THREE.GLTFLoader: Legacy binary file detected. Use LegacyGLTFLoader instead.' );
throw new Error( 'THREE.GLTFLoader: Legacy binary file detected.' );
}
......
import {
AnimationClip,
Camera,
Loader,
LoadingManager,
Scene
} from '../../../../src/Three';
export interface GLTF {
animations: AnimationClip[];
scene: Scene;
scenes: Scene[];
cameras: Camera[];
}
export class LegacyGLTFLoader extends Loader {
constructor( manager?: LoadingManager );
load( url: string, onLoad: ( gltf: GLTF ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ): void;
parse( data: ArrayBuffer | string, path: string, callback: ( gltf: GLTF ) => void ): void;
}
import {
Geometry,
Loader,
LoadingManager,
Material
} from '../../../../src/Three';
export interface LegacyJSONLoaderResult {
geometry: Geometry;
materials: Material[];
}
export class LegacyJSONLoader extends Loader {
constructor( manager?: LoadingManager );
withCredentials: boolean;
load( url: string, onLoad: ( geometry: Geometry, materials: Material[] ) => void, onProgress?: ( event: ProgressEvent ) => void, onError?: ( event: ErrorEvent ) => void ): void;
parse( json: object, path: string ): LegacyJSONLoaderResult;
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册