language stringclasses 1 value | owner stringlengths 2 15 | repo stringlengths 2 21 | sha stringlengths 45 45 | message stringlengths 7 36.3k | path stringlengths 1 199 | patch stringlengths 15 102k | is_multipart bool 2 classes |
|---|---|---|---|---|---|---|---|
Other | mrdoob | three.js | a6c3193465f533048d1608fbce30d3bbaf9e5d74.json | Translate some page in the object,and little fix. | docs/api/zh/objects/Group.html | @@ -10,15 +10,14 @@
<body>
[page:Object3D] →
- <h1>[name]</h1>
+ <h1>组([name])</h1>
<p class="desc">
- This is almost identical to an [page:Object3D Object3D]. Its purpose is to make working
- with groups of objects syntactically clearer.
+ 它几乎和[page:Object3D Object3D]是相同的,其目的是使得组中对象在语法上的结构更加清晰。
</p>
- <h2>Example</h2>
+ <h2>示例</h2>
<code>
var geometry = new THREE.BoxBufferGeometry( 1, 1, 1 );
@@ -40,20 +39,20 @@ <h2>Example</h2>
</code>
- <h2>Constructor</h2>
+ <h2>构造器</h2>
<h3>[name]( )</h3>
- <h2>Properties</h2>
- <p>See the base [page:Object3D] class for common properties.</p>
+ <h2>属性</h2>
+ <p>请参阅其基类[page:Object3D]来查看公共属性。</p>
<h3>[property:String type]</h3>
- <p>A string 'Group'. This should not be changed.</p>
+ <p>一个字符串:“Group”。这个属性不应当被改变。</p>
- <h2>Methods</h2>
- <p>See the base [page:Object3D] class for common methods.</p>
+ <h2>方法</h2>
+ <p>请参阅其基类[page:Object3D]来查看其公共方法。</p>
- <h2>Source</h2>
+ <h2>源代码</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body> | true |
Other | mrdoob | three.js | a6c3193465f533048d1608fbce30d3bbaf9e5d74.json | Translate some page in the object,and little fix. | docs/api/zh/objects/Skeleton.html | @@ -9,14 +9,13 @@
</head>
<body>
- <h1>[name]</h1>
+ <h1>骨架([name])</h1>
<p class="desc">
- Use an array of [page:Bone bones] to create a skeleton that can be used by a
- [page:SkinnedMesh].
+ 使用一个[page:Bone bones]数组来创建一个可以由[page:SkinnedMesh]使用的骨架。
</p>
- <h2>Example</h2>
+ <h2>实例</h2>
<code>
// Create a simple "arm"
@@ -40,76 +39,75 @@ <h2>Example</h2>
var armSkeleton = new THREE.Skeleton( bones );
</code>
<p>
- See the [page:SkinnedMesh] page for an example of usage with standard [page:BufferGeometry].
+ 请查看[page:SkinnedMesh]页面,来查看其在标准的[page:BufferGeometry]中使用的示例。
</p>
- <h2>Constructor</h2>
+ <h2>构造器</h2>
<h3>[name]( [param:Array bones], [param:Array boneInverses] )</h3>
<p>
- [page:Array bones] - The array of [page:Bone bones]. Default is an empty array.<br/>
- [page:Array boneInverses] - (optional) An array of [page:Matrix4 Matrix4s].<br /><br />
+ [page:Array bones] —— 包含有一组[page:Bone bone]的数组,默认值是一个空数组。<br/>
+ [page:Array boneInverses] —— (可选) 包含[page:Matrix4 Matrix4]的数组。<br /><br />
- Creates a new [name].
+ 创建一个新的[name].
</p>
- <h2>Properties</h2>
+ <h2>属性</h2>
<h3>[property:Array bones]</h3>
<p>
- The array of [page:bone bones]. Note this is a copy of the original array, not a reference,
- so you can modify the original array without effecting this one.
+ 包含有一组[page:Bone bone]的数组。请注意,这是一份原始数组的拷贝,不是引用,所以你可以在不对当前数组造成影响的情况下,修改原始数组。
</p>
<h3>[property:Array boneInverses]</h3>
<p>
- An array of [page:Matrix4 Matrix4s] that represent the inverse of the [page:Matrix4 matrixWorld]
- of the individual bones.
+ 包含有一组[page:Matrix4 Matrix4],表示每个独立骨骼[page:Matrix4 matrixWorld]矩阵的逆矩阵。
</p>
<h3>[property:Float32Array boneMatrices]</h3>
<p>
- The array buffer holding the bone data when using a vertex texture.
+ 当使用顶点纹理时,数组缓冲区保存着骨骼数据。
</p>
<h3>[property:DataTexture boneTexture]</h3>
<p>
- The [page:DataTexture] holding the bone data when using a vertex texture.
+ 当使用顶点纹理时,[page:DataTexture]保存着骨骼数据。
</p>
- <h2>Methods</h2>
+ <h2>方法</h2>
<h3>[method:Skeleton clone]()</h3>
<p>
- Returns a clone of this Skeleton object.
+ 返回一个当前Skeleton对象的克隆。
</p>
<h3>[method:null calculateInverses]()</h3>
- <p>Generates the [page:.boneInverses boneInverses] array if not provided in the constructor.</p>
+ <p>如果没有在构造器中提供,生成[page:.boneInverses boneInverses]数组。
+ </p>
<h3>[method:null pose]()</h3>
- <p>Returns the skeleton to the base pose.</p>
+ <p>返回骨架的基础姿势。</p>
<h3>[method:null update]()</h3>
<p>
- Updates the [page:Float32Array boneMatrices] and [page:DataTexture boneTexture] after changing the bones.
- This is called automatically by the [page:WebGLRenderer] if the skeleton is used with a [page:SkinnedMesh].
+ 在改变骨骼后,更新[page:Float32Array boneMatrices] 和 [page:DataTexture boneTexture]的值。
+ 如果骨架被用于[page:SkinnedMesh],则它将会被[page:WebGLRenderer]自动调用。
</p>
<h3>[method:Bone getBoneByName]( [param:String name] )</h3>
<p>
- name -- String to match to the Bone's .name property. <br /><br />
-
- Searches through the skeleton's bone array and returns the first with a matching name.<br />
+
+ name -- 匹配Bone对象中.name属性的字符串。<br /><br />
+ 在骨架中的骨骼数组中遍览,并返回第一个能够和name匹配上的骨骼对象。<br />
</p>
- <h2>Source</h2>
+ <h2>源代码</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body> | true |
Other | mrdoob | three.js | a6c3193465f533048d1608fbce30d3bbaf9e5d74.json | Translate some page in the object,and little fix. | docs/api/zh/objects/SkinnedMesh.html | @@ -10,11 +10,11 @@
<body>
[page:Object3D] → [page:Mesh] →
- <h1>[name]</h1>
+ <h1>蒙皮网格([name])</h1>
<p class="desc">
- A mesh that has a [page:Skeleton] with [page:Bone bones] that can then be used to animate the vertices of the geometry.
- The material must support skinning and have skinning enabled - see [page:MeshStandardMaterial.skinning].
+ 具有[page:Skeleton](骨架)和[page:Bone bones](骨骼)的网格,可用于给几何体上的顶点添加动画。
+ 其材质必须支持蒙皮,并且已经启用了蒙皮 —— 请阅读[page:MeshStandardMaterial.skinning]。
</p>
<iframe id="scene" src="scenes/bones-browser.html"></iframe>
@@ -35,7 +35,7 @@ <h1>[name]</h1>
</script>
- <h2>Example</h2>
+ <h2>示例</h2>
<code>
var geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
@@ -68,94 +68,88 @@ <h2>Example</h2>
armSkeleton.bones[ 1 ].rotation.x = 0.2;
</code>
- <h2>Constructor</h2>
+ <h2>构造器</h2>
<h3>[name]( [param:Geometry geometry], [param:Material material] )</h3>
<p>
- [page:Geometry geometry] - an instance of [page:Geometry] or [page:BufferGeometry] (recommended).
- [page:Geometry.skinIndices skinIndices] and [page:Geometry.skinWeights skinWeights] should be set to true on the geometry.<br />
- [page:Material material] - (optional) an instance of [page:Material]. Default is a new [page:MeshBasicMaterial].
+ [page:Geometry geometry] —— 一个[page:Geometry]或者[page:BufferGeometry](推荐)的实例。
+ [page:Geometry.skinIndices skinIndices] 和 [page:Geometry.skinWeights skinWeights] 在几何体上应当被设置为true。<br />
+ [page:Material material] —— (可选)一个[page:Material]的实例,默认值是一个新的[page:MeshBasicMaterial]。
</p>
- <h2>Properties</h2>
- <p>See the base [page:Mesh] class for common properties.</p>
+ <h2>属性</h2>
+ <p>请参阅其基类[page:Mesh]来查看共有属性。</p>
<h3>[property:string bindMode]</h3>
<p>
- Either "attached" or "detached". "attached" uses the [page:SkinnedMesh.matrixWorld]
- property for the base transform matrix of the bones. "detached" uses the
- [page:SkinnedMesh.bindMatrix]. Default is "attached".
+ “attached”(附加)或者“detached”(分离)。“attached”使用[page:SkinnedMesh.matrixWorld]
+ 属性作为对骨骼的基本变换矩阵,“detached”则使用[page:SkinnedMesh.bindMatrix]。
+ 默认值是“attached”。
</p>
<h3>[property:Matrix4 bindMatrix]</h3>
<p>
- The base matrix that is used for the bound bone transforms.
+ 用于绑定的骨骼变换的基础矩阵。
</p>
<h3>[property:Matrix4 bindMatrixInverse]</h3>
<p>
- The base matrix that is used for resetting the bound bone transforms.
+ 用于重置绑定的骨骼变换的基础矩阵。
</p>
<h3>[property:Boolean isSkinnedMesh]</h3>
<p>
- Used to check whether this or derived classes are skinned meshes. Default is *true*.<br /><br />
-
- You should not change this, as it used internally for optimisation.
+ 用于检查这个类或者其派生类是否为蒙皮网格,默认值为*true*。<br /><br />
+ 你不应当对这个属性进行改变,因为它在使用,以用于优化。
</p>
<h3>[property:Skeleton skeleton]</h3>
<p>
- [page:Skeleton] created from the [page:Geometry.bones bones] of the [page:Geometry] passed in the
- constructor.
+ [page:Skeleton]是由从构造函数中传入的[page:Geometry]中的[page:Geometry.bones bones]来创建的。
</p>
- <h2>Methods</h2>
- <p>See the base [page:Mesh] class for common methods.</p>
+ <h2>方法</h2>
+ <p>请参阅其基类[page:Mesh]来查看共有方法。</p>
<h3>[method:null bind]( [param:Skeleton skeleton], [param:Matrix4 bindMatrix] )</h3>
<p>
- [page:Skeleton skeleton] - [page:Skeleton] created from a [page:Bone Bones] tree.<br/>
- [page:Matrix4 bindMatrix] - [page:Matrix4] that represents the base transform of the skeleton.<br /><br />
-
- Bind a skeleton to the skinned mesh. The bindMatrix gets saved to .bindMatrix property
- and the .bindMatrixInverse gets calculated. This is called automatically in the constructor, and the skeleton
- is created from the [page:Geometry.bones bones] of the [page:Geometry] passed in the
- constructor.
+ [page:Skeleton skeleton] —— 由一棵[page:Bone Bones]树创建的[page:Skeleton]。<br/>
+ [page:Matrix4 bindMatrix] —— 代表着骨架基本变换的[page:Matrix4](4x4矩阵)。<br /><br />
+ 将骨架绑定到一个蒙皮网格上。bindMatrix会被保存到.bindMatrix属性中,其逆矩阵.bindMatrixInverse也会被计算出来。
+ 它在构造函数中会被自动调用,其骨架是由传入到构造函数的[page:Geometry]中的[page:Geometry.bones bones]来创建的。
</p>
<h3>[method:SkinnedMesh clone]()</h3>
<p>
- Returns a clone of this SkinnedMesh object and any descendants.
+ 返回当前SkinnedMesh对象的一个克隆及其任何后代。
</p>
<h3>[method:null normalizeSkinWeights]()</h3>
<p>
- Normalizes the [page:Geometry.skinWeights] vectors. Does not affect [page:BufferGeometry].
+ 规范化[page:Geometry.skinWeights]矢量。不会对[page:BufferGeometry]产生影响。
</p>
<h3>[method:null pose]()</h3>
<p>
- This method sets the skinned mesh in the rest pose (resets the pose).
+ 这个方法设置了在“休息”状态下蒙皮网格的姿势(重置姿势)。
</p>
<h3>[method:null updateMatrixWorld]( [param:Boolean force] )</h3>
<p>
- Updates the [page:Matrix4 MatrixWorld].
+ 更新[page:Matrix4 MatrixWorld]矩阵。
</p>
<h3>[method:null initBones]()</h3>
<p>
- Creates an array of hierarchical [page:Bone bones] objects from the internal geometry.
+ 从内部几何体中创建一个分层[page:Bone bones]对象的数组。
</p>
- <h2>Source</h2>
-
+ <h2>源代码</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body>
</html> | true |
Other | mrdoob | three.js | a6c3193465f533048d1608fbce30d3bbaf9e5d74.json | Translate some page in the object,and little fix. | docs/api/zh/objects/Sprite.html | @@ -10,16 +10,14 @@
<body>
[page:Object3D] →
- <h1>[name]</h1>
+ <h1>精灵([name])</h1>
<p class="desc">
- A sprite is a plane that always faces towards the camera, generally with a
- partially transparent texture applied.<br /><br />
-
- Sprites do not cast shadows, setting <code>castShadow = true</code> will have no effect.
+ 精灵是一个总是面朝着摄像机的平面,通常含有使用一个半透明的纹理。<br /><br />
+ 精灵不会投射任何阴影,即使设置了<code>castShadow = true</code>也将不会有任何效果。
</p>
- <h2>Example</h2>
+ <h2>示例</h2>
<code>
var spriteMap = new THREE.TextureLoader().load( "sprite.png" );
@@ -29,61 +27,59 @@ <h2>Example</h2>
</code>
- <h2>Constructor</h2>
+ <h2>构造器</h2>
<h3>[name]( [param:Material material] )</h3>
<p>
- [page:Material material] - (optional) an instance of [page:SpriteMaterial]. Default is a white [page:SpriteMaterial].<br /><br />
+ [page:Material material] - (可选值)是[page:SpriteMaterial]的一个实例。 默认值是一个白色的[page:SpriteMaterial]。<br /><br />
- Creates a new [name].
+ 创建一个新的[name]。
</p>
- <h2>Properties</h2>
- <p>See the base [page:Object3D] class for common properties.</p>
+ <h2>属性</h2>
+ <p>请参阅其基类[page:Object3D]来查看共有属性。</p>
<h3>[property:Boolean isSprite]</h3>
<p>
- Used to check whether this or derived classes are sprites. Default is *true*.<br /><br />
-
- You should not change this, as it used internally for optimisation.
+ 用于检查这个类或者其派生类是否为精灵,默认值为*true*。<br /><br />
+ 你不应当对这个属性进行改变,因为它在使用,以用于优化。
</p>
<h3>[property:SpriteMaterial material]</h3>
<p>
- An instance of [page:SpriteMaterial], defining the object's appearance.
- Default is a white [page:SpriteMaterial].
+ [page:SpriteMaterial]的一个实例,定义了这个对象的外观。默认值是一个白色的[page:SpriteMaterial]。
</p>
<h3>[property:Vector2 center]</h3>
<p>
- The sprite's anchor point, and the point around which the sprite rotates. A value of (0.5, 0.5) corresponds to the midpoint of the sprite.
- A value of (0, 0) corresponds to the lower left corner of the sprite. The default is (0.5, 0.5).
+ 这个精灵的锚点,也就是精灵旋转时,围绕着旋转的点。当值为(0.5,0.5)时,对应着这个精灵的中心点;当值为(0,0)时,对应着这个精灵左下角的点。<br>
+ 其默认值是(0.5,0.5)。
</p>
- <h2>Methods</h2>
- <p>See the base [page:Object3D] class for common methods.</p>
+ <h2>方法</h2>
+ <p>请参阅其基类[page:Object3D]来查看共有方法。</p>
<h3>[method:Sprite clone]()</h3>
<p>
- Returns a clone of this Sprite object and any descendants.
+ 返回当前Sprite对象的一个克隆及其任何后代。
</p>
<h3>[method:Sprite copy]( [param:Sprite sprite] )</h3>
<p>
- Copies the properties of the passed sprite to this one.
+ 将前一个Sprite对象的属性复制给当前的这个对象。
</p>
<h3>[method:null raycast]( [param:Raycaster raycaster], [param:Array intersects] )</h3>
<p>
- Get intersections between a casted ray and this sprite.
- [page:Raycaster.intersectObject] will call this method.
+ 在投射的光线和精灵之前产生交互。
+ [page:Raycaster.intersectObject]将会调用这个方法。
</p>
- <h2>Source</h2>
+ <h2>源代码</h2>
[link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
</body> | true |
Other | mrdoob | three.js | b4c85224bd0113cbe24b87e9cd9e5cfb527f32c4.json | Fix morph multimaterial | examples/js/loaders/FBXLoader.js | @@ -1407,31 +1407,26 @@ THREE.FBXLoader = ( function () {
setupMorphMaterials: function () {
+ var self = this;
sceneGraph.traverse( function ( child ) {
if ( child.isMesh ) {
- if ( child.geometry.morphAttributes.position || child.geometry.morphAttributes.normal ) {
-
- var uuid = child.uuid;
- var matUuid = child.material.uuid;
+ if ( child.geometry.morphAttributes.position && child.geometry.morphAttributes.position.length ) {
- // if a geometry has morph targets, it cannot share the material with other geometries
- var sharedMat = false;
+ if ( Array.isArray( child.material ) ) {
- sceneGraph.traverse( function ( child ) {
+ child.material.forEach( function ( material, i ) {
- if ( child.isMesh ) {
+ self.setupMorphMaterial( child, material, i );
- if ( child.material.uuid === matUuid && child.uuid !== uuid ) sharedMat = true;
-
- }
+ } );
- } );
+ } else {
- if ( sharedMat === true ) child.material = child.material.clone();
+ self.setupMorphMaterial( child, child.material );
- child.material.morphTargets = true;
+ }
}
@@ -1441,6 +1436,44 @@ THREE.FBXLoader = ( function () {
},
+ setupMorphMaterial: function ( child, material, index ) {
+
+ var uuid = child.uuid;
+ var matUuid = material.uuid;
+
+ // if a geometry has morph targets, it cannot share the material with other geometries
+ var sharedMat = false;
+
+ sceneGraph.traverse( function ( node ) {
+
+ if ( node.isMesh ) {
+
+ if ( Array.isArray( node.material ) ) {
+
+ node.material.forEach( function ( mat ) {
+
+ if ( mat.uuid === matUuid && node.uuid !== uuid ) sharedMat = true;
+
+ } );
+
+ } else if ( node.material.uuid === matUuid && node.uuid !== uuid ) sharedMat = true;
+
+ }
+
+ } );
+
+ if ( sharedMat === true ) {
+
+ var clonedMat = material.clone();
+ clonedMat.morphTargets = true;
+
+ if ( index === undefined ) child.material = clonedMat;
+ else child.material[ index ] = clonedMat;
+
+ } else material.morphTargets = true;
+
+ }
+
};
// parse Geometry data from FBXTree and return map of BufferGeometries
@@ -2591,7 +2624,7 @@ THREE.FBXLoader = ( function () {
var initialRotation = new THREE.Quaternion();
var initialScale = new THREE.Vector3();
- rawTracks.transform.decompose( initialPosition, initialRotation, initialScale );
+ if ( rawTracks.transform ) rawTracks.transform.decompose( initialPosition, initialRotation, initialScale );
initialPosition = initialPosition.toArray();
initialRotation = new THREE.Euler().setFromQuaternion( initialRotation, rawTracks.eulerOrder ).toArray(); | false |
Other | mrdoob | three.js | 83c3c06947120e771e010c886bcaca88c0ea6e1c.json | Add 3D Texture example | examples/webgl_materials_texture_3d.html | @@ -0,0 +1,213 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - 3D texture</title>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ background:#000;
+ padding:0;
+ margin:0;
+ overflow:hidden;
+ }
+
+ #info {
+ position: absolute;
+ top: 0px;
+ width: 100%;
+ color: #ffffff;
+ padding: 5px;
+ font-family:Monospace;
+ font-size:13px;
+ text-align:center;
+ }
+
+ a {
+ color: #ffffff;
+ }
+ </style>
+ </head>
+ <script id="vs" type="x-shader/x-vertex">
+ #version 300 es
+
+ uniform float depth;
+ uniform vec2 size;
+ out vec3 vUv;
+
+ void main() {
+
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
+
+ // Convert position.xy to 1.0-0.0
+
+ vUv.xy = position.xy / size + 0.5;
+ vUv.y = 1.0 - vUv.y; // original data is upside down
+
+ vUv.z = depth;
+
+ }
+ </script>
+
+ <script id="fs" type="x-shader/x-fragment">
+ #version 300 es
+
+ precision highp float;
+ precision highp int;
+ precision highp sampler3D;
+
+ uniform sampler3D diffuse;
+ in vec3 vUv;
+ out vec4 out_FragColor;
+
+ void main() {
+
+ vec4 color = texture( diffuse, vUv );
+ color.r *= 1.5; // lighten a bit
+ color.gba = vec3( color.x );
+
+ out_FragColor = vec4( color.rgb, 1.0 );
+
+ }
+ </script>
+ <body>
+ <div id="info">
+ <a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - 3D Texture<br />
+ Scanned head data by
+ <a href="https://www.codeproject.com/Articles/352270/Getting-started-with-Volume-Rendering" target="_blank" rel="noopener">Divine Augustine</a><br />
+ licensed under
+ <a href="https://www.codeproject.com/info/cpol10.aspx" target="_blank" rel="noopener">CPOL</a>
+ </div>
+
+ <script src="../build/three.js"></script>
+ <!--<script src="js/controls/OrbitControls.js"></script>-->
+
+ <script src="js/libs/jszip.min.js"></script>
+
+ <script src="js/Detector.js"></script>
+ <script src="js/libs/stats.min.js"></script>
+
+ <script>
+
+ if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+ var camera, scene, mesh, renderer, stats;
+
+ var planeWidth = 50;
+ var planeHeight = 50;
+
+ var depthStep = 1 / ( 109 * 3 );
+
+ init();
+ animate();
+
+ function init() {
+
+ var container = document.createElement( 'div' );
+ document.body.appendChild( container );
+
+ camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.1, 2000 );
+ camera.position.z = 70;
+
+ scene = new THREE.Scene();
+
+ var geometry = new THREE.PlaneBufferGeometry( planeWidth, planeHeight );
+
+ // width 256, height 256, depth 109, 8-bit, zip archived raw data
+
+ new THREE.FileLoader()
+ .setResponseType( 'arraybuffer' )
+ .load( 'textures/3d/head256x256x109.zip', function ( data ) {
+
+ var zip = new JSZip( data );
+ var array = zip.files[ 'head256x256x109' ].asUint8Array();
+
+ var texture = new THREE.Texture3D( array, 256, 256, 109 );
+
+ texture.format = THREE.RedFormat;
+ texture.type = THREE.UnsignedByteType;
+
+ texture.needsUpdate = true;
+
+ var material = new THREE.ShaderMaterial( {
+ uniforms: {
+ diffuse: { value: texture },
+ depth: { value: 0 },// 50 / 109 },
+ size: { value: new THREE.Vector2( planeWidth, planeHeight ) }
+ },
+ vertexShader: document.getElementById( 'vs' ).textContent.trim(),
+ fragmentShader: document.getElementById( 'fs' ).textContent.trim()
+ } );
+
+ mesh = new THREE.Mesh( geometry, material );
+
+ scene.add( mesh );
+
+ } );
+
+ // var controls = new THREE.OrbitControls( camera );
+
+ // 3D Texture is available on WebGL 2.0
+
+ var canvas = document.createElement( 'canvas' );
+ var context = canvas.getContext( 'webgl2' );
+
+ renderer = new THREE.WebGLRenderer( { antialias: true, canvas: canvas, context: context } );
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ container.appendChild( renderer.domElement );
+
+ stats = new Stats();
+ container.appendChild( stats.dom );
+
+ window.addEventListener( 'resize', onWindowResize, false );
+ onWindowResize();
+
+ }
+
+ function onWindowResize() {
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ if ( mesh ) {
+
+ var value = mesh.material.uniforms.depth.value;
+
+ value += depthStep;
+
+ if ( value > 1.0 || value < 0.0 ) {
+
+ if ( value > 1.0 ) value = 2.0 - value;
+ if ( value < 0.0 ) vlaue = - value;
+
+ depthStep = - depthStep;
+
+ }
+
+ mesh.material.uniforms.depth.value = value;;
+
+ }
+
+ render();
+ stats.update();
+
+ }
+
+ function render() {
+
+ renderer.render( scene, camera );
+
+ }
+
+ </script>
+ </body>
+</html> | false |
Other | mrdoob | three.js | f72d822eb2945dd07c719aa3133b0a0bff2b5b2f.json | Correct Vector3 to Vector2 | docs/api/extras/curves/SplineCurve.html | @@ -1,72 +1,72 @@
-<!DOCTYPE html>
-<html lang="en">
- <head>
+<!DOCTYPE html>
+<html lang="en">
+ <head>
<meta charset="utf-8" />
- <base href="../../../" />
- <script src="list.js"></script>
- <script src="page.js"></script>
- <link type="text/css" rel="stylesheet" href="page.css" />
- </head>
- <body>
- [page:Curve] →
-
- <h1>[name]</h1>
-
- <div class="desc">
- Create a smooth 2d spline curve from a series of points. Internally this uses
- [page:Interpolations.CatmullRom] to create the curve.
- </div>
-
- <h2>Example</h2>
-
-<code>
-// Create a sine-like wave
-var curve = new THREE.SplineCurve( [
- new THREE.Vector2( -10, 0 ),
- new THREE.Vector2( -5, 5 ),
- new THREE.Vector2( 0, 0 ),
- new THREE.Vector2( 5, -5 ),
- new THREE.Vector2( 10, 0 )
-] );
-
-var points = curve.getPoints( 50 );
-var geometry = new THREE.BufferGeometry().setFromPoints( points );
-
-var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
-
-// Create the final object to add to the scene
-var splineObject = new THREE.Line( geometry, material );
-</code>
-
- <h2>Constructor</h2>
-
-
- <h3>[name]( [page:Array points] )</h3>
- <div>points – An array of [page:Vector2] points that define the curve.</div>
-
-
- <h2>Properties</h2>
- <div>See the base [page:Curve] class for common properties.</div>
-
- <h3>[property:Boolean isSplineCurve]</h3>
- <div>
- Used to check whether this or derived classes are SplineCurves. Default is *true*.<br /><br />
-
- You should not change this, as it used internally for optimisation.
- </div>
-
- <h3>[property:Array points]</h3>
- <div>The array of [page:Vector3] points that define the curve.</div>
-
-
-
- <h2>Methods</h2>
- <div>See the base [page:Curve] class for common methods.</div>
-
-
-
- <h2>Source</h2>
-
- [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
- </body>
-</html>
+ <base href="../../../" />
+ <script src="list.js"></script>
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ [page:Curve] →
+
+ <h1>[name]</h1>
+
+ <div class="desc">
+ Create a smooth 2d spline curve from a series of points. Internally this uses
+ [page:Interpolations.CatmullRom] to create the curve.
+ </div>
+
+ <h2>Example</h2>
+
+<code>
+// Create a sine-like wave
+var curve = new THREE.SplineCurve( [
+ new THREE.Vector2( -10, 0 ),
+ new THREE.Vector2( -5, 5 ),
+ new THREE.Vector2( 0, 0 ),
+ new THREE.Vector2( 5, -5 ),
+ new THREE.Vector2( 10, 0 )
+] );
+
+var points = curve.getPoints( 50 );
+var geometry = new THREE.BufferGeometry().setFromPoints( points );
+
+var material = new THREE.LineBasicMaterial( { color : 0xff0000 } );
+
+// Create the final object to add to the scene
+var splineObject = new THREE.Line( geometry, material );
+</code>
+
+ <h2>Constructor</h2>
+
+
+ <h3>[name]( [page:Array points] )</h3>
+ <div>points – An array of [page:Vector2] points that define the curve.</div>
+
+
+ <h2>Properties</h2>
+ <div>See the base [page:Curve] class for common properties.</div>
+
+ <h3>[property:Boolean isSplineCurve]</h3>
+ <div>
+ Used to check whether this or derived classes are SplineCurves. Default is *true*.<br /><br />
+
+ You should not change this, as it used internally for optimisation.
+ </div>
+
+ <h3>[property:Array points]</h3>
+ <div>The array of [page:Vector2] points that define the curve.</div>
+
+
+
+ <h2>Methods</h2>
+ <div>See the base [page:Curve] class for common methods.</div>
+
+
+
+ <h2>Source</h2>
+
+ [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
+ </body>
+</html>
| false |
Other | mrdoob | three.js | b5032dd15b1860640180f60cf9c2bf5438ac08f6.json | Update definitions of torus radii | docs/api/geometries/TorusBufferGeometry.html | @@ -44,7 +44,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer radialSegments], [page:Integer tubularSegments], [page:Float arc])</h3>
<div>
- radius — Default is 1. <br />
+ radius - Radius of the torus, from the center of the torus to the center of the tube. Default is 1. <br />
tube — Radius of the tube. Default is 0.4. <br />
radialSegments — Default is 8 <br />
tubularSegments — Default is 6. <br /> | true |
Other | mrdoob | three.js | b5032dd15b1860640180f60cf9c2bf5438ac08f6.json | Update definitions of torus radii | docs/api/geometries/TorusGeometry.html | @@ -44,7 +44,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer radialSegments], [page:Integer tubularSegments], [page:Float arc])</h3>
<div>
- radius — Default is 1. <br />
+ radius - Radius of the torus, from the center of the torus to the center of the tube. Default is 1. <br />
tube — Radius of the tube. Default is 0.4. <br />
radialSegments — Default is 8 <br />
tubularSegments — Default is 6. <br /> | true |
Other | mrdoob | three.js | b5032dd15b1860640180f60cf9c2bf5438ac08f6.json | Update definitions of torus radii | docs/api/geometries/TorusKnotBufferGeometry.html | @@ -45,7 +45,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer tubularSegments], [page:Integer radialSegments], [page:Integer p], [page:Integer q])</h3>
<div>
<ul>
- <li>radius — Default is 1.</li>
+ <li>radius - Radius of the torus. Default is 1.</li>
<li>tube — Radius of the tube. Default is 0.4.</li>
<li>tubularSegments — Default is 64.</li>
<li>radialSegments — Default is 8.</li> | true |
Other | mrdoob | three.js | b5032dd15b1860640180f60cf9c2bf5438ac08f6.json | Update definitions of torus radii | docs/api/geometries/TorusKnotGeometry.html | @@ -45,7 +45,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer tubularSegments], [page:Integer radialSegments], [page:Integer p], [page:Integer q])</h3>
<div>
<ul>
- <li>radius — Default is 1.</li>
+ <li>radius - Radius of the torus. Default is 1.</li>
<li>tube — Radius of the tube. Default is 0.4.</li>
<li>tubularSegments — Default is 64.</li>
<li>radialSegments — Default is 8.</li> | true |
Other | mrdoob | three.js | 1d89bd105dc7956a9427daf09c8cb7a12d1aab44.json | Change incorrect references in Torus docs
The tube parameter is actually a radius, not a diameter | docs/api/geometries/TorusBufferGeometry.html | @@ -45,7 +45,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer radialSegments], [page:Integer tubularSegments], [page:Float arc])</h3>
<div>
radius — Default is 1. <br />
- tube — Diameter of the tube. Default is 0.4. <br />
+ tube — Radius of the tube. Default is 0.4. <br />
radialSegments — Default is 8 <br />
tubularSegments — Default is 6. <br />
arc — Central angle. Default is Math.PI * 2. | true |
Other | mrdoob | three.js | 1d89bd105dc7956a9427daf09c8cb7a12d1aab44.json | Change incorrect references in Torus docs
The tube parameter is actually a radius, not a diameter | docs/api/geometries/TorusGeometry.html | @@ -45,7 +45,7 @@ <h2>Constructor</h2>
<h3>[name]([page:Float radius], [page:Float tube], [page:Integer radialSegments], [page:Integer tubularSegments], [page:Float arc])</h3>
<div>
radius — Default is 1. <br />
- tube — Diameter of the tube. Default is 0.4. <br />
+ tube — Radius of the tube. Default is 0.4. <br />
radialSegments — Default is 8 <br />
tubularSegments — Default is 6. <br />
arc — Central angle. Default is Math.PI * 2. | true |
Other | mrdoob | three.js | 1d89bd105dc7956a9427daf09c8cb7a12d1aab44.json | Change incorrect references in Torus docs
The tube parameter is actually a radius, not a diameter | docs/api/geometries/TorusKnotBufferGeometry.html | @@ -46,7 +46,7 @@ <h3>[name]([page:Float radius], [page:Float tube], [page:Integer tubularSegments
<div>
<ul>
<li>radius — Default is 1.</li>
- <li>tube — Diameter of the tube. Default is 0.4.</li>
+ <li>tube — Radius of the tube. Default is 0.4.</li>
<li>tubularSegments — Default is 64.</li>
<li>radialSegments — Default is 8.</li>
<li>p — This value determines, how many times the geometry winds around its axis of rotational symmetry. Default is 2.</li> | true |
Other | mrdoob | three.js | 1d89bd105dc7956a9427daf09c8cb7a12d1aab44.json | Change incorrect references in Torus docs
The tube parameter is actually a radius, not a diameter | docs/api/geometries/TorusKnotGeometry.html | @@ -46,7 +46,7 @@ <h3>[name]([page:Float radius], [page:Float tube], [page:Integer tubularSegments
<div>
<ul>
<li>radius — Default is 1.</li>
- <li>tube — Diameter of the tube. Default is 0.4.</li>
+ <li>tube — Radius of the tube. Default is 0.4.</li>
<li>tubularSegments — Default is 64.</li>
<li>radialSegments — Default is 8.</li>
<li>p — This value determines, how many times the geometry winds around its axis of rotational symmetry. Default is 2.</li> | true |
Other | mrdoob | three.js | 764fb013869a7ba8db8f97dfee2b9ec6a1df54a2.json | Add initial doc for ply exporter | docs/examples/exporters/PLYExporter.html | @@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8" />
+ <base href="../../" />
+ <script src="list.js"></script>
+ <script src="page.js"></script>
+ <link type="text/css" rel="stylesheet" href="page.css" />
+ </head>
+ <body>
+ <h1>[name]</h1>
+
+ <p class="desc">
+ An exporter for *PLY*.
+ <br /><br />
+ <a href="https://www.khronos.org/gltf">glTF</a> (GL Transmission Format) is an
+ <a href="https://github.com/KhronosGroup/glTF/tree/master/specification/2.0">open format specification</a>
+ for efficient delivery and loading of 3D content. Assets may be provided either in JSON (.gltf)
+ or binary (.glb) format. External files store textures (.jpg, .png) and additional binary
+ data (.bin). A glTF asset may deliver one or more scenes, including meshes, materials,
+ textures, skins, skeletons, morph targets, animations, lights, and/or cameras.
+ </p>
+
+ <h2>Example</h2>
+
+ <code>
+ // Instantiate a exporter
+ var exporter = new THREE.PLYExporter( defaultOptions );
+
+ // Parse the input and generate the ply output
+ var data = exporter.parse( scene, options );
+ downloadFile(data);
+ </code>
+
+ [example:misc_exporter_gltf]
+
+ <h2>Constructor</h2>
+
+ <h3>[name]()</h3>
+ <p>
+ </p>
+ <p>
+ Creates a new [name].
+ </p>
+
+ <h2>Methods</h2>
+
+ <h3>[method:null parse]( [param:Object3D input], [param:Object options] )</h3>
+ <p>
+ [page:Object input] — Object3D<br />
+ [page:Options options] — Export options<br />
+ <ul>
+ <li>excludeAttributes - array. Which properties to explicitly exclude from the exported PLY file. Valid values are 'color', 'normal', 'uv', and 'index'. If indices are excluded, then a point cloud is exported. Default is an empty array.</li>
+ <li>binary - bool. Export in binary format, returning an ArrayBuffer. Default is false.</li>
+ </ul>
+ </p>
+ <p>
+ Generates ply file data as string or ArrayBuffer (ascii or binary) output from the input object
+ </p>
+
+ <h2>Source</h2>
+
+ [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/PLYExporter.js examples/js/exporters/PLYExporter.js]
+ </body>
+</html> | false |
Other | mrdoob | three.js | 94743d102bc4f63604b75d5f7f2d87aa834dfa36.json | use options hash | examples/js/loaders/EquiangularToCubeGenerator.js | @@ -2,10 +2,10 @@
* @author Richard M. / https://github.com/richardmonette
*/
-THREE.EquiangularToCubeGenerator = function ( sourceTexture, resolution, type, format ) {
+THREE.EquiangularToCubeGenerator = function ( sourceTexture, options ) {
this.sourceTexture = sourceTexture;
- this.resolution = resolution;
+ this.resolution = options.resolution || 512;
this.views = [
{ t: [ 1, 0, 0 ], u: [ 0, - 1, 0 ] },
@@ -23,10 +23,10 @@ THREE.EquiangularToCubeGenerator = function ( sourceTexture, resolution, type, f
this.scene.add( this.boxMesh );
var params = {
- format: format ? format : this.sourceTexture.format,
+ format: options.format || this.sourceTexture.format,
magFilter: this.sourceTexture.magFilter,
minFilter: this.sourceTexture.minFilter,
- type: type ? type : this.sourceTexture.type,
+ type: options.type || this.sourceTexture.type,
generateMipmaps: this.sourceTexture.generateMipmaps,
anisotropy: this.sourceTexture.anisotropy,
encoding: this.sourceTexture.encoding | true |
Other | mrdoob | three.js | 94743d102bc4f63604b75d5f7f2d87aa834dfa36.json | use options hash | examples/webgl_materials_envmaps_exr.html | @@ -106,7 +106,7 @@
texture.magFilter = THREE.NearestFilter;
texture.encoding = THREE.LinearEncoding;
- var cubemapGenerator = new THREE.EquiangularToCubeGenerator( texture, 512, THREE.HalfFloatType );
+ var cubemapGenerator = new THREE.EquiangularToCubeGenerator( texture, { resolution: 512, type: THREE.HalfFloatType } );
var cubeMapTexture = cubemapGenerator.update( renderer );
var pmremGenerator = new THREE.PMREMGenerator( cubeMapTexture ); | true |
Other | mrdoob | three.js | ad597c55d61bb0d46d8ec1286672fd828527d311.json | add params for cubemap params (to support mobile) | examples/js/loaders/EquiangularToCubeGenerator.js | @@ -2,7 +2,7 @@
* @author Richard M. / https://github.com/richardmonette
*/
-THREE.EquiangularToCubeGenerator = function ( sourceTexture, resolution ) {
+THREE.EquiangularToCubeGenerator = function ( sourceTexture, resolution, type, format ) {
this.sourceTexture = sourceTexture;
this.resolution = resolution;
@@ -23,10 +23,10 @@ THREE.EquiangularToCubeGenerator = function ( sourceTexture, resolution ) {
this.scene.add( this.boxMesh );
var params = {
- format: THREE.RGBAFormat,
+ format: format ? format : this.sourceTexture.format,
magFilter: this.sourceTexture.magFilter,
minFilter: this.sourceTexture.minFilter,
- type: this.sourceTexture.type,
+ type: type ? type : this.sourceTexture.type,
generateMipmaps: this.sourceTexture.generateMipmaps,
anisotropy: this.sourceTexture.anisotropy,
encoding: this.sourceTexture.encoding | true |
Other | mrdoob | three.js | ad597c55d61bb0d46d8ec1286672fd828527d311.json | add params for cubemap params (to support mobile) | examples/webgl_materials_envmaps_exr.html | @@ -106,7 +106,7 @@
texture.magFilter = THREE.NearestFilter;
texture.encoding = THREE.LinearEncoding;
- var cubemapGenerator = new THREE.EquiangularToCubeGenerator( texture, 512 );
+ var cubemapGenerator = new THREE.EquiangularToCubeGenerator( texture, 512, THREE.HalfFloatType );
var cubeMapTexture = cubemapGenerator.update( renderer );
var pmremGenerator = new THREE.PMREMGenerator( cubeMapTexture ); | true |
Other | mrdoob | three.js | 908fa7354d9f5b9aa0fdd83a391360e058b51552.json | Add some utility functions to BufferGeometryUtils | examples/js/BufferGeometryUtils.js | @@ -391,6 +391,90 @@ THREE.BufferGeometryUtils = {
return new THREE.BufferAttribute( array, itemSize, normalized );
+ },
+
+ /**
+ * @param {Array<THREE.BufferAttribute>} attributes
+ * @return {Array<THREE.InterleavedBufferAttribute>}
+ */
+ interleaveAttributes: function ( attributes ) {
+
+ // Interleaves the provided attributes into an InterleavedBuffer and returns
+ // a set of InterleavedBufferAttributes for each attribute
+ var TypedArray;
+ var arrayLength = 0;
+ var stride = 0;
+
+ // calculate the the length and type of the interleavedBuffer
+ for ( var i = 0, l = attributes.length; i < l; ++ i ) {
+
+ var attribute = attributes[ i ];
+
+ if ( TypedArray === undefined ) TypedArray = attribute.array.constructor;
+ if ( TypedArray !== attribute.array.constructor ) {
+
+ console.warn( 'AttributeBuffers of different types cannot be interleaved' );
+ return null;
+
+ }
+
+ arrayLength += attribute.array.length;
+ stride += attribute.itemSize;
+
+ }
+
+ // Create the set of buffer attributes
+ var interleavedBuffer = new THREE.InterleavedBuffer( new TypedArray( arrayLength ), stride );
+ var offset = 0;
+ var res = [];
+ var getters = [ 'getX', 'getY', 'getZ', 'getW' ];
+ var setters = [ 'setX', 'setY', 'setZ', 'setW' ];
+
+ for ( var j = 0, l = attributes.length; j < l; j ++ ) {
+
+ var attribute = attributes[ j ];
+ var itemSize = attribute.itemSize;
+ var count = attribute.count;
+ var iba = new THREE.InterleavedBufferAttribute( interleavedBuffer, itemSize, offset, attribute.normalized );
+ res.push( iba );
+
+ offset += itemSize;
+
+ // Move the data for each attribute into the new interleavedBuffer
+ // at the appropriate offset
+ for ( var c = 0; c < count; c ++ ) {
+
+ for ( var k = 0; k < itemSize; k ++ ) {
+
+ iba[ setters[ k ] ]( c, attribute[ getters[ k ] ]( c ) );
+
+ }
+
+ }
+
+ }
+
+ return res;
+
+ },
+
+ /**
+ * @param {Array<THREE.BufferGeometry>} geometry
+ * @return {number}
+ */
+ getMemoryUse: function ( geometry ) {
+
+ // Return the estimated memory used by this geometry
+ var mem = 0;
+ for ( var name in geometry.attributes ) {
+
+ mem += geometry.getAttribute( name ).array.byteLength;
+
+ }
+
+ mem += geometry.getIndex() ? geometry.getIndex().array.byteLength : 0;
+ return mem;
+
}
}; | false |
Other | mrdoob | three.js | 836e363c07cf59b759b907d4fbf4b4529bc2dcaf.json | fix bypassnode without .value | examples/js/nodes/core/BypassNode.js | @@ -17,27 +17,39 @@ THREE.BypassNode.prototype.nodeType = "Bypass";
THREE.BypassNode.prototype.getType = function ( builder ) {
- return this.value ? this.value.getType( builder ) : 'void';
+ if ( this.value ) {
+
+ return this.value.getType( builder );
+
+ } else if (builder.isShader( 'fragment' )) {
+
+ return 'fv1';
+
+ }
+
+ return 'void';
};
THREE.BypassNode.prototype.generate = function ( builder, output ) {
var code = this.code.build( builder, output ) + ';';
- if ( builder.isShader( 'fragment' ) ) {
+ if ( builder.isShader( 'vertex' ) ) {
- builder.material.addFragmentNode( code );
+ builder.material.addVertexNode( code );
+
+ if (this.value) {
+
+ return this.value.build( builder, output );
+
+ }
} else {
- builder.material.addVertexNode( code );
-
- }
-
- if (this.value) {
+ builder.material.addFragmentNode( code );
- return this.value.build( builder, output );
+ return this.value ? this.value.build( builder, output ) : builder.format( '0.0', 'fv1', output );
}
| false |
Other | mrdoob | three.js | 9bea0556fe15ecc68651e51bad34dd916b20022b.json | Address PR feedback. | examples/js/controls/OrbitControls.js | @@ -75,7 +75,7 @@ THREE.OrbitControls = function ( object, domElement ) {
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
// Mouse buttons
- this.mouseButtons = { ORBIT: THREE.MOUSE.LEFT, ZOOM: THREE.MOUSE.MIDDLE, PAN: THREE.MOUSE.RIGHT };
+ this.mouseButtons = { LEFT: THREE.MOUSE.LEFT, MIDDLE: THREE.MOUSE.MIDDLE, RIGHT: THREE.MOUSE.RIGHT };
// for reset
this.target0 = this.target.clone();
@@ -86,18 +86,6 @@ THREE.OrbitControls = function ( object, domElement ) {
// public methods
//
- this.getStateForMouseDown = function ( event ) {
-
- if ( event.button === scope.mouseButtons.ORBIT && ! event.ctrlKey ) return STATE.ROTATE;
-
- if ( event.button === scope.mouseButtons.ZOOM ) return STATE.DOLLY;
-
- if ( event.button === scope.mouseButtons.PAN || ( event.button === scope.mouseButtons.ORBIT && event.ctrlKey ) ) return STATE.PAN;
-
- return STATE.NONE;
-
- };
-
this.getPolarAngle = function () {
return spherical.phi;
@@ -687,46 +675,60 @@ THREE.OrbitControls = function ( object, domElement ) {
event.preventDefault();
- var newState = scope.getStateForMouseDown( event );
+ switch ( event.button ) {
- switch ( newState ) {
+ case scope.mouseButtons.LEFT:
- case STATE.ROTATE:
+ if ( event.ctrlKey || event.metaKey ) {
- if ( scope.enableRotate === false ) return;
+ if ( scope.enablePan === false ) return;
+
+ handleMouseDownPan( event );
+
+ state = STATE.PAN;
+
+ } else {
+
+ if ( scope.enableRotate === false ) return;
- handleMouseDownRotate( event );
+ handleMouseDownRotate( event );
+
+ state = STATE.ROTATE;
+
+ }
break;
- case STATE.DOLLY:
+ case scope.mouseButtons.MIDDLE:
if ( scope.enableZoom === false ) return;
handleMouseDownDolly( event );
+ state = STATE.DOLLY;
+
break;
- case STATE.PAN:
+ case scope.mouseButtons.RIGHT:
if ( scope.enablePan === false ) return;
handleMouseDownPan( event );
- break;
-
- default: // STATE.NONE
+ state = STATE.PAN;
- return;
+ break;
}
- state = newState;
+ if ( state !== STATE.NONE ) {
- document.addEventListener( 'mousemove', onMouseMove, false );
- document.addEventListener( 'mouseup', onMouseUp, false );
+ document.addEventListener( 'mousemove', onMouseMove, false );
+ document.addEventListener( 'mouseup', onMouseUp, false );
- scope.dispatchEvent( startEvent );
+ scope.dispatchEvent( startEvent );
+
+ }
}
| false |
Other | mrdoob | three.js | 88c17cd1cb75e92dbc052b13c93d054410062d03.json | Add Lorenz attractor | examples/files.js | @@ -322,6 +322,7 @@ var files = {
"webvr_cubes",
"webvr_daydream",
"webvr_gearvr",
+ "webvr_lorenz_attractor",
"webvr_oculus-go",
"webvr_panorama",
"webvr_rollercoaster", | false |
Other | mrdoob | three.js | a904d8808c6fa4aa4e6568d419c1ae6ea2c2e22a.json | Fix example in SknnedMesh.html
Fixes #14314 | docs/api/objects/SkinnedMesh.html | @@ -38,7 +38,7 @@ <h1>[name]</h1>
<h2>Example</h2>
<code>
- var geometry = new THREE.CylinderBufferGeometry( 5, 5, 5, 5, 15, 5, 30 );
+ var geometry = new THREE.CylinderGeometry( 5, 5, 5, 5, 15, 5, 30 );
//Create the skin indices and skin weights
for ( var i = 0; i < geometry.vertices.length; i ++ ) { | false |
Other | mrdoob | three.js | c9a4cd8e5c568b7a95439908f782dcc7ee7fd66b.json | Reduce size and reposition | examples/webvr_lorenz_attractor.html | @@ -27,14 +27,14 @@
var camera, scene, renderer, x, y, z, c, geometry;
- var scale = 30;
+ var scale = .015; // for reducing overall displayed size
var multiplier = 5; // integer, increase for faster visualization
var steps = 100000;
var current = 1;
var shown = 10000;
- var beta = 8/3;
+ var beta = 8 / 3;
var rho = 28;
var sigma = 10;
@@ -58,7 +58,7 @@
y += dy;
z += dz;
- geometry.attributes.position.set( [ x, y, z ], 0 );
+ geometry.attributes.position.set( [ scale * x, scale * y, scale * z ], 0 );
c.setHSL( current / steps, 1, .5 );
geometry.attributes.color.set( [ c.r, c.g, c.b ], 0 );
@@ -80,16 +80,16 @@
function init() {
scene = new THREE.Scene();
- scene.position.set( 0, 0, - 1.5 * scale );
+ scene.position.set( 0, 1.5, - 1 );
- camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 1000 );
- camera.lookAt( 0, 0, - 1.5 * scale );
+ camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 0.1, 2 );
+ camera.lookAt( 0, 1.5, - 1 );
//
- x = scale / 2 * Math.random();
- y = scale / 2 * Math.random();
- z = scale / 2 * Math.random();
+ x = 15 * Math.random();
+ y = 15 * Math.random();
+ z = 15 * Math.random();
c = new THREE.Color();
@@ -98,7 +98,7 @@
var positions = new Float32Array( 3 * shown );
for ( var i = 0; i < positions.length; i += 3 ) {
- positions.set( [ x, y, z ], i );
+ positions.set( [ scale * x, scale * y, scale * z ], i );
}
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) ); | false |
Other | mrdoob | three.js | 006a90682c49065e81aa2138029680d5530ba0e0.json | Fix Error message in GLTFLoader | examples/js/loaders/GLTFLoader.js | @@ -1421,7 +1421,7 @@ THREE.GLTFLoader = ( function () {
if ( bufferDef.type && bufferDef.type !== 'arraybuffer' ) {
- throw new Error( 'THREE.GLTFLoader: %s buffer type is not supported.', bufferDef.type );
+ throw new Error( 'THREE.GLTFLoader: ' + bufferDef.type + ' buffer type is not supported.' );
}
| false |
Other | mrdoob | three.js | c1d8e09ebfedbf69fdb6f2e70725e14435dc2143.json | Add ';' and better indent | docs/api/lights/shadows/DirectionalLightShadow.html | @@ -37,8 +37,8 @@ <h2>Example</h2>
//Set up shadow properties for the light
light.shadow.mapSize.width = 512; // default
light.shadow.mapSize.height = 512; // default
-light.shadow.camera.near = 0.5; // default
-light.shadow.camera.far = 500 // default
+light.shadow.camera.near = 0.5; // default
+light.shadow.camera.far = 500; // default
//Create a sphere that cast shadows (but does not receive them)
var sphereGeometry = new THREE.SphereBufferGeometry( 5, 32, 32 ); | false |
Other | mrdoob | three.js | 47e792705d29e547660d4a5ef9fd1bff6a41e443.json | Fix GLTFLoader uncaught exception | examples/js/loaders/GLTFLoader.js | @@ -1025,11 +1025,9 @@ THREE.GLTFLoader = ( function () {
if ( value ) {
- fns.push( value );
-
if ( value instanceof Promise ) {
- value.then( function ( key, value ) {
+ value = value.then( function ( key, value ) {
results[ key ] = value;
@@ -1041,6 +1039,8 @@ THREE.GLTFLoader = ( function () {
}
+ fns.push( value );
+
}
}
@@ -1057,11 +1057,9 @@ THREE.GLTFLoader = ( function () {
if ( value ) {
- fns.push( value );
-
if ( value instanceof Promise ) {
- value.then( function ( key, value ) {
+ value = value.then( function ( key, value ) {
results[ key ] = value;
@@ -1073,6 +1071,8 @@ THREE.GLTFLoader = ( function () {
}
+ fns.push( value );
+
}
} | false |
Other | mrdoob | three.js | cdbd039552d9f26a3db91d6c9582e18159f31558.json | add name to object just once | examples/js/loaders/ColladaLoader.js | @@ -2751,7 +2751,7 @@ THREE.ColladaLoader.prototype = {
function parseNode( xml ) {
var data = {
- name: xml.getAttribute( 'name' ),
+ name: xml.getAttribute( 'name' ) || '',
type: xml.getAttribute( 'type' ),
id: xml.getAttribute( 'id' ),
sid: xml.getAttribute( 'sid' ),
@@ -3111,7 +3111,6 @@ THREE.ColladaLoader.prototype = {
for ( var i = 0; i < objects.length; i ++ ) {
- objects[ i ].name = ( type === 'JOINT' ) ? data.sid : data.name;
object.add( objects[ i ] );
} | false |
Other | mrdoob | three.js | cbafcbec083fcc06a46fdfd6619a9270efd37ccb.json | switch push style | examples/js/loaders/FBXLoader.js | @@ -50,8 +50,9 @@
try {
+ console.time( 'parse: ' );
var scene = self.parse( buffer, resourceDirectory );
-
+ console.timeEnd( 'parse: ' );
onLoad( scene );
} catch ( error ) {
@@ -898,59 +899,53 @@
for ( var i = 2; i < faceLength; i ++ ) {
- vertexB.push(
- vertexPositions[ vertexPositionIndexes[ 0 ] ],
- vertexPositions[ vertexPositionIndexes[ 1 ] ],
- vertexPositions[ vertexPositionIndexes[ 2 ] ],
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ 0 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ 1 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ 2 ] ] );
- vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 ] ],
- vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 + 1 ] ],
- vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 + 2 ] ],
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 + 1 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ ( i - 1 ) * 3 + 2 ] ] );
- vertexPositions[ vertexPositionIndexes[ i * 3 ] ],
- vertexPositions[ vertexPositionIndexes[ i * 3 + 1 ] ],
- vertexPositions[ vertexPositionIndexes[ i * 3 + 2 ] ]
- );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ i * 3 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ i * 3 + 1 ] ] );
+ vertexB.push( vertexPositions[ vertexPositionIndexes[ i * 3 + 2 ] ] );
}
if ( deformer ) {
for ( var i = 2; i < faceLength; i ++ ) {
- weightsB.push(
- faceWeights[ 0 ],
- faceWeights[ 1 ],
- faceWeights[ 2 ],
- faceWeights[ 3 ],
-
- faceWeights[ ( i - 1 ) * 4 ],
- faceWeights[ ( i - 1 ) * 4 + 1 ],
- faceWeights[ ( i - 1 ) * 4 + 2 ],
- faceWeights[ ( i - 1 ) * 4 + 3 ],
-
- faceWeights[ i * 4 ],
- faceWeights[ i * 4 + 1 ],
- faceWeights[ i * 4 + 2 ],
- faceWeights[ i * 4 + 3 ]
- );
-
- weightsIndicesB.push(
- faceWeightIndices[ 0 ],
- faceWeightIndices[ 1 ],
- faceWeightIndices[ 2 ],
- faceWeightIndices[ 3 ],
-
- faceWeightIndices[ ( i - 1 ) * 4 ],
- faceWeightIndices[ ( i - 1 ) * 4 + 1 ],
- faceWeightIndices[ ( i - 1 ) * 4 + 2 ],
- faceWeightIndices[ ( i - 1 ) * 4 + 3 ],
-
- faceWeightIndices[ i * 4 ],
- faceWeightIndices[ i * 4 + 1 ],
- faceWeightIndices[ i * 4 + 2 ],
- faceWeightIndices[ i * 4 + 3 ]
- );
+ weightsB.push( faceWeights[ 0 ] );
+ weightsB.push( faceWeights[ 1 ] );
+ weightsB.push( faceWeights[ 2 ] );
+ weightsB.push( faceWeights[ 3 ] );
+
+ weightsB.push( faceWeights[ ( i - 1 ) * 4 ] );
+ weightsB.push( faceWeights[ ( i - 1 ) * 4 + 1 ] );
+ weightsB.push( faceWeights[ ( i - 1 ) * 4 + 2 ] );
+ weightsB.push( faceWeights[ ( i - 1 ) * 4 + 3 ] );
+
+ weightsB.push( faceWeights[ i * 4 ] );
+ weightsB.push( faceWeights[ i * 4 + 1 ] );
+ weightsB.push( faceWeights[ i * 4 + 2 ] );
+ weightsB.push( faceWeights[ i * 4 + 3 ] );
+
+ weightsIndicesB.push( faceWeightIndices[ 0 ] );
+ weightsIndicesB.push( faceWeightIndices[ 1 ] );
+ weightsIndicesB.push( faceWeightIndices[ 2 ] );
+ weightsIndicesB.push( faceWeightIndices[ 3 ] );
+
+ weightsIndicesB.push( faceWeightIndices[ ( i - 1 ) * 4 ] );
+ weightsIndicesB.push( faceWeightIndices[ ( i - 1 ) * 4 + 1 ] );
+ weightsIndicesB.push( faceWeightIndices[ ( i - 1 ) * 4 + 2 ] );
+ weightsIndicesB.push( faceWeightIndices[ ( i - 1 ) * 4 + 3 ] );
+
+ weightsIndicesB.push( faceWeightIndices[ i * 4 ] );
+ weightsIndicesB.push( faceWeightIndices[ i * 4 + 1 ] );
+ weightsIndicesB.push( faceWeightIndices[ i * 4 + 2 ] );
+ weightsIndicesB.push( faceWeightIndices[ i * 4 + 3 ] );
}
@@ -960,19 +955,17 @@
for ( var i = 2; i < faceLength; i ++ ) {
- normalB.push(
- faceNormals[ 0 ],
- faceNormals[ 1 ],
- faceNormals[ 2 ],
+ normalB.push( faceNormals[ 0 ] );
+ normalB.push( faceNormals[ 1 ] );
+ normalB.push( faceNormals[ 2 ] );
- faceNormals[ ( i - 1 ) * 3 ],
- faceNormals[ ( i - 1 ) * 3 + 1 ],
- faceNormals[ ( i - 1 ) * 3 + 2 ],
+ normalB.push( faceNormals[ ( i - 1 ) * 3 ] );
+ normalB.push( faceNormals[ ( i - 1 ) * 3 + 1 ] );
+ normalB.push( faceNormals[ ( i - 1 ) * 3 + 2 ] );
- faceNormals[ i * 3 ],
- faceNormals[ i * 3 + 1 ],
- faceNormals[ i * 3 + 2 ]
- );
+ normalB.push( faceNormals[ i * 3 ] );
+ normalB.push( faceNormals[ i * 3 + 1 ] );
+ normalB.push( faceNormals[ i * 3 + 2 ] );
}
@@ -986,18 +979,14 @@
for ( var i = 2; i < faceLength; i ++ ) {
- uvsB[ j ].push(
-
- faceUVs[ j ][ 0 ],
- faceUVs[ j ][ 1 ],
+ uvsB[ j ].push( faceUVs[ j ][ 0 ] );
+ uvsB[ j ].push( faceUVs[ j ][ 1 ] );
- faceUVs[ j ][ ( i - 1 ) * 2 ],
- faceUVs[ j ][ ( i - 1 ) * 2 + 1 ],
+ uvsB[ j ].push( faceUVs[ j ][ ( i - 1 ) * 2 ] );
+ uvsB[ j ].push( faceUVs[ j ][ ( i - 1 ) * 2 + 1 ] );
- faceUVs[ j ][ i * 2 ],
- faceUVs[ j ][ i * 2 + 1 ]
-
- );
+ uvsB[ j ].push( faceUVs[ j ][ i * 2 ] );
+ uvsB[ j ].push( faceUVs[ j ][ i * 2 + 1 ] );
}
@@ -1009,19 +998,18 @@
for ( var i = 2; i < faceLength; i ++ ) {
- colorsB.push(
- faceColors[ 0 ],
- faceColors[ 1 ],
- faceColors[ 2 ],
- faceColors[ ( i - 1 ) * 3 ],
- faceColors[ ( i - 1 ) * 3 + 1 ],
- faceColors[ ( i - 1 ) * 3 + 2 ],
+ colorsB.push( faceColors[ 0 ] );
+ colorsB.push( faceColors[ 1 ] );
+ colorsB.push( faceColors[ 2 ] );
+
+ colorsB.push( faceColors[ ( i - 1 ) * 3 ] );
+ colorsB.push( faceColors[ ( i - 1 ) * 3 + 1 ] );
+ colorsB.push( faceColors[ ( i - 1 ) * 3 + 2 ] );
- faceColors[ i * 3 ],
- faceColors[ i * 3 + 1 ],
- faceColors[ i * 3 + 2 ]
- );
+ colorsB.push( faceColors[ i * 3 ] );
+ colorsB.push( faceColors[ i * 3 + 1 ] );
+ colorsB.push( faceColors[ i * 3 + 2 ] );
}
@@ -1033,11 +1021,9 @@
for ( var i = 2; i < faceLength; i ++ ) {
- materialsB.push(
- materialIndex,
- materialIndex,
- materialIndex
- );
+ materialsB.push( materialIndex );
+ materialsB.push( materialIndex );
+ materialsB.push( materialIndex );
}
@@ -1077,6 +1063,7 @@
geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( weightsB, 4 ) );
+ // used later to bind the skeleton to the model
geo.FBX_Deformer = deformer;
} | false |
Other | mrdoob | three.js | 3268df1029fb9a88c98f32757bc6c48004d0c487.json | Update BufferGeometry doc | docs/api/core/BufferGeometry.html | @@ -195,7 +195,7 @@ <h2>Methods</h2>
<h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3>
- <h3>[method:null addAttribute]( [param:String name], [param:BufferAttribute attribute] )</h3>
+ <h3>[method:BufferGeometry addAttribute]( [param:String name], [param:BufferAttribute attribute] )</h3>
<p>
Adds an attribute to this geometry. Use this rather than the attributes property,
because an internal hashmap of [page:.attributes] is maintained to speed up iterating over | false |
Other | mrdoob | three.js | fe4b89a167b69037305d55c7b5b310e10daf993a.json | Fix style bugs | src/math/Matrix4.js | @@ -288,6 +288,7 @@ Object.assign( Matrix4.prototype, {
return this.compose( zero, q, one );
};
+
}(),
lookAt: function () {
@@ -732,24 +733,24 @@ Object.assign( Matrix4.prototype, {
var te = this.elements;
var x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
- var x2 = x + x, y2 = y + y, z2 = z + z;
+ var x2 = x + x, y2 = y + y, z2 = z + z;
var xx = x * x2, xy = x * y2, xz = x * z2;
var yy = y * y2, yz = y * z2, zz = z * z2;
var wx = w * x2, wy = w * y2, wz = w * z2;
var sx = scale.x, sy = scale.y, sz = scale.z;
- te[ 0 ] = (1 - ( yy + zz )) * sx;
- te[ 4 ] = (xy - wz) * sy;
- te[ 8 ] = (xz + wy) * sz;
+ te[ 0 ] = ( 1 - ( yy + zz ) ) * sx;
+ te[ 4 ] = ( xy - wz ) * sy;
+ te[ 8 ] = ( xz + wy ) * sz;
- te[ 1 ] = (xy + wz) * sx;
- te[ 5 ] = (1 - ( xx + zz )) * sy;
- te[ 9 ] = (yz - wx) * sz;
+ te[ 1 ] = ( xy + wz ) * sx;
+ te[ 5 ] = ( 1 - ( xx + zz ) ) * sy;
+ te[ 9 ] = ( yz - wx ) * sz;
- te[ 2 ] = (xz - wy) * sx;
- te[ 6 ] = (yz + wx) * sy;
- te[ 10 ] = (1 - ( xx + yy )) * sz;
+ te[ 2 ] = ( xz - wy ) * sx;
+ te[ 6 ] = ( yz + wx ) * sy;
+ te[ 10 ] = ( 1 - ( xx + yy ) ) * sz;
// last column
te[ 3 ] = 0;
@@ -763,6 +764,7 @@ Object.assign( Matrix4.prototype, {
te[ 15 ] = 1;
return this;
+
},
decompose: function () { | false |
Other | mrdoob | three.js | 7058bf8ea3a9f9c11bf76ef158e7b9a22757a74d.json | Fix variable name.
Change the variable name 'cube' to 'klein'. | docs/api/geometries/ParametricBufferGeometry.html | @@ -37,8 +37,8 @@ <h2>Example</h2>
<code>
var geometry = new THREE.ParametricBufferGeometry( THREE.ParametricGeometries.klein, 25, 25 );
var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
- var cube = new THREE.Mesh( geometry, material );
- scene.add( cube );
+ var klein = new THREE.Mesh( geometry, material );
+ scene.add( klein );
</code>
| false |
Other | mrdoob | three.js | 03681b7bd6e1a3910a667a03ba99f79d396289ac.json | Add updateMatrixWorld benchmark | test/benchmark/benchmarks.html | @@ -15,6 +15,7 @@
<script src="core/Vector3Storage.js"></script>
<script src="core/Vector3Length.js"></script>
<script src="core/Float32Array.js"></script>
+ <script src="core/UpdateMatrixWorld.js"></script>
</head>
<body>
<header> | true |
Other | mrdoob | three.js | 03681b7bd6e1a3910a667a03ba99f79d396289ac.json | Add updateMatrixWorld benchmark | test/benchmark/core/UpdateMatrixWorld.js | @@ -0,0 +1,48 @@
+(function() {
+
+ THREE = Bench.THREE;
+
+ var position = new THREE.Vector3(1, 1, 1);
+ var scale = new THREE.Vector3(2, 1, 0.5);
+ var rotation = new THREE.Quaternion();
+ rotation.setFromAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 8);
+ var createLocallyOffsetChild = function() {
+ var child = new THREE.Object3D();
+ child.position = position;
+ child.scale = scale;
+ child.rotation = rotation;
+ return child;
+ };
+
+ var generateSceneGraph = function(root, depth, breadth, initObject) {
+ if (depth > 0) {
+ for (var i = 0; i < breadth; i++) {
+ var child = initObject();
+ root.add(child);
+ generateSceneGraph(child, depth - 1, breadth, initObject);
+ }
+ }
+ return root;
+ };
+
+ var nodeCount = function(root) {
+ return root.children.reduce(function(acc, x) { return acc + nodeCount(x); }, 1);
+ };
+
+ var rootA = generateSceneGraph(new THREE.Object3D(), 100, 1, createLocallyOffsetChild);
+ var rootB = generateSceneGraph(new THREE.Object3D(), 3, 10, createLocallyOffsetChild);
+ var rootC = generateSceneGraph(new THREE.Object3D(), 9, 3, createLocallyOffsetChild);
+
+ var s = Bench.newSuite("Update world transforms");
+
+ s.add('Update graph depth=100, breadth=1 (' + nodeCount(rootA) + ' nodes)', function() {
+ rootA.updateMatrixWorld(true);
+ });
+ s.add('Update graph depth=3, breadth=10 (' + nodeCount(rootB) + ' nodes)', function() {
+ rootB.updateMatrixWorld(true);
+ });
+ s.add('Update graph depth=9, breadth=3 (' + nodeCount(rootC) + ' nodes)', function() {
+ rootC.updateMatrixWorld(true);
+ });
+
+})(); | true |
Other | mrdoob | three.js | fd1ad09fb8cf5d1af0c8f94ed107b035bafb90f3.json | Improve collision handling | examples/webvr_gearvr.html | @@ -231,6 +231,10 @@
if ( normal.length() < 2 * radius ) {
+ normal.multiplyScalar( 0.5 * normal.length() - radius );
+ cube.position.sub( normal );
+ cube2.position.add( normal );
+
normal.normalize();
relativeVelocity.copy( cube.userData.velocity ).sub( cube2.userData.velocity ); | false |
Other | mrdoob | three.js | 63f7f8b0bc17795364fa72d34cd6ac7d71203cbe.json | Add collision handling | examples/webvr_gearvr.html | @@ -42,6 +42,10 @@
var controller;
var room;
+
+ var radius = 0.08;
+ var normal = new THREE.Vector3();
+ var relativeVelocity = new THREE.Vector3();
init();
animate();
@@ -77,7 +81,7 @@
light.position.set( 1, 1, 1 ).normalize();
scene.add( light );
- var geometry = new THREE.IcosahedronBufferGeometry( 0.08, 2 );
+ var geometry = new THREE.IcosahedronBufferGeometry( radius, 2 );
for ( var i = 0; i < 200; i ++ ) {
@@ -187,7 +191,7 @@
// keep cubes inside room
- var range = 3 - 0.08;
+ var range = 3 - radius;
for ( var i = 0; i < room.children.length; i ++ ) {
@@ -218,6 +222,28 @@
cube.userData.velocity.z = - cube.userData.velocity.z;
}
+
+ for ( var j = i + 1; j < room.children.length; j ++ ) {
+
+ var cube2 = room.children[ j ];
+
+ normal.copy( cube.position ).sub( cube2.position );
+
+ if ( normal.length() < 2 * radius ) {
+
+ normal.normalize();
+
+ relativeVelocity.copy( cube.userData.velocity ).sub( cube2.userData.velocity );
+ var dot = relativeVelocity.dot( normal );
+
+ normal = normal.multiplyScalar( dot );
+
+ cube.userData.velocity.sub( normal );
+ cube2.userData.velocity.add( normal );
+
+ }
+
+ }
cube.userData.velocity.y -= 0.00098;
| false |
Other | mrdoob | three.js | 158fc6ca70d4afebff5d323f62ef87b3efb6b48d.json | Update webgl2_sandbox example | examples/webgl2_sandbox.html | @@ -44,7 +44,7 @@
import { Mesh } from '../src/objects/Mesh.js';
import { Fog } from '../src/scenes/Fog.js';
import { Scene } from '../src/scenes/Scene.js';
- import { WebGL2Renderer } from '../src/renderers/WebGL2Renderer.js';
+ import { WebGLRenderer } from '../src/renderers/WebGLRenderer.js';
//
@@ -89,7 +89,10 @@
}
- renderer = new WebGL2Renderer();
+ var canvas = document.createElement( 'canvas' );
+ var context = canvas.getContext( 'webgl2' );
+
+ renderer = new WebGLRenderer( { canvas: canvas, context: context } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement ); | false |
Other | mrdoob | three.js | 1f2b11a169f9f536ed62424bf9a1ae66b812d175.json | Remove unneccessary argument
https://lgtm.com/projects/g/mrdoob/three.js/snapshot/60c5764c63fa3841f02dcf91cf7dceeeef66889c/files/build/three.module.js?#x16404adc80fd6243:1 | src/geometries/ExtrudeGeometry.js | @@ -72,7 +72,7 @@ function ExtrudeBufferGeometry( shapes, options ) {
for ( var i = 0, l = shapes.length; i < l; i ++ ) {
var shape = shapes[ i ];
- addShape( shape, options );
+ addShape( shape );
}
| false |
Other | mrdoob | three.js | a89ed40a1e72a9179844fad9db3ad93bc1ba9374.json | Remove mipmaps serialization | src/loaders/ObjectLoader.js | @@ -570,7 +570,6 @@ Object.assign( ObjectLoader.prototype, {
if ( data.minFilter !== undefined ) texture.minFilter = parseConstant( data.minFilter, TEXTURE_FILTER );
if ( data.magFilter !== undefined ) texture.magFilter = parseConstant( data.magFilter, TEXTURE_FILTER );
if ( data.anisotropy !== undefined ) texture.anisotropy = data.anisotropy;
- if ( data.mipmaps !== undefined ) texture.mipmaps = data.mipmaps;
if ( data.flipY !== undefined ) texture.flipY = data.flipY;
| true |
Other | mrdoob | three.js | a89ed40a1e72a9179844fad9db3ad93bc1ba9374.json | Remove mipmaps serialization | src/textures/Texture.js | @@ -197,7 +197,6 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
- mipmaps: this.mipmaps.slice(),
flipY: this.flipY,
| true |
Other | mrdoob | three.js | 99a7cb9fdff3c4968ccd4c78d00bc7f5cac5f333.json | Remove an unnecessary space | src/textures/Texture.js | @@ -240,7 +240,7 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
width: mipmap.width,
height: mipmap.height,
type: mipmap.data.constructor.name,
- array: Array.prototype.slice.call( mipmap.data )
+ array: Array.prototype.slice.call( mipmap.data )
} );
} else { | false |
Other | mrdoob | three.js | 22e44073bc8eb99790b7c86f456c6ace36f04bd4.json | Remove .userData from Geometry doc | docs/api/core/Geometry.html | @@ -174,12 +174,6 @@ <h3>[property:Array skinIndices]</h3>
</code>
</p>
- <h3>[property:Object userData]</h3>
- <p>
- An object that can be used to store custom data about the Geometry. It should not hold
- references to functions as these will not be cloned.
- </p>
-
<h3>[property:String uuid]</h3>
<p>
[link:http://en.wikipedia.org/wiki/Universally_unique_identifier UUID] of this object instance. | false |
Other | mrdoob | three.js | d512381bd72edde8238ad5f2edff66a70600c001.json | Fix Texture.mapping type in Texture doc | docs/api/textures/Texture.html | @@ -60,7 +60,7 @@ <h3>[property:array mipmaps]</h3>
Array of user-specified mipmaps (optional).
</p>
- <h3>[property:object mapping]</h3>
+ <h3>[property:number mapping]</h3>
<p>
How the image is applied to the object. An object type of [page:Textures THREE.UVMapping] is the default,
where the U,V coordinates are used to apply the map.<br /> | false |
Other | mrdoob | three.js | 01ff9bd73b1441107caf6fae239cd1ead4537a05.json | Keep front of helper facing direction of normal | src/helpers/PlaneHelper.js | @@ -9,6 +9,7 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
import { Float32BufferAttribute } from '../core/BufferAttribute.js';
import { BufferGeometry } from '../core/BufferGeometry.js';
import { Object3D } from '../core/Object3D.js';
+import { FrontSide, BackSide } from '../constants.js';
function PlaneHelper( plane, size, hex ) {
@@ -51,6 +52,8 @@ PlaneHelper.prototype.updateMatrixWorld = function ( force ) {
this.scale.set( 0.5 * this.size, 0.5 * this.size, scale );
+ this.children[ 0 ].material.side = ( scale < 0 ) ? BackSide : FrontSide; // renderer flips side when determinant < 0; flipping not wanted here
+
this.lookAt( this.plane.normal );
Object3D.prototype.updateMatrixWorld.call( this, force ); | false |
Other | mrdoob | three.js | f949a2c4c31978ef42c37cf5d22c301c70d3a8cd.json | fix some mistakes and approve the effect | examples/js/shaders/AfterimageShader.js | @@ -51,12 +51,19 @@ THREE.AfterimageShader = {
"texelOld *= damp;",
- "texelOld.r *= when_gt( texelOld.r, 0.2 );",
- "texelOld.g *= when_gt( texelOld.g, 0.2 );",
- "texelOld.b *= when_gt( texelOld.b, 0.2 );",
- "texelOld.a *= when_gt( texelOld.a, 0.2 );",
+ "texelOld.r *= when_gt( texelOld.r, 0.1 );",
+ "texelOld.g *= when_gt( texelOld.g, 0.1 );",
+ "texelOld.b *= when_gt( texelOld.b, 0.1 );",
+ "texelOld.a *= when_gt( texelOld.a, 0.1 );",
- "gl_FragColor = texelOld + texelNew;",
+ "gl_FragColor = vec4(",
+
+ "max( texelNew.r, texelOld.r ),",
+ "max( texelNew.g, texelOld.g ),",
+ "max( texelNew.b, texelOld.b ),",
+ "max( texelNew.a, texelOld.a )",
+
+ ");",
"}"
| true |
Other | mrdoob | three.js | f949a2c4c31978ef42c37cf5d22c301c70d3a8cd.json | fix some mistakes and approve the effect | examples/webgl_postprocessing_afterimage.html | @@ -55,7 +55,7 @@
scene.add( object );
var geometry = new THREE.BoxBufferGeometry( 150, 150, 150, 2, 2, 2);
- var material = new THREE.MeshNormalMaterial( { wireframe: true } );
+ var material = new THREE.MeshNormalMaterial();
mesh = new THREE.Mesh( geometry, material );
scene.add( mesh );
| true |
Other | mrdoob | three.js | 54fdf6304b789b575b341f2008adcf31b96ab468.json | Add missing isCanvasTexture property | src/textures/CanvasTexture.js | @@ -14,6 +14,6 @@ function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, for
CanvasTexture.prototype = Object.create( Texture.prototype );
CanvasTexture.prototype.constructor = CanvasTexture;
-
+CanvasTexture.prototype.isCanvasTexture = true;
export { CanvasTexture }; | false |
Other | mrdoob | three.js | 2928e097a2050675791e449345a7826a9ccaa20b.json | Add userData to Geometry | src/core/Geometry.js | @@ -46,6 +46,8 @@ function Geometry() {
this.boundingBox = null;
this.boundingSphere = null;
+ this.userData = {};
+
// update flags
this.elementsNeedUpdate = false;
@@ -987,6 +989,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
data.uuid = this.uuid;
data.type = this.type;
if ( this.name !== '' ) data.name = this.name;
+ if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
if ( this.parameters !== undefined ) {
@@ -1415,6 +1418,10 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
}
+ // user data
+
+ this.userData = source.userData;
+
// update flags
this.elementsNeedUpdate = source.elementsNeedUpdate; | false |
Other | mrdoob | three.js | 0e489d543b20f4406bbc95a2dae45bcfe67f4c2b.json | Add userData to BufferGeometry | src/core/BufferGeometry.js | @@ -38,6 +38,8 @@ function BufferGeometry() {
this.drawRange = { start: 0, count: Infinity };
+ this.userData = {};
+
}
BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
@@ -930,6 +932,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
data.uuid = this.uuid;
data.type = this.type;
if ( this.name !== '' ) data.name = this.name;
+ if ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;
if ( this.parameters !== undefined ) {
@@ -1123,6 +1126,10 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy
this.drawRange.start = source.drawRange.start;
this.drawRange.count = source.drawRange.count;
+ // user data
+
+ this.userData = source.userData;
+
return this;
}, | false |
Other | mrdoob | three.js | 10df2978ab18a9e187ac16e6e458961b0d7aef69.json | add afterimage effect
a postprocessing of afterimage effect. Looks pretty cool. | examples/js/postprocessing/AfterimagePass.js | @@ -0,0 +1,88 @@
+/**
+ * @author HypnosNova / https://www.threejs.org.cn/gallery/
+ */
+
+THREE.AfterimagePass = function ( damp ) {
+
+ THREE.Pass.call( this );
+
+ if ( THREE.AfterimageShader === undefined )
+ console.error( "THREE.AfterimagePass relies on THREE.AfterimageShader" );
+
+ this.shader = THREE.AfterimageShader;
+
+ this.uniforms = THREE.UniformsUtils.clone( this.shader.uniforms );
+
+ this.uniforms[ "damp" ].value = damp !== undefined ? damp : 0.96;
+
+ this.textureComp = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+
+ minFilter: THREE.LinearFilter,
+ magFilter: THREE.NearestFilter,
+ format: THREE.RGBAFormat
+
+ } );
+
+ this.textureOld = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, {
+
+ minFilter: THREE.LinearFilter,
+ magFilter: THREE.NearestFilter,
+ format: THREE.RGBAFormat
+
+ } );
+
+ this.shaderMaterial = new THREE.ShaderMaterial( {
+
+ uniforms: this.uniforms,
+ vertexShader: this.shader.vertexShader,
+ fragmentShader: this.shader.fragmentShader
+
+ } );
+
+ this.sceneComp = new THREE.Scene();
+ this.scene = new THREE.Scene();
+
+ this.camera = new THREE.OrthographicCamera( -1, 1, 1, -1, 0, 1 );
+ this.camera.position.z = 1;
+
+ var geometry = new THREE.PlaneBufferGeometry( 2, 2 );
+
+ this.quadComp = new THREE.Mesh( geometry, this.shaderMaterial );
+ this.sceneComp.add( this.quadComp );
+
+ var material = new THREE.MeshBasicMaterial( {
+ map: this.textureComp.texture
+ } );
+
+ var quadScreen = new THREE.Mesh( geometry, material );
+ this.scene.add( quadScreen );
+
+};
+
+THREE.AfterimagePass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {
+
+ constructor: THREE.AfterimagePass,
+
+ render: function ( renderer, writeBuffer, readBuffer ) {
+
+ this.uniforms[ "tOld" ].value = this.textureOld.texture;
+ this.uniforms[ "tNew" ].value = readBuffer.texture;
+
+ this.quadComp.material = this.shaderMaterial;
+
+ renderer.render( this.sceneComp, this.camera, this.textureComp );
+ renderer.render( this.scene, this.camera, this.textureOld );
+
+ if ( this.renderToScreen ) {
+
+ renderer.render( this.scene, this.camera );
+
+ } else {
+
+ renderer.render( this.scene, this.camera, writeBuffer, this.clear );
+
+ }
+
+ }
+
+} ); | true |
Other | mrdoob | three.js | 10df2978ab18a9e187ac16e6e458961b0d7aef69.json | add afterimage effect
a postprocessing of afterimage effect. Looks pretty cool. | examples/js/shaders/AfterimageShader.js | @@ -0,0 +1,65 @@
+/**
+ * @author HypnosNova / https://www.threejs.org.cn/gallery/
+ * I'm lucky to get this domain name.(threejs.org.cn)
+ *
+ * Afterimage shader
+ * I created this effect inspired by a demo on codepen. (Unfortunately, I forgot the url)
+ */
+
+THREE.AfterimageShader = {
+
+ uniforms: {
+
+ "damp": { value: 0.96 },
+ "tOld": { value: null },
+ "tNew": { value: null }
+
+ },
+
+ vertexShader: [
+
+ "varying vec2 vUv;",
+
+ "void main() {",
+
+ "vUv = uv;",
+ "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+ "}"
+
+ ].join( "\n" ),
+
+ fragmentShader: [
+
+ "uniform float damp;",
+
+ "uniform sampler2D tOld;",
+ "uniform sampler2D tNew;",
+
+ "varying vec2 vUv;",
+
+ "float when_gt( float x, float y ) {",
+
+ "return max( sign( x - y ), 0.0 );",
+
+ "}",
+
+ "void main() {",
+
+ "vec4 texelOld = texture2D( tOld, vUv );",
+ "vec4 texelNew = texture2D( tNew, vUv );",
+
+ "texelOld *= damp;",
+
+ "texelOld.r *= when_gt( texelOld.r, 0.2 );",
+ "texelOld.g *= when_gt( texelOld.g, 0.2 );",
+ "texelOld.b *= when_gt( texelOld.b, 0.2 );",
+ "texelOld.a *= when_gt( texelOld.a, 0.2 );",
+
+ "gl_FragColor = texelOld + texelNew;",
+
+ "}"
+
+ ].join( "\n" )
+
+}; | true |
Other | mrdoob | three.js | 10df2978ab18a9e187ac16e6e458961b0d7aef69.json | add afterimage effect
a postprocessing of afterimage effect. Looks pretty cool. | examples/webgl_postprocessing_afterimage.html | @@ -0,0 +1,116 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - postprocessing - afterimage</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ margin: 0px;
+ background-color: #000000;
+ overflow: hidden;
+ }
+ </style>
+ </head>
+ <body>
+
+ <script src="../build/three.js"></script>
+
+ <script src="js/shaders/CopyShader.js"></script>
+ <script src="js/shaders/AfterimageShader.js"></script>
+
+ <script src="js/postprocessing/EffectComposer.js"></script>
+ <script src="js/postprocessing/RenderPass.js"></script>
+ <script src="js/postprocessing/MaskPass.js"></script>
+ <script src="js/postprocessing/ShaderPass.js"></script>
+ <script src="js/postprocessing/AfterimagePass.js"></script>
+
+ <script src="js/libs/dat.gui.min.js" type="text/javascript" charset="utf-8"></script>
+
+ <script>
+
+ var camera, scene, renderer, composer;
+ var mesh, light;
+
+ var afterimagePass, openPass=true;
+
+ init();
+ createGUI();
+ animate();
+
+ function init() {
+
+ renderer = new THREE.WebGLRenderer();
+ renderer.setPixelRatio( window.devicePixelRatio );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ document.body.appendChild( renderer.domElement );
+
+ camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
+ camera.position.z = 400;
+
+ scene = new THREE.Scene();
+ scene.fog = new THREE.Fog( 0x000000, 1, 1000 );
+
+ object = new THREE.Object3D();
+ scene.add( object );
+
+ var geometry = new THREE.BoxBufferGeometry( 150, 150, 150, 2, 2, 2);
+ var material = new THREE.MeshNormalMaterial( { wireframe: true } );
+ mesh = new THREE.Mesh( geometry, material );
+ scene.add( mesh );
+
+ // postprocessing
+
+ composer = new THREE.EffectComposer( renderer );
+ composer.addPass( new THREE.RenderPass( scene, camera ) );
+
+ afterimagePass = new THREE.AfterimagePass();
+ afterimagePass.renderToScreen = true;
+ composer.addPass( afterimagePass );
+
+ window.addEventListener( 'resize', onWindowResize, false );
+
+ }
+
+ function createGUI(){
+
+ var gui = new dat.GUI( { name: 'Damp setting' } );
+ gui.add( afterimagePass.uniforms[ "damp" ], 'value', 0, 1 ).step( 0.001 );
+ gui.add( this, 'openPass');
+
+ }
+
+ function onWindowResize() {
+
+ camera.aspect = window.innerWidth / window.innerHeight;
+ camera.updateProjectionMatrix();
+
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ composer.setSize( window.innerWidth, window.innerHeight );
+
+ }
+
+ function animate() {
+
+ requestAnimationFrame( animate );
+
+ var time = Date.now();
+
+ mesh.rotation.x += 0.005;
+ mesh.rotation.y += 0.01;
+
+ if(openPass){
+
+ composer.render();
+
+ } else {
+
+ renderer.render(scene, camera);
+
+ }
+
+ }
+
+ </script>
+ </body>
+</html> | true |
Other | mrdoob | three.js | 1f3207f15754e5af8df480b8cd5a5fe6b54f1ee9.json | Add missing properties to Texture.toJSON() | src/textures/Texture.js | @@ -191,11 +191,18 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {
wrap: [ this.wrapS, this.wrapT ],
format: this.format,
+ type: this.type,
+ encoding: this.encoding,
+
minFilter: this.minFilter,
magFilter: this.magFilter,
anisotropy: this.anisotropy,
+ mipmaps: this.mipmaps.slice(),
+
+ flipY: this.flipY,
- flipY: this.flipY
+ premultiplyAlpha: this.premultiplyAlpha,
+ unpackAlignment: this.unpackAlignment
};
| false |
Other | mrdoob | three.js | 473c861ee144620772877dde7a4dbb1265257b45.json | Remove unnecessary code
/ping @takahirox | examples/js/loaders/GLTFLoader.js | @@ -572,7 +572,6 @@ THREE.GLTFLoader = ( function () {
].join( '\n' );
var fragmentShader = shader.fragmentShader
- .replace( '#include <specularmap_fragment>', '' )
.replace( 'uniform float roughness;', 'uniform vec3 specular;' )
.replace( 'uniform float metalness;', 'uniform float glossiness;' )
.replace( '#include <roughnessmap_pars_fragment>', specularMapParsFragmentChunk ) | false |
Other | mrdoob | three.js | 8ef140ad6de5c338d0410bf1078536056840553d.json | fix mosaic mask | examples/webgl_postprocessing_nodes.html | @@ -465,9 +465,9 @@
}, false, 0, 1 );
- addGui( 'mask', true, function ( val ) {
+ addGui( 'mask', false, function ( val ) {
- fadeCoord.c = val ? maskAlpha : fade;
+ fadeScreen.c = val ? new THREE.TextureNode( lensflare2 ) : fade;
nodepass.needsUpdate = true;
| false |
Other | mrdoob | three.js | 648a85d025925d3a57738887607454c6cde1758f.json | add uuid for shader and uniforms | examples/js/nodes/NodeMaterial.js | @@ -6,6 +6,8 @@ THREE.NodeMaterial = function ( vertex, fragment ) {
THREE.ShaderMaterial.call( this );
+ this.defines.UUID = THREE.Math.generateUUID();
+
this.vertex = vertex || new THREE.RawNode( new THREE.PositionNode( THREE.PositionNode.PROJECTION ) );
this.fragment = fragment || new THREE.RawNode( new THREE.ColorNode( 0xFF0000 ) );
@@ -101,7 +103,7 @@ THREE.NodeMaterial.prototype.build = function ( params ) {
this.nodes = [];
- this.defines = {};
+ this.defines = { UUID: this.defines.UUID };
this.uniforms = {};
this.attributes = {};
@@ -310,7 +312,7 @@ THREE.NodeMaterial.prototype.createUniform = function ( type, node, ns, needsUpd
var uniform = new THREE.NodeUniform( {
type: type,
- name: ns ? ns : 'nVu' + index,
+ name: ns ? ns : 'nVu' + index + '_' + THREE.Math.generateUUID().substr(0, 8),
node: node,
needsUpdate: needsUpdate
} ); | false |
Other | mrdoob | three.js | 94e5122f8327974a153fa1dfbb74c19df2daf961.json | Remove unnecessary shader chunk | examples/webgl_buffergeometry_instancing_lambert.html | @@ -144,7 +144,6 @@
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
- #include <lights_pars_maps>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex> | true |
Other | mrdoob | three.js | 94e5122f8327974a153fa1dfbb74c19df2daf961.json | Remove unnecessary shader chunk | examples/webgl_shaders_tonemapping.html | @@ -161,7 +161,6 @@
THREE.ShaderChunk[ "common" ],
THREE.ShaderChunk[ "bsdfs" ],
THREE.ShaderChunk[ "lights_pars_begin" ],
- THREE.ShaderChunk[ "lights_pars_maps" ],
THREE.ShaderChunk[ "lights_phong_pars_fragment" ],
"void main() {", | true |
Other | mrdoob | three.js | 94e5122f8327974a153fa1dfbb74c19df2daf961.json | Remove unnecessary shader chunk | src/renderers/shaders/ShaderLib/meshlambert_frag.glsl | @@ -24,7 +24,6 @@ varying vec3 vLightFront;
#include <envmap_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
-#include <lights_pars_maps>
#include <fog_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment> | true |
Other | mrdoob | three.js | 94e5122f8327974a153fa1dfbb74c19df2daf961.json | Remove unnecessary shader chunk | src/renderers/shaders/ShaderLib/meshlambert_vert.glsl | @@ -14,7 +14,6 @@ varying vec3 vLightFront;
#include <envmap_pars_vertex>
#include <bsdfs>
#include <lights_pars_begin>
-#include <lights_pars_maps>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex> | true |
Other | mrdoob | three.js | 94e5122f8327974a153fa1dfbb74c19df2daf961.json | Remove unnecessary shader chunk | src/renderers/shaders/ShaderLib/meshphong_frag.glsl | @@ -22,7 +22,6 @@ uniform float opacity;
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
-#include <lights_pars_maps>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment> | true |
Other | mrdoob | three.js | 76fb60ae361880bed5b62c268667677077c3ab9a.json | use auto build | examples/js/loaders/NodeMaterialLoader.js | @@ -581,8 +581,6 @@ Object.assign( THREE.NodeMaterialLoader.prototype, {
object.value = this.getNode( node.value );
- object.build();
-
}
return this.material || this.pass || this; | true |
Other | mrdoob | three.js | 76fb60ae361880bed5b62c268667677077c3ab9a.json | use auto build | examples/js/nodes/postprocessing/NodePass.js | @@ -54,14 +54,6 @@ THREE.NodePass.prototype.render = function () {
};
-THREE.NodePass.prototype.build = function () {
-
- this.node.build();
-
- this.needsUpdate = false;
-
-};
-
THREE.NodePass.prototype.toJSON = function ( meta ) {
var isRootObject = ( meta === undefined || typeof meta === 'string' ); | true |
Other | mrdoob | three.js | ec05fcdb9fd8894b33e1a5dad921467ddeef9694.json | fix dead link | examples/webgl_postprocessing_advanced.html | @@ -35,7 +35,7 @@
<div id="info">
<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl postprocessing example -
- <a href="http://graphics.cs.williams.edu/data/meshes.xml#14" target="_blank" rel="noopener">Lee Perry-Smith</a> head
+ <a href="http://g3d.cs.williams.edu/g3d/data10/index.html#mesh19" target="_blank" rel="noopener">Lee Perry-Smith</a> head
</div>
<div id="container"></div> | false |
Other | mrdoob | three.js | 4963e37c83da93dcd377c3c4c5b6b05bfffdccb2.json | resolve more conflicts | examples/js/loaders/FBXLoader.js | @@ -732,10 +732,10 @@
var uvInfo = [];
var i = 0;
- while ( subNodes.LayerElementUV[ i ] ) {
+ while ( subNodes.LayerElementUV[ i ] ){
- uvInfo.push( getUVs( subNodes.LayerElementUV[ i ] ) );
- i ++;
+ uvInfo.push(getUVs( subNodes.LayerElementUV[ i ] ));
+ i++;
}
| false |
Other | mrdoob | three.js | efa028e2fe1f7c16d1e465d4bc8dcae774472018.json | Fix unpack bug | examples/js/shaders/SAOShader.js | @@ -102,7 +102,7 @@ THREE.SAOShader = {
"vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {",
" #if NORMAL_TEXTURE == 1",
- " return -unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
+ " return unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );",
" #else",
" return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );",
" #endif", | true |
Other | mrdoob | three.js | efa028e2fe1f7c16d1e465d4bc8dcae774472018.json | Fix unpack bug | src/renderers/shaders/ShaderChunk/packing.glsl | @@ -3,7 +3,7 @@ vec3 packNormalToRGB( const in vec3 normal ) {
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
- return 1.0 - 2.0 * rgb.xyz;
+ return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1) | true |
Other | mrdoob | three.js | ae581776a6ca749e4a274e43e4487220e4bdba5f.json | add new lines and spaces for code style | examples/webgl_tonemapping.html | @@ -221,7 +221,7 @@
gui.add( params, 'exposure', 0, 10 );
gui.add( params, 'whitePoint', 0, 10 );
gui.add( params, 'opacity', 0, 1 );
- gui.add( params, 'renderMode', [ 'Renderer', 'Composer'] );
+ gui.add( params, 'renderMode', [ 'Renderer', 'Composer' ] );
gui.open();
}
@@ -258,10 +258,13 @@
standardMaterial.opacity = params.opacity;
if( renderer.toneMapping !== toneMappingOptions[ params.toneMapping ] ) {
+
renderer.toneMapping = toneMappingOptions[ params.toneMapping ];
standardMaterial.needsUpdate = true;
floorMaterial.needsUpdate = true;
+
}
+
renderer.toneMappingExposure = params.exposure;
renderer.toneMappingWhitePoint = params.whitePoint;
@@ -275,10 +278,13 @@
}
if( params.renderMode === "Composer" ) {
+
composer.render();
- }
- else {
+
+ } else {
+
renderer.render( scene, camera );
+
}
} | false |
Other | mrdoob | three.js | a86afe1858f9b4adaa57e8b0f791c207df311a9e.json | remove redundant test and clean up | examples/webgl_tonemapping.html | @@ -253,18 +253,14 @@
function render() {
- if ( standardMaterial !== undefined ) {
+ standardMaterial.roughness = params.roughness;
+ standardMaterial.bumpScale = - 0.05 * params.bumpScale;
+ standardMaterial.opacity = params.opacity;
-
- standardMaterial.roughness = params.roughness;
- standardMaterial.bumpScale = - 0.05 * params.bumpScale;
- standardMaterial.opacity = params.opacity;
-
- }
if( renderer.toneMapping !== toneMappingOptions[ params.toneMapping ] ) {
renderer.toneMapping = toneMappingOptions[ params.toneMapping ];
- if( standardMaterial ) standardMaterial.needsUpdate = true;
- if( floorMaterial ) floorMaterial.needsUpdate = true;
+ standardMaterial.needsUpdate = true;
+ floorMaterial.needsUpdate = true;
}
renderer.toneMappingExposure = params.exposure;
renderer.toneMappingWhitePoint = params.whitePoint; | false |
Other | mrdoob | three.js | fd5934e6577ff6153bd33d746cf359f45a779764.json | fix alphabetical order of loader examples | examples/files.js | @@ -101,13 +101,13 @@ var files = {
"webgl_loader_mmd_pose",
"webgl_loader_mmd_audio",
"webgl_loader_nodes",
+ "webgl_loader_nrrd",
"webgl_loader_obj",
"webgl_loader_obj_mtl",
"webgl_loader_obj2",
"webgl_loader_obj2_meshspray",
"webgl_loader_obj2_options",
"webgl_loader_obj2_run_director",
- "webgl_loader_nrrd",
"webgl_loader_pcd",
"webgl_loader_pdb",
"webgl_loader_playcanvas", | false |
Other | mrdoob | three.js | c48d55fc3a11004edb2a8837373f77661cc838b8.json | rename Triangle.uvIntersection to getUV | src/math/Triangle.js | @@ -1,4 +1,3 @@
-import { Vector2 } from './Vector2.js';
import { Vector3 } from './Vector3.js';
/**
@@ -109,24 +108,20 @@ Object.assign( Triangle, {
}(),
- uvIntersection: function () {
+ getUV: function () {
var barycoord = new Vector3();
- var v1 = new Vector2();
- var v2 = new Vector2();
- var v3 = new Vector2();
- return function uvIntersection( point, p1, p2, p3, uv1, uv2, uv3, result ) {
+ return function getUV( point, p1, p2, p3, uv1, uv2, uv3, target ) {
this.getBarycoord( point, p1, p2, p3, barycoord );
- v1.copy( uv1 ).multiplyScalar( barycoord.x );
- v2.copy( uv2 ).multiplyScalar( barycoord.y );
- v3.copy( uv3 ).multiplyScalar( barycoord.z );
+ target.set( 0, 0 );
+ target.addScaledVector( uv1, barycoord.x );
+ target.addScaledVector( uv2, barycoord.y );
+ target.addScaledVector( uv3, barycoord.z );
- v1.add( v2 ).add( v3 );
-
- return result.copy( v1 );
+ return target;
};
@@ -232,9 +227,9 @@ Object.assign( Triangle.prototype, {
},
- uvIntersection: function ( point, uv1, uv2, uv3, result ) {
+ getUV: function ( point, uv1, uv2, uv3, result ) {
- return Triangle.uvIntersection( point, this.a, this.b, this.c, uv1, uv2, uv3, result );
+ return Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, result );
},
| true |
Other | mrdoob | three.js | c48d55fc3a11004edb2a8837373f77661cc838b8.json | rename Triangle.uvIntersection to getUV | src/objects/Mesh.js | @@ -190,7 +190,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
uvB.fromBufferAttribute( uv, b );
uvC.fromBufferAttribute( uv, c );
- intersection.uv = Triangle.uvIntersection( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
+ intersection.uv = Triangle.getUV( intersectionPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() );
}
@@ -432,7 +432,7 @@ Mesh.prototype = Object.assign( Object.create( Object3D.prototype ), {
uvB.copy( uvs_f[ 1 ] );
uvC.copy( uvs_f[ 2 ] );
- intersection.uv = Triangle.uvIntersection( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );
+ intersection.uv = Triangle.getUV( intersectionPoint, fvA, fvB, fvC, uvA, uvB, uvC, new Vector2() );
}
| true |
Other | mrdoob | three.js | c48d55fc3a11004edb2a8837373f77661cc838b8.json | rename Triangle.uvIntersection to getUV | src/objects/Sprite.js | @@ -149,7 +149,7 @@ Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
distance: distance,
point: intersectPoint.clone(),
- uv: Triangle.uvIntersection( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),
+ uv: Triangle.getUV( intersectPoint, vA, vB, vC, uvA, uvB, uvC, new Vector2() ),
face: null,
object: this
| true |
Other | mrdoob | three.js | bf9b0d4dd4b46c89b08637142f2c61f0ee91ba75.json | Fix error handling for PCDLoader parsing #14776 | examples/js/loaders/PCDLoader.js | @@ -28,7 +28,23 @@ THREE.PCDLoader.prototype = {
loader.setResponseType( 'arraybuffer' );
loader.load( url, function ( data ) {
- onLoad( scope.parse( data, url ) );
+ try {
+
+ onLoad( scope.parse( data, url ) );
+
+ } catch ( e ) {
+
+ if ( onError ) {
+
+ onError( e );
+
+ } else {
+
+ throw e;
+
+ }
+
+ }
}, onProgress, onError );
| false |
Other | mrdoob | three.js | 7f57a46b1ad5c9b7e83e9a19b116baf17a442b89.json | Remove unneeded parameter | examples/webgl_physics_terrain.html | @@ -204,7 +204,7 @@
// Create the terrain body
- var groundShape = createTerrainShape( heightData );
+ var groundShape = createTerrainShape();
var groundTransform = new Ammo.btTransform();
groundTransform.setIdentity();
// Shifts the terrain, since bullet re-centers it on its bounding box. | false |
Other | mrdoob | three.js | c6639997ecd356648294eac619e917c315af97a1.json | add sprite raycast demo | examples/files.js | @@ -242,6 +242,7 @@ var files = {
"webgl_postprocessing_taa",
"webgl_postprocessing_unreal_bloom",
"webgl_raycast_texture",
+ "webgl_raycast_sprite",
"webgl_read_float_buffer",
"webgl_refraction",
"webgl_rtt", | true |
Other | mrdoob | three.js | c6639997ecd356648294eac619e917c315af97a1.json | add sprite raycast demo | examples/webgl_raycast_sprite.html | @@ -0,0 +1,177 @@
+
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <title>three.js webgl - raycast - sprite</title>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
+ <style>
+ body {
+ margin: 0px;
+ background-color: #fff;
+ overflow: hidden;
+ }
+
+ #info{
+ position: absolute;
+ z-index: 1;
+ width: 100%;
+ text-align: center;
+ }
+ </style>
+ </head>
+<body>
+ <div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - webgl raycast sprite<br></div>
+ <script src="../build/three.js"></script>
+ <script src="./js/controls/OrbitControls.js"></script>
+ <script>
+ var renderer;
+ var scene;
+ var spriteGroup;
+ var camera;
+ var controls;
+
+ init();
+
+ function init() {
+
+ initRender();
+ initScene();
+ initCamera();
+ addSprite();
+
+ render();
+ window.addEventListener( "mousemove", onDocumentMouseMove, false );
+
+ }
+
+ function render() {
+
+ renderer.render( scene, camera );
+ requestAnimationFrame( render );
+
+ }
+
+ function initRender() {
+
+ renderer = new THREE.WebGLRenderer( {
+ antialias: true
+ } );
+ renderer.setSize( window.innerWidth, window.innerHeight );
+ document.body.appendChild( renderer.domElement );
+ renderer.setClearColor( 0xFFFFFF, 1.0 );
+
+ }
+
+ function initScene() {
+
+ scene = new THREE.Scene();
+ spriteGroup = new THREE.Object3D();
+ scene.add( spriteGroup );
+
+ }
+
+ function initCamera() {
+
+ camera = new THREE.PerspectiveCamera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
+ camera.position.y = 15;
+ camera.position.z = 15;
+ camera.position.x = 15;
+ camera.lookAt( {
+ x: 0,
+ y: 0,
+ z: 0
+ } );
+
+ controls = new THREE.OrbitControls( camera, renderer.domElement );
+ controls.target = new THREE.Vector3( 0, 0, 0 );
+ controls.enableRotate = true;
+
+ }
+
+ function addSprite() {
+
+ var sprite;
+
+ sprite = makeSprite( '#69f', spriteGroup );
+ sprite.position.set( 6, 5, 5 );
+ sprite.scale.set( 2, 5, 1 );
+
+ sprite = makeSprite( '#69f', spriteGroup );
+ sprite.position.set( 8, - 2, 2 );
+ sprite.center.set( 0.5, 0 );
+ sprite.scale.set( 1, - 5, 1 );
+ sprite.material.rotation = Math.PI / 3 * 4;
+
+ var g = new THREE.Object3D();
+ spriteGroup.add( g );
+ g.scale.set( 1, 2, 1 );
+ g.position.set( - 5, 0, 0 );
+ g.rotation.set( Math.PI / 2, 0, 0 );
+
+ sprite = makeSprite( '#69f', g );
+ sprite.position.set( 0, 2, 5 );
+ sprite.scale.set( 10, 2, 3 );
+ sprite.center.set( - 0.1, 0 );
+ sprite.material.rotation = Math.PI / 3;
+
+ }
+
+ function makeSprite( color, parent ) {
+
+ var sprite = new THREE.Sprite( new THREE.SpriteMaterial( {
+ color: color
+ } ) );
+ parent.add( sprite );
+ return sprite;
+
+ }
+
+ var selectedObject = null;
+
+ function onDocumentMouseMove( event ) {
+
+ event.preventDefault();
+ if ( selectedObject ) {
+
+ selectedObject.material.color.set( '#69f' );
+ selectedObject = null;
+
+ }
+
+ var intersects = getIntersects( event.layerX, event.layerY );
+ if ( intersects.length > 0 ) {
+
+ var res = intersects.filter( function ( res ) {
+
+ return res && res.object;
+
+ } )[ 0 ];
+
+ if ( res && res.object ) {
+
+ selectedObject = res.object;
+ selectedObject.material.color.set( '#f00' );
+
+ }
+
+ }
+
+ }
+
+ var raycaster = new THREE.Raycaster();
+ var mouseVector = new THREE.Vector3();
+
+ function getIntersects( x, y ) {
+
+ mouseVector.set(
+ ( x / window.innerWidth ) * 2 - 1, - ( y / window.innerHeight ) * 2 + 1,
+ 0.5 );
+ raycaster.setFromCamera( mouseVector, camera );
+ var intersects = raycaster.intersectObjects( [ spriteGroup ], true );
+ return intersects;
+
+ }
+ </script>
+</body>
+</html>
\ No newline at end of file | true |
Other | mrdoob | three.js | 0cbee093ae2f969646d7b0cc7187d30bc7defae4.json | Keep the cursor as pointer after dragging | examples/js/controls/DragControls.js | @@ -154,7 +154,7 @@ THREE.DragControls = function ( _objects, _camera, _domElement ) {
}
- _domElement.style.cursor = 'auto';
+ _domElement.style.cursor = _hovered ? 'pointer' : 'auto';
}
| false |
Other | mrdoob | three.js | 3a5bcfcef0528b46547a0b4fb6388bfb07da9470.json | Add the onDone callback | examples/js/exporters/ColladaExporter.js | @@ -17,7 +17,7 @@ THREE.ColladaExporter.prototype = {
constructor: THREE.ColladaExporter,
- parse: function ( object, options = {} ) {
+ parse: function ( object, onDone, options = {} ) {
options = Object.assign( {
version: '1.4.1',
@@ -549,7 +549,7 @@ THREE.ColladaExporter.prototype = {
var libraryVisualScenes = processObject( object );
var specLink = version === '1.4.1' ? 'http://www.collada.org/2005/11/COLLADASchema' : 'https://www.khronos.org/collada/';
- var res =
+ var dae =
'<?xml version="1.0" encoding="UTF-8" standalone="no" ?>' +
`<COLLADA xmlns="${ specLink }" version="${ version }">` +
'<asset>' +
@@ -559,29 +559,38 @@ THREE.ColladaExporter.prototype = {
( options.author !== null ? `<author>${ options.author }</author>` : '' ) +
'</contributor>' +
`<created>${ ( new Date() ).toISOString() }</created>` +
+ `<modified>${ ( new Date() ).toISOString() }</modified>` +
'<up_axis>Y_UP</up_axis>'
) +
'</asset>';
- res += `<library_images>${ libraryImages.join( '' ) }</library_images>`;
+ dae += `<library_images>${ libraryImages.join( '' ) }</library_images>`;
- res += `<library_effects>${ libraryEffects.join( '' ) }</library_effects>`;
+ dae += `<library_effects>${ libraryEffects.join( '' ) }</library_effects>`;
- res += `<library_materials>${ libraryMaterials.join( '' ) }</library_materials>`;
+ dae += `<library_materials>${ libraryMaterials.join( '' ) }</library_materials>`;
- res += `<library_geometries>${ libraryGeometries.join( '' ) }</library_geometries>`;
+ dae += `<library_geometries>${ libraryGeometries.join( '' ) }</library_geometries>`;
- res += `<library_visual_scenes><visual_scene id="Scene" name="scene">${ libraryVisualScenes }</visual_scene></library_visual_scenes>`;
+ dae += `<library_visual_scenes><visual_scene id="Scene" name="scene">${ libraryVisualScenes }</visual_scene></library_visual_scenes>`;
- res += '<scene><instance_visual_scene url="#Scene"/></scene>';
+ dae += '<scene><instance_visual_scene url="#Scene"/></scene>';
- res += '</COLLADA>';
+ dae += '</COLLADA>';
- return {
- data: format( res ),
+ var res = {
+ data: format( dae ),
textures
};
+ if ( typeof onDone === 'function' ) {
+
+ requestAnimationFrame( () => onDone( res ) );
+
+ }
+
+ return res;
+
}
}; | false |
Other | mrdoob | three.js | 7095292fdefe6a92ea14867619d73ca0c48222cb.json | Use THREE.Matrix3 instead of native SVG matrices. | examples/js/loaders/SVGLoader.js | @@ -1,6 +1,7 @@
/**
* @author mrdoob / http://mrdoob.com/
* @author zz85 / http://joshuakoo.com/
+ * @author yomboprime / https://yombo.org
*/
THREE.SVGLoader = function ( manager ) {
@@ -103,7 +104,7 @@ THREE.SVGLoader.prototype = {
if ( transform ) {
- copyTransform( transformStack.pop(), currentTransform );
+ currentTransform.copy( transformStack.pop() );
}
@@ -672,20 +673,15 @@ THREE.SVGLoader.prototype = {
style = Object.assign( {}, style ); // clone style
if ( node.hasAttribute( 'fill' ) ) style.fill = node.getAttribute( 'fill' );
- if ( node.style.fill !== '' && node.style.fill !== 'none' ) style.fill = node.style.fill;
-
- if ( ! isVisible( style ) ) {
- if ( node.hasAttribute( 'stroke' ) ) style.fill = node.getAttribute( 'stroke' );
- if ( node.style.stroke !== '' && node.style.stroke !== 'none' ) style.fill = node.style.stroke;
- }
+ if ( node.style.fill !== '' ) style.fill = node.style.fill;
return style;
}
function isVisible( style ) {
- return ( style.fill !== 'none' && style.fill !== 'transparent' ) || ( style.stroke !== 'none' && style.stroke !== 'transparent' );
+ return style.fill !== 'none' && style.fill !== 'transparent';
}
@@ -740,11 +736,10 @@ THREE.SVGLoader.prototype = {
if ( transform ) {
if ( transformStack.length > 0 ) {
- multiplyTransforms( transform, transformStack[ transformStack.length - 1 ], tempTransform );
- copyTransform( tempTransform, transform );
+ transform.premultiply( transformStack[ transformStack.length - 1 ] );
}
- copyTransform( transform, currentTransform );
+ currentTransform.copy( transform );
transformStack.push( transform );
}
@@ -772,17 +767,17 @@ THREE.SVGLoader.prototype = {
if ( array.length >= 1 ) {
- transform = createIdTransform();
+ transform = new THREE.Matrix3();
// Translation X
- transform[ 4 ] = array[ 0 ];
+ transform.elements[ 6 ] = array[ 0 ];
}
if ( array.length >= 2 ) {
// Translation Y
- transform[ 5 ] = array[ 1 ];
+ transform.elements[ 7 ] = array[ 1 ];
}
@@ -791,15 +786,15 @@ THREE.SVGLoader.prototype = {
case "rotate":
if ( array.length >= 1 ) {
-
+
var angle = 0;
var cx = 0;
var cy = 0;
- transform = createIdTransform();
+ transform = new THREE.Matrix3();
// Angle
- angle = array[ 0 ] * Math.PI / 180;
+ angle = - array[ 0 ] * Math.PI / 180;
if ( array.length >= 3 ) {
@@ -810,19 +805,11 @@ THREE.SVGLoader.prototype = {
}
// Rotate around center (cx, cy)
-
- var translation = createIdTransform();
- translation[ 4 ] = -cx;
- translation[ 5 ] = -cy;
-
- var rotation = createRotationTransform( angle );
-
- var translRot = createIdTransform();
- multiplyTransforms( translation, rotation, translRot );
-
- translation[ 4 ] = cx;
- translation[ 5 ] = cy;
- multiplyTransforms( translRot, translation, transform );
+ var translation = new THREE.Matrix3().translate( -cx, -cy );
+ var rotation = new THREE.Matrix3().rotate( angle );
+ var translRot = new THREE.Matrix3().multiplyMatrices( rotation, translation );
+ translation.identity().translate( cx, cy );
+ transform.multiplyMatrices( translation, translRot );
}
@@ -832,7 +819,7 @@ THREE.SVGLoader.prototype = {
if ( array.length >= 1 ) {
- transform = createIdTransform();
+ transform = new THREE.Matrix3();
var scaleX = array[ 0 ];
var scaleY = scaleX;
@@ -841,8 +828,8 @@ THREE.SVGLoader.prototype = {
scaleY = array[ 1 ];
}
- transform[ 0 ] = scaleX;
- transform[ 3 ] = scaleY;
+ transform.elements[ 0 ] = scaleX;
+ transform.elements[ 4 ] = scaleY;
}
@@ -852,9 +839,9 @@ THREE.SVGLoader.prototype = {
if ( array.length === 1 ) {
- transform = createIdTransform();
+ transform = new THREE.Matrix3();
- transform[ 2 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
+ transform.elements[ 3 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
}
@@ -864,9 +851,9 @@ THREE.SVGLoader.prototype = {
if ( array.length === 1 ) {
- transform = createIdTransform();
+ transform = new THREE.Matrix3();
- transform[ 1 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
+ transform.elements[ 1 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
}
@@ -876,7 +863,19 @@ THREE.SVGLoader.prototype = {
if ( array.length === 6 ) {
- transform = array;
+ transform = new THREE.Matrix3();
+
+ var e = transform.elements;
+
+ e[ 0 ] = array[ 0 ];
+ e[ 1 ] = array[ 1 ];
+ e[ 2 ] = 0;
+ e[ 3 ] = array[ 2 ];
+ e[ 4 ] = array[ 3 ];
+ e[ 5 ] = 0;
+ e[ 6 ] = array[ 4 ];
+ e[ 7 ] = array[ 5 ];
+ e[ 8 ] = 1;
}
@@ -891,17 +890,19 @@ THREE.SVGLoader.prototype = {
function transformPath( path, m ) {
- var isRotated = isTransformRotated( m );
-
- function transfVec2( v ) {
+ function transfVec2( v2 ) {
- var x = v.x * m[ 0 ] + v.y * m[ 2 ] + m[ 4 ];
- var y = v.x * m[ 1 ] + v.y * m[ 3 ] + m[ 5 ];
+ tempV3.set( v2.x, v2.y, 1 ).applyMatrix3( m );
- v.set( x, y );
+ v2.set( tempV3.x, tempV3.y );
}
+ var isRotated = isTransformRotated( m );
+
+ var tempV2 = new THREE.Vector2();
+ var tempV3 = new THREE.Vector3();
+
var subPaths = path.subPaths;
for ( var i = 0, n = subPaths.length; i < n; i++ ) {
@@ -940,6 +941,11 @@ THREE.SVGLoader.prototype = {
console.warn( "SVGLoader: Elliptic arc or ellipse rotation or skewing is not implemented." );
}
+ tempV2.set( curve.aX, curve.aY );
+ transfVec2( tempV2 );
+ curve.aX = tempV2.x;
+ curve.aY = tempV2.y;
+
curve.xRadius *= getTransformScaleX( m );
curve.yRadius *= getTransformScaleY( m );
@@ -951,73 +957,18 @@ THREE.SVGLoader.prototype = {
}
- function createIdTransform( m ) {
-
- // 2 x 3 matrix:
- // 1 0
- // 0 1
- // tx ty
-
- if ( ! m ) {
- m = [];
- }
-
- m[ 0 ] = 1;
- m[ 1 ] = 0;
- m[ 2 ] = 0;
- m[ 3 ] = 1;
- m[ 4 ] = 0;
- m[ 5 ] = 0;
-
- return m;
-
- }
-
- function copyTransform( orig, dest ) {
-
- for ( var i = 0; i < 6; i++ ) {
- dest[ i ] = orig[ i ]
- }
-
- }
-
- function multiplyTransforms( a, b, r ) {
-
- r[ 0 ] = a[ 0 ] * b[ 0 ] + a[ 1 ] * b[ 2 ];
- r[ 1 ] = a[ 0 ] * b[ 1 ] + a[ 1 ] * b[ 3 ];
- r[ 2 ] = a[ 2 ] * b[ 0 ] + a[ 3 ] * b[ 2 ];
- r[ 3 ] = a[ 2 ] * b[ 1 ] + a[ 3 ] * b[ 3 ];
- r[ 4 ] = a[ 4 ] * b[ 0 ] + a[ 5 ] * b[ 2 ] + b[ 4 ];
- r[ 5 ] = a[ 4 ] * b[ 1 ] + a[ 5 ] * b[ 3 ] + b[ 5 ];
-
- }
-
function isTransformRotated( m ) {
- return m[ 1 ] !== 0 || m[ 2 ] !== 0;
+ return m.elements[ 1 ] !== 0 || m.elements[ 3 ] !== 0;
}
function getTransformScaleX( m ) {
- return Math.sqrt( m[ 0 ] * m[ 0 ] + m[ 1 ] * m[ 1 ] )
+ var te = m.elements;
+ return Math.sqrt( te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] )
}
function getTransformScaleY( m ) {
- return Math.sqrt( m[ 2 ] * m[ 2 ] + m[ 3 ] * m[ 3 ] )
- }
-
- function createRotationTransform( angle ) {
-
- var rotation = createIdTransform();
-
- var c = Math.cos( angle );
- var s = Math.sin( angle );
-
- rotation[ 0 ] = c;
- rotation[ 1 ] = s;
- rotation[ 2 ] = - s;
- rotation[ 3 ] = c;
-
- return rotation;
-
+ var te = m.elements;
+ return Math.sqrt( te[ 3 ] * te[ 3 ] + te[ 4 ] * te[ 4 ] )
}
//
@@ -1028,9 +979,7 @@ THREE.SVGLoader.prototype = {
var transformStack = [];
- var currentTransform = createIdTransform();
-
- var tempTransform = createIdTransform();
+ var currentTransform = new THREE.Matrix3();
console.time( 'THREE.SVGLoader: DOMParser' );
| false |
Other | mrdoob | three.js | 2641cd08cea2f1ed372566975c9f1380996188c8.json | fix copy and serialize | examples/js/nodes/postprocessing/NodePass.js | @@ -47,7 +47,7 @@ NodePass.prototype.render = function () {
NodePass.prototype.copy = function ( source ) {
- this.material = source.material;
+ this.input = source.input;
};
@@ -78,7 +78,7 @@ NodePass.prototype.toJSON = function ( meta ) {
if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
- data.material = this.material.toJSON( meta ).uuid;
+ data.input = this.input.toJSON( meta ).uuid;
}
| true |
Other | mrdoob | three.js | 2641cd08cea2f1ed372566975c9f1380996188c8.json | fix copy and serialize | examples/js/nodes/postprocessing/NodePostProcessing.js | @@ -82,7 +82,7 @@ NodePostProcessing.prototype = {
copy: function ( source ) {
- this.material = source.material;
+ this.output = source.output;
},
@@ -113,7 +113,7 @@ NodePostProcessing.prototype = {
if ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;
- data.material = this.material.toJSON( meta ).uuid;
+ data.output = this.output.toJSON( meta ).uuid;
}
| true |
Other | mrdoob | three.js | 18317890f5cef98f0c7be068d2e0fd064f93de01.json | Improve collada "duplicate node warning". | examples/js/loaders/ColladaLoader.js | @@ -3183,10 +3183,14 @@ THREE.ColladaLoader.prototype = {
}
- if (hasNode(data.id)) {
- console.warn("Duplicate id ", data.id, "ignoring")
+ if ( hasNode( data.id ) ) {
+
+ console.warn( 'THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.', data.id );
+
} else {
+
library.nodes[ data.id ] = data;
+
}
return data; | false |
Other | mrdoob | three.js | 73bb970ee30bd80745d09db2fe4775a420ed374f.json | Add a warning and ignore duplicate node IDs.
Addresses the "too much recursion" error in issue #14453 | examples/js/loaders/ColladaLoader.js | @@ -3183,7 +3183,11 @@ THREE.ColladaLoader.prototype = {
}
- library.nodes[ data.id ] = data;
+ if (hasNode(data.id)) {
+ console.warn("Duplicate id ", data.id, "ignoring")
+ } else {
+ library.nodes[ data.id ] = data;
+ }
return data;
| false |
Other | mrdoob | three.js | 63d7b66eef27de7e1c1002090dbeeb895e9f05f4.json | Fix syntax error from by #13172 merge. | examples/js/loaders/ColladaLoader.js | @@ -3519,7 +3519,7 @@ THREE.ColladaLoader.prototype = {
}
- var fallbackMaterial = new THREE.MeshBasicMaterial( { color: 0xff00ff ) };
+ var fallbackMaterial = new THREE.MeshBasicMaterial( { color: 0xff00ff } );
function resolveMaterialBinding( keys, instanceMaterials ) {
| false |
Other | mrdoob | three.js | 608a543cd66df6518a4c3bc353d59a91e42216f3.json | fix gltf KHR_lights_punctual no color bug | examples/js/loaders/GLTFLoader.js | @@ -282,7 +282,11 @@ THREE.GLTFLoader = ( function () {
var light = lights[ lightId ];
var lightNode;
- var color = new THREE.Color().fromArray( light.color );
+ // the color default value is [1, 1, 1]
+ var color = new THREE.Color(1, 1, 1);
+ if ( light.color !== undefined ) {
+ color.fromArray( light.color )
+ }
switch ( light.type ) {
| false |
Other | mrdoob | three.js | 8578b58bd820f4194e15c5de3245585e3852883e.json | Add tags to adjust whitespace issues | docs/api/lights/DirectionalLight.html | @@ -52,10 +52,10 @@ <h2>Example</h2>
</p>
<code>
-// White directional light at half intensity shining from the top.
-var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
-scene.add( directionalLight );
- </code>
+ // White directional light at half intensity shining from the top.
+ var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 );
+ scene.add( directionalLight );
+ </code>
<h2>Constructor</h2>
@@ -104,26 +104,28 @@ <h3>[property:Object3D target]</h3>
*Note*: For the target's position to be changed to anything other than the default,
it must be added to the [page:Scene scene] using
- <code>
- scene.add( light.target );
- </code>
-
+ </p>
+ <code>
+ scene.add( light.target );
+ </code>
+ <p>
This is so that the target's [page:Object3D.matrixWorld matrixWorld] gets automatically
updated each frame.<br /><br />
It is also possible to set the target to be another object in the scene (anything with a
[page:Object3D.position position] property), like so:
- <code>
- var targetObject = new THREE.Object3D();
- scene.add(targetObject);
+ </p>
+ <code>
+ var targetObject = new THREE.Object3D();
+ scene.add(targetObject);
- light.target = targetObject;
- </code>
+ light.target = targetObject;
+ </code>
+ <p>
The directionalLight will now track the target object.
</p>
-
<h2>Methods</h2>
See the base [page:Light Light] class for common methods. | false |
Other | mrdoob | three.js | 96d5134090427f72004627e96c4a96cc96f99445.json | allow parsing of empty geometry nodes | examples/js/loaders/FBXLoader.js | @@ -747,8 +747,8 @@
// Generate a THREE.BufferGeometry from a node in FBXTree.Objects.Geometry
function genGeometry( FBXTree, relationships, geometryNode, skeleton, preTransform ) {
- var vertexPositions = geometryNode.Vertices.a;
- var vertexIndices = geometryNode.PolygonVertexIndex.a;
+ var vertexPositions = ( geometryNode.Vertices !== undefined ) ? geometryNode.Vertices.a : [];
+ var vertexIndices = ( geometryNode.PolygonVertexIndex !== undefined ) ? geometryNode.PolygonVertexIndex.a : [];
// create arrays to hold the final data used to build the buffergeometry
var vertexBuffer = []; | false |
Other | mrdoob | three.js | e7f47527b6e4a013eac3befa541fd1c31b76ecf6.json | Remove unnecessary ExplodeModifier | examples/webgl_modifier_tessellation.html | @@ -36,7 +36,6 @@
<script src="js/controls/TrackballControls.js"></script>
- <script src="js/modifiers/ExplodeModifier.js"></script>
<script src="js/modifiers/TessellateModifier.js"></script>
<script src="js/Detector.js"></script>
@@ -140,15 +139,12 @@
}
- var explodeModifier = new THREE.ExplodeModifier();
- explodeModifier.modify( geometry );
-
- var numFaces = geometry.faces.length;
-
//
geometry = new THREE.BufferGeometry().fromGeometry( geometry );
+ var numFaces = geometry.attributes.position.count / 3
+
var colors = new Float32Array( numFaces * 3 * 3 );
var displacement = new Float32Array( numFaces * 3 * 3 );
| false |
Other | mrdoob | three.js | 03f74c4dca672a6d413138f70b4a971997379edf.json | Fix missing name copy in BufferAttribute.copy | src/core/BufferAttribute.js | @@ -68,6 +68,7 @@ Object.assign( BufferAttribute.prototype, {
copy: function ( source ) {
+ this.name = source.name;
this.array = new source.array.constructor( source.array );
this.itemSize = source.itemSize;
this.count = source.count; | false |
Other | mrdoob | three.js | 53838a297a104e02faf38aa252ce3240e3122357.json | Add support for chaining | examples/js/loaders/MTLLoader.js | @@ -47,6 +47,7 @@ THREE.MTLLoader.prototype = {
*
* @see setTexturePath
* @param {String} path
+ * @return {THREE.MTLLoader}
*
* @example
* mtlLoader.setPath( 'assets/obj/' );
@@ -55,6 +56,7 @@ THREE.MTLLoader.prototype = {
setPath: function ( path ) {
this.path = path;
+ return this;
},
@@ -65,6 +67,7 @@ THREE.MTLLoader.prototype = {
*
* @see setPath
* @param {String} path
+ * @return {THREE.MTLLoader}
*
* @example
* mtlLoader.setPath( 'assets/obj/' );
@@ -74,26 +77,29 @@ THREE.MTLLoader.prototype = {
setTexturePath: function ( path ) {
this.texturePath = path;
+ return this;
},
setBaseUrl: function ( path ) {
console.warn( 'THREE.MTLLoader: .setBaseUrl() is deprecated. Use .setTexturePath( path ) for texture path or .setPath( path ) for general base path instead.' );
- this.setTexturePath( path );
+ return this.setTexturePath( path );
},
setCrossOrigin: function ( value ) {
this.crossOrigin = value;
+ return this;
},
setMaterialOptions: function ( value ) {
this.materialOptions = value;
+ return this;
},
| true |
Other | mrdoob | three.js | 53838a297a104e02faf38aa252ce3240e3122357.json | Add support for chaining | examples/js/loaders/OBJLoader.js | @@ -392,6 +392,8 @@ THREE.OBJLoader = ( function () {
this.path = value;
+ return this;
+
},
setMaterials: function ( materials ) { | true |
Other | mrdoob | three.js | 53838a297a104e02faf38aa252ce3240e3122357.json | Add support for chaining | examples/webgl_loader_obj_mtl.html | @@ -77,33 +77,37 @@
// model
var onProgress = function ( xhr ) {
+
if ( xhr.lengthComputable ) {
+
var percentComplete = xhr.loaded / xhr.total * 100;
- console.log( Math.round(percentComplete, 2) + '% downloaded' );
+ console.log( Math.round( percentComplete, 2 ) + '% downloaded' );
+
}
+
};
var onError = function ( xhr ) { };
THREE.Loader.Handlers.add( /\.dds$/i, new THREE.DDSLoader() );
- var mtlLoader = new THREE.MTLLoader();
- mtlLoader.setPath( 'models/obj/male02/' );
- mtlLoader.load( 'male02_dds.mtl', function( materials ) {
+ new THREE.MTLLoader()
+ .setPath( 'models/obj/male02/' )
+ .load( 'male02_dds.mtl', function ( materials ) {
- materials.preload();
+ materials.preload();
- var objLoader = new THREE.OBJLoader();
- objLoader.setMaterials( materials );
- objLoader.setPath( 'models/obj/male02/' );
- objLoader.load( 'male02.obj', function ( object ) {
+ new THREE.OBJLoader()
+ .setMaterials( materials )
+ .setPath( 'models/obj/male02/' )
+ .load( 'male02.obj', function ( object ) {
- object.position.y = - 95;
- scene.add( object );
+ object.position.y = - 95;
+ scene.add( object );
- }, onProgress, onError );
+ }, onProgress, onError );
- });
+ } );
//
| true |
Other | mrdoob | three.js | 54551f17730eaf164416fc6019211194085bd628.json | Add missing semicolon | examples/js/BufferGeometryUtils.js | @@ -250,7 +250,7 @@ THREE.BufferGeometryUtils = {
if ( isIndexed ) {
- count = geometry.index.count
+ count = geometry.index.count;
} else if ( geometry.attributes.position !== undefined ) {
| false |
Other | mrdoob | three.js | 39ddddb2a5b9e9d115ad39cdf72eecf90a5cb5ed.json | update the doc for CSS2D renderer as well | docs/examples/renderers/CSS2DRenderer.html | @@ -12,7 +12,6 @@ <h1>[name]</h1>
<div class="desc">[name] is a simplified version of [page:CSS3DRenderer]. The only transformation that is supported is translation.<br />
The renderer is very useful if you want to combine HTML based labels with 3D objects. Here too, the respective DOM elements are wrapped into an instance of *CSS2DObject* and added to the scene graph.<br />
- Unlike [page:CSS3DRenderer], orthographic cameras are supported.
</div>
<script> | false |
Other | mrdoob | three.js | 063515b2ed2f6b1cd71b122d25b12a622deb0e59.json | use camera.is*** for its type detection | examples/files.js | @@ -348,11 +348,11 @@ var files = {
],
"css3d": [
"css3d_molecules",
+ "css3d_orthographic",
"css3d_panorama",
"css3d_panorama_deviceorientation",
"css3d_periodictable",
"css3d_sandbox",
- "css3d_orthographic",
"css3d_sprites",
"css3d_youtube"
], | true |
Other | mrdoob | three.js | 063515b2ed2f6b1cd71b122d25b12a622deb0e59.json | use camera.is*** for its type detection | examples/js/renderers/CSS3DRenderer.js | @@ -262,7 +262,7 @@ THREE.CSS3DRenderer = function () {
if ( cache.camera.fov !== fov ) {
- if ( camera.type === 'PerspectiveCamera' ) {
+ if ( camera.isPerspectiveCamera ) {
domElement.style.WebkitPerspective = fov + 'px';
domElement.style.perspective = fov + 'px';
@@ -277,7 +277,7 @@ THREE.CSS3DRenderer = function () {
if ( camera.parent === null ) camera.updateMatrixWorld();
- var cameraCSSMatrix = camera.type === 'OrthographicCamera' ?
+ var cameraCSSMatrix = camera.isOrthographicCamera ?
'scale(' + fov + ')' + getCameraCSSMatrix( camera.matrixWorldInverse ) :
'translateZ(' + fov + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse );
| true |
Other | mrdoob | three.js | 131212ae616a5664870d2e7a8a787683e1cbf197.json | remove params from createTexture | examples/js/GPUComputationRenderer.js | @@ -306,13 +306,10 @@ function GPUComputationRenderer( sizeX, sizeY, renderer ) {
};
- this.createTexture = function( sizeXTexture, sizeYTexture ) {
+ this.createTexture = function() {
- sizeXTexture = sizeXTexture || sizeX;
- sizeYTexture = sizeYTexture || sizeY;
-
- var a = new Float32Array( sizeXTexture * sizeYTexture * 4 );
- var texture = new THREE.DataTexture( a, sizeXTexture, sizeYTexture, THREE.RGBAFormat, THREE.FloatType );
+ var a = new Float32Array( sizeX * sizeY * 4 );
+ var texture = new THREE.DataTexture( a, sizeX, sizeY, THREE.RGBAFormat, THREE.FloatType );
texture.needsUpdate = true;
return texture; | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.