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
2ab6388f42c65658cd622d8f6a85a526f88f6a83.json
simplify formula suggested by WestLangley
examples/js/renderers/CSS3DRenderer.js
@@ -277,14 +277,9 @@ THREE.CSS3DRenderer = function () { if ( camera.parent === null ) camera.updateMatrixWorld(); - var cameraCSSMatrix = 'translateZ(' + fov + 'px)' + - getCameraCSSMatrix( camera.matrixWorldInverse ); - - if ( camera.type === 'OrthographicCamera' ) { - - cameraCSSMatrix = 'scale(' + fov + ')' + cameraCSSMatrix; - - } + var cameraCSSMatrix = camera.type === 'OrthographicCamera' ? + 'scale(' + fov + ')' + getCameraCSSMatrix( camera.matrixWorldInverse ) : + 'translateZ(' + fov + 'px)' + getCameraCSSMatrix( camera.matrixWorldInverse ); var style = cameraCSSMatrix + 'translate(' + _widthHalf + 'px,' + _heightHalf + 'px)';
false
Other
mrdoob
three.js
8a5ca09d56ea03d43ad0c60ee28204ad93206497.json
Add example to model loading page.
docs/manual/en/introduction/Loading-3D-models.html
@@ -2,127 +2,174 @@ <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" /> + <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> - <br /> - - <p> - 3D models are available in hundreds of file formats, each with different - purposes, assorted features, and varying complexity. Although - <a href="https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders" target="_blank" rel="noopener"> - three.js provides many loaders</a>, choosing the right format and - workflow will save time and frustration later on. Some formats are - difficult to work with, inefficient for realtime experiences, or simply not - fully supported at this time. - </p> - - <p> - This guide provides a workflow recommended for most users, and suggestions - for what to try if things don't go as expected. - </p> - - <h2>Before we start</h2> - - <p> - If you're new to running a local server, begin with - [link:#manual/introduction/How-to-run-things-locally how to run things locally] - first. Many common errors viewing 3D models can be avoided by hosting files - correctly. - </p> - - <h2>Recommended workflow</h2> - - <p> - Where possible, we recommend using glTF (GL Transmission Format). Both - <small>.GLB</small> and <small>.GLTF</small> versions of the format are - well supported. Because glTF is focused on runtime asset delivery, it is - compact to transmit and fast to load. Features include meshes, materials, - textures, skins, skeletons, morph targets, animations, lights, and - cameras. - </p> - - <p> - Public-domain glTF files are available on sites like - <a href="https://sketchfab.com/models?features=downloadable&sort_by=-likeCount&type=models" target="_blank" rel="noopener"> - Sketchfab</a>, or various tools include glTF export: - </p> - - <ul> - <li><a href="https://github.com/KhronosGroup/glTF-Blender-Exporter" target="_blank" rel="noopener">glTF-Blender-Exporter</a> by the Khronos Group</li> - <li><a href="https://github.com/KhronosGroup/COLLADA2GLTF" target="_blank" rel="noopener">COLLADA2GLTF</a> by the Khronos Group</li> - <li><a href="https://github.com/facebookincubator/FBX2glTF" target="_blank" rel="noopener">FBX2GLTF</a> by Facebook</li> - <li><a href="https://github.com/AnalyticalGraphicsInc/obj2gltf" target="_blank" rel="noopener">OBJ2GLTF</a> by Analytical Graphics Inc</li> - <li><a href="https://www.allegorithmic.com/products/substance-painter" target="_blank" rel="noopener">Substance Painter</a> by Allegorithmic</li> - <li><a href="https://www.foundry.com/products/modo" target="_blank" rel="noopener">Modo</a> by Foundry</li> - <li><a href="https://www.marmoset.co/toolbag/" target="_blank" rel="noopener">Toolbag</a> by Marmoset</li> - <li>&hellip;and <a href="https://github.com/khronosgroup/gltf#gltf-tools" target="_blank" rel="noopener">many more</a></li> - </ul> - - <p> - If your preferred tools do not support glTF, consider requesting glTF - export from the authors, or posting on - <a href="https://github.com/KhronosGroup/glTF/issues/1051" target="_blank" rel="noopener">the glTF roadmap thread</a>. - </p> - - <p> - When glTF is not an option, popular formats such as FBX, OBJ, or COLLADA - are also available and regularly maintained. - </p> - - <h2>Troubleshooting</h2> - - <p> - You've spent hours modeling an artisanal masterpiece, you load it into - the webpage, and — oh no! 😭 It's distorted, miscolored, or missing entirely. - Start with these troubleshooting steps: - </p> - - <ol> - <li> - Check the JavaScript console for errors, and make sure you've used an - <em>onError</em> callback when calling <em>.load()</em> to log the result. - </li> - <li> - View the model in another application. For glTF, drag-and-drop viewers - are available for - <a href="https://gltf-viewer.donmccurdy.com/" target="_blank" rel="noopener">three.js</a> and - <a href="http://sandbox.babylonjs.com/" target="_blank" rel="noopener">babylon.js</a>. If the model - appears correctly in one or more applications, - <a href="https://github.com/mrdoob/three.js/issues/new" target="_blank" rel="noopener">file a bug against three.js</a>. - If the model cannot be shown in any application, we strongly encourage - filing a bug with the application used to create the model. - </li> - <li> - Try scaling the model up or down by a factor of 1000. Many models are - scaled differently, and large models may not appear if the camera is - inside the model. - </li> - <li> - Look for failed texture requests in the network tab, like - <em>C:\\Path\To\Model\texture.jpg</em>. Use paths relative to your - model instead, such as <em>images/texture.jpg</em> — this may require - editing the model file in a text editor. - </li> - </ol> - - <h2>Asking for help</h2> - - <p> - If you've gone through the troubleshooting process above and your model - still isn't working, the right approach to asking for help will get you to - a solution faster. Post a question on the - <a href="https://discourse.threejs.org/" target="_blank" rel="noopener">three.js forum</a> and, whenever possible, - include your model (or a simpler model with the same problem) in any formats - you have available. Include enough information for someone else to reproduce - the issue quickly — ideally, a live demo. - </p> + <h1>[name]</h1> + <br /> + + <p> + 3D models are available in hundreds of file formats, each with different + purposes, assorted features, and varying complexity. Although + <a href="https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders" target="_blank" rel="noopener"> + three.js provides many loaders</a>, choosing the right format and + workflow will save time and frustration later on. Some formats are + difficult to work with, inefficient for realtime experiences, or simply not + fully supported at this time. + </p> + + <p> + This guide provides a workflow recommended for most users, and suggestions + for what to try if things don't go as expected. + </p> + + <h2>Before we start</h2> + + <p> + If you're new to running a local server, begin with + [link:#manual/introduction/How-to-run-things-locally how to run things locally] + first. Many common errors viewing 3D models can be avoided by hosting files + correctly. + </p> + + <h2>Recommended workflow</h2> + + <p> + Where possible, we recommend using glTF (GL Transmission Format). Both + <small>.GLB</small> and <small>.GLTF</small> versions of the format are + well supported. Because glTF is focused on runtime asset delivery, it is + compact to transmit and fast to load. Features include meshes, materials, + textures, skins, skeletons, morph targets, animations, lights, and + cameras. + </p> + + <p> + Public-domain glTF files are available on sites like + <a href="https://sketchfab.com/models?features=downloadable&sort_by=-likeCount&type=models" target="_blank" rel="noopener"> + Sketchfab</a>, or various tools include glTF export: + </p> + + <ul> + <li><a href="https://github.com/KhronosGroup/glTF-Blender-Exporter" target="_blank" rel="noopener">glTF-Blender-Exporter</a> by the Khronos Group</li> + <li><a href="https://github.com/KhronosGroup/COLLADA2GLTF" target="_blank" rel="noopener">COLLADA2GLTF</a> by the Khronos Group</li> + <li><a href="https://github.com/facebookincubator/FBX2glTF" target="_blank" rel="noopener">FBX2GLTF</a> by Facebook</li> + <li><a href="https://github.com/AnalyticalGraphicsInc/obj2gltf" target="_blank" rel="noopener">OBJ2GLTF</a> by Analytical Graphics Inc</li> + <li><a href="https://www.allegorithmic.com/products/substance-painter" target="_blank" rel="noopener">Substance Painter</a> by Allegorithmic</li> + <li><a href="https://www.foundry.com/products/modo" target="_blank" rel="noopener">Modo</a> by Foundry</li> + <li><a href="https://www.marmoset.co/toolbag/" target="_blank" rel="noopener">Toolbag</a> by Marmoset</li> + <li>&hellip;and <a href="https://github.com/khronosgroup/gltf#gltf-tools" target="_blank" rel="noopener">many more</a></li> + </ul> + + <p> + If your preferred tools do not support glTF, consider requesting glTF + export from the authors, or posting on + <a href="https://github.com/KhronosGroup/glTF/issues/1051" target="_blank" rel="noopener">the glTF roadmap thread</a>. + </p> + + <p> + When glTF is not an option, popular formats such as FBX, OBJ, or COLLADA + are also available and regularly maintained. + </p> + + <h2>Loading</h2> + + <p> + Only a few loaders ([page:ObjectLoader] and [page:JSONLoader]) are included by default with + three.js — others should be added to your page individually. Depending on your + preference and comfort with build tools, choose one of the following: + </p> + + <code> + // global script + &lt;script src="GLTFLoader.js"&gt;&lt;/script&gt; + + // commonjs + var THREE = window.THREE = require('three'); + require('three/examples/js/loaders/GLTFLoader'); + </code> + + <p> + Currently three.js examples are not available as ES modules (import &hellip; from '&hellip;'). + Several workarounds are discussed in + <a href="https://github.com/KhronosGroup/glTF/issues/9562" target="_blank" rel="noopener">#9562</a>. + </p> + + <p> + Once you've imported a loader, you're ready to add a model to your scene. Syntax varies among + different loaders — when using another format, check the examples and documentation for that + loader. For glTF, basic usage would be: + </p> + + <code> + var loader = new THREE.GLTFLoader(); + + loader.load( 'path/to/model.glb', function ( gltf ) { + + scene.add( gltf.scene ); + + }, undefined, function ( error ) { + + console.error( error ); + + } ); + </code> + + <p> + See [page:GLTFLoader GLTFLoader documentation] for further details. + </p> + + <h2>Troubleshooting</h2> + + <p> + You've spent hours modeling an artisanal masterpiece, you load it into + the webpage, and — oh no! 😭 It's distorted, miscolored, or missing entirely. + Start with these troubleshooting steps: + </p> + + <ol> + <li> + Check the JavaScript console for errors, and make sure you've used an + <em>onError</em> callback when calling <em>.load()</em> to log the result. + </li> + <li> + View the model in another application. For glTF, drag-and-drop viewers + are available for + <a href="https://gltf-viewer.donmccurdy.com/" target="_blank" rel="noopener">three.js</a> and + <a href="http://sandbox.babylonjs.com/" target="_blank" rel="noopener">babylon.js</a>. If the model + appears correctly in one or more applications, + <a href="https://github.com/mrdoob/three.js/issues/new" target="_blank" rel="noopener">file a bug against three.js</a>. + If the model cannot be shown in any application, we strongly encourage + filing a bug with the application used to create the model. + </li> + <li> + Try scaling the model up or down by a factor of 1000. Many models are + scaled differently, and large models may not appear if the camera is + inside the model. + </li> + <li> + Look for failed texture requests in the network tab, like + <em>C:\\Path\To\Model\texture.jpg</em>. Use paths relative to your + model instead, such as <em>images/texture.jpg</em> — this may require + editing the model file in a text editor. + </li> + </ol> + + <h2>Asking for help</h2> + + <p> + If you've gone through the troubleshooting process above and your model + still isn't working, the right approach to asking for help will get you to + a solution faster. Post a question on the + <a href="https://discourse.threejs.org/" target="_blank" rel="noopener">three.js forum</a> and, whenever possible, + include your model (or a simpler model with the same problem) in any formats + you have available. Include enough information for someone else to reproduce + the issue quickly — ideally, a live demo. + </p> </body>
true
Other
mrdoob
three.js
8a5ca09d56ea03d43ad0c60ee28204ad93206497.json
Add example to model loading page.
docs/manual/zh/introduction/Loading-3D-models.html
@@ -2,107 +2,111 @@ <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" /> + <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>载入3D模型([name])</h1> - <br /> + <h1>载入3D模型([name])</h1> + <br /> - <p> + <p> 3D模型目前的有成千上万种格式可供选择,但每一种格式都具有不同的目的、用途以及复杂性。 - 虽然<a href="https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders" target="_blank" rel="noopener"> + 虽然<a href="https://github.com/mrdoob/three.js/tree/dev/examples/js/loaders" target="_blank" rel="noopener"> three.js已经提供了多种导入工具</a> 但是选择正确的文件格式以及工作流程将可以节省很多时间,以及避免很多挫折。某些格式难以使用,或者实时体验效率低下,或者目前尚未得到完全支持。 - </p> + </p> - <p> + <p> 对大多数用户,本指南向你推荐了一个工作流程,并向你提供了一些当没有达到预期效果时的建议。 - </p> + </p> - <h2>在开始之前</h2> + <h2>在开始之前</h2> - <p> - 如果你是第一次运行一个本地服务器,可以先阅读[link:#manual/introduction/How-to-run-things-locally how to run things locally]。 - 正确地托管文件,可以避免很多查看3D模型时的常见错误。 - </p> + <p> + 如果你是第一次运行一个本地服务器,可以先阅读[link:#manual/introduction/How-to-run-things-locally how to run things locally]。 + 正确地托管文件,可以避免很多查看3D模型时的常见错误。 + </p> - <h2>推荐的工作流程</h2> + <h2>推荐的工作流程</h2> - <p> - 如果有可能的话,我们推荐使用glTF(gl传输格式)。<small>.GLB</small>和<small>.GLTF</small>是这种格式的这两种不同版本, - 都可以被很好地支持。由于glTF这种格式是专注于在程序运行时呈现三维物体的,所以它的传输效率非常高,且加载速度非常快。 - 功能方面则包括了网格、材质、纹理、皮肤、骨骼、变形目标、动画、灯光和摄像机。 - </p> + <p> + 如果有可能的话,我们推荐使用glTF(gl传输格式)。<small>.GLB</small>和<small>.GLTF</small>是这种格式的这两种不同版本, + 都可以被很好地支持。由于glTF这种格式是专注于在程序运行时呈现三维物体的,所以它的传输效率非常高,且加载速度非常快。 + 功能方面则包括了网格、材质、纹理、皮肤、骨骼、变形目标、动画、灯光和摄像机。 + </p> - <p> - 公共领域的glTF文件可以在网上找到,例如 - <a href="https://sketchfab.com/models?features=downloadable&sort_by=-likeCount&type=models" target="_blank" rel="noopener"> - Sketchfab</a>,或者很多工具包含了glTF的导出功能: - </p> + <p> + 公共领域的glTF文件可以在网上找到,例如 + <a href="https://sketchfab.com/models?features=downloadable&sort_by=-likeCount&type=models" target="_blank" rel="noopener"> + Sketchfab</a>,或者很多工具包含了glTF的导出功能: + </p> - <ul> - <li><a href="https://github.com/KhronosGroup/glTF-Blender-Exporter" target="_blank" rel="noopener">glTF-Blender-Exporter</a> by the Khronos Group</li> - <li><a href="https://github.com/KhronosGroup/COLLADA2GLTF" target="_blank" rel="noopener">COLLADA2GLTF</a> by the Khronos Group</li> - <li><a href="https://github.com/facebookincubator/FBX2glTF" target="_blank" rel="noopener">FBX2GLTF</a> by Facebook</li> - <li><a href="https://github.com/AnalyticalGraphicsInc/obj2gltf" target="_blank" rel="noopener">OBJ2GLTF</a> by Analytical Graphics Inc</li> - <li><a href="https://www.allegorithmic.com/products/substance-painter" target="_blank" rel="noopener">Substance Painter</a> by Allegorithmic</li> - <li><a href="https://www.foundry.com/products/modo" target="_blank" rel="noopener">Modo</a> by Foundry</li> - <li><a href="https://www.marmoset.co/toolbag/" target="_blank" rel="noopener">Toolbag</a> by Marmoset</li> - <li>……<a href="https://github.com/khronosgroup/gltf#gltf-tools" target="_blank" rel="noopener">还有更多</a></li> - </ul> + <ul> + <li><a href="https://github.com/KhronosGroup/glTF-Blender-Exporter" target="_blank" rel="noopener">glTF-Blender-Exporter</a> by the Khronos Group</li> + <li><a href="https://github.com/KhronosGroup/COLLADA2GLTF" target="_blank" rel="noopener">COLLADA2GLTF</a> by the Khronos Group</li> + <li><a href="https://github.com/facebookincubator/FBX2glTF" target="_blank" rel="noopener">FBX2GLTF</a> by Facebook</li> + <li><a href="https://github.com/AnalyticalGraphicsInc/obj2gltf" target="_blank" rel="noopener">OBJ2GLTF</a> by Analytical Graphics Inc</li> + <li><a href="https://www.allegorithmic.com/products/substance-painter" target="_blank" rel="noopener">Substance Painter</a> by Allegorithmic</li> + <li><a href="https://www.foundry.com/products/modo" target="_blank" rel="noopener">Modo</a> by Foundry</li> + <li><a href="https://www.marmoset.co/toolbag/" target="_blank" rel="noopener">Toolbag</a> by Marmoset</li> + <li>……<a href="https://github.com/khronosgroup/gltf#gltf-tools" target="_blank" rel="noopener">还有更多</a></li> + </ul> - <p> - 倘若你所喜欢的工具不支持glTF格式,请考虑向该工具的作者请求glTF导出功能, - 或者在<a href="https://github.com/KhronosGroup/glTF/issues/1051" target="_blank" rel="noopener">the glTF roadmap thread</a>贴出你的想法。 + <p> + 倘若你所喜欢的工具不支持glTF格式,请考虑向该工具的作者请求glTF导出功能, + 或者在<a href="https://github.com/KhronosGroup/glTF/issues/1051" target="_blank" rel="noopener">the glTF roadmap thread</a>贴出你的想法。 - </p> + </p> - <p> - 当glTF不可用的时候,诸如FBX、OBJ或者COLLADA等等其它广受欢迎的格式在Three.js中也是可以使用、并且定期维护的。 - </p> + <p> + 当glTF不可用的时候,诸如FBX、OBJ或者COLLADA等等其它广受欢迎的格式在Three.js中也是可以使用、并且定期维护的。 + </p> - <h2>故障排除</h2> + <h2>Loading</h2> - <p> - 你花了几个小时亲手建了一个堪称杰作的模型,现在你把它给导入到网页中—— - 哦,天呐~😭它导入以后完全失真了、材质贴图丢了、或者说整个模型完全丢失了!<br> - 接下来我们来按照下面的步骤排除故障: - </p> + <p>TODO.</p> - <ol> - <li> + <h2>故障排除</h2> + + <p> + 你花了几个小时亲手建了一个堪称杰作的模型,现在你把它给导入到网页中—— + 哦,天呐~😭它导入以后完全失真了、材质贴图丢了、或者说整个模型完全丢失了!<br> + 接下来我们来按照下面的步骤排除故障: + </p> + + <ol> + <li> 在Javascript的Console中查找错误,并确定当你调用<em>.load()</em>的时候,使用了<em>onError</em>回调函数来输出结果。 - </li> - <li> + </li> + <li> 请在别的应用程序中查看3D模型。对于glTF格式的模型来说,可以直接在下面的应用程序中进行查看: - <a href="https://gltf-viewer.donmccurdy.com/" target="_blank" rel="noopener">three.js</a>和 - <a href="http://sandbox.babylonjs.com/" target="_blank" rel="noopener">babylon.js</a>。 + <a href="https://gltf-viewer.donmccurdy.com/" target="_blank" rel="noopener">three.js</a>和 + <a href="http://sandbox.babylonjs.com/" target="_blank" rel="noopener">babylon.js</a>。 如果该模型能够在一个或者更多应用程序里正确地呈现,请<a href="https://github.com/mrdoob/three.js/issues/new" target="_blank" rel="noopener">点击这里向three.js提交Bug报告</a>。 如果模型不能在任意一个应用程序里显示,我们强烈鼓励你向我们提交Bug报告,并告知我们你的模型是使用哪一款应用程序创建的。 - </li> - <li> + </li> + <li> 尝试将模型放大或缩小到原来的1000倍。许多模型的缩放比例各不相同,倘若摄像机位于相机内,则大型模型将可能不会显示。 - </li> - <li> + </li> + <li> 在网络面板中查找失败的纹理贴图请求,像<em>C:\\Path\To\Model\texture.jpg</em>。使用相对于你的模型的文件路径,例如 <em>images/texture.jpg</em>——这或许需要在文本编辑器中来对模型文件进行修改。 - </li> - </ol> + </li> + </ol> - <h2>请求帮助</h2> + <h2>请求帮助</h2> - <p> + <p> 倘若你已经尝试经历了以上故障排除的过程,但是你的模型仍然无法工作,寻求正确的方法来获得帮助将使您更快地获得解决方案。 您可以将您的问题发布到<a href="https://discourse.threejs.org/" target="_blank" rel="noopener">three.js forum</a>, 同时,尽可能将你的模型(或者一个简单的、具有相同问题的模型)包含在你能够使用的任何格式中,为其他人提供足够的信息,以便快速重现这个问题——最好是一个能够现场演示的Demo。 - </p> + </p> </body>
true
Other
mrdoob
three.js
e4a12e8b61c0af85839a8fb68e7c5720df454f45.json
Add default frustum to OrthographicCamera
src/cameras/OrthographicCamera.js
@@ -15,10 +15,10 @@ function OrthographicCamera( left, right, top, bottom, near, far ) { this.zoom = 1; this.view = null; - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; + this.left = ( left !== undefined ) ? left : -1; + this.right = ( right !== undefined ) ? right : 1; + this.top = ( top !== undefined ) ? ltopeft : 1; + this.bottom = ( bottom !== undefined ) ? bottom : -1; this.near = ( near !== undefined ) ? near : 0.1; this.far = ( far !== undefined ) ? far : 2000;
false
Other
mrdoob
three.js
91cd51830a05824eaafb1377baf80977dcbec8e3.json
Improve endnote docs.
docs/examples/loaders/GLTFLoader.html
@@ -37,10 +37,11 @@ <h2>Extensions</h2> </ul> <p><i> - <sup>*</sup>UV transforms are supported, with several key limitations in comparison to the - glTF specification. A transform is applied to all textures using that UV set on the current - material, and no more than one transform may be used per material. Each use of a texture with - a unique transform will result in an additional GPU texture upload. See + <sup>*</sup>UV transforms are supported, with several key limitations. Transforms applied to + a texture using the first UV slot (all textures except aoMap and lightMap) must share the same + transform, or no transfor at all. The aoMap and lightMap textures cannot be transformed. No + more than one transform may be used per material. Each use of a texture with a unique + transform will result in an additional GPU texture upload. See #[link:https://github.com/mrdoob/three.js/pull/13831 13831] and #[link:https://github.com/mrdoob/three.js/issues/12788 12788]. </i></p>
true
Other
mrdoob
three.js
91cd51830a05824eaafb1377baf80977dcbec8e3.json
Improve endnote docs.
docs/page.css
@@ -130,3 +130,13 @@ span.param { a.param:hover { color: #777; } + +sup, sub { + /* prevent superscript and subscript elements from affecting line-height */ + vertical-align: baseline; + position: relative; + top: -0.4em; +} +sub { + top: 0.4em; +} \ No newline at end of file
true
Other
mrdoob
three.js
b63ec3e8caf7e6ccefb1b4a9c38f61a02b4f2945.json
Add STL exporter in binary format to menu bar
editor/js/Menubar.File.js
@@ -265,7 +265,7 @@ Menubar.File = function ( editor ) { } ); options.add( option ); - // Export STL + // Export STL (ASCII) var option = new UI.Row(); option.setClass( 'option' ); @@ -279,6 +279,20 @@ Menubar.File = function ( editor ) { } ); options.add( option ); + // Export STL (Binary) + + var option = new UI.Row(); + option.setClass( 'option' ); + option.setTextContent( 'Export STL (Binary)' ); + option.onClick( function () { + + var exporter = new THREE.STLExporter(); + + saveString( exporter.parse( editor.scene, { binary: true } ), 'model-binary.stl' ); + + } ); + options.add( option ); + // options.add( new UI.HorizontalRule() );
false
Other
mrdoob
three.js
b8f08250a678b29944ab4a3e7369b4933e34d8b7.json
Add options arg to constructor
docs/api/en/cameras/CubeCamera.html
@@ -43,11 +43,17 @@ <h2>Examples</h2> <h2>Constructor</h2> - <h3>[name]( [param:Number near], [param:Number far], [param:Number cubeResolution] )</h3> + <h3>[name]( [param:Number near], [param:Number far], [param:Number cubeResolution], [param:Object options] )</h3> <p> near -- The near clipping distance. <br /> far -- The far clipping distance <br /> - cubeResolution -- Sets the length of the cube's edges. + cubeResolution -- Sets the length of the cube's edges. <br /> + options - (optional) object that holds texture parameters passed to the auto-generated WebGLRenderTargetCube. + If not specified, the options default to: + <code> + { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter } + </code> + </p> <p> Constructs a CubeCamera that contains 6 [page:PerspectiveCamera PerspectiveCameras] that
true
Other
mrdoob
three.js
b8f08250a678b29944ab4a3e7369b4933e34d8b7.json
Add options arg to constructor
src/cameras/CubeCamera.js
@@ -11,7 +11,7 @@ import { PerspectiveCamera } from './PerspectiveCamera.js'; * @author alteredq / http://alteredqualia.com/ */ -function CubeCamera( near, far, cubeResolution ) { +function CubeCamera( near, far, cubeResolution, options ) { Object3D.call( this ); @@ -49,7 +49,7 @@ function CubeCamera( near, far, cubeResolution ) { cameraNZ.lookAt( new Vector3( 0, 0, - 1 ) ); this.add( cameraNZ ); - var options = { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter }; + options = options || { format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter }; this.renderTarget = new WebGLRenderTargetCube( cubeResolution, cubeResolution, options ); this.renderTarget.texture.name = "CubeCamera";
true
Other
mrdoob
three.js
30a3f0c185546ca22ba46a65f7d77d8cd4b6ba15.json
Update background color of kmz loader example
examples/webgl_loader_kmz.html
@@ -62,7 +62,7 @@ function init() { scene = new THREE.Scene(); - scene.background = new THREE.Color( 0xaaaaaa ); + scene.background = new THREE.Color( 0x999999 ); var light = new THREE.DirectionalLight( 0xffffff ); light.position.set( 0.5, 1.0, 0.5 ).normalize();
false
Other
mrdoob
three.js
a063cf571ab025a89892019fc3bef009a4b55346.json
Fix inconsistent menu order.
docs/list.js
@@ -176,8 +176,8 @@ var list = { "TorusGeometry": "api/geometries/TorusGeometry", "TorusKnotBufferGeometry": "api/geometries/TorusKnotBufferGeometry", "TorusKnotGeometry": "api/geometries/TorusKnotGeometry", - "TubeGeometry": "api/geometries/TubeGeometry", "TubeBufferGeometry": "api/geometries/TubeBufferGeometry", + "TubeGeometry": "api/geometries/TubeGeometry", "WireframeGeometry": "api/geometries/WireframeGeometry" },
false
Other
mrdoob
three.js
3ccef258935b7b892cf63024a4113481007c6fe0.json
Fix broken link.
docs/api/geometries/TextBufferGeometry.html
@@ -155,6 +155,6 @@ <h2>Available Fonts</h2> <h2>Source</h2> - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/src/TextGeometry.js src/TextGeometry.js] </body> </html>
false
Other
mrdoob
three.js
1b11cef40e2fc436cea4b1d3f43a7400fbb95f8f.json
Fix broken link.
docs/api/geometries/ExtrudeBufferGeometry.html
@@ -140,6 +140,6 @@ <h3>[method:null addShape]([page:Shape shape], [page:Object options])</h3> <h2>Source</h2> - [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js] + [link:https://github.com/mrdoob/three.js/blob/master/src/ExtrudeGeometry.js src/ExtrudeGeometry.js] </body> </html>
false
Other
mrdoob
three.js
0dbdd90362f457964b9b819afee9267aa0a15b1f.json
Fix errors in setting bone transforms
examples/js/loaders/FBXLoader.js
@@ -463,7 +463,6 @@ // Also parse the texture map and return any textures associated with the material function parseParameters( FBXTree, properties, textureMap, ID, connections ) { - var parameters = {}; if ( properties.BumpFactor ) { @@ -644,10 +643,12 @@ ID: child.ID, indices: [], weights: [], + + // the global initial transform of the geometry node this bone is connected to transform: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.Transform.properties.a ), - //currently not used - // transformLink: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.TransformLink.properties.a ), + // the global initial transform of this bone + transformLink: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.TransformLink.properties.a ), }; @@ -1540,7 +1541,7 @@ var node = modelNodes[ nodeID ]; var relationships = connections.get( id ); - var model = buildSkeleton( relationships, skeletons ); + var model = buildSkeleton( relationships, skeletons, id, node.attrName ); if ( ! model ) { @@ -1558,36 +1559,31 @@ case 'NurbsCurve': model = createCurve( relationships, geometryMap ); break; - case 'LimbNode': + case 'LimbNode': // usually associated with a bone, however if one was not created we'll make a Group instead case 'Null': default: model = new THREE.Group(); break; } - } - - if ( model ) { - - setModelTransforms( FBXTree, model, node ); - model.name = THREE.PropertyBinding.sanitizeNodeName( node.attrName ); model.ID = id; - modelMap.set( id, model ); - } + setModelTransforms( FBXTree, model, node ); + modelMap.set( id, model ); + } return modelMap; } - function buildSkeleton( relationships, skeletons ) { + function buildSkeleton( relationships, skeletons, id, name ) { - var model = null; + var bone = null; relationships.parents.forEach( function ( parent ) { @@ -1599,16 +1595,20 @@ if ( rawBone.ID === parent.ID ) { - var model2 = model; - model = new THREE.Bone(); - skeleton.bones[ i ] = model; + var subBone = bone; + bone = new THREE.Bone(); + + // set name and id here - otherwise in cases where "subBone" is created it will not have a name / id + bone.name = THREE.PropertyBinding.sanitizeNodeName( name ); + bone.ID = id; + + skeleton.bones[ i ] = bone; // In cases where a bone is shared between multiple meshes - // model will already be defined and we'll hit this case - // TODO: currently doesn't work correctly - if ( model2 !== null ) { + // duplicate the bone here and and it as a child of the first bone + if ( subBone !== null ) { - model.add( model2 ); + bone.add( subBone ); } @@ -1620,7 +1620,7 @@ } ); - return model; + return bone; } @@ -1983,6 +1983,8 @@ // parse the model node for transform details and apply them to the model function setModelTransforms( FBXTree, model, modelNode ) { + // console.log( modelNode, model ) + // http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html if ( 'RotationOrder' in modelNode.properties ) { @@ -2093,14 +2095,21 @@ var skeleton = skeletons[ ID ]; - skeleton.bones.forEach( function ( bone ) { + skeleton.bones.forEach( function ( bone, i ) { + // if the bone's initial transform is set in a poseNode, copy that if ( worldMatrices.has( bone.ID ) ) { var mat = worldMatrices.get( bone.ID ); bone.matrixWorld.copy( mat ); } + // otherwise use the transform from the rawBone + else { + + bone.matrixWorld.copy( skeleton.rawBones[ i ].transformLink ) + + } } );
false
Other
mrdoob
three.js
3e9f292bcd82a24b90bfa0cc5bda175758b88570.json
Simplify deformer parsing
examples/js/loaders/FBXLoader.js
@@ -103,9 +103,9 @@ var images = parseImages( FBXTree ); var textures = parseTextures( FBXTree, new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ), images, connections ); var materials = parseMaterials( FBXTree, textures, connections ); - var deformers = parseDeformers( FBXTree, connections ); - var geometryMap = parseGeometries( FBXTree, connections, deformers ); - var sceneGraph = parseScene( FBXTree, connections, deformers, geometryMap, materials ); + var skeletons = parseDeformers( FBXTree, connections ); + var geometryMap = parseGeometries( FBXTree, connections, skeletons ); + var sceneGraph = parseScene( FBXTree, connections, skeletons, geometryMap, materials ); return sceneGraph; @@ -310,7 +310,7 @@ var texture = loadTexture( textureNode, loader, imageMap, connections ); - texture.FBX_ID = textureNode.id; + texture.ID = textureNode.id; texture.name = textureNode.attrName; @@ -419,7 +419,7 @@ // FBX format currently only supports Lambert and Phong shading models function parseMaterial( FBXTree, materialNode, textureMap, connections ) { - var FBX_ID = materialNode.id; + var ID = materialNode.id; var name = materialNode.attrName; var type = materialNode.properties.ShadingModel; @@ -431,9 +431,9 @@ } // Ignore unused materials which don't have any connections. - if ( ! connections.has( FBX_ID ) ) return null; + if ( ! connections.has( ID ) ) return null; - var parameters = parseParameters( FBXTree, materialNode.properties, textureMap, FBX_ID, connections ); + var parameters = parseParameters( FBXTree, materialNode.properties, textureMap, ID, connections ); var material; @@ -461,7 +461,7 @@ // Parse FBX material and return parameters suitable for a three.js material // Also parse the texture map and return any textures associated with the material - function parseParameters( FBXTree, properties, textureMap, FBX_ID, connections ) { + function parseParameters( FBXTree, properties, textureMap, ID, connections ) { var parameters = {}; @@ -517,7 +517,7 @@ } - connections.get( FBX_ID ).children.forEach( function ( child ) { + connections.get( ID ).children.forEach( function ( child ) { var type = child.relationship; @@ -594,7 +594,7 @@ // Generates map of Skeleton-like objects for use later when generating and binding skeletons. function parseDeformers( FBXTree, connections ) { - var deformers = {}; + var skeletons = {}; if ( 'Deformer' in FBXTree.Objects.subNodes ) { @@ -607,66 +607,72 @@ if ( deformerNode.attrType === 'Skin' ) { var relationships = connections.get( parseInt( nodeID ) ); + var skeleton = parseSkeleton( relationships, DeformerNodes ); - skeleton.FBX_ID = parseInt( nodeID ); + skeleton.ID = nodeID; + + if ( relationships.parents.length > 1 ) console.warn( 'THREE.FBXLoader: skeleton attached to more than one geometry is not supported.' ); + skeleton.geometryID = relationships.parents[ 0 ].ID; - deformers[ nodeID ] = skeleton; + skeletons[ nodeID ] = skeleton; } } } - return deformers; + return skeletons; } // Parse single nodes in FBXTree.Objects.subNodes.Deformer - // Generates a "Skeleton Representation" of FBX nodes based on an FBX Skin Deformer's connections - // and an object containing SubDeformer nodes. - function parseSkeleton( connections, DeformerNodes ) { + // The top level deformer nodes have type 'Skin' and subDeformer nodes have type 'Cluster' + // Each skin node represents a skeleton and each cluster node represents a bone + function parseSkeleton( connections, deformerNodes ) { + + var rawBones = []; - var subDeformers = {}; + connections.children.forEach( function ( child ) { - connections.children.forEach( function ( child, i ) { + var subDeformerNode = deformerNodes[ child.ID ]; - var subDeformerNode = DeformerNodes[ child.ID ]; + if ( subDeformerNode.attrType !== 'Cluster' ) return; - var subDeformer = { + var rawBone = { - FBX_ID: child.ID, - index: i, + ID: child.ID, indices: [], weights: [], transform: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.Transform.properties.a ), - transformLink: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.TransformLink.properties.a ), - linkMode: subDeformerNode.properties.Mode, + + //currently not used + // transformLink: new THREE.Matrix4().fromArray( subDeformerNode.subNodes.TransformLink.properties.a ), }; if ( 'Indexes' in subDeformerNode.subNodes ) { - subDeformer.indices = subDeformerNode.subNodes.Indexes.properties.a; - subDeformer.weights = subDeformerNode.subNodes.Weights.properties.a; + rawBone.indices = subDeformerNode.subNodes.Indexes.properties.a; + rawBone.weights = subDeformerNode.subNodes.Weights.properties.a; } - subDeformers[ child.ID ] = subDeformer; + rawBones.push( rawBone ); } ); return { - map: subDeformers, + rawBones: rawBones, bones: [] }; } // Parse nodes in FBXTree.Objects.subNodes.Geometry - function parseGeometries( FBXTree, connections, deformers ) { + function parseGeometries( FBXTree, connections, skeletons ) { var geometryMap = new Map(); @@ -677,7 +683,7 @@ for ( var nodeID in geometryNodes ) { var relationships = connections.get( parseInt( nodeID ) ); - var geo = parseGeometry( FBXTree, relationships, geometryNodes[ nodeID ], deformers ); + var geo = parseGeometry( FBXTree, relationships, geometryNodes[ nodeID ], skeletons ); geometryMap.set( parseInt( nodeID ), geo ); } @@ -689,12 +695,12 @@ } // Parse single node in FBXTree.Objects.subNodes.Geometry - function parseGeometry( FBXTree, relationships, geometryNode, deformers ) { + function parseGeometry( FBXTree, relationships, geometryNode, skeletons ) { switch ( geometryNode.attrType ) { case 'Mesh': - return parseMeshGeometry( FBXTree, relationships, geometryNode, deformers ); + return parseMeshGeometry( FBXTree, relationships, geometryNode, skeletons ); break; case 'NurbsCurve': @@ -706,27 +712,25 @@ } // Parse single node mesh geometry in FBXTree.Objects.subNodes.Geometry - function parseMeshGeometry( FBXTree, relationships, geometryNode, deformers ) { - - var deformer = relationships.children.reduce( function ( deformer, child ) { - - if ( deformers[ child.ID ] !== undefined ) deformer = deformers[ child.ID ]; - - return deformer; - - }, null ); + function parseMeshGeometry( FBXTree, relationships, geometryNode, skeletons ) { var modelNodes = relationships.parents.map( function ( parent ) { - var modelNode = FBXTree.Objects.subNodes.Model[ parent.ID ]; - - return modelNode; + return FBXTree.Objects.subNodes.Model[ parent.ID ]; } ); // don't create geometry if it is not associated with any models if ( modelNodes.length === 0 ) return; + var skeleton = relationships.children.reduce( function ( skeleton, child ) { + + if ( skeletons[ child.ID ] !== undefined ) skeleton = skeletons[ child.ID ]; + + return skeleton; + + }, null ); + var preTransform = new THREE.Matrix4(); // TODO: if there is more than one model associated with the geometry, AND the models have @@ -751,12 +755,12 @@ } - return genGeometry( FBXTree, relationships, geometryNode, deformer, preTransform ); + return genGeometry( FBXTree, relationships, geometryNode, skeleton, preTransform ); } // Generate a THREE.BufferGeometry from a node in FBXTree.Objects.subNodes.Geometry - function genGeometry( FBXTree, relationships, geometryNode, deformer, preTransform ) { + function genGeometry( FBXTree, relationships, geometryNode, skeleton, preTransform ) { var subNodes = geometryNode.subNodes; @@ -805,30 +809,25 @@ var weightTable = {}; - if ( deformer ) { + if ( skeleton !== null ) { - var subDeformers = deformer.map; + skeleton.rawBones.forEach( function ( rawBone, i ) { - for ( var key in subDeformers ) { - - var subDeformer = subDeformers[ key ]; - - subDeformer.indices.forEach( function ( index, i ) { - - var weight = subDeformer.weights[ i ]; + // loop over the bone's vertex indices and weights + rawBone.indices.forEach( function ( index, j ) { if ( weightTable[ index ] === undefined ) weightTable[ index ] = []; weightTable[ index ].push( { - id: subDeformer.index, - weight: weight + id: i, + weight: rawBone.weights[ j ], } ); } ); - } + } ); } @@ -876,7 +875,7 @@ } - if ( deformer ) { + if ( skeleton ) { if ( weightTable[ vertexIndex ] !== undefined ) { @@ -999,7 +998,7 @@ vertexBuffer.push( vertexPositions[ vertexPositionIndexes[ i * 3 + 1 ] ] ); vertexBuffer.push( vertexPositions[ vertexPositionIndexes[ i * 3 + 2 ] ] ); - if ( deformer ) { + if ( skeleton ) { vertexWeightsBuffer.push( faceWeights[ 0 ] ); vertexWeightsBuffer.push( faceWeights[ 1 ] ); @@ -1126,14 +1125,14 @@ } - if ( deformer ) { + if ( skeleton ) { geo.addAttribute( 'skinIndex', new THREE.Float32BufferAttribute( weightsIndicesBuffer, 4 ) ); geo.addAttribute( 'skinWeight', new THREE.Float32BufferAttribute( vertexWeightsBuffer, 4 ) ); // used later to bind the skeleton to the model - geo.FBX_Deformer = deformer; + geo.FBX_Deformer = skeleton; } @@ -1487,21 +1486,20 @@ } // create the main THREE.Group() to be returned by the loader - function parseScene( FBXTree, connections, deformers, geometryMap, materialMap ) { + function parseScene( FBXTree, connections, skeletons, geometryMap, materialMap ) { var sceneGraph = new THREE.Group(); - var modelMap = parseModels( FBXTree, deformers, geometryMap, materialMap, connections ); + var modelMap = parseModels( FBXTree, skeletons, geometryMap, materialMap, connections ); var modelNodes = FBXTree.Objects.subNodes.Model; modelMap.forEach( function ( model ) { - var modelNode = modelNodes[ model.FBX_ID ]; + var modelNode = modelNodes[ model.ID ]; + setLookAtProperties( FBXTree, model, modelNode, connections, sceneGraph ); - setModelTransforms( FBXTree, model, modelNode, connections, sceneGraph ); - - var parentConnections = connections.get( model.FBX_ID ).parents; + var parentConnections = connections.get( model.ID ).parents; parentConnections.forEach( function ( connection ) { @@ -1516,9 +1514,11 @@ } + } ); - bindSkeleton( FBXTree, deformers, geometryMap, modelMap, connections, sceneGraph ); + + bindSkeleton( FBXTree, skeletons, geometryMap, modelMap, connections, sceneGraph ); addAnimations( FBXTree, connections, sceneGraph, modelMap ); @@ -1529,7 +1529,7 @@ } // parse nodes in FBXTree.Objects.subNodes.Model - function parseModels( FBXTree, deformers, geometryMap, materialMap, connections ) { + function parseModels( FBXTree, skeletons, geometryMap, materialMap, connections ) { var modelMap = new Map(); var modelNodes = FBXTree.Objects.subNodes.Model; @@ -1539,37 +1539,8 @@ var id = parseInt( nodeID ); var node = modelNodes[ nodeID ]; var relationships = connections.get( id ); - var model = null; - - // create bones - relationships.parents.forEach( function ( parent ) { - - for ( var FBX_ID in deformers ) { - var deformer = deformers[ FBX_ID ]; - var subDeformers = deformer.map; - var subDeformer = subDeformers[ parent.ID ]; - - if ( subDeformer ) { - - var model2 = model; - model = new THREE.Bone(); - deformer.bones[ subDeformer.index ] = model; - - // In cases where a bone is shared between multiple meshes - // model will already be defined and we'll hit this case - // TODO: currently doesn't work correctly - if ( model2 !== null ) { - - model.add( model2 ); - - } - - } - - } - - } ); + var model = buildSkeleton( relationships, skeletons ); if ( ! model ) { @@ -1587,6 +1558,8 @@ case 'NurbsCurve': model = createCurve( relationships, geometryMap ); break; + case 'LimbNode': + case 'Null': default: model = new THREE.Group(); break; @@ -1595,17 +1568,62 @@ } - model.name = THREE.PropertyBinding.sanitizeNodeName( node.attrName ); - model.FBX_ID = id; + if ( model ) { - modelMap.set( id, model ); + setModelTransforms( FBXTree, model, node ); + + model.name = THREE.PropertyBinding.sanitizeNodeName( node.attrName ); + model.ID = id; + + modelMap.set( id, model ); + + } } return modelMap; } + function buildSkeleton( relationships, skeletons ) { + + var model = null; + + relationships.parents.forEach( function ( parent ) { + + for ( var ID in skeletons ) { + + var skeleton = skeletons[ ID ]; + + skeleton.rawBones.forEach( function ( rawBone, i ) { + + if ( rawBone.ID === parent.ID ) { + + var model2 = model; + model = new THREE.Bone(); + skeleton.bones[ i ] = model; + + // In cases where a bone is shared between multiple meshes + // model will already be defined and we'll hit this case + // TODO: currently doesn't work correctly + if ( model2 !== null ) { + + model.add( model2 ); + + } + + } + + } ); + + } + + } ); + + return model; + + } + // create a THREE.PerspectiveCamera or THREE.OrthographicCamera function createCamera( FBXTree, relationships ) { @@ -1924,8 +1942,46 @@ } + function setLookAtProperties( FBXTree, model, modelNode, connections, sceneGraph ) { + + if ( 'LookAtProperty' in modelNode.properties ) { + + var children = connections.get( model.ID ).children; + + children.forEach( function ( child ) { + + if ( child.relationship === 'LookAtProperty' ) { + + var lookAtTarget = FBXTree.Objects.subNodes.Model[ child.ID ]; + + if ( 'Lcl_Translation' in lookAtTarget.properties ) { + + var pos = lookAtTarget.properties.Lcl_Translation.value; + + // DirectionalLight, SpotLight + if ( model.target !== undefined ) { + + model.target.position.fromArray( pos ); + sceneGraph.add( model.target ); + + } else { // Cameras and other Object3Ds + + model.lookAt( new THREE.Vector3().fromArray( pos ) ); + + } + + } + + } + + } ); + + } + + } + // parse the model node for transform details and apply them to the model - function setModelTransforms( FBXTree, model, modelNode, connections, sceneGraph ) { + function setModelTransforms( FBXTree, model, modelNode ) { // http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html if ( 'RotationOrder' in modelNode.properties ) { @@ -1991,43 +2047,9 @@ } - if ( 'LookAtProperty' in modelNode.properties ) { - - var children = connections.get( model.FBX_ID ).children; - - children.forEach( function ( child ) { - - if ( child.relationship === 'LookAtProperty' ) { - - var lookAtTarget = FBXTree.Objects.subNodes.Model[ child.ID ]; - - if ( 'Lcl_Translation' in lookAtTarget.properties ) { - - var pos = lookAtTarget.properties.Lcl_Translation.value; - - // DirectionalLight, SpotLight - if ( model.target !== undefined ) { - - model.target.position.fromArray( pos ); - sceneGraph.add( model.target ); - - } else { // Cameras and other Object3Ds - - model.lookAt( new THREE.Vector3().fromArray( pos ) ); - - } - - } - - } - - } ); - - } - } - function bindSkeleton( FBXTree, deformers, geometryMap, modelMap, connections, sceneGraph ) { + function bindSkeleton( FBXTree, skeletons, geometryMap, modelMap, connections, sceneGraph ) { // Now with the bones created, we can update the skeletons and bind them to the skinned meshes. sceneGraph.updateMatrixWorld( true ); @@ -2067,47 +2089,38 @@ } - for ( var FBX_ID in deformers ) { + for ( var ID in skeletons ) { - var deformer = deformers[ FBX_ID ]; - var subDeformers = deformer.map; + var skeleton = skeletons[ ID ]; - for ( var key in subDeformers ) { + skeleton.bones.forEach( function ( bone ) { - var subDeformer = subDeformers[ key ]; - var subDeformerIndex = subDeformer.index; + if ( worldMatrices.has( bone.ID ) ) { - var bone = deformer.bones[ subDeformerIndex ]; - if ( ! worldMatrices.has( bone.FBX_ID ) ) { - - break; + var mat = worldMatrices.get( bone.ID ); + bone.matrixWorld.copy( mat ); } - var mat = worldMatrices.get( bone.FBX_ID ); - bone.matrixWorld.copy( mat ); - } + } ); // Now that skeleton is in bind pose, bind to model. - deformer.skeleton = new THREE.Skeleton( deformer.bones ); - - var relationships = connections.get( deformer.FBX_ID ); - var parents = relationships.parents; + var parents = connections.get( parseInt( skeleton.ID ) ).parents; parents.forEach( function ( parent ) { if ( geometryMap.has( parent.ID ) ) { var geoID = parent.ID; - var georelationships = connections.get( geoID ); + var geoRelationships = connections.get( geoID ); - georelationships.parents.forEach( function ( geoConnParent ) { + geoRelationships.parents.forEach( function ( geoConnParent ) { if ( modelMap.has( geoConnParent.ID ) ) { var model = modelMap.get( geoConnParent.ID ); - model.bind( deformer.skeleton, model.matrixWorld ); + model.bind( new THREE.Skeleton( skeleton.bones ), model.matrixWorld ); }
false
Other
mrdoob
three.js
6d983ef7f6a2a2ea6d1747b17f8cce68cb4d5ca0.json
Throw Errors in WebGLRenderer …instead of strings.
src/renderers/WebGLRenderer.js
@@ -215,11 +215,11 @@ function WebGLRenderer( parameters ) { if ( _canvas.getContext( 'webgl' ) !== null ) { - throw 'Error creating WebGL context with your selected attributes.'; + throw new Error( 'Error creating WebGL context with your selected attributes.' ); } else { - throw 'Error creating WebGL context.'; + throw new Error( 'Error creating WebGL context.' ); } @@ -239,7 +239,7 @@ function WebGLRenderer( parameters ) { } catch ( error ) { - console.error( 'THREE.WebGLRenderer: ' + error ); + console.error( 'THREE.WebGLRenderer: ' + error.message ); }
false
Other
mrdoob
three.js
0321eef244b182381592baa6976aa153545a1c67.json
remove trailing comma
examples/js/loaders/GLTFLoader.js
@@ -139,7 +139,7 @@ THREE.GLTFLoader = ( function () { path: path || this.path || '', crossOrigin: this.crossOrigin, - manager: this.manager, + manager: this.manager } );
false
Other
mrdoob
three.js
e2fe7c44913db2e447764c27700bef32852773c1.json
Update the document content
docs/manual/introduction/Browser-support.html
@@ -13,57 +13,21 @@ <h1>[name]</h1> <h2>Overview</h2> <div> <p> - <strong>TL;DR</strong> three.js supports most modern browsers, including Internet Explorer 11 and above.</p> + Three.js can use WebGL to render your scenes on all modern browsers. For older browsers, especially Internet Explorer 10 and below, you may have to fallback to one of the other renderers (CSS2DRenderer, CSS3DRenderer, SVGRenderer, CanvasRenderer). Additionally, you may have to include some polyfills, especially if you are using files from the /examples folder. + </p> <p> - three.js provides WebGL, Canvas, SVG and CSS renderers. Different renderers may have different requirements of compatibility. - In theory, three.js works on all browsers that support WebGL: Google Chrome 9+, Firefox 4+, Opera 15+, Safari - 5.1+, Internet Explorer 11 and Microsoft Edge. More infomation can be found at - <a href="https://caniuse.com/#feat=webgl" target="_blank">Can I use WebGL?</a>. + Note: if you don't need to support these old browsers, then it is not recommended to use the other renderers as they are slower and support less features than the WebGLRenderer. </p> </div> - <h2>Internet Explorer Compatibily</h2> + <h2>Browsers that support WebGL</h2> <div> <p> - It is strongly recommended to upgrade older versions of IE to IE11. If you still need to support IE9, you can use CanvasRenderer - instead. Note that CanvasRenderer only supports a small subset of WebGLRenderer's features. - </p> - <p> - For Internet Explorer, the table below lists avaiable renderers. + Google Chrome 9+, Firefox 4+, Opera 15+, Safari 5.1+, Internet Explorer 11 and Microsoft Edge. You can find which browsers support WebGL at <a href="https://caniuse.com/#feat=webgl" target="_blank">Can I use WebGL?</a>. </p> - <table> - <thead> - <tr> - <th>Renderer</th> - <th>IE Version</th> - </tr> - </thead> - <tbody> - <tr> - <td>WebGLRenderer</td> - <td>IE11+</td> - </tr> - <tr> - <td>CanvasRenderer</td> - <td>IE9+</td> - </tr> - <tr> - <td>SVGRenderer</td> - <td>IE9+</td> - </tr> - <tr> - <td>CSS3DRenderer</td> - <td>IE10+</td> - </tr> - <tr> - <td>CSS2DRenderer</td> - <td>IE9+</td> - </tr> - </tbody> - </table> </div> - <h2>Part of ECMAScript Language Features or Web APIs Used in three.js</h2> + <h2>JavaScript Language Features or Web APIs Used in three.js</h2> <div> <p> Here are some features used in three.js. Some of them may require additional polyfills. @@ -97,31 +61,16 @@ <h2>Part of ECMAScript Language Features or Web APIs Used in three.js</h2> <td>Source</td> <td>FileLoader, etc.</td> </tr> - <tr> - <td>performance</td> - <td>Source</td> - <td>Clock, etc.</td> - </tr> - <tr> - <td>requestAnimationFrame</td> - <td>Source</td> - <td>WebGLRenderer, VideoTexture, etc.</td> - </tr> <tr> <td>Promise</td> <td>Examples</td> - <td>GLTFLoader, GLTF2Loader, WEBVR, etc.</td> + <td>GLTFLoader, GLTF2Loader, WebVR, VREffect, etc.</td> </tr> <tr> <td>Fetch</td> <td>Examples</td> <td>ImageBitmapLoader, etc.</td> </tr> - <tr> - <td>Web Workers</td> - <td>Examples</td> - <td>WWOBJLoader2, etc.</td> - </tr> <tr> <td>File API</td> <td>Examples</td> @@ -132,15 +81,10 @@ <h2>Part of ECMAScript Language Features or Web APIs Used in three.js</h2> <td>Examples</td> <td>GLTFLoader, etc.</td> </tr> - <tr> - <td>TextEncoder & TextDecoder</td> - <td>Examples</td> - <td>FBXLoader, GLTFLoader, PCDLoaderetc, STLLoader, etc.</td> - </tr> <tr> <td>Pointer Lock API</td> <td>Examples</td> - <td>PointerLockControls, etc.</td> + <td>PointerLockControls</td> </tr> </tbody> </table> @@ -152,8 +96,6 @@ <h2>Polyfills</h2> <ul> <li>Typed Arrays</li> <li>Blob</li> - <li>performance</li> - <li>requestAnimationFrame</li> </ul> </div> @@ -170,13 +112,7 @@ <h3>Suggested polyfills</h3> <a href="https://github.com/stefanpenner/es6-promise/" target="_blank">ES6-Promise</a> </li> <li> - <a href="https://github.com/eligrey/Blob.js" target="_blank">Blob.js</a> - </li> - <li> - <a href="https://gist.github.com/paulirish/5438650" target="_blank">performance</a> - </li> - <li> - <a href="https://gist.github.com/paulirish/1579671" target="_blank">requestAnimationFrame</a> + <a href="https://github.com/github/fetch" target="_blank">fetch</a> </li> </ul> </div>
false
Other
mrdoob
three.js
3675404aaf5aa1bad1247be80d90794b03dde73a.json
Add document for browser support
docs/list.js
@@ -5,6 +5,7 @@ var list = { "Getting Started": { "Creating a scene": "manual/introduction/Creating-a-scene", "Import via modules": "manual/introduction/Import-via-modules", + "Browser support": "manual/introduction/Browser-support", "WebGL compatibility check": "manual/introduction/WebGL-compatibility-check", "How to run things locally": "manual/introduction/How-to-run-thing-locally", "Drawing Lines": "manual/introduction/Drawing-lines",
true
Other
mrdoob
three.js
3675404aaf5aa1bad1247be80d90794b03dde73a.json
Add document for browser support
docs/manual/introduction/Browser-support.html
@@ -0,0 +1,184 @@ +<!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> + + <h2>Overview</h2> + <div> + <p> + <strong>TL;DR</strong> three.js supports most modern browsers, including Internet Explorer 11 and above.</p> + <p> + three.js provides WebGL, Canvas, SVG and CSS renderers. Different renderers may have different requirements of compatibility. + In theory, three.js works on all browsers that support WebGL: Google Chrome 9+, Firefox 4+, Opera 15+, Safari + 5.1+, Internet Explorer 11 and Microsoft Edge. More infomation can be found at + <a href="https://caniuse.com/#feat=webgl" target="_blank">Can I use WebGL?</a>. + </p> + </div> + + <h2>Internet Explorer Compatibily</h2> + <div> + <p> + It is strongly recommended to upgrade older versions of IE to IE11. If you still need to support IE9, you can use CanvasRenderer + instead. Note that CanvasRenderer only supports a small subset of WebGLRenderer's features. + </p> + <p> + For Internet Explorer, the table below lists avaiable renderers. + </p> + <table> + <thead> + <tr> + <th>Renderer</th> + <th>IE Version</th> + </tr> + </thead> + <tbody> + <tr> + <td>WebGLRenderer</td> + <td>IE11+</td> + </tr> + <tr> + <td>CanvasRenderer</td> + <td>IE9+</td> + </tr> + <tr> + <td>SVGRenderer</td> + <td>IE9+</td> + </tr> + <tr> + <td>CSS3DRenderer</td> + <td>IE10+</td> + </tr> + <tr> + <td>CSS2DRenderer</td> + <td>IE9+</td> + </tr> + </tbody> + </table> + </div> + + <h2>Part of ECMAScript Language Features or Web APIs Used in three.js</h2> + <div> + <p> + Here are some features used in three.js. Some of them may require additional polyfills. + </p> + <table> + <thead> + <tr> + <th>Feature</th> + <th>Use Scope</th> + <th>Modules</th> + </tr> + </thead> + <tbody> + <tr> + <td>Typed Arrays</td> + <td>Source</td> + <td>BufferAttribute, BufferGeometry, etc.</td> + </tr> + <tr> + <td>Web Audio API</td> + <td>Source</td> + <td>Audio, AudioContext, AudioListener, etc.</td> + </tr> + <tr> + <td>WebVR API</td> + <td>Source</td> + <td>WebVRManager, etc.</td> + </tr> + <tr> + <td>Blob</td> + <td>Source</td> + <td>FileLoader, etc.</td> + </tr> + <tr> + <td>performance</td> + <td>Source</td> + <td>Clock, etc.</td> + </tr> + <tr> + <td>requestAnimationFrame</td> + <td>Source</td> + <td>WebGLRenderer, VideoTexture, etc.</td> + </tr> + <tr> + <td>Promise</td> + <td>Examples</td> + <td>GLTFLoader, GLTF2Loader, WEBVR, etc.</td> + </tr> + <tr> + <td>Fetch</td> + <td>Examples</td> + <td>ImageBitmapLoader, etc.</td> + </tr> + <tr> + <td>Web Workers</td> + <td>Examples</td> + <td>WWOBJLoader2, etc.</td> + </tr> + <tr> + <td>File API</td> + <td>Examples</td> + <td>GLTFExporter, etc.</td> + </tr> + <tr> + <td>URL API</td> + <td>Examples</td> + <td>GLTFLoader, etc.</td> + </tr> + <tr> + <td>TextEncoder & TextDecoder</td> + <td>Examples</td> + <td>FBXLoader, GLTFLoader, PCDLoaderetc, STLLoader, etc.</td> + </tr> + <tr> + <td>Pointer Lock API</td> + <td>Examples</td> + <td>PointerLockControls, etc.</td> + </tr> + </tbody> + </table> + </div> + + <h2>Polyfills</h2> + <div> + <p>Just import polyfills base on your requirements. Taking IE9 as an example, you need to polyfill at least these features:</p> + <ul> + <li>Typed Arrays</li> + <li>Blob</li> + <li>performance</li> + <li>requestAnimationFrame</li> + </ul> + </div> + + <h3>Suggested polyfills</h3> + <div> + <ul> + <li> + <a href="https://github.com/zloirock/core-js" target="_blank">core-js</a> + </li> + <li> + <a href="https://github.com/inexorabletash/polyfill/blob/master/typedarray.js" target="_blank">typedarray.js</a> + </li> + <li> + <a href="https://github.com/stefanpenner/es6-promise/" target="_blank">ES6-Promise</a> + </li> + <li> + <a href="https://github.com/eligrey/Blob.js" target="_blank">Blob.js</a> + </li> + <li> + <a href="https://gist.github.com/paulirish/5438650" target="_blank">performance</a> + </li> + <li> + <a href="https://gist.github.com/paulirish/1579671" target="_blank">requestAnimationFrame</a> + </li> + </ul> + </div> +</body> +</html> \ No newline at end of file
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/core/NodeBuilder.js
@@ -64,7 +64,7 @@ function NodeBuilder() { this.attributes = {}; this.prefixCode = [ - "#ifdef GL_EXT_shader_texture_lod", + "#ifdef TEXTURE_LOD_EXT", " #define texCube(a, b) textureCube(a, b)", " #define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)", @@ -82,7 +82,8 @@ function NodeBuilder() { "#endif", - "#include <packing>" + "#include <packing>", + "#include <common>" ].join( "\n" ); @@ -817,30 +818,30 @@ NodeBuilder.prototype = { switch ( typeToType ) { - case 'f <- v2': return code + '.x'; - case 'f <- v3': return code + '.x'; - case 'f <- v4': return code + '.x'; - case 'f <- i': return 'float( ' + code + ' )'; + case 'f <- v2' : return code + '.x'; + case 'f <- v3' : return code + '.x'; + case 'f <- v4' : return code + '.x'; + case 'f <- i' : return 'float( ' + code + ' )'; - case 'v2 <- f': return 'vec2( ' + code + ' )'; + case 'v2 <- f' : return 'vec2( ' + code + ' )'; case 'v2 <- v3': return code + '.xy'; case 'v2 <- v4': return code + '.xy'; - case 'v2 <- i': return 'vec2( float( ' + code + ' ) )'; + case 'v2 <- i' : return 'vec2( float( ' + code + ' ) )'; - case 'v3 <- f': return 'vec3( ' + code + ' )'; + case 'v3 <- f' : return 'vec3( ' + code + ' )'; case 'v3 <- v2': return 'vec3( ' + code + ', 0.0 )'; case 'v3 <- v4': return code + '.xyz'; - case 'v3 <- i': return 'vec2( float( ' + code + ' ) )'; + case 'v3 <- i' : return 'vec2( float( ' + code + ' ) )'; - case 'v4 <- f': return 'vec4( ' + code + ' )'; + case 'v4 <- f' : return 'vec4( ' + code + ' )'; case 'v4 <- v2': return 'vec4( ' + code + ', 0.0, 1.0 )'; case 'v4 <- v3': return 'vec4( ' + code + ', 1.0 )'; - case 'v4 <- i': return 'vec4( float( ' + code + ' ) )'; + case 'v4 <- i' : return 'vec4( float( ' + code + ' ) )'; - case 'i <- f': return 'int( ' + code + ' )'; - case 'i <- v2': return 'int( ' + code + '.x )'; - case 'i <- v3': return 'int( ' + code + '.x )'; - case 'i <- v4': return 'int( ' + code + '.x )'; + case 'i <- f' : return 'int( ' + code + ' )'; + case 'i <- v2' : return 'int( ' + code + '.x )'; + case 'i <- v3' : return 'int( ' + code + '.x )'; + case 'i <- v4' : return 'int( ' + code + '.x )'; }
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/materials/nodes/MeshStandardNode.js
@@ -75,6 +75,10 @@ MeshStandardNode.prototype.build = function ( builder ) { this.normal = new NormalMapNode( builder.resolve( props.normalMap ) ); this.normal.scale = builder.findNode( props.normalScale, inputs.normalScale ); + } else { + + this.normal = undefined; + } // slots
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/materials/nodes/PhongNode.js
@@ -25,7 +25,6 @@ PhongNode.prototype.build = function ( builder ) { var code; builder.define( 'PHONG' ); - builder.define( 'ALPHATEST', '0.0' ); builder.requires.lights = true; @@ -49,7 +48,6 @@ PhongNode.prototype.build = function ( builder ) { "#endif", - "#include <common>", //"#include <encodings_pars_fragment>", // encoding functions "#include <fog_pars_vertex>", "#include <morphtarget_pars_vertex>", @@ -148,7 +146,6 @@ PhongNode.prototype.build = function ( builder ) { builder.requires.transparent = alpha != undefined; builder.addParsCode( [ - "#include <common>", "#include <fog_pars_fragment>", "#include <bsdfs>", "#include <lights_pars_begin>", @@ -183,7 +180,11 @@ PhongNode.prototype.build = function ( builder ) { output.push( alpha.code, - 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;' + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif' ); }
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/materials/nodes/SpriteNode.js
@@ -23,7 +23,6 @@ SpriteNode.prototype.build = function ( builder ) { var output, code; builder.define( 'SPRITE' ); - builder.define( 'ALPHATEST', '0.0' ); builder.requires.lights = false; builder.requires.transparent = this.alpha !== undefined; @@ -37,7 +36,6 @@ SpriteNode.prototype.build = function ( builder ) { ] ) ); builder.addParsCode( [ - "#include <common>", "#include <fog_pars_vertex>", "#include <logdepthbuf_pars_vertex>", "#include <clipping_planes_pars_vertex>" @@ -113,7 +111,6 @@ SpriteNode.prototype.build = function ( builder ) { } else { builder.addParsCode( [ - "#include <common>", "#include <fog_pars_fragment>", "#include <logdepthbuf_pars_fragment>", "#include <clipping_planes_pars_fragment>" @@ -139,7 +136,11 @@ SpriteNode.prototype.build = function ( builder ) { output = [ alpha.code, - 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif', color.code, "gl_FragColor = vec4( " + color.result + ", " + alpha.result + " );" ];
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/materials/nodes/StandardNode.js
@@ -26,7 +26,6 @@ StandardNode.prototype.build = function ( builder ) { var code; builder.define( this.clearCoat || this.clearCoatRoughness ? 'PHYSICAL' : 'STANDARD' ); - builder.define( 'ALPHATEST', '0.0' ); builder.requires.lights = true; @@ -52,7 +51,6 @@ StandardNode.prototype.build = function ( builder ) { "#endif", - "#include <common>", //"#include <encodings_pars_fragment>", // encoding functions "#include <fog_pars_vertex>", "#include <morphtarget_pars_vertex>", @@ -181,7 +179,6 @@ StandardNode.prototype.build = function ( builder ) { "#endif", - "#include <common>", "#include <dithering_pars_fragment>", "#include <fog_pars_fragment>", "#include <bsdfs>", @@ -219,7 +216,11 @@ StandardNode.prototype.build = function ( builder ) { output.push( alpha.code, - 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;' + '#ifdef ALPHATEST', + + 'if ( ' + alpha.result + ' <= ALPHATEST ) discard;', + + '#endif' ); }
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/math/CondNode.js
@@ -14,7 +14,7 @@ function CondNode( a, b, ifNode, elseNode, op ) { this.ifNode = ifNode; this.elseNode = elseNode; - this.op = op || CondNode.EQUAL; + this.op = op; };
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/math/Math1Node.js
@@ -10,7 +10,7 @@ function Math1Node( a, method ) { this.a = a; - this.method = method || Math1Node.SIN; + this.method = method; };
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/math/Math2Node.js
@@ -11,7 +11,7 @@ function Math2Node( a, b, method ) { this.a = a; this.b = b; - this.method = method || Math2Node.DISTANCE; + this.method = method; };
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/math/Math3Node.js
@@ -12,7 +12,7 @@ function Math3Node( a, b, c, method ) { this.b = b; this.c = c; - this.method = method || Math3Node.MIX; + this.method = method; };
true
Other
mrdoob
three.js
5da506d3c960e81b89d859c404092a7f5313fe1f.json
fix ALPHATEST and cleanup
examples/js/nodes/math/OperatorNode.js
@@ -10,7 +10,7 @@ function OperatorNode( a, b, op ) { this.a = a; this.b = b; - this.op = op || OperatorNode.ADD; + this.op = op; };
true
Other
mrdoob
three.js
303a954121734963c1376b6dbff79bf523fb6276.json
Classify STL file prefix using matchDataViewAt
examples/js/loaders/STLLoader.js
@@ -96,24 +96,27 @@ THREE.STLLoader.prototype = { for ( var off = 0; off < 5; off ++ ) { - // Check if solid[ i ] matches the i-th byte at the current offset + // If "solid" text is matched to the current offset, declare it to be an ASCII STL. - var found = true; - for ( var i = 0; found && i < 5; i ++ ) { + if ( matchDataViewAt ( solid, reader, off ) ) return false; - found = found && ( solid[ i ] == reader.getUint8( off + i, false ) ); + } - } + // Couldn't find "solid" text at the beginning; it is binary STL. - // Found "solid" text at the beginning; declare it to be an ASCII STL. + return true; - if ( found ) { - return false; - } + } - } + function matchDataViewAt( query, reader, offset ) { - // Couldn't find "solid" text at the beginning; it is binary STL. + // Check if each byte in query matches the corresponding byte from the current offset + + for ( var i = 0, il = query.length; i < il; i ++ ) { + + if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false; + + } return true;
false
Other
mrdoob
three.js
9eafb9e9e83ede23c6aa3eff8354a908cdc18e14.json
add comment and fix euler ordering
examples/js/loaders/FBXLoader.js
@@ -3851,16 +3851,17 @@ } + // Returns the three.js intrinsic Euler order corresponding to FBX extrinsic Euler order // ref: http://help.autodesk.com/view/FBX/2017/ENU/?guid=__cpp_ref_class_fbx_euler_html function getEulerOrder( order ) { var enums = [ - 'ZYX', // -> XYZ in FBX - 'YXZ', - 'ZXY', - 'YZX', - 'XZY', - 'XYZ', + 'ZYX', // -> XYZ extrinsic + 'YZX', // -> XZY extrinsic + 'XZY', // -> YZX extrinsic + 'ZXY', // -> YXZ extrinsic + 'YXZ', // -> ZXY extrinsic + 'XYZ', // -> ZYX extrinsic //'SphericXYZ', // not possible to support ];
false
Other
mrdoob
three.js
e0fb997c502adf4d1853d87fdc66ecf5d7e08af4.json
fix undefined curveNode
examples/js/loaders/FBXLoader.js
@@ -97,7 +97,7 @@ } - console.log( FBXTree ); + // console.log( FBXTree ); var textureLoader = new THREE.TextureLoader( this.manager ).setPath( resourceDirectory ).setCrossOrigin( this.crossOrigin ); @@ -2246,6 +2246,7 @@ var curveNodesMap = parseAnimationCurveNodes( FBXTree ); parseAnimationCurves( FBXTree, connections, curveNodesMap ); + var layersMap = parseAnimationLayers( FBXTree, connections, curveNodesMap ); var rawClips = parseAnimStacks( FBXTree, connections, layersMap ); @@ -2329,7 +2330,7 @@ curveNodesMap.get( animationCurveID ).curves[ 'z' ] = animationCurve; - } else if ( animationCurveRelationship.match( /d|DeformPercent/ ) ) { + } else if ( animationCurveRelationship.match( /d|DeformPercent/ ) && curveNodesMap.has( animationCurveID ) ) { curveNodesMap.get( animationCurveID ).curves[ 'morph' ] = animationCurve;
false
Other
mrdoob
three.js
5b1441a0e9422d25bf0343aae9fca2f3df8b5504.json
convert anim values back to arrays
examples/js/loaders/FBXLoader.js
@@ -2555,6 +2555,10 @@ if ( rawTracks.transform ) rawTracks.transform.decompose( initialPosition, initialRotation, initialScale ); + initialPosition = initialPosition.toArray(); + initialRotation = new THREE.Euler().setFromQuaternion( initialRotation ).toArray(); // todo: euler order + initialScale = initialScale.toArray(); + if ( rawTracks.T !== undefined && Object.keys( rawTracks.T.curves ).length > 0 ) { var positionTrack = generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, initialPosition, 'position' );
false
Other
mrdoob
three.js
ad44277f5554cee5928c8f013114a1ba56fcc286.json
use generateTransform for geometry transforms
examples/js/loaders/FBXLoader.js
@@ -814,44 +814,24 @@ }, null ); - var preTransform = new THREE.Matrix4(); - // TODO: if there is more than one model associated with the geometry, AND the models have // different geometric transforms, then this will cause problems // if ( modelNodes.length > 1 ) { } // For now just assume one model and get the preRotations from that var modelNode = modelNodes[ 0 ]; - if ( 'GeometricRotation' in modelNode ) { - - var eulerOrder = 'ZYX'; - - if ( 'RotationOrder' in modelNode ) { - - eulerOrder = getEulerOrder( parseInt( modelNode.RotationOrder.value ) ); - - } - - var array = modelNode.GeometricRotation.value.map( THREE.Math.degToRad ); - array.push( eulerOrder ); - preTransform.makeRotationFromEuler( new THREE.Euler().fromArray( array ) ); - - } - - if ( 'GeometricTranslation' in modelNode ) { - - preTransform.setPosition( new THREE.Vector3().fromArray( modelNode.GeometricTranslation.value ) ); - - } + var transformData = {}; - if ( 'GeometricScaling' in modelNode ) { + if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = modelNode.RotationOrder.value; - preTransform.scale( new THREE.Vector3().fromArray( modelNode.GeometricScaling.value ) ); + if ( 'GeometricTranslation' in modelNode ) transformData.translation = modelNode.GeometricTranslation.value; + if ( 'GeometricRotation' in modelNode ) transformData.rotation = modelNode.GeometricRotation.value; + if ( 'GeometricScaling' in modelNode ) transformData.scale = modelNode.GeometricScaling.value; - } + var transform = generateTransform( transformData ); - return genGeometry( FBXTree, geoNode, skeleton, morphTarget, preTransform ); + return genGeometry( FBXTree, geoNode, skeleton, morphTarget, transform ); }
false
Other
mrdoob
three.js
6139da0c9325a4b43e1750a97bbbc4873ecb701d.json
use generateTransform for animation transforms
examples/js/loaders/FBXLoader.js
@@ -2408,18 +2408,16 @@ initialPosition: [ 0, 0, 0 ], initialRotation: [ 0, 0, 0 ], initialScale: [ 1, 1, 1 ], + transform: getModelAnimTransform( rawModel ), }; - if ( 'Lcl_Translation' in rawModel ) node.initialPosition = rawModel.Lcl_Translation.value; + node.transform = getModelAnimTransform( rawModel ); - if ( 'Lcl_Rotation' in rawModel ) node.initialRotation = rawModel.Lcl_Rotation.value; - - if ( 'Lcl_Scaling' in rawModel ) node.initialScale = rawModel.Lcl_Scaling.value; - - // if the animated model is pre rotated, we'll have to apply the pre rotations to every + // if the animated model is pre or post rotated, we'll have to apply the pre rotations to every // animation value as well if ( 'PreRotation' in rawModel ) node.preRotations = rawModel.PreRotation.value; + if ( 'PostRotation' in rawModel ) node.postRotations = rawModel.PostRotation.value; layerCurveNodes[ i ] = node; @@ -2476,6 +2474,26 @@ } + function getModelAnimTransform( modelNode ) { + + var transformData = {}; + + if ( 'RotationOrder' in modelNode ) transformData.eulerOrder = parseInt( modelNode.RotationOrder.value ); + + if ( 'Lcl_Translation' in modelNode ) transformData.translation = modelNode.Lcl_Translation.value; + if ( 'RotationOffset' in modelNode ) transformData.rotationOffset = modelNode.RotationOffset.value; + + if ( 'Lcl_Rotation' in modelNode ) transformData.rotation = modelNode.Lcl_Rotation.value; + if ( 'PreRotation' in modelNode ) transformData.preRotation = modelNode.PreRotation.value; + + if ( 'PostRotation' in modelNode ) transformData.postRotation = modelNode.PostRotation.value; + + if ( 'Lcl_Scaling' in modelNode ) transformData.scale = modelNode.Lcl_Scaling.value; + + return generateTransform( transformData ); + + } + // parse nodes in FBXTree.Objects.AnimationStack. These are the top level node in the animation // hierarchy. Each Stack node will be used to create a THREE.AnimationClip function parseAnimStacks( FBXTree, connections, layersMap ) { @@ -2551,23 +2569,29 @@ var tracks = []; + var initialPosition = new THREE.Vector3(); + var initialRotation = new THREE.Quaternion(); + var initialScale = new THREE.Vector3(); + + if ( rawTracks.transform ) rawTracks.transform.decompose( initialPosition, initialRotation, initialScale ); + if ( rawTracks.T !== undefined && Object.keys( rawTracks.T.curves ).length > 0 ) { - var positionTrack = generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, rawTracks.initialPosition, 'position' ); + var positionTrack = generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, initialPosition, 'position' ); if ( positionTrack !== undefined ) tracks.push( positionTrack ); } if ( rawTracks.R !== undefined && Object.keys( rawTracks.R.curves ).length > 0 ) { - var rotationTrack = generateRotationTrack( rawTracks.modelName, rawTracks.R.curves, rawTracks.initialRotation, rawTracks.preRotations ); + var rotationTrack = generateRotationTrack( rawTracks.modelName, rawTracks.R.curves, initialRotation, rawTracks.preRotations, rawTracks.postRotations ); if ( rotationTrack !== undefined ) tracks.push( rotationTrack ); } if ( rawTracks.S !== undefined && Object.keys( rawTracks.S.curves ).length > 0 ) { - var scaleTrack = generateVectorTrack( rawTracks.modelName, rawTracks.S.curves, rawTracks.initialScale, 'scale' ); + var scaleTrack = generateVectorTrack( rawTracks.modelName, rawTracks.S.curves, initialScale, 'scale' ); if ( scaleTrack !== undefined ) tracks.push( scaleTrack ); } @@ -2592,7 +2616,7 @@ } - function generateRotationTrack( modelName, curves, initialValue, preRotations ) { + function generateRotationTrack( modelName, curves, initialValue, preRotations, postRotations ) { if ( curves.x !== undefined ) { @@ -2626,6 +2650,16 @@ } + if ( postRotations !== undefined ) { + + postRotations = postRotations.map( THREE.Math.degToRad ); + postRotations.push( 'ZYX' ); + + postRotations = new THREE.Euler().fromArray( postRotations ); + postRotations = new THREE.Quaternion().setFromEuler( postRotations ); + + } + var quaternion = new THREE.Quaternion(); var euler = new THREE.Euler();
false
Other
mrdoob
three.js
e8948e3b6f1d0f93f116ec2f6031c1bd6311efa9.json
Add ColladaExporter docs, fix links in PLYExporter
docs/examples/exporters/ColladaExporter.html
@@ -0,0 +1,81 @@ +<!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 *Collada*. + <br /><br /> + <a href="https://www.khronos.org/collada/">Collada</a> is a + file format for robust representation of scenes, materials, animations, and other 3D content in an xml format. + This exporter only supports exporting geometry, materials, textures, and scene hierarchy. + </p> + + <h2>Example</h2> + + <code> + // Instantiate an exporter + var exporter = new THREE.ColladaExporter(); + + // Parse the input and generate the ply output + var data = exporter.parse( scene, null, options ); + downloadFile(data); + </code> + + <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:Function onCompleted], [param:Object options] )</h3> + <p> + [page:Object input] — Object3D to be exported<br /> + [page:Function onCompleted] — Will be called when the export completes. Optional. The same data is immediately returned from the function.<br /> + [page:Options options] — Export options<br /> + <ul> + <li>version - string. Which version of Collada to export. The options are "1.4.1" or "1.5.0". Defaults to "1.4.1".</li> + <li>author - string. The name to include in the author field. Author field is excluded by default.</li> + <li>textureDirectory - string. The directory relative to the Collada file to save the textures to.</li> + </ul> + </p> + <p> + Generates an object with Collada file and texture data. This object is returned from the function and passed into the "onCompleted" callback. + <code> + { + // Collada file content + data: "", + + // List of referenced texures + textures: [{ + + // File directory, name, and extension of the texture data + directory: "", + name: "", + ext: "", + + // The texture data and original texture object + data: [], + original: &ltTHREE.Texture&gt + }, ...] + } + </code> + </p> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/ColladaExporter.js examples/js/exporters/ColladaExporter.js] + </body> +</html>
true
Other
mrdoob
three.js
e8948e3b6f1d0f93f116ec2f6031c1bd6311efa9.json
Add ColladaExporter docs, fix links in PLYExporter
docs/examples/exporters/PLYExporter.html
@@ -13,7 +13,7 @@ <h1>[name]</h1> <p class="desc"> An exporter for *PLY*. <br /><br /> - <a href="https://www.khronos.org/gltf">PLY</a> (Polygon or Stanford Triangle Format) is a + <a href="https://en.wikipedia.org/wiki/PLY_(file_format)">PLY</a> (Polygon or Stanford Triangle Format) is a file format for efficient delivery and loading of simple, static 3D content in a dense format. Both binary and ascii formats are supported. PLY can store vertex positions, colors, normals and uv coordinates. No textures or texture references are saved. @@ -41,7 +41,7 @@ <h3>[name]()</h3> <h2>Methods</h2> - <h3>[method:null parse]( [param:Object3D input], [param:Object options] )</h3> + <h3>[method:ArrayBufferOrString parse]( [param:Object3D input], [param:Object options] )</h3> <p> [page:Object input] — Object3D<br /> [page:Options options] — Export options<br />
true
Other
mrdoob
three.js
d20b0069e37e5b80c6a8ac6131411ac1b0660bee.json
add boxselection demo
examples/files.js
@@ -59,6 +59,7 @@ var files = { "webgl_interactive_lines", "webgl_interactive_points", "webgl_interactive_raycasting_points", + "webgl_interactive_boxselection", "webgl_interactive_voxelpainter", "webgl_kinect", "webgl_lensflares",
true
Other
mrdoob
three.js
d20b0069e37e5b80c6a8ac6131411ac1b0660bee.json
add boxselection demo
examples/js/interactive/SelectionBox.js
@@ -0,0 +1,116 @@ +/** + * @author HypnosNova / https://www.threejs.org.cn/gallery + * This is a class to check whether objects are in a selection area in 3D space + */ + +function SelectionBox ( camera, scene, deep ) { + + this.camera = camera; + this.scene = scene; + this.startPoint = new THREE.Vector3(); + this.endPoint = new THREE.Vector3(); + this.collection = []; + this.deep = deep || Number.MAX_VALUE; + +} + +SelectionBox.prototype.select = function ( startPoint, endPoint ) { + + this.startPoint = startPoint || this.startPoint; + this.endPoint = endPoint || this.endPoint; + this.collection = []; + + var boxSelectionFrustum = this.createFrustum( this.startPoint, this.endPoint ); + this.searchChildInFrustum( boxSelectionFrustum, this.scene ); + + return this.collection; + +} + +SelectionBox.prototype.createFrustum = function ( startPoint, endPoint ) { + + startPoint = startPoint || this.startPoint; + endPoint = endPoint || this.endPoint + + this.camera.updateProjectionMatrix(); + this.camera.updateMatrixWorld(); + this.camera.updateMatrix(); + + var tmpPoint = startPoint.clone(); + tmpPoint.x = Math.min( startPoint.x, endPoint.x ); + tmpPoint.y = Math.max( startPoint.y, endPoint.y ); + endPoint.x = Math.max( startPoint.x, endPoint.x ); + endPoint.y = Math.min( startPoint.y, endPoint.y ); + + var vecNear = this.camera.position.clone(); + var vecTopLeft = tmpPoint.clone(); + var vecTopRight = new THREE.Vector3( endPoint.x, tmpPoint.y, 0 ); + var vecDownRight = endPoint.clone(); + var vecDownLeft = new THREE.Vector3( tmpPoint.x, endPoint.y, 0 ); + vecTopLeft.unproject( this.camera ); + vecTopRight.unproject( this.camera ); + vecDownRight.unproject( this.camera ); + vecDownLeft.unproject( this.camera ); + + var vectemp1 = vecTopLeft.clone().sub( vecNear ); + var vectemp2 = vecTopRight.clone().sub( vecNear ); + var vectemp3 = vecDownRight.clone().sub( vecNear ); + vectemp1.normalize(); + vectemp2.normalize(); + vectemp3.normalize(); + + vectemp1.multiplyScalar( this.deep ); + vectemp2.multiplyScalar( this.deep ); + vectemp3.multiplyScalar( this.deep ); + vectemp1.add( vecNear ); + vectemp2.add( vecNear ); + vectemp3.add( vecNear ); + + var planeTop = new THREE.Plane(); + planeTop.setFromCoplanarPoints( vecNear, vecTopLeft, vecTopRight ); + var planeRight = new THREE.Plane(); + planeRight.setFromCoplanarPoints( vecNear, vecTopRight, vecDownRight ); + var planeDown = new THREE.Plane(); + planeDown.setFromCoplanarPoints( vecDownRight, vecDownLeft, vecNear ); + var planeLeft = new THREE.Plane(); + planeLeft.setFromCoplanarPoints( vecDownLeft, vecTopLeft, vecNear ); + var planeFront = new THREE.Plane(); + planeFront.setFromCoplanarPoints( vecTopRight, vecDownRight, vecDownLeft ); + var planeBack = new THREE.Plane(); + planeBack.setFromCoplanarPoints( vectemp3, vectemp2, vectemp1 ); + planeBack.normal = planeBack.normal.multiplyScalar( -1 ); + + return new THREE.Frustum( planeTop, planeRight, planeDown, planeLeft, planeFront, planeBack ); + +} + +SelectionBox.prototype.searchChildInFrustum = function ( frustum, object ) { + + if ( object instanceof THREE.Mesh ) { + + if ( object.material !== undefined ) { + + object.geometry.computeBoundingSphere(); + var center = object.geometry.boundingSphere.center.clone().applyMatrix4( object.matrixWorld ); + + if ( frustum.containsPoint( center ) ) { + + this.collection.push( object ); + + } + + } + + } + + if ( object.children.length > 0 ) { + + for ( var x = 0; x < object.children.length; x++ ) { + + this.searchChildInFrustum( frustum, object.children[x] ); + + } + + } + +} \ No newline at end of file
true
Other
mrdoob
three.js
d20b0069e37e5b80c6a8ac6131411ac1b0660bee.json
add boxselection demo
examples/js/interactive/SelectionHelper.js
@@ -0,0 +1,73 @@ +function SelectionHelper ( selectionBox, renderer, cssClassName ) { + + this.element = document.createElement( "div" ); + this.element.classList.add( cssClassName ); + this.element.style.pointerEvents = "none"; + + this.renderer = renderer; + + this.startPoint = { x: 0, y: 0 }; + this.pointTopLeft = { x: 0, y: 0 }; + this.pointBottomRight = { x: 0, y: 0 }; + + this.isDown = false; + + this.renderer.domElement.addEventListener( "mousedown", function ( event ) { + + this.isDown = true; + this.onSelectStart( event ); + + }.bind( this ), false ); + + this.renderer.domElement.addEventListener( "mousemove", function ( event ) { + + if ( this.isDown ) { + + this.onSelectMove( event ); + + } + + }.bind( this ), false ); + + this.renderer.domElement.addEventListener( "mouseup", function ( event ) { + + this.isDown = false; + this.onSelectOver( event ); + + }.bind( this ), false ); + +} + +SelectionHelper.prototype.onSelectStart = function ( event ) { + + this.renderer.domElement.parentElement.appendChild( this.element ); + + this.element.style.left = event.clientX + "px"; + this.element.style.top = event.clientY + "px"; + this.element.style.width = "0px"; + this.element.style.height = "0px"; + + this.startPoint.x = event.clientX; + this.startPoint.y = event.clientY; + +} + +SelectionHelper.prototype.onSelectMove = function ( event ) { + + this.pointBottomRight.x = Math.max( this.startPoint.x, event.clientX ); + this.pointBottomRight.y = Math.max( this.startPoint.y, event.clientY ); + this.pointTopLeft.x = Math.min( this.startPoint.x, event.clientX ); + this.pointTopLeft.y = Math.min( this.startPoint.y, event.clientY ); + + this.element.style.left = this.pointTopLeft.x + "px"; + this.element.style.top = this.pointTopLeft.y + "px"; + this.element.style.width = ( this.pointBottomRight.x - this.pointTopLeft.x ) + "px"; + this.element.style.height = ( this.pointBottomRight.y - this.pointTopLeft.y ) + "px"; + +} + +SelectionHelper.prototype.onSelectOver = function ( event ) { + + this.element.parentElement.removeChild( this.element ); + +}
true
Other
mrdoob
three.js
d20b0069e37e5b80c6a8ac6131411ac1b0660bee.json
add boxselection demo
examples/webgl_interactive_boxselection.html
@@ -0,0 +1,206 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <title>three.js webgl - draggable cubes</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 { + font-family: Monospace; + background-color: #f0f0f0; + margin: 0px; + overflow: hidden; + } + + .selectBox { + border: 1px solid #55aaff; + background-color: rgba(75, 160, 255, 0.3); + position: fixed; + } + </style> + </head> + <body> + + <script src="../build/three.js"></script> + <script src="js/libs/stats.min.js"></script> + + <script src="js/interactive/SelectionBox.js"></script> + <script src="js/interactive/SelectionHelper.js"></script> + + <script> + + var container, stats; + var camera, controls, scene, renderer; + var objects = []; + + init(); + animate(); + + function init() { + + container = document.createElement( 'div' ); + document.body.appendChild( container ); + + camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 1, 5000 ); + camera.position.z = 1000; + + scene = new THREE.Scene(); + scene.background = new THREE.Color( 0xf0f0f0 ); + + scene.add( new THREE.AmbientLight( 0x505050 ) ); + + var light = new THREE.SpotLight( 0xffffff, 1.5 ); + light.position.set( 0, 500, 2000 ); + light.angle = Math.PI / 9; + + light.castShadow = true; + light.shadow.camera.near = 1000; + light.shadow.camera.far = 4000; + light.shadow.mapSize.width = 1024; + light.shadow.mapSize.height = 1024; + + scene.add( light ); + + var geometry = new THREE.BoxBufferGeometry( 20, 20, 20 ); + + for ( var i = 0; i < 200; i ++ ) { + + var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: Math.random() * 0xffffff } ) ); + + object.position.x = Math.random() * 1600 - 800; + object.position.y = Math.random() * 900 - 450; + object.position.z = Math.random() * 900 - 500; + + object.rotation.x = Math.random() * 2 * Math.PI; + object.rotation.y = Math.random() * 2 * Math.PI; + object.rotation.z = Math.random() * 2 * Math.PI; + + object.scale.x = Math.random() * 2 + 1; + object.scale.y = Math.random() * 2 + 1; + object.scale.z = Math.random() * 2 + 1; + + object.castShadow = true; + object.receiveShadow = true; + + scene.add( object ); + + objects.push( object ); + + } + + renderer = new THREE.WebGLRenderer( { antialias: true } ); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + + renderer.shadowMap.enabled = true; + renderer.shadowMap.type = THREE.PCFShadowMap; + + container.appendChild( renderer.domElement ); + + var info = document.createElement( 'div' ); + info.style.position = 'absolute'; + info.style.top = '10px'; + info.style.width = '100%'; + info.style.textAlign = 'center'; + info.innerHTML = '<a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> webgl - box selection'; + container.appendChild( info ); + + stats = new Stats(); + container.appendChild( stats.dom ); + + // + + window.addEventListener( 'resize', onWindowResize, false ); + + } + + function onWindowResize() { + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + + renderer.setSize( window.innerWidth, window.innerHeight ); + + } + + // + + function animate() { + + requestAnimationFrame( animate ); + + render(); + stats.update(); + + } + + function render() { + + renderer.render( scene, camera ); + + } + + var selectionBox = new SelectionBox( camera, scene ); + var helper = new SelectionHelper( selectionBox, renderer, "selectBox" ); + + document.addEventListener("mousedown", function ( e ) { + + for ( var item of selectionBox.collection ) { + + item.material.emissive = new THREE.Color( 0x000000 ); + + } + + selectionBox.startPoint.set( + ( event.clientX / window.innerWidth ) * 2 - 1, + -( event.clientY / window.innerHeight ) * 2 + 1, + 0.5 ); + } ); + + document.addEventListener( "mousemove", function ( e ) { + + if ( helper.isDown ) { + + for ( var i = 0; i < selectionBox.collection.length; i++ ) { + + selectionBox.collection[i].material.emissive = new THREE.Color( 0x000000 ); + + } + + selectionBox.endPoint.set( + ( event.clientX / window.innerWidth ) * 2 - 1, + -( event.clientY / window.innerHeight ) * 2 + 1, + 0.5 ); + + var allSelected = selectionBox.select(); + + for ( var i = 0; i < allSelected.length; i++ ) { + + allSelected[i].material.emissive = new THREE.Color( 0x0000ff ); + + } + } + + } ); + + document.addEventListener("mouseup", function (e) { + + selectionBox.endPoint.set( + (event.clientX / window.innerWidth) * 2 - 1, + -(event.clientY / window.innerHeight) * 2 + 1, + 0.5 ); + + var allSelected = selectionBox.select(); + + for ( var i=0; i < allSelected.length; i++ ) { + + item.material.emissive = new THREE.Color(0x0000ff); + + } + + }); + + </script> + + </body> +</html>
true
Other
mrdoob
three.js
5262440b18f287a3d384cad6b769a5fc87e04a30.json
handle resize event
examples/webgl_buffergeometry_instancing_lambert.html
@@ -387,6 +387,19 @@ stats = new Stats(); document.body.appendChild( stats.dom ); + // + + window.addEventListener( 'resize', onWindowResize, false ); + + } + + function onWindowResize( event ) { + + renderer.setSize( window.innerWidth, window.innerHeight ); + + camera.aspect = window.innerWidth / window.innerHeight; + camera.updateProjectionMatrix(); + } function animate() {
false
Other
mrdoob
three.js
b61a4713d1a06c8fb282f75ddb81cae958431722.json
Add MMDPhysics doc
docs/examples/animations/MMDPhysics.html
@@ -0,0 +1,112 @@ +<!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"> A Physics handler for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br /> + [name] calculates Physics for model loaded by [page:MMDLoader] with <a href="https://github.com/kripken/ammo.js/">ammo.js</a> (Bullet-based JavaScript Physics engine). + </p> + + <h2>Example</h2> + + <code> + var physics; + + // Load MMD resources and instantiate MMDPhysics + new THREE.MMDLoader().load( + 'models/mmd/miku.pmd', + function ( mesh ) { + + physics = new THREE.MMDPhysics( mesh ) + scene.add( mesh ); + + } + ); + + function render() { + + var delta = clock.getDelta(); + animate( delta ); // update bones + if ( physics !== undefined ) physics.update( delta ); + renderer.render( scene, camera ); + + } + </code> + + [example:webgl_loader_mmd]<br /> + [example:webgl_loader_mmd_audio]<br /> + + <br /> + <hr> + + <h2>Constructor</h2> + + <h3>[name]( [param:SkinnedMesh mesh], [param:Array rigidBodyParams], [param:Array constraintParams], [param:Object params] )</h3> + <p> + [page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] calculates Physics.<br /> + [page:Array rigidBodyParams] — An array of [page:Object] specifying Rigid Body parameters.<br /> + [page:Array constraintParams] — (optional) An array of [page:Object] specifying Constraint parameters.<br /> + [page:Object params] — (optional)<br /> + <ul> + <li>[page:Number unitStep] - Default is 1 / 65.</li> + <li>[page:Integer maxStepNum] - Default is 3.</li> + <li>[page:Vector3 gravity] - Default is ( 0, - 9.8 * 10, 0 )</li> + </ul> + </p> + <p> + Creates a new [name]. + </p> + + <h2>Properties</h2> + + <h3>[property:Array mesh]</h3> + <p>[page:SkinnedMesh] passed to the constructor.</p> + + <h2>Methods</h2> + + <h3>[method:MMDPhysicsHelper createHelper]()</h3> + <p> + Return [page:MMDPhysicsHelper]. You can visualize Rigid bodies by adding the helper to scene. + </p> + + <h3>[method:CCDIKSolver reset]()</h3> + <p> + Resets Rigid bodies transorm to current bone's. + </p> + + <h3>[method:CCDIKSolver setGravity]( [param:Vector3 gravity] )</h3> + <p> + [page:Vector3 gravity] — Direction and volume of gravity. + </p> + <p> + Set gravity. + </p> + + <h3>[method:CCDIKSolver update]( [param:Number delta] )</h3> + <p> + [page:Number delta] — Time in second. + </p> + <p> + Advance Physics calculation and updates bones. + </p> + + <h3>[method:CCDIKSolver warmup]( [param:Integer cycles] )</h3> + <p> + [page:Number delta] — Time in second. + </p> + <p> + Warm up Rigid bodies. Calculates cycles steps. + </p> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDPhysics.js examples/js/animation/MMDPhysics.js] + </body> +</html>
false
Other
mrdoob
three.js
b2db307a6f47197b2b9638994f37d12e045f3454.json
Add CCDIKSolver doc
docs/examples/animations/CCDIKSolver.html
@@ -0,0 +1,100 @@ +<!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"> A solver for IK with <a href="https://sites.google.com/site/auraliusproject/ccd-algorithm"><em>CCD Algorithm</em></a>. <br /><br /> + [name] solves Inverse Kinematics Problem with CCD Algorithm. + [name] is designed to work with [page:SkinnedMesh] loaded by [page:MMDLoader] but also can be used for generic [page:SkinnedMesh]. + </p> + + <h2>Example</h2> + + <code> + var ikSolver; + + // Load MMD resources and instantiate CCDIKSolver + new THREE.MMDLoader().load( + 'models/mmd/miku.pmd', + function ( mesh ) { + + ikSolver = new CCDIKSolver( mesh, mesh.geometry.iks ); + scene.add( mesh ); + + } + ); + + function render() { + + animate(); // update bones + if ( ikSolver !== undefined ) ikSolver.update(); + renderer.render( scene, camera ); + + } + </code> + + [example:webgl_loader_mmd]<br /> + [example:webgl_loader_mmd_pose]<br /> + [example:webgl_loader_mmd_audio]<br /> + + <br /> + <hr> + + <h2>Constructor</h2> + + <h3>[name]( [param:SkinnedMesh mesh], [param:Array iks] )</h3> + <p> + [page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] solves IK problem.<br /> + [page:Array iks] — An array of [page:Object] specifying IK parameter. target, effector, and link-index are index integers in .skeleton.bones. + The bones relation should be "links[ n ], links[ n - 1 ], ..., links[ 0 ], effector" in order from parent to child.<br /> + <ul> + <li>[page:Integer target] — Target bone.</li> + <li>[page:Integer effector] — Effector bone.</li> + <li>[page:Array links] — An array of [page: Object] specifying link bones. + <ul> + <li>[page:Integer index] — Link bone.</li> + <li>[page:Vector3 limitation] — (optional) Rotation axis. Default is undefined.</li> + <li>[page:Boolean enabled] — (optional) Default is true.</li> + </ul> + </li> + <li>[page:Integer iteration] — (optional) Iteration number of calculation. Smaller is faster but less precise. Default is 1.</li> + <li>[page:Number minAngle] — (optional) Minimum rotation angle in a step. Default is undefined.</li> + <li>[page:Number maxAngle] — (optional) Maximum rotation angle in a step. Default is undefined.</li> + </ul> + </p> + <p> + Creates a new [name]. + </p> + + <h2>Properties</h2> + + <h3>[property:Array iks]</h3> + <p>An array of IK parameter passed to the constructor.</p> + + <h3>[property:SkinnedMesh mesh]</h3> + <p>[page:SkinnedMesh] passed to the constructor.</p> + + <h2>Methods</h2> + + <h3>[method:CCDIKHelper createHelper]()</h3> + <p> + Return [page:CCDIKHelper]. You can visualize IK bones by adding the helper to scene. + </p> + + <h3>[method:CCDIKSolver update]()</h3> + <p> + Update bones quaternion by solving CCD algorithm. + </p> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/CCDIKSolver.js examples/js/animation/CCDIKSolver.js] + </body> +</html>
false
Other
mrdoob
three.js
202bbb3422e0884db972df6d022dec11393f7e99.json
fix minor issue #13988
src/extras/core/Font.js
@@ -40,7 +40,7 @@ Object.assign( Font.prototype, { function createPaths( text, size, divisions, data ) { - var chars = String( text ).split( '' ); + var chars = Array.from ? Array.from( text ) : String( text ).split( '' ); // see #13988 var scale = size / data.resolution; var line_height = ( data.boundingBox.yMax - data.boundingBox.yMin + data.underlineThickness ) * scale;
false
Other
mrdoob
three.js
a355aa803bb47d0725bf17bf39e9a0a8865e981b.json
use var instead of const
src/math/Box3.js
@@ -564,31 +564,31 @@ Object.assign( Box3.prototype, { // transform of empty box is an empty box. if ( this.isEmpty( ) ) return this; - const m = matrix.elements; + var m = matrix.elements; - const xax = m[ 0 ] * this.min.x; - const xay = m[ 1 ] * this.min.x; - const xaz = m[ 2 ] * this.min.x; + var xax = m[ 0 ] * this.min.x; + var xay = m[ 1 ] * this.min.x; + var xaz = m[ 2 ] * this.min.x; - const xbx = m[ 0 ] * this.max.x; - const xby = m[ 1 ] * this.max.x; - const xbz = m[ 2 ] * this.max.x; + var xbx = m[ 0 ] * this.max.x; + var xby = m[ 1 ] * this.max.x; + var xbz = m[ 2 ] * this.max.x; - const yax = m[ 4 ] * this.min.y; - const yay = m[ 5 ] * this.min.y; - const yaz = m[ 6 ] * this.min.y; + var yax = m[ 4 ] * this.min.y; + var yay = m[ 5 ] * this.min.y; + var yaz = m[ 6 ] * this.min.y; - const ybx = m[ 4 ] * this.max.y; - const yby = m[ 5 ] * this.max.y; - const ybz = m[ 6 ] * this.max.y; + var ybx = m[ 4 ] * this.max.y; + var yby = m[ 5 ] * this.max.y; + var ybz = m[ 6 ] * this.max.y; - const zax = m[ 8 ] * this.min.z; - const zay = m[ 9 ] * this.min.z; - const zaz = m[ 10 ] * this.min.z; + var zax = m[ 8 ] * this.min.z; + var zay = m[ 9 ] * this.min.z; + var zaz = m[ 10 ] * this.min.z; - const zbx = m[ 8 ] * this.max.z; - const zby = m[ 9 ] * this.max.z; - const zbz = m[ 10 ] * this.max.z; + var zbx = m[ 8 ] * this.max.z; + var zby = m[ 9 ] * this.max.z; + var zbz = m[ 10 ] * this.max.z; this.min.x = Math.min( xax, xbx ) + Math.min( yax, ybx ) + Math.min( zax, zbx ) + m[ 12 ]; this.min.y = Math.min( xay, xby ) + Math.min( yay, yby ) + Math.min( zay, zby ) + m[ 13 ];
false
Other
mrdoob
three.js
0aa9bac390903430b7f1c8b675382e44326e352b.json
Add .getBoneByName() to Skeleton Doc
docs/api/objects/Skeleton.html
@@ -103,6 +103,13 @@ <h3>[method:null update]()</h3> This is called automatically by the [page:WebGLRenderer] if the skeleton is used with a [page:SkinnedMesh]. </div> + <h3>[method:Bone getBoneByName]( [param:String name] )</h3> + <div> + 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 /> + </div> + <h2>Source</h2> [link:https://github.com/mrdoob/three.js/blob/master/src/[path].js src/[path].js]
false
Other
mrdoob
three.js
45ea96769e67036a5bfda88b41aa86ce609944a4.json
translate this passage.
docs/api/zh/deprecated/DeprecatedList.html
@@ -15,15 +15,10 @@ <h1>已被弃用API列表(Deprecated API List)</h1> 下面就列举出了这些API元素,以及一些关于他们的替代信息。 </p> - - - - - - - - - + + + + <h2>音频(Audio)</h2> <h3>[page:Audio]</h3> @@ -36,15 +31,9 @@ <h3>[page:BinaryTextureLoader]</h3> <p>BinaryTextureLoader 已被重命名为 [page:DataTextureLoader].</p> - - - - - - - - - + + + <h2>缓冲器(Buffers)</h2> <h3>[page:BufferAttribute]</h3> @@ -186,7 +175,7 @@ <h3>[page:GeometryUtils]</h3> <p> GeometryUtils.merge 已被移动到了 [page:Geometry]. 请使用[page:Geometry.merge]( geometry2, matrix, materialIndexOffset )。<br /><br /> - GeometryUtils.center 已被移动到了 [page:Geometry]. 请使用[page:Geometry.center]( ) instead. + GeometryUtils.center 已被移动到了 [page:Geometry]. 请使用[page:Geometry.center]( ) 。 </p> <h3>[page:Plane]</h3> @@ -297,7 +286,7 @@ <h3>[page:Line3]</h3> <h3>[page:Math]</h3> <p> - Math.random16() 已被弃用。 请使用Math.random() instead. + Math.random16() 已被弃用。 请使用Math.random() 。 </p> <h3>[page:Matrix3]</h3> @@ -345,7 +334,7 @@ <h3>[page:Matrix4]</h3> Matrix4.applyToVector3Array() 已被删除。<br /><br /> - Matrix4.makeFrustum() 已被删除。 请使用[page:Matrix4.makePerspective]( left, right, top, bottom, near, far ) instead. + Matrix4.makeFrustum() 已被删除。 请使用[page:Matrix4.makePerspective]( left, right, top, bottom, near, far ) 。 </p> @@ -452,7 +441,7 @@ <h3>[page:ShaderMaterial.derivatives]</h3> - <h2>Objects</h2> + <h2>物体(Objects)</h2> <h3>[page:LOD.objects]</h3> <p>LOD.objects 已被重命名为 [page:LOD.levels].</p> @@ -489,7 +478,7 @@ <h3>[page:Shape]</h3> <p> Shape.extrude 已被删除。 请使用[page:ExtrudeGeometry]。<br /><br /> - Shape.makeGeometry 已被删除。 请使用[page:ShapeGeometry] instead. + Shape.makeGeometry 已被删除。 请使用[page:ShapeGeometry] 。 </p> @@ -561,13 +550,13 @@ <h3>[page:WebGLRenderer]</h3> WebGLRenderer.shadowMapType 现在是 [page:WebGLRenderer.shadowMap.type].<br /><br /> - WebGLRenderer.shadowMapCullFace 已被删除。 Set [page:Material.shadowSide]。<br /><br /> + WebGLRenderer.shadowMapCullFace 已被删除。请设置[page:Material.shadowSide]。<br /><br /> - WebGLRenderer.shadowMap.cullFace 已被删除。 Set [page:Material.shadowSide]。<br /><br /> + WebGLRenderer.shadowMap.cullFace 已被删除。请设置[page:Material.shadowSide]。<br /><br /> - WebGLRenderer.shadowMap.renderReverseSided 已被删除。 Set [page:Material.shadowSide]。<br /><br /> + WebGLRenderer.shadowMap.renderReverseSided 已被删除。请设置[page:Material.shadowSide]。<br /><br /> - WebGLRenderer.shadowMap.renderSingleSided 已被删除。 Set [page:Material.shadowSide] instead. + WebGLRenderer.shadowMap.renderSingleSided 已被删除。请设置[page:Material.shadowSide]。 </p> @@ -605,7 +594,7 @@ <h3>[page:ImageUtils]</h3> ImageUtils.loadCompressedTexture 已被删除。 请使用[page:DDSLoader]。<br /><br /> - ImageUtils.loadCompressedTextureCube 已被删除。 请使用[page:DDSLoader] instead. + ImageUtils.loadCompressedTextureCube 已被删除。 请使用[page:DDSLoader] 。 </p>
false
Other
mrdoob
three.js
bfefe8a38ccee9f2069e78b376836801afcc0fbf.json
Correct some expression in the passage
docs/manual/zh/introduction/Useful-links.html
@@ -23,7 +23,7 @@ <h1>一些有用的链接([name])</h1><br /> <h2>帮助论坛</h2> <p> Three.js官方使用[link:http://stackoverflow.com/tags/three.js/info Stack Overflow]来处理帮助请求。 - 如果你需要一些帮助,这才是你所要去的地方。请*一定不要*在GitHub上提issue来寻求帮助。 + 如果你需要一些帮助,这才是你所要去的地方。请<strong>一定不要</strong>在GitHub上提issue来寻求帮助。 </p> @@ -63,7 +63,7 @@ <h3>更加广泛、高级的文章与教程</h3> </li> </ul> - <h3>其他语言的教程</h3> + <h3>其它非英语的教程</h3> <ul> <li> [link:http://www.natural-science.or.jp/article/20120220155529.php Building A Physics Simulation Environment] - three.js tutorial in Japanese
false
Other
mrdoob
three.js
9d382d6f664720486beca0b937f70c1ba545cacc.json
fix soft tabs
test/unit/src/animation/AnimationAction.tests.js
@@ -13,19 +13,19 @@ import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants'; function createAnimation(){ - var root = new Object3D(); + var root = new Object3D(); var mixer = new AnimationMixer(root); var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); var clip = new AnimationClip( "clip1", 1000, [track] ); - var animationAction = mixer.clipAction( clip ); - return { - root: root, - mixer: mixer, - track: track, - clip: clip, - animationAction: animationAction - }; + var animationAction = mixer.clipAction( clip ); + return { + root: root, + mixer: mixer, + track: track, + clip: clip, + animationAction: animationAction + }; } @@ -306,25 +306,25 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "getMixer", ( assert ) => { - var { mixer, animationAction } = createAnimation(); - var mixer2 = animationAction.getMixer(); - assert.equal( mixer, mixer2, "mixer should be returned by getMixer." ); + var { mixer, animationAction } = createAnimation(); + var mixer2 = animationAction.getMixer(); + assert.equal( mixer, mixer2, "mixer should be returned by getMixer." ); } ); - QUnit.test("getClip", (assert) => { + QUnit.test("getClip", (assert) => { - var { clip, animationAction } = createAnimation(); - var clip2 = animationAction.getClip(); - assert.equal( clip, clip2, "clip should be returned by getClip." ); + var { clip, animationAction } = createAnimation(); + var clip2 = animationAction.getClip(); + assert.equal( clip, clip2, "clip should be returned by getClip." ); } ); QUnit.test( "getRoot", ( assert ) => { - var { root, animationAction } = createAnimation(); - var root2 = animationAction.getRoot(); - assert.equal(root, root2, "root should be returned by getRoot." ); + var { root, animationAction } = createAnimation(); + var root2 = animationAction.getRoot(); + assert.equal(root, root2, "root should be returned by getRoot." ); } );
false
Other
mrdoob
three.js
c802a474795da6d60ae82533e57e138e76d0f5c4.json
Add test for getMixer, getClip & getRoot
test/unit/src/animation/AnimationAction.tests.js
@@ -13,13 +13,19 @@ import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants'; function createAnimation(){ - - var mixer = new AnimationMixer(new Object3D()); + var root = new Object3D(); + var mixer = new AnimationMixer(root); var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); var clip = new AnimationClip( "clip1", 1000, [track] ); - var animationAction = new AnimationAction( mixer, clip ); - return { mixer :mixer,track:track,clip:clip,animationAction:animationAction}; + var animationAction = mixer.clipAction( clip ); + return { + root: root, + mixer: mixer, + track: track, + clip: clip, + animationAction: animationAction + }; } @@ -298,21 +304,27 @@ export default QUnit.module( 'Animation', () => { } ); - QUnit.todo( "getMixer", ( assert ) => { + QUnit.test( "getMixer", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var { mixer, animationAction } = createAnimation(); + var mixer2 = animationAction.getMixer(); + assert.equal( mixer, mixer2, "mixer should be returned by getMixer." ); } ); - QUnit.todo( "getClip", ( assert ) => { + QUnit.test("getClip", (assert) => { - assert.ok( false, "everything's gonna be alright" ); + var { clip, animationAction } = createAnimation(); + var clip2 = animationAction.getClip(); + assert.equal( clip, clip2, "clip should be returned by getClip." ); } ); - QUnit.todo( "getRoot", ( assert ) => { + QUnit.test( "getRoot", ( assert ) => { - assert.ok( false, "everything's gonna be alright" ); + var { root, animationAction } = createAnimation(); + var root2 = animationAction.getRoot(); + assert.equal(root, root2, "root should be returned by getRoot." ); } );
false
Other
mrdoob
three.js
15e41aff657691220528fcd7f2c4f02572055e86.json
Simplify image parsing
examples/js/loaders/FBXLoader.js
@@ -163,14 +163,11 @@ // Parse FBXTree.Objects.Video for embedded image data // These images are connected to textures in FBXTree.Objects.Textures - // via FBXTree.Connections. Note that images can be duplicated here, in which case only one - // may have a .Content field - we'll check for this and duplicate the data in the imageMap + // via FBXTree.Connections. function parseImages( FBXTree ) { - var imageMap = new Map(); - - var names = {}; - var duplicates = []; + var images = {}; + var blobs = {}; if ( 'Video' in FBXTree.Objects ) { @@ -182,51 +179,38 @@ var id = parseInt( nodeID ); - // check whether the file name is used by another videoNode - // and if so keep a record of both ids as a duplicate pair [ id1, id2 ] - if ( videoNode.FileName in names ) { + images[ id ] = videoNode.Filename; - duplicates.push( [ id, names[ videoNode.FileName ] ] ); + // raw image data is in videoNode.Content + if ( 'Content' in videoNode ) { - } + var arrayBufferContent = ( videoNode.Content instanceof ArrayBuffer ) && ( videoNode.Content.byteLength > 0 ); + var base64Content = ( typeof videoNode.Content === 'string' ) && ( videoNode.Content !== '' ); - names[ videoNode.FileName ] = id; + if ( arrayBufferContent || base64Content ) { - // raw image data is in videoNode.Content - if ( 'Content' in videoNode && videoNode.Content !== '' ) { + var image = parseImage( videoNodes[ nodeID ] ); - var image = parseImage( videoNodes[ nodeID ] ); + blobs[ videoNode.Filename ] = image; - imageMap.set( id, image ); + } } } } + for ( var id in images ) { - // check each duplicate pair - if only one is in the image map then - // create an entry for the other id containing the same image data - // Note: it seems to be possible for entries to have the same file name but different - // content, we won't overwrite these - duplicates.forEach( function ( duplicatePair ) { - - if ( imageMap.has( duplicatePair[ 0 ] ) && ! imageMap.has( duplicatePair[ 1 ] ) ) { - - var image = imageMap.get( duplicatePair[ 0 ] ); - imageMap.set( duplicatePair[ 1 ], image ); + var filename = images[ id ]; - } else if ( imageMap.has( duplicatePair[ 1 ] ) && ! imageMap.has( duplicatePair[ 0 ] ) ) { + if ( blobs[ filename ] !== undefined ) images[ id ] = blobs[ filename ]; + else images[ id ] = images[ id ].split( '\\' ).pop(); - var image = imageMap.get( duplicatePair[ 1 ] ); - imageMap.set( duplicatePair[ 0 ], image ); - - } - - } ); + } - return imageMap; + return images; } @@ -285,7 +269,7 @@ // Parse nodes in FBXTree.Objects.Texture // These contain details such as UV scaling, cropping, rotation etc and are connected // to images in FBXTree.Objects.Video - function parseTextures( FBXTree, loader, imageMap, connections ) { + function parseTextures( FBXTree, loader, images, connections ) { var textureMap = new Map(); @@ -294,7 +278,7 @@ var textureNodes = FBXTree.Objects.Texture; for ( var nodeID in textureNodes ) { - var texture = parseTexture( textureNodes[ nodeID ], loader, imageMap, connections ); + var texture = parseTexture( textureNodes[ nodeID ], loader, images, connections ); textureMap.set( parseInt( nodeID ), texture ); } @@ -306,9 +290,9 @@ } // Parse individual node in FBXTree.Objects.Texture - function parseTexture( textureNode, loader, imageMap, connections ) { + function parseTexture( textureNode, loader, images, connections ) { - var texture = loadTexture( textureNode, loader, imageMap, connections ); + var texture = loadTexture( textureNode, loader, images, connections ); texture.ID = textureNode.id; @@ -340,40 +324,15 @@ } // load a texture specified as a blob or data URI, or via an external URL using THREE.TextureLoader - function loadTexture( textureNode, loader, imageMap, connections ) { + function loadTexture( textureNode, loader, images, connections ) { var fileName; - var filePath = textureNode.FileName; - var relativeFilePath = textureNode.RelativeFilename; - var children = connections.get( textureNode.id ).children; - if ( children !== undefined && children.length > 0 && imageMap.has( children[ 0 ].ID ) ) { + if ( children !== undefined && children.length > 0 && images[ children[ 0 ].ID ] !== undefined ) { - fileName = imageMap.get( children[ 0 ].ID ); - - } - // check that relative path is not an actually an absolute path and if so use it to load texture - else if ( relativeFilePath !== undefined && relativeFilePath[ 0 ] !== '/' && relativeFilePath.match( /^[a-zA-Z]:/ ) === null ) { - - fileName = relativeFilePath; - - } - // texture specified by absolute path - else { - - var split = filePath.split( /[\\\/]/ ); - - if ( split.length > 0 ) { - - fileName = split[ split.length - 1 ]; - - } else { - - fileName = filePath; - - } + fileName = images[ children[ 0 ].ID ]; } @@ -2396,21 +2355,21 @@ var tracks = []; - if ( rawTracks.T !== undefined && Object.keys( rawTracks.T.curves ).length > 0 ) { + if ( rawTracks.T !== undefined ) { var positionTrack = generateVectorTrack( rawTracks.modelName, rawTracks.T.curves, rawTracks.initialPosition, 'position' ); if ( positionTrack !== undefined ) tracks.push( positionTrack ); } - if ( rawTracks.R !== undefined && Object.keys( rawTracks.R.curves ).length > 0 ) { + if ( rawTracks.R !== undefined ) { var rotationTrack = generateRotationTrack( rawTracks.modelName, rawTracks.R.curves, rawTracks.initialRotation, rawTracks.preRotations ); if ( rotationTrack !== undefined ) tracks.push( rotationTrack ); } - if ( rawTracks.S !== undefined && Object.keys( rawTracks.S.curves ).length > 0 ) { + if ( rawTracks.S !== undefined ) { var scaleTrack = generateVectorTrack( rawTracks.modelName, rawTracks.S.curves, rawTracks.initialScale, 'scale' ); if ( scaleTrack !== undefined ) tracks.push( scaleTrack );
false
Other
mrdoob
three.js
f8c0af8748e9046a5e8700c18517ebd09839e210.json
Add unit test for clipTime in AnimationAtion
test/unit/src/animation/AnimationAction.tests.js
@@ -16,9 +16,9 @@ function createAnimation(){ var mixer = new AnimationMixer(new Object3D()); var track = new NumberKeyframeTrack( ".rotation[x]", [ 0, 1000 ], [ 0, 360 ] ); - var clip = new AnimationClip( "clip1", 1000, [track] ); + var clip = new AnimationClip( "clip1", 1000, [track] ); - var animationAction = new AnimationAction( mixer, clip ); + var animationAction = new AnimationAction( mixer, clip ); return { mixer :mixer,track:track,clip:clip,animationAction:animationAction}; } @@ -189,7 +189,26 @@ export default QUnit.module( 'Animation', () => { mixer.update(1000); assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); mixer.update(1000); - assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it is not running anymore." ); + assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); + + } ); + + QUnit.test( "setLoop LoopPingPong", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + animationAction.setLoop(LoopPingPong,3); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(500); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(1000); + assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.ok( animationAction.isRunning(), "When an animation is in fourth loop when in looprepeat 3 times, it is running." ); mixer.update(1000); assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." );
false
Other
mrdoob
three.js
184db4b62adcb62b49f604289a81f5393119243a.json
tabify the issues
test/unit/src/animation/AnimationAction.tests.js
@@ -41,7 +41,7 @@ export default QUnit.module( 'Animation', () => { // PUBLIC STUFF QUnit.test( "play", ( assert ) => { - var {mixer,animationAction} = createAnimation(); + var {mixer,animationAction} = createAnimation(); var animationAction2 = animationAction.play(); assert.equal( animationAction, animationAction2, "AnimationAction.play can be chained." ); @@ -69,7 +69,7 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "stop", ( assert ) => { - var {mixer,animationAction} = createAnimation(); + var {mixer,animationAction} = createAnimation(); var animationAction2 = animationAction.stop(); assert.equal( animationAction, animationAction2, "AnimationAction.stop can be chained." ); @@ -97,7 +97,7 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "reset", ( assert ) => { - var {mixer,animationAction} = createAnimation(); + var {mixer,animationAction} = createAnimation(); var animationAction2 = animationAction.stop(); assert.equal( animationAction, animationAction2, "AnimationAction.reset can be chained." ); assert.equal( animationAction2.paused, false, "AnimationAction.reset() sets paused false" ); @@ -110,19 +110,19 @@ export default QUnit.module( 'Animation', () => { QUnit.test( "isRunning", ( assert ) => { - var {mixer,animationAction} = createAnimation(); + var {mixer,animationAction} = createAnimation(); assert.notOk( animationAction.isRunning(), "When an animation is just made, it is not running." ); - animationAction.play(); + animationAction.play(); assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); - animationAction.stop(); + animationAction.stop(); assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); - animationAction.play(); - animationAction.paused = true; + animationAction.play(); + animationAction.paused = true; assert.notOk( animationAction.isRunning(), "When an animation is paused, it is not running." ); - animationAction.paused = false; - animationAction.enabled = false; + animationAction.paused = false; + animationAction.enabled = false; assert.notOk( animationAction.isRunning(), "When an animation is not enabled, it is not running." ); - animationAction.enabled = true; + animationAction.enabled = true; assert.ok( animationAction.isRunning(), "When an animation is enabled, it is running." ); } ); @@ -131,67 +131,67 @@ export default QUnit.module( 'Animation', () => { var {mixer,animationAction} = createAnimation(); assert.notOk( animationAction.isScheduled(), "When an animation is just made, it is not scheduled." ); - animationAction.play(); - assert.ok( animationAction.isScheduled(), "When an animation is started, it is scheduled." ); - mixer.update(1); - assert.ok( animationAction.isScheduled(), "When an animation is updated, it is scheduled." ); - animationAction.stop(); - assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it isn't scheduled anymore." ); - - + animationAction.play(); + assert.ok( animationAction.isScheduled(), "When an animation is started, it is scheduled." ); + mixer.update(1); + assert.ok( animationAction.isScheduled(), "When an animation is updated, it is scheduled." ); + animationAction.stop(); + assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it isn't scheduled anymore." ); + + } ); QUnit.test( "startAt", ( assert ) => { var {mixer,animationAction} = createAnimation(); - animationAction.startAt(2); - animationAction.play(); - assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time, it is not running." ); + animationAction.startAt(2); + animationAction.play(); + assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time, it is not running." ); assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time, it is scheduled." ); - mixer.update(1); - assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time and the interval is not passed, it is not running." ); + mixer.update(1); + assert.notOk( animationAction.isRunning(), "When an animation is started at a specific time and the interval is not passed, it is not running." ); assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is not passed, it is scheduled." ); - mixer.update(1); - assert.ok( animationAction.isRunning(), "When an animation is started at a specific time and the interval is passed, it is running." ); + mixer.update(1); + assert.ok( animationAction.isRunning(), "When an animation is started at a specific time and the interval is passed, it is running." ); assert.ok( animationAction.isScheduled(), "When an animation is started at a specific time and the interval is passed, it is scheduled." ); - animationAction.stop(); - assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); + animationAction.stop(); + assert.notOk( animationAction.isRunning(), "When an animation is stopped, it is not running." ); assert.notOk( animationAction.isScheduled(), "When an animation is stopped, it is not scheduled." ); - + } ); QUnit.test( "setLoop LoopOnce", ( assert ) => { var {mixer,animationAction} = createAnimation(); - animationAction.setLoop(LoopOnce); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + animationAction.setLoop(LoopOnce); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); mixer.update(500); - assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); mixer.update(500); - assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); mixer.update(500); - assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); } ); QUnit.test( "setLoop LoopRepeat", ( assert ) => { var {mixer,animationAction} = createAnimation(); - animationAction.setLoop(LoopRepeat,3); - animationAction.play(); - assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + animationAction.setLoop(LoopRepeat,3); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); mixer.update(500); - assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); + assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); mixer.update(1000); - assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); + assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); mixer.update(1000); - assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it is not running anymore." ); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it is not running anymore." ); mixer.update(1000); - assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); } );
false
Other
mrdoob
three.js
cc8d54c1a81e350f89d094a42e342508ec476fd0.json
add Test for setLoop (LoopOnce,LoopRepeat)
test/unit/src/animation/AnimationAction.tests.js
@@ -8,6 +8,7 @@ import { AnimationMixer } from '../../../../src/animation/AnimationMixer'; import { AnimationClip } from '../../../../src/animation/AnimationClip'; import { NumberKeyframeTrack } from '../../../../src/animation/tracks/NumberKeyframeTrack'; import { Object3D } from '../../../../src/core/Object3D'; +import { LoopOnce, LoopRepeat, LoopPingPong } from '../../../../src/constants'; function createAnimation(){ @@ -160,10 +161,38 @@ export default QUnit.module( 'Animation', () => { } ); - QUnit.todo( "setLoop", ( assert ) => { - - assert.ok( false, "everything's gonna be alright" ); + QUnit.test( "setLoop LoopOnce", ( assert ) => { + var {mixer,animationAction} = createAnimation(); + animationAction.setLoop(LoopOnce); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(500); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(500); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + mixer.update(500); + assert.notOk( animationAction.isRunning(), "When an animation is ended, it is not running." ); + + } ); + + QUnit.test( "setLoop LoopRepeat", ( assert ) => { + + var {mixer,animationAction} = createAnimation(); + animationAction.setLoop(LoopRepeat,3); + animationAction.play(); + assert.ok( animationAction.isRunning(), "When an animation is started, it is running." ); + mixer.update(500); + assert.ok( animationAction.isRunning(), "When an animation is in the first loop, it is running." ); + mixer.update(1000); + assert.ok( animationAction.isRunning(), "When an animation is in second loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.ok( animationAction.isRunning(), "When an animation is in third loop when in looprepeat 3 times, it is running." ); + mixer.update(1000); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it is not running anymore." ); + mixer.update(1000); + assert.notOk( animationAction.isRunning(), "When an animation ended his third loop when in looprepeat 3 times, it stays not running anymore." ); + } ); QUnit.todo( "setEffectiveWeight", ( assert ) => {
false
Other
mrdoob
three.js
17791a42c5af98dd981311615c87b4c2dbad8589.json
Allow instantiating WebGLTextures from a worker
src/renderers/webgl/WebGLTextures.js
@@ -7,7 +7,7 @@ import { _Math } from '../../math/Math.js'; function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, infoMemory ) { - var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof window.WebGL2RenderingContext ); + var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext ); var _videoTextures = {}; //
false
Other
mrdoob
three.js
a67575ea404363af75728f963f7fe2d658c1aec0.json
remove conditions that are always true
examples/js/loaders/XLoader.js
@@ -1480,7 +1480,6 @@ var model = _model; var animation = _animation; - var bindFlag = _isBind ? _isBind : true; if ( ! model ) { model = this.Meshes[ 0 ]; @@ -1565,16 +1564,14 @@ model.geometry.animations = []; } - if ( bindFlag ) { - model.geometry.animations.push( THREE.AnimationClip.parseAnimation( put, model.skeleton.bones ) ); - if ( ! model.animationMixer ) { + model.geometry.animations.push( THREE.AnimationClip.parseAnimation( put, model.skeleton.bones ) ); + if ( ! model.animationMixer ) { - model.animationMixer = new THREE.AnimationMixer( model ); - - } + model.animationMixer = new THREE.AnimationMixer( model ); } + return put; }
false
Other
mrdoob
three.js
bd76c7a3ecce17b8bf3004e4cc626f6ec8966e85.json
Improve code readability This also fixes https://lgtm.com/projects/g/mrdoob/three.js/snapshot/c47fb709c7f969c42bb0b8bb2316a8cf8a53754c/files/examples/js/loaders/AssimpLoader.js?sort=name&dir=ASC&mode=heatmap&excluded=false#x3eeae27c070bf750:1
examples/js/loaders/AssimpLoader.js
@@ -1128,26 +1128,30 @@ THREE.AssimpLoader.prototype = { } - if ( ! key ) return null; + if ( ! key ) { + + return null; - if ( key && nextKey ) { + } else if ( nextKey ) { var dT = nextKey.mTime - key.mTime; var T = key.mTime - time; var l = T / dT; return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l ); - } + } else { - nextKey = keys[ 0 ].clone(); - nextKey.mTime += lne; + nextKey = keys[ 0 ].clone(); + nextKey.mTime += lne; - var dT = nextKey.mTime - key.mTime; - var T = key.mTime - time; - var l = T / dT; + var dT = nextKey.mTime - key.mTime; + var T = key.mTime - time; + var l = T / dT; - return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l ); + return lerp( key.mValue.toTHREE(), nextKey.mValue.toTHREE(), l ); + + } }
false
Other
mrdoob
three.js
e5bceae52dc1322ea0a32a266ece8520e717a803.json
make objects shinier
examples/webgl_postprocessing_pixel.html
@@ -129,7 +129,7 @@ var geom = geomData[ Math.floor( Math.random() * geomData.length ) ]; var color = new THREE.Color(); color.setHSL( Math.random(), .7 + .2 * Math.random(), .5 + .1 * Math.random() ); - var mat = new THREE.MeshPhongMaterial( { color: color } ); + var mat = new THREE.MeshPhongMaterial( { color: color, shininess: 200 } ); var mesh = new THREE.Mesh( geom, mat ); var s = 4 + Math.random() * 10; mesh.scale.set( s, s, s );
false
Other
mrdoob
three.js
aa30c4cd507dd7be90a21e9c553a0229b90ce4ef.json
add extra space on bottom
examples/webgl_postprocessing_pixel.html
@@ -181,7 +181,6 @@ init(); animate(); - </script> </body> </html>
false
Other
mrdoob
three.js
1a197e68abf918ca2804de5958815dbd8c0f7b84.json
remove shadows and fix formatting
examples/webgl_postprocessing_pixel.html
@@ -77,8 +77,6 @@ var container = document.getElementById( 'container' ); renderer = new THREE.WebGLRenderer({antialias: true}); - renderer.shadowMap.enabled = true; - renderer.shadowMap.type = THREE.PCSoftShadowMap; renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight); renderer.setClearColor(0xbfe7ff); @@ -99,24 +97,11 @@ shadowLight.position.set(150, 75, 150); - shadowLight.castShadow = true; - shadowLight.shadow.camera.left = -75; - shadowLight.shadow.camera.right = 75; - shadowLight.shadow.camera.top = 75; - shadowLight.shadow.camera.bottom = -75; - shadowLight.shadow.camera.near = 1; - shadowLight.shadow.camera.far = 1000; - - shadowLight.shadow.mapSize.width = 1024; - shadowLight.shadow.mapSize.height = 1024; - var shadowLight2 = shadowLight.clone(); - shadowLight2.castShadow = false; shadowLight2.intensity = .2; shadowLight2.position.set(-150, 75, -150); var shadowLight3 = shadowLight.clone(); - shadowLight3.castShadow = false; shadowLight3.intensity = .1; shadowLight3.position.set(0, 125, 0); @@ -125,11 +110,11 @@ scene.add(shadowLight2); scene.add(shadowLight3); - geomData.push(new THREE.SphereGeometry(1, 64, 64)); - geomData.push(new THREE.BoxGeometry(1, 1, 1,)); - geomData.push(new THREE.ConeGeometry(1, 1, 32)); - geomData.push(new THREE.TetrahedronGeometry(1)); - geomData.push(new THREE.TorusKnotGeometry(1, .4)); + geomData.push( new THREE.SphereGeometry( 1, 64, 64 ) ); + geomData.push( new THREE.BoxGeometry( 1, 1, 1 ) ); + geomData.push( new THREE.ConeGeometry( 1, 1, 32 ) ); + geomData.push( new THREE.TetrahedronGeometry( 1 ) ); + geomData.push( new THREE.TorusKnotGeometry( 1, .4 ) ); var numShapes = 25; group = new THREE.Group();
false
Other
mrdoob
three.js
dbb5835931db11dbab1737c6a3f5b8e789bc5c95.json
Add Sprite pivot property
docs/api/objects/Sprite.html
@@ -57,7 +57,12 @@ <h3>[property:SpriteMaterial material]</h3> </div> - <h2>Methods</h2> + <h3>[property:Vector2 pivot]</h3> + <div> + The origin of the sprite, and the point around which the sprite rotates. The lower-left is (-0.5, -0.5). The upper-right is (0.5, 0.5). The default is (0.0, 0.0), the center of the sprite. + </div> + + <h2>Methods</h2> <div>See the base [page:Object3D] class for common methods.</div> <h3>[method:Sprite clone]()</h3>
true
Other
mrdoob
three.js
dbb5835931db11dbab1737c6a3f5b8e789bc5c95.json
Add Sprite pivot property
examples/webgl_sprites.html
@@ -119,22 +119,27 @@ var height = material.map.image.height; spriteTL = new THREE.Sprite( material ); + spriteTL.pivot.set( - 0.5, 0.5 ); spriteTL.scale.set( width, height, 1 ); sceneOrtho.add( spriteTL ); spriteTR = new THREE.Sprite( material ); + spriteTR.pivot.set( 0.5, 0.5 ); spriteTR.scale.set( width, height, 1 ); sceneOrtho.add( spriteTR ); spriteBL = new THREE.Sprite( material ); + spriteBL.pivot.set( - 0.5, - 0.5 ); spriteBL.scale.set( width, height, 1 ); sceneOrtho.add( spriteBL ); spriteBR = new THREE.Sprite( material ); + spriteBR.pivot.set( 0.5, - 0.5 ); spriteBR.scale.set( width, height, 1 ); sceneOrtho.add( spriteBR ); spriteC = new THREE.Sprite( material ); + spriteC.pivot.set( 0, 0 ); spriteC.scale.set( width, height, 1 ); sceneOrtho.add( spriteC ); @@ -147,16 +152,11 @@ var width = window.innerWidth / 2; var height = window.innerHeight / 2; - var material = spriteTL.material; - - var imageWidth = material.map.image.width / 2; - var imageHeight = material.map.image.height / 2; - - spriteTL.position.set( - width + imageWidth, height - imageHeight, 1 ); // top left - spriteTR.position.set( width - imageWidth, height - imageHeight, 1 ); // top right - spriteBL.position.set( - width + imageWidth, - height + imageHeight, 1 ); // bottom left - spriteBR.position.set( width - imageWidth, - height + imageHeight, 1 ); // bottom right - spriteC.position.set( 0, 0, 1 ); // center + spriteTL.position.set( - width, height, 1 ); // top left + spriteTR.position.set( width, height, 1 ); // top right + spriteBL.position.set( - width, - height, 1 ); // bottom left + spriteBR.position.set( width, - height, 1 ); // bottom right + spriteC.position.set( 0, 0, 1 ); // center }
true
Other
mrdoob
three.js
dbb5835931db11dbab1737c6a3f5b8e789bc5c95.json
Add Sprite pivot property
src/objects/Sprite.js
@@ -1,3 +1,4 @@ +import { Vector2 } from '../math/Vector2.js'; import { Vector3 } from '../math/Vector3.js'; import { Object3D } from '../core/Object3D.js'; import { SpriteMaterial } from '../materials/SpriteMaterial.js'; @@ -15,6 +16,8 @@ function Sprite( material ) { this.material = ( material !== undefined ) ? material : new SpriteMaterial(); + this.pivot = new Vector2( 0, 0 ); + } Sprite.prototype = Object.assign( Object.create( Object3D.prototype ), {
true
Other
mrdoob
three.js
dbb5835931db11dbab1737c6a3f5b8e789bc5c95.json
Add Sprite pivot property
src/renderers/webgl/WebGLSpriteRenderer.js
@@ -55,6 +55,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { uvScale: gl.getUniformLocation( program, 'uvScale' ), rotation: gl.getUniformLocation( program, 'rotation' ), + pivot: gl.getUniformLocation( program, 'pivot' ), scale: gl.getUniformLocation( program, 'scale' ), color: gl.getUniformLocation( program, 'color' ), @@ -171,6 +172,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { // render all sprites var scale = []; + var pivot = []; for ( var i = 0, l = sprites.length; i < l; i ++ ) { @@ -189,6 +191,9 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { scale[ 0 ] = spriteScale.x; scale[ 1 ] = spriteScale.y; + pivot[ 0 ] = sprite.pivot.x; + pivot[ 1 ] = sprite.pivot.y; + var fogType = 0; if ( scene.fog && material.fog ) { @@ -220,6 +225,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { gl.uniform3f( uniforms.color, material.color.r, material.color.g, material.color.b ); gl.uniform1f( uniforms.rotation, material.rotation ); + gl.uniform2fv( uniforms.pivot, pivot ); gl.uniform2fv( uniforms.scale, scale ); state.setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha ); @@ -259,6 +265,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { 'uniform mat4 modelViewMatrix;', 'uniform mat4 projectionMatrix;', 'uniform float rotation;', + 'uniform vec2 pivot;', 'uniform vec2 scale;', 'uniform vec2 uvOffset;', 'uniform vec2 uvScale;', @@ -273,7 +280,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { ' vUV = uvOffset + uv * uvScale;', - ' vec2 alignedPosition = position * scale;', + ' vec2 alignedPosition = ( position - pivot ) * scale;', ' vec2 rotatedPosition;', ' rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;',
true
Other
mrdoob
three.js
a064db482a032e3c1539eca99611777ae24b00b8.json
simplify getString method
examples/js/loaders/FBXLoader.js
@@ -3650,13 +3650,13 @@ getString: function ( size ) { - var a = new Uint8Array( size ); + var a = new Uint8Array( this.getUint8Array( size ) ); - for ( var i = 0; i < size; i ++ ) { + // for ( var i = 0; i < size; i ++ ) { - a[ i ] = this.getUint8(); + // a[ i ] = this.getUint8(); - } + // } return THREE.LoaderUtils.decodeText( a );
false
Other
mrdoob
three.js
0cd15ca493faf140fe0b73becfcf2273ae67a451.json
Revert a new line I have wrongly removed
examples/js/loaders/GLTFLoader.js
@@ -2051,6 +2051,7 @@ THREE.GLTFLoader = ( function () { geometries.push( geometry ); } + } return geometries;
false
Other
mrdoob
three.js
6e0892b963bfc3d0d1f1dc162804dafca2fb4f18.json
Update PDBLoader.js with Comments Added comments to better understand file parser and data structures in more detail.
examples/js/loaders/PDBLoader.js
@@ -4,7 +4,7 @@ */ THREE.PDBLoader = function ( manager ) { - + //add your own manager or use default manager this.manager = ( manager !== undefined ) ? manager : THREE.DefaultLoadingManager; }; @@ -49,23 +49,50 @@ THREE.PDBLoader.prototype = { } function parseBond( start, length ) { - + /* + + line1 CONECT 1 2 + 12345678901234567890123456789001234567890 + Siiii) + P1iii) + P2iii) + P3iii) + P4iii) + line2 CONECT 2 1 9 49 + + satomL1 = 1, satomL2 = 2 + P1 = eatomL1 = 2, eatomL2_i = 1, + P2 eatomL2_ii = 9 + P3 eatomL2_iii = 49 + P4 + + hL1 = s1e2 + hL2 = s1e2 X, s2e9, s2e49 + bhash = {s1e2: 0, s2e9: 1, s2e49: 2 ...} //bond connections + bonds = [ [0,1,1], [1, 8, 1], [1, 48, 1 ...] + + + */ + var eatom = parseInt( lines[ i ].substr( start, length ) ); if ( eatom ) { - + //Generate Hash Key from Starting Atom and Connecting End Atom corresponding Connection var h = hash( satom, eatom ); - + + //if already exists do not create, skip if ( bhash[ h ] === undefined ) { - + + //reduce satom and eatom connection by factor of 1 (single bond) bonds.push( [ satom - 1, eatom - 1, 1 ] ); - bhash[ h ] = bonds.length - 1; + bhash[ h ] = bonds.length - 1; //identifies bond entry in bonds[bhash[s1e2]] array (key: endpoints Index: bond) } else { // doesn't really work as almost all PDBs // have just normal bonds appearing multiple // times instead of being double/triple bonds + //increase last entry by 1, represents multiple bond // bonds[bhash[h]][2] += 1; } @@ -77,6 +104,11 @@ THREE.PDBLoader.prototype = { function buildGeometry() { var build = { + /* + This class is an efficient alternative to Geometry, because it stores all data, + including vertex positions, face indices, normals, colors, UVs, and custom attributes + within buffers; this reduces the cost of passing all this data to the GPU. + */ geometryAtoms: new THREE.BufferGeometry(), geometryBonds: new THREE.BufferGeometry(), json: { @@ -98,43 +130,70 @@ THREE.PDBLoader.prototype = { for ( i = 0, l = atoms.length; i < l; i ++ ) { + /* + //Array of Atoms, Arrays consisting of 4 entries: + [ [X-Coord, Y-Coord, Z-Coord, Color_Array[element_name], Element_Name], ... ] + + atoms.push( [ x, y, z, CPK[ e ], capitalize( e ) ] ); + */ + var atom = atoms[ i ]; - - var x = atom[ 0 ]; + + + var x = atom[ 0 ]; var y = atom[ 1 ]; var z = atom[ 2 ]; - + + // Array of Atoms Coord Positions verticesAtoms.push( x, y, z ); - + + + /* + Generate float value representations for each color channels for use + in Float32BufferAttribute for color: + THREE.Float32BufferAttribute( colorsAtoms, 3 ) in + geometryAtoms.addAttribute( 'color', new THREE.Float32BufferAttribute( colorsAtoms, 3 ) ); + where geometryAtoms is a BufferGeometry Object + + */ var r = atom[ 3 ][ 0 ] / 255; var g = atom[ 3 ][ 1 ] / 255; var b = atom[ 3 ][ 2 ] / 255; - + + //Generate Array of Color Float32 Arrays Entries for each Atom colorsAtoms.push( r, g, b ); } // bonds - + /* Graphite + bonds = [ [0,1,1], [1, 8, 1], [1, 48, 1 ...] + */ for ( i = 0, l = bonds.length; i < l; i ++ ) { var bond = bonds[ i ]; var start = bond[ 0 ]; var end = bond[ 1 ]; + + // verticesBonds == verticesAtoms positions multiplied by factor of 3 and incremented + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 0 ] ); //verticesAtoms[0] -- verticesAtoms[3] + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 1 ] ); //verticesAtoms[1] -- verticesAtoms[4] + verticesBonds.push( verticesAtoms[ ( start * 3 ) + 2 ] ); //verticesAtoms[2] -- verticesAtoms[5] - verticesBonds.push( verticesAtoms[ ( start * 3 ) + 0 ] ); - verticesBonds.push( verticesAtoms[ ( start * 3 ) + 1 ] ); - verticesBonds.push( verticesAtoms[ ( start * 3 ) + 2 ] ); - - verticesBonds.push( verticesAtoms[ ( end * 3 ) + 0 ] ); - verticesBonds.push( verticesAtoms[ ( end * 3 ) + 1 ] ); - verticesBonds.push( verticesAtoms[ ( end * 3 ) + 2 ] ); + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 0 ] ); //verticesAtoms[3] -- verticesAtoms[24] + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 1 ] ); //verticesAtoms[4] -- verticesAtoms[25] + verticesBonds.push( verticesAtoms[ ( end * 3 ) + 2 ] ); //verticesAtoms[5] -- verticesAtoms[26] } // build geometry - + + + /* BufferAttribute class stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes ) + associated with a BufferGeometry, which allows for more efficient passing of data to the GPU. + */ + geometryAtoms.addAttribute( 'position', new THREE.Float32BufferAttribute( verticesAtoms, 3 ) ); geometryAtoms.addAttribute( 'color', new THREE.Float32BufferAttribute( colorsAtoms, 3 ) ); @@ -143,7 +202,23 @@ THREE.PDBLoader.prototype = { return build; } - + + /* https://en.wikipedia.org/wiki/CPK_coloring?oldformat=true + + CPK coloring is a popular color convention for distinguishing atoms of different chemical elements in molecular models. + (CPK <== Corey, Pauling, Koltun) + CPK molecular models designed by chemists Robert Corey and Linus Pauling, and improved by Walter Koltun + Koltun Colors Scheme for Periodic Table: + White for hydrogen + Black for carbon + Blue for nitrogen + Red for oxygen + Deep yellow for sulfur + Purple for phosphorus + Light, medium, medium dark, and dark green for the halogens (F, Cl, Br, I) + Silver for metals (Co, Fe, Ni, Cu) + + */ var CPK = { h: [ 255, 255, 255 ], he: [ 217, 255, 255 ], li: [ 204, 128, 255 ], be: [ 194, 255, 0 ], b: [ 255, 181, 181 ], c: [ 144, 144, 144 ], n: [ 48, 80, 248 ], o: [ 255, 13, 13 ], f: [ 144, 224, 80 ], ne: [ 179, 227, 245 ], na: [ 171, 92, 242 ], mg: [ 138, 255, 0 ], al: [ 191, 166, 166 ], si: [ 240, 200, 160 ], p: [ 255, 128, 0 ], s: [ 255, 255, 48 ], cl: [ 31, 240, 31 ], ar: [ 128, 209, 227 ], k: [ 143, 64, 212 ], ca: [ 61, 255, 0 ], sc: [ 230, 230, 230 ], ti: [ 191, 194, 199 ], v: [ 166, 166, 171 ], cr: [ 138, 153, 199 ], mn: [ 156, 122, 199 ], fe: [ 224, 102, 51 ], co: [ 240, 144, 160 ], ni: [ 80, 208, 80 ], cu: [ 200, 128, 51 ], zn: [ 125, 128, 176 ], ga: [ 194, 143, 143 ], ge: [ 102, 143, 143 ], as: [ 189, 128, 227 ], se: [ 255, 161, 0 ], br: [ 166, 41, 41 ], kr: [ 92, 184, 209 ], rb: [ 112, 46, 176 ], sr: [ 0, 255, 0 ], y: [ 148, 255, 255 ], zr: [ 148, 224, 224 ], nb: [ 115, 194, 201 ], mo: [ 84, 181, 181 ], tc: [ 59, 158, 158 ], ru: [ 36, 143, 143 ], rh: [ 10, 125, 140 ], pd: [ 0, 105, 133 ], ag: [ 192, 192, 192 ], cd: [ 255, 217, 143 ], in: [ 166, 117, 115 ], sn: [ 102, 128, 128 ], sb: [ 158, 99, 181 ], te: [ 212, 122, 0 ], i: [ 148, 0, 148 ], xe: [ 66, 158, 176 ], cs: [ 87, 23, 143 ], ba: [ 0, 201, 0 ], la: [ 112, 212, 255 ], ce: [ 255, 255, 199 ], pr: [ 217, 255, 199 ], nd: [ 199, 255, 199 ], pm: [ 163, 255, 199 ], sm: [ 143, 255, 199 ], eu: [ 97, 255, 199 ], gd: [ 69, 255, 199 ], tb: [ 48, 255, 199 ], dy: [ 31, 255, 199 ], ho: [ 0, 255, 156 ], er: [ 0, 230, 117 ], tm: [ 0, 212, 82 ], yb: [ 0, 191, 56 ], lu: [ 0, 171, 36 ], hf: [ 77, 194, 255 ], ta: [ 77, 166, 255 ], w: [ 33, 148, 214 ], re: [ 38, 125, 171 ], os: [ 38, 102, 150 ], ir: [ 23, 84, 135 ], pt: [ 208, 208, 224 ], au: [ 255, 209, 35 ], hg: [ 184, 184, 208 ], tl: [ 166, 84, 77 ], pb: [ 87, 89, 97 ], bi: [ 158, 79, 181 ], po: [ 171, 92, 0 ], at: [ 117, 79, 69 ], rn: [ 66, 130, 150 ], fr: [ 66, 0, 102 ], ra: [ 0, 125, 0 ], ac: [ 112, 171, 250 ], th: [ 0, 186, 255 ], pa: [ 0, 161, 255 ], u: [ 0, 143, 255 ], np: [ 0, 128, 255 ], pu: [ 0, 107, 255 ], am: [ 84, 92, 242 ], cm: [ 120, 92, 227 ], bk: [ 138, 79, 227 ], cf: [ 161, 54, 212 ], es: [ 179, 31, 212 ], fm: [ 179, 31, 186 ], md: [ 179, 13, 166 ], no: [ 189, 13, 135 ], lr: [ 199, 0, 102 ], rf: [ 204, 0, 89 ], db: [ 209, 0, 79 ], sg: [ 217, 0, 69 ], bh: [ 224, 0, 56 ], hs: [ 230, 0, 46 ], mt: [ 235, 0, 38 ], ds: [ 235, 0, 38 ], rg: [ 235, 0, 38 ], cn: [ 235, 0, 38 ], uut: [ 235, 0, 38 ], uuq: [ 235, 0, 38 ], uup: [ 235, 0, 38 ], uuh: [ 235, 0, 38 ], uus: [ 235, 0, 38 ], uuo: [ 235, 0, 38 ] }; @@ -156,27 +231,63 @@ THREE.PDBLoader.prototype = { var x, y, z, e; // parse - + + //Decompose text into Array: (an array entry for each line) var lines = text.split( '\n' ); for ( var i = 0, l = lines.length; i < l; i ++ ) { - - if ( lines[ i ].substr( 0, 4 ) === 'ATOM' || lines[ i ].substr( 0, 6 ) === 'HETATM' ) { - + + // extract atom coords from pdb + //Also SDF file Format similar to PDB file format: http://link.fyicenter.com/out.php?ID=571 + + + /* + https://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM + + e x y z + ATOM 2 C 1 -8.580 0.025 -4.537 1.00 0.00 + 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + 0**4 Ei) Xiiiiii)Yiiiiii)Ziiiiii) + + or + + https://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#HETATM + + x y z + HETATM 1 C01 UNK A 1 -10.447 3.465 0.000 0.00 0.00 0 + 12345678901234567890123456789012345678901234567890123456789012345678901234567890 + 0****6 Xiiiiii)Yiiiiii)Ziiiiii) + + */ + + if ( lines[ i ].substr( 0, 4 ) === 'ATOM' || lines[ i ].substr( 0, 6 ) === 'HETATM' ) { + + //extract x,y,z coord for each atom from pdb file extracted lines + //extract values from locations for each coord x = parseFloat( lines[ i ].substr( 30, 7 ) ); y = parseFloat( lines[ i ].substr( 38, 7 ) ); z = parseFloat( lines[ i ].substr( 46, 7 ) ); + //If long line extract Chemistry Element from near the end of line e = trim( lines[ i ].substr( 76, 2 ) ).toLowerCase(); - + + //If not a long line extract the Chemistry from near the beginning of line if ( e === '' ) { - + //extract first 2 characters of Chemical Element Name + /* + e + ATOM 2 C 1 -8.580 0.025 -4.537 1.00 0.00 + 1234567890123567890123567890123567890123567890123567890123567890123567890 + 0**4 E i) + */ e = trim( lines[ i ].substr( 12, 2 ) ).toLowerCase(); } - + + //add atoms to atoms array atoms.push( [ x, y, z, CPK[ e ], capitalize( e ) ] ); - + + //create histogram if ( histogram[ e ] === undefined ) { histogram[ e ] = 1; @@ -188,7 +299,25 @@ THREE.PDBLoader.prototype = { } } else if ( lines[ i ].substr( 0, 6 ) === 'CONECT' ) { - + /* + https://www.wwpdb.org/documentation/file-format-content/format33/sect10.html#CONECT + + The CONECT records specify connectivity between atoms for which coordinates are supplied. + + CONECT 1 2 + 12345678901234567890123456789001234567890 + Siiii) + Piiii) + Piiii) + Piiii) + Piiii) + CONECT 2 1 9 49 + CONECT 3 4 + + */ + + //Extract Bonds per line + //Get the 1st atom_serial_num per line & convert String Representation to Int var satom = parseInt( lines[ i ].substr( 6, 5 ) ); parseBond( 11, 5 );
false
Other
mrdoob
three.js
6b8a0d501e2be2d2011788db75be923268d45d7d.json
Fix minor typo
docs/manual/introduction/Import-via-modules.html
@@ -19,7 +19,7 @@ <h1>[name]</h1><br /> </ul> </div> - <div>Using a dependency manager like npm avoids these caveats by allowing you to simply download and import your desired version of the libarary onto your machine.</div> + <div>Using a dependency manager like npm avoids these caveats by allowing you to simply download and import your desired version of the library onto your machine.</div> <h2>Installation via npm</h2>
false
Other
mrdoob
three.js
86e8095ff46755911719016653fe37bf29af6562.json
Fix sprite renderer bug
src/renderers/webgl/WebGLSpriteRenderer.js
@@ -225,6 +225,7 @@ function WebGLSpriteRenderer( renderer, gl, state, textures, capabilities ) { state.setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha ); state.buffers.depth.setTest( material.depthTest ); state.buffers.depth.setMask( material.depthWrite ); + state.buffers.color.setMask( material.colorWrite ); textures.setTexture2D( material.map || texture, 0 );
false
Other
mrdoob
three.js
129ea49e81a3650255929ee8dd98a13c0361fef9.json
Remove special casing for `node.meshes`
examples/js/loaders/GLTFLoader.js
@@ -2171,37 +2171,16 @@ THREE.GLTFLoader = ( function () { ] ).then( function ( dependencies ) { return _each( __nodes, function ( _node, nodeId ) { - + var node = json.nodes[ nodeId ]; - var meshes; - - if ( node.mesh !== undefined) { - - meshes = [ node.mesh ]; - - } else if ( node.meshes !== undefined ) { - - console.warn( 'THREE.GLTFLoader: Legacy glTF file detected. Nodes may have no more than one mesh.' ); - - meshes = node.meshes; - - } - - if ( meshes !== undefined ) { - - for ( var meshId in meshes ) { - - var mesh = meshes[ meshId ]; - var group = dependencies.meshes[ mesh ]; - - if ( group === undefined ) { + var mesh = node.mesh; - console.warn( 'THREE.GLTFLoader: Could not find node "' + mesh + '".' ); - continue; + if ( mesh !== undefined) { - } + var group = dependencies.meshes[ mesh ]; + if ( group !== undefined ) { // do not clone children as they will be replaced anyway var clonedgroup = group.clone( false ); @@ -2302,8 +2281,11 @@ THREE.GLTFLoader = ( function () { } _node.add( clonedgroup ); + } else { - } + console.warn( 'THREE.GLTFLoader: Could not find node "' + mesh + '".' ); + + } }
false
Other
mrdoob
three.js
0ace56e97c3ab1b96c0510fab6fad4193e4dbad7.json
replace .length with variable
src/extras/curves/CatmullRomCurve3.js
@@ -114,7 +114,7 @@ CatmullRomCurve3.prototype.getPoint = function ( t, optionalTarget ) { if ( this.closed ) { - intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / points.length ) + 1 ) * points.length; + intPoint += intPoint > 0 ? 0 : ( Math.floor( Math.abs( intPoint ) / l ) + 1 ) * l; } else if ( weight === 0 && intPoint === l - 1 ) {
false
Other
mrdoob
three.js
a18dc1a8e3c88244ec4d95de0b5070d45afa4157.json
Add Texture.updateMatrix() method
docs/api/textures/Texture.html
@@ -154,21 +154,21 @@ <h3>[property:number rotation]</h3> <h3>[property:Vector2 center]</h3> <p> - Indicates where the center of rotation is. To rotate around the center point set this value to (0.5, 0.5). Default value is (0.0, 0.0). + The point around which rotation occurs. A value of (0.5, 0.5) corresponds to the center of the texture. Default is (0, 0), the lower left. </p> <h3>[property:boolean matrixAutoUpdate]</h3> <p> - Whether to update the texture's uv-transform [property:Matrix3 matrix] based on the [property:Vector2 offset], - [property:Vector2 repeat], and [property:number rotation] settings. True by default. + Whether to update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat], + [page:Texture.rotation .rotation], and [page:Texture.center .center]. True by default. Set this to false if you are specifying the uv-transform matrix directly. </p> <h3>[property:Matrix3 matrix]</h3> <p> - The uv-transform matrix for the texture. Updated by the renderer from the texture properties [property:Vector2 offset], [property:Vector2 repeat], - and [property:number rotation] when the texture's [property:boolean matrixAutoUpdate] property is true. - When [property:boolean matrixAutoUpdate] property is false, this matrix may be set manually. + The uv-transform matrix for the texture. Updated by the renderer from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat], + [page:Texture.rotation .rotation], and [page:Texture.center .center] when the texture's [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is true. + When [page:Texture.matrixAutoUpdate .matrixAutoUpdate] property is false, this matrix may be set manually. Default is the identity matrix. </p> @@ -228,6 +228,12 @@ <h2>Methods</h2> <h3>[page:EventDispatcher EventDispatcher] methods are available on this class.</h3> + <h3>[method:null updateMatrix]()</h3> + <p> + Update the texture's uv-transform [page:Texture.matrix .matrix] from the texture properties [page:Texture.offset .offset], [page:Texture.repeat .repeat], + [page:Texture.rotation .rotation], and [page:Texture.center .center]. + </p> + <h3>[method:Texture clone]( [param:Texture texture] )</h3> <p> Make copy of the texture. Note this is not a "deep copy", the image is shared. @@ -246,7 +252,7 @@ <h3>[method:null dispose]()</h3> <h3>[method:null transformUv]( uv )</h3> <p> - Transform the uv based on the value of this texture's [page:Texture.repeat .repeat], [page:Texture.offset .offset], + Transform the uv based on the value of this texture's [page:Texture.offset .offset], [page:Texture.repeat .repeat], [page:Texture.wrapS .wrapS], [page:Texture.wrapT .wrapT] and [page:Texture.flipY .flipY] properties. </p>
true
Other
mrdoob
three.js
a18dc1a8e3c88244ec4d95de0b5070d45afa4157.json
Add Texture.updateMatrix() method
src/renderers/WebGLRenderer.js
@@ -2050,12 +2050,7 @@ function WebGLRenderer( parameters ) { if ( uvScaleMap.matrixAutoUpdate === true ) { - var offset = uvScaleMap.offset; - var repeat = uvScaleMap.repeat; - var rotation = uvScaleMap.rotation; - var center = uvScaleMap.center; - - uvScaleMap.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y ); + uvScaleMap.updateMatrix(); } @@ -2093,12 +2088,7 @@ function WebGLRenderer( parameters ) { if ( material.map.matrixAutoUpdate === true ) { - var offset = material.map.offset; - var repeat = material.map.repeat; - var rotation = material.map.rotation; - var center = material.map.center; - - material.map.matrix.setUvTransform( offset.x, offset.y, repeat.x, repeat.y, rotation, center.x, center.y ); + material.map.updateMatrix(); }
true
Other
mrdoob
three.js
a18dc1a8e3c88244ec4d95de0b5070d45afa4157.json
Add Texture.updateMatrix() method
src/textures/Texture.js
@@ -70,6 +70,12 @@ Texture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), { isTexture: true, + updateMatrix: function () { + + this.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y ); + + }, + clone: function () { return new this.constructor().copy( this );
true
Other
mrdoob
three.js
79c66a2f13b39f5663fe0ff4d523a4dc89fa3c5e.json
fix lint error
src/core/BufferGeometry.js
@@ -68,7 +68,7 @@ BufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototy addAttribute: function ( name, attribute ) { - if ( ! (attribute && (attribute.isBufferAttribute || attribute.isInterleavedBufferAttribute || attribute.isGLBufferAttribute) ) ) { + if ( ! ( attribute && ( attribute.isBufferAttribute || attribute.isInterleavedBufferAttribute || attribute.isGLBufferAttribute ) ) ) { console.warn( 'THREE.BufferGeometry: .addAttribute() now expects ( name, attribute ).' );
false
Other
mrdoob
three.js
f0b3212aad1f029393d99bb917556994a865fdb0.json
test absolute span
examples/js/loaders/FBXLoader.js
@@ -2692,9 +2692,11 @@ var initialValue = curve.values[ i - 1 ]; var valuesSpan = curve.values[ i ] - initialValue; - if ( valuesSpan >= 180 ) { + var absoluteSpan = Math.abs( valuesSpan ); - var numSubIntervals = Math.abs( valuesSpan / 180 ); + if ( absoluteSpan >= 180 ) { + + var numSubIntervals = absoluteSpan / 180; var step = valuesSpan / numSubIntervals; var nextValue = initialValue + step;
false
Other
mrdoob
three.js
c52335f473eadbaac6a84b04529de3c3afa20436.json
Adjust camera in VRM loader example
examples/webgl_loader_vrm.html
@@ -61,10 +61,10 @@ document.body.appendChild( container ); camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 0.25, 20 ); - camera.position.set( 0, 0.8, - 2.2 ); + camera.position.set( 0, 1.6, - 2.2 ); controls = new THREE.OrbitControls( camera ); - controls.target.set( 0, 0.8, 0 ); + controls.target.set( 0, 0.9, 0 ); controls.update(); scene = new THREE.Scene();
false
Other
mrdoob
three.js
37ab2c2420f40d233756e4249a4fdf66b44c2258.json
fix Filename to RelativeFilename in parseImage() The path of "Filename" property is useless. It depends on local directory (ex. C:\somewhere\blahblah\shitty.fbx). RelativeFilename is better for URI.
examples/js/loaders/FBXLoader.js
@@ -173,7 +173,7 @@ var id = parseInt( nodeID ); - images[ id ] = videoNode.Filename; + images[ id ] = videoNode.RelativeFilename || videoNode.Filename; // raw image data is in videoNode.Content if ( 'Content' in videoNode ) {
false
Other
mrdoob
three.js
684d5d4dbd5918c429a9b75969f4490a8e730eae.json
Change variable name from cube to klein Because the object is not a cube, it's a klein bottle.
docs/api/geometries/ParametricGeometry.html
@@ -37,8 +37,8 @@ <h2>Example</h2> <code> var geometry = new THREE.ParametricGeometry( 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
6787bbc2af6c5b91f231d60d208c1890185bcf6e.json
fix renderOrder ReflectorRTT
examples/js/objects/ReflectorRTT.js
@@ -4,6 +4,8 @@ THREE.ReflectorRTT = function ( geometry, options ) { this.geometry.setDrawRange( 0, 0 ); // avoid rendering geometry + this.renderOrder = -Infinity; // render RTT first + }; THREE.ReflectorRTT.prototype = Object.create( THREE.Reflector.prototype );
false
Other
mrdoob
three.js
b0c0e588b2763973add1ec6aabc3d74a372fd688.json
remove console log
examples/js/loaders/FBXLoader.js
@@ -2791,8 +2791,6 @@ var innerPropFlag = props[ 3 ]; var innerPropValue = props[ 4 ]; - console.log( innerPropType1 ) - // cast values where needed, otherwise leave as strings switch ( innerPropType1 ) {
false
Other
mrdoob
three.js
c49a2071502252156c890be191af8b03b7aaf319.json
Add parsing of double sided extra effect elements Blender exports the double sided property and this change will make the Collada Loader recognise this property element.
examples/js/loaders/ColladaLoader.js
@@ -1062,6 +1062,10 @@ THREE.ColladaLoader.prototype = { case 'technique': data.technique = parseEffectTechnique( child ); break; + + case 'extra': + data.extra = parseEffectExtra( child ); + break; } @@ -1328,6 +1332,54 @@ THREE.ColladaLoader.prototype = { } } + + function parseEffectExtra( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'technique': + data.technique = parseEffectExtraTechnique( child ); + break; + + } + + } + + return data; + + } + + function parseEffectExtraTechnique( xml ) { + + var data = {}; + + for ( var i = 0, l = xml.childNodes.length; i < l; i ++ ) { + + var child = xml.childNodes[ i ]; + + if ( child.nodeType !== 1 ) continue; + + switch ( child.nodeName ) { + + case 'double_sided': + data[ child.nodeName ] = parseInt( child.textContent ); + break; + + } + + } + + return data; + + } function buildEffect( data ) { @@ -1373,7 +1425,8 @@ THREE.ColladaLoader.prototype = { var effect = getEffect( data.url ); var technique = effect.profile.technique; - + var extra = effect.profile.extra; + var material; switch ( technique.type ) { @@ -1499,6 +1552,16 @@ THREE.ColladaLoader.prototype = { } } + + if ( extra !== undefined && extra.technique !== undefined && isEmpty( extra.technique ) === false ) { + + if ( extra.technique.double_sided !== undefined ) { + + material.side = THREE.DoubleSide; + + } + + } return material;
false
Other
mrdoob
three.js
fc38b8ca4fcd5d465b028387cd5b025be5f1bd2a.json
Add MMDAnimationHelper documentation
docs/examples/animations/MMDAnimationHelper.html
@@ -0,0 +1,162 @@ +<!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"> A animation helper for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br /> + [name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics. + </p> + + <h2>Example</h2> + + <code> + // Instantiate a helper + var helper = new THREE.MMDAnimationHelper(); + + // Load MMD resources and add to helper + new THREE.MMDLoader().loadWithAnimation( + 'models/mmd/miku.pmd', + 'models/mmd/dance.vmd', + function ( mmd ) { + + helper.add( mmd.mesh, { + animation: mmd.animation, + physics: true + } ); + + scene.add( mesh ); + + new THREE.AudioLoader().load( + 'audios/mmd/song.mp3', + function ( buffer ) { + + var listener = new THREE.AudioListener(); + var audio = new THREE.Audio( listener ) + .setBuffer( buffer ); + + listener.position.z = 1; + + scene.add( audio ); + scene.add( listener ); + + } + + ); + + } + ); + + function render() { + + helper.update( clock.getDelta() ); + renderer.render( scene, camera ); + + } + </code> + + [example:webgl_loader_mmd]<br /> + [example:webgl_loader_mmd_pose]<br /> + [example:webgl_loader_mmd_audio]<br /> + + <br /> + <hr> + + <h2>Constructor</h2> + + <h3>[name]( [param:Object params] )</h3> + <p> + [page:Object params] — (optional)<br /> + <ul> + <li> [page:Boolean sync] - Whether animation durations of added objects are synched. Default is true.</li> + <li> [page:Number afterglow] - Default is 0.0.</li> + <li> [page:Boolean resetPhysicsOnLoop] - Default is true.</li> + </ul> + </p> + <p> + Creates a new [name]. + </p> + + <h2>Properties</h2> + + <h3>[property:Audio audio]</h3> + <p>An [page:Audio] added to helper.</p> + + <h3>[property:Camera camera]</h3> + <p>An [page:Camera] added to helper.</p> + + <h3>[property:Array meshes]</h3> + <p>An array of [page:SkinnedMesh] added to helper.</p> + + <h3>[property:WeakMap objects]</h3> + <p>A [page:WeakMap] which holds animation stuffs used in helper for objects added to helper. For example, you can access [page:AnimationMixer] for an added [page:SkinnedMesh] with "helper.objects.get( mesh ).mixer"</p> + + + <h2>Methods</h2> + + <h3>[method:MMDAnimationHelper add]( [param:Object3D object], [param:Object params] )</h3> + <p> + [page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]<br /> + [page:Object params] — (optional)<br /> + <ul> + <li>[page:AnimationClip animation] - an [page:AnimationClip] or an array of [page:AnimationClip] set to object. Only for [page:SkinnedMesh] and [page:Camera]. Default is undefined.</li> + <li>[page:Boolean physics] - Only for [page:SkinnedMesh]. A flag whether turn on physics. Default is true.</li> + <li>[page:Number delayTime] - Only for [page:Audio]. Default is 0.0.</li> + </ul> + </p> + <p> + Add an [page:SkinnedMesh], [page:Camera], or [page:Audio] to helper and setup animation. The anmation durations of added objects are synched. + If camera/audio has already been added, it'll be replaced with a new one. + </p> + + <h3>[method:MMDAnimationHelper enable]( [param:string key], [param:Boolean enabled] )</h3> + <p> + [page:string key] — Allowed strings are 'animation', 'ik', 'grant', 'physics', and 'cameraAnimation'.<br /> + [page:Boolean enabled] — true is enable, false is disable<br /> + </p> + <p> + Enable/Disable an animation feature + </p> + + <h3>[method:MMDAnimationHelper pose]( [param:SkinnedMesh mesh], [param:Object vpd], [param:Object params] )</h3> + <p> + [page:SkinnedMesh mesh] — [page:SkinnedMesh] which changes the posing. It doesn't need to be added to helper.<br /> + [page:Object vpd] — VPD content obtained by [page:MMDLoader].loadVPD<br /> + [page:Object params] — (optional)<br /> + <ul> + <li>[page:Boolean resetPose] - Default is true.</li> + <li>[page:Boolean ik] - Default is true.</li> + <li>[page:Boolean grant] - Default is true.</li> + </ul> + </p> + <p> + Changes the posing of [page:SkinnedMesh] as VPD content specifies. + </p> + + <h3>[method:MMDAnimationHelper remove]( [param:Object3D object] )</h3> + <p> + [page:Object3D object] — [page:SkinnedMesh], [page:Camera], or [page:Audio]<br /> + </p> + <p> + Remove an [page:SkinnedMesh], [page:Camera], or [page:Audio] from helper. + </p> + + <h3>[method:MMDAnimationHelper update]( [param:Nummber delta] )</h3> + <p> + [page:Number delta] — number in second<br /> + </p> + <p> + Advance mixer time and update the animations of objects added to helper + </p> + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDAnimationHelper.js examples/js/animation/MMDAnimationHelper.js] + </body> +</html>
false
Other
mrdoob
three.js
83ed893f1ba50617cdc4db232779e89a3a11ae72.json
Add MMDLoader documentation
docs/examples/loaders/MMDLoader.html
@@ -0,0 +1,118 @@ +<!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:Loader] &rarr; + <h1>[name]</h1> + + <p class="desc"> A loader for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br /> + [name] creates Three.js Objects from MMD resources as PMD, PMX, VMD, and VPD files. + You can easily handle MMD special features, as IK, Grant, and Physics, with [page:MMDAnimationHelper].<br /><br /> + + If you want raw content of MMD resources, use .loadPMD/PMX/VMD/VPD methods. + + <h2>Example</h2> + + <code> + // Instantiate a loader + var loader = new THREE.MMDLoader(); + + // Load a MMD model + loader.load( + // path to PMD/PMX file + 'models/mmd/miku.pmd', + // called when the resource is loaded + function ( mesh ) { + + scene.add( mesh ); + + }, + // called when loading is in progresses + function ( xhr ) { + + console.log( ( xhr.loaded / xhr.total * 100 ) + '% loaded' ); + + }, + // called when loading has errors + function ( error ) { + + console.log( 'An error happened' ); + + } + ); + </code> + + [example:webgl_loader_mmd]<br /> + [example:webgl_loader_mmd_pose]<br /> + [example:webgl_loader_mmd_audio]<br /> + + <br /> + <hr> + + <h2>Constructor</h2> + + <h3>[name]( [param:LoadingManager manager] )</h3> + <p> + [page:LoadingManager manager] — The [page:LoadingManager loadingManager] for the loader to use. Default is [page:LoadingManager THREE.DefaultLoadingManager]. + </p> + <p> + Creates a new [name]. + </p> + + <h2>Properties</h2> + + + <h2>Methods</h2> + + <h3>[method:null load]( [param:String url], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3> + <p> + [page:String url] — A string containing the path/URL of the <em>.pmd</em> or <em>.pmx</em> file.<br /> + [page:Function onLoad] — A function to be called after the loading is successfully completed.<br /> + [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br /> + [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br /> + </p> + <p> + Begin loading PMD/PMX model file from url and fire the callback function with the parsed [page:SkinnedMesh] containing [page:BufferGeometry] and an array of [page:MeshToonMaterial]. + </p> + + <h3>[method:null loadAnimation]( [param:String url], [param:Object3D object], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3> + <p> + [page:String url] — A string or an array of string containing the path/URL of the <em>.vmd</em> file(s).If two or more files are specified, they'll be merged.<br /> + [page:Object3D object] — [page:SkinnedMesh] or [page:Camera]. Clip and its tacks will be fitting to this object.<br /> + [page:Function onLoad] — A function to be called after the loading is successfully completed.<br /> + [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br /> + [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br /> + </p> + <p> + Begin loading VMD motion file(s) from url(s) and fire the callback function with the parsed [page:AnimatioinClip]. + </p> + + <h3>[method:null loadWithAnimation]( [param:String modelUrl], [param:String vmdUrl], [param:Function onLoad], [param:Function onProgress], [param:Function onError] )</h3> + <p> + [page:String modelUrl] — A string containing the path/URL of the <em>.pmd</em> or <em>.pmx</em> file.<br /> + [page:String vmdUrl] — A string or an array of string containing the path/URL of the <em>.vmd</em> file(s).<br /> + [page:Function onLoad] — A function to be called after the loading is successfully completed.<br /> + [page:Function onProgress] — (optional) A function to be called while the loading is in progress. The argument will be the XMLHttpRequest instance, that contains .[page:Integer total] and .[page:Integer loaded] bytes.<br /> + [page:Function onError] — (optional) A function to be called if an error occurs during loading. The function receives error as an argument.<br /> + </p> + <p> + Begin loading PMD/PMX model file and VMD motion file(s) from urls and fire the callback function with an [page:Object] containing parsed [page:SkinnedMesh] and [page:AnimationClip] fitting to the [page:SkinnedMesh]. + </p> + + <h3>[method:MMDLoader setCrossOrigin]( [param:String crossOrigin] )</h3> + <p> + [page:String crossOrigin] — The crossOrigin string to implement CORS for loading the url from a different domain that allows CORS. + </p> + + + <h2>Source</h2> + + [link:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/MMDLoader.js examples/js/loaders/MMDLoader.js] + </body> +</html>
false
Other
mrdoob
three.js
21043ad1601b0d9e89558b4ec5cb36e64e234ca8.json
Update MMD examples
examples/webgl_loader_mmd.html
@@ -43,6 +43,7 @@ <script src="js/effects/OutlineEffect.js"></script> <script src="js/animation/CCDIKSolver.js"></script> <script src="js/animation/MMDPhysics.js"></script> + <script src="js/animation/MMDAnimationHelper.js"></script> <script src="js/controls/OrbitControls.js"></script> @@ -120,37 +121,34 @@ var modelFile = 'models/mmd/miku/miku_v2.pmd'; var vmdFiles = [ 'models/mmd/vmds/wavefile_v2.vmd' ]; - helper = new THREE.MMDHelper(); + helper = new THREE.MMDAnimationHelper( { + afterglow: 2.0 + } ); var loader = new THREE.MMDLoader(); - loader.load( modelFile, vmdFiles, function ( object ) { + loader.loadWithAnimation( modelFile, vmdFiles, function ( mmd ) { - mesh = object; + mesh = mmd.mesh; mesh.position.y = -10; scene.add( mesh ); - helper.add( mesh ); - helper.setAnimation( mesh ); + helper.add( mesh, { + animation: mmd.animation, + physics: true + } ); /* - * Note: create CCDIKHelper after calling helper.setAnimation() + * Note: create CCDIKHelper and MMDPhysicsHelper after calling helper.add( mesh ) */ ikHelper = new THREE.CCDIKHelper( mesh ); ikHelper.visible = false; scene.add( ikHelper ); - /* - * Note: You're recommended to call helper.setPhysics() - * after calling helper.setAnimation(). - */ - helper.setPhysics( mesh ); - physicsHelper = new THREE.MMDPhysicsHelper( mesh ); + physicsHelper = new THREE.MMDPhysicsHelper( mesh, helper.objects.get( mesh ).physics ); physicsHelper.visible = false; scene.add( physicsHelper ); - helper.unifyAnimationDuration( { afterglow: 2.0 } ); - initGui(); }, onProgress, onError ); @@ -195,7 +193,7 @@ var gui = new dat.GUI(); gui.add( api, 'animation' ).onChange( function () { - helper.doAnimation = api[ 'animation' ]; + helper.enable( 'animation', api[ 'animation' ] ); } ); gui.add( api, 'gradient mapping' ).onChange( function () { @@ -216,15 +214,15 @@ } ); gui.add( api, 'ik' ).onChange( function () { - helper.doIk = api[ 'ik' ]; + helper.enable( 'ik', api[ 'ik' ] ); } ); gui.add( api, 'outline' ).onChange( function () { effect.enabled = api[ 'outline' ]; } ); gui.add( api, 'physics' ).onChange( function () { - helper.enablePhysics( api[ 'physics' ] ); + helper.enable( 'physics', api[ 'physics' ] ); } ); gui.add( api, 'show IK bones' ).onChange( function () { @@ -265,9 +263,11 @@ function render() { - helper.animate( clock.getDelta() ); + helper.update( clock.getDelta() ); + if ( physicsHelper !== undefined && physicsHelper.visible ) physicsHelper.update(); if ( ikHelper !== undefined && ikHelper.visible ) ikHelper.update(); + effect.render( scene, camera ); }
true
Other
mrdoob
three.js
21043ad1601b0d9e89558b4ec5cb36e64e234ca8.json
Update MMD examples
examples/webgl_loader_mmd_audio.html
@@ -45,6 +45,7 @@ <script src="js/effects/OutlineEffect.js"></script> <script src="js/animation/CCDIKSolver.js"></script> <script src="js/animation/MMDPhysics.js"></script> + <script src="js/animation/MMDAnimationHelper.js"></script> <script src="js/Detector.js"></script> <script src="js/libs/stats.min.js"></script> @@ -116,36 +117,33 @@ var audioFile = 'models/mmd/audios/wavefile_short.mp3'; var audioParams = { delayTime: 160 * 1 / 30 }; - helper = new THREE.MMDHelper(); + helper = new THREE.MMDAnimationHelper(); var loader = new THREE.MMDLoader(); - loader.load( modelFile, vmdFiles, function ( object ) { + loader.loadWithAnimation( modelFile, vmdFiles, function ( mmd ) { - mesh = object; + mesh = mmd.mesh; - helper.add( mesh ); - helper.setAnimation( mesh ); - helper.setPhysics( mesh ); + helper.add( mesh, { + animation: mmd.animation, + physics: true + } ); - loader.loadVmds( cameraFiles, function ( vmd ) { + loader.loadAnimation( cameraFiles, camera, function ( cameraAnimation ) { - helper.setCamera( camera ); + helper.add( camera, { + animation: cameraAnimation + } ); - loader.pourVmdIntoCamera( camera, vmd ); - helper.setCameraAnimation( camera ); + new THREE.AudioLoader().load( audioFile, function ( buffer ) { - loader.loadAudio( audioFile, function ( audio, listener ) { + var listener = new THREE.AudioListener(); + var audio = new THREE.Audio( listener ).setBuffer( buffer ); listener.position.z = 1; - helper.setAudio( audio, listener, audioParams ); - - /* - * Note: call this method after you set all animations - * including camera and audio. - */ - helper.unifyAnimationDuration(); + helper.add( audio, audioParams ); scene.add( audio ); scene.add( listener ); @@ -199,7 +197,7 @@ if ( ready ) { - helper.animate( clock.getDelta() ); + helper.update( clock.getDelta() ); }
true
Other
mrdoob
three.js
21043ad1601b0d9e89558b4ec5cb36e64e234ca8.json
Update MMD examples
examples/webgl_loader_mmd_pose.html
@@ -43,6 +43,7 @@ <script src="js/effects/OutlineEffect.js"></script> <script src="js/animation/CCDIKSolver.js"></script> <script src="js/animation/MMDPhysics.js"></script> + <script src="js/animation/MMDAnimationHelper.js"></script> <script src="js/Detector.js"></script> <script src="js/libs/stats.min.js"></script> @@ -118,11 +119,11 @@ 'models/mmd/vpds/11.vpd' ]; - helper = new THREE.MMDHelper(); + helper = new THREE.MMDAnimationHelper(); var loader = new THREE.MMDLoader(); - loader.loadModel( modelFile, function ( object ) { + loader.load( modelFile, function ( object ) { mesh = object; mesh.position.y = -10; @@ -135,7 +136,7 @@ var vpdFile = vpdFiles[ vpdIndex ]; - loader.loadVpd( vpdFile, function ( vpd ) { + loader.loadVPD( vpdFile, false, function ( vpd ) { vpds.push( vpd ); @@ -254,7 +255,7 @@ } else { - helper.poseAsVpd( mesh, vpds[ index ] ); + helper.pose( mesh, vpds[ index ] ); }
true
Other
mrdoob
three.js
f2e3a813b2b533145b80be1febd5db7a41447e28.json
Use singleline if for uuid validation
src/loaders/ObjectLoader.js
@@ -456,13 +456,11 @@ Object.assign( ObjectLoader.prototype, { for ( var i = 0; i < json.length; i ++ ) { - var clip = AnimationClip.parse( json[ i ] ); + var data = json[ i ]; - if ( json[ i ].uuid !== undefined ) { + var clip = AnimationClip.parse( data ); - clip.uuid = json[ i ].uuid; - - } + if ( data.uuid !== undefined ) clip.uuid = data.uuid; animations.push( clip );
false
Other
mrdoob
three.js
3fb9d61eb91d6fdb0e541061aede623c9b067f3a.json
fix lint error
examples/js/renderers/CSS2DRenderer.js
@@ -133,7 +133,7 @@ THREE.CSS2DRenderer = function () { return result; - } + }; var zOrder = function ( scene ) {
false
Other
mrdoob
three.js
4f780dceb7514561bd2aa43d8dc8e425a608323f.json
add an example for CSS2DRenderer
docs/examples/renderers/CSS2DRenderer.html
@@ -33,6 +33,7 @@ <h1>[name]</h1> <h2>Examples</h2> <p> + [example:css2d_label]<br> [example:webgl_loader_pdb molecules] </p>
true
Other
mrdoob
three.js
4f780dceb7514561bd2aa43d8dc8e425a608323f.json
add an example for CSS2DRenderer
examples/css2d_label.html
@@ -0,0 +1,150 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> + <title>three.js css2d - label</title> + <style> + body { + background-color: #000; + margin: 0; + overflow: hidden; + } + #info { + position: absolute; + top: 0px; + width: 100%; + color: #FFF; + padding: 5px; + font-family: Monospace; + font-size: 13px; + text-align: center; + z-index: 1; + } + + .label{ + color: #FFF; + font-family: sans-serif; + padding: 2px; + background: rgba( 0, 0, 0, .6 ); + } + + a { + color: #000000; + } + + </style> + </head> + <body> + <div id="info"><a href="http://threejs.org" target="_blank" rel="noopener">three.js</a> - three.js css2d - label</div> + + <script src="../build/three.js"></script> + + <script src="js/controls/OrbitControls.js"></script> + + <script src="js/renderers/CSS2DRenderer.js"></script> + + <script> + + var camera, scene, renderer, renderer2; + var controls; + var clock = new THREE.Clock(); + var textureLoader = new THREE.TextureLoader(); + + var earth, moon; + + init(); + animate(); + + function init() { + + var EARTH_RADIUS = 1; + var MOON_RADIUS = 0.27; + + camera = new THREE.PerspectiveCamera( 45, window.innerWidth / window.innerHeight, 1, 1000 ); + camera.position.set( 10, 5, 20 ); + + controls = new THREE.OrbitControls( camera ); + + scene = new THREE.Scene(); + + scene2 = new THREE.Scene(); + + dirLight = new THREE.DirectionalLight( 0xffffff ); + dirLight.position.set( 0, 0, 1 ); + scene.add( dirLight ); + + var axesHelper = new THREE.AxesHelper( 5 ); + scene.add( axesHelper ); + + // + + var earthGeometry = new THREE.SphereBufferGeometry( EARTH_RADIUS, 16, 16 ); + var earthMaterial = new THREE.MeshPhongMaterial( { + specular: 0x333333, + shininess: 5, + map: textureLoader.load( 'textures/planets/earth_atmos_2048.jpg' ), + specularMap: textureLoader.load( 'textures/planets/earth_specular_2048.jpg' ), + normalMap: textureLoader.load( 'textures/planets/earth_normal_2048.jpg' ), + normalScale: new THREE.Vector2( 0.85, 0.85 ) + } ); + earth = new THREE.Mesh( earthGeometry, earthMaterial ); + scene.add( earth ); + + var moonGeometry = new THREE.SphereBufferGeometry( MOON_RADIUS, 16, 16 ); + var moonMaterial = new THREE.MeshPhongMaterial( { + shininess: 5, + map: textureLoader.load( 'textures/planets/moon_1024.jpg' ) + } ); + moon = new THREE.Mesh( moonGeometry, moonMaterial ); + scene.add( moon ); + + // + + var earthDiv = document.createElement( 'div' ); + earthDiv.className = 'label'; + earthDiv.textContent = 'Earth'; + earthDiv.style.marginTop = '-1em'; + var earthLabel = new THREE.CSS2DObject( earthDiv ); + earthLabel.position.set( 0, EARTH_RADIUS, 0 ); + earth.add( earthLabel ); + + var moonDiv = document.createElement( 'div' ); + moonDiv.className = 'label'; + moonDiv.textContent = 'Moon'; + moonDiv.style.marginTop = '-1em'; + var moonLabel = new THREE.CSS2DObject( moonDiv ); + moonLabel.position.set( 0, MOON_RADIUS, 0 ); + moon.add( moonLabel ); + + // + + renderer = new THREE.WebGLRenderer(); + renderer.setPixelRatio( window.devicePixelRatio ); + renderer.setSize( window.innerWidth, window.innerHeight ); + document.body.appendChild( renderer.domElement ); + + renderer2 = new THREE.CSS2DRenderer(); + renderer2.setSize( window.innerWidth, window.innerHeight ); + renderer2.domElement.style.position = 'absolute'; + renderer2.domElement.style.top = 0; + document.body.appendChild( renderer2.domElement ); + + } + + function animate() { + + requestAnimationFrame( animate ); + + var elapsed = clock.getElapsedTime(); + + moon.position.set( Math.sin( elapsed ) * 5, 0, Math.cos( elapsed ) * 5 ); + + renderer.render( scene, camera ); + renderer2.render( scene, camera ); + + } + + </script> + </body> +</html>
true
Other
mrdoob
three.js
4f780dceb7514561bd2aa43d8dc8e425a608323f.json
add an example for CSS2DRenderer
examples/files.js
@@ -358,6 +358,9 @@ var files = { "css3d_sprites", "css3d_youtube" ], + "css2d": [ + "css2d_label" + ], "canvas": [ "canvas_ascii_effect", "canvas_camera_orthographic",
true
Other
mrdoob
three.js
1b56759e45641e6cf5c635c48406435de8fd25e5.json
Prevent aspect from affecting rotate speed
examples/js/controls/OrbitControls.js
@@ -461,10 +461,8 @@ THREE.OrbitControls = function ( object, domElement ) { var element = scope.domElement === document ? scope.domElement.body : scope.domElement; - // rotating across whole screen goes 360 degrees around - rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth ); + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height - // rotating up and down along whole screen attempts to go 360, but limited to 180 rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); rotateStart.copy( rotateEnd ); @@ -611,10 +609,8 @@ THREE.OrbitControls = function ( object, domElement ) { var element = scope.domElement === document ? scope.domElement.body : scope.domElement; - // rotating across whole screen goes 360 degrees around - rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth ); + rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height - // rotating up and down along whole screen attempts to go 360, but limited to 180 rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight ); rotateStart.copy( rotateEnd );
false
Other
mrdoob
three.js
243e853a4f93f30a1a983575d02cac01a2727dd8.json
Remove MMD KeyframeTrackEx
examples/js/loaders/MMDLoader.js
@@ -354,7 +354,15 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) { } - return new THREE.MMDLoader[ type ]( node, times, values, interpolations ); + var track = new THREE[ type ]( node, times, values ); + + track.createInterpolant = function InterpolantFactoryMethodCubicBezier( result ) { + + return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, new Float32Array( interpolations ) ); + + }; + + return track; }; @@ -378,16 +386,6 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) { position.add( center ); position.applyQuaternion( quaternion ); - /* - * Note: This is a workaround not to make Animation system calculate lerp - * if the diff from the last frame is 1 frame (in 30fps). - */ - if ( times.length > 0 && time < times[ times.length - 1 ] + ( 1 / 30 ) * 1.5 ) { - - times[ times.length - 1 ] = time - 1e-13; - - } - times.push( time ); pushVector3( centers, center ); @@ -419,10 +417,10 @@ THREE.MMDLoader.prototype.pourVmdIntoCamera = function ( camera, vmd, name ) { var tracks = []; - tracks.push( createTrack( '.center', 'VectorKeyframeTrackEx', times, centers, cInterpolations ) ); - tracks.push( createTrack( '.quaternion', 'QuaternionKeyframeTrackEx', times, quaternions, qInterpolations ) ); - tracks.push( createTrack( '.position', 'VectorKeyframeTrackEx', times, positions, pInterpolations ) ); - tracks.push( createTrack( '.fov', 'NumberKeyframeTrackEx', times, fovs, fInterpolations ) ); + tracks.push( createTrack( '.center', 'VectorKeyframeTrack', times, centers, cInterpolations ) ); + tracks.push( createTrack( '.quaternion', 'QuaternionKeyframeTrack', times, quaternions, qInterpolations ) ); + tracks.push( createTrack( '.position', 'VectorKeyframeTrack', times, positions, pInterpolations ) ); + tracks.push( createTrack( '.fov', 'NumberKeyframeTrack', times, fovs, fInterpolations ) ); var clip = new THREE.AnimationClip( name === undefined ? THREE.Math.generateUUID() : name, - 1, tracks ); @@ -1528,6 +1526,20 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) { }; + var createTrack = function ( node, type, times, values, interpolations ) { + + var track = new THREE[ type ]( node, times, values ); + + track.createInterpolant = function InterpolantFactoryMethodCubicBezier( result ) { + + return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, new Float32Array( interpolations ) ); + + }; + + return track; + + }; + for ( var i = 0; i < orderedMotions.length; i ++ ) { var times = []; @@ -1574,8 +1586,8 @@ THREE.MMDLoader.prototype.createAnimation = function ( mesh, vmd, name ) { var boneName = '.bones[' + bone.name + ']'; - tracks.push( new THREE.MMDLoader.VectorKeyframeTrackEx( boneName + '.position', times, positions, pInterpolations ) ); - tracks.push( new THREE.MMDLoader.QuaternionKeyframeTrackEx( boneName + '.quaternion', times, rotations, rInterpolations ) ); + tracks.push( createTrack( boneName + '.position', 'VectorKeyframeTrack', times, positions, pInterpolations ) ); + tracks.push( createTrack( boneName + '.quaternion', 'QuaternionKeyframeTrack', times, rotations, rInterpolations ) ); } @@ -1759,83 +1771,6 @@ THREE.MMDLoader.DataCreationHelper.prototype = { }; -/* - * extends existing KeyframeTrack for bone and camera animation. - * - use Float64Array for times - * - use Cubic Bezier curves interpolation - */ -THREE.MMDLoader.VectorKeyframeTrackEx = function ( name, times, values, interpolationParameterArray ) { - - this.interpolationParameters = new Float32Array( interpolationParameterArray ); - - THREE.VectorKeyframeTrack.call( this, name, times, values ); - -}; - -THREE.MMDLoader.VectorKeyframeTrackEx.prototype = Object.create( THREE.VectorKeyframeTrack.prototype ); -THREE.MMDLoader.VectorKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.VectorKeyframeTrackEx; -THREE.MMDLoader.VectorKeyframeTrackEx.prototype.TimeBufferType = Float64Array; - -THREE.MMDLoader.VectorKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) { - - return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters ); - -}; - -THREE.MMDLoader.VectorKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) { - - this.createInterpolant = this.InterpolantFactoryMethodCubicBezier; - -}; - -THREE.MMDLoader.QuaternionKeyframeTrackEx = function ( name, times, values, interpolationParameterArray ) { - - this.interpolationParameters = new Float32Array( interpolationParameterArray ); - - THREE.QuaternionKeyframeTrack.call( this, name, times, values ); - -}; - -THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype = Object.create( THREE.QuaternionKeyframeTrack.prototype ); -THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.QuaternionKeyframeTrackEx; -THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.TimeBufferType = Float64Array; - -THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) { - - return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters ); - -}; - -THREE.MMDLoader.QuaternionKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) { - - this.createInterpolant = this.InterpolantFactoryMethodCubicBezier; - -}; - -THREE.MMDLoader.NumberKeyframeTrackEx = function ( name, times, values, interpolationParameterArray ) { - - this.interpolationParameters = new Float32Array( interpolationParameterArray ); - - THREE.NumberKeyframeTrack.call( this, name, times, values ); - -}; - -THREE.MMDLoader.NumberKeyframeTrackEx.prototype = Object.create( THREE.NumberKeyframeTrack.prototype ); -THREE.MMDLoader.NumberKeyframeTrackEx.prototype.constructor = THREE.MMDLoader.NumberKeyframeTrackEx; -THREE.MMDLoader.NumberKeyframeTrackEx.prototype.TimeBufferType = Float64Array; - -THREE.MMDLoader.NumberKeyframeTrackEx.prototype.InterpolantFactoryMethodCubicBezier = function ( result ) { - - return new THREE.MMDLoader.CubicBezierInterpolation( this.times, this.values, this.getValueSize(), result, this.interpolationParameters ); - -}; - -THREE.MMDLoader.NumberKeyframeTrackEx.prototype.setInterpolation = function ( interpolation ) { - - this.createInterpolant = this.InterpolantFactoryMethodCubicBezier; - -}; - THREE.MMDLoader.CubicBezierInterpolation = function ( parameterPositions, sampleValues, sampleSize, resultBuffer, params ) { THREE.Interpolant.call( this, parameterPositions, sampleValues, sampleSize, resultBuffer ); @@ -1856,7 +1791,8 @@ THREE.MMDLoader.CubicBezierInterpolation.prototype.interpolate_ = function ( i1, var offset1 = i1 * stride; var offset0 = offset1 - stride; - var weight1 = ( t - t0 ) / ( t1 - t0 ); + // No interpolation if next key frame is in one frame in 30fps. This is from MMD animation spec. + var weight1 = ( ( t1 - t0 ) < 1 / 30 * 1.5 ) ? 0.0 : ( t - t0 ) / ( t1 - t0 ); if ( stride === 4 ) { // Quaternion
false
Other
mrdoob
three.js
4da3cc11407434a6ccc75d8789b2622cb02a57cb.json
Add uuid field to AnimationClip.toJSON When converting the scene to JSON all objects except animation clips have uuid fields included. This change adds the uuid to the JSON object for AnimationClips.
src/animation/AnimationClip.js
@@ -59,7 +59,8 @@ Object.assign( AnimationClip, { 'name': clip.name, 'duration': clip.duration, - 'tracks': tracks + 'tracks': tracks, + 'uuid': clip.uuid };
false
Other
mrdoob
three.js
65ea3db93aa8ea6cdff9f9dce185b936840f79af.json
add rotateOnWorldAxis method to Object3D
docs/api/core/Object3D.html
@@ -320,6 +320,15 @@ <h3>[method:Object3D rotateOnAxis]( [page:Vector3 axis], [page:Float angle] )</h Rotate an object along an axis in object space. The axis is assumed to be normalized. </div> + <h3>[method:Object3D rotateOnWorldAxis]( [page:Vector3 axis], [page:Float angle] )</h3> + <div> + axis -- A normalized vector in world space. <br /> + angle -- The angle in radians.<br /><br /> + + Rotate an object along an axis in world space. The axis is assumed to be normalized. + Method Assumes no rotated parent. + </div> + <h3>[method:null rotateX]( [page:Float rad] )</h3> <div> rad - the angle to rotate in radians.<br /><br />
true
Other
mrdoob
three.js
65ea3db93aa8ea6cdff9f9dce185b936840f79af.json
add rotateOnWorldAxis method to Object3D
src/core/Object3D.js
@@ -170,6 +170,26 @@ Object.assign( Object3D.prototype, EventDispatcher.prototype, { }(), + rotateOnWorldAxis: function () { + + // rotate object on axis in world space + // axis is assumed to be normalized + // method assumes no rotated parent + + var q1 = new Quaternion(); + + return function rotateOnWorldAxis(axis, angle) { + + q1.setFromAxisAngle(axis, angle); + + this.quaternion.premultiply(q1); + + return this; + + }; + + }(), + rotateX: function () { var v1 = new Vector3( 1, 0, 0 );
true
Other
mrdoob
three.js
5408bd8978e9be03ef7ca70d8f57963bdb780878.json
Add inLineCurve3 check
src/extras/core/CurvePath.js
@@ -171,8 +171,9 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), { var curve = curves[ i ]; var resolution = ( curve && curve.isEllipseCurve ) ? divisions * 2 : ( curve && curve.isLineCurve ) ? 1 - : ( curve && curve.isSplineCurve ) ? divisions * curve.points.length - : divisions; + : ( curve && curve.isLineCurve3 ) ? 1 + : ( curve && curve.isSplineCurve ) ? divisions * curve.points.length + : divisions; var pts = curve.getPoints( resolution );
false